@tricoteuses/assemblee 3.3.0 → 3.3.3

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.
@@ -1,8 +1,42 @@
1
1
  import { ActeurClean } from '../schemas/clean/acteurs_et_organes';
2
2
  import { RapporteurRaw } from '../schemas/raw/dossiers_legislatifs';
3
+ type CollaborateurMutable = {
4
+ collaborateur: Array<Record<string, unknown> | null> | Record<string, unknown> | null;
5
+ };
6
+ type MandatMutable = {
7
+ uid: string;
8
+ "@xsi:type"?: string;
9
+ xsiType?: string;
10
+ infosQualite: Record<string, unknown>;
11
+ organes?: {
12
+ organeRef: string | string[];
13
+ };
14
+ organesRefs?: string[];
15
+ suppleants?: {
16
+ suppleant: Record<string, unknown>;
17
+ };
18
+ suppleant?: Record<string, unknown>;
19
+ election?: {
20
+ lieu: Record<string, unknown>;
21
+ [key: string]: unknown;
22
+ };
23
+ mandature?: Record<string, unknown>;
24
+ chambre?: undefined;
25
+ collaborateurs?: CollaborateurMutable[] | CollaborateurMutable | Record<string, unknown>[] | null[] | null;
26
+ InfosHorsSIAN?: {
27
+ HATVP_URI?: undefined;
28
+ [key: string]: unknown;
29
+ };
30
+ [key: string]: unknown;
31
+ };
3
32
  type RapporteurMutable = RapporteurRaw & {
4
33
  etudePlfRef?: string;
5
34
  };
6
35
  export declare function cleanActeur(data: unknown): ActeurClean;
36
+ /**
37
+ * Reconciles duplicated GOUVERNEMENT mandates left open by the Assemblée open
38
+ * data
39
+ */
40
+ export declare function reconcileGouvernementMandatDateFins(mandats: MandatMutable[]): void;
7
41
  export declare function cleanRapporteur(rapporteur: RapporteurMutable): void;
8
42
  export {};
@@ -0,0 +1 @@
1
+ export {};
package/lib/cleaners.js CHANGED
@@ -42,9 +42,9 @@ function c(e) {
42
42
  ].includes(e ?? ""), `Unexpected "@xsi:type": ${e}`), t.xsiType = e, delete t["@xsi:type"], s.notStrictEqual(t.uid, void 0), s.notStrictEqual(t.type, void 0), s.notStrictEqual(t.typeLibelle, void 0), e === "AdressePostale_Type" && s.strictEqual(t.adresseDeRattachement, void 0);
43
43
  }
44
44
  }
45
- let l = t.mandats;
46
- if (l !== void 0) {
47
- let e = [], n = Array.isArray(l) ? l : l.mandat;
45
+ let u = t.mandats;
46
+ if (u !== void 0) {
47
+ let e = [], n = Array.isArray(u) ? u : u.mandat;
48
48
  Array.isArray(n) ? e = t.mandats = n : typeof n == "object" && (e = t.mandats = [n]);
49
49
  for (let n of e) {
50
50
  r(n);
@@ -89,11 +89,11 @@ function c(e) {
89
89
  let f = n.InfosHorsSIAN;
90
90
  f !== void 0 && (r(f), s.strictEqual(f.HATVP_URI, void 0), s.strictEqual(Object.keys(f).length, 0), delete n.InfosHorsSIAN);
91
91
  }
92
- e.sort((e, t) => e.uid.length === t.uid.length ? e.uid.localeCompare(t.uid) : e.uid.length - t.uid.length);
92
+ e.sort((e, t) => e.uid.length === t.uid.length ? e.uid.localeCompare(t.uid) : e.uid.length - t.uid.length), l(e);
93
93
  }
94
- let u = t.deports;
95
- if (u !== void 0) {
96
- let e = [], n = Array.isArray(u) ? u : u.deport;
94
+ let d = t.deports;
95
+ if (d !== void 0) {
96
+ let e = [], n = Array.isArray(d) ? d : d.deport;
97
97
  Array.isArray(n) ? e = t.deports = n : typeof n == "object" && (e = t.deports = [n]);
98
98
  for (let t of e) {
99
99
  r(t);
@@ -105,15 +105,32 @@ function c(e) {
105
105
  return t;
106
106
  }
107
107
  function l(e) {
108
+ let t = /* @__PURE__ */ new Map();
109
+ for (let n of e) {
110
+ if (n.typeOrgane !== "GOUVERNEMENT") continue;
111
+ let e = n.organesRefs?.[0];
112
+ if (!e) continue;
113
+ let r = `${e}\u0000${typeof n.dateDebut == "string" ? n.dateDebut : ""}`, i = t.get(r);
114
+ i ? i.push(n) : t.set(r, [n]);
115
+ }
116
+ for (let e of t.values()) {
117
+ if (e.length < 2) continue;
118
+ let t = e.map((e) => e.dateFin).filter((e) => typeof e == "string" && e.length > 0);
119
+ if (t.length === 0) continue;
120
+ let n = t.reduce((e, t) => t > e ? t : e);
121
+ for (let t of e) (t.dateFin == null || t.dateFin === "") && (t.dateFin = n);
122
+ }
123
+ }
124
+ function u(e) {
108
125
  let t = e.etudePLFRef;
109
126
  e.etudePLFRef !== void 0 && (delete e.etudePLFRef, e.etudePlfRef = t);
110
127
  }
111
128
  //#endregion
112
129
  //#region src/cleaners/documents.ts
113
- function u(e) {
130
+ function d(e) {
114
131
  return Array.isArray(e) ? e : [e];
115
132
  }
116
- function d(e) {
133
+ function f(e) {
117
134
  let t = e;
118
135
  if (r(t), t.metadatas?.dateSuppression !== void 0) {
119
136
  for (let e of Object.getOwnPropertyNames(t)) delete t[e];
@@ -129,27 +146,27 @@ function d(e) {
129
146
  }
130
147
  let o = t.divisions;
131
148
  if (o !== void 0) {
132
- let e = Array.isArray(o) ? o : u(o.division);
149
+ let e = Array.isArray(o) ? o : d(o.division);
133
150
  t.divisions = e;
134
- for (let t of e) d(t);
151
+ for (let t of e) f(t);
135
152
  }
136
153
  s.strictEqual(t.redacteur, void 0);
137
154
  let c = t.classification;
138
155
  s(c), r(c);
139
156
  let l = t.auteurs;
140
157
  if (l !== void 0) {
141
- let e = Array.isArray(l) ? l : u(l.auteur);
158
+ let e = Array.isArray(l) ? l : d(l.auteur);
142
159
  t.auteurs = e;
143
160
  for (let t of e) {
144
161
  let e = t.organe;
145
162
  e !== void 0 && (t.organeRef = e.organeRef, delete t.organe);
146
163
  }
147
164
  }
148
- let f = t.notice;
149
- i(f, "adoptionConforme");
165
+ let u = t.notice;
166
+ i(u, "adoptionConforme");
150
167
  let p = t.coSignataires;
151
168
  if (p !== void 0) {
152
- let e = Array.isArray(p) ? p : u(p.coSignataire);
169
+ let e = Array.isArray(p) ? p : d(p.coSignataire);
153
170
  t.coSignataires = e;
154
171
  for (let t of e) {
155
172
  r(t), i(t, "edite");
@@ -169,7 +186,7 @@ function d(e) {
169
186
  r(e), i(e, "amendable");
170
187
  let t = m.amendementsCommission;
171
188
  if (t !== void 0) {
172
- let e = Array.isArray(t) ? t : u(t.commission);
189
+ let e = Array.isArray(t) ? t : d(t.commission);
173
190
  m.amendementsCommission = e;
174
191
  for (let t of e) r(t), i(t, "amendable"), s.strictEqual(t.dateLimiteDepot, void 0);
175
192
  }
@@ -186,28 +203,28 @@ function d(e) {
186
203
  }
187
204
  i(t, "rapportPublie");
188
205
  let g = t.organesReferents;
189
- return g !== void 0 && (t.organesReferents = Array.isArray(g) ? g : u(g.organeRef)), t;
206
+ return g !== void 0 && (t.organesReferents = Array.isArray(g) ? g : d(g.organeRef)), t;
190
207
  }
191
208
  //#endregion
192
209
  //#region src/cleaners/actes_legislatifs.ts
193
- function f(e) {
210
+ function p(e) {
194
211
  return Array.isArray(e) ? e : [e];
195
212
  }
196
- function p(e) {
213
+ function m(e) {
197
214
  let t = e;
198
215
  r(t);
199
216
  let n = t["@xsi:type"];
200
217
  n !== void 0 && (t.xsiType = n, delete t["@xsi:type"]);
201
218
  let i = t.auteurs;
202
- i !== void 0 && (t.auteursRefs = f(i.acteurRef), delete t.auteurs);
219
+ i !== void 0 && (t.auteursRefs = p(i.acteurRef), delete t.auteurs);
203
220
  let a = t.casSaisine;
204
- a !== void 0 && h(a);
221
+ a !== void 0 && g(a);
205
222
  let o = t.contributionInternaute;
206
223
  o !== void 0 && r(o), s.strictEqual(t.dateRetrait, void 0);
207
224
  let c = t.decision;
208
- c !== void 0 && h(c);
209
- let u = t.infoJO;
210
- u !== void 0 && (g(u), t.infoJo = u, delete t.infoJO);
225
+ c !== void 0 && g(c);
226
+ let l = t.infoJO;
227
+ l !== void 0 && (_(l), t.infoJo = l, delete t.infoJO);
211
228
  let d = t.infoJOCE;
212
229
  if (d !== void 0) {
213
230
  t.infoJoce = d, delete t.infoJOCE;
@@ -216,36 +233,36 @@ function p(e) {
216
233
  let n = d.dateJOCE;
217
234
  n !== void 0 && (d.dateJoce = n, delete d.dateJOCE);
218
235
  }
219
- let _ = t.infoJORect;
220
- if (_ !== void 0) {
221
- let e = f(_);
236
+ let f = t.infoJORect;
237
+ if (f !== void 0) {
238
+ let e = p(f);
222
239
  t.infoJoRect = e, delete t.infoJORect;
223
- for (let t of e) g(t);
240
+ for (let t of e) _(t);
224
241
  }
225
- m(t);
242
+ h(t);
226
243
  let v = t.initiateurs;
227
- v !== void 0 && (s.strictEqual(t.initiateur, void 0), !Array.isArray(v) && v.acteurRef === void 0 ? (s.notStrictEqual(v.organeRef, void 0), t.initiateur = { organeRef: v.organeRef }) : t.initiateur = { acteurs: f(v) }, delete t.initiateurs), s.strictEqual(t.odSeancejRef, void 0);
244
+ v !== void 0 && (s.strictEqual(t.initiateur, void 0), !Array.isArray(v) && v.acteurRef === void 0 ? (s.notStrictEqual(v.organeRef, void 0), t.initiateur = { organeRef: v.organeRef }) : t.initiateur = { acteurs: p(v) }, delete t.initiateurs), s.strictEqual(t.odSeancejRef, void 0);
228
245
  let y = t.provenance;
229
246
  y !== void 0 && (delete t.provenance, t.provenanceRef = y);
230
247
  let b = t.rapporteurs;
231
248
  if (b !== void 0 && !Array.isArray(b)) {
232
- let e = f(b.rapporteur);
249
+ let e = p(b.rapporteur);
233
250
  t.rapporteurs = e;
234
- for (let t of e) l(t);
251
+ for (let t of e) u(t);
235
252
  }
236
253
  let x = t.referenceNOR;
237
254
  x !== void 0 && (t.referenceNor = x, delete t.referenceNOR), s.strictEqual(t.reunion, void 0);
238
255
  let S = t.statutAdoption;
239
- S !== void 0 && h(S);
256
+ S !== void 0 && g(S);
240
257
  let C = t.statutConclusion;
241
- C !== void 0 && (h(C), C.famCode === "TSORTFnull" && delete t.statutConclusion);
258
+ C !== void 0 && (g(C), C.famCode === "TSORTFnull" && delete t.statutConclusion);
242
259
  let w = t.texteAdopte;
243
260
  w !== void 0 && (delete t.texteAdopte, t.texteAdopteRef = w);
244
261
  let T = t.texteAssocie;
245
262
  T !== void 0 && (delete t.texteAssocie, t.texteAssocieRef = T);
246
263
  let E = t.textesAssocies;
247
264
  if (E !== void 0 && !Array.isArray(E)) {
248
- let e = f(E.texteAssocie);
265
+ let e = p(E.texteAssocie);
249
266
  t.textesAssocies = e;
250
267
  for (let t of e) {
251
268
  let e = t.refTexteAssocie;
@@ -253,36 +270,36 @@ function p(e) {
253
270
  }
254
271
  }
255
272
  let D = t.typeDeclaration;
256
- D !== void 0 && h(D);
273
+ D !== void 0 && g(D);
257
274
  let O = t.typeMotion;
258
- O !== void 0 && h(O);
275
+ O !== void 0 && g(O);
259
276
  let k = t.typeMotionCensure;
260
- k !== void 0 && h(k);
277
+ k !== void 0 && g(k);
261
278
  let A = t.voteRefs;
262
- A !== void 0 && !Array.isArray(A) && (t.voteRefs = f(A.voteRef));
279
+ A !== void 0 && !Array.isArray(A) && (t.voteRefs = p(A.voteRef));
263
280
  let j = t.actesLegislatifs;
264
281
  if (j !== void 0 && !Array.isArray(j)) {
265
- let e = f(j.acteLegislatif);
282
+ let e = p(j.acteLegislatif);
266
283
  t.actesLegislatifs = e;
267
- for (let t of e) p(t);
284
+ for (let t of e) m(t);
268
285
  }
269
286
  }
270
- function m(e) {
287
+ function h(e) {
271
288
  let t = e, n = t.initiateur;
272
289
  if (n !== void 0) {
273
290
  let e = n.acteurs;
274
291
  if (e !== void 0 && !Array.isArray(e)) {
275
- let t = f(e.acteur);
292
+ let t = p(e.acteur);
276
293
  t.length > 0 ? n.acteurs = t : delete n.acteurs;
277
294
  }
278
295
  let r = n.organes;
279
296
  r !== void 0 && (n.organeRef = r.organe.organeRef.uid, s.notStrictEqual(n.organeRef, void 0), delete n.organes), n.acteurs === void 0 && n.organeRef === void 0 && delete t.initiateur;
280
297
  }
281
298
  }
282
- function h(e) {
299
+ function g(e) {
283
300
  e.famCode = e.fam_code, delete e.fam_code, s(e.famCode), e.libelle || (e.libelle = e.famCode);
284
301
  }
285
- function g(e) {
302
+ function _(e) {
286
303
  r(e);
287
304
  let t = e.typeJO;
288
305
  t !== void 0 && (e.typeJo = t, delete e.typeJO);
@@ -295,20 +312,20 @@ function g(e) {
295
312
  }
296
313
  //#endregion
297
314
  //#region src/cleaners/dossiers_legislatifs.ts
298
- function _(e) {
315
+ function v(e) {
299
316
  let t = e;
300
317
  r(t);
301
318
  let n = t["@xsi:type"];
302
319
  n !== void 0 && (t.xsiType = n, delete t["@xsi:type"]);
303
320
  let i = t.titreDossier;
304
- r(i), m(t);
321
+ r(i), h(t);
305
322
  let a = t.actesLegislatifs;
306
323
  if (a != null) {
307
324
  let e = Array.isArray(a) ? a : a.acteLegislatif;
308
325
  Array.isArray(e) || (s(e), e = [e]);
309
326
  let n = e;
310
327
  t.actesLegislatifs = n;
311
- for (let e of n) p(e);
328
+ for (let e of n) m(e);
312
329
  }
313
330
  let o = t.PLF;
314
331
  if (o !== void 0) {
@@ -318,25 +335,25 @@ function _(e) {
318
335
  let e = t.rapporteur;
319
336
  if (e !== void 0) {
320
337
  Array.isArray(e) || (s(e), e = [e]), delete t.rapporteur, t.rapporteurs = e;
321
- for (let t of e) l(t);
338
+ for (let t of e) u(t);
322
339
  }
323
340
  let n = t.missionMinefi;
324
- n !== void 0 && v(n), t.ordreDiqs = t.ordreDIQS, delete t.ordreDIQS, s(t.ordreDiqs);
341
+ n !== void 0 && y(n), t.ordreDiqs = t.ordreDIQS, delete t.ordreDIQS, s(t.ordreDiqs);
325
342
  }
326
343
  }
327
344
  return t;
328
345
  }
329
- function v(e) {
346
+ function y(e) {
330
347
  let t = e.missions;
331
348
  if (t !== void 0) {
332
349
  let n = Array.isArray(t) ? t : t.mission;
333
350
  Array.isArray(n) || (s(n), n = [n]), e.missions = n;
334
- for (let e of n) v(e);
351
+ for (let e of n) y(e);
335
352
  }
336
353
  }
337
354
  //#endregion
338
355
  //#region src/cleaners/organes.ts
339
- function y(e) {
356
+ function b(e) {
340
357
  let t = e;
341
358
  r(t);
342
359
  let n = t["@xsi:type"];
@@ -365,7 +382,7 @@ function y(e) {
365
382
  }
366
383
  //#endregion
367
384
  //#region src/cleaners/reunions.ts
368
- function b(e) {
385
+ function x(e) {
369
386
  r(e);
370
387
  let t = e.chrono;
371
388
  s(t);
@@ -377,7 +394,7 @@ function b(e) {
377
394
  n !== void 0 && (s.strictEqual(typeof n, "string"), n = new Date(n), t.cloture = n);
378
395
  }
379
396
  }
380
- function x(e) {
397
+ function S(e) {
381
398
  let t = e;
382
399
  r(t), i(t, "captationVideo"), i(t, "comiteSecret"), i(t, "ouverturePresse");
383
400
  let n = t["@xsi:type"];
@@ -389,7 +406,7 @@ function x(e) {
389
406
  let c = t.lieu;
390
407
  c !== void 0 && r(c);
391
408
  let l = t.cycleDeVie;
392
- s.notStrictEqual(l, void 0), b(l);
409
+ s.notStrictEqual(l, void 0), x(l);
393
410
  let u = t.demandeurs;
394
411
  if (u != null) {
395
412
  let e = u.acteur;
@@ -458,7 +475,7 @@ function x(e) {
458
475
  let t = e["@xsi:type"];
459
476
  t !== void 0 && (e.xsiType = t, delete e["@xsi:type"]);
460
477
  let n = e.cycleDeVie;
461
- s.notStrictEqual(n, void 0), b(n), s.strictEqual(e.demandeurPoint, void 0);
478
+ s.notStrictEqual(n, void 0), x(n), s.strictEqual(e.demandeurPoint, void 0);
462
479
  let a = e.dossiersLegislatifsRefs;
463
480
  a !== void 0 && (e.dossiersLegislatifsRefs = Array.isArray(a) ? a : Array.isArray(a.dossierRef) ? a.dossierRef : [a.dossierRef]), e.typePointOdj = e.typePointODJ, delete e.typePointODJ, s.strictEqual(e.textesAssocies, void 0), e.natureTravauxOdj = e.natureTravauxODJ, delete e.natureTravauxODJ;
464
481
  let o = e.dateConfPres;
@@ -503,18 +520,18 @@ function x(e) {
503
520
  }
504
521
  //#endregion
505
522
  //#region src/cleaners/scrutins.ts
506
- function S(e) {
523
+ function C(e) {
507
524
  return "votant" in e;
508
525
  }
509
- function C(e) {
526
+ function w(e) {
510
527
  if (e == null) return;
511
528
  if (typeof e == "string") return s.strictEqual(e, "0"), [];
512
529
  if (Array.isArray(e)) {
513
530
  let t = e.filter((e) => e !== null);
514
- if (t.length === 0 || !S(t[0])) return t;
531
+ if (t.length === 0 || !C(t[0])) return t;
515
532
  let n = [];
516
533
  for (let e of t) {
517
- s(S(e));
534
+ s(C(e));
518
535
  let t = e.votant;
519
536
  Array.isArray(t) ? n.push(...t) : n.push(t);
520
537
  }
@@ -523,58 +540,58 @@ function C(e) {
523
540
  let t = [], n = e.votant;
524
541
  return Array.isArray(n) ? t.push(...n) : t.push(n), t;
525
542
  }
526
- function w(e) {
543
+ function T(e) {
527
544
  r(e);
528
545
  let t = e.nonVotants ?? e.nonVotant;
529
546
  if (e.nonVotants === void 0 ? delete e.nonVotant : s.strictEqual(e.nonVotant, void 0), t !== void 0) {
530
- let n = C(t);
547
+ let n = w(t);
531
548
  if (n !== void 0 && n.length === 0) delete e.nonVotants;
532
549
  else if (n !== void 0) {
533
550
  e.nonVotants = n;
534
- for (let e of n) D(e);
551
+ for (let e of n) O(e);
535
552
  }
536
553
  }
537
554
  let n = e.pour ?? e.pours;
538
555
  if (e.pour === void 0 ? delete e.pours : s.strictEqual(e.pours, void 0), n !== void 0) {
539
- let t = C(n);
556
+ let t = w(n);
540
557
  if (s(t), t.length === 0) delete e.pour;
541
558
  else {
542
559
  e.pour = t;
543
- for (let e of t) D(e);
560
+ for (let e of t) O(e);
544
561
  }
545
562
  }
546
563
  let i = e.contre ?? e.contres;
547
564
  if (e.contre === void 0 ? delete e.contres : s.strictEqual(e.contres, void 0), i !== void 0) {
548
- let t = C(i);
565
+ let t = w(i);
549
566
  if (s(t), t.length === 0) delete e.contre;
550
567
  else {
551
568
  e.contre = t;
552
- for (let e of t) D(e);
569
+ for (let e of t) O(e);
553
570
  }
554
571
  }
555
572
  let a = e.abstentions ?? e.abstention;
556
573
  if (e.abstentions === void 0 ? delete e.abstention : s.strictEqual(e.abstention, void 0), a !== void 0) {
557
- let t = C(a);
574
+ let t = w(a);
558
575
  if (s(t), t.length === 0) delete e.abstentions;
559
576
  else {
560
577
  e.abstentions = t;
561
- for (let e of t) D(e);
578
+ for (let e of t) O(e);
562
579
  }
563
580
  }
564
581
  let o = e.nonVotantsVolontaires;
565
582
  if (o !== void 0) {
566
- let t = C(o);
583
+ let t = w(o);
567
584
  if (s(t), t.length === 0) delete e.nonVotantsVolontaires;
568
585
  else {
569
586
  e.nonVotantsVolontaires = t;
570
- for (let e of t) D(e);
587
+ for (let e of t) O(e);
571
588
  }
572
589
  }
573
590
  }
574
- function T(e) {
591
+ function E(e) {
575
592
  r(e), e.abstention !== void 0 && (s.strictEqual(e.abstentions, void 0), e.abstentions = e.abstention, delete e.abstention), e.nonVotant !== void 0 && (s.strictEqual(e.nonVotants, void 0), e.nonVotants = e.nonVotant, delete e.nonVotant);
576
593
  }
577
- function E(e) {
594
+ function D(e) {
578
595
  let t = e;
579
596
  r(t);
580
597
  let n = t.demandeur;
@@ -583,37 +600,37 @@ function E(e) {
583
600
  r(i), s.strictEqual(i.referenceLegislative, void 0);
584
601
  let a = t.miseAuPoint;
585
602
  if (a !== void 0) {
586
- w(a);
603
+ T(a);
587
604
  let e = a.dysfonctionnement;
588
- e !== void 0 && (w(e), Object.values(e).every((e) => e === void 0) && delete a.dysfonctionnement), Object.values(a).every((e) => e === void 0) && delete t.miseAuPoint;
605
+ e !== void 0 && (T(e), Object.values(e).every((e) => e === void 0) && delete a.dysfonctionnement), Object.values(a).every((e) => e === void 0) && delete t.miseAuPoint;
589
606
  }
590
607
  let o = t.syntheseVote;
591
- T(o.decompte);
608
+ E(o.decompte);
592
609
  let c = t.ventilationVotes.organe;
593
610
  s(c);
594
611
  let l = c.groupes.groupe;
595
612
  s(Array.isArray(l));
596
613
  for (let e of l) {
597
614
  let t = e.vote;
598
- T(t.decompteVoix), w(t.decompteNominatif);
615
+ E(t.decompteVoix), T(t.decompteNominatif);
599
616
  }
600
617
  return t.ventilationVotes = {
601
618
  ...c,
602
619
  groupes: l
603
620
  }, t;
604
621
  }
605
- function D(e) {
622
+ function O(e) {
606
623
  i(e, "parDelegation"), a(e, "numPlace");
607
624
  }
608
625
  //#endregion
609
626
  //#region src/cleaners/questions.ts
610
- function O(e) {
627
+ function k(e) {
611
628
  let t = n.parse(e);
612
629
  return r(t, { recursive: !0 }), t;
613
630
  }
614
631
  //#endregion
615
632
  //#region src/cleaners/debats.ts
616
- function k(n) {
633
+ function A(n) {
617
634
  let i = t.safeParse(n);
618
635
  if (i.success) {
619
636
  let e = i.data;
@@ -622,4 +639,4 @@ function k(n) {
622
639
  return e.parse(n);
623
640
  }
624
641
  //#endregion
625
- export { c as cleanActeur, o as cleanAmendement, k as cleanCompteRendu, d as cleanDocumentOrDivision, _ as cleanDossierParlementaire, y as cleanOrgane, O as cleanQuestion, x as cleanReunion, E as cleanScrutin };
642
+ export { c as cleanActeur, o as cleanAmendement, A as cleanCompteRendu, f as cleanDocumentOrDivision, v as cleanDossierParlementaire, b as cleanOrgane, k as cleanQuestion, S as cleanReunion, D as cleanScrutin };
@@ -0,0 +1 @@
1
+ export {};
package/lib/parsers.js CHANGED
@@ -8323,56 +8323,64 @@ function Ru(e) {
8323
8323
  var zu = [
8324
8324
  /^– \d+ –/,
8325
8325
  /^- \d+ -/,
8326
- /^Délibéré en séance publique/,
8327
- /^Fait le/,
8328
8326
  /^La Présidente,$/,
8329
- /^Le Président,$/,
8330
- /^Signé/
8327
+ /^Le Président,$/
8331
8328
  ];
8332
8329
  function Bu(e) {
8333
8330
  return zu.some((t) => t.test(e));
8334
8331
  }
8335
- function Vu(e, t) {
8336
- let n = Nu(Pu(t, { removeEmptyElements: !0 })), r = n("p:not(table p), h4, table").toArray().filter((e) => Lu(Q(n(e).text())).length > 0), i = [], a = [], o = null, s = null, c = !1, l = [], u = [], d = [], f = !1;
8332
+ var Vu = [
8333
+ /^Délibéré en séance publique/,
8334
+ /^Fait le/,
8335
+ /^Signé/
8336
+ ];
8337
+ function Hu(e) {
8338
+ return Vu.some((t) => t.test(e));
8339
+ }
8340
+ function Uu(e, t) {
8341
+ let n = Nu(Pu(t, { removeEmptyElements: !0 })), r = n("p:not(table p), h4, table").toArray().filter((e) => Lu(Q(n(e).text())).length > 0), i = [], a = [], o = null, s = null, c = !1, l = [], u = [], d = [], f = !1, p = !1;
8337
8342
  for (let e of r) {
8338
- let t = n(e), r = t.find("a").first().attr("href") || "", p = t.hasClass("assnatFootnoteText") || r.startsWith("#_ftnref"), m = Lu(Q(t.prop("outerHTML") || "")), h = t.is("table") ? Fu(t) : Lu(Q(t.text()));
8339
- if (p) {
8343
+ let t = n(e), r = t.find("a").first().attr("href") || "", m = t.hasClass("assnatFootnoteText") || r.startsWith("#_ftnref"), h = Lu(Q(t.prop("outerHTML") || "")), g = t.is("table") ? Fu(t) : Lu(Q(t.text()));
8344
+ if (m) {
8340
8345
  f && d.push({
8341
- texte: h,
8342
- html: m
8346
+ texte: g,
8347
+ html: h
8343
8348
  });
8344
8349
  continue;
8345
8350
  }
8346
- let g = Ru(h), [_, v] = Iu(g);
8347
- if (!f) if (_ !== null && _ >= 0 && v !== "Annexe") f = !0;
8351
+ let _ = Ru(g), [v, y] = Iu(_);
8352
+ if (!f) if (v !== null && v >= 0 && y !== "Annexe") f = !0;
8348
8353
  else continue;
8349
- if (!(!g || Bu(h) || _ !== null && _ < 0)) if (_ === null) l.length === 0 || c && u.length === 0 ? l.push({
8350
- texte: h,
8351
- html: m
8352
- }) : u.push({
8353
- texte: h,
8354
- html: m
8355
- }), c && l.length >= 2 && (c = !1);
8356
- else {
8357
- if (v !== "ExposeMotifs" && t.closest(".assnatSection2").length > 0) {
8358
- u.push({
8359
- texte: h,
8360
- html: m
8361
- });
8362
- continue;
8354
+ if (!(!_ || Bu(g) || v !== null && v < 0)) {
8355
+ if (Hu(g)) break;
8356
+ if (v === null) l.length === 0 || c && u.length === 0 ? l.push({
8357
+ texte: g,
8358
+ html: h
8359
+ }) : u.push({
8360
+ texte: g,
8361
+ html: h
8362
+ }), c && l.length >= 2 && (c = !1);
8363
+ else {
8364
+ if (y === "ExposeMotifs" && (p = !0), y !== "ExposeMotifs" && p && t.closest(".assnatSection2").length > 0) {
8365
+ u.push({
8366
+ texte: g,
8367
+ html: h
8368
+ });
8369
+ continue;
8370
+ }
8371
+ for (o = v, l.length > 0 && i.push({
8372
+ id: `D_${Ru(l[0]?.texte ?? "")}`,
8373
+ type: s ?? "",
8374
+ niveau: o + 1,
8375
+ niveauRelatif: a.length,
8376
+ titres: l,
8377
+ alineas: u
8378
+ }); a.length > 0 && o < a[a.length - 1];) a.pop();
8379
+ (a.length === 0 || o > a[a.length - 1]) && a.push(o), s = y, l = [{
8380
+ texte: g,
8381
+ html: h
8382
+ }], u = [], c = !_.match(/^ARTICLES?(_|$)/) && !_.match(/^EXPOSE_DES_MOTIFS$/);
8363
8383
  }
8364
- for (o = _, l.length > 0 && i.push({
8365
- id: `D_${Ru(l[0]?.texte ?? "")}`,
8366
- type: s ?? "",
8367
- niveau: o + 1,
8368
- niveauRelatif: a.length,
8369
- titres: l,
8370
- alineas: u
8371
- }); a.length > 0 && o < a[a.length - 1];) a.pop();
8372
- (a.length === 0 || o > a[a.length - 1]) && a.push(o), s = v, l = [{
8373
- texte: h,
8374
- html: m
8375
- }], u = [], c = !g.match(/^ARTICLES?(_|$)/) && !g.match(/^EXPOSE_DES_MOTIFS$/);
8376
8384
  }
8377
8385
  }
8378
8386
  l.length > 0 && i.push({
@@ -8383,19 +8391,19 @@ function Vu(e, t) {
8383
8391
  titres: l,
8384
8392
  alineas: u
8385
8393
  });
8386
- let p = /* @__PURE__ */ new Map();
8394
+ let m = /* @__PURE__ */ new Map();
8387
8395
  for (let e of i) for (let t of [...e.titres || [], ...e.alineas || []]) {
8388
8396
  if (!t.html?.includes("#_ftn") && !t.html?.includes("Footnote")) continue;
8389
8397
  let n = Nu(t.html, null, !1);
8390
8398
  n(".assnatFootnote, .assNatFootnote, a[href^=\"#_ftn\"]:not([href^=\"#_ftnref\"])").each((t, r) => {
8391
8399
  let i = n(r).text().match(/(\d+)/);
8392
- i && !p.has(i[1]) && p.set(i[1], e);
8400
+ i && !m.has(i[1]) && m.set(i[1], e);
8393
8401
  });
8394
8402
  }
8395
8403
  for (let e of d) {
8396
8404
  let t = e.texte?.match(/^[\s([]*(\d+)[\s)\]]*/), n = !1;
8397
8405
  if (t) {
8398
- let r = t[1], i = p.get(r);
8406
+ let r = t[1], i = m.get(r);
8399
8407
  i && (i.alineas?.push(e), n = !0);
8400
8408
  }
8401
8409
  if (!n) {
@@ -8410,7 +8418,7 @@ function Vu(e, t) {
8410
8418
  }
8411
8419
  //#endregion
8412
8420
  //#region node_modules/date-fns/formatISO.js
8413
- function Hu(e, t) {
8421
+ function Wu(e, t) {
8414
8422
  let n = i(e, t?.in);
8415
8423
  if (isNaN(+n)) throw RangeError("Invalid time value");
8416
8424
  let a = t?.format ?? "extended", o = t?.representation ?? "complete", s = "", c = "", l = a === "extended" ? "-" : "", u = a === "extended" ? ":" : "";
@@ -8435,14 +8443,14 @@ function Hu(e, t) {
8435
8443
  }
8436
8444
  //#endregion
8437
8445
  //#region src/parsers/recherche_amendements.ts
8438
- var Uu = /* @__PURE__ */ RegExp("^(\\ufeff?(= yaml =|---)$[\\s\\S]*?^(?:\\2|\\.\\.\\.)\\s*$(?:\\r?\\n)?)", "m");
8439
- function Wu(e) {
8440
- return e.replace(Uu, "");
8446
+ var Gu = /* @__PURE__ */ RegExp("^(\\ufeff?(= yaml =|---)$[\\s\\S]*?^(?:\\2|\\.\\.\\.)\\s*$(?:\\r?\\n)?)", "m");
8447
+ function Ku(e) {
8448
+ return e.replace(Gu, "");
8441
8449
  }
8442
- async function* Gu(e, t, r, i, o, s = {}) {
8443
- for await (let [c, l] of Ku(e, t, r, i, o, s)) a(l), yield [c, n.toAmendement(JSON.stringify(l))];
8450
+ async function* qu(e, t, r, i, o, s = {}) {
8451
+ for await (let [c, l] of Ju(e, t, r, i, o, s)) a(l), yield [c, n.toAmendement(JSON.stringify(l))];
8444
8452
  }
8445
- async function* Ku(n, r, i, a, f, p = {}) {
8453
+ async function* Ju(n, r, i, a, f, p = {}) {
8446
8454
  await s.ensureDir(n), o.strictEqual(/[?&]date_depot=/.exec(r), null, `URL ${r} already contains a deposit date`), o.strictEqual(/[?&]order=/.exec(r), null, `URL ${r} already contains a sort order`), o.strictEqual(/[?&]page=/.exec(r), null, `URL ${r} already contains a page number`), i && o.notStrictEqual(/[?&]etat=/.exec(r), null, `In incremental mode, URL ${r} must contain an "etat" query parameter`), r += (r.includes("?") ? "&" : "?") + "order=date_depot,desc&page=1", a != null && o.notStrictEqual(/\d{4}-\d{2}-\d{2}/.exec(a), null, `Invalid format for minimum date: ${a}`);
8447
8455
  let m = 0;
8448
8456
  iterSearchPages: for (;;) {
@@ -8480,11 +8488,11 @@ async function* Ku(n, r, i, a, f, p = {}) {
8480
8488
  let n = l.querySelectorAll("td");
8481
8489
  if (o.strictEqual(n.length, 11, `Unexpected number of columns in amendment row: ${l.outerHTML}`), a != null) {
8482
8490
  let r = n[10];
8483
- if (Hu(t(r.text, "d MMMM y", /* @__PURE__ */ new Date(), { locale: e }), { representation: "date" }) < a) break iterSearchPages;
8491
+ if (Wu(t(r.text, "d MMMM y", /* @__PURE__ */ new Date(), { locale: e }), { representation: "date" }) < a) break iterSearchPages;
8484
8492
  }
8485
8493
  if (f != null) {
8486
8494
  let r = n[7];
8487
- if (r.text && Hu(t(r.text, "d MMMM y", /* @__PURE__ */ new Date(), { locale: e }), { representation: "date" }) < f) continue;
8495
+ if (r.text && Wu(t(r.text, "d MMMM y", /* @__PURE__ */ new Date(), { locale: e }), { representation: "date" }) < f) continue;
8488
8496
  }
8489
8497
  }
8490
8498
  let h = l.getAttribute("data-href");
@@ -8501,7 +8509,7 @@ async function* Ku(n, r, i, a, f, p = {}) {
8501
8509
  if (i) break iterSearchPages;
8502
8510
  continue;
8503
8511
  }
8504
- if (y !== null && Wu(y) === ee) continue;
8512
+ if (y !== null && Ku(y) === ee) continue;
8505
8513
  p.verbose && console.log(y === null ? `Adding amendement search cache: ${_}…` : `Updating amendement search cache: ${_}…`);
8506
8514
  let b = new URL(h, "https://www.assemblee-nationale.fr/").toString(), ne = await fetch(b);
8507
8515
  if (ne.status === 404) {
@@ -8531,7 +8539,7 @@ async function* Ku(n, r, i, a, f, p = {}) {
8531
8539
  }
8532
8540
  //#endregion
8533
8541
  //#region src/parsers/plf/parser_utils.ts
8534
- function qu(e) {
8542
+ function Yu(e) {
8535
8543
  return e.normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[^a-zA-Z0-9]/g, "_").replace(/_+/g, "_").replace(/^_|_$/g, "").toUpperCase();
8536
8544
  }
8537
8545
  function $(e) {
@@ -8540,7 +8548,7 @@ function $(e) {
8540
8548
  html: Q(e.html())
8541
8549
  };
8542
8550
  }
8543
- function Ju(e, t, n, r) {
8551
+ function Xu(e, t, n, r) {
8544
8552
  return {
8545
8553
  id: e,
8546
8554
  type: t,
@@ -8550,10 +8558,10 @@ function Ju(e, t, n, r) {
8550
8558
  alineas: []
8551
8559
  };
8552
8560
  }
8553
- function Yu(e) {
8561
+ function Zu(e) {
8554
8562
  return /états\s+l[ée]gislatifs\s+annex/i.test(e);
8555
8563
  }
8556
- function Xu(e) {
8564
+ function Qu(e) {
8557
8565
  return {
8558
8566
  texte: Fu(e),
8559
8567
  html: e.prop("outerHTML") || ""
@@ -8561,19 +8569,19 @@ function Xu(e) {
8561
8569
  }
8562
8570
  //#endregion
8563
8571
  //#region src/parsers/plf/depot.ts
8564
- var Zu = [
8572
+ var $u = [
8565
8573
  "Partie",
8566
8574
  "Titre",
8567
8575
  "Chapitre",
8568
8576
  "Section"
8569
8577
  ];
8570
- function Qu(e) {
8578
+ function ed(e) {
8571
8579
  let t = Nu(Pu(e)), n = [], r = [], i = "generalExpose", a = null, o = null, s = t("h1, h2, h3, h4, h5, h6, p.assnatFPFexpogentitre1, p.assnatFPFexpogentexte, li.assnatFPFprojetloiartexte, p.assnatFPFfinartexte, table, img").toArray(), c = () => {
8572
8580
  o && (n.push(o), o = null);
8573
8581
  };
8574
8582
  for (let e of s) {
8575
8583
  if (i === "done") break;
8576
- let s = t(e), _ = Q(s.text()), v = $u(s), y = v !== null, ee = v !== null && v >= 2 && v <= 5, te = s.hasClass("assnatFPFexpogentitre1"), b = s.hasClass("assnatFPFexpogentexte"), ne = s.hasClass("assnatFPFprojetloiartexte"), re = s.hasClass("assnatFPFfinartexte"), x = s.is("table"), ie = s.is("img"), ae = s.find("img").length > 0;
8584
+ let s = t(e), _ = Q(s.text()), v = td(s), y = v !== null, ee = v !== null && v >= 2 && v <= 5, te = s.hasClass("assnatFPFexpogentitre1"), b = s.hasClass("assnatFPFexpogentexte"), ne = s.hasClass("assnatFPFprojetloiartexte"), re = s.hasClass("assnatFPFfinartexte"), x = s.is("table"), ie = s.is("img"), ae = s.find("img").length > 0;
8577
8585
  if (!(y && _.length === 0)) {
8578
8586
  if (i === "generalExpose") {
8579
8587
  if (v === 1) {
@@ -8582,11 +8590,11 @@ function Qu(e) {
8582
8590
  a && n.push(a), a = null, i = "hierarchy";
8583
8591
  continue;
8584
8592
  }
8585
- e.includes("exposé général des motifs") && (a ?? (a = Ju("D_EXPOSE", "Exposé des motifs", 1, 1)));
8593
+ e.includes("exposé général des motifs") && (a ?? (a = Xu("D_EXPOSE", "Exposé des motifs", 1, 1)));
8586
8594
  }
8587
8595
  if (ee && (a && n.push(a), a = null, i = "hierarchy"), a) {
8588
8596
  if (ie) {
8589
- let e = nd(s);
8597
+ let e = id(s);
8590
8598
  if (e) {
8591
8599
  var l;
8592
8600
  (l = a).alineas ?? (l.alineas = []), a.alineas.push(e);
@@ -8595,36 +8603,36 @@ function Qu(e) {
8595
8603
  var u;
8596
8604
  (u = a).titres ?? (u.titres = []), a.titres.push($(s));
8597
8605
  } else if (te || b) {
8598
- let e = ae ? ed(s) : $(s);
8606
+ let e = ae ? nd(s) : $(s);
8599
8607
  if (e) {
8600
8608
  var d;
8601
8609
  (d = a).alineas ?? (d.alineas = []), a.alineas.push(e);
8602
8610
  }
8603
8611
  } else if (x) {
8604
8612
  var f;
8605
- (f = a).alineas ?? (f.alineas = []), a.alineas.push(Xu(s));
8613
+ (f = a).alineas ?? (f.alineas = []), a.alineas.push(Qu(s));
8606
8614
  }
8607
8615
  continue;
8608
8616
  }
8609
8617
  }
8610
- if (Yu(_)) {
8618
+ if (Zu(_)) {
8611
8619
  c(), a && (n.push(a), a = null), i = "done";
8612
8620
  continue;
8613
8621
  }
8614
8622
  if (v !== 1) {
8615
8623
  if (ee) {
8616
8624
  c();
8617
- let e = v - 2, t = Zu[e];
8625
+ let e = v - 2, t = $u[e];
8618
8626
  for (; r.length > 0 && r[r.length - 1] >= e;) r.pop();
8619
8627
  r.push(e);
8620
- let a = Ju(`D_${qu(_)}`, t, e + 1, r.length);
8628
+ let a = Xu(`D_${Yu(_)}`, t, e + 1, r.length);
8621
8629
  a.titres = [$(s)], n.push(a), i = "hierarchy";
8622
8630
  continue;
8623
8631
  }
8624
8632
  if (v === 6) {
8625
8633
  c();
8626
8634
  let e = r.length + 1;
8627
- o = Ju(`D_${qu(_)}`, "Article", 5, e), o.titres = [$(s)], i = "articleBody";
8635
+ o = Xu(`D_${Yu(_)}`, "Article", 5, e), o.titres = [$(s)], i = "articleBody";
8628
8636
  continue;
8629
8637
  }
8630
8638
  if (ne && i === "articleBody" && o) {
@@ -8634,7 +8642,7 @@ function Qu(e) {
8634
8642
  }
8635
8643
  if (x && i === "articleBody" && o) {
8636
8644
  var m;
8637
- (m = o).alineas ?? (m.alineas = []), o.alineas.push(Xu(s));
8645
+ (m = o).alineas ?? (m.alineas = []), o.alineas.push(Qu(s));
8638
8646
  continue;
8639
8647
  }
8640
8648
  if (re && o) {
@@ -8654,7 +8662,7 @@ function Qu(e) {
8654
8662
  }
8655
8663
  if (x) {
8656
8664
  var g;
8657
- (g = o).exposeDesMotifs ?? (g.exposeDesMotifs = []), o.exposeDesMotifs.push(Xu(s));
8665
+ (g = o).exposeDesMotifs ?? (g.exposeDesMotifs = []), o.exposeDesMotifs.push(Qu(s));
8658
8666
  }
8659
8667
  }
8660
8668
  }
@@ -8662,11 +8670,11 @@ function Qu(e) {
8662
8670
  }
8663
8671
  return c(), a && n.push(a), { subdivisions: n };
8664
8672
  }
8665
- function $u(e) {
8673
+ function td(e) {
8666
8674
  for (let t = 1; t <= 6; t++) if (e.is(`h${t}`)) return t;
8667
8675
  return null;
8668
8676
  }
8669
- function ed(e) {
8677
+ function nd(e) {
8670
8678
  let t = e.clone();
8671
8679
  t.find("img").remove();
8672
8680
  let n = Q(t.text());
@@ -8675,14 +8683,14 @@ function ed(e) {
8675
8683
  html: Q(t.html())
8676
8684
  } : null;
8677
8685
  }
8678
- function td(e) {
8686
+ function rd(e) {
8679
8687
  if (!e || !/^\d+$/.test(e)) return;
8680
8688
  let t = Number(e);
8681
8689
  return t > 0 ? t : void 0;
8682
8690
  }
8683
- function nd(e) {
8691
+ function id(e) {
8684
8692
  if (!e.attr("src")) return null;
8685
- let t = td(e.attr("width")), n = td(e.attr("height"));
8693
+ let t = rd(e.attr("width")), n = rd(e.attr("height"));
8686
8694
  return t === 15 && n === 15 || t === 2 && n === 138 ? null : {
8687
8695
  texte: Q(e.attr("alt") ?? ""),
8688
8696
  html: e.prop("outerHTML") || ""
@@ -8690,18 +8698,18 @@ function nd(e) {
8690
8698
  }
8691
8699
  //#endregion
8692
8700
  //#region src/parsers/plf/later_stage.ts
8693
- function rd(e) {
8701
+ function ad(e) {
8694
8702
  let t = Nu(Pu(e)), n = [], r = [], i = null, a = null, o = null, s = !1, c = t("p.assnat2PartieNum, p.assnat2PartieIntit, p.assnat4TitreNum, p.assnat4TitreNum0, p.assnat4TitreIntit, p.assnat9ArticleNum, p.assnatLoiTexte, p.assnat1TomeNum, table, p.assnat5ChapitreIntit, p.assnat5ChapitreIntit0, p.assnat5ChapitreNum, p.assnat5ChapitreNum0, p.assnat6SectionIntit, p.assnat6SectionIntit0, p.assnat6SectionNum, p.assnat6SectionNum0").toArray();
8695
8703
  for (let e of c) {
8696
8704
  let c = t(e), l = Q(c.text());
8697
- if (l.length === 0 || (!s && Yu(l) && (i && (n.push(i), i = null), s = !0), s)) continue;
8705
+ if (l.length === 0 || (!s && Zu(l) && (i && (n.push(i), i = null), s = !0), s)) continue;
8698
8706
  let u = c.hasClass("assnat2PartieNum"), d = c.hasClass("assnat2PartieIntit"), f = c.hasClass("assnat4TitreNum") || c.hasClass("assnat4TitreNum0"), p = c.hasClass("assnat4TitreIntit"), m = c.hasClass("assnat9ArticleNum"), h = c.hasClass("assnatLoiTexte"), g = c.is("table");
8699
8707
  if (d) {
8700
8708
  for (i && (n.push(i), i = null); r.length > 0 && r[r.length - 1] >= 0;) r.pop();
8701
8709
  r.push(0);
8702
- let e = id(a, $(c));
8710
+ let e = od(a, $(c));
8703
8711
  a = null, o = null;
8704
- let t = Ju(`D_${qu(e.texte ?? l)}`, "Partie", 1, r.length);
8712
+ let t = Xu(`D_${Yu(e.texte ?? l)}`, "Partie", 1, r.length);
8705
8713
  t.titres = [e], n.push(t);
8706
8714
  continue;
8707
8715
  }
@@ -8712,9 +8720,9 @@ function rd(e) {
8712
8720
  if (p) {
8713
8721
  for (i && (n.push(i), i = null); r.length > 0 && r[r.length - 1] >= 1;) r.pop();
8714
8722
  r.push(1);
8715
- let e = id(o, $(c));
8723
+ let e = od(o, $(c));
8716
8724
  o = null;
8717
- let t = Ju(`D_${qu(e.texte ?? l)}`, "Titre", 2, r.length);
8725
+ let t = Xu(`D_${Yu(e.texte ?? l)}`, "Titre", 2, r.length);
8718
8726
  t.titres = [e], n.push(t);
8719
8727
  continue;
8720
8728
  }
@@ -8725,7 +8733,7 @@ function rd(e) {
8725
8733
  if (m) {
8726
8734
  i && n.push(i);
8727
8735
  let e = r.length + 1;
8728
- i = Ju(`D_${qu(l)}`, "Article", 5, e), i.titres = [$(c)];
8736
+ i = Xu(`D_${Yu(l)}`, "Article", 5, e), i.titres = [$(c)];
8729
8737
  continue;
8730
8738
  }
8731
8739
  if (h) {
@@ -8735,7 +8743,7 @@ function rd(e) {
8735
8743
  let e = /^chapitre\b/i.test(l), t = /^section\b/i.test(l), a = /^[IVXLCDM]+[.\s]/.test(l), o = /^[A-Z][.\s]/.test(l), s = e || !t && a, u = s ? "Chapitre" : t || !e && o ? "Section" : "Chapitre", d = s ? 2 : 3;
8736
8744
  for (; r.length > 0 && r[r.length - 1] >= d;) r.pop();
8737
8745
  r.push(d);
8738
- let f = Ju(`D_${qu(l)}`, u, d + 1, r.length);
8746
+ let f = Xu(`D_${Yu(l)}`, u, d + 1, r.length);
8739
8747
  f.titres = [$(c)], n.push(f);
8740
8748
  continue;
8741
8749
  }
@@ -8743,14 +8751,14 @@ function rd(e) {
8743
8751
  continue;
8744
8752
  }
8745
8753
  if (g && i) {
8746
- i.alineas = i.alineas || [], i.alineas.push(Xu(c));
8754
+ i.alineas = i.alineas || [], i.alineas.push(Qu(c));
8747
8755
  continue;
8748
8756
  }
8749
8757
  (/assnat5Chapitre(Intit|Num)/.test(c.attr("class") ?? "") || /assnat6Section(Intit|Num)/.test(c.attr("class") ?? "")) && i && (i.alineas = i.alineas || [], i.alineas.push($(c)));
8750
8758
  }
8751
8759
  return i && n.push(i), { subdivisions: n };
8752
8760
  }
8753
- function id(e, t) {
8761
+ function od(e, t) {
8754
8762
  return e === null ? t : {
8755
8763
  texte: `${e.texte} : ${t.texte}`,
8756
8764
  html: `${e.html} : ${t.html}`
@@ -8758,20 +8766,20 @@ function id(e, t) {
8758
8766
  }
8759
8767
  //#endregion
8760
8768
  //#region src/parsers/plf/variant_detection.ts
8761
- var ad = [
8769
+ var sd = [
8762
8770
  "assnatFPFexpogentexte",
8763
8771
  "assnatFPFexpogentitre1",
8764
8772
  "assnatFPFexpogentitre2",
8765
8773
  "assnatFPFexpogentitre3",
8766
8774
  "assnatFPFexpogentitre4"
8767
8775
  ];
8768
- function od(e) {
8776
+ function cd(e) {
8769
8777
  let t = Nu(Pu(e));
8770
- return t("h1, h2, h3, h4, h5, h6").toArray().some((e) => Q(t(e).text()).normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase().includes("expose general des motifs")) || t(ad.map((e) => `.${e}`).join(", ")).length > 0 ? "depot" : "laterStage";
8778
+ return t("h1, h2, h3, h4, h5, h6").toArray().some((e) => Q(t(e).text()).normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase().includes("expose general des motifs")) || t(sd.map((e) => `.${e}`).join(", ")).length > 0 ? "depot" : "laterStage";
8771
8779
  }
8772
8780
  //#endregion
8773
8781
  //#region src/parsers/plf/credits.ts
8774
- var sd = {
8782
+ var ld = {
8775
8783
  bg: {
8776
8784
  budgetType: "budgetGeneral",
8777
8785
  libelle: "Budget général"
@@ -8789,15 +8797,15 @@ var sd = {
8789
8797
  libelle: "Comptes de concours financiers"
8790
8798
  }
8791
8799
  };
8792
- function cd(e) {
8800
+ function ud(e) {
8793
8801
  if (!e) return [];
8794
- let t = Nu(Pu(e)), n = md(t);
8802
+ let t = Nu(Pu(e)), n = gd(t);
8795
8803
  if (n.length === 0) return [];
8796
8804
  let r = [];
8797
8805
  for (let e of n) {
8798
8806
  let n = [], i;
8799
8807
  for (let r of e.tableEls) {
8800
- let e = fd(t, r);
8808
+ let e = md(t, r);
8801
8809
  n.push(...e.missions), e.total && (i = e.total);
8802
8810
  }
8803
8811
  n.length !== 0 && r.push({
@@ -8812,7 +8820,7 @@ function cd(e) {
8812
8820
  }
8813
8821
  return r;
8814
8822
  }
8815
- function ld(e) {
8823
+ function dd(e) {
8816
8824
  let t = Q(e).replace(/[\u2212\u2011]/g, "-").replace(/\s/g, "").replace(/[^0-9,.-]/g, ""), n = (t.match(/,/g) ?? []).length;
8817
8825
  if (n > 1) return;
8818
8826
  let r = n === 1 ? t.replace(/\./g, "").replace(",", ".") : t;
@@ -8820,44 +8828,47 @@ function ld(e) {
8820
8828
  let i = Number(r);
8821
8829
  return Number.isNaN(i) ? void 0 : i;
8822
8830
  }
8823
- function ud(e) {
8831
+ function fd(e) {
8824
8832
  let t = Q(e);
8825
8833
  if (!/\(\s*ligne\s+supprim(?:ée|ee)\s*\)\s*$/i.test(t)) return t.replace(/\s*\(\s*ligne\s+nouvelle\s*\)\s*$/i, "").trim();
8826
8834
  }
8827
- function dd(e, t) {
8828
- let n = ld(t(e[1]).text()), r = ld(t(e[2]).text());
8835
+ function pd(e, t) {
8836
+ let n = dd(t(e[1]).text()), r = dd(t(e[2]).text());
8829
8837
  return e.length >= 5 ? {
8830
8838
  autorisationEngagement: n,
8831
8839
  creditPaiement: r,
8832
- autorisationEngagementAnnule: ld(t(e[3]).text()),
8833
- creditPaiementAnnule: ld(t(e[4]).text())
8840
+ autorisationEngagementAnnule: dd(t(e[3]).text()),
8841
+ creditPaiementAnnule: dd(t(e[4]).text())
8834
8842
  } : {
8835
8843
  autorisationEngagement: n,
8836
8844
  creditPaiement: r
8837
8845
  };
8838
8846
  }
8839
- function fd(e, t) {
8840
- let n = [], r = null, i = null, a, o = e(t).find("tbody tr").toArray();
8847
+ function md(e, t) {
8848
+ let n = [], r = null, i = null, a, o = e(t).find("tbody tr").toArray(), s = o.some((t) => {
8849
+ let n = (e(t).find("td").first().attr("style") || "").replace(/[\n\t]/g, " ");
8850
+ return /border-top/.test(n);
8851
+ });
8841
8852
  for (let t of o) {
8842
8853
  let o = e(t).find("td").toArray();
8843
8854
  if (o.length < 3) continue;
8844
- let s = e(o[0]), c = (s.attr("style") || "").replace(/[\n\t]/g, " "), l = Q(s.text());
8845
- if (!l) continue;
8846
- let u = /^total/i.test(l), d = dd(o, e);
8847
- if (u) {
8848
- a = d;
8855
+ let c = e(o[0]), l = (c.attr("style") || "").replace(/[\n\t]/g, " "), u = Q(c.text());
8856
+ if (!u) continue;
8857
+ let d = /^total/i.test(u), f = pd(o, e);
8858
+ if (d) {
8859
+ a = f;
8849
8860
  continue;
8850
8861
  }
8851
- if (/dont\s+titre/i.test(l) && i) {
8862
+ if (/dont\s+titre/i.test(u) && i) {
8852
8863
  i.lignes = i.lignes || [], i.lignes.push({
8853
- libelle: l,
8854
- ...d
8864
+ libelle: u,
8865
+ ...f
8855
8866
  });
8856
8867
  continue;
8857
8868
  }
8858
- if (/border-(?:top|bottom)/.test(c)) {
8869
+ if (s ? /border-top/.test(l) : /border-bottom/.test(l)) {
8859
8870
  r && n.push(r);
8860
- let e = ud(s.text());
8871
+ let e = fd(c.text());
8861
8872
  if (e === void 0) {
8862
8873
  r = null, i = null;
8863
8874
  continue;
@@ -8865,20 +8876,20 @@ function fd(e, t) {
8865
8876
  r = {
8866
8877
  budgetType: "budgetGeneral",
8867
8878
  libelle: e,
8868
- ...d,
8879
+ ...f,
8869
8880
  programmes: []
8870
8881
  }, i = null;
8871
8882
  continue;
8872
8883
  }
8873
8884
  if (r) {
8874
- let e = ud(s.text());
8885
+ let e = fd(c.text());
8875
8886
  if (e === void 0) {
8876
8887
  i = null;
8877
8888
  continue;
8878
8889
  }
8879
8890
  i = {
8880
8891
  libelle: e,
8881
- ...d
8892
+ ...f
8882
8893
  }, r.programmes.push(i);
8883
8894
  }
8884
8895
  }
@@ -8887,11 +8898,11 @@ function fd(e, t) {
8887
8898
  total: a
8888
8899
  };
8889
8900
  }
8890
- function pd(e, t) {
8901
+ function hd(e, t) {
8891
8902
  let n = e(t).find("tr").slice(0, 3).find("th, td").toArray().map((t) => Q(e(t).text()).toLocaleLowerCase("fr"));
8892
8903
  return n.some((e) => e.includes("mission / programme")) && n.some((e) => e.includes("autorisation") && e.includes("engagement")) && n.some((e) => e.includes("crédit") && e.includes("paiement"));
8893
8904
  }
8894
- function md(e) {
8905
+ function gd(e) {
8895
8906
  let t, n, r = !1, i = /* @__PURE__ */ new Map(), a = e("p, h1, h2, h3, h4, h5, h6, a:not([href]), table").toArray().filter((t) => e(t).parents("table").length === 0);
8896
8907
  for (let o of a) {
8897
8908
  let a = e(o);
@@ -8911,7 +8922,7 @@ function md(e) {
8911
8922
  o !== /COMPTES\s+DE\s+CONCOURS\s+FINANCIERS/i.test(e) && (n = o ? "cas" : "ccf");
8912
8923
  continue;
8913
8924
  }
8914
- if (!pd(e, o)) continue;
8925
+ if (!hd(e, o)) continue;
8915
8926
  let s = t === "B" ? "bg" : t === "C" ? "ba" : t === "D" ? n : void 0;
8916
8927
  if (!s) continue;
8917
8928
  r = !0;
@@ -8921,7 +8932,7 @@ function md(e) {
8921
8932
  continue;
8922
8933
  }
8923
8934
  i.set(s, {
8924
- ...sd[s],
8935
+ ...ld[s],
8925
8936
  tableEls: [o]
8926
8937
  });
8927
8938
  }
@@ -8929,8 +8940,8 @@ function md(e) {
8929
8940
  }
8930
8941
  //#endregion
8931
8942
  //#region src/parsers/plf/index.ts
8932
- function hd(e) {
8933
- return e ? od(e) === "depot" ? Qu(e) : rd(e) : { subdivisions: [] };
8943
+ function _d(e) {
8944
+ return e ? cd(e) === "depot" ? ed(e) : ad(e) : { subdivisions: [] };
8934
8945
  }
8935
8946
  //#endregion
8936
- export { Gu as iterRechercheAmendements, Ku as iterRechercheRawAmendements, hd as parsePlf, cd as parsePlfCredits, Vu as parseTexte };
8947
+ export { qu as iterRechercheAmendements, Ju as iterRechercheRawAmendements, _d as parsePlf, ud as parsePlfCredits, Uu as parseTexte };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tricoteuses/assemblee",
3
- "version": "3.3.0",
3
+ "version": "3.3.3",
4
4
  "description": "Retrieve, clean up & handle French Assemblée nationale's open data",
5
5
  "keywords": [
6
6
  "Assemblée nationale",