@tricoteuses/tisseuse 0.16.1 → 0.17.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.
@@ -9866,17 +9866,34 @@ function fp(e) {
9866
9866
  }
9867
9867
  return n;
9868
9868
  }
9869
- var pp = Ic(Js((e, t, n, r) => t._useHtmlParser2 ? pa(e, t) : up(e, t, n, r)), (e, t) => t._useHtmlParser2 ? fr(e, t) : fp(e));
9869
+ var pp = Ic(Js((e, t, n, r) => t._useHtmlParser2 ? pa(e, t) : up(e, t, n, r)), (e, t) => t._useHtmlParser2 ? fr(e, t) : fp(e)), mp = _("(?:mégawattheures?|kilowattheures?|hectolitres?|kilogrammes?|kilowatts?|millilitres?|grammes?|mètres?(?: cubes?| carrés?)?|tonnes?|litres?|unités?|pourcentage|g\\s*/\\s*km|GWh(?:\\s*/\\s*jour)?|MWh|kWh|kVA|ETPT|CV|kg|km|m[²³]|%)", { flags: "i" }), hp = o(_("(?:euros?|centimes d['’]euros?|€|M€)", { flags: "i" }), a([
9870
+ _("(?:milliers|millions|milliards)", { flags: "i" }),
9871
+ T,
9872
+ _("d['’]euros?", { flags: "i" })
9873
+ ])), gp = a([
9874
+ o(_(String.raw`\(en `, { flags: "i" }), _(String.raw`\(\s*(?=€|M€)`, { flags: "i" })),
9875
+ o(a([hp, w(o(a([
9876
+ T,
9877
+ _("par ", { flags: "i" }),
9878
+ mp
9879
+ ]), a([_(String.raw`\s*/\s*(?:1\s*000\s*)?`), mp])), { default: null })]), mp),
9880
+ w(_(String.raw`\.`), { default: null }),
9881
+ _(String.raw`\)`)
9882
+ ]);
9883
+ function _p(e) {
9884
+ let t = new S(e);
9885
+ return gp(t) !== void 0 && !t.remaining().trim();
9886
+ }
9870
9887
  //#endregion
9871
9888
  //#region src/lib/extractors/article_portions.ts
9872
- function mp(e, t) {
9889
+ function vp(e, t) {
9873
9890
  return e.length === t.length && e.every((e, n) => {
9874
9891
  let r = t[n];
9875
9892
  return e.type === r?.type && e.index === r.index && e.num === r.num && e.relative === r.relative && e.present === r.present;
9876
9893
  });
9877
9894
  }
9878
- function hp(e) {
9879
- if (e.count === void 0 || e.count <= 1 || !mp(e.first, e.last)) return {
9895
+ function yp(e) {
9896
+ if (e.count === void 0 || e.count <= 1 || !vp(e.first, e.last)) return {
9880
9897
  first: e.first,
9881
9898
  last: e.last
9882
9899
  };
@@ -9903,7 +9920,7 @@ function hp(e) {
9903
9920
  } : n)
9904
9921
  };
9905
9922
  }
9906
- function gp(e, t) {
9923
+ function bp(e, t) {
9907
9924
  if (t <= 1) return e;
9908
9925
  let n = e.findLastIndex((e) => e.type === "alinéa" && typeof e.index == "number");
9909
9926
  if (n < 0) return e;
@@ -9913,42 +9930,42 @@ function gp(e, t) {
9913
9930
  index: e.index - t + 1
9914
9931
  } : e);
9915
9932
  }
9916
- var _p = String.raw`[A-Zİ]|[a-z]`, vp = new RegExp(String.raw`^\s*([IVXLCDM]+|${_p}|\d+)(?:\s+(?:${be}))?(?:\s+\([^)]+\))?(?:\s*(?:°|\.|\)|-|–|—))+(?:\s+(?:${be}))?(?:\s+\([^)]+\))?(?:\s+|(?=[\p{L}\p{N}]))`, "iu"), yp = /^\s*-\s*/u, bp = /^(partie|livre|titre|sous-titre|chapitre|section|sous-section|paragraphe|sous-paragraphe|sous-sous-paragraphe)\b/i;
9917
- function xp(e) {
9933
+ var xp = String.raw`[A-Zİ]|[a-z]`, Sp = new RegExp(String.raw`^\s*([IVXLCDM]+|${xp}|\d+)(?:\s+(?:${be}))?(?:\s+\([^)]+\))?(?:\s*(?:°|\.|\)|-|–|—))+(?:\s+(?:${be}))?(?:\s+\([^)]+\))?(?:\s+|(?=[\p{L}\p{N}]))`, "iu"), Cp = /^\s*-\s*/u, wp = /^(partie|livre|titre|sous-titre|chapitre|section|sous-section|paragraphe|sous-paragraphe|sous-sous-paragraphe)\b/i;
9934
+ function Tp(e) {
9918
9935
  return /^[IVXLCDM]+$/i.test(e);
9919
9936
  }
9920
- function Sp(e) {
9921
- return Cp(e) !== void 0;
9937
+ function Ep(e) {
9938
+ return Dp(e) !== void 0;
9922
9939
  }
9923
- function Cp(e) {
9924
- let t = e.trim().match(vp);
9940
+ function Dp(e) {
9941
+ let t = e.trim().match(Sp);
9925
9942
  if (!t) return;
9926
- let n = Tp(t[0]), r = n?.num ?? t[1];
9943
+ let n = kp(t[0]), r = n?.num ?? t[1];
9927
9944
  if (!r) return;
9928
- let i = n?.index ?? Ep(r);
9945
+ let i = n?.index ?? Ap(r);
9929
9946
  if (!(n === null && i === void 0)) return {
9930
9947
  ...i === void 0 ? {} : { index: i },
9931
- level: Dp(t[0] ?? r),
9948
+ level: jp(t[0] ?? r),
9932
9949
  prefix: t[0],
9933
9950
  restText: e.trim().slice(t[0].length).trim(),
9934
9951
  token: r
9935
9952
  };
9936
9953
  }
9937
- function wp(e) {
9954
+ function Op(e) {
9938
9955
  return _e(e).output.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
9939
9956
  }
9940
- function Tp(e) {
9941
- let t = h(e, Et) ?? h(wp(e), Et);
9957
+ function kp(e) {
9958
+ let t = h(e, Et) ?? h(Op(e), Et);
9942
9959
  return t && typeof t == "object" && t.type === "item" && typeof t.index == "number" && typeof t.num == "string" ? {
9943
9960
  num: t.num,
9944
9961
  index: t.index
9945
9962
  } : null;
9946
9963
  }
9947
- function Ep(e) {
9948
- let t = e.trim(), n = t.split(/\s+/), r = wp(n[0] ? n[0].replace(/[^\p{L}\p{N}]+/gu, "") : t), i = n.length > 1 ? n.slice(1).join(" ") : void 0, a = (() => {
9964
+ function Ap(e) {
9965
+ let t = e.trim(), n = t.split(/\s+/), r = Op(n[0] ? n[0].replace(/[^\p{L}\p{N}]+/gu, "") : t), i = n.length > 1 ? n.slice(1).join(" ") : void 0, a = (() => {
9949
9966
  if (/^\d+$/.test(r)) return Number(r);
9950
9967
  if (/^[A-Z]$/i.test(r)) return r.toLowerCase().charCodeAt(0) - 97 + 1;
9951
- if (xp(r)) return C(r.toUpperCase());
9968
+ if (Tp(r)) return C(r.toUpperCase());
9952
9969
  })();
9953
9970
  if (a === void 0) return;
9954
9971
  if (!i) return a;
@@ -9959,24 +9976,24 @@ function Ep(e) {
9959
9976
  }
9960
9977
  return a;
9961
9978
  }
9962
- function Dp(e) {
9963
- let t = e.trim().split(/\s+/)[0] ?? e, n = t.replace(/[^\p{L}\p{N}]+/gu, ""), r = wp(n);
9964
- return /^[ivxlcdm]+$/.test(r) && (r.length > 1 || /^[ivx]$/.test(r)) ? 105 : /^[IVXLCDM]+$/.test(n) && (n.length > 1 || /^[IVX]$/.test(n)) ? 100 : /^[A-Z]$/.test(r) ? 101 : /^\d+$/.test(r) && /°/.test(t) ? 103 : /^\d+$/.test(r) ? 102 : /^[a-z]$/.test(r) ? 104 : xp(r) ? 100 : 105;
9979
+ function jp(e) {
9980
+ let t = e.trim().split(/\s+/)[0] ?? e, n = t.replace(/[^\p{L}\p{N}]+/gu, ""), r = Op(n);
9981
+ return /^[ivxlcdm]+$/.test(r) && (r.length > 1 || /^[ivx]$/.test(r)) ? 105 : /^[IVXLCDM]+$/.test(n) && (n.length > 1 || /^[IVX]$/.test(n)) ? 100 : /^[A-Z]$/.test(r) ? 101 : /^\d+$/.test(r) && /°/.test(t) ? 103 : /^\d+$/.test(r) ? 102 : /^[a-z]$/.test(r) ? 104 : Tp(r) ? 100 : 105;
9965
9982
  }
9966
- function Op(e) {
9983
+ function Mp(e) {
9967
9984
  return e.children.filter((e) => e.type === "alinéa").length + 1;
9968
9985
  }
9969
- function kp(e, t, n) {
9986
+ function Np(e, t, n) {
9970
9987
  let r = new RegExp(String.raw`</${t}\s*>`, "iu");
9971
9988
  r.lastIndex = n;
9972
9989
  let i = r.exec(e.slice(n));
9973
9990
  return i ? n + i.index + i[0].length : e.length;
9974
9991
  }
9975
- function Ap(e) {
9992
+ function Pp(e) {
9976
9993
  return pp(e).text().replace(/\s+/g, " ").trim();
9977
9994
  }
9978
- function jp(e, t, n, r, i, a = {}) {
9979
- let o = Ap(t);
9995
+ function Fp(e, t, n, r, i, a = {}) {
9996
+ let o = Pp(t);
9980
9997
  o && e.push({
9981
9998
  html: t,
9982
9999
  htmlStart: n,
@@ -9986,9 +10003,9 @@ function jp(e, t, n, r, i, a = {}) {
9986
10003
  ...a
9987
10004
  });
9988
10005
  }
9989
- function Mp(e) {
10006
+ function Ip(e) {
9990
10007
  let t = [], n = /<\s*(table|p|br)\b[^>]*>/giu, r = 0, i = 0, a = null, o = (n) => {
9991
- a !== null && (jp(t, e.slice(a, n), a, n, -1), a = null);
10008
+ a !== null && (Fp(t, e.slice(a, n), a, n, -1), a = null);
9992
10009
  };
9993
10010
  for (; i < e.length;) {
9994
10011
  n.lastIndex = i;
@@ -10000,25 +10017,55 @@ function Mp(e) {
10000
10017
  continue;
10001
10018
  }
10002
10019
  if (o(c), u === "table") {
10003
- let n = kp(e, "table", c + l.length);
10004
- jp(t, e.slice(c, n), c, n, -1, { isTable: !0 }), i = n;
10020
+ let n = Np(e, "table", c + l.length);
10021
+ Fp(t, e.slice(c, n), c, n, -1, { isTable: !0 }), i = n;
10005
10022
  continue;
10006
10023
  }
10007
10024
  if (u === "p") {
10008
- let n = kp(e, "p", c + l.length), a = c + l.length, o = /<\/p\s*>\s*$/iu.exec(e.slice(a, n)), s = o ? a + o.index : n, u = e.slice(a, s), d = /<br\s*\/?>/giu, f = 0, p;
10025
+ let n = Np(e, "p", c + l.length), a = c + l.length, o = /<\/p\s*>\s*$/iu.exec(e.slice(a, n)), s = o ? a + o.index : n, u = e.slice(a, s), d = /<br\s*\/?>/giu, f = 0, p;
10009
10026
  for (; (p = d.exec(u)) !== null;) {
10010
10027
  let e = a + f, n = a + p.index;
10011
- jp(t, u.slice(f, p.index), e, n, r), f = p.index + p[0].length;
10028
+ Fp(t, u.slice(f, p.index), e, n, r), f = p.index + p[0].length;
10012
10029
  }
10013
- jp(t, u.slice(f), a + f, s, r), r += 1, i = n;
10030
+ Fp(t, u.slice(f), a + f, s, r), r += 1, i = n;
10014
10031
  }
10015
10032
  }
10016
10033
  return i < e.length && a === null && (a = i), o(e.length), t;
10017
10034
  }
10018
- function Np(e, t, n = t.text) {
10035
+ function Lp(e) {
10036
+ let t = Ip(e), n = t.flatMap((e, n) => {
10037
+ let r = t[n + 1];
10038
+ return e.paragraphIndex >= 0 && r?.isTable && _p(e.text) ? [{
10039
+ note: e,
10040
+ table: r
10041
+ }] : [];
10042
+ });
10043
+ if (n.length === 0) return [];
10044
+ let r = pp(e, { sourceCodeLocationInfo: !0 }), i = r("p").toArray(), a = [];
10045
+ for (let { note: t, table: o } of n) {
10046
+ let n = i.find((e) => {
10047
+ let n = e.sourceCodeLocation;
10048
+ return n?.startTag?.endOffset !== void 0 && n.startTag.endOffset <= t.htmlStart && n.endOffset >= t.htmlStop;
10049
+ }), s = n?.sourceCodeLocation;
10050
+ if (!n || !s) continue;
10051
+ let c = pp(e.slice(s.endOffset, o.htmlStart));
10052
+ r(n).text().replace(/\s+/gu, " ").trim() !== t.text || c.root().text().trim() !== "" || !c("*").toArray().every((e) => "tagName" in e && [
10053
+ "html",
10054
+ "head",
10055
+ "body",
10056
+ "div",
10057
+ "br"
10058
+ ].includes(e.tagName)) || a.push({
10059
+ start: s.startOffset,
10060
+ stop: s.endOffset
10061
+ });
10062
+ }
10063
+ return a;
10064
+ }
10065
+ function Rp(e, t, n = t.text) {
10019
10066
  return {
10020
10067
  type: "alinéa",
10021
- index: Op(e),
10068
+ index: Mp(e),
10022
10069
  text: n,
10023
10070
  html: t.html,
10024
10071
  paragraphIndex: t.paragraphIndex,
@@ -10027,17 +10074,17 @@ function Np(e, t, n = t.text) {
10027
10074
  lineIndex: t.htmlStart
10028
10075
  };
10029
10076
  }
10030
- function Pp(e) {
10077
+ function zp(e) {
10031
10078
  let t = {
10032
10079
  type: "article",
10033
10080
  children: []
10034
10081
  }, n = [{
10035
10082
  level: -1,
10036
10083
  node: t
10037
- }], r = Mp(e), i = (e, t, r) => {
10084
+ }], r = Lp(e), i = Ip(e), a = (e, t, r) => {
10038
10085
  let i = e, a = t;
10039
10086
  for (;;) {
10040
- let e = Cp(a);
10087
+ let e = Dp(a);
10041
10088
  if (!e) break;
10042
10089
  let t = {
10043
10090
  type: "item",
@@ -10051,41 +10098,42 @@ function Pp(e) {
10051
10098
  node: t
10052
10099
  }), i = t, a = e.restText;
10053
10100
  }
10054
- a && i.children.push(Np(i, r, a));
10101
+ a && i.children.push(Rp(i, r, a));
10055
10102
  };
10056
- for (let e of r) {
10057
- let r = e.text;
10103
+ for (let e of i) {
10104
+ if (e.paragraphIndex >= 0 && r.some(({ start: t, stop: n }) => t < e.htmlStart && e.htmlStop < n)) continue;
10105
+ let i = e.text;
10058
10106
  if (e.isTable) {
10059
- let i = n[n.length - 1]?.node ?? t;
10060
- i.children.push(Np(i, e, r));
10107
+ let r = n[n.length - 1]?.node ?? t;
10108
+ r.children.push(Rp(r, e, i));
10061
10109
  continue;
10062
10110
  }
10063
- let a = Cp(r);
10064
- if (a) {
10065
- let r = a.level;
10111
+ let o = Dp(i);
10112
+ if (o) {
10113
+ let r = o.level;
10066
10114
  for (; n.length > 0 && n[n.length - 1].level >= r;) n.pop();
10067
- let o = n[n.length - 1]?.node ?? t, s = {
10115
+ let i = n[n.length - 1]?.node ?? t, s = {
10068
10116
  type: "item",
10069
- index: a.index,
10070
- num: a.token,
10117
+ index: o.index,
10118
+ num: o.token,
10071
10119
  label: void 0,
10072
10120
  children: []
10073
10121
  };
10074
- o.children.push(s), n.push({
10122
+ i.children.push(s), n.push({
10075
10123
  level: r,
10076
10124
  node: s
10077
10125
  });
10078
- let c = a.restText;
10079
- c && (bp.test(c) ? s.label = c : Cp(c) ? i(s, c, e) : s.children.push(Np(s, e, c)));
10126
+ let c = o.restText;
10127
+ c && (wp.test(c) ? s.label = c : Dp(c) ? a(s, c, e) : s.children.push(Rp(s, e, c)));
10080
10128
  continue;
10081
10129
  }
10082
- let o = n[n.length - 1]?.node ?? t;
10083
- o.children.push(Np(o, e, r));
10130
+ let s = n[n.length - 1]?.node ?? t;
10131
+ s.children.push(Rp(s, e, i));
10084
10132
  }
10085
10133
  return t;
10086
10134
  }
10087
- function Fp(e) {
10088
- return e.type === "parent-enfant" ? Ip(e.child) ? Fp(e.child) : [...Fp(e.parent), ...Fp(e.child)] : lt(e) && (ut(e) || dt(e)) ? [{
10135
+ function Bp(e) {
10136
+ return e.type === "parent-enfant" ? Vp(e.child) ? Bp(e.child) : [...Bp(e.parent), ...Bp(e.child)] : lt(e) && (ut(e) || dt(e)) ? [{
10089
10137
  type: e.type,
10090
10138
  index: e.index,
10091
10139
  num: e.num,
@@ -10093,14 +10141,14 @@ function Fp(e) {
10093
10141
  present: e.present
10094
10142
  }] : [];
10095
10143
  }
10096
- function Ip(e) {
10097
- return e.type === "reference_et_action" ? Ip(e.reference) : e.type === "parent-enfant" ? Ip(e.parent) || Ip(e.child) : lt(e) && e.type === "article";
10144
+ function Vp(e) {
10145
+ return e.type === "reference_et_action" ? Vp(e.reference) : e.type === "parent-enfant" ? Vp(e.parent) || Vp(e.child) : lt(e) && e.type === "article";
10098
10146
  }
10099
- function Lp(e) {
10100
- if (e.type === "reference_et_action") return Lp(e.reference);
10147
+ function Hp(e) {
10148
+ if (e.type === "reference_et_action") return Hp(e.reference);
10101
10149
  if (e.type === "parent-enfant") {
10102
- if (Ip(e.child)) return Lp(e.child);
10103
- let t = Lp(e.parent), n = Lp(e.child);
10150
+ if (Vp(e.child)) return Hp(e.child);
10151
+ let t = Hp(e.parent), n = Hp(e.child);
10104
10152
  if (t.length === 0) return n;
10105
10153
  if (n.length === 0) return t;
10106
10154
  let r = [];
@@ -10131,7 +10179,7 @@ function Lp(e) {
10131
10179
  return r;
10132
10180
  }
10133
10181
  if (e.type === "bounded-interval") {
10134
- let t = Fp(e.first), n = Fp(e.last);
10182
+ let t = Bp(e.first), n = Bp(e.last);
10135
10183
  return t.length === 0 || n.length === 0 ? [] : [{
10136
10184
  kind: "range",
10137
10185
  first: t,
@@ -10139,7 +10187,7 @@ function Lp(e) {
10139
10187
  }];
10140
10188
  }
10141
10189
  if (e.type === "counted-interval") {
10142
- let t = Fp(e.first), n = gp(t, e.count);
10190
+ let t = Bp(e.first), n = bp(t, e.count);
10143
10191
  return n.length === 0 ? [] : [{
10144
10192
  kind: "range",
10145
10193
  first: n,
@@ -10147,15 +10195,15 @@ function Lp(e) {
10147
10195
  count: e.count
10148
10196
  }];
10149
10197
  }
10150
- if (e.type === "enumeration") return [...Lp(e.left), ...Lp(e.right)];
10151
- if (e.type === "exclusion") return Lp(e.left);
10152
- let t = Fp(e);
10198
+ if (e.type === "enumeration") return [...Hp(e.left), ...Hp(e.right)];
10199
+ if (e.type === "exclusion") return Hp(e.left);
10200
+ let t = Bp(e);
10153
10201
  return t.length === 0 ? [] : [{
10154
10202
  kind: "single",
10155
10203
  steps: t
10156
10204
  }];
10157
10205
  }
10158
- var Rp = new Set([
10206
+ var Up = new Set([
10159
10207
  "I",
10160
10208
  "V",
10161
10209
  "X",
@@ -10164,18 +10212,18 @@ var Rp = new Set([
10164
10212
  "D",
10165
10213
  "M"
10166
10214
  ]);
10167
- function zp(e) {
10215
+ function Wp(e) {
10168
10216
  return e ? /^([A-Z])(?:\s+\p{L}+)?$/iu.exec(e.trim())?.[1]?.toUpperCase() ?? null : null;
10169
10217
  }
10170
- function Bp(e) {
10218
+ function Gp(e) {
10171
10219
  return e.toLowerCase().charCodeAt(0) - 97 + 1;
10172
10220
  }
10173
- function Vp(e) {
10221
+ function Kp(e) {
10174
10222
  let t = /* @__PURE__ */ new Map();
10175
10223
  for (let [n, r] of e.entries()) {
10176
10224
  if (r.kind !== "single") continue;
10177
10225
  let e = r.steps.at(-1);
10178
- if (e?.type !== "item" || !zp(e.num)) continue;
10226
+ if (e?.type !== "item" || !Wp(e.num)) continue;
10179
10227
  let i = JSON.stringify(r.steps.slice(0, -1)), a = t.get(i);
10180
10228
  a ? a.push({
10181
10229
  index: n,
@@ -10187,24 +10235,24 @@ function Vp(e) {
10187
10235
  }
10188
10236
  let n = [...e];
10189
10237
  for (let e of t.values()) if (e.some(({ step: e }) => {
10190
- let t = zp(e.num);
10191
- return t !== null && !Rp.has(t);
10238
+ let t = Wp(e.num);
10239
+ return t !== null && !Up.has(t);
10192
10240
  })) for (let { index: t, step: r } of e) {
10193
- let e = zp(r.num);
10194
- if (!e || !Rp.has(e)) continue;
10241
+ let e = Wp(r.num);
10242
+ if (!e || !Up.has(e)) continue;
10195
10243
  let i = n[t];
10196
10244
  i?.kind === "single" && (n[t] = {
10197
10245
  ...i,
10198
10246
  steps: i.steps.map((t, n) => n === i.steps.length - 1 ? {
10199
10247
  ...t,
10200
- index: Bp(e)
10248
+ index: Gp(e)
10201
10249
  } : t)
10202
10250
  });
10203
10251
  }
10204
10252
  return n;
10205
10253
  }
10206
- function Hp(e) {
10207
- let t = Vp(Lp(e));
10254
+ function qp(e) {
10255
+ let t = Kp(Hp(e));
10208
10256
  if (t.length === 0) return t;
10209
10257
  let n = t[0];
10210
10258
  if (n?.kind === "single" && n.steps.length > 1) {
@@ -10216,17 +10264,17 @@ function Hp(e) {
10216
10264
  }
10217
10265
  return t;
10218
10266
  }
10219
- function Up(e, t) {
10267
+ function Jp(e, t) {
10220
10268
  if (t.num !== void 0 && e.num !== void 0) {
10221
- let n = (e) => wp(e).toLowerCase().replace(/[.)]/g, "").trim();
10269
+ let n = (e) => Op(e).toLowerCase().replace(/[.)]/g, "").trim();
10222
10270
  if (n(t.num) !== n(e.num)) return !1;
10223
10271
  }
10224
10272
  return t.index !== void 0 && e.index !== void 0 ? t.index === e.index : t.num !== void 0 && e.num !== void 0;
10225
10273
  }
10226
- function Wp(e) {
10274
+ function Yp(e) {
10227
10275
  return /[.!?…]/u.test(e);
10228
10276
  }
10229
- function Gp(e, t) {
10277
+ function Xp(e, t) {
10230
10278
  let n = e.slice(0, t), r = /([\p{L}]+)\.?$/u.exec(n)?.[1];
10231
10279
  if (!r) return !1;
10232
10280
  let i = e.slice(t + 1), a = /\S/u.exec(i)?.[0], o = (/^\s*([\p{L}\p{N}*]+)/u.exec(i)?.[1] ?? "").toLowerCase(), s = r.toLowerCase();
@@ -10254,7 +10302,7 @@ function Gp(e, t) {
10254
10302
  }
10255
10303
  return !1;
10256
10304
  }
10257
- function Kp(e) {
10305
+ function Zp(e) {
10258
10306
  let t = e.text, n = [], r = 0, i = (e) => {
10259
10307
  let i = r, a = e;
10260
10308
  for (; i < a && /\s/u.test(t[i] ?? "");) i += 1;
@@ -10267,7 +10315,7 @@ function Kp(e) {
10267
10315
  };
10268
10316
  for (let e = 0; e < t.length; e += 1) {
10269
10317
  let n = t[e] ?? "";
10270
- if (!Wp(n) || n === "." && Gp(t, e)) continue;
10318
+ if (!Yp(n) || n === "." && Xp(t, e)) continue;
10271
10319
  let a = e + 1;
10272
10320
  for (; a < t.length && /[»”")\]]/u.test(t[a] ?? "");) a += 1;
10273
10321
  let o = t.slice(a);
@@ -10284,11 +10332,11 @@ function Kp(e) {
10284
10332
  alinea: e
10285
10333
  }));
10286
10334
  }
10287
- function qp(e, t) {
10335
+ function Qp(e, t) {
10288
10336
  let n = (e) => "children" in e && (e.type === "article" || e.type === "item" || at.includes(e.type)) ? e.children : [], r = (e) => e.type === "alinéa" ? [e] : "children" in e && (e.type === "article" || e.type === "item" || at.includes(e.type)) ? e.children.flatMap(r) : [];
10289
10337
  if (at.includes(t.type)) {
10290
10338
  let r = n(e);
10291
- for (let e of r) if (at.includes(e.type) && e.type === t.type && Up(e, t)) return {
10339
+ for (let e of r) if (at.includes(e.type) && e.type === t.type && Jp(e, t)) return {
10292
10340
  node: e,
10293
10341
  path: [e]
10294
10342
  };
@@ -10296,13 +10344,13 @@ function qp(e, t) {
10296
10344
  }
10297
10345
  if (t.type === "item") {
10298
10346
  let r = n(e);
10299
- for (let e of r) if (e.type === "item" && Up(e, t)) return {
10347
+ for (let e of r) if (e.type === "item" && Jp(e, t)) return {
10300
10348
  node: e,
10301
10349
  path: [e]
10302
10350
  };
10303
10351
  for (let e of r) {
10304
10352
  if (e.type === "alinéa") continue;
10305
- let n = qp(e, t);
10353
+ let n = Qp(e, t);
10306
10354
  if (n) return {
10307
10355
  node: n.node,
10308
10356
  path: [e, ...n.path]
@@ -10328,7 +10376,7 @@ function qp(e, t) {
10328
10376
  if (t.index === void 0) return null;
10329
10377
  let n = e.type === "alinéa" ? [e] : r(e);
10330
10378
  if (n.length === 0) return null;
10331
- let i = n.flatMap(Kp), a = t.index, o = a < 0 ? i.length + a + 1 : a;
10379
+ let i = n.flatMap(Zp), a = t.index, o = a < 0 ? i.length + a + 1 : a;
10332
10380
  if (o < 1 || o > i.length) return null;
10333
10381
  let s = i[o - 1];
10334
10382
  return {
@@ -10338,12 +10386,12 @@ function qp(e, t) {
10338
10386
  }
10339
10387
  return null;
10340
10388
  }
10341
- function Jp(e, t) {
10389
+ function $p(e, t) {
10342
10390
  if (t.kind === "range") {
10343
- let n = hp(t), r = Jp(e, {
10391
+ let n = yp(t), r = $p(e, {
10344
10392
  kind: "single",
10345
10393
  steps: n.first
10346
- }), i = Jp(e, {
10394
+ }), i = $p(e, {
10347
10395
  kind: "single",
10348
10396
  steps: n.last
10349
10397
  });
@@ -10357,7 +10405,7 @@ function Jp(e, t) {
10357
10405
  }
10358
10406
  let n = e, r = [];
10359
10407
  for (let e of t.steps) {
10360
- let t = qp(n, e);
10408
+ let t = Qp(n, e);
10361
10409
  if (!t) return null;
10362
10410
  n = t.node, r.push(...t.path);
10363
10411
  }
@@ -10369,14 +10417,14 @@ function Jp(e, t) {
10369
10417
  }
10370
10418
  //#endregion
10371
10419
  //#region src/lib/text_parsers/citations.ts
10372
- function Yp(e, t = e) {
10420
+ function em(e, t = e) {
10373
10421
  return {
10374
10422
  content: [{ position: e }],
10375
10423
  position: t,
10376
10424
  type: "citation"
10377
10425
  };
10378
10426
  }
10379
- var Xp = _(String.raw`^« ?([^»\n]+)`, {
10427
+ var tm = _(String.raw`^« ?([^»\n]+)`, {
10380
10428
  flags: "dm",
10381
10429
  value: (e) => {
10382
10430
  let t = e.indices[1], n = t[1];
@@ -10385,43 +10433,43 @@ var Xp = _(String.raw`^« ?([^»\n]+)`, {
10385
10433
  stop: n
10386
10434
  } };
10387
10435
  }
10388
- }), Zp = _(String.raw`« ?(.*?) ?»`, {
10436
+ }), nm = _(String.raw`« ?(.*?) ?»`, {
10389
10437
  flags: "d",
10390
10438
  value: (e, t) => {
10391
10439
  let n = e.indices[1];
10392
- return Yp({
10440
+ return em({
10393
10441
  start: n[0],
10394
10442
  stop: n[1]
10395
10443
  }, t.position());
10396
10444
  }
10397
10445
  });
10398
- function Qp(e, t) {
10446
+ function rm(e, t) {
10399
10447
  if (t <= 0) return !0;
10400
10448
  let n = Math.max(e.lastIndexOf("\n", t - 1), e.lastIndexOf("\r", t - 1)) + 1;
10401
10449
  return e.slice(n, t).trim() === "";
10402
10450
  }
10403
- function $p(e, t, n) {
10451
+ function im(e, t, n) {
10404
10452
  let r = n;
10405
10453
  for (; r > t && /\s/u.test(e[r - 1]);) r--;
10406
10454
  return r;
10407
10455
  }
10408
- function em(e, t) {
10456
+ function am(e, t) {
10409
10457
  return /^[ \t]*« ?/u.exec(e.slice(t))?.[0] ?? null;
10410
10458
  }
10411
- function tm(e, t, { allowClosingQuoteAsOpening: n = !1, allowUnclosed: r = !1 } = {}) {
10459
+ function om(e, t, { allowClosingQuoteAsOpening: n = !1, allowUnclosed: r = !1 } = {}) {
10412
10460
  if (e[t] !== "«" && !(n && e[t] === "»")) return;
10413
10461
  let i = [], a = 1, o = t + 1;
10414
10462
  e[o] === " " && o++;
10415
10463
  for (let n = o; n < e.length; n++) {
10416
10464
  let s = e[n];
10417
10465
  if (s === "«") {
10418
- if (a === 1 && Qp(e, n)) {
10419
- let t = $p(e, o, n);
10466
+ if (a === 1 && rm(e, n)) {
10467
+ let t = im(e, o, n);
10420
10468
  i.push({
10421
10469
  start: o,
10422
10470
  stop: t
10423
10471
  });
10424
- let r = em(e, n);
10472
+ let r = am(e, n);
10425
10473
  o = n + (r?.length ?? 1), n = o - 1;
10426
10474
  continue;
10427
10475
  }
@@ -10430,7 +10478,7 @@ function tm(e, t, { allowClosingQuoteAsOpening: n = !1, allowUnclosed: r = !1 }
10430
10478
  }
10431
10479
  if (s === "»") {
10432
10480
  if (a--, a === 0) {
10433
- let r = $p(e, o, n);
10481
+ let r = im(e, o, n);
10434
10482
  return i.push({
10435
10483
  start: o,
10436
10484
  stop: r
@@ -10446,9 +10494,9 @@ function tm(e, t, { allowClosingQuoteAsOpening: n = !1, allowUnclosed: r = !1 }
10446
10494
  continue;
10447
10495
  }
10448
10496
  if (s === "\n" && a === 1) {
10449
- let t = em(e, n + 1);
10497
+ let t = am(e, n + 1);
10450
10498
  if (t !== null) {
10451
- let r = $p(e, o, n);
10499
+ let r = im(e, o, n);
10452
10500
  i.push({
10453
10501
  start: o,
10454
10502
  stop: r
@@ -10459,7 +10507,7 @@ function tm(e, t, { allowClosingQuoteAsOpening: n = !1, allowUnclosed: r = !1 }
10459
10507
  }
10460
10508
  }
10461
10509
  if (!r) return;
10462
- let s = $p(e, o, e.length), c = /\s*«\s*$/u.exec(e.slice(o, s));
10510
+ let s = im(e, o, e.length), c = /\s*«\s*$/u.exec(e.slice(o, s));
10463
10511
  if (c !== null && (s -= c[0].length), !(s <= o && i.length === 0)) return s > o && i.push({
10464
10512
  start: o,
10465
10513
  stop: s
@@ -10472,12 +10520,12 @@ function tm(e, t, { allowClosingQuoteAsOpening: n = !1, allowUnclosed: r = !1 }
10472
10520
  }
10473
10521
  };
10474
10522
  }
10475
- function nm(e, t) {
10523
+ function sm(e, t) {
10476
10524
  let n = [], r = 0;
10477
10525
  for (; r < e.length;) {
10478
10526
  let i = e.indexOf("«", r), a = t?.allowClosingQuoteAsOpening ? e.indexOf("»", r) : -1, o = i === -1 ? a : a === -1 ? i : Math.min(i, a);
10479
10527
  if (o === -1) break;
10480
- let s = tm(e, o, t);
10528
+ let s = om(e, o, t);
10481
10529
  if (s === void 0) {
10482
10530
  r = o + 1;
10483
10531
  continue;
@@ -10487,7 +10535,7 @@ function nm(e, t) {
10487
10535
  return n;
10488
10536
  }
10489
10537
  var Z = (e) => {
10490
- let t = e.offset, n = /^[ \t]*/u.exec(e.remaining())?.[0] ?? "", r = e.offset + n.length, i = tm(e.input, r);
10538
+ let t = e.offset, n = /^[ \t]*/u.exec(e.remaining())?.[0] ?? "", r = e.offset + n.length, i = om(e.input, r);
10491
10539
  if (i === void 0) {
10492
10540
  e.offset = t, e.length = 0, e.usedInputs = void 0;
10493
10541
  return;
@@ -10498,7 +10546,7 @@ var Z = (e) => {
10498
10546
  type: "citation"
10499
10547
  };
10500
10548
  };
10501
- function rm(e, t) {
10549
+ function cm(e, t) {
10502
10550
  let n = 0, r = t.content[0].position, i = t.content.at(-1).position, a = t.content.map(({ position: t }) => e.input.slice(t.start, t.stop)).join("\n");
10503
10551
  return {
10504
10552
  input: e.text(t.position),
@@ -10529,12 +10577,12 @@ function rm(e, t) {
10529
10577
  title: "Conversion de citation"
10530
10578
  };
10531
10579
  }
10532
- function im(e, t) {
10533
- return rm(new S(e), t).output;
10580
+ function lm(e, t) {
10581
+ return cm(new S(e), t).output;
10534
10582
  }
10535
10583
  //#endregion
10536
10584
  //#region src/lib/text_parsers/legal_text_aliases.ts
10537
- var am = [
10585
+ var um = [
10538
10586
  {
10539
10587
  cid: "LEGITEXT000025024948",
10540
10588
  nature: "CODE",
@@ -10685,10 +10733,10 @@ var am = [
10685
10733
  pattern: "(?:comofi|cmf)",
10686
10734
  title: "Code monétaire et financier"
10687
10735
  }
10688
- ], om = am.map((e) => ({
10736
+ ], dm = um.map((e) => ({
10689
10737
  alias: e,
10690
10738
  regExp: RegExp(`^(?:${e.pattern})$`, "iv")
10691
- })), sm = "cpce", cm = {
10739
+ })), fm = "cpce", pm = {
10692
10740
  execution: {
10693
10741
  cid: "LEGITEXT000025024948",
10694
10742
  nature: "CODE",
@@ -10699,26 +10747,26 @@ var am = [
10699
10747
  nature: "CODE",
10700
10748
  title: "Code des postes et des communications électroniques"
10701
10749
  }
10702
- }, lm = am.map(({ cid: e, title: t }) => ({
10750
+ }, mm = um.map(({ cid: e, title: t }) => ({
10703
10751
  cid: e,
10704
10752
  normalizedTitle: t.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/gu, "").replace(/\s+/gu, " ").trim()
10705
10753
  }));
10706
- function um(e) {
10707
- let t = e.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/gu, "").replace(/\s+/gu, " ").trim(), n = om.find(({ regExp: e }) => e.test(t));
10754
+ function hm(e) {
10755
+ let t = e.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/gu, "").replace(/\s+/gu, " ").trim(), n = dm.find(({ regExp: e }) => e.test(t));
10708
10756
  if (n !== void 0) return n.alias.cid;
10709
10757
  let r = t.match(/^(?:le\s+|la\s+|du\s+|de\s+la\s+|de\s+l')?(code\b.+)$/);
10710
10758
  if (r === null || r[1] === void 0) return;
10711
- let i = r[1], a = lm.filter(({ normalizedTitle: e }) => e.startsWith(i));
10759
+ let i = r[1], a = mm.filter(({ normalizedTitle: e }) => e.startsWith(i));
10712
10760
  return a.length === 1 ? a[0].cid : void 0;
10713
10761
  }
10714
- new Set([...am.map(({ cid: e }) => e), ...Object.values(cm).map(({ cid: e }) => e)]);
10715
- var dm = [{
10716
- info: cm.execution,
10762
+ new Set([...um.map(({ cid: e }) => e), ...Object.values(pm).map(({ cid: e }) => e)]);
10763
+ var gm = [{
10764
+ info: pm.execution,
10717
10765
  regExp: /code\s+des?\s+proc[eé]dures?\s+(?:civiles?\s+)?d['’]\s*ex(?:c)?[eé]cution/giu
10718
10766
  }, {
10719
- info: cm.postes,
10767
+ info: pm.postes,
10720
10768
  regExp: /code\s+des\s+postes\s+et\s+(?:des?\s+)?communications?\s+[eé]lectroniques?/giu
10721
- }], fm = `(?:${[...am.map(({ pattern: e }) => `(?:${e})`), sm].join("|")})`, pm = {
10769
+ }], _m = `(?:${[...um.map(({ pattern: e }) => `(?:${e})`), fm].join("|")})`, vm = {
10722
10770
  I: {
10723
10771
  cid: "LEGITEXT000006069568",
10724
10772
  nature: "CODE",
@@ -10740,9 +10788,9 @@ var dm = [{
10740
10788
  title: "Code général des impôts, annexe IV"
10741
10789
  }
10742
10790
  };
10743
- function mm(e, t) {
10791
+ function ym(e, t) {
10744
10792
  let n = [];
10745
- for (let { info: r, regExp: i } of dm) {
10793
+ for (let { info: r, regExp: i } of gm) {
10746
10794
  i.lastIndex = 0;
10747
10795
  for (let a of e.matchAll(i)) a.index <= t.start && n.push({
10748
10796
  index: a.index,
@@ -10751,9 +10799,9 @@ function mm(e, t) {
10751
10799
  }
10752
10800
  return n.sort((e, t) => t.index - e.index), n[0]?.info;
10753
10801
  }
10754
- function hm(e, t) {
10755
- if (/^cpce$/iv.test(e)) return t === void 0 ? void 0 : mm(t.input, t.position);
10756
- let n = om.find(({ regExp: t }) => t.test(e))?.alias;
10802
+ function bm(e, t) {
10803
+ if (/^cpce$/iv.test(e)) return t === void 0 ? void 0 : ym(t.input, t.position);
10804
+ let n = dm.find(({ regExp: t }) => t.test(e))?.alias;
10757
10805
  if (n === void 0) return;
10758
10806
  let { cid: r, nature: i, title: a } = n;
10759
10807
  return {
@@ -10762,15 +10810,15 @@ function hm(e, t) {
10762
10810
  title: a
10763
10811
  };
10764
10812
  }
10765
- function gm(e, t) {
10813
+ function xm(e, t) {
10766
10814
  return e.cid === "LEGITEXT000006070716" && t !== void 0 && /^[LR]\d/u.test(t) ? {
10767
- ...cm.execution,
10815
+ ...pm.execution,
10768
10816
  position: e.position,
10769
10817
  type: "texte"
10770
10818
  } : e;
10771
10819
  }
10772
- function _m(e, t, n) {
10773
- let r = hm(e, n === void 0 ? void 0 : {
10820
+ function Sm(e, t, n) {
10821
+ let r = bm(e, n === void 0 ? void 0 : {
10774
10822
  input: n,
10775
10823
  position: t
10776
10824
  });
@@ -10780,39 +10828,39 @@ function _m(e, t, n) {
10780
10828
  type: "texte"
10781
10829
  };
10782
10830
  }
10783
- var vm = o(...am.map(({ pattern: e }) => _(`${e}(?=$|\\P{Alphabetic})`, {
10831
+ var Cm = o(...um.map(({ pattern: e }) => _(`${e}(?=$|\\P{Alphabetic})`, {
10784
10832
  flags: "iv",
10785
- value: (e, t) => _m(e[0], t.position(), t.input)
10786
- })), _(`${sm}(?=$|\\P{Alphabetic})`, {
10833
+ value: (e, t) => Sm(e[0], t.position(), t.input)
10834
+ })), _(`${fm}(?=$|\\P{Alphabetic})`, {
10787
10835
  flags: "iv",
10788
- value: (e, t) => _m(e[0], t.position(), t.input)
10836
+ value: (e, t) => Sm(e[0], t.position(), t.input)
10789
10837
  }));
10790
10838
  //#endregion
10791
10839
  //#region src/lib/text_parsers/doctrinal_references.ts
10792
- function ym(e, t) {
10840
+ function wm(e, t) {
10793
10841
  let n = e.indices?.groups?.[t];
10794
10842
  return n === void 0 ? void 0 : {
10795
10843
  start: n[0],
10796
10844
  stop: n[1]
10797
10845
  };
10798
10846
  }
10799
- function bm(e) {
10847
+ function Tm(e) {
10800
10848
  let t = e.match(/^(?<article>.*\d(?:[\p{L}\d-]*))\s+(?<subdivision>[IVXLCDM]+(?:\s+(?:bis|ter|quater))?|\d+\s*(?:°|º|er|e|ème))$/iu)?.groups?.article?.trim() ?? e;
10801
10849
  return {
10802
10850
  num: qt(t),
10803
10851
  parsedArticleText: t
10804
10852
  };
10805
10853
  }
10806
- function xm(e, t) {
10854
+ function Em(e, t) {
10807
10855
  let n = e.groups?.article?.trim(), r = e.groups?.text;
10808
10856
  if (n === void 0 || r === void 0) return;
10809
- let i = ym(e, "articleKeyword");
10857
+ let i = wm(e, "articleKeyword");
10810
10858
  if (i === void 0 && !/^(?:(?:L\.?\s*O|[LRDA])\*?\.?\s*)\d/iu.test(n)) return;
10811
- let { num: a, parsedArticleText: o } = bm(n), s = ym(e, "article"), c = ym(e, "text");
10859
+ let { num: a, parsedArticleText: o } = Tm(n), s = wm(e, "article"), c = wm(e, "text");
10812
10860
  if (a === void 0 || s === void 0 || c === void 0) return;
10813
- let l = _m(r, c, t.input);
10861
+ let l = Sm(r, c, t.input);
10814
10862
  if (l === void 0) return;
10815
- let u = gm(l, a), d = {
10863
+ let u = xm(l, a), d = {
10816
10864
  num: a,
10817
10865
  position: {
10818
10866
  start: i?.start ?? s.start,
@@ -10830,17 +10878,17 @@ function xm(e, t) {
10830
10878
  type: "parent-enfant"
10831
10879
  };
10832
10880
  }
10833
- var Sm = _(String.raw`cgi\s*,\s*ann(?:exe)?\.?\s*(IV|III|II|I)`, {
10881
+ var Dm = _(String.raw`cgi\s*,\s*ann(?:exe)?\.?\s*(IV|III|II|I)`, {
10834
10882
  flags: "i",
10835
10883
  value: (e, t) => {
10836
- let n = pm[e[1].toUpperCase()];
10884
+ let n = vm[e[1].toUpperCase()];
10837
10885
  return n === void 0 ? void 0 : {
10838
10886
  ...n,
10839
10887
  position: t.position(),
10840
10888
  type: "texte"
10841
10889
  };
10842
10890
  }
10843
- }), Cm = y(Zt, { value: (e, t) => {
10891
+ }), Om = y(Zt, { value: (e, t) => {
10844
10892
  let n = t.position(), r = t.text(n), i = r.match(/^(?<article>.*\d(?:[\p{L}\d-]*))\s+\d+\s*(?:°|º|er|e|ème)$/iu)?.groups?.article?.trim() ?? r;
10845
10893
  return {
10846
10894
  num: qt(i),
@@ -10850,25 +10898,25 @@ var Sm = _(String.raw`cgi\s*,\s*ann(?:exe)?\.?\s*(IV|III|II|I)`, {
10850
10898
  },
10851
10899
  type: "article"
10852
10900
  };
10853
- } }), wm = a([_(String.raw`\s*,\s*art(?:icle)?\.?\s+`, { flags: "i" }), Cm], { value: (e) => e[1] }), Tm = a([
10901
+ } }), km = a([_(String.raw`\s*,\s*art(?:icle)?\.?\s+`, { flags: "i" }), Om], { value: (e) => e[1] }), Am = a([
10854
10902
  w(_(String.raw`(?:le|la|les)\s+`, { flags: "i" }), { default: "" }),
10855
- o(Sm, vm),
10856
- wm
10903
+ o(Dm, Cm),
10904
+ km
10857
10905
  ], { value: (e, t) => {
10858
10906
  let n = e[2];
10859
10907
  return {
10860
10908
  child: n,
10861
- parent: gm(e[1], n.num),
10909
+ parent: xm(e[1], n.num),
10862
10910
  position: t.position(),
10863
10911
  type: "parent-enfant"
10864
10912
  };
10865
- } }), Em = _(String.raw`(?:(?<articleKeyword>articles?)\s+)?(?<article>\S[^\n,;:\(\)]*?)\s+(?:(?:du|de\s+la|de\s+l['’])\s+)?(?<text>${fm})(?=$|\P{Alphabetic})`, {
10913
+ } }), jm = _(String.raw`(?:(?<articleKeyword>articles?)\s+)?(?<article>\S[^\n,;:\(\)]*?)\s+(?:(?:du|de\s+la|de\s+l['’])\s+)?(?<text>${_m})(?=$|\P{Alphabetic})`, {
10866
10914
  flags: "div",
10867
- value: (e, t) => xm(e, t)
10868
- }), Dm = _(String.raw`(?<article1>(?:(?:L\.?\s*O|[LRDA])\*?\.?\s*)\d[^\n,;:\(\)]*?)\s+(?<coordinator>et|ou)\s+(?<article2>(?:(?:L\.?\s*O|[LRDA])\*?\.?\s*)\d[^\n,;:\(\)]*?)\s+(?:(?:du|de\s+la|de\s+l['’])\s+)?(?<text>${fm})(?=$|\P{Alphabetic})`, {
10915
+ value: (e, t) => Em(e, t)
10916
+ }), Mm = _(String.raw`(?<article1>(?:(?:L\.?\s*O|[LRDA])\*?\.?\s*)\d[^\n,;:\(\)]*?)\s+(?<coordinator>et|ou)\s+(?<article2>(?:(?:L\.?\s*O|[LRDA])\*?\.?\s*)\d[^\n,;:\(\)]*?)\s+(?:(?:du|de\s+la|de\s+l['’])\s+)?(?<text>${_m})(?=$|\P{Alphabetic})`, {
10869
10917
  flags: "div",
10870
10918
  value: (e, t) => {
10871
- let n = ym(e, "article1"), r = ym(e, "article2"), i = ym(e, "text"), a = e.groups?.article1, o = e.groups?.article2, s = e.groups?.coordinator, c = a === void 0 ? void 0 : qt(a.trim()), l = o === void 0 ? void 0 : qt(o.trim()), u = e.groups?.text === void 0 || i === void 0 ? void 0 : _m(e.groups.text, i, t.input);
10919
+ let n = wm(e, "article1"), r = wm(e, "article2"), i = wm(e, "text"), a = e.groups?.article1, o = e.groups?.article2, s = e.groups?.coordinator, c = a === void 0 ? void 0 : qt(a.trim()), l = o === void 0 ? void 0 : qt(o.trim()), u = e.groups?.text === void 0 || i === void 0 ? void 0 : Sm(e.groups.text, i, t.input);
10872
10920
  if (!(n === void 0 || r === void 0 || c === void 0 || l === void 0 || s !== "et" && s !== "ou" || u === void 0)) return {
10873
10921
  child: {
10874
10922
  coordinator: s,
@@ -10888,7 +10936,7 @@ var Sm = _(String.raw`cgi\s*,\s*ann(?:exe)?\.?\s*(IV|III|II|I)`, {
10888
10936
  },
10889
10937
  type: "enumeration"
10890
10938
  },
10891
- parent: gm(gm(u, c), l),
10939
+ parent: xm(xm(u, c), l),
10892
10940
  position: {
10893
10941
  start: n.start,
10894
10942
  stop: u.position.stop
@@ -10896,7 +10944,7 @@ var Sm = _(String.raw`cgi\s*,\s*ann(?:exe)?\.?\s*(IV|III|II|I)`, {
10896
10944
  type: "parent-enfant"
10897
10945
  };
10898
10946
  }
10899
- }), Om = o(Tm, Dm, Em), km = (e) => {
10947
+ }), Nm = o(Am, Mm, jm), Pm = (e) => {
10900
10948
  let t = e.offset, n = /,\s*(?:par\s+)?/guy;
10901
10949
  if (n.lastIndex = t, !n.exec(e.input)) return;
10902
10950
  e.offset = n.lastIndex;
@@ -10912,7 +10960,7 @@ var Sm = _(String.raw`cgi\s*,\s*ann(?:exe)?\.?\s*(IV|III|II|I)`, {
10912
10960
  }
10913
10961
  return e.offset = i.lastIndex, e.length = 0, e.usedInputs = e.input.slice(t, e.offset), r;
10914
10962
  };
10915
- function Am(e) {
10963
+ function Fm(e) {
10916
10964
  for (let t = 0; t < e.length; t += 1) {
10917
10965
  let n = t === 0 ? void 0 : e[t - 1];
10918
10966
  if (n && /[\p{L}\p{N}_]/u.test(n)) continue;
@@ -10921,7 +10969,7 @@ function Am(e) {
10921
10969
  }
10922
10970
  return null;
10923
10971
  }
10924
- function jm(e, t) {
10972
+ function Im(e, t) {
10925
10973
  let n = e.slice(0, Math.max(0, t)), r = /(?:^|[^\p{L}\p{N}_])les\s+/giu, i = null;
10926
10974
  for (; r.exec(n) !== null;) {
10927
10975
  let e = new S(n, r.lastIndex), t = Ee(e);
@@ -10929,7 +10977,7 @@ function jm(e, t) {
10929
10977
  }
10930
10978
  return i;
10931
10979
  }
10932
- function Mm(e) {
10980
+ function Lm(e) {
10933
10981
  let t = [], n = /(?:,\s*)?par\s+/giu, r = 0, i;
10934
10982
  for (; (i = n.exec(e)) !== null;) {
10935
10983
  let a = new S(e, n.lastIndex);
@@ -10941,17 +10989,17 @@ function Mm(e) {
10941
10989
  }
10942
10990
  //#endregion
10943
10991
  //#region src/lib/text_parsers/actions.ts
10944
- var Nm = (e) => a([
10992
+ var Rm = (e) => a([
10945
10993
  _(e, { flags: "i" }),
10946
- km,
10994
+ Pm,
10947
10995
  _(e === "est" ? "remplacée?" : "remplacée?s", { flags: "i" })
10948
- ], { value: "remplacer" }), Pm = o(t(_("(modalités|conditions) d'application (de )?", { flags: "i" }), {
10996
+ ], { value: "remplacer" }), zm = o(t(_("(modalités|conditions) d'application (de )?", { flags: "i" }), {
10949
10997
  lookbackLength: 35,
10950
10998
  value: { action: "précision" }
10951
10999
  }), t(_("en application (de )?", { flags: "i" }), {
10952
11000
  lookbackLength: 35,
10953
11001
  value: { action: "application" }
10954
- })), Fm = ye("après|avant|ajoutée?s?|insérée?s?|complétée?s?|rédigée?s?|suit|modifiée?s?|rétablie?s?|remplacée?s?|supprimée?s?|abrogée?s?|devient", o(a([
11002
+ })), Bm = ye("après|avant|ajoutée?s?|insérée?s?|complétée?s?|rédigée?s?|suit|modifiée?s?|rétablie?s?|remplacée?s?|supprimée?s?|abrogée?s?|devient", o(a([
10955
11003
  E,
10956
11004
  _("est complété par les mots ?", { flags: "i" }),
10957
11005
  _(" ?:"),
@@ -11019,7 +11067,7 @@ var Nm = (e) => a([
11019
11067
  }), _("est rétablie? (ainsi qu'il|comme) suit", {
11020
11068
  flags: "i",
11021
11069
  value: "rétablir"
11022
- }), Nm("est"), _("est remplacée?", {
11070
+ }), Rm("est"), _("est remplacée?", {
11023
11071
  flags: "i",
11024
11072
  value: "remplacer"
11025
11073
  }), _("sont ainsi modifiée?s", {
@@ -11034,7 +11082,7 @@ var Nm = (e) => a([
11034
11082
  }), _("sont rétablie?s (ainsi qu'il|comme) suit", {
11035
11083
  flags: "i",
11036
11084
  value: "rétablir"
11037
- }), Nm("sont"), _("sont remplacée?s", {
11085
+ }), Rm("sont"), _("sont remplacée?s", {
11038
11086
  flags: "i",
11039
11087
  value: "remplacer"
11040
11088
  }), _("sont renum[eé]rotée?s", {
@@ -11054,7 +11102,7 @@ var Nm = (e) => a([
11054
11102
  }), _("est remplacée?", {
11055
11103
  flags: "i",
11056
11104
  value: "remplacer"
11057
- }), Nm("est"), Nm("sont"), _("sont remplacée?s", {
11105
+ }), Rm("est"), Rm("sont"), _("sont remplacée?s", {
11058
11106
  flags: "i",
11059
11107
  value: "remplacer"
11060
11108
  }), _("est modifiée?", {
@@ -11214,23 +11262,23 @@ var Nm = (e) => a([
11214
11262
  }), _("est supprimée?", {
11215
11263
  flags: "i",
11216
11264
  value: "supprimer"
11217
- }))], { value: (e) => ({ action: e[1] }) }))), Im = o(ln, Cn), Lm = o(dn, bn, vm, Ae), Rm = a([Im, b(a([e, Lm], { value: (e) => e[1] }))], { value: (e, t) => gt(e[0], e[1], t.position()) }), zm = a([Lm, b(a([e, Lm], { value: (e) => e[1] }))], { value: (e, t) => gt(e[0], e[1], t.position()) }), Bm = a([x, Rm], { value: (e) => e[1] }), Vm = o(a([e, zm], { value: (e) => e[1] }), Bm), Hm = o(a([Vt, w(Vm, { default: null })], { value: (e) => {
11265
+ }))], { value: (e) => ({ action: e[1] }) }))), Vm = o(ln, Cn), Hm = o(dn, bn, Cm, Ae), Um = a([Vm, b(a([e, Hm], { value: (e) => e[1] }))], { value: (e, t) => gt(e[0], e[1], t.position()) }), Wm = a([Hm, b(a([e, Hm], { value: (e) => e[1] }))], { value: (e, t) => gt(e[0], e[1], t.position()) }), Gm = a([x, Um], { value: (e) => e[1] }), Km = o(a([e, Wm], { value: (e) => e[1] }), Gm), qm = o(a([Vt, w(Km, { default: null })], { value: (e) => {
11218
11266
  let t = e[0], n = e[1];
11219
11267
  return n === null ? t : pt(n, t);
11220
- } }), Rm), Um = o(a([Ht, w(Vm, { default: null })], { value: (e) => {
11268
+ } }), Um), Jm = o(a([Ht, w(Km, { default: null })], { value: (e) => {
11221
11269
  let t = e[0], n = e[1];
11222
11270
  return n === null ? t : pt(n, t);
11223
- } }), zm), Wm = a([
11224
- w(Pm, { default: null }),
11271
+ } }), Wm), Ym = a([
11272
+ w(zm, { default: null }),
11225
11273
  a([
11226
11274
  ie,
11227
- Hm,
11275
+ qm,
11228
11276
  w([w(_(" modifiée?s", { flags: "i" }), { default: "" }), _(" susvisée?s", { flags: "i" })], { default: "" })
11229
11277
  ], { value: (e, t) => ({
11230
11278
  ...e[1],
11231
11279
  position: t.position()
11232
11280
  }) }),
11233
- w(Fm, { default: null })
11281
+ w(Bm, { default: null })
11234
11282
  ], { value: (e, t) => {
11235
11283
  let n = e[2] ?? e[0];
11236
11284
  return n === null ? e[1] : {
@@ -11239,18 +11287,18 @@ var Nm = (e) => a([
11239
11287
  reference: e[1],
11240
11288
  type: "reference_et_action"
11241
11289
  };
11242
- } }), Gm = o(a([
11243
- w(Pm, { default: null }),
11290
+ } }), Xm = o(a([
11291
+ w(zm, { default: null }),
11244
11292
  a([
11245
11293
  oe,
11246
- Um,
11294
+ Jm,
11247
11295
  w([w(_(" modifiée?", { flags: "i" }), { default: "" }), _(" susvisée?", { flags: "i" })], { default: "" }),
11248
11296
  w(_(String.raw`, ?qui devient [^,]+ ","`, { flags: "i" }), { default: "" })
11249
11297
  ], { value: (e, t) => ({
11250
11298
  ...e[1],
11251
11299
  position: t.position()
11252
11300
  }) }),
11253
- w(Fm, { default: null })
11301
+ w(Bm, { default: null })
11254
11302
  ], { value: (e, t) => {
11255
11303
  let n = e[2] ?? e[0];
11256
11304
  return n === null ? e[1] : {
@@ -11259,43 +11307,43 @@ var Nm = (e) => a([
11259
11307
  reference: e[1],
11260
11308
  type: "reference_et_action"
11261
11309
  };
11262
- } }), Wm), Km = ye("article|loi|décret|code|alinéa|phrase|chapitre|titre|livre|partie|section|paragraphe|ordonnance|constitution|directive|règlement|\\d|[ivxlc]+|[a-zA-Z]", a([Gm, b([o(St, xt), Gm])], { value: (e, t) => mt(e[0], e[1], t.position()) })), qm = y(Um, { value: (e, t) => ({
11310
+ } }), Ym), Zm = ye("article|loi|décret|code|alinéa|phrase|chapitre|titre|livre|partie|section|paragraphe|ordonnance|constitution|directive|règlement|\\d|[ivxlc]+|[a-zA-Z]", a([Xm, b([o(St, xt), Xm])], { value: (e, t) => mt(e[0], e[1], t.position()) })), Qm = y(Jm, { value: (e, t) => ({
11263
11311
  ...e,
11264
11312
  position: t.position()
11265
- }) }), Jm = o(b(qm, {
11313
+ }) }), $m = o(b(Qm, {
11266
11314
  min: 2,
11267
11315
  separator: i,
11268
11316
  value: (e) => [e[0], ...e.slice(1).map(([, e]) => e)]
11269
- }), b(qm, {
11317
+ }), b(Qm, {
11270
11318
  min: 2,
11271
11319
  separator: _(String.raw`\n`),
11272
11320
  value: (e) => [e[0], ...e.slice(1).map(([, e]) => e)]
11273
- }), y(qm, { value: (e) => [e] }));
11321
+ }), y(Qm, { value: (e) => [e] }));
11274
11322
  //#endregion
11275
11323
  //#region src/lib/extractors/references.ts
11276
- function Ym({ text: e }) {
11324
+ function eh({ text: e }) {
11277
11325
  return /^\p{Lowercase_Letter}$/u.test(e);
11278
11326
  }
11279
- function Xm(e) {
11327
+ function th(e) {
11280
11328
  return !/^[\p{Alphabetic}\p{Decimal_Number}]$/u.test(e);
11281
11329
  }
11282
- function Zm(e) {
11330
+ function nh(e) {
11283
11331
  return e !== void 0 && /^[\p{Alphabetic}\p{Decimal_Number}«]$/u.test(e);
11284
11332
  }
11285
- function Qm(e, t) {
11333
+ function rh(e, t) {
11286
11334
  if (t <= 0) return !0;
11287
11335
  let n = e[t - 1], r = e[t];
11288
- return Zm(r) && (Xm(n) || Xm(r));
11336
+ return nh(r) && (th(n) || th(r));
11289
11337
  }
11290
- function $m(e) {
11291
- return e !== void 0 && Ym(e) ? 5 : void 0;
11338
+ function ih(e) {
11339
+ return e !== void 0 && eh(e) ? 5 : void 0;
11292
11340
  }
11293
- function* eh(e, t, n = {}) {
11341
+ function* ah(e, t, n = {}) {
11294
11342
  n.diagnostics !== void 0 && n.diagnostics.citationCount++;
11295
- let r = rm(e, t), i = new S(r.output);
11343
+ let r = cm(e, t), i = new S(r.output);
11296
11344
  i.currentText = e.currentText;
11297
11345
  let a = g(r);
11298
- for (let e of nh(i, n)) {
11346
+ for (let e of sh(i, n)) {
11299
11347
  e = structuredClone(e), t.references === void 0 && (t.references = []), t.references.push(e);
11300
11348
  for (let t of bt(e)) {
11301
11349
  let e = t.position;
@@ -11304,138 +11352,138 @@ function* eh(e, t, n = {}) {
11304
11352
  yield e;
11305
11353
  }
11306
11354
  }
11307
- function* th(e, t = {}) {
11308
- yield* nh(e, t);
11355
+ function* oh(e, t = {}) {
11356
+ yield* sh(e, t);
11309
11357
  }
11310
- function* nh(e, t = {}) {
11311
- let n = ye(String.raw`arrêtés?|circulaires?|code|constitution|décrets?(?:-loi)?|loi|ordonnance|art\.|articles?|chapitre|livre|paragraphe|partie|section|sous-paragraphe|sous-section|sous-sous-paragraphe|sous-titre|titre|alinéas?|phrases?|règlements?|directives?|décisions?|«|[IVXLCDM]+|[A-Z]|\d+`, o(Z, en, gn, Om, Km), 80, String.raw`(?<=^|\P{Alphabetic})(?:arrêtés?|circulaires?|code|constitution|décrets?(?:-loi)?|loi|ordonnance|art\.|articles?|chapitre|livre|paragraphe|partie|section|sous-paragraphe|sous-section|sous-sous-paragraphe|sous-titre|titre|alinéas?|phrases?|règlements?|directives?|décisions?|«|[IVXLCDM]+|[A-Z]|\d+)(?=$|\P{Alphabetic})`);
11358
+ function* sh(e, t = {}) {
11359
+ let n = ye(String.raw`arrêtés?|circulaires?|code|constitution|décrets?(?:-loi)?|loi|ordonnance|art\.|articles?|chapitre|livre|paragraphe|partie|section|sous-paragraphe|sous-section|sous-sous-paragraphe|sous-titre|titre|alinéas?|phrases?|règlements?|directives?|décisions?|«|[IVXLCDM]+|[A-Z]|\d+`, o(Z, en, gn, Nm, Zm), 80, String.raw`(?<=^|\P{Alphabetic})(?:arrêtés?|circulaires?|code|constitution|décrets?(?:-loi)?|loi|ordonnance|art\.|articles?|chapitre|livre|paragraphe|partie|section|sous-paragraphe|sous-section|sous-sous-paragraphe|sous-titre|titre|alinéas?|phrases?|règlements?|directives?|décisions?|«|[IVXLCDM]+|[A-Z]|\d+)(?=$|\P{Alphabetic})`);
11312
11360
  for (let r of n.extract(e, {
11313
- canStartAtOffset: Qm,
11361
+ canStartAtOffset: rh,
11314
11362
  diagnostics: t.diagnostics?.fastPath,
11315
11363
  overlapWindow: 80,
11316
- overlapWindowForCandidate: (e, n) => t.overlapWindowForCandidate?.(e) ?? $m(n)
11317
- })) if (r !== void 0) if (r.type === "citation") yield* eh(e, r, t);
11364
+ overlapWindowForCandidate: (e, n) => t.overlapWindowForCandidate?.(e) ?? ih(n)
11365
+ })) if (r !== void 0) if (r.type === "citation") yield* ah(e, r, t);
11318
11366
  else {
11319
11367
  if (r.type === "reference_et_action" || r.type === "alinéa" || r.type === "article" || r.type === "chapitre" || r.type === "item" || r.type === "livre" || r.type === "paragraphe" || r.type === "partie" || r.type === "phrase" || r.type === "section" || r.type === "sous-paragraphe" || r.type === "sous-section" || r.type === "sous-sous-paragraphe" || r.type === "sous-titre" || r.type === "titre" || r.type === "texte" || r.type === "bounded-interval" || r.type === "counted-interval" || r.type === "enumeration" || r.type === "exclusion" || r.type === "parent-enfant" || r.type === "incomplete-header") {
11320
11368
  for (let n of bt(r)) if (n.type === "reference_et_action") {
11321
11369
  let { originalCitations: r } = n.action;
11322
- if (r !== void 0) for (let n of r) for (let r of eh(e, n, t));
11370
+ if (r !== void 0) for (let n of r) for (let r of ah(e, n, t));
11323
11371
  }
11324
11372
  }
11325
11373
  yield r;
11326
11374
  }
11327
11375
  }
11328
- function* rh(e, t, n = {}) {
11376
+ function* ch(e, t, n = {}) {
11329
11377
  let r = g(t);
11330
- for (let t of th(e, n)) {
11378
+ for (let t of oh(e, n)) {
11331
11379
  for (let e of bt(t, { citations: !0 })) e.position !== void 0 && (e.originalTransformation = s(r, e.position));
11332
11380
  yield t;
11333
11381
  }
11334
11382
  }
11335
- var ih = (e) => [...th(e)], ah = (e, t) => [...rh(e, t)], oh = "(?:avant|apr[eè]s)", sh = o(_("avant(?![-A-Za-zÀ-ÖØ-öø-ÿ0-9_])", {
11383
+ var lh = (e) => [...oh(e)], uh = (e, t) => [...ch(e, t)], dh = "(?:avant|apr[eè]s)", fh = o(_("avant(?![-A-Za-zÀ-ÖØ-öø-ÿ0-9_])", {
11336
11384
  flags: "i",
11337
11385
  value: "before"
11338
11386
  }), _("apr[eè]s(?![-A-Za-zÀ-ÖØ-öø-ÿ0-9_])", {
11339
11387
  flags: "i",
11340
11388
  value: "after"
11341
- })), ch = o(_("(?:au|a[uù])\\s+d[eé]but\\b", {
11389
+ })), ph = o(_("(?:au|a[uù])\\s+d[eé]but\\b", {
11342
11390
  flags: "i",
11343
11391
  value: "start"
11344
11392
  }), _("(?:a|à)\\s+la\\s+fin\\b", {
11345
11393
  flags: "i",
11346
11394
  value: "end"
11347
11395
  }));
11348
- function lh(e) {
11396
+ function mh(e) {
11349
11397
  return e === "before" ? "insert_before" : "insert_after";
11350
11398
  }
11351
- function uh(e) {
11352
- let t = fh(e), n = /(?:^|[^\p{L}\p{N}_-])(avant|apres)(?![\p{L}\p{N}_-])/u.exec(t);
11399
+ function hh(e) {
11400
+ let t = _h(e), n = /(?:^|[^\p{L}\p{N}_-])(avant|apres)(?![\p{L}\p{N}_-])/u.exec(t);
11353
11401
  return n ? n[1] === "avant" ? "before" : "after" : null;
11354
11402
  }
11355
- function dh(e) {
11356
- let t = fh(e), n = /(?:^|[^\p{L}\p{N}_-])(?:au|a[uù])\s+debut\b/u.exec(t), r = /(?:^|[^\p{L}\p{N}_-])a\s+la\s+fin\b/u.exec(t);
11403
+ function gh(e) {
11404
+ let t = _h(e), n = /(?:^|[^\p{L}\p{N}_-])(?:au|a[uù])\s+debut\b/u.exec(t), r = /(?:^|[^\p{L}\p{N}_-])a\s+la\s+fin\b/u.exec(t);
11357
11405
  return !n && !r ? null : n ? r ? n.index <= r.index ? "start" : "end" : "start" : "end";
11358
11406
  }
11359
- function fh(e) {
11407
+ function _h(e) {
11360
11408
  return e.toLowerCase().normalize("NFD").replace(/\p{Diacritic}/gu, "");
11361
11409
  }
11362
11410
  //#endregion
11363
11411
  //#region src/lib/text_parsers/action_words.ts
11364
- var ph = /\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;
11365
- function mh(e) {
11412
+ var vh = /\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;
11413
+ function yh(e) {
11366
11414
  return e.toLowerCase().normalize("NFD").replace(/\p{Diacritic}/gu, "");
11367
11415
  }
11368
- function hh(e, t = e) {
11416
+ function bh(e, t = e) {
11369
11417
  return /\bredige\b|\bredigee\b|\bredigees\b|\brediges\b|\bainsi\b/.test(e) || /\bdispositions suivantes\b/.test(t);
11370
11418
  }
11371
- function gh(e) {
11372
- return uh(e) === "after";
11419
+ function xh(e) {
11420
+ return hh(e) === "after";
11373
11421
  }
11374
- function _h(e) {
11375
- return uh(e) === "before";
11422
+ function Sh(e) {
11423
+ return hh(e) === "before";
11376
11424
  }
11377
- function vh(e) {
11425
+ function Ch(e) {
11378
11426
  return /\bretabl/.test(e);
11379
11427
  }
11380
- function yh(e) {
11428
+ function wh(e) {
11381
11429
  return /\binsere(?:e|es|s)?\b|\bajoute\b|\bajoutee\b|\bajoutes\b|\bajoutees\b|\bcomplete(?:e|es|s)?\b/.test(e);
11382
11430
  }
11383
- function bh(e) {
11431
+ function Th(e) {
11384
11432
  return /\bremplace\b|\bremplacee\b|\bremplaces\b|\bremplacees\b/.test(e);
11385
11433
  }
11386
- function xh(e) {
11434
+ function Eh(e) {
11387
11435
  return /\bsupprime\b|\bsupprimee\b|\bsupprimes\b|\bsupprimees\b|\babroge\b|\babrogee\b|\babroges\b|\babrogees\b/.test(e);
11388
11436
  }
11389
- function Sh(e) {
11437
+ function Dh(e) {
11390
11438
  return /\b(remplace|modifie|redige|rediges|redigee|redigees)\b/.test(e);
11391
11439
  }
11392
11440
  //#endregion
11393
11441
  //#region src/lib/extractors/portion_references.ts
11394
- function Ch(e, t) {
11442
+ function Oh(e, t) {
11395
11443
  e && (e.start += t, e.stop += t);
11396
11444
  }
11397
- function wh(e, t) {
11445
+ function kh(e, t) {
11398
11446
  if (e.type === "parent-enfant") {
11399
- wh(e.parent, t), wh(e.child, t), Ch(e.position, t);
11447
+ kh(e.parent, t), kh(e.child, t), Oh(e.position, t);
11400
11448
  return;
11401
11449
  }
11402
11450
  if (e.type === "bounded-interval") {
11403
- wh(e.first, t), wh(e.last, t), Ch(e.position, t);
11451
+ kh(e.first, t), kh(e.last, t), Oh(e.position, t);
11404
11452
  return;
11405
11453
  }
11406
11454
  if (e.type === "counted-interval") {
11407
- wh(e.first, t), Ch(e.position, t);
11455
+ kh(e.first, t), Oh(e.position, t);
11408
11456
  return;
11409
11457
  }
11410
11458
  if (e.type === "enumeration" || e.type === "exclusion") {
11411
- wh(e.left, t), wh(e.right, t), Ch(e.position, t);
11459
+ kh(e.left, t), kh(e.right, t), Oh(e.position, t);
11412
11460
  return;
11413
11461
  }
11414
11462
  if (e.type === "reference_et_action") {
11415
- wh(e.reference, t), Ch(e.position, t);
11463
+ kh(e.reference, t), Oh(e.position, t);
11416
11464
  return;
11417
11465
  }
11418
- Ch(e.position, t);
11466
+ Oh(e.position, t);
11419
11467
  }
11420
- function Th(e) {
11468
+ function Ah(e) {
11421
11469
  return e.replace(/\b(de\s+l['’]?|de\s+la|de\s+le|du|des)\s*$/i, "");
11422
11470
  }
11423
- function Eh(e) {
11471
+ function jh(e) {
11424
11472
  let t = /^(?:(?:[aà]\s+)?l['’]|(?:[aà]\s+)?la\b|(?:[aà]\s+)?le\b|les\b|des\b|aux\b|du\b)\s*/iu.exec(e)?.[0].length ?? 0, n = e.slice(t > 0 ? t : 0).trim();
11425
11473
  return n ? {
11426
11474
  text: n,
11427
11475
  offset: t
11428
11476
  } : null;
11429
11477
  }
11430
- function Dh(e) {
11478
+ function Mh(e) {
11431
11479
  return [...e.matchAll(/(?:^|\P{L})(\p{L})/gu)].map((e) => (e.index ?? 0) + e[0].length - (e[1]?.length ?? 0));
11432
11480
  }
11433
- function Oh(e) {
11481
+ function Nh(e) {
11434
11482
  let t = new S(e), n = Lt(t);
11435
11483
  return !n || t.remaining().trim().length !== 0 ? null : n;
11436
11484
  }
11437
- function kh(e) {
11438
- for (let t of Dh(e)) {
11485
+ function Ph(e) {
11486
+ for (let t of Mh(e)) {
11439
11487
  let n = new S(e, t), r = Tt(n);
11440
11488
  if (!(r === void 0 || n.remaining().trim() !== "")) return {
11441
11489
  nature: r,
@@ -11444,17 +11492,17 @@ function kh(e) {
11444
11492
  }
11445
11493
  return null;
11446
11494
  }
11447
- function Ah(e, t) {
11495
+ function Fh(e, t) {
11448
11496
  let n = e.trim().replace(/[;:,]\s*$/u, "").replace(/\b(?:est|sont)\s*$/iu, "").trim();
11449
11497
  if (!n) return null;
11450
- for (let e of Dh(n)) {
11451
- let r = n.slice(e).trim(), i = kh(r);
11498
+ for (let e of Mh(n)) {
11499
+ let r = n.slice(e).trim(), i = Ph(r);
11452
11500
  if (!i) continue;
11453
- let a = Mm(r.slice(0, i.start)).trim();
11501
+ let a = Lm(r.slice(0, i.start)).trim();
11454
11502
  if (!a) continue;
11455
11503
  let o = /\s*(,|\bet\b|\bou\b|(?<!\p{L})[aà](?!\p{L}))\s*/giu, s = [], c = 0, l;
11456
11504
  for (; (l = o.exec(a)) !== null;) {
11457
- let e = mh(l[1] ?? "");
11505
+ let e = yh(l[1] ?? "");
11458
11506
  if (a.slice(c, l.index).trim() === "") {
11459
11507
  e !== "a" && e !== "à" && (c = o.lastIndex);
11460
11508
  continue;
@@ -11471,17 +11519,17 @@ function Ah(e, t) {
11471
11519
  }), s.length < 2) continue;
11472
11520
  let u = s.some((e) => e.separator === "à"), d = [], f = [], p = !0, m = i.nature, h;
11473
11521
  for (let [n, r] of s.entries()) {
11474
- let i = Eh(r.text);
11522
+ let i = jh(r.text);
11475
11523
  if (!i) {
11476
11524
  d.length = 0;
11477
11525
  break;
11478
11526
  }
11479
- let a = Oh(`${i.text} ${m}`);
11527
+ let a = Nh(`${i.text} ${m}`);
11480
11528
  if (!a) {
11481
11529
  d.length = 0;
11482
11530
  break;
11483
11531
  }
11484
- wh(a, t + e + r.start + i.offset), d.push(a), a.type !== m || a.index === void 0 || a.index < 1 ? p = !1 : (h !== void 0 && !u && a.index !== h + 1 && (p = !1), h = a.index), n < s.length - 1 && (f.push(r.separator ?? "et"), (r.separator ?? "et") === "ou" && (p = !1));
11532
+ kh(a, t + e + r.start + i.offset), d.push(a), a.type !== m || a.index === void 0 || a.index < 1 ? p = !1 : (h !== void 0 && !u && a.index !== h + 1 && (p = !1), h = a.index), n < s.length - 1 && (f.push(r.separator ?? "et"), (r.separator ?? "et") === "ou" && (p = !1));
11485
11533
  }
11486
11534
  let [g, ..._] = d;
11487
11535
  if (!g || _.length === 0) continue;
@@ -11498,16 +11546,16 @@ function Ah(e, t) {
11498
11546
  }
11499
11547
  return null;
11500
11548
  }
11501
- function jh(e, t) {
11549
+ function Ih(e, t) {
11502
11550
  let n = e.trim().replace(/[;:,]\s*$/u, "").replace(/\b(?:est|sont)\s*$/iu, "").trim();
11503
11551
  if (!n) return null;
11504
- for (let e of Dh(n)) {
11552
+ for (let e of Mh(n)) {
11505
11553
  let r = n.slice(e);
11506
11554
  if (!r) continue;
11507
11555
  let i = new S(r), a = Lt(i);
11508
11556
  if (!a || i.offset === 0 || !x(i)) continue;
11509
- let o = i.offset, s = Ah(r.slice(o), t + e + o);
11510
- if (s) return wh(a, t + e), {
11557
+ let o = i.offset, s = Fh(r.slice(o), t + e + o);
11558
+ if (s) return kh(a, t + e), {
11511
11559
  ...pt(s, a),
11512
11560
  position: {
11513
11561
  start: a.position.start,
@@ -11517,65 +11565,65 @@ function jh(e, t) {
11517
11565
  }
11518
11566
  return null;
11519
11567
  }
11520
- function Mh(e, t) {
11521
- let n = Th(e);
11568
+ function Lh(e, t) {
11569
+ let n = Ah(e);
11522
11570
  if (!n) return null;
11523
- let r = jh(n, t);
11571
+ let r = Ih(n, t);
11524
11572
  if (r) return r;
11525
- let i = Ah(n, t);
11573
+ let i = Fh(n, t);
11526
11574
  if (i) return i;
11527
- for (let e of Dh(n)) {
11575
+ for (let e of Mh(n)) {
11528
11576
  let r = n.slice(e);
11529
11577
  if (!r) continue;
11530
11578
  let i = new S(r), a = Lt(i);
11531
- if (!(!a || i.offset === 0) && r.slice(i.offset).trim().length === 0) return wh(a, t + e), a;
11579
+ if (!(!a || i.offset === 0) && r.slice(i.offset).trim().length === 0) return kh(a, t + e), a;
11532
11580
  }
11533
11581
  return null;
11534
11582
  }
11535
- function Nh(e) {
11536
- return Math.max(0, ...Hp(e).map((e) => e.kind === "single" ? e.steps.length : Math.max(e.first.length, e.last.length)));
11583
+ function Rh(e) {
11584
+ return Math.max(0, ...qp(e).map((e) => e.kind === "single" ? e.steps.length : Math.max(e.first.length, e.last.length)));
11537
11585
  }
11538
- function Ph(e) {
11539
- return Hp(e).length;
11586
+ function zh(e) {
11587
+ return qp(e).length;
11540
11588
  }
11541
- function Fh(e, t) {
11589
+ function Bh(e, t) {
11542
11590
  if (!e) return t;
11543
11591
  if (!t) return e;
11544
- let n = Nh(e), r = Nh(t);
11545
- return n === r ? Ph(e) >= Ph(t) ? e : t : n > r ? e : t;
11592
+ let n = Rh(e), r = Rh(t);
11593
+ return n === r ? zh(e) >= zh(t) ? e : t : n > r ? e : t;
11546
11594
  }
11547
- function Ih(e) {
11595
+ function Vh(e) {
11548
11596
  return e.map((e) => ({
11549
11597
  reference: e,
11550
- specificity: Nh(e)
11598
+ specificity: Rh(e)
11551
11599
  })).filter((e) => e.specificity > 0).sort((e, t) => t.specificity - e.specificity)[0]?.reference ?? null;
11552
11600
  }
11553
- function Lh(e, { actionIndex: t = e.length } = {}) {
11601
+ function Hh(e, { actionIndex: t = e.length } = {}) {
11554
11602
  let n = /\barticle\b/i.exec(e);
11555
11603
  if (!n || n.index === void 0) return null;
11556
11604
  let r = n.index, i = new S(e.slice(r)), a = dn(i);
11557
11605
  if (!a) return null;
11558
- wh(a, r);
11559
- let o = e.slice(0, r), s = r + i.offset, c = e.slice(s, t), l = Fh(Ih(Rh(o)), Mh(o, 0)) ?? Ih(Rh(c)) ?? Mh(c, s);
11606
+ kh(a, r);
11607
+ let o = e.slice(0, r), s = r + i.offset, c = e.slice(s, t), l = Bh(Vh(Uh(o)), Lh(o, 0)) ?? Vh(Uh(c)) ?? Lh(c, s);
11560
11608
  return l ? pt(a, l) : null;
11561
11609
  }
11562
- function Rh(e) {
11563
- return ih(new S(e));
11610
+ function Uh(e) {
11611
+ return lh(new S(e));
11564
11612
  }
11565
11613
  //#endregion
11566
11614
  //#region src/lib/extractors/quoted_text.ts
11567
- function zh(e) {
11615
+ function Wh(e) {
11568
11616
  return e.split(/\n+/).map((e) => e.replace(/^\s*[«“"]\s*/u, "").trim()).filter((e) => e.length > 0).join("\n").replace(/[»”"]\s*$/u, "").trim();
11569
11617
  }
11570
- function Bh(e, t) {
11571
- return nm(e, t).map((t) => ({
11618
+ function Gh(e, t) {
11619
+ return sm(e, t).map((t) => ({
11572
11620
  closed: t.closed,
11573
- text: zh(t.content.map(({ start: t, stop: n }) => e.slice(t, n)).join("\n")),
11621
+ text: Wh(t.content.map(({ start: t, stop: n }) => e.slice(t, n)).join("\n")),
11574
11622
  start: t.position.start,
11575
11623
  end: t.position.stop
11576
11624
  }));
11577
11625
  }
11578
- function Vh(e, t) {
11626
+ function Kh(e, t) {
11579
11627
  if (t.length === 0) return e;
11580
11628
  let n = 0, r = [];
11581
11629
  for (let { start: i, end: a } of t) {
@@ -11584,30 +11632,30 @@ function Vh(e, t) {
11584
11632
  }
11585
11633
  return n < e.length && r.push(e.slice(n)), r.join("");
11586
11634
  }
11587
- function Hh(e) {
11588
- return nm(e, { allowUnclosed: !0 }).map(({ position: e }) => ({
11635
+ function qh(e) {
11636
+ return sm(e, { allowUnclosed: !0 }).map(({ position: e }) => ({
11589
11637
  start: e.start,
11590
11638
  end: e.stop
11591
11639
  }));
11592
11640
  }
11593
- function Uh(e, t) {
11641
+ function Jh(e, t) {
11594
11642
  return e ? t.some((t) => e.start >= t.start && e.stop <= t.end) : !1;
11595
11643
  }
11596
- function Wh(e, t) {
11597
- return Uh(e, t);
11644
+ function Yh(e, t) {
11645
+ return Jh(e, t);
11598
11646
  }
11599
- function Gh(e) {
11647
+ function Xh(e) {
11600
11648
  if (!e.includes("«")) return e;
11601
11649
  let t = e.split("");
11602
- for (let { start: n, end: r } of Hh(e)) for (let e = n + 1; e < r; e++) t[e] === "«" || t[e] === "»" || (t[e] = " ");
11650
+ for (let { start: n, end: r } of qh(e)) for (let e = n + 1; e < r; e++) t[e] === "«" || t[e] === "»" || (t[e] = " ");
11603
11651
  return t.join("");
11604
11652
  }
11605
11653
  //#endregion
11606
11654
  //#region src/lib/text_parsers/action_citation_patterns.ts
11607
- function Kh(e) {
11655
+ function Zh(e) {
11608
11656
  return `(?:${e.join("|")})`;
11609
11657
  }
11610
- var qh = [
11658
+ var Qh = [
11611
11659
  "(?:à\\s+|de\\s+)?l[’']année",
11612
11660
  "(?:à\\s+|de\\s+)?la date",
11613
11661
  "(?:à\\s+|de\\s+)?la mention",
@@ -11625,7 +11673,7 @@ var qh = [
11625
11673
  "(?:aux|des|les)\\s+nombres",
11626
11674
  "(?:aux|des|les)\\s+références",
11627
11675
  "le tableau intitulé"
11628
- ], Jh = [
11676
+ ], $h = [
11629
11677
  "l[’']année",
11630
11678
  "la date",
11631
11679
  "la mention",
@@ -11643,10 +11691,10 @@ var qh = [
11643
11691
  "les mots",
11644
11692
  "les nombres",
11645
11693
  "les références"
11646
- ], Yh = Kh(qh), Xh = Kh(Jh);
11694
+ ], eg = Zh(Qh), tg = Zh($h);
11647
11695
  //#endregion
11648
11696
  //#region src/lib/text_parsers/action_directives.ts
11649
- function Zh(e) {
11697
+ function ng(e) {
11650
11698
  return e.type === "reference_et_action" ? {
11651
11699
  action: e.action,
11652
11700
  reference: e.reference
@@ -11655,13 +11703,13 @@ function Zh(e) {
11655
11703
  reference: e
11656
11704
  };
11657
11705
  }
11658
- function Qh(e) {
11706
+ function rg(e) {
11659
11707
  let t = e.indices?.[0]?.[0] ?? e.index, n = /« ?(.*?) ?»/dg, r = [], i;
11660
11708
  for (; (i = n.exec(e[0])) !== null;) {
11661
11709
  let e = i.indices?.[1], n = i.indices?.[0];
11662
11710
  if (!e || !n) continue;
11663
11711
  let a = e[0], o = e[1], s = n[0], c = n[1];
11664
- r.push(Yp({
11712
+ r.push(em({
11665
11713
  start: t + a,
11666
11714
  stop: t + o
11667
11715
  }, {
@@ -11671,21 +11719,21 @@ function Qh(e) {
11671
11719
  }
11672
11720
  return r;
11673
11721
  }
11674
- var $h = a([
11675
- _(`${Yh}s?`, { flags: "i" }),
11722
+ var ig = a([
11723
+ _(`${eg}s?`, { flags: "i" }),
11676
11724
  _(" ?: ?"),
11677
11725
  Z
11678
- ], { value: (e) => e[2] }), eg = a([
11679
- _(`${Xh}s?(?: suivant(?:e)?s?)?`, { flags: "i" }),
11726
+ ], { value: (e) => e[2] }), ag = a([
11727
+ _(`${tg}s?(?: suivant(?:e)?s?)?`, { flags: "i" }),
11680
11728
  _(" ?: ?"),
11681
11729
  Z
11682
- ], { value: (e) => e[2] }), tg = a([
11730
+ ], { value: (e) => e[2] }), og = a([
11683
11731
  E,
11684
- $h,
11732
+ ig,
11685
11733
  T,
11686
11734
  o(_("est remplacée? par", { flags: "i" }), _("sont remplacée?s par", { flags: "i" })),
11687
11735
  T,
11688
- eg
11736
+ ag
11689
11737
  ], { value: (e) => ({
11690
11738
  action: {
11691
11739
  action: "remplacer",
@@ -11696,9 +11744,9 @@ var $h = a([
11696
11744
  replacementCitation: e[5],
11697
11745
  targetCitation: e[1]
11698
11746
  }
11699
- }) }), ng = o(_(`(?:, ?| )(?:${Yh}s? ?: ?« ?[^»]+ ?»(?: ?(?:,|et) ?)*)+(?:est|sont) (?:supprimée?s?|abrogée?s?)`, {
11747
+ }) }), sg = o(_(`(?:, ?| )(?:${eg}s? ?: ?« ?[^»]+ ?»(?: ?(?:,|et) ?)*)+(?:est|sont) (?:supprimée?s?|abrogée?s?)`, {
11700
11748
  flags: "di",
11701
- value: (e) => Qh(e).map((e) => ({
11749
+ value: (e) => rg(e).map((e) => ({
11702
11750
  action: {
11703
11751
  action: "supprimer",
11704
11752
  actionInContent: !0
@@ -11710,8 +11758,8 @@ var $h = a([
11710
11758
  }))
11711
11759
  }), a([
11712
11760
  E,
11713
- $h,
11714
- b([_("(?:, ?| et )"), $h], { value: (e) => e.map((e) => e[1]) }),
11761
+ ig,
11762
+ b([_("(?:, ?| et )"), ig], { value: (e) => e.map((e) => e[1]) }),
11715
11763
  T,
11716
11764
  o(_("est supprimée?", { flags: "i" }), _("sont supprimée?s", { flags: "i" }), _("est abrogée?", { flags: "i" }), _("sont abrogée?s", { flags: "i" }))
11717
11765
  ], { value: (e) => [e[1], ...e[2] ?? []].map((e) => ({
@@ -11723,9 +11771,9 @@ var $h = a([
11723
11771
  kind: "delete",
11724
11772
  targetCitation: e
11725
11773
  }
11726
- })) })), rg = o(a([
11774
+ })) })), cg = o(a([
11727
11775
  E,
11728
- sh,
11776
+ fh,
11729
11777
  T,
11730
11778
  _("(?:la référence|la mention|le mot|les mots|le signe)", { flags: "i" }),
11731
11779
  _(" ?: ?"),
@@ -11741,10 +11789,10 @@ var $h = a([
11741
11789
  },
11742
11790
  operation: {
11743
11791
  insertCitation: e[9],
11744
- kind: lh(e[1]),
11792
+ kind: mh(e[1]),
11745
11793
  targetCitation: e[5]
11746
11794
  }
11747
- }) }), tg, ng, a([
11795
+ }) }), og, sg, a([
11748
11796
  E,
11749
11797
  o(_("est ainsi rédigée?", { flags: "i" }), _("sont ainsi rédigée?s", { flags: "i" }), _("est rédigée? (?:ainsi qu'il|comme) suit", { flags: "i" }), _("sont rédigée?s (?:ainsi qu'il|comme) suit", { flags: "i" })),
11750
11798
  _(" ?: ?"),
@@ -11759,27 +11807,27 @@ var $h = a([
11759
11807
  replacementCitation: e[3],
11760
11808
  replacementKind: "text"
11761
11809
  }
11762
- }) })), ig = o(rg, a([_(" et"), rg], { value: (e) => e[1] })), ag = w(o(a([
11810
+ }) })), lg = o(cg, a([_(" et"), cg], { value: (e) => e[1] })), ug = w(o(a([
11763
11811
  T,
11764
11812
  _("par", { flags: "i" }),
11765
11813
  T,
11766
- eg
11814
+ ag
11767
11815
  ], { value: (e) => ({
11768
11816
  citation: e[3],
11769
11817
  kind: "replace"
11770
- }) }), a([T, eg], { value: (e) => ({
11818
+ }) }), a([T, ag], { value: (e) => ({
11771
11819
  citation: e[1],
11772
11820
  kind: "insert"
11773
11821
  }) })), { default: null });
11774
- function og(e) {
11822
+ function dg(e) {
11775
11823
  return typeof e == "object" && !!e && "action" in e && "operation" in e;
11776
11824
  }
11777
- function sg(e) {
11825
+ function fg(e) {
11778
11826
  let t = [];
11779
- for (let n of e) og(n) ? t.push(n) : Array.isArray(n) && t.push(...sg(n));
11827
+ for (let n of e) dg(n) ? t.push(n) : Array.isArray(n) && t.push(...fg(n));
11780
11828
  return t;
11781
11829
  }
11782
- function cg(e, t) {
11830
+ function pg(e, t) {
11783
11831
  if (!e) return [];
11784
11832
  let n = e.originalCitations ?? [];
11785
11833
  if (e.action === "remplacer") {
@@ -11827,12 +11875,12 @@ function cg(e, t) {
11827
11875
  }
11828
11876
  return [];
11829
11877
  }
11830
- var lg = ye("après|avant|remplacée?s?|supprimée?s?|abrogée?s?|ins[eé]r[eé]e?s?|ajout[eé]e?s?|rédigée?s?", a([
11831
- Km,
11832
- ag,
11833
- b(ig, { value: (e) => sg(e) })
11878
+ var mg = ye("après|avant|remplacée?s?|supprimée?s?|abrogée?s?|ins[eé]r[eé]e?s?|ajout[eé]e?s?|rédigée?s?", a([
11879
+ Zm,
11880
+ ug,
11881
+ b(lg, { value: (e) => fg(e) })
11834
11882
  ], { value: (e, t) => {
11835
- let { action: n, reference: r } = Zh(e[0]), i = [...cg(n, e[1]), ...e[2] ?? []], a = n ?? i[0]?.action;
11883
+ let { action: n, reference: r } = ng(e[0]), i = [...pg(n, e[1]), ...e[2] ?? []], a = n ?? i[0]?.action;
11836
11884
  if (!(!a || i.length === 0)) return {
11837
11885
  action: a,
11838
11886
  operations: i.map(({ operation: e }) => e),
@@ -11840,7 +11888,7 @@ var lg = ye("après|avant|remplacée?s?|supprimée?s?|abrogée?s?|ins[eé]r[eé]
11840
11888
  reference: r,
11841
11889
  type: "action_directive"
11842
11890
  };
11843
- } }), 200), ug = a([
11891
+ } }), 200), hg = a([
11844
11892
  _("la\\s+fin\\s+de\\s+", { flags: "i" }),
11845
11893
  w(_("(?:la\\s+|l['’]\\s*)", { flags: "i" }), { default: "" }),
11846
11894
  o(_("phrase", {
@@ -11857,14 +11905,14 @@ var lg = ye("après|avant|remplacée?s?|supprimée?s?|abrogée?s?|ins[eé]r[eé]
11857
11905
  type: "tail_after_target",
11858
11906
  unit: e[2]
11859
11907
  }) });
11860
- function dg(e) {
11908
+ function gg(e) {
11861
11909
  if (e.type === "phrase") return "phrase";
11862
11910
  if (e.type === "alinéa") return "alinéa";
11863
11911
  if (e.type === "article") return "article";
11864
- if (e.type === "parent-enfant") return dg(e.child);
11912
+ if (e.type === "parent-enfant") return gg(e.child);
11865
11913
  }
11866
- function fg(e) {
11867
- let t = mh(e);
11914
+ function _g(e) {
11915
+ let t = yh(e);
11868
11916
  if (!/\bla\s+fin\s+d/iu.test(t)) return null;
11869
11917
  let n = /\bla\s+fin\s+(?:de\s+la|d['’]?une|du|de\s+l['’]?|des)\s*[^,;.]*\bphrase\b/u.test(t) ? "phrase" : /\bla\s+fin\s+(?:de\s+la|d['’]?un|du|de\s+l['’]?|des)\s*[^,;.]*\balinea\b/u.test(t) ? "alinéa" : /\bla\s+fin\s+(?:de\s+l['’]?|d['’]?)article\b/u.test(t) ? "article" : void 0;
11870
11918
  return {
@@ -11874,10 +11922,10 @@ function fg(e) {
11874
11922
  }
11875
11923
  //#endregion
11876
11924
  //#region src/lib/text_parsers/action_occurrences.ts
11877
- function pg(e) {
11925
+ function vg(e) {
11878
11926
  return e.replace(/\s+/gu, " ").trim().normalize("NFD").replace(/[\u0300-\u036f]/gu, "").replace(/[’‘]/gu, "'").toLowerCase();
11879
11927
  }
11880
- function mg(e, t) {
11928
+ function yg(e, t) {
11881
11929
  let n = e.slice(0, Math.max(0, t)), r = RegExp(`\\b(${he})\\s+occurrence\\b`, "giu"), i = null, a;
11882
11930
  for (; (a = r.exec(n)) !== null;) {
11883
11931
  if (/^derni(?:ère|ere)$/iu.test(a[1] ?? "")) {
@@ -11889,13 +11937,64 @@ function mg(e, t) {
11889
11937
  }
11890
11938
  return i;
11891
11939
  }
11892
- function hg(e) {
11893
- let t = pg(e);
11894
- return /\b(?:derniere\s+occurrence|a\s+la\s+fin)\b/u.test(t) ? "last" : mg(e, e.length) ?? void 0;
11940
+ function bg(e) {
11941
+ let t = vg(e);
11942
+ return /\b(?:derniere\s+occurrence|a\s+la\s+fin)\b/u.test(t) ? "last" : yg(e, e.length) ?? void 0;
11943
+ }
11944
+ //#endregion
11945
+ //#region src/lib/text_parsers/table_row_targets.ts
11946
+ var xg = ye("lignes du tableau", a([
11947
+ _("les ", { flags: "i" }),
11948
+ o(a([
11949
+ De,
11950
+ _(" et ", { flags: "i" }),
11951
+ De
11952
+ ], { value: (e) => {
11953
+ let t = e[0], n = e[2];
11954
+ return t > 0 && n === t + 1 ? {
11955
+ rowIndex: t,
11956
+ rowEndIndex: n
11957
+ } : void 0;
11958
+ } }), a([
11959
+ ge,
11960
+ _(" "),
11961
+ Ne
11962
+ ], { value: (e) => {
11963
+ let t = e[0], n = e[2];
11964
+ return t > 1 && n.index === -1 ? {
11965
+ rowIndex: -t,
11966
+ rowEndIndex: -1
11967
+ } : void 0;
11968
+ } })),
11969
+ _(" lignes du tableau", { flags: "i" })
11970
+ ], { value: (e, t) => ({
11971
+ ...e[1],
11972
+ position: t.position()
11973
+ }) })), Sg = ye("lignes du tableau constituant", a([
11974
+ xg,
11975
+ _(" constituant le ", { flags: "i" }),
11976
+ Dt,
11977
+ e,
11978
+ dn
11979
+ ], { value: (e, t) => {
11980
+ let { rowIndex: n, rowEndIndex: r } = e[0], i = e[2];
11981
+ if (!(i.type !== "alinéa" || i.index === void 0 || n < 1 || r !== n + 1)) return {
11982
+ article: e[4],
11983
+ alineaIndex: i.index,
11984
+ rowIndex: n,
11985
+ rowEndIndex: r,
11986
+ position: t.position()
11987
+ };
11988
+ } }));
11989
+ function Cg(e) {
11990
+ return [...xg.extract(new S(e), { overlapWindow: 50 })];
11991
+ }
11992
+ function wg(e) {
11993
+ return [...Sg.extract(new S(e), { overlapWindow: 50 })];
11895
11994
  }
11896
11995
  //#endregion
11897
11996
  //#region src/lib/extractors/action_directives.ts
11898
- function gg() {
11997
+ function Tg() {
11899
11998
  return {
11900
11999
  applyApplicabilityDatesMs: 0,
11901
12000
  buildListItemTreeMs: 0,
@@ -11931,38 +12030,38 @@ function gg() {
11931
12030
  function Q(e, t, n) {
11932
12031
  e !== void 0 && (e[t] += Math.round((performance.now() - n) * 10) / 10);
11933
12032
  }
11934
- var _g = "(?:(?:alinea|alineas|section|sous-section|paragraphe|sous-paragraphe|sous-sous-paragraphe|chapitre|titre|livre|partie)|(?:[ivxlcdm]+|[a-z]|\\d+\\s*°?)(?:\\s+(?:bis|ter|quater|quinquies|sexies|septies|octies|nonies|decies|undecies|duodecies))?)", vg = "(?:un|une|l['’]?|le|la)";
11935
- function yg(e) {
12033
+ var Eg = "(?:(?:alinea|alineas|section|sous-section|paragraphe|sous-paragraphe|sous-sous-paragraphe|chapitre|titre|livre|partie)|(?:[ivxlcdm]+|[a-z]|\\d+\\s*°?)(?:\\s+(?:bis|ter|quater|quinquies|sexies|septies|octies|nonies|decies|undecies|duodecies))?)", Dg = "(?:un|une|l['’]?|le|la)";
12034
+ function Og(e) {
11936
12035
  return /\b(?:les?|la|l['’]?)\s+(?:mots?|references?|mentions?|signes?|nombres?|montants?|taux|pourcentages?|dates?|annees?)\b/u.test(e);
11937
12036
  }
11938
- function bg(e) {
12037
+ function kg(e) {
11939
12038
  return /\b(?:une|la|les?)\s+phrases?\b/u.test(e);
11940
12039
  }
11941
- function xg(e) {
11942
- return new RegExp(String.raw`\b(?:insere(?:e|es|s)?|ajoute(?:e|es|s)?|complete(?:e|es|s)?|retabli(?:e|es|s)?)\b[\s\S]{0,90}\b${vg}\s+${_g}\b`, "u").test(e) ? !0 : new RegExp(String.raw`\b${vg}\s+${_g}\b[\s\S]{0,90}\b(?:est|sont)\s+(?:ainsi\s+)?(?:insere(?:e|es|s)?|ajoute(?:e|es|s)?|complete(?:e|es|s)?|retabli(?:e|es|s)?)\b`, "u").test(e);
12040
+ function Ag(e) {
12041
+ return new RegExp(String.raw`\b(?:insere(?:e|es|s)?|ajoute(?:e|es|s)?|complete(?:e|es|s)?|retabli(?:e|es|s)?)\b[\s\S]{0,90}\b${Dg}\s+${Eg}\b`, "u").test(e) ? !0 : new RegExp(String.raw`\b${Dg}\s+${Eg}\b[\s\S]{0,90}\b(?:est|sont)\s+(?:ainsi\s+)?(?:insere(?:e|es|s)?|ajoute(?:e|es|s)?|complete(?:e|es|s)?|retabli(?:e|es|s)?)\b`, "u").test(e);
11943
12042
  }
11944
- function Sg({ hasRedactionIntro: e, insertText: t, normalized: n }) {
11945
- if (!yg(n) && !bg(n) && (xg(n) && /\balinea\b/u.test(n) || e && Sp(t))) return "block";
12043
+ function jg({ hasRedactionIntro: e, insertText: t, normalized: n }) {
12044
+ if (!Og(n) && !kg(n) && (Ag(n) && /\balinea\b/u.test(n) || e && Ep(t))) return "block";
11946
12045
  }
11947
- function Cg({ hasRedactionIntro: e, normalized: t, replacementText: n }) {
11948
- if (!bg(t) && (e && /\balineas?\b/u.test(t) || e && Sp(n))) return "block";
12046
+ function Mg({ hasRedactionIntro: e, normalized: t, replacementText: n }) {
12047
+ if (!kg(t) && (e && /\balineas?\b/u.test(t) || e && Ep(n))) return "block";
11949
12048
  }
11950
- function wg(e) {
11951
- let t = Cp(e);
12049
+ function Ng(e) {
12050
+ let t = Dp(e);
11952
12051
  return t ? t.restText : e;
11953
12052
  }
11954
- function Tg(e) {
11955
- let t = wg(e);
11956
- return t === e ? e.replace(yp, "") : t;
12053
+ function Pg(e) {
12054
+ let t = Ng(e);
12055
+ return t === e ? e.replace(Cp, "") : t;
11957
12056
  }
11958
- function Eg(e, t) {
12057
+ function Fg(e, t) {
11959
12058
  if (e === void 0) return;
11960
- let n = /^Le (.+?) est ainsi r[eé]dig[eé] :$/u.exec(Tg(e).trim());
12059
+ let n = /^Le (.+?) est ainsi r[eé]dig[eé] :$/u.exec(Pg(e).trim());
11961
12060
  if (!n) return;
11962
- let r = Cp(`${n[1]}. – rédaction`), i = Cp(t);
12061
+ let r = Dp(`${n[1]}. – rédaction`), i = Dp(t);
11963
12062
  if (!(!r || !i || r.token !== i.token || r.level !== i.level || !i.restText.startsWith("«"))) return i.token;
11964
12063
  }
11965
- function Dg(e) {
12064
+ function Ig(e) {
11966
12065
  let t = e.split("\n"), n = [], r = 0;
11967
12066
  for (let e of t) {
11968
12067
  let t = r, i = t + e.length;
@@ -11974,129 +12073,129 @@ function Dg(e) {
11974
12073
  }
11975
12074
  return n;
11976
12075
  }
11977
- function Og(e) {
11978
- return Cp(e) !== void 0 || yp.test(e);
12076
+ function Lg(e) {
12077
+ return Dp(e) !== void 0 || Cp.test(e);
11979
12078
  }
11980
- function kg(e) {
11981
- if (yp.test(e)) return {
12079
+ function Rg(e) {
12080
+ if (Cp.test(e)) return {
11982
12081
  marker: "-",
11983
12082
  level: 5
11984
12083
  };
11985
- let t = Cp(e);
12084
+ let t = Dp(e);
11986
12085
  return t ? {
11987
12086
  marker: t.token,
11988
- level: Ag(t.token)
12087
+ level: zg(t.token)
11989
12088
  } : null;
11990
12089
  }
11991
- function Ag(e) {
12090
+ function zg(e) {
11992
12091
  let t = e.trim().split(/\s+/u)[0]?.replace(/[^\p{L}\p{N}]+/gu, "") ?? "";
11993
- return /^\d+$/u.test(t) ? 2 : /^[ivxlcdm]+$/u.test(t) && (t.length > 1 || /^[ivx]$/u.test(t)) ? 4 : /^[a-z]$/u.test(t) ? 3 : xp(t) || /^[A-Z]$/u.test(t) ? 1 : 2;
12092
+ return /^\d+$/u.test(t) ? 2 : /^[ivxlcdm]+$/u.test(t) && (t.length > 1 || /^[ivx]$/u.test(t)) ? 4 : /^[a-z]$/u.test(t) ? 3 : Tp(t) || /^[A-Z]$/u.test(t) ? 1 : 2;
11994
12093
  }
11995
- function jg(e) {
12094
+ function Bg(e) {
11996
12095
  let t = [], n = e;
11997
12096
  for (;;) {
11998
- let e = kg(n);
12097
+ let e = Rg(n);
11999
12098
  if (!e) return t;
12000
12099
  t.push(e.marker);
12001
- let r = Tg(n);
12100
+ let r = Pg(n);
12002
12101
  if (r === n) return t;
12003
12102
  n = r.trimStart();
12004
12103
  }
12005
12104
  }
12006
- function Mg(e) {
12007
- let t = mh(Vh(e, Bh(e))), n = String.raw`(?:(?:la\s+reference|la\s+mention|les\s+mots|le\s+mot|le\s+signe|les\s+references)|(?:${vg}\s+${_g}))?`;
12105
+ function Vg(e) {
12106
+ let t = yh(Kh(e, Gh(e))), n = String.raw`(?:(?:la\s+reference|la\s+mention|les\s+mots|le\s+mot|le\s+signe|les\s+references)|(?:${Dg}\s+${Eg}))?`;
12008
12107
  return new RegExp(String.raw`(?:^|[;:.]\s*)(?:(?:il\s+)?est|sont)\s+${"(?:insere(?:e|es|s)?|ajoute(?:e|es|s)?)"}\s+${n}\s*(?:ainsi\s+redigee?s?)?\s*:`, "u").exec(t)?.index ?? null;
12009
12108
  }
12010
- function Ng(e) {
12011
- let t = Mg(e);
12109
+ function Hg(e) {
12110
+ let t = Vg(e);
12012
12111
  if (t !== null) return t;
12013
12112
  for (let t = 0; t < e.length; t += 1) {
12014
12113
  let n = new S(e.slice(t));
12015
- if (Fm(n) && n.offset > 0) return t;
12114
+ if (Bm(n) && n.offset > 0) return t;
12016
12115
  }
12017
12116
  return null;
12018
12117
  }
12019
- function Pg() {
12118
+ function Ug() {
12020
12119
  return {
12021
12120
  actionIndexByText: /* @__PURE__ */ new Map(),
12022
12121
  quoteRangesByText: /* @__PURE__ */ new Map(),
12023
12122
  referencesByText: /* @__PURE__ */ new Map()
12024
12123
  };
12025
12124
  }
12026
- function Fg(e, t, n) {
12027
- if (e === void 0) return Ng(t);
12125
+ function Wg(e, t, n) {
12126
+ if (e === void 0) return Hg(t);
12028
12127
  if (e.actionIndexByText.has(t)) return n !== void 0 && (n.listActionIndexCacheHitCount += 1), e.actionIndexByText.get(t) ?? null;
12029
12128
  n !== void 0 && (n.listActionIndexCacheMissCount += 1);
12030
- let r = Ng(t);
12129
+ let r = Hg(t);
12031
12130
  return e.actionIndexByText.set(t, r), r;
12032
12131
  }
12033
- function Ig(e, t, n) {
12034
- if (e === void 0) return Hh(t);
12132
+ function Gg(e, t, n) {
12133
+ if (e === void 0) return qh(t);
12035
12134
  let r = e.quoteRangesByText.get(t);
12036
12135
  if (r !== void 0) return n !== void 0 && (n.listQuoteRangeCacheHitCount += 1), r;
12037
12136
  n !== void 0 && (n.listQuoteRangeCacheMissCount += 1);
12038
- let i = Hh(t);
12137
+ let i = qh(t);
12039
12138
  return e.quoteRangesByText.set(t, i), i;
12040
12139
  }
12041
- function Lg(e, t, n) {
12042
- if (e === void 0) return ih(new S(t));
12140
+ function Kg(e, t, n) {
12141
+ if (e === void 0) return lh(new S(t));
12043
12142
  let r = e.referencesByText.get(t);
12044
12143
  if (r !== void 0) return n !== void 0 && (n.listReferenceCacheHitCount += 1), structuredClone(r);
12045
12144
  n !== void 0 && (n.listReferenceCacheMissCount += 1);
12046
- let i = ih(new S(t));
12145
+ let i = lh(new S(t));
12047
12146
  return e.referencesByText.set(t, structuredClone(i)), i;
12048
12147
  }
12049
- function Rg(e) {
12148
+ function qg(e) {
12050
12149
  return e.type === "reference_et_action" ? e.reference : e;
12051
12150
  }
12052
- function zg(e, t, n, r = e.length) {
12053
- let i = Ig(t, e, n);
12054
- return Lg(t, e, n).map(Rg).find((e) => yt(e) === "article" && !Wh(e.position, i) && (e.position?.start ?? 0) < r) || (tv(Gh(e).slice(0, r))?.reference ?? null);
12151
+ function Jg(e, t, n, r = e.length) {
12152
+ let i = Gg(t, e, n);
12153
+ return Kg(t, e, n).map(qg).find((e) => yt(e) === "article" && !Yh(e.position, i) && (e.position?.start ?? 0) < r) || (uv(Xh(e).slice(0, r))?.reference ?? null);
12055
12154
  }
12056
- function Bg(e, t, n, r) {
12057
- let i = Ig(n, e, r), a = Lg(n, e, r), o = a.flatMap((e) => Array.from(k(Rg(e)))).filter((e) => e.type === "article" && e.position).map((e) => ({
12155
+ function Yg(e, t, n, r) {
12156
+ let i = Gg(n, e, r), a = Kg(n, e, r), o = a.flatMap((e) => Array.from(k(qg(e)))).filter((e) => e.type === "article" && e.position).map((e) => ({
12058
12157
  start: e.position.start,
12059
12158
  end: e.position.stop
12060
- })), s = a.map(Rg).filter((e) => !Wh(e.position, i) && !Uh(e.position, o) && yt(e) !== "article" && (e.position?.start ?? 0) < t).sort((e, t) => (e.position?.start ?? 0) - (t.position?.start ?? 0)), c = e.slice(0, t).trimEnd(), l = Mh(I_(c), 0) ?? Mh(c, 0) ?? Mh(c.replace(/\b(?:est|sont)\s*$/iu, "").trimEnd(), 0), u = l && !Uh(l.position, o) ? l : null, d = s[0];
12061
- return d ? Fh(d, u) : u;
12159
+ })), s = a.map(qg).filter((e) => !Yh(e.position, i) && !Jh(e.position, o) && yt(e) !== "article" && (e.position?.start ?? 0) < t).sort((e, t) => (e.position?.start ?? 0) - (t.position?.start ?? 0)), c = e.slice(0, t).trimEnd(), l = Lh(G_(c), 0) ?? Lh(c, 0) ?? Lh(c.replace(/\b(?:est|sont)\s*$/iu, "").trimEnd(), 0), u = l && !Jh(l.position, o) ? l : null, d = s[0];
12160
+ return d ? Bh(d, u) : u;
12062
12161
  }
12063
- function Vg(e, t, n) {
12064
- let r = Fg(t, e, n) ?? e.length, i = Ig(t, e, n), a = Lg(t, e, n).map(Rg).filter((e) => !Wh(e.position, i) && (e.position?.start ?? 0) < r).sort((e, t) => (e.position?.start ?? 0) - (t.position?.start ?? 0));
12162
+ function Xg(e, t, n) {
12163
+ let r = Wg(t, e, n) ?? e.length, i = Gg(t, e, n), a = Kg(t, e, n).map(qg).filter((e) => !Yh(e.position, i) && (e.position?.start ?? 0) < r).sort((e, t) => (e.position?.start ?? 0) - (t.position?.start ?? 0));
12065
12164
  return a.length === 0 ? null : a.find((e) => yt(e) !== "article") ?? null ?? a[0] ?? null;
12066
12165
  }
12067
- function Hg(e, t, n) {
12068
- let r = [e, wg(e)].map((e) => e.trim()).filter((e, t, n) => e && n.indexOf(e) === t);
12166
+ function Zg(e, t, n) {
12167
+ let r = [e, Ng(e)].map((e) => e.trim()).filter((e, t, n) => e && n.indexOf(e) === t);
12069
12168
  for (let e of r) {
12070
- let r = Fg(t, e, n) ?? e.length, i = Mh(e, 0) ?? Lh(e, { actionIndex: r }) ?? Vg(e, t, n) ?? zg(e, t, n);
12169
+ let r = Wg(t, e, n) ?? e.length, i = Lh(e, 0) ?? Hh(e, { actionIndex: r }) ?? Xg(e, t, n) ?? Jg(e, t, n);
12071
12170
  if (i) return i;
12072
12171
  }
12073
12172
  return null;
12074
12173
  }
12075
- function Ug(e) {
12174
+ function Qg(e) {
12076
12175
  return e?.toLowerCase().replace(/[.)]/g, "").trim();
12077
12176
  }
12078
- function Wg(e, t) {
12079
- return !(e.type !== t.type || e.index !== void 0 && t.index !== void 0 && e.index !== t.index || e.num !== void 0 && t.num !== void 0 && Ug(e.num) !== Ug(t.num));
12177
+ function $g(e, t) {
12178
+ return !(e.type !== t.type || e.index !== void 0 && t.index !== void 0 && e.index !== t.index || e.num !== void 0 && t.num !== void 0 && Qg(e.num) !== Qg(t.num));
12080
12179
  }
12081
- function Gg(e) {
12180
+ function e_(e) {
12082
12181
  let t = null;
12083
12182
  for (let n of k(e)) t = n;
12084
12183
  return t;
12085
12184
  }
12086
- function Kg(e, t) {
12087
- return t && e.type === "parent-enfant" && Wg(e.parent, t) ? e.child : e;
12185
+ function t_(e, t) {
12186
+ return t && e.type === "parent-enfant" && $g(e.parent, t) ? e.child : e;
12088
12187
  }
12089
- function qg(e, t) {
12188
+ function n_(e, t) {
12090
12189
  let n = null;
12091
12190
  for (let r of k(e)) r.type === t && r.relative === void 0 && (r.index === void 0 && r.num === void 0 || (n = r));
12092
12191
  return n;
12093
12192
  }
12094
- function Jg(e, t) {
12193
+ function r_(e, t) {
12095
12194
  if (!t) return e;
12096
12195
  let n = structuredClone(e), r = (e) => {
12097
12196
  if (e.type !== "parent-enfant" && e.type !== "bounded-interval" && e.type !== "counted-interval" && e.type !== "enumeration" && e.type !== "exclusion" && e.type !== "reference_et_action") {
12098
12197
  if (e.relative === 0) {
12099
- let n = qg(t, e.type);
12198
+ let n = n_(t, e.type);
12100
12199
  n && (e.index = n.index, e.num = n.num, delete e.relative);
12101
12200
  }
12102
12201
  return;
@@ -12122,7 +12221,7 @@ function Jg(e, t) {
12122
12221
  };
12123
12222
  return r(n), n;
12124
12223
  }
12125
- function Yg(e) {
12224
+ function i_(e) {
12126
12225
  let t = (e) => {
12127
12226
  if (e.type !== "parent-enfant" && e.type !== "bounded-interval" && e.type !== "counted-interval" && e.type !== "enumeration" && e.type !== "exclusion" && e.type !== "reference_et_action") return e.relative !== void 0;
12128
12227
  switch (e.type) {
@@ -12136,13 +12235,13 @@ function Yg(e) {
12136
12235
  };
12137
12236
  return t(e);
12138
12237
  }
12139
- function Xg(e) {
12140
- let t = /* @__PURE__ */ new Map(), n = e.join("\n"), r = Dg(n), i = Array(e.length), a = e.length;
12141
- for (let t = e.length - 1; t >= 0; t--) i[t] = a, Cp(e[t]) && (a = t);
12238
+ function a_(e) {
12239
+ let t = /* @__PURE__ */ new Map(), n = e.join("\n"), r = Ig(n), i = Array(e.length), a = e.length;
12240
+ for (let t = e.length - 1; t >= 0; t--) i[t] = a, Dp(e[t]) && (a = t);
12142
12241
  for (let a = 1; a < e.length; a++) {
12143
- let o = e[a], s = Eg(e[a - 1], o);
12242
+ let o = e[a], s = Fg(e[a - 1], o);
12144
12243
  if (!s) continue;
12145
- let c = o.indexOf("«"), l = r[a].start + c, u = i[a], d = tm(n.slice(l, r[u]?.start ?? n.length), 0, { allowUnclosed: !0 });
12244
+ let c = o.indexOf("«"), l = r[a].start + c, u = i[a], d = om(n.slice(l, r[u]?.start ?? n.length), 0, { allowUnclosed: !0 });
12146
12245
  if (!d?.closed || d.content.length === 0) continue;
12147
12246
  let f = l + d.position.stop, p = a;
12148
12247
  for (; p + 1 < r.length && f > r[p].end;) p++;
@@ -12154,8 +12253,8 @@ function Xg(e) {
12154
12253
  }
12155
12254
  return t;
12156
12255
  }
12157
- function Zg(e) {
12158
- let t = [], n = [], r = Xg(e.map((e) => e.text)), i = -1;
12256
+ function o_(e) {
12257
+ let t = [], n = [], r = a_(e.map((e) => e.text)), i = -1;
12159
12258
  for (let [a, o] of e.entries()) {
12160
12259
  let s = n.at(-1);
12161
12260
  if (a <= i) {
@@ -12167,9 +12266,9 @@ function Zg(e) {
12167
12266
  s.body.push(o), s.quotedRedactionMarker = c.marker, i = c.endIndex;
12168
12267
  continue;
12169
12268
  }
12170
- if (!Og(o.text)) {
12269
+ if (!Lg(o.text)) {
12171
12270
  let e = n[n.length - 1];
12172
- if (e && Qg(o.text)) {
12271
+ if (e && s_(o.text)) {
12173
12272
  let r = (e.marker === "" ? e.level - 1 : e.level) + 1, i = {
12174
12273
  body: [],
12175
12274
  children: [],
@@ -12182,7 +12281,7 @@ function Zg(e) {
12182
12281
  } else e?.body.push(o);
12183
12282
  continue;
12184
12283
  }
12185
- let l = kg(o.text), u = l?.level ?? 0, d = {
12284
+ let l = Rg(o.text), u = l?.level ?? 0, d = {
12186
12285
  body: [],
12187
12286
  children: [],
12188
12287
  level: u,
@@ -12194,28 +12293,28 @@ function Zg(e) {
12194
12293
  }
12195
12294
  return t;
12196
12295
  }
12197
- function Qg(e) {
12198
- let t = Tg(e).trim();
12199
- return !t || sv(t) ? !1 : Ng(t) !== null;
12296
+ function s_(e) {
12297
+ let t = Pg(e).trim();
12298
+ return !t || gv(t) ? !1 : Hg(t) !== null;
12200
12299
  }
12201
- function $g(e, t, n) {
12300
+ function c_(e, t, n) {
12202
12301
  for (let r of e) {
12203
- let e = n_(r);
12302
+ let e = d_(r);
12204
12303
  if (e) {
12205
- let r = performance.now(), i = Fg(t, e, n);
12304
+ let r = performance.now(), i = Wg(t, e, n);
12206
12305
  if (Q(n, "listFindActionIndexMs", r), i !== null) return !0;
12207
12306
  }
12208
- if ($g(r.children, t, n)) return !0;
12307
+ if (c_(r.children, t, n)) return !0;
12209
12308
  }
12210
12309
  return !1;
12211
12310
  }
12212
- function e_(e, t) {
12311
+ function l_(e, t) {
12213
12312
  if (!e) return t;
12214
12313
  if (!t) return e;
12215
- let n = Kg(t, Gg(e));
12314
+ let n = t_(t, e_(e));
12216
12315
  return n.type === "article" || yt(n), pt(e, n);
12217
12316
  }
12218
- function t_(e, t) {
12317
+ function u_(e, t) {
12219
12318
  return {
12220
12319
  ...pt(e, t),
12221
12320
  position: {
@@ -12224,16 +12323,16 @@ function t_(e, t) {
12224
12323
  }
12225
12324
  };
12226
12325
  }
12227
- function n_(e) {
12228
- return [Tg(e.line.text), ...e.body.map((e) => e.text)].join("\n").trim();
12326
+ function d_(e) {
12327
+ return [Pg(e.line.text), ...e.body.map((e) => e.text)].join("\n").trim();
12229
12328
  }
12230
- function r_(e) {
12329
+ function f_(e) {
12231
12330
  return e.body[e.body.length - 1]?.end ?? e.line.end;
12232
12331
  }
12233
- function i_(e) {
12332
+ function p_(e) {
12234
12333
  return (e ?? "").replace(/°/gu, "").replace(/\s+/gu, " ").trim();
12235
12334
  }
12236
- function a_(e, t) {
12335
+ function m_(e, t) {
12237
12336
  let n = new S(e, t), r = fe(n);
12238
12337
  return typeof r == "string" && n.offset > t ? {
12239
12338
  date: r,
@@ -12241,14 +12340,14 @@ function a_(e, t) {
12241
12340
  stop: n.offset
12242
12341
  } : null;
12243
12342
  }
12244
- function o_(e) {
12245
- let t = Hh(e), n = [];
12343
+ function h_(e) {
12344
+ let t = qh(e), n = [];
12246
12345
  for (let r = 0; r < e.length; r += 1) {
12247
12346
  let i = e[r];
12248
12347
  if (i === void 0 || !/\d/u.test(i)) continue;
12249
- let a = a_(e, r);
12348
+ let a = m_(e, r);
12250
12349
  if (a) {
12251
- if (Uh(a, t)) {
12350
+ if (Jh(a, t)) {
12252
12351
  r = Math.max(r, a.stop - 1);
12253
12352
  continue;
12254
12353
  }
@@ -12257,25 +12356,25 @@ function o_(e) {
12257
12356
  }
12258
12357
  return n;
12259
12358
  }
12260
- function s_(e) {
12261
- return mh(e).replace(/\s+/gu, " ");
12359
+ function g_(e) {
12360
+ return yh(e).replace(/\s+/gu, " ");
12262
12361
  }
12263
- function c_(e) {
12264
- let t = s_(e), n = /\b(?:entr(?:e|ent|era|eront)\s+en\s+vigueur|s['’]?\s*appli(?:que|quent)|est\s+applicable|sont\s+applicables?|applicables?)\b/giu, r = null, i;
12362
+ function __(e) {
12363
+ let t = g_(e), n = /\b(?:entr(?:e|ent|era|eront)\s+en\s+vigueur|s['’]?\s*appli(?:que|quent)|est\s+applicable|sont\s+applicables?|applicables?)\b/giu, r = null, i;
12265
12364
  for (; (i = n.exec(t)) !== null;) r = i;
12266
12365
  return r;
12267
12366
  }
12268
- function l_(e, t) {
12269
- let n = s_(e.slice(0, t.start)), r = s_(e.slice(t.stop));
12270
- return !!(/\bau\s*$/u.test(n) && r.startsWith(",") || /\ba compter\s+(?:du|de la|de l['’]?|des)?\s*$/u.test(n) || /\babroge(?:e|es|s)?\s+a compter\s+(?:du|de la|de l['’]?|des)?\s*$/u.test(n) || c_(e.slice(0, t.start)));
12367
+ function v_(e, t) {
12368
+ let n = g_(e.slice(0, t.start)), r = g_(e.slice(t.stop));
12369
+ return !!(/\bau\s*$/u.test(n) && r.startsWith(",") || /\ba compter\s+(?:du|de la|de l['’]?|des)?\s*$/u.test(n) || /\babroge(?:e|es|s)?\s+a compter\s+(?:du|de la|de l['’]?|des)?\s*$/u.test(n) || __(e.slice(0, t.start)));
12271
12370
  }
12272
- function u_(e) {
12273
- return o_(e).find((t) => l_(e, t))?.date;
12371
+ function y_(e) {
12372
+ return h_(e).find((t) => v_(e, t))?.date;
12274
12373
  }
12275
- function d_(e) {
12276
- return e.map((e) => i_(e.num)).filter((e) => e.length > 0);
12374
+ function b_(e) {
12375
+ return e.map((e) => p_(e.num)).filter((e) => e.length > 0);
12277
12376
  }
12278
- function f_(e, t) {
12377
+ function x_(e, t) {
12279
12378
  let n = e.at(-1), r = t.at(-1);
12280
12379
  if (!n || !r) return [e, t];
12281
12380
  let i = e.slice(0, -1), a = t.slice(0, -1);
@@ -12286,51 +12385,51 @@ function f_(e, t) {
12286
12385
  for (let e = o; e <= s; e += 1) c.push([...i, String(e)]);
12287
12386
  return c;
12288
12387
  }
12289
- function p_(e) {
12388
+ function S_(e) {
12290
12389
  if (e.kind === "single") {
12291
- let t = d_(e.steps);
12390
+ let t = b_(e.steps);
12292
12391
  return t.length > 0 ? [t] : [];
12293
12392
  }
12294
- let t = d_(e.first), n = d_(e.last);
12295
- return t.length === 0 && n.length === 0 ? [] : f_(t, n);
12393
+ let t = b_(e.first), n = b_(e.last);
12394
+ return t.length === 0 && n.length === 0 ? [] : x_(t, n);
12296
12395
  }
12297
- function m_(e) {
12298
- let t = ih(new S(e)), n = [];
12299
- for (let e of t.map(Rg)) {
12396
+ function C_(e) {
12397
+ let t = lh(new S(e)), n = [];
12398
+ for (let e of t.map(qg)) {
12300
12399
  if (e.type === "article" && e.present) {
12301
12400
  n.push([]);
12302
12401
  continue;
12303
12402
  }
12304
- for (let t of Hp(e)) n.push(...p_(t));
12403
+ for (let t of qp(e)) n.push(...S_(t));
12305
12404
  }
12306
12405
  return n.filter((e, t, n) => n.findIndex((t) => t.join("\0") === e.join("\0")) === t);
12307
12406
  }
12308
- function h_(e) {
12407
+ function w_(e) {
12309
12408
  let t = [], n = e.split(/(?<=[.;])\s+/u).map((e) => e.trim()).filter(Boolean);
12310
- for (let e of n) for (let n of o_(e)) {
12311
- if (!l_(e, n)) continue;
12312
- let r = c_(e.slice(0, n.start));
12409
+ for (let e of n) for (let n of h_(e)) {
12410
+ if (!v_(e, n)) continue;
12411
+ let r = __(e.slice(0, n.start));
12313
12412
  if (!r) continue;
12314
- let i = m_(e.slice(0, r.index).trim());
12413
+ let i = C_(e.slice(0, r.index).trim());
12315
12414
  if (i.length === 0) continue;
12316
12415
  t.push({
12317
12416
  date: n.date,
12318
12417
  paths: i
12319
12418
  });
12320
- let a = g_(e.slice(n.stop), i);
12419
+ let a = T_(e.slice(n.stop), i);
12321
12420
  t.push(...a);
12322
12421
  }
12323
12422
  return t;
12324
12423
  }
12325
- function g_(e, t) {
12424
+ function T_(e, t) {
12326
12425
  let n = /(?:^|[^\p{L}\p{N}_])(?:a|à)\s+l['’]exception\s+(.+?)(?:\bqui\b|\bentr(?:e|ent|era|eront)\s+en\s+vigueur\b)/iu.exec(e);
12327
12426
  if (!n) return [];
12328
12427
  let r = n.index + n[0].length, i = n[1]?.trim();
12329
12428
  if (!i) return [];
12330
- let a = m_(i);
12429
+ let a = C_(i);
12331
12430
  if (a.length === 0) return [];
12332
12431
  let o = [];
12333
- for (let n of o_(e.slice(r))) {
12432
+ for (let n of h_(e.slice(r))) {
12334
12433
  let e = n.date;
12335
12434
  o.push({
12336
12435
  date: e,
@@ -12341,44 +12440,44 @@ function g_(e, t) {
12341
12440
  }
12342
12441
  return o;
12343
12442
  }
12344
- function __(e, t, n) {
12443
+ function E_(e, t, n) {
12345
12444
  return [
12346
12445
  ...e,
12347
- i_(t.marker),
12348
- ...jg(n).map(i_)
12446
+ p_(t.marker),
12447
+ ...Bg(n).map(p_)
12349
12448
  ].filter((e) => e.length > 0);
12350
12449
  }
12351
- function v_(e) {
12450
+ function D_(e) {
12352
12451
  let t = [];
12353
- for (let n of e) t.push(...h_(n_(n))), t.push(...v_(n.children));
12452
+ for (let n of e) t.push(...w_(d_(n))), t.push(...D_(n.children));
12354
12453
  return t;
12355
12454
  }
12356
- function y_(e, t) {
12455
+ function O_(e, t) {
12357
12456
  return t.length > e.length ? !1 : t.every((t, n) => e[n] === t);
12358
12457
  }
12359
- function b_(e, t) {
12458
+ function k_(e, t) {
12360
12459
  if (t.length > e.length) return !1;
12361
12460
  let n = e.length - t.length;
12362
12461
  return t.every((t, r) => e[n + r] === t);
12363
12462
  }
12364
- function x_(e, t, n) {
12365
- return n ? n.some((n) => x_(e, n) ? x_(e, y_(e, n) ? [...n, ...t] : t) : !1) : t.length === 0 ? !0 : y_(e, t) || b_(e, t);
12463
+ function A_(e, t, n) {
12464
+ return n ? n.some((n) => A_(e, n) ? A_(e, O_(e, n) ? [...n, ...t] : t) : !1) : t.length === 0 ? !0 : O_(e, t) || k_(e, t);
12366
12465
  }
12367
- function S_(e, t, n) {
12466
+ function j_(e, t, n) {
12368
12467
  if (e.length === 0 || n.length === 0) return;
12369
12468
  let r = new Map(t.map((e) => [e.directive, e.sourcePath]));
12370
12469
  for (let t of e) {
12371
12470
  if (t.applicabilityDate) continue;
12372
12471
  let e = r.get(t) ?? [], i, a = -1;
12373
12472
  for (let t of n) for (let n of t.paths) {
12374
- if (!x_(e, n, t.parentPaths)) continue;
12473
+ if (!A_(e, n, t.parentPaths)) continue;
12375
12474
  let r = n.length + Math.max(0, ...t.parentPaths?.map((e) => e.length) ?? [0]);
12376
12475
  r > a && (i = t.date, a = r);
12377
12476
  }
12378
12477
  i && (t.applicabilityDate = i);
12379
12478
  }
12380
12479
  }
12381
- function C_(e, t) {
12480
+ function M_(e, t) {
12382
12481
  if (!e) return t;
12383
12482
  if (!t) return e;
12384
12483
  let n = t.rowIndex ?? e.rowIndex, r = t.columnIndex ?? e.columnIndex;
@@ -12388,44 +12487,44 @@ function C_(e, t) {
12388
12487
  ...r ? { columnIndex: r } : {}
12389
12488
  };
12390
12489
  }
12391
- function w_(e) {
12490
+ function N_(e) {
12392
12491
  return e !== void 0 && (e.rowIndex !== void 0 || e.columnIndex !== void 0);
12393
12492
  }
12394
- function T_(e, t, n, r) {
12493
+ function P_(e, t, n, r) {
12395
12494
  if (t.kind === "compound") return null;
12396
- let i = [...lg.extract(new S(e), { overlapWindow: 100 })];
12495
+ let i = [...mg.extract(new S(e), { overlapWindow: 100 })];
12397
12496
  if (i.length < 2) return null;
12398
- let a = ih(new S(e)).flatMap((e) => [...k(e)]).filter((e) => e.type === "article");
12497
+ let a = lh(new S(e)).flatMap((e) => [...k(e)]).filter((e) => e.type === "article");
12399
12498
  if (a.length !== 1) return null;
12400
- let o = a[0], s = e_(n, o), c = [t];
12499
+ let o = a[0], s = l_(n, o), c = [t];
12401
12500
  for (let t = 1; t < i.length; t += 1) {
12402
- let n = i[t], a = i[t + 1], o = nv(e.slice(n.position.start, a?.position.start ?? e.length), { allowListExtraction: !1 });
12501
+ let n = i[t], a = i[t + 1], o = dv(e.slice(n.position.start, a?.position.start ?? e.length), { allowListExtraction: !1 });
12403
12502
  if (o.length !== 1 || o[0].kind === "compound") return null;
12404
12503
  let l = o[0];
12405
12504
  if ([...k(l.reference)].some((e) => e.type === "article")) return null;
12406
12505
  c.push({
12407
12506
  ...l,
12408
- reference: e_(s, l.reference),
12507
+ reference: l_(s, l.reference),
12409
12508
  sourcePosition: r,
12410
12509
  sourceText: e
12411
12510
  });
12412
12511
  }
12413
12512
  return c;
12414
12513
  }
12415
- function E_(e, t, n, r, i = [], a = [], o, s) {
12514
+ function F_(e, t, n, r, i = [], a = [], o, s) {
12416
12515
  let c = [], l = t;
12417
12516
  for (let u of e) {
12418
12517
  s !== void 0 && (s.listItemCount += 1);
12419
- let e = Tg(u.line.text), d = __(i, u, e), f = n_(u);
12518
+ let e = Pg(u.line.text), d = E_(i, u, e), f = d_(u);
12420
12519
  if (!f) continue;
12421
- let p = C_(r, F_(f, r !== void 0)), m, h, g = () => {
12520
+ let p = M_(r, W_(f, r !== void 0)), m, h, g = () => {
12422
12521
  if (m !== void 0) return m;
12423
12522
  let t = performance.now();
12424
- return m = Hg(e, o, s), Q(s, "listPickLineReferenceMs", t), m;
12425
- }, _ = () => (h === void 0 && (h = e_(t, g())), h), v = performance.now(), y = Fg(o, f, s);
12523
+ return m = Zg(e, o, s), Q(s, "listPickLineReferenceMs", t), m;
12524
+ }, _ = () => (h === void 0 && (h = l_(t, g())), h), v = performance.now(), y = Wg(o, f, s);
12426
12525
  if (Q(s, "listFindActionIndexMs", v), y === null) {
12427
12526
  if (h = _(), u.children.length > 0) {
12428
- let e = h ?? t, r = E_(u.children, e, n, p, d, a, o, s);
12527
+ let e = h ?? t, r = F_(u.children, e, n, p, d, a, o, s);
12429
12528
  r.length > 0 && (c.push(...r), l = r[r.length - 1]?.reference ?? l);
12430
12529
  continue;
12431
12530
  }
@@ -12433,23 +12532,23 @@ function E_(e, t, n, r, i = [], a = [], o, s) {
12433
12532
  continue;
12434
12533
  }
12435
12534
  s !== void 0 && (s.listActionItemCount += 1);
12436
- let b = performance.now(), x = Bg(f, y ?? f.length, o, s), ee = x === null ? zg(f, o, s, y ?? f.length) : null, te = x ?? ee ?? g();
12535
+ let b = performance.now(), x = Yg(f, y ?? f.length, o, s), ee = x === null ? Jg(f, o, s, y ?? f.length) : null, te = x ?? ee ?? g();
12437
12536
  Q(s, "listPickLocalReferenceMs", b);
12438
- let S = e_(t, te) ?? ee ?? h;
12537
+ let S = l_(t, te) ?? ee ?? h;
12439
12538
  if (!S) {
12440
12539
  if (u.children.length > 0) {
12441
- let e = E_(u.children, h ?? t, n, p, d, a, o, s);
12540
+ let e = F_(u.children, h ?? t, n, p, d, a, o, s);
12442
12541
  c.push(...e);
12443
12542
  }
12444
12543
  continue;
12445
12544
  }
12446
- S = Jg(S, Yg(S) ? l ?? t : t);
12447
- let ne = performance.now(), C = ev({
12545
+ S = r_(S, i_(S) ? l ?? t : t);
12546
+ let ne = performance.now(), C = lv({
12448
12547
  action: { action: "modifier" },
12449
12548
  reference: S,
12450
12549
  sourcePosition: {
12451
12550
  start: u.line.start,
12452
- stop: r_(u)
12551
+ stop: f_(u)
12453
12552
  },
12454
12553
  sourceText: f,
12455
12554
  fullText: n,
@@ -12470,14 +12569,14 @@ function E_(e, t, n, r, i = [], a = [], o, s) {
12470
12569
  if (Q(s, "listBuildActionDirectiveMs", ne), !C) {
12471
12570
  if (l = S, u.children.length > 0) {
12472
12571
  h = _();
12473
- let e = E_(u.children, h ?? S, n, p, d, a, o, s);
12572
+ let e = F_(u.children, h ?? S, n, p, d, a, o, s);
12474
12573
  c.push(...e), l = e[e.length - 1]?.reference ?? l;
12475
12574
  }
12476
12575
  continue;
12477
12576
  }
12478
- let ie = Array.isArray(C) ? C : T_(f, C, t, {
12577
+ let ie = Array.isArray(C) ? C : P_(f, C, t, {
12479
12578
  start: u.line.start,
12480
- stop: r_(u)
12579
+ stop: f_(u)
12481
12580
  }) ?? [C];
12482
12581
  c.push(...ie);
12483
12582
  for (let e of ie) a.push({
@@ -12486,28 +12585,28 @@ function E_(e, t, n, r, i = [], a = [], o, s) {
12486
12585
  });
12487
12586
  if (l = S, u.children.length > 0) {
12488
12587
  h = _();
12489
- let e = E_(u.children, h ?? S, n, p, d, a, o, s);
12588
+ let e = F_(u.children, h ?? S, n, p, d, a, o, s);
12490
12589
  e.length > 0 && (c.push(...e), l = e[e.length - 1]?.reference ?? l);
12491
12590
  }
12492
12591
  }
12493
- return $_(c);
12592
+ return cv(c);
12494
12593
  }
12495
- function D_(e, t) {
12496
- let n = Dg(e), r = n.findIndex((e) => Og(e.text));
12594
+ function I_(e, t) {
12595
+ let n = Ig(e), r = n.findIndex((e) => Lg(e.text));
12497
12596
  if (r === -1) return null;
12498
- let i = Pg(), a = performance.now(), o = Zg(n.slice(r));
12499
- if (Q(t, "buildListItemTreeMs", a), !$g(o, i, t)) return null;
12597
+ let i = Ug(), a = performance.now(), o = o_(n.slice(r));
12598
+ if (Q(t, "buildListItemTreeMs", a), !c_(o, i, t)) return null;
12500
12599
  let s = performance.now(), c = null;
12501
- for (let e = r - 1; e >= 0 && (c = Hg(n[e]?.text ?? "", i, t), c === null); --e);
12600
+ for (let e = r - 1; e >= 0 && (c = Zg(n[e]?.text ?? "", i, t), c === null); --e);
12502
12601
  Q(t, "findBaseReferenceMs", s);
12503
- let l = [], u = performance.now(), d = E_(o, c, e, void 0, [], l, i, t);
12602
+ let l = [], u = performance.now(), d = F_(o, c, e, void 0, [], l, i, t);
12504
12603
  Q(t, "processListItemNodesMs", u);
12505
- let f = performance.now(), p = v_(o);
12604
+ let f = performance.now(), p = D_(o);
12506
12605
  Q(t, "collectApplicabilityScopesMs", f);
12507
12606
  let m = performance.now();
12508
- return S_(d, l, p), Q(t, "applyApplicabilityDatesMs", m), d.length > 0 ? d : null;
12607
+ return j_(d, l, p), Q(t, "applyApplicabilityDatesMs", m), d.length > 0 ? d : null;
12509
12608
  }
12510
- function O_(e, t) {
12609
+ function L_(e, t) {
12511
12610
  let n = e.indexOf("«");
12512
12611
  if (n === -1) return;
12513
12612
  let r = e.indexOf("»", n + 1);
@@ -12522,40 +12621,40 @@ function O_(e, t) {
12522
12621
  }
12523
12622
  };
12524
12623
  }
12525
- function k_(e) {
12526
- let t = mh(e);
12624
+ function R_(e) {
12625
+ let t = yh(e);
12527
12626
  return /\btableau\b/.test(t) && /\b(?:tableau|celui)\s+(?:suivant|ainsi\s+redigee?|ainsi\s+rediges|ainsi\s+redigees)\b/.test(t);
12528
12627
  }
12529
- function A_(e) {
12530
- for (let t of Dg(e)) {
12531
- if (!k_(t.text)) continue;
12628
+ function z_(e) {
12629
+ for (let t of Ig(e)) {
12630
+ if (!R_(t.text)) continue;
12532
12631
  let e = t.text.indexOf(":");
12533
12632
  return e === -1 ? t.end : t.start + e + 1;
12534
12633
  }
12535
12634
  return null;
12536
12635
  }
12537
- function j_(e, t) {
12538
- let n = A_(e);
12539
- return n === null ? O_(e, t) : O_(e.slice(n), t + n);
12636
+ function B_(e, t) {
12637
+ let n = z_(e);
12638
+ return n === null ? L_(e, t) : L_(e.slice(n), t + n);
12540
12639
  }
12541
- function M_(e, t) {
12542
- return mg(e, t);
12640
+ function V_(e, t) {
12641
+ return yg(e, t);
12543
12642
  }
12544
- function N_(e, t) {
12545
- let n = jm(e, t);
12643
+ function H_(e, t) {
12644
+ let n = Im(e, t);
12546
12645
  return n && n > 1 ? n : void 0;
12547
12646
  }
12548
- function P_(e, t) {
12647
+ function U_(e, t) {
12549
12648
  if (!Array.isArray(e) || e.length < 2 || t.length < e.length) return e;
12550
12649
  let n = e[0];
12551
12650
  return e.some((e) => JSON.stringify(e) !== JSON.stringify(n)) ? e : n;
12552
12651
  }
12553
- function F_(e, t = !1) {
12554
- let n = Vh(e, Bh(e)), r = mh(n), i = /\btableau\b/.test(r);
12652
+ function W_(e, t = !1) {
12653
+ let n = Kh(e, Gh(e)), r = yh(n), i = /\btableau\b/.test(r);
12555
12654
  if (!i && !t) return;
12556
12655
  let a = (e) => {
12557
12656
  if (!e) return;
12558
- let t = e.replace(/^(?:a|à)\s+la\s+/iu, "").trim(), n = mh(t);
12657
+ let t = e.replace(/^(?:a|à)\s+la\s+/iu, "").trim(), n = yh(t);
12559
12658
  if (/^derni(?:er|ere)s?\b/u.test(n)) return -1;
12560
12659
  let r = me(t);
12561
12660
  return r && r > 0 ? r : void 0;
@@ -12563,43 +12662,49 @@ function F_(e, t = !1) {
12563
12662
  type: "table",
12564
12663
  ...e === void 0 ? {} : { rowIndex: e },
12565
12664
  ...t === void 0 ? {} : { columnIndex: t }
12566
- } : void 0, s = /(?:^|[^\p{L}\p{N}_])(?:a|à)\s+la\s+(.+?)\s+ligne\s+de\s+la\s+(.+?)\s+colonne\b/iu.exec(n);
12567
- if (s) {
12568
- let e = o(a(s[1]), a(s[2]));
12665
+ } : void 0, s = Cg(n)[0];
12666
+ if (s) return {
12667
+ type: "table",
12668
+ rowIndex: s.rowIndex,
12669
+ rowEndIndex: s.rowEndIndex
12670
+ };
12671
+ let c = /(?:^|[^\p{L}\p{N}_])(?:a|à)\s+la\s+(.+?)\s+ligne\s+de\s+la\s+(.+?)\s+colonne\b/iu.exec(n);
12672
+ if (c) {
12673
+ let e = o(a(c[1]), a(c[2]));
12569
12674
  if (e) return e;
12570
12675
  }
12571
- let c = /(?:^|[^\p{L}\p{N}_])(?:a|à)\s+la\s+(.+?)\s+colonne\s+de\s+la\s+(.+?)\s+ligne\b/iu.exec(n);
12572
- if (c) {
12573
- let e = a(c[1]), t = o(a(c[2]), e);
12676
+ let l = /(?:^|[^\p{L}\p{N}_])(?:a|à)\s+la\s+(.+?)\s+colonne\s+de\s+la\s+(.+?)\s+ligne\b/iu.exec(n);
12677
+ if (l) {
12678
+ let e = a(l[1]), t = o(a(l[2]), e);
12574
12679
  if (t) return t;
12575
12680
  }
12576
- let l = /\bla\s+(.+?)\s+ligne\b/iu.exec(n), u = /\bla\s+(.+?)\s+colonne\b/iu.exec(n);
12577
- return o(a(l?.[1]), a(u?.[1])) || (i ? { type: "table" } : void 0);
12681
+ let u = /\bla\s+(.+?)\s+ligne\b/iu.exec(n), d = /\bla\s+(.+?)\s+colonne\b/iu.exec(n);
12682
+ return o(a(u?.[1]), a(d?.[1])) || (i ? { type: "table" } : void 0);
12578
12683
  }
12579
- function I_(e) {
12684
+ function G_(e) {
12580
12685
  return e.replace(/(?:[,;:]\s*)?(?:(?:le|la|les|l['’])\s+)?(?:année|date|dispositions?|mention|montant|mot|mots|nombre|nombres|pourcentage|référence|références|signe|taux|texte|phrase|phrases|tableau)(?:\s+[^,;:]*)?\s*:?\s*$/iu, "").trimEnd();
12581
12686
  }
12582
- function L_(e) {
12687
+ function K_(e) {
12583
12688
  return e.replace(/(?:[,;:]\s*)?(?:(?:le|la|les|l['’])\s+)?(?:année|date|dispositions?|mention|montant|mot|mots|nombre|nombres|pourcentage|référence|références|signe|taux|texte|tableau)(?:\s+[^,;:]*)?\s*:?\s*$/iu, "").trimEnd();
12584
12689
  }
12585
- var R_ = [
12586
- z_("(?:la\\s+date\\s+d(?:u|e|[’']))"),
12587
- z_("(?:le\\s+montant\\s+d(?:e|[’']))"),
12588
- z_("(?:la\\s+référence\\s+à)")
12690
+ var q_ = [
12691
+ J_("(?:la\\s+date\\s+d(?:u|e|[’']))"),
12692
+ J_("(?:le\\s+montant\\s+d(?:e|[’']))"),
12693
+ J_("(?:la\\s+référence\\s+à)")
12589
12694
  ];
12590
- function z_(e) {
12695
+ function J_(e) {
12591
12696
  return new RegExp(String.raw`(?:^|[,;:]\s*)${e}\s+(?<target>.+?)\s+(?:est|sont)\s+remplac[eé]e?s?\s+par\s+${e}\s+(?<replacement>.+?)(?=\s*(?:[.;]|$))`, "iu");
12592
12697
  }
12593
- function B_(e) {
12698
+ function Y_(e) {
12594
12699
  return e.replace(/\s+/gu, " ").replace(/\s+([,;])/gu, "$1").trim();
12595
12700
  }
12596
- function V_(e) {
12701
+ function X_(e) {
12597
12702
  if (e.includes("«") || e.includes("»")) return null;
12598
- for (let t of R_) {
12703
+ for (let t of q_) {
12599
12704
  let n = t.exec(e), r = n?.groups?.target, i = n?.groups?.replacement;
12600
12705
  if (!(!r || !i)) return {
12601
- targetText: B_(r),
12602
- replacementText: B_(i),
12706
+ targetText: Y_(r),
12707
+ replacementText: Y_(i),
12603
12708
  operandRange: {
12604
12709
  start: n.index,
12605
12710
  end: n.index + n[0].length
@@ -12608,25 +12713,25 @@ function V_(e) {
12608
12713
  }
12609
12714
  return null;
12610
12715
  }
12611
- function H_(e, t) {
12612
- return hh(mh(e.slice(0, t.start)), mh(e));
12716
+ function Z_(e, t) {
12717
+ return bh(yh(e.slice(0, t.start)), yh(e));
12613
12718
  }
12614
- function U_(e) {
12719
+ function Q_(e) {
12615
12720
  return /^[\s.;]*$/u.test(e);
12616
12721
  }
12617
- function W_(e, t) {
12722
+ function $_(e, t) {
12618
12723
  let n = [];
12619
12724
  for (let r = 0; r < t.length; r++) {
12620
12725
  let i = t[r];
12621
- if (i.closed === !1 && !H_(e, i)) continue;
12622
- if (!H_(e, i)) {
12726
+ if (i.closed === !1 && !Z_(e, i)) continue;
12727
+ if (!Z_(e, i)) {
12623
12728
  n.push(i);
12624
12729
  continue;
12625
12730
  }
12626
12731
  let a = [i];
12627
12732
  for (; r + 1 < t.length;) {
12628
12733
  let n = t[r + 1];
12629
- if (!U_(e.slice(a.at(-1).end, n.start))) break;
12734
+ if (!Q_(e.slice(a.at(-1).end, n.start))) break;
12630
12735
  a.push(n), r++;
12631
12736
  }
12632
12737
  n.push({
@@ -12638,38 +12743,38 @@ function W_(e, t) {
12638
12743
  }
12639
12744
  return n;
12640
12745
  }
12641
- function G_(e) {
12642
- let t = V_(e);
12746
+ function ev(e) {
12747
+ let t = X_(e);
12643
12748
  return t ? [t.operandRange] : [];
12644
12749
  }
12645
- function K_(e, t) {
12646
- return Uh(e.position, t) ? !0 : Array.from(k(Rg(e))).some((e) => Uh(e.position, t));
12750
+ function tv(e, t) {
12751
+ return Jh(e.position, t) ? !0 : Array.from(k(qg(e))).some((e) => Jh(e.position, t));
12647
12752
  }
12648
- function q_(e, t, n, r, i, a) {
12649
- let o = mh(e), s = mh(Vh(e, i)), c = hh(s, o), l = gh(s), u = _h(s), d = dh(s), f = n.action === "rétablir" || vh(s), p = yh(s) || f, m = bh(s), h = xh(s), g = k_(e), _ = u ? "insert_before" : "insert_after", v = l ? fg(s) : null, y = m ? v : null, b = h ? v : null, x = () => {
12753
+ function nv(e, t, n, r, i, a) {
12754
+ let o = yh(e), s = yh(Kh(e, i)), c = bh(s, o), l = xh(s), u = Sh(s), d = gh(s), f = n.action === "rétablir" || Ch(s), p = wh(s) || f, m = Th(s), h = Eh(s), g = R_(e), _ = u ? "insert_before" : "insert_after", v = l ? _g(s) : null, y = m ? v : null, b = h ? v : null, x = () => {
12650
12755
  let n = i[0]?.start;
12651
- return (n === void 0 ? void 0 : N_(t, n)) ?? Am(e) ?? void 0;
12756
+ return (n === void 0 ? void 0 : H_(t, n)) ?? Fm(e) ?? void 0;
12652
12757
  }, ee = () => {
12653
12758
  let e = i[0]?.start;
12654
- return (e === void 0 ? void 0 : M_(t, e)) ?? void 0;
12759
+ return (e === void 0 ? void 0 : V_(t, e)) ?? void 0;
12655
12760
  }, te = () => {
12656
12761
  let e = i[0]?.start;
12657
- return e === void 0 ? !1 : hh(mh(t.slice(0, e)), o);
12762
+ return e === void 0 ? !1 : bh(yh(t.slice(0, e)), o);
12658
12763
  }, S = (e, n) => {
12659
12764
  let r = i[e], a = i[n];
12660
12765
  if (!r || !a) return null;
12661
- let o = mh(t.slice(r.end, a.start)), s = yh(o);
12662
- return s === bh(o) ? null : s ? "insert" : "replace";
12766
+ let o = yh(t.slice(r.end, a.start)), s = wh(o);
12767
+ return s === Th(o) ? null : s ? "insert" : "replace";
12663
12768
  }, ne = (e) => {
12664
12769
  let n = i[e];
12665
12770
  if (!n) return;
12666
12771
  let r = i[e - 1]?.end ?? 0;
12667
- return M_(t.slice(r), n.start - r) ?? void 0;
12772
+ return V_(t.slice(r), n.start - r) ?? void 0;
12668
12773
  }, C = (e) => {
12669
12774
  let t = ne(e);
12670
12775
  return t === void 0 ? {} : { occurrenceIndex: t };
12671
12776
  }, re = ({ kind: e, targetText: t, targetQuoteIndex: n = 0, insertText: r, expectsFollowingTable: i }) => {
12672
- let a = Sg({
12777
+ let a = jg({
12673
12778
  hasRedactionIntro: c,
12674
12779
  insertText: r,
12675
12780
  normalized: o
@@ -12738,7 +12843,7 @@ function q_(e, t, n, r, i, a) {
12738
12843
  }
12739
12844
  if (p && m && a.length === 3 && !l && !u) {
12740
12845
  let e = i[0]?.start;
12741
- if (yh(e === void 0 ? "" : mh(t.slice(0, e))) && S(1, 2) === "replace") return [re({
12846
+ if (wh(e === void 0 ? "" : yh(t.slice(0, e))) && S(1, 2) === "replace") return [re({
12742
12847
  kind: d === "start" ? "insert_before" : "insert_after",
12743
12848
  targetText: "",
12744
12849
  insertText: a[0],
@@ -12816,7 +12921,7 @@ function q_(e, t, n, r, i, a) {
12816
12921
  replacement: { type: "following_table" }
12817
12922
  };
12818
12923
  if (m && !p && !h && a.length === 0) {
12819
- let t = V_(e);
12924
+ let t = X_(e);
12820
12925
  if (t) return {
12821
12926
  kind: "replace",
12822
12927
  targetText: t.targetText,
@@ -12846,7 +12951,7 @@ function q_(e, t, n, r, i, a) {
12846
12951
  };
12847
12952
  }
12848
12953
  if (!p && a.length === 1 && c && te()) {
12849
- let e = Cg({
12954
+ let e = Mg({
12850
12955
  hasRedactionIntro: c,
12851
12956
  normalized: o,
12852
12957
  replacementText: a[0]
@@ -12879,8 +12984,8 @@ function q_(e, t, n, r, i, a) {
12879
12984
  expectsFollowingTable: g
12880
12985
  });
12881
12986
  if (u) {
12882
- let e = mh(t.slice(i[0]?.end, i[1]?.start));
12883
- return S(0, 1) === "insert" && _h(e) ? re({
12987
+ let e = yh(t.slice(i[0]?.end, i[1]?.start));
12988
+ return S(0, 1) === "insert" && Sh(e) ? re({
12884
12989
  kind: "insert_before",
12885
12990
  targetText: a[1],
12886
12991
  targetQuoteIndex: 1,
@@ -12911,11 +13016,11 @@ function q_(e, t, n, r, i, a) {
12911
13016
  expectsFollowingTable: g
12912
13017
  }) : null;
12913
13018
  }
12914
- function J_(e) {
12915
- let t = mh(e);
13019
+ function rv(e) {
13020
+ let t = yh(e);
12916
13021
  return /\bapres\b/.test(t) && /\bla\s+fin\s+(?:(?:de\s+l['’]?)|d['’]?|de|du|des)?\s*$/u.test(t);
12917
13022
  }
12918
- function Y_(e) {
13023
+ function iv(e) {
12919
13024
  switch (e.kind) {
12920
13025
  case "insert_after":
12921
13026
  case "insert_before": return {
@@ -12960,7 +13065,7 @@ function Y_(e) {
12960
13065
  case "delete_article": return { kind: "delete_article" };
12961
13066
  }
12962
13067
  }
12963
- function X_(e) {
13068
+ function av(e) {
12964
13069
  let t = (t) => {
12965
13070
  let n = e[t];
12966
13071
  return typeof n == "string" ? n : "";
@@ -12977,7 +13082,7 @@ function X_(e) {
12977
13082
  o
12978
13083
  ].join("|");
12979
13084
  }
12980
- function Z_(e, t, n) {
13085
+ function ov(e, t, n) {
12981
13086
  return t.targetType === n.targetType && JSON.stringify(t.reference) === JSON.stringify(n.reference) && JSON.stringify(t.portionSelectors) === JSON.stringify(n.portionSelectors) ? e : {
12982
13087
  ...e,
12983
13088
  targetType: t.targetType,
@@ -12985,10 +13090,10 @@ function Z_(e, t, n) {
12985
13090
  portionSelectors: t.portionSelectors
12986
13091
  };
12987
13092
  }
12988
- function Q_(e, t) {
12989
- return (e.kind === "compound" ? e.operations : [Y_(e)]).map((n) => Z_(n, e, t));
13093
+ function sv(e, t) {
13094
+ return (e.kind === "compound" ? e.operations : [iv(e)]).map((n) => ov(n, e, t));
12990
13095
  }
12991
- function $_(e) {
13096
+ function cv(e) {
12992
13097
  let t = [];
12993
13098
  for (let n = 0; n < e.length; n += 1) {
12994
13099
  let r = e[n];
@@ -13003,14 +13108,14 @@ function $_(e) {
13003
13108
  continue;
13004
13109
  }
13005
13110
  let o = i[0], s = [];
13006
- for (let [e, t] of i.entries()) for (let [n, r] of Q_(t, o).entries()) s.push({
13111
+ for (let [e, t] of i.entries()) for (let [n, r] of sv(t, o).entries()) s.push({
13007
13112
  directiveIndex: e,
13008
13113
  operationIndex: n,
13009
13114
  operation: r
13010
13115
  });
13011
13116
  let c = /* @__PURE__ */ new Set(), l = [];
13012
13117
  for (let e = s.length - 1; e >= 0; --e) {
13013
- let t = s[e], n = X_(t.operation);
13118
+ let t = s[e], n = av(t.operation);
13014
13119
  c.has(n) || (c.add(n), l.push(t));
13015
13120
  }
13016
13121
  l.sort((e, t) => e.directiveIndex - t.directiveIndex || e.operationIndex - t.operationIndex), t.push({
@@ -13029,17 +13134,17 @@ function $_(e) {
13029
13134
  }
13030
13135
  return t;
13031
13136
  }
13032
- function ev({ action: e, reference: t, sourcePosition: n, sourceText: r, fullText: i, tableTarget: a }) {
13033
- let o = e.target ?? yt(t), s = Hp(t), c = i && n.start < i.length ? i.slice(n.start) : r, l = i && n.start < i.length ? n.start : 0, u = i === r && n.start < r.length && !J_(r.slice(0, n.start)) ? r.slice(n.start) : r, d = W_(u, Bh(u, {
13137
+ function lv({ action: e, reference: t, sourcePosition: n, sourceText: r, fullText: i, tableTarget: a }) {
13138
+ let o = e.target ?? yt(t), s = qp(t), c = i && n.start < i.length ? i.slice(n.start) : r, l = i && n.start < i.length ? n.start : 0, u = i === r && n.start < r.length && !rv(r.slice(0, n.start)) ? r.slice(n.start) : r, d = $_(u, Gh(u, {
13034
13139
  allowClosingQuoteAsOpening: !0,
13035
13140
  allowUnclosed: !0
13036
- })), f = q_(r, u, e, o, d, d.map((e) => e.text));
13141
+ })), f = nv(r, u, e, o, d, d.map((e) => e.text));
13037
13142
  if (!f) return null;
13038
- let p = P_(f, s), m = u_(r), h = {
13143
+ let p = U_(f, s), m = y_(r), h = {
13039
13144
  ...m ? { applicabilityDate: m } : {},
13040
13145
  sourcePosition: n,
13041
13146
  sourceText: r
13042
- }, g = j_(c, l), _ = (e) => {
13147
+ }, g = B_(c, l), _ = (e) => {
13043
13148
  switch (e.kind) {
13044
13149
  case "insert_after":
13045
13150
  case "insert_before": return {
@@ -13103,7 +13208,7 @@ function ev({ action: e, reference: t, sourcePosition: n, sourceText: r, fullTex
13103
13208
  ...e.occurrenceIndex === void 0 ? {} : { occurrenceIndex: e.occurrenceIndex },
13104
13209
  ...e.insertLayout ? { insertLayout: e.insertLayout } : {},
13105
13210
  ...e.expectsFollowingTable && g ? { citation: g } : {},
13106
- ...w_(a) ? { tableTarget: a } : {},
13211
+ ...N_(a) ? { tableTarget: a } : {},
13107
13212
  ...h
13108
13213
  };
13109
13214
  case "replace": return {
@@ -13120,7 +13225,7 @@ function ev({ action: e, reference: t, sourcePosition: n, sourceText: r, fullTex
13120
13225
  ...e.occurrenceIndex === void 0 ? {} : { occurrenceIndex: e.occurrenceIndex },
13121
13226
  ...e.targetOccurrenceCount === void 0 ? {} : { targetOccurrenceCount: e.targetOccurrenceCount },
13122
13227
  ...e.targetScope ? { targetScope: e.targetScope } : {},
13123
- ...w_(a) ? { tableTarget: a } : {},
13228
+ ...N_(a) ? { tableTarget: a } : {},
13124
13229
  ...h
13125
13230
  };
13126
13231
  case "replace_portion": return e.replacement.type === "following_table" && !g ? null : {
@@ -13132,11 +13237,11 @@ function ev({ action: e, reference: t, sourcePosition: n, sourceText: r, fullTex
13132
13237
  replacement: e.replacement,
13133
13238
  ...e.replacementLayout ? { replacementLayout: e.replacementLayout } : {},
13134
13239
  ...e.replacement.type === "following_table" && g ? { citation: g } : {},
13135
- ...w_(a) ? { tableTarget: a } : {},
13240
+ ...N_(a) ? { tableTarget: a } : {},
13136
13241
  ...h
13137
13242
  };
13138
13243
  case "delete": {
13139
- let n = d.map((e) => M_(u, e.start)), r = /* @__PURE__ */ new Map();
13244
+ let n = d.map((e) => V_(u, e.start)), r = /* @__PURE__ */ new Map();
13140
13245
  for (let [e, t] of d.entries()) r.has(t.text) || r.set(t.text, n[e] ?? null);
13141
13246
  let i = [e.targetText, ...e.extraTargetTexts ?? []].filter((e) => e && e.trim().length > 0).filter((e, t, n) => n.indexOf(e) === t);
13142
13247
  return i.length > 1 ? v(i.map((t) => ({
@@ -13145,7 +13250,7 @@ function ev({ action: e, reference: t, sourcePosition: n, sourceText: r, fullTex
13145
13250
  ...e.targetScope ? { targetScope: e.targetScope } : {},
13146
13251
  occurrenceIndex: r.get(t) ?? void 0,
13147
13252
  ...t === e.targetText && e.targetOccurrenceCount !== void 0 ? { targetOccurrenceCount: e.targetOccurrenceCount } : {},
13148
- ...w_(a) ? { tableTarget: a } : {}
13253
+ ...N_(a) ? { tableTarget: a } : {}
13149
13254
  }))) : {
13150
13255
  kind: "delete",
13151
13256
  targetType: o,
@@ -13155,7 +13260,7 @@ function ev({ action: e, reference: t, sourcePosition: n, sourceText: r, fullTex
13155
13260
  ...e.targetScope ? { targetScope: e.targetScope } : {},
13156
13261
  occurrenceIndex: r.get(e.targetText) ?? void 0,
13157
13262
  ...e.targetOccurrenceCount === void 0 ? {} : { targetOccurrenceCount: e.targetOccurrenceCount },
13158
- ...w_(a) ? { tableTarget: a } : {},
13263
+ ...N_(a) ? { tableTarget: a } : {},
13159
13264
  ...h
13160
13265
  };
13161
13266
  }
@@ -13164,7 +13269,7 @@ function ev({ action: e, reference: t, sourcePosition: n, sourceText: r, fullTex
13164
13269
  targetType: o,
13165
13270
  reference: t,
13166
13271
  portionSelectors: s,
13167
- ...w_(a) ? { tableTarget: a } : {},
13272
+ ...N_(a) ? { tableTarget: a } : {},
13168
13273
  ...h
13169
13274
  };
13170
13275
  case "delete_article": return o === "article" ? {
@@ -13188,7 +13293,7 @@ function ev({ action: e, reference: t, sourcePosition: n, sourceText: r, fullTex
13188
13293
  }
13189
13294
  return y(p);
13190
13295
  }
13191
- function tv(e) {
13296
+ function uv(e) {
13192
13297
  let t = /\barticle\s+([0-9]+(?:-[0-9]+)?(?:\s*[A-Z])?(?:\s+[a-z]+)?)\b/i.exec(e);
13193
13298
  if (!t || t.index === void 0) return null;
13194
13299
  let n = t.index, r = t.index + t[0].length;
@@ -13207,73 +13312,73 @@ function tv(e) {
13207
13312
  }
13208
13313
  };
13209
13314
  }
13210
- function nv(e, t) {
13315
+ function dv(e, t) {
13211
13316
  let n = performance.now(), r = ve(e);
13212
13317
  Q(t.diagnostics, "simplifyMs", n);
13213
13318
  let i = r.output;
13214
13319
  if (t.allowListExtraction) {
13215
- let e = performance.now(), n = D_(i, t.diagnostics);
13320
+ let e = performance.now(), n = I_(i, t.diagnostics);
13216
13321
  if (Q(t.diagnostics, "listExtractionMs", e), n) return t.diagnostics !== void 0 && (t.diagnostics.directiveCount = n.length), n;
13217
13322
  }
13218
- let a = performance.now(), o = Hh(i), s = G_(i), c = Gh(i);
13323
+ let a = performance.now(), o = qh(i), s = ev(i), c = Xh(i);
13219
13324
  Q(t.diagnostics, "prepareRangesMs", a);
13220
- let l = new S(i), u = performance.now(), d = ih(l);
13325
+ let l = new S(i), u = performance.now(), d = lh(l);
13221
13326
  Q(t.diagnostics, "extractReferencesMs", u);
13222
13327
  let f = [...o, ...s];
13223
13328
  if (f.length > 0) {
13224
13329
  let e = performance.now();
13225
- d = d.filter((e) => !K_(e, f)), Q(t.diagnostics, "filterReferencesMs", e);
13330
+ d = d.filter((e) => !tv(e, f)), Q(t.diagnostics, "filterReferencesMs", e);
13226
13331
  }
13227
13332
  if (d.length === 0) {
13228
13333
  let e = performance.now();
13229
- d = ih(new S(c.split(",")[0] ?? c)), Q(t.diagnostics, "fallbackReferencesMs", e);
13334
+ d = lh(new S(c.split(",")[0] ?? c)), Q(t.diagnostics, "fallbackReferencesMs", e);
13230
13335
  }
13231
13336
  if (d.length === 0) {
13232
- let e = performance.now(), n = tv(c);
13337
+ let e = performance.now(), n = uv(c);
13233
13338
  n && (d = [{
13234
13339
  ...n.reference,
13235
13340
  position: n.position
13236
13341
  }]), Q(t.diagnostics, "fallbackReferencesMs", e);
13237
13342
  }
13238
13343
  t.diagnostics !== void 0 && (t.diagnostics.referenceCount = d.length);
13239
- let p = performance.now(), m = Ng(c);
13344
+ let p = performance.now(), m = Hg(c);
13240
13345
  if (d.length === 1 && d[0]?.type === "article") {
13241
- let e = Lh(c, { actionIndex: m ?? c.length });
13346
+ let e = Hh(c, { actionIndex: m ?? c.length });
13242
13347
  e && (d = [e]);
13243
13348
  }
13244
13349
  if (m !== null) {
13245
- let e = d.some((e) => yt(Rg(e)) === "article"), t = d.some((e) => [...k(Rg(e))].some((e) => e.type === "article")), n = c.slice(0, m), r = Mh(I_(n), 0) ?? Mh(n, 0), i = d.map(Rg).sort((e, t) => Nh(t) - Nh(e) || Ph(t) - Ph(e))[0], a = Fh(i ?? null, r);
13350
+ let e = d.some((e) => yt(qg(e)) === "article"), t = d.some((e) => [...k(qg(e))].some((e) => e.type === "article")), n = c.slice(0, m), r = Lh(G_(n), 0) ?? Lh(n, 0), i = d.map(qg).sort((e, t) => Rh(t) - Rh(e) || zh(t) - zh(e))[0], a = Bh(i ?? null, r);
13246
13351
  if (!e && a && a === r && (d = [r]), !t) {
13247
13352
  let e = i, t = n.indexOf(":");
13248
13353
  if (t !== -1) {
13249
- let r = t + 1, i = Mh(L_(n.slice(r)), r), a = i ? Hp(i) : [];
13250
- e && i && Nh(e) > 0 && (a.length > 1 || a.some((e) => e.kind === "range")) && (d = [t_(e, i)]);
13354
+ let r = t + 1, i = Lh(K_(n.slice(r)), r), a = i ? qp(i) : [];
13355
+ e && i && Rh(e) > 0 && (a.length > 1 || a.some((e) => e.kind === "range")) && (d = [u_(e, i)]);
13251
13356
  }
13252
13357
  }
13253
13358
  if (t) {
13254
- let e = d.map(Rg).filter((e) => [...k(e)].some((e) => e.type === "article")).sort((e, t) => Nh(t) - Nh(e) || Ph(t) - Ph(e))[0], t = n.indexOf(":"), r = t === -1 ? 0 : t + 1, i = Mh(L_(n.slice(r)), r), a = i ? Hp(i) : [];
13255
- t !== -1 && e && i && Nh(e) > 0 && (a.length > 1 || a.some((e) => e.kind === "range")) && d.push(t_(e, i));
13359
+ let e = d.map(qg).filter((e) => [...k(e)].some((e) => e.type === "article")).sort((e, t) => Rh(t) - Rh(e) || zh(t) - zh(e))[0], t = n.indexOf(":"), r = t === -1 ? 0 : t + 1, i = Lh(K_(n.slice(r)), r), a = i ? qp(i) : [];
13360
+ t !== -1 && e && i && Rh(e) > 0 && (a.length > 1 || a.some((e) => e.kind === "range")) && d.push(u_(e, i));
13256
13361
  }
13257
13362
  }
13258
13363
  Q(t.diagnostics, "refineReferencesMs", p);
13259
13364
  let h = [], g = performance.now();
13260
13365
  for (let e of d) {
13261
13366
  if (e.type === "reference_et_action") {
13262
- let t = e.position?.start ?? 0, n = i.lastIndexOf("\n", Math.max(0, t - 1)) + 1, r = J_(i.slice(n, t)) ? n : t, a = {
13367
+ let t = e.position?.start ?? 0, n = i.lastIndexOf("\n", Math.max(0, t - 1)) + 1, r = rv(i.slice(n, t)) ? n : t, a = {
13263
13368
  start: r,
13264
13369
  stop: i.length
13265
- }, o = i.slice(r), s = ev({
13370
+ }, o = i.slice(r), s = lv({
13266
13371
  action: e.action,
13267
13372
  reference: e.reference,
13268
13373
  sourcePosition: a,
13269
13374
  sourceText: o,
13270
13375
  fullText: i,
13271
- tableTarget: F_(o) ?? F_(i)
13376
+ tableTarget: W_(o) ?? W_(i)
13272
13377
  });
13273
13378
  s && (Array.isArray(s) ? h.push(...s) : h.push(s));
13274
13379
  continue;
13275
13380
  }
13276
- let t = ev({
13381
+ let t = lv({
13277
13382
  action: { action: "modifier" },
13278
13383
  reference: e,
13279
13384
  sourcePosition: e.position ?? {
@@ -13282,92 +13387,92 @@ function nv(e, t) {
13282
13387
  },
13283
13388
  sourceText: i,
13284
13389
  fullText: i,
13285
- tableTarget: F_(i)
13390
+ tableTarget: W_(i)
13286
13391
  });
13287
13392
  t && (Array.isArray(t) ? h.push(...t) : h.push(t));
13288
13393
  }
13289
13394
  if (h.length === 0) {
13290
- let e = tv(c);
13395
+ let e = uv(c);
13291
13396
  if (e) {
13292
- let t = ev({
13397
+ let t = lv({
13293
13398
  action: { action: "modifier" },
13294
13399
  reference: e.reference,
13295
13400
  sourcePosition: e.position,
13296
13401
  sourceText: i,
13297
13402
  fullText: i,
13298
- tableTarget: F_(i)
13403
+ tableTarget: W_(i)
13299
13404
  });
13300
13405
  t && (Array.isArray(t) ? h.push(...t) : h.push(t));
13301
13406
  }
13302
13407
  }
13303
13408
  Q(t.diagnostics, "buildDirectivesMs", g);
13304
- let _ = performance.now(), v = $_(h);
13409
+ let _ = performance.now(), v = cv(h);
13305
13410
  return Q(t.diagnostics, "canonicalizeMs", _), t.diagnostics !== void 0 && (t.diagnostics.directiveCount = v.length), v;
13306
13411
  }
13307
- function rv(e) {
13412
+ function fv(e) {
13308
13413
  let t = new S(ve(e).output);
13309
- return [...lg.extract(t, { overlapWindow: 100 })];
13414
+ return [...mg.extract(t, { overlapWindow: 100 })];
13310
13415
  }
13311
- function iv(e, t) {
13312
- return nv(e, {
13416
+ function pv(e, t) {
13417
+ return dv(e, {
13313
13418
  allowListExtraction: !0,
13314
13419
  diagnostics: t
13315
13420
  });
13316
13421
  }
13317
- var av = iv;
13318
- function ov(e) {
13319
- let t = mh(e);
13320
- return t.includes("«") || t.includes("»") || !e.trim().endsWith(":") ? !1 : Sh(t);
13422
+ var mv = pv;
13423
+ function hv(e) {
13424
+ let t = yh(e);
13425
+ return t.includes("«") || t.includes("»") || !e.trim().endsWith(":") ? !1 : Dh(t);
13321
13426
  }
13322
- function sv(e) {
13427
+ function gv(e) {
13323
13428
  return e.trimStart().startsWith("«");
13324
13429
  }
13325
- function cv(e) {
13430
+ function _v(e) {
13326
13431
  return /»[.;]?\s*$/u.test(e);
13327
13432
  }
13328
- function lv(e, t) {
13433
+ function vv(e, t) {
13329
13434
  for (let n = t; n < e.length; n += 1) {
13330
- let t = wg(e[n]).trim();
13435
+ let t = Ng(e[n]).trim();
13331
13436
  if (t.length > 0) return t;
13332
13437
  }
13333
13438
  }
13334
- function uv(e, t) {
13439
+ function yv(e, t) {
13335
13440
  let n = [], r = !1, i = t + 1;
13336
13441
  for (; i < e.length;) {
13337
- let t = e[i], a = wg(t);
13442
+ let t = e[i], a = Ng(t);
13338
13443
  if (!r && a.includes("«") && (r = !0), r) {
13339
13444
  n.push(a);
13340
- let t = lv(e, i + 1);
13341
- if (cv(a) && (t === void 0 || !sv(t))) break;
13445
+ let t = vv(e, i + 1);
13446
+ if (_v(a) && (t === void 0 || !gv(t))) break;
13342
13447
  } else if (a.trim().length > 0) break;
13343
13448
  i += 1;
13344
13449
  }
13345
13450
  return !r || n.length === 0 ? null : {
13346
- combinedText: [wg(e[t]), ...n].join("\n"),
13451
+ combinedText: [Ng(e[t]), ...n].join("\n"),
13347
13452
  endIndex: i
13348
13453
  };
13349
13454
  }
13350
- function dv(e) {
13455
+ function bv(e) {
13351
13456
  let t = v()(e).output.split("\n").map((e) => e.trim()).filter((e) => e.length > 0), n = [];
13352
13457
  for (let e = 0; e < t.length; e += 1) {
13353
13458
  let r = t[e];
13354
- if (ov(r)) {
13355
- let r = uv(t, e);
13459
+ if (hv(r)) {
13460
+ let r = yv(t, e);
13356
13461
  if (r) {
13357
- let t = iv(r.combinedText);
13462
+ let t = pv(r.combinedText);
13358
13463
  if (t.length > 0) {
13359
13464
  n.push(...t), e = r.endIndex;
13360
13465
  continue;
13361
13466
  }
13362
13467
  }
13363
13468
  }
13364
- let i = nv(r, { allowListExtraction: !1 });
13469
+ let i = dv(r, { allowListExtraction: !1 });
13365
13470
  i.length > 0 && n.push(...i);
13366
13471
  }
13367
13472
  return n;
13368
13473
  }
13369
- var fv = dv, pv;
13370
- function mv(e) {
13474
+ var xv = bv, Sv;
13475
+ function Cv(e) {
13371
13476
  return {
13372
13477
  dateDebut: e.dateDebut ?? "0001-01-01",
13373
13478
  dateFin: e.dateFin ?? "2999-01-01",
@@ -13376,7 +13481,7 @@ function mv(e) {
13376
13481
  textId: e.textId
13377
13482
  };
13378
13483
  }
13379
- function hv(e) {
13484
+ function wv(e) {
13380
13485
  if (e.length === 0) return;
13381
13486
  let t = /* @__PURE__ */ new Map();
13382
13487
  for (let n of e) {
@@ -13395,7 +13500,7 @@ function hv(e) {
13395
13500
  let [{ id: n }] = [...t.values()];
13396
13501
  return { articleId: n };
13397
13502
  }
13398
- function gv(e) {
13503
+ function Tv(e) {
13399
13504
  let t = e["@id"];
13400
13505
  return t === void 0 ? null : {
13401
13506
  dateDebut: e["@debut"] ?? null,
@@ -13405,10 +13510,10 @@ function gv(e) {
13405
13510
  title: e["#text"] ?? null
13406
13511
  };
13407
13512
  }
13408
- function _v(e, t) {
13513
+ function Ev(e, t) {
13409
13514
  return (e.dateDebut === null || e.dateDebut <= t) && (e.dateFin === null || e.dateFin >= t);
13410
13515
  }
13411
- var vv = class extends Oe {
13516
+ var Dv = class extends Oe {
13412
13517
  canutesDb;
13413
13518
  articleHistoryInfoByTextAndNum = /* @__PURE__ */ new Map();
13414
13519
  articleRowsByNumByTextAndDate = /* @__PURE__ */ new Map();
@@ -13434,12 +13539,12 @@ var vv = class extends Oe {
13434
13539
  WHERE
13435
13540
  data -> 'CONTEXTE' -> 'TEXTE' ->> '@cid' = ${n}
13436
13541
  AND num = ${t}
13437
- `).map(mv), this.articleRowsByNumByTextAndDate.set(r, i)), i;
13542
+ `).map(Cv), this.articleRowsByNumByTextAndDate.set(r, i)), i;
13438
13543
  }
13439
13544
  async getArticleHistoryInfo({ num: e, textId: t }) {
13440
13545
  if (e === void 0) return;
13441
13546
  let n = `${t}\0${e}`, r = this.articleHistoryInfoByTextAndNum.get(n);
13442
- return r === void 0 && (r = hv(await this.canutesDb`
13547
+ return r === void 0 && (r = wv(await this.canutesDb`
13443
13548
  SELECT
13444
13549
  id,
13445
13550
  data -> 'META' -> 'META_SPEC' -> 'META_ARTICLE' ->> 'DATE_DEBUT' AS "dateDebut",
@@ -13462,7 +13567,7 @@ var vv = class extends Oe {
13462
13567
  SELECT data
13463
13568
  FROM legifrance.textelr
13464
13569
  WHERE id = ${t}
13465
- `)[0]?.data.STRUCT?.LIEN_SECTION_TA?.map(gv).filter((e) => e !== null).filter((t) => _v(t, e)) ?? [] : i.map(gv).filter((e) => e !== null).filter((t) => _v(t, e)), this.directSectionChildrenByParentAndDate.set(n, r);
13570
+ `)[0]?.data.STRUCT?.LIEN_SECTION_TA?.map(Tv).filter((e) => e !== null).filter((t) => Ev(t, e)) ?? [] : i.map(Tv).filter((e) => e !== null).filter((t) => Ev(t, e)), this.directSectionChildrenByParentAndDate.set(n, r);
13466
13571
  }
13467
13572
  return r;
13468
13573
  }
@@ -13505,7 +13610,7 @@ var vv = class extends Oe {
13505
13610
  FROM legifrance.article
13506
13611
  WHERE num = ${t}
13507
13612
  LIMIT 100
13508
- `).map(mv), this.globalArticleRowsByNumAndDate.set(n, r)), r;
13613
+ `).map(Cv), this.globalArticleRowsByNumAndDate.set(n, r)), r;
13509
13614
  }
13510
13615
  async preloadTextTitlesInfos(e = {}) {
13511
13616
  let t = (t, n = {}) => {
@@ -13520,7 +13625,7 @@ var vv = class extends Oe {
13520
13625
  return;
13521
13626
  }
13522
13627
  let n = new we("canutes.preloadTextTitlesInfos");
13523
- pv === void 0 ? (t("queryTextTitlesInfos:start"), pv = (async () => {
13628
+ Sv === void 0 ? (t("queryTextTitlesInfos:start"), Sv = (async () => {
13524
13629
  let e = await n.time("queryTextTitlesInfos", () => this.canutesDb`
13525
13630
  SELECT
13526
13631
  data -> 'META' -> 'META_SPEC' -> 'META_TEXTE_CHRONICLE' ->> 'CID' AS cid,
@@ -13550,8 +13655,8 @@ var vv = class extends Oe {
13550
13655
  `);
13551
13656
  t("queryTextTitlesInfos:done", { count: e.length }), t("buildTextTitlesInfos:start", { count: e.length }), await Se(e, { onProgress: ({ count: e, phase: n }) => t(`buildTextTitlesInfos:${n}`, { count: e }) }), t("buildTextTitlesInfos:done", { count: e.length }), t("setTextTitlesInfos:done");
13552
13657
  })().catch((e) => {
13553
- throw pv = void 0, e;
13554
- })) : t("waiting-for-shared-preload"), await pv, n.log(), this.textTitlesInfosLoaded = !0;
13658
+ throw Sv = void 0, e;
13659
+ })) : t("waiting-for-shared-preload"), await Sv, n.log(), this.textTitlesInfosLoaded = !0;
13555
13660
  }
13556
13661
  async preloadUniqueActiveArticlesByNums({ date: e, nums: t }) {
13557
13662
  let n = [...new Set([...t].filter(Boolean))].filter((t) => !this.globalArticleRowsByNumAndDate.has(`${t}\0${e}`));
@@ -13565,7 +13670,7 @@ var vv = class extends Oe {
13565
13670
  data -> 'META' -> 'META_SPEC' -> 'META_ARTICLE' ->> 'DATE_FIN' AS "dateFin"
13566
13671
  FROM legifrance.article
13567
13672
  WHERE num IN ${this.canutesDb(n)}
13568
- `).map(mv), i = /* @__PURE__ */ new Map();
13673
+ `).map(Cv), i = /* @__PURE__ */ new Map();
13569
13674
  for (let e of r) {
13570
13675
  if (e.num === null) continue;
13571
13676
  let t = i.get(e.num);
@@ -13576,7 +13681,7 @@ var vv = class extends Oe {
13576
13681
  };
13577
13682
  //#endregion
13578
13683
  //#region src/lib/extractors/links.ts
13579
- function yv() {
13684
+ function Ov() {
13580
13685
  return {
13581
13686
  citationCount: 0,
13582
13687
  fastPath: {
@@ -13593,7 +13698,7 @@ function yv() {
13593
13698
  }
13594
13699
  };
13595
13700
  }
13596
- function bv() {
13701
+ function kv() {
13597
13702
  return {
13598
13703
  articleDefinitionLinkCount: 0,
13599
13704
  articleDirectLookupMs: 0,
@@ -13623,7 +13728,7 @@ function bv() {
13623
13728
  textLinkMs: 0
13624
13729
  };
13625
13730
  }
13626
- function xv() {
13731
+ function Av() {
13627
13732
  return {
13628
13733
  alternativeTargetCandidateCount: 0,
13629
13734
  getActiveArticlesByTextAndNumCount: 0,
@@ -13634,7 +13739,7 @@ function xv() {
13634
13739
  uniqueFallbackCheckCount: 0
13635
13740
  };
13636
13741
  }
13637
- function Sv(e, t, n, r, i) {
13742
+ function jv(e, t, n, r, i) {
13638
13743
  let a = e.get(t);
13639
13744
  a === void 0 && (a = /* @__PURE__ */ new Map(), e.set(t, a));
13640
13745
  let o = a.get(n) ?? {
@@ -13644,7 +13749,7 @@ function Sv(e, t, n, r, i) {
13644
13749
  };
13645
13750
  o.count += 1, o.outputSize += i, o.totalMs += r, a.set(n, o);
13646
13751
  }
13647
- function Cv(e) {
13752
+ function Mv(e) {
13648
13753
  return Object.fromEntries([...e.entries()].map(([e, t]) => {
13649
13754
  let n = 0, r = 0, i = 0;
13650
13755
  for (let e of t.values()) n += e.count, r += e.outputSize, i += e.totalMs;
@@ -13662,7 +13767,7 @@ function Cv(e) {
13662
13767
  }];
13663
13768
  }));
13664
13769
  }
13665
- var wv = class {
13770
+ var Nv = class {
13666
13771
  inner;
13667
13772
  diagnostics;
13668
13773
  constructor(e, t) {
@@ -13670,67 +13775,67 @@ var wv = class {
13670
13775
  }
13671
13776
  async getActiveArticlesByTextAndNum(e) {
13672
13777
  let t = performance.now(), n = await this.inner.getActiveArticlesByTextAndNum(e);
13673
- return Sv(this.diagnostics, "getActiveArticlesByTextAndNum", `${e.date}\0${e.textId}\0${e.num ?? ""}`, performance.now() - t, n.length), n;
13778
+ return jv(this.diagnostics, "getActiveArticlesByTextAndNum", `${e.date}\0${e.textId}\0${e.num ?? ""}`, performance.now() - t, n.length), n;
13674
13779
  }
13675
13780
  async getArticleHistoryInfo(e) {
13676
13781
  let t = performance.now(), n = await this.inner.getArticleHistoryInfo(e);
13677
- return Sv(this.diagnostics, "getArticleHistoryInfo", `${e.textId}\0${e.num ?? ""}`, performance.now() - t, n === void 0 ? 0 : 1), n;
13782
+ return jv(this.diagnostics, "getArticleHistoryInfo", `${e.textId}\0${e.num ?? ""}`, performance.now() - t, n === void 0 ? 0 : 1), n;
13678
13783
  }
13679
13784
  async getDirectSectionChildren(e) {
13680
13785
  let t = performance.now(), n = await this.inner.getDirectSectionChildren(e);
13681
- return Sv(this.diagnostics, "getDirectSectionChildren", `${e.date}\0${e.parentPath}`, performance.now() - t, n.length), n;
13786
+ return jv(this.diagnostics, "getDirectSectionChildren", `${e.date}\0${e.parentPath}`, performance.now() - t, n.length), n;
13682
13787
  }
13683
13788
  async getEuropeanTextUrl(e) {
13684
13789
  let t = performance.now(), n = await this.inner.getEuropeanTextUrl(e);
13685
- return Sv(this.diagnostics, "getEuropeanTextUrl", e, performance.now() - t, n === void 0 ? 0 : 1), n;
13790
+ return jv(this.diagnostics, "getEuropeanTextUrl", e, performance.now() - t, n === void 0 ? 0 : 1), n;
13686
13791
  }
13687
13792
  async getTextIdFromSegmentId(e) {
13688
13793
  let t = performance.now(), n = await this.inner.getTextIdFromSegmentId(e);
13689
- return Sv(this.diagnostics, "getTextIdFromSegmentId", e, performance.now() - t, n === void 0 ? 0 : 1), n;
13794
+ return jv(this.diagnostics, "getTextIdFromSegmentId", e, performance.now() - t, n === void 0 ? 0 : 1), n;
13690
13795
  }
13691
13796
  async getUniqueActiveArticlesByNum(e) {
13692
13797
  let t = performance.now(), n = await this.inner.getUniqueActiveArticlesByNum(e);
13693
- return Sv(this.diagnostics, "getUniqueActiveArticlesByNum", `${e.date}\0${e.num ?? ""}`, performance.now() - t, n.length), n;
13798
+ return jv(this.diagnostics, "getUniqueActiveArticlesByNum", `${e.date}\0${e.num ?? ""}`, performance.now() - t, n.length), n;
13694
13799
  }
13695
13800
  async preloadActiveArticlesByTextIds(e) {
13696
13801
  let t = [...e.nums ?? []].filter((e) => e !== void 0).toSorted(), n = [...e.textIds].filter((e) => e !== void 0).toSorted(), r = performance.now();
13697
- await this.inner.preloadActiveArticlesByTextIds(e), Sv(this.diagnostics, "preloadActiveArticlesByTextIds", `${e.date}\0texts=${n.length}\0nums=${t.length}`, performance.now() - r, n.length * Math.max(1, t.length));
13802
+ await this.inner.preloadActiveArticlesByTextIds(e), jv(this.diagnostics, "preloadActiveArticlesByTextIds", `${e.date}\0texts=${n.length}\0nums=${t.length}`, performance.now() - r, n.length * Math.max(1, t.length));
13698
13803
  }
13699
13804
  async preloadTextTitlesInfos(e) {
13700
13805
  let t = performance.now();
13701
- await this.inner.preloadTextTitlesInfos(e), Sv(this.diagnostics, "preloadTextTitlesInfos", "all", performance.now() - t, 1);
13806
+ await this.inner.preloadTextTitlesInfos(e), jv(this.diagnostics, "preloadTextTitlesInfos", "all", performance.now() - t, 1);
13702
13807
  }
13703
13808
  async preloadUniqueActiveArticlesByNums(e) {
13704
13809
  let t = [...e.nums].filter((e) => e !== void 0).toSorted(), n = performance.now();
13705
13810
  await this.inner.preloadUniqueActiveArticlesByNums({
13706
13811
  ...e,
13707
13812
  nums: t
13708
- }), Sv(this.diagnostics, "preloadUniqueActiveArticlesByNums", `${e.date}\0nums=${t.length}`, performance.now() - n, t.length);
13813
+ }), jv(this.diagnostics, "preloadUniqueActiveArticlesByNums", `${e.date}\0nums=${t.length}`, performance.now() - n, t.length);
13709
13814
  }
13710
13815
  };
13711
13816
  function $(e, t, n) {
13712
13817
  e[t] += Math.round((performance.now() - n) * 10) / 10;
13713
13818
  }
13714
- function Tv(e) {
13819
+ function Pv(e) {
13715
13820
  let t = {};
13716
13821
  for (let n of e) t[n.type] = (t[n.type] ?? 0) + 1;
13717
13822
  return t;
13718
13823
  }
13719
- function Ev(e, t = 20) {
13824
+ function Fv(e, t = 20) {
13720
13825
  return Object.entries(e).map(([e, t]) => ({
13721
13826
  count: t,
13722
13827
  value: e
13723
13828
  })).toSorted((e, t) => t.count - e.count).slice(0, t);
13724
13829
  }
13725
- async function* Dv({ canutesDb: e, context: t, date: n, includeInternalArticleLinks: r = !1, legiResolver: i, logIgnoredReferencesTypes: a, logPartialReferences: o, logReferences: s, state: c, transformation: l }) {
13726
- let u = i ?? (e === void 0 ? void 0 : new vv(e));
13830
+ async function* Iv({ canutesDb: e, context: t, date: n, includeInternalArticleLinks: r = !1, legiResolver: i, logIgnoredReferencesTypes: a, logPartialReferences: o, logReferences: s, state: c, transformation: l }) {
13831
+ let u = i ?? (e === void 0 ? void 0 : new Dv(e));
13727
13832
  if (u === void 0) throw Error("A Canutes database or legal resolver is required");
13728
- let d = new we("extractTextLinks"), f = /* @__PURE__ */ new Map(), p = d.enabled ? new wv(u, f) : u, m = yv(), h = bv(), _ = xv(), v = {}, y = l === void 0 ? void 0 : g(l), b = c === void 0 ? {} : structuredClone(c), x = d.timeSync("extractReferences", () => {
13833
+ let d = new we("extractTextLinks"), f = /* @__PURE__ */ new Map(), p = d.enabled ? new Nv(u, f) : u, m = Ov(), h = kv(), _ = Av(), v = {}, y = l === void 0 ? void 0 : g(l), b = c === void 0 ? {} : structuredClone(c), x = d.timeSync("extractReferences", () => {
13729
13834
  let e = [];
13730
- for (let n of l === void 0 ? th(t, { diagnostics: m }) : rh(t, l, { diagnostics: m })) s && console.log(`In "${t.input.slice(n.position.start, n.position.stop)}": \nReference "${t.text(n.position)}": ${JSON.stringify(n, null, 2)}`), e.push(n);
13835
+ for (let n of l === void 0 ? oh(t, { diagnostics: m }) : ch(t, l, { diagnostics: m })) s && console.log(`In "${t.input.slice(n.position.start, n.position.stop)}": \nReference "${t.text(n.position)}": ${JSON.stringify(n, null, 2)}`), e.push(n);
13731
13836
  return e;
13732
13837
  }, { inputSize: t.input.length }), ee = performance.now();
13733
- for (let e of x) for (let n of Jv(t, e)) {
13838
+ for (let e of x) for (let n of ry(t, e)) {
13734
13839
  let r = n.type === "parent-enfant" ? n.parent : n;
13735
13840
  switch (r.type) {
13736
13841
  case "alinéa":
@@ -13759,7 +13864,7 @@ async function* Dv({ canutesDb: e, context: t, date: n, includeInternalArticleLi
13759
13864
  r.definition && b.textId === void 0 && o && console.log(`In "${t.input.slice(e.position.start, e.position.stop)}": Missing state.textId for division definition`);
13760
13865
  break;
13761
13866
  case "texte":
13762
- Ov({
13867
+ Lv({
13763
13868
  context: t,
13764
13869
  logPartialReferences: o,
13765
13870
  reference: e,
@@ -13775,14 +13880,14 @@ async function* Dv({ canutesDb: e, context: t, date: n, includeInternalArticleLi
13775
13880
  phase: "collectDefinitionsAndTextState"
13776
13881
  });
13777
13882
  let te = /* @__PURE__ */ new Set();
13778
- for (let e of x) for (let t of qv(e, { citations: !0 })) te.add(t);
13779
- let S = kv(t, x);
13883
+ for (let e of x) for (let t of ny(e, { citations: !0 })) te.add(t);
13884
+ let S = Rv(t, x);
13780
13885
  await d.time("preloadActiveArticlesByTextIds", () => p.preloadActiveArticlesByTextIds({
13781
13886
  date: n,
13782
13887
  nums: te,
13783
13888
  textIds: S
13784
13889
  }), { count: S.size });
13785
- let ne = await d.time("collectUniqueFallbackArticleNums", () => Av({
13890
+ let ne = await d.time("collectUniqueFallbackArticleNums", () => zv({
13786
13891
  context: t,
13787
13892
  date: n,
13788
13893
  legiResolver: p,
@@ -13796,7 +13901,7 @@ async function* Dv({ canutesDb: e, context: t, date: n, includeInternalArticleLi
13796
13901
  nums: ne
13797
13902
  }), { count: ne.size }), b = c === void 0 ? {} : c;
13798
13903
  let C = 0, re = performance.now();
13799
- for (let e of x) for await (let i of $v({
13904
+ for (let e of x) for await (let i of cy({
13800
13905
  articleDefinitionByNumByTextId: v,
13801
13906
  includeInternalArticleLinks: r,
13802
13907
  legiResolver: p,
@@ -13816,12 +13921,12 @@ async function* Dv({ canutesDb: e, context: t, date: n, includeInternalArticleLi
13816
13921
  phase: "iterReferenceLinks"
13817
13922
  }), d.log({
13818
13923
  articleNumCount: te.size,
13819
- referenceTypeCounts: Tv(x),
13924
+ referenceTypeCounts: Pv(x),
13820
13925
  referenceCount: x.length,
13821
13926
  iterationDiagnostics: h,
13822
- resolverCallDiagnostics: Cv(f),
13927
+ resolverCallDiagnostics: Mv(f),
13823
13928
  resolverDiagnostics: _,
13824
- topFastPathAnchors: Ev(m.fastPath.anchorCounts),
13929
+ topFastPathAnchors: Fv(m.fastPath.anchorCounts),
13825
13930
  uniqueFallbackArticleNumCount: ne.size,
13826
13931
  fastPathCandidateCount: m.fastPath.candidateCount,
13827
13932
  fastPathCheckedOffsetCount: m.fastPath.checkedOffsetCount,
@@ -13835,7 +13940,7 @@ async function* Dv({ canutesDb: e, context: t, date: n, includeInternalArticleLi
13835
13940
  extractReferencesCitationCount: m.citationCount
13836
13941
  });
13837
13942
  }
13838
- function Ov({ context: e, logPartialReferences: t, reference: n, state: r, text: i }) {
13943
+ function Lv({ context: e, logPartialReferences: t, reference: n, state: r, text: i }) {
13839
13944
  switch (i.nature) {
13840
13945
  case "ARRETE":
13841
13946
  case "CIRCULAIRE":
@@ -13906,17 +14011,17 @@ function Ov({ context: e, logPartialReferences: t, reference: n, state: r, text:
13906
14011
  default: i.nature === void 0 ? delete r.textId : m("nature", i.nature);
13907
14012
  }
13908
14013
  }
13909
- function kv(e, t) {
14014
+ function Rv(e, t) {
13910
14015
  let n = /* @__PURE__ */ new Set();
13911
- for (let r of t) for (let t of Jv(e, r, { citations: !0 })) {
14016
+ for (let r of t) for (let t of ry(e, r, { citations: !0 })) {
13912
14017
  let e = t.type === "parent-enfant" ? t.parent : t;
13913
14018
  e.type === "texte" && e.cid !== void 0 ? n.add(e.cid) : e.type === "article" && e.implicitText?.cid !== void 0 && n.add(e.implicitText.cid);
13914
14019
  }
13915
14020
  return n;
13916
14021
  }
13917
- async function Av({ context: e, date: t, legiResolver: n, logPartialReferences: r, resolverDiagnostics: i, references: a, state: o }) {
14022
+ async function zv({ context: e, date: t, legiResolver: n, logPartialReferences: r, resolverDiagnostics: i, references: a, state: o }) {
13918
14023
  let s = /* @__PURE__ */ new Set();
13919
- for (let c of a) await jv({
14024
+ for (let c of a) await Bv({
13920
14025
  articleNums: s,
13921
14026
  context: e,
13922
14027
  date: t,
@@ -13928,8 +14033,8 @@ async function Av({ context: e, date: t, legiResolver: n, logPartialReferences:
13928
14033
  });
13929
14034
  return s;
13930
14035
  }
13931
- async function jv({ articleNums: e, context: t, date: n, legiResolver: r, logPartialReferences: i, resolverDiagnostics: a, reference: o, state: s }) {
13932
- for (let c of Jv(t, o)) await Mv({
14036
+ async function Bv({ articleNums: e, context: t, date: n, legiResolver: r, logPartialReferences: i, resolverDiagnostics: a, reference: o, state: s }) {
14037
+ for (let c of ry(t, o)) await Vv({
13933
14038
  articleNums: e,
13934
14039
  atomicOrParentChildReference: c,
13935
14040
  context: t,
@@ -13945,7 +14050,7 @@ async function jv({ articleNums: e, context: t, date: n, legiResolver: r, logPar
13945
14050
  if (c !== void 0) {
13946
14051
  for (let o of c) if (o.references !== void 0) {
13947
14052
  let c = structuredClone(s);
13948
- for (let s of o.references) await jv({
14053
+ for (let s of o.references) await Bv({
13949
14054
  articleNums: e,
13950
14055
  context: t,
13951
14056
  date: n,
@@ -13959,7 +14064,7 @@ async function jv({ articleNums: e, context: t, date: n, legiResolver: r, logPar
13959
14064
  }
13960
14065
  }
13961
14066
  }
13962
- async function Mv({ articleNums: e, atomicOrParentChildReference: t, context: n, date: r, legiResolver: i, logPartialReferences: a, resolverDiagnostics: o, reference: s, state: c }) {
14067
+ async function Vv({ articleNums: e, atomicOrParentChildReference: t, context: n, date: r, legiResolver: i, logPartialReferences: a, resolverDiagnostics: o, reference: s, state: c }) {
13963
14068
  let l = t.type === "parent-enfant" ? t.parent : t, u = t.type === "parent-enfant" ? t : void 0;
13964
14069
  switch (l.type) {
13965
14070
  case "alinéa":
@@ -13968,7 +14073,7 @@ async function Mv({ articleNums: e, atomicOrParentChildReference: t, context: n,
13968
14073
  case "phrase": break;
13969
14074
  case "article":
13970
14075
  if (l.definition && c.textId !== void 0) break;
13971
- await Gv({
14076
+ await ey({
13972
14077
  article: l,
13973
14078
  date: r,
13974
14079
  legiResolver: i,
@@ -13987,7 +14092,7 @@ async function Mv({ articleNums: e, atomicOrParentChildReference: t, context: n,
13987
14092
  case "sous-titre":
13988
14093
  case "titre":
13989
14094
  if (l.definition && c.textId !== void 0) break;
13990
- u !== void 0 && await jv({
14095
+ u !== void 0 && await Bv({
13991
14096
  articleNums: e,
13992
14097
  context: n,
13993
14098
  date: r,
@@ -13999,13 +14104,13 @@ async function Mv({ articleNums: e, atomicOrParentChildReference: t, context: n,
13999
14104
  });
14000
14105
  break;
14001
14106
  case "texte":
14002
- Ov({
14107
+ Lv({
14003
14108
  context: n,
14004
14109
  logPartialReferences: a,
14005
14110
  reference: s,
14006
14111
  state: c,
14007
14112
  text: l
14008
- }), u !== void 0 && await jv({
14113
+ }), u !== void 0 && await Bv({
14009
14114
  articleNums: e,
14010
14115
  context: n,
14011
14116
  date: r,
@@ -14019,14 +14124,14 @@ async function Mv({ articleNums: e, atomicOrParentChildReference: t, context: n,
14019
14124
  default: break;
14020
14125
  }
14021
14126
  }
14022
- var Nv = new Set([
14127
+ var Hv = new Set([
14023
14128
  "LEGITEXT000005634379",
14024
14129
  "LEGITEXT000006069583",
14025
14130
  "LEGITEXT000006070933",
14026
14131
  "LEGITEXT000006072026",
14027
14132
  "LEGITEXT000006073984",
14028
14133
  "LEGITEXT000006074096"
14029
- ]), Pv = new Set([
14134
+ ]), Uv = new Set([
14030
14135
  "LEGITEXT000006069568",
14031
14136
  "LEGITEXT000006069569",
14032
14137
  "LEGITEXT000006069574",
@@ -14034,41 +14139,41 @@ var Nv = new Set([
14034
14139
  "LEGITEXT000006069577",
14035
14140
  "LEGITEXT000006069583"
14036
14141
  ]);
14037
- function Fv(e, t, n) {
14142
+ function Wv(e, t, n) {
14038
14143
  let r = n.replace(/\s+/gu, " ").trim();
14039
14144
  r !== "" && r !== t && e.add(r);
14040
14145
  }
14041
- function Iv(e, t) {
14146
+ function Gv(e, t) {
14042
14147
  let n = new Set([e]), r = new Set([e]);
14043
14148
  for (let i = 0; i < 3; i++) {
14044
14149
  let i = /* @__PURE__ */ new Set();
14045
14150
  for (let a of r) {
14046
14151
  let r = /* @__PURE__ */ new Set();
14047
- Fv(r, e, a.replace(/\s*-\s*/gu, "-")), Fv(r, e, a.replace(/^(R\*)\s*(\d)/u, "$1 $2")), t === "LEGITEXT000006069583" && (Fv(r, e, a.replace(/^(R)(\d)/u, "$1*$2")), Fv(r, e, a.replace(/^(R)(\d)/u, "$1* $2"))), Fv(r, e, a.replace(/^R\*/u, "*R")), Fv(r, e, a.replace(/^R\*/u, "R"));
14048
- for (let t of a.matchAll(/-(?=\p{L})/gu)) Fv(r, e, `${a.slice(0, t.index)} ${a.slice(t.index + 1)}`);
14049
- Fv(r, e, a.replace(/-O(?=\p{L}|\s|$)/gu, "-0")), Fv(r, e, a.replace(/-0(?=\p{L})/gu, "-0 "));
14152
+ Wv(r, e, a.replace(/\s*-\s*/gu, "-")), Wv(r, e, a.replace(/^(R\*)\s*(\d)/u, "$1 $2")), t === "LEGITEXT000006069583" && (Wv(r, e, a.replace(/^(R)(\d)/u, "$1*$2")), Wv(r, e, a.replace(/^(R)(\d)/u, "$1* $2"))), Wv(r, e, a.replace(/^R\*/u, "*R")), Wv(r, e, a.replace(/^R\*/u, "R"));
14153
+ for (let t of a.matchAll(/-(?=\p{L})/gu)) Wv(r, e, `${a.slice(0, t.index)} ${a.slice(t.index + 1)}`);
14154
+ Wv(r, e, a.replace(/-O(?=\p{L}|\s|$)/gu, "-0")), Wv(r, e, a.replace(/-0(?=\p{L})/gu, "-0 "));
14050
14155
  let o = a.match(/^((?:L\s*O|[LRDA])\*?\s*)(\d{4,})$/u);
14051
14156
  if (o !== null) {
14052
14157
  let [, t, n] = o;
14053
- for (let i = 2; i < n.length; i++) Fv(r, e, `${t}${n.slice(0, i)}-${n.slice(i)}`);
14158
+ for (let i = 2; i < n.length; i++) Wv(r, e, `${t}${n.slice(0, i)}-${n.slice(i)}`);
14054
14159
  }
14055
- if (/^(?:L\s*O|[LRDA])\*?/u.test(a) && Fv(r, e, a.replace(/\s+(\d+)$/u, "-$1")), t === "LEGITEXT000006069576" && /^0\d+$/u.test(a) && Fv(r, e, String(Number(a))), Nv.has(t) && /^\d/u.test(a)) for (let t of [
14160
+ if (/^(?:L\s*O|[LRDA])\*?/u.test(a) && Wv(r, e, a.replace(/\s+(\d+)$/u, "-$1")), t === "LEGITEXT000006069576" && /^0\d+$/u.test(a) && Wv(r, e, String(Number(a))), Hv.has(t) && /^\d/u.test(a)) for (let t of [
14056
14161
  "L",
14057
14162
  "R",
14058
14163
  "D",
14059
14164
  "A",
14060
14165
  "R*",
14061
14166
  "*R"
14062
- ]) Fv(r, e, `${t}${a}`);
14063
- Fv(r, e, a.replace(/(\d)\s+0(?=\s*-?\s*\p{L})/gu, "$1-0")), Fv(r, e, a.replace(/(\p{L})\s+(\d{2})-([\p{L}])$/u, "$1-$2 $3"));
14167
+ ]) Wv(r, e, `${t}${a}`);
14168
+ Wv(r, e, a.replace(/(\d)\s+0(?=\s*-?\s*\p{L})/gu, "$1-0")), Wv(r, e, a.replace(/(\p{L})\s+(\d{2})-([\p{L}])$/u, "$1-$2 $3"));
14064
14169
  for (let e of r) n.has(e) || (n.add(e), i.add(e));
14065
14170
  }
14066
14171
  r = i;
14067
14172
  }
14068
14173
  return n.delete(e), [...n];
14069
14174
  }
14070
- function Lv(e, t) {
14071
- if (!Pv.has(t)) return [];
14175
+ function Kv(e, t) {
14176
+ if (!Uv.has(t)) return [];
14072
14177
  let n = [], r = e;
14073
14178
  for (let e = 0; e < 4; e++) {
14074
14179
  let e = r.replace(/(?:\s*-\s*|\s+)(?:[IVX]+|[1-9]\d*)(?:\s+(?:bis|ter|quater|quinquies|sexies))?$/iu, "").trim();
@@ -14077,10 +14182,10 @@ function Lv(e, t) {
14077
14182
  }
14078
14183
  return n;
14079
14184
  }
14080
- function Rv(e, t) {
14185
+ function qv(e, t) {
14081
14186
  return `${e}\0${t}`;
14082
14187
  }
14083
- var zv = new Map([
14188
+ var Jv = new Map([
14084
14189
  ...[
14085
14190
  "1594 F quinquies A",
14086
14191
  "1594 F quinquies-D",
@@ -14088,7 +14193,7 @@ var zv = new Map([
14088
14193
  "1594 F quinquies E II",
14089
14194
  "1594 F quinquies- E-I",
14090
14195
  "1594 F quinquies K"
14091
- ].map((e) => [Rv("LEGITEXT000006069577", e), {
14196
+ ].map((e) => [qv("LEGITEXT000006069577", e), {
14092
14197
  num: "1594 F quinquies",
14093
14198
  textId: "LEGITEXT000006069577"
14094
14199
  }]),
@@ -14097,7 +14202,7 @@ var zv = new Map([
14097
14202
  "1594-0 G-A",
14098
14203
  "1594-0 G-A-II",
14099
14204
  "1594-0 G-A-VI"
14100
- ].map((e) => [Rv("LEGITEXT000006069577", e), {
14205
+ ].map((e) => [qv("LEGITEXT000006069577", e), {
14101
14206
  num: "1594-0 G",
14102
14207
  textId: "LEGITEXT000006069577"
14103
14208
  }]),
@@ -14109,23 +14214,23 @@ var zv = new Map([
14109
14214
  ["38 B", "LEGITEXT000006069574"],
14110
14215
  ["49 octies D", "LEGITEXT000006069574"],
14111
14216
  ["199-0", "LEGITEXT000006069576"]
14112
- ].map(([e, t]) => [Rv("LEGITEXT000006069577", e), {
14217
+ ].map(([e, t]) => [qv("LEGITEXT000006069577", e), {
14113
14218
  num: e,
14114
14219
  textId: t
14115
14220
  }]),
14116
- [Rv("LEGITEXT000006069577", "L173"), {
14221
+ [qv("LEGITEXT000006069577", "L173"), {
14117
14222
  num: "173",
14118
14223
  textId: "LEGITEXT000006069577"
14119
14224
  }],
14120
- [Rv("LEGITEXT000006069583", "L38 B"), {
14225
+ [qv("LEGITEXT000006069583", "L38 B"), {
14121
14226
  num: "L38",
14122
14227
  textId: "LEGITEXT000006069583"
14123
14228
  }],
14124
- ...["L311-13 C", "L311-13 D"].map((e) => [Rv("LEGITEXT000006070158", e), {
14229
+ ...["L311-13 C", "L311-13 D"].map((e) => [qv("LEGITEXT000006070158", e), {
14125
14230
  num: "L311-13",
14126
14231
  textId: "LEGITEXT000006070158"
14127
14232
  }]),
14128
- [Rv("LEGITEXT000006071154", "226-14"), {
14233
+ [qv("LEGITEXT000006071154", "226-14"), {
14129
14234
  num: "226-14",
14130
14235
  textId: "LEGITEXT000006070719"
14131
14236
  }],
@@ -14133,17 +14238,17 @@ var zv = new Map([
14133
14238
  "1300-1",
14134
14239
  "1300-2",
14135
14240
  "1300-4"
14136
- ].map((e) => [Rv("LEGITEXT000006070721", e), {
14241
+ ].map((e) => [qv("LEGITEXT000006070721", e), {
14137
14242
  num: e,
14138
14243
  textId: "LEGITEXT000006070716"
14139
14244
  }])
14140
- ]), Bv = new Map([
14141
- [Rv("LEGITEXT000006069574", "382-0 C bis"), "LEGIARTI000036256024"],
14142
- [Rv("LEGITEXT000006069577", "1586 quinquies"), "LEGIARTI000023380915"],
14143
- [Rv("LEGITEXT000006069577", "1681 sexies"), "LEGIARTI000037986425"],
14144
- [Rv("LEGITEXT000006069577", "286"), "LEGIARTI000033815246"]
14245
+ ]), Yv = new Map([
14246
+ [qv("LEGITEXT000006069574", "382-0 C bis"), "LEGIARTI000036256024"],
14247
+ [qv("LEGITEXT000006069577", "1586 quinquies"), "LEGIARTI000023380915"],
14248
+ [qv("LEGITEXT000006069577", "1681 sexies"), "LEGIARTI000037986425"],
14249
+ [qv("LEGITEXT000006069577", "286"), "LEGIARTI000033815246"]
14145
14250
  ]);
14146
- function Vv(e, t) {
14251
+ function Xv(e, t) {
14147
14252
  let n = /* @__PURE__ */ new Map(), r = (t, r) => {
14148
14253
  let i = r.replace(/[.·]/gu, "-").replace(/\s*-\s*/gu, "-").replace(/\s+/gu, "-").replace(/-{2,}/gu, "-").replace(/^-|-$/gu, "").replace(/-(?=\s)/gu, "").replace(/\s+/gu, " ").trim();
14149
14254
  i === "" || i === e || !/^(?:[LRDA]\s*)?\d+(?:-\d+)*(?:\s+(?:bis|ter|quater|quinquies|sexies|septies))?$/iu.test(i) || n.set(`${t}\0${i}`, {
@@ -14152,12 +14257,12 @@ function Vv(e, t) {
14152
14257
  });
14153
14258
  }, i = /^(.*\d)\s*[,,;]?\s*(css|cgi|cibs|lpf|cch|cja|casf|cgct|coj|cpi|csp|ceseda|cmf|comofi|cpce)$/iu.exec(e);
14154
14259
  if (i !== null) {
14155
- let e = um(i[2]);
14260
+ let e = hm(i[2]);
14156
14261
  e !== void 0 && r(e, i[1]);
14157
14262
  }
14158
14263
  let a = /^(.*\d)[\s,;]+(?:du\s+|de\s+la\s+|de\s+l')?(code\b[\w'\s]*)$/iu.exec(e);
14159
14264
  if (a !== null) {
14160
- let e = um(a[2]);
14265
+ let e = hm(a[2]);
14161
14266
  e !== void 0 && r(e, a[1]);
14162
14267
  }
14163
14268
  t !== void 0 && r(t, e);
@@ -14177,18 +14282,18 @@ function Vv(e, t) {
14177
14282
  });
14178
14283
  return o;
14179
14284
  }
14180
- function Hv(e) {
14181
- let t = new Set(e.flatMap(({ num: e, textId: t }) => e === null || t === null ? [] : [Rv(t, e)]));
14285
+ function Zv(e) {
14286
+ let t = new Set(e.flatMap(({ num: e, textId: t }) => e === null || t === null ? [] : [qv(t, e)]));
14182
14287
  if (t.size !== 1) return;
14183
- let n = Bv.get([...t][0]);
14288
+ let n = Yv.get([...t][0]);
14184
14289
  if (n !== void 0) return e.find(({ id: e }) => e === n);
14185
14290
  }
14186
- function Uv(e) {
14291
+ function Qv(e) {
14187
14292
  if (e.length < 2) return;
14188
14293
  let [t, ...n] = [...e].sort((e, t) => t.dateDebut.localeCompare(e.dateDebut));
14189
14294
  if (!n.some(({ dateDebut: e }) => e >= t.dateDebut)) return t;
14190
14295
  }
14191
- async function Wv({ alternatives: e, date: t, legiResolver: n, resolverDiagnostics: r }) {
14296
+ async function $v({ alternatives: e, date: t, legiResolver: n, resolverDiagnostics: r }) {
14192
14297
  let i = [];
14193
14298
  r.alternativeTargetCandidateCount += e.length;
14194
14299
  for (let { num: a, textId: o } of e) {
@@ -14202,7 +14307,7 @@ async function Wv({ alternatives: e, date: t, legiResolver: n, resolverDiagnosti
14202
14307
  }
14203
14308
  return i.length === 1 ? i[0] : [];
14204
14309
  }
14205
- async function Gv({ article: e, date: t, legiResolver: n, resolverDiagnostics: r, state: i }) {
14310
+ async function ey({ article: e, date: t, legiResolver: n, resolverDiagnostics: r, state: i }) {
14206
14311
  if (r.uniqueFallbackCheckCount++, e.present || e.num === void 0) return !1;
14207
14312
  let a = e.implicitText?.cid ?? i.textId;
14208
14313
  return !(a !== void 0 && (r.getActiveArticlesByTextAndNumCount++, (await n.getActiveArticlesByTextAndNum({
@@ -14215,7 +14320,7 @@ async function Gv({ article: e, date: t, legiResolver: n, resolverDiagnostics: r
14215
14320
  textId: i.defaultTextId
14216
14321
  })).length > 0));
14217
14322
  }
14218
- async function* Kv({ ancestors: e, article: t, articleDefinitionByNumByTextId: n, includeInternalArticleLinks: r, legiResolver: i, context: a, date: o, logPartialReferences: c, originalPositionsFromTransformedIterator: l, reference: u, iterationDiagnostics: d, resolverDiagnostics: f, state: p }) {
14323
+ async function* ty({ ancestors: e, article: t, articleDefinitionByNumByTextId: n, includeInternalArticleLinks: r, legiResolver: i, context: a, date: o, logPartialReferences: c, originalPositionsFromTransformedIterator: l, reference: u, iterationDiagnostics: d, resolverDiagnostics: f, state: p }) {
14219
14324
  let m = performance.now();
14220
14325
  if (t.present) {
14221
14326
  $(d, "articleLinkMs", m);
@@ -14255,10 +14360,10 @@ async function* Kv({ ancestors: e, article: t, articleDefinitionByNumByTextId: n
14255
14360
  }), $(d, "articleDirectLookupMs", e), h.length > 0 && (_ = h);
14256
14361
  }
14257
14362
  if (h.length === 0 && t.num !== void 0 && g !== void 0) {
14258
- let e = zv.get(Rv(g, t.num));
14363
+ let e = Jv.get(qv(g, t.num));
14259
14364
  if (e !== void 0) {
14260
14365
  let t = performance.now();
14261
- h = await Wv({
14366
+ h = await $v({
14262
14367
  alternatives: [e],
14263
14368
  date: o,
14264
14369
  legiResolver: i,
@@ -14268,8 +14373,8 @@ async function* Kv({ ancestors: e, article: t, articleDefinitionByNumByTextId: n
14268
14373
  }
14269
14374
  if (h.length === 0 && t.num !== void 0 && g !== void 0) {
14270
14375
  let e = performance.now();
14271
- h = await Wv({
14272
- alternatives: Iv(t.num, g).map((e) => ({
14376
+ h = await $v({
14377
+ alternatives: Gv(t.num, g).map((e) => ({
14273
14378
  num: e,
14274
14379
  textId: g
14275
14380
  })),
@@ -14280,8 +14385,8 @@ async function* Kv({ ancestors: e, article: t, articleDefinitionByNumByTextId: n
14280
14385
  }
14281
14386
  if (h.length === 0 && t.num !== void 0 && g !== void 0) {
14282
14387
  let e = performance.now();
14283
- h = await Wv({
14284
- alternatives: Lv(t.num, g).map((e) => ({
14388
+ h = await $v({
14389
+ alternatives: Kv(t.num, g).map((e) => ({
14285
14390
  num: e,
14286
14391
  textId: g
14287
14392
  })),
@@ -14291,7 +14396,7 @@ async function* Kv({ ancestors: e, article: t, articleDefinitionByNumByTextId: n
14291
14396
  }), $(d, "articleFiscalParentLookupMs", e);
14292
14397
  }
14293
14398
  let v = [];
14294
- if (h.length === 0 && t.num !== void 0 && (v = Vv(t.num, g), v.length > 0 && (h = await Wv({
14399
+ if (h.length === 0 && t.num !== void 0 && (v = Xv(t.num, g), v.length > 0 && (h = await $v({
14295
14400
  alternatives: v,
14296
14401
  date: o,
14297
14402
  legiResolver: i,
@@ -14320,10 +14425,10 @@ async function* Kv({ ancestors: e, article: t, articleDefinitionByNumByTextId: n
14320
14425
  if (n.length === 1) p.articleId = n[0].id;
14321
14426
  else {
14322
14427
  n.length !== 0 && (h = n);
14323
- let e = Hv(h);
14428
+ let e = Zv(h);
14324
14429
  if (e !== void 0) p.articleId = e.id;
14325
14430
  else {
14326
- let e = Uv(h.filter(({ dateDebut: e, dateFin: t }) => e <= o && t > o));
14431
+ let e = Qv(h.filter(({ dateDebut: e, dateFin: t }) => e <= o && t > o));
14327
14432
  e === void 0 ? (n = h.filter(({ id: e }) => !p.textId?.startsWith("JORF") || e.startsWith("JORF")), n.length === 1 ? p.articleId = n[0].id : (n.length !== 0 && (h = n), c && console.warn(`In "${a.input.slice(t.position.start, t.position.stop)}": Unable to filter article ${t.num ?? null} of text ${p.textId ?? null} among IDs ${JSON.stringify(h.map(({ id: e }) => e), null, 2)} for reference ${JSON.stringify(t, null, 2)}`), delete p.articleId)) : p.articleId = e.id;
14328
14433
  }
14329
14434
  }
@@ -14352,7 +14457,7 @@ async function* Kv({ ancestors: e, article: t, articleDefinitionByNumByTextId: n
14352
14457
  });
14353
14458
  $(d, "articleHistoryLookupMs", e), n !== void 0 && (b = n.articleId);
14354
14459
  } else if (_.length === 0 && g !== void 0 && v.length !== 1) {
14355
- let e = [], n = new Set([...Lv(t.num, g), ...Iv(t.num, g)]);
14460
+ let e = [], n = new Set([...Kv(t.num, g), ...Gv(t.num, g)]);
14356
14461
  for (let t of n) {
14357
14462
  f.getActiveArticlesByTextAndNumCount++;
14358
14463
  let n = performance.now(), r = await i.getActiveArticlesByTextAndNum({
@@ -14388,91 +14493,91 @@ async function* Kv({ ancestors: e, article: t, articleDefinitionByNumByTextId: n
14388
14493
  type: "external_article"
14389
14494
  }).filter(([, e]) => e !== void 0)), d.articleExternalLinkCount++, d.articleLinkCount++, $(d, "articleLinkMs", m);
14390
14495
  }
14391
- function* qv(e, { citations: t = !1 } = {}) {
14496
+ function* ny(e, { citations: t = !1 } = {}) {
14392
14497
  switch (e.type) {
14393
14498
  case "article":
14394
14499
  e.num !== void 0 && (yield e.num);
14395
14500
  break;
14396
14501
  case "bounded-interval":
14397
- yield* qv(e.first, { citations: t }), yield* qv(e.last, { citations: t });
14502
+ yield* ny(e.first, { citations: t }), yield* ny(e.last, { citations: t });
14398
14503
  break;
14399
14504
  case "counted-interval":
14400
- yield* qv(e.first, { citations: t });
14505
+ yield* ny(e.first, { citations: t });
14401
14506
  break;
14402
14507
  case "enumeration":
14403
14508
  case "exclusion":
14404
- yield* qv(e.left, { citations: t }), yield* qv(e.right, { citations: t });
14509
+ yield* ny(e.left, { citations: t }), yield* ny(e.right, { citations: t });
14405
14510
  break;
14406
14511
  case "parent-enfant":
14407
- yield* qv(e.parent, { citations: t }), yield* qv(e.child, { citations: t });
14512
+ yield* ny(e.parent, { citations: t }), yield* ny(e.child, { citations: t });
14408
14513
  break;
14409
14514
  case "reference_et_action":
14410
- if (yield* qv(e.reference, { citations: t }), t) {
14515
+ if (yield* ny(e.reference, { citations: t }), t) {
14411
14516
  let { originalCitations: n } = e.action;
14412
14517
  if (n !== void 0) {
14413
- for (let e of n) if (e.references !== void 0) for (let n of e.references) yield* qv(n, { citations: t });
14518
+ for (let e of n) if (e.references !== void 0) for (let n of e.references) yield* ny(n, { citations: t });
14414
14519
  }
14415
14520
  }
14416
14521
  break;
14417
14522
  }
14418
14523
  }
14419
- function* Jv(e, t, { citations: n = !1 } = {}) {
14524
+ function* ry(e, t, { citations: n = !1 } = {}) {
14420
14525
  switch (t.type) {
14421
14526
  case "bounded-interval":
14422
- yield* Jv(e, t.first, { citations: n }), yield* Jv(e, t.last, { citations: n });
14527
+ yield* ry(e, t.first, { citations: n }), yield* ry(e, t.last, { citations: n });
14423
14528
  break;
14424
14529
  case "counted-interval":
14425
- yield* Jv(e, t.first, { citations: n });
14530
+ yield* ry(e, t.first, { citations: n });
14426
14531
  break;
14427
14532
  case "enumeration":
14428
14533
  case "exclusion":
14429
- yield* Jv(e, t.left, { citations: n }), yield* Jv(e, t.right, { citations: n });
14534
+ yield* ry(e, t.left, { citations: n }), yield* ry(e, t.right, { citations: n });
14430
14535
  break;
14431
14536
  case "reference_et_action":
14432
- if (yield* Jv(e, t.reference, { citations: n }), n) {
14537
+ if (yield* ry(e, t.reference, { citations: n }), n) {
14433
14538
  let { originalCitations: r } = t.action;
14434
14539
  if (r !== void 0) {
14435
- for (let t of r) if (t.references !== void 0) for (let r of t.references) yield* Jv(e, r, { citations: n });
14540
+ for (let t of r) if (t.references !== void 0) for (let r of t.references) yield* ry(e, r, { citations: n });
14436
14541
  }
14437
14542
  }
14438
14543
  break;
14439
14544
  default: yield t;
14440
14545
  }
14441
14546
  }
14442
- function* Yv(e, t) {
14547
+ function* iy(e, t) {
14443
14548
  if (t.type === "texte") console.error(`iterDeepestDivisionsOrArticles must not be called with a text:\n${JSON.stringify(t, null, 2)}`);
14444
14549
  else if (ut(t) || t.type === "article") yield t;
14445
14550
  else if (!(dt(t) || t.type === "incomplete-header")) switch (t.type) {
14446
14551
  case "bounded-interval":
14447
- yield* Yv(e, t.first), yield* Yv(e, t.last);
14552
+ yield* iy(e, t.first), yield* iy(e, t.last);
14448
14553
  break;
14449
14554
  case "counted-interval":
14450
- yield* Yv(e, t.first);
14555
+ yield* iy(e, t.first);
14451
14556
  break;
14452
14557
  case "enumeration":
14453
14558
  case "exclusion":
14454
- yield* Yv(e, t.left), yield* Yv(e, t.right);
14559
+ yield* iy(e, t.left), yield* iy(e, t.right);
14455
14560
  break;
14456
14561
  case "parent-enfant": {
14457
- let n = [...Yv(e, t.child)];
14458
- n.length === 0 ? yield* Yv(e, t.parent) : yield* n;
14562
+ let n = [...iy(e, t.child)];
14563
+ n.length === 0 ? yield* iy(e, t.parent) : yield* n;
14459
14564
  break;
14460
14565
  }
14461
14566
  case "reference_et_action": {
14462
- yield* Yv(e, t.reference);
14567
+ yield* iy(e, t.reference);
14463
14568
  let { originalCitations: n } = t.action;
14464
14569
  if (n !== void 0) {
14465
- for (let t of n) if (t.references !== void 0) for (let n of t.references) yield* Yv(e, n);
14570
+ for (let t of n) if (t.references !== void 0) for (let n of t.references) yield* iy(e, n);
14466
14571
  }
14467
14572
  break;
14468
14573
  }
14469
14574
  default: m("iterDeepestDivisionsOrArticles reference.type", t);
14470
14575
  }
14471
14576
  }
14472
- function Xv(e) {
14577
+ function ay(e) {
14473
14578
  return e?.split(":")[0].trim().toLowerCase().split(/\s+/).map((e) => e.trim()).filter((e) => e !== "").join(" ");
14474
14579
  }
14475
- async function* Zv({ ancestors: e, articleDefinitionByNumByTextId: t, includeInternalArticleLinks: n, legiResolver: r, context: i, date: a, division: o, divisionChildReference: c, logIgnoredReferencesTypes: l, logPartialReferences: u, originalPositionsFromTransformedIterator: d, parentSectionChildren: f, reference: p, iterationDiagnostics: m, resolverDiagnostics: h, state: g }) {
14580
+ async function* oy({ ancestors: e, articleDefinitionByNumByTextId: t, includeInternalArticleLinks: n, legiResolver: r, context: i, date: a, division: o, divisionChildReference: c, logIgnoredReferencesTypes: l, logPartialReferences: u, originalPositionsFromTransformedIterator: d, parentSectionChildren: f, reference: p, iterationDiagnostics: m, resolverDiagnostics: h, state: g }) {
14476
14581
  let _ = performance.now();
14477
14582
  if (o.present) {
14478
14583
  $(m, "divisionLinkMs", _);
@@ -14489,20 +14594,20 @@ async function* Zv({ ancestors: e, articleDefinitionByNumByTextId: t, includeInt
14489
14594
  }
14490
14595
  if (f !== void 0) {
14491
14596
  for (let e of f) {
14492
- let t = Xv(e.title);
14597
+ let t = ay(e.title);
14493
14598
  if (t !== void 0) {
14494
14599
  let n = !1;
14495
- if (o.index !== void 0 && (n = Qv(o.type, o.index).some((e) => e === t)), !n && o.num !== void 0 && (n = `${o.type} ${o.num.toLowerCase()}` === t), n) {
14600
+ if (o.index !== void 0 && (n = sy(o.type, o.index).some((e) => e === t)), !n && o.num !== void 0 && (n = `${o.type} ${o.num.toLowerCase()}` === t), n) {
14496
14601
  v = e;
14497
14602
  break;
14498
14603
  }
14499
14604
  }
14500
14605
  }
14501
14606
  if (v === void 0 && (v = f.find((e) => {
14502
- let t = Xv(e.title)?.split(/\s+/);
14607
+ let t = ay(e.title)?.split(/\s+/);
14503
14608
  return t !== void 0 && t.length === 2 && at.includes(t[0]) && t[1] === "législative";
14504
14609
  }), v !== void 0)) {
14505
- let e = Xv(v.title).split(/\s+/), t = {
14610
+ let e = ay(v.title).split(/\s+/), t = {
14506
14611
  start: o.position.stop,
14507
14612
  stop: o.position.stop
14508
14613
  }, n = d === void 0 ? void 0 : s(d, t), r = Object.fromEntries(Object.entries({
@@ -14520,8 +14625,8 @@ async function* Zv({ ancestors: e, articleDefinitionByNumByTextId: t, includeInt
14520
14625
  }).filter(([, e]) => e !== void 0)), o = r;
14521
14626
  }
14522
14627
  }
14523
- let y = c === void 0 ? [] : [...Yv(i, c.child)], b = 0;
14524
- if (c !== void 0) for (let s of Jv(i, c.child)) {
14628
+ let y = c === void 0 ? [] : [...iy(i, c.child)], b = 0;
14629
+ if (c !== void 0) for (let s of ry(i, c.child)) {
14525
14630
  let f = s.type === "parent-enfant" ? s.parent : s, _ = s.type === "parent-enfant" ? s : void 0;
14526
14631
  switch (f.type) {
14527
14632
  case "alinéa":
@@ -14530,7 +14635,7 @@ async function* Zv({ ancestors: e, articleDefinitionByNumByTextId: t, includeInt
14530
14635
  case "phrase": break;
14531
14636
  case "article": {
14532
14637
  let s = performance.now();
14533
- for await (let s of Kv({
14638
+ for await (let s of ty({
14534
14639
  ancestors: y.length === 1 ? [...e ?? [], o] : void 0,
14535
14640
  article: f,
14536
14641
  articleDefinitionByNumByTextId: t,
@@ -14568,7 +14673,7 @@ async function* Zv({ ancestors: e, articleDefinitionByNumByTextId: t, includeInt
14568
14673
  }), $(m, "divisionDirectChildrenLookupMs", e);
14569
14674
  }
14570
14675
  let c = performance.now();
14571
- for await (let c of Zv({
14676
+ for await (let c of oy({
14572
14677
  ancestors: y.length === 1 ? [...e ?? [], o] : void 0,
14573
14678
  articleDefinitionByNumByTextId: t,
14574
14679
  includeInternalArticleLinks: n,
@@ -14612,7 +14717,7 @@ async function* Zv({ ancestors: e, articleDefinitionByNumByTextId: t, includeInt
14612
14717
  }
14613
14718
  $(m, "divisionLinkMs", _);
14614
14719
  }
14615
- function* Qv(e, t) {
14720
+ function* sy(e, t) {
14616
14721
  let n = Math.floor(t), i = Math.floor((t - n) * 1e3);
14617
14722
  if (i === 0) {
14618
14723
  for (let t of r(n)) yield `${t.toLowerCase()} ${e}`;
@@ -14622,9 +14727,9 @@ function* Qv(e, t) {
14622
14727
  for (let r of te(n)) yield `${e} ${t} ${r.toLowerCase()}`;
14623
14728
  }
14624
14729
  }
14625
- async function* $v({ articleDefinitionByNumByTextId: e, includeInternalArticleLinks: t = !1, legiResolver: n, context: r, date: i, logIgnoredReferencesTypes: a, logPartialReferences: o, originalPositionsFromTransformedIterator: c, reference: l, iterationDiagnostics: u, resolverDiagnostics: d, state: f }) {
14626
- let p = e ?? {}, m = d ?? xv(), h = u ?? bv(), g = f === void 0 ? {} : f;
14627
- for (let e of Jv(r, l)) {
14730
+ async function* cy({ articleDefinitionByNumByTextId: e, includeInternalArticleLinks: t = !1, legiResolver: n, context: r, date: i, logIgnoredReferencesTypes: a, logPartialReferences: o, originalPositionsFromTransformedIterator: c, reference: l, iterationDiagnostics: u, resolverDiagnostics: d, state: f }) {
14731
+ let p = e ?? {}, m = d ?? Av(), h = u ?? kv(), g = f === void 0 ? {} : f;
14732
+ for (let e of ry(r, l)) {
14628
14733
  let u = e.type === "parent-enfant" ? e.parent : e, d = e.type === "parent-enfant" ? e : void 0;
14629
14734
  switch (u.type) {
14630
14735
  case "alinéa":
@@ -14635,7 +14740,7 @@ async function* $v({ articleDefinitionByNumByTextId: e, includeInternalArticleLi
14635
14740
  if (u.definition && g.textId !== void 0) {
14636
14741
  let e = p[g.textId]?.[u.num];
14637
14742
  e !== void 0 && (e.originalTransformation === void 0 && c !== void 0 && (e.originalTransformation = s(c, e.position)), yield e, h.articleDefinitionLinkCount++, h.articleLinkCount++);
14638
- } else for await (let e of Kv({
14743
+ } else for await (let e of ty({
14639
14744
  article: u,
14640
14745
  articleDefinitionByNumByTextId: p,
14641
14746
  includeInternalArticleLinks: t,
@@ -14660,7 +14765,7 @@ async function* $v({ articleDefinitionByNumByTextId: e, includeInternalArticleLi
14660
14765
  case "sous-sous-paragraphe":
14661
14766
  case "sous-titre":
14662
14767
  case "titre":
14663
- if (!(u.definition && g.textId !== void 0)) for await (let e of Zv({
14768
+ if (!(u.definition && g.textId !== void 0)) for await (let e of oy({
14664
14769
  articleDefinitionByNumByTextId: p,
14665
14770
  includeInternalArticleLinks: t,
14666
14771
  legiResolver: n,
@@ -14679,15 +14784,15 @@ async function* $v({ articleDefinitionByNumByTextId: e, includeInternalArticleLi
14679
14784
  break;
14680
14785
  case "texte": {
14681
14786
  let e = performance.now();
14682
- Ov({
14787
+ Lv({
14683
14788
  context: r,
14684
14789
  logPartialReferences: o,
14685
14790
  reference: l,
14686
14791
  state: g,
14687
14792
  text: u
14688
14793
  });
14689
- let f = d === void 0 ? [] : [...Yv(r, d.child)], _ = 0;
14690
- if (d !== void 0) for (let e of Jv(r, d.child)) {
14794
+ let f = d === void 0 ? [] : [...iy(r, d.child)], _ = 0;
14795
+ if (d !== void 0) for (let e of ry(r, d.child)) {
14691
14796
  let s = e.type === "parent-enfant" ? e.parent : e, v = e.type === "parent-enfant" ? e : void 0;
14692
14797
  switch (s.type) {
14693
14798
  case "alinéa":
@@ -14696,7 +14801,7 @@ async function* $v({ articleDefinitionByNumByTextId: e, includeInternalArticleLi
14696
14801
  case "phrase": break;
14697
14802
  case "article": {
14698
14803
  let e = performance.now();
14699
- for await (let e of Kv({
14804
+ for await (let e of ty({
14700
14805
  ancestors: f.length === 1 ? [u] : void 0,
14701
14806
  article: s,
14702
14807
  articleDefinitionByNumByTextId: p,
@@ -14734,7 +14839,7 @@ async function* $v({ articleDefinitionByNumByTextId: e, includeInternalArticleLi
14734
14839
  }), $(h, "divisionDirectChildrenLookupMs", t);
14735
14840
  }
14736
14841
  let d = performance.now();
14737
- for await (let d of Zv({
14842
+ for await (let d of oy({
14738
14843
  ancestors: f.length === 1 ? [u] : void 0,
14739
14844
  articleDefinitionByNumByTextId: p,
14740
14845
  includeInternalArticleLinks: t,
@@ -14796,7 +14901,7 @@ async function* $v({ articleDefinitionByNumByTextId: e, includeInternalArticleLi
14796
14901
  for (let l of s.references) {
14797
14902
  h.citationReferenceCount++;
14798
14903
  let s = performance.now();
14799
- for await (let s of $v({
14904
+ for await (let s of cy({
14800
14905
  articleDefinitionByNumByTextId: p,
14801
14906
  includeInternalArticleLinks: t,
14802
14907
  legiResolver: n,
@@ -14818,13 +14923,13 @@ async function* $v({ articleDefinitionByNumByTextId: e, includeInternalArticleLi
14818
14923
  }
14819
14924
  //#endregion
14820
14925
  //#region src/lib/extractors/table_of_contents.ts
14821
- function ey(e) {
14926
+ function ly(e) {
14822
14927
  let t = e;
14823
14928
  return t.items ?? [...t.articles ?? [], ...t.divisions ?? []];
14824
14929
  }
14825
- function* ty({ context: e, tableOfContents: t, transformation: n }) {
14930
+ function* uy({ context: e, tableOfContents: t, transformation: n }) {
14826
14931
  let r = 0, i = g(n);
14827
- for (let n of ry(t)) {
14932
+ for (let n of fy(t)) {
14828
14933
  let t = n.line.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), a = RegExp(`^${t}$`, "m");
14829
14934
  a.lastIndex = r;
14830
14935
  let o = a.exec(e.input);
@@ -14836,7 +14941,7 @@ function* ty({ context: e, tableOfContents: t, transformation: n }) {
14836
14941
  u.originalTransformation = l, u.position = c, yield u, r = c.stop;
14837
14942
  }
14838
14943
  }
14839
- function ny(e) {
14944
+ function dy(e) {
14840
14945
  let t = new S(e), n = { items: [] }, r = [];
14841
14946
  for (let e of wn(t)) if (ut(e)) {
14842
14947
  let i = r.findIndex(({ type: t }) => t === e.type);
@@ -14854,20 +14959,20 @@ function ny(e) {
14854
14959
  else throw Error(`Unexpected type "${e.type}" in definition:\n${JSON.stringify(e, null, 2)}`);
14855
14960
  return n;
14856
14961
  }
14857
- function* ry(e) {
14962
+ function* fy(e) {
14858
14963
  e.type !== void 0 && (yield e);
14859
- for (let t of ey(e)) t.type === "article" ? yield t : yield* ry(t);
14964
+ for (let t of ly(e)) t.type === "article" ? yield t : yield* fy(t);
14860
14965
  }
14861
14966
  //#endregion
14862
14967
  //#region src/lib/links.ts
14863
- var iy = ["Exploratrice", "Forgejo"];
14864
- function ay(e) {
14968
+ var py = ["Exploratrice", "Forgejo"];
14969
+ function my(e) {
14865
14970
  let t = /^articles?\s+(?:n°\s*)?((?:1er|\d+)(?:\s+(?:bis|ter|quater|quinquies|septies))?(?:[-.·\s]\d+)*)\s+(?:du|de\s+la|de\s+l'|des|au|à)\b/iu.exec(e);
14866
14971
  if (t === null) return;
14867
14972
  let n = t[1].replace(/^(\d+)er\b/iu, "$1").replace(/[.·\s]/gu, "-").replace(/-{2,}/gu, "-").replace(/^-|-$/gu, "");
14868
14973
  return /^\d+(?:-\d+)*(?:-(?:bis|ter|quater|quinquies|septies))?$/iu.test(n) ? n : void 0;
14869
14974
  }
14870
- function oy(e, t, n) {
14975
+ function hy(e, t, n) {
14871
14976
  if (n.match(Ge) === null) throw Error(`Unknown ID format: ${n}`);
14872
14977
  switch (e) {
14873
14978
  case "Exploratrice": return new URL(`legifrance/articles/${n}/versions`, t).toString();
@@ -14875,7 +14980,7 @@ function oy(e, t, n) {
14875
14980
  default: m("urlFromArticleVersionsId linkType", e);
14876
14981
  }
14877
14982
  }
14878
- function sy(e, t, n) {
14983
+ function gy(e, t, n) {
14879
14984
  let r = n.match(Ge);
14880
14985
  if (r === null) throw Error(`Unknown ID format: ${n}`);
14881
14986
  switch (e) {
@@ -14896,19 +15001,19 @@ function sy(e, t, n) {
14896
15001
  }
14897
15002
  //#endregion
14898
15003
  //#region src/lib/linkers/html.ts
14899
- function cy(e, t) {
15004
+ function _y(e, t) {
14900
15005
  if (e !== void 0) return e;
14901
- if (t !== void 0) return new vv(t);
15006
+ if (t !== void 0) return new Dv(t);
14902
15007
  throw Error("A Canutes database or legal resolver is required");
14903
15008
  }
14904
- function ly(e, t) {
15009
+ function vy(e, t) {
14905
15010
  return t.type === "reference_et_action" ? JSON.stringify({
14906
15011
  ...e,
14907
15012
  action: t.action
14908
15013
  }) : JSON.stringify(e);
14909
15014
  }
14910
- async function uy({ canutesDb: e, includeInternalArticleLinks: t = !1, legiResolver: n, date: r, html: i, linkBaseUrl: a, linkType: o, logIgnoredReferencesTypes: s, logPartialReferences: c, logReferences: l, onLink: u, previousContext: d, state: f }) {
14911
- let p = new we("addLinksToHtml"), h = cy(n, e);
15015
+ async function yy({ canutesDb: e, includeInternalArticleLinks: t = !1, legiResolver: n, date: r, html: i, linkBaseUrl: a, linkType: o, logIgnoredReferencesTypes: s, logPartialReferences: c, logReferences: l, onLink: u, previousContext: d, state: f }) {
15016
+ let p = new we("addLinksToHtml"), h = _y(n, e);
14912
15017
  await p.time("preloadTextTitlesInfos", () => h.preloadTextTitlesInfos());
14913
15018
  let g = p.timeSync("simplifyHtml", () => v({ removeAWithHref: !0 })(i), {
14914
15019
  inputSize: i.length,
@@ -14917,7 +15022,7 @@ async function uy({ canutesDb: e, includeInternalArticleLinks: t = !1, legiResol
14917
15022
  _.currentArticle = d?.currentArticle, _.currentText = d?.currentText;
14918
15023
  let y = [], b = { value: 0 }, x = -1;
14919
15024
  await p.time("extractTextLinks", async () => {
14920
- for await (let e of Dv({
15025
+ for await (let e of Iv({
14921
15026
  includeInternalArticleLinks: t,
14922
15027
  legiResolver: h,
14923
15028
  context: _,
@@ -14931,7 +15036,7 @@ async function uy({ canutesDb: e, includeInternalArticleLinks: t = !1, legiResol
14931
15036
  case "article_definition": {
14932
15037
  let { article: t, originalTransformation: n, textId: r } = e;
14933
15038
  if (n === void 0) throw Error(`Missing originalTransformation attribute in article definition: ${JSON.stringify(e, null, 2)}`);
14934
- fy({
15039
+ xy({
14935
15040
  inputHtml: i,
14936
15041
  originalTransformation: n,
14937
15042
  output: { replacements: y },
@@ -14944,10 +15049,10 @@ async function uy({ canutesDb: e, includeInternalArticleLinks: t = !1, legiResol
14944
15049
  let { articleId: t, historyArticleId: n, originalTransformation: r } = e;
14945
15050
  if (t === void 0 && n === void 0) break;
14946
15051
  if (r === void 0) throw Error(`Missing originalTransformation attribute in external article link: ${JSON.stringify(e, null, 2)}`);
14947
- let s = t === void 0 ? oy(o, a, n) : sy(o, a, t);
15052
+ let s = t === void 0 ? hy(o, a, n) : gy(o, a, t);
14948
15053
  if (s === void 0) break;
14949
15054
  let c = t === void 0 ? `class="lien_article_historique" href="${s}" title="Versions de l'article"` : `class="lien_article_externe" href="${s}"`;
14950
- fy({
15055
+ xy({
14951
15056
  inputHtml: i,
14952
15057
  originalTransformation: r,
14953
15058
  output: { replacements: y },
@@ -14960,12 +15065,12 @@ async function uy({ canutesDb: e, includeInternalArticleLinks: t = !1, legiResol
14960
15065
  let { originalTransformation: t, sectionTaId: n } = e;
14961
15066
  if (n !== void 0) {
14962
15067
  if (t === void 0) throw Error(`Missing originalTransformation attribute in external division link: ${JSON.stringify(e, null, 2)}`);
14963
- fy({
15068
+ xy({
14964
15069
  inputHtml: i,
14965
15070
  originalTransformation: t,
14966
15071
  output: { replacements: y },
14967
15072
  replacementCounter: b,
14968
- tagHtmlFromOriginal: (e) => `<a class="lien_division_externe" href="${sy(o, a, n)}">${e}</a>`
15073
+ tagHtmlFromOriginal: (e) => `<a class="lien_division_externe" href="${gy(o, a, n)}">${e}</a>`
14969
15074
  });
14970
15075
  }
14971
15076
  break;
@@ -14977,7 +15082,7 @@ async function uy({ canutesDb: e, includeInternalArticleLinks: t = !1, legiResol
14977
15082
  continue;
14978
15083
  }
14979
15084
  if (t === void 0) throw Error(`Missing originalTransformation attribute in external text link: ${JSON.stringify(e, null, 2)}`);
14980
- let s = ay(_.text(n.position)), l, u;
15085
+ let s = my(_.text(n.position)), l, u;
14981
15086
  if (s !== void 0) {
14982
15087
  let e = await h.getActiveArticlesByTextAndNum({
14983
15088
  date: r,
@@ -14994,17 +15099,17 @@ async function uy({ canutesDb: e, includeInternalArticleLinks: t = !1, legiResol
14994
15099
  }
14995
15100
  }
14996
15101
  if (l === void 0 && u === void 0) {
14997
- fy({
15102
+ xy({
14998
15103
  inputHtml: i,
14999
15104
  originalTransformation: t,
15000
15105
  output: { replacements: y },
15001
15106
  replacementCounter: b,
15002
- tagHtmlFromOriginal: (e) => `<a class="lien_texte_externe" href="${sy(o, a, n.cid)}">${e}</a>`
15107
+ tagHtmlFromOriginal: (e) => `<a class="lien_texte_externe" href="${gy(o, a, n.cid)}">${e}</a>`
15003
15108
  });
15004
15109
  break;
15005
15110
  }
15006
- let d = l ?? u, f = l === void 0 ? `class="lien_article_historique" href="${oy(o, a, d)}" title="Versions de l'article"` : `class="lien_article_externe" href="${sy(o, a, d)}"`;
15007
- fy({
15111
+ let d = l ?? u, f = l === void 0 ? `class="lien_article_historique" href="${hy(o, a, d)}" title="Versions de l'article"` : `class="lien_article_externe" href="${gy(o, a, d)}"`;
15112
+ xy({
15008
15113
  inputHtml: i,
15009
15114
  originalTransformation: t,
15010
15115
  output: { replacements: y },
@@ -15017,7 +15122,7 @@ async function uy({ canutesDb: e, includeInternalArticleLinks: t = !1, legiResol
15017
15122
  let { url: t, originalTransformation: n } = e;
15018
15123
  if (t === void 0) continue;
15019
15124
  if (n === void 0) throw Error(`Missing originalTransformation attribute in european text link: ${JSON.stringify(e, null, 2)}`);
15020
- fy({
15125
+ xy({
15021
15126
  inputHtml: i,
15022
15127
  originalTransformation: n,
15023
15128
  output: { replacements: y },
@@ -15029,7 +15134,7 @@ async function uy({ canutesDb: e, includeInternalArticleLinks: t = !1, legiResol
15029
15134
  case "internal_article": {
15030
15135
  let { definition: t, originalTransformation: n } = e;
15031
15136
  if (n === void 0) throw Error(`Missing originalTransformation attribute in internal article link: ${JSON.stringify(e, null, 2)}`);
15032
- fy({
15137
+ xy({
15033
15138
  inputHtml: i,
15034
15139
  originalTransformation: n,
15035
15140
  output: { replacements: y },
@@ -15041,7 +15146,7 @@ async function uy({ canutesDb: e, includeInternalArticleLinks: t = !1, legiResol
15041
15146
  default: m("Link", e);
15042
15147
  }
15043
15148
  }, { count: x + 1 });
15044
- let ee = p.timeSync("applyHtmlReplacements", () => dy(i, y), {
15149
+ let ee = p.timeSync("applyHtmlReplacements", () => by(i, y), {
15045
15150
  count: y.length,
15046
15151
  inputSize: i.length
15047
15152
  });
@@ -15053,13 +15158,13 @@ async function uy({ canutesDb: e, includeInternalArticleLinks: t = !1, legiResol
15053
15158
  output: y.length === 0 ? null : ee
15054
15159
  };
15055
15160
  }
15056
- function dy(e, t) {
15161
+ function by(e, t) {
15057
15162
  if (t.length === 0) return e;
15058
15163
  let n = [], r = 0;
15059
15164
  for (let i of t.toSorted((e, t) => e.start - t.start || e.stop - t.stop || e.order - t.order)) i.start < r || (n.push(e.slice(r, i.start)), n.push(i.replacement), r = i.stop);
15060
15165
  return n.push(e.slice(r)), n.join("");
15061
15166
  }
15062
- function fy({ inputHtml: e, originalTransformation: t, output: n, replacementCounter: r, tagHtmlFromOriginal: i }) {
15167
+ function xy({ inputHtml: e, originalTransformation: t, output: n, replacementCounter: r, tagHtmlFromOriginal: i }) {
15063
15168
  let a = ee(t, i(p(e, t, 0) ?? ""));
15064
15169
  n.replacements.push({
15065
15170
  order: r.value++,
@@ -15068,11 +15173,11 @@ function fy({ inputHtml: e, originalTransformation: t, output: n, replacementCou
15068
15173
  stop: t.position.stop
15069
15174
  });
15070
15175
  }
15071
- function py({ attributes: e, inputHtml: t, originalTransformation: n, outputByType: r, replacementCounter: i }) {
15176
+ function Sy({ attributes: e, inputHtml: t, originalTransformation: n, outputByType: r, replacementCounter: i }) {
15072
15177
  let a = Object.entries(e).map(([e, t]) => `${e}="${$e(t, !0)}"`).join(" ");
15073
15178
  for (let e of ["links", "links_or_references"]) {
15074
15179
  let o = r[e];
15075
- o !== void 0 && fy({
15180
+ o !== void 0 && xy({
15076
15181
  inputHtml: t,
15077
15182
  originalTransformation: n,
15078
15183
  output: o,
@@ -15081,11 +15186,11 @@ function py({ attributes: e, inputHtml: t, originalTransformation: n, outputByTy
15081
15186
  });
15082
15187
  }
15083
15188
  }
15084
- function my({ id: e, outputByType: t }) {
15189
+ function Cy({ id: e, outputByType: t }) {
15085
15190
  return t.references !== void 0 || e === void 0 && t.links_or_references !== void 0;
15086
15191
  }
15087
- async function hy({ canutesDb: e, legiResolver: t, date: n, defaultTextId: r, htmlTransformation: i, inputHtml: a, linkBaseUrl: o, linkType: s, logIgnoredReferencesTypes: c, logPartialReferences: l, logReferences: u, outputTypes: d, referredLegifranceTextsInfos: f }) {
15088
- let p = cy(t, e);
15192
+ async function wy({ canutesDb: e, legiResolver: t, date: n, defaultTextId: r, htmlTransformation: i, inputHtml: a, linkBaseUrl: o, linkType: s, logIgnoredReferencesTypes: c, logPartialReferences: l, logReferences: u, outputTypes: d, referredLegifranceTextsInfos: f }) {
15193
+ let p = _y(t, e);
15089
15194
  await p.preloadTextTitlesInfos();
15090
15195
  let h = new S(i.output), g = {}, _ = {};
15091
15196
  for (let e of d) _[e] = {
@@ -15094,7 +15199,7 @@ async function hy({ canutesDb: e, legiResolver: t, date: n, defaultTextId: r, ht
15094
15199
  replacements: []
15095
15200
  };
15096
15201
  let v = { value: 0 };
15097
- for await (let e of Dv({
15202
+ for await (let e of Iv({
15098
15203
  legiResolver: p,
15099
15204
  context: h,
15100
15205
  date: n,
@@ -15107,7 +15212,7 @@ async function hy({ canutesDb: e, legiResolver: t, date: n, defaultTextId: r, ht
15107
15212
  case "article_definition": {
15108
15213
  let { article: t, originalTransformation: n, textId: r } = e;
15109
15214
  if (n === void 0) throw Error(`Missing originalTransformation attribute in article definition: ${JSON.stringify(e, null, 2)}`);
15110
- for (let e of Object.values(_)) fy({
15215
+ for (let e of Object.values(_)) xy({
15111
15216
  inputHtml: a,
15112
15217
  originalTransformation: n,
15113
15218
  output: e,
@@ -15120,10 +15225,10 @@ async function hy({ canutesDb: e, legiResolver: t, date: n, defaultTextId: r, ht
15120
15225
  let { article: t, articleId: n, historyArticleId: r, originalTransformation: i } = e;
15121
15226
  if (i === void 0) throw Error(`Missing originalTransformation attribute in external article link: ${JSON.stringify(e, null, 2)}`);
15122
15227
  if (n !== void 0) {
15123
- if (py({
15228
+ if (Sy({
15124
15229
  attributes: {
15125
15230
  class: "lien_article_externe",
15126
- href: sy(s, o, n)
15231
+ href: gy(s, o, n)
15127
15232
  },
15128
15233
  inputHtml: a,
15129
15234
  originalTransformation: i,
@@ -15134,8 +15239,8 @@ async function hy({ canutesDb: e, legiResolver: t, date: n, defaultTextId: r, ht
15134
15239
  e != null && (g[e] = (g[e] ?? 0) + 1);
15135
15240
  }
15136
15241
  } else if (r !== void 0) {
15137
- let e = oy(s, o, r);
15138
- e !== void 0 && py({
15242
+ let e = hy(s, o, r);
15243
+ e !== void 0 && Sy({
15139
15244
  attributes: {
15140
15245
  class: "lien_article_historique",
15141
15246
  href: e,
@@ -15147,14 +15252,14 @@ async function hy({ canutesDb: e, legiResolver: t, date: n, defaultTextId: r, ht
15147
15252
  replacementCounter: v
15148
15253
  });
15149
15254
  }
15150
- my({
15255
+ Cy({
15151
15256
  id: n,
15152
15257
  outputByType: _
15153
- }) && gy({
15258
+ }) && Ty({
15154
15259
  attributes: {
15155
15260
  class: "reference_article",
15156
15261
  style: "background-color: #eae462",
15157
- title: ly(t, e.reference)
15262
+ title: vy(t, e.reference)
15158
15263
  },
15159
15264
  id: n,
15160
15265
  inputHtml: a,
@@ -15167,10 +15272,10 @@ async function hy({ canutesDb: e, legiResolver: t, date: n, defaultTextId: r, ht
15167
15272
  case "external_division": {
15168
15273
  let { division: t, originalTransformation: n, sectionTaId: r } = e;
15169
15274
  if (n === void 0) throw Error(`Missing originalTransformation attribute in external division link: ${JSON.stringify(e, null, 2)}`);
15170
- if (r !== void 0 && (py({
15275
+ if (r !== void 0 && (Sy({
15171
15276
  attributes: {
15172
15277
  class: "lien_division_externe",
15173
- href: sy(s, o, r)
15278
+ href: gy(s, o, r)
15174
15279
  },
15175
15280
  inputHtml: a,
15176
15281
  originalTransformation: n,
@@ -15180,14 +15285,14 @@ async function hy({ canutesDb: e, legiResolver: t, date: n, defaultTextId: r, ht
15180
15285
  let e = await p.getTextIdFromSegmentId(r);
15181
15286
  e != null && (g[e] = (g[e] ?? 0) + 1);
15182
15287
  }
15183
- my({
15288
+ Cy({
15184
15289
  id: r,
15185
15290
  outputByType: _
15186
- }) && gy({
15291
+ }) && Ty({
15187
15292
  attributes: {
15188
15293
  class: "reference_division",
15189
15294
  style: "background-color: #eae462",
15190
- title: ly(t, e.reference)
15295
+ title: vy(t, e.reference)
15191
15296
  },
15192
15297
  id: r,
15193
15298
  inputHtml: a,
@@ -15200,7 +15305,7 @@ async function hy({ canutesDb: e, legiResolver: t, date: n, defaultTextId: r, ht
15200
15305
  case "european_text": {
15201
15306
  let { url: t, originalTransformation: n, text: r, titleId: i } = e;
15202
15307
  if (n === void 0) throw Error(`Missing originalTransformation attribute in external text link: ${JSON.stringify(e, null, 2)}`);
15203
- py({
15308
+ Sy({
15204
15309
  attributes: {
15205
15310
  class: "lien_texte_european",
15206
15311
  href: t,
@@ -15210,14 +15315,14 @@ async function hy({ canutesDb: e, legiResolver: t, date: n, defaultTextId: r, ht
15210
15315
  originalTransformation: n,
15211
15316
  outputByType: _,
15212
15317
  replacementCounter: v
15213
- }), my({
15318
+ }), Cy({
15214
15319
  id: i,
15215
15320
  outputByType: _
15216
- }) && gy({
15321
+ }) && Ty({
15217
15322
  attributes: {
15218
15323
  class: "reference_texte",
15219
15324
  style: "background-color: #eae462",
15220
- title: ly(r, e.reference)
15325
+ title: vy(r, e.reference)
15221
15326
  },
15222
15327
  id: i,
15223
15328
  inputHtml: a,
@@ -15232,7 +15337,7 @@ async function hy({ canutesDb: e, legiResolver: t, date: n, defaultTextId: r, ht
15232
15337
  if (t === void 0) throw Error(`Missing originalTransformation attribute in external text link: ${JSON.stringify(e, null, 2)}`);
15233
15338
  if (r.cid === void 0) !r.present && l && console.error(`Link to text "${h.text(r.position)}" without CID: ${JSON.stringify(r, null, 2)}`);
15234
15339
  else {
15235
- let e = ay(h.text(r.position)), i;
15340
+ let e = my(h.text(r.position)), i;
15236
15341
  if (e !== void 0) {
15237
15342
  let t = await p.getActiveArticlesByTextAndNum({
15238
15343
  date: n,
@@ -15241,13 +15346,13 @@ async function hy({ canutesDb: e, legiResolver: t, date: n, defaultTextId: r, ht
15241
15346
  }), a = t.filter(({ dateDebut: e, dateFin: t }) => e <= n && t > n);
15242
15347
  if (a.length === 1) i = {
15243
15348
  class: "lien_article_externe",
15244
- href: sy(s, o, a[0].id)
15349
+ href: gy(s, o, a[0].id)
15245
15350
  };
15246
15351
  else if (t.length > 0) {
15247
15352
  let t = await p.getArticleHistoryInfo({
15248
15353
  num: e,
15249
15354
  textId: r.cid
15250
- }), n = t === void 0 ? void 0 : oy(s, o, t.articleId);
15355
+ }), n = t === void 0 ? void 0 : hy(s, o, t.articleId);
15251
15356
  n !== void 0 && (i = {
15252
15357
  class: "lien_article_historique",
15253
15358
  href: n,
@@ -15255,10 +15360,10 @@ async function hy({ canutesDb: e, legiResolver: t, date: n, defaultTextId: r, ht
15255
15360
  });
15256
15361
  }
15257
15362
  }
15258
- py({
15363
+ Sy({
15259
15364
  attributes: i ?? {
15260
15365
  class: "lien_texte_externe",
15261
- href: sy(s, o, r.cid)
15366
+ href: gy(s, o, r.cid)
15262
15367
  },
15263
15368
  inputHtml: a,
15264
15369
  originalTransformation: t,
@@ -15266,14 +15371,14 @@ async function hy({ canutesDb: e, legiResolver: t, date: n, defaultTextId: r, ht
15266
15371
  replacementCounter: v
15267
15372
  }), i === void 0 && f && (g[r.cid] = (g[r.cid] ?? 0) + 1);
15268
15373
  }
15269
- my({
15374
+ Cy({
15270
15375
  id: r.cid,
15271
15376
  outputByType: _
15272
- }) && gy({
15377
+ }) && Ty({
15273
15378
  attributes: {
15274
15379
  class: "reference_texte",
15275
15380
  style: "background-color: #eae462",
15276
- title: ly(r, e.reference)
15381
+ title: vy(r, e.reference)
15277
15382
  },
15278
15383
  id: r.cid,
15279
15384
  inputHtml: a,
@@ -15286,7 +15391,7 @@ async function hy({ canutesDb: e, legiResolver: t, date: n, defaultTextId: r, ht
15286
15391
  case "internal_article": {
15287
15392
  let { definition: t, originalTransformation: n } = e;
15288
15393
  if (n === void 0) throw Error(`Missing originalTransformation attribute in internal article link: ${JSON.stringify(e, null, 2)}`);
15289
- for (let e of Object.values(_)) fy({
15394
+ for (let e of Object.values(_)) xy({
15290
15395
  inputHtml: a,
15291
15396
  originalTransformation: n,
15292
15397
  output: e,
@@ -15297,18 +15402,18 @@ async function hy({ canutesDb: e, legiResolver: t, date: n, defaultTextId: r, ht
15297
15402
  }
15298
15403
  default: m("Link", e);
15299
15404
  }
15300
- for (let e of Object.values(_)) e.html = dy(a, e.replacements);
15405
+ for (let e of Object.values(_)) e.html = by(a, e.replacements);
15301
15406
  return {
15302
15407
  outputByType: _,
15303
15408
  referredLegifranceTextCountByCid: g
15304
15409
  };
15305
15410
  }
15306
- function gy({ attributes: e, id: t, inputHtml: n, originalTransformation: r, outputByType: i, replacementCounter: a }) {
15411
+ function Ty({ attributes: e, id: t, inputHtml: n, originalTransformation: r, outputByType: i, replacementCounter: a }) {
15307
15412
  let o = Object.entries(e).map(([e, t]) => `${e}="${$e(t, !0)}"`).join(" ");
15308
15413
  for (let e of ["links_or_references", "references"]) {
15309
15414
  if (e === "links_or_references" && t !== void 0) continue;
15310
15415
  let s = i[e];
15311
- s !== void 0 && fy({
15416
+ s !== void 0 && xy({
15312
15417
  inputHtml: n,
15313
15418
  originalTransformation: r,
15314
15419
  output: s,
@@ -15318,4 +15423,4 @@ function gy({ attributes: e, id: t, inputHtml: n, originalTransformation: r, out
15318
15423
  }
15319
15424
  }
15320
15425
  //#endregion
15321
- export { nm as $, sh as A, Rt as At, zm as B, at as Bt, dg as C, Kt as Ct, ph as D, Bt as Dt, Yh as E, zt as Et, ih as F, O as Ft, Dm as G, ut as Gt, Fm as H, rt as Ht, ah as I, k as It, Z as J, ct as Jt, Tm as K, dt as Kt, Jm as L, bt as Lt, eh as M, pt as Mt, th as N, mt as Nt, ch as O, Et as Ot, rh as P, gt as Pt, Yp as Q, Km as R, et as Rt, ug as S, Yt as St, Xh as T, Jt as Tt, Om as U, it as Ut, Lm as V, nt as Vt, Em as W, lt as Wt, Zp as X, Xp as Y, st as Yt, im as Z, fv as _, nn as _t, oy as a, Jp as at, iv as b, on as bt, ny as c, gn as ct, Dv as d, Cn as dt, tm as et, $v as f, fn as ft, rv as g, en as gt, gg as h, ln as ht, iy as i, Cp as it, oh as j, Dt as jt, lh as k, Lt as kt, ey as l, _n as lt, Xg as m, dn as mt, uy as n, Hp as nt, sy as o, pp as ot, vv as p, hn as pt, vm as q, ot as qt, ay as r, Sp as rt, ty as s, wn as st, hy as t, Pp as tt, ry as u, bn as ut, av as v, rn as vt, lg as w, qt as wt, hg as x, Zt as xt, dv as y, tn as yt, qm as z, tt as zt };
15426
+ export { em as $, mh as A, Et as At, Qm as B, et as Bt, hg as C, Zt as Ct, eg as D, Jt as Dt, tg as E, qt as Et, ch as F, mt as Ft, jm as G, it as Gt, Hm as H, at as Ht, lh as I, gt as It, Cm as J, dt as Jt, Mm as K, lt as Kt, uh as L, O as Lt, dh as M, Rt as Mt, ah as N, Dt as Nt, vh as O, zt as Ot, oh as P, pt as Pt, lm as Q, $m as R, k as Rt, bg as S, on as St, mg as T, Kt as Tt, Bm as U, nt as Ut, Wm as V, tt as Vt, Nm as W, rt as Wt, tm as X, ct as Xt, Z as Y, ot as Yt, nm as Z, st as Zt, xv as _, ln as _t, hy as a, Ep as at, pv as b, rn as bt, dy as c, pp as ct, Iv as d, _n as dt, sm as et, cy as f, bn as ft, fv as g, dn as gt, Tg as h, hn as ht, py as i, Lp as it, fh as j, Lt as jt, ph as k, Bt as kt, ly as l, wn as lt, a_ as m, fn as mt, yy as n, zp as nt, gy as o, Dp as ot, Dv as p, Cn as pt, Am as q, ut as qt, my as r, qp as rt, uy as s, $p as st, wy as t, om as tt, fy as u, gn as ut, mv as v, en as vt, gg as w, Yt as wt, wg as x, tn as xt, bv as y, nn as yt, Zm as z, bt as zt };