@tricoteuses/assemblee 3.7.2 → 3.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,11 @@
1
1
  import { AmendementRaw as RawAmendement } from '../schemas/raw/amendements.js';
2
2
  import { AmendementClean as Amendement } from '../schemas/clean/amendements.js';
3
+ /**
4
+ * Iterates the amendments of an amendment search URL. Supports both the
5
+ * unfiltered layout and pages filtered by a single examen (`?examen=…`, to be
6
+ * used in non-incremental mode, since incremental mode requires an `etat`
7
+ * parameter).
8
+ */
3
9
  export declare function iterRechercheAmendements(amendementsSearchCacheDir: string, url: string, incremental: boolean, minDateDepot?: string | null, minDateExamen?: string | null, options?: {
4
10
  silent?: boolean;
5
11
  verbose?: boolean;
package/lib/parsers.js CHANGED
@@ -8436,10 +8436,32 @@ var Yu = /* @__PURE__ */ RegExp("^(\\ufeff?(= yaml =|---)$[\\s\\S]*?^(?:\\2|\\.\
8436
8436
  function Xu(e) {
8437
8437
  return e.replace(Yu, "");
8438
8438
  }
8439
- async function* Zu(e, t, n, i, o, s = {}) {
8440
- for await (let [c, l] of Qu(e, t, n, i, o, s)) a(l), yield [c, r.toAmendement(JSON.stringify(l))];
8439
+ var Zu = [
8440
+ "",
8441
+ "n°",
8442
+ "Dossier législatif",
8443
+ "Emplacement",
8444
+ "Auteur",
8445
+ "État",
8446
+ "Sort",
8447
+ "Date d'examen",
8448
+ "Examiné par",
8449
+ "Texte visé",
8450
+ "Date de dépôt"
8451
+ ], Qu = [
8452
+ "",
8453
+ "n°",
8454
+ "Emplacement",
8455
+ "Auteur",
8456
+ "État",
8457
+ "Sort",
8458
+ "Date d'examen",
8459
+ "Date de dépôt"
8460
+ ];
8461
+ async function* $u(e, t, n, i, o, s = {}) {
8462
+ for await (let [c, l] of ed(e, t, n, i, o, s)) a(l), yield [c, r.toAmendement(JSON.stringify(l))];
8441
8463
  }
8442
- async function* Qu(e, r, i, a, f, p = {}) {
8464
+ async function* ed(e, r, i, a, f, p = {}) {
8443
8465
  await s.ensureDir(e), 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}`);
8444
8466
  let ee = 0;
8445
8467
  iterSearchPages: for (;;) {
@@ -8456,31 +8478,19 @@ async function* Qu(e, r, i, a, f, p = {}) {
8456
8478
  o.notStrictEqual(b, null);
8457
8479
  let x = b.querySelector("tfoot > tr");
8458
8480
  o.notStrictEqual(x, null);
8459
- let S = x.querySelectorAll("td, th").map((e) => e.text);
8460
- o(l(S, [
8461
- "",
8462
- "n°",
8463
- "Dossier législatif",
8464
- "Emplacement",
8465
- "Auteur",
8466
- "État",
8467
- "Sort",
8468
- "Date d'examen",
8469
- "Examiné par",
8470
- "Texte visé",
8471
- "Date de dépôt"
8472
- ]), `Unexpected columns in ${JSON.stringify(S, null, 2)}`);
8473
- let te = b.querySelectorAll("tbody > tr");
8474
- o.notStrictEqual(te.length, 0);
8475
- for (let l of te) {
8481
+ let S = x.querySelectorAll("td, th").map((e) => e.text), te, ne, re;
8482
+ l(S, Zu) ? (te = Zu.length, ne = 10, re = 7) : l(S, Qu) ? (te = Qu.length, ne = 7, re = 6) : o(!1, `Unexpected columns in ${JSON.stringify(S, null, 2)}`);
8483
+ let ie = b.querySelectorAll("tbody > tr");
8484
+ o.notStrictEqual(ie.length, 0);
8485
+ for (let l of ie) {
8476
8486
  if (ee++, a != null || f != null) {
8477
8487
  let e = l.querySelectorAll("td");
8478
- if (o.strictEqual(e.length, 11, `Unexpected number of columns in amendment row: ${l.outerHTML}`), a != null) {
8479
- let r = e[10];
8488
+ if (o.strictEqual(e.length, te, `Unexpected number of columns in amendment row: ${l.outerHTML}`), a != null) {
8489
+ let r = e[ne];
8480
8490
  if (Ju(n(r.text, "d MMMM y", /* @__PURE__ */ new Date(), { locale: t }), { representation: "date" }) < a) break iterSearchPages;
8481
8491
  }
8482
8492
  if (f != null) {
8483
- let r = e[7];
8493
+ let r = e[re];
8484
8494
  if (r.text && Ju(n(r.text, "d MMMM y", /* @__PURE__ */ new Date(), { locale: t }), { representation: "date" }) < f) continue;
8485
8495
  }
8486
8496
  }
@@ -8506,29 +8516,29 @@ async function* Qu(e, r, i, a, f, p = {}) {
8506
8516
  continue;
8507
8517
  }
8508
8518
  o(S.ok, `Retrieval of amendement HTML page at ${x} failed with error: ${S.status} ${S.statusText}`);
8509
- let te = await S.text(), ne = d(te).querySelectorAll("li.mirror-card-header--options--content--item");
8510
- o.notStrictEqual(ne.length, 0);
8511
- let re = ne.find((e) => {
8519
+ let ie = await S.text(), ae = d(ie).querySelectorAll("li.mirror-card-header--options--content--item");
8520
+ o.notStrictEqual(ae.length, 0);
8521
+ let oe = ae.find((e) => {
8512
8522
  let t = e.querySelector("a > span");
8513
8523
  return o.notStrictEqual(t, null, `No <span> in <a> found in ${e.toString()}`), t.text === "Version JSON";
8514
8524
  });
8515
- o.notStrictEqual(re, void 0, `No JSON version found for amendement at ${x}`);
8516
- let ie = re.querySelector("a");
8517
- o.notStrictEqual(ie, null, `No <a> found in ${re.toString()}`);
8518
- let ae = ie.getAttribute("href");
8519
- o.notStrictEqual(ae, void 0, `No URL found for JSON version of amendement: ${re.toString()}`);
8520
- let oe = new URL(ae, "https://www.assemblee-nationale.fr/").toString(), se = await fetch(oe);
8521
- o(se.ok, `Retrieval of amendement JSON page at ${oe} failed with error: ${se.status} ${se.statusText}`), yield [m, await se.json()], await s.writeFile(g, b, "utf8");
8525
+ o.notStrictEqual(oe, void 0, `No JSON version found for amendement at ${x}`);
8526
+ let se = oe.querySelector("a");
8527
+ o.notStrictEqual(se, null, `No <a> found in ${oe.toString()}`);
8528
+ let ce = se.getAttribute("href");
8529
+ o.notStrictEqual(ce, void 0, `No URL found for JSON version of amendement: ${oe.toString()}`);
8530
+ let le = new URL(ce, "https://www.assemblee-nationale.fr/").toString(), ue = await fetch(le);
8531
+ o(ue.ok, `Retrieval of amendement JSON page at ${le} failed with error: ${ue.status} ${ue.statusText}`), yield [m, await ue.json()], await s.writeFile(g, b, "utf8");
8522
8532
  }
8523
- let ne = g.querySelector("div.an-pagination--item > i.an-icons-chevron-right ~ a");
8524
- if (ne === null) break;
8525
- let re = ne.getAttribute("href");
8526
- o.notStrictEqual(re, void 0), r = new URL(re, "https://www.assemblee-nationale.fr/").toString();
8533
+ let ae = g.querySelector("div.an-pagination--item > i.an-icons-chevron-right ~ a");
8534
+ if (ae === null) break;
8535
+ let oe = ae.getAttribute("href");
8536
+ o.notStrictEqual(oe, void 0), r = new URL(oe, "https://www.assemblee-nationale.fr/").toString();
8527
8537
  }
8528
8538
  }
8529
8539
  //#endregion
8530
8540
  //#region src/parsers/plf/parser_utils.ts
8531
- function $u(e) {
8541
+ function td(e) {
8532
8542
  return e.normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[^a-zA-Z0-9]/g, "_").replace(/_+/g, "_").replace(/^_|_$/g, "").toUpperCase();
8533
8543
  }
8534
8544
  function $(e) {
@@ -8537,7 +8547,7 @@ function $(e) {
8537
8547
  html: Q(e.html())
8538
8548
  };
8539
8549
  }
8540
- function ed(e, t, n, r) {
8550
+ function nd(e, t, n, r) {
8541
8551
  return {
8542
8552
  id: e,
8543
8553
  type: t,
@@ -8547,10 +8557,10 @@ function ed(e, t, n, r) {
8547
8557
  alineas: []
8548
8558
  };
8549
8559
  }
8550
- function td(e) {
8560
+ function rd(e) {
8551
8561
  return /états\s+l[ée]gislatifs\s+annex/i.test(e);
8552
8562
  }
8553
- function nd(e) {
8563
+ function id(e) {
8554
8564
  return {
8555
8565
  texte: Fu(e),
8556
8566
  html: e.prop("outerHTML") || ""
@@ -8558,22 +8568,22 @@ function nd(e) {
8558
8568
  }
8559
8569
  //#endregion
8560
8570
  //#region src/parsers/plf/depot.ts
8561
- var rd = [
8571
+ var ad = [
8562
8572
  "Partie",
8563
8573
  "Titre",
8564
8574
  "Chapitre",
8565
8575
  "Section"
8566
8576
  ];
8567
- function id(e) {
8577
+ function od(e) {
8568
8578
  let t = Nu(Pu(e)), n = [], r = [], i = "generalExpose", a = null, o = null, s = [], c = t("h1, h2, h3, h4, h5, h6, p.assnatPastille, p.assnatFPFexpogentitre1, p.assnatFPFexpogentexte, li.assnatFPFexpogentexte, li.assnatFPFprojetloiartexte, p.assnatFPFprojetloiartexte, p.assnatFPFfinartexte, table, img").toArray(), l = () => {
8569
- o && s.length > 0 && (o.alineas = ad(s)), s = [];
8579
+ o && s.length > 0 && (o.alineas = sd(s)), s = [];
8570
8580
  }, u = () => {
8571
8581
  o && (l(), n.push(o), o = null);
8572
8582
  };
8573
8583
  for (let e of c) {
8574
8584
  if (i === "done") break;
8575
- let c = t(e), g = Q(c.text()), _ = ud(c), v = _ !== null, y = _ !== null && _ >= 2 && _ <= 5, b = c.hasClass("assnatFPFexpogentitre1"), x = c.hasClass("assnatFPFexpogentexte"), S = c.hasClass("assnatPastille"), te = c.hasClass("assnatFPFprojetloiartexte"), ne = c.hasClass("assnatFPFfinartexte"), re = c.is("table"), ie = c.is("img"), ae = c.find("img").length > 0;
8576
- if (!(v && g.length === 0) && !(re && c.find("p.assnatFARTT08Bleu").length > 0) && !(re && ld(c)) && !(x && g.length === 0)) {
8585
+ let c = t(e), g = Q(c.text()), _ = fd(c), v = _ !== null, y = _ !== null && _ >= 2 && _ <= 5, b = c.hasClass("assnatFPFexpogentitre1"), x = c.hasClass("assnatFPFexpogentexte"), S = c.hasClass("assnatPastille"), te = c.hasClass("assnatFPFprojetloiartexte"), ne = c.hasClass("assnatFPFfinartexte"), re = c.is("table"), ie = c.is("img"), ae = c.find("img").length > 0;
8586
+ if (!(v && g.length === 0) && !(re && c.find("p.assnatFARTT08Bleu").length > 0) && !(re && dd(c)) && !(x && g.length === 0)) {
8577
8587
  if (i === "generalExpose") {
8578
8588
  if (_ === 1) {
8579
8589
  let e = g.toLowerCase();
@@ -8581,11 +8591,11 @@ function id(e) {
8581
8591
  a && n.push(a), a = null, i = "hierarchy";
8582
8592
  continue;
8583
8593
  }
8584
- e.includes("exposé général des motifs") && (a ?? (a = ed("D_EXPOSE", "Exposé des motifs", 1, 1)));
8594
+ e.includes("exposé général des motifs") && (a ?? (a = nd("D_EXPOSE", "Exposé des motifs", 1, 1)));
8585
8595
  }
8586
8596
  if (y && (a && n.push(a), a = null, i = "hierarchy"), a) {
8587
8597
  if (ie) {
8588
- let e = pd(c);
8598
+ let e = hd(c);
8589
8599
  if (e) {
8590
8600
  var d;
8591
8601
  (d = a).alineas ?? (d.alineas = []), a.alineas.push(e);
@@ -8594,42 +8604,42 @@ function id(e) {
8594
8604
  var f;
8595
8605
  (f = a).titres ?? (f.titres = []), a.titres.push($(c));
8596
8606
  } else if (b || x) {
8597
- let e = ae ? dd(c) : $(c);
8607
+ let e = ae ? pd(c) : $(c);
8598
8608
  if (e) {
8599
8609
  var p;
8600
8610
  (p = a).alineas ?? (p.alineas = []), a.alineas.push(e);
8601
8611
  }
8602
8612
  } else if (re) {
8603
8613
  var ee;
8604
- (ee = a).alineas ?? (ee.alineas = []), a.alineas.push(nd(c));
8614
+ (ee = a).alineas ?? (ee.alineas = []), a.alineas.push(id(c));
8605
8615
  }
8606
8616
  continue;
8607
8617
  }
8608
8618
  }
8609
- if (td(g)) {
8619
+ if (rd(g)) {
8610
8620
  u(), a && (n.push(a), a = null), i = "done";
8611
8621
  continue;
8612
8622
  }
8613
8623
  if (_ !== 1) {
8614
8624
  if (y) {
8615
8625
  u();
8616
- let e = _ - 2, t = rd[e];
8626
+ let e = _ - 2, t = ad[e];
8617
8627
  for (; r.length > 0 && r[r.length - 1] >= e;) r.pop();
8618
8628
  r.push(e);
8619
- let a = ed(`D_${$u(g)}`, t, e + 1, r.length);
8629
+ let a = nd(`D_${td(g)}`, t, e + 1, r.length);
8620
8630
  a.titres = [$(c)], n.push(a), i = "hierarchy";
8621
8631
  continue;
8622
8632
  }
8623
8633
  if (_ === 6) {
8624
8634
  u();
8625
8635
  let e = r.length + 1;
8626
- o = ed(`D_${$u(g)}`, "Article", 5, e), o.titres = [$(c)], s = [], i = "articleBody";
8636
+ o = nd(`D_${td(g)}`, "Article", 5, e), o.titres = [$(c)], s = [], i = "articleBody";
8627
8637
  continue;
8628
8638
  }
8629
8639
  if (S && i === "articleBody" && o) {
8630
8640
  s.push({
8631
8641
  type: "marker",
8632
- number: cd(g)
8642
+ number: ud(g)
8633
8643
  });
8634
8644
  continue;
8635
8645
  }
@@ -8644,7 +8654,7 @@ function id(e) {
8644
8654
  if (re && i === "articleBody" && o) {
8645
8655
  s.push({
8646
8656
  type: "content",
8647
- content: nd(c)
8657
+ content: id(c)
8648
8658
  });
8649
8659
  continue;
8650
8660
  }
@@ -8665,7 +8675,7 @@ function id(e) {
8665
8675
  }
8666
8676
  if (re) {
8667
8677
  var h;
8668
- (h = o).exposeDesMotifs ?? (h.exposeDesMotifs = []), o.exposeDesMotifs.push(nd(c));
8678
+ (h = o).exposeDesMotifs ?? (h.exposeDesMotifs = []), o.exposeDesMotifs.push(id(c));
8669
8679
  }
8670
8680
  }
8671
8681
  }
@@ -8673,7 +8683,7 @@ function id(e) {
8673
8683
  }
8674
8684
  return u(), a && n.push(a), { subdivisions: n };
8675
8685
  }
8676
- function ad(e) {
8686
+ function sd(e) {
8677
8687
  let t = e.flatMap((e) => e.type === "content" ? [e.content] : []);
8678
8688
  if (e.length - t.length === 0) return t;
8679
8689
  let n = [], r, i;
@@ -8689,43 +8699,43 @@ function ad(e) {
8689
8699
  contents: []
8690
8700
  }, n.push(r), i = a.number;
8691
8701
  }
8692
- od(n);
8702
+ cd(n);
8693
8703
  let a = [];
8694
8704
  for (let e = 0; e < n.length; e++) {
8695
8705
  let r = n[e], i = n[e + 1], o = i ? i.number - r.number : 1;
8696
8706
  if (r.contents.length < o) return t;
8697
8707
  for (let e = 0; e < o - 1; e++) a.push(r.contents[e]);
8698
- a.push(sd(r.contents.slice(o - 1)));
8708
+ a.push(ld(r.contents.slice(o - 1)));
8699
8709
  }
8700
8710
  return a;
8701
8711
  }
8702
- function od(e) {
8712
+ function cd(e) {
8703
8713
  for (let t = 0; t < e.length - 1; t++) {
8704
8714
  let n = e[t].contents, r = e[t + 1].contents, i = n[n.length - 1];
8705
8715
  i?.texte?.trim() === "«" && r.some(({ html: e }) => /<table\b/.test(e ?? "")) && (n.pop(), r.unshift(i));
8706
8716
  }
8707
8717
  }
8708
- function sd(e) {
8718
+ function ld(e) {
8709
8719
  return {
8710
8720
  texte: e.flatMap(({ texte: e }) => e === void 0 ? [] : [e]).join("\n"),
8711
8721
  html: e.flatMap(({ html: e }) => e === void 0 ? [] : [e]).join("\n")
8712
8722
  };
8713
8723
  }
8714
- function cd(e) {
8724
+ function ud(e) {
8715
8725
  let t = /^\((\d+)\)$/.exec(e);
8716
8726
  if (!t) return;
8717
8727
  let n = Number(t[1]);
8718
8728
  return Number.isSafeInteger(n) && n > 0 ? n : void 0;
8719
8729
  }
8720
- function ld(e) {
8730
+ function dd(e) {
8721
8731
  let t = e.children("tbody").children("tr").add(e.children("tr"));
8722
8732
  return t.length === 1 && t.children("td").length === 1 && e.find("h6, .assnatFPFexpogentexte").length > 0;
8723
8733
  }
8724
- function ud(e) {
8734
+ function fd(e) {
8725
8735
  for (let t = 1; t <= 6; t++) if (e.is(`h${t}`)) return t;
8726
8736
  return null;
8727
8737
  }
8728
- function dd(e) {
8738
+ function pd(e) {
8729
8739
  let t = e.clone();
8730
8740
  t.find("img").remove();
8731
8741
  let n = Q(t.text());
@@ -8734,14 +8744,14 @@ function dd(e) {
8734
8744
  html: Q(t.html())
8735
8745
  } : null;
8736
8746
  }
8737
- function fd(e) {
8747
+ function md(e) {
8738
8748
  if (!e || !/^\d+$/.test(e)) return;
8739
8749
  let t = Number(e);
8740
8750
  return t > 0 ? t : void 0;
8741
8751
  }
8742
- function pd(e) {
8752
+ function hd(e) {
8743
8753
  if (!e.attr("src")) return null;
8744
- let t = fd(e.attr("width")), n = fd(e.attr("height"));
8754
+ let t = md(e.attr("width")), n = md(e.attr("height"));
8745
8755
  return t === 15 && n === 15 || t === 2 && n === 138 ? null : {
8746
8756
  texte: Q(e.attr("alt") ?? ""),
8747
8757
  html: e.prop("outerHTML") || ""
@@ -8749,18 +8759,18 @@ function pd(e) {
8749
8759
  }
8750
8760
  //#endregion
8751
8761
  //#region src/parsers/plf/later_stage.ts
8752
- function md(e) {
8762
+ function gd(e) {
8753
8763
  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();
8754
8764
  for (let e of c) {
8755
8765
  let c = t(e), l = Q(c.text());
8756
- if (l.length === 0 || (!s && td(l) && (i && (n.push(i), i = null), s = !0), s)) continue;
8766
+ if (l.length === 0 || (!s && rd(l) && (i && (n.push(i), i = null), s = !0), s)) continue;
8757
8767
  let u = c.hasClass("assnat2PartieNum"), d = c.hasClass("assnat2PartieIntit"), f = c.hasClass("assnat4TitreNum") || c.hasClass("assnat4TitreNum0"), p = c.hasClass("assnat4TitreIntit"), ee = c.hasClass("assnat9ArticleNum"), m = c.hasClass("assnatLoiTexte"), h = c.is("table");
8758
8768
  if (d) {
8759
8769
  for (i && (n.push(i), i = null); r.length > 0 && r[r.length - 1] >= 0;) r.pop();
8760
8770
  r.push(0);
8761
- let e = hd(a, $(c));
8771
+ let e = _d(a, $(c));
8762
8772
  a = null, o = null;
8763
- let t = ed(`D_${$u(e.texte ?? l)}`, "Partie", 1, r.length);
8773
+ let t = nd(`D_${td(e.texte ?? l)}`, "Partie", 1, r.length);
8764
8774
  t.titres = [e], n.push(t);
8765
8775
  continue;
8766
8776
  }
@@ -8771,9 +8781,9 @@ function md(e) {
8771
8781
  if (p) {
8772
8782
  for (i && (n.push(i), i = null); r.length > 0 && r[r.length - 1] >= 1;) r.pop();
8773
8783
  r.push(1);
8774
- let e = hd(o, $(c));
8784
+ let e = _d(o, $(c));
8775
8785
  o = null;
8776
- let t = ed(`D_${$u(e.texte ?? l)}`, "Titre", 2, r.length);
8786
+ let t = nd(`D_${td(e.texte ?? l)}`, "Titre", 2, r.length);
8777
8787
  t.titres = [e], n.push(t);
8778
8788
  continue;
8779
8789
  }
@@ -8784,7 +8794,7 @@ function md(e) {
8784
8794
  if (ee) {
8785
8795
  i && n.push(i);
8786
8796
  let e = r.length + 1;
8787
- i = ed(`D_${$u(l)}`, "Article", 5, e), i.titres = [$(c)];
8797
+ i = nd(`D_${td(l)}`, "Article", 5, e), i.titres = [$(c)];
8788
8798
  continue;
8789
8799
  }
8790
8800
  if (m) {
@@ -8794,7 +8804,7 @@ function md(e) {
8794
8804
  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;
8795
8805
  for (; r.length > 0 && r[r.length - 1] >= d;) r.pop();
8796
8806
  r.push(d);
8797
- let f = ed(`D_${$u(l)}`, u, d + 1, r.length);
8807
+ let f = nd(`D_${td(l)}`, u, d + 1, r.length);
8798
8808
  f.titres = [$(c)], n.push(f);
8799
8809
  continue;
8800
8810
  }
@@ -8802,14 +8812,14 @@ function md(e) {
8802
8812
  continue;
8803
8813
  }
8804
8814
  if (h && i) {
8805
- i.alineas = i.alineas || [], i.alineas.push(nd(c));
8815
+ i.alineas = i.alineas || [], i.alineas.push(id(c));
8806
8816
  continue;
8807
8817
  }
8808
8818
  (/assnat5Chapitre(Intit|Num)/.test(c.attr("class") ?? "") || /assnat6Section(Intit|Num)/.test(c.attr("class") ?? "")) && i && (i.alineas = i.alineas || [], i.alineas.push($(c)));
8809
8819
  }
8810
8820
  return i && n.push(i), { subdivisions: n };
8811
8821
  }
8812
- function hd(e, t) {
8822
+ function _d(e, t) {
8813
8823
  return e === null ? t : {
8814
8824
  texte: `${e.texte} : ${t.texte}`,
8815
8825
  html: `${e.html} : ${t.html}`
@@ -8817,20 +8827,20 @@ function hd(e, t) {
8817
8827
  }
8818
8828
  //#endregion
8819
8829
  //#region src/parsers/plf/variant_detection.ts
8820
- var gd = [
8830
+ var vd = [
8821
8831
  "assnatFPFexpogentexte",
8822
8832
  "assnatFPFexpogentitre1",
8823
8833
  "assnatFPFexpogentitre2",
8824
8834
  "assnatFPFexpogentitre3",
8825
8835
  "assnatFPFexpogentitre4"
8826
8836
  ];
8827
- function _d(e) {
8837
+ function yd(e) {
8828
8838
  let t = Nu(Pu(e));
8829
- 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(gd.map((e) => `.${e}`).join(", ")).length > 0 ? "depot" : "laterStage";
8839
+ 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(vd.map((e) => `.${e}`).join(", ")).length > 0 ? "depot" : "laterStage";
8830
8840
  }
8831
8841
  //#endregion
8832
8842
  //#region src/parsers/plf/credits.ts
8833
- var vd = {
8843
+ var bd = {
8834
8844
  bg: {
8835
8845
  budgetType: "budgetGeneral",
8836
8846
  libelle: "Budget général"
@@ -8848,15 +8858,15 @@ var vd = {
8848
8858
  libelle: "Comptes de concours financiers"
8849
8859
  }
8850
8860
  };
8851
- function yd(e) {
8861
+ function xd(e) {
8852
8862
  if (!e) return [];
8853
- let t = Nu(Pu(e)), n = Td(t);
8863
+ let t = Nu(Pu(e)), n = Dd(t);
8854
8864
  if (n.length === 0) return [];
8855
8865
  let r = [];
8856
8866
  for (let e of n) {
8857
8867
  let n = [], i;
8858
8868
  for (let r of e.tableEls) {
8859
- let e = Cd(t, r);
8869
+ let e = Td(t, r);
8860
8870
  n.push(...e.missions), e.total && (i = e.total);
8861
8871
  }
8862
8872
  n.length === 0 && !e.estConformeVersionPrecedente || r.push({
@@ -8872,7 +8882,7 @@ function yd(e) {
8872
8882
  }
8873
8883
  return r;
8874
8884
  }
8875
- function bd(e) {
8885
+ function Sd(e) {
8876
8886
  let t = Q(e).replace(/[\u2212\u2011]/g, "-").replace(/\s/g, "").replace(/[^0-9,.-]/g, ""), n = (t.match(/,/g) ?? []).length;
8877
8887
  if (n > 1) return;
8878
8888
  let r = n === 1 ? t.replace(/\./g, "").replace(",", ".") : t;
@@ -8880,23 +8890,23 @@ function bd(e) {
8880
8890
  let i = Number(r);
8881
8891
  return Number.isNaN(i) ? void 0 : i;
8882
8892
  }
8883
- function xd(e) {
8893
+ function Cd(e) {
8884
8894
  let t = Q(e);
8885
8895
  if (!/\(\s*ligne\s+supprim(?:ée|ee)\s*\)\s*$/i.test(t)) return t.replace(/\s*\(\s*ligne\s+nouvelle\s*\)\s*$/i, "").trim();
8886
8896
  }
8887
- function Sd(e, t) {
8888
- let n = bd(t(e[1]).text()), r = bd(t(e[2]).text());
8897
+ function wd(e, t) {
8898
+ let n = Sd(t(e[1]).text()), r = Sd(t(e[2]).text());
8889
8899
  return e.length >= 5 ? {
8890
8900
  autorisationEngagement: n,
8891
8901
  creditPaiement: r,
8892
- autorisationEngagementAnnule: bd(t(e[3]).text()),
8893
- creditPaiementAnnule: bd(t(e[4]).text())
8902
+ autorisationEngagementAnnule: Sd(t(e[3]).text()),
8903
+ creditPaiementAnnule: Sd(t(e[4]).text())
8894
8904
  } : {
8895
8905
  autorisationEngagement: n,
8896
8906
  creditPaiement: r
8897
8907
  };
8898
8908
  }
8899
- function Cd(e, t) {
8909
+ function Td(e, t) {
8900
8910
  let n = [], r = null, i = null, a, o = e(t).find("tbody tr").toArray(), s = o.some((t) => {
8901
8911
  let n = (e(t).find("td").first().attr("style") || "").replace(/[\n\t]/g, " ");
8902
8912
  return /border-top/.test(n);
@@ -8906,7 +8916,7 @@ function Cd(e, t) {
8906
8916
  if (o.length < 3) continue;
8907
8917
  let c = e(o[0]), l = (c.attr("style") || "").replace(/[\n\t]/g, " "), u = Q(c.text());
8908
8918
  if (!u) continue;
8909
- let d = /^total/i.test(u), f = Sd(o, e);
8919
+ let d = /^total/i.test(u), f = wd(o, e);
8910
8920
  if (d) {
8911
8921
  a = f;
8912
8922
  continue;
@@ -8920,7 +8930,7 @@ function Cd(e, t) {
8920
8930
  }
8921
8931
  if (s ? /border-top/.test(l) : /border-bottom/.test(l)) {
8922
8932
  r && n.push(r);
8923
- let e = xd(c.text());
8933
+ let e = Cd(c.text());
8924
8934
  if (e === void 0) {
8925
8935
  r = null, i = null;
8926
8936
  continue;
@@ -8934,7 +8944,7 @@ function Cd(e, t) {
8934
8944
  continue;
8935
8945
  }
8936
8946
  if (r) {
8937
- let e = xd(c.text());
8947
+ let e = Cd(c.text());
8938
8948
  if (e === void 0) {
8939
8949
  i = null;
8940
8950
  continue;
@@ -8950,11 +8960,11 @@ function Cd(e, t) {
8950
8960
  total: a
8951
8961
  };
8952
8962
  }
8953
- function wd(e, t) {
8963
+ function Ed(e, t) {
8954
8964
  let n = e(t).find("tr").slice(0, 3).find("th, td").toArray().map((t) => Q(e(t).text()).toLocaleLowerCase("fr"));
8955
8965
  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"));
8956
8966
  }
8957
- function Td(e) {
8967
+ function Dd(e) {
8958
8968
  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);
8959
8969
  for (let o of a) {
8960
8970
  let a = e(o);
@@ -8971,7 +8981,7 @@ function Td(e) {
8971
8981
  for (let t of e) {
8972
8982
  let e = i.get(t);
8973
8983
  e ? e.estConformeVersionPrecedente = !0 : i.set(t, {
8974
- ...vd[t],
8984
+ ...bd[t],
8975
8985
  tableEls: [],
8976
8986
  estConformeVersionPrecedente: !0
8977
8987
  });
@@ -8987,7 +8997,7 @@ function Td(e) {
8987
8997
  s !== /COMPTES\s+DE\s+CONCOURS\s+FINANCIERS/i.test(e) && (n = s ? "cas" : "ccf");
8988
8998
  continue;
8989
8999
  }
8990
- if (!wd(e, o)) continue;
9000
+ if (!Ed(e, o)) continue;
8991
9001
  let s = t === "B" ? "bg" : t === "C" ? "ba" : t === "D" ? n : void 0;
8992
9002
  if (!s) continue;
8993
9003
  r = !0;
@@ -8997,7 +9007,7 @@ function Td(e) {
8997
9007
  continue;
8998
9008
  }
8999
9009
  i.set(s, {
9000
- ...vd[s],
9010
+ ...bd[s],
9001
9011
  tableEls: [o],
9002
9012
  estConformeVersionPrecedente: !1
9003
9013
  });
@@ -9006,8 +9016,8 @@ function Td(e) {
9006
9016
  }
9007
9017
  //#endregion
9008
9018
  //#region src/parsers/plf/index.ts
9009
- function Ed(e) {
9010
- return e ? _d(e) === "depot" ? id(e) : md(e) : { subdivisions: [] };
9019
+ function Od(e) {
9020
+ return e ? yd(e) === "depot" ? od(e) : gd(e) : { subdivisions: [] };
9011
9021
  }
9012
9022
  //#endregion
9013
- export { Zu as iterRechercheAmendements, Qu as iterRechercheRawAmendements, Ed as parsePlf, yd as parsePlfCredits, qu as parseTexte };
9023
+ export { $u as iterRechercheAmendements, ed as iterRechercheRawAmendements, Od as parsePlf, xd as parsePlfCredits, qu as parseTexte };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tricoteuses/assemblee",
3
- "version": "3.7.2",
3
+ "version": "3.8.0",
4
4
  "description": "Retrieve, clean up & handle French Assemblée nationale's open data",
5
5
  "keywords": [
6
6
  "Assemblée nationale",