@tricoteuses/tisseuse 0.14.11 → 0.14.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
- import { n as e, r as t, t as n } from "./resolver-D5TCkLkD.js";
1
+ import { a as e, i as t, o as n, r, t as i } from "./resolver-CuP8arVX.js";
2
2
  //#region src/lib/f_legi/resolver.ts
3
- var r = [
3
+ var a = [
4
4
  "article_location_diffs",
5
5
  "article_num_candidate_stats",
6
6
  "article_num_candidates",
@@ -9,18 +9,19 @@ var r = [
9
9
  "legiarti",
10
10
  "legitext",
11
11
  "scta",
12
- "text_titles_infos"
13
- ], i;
14
- async function a(e) {
12
+ "text_titles_infos",
13
+ "text_titles_infos_parser_cache"
14
+ ], o, s;
15
+ async function c(e) {
15
16
  let t = await e`
16
17
  SELECT required.name
17
- FROM unnest(${e.array([...r])}::text[]) AS required(name)
18
+ FROM unnest(${e.array([...a])}::text[]) AS required(name)
18
19
  WHERE to_regclass(required.name) IS NULL
19
20
  ORDER BY required.name
20
21
  `;
21
22
  if (t.length > 0) throw Error(`The f_legi database is missing required relations: ${t.map(({ name: e }) => e).join(", ")}`);
22
23
  }
23
- var o = class extends n {
24
+ var l = class extends i {
24
25
  flegiDb;
25
26
  articleRowsByNumByTextAndDate = /* @__PURE__ */ new Map();
26
27
  articleNumsLoadedByTextAndDate = /* @__PURE__ */ new Map();
@@ -39,123 +40,222 @@ var o = class extends n {
39
40
  return t === void 0 ? [] : (await this.getActiveArticleRowsByNum(n, e, t)).get(t) ?? [];
40
41
  }
41
42
  async getDirectSectionChildren({ date: e, parentPath: t }) {
42
- let n = `${t}\0${e}`, r = this.directSectionChildrenByParentAndDate.get(n);
43
- if (r === void 0) {
44
- if (r = await this.getDirectSectionChildrenByExactParentPath({
43
+ let r = `${t}\0${e}`, i = this.directSectionChildrenByParentAndDate.get(r);
44
+ if (i === void 0) {
45
+ let a = new n("f_legi.getDirectSectionChildren"), o, s = !1;
46
+ if (i = await a.time("getDirectSectionChildrenByExactParentPath", () => this.getDirectSectionChildrenByExactParentPath({
45
47
  date: e,
46
48
  parentPath: t
47
- }), r.length === 0 && !t.includes(".")) {
48
- let n = await this.getRootTextIdsFromTextId(t);
49
- n.length > 1 && (r = await this.flegiDb`
50
- SELECT
51
- dernier_segment AS id,
52
- chemin::text AS path,
53
- titre AS title,
54
- date_debut::text AS "dateDebut",
55
- date_fin::text AS "dateFin"
56
- FROM scta
57
- WHERE
58
- subltree(chemin, 0, 1) = ANY(${this.flegiDb.array(n)}::ltree[])
59
- AND nlevel(chemin) = 2
60
- AND type_objet = 'scta'
61
- AND date_debut <= ${e}::date
62
- AND date_fin >= ${e}::date
63
- ORDER BY tri_hierarchique
64
- `);
49
+ })), i.length === 0 && !t.includes(".")) {
50
+ o = await a.time("getRootTextIdsFromTextId", () => this.getRootTextIdsFromTextId(t));
51
+ let n = o;
52
+ n.length > 1 && (s = !0, i = await a.time("queryRootDirectSectionChildren", () => this.flegiDb`
53
+ SELECT
54
+ dernier_segment AS id,
55
+ chemin::text AS path,
56
+ titre AS title,
57
+ date_debut::text AS "dateDebut",
58
+ date_fin::text AS "dateFin"
59
+ FROM scta
60
+ WHERE
61
+ subltree(chemin, 0, 1) = ANY(${this.flegiDb.array(n)}::ltree[])
62
+ AND nlevel(chemin) = 2
63
+ AND type_objet = 'scta'
64
+ AND date_debut <= ${e}::date
65
+ AND date_fin >= ${e}::date
66
+ ORDER BY tri_hierarchique
67
+ `, { count: o.length }));
65
68
  }
66
- this.directSectionChildrenByParentAndDate.set(n, r);
69
+ a.log({
70
+ exactResultCount: o === void 0 ? i.length : 0,
71
+ fallbackResultCount: s ? i.length : void 0,
72
+ fallbackRootTextIdCount: o?.length,
73
+ parentPath: t,
74
+ resultCount: i.length,
75
+ usedFallbackQuery: s
76
+ }), this.directSectionChildrenByParentAndDate.set(r, i);
67
77
  }
68
- return r;
78
+ return i;
69
79
  }
70
80
  async getTextIdFromSegmentId(e) {
71
81
  let t = this.textIdBySegmentId.get(e);
72
82
  return t === void 0 && (t = await this.getTextIdFromSegmentIdUsingContextHeuristic(e) ?? await this.getTextIdFromSegmentIdUsingSctaHeuristic(e) ?? null, this.textIdBySegmentId.set(e, t)), t ?? void 0;
73
83
  }
74
- async preloadTextTitlesInfos(n = {}) {
75
- let r = (e, t = {}) => {
76
- n.onProgress?.({
77
- ...t,
78
- phase: e,
84
+ async preloadTextTitlesInfos(e = {}) {
85
+ let t = (t, n = {}) => {
86
+ e.onProgress?.({
87
+ ...n,
88
+ phase: t,
79
89
  resolver: "f_legi"
80
90
  });
81
- };
82
- if (this.textTitlesInfosLoaded) {
83
- r("already-loaded");
91
+ }, r = new n("f_legi.preloadTextTitlesInfos");
92
+ if (this.schemaValidationPromise ??= c(this.flegiDb).catch((e) => {
93
+ throw this.schemaValidationPromise = void 0, e;
94
+ }), await this.schemaValidationPromise, this.textTitlesInfosLoaded) {
95
+ let e = await this.getTextTitlesInfosParserCacheMeta(r);
96
+ if (e !== void 0 && e.formatVersion === 1 && e.generatedAt === o) {
97
+ t("already-loaded");
98
+ return;
99
+ }
100
+ this.textTitlesInfosLoaded = !1;
101
+ }
102
+ s === void 0 ? s = (async () => await this.loadOrBuildTextTitlesInfosParserCache({
103
+ progress: t,
104
+ timings: r
105
+ }))().catch((e) => {
106
+ throw s = void 0, e;
107
+ }) : t("waiting-for-shared-preload"), o = await s, s = void 0, t("setTextTitlesInfos:done"), r.log(), this.textTitlesInfosLoaded = !0;
108
+ }
109
+ async buildAndCacheTextTitlesInfos({ progress: n, sql: i, timings: a }) {
110
+ await a.time("lockTextTitlesInfos", () => i`SELECT lock_text_titles_infos_for_parser_cache()`), n("queryTextTitlesInfos:start");
111
+ let o = await a.time("queryTextTitlesInfos", () => i`
112
+ SELECT
113
+ cid,
114
+ date_texte::text AS "dateTexte",
115
+ legi_id::text AS id,
116
+ nature,
117
+ num,
118
+ title
119
+ FROM text_titles_infos
120
+ ORDER BY legi_id
121
+ `);
122
+ n("queryTextTitlesInfos:done", { count: o.length }), n("buildTextTitlesInfos:start", { count: o.length });
123
+ let s = performance.now(), c = await r(o, { onProgress: ({ count: e, phase: t }) => n(`buildTextTitlesInfos:${t}`, { count: e }) });
124
+ a.add({
125
+ count: o.length,
126
+ durationMs: Math.round((performance.now() - s) * 10) / 10,
127
+ phase: "buildTextTitlesInfos"
128
+ }), n("buildTextTitlesInfos:done"), n("writeTextTitlesInfosParserCache:start", { count: o.length });
129
+ let [l] = await a.time("writeTextTitlesInfosParserCache", () => i`
130
+ INSERT INTO text_titles_infos_parser_cache (
131
+ key,
132
+ format_version,
133
+ source_row_count,
134
+ generated_at,
135
+ data
136
+ ) VALUES (
137
+ ${e},
138
+ ${1},
139
+ ${o.length},
140
+ now(),
141
+ ${this.flegiDb.json(c)}
142
+ )
143
+ ON CONFLICT (key)
144
+ DO UPDATE SET
145
+ format_version = EXCLUDED.format_version,
146
+ source_row_count = EXCLUDED.source_row_count,
147
+ generated_at = EXCLUDED.generated_at,
148
+ data = EXCLUDED.data
149
+ RETURNING generated_at::text AS "generatedAt"
150
+ `);
151
+ return n("writeTextTitlesInfosParserCache:done", { count: o.length }), t(c), l.generatedAt;
152
+ }
153
+ async getTextTitlesInfosParserCacheMeta(t) {
154
+ let [n] = await t.time("queryTextTitlesInfosParserCacheMeta", () => this.flegiDb`
155
+ SELECT
156
+ format_version AS "formatVersion",
157
+ generated_at::text AS "generatedAt",
158
+ source_row_count AS "sourceRowCount"
159
+ FROM text_titles_infos_parser_cache
160
+ WHERE key = ${e}
161
+ `);
162
+ return n;
163
+ }
164
+ async loadTextTitlesInfosParserCache({ progress: n, sql: r, timings: i }) {
165
+ let a = r ?? this.flegiDb;
166
+ n("queryTextTitlesInfosParserCache:start");
167
+ let [o] = await i.time("queryTextTitlesInfosParserCache", () => a`
168
+ SELECT
169
+ data,
170
+ format_version AS "formatVersion",
171
+ generated_at::text AS "generatedAt",
172
+ source_row_count AS "sourceRowCount"
173
+ FROM text_titles_infos_parser_cache
174
+ WHERE key = ${e}
175
+ `);
176
+ if (o === void 0) {
177
+ n("queryTextTitlesInfosParserCache:miss");
84
178
  return;
85
179
  }
86
- let o = new e("f_legi.preloadTextTitlesInfos");
87
- this.schemaValidationPromise ??= a(this.flegiDb).catch((e) => {
88
- throw this.schemaValidationPromise = void 0, e;
89
- }), await this.schemaValidationPromise, i === void 0 ? (r("queryTextTitlesInfos:start"), i = (async () => {
90
- let e = await o.time("queryTextTitlesInfos", () => this.flegiDb`
91
- SELECT
92
- cid,
93
- date_texte::text AS "dateTexte",
94
- legi_id::text AS id,
95
- nature,
96
- num,
97
- title
98
- FROM text_titles_infos
99
- ORDER BY legi_id
100
- `);
101
- r("queryTextTitlesInfos:done", { count: e.length }), r("buildTextTitlesInfos:start", { count: e.length });
102
- let n = performance.now();
103
- await t(e, { onProgress: ({ count: e, phase: t }) => r(`buildTextTitlesInfos:${t}`, { count: e }) }), o.add({
104
- count: e.length,
105
- durationMs: Math.round((performance.now() - n) * 10) / 10,
106
- phase: "buildTextTitlesInfos"
107
- }), r("buildTextTitlesInfos:done");
108
- })().catch((e) => {
109
- throw i = void 0, e;
110
- })) : r("waiting-for-shared-preload"), await i, r("setTextTitlesInfos:done"), o.log(), this.textTitlesInfosLoaded = !0;
180
+ if (o.formatVersion !== 1) {
181
+ n("queryTextTitlesInfosParserCache:format-mismatch");
182
+ return;
183
+ }
184
+ n("queryTextTitlesInfosParserCache:done", { count: o.sourceRowCount });
185
+ let s = performance.now();
186
+ return t(o.data), i.add({
187
+ count: o.sourceRowCount,
188
+ durationMs: Math.round((performance.now() - s) * 10) / 10,
189
+ phase: "installTextTitlesInfosParserCache"
190
+ }), o.generatedAt;
191
+ }
192
+ async loadOrBuildTextTitlesInfosParserCache({ progress: e, timings: t }) {
193
+ let n = await this.loadTextTitlesInfosParserCache({
194
+ progress: e,
195
+ timings: t
196
+ });
197
+ return n === void 0 ? await this.flegiDb.begin(async (n) => {
198
+ await t.time("waitTextTitlesInfosParserCacheLock", () => n`SELECT pg_advisory_xact_lock(hashtext('text_titles_infos_parser_cache'))`);
199
+ let r = await this.loadTextTitlesInfosParserCache({
200
+ progress: e,
201
+ sql: n,
202
+ timings: t
203
+ });
204
+ return r === void 0 ? await this.buildAndCacheTextTitlesInfos({
205
+ progress: e,
206
+ sql: n,
207
+ timings: t
208
+ }) : r;
209
+ }) : n;
111
210
  }
112
211
  async getUniqueActiveArticlesByNum({ date: e, num: t }) {
113
212
  if (t === void 0) return [];
114
213
  let n = `${t}\0${e}`, r = this.globalArticleRowsByNumAndDate.get(n);
115
214
  return r === void 0 && (r = await this.queryUniqueActiveArticlesByNumsUsingContextHeuristic([t]), this.globalArticleRowsByNumAndDate.set(n, r)), r;
116
215
  }
117
- async preloadUniqueActiveArticlesByNums({ date: t, nums: n }) {
118
- let r = [];
119
- for (let e of n) {
120
- if (e === void 0) continue;
121
- let n = `${e}\0${t}`;
122
- this.globalArticleRowsByNumAndDate.has(n) || r.push(e);
216
+ async preloadUniqueActiveArticlesByNums({ date: e, nums: t }) {
217
+ let r = [], i = /* @__PURE__ */ new Set();
218
+ for (let n of t) {
219
+ if (n === void 0 || i.has(n)) continue;
220
+ i.add(n);
221
+ let t = `${n}\0${e}`;
222
+ this.globalArticleRowsByNumAndDate.has(t) || r.push(n);
123
223
  }
124
224
  if (r.length === 0) return;
125
- let i = new e("f_legi.preloadUniqueActiveArticlesByNums"), a = await i.time("queryGloballyUniqueArticleRowsByNums", () => this.queryGloballyUniqueArticleRowsByNums(r), { count: r.length }), o = new Set(a.map(({ num: e }) => e).filter((e) => e !== null)), s = r.filter((e) => !o.has(e)), c = await i.time("queryUniqueActiveArticlesByNumsUsingContextHeuristic", () => this.queryUniqueActiveArticlesByNumsUsingContextHeuristic(s), { count: s.length }), l = [...a, ...c].toSorted((e, t) => e.id < t.id ? -1 : +(e.id > t.id)), u = /* @__PURE__ */ new Map();
126
- for (let e of r) u.set(e, []);
127
- let d = /* @__PURE__ */ new Map();
128
- for (let e of l) {
225
+ 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();
226
+ for (let e of r) d.set(e, []);
227
+ let f = /* @__PURE__ */ new Map();
228
+ for (let e of u) {
129
229
  if (e.num === null) continue;
130
- let t = d.get(e.num) ?? 0;
131
- d.set(e.num, t + 1), !(t >= 100) && u.get(e.num)?.push(e);
230
+ let t = f.get(e.num) ?? 0;
231
+ f.set(e.num, t + 1), !(t >= 100) && d.get(e.num)?.push(e);
132
232
  }
133
- for (let [e, n] of u) this.globalArticleRowsByNumAndDate.set(`${e}\0${t}`, n);
134
- i.log({
135
- articleRowCount: l.length,
136
- globallyUniqueArticleRowCount: a.length,
137
- heuristicArticleRowCount: c.length,
138
- heuristicNumCount: s.length,
233
+ for (let [t, n] of d) this.globalArticleRowsByNumAndDate.set(`${t}\0${e}`, n);
234
+ a.log({
235
+ articleRowCount: u.length,
236
+ globallyUniqueArticleRowCount: o.length,
237
+ heuristicArticleRowCount: l.length,
238
+ heuristicNumCount: c.length,
139
239
  numCount: r.length
140
240
  });
141
241
  }
142
- async preloadActiveArticlesByTextIds({ date: t, nums: n, textIds: r }) {
143
- let i = n === void 0 ? void 0 : [...new Set(n)].filter(Boolean), a = [...new Set(r)].filter((e) => {
144
- if (e === void 0) return !1;
145
- let n = `${e}\0${t}`;
242
+ async preloadActiveArticlesByTextIds({ date: e, nums: t, textIds: r }) {
243
+ let i = t === void 0 ? void 0 : [...new Set(t)].filter(Boolean), a = [...new Set(r)].filter((t) => {
244
+ if (t === void 0) return !1;
245
+ let n = `${t}\0${e}`;
146
246
  if (this.articleRowsByNumByTextAndDate.get(n) === void 0) return !0;
147
247
  let r = this.articleNumsLoadedByTextAndDate.get(n);
148
248
  return r === "all" ? !1 : i === void 0 ? !0 : i.some((e) => !r?.has(e));
149
249
  });
150
250
  if (a.length === 0) return;
151
- 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) => {
251
+ 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) => {
152
252
  if (e === null) return;
153
253
  let n = u.get(e);
154
254
  n === void 0 ? u.set(e, [t]) : n.push(t);
155
255
  };
156
256
  for (let e of l) d(e.rootTextId, e), d(e.textId, e);
157
- for (let e of a) {
158
- let n = `${e}\0${t}`, r = s.get(e) ?? [e], a = /* @__PURE__ */ new Map();
257
+ for (let t of a) {
258
+ let n = `${t}\0${e}`, r = s.get(t) ?? [t], a = /* @__PURE__ */ new Map();
159
259
  for (let e of r) for (let t of u.get(e) ?? []) a.set(`${t.id}\0${t.textId}`, {
160
260
  id: t.id,
161
261
  textId: t.textId,
@@ -163,11 +263,14 @@ var o = class extends n {
163
263
  dateDebut: t.dateDebut,
164
264
  dateFin: t.dateFin
165
265
  });
166
- let o = this.articleRowsByNumByTextAndDate.get(n) ?? /* @__PURE__ */ new Map();
266
+ let o = this.articleRowsByNumByTextAndDate.get(n) ?? /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map();
267
+ for (let [e, t] of o) c.set(e, new Set(t.map((e) => `${e.id}\0${e.textId}`)));
167
268
  for (let e of a.values()) {
168
269
  if (e.num === null) continue;
169
- let t = o.get(e.num);
170
- t === void 0 ? o.set(e.num, [e]) : t.some((t) => t.id === e.id && t.textId === e.textId) || t.push(e);
270
+ let t = `${e.id}\0${e.textId}`, n = c.get(e.num);
271
+ n === void 0 && (n = /* @__PURE__ */ new Set(), c.set(e.num, n));
272
+ let r = o.get(e.num);
273
+ r === void 0 ? (o.set(e.num, [e]), n.add(t)) : n.has(t) || (r.push(e), n.add(t));
171
274
  }
172
275
  if (this.articleRowsByNumByTextAndDate.set(n, o), i === void 0) this.articleNumsLoadedByTextAndDate.set(n, "all");
173
276
  else {
@@ -420,6 +523,23 @@ var o = class extends n {
420
523
  `).toSorted((e, t) => e.id.localeCompare(t.id));
421
524
  }
422
525
  async getDirectSectionChildrenByExactParentPath({ date: e, parentPath: t }) {
526
+ if (!t.includes(".")) return await this.flegiDb`
527
+ SELECT
528
+ dernier_segment AS id,
529
+ chemin::text AS path,
530
+ titre AS title,
531
+ date_debut::text AS "dateDebut",
532
+ date_fin::text AS "dateFin"
533
+ FROM scta
534
+ WHERE
535
+ subltree(chemin, 0, 1) = ${t}::ltree
536
+ AND nlevel(chemin) = 2
537
+ AND type_objet = 'scta'
538
+ AND date_debut <= ${e}::date
539
+ AND date_fin >= ${e}::date
540
+ ORDER BY tri_hierarchique
541
+ `;
542
+ let n = `${t}.*{1}`;
423
543
  return await this.flegiDb`
424
544
  SELECT
425
545
  dernier_segment AS id,
@@ -429,8 +549,7 @@ var o = class extends n {
429
549
  date_fin::text AS "dateFin"
430
550
  FROM scta
431
551
  WHERE
432
- chemin <@ ${t}::ltree
433
- AND nlevel(chemin) = nlevel(${t}::ltree) + 1
552
+ chemin ~ ${n}::lquery
434
553
  AND type_objet = 'scta'
435
554
  AND date_debut <= ${e}::date
436
555
  AND date_fin >= ${e}::date
@@ -476,14 +595,14 @@ var o = class extends n {
476
595
  return t === void 0 && (t = (await this.getContextTextIdsByTextIds([e])).get(e) ?? [e], this.contextTextIdsByTextId.set(e, t)), t;
477
596
  }
478
597
  async getContextTextIdsByTextIds(e) {
479
- let t = /* @__PURE__ */ new Map(), n = e.filter((e) => !this.contextTextIdsByTextId.has(e));
598
+ let t = /* @__PURE__ */ new Map(), n = e.filter((e) => !this.contextTextIdsByTextId.has(e)), r = new Set(n);
480
599
  for (let n of e) {
481
600
  let e = this.contextTextIdsByTextId.get(n);
482
601
  e !== void 0 && t.set(n, e);
483
602
  }
484
603
  if (n.length === 0) return t;
485
604
  for (let e of n) t.set(e, [e]);
486
- let r = await this.flegiDb`
605
+ let i = await this.flegiDb`
487
606
  SELECT legi_id AS "textId", cid AS "contextTextId"
488
607
  FROM legitext
489
608
  WHERE legi_id IN ${this.flegiDb(n)} OR cid IN ${this.flegiDb(n)}
@@ -496,10 +615,10 @@ var o = class extends n {
496
615
 
497
616
  ORDER BY "textId", "contextTextId"
498
617
  `;
499
- for (let { contextTextId: e, textId: i } of r) for (let r of [i, e]) {
500
- if (!n.includes(r)) continue;
501
- let i = t.get(r) ?? [r];
502
- i.includes(e) || i.push(e), t.set(r, i);
618
+ for (let { contextTextId: e, textId: n } of i) for (let i of [n, e]) {
619
+ if (!r.has(i)) continue;
620
+ let n = t.get(i) ?? [i];
621
+ n.includes(e) || n.push(e), t.set(i, n);
503
622
  }
504
623
  for (let e of n) this.contextTextIdsByTextId.set(e, t.get(e) ?? [e]);
505
624
  return t;
@@ -509,14 +628,14 @@ var o = class extends n {
509
628
  return t === void 0 && (t = (await this.getRootTextIdsByTextIds([e])).get(e) ?? [e], this.rootTextIdsByTextId.set(e, t)), t;
510
629
  }
511
630
  async getRootTextIdsByTextIds(e) {
512
- let t = /* @__PURE__ */ new Map(), n = e.filter((e) => !this.rootTextIdsByTextId.has(e));
631
+ let t = /* @__PURE__ */ new Map(), n = e.filter((e) => !this.rootTextIdsByTextId.has(e)), r = new Set(n);
513
632
  for (let n of e) {
514
633
  let e = this.rootTextIdsByTextId.get(n);
515
634
  e !== void 0 && t.set(n, e);
516
635
  }
517
636
  if (n.length === 0) return t;
518
637
  for (let e of n) t.set(e, [e]);
519
- let r = await this.flegiDb`
638
+ let i = await this.flegiDb`
520
639
  SELECT cid AS "textId", legi_id AS "rootTextId"
521
640
  FROM legitext
522
641
  WHERE cid IN ${this.flegiDb(n)}
@@ -529,13 +648,14 @@ var o = class extends n {
529
648
 
530
649
  ORDER BY "textId", "rootTextId"
531
650
  `;
532
- for (let { textId: e, rootTextId: n } of r) {
533
- let r = t.get(e) ?? [e];
534
- r.includes(n) || r.push(n), t.set(e, r);
651
+ for (let { textId: e, rootTextId: n } of i) {
652
+ if (!r.has(e)) continue;
653
+ let i = t.get(e) ?? [e];
654
+ i.includes(n) || i.push(n), t.set(e, i);
535
655
  }
536
656
  for (let e of n) this.rootTextIdsByTextId.set(e, t.get(e) ?? [e]);
537
657
  return t;
538
658
  }
539
659
  };
540
660
  //#endregion
541
- export { o as FlegiResolver, a as checkFlegiResolverDatabase };
661
+ export { l as FlegiResolver, c as checkFlegiResolverDatabase };