@tricoteuses/tisseuse 0.14.19 → 0.15.1

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/dist/server.js CHANGED
@@ -1,11 +1,11 @@
1
- import { A as e, Ct as t, D as n, E as r, Ft as i, It as a, L as o, O as s, Ot as c, S as l, St as u, T as d, Tt as f, X as p, Z as m, _ as h, at as g, b as _, c as v, k as y, m as b, n as x, p as ee, q as S, rt as C, s as te, t as ne, u as re, vt as ie, w as ae, wt as w, x as oe } from "./html-BmJb9-6k.js";
2
- import { Dt as T, Et as E, F as se, N as ce, Nt as D, O as le, Tt as ue, ct as de, et as fe, ht as pe, jt as O, k as me, n as he, o as ge, r as _e, t as ve, vt as k } from "./resolver-CuP8arVX.js";
3
- import * as ye from "node:crypto";
4
- import { createHash as be } from "node:crypto";
5
- import A from "fs-extra";
6
- import j from "node:path";
1
+ import { A as e, Ct as t, D as n, E as r, Ft as i, It as a, L as o, O as s, Ot as c, P as l, S as u, St as d, T as f, Tt as p, X as m, Z as h, _ as g, at as _, b as v, c as y, h as b, k as x, m as ee, n as S, p as te, q as C, rt as ne, s as re, t as ie, tt as ae, u as oe, vt as se, w as ce, wt as w, x as le, y as ue } from "./html-D5hxZhPd.js";
2
+ import { Dt as T, Et as E, F as de, I as fe, N as pe, Nt as D, O as me, Tt as O, ct as he, et as ge, ht as _e, jt as k, k as ve, n as ye, o as be, r as xe, t as Se, vt as A } from "./resolver-CuP8arVX.js";
3
+ import * as Ce from "node:crypto";
4
+ import { createHash as we } from "node:crypto";
5
+ import j from "fs-extra";
6
+ import M from "node:path";
7
7
  //#region src/lib/server/assemblee_amendment_search.ts
8
- function xe(e, t) {
8
+ function Te(e, t) {
9
9
  let n = e;
10
10
  for (let e of t) {
11
11
  if (typeof n != "object" || !n) return null;
@@ -13,34 +13,34 @@ function xe(e, t) {
13
13
  }
14
14
  return typeof n == "string" && n.trim() ? n.trim() : null;
15
15
  }
16
- function Se(e) {
16
+ function Ee(e) {
17
17
  return e.replace(/\u00a0/gu, " ").replace(/\s+/gu, " ").trim();
18
18
  }
19
- function Ce(e) {
20
- return Se(g(e).text());
19
+ function De(e) {
20
+ return Ee(_(e).text());
21
21
  }
22
- function we(e) {
23
- let t = Se([
24
- xe(e, [
22
+ function Oe(e) {
23
+ let t = Ee([
24
+ Te(e, [
25
25
  "corps",
26
26
  "contenuAuteur",
27
27
  "dispositif"
28
28
  ]),
29
- xe(e, [
29
+ Te(e, [
30
30
  "corps",
31
31
  "contenuAuteur",
32
32
  "dispositifAmdtCreditPLF"
33
33
  ]),
34
- xe(e, [
34
+ Te(e, [
35
35
  "corps",
36
36
  "contenuAuteur",
37
37
  "dispositifAmdtCreditPLFR"
38
38
  ])
39
- ].filter((e) => e !== null).map((e) => Ce(e)).join("\n")), n = xe(e, [
39
+ ].filter((e) => e !== null).map((e) => De(e)).join("\n")), n = Te(e, [
40
40
  "corps",
41
41
  "contenuAuteur",
42
42
  "exposeSommaire"
43
- ]), r = n === null ? "" : Ce(n);
43
+ ]), r = n === null ? "" : De(n);
44
44
  return [...t ? [{
45
45
  content: t,
46
46
  itemKind: "dispositif",
@@ -51,37 +51,158 @@ function we(e) {
51
51
  label: "Exposé sommaire"
52
52
  }] : []];
53
53
  }
54
- function Te(e, t) {
55
- return be("sha256").update(JSON.stringify({
54
+ function ke(e, t) {
55
+ return we("sha256").update(JSON.stringify({
56
56
  item: e,
57
57
  metadata: t
58
58
  })).digest("hex");
59
59
  }
60
60
  //#endregion
61
+ //#region src/lib/extractors/article_action_targets.ts
62
+ function N(e) {
63
+ switch (e.type) {
64
+ case "reference_et_action": return N(e.reference);
65
+ case "enumeration": return [...N(e.left), ...N(e.right)];
66
+ case "parent-enfant": {
67
+ let t = [...i(e.parent)].filter((e) => e.type === "article");
68
+ return t.length === 1 ? [{
69
+ article: t[0],
70
+ reference: e
71
+ }] : t.length > 1 ? [] : N(e.child).map((t) => ({
72
+ article: t.article,
73
+ reference: {
74
+ ...e,
75
+ child: t.reference,
76
+ position: {
77
+ start: Math.min(e.parent.position.start, t.reference.position.start),
78
+ stop: Math.max(e.parent.position.stop, t.reference.position.stop)
79
+ }
80
+ }
81
+ }));
82
+ }
83
+ case "article": return [{
84
+ article: e,
85
+ reference: e
86
+ }];
87
+ default: return [];
88
+ }
89
+ }
90
+ //#endregion
91
+ //#region src/lib/extractors/article_action_effects.ts
92
+ function Ae(e, t) {
93
+ if (t < 2) return null;
94
+ let n = ve(e), r = b(e);
95
+ if (r.length !== t) return null;
96
+ let i = l(new O(n.output)), a = (e) => fe(n, [e])[0].position;
97
+ return r.map((t, n) => ({
98
+ sourceText: e,
99
+ referencePosition: a({
100
+ start: (n === 0 ? i.find((e) => e.position.start <= t.reference.position.start && e.position.stop >= t.reference.position.stop) : void 0)?.position.start ?? t.reference.position.start,
101
+ stop: t.reference.position.stop
102
+ }),
103
+ actionPosition: a(t.position)
104
+ }));
105
+ }
106
+ function je(e, t) {
107
+ if (t.length < 2) return null;
108
+ let n = ve(e), r = n.output, i = (e) => fe(n, [e])[0].position, a = l(new O(r)), o = a.flatMap(N);
109
+ if (o.length !== t.length || o.length < 2) return null;
110
+ let s = o.filter(({ reference: e }) => e.type === "parent-enfant" && e.parent.type === "texte" && e.parent.nature !== "CODE");
111
+ if (s.length > 0 && s.length < o.length) {
112
+ let n = o.filter((e) => !s.includes(e));
113
+ if (n.length !== 1) return null;
114
+ let a = n[0], c = t[o.indexOf(a)], l = ue(r);
115
+ return !c || l.length !== 1 || l[0].kind === "compound" ? null : [{
116
+ targetId: c,
117
+ sourceAnnotation: {
118
+ sourceText: e,
119
+ referencePosition: i(a.reference.position),
120
+ actionPosition: {
121
+ start: 0,
122
+ stop: e.length
123
+ }
124
+ },
125
+ directive: {
126
+ ...l[0],
127
+ reference: a.reference,
128
+ sourcePosition: {
129
+ start: 0,
130
+ stop: r.length
131
+ },
132
+ sourceText: r
133
+ }
134
+ }];
135
+ }
136
+ let c = [], u = 0;
137
+ for (let e = 1; e < a.length; e += 1) {
138
+ let t = a[e];
139
+ t.type !== "reference_et_action" || N(t).length === 0 || a.slice(u, e).flatMap(N).length === 0 || ue(r.slice(u === 0 ? 0 : a[u].position.start, t.position.start)).length === 1 && ue(r.slice(t.position.start)).length === 1 && (c.push(e - 1), u = e);
140
+ }
141
+ c.push(a.length - 1);
142
+ let d = [], f = 0, p = 0;
143
+ for (let n of c) {
144
+ let o = a.slice(f, n + 1).flatMap(N);
145
+ if (o.length === 0) {
146
+ f = n + 1;
147
+ continue;
148
+ }
149
+ let s = f === 0 ? 0 : a[f].position.start, c = a[n + 1]?.position.start ?? r.length, l = ue(r.slice(s, c));
150
+ if (l.length !== 1 || l[0].kind === "compound") return null;
151
+ let u = l[0];
152
+ for (let n of o) {
153
+ let a = t[p++];
154
+ if (!a) return null;
155
+ d.push({
156
+ targetId: a,
157
+ sourceAnnotation: {
158
+ sourceText: e,
159
+ referencePosition: i(n.reference.position),
160
+ actionPosition: i({
161
+ start: s,
162
+ stop: c
163
+ })
164
+ },
165
+ directive: {
166
+ ...u,
167
+ sourceText: r,
168
+ sourcePosition: {
169
+ start: 0,
170
+ stop: r.length
171
+ },
172
+ reference: n.reference,
173
+ portionSelectors: ae(n.reference)
174
+ }
175
+ });
176
+ }
177
+ f = n + 1;
178
+ }
179
+ return p === t.length ? d : null;
180
+ }
181
+ //#endregion
61
182
  //#region src/lib/server/parsed_bills.ts
62
- var Ee = /^expos[ée]\s+des\s+motifs\b/iu;
63
- function M(e) {
183
+ var Me = /^expos[ée]\s+des\s+motifs\b/iu;
184
+ function P(e) {
64
185
  return (e ?? "").replace(/\u00a0/g, " ").replace(/\s+/g, " ").trim();
65
186
  }
66
- function N(e) {
67
- return M(e).toLowerCase().normalize("NFD").replace(/\p{Diacritic}/gu, "");
187
+ function F(e) {
188
+ return P(e).toLowerCase().normalize("NFD").replace(/\p{Diacritic}/gu, "");
68
189
  }
69
- function De(e) {
70
- return u(M(e));
190
+ function Ne(e) {
191
+ return d(P(e));
71
192
  }
72
- function Oe(e) {
73
- return `_TocArt${De(e).replace(/\s+/gu, "")}`;
193
+ function I(e) {
194
+ return `_TocArt${Ne(e).replace(/\s+/gu, "")}`;
74
195
  }
75
- function ke(e, t) {
196
+ function Pe(e, t) {
76
197
  return e(t).closest(".assnatTOC6,.assnatTOC5,.assnatTOC4").length > 0;
77
198
  }
78
- function Ae(e) {
79
- return N(e).replace(/[‐‑‒–—]/gu, "-").replace(/\s*\.\s*/gu, ".");
199
+ function Fe(e) {
200
+ return F(e).replace(/[‐‑‒–—]/gu, "-").replace(/\s*\.\s*/gu, ".");
80
201
  }
81
- function je(e) {
82
- return Ae(e).replace(/[^a-z0-9]+/gu, "-").replace(/^-|-$/gu, "");
202
+ function Ie(e) {
203
+ return Fe(e).replace(/[^a-z0-9]+/gu, "-").replace(/^-|-$/gu, "");
83
204
  }
84
- function Me(e) {
205
+ function Le(e) {
85
206
  switch (e.kind) {
86
207
  case "insert_after":
87
208
  case "insert_before": return e.insertText;
@@ -99,12 +220,12 @@ function Me(e) {
99
220
  default: return;
100
221
  }
101
222
  }
102
- function Ne(e) {
103
- let n = M(e.sourceText), r = /\b(?:ins[ée]r[ée]s?|cr[ée][ée]s?|ajout[ée]s?|compl[ée]t[ée]s?\s+par)\b[\s\S]{0,160}?\barticle\s+(.+?)\s+ainsi\s+r[ée]dig[ée]s?\b/iu.exec(n);
223
+ function Re(e) {
224
+ let n = P(e.sourceText), r = /\b(?:ins[ée]r[ée]s?|cr[ée][ée]s?|ajout[ée]s?|compl[ée]t[ée]s?\s+par)\b[\s\S]{0,160}?\barticle\s+(.+?)\s+ainsi\s+r[ée]dig[ée]s?\b/iu.exec(n);
104
225
  if (r?.[1] !== void 0) return t(r[1]);
105
226
  }
106
- function Pe(e) {
107
- let t = Me(e), n = ie(t ?? "");
227
+ function ze(e) {
228
+ let t = Le(e), n = se(t ?? "");
108
229
  if (n.length > 0 && t !== void 0) return n.map((e, r) => {
109
230
  let i = e.start, a = n[r + 1]?.start ?? t.length, o = t.slice(i, a).trim();
110
231
  return {
@@ -112,58 +233,58 @@ function Pe(e) {
112
233
  text: o
113
234
  };
114
235
  });
115
- let r = Ne(e);
236
+ let r = Re(e);
116
237
  return r === void 0 ? [] : [{
117
238
  num: r,
118
239
  text: t ?? e.sourceText
119
240
  }];
120
241
  }
121
- function Fe(e, t = /* @__PURE__ */ new Set()) {
242
+ function Be(e, t = /* @__PURE__ */ new Set()) {
122
243
  if (e == null) return t;
123
244
  if (Array.isArray(e)) {
124
- for (let n of e) Fe(n, t);
245
+ for (let n of e) Be(n, t);
125
246
  return t;
126
247
  }
127
248
  if (typeof e != "object") return t;
128
249
  let n = e;
129
250
  n.type === "article" && typeof n.num == "string" && t.add(n.num);
130
- for (let e of Object.values(n)) Fe(e, t);
251
+ for (let e of Object.values(n)) Be(e, t);
131
252
  return t;
132
253
  }
133
- function Ie(e) {
134
- let t = N(e.sourceText);
254
+ function Ve(e) {
255
+ let t = F(e.sourceText);
135
256
  return /\b(?:cree|cree[e]?s?|resultant|issu|prevu|mentionne)\b[\s\S]{0,80}\b(?:present|presente|pjl|projet\s+de\s+loi)\b/u.test(t);
136
257
  }
137
- function Le(e) {
138
- return M(e).replace(/[’']/gu, "'").replace(/[‐‑‒–—]/gu, "-");
258
+ function He(e) {
259
+ return P(e).replace(/[’']/gu, "'").replace(/[‐‑‒–—]/gu, "-");
139
260
  }
140
- function Re(e, t) {
141
- let n = new ue(e, t), r = fe(n);
261
+ function Ue(e, t) {
262
+ let n = new O(e, t), r = ge(n);
142
263
  return typeof r != "string" || n.offset <= t ? null : {
143
264
  date: r,
144
265
  start: t,
145
266
  stop: n.offset
146
267
  };
147
268
  }
148
- function ze(e, t) {
269
+ function We(e, t) {
149
270
  let n = /\d/u.exec(e.slice(t));
150
271
  if (!n) return null;
151
272
  let r = t + n.index;
152
- return e.slice(t, r).trim().length > 0 ? null : Re(e, r);
273
+ return e.slice(t, r).trim().length > 0 ? null : Ue(e, r);
153
274
  }
154
- function Be(e) {
275
+ function Ge(e) {
155
276
  let t = /^la présente loi (?:s['’]appli(?:que|quent)|entr(?:e|ent) en vigueur) (?:[aà] compter (?:du|de|d['’])|au|le)\s*/u, n = /^la présente loi s['’]appli(?:que|quent)\s*:\s*/u, r = /\b[aà] compter (?:du|de|d['’])\s*/gu, i = [], a = "la présente loi", o = e.indexOf(a);
156
277
  for (; o !== -1;) {
157
278
  let s = e.indexOf(a, o + 15), c = e.slice(o, o + 1400), l = t.exec(c);
158
279
  if (l) {
159
- let e = ze(c, l[0].length);
280
+ let e = We(c, l[0].length);
160
281
  e && i.push(e.date);
161
282
  }
162
283
  let u = n.exec(c);
163
284
  if (u) {
164
285
  let e = /\barticle\s+\w/iu.exec(c), t = e === null ? c.slice(u[0].length) : c.slice(u[0].length, e.index);
165
286
  for (r.lastIndex = 0; r.exec(t) !== null;) {
166
- let e = ze(t, r.lastIndex);
287
+ let e = We(t, r.lastIndex);
167
288
  e && /^\s+pour\s+les\s+autres\s+dispositions\s+fiscales\b/iu.test(t.slice(e.stop)) && i.push(e.date);
168
289
  }
169
290
  }
@@ -171,20 +292,20 @@ function Be(e) {
171
292
  }
172
293
  return i;
173
294
  }
174
- function Ve(e) {
175
- let t = Be(Le(e).toLowerCase()), n = Array.from(new Set(t));
295
+ function Ke(e) {
296
+ let t = Ge(He(e).toLowerCase()), n = Array.from(new Set(t));
176
297
  return n.length === 1 ? n[0] : void 0;
177
298
  }
178
- function He(e) {
179
- return N(e).replace(/[’]/gu, "'").replace(/[‐‑‒–—]/gu, "-").replace(/^(?:(?:article\s+[^:]+|[a-z][.)]|[ivxlcdm]+\.|\d+°)\s*(?:-\s*)?)+/iu, "");
299
+ function qe(e) {
300
+ return F(e).replace(/[’]/gu, "'").replace(/[‐‑‒–—]/gu, "-").replace(/^(?:(?:article\s+[^:]+|[a-z][.)]|[ivxlcdm]+\.|\d+°)\s*(?:-\s*)?)+/iu, "");
180
301
  }
181
- function P(e) {
302
+ function L(e) {
182
303
  return e?.type === "tag";
183
304
  }
184
- function Ue(e, t) {
305
+ function Je(e, t) {
185
306
  return e.html(t) ?? "";
186
307
  }
187
- function We(e, t) {
308
+ function Ye(e, t) {
188
309
  let n = [], r = /* @__PURE__ */ new Set();
189
310
  for (let i of e(t).find("a").get()) {
190
311
  let a = e(i).attr("href") ?? "", o = /\/legifrance\/(articles|sections|textes)\/([^?#"]+)/u.exec(a);
@@ -192,46 +313,46 @@ function We(e, t) {
192
313
  let s = o[1] === "articles" ? "article" : o[1] === "sections" ? "division" : "text", c = o[2].replace(/\.md$/u, ""), l = `${s}\0${c}`;
193
314
  if (r.has(l)) continue;
194
315
  r.add(l);
195
- let u = M(e(i).text());
316
+ let u = P(e(i).text());
196
317
  n.push({
197
318
  id: c,
198
- ...Ge(e, t, i) ? { insideFrenchQuotes: !0 } : {},
319
+ ...Xe(e, t, i) ? { insideFrenchQuotes: !0 } : {},
199
320
  ...u ? { text: u } : {},
200
321
  type: s
201
322
  });
202
323
  }
203
324
  return n;
204
325
  }
205
- function Ge(e, t, n) {
206
- let r = Ke(e, t, n);
326
+ function Xe(e, t, n) {
327
+ let r = Ze(e, t, n);
207
328
  return (r.match(/«/gu) ?? []).length > (r.match(/»/gu) ?? []).length;
208
329
  }
209
- function Ke(e, t, n) {
330
+ function Ze(e, t, n) {
210
331
  if (t === n) return "";
211
332
  if (t.type === "text") return t.data ?? "";
212
- if (!P(t)) return "";
333
+ if (!L(t)) return "";
213
334
  let r = "";
214
335
  for (let i of e(t).contents().get()) {
215
336
  if (i === n) return r;
216
- if (P(i) && e.contains(i, n)) return r + Ke(e, i, n);
337
+ if (L(i) && e.contains(i, n)) return r + Ze(e, i, n);
217
338
  r += e(i).text();
218
339
  }
219
340
  return r;
220
341
  }
221
- function qe(e, t) {
222
- return t.map((t) => M(e(t).text())).filter(Boolean).join("\n");
342
+ function Qe(e, t) {
343
+ return t.map((t) => P(e(t).text())).filter(Boolean).join("\n");
223
344
  }
224
- function Je(e) {
225
- let t = N(e);
226
- return !t || Ee.test(t) ? "noise" : r.test(e) ? "directive_candidate" : "context";
345
+ function $e(e) {
346
+ let t = F(e);
347
+ return !t || Me.test(t) ? "noise" : r.test(e) ? "directive_candidate" : "context";
227
348
  }
228
- async function Ye(e, t, n) {
349
+ async function et(e, t, n) {
229
350
  if (n === void 0) throw Error("A document date is required to add links to legal references.");
230
351
  if (t.legiResolver === void 0 && t.canutesDb === void 0) throw Error("A Canutes database or an explicit legal resolver is required to add links to legal references.");
231
- let { output: r } = await x({
352
+ let { output: r } = await S({
232
353
  date: n,
233
354
  html: e,
234
- legiResolver: t.legiResolver ?? new ee(t.canutesDb),
355
+ legiResolver: t.legiResolver ?? new te(t.canutesDb),
235
356
  linkBaseUrl: t.linkBaseUrl,
236
357
  linkType: t.linkType,
237
358
  logIgnoredReferencesTypes: t.logIgnoredReferencesTypes,
@@ -240,13 +361,13 @@ async function Ye(e, t, n) {
240
361
  });
241
362
  return r ?? e;
242
363
  }
243
- function Xe(e, t) {
364
+ function tt(e, t) {
244
365
  let n = e(t).closest("h1,h2,h3,h4,h5,h6,p,td,th").get(0), r = e(t).closest("table").get(0);
245
- return P(r) && P(n) && e(n).parents("table").get(0) === r ? r : P(n) ? n : t;
366
+ return L(r) && L(n) && e(n).parents("table").get(0) === r ? r : L(n) ? n : t;
246
367
  }
247
- function Ze(e, t, n, r) {
368
+ function nt(e, t, n, r) {
248
369
  if (t.has(r.container)) return;
249
- let i = r.id ?? Oe(r.num ?? r.label);
370
+ let i = r.id ?? I(r.num ?? r.label);
250
371
  n.has(i) || (n.add(i), t.add(r.container), e.push({
251
372
  id: i,
252
373
  label: r.label,
@@ -256,25 +377,25 @@ function Ze(e, t, n, r) {
256
377
  container: r.container
257
378
  }));
258
379
  }
259
- function Qe(e) {
380
+ function rt(e) {
260
381
  let t = /* @__PURE__ */ new Map();
261
382
  return e("body *").each((e, n) => {
262
383
  t.set(n, e);
263
384
  }), t;
264
385
  }
265
- function F(e, t) {
386
+ function R(e, t) {
266
387
  return e.get(t) ?? 2 ** 53 - 1;
267
388
  }
268
- function $e(e) {
389
+ function it(e) {
269
390
  let t = [], n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set();
270
391
  e("a[id], span[id], h1[id], h2[id], h3[id], h4[id], h5[id], h6[id]").each((i, a) => {
271
- if (ke(e, a)) return;
272
- let o = w(M(e(a).text()));
392
+ if (Pe(e, a)) return;
393
+ let o = w(P(e(a).text()));
273
394
  if (!o) return;
274
395
  let s = e(a).attr("id");
275
396
  if (!s || r.has(s)) return;
276
- let c = Xe(e, a);
277
- Ze(t, n, r, {
397
+ let c = tt(e, a);
398
+ nt(t, n, r, {
278
399
  id: s,
279
400
  ...o,
280
401
  element: a,
@@ -282,97 +403,161 @@ function $e(e) {
282
403
  });
283
404
  }), e("h1:not([id]), h2:not([id]), h3:not([id]), h4:not([id]), h5:not([id]), h6:not([id])").each((i, a) => {
284
405
  if (n.has(a)) return;
285
- let o = w(M(e(a).text()));
286
- o && Ze(t, n, r, {
406
+ let o = w(P(e(a).text()));
407
+ o && nt(t, n, r, {
287
408
  ...o,
288
409
  element: a,
289
410
  container: a
290
411
  });
291
412
  });
292
- let i = Qe(e);
293
- return t.sort((e, t) => F(i, e.container) - F(i, t.container)), t;
413
+ let i = rt(e);
414
+ return t.sort((e, t) => R(i, e.container) - R(i, t.container)), t;
294
415
  }
295
- function et(e, t) {
296
- if (ke(e, t)) return !1;
416
+ function at(e, t) {
417
+ if (Pe(e, t)) return !1;
297
418
  let n = t.tagName?.toLowerCase();
298
419
  if (n !== "p") return /^h[1-6]$/u.test(n ?? "");
299
420
  let r = e(t).attr("style") ?? "", i = e(t).html() ?? "";
300
421
  return /text-align\s*:\s*center/iu.test(r) && (/font-weight\s*:\s*bold/iu.test(r) || /font-weight\s*:\s*bold/iu.test(i) || /<(?:strong|b)(?:\s|>)/iu.test(i));
301
422
  }
302
- function tt(e) {
423
+ function ot(e) {
303
424
  let t = [], n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set();
304
425
  return e("p.assnat9ArticleNum,h1,h2,h3,h4,h5,h6,p").each((i, a) => {
305
- if (ke(e, a) || !e(a).hasClass("assnat9ArticleNum") && !et(e, a)) return;
426
+ if (Pe(e, a) || !e(a).hasClass("assnat9ArticleNum") && !at(e, a)) return;
306
427
  let o = w(e(a).text());
307
- o && Ze(t, n, r, {
428
+ o && nt(t, n, r, {
308
429
  ...o,
309
430
  element: a,
310
431
  container: a
311
432
  });
312
433
  }), t;
313
434
  }
314
- function nt(e) {
315
- let t = N(De(e ?? "")).replace(/[()]/gu, "").trim();
316
- if (!t || t === "liminaire") return;
317
- if (t === "unique") return {
435
+ function st(e) {
436
+ let t = Ne(e ?? "").replace(/[()]/gu, "").trim();
437
+ if (!t || t.toLowerCase() === "liminaire") return;
438
+ if (t.toLowerCase() === "unique") return {
318
439
  base: 1,
319
440
  suffixOrder: 0,
320
- text: t
441
+ text: "unique"
321
442
  };
322
- let n = /^(?:(\d+)|1er|premier)(?:\s+([a-z]+))?$/u.exec(t);
443
+ let n = /^(\d+|premier)(?:\s+([a-z]+))?(?:\s+([A-Z]+))?$/u.exec(t);
323
444
  if (!n) return;
324
- let r = n[1] === void 0 ? 1 : Number.parseInt(n[1], 10), i = n[2], a = i === void 0 ? 0 : rt(i);
445
+ let r = n[1] === "premier" ? 1 : Number.parseInt(n[1], 10), i = n[2], a = i === void 0 ? 0 : lt(i);
325
446
  if (a !== void 0) return {
326
447
  base: r,
327
448
  suffixOrder: a,
449
+ letters: n[3],
328
450
  text: t
329
451
  };
330
452
  }
331
- function rt(e) {
332
- let t = new ue(e), n = de(t);
453
+ function ct(e, t) {
454
+ if (t.base !== e.base) return t.base - e.base;
455
+ if (t.suffixOrder !== e.suffixOrder) return t.suffixOrder - e.suffixOrder;
456
+ for (let n = 0; n <= Math.max(e.letters?.length ?? 0, t.letters?.length ?? 0); n++) {
457
+ let r = (t.letters?.[n]?.charCodeAt(0) ?? 91) - (e.letters?.[n]?.charCodeAt(0) ?? 91);
458
+ if (r !== 0) return r;
459
+ }
460
+ return 0;
461
+ }
462
+ function lt(e) {
463
+ let t = new O(e), n = he(t);
333
464
  if (!(n === void 0 || t.offset !== e.length) && !(typeof n != "object" || !n || !("value" in n) || typeof n.value != "number")) return n.value - 1;
334
465
  }
335
- function it(e) {
466
+ function ut(e) {
336
467
  let t = [], n = e.map((e) => ({
337
468
  heading: e,
338
- token: nt(e.num)
469
+ token: st(e.num)
339
470
  }));
340
- n.filter(({ token: e }) => e?.text === "unique").length > 0 && e.length > 1 && t.push("Article unique appears with other articles");
471
+ n.filter(({ token: e }) => e?.text === "unique").length > 0 && e.length > 1 && t.push({
472
+ code: "article_toc_out_of_order",
473
+ message: "Article unique appears with other articles"
474
+ });
341
475
  let r;
342
476
  for (let { heading: e, token: i } of n) if (!(i === void 0 || i.text === "unique")) {
343
477
  if (r !== void 0) {
344
- let n = r.base * 100 + r.suffixOrder;
345
- i.base * 100 + i.suffixOrder <= n ? t.push(`Article ${e.num ?? e.label} is out of order`) : (i.base === r.base && i.suffixOrder > r.suffixOrder + 1 || r.suffixOrder === 0 && i.suffixOrder === 0 && i.base > r.base + 1) && t.push(`Missing article between ${r.text} and ${i.text}`);
346
- } else i.suffixOrder > 0 && t.push(`Missing article before ${i.text}`);
478
+ let n = ct(r, i);
479
+ n === 0 ? t.push({
480
+ code: "article_toc_duplicate_number",
481
+ message: `Article ${e.num ?? e.label} is repeated`,
482
+ details: { article: e.label }
483
+ }) : n < 0 ? t.push({
484
+ code: "article_toc_out_of_order",
485
+ message: `Article ${e.num ?? e.label} is out of order`,
486
+ details: {
487
+ previous: r.text,
488
+ next: i.text
489
+ }
490
+ }) : (i.base > r.base + 1 || i.base === r.base && i.suffixOrder > r.suffixOrder + 1 || i.base === r.base && i.suffixOrder === r.suffixOrder && r.letters?.length === 1 && i.letters?.length === 1 && i.letters.charCodeAt(0) > r.letters.charCodeAt(0) + 1) && t.push({
491
+ code: "article_toc_number_gap",
492
+ message: `Missing article between ${r.text} and ${i.text}`,
493
+ details: {
494
+ previous: r.text,
495
+ next: i.text
496
+ }
497
+ });
498
+ } else i.suffixOrder > 0 && t.push({
499
+ code: "article_toc_number_gap",
500
+ message: `Missing article before ${i.text}`,
501
+ details: { next: i.text }
502
+ });
347
503
  r = i;
348
504
  }
349
- t.length > 0 && process.env.TISSEUSE_WARN_ASSEMBLEE_HEADING_SEQUENCE === "1" && console.warn("Incoherent Assemblée article heading sequence", { issues: t });
505
+ return t;
350
506
  }
351
- function at(e, { warn: t = !0 } = {}) {
352
- let n = $e(e);
353
- if (n.length > 0) return t && it(n), n;
354
- let r = tt(e);
355
- return t && it(r), r;
507
+ function dt(e) {
508
+ let t = ut(e);
509
+ t.length > 0 && process.env.TISSEUSE_WARN_ASSEMBLEE_HEADING_SEQUENCE === "1" && console.warn("Incoherent Assemblée article heading sequence", { issues: t.map((e) => e.message) });
356
510
  }
357
- function ot(e) {
511
+ function ft(e, { warn: t = !0 } = {}) {
512
+ let n = it(e), r = ot(e);
513
+ if (n.length === 0) return t && dt(r), r;
514
+ let i = rt(e), a = (e, t) => {
515
+ let n = new Set(e.map((e) => e.container)), r = new Set(e.map((e) => I(e.num ?? e.label)));
516
+ for (let i of t) {
517
+ let t = I(i.num ?? i.label);
518
+ n.has(i.container) || r.has(t) || (n.add(i.container), r.add(t), e.push(i));
519
+ }
520
+ return e.sort((e, t) => R(i, e.container) - R(i, t.container)), e;
521
+ }, o = r.filter((t) => e(t.element).is("p.assnat9ArticleNum,h1,h2,h3,h4,h5,h6")), s = a([...n], o), c = a([...s], r.filter((e) => !o.includes(e))), l = s.length >= 2 && ut(c).length > ut(s).length ? s : c;
522
+ return t && dt(l), l;
523
+ }
524
+ function pt(e) {
358
525
  let t = e.next;
359
526
  for (; t !== null;) {
360
- if (P(t)) return t;
527
+ if (L(t)) return t;
361
528
  t = t.next;
362
529
  }
363
530
  return null;
364
531
  }
365
- function st(e, t, n, r = Qe(e)) {
532
+ function mt(e, t, n) {
533
+ let r = e(t.container);
534
+ if (!r.is("p.assnat9ArticleNum")) return;
535
+ let i = r.parent(), a = i.parent();
536
+ if (!i.is("div") || i.children().length !== 1 || !a.is("div")) return;
537
+ let o = a.children().get();
538
+ if (o.length !== 3 && o.length !== 4 || o[0] !== i.get(0) || o[1]?.tagName !== "span" || P(e(o[1]).text()) !== "") return;
539
+ let s = o.length === 4 ? o[2] : void 0;
540
+ if (s !== void 0 && (s.tagName !== "p" || !e(s).hasClass("assnat9ArticleNum") || !/^\(non modifié\)$/iu.test(P(e(s).text())))) return;
541
+ let c = o.at(-1);
542
+ if (!(c.tagName !== "div" || n !== void 0 && e.contains(c, n.container) || e(c).find("p.assnat9ArticleNum,h1,h2,h3,h4,h5,h6").toArray().some((t) => w(e(t).text()) !== null))) return [
543
+ t.container,
544
+ ...s === void 0 ? [] : [s],
545
+ c
546
+ ];
547
+ }
548
+ function ht(e, t, n, r = rt(e)) {
366
549
  let i = [t.container], a = n?.container;
367
- for (let e = ot(t.container); e !== null && e !== a; e = ot(e)) i.push(e);
550
+ for (let e = pt(t.container); e !== null && e !== a; e = pt(e)) i.push(e);
368
551
  if (i.length > 1) return i;
369
- let o = F(r, t.container), s = a ? F(r, a) : -1;
552
+ let o = mt(e, t, n);
553
+ if (o !== void 0) return o;
554
+ let s = R(r, t.container), c = a ? R(r, a) : -1;
370
555
  return e("body > *").get().filter((e) => {
371
- let t = F(r, e);
372
- return t >= o && (s === -1 || t < s);
556
+ let t = R(r, e);
557
+ return t >= s && (c === -1 || t < c);
373
558
  });
374
559
  }
375
- function ct(e, t) {
560
+ function gt(e, t) {
376
561
  let n = [], r = /* @__PURE__ */ new Set();
377
562
  for (let i of t) {
378
563
  let t = "p,li,table", a = e(i).is(t) ? [i] : e(i).find(t).get();
@@ -380,105 +565,105 @@ function ct(e, t) {
380
565
  }
381
566
  return n;
382
567
  }
383
- function lt(e, t, n) {
568
+ function _t(e, t, n) {
384
569
  let r = [], i = !1;
385
- for (let a of ct(e, n)) {
386
- let n = M(e(a).text());
570
+ for (let a of gt(e, n)) {
571
+ let n = P(e(a).text());
387
572
  if (!n) continue;
388
- Ee.test(n) && (i = !0);
389
- let o = i ? "noise" : Je(n), s = `${t}-b${r.length + 1}`;
573
+ Me.test(n) && (i = !0);
574
+ let o = i ? "noise" : $e(n), s = `${t}-b${r.length + 1}`;
390
575
  e(a).attr("data-pjl-parsed-article-id", t), e(a).attr("data-pjl-parsed-block-id", s), r.push({
391
576
  id: s,
392
577
  articleId: t,
393
578
  kind: o,
394
- links: We(e, a),
579
+ links: Ye(e, a),
395
580
  text: n,
396
- html: Ue(e, a)
581
+ html: Je(e, a)
397
582
  });
398
583
  }
399
584
  return r;
400
585
  }
401
- function ut(e, t) {
586
+ function vt(e, t) {
402
587
  if (t.length === 0) return e;
403
588
  let n = `<div style="display: none;">\n${t.map((e) => `<p class="assnatTOC6"><a href="#${e.id}"><span class="assnatHyperlink" style="font-weight:bold; text-decoration:none; color:#000000">${e.label.toUpperCase()}</span></a></p>`).join("\n")}\n</div>`;
404
589
  return e.includes("class=\"assnatSection3\"") ? e.replace(/(<div class="assnatSection3">)/u, `${n}$1`) : e.includes("id=\"formCorrection:panel:1:table\"") ? e.replace(/(<div id="formCorrection:panel:1:table">)/u, `${n}$1`) : `${n}\n${e}`;
405
590
  }
406
- function dt(e) {
407
- let t = g(e), n = ft(t);
408
- for (let e of at(t, { warn: !1 })) {
409
- let r = Oe(e.num ?? e.label.replace(/^Article\s+/iu, "")), i = t(e.element), a = i.attr("id");
591
+ function yt(e) {
592
+ let t = _(e), n = bt(t);
593
+ for (let e of ft(t, { warn: !1 })) {
594
+ let r = I(e.num ?? e.label.replace(/^Article\s+/iu, "")), i = t(e.element), a = i.attr("id");
410
595
  if (a !== r) {
411
- if (a?.startsWith("_Toc") && !mt(n, a, e.element)) {
596
+ if (a?.startsWith("_Toc") && !Ct(n, a, e.element)) {
412
597
  let e = t("<span></span>").attr("id", a);
413
598
  i.before(e);
414
599
  let r = e.get(0);
415
- P(r) && I(n, a, r);
600
+ L(r) && xt(n, a, r);
416
601
  }
417
- a && pt(n, a, e.element), i.attr("id", r), I(n, r, e.element);
602
+ a && St(n, a, e.element), i.attr("id", r), xt(n, r, e.element);
418
603
  }
419
604
  }
420
- let r = at(t), i = Qe(t);
605
+ let r = ft(t), i = rt(t);
421
606
  for (let [e, a] of r.entries()) {
422
- let o = st(t, a, r[e + 1], i).flatMap((e) => t(e).is("span.alinea[data-alinea]") ? [e] : t(e).find("span.alinea[data-alinea]").get());
607
+ let o = ht(t, a, r[e + 1], i).flatMap((e) => t(e).is("span.alinea[data-alinea]") ? [e] : t(e).find("span.alinea[data-alinea]").get());
423
608
  for (let e of o) {
424
609
  let r = t(e).attr("data-alinea")?.trim();
425
610
  if (!r) continue;
426
611
  let i = `${a.id}-alinea-${r.replace(/\s+/gu, "")}`;
427
- if (mt(n, i, e)) continue;
612
+ if (Ct(n, i, e)) continue;
428
613
  let o = t(e).attr("id");
429
614
  if (o && o !== i) {
430
615
  let r = t("<span></span>").attr("id", i);
431
616
  t(e).before(r);
432
617
  let a = r.get(0);
433
- P(a) && I(n, i, a);
434
- } else o && pt(n, o, e), t(e).attr("id", i), I(n, i, e);
618
+ L(a) && xt(n, i, a);
619
+ } else o && St(n, o, e), t(e).attr("id", i), xt(n, i, e);
435
620
  }
436
621
  }
437
622
  return t.html();
438
623
  }
439
- function ft(e) {
624
+ function bt(e) {
440
625
  let t = /* @__PURE__ */ new Map();
441
626
  for (let n of e("[id]").get()) {
442
627
  let r = e(n).attr("id");
443
- r && I(t, r, n);
628
+ r && xt(t, r, n);
444
629
  }
445
630
  return t;
446
631
  }
447
- function I(e, t, n) {
632
+ function xt(e, t, n) {
448
633
  let r = e.get(t);
449
634
  r === void 0 && (r = /* @__PURE__ */ new Set(), e.set(t, r)), r.add(n);
450
635
  }
451
- function pt(e, t, n) {
636
+ function St(e, t, n) {
452
637
  let r = e.get(t);
453
638
  r !== void 0 && (r.delete(n), r.size === 0 && e.delete(t));
454
639
  }
455
- function mt(e, t, n) {
640
+ function Ct(e, t, n) {
456
641
  for (let r of e.get(t) ?? []) if (r !== n) return !0;
457
642
  return !1;
458
643
  }
459
- function ht(e, t) {
460
- let n = He("sourceText" in t ? t.sourceText : "");
644
+ function wt(e, t) {
645
+ let n = qe("sourceText" in t ? t.sourceText : "");
461
646
  if (n) return e.filter((e) => e.kind === "directive_candidate").find((e) => {
462
- let t = He(e.text);
647
+ let t = qe(e.text);
463
648
  return t.length > 0 && (n.includes(t) || t.includes(n));
464
649
  });
465
650
  }
466
- function gt(e, t) {
651
+ function Tt(e, t) {
467
652
  if (t) return t.blockIds.map((t) => e.get(t)).find((e) => e?.kind === "directive_candidate");
468
653
  }
469
- function _t(e) {
654
+ function Et(e) {
470
655
  return e?.links.filter((e) => !e.insideFrenchQuotes && (e.type === "article" || e.type === "division")).map((e) => e.id) ?? [];
471
656
  }
472
- function vt(e, t) {
473
- let n = M(e);
657
+ function Dt(e, t) {
658
+ let n = P(e);
474
659
  if (!n) return;
475
- let r = C(n);
660
+ let r = ne(n);
476
661
  return r ? r.level : n.endsWith(":") ? (t ?? -1) + 1 : void 0;
477
662
  }
478
- function yt(e) {
663
+ function Ot(e) {
479
664
  let t = /* @__PURE__ */ new Map(), n = [];
480
665
  for (let r of e) {
481
- let e = vt(r.text, n.at(-1)?.level);
666
+ let e = Dt(r.text, n.at(-1)?.level);
482
667
  if (e === void 0) {
483
668
  t.set(r.id, [...n.map((e) => e.block), r]);
484
669
  continue;
@@ -491,14 +676,14 @@ function yt(e) {
491
676
  }
492
677
  return t;
493
678
  }
494
- function bt(e, t) {
679
+ function kt(e, t) {
495
680
  let n = [], r = /* @__PURE__ */ new Set();
496
681
  for (let i of [...e ?? [], ...t]) i !== void 0 && (r.has(i.id) || (r.add(i.id), n.push(i)));
497
682
  return n;
498
683
  }
499
- function xt(e, t, n) {
684
+ function At(e, t, n) {
500
685
  if (!t) return;
501
- let r = bt(e, t.blockIds.map((e) => n.get(e)).filter((e) => e !== void 0));
686
+ let r = kt(e, t.blockIds.map((e) => n.get(e)).filter((e) => e !== void 0));
502
687
  if (r.length === 0) return;
503
688
  let i = r.map((e) => e.id);
504
689
  if (i.length === t.blockIds.length && i.every((e, n) => e === t.blockIds[n])) return;
@@ -513,7 +698,7 @@ function xt(e, t, n) {
513
698
  }
514
699
  };
515
700
  }
516
- function St(e) {
701
+ function jt(e) {
517
702
  let t = [], n = 0;
518
703
  for (let r of e.blocks) {
519
704
  let i = e.directiveText.indexOf(r.text, n);
@@ -527,7 +712,7 @@ function St(e) {
527
712
  }
528
713
  return t;
529
714
  }
530
- function Ct(e, t, n) {
715
+ function Mt(e, t, n) {
531
716
  let { start: r, stop: i } = n.sourcePosition, a = t.filter((e) => e.stop > r && e.start < i);
532
717
  if (a.length === 0) return;
533
718
  let o = a[0], s = a[a.length - 1], c = o.start, l = s.stop;
@@ -541,7 +726,7 @@ function Ct(e, t, n) {
541
726
  }
542
727
  };
543
728
  }
544
- function wt(e, t, n) {
729
+ function Nt(e, t, n) {
545
730
  if (!t) return;
546
731
  let r = e.directiveText.indexOf(t.text);
547
732
  if (r === -1) return;
@@ -554,14 +739,14 @@ function wt(e, t, n) {
554
739
  stop: a
555
740
  };
556
741
  }
557
- function Tt(e, t) {
558
- let n = performance.now(), r = performance.now(), i = St(e), a = performance.now() - r, o = performance.now(), s = new Map(e.blocks.map((e) => [e.id, e])), c = yt(e.blocks), l = /* @__PURE__ */ new Map(), u = [];
742
+ function Pt(e, t) {
743
+ let n = performance.now(), r = performance.now(), i = jt(e), a = performance.now() - r, o = performance.now(), s = new Map(e.blocks.map((e) => [e.id, e])), c = Ot(e.blocks), l = /* @__PURE__ */ new Map(), u = [];
559
744
  for (let t of e.blocks) {
560
- let e = _t(t);
745
+ let e = Et(t);
561
746
  e.length > 0 && (u = e), l.set(t.id, u);
562
747
  }
563
- let d = performance.now() - o, f = performance.now(), p = b(), m = h(e.directiveText, t === void 0 ? void 0 : p), g = performance.now() - f, _ = performance.now(), v = m.map((t) => {
564
- let n = Ct(e, i, t), r = gt(s, n) ?? ht(e.blocks, t), a = _t(r), o = a.length > 0 ? a : r?.id === void 0 ? [] : l.get(r.id) ?? [], u = wt(e, r, t), d = xt(r?.id === void 0 ? void 0 : c.get(r.id), n, s);
748
+ let d = performance.now() - o, f = performance.now(), p = ee(), m = g(e.directiveText, t === void 0 ? void 0 : p), h = performance.now() - f, _ = performance.now(), v = m.map((t) => {
749
+ let n = Mt(e, i, t), r = Tt(s, n) ?? wt(e.blocks, t), a = Et(r), o = a.length > 0 ? a : r?.id === void 0 ? [] : l.get(r.id) ?? [], u = Nt(e, r, t), d = At(r?.id === void 0 ? void 0 : c.get(r.id), n, s);
565
750
  return {
566
751
  articleId: e.id,
567
752
  blockId: r?.id,
@@ -579,27 +764,50 @@ function Tt(e, t) {
579
764
  directive: t,
580
765
  ...o.length > 0 ? { targetIds: o } : {}
581
766
  };
582
- }), y = performance.now() - _;
767
+ }), y = /* @__PURE__ */ new Set(), b = /* @__PURE__ */ new Map(), x = v.flatMap((e) => {
768
+ let t = e.blockId ? s.get(e.blockId) : void 0;
769
+ if (!t) return [e];
770
+ if (y.has(t.id)) return [];
771
+ let n = b.get(t.id);
772
+ if (n === void 0 && (n = je(t.text, Et(t)), b.set(t.id, n)), !n) {
773
+ let n = e.directive, r = e.targetIds?.length === 1 && n.kind === "compound" ? Ae(t.text, n.operations.length) : null;
774
+ return [r ? {
775
+ ...e,
776
+ sourceAnnotations: r
777
+ } : e];
778
+ }
779
+ return y.add(t.id), [{
780
+ ...e,
781
+ effects: n.map((t) => ({
782
+ ...t,
783
+ directive: {
784
+ ...t.directive,
785
+ sourcePosition: e.directive.sourcePosition,
786
+ sourceText: e.directive.sourceText
787
+ }
788
+ }))
789
+ }];
790
+ }), S = performance.now() - _;
583
791
  return t?.push({
584
792
  actionDirectiveExtraction: p,
585
793
  articleId: e.id,
586
794
  blockCount: e.blocks.length,
587
795
  buildRangesMs: Math.round(a * 10) / 10,
588
- directiveCount: v.length,
796
+ directiveCount: x.length,
589
797
  directiveTextSize: e.directiveText.length,
590
- extractActionDirectivesMs: Math.round(g * 10) / 10,
591
- mapDirectivesMs: Math.round(y * 10) / 10,
798
+ extractActionDirectivesMs: Math.round(h * 10) / 10,
799
+ mapDirectivesMs: Math.round(S * 10) / 10,
592
800
  prepareBlockIndexesMs: Math.round(d * 10) / 10,
593
801
  totalMs: Math.round((performance.now() - n) * 10) / 10
594
- }), v;
802
+ }), x;
595
803
  }
596
- function Et(e) {
804
+ function Ft(e) {
597
805
  let t = /* @__PURE__ */ new Map(), n = [], r = /* @__PURE__ */ new Set();
598
806
  for (let i of e) {
599
- let e = Pe(i.directive);
807
+ let e = ze(i.directive);
600
808
  if (e.length === 0) continue;
601
809
  let a = e.map(({ num: e }) => ({
602
- definitionId: `${i.articleId}:article:${je(e)}`,
810
+ definitionId: `${i.articleId}:article:${Ie(e)}`,
603
811
  num: e
604
812
  }));
605
813
  t.set(i, a);
@@ -622,13 +830,13 @@ function Et(e) {
622
830
  definitions: n
623
831
  };
624
832
  }
625
- function Dt(e, t, n) {
626
- let r = new Map(t.map((e) => [Ae(e.num), e]));
833
+ function It(e, t, n) {
834
+ let r = new Map(t.map((e) => [Fe(e.num), e]));
627
835
  return e.map((e) => {
628
- let t = n.get(e), i = t?.[0], a = [...Fe(e.directive.reference)].map((e) => r.get(Ae(e))).filter((e) => e !== void 0 && e.definitionId !== i?.definitionId)[0], o = a === void 0 ? void 0 : {
836
+ let t = n.get(e), i = t?.[0], a = [...Be(e.directive.reference)].map((e) => r.get(Fe(e))).filter((e) => e !== void 0 && e.definitionId !== i?.definitionId)[0], o = a === void 0 ? void 0 : {
629
837
  definitionId: a.definitionId,
630
838
  num: a.num
631
- }, s = Ie(e.directive), c = (e.targetIds?.length ?? 0) > 0;
839
+ }, s = Ve(e.directive), c = (e.targetIds?.length ?? 0) > 0;
632
840
  return {
633
841
  ...e,
634
842
  ...i === void 0 ? {} : { createdArticle: i },
@@ -641,7 +849,7 @@ function Dt(e, t, n) {
641
849
  };
642
850
  });
643
851
  }
644
- function Ot(e) {
852
+ function Lt(e) {
645
853
  switch (e.kind) {
646
854
  case "insert_after":
647
855
  case "insert_before": return [e.insertText];
@@ -659,8 +867,8 @@ function Ot(e) {
659
867
  default: return [];
660
868
  }
661
869
  }
662
- function kt(e) {
663
- return e.flatMap((e) => Ot(e.directive).filter((e) => /[«»]/u.test(e)).map((t) => ({
870
+ function Rt(e) {
871
+ return e.flatMap((e) => Lt(e.directive).filter((e) => /[«»]/u.test(e)).map((t) => ({
664
872
  code: "nested_french_quote_in_redaction",
665
873
  message: "Écart à la règle légistique détecté : une citation imbriquée dans une rédaction devrait utiliser des guillemets anglais et non des guillemets français.",
666
874
  details: {
@@ -672,18 +880,18 @@ function kt(e) {
672
880
  }
673
881
  })));
674
882
  }
675
- function At(e) {
676
- return Ot(e).map((t) => ({
883
+ function zt(e) {
884
+ return Lt(e).map((t) => ({
677
885
  directiveKind: e.kind,
678
886
  text: t
679
887
  }));
680
888
  }
681
- function jt(e) {
889
+ function Bt(e) {
682
890
  let t = /* @__PURE__ */ new Set();
683
891
  for (let n of e.matchAll(/«[^«»\n]+»/gu)) t.add(n[0]);
684
892
  return Array.from(t);
685
893
  }
686
- function Mt(e, t) {
894
+ function Vt(e, t) {
687
895
  let n = new Map(e.blocks.map((e) => [e.id, e])), r = t.sourceBlockIds ?? e.blocks.map((e) => e.id), i = [], a = 0;
688
896
  for (let e of r) {
689
897
  let t = n.get(e);
@@ -695,11 +903,11 @@ function Mt(e, t) {
695
903
  }
696
904
  return i;
697
905
  }
698
- function Nt(e, t, n) {
906
+ function Ht(e, t, n) {
699
907
  return e.find((e) => t >= e.start && n <= e.stop);
700
908
  }
701
- function Pt(e, t, n) {
702
- let r = jt(n), i = r.flatMap((t) => {
909
+ function Ut(e, t, n) {
910
+ let r = Bt(n), i = r.flatMap((t) => {
703
911
  for (let n of e.blocks) {
704
912
  let e = n.text.indexOf(t);
705
913
  if (e !== -1) return [{
@@ -718,7 +926,7 @@ function Pt(e, t, n) {
718
926
  e.directiveText
719
927
  ].filter((e) => e !== void 0 && e.length > 0), o = a.find((e) => r.some((t) => e.includes(t))) ?? a[0];
720
928
  if (!o) return [];
721
- let s = Mt(e, t);
929
+ let s = Vt(e, t);
722
930
  if (s.length === 0) return [];
723
931
  let c = [], l = 0;
724
932
  for (let e of r) {
@@ -726,7 +934,7 @@ function Pt(e, t, n) {
726
934
  if (t === -1) continue;
727
935
  let n = t + e.length;
728
936
  l = n;
729
- let r = Nt(s, t, n);
937
+ let r = Ht(s, t, n);
730
938
  r && c.push({
731
939
  blockId: r.block.id,
732
940
  start: t - r.start,
@@ -736,15 +944,15 @@ function Pt(e, t, n) {
736
944
  }
737
945
  return c;
738
946
  }
739
- function Ft(e, t) {
947
+ function Wt(e, t) {
740
948
  let n = new Map(e.map((e) => [e.id, e]));
741
949
  return t.flatMap((e) => {
742
950
  let t = n.get(e.articleId);
743
- return t ? At(e.directive).filter(({ text: e }) => /[«»]/u.test(e)).map(({ directiveKind: n, text: r }) => ({
951
+ return t ? zt(e.directive).filter(({ text: e }) => /[«»]/u.test(e)).map(({ directiveKind: n, text: r }) => ({
744
952
  articleId: e.articleId,
745
953
  code: "nested_french_quote_in_redaction",
746
954
  message: "Écart à la règle légistique détecté : une citation imbriquée dans une rédaction devrait utiliser des guillemets anglais et non des guillemets français.",
747
- ranges: Pt(t, e, r),
955
+ ranges: Ut(t, e, r),
748
956
  severity: "warning",
749
957
  details: {
750
958
  blockId: e.blockId,
@@ -755,19 +963,20 @@ function Ft(e, t) {
755
963
  })) : [];
756
964
  });
757
965
  }
758
- function It(e, t, n, r, i, a, o = !0, s) {
759
- let c = new ge("parsedBill.buildParsedDocument"), l = i.reduce((e, t) => e + t.blocks.length, 0), u = c.timeSync("buildDirectiveText", () => i.map((e) => e.directiveText).filter(Boolean).join("\n")), d = {
966
+ function Gt(e, t, n, r, i, a, o = !0, s) {
967
+ let c = new be("parsedBill.buildParsedDocument"), l = i.reduce((e, t) => e + t.blocks.length, 0), u = c.timeSync("buildDirectiveText", () => i.map((e) => e.directiveText).filter(Boolean).join("\n")), d = {
760
968
  sourceFormat: e,
761
969
  documentDate: r,
762
970
  html: t,
763
971
  htmlWithLinks: n,
764
- tableOfContents: a ?? c.timeSync("extractTableOfContents", () => v(u), { inputSize: u.length }),
972
+ tableOfContents: a ?? c.timeSync("extractTableOfContents", () => y(u), { inputSize: u.length }),
765
973
  articles: i
766
974
  };
767
975
  if (!o) {
768
976
  let e = {
769
977
  ...d,
770
- directives: []
978
+ directives: [],
979
+ ...s?.length ? { diagnostics: s } : {}
771
980
  };
772
981
  return c.log({
773
982
  articleCount: i.length,
@@ -776,14 +985,14 @@ function It(e, t, n, r, i, a, o = !0, s) {
776
985
  directiveTextSize: u.length
777
986
  }), e;
778
987
  }
779
- let f = c.timeSync("extractGlobalApplicabilityDate", () => Ve(i.map((e) => e.text).join("\n"))), p = [], m = c.timeSync("extractDirectivesFromArticles", () => {
988
+ let f = c.timeSync("extractGlobalApplicabilityDate", () => Ke(i.map((e) => e.text).join("\n"))), p = [], m = c.timeSync("extractDirectivesFromArticles", () => {
780
989
  let e = [];
781
990
  for (let t of i) {
782
- let n = Tt(t, c.enabled ? p : void 0);
991
+ let n = Pt(t, c.enabled ? p : void 0);
783
992
  e.push(...n);
784
993
  }
785
994
  return e;
786
- }, { count: i.length }), { createdArticlesByDirective: h, definitions: g } = c.timeSync("buildInternalArticleDefinitions", () => Et(m), { count: m.length }), _ = c.timeSync("attachInternalArticleMetadata", () => Dt(m, g, h), { count: m.length }), y = c.timeSync("collectNestedFrenchQuoteDiagnostics", () => kt(_), { count: _.length }), b = [...s ?? [], ...y], x = c.timeSync("collectNestedFrenchQuoteAnnotations", () => Ft(i, _), { count: _.length }), ee = {
995
+ }, { count: i.length }), { createdArticlesByDirective: h, definitions: g } = c.timeSync("buildInternalArticleDefinitions", () => Ft(m), { count: m.length }), _ = c.timeSync("attachInternalArticleMetadata", () => It(m, g, h), { count: m.length }), v = c.timeSync("collectNestedFrenchQuoteDiagnostics", () => Rt(_), { count: _.length }), b = [...s ?? [], ...v], x = c.timeSync("collectNestedFrenchQuoteAnnotations", () => Wt(i, _), { count: _.length }), ee = {
787
996
  ...d,
788
997
  ...f ? { globalApplicabilityDate: f } : {},
789
998
  ...g.length > 0 ? { internalArticleDefinitions: g } : {},
@@ -877,74 +1086,95 @@ function It(e, t, n, r, i, a, o = !0, s) {
877
1086
  slowDirectiveArticles: p.toSorted((e, t) => t.totalMs - e.totalMs).slice(0, 10)
878
1087
  }), ee;
879
1088
  }
880
- function Lt(e) {
1089
+ function Kt(e) {
881
1090
  return { items: e.map((e) => ({
882
1091
  id: e.id,
883
1092
  line: e.title ? `${e.label} : ${e.title}` : e.label,
884
1093
  type: "article"
885
1094
  })) };
886
1095
  }
887
- function Rt(e) {
888
- return Array.from(re(e)).filter((e) => e.type === "article").map((e) => N(e.line.split(/[::]/u)[0]));
1096
+ function qt(e) {
1097
+ return Array.from(oe(e)).filter((e) => e.type === "article").map((e) => F(e.line.split(/[::]/u)[0]));
889
1098
  }
890
- function zt(e) {
891
- let t = Rt(v(e.map((e) => e.directiveText).filter(Boolean).join("\n"))), n = e.map((e) => N(e.label)), r = [];
892
- if (t.length > 0 && (t.length !== n.length || t.some((e, t) => e !== n[t]))) {
893
- let i = t.findIndex((e, t) => e !== n[t]);
894
- r.push({
1099
+ function Jt(e, t, n, r) {
1100
+ let i = ut(e), a = new Set(Array.from(n.matchAll(/\s+id=(?:"([^"]+)"|'([^']+)')/gu), (e) => e[1] ?? e[2])), o = Array.from(oe(t)).filter((e) => e.type === "article"), s = e.map((e) => r === "akoma-ntoso" ? e.num ? I(e.num) : _(e.html)("p.TCNumArticle").first().attr("id") ?? I(e.label) : e.id), c = o.map((e) => e.id);
1101
+ (c.length !== s.length || c.some((e, t) => e !== s[t])) && i.push({
1102
+ code: "article_toc_source_heading_mismatch",
1103
+ message: "The table of contents differs from the parsed article headings",
1104
+ details: {
1105
+ articleIds: s,
1106
+ tocIds: c
1107
+ }
1108
+ });
1109
+ for (let e of c) e && !a.has(e) && i.push({
1110
+ code: "article_toc_missing_anchor",
1111
+ message: `The article anchor ${e} is absent from the rendered text`,
1112
+ details: { id: e }
1113
+ });
1114
+ return i;
1115
+ }
1116
+ function Yt(e, t, n) {
1117
+ let r = qt(y(e.map((e) => e.directiveText).filter(Boolean).join("\n"))), i = e.map((e) => F(e.label)), a = Kt(e), o = [...n, ...Jt(e, a, t, "assemblee-html")];
1118
+ if (r.length > 0 && (r.length !== i.length || r.some((e, t) => e !== i[t]))) {
1119
+ let t = r.findIndex((e, t) => e !== i[t]);
1120
+ o.push({
895
1121
  code: "assemblee_toc_article_order_mismatch",
896
1122
  message: "The article order reconstructed from divisions differs from the extracted article headings; using article heading order.",
897
1123
  details: {
898
- articleHeadingCount: n.length,
899
- extractedTocArticleCount: t.length,
1124
+ articleHeadingCount: i.length,
1125
+ extractedTocArticleCount: r.length,
900
1126
  firstArticleHeadings: e.slice(0, 12).map((e) => e.label),
901
- firstExtractedTocArticles: t.slice(0, 12),
902
- firstMismatch: i === -1 ? void 0 : {
903
- index: i,
904
- articleHeading: e[i]?.label,
905
- extractedTocArticle: t[i]
1127
+ firstExtractedTocArticles: r.slice(0, 12),
1128
+ firstMismatch: t === -1 ? void 0 : {
1129
+ index: t,
1130
+ articleHeading: e[t]?.label,
1131
+ extractedTocArticle: r[t]
906
1132
  }
907
1133
  }
908
1134
  });
909
1135
  }
910
1136
  return {
911
- diagnostics: r,
912
- tableOfContents: Lt(e)
1137
+ diagnostics: o,
1138
+ tableOfContents: a
913
1139
  };
914
1140
  }
915
- async function Bt(e, t) {
916
- let n = new ge("parseAssembleeBillRaw"), r = t.linkedHtml === void 0 ? await n.time("linkAssembleeBillRaw", () => Vt(e, t)) : void 0, i = n.timeSync("applyArticleAnchorIds", () => dt(t.linkedHtml ?? r.linkedHtml), { inputSize: e.length }), a = n.timeSync("cheerioLoadLinkedHtml", () => g(i)), o = n.timeSync("extractArticleHeadings", () => at(a)), s = Qe(a), c = n.timeSync("extractArticlesAndBlocks", () => o.map((e, t) => {
917
- let n = st(a, e, o[t + 1], s), r = lt(a, e.id, n), i = r.filter((e) => e.kind !== "noise").map((e) => e.text).join("\n");
1141
+ async function Xt(e, t) {
1142
+ let n = new be("parseAssembleeBillRaw"), r = t.linkedHtml === void 0 ? await n.time("linkAssembleeBillRaw", () => Zt(e, t)) : void 0, i = n.timeSync("applyArticleAnchorIds", () => yt(t.linkedHtml ?? r.linkedHtml), { inputSize: e.length }), a = n.timeSync("cheerioLoadLinkedHtml", () => _(i)), o = n.timeSync("extractArticleHeadings", () => ft(a)), s = new Set(o.map((e) => e.id)), c = ot(a).filter((e) => !s.has(I(e.num ?? e.label))).map((e) => e.label), l = c.length > 0 ? [{
1143
+ code: "article_toc_source_heading_mismatch",
1144
+ message: "Some structural article headings were not retained",
1145
+ details: { discardedCandidates: c }
1146
+ }] : [], u = rt(a), d = n.timeSync("extractArticlesAndBlocks", () => o.map((e, t) => {
1147
+ let n = ht(a, e, o[t + 1], u), r = _t(a, e.id, n), i = r.filter((e) => e.kind !== "noise").map((e) => e.text).join("\n");
918
1148
  return {
919
1149
  id: e.id,
920
1150
  label: e.label,
921
1151
  num: e.num,
922
1152
  title: e.title,
923
- text: qe(a, n),
924
- html: n.map((e) => Ue(a, e)).join("\n"),
1153
+ text: Qe(a, n),
1154
+ html: n.map((e) => Je(a, e)).join("\n"),
925
1155
  directiveText: i,
926
1156
  blocks: r
927
1157
  };
928
- }), { count: o.length }), l = n.timeSync("injectHiddenArticleSummary", () => ut(a.html(), c)), { diagnostics: u, tableOfContents: d } = n.timeSync("buildAssembleeTableOfContents", () => zt(c), { count: c.length }), f = n.timeSync("buildParsedDocument", () => It("assemblee-html", e, l, t.date, c, d, t.includeDirectiveAnalysis, u));
929
- return f.diagnostics?.length && process.env.TISSEUSE_WARN_PARSED_BILL_DIAGNOSTICS === "1" && console.warn("Assemblée bill parsing diagnostics", f.diagnostics), n.log({
930
- articleCount: f.articles.length,
931
- blockCount: f.articles.reduce((e, t) => e + t.blocks.length, 0),
932
- directiveCount: f.directives.length,
933
- targetDirectiveCount: f.directives.filter((e) => e.targetIds !== void 0).length
934
- }), f;
1158
+ }), { count: o.length }), f = n.timeSync("injectHiddenArticleSummary", () => vt(a.html(), d)), { diagnostics: p, tableOfContents: m } = n.timeSync("buildAssembleeTableOfContents", () => Yt(d, f, l), { count: d.length }), h = n.timeSync("buildParsedDocument", () => Gt("assemblee-html", e, f, t.date, d, m, t.includeDirectiveAnalysis, p));
1159
+ return h.diagnostics?.length && process.env.TISSEUSE_WARN_PARSED_BILL_DIAGNOSTICS === "1" && console.warn("Assemblée bill parsing diagnostics", h.diagnostics), n.log({
1160
+ articleCount: h.articles.length,
1161
+ blockCount: h.articles.reduce((e, t) => e + t.blocks.length, 0),
1162
+ directiveCount: h.directives.length,
1163
+ targetDirectiveCount: h.directives.filter((e) => e.targetIds !== void 0).length
1164
+ }), h;
935
1165
  }
936
- async function Vt(e, t) {
1166
+ async function Zt(e, t) {
937
1167
  return {
938
1168
  sourceFormat: "assemblee-html",
939
1169
  documentDate: t.date,
940
1170
  html: e,
941
- linkedHtml: await Ye(e, t, t.date)
1171
+ linkedHtml: await et(e, t, t.date)
942
1172
  };
943
1173
  }
944
- function L(e) {
1174
+ function z(e) {
945
1175
  return e.replace(/&/gu, "&amp;").replace(/</gu, "&lt;").replace(/>/gu, "&gt;").replace(/"/gu, "&quot;");
946
1176
  }
947
- function Ht(e) {
1177
+ function Qt(e) {
948
1178
  let t = e;
949
1179
  for (let e = 0; e < 3; e++) {
950
1180
  let e = t;
@@ -952,27 +1182,27 @@ function Ht(e) {
952
1182
  }
953
1183
  return t;
954
1184
  }
955
- function Ut(e) {
1185
+ function $t(e) {
956
1186
  return /(?:&lt;|&amp;lt;)\/?(?:p|br|span|b|i|u|sup|sub|table|thead|tbody|tr|th|td|ul|ol|li)\b/iu.test(e);
957
1187
  }
958
- function R(e) {
1188
+ function B(e) {
959
1189
  return e.name.replace(/^.*:/u, "");
960
1190
  }
961
- function Wt(e, t) {
962
- return t.children.map((t) => z(e, t)).filter(Boolean).join("");
1191
+ function en(e, t) {
1192
+ return t.children.map((t) => V(e, t)).filter(Boolean).join("");
963
1193
  }
964
- function Gt(e, t) {
965
- return t.children.map((t) => t.type === "text" && Ut(t.data) ? Ht(t.data) : z(e, t)).filter(Boolean).join("");
1194
+ function tn(e, t) {
1195
+ return t.children.map((t) => t.type === "text" && $t(t.data) ? Qt(t.data) : V(e, t)).filter(Boolean).join("");
966
1196
  }
967
- function z(e, t) {
1197
+ function V(e, t) {
968
1198
  if (t.type === "text") {
969
1199
  let e = t.data.replace(/\s+\./gu, ".");
970
- return Ut(e) ? Ht(e) : L(e);
1200
+ return $t(e) ? Qt(e) : z(e);
971
1201
  }
972
- if (!P(t)) return "";
973
- let n = R(t), r = Wt(e, t);
1202
+ if (!L(t)) return "";
1203
+ let n = B(t), r = en(e, t);
974
1204
  switch (n) {
975
- case "p": return `<p${B(e, t, [
1205
+ case "p": return `<p${H(e, t, [
976
1206
  "id",
977
1207
  "class",
978
1208
  "align",
@@ -986,13 +1216,13 @@ function z(e, t) {
986
1216
  case "u":
987
1217
  case "sup":
988
1218
  case "sub":
989
- case "abbr": return `<${n}${B(e, t, [
1219
+ case "abbr": return `<${n}${H(e, t, [
990
1220
  "id",
991
1221
  "class",
992
1222
  "title",
993
1223
  "style"
994
1224
  ])}>${r}</${n}>`;
995
- case "a": return `<a href="${L(e(t).attr("href") ?? e(t).attr("target") ?? "#")}"${B(e, t, [
1225
+ case "a": return `<a href="${z(e(t).attr("href") ?? e(t).attr("target") ?? "#")}"${H(e, t, [
996
1226
  "id",
997
1227
  "class",
998
1228
  "title",
@@ -1003,8 +1233,8 @@ function z(e, t) {
1003
1233
  case "tbody":
1004
1234
  case "tr":
1005
1235
  case "th":
1006
- case "td": return Kt(e, t, n, r);
1007
- case "caption": return `<caption${B(e, t, [
1236
+ case "td": return nn(e, t, n, r);
1237
+ case "caption": return `<caption${H(e, t, [
1008
1238
  "id",
1009
1239
  "class",
1010
1240
  "align",
@@ -1012,12 +1242,12 @@ function z(e, t) {
1012
1242
  ])}>${r}</caption>`;
1013
1243
  case "num": return `<span class="akn-num">${r}</span> `;
1014
1244
  case "heading": return `<p class="akn-heading">${r}</p>`;
1015
- case "content": return Gt(e, t);
1016
- case "alinea": return V(e, t, "div", "akn-alinea");
1017
- case "article": return V(e, t, "article", "akn-article");
1245
+ case "content": return tn(e, t);
1246
+ case "alinea": return vn(e, t, "div", "akn-alinea");
1247
+ case "article": return vn(e, t, "article", "akn-article");
1018
1248
  case "blockList":
1019
1249
  case "list": return `<div class="akn-list">${r}</div>`;
1020
- case "item": return V(e, t, "div", "akn-item");
1250
+ case "item": return vn(e, t, "div", "akn-item");
1021
1251
  case "listIntroduction":
1022
1252
  case "listWrapUp":
1023
1253
  case "intro":
@@ -1033,23 +1263,23 @@ function z(e, t) {
1033
1263
  case "book":
1034
1264
  case "tome":
1035
1265
  case "subchapter":
1036
- case "subsection": return V(e, t, "section", `akn-${n}`);
1266
+ case "subsection": return vn(e, t, "section", `akn-${n}`);
1037
1267
  case "crossHeading": return `<p class="akn-cross-heading">${r}</p>`;
1038
1268
  default: return r;
1039
1269
  }
1040
1270
  }
1041
- function B(e, t, n, r = {}) {
1271
+ function H(e, t, n, r = {}) {
1042
1272
  let i = [];
1043
1273
  for (let r of n) {
1044
1274
  if (r === "style") continue;
1045
1275
  let n = e(t).attr(r);
1046
- n !== void 0 && i.push(`${r}="${L(n)}"`);
1276
+ n !== void 0 && i.push(`${r}="${z(n)}"`);
1047
1277
  }
1048
1278
  let a = r.style ?? e(t).attr("style");
1049
- return a && i.push(`style="${L(a)}"`), i.length > 0 ? ` ${i.join(" ")}` : "";
1279
+ return a && i.push(`style="${z(a)}"`), i.length > 0 ? ` ${i.join(" ")}` : "";
1050
1280
  }
1051
- function Kt(e, t, n, r) {
1052
- return `<${n}${B(e, t, [
1281
+ function nn(e, t, n, r) {
1282
+ return `<${n}${H(e, t, [
1053
1283
  "id",
1054
1284
  "class",
1055
1285
  "colspan",
@@ -1062,155 +1292,155 @@ function Kt(e, t, n, r) {
1062
1292
  "cellspacing",
1063
1293
  "cellpadding",
1064
1294
  "style"
1065
- ], { style: qt(e, t, n) })}>${r}</${n}>`;
1295
+ ], { style: rn(e, t, n) })}>${r}</${n}>`;
1066
1296
  }
1067
- function qt(e, t, n) {
1297
+ function rn(e, t, n) {
1068
1298
  let r = e(t).attr("style") ?? "";
1069
- return (n === "td" || n === "th") && /font-weight\s*:\s*bold/iu.test(r) && !/text-align\s*:/iu.test(r) && (r = Jt(r, "text-align", "center")), r || void 0;
1299
+ return (n === "td" || n === "th") && /font-weight\s*:\s*bold/iu.test(r) && !/text-align\s*:/iu.test(r) && (r = an(r, "text-align", "center")), r || void 0;
1070
1300
  }
1071
- function Jt(e, t, n) {
1301
+ function an(e, t, n) {
1072
1302
  let r = e.trim();
1073
1303
  return `${r}${r && !r.endsWith(";") ? ";" : ""} ${t}: ${n};`.trim();
1074
1304
  }
1075
- function Yt(e, t) {
1076
- let n = [M(e(t).children("num").first().text()), M(e(t).children("heading").first().text())].filter(Boolean);
1077
- return n.length === 0 ? "" : `<p class="akn-heading">${L(n.join(" "))}</p>`;
1305
+ function on(e, t) {
1306
+ let n = [P(e(t).children("num").first().text()), P(e(t).children("heading").first().text())].filter(Boolean);
1307
+ return n.length === 0 ? "" : `<p class="akn-heading">${z(n.join(" "))}</p>`;
1078
1308
  }
1079
- function Xt(e, t) {
1309
+ function sn(e, t) {
1080
1310
  if (!t) return !1;
1081
- let n = (e) => M(e).replace(/\s+/gu, " ").replace(/\s*[..]\s*(?=[–—-])/gu, " ").trim();
1082
- return n(M(e.replace(/<[^>]*>/gu, " ").replace(/&nbsp;/gu, " ").replace(/&#xa0;/giu, " ").replace(/&#x2013;/giu, "–"))).startsWith(n(t));
1311
+ let n = (e) => P(e).replace(/\s+/gu, " ").replace(/\s*[..]\s*(?=[–—-])/gu, " ").trim();
1312
+ return n(P(e.replace(/<[^>]*>/gu, " ").replace(/&nbsp;/gu, " ").replace(/&#xa0;/giu, " ").replace(/&#x2013;/giu, "–"))).startsWith(n(t));
1083
1313
  }
1084
- function Zt(e) {
1085
- let t = L(e);
1314
+ function cn(e) {
1315
+ let t = z(e);
1086
1316
  return `<p data-pastille="${t}" class="pastille"><span aria-label="pastille ${t}">${t}</span></p>`;
1087
1317
  }
1088
- function Qt(e, t) {
1089
- return $t([en({
1318
+ function ln(e, t) {
1319
+ return un([dn({
1090
1320
  content: e,
1091
1321
  pastille: t
1092
1322
  })]);
1093
1323
  }
1094
- function $t(e) {
1324
+ function un(e) {
1095
1325
  return `<table class="fixed-size large akn-pastille-table"><colgroup><col style="width: 5.0%;" class="texte-col-0 texte-col-pastille"><col style="width: 95.0%;" class="texte-col-1"></colgroup><tbody>${e.join("\n")}</tbody></table>`;
1096
1326
  }
1097
- function en({ content: e, pastille: t, style: n, contextClass: r }) {
1098
- let i = n ? ` style="${L(n)}"` : "", a = r ? ` ${L(r)}` : "";
1099
- return `<tr${r ? ` class="${L(r)} hideable"` : ""}><td style="overflow: hidden; width: 5.0%;" class="texte-col-0 texte-col-pastille no-right-border"><div class="tableauComparatifCell${a}">${Zt(t)}</div></td><td style="overflow: hidden; width: 95.0%;" class="texte-col-1 no-right-border"><div class="tableauComparatifCell${a}"${i}>${e}</div></td></tr>`;
1327
+ function dn({ content: e, pastille: t, style: n, contextClass: r }) {
1328
+ let i = n ? ` style="${z(n)}"` : "", a = r ? ` ${z(r)}` : "";
1329
+ return `<tr${r ? ` class="${z(r)} hideable"` : ""}><td style="overflow: hidden; width: 5.0%;" class="texte-col-0 texte-col-pastille no-right-border"><div class="tableauComparatifCell${a}">${cn(t)}</div></td><td style="overflow: hidden; width: 95.0%;" class="texte-col-1 no-right-border"><div class="tableauComparatifCell${a}"${i}>${e}</div></td></tr>`;
1100
1330
  }
1101
- function tn({ content: e, style: t, contextClass: n }) {
1102
- let r = t ? ` style="${L(t)}"` : "", i = n ? ` ${L(n)}` : "";
1103
- return `<tr${n ? ` class="${L(n)} hideable"` : ""}><td style="overflow: hidden; width: 5.0%;" class="texte-col-0 no-right-border"><div class="tableauComparatifCell${i}"><p class="pastille"><br></p></div></td><td style="overflow: hidden; width: 95.0%;" class="texte-col-1 no-right-border"><div class="tableauComparatifCell${i}"${r}>${e}</div></td></tr>`;
1331
+ function fn({ content: e, style: t, contextClass: n }) {
1332
+ let r = t ? ` style="${z(t)}"` : "", i = n ? ` ${z(n)}` : "";
1333
+ return `<tr${n ? ` class="${z(n)} hideable"` : ""}><td style="overflow: hidden; width: 5.0%;" class="texte-col-0 no-right-border"><div class="tableauComparatifCell${i}"><p class="pastille"><br></p></div></td><td style="overflow: hidden; width: 95.0%;" class="texte-col-1 no-right-border"><div class="tableauComparatifCell${i}"${r}>${e}</div></td></tr>`;
1104
1334
  }
1105
- function nn(e, t) {
1335
+ function pn(e, t) {
1106
1336
  return e(t).attr("data:pastille") ?? e(t).attr("pastille");
1107
1337
  }
1108
- function rn(e, t) {
1338
+ function mn(e, t) {
1109
1339
  return e(t).find("alinea[data\\:pastille],alinea[pastille]").length > 0;
1110
1340
  }
1111
- function an(e, t) {
1112
- return e(t).children().get().filter((e) => P(e) ? R(e) === "content" : !1).map((t) => z(e, t)).filter(Boolean).join("\n");
1341
+ function hn(e, t) {
1342
+ return e(t).children().get().filter((e) => L(e) ? B(e) === "content" : !1).map((t) => V(e, t)).filter(Boolean).join("\n");
1113
1343
  }
1114
- function on(e, t) {
1344
+ function gn(e, t) {
1115
1345
  let n = [];
1116
1346
  return e(t).children().each((t, r) => {
1117
- if (!P(r)) return;
1118
- let i = R(r);
1119
- i === "num" || i === "heading" || i === "content" || n.push(z(e, r));
1347
+ if (!L(r)) return;
1348
+ let i = B(r);
1349
+ i === "num" || i === "heading" || i === "content" || n.push(V(e, r));
1120
1350
  }), n.filter(Boolean);
1121
1351
  }
1122
- function sn(e, t) {
1123
- let n = [], r = R(t), i = r === "alinea" ? nn(e, t) : void 0, a = an(e, t), o = cn(e, t, r, i), s = mn(e, t);
1352
+ function _n(e, t) {
1353
+ let n = [], r = B(t), i = r === "alinea" ? pn(e, t) : void 0, a = hn(e, t), o = yn(e, t, r, i), s = Tn(e, t);
1124
1354
  if (i) {
1125
- let r = [Xt(a, M(e(t).children("num").first().text())) ? "" : Yt(e, t), a].filter(Boolean).join("\n");
1126
- M(r) && n.push(en({
1355
+ let r = [sn(a, P(e(t).children("num").first().text())) ? "" : on(e, t), a].filter(Boolean).join("\n");
1356
+ P(r) && n.push(dn({
1127
1357
  content: r,
1128
1358
  pastille: i,
1129
1359
  style: o,
1130
1360
  contextClass: s
1131
1361
  }));
1132
- } else a && n.push(tn({
1362
+ } else a && n.push(fn({
1133
1363
  content: a,
1134
1364
  style: o,
1135
1365
  contextClass: s
1136
1366
  }));
1137
1367
  for (let r of e(t).children().get()) {
1138
- if (!P(r)) continue;
1139
- let t = R(r);
1140
- t === "num" || t === "heading" || t === "content" || (t === "alinea" || rn(e, r)) && n.push(...sn(e, r));
1368
+ if (!L(r)) continue;
1369
+ let t = B(r);
1370
+ t === "num" || t === "heading" || t === "content" || (t === "alinea" || mn(e, r)) && n.push(..._n(e, r));
1141
1371
  }
1142
1372
  return n;
1143
1373
  }
1144
- function V(e, t, n, r) {
1145
- let i = R(t), a = e(t).attr("eId") ?? e(t).attr("GUID"), o = nn(e, t), s = cn(e, t, i, o), c = [`<${n} ${[
1146
- a ? `id="${L(a)}"` : void 0,
1374
+ function vn(e, t, n, r) {
1375
+ let i = B(t), a = e(t).attr("eId") ?? e(t).attr("GUID"), o = pn(e, t), s = yn(e, t, i, o), c = [`<${n} ${[
1376
+ a ? `id="${z(a)}"` : void 0,
1147
1377
  `class="${r}"`,
1148
- o ? `data-pastille="${L(o)}"` : void 0,
1149
- s ? `style="${L(s)}"` : void 0
1378
+ o ? `data-pastille="${z(o)}"` : void 0,
1379
+ s ? `style="${z(s)}"` : void 0
1150
1380
  ].filter((e) => e !== void 0).join(" ")}>`];
1151
1381
  if (i === "part" || i === "title") {
1152
- let r = dn(e, t, i), a = pn(e, t), o = r ? [tn({
1382
+ let r = Sn(e, t, i), a = wn(e, t), o = r ? [fn({
1153
1383
  content: r,
1154
1384
  contextClass: a
1155
1385
  })] : [], s = () => {
1156
- o.length !== 0 && (c.push(un(o)), o = []);
1386
+ o.length !== 0 && (c.push(xn(o)), o = []);
1157
1387
  };
1158
1388
  return e(t).children().each((t, n) => {
1159
- if (!P(n)) return;
1160
- let r = R(n);
1389
+ if (!L(n)) return;
1390
+ let r = B(n);
1161
1391
  if (!(r === "num" || r === "heading" || r === "content")) {
1162
1392
  if (r === "alinea") {
1163
- o.push(...sn(e, n));
1393
+ o.push(..._n(e, n));
1164
1394
  return;
1165
1395
  }
1166
- s(), c.push(z(e, n));
1396
+ s(), c.push(V(e, n));
1167
1397
  }
1168
1398
  }), s(), c.push(`</${n}>`), c.join("\n");
1169
1399
  }
1170
1400
  if (i === "article") {
1171
- let r = M(e(t).children("num").first().text()), i = M(e(t).children("heading").first().text()), a = w(r) ?? {
1401
+ let r = P(e(t).children("num").first().text()), i = P(e(t).children("heading").first().text()), a = w(r) ?? {
1172
1402
  label: r,
1173
1403
  num: r
1174
- }, o = `<p class="TCNumArticle as-text toc-article dispositif" id="${L(`_TocArt${(a.num ?? r).replace(/\s+/gu, "")}`)}">${L(a.label)}${i ? ` : ${L(i)}` : ""}</p>`;
1175
- if (rn(e, t)) {
1176
- let r = [tn({
1404
+ }, o = `<p class="TCNumArticle as-text toc-article dispositif" id="${z(`_TocArt${(a.num ?? r).replace(/\s+/gu, "")}`)}">${z(a.label)}${i ? ` : ${z(i)}` : ""}</p>`;
1405
+ if (mn(e, t)) {
1406
+ let r = [fn({
1177
1407
  content: o,
1178
- contextClass: gn(a.label)
1179
- }), ...sn(e, t)];
1180
- c.push($t(r));
1181
- for (let n of on(e, t)) n.includes("akn-pastille-table") || c.push(n);
1408
+ contextClass: Dn(a.label)
1409
+ }), ..._n(e, t)];
1410
+ c.push(un(r));
1411
+ for (let n of gn(e, t)) n.includes("akn-pastille-table") || c.push(n);
1182
1412
  return c.push(`</${n}>`), c.join("\n");
1183
1413
  }
1184
1414
  c.push(o);
1185
1415
  }
1186
1416
  let l = [];
1187
1417
  for (let n of ["content", "children"]) e(t).children().each((t, r) => {
1188
- if (!P(r)) return;
1189
- let i = R(r);
1190
- i === "num" || i === "heading" || n === "content" && i !== "content" || n === "children" && i === "content" || l.push(z(e, r));
1418
+ if (!L(r)) return;
1419
+ let i = B(r);
1420
+ i === "num" || i === "heading" || n === "content" && i !== "content" || n === "children" && i === "content" || l.push(V(e, r));
1191
1421
  });
1192
1422
  let u = l.join("\n");
1193
1423
  if (i !== "article") {
1194
- let n = Xt(u, M(e(t).children("num").first().text())) ? "" : Yt(e, t);
1424
+ let n = sn(u, P(e(t).children("num").first().text())) ? "" : on(e, t);
1195
1425
  n && c.push(n);
1196
1426
  }
1197
- return c.push(o ? Qt(u, o) : u), c.push(`</${n}>`), c.join("\n");
1427
+ return c.push(o ? ln(u, o) : u), c.push(`</${n}>`), c.join("\n");
1198
1428
  }
1199
- function cn(e, t, n, r) {
1200
- let i = ln(e(t).attr("style") ?? "", "font-family");
1201
- return !r && n !== "article" && /font-weight\s*:\s*bold/iu.test(i) && !/text-align\s*:/iu.test(i) && (i = Jt(i, "text-align", "center")), i || void 0;
1429
+ function yn(e, t, n, r) {
1430
+ let i = bn(e(t).attr("style") ?? "", "font-family");
1431
+ return !r && n !== "article" && /font-weight\s*:\s*bold/iu.test(i) && !/text-align\s*:/iu.test(i) && (i = an(i, "text-align", "center")), i || void 0;
1202
1432
  }
1203
- function ln(e, t) {
1433
+ function bn(e, t) {
1204
1434
  return e.split(";").map((e) => e.trim()).filter(Boolean).filter((e) => !e.toLowerCase().startsWith(`${t.toLowerCase()}:`)).join(";");
1205
1435
  }
1206
- function un(e) {
1436
+ function xn(e) {
1207
1437
  return `<table class="fixed-size large akn-section-table"><colgroup><col style="width: 5.0%;" class="texte-col-0 texte-col-pastille"><col style="width: 95.0%;" class="texte-col-1"></colgroup><tbody>${e.join("\n")}</tbody></table>`;
1208
1438
  }
1209
- function dn(e, t, n) {
1210
- let r = M(e(t).children("num").first().text()), i = M(e(t).children("heading").first().text()), a = fn(n), o = [];
1211
- return r && o.push(`<p class="${a.num} as-text dispositif"><span aria-label="">${L(r)}</span></p>`), i && o.push(`<p class="${a.heading} as-text dispositif"><span aria-label="">${L(i)}</span></p>`), o.join("\n");
1439
+ function Sn(e, t, n) {
1440
+ let r = P(e(t).children("num").first().text()), i = P(e(t).children("heading").first().text()), a = Cn(n), o = [];
1441
+ return r && o.push(`<p class="${a.num} as-text dispositif"><span aria-label="">${z(r)}</span></p>`), i && o.push(`<p class="${a.heading} as-text dispositif"><span aria-label="">${z(i)}</span></p>`), o.join("\n");
1212
1442
  }
1213
- function fn(e) {
1443
+ function Cn(e) {
1214
1444
  switch (e) {
1215
1445
  case "part": return {
1216
1446
  num: "TCNumPartie",
@@ -1234,22 +1464,22 @@ function fn(e) {
1234
1464
  };
1235
1465
  }
1236
1466
  }
1237
- function pn(e, t) {
1238
- let n = hn(M(e(t).children("num").first().text()));
1467
+ function wn(e, t) {
1468
+ let n = En(P(e(t).children("num").first().text()));
1239
1469
  if (n) return n;
1240
1470
  for (let n of e(t).parents().get()) {
1241
- if (!P(n)) continue;
1242
- let t = R(n);
1471
+ if (!L(n)) continue;
1472
+ let t = B(n);
1243
1473
  if (t !== "title" && t !== "part") continue;
1244
- let r = hn(M(e(n).children("num").first().text()));
1474
+ let r = En(P(e(n).children("num").first().text()));
1245
1475
  if (r) return r;
1246
1476
  }
1247
1477
  }
1248
- function mn(e, t) {
1249
- return pn(e, t);
1478
+ function Tn(e, t) {
1479
+ return wn(e, t);
1250
1480
  }
1251
- function hn(e) {
1252
- let [t, ...n] = M(e).split(/\s+/u);
1481
+ function En(e) {
1482
+ let [t, ...n] = P(e).split(/\s+/u);
1253
1483
  if (!t || n.length === 0) return;
1254
1484
  let r = t.toLocaleLowerCase("fr-FR");
1255
1485
  if ([
@@ -1259,10 +1489,10 @@ function hn(e) {
1259
1489
  "section"
1260
1490
  ].includes(r)) return `${r}-${n.join("_")}`;
1261
1491
  }
1262
- function gn(e) {
1263
- return `article-${M(e).replace(/^Article\s+/iu, "").replace(/\s+/gu, "_")} article`;
1492
+ function Dn(e) {
1493
+ return `article-${P(e).replace(/^Article\s+/iu, "").replace(/\s+/gu, "_")} article`;
1264
1494
  }
1265
- function _n(e) {
1495
+ function On(e) {
1266
1496
  switch (e) {
1267
1497
  case "part": return "partie";
1268
1498
  case "book": return "livre";
@@ -1274,11 +1504,11 @@ function _n(e) {
1274
1504
  default: return;
1275
1505
  }
1276
1506
  }
1277
- function vn(e, t) {
1278
- return [M(e(t).children("num").first().text()), M(e(t).children("heading").first().text())].filter(Boolean).join(" ");
1507
+ function kn(e, t) {
1508
+ return [P(e(t).children("num").first().text()), P(e(t).children("heading").first().text())].filter(Boolean).join(" ");
1279
1509
  }
1280
- function yn(e, t) {
1281
- let n = M(e(t).children("num").first().text()), r = M(e(t).children("heading").first().text()), i = w(n) ?? {
1510
+ function An(e, t) {
1511
+ let n = P(e(t).children("num").first().text()), r = P(e(t).children("heading").first().text()), i = w(n) ?? {
1282
1512
  label: n,
1283
1513
  num: n
1284
1514
  };
@@ -1288,24 +1518,24 @@ function yn(e, t) {
1288
1518
  type: "article"
1289
1519
  };
1290
1520
  }
1291
- function bn(e, t) {
1521
+ function jn(e, t) {
1292
1522
  e.items.push(...t.items);
1293
1523
  }
1294
- function xn(e, t) {
1524
+ function Mn(e, t) {
1295
1525
  let n = { items: [] };
1296
1526
  return e(t).children().each((t, r) => {
1297
- if (!P(r)) return;
1298
- let i = R(r);
1527
+ if (!L(r)) return;
1528
+ let i = B(r);
1299
1529
  if (i === "article") {
1300
- n.items.push(yn(e, r));
1530
+ n.items.push(An(e, r));
1301
1531
  return;
1302
1532
  }
1303
- let a = _n(i);
1533
+ let a = On(i);
1304
1534
  if (!a) {
1305
- bn(n, xn(e, r));
1535
+ jn(n, Mn(e, r));
1306
1536
  return;
1307
1537
  }
1308
- let o = vn(e, r), s = xn(e, r);
1538
+ let o = kn(e, r), s = Mn(e, r);
1309
1539
  !o && s.items.length === 0 || n.items.push({
1310
1540
  ...s,
1311
1541
  id: e(r).attr("eId") ?? e(r).attr("GUID"),
@@ -1314,26 +1544,26 @@ function xn(e, t) {
1314
1544
  });
1315
1545
  }), n;
1316
1546
  }
1317
- function Sn(e) {
1547
+ function Nn(e) {
1318
1548
  let t = e("body").first().get(0);
1319
- return t === void 0 ? { items: [] } : xn(e, t);
1549
+ return t === void 0 ? { items: [] } : Mn(e, t);
1320
1550
  }
1321
- function Cn(e) {
1551
+ function Pn(e) {
1322
1552
  return e("FRBRExpression FRBRdate[name=\"#depot\"]").attr("date") ?? e("FRBRWork FRBRdate[name=\"#presentation\"]").attr("date");
1323
1553
  }
1324
- function wn(e) {
1554
+ function Fn(e) {
1325
1555
  let t = e("preamble").first(), n = e("body").first(), r = ["<div class=\"akn-bill\">"];
1326
- return t.length > 0 && (r.push("<section class=\"akn-preamble\">"), r.push(Wt(e, t.get(0))), r.push("</section>")), r.push("<section class=\"akn-body\">"), n.children().each((t, n) => {
1327
- P(n) && r.push(R(n) === "article" ? V(e, n, "article", "akn-article") : z(e, n));
1556
+ return t.length > 0 && (r.push("<section class=\"akn-preamble\">"), r.push(en(e, t.get(0))), r.push("</section>")), r.push("<section class=\"akn-body\">"), n.children().each((t, n) => {
1557
+ L(n) && r.push(B(n) === "article" ? vn(e, n, "article", "akn-article") : V(e, n));
1328
1558
  }), r.push("</section></div>"), r.join("\n");
1329
1559
  }
1330
- function Tn(e) {
1331
- let t = g(e, { xml: {
1560
+ function In(e) {
1561
+ let t = _(e, { xml: {
1332
1562
  decodeEntities: !1,
1333
1563
  lowerCaseTags: !1,
1334
1564
  lowerCaseAttributeNames: !1,
1335
1565
  xmlMode: !0
1336
- } }), n = Cn(t), r = wn(t);
1566
+ } }), n = Pn(t), r = Fn(t);
1337
1567
  return {
1338
1568
  sourceFormat: "akoma-ntoso",
1339
1569
  documentDate: n,
@@ -1341,42 +1571,42 @@ function Tn(e) {
1341
1571
  linkedHtml: r
1342
1572
  };
1343
1573
  }
1344
- function En(e) {
1345
- return Dn(g(e));
1574
+ function Ln(e) {
1575
+ return Rn(_(e));
1346
1576
  }
1347
- function Dn(e) {
1577
+ function Rn(e) {
1348
1578
  let t = [];
1349
1579
  return e("article.akn-article").each((n, r) => {
1350
- let i = e(r).children("p.TCNumArticle").first().get(0), a = M(i ? e(i).text() : ""), o = w(a) ?? { label: a || `Article ${n + 1}` }, s = e(r).attr("id") ?? `akn-article-${String(n + 1).padStart(3, "0")}`, c = [r], l = lt(e, s, c), u = l.filter((e) => e.kind !== "noise").map((e) => e.text).join("\n");
1580
+ let i = e(r).find("p.TCNumArticle").first().get(0), a = P(i ? e(i).text() : ""), o = w(a) ?? { label: a || `Article ${n + 1}` }, s = e(r).attr("id") ?? `akn-article-${String(n + 1).padStart(3, "0")}`, c = [r], l = _t(e, s, c), u = l.filter((e) => e.kind !== "noise").map((e) => e.text).join("\n");
1351
1581
  t.push({
1352
1582
  id: s,
1353
1583
  label: o.label,
1354
1584
  num: o.num,
1355
1585
  title: o.title,
1356
- text: qe(e, c),
1357
- html: Ue(e, r),
1586
+ text: Qe(e, c),
1587
+ html: Je(e, r),
1358
1588
  directiveText: u,
1359
1589
  blocks: l
1360
1590
  });
1361
1591
  }), t;
1362
1592
  }
1363
- function On(e) {
1364
- let t = g(e);
1593
+ function zn(e) {
1594
+ let t = _(e);
1365
1595
  return {
1366
- articles: Dn(t),
1596
+ articles: Rn(t),
1367
1597
  htmlWithLinks: t.html()
1368
1598
  };
1369
1599
  }
1370
- async function kn(e, t) {
1371
- let n = new ge("parseAkomaNtosoBillRaw"), r = n.timeSync("cheerioLoadXml", () => g(e, { xml: {
1600
+ async function Bn(e, t) {
1601
+ let n = new be("parseAkomaNtosoBillRaw"), r = n.timeSync("cheerioLoadXml", () => _(e, { xml: {
1372
1602
  decodeEntities: !1,
1373
1603
  lowerCaseTags: !1,
1374
1604
  lowerCaseAttributeNames: !1,
1375
1605
  xmlMode: !0
1376
- } })), i = t.date ?? Cn(r), a = n.timeSync("renderAknHtml", () => wn(r), { inputSize: e.length }), o = t.linkedHtml ?? await n.time("addLinksToRenderedAknHtml", () => Ye(a, {
1606
+ } })), i = t.date ?? Pn(r), a = n.timeSync("renderAknHtml", () => Fn(r), { inputSize: e.length }), o = t.linkedHtml ?? await n.time("addLinksToRenderedAknHtml", () => et(a, {
1377
1607
  ...t,
1378
1608
  date: i
1379
- }, i)), s = n.timeSync("extractRenderedAknArticles", () => En(a)), c = n.timeSync("injectHiddenArticleSummary", () => ut(o, s)), { articles: l, htmlWithLinks: u } = n.timeSync("extractLinkedAknArticlesAndTaggedHtml", () => On(c)), d = l.length > 0 ? l : s, f = n.timeSync("extractAknTableOfContents", () => Sn(r)), p = n.timeSync("buildParsedDocument", () => It("akoma-ntoso", a, l.length > 0 ? u : c, i, d, f, t.includeDirectiveAnalysis));
1609
+ }, i)), s = n.timeSync("extractRenderedAknArticles", () => Ln(a)), c = n.timeSync("injectHiddenArticleSummary", () => vt(o, s)), { articles: l, htmlWithLinks: u } = n.timeSync("extractLinkedAknArticlesAndTaggedHtml", () => zn(c)), d = l.length > 0 ? l : s, f = n.timeSync("extractAknTableOfContents", () => Nn(r)), p = n.timeSync("buildParsedDocument", () => Gt("akoma-ntoso", a, l.length > 0 ? u : c, i, d, f, t.includeDirectiveAnalysis, Jt(d, f, l.length > 0 ? u : c, "akoma-ntoso")));
1380
1610
  return n.log({
1381
1611
  articleCount: p.articles.length,
1382
1612
  blockCount: p.articles.reduce((e, t) => e + t.blocks.length, 0),
@@ -1384,25 +1614,25 @@ async function kn(e, t) {
1384
1614
  targetDirectiveCount: p.directives.filter((e) => e.targetIds !== void 0).length
1385
1615
  }), p;
1386
1616
  }
1387
- async function An(e, t) {
1388
- let n = Tn(e), r = t.date ?? n.documentDate;
1617
+ async function Vn(e, t) {
1618
+ let n = In(e), r = t.date ?? n.documentDate;
1389
1619
  return {
1390
1620
  sourceFormat: "akoma-ntoso",
1391
1621
  documentDate: r,
1392
1622
  html: n.html,
1393
- linkedHtml: await Ye(n.html, t, r)
1623
+ linkedHtml: await et(n.html, t, r)
1394
1624
  };
1395
1625
  }
1396
1626
  //#endregion
1397
1627
  //#region src/lib/server/assemblee_document_search.ts
1398
- var jn = /\bexpos[ée]\s+des\s+motifs\b/giu, Mn = /\barticle\s+(?:premier|1er|\d+)/iu;
1399
- function Nn(e) {
1628
+ var Hn = /\bexpos[ée]\s+des\s+motifs\b/giu, Un = /\barticle\s+(?:premier|1er|\d+)/iu;
1629
+ function Wn(e) {
1400
1630
  return e.replace(/\u00a0/gu, " ").replace(/\s+/gu, " ").trim();
1401
1631
  }
1402
- function Pn(e) {
1403
- let t = Nn(g(e).text()), n = [...t.matchAll(jn)], r = /* @__PURE__ */ new Set(), i = [];
1632
+ function Gn(e) {
1633
+ let t = Wn(_(e).text()), n = [...t.matchAll(Hn)], r = /* @__PURE__ */ new Set(), i = [];
1404
1634
  for (let [e, a] of n.entries()) {
1405
- let o = (a.index ?? 0) + a[0].length, s = t.slice(o), c = Mn.exec(s), l = Nn(s.slice(0, c?.index ?? s.length));
1635
+ let o = (a.index ?? 0) + a[0].length, s = t.slice(o), c = Un.exec(s), l = Wn(s.slice(0, c?.index ?? s.length));
1406
1636
  if (l.length < 20 || r.has(l)) continue;
1407
1637
  r.add(l);
1408
1638
  let u = `expose-des-motifs-${e + 1}`;
@@ -1418,8 +1648,8 @@ function Pn(e) {
1418
1648
  }
1419
1649
  return i;
1420
1650
  }
1421
- async function Fn({ date: e, html: t, linkBaseUrl: n, linkType: r }) {
1422
- let i = await Bt(t, {
1651
+ async function Kn({ date: e, html: t, linkBaseUrl: n, linkType: r }) {
1652
+ let i = await Xt(t, {
1423
1653
  date: e,
1424
1654
  includeDirectiveAnalysis: !1,
1425
1655
  linkBaseUrl: n,
@@ -1428,7 +1658,7 @@ async function Fn({ date: e, html: t, linkBaseUrl: n, linkType: r }) {
1428
1658
  });
1429
1659
  return {
1430
1660
  items: [...i.articles.map((e) => {
1431
- let t = Nn(e.directiveText || e.text);
1661
+ let t = Wn(e.directiveText || e.text);
1432
1662
  if (t) return {
1433
1663
  anchor: e.id,
1434
1664
  articleNumber: e.num ?? null,
@@ -1438,17 +1668,17 @@ async function Fn({ date: e, html: t, linkBaseUrl: n, linkType: r }) {
1438
1668
  label: e.label,
1439
1669
  title: e.title ?? null
1440
1670
  };
1441
- }).filter((e) => e !== void 0), ...Pn(t)],
1671
+ }).filter((e) => e !== void 0), ...Gn(t)],
1442
1672
  tableOfContents: i.tableOfContents
1443
1673
  };
1444
1674
  }
1445
- function In(e, t) {
1446
- return be("sha256").update(JSON.stringify({
1675
+ function qn(e, t) {
1676
+ return we("sha256").update(JSON.stringify({
1447
1677
  item: e,
1448
1678
  metadata: t
1449
1679
  })).digest("hex");
1450
1680
  }
1451
- function Ln(e) {
1681
+ function Jn(e) {
1452
1682
  if (typeof e != "object" || !e) return;
1453
1683
  let t = e.cycleDeVie?.chrono;
1454
1684
  if (t !== void 0) for (let e of [
@@ -1463,11 +1693,11 @@ function Ln(e) {
1463
1693
  }
1464
1694
  //#endregion
1465
1695
  //#region src/lib/server/senat_amendment_search.ts
1466
- function Rn(e) {
1467
- return e?.trim() ? g(e).text().replace(/\u00a0/gu, " ").replace(/\s+/gu, " ").trim() : "";
1696
+ function Yn(e) {
1697
+ return e?.trim() ? _(e).text().replace(/\u00a0/gu, " ").replace(/\s+/gu, " ").trim() : "";
1468
1698
  }
1469
- function zn({ dispositifHtml: e, objetHtml: t }) {
1470
- let n = Rn(e), r = Rn(t);
1699
+ function Xn({ dispositifHtml: e, objetHtml: t }) {
1700
+ let n = Yn(e), r = Yn(t);
1471
1701
  return [...n ? [{
1472
1702
  content: n,
1473
1703
  itemKind: "dispositif",
@@ -1478,165 +1708,165 @@ function zn({ dispositifHtml: e, objetHtml: t }) {
1478
1708
  label: "Objet"
1479
1709
  }] : []];
1480
1710
  }
1481
- function Bn(e, t) {
1482
- return be("sha256").update(JSON.stringify({
1711
+ function Zn(e, t) {
1712
+ return we("sha256").update(JSON.stringify({
1483
1713
  item: e,
1484
1714
  metadata: t
1485
1715
  })).digest("hex");
1486
1716
  }
1487
1717
  //#endregion
1488
1718
  //#region src/lib/text_parsers/amendment_action_directives.ts
1489
- function H(e, t) {
1719
+ function U(e, t) {
1490
1720
  return {
1491
1721
  ...t,
1492
1722
  position: e.position(),
1493
1723
  type: "amendment_action_directive"
1494
1724
  };
1495
1725
  }
1496
- function Vn(e, t) {
1726
+ function Qn(e, t) {
1497
1727
  return {
1498
1728
  type: e === "start" ? "head_of_target" : "tail_after_target",
1499
- unit: t ? l(t) : "article"
1729
+ unit: t ? u(t) : "article"
1500
1730
  };
1501
1731
  }
1502
- function Hn(e) {
1732
+ function $n(e) {
1503
1733
  return e === "start" ? "insert_before" : "insert_after";
1504
1734
  }
1505
- var Un = O(D("[\\s\\S]*?(?=supprimer|substituer|remplacer|ins[eé]rer|compl[eé]ter|r[eé]diger)", { flags: "i" }), { default: "" }), U = E(f, T([D("les?\\s+", { flags: "i" }), c], { value: (e) => e[1] }), c, o), Wn = E(T([D("la\\s+fin\\s+de\\s+", { flags: "i" }), U], { value: (e) => {
1735
+ var er = k(D("[\\s\\S]*?(?=supprimer|substituer|remplacer|ins[eé]rer|compl[eé]ter|r[eé]diger)", { flags: "i" }), { default: "" }), W = E(p, T([D("les?\\s+", { flags: "i" }), c], { value: (e) => e[1] }), c, o), tr = E(T([D("la\\s+fin\\s+de\\s+", { flags: "i" }), W], { value: (e) => {
1506
1736
  let t = e[1];
1507
1737
  return {
1508
1738
  targetReference: t,
1509
1739
  targetScope: {
1510
1740
  type: "tail_after_target",
1511
- unit: l(t)
1741
+ unit: u(t)
1512
1742
  }
1513
1743
  };
1514
- } }), T([oe], { value: (e) => ({ targetScope: e[0] }) })), W = O(T([
1515
- O(D("(?:[aà]\\s+la\\s+fin\\s+(?:du|de\\s+la|de\\s+l['’]?)\\s*)", { flags: "i" }), { default: "" }),
1516
- O(D("(?:au\\s+d[eé]but\\s+d(?:u|e\\s+la|e\\s+l['’]?)\\s*)", { flags: "i" }), { default: "" }),
1517
- U,
1518
- O(D("\\s*,?\\s*(?:(?:[IVXLCDM]+)\\s*[.\\-–—]+\\s*|\\d+°\\s*|[a-z]\\)\\s*)?", { flags: "i" }), { default: "" })
1744
+ } }), T([le], { value: (e) => ({ targetScope: e[0] }) })), G = k(T([
1745
+ k(D("(?:[aà]\\s+la\\s+fin\\s+(?:du|de\\s+la|de\\s+l['’]?)\\s*)", { flags: "i" }), { default: "" }),
1746
+ k(D("(?:au\\s+d[eé]but\\s+d(?:u|e\\s+la|e\\s+l['’]?)\\s*)", { flags: "i" }), { default: "" }),
1747
+ W,
1748
+ k(D("\\s*,?\\s*(?:(?:[IVXLCDM]+)\\s*[.\\-–—]+\\s*|\\d+°\\s*|[a-z]\\)\\s*)?", { flags: "i" }), { default: "" })
1519
1749
  ], { value: (e, t) => ({
1520
1750
  reference: e[2],
1521
1751
  text: t.text()
1522
- }) }), { default: null }), Gn = O(D(`(?:(?:[aà]\\s+)?la\\s+(?:derni(?:ère|ere)|${pe})\\s+occurrence\\s+)`, { flags: "i" }), { default: "" });
1523
- function G(e) {
1752
+ }) }), { default: null }), nr = k(D(`(?:(?:[aà]\\s+)?la\\s+(?:derni(?:ère|ere)|${_e})\\s+occurrence\\s+)`, { flags: "i" }), { default: "" });
1753
+ function K(e) {
1524
1754
  return e?.text ?? "";
1525
1755
  }
1526
- function K(e) {
1527
- return { citation: m(e.position()) };
1756
+ function rr(e) {
1757
+ return { citation: h(e.position()) };
1528
1758
  }
1529
- var q = E(T([S], { value: (e) => ({ citation: e[0] }) }), D("\\S[\\s\\S]*", { value: (e, t) => K(t) })), Kn = D("\\S[\\s\\S]*", { value: (e, t) => K(t) }), J = D("[^:«“\"]*(?::\\s*)?", { flags: "i" }), qn = D("\\S[\\s\\S]*?(?=\\s+par\\s+(?:les?\\s+)?(?:mots?|montants?|taux|références?|mentions?|dates?|années?)\\s*:)", {
1759
+ var q = E(T([C], { value: (e) => ({ citation: e[0] }) }), D("\\S[\\s\\S]*", { value: (e, t) => rr(t) })), ir = D("\\S[\\s\\S]*", { value: (e, t) => rr(t) }), J = D("[^:«“\"]*(?::\\s*)?", { flags: "i" }), ar = D("\\S[\\s\\S]*?(?=\\s+par\\s+(?:les?\\s+)?(?:mots?|montants?|taux|références?|mentions?|dates?|années?)\\s*:)", {
1530
1760
  flags: "i",
1531
- value: (e, t) => K(t)
1532
- }), Jn = D("\\S[\\s\\S]*?(?=\\s+(?:ins[eé]rer|ajouter|supprimer|r[eé]diger)\\b)", {
1761
+ value: (e, t) => rr(t)
1762
+ }), or = D("\\S[\\s\\S]*?(?=\\s+(?:ins[eé]rer|ajouter|supprimer|r[eé]diger)\\b)", {
1533
1763
  flags: "i",
1534
- value: (e, t) => K(t)
1535
- }), Yn = D("\\S[\\s\\S]*?(?=\\s*(?:(?:[IVXLCDM]+)\\s*[.\\-–—]+\\s*|\\d+°\\s*|[a-z]\\)\\s*|$))", {
1764
+ value: (e, t) => rr(t)
1765
+ }), sr = D("\\S[\\s\\S]*?(?=\\s*(?:(?:[IVXLCDM]+)\\s*[.\\-–—]+\\s*|\\d+°\\s*|[a-z]\\)\\s*|$))", {
1536
1766
  flags: "i",
1537
- value: (e, t) => K(t)
1538
- }), Xn = E(T([S], { value: (e) => ({ citation: e[0] }) }), qn), Zn = E(T([S], { value: (e) => ({ citation: e[0] }) }), Yn), Qn = T([D(`${d}s?\\s*:?\\s*`, { flags: "i" }), Xn], { value: (e) => e[1] }), $n = T([D(`${ae}s?(?: suivant(?:e)?s?)?\\s*:?\\s*`, { flags: "i" }), Zn], { value: (e) => e[1] }), er = E(T([S], { value: (e) => ({ citation: e[0] }) }), Jn), tr = T([
1539
- Gn,
1540
- D(`${d}s?\\s*:?\\s*`, { flags: "i" }),
1541
- er
1542
- ], { value: (e) => e[2] }), nr = T([
1543
- Gn,
1544
- D(`${d}s?\\s*:?\\s*`, { flags: "i" }),
1545
- E(T([S], { value: (e) => ({ citation: e[0] }) }), Kn)
1767
+ value: (e, t) => rr(t)
1768
+ }), cr = E(T([C], { value: (e) => ({ citation: e[0] }) }), ar), lr = E(T([C], { value: (e) => ({ citation: e[0] }) }), sr), ur = T([D(`${f}s?\\s*:?\\s*`, { flags: "i" }), cr], { value: (e) => e[1] }), dr = T([D(`${ce}s?(?: suivant(?:e)?s?)?\\s*:?\\s*`, { flags: "i" }), lr], { value: (e) => e[1] }), fr = E(T([C], { value: (e) => ({ citation: e[0] }) }), or), pr = T([
1769
+ nr,
1770
+ D(`${f}s?\\s*:?\\s*`, { flags: "i" }),
1771
+ fr
1772
+ ], { value: (e) => e[2] }), mr = T([
1773
+ nr,
1774
+ D(`${f}s?\\s*:?\\s*`, { flags: "i" }),
1775
+ E(T([C], { value: (e) => ({ citation: e[0] }) }), ir)
1546
1776
  ], { value: (e) => e[2] });
1547
1777
  function Y(e) {
1548
1778
  return e?.reference;
1549
1779
  }
1550
- var rr = T([Un, D("supprimer\\s+cet\\s+article", { flags: "i" })], { value: (e, t) => H(t, {
1780
+ var hr = T([er, D("supprimer\\s+cet\\s+article", { flags: "i" })], { value: (e, t) => U(t, {
1551
1781
  contextText: e[0],
1552
1782
  kind: "delete_article"
1553
- }) }), ir = T([
1554
- W,
1783
+ }) }), gr = T([
1784
+ G,
1555
1785
  D("supprimer", { flags: "i" }),
1556
- O(T([k, U], { value: (e) => e[1] }), { default: null }),
1557
- O(T([k, nr], { value: (e) => e[1] }), { default: null })
1558
- ], { value: (e, t) => H(t, {
1559
- contextText: G(e[0]),
1786
+ k(T([A, W], { value: (e) => e[1] }), { default: null }),
1787
+ k(T([A, mr], { value: (e) => e[1] }), { default: null })
1788
+ ], { value: (e, t) => U(t, {
1789
+ contextText: K(e[0]),
1560
1790
  kind: "delete_portion",
1561
1791
  targetCitation: e[3]?.citation ?? void 0,
1562
1792
  targetReference: e[2] ?? Y(e[0])
1563
- }) }), ar = T([
1564
- W,
1793
+ }) }), _r = T([
1794
+ G,
1565
1795
  E(D("r[eé]diger\\s+ainsi", { flags: "i" }), D("r[eé]tablir", { flags: "i" })),
1566
1796
  J,
1567
1797
  q
1568
- ], { value: (e, t) => H(t, {
1569
- contextText: G(e[0]),
1798
+ ], { value: (e, t) => U(t, {
1799
+ contextText: K(e[0]),
1570
1800
  kind: "rewrite_portion",
1571
1801
  replacementCitation: e[3].citation,
1572
1802
  targetReference: Y(e[0])
1573
- }) }), or = T([
1574
- W,
1803
+ }) }), vr = T([
1804
+ G,
1575
1805
  E(D("substituer", { flags: "i" }), D("remplacer", { flags: "i" })),
1576
- k,
1577
- Gn,
1578
- Qn,
1806
+ A,
1807
+ nr,
1808
+ ur,
1579
1809
  D("\\s*,?\\s*"),
1580
- O(D("par\\s+", { flags: "i" }), { default: "" }),
1581
- $n
1582
- ], { value: (e, t) => H(t, {
1583
- contextText: G(e[0]),
1810
+ k(D("par\\s+", { flags: "i" }), { default: "" }),
1811
+ dr
1812
+ ], { value: (e, t) => U(t, {
1813
+ contextText: K(e[0]),
1584
1814
  kind: "replace",
1585
1815
  replacementCitation: e[7].citation,
1586
1816
  targetCitation: e[4].citation,
1587
1817
  targetReference: Y(e[0])
1588
- }) }), sr = T([
1589
- W,
1818
+ }) }), yr = T([
1819
+ G,
1590
1820
  D("substituer", { flags: "i" }),
1591
- k,
1592
- O(D("(?:[aà]|aux?|à la)\\s+", { flags: "i" }), { default: "" }),
1593
- U,
1821
+ A,
1822
+ k(D("(?:[aà]|aux?|à la)\\s+", { flags: "i" }), { default: "" }),
1823
+ W,
1594
1824
  D("[\\s\\S]*?(?=[«“\"]|$)"),
1595
1825
  q
1596
- ], { value: (e, t) => H(t, {
1597
- contextText: G(e[0]),
1826
+ ], { value: (e, t) => U(t, {
1827
+ contextText: K(e[0]),
1598
1828
  kind: "rewrite_portion",
1599
1829
  replacementCitation: e[6].citation,
1600
1830
  targetReference: e[4] ?? Y(e[0])
1601
- }) }), cr = T([
1602
- y,
1603
- k,
1831
+ }) }), br = T([
1832
+ x,
1833
+ A,
1604
1834
  D("l['’ ]article", { flags: "i" }),
1605
1835
  D("[\\s\\S]*?(?=ins[eé]rer)", { flags: "i" }),
1606
1836
  D("ins[eé]rer", { flags: "i" }),
1607
1837
  J,
1608
1838
  q
1609
- ], { value: (e, t) => H(t, {
1839
+ ], { value: (e, t) => U(t, {
1610
1840
  contextText: "",
1611
1841
  insertCitation: e[6].citation,
1612
1842
  kind: e[0] === "before" ? "insert_article_before" : "insert_article_after"
1613
- }) }), lr = T([
1614
- y,
1615
- k,
1616
- U,
1843
+ }) }), xr = T([
1844
+ x,
1845
+ A,
1846
+ W,
1617
1847
  D("[\\s\\S]*?(?=ins[eé]rer|ajouter)", { flags: "i" }),
1618
1848
  E(D("ins[eé]rer", { flags: "i" }), D("ajouter", { flags: "i" })),
1619
1849
  J,
1620
1850
  q
1621
- ], { value: (e, t) => H(t, {
1851
+ ], { value: (e, t) => U(t, {
1622
1852
  contextText: "",
1623
1853
  insertCitation: e[6].citation,
1624
1854
  kind: s(e[0]),
1625
1855
  targetReference: e[2]
1626
- }) }), ur = T([
1627
- y,
1628
- k,
1856
+ }) }), Sr = T([
1857
+ x,
1858
+ A,
1629
1859
  D("l['’ ]alin[eé]a", { flags: "i" }),
1630
1860
  D("[\\s\\S]*?(?=ins[eé]rer)", { flags: "i" }),
1631
1861
  D("ins[eé]rer", { flags: "i" }),
1632
1862
  J,
1633
1863
  q
1634
- ], { value: (e, t) => H(t, {
1864
+ ], { value: (e, t) => U(t, {
1635
1865
  contextText: "",
1636
1866
  insertCitation: e[6].citation,
1637
1867
  kind: s(e[0])
1638
- }) }), dr = T([
1639
- W,
1868
+ }) }), Cr = T([
1869
+ G,
1640
1870
  n,
1641
1871
  D("[\\s\\S]*?(?=ins[eé]rer|ajouter)", { flags: "i" }),
1642
1872
  E(D("ins[eé]rer", { flags: "i" }), D("ajouter", { flags: "i" })),
@@ -1644,55 +1874,55 @@ var rr = T([Un, D("supprimer\\s+cet\\s+article", { flags: "i" })], { value: (e,
1644
1874
  q
1645
1875
  ], { value: (e, t) => {
1646
1876
  let n = e[0], r = Y(n), i = e[1];
1647
- return H(t, {
1648
- contextText: G(n),
1877
+ return U(t, {
1878
+ contextText: K(n),
1649
1879
  insertCitation: e[5].citation,
1650
- kind: Hn(i),
1880
+ kind: $n(i),
1651
1881
  targetReference: r,
1652
- targetScope: Vn(i, r)
1882
+ targetScope: Qn(i, r)
1653
1883
  });
1654
- } }), fr = T([
1655
- W,
1656
- y,
1657
- k,
1658
- tr,
1884
+ } }), wr = T([
1885
+ G,
1886
+ x,
1887
+ A,
1888
+ pr,
1659
1889
  D("[\\s\\S]*?(?=ins[eé]rer)"),
1660
1890
  D("ins[eé]rer", { flags: "i" }),
1661
- k,
1662
- $n
1663
- ], { value: (e, t) => H(t, {
1664
- contextText: G(e[0]),
1891
+ A,
1892
+ dr
1893
+ ], { value: (e, t) => U(t, {
1894
+ contextText: K(e[0]),
1665
1895
  insertCitation: e[7].citation,
1666
1896
  kind: s(e[1]),
1667
1897
  targetCitation: e[3].citation,
1668
1898
  targetReference: Y(e[0])
1669
- }) }), pr = T([
1899
+ }) }), Tr = T([
1900
+ G,
1901
+ x,
1902
+ A,
1670
1903
  W,
1671
- y,
1672
- k,
1673
- U,
1674
1904
  D("[\\s\\S]*?(?=ins[eé]rer|ajouter)", { flags: "i" }),
1675
1905
  E(D("ins[eé]rer", { flags: "i" }), D("ajouter", { flags: "i" })),
1676
1906
  J,
1677
1907
  q
1678
- ], { value: (e, t) => H(t, {
1679
- contextText: G(e[0]),
1908
+ ], { value: (e, t) => U(t, {
1909
+ contextText: K(e[0]),
1680
1910
  insertCitation: e[7].citation,
1681
1911
  kind: s(e[1]),
1682
1912
  targetReference: Y(e[0]) ?? e[3]
1683
- }) }), mr = E(dr, cr, lr, ur, sr, T([
1684
- W,
1685
- y,
1686
- k,
1687
- tr,
1913
+ }) }), Er = E(Cr, br, xr, Sr, yr, T([
1914
+ G,
1915
+ x,
1916
+ A,
1917
+ pr,
1688
1918
  D("[\\s\\S]*?(?=supprimer|r[eé]diger)", { flags: "i" }),
1689
1919
  E(T([
1690
1920
  D("supprimer", {
1691
1921
  flags: "i",
1692
1922
  value: "delete_portion"
1693
1923
  }),
1694
- k,
1695
- Wn
1924
+ A,
1925
+ tr
1696
1926
  ], { value: (e) => ({
1697
1927
  kind: e[0],
1698
1928
  ...e[2]
@@ -1701,8 +1931,8 @@ var rr = T([Un, D("supprimer\\s+cet\\s+article", { flags: "i" })], { value: (e,
1701
1931
  flags: "i",
1702
1932
  value: "rewrite_portion"
1703
1933
  }),
1704
- k,
1705
- Wn,
1934
+ A,
1935
+ tr,
1706
1936
  J,
1707
1937
  q
1708
1938
  ], { value: (e) => ({
@@ -1712,49 +1942,49 @@ var rr = T([Un, D("supprimer\\s+cet\\s+article", { flags: "i" })], { value: (e,
1712
1942
  }) }))
1713
1943
  ], { value: (e, t) => {
1714
1944
  let n = e[5];
1715
- return H(t, {
1716
- contextText: G(e[0]),
1945
+ return U(t, {
1946
+ contextText: K(e[0]),
1717
1947
  kind: n.kind,
1718
1948
  replacementCitation: n.replacementCitation,
1719
1949
  targetCitation: e[3].citation,
1720
1950
  targetReference: Y(e[0]) ?? n.targetReference,
1721
1951
  targetScope: n.targetScope
1722
1952
  });
1723
- } }), fr, pr, T([
1724
- Un,
1953
+ } }), wr, Tr, T([
1954
+ er,
1725
1955
  D("ins[eé]rer", { flags: "i" }),
1726
1956
  D(`[\\s\\S]*?(?=${e})`, { flags: "i" }),
1727
- y,
1957
+ x,
1728
1958
  J,
1729
- S,
1959
+ C,
1730
1960
  J,
1731
- S
1732
- ], { value: (e, t) => H(t, {
1961
+ C
1962
+ ], { value: (e, t) => U(t, {
1733
1963
  contextText: e[0],
1734
1964
  insertCitation: e[8],
1735
1965
  kind: s(e[3]),
1736
1966
  targetCitation: e[6]
1737
- }) }), or, ar, T([
1738
- W,
1967
+ }) }), vr, _r, T([
1968
+ G,
1739
1969
  D("compl[eé]ter", { flags: "i" }),
1740
- O(T([k, U], { value: (e) => e[1] }), { default: null }),
1970
+ k(T([A, W], { value: (e) => e[1] }), { default: null }),
1741
1971
  J,
1742
1972
  q
1743
- ], { value: (e, t) => H(t, {
1744
- contextText: G(e[0]),
1973
+ ], { value: (e, t) => U(t, {
1974
+ contextText: K(e[0]),
1745
1975
  insertCitation: e[4].citation,
1746
1976
  kind: "insert_after",
1747
1977
  targetReference: e[2] ?? Y(e[0])
1748
- }) }), rr, ir);
1978
+ }) }), hr, gr);
1749
1979
  //#endregion
1750
1980
  //#region src/lib/server/parsed_amendments.ts
1751
- function hr(e) {
1981
+ function Dr(e) {
1752
1982
  return e.replace(/\s+/gu, " ").trim();
1753
1983
  }
1754
- function gr(e) {
1755
- return e.split(/\n/gu).map(hr).filter(Boolean).join("\n");
1984
+ function Or(e) {
1985
+ return e.split(/\n/gu).map(Dr).filter(Boolean).join("\n");
1756
1986
  }
1757
- function _r(e, t) {
1987
+ function kr(e, t) {
1758
1988
  let { start: n, stop: r } = t;
1759
1989
  for (; n < r && /\s/u.test(e[n]);) n++;
1760
1990
  for (; r > n && /\s/u.test(e[r - 1]);) r--;
@@ -1763,16 +1993,16 @@ function _r(e, t) {
1763
1993
  stop: r
1764
1994
  } : null;
1765
1995
  }
1766
- function vr(e, t) {
1767
- return se(ce(e), t);
1996
+ function Ar(e, t) {
1997
+ return de(pe(e), t);
1768
1998
  }
1769
- function yr(e) {
1999
+ function jr(e) {
1770
2000
  return e === "before_article" || e === "on_article" || e === "after_article" ? e : "unknown";
1771
2001
  }
1772
- function br(e) {
2002
+ function Mr(e) {
1773
2003
  return {
1774
2004
  articleLabel: e.targetArticleLabel ?? null,
1775
- targetPosition: yr(e.targetPosition),
2005
+ targetPosition: jr(e.targetPosition),
1776
2006
  alinea: e.targetAlinea ?? null,
1777
2007
  alineaLabel: e.targetAlineaLabel ?? null,
1778
2008
  subdivisionSourceId: e.targetSubdivisionSourceId ?? null,
@@ -1787,68 +2017,68 @@ function X(e) {
1787
2017
  sourceText: e.text
1788
2018
  };
1789
2019
  }
1790
- function xr(e) {
2020
+ function Nr(e) {
1791
2021
  return {
1792
2022
  ...e.originalTransformation === void 0 ? {} : { sourceOriginalTransformation: e.originalTransformation },
1793
2023
  sourcePosition: e.position,
1794
2024
  sourceText: e.text
1795
2025
  };
1796
2026
  }
1797
- function Sr(e) {
2027
+ function Pr(e) {
1798
2028
  return {
1799
2029
  ...e?.originalTransformation === void 0 ? {} : { dispositifOriginalTransformation: e.originalTransformation },
1800
2030
  ...e === null ? {} : { dispositifPosition: e.position },
1801
2031
  dispositifText: e?.text ?? null
1802
2032
  };
1803
2033
  }
1804
- function Z(e, t, n, r = gr(e.slice(n.start, n.stop))) {
2034
+ function Fr(e, t, n, r = Or(e.slice(n.start, n.stop))) {
1805
2035
  return {
1806
- originalTransformation: vr(t, n),
2036
+ originalTransformation: Ar(t, n),
1807
2037
  position: n,
1808
2038
  text: r
1809
2039
  };
1810
2040
  }
1811
- function Cr(e) {
2041
+ function Ir(e) {
1812
2042
  let t = e.dispositifHtml ?? e.dispositifText;
1813
2043
  if (!t) return null;
1814
- let n = e.dispositifHtml ? le()(t) : me(t), r = n.output, i = _r(r, {
2044
+ let n = e.dispositifHtml ? me()(t) : ve(t), r = n.output, i = kr(r, {
1815
2045
  start: 0,
1816
2046
  stop: r.length
1817
2047
  });
1818
2048
  return {
1819
- dispositif: i === null ? null : Z(r, n, i),
2049
+ dispositif: i === null ? null : Fr(r, n, i),
1820
2050
  simplifiedText: r,
1821
2051
  transformation: n
1822
2052
  };
1823
2053
  }
1824
- function Q(e) {
2054
+ function Z(e) {
1825
2055
  if (!e) return [];
1826
- if (e.type === "enumeration") return [...Q(e.left), ...Q(e.right)];
2056
+ if (e.type === "enumeration") return [...Z(e.left), ...Z(e.right)];
1827
2057
  if (e.type === "bounded-interval") {
1828
- let t = Q(e.first)[0], n = Q(e.last)[0];
2058
+ let t = Z(e.first)[0], n = Z(e.last)[0];
1829
2059
  return t !== void 0 && n !== void 0 && n >= t ? Array.from({ length: n - t + 1 }, (e, n) => t + n) : [t, n].filter((e) => e !== void 0);
1830
2060
  }
1831
2061
  if (e.type === "counted-interval") {
1832
- let t = Q(e.first)[0];
2062
+ let t = Z(e.first)[0];
1833
2063
  return t === void 0 ? [] : Array.from({ length: e.count }, (e, n) => t + n);
1834
2064
  }
1835
- if (e.type === "exclusion") return Q(e.left);
2065
+ if (e.type === "exclusion") return Z(e.left);
1836
2066
  for (let t of i(e)) if (t.type === "alinéa" && typeof t.index == "number" && t.index > 0) return [t.index];
1837
2067
  return [];
1838
2068
  }
1839
- function wr(e, t) {
1840
- let n = Q(t);
2069
+ function Lr(e, t) {
2070
+ let n = Z(t);
1841
2071
  return {
1842
2072
  ...e,
1843
2073
  alinea: n[0] ?? e.alinea ?? null,
1844
2074
  ...n.length > 0 ? { alineas: n } : {}
1845
2075
  };
1846
2076
  }
1847
- function Tr(e) {
2077
+ function Rr(e) {
1848
2078
  return e.replace(/^\s*(?:[IVXLCDM]+)\s*(?:\.\s*)?[-–—]\s*/iu, "").replace(/^\s*(?:\d+°|[a-z]\))\s*/iu, "").trim();
1849
2079
  }
1850
- function Er(e, t) {
1851
- let n = /^alin[eé]as?\s+(?:(\d+)|1er|premier)\b/iu.exec(Tr(t.text));
2080
+ function zr(e, t) {
2081
+ let n = /^alin[eé]as?\s+(?:(\d+)|1er|premier)\b/iu.exec(Rr(t.text));
1852
2082
  if (!n) return null;
1853
2083
  let r = n[1] === void 0 ? 1 : Number.parseInt(n[1], 10);
1854
2084
  return !Number.isFinite(r) || r < 1 ? null : {
@@ -1857,25 +2087,25 @@ function Er(e, t) {
1857
2087
  alineas: [r]
1858
2088
  };
1859
2089
  }
1860
- function Dr(e, t) {
2090
+ function Br(e, t) {
1861
2091
  if (e) return e.unit === "article" && t.alinea !== null ? {
1862
2092
  ...e,
1863
2093
  unit: "alinéa"
1864
2094
  } : e;
1865
2095
  }
1866
- function Or(e) {
1867
- return /^(?:apr[eè]s|avant|(?:au|a[uù])\s+d[eé]but|(?:a|à)\s+la\s+fin)\b/iu.test(Tr(e.text));
2096
+ function Vr(e) {
2097
+ return /^(?:apr[eè]s|avant|(?:au|a[uù])\s+d[eé]but|(?:a|à)\s+la\s+fin)\b/iu.test(Rr(e.text));
1868
2098
  }
1869
- function kr(e, t, n, r) {
1870
- return Z(e, t, {
2099
+ function Hr(e, t, n, r) {
2100
+ return Fr(e, t, {
1871
2101
  start: n.position.start,
1872
2102
  stop: r.position.stop
1873
2103
  });
1874
2104
  }
1875
- function Ar(e) {
2105
+ function Ur(e) {
1876
2106
  return /^\s*(?:[IVXLCDM]+)\s*(?:\.\s*)?[-–—]\s*(?!alin[eé]a\b)/iu.test(e.text);
1877
2107
  }
1878
- function jr(e, t) {
2108
+ function Wr(e, t) {
1879
2109
  let n = { ...t.position };
1880
2110
  function r(t) {
1881
2111
  let r = t.exec(e.slice(n.start, n.stop));
@@ -1884,36 +2114,36 @@ function jr(e, t) {
1884
2114
  stop: n.stop
1885
2115
  });
1886
2116
  }
1887
- return r(/^(?:(?:[IVXLCDM]+)\s*(?:\.\s*)?[-–—]\s*|[a-z]\)\s*(?:[.\-–—]\s*)*|\d+°\s*)/iu), r(/^[.\-–—]\s*/u), r(/^en\s+cons[ée]quence\s*,\s*/iu), _r(e, n);
2117
+ return r(/^(?:(?:[IVXLCDM]+)\s*(?:\.\s*)?[-–—]\s*|[a-z]\)\s*(?:[.\-–—]\s*)*|\d+°\s*)/iu), r(/^[.\-–—]\s*/u), r(/^en\s+cons[ée]quence\s*,\s*/iu), kr(e, n);
1888
2118
  }
1889
- function Mr(e) {
1890
- return _(e);
2119
+ function Gr(e) {
2120
+ return v(e);
1891
2121
  }
1892
- function Nr(e, t) {
1893
- return mr(new ue(e.slice(0, t.stop), t.start)) ?? null;
2122
+ function Kr(e, t) {
2123
+ return Er(new O(e.slice(0, t.stop), t.start)) ?? null;
1894
2124
  }
1895
- function $(e, t, n) {
1896
- if (n) return Z(e, t, n.position, gr(p(e, n)));
2125
+ function Q(e, t, n) {
2126
+ if (n) return Fr(e, t, n.position, Or(m(e, n)));
1897
2127
  }
1898
- function Pr(e, t) {
2128
+ function qr(e, t) {
1899
2129
  if (!e) return;
1900
2130
  let n = structuredClone(e);
1901
- for (let e of a(n, { citations: !0 })) e.position !== void 0 && (e.originalTransformation = vr(t, e.position));
2131
+ for (let e of a(n, { citations: !0 })) e.position !== void 0 && (e.originalTransformation = Ar(t, e.position));
1902
2132
  return n;
1903
2133
  }
1904
- function Fr(e, t, n, r) {
1905
- let i = jr(e, n);
2134
+ function Jr(e, t, n, r) {
2135
+ let i = Wr(e, n);
1906
2136
  if (!i) return null;
1907
- let a = Nr(e, i);
2137
+ let a = Kr(e, i);
1908
2138
  if (!a) return null;
1909
- let o = Z(e, t, i), s = Pr(a.targetReference, t), c = wr(r, s), l = Mr(o.text);
2139
+ let o = Fr(e, t, i), s = qr(a.targetReference, t), c = Lr(r, s), l = Gr(o.text);
1910
2140
  if (a.kind === "delete_article") return {
1911
2141
  kind: "delete_article",
1912
2142
  ...X(o),
1913
2143
  target: c
1914
2144
  };
1915
2145
  if (a.kind === "delete_portion") {
1916
- let n = $(e, t, a.targetCitation);
2146
+ let n = Q(e, t, a.targetCitation);
1917
2147
  return {
1918
2148
  kind: "delete_portion",
1919
2149
  ...X(o),
@@ -1924,13 +2154,13 @@ function Fr(e, t, n, r) {
1924
2154
  },
1925
2155
  targetOccurrence: l,
1926
2156
  targetReference: s,
1927
- targetScope: Dr(a.targetScope, c)
2157
+ targetScope: Br(a.targetScope, c)
1928
2158
  };
1929
2159
  }
1930
2160
  if (a.kind === "rewrite_portion") {
1931
- let n = $(e, t, a.replacementCitation);
2161
+ let n = Q(e, t, a.replacementCitation);
1932
2162
  if (!n) return null;
1933
- let r = $(e, t, a.targetCitation);
2163
+ let r = Q(e, t, a.targetCitation);
1934
2164
  return {
1935
2165
  kind: "rewrite_portion",
1936
2166
  ...X(o),
@@ -1941,13 +2171,13 @@ function Fr(e, t, n, r) {
1941
2171
  },
1942
2172
  targetOccurrence: l,
1943
2173
  targetReference: s,
1944
- targetScope: Dr(a.targetScope, c),
2174
+ targetScope: Br(a.targetScope, c),
1945
2175
  replacementCitation: n,
1946
2176
  replacementText: n.text
1947
2177
  };
1948
2178
  }
1949
2179
  if (a.kind === "replace") {
1950
- let n = $(e, t, a.replacementCitation), r = $(e, t, a.targetCitation);
2180
+ let n = Q(e, t, a.replacementCitation), r = Q(e, t, a.targetCitation);
1951
2181
  return !n || !r ? null : {
1952
2182
  kind: "replace",
1953
2183
  ...X(o),
@@ -1961,7 +2191,7 @@ function Fr(e, t, n, r) {
1961
2191
  };
1962
2192
  }
1963
2193
  if (a.kind === "insert_article_after") {
1964
- let n = $(e, t, a.insertCitation);
2194
+ let n = Q(e, t, a.insertCitation);
1965
2195
  return n ? {
1966
2196
  kind: "insert_article_after",
1967
2197
  ...X(o),
@@ -1971,7 +2201,7 @@ function Fr(e, t, n, r) {
1971
2201
  } : null;
1972
2202
  }
1973
2203
  if (a.kind === "insert_article_before") {
1974
- let n = $(e, t, a.insertCitation);
2204
+ let n = Q(e, t, a.insertCitation);
1975
2205
  return n ? {
1976
2206
  kind: "insert_article_before",
1977
2207
  ...X(o),
@@ -1981,9 +2211,9 @@ function Fr(e, t, n, r) {
1981
2211
  } : null;
1982
2212
  }
1983
2213
  if (a.kind === "insert_after" || a.kind === "insert_before") {
1984
- let n = $(e, t, a.insertCitation);
2214
+ let n = Q(e, t, a.insertCitation);
1985
2215
  if (!n) return null;
1986
- let r = $(e, t, a.targetCitation);
2216
+ let r = Q(e, t, a.targetCitation);
1987
2217
  return {
1988
2218
  kind: a.kind,
1989
2219
  ...X(o),
@@ -1996,19 +2226,19 @@ function Fr(e, t, n, r) {
1996
2226
  targetReference: s,
1997
2227
  insertCitation: n,
1998
2228
  insertText: n.text,
1999
- targetScope: Dr(a.targetScope, c)
2229
+ targetScope: Br(a.targetScope, c)
2000
2230
  };
2001
2231
  }
2002
2232
  return null;
2003
2233
  }
2004
- function Ir(e, t) {
2234
+ function Yr(e, t) {
2005
2235
  let n = [], r = 0, i = 0;
2006
2236
  function a(r) {
2007
- let a = _r(e, {
2237
+ let a = kr(e, {
2008
2238
  start: i,
2009
2239
  stop: r
2010
2240
  });
2011
- a !== null && n.push(Z(e, t, a));
2241
+ a !== null && n.push(Fr(e, t, a));
2012
2242
  }
2013
2243
  function o(t) {
2014
2244
  let n = Math.max(e.lastIndexOf("\n", t - 1), e.lastIndexOf("\r", t - 1));
@@ -2026,7 +2256,7 @@ function Ir(e, t) {
2026
2256
  continue;
2027
2257
  }
2028
2258
  if (r > 0) continue;
2029
- let s = e.slice(t + 1), c = /[\n\r]/u.test(n), l = /[.;]/u.test(n), u = e.slice(i, l ? t + 1 : t), d = /^\s*(?:(?:[IVXLCDM]+)\s*[.\-–—]+\s*|\d+°\s*|[a-z]\)\s*|(?:Supprimer|Après|Avant|Compléter|Rédiger|Substituer|Remplacer)\b)/iu.test(s), f = c && /^\s*(?:R[eé]diger|Ins[eé]rer|Ajouter|Supprimer)\b/iu.test(s) && Or({
2259
+ let s = e.slice(t + 1), c = /[\n\r]/u.test(n), l = /[.;]/u.test(n), u = e.slice(i, l ? t + 1 : t), d = /^\s*(?:(?:[IVXLCDM]+)\s*[.\-–—]+\s*|\d+°\s*|[a-z]\)\s*|(?:Supprimer|Après|Avant|Compléter|Rédiger|Substituer|Remplacer)\b)/iu.test(s), f = c && /^\s*(?:R[eé]diger|Ins[eé]rer|Ajouter|Supprimer)\b/iu.test(s) && Vr({
2030
2260
  originalTransformation: void 0,
2031
2261
  position: {
2032
2262
  start: i,
@@ -2038,8 +2268,8 @@ function Ir(e, t) {
2038
2268
  }
2039
2269
  return a(e.length), n;
2040
2270
  }
2041
- function Lr(e) {
2042
- let t = Cr(e), n = t?.dispositif ?? null, r = Sr(n), i = [], a = [], o = br(e);
2271
+ function Xr(e) {
2272
+ let t = Ir(e), n = t?.dispositif ?? null, r = Pr(n), i = [], a = [], o = Mr(e);
2043
2273
  if (e.sourceFormat === "senat-ameli" && e.sourceKind === "S") return i.push({
2044
2274
  code: "unsupported_sub_amendment",
2045
2275
  message: "Les sous-amendements ne sont pas encore projetés."
@@ -2057,9 +2287,9 @@ function Lr(e) {
2057
2287
  });
2058
2288
  else {
2059
2289
  let { simplifiedText: e, transformation: r } = t, s = o, c = null;
2060
- for (let t of Ir(e, r)) {
2061
- Ar(t) && (s = o, c = null);
2062
- let n = c ? kr(e, r, c, t) : t, i = Fr(e, r, n, s);
2290
+ for (let t of Yr(e, r)) {
2291
+ Ur(t) && (s = o, c = null);
2292
+ let n = c ? Hr(e, r, c, t) : t, i = Jr(e, r, n, s);
2063
2293
  if (i) {
2064
2294
  a.push(i), c = null, (i.target.alinea !== null || i.target.alineas) && (s = i.target);
2065
2295
  continue;
@@ -2068,12 +2298,12 @@ function Lr(e) {
2068
2298
  c = n;
2069
2299
  continue;
2070
2300
  }
2071
- let l = Er(o, t);
2301
+ let l = zr(o, t);
2072
2302
  if (l !== null) {
2073
2303
  s = l;
2074
2304
  continue;
2075
2305
  }
2076
- Or(t) && (c = t);
2306
+ Vr(t) && (c = t);
2077
2307
  }
2078
2308
  a.length === 0 && (o.targetPosition === "after_article" || o.targetPosition === "before_article") && a.push({
2079
2309
  kind: o.targetPosition === "before_article" ? "insert_article_before" : "insert_article_after",
@@ -2084,7 +2314,7 @@ function Lr(e) {
2084
2314
  }), a.length === 0 && i.push({
2085
2315
  code: "unrecognized_dispositif",
2086
2316
  message: "Le dispositif est présent mais aucune directive d'amendement n'a été reconnue.",
2087
- ...xr(n)
2317
+ ...Nr(n)
2088
2318
  });
2089
2319
  }
2090
2320
  return {
@@ -2098,25 +2328,25 @@ function Lr(e) {
2098
2328
  }
2099
2329
  //#endregion
2100
2330
  //#region src/lib/server/senat_document_search.ts
2101
- function Rr(e) {
2331
+ function $(e) {
2102
2332
  return e.replace(/\u00a0/gu, " ").replace(/\s+/gu, " ").trim();
2103
2333
  }
2104
- function zr(e) {
2334
+ function Zr(e) {
2105
2335
  let t = w(e);
2106
2336
  if (!t) return {
2107
2337
  articleNumber: null,
2108
2338
  label: e,
2109
2339
  title: null
2110
2340
  };
2111
- let n = Rr(t.num ?? "") || null, r = Rr(t.title ?? "") || null;
2341
+ let n = $(t.num ?? "") || null, r = $(t.title ?? "") || null;
2112
2342
  return {
2113
2343
  articleNumber: n,
2114
2344
  label: t.label,
2115
2345
  title: r
2116
2346
  };
2117
2347
  }
2118
- function Br(e) {
2119
- let t = g(e), n = [], r = Rr(t("section.akn-preamble").text());
2348
+ function Qr(e) {
2349
+ let t = _(e), n = [], r = $(t("section.akn-preamble").text());
2120
2350
  return r && n.push({
2121
2351
  anchor: "senat-expose-des-motifs",
2122
2352
  articleNumber: null,
@@ -2126,9 +2356,9 @@ function Br(e) {
2126
2356
  label: "Exposé des motifs",
2127
2357
  title: null
2128
2358
  }), t("article.akn-article").each((e, r) => {
2129
- let i = t(r), a = i.attr("id") || `akn-article-${e + 1}`, o = Rr(i.children("p.TCNumArticle").first().text()), s = `Article ${e + 1}`, c = zr(o || s), l = i.clone();
2359
+ let i = t(r), a = i.attr("id") || `akn-article-${e + 1}`, o = $(i.children("p.TCNumArticle").first().text()), s = `Article ${e + 1}`, c = Zr(o || s), l = i.clone();
2130
2360
  l.children("p.TCNumArticle").remove();
2131
- let u = Rr(l.text());
2361
+ let u = $(l.text());
2132
2362
  u && n.push({
2133
2363
  anchor: i.attr("id") || null,
2134
2364
  articleNumber: c.articleNumber,
@@ -2140,40 +2370,40 @@ function Br(e) {
2140
2370
  });
2141
2371
  }), n;
2142
2372
  }
2143
- function Vr(e, t) {
2144
- return be("sha256").update(JSON.stringify({
2373
+ function $r(e, t) {
2374
+ return we("sha256").update(JSON.stringify({
2145
2375
  item: e,
2146
2376
  metadata: t
2147
2377
  })).digest("hex");
2148
2378
  }
2149
2379
  //#endregion
2150
2380
  //#region src/lib/server/senat_document_sources.ts
2151
- var Hr = new Set(["senat.fr", "www.senat.fr"]), Ur = "https://www.senat.fr";
2152
- function Wr(e) {
2381
+ var ei = new Set(["senat.fr", "www.senat.fr"]), ti = "https://www.senat.fr";
2382
+ function ni(e) {
2153
2383
  return e?.trim() || void 0;
2154
2384
  }
2155
- function Gr(e) {
2385
+ function ri(e) {
2156
2386
  try {
2157
- let t = e.replace(/^\/+/, ""), n = /^https?:\/\//iu.test(e) ? new URL(e) : new URL(/^(?:akomantoso|leg)\//iu.test(t) ? `/${t}` : `/leg/${t}`, Ur);
2158
- return Hr.has(n.hostname.toLowerCase()) ? n : void 0;
2387
+ let t = e.replace(/^\/+/, ""), n = /^https?:\/\//iu.test(e) ? new URL(e) : new URL(/^(?:akomantoso|leg)\//iu.test(t) ? `/${t}` : `/leg/${t}`, ti);
2388
+ return ei.has(n.hostname.toLowerCase()) ? n : void 0;
2159
2389
  } catch {
2160
2390
  return;
2161
2391
  }
2162
2392
  }
2163
- function Kr(e) {
2164
- let t = Wr(e);
2393
+ function ii(e) {
2394
+ let t = ni(e);
2165
2395
  if (t === void 0) return {
2166
2396
  publicUrl: null,
2167
2397
  status: "no_url"
2168
2398
  };
2169
- let n = Gr(t);
2399
+ let n = ri(t);
2170
2400
  if (n === void 0) return {
2171
2401
  publicUrl: t,
2172
2402
  status: "unsupported_source"
2173
2403
  };
2174
2404
  let r = n.pathname;
2175
2405
  if (/^\/akomantoso\/[^/]+\.akn\.xml$/iu.test(r)) return {
2176
- akomaNtosoUrl: `${Ur}${r}`,
2406
+ akomaNtosoUrl: `${ti}${r}`,
2177
2407
  publicUrl: n.toString(),
2178
2408
  status: "available"
2179
2409
  };
@@ -2182,17 +2412,17 @@ function Kr(e) {
2182
2412
  publicUrl: n.toString(),
2183
2413
  status: "unsupported_source"
2184
2414
  } : {
2185
- akomaNtosoUrl: `${Ur}/akomantoso/${i.replace(/\.html$/iu, ".akn.xml")}`,
2415
+ akomaNtosoUrl: `${ti}/akomantoso/${i.replace(/\.html$/iu, ".akn.xml")}`,
2186
2416
  publicUrl: n.toString(),
2187
2417
  status: "available"
2188
2418
  };
2189
2419
  }
2190
- function qr(e) {
2420
+ function ai(e) {
2191
2421
  return /^\s*(?:<\?xml\b[^>]*>\s*)?<akomaNtoso[\s/>]/iu.test(e);
2192
2422
  }
2193
2423
  //#endregion
2194
2424
  //#region src/lib/alineas/alineas_numbers.ts
2195
- var Jr = {
2425
+ var oi = {
2196
2426
  "0150a855548f15a2af52ea057be53f5d": 1,
2197
2427
  "039826cf379b94afefe90b25c6045ca0": 1,
2198
2428
  "03a7e564b84662f4d957c51018e26244": 1,
@@ -21166,7 +21396,7 @@ var Jr = {
21166
21396
  d16d29c923bd60c7b095b66c6058fe60: 1664,
21167
21397
  "1c14c2adf5cfda3220b2057160e10e91": 1665,
21168
21398
  e44c55ca1ac46ff46420686a466c9fc6: 1665
21169
- }, Yr = "\np:has(.alinea) {\n margin: 0.6em 0;\n}\n.alinea {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n min-width: 1.5em;\n height: 1.5em;\n padding: 0 0.3em;\n margin-right: 0.3em;\n font-size: 0.75em;\n font-weight: bold;\n color: #555;\n background-color: #f0f0f0;\n border: 1px solid #ccc;\n border-radius: 1em;\n vertical-align: middle;\n}\n", Xr = "\nh1 {\n font-size: 1.8em;\n margin: 1em 0 0.5em 0;\n}\nh2 {\n font-size: 1.5em;\n margin: 0.9em 0 0.4em 0;\n}\nh3 {\n font-size: 1.3em;\n margin: 0.8em 0 0.4em 0;\n}\nh4 {\n font-size: 1.15em;\n margin: 0.7em 0 0.3em 0;\n}\nh5 {\n font-size: 1.05em;\n margin: 0.6em 0 0.3em 0;\n}\nh6 {\n font-size: 1em;\n margin: 0.5em 0 0.3em 0;\n}\n", Zr = "\n.expose-motifs-titre {\n font-size: 1.1em;\n font-weight: bold;\n color: #0070b9;\n margin: 1em 0 0.5em 0;\n}\n.expose-motifs {\n border-left: 3px solid #0070b9;\n padding-left: 1em;\n margin: 0.5em 0 1em 0;\n color: #333;\n}\n.expose-motifs p {\n margin: 0.5em 0;\n}\n", Qr = "\nol {\n list-style: none;\n padding-left: 0;\n margin: 0.5em 0;\n counter-reset: list-counter;\n}\nol > li {\n counter-increment: list-counter;\n margin: 0.3em 0;\n padding-left: 2.3em;\n position: relative;\n}\nol > li::before {\n content: counter(list-counter);\n display: inline-flex;\n align-items: center;\n justify-content: center;\n min-width: 1.5em;\n height: 1.5em;\n padding: 0 0.3em;\n font-size: 0.75em;\n font-weight: bold;\n color: #555;\n background-color: #f0f0f0;\n border: 1px solid #ccc;\n border-radius: 1em;\n position: absolute;\n left: 0;\n top: 0.1em;\n}\n", $r = "\n.cover-title {\n font-size: 1.8em;\n font-weight: bold;\n color: #0070b9;\n text-align: center;\n margin: 1em 0;\n}\n.cover-subtitle {\n font-size: 1.4em;\n font-weight: bold;\n color: #0070b9;\n text-align: center;\n margin: 0.8em 0;\n}\n.cover-info {\n text-align: center;\n margin: 0.3em 0;\n color: #333;\n}\n.cover-year {\n font-size: 2em;\n font-weight: bold;\n color: #0070b9;\n text-align: center;\n margin: 1em 0;\n}\n", ei = {
21399
+ }, si = "\np:has(.alinea) {\n margin: 0.6em 0;\n}\n.alinea {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n min-width: 1.5em;\n height: 1.5em;\n padding: 0 0.3em;\n margin-right: 0.3em;\n font-size: 0.75em;\n font-weight: bold;\n color: #555;\n background-color: #f0f0f0;\n border: 1px solid #ccc;\n border-radius: 1em;\n vertical-align: middle;\n}\n", ci = "\nh1 {\n font-size: 1.8em;\n margin: 1em 0 0.5em 0;\n}\nh2 {\n font-size: 1.5em;\n margin: 0.9em 0 0.4em 0;\n}\nh3 {\n font-size: 1.3em;\n margin: 0.8em 0 0.4em 0;\n}\nh4 {\n font-size: 1.15em;\n margin: 0.7em 0 0.3em 0;\n}\nh5 {\n font-size: 1.05em;\n margin: 0.6em 0 0.3em 0;\n}\nh6 {\n font-size: 1em;\n margin: 0.5em 0 0.3em 0;\n}\n", li = "\n.expose-motifs-titre {\n font-size: 1.1em;\n font-weight: bold;\n color: #0070b9;\n margin: 1em 0 0.5em 0;\n}\n.expose-motifs {\n border-left: 3px solid #0070b9;\n padding-left: 1em;\n margin: 0.5em 0 1em 0;\n color: #333;\n}\n.expose-motifs p {\n margin: 0.5em 0;\n}\n", ui = "\nol {\n list-style: none;\n padding-left: 0;\n margin: 0.5em 0;\n counter-reset: list-counter;\n}\nol > li {\n counter-increment: list-counter;\n margin: 0.3em 0;\n padding-left: 2.3em;\n position: relative;\n}\nol > li::before {\n content: counter(list-counter);\n display: inline-flex;\n align-items: center;\n justify-content: center;\n min-width: 1.5em;\n height: 1.5em;\n padding: 0 0.3em;\n font-size: 0.75em;\n font-weight: bold;\n color: #555;\n background-color: #f0f0f0;\n border: 1px solid #ccc;\n border-radius: 1em;\n position: absolute;\n left: 0;\n top: 0.1em;\n}\n", di = "\n.cover-title {\n font-size: 1.8em;\n font-weight: bold;\n color: #0070b9;\n text-align: center;\n margin: 1em 0;\n}\n.cover-subtitle {\n font-size: 1.4em;\n font-weight: bold;\n color: #0070b9;\n text-align: center;\n margin: 0.8em 0;\n}\n.cover-info {\n text-align: center;\n margin: 0.3em 0;\n color: #333;\n}\n.cover-year {\n font-size: 2em;\n font-weight: bold;\n color: #0070b9;\n text-align: center;\n margin: 1em 0;\n}\n", fi = {
21170
21400
  assnatetatagr: { bold: !0 },
21171
21401
  assnatetatagrgr: { bold: !0 },
21172
21402
  assnatetatatr: { bold: !0 },
@@ -21267,29 +21497,29 @@ var Jr = {
21267
21497
  assnatxl67: { align: "center" },
21268
21498
  assnatenteteequilibre: { align: "center" }
21269
21499
  };
21270
- function ti(e) {
21271
- let t = Object.keys(ei).sort((e, t) => t.length - e.length);
21272
- for (let n of t) if (e.includes(n)) return ei[n];
21500
+ function pi(e) {
21501
+ let t = Object.keys(fi).sort((e, t) => t.length - e.length);
21502
+ for (let n of t) if (e.includes(n)) return fi[n];
21273
21503
  return null;
21274
21504
  }
21275
- function ni(e) {
21276
- return ye.createHash("md5").update(e).digest("hex");
21505
+ function mi(e) {
21506
+ return Ce.createHash("md5").update(e).digest("hex");
21277
21507
  }
21278
- function ri(e) {
21508
+ function hi(e) {
21279
21509
  return e ? /font-weight\s*:\s*(bold|[6-9]00|1000)/i.test(e) || /font-family\s*:\s*[^;]*\bBold\b/i.test(e) : !1;
21280
21510
  }
21281
- function ii(e) {
21511
+ function gi(e) {
21282
21512
  return e ? /font-style\s*:\s*italic/i.test(e) || /font-family\s*:\s*[^;]*\bItalic\b/i.test(e) : !1;
21283
21513
  }
21284
- function ai(e) {
21514
+ function _i(e) {
21285
21515
  if (!e || !/vertical-align\s*:\s*super/i.test(e)) return !1;
21286
21516
  let t = e.match(/font-size\s*:\s*([\d.]+)pt/i);
21287
21517
  return !(t && parseFloat(t[1]) < 8);
21288
21518
  }
21289
- function oi(e) {
21519
+ function vi(e) {
21290
21520
  return e ? /vertical-align\s*:\s*sub/i.test(e) : !1;
21291
21521
  }
21292
- function si(e) {
21522
+ function yi(e) {
21293
21523
  if (!e) return;
21294
21524
  let t = [
21295
21525
  "width",
@@ -21324,15 +21554,15 @@ function si(e) {
21324
21554
  }
21325
21555
  return n.length > 0 ? n.join("; ") : void 0;
21326
21556
  }
21327
- function ci(e, t) {
21557
+ function bi(e, t) {
21328
21558
  return !!(e && /text-align\s*:\s*center/i.test(e) || t && /center/i.test(t));
21329
21559
  }
21330
- function li(e) {
21560
+ function xi(e) {
21331
21561
  if (!e) return null;
21332
21562
  let t = e.match(/text-align\s*:\s*(left|center|right|justify)/i);
21333
21563
  return t ? t[1].toLowerCase() : null;
21334
21564
  }
21335
- function ui(e) {
21565
+ function Si(e) {
21336
21566
  if (!e) return null;
21337
21567
  for (let [t, n] of [
21338
21568
  [/assnat1Tome|assnatAN1PARTIE/i, 1],
@@ -21344,8 +21574,8 @@ function ui(e) {
21344
21574
  ]) if (t.test(e)) return n;
21345
21575
  return null;
21346
21576
  }
21347
- function di(e, t = {}) {
21348
- let { keepAlignment: n = !0, removeEmptyParagraphs: r = !0, strictAlineas: i = !1 } = t, a = g(e, { xml: { decodeEntities: !1 } });
21577
+ function Ci(e, t = {}) {
21578
+ let { keepAlignment: n = !0, removeEmptyParagraphs: r = !0, strictAlineas: i = !1 } = t, a = _(e, { xml: { decodeEntities: !1 } });
21349
21579
  a("style, script, meta, link").remove(), a(".assnatHeader, .assnatFooter, .assnatHeaderLeft, .assnatHeaderandFooter").remove(), a(".assnatFARSautApres, .assnatFARSautAvant, .assnatFARSautPageNiv0, .assnatFARSautPageNiv1, .assnatFARSautPageNiv1PG").remove(), a(".assnatFARTT08Bleu").each((e, t) => {
21350
21580
  let n = a(t).closest("table");
21351
21581
  n.length > 0 && n.remove();
@@ -21370,7 +21600,7 @@ function di(e, t = {}) {
21370
21600
  if (i.length !== 0 && !(n.parents("del").length > 0 || n.find("del img").length > 0) && !(i.parent("del").length > 0)) {
21371
21601
  let e = i.attr();
21372
21602
  if (e && (e.width === "45" && (e.height === "31" || e.height === "30") || parseInt(e.width || "0", 10) < 50 && parseInt(e.height || "0", 10) < 50) && r.includes("position:absolute")) {
21373
- let t = (e.src || "").match(/^data:image\/png;base64,(.+)$/), r = t ? ni(t[1]) : void 0, i = r ? ` data-image-hash="${r}"` : "";
21603
+ let t = (e.src || "").match(/^data:image\/png;base64,(.+)$/), r = t ? mi(t[1]) : void 0, i = r ? ` data-image-hash="${r}"` : "";
21374
21604
  n.replaceWith(`<span class="alinea"${i}></span>`);
21375
21605
  return;
21376
21606
  }
@@ -21389,7 +21619,7 @@ function di(e, t = {}) {
21389
21619
  (!r || r === "\xA0") && n.remove();
21390
21620
  }), a("span[style*=\"display:block\"][style*=\"position:absolute\"]:not(.alinea)").remove(), a("del").remove();
21391
21621
  function o(e) {
21392
- let t = a(e), n = t.attr("style"), r = e.tagName?.toLowerCase() || "", i = ri(n) || r === "b" || r === "strong", o = ii(n) || r === "i" || r === "em", s = ai(n) || r === "sup", c = oi(n) || r === "sub", l = t.attr("class") || "";
21622
+ let t = a(e), n = t.attr("style"), r = e.tagName?.toLowerCase() || "", i = hi(n) || r === "b" || r === "strong", o = gi(n) || r === "i" || r === "em", s = _i(n) || r === "sup", c = vi(n) || r === "sub", l = t.attr("class") || "";
21393
21623
  return /bold/i.test(l) && (i = !0), /strongemphasis/i.test(l) ? i = !0 : /italic|emphasis/i.test(l) && (o = !0), {
21394
21624
  bold: i,
21395
21625
  italic: o,
@@ -21423,7 +21653,7 @@ function di(e, t = {}) {
21423
21653
  c = e;
21424
21654
  }
21425
21655
  for (a("p").each((e, t) => {
21426
- let r = a(t), i = r.attr("class") || "", o = r.attr("style"), s = ui(i);
21656
+ let r = a(t), i = r.attr("class") || "", o = r.attr("style"), s = Si(i);
21427
21657
  if (i.includes("assnatFARCouvTitreD")) {
21428
21658
  let e = r.html() || "";
21429
21659
  r.replaceWith(`<p class="cover-subtitle">${e}</p>`);
@@ -21456,11 +21686,11 @@ function di(e, t = {}) {
21456
21686
  let c = r.text().trim().startsWith("«");
21457
21687
  if (s && !c) {
21458
21688
  let e = a(`<h${s}>${r.html() || ""}</h${s}>`);
21459
- n && ci(o, i) && e.attr("align", "center"), r.replaceWith(e);
21689
+ n && bi(o, i) && e.attr("align", "center"), r.replaceWith(e);
21460
21690
  } else {
21461
- let e = ti(i), t;
21691
+ let e = pi(i), t;
21462
21692
  if (n) {
21463
- let n = li(o);
21693
+ let n = xi(o);
21464
21694
  n && n !== "justify" && n !== "left" ? t = n : e?.align && (t = e.align);
21465
21695
  }
21466
21696
  if (r.removeAttr("style").removeAttr("class"), t && r.attr("align", t), e?.bold) {
@@ -21470,7 +21700,7 @@ function di(e, t = {}) {
21470
21700
  }
21471
21701
  }), a("h1, h2, h3, h4, h5, h6").each((e, t) => {
21472
21702
  let r = a(t), i = r.attr("style"), o = r.attr("class");
21473
- n && ci(i, o) ? (r.removeAttr("style").removeAttr("class"), r.attr("align", "center")) : r.removeAttr("style").removeAttr("class");
21703
+ n && bi(i, o) ? (r.removeAttr("style").removeAttr("class"), r.attr("align", "center")) : r.removeAttr("style").removeAttr("class");
21474
21704
  }), a("a").each((e, t) => {
21475
21705
  let n = a(t), r = n.attr("href"), i = n.attr("id"), o = { ...t.attribs || {} };
21476
21706
  for (let e of Object.keys(o)) e !== "href" && e !== "id" && n.removeAttr(e);
@@ -21509,7 +21739,7 @@ function di(e, t = {}) {
21509
21739
  }), a("br").each((e, t) => {
21510
21740
  a(t).removeAttr("style").removeAttr("class");
21511
21741
  }), a("table, tr, td, th, thead, tbody, tfoot").each((e, t) => {
21512
- let n = a(t), r = si(n.attr("style"));
21742
+ let n = a(t), r = yi(n.attr("style"));
21513
21743
  n.removeAttr("style").removeAttr("class"), r && n.attr("style", r);
21514
21744
  }), a("td, th").each((e, t) => {
21515
21745
  let n = a(t), r = n.children();
@@ -21527,17 +21757,17 @@ function di(e, t = {}) {
21527
21757
  !isNaN(e) && e > 1 && n.attr("style", `counter-reset: list-counter ${e - 1}`), n.attr("start", r);
21528
21758
  }
21529
21759
  }), a("li").each((e, t) => {
21530
- let n = a(t), r = li(n.attr("style"));
21760
+ let n = a(t), r = xi(n.attr("style"));
21531
21761
  n.removeAttr("style").removeAttr("class"), r === "center" && n.attr("style", "text-align: center");
21532
21762
  let i = n.html() || "", o = i.replace(/^(\s|&#xa0;|&#160;|\u00a0)+/, "");
21533
21763
  o !== i && n.html(o);
21534
- }), fi(a), pi(a, i);
21764
+ }), wi(a), Ti(a, i);
21535
21765
  let l = a("body").html() || a.html(), u = l.includes("class=\"alinea"), d = a("ol").length > 0, f = a("h1, h2, h3, h4, h5, h6").length > 0, p = l.includes("class=\"expose-motifs"), m = l.includes("class=\"cover-title\"") || l.includes("class=\"cover-subtitle\"") || l.includes("class=\"cover-info\"") || l.includes("class=\"cover-year\""), h = "";
21536
- m && (h += $r), f && (h += Xr), p && (h += Zr), u && (h += Yr), d && (h += Qr);
21537
- let _ = h ? `<style>${h}</style>\n${l}` : l;
21538
- return _ = _.replace(/>\s+</g, "> <").replace(/\r\n/g, "\n").replace(/\r/g, "\n").replace(/\n{3,}/g, "\n\n").split("\n").map((e) => e.trim()).filter((e) => e.length > 0).join("\n"), _ = _.replace(/&nbsp;/g, "\xA0"), r && (_ = _.replace(/<p[^>]*>\s*(&nbsp;|&#xa0;|&#160;|\u00a0|\s)*\s*<\/p>/gi, "").replace(/<p[^>]*>\s*<(strong|em|b|i)>\s*(&nbsp;|&#xa0;|&#160;|\u00a0|\s)*\s*<\/\1>\s*<\/p>/gi, "")), _ = _.replace(/<span[^>]*>\s*<\/span>/gi, ""), _ = _.replace(/ class=""/g, ""), _ = mi(_), _ = _.replace(/<(strong|em|b|i|sup|sub)>\s*(&nbsp;|&#xa0;|&#160;|\u00a0|\s)*\s*<\/\1>/gi, "").replace(/<(strong|em|b|i)>(&nbsp;|&#xa0;|&#160;|\u00a0)+<\/\1>/gi, " ").replace(/<br\s*\/?>/gi, "<br/>").replace(/ +/g, " ").trim(), _;
21766
+ m && (h += di), f && (h += ci), p && (h += li), u && (h += si), d && (h += ui);
21767
+ let g = h ? `<style>${h}</style>\n${l}` : l;
21768
+ return g = g.replace(/>\s+</g, "> <").replace(/\r\n/g, "\n").replace(/\r/g, "\n").replace(/\n{3,}/g, "\n\n").split("\n").map((e) => e.trim()).filter((e) => e.length > 0).join("\n"), g = g.replace(/&nbsp;/g, "\xA0"), r && (g = g.replace(/<p[^>]*>\s*(&nbsp;|&#xa0;|&#160;|\u00a0|\s)*\s*<\/p>/gi, "").replace(/<p[^>]*>\s*<(strong|em|b|i)>\s*(&nbsp;|&#xa0;|&#160;|\u00a0|\s)*\s*<\/\1>\s*<\/p>/gi, "")), g = g.replace(/<span[^>]*>\s*<\/span>/gi, ""), g = g.replace(/ class=""/g, ""), g = Ei(g), g = g.replace(/<(strong|em|b|i|sup|sub)>\s*(&nbsp;|&#xa0;|&#160;|\u00a0|\s)*\s*<\/\1>/gi, "").replace(/<(strong|em|b|i)>(&nbsp;|&#xa0;|&#160;|\u00a0)+<\/\1>/gi, " ").replace(/<br\s*\/?>/gi, "<br/>").replace(/ +/g, " ").trim(), g;
21539
21769
  }
21540
- function fi(e) {
21770
+ function wi(e) {
21541
21771
  e("span[id]").each((t, n) => {
21542
21772
  let r = e(n), i = r.attr("id"), a = n.attribs || {}, o = Object.keys(a);
21543
21773
  if (o.length !== 1 || o[0] !== "id") return;
@@ -21560,13 +21790,13 @@ function fi(e) {
21560
21790
  l.trim() === u.trim() && (s.attr("id", i), r.replaceWith(r.html() || ""));
21561
21791
  });
21562
21792
  }
21563
- function pi(e, t = !1) {
21793
+ function Ti(e, t = !1) {
21564
21794
  let n = e("body");
21565
21795
  if (n.length === 0) return;
21566
21796
  let r = n.find("span.alinea[data-image-hash]"), i = -1;
21567
21797
  r.each((n, r) => {
21568
21798
  let a = e(r), o = a.attr("data-image-hash"), s;
21569
- if (o && Jr[o] !== void 0 && (s = Jr[o]), s === void 0) {
21799
+ if (o && oi[o] !== void 0 && (s = oi[o]), s === void 0) {
21570
21800
  if (t) throw Error(`Missing alinea number mapping for image hash: "${o}". Please extract images, review them, and update the mapping in "src/lib/alineas/alineas_numbers.ts".`);
21571
21801
  a.remove();
21572
21802
  return;
@@ -21578,11 +21808,11 @@ function pi(e, t = !1) {
21578
21808
  i = s, a.attr("data-alinea", String(s)), a.text(String(s)), a.removeAttr("data-image-hash");
21579
21809
  });
21580
21810
  }
21581
- function mi(e) {
21811
+ function Ei(e) {
21582
21812
  let t = e;
21583
21813
  return t = t.replace(/<\/strong>(\s*)<strong>/gi, "$1"), t = t.replace(/<\/em>(\s*)<em>/gi, "$1"), t = t.replace(/<\/sup>(\s*)<sup>/gi, "$1"), t = t.replace(/<\/sub>(\s*)<sub>/gi, "$1"), t;
21584
21814
  }
21585
- function hi(e, t = {}) {
21815
+ function Di(e, t = {}) {
21586
21816
  return `<!DOCTYPE html>
21587
21817
  <html lang="fr">
21588
21818
  <head>
@@ -21590,33 +21820,33 @@ function hi(e, t = {}) {
21590
21820
  <title>Document simplifié</title>
21591
21821
  </head>
21592
21822
  <body>
21593
- ${di(e, t)}
21823
+ ${Ci(e, t)}
21594
21824
  </body>
21595
21825
  </html>`;
21596
21826
  }
21597
21827
  //#endregion
21598
21828
  //#region src/lib/server/text_parsers/transformers.ts
21599
- function gi(e, t) {
21829
+ function Oi(e, t) {
21600
21830
  let n = "transformation_", r = {};
21601
- for (let e of A.readdirSync(t).toSorted()) if (e.startsWith(n) && e.endsWith(".json")) {
21831
+ for (let e of j.readdirSync(t).toSorted()) if (e.startsWith(n) && e.endsWith(".json")) {
21602
21832
  let i = e.slice(15, -5), a = i.split(".").map((e) => parseInt(e) - 1), o = r;
21603
21833
  for (let e of a.slice(1)) {
21604
21834
  let t = o.transformations ??= [];
21605
21835
  for (; e >= t.length;) t.push({});
21606
21836
  o = t[e];
21607
21837
  }
21608
- o.output = A.readFileSync(j.join(t, `${n}${i}.html`), { encoding: "utf-8" });
21609
- let { sourceMap: s, title: c } = A.readJsonSync(j.join(t, e), { encoding: "utf-8" });
21838
+ o.output = j.readFileSync(M.join(t, `${n}${i}.html`), { encoding: "utf-8" });
21839
+ let { sourceMap: s, title: c } = j.readJsonSync(M.join(t, e), { encoding: "utf-8" });
21610
21840
  o.sourceMap = s ?? [], o.title = c;
21611
21841
  }
21612
- return _i(r, e), r;
21842
+ return ki(r, e), r;
21613
21843
  }
21614
- function _i(e, t) {
21615
- if (e.input = t, e.transformations !== void 0) for (let n of e.transformations) _i(n, t), t = n.output;
21844
+ function ki(e, t) {
21845
+ if (e.input = t, e.transformations !== void 0) for (let n of e.transformations) ki(n, t), t = n.output;
21616
21846
  return t;
21617
21847
  }
21618
- function vi(e, t, n = "1") {
21619
- if (A.ensureDirSync(t), e.transformations === void 0) A.writeJsonSync(j.join(t, `transformation_${n}.json`), {
21848
+ function Ai(e, t, n = "1") {
21849
+ if (j.ensureDirSync(t), e.transformations === void 0) j.writeJsonSync(M.join(t, `transformation_${n}.json`), {
21620
21850
  sourceMap: e.sourceMap,
21621
21851
  title: e.title
21622
21852
  }, {
@@ -21624,24 +21854,24 @@ function vi(e, t, n = "1") {
21624
21854
  spaces: 2
21625
21855
  });
21626
21856
  else {
21627
- A.writeJsonSync(j.join(t, `transformation_${n}.json`), { title: e.title }, {
21857
+ j.writeJsonSync(M.join(t, `transformation_${n}.json`), { title: e.title }, {
21628
21858
  encoding: "utf-8",
21629
21859
  spaces: 2
21630
21860
  });
21631
- for (let [r, i] of e.transformations.entries()) vi(i, t, `${n}.${r + 1}`);
21861
+ for (let [r, i] of e.transformations.entries()) Ai(i, t, `${n}.${r + 1}`);
21632
21862
  }
21633
- e.output !== void 0 && A.writeFileSync(j.join(t, `transformation_${n}.html`), e.output, { encoding: "utf-8" });
21863
+ e.output !== void 0 && j.writeFileSync(M.join(t, `transformation_${n}.html`), e.output, { encoding: "utf-8" });
21634
21864
  }
21635
21865
  //#endregion
21636
21866
  //#region src/lib/server/linkers/html.ts
21637
- async function yi({ canutesDb: e, legiResolver: t, date: n, defaultTextId: r, htmlFilePath: i, htmlTransformationsInputDir: a, htmlTransformationsOutputDir: o, htmlWithLinksFilePath: s, htmlWithLinksOrReferencesFilePath: c, htmlWithLinksTransformationsOutputDir: l, htmlWithReferencesFilePath: u, linkBaseUrl: d, linkType: f, logIgnoredReferencesTypes: p, logPartialReferences: m, logReferences: h, referredLegifranceTextsInfosFilePath: g }) {
21638
- let _ = t ?? (e === void 0 ? void 0 : new ee(e));
21867
+ async function ji({ canutesDb: e, legiResolver: t, date: n, defaultTextId: r, htmlFilePath: i, htmlTransformationsInputDir: a, htmlTransformationsOutputDir: o, htmlWithLinksFilePath: s, htmlWithLinksOrReferencesFilePath: c, htmlWithLinksTransformationsOutputDir: l, htmlWithReferencesFilePath: u, linkBaseUrl: d, linkType: f, logIgnoredReferencesTypes: p, logPartialReferences: m, logReferences: h, referredLegifranceTextsInfosFilePath: g }) {
21868
+ let _ = t ?? (e === void 0 ? void 0 : new te(e));
21639
21869
  if (_ === void 0) throw Error("A Canutes database or legal resolver is required");
21640
- let v = await A.readFile(i, { encoding: "utf-8" }), y;
21641
- a === void 0 ? (y = le({ removeAWithHref: !0 })(v), o !== void 0 && vi(y, o)) : y = gi(v, a);
21870
+ let v = await j.readFile(i, { encoding: "utf-8" }), y;
21871
+ a === void 0 ? (y = me({ removeAWithHref: !0 })(v), o !== void 0 && Ai(y, o)) : y = Oi(v, a);
21642
21872
  let b = [];
21643
21873
  s !== void 0 && b.push("links"), c !== void 0 && b.push("links_or_references"), u !== void 0 && b.push("references");
21644
- let { outputByType: x, referredLegifranceTextCountByCid: S } = await ne({
21874
+ let { outputByType: x, referredLegifranceTextCountByCid: ee } = await ie({
21645
21875
  legiResolver: _,
21646
21876
  date: n,
21647
21877
  defaultTextId: r,
@@ -21654,42 +21884,42 @@ async function yi({ canutesDb: e, legiResolver: t, date: n, defaultTextId: r, ht
21654
21884
  logReferences: h,
21655
21885
  outputTypes: b,
21656
21886
  referredLegifranceTextsInfos: g !== void 0
21657
- }), C = {};
21658
- s !== void 0 && (C.links = s), c !== void 0 && (C.links_or_references = c), u !== void 0 && (C.references = u);
21887
+ }), S = {};
21888
+ s !== void 0 && (S.links = s), c !== void 0 && (S.links_or_references = c), u !== void 0 && (S.references = u);
21659
21889
  for (let [e, t] of Object.entries(x)) {
21660
- let n = C[e];
21661
- n !== void 0 && await A.writeFile(n, t.html, { encoding: "utf-8" });
21890
+ let n = S[e];
21891
+ n !== void 0 && await j.writeFile(n, t.html, { encoding: "utf-8" });
21662
21892
  }
21663
- x.links !== void 0 && l !== void 0 && vi(le()(x.links.html), l), g !== void 0 && await A.writeJson(g, S, {
21893
+ x.links !== void 0 && l !== void 0 && Ai(me()(x.links.html), l), g !== void 0 && await j.writeJson(g, ee, {
21664
21894
  encoding: "utf-8",
21665
21895
  spaces: 2
21666
21896
  });
21667
21897
  }
21668
21898
  //#endregion
21669
21899
  //#region src/lib/server/tables_of_contents.ts
21670
- async function bi(e, t, n, r) {
21671
- let i = gi(await A.readFile(e, { encoding: "utf-8" }), t), a = i.output, o = new ue(a), s = await A.readJson(n, { encoding: "utf-8" });
21672
- for await (let e of te({
21900
+ async function Mi(e, t, n, r) {
21901
+ let i = Oi(await j.readFile(e, { encoding: "utf-8" }), t), a = i.output, o = new O(a), s = await j.readJson(n, { encoding: "utf-8" });
21902
+ for await (let e of re({
21673
21903
  context: o,
21674
21904
  tableOfContents: s,
21675
21905
  transformation: i
21676
21906
  }));
21677
- await A.writeJson(r, s, {
21907
+ await j.writeJson(r, s, {
21678
21908
  encoding: "utf-8",
21679
21909
  spaces: 2
21680
21910
  });
21681
21911
  }
21682
- async function xi(e, t, n) {
21683
- let r = gi(await A.readFile(e, { encoding: "utf-8" }), t).output, i = v(r);
21684
- await A.writeJson(n, i, {
21912
+ async function Ni(e, t, n) {
21913
+ let r = Oi(await j.readFile(e, { encoding: "utf-8" }), t).output, i = y(r);
21914
+ await j.writeJson(n, i, {
21685
21915
  encoding: "utf-8",
21686
21916
  spaces: 2
21687
21917
  });
21688
21918
  }
21689
21919
  //#endregion
21690
21920
  //#region src/lib/server/legi/resolvers.ts
21691
- function Si({ canutesDb: e }) {
21692
- return new ee(e);
21921
+ function Pi({ canutesDb: e }) {
21922
+ return new te(e);
21693
21923
  }
21694
21924
  //#endregion
21695
- export { ve as LegiResolver, yi as addLinksOrReferencesToHtmlFile, bi as addPositionsToTableOfContentsFile, he as buildAndInstallTextTitlesInfos, _e as buildTextTitlesInfos, Si as createLegiResolver, we as extractAssembleeAmendmentSearchItems, Pn as extractAssembleeExposesDesMotifs, zn as extractSenatAmendmentSearchItems, Te as hashAssembleeAmendmentSearchItem, In as hashAssembleeSearchItem, Bn as hashSenatAmendmentSearchItem, Vr as hashSenatSearchItem, qr as isAkomaNtosoXml, Ln as isoDateFromAssembleeDocument, An as linkAkomaNtosoBillRaw, Vt as linkAssembleeBillRaw, kn as parseAkomaNtosoBillRaw, Lr as parseAmendment, Bt as parseAssembleeBillRaw, Fn as parseAssembleeDocumentSearchContent, Br as parseSenatDocumentSearchContent, gi as readTransformation, Tn as renderAkomaNtosoBillRaw, Kr as resolveSenatAkomaNtosoSource, xi as simplifiedHtmlBillFileToTableOfContentsFile, di as simplifyWordHtml, hi as simplifyWordHtmlToDocument, vi as writeTransformation };
21925
+ export { Se as LegiResolver, ji as addLinksOrReferencesToHtmlFile, Mi as addPositionsToTableOfContentsFile, ye as buildAndInstallTextTitlesInfos, xe as buildTextTitlesInfos, Pi as createLegiResolver, Oe as extractAssembleeAmendmentSearchItems, Gn as extractAssembleeExposesDesMotifs, Xn as extractSenatAmendmentSearchItems, ke as hashAssembleeAmendmentSearchItem, qn as hashAssembleeSearchItem, Zn as hashSenatAmendmentSearchItem, $r as hashSenatSearchItem, ai as isAkomaNtosoXml, Jn as isoDateFromAssembleeDocument, Vn as linkAkomaNtosoBillRaw, Zt as linkAssembleeBillRaw, Bn as parseAkomaNtosoBillRaw, Xr as parseAmendment, Xt as parseAssembleeBillRaw, Kn as parseAssembleeDocumentSearchContent, Qr as parseSenatDocumentSearchContent, Oi as readTransformation, In as renderAkomaNtosoBillRaw, ii as resolveSenatAkomaNtosoSource, Ni as simplifiedHtmlBillFileToTableOfContentsFile, Ci as simplifyWordHtml, Di as simplifyWordHtmlToDocument, Ai as writeTransformation };