@tricoteuses/tisseuse 0.13.7 → 0.13.9

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 (31) hide show
  1. package/README.md +39 -35
  2. package/dist/{textes-BIJjrNwg.js → html-DhGw-Yqr.js} +3875 -5243
  3. package/dist/index.js +280 -147
  4. package/dist/resolver-DZS-DNp6.js +1848 -0
  5. package/dist/server-f-legi.js +532 -0
  6. package/dist/server.js +530 -2161
  7. package/dist/src/lib/extractors/links.d.ts +6 -4
  8. package/dist/src/lib/f_legi/resolver.d.ts +5 -7
  9. package/dist/src/lib/index.d.ts +2 -0
  10. package/dist/src/lib/legi/canutes_resolver.d.ts +5 -6
  11. package/dist/src/lib/legi/resolver.d.ts +15 -12
  12. package/dist/src/lib/legi/resolver.test.d.ts +1 -0
  13. package/dist/src/lib/legi/text_titles_infos.d.ts +26 -0
  14. package/dist/src/lib/linkers/html.d.ts +15 -4
  15. package/dist/src/lib/linkers/markdown.d.ts +4 -2
  16. package/dist/src/lib/server/databases/index.d.ts +1 -1
  17. package/dist/src/lib/server/f_legi/index.d.ts +1 -0
  18. package/dist/src/lib/server/index.d.ts +2 -1
  19. package/dist/src/lib/server/judilibre_search.d.ts +31 -0
  20. package/dist/src/lib/server/judilibre_search.test.d.ts +1 -0
  21. package/dist/src/lib/server/legi/resolvers.d.ts +2 -7
  22. package/dist/src/lib/server/linkers/html.d.ts +4 -2
  23. package/dist/src/scripts/enrich_senat_documents.d.ts +1 -0
  24. package/dist/src/scripts/index_postgres_judilibre.d.ts +1 -0
  25. package/package.json +8 -1
  26. package/dist/src/lib/f_legi/extractors/links.d.ts +0 -134
  27. package/dist/src/lib/f_legi/linkers/html.d.ts +0 -51
  28. package/dist/src/lib/server/f_legi/databases/index.d.ts +0 -2
  29. package/dist/src/lib/server/f_legi/linkers/html.d.ts +0 -20
  30. package/dist/src/scripts/f_legi/add_links_to_html_document.d.ts +0 -0
  31. /package/dist/src/{scripts/extract_texts_titles_infos.d.ts → lib/f_legi/resolver.test.d.ts} +0 -0
package/dist/server.js CHANGED
@@ -1,12 +1,11 @@
1
- import { $t as e, A as t, Dn as n, Jn as r, L as i, Qn as a, Xn as o, Yn as s, Zn as c, a as l, an as u, c as d, dt as f, fn as p, ft as m, g as h, in as g, l as _, lt as v, nt as ee, pt as y, rt as b, st as te, t as x, u as S, x as ne } from "./textes-BIJjrNwg.js";
2
- import * as re from "node:crypto";
3
- import { createHash as C } from "node:crypto";
4
- import w from "fs-extra";
5
- import T from "node:path";
6
- import { fileURLToPath as ie } from "node:url";
7
- import ae from "postgres";
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";
8
7
  //#region src/lib/server/assemblee_amendment_search.ts
9
- function E(e, t) {
8
+ function v(e, t) {
10
9
  let n = e;
11
10
  for (let e of t) {
12
11
  if (typeof n != "object" || !n) return null;
@@ -14,34 +13,34 @@ function E(e, t) {
14
13
  }
15
14
  return typeof n == "string" && n.trim() ? n.trim() : null;
16
15
  }
17
- function oe(e) {
16
+ function y(e) {
18
17
  return e.replace(/\u00a0/gu, " ").replace(/\s+/gu, " ").trim();
19
18
  }
20
- function se(e) {
21
- return oe(y(e).text());
19
+ function b(t) {
20
+ return y(e(t).text());
22
21
  }
23
- function ce(e) {
24
- let t = oe([
25
- E(e, [
22
+ function x(e) {
23
+ let t = y([
24
+ v(e, [
26
25
  "corps",
27
26
  "contenuAuteur",
28
27
  "dispositif"
29
28
  ]),
30
- E(e, [
29
+ v(e, [
31
30
  "corps",
32
31
  "contenuAuteur",
33
32
  "dispositifAmdtCreditPLF"
34
33
  ]),
35
- E(e, [
34
+ v(e, [
36
35
  "corps",
37
36
  "contenuAuteur",
38
37
  "dispositifAmdtCreditPLFR"
39
38
  ])
40
- ].filter((e) => e !== null).map((e) => se(e)).join("\n")), n = E(e, [
39
+ ].filter((e) => e !== null).map((e) => b(e)).join("\n")), n = v(e, [
41
40
  "corps",
42
41
  "contenuAuteur",
43
42
  "exposeSommaire"
44
- ]), r = n === null ? "" : se(n);
43
+ ]), r = n === null ? "" : b(n);
45
44
  return [...t ? [{
46
45
  content: t,
47
46
  itemKind: "dispositif",
@@ -52,1040 +51,28 @@ function ce(e) {
52
51
  label: "Exposé sommaire"
53
52
  }] : []];
54
53
  }
55
- function le(e, t) {
56
- return C("sha256").update(JSON.stringify({
54
+ function S(e, t) {
55
+ return h("sha256").update(JSON.stringify({
57
56
  item: e,
58
57
  metadata: t
59
58
  })).digest("hex");
60
59
  }
61
60
  //#endregion
62
- //#region src/lib/timings.ts
63
- var D = class {
64
- label;
65
- enabled;
66
- metrics = [];
67
- startedAt = performance.now();
68
- constructor(e, t = ue()) {
69
- this.label = e, this.enabled = t;
70
- }
71
- add(e) {
72
- this.enabled && (this.metrics.push(e), de() && console.info(`[timing:${this.label}]`, JSON.stringify(e)));
73
- }
74
- async time(e, t, n) {
75
- if (!this.enabled) return t();
76
- let r = performance.now();
77
- try {
78
- return await t();
79
- } finally {
80
- this.add({
81
- ...n,
82
- durationMs: Math.round((performance.now() - r) * 10) / 10,
83
- phase: e
84
- });
85
- }
86
- }
87
- timeSync(e, t, n) {
88
- if (!this.enabled) return t();
89
- let r = performance.now();
90
- try {
91
- return t();
92
- } finally {
93
- this.add({
94
- ...n,
95
- durationMs: Math.round((performance.now() - r) * 10) / 10,
96
- phase: e
97
- });
98
- }
99
- }
100
- log(e) {
101
- if (!this.enabled) return;
102
- let t = Math.round((performance.now() - this.startedAt) * 10) / 10;
103
- console.info(`[timings:${this.label}]`, JSON.stringify({
104
- ...e,
105
- totalMs: t,
106
- metricCount: this.metrics.length,
107
- metrics: this.metrics
108
- }, null, 2));
109
- }
110
- };
111
- function ue() {
112
- let e = globalThis.process?.env;
113
- return e?.PJL_BUILD_TIMINGS === "1" || e?.PJL_BUILD_TIMINGS === "true";
114
- }
115
- function de() {
116
- let e = globalThis.process?.env;
117
- return e?.PJL_BUILD_TIMINGS_PROGRESS === "1" || e?.PJL_BUILD_TIMINGS_PROGRESS === "true";
118
- }
119
- //#endregion
120
- //#region src/lib/f_legi/extractors/links.ts
121
- async function* fe({ context: e, date: t, flegiResolver: n, logIgnoredReferencesTypes: r, logPartialReferences: i, logReferences: a, state: o, transformation: s }) {
122
- let c = new D("f_legi.extractTextLinks"), l = {}, u = s === void 0 ? void 0 : te(s), d = o === void 0 ? {} : structuredClone(o), f = c.timeSync("extractReferences", () => {
123
- let t = [];
124
- for (let n of ne(e, { overlapWindowForCandidate: pe })) a && console.log(`In "${e.input.slice(n.position.start, n.position.stop)}": \nReference "${e.text(n.position)}": ${JSON.stringify(n, null, 2)}`), t.push(n);
125
- return t;
126
- }, { inputSize: e.input.length }), p = performance.now();
127
- for (let t of f) for (let n of M(e, t)) {
128
- let a = n.type === "parent-enfant" ? n.parent : n;
129
- switch (a.type) {
130
- case "alinéa":
131
- case "incomplete-header":
132
- case "item":
133
- case "phrase": break;
134
- case "article":
135
- a.definition && (d.textId === void 0 ? i && console.log(`In "${e.input.slice(t.position.start, t.position.stop)}": Missing state.textId for article definition`) : (l[d.textId] ??= {})[a.num] = Object.fromEntries(Object.entries({
136
- article: a,
137
- position: a.position,
138
- reference: t,
139
- textId: d.textId,
140
- type: "article_definition"
141
- }).filter(([, e]) => e !== void 0)));
142
- break;
143
- case "chapitre":
144
- case "livre":
145
- case "paragraphe":
146
- case "partie":
147
- case "section":
148
- case "sous-paragraphe":
149
- case "sous-section":
150
- case "sous-sous-paragraphe":
151
- case "sous-titre":
152
- case "titre":
153
- a.definition && d.textId === void 0 && i && console.log(`In "${e.input.slice(t.position.start, t.position.stop)}": Missing state.textId for division definition`);
154
- break;
155
- case "texte":
156
- O({
157
- context: e,
158
- logPartialReferences: i,
159
- reference: t,
160
- state: d,
161
- text: a
162
- });
163
- break;
164
- default: r && (console.log(`In "${e.input.slice(t.position.start, t.position.stop)}": Reference ${JSON.stringify(a, null, 2)} ignored`), console.log(JSON.stringify(t, null, 2)));
165
- }
166
- }
167
- c.add({
168
- durationMs: Math.round((performance.now() - p) * 10) / 10,
169
- phase: "collectDefinitionsAndTextState"
170
- });
171
- let m = /* @__PURE__ */ new Set();
172
- for (let e of f) for (let t of j(e, { citations: !0 })) m.add(t);
173
- let h = me(e, f);
174
- ve(n) && await c.time("preloadActiveArticlesByTextIds", () => n.preloadActiveArticlesByTextIds({
175
- date: t,
176
- nums: m,
177
- textIds: h
178
- }), { count: h.size });
179
- let g = await c.time("collectUniqueFallbackArticleNums", () => he({
180
- context: e,
181
- date: t,
182
- flegiResolver: n,
183
- logPartialReferences: i,
184
- references: f,
185
- state: o === void 0 ? {} : structuredClone(o)
186
- }), { count: f.length });
187
- await c.time("preloadUniqueActiveArticlesByNums", () => n.preloadUniqueActiveArticlesByNums({
188
- date: t,
189
- nums: g
190
- }), { count: g.size }), d = o === void 0 ? {} : o;
191
- let _ = 0, v = performance.now();
192
- for (let a of f) for await (let o of xe({
193
- articleDefinitionByNumByTextId: l,
194
- flegiResolver: n,
195
- context: e,
196
- date: t,
197
- logIgnoredReferencesTypes: r,
198
- logPartialReferences: i,
199
- originalPositionsFromTransformedIterator: u,
200
- reference: a,
201
- state: d
202
- })) _++, yield o;
203
- c.add({
204
- count: _,
205
- durationMs: Math.round((performance.now() - v) * 10) / 10,
206
- phase: "iterReferenceLinks"
207
- }), c.log({ referenceCount: f.length });
208
- }
209
- function pe(e) {
210
- return /^[a-z]$/i.test(e) ? 0 : 80;
211
- }
212
- function O({ context: e, logPartialReferences: t, reference: n, state: i, text: a }) {
213
- switch (a.nature) {
214
- case "ARRETE":
215
- case "CIRCULAIRE":
216
- case "CONVENTION":
217
- case "DECRET_LOI":
218
- delete i.textId;
219
- break;
220
- case "ARRETEURO":
221
- case "AVISEURO":
222
- case "DECISION_EURO":
223
- case "DECLARATIONEURO":
224
- case "DELIBERATIONEURO":
225
- case "DIRECTIVE_EURO":
226
- case "INFORMATIONEURO":
227
- case "INSTRUCTIONEURO":
228
- case "LETTREEURO":
229
- case "REGLEMENTEUROPEEN":
230
- delete i.textId;
231
- break;
232
- case "CODE":
233
- if (a.relative === 0 && i.codeId !== void 0) {
234
- i.textId = i.codeId;
235
- break;
236
- }
237
- if (a.cid === void 0) {
238
- t && console.log(`In "${e.input.slice(n.position.start, n.position.stop)}": Missing CID of ${a.nature} reference ${JSON.stringify(a, null, 2)}`), delete i.textId;
239
- break;
240
- }
241
- i.textId = i.codeId = a.cid;
242
- break;
243
- case "CONSTITUTION":
244
- if (a.relative === 0 && i.constitutionId !== void 0) {
245
- i.textId = i.constitutionId;
246
- break;
247
- }
248
- if (a.cid === void 0) {
249
- t && console.log(`In "${e.input.slice(n.position.start, n.position.stop)}": Missing CID of ${a.nature} reference ${JSON.stringify(a, null, 2)}`), delete i.textId;
250
- break;
251
- }
252
- i.textId = i.constitutionId = a.cid;
253
- break;
254
- case "DECRET":
255
- if (a.relative === 0 && i.decreeId !== void 0) {
256
- i.textId = i.decreeId;
257
- break;
258
- }
259
- if (a.cid === void 0) {
260
- t && console.log(`In "${e.input.slice(n.position.start, n.position.stop)}": Missing CID of ${a.nature} reference ${JSON.stringify(a, null, 2)}`), delete i.textId;
261
- break;
262
- }
263
- i.textId = i.decreeId = a.cid;
264
- break;
265
- case "LOI":
266
- case "LOI_CONSTIT":
267
- case "LOI_ORGANIQUE":
268
- case "ORDONNANCE":
269
- if (a.relative === 0 && i.lawId !== void 0) {
270
- i.textId = i.lawId;
271
- break;
272
- }
273
- if (a.cid === void 0) {
274
- t && console.log(`In "${e.input.slice(n.position.start, n.position.stop)}": Missing CID of ${a.nature} reference ${JSON.stringify(a, null, 2)}`), delete i.textId;
275
- break;
276
- }
277
- i.textId = i.lawId = a.cid;
278
- break;
279
- default: a.nature === void 0 ? delete i.textId : r("nature", a.nature);
280
- }
281
- }
282
- function me(e, t) {
283
- let n = /* @__PURE__ */ new Set();
284
- for (let r of t) for (let t of M(e, r, { citations: !0 })) {
285
- let e = t.type === "parent-enfant" ? t.parent : t;
286
- e.type === "texte" && e.cid !== void 0 ? n.add(e.cid) : e.type === "article" && e.implicitText?.cid !== void 0 && n.add(e.implicitText.cid);
287
- }
288
- return n;
289
- }
290
- async function he({ context: e, date: t, flegiResolver: n, logPartialReferences: r, references: i, state: a }) {
291
- let o = /* @__PURE__ */ new Set();
292
- for (let s of i) await k({
293
- articleNums: o,
294
- context: e,
295
- date: t,
296
- flegiResolver: n,
297
- logPartialReferences: r,
298
- reference: s,
299
- state: a
300
- });
301
- return o;
302
- }
303
- async function k({ articleNums: e, context: t, date: n, flegiResolver: r, logPartialReferences: i, reference: a, state: o }) {
304
- for (let s of M(t, a)) await ge({
305
- articleNums: e,
306
- atomicOrParentChildReference: s,
307
- context: t,
308
- date: n,
309
- flegiResolver: r,
310
- logPartialReferences: i,
311
- reference: a,
312
- state: o
313
- });
314
- if (a.type === "reference_et_action") {
315
- let { originalCitations: s } = a.action;
316
- if (s !== void 0) {
317
- for (let a of s) if (a.references !== void 0) {
318
- let s = structuredClone(o);
319
- for (let o of a.references) await k({
320
- articleNums: e,
321
- context: t,
322
- date: n,
323
- flegiResolver: r,
324
- logPartialReferences: i,
325
- reference: o,
326
- state: s
327
- });
328
- }
329
- }
330
- }
331
- }
332
- async function ge({ articleNums: e, atomicOrParentChildReference: t, context: n, date: r, flegiResolver: i, logPartialReferences: a, reference: o, state: s }) {
333
- let c = t.type === "parent-enfant" ? t.parent : t, l = t.type === "parent-enfant" ? t : void 0;
334
- switch (c.type) {
335
- case "alinéa":
336
- case "incomplete-header":
337
- case "item":
338
- case "phrase": break;
339
- case "article":
340
- if (c.definition && s.textId !== void 0) break;
341
- await _e({
342
- article: c,
343
- date: r,
344
- flegiResolver: i,
345
- state: s
346
- }) && e.add(c.num);
347
- break;
348
- case "chapitre":
349
- case "livre":
350
- case "paragraphe":
351
- case "partie":
352
- case "section":
353
- case "sous-paragraphe":
354
- case "sous-section":
355
- case "sous-sous-paragraphe":
356
- case "sous-titre":
357
- case "titre":
358
- if (c.definition && s.textId !== void 0) break;
359
- l !== void 0 && await k({
360
- articleNums: e,
361
- context: n,
362
- date: r,
363
- flegiResolver: i,
364
- logPartialReferences: a,
365
- reference: l.child,
366
- state: s
367
- });
368
- break;
369
- case "texte":
370
- O({
371
- context: n,
372
- logPartialReferences: a,
373
- reference: o,
374
- state: s,
375
- text: c
376
- }), l !== void 0 && await k({
377
- articleNums: e,
378
- context: n,
379
- date: r,
380
- flegiResolver: i,
381
- logPartialReferences: a,
382
- reference: l.child,
383
- state: s
384
- });
385
- break;
386
- default: break;
387
- }
388
- }
389
- async function _e({ article: e, date: t, flegiResolver: n, state: r }) {
390
- if (e.present || e.num === void 0) return !1;
391
- let i = e.implicitText?.cid ?? r.textId;
392
- return !(i !== void 0 && (await n.getActiveArticlesByTextAndNum({
393
- date: t,
394
- num: e.num,
395
- textId: i
396
- })).length > 0 || r.defaultTextId !== void 0 && r.defaultTextId !== i && (await n.getActiveArticlesByTextAndNum({
397
- date: t,
398
- num: e.num,
399
- textId: r.defaultTextId
400
- })).length > 0);
401
- }
402
- function ve(e) {
403
- return "preloadActiveArticlesByTextIds" in e;
404
- }
405
- async function* A({ ancestors: e, article: t, flegiResolver: n, context: r, date: i, logPartialReferences: a, originalPositionsFromTransformedIterator: o, reference: s, state: c }) {
406
- if (t.present) return;
407
- let l = [], u = t.implicitText?.cid ?? c.textId;
408
- if (u !== void 0 && (l = await n.getActiveArticlesByTextAndNum({
409
- date: i,
410
- num: t.num,
411
- textId: u
412
- })), l.length === 0 && c.defaultTextId !== void 0 && c.defaultTextId !== u && (l = await n.getActiveArticlesByTextAndNum({
413
- date: i,
414
- num: t.num,
415
- textId: c.defaultTextId
416
- })), l.length === 0 && t.num !== void 0 && (l = await n.getUniqueActiveArticlesByNum({
417
- date: i,
418
- num: t.num
419
- }), l.length !== 0 && l.reduce((e, { textId: t }) => (t !== null && e.add(t), e), /* @__PURE__ */ new Set()).size > 1 && (l = [])), l.length === 0) a && console.warn(`In "${r.input.slice(t.position.start, t.position.stop)}": Unknown article ${t.num ?? null} of text ${u} for reference ${JSON.stringify(t, null, 2)}`), delete c.articleId;
420
- else if (l.length === 1) c.articleId = l[0].id;
421
- else {
422
- let e = l.filter(({ dateDebut: e, dateFin: t }) => e <= i && t > i);
423
- e.length === 1 ? c.articleId = e[0].id : (e.length !== 0 && (l = e), e = l.filter(({ id: e }) => !c.textId?.startsWith("JORF") || e.startsWith("JORF")), e.length === 1 ? c.articleId = e[0].id : (e.length !== 0 && (l = e), a && console.warn(`In "${r.input.slice(t.position.start, t.position.stop)}": Unable to filter article ${t.num ?? null} of text ${c.textId ?? null} among IDs ${JSON.stringify(l.map(({ id: e }) => e), null, 2)} for reference ${JSON.stringify(t, null, 2)}`), delete c.articleId));
424
- }
425
- let d = e === void 0 ? t.position : t.position.start < e[0].position.start ? {
426
- start: t.position.start,
427
- stop: e[0].position.stop
428
- } : {
429
- start: e[0].position.start,
430
- stop: t.position.stop
431
- };
432
- yield Object.fromEntries(Object.entries({
433
- article: t,
434
- articleId: c.articleId,
435
- originalTransformation: o === void 0 ? void 0 : v(o, d),
436
- position: d,
437
- reference: s,
438
- type: "external_article"
439
- }).filter(([, e]) => e !== void 0));
440
- }
441
- function* j(e, { citations: t = !1 } = {}) {
442
- switch (e.type) {
443
- case "article":
444
- e.num !== void 0 && (yield e.num);
445
- break;
446
- case "bounded-interval":
447
- yield* j(e.first, { citations: t }), yield* j(e.last, { citations: t });
448
- break;
449
- case "counted-interval":
450
- yield* j(e.first, { citations: t });
451
- break;
452
- case "enumeration":
453
- case "exclusion":
454
- yield* j(e.left, { citations: t }), yield* j(e.right, { citations: t });
455
- break;
456
- case "parent-enfant":
457
- yield* j(e.parent, { citations: t }), yield* j(e.child, { citations: t });
458
- break;
459
- case "reference_et_action":
460
- if (yield* j(e.reference, { citations: t }), t) {
461
- let { originalCitations: n } = e.action;
462
- if (n !== void 0) {
463
- for (let e of n) if (e.references !== void 0) for (let n of e.references) yield* j(n, { citations: t });
464
- }
465
- }
466
- break;
467
- }
468
- }
469
- function* M(e, t, { citations: n = !1 } = {}) {
470
- switch (t.type) {
471
- case "bounded-interval":
472
- yield* M(e, t.first, { citations: n }), yield* M(e, t.last, { citations: n });
473
- break;
474
- case "counted-interval":
475
- yield* M(e, t.first, { citations: n });
476
- break;
477
- case "enumeration":
478
- case "exclusion":
479
- yield* M(e, t.left, { citations: n }), yield* M(e, t.right, { citations: n });
480
- break;
481
- case "reference_et_action":
482
- if (yield* M(e, t.reference, { citations: n }), n) {
483
- let { originalCitations: r } = t.action;
484
- if (r !== void 0) {
485
- for (let t of r) if (t.references !== void 0) for (let r of t.references) yield* M(e, r, { citations: n });
486
- }
487
- }
488
- break;
489
- default: yield t;
490
- }
491
- }
492
- function* N(e, t) {
493
- if (t.type === "texte") console.error(`iterDeepestDivisionsOrArticles must not be called with a text:\n${JSON.stringify(t, null, 2)}`);
494
- else if (g(t) || t.type === "article") yield t;
495
- else if (!(u(t) || t.type === "incomplete-header")) switch (t.type) {
496
- case "bounded-interval":
497
- yield* N(e, t.first), yield* N(e, t.last);
498
- break;
499
- case "counted-interval":
500
- yield* N(e, t.first);
501
- break;
502
- case "enumeration":
503
- case "exclusion":
504
- yield* N(e, t.left), yield* N(e, t.right);
505
- break;
506
- case "parent-enfant": {
507
- let n = [...N(e, t.child)];
508
- n.length === 0 ? yield* N(e, t.parent) : yield* n;
509
- break;
510
- }
511
- case "reference_et_action": {
512
- yield* N(e, t.reference);
513
- let { originalCitations: n } = t.action;
514
- if (n !== void 0) {
515
- for (let t of n) if (t.references !== void 0) for (let n of t.references) yield* N(e, n);
516
- }
517
- break;
518
- }
519
- default: r("iterDeepestDivisionsOrArticles reference.type", t);
520
- }
521
- }
522
- function ye(e) {
523
- return e?.split(":")[0].trim().toLowerCase().split(/\s+/).map((e) => e.trim()).filter((e) => e !== "").join(" ");
524
- }
525
- async function* P({ ancestors: t, flegiResolver: n, context: r, date: i, division: a, divisionChildReference: o, logIgnoredReferencesTypes: s, logPartialReferences: c, originalPositionsFromTransformedIterator: l, parentSectionChildren: u, reference: d, state: f }) {
526
- if (a.present) return;
527
- let p;
528
- if (u === void 0 && f.textId !== void 0 && (u = await n.getDirectSectionChildren({
529
- date: i,
530
- parentPath: f.textId
531
- })), u !== void 0) {
532
- for (let e of u) {
533
- let t = ye(e.title);
534
- if (t !== void 0) {
535
- let n = !1;
536
- if (a.index !== void 0 && (n = be(a.type, a.index).some((e) => e === t)), !n && a.num !== void 0 && (n = `${a.type} ${a.num.toLowerCase()}` === t), n) {
537
- p = e;
538
- break;
539
- }
540
- }
541
- }
542
- if (p === void 0 && (p = u.find((t) => {
543
- let n = ye(t.title)?.split(/\s+/);
544
- return n !== void 0 && n.length === 2 && e.includes(n[0]) && n[1] === "législative";
545
- }), p !== void 0)) {
546
- let e = ye(p.title).split(/\s+/), t = {
547
- start: a.position.stop,
548
- stop: a.position.stop
549
- }, n = l === void 0 ? void 0 : v(l, t), r = Object.fromEntries(Object.entries({
550
- num: e[1],
551
- originalTransformation: n,
552
- position: t,
553
- type: e[0]
554
- }).filter(([, e]) => e !== void 0));
555
- o = Object.fromEntries(Object.entries({
556
- child: o ?? a,
557
- parent: r,
558
- originalTransformation: n,
559
- position: t,
560
- type: "parent-enfant"
561
- }).filter(([, e]) => e !== void 0)), a = r;
562
- }
563
- }
564
- let m = o === void 0 ? [] : [...N(r, o.child)], h = 0;
565
- if (o !== void 0) for (let e of M(r, o.child)) {
566
- let u = e.type === "parent-enfant" ? e.parent : e, g = e.type === "parent-enfant" ? e : void 0;
567
- switch (u.type) {
568
- case "alinéa":
569
- case "incomplete-header":
570
- case "item":
571
- case "phrase": break;
572
- case "article":
573
- yield* A({
574
- ancestors: m.length === 1 ? [...t ?? [], a] : void 0,
575
- article: u,
576
- flegiResolver: n,
577
- context: r,
578
- date: i,
579
- logPartialReferences: c,
580
- originalPositionsFromTransformedIterator: l,
581
- reference: d,
582
- state: f
583
- }), h++;
584
- break;
585
- case "chapitre":
586
- case "livre":
587
- case "paragraphe":
588
- case "partie":
589
- case "section":
590
- case "sous-paragraphe":
591
- case "sous-section":
592
- case "sous-sous-paragraphe":
593
- case "sous-titre":
594
- case "titre": {
595
- let e;
596
- p !== void 0 && (e = await n.getDirectSectionChildren({
597
- date: i,
598
- parentPath: p.path
599
- })), yield* P({
600
- ancestors: m.length === 1 ? [...t ?? [], a] : void 0,
601
- flegiResolver: n,
602
- context: r,
603
- date: i,
604
- division: u,
605
- divisionChildReference: g,
606
- logIgnoredReferencesTypes: s,
607
- logPartialReferences: c,
608
- originalPositionsFromTransformedIterator: l,
609
- parentSectionChildren: e,
610
- reference: d,
611
- state: f
612
- }), h++;
613
- break;
614
- }
615
- default: s && (console.log(`In "${r.input.slice(o.position.start, o.position.stop)}": Reference of type ${u.type} ignored in division`), console.log(JSON.stringify(o, null, 2)));
616
- }
617
- }
618
- if (h === 0) {
619
- f.sectionTaId = p?.id;
620
- let e = t === void 0 ? a.position : a.position.start < t[0].position.start ? {
621
- start: a.position.start,
622
- stop: t[0].position.stop
623
- } : {
624
- start: t[0].position.start,
625
- stop: a.position.stop
626
- };
627
- yield Object.fromEntries(Object.entries({
628
- division: a,
629
- originalTransformation: l === void 0 ? void 0 : v(l, e),
630
- position: e,
631
- reference: d,
632
- sectionTaId: f.sectionTaId,
633
- type: "external_division"
634
- }).filter(([, e]) => e !== void 0));
635
- }
636
- }
637
- function* be(e, t) {
638
- let n = Math.floor(t), r = Math.floor((t - n) * 1e3);
639
- if (r === 0) {
640
- for (let t of c(n)) yield `${t.toLowerCase()} ${e}`;
641
- for (let t of s(n)) yield `${e} ${t.toLowerCase()}`;
642
- } else for (let t of o(r)) {
643
- for (let r of c(n)) yield `${r.toLowerCase()} ${t} ${e}`;
644
- for (let r of s(n)) yield `${e} ${t} ${r.toLowerCase()}`;
645
- }
646
- }
647
- async function* xe({ articleDefinitionByNumByTextId: e, flegiResolver: t, context: n, date: r, logIgnoredReferencesTypes: i, logPartialReferences: a, originalPositionsFromTransformedIterator: o, reference: s, state: c }) {
648
- let l = e ?? {}, u = c === void 0 ? {} : c;
649
- for (let e of M(n, s)) {
650
- let c = e.type === "parent-enfant" ? e.parent : e, d = e.type === "parent-enfant" ? e : void 0;
651
- switch (c.type) {
652
- case "alinéa":
653
- case "incomplete-header":
654
- case "item":
655
- case "phrase": break;
656
- case "article":
657
- if (c.definition && u.textId !== void 0) {
658
- let e = l[u.textId]?.[c.num];
659
- e !== void 0 && (e.originalTransformation === void 0 && o !== void 0 && (e.originalTransformation = v(o, e.position)), yield e);
660
- } else yield* A({
661
- article: c,
662
- flegiResolver: t,
663
- context: n,
664
- date: r,
665
- logPartialReferences: a,
666
- originalPositionsFromTransformedIterator: o,
667
- reference: s,
668
- state: u
669
- });
670
- break;
671
- case "chapitre":
672
- case "livre":
673
- case "paragraphe":
674
- case "partie":
675
- case "section":
676
- case "sous-paragraphe":
677
- case "sous-section":
678
- case "sous-sous-paragraphe":
679
- case "sous-titre":
680
- case "titre":
681
- c.definition && u.textId !== void 0 || (yield* P({
682
- flegiResolver: t,
683
- context: n,
684
- date: r,
685
- division: c,
686
- divisionChildReference: d,
687
- logIgnoredReferencesTypes: i,
688
- logPartialReferences: a,
689
- originalPositionsFromTransformedIterator: o,
690
- reference: s,
691
- state: u
692
- }));
693
- break;
694
- case "texte": {
695
- O({
696
- context: n,
697
- logPartialReferences: a,
698
- reference: s,
699
- state: u,
700
- text: c
701
- });
702
- let e = d === void 0 ? [] : [...N(n, d.child)], l = 0;
703
- if (d !== void 0) for (let f of M(n, d.child)) {
704
- let p = f.type === "parent-enfant" ? f.parent : f, m = f.type === "parent-enfant" ? f : void 0;
705
- switch (p.type) {
706
- case "alinéa":
707
- case "incomplete-header":
708
- case "item":
709
- case "phrase": break;
710
- case "article":
711
- yield* A({
712
- ancestors: e.length === 1 ? [c] : void 0,
713
- article: p,
714
- flegiResolver: t,
715
- context: n,
716
- date: r,
717
- logPartialReferences: a,
718
- originalPositionsFromTransformedIterator: o,
719
- reference: s,
720
- state: u
721
- }), l++;
722
- break;
723
- case "chapitre":
724
- case "livre":
725
- case "paragraphe":
726
- case "partie":
727
- case "section":
728
- case "sous-paragraphe":
729
- case "sous-section":
730
- case "sous-sous-paragraphe":
731
- case "sous-titre":
732
- case "titre": {
733
- let d;
734
- u.textId !== void 0 && (d = await t.getDirectSectionChildren({
735
- date: r,
736
- parentPath: u.textId
737
- })), yield* P({
738
- ancestors: e.length === 1 ? [c] : void 0,
739
- flegiResolver: t,
740
- context: n,
741
- date: r,
742
- division: p,
743
- divisionChildReference: m,
744
- logIgnoredReferencesTypes: i,
745
- logPartialReferences: a,
746
- originalPositionsFromTransformedIterator: o,
747
- parentSectionChildren: d,
748
- reference: s,
749
- state: u
750
- }), l++;
751
- break;
752
- }
753
- default: i && (console.log(`In "${n.input.slice(s.position.start, d.position.stop)}": Reference of type ${p.type} ignored in text`), console.log(JSON.stringify(d, null, 2)));
754
- }
755
- }
756
- if (l === 0) {
757
- if (c.position === void 0) throw Error(`Position missing in atomic reference: ${c}`);
758
- yield Object.fromEntries(Object.entries({
759
- originalTransformation: o === void 0 ? void 0 : v(o, c.position),
760
- position: c.position,
761
- reference: s,
762
- text: c,
763
- type: "external_text"
764
- }).filter(([, e]) => e !== void 0));
765
- }
766
- break;
767
- }
768
- default: i && (console.log(`In "${n.input.slice(s.position.start, s.position.stop)}": Reference ${JSON.stringify(c, null, 2)} ignored`), console.log(JSON.stringify(s, null, 2)));
769
- }
770
- }
771
- if (s.type === "reference_et_action") {
772
- let { originalCitations: e } = s.action;
773
- if (e !== void 0) {
774
- for (let s of e) if (s.references !== void 0) {
775
- let e = structuredClone(u);
776
- for (let c of s.references) yield* xe({
777
- articleDefinitionByNumByTextId: l,
778
- flegiResolver: t,
779
- context: n,
780
- date: r,
781
- logIgnoredReferencesTypes: i,
782
- logPartialReferences: a,
783
- originalPositionsFromTransformedIterator: o,
784
- reference: c,
785
- state: e
786
- });
787
- }
788
- }
789
- }
790
- }
791
- //#endregion
792
- //#region src/lib/f_legi/linkers/html.ts
793
- async function Se({ legiResolver: e, date: t, html: i, linkBaseUrl: a, linkType: o, logIgnoredReferencesTypes: s, logPartialReferences: c, logReferences: l, onLink: u, previousContext: f, state: p }) {
794
- let m = new D("f_legi.addLinksToHtml");
795
- await m.time("preloadTextTitlesInfos", () => e.preloadTextTitlesInfos());
796
- let h = m.timeSync("simplifyHtml", () => ee({ removeAWithHref: !0 })(i), {
797
- inputSize: i.length,
798
- outputSize: void 0
799
- }), g = new n(h.output);
800
- g.currentArticle = f?.currentArticle, g.currentText = f?.currentText;
801
- let _ = [], v = { value: 0 }, y = -1;
802
- await m.time("extractTextLinks", async () => {
803
- for await (let n of fe({
804
- flegiResolver: e,
805
- context: g,
806
- date: t,
807
- logIgnoredReferencesTypes: s,
808
- logPartialReferences: c,
809
- logReferences: l,
810
- state: p,
811
- transformation: h
812
- })) if (y++, !(u !== void 0 && await u(n, y))) switch (n.type) {
813
- case "article_definition": {
814
- let { article: e, originalTransformation: t, textId: r } = n;
815
- if (t === void 0) throw Error(`Missing originalTransformation attribute in article definition: ${JSON.stringify(n, null, 2)}`);
816
- F({
817
- inputHtml: i,
818
- originalTransformation: t,
819
- output: { replacements: _ },
820
- replacementCounter: v,
821
- tagHtmlFromOriginal: (t) => `<span class="definition_article" id="definition_article_${r}_${e.num.replaceAll(" ", "_")}">${t}</span>`
822
- });
823
- break;
824
- }
825
- case "external_article": {
826
- let { articleId: e, originalTransformation: t } = n;
827
- if (e !== void 0) {
828
- if (t === void 0) throw Error(`Missing originalTransformation attribute in external article link: ${JSON.stringify(n, null, 2)}`);
829
- F({
830
- inputHtml: i,
831
- originalTransformation: t,
832
- output: { replacements: _ },
833
- replacementCounter: v,
834
- tagHtmlFromOriginal: (t) => `<a class="lien_article_externe" href="${d(o, a, e)}">${t}</a>`
835
- });
836
- }
837
- break;
838
- }
839
- case "external_division": {
840
- let { originalTransformation: e, sectionTaId: t } = n;
841
- if (t !== void 0) {
842
- if (e === void 0) throw Error(`Missing originalTransformation attribute in external division link: ${JSON.stringify(n, null, 2)}`);
843
- F({
844
- inputHtml: i,
845
- originalTransformation: e,
846
- output: { replacements: _ },
847
- replacementCounter: v,
848
- tagHtmlFromOriginal: (e) => `<a class="lien_division_externe" href="${d(o, a, t)}">${e}</a>`
849
- });
850
- }
851
- break;
852
- }
853
- case "external_text": {
854
- let { originalTransformation: e, text: t } = n;
855
- if (t.cid === void 0) {
856
- t.relative !== 0 && c && console.error(`Link to text "${g.text(t.position)}" without CID: ${JSON.stringify(t, null, 2)}`);
857
- continue;
858
- }
859
- if (e === void 0) throw Error(`Missing originalTransformation attribute in external text link: ${JSON.stringify(n, null, 2)}`);
860
- F({
861
- inputHtml: i,
862
- originalTransformation: e,
863
- output: { replacements: _ },
864
- replacementCounter: v,
865
- tagHtmlFromOriginal: (e) => `<a class="lien_texte_externe" href="${d(o, a, t.cid)}">${e}</a>`
866
- });
867
- break;
868
- }
869
- case "european_text": {
870
- let { url: e, originalTransformation: t } = n;
871
- if (e === void 0) continue;
872
- if (t === void 0) throw Error(`Missing originalTransformation attribute in european text link: ${JSON.stringify(n, null, 2)}`);
873
- F({
874
- inputHtml: i,
875
- originalTransformation: t,
876
- output: { replacements: _ },
877
- replacementCounter: v,
878
- tagHtmlFromOriginal: (t) => `<a class="lien_texte_european" href="${e}" target="_blank">${t}</a>`
879
- });
880
- break;
881
- }
882
- case "internal_article": {
883
- let { definition: e, originalTransformation: t } = n;
884
- if (t === void 0) throw Error(`Missing originalTransformation attribute in internal article link: ${JSON.stringify(n, null, 2)}`);
885
- F({
886
- inputHtml: i,
887
- originalTransformation: t,
888
- output: { replacements: _ },
889
- replacementCounter: v,
890
- tagHtmlFromOriginal: (t) => `<a class="lien_article_interne" href="#definition_article_${e.textId}_${e.article.num.replaceAll(" ", "_")}" style="background-color: #eae462">${t}</a>`
891
- });
892
- break;
893
- }
894
- default: r("Link", n);
895
- }
896
- }, { count: y + 1 });
897
- let b = m.timeSync("applyHtmlReplacements", () => Ce(i, _), {
898
- count: _.length,
899
- inputSize: i.length
900
- });
901
- return m.log({
902
- linkCount: y + 1,
903
- replacementCount: _.length
904
- }), {
905
- context: g,
906
- output: _.length === 0 ? null : b
907
- };
908
- }
909
- function Ce(e, t) {
910
- if (t.length === 0) return e;
911
- let n = [], r = 0;
912
- for (let i of t.toSorted((e, t) => e.start - t.start || e.stop - t.stop || e.order - t.order)) {
913
- if (i.start < r) {
914
- console.warn(`Skipping overlapping HTML replacement at ${i.start}-${i.stop}`);
915
- continue;
916
- }
917
- n.push(e.slice(r, i.start)), n.push(i.replacement), r = i.stop;
918
- }
919
- return n.push(e.slice(r)), n.join("");
920
- }
921
- function F({ inputHtml: e, originalTransformation: t, output: n, replacementCounter: r, tagHtmlFromOriginal: i }) {
922
- let a = m(t, i(f(e, t, 0) ?? ""));
923
- n.replacements.push({
924
- order: r.value++,
925
- replacement: a,
926
- start: t.position.start,
927
- stop: t.position.stop
928
- });
929
- }
930
- //#endregion
931
- //#region src/lib/legi/canutes_resolver.ts
932
- var we = T.dirname(ie(import.meta.url)), Te = [
933
- "src/lib/text_parsers/text_titles_infos.json",
934
- T.resolve(we, "../text_parsers/text_titles_infos.json"),
935
- T.resolve(we, "../src/lib/text_parsers/text_titles_infos.json")
936
- ];
937
- async function Ee(e) {
938
- if (e) return e;
939
- for (let e of Te) if (await w.pathExists(e)) return e;
940
- return Te[0];
941
- }
942
- function I(e) {
943
- return {
944
- dateDebut: e.dateDebut ?? "0001-01-01",
945
- dateFin: e.dateFin ?? "2999-01-01",
946
- id: e.id,
947
- num: e.num,
948
- textId: e.textId
949
- };
950
- }
951
- function De(e) {
952
- let t = e["@id"];
953
- return t === void 0 ? null : {
954
- dateDebut: e["@debut"] ?? null,
955
- dateFin: e["@fin"] ?? null,
956
- id: t,
957
- path: t,
958
- title: e["#text"] ?? null
959
- };
960
- }
961
- function Oe(e, t) {
962
- return (e.dateDebut === null || e.dateDebut <= t) && (e.dateFin === null || e.dateFin >= t);
963
- }
964
- var ke = class {
965
- canutesDb;
966
- options;
967
- articleRowsByNumByTextAndDate = /* @__PURE__ */ new Map();
968
- directSectionChildrenByParentAndDate = /* @__PURE__ */ new Map();
969
- globalArticleRowsByNumAndDate = /* @__PURE__ */ new Map();
970
- textIdBySegmentId = /* @__PURE__ */ new Map();
971
- textTitlesInfosLoaded = !1;
972
- constructor(e, t = {}) {
973
- this.canutesDb = e, this.options = t;
974
- }
975
- async getActiveArticlesByTextAndNum({ date: e, num: t, textId: n }) {
976
- if (t === void 0) return [];
977
- let r = `${n}\0${t}\0${e}`, i = this.articleRowsByNumByTextAndDate.get(r);
978
- return i === void 0 && (i = (await this.canutesDb`
979
- SELECT
980
- id,
981
- num,
982
- data -> 'CONTEXTE' -> 'TEXTE' ->> '@cid' AS "textId",
983
- data -> 'META' -> 'META_SPEC' -> 'META_ARTICLE' ->> 'DATE_DEBUT' AS "dateDebut",
984
- data -> 'META' -> 'META_SPEC' -> 'META_ARTICLE' ->> 'DATE_FIN' AS "dateFin"
985
- FROM legifrance.article
986
- WHERE
987
- data -> 'CONTEXTE' -> 'TEXTE' ->> '@cid' = ${n}
988
- AND num = ${t}
989
- `).map(I), this.articleRowsByNumByTextAndDate.set(r, i)), i;
990
- }
991
- async getDirectSectionChildren({ date: e, parentPath: t }) {
992
- let n = `${t}\0${e}`, r = this.directSectionChildrenByParentAndDate.get(n);
993
- if (r === void 0) {
994
- let i = (await this.canutesDb`
995
- SELECT data
996
- FROM legifrance.section_ta
997
- WHERE id = ${t}
998
- `)[0]?.data.STRUCTURE_TA?.LIEN_SECTION_TA;
999
- r = i === void 0 ? (await this.canutesDb`
1000
- SELECT data
1001
- FROM legifrance.textelr
1002
- WHERE id = ${t}
1003
- `)[0]?.data.STRUCT?.LIEN_SECTION_TA?.map(De).filter((e) => e !== null).filter((t) => Oe(t, e)) ?? [] : i.map(De).filter((e) => e !== null).filter((t) => Oe(t, e)), this.directSectionChildrenByParentAndDate.set(n, r);
1004
- }
1005
- return r;
1006
- }
1007
- async getTextIdFromSegmentId(e) {
1008
- let t = this.textIdBySegmentId.get(e);
1009
- return t === void 0 && (t = e.startsWith("LEGIARTI") || e.startsWith("JORFARTI") ? (await this.canutesDb`
1010
- SELECT data -> 'CONTEXTE' -> 'TEXTE' ->> '@cid' AS "textId"
1011
- FROM legifrance.article
1012
- WHERE id = ${e}
1013
- `)[0]?.textId ?? null : (await this.canutesDb`
1014
- SELECT data -> 'CONTEXTE' -> 'TEXTE' ->> '@cid' AS "textId"
1015
- FROM legifrance.section_ta
1016
- WHERE id = ${e}
1017
- `)[0]?.textId ?? null, this.textIdBySegmentId.set(e, t)), t ?? void 0;
1018
- }
1019
- async getUniqueActiveArticlesByNum({ date: e, num: t }) {
1020
- if (t === void 0) return [];
1021
- let n = `${t}\0${e}`, r = this.globalArticleRowsByNumAndDate.get(n);
1022
- return r === void 0 && (r = (await this.canutesDb`
1023
- SELECT
1024
- id,
1025
- num,
1026
- data -> 'CONTEXTE' -> 'TEXTE' ->> '@cid' AS "textId",
1027
- data -> 'META' -> 'META_SPEC' -> 'META_ARTICLE' ->> 'DATE_DEBUT' AS "dateDebut",
1028
- data -> 'META' -> 'META_SPEC' -> 'META_ARTICLE' ->> 'DATE_FIN' AS "dateFin"
1029
- FROM legifrance.article
1030
- WHERE num = ${t}
1031
- LIMIT 100
1032
- `).map(I), this.globalArticleRowsByNumAndDate.set(n, r)), r;
1033
- }
1034
- async preloadTextTitlesInfos(e = {}) {
1035
- let t = (t, n = {}) => {
1036
- e.onProgress?.({
1037
- ...n,
1038
- phase: t,
1039
- resolver: "canutes"
1040
- });
1041
- };
1042
- if (this.textTitlesInfosLoaded) {
1043
- t("already-loaded");
1044
- return;
1045
- }
1046
- t("resolveJsonPath:start");
1047
- let n = await Ee(this.options.textTitlesInfosPath);
1048
- t("resolveJsonPath:done", { detail: n }), t("readJson:start", { detail: n });
1049
- let r = await w.stat(n), a = await w.readJson(n);
1050
- t("readJson:done", {
1051
- count: r.size,
1052
- detail: n
1053
- }), t("setTextTitlesInfos:start"), i(a), t("setTextTitlesInfos:done"), this.textTitlesInfosLoaded = !0;
1054
- }
1055
- async preloadUniqueActiveArticlesByNums({ date: e, nums: t }) {
1056
- let n = [...new Set([...t].filter(Boolean))].filter((t) => !this.globalArticleRowsByNumAndDate.has(`${t}\0${e}`));
1057
- if (n.length === 0) return;
1058
- let r = (await this.canutesDb`
1059
- SELECT
1060
- id,
1061
- num,
1062
- data -> 'CONTEXTE' -> 'TEXTE' ->> '@cid' AS "textId",
1063
- data -> 'META' -> 'META_SPEC' -> 'META_ARTICLE' ->> 'DATE_DEBUT' AS "dateDebut",
1064
- data -> 'META' -> 'META_SPEC' -> 'META_ARTICLE' ->> 'DATE_FIN' AS "dateFin"
1065
- FROM legifrance.article
1066
- WHERE num IN ${this.canutesDb(n)}
1067
- `).map(I), i = /* @__PURE__ */ new Map();
1068
- for (let e of r) {
1069
- if (e.num === null) continue;
1070
- let t = i.get(e.num);
1071
- t === void 0 ? i.set(e.num, [e]) : t.length < 100 && t.push(e);
1072
- }
1073
- for (let t of n) this.globalArticleRowsByNumAndDate.set(`${t}\0${e}`, i.get(t) ?? []);
1074
- }
1075
- }, Ae = /\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, je = /^article\s+(.+?)(?:\s*[::]\s*(.+))?$/iu, Me = /^expos[ée]\s+des\s+motifs\b/iu;
1076
- function L(e) {
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) {
1077
64
  return (e ?? "").replace(/\u00a0/g, " ").replace(/\s+/g, " ").trim();
1078
65
  }
1079
- function R(e) {
1080
- return L(e).toLowerCase().normalize("NFD").replace(/\p{Diacritic}/gu, "");
66
+ function D(e) {
67
+ return E(e).toLowerCase().normalize("NFD").replace(/\p{Diacritic}/gu, "");
1081
68
  }
1082
- function z(e) {
1083
- return R(e).replace(/[‐‑‒–—]/gu, "-").replace(/\s*\.\s*/gu, ".");
69
+ function O(e) {
70
+ return D(e).replace(/[‐‑‒–—]/gu, "-").replace(/\s*\.\s*/gu, ".");
1084
71
  }
1085
- function Ne(e) {
1086
- return z(e).replace(/[^a-z0-9]+/gu, "-").replace(/^-|-$/gu, "");
72
+ function ee(e) {
73
+ return O(e).replace(/[^a-z0-9]+/gu, "-").replace(/^-|-$/gu, "");
1087
74
  }
1088
- function Pe(e) {
75
+ function te(e) {
1089
76
  switch (e.kind) {
1090
77
  case "insert_after":
1091
78
  case "insert_before": return e.insertText;
@@ -1103,71 +90,71 @@ function Pe(e) {
1103
90
  default: return;
1104
91
  }
1105
92
  }
1106
- function Fe(e) {
1107
- let t = L(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);
1108
- if (n?.[1] !== void 0) return L(n[1]);
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]);
1109
96
  }
1110
- function Ie(e) {
1111
- let t = Pe(e), n = [...(t ?? "").matchAll(/(?:^|\n)\s*(?:[«"]\s*)?(?:Art\.|Article)\s+(.+?)\s*[..]\s*[–—-]/giu)];
97
+ function re(e) {
98
+ let t = te(e), n = [...(t ?? "").matchAll(/(?:^|\n)\s*(?:[«"]\s*)?(?:Art\.|Article)\s+(.+?)\s*[..]\s*[–—-]/giu)];
1112
99
  if (n.length > 0 && t !== void 0) return n.map((e, r) => {
1113
100
  let i = e.index ?? 0, a = n[r + 1]?.index ?? t.length, o = t.slice(i, a).trim();
1114
101
  return {
1115
- num: L(e[1]),
102
+ num: E(e[1]),
1116
103
  text: o
1117
104
  };
1118
105
  });
1119
- let r = Fe(e);
106
+ let r = ne(e);
1120
107
  return r === void 0 ? [] : [{
1121
108
  num: r,
1122
109
  text: t ?? e.sourceText
1123
110
  }];
1124
111
  }
1125
- function B(e, t = /* @__PURE__ */ new Set()) {
112
+ function k(e, t = /* @__PURE__ */ new Set()) {
1126
113
  if (e == null) return t;
1127
114
  if (Array.isArray(e)) {
1128
- for (let n of e) B(n, t);
115
+ for (let n of e) k(n, t);
1129
116
  return t;
1130
117
  }
1131
118
  if (typeof e != "object") return t;
1132
119
  let n = e;
1133
120
  n.type === "article" && typeof n.num == "string" && t.add(n.num);
1134
- for (let e of Object.values(n)) B(e, t);
121
+ for (let e of Object.values(n)) k(e, t);
1135
122
  return t;
1136
123
  }
1137
- function Le(e) {
1138
- let t = R(e.sourceText);
124
+ function ie(e) {
125
+ let t = D(e.sourceText);
1139
126
  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);
1140
127
  }
1141
- function Re(e) {
1142
- return L(e).replace(/[’']/gu, "'").replace(/[‐‑‒–—]/gu, "-");
128
+ function ae(e) {
129
+ return E(e).replace(/[’']/gu, "'").replace(/[‐‑‒–—]/gu, "-");
1143
130
  }
1144
- function ze(e, t) {
1145
- let r = new n(e, t), i = p(r);
1146
- return typeof i != "string" || r.offset <= t ? null : {
1147
- date: i,
131
+ function oe(e, t) {
132
+ let n = new p(e, t), r = c(n);
133
+ return typeof r != "string" || n.offset <= t ? null : {
134
+ date: r,
1148
135
  start: t,
1149
- stop: r.offset
136
+ stop: n.offset
1150
137
  };
1151
138
  }
1152
- function Be(e, t) {
139
+ function se(e, t) {
1153
140
  let n = /\d/u.exec(e.slice(t));
1154
141
  if (!n) return null;
1155
142
  let r = t + n.index;
1156
- return e.slice(t, r).trim().length > 0 ? null : ze(e, r);
143
+ return e.slice(t, r).trim().length > 0 ? null : oe(e, r);
1157
144
  }
1158
- function Ve(e) {
145
+ function ce(e) {
1159
146
  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);
1160
147
  for (; o !== -1;) {
1161
148
  let s = e.indexOf(a, o + 15), c = e.slice(o, o + 1400), l = t.exec(c);
1162
149
  if (l) {
1163
- let e = Be(c, l[0].length);
150
+ let e = se(c, l[0].length);
1164
151
  e && i.push(e.date);
1165
152
  }
1166
153
  let u = n.exec(c);
1167
154
  if (u) {
1168
155
  let e = /\barticle\s+\w/iu.exec(c), t = e === null ? c.slice(u[0].length) : c.slice(u[0].length, e.index);
1169
156
  for (r.lastIndex = 0; r.exec(t) !== null;) {
1170
- let e = Be(t, r.lastIndex);
157
+ let e = se(t, r.lastIndex);
1171
158
  e && /^\s+pour\s+les\s+autres\s+dispositions\s+fiscales\b/iu.test(t.slice(e.stop)) && i.push(e.date);
1172
159
  }
1173
160
  }
@@ -1175,20 +162,20 @@ function Ve(e) {
1175
162
  }
1176
163
  return i;
1177
164
  }
1178
- function He(e) {
1179
- let t = Ve(Re(e).toLowerCase()), n = Array.from(new Set(t));
165
+ function le(e) {
166
+ let t = ce(ae(e).toLowerCase()), n = Array.from(new Set(t));
1180
167
  return n.length === 1 ? n[0] : void 0;
1181
168
  }
1182
- function Ue(e) {
1183
- return R(e).replace(/[’]/gu, "'").replace(/[‐‑‒–—]/gu, "-").replace(/^(?:(?:article\s+[^:]+|[a-z][.)]|[ivxlcdm]+\.|\d+°)\s*(?:-\s*)?)+/iu, "");
169
+ function ue(e) {
170
+ return D(e).replace(/[’]/gu, "'").replace(/[‐‑‒–—]/gu, "-").replace(/^(?:(?:article\s+[^:]+|[a-z][.)]|[ivxlcdm]+\.|\d+°)\s*(?:-\s*)?)+/iu, "");
1184
171
  }
1185
- function V(e) {
172
+ function A(e) {
1186
173
  return e?.type === "tag";
1187
174
  }
1188
- function H(e, t) {
175
+ function j(e, t) {
1189
176
  return e.html(t) ?? "";
1190
177
  }
1191
- function We(e, t) {
178
+ function de(e, t) {
1192
179
  let n = [], r = /* @__PURE__ */ new Set();
1193
180
  for (let i of e(t).find("a").get()) {
1194
181
  let a = e(i).attr("href") ?? "", o = /\/legifrance\/(articles|sections|textes)\/([^?#"]+)/u.exec(a);
@@ -1196,37 +183,37 @@ function We(e, t) {
1196
183
  let s = o[1] === "articles" ? "article" : o[1] === "sections" ? "division" : "text", c = o[2].replace(/\.md$/u, ""), l = `${s}\0${c}`;
1197
184
  if (r.has(l)) continue;
1198
185
  r.add(l);
1199
- let u = L(e(i).text());
186
+ let u = E(e(i).text());
1200
187
  n.push({
1201
188
  id: c,
1202
- ...Ge(e, t, i) ? { insideFrenchQuotes: !0 } : {},
189
+ ...fe(e, t, i) ? { insideFrenchQuotes: !0 } : {},
1203
190
  ...u ? { text: u } : {},
1204
191
  type: s
1205
192
  });
1206
193
  }
1207
194
  return n;
1208
195
  }
1209
- function Ge(e, t, n) {
1210
- let r = Ke(e, t, n);
196
+ function fe(e, t, n) {
197
+ let r = pe(e, t, n);
1211
198
  return (r.match(/«/gu) ?? []).length > (r.match(/»/gu) ?? []).length;
1212
199
  }
1213
- function Ke(e, t, n) {
200
+ function pe(e, t, n) {
1214
201
  if (t === n) return "";
1215
202
  if (t.type === "text") return t.data ?? "";
1216
- if (!V(t)) return "";
203
+ if (!A(t)) return "";
1217
204
  let r = "";
1218
205
  for (let i of e(t).contents().get()) {
1219
206
  if (i === n) return r;
1220
- if (V(i) && e.contains(i, n)) return r + Ke(e, i, n);
207
+ if (A(i) && e.contains(i, n)) return r + pe(e, i, n);
1221
208
  r += e(i).text();
1222
209
  }
1223
210
  return r;
1224
211
  }
1225
- function qe(e, t) {
1226
- return t.map((t) => L(e(t).text())).filter(Boolean).join("\n");
212
+ function me(e, t) {
213
+ return t.map((t) => E(e(t).text())).filter(Boolean).join("\n");
1227
214
  }
1228
- function U(e) {
1229
- let t = L(e).replace(/\s+:\s+/u, " : "), n = je.exec(t), r = n?.[1]?.trim();
215
+ function M(e) {
216
+ let t = E(e).replace(/\s+:\s+/u, " : "), n = w.exec(t), r = n?.[1]?.trim();
1230
217
  if (!r) return null;
1231
218
  let i = r.replace(/\s+/gu, ""), a = n?.[2]?.trim();
1232
219
  return {
@@ -1235,37 +222,37 @@ function U(e) {
1235
222
  title: a
1236
223
  };
1237
224
  }
1238
- function Je(e) {
1239
- let t = R(e);
1240
- return !t || Me.test(t) ? "noise" : Ae.test(e) ? "directive_candidate" : "context";
225
+ function he(e) {
226
+ let t = D(e);
227
+ return !t || T.test(t) ? "noise" : C.test(e) ? "directive_candidate" : "context";
1241
228
  }
1242
- async function W(e, t, n) {
1243
- if (n === void 0) throw Error("A document date is required to add links to legal references.");
229
+ async function N(e, t, r) {
230
+ if (r === void 0) throw Error("A document date is required to add links to legal references.");
1244
231
  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.");
1245
- let { output: r } = await Se({
1246
- date: n,
232
+ let { output: i } = await n({
233
+ date: r,
1247
234
  html: e,
1248
- legiResolver: t.legiResolver ?? new ke(t.canutesDb),
235
+ legiResolver: t.legiResolver ?? new o(t.canutesDb),
1249
236
  linkBaseUrl: t.linkBaseUrl,
1250
237
  linkType: t.linkType,
1251
238
  logIgnoredReferencesTypes: t.logIgnoredReferencesTypes,
1252
239
  logPartialReferences: t.logPartialReferences,
1253
240
  logReferences: t.logReferences
1254
241
  });
1255
- return r ?? e;
242
+ return i ?? e;
1256
243
  }
1257
- function Ye(e, t) {
244
+ function ge(e, t) {
1258
245
  let n = e(t).closest("h1,h2,h3,h4,h5,h6,p,td,th").get(0), r = e(t).closest("table").get(0);
1259
- return V(r) && V(n) && e(n).parents("table").get(0) === r ? r : V(n) ? n : t;
246
+ return A(r) && A(n) && e(n).parents("table").get(0) === r ? r : A(n) ? n : t;
1260
247
  }
1261
- function Xe(e) {
248
+ function P(e) {
1262
249
  let t = [], n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set();
1263
250
  return e("a[id], span[id], h1[id], h2[id], h3[id], h4[id], h5[id], h6[id]").each((i, a) => {
1264
- let o = U(L(e(a).text()));
251
+ let o = M(E(e(a).text()));
1265
252
  if (!o) return;
1266
253
  let s = e(a).attr("id");
1267
254
  if (!s || r.has(s)) return;
1268
- let c = Ye(e, a);
255
+ let c = ge(e, a);
1269
256
  n.has(c) || (r.add(s), n.add(c), t.push({
1270
257
  id: s,
1271
258
  ...o,
@@ -1274,17 +261,17 @@ function Xe(e) {
1274
261
  }));
1275
262
  }), t;
1276
263
  }
1277
- function Ze(e) {
264
+ function F(e) {
1278
265
  let t = e.next;
1279
266
  for (; t !== null;) {
1280
- if (V(t)) return t;
267
+ if (A(t)) return t;
1281
268
  t = t.next;
1282
269
  }
1283
270
  return null;
1284
271
  }
1285
- function Qe(e, t, n) {
272
+ function _e(e, t, n) {
1286
273
  let r = [t.container], i = n?.container;
1287
- for (let e = Ze(t.container); e !== null && e !== i; e = Ze(e)) r.push(e);
274
+ for (let e = F(t.container); e !== null && e !== i; e = F(e)) r.push(e);
1288
275
  if (r.length > 1) return r;
1289
276
  let a = e("body *").index(t.container), o = i ? e("body *").index(i) : -1;
1290
277
  return e("body > *").get().filter((t) => {
@@ -1292,7 +279,7 @@ function Qe(e, t, n) {
1292
279
  return n >= a && (o === -1 || n < o);
1293
280
  });
1294
281
  }
1295
- function $e(e, t) {
282
+ function ve(e, t) {
1296
283
  let n = [], r = /* @__PURE__ */ new Set();
1297
284
  for (let i of t) {
1298
285
  let t = "p,li,table", a = e(i).is(t) ? [i] : e(i).find(t).get();
@@ -1300,70 +287,70 @@ function $e(e, t) {
1300
287
  }
1301
288
  return n;
1302
289
  }
1303
- function et(e, t, n) {
290
+ function I(e, t, n) {
1304
291
  let r = [], i = !1;
1305
- for (let a of $e(e, n)) {
1306
- let n = L(e(a).text());
292
+ for (let a of ve(e, n)) {
293
+ let n = E(e(a).text());
1307
294
  if (!n) continue;
1308
- Me.test(n) && (i = !0);
1309
- let o = i ? "noise" : Je(n), s = `${t}-b${r.length + 1}`;
295
+ T.test(n) && (i = !0);
296
+ let o = i ? "noise" : he(n), s = `${t}-b${r.length + 1}`;
1310
297
  e(a).attr("data-pjl-parsed-article-id", t), e(a).attr("data-pjl-parsed-block-id", s), r.push({
1311
298
  id: s,
1312
299
  articleId: t,
1313
300
  kind: o,
1314
- links: We(e, a),
301
+ links: de(e, a),
1315
302
  text: n,
1316
- html: H(e, a)
303
+ html: j(e, a)
1317
304
  });
1318
305
  }
1319
306
  return r;
1320
307
  }
1321
- function tt(e, t) {
308
+ function L(e, t) {
1322
309
  if (t.length === 0) return e;
1323
310
  let n = `<div style="display: none;">\n${t.map((e) => `<p class="assnatTOC6"><a href="#${`_TocArt${(e.num ?? e.label.replace(/^Article\s+/iu, "")).replace(/\s+/gu, "")}`}"><span class="assnatHyperlink" style="font-weight:bold; text-decoration:none; color:#000000">${e.label.toUpperCase()}</span></a></p>`).join("\n")}\n</div>`;
1324
311
  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}`;
1325
312
  }
1326
- function nt(e) {
1327
- let t = y(e);
1328
- for (let e of Xe(t)) {
1329
- let n = `_TocArt${(e.num ?? e.label.replace(/^Article\s+/iu, "")).replace(/\s+/gu, "")}`, r = t(e.element), i = r.attr("id");
1330
- i?.startsWith("_TocArt") || (i?.startsWith("_Toc") && !rt(t, i, e.element) && r.before(t("<span></span>").attr("id", i)), r.attr("id", n));
313
+ function ye(t) {
314
+ let n = e(t);
315
+ for (let e of P(n)) {
316
+ let t = `_TocArt${(e.num ?? e.label.replace(/^Article\s+/iu, "")).replace(/\s+/gu, "")}`, r = n(e.element), i = r.attr("id");
317
+ i?.startsWith("_TocArt") || (i?.startsWith("_Toc") && !be(n, i, e.element) && r.before(n("<span></span>").attr("id", i)), r.attr("id", t));
1331
318
  }
1332
- return t.html();
319
+ return n.html();
1333
320
  }
1334
- function rt(e, t, n) {
321
+ function be(e, t, n) {
1335
322
  for (let r of e("[id]").get()) if (r !== n && e(r).attr("id") === t) return !0;
1336
323
  return !1;
1337
324
  }
1338
- function it(e, t) {
1339
- let n = Ue("sourceText" in t ? t.sourceText : "");
325
+ function xe(e, t) {
326
+ let n = ue("sourceText" in t ? t.sourceText : "");
1340
327
  if (n) return e.filter((e) => e.kind === "directive_candidate").find((e) => {
1341
- let t = Ue(e.text);
328
+ let t = ue(e.text);
1342
329
  return t.length > 0 && (n.includes(t) || t.includes(n));
1343
330
  });
1344
331
  }
1345
- function at(e, t) {
332
+ function Se(e, t) {
1346
333
  if (t) return t.blockIds.map((t) => e.get(t)).find((e) => e?.kind === "directive_candidate");
1347
334
  }
1348
- function ot(e) {
335
+ function R(e) {
1349
336
  return e?.links.filter((e) => !e.insideFrenchQuotes && (e.type === "article" || e.type === "division")).map((e) => e.id) ?? [];
1350
337
  }
1351
- var st = [
338
+ var Ce = [
1352
339
  /^([IVXLCDM]+)\s*[.).]?\s*[–—-]/iu,
1353
340
  /^(\d+°)\s+/u,
1354
341
  /^([a-z])\)\s+/iu,
1355
342
  /^([ivxlcdm]+)\)\s+/iu
1356
343
  ];
1357
- function ct(e) {
1358
- let t = L(e);
344
+ function we(e) {
345
+ let t = E(e);
1359
346
  if (!t) return;
1360
- let n = st.findIndex((e) => e.test(t));
347
+ let n = Ce.findIndex((e) => e.test(t));
1361
348
  return n === -1 ? t.endsWith(":") ? 0 : void 0 : n + 1;
1362
349
  }
1363
- function lt(e) {
350
+ function Te(e) {
1364
351
  let t = /* @__PURE__ */ new Map(), n = [];
1365
352
  for (let r of e) {
1366
- let e = ct(r.text);
353
+ let e = we(r.text);
1367
354
  if (e === void 0) {
1368
355
  t.set(r.id, [...n, r]);
1369
356
  continue;
@@ -1372,14 +359,14 @@ function lt(e) {
1372
359
  }
1373
360
  return t;
1374
361
  }
1375
- function ut(e, t) {
362
+ function Ee(e, t) {
1376
363
  let n = [], r = /* @__PURE__ */ new Set();
1377
364
  for (let i of [...e ?? [], ...t]) i !== void 0 && (r.has(i.id) || (r.add(i.id), n.push(i)));
1378
365
  return n;
1379
366
  }
1380
- function dt(e, t, n) {
367
+ function De(e, t, n) {
1381
368
  if (!t) return;
1382
- let r = ut(e, t.blockIds.map((e) => n.get(e)).filter((e) => e !== void 0));
369
+ let r = Ee(e, t.blockIds.map((e) => n.get(e)).filter((e) => e !== void 0));
1383
370
  if (r.length === 0) return;
1384
371
  let i = r.map((e) => e.id);
1385
372
  if (i.length === t.blockIds.length && i.every((e, n) => e === t.blockIds[n])) return;
@@ -1394,7 +381,7 @@ function dt(e, t, n) {
1394
381
  }
1395
382
  };
1396
383
  }
1397
- function ft(e) {
384
+ function Oe(e) {
1398
385
  let t = [], n = 0;
1399
386
  for (let r of e.blocks) {
1400
387
  let i = e.directiveText.indexOf(r.text, n);
@@ -1408,7 +395,7 @@ function ft(e) {
1408
395
  }
1409
396
  return t;
1410
397
  }
1411
- function pt(e, t, n) {
398
+ function ke(e, t, n) {
1412
399
  let { start: r, stop: i } = n.sourcePosition, a = t.filter((e) => e.stop >= r && e.start <= i);
1413
400
  if (a.length === 0) return;
1414
401
  let o = a[0], s = a[a.length - 1], c = o.start, l = s.stop;
@@ -1422,7 +409,7 @@ function pt(e, t, n) {
1422
409
  }
1423
410
  };
1424
411
  }
1425
- function mt(e, t, n) {
412
+ function Ae(e, t, n) {
1426
413
  if (!t) return;
1427
414
  let r = e.directiveText.indexOf(t.text);
1428
415
  if (r === -1) return;
@@ -1435,14 +422,14 @@ function mt(e, t, n) {
1435
422
  stop: a
1436
423
  };
1437
424
  }
1438
- function ht(e) {
1439
- let t = ft(e), n = new Map(e.blocks.map((e) => [e.id, e])), r = lt(e.blocks), i = /* @__PURE__ */ new Map(), a = [];
425
+ function je(e) {
426
+ let t = Oe(e), n = new Map(e.blocks.map((e) => [e.id, e])), r = Te(e.blocks), a = /* @__PURE__ */ new Map(), o = [];
1440
427
  for (let t of e.blocks) {
1441
- let e = ot(t);
1442
- e.length > 0 && (a = e), i.set(t.id, a);
428
+ let e = R(t);
429
+ e.length > 0 && (o = e), a.set(t.id, o);
1443
430
  }
1444
- return h(e.directiveText).map((a) => {
1445
- let o = pt(e, t, a), s = at(n, o) ?? it(e.blocks, a), c = ot(s), l = c.length > 0 ? c : s?.id === void 0 ? [] : i.get(s.id) ?? [], u = mt(e, s, a), d = dt(s?.id === void 0 ? void 0 : r.get(s.id), o, n);
431
+ return i(e.directiveText).map((i) => {
432
+ let o = ke(e, t, i), s = Se(n, o) ?? xe(e.blocks, i), c = R(s), l = c.length > 0 ? c : s?.id === void 0 ? [] : a.get(s.id) ?? [], u = Ae(e, s, i), d = De(s?.id === void 0 ? void 0 : r.get(s.id), o, n);
1446
433
  return {
1447
434
  articleId: e.id,
1448
435
  blockId: s?.id,
@@ -1457,18 +444,18 @@ function ht(e) {
1457
444
  sourceContextBlockIds: d.blockIds,
1458
445
  sourceContextPosition: d.position
1459
446
  },
1460
- directive: a,
447
+ directive: i,
1461
448
  ...l.length > 0 ? { targetIds: l } : {}
1462
449
  };
1463
450
  });
1464
451
  }
1465
- function gt(e) {
452
+ function Me(e) {
1466
453
  let t = /* @__PURE__ */ new Map(), n = [], r = /* @__PURE__ */ new Set();
1467
454
  for (let i of e) {
1468
- let e = Ie(i.directive);
455
+ let e = re(i.directive);
1469
456
  if (e.length === 0) continue;
1470
457
  let a = e.map(({ num: e }) => ({
1471
- definitionId: `${i.articleId}:article:${Ne(e)}`,
458
+ definitionId: `${i.articleId}:article:${ee(e)}`,
1472
459
  num: e
1473
460
  }));
1474
461
  t.set(i, a);
@@ -1492,13 +479,13 @@ function gt(e) {
1492
479
  definitions: n
1493
480
  };
1494
481
  }
1495
- function _t(e, t, n) {
1496
- let r = new Map(t.map((e) => [z(e.num), e]));
482
+ function Ne(e, t, n) {
483
+ let r = new Map(t.map((e) => [O(e.num), e]));
1497
484
  return e.map((e) => {
1498
- let t = n.get(e), i = t?.[0], a = [...B(e.directive.reference)].map((e) => r.get(z(e))).filter((e) => e !== void 0 && e.definitionId !== i?.definitionId)[0], o = a === void 0 ? void 0 : {
485
+ 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 : {
1499
486
  definitionId: a.definitionId,
1500
487
  num: a.num
1501
- }, s = Le(e.directive), c = (e.targetIds?.length ?? 0) > 0;
488
+ }, s = ie(e.directive), c = (e.targetIds?.length ?? 0) > 0;
1502
489
  return {
1503
490
  ...e,
1504
491
  ...i === void 0 ? {} : { createdArticle: i },
@@ -1511,72 +498,72 @@ function _t(e, t, n) {
1511
498
  };
1512
499
  });
1513
500
  }
1514
- function vt(e, t, n, r, i, a, o = !0) {
1515
- let s = i.map((e) => e.directiveText).filter(Boolean).join("\n"), c = {
501
+ function z(e, t, n, i, a, o, s = !0) {
502
+ let c = a.map((e) => e.directiveText).filter(Boolean).join("\n"), l = {
1516
503
  sourceFormat: e,
1517
- documentDate: r,
504
+ documentDate: i,
1518
505
  html: t,
1519
506
  htmlWithLinks: n,
1520
- tableOfContents: a ?? S(s),
1521
- articles: i
507
+ tableOfContents: o ?? r(c),
508
+ articles: a
1522
509
  };
1523
- if (!o) return {
1524
- ...c,
510
+ if (!s) return {
511
+ ...l,
1525
512
  directives: []
1526
513
  };
1527
- let l = He(i.map((e) => e.text).join("\n")), u = i.flatMap(ht), { createdArticlesByDirective: d, definitions: f } = gt(u), p = _t(u, f, d);
514
+ let u = le(a.map((e) => e.text).join("\n")), d = a.flatMap(je), { createdArticlesByDirective: f, definitions: p } = Me(d), m = Ne(d, p, f);
1528
515
  return {
1529
- ...c,
1530
- ...l ? { globalApplicabilityDate: l } : {},
1531
- ...f.length > 0 ? { internalArticleDefinitions: f } : {},
1532
- directives: p
516
+ ...l,
517
+ ...u ? { globalApplicabilityDate: u } : {},
518
+ ...p.length > 0 ? { internalArticleDefinitions: p } : {},
519
+ directives: m
1533
520
  };
1534
521
  }
1535
- function yt(e) {
1536
- let t = S(e.map((e) => e.directiveText).filter(Boolean).join("\n")), n = new Map(e.map((e) => [R(e.label), e.id])), r = 0;
1537
- function i(e) {
1538
- for (let t of e.articles ?? []) r += 1, t.id ??= n.get(R(t.line));
1539
- for (let t of e.divisions ?? []) i(t);
522
+ function Pe(e) {
523
+ 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;
524
+ function a(e) {
525
+ for (let t of e.articles ?? []) i += 1, t.id ??= n.get(D(t.line));
526
+ for (let t of e.divisions ?? []) a(t);
1540
527
  }
1541
- return i(t), r > 0 ? t : { articles: e.map((e) => ({
528
+ return a(t), i > 0 ? t : { articles: e.map((e) => ({
1542
529
  id: e.id,
1543
530
  line: e.title ? `${e.label} : ${e.title}` : e.label,
1544
531
  type: "article"
1545
532
  })) };
1546
533
  }
1547
- async function bt(e, t) {
1548
- let n = new D("parseAssembleeBillRaw"), r = t.linkedHtml === void 0 ? await n.time("linkAssembleeBillRaw", () => xt(e, t)) : void 0, i = n.timeSync("applyArticleAnchorIds", () => nt(t.linkedHtml ?? r.linkedHtml), { inputSize: e.length }), a = n.timeSync("cheerioLoadLinkedHtml", () => y(i)), o = n.timeSync("extractArticleHeadings", () => Xe(a)), s = n.timeSync("extractArticlesAndBlocks", () => o.map((e, t) => {
1549
- let n = Qe(a, e, o[t + 1]), r = et(a, e.id, n), i = r.filter((e) => e.kind !== "noise").map((e) => e.text).join("\n");
534
+ async function Fe(t, n) {
535
+ let r = new u("parseAssembleeBillRaw"), i = n.linkedHtml === void 0 ? await r.time("linkAssembleeBillRaw", () => Ie(t, n)) : void 0, a = r.timeSync("applyArticleAnchorIds", () => ye(n.linkedHtml ?? i.linkedHtml), { inputSize: t.length }), o = r.timeSync("cheerioLoadLinkedHtml", () => e(a)), s = r.timeSync("extractArticleHeadings", () => P(o)), c = r.timeSync("extractArticlesAndBlocks", () => s.map((e, t) => {
536
+ let n = _e(o, e, s[t + 1]), r = I(o, e.id, n), i = r.filter((e) => e.kind !== "noise").map((e) => e.text).join("\n");
1550
537
  return {
1551
538
  id: e.id,
1552
539
  label: e.label,
1553
540
  num: e.num,
1554
541
  title: e.title,
1555
- text: qe(a, n),
1556
- html: n.map((e) => H(a, e)).join("\n"),
542
+ text: me(o, n),
543
+ html: n.map((e) => j(o, e)).join("\n"),
1557
544
  directiveText: i,
1558
545
  blocks: r
1559
546
  };
1560
- }), { count: o.length }), c = n.timeSync("injectHiddenArticleSummary", () => tt(a.html(), s)), l = n.timeSync("buildAssembleeTableOfContents", () => yt(s), { count: s.length }), u = n.timeSync("buildParsedDocument", () => vt("assemblee-html", e, c, t.date, s, l, t.includeDirectiveAnalysis));
1561
- return n.log({
1562
- articleCount: u.articles.length,
1563
- blockCount: u.articles.reduce((e, t) => e + t.blocks.length, 0),
1564
- directiveCount: u.directives.length,
1565
- targetDirectiveCount: u.directives.filter((e) => e.targetIds !== void 0).length
1566
- }), u;
547
+ }), { count: s.length }), l = r.timeSync("injectHiddenArticleSummary", () => L(o.html(), c)), d = r.timeSync("buildAssembleeTableOfContents", () => Pe(c), { count: c.length }), f = r.timeSync("buildParsedDocument", () => z("assemblee-html", t, l, n.date, c, d, n.includeDirectiveAnalysis));
548
+ return r.log({
549
+ articleCount: f.articles.length,
550
+ blockCount: f.articles.reduce((e, t) => e + t.blocks.length, 0),
551
+ directiveCount: f.directives.length,
552
+ targetDirectiveCount: f.directives.filter((e) => e.targetIds !== void 0).length
553
+ }), f;
1567
554
  }
1568
- async function xt(e, t) {
555
+ async function Ie(e, t) {
1569
556
  return {
1570
557
  sourceFormat: "assemblee-html",
1571
558
  documentDate: t.date,
1572
559
  html: e,
1573
- linkedHtml: await W(e, t, t.date)
560
+ linkedHtml: await N(e, t, t.date)
1574
561
  };
1575
562
  }
1576
- function G(e) {
563
+ function B(e) {
1577
564
  return e.replace(/&/gu, "&amp;").replace(/</gu, "&lt;").replace(/>/gu, "&gt;").replace(/"/gu, "&quot;");
1578
565
  }
1579
- function St(e) {
566
+ function Le(e) {
1580
567
  let t = e;
1581
568
  for (let e = 0; e < 3; e++) {
1582
569
  let e = t;
@@ -1584,27 +571,27 @@ function St(e) {
1584
571
  }
1585
572
  return t;
1586
573
  }
1587
- function Ct(e) {
574
+ function Re(e) {
1588
575
  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);
1589
576
  }
1590
- function K(e) {
577
+ function V(e) {
1591
578
  return e.name.replace(/^.*:/u, "");
1592
579
  }
1593
- function wt(e, t) {
1594
- return t.children.map((t) => q(e, t)).filter(Boolean).join("");
580
+ function ze(e, t) {
581
+ return t.children.map((t) => H(e, t)).filter(Boolean).join("");
1595
582
  }
1596
- function Tt(e, t) {
1597
- return t.children.map((t) => t.type === "text" && Ct(t.data) ? St(t.data) : q(e, t)).filter(Boolean).join("");
583
+ function Be(e, t) {
584
+ return t.children.map((t) => t.type === "text" && Re(t.data) ? Le(t.data) : H(e, t)).filter(Boolean).join("");
1598
585
  }
1599
- function q(e, t) {
586
+ function H(e, t) {
1600
587
  if (t.type === "text") {
1601
588
  let e = t.data.replace(/\s+\./gu, ".");
1602
- return Ct(e) ? St(e) : G(e);
589
+ return Re(e) ? Le(e) : B(e);
1603
590
  }
1604
- if (!V(t)) return "";
1605
- let n = K(t), r = wt(e, t);
591
+ if (!A(t)) return "";
592
+ let n = V(t), r = ze(e, t);
1606
593
  switch (n) {
1607
- case "p": return `<p${J(e, t, [
594
+ case "p": return `<p${U(e, t, [
1608
595
  "id",
1609
596
  "class",
1610
597
  "align",
@@ -1618,13 +605,13 @@ function q(e, t) {
1618
605
  case "u":
1619
606
  case "sup":
1620
607
  case "sub":
1621
- case "abbr": return `<${n}${J(e, t, [
608
+ case "abbr": return `<${n}${U(e, t, [
1622
609
  "id",
1623
610
  "class",
1624
611
  "title",
1625
612
  "style"
1626
613
  ])}>${r}</${n}>`;
1627
- case "a": return `<a href="${G(e(t).attr("href") ?? e(t).attr("target") ?? "#")}"${J(e, t, [
614
+ case "a": return `<a href="${B(e(t).attr("href") ?? e(t).attr("target") ?? "#")}"${U(e, t, [
1628
615
  "id",
1629
616
  "class",
1630
617
  "title",
@@ -1635,8 +622,8 @@ function q(e, t) {
1635
622
  case "tbody":
1636
623
  case "tr":
1637
624
  case "th":
1638
- case "td": return Et(e, t, n, r);
1639
- case "caption": return `<caption${J(e, t, [
625
+ case "td": return Ve(e, t, n, r);
626
+ case "caption": return `<caption${U(e, t, [
1640
627
  "id",
1641
628
  "class",
1642
629
  "align",
@@ -1644,12 +631,12 @@ function q(e, t) {
1644
631
  ])}>${r}</caption>`;
1645
632
  case "num": return `<span class="akn-num">${r}</span> `;
1646
633
  case "heading": return `<p class="akn-heading">${r}</p>`;
1647
- case "content": return Tt(e, t);
1648
- case "alinea": return Y(e, t, "div", "akn-alinea");
1649
- case "article": return Y(e, t, "article", "akn-article");
634
+ case "content": return Be(e, t);
635
+ case "alinea": return q(e, t, "div", "akn-alinea");
636
+ case "article": return q(e, t, "article", "akn-article");
1650
637
  case "blockList":
1651
638
  case "list": return `<div class="akn-list">${r}</div>`;
1652
- case "item": return Y(e, t, "div", "akn-item");
639
+ case "item": return q(e, t, "div", "akn-item");
1653
640
  case "listIntroduction":
1654
641
  case "listWrapUp":
1655
642
  case "intro":
@@ -1665,23 +652,23 @@ function q(e, t) {
1665
652
  case "book":
1666
653
  case "tome":
1667
654
  case "subchapter":
1668
- case "subsection": return Y(e, t, "section", `akn-${n}`);
655
+ case "subsection": return q(e, t, "section", `akn-${n}`);
1669
656
  case "crossHeading": return `<p class="akn-cross-heading">${r}</p>`;
1670
657
  default: return r;
1671
658
  }
1672
659
  }
1673
- function J(e, t, n, r = {}) {
660
+ function U(e, t, n, r = {}) {
1674
661
  let i = [];
1675
662
  for (let r of n) {
1676
663
  if (r === "style") continue;
1677
664
  let n = e(t).attr(r);
1678
- n !== void 0 && i.push(`${r}="${G(n)}"`);
665
+ n !== void 0 && i.push(`${r}="${B(n)}"`);
1679
666
  }
1680
667
  let a = r.style ?? e(t).attr("style");
1681
- return a && i.push(`style="${G(a)}"`), i.length > 0 ? ` ${i.join(" ")}` : "";
668
+ return a && i.push(`style="${B(a)}"`), i.length > 0 ? ` ${i.join(" ")}` : "";
1682
669
  }
1683
- function Et(e, t, n, r) {
1684
- return `<${n}${J(e, t, [
670
+ function Ve(e, t, n, r) {
671
+ return `<${n}${U(e, t, [
1685
672
  "id",
1686
673
  "class",
1687
674
  "colspan",
@@ -1694,155 +681,155 @@ function Et(e, t, n, r) {
1694
681
  "cellspacing",
1695
682
  "cellpadding",
1696
683
  "style"
1697
- ], { style: Dt(e, t, n) })}>${r}</${n}>`;
684
+ ], { style: He(e, t, n) })}>${r}</${n}>`;
1698
685
  }
1699
- function Dt(e, t, n) {
686
+ function He(e, t, n) {
1700
687
  let r = e(t).attr("style") ?? "";
1701
- return (n === "td" || n === "th") && /font-weight\s*:\s*bold/iu.test(r) && !/text-align\s*:/iu.test(r) && (r = Ot(r, "text-align", "center")), r || void 0;
688
+ return (n === "td" || n === "th") && /font-weight\s*:\s*bold/iu.test(r) && !/text-align\s*:/iu.test(r) && (r = Ue(r, "text-align", "center")), r || void 0;
1702
689
  }
1703
- function Ot(e, t, n) {
690
+ function Ue(e, t, n) {
1704
691
  let r = e.trim();
1705
692
  return `${r}${r && !r.endsWith(";") ? ";" : ""} ${t}: ${n};`.trim();
1706
693
  }
1707
- function kt(e, t) {
1708
- let n = [L(e(t).children("num").first().text()), L(e(t).children("heading").first().text())].filter(Boolean);
1709
- return n.length === 0 ? "" : `<p class="akn-heading">${G(n.join(" "))}</p>`;
694
+ function We(e, t) {
695
+ let n = [E(e(t).children("num").first().text()), E(e(t).children("heading").first().text())].filter(Boolean);
696
+ return n.length === 0 ? "" : `<p class="akn-heading">${B(n.join(" "))}</p>`;
1710
697
  }
1711
- function At(e, t) {
698
+ function Ge(e, t) {
1712
699
  if (!t) return !1;
1713
- let n = (e) => L(e).replace(/\s+/gu, " ").replace(/\s*[..]\s*(?=[–—-])/gu, " ").trim();
1714
- return n(L(e.replace(/<[^>]*>/gu, " ").replace(/&nbsp;/gu, " ").replace(/&#xa0;/giu, " ").replace(/&#x2013;/giu, "–"))).startsWith(n(t));
700
+ let n = (e) => E(e).replace(/\s+/gu, " ").replace(/\s*[..]\s*(?=[–—-])/gu, " ").trim();
701
+ return n(E(e.replace(/<[^>]*>/gu, " ").replace(/&nbsp;/gu, " ").replace(/&#xa0;/giu, " ").replace(/&#x2013;/giu, "–"))).startsWith(n(t));
1715
702
  }
1716
- function jt(e) {
1717
- let t = G(e);
703
+ function Ke(e) {
704
+ let t = B(e);
1718
705
  return `<p data-pastille="${t}" class="pastille"><span aria-label="pastille ${t}">${t}</span></p>`;
1719
706
  }
1720
- function Mt(e, t) {
1721
- return Nt([Pt({
707
+ function qe(e, t) {
708
+ return W([Je({
1722
709
  content: e,
1723
710
  pastille: t
1724
711
  })]);
1725
712
  }
1726
- function Nt(e) {
713
+ function W(e) {
1727
714
  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>`;
1728
715
  }
1729
- function Pt({ content: e, pastille: t, style: n, contextClass: r }) {
1730
- let i = n ? ` style="${G(n)}"` : "", a = r ? ` ${G(r)}` : "";
1731
- return `<tr${r ? ` class="${G(r)} hideable"` : ""}><td style="overflow: hidden; width: 5.0%;" class="texte-col-0 texte-col-pastille no-right-border"><div class="tableauComparatifCell${a}">${jt(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>`;
716
+ function Je({ content: e, pastille: t, style: n, contextClass: r }) {
717
+ let i = n ? ` style="${B(n)}"` : "", a = r ? ` ${B(r)}` : "";
718
+ return `<tr${r ? ` class="${B(r)} hideable"` : ""}><td style="overflow: hidden; width: 5.0%;" class="texte-col-0 texte-col-pastille no-right-border"><div class="tableauComparatifCell${a}">${Ke(t)}</div></td><td style="overflow: hidden; width: 95.0%;" class="texte-col-1 no-right-border"><div class="tableauComparatifCell${a}"${i}>${e}</div></td></tr>`;
1732
719
  }
1733
- function Ft({ content: e, style: t, contextClass: n }) {
1734
- let r = t ? ` style="${G(t)}"` : "", i = n ? ` ${G(n)}` : "";
1735
- return `<tr${n ? ` class="${G(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>`;
720
+ function G({ content: e, style: t, contextClass: n }) {
721
+ let r = t ? ` style="${B(t)}"` : "", i = n ? ` ${B(n)}` : "";
722
+ return `<tr${n ? ` class="${B(n)} hideable"` : ""}><td style="overflow: hidden; width: 5.0%;" class="texte-col-0 no-right-border"><div class="tableauComparatifCell${i}"><p class="pastille"><br></p></div></td><td style="overflow: hidden; width: 95.0%;" class="texte-col-1 no-right-border"><div class="tableauComparatifCell${i}"${r}>${e}</div></td></tr>`;
1736
723
  }
1737
- function It(e, t) {
724
+ function Ye(e, t) {
1738
725
  return e(t).attr("data:pastille") ?? e(t).attr("pastille");
1739
726
  }
1740
- function Lt(e, t) {
727
+ function Xe(e, t) {
1741
728
  return e(t).find("alinea[data\\:pastille],alinea[pastille]").length > 0;
1742
729
  }
1743
- function Rt(e, t) {
1744
- return e(t).children().get().filter((e) => V(e) ? K(e) === "content" : !1).map((t) => q(e, t)).filter(Boolean).join("\n");
730
+ function Ze(e, t) {
731
+ return e(t).children().get().filter((e) => A(e) ? V(e) === "content" : !1).map((t) => H(e, t)).filter(Boolean).join("\n");
1745
732
  }
1746
- function zt(e, t) {
733
+ function Qe(e, t) {
1747
734
  let n = [];
1748
735
  return e(t).children().each((t, r) => {
1749
- if (!V(r)) return;
1750
- let i = K(r);
1751
- i === "num" || i === "heading" || i === "content" || n.push(q(e, r));
736
+ if (!A(r)) return;
737
+ let i = V(r);
738
+ i === "num" || i === "heading" || i === "content" || n.push(H(e, r));
1752
739
  }), n.filter(Boolean);
1753
740
  }
1754
- function Bt(e, t) {
1755
- let n = [], r = K(t), i = r === "alinea" ? It(e, t) : void 0, a = Rt(e, t), o = Vt(e, t, r, i), s = qt(e, t);
741
+ function K(e, t) {
742
+ let n = [], r = V(t), i = r === "alinea" ? Ye(e, t) : void 0, a = Ze(e, t), o = $e(e, t, r, i), s = at(e, t);
1756
743
  if (i) {
1757
- let r = [At(a, L(e(t).children("num").first().text())) ? "" : kt(e, t), a].filter(Boolean).join("\n");
1758
- L(r) && n.push(Pt({
744
+ let r = [Ge(a, E(e(t).children("num").first().text())) ? "" : We(e, t), a].filter(Boolean).join("\n");
745
+ E(r) && n.push(Je({
1759
746
  content: r,
1760
747
  pastille: i,
1761
748
  style: o,
1762
749
  contextClass: s
1763
750
  }));
1764
- } else a && n.push(Ft({
751
+ } else a && n.push(G({
1765
752
  content: a,
1766
753
  style: o,
1767
754
  contextClass: s
1768
755
  }));
1769
756
  for (let r of e(t).children().get()) {
1770
- if (!V(r)) continue;
1771
- let t = K(r);
1772
- t === "num" || t === "heading" || t === "content" || (t === "alinea" || Lt(e, r)) && n.push(...Bt(e, r));
757
+ if (!A(r)) continue;
758
+ let t = V(r);
759
+ t === "num" || t === "heading" || t === "content" || (t === "alinea" || Xe(e, r)) && n.push(...K(e, r));
1773
760
  }
1774
761
  return n;
1775
762
  }
1776
- function Y(e, t, n, r) {
1777
- let i = K(t), a = e(t).attr("eId") ?? e(t).attr("GUID"), o = It(e, t), s = Vt(e, t, i, o), c = [`<${n} ${[
1778
- a ? `id="${G(a)}"` : void 0,
763
+ function q(e, t, n, r) {
764
+ let i = V(t), a = e(t).attr("eId") ?? e(t).attr("GUID"), o = Ye(e, t), s = $e(e, t, i, o), c = [`<${n} ${[
765
+ a ? `id="${B(a)}"` : void 0,
1779
766
  `class="${r}"`,
1780
- o ? `data-pastille="${G(o)}"` : void 0,
1781
- s ? `style="${G(s)}"` : void 0
767
+ o ? `data-pastille="${B(o)}"` : void 0,
768
+ s ? `style="${B(s)}"` : void 0
1782
769
  ].filter((e) => e !== void 0).join(" ")}>`];
1783
770
  if (i === "part" || i === "title") {
1784
- let r = Wt(e, t, i), a = Kt(e, t), o = r ? [Ft({
771
+ let r = nt(e, t, i), a = it(e, t), o = r ? [G({
1785
772
  content: r,
1786
773
  contextClass: a
1787
774
  })] : [], s = () => {
1788
- o.length !== 0 && (c.push(Ut(o)), o = []);
775
+ o.length !== 0 && (c.push(tt(o)), o = []);
1789
776
  };
1790
777
  return e(t).children().each((t, n) => {
1791
- if (!V(n)) return;
1792
- let r = K(n);
778
+ if (!A(n)) return;
779
+ let r = V(n);
1793
780
  if (!(r === "num" || r === "heading" || r === "content")) {
1794
781
  if (r === "alinea") {
1795
- o.push(...Bt(e, n));
782
+ o.push(...K(e, n));
1796
783
  return;
1797
784
  }
1798
- s(), c.push(q(e, n));
785
+ s(), c.push(H(e, n));
1799
786
  }
1800
787
  }), s(), c.push(`</${n}>`), c.join("\n");
1801
788
  }
1802
789
  if (i === "article") {
1803
- let r = L(e(t).children("num").first().text()), i = L(e(t).children("heading").first().text()), a = U(r) ?? {
790
+ let r = E(e(t).children("num").first().text()), i = E(e(t).children("heading").first().text()), a = M(r) ?? {
1804
791
  label: r,
1805
792
  num: r
1806
- }, o = `<p class="TCNumArticle as-text toc-article dispositif" id="${G(`_TocArt${(a.num ?? r).replace(/\s+/gu, "")}`)}">${G(a.label)}${i ? ` : ${G(i)}` : ""}</p>`;
1807
- if (Lt(e, t)) {
1808
- let r = [Ft({
793
+ }, o = `<p class="TCNumArticle as-text toc-article dispositif" id="${B(`_TocArt${(a.num ?? r).replace(/\s+/gu, "")}`)}">${B(a.label)}${i ? ` : ${B(i)}` : ""}</p>`;
794
+ if (Xe(e, t)) {
795
+ let r = [G({
1809
796
  content: o,
1810
- contextClass: Yt(a.label)
1811
- }), ...Bt(e, t)];
1812
- c.push(Nt(r));
1813
- for (let n of zt(e, t)) n.includes("akn-pastille-table") || c.push(n);
797
+ contextClass: st(a.label)
798
+ }), ...K(e, t)];
799
+ c.push(W(r));
800
+ for (let n of Qe(e, t)) n.includes("akn-pastille-table") || c.push(n);
1814
801
  return c.push(`</${n}>`), c.join("\n");
1815
802
  }
1816
803
  c.push(o);
1817
804
  }
1818
805
  let l = [];
1819
806
  for (let n of ["content", "children"]) e(t).children().each((t, r) => {
1820
- if (!V(r)) return;
1821
- let i = K(r);
1822
- i === "num" || i === "heading" || n === "content" && i !== "content" || n === "children" && i === "content" || l.push(q(e, r));
807
+ if (!A(r)) return;
808
+ let i = V(r);
809
+ i === "num" || i === "heading" || n === "content" && i !== "content" || n === "children" && i === "content" || l.push(H(e, r));
1823
810
  });
1824
811
  let u = l.join("\n");
1825
812
  if (i !== "article") {
1826
- let n = At(u, L(e(t).children("num").first().text())) ? "" : kt(e, t);
813
+ let n = Ge(u, E(e(t).children("num").first().text())) ? "" : We(e, t);
1827
814
  n && c.push(n);
1828
815
  }
1829
- return c.push(o ? Mt(u, o) : u), c.push(`</${n}>`), c.join("\n");
816
+ return c.push(o ? qe(u, o) : u), c.push(`</${n}>`), c.join("\n");
1830
817
  }
1831
- function Vt(e, t, n, r) {
1832
- let i = Ht(e(t).attr("style") ?? "", "font-family");
1833
- return !r && n !== "article" && /font-weight\s*:\s*bold/iu.test(i) && !/text-align\s*:/iu.test(i) && (i = Ot(i, "text-align", "center")), i || void 0;
818
+ function $e(e, t, n, r) {
819
+ let i = et(e(t).attr("style") ?? "", "font-family");
820
+ return !r && n !== "article" && /font-weight\s*:\s*bold/iu.test(i) && !/text-align\s*:/iu.test(i) && (i = Ue(i, "text-align", "center")), i || void 0;
1834
821
  }
1835
- function Ht(e, t) {
822
+ function et(e, t) {
1836
823
  return e.split(";").map((e) => e.trim()).filter(Boolean).filter((e) => !e.toLowerCase().startsWith(`${t.toLowerCase()}:`)).join(";");
1837
824
  }
1838
- function Ut(e) {
825
+ function tt(e) {
1839
826
  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>`;
1840
827
  }
1841
- function Wt(e, t, n) {
1842
- let r = L(e(t).children("num").first().text()), i = L(e(t).children("heading").first().text()), a = Gt(n), o = [];
1843
- return r && o.push(`<p class="${a.num} as-text dispositif"><span aria-label="">${G(r)}</span></p>`), i && o.push(`<p class="${a.heading} as-text dispositif"><span aria-label="">${G(i)}</span></p>`), o.join("\n");
828
+ function nt(e, t, n) {
829
+ let r = E(e(t).children("num").first().text()), i = E(e(t).children("heading").first().text()), a = rt(n), o = [];
830
+ return r && o.push(`<p class="${a.num} as-text dispositif"><span aria-label="">${B(r)}</span></p>`), i && o.push(`<p class="${a.heading} as-text dispositif"><span aria-label="">${B(i)}</span></p>`), o.join("\n");
1844
831
  }
1845
- function Gt(e) {
832
+ function rt(e) {
1846
833
  switch (e) {
1847
834
  case "part": return {
1848
835
  num: "TCNumPartie",
@@ -1866,22 +853,22 @@ function Gt(e) {
1866
853
  };
1867
854
  }
1868
855
  }
1869
- function Kt(e, t) {
1870
- let n = Jt(L(e(t).children("num").first().text()));
856
+ function it(e, t) {
857
+ let n = ot(E(e(t).children("num").first().text()));
1871
858
  if (n) return n;
1872
859
  for (let n of e(t).parents().get()) {
1873
- if (!V(n)) continue;
1874
- let t = K(n);
860
+ if (!A(n)) continue;
861
+ let t = V(n);
1875
862
  if (t !== "title" && t !== "part") continue;
1876
- let r = Jt(L(e(n).children("num").first().text()));
863
+ let r = ot(E(e(n).children("num").first().text()));
1877
864
  if (r) return r;
1878
865
  }
1879
866
  }
1880
- function qt(e, t) {
1881
- return Kt(e, t);
867
+ function at(e, t) {
868
+ return it(e, t);
1882
869
  }
1883
- function Jt(e) {
1884
- let [t, ...n] = L(e).split(/\s+/u);
870
+ function ot(e) {
871
+ let [t, ...n] = E(e).split(/\s+/u);
1885
872
  if (!t || n.length === 0) return;
1886
873
  let r = t.toLocaleLowerCase("fr-FR");
1887
874
  if ([
@@ -1891,10 +878,10 @@ function Jt(e) {
1891
878
  "section"
1892
879
  ].includes(r)) return `${r}-${n.join("_")}`;
1893
880
  }
1894
- function Yt(e) {
1895
- return `article-${L(e).replace(/^Article\s+/iu, "").replace(/\s+/gu, "_")} article`;
881
+ function st(e) {
882
+ return `article-${E(e).replace(/^Article\s+/iu, "").replace(/\s+/gu, "_")} article`;
1896
883
  }
1897
- function Xt(e) {
884
+ function ct(e) {
1898
885
  switch (e) {
1899
886
  case "part": return "partie";
1900
887
  case "book": return "livre";
@@ -1906,11 +893,11 @@ function Xt(e) {
1906
893
  default: return;
1907
894
  }
1908
895
  }
1909
- function Zt(e, t) {
1910
- return [L(e(t).children("num").first().text()), L(e(t).children("heading").first().text())].filter(Boolean).join(" ");
896
+ function lt(e, t) {
897
+ return [E(e(t).children("num").first().text()), E(e(t).children("heading").first().text())].filter(Boolean).join(" ");
1911
898
  }
1912
- function Qt(e, t) {
1913
- let n = L(e(t).children("num").first().text()), r = L(e(t).children("heading").first().text()), i = U(n) ?? {
899
+ function ut(e, t) {
900
+ let n = E(e(t).children("num").first().text()), r = E(e(t).children("heading").first().text()), i = M(n) ?? {
1914
901
  label: n,
1915
902
  num: n
1916
903
  };
@@ -1920,24 +907,24 @@ function Qt(e, t) {
1920
907
  type: "article"
1921
908
  };
1922
909
  }
1923
- function $t(e, t) {
910
+ function dt(e, t) {
1924
911
  t.articles?.length && (e.articles ??= [], e.articles.push(...t.articles)), t.divisions?.length && (e.divisions ??= [], e.divisions.push(...t.divisions));
1925
912
  }
1926
- function en(e, t) {
913
+ function J(e, t) {
1927
914
  let n = {};
1928
915
  return e(t).children().each((t, r) => {
1929
- if (!V(r)) return;
1930
- let i = K(r);
916
+ if (!A(r)) return;
917
+ let i = V(r);
1931
918
  if (i === "article") {
1932
- n.articles ??= [], n.articles.push(Qt(e, r));
919
+ n.articles ??= [], n.articles.push(ut(e, r));
1933
920
  return;
1934
921
  }
1935
- let a = Xt(i);
922
+ let a = ct(i);
1936
923
  if (!a) {
1937
- $t(n, en(e, r));
924
+ dt(n, J(e, r));
1938
925
  return;
1939
926
  }
1940
- let o = Zt(e, r), s = en(e, r);
927
+ let o = lt(e, r), s = J(e, r);
1941
928
  !o && !s.articles?.length && !s.divisions?.length || (n.divisions ??= [], n.divisions.push({
1942
929
  ...s,
1943
930
  id: e(r).attr("eId") ?? e(r).attr("GUID"),
@@ -1946,112 +933,112 @@ function en(e, t) {
1946
933
  }));
1947
934
  }), n;
1948
935
  }
1949
- function tn(e) {
936
+ function ft(e) {
1950
937
  let t = e("body").first().get(0);
1951
- return t === void 0 ? {} : en(e, t);
938
+ return t === void 0 ? {} : J(e, t);
1952
939
  }
1953
- function nn(e) {
940
+ function pt(e) {
1954
941
  return e("FRBRExpression FRBRdate[name=\"#depot\"]").attr("date") ?? e("FRBRWork FRBRdate[name=\"#presentation\"]").attr("date");
1955
942
  }
1956
- function rn(e) {
943
+ function mt(e) {
1957
944
  let t = e("preamble").first(), n = e("body").first(), r = ["<div class=\"akn-bill\">"];
1958
- return t.length > 0 && (r.push("<section class=\"akn-preamble\">"), r.push(wt(e, t.get(0))), r.push("</section>")), r.push("<section class=\"akn-body\">"), n.children().each((t, n) => {
1959
- V(n) && r.push(K(n) === "article" ? Y(e, n, "article", "akn-article") : q(e, n));
945
+ return t.length > 0 && (r.push("<section class=\"akn-preamble\">"), r.push(ze(e, t.get(0))), r.push("</section>")), r.push("<section class=\"akn-body\">"), n.children().each((t, n) => {
946
+ A(n) && r.push(V(n) === "article" ? q(e, n, "article", "akn-article") : H(e, n));
1960
947
  }), r.push("</section></div>"), r.join("\n");
1961
948
  }
1962
- function an(e) {
1963
- let t = y(e, { xml: {
949
+ function ht(t) {
950
+ let n = e(t, { xml: {
1964
951
  decodeEntities: !1,
1965
952
  lowerCaseTags: !1,
1966
953
  lowerCaseAttributeNames: !1,
1967
954
  xmlMode: !0
1968
- } }), n = nn(t), r = rn(t);
955
+ } }), r = pt(n), i = mt(n);
1969
956
  return {
1970
957
  sourceFormat: "akoma-ntoso",
1971
- documentDate: n,
1972
- html: r,
1973
- linkedHtml: r
958
+ documentDate: r,
959
+ html: i,
960
+ linkedHtml: i
1974
961
  };
1975
962
  }
1976
- function on(e) {
1977
- return sn(y(e));
963
+ function gt(t) {
964
+ return _t(e(t));
1978
965
  }
1979
- function sn(e) {
966
+ function _t(e) {
1980
967
  let t = [];
1981
968
  return e("article.akn-article").each((n, r) => {
1982
- let i = e(r).children("p.TCNumArticle").first().get(0), a = L(i ? e(i).text() : ""), o = U(a) ?? { label: a || `Article ${n + 1}` }, s = e(r).attr("id") ?? `akn-article-${String(n + 1).padStart(3, "0")}`, c = [r], l = et(e, s, c), u = l.filter((e) => e.kind !== "noise").map((e) => e.text).join("\n");
969
+ let i = e(r).children("p.TCNumArticle").first().get(0), a = E(i ? e(i).text() : ""), o = M(a) ?? { label: a || `Article ${n + 1}` }, s = e(r).attr("id") ?? `akn-article-${String(n + 1).padStart(3, "0")}`, c = [r], l = I(e, s, c), u = l.filter((e) => e.kind !== "noise").map((e) => e.text).join("\n");
1983
970
  t.push({
1984
971
  id: s,
1985
972
  label: o.label,
1986
973
  num: o.num,
1987
974
  title: o.title,
1988
- text: qe(e, c),
1989
- html: H(e, r),
975
+ text: me(e, c),
976
+ html: j(e, r),
1990
977
  directiveText: u,
1991
978
  blocks: l
1992
979
  });
1993
980
  }), t;
1994
981
  }
1995
- function cn(e) {
1996
- let t = y(e);
982
+ function vt(t) {
983
+ let n = e(t);
1997
984
  return {
1998
- articles: sn(t),
1999
- htmlWithLinks: t.html()
985
+ articles: _t(n),
986
+ htmlWithLinks: n.html()
2000
987
  };
2001
988
  }
2002
- async function ln(e, t) {
2003
- let n = new D("parseAkomaNtosoBillRaw"), r = n.timeSync("cheerioLoadXml", () => y(e, { xml: {
989
+ async function yt(t, n) {
990
+ let r = new u("parseAkomaNtosoBillRaw"), i = r.timeSync("cheerioLoadXml", () => e(t, { xml: {
2004
991
  decodeEntities: !1,
2005
992
  lowerCaseTags: !1,
2006
993
  lowerCaseAttributeNames: !1,
2007
994
  xmlMode: !0
2008
- } })), i = t.date ?? nn(r), a = n.timeSync("renderAknHtml", () => rn(r), { inputSize: e.length }), o = t.linkedHtml ?? await n.time("addLinksToRenderedAknHtml", () => W(a, {
2009
- ...t,
2010
- date: i
2011
- }, i)), s = n.timeSync("extractRenderedAknArticles", () => on(a)), c = n.timeSync("injectHiddenArticleSummary", () => tt(o, s)), { articles: l, htmlWithLinks: u } = n.timeSync("extractLinkedAknArticlesAndTaggedHtml", () => cn(c)), d = l.length > 0 ? l : s, f = n.timeSync("extractAknTableOfContents", () => tn(r)), p = n.timeSync("buildParsedDocument", () => vt("akoma-ntoso", a, l.length > 0 ? u : c, i, d, f));
2012
- return n.log({
2013
- articleCount: p.articles.length,
2014
- blockCount: p.articles.reduce((e, t) => e + t.blocks.length, 0),
2015
- directiveCount: p.directives.length,
2016
- targetDirectiveCount: p.directives.filter((e) => e.targetIds !== void 0).length
2017
- }), p;
995
+ } })), a = n.date ?? pt(i), o = r.timeSync("renderAknHtml", () => mt(i), { inputSize: t.length }), s = n.linkedHtml ?? await r.time("addLinksToRenderedAknHtml", () => N(o, {
996
+ ...n,
997
+ date: a
998
+ }, a)), c = r.timeSync("extractRenderedAknArticles", () => gt(o)), l = r.timeSync("injectHiddenArticleSummary", () => L(s, c)), { articles: d, htmlWithLinks: f } = r.timeSync("extractLinkedAknArticlesAndTaggedHtml", () => vt(l)), p = d.length > 0 ? d : c, m = r.timeSync("extractAknTableOfContents", () => ft(i)), h = r.timeSync("buildParsedDocument", () => z("akoma-ntoso", o, d.length > 0 ? f : l, a, p, m));
999
+ return r.log({
1000
+ articleCount: h.articles.length,
1001
+ blockCount: h.articles.reduce((e, t) => e + t.blocks.length, 0),
1002
+ directiveCount: h.directives.length,
1003
+ targetDirectiveCount: h.directives.filter((e) => e.targetIds !== void 0).length
1004
+ }), h;
2018
1005
  }
2019
- async function un(e, t) {
2020
- let n = an(e), r = t.date ?? n.documentDate;
1006
+ async function bt(e, t) {
1007
+ let n = ht(e), r = t.date ?? n.documentDate;
2021
1008
  return {
2022
1009
  sourceFormat: "akoma-ntoso",
2023
1010
  documentDate: r,
2024
1011
  html: n.html,
2025
- linkedHtml: await W(n.html, t, r)
1012
+ linkedHtml: await N(n.html, t, r)
2026
1013
  };
2027
1014
  }
2028
1015
  //#endregion
2029
1016
  //#region src/lib/server/assemblee_document_search.ts
2030
- var dn = /\bexpos[ée]\s+des\s+motifs\b/giu, fn = /\barticle\s+(?:premier|1er|\d+)/iu;
2031
- function pn(e) {
1017
+ var xt = /\bexpos[ée]\s+des\s+motifs\b/giu, St = /\barticle\s+(?:premier|1er|\d+)/iu;
1018
+ function Y(e) {
2032
1019
  return e.replace(/\u00a0/gu, " ").replace(/\s+/gu, " ").trim();
2033
1020
  }
2034
- function mn(e) {
2035
- let t = pn(y(e).text()), n = [...t.matchAll(dn)], r = /* @__PURE__ */ new Set(), i = [];
2036
- for (let [e, a] of n.entries()) {
2037
- let o = (a.index ?? 0) + a[0].length, s = t.slice(o), c = fn.exec(s), l = pn(s.slice(0, c?.index ?? s.length));
2038
- if (l.length < 20 || r.has(l)) continue;
2039
- r.add(l);
1021
+ function Ct(t) {
1022
+ let n = Y(e(t).text()), r = [...n.matchAll(xt)], i = /* @__PURE__ */ new Set(), a = [];
1023
+ for (let [e, t] of r.entries()) {
1024
+ let o = (t.index ?? 0) + t[0].length, s = n.slice(o), c = St.exec(s), l = Y(s.slice(0, c?.index ?? s.length));
1025
+ if (l.length < 20 || i.has(l)) continue;
1026
+ i.add(l);
2040
1027
  let u = `expose-des-motifs-${e + 1}`;
2041
- i.push({
1028
+ a.push({
2042
1029
  anchor: u,
2043
1030
  articleNumber: null,
2044
1031
  content: l,
2045
1032
  itemId: u,
2046
1033
  itemKind: "expose_des_motifs",
2047
- label: n.length === 1 ? "Exposé des motifs" : `Exposé des motifs ${e + 1}`,
1034
+ label: r.length === 1 ? "Exposé des motifs" : `Exposé des motifs ${e + 1}`,
2048
1035
  title: null
2049
1036
  });
2050
1037
  }
2051
- return i;
1038
+ return a;
2052
1039
  }
2053
- async function hn({ date: e, html: t, linkBaseUrl: n, linkType: r }) {
2054
- let i = await bt(t, {
1040
+ async function wt({ date: e, html: t, linkBaseUrl: n, linkType: r }) {
1041
+ let i = await Fe(t, {
2055
1042
  date: e,
2056
1043
  includeDirectiveAnalysis: !1,
2057
1044
  linkBaseUrl: n,
@@ -2060,7 +1047,7 @@ async function hn({ date: e, html: t, linkBaseUrl: n, linkType: r }) {
2060
1047
  });
2061
1048
  return {
2062
1049
  items: [...i.articles.map((e) => {
2063
- let t = pn(e.directiveText || e.text);
1050
+ let t = Y(e.directiveText || e.text);
2064
1051
  if (t) return {
2065
1052
  anchor: e.id,
2066
1053
  articleNumber: e.num ?? null,
@@ -2070,17 +1057,17 @@ async function hn({ date: e, html: t, linkBaseUrl: n, linkType: r }) {
2070
1057
  label: e.label,
2071
1058
  title: e.title ?? null
2072
1059
  };
2073
- }).filter((e) => e !== void 0), ...mn(t)],
1060
+ }).filter((e) => e !== void 0), ...Ct(t)],
2074
1061
  tableOfContents: i.tableOfContents
2075
1062
  };
2076
1063
  }
2077
- function gn(e, t) {
2078
- return C("sha256").update(JSON.stringify({
1064
+ function Tt(e, t) {
1065
+ return h("sha256").update(JSON.stringify({
2079
1066
  item: e,
2080
1067
  metadata: t
2081
1068
  })).digest("hex");
2082
1069
  }
2083
- function _n(e) {
1070
+ function Et(e) {
2084
1071
  if (typeof e != "object" || !e) return;
2085
1072
  let t = e.cycleDeVie?.chrono;
2086
1073
  if (t !== void 0) for (let e of [
@@ -2095,11 +1082,11 @@ function _n(e) {
2095
1082
  }
2096
1083
  //#endregion
2097
1084
  //#region src/lib/server/senat_amendment_search.ts
2098
- function vn(e) {
2099
- return e?.trim() ? y(e).text().replace(/\u00a0/gu, " ").replace(/\s+/gu, " ").trim() : "";
1085
+ function Dt(t) {
1086
+ return t?.trim() ? e(t).text().replace(/\u00a0/gu, " ").replace(/\s+/gu, " ").trim() : "";
2100
1087
  }
2101
- function yn({ dispositifHtml: e, objetHtml: t }) {
2102
- let n = vn(e), r = vn(t);
1088
+ function Ot({ dispositifHtml: e, objetHtml: t }) {
1089
+ let n = Dt(e), r = Dt(t);
2103
1090
  return [...n ? [{
2104
1091
  content: n,
2105
1092
  itemKind: "dispositif",
@@ -2110,20 +1097,20 @@ function yn({ dispositifHtml: e, objetHtml: t }) {
2110
1097
  label: "Objet"
2111
1098
  }] : []];
2112
1099
  }
2113
- function bn(e, t) {
2114
- return C("sha256").update(JSON.stringify({
1100
+ function kt(e, t) {
1101
+ return h("sha256").update(JSON.stringify({
2115
1102
  item: e,
2116
1103
  metadata: t
2117
1104
  })).digest("hex");
2118
1105
  }
2119
1106
  //#endregion
2120
1107
  //#region src/lib/server/senat_document_search.ts
2121
- var xn = /^article\s+(.+?)(?:\s*[::]\s*(.+))?$/iu;
1108
+ var At = /^article\s+(.+?)(?:\s*[::]\s*(.+))?$/iu;
2122
1109
  function X(e) {
2123
1110
  return e.replace(/\u00a0/gu, " ").replace(/\s+/gu, " ").trim();
2124
1111
  }
2125
- function Sn(e) {
2126
- let t = e.match(xn);
1112
+ function jt(e) {
1113
+ let t = e.match(At);
2127
1114
  if (!t) return {
2128
1115
  articleNumber: null,
2129
1116
  label: e,
@@ -2136,21 +1123,21 @@ function Sn(e) {
2136
1123
  title: r
2137
1124
  };
2138
1125
  }
2139
- function Cn(e) {
2140
- let t = y(e), n = [], r = X(t("section.akn-preamble").text());
2141
- return r && n.push({
1126
+ function Mt(t) {
1127
+ let n = e(t), r = [], i = X(n("section.akn-preamble").text());
1128
+ return i && r.push({
2142
1129
  anchor: "senat-expose-des-motifs",
2143
1130
  articleNumber: null,
2144
- content: r,
1131
+ content: i,
2145
1132
  itemId: "expose-des-motifs",
2146
1133
  itemKind: "expose_des_motifs",
2147
1134
  label: "Exposé des motifs",
2148
1135
  title: null
2149
- }), t("article.akn-article").each((e, r) => {
2150
- let i = t(r), a = i.attr("id") || `akn-article-${e + 1}`, o = X(i.children("p.TCNumArticle").first().text()), s = `Article ${e + 1}`, c = Sn(o || s), l = i.clone();
1136
+ }), n("article.akn-article").each((e, t) => {
1137
+ let i = n(t), a = i.attr("id") || `akn-article-${e + 1}`, o = X(i.children("p.TCNumArticle").first().text()), s = `Article ${e + 1}`, c = jt(o || s), l = i.clone();
2151
1138
  l.children("p.TCNumArticle").remove();
2152
1139
  let u = X(l.text());
2153
- u && n.push({
1140
+ u && r.push({
2154
1141
  anchor: i.attr("id") || null,
2155
1142
  articleNumber: c.articleNumber,
2156
1143
  content: u,
@@ -2159,42 +1146,42 @@ function Cn(e) {
2159
1146
  label: c.label,
2160
1147
  title: c.title
2161
1148
  });
2162
- }), n;
1149
+ }), r;
2163
1150
  }
2164
- function wn(e, t) {
2165
- return C("sha256").update(JSON.stringify({
1151
+ function Nt(e, t) {
1152
+ return h("sha256").update(JSON.stringify({
2166
1153
  item: e,
2167
1154
  metadata: t
2168
1155
  })).digest("hex");
2169
1156
  }
2170
1157
  //#endregion
2171
1158
  //#region src/lib/server/senat_document_sources.ts
2172
- var Tn = new Set(["senat.fr", "www.senat.fr"]), En = "https://www.senat.fr";
2173
- function Dn(e) {
1159
+ var Pt = new Set(["senat.fr", "www.senat.fr"]), Z = "https://www.senat.fr";
1160
+ function Ft(e) {
2174
1161
  return e?.trim() || void 0;
2175
1162
  }
2176
- function On(e) {
1163
+ function It(e) {
2177
1164
  try {
2178
- let t = e.replace(/^\/+/, ""), n = /^https?:\/\//iu.test(e) ? new URL(e) : new URL(/^(?:akomantoso|leg)\//iu.test(t) ? `/${t}` : `/leg/${t}`, En);
2179
- return Tn.has(n.hostname.toLowerCase()) ? n : void 0;
1165
+ let t = e.replace(/^\/+/, ""), n = /^https?:\/\//iu.test(e) ? new URL(e) : new URL(/^(?:akomantoso|leg)\//iu.test(t) ? `/${t}` : `/leg/${t}`, Z);
1166
+ return Pt.has(n.hostname.toLowerCase()) ? n : void 0;
2180
1167
  } catch {
2181
1168
  return;
2182
1169
  }
2183
1170
  }
2184
- function kn(e) {
2185
- let t = Dn(e);
1171
+ function Lt(e) {
1172
+ let t = Ft(e);
2186
1173
  if (t === void 0) return {
2187
1174
  publicUrl: null,
2188
1175
  status: "no_url"
2189
1176
  };
2190
- let n = On(t);
1177
+ let n = It(t);
2191
1178
  if (n === void 0) return {
2192
1179
  publicUrl: t,
2193
1180
  status: "unsupported_source"
2194
1181
  };
2195
1182
  let r = n.pathname;
2196
1183
  if (/^\/akomantoso\/[^/]+\.akn\.xml$/iu.test(r)) return {
2197
- akomaNtosoUrl: `${En}${r}`,
1184
+ akomaNtosoUrl: `${Z}${r}`,
2198
1185
  publicUrl: n.toString(),
2199
1186
  status: "available"
2200
1187
  };
@@ -2203,17 +1190,17 @@ function kn(e) {
2203
1190
  publicUrl: n.toString(),
2204
1191
  status: "unsupported_source"
2205
1192
  } : {
2206
- akomaNtosoUrl: `${En}/akomantoso/${i.replace(/\.html$/iu, ".akn.xml")}`,
1193
+ akomaNtosoUrl: `${Z}/akomantoso/${i.replace(/\.html$/iu, ".akn.xml")}`,
2207
1194
  publicUrl: n.toString(),
2208
1195
  status: "available"
2209
1196
  };
2210
1197
  }
2211
- function An(e) {
1198
+ function Rt(e) {
2212
1199
  return /^\s*(?:<\?xml\b[^>]*>\s*)?<akomaNtoso[\s/>]/iu.test(e);
2213
1200
  }
2214
1201
  //#endregion
2215
1202
  //#region src/lib/alineas/alineas_numbers.ts
2216
- var jn = {
1203
+ var zt = {
2217
1204
  "0150a855548f15a2af52ea057be53f5d": 1,
2218
1205
  "039826cf379b94afefe90b25c6045ca0": 1,
2219
1206
  "03a7e564b84662f4d957c51018e26244": 1,
@@ -21187,7 +20174,7 @@ var jn = {
21187
20174
  d16d29c923bd60c7b095b66c6058fe60: 1664,
21188
20175
  "1c14c2adf5cfda3220b2057160e10e91": 1665,
21189
20176
  e44c55ca1ac46ff46420686a466c9fc6: 1665
21190
- }, Mn = "\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", Nn = "\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", Pn = "\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", Fn = "\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", In = "\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", Ln = {
20177
+ }, Bt = "\np:has(.alinea) {\n margin: 0.6em 0;\n}\n.alinea {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n min-width: 1.5em;\n height: 1.5em;\n padding: 0 0.3em;\n margin-right: 0.3em;\n font-size: 0.75em;\n font-weight: bold;\n color: #555;\n background-color: #f0f0f0;\n border: 1px solid #ccc;\n border-radius: 1em;\n vertical-align: middle;\n}\n", Vt = "\nh1 {\n font-size: 1.8em;\n margin: 1em 0 0.5em 0;\n}\nh2 {\n font-size: 1.5em;\n margin: 0.9em 0 0.4em 0;\n}\nh3 {\n font-size: 1.3em;\n margin: 0.8em 0 0.4em 0;\n}\nh4 {\n font-size: 1.15em;\n margin: 0.7em 0 0.3em 0;\n}\nh5 {\n font-size: 1.05em;\n margin: 0.6em 0 0.3em 0;\n}\nh6 {\n font-size: 1em;\n margin: 0.5em 0 0.3em 0;\n}\n", Ht = "\n.expose-motifs-titre {\n font-size: 1.1em;\n font-weight: bold;\n color: #0070b9;\n margin: 1em 0 0.5em 0;\n}\n.expose-motifs {\n border-left: 3px solid #0070b9;\n padding-left: 1em;\n margin: 0.5em 0 1em 0;\n color: #333;\n}\n.expose-motifs p {\n margin: 0.5em 0;\n}\n", Ut = "\nol {\n list-style: none;\n padding-left: 0;\n margin: 0.5em 0;\n counter-reset: list-counter;\n}\nol > li {\n counter-increment: list-counter;\n margin: 0.3em 0;\n padding-left: 2.3em;\n position: relative;\n}\nol > li::before {\n content: counter(list-counter);\n display: inline-flex;\n align-items: center;\n justify-content: center;\n min-width: 1.5em;\n height: 1.5em;\n padding: 0 0.3em;\n font-size: 0.75em;\n font-weight: bold;\n color: #555;\n background-color: #f0f0f0;\n border: 1px solid #ccc;\n border-radius: 1em;\n position: absolute;\n left: 0;\n top: 0.1em;\n}\n", Wt = "\n.cover-title {\n font-size: 1.8em;\n font-weight: bold;\n color: #0070b9;\n text-align: center;\n margin: 1em 0;\n}\n.cover-subtitle {\n font-size: 1.4em;\n font-weight: bold;\n color: #0070b9;\n text-align: center;\n margin: 0.8em 0;\n}\n.cover-info {\n text-align: center;\n margin: 0.3em 0;\n color: #333;\n}\n.cover-year {\n font-size: 2em;\n font-weight: bold;\n color: #0070b9;\n text-align: center;\n margin: 1em 0;\n}\n", Gt = {
21191
20178
  assnatetatagr: { bold: !0 },
21192
20179
  assnatetatagrgr: { bold: !0 },
21193
20180
  assnatetatatr: { bold: !0 },
@@ -21288,29 +20275,29 @@ var jn = {
21288
20275
  assnatxl67: { align: "center" },
21289
20276
  assnatenteteequilibre: { align: "center" }
21290
20277
  };
21291
- function Rn(e) {
21292
- let t = Object.keys(Ln).sort((e, t) => t.length - e.length);
21293
- for (let n of t) if (e.includes(n)) return Ln[n];
20278
+ function Kt(e) {
20279
+ let t = Object.keys(Gt).sort((e, t) => t.length - e.length);
20280
+ for (let n of t) if (e.includes(n)) return Gt[n];
21294
20281
  return null;
21295
20282
  }
21296
- function zn(e) {
21297
- return re.createHash("md5").update(e).digest("hex");
20283
+ function qt(e) {
20284
+ return m.createHash("md5").update(e).digest("hex");
21298
20285
  }
21299
- function Bn(e) {
20286
+ function Jt(e) {
21300
20287
  return e ? /font-weight\s*:\s*(bold|[6-9]00|1000)/i.test(e) || /font-family\s*:\s*[^;]*\bBold\b/i.test(e) : !1;
21301
20288
  }
21302
- function Vn(e) {
20289
+ function Yt(e) {
21303
20290
  return e ? /font-style\s*:\s*italic/i.test(e) || /font-family\s*:\s*[^;]*\bItalic\b/i.test(e) : !1;
21304
20291
  }
21305
- function Hn(e) {
20292
+ function Xt(e) {
21306
20293
  if (!e || !/vertical-align\s*:\s*super/i.test(e)) return !1;
21307
20294
  let t = e.match(/font-size\s*:\s*([\d.]+)pt/i);
21308
20295
  return !(t && parseFloat(t[1]) < 8);
21309
20296
  }
21310
- function Un(e) {
20297
+ function Zt(e) {
21311
20298
  return e ? /vertical-align\s*:\s*sub/i.test(e) : !1;
21312
20299
  }
21313
- function Wn(e) {
20300
+ function Qt(e) {
21314
20301
  if (!e) return;
21315
20302
  let t = [
21316
20303
  "width",
@@ -21345,15 +20332,15 @@ function Wn(e) {
21345
20332
  }
21346
20333
  return n.length > 0 ? n.join("; ") : void 0;
21347
20334
  }
21348
- function Gn(e, t) {
20335
+ function $t(e, t) {
21349
20336
  return !!(e && /text-align\s*:\s*center/i.test(e) || t && /center/i.test(t));
21350
20337
  }
21351
- function Kn(e) {
20338
+ function en(e) {
21352
20339
  if (!e) return null;
21353
20340
  let t = e.match(/text-align\s*:\s*(left|center|right|justify)/i);
21354
20341
  return t ? t[1].toLowerCase() : null;
21355
20342
  }
21356
- function qn(e) {
20343
+ function tn(e) {
21357
20344
  if (!e) return null;
21358
20345
  for (let [t, n] of [
21359
20346
  [/assnat1Tome|assnatAN1PARTIE/i, 1],
@@ -21365,73 +20352,73 @@ function qn(e) {
21365
20352
  ]) if (t.test(e)) return n;
21366
20353
  return null;
21367
20354
  }
21368
- function Jn(e, t = {}) {
21369
- let { keepAlignment: n = !0, removeEmptyParagraphs: r = !0, strictAlineas: i = !1 } = t, a = y(e, { xml: { decodeEntities: !1 } });
21370
- a("style, script, meta, link").remove(), a(".assnatHeader, .assnatFooter, .assnatHeaderLeft, .assnatHeaderandFooter").remove(), a(".assnatFARSautApres, .assnatFARSautAvant, .assnatFARSautPageNiv0, .assnatFARSautPageNiv1, .assnatFARSautPageNiv1PG").remove(), a(".assnatFARTT08Bleu").each((e, t) => {
21371
- let n = a(t).closest("table");
20355
+ function nn(t, n = {}) {
20356
+ let { keepAlignment: r = !0, removeEmptyParagraphs: i = !0, strictAlineas: a = !1 } = n, o = e(t, { xml: { decodeEntities: !1 } });
20357
+ o("style, script, meta, link").remove(), o(".assnatHeader, .assnatFooter, .assnatHeaderLeft, .assnatHeaderandFooter").remove(), o(".assnatFARSautApres, .assnatFARSautAvant, .assnatFARSautPageNiv0, .assnatFARSautPageNiv1, .assnatFARSautPageNiv1PG").remove(), o(".assnatFARTT08Bleu").each((e, t) => {
20358
+ let n = o(t).closest("table");
21372
20359
  n.length > 0 && n.remove();
21373
- }), a("table").each((e, t) => {
21374
- let n = a(t), r = n.find("> tbody > tr, > tr");
20360
+ }), o("table").each((e, t) => {
20361
+ let n = o(t), r = n.find("> tbody > tr, > tr");
21375
20362
  if (r.length !== 1) return;
21376
20363
  let i = r.find("> td, > th");
21377
20364
  if (i.length !== 1) return;
21378
- let o = i.first();
21379
- if (o.find("h1, h2, h3, h4, h5, h6").length > 0) {
21380
- let e = o.attr("style") || "";
21381
- (e.includes("border-left:") || e.includes("border-bottom:")) && n.replaceWith(o.html() || "");
20365
+ let a = i.first();
20366
+ if (a.find("h1, h2, h3, h4, h5, h6").length > 0) {
20367
+ let e = a.attr("style") || "";
20368
+ (e.includes("border-left:") || e.includes("border-bottom:")) && n.replaceWith(a.html() || "");
21382
20369
  }
21383
- }), a("br[style*=\"page-break\"]").remove(), a("span[style*=\"position:absolute\"][style*=\"z-index:-65537\"]").each((e, t) => {
21384
- let n = a(t), r = n.find("img");
20370
+ }), o("br[style*=\"page-break\"]").remove(), o("span[style*=\"position:absolute\"][style*=\"z-index:-65537\"]").each((e, t) => {
20371
+ let n = o(t), r = n.find("img");
21385
20372
  if (r.length > 0) {
21386
20373
  let e = parseInt(r.attr("width") || "0", 10), t = parseInt(r.attr("height") || "0", 10);
21387
20374
  (e >= 50 || t >= 50) && n.remove();
21388
20375
  }
21389
- }), a("span[style*=\"position:absolute\"]").each((e, t) => {
21390
- let n = a(t), r = n.attr("style") || "", i = n.find("img");
20376
+ }), o("span[style*=\"position:absolute\"]").each((e, t) => {
20377
+ let n = o(t), r = n.attr("style") || "", i = n.find("img");
21391
20378
  if (i.length !== 0 && !(n.parents("del").length > 0 || n.find("del img").length > 0) && !(i.parent("del").length > 0)) {
21392
20379
  let e = i.attr();
21393
20380
  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")) {
21394
- let t = (e.src || "").match(/^data:image\/png;base64,(.+)$/), r = t ? zn(t[1]) : void 0, i = r ? ` data-image-hash="${r}"` : "";
20381
+ let t = (e.src || "").match(/^data:image\/png;base64,(.+)$/), r = t ? qt(t[1]) : void 0, i = r ? ` data-image-hash="${r}"` : "";
21395
20382
  n.replaceWith(`<span class="alinea"${i}></span>`);
21396
20383
  return;
21397
20384
  }
21398
20385
  }
21399
- }), a("span[style*=\"position:absolute\"]").each((e, t) => {
21400
- let n = a(t), r = n.attr("style") || "", i = n.find("img");
20386
+ }), o("span[style*=\"position:absolute\"]").each((e, t) => {
20387
+ let n = o(t), r = n.attr("style") || "", i = n.find("img");
21401
20388
  if (i.length > 0 && n.children().length === 1 && r.includes("height:0pt")) {
21402
20389
  let e = parseInt(i.attr("width") || "0", 10), t = parseInt(i.attr("height") || "0", 10);
21403
20390
  e < 100 || t < 100 ? n.remove() : n.replaceWith(i);
21404
20391
  }
21405
- }), a("img").each((e, t) => {
21406
- let n = a(t), r = parseInt(n.attr("width") || "0", 10), i = parseInt(n.attr("height") || "0", 10);
20392
+ }), o("img").each((e, t) => {
20393
+ let n = o(t), r = parseInt(n.attr("width") || "0", 10), i = parseInt(n.attr("height") || "0", 10);
21407
20394
  r < 100 || i < 100 ? n.remove() : n.removeAttr("style").removeAttr("class");
21408
- }), a("span[style*=\"height:0pt\"]:not(.alinea)").each((e, t) => {
21409
- let n = a(t), r = n.text().trim();
20395
+ }), o("span[style*=\"height:0pt\"]:not(.alinea)").each((e, t) => {
20396
+ let n = o(t), r = n.text().trim();
21410
20397
  (!r || r === "\xA0") && n.remove();
21411
- }), a("span[style*=\"display:block\"][style*=\"position:absolute\"]:not(.alinea)").remove(), a("del").remove();
21412
- function o(e) {
21413
- let t = a(e), n = t.attr("style"), r = e.tagName?.toLowerCase() || "", i = Bn(n) || r === "b" || r === "strong", o = Vn(n) || r === "i" || r === "em", s = Hn(n) || r === "sup", c = Un(n) || r === "sub", l = t.attr("class") || "";
21414
- return /bold/i.test(l) && (i = !0), /strongemphasis/i.test(l) ? i = !0 : /italic|emphasis/i.test(l) && (o = !0), {
20398
+ }), o("span[style*=\"display:block\"][style*=\"position:absolute\"]:not(.alinea)").remove(), o("del").remove();
20399
+ function s(e) {
20400
+ let t = o(e), n = t.attr("style"), r = e.tagName?.toLowerCase() || "", i = Jt(n) || r === "b" || r === "strong", a = Yt(n) || r === "i" || r === "em", s = Xt(n) || r === "sup", c = Zt(n) || r === "sub", l = t.attr("class") || "";
20401
+ return /bold/i.test(l) && (i = !0), /strongemphasis/i.test(l) ? i = !0 : /italic|emphasis/i.test(l) && (a = !0), {
21415
20402
  bold: i,
21416
- italic: o,
20403
+ italic: a,
21417
20404
  sup: s,
21418
20405
  sub: c
21419
20406
  };
21420
20407
  }
21421
- function s(e, t) {
20408
+ function c(e, t) {
21422
20409
  let n = e;
21423
20410
  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;
21424
20411
  }
21425
- let c = a("span").length;
21426
- for (; c > 0;) {
21427
- a("span").each((e, t) => {
21428
- 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");
20412
+ let l = o("span").length;
20413
+ for (; l > 0;) {
20414
+ o("span").each((e, t) => {
20415
+ 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");
21429
20416
  if (u) {
21430
20417
  let e = n.html() || "";
21431
20418
  n.replaceWith(e);
21432
20419
  } else if (l) {
21433
20420
  let e = n.html() || "";
21434
- n.replaceWith(s(e, c));
20421
+ n.replaceWith(c(e, a));
21435
20422
  } else if (d) n.removeAttr("style");
21436
20423
  else if (f) n.removeAttr("style").removeAttr("class");
21437
20424
  else {
@@ -21439,76 +20426,76 @@ function Jn(e, t = {}) {
21439
20426
  e.trim() === "" && e.length > 0 ? n.replaceWith(" ") : n.replaceWith(e);
21440
20427
  }
21441
20428
  });
21442
- let e = a("span").length;
21443
- if (e >= c) break;
21444
- c = e;
20429
+ let e = o("span").length;
20430
+ if (e >= l) break;
20431
+ l = e;
21445
20432
  }
21446
- for (a("p").each((e, t) => {
21447
- let r = a(t), i = r.attr("class") || "", o = r.attr("style"), s = qn(i);
20433
+ for (o("p").each((e, t) => {
20434
+ let n = o(t), i = n.attr("class") || "", a = n.attr("style"), s = tn(i);
21448
20435
  if (i.includes("assnatFARCouvTitreD")) {
21449
- let e = r.html() || "";
21450
- r.replaceWith(`<p class="cover-subtitle">${e}</p>`);
20436
+ let e = n.html() || "";
20437
+ n.replaceWith(`<p class="cover-subtitle">${e}</p>`);
21451
20438
  return;
21452
20439
  }
21453
20440
  if (i.includes("assnatFARCouvTitre")) {
21454
- let e = r.html() || "";
21455
- r.replaceWith(`<p class="cover-title">${e}</p>`);
20441
+ let e = n.html() || "";
20442
+ n.replaceWith(`<p class="cover-title">${e}</p>`);
21456
20443
  return;
21457
20444
  }
21458
20445
  if (i.includes("assnatFPFprem")) {
21459
- let e = r.html() || "";
21460
- r.replaceWith(`<p class="cover-info">${e}</p>`);
20446
+ let e = n.html() || "";
20447
+ n.replaceWith(`<p class="cover-info">${e}</p>`);
21461
20448
  return;
21462
20449
  }
21463
20450
  if (i.includes("assnatFARCouvAnnee")) {
21464
- let e = r.html() || "";
21465
- r.replaceWith(`<p class="cover-year">${e}</p>`);
20451
+ let e = n.html() || "";
20452
+ n.replaceWith(`<p class="cover-year">${e}</p>`);
21466
20453
  return;
21467
20454
  }
21468
20455
  if (i.includes("assnatFPFexpogentitre1")) {
21469
- let e = r.html() || "";
21470
- r.replaceWith(`<p class="expose-motifs-titre">${e}</p>`);
20456
+ let e = n.html() || "";
20457
+ n.replaceWith(`<p class="expose-motifs-titre">${e}</p>`);
21471
20458
  return;
21472
20459
  }
21473
20460
  if (i.includes("assnatFPFexpogentexte")) {
21474
- r.removeAttr("style").attr("class", "expose-motifs-text");
20461
+ n.removeAttr("style").attr("class", "expose-motifs-text");
21475
20462
  return;
21476
20463
  }
21477
- let c = r.text().trim().startsWith("«");
20464
+ let c = n.text().trim().startsWith("«");
21478
20465
  if (s && !c) {
21479
- let e = a(`<h${s}>${r.html() || ""}</h${s}>`);
21480
- n && Gn(o, i) && e.attr("align", "center"), r.replaceWith(e);
20466
+ let e = o(`<h${s}>${n.html() || ""}</h${s}>`);
20467
+ r && $t(a, i) && e.attr("align", "center"), n.replaceWith(e);
21481
20468
  } else {
21482
- let e = Rn(i), t;
21483
- if (n) {
21484
- let n = Kn(o);
20469
+ let e = Kt(i), t;
20470
+ if (r) {
20471
+ let n = en(a);
21485
20472
  n && n !== "justify" && n !== "left" ? t = n : e?.align && (t = e.align);
21486
20473
  }
21487
- if (r.removeAttr("style").removeAttr("class"), t && r.attr("align", t), e?.bold) {
21488
- let e = r.html() || "";
21489
- e.trim().startsWith("<strong>") || r.html(`<strong>${e}</strong>`);
20474
+ if (n.removeAttr("style").removeAttr("class"), t && n.attr("align", t), e?.bold) {
20475
+ let e = n.html() || "";
20476
+ e.trim().startsWith("<strong>") || n.html(`<strong>${e}</strong>`);
21490
20477
  }
21491
20478
  }
21492
- }), a("h1, h2, h3, h4, h5, h6").each((e, t) => {
21493
- let r = a(t), i = r.attr("style"), o = r.attr("class");
21494
- n && Gn(i, o) ? (r.removeAttr("style").removeAttr("class"), r.attr("align", "center")) : r.removeAttr("style").removeAttr("class");
21495
- }), a("a").each((e, t) => {
21496
- let n = a(t), r = n.attr("href"), i = n.attr("id"), o = { ...t.attribs || {} };
21497
- for (let e of Object.keys(o)) e !== "href" && e !== "id" && n.removeAttr(e);
20479
+ }), o("h1, h2, h3, h4, h5, h6").each((e, t) => {
20480
+ let n = o(t), i = n.attr("style"), a = n.attr("class");
20481
+ r && $t(i, a) ? (n.removeAttr("style").removeAttr("class"), n.attr("align", "center")) : n.removeAttr("style").removeAttr("class");
20482
+ }), o("a").each((e, t) => {
20483
+ let n = o(t), r = n.attr("href"), i = n.attr("id"), a = { ...t.attribs || {} };
20484
+ for (let e of Object.keys(a)) e !== "href" && e !== "id" && n.removeAttr(e);
21498
20485
  if (!r && !i) n.replaceWith(n.html() || "");
21499
20486
  else if (!r && i) {
21500
20487
  let e = n.html() || "";
21501
20488
  n.replaceWith(`<span id="${i}">${e}</span>`);
21502
20489
  }
21503
- }); a("div").length > 0;) a("div").each((e, t) => {
21504
- let n = a(t), r = n.html() || "";
20490
+ }); o("div").length > 0;) o("div").each((e, t) => {
20491
+ let n = o(t), r = n.html() || "";
21505
20492
  n.replaceWith(r);
21506
20493
  });
21507
- a(".expose-motifs-titre").each((e, t) => {
21508
- let n = a(t), r = [], i = n.next();
20494
+ o(".expose-motifs-titre").each((e, t) => {
20495
+ let n = o(t), r = [], i = n.next();
21509
20496
  for (; i.length > 0;) if (i.is("table") && i.find(".expose-motifs-text").length > 0) {
21510
20497
  i.find(".expose-motifs-text").each((e, t) => {
21511
- r.push(a(t).clone());
20498
+ r.push(o(t).clone());
21512
20499
  });
21513
20500
  let e = i;
21514
20501
  i = i.next(), e.remove();
@@ -21522,43 +20509,43 @@ function Jn(e, t = {}) {
21522
20509
  i = i.next(), e.remove();
21523
20510
  } else break;
21524
20511
  if (r.length > 0) {
21525
- let e = a("<div class=\"expose-motifs\"></div>");
20512
+ let e = o("<div class=\"expose-motifs\"></div>");
21526
20513
  r.forEach((t) => {
21527
20514
  t.removeClass("expose-motifs-text"), e.append(t);
21528
20515
  }), n.after(e);
21529
20516
  }
21530
- }), a("br").each((e, t) => {
21531
- a(t).removeAttr("style").removeAttr("class");
21532
- }), a("table, tr, td, th, thead, tbody, tfoot").each((e, t) => {
21533
- let n = a(t), r = Wn(n.attr("style"));
20517
+ }), o("br").each((e, t) => {
20518
+ o(t).removeAttr("style").removeAttr("class");
20519
+ }), o("table, tr, td, th, thead, tbody, tfoot").each((e, t) => {
20520
+ let n = o(t), r = Qt(n.attr("style"));
21534
20521
  n.removeAttr("style").removeAttr("class"), r && n.attr("style", r);
21535
- }), a("td, th").each((e, t) => {
21536
- let n = a(t), r = n.children();
20522
+ }), o("td, th").each((e, t) => {
20523
+ let n = o(t), r = n.children();
21537
20524
  if (r.length === 1 && r.first().is("p")) {
21538
- let e = r.first(), t = n.html() || "", i = a.html(e);
20525
+ let e = r.first(), t = n.html() || "", i = o.html(e);
21539
20526
  if (t.trim() === i.trim()) {
21540
20527
  let t = e.attr("align"), r = e.attr("id");
21541
20528
  n.html(e.html() || ""), t && !n.attr("align") && n.attr("align", t), r && !n.attr("id") && n.attr("id", r);
21542
20529
  }
21543
20530
  }
21544
- }), a("ol, ul").each((e, t) => {
21545
- let n = a(t), r = n.attr("start");
20531
+ }), o("ol, ul").each((e, t) => {
20532
+ let n = o(t), r = n.attr("start");
21546
20533
  if (n.removeAttr("style").removeAttr("class"), r) {
21547
20534
  let e = parseInt(r, 10);
21548
20535
  !isNaN(e) && e > 1 && n.attr("style", `counter-reset: list-counter ${e - 1}`), n.attr("start", r);
21549
20536
  }
21550
- }), a("li").each((e, t) => {
21551
- let n = a(t), r = Kn(n.attr("style"));
20537
+ }), o("li").each((e, t) => {
20538
+ let n = o(t), r = en(n.attr("style"));
21552
20539
  n.removeAttr("style").removeAttr("class"), r === "center" && n.attr("style", "text-align: center");
21553
- let i = n.html() || "", o = i.replace(/^(\s|&#xa0;|&#160;|\u00a0)+/, "");
21554
- o !== i && n.html(o);
21555
- }), Yn(a), Xn(a, i);
21556
- let l = a("body").html() || a.html(), u = l.includes("class=\"alinea"), d = a("ol").length > 0, f = a("h1, h2, h3, h4, h5, h6").length > 0, p = l.includes("class=\"expose-motifs"), m = l.includes("class=\"cover-title\"") || l.includes("class=\"cover-subtitle\"") || l.includes("class=\"cover-info\"") || l.includes("class=\"cover-year\""), h = "";
21557
- m && (h += In), f && (h += Nn), p && (h += Pn), u && (h += Mn), d && (h += Fn);
21558
- let g = h ? `<style>${h}</style>\n${l}` : l;
21559
- return g = g.replace(/>\s+</g, "> <").replace(/\r\n/g, "\n").replace(/\r/g, "\n").replace(/\n{3,}/g, "\n\n").split("\n").map((e) => e.trim()).filter((e) => e.length > 0).join("\n"), g = g.replace(/&nbsp;/g, "\xA0"), r && (g = g.replace(/<p[^>]*>\s*(&nbsp;|&#xa0;|&#160;|\u00a0|\s)*\s*<\/p>/gi, "").replace(/<p[^>]*>\s*<(strong|em|b|i)>\s*(&nbsp;|&#xa0;|&#160;|\u00a0|\s)*\s*<\/\1>\s*<\/p>/gi, "")), g = g.replace(/<span[^>]*>\s*<\/span>/gi, ""), g = g.replace(/ class=""/g, ""), g = Zn(g), g = g.replace(/<(strong|em|b|i|sup|sub)>\s*(&nbsp;|&#xa0;|&#160;|\u00a0|\s)*\s*<\/\1>/gi, "").replace(/<(strong|em|b|i)>(&nbsp;|&#xa0;|&#160;|\u00a0)+<\/\1>/gi, " ").replace(/<br\s*\/?>/gi, "<br/>").replace(/ +/g, " ").trim(), g;
20540
+ let i = n.html() || "", a = i.replace(/^(\s|&#xa0;|&#160;|\u00a0)+/, "");
20541
+ a !== i && n.html(a);
20542
+ }), rn(o), an(o, a);
20543
+ 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 = "";
20544
+ h && (g += Wt), p && (g += Vt), m && (g += Ht), d && (g += Bt), f && (g += Ut);
20545
+ let _ = g ? `<style>${g}</style>\n${u}` : u;
20546
+ return _ = _.replace(/>\s+</g, "> <").replace(/\r\n/g, "\n").replace(/\r/g, "\n").replace(/\n{3,}/g, "\n\n").split("\n").map((e) => e.trim()).filter((e) => e.length > 0).join("\n"), _ = _.replace(/&nbsp;/g, "\xA0"), i && (_ = _.replace(/<p[^>]*>\s*(&nbsp;|&#xa0;|&#160;|\u00a0|\s)*\s*<\/p>/gi, "").replace(/<p[^>]*>\s*<(strong|em|b|i)>\s*(&nbsp;|&#xa0;|&#160;|\u00a0|\s)*\s*<\/\1>\s*<\/p>/gi, "")), _ = _.replace(/<span[^>]*>\s*<\/span>/gi, ""), _ = _.replace(/ class=""/g, ""), _ = on(_), _ = _.replace(/<(strong|em|b|i|sup|sub)>\s*(&nbsp;|&#xa0;|&#160;|\u00a0|\s)*\s*<\/\1>/gi, "").replace(/<(strong|em|b|i)>(&nbsp;|&#xa0;|&#160;|\u00a0)+<\/\1>/gi, " ").replace(/<br\s*\/?>/gi, "<br/>").replace(/ +/g, " ").trim(), _;
21560
20547
  }
21561
- function Yn(e) {
20548
+ function rn(e) {
21562
20549
  e("span[id]").each((t, n) => {
21563
20550
  let r = e(n), i = r.attr("id"), a = n.attribs || {}, o = Object.keys(a);
21564
20551
  if (o.length !== 1 || o[0] !== "id") return;
@@ -21581,13 +20568,13 @@ function Yn(e) {
21581
20568
  l.trim() === u.trim() && (s.attr("id", i), r.replaceWith(r.html() || ""));
21582
20569
  });
21583
20570
  }
21584
- function Xn(e, t = !1) {
20571
+ function an(e, t = !1) {
21585
20572
  let n = e("body");
21586
20573
  if (n.length === 0) return;
21587
20574
  let r = n.find("span.alinea[data-image-hash]"), i = -1;
21588
20575
  r.each((n, r) => {
21589
20576
  let a = e(r), o = a.attr("data-image-hash"), s;
21590
- if (o && jn[o] !== void 0 && (s = jn[o]), s === void 0) {
20577
+ if (o && zt[o] !== void 0 && (s = zt[o]), s === void 0) {
21591
20578
  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".`);
21592
20579
  a.remove();
21593
20580
  return;
@@ -21599,11 +20586,11 @@ function Xn(e, t = !1) {
21599
20586
  i = s, a.attr("data-alinea", String(s)), a.text(String(s)), a.removeAttr("data-image-hash");
21600
20587
  });
21601
20588
  }
21602
- function Zn(e) {
20589
+ function on(e) {
21603
20590
  let t = e;
21604
20591
  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;
21605
20592
  }
21606
- function Qn(e, t = {}) {
20593
+ function sn(e, t = {}) {
21607
20594
  return `<!DOCTYPE html>
21608
20595
  <html lang="fr">
21609
20596
  <head>
@@ -21611,33 +20598,33 @@ function Qn(e, t = {}) {
21611
20598
  <title>Document simplifié</title>
21612
20599
  </head>
21613
20600
  <body>
21614
- ${Jn(e, t)}
20601
+ ${nn(e, t)}
21615
20602
  </body>
21616
20603
  </html>`;
21617
20604
  }
21618
20605
  //#endregion
21619
20606
  //#region src/lib/server/text_parsers/transformers.ts
21620
- function Z(e, t) {
20607
+ function Q(e, t) {
21621
20608
  let n = "transformation_", r = {};
21622
- for (let e of w.readdirSync(t).toSorted()) if (e.startsWith(n) && e.endsWith(".json")) {
20609
+ for (let e of g.readdirSync(t).toSorted()) if (e.startsWith(n) && e.endsWith(".json")) {
21623
20610
  let i = e.slice(15, -5), a = i.split(".").map((e) => parseInt(e) - 1), o = r;
21624
20611
  for (let e of a.slice(1)) {
21625
20612
  let t = o.transformations ??= [];
21626
20613
  for (; e >= t.length;) t.push({});
21627
20614
  o = t[e];
21628
20615
  }
21629
- o.output = w.readFileSync(T.join(t, `${n}${i}.html`), { encoding: "utf-8" });
21630
- let { sourceMap: s, title: c } = w.readJsonSync(T.join(t, e), { encoding: "utf-8" });
20616
+ o.output = g.readFileSync(_.join(t, `${n}${i}.html`), { encoding: "utf-8" });
20617
+ let { sourceMap: s, title: c } = g.readJsonSync(_.join(t, e), { encoding: "utf-8" });
21631
20618
  o.sourceMap = s ?? [], o.title = c;
21632
20619
  }
21633
- return $n(r, e), r;
20620
+ return cn(r, e), r;
21634
20621
  }
21635
- function $n(e, t) {
21636
- if (e.input = t, e.transformations !== void 0) for (let n of e.transformations) $n(n, t), t = n.output;
20622
+ function cn(e, t) {
20623
+ if (e.input = t, e.transformations !== void 0) for (let n of e.transformations) cn(n, t), t = n.output;
21637
20624
  return t;
21638
20625
  }
21639
- function Q(e, t, n = "1") {
21640
- if (w.ensureDirSync(t), e.transformations === void 0) w.writeJsonSync(T.join(t, `transformation_${n}.json`), {
20626
+ function $(e, t, n = "1") {
20627
+ if (g.ensureDirSync(t), e.transformations === void 0) g.writeJsonSync(_.join(t, `transformation_${n}.json`), {
21641
20628
  sourceMap: e.sourceMap,
21642
20629
  title: e.title
21643
20630
  }, {
@@ -21645,690 +20632,72 @@ function Q(e, t, n = "1") {
21645
20632
  spaces: 2
21646
20633
  });
21647
20634
  else {
21648
- w.writeJsonSync(T.join(t, `transformation_${n}.json`), { title: e.title }, {
20635
+ g.writeJsonSync(_.join(t, `transformation_${n}.json`), { title: e.title }, {
21649
20636
  encoding: "utf-8",
21650
20637
  spaces: 2
21651
20638
  });
21652
- for (let [r, i] of e.transformations.entries()) Q(i, t, `${n}.${r + 1}`);
20639
+ for (let [r, i] of e.transformations.entries()) $(i, t, `${n}.${r + 1}`);
21653
20640
  }
21654
- e.output !== void 0 && w.writeFileSync(T.join(t, `transformation_${n}.html`), e.output, { encoding: "utf-8" });
20641
+ e.output !== void 0 && g.writeFileSync(_.join(t, `transformation_${n}.html`), e.output, { encoding: "utf-8" });
21655
20642
  }
21656
20643
  //#endregion
21657
20644
  //#region src/lib/server/linkers/html.ts
21658
- async function er({ canutesDb: e, date: t, defaultTextId: n, htmlFilePath: r, htmlTransformationsInputDir: i, htmlTransformationsOutputDir: a, htmlWithLinksFilePath: o, htmlWithLinksOrReferencesFilePath: s, htmlWithLinksTransformationsOutputDir: c, htmlWithReferencesFilePath: u, linkBaseUrl: d, linkType: f, logIgnoredReferencesTypes: p, logPartialReferences: m, logReferences: h, referredLegifranceTextsInfosFilePath: g }) {
21659
- let _ = await w.readFile(r, { encoding: "utf-8" }), v;
21660
- i === void 0 ? (v = ee({ removeAWithHref: !0 })(_), a !== void 0 && Q(v, a)) : v = Z(_, i);
21661
- let y = [];
21662
- o !== void 0 && y.push("links"), s !== void 0 && y.push("links_or_references"), u !== void 0 && y.push("references");
21663
- let { outputByType: b, referredLegifranceTextCountByCid: te } = await l({
21664
- canutesDb: e,
21665
- date: t,
21666
- defaultTextId: n,
21667
- htmlTransformation: v,
21668
- inputHtml: _,
21669
- linkBaseUrl: d,
21670
- linkType: f,
21671
- logIgnoredReferencesTypes: p,
21672
- logPartialReferences: m,
21673
- logReferences: h,
21674
- outputTypes: y,
21675
- referredLegifranceTextsInfos: g !== void 0
21676
- }), x = {};
21677
- o !== void 0 && (x.links = o), s !== void 0 && (x.links_or_references = s), u !== void 0 && (x.references = u);
21678
- for (let [e, t] of Object.entries(b)) {
21679
- let n = x[e];
21680
- n !== void 0 && await w.writeFile(n, t.html, { encoding: "utf-8" });
20645
+ async function ln({ canutesDb: e, legiResolver: t, date: n, defaultTextId: r, htmlFilePath: i, htmlTransformationsInputDir: c, htmlTransformationsOutputDir: l, htmlWithLinksFilePath: u, htmlWithLinksOrReferencesFilePath: d, htmlWithLinksTransformationsOutputDir: f, htmlWithReferencesFilePath: p, linkBaseUrl: m, linkType: h, logIgnoredReferencesTypes: _, logPartialReferences: v, logReferences: y, referredLegifranceTextsInfosFilePath: b }) {
20646
+ let x = t ?? (e === void 0 ? void 0 : new o(e));
20647
+ if (x === void 0) throw Error("A Canutes database or legal resolver is required");
20648
+ let S = await g.readFile(i, { encoding: "utf-8" }), C;
20649
+ c === void 0 ? (C = s({ removeAWithHref: !0 })(S), l !== void 0 && $(C, l)) : C = Q(S, c);
20650
+ let w = [];
20651
+ u !== void 0 && w.push("links"), d !== void 0 && w.push("links_or_references"), p !== void 0 && w.push("references");
20652
+ let { outputByType: T, referredLegifranceTextCountByCid: E } = await a({
20653
+ legiResolver: x,
20654
+ date: n,
20655
+ defaultTextId: r,
20656
+ htmlTransformation: C,
20657
+ inputHtml: S,
20658
+ linkBaseUrl: m,
20659
+ linkType: h,
20660
+ logIgnoredReferencesTypes: _,
20661
+ logPartialReferences: v,
20662
+ logReferences: y,
20663
+ outputTypes: w,
20664
+ referredLegifranceTextsInfos: b !== void 0
20665
+ }), D = {};
20666
+ u !== void 0 && (D.links = u), d !== void 0 && (D.links_or_references = d), p !== void 0 && (D.references = p);
20667
+ for (let [e, t] of Object.entries(T)) {
20668
+ let n = D[e];
20669
+ n !== void 0 && await g.writeFile(n, t.html, { encoding: "utf-8" });
21681
20670
  }
21682
- b.links !== void 0 && c !== void 0 && Q(ee()(b.links.html), c), g !== void 0 && await w.writeJson(g, te, {
20671
+ T.links !== void 0 && f !== void 0 && $(s()(T.links.html), f), b !== void 0 && await g.writeJson(b, E, {
21683
20672
  encoding: "utf-8",
21684
20673
  spaces: 2
21685
20674
  });
21686
20675
  }
21687
20676
  //#endregion
21688
- //#region src/lib/legi/resolver.ts
21689
- var tr = ["canutes", "f_legi"], nr = "canutes";
21690
- function rr(e) {
21691
- if (e === void 0 || e === "") return nr;
21692
- if (tr.includes(e)) return e;
21693
- throw Error(`Unknown legal resolver "${e}". Expected one of: ${tr.join(", ")}`);
21694
- }
21695
- //#endregion
21696
20677
  //#region src/lib/server/tables_of_contents.ts
21697
- async function ir(e, t, r, i) {
21698
- let a = Z(await w.readFile(e, { encoding: "utf-8" }), t), o = a.output, s = new n(o), c = await w.readJson(r, { encoding: "utf-8" });
21699
- for await (let e of _({
20678
+ async function un(e, n, r, i) {
20679
+ 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" });
20680
+ for await (let e of t({
21700
20681
  context: s,
21701
20682
  tableOfContents: c,
21702
20683
  transformation: a
21703
20684
  }));
21704
- await w.writeJson(i, c, {
20685
+ await g.writeJson(i, c, {
21705
20686
  encoding: "utf-8",
21706
20687
  spaces: 2
21707
20688
  });
21708
20689
  }
21709
- async function ar(e, t, n) {
21710
- let r = Z(await w.readFile(e, { encoding: "utf-8" }), t).output, i = S(r);
21711
- await w.writeJson(n, i, {
20690
+ async function dn(e, t, n) {
20691
+ let i = Q(await g.readFile(e, { encoding: "utf-8" }), t).output, a = r(i);
20692
+ await g.writeJson(n, a, {
21712
20693
  encoding: "utf-8",
21713
20694
  spaces: 2
21714
20695
  });
21715
20696
  }
21716
20697
  //#endregion
21717
- //#region src/lib/f_legi/resolver.ts
21718
- var $, or = class {
21719
- flegiDb;
21720
- articleRowsByNumByTextAndDate = /* @__PURE__ */ new Map();
21721
- articleNumsLoadedByTextAndDate = /* @__PURE__ */ new Map();
21722
- articleRowsByContextTextId = /* @__PURE__ */ new Map();
21723
- directSectionChildrenByParentAndDate = /* @__PURE__ */ new Map();
21724
- globalArticleRowsByNumAndDate = /* @__PURE__ */ new Map();
21725
- rootTextIdsByTextId = /* @__PURE__ */ new Map();
21726
- contextTextIdsByTextId = /* @__PURE__ */ new Map();
21727
- textIdBySegmentId = /* @__PURE__ */ new Map();
21728
- textTitlesInfosLoaded = !1;
21729
- constructor(e) {
21730
- this.flegiDb = e;
21731
- }
21732
- async getActiveArticlesByTextAndNum({ date: e, num: t, textId: n }) {
21733
- return t === void 0 ? [] : (await this.getActiveArticleRowsByNum(n, e)).get(t) ?? [];
21734
- }
21735
- async getDirectSectionChildren({ date: e, parentPath: t }) {
21736
- let n = `${t}\0${e}`, r = this.directSectionChildrenByParentAndDate.get(n);
21737
- if (r === void 0) {
21738
- if (r = await this.getDirectSectionChildrenByExactParentPath({
21739
- date: e,
21740
- parentPath: t
21741
- }), r.length === 0 && !t.includes(".")) {
21742
- let n = await this.getRootTextIdsFromTextId(t);
21743
- n.length > 1 && (r = await this.flegiDb`
21744
- SELECT
21745
- dernier_segment AS id,
21746
- chemin::text AS path,
21747
- titre AS title,
21748
- date_debut::text AS "dateDebut",
21749
- date_fin::text AS "dateFin"
21750
- FROM scta
21751
- WHERE
21752
- subltree(chemin, 0, 1) = ANY(${this.flegiDb.array(n)}::ltree[])
21753
- AND nlevel(chemin) = 2
21754
- AND type_objet = 'scta'
21755
- AND date_debut <= ${e}::date
21756
- AND date_fin >= ${e}::date
21757
- ORDER BY tri_hierarchique
21758
- `);
21759
- }
21760
- this.directSectionChildrenByParentAndDate.set(n, r);
21761
- }
21762
- return r;
21763
- }
21764
- async getTextIdFromSegmentId(e) {
21765
- let t = this.textIdBySegmentId.get(e);
21766
- return t === void 0 && (t = await this.getTextIdFromSegmentIdUsingContextHeuristic(e) ?? await this.getTextIdFromSegmentIdUsingSctaHeuristic(e) ?? null, this.textIdBySegmentId.set(e, t)), t ?? void 0;
21767
- }
21768
- async preloadTextTitlesInfos(e = {}) {
21769
- let t = (t, n = {}) => {
21770
- e.onProgress?.({
21771
- ...n,
21772
- phase: t,
21773
- resolver: "f_legi"
21774
- });
21775
- };
21776
- if (this.textTitlesInfosLoaded) {
21777
- t("already-loaded");
21778
- return;
21779
- }
21780
- let n = new D("f_legi.preloadTextTitlesInfos");
21781
- $ === void 0 ? (t("queryTextTitlesInfos:start"), $ = (async () => {
21782
- let e = await n.time("queryTextTitlesInfos", () => this.flegiDb`
21783
- SELECT
21784
- cid,
21785
- date_texte::text AS "dateTexte",
21786
- nature,
21787
- num,
21788
- title
21789
- FROM text_titles_infos
21790
- ORDER BY legi_id
21791
- `);
21792
- t("queryTextTitlesInfos:done", { count: e.length }), t("buildTextTitlesInfos:start", { count: e.length });
21793
- let r = performance.now(), i = await lr(e, { onProgress: ({ count: e, phase: n }) => t(`buildTextTitlesInfos:${n}`, { count: e }) });
21794
- return n.add({
21795
- count: e.length,
21796
- durationMs: Math.round((performance.now() - r) * 10) / 10,
21797
- phase: "buildTextTitlesInfos"
21798
- }), t("buildTextTitlesInfos:done"), i;
21799
- })().catch((e) => {
21800
- throw $ = void 0, e;
21801
- })) : t("waiting-for-shared-preload");
21802
- let r = await $;
21803
- t("setTextTitlesInfos:start"), i(r), t("setTextTitlesInfos:done"), n.log(), this.textTitlesInfosLoaded = !0;
21804
- }
21805
- async getUniqueActiveArticlesByNum({ date: e, num: t }) {
21806
- if (t === void 0) return [];
21807
- let n = `${t}\0${e}`, r = this.globalArticleRowsByNumAndDate.get(n);
21808
- return r === void 0 && (r = await this.queryUniqueActiveArticlesByNumsUsingContextHeuristic([t]), this.globalArticleRowsByNumAndDate.set(n, r)), r;
21809
- }
21810
- async preloadUniqueActiveArticlesByNums({ date: e, nums: t }) {
21811
- let n = [];
21812
- for (let r of t) {
21813
- if (r === void 0) continue;
21814
- let t = `${r}\0${e}`;
21815
- this.globalArticleRowsByNumAndDate.has(t) || (this.globalArticleRowsByNumAndDate.set(t, []), n.push(r));
21816
- }
21817
- if (n.length === 0) return;
21818
- let r = new D("f_legi.preloadUniqueActiveArticlesByNums"), i = await r.time("queryGloballyUniqueArticleRowsByNums", () => this.queryGloballyUniqueArticleRowsByNums(n), { count: n.length }), a = new Set(i.map(({ num: e }) => e).filter((e) => e !== null)), o = n.filter((e) => !a.has(e)), s = await r.time("queryUniqueActiveArticlesByNumsUsingContextHeuristic", () => this.queryUniqueActiveArticlesByNumsUsingContextHeuristic(o), { count: o.length }), c = [...i, ...s].toSorted((e, t) => e.id < t.id ? -1 : +(e.id > t.id)), l = /* @__PURE__ */ new Map();
21819
- for (let t of c) {
21820
- if (t.num === null) continue;
21821
- let n = l.get(t.num) ?? 0;
21822
- if (l.set(t.num, n + 1), n >= 100) continue;
21823
- let r = `${t.num}\0${e}`;
21824
- this.globalArticleRowsByNumAndDate.get(r)?.push(t);
21825
- }
21826
- r.log({
21827
- articleRowCount: c.length,
21828
- globallyUniqueArticleRowCount: i.length,
21829
- heuristicArticleRowCount: s.length,
21830
- heuristicNumCount: o.length,
21831
- numCount: n.length
21832
- });
21833
- }
21834
- async preloadActiveArticlesByTextIds({ date: e, nums: t, textIds: n }) {
21835
- let r = t === void 0 ? void 0 : [...new Set(t)].filter(Boolean), i = [...new Set(n)].filter((t) => {
21836
- if (t === void 0) return !1;
21837
- let n = `${t}\0${e}`;
21838
- if (this.articleRowsByNumByTextAndDate.get(n) === void 0) return !0;
21839
- let i = this.articleNumsLoadedByTextAndDate.get(n);
21840
- return i === "all" ? !1 : r === void 0 ? !0 : r.some((e) => !i?.has(e));
21841
- });
21842
- if (i.length === 0) return;
21843
- let a = new D("f_legi.preloadActiveArticlesByTextIds"), o = await a.time("getContextTextIdsByTextIds", () => this.getContextTextIdsByTextIds(i)), s = [...new Set([...o.values()].flat())], c = await a.time("getActiveArticleRowsForContextTextIds", () => r === void 0 ? this.getActiveArticleRowsForContextTextIdsWithRoots(s) : this.queryActiveArticleRowsForContextTextIds(s, r), { count: s.length }), l = /* @__PURE__ */ new Map(), u = (e, t) => {
21844
- if (e === null) return;
21845
- let n = l.get(e);
21846
- n === void 0 ? l.set(e, [t]) : n.push(t);
21847
- };
21848
- for (let e of c) u(e.rootTextId, e), u(e.textId, e);
21849
- for (let t of i) {
21850
- let n = `${t}\0${e}`, i = o.get(t) ?? [t], a = /* @__PURE__ */ new Map();
21851
- for (let e of i) for (let t of l.get(e) ?? []) a.set(`${t.id}\0${t.textId}`, {
21852
- id: t.id,
21853
- textId: t.textId,
21854
- num: t.num,
21855
- dateDebut: t.dateDebut,
21856
- dateFin: t.dateFin
21857
- });
21858
- let s = this.articleRowsByNumByTextAndDate.get(n) ?? /* @__PURE__ */ new Map();
21859
- for (let e of a.values()) {
21860
- if (e.num === null) continue;
21861
- let t = s.get(e.num);
21862
- t === void 0 ? s.set(e.num, [e]) : t.some((t) => t.id === e.id && t.textId === e.textId) || t.push(e);
21863
- }
21864
- if (this.articleRowsByNumByTextAndDate.set(n, s), r === void 0) this.articleNumsLoadedByTextAndDate.set(n, "all");
21865
- else {
21866
- let e = this.articleNumsLoadedByTextAndDate.get(n);
21867
- if (e !== "all") {
21868
- let t = e ?? /* @__PURE__ */ new Set();
21869
- for (let e of r) t.add(e);
21870
- this.articleNumsLoadedByTextAndDate.set(n, t);
21871
- }
21872
- }
21873
- }
21874
- a.log({
21875
- articleRowCount: c.length,
21876
- articleNumCount: r?.length,
21877
- rootTextIdCount: s.length,
21878
- textIdCount: i.length
21879
- });
21880
- }
21881
- async queryUniqueActiveArticlesByNumsUsingContextHeuristic(e) {
21882
- return e.length === 0 ? [] : await this.flegiDb`
21883
- SELECT
21884
- id,
21885
- "textId",
21886
- num,
21887
- "dateDebut",
21888
- "dateFin"
21889
- FROM (
21890
- SELECT
21891
- id,
21892
- text_id AS "textId",
21893
- num,
21894
- date_debut::text AS "dateDebut",
21895
- date_fin::text AS "dateFin",
21896
- row_number() OVER (
21897
- PARTITION BY num
21898
- ORDER BY id
21899
- ) AS "rowNumber"
21900
- FROM article_num_candidates
21901
- WHERE num IN ${this.flegiDb(e)}
21902
- ) AS ranked_articles
21903
- WHERE "rowNumber" <= 100
21904
- `;
21905
- }
21906
- async queryGloballyUniqueArticleRowsByNums(e) {
21907
- return e.length === 0 ? [] : await this.flegiDb`
21908
- WITH unique_stats AS (
21909
- SELECT
21910
- num,
21911
- unique_article_id,
21912
- unique_article_source,
21913
- unique_text_cid
21914
- FROM article_num_candidate_stats
21915
- WHERE
21916
- num IN ${this.flegiDb(e)}
21917
- AND candidate_article_count = 1
21918
- AND unique_article_id IS NOT NULL
21919
- AND unique_article_source IS NOT NULL
21920
- AND unique_text_cid IS NOT NULL
21921
- )
21922
- SELECT
21923
- legiarti.legi_id AS id,
21924
- unique_stats.unique_text_cid AS "textId",
21925
- legiarti.num,
21926
- legiarti.date_debut::text AS "dateDebut",
21927
- legiarti.date_fin::text AS "dateFin"
21928
- FROM unique_stats
21929
- JOIN legiarti
21930
- ON unique_stats.unique_article_source = 'LEGI'
21931
- AND legiarti.legi_id = unique_stats.unique_article_id
21932
-
21933
- UNION ALL
21934
-
21935
- SELECT
21936
- jorfarti.legi_id AS id,
21937
- unique_stats.unique_text_cid AS "textId",
21938
- jorfarti.num,
21939
- jorfarti.date_debut::text AS "dateDebut",
21940
- jorfarti.date_fin::text AS "dateFin"
21941
- FROM unique_stats
21942
- JOIN jorfarti
21943
- ON unique_stats.unique_article_source = 'JORF'
21944
- AND jorfarti.legi_id = unique_stats.unique_article_id
21945
- `;
21946
- }
21947
- async getActiveArticleRowsByNum(e, t) {
21948
- let n = `${e}\0${t}`, r = this.articleRowsByNumByTextAndDate.get(n);
21949
- if (r === void 0) {
21950
- let t = await this.getContextTextIdsFromTextId(e), i = await this.getActiveArticleRowsForContextTextIds(t);
21951
- r = /* @__PURE__ */ new Map();
21952
- for (let e of i) {
21953
- if (e.num === null) continue;
21954
- let t = r.get(e.num);
21955
- t === void 0 ? r.set(e.num, [e]) : t.push(e);
21956
- }
21957
- this.articleRowsByNumByTextAndDate.set(n, r), this.articleNumsLoadedByTextAndDate.set(n, "all");
21958
- }
21959
- return r;
21960
- }
21961
- async getActiveArticleRowsForContextTextIds(e) {
21962
- return (await this.getActiveArticleRowsForContextTextIdsWithRoots(e)).map((e) => ({
21963
- id: e.id,
21964
- textId: e.textId,
21965
- num: e.num,
21966
- dateDebut: e.dateDebut,
21967
- dateFin: e.dateFin
21968
- }));
21969
- }
21970
- async getActiveArticleRowsForContextTextIdsWithRoots(e) {
21971
- let t = [...new Set(e)], n = t.filter((e) => !this.articleRowsByContextTextId.has(e));
21972
- if (n.length > 0) {
21973
- let e = await this.queryActiveArticleRowsForContextTextIds(n);
21974
- for (let e of n) this.articleRowsByContextTextId.set(e, []);
21975
- for (let t of e) this.articleRowsByContextTextId.get(t.rootTextId)?.push(t);
21976
- }
21977
- return t.flatMap((e) => this.articleRowsByContextTextId.get(e) ?? []).toSorted((e, t) => e.id.localeCompare(t.id));
21978
- }
21979
- async queryActiveArticleRowsForContextTextIds(e, t) {
21980
- if (e.length === 0 || t?.length === 0) return [];
21981
- let n = t === void 0 ? this.flegiDb`` : this.flegiDb`AND num IN ${this.flegiDb(t)}`, r = t === void 0 ? this.flegiDb`` : this.flegiDb`AND legiarti.num IN ${this.flegiDb(t)}`, i = t === void 0 ? this.flegiDb`` : this.flegiDb`AND jorfarti.num IN ${this.flegiDb(t)}`;
21982
- return (await this.flegiDb`
21983
- SELECT DISTINCT ON (article_rows.id, article_rows."textId")
21984
- article_rows.id,
21985
- article_rows."rootTextId",
21986
- article_rows."textId",
21987
- article_rows.num,
21988
- article_rows."dateDebut",
21989
- article_rows."dateFin"
21990
- FROM (
21991
- SELECT
21992
- legi_id AS id,
21993
- context_text_cid AS "rootTextId",
21994
- context_text_cid AS "textId",
21995
- num,
21996
- date_debut::text AS "dateDebut",
21997
- date_fin::text AS "dateFin",
21998
- 0 AS priority,
21999
- true AS "hasValidParentPeriod",
22000
- NULL::varchar AS tri_hierarchique,
22001
- legi_id AS order_id
22002
- FROM legiarti
22003
- WHERE
22004
- context_text_cid IN ${this.flegiDb(e)}
22005
- ${n}
22006
-
22007
- UNION ALL
22008
-
22009
- SELECT
22010
- legi_id AS id,
22011
- context_text_cid AS "rootTextId",
22012
- context_text_cid AS "textId",
22013
- num,
22014
- date_debut::text AS "dateDebut",
22015
- date_fin::text AS "dateFin",
22016
- 0 AS priority,
22017
- true AS "hasValidParentPeriod",
22018
- NULL::varchar AS tri_hierarchique,
22019
- legi_id AS order_id
22020
- FROM jorfarti
22021
- WHERE
22022
- context_text_cid IN ${this.flegiDb(e)}
22023
- ${n}
22024
-
22025
- UNION ALL
22026
-
22027
- -- Heuristique sur scta uniquement en fallback pour les
22028
- -- rares articles sans CONTEXTE -> TEXTE dans f_legi.
22029
- SELECT
22030
- legiarti.legi_id AS id,
22031
- COALESCE(
22032
- legitext.cid,
22033
- subltree(scta.chemin, 0, 1)::text
22034
- ) AS "rootTextId",
22035
- COALESCE(
22036
- legitext.cid,
22037
- subltree(scta.chemin, 0, 1)::text
22038
- ) AS "textId",
22039
- legiarti.num,
22040
- legiarti.date_debut::text AS "dateDebut",
22041
- legiarti.date_fin::text AS "dateFin",
22042
- 1 AS priority,
22043
- (scta.parents_valid_period IS NOT NULL AND NOT isempty(scta.parents_valid_period)) AS "hasValidParentPeriod",
22044
- scta.tri_hierarchique,
22045
- legiarti.legi_id AS order_id
22046
- FROM article_location_diffs
22047
- JOIN legiarti
22048
- ON legiarti.legi_id = article_location_diffs.article_id
22049
- JOIN scta
22050
- ON scta.dernier_segment = legiarti.legi_id
22051
- AND scta.type_objet = 'art'
22052
- LEFT JOIN legitext
22053
- ON legitext.legi_id = subltree(scta.chemin, 0, 1)::text
22054
- WHERE
22055
- article_location_diffs.diff_type = 'missing_from_contexte'
22056
- AND COALESCE(
22057
- legitext.cid,
22058
- subltree(scta.chemin, 0, 1)::text
22059
- ) IN ${this.flegiDb(e)}
22060
- ${r}
22061
-
22062
- UNION ALL
22063
-
22064
- SELECT
22065
- jorfarti.legi_id AS id,
22066
- COALESCE(
22067
- jorftext.cid,
22068
- subltree(scta.chemin, 0, 1)::text
22069
- ) AS "rootTextId",
22070
- COALESCE(
22071
- jorftext.cid,
22072
- subltree(scta.chemin, 0, 1)::text
22073
- ) AS "textId",
22074
- jorfarti.num,
22075
- jorfarti.date_debut::text AS "dateDebut",
22076
- jorfarti.date_fin::text AS "dateFin",
22077
- 1 AS priority,
22078
- (scta.parents_valid_period IS NOT NULL AND NOT isempty(scta.parents_valid_period)) AS "hasValidParentPeriod",
22079
- scta.tri_hierarchique,
22080
- jorfarti.legi_id AS order_id
22081
- FROM article_location_diffs
22082
- JOIN jorfarti
22083
- ON jorfarti.legi_id = article_location_diffs.article_id
22084
- JOIN scta
22085
- ON scta.dernier_segment = jorfarti.legi_id
22086
- AND scta.type_objet = 'art'
22087
- LEFT JOIN jorftext
22088
- ON jorftext.legi_id = subltree(scta.chemin, 0, 1)::text
22089
- WHERE
22090
- article_location_diffs.diff_type = 'missing_from_contexte'
22091
- AND COALESCE(
22092
- jorftext.cid,
22093
- subltree(scta.chemin, 0, 1)::text
22094
- ) IN ${this.flegiDb(e)}
22095
- ${i}
22096
- ) AS article_rows
22097
- ORDER BY
22098
- article_rows.id,
22099
- article_rows."textId",
22100
- article_rows.priority,
22101
- article_rows."hasValidParentPeriod" DESC,
22102
- article_rows.tri_hierarchique,
22103
- article_rows.order_id
22104
- `).toSorted((e, t) => e.id.localeCompare(t.id));
22105
- }
22106
- async getDirectSectionChildrenByExactParentPath({ date: e, parentPath: t }) {
22107
- return await this.flegiDb`
22108
- SELECT
22109
- dernier_segment AS id,
22110
- chemin::text AS path,
22111
- titre AS title,
22112
- date_debut::text AS "dateDebut",
22113
- date_fin::text AS "dateFin"
22114
- FROM scta
22115
- WHERE
22116
- chemin <@ ${t}::ltree
22117
- AND nlevel(chemin) = nlevel(${t}::ltree) + 1
22118
- AND type_objet = 'scta'
22119
- AND date_debut <= ${e}::date
22120
- AND date_fin >= ${e}::date
22121
- ORDER BY tri_hierarchique
22122
- `;
22123
- }
22124
- async getTextIdFromSegmentIdUsingContextHeuristic(e) {
22125
- if (e.startsWith("LEGIARTI")) return (await this.flegiDb`
22126
- SELECT context_text_cid AS "textId"
22127
- FROM legiarti
22128
- WHERE legi_id = ${e}
22129
- LIMIT 1
22130
- `)[0]?.textId;
22131
- if (e.startsWith("JORFARTI")) return (await this.flegiDb`
22132
- SELECT context_text_cid AS "textId"
22133
- FROM jorfarti
22134
- WHERE legi_id = ${e}
22135
- LIMIT 1
22136
- `)[0]?.textId;
22137
- }
22138
- async getTextIdFromSegmentIdUsingSctaHeuristic(e) {
22139
- return (await this.flegiDb`
22140
- SELECT
22141
- COALESCE(
22142
- legitext.cid,
22143
- jorftext.cid,
22144
- subltree(scta.chemin, 0, 1)::text
22145
- ) AS "textId"
22146
- FROM scta
22147
- LEFT JOIN legitext
22148
- ON legitext.legi_id = subltree(scta.chemin, 0, 1)::text
22149
- LEFT JOIN jorftext
22150
- ON jorftext.legi_id = subltree(scta.chemin, 0, 1)::text
22151
- WHERE scta.dernier_segment = ${e}
22152
- ORDER BY
22153
- (scta.parents_valid_period IS NOT NULL AND NOT isempty(scta.parents_valid_period)) DESC,
22154
- scta.date_debut DESC
22155
- LIMIT 1
22156
- `)[0]?.textId;
22157
- }
22158
- async getContextTextIdsFromTextId(e) {
22159
- let t = this.contextTextIdsByTextId.get(e);
22160
- return t === void 0 && (t = (await this.getContextTextIdsByTextIds([e])).get(e) ?? [e], this.contextTextIdsByTextId.set(e, t)), t;
22161
- }
22162
- async getContextTextIdsByTextIds(e) {
22163
- let t = /* @__PURE__ */ new Map(), n = e.filter((e) => !this.contextTextIdsByTextId.has(e));
22164
- for (let n of e) {
22165
- let e = this.contextTextIdsByTextId.get(n);
22166
- e !== void 0 && t.set(n, e);
22167
- }
22168
- if (n.length === 0) return t;
22169
- for (let e of n) t.set(e, [e]);
22170
- let r = await this.flegiDb`
22171
- SELECT legi_id AS "textId", cid AS "contextTextId"
22172
- FROM legitext
22173
- WHERE legi_id IN ${this.flegiDb(n)} OR cid IN ${this.flegiDb(n)}
22174
-
22175
- UNION ALL
22176
-
22177
- SELECT legi_id AS "textId", cid AS "contextTextId"
22178
- FROM jorftext
22179
- WHERE legi_id IN ${this.flegiDb(n)} OR cid IN ${this.flegiDb(n)}
22180
-
22181
- ORDER BY "textId", "contextTextId"
22182
- `;
22183
- for (let { contextTextId: e, textId: i } of r) for (let r of [i, e]) {
22184
- if (!n.includes(r)) continue;
22185
- let i = t.get(r) ?? [r];
22186
- i.includes(e) || i.push(e), t.set(r, i);
22187
- }
22188
- for (let e of n) this.contextTextIdsByTextId.set(e, t.get(e) ?? [e]);
22189
- return t;
22190
- }
22191
- async getRootTextIdsFromTextId(e) {
22192
- let t = this.rootTextIdsByTextId.get(e);
22193
- return t === void 0 && (t = (await this.getRootTextIdsByTextIds([e])).get(e) ?? [e], this.rootTextIdsByTextId.set(e, t)), t;
22194
- }
22195
- async getRootTextIdsByTextIds(e) {
22196
- let t = /* @__PURE__ */ new Map(), n = e.filter((e) => !this.rootTextIdsByTextId.has(e));
22197
- for (let n of e) {
22198
- let e = this.rootTextIdsByTextId.get(n);
22199
- e !== void 0 && t.set(n, e);
22200
- }
22201
- if (n.length === 0) return t;
22202
- for (let e of n) t.set(e, [e]);
22203
- let r = await this.flegiDb`
22204
- SELECT cid AS "textId", legi_id AS "rootTextId"
22205
- FROM legitext
22206
- WHERE cid IN ${this.flegiDb(n)}
22207
-
22208
- UNION ALL
22209
-
22210
- SELECT cid AS "textId", legi_id AS "rootTextId"
22211
- FROM jorftext
22212
- WHERE cid IN ${this.flegiDb(n)}
22213
-
22214
- ORDER BY "textId", "rootTextId"
22215
- `;
22216
- for (let { textId: e, rootTextId: n } of r) {
22217
- let r = t.get(e) ?? [e];
22218
- r.includes(n) || r.push(n), t.set(e, r);
22219
- }
22220
- for (let e of n) this.rootTextIdsByTextId.set(e, t.get(e) ?? [e]);
22221
- return t;
22222
- }
22223
- };
22224
- function sr(e, t, n, r) {
22225
- n != null && ((e[t] ??= {})[n] ??= []).push(r);
22226
- }
22227
- function cr(e, t, n) {
22228
- let r = fr(x(t).replace(/[,()]/g, " ")).split(" ").map((e) => /^[IVX]+$/gi.test(e) ? a(e).toString() : e.toLowerCase().replace(/^no$/, "n°")), i = e;
22229
- for (let e of r) i = i[e] ??= {};
22230
- i.cid === void 0 ? i.cid = n : Array.isArray(i.cid) ? i.cid.push(n) : i.cid = [i.cid, n];
22231
- }
22232
- async function lr(e, { onProgress: r } = {}) {
22233
- let i = {}, a = {}, o = {}, s = {}, c = {};
22234
- r?.({
22235
- count: e.length,
22236
- phase: "parse:start"
22237
- });
22238
- for (let [l, { cid: u, dateTexte: d, nature: f, num: p, title: m }] of e.entries()) {
22239
- l > 0 && l % 2e4 == 0 && (r?.({
22240
- count: l,
22241
- phase: "parse:progress"
22242
- }), await new Promise((e) => setTimeout(e, 0)));
22243
- let e = x(m);
22244
- if ([
22245
- "code",
22246
- "décret",
22247
- "loi",
22248
- "ordonnance"
22249
- ].includes(e.toLowerCase())) continue;
22250
- o[u] = [f, e];
22251
- let h = /* @__PURE__ */ new Set(), g = /* @__PURE__ */ new Set();
22252
- switch (e) {
22253
- case "Constitution du 4 octobre 1958":
22254
- g.add(e), h.add("Constitution");
22255
- break;
22256
- case "Loi contenant organisation du notariat (loi 25 ventôse an XI)":
22257
- g.add("Loi du 25 ventôse an XI (16 mars 1803) contenant organisation du notariat");
22258
- break;
22259
- case "Loi des 16-24 août 1790 sur l'organisation judiciaire":
22260
- h.add(e), g.add("Loi du 16 août 1790 sur l'organisation judiciaire");
22261
- break;
22262
- case "Loi des 2-17 mars 1791 portant suspension de tous les droits d'aides, de toutes les maîtrises et jurandes et établissement des droits de patente (décret d'Allarde)":
22263
- h.add(e), g.add("Loi du 17 mars 1791 portant suspension de tous les droits d'aides, de toutes les maîtrises et jurandes et établissement des droits de patente (décret d'Allarde)");
22264
- break;
22265
- case "Loi n° 77-1423 du 27 décembre 1977 77-1423 du 27 décembre 1977 autorisant l'approbation de la convention sur le commerce international des espèces de faune et de flore sauvages menacées d'extinction, ensemble quatre annexes, ouverte à la signature à Washington jusqu'au 30 avril 1973 et, après cette date, à Berne jusqu'au 31 décembre 1974":
22266
- g.add("Loi n° 77-1423 du 27 décembre 1977 autorisant l'approbation de la convention sur le commerce international des espèces de faune et de flore sauvages menacées d'extinction, ensemble quatre annexes, ouverte à la signature à Washington jusqu'au 30 avril 1973 et, après cette date, à Berne jusqu'au 31 décembre 1974");
22267
- break;
22268
- default: g.add(e);
22269
- }
22270
- for (let e of g) {
22271
- let r = t(new n(fr(e)));
22272
- if (r === void 0 && f === "DECRET" && (r = {
22273
- date: d ?? void 0,
22274
- nature: f,
22275
- num: p ?? void 0,
22276
- titleRest: e.replace(/^Décrets?\s*/i, "").trim() || void 0,
22277
- type: "texte"
22278
- }), r === void 0) throw Error(`Unparsable title of ${f} n° ${p ?? ""} du ${d ?? ""} (${u}): ${e}`);
22279
- sr(s, f, r.date, u), sr(c, f, r.num, u), r.titleRest !== void 0 && cr(a, r.titleRest, u);
22280
- }
22281
- for (let e of h) cr(i, e, u);
22282
- }
22283
- r?.({
22284
- count: e.length,
22285
- phase: "parse:done"
22286
- }), r?.({ phase: "compact:start" }), await new Promise((e) => setTimeout(e, 0));
22287
- let l = {
22288
- textCidByOtherTitleWordsTree: dr(i),
22289
- textCidByTitleRestWordsTree: dr(a),
22290
- textInfosByCid: o,
22291
- textsCidsByNatureAndDate: ur(s),
22292
- textsCidsByNatureAndNum: ur(c)
22293
- };
22294
- return r?.({ phase: "compact:done" }), l;
22295
- }
22296
- function ur(e) {
22297
- return Object.fromEntries(Object.entries(e).map(([e, t]) => [e, Object.fromEntries(Object.entries(t).map(([e, t]) => [e, t.length === 1 ? t[0] : t]))]));
22298
- }
22299
- function dr(e) {
22300
- let t = {};
22301
- e.cid !== void 0 && (t.cid = e.cid);
22302
- for (let [n, r] of Object.entries(e)) {
22303
- if (n === "cid") continue;
22304
- let e = n, i = dr(r);
22305
- for (; i.cid === void 0;) {
22306
- let t = Object.entries(i).filter(([e]) => e !== "cid");
22307
- if (t.length !== 1) break;
22308
- let [[n, r]] = t;
22309
- e = `${e} ${n}`, i = r;
22310
- }
22311
- t[e] = i;
22312
- }
22313
- return t;
22314
- }
22315
- function fr(e) {
22316
- return b(e).output;
22317
- }
22318
- var pr = ae(process.env.F_LEGI_DSN ?? "postgresql://f_legi:f_legi@127.0.0.1:5432/f_legi");
22319
- //#endregion
22320
20698
  //#region src/lib/server/legi/resolvers.ts
22321
- function mr(e) {
22322
- return e ?? process.env.TISSEUSE_TEXT_TITLES_INFOS_PATH;
22323
- }
22324
- function hr(e) {
22325
- return rr(e ?? process.env.TISSEUSE_LEGI_RESOLVER);
22326
- }
22327
- function gr({ canutesDb: e, resolver: t, textTitlesInfosPath: n }) {
22328
- switch (hr(t)) {
22329
- case "canutes": return new ke(e, { textTitlesInfosPath: mr(n) });
22330
- case "f_legi": return new or(pr);
22331
- }
20699
+ function fn({ canutesDb: e }) {
20700
+ return new o(e);
22332
20701
  }
22333
20702
  //#endregion
22334
- export { er as addLinksOrReferencesToHtmlFile, ir as addPositionsToTableOfContentsFile, gr as createLegiResolver, nr as defaultLegiResolverKind, ce as extractAssembleeAmendmentSearchItems, mn as extractAssembleeExposesDesMotifs, yn as extractSenatAmendmentSearchItems, le as hashAssembleeAmendmentSearchItem, gn as hashAssembleeSearchItem, bn as hashSenatAmendmentSearchItem, wn as hashSenatSearchItem, An as isAkomaNtosoXml, _n as isoDateFromAssembleeDocument, tr as legiResolverKinds, un as linkAkomaNtosoBillRaw, xt as linkAssembleeBillRaw, ln as parseAkomaNtosoBillRaw, bt as parseAssembleeBillRaw, hn as parseAssembleeDocumentSearchContent, rr as parseLegiResolverKind, Cn as parseSenatDocumentSearchContent, Z as readTransformation, an as renderAkomaNtosoBillRaw, kn as resolveSenatAkomaNtosoSource, ar as simplifiedHtmlBillFileToTableOfContentsFile, Jn as simplifyWordHtml, Qn as simplifyWordHtmlToDocument, Q as writeTransformation };
20703
+ export { f as LegiResolver, ln as addLinksOrReferencesToHtmlFile, un as addPositionsToTableOfContentsFile, d as buildAndInstallTextTitlesInfos, l as buildTextTitlesInfos, fn as createLegiResolver, x as extractAssembleeAmendmentSearchItems, Ct as extractAssembleeExposesDesMotifs, Ot as extractSenatAmendmentSearchItems, S as hashAssembleeAmendmentSearchItem, Tt as hashAssembleeSearchItem, kt as hashSenatAmendmentSearchItem, Nt as hashSenatSearchItem, Rt as isAkomaNtosoXml, Et as isoDateFromAssembleeDocument, bt as linkAkomaNtosoBillRaw, Ie as linkAssembleeBillRaw, yt as parseAkomaNtosoBillRaw, Fe as parseAssembleeBillRaw, wt as parseAssembleeDocumentSearchContent, Mt as parseSenatDocumentSearchContent, Q as readTransformation, ht as renderAkomaNtosoBillRaw, Lt as resolveSenatAkomaNtosoSource, dn as simplifiedHtmlBillFileToTableOfContentsFile, nn as simplifyWordHtml, sn as simplifyWordHtmlToDocument, $ as writeTransformation };