@tricoteuses/tisseuse 0.13.8 → 0.13.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -35
- package/dist/{textes-BIJjrNwg.js → html-DhGw-Yqr.js} +3875 -5243
- package/dist/index.js +280 -147
- package/dist/resolver-DZS-DNp6.js +1848 -0
- package/dist/server-f-legi.js +532 -0
- package/dist/server.js +542 -2161
- package/dist/src/lib/extractors/links.d.ts +6 -4
- package/dist/src/lib/f_legi/resolver.d.ts +5 -7
- package/dist/src/lib/index.d.ts +2 -0
- package/dist/src/lib/legi/canutes_resolver.d.ts +5 -6
- package/dist/src/lib/legi/resolver.d.ts +15 -12
- package/dist/src/lib/legi/resolver.test.d.ts +1 -0
- package/dist/src/lib/legi/text_titles_infos.d.ts +26 -0
- package/dist/src/lib/linkers/html.d.ts +15 -4
- package/dist/src/lib/linkers/markdown.d.ts +4 -2
- package/dist/src/lib/server/atomic_files.d.ts +8 -0
- package/dist/src/lib/server/atomic_files.test.d.ts +1 -0
- package/dist/src/lib/server/document_git_checkpoint.d.ts +6 -0
- package/dist/src/lib/server/document_git_checkpoint.test.d.ts +1 -0
- package/dist/src/lib/server/enriched_document_checkpoint.d.ts +3 -0
- package/dist/src/lib/server/enriched_document_checkpoint.test.d.ts +1 -0
- package/dist/src/lib/server/f_legi/index.d.ts +1 -0
- package/dist/src/lib/server/index.d.ts +2 -1
- package/dist/src/lib/server/legi/resolvers.d.ts +2 -7
- package/dist/src/lib/server/linkers/html.d.ts +4 -2
- package/dist/src/scripts/enrich_senat_documents.d.ts +1 -0
- package/package.json +7 -1
- package/dist/src/lib/f_legi/extractors/links.d.ts +0 -134
- package/dist/src/lib/f_legi/linkers/html.d.ts +0 -51
- package/dist/src/lib/server/f_legi/databases/index.d.ts +0 -2
- package/dist/src/lib/server/f_legi/linkers/html.d.ts +0 -20
- package/dist/src/scripts/f_legi/add_links_to_html_document.d.ts +0 -0
- /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 {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
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
|
|
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
|
|
16
|
+
function y(e) {
|
|
18
17
|
return e.replace(/\u00a0/gu, " ").replace(/\s+/gu, " ").trim();
|
|
19
18
|
}
|
|
20
|
-
function
|
|
21
|
-
return
|
|
19
|
+
function b(t) {
|
|
20
|
+
return y(e(t).text());
|
|
22
21
|
}
|
|
23
|
-
function
|
|
24
|
-
let t =
|
|
25
|
-
|
|
22
|
+
function x(e) {
|
|
23
|
+
let t = y([
|
|
24
|
+
v(e, [
|
|
26
25
|
"corps",
|
|
27
26
|
"contenuAuteur",
|
|
28
27
|
"dispositif"
|
|
29
28
|
]),
|
|
30
|
-
|
|
29
|
+
v(e, [
|
|
31
30
|
"corps",
|
|
32
31
|
"contenuAuteur",
|
|
33
32
|
"dispositifAmdtCreditPLF"
|
|
34
33
|
]),
|
|
35
|
-
|
|
34
|
+
v(e, [
|
|
36
35
|
"corps",
|
|
37
36
|
"contenuAuteur",
|
|
38
37
|
"dispositifAmdtCreditPLFR"
|
|
39
38
|
])
|
|
40
|
-
].filter((e) => e !== null).map((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 ? "" :
|
|
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
|
|
56
|
-
return
|
|
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/
|
|
63
|
-
var
|
|
64
|
-
|
|
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
|
|
1080
|
-
return
|
|
66
|
+
function D(e) {
|
|
67
|
+
return E(e).toLowerCase().normalize("NFD").replace(/\p{Diacritic}/gu, "");
|
|
1081
68
|
}
|
|
1082
|
-
function
|
|
1083
|
-
return
|
|
69
|
+
function O(e) {
|
|
70
|
+
return D(e).replace(/[‐‑‒–—]/gu, "-").replace(/\s*\.\s*/gu, ".");
|
|
1084
71
|
}
|
|
1085
|
-
function
|
|
1086
|
-
return
|
|
72
|
+
function ee(e) {
|
|
73
|
+
return O(e).replace(/[^a-z0-9]+/gu, "-").replace(/^-|-$/gu, "");
|
|
1087
74
|
}
|
|
1088
|
-
function
|
|
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
|
|
1107
|
-
let t =
|
|
1108
|
-
if (n?.[1] !== void 0) return
|
|
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
|
|
1111
|
-
let t =
|
|
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:
|
|
102
|
+
num: E(e[1]),
|
|
1116
103
|
text: o
|
|
1117
104
|
};
|
|
1118
105
|
});
|
|
1119
|
-
let r =
|
|
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
|
|
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)
|
|
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))
|
|
121
|
+
for (let e of Object.values(n)) k(e, t);
|
|
1135
122
|
return t;
|
|
1136
123
|
}
|
|
1137
|
-
function
|
|
1138
|
-
let t =
|
|
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
|
|
1142
|
-
return
|
|
128
|
+
function ae(e) {
|
|
129
|
+
return E(e).replace(/[’']/gu, "'").replace(/[‐‑‒–—]/gu, "-");
|
|
1143
130
|
}
|
|
1144
|
-
function
|
|
1145
|
-
let
|
|
1146
|
-
return typeof
|
|
1147
|
-
date:
|
|
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:
|
|
136
|
+
stop: n.offset
|
|
1150
137
|
};
|
|
1151
138
|
}
|
|
1152
|
-
function
|
|
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 :
|
|
143
|
+
return e.slice(t, r).trim().length > 0 ? null : oe(e, r);
|
|
1157
144
|
}
|
|
1158
|
-
function
|
|
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 =
|
|
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 =
|
|
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
|
|
1179
|
-
let 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
|
|
1183
|
-
return
|
|
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
|
|
172
|
+
function A(e) {
|
|
1186
173
|
return e?.type === "tag";
|
|
1187
174
|
}
|
|
1188
|
-
function
|
|
175
|
+
function j(e, t) {
|
|
1189
176
|
return e.html(t) ?? "";
|
|
1190
177
|
}
|
|
1191
|
-
function
|
|
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 =
|
|
186
|
+
let u = E(e(i).text());
|
|
1200
187
|
n.push({
|
|
1201
188
|
id: c,
|
|
1202
|
-
...
|
|
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
|
|
1210
|
-
let r =
|
|
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
|
|
200
|
+
function pe(e, t, n) {
|
|
1214
201
|
if (t === n) return "";
|
|
1215
202
|
if (t.type === "text") return t.data ?? "";
|
|
1216
|
-
if (!
|
|
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 (
|
|
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
|
|
1226
|
-
return t.map((t) =>
|
|
212
|
+
function me(e, t) {
|
|
213
|
+
return t.map((t) => E(e(t).text())).filter(Boolean).join("\n");
|
|
1227
214
|
}
|
|
1228
|
-
function
|
|
1229
|
-
let t =
|
|
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
|
|
1239
|
-
let t =
|
|
1240
|
-
return !t ||
|
|
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
|
|
1243
|
-
if (
|
|
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:
|
|
1246
|
-
date:
|
|
232
|
+
let { output: i } = await n({
|
|
233
|
+
date: r,
|
|
1247
234
|
html: e,
|
|
1248
|
-
legiResolver: t.legiResolver ?? new
|
|
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
|
|
242
|
+
return i ?? e;
|
|
1256
243
|
}
|
|
1257
|
-
function
|
|
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
|
|
246
|
+
return A(r) && A(n) && e(n).parents("table").get(0) === r ? r : A(n) ? n : t;
|
|
1260
247
|
}
|
|
1261
|
-
function
|
|
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 =
|
|
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 =
|
|
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
|
|
264
|
+
function F(e) {
|
|
1278
265
|
let t = e.next;
|
|
1279
266
|
for (; t !== null;) {
|
|
1280
|
-
if (
|
|
267
|
+
if (A(t)) return t;
|
|
1281
268
|
t = t.next;
|
|
1282
269
|
}
|
|
1283
270
|
return null;
|
|
1284
271
|
}
|
|
1285
|
-
function
|
|
272
|
+
function I(e, t, n) {
|
|
1286
273
|
let r = [t.container], i = n?.container;
|
|
1287
|
-
for (let 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
|
|
282
|
+
function _e(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,82 @@ function $e(e, t) {
|
|
|
1300
287
|
}
|
|
1301
288
|
return n;
|
|
1302
289
|
}
|
|
1303
|
-
function
|
|
290
|
+
function L(e, t, n) {
|
|
1304
291
|
let r = [], i = !1;
|
|
1305
|
-
for (let a of
|
|
1306
|
-
let n =
|
|
292
|
+
for (let a of _e(e, n)) {
|
|
293
|
+
let n = E(e(a).text());
|
|
1307
294
|
if (!n) continue;
|
|
1308
|
-
|
|
1309
|
-
let o = i ? "noise" :
|
|
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:
|
|
301
|
+
links: de(e, a),
|
|
1315
302
|
text: n,
|
|
1316
|
-
html:
|
|
303
|
+
html: j(e, a)
|
|
1317
304
|
});
|
|
1318
305
|
}
|
|
1319
306
|
return r;
|
|
1320
307
|
}
|
|
1321
|
-
function
|
|
308
|
+
function R(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
|
|
1327
|
-
let
|
|
1328
|
-
for (let e of
|
|
1329
|
-
let
|
|
1330
|
-
i?.startsWith("_TocArt") || (i?.startsWith("_Toc") && !
|
|
313
|
+
function ve(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") && !z(n, i, e.element) && r.before(n("<span></span>").attr("id", i)), r.attr("id", t));
|
|
318
|
+
}
|
|
319
|
+
let r = P(n);
|
|
320
|
+
for (let [e, t] of r.entries()) {
|
|
321
|
+
let i = I(n, t, r[e + 1]).flatMap((e) => n(e).is("span.alinea[data-alinea]") ? [e] : n(e).find("span.alinea[data-alinea]").get());
|
|
322
|
+
for (let e of i) {
|
|
323
|
+
let r = n(e).attr("data-alinea")?.trim();
|
|
324
|
+
if (!r) continue;
|
|
325
|
+
let i = `${t.id}-alinea-${r.replace(/\s+/gu, "")}`;
|
|
326
|
+
if (z(n, i, e)) continue;
|
|
327
|
+
let a = n(e).attr("id");
|
|
328
|
+
a && a !== i ? n(e).before(n("<span></span>").attr("id", i)) : n(e).attr("id", i);
|
|
329
|
+
}
|
|
1331
330
|
}
|
|
1332
|
-
return
|
|
331
|
+
return n.html();
|
|
1333
332
|
}
|
|
1334
|
-
function
|
|
333
|
+
function z(e, t, n) {
|
|
1335
334
|
for (let r of e("[id]").get()) if (r !== n && e(r).attr("id") === t) return !0;
|
|
1336
335
|
return !1;
|
|
1337
336
|
}
|
|
1338
|
-
function
|
|
1339
|
-
let n =
|
|
337
|
+
function ye(e, t) {
|
|
338
|
+
let n = ue("sourceText" in t ? t.sourceText : "");
|
|
1340
339
|
if (n) return e.filter((e) => e.kind === "directive_candidate").find((e) => {
|
|
1341
|
-
let t =
|
|
340
|
+
let t = ue(e.text);
|
|
1342
341
|
return t.length > 0 && (n.includes(t) || t.includes(n));
|
|
1343
342
|
});
|
|
1344
343
|
}
|
|
1345
|
-
function
|
|
344
|
+
function be(e, t) {
|
|
1346
345
|
if (t) return t.blockIds.map((t) => e.get(t)).find((e) => e?.kind === "directive_candidate");
|
|
1347
346
|
}
|
|
1348
|
-
function
|
|
347
|
+
function xe(e) {
|
|
1349
348
|
return e?.links.filter((e) => !e.insideFrenchQuotes && (e.type === "article" || e.type === "division")).map((e) => e.id) ?? [];
|
|
1350
349
|
}
|
|
1351
|
-
var
|
|
350
|
+
var Se = [
|
|
1352
351
|
/^([IVXLCDM]+)\s*[.).]?\s*[–—-]/iu,
|
|
1353
352
|
/^(\d+°)\s+/u,
|
|
1354
353
|
/^([a-z])\)\s+/iu,
|
|
1355
354
|
/^([ivxlcdm]+)\)\s+/iu
|
|
1356
355
|
];
|
|
1357
|
-
function
|
|
1358
|
-
let t =
|
|
356
|
+
function Ce(e) {
|
|
357
|
+
let t = E(e);
|
|
1359
358
|
if (!t) return;
|
|
1360
|
-
let n =
|
|
359
|
+
let n = Se.findIndex((e) => e.test(t));
|
|
1361
360
|
return n === -1 ? t.endsWith(":") ? 0 : void 0 : n + 1;
|
|
1362
361
|
}
|
|
1363
|
-
function
|
|
362
|
+
function we(e) {
|
|
1364
363
|
let t = /* @__PURE__ */ new Map(), n = [];
|
|
1365
364
|
for (let r of e) {
|
|
1366
|
-
let e =
|
|
365
|
+
let e = Ce(r.text);
|
|
1367
366
|
if (e === void 0) {
|
|
1368
367
|
t.set(r.id, [...n, r]);
|
|
1369
368
|
continue;
|
|
@@ -1372,14 +371,14 @@ function lt(e) {
|
|
|
1372
371
|
}
|
|
1373
372
|
return t;
|
|
1374
373
|
}
|
|
1375
|
-
function
|
|
374
|
+
function Te(e, t) {
|
|
1376
375
|
let n = [], r = /* @__PURE__ */ new Set();
|
|
1377
376
|
for (let i of [...e ?? [], ...t]) i !== void 0 && (r.has(i.id) || (r.add(i.id), n.push(i)));
|
|
1378
377
|
return n;
|
|
1379
378
|
}
|
|
1380
|
-
function
|
|
379
|
+
function Ee(e, t, n) {
|
|
1381
380
|
if (!t) return;
|
|
1382
|
-
let r =
|
|
381
|
+
let r = Te(e, t.blockIds.map((e) => n.get(e)).filter((e) => e !== void 0));
|
|
1383
382
|
if (r.length === 0) return;
|
|
1384
383
|
let i = r.map((e) => e.id);
|
|
1385
384
|
if (i.length === t.blockIds.length && i.every((e, n) => e === t.blockIds[n])) return;
|
|
@@ -1394,7 +393,7 @@ function dt(e, t, n) {
|
|
|
1394
393
|
}
|
|
1395
394
|
};
|
|
1396
395
|
}
|
|
1397
|
-
function
|
|
396
|
+
function De(e) {
|
|
1398
397
|
let t = [], n = 0;
|
|
1399
398
|
for (let r of e.blocks) {
|
|
1400
399
|
let i = e.directiveText.indexOf(r.text, n);
|
|
@@ -1408,7 +407,7 @@ function ft(e) {
|
|
|
1408
407
|
}
|
|
1409
408
|
return t;
|
|
1410
409
|
}
|
|
1411
|
-
function
|
|
410
|
+
function Oe(e, t, n) {
|
|
1412
411
|
let { start: r, stop: i } = n.sourcePosition, a = t.filter((e) => e.stop >= r && e.start <= i);
|
|
1413
412
|
if (a.length === 0) return;
|
|
1414
413
|
let o = a[0], s = a[a.length - 1], c = o.start, l = s.stop;
|
|
@@ -1422,7 +421,7 @@ function pt(e, t, n) {
|
|
|
1422
421
|
}
|
|
1423
422
|
};
|
|
1424
423
|
}
|
|
1425
|
-
function
|
|
424
|
+
function ke(e, t, n) {
|
|
1426
425
|
if (!t) return;
|
|
1427
426
|
let r = e.directiveText.indexOf(t.text);
|
|
1428
427
|
if (r === -1) return;
|
|
@@ -1435,14 +434,14 @@ function mt(e, t, n) {
|
|
|
1435
434
|
stop: a
|
|
1436
435
|
};
|
|
1437
436
|
}
|
|
1438
|
-
function
|
|
1439
|
-
let t =
|
|
437
|
+
function Ae(e) {
|
|
438
|
+
let t = De(e), n = new Map(e.blocks.map((e) => [e.id, e])), r = we(e.blocks), a = /* @__PURE__ */ new Map(), o = [];
|
|
1440
439
|
for (let t of e.blocks) {
|
|
1441
|
-
let e =
|
|
1442
|
-
e.length > 0 && (
|
|
440
|
+
let e = xe(t);
|
|
441
|
+
e.length > 0 && (o = e), a.set(t.id, o);
|
|
1443
442
|
}
|
|
1444
|
-
return
|
|
1445
|
-
let o =
|
|
443
|
+
return i(e.directiveText).map((i) => {
|
|
444
|
+
let o = Oe(e, t, i), s = be(n, o) ?? ye(e.blocks, i), c = xe(s), l = c.length > 0 ? c : s?.id === void 0 ? [] : a.get(s.id) ?? [], u = ke(e, s, i), d = Ee(s?.id === void 0 ? void 0 : r.get(s.id), o, n);
|
|
1446
445
|
return {
|
|
1447
446
|
articleId: e.id,
|
|
1448
447
|
blockId: s?.id,
|
|
@@ -1457,18 +456,18 @@ function ht(e) {
|
|
|
1457
456
|
sourceContextBlockIds: d.blockIds,
|
|
1458
457
|
sourceContextPosition: d.position
|
|
1459
458
|
},
|
|
1460
|
-
directive:
|
|
459
|
+
directive: i,
|
|
1461
460
|
...l.length > 0 ? { targetIds: l } : {}
|
|
1462
461
|
};
|
|
1463
462
|
});
|
|
1464
463
|
}
|
|
1465
|
-
function
|
|
464
|
+
function je(e) {
|
|
1466
465
|
let t = /* @__PURE__ */ new Map(), n = [], r = /* @__PURE__ */ new Set();
|
|
1467
466
|
for (let i of e) {
|
|
1468
|
-
let e =
|
|
467
|
+
let e = re(i.directive);
|
|
1469
468
|
if (e.length === 0) continue;
|
|
1470
469
|
let a = e.map(({ num: e }) => ({
|
|
1471
|
-
definitionId: `${i.articleId}:article:${
|
|
470
|
+
definitionId: `${i.articleId}:article:${ee(e)}`,
|
|
1472
471
|
num: e
|
|
1473
472
|
}));
|
|
1474
473
|
t.set(i, a);
|
|
@@ -1492,13 +491,13 @@ function gt(e) {
|
|
|
1492
491
|
definitions: n
|
|
1493
492
|
};
|
|
1494
493
|
}
|
|
1495
|
-
function
|
|
1496
|
-
let r = new Map(t.map((e) => [
|
|
494
|
+
function Me(e, t, n) {
|
|
495
|
+
let r = new Map(t.map((e) => [O(e.num), e]));
|
|
1497
496
|
return e.map((e) => {
|
|
1498
|
-
let t = n.get(e), i = t?.[0], a = [...
|
|
497
|
+
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
498
|
definitionId: a.definitionId,
|
|
1500
499
|
num: a.num
|
|
1501
|
-
}, s =
|
|
500
|
+
}, s = ie(e.directive), c = (e.targetIds?.length ?? 0) > 0;
|
|
1502
501
|
return {
|
|
1503
502
|
...e,
|
|
1504
503
|
...i === void 0 ? {} : { createdArticle: i },
|
|
@@ -1511,72 +510,72 @@ function _t(e, t, n) {
|
|
|
1511
510
|
};
|
|
1512
511
|
});
|
|
1513
512
|
}
|
|
1514
|
-
function
|
|
1515
|
-
let
|
|
513
|
+
function Ne(e, t, n, i, a, o, s = !0) {
|
|
514
|
+
let c = a.map((e) => e.directiveText).filter(Boolean).join("\n"), l = {
|
|
1516
515
|
sourceFormat: e,
|
|
1517
|
-
documentDate:
|
|
516
|
+
documentDate: i,
|
|
1518
517
|
html: t,
|
|
1519
518
|
htmlWithLinks: n,
|
|
1520
|
-
tableOfContents:
|
|
1521
|
-
articles:
|
|
519
|
+
tableOfContents: o ?? r(c),
|
|
520
|
+
articles: a
|
|
1522
521
|
};
|
|
1523
|
-
if (!
|
|
1524
|
-
...
|
|
522
|
+
if (!s) return {
|
|
523
|
+
...l,
|
|
1525
524
|
directives: []
|
|
1526
525
|
};
|
|
1527
|
-
let
|
|
526
|
+
let u = le(a.map((e) => e.text).join("\n")), d = a.flatMap(Ae), { createdArticlesByDirective: f, definitions: p } = je(d), m = Me(d, p, f);
|
|
1528
527
|
return {
|
|
1529
|
-
...
|
|
1530
|
-
...
|
|
1531
|
-
...
|
|
1532
|
-
directives:
|
|
528
|
+
...l,
|
|
529
|
+
...u ? { globalApplicabilityDate: u } : {},
|
|
530
|
+
...p.length > 0 ? { internalArticleDefinitions: p } : {},
|
|
531
|
+
directives: m
|
|
1533
532
|
};
|
|
1534
533
|
}
|
|
1535
|
-
function
|
|
1536
|
-
let t =
|
|
1537
|
-
function
|
|
1538
|
-
for (let t of e.articles ?? [])
|
|
1539
|
-
for (let t of e.divisions ?? [])
|
|
534
|
+
function Pe(e) {
|
|
535
|
+
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;
|
|
536
|
+
function a(e) {
|
|
537
|
+
for (let t of e.articles ?? []) i += 1, t.id ??= n.get(D(t.line));
|
|
538
|
+
for (let t of e.divisions ?? []) a(t);
|
|
1540
539
|
}
|
|
1541
|
-
return
|
|
540
|
+
return a(t), i > 0 ? t : { articles: e.map((e) => ({
|
|
1542
541
|
id: e.id,
|
|
1543
542
|
line: e.title ? `${e.label} : ${e.title}` : e.label,
|
|
1544
543
|
type: "article"
|
|
1545
544
|
})) };
|
|
1546
545
|
}
|
|
1547
|
-
async function
|
|
1548
|
-
let
|
|
1549
|
-
let n =
|
|
546
|
+
async function Fe(t, n) {
|
|
547
|
+
let r = new u("parseAssembleeBillRaw"), i = n.linkedHtml === void 0 ? await r.time("linkAssembleeBillRaw", () => Ie(t, n)) : void 0, a = r.timeSync("applyArticleAnchorIds", () => ve(n.linkedHtml ?? i.linkedHtml), { inputSize: t.length }), o = r.timeSync("cheerioLoadLinkedHtml", () => e(a)), s = r.timeSync("extractArticleHeadings", () => P(o)), c = r.timeSync("extractArticlesAndBlocks", () => s.map((e, t) => {
|
|
548
|
+
let n = I(o, e, s[t + 1]), r = L(o, e.id, n), i = r.filter((e) => e.kind !== "noise").map((e) => e.text).join("\n");
|
|
1550
549
|
return {
|
|
1551
550
|
id: e.id,
|
|
1552
551
|
label: e.label,
|
|
1553
552
|
num: e.num,
|
|
1554
553
|
title: e.title,
|
|
1555
|
-
text:
|
|
1556
|
-
html: n.map((e) =>
|
|
554
|
+
text: me(o, n),
|
|
555
|
+
html: n.map((e) => j(o, e)).join("\n"),
|
|
1557
556
|
directiveText: i,
|
|
1558
557
|
blocks: r
|
|
1559
558
|
};
|
|
1560
|
-
}), { count:
|
|
1561
|
-
return
|
|
1562
|
-
articleCount:
|
|
1563
|
-
blockCount:
|
|
1564
|
-
directiveCount:
|
|
1565
|
-
targetDirectiveCount:
|
|
1566
|
-
}),
|
|
559
|
+
}), { count: s.length }), l = r.timeSync("injectHiddenArticleSummary", () => R(o.html(), c)), d = r.timeSync("buildAssembleeTableOfContents", () => Pe(c), { count: c.length }), f = r.timeSync("buildParsedDocument", () => Ne("assemblee-html", t, l, n.date, c, d, n.includeDirectiveAnalysis));
|
|
560
|
+
return r.log({
|
|
561
|
+
articleCount: f.articles.length,
|
|
562
|
+
blockCount: f.articles.reduce((e, t) => e + t.blocks.length, 0),
|
|
563
|
+
directiveCount: f.directives.length,
|
|
564
|
+
targetDirectiveCount: f.directives.filter((e) => e.targetIds !== void 0).length
|
|
565
|
+
}), f;
|
|
1567
566
|
}
|
|
1568
|
-
async function
|
|
567
|
+
async function Ie(e, t) {
|
|
1569
568
|
return {
|
|
1570
569
|
sourceFormat: "assemblee-html",
|
|
1571
570
|
documentDate: t.date,
|
|
1572
571
|
html: e,
|
|
1573
|
-
linkedHtml: await
|
|
572
|
+
linkedHtml: await N(e, t, t.date)
|
|
1574
573
|
};
|
|
1575
574
|
}
|
|
1576
|
-
function
|
|
575
|
+
function B(e) {
|
|
1577
576
|
return e.replace(/&/gu, "&").replace(/</gu, "<").replace(/>/gu, ">").replace(/"/gu, """);
|
|
1578
577
|
}
|
|
1579
|
-
function
|
|
578
|
+
function Le(e) {
|
|
1580
579
|
let t = e;
|
|
1581
580
|
for (let e = 0; e < 3; e++) {
|
|
1582
581
|
let e = t;
|
|
@@ -1584,27 +583,27 @@ function St(e) {
|
|
|
1584
583
|
}
|
|
1585
584
|
return t;
|
|
1586
585
|
}
|
|
1587
|
-
function
|
|
586
|
+
function Re(e) {
|
|
1588
587
|
return /(?:<|&lt;)\/?(?:p|br|span|b|i|u|sup|sub|table|thead|tbody|tr|th|td|ul|ol|li)\b/iu.test(e);
|
|
1589
588
|
}
|
|
1590
|
-
function
|
|
589
|
+
function V(e) {
|
|
1591
590
|
return e.name.replace(/^.*:/u, "");
|
|
1592
591
|
}
|
|
1593
|
-
function
|
|
1594
|
-
return t.children.map((t) =>
|
|
592
|
+
function ze(e, t) {
|
|
593
|
+
return t.children.map((t) => H(e, t)).filter(Boolean).join("");
|
|
1595
594
|
}
|
|
1596
|
-
function
|
|
1597
|
-
return t.children.map((t) => t.type === "text" &&
|
|
595
|
+
function Be(e, t) {
|
|
596
|
+
return t.children.map((t) => t.type === "text" && Re(t.data) ? Le(t.data) : H(e, t)).filter(Boolean).join("");
|
|
1598
597
|
}
|
|
1599
|
-
function
|
|
598
|
+
function H(e, t) {
|
|
1600
599
|
if (t.type === "text") {
|
|
1601
600
|
let e = t.data.replace(/\s+\./gu, ".");
|
|
1602
|
-
return
|
|
601
|
+
return Re(e) ? Le(e) : B(e);
|
|
1603
602
|
}
|
|
1604
|
-
if (!
|
|
1605
|
-
let n =
|
|
603
|
+
if (!A(t)) return "";
|
|
604
|
+
let n = V(t), r = ze(e, t);
|
|
1606
605
|
switch (n) {
|
|
1607
|
-
case "p": return `<p${
|
|
606
|
+
case "p": return `<p${U(e, t, [
|
|
1608
607
|
"id",
|
|
1609
608
|
"class",
|
|
1610
609
|
"align",
|
|
@@ -1618,13 +617,13 @@ function q(e, t) {
|
|
|
1618
617
|
case "u":
|
|
1619
618
|
case "sup":
|
|
1620
619
|
case "sub":
|
|
1621
|
-
case "abbr": return `<${n}${
|
|
620
|
+
case "abbr": return `<${n}${U(e, t, [
|
|
1622
621
|
"id",
|
|
1623
622
|
"class",
|
|
1624
623
|
"title",
|
|
1625
624
|
"style"
|
|
1626
625
|
])}>${r}</${n}>`;
|
|
1627
|
-
case "a": return `<a href="${
|
|
626
|
+
case "a": return `<a href="${B(e(t).attr("href") ?? e(t).attr("target") ?? "#")}"${U(e, t, [
|
|
1628
627
|
"id",
|
|
1629
628
|
"class",
|
|
1630
629
|
"title",
|
|
@@ -1635,8 +634,8 @@ function q(e, t) {
|
|
|
1635
634
|
case "tbody":
|
|
1636
635
|
case "tr":
|
|
1637
636
|
case "th":
|
|
1638
|
-
case "td": return
|
|
1639
|
-
case "caption": return `<caption${
|
|
637
|
+
case "td": return Ve(e, t, n, r);
|
|
638
|
+
case "caption": return `<caption${U(e, t, [
|
|
1640
639
|
"id",
|
|
1641
640
|
"class",
|
|
1642
641
|
"align",
|
|
@@ -1644,12 +643,12 @@ function q(e, t) {
|
|
|
1644
643
|
])}>${r}</caption>`;
|
|
1645
644
|
case "num": return `<span class="akn-num">${r}</span> `;
|
|
1646
645
|
case "heading": return `<p class="akn-heading">${r}</p>`;
|
|
1647
|
-
case "content": return
|
|
1648
|
-
case "alinea": return
|
|
1649
|
-
case "article": return
|
|
646
|
+
case "content": return Be(e, t);
|
|
647
|
+
case "alinea": return q(e, t, "div", "akn-alinea");
|
|
648
|
+
case "article": return q(e, t, "article", "akn-article");
|
|
1650
649
|
case "blockList":
|
|
1651
650
|
case "list": return `<div class="akn-list">${r}</div>`;
|
|
1652
|
-
case "item": return
|
|
651
|
+
case "item": return q(e, t, "div", "akn-item");
|
|
1653
652
|
case "listIntroduction":
|
|
1654
653
|
case "listWrapUp":
|
|
1655
654
|
case "intro":
|
|
@@ -1665,23 +664,23 @@ function q(e, t) {
|
|
|
1665
664
|
case "book":
|
|
1666
665
|
case "tome":
|
|
1667
666
|
case "subchapter":
|
|
1668
|
-
case "subsection": return
|
|
667
|
+
case "subsection": return q(e, t, "section", `akn-${n}`);
|
|
1669
668
|
case "crossHeading": return `<p class="akn-cross-heading">${r}</p>`;
|
|
1670
669
|
default: return r;
|
|
1671
670
|
}
|
|
1672
671
|
}
|
|
1673
|
-
function
|
|
672
|
+
function U(e, t, n, r = {}) {
|
|
1674
673
|
let i = [];
|
|
1675
674
|
for (let r of n) {
|
|
1676
675
|
if (r === "style") continue;
|
|
1677
676
|
let n = e(t).attr(r);
|
|
1678
|
-
n !== void 0 && i.push(`${r}="${
|
|
677
|
+
n !== void 0 && i.push(`${r}="${B(n)}"`);
|
|
1679
678
|
}
|
|
1680
679
|
let a = r.style ?? e(t).attr("style");
|
|
1681
|
-
return a && i.push(`style="${
|
|
680
|
+
return a && i.push(`style="${B(a)}"`), i.length > 0 ? ` ${i.join(" ")}` : "";
|
|
1682
681
|
}
|
|
1683
|
-
function
|
|
1684
|
-
return `<${n}${
|
|
682
|
+
function Ve(e, t, n, r) {
|
|
683
|
+
return `<${n}${U(e, t, [
|
|
1685
684
|
"id",
|
|
1686
685
|
"class",
|
|
1687
686
|
"colspan",
|
|
@@ -1694,155 +693,155 @@ function Et(e, t, n, r) {
|
|
|
1694
693
|
"cellspacing",
|
|
1695
694
|
"cellpadding",
|
|
1696
695
|
"style"
|
|
1697
|
-
], { style:
|
|
696
|
+
], { style: He(e, t, n) })}>${r}</${n}>`;
|
|
1698
697
|
}
|
|
1699
|
-
function
|
|
698
|
+
function He(e, t, n) {
|
|
1700
699
|
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 =
|
|
700
|
+
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
701
|
}
|
|
1703
|
-
function
|
|
702
|
+
function Ue(e, t, n) {
|
|
1704
703
|
let r = e.trim();
|
|
1705
704
|
return `${r}${r && !r.endsWith(";") ? ";" : ""} ${t}: ${n};`.trim();
|
|
1706
705
|
}
|
|
1707
|
-
function
|
|
1708
|
-
let n = [
|
|
1709
|
-
return n.length === 0 ? "" : `<p class="akn-heading">${
|
|
706
|
+
function We(e, t) {
|
|
707
|
+
let n = [E(e(t).children("num").first().text()), E(e(t).children("heading").first().text())].filter(Boolean);
|
|
708
|
+
return n.length === 0 ? "" : `<p class="akn-heading">${B(n.join(" "))}</p>`;
|
|
1710
709
|
}
|
|
1711
|
-
function
|
|
710
|
+
function Ge(e, t) {
|
|
1712
711
|
if (!t) return !1;
|
|
1713
|
-
let n = (e) =>
|
|
1714
|
-
return n(
|
|
712
|
+
let n = (e) => E(e).replace(/\s+/gu, " ").replace(/\s*[..]\s*(?=[–—-])/gu, " ").trim();
|
|
713
|
+
return n(E(e.replace(/<[^>]*>/gu, " ").replace(/ /gu, " ").replace(/ /giu, " ").replace(/–/giu, "–"))).startsWith(n(t));
|
|
1715
714
|
}
|
|
1716
|
-
function
|
|
1717
|
-
let t =
|
|
715
|
+
function Ke(e) {
|
|
716
|
+
let t = B(e);
|
|
1718
717
|
return `<p data-pastille="${t}" class="pastille"><span aria-label="pastille ${t}">${t}</span></p>`;
|
|
1719
718
|
}
|
|
1720
|
-
function
|
|
1721
|
-
return
|
|
719
|
+
function qe(e, t) {
|
|
720
|
+
return W([Je({
|
|
1722
721
|
content: e,
|
|
1723
722
|
pastille: t
|
|
1724
723
|
})]);
|
|
1725
724
|
}
|
|
1726
|
-
function
|
|
725
|
+
function W(e) {
|
|
1727
726
|
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
727
|
}
|
|
1729
|
-
function
|
|
1730
|
-
let i = n ? ` style="${
|
|
1731
|
-
return `<tr${r ? ` class="${
|
|
728
|
+
function Je({ content: e, pastille: t, style: n, contextClass: r }) {
|
|
729
|
+
let i = n ? ` style="${B(n)}"` : "", a = r ? ` ${B(r)}` : "";
|
|
730
|
+
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
731
|
}
|
|
1733
|
-
function
|
|
1734
|
-
let r = t ? ` style="${
|
|
1735
|
-
return `<tr${n ? ` class="${
|
|
732
|
+
function G({ content: e, style: t, contextClass: n }) {
|
|
733
|
+
let r = t ? ` style="${B(t)}"` : "", i = n ? ` ${B(n)}` : "";
|
|
734
|
+
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
735
|
}
|
|
1737
|
-
function
|
|
736
|
+
function Ye(e, t) {
|
|
1738
737
|
return e(t).attr("data:pastille") ?? e(t).attr("pastille");
|
|
1739
738
|
}
|
|
1740
|
-
function
|
|
739
|
+
function Xe(e, t) {
|
|
1741
740
|
return e(t).find("alinea[data\\:pastille],alinea[pastille]").length > 0;
|
|
1742
741
|
}
|
|
1743
|
-
function
|
|
1744
|
-
return e(t).children().get().filter((e) =>
|
|
742
|
+
function Ze(e, t) {
|
|
743
|
+
return e(t).children().get().filter((e) => A(e) ? V(e) === "content" : !1).map((t) => H(e, t)).filter(Boolean).join("\n");
|
|
1745
744
|
}
|
|
1746
|
-
function
|
|
745
|
+
function Qe(e, t) {
|
|
1747
746
|
let n = [];
|
|
1748
747
|
return e(t).children().each((t, r) => {
|
|
1749
|
-
if (!
|
|
1750
|
-
let i =
|
|
1751
|
-
i === "num" || i === "heading" || i === "content" || n.push(
|
|
748
|
+
if (!A(r)) return;
|
|
749
|
+
let i = V(r);
|
|
750
|
+
i === "num" || i === "heading" || i === "content" || n.push(H(e, r));
|
|
1752
751
|
}), n.filter(Boolean);
|
|
1753
752
|
}
|
|
1754
|
-
function
|
|
1755
|
-
let n = [], r =
|
|
753
|
+
function K(e, t) {
|
|
754
|
+
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
755
|
if (i) {
|
|
1757
|
-
let r = [
|
|
1758
|
-
|
|
756
|
+
let r = [Ge(a, E(e(t).children("num").first().text())) ? "" : We(e, t), a].filter(Boolean).join("\n");
|
|
757
|
+
E(r) && n.push(Je({
|
|
1759
758
|
content: r,
|
|
1760
759
|
pastille: i,
|
|
1761
760
|
style: o,
|
|
1762
761
|
contextClass: s
|
|
1763
762
|
}));
|
|
1764
|
-
} else a && n.push(
|
|
763
|
+
} else a && n.push(G({
|
|
1765
764
|
content: a,
|
|
1766
765
|
style: o,
|
|
1767
766
|
contextClass: s
|
|
1768
767
|
}));
|
|
1769
768
|
for (let r of e(t).children().get()) {
|
|
1770
|
-
if (!
|
|
1771
|
-
let t =
|
|
1772
|
-
t === "num" || t === "heading" || t === "content" || (t === "alinea" ||
|
|
769
|
+
if (!A(r)) continue;
|
|
770
|
+
let t = V(r);
|
|
771
|
+
t === "num" || t === "heading" || t === "content" || (t === "alinea" || Xe(e, r)) && n.push(...K(e, r));
|
|
1773
772
|
}
|
|
1774
773
|
return n;
|
|
1775
774
|
}
|
|
1776
|
-
function
|
|
1777
|
-
let i =
|
|
1778
|
-
a ? `id="${
|
|
775
|
+
function q(e, t, n, r) {
|
|
776
|
+
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} ${[
|
|
777
|
+
a ? `id="${B(a)}"` : void 0,
|
|
1779
778
|
`class="${r}"`,
|
|
1780
|
-
o ? `data-pastille="${
|
|
1781
|
-
s ? `style="${
|
|
779
|
+
o ? `data-pastille="${B(o)}"` : void 0,
|
|
780
|
+
s ? `style="${B(s)}"` : void 0
|
|
1782
781
|
].filter((e) => e !== void 0).join(" ")}>`];
|
|
1783
782
|
if (i === "part" || i === "title") {
|
|
1784
|
-
let r =
|
|
783
|
+
let r = nt(e, t, i), a = it(e, t), o = r ? [G({
|
|
1785
784
|
content: r,
|
|
1786
785
|
contextClass: a
|
|
1787
786
|
})] : [], s = () => {
|
|
1788
|
-
o.length !== 0 && (c.push(
|
|
787
|
+
o.length !== 0 && (c.push(tt(o)), o = []);
|
|
1789
788
|
};
|
|
1790
789
|
return e(t).children().each((t, n) => {
|
|
1791
|
-
if (!
|
|
1792
|
-
let r =
|
|
790
|
+
if (!A(n)) return;
|
|
791
|
+
let r = V(n);
|
|
1793
792
|
if (!(r === "num" || r === "heading" || r === "content")) {
|
|
1794
793
|
if (r === "alinea") {
|
|
1795
|
-
o.push(...
|
|
794
|
+
o.push(...K(e, n));
|
|
1796
795
|
return;
|
|
1797
796
|
}
|
|
1798
|
-
s(), c.push(
|
|
797
|
+
s(), c.push(H(e, n));
|
|
1799
798
|
}
|
|
1800
799
|
}), s(), c.push(`</${n}>`), c.join("\n");
|
|
1801
800
|
}
|
|
1802
801
|
if (i === "article") {
|
|
1803
|
-
let r =
|
|
802
|
+
let r = E(e(t).children("num").first().text()), i = E(e(t).children("heading").first().text()), a = M(r) ?? {
|
|
1804
803
|
label: r,
|
|
1805
804
|
num: r
|
|
1806
|
-
}, o = `<p class="TCNumArticle as-text toc-article dispositif" id="${
|
|
1807
|
-
if (
|
|
1808
|
-
let r = [
|
|
805
|
+
}, 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>`;
|
|
806
|
+
if (Xe(e, t)) {
|
|
807
|
+
let r = [G({
|
|
1809
808
|
content: o,
|
|
1810
|
-
contextClass:
|
|
1811
|
-
}), ...
|
|
1812
|
-
c.push(
|
|
1813
|
-
for (let n of
|
|
809
|
+
contextClass: st(a.label)
|
|
810
|
+
}), ...K(e, t)];
|
|
811
|
+
c.push(W(r));
|
|
812
|
+
for (let n of Qe(e, t)) n.includes("akn-pastille-table") || c.push(n);
|
|
1814
813
|
return c.push(`</${n}>`), c.join("\n");
|
|
1815
814
|
}
|
|
1816
815
|
c.push(o);
|
|
1817
816
|
}
|
|
1818
817
|
let l = [];
|
|
1819
818
|
for (let n of ["content", "children"]) e(t).children().each((t, r) => {
|
|
1820
|
-
if (!
|
|
1821
|
-
let i =
|
|
1822
|
-
i === "num" || i === "heading" || n === "content" && i !== "content" || n === "children" && i === "content" || l.push(
|
|
819
|
+
if (!A(r)) return;
|
|
820
|
+
let i = V(r);
|
|
821
|
+
i === "num" || i === "heading" || n === "content" && i !== "content" || n === "children" && i === "content" || l.push(H(e, r));
|
|
1823
822
|
});
|
|
1824
823
|
let u = l.join("\n");
|
|
1825
824
|
if (i !== "article") {
|
|
1826
|
-
let n =
|
|
825
|
+
let n = Ge(u, E(e(t).children("num").first().text())) ? "" : We(e, t);
|
|
1827
826
|
n && c.push(n);
|
|
1828
827
|
}
|
|
1829
|
-
return c.push(o ?
|
|
828
|
+
return c.push(o ? qe(u, o) : u), c.push(`</${n}>`), c.join("\n");
|
|
1830
829
|
}
|
|
1831
|
-
function
|
|
1832
|
-
let i =
|
|
1833
|
-
return !r && n !== "article" && /font-weight\s*:\s*bold/iu.test(i) && !/text-align\s*:/iu.test(i) && (i =
|
|
830
|
+
function $e(e, t, n, r) {
|
|
831
|
+
let i = et(e(t).attr("style") ?? "", "font-family");
|
|
832
|
+
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
833
|
}
|
|
1835
|
-
function
|
|
834
|
+
function et(e, t) {
|
|
1836
835
|
return e.split(";").map((e) => e.trim()).filter(Boolean).filter((e) => !e.toLowerCase().startsWith(`${t.toLowerCase()}:`)).join(";");
|
|
1837
836
|
}
|
|
1838
|
-
function
|
|
837
|
+
function tt(e) {
|
|
1839
838
|
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
839
|
}
|
|
1841
|
-
function
|
|
1842
|
-
let r =
|
|
1843
|
-
return r && o.push(`<p class="${a.num} as-text dispositif"><span aria-label="">${
|
|
840
|
+
function nt(e, t, n) {
|
|
841
|
+
let r = E(e(t).children("num").first().text()), i = E(e(t).children("heading").first().text()), a = rt(n), o = [];
|
|
842
|
+
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
843
|
}
|
|
1845
|
-
function
|
|
844
|
+
function rt(e) {
|
|
1846
845
|
switch (e) {
|
|
1847
846
|
case "part": return {
|
|
1848
847
|
num: "TCNumPartie",
|
|
@@ -1866,22 +865,22 @@ function Gt(e) {
|
|
|
1866
865
|
};
|
|
1867
866
|
}
|
|
1868
867
|
}
|
|
1869
|
-
function
|
|
1870
|
-
let n =
|
|
868
|
+
function it(e, t) {
|
|
869
|
+
let n = ot(E(e(t).children("num").first().text()));
|
|
1871
870
|
if (n) return n;
|
|
1872
871
|
for (let n of e(t).parents().get()) {
|
|
1873
|
-
if (!
|
|
1874
|
-
let t =
|
|
872
|
+
if (!A(n)) continue;
|
|
873
|
+
let t = V(n);
|
|
1875
874
|
if (t !== "title" && t !== "part") continue;
|
|
1876
|
-
let r =
|
|
875
|
+
let r = ot(E(e(n).children("num").first().text()));
|
|
1877
876
|
if (r) return r;
|
|
1878
877
|
}
|
|
1879
878
|
}
|
|
1880
|
-
function
|
|
1881
|
-
return
|
|
879
|
+
function at(e, t) {
|
|
880
|
+
return it(e, t);
|
|
1882
881
|
}
|
|
1883
|
-
function
|
|
1884
|
-
let [t, ...n] =
|
|
882
|
+
function ot(e) {
|
|
883
|
+
let [t, ...n] = E(e).split(/\s+/u);
|
|
1885
884
|
if (!t || n.length === 0) return;
|
|
1886
885
|
let r = t.toLocaleLowerCase("fr-FR");
|
|
1887
886
|
if ([
|
|
@@ -1891,10 +890,10 @@ function Jt(e) {
|
|
|
1891
890
|
"section"
|
|
1892
891
|
].includes(r)) return `${r}-${n.join("_")}`;
|
|
1893
892
|
}
|
|
1894
|
-
function
|
|
1895
|
-
return `article-${
|
|
893
|
+
function st(e) {
|
|
894
|
+
return `article-${E(e).replace(/^Article\s+/iu, "").replace(/\s+/gu, "_")} article`;
|
|
1896
895
|
}
|
|
1897
|
-
function
|
|
896
|
+
function ct(e) {
|
|
1898
897
|
switch (e) {
|
|
1899
898
|
case "part": return "partie";
|
|
1900
899
|
case "book": return "livre";
|
|
@@ -1906,11 +905,11 @@ function Xt(e) {
|
|
|
1906
905
|
default: return;
|
|
1907
906
|
}
|
|
1908
907
|
}
|
|
1909
|
-
function
|
|
1910
|
-
return [
|
|
908
|
+
function lt(e, t) {
|
|
909
|
+
return [E(e(t).children("num").first().text()), E(e(t).children("heading").first().text())].filter(Boolean).join(" ");
|
|
1911
910
|
}
|
|
1912
|
-
function
|
|
1913
|
-
let n =
|
|
911
|
+
function ut(e, t) {
|
|
912
|
+
let n = E(e(t).children("num").first().text()), r = E(e(t).children("heading").first().text()), i = M(n) ?? {
|
|
1914
913
|
label: n,
|
|
1915
914
|
num: n
|
|
1916
915
|
};
|
|
@@ -1920,24 +919,24 @@ function Qt(e, t) {
|
|
|
1920
919
|
type: "article"
|
|
1921
920
|
};
|
|
1922
921
|
}
|
|
1923
|
-
function
|
|
922
|
+
function dt(e, t) {
|
|
1924
923
|
t.articles?.length && (e.articles ??= [], e.articles.push(...t.articles)), t.divisions?.length && (e.divisions ??= [], e.divisions.push(...t.divisions));
|
|
1925
924
|
}
|
|
1926
|
-
function
|
|
925
|
+
function J(e, t) {
|
|
1927
926
|
let n = {};
|
|
1928
927
|
return e(t).children().each((t, r) => {
|
|
1929
|
-
if (!
|
|
1930
|
-
let i =
|
|
928
|
+
if (!A(r)) return;
|
|
929
|
+
let i = V(r);
|
|
1931
930
|
if (i === "article") {
|
|
1932
|
-
n.articles ??= [], n.articles.push(
|
|
931
|
+
n.articles ??= [], n.articles.push(ut(e, r));
|
|
1933
932
|
return;
|
|
1934
933
|
}
|
|
1935
|
-
let a =
|
|
934
|
+
let a = ct(i);
|
|
1936
935
|
if (!a) {
|
|
1937
|
-
|
|
936
|
+
dt(n, J(e, r));
|
|
1938
937
|
return;
|
|
1939
938
|
}
|
|
1940
|
-
let o =
|
|
939
|
+
let o = lt(e, r), s = J(e, r);
|
|
1941
940
|
!o && !s.articles?.length && !s.divisions?.length || (n.divisions ??= [], n.divisions.push({
|
|
1942
941
|
...s,
|
|
1943
942
|
id: e(r).attr("eId") ?? e(r).attr("GUID"),
|
|
@@ -1946,112 +945,112 @@ function en(e, t) {
|
|
|
1946
945
|
}));
|
|
1947
946
|
}), n;
|
|
1948
947
|
}
|
|
1949
|
-
function
|
|
948
|
+
function ft(e) {
|
|
1950
949
|
let t = e("body").first().get(0);
|
|
1951
|
-
return t === void 0 ? {} :
|
|
950
|
+
return t === void 0 ? {} : J(e, t);
|
|
1952
951
|
}
|
|
1953
|
-
function
|
|
952
|
+
function pt(e) {
|
|
1954
953
|
return e("FRBRExpression FRBRdate[name=\"#depot\"]").attr("date") ?? e("FRBRWork FRBRdate[name=\"#presentation\"]").attr("date");
|
|
1955
954
|
}
|
|
1956
|
-
function
|
|
955
|
+
function mt(e) {
|
|
1957
956
|
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(
|
|
1959
|
-
|
|
957
|
+
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) => {
|
|
958
|
+
A(n) && r.push(V(n) === "article" ? q(e, n, "article", "akn-article") : H(e, n));
|
|
1960
959
|
}), r.push("</section></div>"), r.join("\n");
|
|
1961
960
|
}
|
|
1962
|
-
function
|
|
1963
|
-
let
|
|
961
|
+
function ht(t) {
|
|
962
|
+
let n = e(t, { xml: {
|
|
1964
963
|
decodeEntities: !1,
|
|
1965
964
|
lowerCaseTags: !1,
|
|
1966
965
|
lowerCaseAttributeNames: !1,
|
|
1967
966
|
xmlMode: !0
|
|
1968
|
-
} }),
|
|
967
|
+
} }), r = pt(n), i = mt(n);
|
|
1969
968
|
return {
|
|
1970
969
|
sourceFormat: "akoma-ntoso",
|
|
1971
|
-
documentDate:
|
|
1972
|
-
html:
|
|
1973
|
-
linkedHtml:
|
|
970
|
+
documentDate: r,
|
|
971
|
+
html: i,
|
|
972
|
+
linkedHtml: i
|
|
1974
973
|
};
|
|
1975
974
|
}
|
|
1976
|
-
function
|
|
1977
|
-
return
|
|
975
|
+
function gt(t) {
|
|
976
|
+
return _t(e(t));
|
|
1978
977
|
}
|
|
1979
|
-
function
|
|
978
|
+
function _t(e) {
|
|
1980
979
|
let t = [];
|
|
1981
980
|
return e("article.akn-article").each((n, r) => {
|
|
1982
|
-
let i = e(r).children("p.TCNumArticle").first().get(0), a =
|
|
981
|
+
let i = e(r).children("p.TCNumArticle").first().get(0), a = E(i ? e(i).text() : ""), o = M(a) ?? { label: a || `Article ${n + 1}` }, s = e(r).attr("id") ?? `akn-article-${String(n + 1).padStart(3, "0")}`, c = [r], l = L(e, s, c), u = l.filter((e) => e.kind !== "noise").map((e) => e.text).join("\n");
|
|
1983
982
|
t.push({
|
|
1984
983
|
id: s,
|
|
1985
984
|
label: o.label,
|
|
1986
985
|
num: o.num,
|
|
1987
986
|
title: o.title,
|
|
1988
|
-
text:
|
|
1989
|
-
html:
|
|
987
|
+
text: me(e, c),
|
|
988
|
+
html: j(e, r),
|
|
1990
989
|
directiveText: u,
|
|
1991
990
|
blocks: l
|
|
1992
991
|
});
|
|
1993
992
|
}), t;
|
|
1994
993
|
}
|
|
1995
|
-
function
|
|
1996
|
-
let
|
|
994
|
+
function vt(t) {
|
|
995
|
+
let n = e(t);
|
|
1997
996
|
return {
|
|
1998
|
-
articles:
|
|
1999
|
-
htmlWithLinks:
|
|
997
|
+
articles: _t(n),
|
|
998
|
+
htmlWithLinks: n.html()
|
|
2000
999
|
};
|
|
2001
1000
|
}
|
|
2002
|
-
async function
|
|
2003
|
-
let
|
|
1001
|
+
async function yt(t, n) {
|
|
1002
|
+
let r = new u("parseAkomaNtosoBillRaw"), i = r.timeSync("cheerioLoadXml", () => e(t, { xml: {
|
|
2004
1003
|
decodeEntities: !1,
|
|
2005
1004
|
lowerCaseTags: !1,
|
|
2006
1005
|
lowerCaseAttributeNames: !1,
|
|
2007
1006
|
xmlMode: !0
|
|
2008
|
-
} })),
|
|
2009
|
-
...
|
|
2010
|
-
date:
|
|
2011
|
-
},
|
|
2012
|
-
return
|
|
2013
|
-
articleCount:
|
|
2014
|
-
blockCount:
|
|
2015
|
-
directiveCount:
|
|
2016
|
-
targetDirectiveCount:
|
|
2017
|
-
}),
|
|
1007
|
+
} })), a = n.date ?? pt(i), o = r.timeSync("renderAknHtml", () => mt(i), { inputSize: t.length }), s = n.linkedHtml ?? await r.time("addLinksToRenderedAknHtml", () => N(o, {
|
|
1008
|
+
...n,
|
|
1009
|
+
date: a
|
|
1010
|
+
}, a)), c = r.timeSync("extractRenderedAknArticles", () => gt(o)), l = r.timeSync("injectHiddenArticleSummary", () => R(s, c)), { articles: d, htmlWithLinks: f } = r.timeSync("extractLinkedAknArticlesAndTaggedHtml", () => vt(l)), p = d.length > 0 ? d : c, m = r.timeSync("extractAknTableOfContents", () => ft(i)), h = r.timeSync("buildParsedDocument", () => Ne("akoma-ntoso", o, d.length > 0 ? f : l, a, p, m));
|
|
1011
|
+
return r.log({
|
|
1012
|
+
articleCount: h.articles.length,
|
|
1013
|
+
blockCount: h.articles.reduce((e, t) => e + t.blocks.length, 0),
|
|
1014
|
+
directiveCount: h.directives.length,
|
|
1015
|
+
targetDirectiveCount: h.directives.filter((e) => e.targetIds !== void 0).length
|
|
1016
|
+
}), h;
|
|
2018
1017
|
}
|
|
2019
|
-
async function
|
|
2020
|
-
let n =
|
|
1018
|
+
async function bt(e, t) {
|
|
1019
|
+
let n = ht(e), r = t.date ?? n.documentDate;
|
|
2021
1020
|
return {
|
|
2022
1021
|
sourceFormat: "akoma-ntoso",
|
|
2023
1022
|
documentDate: r,
|
|
2024
1023
|
html: n.html,
|
|
2025
|
-
linkedHtml: await
|
|
1024
|
+
linkedHtml: await N(n.html, t, r)
|
|
2026
1025
|
};
|
|
2027
1026
|
}
|
|
2028
1027
|
//#endregion
|
|
2029
1028
|
//#region src/lib/server/assemblee_document_search.ts
|
|
2030
|
-
var
|
|
2031
|
-
function
|
|
1029
|
+
var xt = /\bexpos[ée]\s+des\s+motifs\b/giu, St = /\barticle\s+(?:premier|1er|\d+)/iu;
|
|
1030
|
+
function Y(e) {
|
|
2032
1031
|
return e.replace(/\u00a0/gu, " ").replace(/\s+/gu, " ").trim();
|
|
2033
1032
|
}
|
|
2034
|
-
function
|
|
2035
|
-
let
|
|
2036
|
-
for (let [e,
|
|
2037
|
-
let o = (
|
|
2038
|
-
if (l.length < 20 ||
|
|
2039
|
-
|
|
1033
|
+
function Ct(t) {
|
|
1034
|
+
let n = Y(e(t).text()), r = [...n.matchAll(xt)], i = /* @__PURE__ */ new Set(), a = [];
|
|
1035
|
+
for (let [e, t] of r.entries()) {
|
|
1036
|
+
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));
|
|
1037
|
+
if (l.length < 20 || i.has(l)) continue;
|
|
1038
|
+
i.add(l);
|
|
2040
1039
|
let u = `expose-des-motifs-${e + 1}`;
|
|
2041
|
-
|
|
1040
|
+
a.push({
|
|
2042
1041
|
anchor: u,
|
|
2043
1042
|
articleNumber: null,
|
|
2044
1043
|
content: l,
|
|
2045
1044
|
itemId: u,
|
|
2046
1045
|
itemKind: "expose_des_motifs",
|
|
2047
|
-
label:
|
|
1046
|
+
label: r.length === 1 ? "Exposé des motifs" : `Exposé des motifs ${e + 1}`,
|
|
2048
1047
|
title: null
|
|
2049
1048
|
});
|
|
2050
1049
|
}
|
|
2051
|
-
return
|
|
1050
|
+
return a;
|
|
2052
1051
|
}
|
|
2053
|
-
async function
|
|
2054
|
-
let i = await
|
|
1052
|
+
async function wt({ date: e, html: t, linkBaseUrl: n, linkType: r }) {
|
|
1053
|
+
let i = await Fe(t, {
|
|
2055
1054
|
date: e,
|
|
2056
1055
|
includeDirectiveAnalysis: !1,
|
|
2057
1056
|
linkBaseUrl: n,
|
|
@@ -2060,7 +1059,7 @@ async function hn({ date: e, html: t, linkBaseUrl: n, linkType: r }) {
|
|
|
2060
1059
|
});
|
|
2061
1060
|
return {
|
|
2062
1061
|
items: [...i.articles.map((e) => {
|
|
2063
|
-
let t =
|
|
1062
|
+
let t = Y(e.directiveText || e.text);
|
|
2064
1063
|
if (t) return {
|
|
2065
1064
|
anchor: e.id,
|
|
2066
1065
|
articleNumber: e.num ?? null,
|
|
@@ -2070,17 +1069,17 @@ async function hn({ date: e, html: t, linkBaseUrl: n, linkType: r }) {
|
|
|
2070
1069
|
label: e.label,
|
|
2071
1070
|
title: e.title ?? null
|
|
2072
1071
|
};
|
|
2073
|
-
}).filter((e) => e !== void 0), ...
|
|
1072
|
+
}).filter((e) => e !== void 0), ...Ct(t)],
|
|
2074
1073
|
tableOfContents: i.tableOfContents
|
|
2075
1074
|
};
|
|
2076
1075
|
}
|
|
2077
|
-
function
|
|
2078
|
-
return
|
|
1076
|
+
function Tt(e, t) {
|
|
1077
|
+
return h("sha256").update(JSON.stringify({
|
|
2079
1078
|
item: e,
|
|
2080
1079
|
metadata: t
|
|
2081
1080
|
})).digest("hex");
|
|
2082
1081
|
}
|
|
2083
|
-
function
|
|
1082
|
+
function Et(e) {
|
|
2084
1083
|
if (typeof e != "object" || !e) return;
|
|
2085
1084
|
let t = e.cycleDeVie?.chrono;
|
|
2086
1085
|
if (t !== void 0) for (let e of [
|
|
@@ -2095,11 +1094,11 @@ function _n(e) {
|
|
|
2095
1094
|
}
|
|
2096
1095
|
//#endregion
|
|
2097
1096
|
//#region src/lib/server/senat_amendment_search.ts
|
|
2098
|
-
function
|
|
2099
|
-
return
|
|
1097
|
+
function Dt(t) {
|
|
1098
|
+
return t?.trim() ? e(t).text().replace(/\u00a0/gu, " ").replace(/\s+/gu, " ").trim() : "";
|
|
2100
1099
|
}
|
|
2101
|
-
function
|
|
2102
|
-
let n =
|
|
1100
|
+
function Ot({ dispositifHtml: e, objetHtml: t }) {
|
|
1101
|
+
let n = Dt(e), r = Dt(t);
|
|
2103
1102
|
return [...n ? [{
|
|
2104
1103
|
content: n,
|
|
2105
1104
|
itemKind: "dispositif",
|
|
@@ -2110,20 +1109,20 @@ function yn({ dispositifHtml: e, objetHtml: t }) {
|
|
|
2110
1109
|
label: "Objet"
|
|
2111
1110
|
}] : []];
|
|
2112
1111
|
}
|
|
2113
|
-
function
|
|
2114
|
-
return
|
|
1112
|
+
function kt(e, t) {
|
|
1113
|
+
return h("sha256").update(JSON.stringify({
|
|
2115
1114
|
item: e,
|
|
2116
1115
|
metadata: t
|
|
2117
1116
|
})).digest("hex");
|
|
2118
1117
|
}
|
|
2119
1118
|
//#endregion
|
|
2120
1119
|
//#region src/lib/server/senat_document_search.ts
|
|
2121
|
-
var
|
|
1120
|
+
var At = /^article\s+(.+?)(?:\s*[::]\s*(.+))?$/iu;
|
|
2122
1121
|
function X(e) {
|
|
2123
1122
|
return e.replace(/\u00a0/gu, " ").replace(/\s+/gu, " ").trim();
|
|
2124
1123
|
}
|
|
2125
|
-
function
|
|
2126
|
-
let t = e.match(
|
|
1124
|
+
function jt(e) {
|
|
1125
|
+
let t = e.match(At);
|
|
2127
1126
|
if (!t) return {
|
|
2128
1127
|
articleNumber: null,
|
|
2129
1128
|
label: e,
|
|
@@ -2136,21 +1135,21 @@ function Sn(e) {
|
|
|
2136
1135
|
title: r
|
|
2137
1136
|
};
|
|
2138
1137
|
}
|
|
2139
|
-
function
|
|
2140
|
-
let
|
|
2141
|
-
return
|
|
1138
|
+
function Mt(t) {
|
|
1139
|
+
let n = e(t), r = [], i = X(n("section.akn-preamble").text());
|
|
1140
|
+
return i && r.push({
|
|
2142
1141
|
anchor: "senat-expose-des-motifs",
|
|
2143
1142
|
articleNumber: null,
|
|
2144
|
-
content:
|
|
1143
|
+
content: i,
|
|
2145
1144
|
itemId: "expose-des-motifs",
|
|
2146
1145
|
itemKind: "expose_des_motifs",
|
|
2147
1146
|
label: "Exposé des motifs",
|
|
2148
1147
|
title: null
|
|
2149
|
-
}),
|
|
2150
|
-
let i = t
|
|
1148
|
+
}), n("article.akn-article").each((e, t) => {
|
|
1149
|
+
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
1150
|
l.children("p.TCNumArticle").remove();
|
|
2152
1151
|
let u = X(l.text());
|
|
2153
|
-
u &&
|
|
1152
|
+
u && r.push({
|
|
2154
1153
|
anchor: i.attr("id") || null,
|
|
2155
1154
|
articleNumber: c.articleNumber,
|
|
2156
1155
|
content: u,
|
|
@@ -2159,42 +1158,42 @@ function Cn(e) {
|
|
|
2159
1158
|
label: c.label,
|
|
2160
1159
|
title: c.title
|
|
2161
1160
|
});
|
|
2162
|
-
}),
|
|
1161
|
+
}), r;
|
|
2163
1162
|
}
|
|
2164
|
-
function
|
|
2165
|
-
return
|
|
1163
|
+
function Nt(e, t) {
|
|
1164
|
+
return h("sha256").update(JSON.stringify({
|
|
2166
1165
|
item: e,
|
|
2167
1166
|
metadata: t
|
|
2168
1167
|
})).digest("hex");
|
|
2169
1168
|
}
|
|
2170
1169
|
//#endregion
|
|
2171
1170
|
//#region src/lib/server/senat_document_sources.ts
|
|
2172
|
-
var
|
|
2173
|
-
function
|
|
1171
|
+
var Pt = new Set(["senat.fr", "www.senat.fr"]), Z = "https://www.senat.fr";
|
|
1172
|
+
function Ft(e) {
|
|
2174
1173
|
return e?.trim() || void 0;
|
|
2175
1174
|
}
|
|
2176
|
-
function
|
|
1175
|
+
function It(e) {
|
|
2177
1176
|
try {
|
|
2178
|
-
let t = e.replace(/^\/+/, ""), n = /^https?:\/\//iu.test(e) ? new URL(e) : new URL(/^(?:akomantoso|leg)\//iu.test(t) ? `/${t}` : `/leg/${t}`,
|
|
2179
|
-
return
|
|
1177
|
+
let t = e.replace(/^\/+/, ""), n = /^https?:\/\//iu.test(e) ? new URL(e) : new URL(/^(?:akomantoso|leg)\//iu.test(t) ? `/${t}` : `/leg/${t}`, Z);
|
|
1178
|
+
return Pt.has(n.hostname.toLowerCase()) ? n : void 0;
|
|
2180
1179
|
} catch {
|
|
2181
1180
|
return;
|
|
2182
1181
|
}
|
|
2183
1182
|
}
|
|
2184
|
-
function
|
|
2185
|
-
let t =
|
|
1183
|
+
function Lt(e) {
|
|
1184
|
+
let t = Ft(e);
|
|
2186
1185
|
if (t === void 0) return {
|
|
2187
1186
|
publicUrl: null,
|
|
2188
1187
|
status: "no_url"
|
|
2189
1188
|
};
|
|
2190
|
-
let n =
|
|
1189
|
+
let n = It(t);
|
|
2191
1190
|
if (n === void 0) return {
|
|
2192
1191
|
publicUrl: t,
|
|
2193
1192
|
status: "unsupported_source"
|
|
2194
1193
|
};
|
|
2195
1194
|
let r = n.pathname;
|
|
2196
1195
|
if (/^\/akomantoso\/[^/]+\.akn\.xml$/iu.test(r)) return {
|
|
2197
|
-
akomaNtosoUrl: `${
|
|
1196
|
+
akomaNtosoUrl: `${Z}${r}`,
|
|
2198
1197
|
publicUrl: n.toString(),
|
|
2199
1198
|
status: "available"
|
|
2200
1199
|
};
|
|
@@ -2203,17 +1202,17 @@ function kn(e) {
|
|
|
2203
1202
|
publicUrl: n.toString(),
|
|
2204
1203
|
status: "unsupported_source"
|
|
2205
1204
|
} : {
|
|
2206
|
-
akomaNtosoUrl: `${
|
|
1205
|
+
akomaNtosoUrl: `${Z}/akomantoso/${i.replace(/\.html$/iu, ".akn.xml")}`,
|
|
2207
1206
|
publicUrl: n.toString(),
|
|
2208
1207
|
status: "available"
|
|
2209
1208
|
};
|
|
2210
1209
|
}
|
|
2211
|
-
function
|
|
1210
|
+
function Rt(e) {
|
|
2212
1211
|
return /^\s*(?:<\?xml\b[^>]*>\s*)?<akomaNtoso[\s/>]/iu.test(e);
|
|
2213
1212
|
}
|
|
2214
1213
|
//#endregion
|
|
2215
1214
|
//#region src/lib/alineas/alineas_numbers.ts
|
|
2216
|
-
var
|
|
1215
|
+
var zt = {
|
|
2217
1216
|
"0150a855548f15a2af52ea057be53f5d": 1,
|
|
2218
1217
|
"039826cf379b94afefe90b25c6045ca0": 1,
|
|
2219
1218
|
"03a7e564b84662f4d957c51018e26244": 1,
|
|
@@ -21187,7 +20186,7 @@ var jn = {
|
|
|
21187
20186
|
d16d29c923bd60c7b095b66c6058fe60: 1664,
|
|
21188
20187
|
"1c14c2adf5cfda3220b2057160e10e91": 1665,
|
|
21189
20188
|
e44c55ca1ac46ff46420686a466c9fc6: 1665
|
|
21190
|
-
},
|
|
20189
|
+
}, 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
20190
|
assnatetatagr: { bold: !0 },
|
|
21192
20191
|
assnatetatagrgr: { bold: !0 },
|
|
21193
20192
|
assnatetatatr: { bold: !0 },
|
|
@@ -21288,29 +20287,29 @@ var jn = {
|
|
|
21288
20287
|
assnatxl67: { align: "center" },
|
|
21289
20288
|
assnatenteteequilibre: { align: "center" }
|
|
21290
20289
|
};
|
|
21291
|
-
function
|
|
21292
|
-
let t = Object.keys(
|
|
21293
|
-
for (let n of t) if (e.includes(n)) return
|
|
20290
|
+
function Kt(e) {
|
|
20291
|
+
let t = Object.keys(Gt).sort((e, t) => t.length - e.length);
|
|
20292
|
+
for (let n of t) if (e.includes(n)) return Gt[n];
|
|
21294
20293
|
return null;
|
|
21295
20294
|
}
|
|
21296
|
-
function
|
|
21297
|
-
return
|
|
20295
|
+
function qt(e) {
|
|
20296
|
+
return m.createHash("md5").update(e).digest("hex");
|
|
21298
20297
|
}
|
|
21299
|
-
function
|
|
20298
|
+
function Jt(e) {
|
|
21300
20299
|
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
20300
|
}
|
|
21302
|
-
function
|
|
20301
|
+
function Yt(e) {
|
|
21303
20302
|
return e ? /font-style\s*:\s*italic/i.test(e) || /font-family\s*:\s*[^;]*\bItalic\b/i.test(e) : !1;
|
|
21304
20303
|
}
|
|
21305
|
-
function
|
|
20304
|
+
function Xt(e) {
|
|
21306
20305
|
if (!e || !/vertical-align\s*:\s*super/i.test(e)) return !1;
|
|
21307
20306
|
let t = e.match(/font-size\s*:\s*([\d.]+)pt/i);
|
|
21308
20307
|
return !(t && parseFloat(t[1]) < 8);
|
|
21309
20308
|
}
|
|
21310
|
-
function
|
|
20309
|
+
function Zt(e) {
|
|
21311
20310
|
return e ? /vertical-align\s*:\s*sub/i.test(e) : !1;
|
|
21312
20311
|
}
|
|
21313
|
-
function
|
|
20312
|
+
function Qt(e) {
|
|
21314
20313
|
if (!e) return;
|
|
21315
20314
|
let t = [
|
|
21316
20315
|
"width",
|
|
@@ -21345,15 +20344,15 @@ function Wn(e) {
|
|
|
21345
20344
|
}
|
|
21346
20345
|
return n.length > 0 ? n.join("; ") : void 0;
|
|
21347
20346
|
}
|
|
21348
|
-
function
|
|
20347
|
+
function $t(e, t) {
|
|
21349
20348
|
return !!(e && /text-align\s*:\s*center/i.test(e) || t && /center/i.test(t));
|
|
21350
20349
|
}
|
|
21351
|
-
function
|
|
20350
|
+
function en(e) {
|
|
21352
20351
|
if (!e) return null;
|
|
21353
20352
|
let t = e.match(/text-align\s*:\s*(left|center|right|justify)/i);
|
|
21354
20353
|
return t ? t[1].toLowerCase() : null;
|
|
21355
20354
|
}
|
|
21356
|
-
function
|
|
20355
|
+
function tn(e) {
|
|
21357
20356
|
if (!e) return null;
|
|
21358
20357
|
for (let [t, n] of [
|
|
21359
20358
|
[/assnat1Tome|assnatAN1PARTIE/i, 1],
|
|
@@ -21365,73 +20364,73 @@ function qn(e) {
|
|
|
21365
20364
|
]) if (t.test(e)) return n;
|
|
21366
20365
|
return null;
|
|
21367
20366
|
}
|
|
21368
|
-
function
|
|
21369
|
-
let { keepAlignment:
|
|
21370
|
-
|
|
21371
|
-
let n =
|
|
20367
|
+
function nn(t, n = {}) {
|
|
20368
|
+
let { keepAlignment: r = !0, removeEmptyParagraphs: i = !0, strictAlineas: a = !1 } = n, o = e(t, { xml: { decodeEntities: !1 } });
|
|
20369
|
+
o("style, script, meta, link").remove(), o(".assnatHeader, .assnatFooter, .assnatHeaderLeft, .assnatHeaderandFooter").remove(), o(".assnatFARSautApres, .assnatFARSautAvant, .assnatFARSautPageNiv0, .assnatFARSautPageNiv1, .assnatFARSautPageNiv1PG").remove(), o(".assnatFARTT08Bleu").each((e, t) => {
|
|
20370
|
+
let n = o(t).closest("table");
|
|
21372
20371
|
n.length > 0 && n.remove();
|
|
21373
|
-
}),
|
|
21374
|
-
let n =
|
|
20372
|
+
}), o("table").each((e, t) => {
|
|
20373
|
+
let n = o(t), r = n.find("> tbody > tr, > tr");
|
|
21375
20374
|
if (r.length !== 1) return;
|
|
21376
20375
|
let i = r.find("> td, > th");
|
|
21377
20376
|
if (i.length !== 1) return;
|
|
21378
|
-
let
|
|
21379
|
-
if (
|
|
21380
|
-
let e =
|
|
21381
|
-
(e.includes("border-left:") || e.includes("border-bottom:")) && n.replaceWith(
|
|
20377
|
+
let a = i.first();
|
|
20378
|
+
if (a.find("h1, h2, h3, h4, h5, h6").length > 0) {
|
|
20379
|
+
let e = a.attr("style") || "";
|
|
20380
|
+
(e.includes("border-left:") || e.includes("border-bottom:")) && n.replaceWith(a.html() || "");
|
|
21382
20381
|
}
|
|
21383
|
-
}),
|
|
21384
|
-
let n =
|
|
20382
|
+
}), o("br[style*=\"page-break\"]").remove(), o("span[style*=\"position:absolute\"][style*=\"z-index:-65537\"]").each((e, t) => {
|
|
20383
|
+
let n = o(t), r = n.find("img");
|
|
21385
20384
|
if (r.length > 0) {
|
|
21386
20385
|
let e = parseInt(r.attr("width") || "0", 10), t = parseInt(r.attr("height") || "0", 10);
|
|
21387
20386
|
(e >= 50 || t >= 50) && n.remove();
|
|
21388
20387
|
}
|
|
21389
|
-
}),
|
|
21390
|
-
let n =
|
|
20388
|
+
}), o("span[style*=\"position:absolute\"]").each((e, t) => {
|
|
20389
|
+
let n = o(t), r = n.attr("style") || "", i = n.find("img");
|
|
21391
20390
|
if (i.length !== 0 && !(n.parents("del").length > 0 || n.find("del img").length > 0) && !(i.parent("del").length > 0)) {
|
|
21392
20391
|
let e = i.attr();
|
|
21393
20392
|
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 ?
|
|
20393
|
+
let t = (e.src || "").match(/^data:image\/png;base64,(.+)$/), r = t ? qt(t[1]) : void 0, i = r ? ` data-image-hash="${r}"` : "";
|
|
21395
20394
|
n.replaceWith(`<span class="alinea"${i}></span>`);
|
|
21396
20395
|
return;
|
|
21397
20396
|
}
|
|
21398
20397
|
}
|
|
21399
|
-
}),
|
|
21400
|
-
let n =
|
|
20398
|
+
}), o("span[style*=\"position:absolute\"]").each((e, t) => {
|
|
20399
|
+
let n = o(t), r = n.attr("style") || "", i = n.find("img");
|
|
21401
20400
|
if (i.length > 0 && n.children().length === 1 && r.includes("height:0pt")) {
|
|
21402
20401
|
let e = parseInt(i.attr("width") || "0", 10), t = parseInt(i.attr("height") || "0", 10);
|
|
21403
20402
|
e < 100 || t < 100 ? n.remove() : n.replaceWith(i);
|
|
21404
20403
|
}
|
|
21405
|
-
}),
|
|
21406
|
-
let n =
|
|
20404
|
+
}), o("img").each((e, t) => {
|
|
20405
|
+
let n = o(t), r = parseInt(n.attr("width") || "0", 10), i = parseInt(n.attr("height") || "0", 10);
|
|
21407
20406
|
r < 100 || i < 100 ? n.remove() : n.removeAttr("style").removeAttr("class");
|
|
21408
|
-
}),
|
|
21409
|
-
let n =
|
|
20407
|
+
}), o("span[style*=\"height:0pt\"]:not(.alinea)").each((e, t) => {
|
|
20408
|
+
let n = o(t), r = n.text().trim();
|
|
21410
20409
|
(!r || r === "\xA0") && n.remove();
|
|
21411
|
-
}),
|
|
21412
|
-
function
|
|
21413
|
-
let t =
|
|
21414
|
-
return /bold/i.test(l) && (i = !0), /strongemphasis/i.test(l) ? i = !0 : /italic|emphasis/i.test(l) && (
|
|
20410
|
+
}), o("span[style*=\"display:block\"][style*=\"position:absolute\"]:not(.alinea)").remove(), o("del").remove();
|
|
20411
|
+
function s(e) {
|
|
20412
|
+
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") || "";
|
|
20413
|
+
return /bold/i.test(l) && (i = !0), /strongemphasis/i.test(l) ? i = !0 : /italic|emphasis/i.test(l) && (a = !0), {
|
|
21415
20414
|
bold: i,
|
|
21416
|
-
italic:
|
|
20415
|
+
italic: a,
|
|
21417
20416
|
sup: s,
|
|
21418
20417
|
sub: c
|
|
21419
20418
|
};
|
|
21420
20419
|
}
|
|
21421
|
-
function
|
|
20420
|
+
function c(e, t) {
|
|
21422
20421
|
let n = e;
|
|
21423
20422
|
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
20423
|
}
|
|
21425
|
-
let
|
|
21426
|
-
for (;
|
|
21427
|
-
|
|
21428
|
-
let n =
|
|
20424
|
+
let l = o("span").length;
|
|
20425
|
+
for (; l > 0;) {
|
|
20426
|
+
o("span").each((e, t) => {
|
|
20427
|
+
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
20428
|
if (u) {
|
|
21430
20429
|
let e = n.html() || "";
|
|
21431
20430
|
n.replaceWith(e);
|
|
21432
20431
|
} else if (l) {
|
|
21433
20432
|
let e = n.html() || "";
|
|
21434
|
-
n.replaceWith(
|
|
20433
|
+
n.replaceWith(c(e, a));
|
|
21435
20434
|
} else if (d) n.removeAttr("style");
|
|
21436
20435
|
else if (f) n.removeAttr("style").removeAttr("class");
|
|
21437
20436
|
else {
|
|
@@ -21439,76 +20438,76 @@ function Jn(e, t = {}) {
|
|
|
21439
20438
|
e.trim() === "" && e.length > 0 ? n.replaceWith(" ") : n.replaceWith(e);
|
|
21440
20439
|
}
|
|
21441
20440
|
});
|
|
21442
|
-
let e =
|
|
21443
|
-
if (e >=
|
|
21444
|
-
|
|
20441
|
+
let e = o("span").length;
|
|
20442
|
+
if (e >= l) break;
|
|
20443
|
+
l = e;
|
|
21445
20444
|
}
|
|
21446
|
-
for (
|
|
21447
|
-
let
|
|
20445
|
+
for (o("p").each((e, t) => {
|
|
20446
|
+
let n = o(t), i = n.attr("class") || "", a = n.attr("style"), s = tn(i);
|
|
21448
20447
|
if (i.includes("assnatFARCouvTitreD")) {
|
|
21449
|
-
let e =
|
|
21450
|
-
|
|
20448
|
+
let e = n.html() || "";
|
|
20449
|
+
n.replaceWith(`<p class="cover-subtitle">${e}</p>`);
|
|
21451
20450
|
return;
|
|
21452
20451
|
}
|
|
21453
20452
|
if (i.includes("assnatFARCouvTitre")) {
|
|
21454
|
-
let e =
|
|
21455
|
-
|
|
20453
|
+
let e = n.html() || "";
|
|
20454
|
+
n.replaceWith(`<p class="cover-title">${e}</p>`);
|
|
21456
20455
|
return;
|
|
21457
20456
|
}
|
|
21458
20457
|
if (i.includes("assnatFPFprem")) {
|
|
21459
|
-
let e =
|
|
21460
|
-
|
|
20458
|
+
let e = n.html() || "";
|
|
20459
|
+
n.replaceWith(`<p class="cover-info">${e}</p>`);
|
|
21461
20460
|
return;
|
|
21462
20461
|
}
|
|
21463
20462
|
if (i.includes("assnatFARCouvAnnee")) {
|
|
21464
|
-
let e =
|
|
21465
|
-
|
|
20463
|
+
let e = n.html() || "";
|
|
20464
|
+
n.replaceWith(`<p class="cover-year">${e}</p>`);
|
|
21466
20465
|
return;
|
|
21467
20466
|
}
|
|
21468
20467
|
if (i.includes("assnatFPFexpogentitre1")) {
|
|
21469
|
-
let e =
|
|
21470
|
-
|
|
20468
|
+
let e = n.html() || "";
|
|
20469
|
+
n.replaceWith(`<p class="expose-motifs-titre">${e}</p>`);
|
|
21471
20470
|
return;
|
|
21472
20471
|
}
|
|
21473
20472
|
if (i.includes("assnatFPFexpogentexte")) {
|
|
21474
|
-
|
|
20473
|
+
n.removeAttr("style").attr("class", "expose-motifs-text");
|
|
21475
20474
|
return;
|
|
21476
20475
|
}
|
|
21477
|
-
let c =
|
|
20476
|
+
let c = n.text().trim().startsWith("«");
|
|
21478
20477
|
if (s && !c) {
|
|
21479
|
-
let e =
|
|
21480
|
-
|
|
20478
|
+
let e = o(`<h${s}>${n.html() || ""}</h${s}>`);
|
|
20479
|
+
r && $t(a, i) && e.attr("align", "center"), n.replaceWith(e);
|
|
21481
20480
|
} else {
|
|
21482
|
-
let e =
|
|
21483
|
-
if (
|
|
21484
|
-
let n =
|
|
20481
|
+
let e = Kt(i), t;
|
|
20482
|
+
if (r) {
|
|
20483
|
+
let n = en(a);
|
|
21485
20484
|
n && n !== "justify" && n !== "left" ? t = n : e?.align && (t = e.align);
|
|
21486
20485
|
}
|
|
21487
|
-
if (
|
|
21488
|
-
let e =
|
|
21489
|
-
e.trim().startsWith("<strong>") ||
|
|
20486
|
+
if (n.removeAttr("style").removeAttr("class"), t && n.attr("align", t), e?.bold) {
|
|
20487
|
+
let e = n.html() || "";
|
|
20488
|
+
e.trim().startsWith("<strong>") || n.html(`<strong>${e}</strong>`);
|
|
21490
20489
|
}
|
|
21491
20490
|
}
|
|
21492
|
-
}),
|
|
21493
|
-
let
|
|
21494
|
-
|
|
21495
|
-
}),
|
|
21496
|
-
let n =
|
|
21497
|
-
for (let e of Object.keys(
|
|
20491
|
+
}), o("h1, h2, h3, h4, h5, h6").each((e, t) => {
|
|
20492
|
+
let n = o(t), i = n.attr("style"), a = n.attr("class");
|
|
20493
|
+
r && $t(i, a) ? (n.removeAttr("style").removeAttr("class"), n.attr("align", "center")) : n.removeAttr("style").removeAttr("class");
|
|
20494
|
+
}), o("a").each((e, t) => {
|
|
20495
|
+
let n = o(t), r = n.attr("href"), i = n.attr("id"), a = { ...t.attribs || {} };
|
|
20496
|
+
for (let e of Object.keys(a)) e !== "href" && e !== "id" && n.removeAttr(e);
|
|
21498
20497
|
if (!r && !i) n.replaceWith(n.html() || "");
|
|
21499
20498
|
else if (!r && i) {
|
|
21500
20499
|
let e = n.html() || "";
|
|
21501
20500
|
n.replaceWith(`<span id="${i}">${e}</span>`);
|
|
21502
20501
|
}
|
|
21503
|
-
});
|
|
21504
|
-
let n =
|
|
20502
|
+
}); o("div").length > 0;) o("div").each((e, t) => {
|
|
20503
|
+
let n = o(t), r = n.html() || "";
|
|
21505
20504
|
n.replaceWith(r);
|
|
21506
20505
|
});
|
|
21507
|
-
|
|
21508
|
-
let n =
|
|
20506
|
+
o(".expose-motifs-titre").each((e, t) => {
|
|
20507
|
+
let n = o(t), r = [], i = n.next();
|
|
21509
20508
|
for (; i.length > 0;) if (i.is("table") && i.find(".expose-motifs-text").length > 0) {
|
|
21510
20509
|
i.find(".expose-motifs-text").each((e, t) => {
|
|
21511
|
-
r.push(
|
|
20510
|
+
r.push(o(t).clone());
|
|
21512
20511
|
});
|
|
21513
20512
|
let e = i;
|
|
21514
20513
|
i = i.next(), e.remove();
|
|
@@ -21522,43 +20521,43 @@ function Jn(e, t = {}) {
|
|
|
21522
20521
|
i = i.next(), e.remove();
|
|
21523
20522
|
} else break;
|
|
21524
20523
|
if (r.length > 0) {
|
|
21525
|
-
let e =
|
|
20524
|
+
let e = o("<div class=\"expose-motifs\"></div>");
|
|
21526
20525
|
r.forEach((t) => {
|
|
21527
20526
|
t.removeClass("expose-motifs-text"), e.append(t);
|
|
21528
20527
|
}), n.after(e);
|
|
21529
20528
|
}
|
|
21530
|
-
}),
|
|
21531
|
-
|
|
21532
|
-
}),
|
|
21533
|
-
let n =
|
|
20529
|
+
}), o("br").each((e, t) => {
|
|
20530
|
+
o(t).removeAttr("style").removeAttr("class");
|
|
20531
|
+
}), o("table, tr, td, th, thead, tbody, tfoot").each((e, t) => {
|
|
20532
|
+
let n = o(t), r = Qt(n.attr("style"));
|
|
21534
20533
|
n.removeAttr("style").removeAttr("class"), r && n.attr("style", r);
|
|
21535
|
-
}),
|
|
21536
|
-
let n =
|
|
20534
|
+
}), o("td, th").each((e, t) => {
|
|
20535
|
+
let n = o(t), r = n.children();
|
|
21537
20536
|
if (r.length === 1 && r.first().is("p")) {
|
|
21538
|
-
let e = r.first(), t = n.html() || "", i =
|
|
20537
|
+
let e = r.first(), t = n.html() || "", i = o.html(e);
|
|
21539
20538
|
if (t.trim() === i.trim()) {
|
|
21540
20539
|
let t = e.attr("align"), r = e.attr("id");
|
|
21541
20540
|
n.html(e.html() || ""), t && !n.attr("align") && n.attr("align", t), r && !n.attr("id") && n.attr("id", r);
|
|
21542
20541
|
}
|
|
21543
20542
|
}
|
|
21544
|
-
}),
|
|
21545
|
-
let n =
|
|
20543
|
+
}), o("ol, ul").each((e, t) => {
|
|
20544
|
+
let n = o(t), r = n.attr("start");
|
|
21546
20545
|
if (n.removeAttr("style").removeAttr("class"), r) {
|
|
21547
20546
|
let e = parseInt(r, 10);
|
|
21548
20547
|
!isNaN(e) && e > 1 && n.attr("style", `counter-reset: list-counter ${e - 1}`), n.attr("start", r);
|
|
21549
20548
|
}
|
|
21550
|
-
}),
|
|
21551
|
-
let n =
|
|
20549
|
+
}), o("li").each((e, t) => {
|
|
20550
|
+
let n = o(t), r = en(n.attr("style"));
|
|
21552
20551
|
n.removeAttr("style").removeAttr("class"), r === "center" && n.attr("style", "text-align: center");
|
|
21553
|
-
let i = n.html() || "",
|
|
21554
|
-
|
|
21555
|
-
}),
|
|
21556
|
-
let
|
|
21557
|
-
|
|
21558
|
-
let
|
|
21559
|
-
return
|
|
20552
|
+
let i = n.html() || "", a = i.replace(/^(\s| | |\u00a0)+/, "");
|
|
20553
|
+
a !== i && n.html(a);
|
|
20554
|
+
}), rn(o), an(o, a);
|
|
20555
|
+
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 = "";
|
|
20556
|
+
h && (g += Wt), p && (g += Vt), m && (g += Ht), d && (g += Bt), f && (g += Ut);
|
|
20557
|
+
let _ = g ? `<style>${g}</style>\n${u}` : u;
|
|
20558
|
+
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(/ /g, "\xA0"), i && (_ = _.replace(/<p[^>]*>\s*( | | |\u00a0|\s)*\s*<\/p>/gi, "").replace(/<p[^>]*>\s*<(strong|em|b|i)>\s*( | | |\u00a0|\s)*\s*<\/\1>\s*<\/p>/gi, "")), _ = _.replace(/<span[^>]*>\s*<\/span>/gi, ""), _ = _.replace(/ class=""/g, ""), _ = on(_), _ = _.replace(/<(strong|em|b|i|sup|sub)>\s*( | | |\u00a0|\s)*\s*<\/\1>/gi, "").replace(/<(strong|em|b|i)>( | | |\u00a0)+<\/\1>/gi, " ").replace(/<br\s*\/?>/gi, "<br/>").replace(/ +/g, " ").trim(), _;
|
|
21560
20559
|
}
|
|
21561
|
-
function
|
|
20560
|
+
function rn(e) {
|
|
21562
20561
|
e("span[id]").each((t, n) => {
|
|
21563
20562
|
let r = e(n), i = r.attr("id"), a = n.attribs || {}, o = Object.keys(a);
|
|
21564
20563
|
if (o.length !== 1 || o[0] !== "id") return;
|
|
@@ -21581,13 +20580,13 @@ function Yn(e) {
|
|
|
21581
20580
|
l.trim() === u.trim() && (s.attr("id", i), r.replaceWith(r.html() || ""));
|
|
21582
20581
|
});
|
|
21583
20582
|
}
|
|
21584
|
-
function
|
|
20583
|
+
function an(e, t = !1) {
|
|
21585
20584
|
let n = e("body");
|
|
21586
20585
|
if (n.length === 0) return;
|
|
21587
20586
|
let r = n.find("span.alinea[data-image-hash]"), i = -1;
|
|
21588
20587
|
r.each((n, r) => {
|
|
21589
20588
|
let a = e(r), o = a.attr("data-image-hash"), s;
|
|
21590
|
-
if (o &&
|
|
20589
|
+
if (o && zt[o] !== void 0 && (s = zt[o]), s === void 0) {
|
|
21591
20590
|
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
20591
|
a.remove();
|
|
21593
20592
|
return;
|
|
@@ -21599,11 +20598,11 @@ function Xn(e, t = !1) {
|
|
|
21599
20598
|
i = s, a.attr("data-alinea", String(s)), a.text(String(s)), a.removeAttr("data-image-hash");
|
|
21600
20599
|
});
|
|
21601
20600
|
}
|
|
21602
|
-
function
|
|
20601
|
+
function on(e) {
|
|
21603
20602
|
let t = e;
|
|
21604
20603
|
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
20604
|
}
|
|
21606
|
-
function
|
|
20605
|
+
function sn(e, t = {}) {
|
|
21607
20606
|
return `<!DOCTYPE html>
|
|
21608
20607
|
<html lang="fr">
|
|
21609
20608
|
<head>
|
|
@@ -21611,33 +20610,33 @@ function Qn(e, t = {}) {
|
|
|
21611
20610
|
<title>Document simplifié</title>
|
|
21612
20611
|
</head>
|
|
21613
20612
|
<body>
|
|
21614
|
-
${
|
|
20613
|
+
${nn(e, t)}
|
|
21615
20614
|
</body>
|
|
21616
20615
|
</html>`;
|
|
21617
20616
|
}
|
|
21618
20617
|
//#endregion
|
|
21619
20618
|
//#region src/lib/server/text_parsers/transformers.ts
|
|
21620
|
-
function
|
|
20619
|
+
function Q(e, t) {
|
|
21621
20620
|
let n = "transformation_", r = {};
|
|
21622
|
-
for (let e of
|
|
20621
|
+
for (let e of g.readdirSync(t).toSorted()) if (e.startsWith(n) && e.endsWith(".json")) {
|
|
21623
20622
|
let i = e.slice(15, -5), a = i.split(".").map((e) => parseInt(e) - 1), o = r;
|
|
21624
20623
|
for (let e of a.slice(1)) {
|
|
21625
20624
|
let t = o.transformations ??= [];
|
|
21626
20625
|
for (; e >= t.length;) t.push({});
|
|
21627
20626
|
o = t[e];
|
|
21628
20627
|
}
|
|
21629
|
-
o.output =
|
|
21630
|
-
let { sourceMap: s, title: c } =
|
|
20628
|
+
o.output = g.readFileSync(_.join(t, `${n}${i}.html`), { encoding: "utf-8" });
|
|
20629
|
+
let { sourceMap: s, title: c } = g.readJsonSync(_.join(t, e), { encoding: "utf-8" });
|
|
21631
20630
|
o.sourceMap = s ?? [], o.title = c;
|
|
21632
20631
|
}
|
|
21633
|
-
return
|
|
20632
|
+
return cn(r, e), r;
|
|
21634
20633
|
}
|
|
21635
|
-
function
|
|
21636
|
-
if (e.input = t, e.transformations !== void 0) for (let n of e.transformations)
|
|
20634
|
+
function cn(e, t) {
|
|
20635
|
+
if (e.input = t, e.transformations !== void 0) for (let n of e.transformations) cn(n, t), t = n.output;
|
|
21637
20636
|
return t;
|
|
21638
20637
|
}
|
|
21639
|
-
function
|
|
21640
|
-
if (
|
|
20638
|
+
function $(e, t, n = "1") {
|
|
20639
|
+
if (g.ensureDirSync(t), e.transformations === void 0) g.writeJsonSync(_.join(t, `transformation_${n}.json`), {
|
|
21641
20640
|
sourceMap: e.sourceMap,
|
|
21642
20641
|
title: e.title
|
|
21643
20642
|
}, {
|
|
@@ -21645,690 +20644,72 @@ function Q(e, t, n = "1") {
|
|
|
21645
20644
|
spaces: 2
|
|
21646
20645
|
});
|
|
21647
20646
|
else {
|
|
21648
|
-
|
|
20647
|
+
g.writeJsonSync(_.join(t, `transformation_${n}.json`), { title: e.title }, {
|
|
21649
20648
|
encoding: "utf-8",
|
|
21650
20649
|
spaces: 2
|
|
21651
20650
|
});
|
|
21652
|
-
for (let [r, i] of e.transformations.entries())
|
|
20651
|
+
for (let [r, i] of e.transformations.entries()) $(i, t, `${n}.${r + 1}`);
|
|
21653
20652
|
}
|
|
21654
|
-
e.output !== void 0 &&
|
|
20653
|
+
e.output !== void 0 && g.writeFileSync(_.join(t, `transformation_${n}.html`), e.output, { encoding: "utf-8" });
|
|
21655
20654
|
}
|
|
21656
20655
|
//#endregion
|
|
21657
20656
|
//#region src/lib/server/linkers/html.ts
|
|
21658
|
-
async function
|
|
21659
|
-
let
|
|
21660
|
-
|
|
21661
|
-
let
|
|
21662
|
-
|
|
21663
|
-
let
|
|
21664
|
-
|
|
21665
|
-
|
|
21666
|
-
|
|
21667
|
-
|
|
21668
|
-
|
|
21669
|
-
|
|
21670
|
-
|
|
21671
|
-
|
|
21672
|
-
|
|
21673
|
-
|
|
21674
|
-
|
|
21675
|
-
|
|
21676
|
-
|
|
21677
|
-
|
|
21678
|
-
|
|
21679
|
-
|
|
21680
|
-
|
|
20657
|
+
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 }) {
|
|
20658
|
+
let x = t ?? (e === void 0 ? void 0 : new o(e));
|
|
20659
|
+
if (x === void 0) throw Error("A Canutes database or legal resolver is required");
|
|
20660
|
+
let S = await g.readFile(i, { encoding: "utf-8" }), C;
|
|
20661
|
+
c === void 0 ? (C = s({ removeAWithHref: !0 })(S), l !== void 0 && $(C, l)) : C = Q(S, c);
|
|
20662
|
+
let w = [];
|
|
20663
|
+
u !== void 0 && w.push("links"), d !== void 0 && w.push("links_or_references"), p !== void 0 && w.push("references");
|
|
20664
|
+
let { outputByType: T, referredLegifranceTextCountByCid: E } = await a({
|
|
20665
|
+
legiResolver: x,
|
|
20666
|
+
date: n,
|
|
20667
|
+
defaultTextId: r,
|
|
20668
|
+
htmlTransformation: C,
|
|
20669
|
+
inputHtml: S,
|
|
20670
|
+
linkBaseUrl: m,
|
|
20671
|
+
linkType: h,
|
|
20672
|
+
logIgnoredReferencesTypes: _,
|
|
20673
|
+
logPartialReferences: v,
|
|
20674
|
+
logReferences: y,
|
|
20675
|
+
outputTypes: w,
|
|
20676
|
+
referredLegifranceTextsInfos: b !== void 0
|
|
20677
|
+
}), D = {};
|
|
20678
|
+
u !== void 0 && (D.links = u), d !== void 0 && (D.links_or_references = d), p !== void 0 && (D.references = p);
|
|
20679
|
+
for (let [e, t] of Object.entries(T)) {
|
|
20680
|
+
let n = D[e];
|
|
20681
|
+
n !== void 0 && await g.writeFile(n, t.html, { encoding: "utf-8" });
|
|
21681
20682
|
}
|
|
21682
|
-
|
|
20683
|
+
T.links !== void 0 && f !== void 0 && $(s()(T.links.html), f), b !== void 0 && await g.writeJson(b, E, {
|
|
21683
20684
|
encoding: "utf-8",
|
|
21684
20685
|
spaces: 2
|
|
21685
20686
|
});
|
|
21686
20687
|
}
|
|
21687
20688
|
//#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
20689
|
//#region src/lib/server/tables_of_contents.ts
|
|
21697
|
-
async function
|
|
21698
|
-
let a =
|
|
21699
|
-
for await (let e of
|
|
20690
|
+
async function un(e, n, r, i) {
|
|
20691
|
+
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" });
|
|
20692
|
+
for await (let e of t({
|
|
21700
20693
|
context: s,
|
|
21701
20694
|
tableOfContents: c,
|
|
21702
20695
|
transformation: a
|
|
21703
20696
|
}));
|
|
21704
|
-
await
|
|
20697
|
+
await g.writeJson(i, c, {
|
|
21705
20698
|
encoding: "utf-8",
|
|
21706
20699
|
spaces: 2
|
|
21707
20700
|
});
|
|
21708
20701
|
}
|
|
21709
|
-
async function
|
|
21710
|
-
let
|
|
21711
|
-
await
|
|
20702
|
+
async function dn(e, t, n) {
|
|
20703
|
+
let i = Q(await g.readFile(e, { encoding: "utf-8" }), t).output, a = r(i);
|
|
20704
|
+
await g.writeJson(n, a, {
|
|
21712
20705
|
encoding: "utf-8",
|
|
21713
20706
|
spaces: 2
|
|
21714
20707
|
});
|
|
21715
20708
|
}
|
|
21716
20709
|
//#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
20710
|
//#region src/lib/server/legi/resolvers.ts
|
|
22321
|
-
function
|
|
22322
|
-
return e
|
|
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
|
-
}
|
|
20711
|
+
function fn({ canutesDb: e }) {
|
|
20712
|
+
return new o(e);
|
|
22332
20713
|
}
|
|
22333
20714
|
//#endregion
|
|
22334
|
-
export {
|
|
20715
|
+
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 };
|