@anyblock/remark-any-block 1.0.3-beta1 → 3.5.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.
@@ -38,6 +38,16 @@ function jsdom_disable() {
38
38
  global.history = void 0;
39
39
  global.document = void 0;
40
40
  }
41
+ const ABCSetting = {
42
+ env: "obsidian",
43
+ // 某些环境的独占 api,其他环境用不上
44
+ obsidian: {
45
+ global_app: null,
46
+ global_ctx: null,
47
+ mermaid: void 0,
48
+ markmap_event: void 0
49
+ }
50
+ };
41
51
  const ABReg = {
42
52
  /**
43
53
  * AB块头部
@@ -59,9 +69,9 @@ const ABReg = {
59
69
  * - 不允许 `::` 是避免与 dataview 的 inline property 冲突
60
70
  */
61
71
  // 有前缀版本(给选择器用)
62
- reg_header: /^((\s|>\s|-\s|\*\s|\+\s)*)(%%)?(\[((?!toc|TOC|\!|< )[\|\!#:;\(\)\s0-9a-zA-Z\u4e00-\u9fa5](?!.*::).*)\]):?(%%)?\s*$/,
72
+ reg_header: /^((\s|>\s|-\s|\*\s|\+\s)*)(%%)?(\[((?!toc|TOC|\!|< )[\|\!#:;\(\)\s0-9a-zA-Z\u4e00-\u9fa5](?!.*::).*)\]):?\3\s*$/,
63
73
  // 可以用空`|`来解除首字符限制。(`|`注意:可以用来弄严格模式,`#`注意:建议后面空一格避免变成“标签”,`!`注意:别易误触发 `> [!note]`
64
- reg_header_up: /^((\s|>\s|-\s|\*\s|\+\s)*)(%%)?(\[((?!toc|TOC|\!)< [\|\!#:;\(\)\s0-9a-zA-Z\u4e00-\u9fa5](?!.*::).*)\]):?(%%)?\s*$/,
74
+ reg_header_up: /^((\s|>\s|-\s|\*\s|\+\s)*)(%%)?(\[((?!toc|TOC|\!)< [\|\!#:;\(\)\s0-9a-zA-Z\u4e00-\u9fa5](?!.*::).*)\]):?\3\s*$/,
65
75
  // 向上检查标志的 头部选择器
66
76
  reg_mdit_head: /^((\s|>\s|-\s|\*\s|\+\s)*)(::::*)\s?(.*)/,
67
77
  reg_mdit_tail: /^((\s|>\s|-\s|\*\s|\+\s)*)(::::*)/,
@@ -74,8 +84,8 @@ const ABReg = {
74
84
  reg_heading: /^((\s|>\s|-\s|\*\s|\+\s)*)(\#+\s)(.*)/,
75
85
  reg_table: /^((\s|>\s|-\s|\*\s|\+\s)*)(\|(.*)\|)/,
76
86
  // 无前缀版本(给处理器用,处理器不需要处理前缀,前缀在选择器阶段已经被去除了)
77
- reg_header_noprefix: /^((\s)*)(%%)?(\[((?!toc|TOC|\!|< )[\|\!#:;\(\)\s0-9a-zA-Z\u4e00-\u9fa5](?!.*::).*)\]):?(%%)?\s*$/,
78
- reg_header_up_noprefix: /^((\s)*)(%%)?(\[((?!toc|TOC|\!)< [\|\!#:;\(\)\s0-9a-zA-Z\u4e00-\u9fa5](?!.*::).*)\]):?(%%)?\s*$/,
87
+ reg_header_noprefix: /^((\s)*)(%%)?(\[((?!toc|TOC|\!|< )[\|\!#:;\(\)\s0-9a-zA-Z\u4e00-\u9fa5](?!.*::).*)\]):?\3\s*$/,
88
+ reg_header_up_noprefix: /^((\s)*)(%%)?(\[((?!toc|TOC|\!)< [\|\!#:;\(\)\s0-9a-zA-Z\u4e00-\u9fa5](?!.*::).*)\]):?\3\s*$/,
79
89
  reg_mdit_head_noprefix: /^((\s)*)(::::*)\s?(.*)/,
80
90
  reg_mdit_tail_noprefix: /^((\s)*)(::::*)/,
81
91
  reg_list_noprefix: /^((\s)*)(-\s|\*\s|\+\s)(.*)/,
@@ -88,12 +98,6 @@ const ABReg = {
88
98
  inline_split: /\| |, |, |\. |。 |: |: /
89
99
  // 内联切分。`|`或全角符号+一空格,半角符号+两空格 (后者由于空格压缩,若经历了重渲染可能有问题)
90
100
  };
91
- const ABCSetting = {
92
- env: "obsidian",
93
- // MarkdownPostProcessorContext类型, obsidian专用
94
- mermaid: void 0
95
- // obsidian专用,表示使用哪种方式渲染mermaid
96
- };
97
101
  const convert = (
98
102
  // Note: overloads in JSDoc can’t yet use different `@template`s.
99
103
  /**
@@ -368,11 +372,11 @@ function autoABAlias(header, selectorName, content) {
368
372
  } else if (selectorName == "table" || ABReg.reg_table_noprefix.test(content.trimStart())) {
369
373
  header = "|table_140lne" + header;
370
374
  }
371
- for (const item of ABAlias_json) {
375
+ for (const item of get_ABAlias_iter()) {
372
376
  header = header.replace(item.regex, item.replacement);
373
377
  }
374
378
  for (const item of ABAlias_json_withSub) {
375
- header = header.replace(item.regex, (match2, ...groups) => {
379
+ header = header.replace(item.regex, (_match, ...groups) => {
376
380
  return item.replacement.replace(/\$(\d+)/g, (_, number) => groups[number - 1] ?? "");
377
381
  });
378
382
  }
@@ -405,15 +409,39 @@ const ABAlias_json_withSub = [
405
409
  // 注意避免和原上/上面的callout语法冲突,以及自身递归
406
410
  ];
407
411
  const ABAlias_json_mdit = [
408
- { regex: /\|:::_140lne\|(2?tabs?|标签页?)\|/, replacement: "|mditTabs|" },
412
+ { regex: /\|:::_140lne\|((?:mdit2|2)?tabs?|标签页?)\|/, replacement: "|mditTabs|" },
409
413
  { regex: "|:::_140lne|demo|", replacement: "|mditDemo|" },
410
414
  { regex: "|:::_140lne|abDemo|", replacement: "|mditABDemo|" },
411
- { regex: /\|:::_140lne\|(2?col|分栏)\|/, replacement: "|mditCol|" },
412
- { regex: /\|:::_140lne\|(2?card|卡片)\|/, replacement: "|mditCard|" },
413
- { regex: /\|:::_140lne\|(2?chat|聊天)\|/, replacement: "|mditChat|code(chat)|" }
415
+ { regex: /\|:::_140lne\|((?:mdit2|2)?col|分栏)\|/, replacement: "|mditCol|" },
416
+ { regex: /\|:::_140lne\|((?:mdit2|2)?card|卡片)\|/, replacement: "|mditCard|" },
417
+ { regex: /\|:::_140lne\|((?:mdit2|2)?chat|聊天)\|/, replacement: "|mditChat|code(chat)|" },
418
+ //
419
+ // {regex: /\|:::_140lne\|2?(timeline|时间线)\|/, replacement: "|title2timeline|"},
420
+ // {regex: /\|:::_140lne\|2?(tabs?|标签页?)\||\|title2tabs?\|/, replacement: "|title2c2listdata|c2listdata2tab|"},
421
+ // {regex: /\|:::_140lne\|2?(col|分栏)\||\|title2col\|/, replacement: "|title2c2listdata|c2listdata2items|addClass(ab-col)|"},
422
+ // {regex: /\|:::_140lne\|2?(card|卡片)\||\|title2card\|/, replacement: "|title2c2listdata|c2listdata2items|addClass(ab-card)|addClass(ab-lay-vfall)|"},
423
+ // {regex: /\|:::_140lne\|2?(nodes?|节点)\||\|(title2node|title2abMindmap)\|/, replacement: "|title2listdata|listdata2strict|listdata2nodes|"},
424
+ // list - 多叉多层树
425
+ { regex: /\|:::_140lne\|(?:mdit2|2)?(mermaid|flow|流程图)\|/, replacement: "|mdit2list|list2mermaid|" },
426
+ { regex: /\|:::_140lne\|(?:mdit2|2)?(mehrmaid|mdmermaid)\|/, replacement: "|mdit2list|list2mehrmaidText|code(mehrmaid)|" },
427
+ { regex: /\|:::_140lne\|(?:mdit2|2)?(puml)?(plantuml|mindmap|脑图|思维导图)\|/, replacement: "|mdit2list|list2pumlMindmap|" },
428
+ { regex: /\|:::_140lne\|(?:mdit2|2)?(markmap|mdMindmap|md脑图|md思维导图)\|/, replacement: "|mdit2list|list2markmap|" },
429
+ { regex: /\|:::_140lne\|(?:mdit2|2)?(wbs|(工作)?分解(图|结构))\|/, replacement: "|mdit2list|list2pumlWBS|" },
430
+ { regex: /\|:::_140lne\|(?:mdit2|2)?(table|multiWayTable|multiCrossTable|表格?|多叉表格?|跨行表格?)\|/, replacement: "|mdit2Listdata|listdata2strict|listdata2table|" },
431
+ // list - lt树 (属于多层一叉树)
432
+ { regex: /\|:::_140lne\|(?:mdit2|2)?(lt|listTable|treeTable|listGrid|treeGrid|列表格|树形表格?)\|/, replacement: "|mdit2list|list2lt|" },
433
+ { regex: /\|:::_140lne\|2?(list|列表)\|/, replacement: "|mdit2list|list2lt|addClass(ab-listtable-likelist)|" },
434
+ { regex: /\|:::_140lne\|(?:mdit2|2)?(dir|dirTree|目录树?|目录结构)\|/, replacement: "|mdit2list|list2dt|" },
435
+ // list - 二层树
436
+ { regex: /\|:::_140lne\|(fakeList|仿列表)\|/, replacement: "|mdit2list|list2table|addClass(ab-table-fc)|addClass(ab-table-likelist)|" },
437
+ // 至后
438
+ { regex: "|mdit2list|", replacement: "|mdit2listdata|listdata2strict|listdata2list|" },
439
+ { regex: "|mdit2List|", replacement: "|mdit2Listdata|listdata2strict|listdata2list|" }
414
440
  ];
415
441
  const ABAlias_json_title = [
416
- { regex: "|title2list|", replacement: "|title2listdata|listdata2strict|listdata2list|" },
442
+ // 至前,特殊
443
+ { regex: "|heading2", replacement: "|title2" },
444
+ { regex: "|h2", replacement: "|title2" },
417
445
  // title - list&title
418
446
  { regex: /\|heading_140lne\|2?(timeline|时间线)\|/, replacement: "|title2timeline|" },
419
447
  { regex: /\|heading_140lne\|2?(tabs?|标签页?)\||\|title2tabs?\|/, replacement: "|title2c2listdata|c2listdata2tab|" },
@@ -426,13 +454,15 @@ const ABAlias_json_title = [
426
454
  { regex: /\|heading_140lne\|2?(puml)?(plantuml|mindmap|脑图|思维导图)\|/, replacement: "|title2list|list2pumlMindmap|" },
427
455
  { regex: /\|heading_140lne\|2?(markmap|mdMindmap|md脑图|md思维导图)\|/, replacement: "|title2list|list2markmap|" },
428
456
  { regex: /\|heading_140lne\|2?(wbs|(工作)?分解(图|结构))\|/, replacement: "|title2list|list2pumlWBS|" },
429
- { regex: /\|heading_140lne\|2?(table|multiWayTable|multiCrossTable|表格?|多叉表格?|跨行表格?)\|/, replacement: "|title2list|list2table|" },
457
+ { regex: /\|heading_140lne\|2?(table|multiWayTable|multiCrossTable|表格?|多叉表格?|跨行表格?)\|/, replacement: "|title2Listdata|listdata2strict|listdata2table|" },
430
458
  // list - lt树 (属于多层一叉树)
431
459
  { regex: /\|heading_140lne\|2?(lt|listTable|treeTable|listGrid|treeGrid|列表格|树形表格?)\|/, replacement: "|title2list|list2lt|" },
432
460
  { regex: /\|heading_140lne\|2?(list|列表)\|/, replacement: "|title2list|list2lt|addClass(ab-listtable-likelist)|" },
433
461
  { regex: /\|heading_140lne\|2?(dir|dirTree|目录树?|目录结构)\|/, replacement: "|title2list|list2dt|" },
434
462
  // list - 二层树
435
- { regex: /\|heading_140lne\|(fakeList|仿列表)\|/, replacement: "|title2list|list2table|addClass(ab-table-fc)|addClass(ab-table-likelist)|" }
463
+ { regex: /\|heading_140lne\|(fakeList|仿列表)\|/, replacement: "|title2list|list2table|addClass(ab-table-fc)|addClass(ab-table-likelist)|" },
464
+ // 至后
465
+ { regex: "|title2list|", replacement: "|title2listdata|listdata2strict|listdata2list|" }
436
466
  ];
437
467
  const ABAlias_json_list = [
438
468
  // 特殊
@@ -516,7 +546,9 @@ const ABAlias_json_general = [
516
546
  { regex: "|超超小字|", replacement: "|addClass(ab-custom-font-smallxx)|" },
517
547
  { regex: "|加粗|", replacement: "|addClass(ab-custom-font-bold)|" }
518
548
  ];
519
- const ABAlias_json_default = [
549
+ const ABAlias_user = [];
550
+ const ABAlias_pro = [];
551
+ const ABAlias_default = [
520
552
  ...ABAlias_json_mdit,
521
553
  ...ABAlias_json_title,
522
554
  ...ABAlias_json_list,
@@ -526,10 +558,11 @@ const ABAlias_json_default = [
526
558
  ...ABAlias_json_general
527
559
  // 这个放最后
528
560
  ];
529
- let ABAlias_json = [
530
- ...ABAlias_json_default
531
- // 设置决定是否停用
532
- ];
561
+ function* get_ABAlias_iter() {
562
+ yield* ABAlias_user;
563
+ yield* ABAlias_pro;
564
+ yield* ABAlias_default;
565
+ }
533
566
  const ABAlias_json_end = [
534
567
  { regex: "|:::_140lne", replacement: "" },
535
568
  { regex: "|heading_140lne", replacement: "" },
@@ -586,24 +619,18 @@ class ABConvertManager {
586
619
  * @param header 转换方式
587
620
  * @param content 要转换的初始文本 (无前缀版本,前缀在选择器环节已经删除了)
588
621
  * @param selectorName 选择器名,空表示未知
589
- * @return 等于el,无用,后面可以删了
590
622
  */
591
623
  static autoABConvert(el, header, content, selectorName = "", ctx) {
592
- let prev_result = content;
593
- let prev_type = "string";
594
- let prev_type2 = ABConvert_IOEnum.text;
595
- let prev_processor;
596
624
  let prev2 = {
597
- // 组合在一起是为了引用传参
598
- prev_result,
599
- prev_type,
600
- prev_type2,
601
- prev_processor
625
+ prev_result: content,
626
+ prev_type: "string",
627
+ prev_type2: ABConvert_IOEnum.text,
628
+ prev_processor: void 0
602
629
  };
603
630
  {
604
- header = autoABAlias(header, selectorName, prev_result);
631
+ header = autoABAlias(header, selectorName, prev2.prev_result);
605
632
  let list_header = header.split("|");
606
- prev_result = this.autoABConvert_runConvert(el, list_header, prev2, ctx);
633
+ this.autoABConvert_runConvert(el, list_header, prev2, ctx);
607
634
  this.autoABConvert_last(el, header, selectorName, prev2, ctx);
608
635
  }
609
636
  }
@@ -662,7 +689,12 @@ class ABConvertManager {
662
689
  break;
663
690
  }
664
691
  }
665
- prev2.prev_result = abReplaceProcessor.process(el, item_header, prev2.prev_result, ctx);
692
+ try {
693
+ prev2.prev_result = abReplaceProcessor.process(el, item_header, prev2.prev_result, ctx);
694
+ } catch (e) {
695
+ console.error(`处理器执行错误, id:${abReplaceProcessor.id}, header:${item_header}, error:`, e);
696
+ break;
697
+ }
666
698
  prev2.prev_type = typeof prev2.prev_result;
667
699
  prev2.prev_type2 = abReplaceProcessor.process_return;
668
700
  prev2.prev_processor = abReplaceProcessor.process;
@@ -676,7 +708,7 @@ class ABConvertManager {
676
708
  /**
677
709
  * 子函数,后处理/尾处理,主要进行末尾追加指令
678
710
  */
679
- static autoABConvert_last(el, header, selectorName, prev2, ctx) {
711
+ static autoABConvert_last(el, _header, _selectorName, prev2, _ctx) {
680
712
  if (prev2.prev_type == "string" && prev2.prev_type2 == ABConvert_IOEnum.text) {
681
713
  const subEl = document.createElement("div");
682
714
  el.appendChild(subEl);
@@ -684,7 +716,7 @@ class ABConvertManager {
684
716
  prev2.prev_result = el;
685
717
  prev2.prev_type = "object";
686
718
  prev2.prev_type2 = ABConvert_IOEnum.el;
687
- prev2.process = "md";
719
+ prev2.prev_processor = "md";
688
720
  } else if (prev2.prev_type == "string" && prev2.prev_type2 == ABConvert_IOEnum.json) {
689
721
  const code_str = "```json\n" + prev2.prev_result + "\n```\n";
690
722
  const subEl = document.createElement("div");
@@ -693,7 +725,7 @@ class ABConvertManager {
693
725
  prev2.prev_result = el;
694
726
  prev2.prev_type = "object";
695
727
  prev2.prev_type2 = ABConvert_IOEnum.el;
696
- prev2.process = "show_json";
728
+ prev2.prev_processor = "show_json";
697
729
  } else if (prev2.prev_type == "object" && (prev2.prev_type2 == ABConvert_IOEnum.list_stream || prev2.prev_type2 == ABConvert_IOEnum.c2list_stream || prev2.prev_type2 == ABConvert_IOEnum.json)) {
698
730
  const code_str = "```json\n" + JSON.stringify(prev2.prev_result, null, 2) + "\n```\n";
699
731
  const subEl = document.createElement("div");
@@ -702,7 +734,7 @@ class ABConvertManager {
702
734
  prev2.prev_result = el;
703
735
  prev2.prev_type = "object";
704
736
  prev2.prev_type2 = ABConvert_IOEnum.el;
705
- prev2.process = "show_listStream";
737
+ prev2.prev_processor = "show_listStream";
706
738
  } else if (prev2.prev_type == "object" && prev2.prev_type2 == ABConvert_IOEnum.el) {
707
739
  return prev2;
708
740
  } else {
@@ -1146,7 +1178,7 @@ class ListProcess {
1146
1178
  }
1147
1179
  }
1148
1180
  /**
1149
- * 标题大纲转列表数据(@todo 正文的level+10,要减掉)
1181
+ * 标题大纲转列表数据
1150
1182
  *
1151
1183
  * @detail
1152
1184
  * 这里要将标题、正文、列表 的等级合为一块,所以存在偏移值:
@@ -1155,8 +1187,13 @@ class ListProcess {
1155
1187
  * 2. 正文等级, = 0, 取值[+1,+Infi]
1156
1188
  * 3. 列表等级, = `(.*)-`个数+1, 取值[0]
1157
1189
  *
1190
+ * (比较旧版是正文+10,列表+11,后来允许标题等级为负数。这样方便很多)
1191
+ *
1192
+ * @fine_mode 精细拆分模式
1193
+ * - true: 会将正文和列表拆分成多个节点
1194
+ * - false: 会将标题+正文+列表合并成一个节点
1158
1195
  */
1159
- static title2data(text2) {
1196
+ static title2data(text2, fine_mode = true) {
1160
1197
  let list_itemInfo = [];
1161
1198
  const list_text = text2.split("\n");
1162
1199
  let mul_mode = "";
@@ -1166,12 +1203,23 @@ class ListProcess {
1166
1203
  const match2 = line.match(ABReg.reg_code);
1167
1204
  if (match2 && match2[3]) {
1168
1205
  codeBlockFlag = match2[1] + match2[3];
1169
- list_itemInfo[list_itemInfo.length - 1].content = list_itemInfo[list_itemInfo.length - 1].content + "\n" + line;
1206
+ if (!fine_mode && list_itemInfo.length > 0) {
1207
+ list_itemInfo[list_itemInfo.length - 1].content += "\n" + line;
1208
+ } else if (mul_mode === "heading" || mul_mode === "") {
1209
+ removeTailBlank();
1210
+ list_itemInfo.push({
1211
+ content: line,
1212
+ level: 0
1213
+ });
1214
+ mul_mode = "para";
1215
+ } else {
1216
+ list_itemInfo[list_itemInfo.length - 1].content += "\n" + line;
1217
+ }
1170
1218
  continue;
1171
1219
  }
1172
1220
  } else {
1173
1221
  if (line.indexOf(codeBlockFlag) == 0) codeBlockFlag = "";
1174
- list_itemInfo[list_itemInfo.length - 1].content = list_itemInfo[list_itemInfo.length - 1].content + "\n" + line;
1222
+ list_itemInfo[list_itemInfo.length - 1].content += "\n" + line;
1175
1223
  continue;
1176
1224
  }
1177
1225
  const match_heading = line.match(ABReg.reg_heading_noprefix);
@@ -1179,32 +1227,133 @@ class ListProcess {
1179
1227
  if (match_heading && !match_heading[1]) {
1180
1228
  removeTailBlank();
1181
1229
  list_itemInfo.push({
1182
- content: match_heading[4],
1230
+ content: fine_mode ? match_heading[4] : line,
1231
+ // 可选是否把标题标志也放进去
1183
1232
  level: match_heading[3].length - 1 - 10
1184
1233
  });
1185
1234
  mul_mode = "heading";
1235
+ } else if (!fine_mode && list_itemInfo.length > 0) {
1236
+ list_itemInfo[list_itemInfo.length - 1].content += "\n" + line;
1237
+ continue;
1186
1238
  } else if (match_list) {
1187
1239
  removeTailBlank();
1188
1240
  list_itemInfo.push({
1189
1241
  content: match_list[4],
1190
1242
  level: match_list[1].length + 1
1191
- //+10
1192
1243
  });
1193
1244
  mul_mode = "list";
1194
- } else if (/^\S/.test(line) && mul_mode == "list") {
1195
- list_itemInfo[list_itemInfo.length - 1].content = list_itemInfo[list_itemInfo.length - 1].content + "\n" + line;
1245
+ } else if (mul_mode == "list" && /^\s/.test(line)) {
1246
+ list_itemInfo[list_itemInfo.length - 1].content += "\n" + line.trimStart();
1247
+ continue;
1196
1248
  } else {
1197
1249
  if (mul_mode == "para") {
1198
- list_itemInfo[list_itemInfo.length - 1].content = list_itemInfo[list_itemInfo.length - 1].content + "\n" + line;
1250
+ list_itemInfo[list_itemInfo.length - 1].content += "\n" + line;
1251
+ continue;
1199
1252
  } else if (/^\s*$/.test(line)) {
1200
1253
  continue;
1201
1254
  } else {
1255
+ removeTailBlank();
1202
1256
  list_itemInfo.push({
1203
1257
  content: line,
1204
1258
  level: 0
1205
- //+10
1206
1259
  });
1207
1260
  mul_mode = "para";
1261
+ continue;
1262
+ }
1263
+ }
1264
+ }
1265
+ removeTailBlank();
1266
+ return list_itemInfo;
1267
+ function removeTailBlank() {
1268
+ if (mul_mode == "para" || mul_mode == "list") {
1269
+ list_itemInfo[list_itemInfo.length - 1].content = list_itemInfo[list_itemInfo.length - 1].content.replace(/\s*$/, "");
1270
+ }
1271
+ }
1272
+ }
1273
+ /**
1274
+ * MarkdownIt 转列表数据
1275
+ *
1276
+ * @detail
1277
+ * 与 title2data 的逻辑基本相同
1278
+ *
1279
+ * 有很多写法变型和语法糖,所以逻辑比较复杂。
1280
+ * 具体设计详见 "docs/docs/dev docs/其他层级表示法.md"
1281
+ *
1282
+ * 支持:
1283
+ *
1284
+ * - 单行标题模式
1285
+ * - 多行标题模式
1286
+ * - 缺少分割标题模式
1287
+ *
1288
+ * @fine_mode 精细拆分模式
1289
+ * - true: 会将正文和列表拆分成多个节点
1290
+ * - false: 会将标题+正文+列表合并成一个节点
1291
+ */
1292
+ static mdit2data(text2, fine_mode = true) {
1293
+ let list_itemInfo = [];
1294
+ const list_text = text2.split("\n");
1295
+ let mul_mode = "";
1296
+ let codeBlockFlag = "";
1297
+ for (let line of list_text) {
1298
+ if (codeBlockFlag == "") {
1299
+ const match2 = line.match(ABReg.reg_code);
1300
+ if (match2 && match2[3]) {
1301
+ codeBlockFlag = match2[1] + match2[3];
1302
+ if (!fine_mode && list_itemInfo.length > 0) {
1303
+ list_itemInfo[list_itemInfo.length - 1].content += "\n" + line;
1304
+ } else if (mul_mode === "mdit" || mul_mode === "") {
1305
+ removeTailBlank();
1306
+ list_itemInfo.push({
1307
+ content: line,
1308
+ level: 0
1309
+ });
1310
+ mul_mode = "para";
1311
+ } else {
1312
+ list_itemInfo[list_itemInfo.length - 1].content += "\n" + line;
1313
+ }
1314
+ continue;
1315
+ }
1316
+ } else {
1317
+ if (line.indexOf(codeBlockFlag) == 0) codeBlockFlag = "";
1318
+ list_itemInfo[list_itemInfo.length - 1].content += "\n" + line;
1319
+ continue;
1320
+ }
1321
+ const match_mdit = line.match(/^(\s*)@(\d+)(?:\s+(.*))?$/);
1322
+ const match_list = line.match(ABReg.reg_list_noprefix);
1323
+ if (match_mdit && !match_mdit[1]) {
1324
+ removeTailBlank();
1325
+ list_itemInfo.push({
1326
+ content: match_mdit[3] ?? "",
1327
+ level: Number(match_mdit[2]) - 100
1328
+ });
1329
+ mul_mode = "mdit";
1330
+ } else if (!fine_mode && list_itemInfo.length > 0) {
1331
+ list_itemInfo[list_itemInfo.length - 1].content += "\n" + line;
1332
+ continue;
1333
+ } else if (match_list) {
1334
+ removeTailBlank();
1335
+ list_itemInfo.push({
1336
+ content: match_list[4],
1337
+ level: match_list[1].length + 1
1338
+ });
1339
+ mul_mode = "list";
1340
+ } else if (mul_mode == "list" && /^\s/.test(line)) {
1341
+ list_itemInfo[list_itemInfo.length - 1].content += "\n" + line.trimStart();
1342
+ continue;
1343
+ } else {
1344
+ if (mul_mode == "para") {
1345
+ list_itemInfo[list_itemInfo.length - 1].content += "\n" + line;
1346
+ continue;
1347
+ } else if (/^\s*$/.test(line)) {
1348
+ continue;
1349
+ } else {
1350
+ removeTailBlank();
1351
+ list_itemInfo.push({
1352
+ content: line,
1353
+ level: 0
1354
+ });
1355
+ mul_mode = "para";
1356
+ continue;
1208
1357
  }
1209
1358
  }
1210
1359
  }
@@ -1423,7 +1572,7 @@ const abc_list2listdata = ABConvert.factory({
1423
1572
  process_param: ABConvert_IOEnum.text,
1424
1573
  process_return: ABConvert_IOEnum.list_stream,
1425
1574
  detail: "列表到listdata",
1426
- process: (el, header, content) => {
1575
+ process: (_el, _header, content) => {
1427
1576
  return ListProcess.list2data(content);
1428
1577
  }
1429
1578
  });
@@ -1432,9 +1581,39 @@ const abc_title2listdata = ABConvert.factory({
1432
1581
  name: "标题到listdata",
1433
1582
  process_param: ABConvert_IOEnum.text,
1434
1583
  process_return: ABConvert_IOEnum.list_stream,
1435
- detail: "标题到listdata",
1436
- process: (el, header, content) => {
1437
- return ListProcess.title2data(content);
1584
+ detail: "标题到listdata。细粒度版本,列表会拆分成多个节点",
1585
+ process: (_el, _header, content) => {
1586
+ return ListProcess.title2data(content, true);
1587
+ }
1588
+ });
1589
+ ABConvert.factory({
1590
+ id: "title2Listdata",
1591
+ name: "标题到Listdata",
1592
+ process_param: ABConvert_IOEnum.text,
1593
+ process_return: ABConvert_IOEnum.list_stream,
1594
+ detail: "标题到Listdata。粗粒度版本,列表为一个节点,不会拆分",
1595
+ process: (_el, _header, content) => {
1596
+ return ListProcess.title2data(content, false);
1597
+ }
1598
+ });
1599
+ ABConvert.factory({
1600
+ id: "mdit2listdata",
1601
+ name: "mdit到listdata",
1602
+ process_param: ABConvert_IOEnum.text,
1603
+ process_return: ABConvert_IOEnum.list_stream,
1604
+ detail: "mdit到listdata。细粒度版本,列表会拆分成多个节点",
1605
+ process: (_el, _header, content) => {
1606
+ return ListProcess.mdit2data(content, true);
1607
+ }
1608
+ });
1609
+ ABConvert.factory({
1610
+ id: "mdit2Listdata",
1611
+ name: "mdit到Listdata",
1612
+ process_param: ABConvert_IOEnum.text,
1613
+ process_return: ABConvert_IOEnum.list_stream,
1614
+ detail: "mdit到Listdata。粗粒度版本,列表为一个节点,不会拆分",
1615
+ process: (_el, _header, content) => {
1616
+ return ListProcess.mdit2data(content, false);
1438
1617
  }
1439
1618
  });
1440
1619
  ABConvert.factory({
@@ -1443,7 +1622,7 @@ ABConvert.factory({
1443
1622
  process_param: ABConvert_IOEnum.list_stream,
1444
1623
  process_return: ABConvert_IOEnum.text,
1445
1624
  detail: "listdata到列表",
1446
- process: (el, header, content) => {
1625
+ process: (_el, _header, content) => {
1447
1626
  return ListProcess.data2list(content);
1448
1627
  }
1449
1628
  });
@@ -1453,17 +1632,18 @@ ABConvert.factory({
1453
1632
  process_param: ABConvert_IOEnum.list_stream,
1454
1633
  process_return: ABConvert_IOEnum.el,
1455
1634
  detail: "listdata到节点图",
1456
- process: (el, header, content) => {
1635
+ process: (el, _header, content) => {
1457
1636
  return ListProcess.data2nodes(content, el);
1458
1637
  }
1459
1638
  });
1460
1639
  ABConvert.factory({
1461
1640
  id: "listdata2strict",
1462
1641
  name: "listdata严格化",
1642
+ match: /listdata2strict|listdata2lint/,
1463
1643
  process_param: ABConvert_IOEnum.list_stream,
1464
1644
  process_return: ABConvert_IOEnum.list_stream,
1465
1645
  detail: "将列表数据转化为更规范的列表数据。统一缩进符(2空格 4空格 tab混用)为level 1、禁止跳等级(h1直接就到h3)",
1466
- process: (el, header, content) => {
1646
+ process: (_el, _header, content) => {
1467
1647
  return ListProcess.data2strict(content);
1468
1648
  }
1469
1649
  });
@@ -1473,7 +1653,7 @@ ABConvert.factory({
1473
1653
  process_param: ABConvert_IOEnum.list_stream,
1474
1654
  process_return: ABConvert_IOEnum.list_stream,
1475
1655
  detail: "当列表中存在任务列表项时,令此列表项支持任务项",
1476
- process: (el, header, content) => {
1656
+ process: (_el, _header, content) => {
1477
1657
  return ListProcess.data2taskData(content);
1478
1658
  }
1479
1659
  });
@@ -1483,7 +1663,7 @@ ABConvert.factory({
1483
1663
  process_param: ABConvert_IOEnum.text,
1484
1664
  process_return: ABConvert_IOEnum.json,
1485
1665
  detail: "列表到listnode",
1486
- process: (el, header, content) => {
1666
+ process: (_el, _header, content) => {
1487
1667
  const data2 = ListProcess.list2listnode(content);
1488
1668
  return JSON.stringify(data2, null, 2);
1489
1669
  }
@@ -1494,7 +1674,7 @@ ABConvert.factory({
1494
1674
  process_param: ABConvert_IOEnum.text,
1495
1675
  process_return: ABConvert_IOEnum.json,
1496
1676
  detail: "列表到json",
1497
- process: (el, header, content) => {
1677
+ process: (_el, _header, content) => {
1498
1678
  const data2 = ListProcess.list2json(content);
1499
1679
  return JSON.stringify(data2, null, 2);
1500
1680
  }
@@ -2007,6 +2187,19 @@ ABConvert.factory({
2007
2187
  return el = TableProcess.data2table(data2, el, matchs[2] == "T");
2008
2188
  }
2009
2189
  });
2190
+ ABConvert.factory({
2191
+ id: "listdata2table",
2192
+ name: "列表数据转表格",
2193
+ match: /listdata2(md)?table(T)?/,
2194
+ default: "listdata2table",
2195
+ process_param: ABConvert_IOEnum.list_stream,
2196
+ process_return: ABConvert_IOEnum.el,
2197
+ process: (el, header, content) => {
2198
+ const matchs = header.match(/listdata2(md)?table(T)?/);
2199
+ if (!matchs) return el;
2200
+ return el = TableProcess.data2table(content, el, matchs[2] == "T");
2201
+ }
2202
+ });
2010
2203
  ABConvert.factory({
2011
2204
  id: "list2c2t",
2012
2205
  name: "列表转二列表格",
@@ -2432,6 +2625,1085 @@ ABConvert.factory({
2432
2625
  return newContent;
2433
2626
  }
2434
2627
  });
2628
+ function _arrayLikeToArray(r, a) {
2629
+ (null == a || a > r.length) && (a = r.length);
2630
+ for (var e = 0, n2 = Array(a); e < a; e++) n2[e] = r[e];
2631
+ return n2;
2632
+ }
2633
+ function _arrayWithHoles(r) {
2634
+ if (Array.isArray(r)) return r;
2635
+ }
2636
+ function _iterableToArrayLimit(r, l2) {
2637
+ var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
2638
+ if (null != t) {
2639
+ var e, n2, i, u, a = [], f = true, o = false;
2640
+ try {
2641
+ if (i = (t = t.call(r)).next, 0 === l2) ;
2642
+ else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l2); f = true) ;
2643
+ } catch (r2) {
2644
+ o = true, n2 = r2;
2645
+ } finally {
2646
+ try {
2647
+ if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
2648
+ } finally {
2649
+ if (o) throw n2;
2650
+ }
2651
+ }
2652
+ return a;
2653
+ }
2654
+ }
2655
+ function _nonIterableRest() {
2656
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
2657
+ }
2658
+ function _slicedToArray(r, e) {
2659
+ return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
2660
+ }
2661
+ function _unsupportedIterableToArray(r, a) {
2662
+ if (r) {
2663
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
2664
+ var t = {}.toString.call(r).slice(8, -1);
2665
+ return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
2666
+ }
2667
+ }
2668
+ const entries = Object.entries, setPrototypeOf = Object.setPrototypeOf, isFrozen = Object.isFrozen, getPrototypeOf = Object.getPrototypeOf, getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
2669
+ let freeze = Object.freeze, seal = Object.seal, create = Object.create;
2670
+ let _ref = typeof Reflect !== "undefined" && Reflect, apply = _ref.apply, construct = _ref.construct;
2671
+ if (!freeze) {
2672
+ freeze = function freeze2(x) {
2673
+ return x;
2674
+ };
2675
+ }
2676
+ if (!seal) {
2677
+ seal = function seal2(x) {
2678
+ return x;
2679
+ };
2680
+ }
2681
+ if (!apply) {
2682
+ apply = function apply2(func, thisArg) {
2683
+ for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
2684
+ args[_key - 2] = arguments[_key];
2685
+ }
2686
+ return func.apply(thisArg, args);
2687
+ };
2688
+ }
2689
+ if (!construct) {
2690
+ construct = function construct2(Func) {
2691
+ for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
2692
+ args[_key2 - 1] = arguments[_key2];
2693
+ }
2694
+ return new Func(...args);
2695
+ };
2696
+ }
2697
+ const arrayForEach = unapply(Array.prototype.forEach);
2698
+ const arrayLastIndexOf = unapply(Array.prototype.lastIndexOf);
2699
+ const arrayPop = unapply(Array.prototype.pop);
2700
+ const arrayPush = unapply(Array.prototype.push);
2701
+ const arraySplice = unapply(Array.prototype.splice);
2702
+ const arrayIsArray = Array.isArray;
2703
+ const stringToLowerCase = unapply(String.prototype.toLowerCase);
2704
+ const stringToString = unapply(String.prototype.toString);
2705
+ const stringMatch = unapply(String.prototype.match);
2706
+ const stringReplace = unapply(String.prototype.replace);
2707
+ const stringIndexOf = unapply(String.prototype.indexOf);
2708
+ const stringTrim = unapply(String.prototype.trim);
2709
+ const numberToString = unapply(Number.prototype.toString);
2710
+ const booleanToString = unapply(Boolean.prototype.toString);
2711
+ const bigintToString = typeof BigInt === "undefined" ? null : unapply(BigInt.prototype.toString);
2712
+ const symbolToString = typeof Symbol === "undefined" ? null : unapply(Symbol.prototype.toString);
2713
+ const objectHasOwnProperty = unapply(Object.prototype.hasOwnProperty);
2714
+ const objectToString = unapply(Object.prototype.toString);
2715
+ const regExpTest = unapply(RegExp.prototype.test);
2716
+ const typeErrorCreate = unconstruct(TypeError);
2717
+ function unapply(func) {
2718
+ return function(thisArg) {
2719
+ if (thisArg instanceof RegExp) {
2720
+ thisArg.lastIndex = 0;
2721
+ }
2722
+ for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
2723
+ args[_key3 - 1] = arguments[_key3];
2724
+ }
2725
+ return apply(func, thisArg, args);
2726
+ };
2727
+ }
2728
+ function unconstruct(Func) {
2729
+ return function() {
2730
+ for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
2731
+ args[_key4] = arguments[_key4];
2732
+ }
2733
+ return construct(Func, args);
2734
+ };
2735
+ }
2736
+ function addToSet(set2, array) {
2737
+ let transformCaseFunc = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : stringToLowerCase;
2738
+ if (setPrototypeOf) {
2739
+ setPrototypeOf(set2, null);
2740
+ }
2741
+ if (!arrayIsArray(array)) {
2742
+ return set2;
2743
+ }
2744
+ let l2 = array.length;
2745
+ while (l2--) {
2746
+ let element = array[l2];
2747
+ if (typeof element === "string") {
2748
+ const lcElement = transformCaseFunc(element);
2749
+ if (lcElement !== element) {
2750
+ if (!isFrozen(array)) {
2751
+ array[l2] = lcElement;
2752
+ }
2753
+ element = lcElement;
2754
+ }
2755
+ }
2756
+ set2[element] = true;
2757
+ }
2758
+ return set2;
2759
+ }
2760
+ function cleanArray(array) {
2761
+ for (let index2 = 0; index2 < array.length; index2++) {
2762
+ const isPropertyExist = objectHasOwnProperty(array, index2);
2763
+ if (!isPropertyExist) {
2764
+ array[index2] = null;
2765
+ }
2766
+ }
2767
+ return array;
2768
+ }
2769
+ function clone$3(object) {
2770
+ const newObject = create(null);
2771
+ for (const _ref2 of entries(object)) {
2772
+ var _ref3 = _slicedToArray(_ref2, 2);
2773
+ const property = _ref3[0];
2774
+ const value = _ref3[1];
2775
+ const isPropertyExist = objectHasOwnProperty(object, property);
2776
+ if (isPropertyExist) {
2777
+ if (arrayIsArray(value)) {
2778
+ newObject[property] = cleanArray(value);
2779
+ } else if (value && typeof value === "object" && value.constructor === Object) {
2780
+ newObject[property] = clone$3(value);
2781
+ } else {
2782
+ newObject[property] = value;
2783
+ }
2784
+ }
2785
+ }
2786
+ return newObject;
2787
+ }
2788
+ function stringifyValue(value) {
2789
+ switch (typeof value) {
2790
+ case "string": {
2791
+ return value;
2792
+ }
2793
+ case "number": {
2794
+ return numberToString(value);
2795
+ }
2796
+ case "boolean": {
2797
+ return booleanToString(value);
2798
+ }
2799
+ case "bigint": {
2800
+ return bigintToString ? bigintToString(value) : "0";
2801
+ }
2802
+ case "symbol": {
2803
+ return symbolToString ? symbolToString(value) : "Symbol()";
2804
+ }
2805
+ case "undefined": {
2806
+ return objectToString(value);
2807
+ }
2808
+ case "function":
2809
+ case "object": {
2810
+ if (value === null) {
2811
+ return objectToString(value);
2812
+ }
2813
+ const valueAsRecord = value;
2814
+ const valueToString = lookupGetter(valueAsRecord, "toString");
2815
+ if (typeof valueToString === "function") {
2816
+ const stringified = valueToString(valueAsRecord);
2817
+ return typeof stringified === "string" ? stringified : objectToString(stringified);
2818
+ }
2819
+ return objectToString(value);
2820
+ }
2821
+ default: {
2822
+ return objectToString(value);
2823
+ }
2824
+ }
2825
+ }
2826
+ function lookupGetter(object, prop2) {
2827
+ while (object !== null) {
2828
+ const desc = getOwnPropertyDescriptor(object, prop2);
2829
+ if (desc) {
2830
+ if (desc.get) {
2831
+ return unapply(desc.get);
2832
+ }
2833
+ if (typeof desc.value === "function") {
2834
+ return unapply(desc.value);
2835
+ }
2836
+ }
2837
+ object = getPrototypeOf(object);
2838
+ }
2839
+ function fallbackValue() {
2840
+ return null;
2841
+ }
2842
+ return fallbackValue;
2843
+ }
2844
+ function isRegex(value) {
2845
+ try {
2846
+ regExpTest(value, "");
2847
+ return true;
2848
+ } catch (_unused) {
2849
+ return false;
2850
+ }
2851
+ }
2852
+ const html$1$1 = freeze(["a", "abbr", "acronym", "address", "area", "article", "aside", "audio", "b", "bdi", "bdo", "big", "blink", "blockquote", "body", "br", "button", "canvas", "caption", "center", "cite", "code", "col", "colgroup", "content", "data", "datalist", "dd", "decorator", "del", "details", "dfn", "dialog", "dir", "div", "dl", "dt", "element", "em", "fieldset", "figcaption", "figure", "font", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6", "head", "header", "hgroup", "hr", "html", "i", "img", "input", "ins", "kbd", "label", "legend", "li", "main", "map", "mark", "marquee", "menu", "menuitem", "meter", "nav", "nobr", "ol", "optgroup", "option", "output", "p", "picture", "pre", "progress", "q", "rp", "rt", "ruby", "s", "samp", "search", "section", "select", "shadow", "slot", "small", "source", "spacer", "span", "strike", "strong", "style", "sub", "summary", "sup", "table", "tbody", "td", "template", "textarea", "tfoot", "th", "thead", "time", "tr", "track", "tt", "u", "ul", "var", "video", "wbr"]);
2853
+ const svg$1 = freeze(["svg", "a", "altglyph", "altglyphdef", "altglyphitem", "animatecolor", "animatemotion", "animatetransform", "circle", "clippath", "defs", "desc", "ellipse", "enterkeyhint", "exportparts", "filter", "font", "g", "glyph", "glyphref", "hkern", "image", "inputmode", "line", "lineargradient", "marker", "mask", "metadata", "mpath", "part", "path", "pattern", "polygon", "polyline", "radialgradient", "rect", "stop", "style", "switch", "symbol", "text", "textpath", "title", "tref", "tspan", "view", "vkern"]);
2854
+ const svgFilters = freeze(["feBlend", "feColorMatrix", "feComponentTransfer", "feComposite", "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap", "feDistantLight", "feDropShadow", "feFlood", "feFuncA", "feFuncB", "feFuncG", "feFuncR", "feGaussianBlur", "feImage", "feMerge", "feMergeNode", "feMorphology", "feOffset", "fePointLight", "feSpecularLighting", "feSpotLight", "feTile", "feTurbulence"]);
2855
+ const svgDisallowed = freeze(["animate", "color-profile", "cursor", "discard", "font-face", "font-face-format", "font-face-name", "font-face-src", "font-face-uri", "foreignobject", "hatch", "hatchpath", "mesh", "meshgradient", "meshpatch", "meshrow", "missing-glyph", "script", "set", "solidcolor", "unknown", "use"]);
2856
+ const mathMl$1 = freeze(["math", "menclose", "merror", "mfenced", "mfrac", "mglyph", "mi", "mlabeledtr", "mmultiscripts", "mn", "mo", "mover", "mpadded", "mphantom", "mroot", "mrow", "ms", "mspace", "msqrt", "mstyle", "msub", "msup", "msubsup", "mtable", "mtd", "mtext", "mtr", "munder", "munderover", "mprescripts"]);
2857
+ const mathMlDisallowed = freeze(["maction", "maligngroup", "malignmark", "mlongdiv", "mscarries", "mscarry", "msgroup", "mstack", "msline", "msrow", "semantics", "annotation", "annotation-xml", "mprescripts", "none"]);
2858
+ const text$2 = freeze(["#text"]);
2859
+ const html$2 = freeze(["accept", "action", "align", "alt", "autocapitalize", "autocomplete", "autopictureinpicture", "autoplay", "background", "bgcolor", "border", "capture", "cellpadding", "cellspacing", "checked", "cite", "class", "clear", "color", "cols", "colspan", "controls", "controlslist", "coords", "crossorigin", "datetime", "decoding", "default", "dir", "disabled", "disablepictureinpicture", "disableremoteplayback", "download", "draggable", "enctype", "enterkeyhint", "exportparts", "face", "for", "headers", "height", "hidden", "high", "href", "hreflang", "id", "inert", "inputmode", "integrity", "ismap", "kind", "label", "lang", "list", "loading", "loop", "low", "max", "maxlength", "media", "method", "min", "minlength", "multiple", "muted", "name", "nonce", "noshade", "novalidate", "nowrap", "open", "optimum", "part", "pattern", "placeholder", "playsinline", "popover", "popovertarget", "popovertargetaction", "poster", "preload", "pubdate", "radiogroup", "readonly", "rel", "required", "rev", "reversed", "role", "rows", "rowspan", "spellcheck", "scope", "selected", "shape", "size", "sizes", "slot", "span", "srclang", "start", "src", "srcset", "step", "style", "summary", "tabindex", "title", "translate", "type", "usemap", "valign", "value", "width", "wrap", "xmlns"]);
2860
+ const svg = freeze(["accent-height", "accumulate", "additive", "alignment-baseline", "amplitude", "ascent", "attributename", "attributetype", "azimuth", "basefrequency", "baseline-shift", "begin", "bias", "by", "class", "clip", "clippathunits", "clip-path", "clip-rule", "color", "color-interpolation", "color-interpolation-filters", "color-profile", "color-rendering", "cx", "cy", "d", "dx", "dy", "diffuseconstant", "direction", "display", "divisor", "dur", "edgemode", "elevation", "end", "exponent", "fill", "fill-opacity", "fill-rule", "filter", "filterunits", "flood-color", "flood-opacity", "font-family", "font-size", "font-size-adjust", "font-stretch", "font-style", "font-variant", "font-weight", "fx", "fy", "g1", "g2", "glyph-name", "glyphref", "gradientunits", "gradienttransform", "height", "href", "id", "image-rendering", "in", "in2", "intercept", "k", "k1", "k2", "k3", "k4", "kerning", "keypoints", "keysplines", "keytimes", "lang", "lengthadjust", "letter-spacing", "kernelmatrix", "kernelunitlength", "lighting-color", "local", "marker-end", "marker-mid", "marker-start", "markerheight", "markerunits", "markerwidth", "maskcontentunits", "maskunits", "max", "mask", "mask-type", "media", "method", "mode", "min", "name", "numoctaves", "offset", "operator", "opacity", "order", "orient", "orientation", "origin", "overflow", "paint-order", "path", "pathlength", "patterncontentunits", "patterntransform", "patternunits", "points", "preservealpha", "preserveaspectratio", "primitiveunits", "r", "rx", "ry", "radius", "refx", "refy", "repeatcount", "repeatdur", "restart", "result", "rotate", "scale", "seed", "shape-rendering", "slope", "specularconstant", "specularexponent", "spreadmethod", "startoffset", "stddeviation", "stitchtiles", "stop-color", "stop-opacity", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke", "stroke-width", "style", "surfacescale", "systemlanguage", "tabindex", "tablevalues", "targetx", "targety", "transform", "transform-origin", "text-anchor", "text-decoration", "text-rendering", "textlength", "type", "u1", "u2", "unicode", "values", "viewbox", "visibility", "version", "vert-adv-y", "vert-origin-x", "vert-origin-y", "width", "word-spacing", "wrap", "writing-mode", "xchannelselector", "ychannelselector", "x", "x1", "x2", "xmlns", "y", "y1", "y2", "z", "zoomandpan"]);
2861
+ const mathMl = freeze(["accent", "accentunder", "align", "bevelled", "close", "columnalign", "columnlines", "columnspacing", "columnspan", "denomalign", "depth", "dir", "display", "displaystyle", "encoding", "fence", "frame", "height", "href", "id", "largeop", "length", "linethickness", "lquote", "lspace", "mathbackground", "mathcolor", "mathsize", "mathvariant", "maxsize", "minsize", "movablelimits", "notation", "numalign", "open", "rowalign", "rowlines", "rowspacing", "rowspan", "rspace", "rquote", "scriptlevel", "scriptminsize", "scriptsizemultiplier", "selection", "separator", "separators", "stretchy", "subscriptshift", "supscriptshift", "symmetric", "voffset", "width", "xmlns"]);
2862
+ const xml$1 = freeze(["xlink:href", "xml:id", "xlink:title", "xml:space", "xmlns:xlink"]);
2863
+ const MUSTACHE_EXPR = seal(/{{[\w\W]*|^[\w\W]*}}/g);
2864
+ const ERB_EXPR = seal(/<%[\w\W]*|^[\w\W]*%>/g);
2865
+ const TMPLIT_EXPR = seal(/\${[\w\W]*/g);
2866
+ const DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]+$/);
2867
+ const ARIA_ATTR = seal(/^aria-[\-\w]+$/);
2868
+ const IS_ALLOWED_URI = seal(
2869
+ /^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i
2870
+ // eslint-disable-line no-useless-escape
2871
+ );
2872
+ const IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i);
2873
+ const ATTR_WHITESPACE = seal(
2874
+ /[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g
2875
+ // eslint-disable-line no-control-regex
2876
+ );
2877
+ const DOCTYPE_NAME = seal(/^html$/i);
2878
+ const CUSTOM_ELEMENT = seal(/^[a-z][.\w]*(-[.\w]+)+$/i);
2879
+ const NODE_TYPE$1 = {
2880
+ element: 1,
2881
+ text: 3,
2882
+ // Deprecated
2883
+ progressingInstruction: 7,
2884
+ comment: 8,
2885
+ document: 9
2886
+ };
2887
+ const getGlobal = function getGlobal2() {
2888
+ return typeof window === "undefined" ? null : window;
2889
+ };
2890
+ const _createTrustedTypesPolicy = function _createTrustedTypesPolicy2(trustedTypes, purifyHostElement) {
2891
+ if (typeof trustedTypes !== "object" || typeof trustedTypes.createPolicy !== "function") {
2892
+ return null;
2893
+ }
2894
+ let suffix = null;
2895
+ const ATTR_NAME = "data-tt-policy-suffix";
2896
+ if (purifyHostElement && purifyHostElement.hasAttribute(ATTR_NAME)) {
2897
+ suffix = purifyHostElement.getAttribute(ATTR_NAME);
2898
+ }
2899
+ const policyName = "dompurify" + (suffix ? "#" + suffix : "");
2900
+ try {
2901
+ return trustedTypes.createPolicy(policyName, {
2902
+ createHTML(html2) {
2903
+ return html2;
2904
+ },
2905
+ createScriptURL(scriptUrl) {
2906
+ return scriptUrl;
2907
+ }
2908
+ });
2909
+ } catch (_) {
2910
+ console.warn("TrustedTypes policy " + policyName + " could not be created.");
2911
+ return null;
2912
+ }
2913
+ };
2914
+ const _createHooksMap = function _createHooksMap2() {
2915
+ return {
2916
+ afterSanitizeAttributes: [],
2917
+ afterSanitizeElements: [],
2918
+ afterSanitizeShadowDOM: [],
2919
+ beforeSanitizeAttributes: [],
2920
+ beforeSanitizeElements: [],
2921
+ beforeSanitizeShadowDOM: [],
2922
+ uponSanitizeAttribute: [],
2923
+ uponSanitizeElement: [],
2924
+ uponSanitizeShadowNode: []
2925
+ };
2926
+ };
2927
+ function createDOMPurify() {
2928
+ let window2 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : getGlobal();
2929
+ const DOMPurify = (root2) => createDOMPurify(root2);
2930
+ DOMPurify.version = "3.4.3";
2931
+ DOMPurify.removed = [];
2932
+ if (!window2 || !window2.document || window2.document.nodeType !== NODE_TYPE$1.document || !window2.Element) {
2933
+ DOMPurify.isSupported = false;
2934
+ return DOMPurify;
2935
+ }
2936
+ let document2 = window2.document;
2937
+ const originalDocument = document2;
2938
+ const currentScript = originalDocument.currentScript;
2939
+ const DocumentFragment = window2.DocumentFragment, HTMLTemplateElement = window2.HTMLTemplateElement, Node3 = window2.Node, Element2 = window2.Element, NodeFilter = window2.NodeFilter, _window$NamedNodeMap = window2.NamedNodeMap, NamedNodeMap = _window$NamedNodeMap === void 0 ? window2.NamedNodeMap || window2.MozNamedAttrMap : _window$NamedNodeMap, HTMLFormElement = window2.HTMLFormElement, DOMParser = window2.DOMParser, trustedTypes = window2.trustedTypes;
2940
+ const ElementPrototype = Element2.prototype;
2941
+ const cloneNode2 = lookupGetter(ElementPrototype, "cloneNode");
2942
+ const remove2 = lookupGetter(ElementPrototype, "remove");
2943
+ const getNextSibling = lookupGetter(ElementPrototype, "nextSibling");
2944
+ const getChildNodes = lookupGetter(ElementPrototype, "childNodes");
2945
+ const getParentNode = lookupGetter(ElementPrototype, "parentNode");
2946
+ if (typeof HTMLTemplateElement === "function") {
2947
+ const template = document2.createElement("template");
2948
+ if (template.content && template.content.ownerDocument) {
2949
+ document2 = template.content.ownerDocument;
2950
+ }
2951
+ }
2952
+ let trustedTypesPolicy;
2953
+ let emptyHTML = "";
2954
+ const _document = document2, implementation = _document.implementation, createNodeIterator = _document.createNodeIterator, createDocumentFragment = _document.createDocumentFragment, getElementsByTagName2 = _document.getElementsByTagName;
2955
+ const importNode = originalDocument.importNode;
2956
+ let hooks = _createHooksMap();
2957
+ DOMPurify.isSupported = typeof entries === "function" && typeof getParentNode === "function" && implementation && implementation.createHTMLDocument !== void 0;
2958
+ const MUSTACHE_EXPR$1 = MUSTACHE_EXPR, ERB_EXPR$1 = ERB_EXPR, TMPLIT_EXPR$1 = TMPLIT_EXPR, DATA_ATTR$1 = DATA_ATTR, ARIA_ATTR$1 = ARIA_ATTR, IS_SCRIPT_OR_DATA$1 = IS_SCRIPT_OR_DATA, ATTR_WHITESPACE$1 = ATTR_WHITESPACE, CUSTOM_ELEMENT$1 = CUSTOM_ELEMENT;
2959
+ let IS_ALLOWED_URI$1 = IS_ALLOWED_URI;
2960
+ let ALLOWED_TAGS = null;
2961
+ const DEFAULT_ALLOWED_TAGS = addToSet({}, [...html$1$1, ...svg$1, ...svgFilters, ...mathMl$1, ...text$2]);
2962
+ let ALLOWED_ATTR = null;
2963
+ const DEFAULT_ALLOWED_ATTR = addToSet({}, [...html$2, ...svg, ...mathMl, ...xml$1]);
2964
+ let CUSTOM_ELEMENT_HANDLING = Object.seal(create(null, {
2965
+ tagNameCheck: {
2966
+ writable: true,
2967
+ configurable: false,
2968
+ enumerable: true,
2969
+ value: null
2970
+ },
2971
+ attributeNameCheck: {
2972
+ writable: true,
2973
+ configurable: false,
2974
+ enumerable: true,
2975
+ value: null
2976
+ },
2977
+ allowCustomizedBuiltInElements: {
2978
+ writable: true,
2979
+ configurable: false,
2980
+ enumerable: true,
2981
+ value: false
2982
+ }
2983
+ }));
2984
+ let FORBID_TAGS = null;
2985
+ let FORBID_ATTR = null;
2986
+ const EXTRA_ELEMENT_HANDLING = Object.seal(create(null, {
2987
+ tagCheck: {
2988
+ writable: true,
2989
+ configurable: false,
2990
+ enumerable: true,
2991
+ value: null
2992
+ },
2993
+ attributeCheck: {
2994
+ writable: true,
2995
+ configurable: false,
2996
+ enumerable: true,
2997
+ value: null
2998
+ }
2999
+ }));
3000
+ let ALLOW_ARIA_ATTR = true;
3001
+ let ALLOW_DATA_ATTR = true;
3002
+ let ALLOW_UNKNOWN_PROTOCOLS = false;
3003
+ let ALLOW_SELF_CLOSE_IN_ATTR = true;
3004
+ let SAFE_FOR_TEMPLATES = false;
3005
+ let SAFE_FOR_XML = true;
3006
+ let WHOLE_DOCUMENT = false;
3007
+ let SET_CONFIG = false;
3008
+ let FORCE_BODY = false;
3009
+ let RETURN_DOM = false;
3010
+ let RETURN_DOM_FRAGMENT = false;
3011
+ let RETURN_TRUSTED_TYPE = false;
3012
+ let SANITIZE_DOM = true;
3013
+ let SANITIZE_NAMED_PROPS = false;
3014
+ const SANITIZE_NAMED_PROPS_PREFIX = "user-content-";
3015
+ let KEEP_CONTENT = true;
3016
+ let IN_PLACE = false;
3017
+ let USE_PROFILES = {};
3018
+ let FORBID_CONTENTS = null;
3019
+ const DEFAULT_FORBID_CONTENTS = addToSet({}, ["annotation-xml", "audio", "colgroup", "desc", "foreignobject", "head", "iframe", "math", "mi", "mn", "mo", "ms", "mtext", "noembed", "noframes", "noscript", "plaintext", "script", "style", "svg", "template", "thead", "title", "video", "xmp"]);
3020
+ let DATA_URI_TAGS = null;
3021
+ const DEFAULT_DATA_URI_TAGS = addToSet({}, ["audio", "video", "img", "source", "image", "track"]);
3022
+ let URI_SAFE_ATTRIBUTES = null;
3023
+ const DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ["alt", "class", "for", "id", "label", "name", "pattern", "placeholder", "role", "summary", "title", "value", "style", "xmlns"]);
3024
+ const MATHML_NAMESPACE = "http://www.w3.org/1998/Math/MathML";
3025
+ const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
3026
+ const HTML_NAMESPACE = "http://www.w3.org/1999/xhtml";
3027
+ let NAMESPACE = HTML_NAMESPACE;
3028
+ let IS_EMPTY_INPUT = false;
3029
+ let ALLOWED_NAMESPACES = null;
3030
+ const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [MATHML_NAMESPACE, SVG_NAMESPACE, HTML_NAMESPACE], stringToString);
3031
+ let MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ["mi", "mo", "mn", "ms", "mtext"]);
3032
+ let HTML_INTEGRATION_POINTS = addToSet({}, ["annotation-xml"]);
3033
+ const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, ["title", "style", "font", "a", "script"]);
3034
+ let PARSER_MEDIA_TYPE = null;
3035
+ const SUPPORTED_PARSER_MEDIA_TYPES = ["application/xhtml+xml", "text/html"];
3036
+ const DEFAULT_PARSER_MEDIA_TYPE = "text/html";
3037
+ let transformCaseFunc = null;
3038
+ let CONFIG = null;
3039
+ const formElement = document2.createElement("form");
3040
+ const isRegexOrFunction = function isRegexOrFunction2(testValue) {
3041
+ return testValue instanceof RegExp || testValue instanceof Function;
3042
+ };
3043
+ const _parseConfig = function _parseConfig2() {
3044
+ let cfg = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
3045
+ if (CONFIG && CONFIG === cfg) {
3046
+ return;
3047
+ }
3048
+ if (!cfg || typeof cfg !== "object") {
3049
+ cfg = {};
3050
+ }
3051
+ cfg = clone$3(cfg);
3052
+ PARSER_MEDIA_TYPE = // eslint-disable-next-line unicorn/prefer-includes
3053
+ SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? DEFAULT_PARSER_MEDIA_TYPE : cfg.PARSER_MEDIA_TYPE;
3054
+ transformCaseFunc = PARSER_MEDIA_TYPE === "application/xhtml+xml" ? stringToString : stringToLowerCase;
3055
+ ALLOWED_TAGS = objectHasOwnProperty(cfg, "ALLOWED_TAGS") && arrayIsArray(cfg.ALLOWED_TAGS) ? addToSet({}, cfg.ALLOWED_TAGS, transformCaseFunc) : DEFAULT_ALLOWED_TAGS;
3056
+ ALLOWED_ATTR = objectHasOwnProperty(cfg, "ALLOWED_ATTR") && arrayIsArray(cfg.ALLOWED_ATTR) ? addToSet({}, cfg.ALLOWED_ATTR, transformCaseFunc) : DEFAULT_ALLOWED_ATTR;
3057
+ ALLOWED_NAMESPACES = objectHasOwnProperty(cfg, "ALLOWED_NAMESPACES") && arrayIsArray(cfg.ALLOWED_NAMESPACES) ? addToSet({}, cfg.ALLOWED_NAMESPACES, stringToString) : DEFAULT_ALLOWED_NAMESPACES;
3058
+ URI_SAFE_ATTRIBUTES = objectHasOwnProperty(cfg, "ADD_URI_SAFE_ATTR") && arrayIsArray(cfg.ADD_URI_SAFE_ATTR) ? addToSet(clone$3(DEFAULT_URI_SAFE_ATTRIBUTES), cfg.ADD_URI_SAFE_ATTR, transformCaseFunc) : DEFAULT_URI_SAFE_ATTRIBUTES;
3059
+ DATA_URI_TAGS = objectHasOwnProperty(cfg, "ADD_DATA_URI_TAGS") && arrayIsArray(cfg.ADD_DATA_URI_TAGS) ? addToSet(clone$3(DEFAULT_DATA_URI_TAGS), cfg.ADD_DATA_URI_TAGS, transformCaseFunc) : DEFAULT_DATA_URI_TAGS;
3060
+ FORBID_CONTENTS = objectHasOwnProperty(cfg, "FORBID_CONTENTS") && arrayIsArray(cfg.FORBID_CONTENTS) ? addToSet({}, cfg.FORBID_CONTENTS, transformCaseFunc) : DEFAULT_FORBID_CONTENTS;
3061
+ FORBID_TAGS = objectHasOwnProperty(cfg, "FORBID_TAGS") && arrayIsArray(cfg.FORBID_TAGS) ? addToSet({}, cfg.FORBID_TAGS, transformCaseFunc) : clone$3({});
3062
+ FORBID_ATTR = objectHasOwnProperty(cfg, "FORBID_ATTR") && arrayIsArray(cfg.FORBID_ATTR) ? addToSet({}, cfg.FORBID_ATTR, transformCaseFunc) : clone$3({});
3063
+ USE_PROFILES = objectHasOwnProperty(cfg, "USE_PROFILES") ? cfg.USE_PROFILES && typeof cfg.USE_PROFILES === "object" ? clone$3(cfg.USE_PROFILES) : cfg.USE_PROFILES : false;
3064
+ ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false;
3065
+ ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false;
3066
+ ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false;
3067
+ ALLOW_SELF_CLOSE_IN_ATTR = cfg.ALLOW_SELF_CLOSE_IN_ATTR !== false;
3068
+ SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false;
3069
+ SAFE_FOR_XML = cfg.SAFE_FOR_XML !== false;
3070
+ WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false;
3071
+ RETURN_DOM = cfg.RETURN_DOM || false;
3072
+ RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false;
3073
+ RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false;
3074
+ FORCE_BODY = cfg.FORCE_BODY || false;
3075
+ SANITIZE_DOM = cfg.SANITIZE_DOM !== false;
3076
+ SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false;
3077
+ KEEP_CONTENT = cfg.KEEP_CONTENT !== false;
3078
+ IN_PLACE = cfg.IN_PLACE || false;
3079
+ IS_ALLOWED_URI$1 = isRegex(cfg.ALLOWED_URI_REGEXP) ? cfg.ALLOWED_URI_REGEXP : IS_ALLOWED_URI;
3080
+ NAMESPACE = typeof cfg.NAMESPACE === "string" ? cfg.NAMESPACE : HTML_NAMESPACE;
3081
+ MATHML_TEXT_INTEGRATION_POINTS = objectHasOwnProperty(cfg, "MATHML_TEXT_INTEGRATION_POINTS") && cfg.MATHML_TEXT_INTEGRATION_POINTS && typeof cfg.MATHML_TEXT_INTEGRATION_POINTS === "object" ? clone$3(cfg.MATHML_TEXT_INTEGRATION_POINTS) : addToSet({}, ["mi", "mo", "mn", "ms", "mtext"]);
3082
+ HTML_INTEGRATION_POINTS = objectHasOwnProperty(cfg, "HTML_INTEGRATION_POINTS") && cfg.HTML_INTEGRATION_POINTS && typeof cfg.HTML_INTEGRATION_POINTS === "object" ? clone$3(cfg.HTML_INTEGRATION_POINTS) : addToSet({}, ["annotation-xml"]);
3083
+ const customElementHandling = objectHasOwnProperty(cfg, "CUSTOM_ELEMENT_HANDLING") && cfg.CUSTOM_ELEMENT_HANDLING && typeof cfg.CUSTOM_ELEMENT_HANDLING === "object" ? clone$3(cfg.CUSTOM_ELEMENT_HANDLING) : create(null);
3084
+ CUSTOM_ELEMENT_HANDLING = create(null);
3085
+ if (objectHasOwnProperty(customElementHandling, "tagNameCheck") && isRegexOrFunction(customElementHandling.tagNameCheck)) {
3086
+ CUSTOM_ELEMENT_HANDLING.tagNameCheck = customElementHandling.tagNameCheck;
3087
+ }
3088
+ if (objectHasOwnProperty(customElementHandling, "attributeNameCheck") && isRegexOrFunction(customElementHandling.attributeNameCheck)) {
3089
+ CUSTOM_ELEMENT_HANDLING.attributeNameCheck = customElementHandling.attributeNameCheck;
3090
+ }
3091
+ if (objectHasOwnProperty(customElementHandling, "allowCustomizedBuiltInElements") && typeof customElementHandling.allowCustomizedBuiltInElements === "boolean") {
3092
+ CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = customElementHandling.allowCustomizedBuiltInElements;
3093
+ }
3094
+ if (SAFE_FOR_TEMPLATES) {
3095
+ ALLOW_DATA_ATTR = false;
3096
+ }
3097
+ if (RETURN_DOM_FRAGMENT) {
3098
+ RETURN_DOM = true;
3099
+ }
3100
+ if (USE_PROFILES) {
3101
+ ALLOWED_TAGS = addToSet({}, text$2);
3102
+ ALLOWED_ATTR = create(null);
3103
+ if (USE_PROFILES.html === true) {
3104
+ addToSet(ALLOWED_TAGS, html$1$1);
3105
+ addToSet(ALLOWED_ATTR, html$2);
3106
+ }
3107
+ if (USE_PROFILES.svg === true) {
3108
+ addToSet(ALLOWED_TAGS, svg$1);
3109
+ addToSet(ALLOWED_ATTR, svg);
3110
+ addToSet(ALLOWED_ATTR, xml$1);
3111
+ }
3112
+ if (USE_PROFILES.svgFilters === true) {
3113
+ addToSet(ALLOWED_TAGS, svgFilters);
3114
+ addToSet(ALLOWED_ATTR, svg);
3115
+ addToSet(ALLOWED_ATTR, xml$1);
3116
+ }
3117
+ if (USE_PROFILES.mathMl === true) {
3118
+ addToSet(ALLOWED_TAGS, mathMl$1);
3119
+ addToSet(ALLOWED_ATTR, mathMl);
3120
+ addToSet(ALLOWED_ATTR, xml$1);
3121
+ }
3122
+ }
3123
+ EXTRA_ELEMENT_HANDLING.tagCheck = null;
3124
+ EXTRA_ELEMENT_HANDLING.attributeCheck = null;
3125
+ if (objectHasOwnProperty(cfg, "ADD_TAGS")) {
3126
+ if (typeof cfg.ADD_TAGS === "function") {
3127
+ EXTRA_ELEMENT_HANDLING.tagCheck = cfg.ADD_TAGS;
3128
+ } else if (arrayIsArray(cfg.ADD_TAGS)) {
3129
+ if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {
3130
+ ALLOWED_TAGS = clone$3(ALLOWED_TAGS);
3131
+ }
3132
+ addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc);
3133
+ }
3134
+ }
3135
+ if (objectHasOwnProperty(cfg, "ADD_ATTR")) {
3136
+ if (typeof cfg.ADD_ATTR === "function") {
3137
+ EXTRA_ELEMENT_HANDLING.attributeCheck = cfg.ADD_ATTR;
3138
+ } else if (arrayIsArray(cfg.ADD_ATTR)) {
3139
+ if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) {
3140
+ ALLOWED_ATTR = clone$3(ALLOWED_ATTR);
3141
+ }
3142
+ addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc);
3143
+ }
3144
+ }
3145
+ if (objectHasOwnProperty(cfg, "ADD_URI_SAFE_ATTR") && arrayIsArray(cfg.ADD_URI_SAFE_ATTR)) {
3146
+ addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR, transformCaseFunc);
3147
+ }
3148
+ if (objectHasOwnProperty(cfg, "FORBID_CONTENTS") && arrayIsArray(cfg.FORBID_CONTENTS)) {
3149
+ if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
3150
+ FORBID_CONTENTS = clone$3(FORBID_CONTENTS);
3151
+ }
3152
+ addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS, transformCaseFunc);
3153
+ }
3154
+ if (objectHasOwnProperty(cfg, "ADD_FORBID_CONTENTS") && arrayIsArray(cfg.ADD_FORBID_CONTENTS)) {
3155
+ if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
3156
+ FORBID_CONTENTS = clone$3(FORBID_CONTENTS);
3157
+ }
3158
+ addToSet(FORBID_CONTENTS, cfg.ADD_FORBID_CONTENTS, transformCaseFunc);
3159
+ }
3160
+ if (KEEP_CONTENT) {
3161
+ ALLOWED_TAGS["#text"] = true;
3162
+ }
3163
+ if (WHOLE_DOCUMENT) {
3164
+ addToSet(ALLOWED_TAGS, ["html", "head", "body"]);
3165
+ }
3166
+ if (ALLOWED_TAGS.table) {
3167
+ addToSet(ALLOWED_TAGS, ["tbody"]);
3168
+ delete FORBID_TAGS.tbody;
3169
+ }
3170
+ if (cfg.TRUSTED_TYPES_POLICY) {
3171
+ if (typeof cfg.TRUSTED_TYPES_POLICY.createHTML !== "function") {
3172
+ throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');
3173
+ }
3174
+ if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== "function") {
3175
+ throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
3176
+ }
3177
+ trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY;
3178
+ emptyHTML = trustedTypesPolicy.createHTML("");
3179
+ } else {
3180
+ if (trustedTypesPolicy === void 0) {
3181
+ trustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript);
3182
+ }
3183
+ if (trustedTypesPolicy !== null && typeof emptyHTML === "string") {
3184
+ emptyHTML = trustedTypesPolicy.createHTML("");
3185
+ }
3186
+ }
3187
+ if (freeze) {
3188
+ freeze(cfg);
3189
+ }
3190
+ CONFIG = cfg;
3191
+ };
3192
+ const ALL_SVG_TAGS = addToSet({}, [...svg$1, ...svgFilters, ...svgDisallowed]);
3193
+ const ALL_MATHML_TAGS = addToSet({}, [...mathMl$1, ...mathMlDisallowed]);
3194
+ const _checkValidNamespace = function _checkValidNamespace2(element) {
3195
+ let parent2 = getParentNode(element);
3196
+ if (!parent2 || !parent2.tagName) {
3197
+ parent2 = {
3198
+ namespaceURI: NAMESPACE,
3199
+ tagName: "template"
3200
+ };
3201
+ }
3202
+ const tagName = stringToLowerCase(element.tagName);
3203
+ const parentTagName = stringToLowerCase(parent2.tagName);
3204
+ if (!ALLOWED_NAMESPACES[element.namespaceURI]) {
3205
+ return false;
3206
+ }
3207
+ if (element.namespaceURI === SVG_NAMESPACE) {
3208
+ if (parent2.namespaceURI === HTML_NAMESPACE) {
3209
+ return tagName === "svg";
3210
+ }
3211
+ if (parent2.namespaceURI === MATHML_NAMESPACE) {
3212
+ return tagName === "svg" && (parentTagName === "annotation-xml" || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
3213
+ }
3214
+ return Boolean(ALL_SVG_TAGS[tagName]);
3215
+ }
3216
+ if (element.namespaceURI === MATHML_NAMESPACE) {
3217
+ if (parent2.namespaceURI === HTML_NAMESPACE) {
3218
+ return tagName === "math";
3219
+ }
3220
+ if (parent2.namespaceURI === SVG_NAMESPACE) {
3221
+ return tagName === "math" && HTML_INTEGRATION_POINTS[parentTagName];
3222
+ }
3223
+ return Boolean(ALL_MATHML_TAGS[tagName]);
3224
+ }
3225
+ if (element.namespaceURI === HTML_NAMESPACE) {
3226
+ if (parent2.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) {
3227
+ return false;
3228
+ }
3229
+ if (parent2.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {
3230
+ return false;
3231
+ }
3232
+ return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);
3233
+ }
3234
+ if (PARSER_MEDIA_TYPE === "application/xhtml+xml" && ALLOWED_NAMESPACES[element.namespaceURI]) {
3235
+ return true;
3236
+ }
3237
+ return false;
3238
+ };
3239
+ const _forceRemove = function _forceRemove2(node) {
3240
+ arrayPush(DOMPurify.removed, {
3241
+ element: node
3242
+ });
3243
+ try {
3244
+ getParentNode(node).removeChild(node);
3245
+ } catch (_) {
3246
+ remove2(node);
3247
+ }
3248
+ };
3249
+ const _removeAttribute = function _removeAttribute2(name2, element) {
3250
+ try {
3251
+ arrayPush(DOMPurify.removed, {
3252
+ attribute: element.getAttributeNode(name2),
3253
+ from: element
3254
+ });
3255
+ } catch (_) {
3256
+ arrayPush(DOMPurify.removed, {
3257
+ attribute: null,
3258
+ from: element
3259
+ });
3260
+ }
3261
+ element.removeAttribute(name2);
3262
+ if (name2 === "is") {
3263
+ if (RETURN_DOM || RETURN_DOM_FRAGMENT) {
3264
+ try {
3265
+ _forceRemove(element);
3266
+ } catch (_) {
3267
+ }
3268
+ } else {
3269
+ try {
3270
+ element.setAttribute(name2, "");
3271
+ } catch (_) {
3272
+ }
3273
+ }
3274
+ }
3275
+ };
3276
+ const _initDocument = function _initDocument2(dirty) {
3277
+ let doc = null;
3278
+ let leadingWhitespace = null;
3279
+ if (FORCE_BODY) {
3280
+ dirty = "<remove></remove>" + dirty;
3281
+ } else {
3282
+ const matches = stringMatch(dirty, /^[\r\n\t ]+/);
3283
+ leadingWhitespace = matches && matches[0];
3284
+ }
3285
+ if (PARSER_MEDIA_TYPE === "application/xhtml+xml" && NAMESPACE === HTML_NAMESPACE) {
3286
+ dirty = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + dirty + "</body></html>";
3287
+ }
3288
+ const dirtyPayload = trustedTypesPolicy ? trustedTypesPolicy.createHTML(dirty) : dirty;
3289
+ if (NAMESPACE === HTML_NAMESPACE) {
3290
+ try {
3291
+ doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE);
3292
+ } catch (_) {
3293
+ }
3294
+ }
3295
+ if (!doc || !doc.documentElement) {
3296
+ doc = implementation.createDocument(NAMESPACE, "template", null);
3297
+ try {
3298
+ doc.documentElement.innerHTML = IS_EMPTY_INPUT ? emptyHTML : dirtyPayload;
3299
+ } catch (_) {
3300
+ }
3301
+ }
3302
+ const body = doc.body || doc.documentElement;
3303
+ if (dirty && leadingWhitespace) {
3304
+ body.insertBefore(document2.createTextNode(leadingWhitespace), body.childNodes[0] || null);
3305
+ }
3306
+ if (NAMESPACE === HTML_NAMESPACE) {
3307
+ return getElementsByTagName2.call(doc, WHOLE_DOCUMENT ? "html" : "body")[0];
3308
+ }
3309
+ return WHOLE_DOCUMENT ? doc.documentElement : body;
3310
+ };
3311
+ const _createNodeIterator = function _createNodeIterator2(root2) {
3312
+ return createNodeIterator.call(
3313
+ root2.ownerDocument || root2,
3314
+ root2,
3315
+ // eslint-disable-next-line no-bitwise
3316
+ NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT | NodeFilter.SHOW_PROCESSING_INSTRUCTION | NodeFilter.SHOW_CDATA_SECTION,
3317
+ null
3318
+ );
3319
+ };
3320
+ const _isClobbered = function _isClobbered2(element) {
3321
+ return element instanceof HTMLFormElement && (typeof element.nodeName !== "string" || typeof element.textContent !== "string" || typeof element.removeChild !== "function" || !(element.attributes instanceof NamedNodeMap) || typeof element.removeAttribute !== "function" || typeof element.setAttribute !== "function" || typeof element.namespaceURI !== "string" || typeof element.insertBefore !== "function" || typeof element.hasChildNodes !== "function");
3322
+ };
3323
+ const _isNode = function _isNode2(value) {
3324
+ return typeof Node3 === "function" && value instanceof Node3;
3325
+ };
3326
+ function _executeHooks(hooks2, currentNode, data2) {
3327
+ arrayForEach(hooks2, (hook) => {
3328
+ hook.call(DOMPurify, currentNode, data2, CONFIG);
3329
+ });
3330
+ }
3331
+ const _sanitizeElements = function _sanitizeElements2(currentNode) {
3332
+ let content = null;
3333
+ _executeHooks(hooks.beforeSanitizeElements, currentNode, null);
3334
+ if (_isClobbered(currentNode)) {
3335
+ _forceRemove(currentNode);
3336
+ return true;
3337
+ }
3338
+ const tagName = transformCaseFunc(currentNode.nodeName);
3339
+ _executeHooks(hooks.uponSanitizeElement, currentNode, {
3340
+ tagName,
3341
+ allowedTags: ALLOWED_TAGS
3342
+ });
3343
+ if (SAFE_FOR_XML && currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && regExpTest(/<[/\w!]/g, currentNode.innerHTML) && regExpTest(/<[/\w!]/g, currentNode.textContent)) {
3344
+ _forceRemove(currentNode);
3345
+ return true;
3346
+ }
3347
+ if (SAFE_FOR_XML && currentNode.namespaceURI === HTML_NAMESPACE && tagName === "style" && _isNode(currentNode.firstElementChild)) {
3348
+ _forceRemove(currentNode);
3349
+ return true;
3350
+ }
3351
+ if (currentNode.nodeType === NODE_TYPE$1.progressingInstruction) {
3352
+ _forceRemove(currentNode);
3353
+ return true;
3354
+ }
3355
+ if (SAFE_FOR_XML && currentNode.nodeType === NODE_TYPE$1.comment && regExpTest(/<[/\w]/g, currentNode.data)) {
3356
+ _forceRemove(currentNode);
3357
+ return true;
3358
+ }
3359
+ if (FORBID_TAGS[tagName] || !(EXTRA_ELEMENT_HANDLING.tagCheck instanceof Function && EXTRA_ELEMENT_HANDLING.tagCheck(tagName)) && !ALLOWED_TAGS[tagName]) {
3360
+ if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName)) {
3361
+ if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) {
3362
+ return false;
3363
+ }
3364
+ if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName)) {
3365
+ return false;
3366
+ }
3367
+ }
3368
+ if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {
3369
+ const parentNode = getParentNode(currentNode) || currentNode.parentNode;
3370
+ const childNodes = getChildNodes(currentNode) || currentNode.childNodes;
3371
+ if (childNodes && parentNode) {
3372
+ const childCount = childNodes.length;
3373
+ for (let i = childCount - 1; i >= 0; --i) {
3374
+ const childClone = cloneNode2(childNodes[i], true);
3375
+ parentNode.insertBefore(childClone, getNextSibling(currentNode));
3376
+ }
3377
+ }
3378
+ }
3379
+ _forceRemove(currentNode);
3380
+ return true;
3381
+ }
3382
+ if (currentNode instanceof Element2 && !_checkValidNamespace(currentNode)) {
3383
+ _forceRemove(currentNode);
3384
+ return true;
3385
+ }
3386
+ if ((tagName === "noscript" || tagName === "noembed" || tagName === "noframes") && regExpTest(/<\/no(script|embed|frames)/i, currentNode.innerHTML)) {
3387
+ _forceRemove(currentNode);
3388
+ return true;
3389
+ }
3390
+ if (SAFE_FOR_TEMPLATES && currentNode.nodeType === NODE_TYPE$1.text) {
3391
+ content = currentNode.textContent;
3392
+ arrayForEach([MUSTACHE_EXPR$1, ERB_EXPR$1, TMPLIT_EXPR$1], (expr) => {
3393
+ content = stringReplace(content, expr, " ");
3394
+ });
3395
+ if (currentNode.textContent !== content) {
3396
+ arrayPush(DOMPurify.removed, {
3397
+ element: currentNode.cloneNode()
3398
+ });
3399
+ currentNode.textContent = content;
3400
+ }
3401
+ }
3402
+ _executeHooks(hooks.afterSanitizeElements, currentNode, null);
3403
+ return false;
3404
+ };
3405
+ const _isValidAttribute = function _isValidAttribute2(lcTag, lcName, value) {
3406
+ if (FORBID_ATTR[lcName]) {
3407
+ return false;
3408
+ }
3409
+ if (SANITIZE_DOM && (lcName === "id" || lcName === "name") && (value in document2 || value in formElement)) {
3410
+ return false;
3411
+ }
3412
+ const nameIsPermitted = ALLOWED_ATTR[lcName] || EXTRA_ELEMENT_HANDLING.attributeCheck instanceof Function && EXTRA_ELEMENT_HANDLING.attributeCheck(lcName, lcTag);
3413
+ if (ALLOW_DATA_ATTR && !FORBID_ATTR[lcName] && regExpTest(DATA_ATTR$1, lcName)) ;
3414
+ else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR$1, lcName)) ;
3415
+ else if (!nameIsPermitted || FORBID_ATTR[lcName]) {
3416
+ if (
3417
+ // First condition does a very basic check if a) it's basically a valid custom element tagname AND
3418
+ // b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
3419
+ // and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck
3420
+ _isBasicCustomElement(lcTag) && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, lcTag) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(lcTag)) && (CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.attributeNameCheck, lcName) || CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.attributeNameCheck(lcName, lcTag)) || // Alternative, second condition checks if it's an `is`-attribute, AND
3421
+ // the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
3422
+ lcName === "is" && CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, value) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(value))
3423
+ ) ;
3424
+ else {
3425
+ return false;
3426
+ }
3427
+ } else if (URI_SAFE_ATTRIBUTES[lcName]) ;
3428
+ else if (regExpTest(IS_ALLOWED_URI$1, stringReplace(value, ATTR_WHITESPACE$1, ""))) ;
3429
+ else if ((lcName === "src" || lcName === "xlink:href" || lcName === "href") && lcTag !== "script" && stringIndexOf(value, "data:") === 0 && DATA_URI_TAGS[lcTag]) ;
3430
+ else if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA$1, stringReplace(value, ATTR_WHITESPACE$1, ""))) ;
3431
+ else if (value) {
3432
+ return false;
3433
+ } else ;
3434
+ return true;
3435
+ };
3436
+ const RESERVED_CUSTOM_ELEMENT_NAMES = addToSet({}, ["annotation-xml", "color-profile", "font-face", "font-face-format", "font-face-name", "font-face-src", "font-face-uri", "missing-glyph"]);
3437
+ const _isBasicCustomElement = function _isBasicCustomElement2(tagName) {
3438
+ return !RESERVED_CUSTOM_ELEMENT_NAMES[stringToLowerCase(tagName)] && regExpTest(CUSTOM_ELEMENT$1, tagName);
3439
+ };
3440
+ const _sanitizeAttributes = function _sanitizeAttributes2(currentNode) {
3441
+ _executeHooks(hooks.beforeSanitizeAttributes, currentNode, null);
3442
+ const attributes2 = currentNode.attributes;
3443
+ if (!attributes2 || _isClobbered(currentNode)) {
3444
+ return;
3445
+ }
3446
+ const hookEvent = {
3447
+ attrName: "",
3448
+ attrValue: "",
3449
+ keepAttr: true,
3450
+ allowedAttributes: ALLOWED_ATTR,
3451
+ forceKeepAttr: void 0
3452
+ };
3453
+ let l2 = attributes2.length;
3454
+ while (l2--) {
3455
+ const attr2 = attributes2[l2];
3456
+ const name2 = attr2.name, namespaceURI = attr2.namespaceURI, attrValue = attr2.value;
3457
+ const lcName = transformCaseFunc(name2);
3458
+ const initValue = attrValue;
3459
+ let value = name2 === "value" ? initValue : stringTrim(initValue);
3460
+ hookEvent.attrName = lcName;
3461
+ hookEvent.attrValue = value;
3462
+ hookEvent.keepAttr = true;
3463
+ hookEvent.forceKeepAttr = void 0;
3464
+ _executeHooks(hooks.uponSanitizeAttribute, currentNode, hookEvent);
3465
+ value = hookEvent.attrValue;
3466
+ if (SANITIZE_NAMED_PROPS && (lcName === "id" || lcName === "name") && stringIndexOf(value, SANITIZE_NAMED_PROPS_PREFIX) !== 0) {
3467
+ _removeAttribute(name2, currentNode);
3468
+ value = SANITIZE_NAMED_PROPS_PREFIX + value;
3469
+ }
3470
+ if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i, value)) {
3471
+ _removeAttribute(name2, currentNode);
3472
+ continue;
3473
+ }
3474
+ if (lcName === "attributename" && stringMatch(value, "href")) {
3475
+ _removeAttribute(name2, currentNode);
3476
+ continue;
3477
+ }
3478
+ if (hookEvent.forceKeepAttr) {
3479
+ continue;
3480
+ }
3481
+ if (!hookEvent.keepAttr) {
3482
+ _removeAttribute(name2, currentNode);
3483
+ continue;
3484
+ }
3485
+ if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(/\/>/i, value)) {
3486
+ _removeAttribute(name2, currentNode);
3487
+ continue;
3488
+ }
3489
+ if (SAFE_FOR_TEMPLATES) {
3490
+ arrayForEach([MUSTACHE_EXPR$1, ERB_EXPR$1, TMPLIT_EXPR$1], (expr) => {
3491
+ value = stringReplace(value, expr, " ");
3492
+ });
3493
+ }
3494
+ const lcTag = transformCaseFunc(currentNode.nodeName);
3495
+ if (!_isValidAttribute(lcTag, lcName, value)) {
3496
+ _removeAttribute(name2, currentNode);
3497
+ continue;
3498
+ }
3499
+ if (trustedTypesPolicy && typeof trustedTypes === "object" && typeof trustedTypes.getAttributeType === "function") {
3500
+ if (namespaceURI) ;
3501
+ else {
3502
+ switch (trustedTypes.getAttributeType(lcTag, lcName)) {
3503
+ case "TrustedHTML": {
3504
+ value = trustedTypesPolicy.createHTML(value);
3505
+ break;
3506
+ }
3507
+ case "TrustedScriptURL": {
3508
+ value = trustedTypesPolicy.createScriptURL(value);
3509
+ break;
3510
+ }
3511
+ }
3512
+ }
3513
+ }
3514
+ if (value !== initValue) {
3515
+ try {
3516
+ if (namespaceURI) {
3517
+ currentNode.setAttributeNS(namespaceURI, name2, value);
3518
+ } else {
3519
+ currentNode.setAttribute(name2, value);
3520
+ }
3521
+ if (_isClobbered(currentNode)) {
3522
+ _forceRemove(currentNode);
3523
+ } else {
3524
+ arrayPop(DOMPurify.removed);
3525
+ }
3526
+ } catch (_) {
3527
+ _removeAttribute(name2, currentNode);
3528
+ }
3529
+ }
3530
+ }
3531
+ _executeHooks(hooks.afterSanitizeAttributes, currentNode, null);
3532
+ };
3533
+ const _sanitizeShadowDOM2 = function _sanitizeShadowDOM(fragment) {
3534
+ let shadowNode = null;
3535
+ const shadowIterator = _createNodeIterator(fragment);
3536
+ _executeHooks(hooks.beforeSanitizeShadowDOM, fragment, null);
3537
+ while (shadowNode = shadowIterator.nextNode()) {
3538
+ _executeHooks(hooks.uponSanitizeShadowNode, shadowNode, null);
3539
+ _sanitizeElements(shadowNode);
3540
+ _sanitizeAttributes(shadowNode);
3541
+ if (shadowNode.content instanceof DocumentFragment) {
3542
+ _sanitizeShadowDOM2(shadowNode.content);
3543
+ }
3544
+ }
3545
+ _executeHooks(hooks.afterSanitizeShadowDOM, fragment, null);
3546
+ };
3547
+ const _sanitizeAttachedShadowRoots2 = function _sanitizeAttachedShadowRoots(root2) {
3548
+ if (root2.nodeType === NODE_TYPE$1.element && root2.shadowRoot instanceof DocumentFragment) {
3549
+ const sr = root2.shadowRoot;
3550
+ _sanitizeAttachedShadowRoots2(sr);
3551
+ _sanitizeShadowDOM2(sr);
3552
+ }
3553
+ const childNodes = root2.childNodes;
3554
+ if (!childNodes) {
3555
+ return;
3556
+ }
3557
+ const snapshot = [];
3558
+ arrayForEach(childNodes, (child) => {
3559
+ arrayPush(snapshot, child);
3560
+ });
3561
+ for (const child of snapshot) {
3562
+ _sanitizeAttachedShadowRoots2(child);
3563
+ }
3564
+ };
3565
+ DOMPurify.sanitize = function(dirty) {
3566
+ let cfg = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
3567
+ let body = null;
3568
+ let importedNode = null;
3569
+ let currentNode = null;
3570
+ let returnNode = null;
3571
+ IS_EMPTY_INPUT = !dirty;
3572
+ if (IS_EMPTY_INPUT) {
3573
+ dirty = "<!-->";
3574
+ }
3575
+ if (typeof dirty !== "string" && !_isNode(dirty)) {
3576
+ dirty = stringifyValue(dirty);
3577
+ if (typeof dirty !== "string") {
3578
+ throw typeErrorCreate("dirty is not a string, aborting");
3579
+ }
3580
+ }
3581
+ if (!DOMPurify.isSupported) {
3582
+ return dirty;
3583
+ }
3584
+ if (!SET_CONFIG) {
3585
+ _parseConfig(cfg);
3586
+ }
3587
+ DOMPurify.removed = [];
3588
+ if (typeof dirty === "string") {
3589
+ IN_PLACE = false;
3590
+ }
3591
+ if (IN_PLACE) {
3592
+ const nn = dirty.nodeName;
3593
+ if (typeof nn === "string") {
3594
+ const tagName = transformCaseFunc(nn);
3595
+ if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
3596
+ throw typeErrorCreate("root node is forbidden and cannot be sanitized in-place");
3597
+ }
3598
+ }
3599
+ _sanitizeAttachedShadowRoots2(dirty);
3600
+ } else if (dirty instanceof Node3) {
3601
+ body = _initDocument("<!---->");
3602
+ importedNode = body.ownerDocument.importNode(dirty, true);
3603
+ if (importedNode.nodeType === NODE_TYPE$1.element && importedNode.nodeName === "BODY") {
3604
+ body = importedNode;
3605
+ } else if (importedNode.nodeName === "HTML") {
3606
+ body = importedNode;
3607
+ } else {
3608
+ body.appendChild(importedNode);
3609
+ }
3610
+ _sanitizeAttachedShadowRoots2(importedNode);
3611
+ } else {
3612
+ if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT && // eslint-disable-next-line unicorn/prefer-includes
3613
+ dirty.indexOf("<") === -1) {
3614
+ return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(dirty) : dirty;
3615
+ }
3616
+ body = _initDocument(dirty);
3617
+ if (!body) {
3618
+ return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : "";
3619
+ }
3620
+ }
3621
+ if (body && FORCE_BODY) {
3622
+ _forceRemove(body.firstChild);
3623
+ }
3624
+ const nodeIterator = _createNodeIterator(IN_PLACE ? dirty : body);
3625
+ while (currentNode = nodeIterator.nextNode()) {
3626
+ _sanitizeElements(currentNode);
3627
+ _sanitizeAttributes(currentNode);
3628
+ if (currentNode.content instanceof DocumentFragment) {
3629
+ _sanitizeShadowDOM2(currentNode.content);
3630
+ }
3631
+ }
3632
+ if (IN_PLACE) {
3633
+ return dirty;
3634
+ }
3635
+ if (RETURN_DOM) {
3636
+ if (SAFE_FOR_TEMPLATES) {
3637
+ body.normalize();
3638
+ let html2 = body.innerHTML;
3639
+ arrayForEach([MUSTACHE_EXPR$1, ERB_EXPR$1, TMPLIT_EXPR$1], (expr) => {
3640
+ html2 = stringReplace(html2, expr, " ");
3641
+ });
3642
+ body.innerHTML = html2;
3643
+ }
3644
+ if (RETURN_DOM_FRAGMENT) {
3645
+ returnNode = createDocumentFragment.call(body.ownerDocument);
3646
+ while (body.firstChild) {
3647
+ returnNode.appendChild(body.firstChild);
3648
+ }
3649
+ } else {
3650
+ returnNode = body;
3651
+ }
3652
+ if (ALLOWED_ATTR.shadowroot || ALLOWED_ATTR.shadowrootmode) {
3653
+ returnNode = importNode.call(originalDocument, returnNode, true);
3654
+ }
3655
+ return returnNode;
3656
+ }
3657
+ let serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;
3658
+ if (WHOLE_DOCUMENT && ALLOWED_TAGS["!doctype"] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) {
3659
+ serializedHTML = "<!DOCTYPE " + body.ownerDocument.doctype.name + ">\n" + serializedHTML;
3660
+ }
3661
+ if (SAFE_FOR_TEMPLATES) {
3662
+ arrayForEach([MUSTACHE_EXPR$1, ERB_EXPR$1, TMPLIT_EXPR$1], (expr) => {
3663
+ serializedHTML = stringReplace(serializedHTML, expr, " ");
3664
+ });
3665
+ }
3666
+ return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(serializedHTML) : serializedHTML;
3667
+ };
3668
+ DOMPurify.setConfig = function() {
3669
+ let cfg = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
3670
+ _parseConfig(cfg);
3671
+ SET_CONFIG = true;
3672
+ };
3673
+ DOMPurify.clearConfig = function() {
3674
+ CONFIG = null;
3675
+ SET_CONFIG = false;
3676
+ };
3677
+ DOMPurify.isValidAttribute = function(tag, attr2, value) {
3678
+ if (!CONFIG) {
3679
+ _parseConfig({});
3680
+ }
3681
+ const lcTag = transformCaseFunc(tag);
3682
+ const lcName = transformCaseFunc(attr2);
3683
+ return _isValidAttribute(lcTag, lcName, value);
3684
+ };
3685
+ DOMPurify.addHook = function(entryPoint, hookFunction) {
3686
+ if (typeof hookFunction !== "function") {
3687
+ return;
3688
+ }
3689
+ arrayPush(hooks[entryPoint], hookFunction);
3690
+ };
3691
+ DOMPurify.removeHook = function(entryPoint, hookFunction) {
3692
+ if (hookFunction !== void 0) {
3693
+ const index2 = arrayLastIndexOf(hooks[entryPoint], hookFunction);
3694
+ return index2 === -1 ? void 0 : arraySplice(hooks[entryPoint], index2, 1)[0];
3695
+ }
3696
+ return arrayPop(hooks[entryPoint]);
3697
+ };
3698
+ DOMPurify.removeHooks = function(entryPoint) {
3699
+ hooks[entryPoint] = [];
3700
+ };
3701
+ DOMPurify.removeAllHooks = function() {
3702
+ hooks = _createHooksMap();
3703
+ };
3704
+ return DOMPurify;
3705
+ }
3706
+ var purify = createDOMPurify();
2435
3707
  ABConvert.factory({
2436
3708
  id: "md",
2437
3709
  name: "md",
@@ -2451,7 +3723,7 @@ ABConvert.factory({
2451
3723
  process_param: ABConvert_IOEnum.text,
2452
3724
  process_return: ABConvert_IOEnum.el,
2453
3725
  process: (el, header, content) => {
2454
- el.innerHTML = `<p>${content.replace(/ /g, "&nbsp;").split("\n").join("<br/>")}</p>`;
3726
+ el.innerHTML = purify.sanitize(`<p>${content.replace(/ /g, "&nbsp;").split("\n").join("<br/>")}</p>`);
2455
3727
  return el;
2456
3728
  }
2457
3729
  });
@@ -3171,12 +4443,10 @@ ABConvert.factory({
3171
4443
  process_return: ABConvert_IOEnum.json,
3172
4444
  process: (el, header, content) => {
3173
4445
  return JSON.stringify(
3174
- ABAlias_json.map((item) => {
3175
- return {
3176
- regex: item.regex.toString(),
3177
- replacement: item.replacement
3178
- };
3179
- }),
4446
+ Array.from(get_ABAlias_iter(), (item) => ({
4447
+ regex: item.regex.toString(),
4448
+ replacement: item.replacement
4449
+ })),
3180
4450
  null,
3181
4451
  2
3182
4452
  );
@@ -15127,7 +16397,7 @@ ABConvert.factory({
15127
16397
  async function render_pumlText(text2, div) {
15128
16398
  var encoded = plantumlEncoder.encode(text2);
15129
16399
  let url = "http://www.plantuml.com/plantuml/img/" + encoded;
15130
- div.innerHTML = `<img src="${url}">`;
16400
+ div.innerHTML = purify.sanitize(`<img src="${url}">`);
15131
16401
  return div;
15132
16402
  }
15133
16403
  function getID(length = 16) {
@@ -15302,206 +16572,20 @@ async function data2mindmap(list_itemInfo, div) {
15302
16572
  return render_mermaidText(mermaidText, div);
15303
16573
  }
15304
16574
  async function render_mermaidText(mermaidText, div) {
15305
- if (ABCSetting.env.startsWith("obsidian") && ABCSetting.mermaid) {
15306
- ABCSetting.mermaid.then(async (mermaid) => {
15307
- const { svg } = await mermaid.render("ab-mermaid-" + getID(), mermaidText);
15308
- div.innerHTML = svg;
16575
+ if (ABCSetting.env.startsWith("obsidian") && ABCSetting.obsidian.mermaid) {
16576
+ ABCSetting.obsidian.mermaid.then(async (mermaid) => {
16577
+ const { svg: svg2 } = await mermaid.render("ab-mermaid-" + getID(), mermaidText);
16578
+ const div_mermaid = document.createElement("div");
16579
+ div.appendChild(div_mermaid);
16580
+ div_mermaid.classList.add("mermaid");
16581
+ div_mermaid.innerHTML = svg2;
15309
16582
  });
15310
16583
  } else {
15311
16584
  div.classList.add("ab-raw");
15312
- div.innerHTML = `<div class="ab-raw-data" type-data="mermaid" content-data='${mermaidText}'></div>`;
16585
+ div.innerHTML = purify.sanitize(`<div class="ab-raw-data" type-data="mermaid" content-data='${mermaidText}'></div>`);
15313
16586
  }
15314
16587
  return div;
15315
16588
  }
15316
- function abConvertEvent(d, isCycle = false) {
15317
- if (d.querySelector(".ab-super-width")) {
15318
- const els_note = d.querySelectorAll(".ab-note");
15319
- for (const el_note of els_note) {
15320
- if (el_note.querySelector(".ab-super-width")) {
15321
- const el_replace = el_note.parentNode;
15322
- if (el_replace && el_replace.classList.contains("ab-replace")) {
15323
- el_replace.classList.add("ab-super-width-p");
15324
- }
15325
- }
15326
- }
15327
- const els_view = document.querySelectorAll(".app-container .workspace-leaf");
15328
- for (const el_view of els_view) {
15329
- el_view.style.setProperty("--ab-width-outer", (el_view.offsetWidth - 40).toString() + "px");
15330
- }
15331
- }
15332
- if (d.querySelector(".ab-nodes-node")) {
15333
- const els_min = document.querySelectorAll(".ab-nodes.min .ab-nodes-node");
15334
- const list_children = d.querySelectorAll(".ab-nodes-node");
15335
- for (const children2 of list_children) {
15336
- const el_content = children2.querySelector(".ab-nodes-content");
15337
- if (!el_content) continue;
15338
- const el_child = children2.querySelector(".ab-nodes-children");
15339
- if (!el_child) continue;
15340
- const el_bracket = el_child.querySelector(".ab-nodes-bracket");
15341
- if (!el_bracket) continue;
15342
- const el_bracket2 = el_child.querySelector(".ab-nodes-bracket2");
15343
- if (!el_bracket2) continue;
15344
- const els_child = el_child.childNodes;
15345
- if (els_child.length < 3) {
15346
- el_bracket.style.setProperty("display", "none");
15347
- el_bracket2.style.setProperty("display", "none");
15348
- continue;
15349
- }
15350
- const el_child_first = els_child[2];
15351
- const el_child_last = els_child[els_child.length - 1];
15352
- const el_child_first_content = el_child_first.querySelector(".ab-nodes-content");
15353
- const el_child_last_content = el_child_last.querySelector(".ab-nodes-content");
15354
- let height = 0;
15355
- let heightToReduce = (el_child_first.offsetHeight + el_child_last.offsetHeight) / 2;
15356
- if (els_child.length == 3) {
15357
- height = el_child_first_content.offsetHeight - 20 > 20 ? el_child_first_content.offsetHeight - 20 : 20;
15358
- el_bracket2.style.cssText = `
15359
- height: ${height}px;
15360
- top: calc(50% - ${height / 2}px);
15361
- `;
15362
- } else {
15363
- el_bracket2.style.cssText = `
15364
- height: calc(100% - ${heightToReduce}px);
15365
- top: ${el_child_first.offsetHeight / 2}px;
15366
- `;
15367
- }
15368
- if (Array.prototype.includes.call(els_min, children2)) {
15369
- if (els_child.length == 3) {
15370
- el_bracket.style.cssText = `
15371
- display: block;
15372
- top: calc(50% + ${el_content.offsetHeight / 2}px - 3px);
15373
- clip-path: circle(40% at 50% 40%);
15374
- `;
15375
- } else {
15376
- el_bracket.setAttribute("display", "none");
15377
- }
15378
- if (els_child.length == 3 && el_content.offsetHeight == el_child_first_content.offsetHeight) {
15379
- el_bracket2.style.cssText = `
15380
- height: 1px;
15381
- top: calc(50% + ${el_content.offsetHeight / 2}px - 1px);
15382
- width: 18px; /* 可以溢出点 */
15383
- border-radius: 0;
15384
- border: none;
15385
- border-bottom: 1px solid var(--node-color);
15386
- `;
15387
- } else {
15388
- if (els_child.length == 3) {
15389
- height = el_child_last_content.offsetHeight / 2 - el_content.offsetHeight / 2;
15390
- el_bracket2.style.setProperty("height", `${height}px`);
15391
- el_bracket2.style.setProperty("top", `calc(50% + ${el_content.offsetHeight / 2}px)`);
15392
- el_bracket2.style.setProperty("border-radius", `0 0 0 10px`);
15393
- el_bracket2.style.setProperty("border-top", `0`);
15394
- } else {
15395
- heightToReduce = el_child_first.offsetHeight / 2 + el_child_first_content.offsetHeight / 2 + el_child_last.offsetHeight / 2 - el_child_last_content.offsetHeight / 2;
15396
- el_bracket2.style.setProperty("height", `calc(100% - ${heightToReduce}px + 1px)`);
15397
- el_bracket2.style.setProperty("top", `${el_child_first.offsetHeight / 2 + el_child_first_content.offsetHeight / 2 - 1}px`);
15398
- }
15399
- el_bracket2.style.setProperty("width", "20px");
15400
- }
15401
- }
15402
- }
15403
- }
15404
- if (d.querySelector(".ab-items.ab-lay-vfall:not(.js-waterfall):not(.ab-lay-hfall):not(.ab-lay-grid)")) {
15405
- const root_el_list = d.querySelectorAll(".ab-items.ab-lay-vfall:not(.js-waterfall):not(.ab-lay-hfall):not(.ab-lay-grid)");
15406
- for (const root_el of root_el_list) {
15407
- root_el.classList.add("js-waterfall");
15408
- const list_children = root_el.querySelectorAll(".ab-items-item");
15409
- const columnCountTmp = parseInt(window.getComputedStyle(root_el).getPropertyValue("column-count"));
15410
- let columnCount;
15411
- if (columnCountTmp && !isNaN(columnCountTmp) && columnCountTmp > 0) {
15412
- columnCount = columnCountTmp;
15413
- } else if (root_el.classList.contains("ab-col-auto") && list_children.length <= 4) {
15414
- columnCount = list_children.length;
15415
- root_el.classList.add("ab-col" + columnCount);
15416
- } else {
15417
- columnCount = 4;
15418
- root_el.classList.add("ab-col" + columnCount);
15419
- }
15420
- const height_cache = [];
15421
- const el_cache = [];
15422
- for (let i = 0; i < columnCount; i++) {
15423
- height_cache.push(0);
15424
- el_cache.push([]);
15425
- }
15426
- for (const children2 of list_children) {
15427
- const minValue = Math.min.apply(null, height_cache);
15428
- const minIndex = height_cache.indexOf(minValue);
15429
- const heightTmp = parseInt(window.getComputedStyle(children2).getPropertyValue("height"));
15430
- height_cache[minIndex] += heightTmp && !isNaN(heightTmp) && heightTmp > 0 ? heightTmp : 10;
15431
- el_cache[minIndex].push(children2);
15432
- }
15433
- const fillNumber = columnCount - list_children.length % columnCount;
15434
- if (fillNumber != 4) {
15435
- for (let i = 0; i < fillNumber; i++) {
15436
- const children2 = document.createElement("div");
15437
- children2.classList.add(".ab-items-item.placeholder");
15438
- children2.setAttribute("style", "height: 20px");
15439
- const minValue = Math.min.apply(null, height_cache);
15440
- const minIndex = height_cache.indexOf(minValue);
15441
- height_cache[minIndex] += 20;
15442
- el_cache[minIndex].push(children2);
15443
- }
15444
- }
15445
- root_el.innerHTML = "";
15446
- for (let i = 0; i < columnCount; i++) {
15447
- for (const j of el_cache[i]) {
15448
- root_el.appendChild(j);
15449
- }
15450
- }
15451
- }
15452
- }
15453
- if (!isCycle && d.querySelector(".ab-markmap-div")) {
15454
- const divEl = d;
15455
- let markmapId = "";
15456
- if (divEl.tagName === "DIV") {
15457
- markmapId = divEl.querySelector(".ab-markmap-div")?.id || "";
15458
- }
15459
- let mindmaps;
15460
- if (markmapId) {
15461
- mindmaps = document.querySelectorAll("#" + markmapId);
15462
- } else {
15463
- mindmaps = document.querySelectorAll(".ab-markmap-div");
15464
- }
15465
- for (const el_div of mindmaps) {
15466
- const el_svg = el_div.querySelector("svg");
15467
- const el_g = el_svg?.querySelector("g");
15468
- if (el_svg && el_g) {
15469
- const scale_new = el_g.getBBox().height / el_div.offsetWidth;
15470
- el_svg.setAttribute("style", `height:${el_g.getBBox().height * scale_new + 40}px`);
15471
- markmap_event(d);
15472
- }
15473
- }
15474
- }
15475
- }
15476
- function markmap_event(d) {
15477
- if (d.querySelector(".ab-markmap-svg")) {
15478
- console.log(" - markmap_event");
15479
- let script_el = document.querySelector('script[script-id="ab-markmap-script"]');
15480
- if (script_el) script_el.remove();
15481
- const divEl = d;
15482
- let markmapId = "";
15483
- if (divEl.tagName === "DIV") {
15484
- markmapId = divEl.querySelector(".ab-markmap-svg")?.id || "";
15485
- }
15486
- script_el = document.createElement("script");
15487
- document.head.appendChild(script_el);
15488
- script_el.type = "module";
15489
- script_el.setAttribute("script-id", "ab-markmap-script");
15490
- script_el.textContent = `
15491
- import { Markmap, } from 'https://jspm.dev/markmap-view';
15492
- const markmapId = "${markmapId || ""}";
15493
- let mindmaps;
15494
- if (markmapId) {
15495
- mindmaps = document.querySelectorAll('#' + markmapId);
15496
- } else {
15497
- mindmaps = document.querySelectorAll('.ab-markmap-svg'); // 注意一下这里的选择器
15498
- }
15499
- for(const mindmap of mindmaps) {
15500
- mindmap.innerHTML = "";
15501
- Markmap.create(mindmap,null,JSON.parse(mindmap.getAttribute('data-json')));
15502
- }`;
15503
- }
15504
- }
15505
16589
  const testPath = "npm2url/dist/index.cjs";
15506
16590
  const defaultProviders = {
15507
16591
  jsdelivr: (path) => `https://cdn.jsdelivr.net/npm/${path}`,
@@ -41127,8 +42211,8 @@ function requireKatex() {
41127
42211
  var _functions = {};
41128
42212
  var _htmlGroupBuilders = {};
41129
42213
  var _mathmlGroupBuilders = {};
41130
- function defineFunction(_ref) {
41131
- var type = _ref.type, names = _ref.names, props = _ref.props, handler = _ref.handler, htmlBuilder = _ref.htmlBuilder, mathmlBuilder = _ref.mathmlBuilder;
42214
+ function defineFunction(_ref2) {
42215
+ var type = _ref2.type, names = _ref2.names, props = _ref2.props, handler = _ref2.handler, htmlBuilder = _ref2.htmlBuilder, mathmlBuilder = _ref2.mathmlBuilder;
41132
42216
  var data2 = {
41133
42217
  type,
41134
42218
  numArgs: props.numArgs,
@@ -42126,8 +43210,8 @@ function requireKatex() {
42126
43210
  props: {
42127
43211
  numArgs: 1
42128
43212
  },
42129
- handler: function handler(_ref, args) {
42130
- var parser = _ref.parser, funcName = _ref.funcName;
43213
+ handler: function handler(_ref2, args) {
43214
+ var parser = _ref2.parser, funcName = _ref2.funcName;
42131
43215
  var base = args[0];
42132
43216
  return {
42133
43217
  type: "accentUnder",
@@ -42202,8 +43286,8 @@ function requireKatex() {
42202
43286
  numArgs: 1,
42203
43287
  numOptionalArgs: 1
42204
43288
  },
42205
- handler: function handler(_ref, args, optArgs) {
42206
- var parser = _ref.parser, funcName = _ref.funcName;
43289
+ handler: function handler(_ref2, args, optArgs) {
43290
+ var parser = _ref2.parser, funcName = _ref2.funcName;
42207
43291
  return {
42208
43292
  type: "xArrow",
42209
43293
  mode: parser.mode,
@@ -42295,8 +43379,8 @@ function requireKatex() {
42295
43379
  numArgs: 1,
42296
43380
  allowedInText: true
42297
43381
  },
42298
- handler: function handler(_ref, args) {
42299
- var parser = _ref.parser;
43382
+ handler: function handler(_ref2, args) {
43383
+ var parser = _ref2.parser;
42300
43384
  var arg = assertNodeType(args[0], "ordgroup");
42301
43385
  var group = arg.body;
42302
43386
  var number = "";
@@ -42334,8 +43418,8 @@ function requireKatex() {
42334
43418
  greediness: 3,
42335
43419
  argTypes: ["color", "original"]
42336
43420
  },
42337
- handler: function handler(_ref, args) {
42338
- var parser = _ref.parser;
43421
+ handler: function handler(_ref2, args) {
43422
+ var parser = _ref2.parser;
42339
43423
  var color2 = assertNodeType(args[0], "color-token").color;
42340
43424
  var body = args[1];
42341
43425
  return {
@@ -42381,8 +43465,8 @@ function requireKatex() {
42381
43465
  argTypes: ["size"],
42382
43466
  allowedInText: true
42383
43467
  },
42384
- handler: function handler(_ref, args, optArgs) {
42385
- var parser = _ref.parser, funcName = _ref.funcName;
43468
+ handler: function handler(_ref2, args, optArgs) {
43469
+ var parser = _ref2.parser, funcName = _ref2.funcName;
42386
43470
  var size = optArgs[0];
42387
43471
  var newRow = funcName === "\\cr";
42388
43472
  var newLine = false;
@@ -42475,8 +43559,8 @@ function requireKatex() {
42475
43559
  numArgs: 0,
42476
43560
  allowedInText: true
42477
43561
  },
42478
- handler: function handler(_ref) {
42479
- var parser = _ref.parser, funcName = _ref.funcName;
43562
+ handler: function handler(_ref2) {
43563
+ var parser = _ref2.parser, funcName = _ref2.funcName;
42480
43564
  parser.consumeSpaces();
42481
43565
  var token = parser.fetch();
42482
43566
  if (globalMap[token.text]) {
@@ -42810,14 +43894,14 @@ function requireKatex() {
42810
43894
  var delimiter_sqrtSvg = function sqrtSvg(sqrtName, height, viewBoxHeight, extraViniculum, options) {
42811
43895
  var path = sqrtPath(sqrtName, extraViniculum, viewBoxHeight);
42812
43896
  var pathNode = new domTree_PathNode(sqrtName, path);
42813
- var svg = new SvgNode([pathNode], {
43897
+ var svg2 = new SvgNode([pathNode], {
42814
43898
  // Note: 1000:1 ratio of viewBox to document em width.
42815
43899
  "width": "400em",
42816
43900
  "height": height + "em",
42817
43901
  "viewBox": "0 0 400000 " + viewBoxHeight,
42818
43902
  "preserveAspectRatio": "xMinYMin slice"
42819
43903
  });
42820
- return buildCommon.makeSvgSpan(["hide-tail"], [svg], options);
43904
+ return buildCommon.makeSvgSpan(["hide-tail"], [svg2], options);
42821
43905
  };
42822
43906
  var makeSqrtImage = function makeSqrtImage2(height, options) {
42823
43907
  var newOptions = options.havingBaseSizing();
@@ -43427,8 +44511,8 @@ function requireKatex() {
43427
44511
  greediness: 3,
43428
44512
  argTypes: ["color", "text"]
43429
44513
  },
43430
- handler: function handler(_ref, args, optArgs) {
43431
- var parser = _ref.parser, funcName = _ref.funcName;
44514
+ handler: function handler(_ref2, args, optArgs) {
44515
+ var parser = _ref2.parser, funcName = _ref2.funcName;
43432
44516
  var color2 = assertNodeType(args[0], "color-token").color;
43433
44517
  var body = args[1];
43434
44518
  return {
@@ -43506,8 +44590,8 @@ function requireKatex() {
43506
44590
  mathmlBuilder: enclose_mathmlBuilder
43507
44591
  });
43508
44592
  var _environments = {};
43509
- function defineEnvironment(_ref) {
43510
- var type = _ref.type, names = _ref.names, props = _ref.props, handler = _ref.handler, htmlBuilder = _ref.htmlBuilder, mathmlBuilder = _ref.mathmlBuilder;
44593
+ function defineEnvironment(_ref2) {
44594
+ var type = _ref2.type, names = _ref2.names, props = _ref2.props, handler = _ref2.handler, htmlBuilder = _ref2.htmlBuilder, mathmlBuilder = _ref2.mathmlBuilder;
43511
44595
  var data2 = {
43512
44596
  type,
43513
44597
  numArgs: props.numArgs || 0,
@@ -43538,8 +44622,8 @@ function requireKatex() {
43538
44622
  }
43539
44623
  return hlineInfo;
43540
44624
  }
43541
- function parseArray(parser, _ref, style) {
43542
- var hskipBeforeAndAfter = _ref.hskipBeforeAndAfter, addJot = _ref.addJot, cols = _ref.cols, arraystretch = _ref.arraystretch, colSeparationType = _ref.colSeparationType;
44625
+ function parseArray(parser, _ref2, style) {
44626
+ var hskipBeforeAndAfter = _ref2.hskipBeforeAndAfter, addJot = _ref2.addJot, cols = _ref2.cols, arraystretch = _ref2.arraystretch, colSeparationType = _ref2.colSeparationType;
43543
44627
  parser.gullet.beginGroup();
43544
44628
  parser.gullet.macros.set("\\\\", "\\cr");
43545
44629
  if (!arraystretch) {
@@ -44178,8 +45262,8 @@ function requireKatex() {
44178
45262
  numArgs: 1,
44179
45263
  argTypes: ["text"]
44180
45264
  },
44181
- handler: function handler(_ref, args) {
44182
- var parser = _ref.parser, funcName = _ref.funcName;
45265
+ handler: function handler(_ref2, args) {
45266
+ var parser = _ref2.parser, funcName = _ref2.funcName;
44183
45267
  var nameGroup = args[0];
44184
45268
  if (nameGroup.type !== "ordgroup") {
44185
45269
  throw new src_ParseError("Invalid environment name", nameGroup);
@@ -44259,8 +45343,8 @@ function requireKatex() {
44259
45343
  props: {
44260
45344
  numArgs: 1
44261
45345
  },
44262
- handler: function handler(_ref, args) {
44263
- var parser = _ref.parser, funcName = _ref.funcName;
45346
+ handler: function handler(_ref2, args) {
45347
+ var parser = _ref2.parser, funcName = _ref2.funcName;
44264
45348
  var body = args[0];
44265
45349
  return {
44266
45350
  type: "mclass",
@@ -44383,8 +45467,8 @@ function requireKatex() {
44383
45467
  numArgs: 1,
44384
45468
  greediness: 2
44385
45469
  },
44386
- handler: function handler(_ref, args) {
44387
- var parser = _ref.parser, funcName = _ref.funcName;
45470
+ handler: function handler(_ref2, args) {
45471
+ var parser = _ref2.parser, funcName = _ref2.funcName;
44388
45472
  var body = args[0];
44389
45473
  var func = funcName;
44390
45474
  if (func in fontAliases) {
@@ -44638,8 +45722,8 @@ function requireKatex() {
44638
45722
  numArgs: 2,
44639
45723
  greediness: 2
44640
45724
  },
44641
- handler: function handler(_ref, args) {
44642
- var parser = _ref.parser, funcName = _ref.funcName;
45725
+ handler: function handler(_ref2, args) {
45726
+ var parser = _ref2.parser, funcName = _ref2.funcName;
44643
45727
  var numer = args[0];
44644
45728
  var denom = args[1];
44645
45729
  var hasBarLine;
@@ -44940,8 +46024,8 @@ function requireKatex() {
44940
46024
  props: {
44941
46025
  numArgs: 1
44942
46026
  },
44943
- handler: function handler(_ref, args) {
44944
- var parser = _ref.parser, funcName = _ref.funcName;
46027
+ handler: function handler(_ref2, args) {
46028
+ var parser = _ref2.parser, funcName = _ref2.funcName;
44945
46029
  return {
44946
46030
  type: "horizBrace",
44947
46031
  mode: parser.mode,
@@ -44961,8 +46045,8 @@ function requireKatex() {
44961
46045
  argTypes: ["url", "original"],
44962
46046
  allowedInText: true
44963
46047
  },
44964
- handler: function handler(_ref, args) {
44965
- var parser = _ref.parser;
46048
+ handler: function handler(_ref2, args) {
46049
+ var parser = _ref2.parser;
44966
46050
  var body = args[1];
44967
46051
  var href = assertNodeType(args[0], "url").url;
44968
46052
  if (!parser.settings.isTrusted({
@@ -45042,9 +46126,9 @@ function requireKatex() {
45042
46126
  argTypes: ["raw", "original"],
45043
46127
  allowedInText: true
45044
46128
  },
45045
- handler: function handler(_ref, args) {
45046
- var parser = _ref.parser, funcName = _ref.funcName;
45047
- _ref.token;
46129
+ handler: function handler(_ref2, args) {
46130
+ var parser = _ref2.parser, funcName = _ref2.funcName;
46131
+ _ref2.token;
45048
46132
  var value = assertNodeType(args[0], "raw").string;
45049
46133
  var body = args[1];
45050
46134
  if (parser.settings.strict) {
@@ -45127,8 +46211,8 @@ function requireKatex() {
45127
46211
  numArgs: 2,
45128
46212
  allowedInText: true
45129
46213
  },
45130
- handler: function handler(_ref, args) {
45131
- var parser = _ref.parser;
46214
+ handler: function handler(_ref2, args) {
46215
+ var parser = _ref2.parser;
45132
46216
  return {
45133
46217
  type: "htmlmathml",
45134
46218
  mode: parser.mode,
@@ -45175,8 +46259,8 @@ function requireKatex() {
45175
46259
  argTypes: ["raw", "url"],
45176
46260
  allowedInText: false
45177
46261
  },
45178
- handler: function handler(_ref, args, optArgs) {
45179
- var parser = _ref.parser;
46262
+ handler: function handler(_ref2, args, optArgs) {
46263
+ var parser = _ref2.parser;
45180
46264
  var width = {
45181
46265
  number: 0,
45182
46266
  unit: "em"
@@ -45290,8 +46374,8 @@ function requireKatex() {
45290
46374
  argTypes: ["size"],
45291
46375
  allowedInText: true
45292
46376
  },
45293
- handler: function handler(_ref, args) {
45294
- var parser = _ref.parser, funcName = _ref.funcName;
46377
+ handler: function handler(_ref2, args) {
46378
+ var parser = _ref2.parser, funcName = _ref2.funcName;
45295
46379
  var size = assertNodeType(args[0], "size");
45296
46380
  if (parser.settings.strict) {
45297
46381
  var mathFunction = funcName[1] === "m";
@@ -45330,8 +46414,8 @@ function requireKatex() {
45330
46414
  numArgs: 1,
45331
46415
  allowedInText: true
45332
46416
  },
45333
- handler: function handler(_ref, args) {
45334
- var parser = _ref.parser, funcName = _ref.funcName;
46417
+ handler: function handler(_ref2, args) {
46418
+ var parser = _ref2.parser, funcName = _ref2.funcName;
45335
46419
  var body = args[0];
45336
46420
  return {
45337
46421
  type: "lap",
@@ -45375,8 +46459,8 @@ function requireKatex() {
45375
46459
  allowedInText: true,
45376
46460
  allowedInMath: false
45377
46461
  },
45378
- handler: function handler(_ref, args) {
45379
- var funcName = _ref.funcName, parser = _ref.parser;
46462
+ handler: function handler(_ref2, args) {
46463
+ var funcName = _ref2.funcName, parser = _ref2.parser;
45380
46464
  var outerMode = parser.mode;
45381
46465
  parser.switchMode("math");
45382
46466
  var close = funcName === "\\(" ? "\\)" : "$";
@@ -45424,8 +46508,8 @@ function requireKatex() {
45424
46508
  props: {
45425
46509
  numArgs: 4
45426
46510
  },
45427
- handler: function handler(_ref, args) {
45428
- var parser = _ref.parser;
46511
+ handler: function handler(_ref2, args) {
46512
+ var parser = _ref2.parser;
45429
46513
  return {
45430
46514
  type: "mathchoice",
45431
46515
  mode: parser.mode,
@@ -45657,8 +46741,8 @@ function requireKatex() {
45657
46741
  props: {
45658
46742
  numArgs: 0
45659
46743
  },
45660
- handler: function handler(_ref, args) {
45661
- var parser = _ref.parser, funcName = _ref.funcName;
46744
+ handler: function handler(_ref2, args) {
46745
+ var parser = _ref2.parser, funcName = _ref2.funcName;
45662
46746
  var fName = funcName;
45663
46747
  if (fName.length === 1) {
45664
46748
  fName = singleCharBigOps[fName];
@@ -45864,8 +46948,8 @@ function requireKatex() {
45864
46948
  props: {
45865
46949
  numArgs: 1
45866
46950
  },
45867
- handler: function handler(_ref, args) {
45868
- var parser = _ref.parser, funcName = _ref.funcName;
46951
+ handler: function handler(_ref2, args) {
46952
+ var parser = _ref2.parser, funcName = _ref2.funcName;
45869
46953
  var body = args[0];
45870
46954
  return {
45871
46955
  type: "operatorname",
@@ -45897,8 +46981,8 @@ function requireKatex() {
45897
46981
  props: {
45898
46982
  numArgs: 1
45899
46983
  },
45900
- handler: function handler(_ref, args) {
45901
- var parser = _ref.parser;
46984
+ handler: function handler(_ref2, args) {
46985
+ var parser = _ref2.parser;
45902
46986
  var body = args[0];
45903
46987
  return {
45904
46988
  type: "overline",
@@ -45943,8 +47027,8 @@ function requireKatex() {
45943
47027
  numArgs: 1,
45944
47028
  allowedInText: true
45945
47029
  },
45946
- handler: function handler(_ref, args) {
45947
- var parser = _ref.parser;
47030
+ handler: function handler(_ref2, args) {
47031
+ var parser = _ref2.parser;
45948
47032
  var body = args[0];
45949
47033
  return {
45950
47034
  type: "phantom",
@@ -46042,8 +47126,8 @@ function requireKatex() {
46042
47126
  argTypes: ["size", "hbox"],
46043
47127
  allowedInText: true
46044
47128
  },
46045
- handler: function handler(_ref, args) {
46046
- var parser = _ref.parser;
47129
+ handler: function handler(_ref2, args) {
47130
+ var parser = _ref2.parser;
46047
47131
  var amount = assertNodeType(args[0], "size").value;
46048
47132
  var body = args[1];
46049
47133
  return {
@@ -46080,8 +47164,8 @@ function requireKatex() {
46080
47164
  numOptionalArgs: 1,
46081
47165
  argTypes: ["size", "size", "size"]
46082
47166
  },
46083
- handler: function handler(_ref, args, optArgs) {
46084
- var parser = _ref.parser;
47167
+ handler: function handler(_ref2, args, optArgs) {
47168
+ var parser = _ref2.parser;
46085
47169
  var shift = optArgs[0];
46086
47170
  var width = assertNodeType(args[0], "size");
46087
47171
  var height = assertNodeType(args[1], "size");
@@ -46154,8 +47238,8 @@ function requireKatex() {
46154
47238
  numArgs: 0,
46155
47239
  allowedInText: true
46156
47240
  },
46157
- handler: function handler(_ref, args) {
46158
- var breakOnTokenText = _ref.breakOnTokenText, funcName = _ref.funcName, parser = _ref.parser;
47241
+ handler: function handler(_ref2, args) {
47242
+ var breakOnTokenText = _ref2.breakOnTokenText, funcName = _ref2.funcName, parser = _ref2.parser;
46159
47243
  var body = parser.parseExpression(false, breakOnTokenText);
46160
47244
  return {
46161
47245
  type: "sizing",
@@ -46182,8 +47266,8 @@ function requireKatex() {
46182
47266
  numOptionalArgs: 1,
46183
47267
  allowedInText: true
46184
47268
  },
46185
- handler: function handler(_ref, args, optArgs) {
46186
- var parser = _ref.parser;
47269
+ handler: function handler(_ref2, args, optArgs) {
47270
+ var parser = _ref2.parser;
46187
47271
  var smashHeight = false;
46188
47272
  var smashDepth = false;
46189
47273
  var tbArg = optArgs[0] && assertNodeType(optArgs[0], "ordgroup");
@@ -46263,8 +47347,8 @@ function requireKatex() {
46263
47347
  numArgs: 1,
46264
47348
  numOptionalArgs: 1
46265
47349
  },
46266
- handler: function handler(_ref, args, optArgs) {
46267
- var parser = _ref.parser;
47350
+ handler: function handler(_ref2, args, optArgs) {
47351
+ var parser = _ref2.parser;
46268
47352
  var index2 = optArgs[0];
46269
47353
  var body = args[0];
46270
47354
  return {
@@ -46348,8 +47432,8 @@ function requireKatex() {
46348
47432
  numArgs: 0,
46349
47433
  allowedInText: true
46350
47434
  },
46351
- handler: function handler(_ref, args) {
46352
- var breakOnTokenText = _ref.breakOnTokenText, funcName = _ref.funcName, parser = _ref.parser;
47435
+ handler: function handler(_ref2, args) {
47436
+ var breakOnTokenText = _ref2.breakOnTokenText, funcName = _ref2.funcName, parser = _ref2.parser;
46353
47437
  var body = parser.parseExpression(true, breakOnTokenText);
46354
47438
  var style = funcName.slice(1, funcName.length - 5);
46355
47439
  return {
@@ -46734,8 +47818,8 @@ function requireKatex() {
46734
47818
  greediness: 2,
46735
47819
  allowedInText: true
46736
47820
  },
46737
- handler: function handler(_ref, args) {
46738
- var parser = _ref.parser, funcName = _ref.funcName;
47821
+ handler: function handler(_ref2, args) {
47822
+ var parser = _ref2.parser, funcName = _ref2.funcName;
46739
47823
  var body = args[0];
46740
47824
  return {
46741
47825
  type: "text",
@@ -46761,8 +47845,8 @@ function requireKatex() {
46761
47845
  numArgs: 1,
46762
47846
  allowedInText: true
46763
47847
  },
46764
- handler: function handler(_ref, args) {
46765
- var parser = _ref.parser;
47848
+ handler: function handler(_ref2, args) {
47849
+ var parser = _ref2.parser;
46766
47850
  return {
46767
47851
  type: "underline",
46768
47852
  mode: parser.mode,
@@ -49632,7 +50716,7 @@ ABConvert.factory({
49632
50716
  process_return: ABConvert_IOEnum.el,
49633
50717
  process: (el, header, content) => {
49634
50718
  list2markmap(content, el);
49635
- markmap_event(el);
50719
+ ABCSetting.obsidian.markmap_event?.(el);
49636
50720
  return el;
49637
50721
  }
49638
50722
  });
@@ -49648,13 +50732,46 @@ function list2markmap(markdown, div) {
49648
50732
  svg_div.classList.add("ab-markmap-div");
49649
50733
  svg_div.id = "ab-markmap-div-" + id;
49650
50734
  const html_str = `<svg class="ab-markmap-svg" id="ab-markmap-${id}" data-json='${JSON.stringify(root2)}' style="height:${height_adapt}px"></svg>`;
49651
- svg_div.innerHTML = html_str;
50735
+ svg_div.innerHTML = purify.sanitize(html_str, {
50736
+ USE_PROFILES: { svg: true }
50737
+ });
49652
50738
  } else {
49653
50739
  div.classList.add("ab-raw");
49654
- div.innerHTML = `<div class="ab-raw-data" type-data="markmap" content-data='${markdown}'></div>`;
50740
+ div.innerHTML = purify.sanitize(`<div class="ab-raw-data" type-data="markmap" content-data='${markdown}'></div>`);
49655
50741
  }
49656
50742
  return div;
49657
50743
  }
50744
+ async function markmap_event(d) {
50745
+ if (ABCSetting.env == "obsidian-min") return;
50746
+ if (d.querySelector(".ab-markmap-svg")) {
50747
+ console.log(" - markmap_event");
50748
+ let script_el = document.querySelector('script[script-id="ab-markmap-script"]');
50749
+ if (script_el) script_el.remove();
50750
+ const divEl = d;
50751
+ let markmapId = "";
50752
+ if (divEl.tagName === "DIV") {
50753
+ markmapId = divEl.querySelector(".ab-markmap-svg")?.id || "";
50754
+ }
50755
+ script_el = document.createElement("script");
50756
+ document.head.appendChild(script_el);
50757
+ script_el.type = "module";
50758
+ script_el.setAttribute("script-id", "ab-markmap-script");
50759
+ script_el.textContent = `
50760
+ import { Markmap, } from 'https://jspm.dev/markmap-view';
50761
+ const markmapId = "${markmapId || ""}";
50762
+ let mindmaps;
50763
+ if (markmapId) {
50764
+ mindmaps = document.querySelectorAll('#' + markmapId);
50765
+ } else {
50766
+ mindmaps = document.querySelectorAll('.ab-markmap-svg'); // 注意一下这里的选择器
50767
+ }
50768
+ for(const mindmap of mindmaps) {
50769
+ mindmap.innerHTML = "";
50770
+ Markmap.create(mindmap,null,JSON.parse(mindmap.getAttribute('data-json')));
50771
+ }`;
50772
+ }
50773
+ }
50774
+ ABCSetting.obsidian.markmap_event = markmap_event;
49658
50775
  const md = new MarkdownIt({
49659
50776
  html: true,
49660
50777
  // 启用 HTML 标签解析
@@ -49711,6 +50828,166 @@ const quartz_transformer_anyblock = () => {
49711
50828
  }
49712
50829
  };
49713
50830
  };
50831
+ function abConvertEvent(d, isCycle = false) {
50832
+ if (d.querySelector(".ab-super-width")) {
50833
+ const els_note = d.querySelectorAll(".ab-note");
50834
+ for (const el_note of els_note) {
50835
+ if (el_note.classList.contains("ab-super-width") || el_note.querySelector(".ab-super-width")) {
50836
+ const el_replace = el_note.parentNode;
50837
+ if (el_replace && el_replace.classList.contains("ab-replace")) {
50838
+ el_replace.classList.add("ab-super-width-p");
50839
+ }
50840
+ }
50841
+ }
50842
+ const els_view = document.querySelectorAll(".app-container .workspace-leaf");
50843
+ for (const el_view of els_view) {
50844
+ el_view.style.setProperty("--ab-width-outer", (el_view.offsetWidth - 40).toString() + "px");
50845
+ }
50846
+ }
50847
+ if (d.querySelector(".ab-nodes-node")) {
50848
+ const els_min = document.querySelectorAll(".ab-nodes.min .ab-nodes-node");
50849
+ const list_children = d.querySelectorAll(".ab-nodes-node");
50850
+ for (const children2 of list_children) {
50851
+ const el_content = children2.querySelector(".ab-nodes-content");
50852
+ if (!el_content) continue;
50853
+ const el_child = children2.querySelector(".ab-nodes-children");
50854
+ if (!el_child) continue;
50855
+ const el_bracket = el_child.querySelector(".ab-nodes-bracket");
50856
+ if (!el_bracket) continue;
50857
+ const el_bracket2 = el_child.querySelector(".ab-nodes-bracket2");
50858
+ if (!el_bracket2) continue;
50859
+ const els_child = el_child.childNodes;
50860
+ if (els_child.length < 3) {
50861
+ el_bracket.style.setProperty("display", "none");
50862
+ el_bracket2.style.setProperty("display", "none");
50863
+ continue;
50864
+ }
50865
+ const el_child_first = els_child[2];
50866
+ const el_child_last = els_child[els_child.length - 1];
50867
+ const el_child_first_content = el_child_first.querySelector(".ab-nodes-content");
50868
+ const el_child_last_content = el_child_last.querySelector(".ab-nodes-content");
50869
+ let height = 0;
50870
+ let heightToReduce = (el_child_first.offsetHeight + el_child_last.offsetHeight) / 2;
50871
+ if (els_child.length == 3) {
50872
+ height = el_child_first_content.offsetHeight - 20 > 20 ? el_child_first_content.offsetHeight - 20 : 20;
50873
+ el_bracket2.style.cssText = `
50874
+ height: ${height}px;
50875
+ top: calc(50% - ${height / 2}px);
50876
+ `;
50877
+ } else {
50878
+ el_bracket2.style.cssText = `
50879
+ height: calc(100% - ${heightToReduce}px);
50880
+ top: ${el_child_first.offsetHeight / 2}px;
50881
+ `;
50882
+ }
50883
+ if (Array.prototype.includes.call(els_min, children2)) {
50884
+ if (els_child.length == 3) {
50885
+ el_bracket.style.cssText = `
50886
+ display: block;
50887
+ top: calc(50% + ${el_content.offsetHeight / 2}px - 3px);
50888
+ clip-path: circle(40% at 50% 40%);
50889
+ `;
50890
+ } else {
50891
+ el_bracket.setAttribute("display", "none");
50892
+ }
50893
+ if (els_child.length == 3 && el_content.offsetHeight == el_child_first_content.offsetHeight) {
50894
+ el_bracket2.style.cssText = `
50895
+ height: 1px;
50896
+ top: calc(50% + ${el_content.offsetHeight / 2}px - 1px);
50897
+ width: 18px; /* 可以溢出点 */
50898
+ border-radius: 0;
50899
+ border: none;
50900
+ border-bottom: 1px solid var(--node-color);
50901
+ `;
50902
+ } else {
50903
+ if (els_child.length == 3) {
50904
+ height = el_child_last_content.offsetHeight / 2 - el_content.offsetHeight / 2;
50905
+ el_bracket2.style.setProperty("height", `${height}px`);
50906
+ el_bracket2.style.setProperty("top", `calc(50% + ${el_content.offsetHeight / 2}px)`);
50907
+ el_bracket2.style.setProperty("border-radius", `0 0 0 10px`);
50908
+ el_bracket2.style.setProperty("border-top", `0`);
50909
+ } else {
50910
+ heightToReduce = el_child_first.offsetHeight / 2 + el_child_first_content.offsetHeight / 2 + el_child_last.offsetHeight / 2 - el_child_last_content.offsetHeight / 2;
50911
+ el_bracket2.style.setProperty("height", `calc(100% - ${heightToReduce}px + 1px)`);
50912
+ el_bracket2.style.setProperty("top", `${el_child_first.offsetHeight / 2 + el_child_first_content.offsetHeight / 2 - 1}px`);
50913
+ }
50914
+ el_bracket2.style.setProperty("width", "20px");
50915
+ }
50916
+ }
50917
+ }
50918
+ }
50919
+ if (d.querySelector(".ab-items.ab-lay-vfall:not(.js-waterfall):not(.ab-lay-hfall):not(.ab-lay-grid)")) {
50920
+ const root_el_list = d.querySelectorAll(".ab-items.ab-lay-vfall:not(.js-waterfall):not(.ab-lay-hfall):not(.ab-lay-grid)");
50921
+ for (const root_el of root_el_list) {
50922
+ root_el.classList.add("js-waterfall");
50923
+ const list_children = root_el.querySelectorAll(".ab-items-item");
50924
+ const columnCountTmp = parseInt(window.getComputedStyle(root_el).getPropertyValue("column-count"));
50925
+ let columnCount;
50926
+ if (columnCountTmp && !isNaN(columnCountTmp) && columnCountTmp > 0) {
50927
+ columnCount = columnCountTmp;
50928
+ } else if (root_el.classList.contains("ab-col-auto") && list_children.length <= 4) {
50929
+ columnCount = list_children.length;
50930
+ root_el.classList.add("ab-col" + columnCount);
50931
+ } else {
50932
+ columnCount = 4;
50933
+ root_el.classList.add("ab-col" + columnCount);
50934
+ }
50935
+ const height_cache = [];
50936
+ const el_cache = [];
50937
+ for (let i = 0; i < columnCount; i++) {
50938
+ height_cache.push(0);
50939
+ el_cache.push([]);
50940
+ }
50941
+ for (const children2 of list_children) {
50942
+ const minValue = Math.min.apply(null, height_cache);
50943
+ const minIndex = height_cache.indexOf(minValue);
50944
+ const heightTmp = parseInt(window.getComputedStyle(children2).getPropertyValue("height"));
50945
+ height_cache[minIndex] += heightTmp && !isNaN(heightTmp) && heightTmp > 0 ? heightTmp : 10;
50946
+ el_cache[minIndex].push(children2);
50947
+ }
50948
+ const fillNumber = columnCount - list_children.length % columnCount;
50949
+ if (fillNumber != 4) {
50950
+ for (let i = 0; i < fillNumber; i++) {
50951
+ const children2 = document.createElement("div");
50952
+ children2.classList.add(".ab-items-item.placeholder");
50953
+ children2.setAttribute("style", "height: 20px");
50954
+ const minValue = Math.min.apply(null, height_cache);
50955
+ const minIndex = height_cache.indexOf(minValue);
50956
+ height_cache[minIndex] += 20;
50957
+ el_cache[minIndex].push(children2);
50958
+ }
50959
+ }
50960
+ root_el.innerHTML = "";
50961
+ for (let i = 0; i < columnCount; i++) {
50962
+ for (const j of el_cache[i]) {
50963
+ root_el.appendChild(j);
50964
+ }
50965
+ }
50966
+ }
50967
+ }
50968
+ if (!isCycle && d.querySelector(".ab-markmap-div")) {
50969
+ const divEl = d;
50970
+ let markmapId = "";
50971
+ if (divEl.tagName === "DIV") {
50972
+ markmapId = divEl.querySelector(".ab-markmap-div")?.id || "";
50973
+ }
50974
+ let mindmaps;
50975
+ if (markmapId) {
50976
+ mindmaps = document.querySelectorAll("#" + markmapId);
50977
+ } else {
50978
+ mindmaps = document.querySelectorAll(".ab-markmap-div");
50979
+ }
50980
+ for (const el_div of mindmaps) {
50981
+ const el_svg = el_div.querySelector("svg");
50982
+ const el_g = el_svg?.querySelector("g");
50983
+ if (el_svg && el_g) {
50984
+ const scale_new = el_g.getBBox().height / el_div.offsetWidth;
50985
+ el_svg.setAttribute("style", `height:${el_g.getBBox().height * scale_new + 40}px`);
50986
+ ABCSetting.obsidian.markmap_event?.(d);
50987
+ }
50988
+ }
50989
+ }
50990
+ }
49714
50991
  export {
49715
50992
  ABConvertManager,
49716
50993
  ABReg,