@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.
@@ -62,6 +62,16 @@ function jsdom_disable() {
62
62
  global.history = void 0;
63
63
  global.document = void 0;
64
64
  }
65
+ const ABCSetting = {
66
+ env: "obsidian",
67
+ // 某些环境的独占 api,其他环境用不上
68
+ obsidian: {
69
+ global_app: null,
70
+ global_ctx: null,
71
+ mermaid: void 0,
72
+ markmap_event: void 0
73
+ }
74
+ };
65
75
  const ABReg = {
66
76
  /**
67
77
  * AB块头部
@@ -83,9 +93,9 @@ const ABReg = {
83
93
  * - 不允许 `::` 是避免与 dataview 的 inline property 冲突
84
94
  */
85
95
  // 有前缀版本(给选择器用)
86
- reg_header: /^((\s|>\s|-\s|\*\s|\+\s)*)(%%)?(\[((?!toc|TOC|\!|< )[\|\!#:;\(\)\s0-9a-zA-Z\u4e00-\u9fa5](?!.*::).*)\]):?(%%)?\s*$/,
96
+ reg_header: /^((\s|>\s|-\s|\*\s|\+\s)*)(%%)?(\[((?!toc|TOC|\!|< )[\|\!#:;\(\)\s0-9a-zA-Z\u4e00-\u9fa5](?!.*::).*)\]):?\3\s*$/,
87
97
  // 可以用空`|`来解除首字符限制。(`|`注意:可以用来弄严格模式,`#`注意:建议后面空一格避免变成“标签”,`!`注意:别易误触发 `> [!note]`
88
- reg_header_up: /^((\s|>\s|-\s|\*\s|\+\s)*)(%%)?(\[((?!toc|TOC|\!)< [\|\!#:;\(\)\s0-9a-zA-Z\u4e00-\u9fa5](?!.*::).*)\]):?(%%)?\s*$/,
98
+ reg_header_up: /^((\s|>\s|-\s|\*\s|\+\s)*)(%%)?(\[((?!toc|TOC|\!)< [\|\!#:;\(\)\s0-9a-zA-Z\u4e00-\u9fa5](?!.*::).*)\]):?\3\s*$/,
89
99
  // 向上检查标志的 头部选择器
90
100
  reg_mdit_head: /^((\s|>\s|-\s|\*\s|\+\s)*)(::::*)\s?(.*)/,
91
101
  reg_mdit_tail: /^((\s|>\s|-\s|\*\s|\+\s)*)(::::*)/,
@@ -98,8 +108,8 @@ const ABReg = {
98
108
  reg_heading: /^((\s|>\s|-\s|\*\s|\+\s)*)(\#+\s)(.*)/,
99
109
  reg_table: /^((\s|>\s|-\s|\*\s|\+\s)*)(\|(.*)\|)/,
100
110
  // 无前缀版本(给处理器用,处理器不需要处理前缀,前缀在选择器阶段已经被去除了)
101
- reg_header_noprefix: /^((\s)*)(%%)?(\[((?!toc|TOC|\!|< )[\|\!#:;\(\)\s0-9a-zA-Z\u4e00-\u9fa5](?!.*::).*)\]):?(%%)?\s*$/,
102
- reg_header_up_noprefix: /^((\s)*)(%%)?(\[((?!toc|TOC|\!)< [\|\!#:;\(\)\s0-9a-zA-Z\u4e00-\u9fa5](?!.*::).*)\]):?(%%)?\s*$/,
111
+ reg_header_noprefix: /^((\s)*)(%%)?(\[((?!toc|TOC|\!|< )[\|\!#:;\(\)\s0-9a-zA-Z\u4e00-\u9fa5](?!.*::).*)\]):?\3\s*$/,
112
+ reg_header_up_noprefix: /^((\s)*)(%%)?(\[((?!toc|TOC|\!)< [\|\!#:;\(\)\s0-9a-zA-Z\u4e00-\u9fa5](?!.*::).*)\]):?\3\s*$/,
103
113
  reg_mdit_head_noprefix: /^((\s)*)(::::*)\s?(.*)/,
104
114
  reg_mdit_tail_noprefix: /^((\s)*)(::::*)/,
105
115
  reg_list_noprefix: /^((\s)*)(-\s|\*\s|\+\s)(.*)/,
@@ -112,12 +122,6 @@ const ABReg = {
112
122
  inline_split: /\| |, |, |\. |。 |: |: /
113
123
  // 内联切分。`|`或全角符号+一空格,半角符号+两空格 (后者由于空格压缩,若经历了重渲染可能有问题)
114
124
  };
115
- const ABCSetting = {
116
- env: "obsidian",
117
- // MarkdownPostProcessorContext类型, obsidian专用
118
- mermaid: void 0
119
- // obsidian专用,表示使用哪种方式渲染mermaid
120
- };
121
125
  const convert = (
122
126
  // Note: overloads in JSDoc can’t yet use different `@template`s.
123
127
  /**
@@ -392,11 +396,11 @@ function autoABAlias(header, selectorName, content) {
392
396
  } else if (selectorName == "table" || ABReg.reg_table_noprefix.test(content.trimStart())) {
393
397
  header = "|table_140lne" + header;
394
398
  }
395
- for (const item of ABAlias_json) {
399
+ for (const item of get_ABAlias_iter()) {
396
400
  header = header.replace(item.regex, item.replacement);
397
401
  }
398
402
  for (const item of ABAlias_json_withSub) {
399
- header = header.replace(item.regex, (match2, ...groups) => {
403
+ header = header.replace(item.regex, (_match, ...groups) => {
400
404
  return item.replacement.replace(/\$(\d+)/g, (_, number) => groups[number - 1] ?? "");
401
405
  });
402
406
  }
@@ -429,15 +433,39 @@ const ABAlias_json_withSub = [
429
433
  // 注意避免和原上/上面的callout语法冲突,以及自身递归
430
434
  ];
431
435
  const ABAlias_json_mdit = [
432
- { regex: /\|:::_140lne\|(2?tabs?|标签页?)\|/, replacement: "|mditTabs|" },
436
+ { regex: /\|:::_140lne\|((?:mdit2|2)?tabs?|标签页?)\|/, replacement: "|mditTabs|" },
433
437
  { regex: "|:::_140lne|demo|", replacement: "|mditDemo|" },
434
438
  { regex: "|:::_140lne|abDemo|", replacement: "|mditABDemo|" },
435
- { regex: /\|:::_140lne\|(2?col|分栏)\|/, replacement: "|mditCol|" },
436
- { regex: /\|:::_140lne\|(2?card|卡片)\|/, replacement: "|mditCard|" },
437
- { regex: /\|:::_140lne\|(2?chat|聊天)\|/, replacement: "|mditChat|code(chat)|" }
439
+ { regex: /\|:::_140lne\|((?:mdit2|2)?col|分栏)\|/, replacement: "|mditCol|" },
440
+ { regex: /\|:::_140lne\|((?:mdit2|2)?card|卡片)\|/, replacement: "|mditCard|" },
441
+ { regex: /\|:::_140lne\|((?:mdit2|2)?chat|聊天)\|/, replacement: "|mditChat|code(chat)|" },
442
+ //
443
+ // {regex: /\|:::_140lne\|2?(timeline|时间线)\|/, replacement: "|title2timeline|"},
444
+ // {regex: /\|:::_140lne\|2?(tabs?|标签页?)\||\|title2tabs?\|/, replacement: "|title2c2listdata|c2listdata2tab|"},
445
+ // {regex: /\|:::_140lne\|2?(col|分栏)\||\|title2col\|/, replacement: "|title2c2listdata|c2listdata2items|addClass(ab-col)|"},
446
+ // {regex: /\|:::_140lne\|2?(card|卡片)\||\|title2card\|/, replacement: "|title2c2listdata|c2listdata2items|addClass(ab-card)|addClass(ab-lay-vfall)|"},
447
+ // {regex: /\|:::_140lne\|2?(nodes?|节点)\||\|(title2node|title2abMindmap)\|/, replacement: "|title2listdata|listdata2strict|listdata2nodes|"},
448
+ // list - 多叉多层树
449
+ { regex: /\|:::_140lne\|(?:mdit2|2)?(mermaid|flow|流程图)\|/, replacement: "|mdit2list|list2mermaid|" },
450
+ { regex: /\|:::_140lne\|(?:mdit2|2)?(mehrmaid|mdmermaid)\|/, replacement: "|mdit2list|list2mehrmaidText|code(mehrmaid)|" },
451
+ { regex: /\|:::_140lne\|(?:mdit2|2)?(puml)?(plantuml|mindmap|脑图|思维导图)\|/, replacement: "|mdit2list|list2pumlMindmap|" },
452
+ { regex: /\|:::_140lne\|(?:mdit2|2)?(markmap|mdMindmap|md脑图|md思维导图)\|/, replacement: "|mdit2list|list2markmap|" },
453
+ { regex: /\|:::_140lne\|(?:mdit2|2)?(wbs|(工作)?分解(图|结构))\|/, replacement: "|mdit2list|list2pumlWBS|" },
454
+ { regex: /\|:::_140lne\|(?:mdit2|2)?(table|multiWayTable|multiCrossTable|表格?|多叉表格?|跨行表格?)\|/, replacement: "|mdit2Listdata|listdata2strict|listdata2table|" },
455
+ // list - lt树 (属于多层一叉树)
456
+ { regex: /\|:::_140lne\|(?:mdit2|2)?(lt|listTable|treeTable|listGrid|treeGrid|列表格|树形表格?)\|/, replacement: "|mdit2list|list2lt|" },
457
+ { regex: /\|:::_140lne\|2?(list|列表)\|/, replacement: "|mdit2list|list2lt|addClass(ab-listtable-likelist)|" },
458
+ { regex: /\|:::_140lne\|(?:mdit2|2)?(dir|dirTree|目录树?|目录结构)\|/, replacement: "|mdit2list|list2dt|" },
459
+ // list - 二层树
460
+ { regex: /\|:::_140lne\|(fakeList|仿列表)\|/, replacement: "|mdit2list|list2table|addClass(ab-table-fc)|addClass(ab-table-likelist)|" },
461
+ // 至后
462
+ { regex: "|mdit2list|", replacement: "|mdit2listdata|listdata2strict|listdata2list|" },
463
+ { regex: "|mdit2List|", replacement: "|mdit2Listdata|listdata2strict|listdata2list|" }
438
464
  ];
439
465
  const ABAlias_json_title = [
440
- { regex: "|title2list|", replacement: "|title2listdata|listdata2strict|listdata2list|" },
466
+ // 至前,特殊
467
+ { regex: "|heading2", replacement: "|title2" },
468
+ { regex: "|h2", replacement: "|title2" },
441
469
  // title - list&title
442
470
  { regex: /\|heading_140lne\|2?(timeline|时间线)\|/, replacement: "|title2timeline|" },
443
471
  { regex: /\|heading_140lne\|2?(tabs?|标签页?)\||\|title2tabs?\|/, replacement: "|title2c2listdata|c2listdata2tab|" },
@@ -450,13 +478,15 @@ const ABAlias_json_title = [
450
478
  { regex: /\|heading_140lne\|2?(puml)?(plantuml|mindmap|脑图|思维导图)\|/, replacement: "|title2list|list2pumlMindmap|" },
451
479
  { regex: /\|heading_140lne\|2?(markmap|mdMindmap|md脑图|md思维导图)\|/, replacement: "|title2list|list2markmap|" },
452
480
  { regex: /\|heading_140lne\|2?(wbs|(工作)?分解(图|结构))\|/, replacement: "|title2list|list2pumlWBS|" },
453
- { regex: /\|heading_140lne\|2?(table|multiWayTable|multiCrossTable|表格?|多叉表格?|跨行表格?)\|/, replacement: "|title2list|list2table|" },
481
+ { regex: /\|heading_140lne\|2?(table|multiWayTable|multiCrossTable|表格?|多叉表格?|跨行表格?)\|/, replacement: "|title2Listdata|listdata2strict|listdata2table|" },
454
482
  // list - lt树 (属于多层一叉树)
455
483
  { regex: /\|heading_140lne\|2?(lt|listTable|treeTable|listGrid|treeGrid|列表格|树形表格?)\|/, replacement: "|title2list|list2lt|" },
456
484
  { regex: /\|heading_140lne\|2?(list|列表)\|/, replacement: "|title2list|list2lt|addClass(ab-listtable-likelist)|" },
457
485
  { regex: /\|heading_140lne\|2?(dir|dirTree|目录树?|目录结构)\|/, replacement: "|title2list|list2dt|" },
458
486
  // list - 二层树
459
- { regex: /\|heading_140lne\|(fakeList|仿列表)\|/, replacement: "|title2list|list2table|addClass(ab-table-fc)|addClass(ab-table-likelist)|" }
487
+ { regex: /\|heading_140lne\|(fakeList|仿列表)\|/, replacement: "|title2list|list2table|addClass(ab-table-fc)|addClass(ab-table-likelist)|" },
488
+ // 至后
489
+ { regex: "|title2list|", replacement: "|title2listdata|listdata2strict|listdata2list|" }
460
490
  ];
461
491
  const ABAlias_json_list = [
462
492
  // 特殊
@@ -540,7 +570,9 @@ const ABAlias_json_general = [
540
570
  { regex: "|超超小字|", replacement: "|addClass(ab-custom-font-smallxx)|" },
541
571
  { regex: "|加粗|", replacement: "|addClass(ab-custom-font-bold)|" }
542
572
  ];
543
- const ABAlias_json_default = [
573
+ const ABAlias_user = [];
574
+ const ABAlias_pro = [];
575
+ const ABAlias_default = [
544
576
  ...ABAlias_json_mdit,
545
577
  ...ABAlias_json_title,
546
578
  ...ABAlias_json_list,
@@ -550,10 +582,11 @@ const ABAlias_json_default = [
550
582
  ...ABAlias_json_general
551
583
  // 这个放最后
552
584
  ];
553
- let ABAlias_json = [
554
- ...ABAlias_json_default
555
- // 设置决定是否停用
556
- ];
585
+ function* get_ABAlias_iter() {
586
+ yield* ABAlias_user;
587
+ yield* ABAlias_pro;
588
+ yield* ABAlias_default;
589
+ }
557
590
  const ABAlias_json_end = [
558
591
  { regex: "|:::_140lne", replacement: "" },
559
592
  { regex: "|heading_140lne", replacement: "" },
@@ -610,24 +643,18 @@ class ABConvertManager {
610
643
  * @param header 转换方式
611
644
  * @param content 要转换的初始文本 (无前缀版本,前缀在选择器环节已经删除了)
612
645
  * @param selectorName 选择器名,空表示未知
613
- * @return 等于el,无用,后面可以删了
614
646
  */
615
647
  static autoABConvert(el, header, content, selectorName = "", ctx) {
616
- let prev_result = content;
617
- let prev_type = "string";
618
- let prev_type2 = ABConvert_IOEnum.text;
619
- let prev_processor;
620
648
  let prev2 = {
621
- // 组合在一起是为了引用传参
622
- prev_result,
623
- prev_type,
624
- prev_type2,
625
- prev_processor
649
+ prev_result: content,
650
+ prev_type: "string",
651
+ prev_type2: ABConvert_IOEnum.text,
652
+ prev_processor: void 0
626
653
  };
627
654
  {
628
- header = autoABAlias(header, selectorName, prev_result);
655
+ header = autoABAlias(header, selectorName, prev2.prev_result);
629
656
  let list_header = header.split("|");
630
- prev_result = this.autoABConvert_runConvert(el, list_header, prev2, ctx);
657
+ this.autoABConvert_runConvert(el, list_header, prev2, ctx);
631
658
  this.autoABConvert_last(el, header, selectorName, prev2, ctx);
632
659
  }
633
660
  }
@@ -686,7 +713,12 @@ class ABConvertManager {
686
713
  break;
687
714
  }
688
715
  }
689
- prev2.prev_result = abReplaceProcessor.process(el, item_header, prev2.prev_result, ctx);
716
+ try {
717
+ prev2.prev_result = abReplaceProcessor.process(el, item_header, prev2.prev_result, ctx);
718
+ } catch (e) {
719
+ console.error(`处理器执行错误, id:${abReplaceProcessor.id}, header:${item_header}, error:`, e);
720
+ break;
721
+ }
690
722
  prev2.prev_type = typeof prev2.prev_result;
691
723
  prev2.prev_type2 = abReplaceProcessor.process_return;
692
724
  prev2.prev_processor = abReplaceProcessor.process;
@@ -700,7 +732,7 @@ class ABConvertManager {
700
732
  /**
701
733
  * 子函数,后处理/尾处理,主要进行末尾追加指令
702
734
  */
703
- static autoABConvert_last(el, header, selectorName, prev2, ctx) {
735
+ static autoABConvert_last(el, _header, _selectorName, prev2, _ctx) {
704
736
  if (prev2.prev_type == "string" && prev2.prev_type2 == ABConvert_IOEnum.text) {
705
737
  const subEl = document.createElement("div");
706
738
  el.appendChild(subEl);
@@ -708,7 +740,7 @@ class ABConvertManager {
708
740
  prev2.prev_result = el;
709
741
  prev2.prev_type = "object";
710
742
  prev2.prev_type2 = ABConvert_IOEnum.el;
711
- prev2.process = "md";
743
+ prev2.prev_processor = "md";
712
744
  } else if (prev2.prev_type == "string" && prev2.prev_type2 == ABConvert_IOEnum.json) {
713
745
  const code_str = "```json\n" + prev2.prev_result + "\n```\n";
714
746
  const subEl = document.createElement("div");
@@ -717,7 +749,7 @@ class ABConvertManager {
717
749
  prev2.prev_result = el;
718
750
  prev2.prev_type = "object";
719
751
  prev2.prev_type2 = ABConvert_IOEnum.el;
720
- prev2.process = "show_json";
752
+ prev2.prev_processor = "show_json";
721
753
  } 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)) {
722
754
  const code_str = "```json\n" + JSON.stringify(prev2.prev_result, null, 2) + "\n```\n";
723
755
  const subEl = document.createElement("div");
@@ -726,7 +758,7 @@ class ABConvertManager {
726
758
  prev2.prev_result = el;
727
759
  prev2.prev_type = "object";
728
760
  prev2.prev_type2 = ABConvert_IOEnum.el;
729
- prev2.process = "show_listStream";
761
+ prev2.prev_processor = "show_listStream";
730
762
  } else if (prev2.prev_type == "object" && prev2.prev_type2 == ABConvert_IOEnum.el) {
731
763
  return prev2;
732
764
  } else {
@@ -1170,7 +1202,7 @@ class ListProcess {
1170
1202
  }
1171
1203
  }
1172
1204
  /**
1173
- * 标题大纲转列表数据(@todo 正文的level+10,要减掉)
1205
+ * 标题大纲转列表数据
1174
1206
  *
1175
1207
  * @detail
1176
1208
  * 这里要将标题、正文、列表 的等级合为一块,所以存在偏移值:
@@ -1179,8 +1211,13 @@ class ListProcess {
1179
1211
  * 2. 正文等级, = 0, 取值[+1,+Infi]
1180
1212
  * 3. 列表等级, = `(.*)-`个数+1, 取值[0]
1181
1213
  *
1214
+ * (比较旧版是正文+10,列表+11,后来允许标题等级为负数。这样方便很多)
1215
+ *
1216
+ * @fine_mode 精细拆分模式
1217
+ * - true: 会将正文和列表拆分成多个节点
1218
+ * - false: 会将标题+正文+列表合并成一个节点
1182
1219
  */
1183
- static title2data(text2) {
1220
+ static title2data(text2, fine_mode = true) {
1184
1221
  let list_itemInfo = [];
1185
1222
  const list_text = text2.split("\n");
1186
1223
  let mul_mode = "";
@@ -1190,12 +1227,23 @@ class ListProcess {
1190
1227
  const match2 = line.match(ABReg.reg_code);
1191
1228
  if (match2 && match2[3]) {
1192
1229
  codeBlockFlag = match2[1] + match2[3];
1193
- list_itemInfo[list_itemInfo.length - 1].content = list_itemInfo[list_itemInfo.length - 1].content + "\n" + line;
1230
+ if (!fine_mode && list_itemInfo.length > 0) {
1231
+ list_itemInfo[list_itemInfo.length - 1].content += "\n" + line;
1232
+ } else if (mul_mode === "heading" || mul_mode === "") {
1233
+ removeTailBlank();
1234
+ list_itemInfo.push({
1235
+ content: line,
1236
+ level: 0
1237
+ });
1238
+ mul_mode = "para";
1239
+ } else {
1240
+ list_itemInfo[list_itemInfo.length - 1].content += "\n" + line;
1241
+ }
1194
1242
  continue;
1195
1243
  }
1196
1244
  } else {
1197
1245
  if (line.indexOf(codeBlockFlag) == 0) codeBlockFlag = "";
1198
- list_itemInfo[list_itemInfo.length - 1].content = list_itemInfo[list_itemInfo.length - 1].content + "\n" + line;
1246
+ list_itemInfo[list_itemInfo.length - 1].content += "\n" + line;
1199
1247
  continue;
1200
1248
  }
1201
1249
  const match_heading = line.match(ABReg.reg_heading_noprefix);
@@ -1203,32 +1251,133 @@ class ListProcess {
1203
1251
  if (match_heading && !match_heading[1]) {
1204
1252
  removeTailBlank();
1205
1253
  list_itemInfo.push({
1206
- content: match_heading[4],
1254
+ content: fine_mode ? match_heading[4] : line,
1255
+ // 可选是否把标题标志也放进去
1207
1256
  level: match_heading[3].length - 1 - 10
1208
1257
  });
1209
1258
  mul_mode = "heading";
1259
+ } else if (!fine_mode && list_itemInfo.length > 0) {
1260
+ list_itemInfo[list_itemInfo.length - 1].content += "\n" + line;
1261
+ continue;
1210
1262
  } else if (match_list) {
1211
1263
  removeTailBlank();
1212
1264
  list_itemInfo.push({
1213
1265
  content: match_list[4],
1214
1266
  level: match_list[1].length + 1
1215
- //+10
1216
1267
  });
1217
1268
  mul_mode = "list";
1218
- } else if (/^\S/.test(line) && mul_mode == "list") {
1219
- list_itemInfo[list_itemInfo.length - 1].content = list_itemInfo[list_itemInfo.length - 1].content + "\n" + line;
1269
+ } else if (mul_mode == "list" && /^\s/.test(line)) {
1270
+ list_itemInfo[list_itemInfo.length - 1].content += "\n" + line.trimStart();
1271
+ continue;
1220
1272
  } else {
1221
1273
  if (mul_mode == "para") {
1222
- list_itemInfo[list_itemInfo.length - 1].content = list_itemInfo[list_itemInfo.length - 1].content + "\n" + line;
1274
+ list_itemInfo[list_itemInfo.length - 1].content += "\n" + line;
1275
+ continue;
1223
1276
  } else if (/^\s*$/.test(line)) {
1224
1277
  continue;
1225
1278
  } else {
1279
+ removeTailBlank();
1226
1280
  list_itemInfo.push({
1227
1281
  content: line,
1228
1282
  level: 0
1229
- //+10
1230
1283
  });
1231
1284
  mul_mode = "para";
1285
+ continue;
1286
+ }
1287
+ }
1288
+ }
1289
+ removeTailBlank();
1290
+ return list_itemInfo;
1291
+ function removeTailBlank() {
1292
+ if (mul_mode == "para" || mul_mode == "list") {
1293
+ list_itemInfo[list_itemInfo.length - 1].content = list_itemInfo[list_itemInfo.length - 1].content.replace(/\s*$/, "");
1294
+ }
1295
+ }
1296
+ }
1297
+ /**
1298
+ * MarkdownIt 转列表数据
1299
+ *
1300
+ * @detail
1301
+ * 与 title2data 的逻辑基本相同
1302
+ *
1303
+ * 有很多写法变型和语法糖,所以逻辑比较复杂。
1304
+ * 具体设计详见 "docs/docs/dev docs/其他层级表示法.md"
1305
+ *
1306
+ * 支持:
1307
+ *
1308
+ * - 单行标题模式
1309
+ * - 多行标题模式
1310
+ * - 缺少分割标题模式
1311
+ *
1312
+ * @fine_mode 精细拆分模式
1313
+ * - true: 会将正文和列表拆分成多个节点
1314
+ * - false: 会将标题+正文+列表合并成一个节点
1315
+ */
1316
+ static mdit2data(text2, fine_mode = true) {
1317
+ let list_itemInfo = [];
1318
+ const list_text = text2.split("\n");
1319
+ let mul_mode = "";
1320
+ let codeBlockFlag = "";
1321
+ for (let line of list_text) {
1322
+ if (codeBlockFlag == "") {
1323
+ const match2 = line.match(ABReg.reg_code);
1324
+ if (match2 && match2[3]) {
1325
+ codeBlockFlag = match2[1] + match2[3];
1326
+ if (!fine_mode && list_itemInfo.length > 0) {
1327
+ list_itemInfo[list_itemInfo.length - 1].content += "\n" + line;
1328
+ } else if (mul_mode === "mdit" || mul_mode === "") {
1329
+ removeTailBlank();
1330
+ list_itemInfo.push({
1331
+ content: line,
1332
+ level: 0
1333
+ });
1334
+ mul_mode = "para";
1335
+ } else {
1336
+ list_itemInfo[list_itemInfo.length - 1].content += "\n" + line;
1337
+ }
1338
+ continue;
1339
+ }
1340
+ } else {
1341
+ if (line.indexOf(codeBlockFlag) == 0) codeBlockFlag = "";
1342
+ list_itemInfo[list_itemInfo.length - 1].content += "\n" + line;
1343
+ continue;
1344
+ }
1345
+ const match_mdit = line.match(/^(\s*)@(\d+)(?:\s+(.*))?$/);
1346
+ const match_list = line.match(ABReg.reg_list_noprefix);
1347
+ if (match_mdit && !match_mdit[1]) {
1348
+ removeTailBlank();
1349
+ list_itemInfo.push({
1350
+ content: match_mdit[3] ?? "",
1351
+ level: Number(match_mdit[2]) - 100
1352
+ });
1353
+ mul_mode = "mdit";
1354
+ } else if (!fine_mode && list_itemInfo.length > 0) {
1355
+ list_itemInfo[list_itemInfo.length - 1].content += "\n" + line;
1356
+ continue;
1357
+ } else if (match_list) {
1358
+ removeTailBlank();
1359
+ list_itemInfo.push({
1360
+ content: match_list[4],
1361
+ level: match_list[1].length + 1
1362
+ });
1363
+ mul_mode = "list";
1364
+ } else if (mul_mode == "list" && /^\s/.test(line)) {
1365
+ list_itemInfo[list_itemInfo.length - 1].content += "\n" + line.trimStart();
1366
+ continue;
1367
+ } else {
1368
+ if (mul_mode == "para") {
1369
+ list_itemInfo[list_itemInfo.length - 1].content += "\n" + line;
1370
+ continue;
1371
+ } else if (/^\s*$/.test(line)) {
1372
+ continue;
1373
+ } else {
1374
+ removeTailBlank();
1375
+ list_itemInfo.push({
1376
+ content: line,
1377
+ level: 0
1378
+ });
1379
+ mul_mode = "para";
1380
+ continue;
1232
1381
  }
1233
1382
  }
1234
1383
  }
@@ -1447,7 +1596,7 @@ const abc_list2listdata = ABConvert.factory({
1447
1596
  process_param: ABConvert_IOEnum.text,
1448
1597
  process_return: ABConvert_IOEnum.list_stream,
1449
1598
  detail: "列表到listdata",
1450
- process: (el, header, content) => {
1599
+ process: (_el, _header, content) => {
1451
1600
  return ListProcess.list2data(content);
1452
1601
  }
1453
1602
  });
@@ -1456,9 +1605,39 @@ const abc_title2listdata = ABConvert.factory({
1456
1605
  name: "标题到listdata",
1457
1606
  process_param: ABConvert_IOEnum.text,
1458
1607
  process_return: ABConvert_IOEnum.list_stream,
1459
- detail: "标题到listdata",
1460
- process: (el, header, content) => {
1461
- return ListProcess.title2data(content);
1608
+ detail: "标题到listdata。细粒度版本,列表会拆分成多个节点",
1609
+ process: (_el, _header, content) => {
1610
+ return ListProcess.title2data(content, true);
1611
+ }
1612
+ });
1613
+ ABConvert.factory({
1614
+ id: "title2Listdata",
1615
+ name: "标题到Listdata",
1616
+ process_param: ABConvert_IOEnum.text,
1617
+ process_return: ABConvert_IOEnum.list_stream,
1618
+ detail: "标题到Listdata。粗粒度版本,列表为一个节点,不会拆分",
1619
+ process: (_el, _header, content) => {
1620
+ return ListProcess.title2data(content, false);
1621
+ }
1622
+ });
1623
+ ABConvert.factory({
1624
+ id: "mdit2listdata",
1625
+ name: "mdit到listdata",
1626
+ process_param: ABConvert_IOEnum.text,
1627
+ process_return: ABConvert_IOEnum.list_stream,
1628
+ detail: "mdit到listdata。细粒度版本,列表会拆分成多个节点",
1629
+ process: (_el, _header, content) => {
1630
+ return ListProcess.mdit2data(content, true);
1631
+ }
1632
+ });
1633
+ ABConvert.factory({
1634
+ id: "mdit2Listdata",
1635
+ name: "mdit到Listdata",
1636
+ process_param: ABConvert_IOEnum.text,
1637
+ process_return: ABConvert_IOEnum.list_stream,
1638
+ detail: "mdit到Listdata。粗粒度版本,列表为一个节点,不会拆分",
1639
+ process: (_el, _header, content) => {
1640
+ return ListProcess.mdit2data(content, false);
1462
1641
  }
1463
1642
  });
1464
1643
  ABConvert.factory({
@@ -1467,7 +1646,7 @@ ABConvert.factory({
1467
1646
  process_param: ABConvert_IOEnum.list_stream,
1468
1647
  process_return: ABConvert_IOEnum.text,
1469
1648
  detail: "listdata到列表",
1470
- process: (el, header, content) => {
1649
+ process: (_el, _header, content) => {
1471
1650
  return ListProcess.data2list(content);
1472
1651
  }
1473
1652
  });
@@ -1477,17 +1656,18 @@ ABConvert.factory({
1477
1656
  process_param: ABConvert_IOEnum.list_stream,
1478
1657
  process_return: ABConvert_IOEnum.el,
1479
1658
  detail: "listdata到节点图",
1480
- process: (el, header, content) => {
1659
+ process: (el, _header, content) => {
1481
1660
  return ListProcess.data2nodes(content, el);
1482
1661
  }
1483
1662
  });
1484
1663
  ABConvert.factory({
1485
1664
  id: "listdata2strict",
1486
1665
  name: "listdata严格化",
1666
+ match: /listdata2strict|listdata2lint/,
1487
1667
  process_param: ABConvert_IOEnum.list_stream,
1488
1668
  process_return: ABConvert_IOEnum.list_stream,
1489
1669
  detail: "将列表数据转化为更规范的列表数据。统一缩进符(2空格 4空格 tab混用)为level 1、禁止跳等级(h1直接就到h3)",
1490
- process: (el, header, content) => {
1670
+ process: (_el, _header, content) => {
1491
1671
  return ListProcess.data2strict(content);
1492
1672
  }
1493
1673
  });
@@ -1497,7 +1677,7 @@ ABConvert.factory({
1497
1677
  process_param: ABConvert_IOEnum.list_stream,
1498
1678
  process_return: ABConvert_IOEnum.list_stream,
1499
1679
  detail: "当列表中存在任务列表项时,令此列表项支持任务项",
1500
- process: (el, header, content) => {
1680
+ process: (_el, _header, content) => {
1501
1681
  return ListProcess.data2taskData(content);
1502
1682
  }
1503
1683
  });
@@ -1507,7 +1687,7 @@ ABConvert.factory({
1507
1687
  process_param: ABConvert_IOEnum.text,
1508
1688
  process_return: ABConvert_IOEnum.json,
1509
1689
  detail: "列表到listnode",
1510
- process: (el, header, content) => {
1690
+ process: (_el, _header, content) => {
1511
1691
  const data2 = ListProcess.list2listnode(content);
1512
1692
  return JSON.stringify(data2, null, 2);
1513
1693
  }
@@ -1518,7 +1698,7 @@ ABConvert.factory({
1518
1698
  process_param: ABConvert_IOEnum.text,
1519
1699
  process_return: ABConvert_IOEnum.json,
1520
1700
  detail: "列表到json",
1521
- process: (el, header, content) => {
1701
+ process: (_el, _header, content) => {
1522
1702
  const data2 = ListProcess.list2json(content);
1523
1703
  return JSON.stringify(data2, null, 2);
1524
1704
  }
@@ -2031,6 +2211,19 @@ ABConvert.factory({
2031
2211
  return el = TableProcess.data2table(data2, el, matchs[2] == "T");
2032
2212
  }
2033
2213
  });
2214
+ ABConvert.factory({
2215
+ id: "listdata2table",
2216
+ name: "列表数据转表格",
2217
+ match: /listdata2(md)?table(T)?/,
2218
+ default: "listdata2table",
2219
+ process_param: ABConvert_IOEnum.list_stream,
2220
+ process_return: ABConvert_IOEnum.el,
2221
+ process: (el, header, content) => {
2222
+ const matchs = header.match(/listdata2(md)?table(T)?/);
2223
+ if (!matchs) return el;
2224
+ return el = TableProcess.data2table(content, el, matchs[2] == "T");
2225
+ }
2226
+ });
2034
2227
  ABConvert.factory({
2035
2228
  id: "list2c2t",
2036
2229
  name: "列表转二列表格",
@@ -2456,6 +2649,1085 @@ ABConvert.factory({
2456
2649
  return newContent;
2457
2650
  }
2458
2651
  });
2652
+ function _arrayLikeToArray(r, a) {
2653
+ (null == a || a > r.length) && (a = r.length);
2654
+ for (var e = 0, n2 = Array(a); e < a; e++) n2[e] = r[e];
2655
+ return n2;
2656
+ }
2657
+ function _arrayWithHoles(r) {
2658
+ if (Array.isArray(r)) return r;
2659
+ }
2660
+ function _iterableToArrayLimit(r, l2) {
2661
+ var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
2662
+ if (null != t) {
2663
+ var e, n2, i, u, a = [], f = true, o = false;
2664
+ try {
2665
+ if (i = (t = t.call(r)).next, 0 === l2) ;
2666
+ else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l2); f = true) ;
2667
+ } catch (r2) {
2668
+ o = true, n2 = r2;
2669
+ } finally {
2670
+ try {
2671
+ if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
2672
+ } finally {
2673
+ if (o) throw n2;
2674
+ }
2675
+ }
2676
+ return a;
2677
+ }
2678
+ }
2679
+ function _nonIterableRest() {
2680
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
2681
+ }
2682
+ function _slicedToArray(r, e) {
2683
+ return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
2684
+ }
2685
+ function _unsupportedIterableToArray(r, a) {
2686
+ if (r) {
2687
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
2688
+ var t = {}.toString.call(r).slice(8, -1);
2689
+ 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;
2690
+ }
2691
+ }
2692
+ const entries = Object.entries, setPrototypeOf = Object.setPrototypeOf, isFrozen = Object.isFrozen, getPrototypeOf = Object.getPrototypeOf, getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
2693
+ let freeze = Object.freeze, seal = Object.seal, create = Object.create;
2694
+ let _ref = typeof Reflect !== "undefined" && Reflect, apply = _ref.apply, construct = _ref.construct;
2695
+ if (!freeze) {
2696
+ freeze = function freeze2(x) {
2697
+ return x;
2698
+ };
2699
+ }
2700
+ if (!seal) {
2701
+ seal = function seal2(x) {
2702
+ return x;
2703
+ };
2704
+ }
2705
+ if (!apply) {
2706
+ apply = function apply2(func, thisArg) {
2707
+ for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
2708
+ args[_key - 2] = arguments[_key];
2709
+ }
2710
+ return func.apply(thisArg, args);
2711
+ };
2712
+ }
2713
+ if (!construct) {
2714
+ construct = function construct2(Func) {
2715
+ for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
2716
+ args[_key2 - 1] = arguments[_key2];
2717
+ }
2718
+ return new Func(...args);
2719
+ };
2720
+ }
2721
+ const arrayForEach = unapply(Array.prototype.forEach);
2722
+ const arrayLastIndexOf = unapply(Array.prototype.lastIndexOf);
2723
+ const arrayPop = unapply(Array.prototype.pop);
2724
+ const arrayPush = unapply(Array.prototype.push);
2725
+ const arraySplice = unapply(Array.prototype.splice);
2726
+ const arrayIsArray = Array.isArray;
2727
+ const stringToLowerCase = unapply(String.prototype.toLowerCase);
2728
+ const stringToString = unapply(String.prototype.toString);
2729
+ const stringMatch = unapply(String.prototype.match);
2730
+ const stringReplace = unapply(String.prototype.replace);
2731
+ const stringIndexOf = unapply(String.prototype.indexOf);
2732
+ const stringTrim = unapply(String.prototype.trim);
2733
+ const numberToString = unapply(Number.prototype.toString);
2734
+ const booleanToString = unapply(Boolean.prototype.toString);
2735
+ const bigintToString = typeof BigInt === "undefined" ? null : unapply(BigInt.prototype.toString);
2736
+ const symbolToString = typeof Symbol === "undefined" ? null : unapply(Symbol.prototype.toString);
2737
+ const objectHasOwnProperty = unapply(Object.prototype.hasOwnProperty);
2738
+ const objectToString = unapply(Object.prototype.toString);
2739
+ const regExpTest = unapply(RegExp.prototype.test);
2740
+ const typeErrorCreate = unconstruct(TypeError);
2741
+ function unapply(func) {
2742
+ return function(thisArg) {
2743
+ if (thisArg instanceof RegExp) {
2744
+ thisArg.lastIndex = 0;
2745
+ }
2746
+ for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
2747
+ args[_key3 - 1] = arguments[_key3];
2748
+ }
2749
+ return apply(func, thisArg, args);
2750
+ };
2751
+ }
2752
+ function unconstruct(Func) {
2753
+ return function() {
2754
+ for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
2755
+ args[_key4] = arguments[_key4];
2756
+ }
2757
+ return construct(Func, args);
2758
+ };
2759
+ }
2760
+ function addToSet(set2, array) {
2761
+ let transformCaseFunc = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : stringToLowerCase;
2762
+ if (setPrototypeOf) {
2763
+ setPrototypeOf(set2, null);
2764
+ }
2765
+ if (!arrayIsArray(array)) {
2766
+ return set2;
2767
+ }
2768
+ let l2 = array.length;
2769
+ while (l2--) {
2770
+ let element = array[l2];
2771
+ if (typeof element === "string") {
2772
+ const lcElement = transformCaseFunc(element);
2773
+ if (lcElement !== element) {
2774
+ if (!isFrozen(array)) {
2775
+ array[l2] = lcElement;
2776
+ }
2777
+ element = lcElement;
2778
+ }
2779
+ }
2780
+ set2[element] = true;
2781
+ }
2782
+ return set2;
2783
+ }
2784
+ function cleanArray(array) {
2785
+ for (let index2 = 0; index2 < array.length; index2++) {
2786
+ const isPropertyExist = objectHasOwnProperty(array, index2);
2787
+ if (!isPropertyExist) {
2788
+ array[index2] = null;
2789
+ }
2790
+ }
2791
+ return array;
2792
+ }
2793
+ function clone$3(object) {
2794
+ const newObject = create(null);
2795
+ for (const _ref2 of entries(object)) {
2796
+ var _ref3 = _slicedToArray(_ref2, 2);
2797
+ const property = _ref3[0];
2798
+ const value = _ref3[1];
2799
+ const isPropertyExist = objectHasOwnProperty(object, property);
2800
+ if (isPropertyExist) {
2801
+ if (arrayIsArray(value)) {
2802
+ newObject[property] = cleanArray(value);
2803
+ } else if (value && typeof value === "object" && value.constructor === Object) {
2804
+ newObject[property] = clone$3(value);
2805
+ } else {
2806
+ newObject[property] = value;
2807
+ }
2808
+ }
2809
+ }
2810
+ return newObject;
2811
+ }
2812
+ function stringifyValue(value) {
2813
+ switch (typeof value) {
2814
+ case "string": {
2815
+ return value;
2816
+ }
2817
+ case "number": {
2818
+ return numberToString(value);
2819
+ }
2820
+ case "boolean": {
2821
+ return booleanToString(value);
2822
+ }
2823
+ case "bigint": {
2824
+ return bigintToString ? bigintToString(value) : "0";
2825
+ }
2826
+ case "symbol": {
2827
+ return symbolToString ? symbolToString(value) : "Symbol()";
2828
+ }
2829
+ case "undefined": {
2830
+ return objectToString(value);
2831
+ }
2832
+ case "function":
2833
+ case "object": {
2834
+ if (value === null) {
2835
+ return objectToString(value);
2836
+ }
2837
+ const valueAsRecord = value;
2838
+ const valueToString = lookupGetter(valueAsRecord, "toString");
2839
+ if (typeof valueToString === "function") {
2840
+ const stringified = valueToString(valueAsRecord);
2841
+ return typeof stringified === "string" ? stringified : objectToString(stringified);
2842
+ }
2843
+ return objectToString(value);
2844
+ }
2845
+ default: {
2846
+ return objectToString(value);
2847
+ }
2848
+ }
2849
+ }
2850
+ function lookupGetter(object, prop2) {
2851
+ while (object !== null) {
2852
+ const desc = getOwnPropertyDescriptor(object, prop2);
2853
+ if (desc) {
2854
+ if (desc.get) {
2855
+ return unapply(desc.get);
2856
+ }
2857
+ if (typeof desc.value === "function") {
2858
+ return unapply(desc.value);
2859
+ }
2860
+ }
2861
+ object = getPrototypeOf(object);
2862
+ }
2863
+ function fallbackValue() {
2864
+ return null;
2865
+ }
2866
+ return fallbackValue;
2867
+ }
2868
+ function isRegex(value) {
2869
+ try {
2870
+ regExpTest(value, "");
2871
+ return true;
2872
+ } catch (_unused) {
2873
+ return false;
2874
+ }
2875
+ }
2876
+ 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"]);
2877
+ 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"]);
2878
+ 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"]);
2879
+ 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"]);
2880
+ 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"]);
2881
+ const mathMlDisallowed = freeze(["maction", "maligngroup", "malignmark", "mlongdiv", "mscarries", "mscarry", "msgroup", "mstack", "msline", "msrow", "semantics", "annotation", "annotation-xml", "mprescripts", "none"]);
2882
+ const text$2 = freeze(["#text"]);
2883
+ 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"]);
2884
+ 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"]);
2885
+ 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"]);
2886
+ const xml$1 = freeze(["xlink:href", "xml:id", "xlink:title", "xml:space", "xmlns:xlink"]);
2887
+ const MUSTACHE_EXPR = seal(/{{[\w\W]*|^[\w\W]*}}/g);
2888
+ const ERB_EXPR = seal(/<%[\w\W]*|^[\w\W]*%>/g);
2889
+ const TMPLIT_EXPR = seal(/\${[\w\W]*/g);
2890
+ const DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]+$/);
2891
+ const ARIA_ATTR = seal(/^aria-[\-\w]+$/);
2892
+ const IS_ALLOWED_URI = seal(
2893
+ /^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i
2894
+ // eslint-disable-line no-useless-escape
2895
+ );
2896
+ const IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i);
2897
+ const ATTR_WHITESPACE = seal(
2898
+ /[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g
2899
+ // eslint-disable-line no-control-regex
2900
+ );
2901
+ const DOCTYPE_NAME = seal(/^html$/i);
2902
+ const CUSTOM_ELEMENT = seal(/^[a-z][.\w]*(-[.\w]+)+$/i);
2903
+ const NODE_TYPE$1 = {
2904
+ element: 1,
2905
+ text: 3,
2906
+ // Deprecated
2907
+ progressingInstruction: 7,
2908
+ comment: 8,
2909
+ document: 9
2910
+ };
2911
+ const getGlobal = function getGlobal2() {
2912
+ return typeof window === "undefined" ? null : window;
2913
+ };
2914
+ const _createTrustedTypesPolicy = function _createTrustedTypesPolicy2(trustedTypes, purifyHostElement) {
2915
+ if (typeof trustedTypes !== "object" || typeof trustedTypes.createPolicy !== "function") {
2916
+ return null;
2917
+ }
2918
+ let suffix = null;
2919
+ const ATTR_NAME = "data-tt-policy-suffix";
2920
+ if (purifyHostElement && purifyHostElement.hasAttribute(ATTR_NAME)) {
2921
+ suffix = purifyHostElement.getAttribute(ATTR_NAME);
2922
+ }
2923
+ const policyName = "dompurify" + (suffix ? "#" + suffix : "");
2924
+ try {
2925
+ return trustedTypes.createPolicy(policyName, {
2926
+ createHTML(html2) {
2927
+ return html2;
2928
+ },
2929
+ createScriptURL(scriptUrl) {
2930
+ return scriptUrl;
2931
+ }
2932
+ });
2933
+ } catch (_) {
2934
+ console.warn("TrustedTypes policy " + policyName + " could not be created.");
2935
+ return null;
2936
+ }
2937
+ };
2938
+ const _createHooksMap = function _createHooksMap2() {
2939
+ return {
2940
+ afterSanitizeAttributes: [],
2941
+ afterSanitizeElements: [],
2942
+ afterSanitizeShadowDOM: [],
2943
+ beforeSanitizeAttributes: [],
2944
+ beforeSanitizeElements: [],
2945
+ beforeSanitizeShadowDOM: [],
2946
+ uponSanitizeAttribute: [],
2947
+ uponSanitizeElement: [],
2948
+ uponSanitizeShadowNode: []
2949
+ };
2950
+ };
2951
+ function createDOMPurify() {
2952
+ let window2 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : getGlobal();
2953
+ const DOMPurify = (root2) => createDOMPurify(root2);
2954
+ DOMPurify.version = "3.4.3";
2955
+ DOMPurify.removed = [];
2956
+ if (!window2 || !window2.document || window2.document.nodeType !== NODE_TYPE$1.document || !window2.Element) {
2957
+ DOMPurify.isSupported = false;
2958
+ return DOMPurify;
2959
+ }
2960
+ let document2 = window2.document;
2961
+ const originalDocument = document2;
2962
+ const currentScript = originalDocument.currentScript;
2963
+ 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;
2964
+ const ElementPrototype = Element2.prototype;
2965
+ const cloneNode2 = lookupGetter(ElementPrototype, "cloneNode");
2966
+ const remove2 = lookupGetter(ElementPrototype, "remove");
2967
+ const getNextSibling = lookupGetter(ElementPrototype, "nextSibling");
2968
+ const getChildNodes = lookupGetter(ElementPrototype, "childNodes");
2969
+ const getParentNode = lookupGetter(ElementPrototype, "parentNode");
2970
+ if (typeof HTMLTemplateElement === "function") {
2971
+ const template = document2.createElement("template");
2972
+ if (template.content && template.content.ownerDocument) {
2973
+ document2 = template.content.ownerDocument;
2974
+ }
2975
+ }
2976
+ let trustedTypesPolicy;
2977
+ let emptyHTML = "";
2978
+ const _document = document2, implementation = _document.implementation, createNodeIterator = _document.createNodeIterator, createDocumentFragment = _document.createDocumentFragment, getElementsByTagName2 = _document.getElementsByTagName;
2979
+ const importNode = originalDocument.importNode;
2980
+ let hooks = _createHooksMap();
2981
+ DOMPurify.isSupported = typeof entries === "function" && typeof getParentNode === "function" && implementation && implementation.createHTMLDocument !== void 0;
2982
+ 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;
2983
+ let IS_ALLOWED_URI$1 = IS_ALLOWED_URI;
2984
+ let ALLOWED_TAGS = null;
2985
+ const DEFAULT_ALLOWED_TAGS = addToSet({}, [...html$1$1, ...svg$1, ...svgFilters, ...mathMl$1, ...text$2]);
2986
+ let ALLOWED_ATTR = null;
2987
+ const DEFAULT_ALLOWED_ATTR = addToSet({}, [...html$2, ...svg, ...mathMl, ...xml$1]);
2988
+ let CUSTOM_ELEMENT_HANDLING = Object.seal(create(null, {
2989
+ tagNameCheck: {
2990
+ writable: true,
2991
+ configurable: false,
2992
+ enumerable: true,
2993
+ value: null
2994
+ },
2995
+ attributeNameCheck: {
2996
+ writable: true,
2997
+ configurable: false,
2998
+ enumerable: true,
2999
+ value: null
3000
+ },
3001
+ allowCustomizedBuiltInElements: {
3002
+ writable: true,
3003
+ configurable: false,
3004
+ enumerable: true,
3005
+ value: false
3006
+ }
3007
+ }));
3008
+ let FORBID_TAGS = null;
3009
+ let FORBID_ATTR = null;
3010
+ const EXTRA_ELEMENT_HANDLING = Object.seal(create(null, {
3011
+ tagCheck: {
3012
+ writable: true,
3013
+ configurable: false,
3014
+ enumerable: true,
3015
+ value: null
3016
+ },
3017
+ attributeCheck: {
3018
+ writable: true,
3019
+ configurable: false,
3020
+ enumerable: true,
3021
+ value: null
3022
+ }
3023
+ }));
3024
+ let ALLOW_ARIA_ATTR = true;
3025
+ let ALLOW_DATA_ATTR = true;
3026
+ let ALLOW_UNKNOWN_PROTOCOLS = false;
3027
+ let ALLOW_SELF_CLOSE_IN_ATTR = true;
3028
+ let SAFE_FOR_TEMPLATES = false;
3029
+ let SAFE_FOR_XML = true;
3030
+ let WHOLE_DOCUMENT = false;
3031
+ let SET_CONFIG = false;
3032
+ let FORCE_BODY = false;
3033
+ let RETURN_DOM = false;
3034
+ let RETURN_DOM_FRAGMENT = false;
3035
+ let RETURN_TRUSTED_TYPE = false;
3036
+ let SANITIZE_DOM = true;
3037
+ let SANITIZE_NAMED_PROPS = false;
3038
+ const SANITIZE_NAMED_PROPS_PREFIX = "user-content-";
3039
+ let KEEP_CONTENT = true;
3040
+ let IN_PLACE = false;
3041
+ let USE_PROFILES = {};
3042
+ let FORBID_CONTENTS = null;
3043
+ 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"]);
3044
+ let DATA_URI_TAGS = null;
3045
+ const DEFAULT_DATA_URI_TAGS = addToSet({}, ["audio", "video", "img", "source", "image", "track"]);
3046
+ let URI_SAFE_ATTRIBUTES = null;
3047
+ const DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ["alt", "class", "for", "id", "label", "name", "pattern", "placeholder", "role", "summary", "title", "value", "style", "xmlns"]);
3048
+ const MATHML_NAMESPACE = "http://www.w3.org/1998/Math/MathML";
3049
+ const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
3050
+ const HTML_NAMESPACE = "http://www.w3.org/1999/xhtml";
3051
+ let NAMESPACE = HTML_NAMESPACE;
3052
+ let IS_EMPTY_INPUT = false;
3053
+ let ALLOWED_NAMESPACES = null;
3054
+ const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [MATHML_NAMESPACE, SVG_NAMESPACE, HTML_NAMESPACE], stringToString);
3055
+ let MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ["mi", "mo", "mn", "ms", "mtext"]);
3056
+ let HTML_INTEGRATION_POINTS = addToSet({}, ["annotation-xml"]);
3057
+ const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, ["title", "style", "font", "a", "script"]);
3058
+ let PARSER_MEDIA_TYPE = null;
3059
+ const SUPPORTED_PARSER_MEDIA_TYPES = ["application/xhtml+xml", "text/html"];
3060
+ const DEFAULT_PARSER_MEDIA_TYPE = "text/html";
3061
+ let transformCaseFunc = null;
3062
+ let CONFIG = null;
3063
+ const formElement = document2.createElement("form");
3064
+ const isRegexOrFunction = function isRegexOrFunction2(testValue) {
3065
+ return testValue instanceof RegExp || testValue instanceof Function;
3066
+ };
3067
+ const _parseConfig = function _parseConfig2() {
3068
+ let cfg = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
3069
+ if (CONFIG && CONFIG === cfg) {
3070
+ return;
3071
+ }
3072
+ if (!cfg || typeof cfg !== "object") {
3073
+ cfg = {};
3074
+ }
3075
+ cfg = clone$3(cfg);
3076
+ PARSER_MEDIA_TYPE = // eslint-disable-next-line unicorn/prefer-includes
3077
+ SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? DEFAULT_PARSER_MEDIA_TYPE : cfg.PARSER_MEDIA_TYPE;
3078
+ transformCaseFunc = PARSER_MEDIA_TYPE === "application/xhtml+xml" ? stringToString : stringToLowerCase;
3079
+ ALLOWED_TAGS = objectHasOwnProperty(cfg, "ALLOWED_TAGS") && arrayIsArray(cfg.ALLOWED_TAGS) ? addToSet({}, cfg.ALLOWED_TAGS, transformCaseFunc) : DEFAULT_ALLOWED_TAGS;
3080
+ ALLOWED_ATTR = objectHasOwnProperty(cfg, "ALLOWED_ATTR") && arrayIsArray(cfg.ALLOWED_ATTR) ? addToSet({}, cfg.ALLOWED_ATTR, transformCaseFunc) : DEFAULT_ALLOWED_ATTR;
3081
+ ALLOWED_NAMESPACES = objectHasOwnProperty(cfg, "ALLOWED_NAMESPACES") && arrayIsArray(cfg.ALLOWED_NAMESPACES) ? addToSet({}, cfg.ALLOWED_NAMESPACES, stringToString) : DEFAULT_ALLOWED_NAMESPACES;
3082
+ 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;
3083
+ 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;
3084
+ FORBID_CONTENTS = objectHasOwnProperty(cfg, "FORBID_CONTENTS") && arrayIsArray(cfg.FORBID_CONTENTS) ? addToSet({}, cfg.FORBID_CONTENTS, transformCaseFunc) : DEFAULT_FORBID_CONTENTS;
3085
+ FORBID_TAGS = objectHasOwnProperty(cfg, "FORBID_TAGS") && arrayIsArray(cfg.FORBID_TAGS) ? addToSet({}, cfg.FORBID_TAGS, transformCaseFunc) : clone$3({});
3086
+ FORBID_ATTR = objectHasOwnProperty(cfg, "FORBID_ATTR") && arrayIsArray(cfg.FORBID_ATTR) ? addToSet({}, cfg.FORBID_ATTR, transformCaseFunc) : clone$3({});
3087
+ USE_PROFILES = objectHasOwnProperty(cfg, "USE_PROFILES") ? cfg.USE_PROFILES && typeof cfg.USE_PROFILES === "object" ? clone$3(cfg.USE_PROFILES) : cfg.USE_PROFILES : false;
3088
+ ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false;
3089
+ ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false;
3090
+ ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false;
3091
+ ALLOW_SELF_CLOSE_IN_ATTR = cfg.ALLOW_SELF_CLOSE_IN_ATTR !== false;
3092
+ SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false;
3093
+ SAFE_FOR_XML = cfg.SAFE_FOR_XML !== false;
3094
+ WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false;
3095
+ RETURN_DOM = cfg.RETURN_DOM || false;
3096
+ RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false;
3097
+ RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false;
3098
+ FORCE_BODY = cfg.FORCE_BODY || false;
3099
+ SANITIZE_DOM = cfg.SANITIZE_DOM !== false;
3100
+ SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false;
3101
+ KEEP_CONTENT = cfg.KEEP_CONTENT !== false;
3102
+ IN_PLACE = cfg.IN_PLACE || false;
3103
+ IS_ALLOWED_URI$1 = isRegex(cfg.ALLOWED_URI_REGEXP) ? cfg.ALLOWED_URI_REGEXP : IS_ALLOWED_URI;
3104
+ NAMESPACE = typeof cfg.NAMESPACE === "string" ? cfg.NAMESPACE : HTML_NAMESPACE;
3105
+ 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"]);
3106
+ 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"]);
3107
+ 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);
3108
+ CUSTOM_ELEMENT_HANDLING = create(null);
3109
+ if (objectHasOwnProperty(customElementHandling, "tagNameCheck") && isRegexOrFunction(customElementHandling.tagNameCheck)) {
3110
+ CUSTOM_ELEMENT_HANDLING.tagNameCheck = customElementHandling.tagNameCheck;
3111
+ }
3112
+ if (objectHasOwnProperty(customElementHandling, "attributeNameCheck") && isRegexOrFunction(customElementHandling.attributeNameCheck)) {
3113
+ CUSTOM_ELEMENT_HANDLING.attributeNameCheck = customElementHandling.attributeNameCheck;
3114
+ }
3115
+ if (objectHasOwnProperty(customElementHandling, "allowCustomizedBuiltInElements") && typeof customElementHandling.allowCustomizedBuiltInElements === "boolean") {
3116
+ CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = customElementHandling.allowCustomizedBuiltInElements;
3117
+ }
3118
+ if (SAFE_FOR_TEMPLATES) {
3119
+ ALLOW_DATA_ATTR = false;
3120
+ }
3121
+ if (RETURN_DOM_FRAGMENT) {
3122
+ RETURN_DOM = true;
3123
+ }
3124
+ if (USE_PROFILES) {
3125
+ ALLOWED_TAGS = addToSet({}, text$2);
3126
+ ALLOWED_ATTR = create(null);
3127
+ if (USE_PROFILES.html === true) {
3128
+ addToSet(ALLOWED_TAGS, html$1$1);
3129
+ addToSet(ALLOWED_ATTR, html$2);
3130
+ }
3131
+ if (USE_PROFILES.svg === true) {
3132
+ addToSet(ALLOWED_TAGS, svg$1);
3133
+ addToSet(ALLOWED_ATTR, svg);
3134
+ addToSet(ALLOWED_ATTR, xml$1);
3135
+ }
3136
+ if (USE_PROFILES.svgFilters === true) {
3137
+ addToSet(ALLOWED_TAGS, svgFilters);
3138
+ addToSet(ALLOWED_ATTR, svg);
3139
+ addToSet(ALLOWED_ATTR, xml$1);
3140
+ }
3141
+ if (USE_PROFILES.mathMl === true) {
3142
+ addToSet(ALLOWED_TAGS, mathMl$1);
3143
+ addToSet(ALLOWED_ATTR, mathMl);
3144
+ addToSet(ALLOWED_ATTR, xml$1);
3145
+ }
3146
+ }
3147
+ EXTRA_ELEMENT_HANDLING.tagCheck = null;
3148
+ EXTRA_ELEMENT_HANDLING.attributeCheck = null;
3149
+ if (objectHasOwnProperty(cfg, "ADD_TAGS")) {
3150
+ if (typeof cfg.ADD_TAGS === "function") {
3151
+ EXTRA_ELEMENT_HANDLING.tagCheck = cfg.ADD_TAGS;
3152
+ } else if (arrayIsArray(cfg.ADD_TAGS)) {
3153
+ if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {
3154
+ ALLOWED_TAGS = clone$3(ALLOWED_TAGS);
3155
+ }
3156
+ addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc);
3157
+ }
3158
+ }
3159
+ if (objectHasOwnProperty(cfg, "ADD_ATTR")) {
3160
+ if (typeof cfg.ADD_ATTR === "function") {
3161
+ EXTRA_ELEMENT_HANDLING.attributeCheck = cfg.ADD_ATTR;
3162
+ } else if (arrayIsArray(cfg.ADD_ATTR)) {
3163
+ if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) {
3164
+ ALLOWED_ATTR = clone$3(ALLOWED_ATTR);
3165
+ }
3166
+ addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc);
3167
+ }
3168
+ }
3169
+ if (objectHasOwnProperty(cfg, "ADD_URI_SAFE_ATTR") && arrayIsArray(cfg.ADD_URI_SAFE_ATTR)) {
3170
+ addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR, transformCaseFunc);
3171
+ }
3172
+ if (objectHasOwnProperty(cfg, "FORBID_CONTENTS") && arrayIsArray(cfg.FORBID_CONTENTS)) {
3173
+ if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
3174
+ FORBID_CONTENTS = clone$3(FORBID_CONTENTS);
3175
+ }
3176
+ addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS, transformCaseFunc);
3177
+ }
3178
+ if (objectHasOwnProperty(cfg, "ADD_FORBID_CONTENTS") && arrayIsArray(cfg.ADD_FORBID_CONTENTS)) {
3179
+ if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
3180
+ FORBID_CONTENTS = clone$3(FORBID_CONTENTS);
3181
+ }
3182
+ addToSet(FORBID_CONTENTS, cfg.ADD_FORBID_CONTENTS, transformCaseFunc);
3183
+ }
3184
+ if (KEEP_CONTENT) {
3185
+ ALLOWED_TAGS["#text"] = true;
3186
+ }
3187
+ if (WHOLE_DOCUMENT) {
3188
+ addToSet(ALLOWED_TAGS, ["html", "head", "body"]);
3189
+ }
3190
+ if (ALLOWED_TAGS.table) {
3191
+ addToSet(ALLOWED_TAGS, ["tbody"]);
3192
+ delete FORBID_TAGS.tbody;
3193
+ }
3194
+ if (cfg.TRUSTED_TYPES_POLICY) {
3195
+ if (typeof cfg.TRUSTED_TYPES_POLICY.createHTML !== "function") {
3196
+ throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');
3197
+ }
3198
+ if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== "function") {
3199
+ throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
3200
+ }
3201
+ trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY;
3202
+ emptyHTML = trustedTypesPolicy.createHTML("");
3203
+ } else {
3204
+ if (trustedTypesPolicy === void 0) {
3205
+ trustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript);
3206
+ }
3207
+ if (trustedTypesPolicy !== null && typeof emptyHTML === "string") {
3208
+ emptyHTML = trustedTypesPolicy.createHTML("");
3209
+ }
3210
+ }
3211
+ if (freeze) {
3212
+ freeze(cfg);
3213
+ }
3214
+ CONFIG = cfg;
3215
+ };
3216
+ const ALL_SVG_TAGS = addToSet({}, [...svg$1, ...svgFilters, ...svgDisallowed]);
3217
+ const ALL_MATHML_TAGS = addToSet({}, [...mathMl$1, ...mathMlDisallowed]);
3218
+ const _checkValidNamespace = function _checkValidNamespace2(element) {
3219
+ let parent2 = getParentNode(element);
3220
+ if (!parent2 || !parent2.tagName) {
3221
+ parent2 = {
3222
+ namespaceURI: NAMESPACE,
3223
+ tagName: "template"
3224
+ };
3225
+ }
3226
+ const tagName = stringToLowerCase(element.tagName);
3227
+ const parentTagName = stringToLowerCase(parent2.tagName);
3228
+ if (!ALLOWED_NAMESPACES[element.namespaceURI]) {
3229
+ return false;
3230
+ }
3231
+ if (element.namespaceURI === SVG_NAMESPACE) {
3232
+ if (parent2.namespaceURI === HTML_NAMESPACE) {
3233
+ return tagName === "svg";
3234
+ }
3235
+ if (parent2.namespaceURI === MATHML_NAMESPACE) {
3236
+ return tagName === "svg" && (parentTagName === "annotation-xml" || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
3237
+ }
3238
+ return Boolean(ALL_SVG_TAGS[tagName]);
3239
+ }
3240
+ if (element.namespaceURI === MATHML_NAMESPACE) {
3241
+ if (parent2.namespaceURI === HTML_NAMESPACE) {
3242
+ return tagName === "math";
3243
+ }
3244
+ if (parent2.namespaceURI === SVG_NAMESPACE) {
3245
+ return tagName === "math" && HTML_INTEGRATION_POINTS[parentTagName];
3246
+ }
3247
+ return Boolean(ALL_MATHML_TAGS[tagName]);
3248
+ }
3249
+ if (element.namespaceURI === HTML_NAMESPACE) {
3250
+ if (parent2.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) {
3251
+ return false;
3252
+ }
3253
+ if (parent2.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {
3254
+ return false;
3255
+ }
3256
+ return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);
3257
+ }
3258
+ if (PARSER_MEDIA_TYPE === "application/xhtml+xml" && ALLOWED_NAMESPACES[element.namespaceURI]) {
3259
+ return true;
3260
+ }
3261
+ return false;
3262
+ };
3263
+ const _forceRemove = function _forceRemove2(node) {
3264
+ arrayPush(DOMPurify.removed, {
3265
+ element: node
3266
+ });
3267
+ try {
3268
+ getParentNode(node).removeChild(node);
3269
+ } catch (_) {
3270
+ remove2(node);
3271
+ }
3272
+ };
3273
+ const _removeAttribute = function _removeAttribute2(name2, element) {
3274
+ try {
3275
+ arrayPush(DOMPurify.removed, {
3276
+ attribute: element.getAttributeNode(name2),
3277
+ from: element
3278
+ });
3279
+ } catch (_) {
3280
+ arrayPush(DOMPurify.removed, {
3281
+ attribute: null,
3282
+ from: element
3283
+ });
3284
+ }
3285
+ element.removeAttribute(name2);
3286
+ if (name2 === "is") {
3287
+ if (RETURN_DOM || RETURN_DOM_FRAGMENT) {
3288
+ try {
3289
+ _forceRemove(element);
3290
+ } catch (_) {
3291
+ }
3292
+ } else {
3293
+ try {
3294
+ element.setAttribute(name2, "");
3295
+ } catch (_) {
3296
+ }
3297
+ }
3298
+ }
3299
+ };
3300
+ const _initDocument = function _initDocument2(dirty) {
3301
+ let doc = null;
3302
+ let leadingWhitespace = null;
3303
+ if (FORCE_BODY) {
3304
+ dirty = "<remove></remove>" + dirty;
3305
+ } else {
3306
+ const matches = stringMatch(dirty, /^[\r\n\t ]+/);
3307
+ leadingWhitespace = matches && matches[0];
3308
+ }
3309
+ if (PARSER_MEDIA_TYPE === "application/xhtml+xml" && NAMESPACE === HTML_NAMESPACE) {
3310
+ dirty = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + dirty + "</body></html>";
3311
+ }
3312
+ const dirtyPayload = trustedTypesPolicy ? trustedTypesPolicy.createHTML(dirty) : dirty;
3313
+ if (NAMESPACE === HTML_NAMESPACE) {
3314
+ try {
3315
+ doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE);
3316
+ } catch (_) {
3317
+ }
3318
+ }
3319
+ if (!doc || !doc.documentElement) {
3320
+ doc = implementation.createDocument(NAMESPACE, "template", null);
3321
+ try {
3322
+ doc.documentElement.innerHTML = IS_EMPTY_INPUT ? emptyHTML : dirtyPayload;
3323
+ } catch (_) {
3324
+ }
3325
+ }
3326
+ const body = doc.body || doc.documentElement;
3327
+ if (dirty && leadingWhitespace) {
3328
+ body.insertBefore(document2.createTextNode(leadingWhitespace), body.childNodes[0] || null);
3329
+ }
3330
+ if (NAMESPACE === HTML_NAMESPACE) {
3331
+ return getElementsByTagName2.call(doc, WHOLE_DOCUMENT ? "html" : "body")[0];
3332
+ }
3333
+ return WHOLE_DOCUMENT ? doc.documentElement : body;
3334
+ };
3335
+ const _createNodeIterator = function _createNodeIterator2(root2) {
3336
+ return createNodeIterator.call(
3337
+ root2.ownerDocument || root2,
3338
+ root2,
3339
+ // eslint-disable-next-line no-bitwise
3340
+ NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT | NodeFilter.SHOW_PROCESSING_INSTRUCTION | NodeFilter.SHOW_CDATA_SECTION,
3341
+ null
3342
+ );
3343
+ };
3344
+ const _isClobbered = function _isClobbered2(element) {
3345
+ 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");
3346
+ };
3347
+ const _isNode = function _isNode2(value) {
3348
+ return typeof Node3 === "function" && value instanceof Node3;
3349
+ };
3350
+ function _executeHooks(hooks2, currentNode, data2) {
3351
+ arrayForEach(hooks2, (hook) => {
3352
+ hook.call(DOMPurify, currentNode, data2, CONFIG);
3353
+ });
3354
+ }
3355
+ const _sanitizeElements = function _sanitizeElements2(currentNode) {
3356
+ let content = null;
3357
+ _executeHooks(hooks.beforeSanitizeElements, currentNode, null);
3358
+ if (_isClobbered(currentNode)) {
3359
+ _forceRemove(currentNode);
3360
+ return true;
3361
+ }
3362
+ const tagName = transformCaseFunc(currentNode.nodeName);
3363
+ _executeHooks(hooks.uponSanitizeElement, currentNode, {
3364
+ tagName,
3365
+ allowedTags: ALLOWED_TAGS
3366
+ });
3367
+ if (SAFE_FOR_XML && currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && regExpTest(/<[/\w!]/g, currentNode.innerHTML) && regExpTest(/<[/\w!]/g, currentNode.textContent)) {
3368
+ _forceRemove(currentNode);
3369
+ return true;
3370
+ }
3371
+ if (SAFE_FOR_XML && currentNode.namespaceURI === HTML_NAMESPACE && tagName === "style" && _isNode(currentNode.firstElementChild)) {
3372
+ _forceRemove(currentNode);
3373
+ return true;
3374
+ }
3375
+ if (currentNode.nodeType === NODE_TYPE$1.progressingInstruction) {
3376
+ _forceRemove(currentNode);
3377
+ return true;
3378
+ }
3379
+ if (SAFE_FOR_XML && currentNode.nodeType === NODE_TYPE$1.comment && regExpTest(/<[/\w]/g, currentNode.data)) {
3380
+ _forceRemove(currentNode);
3381
+ return true;
3382
+ }
3383
+ if (FORBID_TAGS[tagName] || !(EXTRA_ELEMENT_HANDLING.tagCheck instanceof Function && EXTRA_ELEMENT_HANDLING.tagCheck(tagName)) && !ALLOWED_TAGS[tagName]) {
3384
+ if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName)) {
3385
+ if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) {
3386
+ return false;
3387
+ }
3388
+ if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName)) {
3389
+ return false;
3390
+ }
3391
+ }
3392
+ if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {
3393
+ const parentNode = getParentNode(currentNode) || currentNode.parentNode;
3394
+ const childNodes = getChildNodes(currentNode) || currentNode.childNodes;
3395
+ if (childNodes && parentNode) {
3396
+ const childCount = childNodes.length;
3397
+ for (let i = childCount - 1; i >= 0; --i) {
3398
+ const childClone = cloneNode2(childNodes[i], true);
3399
+ parentNode.insertBefore(childClone, getNextSibling(currentNode));
3400
+ }
3401
+ }
3402
+ }
3403
+ _forceRemove(currentNode);
3404
+ return true;
3405
+ }
3406
+ if (currentNode instanceof Element2 && !_checkValidNamespace(currentNode)) {
3407
+ _forceRemove(currentNode);
3408
+ return true;
3409
+ }
3410
+ if ((tagName === "noscript" || tagName === "noembed" || tagName === "noframes") && regExpTest(/<\/no(script|embed|frames)/i, currentNode.innerHTML)) {
3411
+ _forceRemove(currentNode);
3412
+ return true;
3413
+ }
3414
+ if (SAFE_FOR_TEMPLATES && currentNode.nodeType === NODE_TYPE$1.text) {
3415
+ content = currentNode.textContent;
3416
+ arrayForEach([MUSTACHE_EXPR$1, ERB_EXPR$1, TMPLIT_EXPR$1], (expr) => {
3417
+ content = stringReplace(content, expr, " ");
3418
+ });
3419
+ if (currentNode.textContent !== content) {
3420
+ arrayPush(DOMPurify.removed, {
3421
+ element: currentNode.cloneNode()
3422
+ });
3423
+ currentNode.textContent = content;
3424
+ }
3425
+ }
3426
+ _executeHooks(hooks.afterSanitizeElements, currentNode, null);
3427
+ return false;
3428
+ };
3429
+ const _isValidAttribute = function _isValidAttribute2(lcTag, lcName, value) {
3430
+ if (FORBID_ATTR[lcName]) {
3431
+ return false;
3432
+ }
3433
+ if (SANITIZE_DOM && (lcName === "id" || lcName === "name") && (value in document2 || value in formElement)) {
3434
+ return false;
3435
+ }
3436
+ const nameIsPermitted = ALLOWED_ATTR[lcName] || EXTRA_ELEMENT_HANDLING.attributeCheck instanceof Function && EXTRA_ELEMENT_HANDLING.attributeCheck(lcName, lcTag);
3437
+ if (ALLOW_DATA_ATTR && !FORBID_ATTR[lcName] && regExpTest(DATA_ATTR$1, lcName)) ;
3438
+ else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR$1, lcName)) ;
3439
+ else if (!nameIsPermitted || FORBID_ATTR[lcName]) {
3440
+ if (
3441
+ // First condition does a very basic check if a) it's basically a valid custom element tagname AND
3442
+ // b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
3443
+ // and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck
3444
+ _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
3445
+ // the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
3446
+ 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))
3447
+ ) ;
3448
+ else {
3449
+ return false;
3450
+ }
3451
+ } else if (URI_SAFE_ATTRIBUTES[lcName]) ;
3452
+ else if (regExpTest(IS_ALLOWED_URI$1, stringReplace(value, ATTR_WHITESPACE$1, ""))) ;
3453
+ else if ((lcName === "src" || lcName === "xlink:href" || lcName === "href") && lcTag !== "script" && stringIndexOf(value, "data:") === 0 && DATA_URI_TAGS[lcTag]) ;
3454
+ else if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA$1, stringReplace(value, ATTR_WHITESPACE$1, ""))) ;
3455
+ else if (value) {
3456
+ return false;
3457
+ } else ;
3458
+ return true;
3459
+ };
3460
+ 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"]);
3461
+ const _isBasicCustomElement = function _isBasicCustomElement2(tagName) {
3462
+ return !RESERVED_CUSTOM_ELEMENT_NAMES[stringToLowerCase(tagName)] && regExpTest(CUSTOM_ELEMENT$1, tagName);
3463
+ };
3464
+ const _sanitizeAttributes = function _sanitizeAttributes2(currentNode) {
3465
+ _executeHooks(hooks.beforeSanitizeAttributes, currentNode, null);
3466
+ const attributes2 = currentNode.attributes;
3467
+ if (!attributes2 || _isClobbered(currentNode)) {
3468
+ return;
3469
+ }
3470
+ const hookEvent = {
3471
+ attrName: "",
3472
+ attrValue: "",
3473
+ keepAttr: true,
3474
+ allowedAttributes: ALLOWED_ATTR,
3475
+ forceKeepAttr: void 0
3476
+ };
3477
+ let l2 = attributes2.length;
3478
+ while (l2--) {
3479
+ const attr2 = attributes2[l2];
3480
+ const name2 = attr2.name, namespaceURI = attr2.namespaceURI, attrValue = attr2.value;
3481
+ const lcName = transformCaseFunc(name2);
3482
+ const initValue = attrValue;
3483
+ let value = name2 === "value" ? initValue : stringTrim(initValue);
3484
+ hookEvent.attrName = lcName;
3485
+ hookEvent.attrValue = value;
3486
+ hookEvent.keepAttr = true;
3487
+ hookEvent.forceKeepAttr = void 0;
3488
+ _executeHooks(hooks.uponSanitizeAttribute, currentNode, hookEvent);
3489
+ value = hookEvent.attrValue;
3490
+ if (SANITIZE_NAMED_PROPS && (lcName === "id" || lcName === "name") && stringIndexOf(value, SANITIZE_NAMED_PROPS_PREFIX) !== 0) {
3491
+ _removeAttribute(name2, currentNode);
3492
+ value = SANITIZE_NAMED_PROPS_PREFIX + value;
3493
+ }
3494
+ if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i, value)) {
3495
+ _removeAttribute(name2, currentNode);
3496
+ continue;
3497
+ }
3498
+ if (lcName === "attributename" && stringMatch(value, "href")) {
3499
+ _removeAttribute(name2, currentNode);
3500
+ continue;
3501
+ }
3502
+ if (hookEvent.forceKeepAttr) {
3503
+ continue;
3504
+ }
3505
+ if (!hookEvent.keepAttr) {
3506
+ _removeAttribute(name2, currentNode);
3507
+ continue;
3508
+ }
3509
+ if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(/\/>/i, value)) {
3510
+ _removeAttribute(name2, currentNode);
3511
+ continue;
3512
+ }
3513
+ if (SAFE_FOR_TEMPLATES) {
3514
+ arrayForEach([MUSTACHE_EXPR$1, ERB_EXPR$1, TMPLIT_EXPR$1], (expr) => {
3515
+ value = stringReplace(value, expr, " ");
3516
+ });
3517
+ }
3518
+ const lcTag = transformCaseFunc(currentNode.nodeName);
3519
+ if (!_isValidAttribute(lcTag, lcName, value)) {
3520
+ _removeAttribute(name2, currentNode);
3521
+ continue;
3522
+ }
3523
+ if (trustedTypesPolicy && typeof trustedTypes === "object" && typeof trustedTypes.getAttributeType === "function") {
3524
+ if (namespaceURI) ;
3525
+ else {
3526
+ switch (trustedTypes.getAttributeType(lcTag, lcName)) {
3527
+ case "TrustedHTML": {
3528
+ value = trustedTypesPolicy.createHTML(value);
3529
+ break;
3530
+ }
3531
+ case "TrustedScriptURL": {
3532
+ value = trustedTypesPolicy.createScriptURL(value);
3533
+ break;
3534
+ }
3535
+ }
3536
+ }
3537
+ }
3538
+ if (value !== initValue) {
3539
+ try {
3540
+ if (namespaceURI) {
3541
+ currentNode.setAttributeNS(namespaceURI, name2, value);
3542
+ } else {
3543
+ currentNode.setAttribute(name2, value);
3544
+ }
3545
+ if (_isClobbered(currentNode)) {
3546
+ _forceRemove(currentNode);
3547
+ } else {
3548
+ arrayPop(DOMPurify.removed);
3549
+ }
3550
+ } catch (_) {
3551
+ _removeAttribute(name2, currentNode);
3552
+ }
3553
+ }
3554
+ }
3555
+ _executeHooks(hooks.afterSanitizeAttributes, currentNode, null);
3556
+ };
3557
+ const _sanitizeShadowDOM2 = function _sanitizeShadowDOM(fragment) {
3558
+ let shadowNode = null;
3559
+ const shadowIterator = _createNodeIterator(fragment);
3560
+ _executeHooks(hooks.beforeSanitizeShadowDOM, fragment, null);
3561
+ while (shadowNode = shadowIterator.nextNode()) {
3562
+ _executeHooks(hooks.uponSanitizeShadowNode, shadowNode, null);
3563
+ _sanitizeElements(shadowNode);
3564
+ _sanitizeAttributes(shadowNode);
3565
+ if (shadowNode.content instanceof DocumentFragment) {
3566
+ _sanitizeShadowDOM2(shadowNode.content);
3567
+ }
3568
+ }
3569
+ _executeHooks(hooks.afterSanitizeShadowDOM, fragment, null);
3570
+ };
3571
+ const _sanitizeAttachedShadowRoots2 = function _sanitizeAttachedShadowRoots(root2) {
3572
+ if (root2.nodeType === NODE_TYPE$1.element && root2.shadowRoot instanceof DocumentFragment) {
3573
+ const sr = root2.shadowRoot;
3574
+ _sanitizeAttachedShadowRoots2(sr);
3575
+ _sanitizeShadowDOM2(sr);
3576
+ }
3577
+ const childNodes = root2.childNodes;
3578
+ if (!childNodes) {
3579
+ return;
3580
+ }
3581
+ const snapshot = [];
3582
+ arrayForEach(childNodes, (child) => {
3583
+ arrayPush(snapshot, child);
3584
+ });
3585
+ for (const child of snapshot) {
3586
+ _sanitizeAttachedShadowRoots2(child);
3587
+ }
3588
+ };
3589
+ DOMPurify.sanitize = function(dirty) {
3590
+ let cfg = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
3591
+ let body = null;
3592
+ let importedNode = null;
3593
+ let currentNode = null;
3594
+ let returnNode = null;
3595
+ IS_EMPTY_INPUT = !dirty;
3596
+ if (IS_EMPTY_INPUT) {
3597
+ dirty = "<!-->";
3598
+ }
3599
+ if (typeof dirty !== "string" && !_isNode(dirty)) {
3600
+ dirty = stringifyValue(dirty);
3601
+ if (typeof dirty !== "string") {
3602
+ throw typeErrorCreate("dirty is not a string, aborting");
3603
+ }
3604
+ }
3605
+ if (!DOMPurify.isSupported) {
3606
+ return dirty;
3607
+ }
3608
+ if (!SET_CONFIG) {
3609
+ _parseConfig(cfg);
3610
+ }
3611
+ DOMPurify.removed = [];
3612
+ if (typeof dirty === "string") {
3613
+ IN_PLACE = false;
3614
+ }
3615
+ if (IN_PLACE) {
3616
+ const nn = dirty.nodeName;
3617
+ if (typeof nn === "string") {
3618
+ const tagName = transformCaseFunc(nn);
3619
+ if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
3620
+ throw typeErrorCreate("root node is forbidden and cannot be sanitized in-place");
3621
+ }
3622
+ }
3623
+ _sanitizeAttachedShadowRoots2(dirty);
3624
+ } else if (dirty instanceof Node3) {
3625
+ body = _initDocument("<!---->");
3626
+ importedNode = body.ownerDocument.importNode(dirty, true);
3627
+ if (importedNode.nodeType === NODE_TYPE$1.element && importedNode.nodeName === "BODY") {
3628
+ body = importedNode;
3629
+ } else if (importedNode.nodeName === "HTML") {
3630
+ body = importedNode;
3631
+ } else {
3632
+ body.appendChild(importedNode);
3633
+ }
3634
+ _sanitizeAttachedShadowRoots2(importedNode);
3635
+ } else {
3636
+ if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT && // eslint-disable-next-line unicorn/prefer-includes
3637
+ dirty.indexOf("<") === -1) {
3638
+ return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(dirty) : dirty;
3639
+ }
3640
+ body = _initDocument(dirty);
3641
+ if (!body) {
3642
+ return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : "";
3643
+ }
3644
+ }
3645
+ if (body && FORCE_BODY) {
3646
+ _forceRemove(body.firstChild);
3647
+ }
3648
+ const nodeIterator = _createNodeIterator(IN_PLACE ? dirty : body);
3649
+ while (currentNode = nodeIterator.nextNode()) {
3650
+ _sanitizeElements(currentNode);
3651
+ _sanitizeAttributes(currentNode);
3652
+ if (currentNode.content instanceof DocumentFragment) {
3653
+ _sanitizeShadowDOM2(currentNode.content);
3654
+ }
3655
+ }
3656
+ if (IN_PLACE) {
3657
+ return dirty;
3658
+ }
3659
+ if (RETURN_DOM) {
3660
+ if (SAFE_FOR_TEMPLATES) {
3661
+ body.normalize();
3662
+ let html2 = body.innerHTML;
3663
+ arrayForEach([MUSTACHE_EXPR$1, ERB_EXPR$1, TMPLIT_EXPR$1], (expr) => {
3664
+ html2 = stringReplace(html2, expr, " ");
3665
+ });
3666
+ body.innerHTML = html2;
3667
+ }
3668
+ if (RETURN_DOM_FRAGMENT) {
3669
+ returnNode = createDocumentFragment.call(body.ownerDocument);
3670
+ while (body.firstChild) {
3671
+ returnNode.appendChild(body.firstChild);
3672
+ }
3673
+ } else {
3674
+ returnNode = body;
3675
+ }
3676
+ if (ALLOWED_ATTR.shadowroot || ALLOWED_ATTR.shadowrootmode) {
3677
+ returnNode = importNode.call(originalDocument, returnNode, true);
3678
+ }
3679
+ return returnNode;
3680
+ }
3681
+ let serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;
3682
+ if (WHOLE_DOCUMENT && ALLOWED_TAGS["!doctype"] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) {
3683
+ serializedHTML = "<!DOCTYPE " + body.ownerDocument.doctype.name + ">\n" + serializedHTML;
3684
+ }
3685
+ if (SAFE_FOR_TEMPLATES) {
3686
+ arrayForEach([MUSTACHE_EXPR$1, ERB_EXPR$1, TMPLIT_EXPR$1], (expr) => {
3687
+ serializedHTML = stringReplace(serializedHTML, expr, " ");
3688
+ });
3689
+ }
3690
+ return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(serializedHTML) : serializedHTML;
3691
+ };
3692
+ DOMPurify.setConfig = function() {
3693
+ let cfg = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
3694
+ _parseConfig(cfg);
3695
+ SET_CONFIG = true;
3696
+ };
3697
+ DOMPurify.clearConfig = function() {
3698
+ CONFIG = null;
3699
+ SET_CONFIG = false;
3700
+ };
3701
+ DOMPurify.isValidAttribute = function(tag, attr2, value) {
3702
+ if (!CONFIG) {
3703
+ _parseConfig({});
3704
+ }
3705
+ const lcTag = transformCaseFunc(tag);
3706
+ const lcName = transformCaseFunc(attr2);
3707
+ return _isValidAttribute(lcTag, lcName, value);
3708
+ };
3709
+ DOMPurify.addHook = function(entryPoint, hookFunction) {
3710
+ if (typeof hookFunction !== "function") {
3711
+ return;
3712
+ }
3713
+ arrayPush(hooks[entryPoint], hookFunction);
3714
+ };
3715
+ DOMPurify.removeHook = function(entryPoint, hookFunction) {
3716
+ if (hookFunction !== void 0) {
3717
+ const index2 = arrayLastIndexOf(hooks[entryPoint], hookFunction);
3718
+ return index2 === -1 ? void 0 : arraySplice(hooks[entryPoint], index2, 1)[0];
3719
+ }
3720
+ return arrayPop(hooks[entryPoint]);
3721
+ };
3722
+ DOMPurify.removeHooks = function(entryPoint) {
3723
+ hooks[entryPoint] = [];
3724
+ };
3725
+ DOMPurify.removeAllHooks = function() {
3726
+ hooks = _createHooksMap();
3727
+ };
3728
+ return DOMPurify;
3729
+ }
3730
+ var purify = createDOMPurify();
2459
3731
  ABConvert.factory({
2460
3732
  id: "md",
2461
3733
  name: "md",
@@ -2475,7 +3747,7 @@ ABConvert.factory({
2475
3747
  process_param: ABConvert_IOEnum.text,
2476
3748
  process_return: ABConvert_IOEnum.el,
2477
3749
  process: (el, header, content) => {
2478
- el.innerHTML = `<p>${content.replace(/ /g, "&nbsp;").split("\n").join("<br/>")}</p>`;
3750
+ el.innerHTML = purify.sanitize(`<p>${content.replace(/ /g, "&nbsp;").split("\n").join("<br/>")}</p>`);
2479
3751
  return el;
2480
3752
  }
2481
3753
  });
@@ -3195,12 +4467,10 @@ ABConvert.factory({
3195
4467
  process_return: ABConvert_IOEnum.json,
3196
4468
  process: (el, header, content) => {
3197
4469
  return JSON.stringify(
3198
- ABAlias_json.map((item) => {
3199
- return {
3200
- regex: item.regex.toString(),
3201
- replacement: item.replacement
3202
- };
3203
- }),
4470
+ Array.from(get_ABAlias_iter(), (item) => ({
4471
+ regex: item.regex.toString(),
4472
+ replacement: item.replacement
4473
+ })),
3204
4474
  null,
3205
4475
  2
3206
4476
  );
@@ -15151,7 +16421,7 @@ ABConvert.factory({
15151
16421
  async function render_pumlText(text2, div) {
15152
16422
  var encoded = plantumlEncoder.encode(text2);
15153
16423
  let url = "http://www.plantuml.com/plantuml/img/" + encoded;
15154
- div.innerHTML = `<img src="${url}">`;
16424
+ div.innerHTML = purify.sanitize(`<img src="${url}">`);
15155
16425
  return div;
15156
16426
  }
15157
16427
  function getID(length = 16) {
@@ -15326,206 +16596,20 @@ async function data2mindmap(list_itemInfo, div) {
15326
16596
  return render_mermaidText(mermaidText, div);
15327
16597
  }
15328
16598
  async function render_mermaidText(mermaidText, div) {
15329
- if (ABCSetting.env.startsWith("obsidian") && ABCSetting.mermaid) {
15330
- ABCSetting.mermaid.then(async (mermaid) => {
15331
- const { svg } = await mermaid.render("ab-mermaid-" + getID(), mermaidText);
15332
- div.innerHTML = svg;
16599
+ if (ABCSetting.env.startsWith("obsidian") && ABCSetting.obsidian.mermaid) {
16600
+ ABCSetting.obsidian.mermaid.then(async (mermaid) => {
16601
+ const { svg: svg2 } = await mermaid.render("ab-mermaid-" + getID(), mermaidText);
16602
+ const div_mermaid = document.createElement("div");
16603
+ div.appendChild(div_mermaid);
16604
+ div_mermaid.classList.add("mermaid");
16605
+ div_mermaid.innerHTML = svg2;
15333
16606
  });
15334
16607
  } else {
15335
16608
  div.classList.add("ab-raw");
15336
- div.innerHTML = `<div class="ab-raw-data" type-data="mermaid" content-data='${mermaidText}'></div>`;
16609
+ div.innerHTML = purify.sanitize(`<div class="ab-raw-data" type-data="mermaid" content-data='${mermaidText}'></div>`);
15337
16610
  }
15338
16611
  return div;
15339
16612
  }
15340
- function abConvertEvent(d, isCycle = false) {
15341
- if (d.querySelector(".ab-super-width")) {
15342
- const els_note = d.querySelectorAll(".ab-note");
15343
- for (const el_note of els_note) {
15344
- if (el_note.querySelector(".ab-super-width")) {
15345
- const el_replace = el_note.parentNode;
15346
- if (el_replace && el_replace.classList.contains("ab-replace")) {
15347
- el_replace.classList.add("ab-super-width-p");
15348
- }
15349
- }
15350
- }
15351
- const els_view = document.querySelectorAll(".app-container .workspace-leaf");
15352
- for (const el_view of els_view) {
15353
- el_view.style.setProperty("--ab-width-outer", (el_view.offsetWidth - 40).toString() + "px");
15354
- }
15355
- }
15356
- if (d.querySelector(".ab-nodes-node")) {
15357
- const els_min = document.querySelectorAll(".ab-nodes.min .ab-nodes-node");
15358
- const list_children = d.querySelectorAll(".ab-nodes-node");
15359
- for (const children2 of list_children) {
15360
- const el_content = children2.querySelector(".ab-nodes-content");
15361
- if (!el_content) continue;
15362
- const el_child = children2.querySelector(".ab-nodes-children");
15363
- if (!el_child) continue;
15364
- const el_bracket = el_child.querySelector(".ab-nodes-bracket");
15365
- if (!el_bracket) continue;
15366
- const el_bracket2 = el_child.querySelector(".ab-nodes-bracket2");
15367
- if (!el_bracket2) continue;
15368
- const els_child = el_child.childNodes;
15369
- if (els_child.length < 3) {
15370
- el_bracket.style.setProperty("display", "none");
15371
- el_bracket2.style.setProperty("display", "none");
15372
- continue;
15373
- }
15374
- const el_child_first = els_child[2];
15375
- const el_child_last = els_child[els_child.length - 1];
15376
- const el_child_first_content = el_child_first.querySelector(".ab-nodes-content");
15377
- const el_child_last_content = el_child_last.querySelector(".ab-nodes-content");
15378
- let height = 0;
15379
- let heightToReduce = (el_child_first.offsetHeight + el_child_last.offsetHeight) / 2;
15380
- if (els_child.length == 3) {
15381
- height = el_child_first_content.offsetHeight - 20 > 20 ? el_child_first_content.offsetHeight - 20 : 20;
15382
- el_bracket2.style.cssText = `
15383
- height: ${height}px;
15384
- top: calc(50% - ${height / 2}px);
15385
- `;
15386
- } else {
15387
- el_bracket2.style.cssText = `
15388
- height: calc(100% - ${heightToReduce}px);
15389
- top: ${el_child_first.offsetHeight / 2}px;
15390
- `;
15391
- }
15392
- if (Array.prototype.includes.call(els_min, children2)) {
15393
- if (els_child.length == 3) {
15394
- el_bracket.style.cssText = `
15395
- display: block;
15396
- top: calc(50% + ${el_content.offsetHeight / 2}px - 3px);
15397
- clip-path: circle(40% at 50% 40%);
15398
- `;
15399
- } else {
15400
- el_bracket.setAttribute("display", "none");
15401
- }
15402
- if (els_child.length == 3 && el_content.offsetHeight == el_child_first_content.offsetHeight) {
15403
- el_bracket2.style.cssText = `
15404
- height: 1px;
15405
- top: calc(50% + ${el_content.offsetHeight / 2}px - 1px);
15406
- width: 18px; /* 可以溢出点 */
15407
- border-radius: 0;
15408
- border: none;
15409
- border-bottom: 1px solid var(--node-color);
15410
- `;
15411
- } else {
15412
- if (els_child.length == 3) {
15413
- height = el_child_last_content.offsetHeight / 2 - el_content.offsetHeight / 2;
15414
- el_bracket2.style.setProperty("height", `${height}px`);
15415
- el_bracket2.style.setProperty("top", `calc(50% + ${el_content.offsetHeight / 2}px)`);
15416
- el_bracket2.style.setProperty("border-radius", `0 0 0 10px`);
15417
- el_bracket2.style.setProperty("border-top", `0`);
15418
- } else {
15419
- heightToReduce = el_child_first.offsetHeight / 2 + el_child_first_content.offsetHeight / 2 + el_child_last.offsetHeight / 2 - el_child_last_content.offsetHeight / 2;
15420
- el_bracket2.style.setProperty("height", `calc(100% - ${heightToReduce}px + 1px)`);
15421
- el_bracket2.style.setProperty("top", `${el_child_first.offsetHeight / 2 + el_child_first_content.offsetHeight / 2 - 1}px`);
15422
- }
15423
- el_bracket2.style.setProperty("width", "20px");
15424
- }
15425
- }
15426
- }
15427
- }
15428
- if (d.querySelector(".ab-items.ab-lay-vfall:not(.js-waterfall):not(.ab-lay-hfall):not(.ab-lay-grid)")) {
15429
- const root_el_list = d.querySelectorAll(".ab-items.ab-lay-vfall:not(.js-waterfall):not(.ab-lay-hfall):not(.ab-lay-grid)");
15430
- for (const root_el of root_el_list) {
15431
- root_el.classList.add("js-waterfall");
15432
- const list_children = root_el.querySelectorAll(".ab-items-item");
15433
- const columnCountTmp = parseInt(window.getComputedStyle(root_el).getPropertyValue("column-count"));
15434
- let columnCount;
15435
- if (columnCountTmp && !isNaN(columnCountTmp) && columnCountTmp > 0) {
15436
- columnCount = columnCountTmp;
15437
- } else if (root_el.classList.contains("ab-col-auto") && list_children.length <= 4) {
15438
- columnCount = list_children.length;
15439
- root_el.classList.add("ab-col" + columnCount);
15440
- } else {
15441
- columnCount = 4;
15442
- root_el.classList.add("ab-col" + columnCount);
15443
- }
15444
- const height_cache = [];
15445
- const el_cache = [];
15446
- for (let i = 0; i < columnCount; i++) {
15447
- height_cache.push(0);
15448
- el_cache.push([]);
15449
- }
15450
- for (const children2 of list_children) {
15451
- const minValue = Math.min.apply(null, height_cache);
15452
- const minIndex = height_cache.indexOf(minValue);
15453
- const heightTmp = parseInt(window.getComputedStyle(children2).getPropertyValue("height"));
15454
- height_cache[minIndex] += heightTmp && !isNaN(heightTmp) && heightTmp > 0 ? heightTmp : 10;
15455
- el_cache[minIndex].push(children2);
15456
- }
15457
- const fillNumber = columnCount - list_children.length % columnCount;
15458
- if (fillNumber != 4) {
15459
- for (let i = 0; i < fillNumber; i++) {
15460
- const children2 = document.createElement("div");
15461
- children2.classList.add(".ab-items-item.placeholder");
15462
- children2.setAttribute("style", "height: 20px");
15463
- const minValue = Math.min.apply(null, height_cache);
15464
- const minIndex = height_cache.indexOf(minValue);
15465
- height_cache[minIndex] += 20;
15466
- el_cache[minIndex].push(children2);
15467
- }
15468
- }
15469
- root_el.innerHTML = "";
15470
- for (let i = 0; i < columnCount; i++) {
15471
- for (const j of el_cache[i]) {
15472
- root_el.appendChild(j);
15473
- }
15474
- }
15475
- }
15476
- }
15477
- if (!isCycle && d.querySelector(".ab-markmap-div")) {
15478
- const divEl = d;
15479
- let markmapId = "";
15480
- if (divEl.tagName === "DIV") {
15481
- markmapId = divEl.querySelector(".ab-markmap-div")?.id || "";
15482
- }
15483
- let mindmaps;
15484
- if (markmapId) {
15485
- mindmaps = document.querySelectorAll("#" + markmapId);
15486
- } else {
15487
- mindmaps = document.querySelectorAll(".ab-markmap-div");
15488
- }
15489
- for (const el_div of mindmaps) {
15490
- const el_svg = el_div.querySelector("svg");
15491
- const el_g = el_svg?.querySelector("g");
15492
- if (el_svg && el_g) {
15493
- const scale_new = el_g.getBBox().height / el_div.offsetWidth;
15494
- el_svg.setAttribute("style", `height:${el_g.getBBox().height * scale_new + 40}px`);
15495
- markmap_event(d);
15496
- }
15497
- }
15498
- }
15499
- }
15500
- function markmap_event(d) {
15501
- if (d.querySelector(".ab-markmap-svg")) {
15502
- console.log(" - markmap_event");
15503
- let script_el = document.querySelector('script[script-id="ab-markmap-script"]');
15504
- if (script_el) script_el.remove();
15505
- const divEl = d;
15506
- let markmapId = "";
15507
- if (divEl.tagName === "DIV") {
15508
- markmapId = divEl.querySelector(".ab-markmap-svg")?.id || "";
15509
- }
15510
- script_el = document.createElement("script");
15511
- document.head.appendChild(script_el);
15512
- script_el.type = "module";
15513
- script_el.setAttribute("script-id", "ab-markmap-script");
15514
- script_el.textContent = `
15515
- import { Markmap, } from 'https://jspm.dev/markmap-view';
15516
- const markmapId = "${markmapId || ""}";
15517
- let mindmaps;
15518
- if (markmapId) {
15519
- mindmaps = document.querySelectorAll('#' + markmapId);
15520
- } else {
15521
- mindmaps = document.querySelectorAll('.ab-markmap-svg'); // 注意一下这里的选择器
15522
- }
15523
- for(const mindmap of mindmaps) {
15524
- mindmap.innerHTML = "";
15525
- Markmap.create(mindmap,null,JSON.parse(mindmap.getAttribute('data-json')));
15526
- }`;
15527
- }
15528
- }
15529
16613
  const testPath = "npm2url/dist/index.cjs";
15530
16614
  const defaultProviders = {
15531
16615
  jsdelivr: (path) => `https://cdn.jsdelivr.net/npm/${path}`,
@@ -41151,8 +42235,8 @@ function requireKatex() {
41151
42235
  var _functions = {};
41152
42236
  var _htmlGroupBuilders = {};
41153
42237
  var _mathmlGroupBuilders = {};
41154
- function defineFunction(_ref) {
41155
- var type = _ref.type, names = _ref.names, props = _ref.props, handler = _ref.handler, htmlBuilder = _ref.htmlBuilder, mathmlBuilder = _ref.mathmlBuilder;
42238
+ function defineFunction(_ref2) {
42239
+ var type = _ref2.type, names = _ref2.names, props = _ref2.props, handler = _ref2.handler, htmlBuilder = _ref2.htmlBuilder, mathmlBuilder = _ref2.mathmlBuilder;
41156
42240
  var data2 = {
41157
42241
  type,
41158
42242
  numArgs: props.numArgs,
@@ -42150,8 +43234,8 @@ function requireKatex() {
42150
43234
  props: {
42151
43235
  numArgs: 1
42152
43236
  },
42153
- handler: function handler(_ref, args) {
42154
- var parser = _ref.parser, funcName = _ref.funcName;
43237
+ handler: function handler(_ref2, args) {
43238
+ var parser = _ref2.parser, funcName = _ref2.funcName;
42155
43239
  var base = args[0];
42156
43240
  return {
42157
43241
  type: "accentUnder",
@@ -42226,8 +43310,8 @@ function requireKatex() {
42226
43310
  numArgs: 1,
42227
43311
  numOptionalArgs: 1
42228
43312
  },
42229
- handler: function handler(_ref, args, optArgs) {
42230
- var parser = _ref.parser, funcName = _ref.funcName;
43313
+ handler: function handler(_ref2, args, optArgs) {
43314
+ var parser = _ref2.parser, funcName = _ref2.funcName;
42231
43315
  return {
42232
43316
  type: "xArrow",
42233
43317
  mode: parser.mode,
@@ -42319,8 +43403,8 @@ function requireKatex() {
42319
43403
  numArgs: 1,
42320
43404
  allowedInText: true
42321
43405
  },
42322
- handler: function handler(_ref, args) {
42323
- var parser = _ref.parser;
43406
+ handler: function handler(_ref2, args) {
43407
+ var parser = _ref2.parser;
42324
43408
  var arg = assertNodeType(args[0], "ordgroup");
42325
43409
  var group = arg.body;
42326
43410
  var number = "";
@@ -42358,8 +43442,8 @@ function requireKatex() {
42358
43442
  greediness: 3,
42359
43443
  argTypes: ["color", "original"]
42360
43444
  },
42361
- handler: function handler(_ref, args) {
42362
- var parser = _ref.parser;
43445
+ handler: function handler(_ref2, args) {
43446
+ var parser = _ref2.parser;
42363
43447
  var color2 = assertNodeType(args[0], "color-token").color;
42364
43448
  var body = args[1];
42365
43449
  return {
@@ -42405,8 +43489,8 @@ function requireKatex() {
42405
43489
  argTypes: ["size"],
42406
43490
  allowedInText: true
42407
43491
  },
42408
- handler: function handler(_ref, args, optArgs) {
42409
- var parser = _ref.parser, funcName = _ref.funcName;
43492
+ handler: function handler(_ref2, args, optArgs) {
43493
+ var parser = _ref2.parser, funcName = _ref2.funcName;
42410
43494
  var size = optArgs[0];
42411
43495
  var newRow = funcName === "\\cr";
42412
43496
  var newLine = false;
@@ -42499,8 +43583,8 @@ function requireKatex() {
42499
43583
  numArgs: 0,
42500
43584
  allowedInText: true
42501
43585
  },
42502
- handler: function handler(_ref) {
42503
- var parser = _ref.parser, funcName = _ref.funcName;
43586
+ handler: function handler(_ref2) {
43587
+ var parser = _ref2.parser, funcName = _ref2.funcName;
42504
43588
  parser.consumeSpaces();
42505
43589
  var token = parser.fetch();
42506
43590
  if (globalMap[token.text]) {
@@ -42834,14 +43918,14 @@ function requireKatex() {
42834
43918
  var delimiter_sqrtSvg = function sqrtSvg(sqrtName, height, viewBoxHeight, extraViniculum, options) {
42835
43919
  var path = sqrtPath(sqrtName, extraViniculum, viewBoxHeight);
42836
43920
  var pathNode = new domTree_PathNode(sqrtName, path);
42837
- var svg = new SvgNode([pathNode], {
43921
+ var svg2 = new SvgNode([pathNode], {
42838
43922
  // Note: 1000:1 ratio of viewBox to document em width.
42839
43923
  "width": "400em",
42840
43924
  "height": height + "em",
42841
43925
  "viewBox": "0 0 400000 " + viewBoxHeight,
42842
43926
  "preserveAspectRatio": "xMinYMin slice"
42843
43927
  });
42844
- return buildCommon.makeSvgSpan(["hide-tail"], [svg], options);
43928
+ return buildCommon.makeSvgSpan(["hide-tail"], [svg2], options);
42845
43929
  };
42846
43930
  var makeSqrtImage = function makeSqrtImage2(height, options) {
42847
43931
  var newOptions = options.havingBaseSizing();
@@ -43451,8 +44535,8 @@ function requireKatex() {
43451
44535
  greediness: 3,
43452
44536
  argTypes: ["color", "text"]
43453
44537
  },
43454
- handler: function handler(_ref, args, optArgs) {
43455
- var parser = _ref.parser, funcName = _ref.funcName;
44538
+ handler: function handler(_ref2, args, optArgs) {
44539
+ var parser = _ref2.parser, funcName = _ref2.funcName;
43456
44540
  var color2 = assertNodeType(args[0], "color-token").color;
43457
44541
  var body = args[1];
43458
44542
  return {
@@ -43530,8 +44614,8 @@ function requireKatex() {
43530
44614
  mathmlBuilder: enclose_mathmlBuilder
43531
44615
  });
43532
44616
  var _environments = {};
43533
- function defineEnvironment(_ref) {
43534
- var type = _ref.type, names = _ref.names, props = _ref.props, handler = _ref.handler, htmlBuilder = _ref.htmlBuilder, mathmlBuilder = _ref.mathmlBuilder;
44617
+ function defineEnvironment(_ref2) {
44618
+ var type = _ref2.type, names = _ref2.names, props = _ref2.props, handler = _ref2.handler, htmlBuilder = _ref2.htmlBuilder, mathmlBuilder = _ref2.mathmlBuilder;
43535
44619
  var data2 = {
43536
44620
  type,
43537
44621
  numArgs: props.numArgs || 0,
@@ -43562,8 +44646,8 @@ function requireKatex() {
43562
44646
  }
43563
44647
  return hlineInfo;
43564
44648
  }
43565
- function parseArray(parser, _ref, style) {
43566
- var hskipBeforeAndAfter = _ref.hskipBeforeAndAfter, addJot = _ref.addJot, cols = _ref.cols, arraystretch = _ref.arraystretch, colSeparationType = _ref.colSeparationType;
44649
+ function parseArray(parser, _ref2, style) {
44650
+ var hskipBeforeAndAfter = _ref2.hskipBeforeAndAfter, addJot = _ref2.addJot, cols = _ref2.cols, arraystretch = _ref2.arraystretch, colSeparationType = _ref2.colSeparationType;
43567
44651
  parser.gullet.beginGroup();
43568
44652
  parser.gullet.macros.set("\\\\", "\\cr");
43569
44653
  if (!arraystretch) {
@@ -44202,8 +45286,8 @@ function requireKatex() {
44202
45286
  numArgs: 1,
44203
45287
  argTypes: ["text"]
44204
45288
  },
44205
- handler: function handler(_ref, args) {
44206
- var parser = _ref.parser, funcName = _ref.funcName;
45289
+ handler: function handler(_ref2, args) {
45290
+ var parser = _ref2.parser, funcName = _ref2.funcName;
44207
45291
  var nameGroup = args[0];
44208
45292
  if (nameGroup.type !== "ordgroup") {
44209
45293
  throw new src_ParseError("Invalid environment name", nameGroup);
@@ -44283,8 +45367,8 @@ function requireKatex() {
44283
45367
  props: {
44284
45368
  numArgs: 1
44285
45369
  },
44286
- handler: function handler(_ref, args) {
44287
- var parser = _ref.parser, funcName = _ref.funcName;
45370
+ handler: function handler(_ref2, args) {
45371
+ var parser = _ref2.parser, funcName = _ref2.funcName;
44288
45372
  var body = args[0];
44289
45373
  return {
44290
45374
  type: "mclass",
@@ -44407,8 +45491,8 @@ function requireKatex() {
44407
45491
  numArgs: 1,
44408
45492
  greediness: 2
44409
45493
  },
44410
- handler: function handler(_ref, args) {
44411
- var parser = _ref.parser, funcName = _ref.funcName;
45494
+ handler: function handler(_ref2, args) {
45495
+ var parser = _ref2.parser, funcName = _ref2.funcName;
44412
45496
  var body = args[0];
44413
45497
  var func = funcName;
44414
45498
  if (func in fontAliases) {
@@ -44662,8 +45746,8 @@ function requireKatex() {
44662
45746
  numArgs: 2,
44663
45747
  greediness: 2
44664
45748
  },
44665
- handler: function handler(_ref, args) {
44666
- var parser = _ref.parser, funcName = _ref.funcName;
45749
+ handler: function handler(_ref2, args) {
45750
+ var parser = _ref2.parser, funcName = _ref2.funcName;
44667
45751
  var numer = args[0];
44668
45752
  var denom = args[1];
44669
45753
  var hasBarLine;
@@ -44964,8 +46048,8 @@ function requireKatex() {
44964
46048
  props: {
44965
46049
  numArgs: 1
44966
46050
  },
44967
- handler: function handler(_ref, args) {
44968
- var parser = _ref.parser, funcName = _ref.funcName;
46051
+ handler: function handler(_ref2, args) {
46052
+ var parser = _ref2.parser, funcName = _ref2.funcName;
44969
46053
  return {
44970
46054
  type: "horizBrace",
44971
46055
  mode: parser.mode,
@@ -44985,8 +46069,8 @@ function requireKatex() {
44985
46069
  argTypes: ["url", "original"],
44986
46070
  allowedInText: true
44987
46071
  },
44988
- handler: function handler(_ref, args) {
44989
- var parser = _ref.parser;
46072
+ handler: function handler(_ref2, args) {
46073
+ var parser = _ref2.parser;
44990
46074
  var body = args[1];
44991
46075
  var href = assertNodeType(args[0], "url").url;
44992
46076
  if (!parser.settings.isTrusted({
@@ -45066,9 +46150,9 @@ function requireKatex() {
45066
46150
  argTypes: ["raw", "original"],
45067
46151
  allowedInText: true
45068
46152
  },
45069
- handler: function handler(_ref, args) {
45070
- var parser = _ref.parser, funcName = _ref.funcName;
45071
- _ref.token;
46153
+ handler: function handler(_ref2, args) {
46154
+ var parser = _ref2.parser, funcName = _ref2.funcName;
46155
+ _ref2.token;
45072
46156
  var value = assertNodeType(args[0], "raw").string;
45073
46157
  var body = args[1];
45074
46158
  if (parser.settings.strict) {
@@ -45151,8 +46235,8 @@ function requireKatex() {
45151
46235
  numArgs: 2,
45152
46236
  allowedInText: true
45153
46237
  },
45154
- handler: function handler(_ref, args) {
45155
- var parser = _ref.parser;
46238
+ handler: function handler(_ref2, args) {
46239
+ var parser = _ref2.parser;
45156
46240
  return {
45157
46241
  type: "htmlmathml",
45158
46242
  mode: parser.mode,
@@ -45199,8 +46283,8 @@ function requireKatex() {
45199
46283
  argTypes: ["raw", "url"],
45200
46284
  allowedInText: false
45201
46285
  },
45202
- handler: function handler(_ref, args, optArgs) {
45203
- var parser = _ref.parser;
46286
+ handler: function handler(_ref2, args, optArgs) {
46287
+ var parser = _ref2.parser;
45204
46288
  var width = {
45205
46289
  number: 0,
45206
46290
  unit: "em"
@@ -45314,8 +46398,8 @@ function requireKatex() {
45314
46398
  argTypes: ["size"],
45315
46399
  allowedInText: true
45316
46400
  },
45317
- handler: function handler(_ref, args) {
45318
- var parser = _ref.parser, funcName = _ref.funcName;
46401
+ handler: function handler(_ref2, args) {
46402
+ var parser = _ref2.parser, funcName = _ref2.funcName;
45319
46403
  var size = assertNodeType(args[0], "size");
45320
46404
  if (parser.settings.strict) {
45321
46405
  var mathFunction = funcName[1] === "m";
@@ -45354,8 +46438,8 @@ function requireKatex() {
45354
46438
  numArgs: 1,
45355
46439
  allowedInText: true
45356
46440
  },
45357
- handler: function handler(_ref, args) {
45358
- var parser = _ref.parser, funcName = _ref.funcName;
46441
+ handler: function handler(_ref2, args) {
46442
+ var parser = _ref2.parser, funcName = _ref2.funcName;
45359
46443
  var body = args[0];
45360
46444
  return {
45361
46445
  type: "lap",
@@ -45399,8 +46483,8 @@ function requireKatex() {
45399
46483
  allowedInText: true,
45400
46484
  allowedInMath: false
45401
46485
  },
45402
- handler: function handler(_ref, args) {
45403
- var funcName = _ref.funcName, parser = _ref.parser;
46486
+ handler: function handler(_ref2, args) {
46487
+ var funcName = _ref2.funcName, parser = _ref2.parser;
45404
46488
  var outerMode = parser.mode;
45405
46489
  parser.switchMode("math");
45406
46490
  var close = funcName === "\\(" ? "\\)" : "$";
@@ -45448,8 +46532,8 @@ function requireKatex() {
45448
46532
  props: {
45449
46533
  numArgs: 4
45450
46534
  },
45451
- handler: function handler(_ref, args) {
45452
- var parser = _ref.parser;
46535
+ handler: function handler(_ref2, args) {
46536
+ var parser = _ref2.parser;
45453
46537
  return {
45454
46538
  type: "mathchoice",
45455
46539
  mode: parser.mode,
@@ -45681,8 +46765,8 @@ function requireKatex() {
45681
46765
  props: {
45682
46766
  numArgs: 0
45683
46767
  },
45684
- handler: function handler(_ref, args) {
45685
- var parser = _ref.parser, funcName = _ref.funcName;
46768
+ handler: function handler(_ref2, args) {
46769
+ var parser = _ref2.parser, funcName = _ref2.funcName;
45686
46770
  var fName = funcName;
45687
46771
  if (fName.length === 1) {
45688
46772
  fName = singleCharBigOps[fName];
@@ -45888,8 +46972,8 @@ function requireKatex() {
45888
46972
  props: {
45889
46973
  numArgs: 1
45890
46974
  },
45891
- handler: function handler(_ref, args) {
45892
- var parser = _ref.parser, funcName = _ref.funcName;
46975
+ handler: function handler(_ref2, args) {
46976
+ var parser = _ref2.parser, funcName = _ref2.funcName;
45893
46977
  var body = args[0];
45894
46978
  return {
45895
46979
  type: "operatorname",
@@ -45921,8 +47005,8 @@ function requireKatex() {
45921
47005
  props: {
45922
47006
  numArgs: 1
45923
47007
  },
45924
- handler: function handler(_ref, args) {
45925
- var parser = _ref.parser;
47008
+ handler: function handler(_ref2, args) {
47009
+ var parser = _ref2.parser;
45926
47010
  var body = args[0];
45927
47011
  return {
45928
47012
  type: "overline",
@@ -45967,8 +47051,8 @@ function requireKatex() {
45967
47051
  numArgs: 1,
45968
47052
  allowedInText: true
45969
47053
  },
45970
- handler: function handler(_ref, args) {
45971
- var parser = _ref.parser;
47054
+ handler: function handler(_ref2, args) {
47055
+ var parser = _ref2.parser;
45972
47056
  var body = args[0];
45973
47057
  return {
45974
47058
  type: "phantom",
@@ -46066,8 +47150,8 @@ function requireKatex() {
46066
47150
  argTypes: ["size", "hbox"],
46067
47151
  allowedInText: true
46068
47152
  },
46069
- handler: function handler(_ref, args) {
46070
- var parser = _ref.parser;
47153
+ handler: function handler(_ref2, args) {
47154
+ var parser = _ref2.parser;
46071
47155
  var amount = assertNodeType(args[0], "size").value;
46072
47156
  var body = args[1];
46073
47157
  return {
@@ -46104,8 +47188,8 @@ function requireKatex() {
46104
47188
  numOptionalArgs: 1,
46105
47189
  argTypes: ["size", "size", "size"]
46106
47190
  },
46107
- handler: function handler(_ref, args, optArgs) {
46108
- var parser = _ref.parser;
47191
+ handler: function handler(_ref2, args, optArgs) {
47192
+ var parser = _ref2.parser;
46109
47193
  var shift = optArgs[0];
46110
47194
  var width = assertNodeType(args[0], "size");
46111
47195
  var height = assertNodeType(args[1], "size");
@@ -46178,8 +47262,8 @@ function requireKatex() {
46178
47262
  numArgs: 0,
46179
47263
  allowedInText: true
46180
47264
  },
46181
- handler: function handler(_ref, args) {
46182
- var breakOnTokenText = _ref.breakOnTokenText, funcName = _ref.funcName, parser = _ref.parser;
47265
+ handler: function handler(_ref2, args) {
47266
+ var breakOnTokenText = _ref2.breakOnTokenText, funcName = _ref2.funcName, parser = _ref2.parser;
46183
47267
  var body = parser.parseExpression(false, breakOnTokenText);
46184
47268
  return {
46185
47269
  type: "sizing",
@@ -46206,8 +47290,8 @@ function requireKatex() {
46206
47290
  numOptionalArgs: 1,
46207
47291
  allowedInText: true
46208
47292
  },
46209
- handler: function handler(_ref, args, optArgs) {
46210
- var parser = _ref.parser;
47293
+ handler: function handler(_ref2, args, optArgs) {
47294
+ var parser = _ref2.parser;
46211
47295
  var smashHeight = false;
46212
47296
  var smashDepth = false;
46213
47297
  var tbArg = optArgs[0] && assertNodeType(optArgs[0], "ordgroup");
@@ -46287,8 +47371,8 @@ function requireKatex() {
46287
47371
  numArgs: 1,
46288
47372
  numOptionalArgs: 1
46289
47373
  },
46290
- handler: function handler(_ref, args, optArgs) {
46291
- var parser = _ref.parser;
47374
+ handler: function handler(_ref2, args, optArgs) {
47375
+ var parser = _ref2.parser;
46292
47376
  var index2 = optArgs[0];
46293
47377
  var body = args[0];
46294
47378
  return {
@@ -46372,8 +47456,8 @@ function requireKatex() {
46372
47456
  numArgs: 0,
46373
47457
  allowedInText: true
46374
47458
  },
46375
- handler: function handler(_ref, args) {
46376
- var breakOnTokenText = _ref.breakOnTokenText, funcName = _ref.funcName, parser = _ref.parser;
47459
+ handler: function handler(_ref2, args) {
47460
+ var breakOnTokenText = _ref2.breakOnTokenText, funcName = _ref2.funcName, parser = _ref2.parser;
46377
47461
  var body = parser.parseExpression(true, breakOnTokenText);
46378
47462
  var style = funcName.slice(1, funcName.length - 5);
46379
47463
  return {
@@ -46758,8 +47842,8 @@ function requireKatex() {
46758
47842
  greediness: 2,
46759
47843
  allowedInText: true
46760
47844
  },
46761
- handler: function handler(_ref, args) {
46762
- var parser = _ref.parser, funcName = _ref.funcName;
47845
+ handler: function handler(_ref2, args) {
47846
+ var parser = _ref2.parser, funcName = _ref2.funcName;
46763
47847
  var body = args[0];
46764
47848
  return {
46765
47849
  type: "text",
@@ -46785,8 +47869,8 @@ function requireKatex() {
46785
47869
  numArgs: 1,
46786
47870
  allowedInText: true
46787
47871
  },
46788
- handler: function handler(_ref, args) {
46789
- var parser = _ref.parser;
47872
+ handler: function handler(_ref2, args) {
47873
+ var parser = _ref2.parser;
46790
47874
  return {
46791
47875
  type: "underline",
46792
47876
  mode: parser.mode,
@@ -49656,7 +50740,7 @@ ABConvert.factory({
49656
50740
  process_return: ABConvert_IOEnum.el,
49657
50741
  process: (el, header, content) => {
49658
50742
  list2markmap(content, el);
49659
- markmap_event(el);
50743
+ ABCSetting.obsidian.markmap_event?.(el);
49660
50744
  return el;
49661
50745
  }
49662
50746
  });
@@ -49672,13 +50756,46 @@ function list2markmap(markdown, div) {
49672
50756
  svg_div.classList.add("ab-markmap-div");
49673
50757
  svg_div.id = "ab-markmap-div-" + id;
49674
50758
  const html_str = `<svg class="ab-markmap-svg" id="ab-markmap-${id}" data-json='${JSON.stringify(root2)}' style="height:${height_adapt}px"></svg>`;
49675
- svg_div.innerHTML = html_str;
50759
+ svg_div.innerHTML = purify.sanitize(html_str, {
50760
+ USE_PROFILES: { svg: true }
50761
+ });
49676
50762
  } else {
49677
50763
  div.classList.add("ab-raw");
49678
- div.innerHTML = `<div class="ab-raw-data" type-data="markmap" content-data='${markdown}'></div>`;
50764
+ div.innerHTML = purify.sanitize(`<div class="ab-raw-data" type-data="markmap" content-data='${markdown}'></div>`);
49679
50765
  }
49680
50766
  return div;
49681
50767
  }
50768
+ async function markmap_event(d) {
50769
+ if (ABCSetting.env == "obsidian-min") return;
50770
+ if (d.querySelector(".ab-markmap-svg")) {
50771
+ console.log(" - markmap_event");
50772
+ let script_el = document.querySelector('script[script-id="ab-markmap-script"]');
50773
+ if (script_el) script_el.remove();
50774
+ const divEl = d;
50775
+ let markmapId = "";
50776
+ if (divEl.tagName === "DIV") {
50777
+ markmapId = divEl.querySelector(".ab-markmap-svg")?.id || "";
50778
+ }
50779
+ script_el = document.createElement("script");
50780
+ document.head.appendChild(script_el);
50781
+ script_el.type = "module";
50782
+ script_el.setAttribute("script-id", "ab-markmap-script");
50783
+ script_el.textContent = `
50784
+ import { Markmap, } from 'https://jspm.dev/markmap-view';
50785
+ const markmapId = "${markmapId || ""}";
50786
+ let mindmaps;
50787
+ if (markmapId) {
50788
+ mindmaps = document.querySelectorAll('#' + markmapId);
50789
+ } else {
50790
+ mindmaps = document.querySelectorAll('.ab-markmap-svg'); // 注意一下这里的选择器
50791
+ }
50792
+ for(const mindmap of mindmaps) {
50793
+ mindmap.innerHTML = "";
50794
+ Markmap.create(mindmap,null,JSON.parse(mindmap.getAttribute('data-json')));
50795
+ }`;
50796
+ }
50797
+ }
50798
+ ABCSetting.obsidian.markmap_event = markmap_event;
49682
50799
  const md = new MarkdownIt({
49683
50800
  html: true,
49684
50801
  // 启用 HTML 标签解析
@@ -49735,6 +50852,166 @@ const quartz_transformer_anyblock = () => {
49735
50852
  }
49736
50853
  };
49737
50854
  };
50855
+ function abConvertEvent(d, isCycle = false) {
50856
+ if (d.querySelector(".ab-super-width")) {
50857
+ const els_note = d.querySelectorAll(".ab-note");
50858
+ for (const el_note of els_note) {
50859
+ if (el_note.classList.contains("ab-super-width") || el_note.querySelector(".ab-super-width")) {
50860
+ const el_replace = el_note.parentNode;
50861
+ if (el_replace && el_replace.classList.contains("ab-replace")) {
50862
+ el_replace.classList.add("ab-super-width-p");
50863
+ }
50864
+ }
50865
+ }
50866
+ const els_view = document.querySelectorAll(".app-container .workspace-leaf");
50867
+ for (const el_view of els_view) {
50868
+ el_view.style.setProperty("--ab-width-outer", (el_view.offsetWidth - 40).toString() + "px");
50869
+ }
50870
+ }
50871
+ if (d.querySelector(".ab-nodes-node")) {
50872
+ const els_min = document.querySelectorAll(".ab-nodes.min .ab-nodes-node");
50873
+ const list_children = d.querySelectorAll(".ab-nodes-node");
50874
+ for (const children2 of list_children) {
50875
+ const el_content = children2.querySelector(".ab-nodes-content");
50876
+ if (!el_content) continue;
50877
+ const el_child = children2.querySelector(".ab-nodes-children");
50878
+ if (!el_child) continue;
50879
+ const el_bracket = el_child.querySelector(".ab-nodes-bracket");
50880
+ if (!el_bracket) continue;
50881
+ const el_bracket2 = el_child.querySelector(".ab-nodes-bracket2");
50882
+ if (!el_bracket2) continue;
50883
+ const els_child = el_child.childNodes;
50884
+ if (els_child.length < 3) {
50885
+ el_bracket.style.setProperty("display", "none");
50886
+ el_bracket2.style.setProperty("display", "none");
50887
+ continue;
50888
+ }
50889
+ const el_child_first = els_child[2];
50890
+ const el_child_last = els_child[els_child.length - 1];
50891
+ const el_child_first_content = el_child_first.querySelector(".ab-nodes-content");
50892
+ const el_child_last_content = el_child_last.querySelector(".ab-nodes-content");
50893
+ let height = 0;
50894
+ let heightToReduce = (el_child_first.offsetHeight + el_child_last.offsetHeight) / 2;
50895
+ if (els_child.length == 3) {
50896
+ height = el_child_first_content.offsetHeight - 20 > 20 ? el_child_first_content.offsetHeight - 20 : 20;
50897
+ el_bracket2.style.cssText = `
50898
+ height: ${height}px;
50899
+ top: calc(50% - ${height / 2}px);
50900
+ `;
50901
+ } else {
50902
+ el_bracket2.style.cssText = `
50903
+ height: calc(100% - ${heightToReduce}px);
50904
+ top: ${el_child_first.offsetHeight / 2}px;
50905
+ `;
50906
+ }
50907
+ if (Array.prototype.includes.call(els_min, children2)) {
50908
+ if (els_child.length == 3) {
50909
+ el_bracket.style.cssText = `
50910
+ display: block;
50911
+ top: calc(50% + ${el_content.offsetHeight / 2}px - 3px);
50912
+ clip-path: circle(40% at 50% 40%);
50913
+ `;
50914
+ } else {
50915
+ el_bracket.setAttribute("display", "none");
50916
+ }
50917
+ if (els_child.length == 3 && el_content.offsetHeight == el_child_first_content.offsetHeight) {
50918
+ el_bracket2.style.cssText = `
50919
+ height: 1px;
50920
+ top: calc(50% + ${el_content.offsetHeight / 2}px - 1px);
50921
+ width: 18px; /* 可以溢出点 */
50922
+ border-radius: 0;
50923
+ border: none;
50924
+ border-bottom: 1px solid var(--node-color);
50925
+ `;
50926
+ } else {
50927
+ if (els_child.length == 3) {
50928
+ height = el_child_last_content.offsetHeight / 2 - el_content.offsetHeight / 2;
50929
+ el_bracket2.style.setProperty("height", `${height}px`);
50930
+ el_bracket2.style.setProperty("top", `calc(50% + ${el_content.offsetHeight / 2}px)`);
50931
+ el_bracket2.style.setProperty("border-radius", `0 0 0 10px`);
50932
+ el_bracket2.style.setProperty("border-top", `0`);
50933
+ } else {
50934
+ heightToReduce = el_child_first.offsetHeight / 2 + el_child_first_content.offsetHeight / 2 + el_child_last.offsetHeight / 2 - el_child_last_content.offsetHeight / 2;
50935
+ el_bracket2.style.setProperty("height", `calc(100% - ${heightToReduce}px + 1px)`);
50936
+ el_bracket2.style.setProperty("top", `${el_child_first.offsetHeight / 2 + el_child_first_content.offsetHeight / 2 - 1}px`);
50937
+ }
50938
+ el_bracket2.style.setProperty("width", "20px");
50939
+ }
50940
+ }
50941
+ }
50942
+ }
50943
+ if (d.querySelector(".ab-items.ab-lay-vfall:not(.js-waterfall):not(.ab-lay-hfall):not(.ab-lay-grid)")) {
50944
+ const root_el_list = d.querySelectorAll(".ab-items.ab-lay-vfall:not(.js-waterfall):not(.ab-lay-hfall):not(.ab-lay-grid)");
50945
+ for (const root_el of root_el_list) {
50946
+ root_el.classList.add("js-waterfall");
50947
+ const list_children = root_el.querySelectorAll(".ab-items-item");
50948
+ const columnCountTmp = parseInt(window.getComputedStyle(root_el).getPropertyValue("column-count"));
50949
+ let columnCount;
50950
+ if (columnCountTmp && !isNaN(columnCountTmp) && columnCountTmp > 0) {
50951
+ columnCount = columnCountTmp;
50952
+ } else if (root_el.classList.contains("ab-col-auto") && list_children.length <= 4) {
50953
+ columnCount = list_children.length;
50954
+ root_el.classList.add("ab-col" + columnCount);
50955
+ } else {
50956
+ columnCount = 4;
50957
+ root_el.classList.add("ab-col" + columnCount);
50958
+ }
50959
+ const height_cache = [];
50960
+ const el_cache = [];
50961
+ for (let i = 0; i < columnCount; i++) {
50962
+ height_cache.push(0);
50963
+ el_cache.push([]);
50964
+ }
50965
+ for (const children2 of list_children) {
50966
+ const minValue = Math.min.apply(null, height_cache);
50967
+ const minIndex = height_cache.indexOf(minValue);
50968
+ const heightTmp = parseInt(window.getComputedStyle(children2).getPropertyValue("height"));
50969
+ height_cache[minIndex] += heightTmp && !isNaN(heightTmp) && heightTmp > 0 ? heightTmp : 10;
50970
+ el_cache[minIndex].push(children2);
50971
+ }
50972
+ const fillNumber = columnCount - list_children.length % columnCount;
50973
+ if (fillNumber != 4) {
50974
+ for (let i = 0; i < fillNumber; i++) {
50975
+ const children2 = document.createElement("div");
50976
+ children2.classList.add(".ab-items-item.placeholder");
50977
+ children2.setAttribute("style", "height: 20px");
50978
+ const minValue = Math.min.apply(null, height_cache);
50979
+ const minIndex = height_cache.indexOf(minValue);
50980
+ height_cache[minIndex] += 20;
50981
+ el_cache[minIndex].push(children2);
50982
+ }
50983
+ }
50984
+ root_el.innerHTML = "";
50985
+ for (let i = 0; i < columnCount; i++) {
50986
+ for (const j of el_cache[i]) {
50987
+ root_el.appendChild(j);
50988
+ }
50989
+ }
50990
+ }
50991
+ }
50992
+ if (!isCycle && d.querySelector(".ab-markmap-div")) {
50993
+ const divEl = d;
50994
+ let markmapId = "";
50995
+ if (divEl.tagName === "DIV") {
50996
+ markmapId = divEl.querySelector(".ab-markmap-div")?.id || "";
50997
+ }
50998
+ let mindmaps;
50999
+ if (markmapId) {
51000
+ mindmaps = document.querySelectorAll("#" + markmapId);
51001
+ } else {
51002
+ mindmaps = document.querySelectorAll(".ab-markmap-div");
51003
+ }
51004
+ for (const el_div of mindmaps) {
51005
+ const el_svg = el_div.querySelector("svg");
51006
+ const el_g = el_svg?.querySelector("g");
51007
+ if (el_svg && el_g) {
51008
+ const scale_new = el_g.getBBox().height / el_div.offsetWidth;
51009
+ el_svg.setAttribute("style", `height:${el_g.getBBox().height * scale_new + 40}px`);
51010
+ ABCSetting.obsidian.markmap_event?.(d);
51011
+ }
51012
+ }
51013
+ }
51014
+ }
49738
51015
  exports.ABConvertManager = ABConvertManager;
49739
51016
  exports.ABReg = ABReg;
49740
51017
  exports.abConvertEvent = abConvertEvent;