@tricoteuses/tisseuse 0.13.12 → 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 +1264 -564
  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));
68
71
  }
69
- function O(e) {
70
- return D(e).replace(/[‐‑‒–—]/gu, "-").replace(/\s*\.\s*/gu, ".");
72
+ function Ee(e) {
73
+ return `_TocArt${Te(e).replace(/\s+/gu, "")}`;
71
74
  }
72
- function ee(e) {
73
- return O(e).replace(/[^a-z0-9]+/gu, "-").replace(/^-|-$/gu, "");
75
+ function De(e, t) {
76
+ return e(t).closest(".assnatTOC6,.assnatTOC5,.assnatTOC4").length > 0;
74
77
  }
75
- function te(e) {
78
+ function Oe(e) {
79
+ return P(e).replace(/[‐‑‒–—]/gu, "-").replace(/\s*\.\s*/gu, ".");
80
+ }
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 A(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 se(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 = A(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 = A(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 se(e) {
162
171
  }
163
172
  return i;
164
173
  }
165
- function ce(e) {
166
- let t = se(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 j(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 M(e) {
181
+ function F(e) {
173
182
  return e?.type === "tag";
174
183
  }
175
- function N(e, t) {
184
+ function Ve(e, t) {
176
185
  return e.html(t) ?? "";
177
186
  }
178
- function le(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,111 +192,170 @@ function le(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
- ...ue(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 ue(e, t, n) {
197
- let r = de(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 de(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 (!M(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 (M(i) && e.contains(i, n)) return r + de(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 fe(e, t) {
213
- return t.map((t) => E(e(t).text())).filter(Boolean).join("\n");
214
- }
215
- function P(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 pe(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 F(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 me(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 M(r) && M(n) && e(n).parents("table").get(0) === r ? r : M(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 I(e) {
249
- return `_TocArt${(e.num ?? e.label.replace(/^Article\s+/iu, "")).replace(/\s*\([^)]*\)\s*$/u, "").replace(/\s+/gu, "")}`;
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
+ }));
250
258
  }
251
- function L(e) {
259
+ function Xe(e) {
252
260
  let t = [], n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set();
253
261
  e("a[id], span[id], h1[id], h2[id], h3[id], h4[id], h5[id], h6[id]").each((i, a) => {
254
- let o = P(E(e(a).text()));
262
+ if (De(e, a)) return;
263
+ let o = v(N(e(a).text()));
255
264
  if (!o) return;
256
265
  let s = e(a).attr("id");
257
266
  if (!s || r.has(s)) return;
258
- let c = me(e, a);
259
- n.has(c) || (r.add(s), n.add(c), t.push({
267
+ let c = Je(e, a);
268
+ Ye(t, n, r, {
260
269
  id: s,
261
270
  ...o,
262
271
  element: a,
263
272
  container: c
264
- }));
273
+ });
265
274
  }), e("h1:not([id]), h2:not([id]), h3:not([id]), h4:not([id]), h5:not([id]), h6:not([id])").each((i, a) => {
266
275
  if (n.has(a)) return;
267
- let o = P(E(e(a).text()));
268
- if (!o) return;
269
- let s = I(o);
270
- r.has(s) || (r.add(s), n.add(a), t.push({
271
- id: s,
276
+ let o = v(N(e(a).text()));
277
+ o && Ye(t, n, r, {
272
278
  ...o,
273
279
  element: a,
274
280
  container: a
275
- }));
281
+ });
276
282
  });
277
283
  let i = e("body *");
278
284
  return t.sort((e, t) => i.index(e.container) - i.index(t.container)), t;
279
285
  }
280
- function he(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) {
281
349
  let t = e.next;
282
350
  for (; t !== null;) {
283
- if (M(t)) return t;
351
+ if (F(t)) return t;
284
352
  t = t.next;
285
353
  }
286
354
  return null;
287
355
  }
288
- function ge(e, t, n) {
356
+ function it(e, t, n) {
289
357
  let r = [t.container], i = n?.container;
290
- for (let e = he(t.container); e !== null && e !== i; e = he(e)) r.push(e);
358
+ for (let e = rt(t.container); e !== null && e !== i; e = rt(e)) r.push(e);
291
359
  if (r.length > 1) return r;
292
360
  let a = e("body *").index(t.container), o = i ? e("body *").index(i) : -1;
293
361
  return e("body > *").get().filter((t) => {
@@ -295,7 +363,7 @@ function ge(e, t, n) {
295
363
  return n >= a && (o === -1 || n < o);
296
364
  });
297
365
  }
298
- function _e(e, t) {
366
+ function at(e, t) {
299
367
  let n = [], r = /* @__PURE__ */ new Set();
300
368
  for (let i of t) {
301
369
  let t = "p,li,table", a = e(i).is(t) ? [i] : e(i).find(t).get();
@@ -303,98 +371,96 @@ function _e(e, t) {
303
371
  }
304
372
  return n;
305
373
  }
306
- function ve(e, t, n) {
374
+ function ot(e, t, n) {
307
375
  let r = [], i = !1;
308
- for (let a of _e(e, n)) {
309
- let n = E(e(a).text());
376
+ for (let a of at(e, n)) {
377
+ let n = N(e(a).text());
310
378
  if (!n) continue;
311
- T.test(n) && (i = !0);
312
- let o = i ? "noise" : pe(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}`;
313
381
  e(a).attr("data-pjl-parsed-article-id", t), e(a).attr("data-pjl-parsed-block-id", s), r.push({
314
382
  id: s,
315
383
  articleId: t,
316
384
  kind: o,
317
- links: le(e, a),
385
+ links: He(e, a),
318
386
  text: n,
319
- html: N(e, a)
387
+ html: Ve(e, a)
320
388
  });
321
389
  }
322
390
  return r;
323
391
  }
324
- function ye(e, t) {
392
+ function st(e, t) {
325
393
  if (t.length === 0) return e;
326
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>`;
327
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}`;
328
396
  }
329
- function be(t) {
330
- let n = e(t);
331
- for (let e of L(n)) {
332
- let t = I(e), r = n(e.element), i = r.attr("id");
333
- i !== t && (i?.startsWith("_Toc") && !xe(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));
334
402
  }
335
- let r = L(n);
336
- for (let [e, t] of r.entries()) {
337
- let i = ge(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());
338
406
  for (let e of i) {
339
- let r = n(e).attr("data-alinea")?.trim();
340
- if (!r) continue;
341
- let i = `${t.id}-alinea-${r.replace(/\s+/gu, "")}`;
342
- if (xe(n, i, e)) continue;
343
- let a = n(e).attr("id");
344
- 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);
345
413
  }
346
414
  }
347
- return n.html();
415
+ return t.html();
348
416
  }
349
- function xe(e, t, n) {
417
+ function lt(e, t, n) {
350
418
  for (let r of e("[id]").get()) if (r !== n && e(r).attr("id") === t) return !0;
351
419
  return !1;
352
420
  }
353
- function Se(e, t) {
354
- let n = j("sourceText" in t ? t.sourceText : "");
421
+ function ut(e, t) {
422
+ let n = Be("sourceText" in t ? t.sourceText : "");
355
423
  if (n) return e.filter((e) => e.kind === "directive_candidate").find((e) => {
356
- let t = j(e.text);
424
+ let t = Be(e.text);
357
425
  return t.length > 0 && (n.includes(t) || t.includes(n));
358
426
  });
359
427
  }
360
- function Ce(e, t) {
428
+ function dt(e, t) {
361
429
  if (t) return t.blockIds.map((t) => e.get(t)).find((e) => e?.kind === "directive_candidate");
362
430
  }
363
- function we(e) {
431
+ function ft(e) {
364
432
  return e?.links.filter((e) => !e.insideFrenchQuotes && (e.type === "article" || e.type === "division")).map((e) => e.id) ?? [];
365
433
  }
366
- var Te = [
367
- /^([IVXLCDM]+)\s*[.).]?\s*[–—-]/iu,
368
- /^(\d+°)\s+/u,
369
- /^([a-z])\)\s+/iu,
370
- /^([ivxlcdm]+)\)\s+/iu
371
- ];
372
- function Ee(e) {
373
- let t = E(e);
434
+ function pt(e) {
435
+ let t = N(e);
374
436
  if (!t) return;
375
- let n = Te.findIndex((e) => e.test(t));
376
- 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;
377
439
  }
378
- function De(e) {
440
+ function mt(e) {
379
441
  let t = /* @__PURE__ */ new Map(), n = [];
380
442
  for (let r of e) {
381
- let e = Ee(r.text);
443
+ let e = pt(r.text);
382
444
  if (e === void 0) {
383
- t.set(r.id, [...n, r]);
445
+ t.set(r.id, [...n.map((e) => e.block), r]);
384
446
  continue;
385
447
  }
386
- 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
+ });
387
453
  }
388
454
  return t;
389
455
  }
390
- function Oe(e, t) {
456
+ function ht(e, t) {
391
457
  let n = [], r = /* @__PURE__ */ new Set();
392
458
  for (let i of [...e ?? [], ...t]) i !== void 0 && (r.has(i.id) || (r.add(i.id), n.push(i)));
393
459
  return n;
394
460
  }
395
- function ke(e, t, n) {
461
+ function gt(e, t, n) {
396
462
  if (!t) return;
397
- let r = Oe(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));
398
464
  if (r.length === 0) return;
399
465
  let i = r.map((e) => e.id);
400
466
  if (i.length === t.blockIds.length && i.every((e, n) => e === t.blockIds[n])) return;
@@ -409,7 +475,7 @@ function ke(e, t, n) {
409
475
  }
410
476
  };
411
477
  }
412
- function Ae(e) {
478
+ function _t(e) {
413
479
  let t = [], n = 0;
414
480
  for (let r of e.blocks) {
415
481
  let i = e.directiveText.indexOf(r.text, n);
@@ -423,7 +489,7 @@ function Ae(e) {
423
489
  }
424
490
  return t;
425
491
  }
426
- function je(e, t, n) {
492
+ function vt(e, t, n) {
427
493
  let { start: r, stop: i } = n.sourcePosition, a = t.filter((e) => e.stop >= r && e.start <= i);
428
494
  if (a.length === 0) return;
429
495
  let o = a[0], s = a[a.length - 1], c = o.start, l = s.stop;
@@ -437,7 +503,7 @@ function je(e, t, n) {
437
503
  }
438
504
  };
439
505
  }
440
- function Me(e, t, n) {
506
+ function yt(e, t, n) {
441
507
  if (!t) return;
442
508
  let r = e.directiveText.indexOf(t.text);
443
509
  if (r === -1) return;
@@ -450,14 +516,14 @@ function Me(e, t, n) {
450
516
  stop: a
451
517
  };
452
518
  }
453
- function Ne(e) {
454
- let t = Ae(e), n = new Map(e.blocks.map((e) => [e.id, e])), r = De(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 = [];
455
521
  for (let t of e.blocks) {
456
- let e = we(t);
457
- 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);
458
524
  }
459
- return i(e.directiveText).map((i) => {
460
- let o = je(e, t, i), s = Ce(n, o) ?? Se(e.blocks, i), c = we(s), l = c.length > 0 ? c : s?.id === void 0 ? [] : a.get(s.id) ?? [], u = Me(e, s, i), d = ke(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);
461
527
  return {
462
528
  articleId: e.id,
463
529
  blockId: s?.id,
@@ -472,18 +538,18 @@ function Ne(e) {
472
538
  sourceContextBlockIds: d.blockIds,
473
539
  sourceContextPosition: d.position
474
540
  },
475
- directive: i,
541
+ directive: a,
476
542
  ...l.length > 0 ? { targetIds: l } : {}
477
543
  };
478
544
  });
479
545
  }
480
- function Pe(e) {
546
+ function xt(e) {
481
547
  let t = /* @__PURE__ */ new Map(), n = [], r = /* @__PURE__ */ new Set();
482
548
  for (let i of e) {
483
- let e = re(i.directive);
549
+ let e = Me(i.directive);
484
550
  if (e.length === 0) continue;
485
551
  let a = e.map(({ num: e }) => ({
486
- definitionId: `${i.articleId}:article:${ee(e)}`,
552
+ definitionId: `${i.articleId}:article:${ke(e)}`,
487
553
  num: e
488
554
  }));
489
555
  t.set(i, a);
@@ -495,7 +561,6 @@ function Pe(e) {
495
561
  blockId: i.blockId,
496
562
  html: o.text,
497
563
  ...i.targetIds === void 0 ? {} : { parentTargetIds: i.targetIds },
498
- sourceDirectiveId: i.directive.sourceText,
499
564
  ...i.sourceBlockHtml === void 0 ? {} : { sourceBlockHtml: i.sourceBlockHtml },
500
565
  ...i.sourceBlockText === void 0 ? {} : { sourceBlockText: i.sourceBlockText },
501
566
  text: o.text
@@ -507,13 +572,13 @@ function Pe(e) {
507
572
  definitions: n
508
573
  };
509
574
  }
510
- function Fe(e, t, n) {
511
- 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]));
512
577
  return e.map((e) => {
513
- 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 : {
514
579
  definitionId: a.definitionId,
515
580
  num: a.num
516
- }, s = ie(e.directive), c = (e.targetIds?.length ?? 0) > 0;
581
+ }, s = Pe(e.directive), c = (e.targetIds?.length ?? 0) > 0;
517
582
  return {
518
583
  ...e,
519
584
  ...i === void 0 ? {} : { createdArticle: i },
@@ -526,72 +591,96 @@ function Fe(e, t, n) {
526
591
  };
527
592
  });
528
593
  }
529
- function Ie(e, t, n, i, a, o, s = !0) {
530
- 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 = {
531
596
  sourceFormat: e,
532
- documentDate: i,
597
+ documentDate: r,
533
598
  html: t,
534
599
  htmlWithLinks: n,
535
- tableOfContents: o ?? r(c),
536
- articles: a
600
+ tableOfContents: a ?? b(c),
601
+ articles: i
537
602
  };
538
- if (!s) return {
603
+ if (!o) return {
539
604
  ...l,
540
605
  directives: []
541
606
  };
542
- let u = ce(a.map((e) => e.text).join("\n")), d = a.flatMap(Ne), { createdArticlesByDirective: f, definitions: p } = Pe(d), m = Fe(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);
543
608
  return {
544
609
  ...l,
545
610
  ...u ? { globalApplicabilityDate: u } : {},
546
611
  ...p.length > 0 ? { internalArticleDefinitions: p } : {},
547
- directives: m
612
+ directives: m,
613
+ ...s !== void 0 && s.length > 0 ? { diagnostics: s } : {}
548
614
  };
549
615
  }
550
- function Le(e) {
551
- 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;
552
- function a(e) {
553
- for (let t of e.articles ?? []) i += 1, t.id ??= n.get(D(t.line));
554
- for (let t of e.divisions ?? []) a(t);
555
- }
556
- return a(t), i > 0 ? t : { articles: e.map((e) => ({
616
+ function wt(e) {
617
+ return { items: e.map((e) => ({
557
618
  id: e.id,
558
619
  line: e.title ? `${e.label} : ${e.title}` : e.label,
559
620
  type: "article"
560
621
  })) };
561
622
  }
562
- async function Re(t, n) {
563
- let r = new u("parseAssembleeBillRaw"), i = n.linkedHtml === void 0 ? await r.time("linkAssembleeBillRaw", () => ze(t, n)) : void 0, a = r.timeSync("applyArticleAnchorIds", () => be(n.linkedHtml ?? i.linkedHtml), { inputSize: t.length }), o = r.timeSync("cheerioLoadLinkedHtml", () => e(a)), s = r.timeSync("extractArticleHeadings", () => L(o)), c = r.timeSync("extractArticlesAndBlocks", () => s.map((e, t) => {
564
- let n = ge(o, e, s[t + 1]), r = ve(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");
565
654
  return {
566
655
  id: e.id,
567
656
  label: e.label,
568
657
  num: e.num,
569
658
  title: e.title,
570
- text: fe(o, n),
571
- html: n.map((e) => N(o, e)).join("\n"),
659
+ text: Ge(a, n),
660
+ html: n.map((e) => Ve(a, e)).join("\n"),
572
661
  directiveText: i,
573
662
  blocks: r
574
663
  };
575
- }), { count: s.length }), l = r.timeSync("injectHiddenArticleSummary", () => ye(o.html(), c)), d = r.timeSync("buildAssembleeTableOfContents", () => Le(c), { count: c.length }), f = r.timeSync("buildParsedDocument", () => Ie("assemblee-html", t, l, n.date, c, d, n.includeDirectiveAnalysis));
576
- 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({
577
666
  articleCount: f.articles.length,
578
667
  blockCount: f.articles.reduce((e, t) => e + t.blocks.length, 0),
579
668
  directiveCount: f.directives.length,
580
669
  targetDirectiveCount: f.directives.filter((e) => e.targetIds !== void 0).length
581
670
  }), f;
582
671
  }
583
- async function ze(e, t) {
672
+ async function Ot(e, t) {
584
673
  return {
585
674
  sourceFormat: "assemblee-html",
586
675
  documentDate: t.date,
587
676
  html: e,
588
- linkedHtml: await F(e, t, t.date)
677
+ linkedHtml: await qe(e, t, t.date)
589
678
  };
590
679
  }
591
- function R(e) {
680
+ function I(e) {
592
681
  return e.replace(/&/gu, "&amp;").replace(/</gu, "&lt;").replace(/>/gu, "&gt;").replace(/"/gu, "&quot;");
593
682
  }
594
- function Be(e) {
683
+ function kt(e) {
595
684
  let t = e;
596
685
  for (let e = 0; e < 3; e++) {
597
686
  let e = t;
@@ -599,27 +688,27 @@ function Be(e) {
599
688
  }
600
689
  return t;
601
690
  }
602
- function z(e) {
691
+ function At(e) {
603
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);
604
693
  }
605
- function B(e) {
694
+ function L(e) {
606
695
  return e.name.replace(/^.*:/u, "");
607
696
  }
608
- function V(e, t) {
609
- 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("");
610
699
  }
611
- function Ve(e, t) {
612
- return t.children.map((t) => t.type === "text" && z(t.data) ? Be(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("");
613
702
  }
614
- function H(e, t) {
703
+ function R(e, t) {
615
704
  if (t.type === "text") {
616
705
  let e = t.data.replace(/\s+\./gu, ".");
617
- return z(e) ? Be(e) : R(e);
706
+ return At(e) ? kt(e) : I(e);
618
707
  }
619
- if (!M(t)) return "";
620
- let n = B(t), r = V(e, t);
708
+ if (!F(t)) return "";
709
+ let n = L(t), r = jt(e, t);
621
710
  switch (n) {
622
- case "p": return `<p${U(e, t, [
711
+ case "p": return `<p${z(e, t, [
623
712
  "id",
624
713
  "class",
625
714
  "align",
@@ -633,13 +722,13 @@ function H(e, t) {
633
722
  case "u":
634
723
  case "sup":
635
724
  case "sub":
636
- case "abbr": return `<${n}${U(e, t, [
725
+ case "abbr": return `<${n}${z(e, t, [
637
726
  "id",
638
727
  "class",
639
728
  "title",
640
729
  "style"
641
730
  ])}>${r}</${n}>`;
642
- case "a": return `<a href="${R(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, [
643
732
  "id",
644
733
  "class",
645
734
  "title",
@@ -650,8 +739,8 @@ function H(e, t) {
650
739
  case "tbody":
651
740
  case "tr":
652
741
  case "th":
653
- case "td": return He(e, t, n, r);
654
- case "caption": return `<caption${U(e, t, [
742
+ case "td": return Nt(e, t, n, r);
743
+ case "caption": return `<caption${z(e, t, [
655
744
  "id",
656
745
  "class",
657
746
  "align",
@@ -659,12 +748,12 @@ function H(e, t) {
659
748
  ])}>${r}</caption>`;
660
749
  case "num": return `<span class="akn-num">${r}</span> `;
661
750
  case "heading": return `<p class="akn-heading">${r}</p>`;
662
- case "content": return Ve(e, t);
663
- case "alinea": return K(e, t, "div", "akn-alinea");
664
- case "article": return K(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");
665
754
  case "blockList":
666
755
  case "list": return `<div class="akn-list">${r}</div>`;
667
- case "item": return K(e, t, "div", "akn-item");
756
+ case "item": return B(e, t, "div", "akn-item");
668
757
  case "listIntroduction":
669
758
  case "listWrapUp":
670
759
  case "intro":
@@ -680,23 +769,23 @@ function H(e, t) {
680
769
  case "book":
681
770
  case "tome":
682
771
  case "subchapter":
683
- case "subsection": return K(e, t, "section", `akn-${n}`);
772
+ case "subsection": return B(e, t, "section", `akn-${n}`);
684
773
  case "crossHeading": return `<p class="akn-cross-heading">${r}</p>`;
685
774
  default: return r;
686
775
  }
687
776
  }
688
- function U(e, t, n, r = {}) {
777
+ function z(e, t, n, r = {}) {
689
778
  let i = [];
690
779
  for (let r of n) {
691
780
  if (r === "style") continue;
692
781
  let n = e(t).attr(r);
693
- n !== void 0 && i.push(`${r}="${R(n)}"`);
782
+ n !== void 0 && i.push(`${r}="${I(n)}"`);
694
783
  }
695
784
  let a = r.style ?? e(t).attr("style");
696
- return a && i.push(`style="${R(a)}"`), i.length > 0 ? ` ${i.join(" ")}` : "";
785
+ return a && i.push(`style="${I(a)}"`), i.length > 0 ? ` ${i.join(" ")}` : "";
697
786
  }
698
- function He(e, t, n, r) {
699
- return `<${n}${U(e, t, [
787
+ function Nt(e, t, n, r) {
788
+ return `<${n}${z(e, t, [
700
789
  "id",
701
790
  "class",
702
791
  "colspan",
@@ -709,155 +798,155 @@ function He(e, t, n, r) {
709
798
  "cellspacing",
710
799
  "cellpadding",
711
800
  "style"
712
- ], { style: Ue(e, t, n) })}>${r}</${n}>`;
801
+ ], { style: Pt(e, t, n) })}>${r}</${n}>`;
713
802
  }
714
- function Ue(e, t, n) {
803
+ function Pt(e, t, n) {
715
804
  let r = e(t).attr("style") ?? "";
716
- return (n === "td" || n === "th") && /font-weight\s*:\s*bold/iu.test(r) && !/text-align\s*:/iu.test(r) && (r = We(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;
717
806
  }
718
- function We(e, t, n) {
807
+ function Ft(e, t, n) {
719
808
  let r = e.trim();
720
809
  return `${r}${r && !r.endsWith(";") ? ";" : ""} ${t}: ${n};`.trim();
721
810
  }
722
- function Ge(e, t) {
723
- let n = [E(e(t).children("num").first().text()), E(e(t).children("heading").first().text())].filter(Boolean);
724
- return n.length === 0 ? "" : `<p class="akn-heading">${R(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>`;
725
814
  }
726
- function Ke(e, t) {
815
+ function Lt(e, t) {
727
816
  if (!t) return !1;
728
- let n = (e) => E(e).replace(/\s+/gu, " ").replace(/\s*[..]\s*(?=[–—-])/gu, " ").trim();
729
- 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));
730
819
  }
731
- function qe(e) {
732
- let t = R(e);
820
+ function Rt(e) {
821
+ let t = I(e);
733
822
  return `<p data-pastille="${t}" class="pastille"><span aria-label="pastille ${t}">${t}</span></p>`;
734
823
  }
735
- function Je(e, t) {
736
- return Ye([Xe({
824
+ function zt(e, t) {
825
+ return Bt([Vt({
737
826
  content: e,
738
827
  pastille: t
739
828
  })]);
740
829
  }
741
- function Ye(e) {
830
+ function Bt(e) {
742
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>`;
743
832
  }
744
- function Xe({ content: e, pastille: t, style: n, contextClass: r }) {
745
- let i = n ? ` style="${R(n)}"` : "", a = r ? ` ${R(r)}` : "";
746
- return `<tr${r ? ` class="${R(r)} hideable"` : ""}><td style="overflow: hidden; width: 5.0%;" class="texte-col-0 texte-col-pastille no-right-border"><div class="tableauComparatifCell${a}">${qe(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>`;
747
836
  }
748
- function W({ content: e, style: t, contextClass: n }) {
749
- let r = t ? ` style="${R(t)}"` : "", i = n ? ` ${R(n)}` : "";
750
- return `<tr${n ? ` class="${R(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>`;
751
840
  }
752
- function Ze(e, t) {
841
+ function Ut(e, t) {
753
842
  return e(t).attr("data:pastille") ?? e(t).attr("pastille");
754
843
  }
755
- function Qe(e, t) {
844
+ function Wt(e, t) {
756
845
  return e(t).find("alinea[data\\:pastille],alinea[pastille]").length > 0;
757
846
  }
758
- function $e(e, t) {
759
- return e(t).children().get().filter((e) => M(e) ? B(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");
760
849
  }
761
- function et(e, t) {
850
+ function Kt(e, t) {
762
851
  let n = [];
763
852
  return e(t).children().each((t, r) => {
764
- if (!M(r)) return;
765
- let i = B(r);
766
- 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));
767
856
  }), n.filter(Boolean);
768
857
  }
769
- function G(e, t) {
770
- let n = [], r = B(t), i = r === "alinea" ? Ze(e, t) : void 0, a = $e(e, t), o = tt(e, t, r, i), s = st(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);
771
860
  if (i) {
772
- let r = [Ke(a, E(e(t).children("num").first().text())) ? "" : Ge(e, t), a].filter(Boolean).join("\n");
773
- E(r) && n.push(Xe({
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({
774
863
  content: r,
775
864
  pastille: i,
776
865
  style: o,
777
866
  contextClass: s
778
867
  }));
779
- } else a && n.push(W({
868
+ } else a && n.push(Ht({
780
869
  content: a,
781
870
  style: o,
782
871
  contextClass: s
783
872
  }));
784
873
  for (let r of e(t).children().get()) {
785
- if (!M(r)) continue;
786
- let t = B(r);
787
- t === "num" || t === "heading" || t === "content" || (t === "alinea" || Qe(e, r)) && n.push(...G(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));
788
877
  }
789
878
  return n;
790
879
  }
791
- function K(e, t, n, r) {
792
- let i = B(t), a = e(t).attr("eId") ?? e(t).attr("GUID"), o = Ze(e, t), s = tt(e, t, i, o), c = [`<${n} ${[
793
- a ? `id="${R(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,
794
883
  `class="${r}"`,
795
- o ? `data-pastille="${R(o)}"` : void 0,
796
- s ? `style="${R(s)}"` : void 0
884
+ o ? `data-pastille="${I(o)}"` : void 0,
885
+ s ? `style="${I(s)}"` : void 0
797
886
  ].filter((e) => e !== void 0).join(" ")}>`];
798
887
  if (i === "part" || i === "title") {
799
- let r = it(e, t, i), a = ot(e, t), o = r ? [W({
888
+ let r = Zt(e, t, i), a = $t(e, t), o = r ? [Ht({
800
889
  content: r,
801
890
  contextClass: a
802
891
  })] : [], s = () => {
803
- o.length !== 0 && (c.push(rt(o)), o = []);
892
+ o.length !== 0 && (c.push(Xt(o)), o = []);
804
893
  };
805
894
  return e(t).children().each((t, n) => {
806
- if (!M(n)) return;
807
- let r = B(n);
895
+ if (!F(n)) return;
896
+ let r = L(n);
808
897
  if (!(r === "num" || r === "heading" || r === "content")) {
809
898
  if (r === "alinea") {
810
- o.push(...G(e, n));
899
+ o.push(...qt(e, n));
811
900
  return;
812
901
  }
813
- s(), c.push(H(e, n));
902
+ s(), c.push(R(e, n));
814
903
  }
815
904
  }), s(), c.push(`</${n}>`), c.join("\n");
816
905
  }
817
906
  if (i === "article") {
818
- let r = E(e(t).children("num").first().text()), i = E(e(t).children("heading").first().text()), a = P(r) ?? {
907
+ let r = N(e(t).children("num").first().text()), i = N(e(t).children("heading").first().text()), a = v(r) ?? {
819
908
  label: r,
820
909
  num: r
821
- }, o = `<p class="TCNumArticle as-text toc-article dispositif" id="${R(`_TocArt${(a.num ?? r).replace(/\s+/gu, "")}`)}">${R(a.label)}${i ? ` : ${R(i)}` : ""}</p>`;
822
- if (Qe(e, t)) {
823
- let r = [W({
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({
824
913
  content: o,
825
- contextClass: lt(a.label)
826
- }), ...G(e, t)];
827
- c.push(Ye(r));
828
- for (let n of et(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);
829
918
  return c.push(`</${n}>`), c.join("\n");
830
919
  }
831
920
  c.push(o);
832
921
  }
833
922
  let l = [];
834
923
  for (let n of ["content", "children"]) e(t).children().each((t, r) => {
835
- if (!M(r)) return;
836
- let i = B(r);
837
- 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));
838
927
  });
839
928
  let u = l.join("\n");
840
929
  if (i !== "article") {
841
- let n = Ke(u, E(e(t).children("num").first().text())) ? "" : Ge(e, t);
930
+ let n = Lt(u, N(e(t).children("num").first().text())) ? "" : It(e, t);
842
931
  n && c.push(n);
843
932
  }
844
- return c.push(o ? Je(u, o) : u), c.push(`</${n}>`), c.join("\n");
933
+ return c.push(o ? zt(u, o) : u), c.push(`</${n}>`), c.join("\n");
845
934
  }
846
- function tt(e, t, n, r) {
847
- let i = nt(e(t).attr("style") ?? "", "font-family");
848
- return !r && n !== "article" && /font-weight\s*:\s*bold/iu.test(i) && !/text-align\s*:/iu.test(i) && (i = We(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;
849
938
  }
850
- function nt(e, t) {
939
+ function Yt(e, t) {
851
940
  return e.split(";").map((e) => e.trim()).filter(Boolean).filter((e) => !e.toLowerCase().startsWith(`${t.toLowerCase()}:`)).join(";");
852
941
  }
853
- function rt(e) {
942
+ function Xt(e) {
854
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>`;
855
944
  }
856
- function it(e, t, n) {
857
- let r = E(e(t).children("num").first().text()), i = E(e(t).children("heading").first().text()), a = at(n), o = [];
858
- return r && o.push(`<p class="${a.num} as-text dispositif"><span aria-label="">${R(r)}</span></p>`), i && o.push(`<p class="${a.heading} as-text dispositif"><span aria-label="">${R(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");
859
948
  }
860
- function at(e) {
949
+ function Qt(e) {
861
950
  switch (e) {
862
951
  case "part": return {
863
952
  num: "TCNumPartie",
@@ -881,22 +970,22 @@ function at(e) {
881
970
  };
882
971
  }
883
972
  }
884
- function ot(e, t) {
885
- let n = ct(E(e(t).children("num").first().text()));
973
+ function $t(e, t) {
974
+ let n = tn(N(e(t).children("num").first().text()));
886
975
  if (n) return n;
887
976
  for (let n of e(t).parents().get()) {
888
- if (!M(n)) continue;
889
- let t = B(n);
977
+ if (!F(n)) continue;
978
+ let t = L(n);
890
979
  if (t !== "title" && t !== "part") continue;
891
- let r = ct(E(e(n).children("num").first().text()));
980
+ let r = tn(N(e(n).children("num").first().text()));
892
981
  if (r) return r;
893
982
  }
894
983
  }
895
- function st(e, t) {
896
- return ot(e, t);
984
+ function en(e, t) {
985
+ return $t(e, t);
897
986
  }
898
- function ct(e) {
899
- let [t, ...n] = E(e).split(/\s+/u);
987
+ function tn(e) {
988
+ let [t, ...n] = N(e).split(/\s+/u);
900
989
  if (!t || n.length === 0) return;
901
990
  let r = t.toLocaleLowerCase("fr-FR");
902
991
  if ([
@@ -906,10 +995,10 @@ function ct(e) {
906
995
  "section"
907
996
  ].includes(r)) return `${r}-${n.join("_")}`;
908
997
  }
909
- function lt(e) {
910
- 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`;
911
1000
  }
912
- function ut(e) {
1001
+ function rn(e) {
913
1002
  switch (e) {
914
1003
  case "part": return "partie";
915
1004
  case "book": return "livre";
@@ -921,11 +1010,11 @@ function ut(e) {
921
1010
  default: return;
922
1011
  }
923
1012
  }
924
- function dt(e, t) {
925
- 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(" ");
926
1015
  }
927
- function ft(e, t) {
928
- let n = E(e(t).children("num").first().text()), r = E(e(t).children("heading").first().text()), i = P(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) ?? {
929
1018
  label: n,
930
1019
  num: n
931
1020
  };
@@ -935,138 +1024,138 @@ function ft(e, t) {
935
1024
  type: "article"
936
1025
  };
937
1026
  }
938
- function pt(e, t) {
939
- 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);
940
1029
  }
941
- function q(e, t) {
942
- let n = {};
1030
+ function cn(e, t) {
1031
+ let n = { items: [] };
943
1032
  return e(t).children().each((t, r) => {
944
- if (!M(r)) return;
945
- let i = B(r);
1033
+ if (!F(r)) return;
1034
+ let i = L(r);
946
1035
  if (i === "article") {
947
- n.articles ??= [], n.articles.push(ft(e, r));
1036
+ n.items.push(on(e, r));
948
1037
  return;
949
1038
  }
950
- let a = ut(i);
1039
+ let a = rn(i);
951
1040
  if (!a) {
952
- pt(n, q(e, r));
1041
+ sn(n, cn(e, r));
953
1042
  return;
954
1043
  }
955
- let o = dt(e, r), s = q(e, r);
956
- !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({
957
1046
  ...s,
958
1047
  id: e(r).attr("eId") ?? e(r).attr("GUID"),
959
1048
  line: o,
960
1049
  type: a
961
- }));
1050
+ });
962
1051
  }), n;
963
1052
  }
964
- function mt(e) {
1053
+ function ln(e) {
965
1054
  let t = e("body").first().get(0);
966
- return t === void 0 ? {} : q(e, t);
1055
+ return t === void 0 ? { items: [] } : cn(e, t);
967
1056
  }
968
- function ht(e) {
1057
+ function un(e) {
969
1058
  return e("FRBRExpression FRBRdate[name=\"#depot\"]").attr("date") ?? e("FRBRWork FRBRdate[name=\"#presentation\"]").attr("date");
970
1059
  }
971
- function gt(e) {
1060
+ function dn(e) {
972
1061
  let t = e("preamble").first(), n = e("body").first(), r = ["<div class=\"akn-bill\">"];
973
- return t.length > 0 && (r.push("<section class=\"akn-preamble\">"), r.push(V(e, t.get(0))), r.push("</section>")), r.push("<section class=\"akn-body\">"), n.children().each((t, n) => {
974
- M(n) && r.push(B(n) === "article" ? K(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));
975
1064
  }), r.push("</section></div>"), r.join("\n");
976
1065
  }
977
- function _t(t) {
978
- let n = e(t, { xml: {
1066
+ function fn(e) {
1067
+ let t = u(e, { xml: {
979
1068
  decodeEntities: !1,
980
1069
  lowerCaseTags: !1,
981
1070
  lowerCaseAttributeNames: !1,
982
1071
  xmlMode: !0
983
- } }), r = ht(n), i = gt(n);
1072
+ } }), n = un(t), r = dn(t);
984
1073
  return {
985
1074
  sourceFormat: "akoma-ntoso",
986
- documentDate: r,
987
- html: i,
988
- linkedHtml: i
1075
+ documentDate: n,
1076
+ html: r,
1077
+ linkedHtml: r
989
1078
  };
990
1079
  }
991
- function vt(t) {
992
- return yt(e(t));
1080
+ function pn(e) {
1081
+ return mn(u(e));
993
1082
  }
994
- function yt(e) {
1083
+ function mn(e) {
995
1084
  let t = [];
996
1085
  return e("article.akn-article").each((n, r) => {
997
- let i = e(r).children("p.TCNumArticle").first().get(0), a = E(i ? e(i).text() : ""), o = P(a) ?? { label: a || `Article ${n + 1}` }, s = e(r).attr("id") ?? `akn-article-${String(n + 1).padStart(3, "0")}`, c = [r], l = ve(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");
998
1087
  t.push({
999
1088
  id: s,
1000
1089
  label: o.label,
1001
1090
  num: o.num,
1002
1091
  title: o.title,
1003
- text: fe(e, c),
1004
- html: N(e, r),
1092
+ text: Ge(e, c),
1093
+ html: Ve(e, r),
1005
1094
  directiveText: u,
1006
1095
  blocks: l
1007
1096
  });
1008
1097
  }), t;
1009
1098
  }
1010
- function bt(t) {
1011
- let n = e(t);
1099
+ function hn(e) {
1100
+ let t = u(e);
1012
1101
  return {
1013
- articles: yt(n),
1014
- htmlWithLinks: n.html()
1102
+ articles: mn(t),
1103
+ htmlWithLinks: t.html()
1015
1104
  };
1016
1105
  }
1017
- async function xt(t, n) {
1018
- 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: {
1019
1108
  decodeEntities: !1,
1020
1109
  lowerCaseTags: !1,
1021
1110
  lowerCaseAttributeNames: !1,
1022
1111
  xmlMode: !0
1023
- } })), a = n.date ?? ht(i), o = r.timeSync("renderAknHtml", () => gt(i), { inputSize: t.length }), s = n.linkedHtml ?? await r.time("addLinksToRenderedAknHtml", () => F(o, {
1024
- ...n,
1025
- date: a
1026
- }, a)), c = r.timeSync("extractRenderedAknArticles", () => vt(o)), l = r.timeSync("injectHiddenArticleSummary", () => ye(s, c)), { articles: d, htmlWithLinks: f } = r.timeSync("extractLinkedAknArticlesAndTaggedHtml", () => bt(l)), p = d.length > 0 ? d : c, m = r.timeSync("extractAknTableOfContents", () => mt(i)), h = r.timeSync("buildParsedDocument", () => Ie("akoma-ntoso", o, d.length > 0 ? f : l, a, p, m));
1027
- return r.log({
1028
- articleCount: h.articles.length,
1029
- blockCount: h.articles.reduce((e, t) => e + t.blocks.length, 0),
1030
- directiveCount: h.directives.length,
1031
- targetDirectiveCount: h.directives.filter((e) => e.targetIds !== void 0).length
1032
- }), 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;
1033
1122
  }
1034
- async function St(e, t) {
1035
- let n = _t(e), r = t.date ?? n.documentDate;
1123
+ async function _n(e, t) {
1124
+ let n = fn(e), r = t.date ?? n.documentDate;
1036
1125
  return {
1037
1126
  sourceFormat: "akoma-ntoso",
1038
1127
  documentDate: r,
1039
1128
  html: n.html,
1040
- linkedHtml: await F(n.html, t, r)
1129
+ linkedHtml: await qe(n.html, t, r)
1041
1130
  };
1042
1131
  }
1043
1132
  //#endregion
1044
1133
  //#region src/lib/server/assemblee_document_search.ts
1045
- var Ct = /\bexpos[ée]\s+des\s+motifs\b/giu, wt = /\barticle\s+(?:premier|1er|\d+)/iu;
1046
- function J(e) {
1134
+ var vn = /\bexpos[ée]\s+des\s+motifs\b/giu, yn = /\barticle\s+(?:premier|1er|\d+)/iu;
1135
+ function bn(e) {
1047
1136
  return e.replace(/\u00a0/gu, " ").replace(/\s+/gu, " ").trim();
1048
1137
  }
1049
- function Y(t) {
1050
- let n = J(e(t).text()), r = [...n.matchAll(Ct)], i = /* @__PURE__ */ new Set(), a = [];
1051
- for (let [e, t] of r.entries()) {
1052
- let o = (t.index ?? 0) + t[0].length, s = n.slice(o), c = wt.exec(s), l = J(s.slice(0, c?.index ?? s.length));
1053
- if (l.length < 20 || i.has(l)) continue;
1054
- 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);
1055
1144
  let u = `expose-des-motifs-${e + 1}`;
1056
- a.push({
1145
+ i.push({
1057
1146
  anchor: u,
1058
1147
  articleNumber: null,
1059
1148
  content: l,
1060
1149
  itemId: u,
1061
1150
  itemKind: "expose_des_motifs",
1062
- 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}`,
1063
1152
  title: null
1064
1153
  });
1065
1154
  }
1066
- return a;
1155
+ return i;
1067
1156
  }
1068
- async function Tt({ date: e, html: t, linkBaseUrl: n, linkType: r }) {
1069
- let i = await Re(t, {
1157
+ async function Sn({ date: e, html: t, linkBaseUrl: n, linkType: r }) {
1158
+ let i = await Dt(t, {
1070
1159
  date: e,
1071
1160
  includeDirectiveAnalysis: !1,
1072
1161
  linkBaseUrl: n,
@@ -1075,7 +1164,7 @@ async function Tt({ date: e, html: t, linkBaseUrl: n, linkType: r }) {
1075
1164
  });
1076
1165
  return {
1077
1166
  items: [...i.articles.map((e) => {
1078
- let t = J(e.directiveText || e.text);
1167
+ let t = bn(e.directiveText || e.text);
1079
1168
  if (t) return {
1080
1169
  anchor: e.id,
1081
1170
  articleNumber: e.num ?? null,
@@ -1085,17 +1174,17 @@ async function Tt({ date: e, html: t, linkBaseUrl: n, linkType: r }) {
1085
1174
  label: e.label,
1086
1175
  title: e.title ?? null
1087
1176
  };
1088
- }).filter((e) => e !== void 0), ...Y(t)],
1177
+ }).filter((e) => e !== void 0), ...xn(t)],
1089
1178
  tableOfContents: i.tableOfContents
1090
1179
  };
1091
1180
  }
1092
- function Et(e, t) {
1093
- return h("sha256").update(JSON.stringify({
1181
+ function Cn(e, t) {
1182
+ return k("sha256").update(JSON.stringify({
1094
1183
  item: e,
1095
1184
  metadata: t
1096
1185
  })).digest("hex");
1097
1186
  }
1098
- function Dt(e) {
1187
+ function wn(e) {
1099
1188
  if (typeof e != "object" || !e) return;
1100
1189
  let t = e.cycleDeVie?.chrono;
1101
1190
  if (t !== void 0) for (let e of [
@@ -1110,11 +1199,11 @@ function Dt(e) {
1110
1199
  }
1111
1200
  //#endregion
1112
1201
  //#region src/lib/server/senat_amendment_search.ts
1113
- function Ot(t) {
1114
- 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() : "";
1115
1204
  }
1116
- function kt({ dispositifHtml: e, objetHtml: t }) {
1117
- let n = Ot(e), r = Ot(t);
1205
+ function En({ dispositifHtml: e, objetHtml: t }) {
1206
+ let n = Tn(e), r = Tn(t);
1118
1207
  return [...n ? [{
1119
1208
  content: n,
1120
1209
  itemKind: "dispositif",
@@ -1125,47 +1214,658 @@ function kt({ dispositifHtml: e, objetHtml: t }) {
1125
1214
  label: "Objet"
1126
1215
  }] : []];
1127
1216
  }
1128
- function At(e, t) {
1129
- return h("sha256").update(JSON.stringify({
1217
+ function Dn(e, t) {
1218
+ return k("sha256").update(JSON.stringify({
1130
1219
  item: e,
1131
1220
  metadata: t
1132
1221
  })).digest("hex");
1133
1222
  }
1134
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
1135
1836
  //#region src/lib/server/senat_document_search.ts
1136
- var jt = /^article\s+(.+?)(?:\s*[::]\s*(.+))?$/iu;
1137
- function X(e) {
1837
+ function $(e) {
1138
1838
  return e.replace(/\u00a0/gu, " ").replace(/\s+/gu, " ").trim();
1139
1839
  }
1140
- function Mt(e) {
1141
- let t = e.match(jt);
1840
+ function Tr(e) {
1841
+ let t = v(e);
1142
1842
  if (!t) return {
1143
1843
  articleNumber: null,
1144
1844
  label: e,
1145
1845
  title: null
1146
1846
  };
1147
- let n = X(t[1] ?? "") || null, r = X(t[2] ?? "") || null;
1847
+ let n = $(t.num ?? "") || null, r = $(t.title ?? "") || null;
1148
1848
  return {
1149
1849
  articleNumber: n,
1150
- label: n ? `Article ${n}` : e,
1850
+ label: t.label,
1151
1851
  title: r
1152
1852
  };
1153
1853
  }
1154
- function Nt(t) {
1155
- let n = e(t), r = [], i = X(n("section.akn-preamble").text());
1156
- 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({
1157
1857
  anchor: "senat-expose-des-motifs",
1158
1858
  articleNumber: null,
1159
- content: i,
1859
+ content: r,
1160
1860
  itemId: "expose-des-motifs",
1161
1861
  itemKind: "expose_des_motifs",
1162
1862
  label: "Exposé des motifs",
1163
1863
  title: null
1164
- }), n("article.akn-article").each((e, t) => {
1165
- 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 = Mt(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();
1166
1866
  l.children("p.TCNumArticle").remove();
1167
- let u = X(l.text());
1168
- u && r.push({
1867
+ let u = $(l.text());
1868
+ u && n.push({
1169
1869
  anchor: i.attr("id") || null,
1170
1870
  articleNumber: c.articleNumber,
1171
1871
  content: u,
@@ -1174,42 +1874,42 @@ function Nt(t) {
1174
1874
  label: c.label,
1175
1875
  title: c.title
1176
1876
  });
1177
- }), r;
1877
+ }), n;
1178
1878
  }
1179
- function Pt(e, t) {
1180
- return h("sha256").update(JSON.stringify({
1879
+ function Dr(e, t) {
1880
+ return k("sha256").update(JSON.stringify({
1181
1881
  item: e,
1182
1882
  metadata: t
1183
1883
  })).digest("hex");
1184
1884
  }
1185
1885
  //#endregion
1186
1886
  //#region src/lib/server/senat_document_sources.ts
1187
- var Ft = new Set(["senat.fr", "www.senat.fr"]), Z = "https://www.senat.fr";
1188
- function It(e) {
1887
+ var Or = new Set(["senat.fr", "www.senat.fr"]), kr = "https://www.senat.fr";
1888
+ function Ar(e) {
1189
1889
  return e?.trim() || void 0;
1190
1890
  }
1191
- function Lt(e) {
1891
+ function jr(e) {
1192
1892
  try {
1193
- let t = e.replace(/^\/+/, ""), n = /^https?:\/\//iu.test(e) ? new URL(e) : new URL(/^(?:akomantoso|leg)\//iu.test(t) ? `/${t}` : `/leg/${t}`, Z);
1194
- return Ft.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;
1195
1895
  } catch {
1196
1896
  return;
1197
1897
  }
1198
1898
  }
1199
- function Rt(e) {
1200
- let t = It(e);
1899
+ function Mr(e) {
1900
+ let t = Ar(e);
1201
1901
  if (t === void 0) return {
1202
1902
  publicUrl: null,
1203
1903
  status: "no_url"
1204
1904
  };
1205
- let n = Lt(t);
1905
+ let n = jr(t);
1206
1906
  if (n === void 0) return {
1207
1907
  publicUrl: t,
1208
1908
  status: "unsupported_source"
1209
1909
  };
1210
1910
  let r = n.pathname;
1211
1911
  if (/^\/akomantoso\/[^/]+\.akn\.xml$/iu.test(r)) return {
1212
- akomaNtosoUrl: `${Z}${r}`,
1912
+ akomaNtosoUrl: `${kr}${r}`,
1213
1913
  publicUrl: n.toString(),
1214
1914
  status: "available"
1215
1915
  };
@@ -1218,17 +1918,17 @@ function Rt(e) {
1218
1918
  publicUrl: n.toString(),
1219
1919
  status: "unsupported_source"
1220
1920
  } : {
1221
- akomaNtosoUrl: `${Z}/akomantoso/${i.replace(/\.html$/iu, ".akn.xml")}`,
1921
+ akomaNtosoUrl: `${kr}/akomantoso/${i.replace(/\.html$/iu, ".akn.xml")}`,
1222
1922
  publicUrl: n.toString(),
1223
1923
  status: "available"
1224
1924
  };
1225
1925
  }
1226
- function zt(e) {
1926
+ function Nr(e) {
1227
1927
  return /^\s*(?:<\?xml\b[^>]*>\s*)?<akomaNtoso[\s/>]/iu.test(e);
1228
1928
  }
1229
1929
  //#endregion
1230
1930
  //#region src/lib/alineas/alineas_numbers.ts
1231
- var Bt = {
1931
+ var Pr = {
1232
1932
  "0150a855548f15a2af52ea057be53f5d": 1,
1233
1933
  "039826cf379b94afefe90b25c6045ca0": 1,
1234
1934
  "03a7e564b84662f4d957c51018e26244": 1,
@@ -20202,7 +20902,7 @@ var Bt = {
20202
20902
  d16d29c923bd60c7b095b66c6058fe60: 1664,
20203
20903
  "1c14c2adf5cfda3220b2057160e10e91": 1665,
20204
20904
  e44c55ca1ac46ff46420686a466c9fc6: 1665
20205
- }, Vt = "\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", Ht = "\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", Ut = "\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", Wt = "\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", Gt = "\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", Kt = {
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 = {
20206
20906
  assnatetatagr: { bold: !0 },
20207
20907
  assnatetatagrgr: { bold: !0 },
20208
20908
  assnatetatatr: { bold: !0 },
@@ -20303,29 +21003,29 @@ var Bt = {
20303
21003
  assnatxl67: { align: "center" },
20304
21004
  assnatenteteequilibre: { align: "center" }
20305
21005
  };
20306
- function qt(e) {
20307
- let t = Object.keys(Kt).sort((e, t) => t.length - e.length);
20308
- for (let n of t) if (e.includes(n)) return Kt[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];
20309
21009
  return null;
20310
21010
  }
20311
- function Jt(e) {
20312
- return m.createHash("md5").update(e).digest("hex");
21011
+ function Hr(e) {
21012
+ return ye.createHash("md5").update(e).digest("hex");
20313
21013
  }
20314
- function Yt(e) {
21014
+ function Ur(e) {
20315
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;
20316
21016
  }
20317
- function Xt(e) {
21017
+ function Wr(e) {
20318
21018
  return e ? /font-style\s*:\s*italic/i.test(e) || /font-family\s*:\s*[^;]*\bItalic\b/i.test(e) : !1;
20319
21019
  }
20320
- function Zt(e) {
21020
+ function Gr(e) {
20321
21021
  if (!e || !/vertical-align\s*:\s*super/i.test(e)) return !1;
20322
21022
  let t = e.match(/font-size\s*:\s*([\d.]+)pt/i);
20323
21023
  return !(t && parseFloat(t[1]) < 8);
20324
21024
  }
20325
- function Qt(e) {
21025
+ function Kr(e) {
20326
21026
  return e ? /vertical-align\s*:\s*sub/i.test(e) : !1;
20327
21027
  }
20328
- function $t(e) {
21028
+ function qr(e) {
20329
21029
  if (!e) return;
20330
21030
  let t = [
20331
21031
  "width",
@@ -20360,15 +21060,15 @@ function $t(e) {
20360
21060
  }
20361
21061
  return n.length > 0 ? n.join("; ") : void 0;
20362
21062
  }
20363
- function en(e, t) {
21063
+ function Jr(e, t) {
20364
21064
  return !!(e && /text-align\s*:\s*center/i.test(e) || t && /center/i.test(t));
20365
21065
  }
20366
- function tn(e) {
21066
+ function Yr(e) {
20367
21067
  if (!e) return null;
20368
21068
  let t = e.match(/text-align\s*:\s*(left|center|right|justify)/i);
20369
21069
  return t ? t[1].toLowerCase() : null;
20370
21070
  }
20371
- function nn(e) {
21071
+ function Xr(e) {
20372
21072
  if (!e) return null;
20373
21073
  for (let [t, n] of [
20374
21074
  [/assnat1Tome|assnatAN1PARTIE/i, 1],
@@ -20380,73 +21080,73 @@ function nn(e) {
20380
21080
  ]) if (t.test(e)) return n;
20381
21081
  return null;
20382
21082
  }
20383
- function rn(t, n = {}) {
20384
- let { keepAlignment: r = !0, removeEmptyParagraphs: i = !0, strictAlineas: a = !1 } = n, o = e(t, { xml: { decodeEntities: !1 } });
20385
- o("style, script, meta, link").remove(), o(".assnatHeader, .assnatFooter, .assnatHeaderLeft, .assnatHeaderandFooter").remove(), o(".assnatFARSautApres, .assnatFARSautAvant, .assnatFARSautPageNiv0, .assnatFARSautPageNiv1, .assnatFARSautPageNiv1PG").remove(), o(".assnatFARTT08Bleu").each((e, t) => {
20386
- 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");
20387
21087
  n.length > 0 && n.remove();
20388
- }), o("table").each((e, t) => {
20389
- 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");
20390
21090
  if (r.length !== 1) return;
20391
21091
  let i = r.find("> td, > th");
20392
21092
  if (i.length !== 1) return;
20393
- let a = i.first();
20394
- if (a.find("h1, h2, h3, h4, h5, h6").length > 0) {
20395
- let e = a.attr("style") || "";
20396
- (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() || "");
20397
21097
  }
20398
- }), o("br[style*=\"page-break\"]").remove(), o("span[style*=\"position:absolute\"][style*=\"z-index:-65537\"]").each((e, t) => {
20399
- 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");
20400
21100
  if (r.length > 0) {
20401
21101
  let e = parseInt(r.attr("width") || "0", 10), t = parseInt(r.attr("height") || "0", 10);
20402
21102
  (e >= 50 || t >= 50) && n.remove();
20403
21103
  }
20404
- }), o("span[style*=\"position:absolute\"]").each((e, t) => {
20405
- 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");
20406
21106
  if (i.length !== 0 && !(n.parents("del").length > 0 || n.find("del img").length > 0) && !(i.parent("del").length > 0)) {
20407
21107
  let e = i.attr();
20408
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")) {
20409
- let t = (e.src || "").match(/^data:image\/png;base64,(.+)$/), r = t ? Jt(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}"` : "";
20410
21110
  n.replaceWith(`<span class="alinea"${i}></span>`);
20411
21111
  return;
20412
21112
  }
20413
21113
  }
20414
- }), o("span[style*=\"position:absolute\"]").each((e, t) => {
20415
- 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");
20416
21116
  if (i.length > 0 && n.children().length === 1 && r.includes("height:0pt")) {
20417
21117
  let e = parseInt(i.attr("width") || "0", 10), t = parseInt(i.attr("height") || "0", 10);
20418
21118
  e < 100 || t < 100 ? n.remove() : n.replaceWith(i);
20419
21119
  }
20420
- }), o("img").each((e, t) => {
20421
- 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);
20422
21122
  r < 100 || i < 100 ? n.remove() : n.removeAttr("style").removeAttr("class");
20423
- }), o("span[style*=\"height:0pt\"]:not(.alinea)").each((e, t) => {
20424
- 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();
20425
21125
  (!r || r === "\xA0") && n.remove();
20426
- }), o("span[style*=\"display:block\"][style*=\"position:absolute\"]:not(.alinea)").remove(), o("del").remove();
20427
- function s(e) {
20428
- let t = o(e), n = t.attr("style"), r = e.tagName?.toLowerCase() || "", i = Yt(n) || r === "b" || r === "strong", a = Xt(n) || r === "i" || r === "em", s = Zt(n) || r === "sup", c = Qt(n) || r === "sub", l = t.attr("class") || "";
20429
- 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), {
20430
21130
  bold: i,
20431
- italic: a,
21131
+ italic: o,
20432
21132
  sup: s,
20433
21133
  sub: c
20434
21134
  };
20435
21135
  }
20436
- function c(e, t) {
21136
+ function s(e, t) {
20437
21137
  let n = e;
20438
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;
20439
21139
  }
20440
- let l = o("span").length;
20441
- for (; l > 0;) {
20442
- o("span").each((e, t) => {
20443
- 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");
20444
21144
  if (u) {
20445
21145
  let e = n.html() || "";
20446
21146
  n.replaceWith(e);
20447
21147
  } else if (l) {
20448
21148
  let e = n.html() || "";
20449
- n.replaceWith(c(e, a));
21149
+ n.replaceWith(s(e, c));
20450
21150
  } else if (d) n.removeAttr("style");
20451
21151
  else if (f) n.removeAttr("style").removeAttr("class");
20452
21152
  else {
@@ -20454,76 +21154,76 @@ function rn(t, n = {}) {
20454
21154
  e.trim() === "" && e.length > 0 ? n.replaceWith(" ") : n.replaceWith(e);
20455
21155
  }
20456
21156
  });
20457
- let e = o("span").length;
20458
- if (e >= l) break;
20459
- l = e;
21157
+ let e = a("span").length;
21158
+ if (e >= c) break;
21159
+ c = e;
20460
21160
  }
20461
- for (o("p").each((e, t) => {
20462
- let n = o(t), i = n.attr("class") || "", a = n.attr("style"), s = nn(i);
21161
+ for (a("p").each((e, t) => {
21162
+ let r = a(t), i = r.attr("class") || "", o = r.attr("style"), s = Xr(i);
20463
21163
  if (i.includes("assnatFARCouvTitreD")) {
20464
- let e = n.html() || "";
20465
- n.replaceWith(`<p class="cover-subtitle">${e}</p>`);
21164
+ let e = r.html() || "";
21165
+ r.replaceWith(`<p class="cover-subtitle">${e}</p>`);
20466
21166
  return;
20467
21167
  }
20468
21168
  if (i.includes("assnatFARCouvTitre")) {
20469
- let e = n.html() || "";
20470
- n.replaceWith(`<p class="cover-title">${e}</p>`);
21169
+ let e = r.html() || "";
21170
+ r.replaceWith(`<p class="cover-title">${e}</p>`);
20471
21171
  return;
20472
21172
  }
20473
21173
  if (i.includes("assnatFPFprem")) {
20474
- let e = n.html() || "";
20475
- n.replaceWith(`<p class="cover-info">${e}</p>`);
21174
+ let e = r.html() || "";
21175
+ r.replaceWith(`<p class="cover-info">${e}</p>`);
20476
21176
  return;
20477
21177
  }
20478
21178
  if (i.includes("assnatFARCouvAnnee")) {
20479
- let e = n.html() || "";
20480
- n.replaceWith(`<p class="cover-year">${e}</p>`);
21179
+ let e = r.html() || "";
21180
+ r.replaceWith(`<p class="cover-year">${e}</p>`);
20481
21181
  return;
20482
21182
  }
20483
21183
  if (i.includes("assnatFPFexpogentitre1")) {
20484
- let e = n.html() || "";
20485
- n.replaceWith(`<p class="expose-motifs-titre">${e}</p>`);
21184
+ let e = r.html() || "";
21185
+ r.replaceWith(`<p class="expose-motifs-titre">${e}</p>`);
20486
21186
  return;
20487
21187
  }
20488
21188
  if (i.includes("assnatFPFexpogentexte")) {
20489
- n.removeAttr("style").attr("class", "expose-motifs-text");
21189
+ r.removeAttr("style").attr("class", "expose-motifs-text");
20490
21190
  return;
20491
21191
  }
20492
- let c = n.text().trim().startsWith("«");
21192
+ let c = r.text().trim().startsWith("«");
20493
21193
  if (s && !c) {
20494
- let e = o(`<h${s}>${n.html() || ""}</h${s}>`);
20495
- r && en(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);
20496
21196
  } else {
20497
- let e = qt(i), t;
20498
- if (r) {
20499
- let n = tn(a);
21197
+ let e = Vr(i), t;
21198
+ if (n) {
21199
+ let n = Yr(o);
20500
21200
  n && n !== "justify" && n !== "left" ? t = n : e?.align && (t = e.align);
20501
21201
  }
20502
- if (n.removeAttr("style").removeAttr("class"), t && n.attr("align", t), e?.bold) {
20503
- let e = n.html() || "";
20504
- 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>`);
20505
21205
  }
20506
21206
  }
20507
- }), o("h1, h2, h3, h4, h5, h6").each((e, t) => {
20508
- let n = o(t), i = n.attr("style"), a = n.attr("class");
20509
- r && en(i, a) ? (n.removeAttr("style").removeAttr("class"), n.attr("align", "center")) : n.removeAttr("style").removeAttr("class");
20510
- }), o("a").each((e, t) => {
20511
- let n = o(t), r = n.attr("href"), i = n.attr("id"), a = { ...t.attribs || {} };
20512
- 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);
20513
21213
  if (!r && !i) n.replaceWith(n.html() || "");
20514
21214
  else if (!r && i) {
20515
21215
  let e = n.html() || "";
20516
21216
  n.replaceWith(`<span id="${i}">${e}</span>`);
20517
21217
  }
20518
- }); o("div").length > 0;) o("div").each((e, t) => {
20519
- 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() || "";
20520
21220
  n.replaceWith(r);
20521
21221
  });
20522
- o(".expose-motifs-titre").each((e, t) => {
20523
- 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();
20524
21224
  for (; i.length > 0;) if (i.is("table") && i.find(".expose-motifs-text").length > 0) {
20525
21225
  i.find(".expose-motifs-text").each((e, t) => {
20526
- r.push(o(t).clone());
21226
+ r.push(a(t).clone());
20527
21227
  });
20528
21228
  let e = i;
20529
21229
  i = i.next(), e.remove();
@@ -20537,43 +21237,43 @@ function rn(t, n = {}) {
20537
21237
  i = i.next(), e.remove();
20538
21238
  } else break;
20539
21239
  if (r.length > 0) {
20540
- let e = o("<div class=\"expose-motifs\"></div>");
21240
+ let e = a("<div class=\"expose-motifs\"></div>");
20541
21241
  r.forEach((t) => {
20542
21242
  t.removeClass("expose-motifs-text"), e.append(t);
20543
21243
  }), n.after(e);
20544
21244
  }
20545
- }), o("br").each((e, t) => {
20546
- o(t).removeAttr("style").removeAttr("class");
20547
- }), o("table, tr, td, th, thead, tbody, tfoot").each((e, t) => {
20548
- let n = o(t), r = $t(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"));
20549
21249
  n.removeAttr("style").removeAttr("class"), r && n.attr("style", r);
20550
- }), o("td, th").each((e, t) => {
20551
- let n = o(t), r = n.children();
21250
+ }), a("td, th").each((e, t) => {
21251
+ let n = a(t), r = n.children();
20552
21252
  if (r.length === 1 && r.first().is("p")) {
20553
- let e = r.first(), t = n.html() || "", i = o.html(e);
21253
+ let e = r.first(), t = n.html() || "", i = a.html(e);
20554
21254
  if (t.trim() === i.trim()) {
20555
21255
  let t = e.attr("align"), r = e.attr("id");
20556
21256
  n.html(e.html() || ""), t && !n.attr("align") && n.attr("align", t), r && !n.attr("id") && n.attr("id", r);
20557
21257
  }
20558
21258
  }
20559
- }), o("ol, ul").each((e, t) => {
20560
- let n = o(t), r = n.attr("start");
21259
+ }), a("ol, ul").each((e, t) => {
21260
+ let n = a(t), r = n.attr("start");
20561
21261
  if (n.removeAttr("style").removeAttr("class"), r) {
20562
21262
  let e = parseInt(r, 10);
20563
21263
  !isNaN(e) && e > 1 && n.attr("style", `counter-reset: list-counter ${e - 1}`), n.attr("start", r);
20564
21264
  }
20565
- }), o("li").each((e, t) => {
20566
- let n = o(t), r = tn(n.attr("style"));
21265
+ }), a("li").each((e, t) => {
21266
+ let n = a(t), r = Yr(n.attr("style"));
20567
21267
  n.removeAttr("style").removeAttr("class"), r === "center" && n.attr("style", "text-align: center");
20568
- let i = n.html() || "", a = i.replace(/^(\s|&#xa0;|&#160;|\u00a0)+/, "");
20569
- a !== i && n.html(a);
20570
- }), an(o), on(o, a);
20571
- 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 = "";
20572
- h && (g += Gt), p && (g += Ht), m && (g += Ut), d && (g += Vt), f && (g += Wt);
20573
- let _ = g ? `<style>${g}</style>\n${u}` : u;
20574
- 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, ""), _ = sn(_), _ = _.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(), _;
20575
21275
  }
20576
- function an(e) {
21276
+ function Qr(e) {
20577
21277
  e("span[id]").each((t, n) => {
20578
21278
  let r = e(n), i = r.attr("id"), a = n.attribs || {}, o = Object.keys(a);
20579
21279
  if (o.length !== 1 || o[0] !== "id") return;
@@ -20596,13 +21296,13 @@ function an(e) {
20596
21296
  l.trim() === u.trim() && (s.attr("id", i), r.replaceWith(r.html() || ""));
20597
21297
  });
20598
21298
  }
20599
- function on(e, t = !1) {
21299
+ function $r(e, t = !1) {
20600
21300
  let n = e("body");
20601
21301
  if (n.length === 0) return;
20602
21302
  let r = n.find("span.alinea[data-image-hash]"), i = -1;
20603
21303
  r.each((n, r) => {
20604
21304
  let a = e(r), o = a.attr("data-image-hash"), s;
20605
- if (o && Bt[o] !== void 0 && (s = Bt[o]), s === void 0) {
21305
+ if (o && Pr[o] !== void 0 && (s = Pr[o]), s === void 0) {
20606
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".`);
20607
21307
  a.remove();
20608
21308
  return;
@@ -20614,11 +21314,11 @@ function on(e, t = !1) {
20614
21314
  i = s, a.attr("data-alinea", String(s)), a.text(String(s)), a.removeAttr("data-image-hash");
20615
21315
  });
20616
21316
  }
20617
- function sn(e) {
21317
+ function ei(e) {
20618
21318
  let t = e;
20619
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;
20620
21320
  }
20621
- function cn(e, t = {}) {
21321
+ function ti(e, t = {}) {
20622
21322
  return `<!DOCTYPE html>
20623
21323
  <html lang="fr">
20624
21324
  <head>
@@ -20626,33 +21326,33 @@ function cn(e, t = {}) {
20626
21326
  <title>Document simplifié</title>
20627
21327
  </head>
20628
21328
  <body>
20629
- ${rn(e, t)}
21329
+ ${Zr(e, t)}
20630
21330
  </body>
20631
21331
  </html>`;
20632
21332
  }
20633
21333
  //#endregion
20634
21334
  //#region src/lib/server/text_parsers/transformers.ts
20635
- function Q(e, t) {
21335
+ function ni(e, t) {
20636
21336
  let n = "transformation_", r = {};
20637
- 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")) {
20638
21338
  let i = e.slice(15, -5), a = i.split(".").map((e) => parseInt(e) - 1), o = r;
20639
21339
  for (let e of a.slice(1)) {
20640
21340
  let t = o.transformations ??= [];
20641
21341
  for (; e >= t.length;) t.push({});
20642
21342
  o = t[e];
20643
21343
  }
20644
- o.output = g.readFileSync(_.join(t, `${n}${i}.html`), { encoding: "utf-8" });
20645
- 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" });
20646
21346
  o.sourceMap = s ?? [], o.title = c;
20647
21347
  }
20648
- return ln(r, e), r;
21348
+ return ri(r, e), r;
20649
21349
  }
20650
- function ln(e, t) {
20651
- if (e.input = t, e.transformations !== void 0) for (let n of e.transformations) ln(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;
20652
21352
  return t;
20653
21353
  }
20654
- function $(e, t, n = "1") {
20655
- 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`), {
20656
21356
  sourceMap: e.sourceMap,
20657
21357
  title: e.title
20658
21358
  }, {
@@ -20660,72 +21360,72 @@ function $(e, t, n = "1") {
20660
21360
  spaces: 2
20661
21361
  });
20662
21362
  else {
20663
- g.writeJsonSync(_.join(t, `transformation_${n}.json`), { title: e.title }, {
21363
+ A.writeJsonSync(j.join(t, `transformation_${n}.json`), { title: e.title }, {
20664
21364
  encoding: "utf-8",
20665
21365
  spaces: 2
20666
21366
  });
20667
- 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}`);
20668
21368
  }
20669
- 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" });
20670
21370
  }
20671
21371
  //#endregion
20672
21372
  //#region src/lib/server/linkers/html.ts
20673
- async function un({ 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 }) {
20674
- let x = t ?? (e === void 0 ? void 0 : new o(e));
20675
- if (x === void 0) throw Error("A Canutes database or legal resolver is required");
20676
- let S = await g.readFile(i, { encoding: "utf-8" }), C;
20677
- c === void 0 ? (C = s({ removeAWithHref: !0 })(S), l !== void 0 && $(C, l)) : C = Q(S, c);
20678
- let w = [];
20679
- u !== void 0 && w.push("links"), d !== void 0 && w.push("links_or_references"), p !== void 0 && w.push("references");
20680
- let { outputByType: T, referredLegifranceTextCountByCid: E } = await a({
20681
- 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,
20682
21382
  date: n,
20683
21383
  defaultTextId: r,
20684
- htmlTransformation: C,
20685
- inputHtml: S,
20686
- linkBaseUrl: m,
20687
- linkType: h,
20688
- logIgnoredReferencesTypes: _,
20689
- logPartialReferences: v,
20690
- logReferences: y,
20691
- outputTypes: w,
20692
- referredLegifranceTextsInfos: b !== void 0
20693
- }), D = {};
20694
- u !== void 0 && (D.links = u), d !== void 0 && (D.links_or_references = d), p !== void 0 && (D.references = p);
20695
- for (let [e, t] of Object.entries(T)) {
20696
- let n = D[e];
20697
- 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" });
20698
21398
  }
20699
- 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, {
20700
21400
  encoding: "utf-8",
20701
21401
  spaces: 2
20702
21402
  });
20703
21403
  }
20704
21404
  //#endregion
20705
21405
  //#region src/lib/server/tables_of_contents.ts
20706
- async function dn(e, n, r, i) {
20707
- 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" });
20708
- for await (let e of t({
20709
- context: s,
20710
- tableOfContents: c,
20711
- 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
20712
21412
  }));
20713
- await g.writeJson(i, c, {
21413
+ await A.writeJson(r, s, {
20714
21414
  encoding: "utf-8",
20715
21415
  spaces: 2
20716
21416
  });
20717
21417
  }
20718
- async function fn(e, t, n) {
20719
- let i = Q(await g.readFile(e, { encoding: "utf-8" }), t).output, a = r(i);
20720
- 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, {
20721
21421
  encoding: "utf-8",
20722
21422
  spaces: 2
20723
21423
  });
20724
21424
  }
20725
21425
  //#endregion
20726
21426
  //#region src/lib/server/legi/resolvers.ts
20727
- function pn({ canutesDb: e }) {
20728
- return new o(e);
21427
+ function ci({ canutesDb: e }) {
21428
+ return new h(e);
20729
21429
  }
20730
21430
  //#endregion
20731
- export { f as LegiResolver, un as addLinksOrReferencesToHtmlFile, dn as addPositionsToTableOfContentsFile, d as buildAndInstallTextTitlesInfos, l as buildTextTitlesInfos, pn as createLegiResolver, x as extractAssembleeAmendmentSearchItems, Y as extractAssembleeExposesDesMotifs, kt as extractSenatAmendmentSearchItems, S as hashAssembleeAmendmentSearchItem, Et as hashAssembleeSearchItem, At as hashSenatAmendmentSearchItem, Pt as hashSenatSearchItem, zt as isAkomaNtosoXml, Dt as isoDateFromAssembleeDocument, St as linkAkomaNtosoBillRaw, ze as linkAssembleeBillRaw, xt as parseAkomaNtosoBillRaw, Re as parseAssembleeBillRaw, Tt as parseAssembleeDocumentSearchContent, Nt as parseSenatDocumentSearchContent, Q as readTransformation, _t as renderAkomaNtosoBillRaw, Rt as resolveSenatAkomaNtosoSource, fn as simplifiedHtmlBillFileToTableOfContentsFile, rn as simplifyWordHtml, cn 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 };