@tricoteuses/tisseuse 0.13.11 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/dist/{html-DhGw-Yqr.js → html-BKxA21Bq.js} +3118 -2926
  2. package/dist/index.js +64 -64
  3. package/dist/{resolver-DZS-DNp6.js → resolver-dqOM1G7A.js} +191 -137
  4. package/dist/server-f-legi.js +26 -17
  5. package/dist/server.js +1266 -563
  6. package/dist/src/lib/extractors/article_portions.d.ts +8 -0
  7. package/dist/src/lib/extractors/portion_references.d.ts +10 -0
  8. package/dist/src/lib/extractors/portion_references.test.d.ts +1 -0
  9. package/dist/src/lib/extractors/quoted_text.d.ts +20 -0
  10. package/dist/src/lib/extractors/table_of_contents.d.ts +18 -8
  11. package/dist/src/lib/extractors/table_of_contents.test.d.ts +1 -0
  12. package/dist/src/lib/index.d.ts +4 -4
  13. package/dist/src/lib/server/index.d.ts +2 -1
  14. package/dist/src/lib/server/parsed_amendments.d.ts +71 -0
  15. package/dist/src/lib/server/parsed_amendments.test.d.ts +1 -0
  16. package/dist/src/lib/server/parsed_bills.d.ts +6 -3
  17. package/dist/src/lib/text_parsers/action_citation_patterns.d.ts +2 -0
  18. package/dist/src/lib/text_parsers/action_citation_patterns.test.d.ts +1 -0
  19. package/dist/src/lib/text_parsers/action_occurrences.d.ts +3 -0
  20. package/dist/src/lib/text_parsers/action_occurrences.test.d.ts +1 -0
  21. package/dist/src/lib/text_parsers/action_position_cues.d.ts +12 -0
  22. package/dist/src/lib/text_parsers/action_position_cues.test.d.ts +1 -0
  23. package/dist/src/lib/text_parsers/action_target_scopes.d.ts +7 -0
  24. package/dist/src/lib/text_parsers/action_words.d.ts +10 -0
  25. package/dist/src/lib/text_parsers/amendment_action_directives.d.ts +17 -0
  26. package/dist/src/lib/text_parsers/articles.d.ts +17 -0
  27. package/dist/src/lib/text_parsers/citations.d.ts +4 -0
  28. package/dist/src/lib/text_parsers/numbers.d.ts +18 -15
  29. package/dist/src/lib/text_parsers/repeated_actions.d.ts +4 -0
  30. package/dist/src/lib/text_parsers/repeated_actions.test.d.ts +1 -0
  31. package/dist/src/scripts/shared/checkpoint_cli_options.d.ts +4 -0
  32. package/dist/src/scripts/shared/checkpoint_cli_options.test.d.ts +1 -0
  33. package/package.json +1 -1
package/dist/server.js CHANGED
@@ -1,11 +1,11 @@
1
- import { F as e, a as t, n, o as r, p as i, t as a, u as o } from "./html-DhGw-Yqr.js";
2
- import { E as s, Q as c, i as l, n as u, r as d, t as f, xt as p } from "./resolver-DZS-DNp6.js";
3
- import * as m from "node:crypto";
4
- import { createHash as h } from "node:crypto";
5
- import g from "fs-extra";
6
- import _ from "node:path";
1
+ import { C as e, D as t, E as n, Et as r, H as i, P as a, S as o, T as s, Tt as c, U as l, Y as u, _ as d, a as f, c as p, ct as m, d as h, ft as g, ht as _, m as ee, mt as v, n as y, o as b, pt as te, q as ne, t as re, v as x, vt as ie, w as ae, x as oe, y as se, z as S } from "./html-BKxA21Bq.js";
2
+ import { Ct as C, D as ce, E as le, N as ue, Q as de, Tt as w, gt as T, i as fe, j as pe, jt as E, kt as D, n as me, ot as he, pt as ge, r as _e, t as ve, wt as O } from "./resolver-dqOM1G7A.js";
3
+ import * as ye from "node:crypto";
4
+ import { createHash as k } from "node:crypto";
5
+ import A from "fs-extra";
6
+ import j from "node:path";
7
7
  //#region src/lib/server/assemblee_amendment_search.ts
8
- function v(e, t) {
8
+ function M(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 v(e, t) {
13
13
  }
14
14
  return typeof n == "string" && n.trim() ? n.trim() : null;
15
15
  }
16
- function y(e) {
16
+ function be(e) {
17
17
  return e.replace(/\u00a0/gu, " ").replace(/\s+/gu, " ").trim();
18
18
  }
19
- function b(t) {
20
- return y(e(t).text());
19
+ function xe(e) {
20
+ return be(u(e).text());
21
21
  }
22
- function x(e) {
23
- let t = y([
24
- v(e, [
22
+ function Se(e) {
23
+ let t = be([
24
+ M(e, [
25
25
  "corps",
26
26
  "contenuAuteur",
27
27
  "dispositif"
28
28
  ]),
29
- v(e, [
29
+ M(e, [
30
30
  "corps",
31
31
  "contenuAuteur",
32
32
  "dispositifAmdtCreditPLF"
33
33
  ]),
34
- v(e, [
34
+ M(e, [
35
35
  "corps",
36
36
  "contenuAuteur",
37
37
  "dispositifAmdtCreditPLFR"
38
38
  ])
39
- ].filter((e) => e !== null).map((e) => b(e)).join("\n")), n = v(e, [
39
+ ].filter((e) => e !== null).map((e) => xe(e)).join("\n")), n = M(e, [
40
40
  "corps",
41
41
  "contenuAuteur",
42
42
  "exposeSommaire"
43
- ]), r = n === null ? "" : b(n);
43
+ ]), r = n === null ? "" : xe(n);
44
44
  return [...t ? [{
45
45
  content: t,
46
46
  itemKind: "dispositif",
@@ -51,28 +51,37 @@ function x(e) {
51
51
  label: "Exposé sommaire"
52
52
  }] : []];
53
53
  }
54
- function S(e, t) {
55
- return h("sha256").update(JSON.stringify({
54
+ function Ce(e, t) {
55
+ return k("sha256").update(JSON.stringify({
56
56
  item: e,
57
57
  metadata: t
58
58
  })).digest("hex");
59
59
  }
60
60
  //#endregion
61
61
  //#region src/lib/server/parsed_bills.ts
62
- var C = /\b(ins[èe]re|ins[ée]r[ée]|ajout|remplac|supprim|abrog|compl[èeé]t|r[ée]dig|r[ée]tabl|modifi(?:e|é|ée|és|ées|er|ant|ent))/iu, w = /^article\s+(.+?)(?:\s*[::]\s*(.+))?$/iu, T = /^expos[ée]\s+des\s+motifs\b/iu;
63
- function E(e) {
62
+ var we = /^expos[ée]\s+des\s+motifs\b/iu;
63
+ function N(e) {
64
64
  return (e ?? "").replace(/\u00a0/g, " ").replace(/\s+/g, " ").trim();
65
65
  }
66
- function D(e) {
67
- return E(e).toLowerCase().normalize("NFD").replace(/\p{Diacritic}/gu, "");
66
+ function P(e) {
67
+ return N(e).toLowerCase().normalize("NFD").replace(/\p{Diacritic}/gu, "");
68
+ }
69
+ function Te(e) {
70
+ return g(N(e));
71
+ }
72
+ function Ee(e) {
73
+ return `_TocArt${Te(e).replace(/\s+/gu, "")}`;
68
74
  }
69
- function O(e) {
70
- return D(e).replace(/[‐‑‒–—]/gu, "-").replace(/\s*\.\s*/gu, ".");
75
+ function De(e, t) {
76
+ return e(t).closest(".assnatTOC6,.assnatTOC5,.assnatTOC4").length > 0;
71
77
  }
72
- function ee(e) {
73
- return O(e).replace(/[^a-z0-9]+/gu, "-").replace(/^-|-$/gu, "");
78
+ function Oe(e) {
79
+ return P(e).replace(/[‐‑‒–—]/gu, "-").replace(/\s*\.\s*/gu, ".");
74
80
  }
75
- function te(e) {
81
+ function ke(e) {
82
+ return Oe(e).replace(/[^a-z0-9]+/gu, "-").replace(/^-|-$/gu, "");
83
+ }
84
+ function Ae(e) {
76
85
  switch (e.kind) {
77
86
  case "insert_after":
78
87
  case "insert_before": return e.insertText;
@@ -90,71 +99,71 @@ function te(e) {
90
99
  default: return;
91
100
  }
92
101
  }
93
- function ne(e) {
94
- let t = E(e.sourceText), n = /\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(t);
95
- if (n?.[1] !== void 0) return E(n[1]);
102
+ function je(e) {
103
+ let t = N(e.sourceText), n = /\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(t);
104
+ if (n?.[1] !== void 0) return te(n[1]);
96
105
  }
97
- function re(e) {
98
- let t = te(e), n = [...(t ?? "").matchAll(/(?:^|\n)\s*(?:[«"]\s*)?(?:Art\.|Article)\s+(.+?)\s*[..]\s*[–—-]/giu)];
106
+ function Me(e) {
107
+ let t = Ae(e), n = m(t ?? "");
99
108
  if (n.length > 0 && t !== void 0) return n.map((e, r) => {
100
- let i = e.index ?? 0, a = n[r + 1]?.index ?? t.length, o = t.slice(i, a).trim();
109
+ let i = e.start, a = n[r + 1]?.start ?? t.length, o = t.slice(i, a).trim();
101
110
  return {
102
- num: E(e[1]),
111
+ num: e.num,
103
112
  text: o
104
113
  };
105
114
  });
106
- let r = ne(e);
115
+ let r = je(e);
107
116
  return r === void 0 ? [] : [{
108
117
  num: r,
109
118
  text: t ?? e.sourceText
110
119
  }];
111
120
  }
112
- function k(e, t = /* @__PURE__ */ new Set()) {
121
+ function Ne(e, t = /* @__PURE__ */ new Set()) {
113
122
  if (e == null) return t;
114
123
  if (Array.isArray(e)) {
115
- for (let n of e) k(n, t);
124
+ for (let n of e) Ne(n, t);
116
125
  return t;
117
126
  }
118
127
  if (typeof e != "object") return t;
119
128
  let n = e;
120
129
  n.type === "article" && typeof n.num == "string" && t.add(n.num);
121
- for (let e of Object.values(n)) k(e, t);
130
+ for (let e of Object.values(n)) Ne(e, t);
122
131
  return t;
123
132
  }
124
- function ie(e) {
125
- let t = D(e.sourceText);
133
+ function Pe(e) {
134
+ let t = P(e.sourceText);
126
135
  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);
127
136
  }
128
- function ae(e) {
129
- return E(e).replace(/[’']/gu, "'").replace(/[‐‑‒–—]/gu, "-");
137
+ function Fe(e) {
138
+ return N(e).replace(/[’']/gu, "'").replace(/[‐‑‒–—]/gu, "-");
130
139
  }
131
- function oe(e, t) {
132
- let n = new p(e, t), r = c(n);
140
+ function Ie(e, t) {
141
+ let n = new C(e, t), r = de(n);
133
142
  return typeof r != "string" || n.offset <= t ? null : {
134
143
  date: r,
135
144
  start: t,
136
145
  stop: n.offset
137
146
  };
138
147
  }
139
- function se(e, t) {
148
+ function Le(e, t) {
140
149
  let n = /\d/u.exec(e.slice(t));
141
150
  if (!n) return null;
142
151
  let r = t + n.index;
143
- return e.slice(t, r).trim().length > 0 ? null : oe(e, r);
152
+ return e.slice(t, r).trim().length > 0 ? null : Ie(e, r);
144
153
  }
145
- function ce(e) {
154
+ function Re(e) {
146
155
  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);
147
156
  for (; o !== -1;) {
148
157
  let s = e.indexOf(a, o + 15), c = e.slice(o, o + 1400), l = t.exec(c);
149
158
  if (l) {
150
- let e = se(c, l[0].length);
159
+ let e = Le(c, l[0].length);
151
160
  e && i.push(e.date);
152
161
  }
153
162
  let u = n.exec(c);
154
163
  if (u) {
155
164
  let e = /\barticle\s+\w/iu.exec(c), t = e === null ? c.slice(u[0].length) : c.slice(u[0].length, e.index);
156
165
  for (r.lastIndex = 0; r.exec(t) !== null;) {
157
- let e = se(t, r.lastIndex);
166
+ let e = Le(t, r.lastIndex);
158
167
  e && /^\s+pour\s+les\s+autres\s+dispositions\s+fiscales\b/iu.test(t.slice(e.stop)) && i.push(e.date);
159
168
  }
160
169
  }
@@ -162,20 +171,20 @@ function ce(e) {
162
171
  }
163
172
  return i;
164
173
  }
165
- function le(e) {
166
- let t = ce(ae(e).toLowerCase()), n = Array.from(new Set(t));
174
+ function ze(e) {
175
+ let t = Re(Fe(e).toLowerCase()), n = Array.from(new Set(t));
167
176
  return n.length === 1 ? n[0] : void 0;
168
177
  }
169
- function ue(e) {
170
- return D(e).replace(/[’]/gu, "'").replace(/[‐‑‒–—]/gu, "-").replace(/^(?:(?:article\s+[^:]+|[a-z][.)]|[ivxlcdm]+\.|\d+°)\s*(?:-\s*)?)+/iu, "");
178
+ function Be(e) {
179
+ return P(e).replace(/[’]/gu, "'").replace(/[‐‑‒–—]/gu, "-").replace(/^(?:(?:article\s+[^:]+|[a-z][.)]|[ivxlcdm]+\.|\d+°)\s*(?:-\s*)?)+/iu, "");
171
180
  }
172
- function A(e) {
181
+ function F(e) {
173
182
  return e?.type === "tag";
174
183
  }
175
- function j(e, t) {
184
+ function Ve(e, t) {
176
185
  return e.html(t) ?? "";
177
186
  }
178
- function de(e, t) {
187
+ function He(e, t) {
179
188
  let n = [], r = /* @__PURE__ */ new Set();
180
189
  for (let i of e(t).find("a").get()) {
181
190
  let a = e(i).attr("href") ?? "", o = /\/legifrance\/(articles|sections|textes)\/([^?#"]+)/u.exec(a);
@@ -183,108 +192,170 @@ function de(e, t) {
183
192
  let s = o[1] === "articles" ? "article" : o[1] === "sections" ? "division" : "text", c = o[2].replace(/\.md$/u, ""), l = `${s}\0${c}`;
184
193
  if (r.has(l)) continue;
185
194
  r.add(l);
186
- let u = E(e(i).text());
195
+ let u = N(e(i).text());
187
196
  n.push({
188
197
  id: c,
189
- ...fe(e, t, i) ? { insideFrenchQuotes: !0 } : {},
198
+ ...Ue(e, t, i) ? { insideFrenchQuotes: !0 } : {},
190
199
  ...u ? { text: u } : {},
191
200
  type: s
192
201
  });
193
202
  }
194
203
  return n;
195
204
  }
196
- function fe(e, t, n) {
197
- let r = pe(e, t, n);
205
+ function Ue(e, t, n) {
206
+ let r = We(e, t, n);
198
207
  return (r.match(/«/gu) ?? []).length > (r.match(/»/gu) ?? []).length;
199
208
  }
200
- function pe(e, t, n) {
209
+ function We(e, t, n) {
201
210
  if (t === n) return "";
202
211
  if (t.type === "text") return t.data ?? "";
203
- if (!A(t)) return "";
212
+ if (!F(t)) return "";
204
213
  let r = "";
205
214
  for (let i of e(t).contents().get()) {
206
215
  if (i === n) return r;
207
- if (A(i) && e.contains(i, n)) return r + pe(e, i, n);
216
+ if (F(i) && e.contains(i, n)) return r + We(e, i, n);
208
217
  r += e(i).text();
209
218
  }
210
219
  return r;
211
220
  }
212
- function me(e, t) {
213
- return t.map((t) => E(e(t).text())).filter(Boolean).join("\n");
214
- }
215
- function M(e) {
216
- let t = E(e).replace(/\s+:\s+/u, " : "), n = w.exec(t), r = n?.[1]?.trim();
217
- if (!r) return null;
218
- let i = r.replace(/\s+/gu, ""), a = n?.[2]?.trim();
219
- return {
220
- label: `Article ${r}`,
221
- num: i,
222
- title: a
223
- };
221
+ function Ge(e, t) {
222
+ return t.map((t) => N(e(t).text())).filter(Boolean).join("\n");
224
223
  }
225
- function he(e) {
226
- let t = D(e);
227
- return !t || T.test(t) ? "noise" : C.test(e) ? "directive_candidate" : "context";
224
+ function Ke(t) {
225
+ let n = P(t);
226
+ return !n || we.test(n) ? "noise" : e.test(t) ? "directive_candidate" : "context";
228
227
  }
229
- async function N(e, t, r) {
230
- if (r === void 0) throw Error("A document date is required to add links to legal references.");
228
+ async function qe(e, t, n) {
229
+ if (n === void 0) throw Error("A document date is required to add links to legal references.");
231
230
  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.");
232
- let { output: i } = await n({
233
- date: r,
231
+ let { output: r } = await y({
232
+ date: n,
234
233
  html: e,
235
- legiResolver: t.legiResolver ?? new o(t.canutesDb),
234
+ legiResolver: t.legiResolver ?? new h(t.canutesDb),
236
235
  linkBaseUrl: t.linkBaseUrl,
237
236
  linkType: t.linkType,
238
237
  logIgnoredReferencesTypes: t.logIgnoredReferencesTypes,
239
238
  logPartialReferences: t.logPartialReferences,
240
239
  logReferences: t.logReferences
241
240
  });
242
- return i ?? e;
241
+ return r ?? e;
243
242
  }
244
- function ge(e, t) {
243
+ function Je(e, t) {
245
244
  let n = e(t).closest("h1,h2,h3,h4,h5,h6,p,td,th").get(0), r = e(t).closest("table").get(0);
246
- return A(r) && A(n) && e(n).parents("table").get(0) === r ? r : A(n) ? n : t;
245
+ return F(r) && F(n) && e(n).parents("table").get(0) === r ? r : F(n) ? n : t;
247
246
  }
248
- function P(e) {
247
+ function Ye(e, t, n, r) {
248
+ if (t.has(r.container)) return;
249
+ let i = r.id ?? Ee(r.num ?? r.label);
250
+ n.has(i) || (n.add(i), t.add(r.container), e.push({
251
+ id: i,
252
+ label: r.label,
253
+ num: r.num,
254
+ title: r.title,
255
+ element: r.element,
256
+ container: r.container
257
+ }));
258
+ }
259
+ function Xe(e) {
249
260
  let t = [], n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set();
250
261
  e("a[id], span[id], h1[id], h2[id], h3[id], h4[id], h5[id], h6[id]").each((i, a) => {
251
- let o = M(E(e(a).text()));
262
+ if (De(e, a)) return;
263
+ let o = v(N(e(a).text()));
252
264
  if (!o) return;
253
265
  let s = e(a).attr("id");
254
266
  if (!s || r.has(s)) return;
255
- let c = ge(e, a);
256
- n.has(c) || (r.add(s), n.add(c), t.push({
267
+ let c = Je(e, a);
268
+ Ye(t, n, r, {
257
269
  id: s,
258
270
  ...o,
259
271
  element: a,
260
272
  container: c
261
- }));
273
+ });
262
274
  }), e("h1:not([id]), h2:not([id]), h3:not([id]), h4:not([id]), h5:not([id]), h6:not([id])").each((i, a) => {
263
275
  if (n.has(a)) return;
264
- let o = M(E(e(a).text()));
265
- if (!o) return;
266
- let s = `_TocArt${(o.num ?? o.label.replace(/^Article\s+/iu, "")).replace(/\s+/gu, "")}`;
267
- r.has(s) || (r.add(s), n.add(a), t.push({
268
- id: s,
276
+ let o = v(N(e(a).text()));
277
+ o && Ye(t, n, r, {
269
278
  ...o,
270
279
  element: a,
271
280
  container: a
272
- }));
281
+ });
273
282
  });
274
283
  let i = e("body *");
275
284
  return t.sort((e, t) => i.index(e.container) - i.index(t.container)), t;
276
285
  }
277
- function F(e) {
286
+ function Ze(e, t) {
287
+ if (De(e, t)) return !1;
288
+ let n = t.tagName?.toLowerCase();
289
+ if (n !== "p") return /^h[1-6]$/u.test(n ?? "");
290
+ let r = e(t).attr("style") ?? "", i = e(t).html() ?? "";
291
+ 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));
292
+ }
293
+ function Qe(e) {
294
+ let t = [], n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set();
295
+ return e("p.assnat9ArticleNum,h1,h2,h3,h4,h5,h6,p").each((i, a) => {
296
+ if (De(e, a) || !e(a).hasClass("assnat9ArticleNum") && !Ze(e, a)) return;
297
+ let o = v(e(a).text());
298
+ o && Ye(t, n, r, {
299
+ ...o,
300
+ element: a,
301
+ container: a
302
+ });
303
+ }), t;
304
+ }
305
+ function $e(e) {
306
+ let t = P(Te(e ?? "")).replace(/[()]/gu, "").trim();
307
+ if (!t || t === "liminaire") return;
308
+ if (t === "unique") return {
309
+ base: 1,
310
+ suffixOrder: 0,
311
+ text: t
312
+ };
313
+ let n = /^(?:(\d+)|1er|premier)(?:\s+([a-z]+))?$/u.exec(t);
314
+ if (!n) return;
315
+ let r = n[1] === void 0 ? 1 : Number.parseInt(n[1], 10), i = n[2], a = i === void 0 ? 0 : et(i);
316
+ if (a !== void 0) return {
317
+ base: r,
318
+ suffixOrder: a,
319
+ text: t
320
+ };
321
+ }
322
+ function et(e) {
323
+ let t = new C(e), n = he(t);
324
+ if (!(n === void 0 || t.offset !== e.length) && !(typeof n != "object" || !n || !("value" in n) || typeof n.value != "number")) return n.value - 1;
325
+ }
326
+ function tt(e) {
327
+ let t = [], n = e.map((e) => ({
328
+ heading: e,
329
+ token: $e(e.num)
330
+ }));
331
+ n.filter(({ token: e }) => e?.text === "unique").length > 0 && e.length > 1 && t.push("Article unique appears with other articles");
332
+ let r;
333
+ for (let { heading: e, token: i } of n) if (!(i === void 0 || i.text === "unique")) {
334
+ if (r !== void 0) {
335
+ let n = r.base * 100 + r.suffixOrder;
336
+ 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}`);
337
+ } else i.suffixOrder > 0 && t.push(`Missing article before ${i.text}`);
338
+ r = i;
339
+ }
340
+ t.length > 0 && process.env.TISSEUSE_WARN_ASSEMBLEE_HEADING_SEQUENCE === "1" && console.warn("Incoherent Assemblée article heading sequence", { issues: t });
341
+ }
342
+ function nt(e, { warn: t = !0 } = {}) {
343
+ let n = Xe(e);
344
+ if (n.length > 0) return t && tt(n), n;
345
+ let r = Qe(e);
346
+ return t && tt(r), r;
347
+ }
348
+ function rt(e) {
278
349
  let t = e.next;
279
350
  for (; t !== null;) {
280
- if (A(t)) return t;
351
+ if (F(t)) return t;
281
352
  t = t.next;
282
353
  }
283
354
  return null;
284
355
  }
285
- function I(e, t, n) {
356
+ function it(e, t, n) {
286
357
  let r = [t.container], i = n?.container;
287
- for (let e = F(t.container); e !== null && e !== i; e = F(e)) r.push(e);
358
+ for (let e = rt(t.container); e !== null && e !== i; e = rt(e)) r.push(e);
288
359
  if (r.length > 1) return r;
289
360
  let a = e("body *").index(t.container), o = i ? e("body *").index(i) : -1;
290
361
  return e("body > *").get().filter((t) => {
@@ -292,7 +363,7 @@ function I(e, t, n) {
292
363
  return n >= a && (o === -1 || n < o);
293
364
  });
294
365
  }
295
- function _e(e, t) {
366
+ function at(e, t) {
296
367
  let n = [], r = /* @__PURE__ */ new Set();
297
368
  for (let i of t) {
298
369
  let t = "p,li,table", a = e(i).is(t) ? [i] : e(i).find(t).get();
@@ -300,98 +371,96 @@ function _e(e, t) {
300
371
  }
301
372
  return n;
302
373
  }
303
- function L(e, t, n) {
374
+ function ot(e, t, n) {
304
375
  let r = [], i = !1;
305
- for (let a of _e(e, n)) {
306
- let n = E(e(a).text());
376
+ for (let a of at(e, n)) {
377
+ let n = N(e(a).text());
307
378
  if (!n) continue;
308
- T.test(n) && (i = !0);
309
- let o = i ? "noise" : he(n), s = `${t}-b${r.length + 1}`;
379
+ we.test(n) && (i = !0);
380
+ let o = i ? "noise" : Ke(n), s = `${t}-b${r.length + 1}`;
310
381
  e(a).attr("data-pjl-parsed-article-id", t), e(a).attr("data-pjl-parsed-block-id", s), r.push({
311
382
  id: s,
312
383
  articleId: t,
313
384
  kind: o,
314
- links: de(e, a),
385
+ links: He(e, a),
315
386
  text: n,
316
- html: j(e, a)
387
+ html: Ve(e, a)
317
388
  });
318
389
  }
319
390
  return r;
320
391
  }
321
- function R(e, t) {
392
+ function st(e, t) {
322
393
  if (t.length === 0) return e;
323
- let n = `<div style="display: none;">\n${t.map((e) => `<p class="assnatTOC6"><a href="#${`_TocArt${(e.num ?? e.label.replace(/^Article\s+/iu, "")).replace(/\s+/gu, "")}`}"><span class="assnatHyperlink" style="font-weight:bold; text-decoration:none; color:#000000">${e.label.toUpperCase()}</span></a></p>`).join("\n")}\n</div>`;
394
+ 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>`;
324
395
  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}`;
325
396
  }
326
- function ve(t) {
327
- let n = e(t);
328
- for (let e of P(n)) {
329
- let t = `_TocArt${(e.num ?? e.label.replace(/^Article\s+/iu, "")).replace(/\s+/gu, "")}`, r = n(e.element), i = r.attr("id");
330
- i?.startsWith("_TocArt") || (i?.startsWith("_Toc") && !z(n, i, e.element) && r.before(n("<span></span>").attr("id", i)), r.attr("id", t));
397
+ function ct(e) {
398
+ let t = u(e);
399
+ for (let e of nt(t, { warn: !1 })) {
400
+ let n = Ee(e.num ?? e.label.replace(/^Article\s+/iu, "")), r = t(e.element), i = r.attr("id");
401
+ i !== n && (i?.startsWith("_Toc") && !lt(t, i, e.element) && r.before(t("<span></span>").attr("id", i)), r.attr("id", n));
331
402
  }
332
- let r = P(n);
333
- for (let [e, t] of r.entries()) {
334
- let i = I(n, t, r[e + 1]).flatMap((e) => n(e).is("span.alinea[data-alinea]") ? [e] : n(e).find("span.alinea[data-alinea]").get());
403
+ let n = nt(t);
404
+ for (let [e, r] of n.entries()) {
405
+ let i = it(t, r, n[e + 1]).flatMap((e) => t(e).is("span.alinea[data-alinea]") ? [e] : t(e).find("span.alinea[data-alinea]").get());
335
406
  for (let e of i) {
336
- let r = n(e).attr("data-alinea")?.trim();
337
- if (!r) continue;
338
- let i = `${t.id}-alinea-${r.replace(/\s+/gu, "")}`;
339
- if (z(n, i, e)) continue;
340
- let a = n(e).attr("id");
341
- a && a !== i ? n(e).before(n("<span></span>").attr("id", i)) : n(e).attr("id", i);
407
+ let n = t(e).attr("data-alinea")?.trim();
408
+ if (!n) continue;
409
+ let i = `${r.id}-alinea-${n.replace(/\s+/gu, "")}`;
410
+ if (lt(t, i, e)) continue;
411
+ let a = t(e).attr("id");
412
+ a && a !== i ? t(e).before(t("<span></span>").attr("id", i)) : t(e).attr("id", i);
342
413
  }
343
414
  }
344
- return n.html();
415
+ return t.html();
345
416
  }
346
- function z(e, t, n) {
417
+ function lt(e, t, n) {
347
418
  for (let r of e("[id]").get()) if (r !== n && e(r).attr("id") === t) return !0;
348
419
  return !1;
349
420
  }
350
- function ye(e, t) {
351
- let n = ue("sourceText" in t ? t.sourceText : "");
421
+ function ut(e, t) {
422
+ let n = Be("sourceText" in t ? t.sourceText : "");
352
423
  if (n) return e.filter((e) => e.kind === "directive_candidate").find((e) => {
353
- let t = ue(e.text);
424
+ let t = Be(e.text);
354
425
  return t.length > 0 && (n.includes(t) || t.includes(n));
355
426
  });
356
427
  }
357
- function be(e, t) {
428
+ function dt(e, t) {
358
429
  if (t) return t.blockIds.map((t) => e.get(t)).find((e) => e?.kind === "directive_candidate");
359
430
  }
360
- function xe(e) {
431
+ function ft(e) {
361
432
  return e?.links.filter((e) => !e.insideFrenchQuotes && (e.type === "article" || e.type === "division")).map((e) => e.id) ?? [];
362
433
  }
363
- var Se = [
364
- /^([IVXLCDM]+)\s*[.).]?\s*[–—-]/iu,
365
- /^(\d+°)\s+/u,
366
- /^([a-z])\)\s+/iu,
367
- /^([ivxlcdm]+)\)\s+/iu
368
- ];
369
- function Ce(e) {
370
- let t = E(e);
434
+ function pt(e) {
435
+ let t = N(e);
371
436
  if (!t) return;
372
- let n = Se.findIndex((e) => e.test(t));
373
- return n === -1 ? t.endsWith(":") ? 0 : void 0 : n + 1;
437
+ let n = ne(t);
438
+ return n ? n.level : t.endsWith(":") ? 0 : void 0;
374
439
  }
375
- function we(e) {
440
+ function mt(e) {
376
441
  let t = /* @__PURE__ */ new Map(), n = [];
377
442
  for (let r of e) {
378
- let e = Ce(r.text);
443
+ let e = pt(r.text);
379
444
  if (e === void 0) {
380
- t.set(r.id, [...n, r]);
445
+ t.set(r.id, [...n.map((e) => e.block), r]);
381
446
  continue;
382
447
  }
383
- n.length = Math.min(n.length, e), t.set(r.id, [...n, r]), n[e] = r, n.length = e + 1;
448
+ for (; n.length > 0 && n[n.length - 1].level >= e;) n.pop();
449
+ t.set(r.id, [...n.map((e) => e.block), r]), n.push({
450
+ level: e,
451
+ block: r
452
+ });
384
453
  }
385
454
  return t;
386
455
  }
387
- function Te(e, t) {
456
+ function ht(e, t) {
388
457
  let n = [], r = /* @__PURE__ */ new Set();
389
458
  for (let i of [...e ?? [], ...t]) i !== void 0 && (r.has(i.id) || (r.add(i.id), n.push(i)));
390
459
  return n;
391
460
  }
392
- function Ee(e, t, n) {
461
+ function gt(e, t, n) {
393
462
  if (!t) return;
394
- let r = Te(e, t.blockIds.map((e) => n.get(e)).filter((e) => e !== void 0));
463
+ let r = ht(e, t.blockIds.map((e) => n.get(e)).filter((e) => e !== void 0));
395
464
  if (r.length === 0) return;
396
465
  let i = r.map((e) => e.id);
397
466
  if (i.length === t.blockIds.length && i.every((e, n) => e === t.blockIds[n])) return;
@@ -406,7 +475,7 @@ function Ee(e, t, n) {
406
475
  }
407
476
  };
408
477
  }
409
- function De(e) {
478
+ function _t(e) {
410
479
  let t = [], n = 0;
411
480
  for (let r of e.blocks) {
412
481
  let i = e.directiveText.indexOf(r.text, n);
@@ -420,7 +489,7 @@ function De(e) {
420
489
  }
421
490
  return t;
422
491
  }
423
- function Oe(e, t, n) {
492
+ function vt(e, t, n) {
424
493
  let { start: r, stop: i } = n.sourcePosition, a = t.filter((e) => e.stop >= r && e.start <= i);
425
494
  if (a.length === 0) return;
426
495
  let o = a[0], s = a[a.length - 1], c = o.start, l = s.stop;
@@ -434,7 +503,7 @@ function Oe(e, t, n) {
434
503
  }
435
504
  };
436
505
  }
437
- function ke(e, t, n) {
506
+ function yt(e, t, n) {
438
507
  if (!t) return;
439
508
  let r = e.directiveText.indexOf(t.text);
440
509
  if (r === -1) return;
@@ -447,14 +516,14 @@ function ke(e, t, n) {
447
516
  stop: a
448
517
  };
449
518
  }
450
- function Ae(e) {
451
- let t = De(e), n = new Map(e.blocks.map((e) => [e.id, e])), r = we(e.blocks), a = /* @__PURE__ */ new Map(), o = [];
519
+ function bt(e) {
520
+ let t = _t(e), n = new Map(e.blocks.map((e) => [e.id, e])), r = mt(e.blocks), i = /* @__PURE__ */ new Map(), a = [];
452
521
  for (let t of e.blocks) {
453
- let e = xe(t);
454
- e.length > 0 && (o = e), a.set(t.id, o);
522
+ let e = ft(t);
523
+ e.length > 0 && (a = e), i.set(t.id, a);
455
524
  }
456
- return i(e.directiveText).map((i) => {
457
- let o = Oe(e, t, i), s = be(n, o) ?? ye(e.blocks, i), c = xe(s), l = c.length > 0 ? c : s?.id === void 0 ? [] : a.get(s.id) ?? [], u = ke(e, s, i), d = Ee(s?.id === void 0 ? void 0 : r.get(s.id), o, n);
525
+ return ee(e.directiveText).map((a) => {
526
+ let o = vt(e, t, a), s = dt(n, o) ?? ut(e.blocks, a), c = ft(s), l = c.length > 0 ? c : s?.id === void 0 ? [] : i.get(s.id) ?? [], u = yt(e, s, a), d = gt(s?.id === void 0 ? void 0 : r.get(s.id), o, n);
458
527
  return {
459
528
  articleId: e.id,
460
529
  blockId: s?.id,
@@ -469,18 +538,18 @@ function Ae(e) {
469
538
  sourceContextBlockIds: d.blockIds,
470
539
  sourceContextPosition: d.position
471
540
  },
472
- directive: i,
541
+ directive: a,
473
542
  ...l.length > 0 ? { targetIds: l } : {}
474
543
  };
475
544
  });
476
545
  }
477
- function je(e) {
546
+ function xt(e) {
478
547
  let t = /* @__PURE__ */ new Map(), n = [], r = /* @__PURE__ */ new Set();
479
548
  for (let i of e) {
480
- let e = re(i.directive);
549
+ let e = Me(i.directive);
481
550
  if (e.length === 0) continue;
482
551
  let a = e.map(({ num: e }) => ({
483
- definitionId: `${i.articleId}:article:${ee(e)}`,
552
+ definitionId: `${i.articleId}:article:${ke(e)}`,
484
553
  num: e
485
554
  }));
486
555
  t.set(i, a);
@@ -492,7 +561,6 @@ function je(e) {
492
561
  blockId: i.blockId,
493
562
  html: o.text,
494
563
  ...i.targetIds === void 0 ? {} : { parentTargetIds: i.targetIds },
495
- sourceDirectiveId: i.directive.sourceText,
496
564
  ...i.sourceBlockHtml === void 0 ? {} : { sourceBlockHtml: i.sourceBlockHtml },
497
565
  ...i.sourceBlockText === void 0 ? {} : { sourceBlockText: i.sourceBlockText },
498
566
  text: o.text
@@ -504,13 +572,13 @@ function je(e) {
504
572
  definitions: n
505
573
  };
506
574
  }
507
- function Me(e, t, n) {
508
- let r = new Map(t.map((e) => [O(e.num), e]));
575
+ function St(e, t, n) {
576
+ let r = new Map(t.map((e) => [Oe(e.num), e]));
509
577
  return e.map((e) => {
510
- let t = n.get(e), i = t?.[0], a = [...k(e.directive.reference)].map((e) => r.get(O(e))).filter((e) => e !== void 0 && e.definitionId !== i?.definitionId)[0], o = a === void 0 ? void 0 : {
578
+ let t = n.get(e), i = t?.[0], a = [...Ne(e.directive.reference)].map((e) => r.get(Oe(e))).filter((e) => e !== void 0 && e.definitionId !== i?.definitionId)[0], o = a === void 0 ? void 0 : {
511
579
  definitionId: a.definitionId,
512
580
  num: a.num
513
- }, s = ie(e.directive), c = (e.targetIds?.length ?? 0) > 0;
581
+ }, s = Pe(e.directive), c = (e.targetIds?.length ?? 0) > 0;
514
582
  return {
515
583
  ...e,
516
584
  ...i === void 0 ? {} : { createdArticle: i },
@@ -523,72 +591,96 @@ function Me(e, t, n) {
523
591
  };
524
592
  });
525
593
  }
526
- function Ne(e, t, n, i, a, o, s = !0) {
527
- let c = a.map((e) => e.directiveText).filter(Boolean).join("\n"), l = {
594
+ function Ct(e, t, n, r, i, a, o = !0, s) {
595
+ let c = i.map((e) => e.directiveText).filter(Boolean).join("\n"), l = {
528
596
  sourceFormat: e,
529
- documentDate: i,
597
+ documentDate: r,
530
598
  html: t,
531
599
  htmlWithLinks: n,
532
- tableOfContents: o ?? r(c),
533
- articles: a
600
+ tableOfContents: a ?? b(c),
601
+ articles: i
534
602
  };
535
- if (!s) return {
603
+ if (!o) return {
536
604
  ...l,
537
605
  directives: []
538
606
  };
539
- let u = le(a.map((e) => e.text).join("\n")), d = a.flatMap(Ae), { createdArticlesByDirective: f, definitions: p } = je(d), m = Me(d, p, f);
607
+ let u = ze(i.map((e) => e.text).join("\n")), d = i.flatMap(bt), { createdArticlesByDirective: f, definitions: p } = xt(d), m = St(d, p, f);
540
608
  return {
541
609
  ...l,
542
610
  ...u ? { globalApplicabilityDate: u } : {},
543
611
  ...p.length > 0 ? { internalArticleDefinitions: p } : {},
544
- directives: m
612
+ directives: m,
613
+ ...s !== void 0 && s.length > 0 ? { diagnostics: s } : {}
545
614
  };
546
615
  }
547
- function Pe(e) {
548
- let t = r(e.map((e) => e.directiveText).filter(Boolean).join("\n")), n = new Map(e.map((e) => [D(e.label), e.id])), i = 0;
549
- function a(e) {
550
- for (let t of e.articles ?? []) i += 1, t.id ??= n.get(D(t.line));
551
- for (let t of e.divisions ?? []) a(t);
552
- }
553
- return a(t), i > 0 ? t : { articles: e.map((e) => ({
616
+ function wt(e) {
617
+ return { items: e.map((e) => ({
554
618
  id: e.id,
555
619
  line: e.title ? `${e.label} : ${e.title}` : e.label,
556
620
  type: "article"
557
621
  })) };
558
622
  }
559
- async function Fe(t, n) {
560
- let r = new u("parseAssembleeBillRaw"), i = n.linkedHtml === void 0 ? await r.time("linkAssembleeBillRaw", () => Ie(t, n)) : void 0, a = r.timeSync("applyArticleAnchorIds", () => ve(n.linkedHtml ?? i.linkedHtml), { inputSize: t.length }), o = r.timeSync("cheerioLoadLinkedHtml", () => e(a)), s = r.timeSync("extractArticleHeadings", () => P(o)), c = r.timeSync("extractArticlesAndBlocks", () => s.map((e, t) => {
561
- let n = I(o, e, s[t + 1]), r = L(o, e.id, n), i = r.filter((e) => e.kind !== "noise").map((e) => e.text).join("\n");
623
+ function Tt(e) {
624
+ return Array.from(p(e)).filter((e) => e.type === "article").map((e) => P(e.line.split(/[::]/u)[0]));
625
+ }
626
+ function Et(e) {
627
+ let t = Tt(b(e.map((e) => e.directiveText).filter(Boolean).join("\n"))), n = e.map((e) => P(e.label)), r = [];
628
+ if (t.length > 0 && (t.length !== n.length || t.some((e, t) => e !== n[t]))) {
629
+ let i = t.findIndex((e, t) => e !== n[t]);
630
+ r.push({
631
+ code: "assemblee_toc_article_order_mismatch",
632
+ message: "The article order reconstructed from divisions differs from the extracted article headings; using article heading order.",
633
+ details: {
634
+ articleHeadingCount: n.length,
635
+ extractedTocArticleCount: t.length,
636
+ firstArticleHeadings: e.slice(0, 12).map((e) => e.label),
637
+ firstExtractedTocArticles: t.slice(0, 12),
638
+ firstMismatch: i === -1 ? void 0 : {
639
+ index: i,
640
+ articleHeading: e[i]?.label,
641
+ extractedTocArticle: t[i]
642
+ }
643
+ }
644
+ });
645
+ }
646
+ return {
647
+ diagnostics: r,
648
+ tableOfContents: wt(e)
649
+ };
650
+ }
651
+ async function Dt(e, t) {
652
+ let n = new me("parseAssembleeBillRaw"), r = t.linkedHtml === void 0 ? await n.time("linkAssembleeBillRaw", () => Ot(e, t)) : void 0, i = n.timeSync("applyArticleAnchorIds", () => ct(t.linkedHtml ?? r.linkedHtml), { inputSize: e.length }), a = n.timeSync("cheerioLoadLinkedHtml", () => u(i)), o = n.timeSync("extractArticleHeadings", () => nt(a)), s = n.timeSync("extractArticlesAndBlocks", () => o.map((e, t) => {
653
+ let n = it(a, e, o[t + 1]), r = ot(a, e.id, n), i = r.filter((e) => e.kind !== "noise").map((e) => e.text).join("\n");
562
654
  return {
563
655
  id: e.id,
564
656
  label: e.label,
565
657
  num: e.num,
566
658
  title: e.title,
567
- text: me(o, n),
568
- html: n.map((e) => j(o, e)).join("\n"),
659
+ text: Ge(a, n),
660
+ html: n.map((e) => Ve(a, e)).join("\n"),
569
661
  directiveText: i,
570
662
  blocks: r
571
663
  };
572
- }), { count: s.length }), l = r.timeSync("injectHiddenArticleSummary", () => R(o.html(), c)), d = r.timeSync("buildAssembleeTableOfContents", () => Pe(c), { count: c.length }), f = r.timeSync("buildParsedDocument", () => Ne("assemblee-html", t, l, n.date, c, d, n.includeDirectiveAnalysis));
573
- return r.log({
664
+ }), { count: o.length }), c = n.timeSync("injectHiddenArticleSummary", () => st(a.html(), s)), { diagnostics: l, tableOfContents: d } = n.timeSync("buildAssembleeTableOfContents", () => Et(s), { count: s.length }), f = n.timeSync("buildParsedDocument", () => Ct("assemblee-html", e, c, t.date, s, d, t.includeDirectiveAnalysis, l));
665
+ return f.diagnostics?.length && process.env.TISSEUSE_WARN_PARSED_BILL_DIAGNOSTICS === "1" && console.warn("Assemblée bill parsing diagnostics", f.diagnostics), n.log({
574
666
  articleCount: f.articles.length,
575
667
  blockCount: f.articles.reduce((e, t) => e + t.blocks.length, 0),
576
668
  directiveCount: f.directives.length,
577
669
  targetDirectiveCount: f.directives.filter((e) => e.targetIds !== void 0).length
578
670
  }), f;
579
671
  }
580
- async function Ie(e, t) {
672
+ async function Ot(e, t) {
581
673
  return {
582
674
  sourceFormat: "assemblee-html",
583
675
  documentDate: t.date,
584
676
  html: e,
585
- linkedHtml: await N(e, t, t.date)
677
+ linkedHtml: await qe(e, t, t.date)
586
678
  };
587
679
  }
588
- function B(e) {
680
+ function I(e) {
589
681
  return e.replace(/&/gu, "&amp;").replace(/</gu, "&lt;").replace(/>/gu, "&gt;").replace(/"/gu, "&quot;");
590
682
  }
591
- function Le(e) {
683
+ function kt(e) {
592
684
  let t = e;
593
685
  for (let e = 0; e < 3; e++) {
594
686
  let e = t;
@@ -596,27 +688,27 @@ function Le(e) {
596
688
  }
597
689
  return t;
598
690
  }
599
- function Re(e) {
691
+ function At(e) {
600
692
  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);
601
693
  }
602
- function V(e) {
694
+ function L(e) {
603
695
  return e.name.replace(/^.*:/u, "");
604
696
  }
605
- function ze(e, t) {
606
- return t.children.map((t) => H(e, t)).filter(Boolean).join("");
697
+ function jt(e, t) {
698
+ return t.children.map((t) => R(e, t)).filter(Boolean).join("");
607
699
  }
608
- function Be(e, t) {
609
- return t.children.map((t) => t.type === "text" && Re(t.data) ? Le(t.data) : H(e, t)).filter(Boolean).join("");
700
+ function Mt(e, t) {
701
+ return t.children.map((t) => t.type === "text" && At(t.data) ? kt(t.data) : R(e, t)).filter(Boolean).join("");
610
702
  }
611
- function H(e, t) {
703
+ function R(e, t) {
612
704
  if (t.type === "text") {
613
705
  let e = t.data.replace(/\s+\./gu, ".");
614
- return Re(e) ? Le(e) : B(e);
706
+ return At(e) ? kt(e) : I(e);
615
707
  }
616
- if (!A(t)) return "";
617
- let n = V(t), r = ze(e, t);
708
+ if (!F(t)) return "";
709
+ let n = L(t), r = jt(e, t);
618
710
  switch (n) {
619
- case "p": return `<p${U(e, t, [
711
+ case "p": return `<p${z(e, t, [
620
712
  "id",
621
713
  "class",
622
714
  "align",
@@ -630,13 +722,13 @@ function H(e, t) {
630
722
  case "u":
631
723
  case "sup":
632
724
  case "sub":
633
- case "abbr": return `<${n}${U(e, t, [
725
+ case "abbr": return `<${n}${z(e, t, [
634
726
  "id",
635
727
  "class",
636
728
  "title",
637
729
  "style"
638
730
  ])}>${r}</${n}>`;
639
- case "a": return `<a href="${B(e(t).attr("href") ?? e(t).attr("target") ?? "#")}"${U(e, t, [
731
+ case "a": return `<a href="${I(e(t).attr("href") ?? e(t).attr("target") ?? "#")}"${z(e, t, [
640
732
  "id",
641
733
  "class",
642
734
  "title",
@@ -647,8 +739,8 @@ function H(e, t) {
647
739
  case "tbody":
648
740
  case "tr":
649
741
  case "th":
650
- case "td": return Ve(e, t, n, r);
651
- case "caption": return `<caption${U(e, t, [
742
+ case "td": return Nt(e, t, n, r);
743
+ case "caption": return `<caption${z(e, t, [
652
744
  "id",
653
745
  "class",
654
746
  "align",
@@ -656,12 +748,12 @@ function H(e, t) {
656
748
  ])}>${r}</caption>`;
657
749
  case "num": return `<span class="akn-num">${r}</span> `;
658
750
  case "heading": return `<p class="akn-heading">${r}</p>`;
659
- case "content": return Be(e, t);
660
- case "alinea": return q(e, t, "div", "akn-alinea");
661
- case "article": return q(e, t, "article", "akn-article");
751
+ case "content": return Mt(e, t);
752
+ case "alinea": return B(e, t, "div", "akn-alinea");
753
+ case "article": return B(e, t, "article", "akn-article");
662
754
  case "blockList":
663
755
  case "list": return `<div class="akn-list">${r}</div>`;
664
- case "item": return q(e, t, "div", "akn-item");
756
+ case "item": return B(e, t, "div", "akn-item");
665
757
  case "listIntroduction":
666
758
  case "listWrapUp":
667
759
  case "intro":
@@ -677,23 +769,23 @@ function H(e, t) {
677
769
  case "book":
678
770
  case "tome":
679
771
  case "subchapter":
680
- case "subsection": return q(e, t, "section", `akn-${n}`);
772
+ case "subsection": return B(e, t, "section", `akn-${n}`);
681
773
  case "crossHeading": return `<p class="akn-cross-heading">${r}</p>`;
682
774
  default: return r;
683
775
  }
684
776
  }
685
- function U(e, t, n, r = {}) {
777
+ function z(e, t, n, r = {}) {
686
778
  let i = [];
687
779
  for (let r of n) {
688
780
  if (r === "style") continue;
689
781
  let n = e(t).attr(r);
690
- n !== void 0 && i.push(`${r}="${B(n)}"`);
782
+ n !== void 0 && i.push(`${r}="${I(n)}"`);
691
783
  }
692
784
  let a = r.style ?? e(t).attr("style");
693
- return a && i.push(`style="${B(a)}"`), i.length > 0 ? ` ${i.join(" ")}` : "";
785
+ return a && i.push(`style="${I(a)}"`), i.length > 0 ? ` ${i.join(" ")}` : "";
694
786
  }
695
- function Ve(e, t, n, r) {
696
- return `<${n}${U(e, t, [
787
+ function Nt(e, t, n, r) {
788
+ return `<${n}${z(e, t, [
697
789
  "id",
698
790
  "class",
699
791
  "colspan",
@@ -706,155 +798,155 @@ function Ve(e, t, n, r) {
706
798
  "cellspacing",
707
799
  "cellpadding",
708
800
  "style"
709
- ], { style: He(e, t, n) })}>${r}</${n}>`;
801
+ ], { style: Pt(e, t, n) })}>${r}</${n}>`;
710
802
  }
711
- function He(e, t, n) {
803
+ function Pt(e, t, n) {
712
804
  let r = e(t).attr("style") ?? "";
713
- return (n === "td" || n === "th") && /font-weight\s*:\s*bold/iu.test(r) && !/text-align\s*:/iu.test(r) && (r = Ue(r, "text-align", "center")), r || void 0;
805
+ return (n === "td" || n === "th") && /font-weight\s*:\s*bold/iu.test(r) && !/text-align\s*:/iu.test(r) && (r = Ft(r, "text-align", "center")), r || void 0;
714
806
  }
715
- function Ue(e, t, n) {
807
+ function Ft(e, t, n) {
716
808
  let r = e.trim();
717
809
  return `${r}${r && !r.endsWith(";") ? ";" : ""} ${t}: ${n};`.trim();
718
810
  }
719
- function We(e, t) {
720
- let n = [E(e(t).children("num").first().text()), E(e(t).children("heading").first().text())].filter(Boolean);
721
- return n.length === 0 ? "" : `<p class="akn-heading">${B(n.join(" "))}</p>`;
811
+ function It(e, t) {
812
+ let n = [N(e(t).children("num").first().text()), N(e(t).children("heading").first().text())].filter(Boolean);
813
+ return n.length === 0 ? "" : `<p class="akn-heading">${I(n.join(" "))}</p>`;
722
814
  }
723
- function Ge(e, t) {
815
+ function Lt(e, t) {
724
816
  if (!t) return !1;
725
- let n = (e) => E(e).replace(/\s+/gu, " ").replace(/\s*[..]\s*(?=[–—-])/gu, " ").trim();
726
- return n(E(e.replace(/<[^>]*>/gu, " ").replace(/&nbsp;/gu, " ").replace(/&#xa0;/giu, " ").replace(/&#x2013;/giu, "–"))).startsWith(n(t));
817
+ let n = (e) => N(e).replace(/\s+/gu, " ").replace(/\s*[..]\s*(?=[–—-])/gu, " ").trim();
818
+ return n(N(e.replace(/<[^>]*>/gu, " ").replace(/&nbsp;/gu, " ").replace(/&#xa0;/giu, " ").replace(/&#x2013;/giu, "–"))).startsWith(n(t));
727
819
  }
728
- function Ke(e) {
729
- let t = B(e);
820
+ function Rt(e) {
821
+ let t = I(e);
730
822
  return `<p data-pastille="${t}" class="pastille"><span aria-label="pastille ${t}">${t}</span></p>`;
731
823
  }
732
- function qe(e, t) {
733
- return W([Je({
824
+ function zt(e, t) {
825
+ return Bt([Vt({
734
826
  content: e,
735
827
  pastille: t
736
828
  })]);
737
829
  }
738
- function W(e) {
830
+ function Bt(e) {
739
831
  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>`;
740
832
  }
741
- function Je({ content: e, pastille: t, style: n, contextClass: r }) {
742
- let i = n ? ` style="${B(n)}"` : "", a = r ? ` ${B(r)}` : "";
743
- return `<tr${r ? ` class="${B(r)} hideable"` : ""}><td style="overflow: hidden; width: 5.0%;" class="texte-col-0 texte-col-pastille no-right-border"><div class="tableauComparatifCell${a}">${Ke(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>`;
833
+ function Vt({ content: e, pastille: t, style: n, contextClass: r }) {
834
+ let i = n ? ` style="${I(n)}"` : "", a = r ? ` ${I(r)}` : "";
835
+ return `<tr${r ? ` class="${I(r)} hideable"` : ""}><td style="overflow: hidden; width: 5.0%;" class="texte-col-0 texte-col-pastille no-right-border"><div class="tableauComparatifCell${a}">${Rt(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>`;
744
836
  }
745
- function G({ content: e, style: t, contextClass: n }) {
746
- let r = t ? ` style="${B(t)}"` : "", i = n ? ` ${B(n)}` : "";
747
- return `<tr${n ? ` class="${B(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>`;
837
+ function Ht({ content: e, style: t, contextClass: n }) {
838
+ let r = t ? ` style="${I(t)}"` : "", i = n ? ` ${I(n)}` : "";
839
+ return `<tr${n ? ` class="${I(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>`;
748
840
  }
749
- function Ye(e, t) {
841
+ function Ut(e, t) {
750
842
  return e(t).attr("data:pastille") ?? e(t).attr("pastille");
751
843
  }
752
- function Xe(e, t) {
844
+ function Wt(e, t) {
753
845
  return e(t).find("alinea[data\\:pastille],alinea[pastille]").length > 0;
754
846
  }
755
- function Ze(e, t) {
756
- return e(t).children().get().filter((e) => A(e) ? V(e) === "content" : !1).map((t) => H(e, t)).filter(Boolean).join("\n");
847
+ function Gt(e, t) {
848
+ return e(t).children().get().filter((e) => F(e) ? L(e) === "content" : !1).map((t) => R(e, t)).filter(Boolean).join("\n");
757
849
  }
758
- function Qe(e, t) {
850
+ function Kt(e, t) {
759
851
  let n = [];
760
852
  return e(t).children().each((t, r) => {
761
- if (!A(r)) return;
762
- let i = V(r);
763
- i === "num" || i === "heading" || i === "content" || n.push(H(e, r));
853
+ if (!F(r)) return;
854
+ let i = L(r);
855
+ i === "num" || i === "heading" || i === "content" || n.push(R(e, r));
764
856
  }), n.filter(Boolean);
765
857
  }
766
- function K(e, t) {
767
- let n = [], r = V(t), i = r === "alinea" ? Ye(e, t) : void 0, a = Ze(e, t), o = $e(e, t, r, i), s = at(e, t);
858
+ function qt(e, t) {
859
+ let n = [], r = L(t), i = r === "alinea" ? Ut(e, t) : void 0, a = Gt(e, t), o = Jt(e, t, r, i), s = en(e, t);
768
860
  if (i) {
769
- let r = [Ge(a, E(e(t).children("num").first().text())) ? "" : We(e, t), a].filter(Boolean).join("\n");
770
- E(r) && n.push(Je({
861
+ let r = [Lt(a, N(e(t).children("num").first().text())) ? "" : It(e, t), a].filter(Boolean).join("\n");
862
+ N(r) && n.push(Vt({
771
863
  content: r,
772
864
  pastille: i,
773
865
  style: o,
774
866
  contextClass: s
775
867
  }));
776
- } else a && n.push(G({
868
+ } else a && n.push(Ht({
777
869
  content: a,
778
870
  style: o,
779
871
  contextClass: s
780
872
  }));
781
873
  for (let r of e(t).children().get()) {
782
- if (!A(r)) continue;
783
- let t = V(r);
784
- t === "num" || t === "heading" || t === "content" || (t === "alinea" || Xe(e, r)) && n.push(...K(e, r));
874
+ if (!F(r)) continue;
875
+ let t = L(r);
876
+ t === "num" || t === "heading" || t === "content" || (t === "alinea" || Wt(e, r)) && n.push(...qt(e, r));
785
877
  }
786
878
  return n;
787
879
  }
788
- function q(e, t, n, r) {
789
- let i = V(t), a = e(t).attr("eId") ?? e(t).attr("GUID"), o = Ye(e, t), s = $e(e, t, i, o), c = [`<${n} ${[
790
- a ? `id="${B(a)}"` : void 0,
880
+ function B(e, t, n, r) {
881
+ let i = L(t), a = e(t).attr("eId") ?? e(t).attr("GUID"), o = Ut(e, t), s = Jt(e, t, i, o), c = [`<${n} ${[
882
+ a ? `id="${I(a)}"` : void 0,
791
883
  `class="${r}"`,
792
- o ? `data-pastille="${B(o)}"` : void 0,
793
- s ? `style="${B(s)}"` : void 0
884
+ o ? `data-pastille="${I(o)}"` : void 0,
885
+ s ? `style="${I(s)}"` : void 0
794
886
  ].filter((e) => e !== void 0).join(" ")}>`];
795
887
  if (i === "part" || i === "title") {
796
- let r = nt(e, t, i), a = it(e, t), o = r ? [G({
888
+ let r = Zt(e, t, i), a = $t(e, t), o = r ? [Ht({
797
889
  content: r,
798
890
  contextClass: a
799
891
  })] : [], s = () => {
800
- o.length !== 0 && (c.push(tt(o)), o = []);
892
+ o.length !== 0 && (c.push(Xt(o)), o = []);
801
893
  };
802
894
  return e(t).children().each((t, n) => {
803
- if (!A(n)) return;
804
- let r = V(n);
895
+ if (!F(n)) return;
896
+ let r = L(n);
805
897
  if (!(r === "num" || r === "heading" || r === "content")) {
806
898
  if (r === "alinea") {
807
- o.push(...K(e, n));
899
+ o.push(...qt(e, n));
808
900
  return;
809
901
  }
810
- s(), c.push(H(e, n));
902
+ s(), c.push(R(e, n));
811
903
  }
812
904
  }), s(), c.push(`</${n}>`), c.join("\n");
813
905
  }
814
906
  if (i === "article") {
815
- let r = E(e(t).children("num").first().text()), i = E(e(t).children("heading").first().text()), a = M(r) ?? {
907
+ let r = N(e(t).children("num").first().text()), i = N(e(t).children("heading").first().text()), a = v(r) ?? {
816
908
  label: r,
817
909
  num: r
818
- }, o = `<p class="TCNumArticle as-text toc-article dispositif" id="${B(`_TocArt${(a.num ?? r).replace(/\s+/gu, "")}`)}">${B(a.label)}${i ? ` : ${B(i)}` : ""}</p>`;
819
- if (Xe(e, t)) {
820
- let r = [G({
910
+ }, o = `<p class="TCNumArticle as-text toc-article dispositif" id="${I(`_TocArt${(a.num ?? r).replace(/\s+/gu, "")}`)}">${I(a.label)}${i ? ` : ${I(i)}` : ""}</p>`;
911
+ if (Wt(e, t)) {
912
+ let r = [Ht({
821
913
  content: o,
822
- contextClass: st(a.label)
823
- }), ...K(e, t)];
824
- c.push(W(r));
825
- for (let n of Qe(e, t)) n.includes("akn-pastille-table") || c.push(n);
914
+ contextClass: nn(a.label)
915
+ }), ...qt(e, t)];
916
+ c.push(Bt(r));
917
+ for (let n of Kt(e, t)) n.includes("akn-pastille-table") || c.push(n);
826
918
  return c.push(`</${n}>`), c.join("\n");
827
919
  }
828
920
  c.push(o);
829
921
  }
830
922
  let l = [];
831
923
  for (let n of ["content", "children"]) e(t).children().each((t, r) => {
832
- if (!A(r)) return;
833
- let i = V(r);
834
- i === "num" || i === "heading" || n === "content" && i !== "content" || n === "children" && i === "content" || l.push(H(e, r));
924
+ if (!F(r)) return;
925
+ let i = L(r);
926
+ i === "num" || i === "heading" || n === "content" && i !== "content" || n === "children" && i === "content" || l.push(R(e, r));
835
927
  });
836
928
  let u = l.join("\n");
837
929
  if (i !== "article") {
838
- let n = Ge(u, E(e(t).children("num").first().text())) ? "" : We(e, t);
930
+ let n = Lt(u, N(e(t).children("num").first().text())) ? "" : It(e, t);
839
931
  n && c.push(n);
840
932
  }
841
- return c.push(o ? qe(u, o) : u), c.push(`</${n}>`), c.join("\n");
933
+ return c.push(o ? zt(u, o) : u), c.push(`</${n}>`), c.join("\n");
842
934
  }
843
- function $e(e, t, n, r) {
844
- let i = et(e(t).attr("style") ?? "", "font-family");
845
- return !r && n !== "article" && /font-weight\s*:\s*bold/iu.test(i) && !/text-align\s*:/iu.test(i) && (i = Ue(i, "text-align", "center")), i || void 0;
935
+ function Jt(e, t, n, r) {
936
+ let i = Yt(e(t).attr("style") ?? "", "font-family");
937
+ return !r && n !== "article" && /font-weight\s*:\s*bold/iu.test(i) && !/text-align\s*:/iu.test(i) && (i = Ft(i, "text-align", "center")), i || void 0;
846
938
  }
847
- function et(e, t) {
939
+ function Yt(e, t) {
848
940
  return e.split(";").map((e) => e.trim()).filter(Boolean).filter((e) => !e.toLowerCase().startsWith(`${t.toLowerCase()}:`)).join(";");
849
941
  }
850
- function tt(e) {
942
+ function Xt(e) {
851
943
  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>`;
852
944
  }
853
- function nt(e, t, n) {
854
- let r = E(e(t).children("num").first().text()), i = E(e(t).children("heading").first().text()), a = rt(n), o = [];
855
- return r && o.push(`<p class="${a.num} as-text dispositif"><span aria-label="">${B(r)}</span></p>`), i && o.push(`<p class="${a.heading} as-text dispositif"><span aria-label="">${B(i)}</span></p>`), o.join("\n");
945
+ function Zt(e, t, n) {
946
+ let r = N(e(t).children("num").first().text()), i = N(e(t).children("heading").first().text()), a = Qt(n), o = [];
947
+ return r && o.push(`<p class="${a.num} as-text dispositif"><span aria-label="">${I(r)}</span></p>`), i && o.push(`<p class="${a.heading} as-text dispositif"><span aria-label="">${I(i)}</span></p>`), o.join("\n");
856
948
  }
857
- function rt(e) {
949
+ function Qt(e) {
858
950
  switch (e) {
859
951
  case "part": return {
860
952
  num: "TCNumPartie",
@@ -878,22 +970,22 @@ function rt(e) {
878
970
  };
879
971
  }
880
972
  }
881
- function it(e, t) {
882
- let n = ot(E(e(t).children("num").first().text()));
973
+ function $t(e, t) {
974
+ let n = tn(N(e(t).children("num").first().text()));
883
975
  if (n) return n;
884
976
  for (let n of e(t).parents().get()) {
885
- if (!A(n)) continue;
886
- let t = V(n);
977
+ if (!F(n)) continue;
978
+ let t = L(n);
887
979
  if (t !== "title" && t !== "part") continue;
888
- let r = ot(E(e(n).children("num").first().text()));
980
+ let r = tn(N(e(n).children("num").first().text()));
889
981
  if (r) return r;
890
982
  }
891
983
  }
892
- function at(e, t) {
893
- return it(e, t);
984
+ function en(e, t) {
985
+ return $t(e, t);
894
986
  }
895
- function ot(e) {
896
- let [t, ...n] = E(e).split(/\s+/u);
987
+ function tn(e) {
988
+ let [t, ...n] = N(e).split(/\s+/u);
897
989
  if (!t || n.length === 0) return;
898
990
  let r = t.toLocaleLowerCase("fr-FR");
899
991
  if ([
@@ -903,10 +995,10 @@ function ot(e) {
903
995
  "section"
904
996
  ].includes(r)) return `${r}-${n.join("_")}`;
905
997
  }
906
- function st(e) {
907
- return `article-${E(e).replace(/^Article\s+/iu, "").replace(/\s+/gu, "_")} article`;
998
+ function nn(e) {
999
+ return `article-${N(e).replace(/^Article\s+/iu, "").replace(/\s+/gu, "_")} article`;
908
1000
  }
909
- function ct(e) {
1001
+ function rn(e) {
910
1002
  switch (e) {
911
1003
  case "part": return "partie";
912
1004
  case "book": return "livre";
@@ -918,11 +1010,11 @@ function ct(e) {
918
1010
  default: return;
919
1011
  }
920
1012
  }
921
- function lt(e, t) {
922
- return [E(e(t).children("num").first().text()), E(e(t).children("heading").first().text())].filter(Boolean).join(" ");
1013
+ function an(e, t) {
1014
+ return [N(e(t).children("num").first().text()), N(e(t).children("heading").first().text())].filter(Boolean).join(" ");
923
1015
  }
924
- function ut(e, t) {
925
- let n = E(e(t).children("num").first().text()), r = E(e(t).children("heading").first().text()), i = M(n) ?? {
1016
+ function on(e, t) {
1017
+ let n = N(e(t).children("num").first().text()), r = N(e(t).children("heading").first().text()), i = v(n) ?? {
926
1018
  label: n,
927
1019
  num: n
928
1020
  };
@@ -932,138 +1024,138 @@ function ut(e, t) {
932
1024
  type: "article"
933
1025
  };
934
1026
  }
935
- function dt(e, t) {
936
- t.articles?.length && (e.articles ??= [], e.articles.push(...t.articles)), t.divisions?.length && (e.divisions ??= [], e.divisions.push(...t.divisions));
1027
+ function sn(e, t) {
1028
+ e.items.push(...t.items);
937
1029
  }
938
- function J(e, t) {
939
- let n = {};
1030
+ function cn(e, t) {
1031
+ let n = { items: [] };
940
1032
  return e(t).children().each((t, r) => {
941
- if (!A(r)) return;
942
- let i = V(r);
1033
+ if (!F(r)) return;
1034
+ let i = L(r);
943
1035
  if (i === "article") {
944
- n.articles ??= [], n.articles.push(ut(e, r));
1036
+ n.items.push(on(e, r));
945
1037
  return;
946
1038
  }
947
- let a = ct(i);
1039
+ let a = rn(i);
948
1040
  if (!a) {
949
- dt(n, J(e, r));
1041
+ sn(n, cn(e, r));
950
1042
  return;
951
1043
  }
952
- let o = lt(e, r), s = J(e, r);
953
- !o && !s.articles?.length && !s.divisions?.length || (n.divisions ??= [], n.divisions.push({
1044
+ let o = an(e, r), s = cn(e, r);
1045
+ !o && s.items.length === 0 || n.items.push({
954
1046
  ...s,
955
1047
  id: e(r).attr("eId") ?? e(r).attr("GUID"),
956
1048
  line: o,
957
1049
  type: a
958
- }));
1050
+ });
959
1051
  }), n;
960
1052
  }
961
- function ft(e) {
1053
+ function ln(e) {
962
1054
  let t = e("body").first().get(0);
963
- return t === void 0 ? {} : J(e, t);
1055
+ return t === void 0 ? { items: [] } : cn(e, t);
964
1056
  }
965
- function pt(e) {
1057
+ function un(e) {
966
1058
  return e("FRBRExpression FRBRdate[name=\"#depot\"]").attr("date") ?? e("FRBRWork FRBRdate[name=\"#presentation\"]").attr("date");
967
1059
  }
968
- function mt(e) {
1060
+ function dn(e) {
969
1061
  let t = e("preamble").first(), n = e("body").first(), r = ["<div class=\"akn-bill\">"];
970
- return t.length > 0 && (r.push("<section class=\"akn-preamble\">"), r.push(ze(e, t.get(0))), r.push("</section>")), r.push("<section class=\"akn-body\">"), n.children().each((t, n) => {
971
- A(n) && r.push(V(n) === "article" ? q(e, n, "article", "akn-article") : H(e, n));
1062
+ return t.length > 0 && (r.push("<section class=\"akn-preamble\">"), r.push(jt(e, t.get(0))), r.push("</section>")), r.push("<section class=\"akn-body\">"), n.children().each((t, n) => {
1063
+ F(n) && r.push(L(n) === "article" ? B(e, n, "article", "akn-article") : R(e, n));
972
1064
  }), r.push("</section></div>"), r.join("\n");
973
1065
  }
974
- function ht(t) {
975
- let n = e(t, { xml: {
1066
+ function fn(e) {
1067
+ let t = u(e, { xml: {
976
1068
  decodeEntities: !1,
977
1069
  lowerCaseTags: !1,
978
1070
  lowerCaseAttributeNames: !1,
979
1071
  xmlMode: !0
980
- } }), r = pt(n), i = mt(n);
1072
+ } }), n = un(t), r = dn(t);
981
1073
  return {
982
1074
  sourceFormat: "akoma-ntoso",
983
- documentDate: r,
984
- html: i,
985
- linkedHtml: i
1075
+ documentDate: n,
1076
+ html: r,
1077
+ linkedHtml: r
986
1078
  };
987
1079
  }
988
- function gt(t) {
989
- return _t(e(t));
1080
+ function pn(e) {
1081
+ return mn(u(e));
990
1082
  }
991
- function _t(e) {
1083
+ function mn(e) {
992
1084
  let t = [];
993
1085
  return e("article.akn-article").each((n, r) => {
994
- let i = e(r).children("p.TCNumArticle").first().get(0), a = E(i ? e(i).text() : ""), o = M(a) ?? { label: a || `Article ${n + 1}` }, s = e(r).attr("id") ?? `akn-article-${String(n + 1).padStart(3, "0")}`, c = [r], l = L(e, s, c), u = l.filter((e) => e.kind !== "noise").map((e) => e.text).join("\n");
1086
+ let i = e(r).children("p.TCNumArticle").first().get(0), a = N(i ? e(i).text() : ""), o = v(a) ?? { label: a || `Article ${n + 1}` }, s = e(r).attr("id") ?? `akn-article-${String(n + 1).padStart(3, "0")}`, c = [r], l = ot(e, s, c), u = l.filter((e) => e.kind !== "noise").map((e) => e.text).join("\n");
995
1087
  t.push({
996
1088
  id: s,
997
1089
  label: o.label,
998
1090
  num: o.num,
999
1091
  title: o.title,
1000
- text: me(e, c),
1001
- html: j(e, r),
1092
+ text: Ge(e, c),
1093
+ html: Ve(e, r),
1002
1094
  directiveText: u,
1003
1095
  blocks: l
1004
1096
  });
1005
1097
  }), t;
1006
1098
  }
1007
- function vt(t) {
1008
- let n = e(t);
1099
+ function hn(e) {
1100
+ let t = u(e);
1009
1101
  return {
1010
- articles: _t(n),
1011
- htmlWithLinks: n.html()
1102
+ articles: mn(t),
1103
+ htmlWithLinks: t.html()
1012
1104
  };
1013
1105
  }
1014
- async function yt(t, n) {
1015
- let r = new u("parseAkomaNtosoBillRaw"), i = r.timeSync("cheerioLoadXml", () => e(t, { xml: {
1106
+ async function gn(e, t) {
1107
+ let n = new me("parseAkomaNtosoBillRaw"), r = n.timeSync("cheerioLoadXml", () => u(e, { xml: {
1016
1108
  decodeEntities: !1,
1017
1109
  lowerCaseTags: !1,
1018
1110
  lowerCaseAttributeNames: !1,
1019
1111
  xmlMode: !0
1020
- } })), a = n.date ?? pt(i), o = r.timeSync("renderAknHtml", () => mt(i), { inputSize: t.length }), s = n.linkedHtml ?? await r.time("addLinksToRenderedAknHtml", () => N(o, {
1021
- ...n,
1022
- date: a
1023
- }, a)), c = r.timeSync("extractRenderedAknArticles", () => gt(o)), l = r.timeSync("injectHiddenArticleSummary", () => R(s, c)), { articles: d, htmlWithLinks: f } = r.timeSync("extractLinkedAknArticlesAndTaggedHtml", () => vt(l)), p = d.length > 0 ? d : c, m = r.timeSync("extractAknTableOfContents", () => ft(i)), h = r.timeSync("buildParsedDocument", () => Ne("akoma-ntoso", o, d.length > 0 ? f : l, a, p, m));
1024
- return r.log({
1025
- articleCount: h.articles.length,
1026
- blockCount: h.articles.reduce((e, t) => e + t.blocks.length, 0),
1027
- directiveCount: h.directives.length,
1028
- targetDirectiveCount: h.directives.filter((e) => e.targetIds !== void 0).length
1029
- }), h;
1112
+ } })), i = t.date ?? un(r), a = n.timeSync("renderAknHtml", () => dn(r), { inputSize: e.length }), o = t.linkedHtml ?? await n.time("addLinksToRenderedAknHtml", () => qe(a, {
1113
+ ...t,
1114
+ date: i
1115
+ }, i)), s = n.timeSync("extractRenderedAknArticles", () => pn(a)), c = n.timeSync("injectHiddenArticleSummary", () => st(o, s)), { articles: l, htmlWithLinks: d } = n.timeSync("extractLinkedAknArticlesAndTaggedHtml", () => hn(c)), f = l.length > 0 ? l : s, p = n.timeSync("extractAknTableOfContents", () => ln(r)), m = n.timeSync("buildParsedDocument", () => Ct("akoma-ntoso", a, l.length > 0 ? d : c, i, f, p, t.includeDirectiveAnalysis));
1116
+ return n.log({
1117
+ articleCount: m.articles.length,
1118
+ blockCount: m.articles.reduce((e, t) => e + t.blocks.length, 0),
1119
+ directiveCount: m.directives.length,
1120
+ targetDirectiveCount: m.directives.filter((e) => e.targetIds !== void 0).length
1121
+ }), m;
1030
1122
  }
1031
- async function bt(e, t) {
1032
- let n = ht(e), r = t.date ?? n.documentDate;
1123
+ async function _n(e, t) {
1124
+ let n = fn(e), r = t.date ?? n.documentDate;
1033
1125
  return {
1034
1126
  sourceFormat: "akoma-ntoso",
1035
1127
  documentDate: r,
1036
1128
  html: n.html,
1037
- linkedHtml: await N(n.html, t, r)
1129
+ linkedHtml: await qe(n.html, t, r)
1038
1130
  };
1039
1131
  }
1040
1132
  //#endregion
1041
1133
  //#region src/lib/server/assemblee_document_search.ts
1042
- var xt = /\bexpos[ée]\s+des\s+motifs\b/giu, St = /\barticle\s+(?:premier|1er|\d+)/iu;
1043
- function Y(e) {
1134
+ var vn = /\bexpos[ée]\s+des\s+motifs\b/giu, yn = /\barticle\s+(?:premier|1er|\d+)/iu;
1135
+ function bn(e) {
1044
1136
  return e.replace(/\u00a0/gu, " ").replace(/\s+/gu, " ").trim();
1045
1137
  }
1046
- function Ct(t) {
1047
- let n = Y(e(t).text()), r = [...n.matchAll(xt)], i = /* @__PURE__ */ new Set(), a = [];
1048
- for (let [e, t] of r.entries()) {
1049
- let o = (t.index ?? 0) + t[0].length, s = n.slice(o), c = St.exec(s), l = Y(s.slice(0, c?.index ?? s.length));
1050
- if (l.length < 20 || i.has(l)) continue;
1051
- i.add(l);
1138
+ function xn(e) {
1139
+ let t = bn(u(e).text()), n = [...t.matchAll(vn)], r = /* @__PURE__ */ new Set(), i = [];
1140
+ for (let [e, a] of n.entries()) {
1141
+ let o = (a.index ?? 0) + a[0].length, s = t.slice(o), c = yn.exec(s), l = bn(s.slice(0, c?.index ?? s.length));
1142
+ if (l.length < 20 || r.has(l)) continue;
1143
+ r.add(l);
1052
1144
  let u = `expose-des-motifs-${e + 1}`;
1053
- a.push({
1145
+ i.push({
1054
1146
  anchor: u,
1055
1147
  articleNumber: null,
1056
1148
  content: l,
1057
1149
  itemId: u,
1058
1150
  itemKind: "expose_des_motifs",
1059
- label: r.length === 1 ? "Exposé des motifs" : `Exposé des motifs ${e + 1}`,
1151
+ label: n.length === 1 ? "Exposé des motifs" : `Exposé des motifs ${e + 1}`,
1060
1152
  title: null
1061
1153
  });
1062
1154
  }
1063
- return a;
1155
+ return i;
1064
1156
  }
1065
- async function wt({ date: e, html: t, linkBaseUrl: n, linkType: r }) {
1066
- let i = await Fe(t, {
1157
+ async function Sn({ date: e, html: t, linkBaseUrl: n, linkType: r }) {
1158
+ let i = await Dt(t, {
1067
1159
  date: e,
1068
1160
  includeDirectiveAnalysis: !1,
1069
1161
  linkBaseUrl: n,
@@ -1072,7 +1164,7 @@ async function wt({ date: e, html: t, linkBaseUrl: n, linkType: r }) {
1072
1164
  });
1073
1165
  return {
1074
1166
  items: [...i.articles.map((e) => {
1075
- let t = Y(e.directiveText || e.text);
1167
+ let t = bn(e.directiveText || e.text);
1076
1168
  if (t) return {
1077
1169
  anchor: e.id,
1078
1170
  articleNumber: e.num ?? null,
@@ -1082,17 +1174,17 @@ async function wt({ date: e, html: t, linkBaseUrl: n, linkType: r }) {
1082
1174
  label: e.label,
1083
1175
  title: e.title ?? null
1084
1176
  };
1085
- }).filter((e) => e !== void 0), ...Ct(t)],
1177
+ }).filter((e) => e !== void 0), ...xn(t)],
1086
1178
  tableOfContents: i.tableOfContents
1087
1179
  };
1088
1180
  }
1089
- function Tt(e, t) {
1090
- return h("sha256").update(JSON.stringify({
1181
+ function Cn(e, t) {
1182
+ return k("sha256").update(JSON.stringify({
1091
1183
  item: e,
1092
1184
  metadata: t
1093
1185
  })).digest("hex");
1094
1186
  }
1095
- function Et(e) {
1187
+ function wn(e) {
1096
1188
  if (typeof e != "object" || !e) return;
1097
1189
  let t = e.cycleDeVie?.chrono;
1098
1190
  if (t !== void 0) for (let e of [
@@ -1107,11 +1199,11 @@ function Et(e) {
1107
1199
  }
1108
1200
  //#endregion
1109
1201
  //#region src/lib/server/senat_amendment_search.ts
1110
- function Dt(t) {
1111
- return t?.trim() ? e(t).text().replace(/\u00a0/gu, " ").replace(/\s+/gu, " ").trim() : "";
1202
+ function Tn(e) {
1203
+ return e?.trim() ? u(e).text().replace(/\u00a0/gu, " ").replace(/\s+/gu, " ").trim() : "";
1112
1204
  }
1113
- function Ot({ dispositifHtml: e, objetHtml: t }) {
1114
- let n = Dt(e), r = Dt(t);
1205
+ function En({ dispositifHtml: e, objetHtml: t }) {
1206
+ let n = Tn(e), r = Tn(t);
1115
1207
  return [...n ? [{
1116
1208
  content: n,
1117
1209
  itemKind: "dispositif",
@@ -1122,47 +1214,658 @@ function Ot({ dispositifHtml: e, objetHtml: t }) {
1122
1214
  label: "Objet"
1123
1215
  }] : []];
1124
1216
  }
1125
- function kt(e, t) {
1126
- return h("sha256").update(JSON.stringify({
1217
+ function Dn(e, t) {
1218
+ return k("sha256").update(JSON.stringify({
1127
1219
  item: e,
1128
1220
  metadata: t
1129
1221
  })).digest("hex");
1130
1222
  }
1131
1223
  //#endregion
1224
+ //#region src/lib/text_parsers/amendment_action_directives.ts
1225
+ function V(e, t) {
1226
+ return {
1227
+ ...t,
1228
+ position: e.position(),
1229
+ type: "amendment_action_directive"
1230
+ };
1231
+ }
1232
+ function On(e, t) {
1233
+ return {
1234
+ type: e === "start" ? "head_of_target" : "tail_after_target",
1235
+ unit: t ? se(t) : "article"
1236
+ };
1237
+ }
1238
+ function kn(e) {
1239
+ return e === "start" ? "insert_before" : "insert_after";
1240
+ }
1241
+ var An = D(E("[\\s\\S]*?(?=supprimer|substituer|remplacer|ins[eé]rer|compl[eé]ter|r[eé]diger)", { flags: "i" }), { default: "" }), H = O(_, w([E("les?\\s+", { flags: "i" }), ie], { value: (e) => e[1] }), ie, a), jn = O(w([E("la\\s+fin\\s+de\\s+", { flags: "i" }), H], { value: (e) => {
1242
+ let t = e[1];
1243
+ return {
1244
+ targetReference: t,
1245
+ targetScope: {
1246
+ type: "tail_after_target",
1247
+ unit: se(t)
1248
+ }
1249
+ };
1250
+ } }), w([x], { value: (e) => ({ targetScope: e[0] }) })), U = D(w([
1251
+ D(E("(?:[aà]\\s+la\\s+fin\\s+(?:du|de\\s+la|de\\s+l['’]?)\\s*)", { flags: "i" }), { default: "" }),
1252
+ D(E("(?:au\\s+d[eé]but\\s+d(?:u|e\\s+la|e\\s+l['’]?)\\s*)", { flags: "i" }), { default: "" }),
1253
+ H,
1254
+ D(E("\\s*,?\\s*(?:(?:[IVXLCDM]+)\\s*[.\\-–—]+\\s*|\\d+°\\s*|[a-z]\\)\\s*)?", { flags: "i" }), { default: "" })
1255
+ ], { value: (e, t) => ({
1256
+ reference: e[2],
1257
+ text: t.text()
1258
+ }) }), { default: null }), Mn = D(E(`(?:(?:[aà]\\s+)?la\\s+(?:derni(?:ère|ere)|${ge})\\s+occurrence\\s+)`, { flags: "i" }), { default: "" });
1259
+ function W(e) {
1260
+ return e?.text ?? "";
1261
+ }
1262
+ function G(e) {
1263
+ return { citation: l(e.position()) };
1264
+ }
1265
+ var K = O(w([S], { value: (e) => ({ citation: e[0] }) }), E("\\S[\\s\\S]*", { value: (e, t) => G(t) })), Nn = E("\\S[\\s\\S]*", { value: (e, t) => G(t) }), q = E("[^:«“\"]*(?::\\s*)?", { flags: "i" }), Pn = E("\\S[\\s\\S]*?(?=\\s+par\\s+(?:les?\\s+)?(?:mots?|montants?|taux|références?|mentions?|dates?|années?)\\s*:)", {
1266
+ flags: "i",
1267
+ value: (e, t) => G(t)
1268
+ }), Fn = E("\\S[\\s\\S]*?(?=\\s+(?:ins[eé]rer|ajouter|supprimer|r[eé]diger)\\b)", {
1269
+ flags: "i",
1270
+ value: (e, t) => G(t)
1271
+ }), In = E("\\S[\\s\\S]*?(?=\\s*(?:(?:[IVXLCDM]+)\\s*[.\\-–—]+\\s*|\\d+°\\s*|[a-z]\\)\\s*|$))", {
1272
+ flags: "i",
1273
+ value: (e, t) => G(t)
1274
+ }), Ln = O(w([S], { value: (e) => ({ citation: e[0] }) }), Pn), Rn = O(w([S], { value: (e) => ({ citation: e[0] }) }), In), zn = w([E(`${o}s?\\s*:?\\s*`, { flags: "i" }), Ln], { value: (e) => e[1] }), Bn = w([E(`${oe}s?(?: suivant(?:e)?s?)?\\s*:?\\s*`, { flags: "i" }), Rn], { value: (e) => e[1] }), Vn = O(w([S], { value: (e) => ({ citation: e[0] }) }), Fn), Hn = w([
1275
+ Mn,
1276
+ E(`${o}s?\\s*:?\\s*`, { flags: "i" }),
1277
+ Vn
1278
+ ], { value: (e) => e[2] }), Un = w([
1279
+ Mn,
1280
+ E(`${o}s?\\s*:?\\s*`, { flags: "i" }),
1281
+ O(w([S], { value: (e) => ({ citation: e[0] }) }), Nn)
1282
+ ], { value: (e) => e[2] });
1283
+ function J(e) {
1284
+ return e?.reference;
1285
+ }
1286
+ var Wn = w([An, E("supprimer\\s+cet\\s+article", { flags: "i" })], { value: (e, t) => V(t, {
1287
+ contextText: e[0],
1288
+ kind: "delete_article"
1289
+ }) }), Gn = w([
1290
+ U,
1291
+ E("supprimer", { flags: "i" }),
1292
+ D(w([T, H], { value: (e) => e[1] }), { default: null }),
1293
+ D(w([T, Un], { value: (e) => e[1] }), { default: null })
1294
+ ], { value: (e, t) => V(t, {
1295
+ contextText: W(e[0]),
1296
+ kind: "delete_portion",
1297
+ targetCitation: e[3]?.citation ?? void 0,
1298
+ targetReference: e[2] ?? J(e[0])
1299
+ }) }), Kn = w([
1300
+ U,
1301
+ O(E("r[eé]diger\\s+ainsi", { flags: "i" }), E("r[eé]tablir", { flags: "i" })),
1302
+ q,
1303
+ K
1304
+ ], { value: (e, t) => V(t, {
1305
+ contextText: W(e[0]),
1306
+ kind: "rewrite_portion",
1307
+ replacementCitation: e[3].citation,
1308
+ targetReference: J(e[0])
1309
+ }) }), qn = w([
1310
+ U,
1311
+ O(E("substituer", { flags: "i" }), E("remplacer", { flags: "i" })),
1312
+ T,
1313
+ Mn,
1314
+ zn,
1315
+ E("\\s*,?\\s*"),
1316
+ D(E("par\\s+", { flags: "i" }), { default: "" }),
1317
+ Bn
1318
+ ], { value: (e, t) => V(t, {
1319
+ contextText: W(e[0]),
1320
+ kind: "replace",
1321
+ replacementCitation: e[7].citation,
1322
+ targetCitation: e[4].citation,
1323
+ targetReference: J(e[0])
1324
+ }) }), Jn = w([
1325
+ U,
1326
+ E("substituer", { flags: "i" }),
1327
+ T,
1328
+ D(E("(?:[aà]|aux?|à la)\\s+", { flags: "i" }), { default: "" }),
1329
+ H,
1330
+ E("[\\s\\S]*?(?=[«“\"]|$)"),
1331
+ K
1332
+ ], { value: (e, t) => V(t, {
1333
+ contextText: W(e[0]),
1334
+ kind: "rewrite_portion",
1335
+ replacementCitation: e[6].citation,
1336
+ targetReference: e[4] ?? J(e[0])
1337
+ }) }), Yn = w([
1338
+ n,
1339
+ T,
1340
+ E("l['’ ]article", { flags: "i" }),
1341
+ E("[\\s\\S]*?(?=ins[eé]rer)", { flags: "i" }),
1342
+ E("ins[eé]rer", { flags: "i" }),
1343
+ q,
1344
+ K
1345
+ ], { value: (e, t) => V(t, {
1346
+ contextText: "",
1347
+ insertCitation: e[6].citation,
1348
+ kind: e[0] === "before" ? "insert_article_before" : "insert_article_after"
1349
+ }) }), Xn = w([
1350
+ n,
1351
+ T,
1352
+ H,
1353
+ E("[\\s\\S]*?(?=ins[eé]rer|ajouter)", { flags: "i" }),
1354
+ O(E("ins[eé]rer", { flags: "i" }), E("ajouter", { flags: "i" })),
1355
+ q,
1356
+ K
1357
+ ], { value: (e, t) => V(t, {
1358
+ contextText: "",
1359
+ insertCitation: e[6].citation,
1360
+ kind: s(e[0]),
1361
+ targetReference: e[2]
1362
+ }) }), Zn = w([
1363
+ n,
1364
+ T,
1365
+ E("l['’ ]alin[eé]a", { flags: "i" }),
1366
+ E("[\\s\\S]*?(?=ins[eé]rer)", { flags: "i" }),
1367
+ E("ins[eé]rer", { flags: "i" }),
1368
+ q,
1369
+ K
1370
+ ], { value: (e, t) => V(t, {
1371
+ contextText: "",
1372
+ insertCitation: e[6].citation,
1373
+ kind: s(e[0])
1374
+ }) }), Qn = w([
1375
+ U,
1376
+ ae,
1377
+ E("[\\s\\S]*?(?=ins[eé]rer|ajouter)", { flags: "i" }),
1378
+ O(E("ins[eé]rer", { flags: "i" }), E("ajouter", { flags: "i" })),
1379
+ q,
1380
+ K
1381
+ ], { value: (e, t) => {
1382
+ let n = e[0], r = J(n), i = e[1];
1383
+ return V(t, {
1384
+ contextText: W(n),
1385
+ insertCitation: e[5].citation,
1386
+ kind: kn(i),
1387
+ targetReference: r,
1388
+ targetScope: On(i, r)
1389
+ });
1390
+ } }), $n = w([
1391
+ U,
1392
+ n,
1393
+ T,
1394
+ Hn,
1395
+ E("[\\s\\S]*?(?=ins[eé]rer)"),
1396
+ E("ins[eé]rer", { flags: "i" }),
1397
+ T,
1398
+ Bn
1399
+ ], { value: (e, t) => V(t, {
1400
+ contextText: W(e[0]),
1401
+ insertCitation: e[7].citation,
1402
+ kind: s(e[1]),
1403
+ targetCitation: e[3].citation,
1404
+ targetReference: J(e[0])
1405
+ }) }), er = w([
1406
+ U,
1407
+ n,
1408
+ T,
1409
+ H,
1410
+ E("[\\s\\S]*?(?=ins[eé]rer|ajouter)", { flags: "i" }),
1411
+ O(E("ins[eé]rer", { flags: "i" }), E("ajouter", { flags: "i" })),
1412
+ q,
1413
+ K
1414
+ ], { value: (e, t) => V(t, {
1415
+ contextText: W(e[0]),
1416
+ insertCitation: e[7].citation,
1417
+ kind: s(e[1]),
1418
+ targetReference: J(e[0]) ?? e[3]
1419
+ }) }), tr = O(Qn, Yn, Xn, Zn, Jn, w([
1420
+ U,
1421
+ n,
1422
+ T,
1423
+ Hn,
1424
+ E("[\\s\\S]*?(?=supprimer|r[eé]diger)", { flags: "i" }),
1425
+ O(w([
1426
+ E("supprimer", {
1427
+ flags: "i",
1428
+ value: "delete_portion"
1429
+ }),
1430
+ T,
1431
+ jn
1432
+ ], { value: (e) => ({
1433
+ kind: e[0],
1434
+ ...e[2]
1435
+ }) }), w([
1436
+ E("r[eé]diger\\s+ainsi", {
1437
+ flags: "i",
1438
+ value: "rewrite_portion"
1439
+ }),
1440
+ T,
1441
+ jn,
1442
+ q,
1443
+ K
1444
+ ], { value: (e) => ({
1445
+ kind: e[0],
1446
+ replacementCitation: e[4].citation,
1447
+ ...e[2]
1448
+ }) }))
1449
+ ], { value: (e, t) => {
1450
+ let n = e[5];
1451
+ return V(t, {
1452
+ contextText: W(e[0]),
1453
+ kind: n.kind,
1454
+ replacementCitation: n.replacementCitation,
1455
+ targetCitation: e[3].citation,
1456
+ targetReference: J(e[0]) ?? n.targetReference,
1457
+ targetScope: n.targetScope
1458
+ });
1459
+ } }), $n, er, w([
1460
+ An,
1461
+ E("ins[eé]rer", { flags: "i" }),
1462
+ E(`[\\s\\S]*?(?=${t})`, { flags: "i" }),
1463
+ n,
1464
+ q,
1465
+ S,
1466
+ q,
1467
+ S
1468
+ ], { value: (e, t) => V(t, {
1469
+ contextText: e[0],
1470
+ insertCitation: e[8],
1471
+ kind: s(e[3]),
1472
+ targetCitation: e[6]
1473
+ }) }), qn, Kn, w([
1474
+ U,
1475
+ E("compl[eé]ter", { flags: "i" }),
1476
+ D(w([T, H], { value: (e) => e[1] }), { default: null }),
1477
+ q,
1478
+ K
1479
+ ], { value: (e, t) => V(t, {
1480
+ contextText: W(e[0]),
1481
+ insertCitation: e[4].citation,
1482
+ kind: "insert_after",
1483
+ targetReference: e[2] ?? J(e[0])
1484
+ }) }), Wn, Gn);
1485
+ //#endregion
1486
+ //#region src/lib/server/parsed_amendments.ts
1487
+ function nr(e) {
1488
+ return e.replace(/\s+/gu, " ").trim();
1489
+ }
1490
+ function rr(e) {
1491
+ return e.split(/\n/gu).map(nr).filter(Boolean).join("\n");
1492
+ }
1493
+ function ir(e, t) {
1494
+ let { start: n, stop: r } = t;
1495
+ for (; n < r && /\s/u.test(e[n]);) n++;
1496
+ for (; r > n && /\s/u.test(e[r - 1]);) r--;
1497
+ return n < r ? {
1498
+ start: n,
1499
+ stop: r
1500
+ } : null;
1501
+ }
1502
+ function ar(e, t) {
1503
+ return ue(pe(e), t);
1504
+ }
1505
+ function or(e) {
1506
+ return e === "before_article" || e === "on_article" || e === "after_article" ? e : "unknown";
1507
+ }
1508
+ function sr(e) {
1509
+ return {
1510
+ articleLabel: e.targetArticleLabel ?? null,
1511
+ targetPosition: or(e.targetPosition),
1512
+ alinea: e.targetAlinea ?? null,
1513
+ alineaLabel: e.targetAlineaLabel ?? null,
1514
+ subdivisionSourceId: e.targetSubdivisionSourceId ?? null,
1515
+ subdivisionLabel: e.targetSubdivisionLabel ?? null,
1516
+ subpos: e.targetSubpos ?? null
1517
+ };
1518
+ }
1519
+ function Y(e) {
1520
+ return {
1521
+ ...e.originalTransformation === void 0 ? {} : { sourceOriginalTransformation: e.originalTransformation },
1522
+ sourcePosition: e.position,
1523
+ sourceText: e.text
1524
+ };
1525
+ }
1526
+ function cr(e) {
1527
+ return {
1528
+ ...e.originalTransformation === void 0 ? {} : { sourceOriginalTransformation: e.originalTransformation },
1529
+ sourcePosition: e.position,
1530
+ sourceText: e.text
1531
+ };
1532
+ }
1533
+ function lr(e) {
1534
+ return {
1535
+ ...e?.originalTransformation === void 0 ? {} : { dispositifOriginalTransformation: e.originalTransformation },
1536
+ ...e === null ? {} : { dispositifPosition: e.position },
1537
+ dispositifText: e?.text ?? null
1538
+ };
1539
+ }
1540
+ function X(e, t, n, r = rr(e.slice(n.start, n.stop))) {
1541
+ return {
1542
+ originalTransformation: ar(t, n),
1543
+ position: n,
1544
+ text: r
1545
+ };
1546
+ }
1547
+ function ur(e) {
1548
+ let t = e.dispositifHtml ?? e.dispositifText;
1549
+ if (!t) return null;
1550
+ let n = e.dispositifHtml ? le()(t) : ce(t), r = n.output, i = ir(r, {
1551
+ start: 0,
1552
+ stop: r.length
1553
+ });
1554
+ return {
1555
+ dispositif: i === null ? null : X(r, n, i),
1556
+ simplifiedText: r,
1557
+ transformation: n
1558
+ };
1559
+ }
1560
+ function Z(e) {
1561
+ if (!e) return [];
1562
+ if (e.type === "enumeration") return [...Z(e.left), ...Z(e.right)];
1563
+ if (e.type === "bounded-interval") {
1564
+ let t = Z(e.first)[0], n = Z(e.last)[0];
1565
+ 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);
1566
+ }
1567
+ if (e.type === "counted-interval") {
1568
+ let t = Z(e.first)[0];
1569
+ return t === void 0 ? [] : Array.from({ length: e.count }, (e, n) => t + n);
1570
+ }
1571
+ if (e.type === "exclusion") return Z(e.left);
1572
+ for (let t of c(e)) if (t.type === "alinéa" && typeof t.index == "number" && t.index > 0) return [t.index];
1573
+ return [];
1574
+ }
1575
+ function dr(e, t) {
1576
+ let n = Z(t);
1577
+ return {
1578
+ ...e,
1579
+ alinea: n[0] ?? e.alinea ?? null,
1580
+ ...n.length > 0 ? { alineas: n } : {}
1581
+ };
1582
+ }
1583
+ function fr(e) {
1584
+ return e.replace(/^\s*(?:[IVXLCDM]+)\s*(?:\.\s*)?[-–—]\s*/iu, "").replace(/^\s*(?:\d+°|[a-z]\))\s*/iu, "").trim();
1585
+ }
1586
+ function pr(e, t) {
1587
+ let n = /^alin[eé]as?\s+(?:(\d+)|1er|premier)\b/iu.exec(fr(t.text));
1588
+ if (!n) return null;
1589
+ let r = n[1] === void 0 ? 1 : Number.parseInt(n[1], 10);
1590
+ return !Number.isFinite(r) || r < 1 ? null : {
1591
+ ...e,
1592
+ alinea: r,
1593
+ alineas: [r]
1594
+ };
1595
+ }
1596
+ function mr(e, t) {
1597
+ if (e) return e.unit === "article" && t.alinea !== null ? {
1598
+ ...e,
1599
+ unit: "alinéa"
1600
+ } : e;
1601
+ }
1602
+ function hr(e) {
1603
+ return /^(?:apr[eè]s|avant|(?:au|a[uù])\s+d[eé]but|(?:a|à)\s+la\s+fin)\b/iu.test(fr(e.text));
1604
+ }
1605
+ function gr(e, t, n, r) {
1606
+ return X(e, t, {
1607
+ start: n.position.start,
1608
+ stop: r.position.stop
1609
+ });
1610
+ }
1611
+ function _r(e) {
1612
+ return /^\s*(?:[IVXLCDM]+)\s*(?:\.\s*)?[-–—]\s*(?!alin[eé]a\b)/iu.test(e.text);
1613
+ }
1614
+ function vr(e, t) {
1615
+ let n = { ...t.position };
1616
+ function r(t) {
1617
+ let r = t.exec(e.slice(n.start, n.stop));
1618
+ r && (n = {
1619
+ start: n.start + r[0].length,
1620
+ stop: n.stop
1621
+ });
1622
+ }
1623
+ 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), ir(e, n);
1624
+ }
1625
+ function yr(e) {
1626
+ return d(e);
1627
+ }
1628
+ function br(e, t) {
1629
+ return tr(new C(e.slice(0, t.stop), t.start)) ?? null;
1630
+ }
1631
+ function Q(e, t, n) {
1632
+ if (n) return X(e, t, n.position, rr(i(e, n)));
1633
+ }
1634
+ function xr(e, t) {
1635
+ if (!e) return;
1636
+ let n = structuredClone(e);
1637
+ for (let e of r(n, { citations: !0 })) e.position !== void 0 && (e.originalTransformation = ar(t, e.position));
1638
+ return n;
1639
+ }
1640
+ function Sr(e, t, n, r) {
1641
+ let i = vr(e, n);
1642
+ if (!i) return null;
1643
+ let a = br(e, i);
1644
+ if (!a) return null;
1645
+ let o = X(e, t, i), s = xr(a.targetReference, t), c = dr(r, s), l = yr(o.text);
1646
+ if (a.kind === "delete_article") return {
1647
+ kind: "delete_article",
1648
+ ...Y(o),
1649
+ target: c
1650
+ };
1651
+ if (a.kind === "delete_portion") {
1652
+ let n = Q(e, t, a.targetCitation);
1653
+ return {
1654
+ kind: "delete_portion",
1655
+ ...Y(o),
1656
+ target: c,
1657
+ ...n === void 0 ? {} : {
1658
+ targetCitation: n,
1659
+ targetText: n.text
1660
+ },
1661
+ targetOccurrence: l,
1662
+ targetReference: s,
1663
+ targetScope: mr(a.targetScope, c)
1664
+ };
1665
+ }
1666
+ if (a.kind === "rewrite_portion") {
1667
+ let n = Q(e, t, a.replacementCitation);
1668
+ if (!n) return null;
1669
+ let r = Q(e, t, a.targetCitation);
1670
+ return {
1671
+ kind: "rewrite_portion",
1672
+ ...Y(o),
1673
+ target: c,
1674
+ ...r === void 0 ? {} : {
1675
+ targetCitation: r,
1676
+ targetText: r.text
1677
+ },
1678
+ targetOccurrence: l,
1679
+ targetReference: s,
1680
+ targetScope: mr(a.targetScope, c),
1681
+ replacementCitation: n,
1682
+ replacementText: n.text
1683
+ };
1684
+ }
1685
+ if (a.kind === "replace") {
1686
+ let n = Q(e, t, a.replacementCitation), r = Q(e, t, a.targetCitation);
1687
+ return !n || !r ? null : {
1688
+ kind: "replace",
1689
+ ...Y(o),
1690
+ target: c,
1691
+ targetCitation: r,
1692
+ targetText: r.text,
1693
+ targetOccurrence: l,
1694
+ targetReference: s,
1695
+ replacementCitation: n,
1696
+ replacementText: n.text
1697
+ };
1698
+ }
1699
+ if (a.kind === "insert_article_after") {
1700
+ let n = Q(e, t, a.insertCitation);
1701
+ return n ? {
1702
+ kind: "insert_article_after",
1703
+ ...Y(o),
1704
+ target: c,
1705
+ insertCitation: n,
1706
+ insertText: n.text
1707
+ } : null;
1708
+ }
1709
+ if (a.kind === "insert_article_before") {
1710
+ let n = Q(e, t, a.insertCitation);
1711
+ return n ? {
1712
+ kind: "insert_article_before",
1713
+ ...Y(o),
1714
+ target: c,
1715
+ insertCitation: n,
1716
+ insertText: n.text
1717
+ } : null;
1718
+ }
1719
+ if (a.kind === "insert_after" || a.kind === "insert_before") {
1720
+ let n = Q(e, t, a.insertCitation);
1721
+ if (!n) return null;
1722
+ let r = Q(e, t, a.targetCitation);
1723
+ return {
1724
+ kind: a.kind,
1725
+ ...Y(o),
1726
+ target: c,
1727
+ ...r === void 0 ? {} : {
1728
+ targetCitation: r,
1729
+ targetText: r.text
1730
+ },
1731
+ targetOccurrence: l,
1732
+ targetReference: s,
1733
+ insertCitation: n,
1734
+ insertText: n.text,
1735
+ targetScope: mr(a.targetScope, c)
1736
+ };
1737
+ }
1738
+ return null;
1739
+ }
1740
+ function Cr(e, t) {
1741
+ let n = [], r = 0, i = 0;
1742
+ function a(r) {
1743
+ let a = ir(e, {
1744
+ start: i,
1745
+ stop: r
1746
+ });
1747
+ a !== null && n.push(X(e, t, a));
1748
+ }
1749
+ function o(t) {
1750
+ let n = Math.max(e.lastIndexOf("\n", t - 1), e.lastIndexOf("\r", t - 1));
1751
+ return e.slice(n + 1, t).trim() === "";
1752
+ }
1753
+ for (let t = 0; t < e.length; t++) {
1754
+ let n = e[t];
1755
+ if (n === "«" || n === "“") {
1756
+ if (r > 0 && o(t)) continue;
1757
+ r += 1;
1758
+ continue;
1759
+ }
1760
+ if (n === "»" || n === "”") {
1761
+ r = Math.max(0, r - 1);
1762
+ continue;
1763
+ }
1764
+ if (r > 0) continue;
1765
+ 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) && hr({
1766
+ originalTransformation: void 0,
1767
+ position: {
1768
+ start: i,
1769
+ stop: t
1770
+ },
1771
+ text: u
1772
+ });
1773
+ (c || l) && d && !f && (a(l ? t + 1 : t), i = t + 1);
1774
+ }
1775
+ return a(e.length), n;
1776
+ }
1777
+ function wr(e) {
1778
+ let t = ur(e), n = t?.dispositif ?? null, r = lr(n), i = [], a = [], o = sr(e);
1779
+ if (e.sourceFormat === "senat-ameli" && e.sourceKind === "S") return i.push({
1780
+ code: "unsupported_sub_amendment",
1781
+ message: "Les sous-amendements ne sont pas encore projetés."
1782
+ }), {
1783
+ sourceFormat: e.sourceFormat,
1784
+ amendmentId: String(e.amendmentId),
1785
+ amendmentNumber: e.amendmentNumber ?? null,
1786
+ ...r,
1787
+ directives: a,
1788
+ diagnostics: i
1789
+ };
1790
+ if (!t || !n) i.push({
1791
+ code: "missing_dispositif",
1792
+ message: "Le dispositif de l'amendement est absent."
1793
+ });
1794
+ else {
1795
+ let { simplifiedText: e, transformation: r } = t, s = o, c = null;
1796
+ for (let t of Cr(e, r)) {
1797
+ _r(t) && (s = o, c = null);
1798
+ let n = c ? gr(e, r, c, t) : t, i = Sr(e, r, n, s);
1799
+ if (i) {
1800
+ a.push(i), c = null, (i.target.alinea !== null || i.target.alineas) && (s = i.target);
1801
+ continue;
1802
+ }
1803
+ if (c) {
1804
+ c = n;
1805
+ continue;
1806
+ }
1807
+ let l = pr(o, t);
1808
+ if (l !== null) {
1809
+ s = l;
1810
+ continue;
1811
+ }
1812
+ hr(t) && (c = t);
1813
+ }
1814
+ a.length === 0 && (o.targetPosition === "after_article" || o.targetPosition === "before_article") && a.push({
1815
+ kind: o.targetPosition === "before_article" ? "insert_article_before" : "insert_article_after",
1816
+ ...Y(n),
1817
+ target: o,
1818
+ insertCitation: n,
1819
+ insertText: n.text
1820
+ }), a.length === 0 && i.push({
1821
+ code: "unrecognized_dispositif",
1822
+ message: "Le dispositif est présent mais aucune directive d'amendement n'a été reconnue.",
1823
+ ...cr(n)
1824
+ });
1825
+ }
1826
+ return {
1827
+ sourceFormat: e.sourceFormat,
1828
+ amendmentId: String(e.amendmentId),
1829
+ amendmentNumber: e.amendmentNumber ?? null,
1830
+ ...r,
1831
+ directives: a,
1832
+ diagnostics: i
1833
+ };
1834
+ }
1835
+ //#endregion
1132
1836
  //#region src/lib/server/senat_document_search.ts
1133
- var At = /^article\s+(.+?)(?:\s*[::]\s*(.+))?$/iu;
1134
- function X(e) {
1837
+ function $(e) {
1135
1838
  return e.replace(/\u00a0/gu, " ").replace(/\s+/gu, " ").trim();
1136
1839
  }
1137
- function jt(e) {
1138
- let t = e.match(At);
1840
+ function Tr(e) {
1841
+ let t = v(e);
1139
1842
  if (!t) return {
1140
1843
  articleNumber: null,
1141
1844
  label: e,
1142
1845
  title: null
1143
1846
  };
1144
- let n = X(t[1] ?? "") || null, r = X(t[2] ?? "") || null;
1847
+ let n = $(t.num ?? "") || null, r = $(t.title ?? "") || null;
1145
1848
  return {
1146
1849
  articleNumber: n,
1147
- label: n ? `Article ${n}` : e,
1850
+ label: t.label,
1148
1851
  title: r
1149
1852
  };
1150
1853
  }
1151
- function Mt(t) {
1152
- let n = e(t), r = [], i = X(n("section.akn-preamble").text());
1153
- return i && r.push({
1854
+ function Er(e) {
1855
+ let t = u(e), n = [], r = $(t("section.akn-preamble").text());
1856
+ return r && n.push({
1154
1857
  anchor: "senat-expose-des-motifs",
1155
1858
  articleNumber: null,
1156
- content: i,
1859
+ content: r,
1157
1860
  itemId: "expose-des-motifs",
1158
1861
  itemKind: "expose_des_motifs",
1159
1862
  label: "Exposé des motifs",
1160
1863
  title: null
1161
- }), n("article.akn-article").each((e, t) => {
1162
- let i = n(t), a = i.attr("id") || `akn-article-${e + 1}`, o = X(i.children("p.TCNumArticle").first().text()), s = `Article ${e + 1}`, c = jt(o || s), l = i.clone();
1864
+ }), t("article.akn-article").each((e, r) => {
1865
+ let i = t(r), a = i.attr("id") || `akn-article-${e + 1}`, o = $(i.children("p.TCNumArticle").first().text()), s = `Article ${e + 1}`, c = Tr(o || s), l = i.clone();
1163
1866
  l.children("p.TCNumArticle").remove();
1164
- let u = X(l.text());
1165
- u && r.push({
1867
+ let u = $(l.text());
1868
+ u && n.push({
1166
1869
  anchor: i.attr("id") || null,
1167
1870
  articleNumber: c.articleNumber,
1168
1871
  content: u,
@@ -1171,42 +1874,42 @@ function Mt(t) {
1171
1874
  label: c.label,
1172
1875
  title: c.title
1173
1876
  });
1174
- }), r;
1877
+ }), n;
1175
1878
  }
1176
- function Nt(e, t) {
1177
- return h("sha256").update(JSON.stringify({
1879
+ function Dr(e, t) {
1880
+ return k("sha256").update(JSON.stringify({
1178
1881
  item: e,
1179
1882
  metadata: t
1180
1883
  })).digest("hex");
1181
1884
  }
1182
1885
  //#endregion
1183
1886
  //#region src/lib/server/senat_document_sources.ts
1184
- var Pt = new Set(["senat.fr", "www.senat.fr"]), Z = "https://www.senat.fr";
1185
- function Ft(e) {
1887
+ var Or = new Set(["senat.fr", "www.senat.fr"]), kr = "https://www.senat.fr";
1888
+ function Ar(e) {
1186
1889
  return e?.trim() || void 0;
1187
1890
  }
1188
- function It(e) {
1891
+ function jr(e) {
1189
1892
  try {
1190
- let t = e.replace(/^\/+/, ""), n = /^https?:\/\//iu.test(e) ? new URL(e) : new URL(/^(?:akomantoso|leg)\//iu.test(t) ? `/${t}` : `/leg/${t}`, Z);
1191
- return Pt.has(n.hostname.toLowerCase()) ? n : void 0;
1893
+ let t = e.replace(/^\/+/, ""), n = /^https?:\/\//iu.test(e) ? new URL(e) : new URL(/^(?:akomantoso|leg)\//iu.test(t) ? `/${t}` : `/leg/${t}`, kr);
1894
+ return Or.has(n.hostname.toLowerCase()) ? n : void 0;
1192
1895
  } catch {
1193
1896
  return;
1194
1897
  }
1195
1898
  }
1196
- function Lt(e) {
1197
- let t = Ft(e);
1899
+ function Mr(e) {
1900
+ let t = Ar(e);
1198
1901
  if (t === void 0) return {
1199
1902
  publicUrl: null,
1200
1903
  status: "no_url"
1201
1904
  };
1202
- let n = It(t);
1905
+ let n = jr(t);
1203
1906
  if (n === void 0) return {
1204
1907
  publicUrl: t,
1205
1908
  status: "unsupported_source"
1206
1909
  };
1207
1910
  let r = n.pathname;
1208
1911
  if (/^\/akomantoso\/[^/]+\.akn\.xml$/iu.test(r)) return {
1209
- akomaNtosoUrl: `${Z}${r}`,
1912
+ akomaNtosoUrl: `${kr}${r}`,
1210
1913
  publicUrl: n.toString(),
1211
1914
  status: "available"
1212
1915
  };
@@ -1215,17 +1918,17 @@ function Lt(e) {
1215
1918
  publicUrl: n.toString(),
1216
1919
  status: "unsupported_source"
1217
1920
  } : {
1218
- akomaNtosoUrl: `${Z}/akomantoso/${i.replace(/\.html$/iu, ".akn.xml")}`,
1921
+ akomaNtosoUrl: `${kr}/akomantoso/${i.replace(/\.html$/iu, ".akn.xml")}`,
1219
1922
  publicUrl: n.toString(),
1220
1923
  status: "available"
1221
1924
  };
1222
1925
  }
1223
- function Rt(e) {
1926
+ function Nr(e) {
1224
1927
  return /^\s*(?:<\?xml\b[^>]*>\s*)?<akomaNtoso[\s/>]/iu.test(e);
1225
1928
  }
1226
1929
  //#endregion
1227
1930
  //#region src/lib/alineas/alineas_numbers.ts
1228
- var zt = {
1931
+ var Pr = {
1229
1932
  "0150a855548f15a2af52ea057be53f5d": 1,
1230
1933
  "039826cf379b94afefe90b25c6045ca0": 1,
1231
1934
  "03a7e564b84662f4d957c51018e26244": 1,
@@ -20199,7 +20902,7 @@ var zt = {
20199
20902
  d16d29c923bd60c7b095b66c6058fe60: 1664,
20200
20903
  "1c14c2adf5cfda3220b2057160e10e91": 1665,
20201
20904
  e44c55ca1ac46ff46420686a466c9fc6: 1665
20202
- }, Bt = "\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", Vt = "\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", Ht = "\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", Ut = "\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", Wt = "\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", Gt = {
20905
+ }, Fr = "\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", Ir = "\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", Lr = "\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", Rr = "\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", zr = "\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", Br = {
20203
20906
  assnatetatagr: { bold: !0 },
20204
20907
  assnatetatagrgr: { bold: !0 },
20205
20908
  assnatetatatr: { bold: !0 },
@@ -20300,29 +21003,29 @@ var zt = {
20300
21003
  assnatxl67: { align: "center" },
20301
21004
  assnatenteteequilibre: { align: "center" }
20302
21005
  };
20303
- function Kt(e) {
20304
- let t = Object.keys(Gt).sort((e, t) => t.length - e.length);
20305
- for (let n of t) if (e.includes(n)) return Gt[n];
21006
+ function Vr(e) {
21007
+ let t = Object.keys(Br).sort((e, t) => t.length - e.length);
21008
+ for (let n of t) if (e.includes(n)) return Br[n];
20306
21009
  return null;
20307
21010
  }
20308
- function qt(e) {
20309
- return m.createHash("md5").update(e).digest("hex");
21011
+ function Hr(e) {
21012
+ return ye.createHash("md5").update(e).digest("hex");
20310
21013
  }
20311
- function Jt(e) {
21014
+ function Ur(e) {
20312
21015
  return e ? /font-weight\s*:\s*(bold|[6-9]00|1000)/i.test(e) || /font-family\s*:\s*[^;]*\bBold\b/i.test(e) : !1;
20313
21016
  }
20314
- function Yt(e) {
21017
+ function Wr(e) {
20315
21018
  return e ? /font-style\s*:\s*italic/i.test(e) || /font-family\s*:\s*[^;]*\bItalic\b/i.test(e) : !1;
20316
21019
  }
20317
- function Xt(e) {
21020
+ function Gr(e) {
20318
21021
  if (!e || !/vertical-align\s*:\s*super/i.test(e)) return !1;
20319
21022
  let t = e.match(/font-size\s*:\s*([\d.]+)pt/i);
20320
21023
  return !(t && parseFloat(t[1]) < 8);
20321
21024
  }
20322
- function Zt(e) {
21025
+ function Kr(e) {
20323
21026
  return e ? /vertical-align\s*:\s*sub/i.test(e) : !1;
20324
21027
  }
20325
- function Qt(e) {
21028
+ function qr(e) {
20326
21029
  if (!e) return;
20327
21030
  let t = [
20328
21031
  "width",
@@ -20357,15 +21060,15 @@ function Qt(e) {
20357
21060
  }
20358
21061
  return n.length > 0 ? n.join("; ") : void 0;
20359
21062
  }
20360
- function $t(e, t) {
21063
+ function Jr(e, t) {
20361
21064
  return !!(e && /text-align\s*:\s*center/i.test(e) || t && /center/i.test(t));
20362
21065
  }
20363
- function en(e) {
21066
+ function Yr(e) {
20364
21067
  if (!e) return null;
20365
21068
  let t = e.match(/text-align\s*:\s*(left|center|right|justify)/i);
20366
21069
  return t ? t[1].toLowerCase() : null;
20367
21070
  }
20368
- function tn(e) {
21071
+ function Xr(e) {
20369
21072
  if (!e) return null;
20370
21073
  for (let [t, n] of [
20371
21074
  [/assnat1Tome|assnatAN1PARTIE/i, 1],
@@ -20377,73 +21080,73 @@ function tn(e) {
20377
21080
  ]) if (t.test(e)) return n;
20378
21081
  return null;
20379
21082
  }
20380
- function nn(t, n = {}) {
20381
- let { keepAlignment: r = !0, removeEmptyParagraphs: i = !0, strictAlineas: a = !1 } = n, o = e(t, { xml: { decodeEntities: !1 } });
20382
- o("style, script, meta, link").remove(), o(".assnatHeader, .assnatFooter, .assnatHeaderLeft, .assnatHeaderandFooter").remove(), o(".assnatFARSautApres, .assnatFARSautAvant, .assnatFARSautPageNiv0, .assnatFARSautPageNiv1, .assnatFARSautPageNiv1PG").remove(), o(".assnatFARTT08Bleu").each((e, t) => {
20383
- let n = o(t).closest("table");
21083
+ function Zr(e, t = {}) {
21084
+ let { keepAlignment: n = !0, removeEmptyParagraphs: r = !0, strictAlineas: i = !1 } = t, a = u(e, { xml: { decodeEntities: !1 } });
21085
+ a("style, script, meta, link").remove(), a(".assnatHeader, .assnatFooter, .assnatHeaderLeft, .assnatHeaderandFooter").remove(), a(".assnatFARSautApres, .assnatFARSautAvant, .assnatFARSautPageNiv0, .assnatFARSautPageNiv1, .assnatFARSautPageNiv1PG").remove(), a(".assnatFARTT08Bleu").each((e, t) => {
21086
+ let n = a(t).closest("table");
20384
21087
  n.length > 0 && n.remove();
20385
- }), o("table").each((e, t) => {
20386
- let n = o(t), r = n.find("> tbody > tr, > tr");
21088
+ }), a("table").each((e, t) => {
21089
+ let n = a(t), r = n.find("> tbody > tr, > tr");
20387
21090
  if (r.length !== 1) return;
20388
21091
  let i = r.find("> td, > th");
20389
21092
  if (i.length !== 1) return;
20390
- let a = i.first();
20391
- if (a.find("h1, h2, h3, h4, h5, h6").length > 0) {
20392
- let e = a.attr("style") || "";
20393
- (e.includes("border-left:") || e.includes("border-bottom:")) && n.replaceWith(a.html() || "");
21093
+ let o = i.first();
21094
+ if (o.find("h1, h2, h3, h4, h5, h6").length > 0) {
21095
+ let e = o.attr("style") || "";
21096
+ (e.includes("border-left:") || e.includes("border-bottom:")) && n.replaceWith(o.html() || "");
20394
21097
  }
20395
- }), o("br[style*=\"page-break\"]").remove(), o("span[style*=\"position:absolute\"][style*=\"z-index:-65537\"]").each((e, t) => {
20396
- let n = o(t), r = n.find("img");
21098
+ }), a("br[style*=\"page-break\"]").remove(), a("span[style*=\"position:absolute\"][style*=\"z-index:-65537\"]").each((e, t) => {
21099
+ let n = a(t), r = n.find("img");
20397
21100
  if (r.length > 0) {
20398
21101
  let e = parseInt(r.attr("width") || "0", 10), t = parseInt(r.attr("height") || "0", 10);
20399
21102
  (e >= 50 || t >= 50) && n.remove();
20400
21103
  }
20401
- }), o("span[style*=\"position:absolute\"]").each((e, t) => {
20402
- let n = o(t), r = n.attr("style") || "", i = n.find("img");
21104
+ }), a("span[style*=\"position:absolute\"]").each((e, t) => {
21105
+ let n = a(t), r = n.attr("style") || "", i = n.find("img");
20403
21106
  if (i.length !== 0 && !(n.parents("del").length > 0 || n.find("del img").length > 0) && !(i.parent("del").length > 0)) {
20404
21107
  let e = i.attr();
20405
21108
  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")) {
20406
- let t = (e.src || "").match(/^data:image\/png;base64,(.+)$/), r = t ? qt(t[1]) : void 0, i = r ? ` data-image-hash="${r}"` : "";
21109
+ let t = (e.src || "").match(/^data:image\/png;base64,(.+)$/), r = t ? Hr(t[1]) : void 0, i = r ? ` data-image-hash="${r}"` : "";
20407
21110
  n.replaceWith(`<span class="alinea"${i}></span>`);
20408
21111
  return;
20409
21112
  }
20410
21113
  }
20411
- }), o("span[style*=\"position:absolute\"]").each((e, t) => {
20412
- let n = o(t), r = n.attr("style") || "", i = n.find("img");
21114
+ }), a("span[style*=\"position:absolute\"]").each((e, t) => {
21115
+ let n = a(t), r = n.attr("style") || "", i = n.find("img");
20413
21116
  if (i.length > 0 && n.children().length === 1 && r.includes("height:0pt")) {
20414
21117
  let e = parseInt(i.attr("width") || "0", 10), t = parseInt(i.attr("height") || "0", 10);
20415
21118
  e < 100 || t < 100 ? n.remove() : n.replaceWith(i);
20416
21119
  }
20417
- }), o("img").each((e, t) => {
20418
- let n = o(t), r = parseInt(n.attr("width") || "0", 10), i = parseInt(n.attr("height") || "0", 10);
21120
+ }), a("img").each((e, t) => {
21121
+ let n = a(t), r = parseInt(n.attr("width") || "0", 10), i = parseInt(n.attr("height") || "0", 10);
20419
21122
  r < 100 || i < 100 ? n.remove() : n.removeAttr("style").removeAttr("class");
20420
- }), o("span[style*=\"height:0pt\"]:not(.alinea)").each((e, t) => {
20421
- let n = o(t), r = n.text().trim();
21123
+ }), a("span[style*=\"height:0pt\"]:not(.alinea)").each((e, t) => {
21124
+ let n = a(t), r = n.text().trim();
20422
21125
  (!r || r === "\xA0") && n.remove();
20423
- }), o("span[style*=\"display:block\"][style*=\"position:absolute\"]:not(.alinea)").remove(), o("del").remove();
20424
- function s(e) {
20425
- let t = o(e), n = t.attr("style"), r = e.tagName?.toLowerCase() || "", i = Jt(n) || r === "b" || r === "strong", a = Yt(n) || r === "i" || r === "em", s = Xt(n) || r === "sup", c = Zt(n) || r === "sub", l = t.attr("class") || "";
20426
- return /bold/i.test(l) && (i = !0), /strongemphasis/i.test(l) ? i = !0 : /italic|emphasis/i.test(l) && (a = !0), {
21126
+ }), a("span[style*=\"display:block\"][style*=\"position:absolute\"]:not(.alinea)").remove(), a("del").remove();
21127
+ function o(e) {
21128
+ let t = a(e), n = t.attr("style"), r = e.tagName?.toLowerCase() || "", i = Ur(n) || r === "b" || r === "strong", o = Wr(n) || r === "i" || r === "em", s = Gr(n) || r === "sup", c = Kr(n) || r === "sub", l = t.attr("class") || "";
21129
+ return /bold/i.test(l) && (i = !0), /strongemphasis/i.test(l) ? i = !0 : /italic|emphasis/i.test(l) && (o = !0), {
20427
21130
  bold: i,
20428
- italic: a,
21131
+ italic: o,
20429
21132
  sup: s,
20430
21133
  sub: c
20431
21134
  };
20432
21135
  }
20433
- function c(e, t) {
21136
+ function s(e, t) {
20434
21137
  let n = e;
20435
21138
  return t.sup ? n = `<sup>${n}</sup>` : t.sub && (n = `<sub>${n}</sub>`), t.italic && (n = `<em>${n}</em>`), t.bold && (n = `<strong>${n}</strong>`), n;
20436
21139
  }
20437
- let l = o("span").length;
20438
- for (; l > 0;) {
20439
- o("span").each((e, t) => {
20440
- let n = o(t), r = n.attr("style") || "", i = n.attr("class") || "", a = s(t), l = a.bold || a.italic || a.sup || a.sub, u = /vertical-align\s*:\s*super/i.test(r) && /font-size\s*:\s*([\d.]+)pt/i.test(r) && parseFloat((r.match(/font-size\s*:\s*([\d.]+)pt/i) || ["", "12"])[1]) < 8, d = i && !/^assnat/i.test(i), f = n.attr("id");
21140
+ let c = a("span").length;
21141
+ for (; c > 0;) {
21142
+ a("span").each((e, t) => {
21143
+ let n = a(t), r = n.attr("style") || "", i = n.attr("class") || "", c = o(t), l = c.bold || c.italic || c.sup || c.sub, u = /vertical-align\s*:\s*super/i.test(r) && /font-size\s*:\s*([\d.]+)pt/i.test(r) && parseFloat((r.match(/font-size\s*:\s*([\d.]+)pt/i) || ["", "12"])[1]) < 8, d = i && !/^assnat/i.test(i), f = n.attr("id");
20441
21144
  if (u) {
20442
21145
  let e = n.html() || "";
20443
21146
  n.replaceWith(e);
20444
21147
  } else if (l) {
20445
21148
  let e = n.html() || "";
20446
- n.replaceWith(c(e, a));
21149
+ n.replaceWith(s(e, c));
20447
21150
  } else if (d) n.removeAttr("style");
20448
21151
  else if (f) n.removeAttr("style").removeAttr("class");
20449
21152
  else {
@@ -20451,76 +21154,76 @@ function nn(t, n = {}) {
20451
21154
  e.trim() === "" && e.length > 0 ? n.replaceWith(" ") : n.replaceWith(e);
20452
21155
  }
20453
21156
  });
20454
- let e = o("span").length;
20455
- if (e >= l) break;
20456
- l = e;
21157
+ let e = a("span").length;
21158
+ if (e >= c) break;
21159
+ c = e;
20457
21160
  }
20458
- for (o("p").each((e, t) => {
20459
- let n = o(t), i = n.attr("class") || "", a = n.attr("style"), s = tn(i);
21161
+ for (a("p").each((e, t) => {
21162
+ let r = a(t), i = r.attr("class") || "", o = r.attr("style"), s = Xr(i);
20460
21163
  if (i.includes("assnatFARCouvTitreD")) {
20461
- let e = n.html() || "";
20462
- n.replaceWith(`<p class="cover-subtitle">${e}</p>`);
21164
+ let e = r.html() || "";
21165
+ r.replaceWith(`<p class="cover-subtitle">${e}</p>`);
20463
21166
  return;
20464
21167
  }
20465
21168
  if (i.includes("assnatFARCouvTitre")) {
20466
- let e = n.html() || "";
20467
- n.replaceWith(`<p class="cover-title">${e}</p>`);
21169
+ let e = r.html() || "";
21170
+ r.replaceWith(`<p class="cover-title">${e}</p>`);
20468
21171
  return;
20469
21172
  }
20470
21173
  if (i.includes("assnatFPFprem")) {
20471
- let e = n.html() || "";
20472
- n.replaceWith(`<p class="cover-info">${e}</p>`);
21174
+ let e = r.html() || "";
21175
+ r.replaceWith(`<p class="cover-info">${e}</p>`);
20473
21176
  return;
20474
21177
  }
20475
21178
  if (i.includes("assnatFARCouvAnnee")) {
20476
- let e = n.html() || "";
20477
- n.replaceWith(`<p class="cover-year">${e}</p>`);
21179
+ let e = r.html() || "";
21180
+ r.replaceWith(`<p class="cover-year">${e}</p>`);
20478
21181
  return;
20479
21182
  }
20480
21183
  if (i.includes("assnatFPFexpogentitre1")) {
20481
- let e = n.html() || "";
20482
- n.replaceWith(`<p class="expose-motifs-titre">${e}</p>`);
21184
+ let e = r.html() || "";
21185
+ r.replaceWith(`<p class="expose-motifs-titre">${e}</p>`);
20483
21186
  return;
20484
21187
  }
20485
21188
  if (i.includes("assnatFPFexpogentexte")) {
20486
- n.removeAttr("style").attr("class", "expose-motifs-text");
21189
+ r.removeAttr("style").attr("class", "expose-motifs-text");
20487
21190
  return;
20488
21191
  }
20489
- let c = n.text().trim().startsWith("«");
21192
+ let c = r.text().trim().startsWith("«");
20490
21193
  if (s && !c) {
20491
- let e = o(`<h${s}>${n.html() || ""}</h${s}>`);
20492
- r && $t(a, i) && e.attr("align", "center"), n.replaceWith(e);
21194
+ let e = a(`<h${s}>${r.html() || ""}</h${s}>`);
21195
+ n && Jr(o, i) && e.attr("align", "center"), r.replaceWith(e);
20493
21196
  } else {
20494
- let e = Kt(i), t;
20495
- if (r) {
20496
- let n = en(a);
21197
+ let e = Vr(i), t;
21198
+ if (n) {
21199
+ let n = Yr(o);
20497
21200
  n && n !== "justify" && n !== "left" ? t = n : e?.align && (t = e.align);
20498
21201
  }
20499
- if (n.removeAttr("style").removeAttr("class"), t && n.attr("align", t), e?.bold) {
20500
- let e = n.html() || "";
20501
- e.trim().startsWith("<strong>") || n.html(`<strong>${e}</strong>`);
21202
+ if (r.removeAttr("style").removeAttr("class"), t && r.attr("align", t), e?.bold) {
21203
+ let e = r.html() || "";
21204
+ e.trim().startsWith("<strong>") || r.html(`<strong>${e}</strong>`);
20502
21205
  }
20503
21206
  }
20504
- }), o("h1, h2, h3, h4, h5, h6").each((e, t) => {
20505
- let n = o(t), i = n.attr("style"), a = n.attr("class");
20506
- r && $t(i, a) ? (n.removeAttr("style").removeAttr("class"), n.attr("align", "center")) : n.removeAttr("style").removeAttr("class");
20507
- }), o("a").each((e, t) => {
20508
- let n = o(t), r = n.attr("href"), i = n.attr("id"), a = { ...t.attribs || {} };
20509
- for (let e of Object.keys(a)) e !== "href" && e !== "id" && n.removeAttr(e);
21207
+ }), a("h1, h2, h3, h4, h5, h6").each((e, t) => {
21208
+ let r = a(t), i = r.attr("style"), o = r.attr("class");
21209
+ n && Jr(i, o) ? (r.removeAttr("style").removeAttr("class"), r.attr("align", "center")) : r.removeAttr("style").removeAttr("class");
21210
+ }), a("a").each((e, t) => {
21211
+ let n = a(t), r = n.attr("href"), i = n.attr("id"), o = { ...t.attribs || {} };
21212
+ for (let e of Object.keys(o)) e !== "href" && e !== "id" && n.removeAttr(e);
20510
21213
  if (!r && !i) n.replaceWith(n.html() || "");
20511
21214
  else if (!r && i) {
20512
21215
  let e = n.html() || "";
20513
21216
  n.replaceWith(`<span id="${i}">${e}</span>`);
20514
21217
  }
20515
- }); o("div").length > 0;) o("div").each((e, t) => {
20516
- let n = o(t), r = n.html() || "";
21218
+ }); a("div").length > 0;) a("div").each((e, t) => {
21219
+ let n = a(t), r = n.html() || "";
20517
21220
  n.replaceWith(r);
20518
21221
  });
20519
- o(".expose-motifs-titre").each((e, t) => {
20520
- let n = o(t), r = [], i = n.next();
21222
+ a(".expose-motifs-titre").each((e, t) => {
21223
+ let n = a(t), r = [], i = n.next();
20521
21224
  for (; i.length > 0;) if (i.is("table") && i.find(".expose-motifs-text").length > 0) {
20522
21225
  i.find(".expose-motifs-text").each((e, t) => {
20523
- r.push(o(t).clone());
21226
+ r.push(a(t).clone());
20524
21227
  });
20525
21228
  let e = i;
20526
21229
  i = i.next(), e.remove();
@@ -20534,43 +21237,43 @@ function nn(t, n = {}) {
20534
21237
  i = i.next(), e.remove();
20535
21238
  } else break;
20536
21239
  if (r.length > 0) {
20537
- let e = o("<div class=\"expose-motifs\"></div>");
21240
+ let e = a("<div class=\"expose-motifs\"></div>");
20538
21241
  r.forEach((t) => {
20539
21242
  t.removeClass("expose-motifs-text"), e.append(t);
20540
21243
  }), n.after(e);
20541
21244
  }
20542
- }), o("br").each((e, t) => {
20543
- o(t).removeAttr("style").removeAttr("class");
20544
- }), o("table, tr, td, th, thead, tbody, tfoot").each((e, t) => {
20545
- let n = o(t), r = Qt(n.attr("style"));
21245
+ }), a("br").each((e, t) => {
21246
+ a(t).removeAttr("style").removeAttr("class");
21247
+ }), a("table, tr, td, th, thead, tbody, tfoot").each((e, t) => {
21248
+ let n = a(t), r = qr(n.attr("style"));
20546
21249
  n.removeAttr("style").removeAttr("class"), r && n.attr("style", r);
20547
- }), o("td, th").each((e, t) => {
20548
- let n = o(t), r = n.children();
21250
+ }), a("td, th").each((e, t) => {
21251
+ let n = a(t), r = n.children();
20549
21252
  if (r.length === 1 && r.first().is("p")) {
20550
- let e = r.first(), t = n.html() || "", i = o.html(e);
21253
+ let e = r.first(), t = n.html() || "", i = a.html(e);
20551
21254
  if (t.trim() === i.trim()) {
20552
21255
  let t = e.attr("align"), r = e.attr("id");
20553
21256
  n.html(e.html() || ""), t && !n.attr("align") && n.attr("align", t), r && !n.attr("id") && n.attr("id", r);
20554
21257
  }
20555
21258
  }
20556
- }), o("ol, ul").each((e, t) => {
20557
- let n = o(t), r = n.attr("start");
21259
+ }), a("ol, ul").each((e, t) => {
21260
+ let n = a(t), r = n.attr("start");
20558
21261
  if (n.removeAttr("style").removeAttr("class"), r) {
20559
21262
  let e = parseInt(r, 10);
20560
21263
  !isNaN(e) && e > 1 && n.attr("style", `counter-reset: list-counter ${e - 1}`), n.attr("start", r);
20561
21264
  }
20562
- }), o("li").each((e, t) => {
20563
- let n = o(t), r = en(n.attr("style"));
21265
+ }), a("li").each((e, t) => {
21266
+ let n = a(t), r = Yr(n.attr("style"));
20564
21267
  n.removeAttr("style").removeAttr("class"), r === "center" && n.attr("style", "text-align: center");
20565
- let i = n.html() || "", a = i.replace(/^(\s|&#xa0;|&#160;|\u00a0)+/, "");
20566
- a !== i && n.html(a);
20567
- }), rn(o), an(o, a);
20568
- let u = o("body").html() || o.html(), d = u.includes("class=\"alinea"), f = o("ol").length > 0, p = o("h1, h2, h3, h4, h5, h6").length > 0, m = u.includes("class=\"expose-motifs"), h = u.includes("class=\"cover-title\"") || u.includes("class=\"cover-subtitle\"") || u.includes("class=\"cover-info\"") || u.includes("class=\"cover-year\""), g = "";
20569
- h && (g += Wt), p && (g += Vt), m && (g += Ht), d && (g += Bt), f && (g += Ut);
20570
- let _ = g ? `<style>${g}</style>\n${u}` : u;
20571
- 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"), i && (_ = _.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, ""), _ = on(_), _ = _.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(), _;
21268
+ let i = n.html() || "", o = i.replace(/^(\s|&#xa0;|&#160;|\u00a0)+/, "");
21269
+ o !== i && n.html(o);
21270
+ }), Qr(a), $r(a, i);
21271
+ let l = a("body").html() || a.html(), d = l.includes("class=\"alinea"), f = a("ol").length > 0, p = a("h1, h2, h3, h4, h5, h6").length > 0, m = l.includes("class=\"expose-motifs"), h = l.includes("class=\"cover-title\"") || l.includes("class=\"cover-subtitle\"") || l.includes("class=\"cover-info\"") || l.includes("class=\"cover-year\""), g = "";
21272
+ h && (g += zr), p && (g += Ir), m && (g += Lr), d && (g += Fr), f && (g += Rr);
21273
+ let _ = g ? `<style>${g}</style>\n${l}` : l;
21274
+ 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, ""), _ = ei(_), _ = _.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(), _;
20572
21275
  }
20573
- function rn(e) {
21276
+ function Qr(e) {
20574
21277
  e("span[id]").each((t, n) => {
20575
21278
  let r = e(n), i = r.attr("id"), a = n.attribs || {}, o = Object.keys(a);
20576
21279
  if (o.length !== 1 || o[0] !== "id") return;
@@ -20593,13 +21296,13 @@ function rn(e) {
20593
21296
  l.trim() === u.trim() && (s.attr("id", i), r.replaceWith(r.html() || ""));
20594
21297
  });
20595
21298
  }
20596
- function an(e, t = !1) {
21299
+ function $r(e, t = !1) {
20597
21300
  let n = e("body");
20598
21301
  if (n.length === 0) return;
20599
21302
  let r = n.find("span.alinea[data-image-hash]"), i = -1;
20600
21303
  r.each((n, r) => {
20601
21304
  let a = e(r), o = a.attr("data-image-hash"), s;
20602
- if (o && zt[o] !== void 0 && (s = zt[o]), s === void 0) {
21305
+ if (o && Pr[o] !== void 0 && (s = Pr[o]), s === void 0) {
20603
21306
  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".`);
20604
21307
  a.remove();
20605
21308
  return;
@@ -20611,11 +21314,11 @@ function an(e, t = !1) {
20611
21314
  i = s, a.attr("data-alinea", String(s)), a.text(String(s)), a.removeAttr("data-image-hash");
20612
21315
  });
20613
21316
  }
20614
- function on(e) {
21317
+ function ei(e) {
20615
21318
  let t = e;
20616
21319
  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;
20617
21320
  }
20618
- function sn(e, t = {}) {
21321
+ function ti(e, t = {}) {
20619
21322
  return `<!DOCTYPE html>
20620
21323
  <html lang="fr">
20621
21324
  <head>
@@ -20623,33 +21326,33 @@ function sn(e, t = {}) {
20623
21326
  <title>Document simplifié</title>
20624
21327
  </head>
20625
21328
  <body>
20626
- ${nn(e, t)}
21329
+ ${Zr(e, t)}
20627
21330
  </body>
20628
21331
  </html>`;
20629
21332
  }
20630
21333
  //#endregion
20631
21334
  //#region src/lib/server/text_parsers/transformers.ts
20632
- function Q(e, t) {
21335
+ function ni(e, t) {
20633
21336
  let n = "transformation_", r = {};
20634
- for (let e of g.readdirSync(t).toSorted()) if (e.startsWith(n) && e.endsWith(".json")) {
21337
+ for (let e of A.readdirSync(t).toSorted()) if (e.startsWith(n) && e.endsWith(".json")) {
20635
21338
  let i = e.slice(15, -5), a = i.split(".").map((e) => parseInt(e) - 1), o = r;
20636
21339
  for (let e of a.slice(1)) {
20637
21340
  let t = o.transformations ??= [];
20638
21341
  for (; e >= t.length;) t.push({});
20639
21342
  o = t[e];
20640
21343
  }
20641
- o.output = g.readFileSync(_.join(t, `${n}${i}.html`), { encoding: "utf-8" });
20642
- let { sourceMap: s, title: c } = g.readJsonSync(_.join(t, e), { encoding: "utf-8" });
21344
+ o.output = A.readFileSync(j.join(t, `${n}${i}.html`), { encoding: "utf-8" });
21345
+ let { sourceMap: s, title: c } = A.readJsonSync(j.join(t, e), { encoding: "utf-8" });
20643
21346
  o.sourceMap = s ?? [], o.title = c;
20644
21347
  }
20645
- return cn(r, e), r;
21348
+ return ri(r, e), r;
20646
21349
  }
20647
- function cn(e, t) {
20648
- if (e.input = t, e.transformations !== void 0) for (let n of e.transformations) cn(n, t), t = n.output;
21350
+ function ri(e, t) {
21351
+ if (e.input = t, e.transformations !== void 0) for (let n of e.transformations) ri(n, t), t = n.output;
20649
21352
  return t;
20650
21353
  }
20651
- function $(e, t, n = "1") {
20652
- if (g.ensureDirSync(t), e.transformations === void 0) g.writeJsonSync(_.join(t, `transformation_${n}.json`), {
21354
+ function ii(e, t, n = "1") {
21355
+ if (A.ensureDirSync(t), e.transformations === void 0) A.writeJsonSync(j.join(t, `transformation_${n}.json`), {
20653
21356
  sourceMap: e.sourceMap,
20654
21357
  title: e.title
20655
21358
  }, {
@@ -20657,72 +21360,72 @@ function $(e, t, n = "1") {
20657
21360
  spaces: 2
20658
21361
  });
20659
21362
  else {
20660
- g.writeJsonSync(_.join(t, `transformation_${n}.json`), { title: e.title }, {
21363
+ A.writeJsonSync(j.join(t, `transformation_${n}.json`), { title: e.title }, {
20661
21364
  encoding: "utf-8",
20662
21365
  spaces: 2
20663
21366
  });
20664
- for (let [r, i] of e.transformations.entries()) $(i, t, `${n}.${r + 1}`);
21367
+ for (let [r, i] of e.transformations.entries()) ii(i, t, `${n}.${r + 1}`);
20665
21368
  }
20666
- e.output !== void 0 && g.writeFileSync(_.join(t, `transformation_${n}.html`), e.output, { encoding: "utf-8" });
21369
+ e.output !== void 0 && A.writeFileSync(j.join(t, `transformation_${n}.html`), e.output, { encoding: "utf-8" });
20667
21370
  }
20668
21371
  //#endregion
20669
21372
  //#region src/lib/server/linkers/html.ts
20670
- async function ln({ canutesDb: e, legiResolver: t, date: n, defaultTextId: r, htmlFilePath: i, htmlTransformationsInputDir: c, htmlTransformationsOutputDir: l, htmlWithLinksFilePath: u, htmlWithLinksOrReferencesFilePath: d, htmlWithLinksTransformationsOutputDir: f, htmlWithReferencesFilePath: p, linkBaseUrl: m, linkType: h, logIgnoredReferencesTypes: _, logPartialReferences: v, logReferences: y, referredLegifranceTextsInfosFilePath: b }) {
20671
- let x = t ?? (e === void 0 ? void 0 : new o(e));
20672
- if (x === void 0) throw Error("A Canutes database or legal resolver is required");
20673
- let S = await g.readFile(i, { encoding: "utf-8" }), C;
20674
- c === void 0 ? (C = s({ removeAWithHref: !0 })(S), l !== void 0 && $(C, l)) : C = Q(S, c);
20675
- let w = [];
20676
- u !== void 0 && w.push("links"), d !== void 0 && w.push("links_or_references"), p !== void 0 && w.push("references");
20677
- let { outputByType: T, referredLegifranceTextCountByCid: E } = await a({
20678
- legiResolver: x,
21373
+ async function ai({ 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: g, referredLegifranceTextsInfosFilePath: _ }) {
21374
+ let ee = t ?? (e === void 0 ? void 0 : new h(e));
21375
+ if (ee === void 0) throw Error("A Canutes database or legal resolver is required");
21376
+ let v = await A.readFile(i, { encoding: "utf-8" }), y;
21377
+ a === void 0 ? (y = le({ removeAWithHref: !0 })(v), o !== void 0 && ii(y, o)) : y = ni(v, a);
21378
+ let b = [];
21379
+ s !== void 0 && b.push("links"), c !== void 0 && b.push("links_or_references"), u !== void 0 && b.push("references");
21380
+ let { outputByType: te, referredLegifranceTextCountByCid: ne } = await re({
21381
+ legiResolver: ee,
20679
21382
  date: n,
20680
21383
  defaultTextId: r,
20681
- htmlTransformation: C,
20682
- inputHtml: S,
20683
- linkBaseUrl: m,
20684
- linkType: h,
20685
- logIgnoredReferencesTypes: _,
20686
- logPartialReferences: v,
20687
- logReferences: y,
20688
- outputTypes: w,
20689
- referredLegifranceTextsInfos: b !== void 0
20690
- }), D = {};
20691
- u !== void 0 && (D.links = u), d !== void 0 && (D.links_or_references = d), p !== void 0 && (D.references = p);
20692
- for (let [e, t] of Object.entries(T)) {
20693
- let n = D[e];
20694
- n !== void 0 && await g.writeFile(n, t.html, { encoding: "utf-8" });
21384
+ htmlTransformation: y,
21385
+ inputHtml: v,
21386
+ linkBaseUrl: d,
21387
+ linkType: f,
21388
+ logIgnoredReferencesTypes: p,
21389
+ logPartialReferences: m,
21390
+ logReferences: g,
21391
+ outputTypes: b,
21392
+ referredLegifranceTextsInfos: _ !== void 0
21393
+ }), x = {};
21394
+ s !== void 0 && (x.links = s), c !== void 0 && (x.links_or_references = c), u !== void 0 && (x.references = u);
21395
+ for (let [e, t] of Object.entries(te)) {
21396
+ let n = x[e];
21397
+ n !== void 0 && await A.writeFile(n, t.html, { encoding: "utf-8" });
20695
21398
  }
20696
- T.links !== void 0 && f !== void 0 && $(s()(T.links.html), f), b !== void 0 && await g.writeJson(b, E, {
21399
+ te.links !== void 0 && l !== void 0 && ii(le()(te.links.html), l), _ !== void 0 && await A.writeJson(_, ne, {
20697
21400
  encoding: "utf-8",
20698
21401
  spaces: 2
20699
21402
  });
20700
21403
  }
20701
21404
  //#endregion
20702
21405
  //#region src/lib/server/tables_of_contents.ts
20703
- async function un(e, n, r, i) {
20704
- let a = Q(await g.readFile(e, { encoding: "utf-8" }), n), o = a.output, s = new p(o), c = await g.readJson(r, { encoding: "utf-8" });
20705
- for await (let e of t({
20706
- context: s,
20707
- tableOfContents: c,
20708
- transformation: a
21406
+ async function oi(e, t, n, r) {
21407
+ let i = ni(await A.readFile(e, { encoding: "utf-8" }), t), a = i.output, o = new C(a), s = await A.readJson(n, { encoding: "utf-8" });
21408
+ for await (let e of f({
21409
+ context: o,
21410
+ tableOfContents: s,
21411
+ transformation: i
20709
21412
  }));
20710
- await g.writeJson(i, c, {
21413
+ await A.writeJson(r, s, {
20711
21414
  encoding: "utf-8",
20712
21415
  spaces: 2
20713
21416
  });
20714
21417
  }
20715
- async function dn(e, t, n) {
20716
- let i = Q(await g.readFile(e, { encoding: "utf-8" }), t).output, a = r(i);
20717
- await g.writeJson(n, a, {
21418
+ async function si(e, t, n) {
21419
+ let r = ni(await A.readFile(e, { encoding: "utf-8" }), t).output, i = b(r);
21420
+ await A.writeJson(n, i, {
20718
21421
  encoding: "utf-8",
20719
21422
  spaces: 2
20720
21423
  });
20721
21424
  }
20722
21425
  //#endregion
20723
21426
  //#region src/lib/server/legi/resolvers.ts
20724
- function fn({ canutesDb: e }) {
20725
- return new o(e);
21427
+ function ci({ canutesDb: e }) {
21428
+ return new h(e);
20726
21429
  }
20727
21430
  //#endregion
20728
- export { f as LegiResolver, ln as addLinksOrReferencesToHtmlFile, un as addPositionsToTableOfContentsFile, d as buildAndInstallTextTitlesInfos, l as buildTextTitlesInfos, fn as createLegiResolver, x as extractAssembleeAmendmentSearchItems, Ct as extractAssembleeExposesDesMotifs, Ot as extractSenatAmendmentSearchItems, S as hashAssembleeAmendmentSearchItem, Tt as hashAssembleeSearchItem, kt as hashSenatAmendmentSearchItem, Nt as hashSenatSearchItem, Rt as isAkomaNtosoXml, Et as isoDateFromAssembleeDocument, bt as linkAkomaNtosoBillRaw, Ie as linkAssembleeBillRaw, yt as parseAkomaNtosoBillRaw, Fe as parseAssembleeBillRaw, wt as parseAssembleeDocumentSearchContent, Mt as parseSenatDocumentSearchContent, Q as readTransformation, ht as renderAkomaNtosoBillRaw, Lt as resolveSenatAkomaNtosoSource, dn as simplifiedHtmlBillFileToTableOfContentsFile, nn as simplifyWordHtml, sn as simplifyWordHtmlToDocument, $ as writeTransformation };
21431
+ export { ve as LegiResolver, ai as addLinksOrReferencesToHtmlFile, oi as addPositionsToTableOfContentsFile, _e as buildAndInstallTextTitlesInfos, fe as buildTextTitlesInfos, ci as createLegiResolver, Se as extractAssembleeAmendmentSearchItems, xn as extractAssembleeExposesDesMotifs, En as extractSenatAmendmentSearchItems, Ce as hashAssembleeAmendmentSearchItem, Cn as hashAssembleeSearchItem, Dn as hashSenatAmendmentSearchItem, Dr as hashSenatSearchItem, Nr as isAkomaNtosoXml, wn as isoDateFromAssembleeDocument, _n as linkAkomaNtosoBillRaw, Ot as linkAssembleeBillRaw, gn as parseAkomaNtosoBillRaw, wr as parseAmendment, Dt as parseAssembleeBillRaw, Sn as parseAssembleeDocumentSearchContent, Er as parseSenatDocumentSearchContent, ni as readTransformation, fn as renderAkomaNtosoBillRaw, Mr as resolveSenatAkomaNtosoSource, si as simplifiedHtmlBillFileToTableOfContentsFile, Zr as simplifyWordHtml, ti as simplifyWordHtmlToDocument, ii as writeTransformation };