ropegeo-common 1.23.0 → 1.24.1
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.
- package/dist/models/betaSections/betaSection.d.ts +13 -1
- package/dist/models/betaSections/betaSection.d.ts.map +1 -1
- package/dist/models/betaSections/betaSection.js +21 -6
- package/dist/models/betaSections/formatExcerptHtml.d.ts +8 -1
- package/dist/models/betaSections/formatExcerptHtml.d.ts.map +1 -1
- package/dist/models/betaSections/formatExcerptHtml.js +42 -35
- package/dist/models/betaSections/normalizeExcerptHtml.d.ts +11 -2
- package/dist/models/betaSections/normalizeExcerptHtml.d.ts.map +1 -1
- package/dist/models/betaSections/normalizeExcerptHtml.js +5 -6
- package/dist/models/index.d.ts +1 -1
- package/dist/models/index.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
import { FetchType } from '../fetchType';
|
|
2
2
|
import { BetaSectionExcerpt } from './betaSectionExcerpt';
|
|
3
3
|
import { BetaSectionImage } from './betaSectionImage';
|
|
4
|
+
/**
|
|
5
|
+
* An excerpt split into its verbatim `body` and the surrounding section
|
|
6
|
+
* context. Each of `before`, `body`, and `after` is independently well-formed
|
|
7
|
+
* HTML, so consumers can render them as separate (e.g. stacked) blocks and
|
|
8
|
+
* de-emphasize the context relative to the body. `before`/`after` are omitted
|
|
9
|
+
* when there is no surrounding context (or it would be empty/whitespace).
|
|
10
|
+
*/
|
|
11
|
+
export type ExcerptHtml = {
|
|
12
|
+
before?: string;
|
|
13
|
+
body: string;
|
|
14
|
+
after?: string;
|
|
15
|
+
};
|
|
4
16
|
export declare function registerBetaSectionParser(fetchType: FetchType, parse: (body: unknown) => BetaSection): void;
|
|
5
17
|
export declare abstract class BetaSection {
|
|
6
18
|
abstract readonly fetchType: FetchType;
|
|
@@ -20,7 +32,7 @@ export declare abstract class BetaSection {
|
|
|
20
32
|
* Renders an excerpt with nearby section context when its offsets still
|
|
21
33
|
* match this section, otherwise falls back to the excerpt alone.
|
|
22
34
|
*/
|
|
23
|
-
toExcerptHtml(excerpt: BetaSectionExcerpt):
|
|
35
|
+
toExcerptHtml(excerpt: BetaSectionExcerpt): ExcerptHtml;
|
|
24
36
|
static fromResponseBody(body: unknown, fetchType?: FetchType): BetaSection;
|
|
25
37
|
protected static assertNumber(obj: Record<string, unknown>, key: string): void;
|
|
26
38
|
protected static assertString(obj: Record<string, unknown>, key: string): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"betaSection.d.ts","sourceRoot":"","sources":["../../../src/models/betaSections/betaSection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"betaSection.d.ts","sourceRoot":"","sources":["../../../src/models/betaSections/betaSection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAUtD;;;;;;GAMG;AACH,MAAM,MAAM,WAAW,GAAG;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAIF,wBAAgB,yBAAyB,CACrC,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,WAAW,GACtC,IAAI,CAEN;AAED,8BAAsB,WAAW;IAC7B,QAAQ,CAAC,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IACvC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,C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AE;IAYrB,SAAS,CAAC,MAAM,CAAC,oBAAoB,CACjC,MAAM,EAAE,gBAAgB,EAAE,EAC1B,SAAS,EAAE,OAAO,GACnB,IAAI;CAeV"}
|
|
@@ -47,16 +47,31 @@ class BetaSection {
|
|
|
47
47
|
(0, formatExcerptHtml_1.isSafeTextBoundary)(this.text, excerpt.start) &&
|
|
48
48
|
(0, formatExcerptHtml_1.isSafeTextBoundary)(this.text, excerpt.end);
|
|
49
49
|
if (!validOffsets)
|
|
50
|
-
return excerpt.toHtml();
|
|
50
|
+
return { body: excerpt.toHtml() };
|
|
51
51
|
const excerptStart = excerpt.start;
|
|
52
52
|
const excerptEnd = excerpt.end;
|
|
53
53
|
const characters = (0, formatExcerptHtml_1.visibleCharacters)(this.text);
|
|
54
54
|
const structuredContext = (0, formatExcerptHtml_1.listContext)(this.text, excerptStart, excerptEnd, characters);
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
55
|
+
const parts = structuredContext ?? {
|
|
56
|
+
before: this.text
|
|
57
|
+
.slice((0, formatExcerptHtml_1.previousSentenceStart)(this.text, excerptStart, characters), excerptStart)
|
|
58
|
+
.trim(),
|
|
59
|
+
body: excerpt.text,
|
|
60
|
+
after: this.text
|
|
61
|
+
.slice(excerptEnd, (0, formatExcerptHtml_1.nextSentenceEnd)(this.text, excerptEnd, characters))
|
|
62
|
+
.trim(),
|
|
63
|
+
};
|
|
64
|
+
// We have the source list here, so keep ordered lists ordered; their
|
|
65
|
+
// `start` ordinals are already aligned to the source by `listContext`.
|
|
66
|
+
const options = { preserveOrderedLists: true };
|
|
67
|
+
const result = { body: (0, normalizeExcerptHtml_1.normalizeExcerptListHtml)(parts.body, options) };
|
|
68
|
+
const before = (0, normalizeExcerptHtml_1.normalizeExcerptListHtml)(parts.before, options);
|
|
69
|
+
if (before.trim().length > 0)
|
|
70
|
+
result.before = before;
|
|
71
|
+
const after = (0, normalizeExcerptHtml_1.normalizeExcerptListHtml)(parts.after, options);
|
|
72
|
+
if (after.trim().length > 0)
|
|
73
|
+
result.after = after;
|
|
74
|
+
return result;
|
|
60
75
|
}
|
|
61
76
|
static fromResponseBody(body, fetchType) {
|
|
62
77
|
if (body == null || typeof body !== 'object') {
|
|
@@ -7,10 +7,17 @@ export declare function visibleCharacters(html: string): VisibleCharacter[];
|
|
|
7
7
|
export declare function isSafeTextBoundary(html: string, offset: number): boolean;
|
|
8
8
|
export declare function previousSentenceStart(html: string, anchor: number, characters: VisibleCharacter[]): number;
|
|
9
9
|
export declare function nextSentenceEnd(html: string, anchor: number, characters: VisibleCharacter[]): number;
|
|
10
|
+
/**
|
|
11
|
+
* When an excerpt is a run of list items, returns the excerpt and its adjacent
|
|
12
|
+
* context split into three independently well-formed HTML fragments. Each
|
|
13
|
+
* fragment stands on its own: the surrounding list items (or the sentence
|
|
14
|
+
* before/after the list) become complete lists/prose so they can be rendered as
|
|
15
|
+
* separate stacked blocks.
|
|
16
|
+
*/
|
|
10
17
|
export declare function listContext(html: string, excerptStart: number, excerptEnd: number, characters: VisibleCharacter[]): {
|
|
11
18
|
before: string;
|
|
19
|
+
body: string;
|
|
12
20
|
after: string;
|
|
13
21
|
} | null;
|
|
14
|
-
export declare function fadeText(html: string, direction: 'toward-end' | 'toward-start'): string;
|
|
15
22
|
export {};
|
|
16
23
|
//# sourceMappingURL=formatExcerptHtml.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatExcerptHtml.d.ts","sourceRoot":"","sources":["../../../src/models/betaSections/formatExcerptHtml.ts"],"names":[],"mappings":"AAAA,KAAK,gBAAgB,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAsBzD,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,gBAAgB,EAAE,CAuBlE;AAYD,2EAA2E;AAC3E,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAsCxE;AAuCD,wBAAgB,qBAAqB,CACjC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,gBAAgB,EAAE,GAC/B,MAAM,CAkBR;AAED,wBAAgB,eAAe,CAC3B,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,gBAAgB,EAAE,GAC/B,MAAM,CAuBR;
|
|
1
|
+
{"version":3,"file":"formatExcerptHtml.d.ts","sourceRoot":"","sources":["../../../src/models/betaSections/formatExcerptHtml.ts"],"names":[],"mappings":"AAAA,KAAK,gBAAgB,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAsBzD,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,gBAAgB,EAAE,CAuBlE;AAYD,2EAA2E;AAC3E,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAsCxE;AAuCD,wBAAgB,qBAAqB,CACjC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,gBAAgB,EAAE,GAC/B,MAAM,CAkBR;AAED,wBAAgB,eAAe,CAC3B,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,gBAAgB,EAAE,GAC/B,MAAM,CAuBR;AAoED;;;;;;GAMG;AACH,wBAAgB,WAAW,CACvB,IAAI,EAAE,MAAM,EACZ,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,gBAAgB,EAAE,GAC/B;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAwDxD"}
|
|
@@ -5,7 +5,6 @@ exports.isSafeTextBoundary = isSafeTextBoundary;
|
|
|
5
5
|
exports.previousSentenceStart = previousSentenceStart;
|
|
6
6
|
exports.nextSentenceEnd = nextSentenceEnd;
|
|
7
7
|
exports.listContext = listContext;
|
|
8
|
-
exports.fadeText = fadeText;
|
|
9
8
|
const HEADER_TAG = /^<\s*(\/?)h[1-6]\b/i;
|
|
10
9
|
const NON_TERMINAL_ABBREVIATIONS = new Set([
|
|
11
10
|
'dr',
|
|
@@ -184,6 +183,33 @@ function findContainingList(html, excerptStart, excerptEnd) {
|
|
|
184
183
|
}
|
|
185
184
|
return (ranges.sort((a, b) => b.openStart - a.openStart || a.closeEnd - b.closeEnd)[0] ?? null);
|
|
186
185
|
}
|
|
186
|
+
/** `ul` or `ol`, parsed from a list's opening tag. */
|
|
187
|
+
function listContainerTag(openTag) {
|
|
188
|
+
return /^<\s*ol\b/i.test(openTag) ? 'ol' : 'ul';
|
|
189
|
+
}
|
|
190
|
+
/** The 1-based ordinal an ordered list's first item renders as (`start`, default 1). */
|
|
191
|
+
function listStartIndex(openTag) {
|
|
192
|
+
const match = openTag.match(/\bstart\s*=\s*["']?\s*(-?\d+)/i);
|
|
193
|
+
const parsed = match != null ? Number.parseInt(match[1], 10) : Number.NaN;
|
|
194
|
+
return Number.isFinite(parsed) ? parsed : 1;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Wraps list items in a standalone `<ul>`/`<ol>`. Ordered lists carry a `start`
|
|
198
|
+
* attribute (whenever the first item is not ordinal 1) so numbering lines up
|
|
199
|
+
* with the source list even when the excerpt parts are rendered as separate
|
|
200
|
+
* blocks.
|
|
201
|
+
*/
|
|
202
|
+
function wrapListItems(tag, itemsHtml, startOrdinal) {
|
|
203
|
+
const startAttr = tag === 'ol' && startOrdinal !== 1 ? ` start="${startOrdinal}"` : '';
|
|
204
|
+
return `<${tag}${startAttr}>${itemsHtml}</${tag}>`;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* When an excerpt is a run of list items, returns the excerpt and its adjacent
|
|
208
|
+
* context split into three independently well-formed HTML fragments. Each
|
|
209
|
+
* fragment stands on its own: the surrounding list items (or the sentence
|
|
210
|
+
* before/after the list) become complete lists/prose so they can be rendered as
|
|
211
|
+
* separate stacked blocks.
|
|
212
|
+
*/
|
|
187
213
|
function listContext(html, excerptStart, excerptEnd, characters) {
|
|
188
214
|
const excerpt = html.slice(excerptStart, excerptEnd).trim();
|
|
189
215
|
if (!/^<li\b/i.test(excerpt) || !/<\/li\s*>$/i.test(excerpt)) {
|
|
@@ -192,6 +218,10 @@ function listContext(html, excerptStart, excerptEnd, characters) {
|
|
|
192
218
|
const range = findContainingList(html, excerptStart, excerptEnd);
|
|
193
219
|
if (range == null)
|
|
194
220
|
return null;
|
|
221
|
+
const openTag = html.slice(range.openStart, range.openEnd);
|
|
222
|
+
const tag = listContainerTag(openTag);
|
|
223
|
+
// Ordinal of the list's first item so ordered excerpts line up with the source.
|
|
224
|
+
const baseOrdinal = tag === 'ol' ? listStartIndex(openTag) : 1;
|
|
195
225
|
const listBody = html.slice(range.openEnd, range.closeStart);
|
|
196
226
|
const items = [...listBody.matchAll(/<li\b[^>]*>[\s\S]*?<\/li\s*>/gi)].map((match) => ({
|
|
197
227
|
start: range.openEnd + match.index,
|
|
@@ -199,40 +229,17 @@ function listContext(html, excerptStart, excerptEnd, characters) {
|
|
|
199
229
|
}));
|
|
200
230
|
const previous = items.filter(({ end }) => end <= excerptStart).at(-1);
|
|
201
231
|
const next = items.find(({ start }) => start >= excerptEnd);
|
|
232
|
+
const firstBodyIndex = items.findIndex(({ start }) => start >= excerptStart);
|
|
233
|
+
const body = wrapListItems(tag, html.slice(excerptStart, excerptEnd), baseOrdinal + firstBodyIndex);
|
|
202
234
|
const before = previous != null
|
|
203
|
-
? html.slice(
|
|
204
|
-
|
|
205
|
-
|
|
235
|
+
? wrapListItems(tag, html.slice(previous.start, previous.end), baseOrdinal + items.indexOf(previous))
|
|
236
|
+
: html
|
|
237
|
+
.slice(previousSentenceStart(html, range.openStart, characters), range.openStart)
|
|
238
|
+
.trim();
|
|
206
239
|
const after = next != null
|
|
207
|
-
? html.slice(next.start, next.end) +
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
}
|
|
212
|
-
function fadeText(html, direction) {
|
|
213
|
-
const parts = html.split(/(<[^>]+>)/g);
|
|
214
|
-
const wordCount = parts.reduce((count, part) => part.startsWith('<')
|
|
215
|
-
? count
|
|
216
|
-
: count + (part.match(/\S+/g)?.length ?? 0), 0);
|
|
217
|
-
if (wordCount === 0)
|
|
218
|
-
return html;
|
|
219
|
-
let wordIndex = 0;
|
|
220
|
-
return parts
|
|
221
|
-
.map((part) => {
|
|
222
|
-
if (part.startsWith('<'))
|
|
223
|
-
return part;
|
|
224
|
-
return part
|
|
225
|
-
.split(/(\s+)/)
|
|
226
|
-
.map((token) => {
|
|
227
|
-
if (token.length === 0 || /^\s+$/.test(token))
|
|
228
|
-
return token;
|
|
229
|
-
const progress = wordCount === 1 ? 1 : wordIndex / (wordCount - 1);
|
|
230
|
-
const proximity = direction === 'toward-end' ? progress : 1 - progress;
|
|
231
|
-
const opacity = (0.3 + proximity * 0.4).toFixed(2);
|
|
232
|
-
wordIndex += 1;
|
|
233
|
-
return `<span style="opacity: ${opacity}">${token}</span>`;
|
|
234
|
-
})
|
|
235
|
-
.join('');
|
|
236
|
-
})
|
|
237
|
-
.join('');
|
|
240
|
+
? wrapListItems(tag, html.slice(next.start, next.end), baseOrdinal + items.indexOf(next))
|
|
241
|
+
: html
|
|
242
|
+
.slice(range.closeEnd, nextSentenceEnd(html, range.closeEnd, characters))
|
|
243
|
+
.trim();
|
|
244
|
+
return { before, body, after };
|
|
238
245
|
}
|
|
@@ -1,6 +1,15 @@
|
|
|
1
|
+
export type NormalizeExcerptListOptions = {
|
|
2
|
+
/**
|
|
3
|
+
* When true, an unpaired closing `</ol>` is repaired by prepending an
|
|
4
|
+
* opening `<ol>` (preserving the ordered list). When false (the default,
|
|
5
|
+
* used for excerpt-only text with no known source order), it is converted
|
|
6
|
+
* to `</ul>` and an opening `<ul>` is prepended instead.
|
|
7
|
+
*/
|
|
8
|
+
preserveOrderedLists?: boolean;
|
|
9
|
+
};
|
|
1
10
|
/**
|
|
2
11
|
* Repairs the list fragments Ropewiki excerpts commonly produce without
|
|
3
|
-
* otherwise rewriting the source HTML.
|
|
12
|
+
* otherwise rewriting the source HTML, so the result is well-formed on its own.
|
|
4
13
|
*/
|
|
5
|
-
export declare function normalizeExcerptListHtml(html: string): string;
|
|
14
|
+
export declare function normalizeExcerptListHtml(html: string, { preserveOrderedLists }?: NormalizeExcerptListOptions): string;
|
|
6
15
|
//# sourceMappingURL=normalizeExcerptHtml.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normalizeExcerptHtml.d.ts","sourceRoot":"","sources":["../../../src/models/betaSections/normalizeExcerptHtml.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,wBAAgB,wBAAwB,
|
|
1
|
+
{"version":3,"file":"normalizeExcerptHtml.d.ts","sourceRoot":"","sources":["../../../src/models/betaSections/normalizeExcerptHtml.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,2BAA2B,GAAG;IACtC;;;;;OAKG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAClC,CAAC;AAEF;;;GAGG;AACH,wBAAgB,wBAAwB,CACpC,IAAI,EAAE,MAAM,EACZ,EAAE,oBAA4B,EAAE,GAAE,2BAAgC,GACnE,MAAM,CA+BR"}
|
|
@@ -6,18 +6,17 @@ function countTags(html, pattern) {
|
|
|
6
6
|
}
|
|
7
7
|
/**
|
|
8
8
|
* Repairs the list fragments Ropewiki excerpts commonly produce without
|
|
9
|
-
* otherwise rewriting the source HTML.
|
|
9
|
+
* otherwise rewriting the source HTML, so the result is well-formed on its own.
|
|
10
10
|
*/
|
|
11
|
-
function normalizeExcerptListHtml(html) {
|
|
11
|
+
function normalizeExcerptListHtml(html, { preserveOrderedLists = false } = {}) {
|
|
12
12
|
if (html.length === 0)
|
|
13
13
|
return html;
|
|
14
14
|
let normalized = html;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
if (olOpenCount === 0 && olCloseCount > 0) {
|
|
15
|
+
const olOpenCount = countTags(normalized, /<ol\b[^>]*>/gi);
|
|
16
|
+
const olCloseCount = countTags(normalized, /<\/ol\s*>/gi);
|
|
17
|
+
if (!preserveOrderedLists && olOpenCount === 0 && olCloseCount > 0) {
|
|
18
18
|
normalized = normalized.replace(/<\/ol\s*>/gi, '</ul>');
|
|
19
19
|
normalized = '<ul>'.repeat(olCloseCount) + normalized;
|
|
20
|
-
olCloseCount = 0;
|
|
21
20
|
}
|
|
22
21
|
else if (olOpenCount > olCloseCount) {
|
|
23
22
|
normalized += '</ol>'.repeat(olOpenCount - olCloseCount);
|
package/dist/models/index.d.ts
CHANGED
|
@@ -55,7 +55,7 @@ export { BetaSectionImage } from './betaSections/betaSectionImage';
|
|
|
55
55
|
export { OnlineBetaSectionImage } from './betaSections/onlineBetaSectionImage';
|
|
56
56
|
export { OfflineBetaSectionImage } from './betaSections/offlineBetaSectionImage';
|
|
57
57
|
export { DownloadBytes } from './betaSections/downloadBytes';
|
|
58
|
-
export { BetaSection } from './betaSections/betaSection';
|
|
58
|
+
export { BetaSection, type ExcerptHtml } from './betaSections/betaSection';
|
|
59
59
|
export { BetaSectionExcerpt } from './betaSections/betaSectionExcerpt';
|
|
60
60
|
export { OnlineBetaSection } from './betaSections/onlineBetaSection';
|
|
61
61
|
export { OfflineBetaSection } from './betaSections/offlineBetaSection';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":"AAAA,OAAO,wCAAwC,CAAC;AAChD,OAAO,8CAA8C,CAAC;AACtD,OAAO,kDAAkD,CAAC;AAC1D,OAAO,8CAA8C,CAAC;AACtD,OAAO,2CAA2C,CAAC;AACnD,OAAO,mCAAmC,CAAC;AAC3C,O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