@cnblogs/markdown-it-presets 1.9.4 → 1.9.6
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/commonjs/index.cjs +936 -19
- package/dist/commonjs/math/index.cjs +234 -8
- package/dist/commonjs/presets/index.cjs +723 -124
- package/dist/es2015/index.mjs +893 -3
- package/dist/es2015/math/index.mjs +210 -3
- package/dist/es2015/presets/index.mjs +681 -100
- package/dist/umd/mathRenderer.js +1 -1
- package/package.json +8 -8
- package/dist/commonjs/index.cjs.map +0 -1
- package/dist/commonjs/math/factory.cjs +0 -17
- package/dist/commonjs/math/factory.cjs.map +0 -1
- package/dist/commonjs/math/impl.cjs +0 -166
- package/dist/commonjs/math/impl.cjs.map +0 -1
- package/dist/commonjs/math/index.cjs.map +0 -1
- package/dist/commonjs/math/model.cjs +0 -23
- package/dist/commonjs/math/model.cjs.map +0 -1
- package/dist/commonjs/presets/index.cjs.map +0 -1
- package/dist/commonjs/presets/option.cjs +0 -36
- package/dist/commonjs/presets/option.cjs.map +0 -1
- package/dist/commonjs/presets/plugins/highlight-code-lines.plugin.cjs +0 -52
- package/dist/commonjs/presets/plugins/highlight-code-lines.plugin.cjs.map +0 -1
- package/dist/commonjs/presets/plugins/html-filter.plugin.cjs +0 -47
- package/dist/commonjs/presets/plugins/html-filter.plugin.cjs.map +0 -1
- package/dist/commonjs/presets/plugins/meta.cjs +0 -40
- package/dist/commonjs/presets/plugins/meta.cjs.map +0 -1
- package/dist/commonjs/presets/plugins/multiline-blockquote/multiline-blockquote.plugin.cjs +0 -15
- package/dist/commonjs/presets/plugins/multiline-blockquote/multiline-blockquote.plugin.cjs.map +0 -1
- package/dist/commonjs/presets/plugins/multiline-blockquote/multiline-blockquote.rule.cjs +0 -44
- package/dist/commonjs/presets/plugins/multiline-blockquote/multiline-blockquote.rule.cjs.map +0 -1
- package/dist/commonjs/presets/plugins/simple-math.plugin.cjs +0 -151
- package/dist/commonjs/presets/plugins/simple-math.plugin.cjs.map +0 -1
- package/dist/commonjs/presets/plugins/simple-mermaid.plugin.cjs +0 -21
- package/dist/commonjs/presets/plugins/simple-mermaid.plugin.cjs.map +0 -1
- package/dist/commonjs/presets/plugins/toc/index.cjs +0 -187
- package/dist/commonjs/presets/plugins/toc/index.cjs.map +0 -1
- package/dist/commonjs/presets/plugins/toc/slugify.cjs +0 -8
- package/dist/commonjs/presets/plugins/toc/slugify.cjs.map +0 -1
- package/dist/commonjs/presets/plugins/toc/toc-item.cjs +0 -3
- package/dist/commonjs/presets/plugins/toc/toc-item.cjs.map +0 -1
- package/dist/commonjs/presets/plugins/toc/toc-option.cjs +0 -18
- package/dist/commonjs/presets/plugins/toc/toc-option.cjs.map +0 -1
- package/dist/commonjs/presets/plugins/unique-custom-id.cjs +0 -30
- package/dist/commonjs/presets/plugins/unique-custom-id.cjs.map +0 -1
- package/dist/es2015/index.mjs.map +0 -1
- package/dist/es2015/math/factory.mjs +0 -13
- package/dist/es2015/math/factory.mjs.map +0 -1
- package/dist/es2015/math/impl.mjs +0 -161
- package/dist/es2015/math/impl.mjs.map +0 -1
- package/dist/es2015/math/index.mjs.map +0 -1
- package/dist/es2015/math/model.mjs +0 -20
- package/dist/es2015/math/model.mjs.map +0 -1
- package/dist/es2015/presets/index.mjs.map +0 -1
- package/dist/es2015/presets/option.mjs +0 -27
- package/dist/es2015/presets/option.mjs.map +0 -1
- package/dist/es2015/presets/plugins/highlight-code-lines.plugin.mjs +0 -49
- package/dist/es2015/presets/plugins/highlight-code-lines.plugin.mjs.map +0 -1
- package/dist/es2015/presets/plugins/html-filter.plugin.mjs +0 -43
- package/dist/es2015/presets/plugins/html-filter.plugin.mjs.map +0 -1
- package/dist/es2015/presets/plugins/meta.mjs +0 -36
- package/dist/es2015/presets/plugins/meta.mjs.map +0 -1
- package/dist/es2015/presets/plugins/multiline-blockquote/multiline-blockquote.plugin.mjs +0 -11
- package/dist/es2015/presets/plugins/multiline-blockquote/multiline-blockquote.plugin.mjs.map +0 -1
- package/dist/es2015/presets/plugins/multiline-blockquote/multiline-blockquote.rule.mjs +0 -40
- package/dist/es2015/presets/plugins/multiline-blockquote/multiline-blockquote.rule.mjs.map +0 -1
- package/dist/es2015/presets/plugins/simple-math.plugin.mjs +0 -147
- package/dist/es2015/presets/plugins/simple-math.plugin.mjs.map +0 -1
- package/dist/es2015/presets/plugins/simple-mermaid.plugin.mjs +0 -17
- package/dist/es2015/presets/plugins/simple-mermaid.plugin.mjs.map +0 -1
- package/dist/es2015/presets/plugins/toc/index.mjs +0 -184
- package/dist/es2015/presets/plugins/toc/index.mjs.map +0 -1
- package/dist/es2015/presets/plugins/toc/slugify.mjs +0 -5
- package/dist/es2015/presets/plugins/toc/slugify.mjs.map +0 -1
- package/dist/es2015/presets/plugins/toc/toc-item.mjs +0 -2
- package/dist/es2015/presets/plugins/toc/toc-item.mjs.map +0 -1
- package/dist/es2015/presets/plugins/toc/toc-option.mjs +0 -15
- package/dist/es2015/presets/plugins/toc/toc-option.mjs.map +0 -1
- package/dist/es2015/presets/plugins/unique-custom-id.mjs +0 -27
- package/dist/es2015/presets/plugins/unique-custom-id.mjs.map +0 -1
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
import { defaultTocOption } from './toc-option';
|
|
2
|
-
const defaults = defaultTocOption;
|
|
3
|
-
const findHeadlineElements = (levels, tokens, options, md, env) => {
|
|
4
|
-
const headings = [];
|
|
5
|
-
let currentHeading = null;
|
|
6
|
-
tokens.forEach(token => {
|
|
7
|
-
if (token.type === 'heading_open') {
|
|
8
|
-
const id = findExistingIdAttr(token);
|
|
9
|
-
const level = parseInt(token.tag.toLowerCase().replace('h', ''), 10);
|
|
10
|
-
if (levels.indexOf(level) >= 0) {
|
|
11
|
-
currentHeading = {
|
|
12
|
-
level: level,
|
|
13
|
-
textContent: null,
|
|
14
|
-
anchor: id || null,
|
|
15
|
-
markdownContent: null,
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
else if (currentHeading && token.type === 'inline') {
|
|
20
|
-
const textContent = token.children
|
|
21
|
-
.filter(childToken => childToken.type === 'text' || childToken.type === 'code_inline')
|
|
22
|
-
.reduce((acc, t) => acc + t.content, '');
|
|
23
|
-
currentHeading.textContent = textContent;
|
|
24
|
-
currentHeading.markdownContent = md.renderer.renderInline(token.children, options, env);
|
|
25
|
-
if (!currentHeading.anchor) {
|
|
26
|
-
currentHeading.anchor = options.slugify(textContent, token.content);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
else if (token.type === 'heading_close') {
|
|
30
|
-
if (currentHeading) {
|
|
31
|
-
headings.push(currentHeading);
|
|
32
|
-
}
|
|
33
|
-
currentHeading = null;
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
return headings;
|
|
37
|
-
};
|
|
38
|
-
const findExistingIdAttr = (token) => {
|
|
39
|
-
if (token && token.attrs && token.attrs.length > 0) {
|
|
40
|
-
const idAttr = token.attrs.find(attr => {
|
|
41
|
-
if (Array.isArray(attr) && attr.length >= 2) {
|
|
42
|
-
return attr[0] === 'id';
|
|
43
|
-
}
|
|
44
|
-
return false;
|
|
45
|
-
});
|
|
46
|
-
if (idAttr && Array.isArray(idAttr) && idAttr.length >= 2) {
|
|
47
|
-
const [, val] = idAttr;
|
|
48
|
-
return val;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
return null;
|
|
52
|
-
};
|
|
53
|
-
function getMinLevel(headlineItems) {
|
|
54
|
-
return Math.min(...headlineItems.map(item => item.level));
|
|
55
|
-
}
|
|
56
|
-
const addListItem = (level, text, anchor, rootNode) => {
|
|
57
|
-
const listItem = {
|
|
58
|
-
level,
|
|
59
|
-
text,
|
|
60
|
-
anchor,
|
|
61
|
-
children: [],
|
|
62
|
-
parent: rootNode,
|
|
63
|
-
};
|
|
64
|
-
rootNode.children.push(listItem);
|
|
65
|
-
return listItem;
|
|
66
|
-
};
|
|
67
|
-
const flatHeadlineItemsToNestedTree = (headlineItems) => {
|
|
68
|
-
const toc = {
|
|
69
|
-
level: getMinLevel(headlineItems) - 1,
|
|
70
|
-
anchor: null,
|
|
71
|
-
text: null,
|
|
72
|
-
children: [],
|
|
73
|
-
parent: null,
|
|
74
|
-
};
|
|
75
|
-
let currentRootNode = toc;
|
|
76
|
-
let prevListItem = currentRootNode;
|
|
77
|
-
headlineItems.forEach(headlineItem => {
|
|
78
|
-
if (headlineItem.level > prevListItem.level) {
|
|
79
|
-
Array.from({ length: headlineItem.level - prevListItem.level }).forEach(_ => {
|
|
80
|
-
currentRootNode = prevListItem;
|
|
81
|
-
prevListItem = addListItem(headlineItem.level, null, null, currentRootNode);
|
|
82
|
-
});
|
|
83
|
-
prevListItem.text = headlineItem.markdownContent;
|
|
84
|
-
prevListItem.anchor = headlineItem.anchor;
|
|
85
|
-
}
|
|
86
|
-
else if (headlineItem.level === prevListItem.level) {
|
|
87
|
-
prevListItem = addListItem(headlineItem.level, headlineItem.markdownContent, headlineItem.anchor, currentRootNode);
|
|
88
|
-
}
|
|
89
|
-
else if (headlineItem.level < prevListItem.level) {
|
|
90
|
-
for (let i = 0; i < prevListItem.level - headlineItem.level; i++) {
|
|
91
|
-
currentRootNode = currentRootNode.parent;
|
|
92
|
-
}
|
|
93
|
-
prevListItem = addListItem(headlineItem.level, headlineItem.markdownContent, headlineItem.anchor, currentRootNode);
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
return toc;
|
|
97
|
-
};
|
|
98
|
-
const tocItemToHtml = (tocItem, options, md) => {
|
|
99
|
-
return ('<' +
|
|
100
|
-
options.listType +
|
|
101
|
-
'>' +
|
|
102
|
-
tocItem.children
|
|
103
|
-
.map(childItem => {
|
|
104
|
-
let li = '<li>';
|
|
105
|
-
let anchor = childItem.anchor;
|
|
106
|
-
if (options && options.transformLink) {
|
|
107
|
-
anchor = options.transformLink(anchor);
|
|
108
|
-
}
|
|
109
|
-
let text = childItem.text ? options.format(childItem.text, md, anchor) : null;
|
|
110
|
-
li += anchor ? `<a href="#${anchor}">${text}</a>` : text || '';
|
|
111
|
-
return li + (childItem.children.length > 0 ? tocItemToHtml(childItem, options, md) : '') + '</li>';
|
|
112
|
-
})
|
|
113
|
-
.join('') +
|
|
114
|
-
'</' +
|
|
115
|
-
options.listType +
|
|
116
|
-
'>');
|
|
117
|
-
};
|
|
118
|
-
const plugin = (md, o) => {
|
|
119
|
-
const options = Object.assign({}, defaults, o);
|
|
120
|
-
const tocRegexp = options.markerPattern;
|
|
121
|
-
let gState;
|
|
122
|
-
const toc = (state, silent) => {
|
|
123
|
-
let token;
|
|
124
|
-
let match;
|
|
125
|
-
if (state.src.charCodeAt(state.pos) !== 0x5b) {
|
|
126
|
-
return false;
|
|
127
|
-
}
|
|
128
|
-
if (silent) {
|
|
129
|
-
return false;
|
|
130
|
-
}
|
|
131
|
-
match = tocRegexp.exec(state.src.substr(state.pos));
|
|
132
|
-
match = !match
|
|
133
|
-
? []
|
|
134
|
-
: match.filter(function (m) {
|
|
135
|
-
return m;
|
|
136
|
-
});
|
|
137
|
-
if (match.length < 1) {
|
|
138
|
-
return false;
|
|
139
|
-
}
|
|
140
|
-
token = state.push('toc_open', 'toc', 1);
|
|
141
|
-
token.markup = '[[toc]]';
|
|
142
|
-
token = state.push('toc_body', '', 0);
|
|
143
|
-
token = state.push('toc_close', 'toc', -1);
|
|
144
|
-
const newline = state.src.indexOf('\n', state.pos);
|
|
145
|
-
if (newline !== -1) {
|
|
146
|
-
state.pos = newline;
|
|
147
|
-
}
|
|
148
|
-
else {
|
|
149
|
-
state.pos = state.pos + state.posMax + 1;
|
|
150
|
-
}
|
|
151
|
-
return true;
|
|
152
|
-
};
|
|
153
|
-
md.renderer.rules.toc_open = (tokens, index) => {
|
|
154
|
-
let tocOpenHtml = '<div class="' + options.containerClass + '">';
|
|
155
|
-
if (options.containerHeaderHtml) {
|
|
156
|
-
tocOpenHtml += options.containerHeaderHtml;
|
|
157
|
-
}
|
|
158
|
-
return tocOpenHtml;
|
|
159
|
-
};
|
|
160
|
-
md.renderer.rules.toc_close = (tokens, index) => {
|
|
161
|
-
let tocFooterHtml = '';
|
|
162
|
-
if (options.containerFooterHtml) {
|
|
163
|
-
tocFooterHtml = options.containerFooterHtml;
|
|
164
|
-
}
|
|
165
|
-
return tocFooterHtml + '</div>';
|
|
166
|
-
};
|
|
167
|
-
md.renderer.rules.toc_body = (tokens, index, opt, env) => {
|
|
168
|
-
if (options.forceFullToc) {
|
|
169
|
-
throw 'forceFullToc was removed in version 0.5.0. For more information, see https://github.com/Oktavilla/markdown-it-table-of-contents/pull/41';
|
|
170
|
-
}
|
|
171
|
-
else {
|
|
172
|
-
const headlineItems = findHeadlineElements(options.includeLevel, gState.tokens, options, md, env);
|
|
173
|
-
const toc = flatHeadlineItemsToNestedTree(headlineItems);
|
|
174
|
-
return tocItemToHtml(toc, options, md);
|
|
175
|
-
}
|
|
176
|
-
};
|
|
177
|
-
md.core.ruler.push('grab_state', state => {
|
|
178
|
-
gState = state;
|
|
179
|
-
return true;
|
|
180
|
-
});
|
|
181
|
-
md.inline.ruler.after('emphasis', 'toc', toc);
|
|
182
|
-
};
|
|
183
|
-
export { plugin as TocPlugin };
|
|
184
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/presets/plugins/toc/index.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,gBAAgB,EAAa,MAAM,cAAc,CAAC;AAI3D,MAAM,QAAQ,GAAG,gBAAgB,CAAC;AAkClC,MAAM,oBAAoB,GAAG,CAAC,MAAM,EAAE,MAAe,EAAE,OAAO,EAAE,EAAc,EAAE,GAAQ,EAAE,EAAE;IACxF,MAAM,QAAQ,GAAG,EAAE,CAAC;IACpB,IAAI,cAAc,GAAiB,IAAI,CAAC;IAExC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QACnB,IAAI,KAAK,CAAC,IAAI,KAAK,cAAc,EAAE;YAC/B,M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;IAGF,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,YAAY,EAAE,KAAK,CAAC,EAAE;QACrC,MAAM,GAAG,KAAK,CAAC;QACf,OAAO,IAAI,CAAC;IAChB,CAAC,CAAC,CAAC;IAGH,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;AAClD,CAAC,CAAC;AAEF,OAAO,EAAE,MAAM,IAAI,SAAS,EAAE,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"slugify.js","sourceRoot":"","sources":["../../../../../src/presets/plugins/toc/slugify.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG,UAAU,CAAC;IACvB,OAAO,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC;AACnF,CAAC,CAAC;AAEF,OAAO,EAAE,OAAO,EAAE,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"toc-item.js","sourceRoot":"","sources":["../../../../../src/presets/plugins/toc/toc-item.ts"],"names":[],"mappings":""}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { slugify } from './slugify';
|
|
2
|
-
const defaultTocOption = {
|
|
3
|
-
includeLevel: [1, 2, 3, 4, 5, 6],
|
|
4
|
-
containerClass: 'toc',
|
|
5
|
-
slugify: slugify,
|
|
6
|
-
markerPattern: /\[TOC]/im,
|
|
7
|
-
listType: 'ul',
|
|
8
|
-
format: content => content.replace(/<\/?a.*?>/g, ''),
|
|
9
|
-
forceFullToc: false,
|
|
10
|
-
containerHeaderHtml: `<div class="toc-container-header">目录</div>`,
|
|
11
|
-
containerFooterHtml: undefined,
|
|
12
|
-
transformLink: undefined,
|
|
13
|
-
};
|
|
14
|
-
export { defaultTocOption };
|
|
15
|
-
//# sourceMappingURL=toc-option.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"toc-option.js","sourceRoot":"","sources":["../../../../../src/presets/plugins/toc/toc-option.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAepC,MAAM,gBAAgB,GAAG;IACrB,YAAY,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IAChC,cAAc,EAAE,KAAK;IACrB,OAAO,EAAE,OAAO;IAChB,aAAa,EAAE,UAAU;IACzB,QAAQ,EAAE,IAAI;IACd,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC;IACpD,YAAY,EAAE,KAAK;IACnB,mBAAmB,EAAE,4CAA4C;IACjE,mBAAmB,EAAE,SAAS;IAC9B,aAAa,EAAE,SAAS;CAC3B,CAAC;AAEF,OAAO,EAAa,gBAAgB,EAAE,CAAC"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
const attrPluginName = 'curly_attributes';
|
|
2
|
-
const uniqueCustomIdAttr = state => {
|
|
3
|
-
const { tokens } = state;
|
|
4
|
-
let map;
|
|
5
|
-
tokens
|
|
6
|
-
.filter(x => !!x.attrGet('id'))
|
|
7
|
-
.forEach(token => {
|
|
8
|
-
map !== null && map !== void 0 ? map : (map = {});
|
|
9
|
-
const idAttrValue = token.attrGet('id');
|
|
10
|
-
if (map.hasOwnProperty(idAttrValue)) {
|
|
11
|
-
const count = map[idAttrValue];
|
|
12
|
-
token.attrSet('id', `${idAttrValue}-${count}`);
|
|
13
|
-
map[idAttrValue] = count + 1;
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
map[idAttrValue] = 1;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
map = undefined;
|
|
20
|
-
};
|
|
21
|
-
const plugin = (md, opt) => {
|
|
22
|
-
if (md.core.ruler.getRules('').some(x => x.name === attrPluginName) != null) {
|
|
23
|
-
md.core.ruler.after(attrPluginName, 'unique_custom_id_attribute', uniqueCustomIdAttr, opt);
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
export { plugin as UniqueCustomIdAttrs };
|
|
27
|
-
//# sourceMappingURL=unique-custom-id.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"unique-custom-id.js","sourceRoot":"","sources":["../../../../src/presets/plugins/unique-custom-id.ts"],"names":[],"mappings":"AAGA,MAAM,cAAc,GAAG,kBAAkB,CAAC;AAE1C,MAAM,kBAAkB,GAAa,KAAK,CAAC,EAAE;IACzC,MAAM,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC;IACzB,IAAI,GAA0C,CAAC;IAC/C,MAAM;SACD,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;SAC9B,OAAO,CAAC,KAAK,CAAC,EAAE;QACb,GAAG,aAAH,GAAG,cAAH,GAAG,IAAH,GAAG,GAAK,EAAE,EAAC;QACX,MAAM,WAAW,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACxC,IAAI,GAAG,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE;YACjC,MAAM,KAAK,GAAG,GAAG,CAAC,WAAW,CAAC,CAAC;YAC/B,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,WAAW,IAAI,KAAK,EAAE,CAAC,CAAC;YAC/C,GAAG,CAAC,WAAW,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC;SAChC;aAAM;YACH,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;SACxB;IACL,CAAC,CAAC,CAAC;IACP,GAAG,GAAG,SAAS,CAAC;AACpB,CAAC,CAAC;AAEF,MAAM,MAAM,GAAsB,CAAC,EAAE,EAAE,GAAG,EAAE,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