@tricoteuses/tisseuse 0.22.2 → 0.22.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,46 @@
1
+ import { ParseBillRawOptions } from '../../lib/server/parsed_bills.js';
2
+ /**
3
+ * Interrupteur de production du rendu des décisions de lien (#510).
4
+ *
5
+ * Le rendu des décisions (`renderLinkDecisions`) n'est pas activé en
6
+ * production : la décision de bascule appartient au mainteneur. Ce que le
7
+ * script de synchronisation des contenus Assemblée offre ici, c'est un
8
+ * **interrupteur explicite**, éteint par défaut.
9
+ *
10
+ * Éteint (variable absente, vide ou différente de `1`), `processDocument`
11
+ * appelle les fonctions de liage exactement comme avant : aucun identifiant
12
+ * documentaire, aucun attribut de décision, un HTML stocké identique à
13
+ * l'octet et donc un `content_hash` inchangé.
14
+ *
15
+ * Allumé, `linkDecisionDocumentId` reçoit l'**UID du document** (identité
16
+ * stable de la source, la même que celle de la file et du document parsé), ce
17
+ * que le rendu des décisions exige.
18
+ *
19
+ * Le nom suit la convention des interrupteurs du paquet
20
+ * (`TISSEUSE_WARN_PARSED_BILL_DIAGNOSTICS=1`, etc.) : une valeur explicite,
21
+ * jamais une valeur par défaut permissive.
22
+ */
23
+ export declare const renderLinkDecisionsEnvName = "TISSEUSE_RENDER_LINK_DECISIONS";
24
+ /**
25
+ * Options de liage à passer à `linkAssembleeBillRaw` pour un document.
26
+ *
27
+ * Rend un objet **vide** quand l'interrupteur est éteint : l'appelant peut
28
+ * l'étaler dans ses options sans ajouter de clé, donc sans changer un octet
29
+ * du résultat.
30
+ */
31
+ export declare function renderLinkDecisionsOptions(documentUid: string, env?: NodeJS.ProcessEnv): Pick<ParseBillRawOptions, "linkDecisionDocumentId" | "renderLinkDecisions">;
32
+ /**
33
+ * `content_hash` d'un document Assemblée stocké.
34
+ *
35
+ * La formule est celle que le script calculait en ligne ; elle est extraite
36
+ * ici pour qu'un test puisse vérifier qu'elle ne bouge pas quand
37
+ * l'interrupteur de rendu des décisions est éteint. Toute clé ajoutée ici
38
+ * change tous les hachages stockés : ne pas la modifier sans une raison qui
39
+ * vaut une réécriture du corpus.
40
+ */
41
+ export declare function assembleeDocumentContentHash({ htmlSimplified, htmlWithLinks, sourceHash, tableOfContents, }: {
42
+ htmlSimplified: string | null;
43
+ htmlWithLinks: string | null;
44
+ sourceHash: string;
45
+ tableOfContents: unknown;
46
+ }): string;
@@ -1,4 +1,4 @@
1
- import { a as e, c as t, h as n, i as r, n as i, r as a, s as o, t as s, u as c } from "./resolver-GT7457lQ.js";
1
+ import { C as e, d as t, f as n, g as r, h as i, p as a, t as o, u as s, v as c } from "./resolver-C8c79uNU.js";
2
2
  //#region src/lib/f_legi/resolver.ts
3
3
  var l = [
4
4
  "article_location_diffs",
@@ -21,22 +21,22 @@ async function f(e) {
21
21
  `;
22
22
  if (t.length > 0) throw Error(`The f_legi database is missing required relations: ${t.map(({ name: e }) => e).join(", ")}`);
23
23
  }
24
- var p = class l extends s {
24
+ var p = class l extends o {
25
25
  flegiDb;
26
26
  articleHistoryInfoByTextAndNum = /* @__PURE__ */ new Map();
27
- async getArticleHistoryInfo({ num: t, textId: n }) {
28
- if (t === void 0) return;
29
- let r = `${n}\0${t}`;
30
- if (this.articleHistoryInfoByTextAndNum.has(r)) return this.articleHistoryInfoByTextAndNum.get(r);
31
- let i = e(await this.flegiDb`
27
+ async getArticleHistoryInfo({ num: e, textId: t }) {
28
+ if (e === void 0) return;
29
+ let n = `${t}\0${e}`;
30
+ if (this.articleHistoryInfoByTextAndNum.has(n)) return this.articleHistoryInfoByTextAndNum.get(n);
31
+ let r = a(await this.flegiDb`
32
32
  SELECT a.legi_id AS id, a.date_debut::text AS "dateDebut",
33
33
  (SELECT jsonb_build_object('VERSION', jsonb_agg(
34
34
  jsonb_build_object('LIEN_ART', jsonb_build_object('@id', v.legi_id_lien))
35
35
  )) FROM versions v WHERE v.legi_id = a.legi_id) AS versions
36
36
  FROM legiarti a
37
- WHERE a.context_text_cid = ${n} AND a.num = ${t}
37
+ WHERE a.context_text_cid = ${t} AND a.num = ${e}
38
38
  `);
39
- return this.articleHistoryInfoByTextAndNum.set(r, i), i;
39
+ return this.articleHistoryInfoByTextAndNum.set(n, r), r;
40
40
  }
41
41
  articleRowsByNumByTextAndDate = /* @__PURE__ */ new Map();
42
42
  articleNumsLoadedByTextAndDate = /* @__PURE__ */ new Map();
@@ -69,7 +69,7 @@ var p = class l extends s {
69
69
  return n?.articleType === "AUTONOME" || n?.articleType === "ENTIEREMENT_MODIF" || n?.articleType === "PARTIELLEMENT_MODIF" ? n.articleType : void 0;
70
70
  }
71
71
  async getVerifiedPublicationComponents(e) {
72
- if (!(e.length !== 2 || e.some((e) => !/^JORFTEXT\d{12}$/.test(e)))) return (await this.flegiDb.begin("isolation level repeatable read read only", async (t) => ({ proof: r(e, await t`
72
+ if (!(e.length !== 2 || e.some((e) => !/^JORFTEXT\d{12}$/.test(e)))) return (await this.flegiDb.begin("isolation level repeatable read read only", async (t) => ({ proof: n(e, await t`
73
73
  SELECT j.cid, n.nature, j.num, j.date_texte::text AS "dateTexte",
74
74
  j.date_publi::text AS "datePubli", j.nor,
75
75
  coalesce(length(j.visas), 0) > 0 AS "hasVisas",
@@ -82,9 +82,9 @@ var p = class l extends s {
82
82
  WHERE j.cid = ANY(${t.array(e)}::text[])
83
83
  `) }))).proof;
84
84
  }
85
- async getVerifiedArticleAbrogation({ date: e, num: t, textId: n }) {
86
- if (/^LEGITEXT\d{12}$/.test(n)) return this.flegiDb.begin("isolation level repeatable read read only", async (r) => {
87
- let i = await r`
85
+ async getVerifiedArticleAbrogation({ date: e, num: n, textId: r }) {
86
+ if (/^LEGITEXT\d{12}$/.test(r)) return this.flegiDb.begin("isolation level repeatable read read only", async (i) => {
87
+ let a = await i`
88
88
  SELECT a.legi_id AS id, a.num, a.context_text_cid AS "textId",
89
89
  a.date_debut::text AS "dateDebut", a.date_fin::text AS "dateFin",
90
90
  e.etat,
@@ -92,7 +92,7 @@ var p = class l extends s {
92
92
  FROM article_location_diffs d
93
93
  JOIN legiarti missing ON missing.legi_id = d.article_id
94
94
  WHERE d.diff_type = 'missing_from_contexte'
95
- AND missing.num = ${t}) AS "missingContext",
95
+ AND missing.num = ${n}) AS "missingContext",
96
96
  (SELECT jsonb_agg(jsonb_build_object(
97
97
  'id', v.legi_id_lien, 'dateDebut', v.debut::text,
98
98
  'dateFin', v.fin::text, 'etat', ve.etat
@@ -100,36 +100,36 @@ var p = class l extends s {
100
100
  FROM versions v JOIN etats ve ON ve.id = v.etat
101
101
  WHERE v.legi_id = a.legi_id) AS versions
102
102
  FROM legiarti a JOIN etats e ON e.id = a.etat
103
- WHERE a.context_text_cid = ${n} AND a.num = ${t}
103
+ WHERE a.context_text_cid = ${r} AND a.num = ${n}
104
104
  LIMIT 129
105
105
  `;
106
- if (i.length === 0 || i.length > 128) return { proof: void 0 };
107
- let o = i[0].missingContext;
108
- return o === 0 ? { proof: a({
109
- candidates: await new l(r).getActiveArticlesByTextAndNum({
106
+ if (a.length === 0 || a.length > 128) return { proof: void 0 };
107
+ let o = a[0].missingContext;
108
+ return o === 0 ? { proof: t({
109
+ candidates: await new l(i).getActiveArticlesByTextAndNum({
110
110
  date: e,
111
- num: t,
112
- textId: n
111
+ num: n,
112
+ textId: r
113
113
  }),
114
114
  date: e,
115
115
  missingContext: o,
116
- num: t,
117
- rows: i,
118
- textId: n
116
+ num: n,
117
+ rows: a,
118
+ textId: r
119
119
  }) } : { proof: void 0 };
120
120
  }).then(({ proof: e }) => e);
121
121
  }
122
122
  async getVerifiedArticleStructure({ date: e, num: t, textId: n }) {
123
123
  if (/^LEGITEXT\d{12}$/.test(n)) return this.flegiDb.begin("isolation level repeatable read read only", async (r) => {
124
- let a = await new l(r).getActiveArticlesByTextAndNum({
124
+ let i = await new l(r).getActiveArticlesByTextAndNum({
125
125
  date: e,
126
126
  num: t,
127
127
  textId: n
128
128
  });
129
- if (a.length < 2 || a.length > 128) return { proof: void 0 };
130
- let o = a.filter(({ dateDebut: t, dateFin: n }) => t < n && t <= e && e < n);
131
- if (o.length < 2) return { proof: void 0 };
132
- let s = await r`
129
+ if (i.length < 2 || i.length > 128) return { proof: void 0 };
130
+ let a = i.filter(({ dateDebut: t, dateFin: n }) => t < n && t <= e && e < n);
131
+ if (a.length < 2) return { proof: void 0 };
132
+ let o = await r`
133
133
  SELECT article_path.dernier_segment AS "articleId",
134
134
  article_path.chemin::text AS "articlePath",
135
135
  edge.chemin::text AS path, edge.type_objet AS type,
@@ -142,28 +142,28 @@ var p = class l extends s {
142
142
  -- texts for each candidate (there need not be a GiST path index).
143
143
  AND subltree(edge.chemin, 0, 1) = ANY(ARRAY[${n}::ltree, ''::ltree])
144
144
  WHERE article_path.type_objet = 'art'
145
- AND article_path.dernier_segment = ANY(${r.array(o.map(({ id: e }) => e))}::text[])
145
+ AND article_path.dernier_segment = ANY(${r.array(a.map(({ id: e }) => e))}::text[])
146
146
  AND subltree(article_path.chemin, 0, 1) = ${n}::ltree
147
147
  ORDER BY article_path.dernier_segment, nlevel(edge.chemin)
148
148
  `, c = /* @__PURE__ */ new Map();
149
- for (let { id: e } of o) {
150
- let t = s.filter(({ articleId: t }) => t === e), r = t[0]?.articlePath, i = r?.split("."), a = i !== void 0 && i.length >= 3 && i[0] === n && i.at(-1) === e && t.length === i.length - 1 && t.every(({ articlePath: e, path: n, type: a }, o) => e === r && n === i.slice(0, o + 2).join(".") && a === (o === t.length - 1 ? "art" : "scta"));
149
+ for (let { id: e } of a) {
150
+ let t = o.filter(({ articleId: t }) => t === e), r = t[0]?.articlePath, i = r?.split("."), a = i !== void 0 && i.length >= 3 && i[0] === n && i.at(-1) === e && t.length === i.length - 1 && t.every(({ articlePath: e, path: n, type: a }, o) => e === r && n === i.slice(0, o + 2).join(".") && a === (o === t.length - 1 ? "art" : "scta"));
151
151
  c.set(e, a ? t.map(({ dateDebut: e, dateFin: t }) => ({
152
152
  dateDebut: e,
153
153
  dateFin: t
154
154
  })) : void 0);
155
155
  }
156
- return { proof: i(a, c, e, n, t) };
156
+ return { proof: s(i, c, e, n, t) };
157
157
  }).then(({ proof: e }) => e);
158
158
  }
159
- async getDirectSectionChildren({ date: e, parentPath: t }) {
160
- let r = `${t}\0${e}`, i = this.directSectionChildrenByParentAndDate.get(r);
159
+ async getDirectSectionChildren({ date: t, parentPath: n }) {
160
+ let r = `${n}\0${t}`, i = this.directSectionChildrenByParentAndDate.get(r);
161
161
  if (i === void 0) {
162
- let a = new n("f_legi.getDirectSectionChildren"), o, s = !1;
163
- if (await a.time("preloadDirectSectionChildrenByParentPath", () => this.preloadDirectSectionChildrenByParentPath(t, e)), i = this.directSectionChildrenByParentAndDate.get(r) ?? [], i.length === 0 && !t.includes(".")) {
164
- o = await a.time("getRootTextIdsFromTextId", () => this.getRootTextIdsFromTextId(t));
165
- let n = o;
166
- n.length > 1 && (s = !0, i = await a.time("queryRootDirectSectionChildren", () => this.flegiDb`
162
+ let a = new e("f_legi.getDirectSectionChildren"), o, s = !1;
163
+ if (await a.time("preloadDirectSectionChildrenByParentPath", () => this.preloadDirectSectionChildrenByParentPath(n, t)), i = this.directSectionChildrenByParentAndDate.get(r) ?? [], i.length === 0 && !n.includes(".")) {
164
+ o = await a.time("getRootTextIdsFromTextId", () => this.getRootTextIdsFromTextId(n));
165
+ let e = o;
166
+ e.length > 1 && (s = !0, i = await a.time("queryRootDirectSectionChildren", () => this.flegiDb`
167
167
  SELECT
168
168
  dernier_segment AS id,
169
169
  chemin::text AS path,
@@ -172,11 +172,11 @@ var p = class l extends s {
172
172
  date_fin::text AS "dateFin"
173
173
  FROM scta
174
174
  WHERE
175
- subltree(chemin, 0, 1) = ANY(${this.flegiDb.array(n)}::ltree[])
175
+ subltree(chemin, 0, 1) = ANY(${this.flegiDb.array(e)}::ltree[])
176
176
  AND nlevel(chemin) = 2
177
177
  AND type_objet = 'scta'
178
- AND date_debut <= ${e}::date
179
- AND date_fin >= ${e}::date
178
+ AND date_debut <= ${t}::date
179
+ AND date_fin >= ${t}::date
180
180
  ORDER BY tri_hierarchique
181
181
  `, { count: o.length }));
182
182
  }
@@ -184,7 +184,7 @@ var p = class l extends s {
184
184
  exactResultCount: o === void 0 ? i.length : 0,
185
185
  fallbackResultCount: s ? i.length : void 0,
186
186
  fallbackRootTextIdCount: o?.length,
187
- parentPath: t,
187
+ parentPath: n,
188
188
  resultCount: i.length,
189
189
  usedFallbackQuery: s
190
190
  }), this.directSectionChildrenByParentAndDate.set(r, i);
@@ -195,34 +195,34 @@ var p = class l extends s {
195
195
  let t = this.textIdBySegmentId.get(e);
196
196
  return t === void 0 && (t = await this.getTextIdFromSegmentIdUsingContextHeuristic(e) ?? await this.getTextIdFromSegmentIdUsingSctaHeuristic(e) ?? null, this.textIdBySegmentId.set(e, t)), t ?? void 0;
197
197
  }
198
- async preloadTextTitlesInfos(e = {}) {
199
- let t = (t, n = {}) => {
200
- e.onProgress?.({
198
+ async preloadTextTitlesInfos(t = {}) {
199
+ let n = (e, n = {}) => {
200
+ t.onProgress?.({
201
201
  ...n,
202
- phase: t,
202
+ phase: e,
203
203
  resolver: "f_legi"
204
204
  });
205
- }, r = new n("f_legi.preloadTextTitlesInfos");
205
+ }, r = new e("f_legi.preloadTextTitlesInfos");
206
206
  if (this.schemaValidationPromise ??= f(this.flegiDb).catch((e) => {
207
207
  throw this.schemaValidationPromise = void 0, e;
208
208
  }), await this.schemaValidationPromise, this.textTitlesInfosLoaded) {
209
209
  let e = await this.getTextTitlesInfosParserCacheMeta(r);
210
210
  if (e !== void 0 && e.formatVersion === 2 && e.generatedAt === u) {
211
- t("already-loaded");
211
+ n("already-loaded");
212
212
  return;
213
213
  }
214
214
  this.textTitlesInfosLoaded = !1;
215
215
  }
216
216
  d === void 0 ? d = (async () => await this.loadOrBuildTextTitlesInfosParserCache({
217
- progress: t,
217
+ progress: n,
218
218
  timings: r
219
219
  }))().catch((e) => {
220
220
  throw d = void 0, e;
221
- }) : t("waiting-for-shared-preload"), u = await d, d = void 0, t("setTextTitlesInfos:done"), r.log(), this.textTitlesInfosLoaded = !0;
221
+ }) : n("waiting-for-shared-preload"), u = await d, d = void 0, n("setTextTitlesInfos:done"), r.log(), this.textTitlesInfosLoaded = !0;
222
222
  }
223
- async buildAndCacheTextTitlesInfos({ progress: e, sql: n, timings: r }) {
224
- await r.time("lockTextTitlesInfos", () => n`SELECT lock_text_titles_infos_for_parser_cache()`), e("queryTextTitlesInfos:start");
225
- let i = await r.time("queryTextTitlesInfos", () => n`
223
+ async buildAndCacheTextTitlesInfos({ progress: e, sql: t, timings: n }) {
224
+ await n.time("lockTextTitlesInfos", () => t`SELECT lock_text_titles_infos_for_parser_cache()`), e("queryTextTitlesInfos:start");
225
+ let a = await n.time("queryTextTitlesInfos", () => t`
226
226
  SELECT
227
227
  t.cid,
228
228
  v.debut::text AS "dateDebut",
@@ -239,14 +239,14 @@ var p = class l extends s {
239
239
  AND v.legi_id_lien = t.legi_id
240
240
  ORDER BY t.legi_id
241
241
  `);
242
- e("queryTextTitlesInfos:done", { count: i.length }), e("buildTextTitlesInfos:start", { count: i.length });
243
- let a = performance.now(), s = await o(i, { onProgress: ({ count: t, phase: n }) => e(`buildTextTitlesInfos:${n}`, { count: t }) });
244
- r.add({
245
- count: i.length,
246
- durationMs: Math.round((performance.now() - a) * 10) / 10,
242
+ e("queryTextTitlesInfos:done", { count: a.length }), e("buildTextTitlesInfos:start", { count: a.length });
243
+ let o = performance.now(), s = await i(a, { onProgress: ({ count: t, phase: n }) => e(`buildTextTitlesInfos:${n}`, { count: t }) });
244
+ n.add({
245
+ count: a.length,
246
+ durationMs: Math.round((performance.now() - o) * 10) / 10,
247
247
  phase: "buildTextTitlesInfos"
248
- }), e("buildTextTitlesInfos:done"), e("writeTextTitlesInfosParserCache:start", { count: i.length });
249
- let [l] = await r.time("writeTextTitlesInfosParserCache", () => n`
248
+ }), e("buildTextTitlesInfos:done"), e("writeTextTitlesInfosParserCache:start", { count: a.length });
249
+ let [l] = await n.time("writeTextTitlesInfosParserCache", () => t`
250
250
  INSERT INTO text_titles_infos_parser_cache (
251
251
  key,
252
252
  format_version,
@@ -256,7 +256,7 @@ var p = class l extends s {
256
256
  ) VALUES (
257
257
  ${c},
258
258
  ${2},
259
- ${i.length},
259
+ ${a.length},
260
260
  now(),
261
261
  ${this.flegiDb.json(s)}
262
262
  )
@@ -268,7 +268,7 @@ var p = class l extends s {
268
268
  data = EXCLUDED.data
269
269
  RETURNING generated_at::text AS "generatedAt"
270
270
  `);
271
- return e("writeTextTitlesInfosParserCache:done", { count: i.length }), t(s), l.generatedAt;
271
+ return e("writeTextTitlesInfosParserCache:done", { count: a.length }), r(s), l.generatedAt;
272
272
  }
273
273
  async getTextTitlesInfosParserCacheMeta(e) {
274
274
  let [t] = await e.time("queryTextTitlesInfosParserCacheMeta", () => this.flegiDb`
@@ -281,10 +281,10 @@ var p = class l extends s {
281
281
  `);
282
282
  return t;
283
283
  }
284
- async loadTextTitlesInfosParserCache({ progress: e, sql: n, timings: r }) {
285
- let i = n ?? this.flegiDb;
284
+ async loadTextTitlesInfosParserCache({ progress: e, sql: t, timings: n }) {
285
+ let i = t ?? this.flegiDb;
286
286
  e("queryTextTitlesInfosParserCache:start");
287
- let [a] = await r.time("queryTextTitlesInfosParserCache", () => i`
287
+ let [a] = await n.time("queryTextTitlesInfosParserCache", () => i`
288
288
  SELECT
289
289
  data,
290
290
  format_version AS "formatVersion",
@@ -303,7 +303,7 @@ var p = class l extends s {
303
303
  }
304
304
  e("queryTextTitlesInfosParserCache:done", { count: a.sourceRowCount });
305
305
  let o = performance.now();
306
- return t(a.data), r.add({
306
+ return r(a.data), n.add({
307
307
  count: a.sourceRowCount,
308
308
  durationMs: Math.round((performance.now() - o) * 10) / 10,
309
309
  phase: "installTextTitlesInfosParserCache"
@@ -333,16 +333,16 @@ var p = class l extends s {
333
333
  let n = `${t}\0${e}`, r = this.globalArticleRowsByNumAndDate.get(n);
334
334
  return r === void 0 && (r = await this.queryUniqueActiveArticlesByNumsUsingContextHeuristic([t]), this.globalArticleRowsByNumAndDate.set(n, r)), r;
335
335
  }
336
- async preloadUniqueActiveArticlesByNums({ date: e, nums: t }) {
336
+ async preloadUniqueActiveArticlesByNums({ date: t, nums: n }) {
337
337
  let r = [], i = /* @__PURE__ */ new Set();
338
- for (let n of t) {
339
- if (n === void 0 || i.has(n)) continue;
340
- i.add(n);
341
- let t = `${n}\0${e}`;
342
- this.globalArticleRowsByNumAndDate.has(t) || r.push(n);
338
+ for (let e of n) {
339
+ if (e === void 0 || i.has(e)) continue;
340
+ i.add(e);
341
+ let n = `${e}\0${t}`;
342
+ this.globalArticleRowsByNumAndDate.has(n) || r.push(e);
343
343
  }
344
344
  if (r.length === 0) return;
345
- let a = new n("f_legi.preloadUniqueActiveArticlesByNums"), o = await a.time("queryGloballyUniqueArticleRowsByNums", () => this.queryGloballyUniqueArticleRowsByNums(r), { count: r.length }), s = new Set(o.map(({ num: e }) => e).filter((e) => e !== null)), c = r.filter((e) => !s.has(e)), l = await a.time("queryUniqueActiveArticlesByNumsUsingContextHeuristic", () => this.queryUniqueActiveArticlesByNumsUsingContextHeuristic(c), { count: c.length }), u = [...o, ...l].toSorted((e, t) => e.id < t.id ? -1 : +(e.id > t.id)), d = /* @__PURE__ */ new Map();
345
+ let a = new e("f_legi.preloadUniqueActiveArticlesByNums"), o = await a.time("queryGloballyUniqueArticleRowsByNums", () => this.queryGloballyUniqueArticleRowsByNums(r), { count: r.length }), s = new Set(o.map(({ num: e }) => e).filter((e) => e !== null)), c = r.filter((e) => !s.has(e)), l = await a.time("queryUniqueActiveArticlesByNumsUsingContextHeuristic", () => this.queryUniqueActiveArticlesByNumsUsingContextHeuristic(c), { count: c.length }), u = [...o, ...l].toSorted((e, t) => e.id < t.id ? -1 : +(e.id > t.id)), d = /* @__PURE__ */ new Map();
346
346
  for (let e of r) d.set(e, []);
347
347
  let f = /* @__PURE__ */ new Map();
348
348
  for (let e of u) {
@@ -350,7 +350,7 @@ var p = class l extends s {
350
350
  let t = f.get(e.num) ?? 0;
351
351
  f.set(e.num, t + 1), !(t >= 100) && d.get(e.num)?.push(e);
352
352
  }
353
- for (let [t, n] of d) this.globalArticleRowsByNumAndDate.set(`${t}\0${e}`, n);
353
+ for (let [e, n] of d) this.globalArticleRowsByNumAndDate.set(`${e}\0${t}`, n);
354
354
  a.log({
355
355
  articleRowCount: u.length,
356
356
  globallyUniqueArticleRowCount: o.length,
@@ -359,23 +359,23 @@ var p = class l extends s {
359
359
  numCount: r.length
360
360
  });
361
361
  }
362
- async preloadActiveArticlesByTextIds({ date: e, nums: t, textIds: r }) {
363
- let i = t === void 0 ? void 0 : [...new Set(t)].filter(Boolean), a = [...new Set(r)].filter((t) => {
364
- if (t === void 0) return !1;
365
- let n = `${t}\0${e}`;
362
+ async preloadActiveArticlesByTextIds({ date: t, nums: n, textIds: r }) {
363
+ let i = n === void 0 ? void 0 : [...new Set(n)].filter(Boolean), a = [...new Set(r)].filter((e) => {
364
+ if (e === void 0) return !1;
365
+ let n = `${e}\0${t}`;
366
366
  if (this.articleRowsByNumByTextAndDate.get(n) === void 0) return !0;
367
367
  let r = this.articleNumsLoadedByTextAndDate.get(n);
368
368
  return r === "all" ? !1 : i === void 0 ? !0 : i.some((e) => !r?.has(e));
369
369
  });
370
370
  if (a.length === 0) return;
371
- let o = new n("f_legi.preloadActiveArticlesByTextIds"), s = await o.time("getContextTextIdsByTextIds", () => this.getContextTextIdsByTextIds(a)), c = [...new Set([...s.values()].flat())], l = await o.time("getActiveArticleRowsForContextTextIds", () => i === void 0 ? this.getActiveArticleRowsForContextTextIdsWithRoots(c) : this.queryActiveArticleRowsForContextTextIds(c, i), { count: c.length }), u = /* @__PURE__ */ new Map(), d = (e, t) => {
371
+ let o = new e("f_legi.preloadActiveArticlesByTextIds"), s = await o.time("getContextTextIdsByTextIds", () => this.getContextTextIdsByTextIds(a)), c = [...new Set([...s.values()].flat())], l = await o.time("getActiveArticleRowsForContextTextIds", () => i === void 0 ? this.getActiveArticleRowsForContextTextIdsWithRoots(c) : this.queryActiveArticleRowsForContextTextIds(c, i), { count: c.length }), u = /* @__PURE__ */ new Map(), d = (e, t) => {
372
372
  if (e === null) return;
373
373
  let n = u.get(e);
374
374
  n === void 0 ? u.set(e, [t]) : n.push(t);
375
375
  };
376
376
  for (let e of l) d(e.rootTextId, e), d(e.textId, e);
377
- for (let t of a) {
378
- let n = `${t}\0${e}`, r = s.get(t) ?? [t], a = /* @__PURE__ */ new Map();
377
+ for (let e of a) {
378
+ let n = `${e}\0${t}`, r = s.get(e) ?? [e], a = /* @__PURE__ */ new Map();
379
379
  for (let e of r) for (let t of u.get(e) ?? []) a.set(`${t.id}\0${t.textId}`, {
380
380
  id: t.id,
381
381
  textId: t.textId,