markdown-it-any-block 3.4.4 → 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.
@@ -4,7 +4,10 @@ const ABCSetting = {
4
4
  env: "obsidian",
5
5
  // 某些环境的独占 api,其他环境用不上
6
6
  obsidian: {
7
- mermaid: void 0
7
+ global_app: null,
8
+ global_ctx: null,
9
+ mermaid: void 0,
10
+ markmap_event: void 0
8
11
  }
9
12
  };
10
13
  const ABReg = {
@@ -177,15 +180,39 @@ const ABAlias_json_withSub = [
177
180
  // 注意避免和原上/上面的callout语法冲突,以及自身递归
178
181
  ];
179
182
  const ABAlias_json_mdit = [
180
- { regex: /\|:::_140lne\|(2?tabs?|标签页?)\|/, replacement: "|mditTabs|" },
183
+ { regex: /\|:::_140lne\|((?:mdit2|2)?tabs?|标签页?)\|/, replacement: "|mditTabs|" },
181
184
  { regex: "|:::_140lne|demo|", replacement: "|mditDemo|" },
182
185
  { regex: "|:::_140lne|abDemo|", replacement: "|mditABDemo|" },
183
- { regex: /\|:::_140lne\|(2?col|分栏)\|/, replacement: "|mditCol|" },
184
- { regex: /\|:::_140lne\|(2?card|卡片)\|/, replacement: "|mditCard|" },
185
- { regex: /\|:::_140lne\|(2?chat|聊天)\|/, replacement: "|mditChat|code(chat)|" }
186
+ { regex: /\|:::_140lne\|((?:mdit2|2)?col|分栏)\|/, replacement: "|mditCol|" },
187
+ { regex: /\|:::_140lne\|((?:mdit2|2)?card|卡片)\|/, replacement: "|mditCard|" },
188
+ { regex: /\|:::_140lne\|((?:mdit2|2)?chat|聊天)\|/, replacement: "|mditChat|code(chat)|" },
189
+ //
190
+ // {regex: /\|:::_140lne\|2?(timeline|时间线)\|/, replacement: "|title2timeline|"},
191
+ // {regex: /\|:::_140lne\|2?(tabs?|标签页?)\||\|title2tabs?\|/, replacement: "|title2c2listdata|c2listdata2tab|"},
192
+ // {regex: /\|:::_140lne\|2?(col|分栏)\||\|title2col\|/, replacement: "|title2c2listdata|c2listdata2items|addClass(ab-col)|"},
193
+ // {regex: /\|:::_140lne\|2?(card|卡片)\||\|title2card\|/, replacement: "|title2c2listdata|c2listdata2items|addClass(ab-card)|addClass(ab-lay-vfall)|"},
194
+ // {regex: /\|:::_140lne\|2?(nodes?|节点)\||\|(title2node|title2abMindmap)\|/, replacement: "|title2listdata|listdata2strict|listdata2nodes|"},
195
+ // list - 多叉多层树
196
+ { regex: /\|:::_140lne\|(?:mdit2|2)?(mermaid|flow|流程图)\|/, replacement: "|mdit2list|list2mermaid|" },
197
+ { regex: /\|:::_140lne\|(?:mdit2|2)?(mehrmaid|mdmermaid)\|/, replacement: "|mdit2list|list2mehrmaidText|code(mehrmaid)|" },
198
+ { regex: /\|:::_140lne\|(?:mdit2|2)?(puml)?(plantuml|mindmap|脑图|思维导图)\|/, replacement: "|mdit2list|list2pumlMindmap|" },
199
+ { regex: /\|:::_140lne\|(?:mdit2|2)?(markmap|mdMindmap|md脑图|md思维导图)\|/, replacement: "|mdit2list|list2markmap|" },
200
+ { regex: /\|:::_140lne\|(?:mdit2|2)?(wbs|(工作)?分解(图|结构))\|/, replacement: "|mdit2list|list2pumlWBS|" },
201
+ { regex: /\|:::_140lne\|(?:mdit2|2)?(table|multiWayTable|multiCrossTable|表格?|多叉表格?|跨行表格?)\|/, replacement: "|mdit2Listdata|listdata2strict|listdata2table|" },
202
+ // list - lt树 (属于多层一叉树)
203
+ { regex: /\|:::_140lne\|(?:mdit2|2)?(lt|listTable|treeTable|listGrid|treeGrid|列表格|树形表格?)\|/, replacement: "|mdit2list|list2lt|" },
204
+ { regex: /\|:::_140lne\|2?(list|列表)\|/, replacement: "|mdit2list|list2lt|addClass(ab-listtable-likelist)|" },
205
+ { regex: /\|:::_140lne\|(?:mdit2|2)?(dir|dirTree|目录树?|目录结构)\|/, replacement: "|mdit2list|list2dt|" },
206
+ // list - 二层树
207
+ { regex: /\|:::_140lne\|(fakeList|仿列表)\|/, replacement: "|mdit2list|list2table|addClass(ab-table-fc)|addClass(ab-table-likelist)|" },
208
+ // 至后
209
+ { regex: "|mdit2list|", replacement: "|mdit2listdata|listdata2strict|listdata2list|" },
210
+ { regex: "|mdit2List|", replacement: "|mdit2Listdata|listdata2strict|listdata2list|" }
186
211
  ];
187
212
  const ABAlias_json_title = [
188
- { regex: "|title2list|", replacement: "|title2listdata|listdata2strict|listdata2list|" },
213
+ // 至前,特殊
214
+ { regex: "|heading2", replacement: "|title2" },
215
+ { regex: "|h2", replacement: "|title2" },
189
216
  // title - list&title
190
217
  { regex: /\|heading_140lne\|2?(timeline|时间线)\|/, replacement: "|title2timeline|" },
191
218
  { regex: /\|heading_140lne\|2?(tabs?|标签页?)\||\|title2tabs?\|/, replacement: "|title2c2listdata|c2listdata2tab|" },
@@ -198,13 +225,15 @@ const ABAlias_json_title = [
198
225
  { regex: /\|heading_140lne\|2?(puml)?(plantuml|mindmap|脑图|思维导图)\|/, replacement: "|title2list|list2pumlMindmap|" },
199
226
  { regex: /\|heading_140lne\|2?(markmap|mdMindmap|md脑图|md思维导图)\|/, replacement: "|title2list|list2markmap|" },
200
227
  { regex: /\|heading_140lne\|2?(wbs|(工作)?分解(图|结构))\|/, replacement: "|title2list|list2pumlWBS|" },
201
- { regex: /\|heading_140lne\|2?(table|multiWayTable|multiCrossTable|表格?|多叉表格?|跨行表格?)\|/, replacement: "|title2list|list2table|" },
228
+ { regex: /\|heading_140lne\|2?(table|multiWayTable|multiCrossTable|表格?|多叉表格?|跨行表格?)\|/, replacement: "|title2Listdata|listdata2strict|listdata2table|" },
202
229
  // list - lt树 (属于多层一叉树)
203
230
  { regex: /\|heading_140lne\|2?(lt|listTable|treeTable|listGrid|treeGrid|列表格|树形表格?)\|/, replacement: "|title2list|list2lt|" },
204
231
  { regex: /\|heading_140lne\|2?(list|列表)\|/, replacement: "|title2list|list2lt|addClass(ab-listtable-likelist)|" },
205
232
  { regex: /\|heading_140lne\|2?(dir|dirTree|目录树?|目录结构)\|/, replacement: "|title2list|list2dt|" },
206
233
  // list - 二层树
207
- { regex: /\|heading_140lne\|(fakeList|仿列表)\|/, replacement: "|title2list|list2table|addClass(ab-table-fc)|addClass(ab-table-likelist)|" }
234
+ { regex: /\|heading_140lne\|(fakeList|仿列表)\|/, replacement: "|title2list|list2table|addClass(ab-table-fc)|addClass(ab-table-likelist)|" },
235
+ // 至后
236
+ { regex: "|title2list|", replacement: "|title2listdata|listdata2strict|listdata2list|" }
208
237
  ];
209
238
  const ABAlias_json_list = [
210
239
  // 特殊
@@ -361,24 +390,18 @@ class ABConvertManager {
361
390
  * @param header 转换方式
362
391
  * @param content 要转换的初始文本 (无前缀版本,前缀在选择器环节已经删除了)
363
392
  * @param selectorName 选择器名,空表示未知
364
- * @return 等于el,无用,后面可以删了
365
393
  */
366
394
  static autoABConvert(el, header, content, selectorName = "", ctx) {
367
- let prev_result = content;
368
- let prev_type = "string";
369
- let prev_type2 = ABConvert_IOEnum.text;
370
- let prev_processor;
371
395
  let prev2 = {
372
- // 组合在一起是为了引用传参
373
- prev_result,
374
- prev_type,
375
- prev_type2,
376
- prev_processor
396
+ prev_result: content,
397
+ prev_type: "string",
398
+ prev_type2: ABConvert_IOEnum.text,
399
+ prev_processor: void 0
377
400
  };
378
401
  {
379
- header = autoABAlias(header, selectorName, prev_result);
402
+ header = autoABAlias(header, selectorName, prev2.prev_result);
380
403
  let list_header = header.split("|");
381
- prev_result = this.autoABConvert_runConvert(el, list_header, prev2, ctx);
404
+ this.autoABConvert_runConvert(el, list_header, prev2, ctx);
382
405
  this.autoABConvert_last(el, header, selectorName, prev2, ctx);
383
406
  }
384
407
  }
@@ -437,7 +460,12 @@ class ABConvertManager {
437
460
  break;
438
461
  }
439
462
  }
440
- prev2.prev_result = abReplaceProcessor.process(el, item_header, prev2.prev_result, ctx);
463
+ try {
464
+ prev2.prev_result = abReplaceProcessor.process(el, item_header, prev2.prev_result, ctx);
465
+ } catch (e) {
466
+ console.error(`处理器执行错误, id:${abReplaceProcessor.id}, header:${item_header}, error:`, e);
467
+ break;
468
+ }
441
469
  prev2.prev_type = typeof prev2.prev_result;
442
470
  prev2.prev_type2 = abReplaceProcessor.process_return;
443
471
  prev2.prev_processor = abReplaceProcessor.process;
@@ -451,7 +479,7 @@ class ABConvertManager {
451
479
  /**
452
480
  * 子函数,后处理/尾处理,主要进行末尾追加指令
453
481
  */
454
- static autoABConvert_last(el, header, selectorName, prev2, ctx) {
482
+ static autoABConvert_last(el, _header, _selectorName, prev2, _ctx) {
455
483
  if (prev2.prev_type == "string" && prev2.prev_type2 == ABConvert_IOEnum.text) {
456
484
  const subEl = document.createElement("div");
457
485
  el.appendChild(subEl);
@@ -459,7 +487,7 @@ class ABConvertManager {
459
487
  prev2.prev_result = el;
460
488
  prev2.prev_type = "object";
461
489
  prev2.prev_type2 = ABConvert_IOEnum.el;
462
- prev2.process = "md";
490
+ prev2.prev_processor = "md";
463
491
  } else if (prev2.prev_type == "string" && prev2.prev_type2 == ABConvert_IOEnum.json) {
464
492
  const code_str = "```json\n" + prev2.prev_result + "\n```\n";
465
493
  const subEl = document.createElement("div");
@@ -468,7 +496,7 @@ class ABConvertManager {
468
496
  prev2.prev_result = el;
469
497
  prev2.prev_type = "object";
470
498
  prev2.prev_type2 = ABConvert_IOEnum.el;
471
- prev2.process = "show_json";
499
+ prev2.prev_processor = "show_json";
472
500
  } 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)) {
473
501
  const code_str = "```json\n" + JSON.stringify(prev2.prev_result, null, 2) + "\n```\n";
474
502
  const subEl = document.createElement("div");
@@ -477,7 +505,7 @@ class ABConvertManager {
477
505
  prev2.prev_result = el;
478
506
  prev2.prev_type = "object";
479
507
  prev2.prev_type2 = ABConvert_IOEnum.el;
480
- prev2.process = "show_listStream";
508
+ prev2.prev_processor = "show_listStream";
481
509
  } else if (prev2.prev_type == "object" && prev2.prev_type2 == ABConvert_IOEnum.el) {
482
510
  return prev2;
483
511
  } else {
@@ -921,7 +949,7 @@ class ListProcess {
921
949
  }
922
950
  }
923
951
  /**
924
- * 标题大纲转列表数据(@todo 正文的level+10,要减掉)
952
+ * 标题大纲转列表数据
925
953
  *
926
954
  * @detail
927
955
  * 这里要将标题、正文、列表 的等级合为一块,所以存在偏移值:
@@ -930,8 +958,13 @@ class ListProcess {
930
958
  * 2. 正文等级, = 0, 取值[+1,+Infi]
931
959
  * 3. 列表等级, = `(.*)-`个数+1, 取值[0]
932
960
  *
961
+ * (比较旧版是正文+10,列表+11,后来允许标题等级为负数。这样方便很多)
962
+ *
963
+ * @fine_mode 精细拆分模式
964
+ * - true: 会将正文和列表拆分成多个节点
965
+ * - false: 会将标题+正文+列表合并成一个节点
933
966
  */
934
- static title2data(text2) {
967
+ static title2data(text2, fine_mode = true) {
935
968
  let list_itemInfo = [];
936
969
  const list_text = text2.split("\n");
937
970
  let mul_mode = "";
@@ -941,12 +974,23 @@ class ListProcess {
941
974
  const match2 = line.match(ABReg.reg_code);
942
975
  if (match2 && match2[3]) {
943
976
  codeBlockFlag = match2[1] + match2[3];
944
- list_itemInfo[list_itemInfo.length - 1].content = list_itemInfo[list_itemInfo.length - 1].content + "\n" + line;
977
+ if (!fine_mode && list_itemInfo.length > 0) {
978
+ list_itemInfo[list_itemInfo.length - 1].content += "\n" + line;
979
+ } else if (mul_mode === "heading" || mul_mode === "") {
980
+ removeTailBlank();
981
+ list_itemInfo.push({
982
+ content: line,
983
+ level: 0
984
+ });
985
+ mul_mode = "para";
986
+ } else {
987
+ list_itemInfo[list_itemInfo.length - 1].content += "\n" + line;
988
+ }
945
989
  continue;
946
990
  }
947
991
  } else {
948
992
  if (line.indexOf(codeBlockFlag) == 0) codeBlockFlag = "";
949
- list_itemInfo[list_itemInfo.length - 1].content = list_itemInfo[list_itemInfo.length - 1].content + "\n" + line;
993
+ list_itemInfo[list_itemInfo.length - 1].content += "\n" + line;
950
994
  continue;
951
995
  }
952
996
  const match_heading = line.match(ABReg.reg_heading_noprefix);
@@ -954,32 +998,133 @@ class ListProcess {
954
998
  if (match_heading && !match_heading[1]) {
955
999
  removeTailBlank();
956
1000
  list_itemInfo.push({
957
- content: match_heading[4],
1001
+ content: fine_mode ? match_heading[4] : line,
1002
+ // 可选是否把标题标志也放进去
958
1003
  level: match_heading[3].length - 1 - 10
959
1004
  });
960
1005
  mul_mode = "heading";
1006
+ } else if (!fine_mode && list_itemInfo.length > 0) {
1007
+ list_itemInfo[list_itemInfo.length - 1].content += "\n" + line;
1008
+ continue;
961
1009
  } else if (match_list) {
962
1010
  removeTailBlank();
963
1011
  list_itemInfo.push({
964
1012
  content: match_list[4],
965
1013
  level: match_list[1].length + 1
966
- //+10
967
1014
  });
968
1015
  mul_mode = "list";
969
- } else if (/^\S/.test(line) && mul_mode == "list") {
970
- list_itemInfo[list_itemInfo.length - 1].content = list_itemInfo[list_itemInfo.length - 1].content + "\n" + line;
1016
+ } else if (mul_mode == "list" && /^\s/.test(line)) {
1017
+ list_itemInfo[list_itemInfo.length - 1].content += "\n" + line.trimStart();
1018
+ continue;
971
1019
  } else {
972
1020
  if (mul_mode == "para") {
973
- list_itemInfo[list_itemInfo.length - 1].content = list_itemInfo[list_itemInfo.length - 1].content + "\n" + line;
1021
+ list_itemInfo[list_itemInfo.length - 1].content += "\n" + line;
1022
+ continue;
974
1023
  } else if (/^\s*$/.test(line)) {
975
1024
  continue;
976
1025
  } else {
1026
+ removeTailBlank();
977
1027
  list_itemInfo.push({
978
1028
  content: line,
979
1029
  level: 0
980
- //+10
981
1030
  });
982
1031
  mul_mode = "para";
1032
+ continue;
1033
+ }
1034
+ }
1035
+ }
1036
+ removeTailBlank();
1037
+ return list_itemInfo;
1038
+ function removeTailBlank() {
1039
+ if (mul_mode == "para" || mul_mode == "list") {
1040
+ list_itemInfo[list_itemInfo.length - 1].content = list_itemInfo[list_itemInfo.length - 1].content.replace(/\s*$/, "");
1041
+ }
1042
+ }
1043
+ }
1044
+ /**
1045
+ * MarkdownIt 转列表数据
1046
+ *
1047
+ * @detail
1048
+ * 与 title2data 的逻辑基本相同
1049
+ *
1050
+ * 有很多写法变型和语法糖,所以逻辑比较复杂。
1051
+ * 具体设计详见 "docs/docs/dev docs/其他层级表示法.md"
1052
+ *
1053
+ * 支持:
1054
+ *
1055
+ * - 单行标题模式
1056
+ * - 多行标题模式
1057
+ * - 缺少分割标题模式
1058
+ *
1059
+ * @fine_mode 精细拆分模式
1060
+ * - true: 会将正文和列表拆分成多个节点
1061
+ * - false: 会将标题+正文+列表合并成一个节点
1062
+ */
1063
+ static mdit2data(text2, fine_mode = true) {
1064
+ let list_itemInfo = [];
1065
+ const list_text = text2.split("\n");
1066
+ let mul_mode = "";
1067
+ let codeBlockFlag = "";
1068
+ for (let line of list_text) {
1069
+ if (codeBlockFlag == "") {
1070
+ const match2 = line.match(ABReg.reg_code);
1071
+ if (match2 && match2[3]) {
1072
+ codeBlockFlag = match2[1] + match2[3];
1073
+ if (!fine_mode && list_itemInfo.length > 0) {
1074
+ list_itemInfo[list_itemInfo.length - 1].content += "\n" + line;
1075
+ } else if (mul_mode === "mdit" || mul_mode === "") {
1076
+ removeTailBlank();
1077
+ list_itemInfo.push({
1078
+ content: line,
1079
+ level: 0
1080
+ });
1081
+ mul_mode = "para";
1082
+ } else {
1083
+ list_itemInfo[list_itemInfo.length - 1].content += "\n" + line;
1084
+ }
1085
+ continue;
1086
+ }
1087
+ } else {
1088
+ if (line.indexOf(codeBlockFlag) == 0) codeBlockFlag = "";
1089
+ list_itemInfo[list_itemInfo.length - 1].content += "\n" + line;
1090
+ continue;
1091
+ }
1092
+ const match_mdit = line.match(/^(\s*)@(\d+)(?:\s+(.*))?$/);
1093
+ const match_list = line.match(ABReg.reg_list_noprefix);
1094
+ if (match_mdit && !match_mdit[1]) {
1095
+ removeTailBlank();
1096
+ list_itemInfo.push({
1097
+ content: match_mdit[3] ?? "",
1098
+ level: Number(match_mdit[2]) - 100
1099
+ });
1100
+ mul_mode = "mdit";
1101
+ } else if (!fine_mode && list_itemInfo.length > 0) {
1102
+ list_itemInfo[list_itemInfo.length - 1].content += "\n" + line;
1103
+ continue;
1104
+ } else if (match_list) {
1105
+ removeTailBlank();
1106
+ list_itemInfo.push({
1107
+ content: match_list[4],
1108
+ level: match_list[1].length + 1
1109
+ });
1110
+ mul_mode = "list";
1111
+ } else if (mul_mode == "list" && /^\s/.test(line)) {
1112
+ list_itemInfo[list_itemInfo.length - 1].content += "\n" + line.trimStart();
1113
+ continue;
1114
+ } else {
1115
+ if (mul_mode == "para") {
1116
+ list_itemInfo[list_itemInfo.length - 1].content += "\n" + line;
1117
+ continue;
1118
+ } else if (/^\s*$/.test(line)) {
1119
+ continue;
1120
+ } else {
1121
+ removeTailBlank();
1122
+ list_itemInfo.push({
1123
+ content: line,
1124
+ level: 0
1125
+ });
1126
+ mul_mode = "para";
1127
+ continue;
983
1128
  }
984
1129
  }
985
1130
  }
@@ -1198,7 +1343,7 @@ const abc_list2listdata = ABConvert.factory({
1198
1343
  process_param: ABConvert_IOEnum.text,
1199
1344
  process_return: ABConvert_IOEnum.list_stream,
1200
1345
  detail: "列表到listdata",
1201
- process: (el, header, content) => {
1346
+ process: (_el, _header, content) => {
1202
1347
  return ListProcess.list2data(content);
1203
1348
  }
1204
1349
  });
@@ -1207,9 +1352,39 @@ const abc_title2listdata = ABConvert.factory({
1207
1352
  name: "标题到listdata",
1208
1353
  process_param: ABConvert_IOEnum.text,
1209
1354
  process_return: ABConvert_IOEnum.list_stream,
1210
- detail: "标题到listdata",
1211
- process: (el, header, content) => {
1212
- return ListProcess.title2data(content);
1355
+ detail: "标题到listdata。细粒度版本,列表会拆分成多个节点",
1356
+ process: (_el, _header, content) => {
1357
+ return ListProcess.title2data(content, true);
1358
+ }
1359
+ });
1360
+ ABConvert.factory({
1361
+ id: "title2Listdata",
1362
+ name: "标题到Listdata",
1363
+ process_param: ABConvert_IOEnum.text,
1364
+ process_return: ABConvert_IOEnum.list_stream,
1365
+ detail: "标题到Listdata。粗粒度版本,列表为一个节点,不会拆分",
1366
+ process: (_el, _header, content) => {
1367
+ return ListProcess.title2data(content, false);
1368
+ }
1369
+ });
1370
+ ABConvert.factory({
1371
+ id: "mdit2listdata",
1372
+ name: "mdit到listdata",
1373
+ process_param: ABConvert_IOEnum.text,
1374
+ process_return: ABConvert_IOEnum.list_stream,
1375
+ detail: "mdit到listdata。细粒度版本,列表会拆分成多个节点",
1376
+ process: (_el, _header, content) => {
1377
+ return ListProcess.mdit2data(content, true);
1378
+ }
1379
+ });
1380
+ ABConvert.factory({
1381
+ id: "mdit2Listdata",
1382
+ name: "mdit到Listdata",
1383
+ process_param: ABConvert_IOEnum.text,
1384
+ process_return: ABConvert_IOEnum.list_stream,
1385
+ detail: "mdit到Listdata。粗粒度版本,列表为一个节点,不会拆分",
1386
+ process: (_el, _header, content) => {
1387
+ return ListProcess.mdit2data(content, false);
1213
1388
  }
1214
1389
  });
1215
1390
  ABConvert.factory({
@@ -1218,7 +1393,7 @@ ABConvert.factory({
1218
1393
  process_param: ABConvert_IOEnum.list_stream,
1219
1394
  process_return: ABConvert_IOEnum.text,
1220
1395
  detail: "listdata到列表",
1221
- process: (el, header, content) => {
1396
+ process: (_el, _header, content) => {
1222
1397
  return ListProcess.data2list(content);
1223
1398
  }
1224
1399
  });
@@ -1228,17 +1403,18 @@ ABConvert.factory({
1228
1403
  process_param: ABConvert_IOEnum.list_stream,
1229
1404
  process_return: ABConvert_IOEnum.el,
1230
1405
  detail: "listdata到节点图",
1231
- process: (el, header, content) => {
1406
+ process: (el, _header, content) => {
1232
1407
  return ListProcess.data2nodes(content, el);
1233
1408
  }
1234
1409
  });
1235
1410
  ABConvert.factory({
1236
1411
  id: "listdata2strict",
1237
1412
  name: "listdata严格化",
1413
+ match: /listdata2strict|listdata2lint/,
1238
1414
  process_param: ABConvert_IOEnum.list_stream,
1239
1415
  process_return: ABConvert_IOEnum.list_stream,
1240
1416
  detail: "将列表数据转化为更规范的列表数据。统一缩进符(2空格 4空格 tab混用)为level 1、禁止跳等级(h1直接就到h3)",
1241
- process: (el, header, content) => {
1417
+ process: (_el, _header, content) => {
1242
1418
  return ListProcess.data2strict(content);
1243
1419
  }
1244
1420
  });
@@ -1248,7 +1424,7 @@ ABConvert.factory({
1248
1424
  process_param: ABConvert_IOEnum.list_stream,
1249
1425
  process_return: ABConvert_IOEnum.list_stream,
1250
1426
  detail: "当列表中存在任务列表项时,令此列表项支持任务项",
1251
- process: (el, header, content) => {
1427
+ process: (_el, _header, content) => {
1252
1428
  return ListProcess.data2taskData(content);
1253
1429
  }
1254
1430
  });
@@ -1258,7 +1434,7 @@ ABConvert.factory({
1258
1434
  process_param: ABConvert_IOEnum.text,
1259
1435
  process_return: ABConvert_IOEnum.json,
1260
1436
  detail: "列表到listnode",
1261
- process: (el, header, content) => {
1437
+ process: (_el, _header, content) => {
1262
1438
  const data2 = ListProcess.list2listnode(content);
1263
1439
  return JSON.stringify(data2, null, 2);
1264
1440
  }
@@ -1269,7 +1445,7 @@ ABConvert.factory({
1269
1445
  process_param: ABConvert_IOEnum.text,
1270
1446
  process_return: ABConvert_IOEnum.json,
1271
1447
  detail: "列表到json",
1272
- process: (el, header, content) => {
1448
+ process: (_el, _header, content) => {
1273
1449
  const data2 = ListProcess.list2json(content);
1274
1450
  return JSON.stringify(data2, null, 2);
1275
1451
  }
@@ -1782,6 +1958,19 @@ ABConvert.factory({
1782
1958
  return el = TableProcess.data2table(data2, el, matchs[2] == "T");
1783
1959
  }
1784
1960
  });
1961
+ ABConvert.factory({
1962
+ id: "listdata2table",
1963
+ name: "列表数据转表格",
1964
+ match: /listdata2(md)?table(T)?/,
1965
+ default: "listdata2table",
1966
+ process_param: ABConvert_IOEnum.list_stream,
1967
+ process_return: ABConvert_IOEnum.el,
1968
+ process: (el, header, content) => {
1969
+ const matchs = header.match(/listdata2(md)?table(T)?/);
1970
+ if (!matchs) return el;
1971
+ return el = TableProcess.data2table(content, el, matchs[2] == "T");
1972
+ }
1973
+ });
1785
1974
  ABConvert.factory({
1786
1975
  id: "list2c2t",
1787
1976
  name: "列表转二列表格",
@@ -2207,6 +2396,1086 @@ ABConvert.factory({
2207
2396
  return newContent;
2208
2397
  }
2209
2398
  });
2399
+ /*! @license DOMPurify 3.4.3 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.3/LICENSE */
2400
+ function _arrayLikeToArray(r, a) {
2401
+ (null == a || a > r.length) && (a = r.length);
2402
+ for (var e = 0, n2 = Array(a); e < a; e++) n2[e] = r[e];
2403
+ return n2;
2404
+ }
2405
+ function _arrayWithHoles(r) {
2406
+ if (Array.isArray(r)) return r;
2407
+ }
2408
+ function _iterableToArrayLimit(r, l2) {
2409
+ var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
2410
+ if (null != t) {
2411
+ var e, n2, i, u, a = [], f = true, o = false;
2412
+ try {
2413
+ if (i = (t = t.call(r)).next, 0 === l2) ;
2414
+ else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l2); f = true) ;
2415
+ } catch (r2) {
2416
+ o = true, n2 = r2;
2417
+ } finally {
2418
+ try {
2419
+ if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
2420
+ } finally {
2421
+ if (o) throw n2;
2422
+ }
2423
+ }
2424
+ return a;
2425
+ }
2426
+ }
2427
+ function _nonIterableRest() {
2428
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
2429
+ }
2430
+ function _slicedToArray(r, e) {
2431
+ return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
2432
+ }
2433
+ function _unsupportedIterableToArray(r, a) {
2434
+ if (r) {
2435
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
2436
+ var t = {}.toString.call(r).slice(8, -1);
2437
+ 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;
2438
+ }
2439
+ }
2440
+ const entries = Object.entries, setPrototypeOf = Object.setPrototypeOf, isFrozen = Object.isFrozen, getPrototypeOf = Object.getPrototypeOf, getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
2441
+ let freeze = Object.freeze, seal = Object.seal, create = Object.create;
2442
+ let _ref = typeof Reflect !== "undefined" && Reflect, apply = _ref.apply, construct = _ref.construct;
2443
+ if (!freeze) {
2444
+ freeze = function freeze2(x) {
2445
+ return x;
2446
+ };
2447
+ }
2448
+ if (!seal) {
2449
+ seal = function seal2(x) {
2450
+ return x;
2451
+ };
2452
+ }
2453
+ if (!apply) {
2454
+ apply = function apply2(func, thisArg) {
2455
+ for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
2456
+ args[_key - 2] = arguments[_key];
2457
+ }
2458
+ return func.apply(thisArg, args);
2459
+ };
2460
+ }
2461
+ if (!construct) {
2462
+ construct = function construct2(Func) {
2463
+ for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
2464
+ args[_key2 - 1] = arguments[_key2];
2465
+ }
2466
+ return new Func(...args);
2467
+ };
2468
+ }
2469
+ const arrayForEach = unapply(Array.prototype.forEach);
2470
+ const arrayLastIndexOf = unapply(Array.prototype.lastIndexOf);
2471
+ const arrayPop = unapply(Array.prototype.pop);
2472
+ const arrayPush = unapply(Array.prototype.push);
2473
+ const arraySplice = unapply(Array.prototype.splice);
2474
+ const arrayIsArray = Array.isArray;
2475
+ const stringToLowerCase = unapply(String.prototype.toLowerCase);
2476
+ const stringToString = unapply(String.prototype.toString);
2477
+ const stringMatch = unapply(String.prototype.match);
2478
+ const stringReplace = unapply(String.prototype.replace);
2479
+ const stringIndexOf = unapply(String.prototype.indexOf);
2480
+ const stringTrim = unapply(String.prototype.trim);
2481
+ const numberToString = unapply(Number.prototype.toString);
2482
+ const booleanToString = unapply(Boolean.prototype.toString);
2483
+ const bigintToString = typeof BigInt === "undefined" ? null : unapply(BigInt.prototype.toString);
2484
+ const symbolToString = typeof Symbol === "undefined" ? null : unapply(Symbol.prototype.toString);
2485
+ const objectHasOwnProperty = unapply(Object.prototype.hasOwnProperty);
2486
+ const objectToString = unapply(Object.prototype.toString);
2487
+ const regExpTest = unapply(RegExp.prototype.test);
2488
+ const typeErrorCreate = unconstruct(TypeError);
2489
+ function unapply(func) {
2490
+ return function(thisArg) {
2491
+ if (thisArg instanceof RegExp) {
2492
+ thisArg.lastIndex = 0;
2493
+ }
2494
+ for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
2495
+ args[_key3 - 1] = arguments[_key3];
2496
+ }
2497
+ return apply(func, thisArg, args);
2498
+ };
2499
+ }
2500
+ function unconstruct(Func) {
2501
+ return function() {
2502
+ for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
2503
+ args[_key4] = arguments[_key4];
2504
+ }
2505
+ return construct(Func, args);
2506
+ };
2507
+ }
2508
+ function addToSet(set2, array) {
2509
+ let transformCaseFunc = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : stringToLowerCase;
2510
+ if (setPrototypeOf) {
2511
+ setPrototypeOf(set2, null);
2512
+ }
2513
+ if (!arrayIsArray(array)) {
2514
+ return set2;
2515
+ }
2516
+ let l2 = array.length;
2517
+ while (l2--) {
2518
+ let element = array[l2];
2519
+ if (typeof element === "string") {
2520
+ const lcElement = transformCaseFunc(element);
2521
+ if (lcElement !== element) {
2522
+ if (!isFrozen(array)) {
2523
+ array[l2] = lcElement;
2524
+ }
2525
+ element = lcElement;
2526
+ }
2527
+ }
2528
+ set2[element] = true;
2529
+ }
2530
+ return set2;
2531
+ }
2532
+ function cleanArray(array) {
2533
+ for (let index2 = 0; index2 < array.length; index2++) {
2534
+ const isPropertyExist = objectHasOwnProperty(array, index2);
2535
+ if (!isPropertyExist) {
2536
+ array[index2] = null;
2537
+ }
2538
+ }
2539
+ return array;
2540
+ }
2541
+ function clone$3(object) {
2542
+ const newObject = create(null);
2543
+ for (const _ref2 of entries(object)) {
2544
+ var _ref3 = _slicedToArray(_ref2, 2);
2545
+ const property = _ref3[0];
2546
+ const value = _ref3[1];
2547
+ const isPropertyExist = objectHasOwnProperty(object, property);
2548
+ if (isPropertyExist) {
2549
+ if (arrayIsArray(value)) {
2550
+ newObject[property] = cleanArray(value);
2551
+ } else if (value && typeof value === "object" && value.constructor === Object) {
2552
+ newObject[property] = clone$3(value);
2553
+ } else {
2554
+ newObject[property] = value;
2555
+ }
2556
+ }
2557
+ }
2558
+ return newObject;
2559
+ }
2560
+ function stringifyValue(value) {
2561
+ switch (typeof value) {
2562
+ case "string": {
2563
+ return value;
2564
+ }
2565
+ case "number": {
2566
+ return numberToString(value);
2567
+ }
2568
+ case "boolean": {
2569
+ return booleanToString(value);
2570
+ }
2571
+ case "bigint": {
2572
+ return bigintToString ? bigintToString(value) : "0";
2573
+ }
2574
+ case "symbol": {
2575
+ return symbolToString ? symbolToString(value) : "Symbol()";
2576
+ }
2577
+ case "undefined": {
2578
+ return objectToString(value);
2579
+ }
2580
+ case "function":
2581
+ case "object": {
2582
+ if (value === null) {
2583
+ return objectToString(value);
2584
+ }
2585
+ const valueAsRecord = value;
2586
+ const valueToString = lookupGetter(valueAsRecord, "toString");
2587
+ if (typeof valueToString === "function") {
2588
+ const stringified = valueToString(valueAsRecord);
2589
+ return typeof stringified === "string" ? stringified : objectToString(stringified);
2590
+ }
2591
+ return objectToString(value);
2592
+ }
2593
+ default: {
2594
+ return objectToString(value);
2595
+ }
2596
+ }
2597
+ }
2598
+ function lookupGetter(object, prop2) {
2599
+ while (object !== null) {
2600
+ const desc = getOwnPropertyDescriptor(object, prop2);
2601
+ if (desc) {
2602
+ if (desc.get) {
2603
+ return unapply(desc.get);
2604
+ }
2605
+ if (typeof desc.value === "function") {
2606
+ return unapply(desc.value);
2607
+ }
2608
+ }
2609
+ object = getPrototypeOf(object);
2610
+ }
2611
+ function fallbackValue() {
2612
+ return null;
2613
+ }
2614
+ return fallbackValue;
2615
+ }
2616
+ function isRegex(value) {
2617
+ try {
2618
+ regExpTest(value, "");
2619
+ return true;
2620
+ } catch (_unused) {
2621
+ return false;
2622
+ }
2623
+ }
2624
+ 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"]);
2625
+ 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"]);
2626
+ 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"]);
2627
+ 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"]);
2628
+ 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"]);
2629
+ const mathMlDisallowed = freeze(["maction", "maligngroup", "malignmark", "mlongdiv", "mscarries", "mscarry", "msgroup", "mstack", "msline", "msrow", "semantics", "annotation", "annotation-xml", "mprescripts", "none"]);
2630
+ const text$2 = freeze(["#text"]);
2631
+ 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"]);
2632
+ 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"]);
2633
+ 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"]);
2634
+ const xml$1 = freeze(["xlink:href", "xml:id", "xlink:title", "xml:space", "xmlns:xlink"]);
2635
+ const MUSTACHE_EXPR = seal(/{{[\w\W]*|^[\w\W]*}}/g);
2636
+ const ERB_EXPR = seal(/<%[\w\W]*|^[\w\W]*%>/g);
2637
+ const TMPLIT_EXPR = seal(/\${[\w\W]*/g);
2638
+ const DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]+$/);
2639
+ const ARIA_ATTR = seal(/^aria-[\-\w]+$/);
2640
+ const IS_ALLOWED_URI = seal(
2641
+ /^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i
2642
+ // eslint-disable-line no-useless-escape
2643
+ );
2644
+ const IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i);
2645
+ const ATTR_WHITESPACE = seal(
2646
+ /[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g
2647
+ // eslint-disable-line no-control-regex
2648
+ );
2649
+ const DOCTYPE_NAME = seal(/^html$/i);
2650
+ const CUSTOM_ELEMENT = seal(/^[a-z][.\w]*(-[.\w]+)+$/i);
2651
+ const NODE_TYPE$1 = {
2652
+ element: 1,
2653
+ text: 3,
2654
+ // Deprecated
2655
+ progressingInstruction: 7,
2656
+ comment: 8,
2657
+ document: 9
2658
+ };
2659
+ const getGlobal = function getGlobal2() {
2660
+ return typeof window === "undefined" ? null : window;
2661
+ };
2662
+ const _createTrustedTypesPolicy = function _createTrustedTypesPolicy2(trustedTypes, purifyHostElement) {
2663
+ if (typeof trustedTypes !== "object" || typeof trustedTypes.createPolicy !== "function") {
2664
+ return null;
2665
+ }
2666
+ let suffix = null;
2667
+ const ATTR_NAME = "data-tt-policy-suffix";
2668
+ if (purifyHostElement && purifyHostElement.hasAttribute(ATTR_NAME)) {
2669
+ suffix = purifyHostElement.getAttribute(ATTR_NAME);
2670
+ }
2671
+ const policyName = "dompurify" + (suffix ? "#" + suffix : "");
2672
+ try {
2673
+ return trustedTypes.createPolicy(policyName, {
2674
+ createHTML(html2) {
2675
+ return html2;
2676
+ },
2677
+ createScriptURL(scriptUrl) {
2678
+ return scriptUrl;
2679
+ }
2680
+ });
2681
+ } catch (_) {
2682
+ console.warn("TrustedTypes policy " + policyName + " could not be created.");
2683
+ return null;
2684
+ }
2685
+ };
2686
+ const _createHooksMap = function _createHooksMap2() {
2687
+ return {
2688
+ afterSanitizeAttributes: [],
2689
+ afterSanitizeElements: [],
2690
+ afterSanitizeShadowDOM: [],
2691
+ beforeSanitizeAttributes: [],
2692
+ beforeSanitizeElements: [],
2693
+ beforeSanitizeShadowDOM: [],
2694
+ uponSanitizeAttribute: [],
2695
+ uponSanitizeElement: [],
2696
+ uponSanitizeShadowNode: []
2697
+ };
2698
+ };
2699
+ function createDOMPurify() {
2700
+ let window2 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : getGlobal();
2701
+ const DOMPurify = (root2) => createDOMPurify(root2);
2702
+ DOMPurify.version = "3.4.3";
2703
+ DOMPurify.removed = [];
2704
+ if (!window2 || !window2.document || window2.document.nodeType !== NODE_TYPE$1.document || !window2.Element) {
2705
+ DOMPurify.isSupported = false;
2706
+ return DOMPurify;
2707
+ }
2708
+ let document2 = window2.document;
2709
+ const originalDocument = document2;
2710
+ const currentScript = originalDocument.currentScript;
2711
+ 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;
2712
+ const ElementPrototype = Element2.prototype;
2713
+ const cloneNode2 = lookupGetter(ElementPrototype, "cloneNode");
2714
+ const remove2 = lookupGetter(ElementPrototype, "remove");
2715
+ const getNextSibling = lookupGetter(ElementPrototype, "nextSibling");
2716
+ const getChildNodes = lookupGetter(ElementPrototype, "childNodes");
2717
+ const getParentNode = lookupGetter(ElementPrototype, "parentNode");
2718
+ if (typeof HTMLTemplateElement === "function") {
2719
+ const template = document2.createElement("template");
2720
+ if (template.content && template.content.ownerDocument) {
2721
+ document2 = template.content.ownerDocument;
2722
+ }
2723
+ }
2724
+ let trustedTypesPolicy;
2725
+ let emptyHTML = "";
2726
+ const _document = document2, implementation = _document.implementation, createNodeIterator = _document.createNodeIterator, createDocumentFragment = _document.createDocumentFragment, getElementsByTagName2 = _document.getElementsByTagName;
2727
+ const importNode = originalDocument.importNode;
2728
+ let hooks = _createHooksMap();
2729
+ DOMPurify.isSupported = typeof entries === "function" && typeof getParentNode === "function" && implementation && implementation.createHTMLDocument !== void 0;
2730
+ 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;
2731
+ let IS_ALLOWED_URI$1 = IS_ALLOWED_URI;
2732
+ let ALLOWED_TAGS = null;
2733
+ const DEFAULT_ALLOWED_TAGS = addToSet({}, [...html$1$1, ...svg$1, ...svgFilters, ...mathMl$1, ...text$2]);
2734
+ let ALLOWED_ATTR = null;
2735
+ const DEFAULT_ALLOWED_ATTR = addToSet({}, [...html$2, ...svg, ...mathMl, ...xml$1]);
2736
+ let CUSTOM_ELEMENT_HANDLING = Object.seal(create(null, {
2737
+ tagNameCheck: {
2738
+ writable: true,
2739
+ configurable: false,
2740
+ enumerable: true,
2741
+ value: null
2742
+ },
2743
+ attributeNameCheck: {
2744
+ writable: true,
2745
+ configurable: false,
2746
+ enumerable: true,
2747
+ value: null
2748
+ },
2749
+ allowCustomizedBuiltInElements: {
2750
+ writable: true,
2751
+ configurable: false,
2752
+ enumerable: true,
2753
+ value: false
2754
+ }
2755
+ }));
2756
+ let FORBID_TAGS = null;
2757
+ let FORBID_ATTR = null;
2758
+ const EXTRA_ELEMENT_HANDLING = Object.seal(create(null, {
2759
+ tagCheck: {
2760
+ writable: true,
2761
+ configurable: false,
2762
+ enumerable: true,
2763
+ value: null
2764
+ },
2765
+ attributeCheck: {
2766
+ writable: true,
2767
+ configurable: false,
2768
+ enumerable: true,
2769
+ value: null
2770
+ }
2771
+ }));
2772
+ let ALLOW_ARIA_ATTR = true;
2773
+ let ALLOW_DATA_ATTR = true;
2774
+ let ALLOW_UNKNOWN_PROTOCOLS = false;
2775
+ let ALLOW_SELF_CLOSE_IN_ATTR = true;
2776
+ let SAFE_FOR_TEMPLATES = false;
2777
+ let SAFE_FOR_XML = true;
2778
+ let WHOLE_DOCUMENT = false;
2779
+ let SET_CONFIG = false;
2780
+ let FORCE_BODY = false;
2781
+ let RETURN_DOM = false;
2782
+ let RETURN_DOM_FRAGMENT = false;
2783
+ let RETURN_TRUSTED_TYPE = false;
2784
+ let SANITIZE_DOM = true;
2785
+ let SANITIZE_NAMED_PROPS = false;
2786
+ const SANITIZE_NAMED_PROPS_PREFIX = "user-content-";
2787
+ let KEEP_CONTENT = true;
2788
+ let IN_PLACE = false;
2789
+ let USE_PROFILES = {};
2790
+ let FORBID_CONTENTS = null;
2791
+ 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"]);
2792
+ let DATA_URI_TAGS = null;
2793
+ const DEFAULT_DATA_URI_TAGS = addToSet({}, ["audio", "video", "img", "source", "image", "track"]);
2794
+ let URI_SAFE_ATTRIBUTES = null;
2795
+ const DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ["alt", "class", "for", "id", "label", "name", "pattern", "placeholder", "role", "summary", "title", "value", "style", "xmlns"]);
2796
+ const MATHML_NAMESPACE = "http://www.w3.org/1998/Math/MathML";
2797
+ const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
2798
+ const HTML_NAMESPACE = "http://www.w3.org/1999/xhtml";
2799
+ let NAMESPACE = HTML_NAMESPACE;
2800
+ let IS_EMPTY_INPUT = false;
2801
+ let ALLOWED_NAMESPACES = null;
2802
+ const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [MATHML_NAMESPACE, SVG_NAMESPACE, HTML_NAMESPACE], stringToString);
2803
+ let MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ["mi", "mo", "mn", "ms", "mtext"]);
2804
+ let HTML_INTEGRATION_POINTS = addToSet({}, ["annotation-xml"]);
2805
+ const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, ["title", "style", "font", "a", "script"]);
2806
+ let PARSER_MEDIA_TYPE = null;
2807
+ const SUPPORTED_PARSER_MEDIA_TYPES = ["application/xhtml+xml", "text/html"];
2808
+ const DEFAULT_PARSER_MEDIA_TYPE = "text/html";
2809
+ let transformCaseFunc = null;
2810
+ let CONFIG = null;
2811
+ const formElement = document2.createElement("form");
2812
+ const isRegexOrFunction = function isRegexOrFunction2(testValue) {
2813
+ return testValue instanceof RegExp || testValue instanceof Function;
2814
+ };
2815
+ const _parseConfig = function _parseConfig2() {
2816
+ let cfg = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
2817
+ if (CONFIG && CONFIG === cfg) {
2818
+ return;
2819
+ }
2820
+ if (!cfg || typeof cfg !== "object") {
2821
+ cfg = {};
2822
+ }
2823
+ cfg = clone$3(cfg);
2824
+ PARSER_MEDIA_TYPE = // eslint-disable-next-line unicorn/prefer-includes
2825
+ SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? DEFAULT_PARSER_MEDIA_TYPE : cfg.PARSER_MEDIA_TYPE;
2826
+ transformCaseFunc = PARSER_MEDIA_TYPE === "application/xhtml+xml" ? stringToString : stringToLowerCase;
2827
+ ALLOWED_TAGS = objectHasOwnProperty(cfg, "ALLOWED_TAGS") && arrayIsArray(cfg.ALLOWED_TAGS) ? addToSet({}, cfg.ALLOWED_TAGS, transformCaseFunc) : DEFAULT_ALLOWED_TAGS;
2828
+ ALLOWED_ATTR = objectHasOwnProperty(cfg, "ALLOWED_ATTR") && arrayIsArray(cfg.ALLOWED_ATTR) ? addToSet({}, cfg.ALLOWED_ATTR, transformCaseFunc) : DEFAULT_ALLOWED_ATTR;
2829
+ ALLOWED_NAMESPACES = objectHasOwnProperty(cfg, "ALLOWED_NAMESPACES") && arrayIsArray(cfg.ALLOWED_NAMESPACES) ? addToSet({}, cfg.ALLOWED_NAMESPACES, stringToString) : DEFAULT_ALLOWED_NAMESPACES;
2830
+ 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;
2831
+ 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;
2832
+ FORBID_CONTENTS = objectHasOwnProperty(cfg, "FORBID_CONTENTS") && arrayIsArray(cfg.FORBID_CONTENTS) ? addToSet({}, cfg.FORBID_CONTENTS, transformCaseFunc) : DEFAULT_FORBID_CONTENTS;
2833
+ FORBID_TAGS = objectHasOwnProperty(cfg, "FORBID_TAGS") && arrayIsArray(cfg.FORBID_TAGS) ? addToSet({}, cfg.FORBID_TAGS, transformCaseFunc) : clone$3({});
2834
+ FORBID_ATTR = objectHasOwnProperty(cfg, "FORBID_ATTR") && arrayIsArray(cfg.FORBID_ATTR) ? addToSet({}, cfg.FORBID_ATTR, transformCaseFunc) : clone$3({});
2835
+ USE_PROFILES = objectHasOwnProperty(cfg, "USE_PROFILES") ? cfg.USE_PROFILES && typeof cfg.USE_PROFILES === "object" ? clone$3(cfg.USE_PROFILES) : cfg.USE_PROFILES : false;
2836
+ ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false;
2837
+ ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false;
2838
+ ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false;
2839
+ ALLOW_SELF_CLOSE_IN_ATTR = cfg.ALLOW_SELF_CLOSE_IN_ATTR !== false;
2840
+ SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false;
2841
+ SAFE_FOR_XML = cfg.SAFE_FOR_XML !== false;
2842
+ WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false;
2843
+ RETURN_DOM = cfg.RETURN_DOM || false;
2844
+ RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false;
2845
+ RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false;
2846
+ FORCE_BODY = cfg.FORCE_BODY || false;
2847
+ SANITIZE_DOM = cfg.SANITIZE_DOM !== false;
2848
+ SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false;
2849
+ KEEP_CONTENT = cfg.KEEP_CONTENT !== false;
2850
+ IN_PLACE = cfg.IN_PLACE || false;
2851
+ IS_ALLOWED_URI$1 = isRegex(cfg.ALLOWED_URI_REGEXP) ? cfg.ALLOWED_URI_REGEXP : IS_ALLOWED_URI;
2852
+ NAMESPACE = typeof cfg.NAMESPACE === "string" ? cfg.NAMESPACE : HTML_NAMESPACE;
2853
+ 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"]);
2854
+ 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"]);
2855
+ 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);
2856
+ CUSTOM_ELEMENT_HANDLING = create(null);
2857
+ if (objectHasOwnProperty(customElementHandling, "tagNameCheck") && isRegexOrFunction(customElementHandling.tagNameCheck)) {
2858
+ CUSTOM_ELEMENT_HANDLING.tagNameCheck = customElementHandling.tagNameCheck;
2859
+ }
2860
+ if (objectHasOwnProperty(customElementHandling, "attributeNameCheck") && isRegexOrFunction(customElementHandling.attributeNameCheck)) {
2861
+ CUSTOM_ELEMENT_HANDLING.attributeNameCheck = customElementHandling.attributeNameCheck;
2862
+ }
2863
+ if (objectHasOwnProperty(customElementHandling, "allowCustomizedBuiltInElements") && typeof customElementHandling.allowCustomizedBuiltInElements === "boolean") {
2864
+ CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = customElementHandling.allowCustomizedBuiltInElements;
2865
+ }
2866
+ if (SAFE_FOR_TEMPLATES) {
2867
+ ALLOW_DATA_ATTR = false;
2868
+ }
2869
+ if (RETURN_DOM_FRAGMENT) {
2870
+ RETURN_DOM = true;
2871
+ }
2872
+ if (USE_PROFILES) {
2873
+ ALLOWED_TAGS = addToSet({}, text$2);
2874
+ ALLOWED_ATTR = create(null);
2875
+ if (USE_PROFILES.html === true) {
2876
+ addToSet(ALLOWED_TAGS, html$1$1);
2877
+ addToSet(ALLOWED_ATTR, html$2);
2878
+ }
2879
+ if (USE_PROFILES.svg === true) {
2880
+ addToSet(ALLOWED_TAGS, svg$1);
2881
+ addToSet(ALLOWED_ATTR, svg);
2882
+ addToSet(ALLOWED_ATTR, xml$1);
2883
+ }
2884
+ if (USE_PROFILES.svgFilters === true) {
2885
+ addToSet(ALLOWED_TAGS, svgFilters);
2886
+ addToSet(ALLOWED_ATTR, svg);
2887
+ addToSet(ALLOWED_ATTR, xml$1);
2888
+ }
2889
+ if (USE_PROFILES.mathMl === true) {
2890
+ addToSet(ALLOWED_TAGS, mathMl$1);
2891
+ addToSet(ALLOWED_ATTR, mathMl);
2892
+ addToSet(ALLOWED_ATTR, xml$1);
2893
+ }
2894
+ }
2895
+ EXTRA_ELEMENT_HANDLING.tagCheck = null;
2896
+ EXTRA_ELEMENT_HANDLING.attributeCheck = null;
2897
+ if (objectHasOwnProperty(cfg, "ADD_TAGS")) {
2898
+ if (typeof cfg.ADD_TAGS === "function") {
2899
+ EXTRA_ELEMENT_HANDLING.tagCheck = cfg.ADD_TAGS;
2900
+ } else if (arrayIsArray(cfg.ADD_TAGS)) {
2901
+ if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {
2902
+ ALLOWED_TAGS = clone$3(ALLOWED_TAGS);
2903
+ }
2904
+ addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc);
2905
+ }
2906
+ }
2907
+ if (objectHasOwnProperty(cfg, "ADD_ATTR")) {
2908
+ if (typeof cfg.ADD_ATTR === "function") {
2909
+ EXTRA_ELEMENT_HANDLING.attributeCheck = cfg.ADD_ATTR;
2910
+ } else if (arrayIsArray(cfg.ADD_ATTR)) {
2911
+ if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) {
2912
+ ALLOWED_ATTR = clone$3(ALLOWED_ATTR);
2913
+ }
2914
+ addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc);
2915
+ }
2916
+ }
2917
+ if (objectHasOwnProperty(cfg, "ADD_URI_SAFE_ATTR") && arrayIsArray(cfg.ADD_URI_SAFE_ATTR)) {
2918
+ addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR, transformCaseFunc);
2919
+ }
2920
+ if (objectHasOwnProperty(cfg, "FORBID_CONTENTS") && arrayIsArray(cfg.FORBID_CONTENTS)) {
2921
+ if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
2922
+ FORBID_CONTENTS = clone$3(FORBID_CONTENTS);
2923
+ }
2924
+ addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS, transformCaseFunc);
2925
+ }
2926
+ if (objectHasOwnProperty(cfg, "ADD_FORBID_CONTENTS") && arrayIsArray(cfg.ADD_FORBID_CONTENTS)) {
2927
+ if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
2928
+ FORBID_CONTENTS = clone$3(FORBID_CONTENTS);
2929
+ }
2930
+ addToSet(FORBID_CONTENTS, cfg.ADD_FORBID_CONTENTS, transformCaseFunc);
2931
+ }
2932
+ if (KEEP_CONTENT) {
2933
+ ALLOWED_TAGS["#text"] = true;
2934
+ }
2935
+ if (WHOLE_DOCUMENT) {
2936
+ addToSet(ALLOWED_TAGS, ["html", "head", "body"]);
2937
+ }
2938
+ if (ALLOWED_TAGS.table) {
2939
+ addToSet(ALLOWED_TAGS, ["tbody"]);
2940
+ delete FORBID_TAGS.tbody;
2941
+ }
2942
+ if (cfg.TRUSTED_TYPES_POLICY) {
2943
+ if (typeof cfg.TRUSTED_TYPES_POLICY.createHTML !== "function") {
2944
+ throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');
2945
+ }
2946
+ if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== "function") {
2947
+ throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
2948
+ }
2949
+ trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY;
2950
+ emptyHTML = trustedTypesPolicy.createHTML("");
2951
+ } else {
2952
+ if (trustedTypesPolicy === void 0) {
2953
+ trustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript);
2954
+ }
2955
+ if (trustedTypesPolicy !== null && typeof emptyHTML === "string") {
2956
+ emptyHTML = trustedTypesPolicy.createHTML("");
2957
+ }
2958
+ }
2959
+ if (freeze) {
2960
+ freeze(cfg);
2961
+ }
2962
+ CONFIG = cfg;
2963
+ };
2964
+ const ALL_SVG_TAGS = addToSet({}, [...svg$1, ...svgFilters, ...svgDisallowed]);
2965
+ const ALL_MATHML_TAGS = addToSet({}, [...mathMl$1, ...mathMlDisallowed]);
2966
+ const _checkValidNamespace = function _checkValidNamespace2(element) {
2967
+ let parent2 = getParentNode(element);
2968
+ if (!parent2 || !parent2.tagName) {
2969
+ parent2 = {
2970
+ namespaceURI: NAMESPACE,
2971
+ tagName: "template"
2972
+ };
2973
+ }
2974
+ const tagName = stringToLowerCase(element.tagName);
2975
+ const parentTagName = stringToLowerCase(parent2.tagName);
2976
+ if (!ALLOWED_NAMESPACES[element.namespaceURI]) {
2977
+ return false;
2978
+ }
2979
+ if (element.namespaceURI === SVG_NAMESPACE) {
2980
+ if (parent2.namespaceURI === HTML_NAMESPACE) {
2981
+ return tagName === "svg";
2982
+ }
2983
+ if (parent2.namespaceURI === MATHML_NAMESPACE) {
2984
+ return tagName === "svg" && (parentTagName === "annotation-xml" || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
2985
+ }
2986
+ return Boolean(ALL_SVG_TAGS[tagName]);
2987
+ }
2988
+ if (element.namespaceURI === MATHML_NAMESPACE) {
2989
+ if (parent2.namespaceURI === HTML_NAMESPACE) {
2990
+ return tagName === "math";
2991
+ }
2992
+ if (parent2.namespaceURI === SVG_NAMESPACE) {
2993
+ return tagName === "math" && HTML_INTEGRATION_POINTS[parentTagName];
2994
+ }
2995
+ return Boolean(ALL_MATHML_TAGS[tagName]);
2996
+ }
2997
+ if (element.namespaceURI === HTML_NAMESPACE) {
2998
+ if (parent2.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) {
2999
+ return false;
3000
+ }
3001
+ if (parent2.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {
3002
+ return false;
3003
+ }
3004
+ return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);
3005
+ }
3006
+ if (PARSER_MEDIA_TYPE === "application/xhtml+xml" && ALLOWED_NAMESPACES[element.namespaceURI]) {
3007
+ return true;
3008
+ }
3009
+ return false;
3010
+ };
3011
+ const _forceRemove = function _forceRemove2(node) {
3012
+ arrayPush(DOMPurify.removed, {
3013
+ element: node
3014
+ });
3015
+ try {
3016
+ getParentNode(node).removeChild(node);
3017
+ } catch (_) {
3018
+ remove2(node);
3019
+ }
3020
+ };
3021
+ const _removeAttribute = function _removeAttribute2(name2, element) {
3022
+ try {
3023
+ arrayPush(DOMPurify.removed, {
3024
+ attribute: element.getAttributeNode(name2),
3025
+ from: element
3026
+ });
3027
+ } catch (_) {
3028
+ arrayPush(DOMPurify.removed, {
3029
+ attribute: null,
3030
+ from: element
3031
+ });
3032
+ }
3033
+ element.removeAttribute(name2);
3034
+ if (name2 === "is") {
3035
+ if (RETURN_DOM || RETURN_DOM_FRAGMENT) {
3036
+ try {
3037
+ _forceRemove(element);
3038
+ } catch (_) {
3039
+ }
3040
+ } else {
3041
+ try {
3042
+ element.setAttribute(name2, "");
3043
+ } catch (_) {
3044
+ }
3045
+ }
3046
+ }
3047
+ };
3048
+ const _initDocument = function _initDocument2(dirty) {
3049
+ let doc = null;
3050
+ let leadingWhitespace = null;
3051
+ if (FORCE_BODY) {
3052
+ dirty = "<remove></remove>" + dirty;
3053
+ } else {
3054
+ const matches = stringMatch(dirty, /^[\r\n\t ]+/);
3055
+ leadingWhitespace = matches && matches[0];
3056
+ }
3057
+ if (PARSER_MEDIA_TYPE === "application/xhtml+xml" && NAMESPACE === HTML_NAMESPACE) {
3058
+ dirty = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + dirty + "</body></html>";
3059
+ }
3060
+ const dirtyPayload = trustedTypesPolicy ? trustedTypesPolicy.createHTML(dirty) : dirty;
3061
+ if (NAMESPACE === HTML_NAMESPACE) {
3062
+ try {
3063
+ doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE);
3064
+ } catch (_) {
3065
+ }
3066
+ }
3067
+ if (!doc || !doc.documentElement) {
3068
+ doc = implementation.createDocument(NAMESPACE, "template", null);
3069
+ try {
3070
+ doc.documentElement.innerHTML = IS_EMPTY_INPUT ? emptyHTML : dirtyPayload;
3071
+ } catch (_) {
3072
+ }
3073
+ }
3074
+ const body = doc.body || doc.documentElement;
3075
+ if (dirty && leadingWhitespace) {
3076
+ body.insertBefore(document2.createTextNode(leadingWhitespace), body.childNodes[0] || null);
3077
+ }
3078
+ if (NAMESPACE === HTML_NAMESPACE) {
3079
+ return getElementsByTagName2.call(doc, WHOLE_DOCUMENT ? "html" : "body")[0];
3080
+ }
3081
+ return WHOLE_DOCUMENT ? doc.documentElement : body;
3082
+ };
3083
+ const _createNodeIterator = function _createNodeIterator2(root2) {
3084
+ return createNodeIterator.call(
3085
+ root2.ownerDocument || root2,
3086
+ root2,
3087
+ // eslint-disable-next-line no-bitwise
3088
+ NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT | NodeFilter.SHOW_PROCESSING_INSTRUCTION | NodeFilter.SHOW_CDATA_SECTION,
3089
+ null
3090
+ );
3091
+ };
3092
+ const _isClobbered = function _isClobbered2(element) {
3093
+ 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");
3094
+ };
3095
+ const _isNode = function _isNode2(value) {
3096
+ return typeof Node3 === "function" && value instanceof Node3;
3097
+ };
3098
+ function _executeHooks(hooks2, currentNode, data2) {
3099
+ arrayForEach(hooks2, (hook) => {
3100
+ hook.call(DOMPurify, currentNode, data2, CONFIG);
3101
+ });
3102
+ }
3103
+ const _sanitizeElements = function _sanitizeElements2(currentNode) {
3104
+ let content = null;
3105
+ _executeHooks(hooks.beforeSanitizeElements, currentNode, null);
3106
+ if (_isClobbered(currentNode)) {
3107
+ _forceRemove(currentNode);
3108
+ return true;
3109
+ }
3110
+ const tagName = transformCaseFunc(currentNode.nodeName);
3111
+ _executeHooks(hooks.uponSanitizeElement, currentNode, {
3112
+ tagName,
3113
+ allowedTags: ALLOWED_TAGS
3114
+ });
3115
+ if (SAFE_FOR_XML && currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && regExpTest(/<[/\w!]/g, currentNode.innerHTML) && regExpTest(/<[/\w!]/g, currentNode.textContent)) {
3116
+ _forceRemove(currentNode);
3117
+ return true;
3118
+ }
3119
+ if (SAFE_FOR_XML && currentNode.namespaceURI === HTML_NAMESPACE && tagName === "style" && _isNode(currentNode.firstElementChild)) {
3120
+ _forceRemove(currentNode);
3121
+ return true;
3122
+ }
3123
+ if (currentNode.nodeType === NODE_TYPE$1.progressingInstruction) {
3124
+ _forceRemove(currentNode);
3125
+ return true;
3126
+ }
3127
+ if (SAFE_FOR_XML && currentNode.nodeType === NODE_TYPE$1.comment && regExpTest(/<[/\w]/g, currentNode.data)) {
3128
+ _forceRemove(currentNode);
3129
+ return true;
3130
+ }
3131
+ if (FORBID_TAGS[tagName] || !(EXTRA_ELEMENT_HANDLING.tagCheck instanceof Function && EXTRA_ELEMENT_HANDLING.tagCheck(tagName)) && !ALLOWED_TAGS[tagName]) {
3132
+ if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName)) {
3133
+ if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) {
3134
+ return false;
3135
+ }
3136
+ if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName)) {
3137
+ return false;
3138
+ }
3139
+ }
3140
+ if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {
3141
+ const parentNode = getParentNode(currentNode) || currentNode.parentNode;
3142
+ const childNodes = getChildNodes(currentNode) || currentNode.childNodes;
3143
+ if (childNodes && parentNode) {
3144
+ const childCount = childNodes.length;
3145
+ for (let i = childCount - 1; i >= 0; --i) {
3146
+ const childClone = cloneNode2(childNodes[i], true);
3147
+ parentNode.insertBefore(childClone, getNextSibling(currentNode));
3148
+ }
3149
+ }
3150
+ }
3151
+ _forceRemove(currentNode);
3152
+ return true;
3153
+ }
3154
+ if (currentNode instanceof Element2 && !_checkValidNamespace(currentNode)) {
3155
+ _forceRemove(currentNode);
3156
+ return true;
3157
+ }
3158
+ if ((tagName === "noscript" || tagName === "noembed" || tagName === "noframes") && regExpTest(/<\/no(script|embed|frames)/i, currentNode.innerHTML)) {
3159
+ _forceRemove(currentNode);
3160
+ return true;
3161
+ }
3162
+ if (SAFE_FOR_TEMPLATES && currentNode.nodeType === NODE_TYPE$1.text) {
3163
+ content = currentNode.textContent;
3164
+ arrayForEach([MUSTACHE_EXPR$1, ERB_EXPR$1, TMPLIT_EXPR$1], (expr) => {
3165
+ content = stringReplace(content, expr, " ");
3166
+ });
3167
+ if (currentNode.textContent !== content) {
3168
+ arrayPush(DOMPurify.removed, {
3169
+ element: currentNode.cloneNode()
3170
+ });
3171
+ currentNode.textContent = content;
3172
+ }
3173
+ }
3174
+ _executeHooks(hooks.afterSanitizeElements, currentNode, null);
3175
+ return false;
3176
+ };
3177
+ const _isValidAttribute = function _isValidAttribute2(lcTag, lcName, value) {
3178
+ if (FORBID_ATTR[lcName]) {
3179
+ return false;
3180
+ }
3181
+ if (SANITIZE_DOM && (lcName === "id" || lcName === "name") && (value in document2 || value in formElement)) {
3182
+ return false;
3183
+ }
3184
+ const nameIsPermitted = ALLOWED_ATTR[lcName] || EXTRA_ELEMENT_HANDLING.attributeCheck instanceof Function && EXTRA_ELEMENT_HANDLING.attributeCheck(lcName, lcTag);
3185
+ if (ALLOW_DATA_ATTR && !FORBID_ATTR[lcName] && regExpTest(DATA_ATTR$1, lcName)) ;
3186
+ else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR$1, lcName)) ;
3187
+ else if (!nameIsPermitted || FORBID_ATTR[lcName]) {
3188
+ if (
3189
+ // First condition does a very basic check if a) it's basically a valid custom element tagname AND
3190
+ // b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
3191
+ // and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck
3192
+ _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
3193
+ // the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
3194
+ 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))
3195
+ ) ;
3196
+ else {
3197
+ return false;
3198
+ }
3199
+ } else if (URI_SAFE_ATTRIBUTES[lcName]) ;
3200
+ else if (regExpTest(IS_ALLOWED_URI$1, stringReplace(value, ATTR_WHITESPACE$1, ""))) ;
3201
+ else if ((lcName === "src" || lcName === "xlink:href" || lcName === "href") && lcTag !== "script" && stringIndexOf(value, "data:") === 0 && DATA_URI_TAGS[lcTag]) ;
3202
+ else if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA$1, stringReplace(value, ATTR_WHITESPACE$1, ""))) ;
3203
+ else if (value) {
3204
+ return false;
3205
+ } else ;
3206
+ return true;
3207
+ };
3208
+ 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"]);
3209
+ const _isBasicCustomElement = function _isBasicCustomElement2(tagName) {
3210
+ return !RESERVED_CUSTOM_ELEMENT_NAMES[stringToLowerCase(tagName)] && regExpTest(CUSTOM_ELEMENT$1, tagName);
3211
+ };
3212
+ const _sanitizeAttributes = function _sanitizeAttributes2(currentNode) {
3213
+ _executeHooks(hooks.beforeSanitizeAttributes, currentNode, null);
3214
+ const attributes2 = currentNode.attributes;
3215
+ if (!attributes2 || _isClobbered(currentNode)) {
3216
+ return;
3217
+ }
3218
+ const hookEvent = {
3219
+ attrName: "",
3220
+ attrValue: "",
3221
+ keepAttr: true,
3222
+ allowedAttributes: ALLOWED_ATTR,
3223
+ forceKeepAttr: void 0
3224
+ };
3225
+ let l2 = attributes2.length;
3226
+ while (l2--) {
3227
+ const attr2 = attributes2[l2];
3228
+ const name2 = attr2.name, namespaceURI = attr2.namespaceURI, attrValue = attr2.value;
3229
+ const lcName = transformCaseFunc(name2);
3230
+ const initValue = attrValue;
3231
+ let value = name2 === "value" ? initValue : stringTrim(initValue);
3232
+ hookEvent.attrName = lcName;
3233
+ hookEvent.attrValue = value;
3234
+ hookEvent.keepAttr = true;
3235
+ hookEvent.forceKeepAttr = void 0;
3236
+ _executeHooks(hooks.uponSanitizeAttribute, currentNode, hookEvent);
3237
+ value = hookEvent.attrValue;
3238
+ if (SANITIZE_NAMED_PROPS && (lcName === "id" || lcName === "name") && stringIndexOf(value, SANITIZE_NAMED_PROPS_PREFIX) !== 0) {
3239
+ _removeAttribute(name2, currentNode);
3240
+ value = SANITIZE_NAMED_PROPS_PREFIX + value;
3241
+ }
3242
+ if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i, value)) {
3243
+ _removeAttribute(name2, currentNode);
3244
+ continue;
3245
+ }
3246
+ if (lcName === "attributename" && stringMatch(value, "href")) {
3247
+ _removeAttribute(name2, currentNode);
3248
+ continue;
3249
+ }
3250
+ if (hookEvent.forceKeepAttr) {
3251
+ continue;
3252
+ }
3253
+ if (!hookEvent.keepAttr) {
3254
+ _removeAttribute(name2, currentNode);
3255
+ continue;
3256
+ }
3257
+ if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(/\/>/i, value)) {
3258
+ _removeAttribute(name2, currentNode);
3259
+ continue;
3260
+ }
3261
+ if (SAFE_FOR_TEMPLATES) {
3262
+ arrayForEach([MUSTACHE_EXPR$1, ERB_EXPR$1, TMPLIT_EXPR$1], (expr) => {
3263
+ value = stringReplace(value, expr, " ");
3264
+ });
3265
+ }
3266
+ const lcTag = transformCaseFunc(currentNode.nodeName);
3267
+ if (!_isValidAttribute(lcTag, lcName, value)) {
3268
+ _removeAttribute(name2, currentNode);
3269
+ continue;
3270
+ }
3271
+ if (trustedTypesPolicy && typeof trustedTypes === "object" && typeof trustedTypes.getAttributeType === "function") {
3272
+ if (namespaceURI) ;
3273
+ else {
3274
+ switch (trustedTypes.getAttributeType(lcTag, lcName)) {
3275
+ case "TrustedHTML": {
3276
+ value = trustedTypesPolicy.createHTML(value);
3277
+ break;
3278
+ }
3279
+ case "TrustedScriptURL": {
3280
+ value = trustedTypesPolicy.createScriptURL(value);
3281
+ break;
3282
+ }
3283
+ }
3284
+ }
3285
+ }
3286
+ if (value !== initValue) {
3287
+ try {
3288
+ if (namespaceURI) {
3289
+ currentNode.setAttributeNS(namespaceURI, name2, value);
3290
+ } else {
3291
+ currentNode.setAttribute(name2, value);
3292
+ }
3293
+ if (_isClobbered(currentNode)) {
3294
+ _forceRemove(currentNode);
3295
+ } else {
3296
+ arrayPop(DOMPurify.removed);
3297
+ }
3298
+ } catch (_) {
3299
+ _removeAttribute(name2, currentNode);
3300
+ }
3301
+ }
3302
+ }
3303
+ _executeHooks(hooks.afterSanitizeAttributes, currentNode, null);
3304
+ };
3305
+ const _sanitizeShadowDOM2 = function _sanitizeShadowDOM(fragment) {
3306
+ let shadowNode = null;
3307
+ const shadowIterator = _createNodeIterator(fragment);
3308
+ _executeHooks(hooks.beforeSanitizeShadowDOM, fragment, null);
3309
+ while (shadowNode = shadowIterator.nextNode()) {
3310
+ _executeHooks(hooks.uponSanitizeShadowNode, shadowNode, null);
3311
+ _sanitizeElements(shadowNode);
3312
+ _sanitizeAttributes(shadowNode);
3313
+ if (shadowNode.content instanceof DocumentFragment) {
3314
+ _sanitizeShadowDOM2(shadowNode.content);
3315
+ }
3316
+ }
3317
+ _executeHooks(hooks.afterSanitizeShadowDOM, fragment, null);
3318
+ };
3319
+ const _sanitizeAttachedShadowRoots2 = function _sanitizeAttachedShadowRoots(root2) {
3320
+ if (root2.nodeType === NODE_TYPE$1.element && root2.shadowRoot instanceof DocumentFragment) {
3321
+ const sr = root2.shadowRoot;
3322
+ _sanitizeAttachedShadowRoots2(sr);
3323
+ _sanitizeShadowDOM2(sr);
3324
+ }
3325
+ const childNodes = root2.childNodes;
3326
+ if (!childNodes) {
3327
+ return;
3328
+ }
3329
+ const snapshot = [];
3330
+ arrayForEach(childNodes, (child) => {
3331
+ arrayPush(snapshot, child);
3332
+ });
3333
+ for (const child of snapshot) {
3334
+ _sanitizeAttachedShadowRoots2(child);
3335
+ }
3336
+ };
3337
+ DOMPurify.sanitize = function(dirty) {
3338
+ let cfg = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
3339
+ let body = null;
3340
+ let importedNode = null;
3341
+ let currentNode = null;
3342
+ let returnNode = null;
3343
+ IS_EMPTY_INPUT = !dirty;
3344
+ if (IS_EMPTY_INPUT) {
3345
+ dirty = "<!-->";
3346
+ }
3347
+ if (typeof dirty !== "string" && !_isNode(dirty)) {
3348
+ dirty = stringifyValue(dirty);
3349
+ if (typeof dirty !== "string") {
3350
+ throw typeErrorCreate("dirty is not a string, aborting");
3351
+ }
3352
+ }
3353
+ if (!DOMPurify.isSupported) {
3354
+ return dirty;
3355
+ }
3356
+ if (!SET_CONFIG) {
3357
+ _parseConfig(cfg);
3358
+ }
3359
+ DOMPurify.removed = [];
3360
+ if (typeof dirty === "string") {
3361
+ IN_PLACE = false;
3362
+ }
3363
+ if (IN_PLACE) {
3364
+ const nn = dirty.nodeName;
3365
+ if (typeof nn === "string") {
3366
+ const tagName = transformCaseFunc(nn);
3367
+ if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
3368
+ throw typeErrorCreate("root node is forbidden and cannot be sanitized in-place");
3369
+ }
3370
+ }
3371
+ _sanitizeAttachedShadowRoots2(dirty);
3372
+ } else if (dirty instanceof Node3) {
3373
+ body = _initDocument("<!---->");
3374
+ importedNode = body.ownerDocument.importNode(dirty, true);
3375
+ if (importedNode.nodeType === NODE_TYPE$1.element && importedNode.nodeName === "BODY") {
3376
+ body = importedNode;
3377
+ } else if (importedNode.nodeName === "HTML") {
3378
+ body = importedNode;
3379
+ } else {
3380
+ body.appendChild(importedNode);
3381
+ }
3382
+ _sanitizeAttachedShadowRoots2(importedNode);
3383
+ } else {
3384
+ if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT && // eslint-disable-next-line unicorn/prefer-includes
3385
+ dirty.indexOf("<") === -1) {
3386
+ return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(dirty) : dirty;
3387
+ }
3388
+ body = _initDocument(dirty);
3389
+ if (!body) {
3390
+ return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : "";
3391
+ }
3392
+ }
3393
+ if (body && FORCE_BODY) {
3394
+ _forceRemove(body.firstChild);
3395
+ }
3396
+ const nodeIterator = _createNodeIterator(IN_PLACE ? dirty : body);
3397
+ while (currentNode = nodeIterator.nextNode()) {
3398
+ _sanitizeElements(currentNode);
3399
+ _sanitizeAttributes(currentNode);
3400
+ if (currentNode.content instanceof DocumentFragment) {
3401
+ _sanitizeShadowDOM2(currentNode.content);
3402
+ }
3403
+ }
3404
+ if (IN_PLACE) {
3405
+ return dirty;
3406
+ }
3407
+ if (RETURN_DOM) {
3408
+ if (SAFE_FOR_TEMPLATES) {
3409
+ body.normalize();
3410
+ let html2 = body.innerHTML;
3411
+ arrayForEach([MUSTACHE_EXPR$1, ERB_EXPR$1, TMPLIT_EXPR$1], (expr) => {
3412
+ html2 = stringReplace(html2, expr, " ");
3413
+ });
3414
+ body.innerHTML = html2;
3415
+ }
3416
+ if (RETURN_DOM_FRAGMENT) {
3417
+ returnNode = createDocumentFragment.call(body.ownerDocument);
3418
+ while (body.firstChild) {
3419
+ returnNode.appendChild(body.firstChild);
3420
+ }
3421
+ } else {
3422
+ returnNode = body;
3423
+ }
3424
+ if (ALLOWED_ATTR.shadowroot || ALLOWED_ATTR.shadowrootmode) {
3425
+ returnNode = importNode.call(originalDocument, returnNode, true);
3426
+ }
3427
+ return returnNode;
3428
+ }
3429
+ let serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;
3430
+ if (WHOLE_DOCUMENT && ALLOWED_TAGS["!doctype"] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) {
3431
+ serializedHTML = "<!DOCTYPE " + body.ownerDocument.doctype.name + ">\n" + serializedHTML;
3432
+ }
3433
+ if (SAFE_FOR_TEMPLATES) {
3434
+ arrayForEach([MUSTACHE_EXPR$1, ERB_EXPR$1, TMPLIT_EXPR$1], (expr) => {
3435
+ serializedHTML = stringReplace(serializedHTML, expr, " ");
3436
+ });
3437
+ }
3438
+ return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(serializedHTML) : serializedHTML;
3439
+ };
3440
+ DOMPurify.setConfig = function() {
3441
+ let cfg = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
3442
+ _parseConfig(cfg);
3443
+ SET_CONFIG = true;
3444
+ };
3445
+ DOMPurify.clearConfig = function() {
3446
+ CONFIG = null;
3447
+ SET_CONFIG = false;
3448
+ };
3449
+ DOMPurify.isValidAttribute = function(tag, attr2, value) {
3450
+ if (!CONFIG) {
3451
+ _parseConfig({});
3452
+ }
3453
+ const lcTag = transformCaseFunc(tag);
3454
+ const lcName = transformCaseFunc(attr2);
3455
+ return _isValidAttribute(lcTag, lcName, value);
3456
+ };
3457
+ DOMPurify.addHook = function(entryPoint, hookFunction) {
3458
+ if (typeof hookFunction !== "function") {
3459
+ return;
3460
+ }
3461
+ arrayPush(hooks[entryPoint], hookFunction);
3462
+ };
3463
+ DOMPurify.removeHook = function(entryPoint, hookFunction) {
3464
+ if (hookFunction !== void 0) {
3465
+ const index2 = arrayLastIndexOf(hooks[entryPoint], hookFunction);
3466
+ return index2 === -1 ? void 0 : arraySplice(hooks[entryPoint], index2, 1)[0];
3467
+ }
3468
+ return arrayPop(hooks[entryPoint]);
3469
+ };
3470
+ DOMPurify.removeHooks = function(entryPoint) {
3471
+ hooks[entryPoint] = [];
3472
+ };
3473
+ DOMPurify.removeAllHooks = function() {
3474
+ hooks = _createHooksMap();
3475
+ };
3476
+ return DOMPurify;
3477
+ }
3478
+ var purify = createDOMPurify();
2210
3479
  ABConvert.factory({
2211
3480
  id: "md",
2212
3481
  name: "md",
@@ -2226,7 +3495,7 @@ ABConvert.factory({
2226
3495
  process_param: ABConvert_IOEnum.text,
2227
3496
  process_return: ABConvert_IOEnum.el,
2228
3497
  process: (el, header, content) => {
2229
- el.innerHTML = `<p>${content.replace(/ /g, "&nbsp;").split("\n").join("<br/>")}</p>`;
3498
+ el.innerHTML = purify.sanitize(`<p>${content.replace(/ /g, "&nbsp;").split("\n").join("<br/>")}</p>`);
2230
3499
  return el;
2231
3500
  }
2232
3501
  });
@@ -14824,7 +16093,7 @@ ABConvert.factory({
14824
16093
  async function render_pumlText(text2, div) {
14825
16094
  var encoded = plantumlEncoder.encode(text2);
14826
16095
  let url = "http://www.plantuml.com/plantuml/img/" + encoded;
14827
- div.innerHTML = `<img src="${url}">`;
16096
+ div.innerHTML = purify.sanitize(`<img src="${url}">`);
14828
16097
  return div;
14829
16098
  }
14830
16099
  function getID(length = 16) {
@@ -15001,207 +16270,18 @@ async function data2mindmap(list_itemInfo, div) {
15001
16270
  async function render_mermaidText(mermaidText, div) {
15002
16271
  if (ABCSetting.env.startsWith("obsidian") && ABCSetting.obsidian.mermaid) {
15003
16272
  ABCSetting.obsidian.mermaid.then(async (mermaid) => {
15004
- const { svg } = await mermaid.render("ab-mermaid-" + getID(), mermaidText);
16273
+ const { svg: svg2 } = await mermaid.render("ab-mermaid-" + getID(), mermaidText);
15005
16274
  const div_mermaid = document.createElement("div");
15006
16275
  div.appendChild(div_mermaid);
15007
16276
  div_mermaid.classList.add("mermaid");
15008
- div_mermaid.innerHTML = svg;
16277
+ div_mermaid.innerHTML = svg2;
15009
16278
  });
15010
16279
  } else {
15011
16280
  div.classList.add("ab-raw");
15012
- div.innerHTML = `<div class="ab-raw-data" type-data="mermaid" content-data='${mermaidText}'></div>`;
16281
+ div.innerHTML = purify.sanitize(`<div class="ab-raw-data" type-data="mermaid" content-data='${mermaidText}'></div>`);
15013
16282
  }
15014
16283
  return div;
15015
16284
  }
15016
- function abConvertEvent(d, isCycle = false) {
15017
- if (d.querySelector(".ab-super-width")) {
15018
- const els_note = d.querySelectorAll(".ab-note");
15019
- for (const el_note of els_note) {
15020
- if (el_note.classList.contains("ab-super-width") || el_note.querySelector(".ab-super-width")) {
15021
- const el_replace = el_note.parentNode;
15022
- if (el_replace && el_replace.classList.contains("ab-replace")) {
15023
- el_replace.classList.add("ab-super-width-p");
15024
- }
15025
- }
15026
- }
15027
- const els_view = document.querySelectorAll(".app-container .workspace-leaf");
15028
- for (const el_view of els_view) {
15029
- el_view.style.setProperty("--ab-width-outer", (el_view.offsetWidth - 40).toString() + "px");
15030
- }
15031
- }
15032
- if (d.querySelector(".ab-nodes-node")) {
15033
- const els_min = document.querySelectorAll(".ab-nodes.min .ab-nodes-node");
15034
- const list_children = d.querySelectorAll(".ab-nodes-node");
15035
- for (const children2 of list_children) {
15036
- const el_content = children2.querySelector(".ab-nodes-content");
15037
- if (!el_content) continue;
15038
- const el_child = children2.querySelector(".ab-nodes-children");
15039
- if (!el_child) continue;
15040
- const el_bracket = el_child.querySelector(".ab-nodes-bracket");
15041
- if (!el_bracket) continue;
15042
- const el_bracket2 = el_child.querySelector(".ab-nodes-bracket2");
15043
- if (!el_bracket2) continue;
15044
- const els_child = el_child.childNodes;
15045
- if (els_child.length < 3) {
15046
- el_bracket.style.setProperty("display", "none");
15047
- el_bracket2.style.setProperty("display", "none");
15048
- continue;
15049
- }
15050
- const el_child_first = els_child[2];
15051
- const el_child_last = els_child[els_child.length - 1];
15052
- const el_child_first_content = el_child_first.querySelector(".ab-nodes-content");
15053
- const el_child_last_content = el_child_last.querySelector(".ab-nodes-content");
15054
- let height = 0;
15055
- let heightToReduce = (el_child_first.offsetHeight + el_child_last.offsetHeight) / 2;
15056
- if (els_child.length == 3) {
15057
- height = el_child_first_content.offsetHeight - 20 > 20 ? el_child_first_content.offsetHeight - 20 : 20;
15058
- el_bracket2.style.cssText = `
15059
- height: ${height}px;
15060
- top: calc(50% - ${height / 2}px);
15061
- `;
15062
- } else {
15063
- el_bracket2.style.cssText = `
15064
- height: calc(100% - ${heightToReduce}px);
15065
- top: ${el_child_first.offsetHeight / 2}px;
15066
- `;
15067
- }
15068
- if (Array.prototype.includes.call(els_min, children2)) {
15069
- if (els_child.length == 3) {
15070
- el_bracket.style.cssText = `
15071
- display: block;
15072
- top: calc(50% + ${el_content.offsetHeight / 2}px - 3px);
15073
- clip-path: circle(40% at 50% 40%);
15074
- `;
15075
- } else {
15076
- el_bracket.setAttribute("display", "none");
15077
- }
15078
- if (els_child.length == 3 && el_content.offsetHeight == el_child_first_content.offsetHeight) {
15079
- el_bracket2.style.cssText = `
15080
- height: 1px;
15081
- top: calc(50% + ${el_content.offsetHeight / 2}px - 1px);
15082
- width: 18px; /* 可以溢出点 */
15083
- border-radius: 0;
15084
- border: none;
15085
- border-bottom: 1px solid var(--node-color);
15086
- `;
15087
- } else {
15088
- if (els_child.length == 3) {
15089
- height = el_child_last_content.offsetHeight / 2 - el_content.offsetHeight / 2;
15090
- el_bracket2.style.setProperty("height", `${height}px`);
15091
- el_bracket2.style.setProperty("top", `calc(50% + ${el_content.offsetHeight / 2}px)`);
15092
- el_bracket2.style.setProperty("border-radius", `0 0 0 10px`);
15093
- el_bracket2.style.setProperty("border-top", `0`);
15094
- } else {
15095
- heightToReduce = el_child_first.offsetHeight / 2 + el_child_first_content.offsetHeight / 2 + el_child_last.offsetHeight / 2 - el_child_last_content.offsetHeight / 2;
15096
- el_bracket2.style.setProperty("height", `calc(100% - ${heightToReduce}px + 1px)`);
15097
- el_bracket2.style.setProperty("top", `${el_child_first.offsetHeight / 2 + el_child_first_content.offsetHeight / 2 - 1}px`);
15098
- }
15099
- el_bracket2.style.setProperty("width", "20px");
15100
- }
15101
- }
15102
- }
15103
- }
15104
- if (d.querySelector(".ab-items.ab-lay-vfall:not(.js-waterfall):not(.ab-lay-hfall):not(.ab-lay-grid)")) {
15105
- const root_el_list = d.querySelectorAll(".ab-items.ab-lay-vfall:not(.js-waterfall):not(.ab-lay-hfall):not(.ab-lay-grid)");
15106
- for (const root_el of root_el_list) {
15107
- root_el.classList.add("js-waterfall");
15108
- const list_children = root_el.querySelectorAll(".ab-items-item");
15109
- const columnCountTmp = parseInt(window.getComputedStyle(root_el).getPropertyValue("column-count"));
15110
- let columnCount;
15111
- if (columnCountTmp && !isNaN(columnCountTmp) && columnCountTmp > 0) {
15112
- columnCount = columnCountTmp;
15113
- } else if (root_el.classList.contains("ab-col-auto") && list_children.length <= 4) {
15114
- columnCount = list_children.length;
15115
- root_el.classList.add("ab-col" + columnCount);
15116
- } else {
15117
- columnCount = 4;
15118
- root_el.classList.add("ab-col" + columnCount);
15119
- }
15120
- const height_cache = [];
15121
- const el_cache = [];
15122
- for (let i = 0; i < columnCount; i++) {
15123
- height_cache.push(0);
15124
- el_cache.push([]);
15125
- }
15126
- for (const children2 of list_children) {
15127
- const minValue = Math.min.apply(null, height_cache);
15128
- const minIndex = height_cache.indexOf(minValue);
15129
- const heightTmp = parseInt(window.getComputedStyle(children2).getPropertyValue("height"));
15130
- height_cache[minIndex] += heightTmp && !isNaN(heightTmp) && heightTmp > 0 ? heightTmp : 10;
15131
- el_cache[minIndex].push(children2);
15132
- }
15133
- const fillNumber = columnCount - list_children.length % columnCount;
15134
- if (fillNumber != 4) {
15135
- for (let i = 0; i < fillNumber; i++) {
15136
- const children2 = document.createElement("div");
15137
- children2.classList.add(".ab-items-item.placeholder");
15138
- children2.setAttribute("style", "height: 20px");
15139
- const minValue = Math.min.apply(null, height_cache);
15140
- const minIndex = height_cache.indexOf(minValue);
15141
- height_cache[minIndex] += 20;
15142
- el_cache[minIndex].push(children2);
15143
- }
15144
- }
15145
- root_el.innerHTML = "";
15146
- for (let i = 0; i < columnCount; i++) {
15147
- for (const j of el_cache[i]) {
15148
- root_el.appendChild(j);
15149
- }
15150
- }
15151
- }
15152
- }
15153
- if (!isCycle && d.querySelector(".ab-markmap-div")) {
15154
- const divEl = d;
15155
- let markmapId = "";
15156
- if (divEl.tagName === "DIV") {
15157
- markmapId = divEl.querySelector(".ab-markmap-div")?.id || "";
15158
- }
15159
- let mindmaps;
15160
- if (markmapId) {
15161
- mindmaps = document.querySelectorAll("#" + markmapId);
15162
- } else {
15163
- mindmaps = document.querySelectorAll(".ab-markmap-div");
15164
- }
15165
- for (const el_div of mindmaps) {
15166
- const el_svg = el_div.querySelector("svg");
15167
- const el_g = el_svg?.querySelector("g");
15168
- if (el_svg && el_g) {
15169
- const scale_new = el_g.getBBox().height / el_div.offsetWidth;
15170
- el_svg.setAttribute("style", `height:${el_g.getBBox().height * scale_new + 40}px`);
15171
- markmap_event(d);
15172
- }
15173
- }
15174
- }
15175
- }
15176
- function markmap_event(d) {
15177
- if (d.querySelector(".ab-markmap-svg")) {
15178
- console.log(" - markmap_event");
15179
- let script_el = document.querySelector('script[script-id="ab-markmap-script"]');
15180
- if (script_el) script_el.remove();
15181
- const divEl = d;
15182
- let markmapId = "";
15183
- if (divEl.tagName === "DIV") {
15184
- markmapId = divEl.querySelector(".ab-markmap-svg")?.id || "";
15185
- }
15186
- script_el = document.createElement("script");
15187
- document.head.appendChild(script_el);
15188
- script_el.type = "module";
15189
- script_el.setAttribute("script-id", "ab-markmap-script");
15190
- script_el.textContent = `
15191
- import { Markmap, } from 'https://jspm.dev/markmap-view';
15192
- const markmapId = "${markmapId || ""}";
15193
- let mindmaps;
15194
- if (markmapId) {
15195
- mindmaps = document.querySelectorAll('#' + markmapId);
15196
- } else {
15197
- mindmaps = document.querySelectorAll('.ab-markmap-svg'); // 注意一下这里的选择器
15198
- }
15199
- for(const mindmap of mindmaps) {
15200
- mindmap.innerHTML = "";
15201
- Markmap.create(mindmap,null,JSON.parse(mindmap.getAttribute('data-json')));
15202
- }`;
15203
- }
15204
- }
15205
16285
  const testPath = "npm2url/dist/index.cjs";
15206
16286
  const defaultProviders = {
15207
16287
  jsdelivr: (path) => `https://cdn.jsdelivr.net/npm/${path}`,
@@ -40791,8 +41871,8 @@ var katex$1 = { exports: {} };
40791
41871
  var _functions = {};
40792
41872
  var _htmlGroupBuilders = {};
40793
41873
  var _mathmlGroupBuilders = {};
40794
- function defineFunction(_ref) {
40795
- var type = _ref.type, names = _ref.names, props = _ref.props, handler = _ref.handler, htmlBuilder = _ref.htmlBuilder, mathmlBuilder = _ref.mathmlBuilder;
41874
+ function defineFunction(_ref2) {
41875
+ var type = _ref2.type, names = _ref2.names, props = _ref2.props, handler = _ref2.handler, htmlBuilder = _ref2.htmlBuilder, mathmlBuilder = _ref2.mathmlBuilder;
40796
41876
  var data2 = {
40797
41877
  type,
40798
41878
  numArgs: props.numArgs,
@@ -41790,8 +42870,8 @@ var katex$1 = { exports: {} };
41790
42870
  props: {
41791
42871
  numArgs: 1
41792
42872
  },
41793
- handler: function handler(_ref, args) {
41794
- var parser = _ref.parser, funcName = _ref.funcName;
42873
+ handler: function handler(_ref2, args) {
42874
+ var parser = _ref2.parser, funcName = _ref2.funcName;
41795
42875
  var base = args[0];
41796
42876
  return {
41797
42877
  type: "accentUnder",
@@ -41866,8 +42946,8 @@ var katex$1 = { exports: {} };
41866
42946
  numArgs: 1,
41867
42947
  numOptionalArgs: 1
41868
42948
  },
41869
- handler: function handler(_ref, args, optArgs) {
41870
- var parser = _ref.parser, funcName = _ref.funcName;
42949
+ handler: function handler(_ref2, args, optArgs) {
42950
+ var parser = _ref2.parser, funcName = _ref2.funcName;
41871
42951
  return {
41872
42952
  type: "xArrow",
41873
42953
  mode: parser.mode,
@@ -41959,8 +43039,8 @@ var katex$1 = { exports: {} };
41959
43039
  numArgs: 1,
41960
43040
  allowedInText: true
41961
43041
  },
41962
- handler: function handler(_ref, args) {
41963
- var parser = _ref.parser;
43042
+ handler: function handler(_ref2, args) {
43043
+ var parser = _ref2.parser;
41964
43044
  var arg = assertNodeType(args[0], "ordgroup");
41965
43045
  var group = arg.body;
41966
43046
  var number = "";
@@ -41998,8 +43078,8 @@ var katex$1 = { exports: {} };
41998
43078
  greediness: 3,
41999
43079
  argTypes: ["color", "original"]
42000
43080
  },
42001
- handler: function handler(_ref, args) {
42002
- var parser = _ref.parser;
43081
+ handler: function handler(_ref2, args) {
43082
+ var parser = _ref2.parser;
42003
43083
  var color = assertNodeType(args[0], "color-token").color;
42004
43084
  var body = args[1];
42005
43085
  return {
@@ -42045,8 +43125,8 @@ var katex$1 = { exports: {} };
42045
43125
  argTypes: ["size"],
42046
43126
  allowedInText: true
42047
43127
  },
42048
- handler: function handler(_ref, args, optArgs) {
42049
- var parser = _ref.parser, funcName = _ref.funcName;
43128
+ handler: function handler(_ref2, args, optArgs) {
43129
+ var parser = _ref2.parser, funcName = _ref2.funcName;
42050
43130
  var size = optArgs[0];
42051
43131
  var newRow = funcName === "\\cr";
42052
43132
  var newLine = false;
@@ -42139,8 +43219,8 @@ var katex$1 = { exports: {} };
42139
43219
  numArgs: 0,
42140
43220
  allowedInText: true
42141
43221
  },
42142
- handler: function handler(_ref) {
42143
- var parser = _ref.parser, funcName = _ref.funcName;
43222
+ handler: function handler(_ref2) {
43223
+ var parser = _ref2.parser, funcName = _ref2.funcName;
42144
43224
  parser.consumeSpaces();
42145
43225
  var token = parser.fetch();
42146
43226
  if (globalMap[token.text]) {
@@ -42474,14 +43554,14 @@ var katex$1 = { exports: {} };
42474
43554
  var delimiter_sqrtSvg = function sqrtSvg(sqrtName, height, viewBoxHeight, extraViniculum, options) {
42475
43555
  var path = sqrtPath(sqrtName, extraViniculum, viewBoxHeight);
42476
43556
  var pathNode = new domTree_PathNode(sqrtName, path);
42477
- var svg = new SvgNode([pathNode], {
43557
+ var svg2 = new SvgNode([pathNode], {
42478
43558
  // Note: 1000:1 ratio of viewBox to document em width.
42479
43559
  "width": "400em",
42480
43560
  "height": height + "em",
42481
43561
  "viewBox": "0 0 400000 " + viewBoxHeight,
42482
43562
  "preserveAspectRatio": "xMinYMin slice"
42483
43563
  });
42484
- return buildCommon.makeSvgSpan(["hide-tail"], [svg], options);
43564
+ return buildCommon.makeSvgSpan(["hide-tail"], [svg2], options);
42485
43565
  };
42486
43566
  var makeSqrtImage = function makeSqrtImage2(height, options) {
42487
43567
  var newOptions = options.havingBaseSizing();
@@ -43091,8 +44171,8 @@ var katex$1 = { exports: {} };
43091
44171
  greediness: 3,
43092
44172
  argTypes: ["color", "text"]
43093
44173
  },
43094
- handler: function handler(_ref, args, optArgs) {
43095
- var parser = _ref.parser, funcName = _ref.funcName;
44174
+ handler: function handler(_ref2, args, optArgs) {
44175
+ var parser = _ref2.parser, funcName = _ref2.funcName;
43096
44176
  var color = assertNodeType(args[0], "color-token").color;
43097
44177
  var body = args[1];
43098
44178
  return {
@@ -43170,8 +44250,8 @@ var katex$1 = { exports: {} };
43170
44250
  mathmlBuilder: enclose_mathmlBuilder
43171
44251
  });
43172
44252
  var _environments = {};
43173
- function defineEnvironment(_ref) {
43174
- var type = _ref.type, names = _ref.names, props = _ref.props, handler = _ref.handler, htmlBuilder = _ref.htmlBuilder, mathmlBuilder = _ref.mathmlBuilder;
44253
+ function defineEnvironment(_ref2) {
44254
+ var type = _ref2.type, names = _ref2.names, props = _ref2.props, handler = _ref2.handler, htmlBuilder = _ref2.htmlBuilder, mathmlBuilder = _ref2.mathmlBuilder;
43175
44255
  var data2 = {
43176
44256
  type,
43177
44257
  numArgs: props.numArgs || 0,
@@ -43202,8 +44282,8 @@ var katex$1 = { exports: {} };
43202
44282
  }
43203
44283
  return hlineInfo;
43204
44284
  }
43205
- function parseArray(parser, _ref, style) {
43206
- var hskipBeforeAndAfter = _ref.hskipBeforeAndAfter, addJot = _ref.addJot, cols = _ref.cols, arraystretch = _ref.arraystretch, colSeparationType = _ref.colSeparationType;
44285
+ function parseArray(parser, _ref2, style) {
44286
+ var hskipBeforeAndAfter = _ref2.hskipBeforeAndAfter, addJot = _ref2.addJot, cols = _ref2.cols, arraystretch = _ref2.arraystretch, colSeparationType = _ref2.colSeparationType;
43207
44287
  parser.gullet.beginGroup();
43208
44288
  parser.gullet.macros.set("\\\\", "\\cr");
43209
44289
  if (!arraystretch) {
@@ -43842,8 +44922,8 @@ var katex$1 = { exports: {} };
43842
44922
  numArgs: 1,
43843
44923
  argTypes: ["text"]
43844
44924
  },
43845
- handler: function handler(_ref, args) {
43846
- var parser = _ref.parser, funcName = _ref.funcName;
44925
+ handler: function handler(_ref2, args) {
44926
+ var parser = _ref2.parser, funcName = _ref2.funcName;
43847
44927
  var nameGroup = args[0];
43848
44928
  if (nameGroup.type !== "ordgroup") {
43849
44929
  throw new src_ParseError("Invalid environment name", nameGroup);
@@ -43923,8 +45003,8 @@ var katex$1 = { exports: {} };
43923
45003
  props: {
43924
45004
  numArgs: 1
43925
45005
  },
43926
- handler: function handler(_ref, args) {
43927
- var parser = _ref.parser, funcName = _ref.funcName;
45006
+ handler: function handler(_ref2, args) {
45007
+ var parser = _ref2.parser, funcName = _ref2.funcName;
43928
45008
  var body = args[0];
43929
45009
  return {
43930
45010
  type: "mclass",
@@ -44047,8 +45127,8 @@ var katex$1 = { exports: {} };
44047
45127
  numArgs: 1,
44048
45128
  greediness: 2
44049
45129
  },
44050
- handler: function handler(_ref, args) {
44051
- var parser = _ref.parser, funcName = _ref.funcName;
45130
+ handler: function handler(_ref2, args) {
45131
+ var parser = _ref2.parser, funcName = _ref2.funcName;
44052
45132
  var body = args[0];
44053
45133
  var func = funcName;
44054
45134
  if (func in fontAliases) {
@@ -44302,8 +45382,8 @@ var katex$1 = { exports: {} };
44302
45382
  numArgs: 2,
44303
45383
  greediness: 2
44304
45384
  },
44305
- handler: function handler(_ref, args) {
44306
- var parser = _ref.parser, funcName = _ref.funcName;
45385
+ handler: function handler(_ref2, args) {
45386
+ var parser = _ref2.parser, funcName = _ref2.funcName;
44307
45387
  var numer = args[0];
44308
45388
  var denom = args[1];
44309
45389
  var hasBarLine;
@@ -44604,8 +45684,8 @@ var katex$1 = { exports: {} };
44604
45684
  props: {
44605
45685
  numArgs: 1
44606
45686
  },
44607
- handler: function handler(_ref, args) {
44608
- var parser = _ref.parser, funcName = _ref.funcName;
45687
+ handler: function handler(_ref2, args) {
45688
+ var parser = _ref2.parser, funcName = _ref2.funcName;
44609
45689
  return {
44610
45690
  type: "horizBrace",
44611
45691
  mode: parser.mode,
@@ -44625,8 +45705,8 @@ var katex$1 = { exports: {} };
44625
45705
  argTypes: ["url", "original"],
44626
45706
  allowedInText: true
44627
45707
  },
44628
- handler: function handler(_ref, args) {
44629
- var parser = _ref.parser;
45708
+ handler: function handler(_ref2, args) {
45709
+ var parser = _ref2.parser;
44630
45710
  var body = args[1];
44631
45711
  var href = assertNodeType(args[0], "url").url;
44632
45712
  if (!parser.settings.isTrusted({
@@ -44706,9 +45786,9 @@ var katex$1 = { exports: {} };
44706
45786
  argTypes: ["raw", "original"],
44707
45787
  allowedInText: true
44708
45788
  },
44709
- handler: function handler(_ref, args) {
44710
- var parser = _ref.parser, funcName = _ref.funcName;
44711
- _ref.token;
45789
+ handler: function handler(_ref2, args) {
45790
+ var parser = _ref2.parser, funcName = _ref2.funcName;
45791
+ _ref2.token;
44712
45792
  var value = assertNodeType(args[0], "raw").string;
44713
45793
  var body = args[1];
44714
45794
  if (parser.settings.strict) {
@@ -44791,8 +45871,8 @@ var katex$1 = { exports: {} };
44791
45871
  numArgs: 2,
44792
45872
  allowedInText: true
44793
45873
  },
44794
- handler: function handler(_ref, args) {
44795
- var parser = _ref.parser;
45874
+ handler: function handler(_ref2, args) {
45875
+ var parser = _ref2.parser;
44796
45876
  return {
44797
45877
  type: "htmlmathml",
44798
45878
  mode: parser.mode,
@@ -44839,8 +45919,8 @@ var katex$1 = { exports: {} };
44839
45919
  argTypes: ["raw", "url"],
44840
45920
  allowedInText: false
44841
45921
  },
44842
- handler: function handler(_ref, args, optArgs) {
44843
- var parser = _ref.parser;
45922
+ handler: function handler(_ref2, args, optArgs) {
45923
+ var parser = _ref2.parser;
44844
45924
  var width = {
44845
45925
  number: 0,
44846
45926
  unit: "em"
@@ -44954,8 +46034,8 @@ var katex$1 = { exports: {} };
44954
46034
  argTypes: ["size"],
44955
46035
  allowedInText: true
44956
46036
  },
44957
- handler: function handler(_ref, args) {
44958
- var parser = _ref.parser, funcName = _ref.funcName;
46037
+ handler: function handler(_ref2, args) {
46038
+ var parser = _ref2.parser, funcName = _ref2.funcName;
44959
46039
  var size = assertNodeType(args[0], "size");
44960
46040
  if (parser.settings.strict) {
44961
46041
  var mathFunction = funcName[1] === "m";
@@ -44994,8 +46074,8 @@ var katex$1 = { exports: {} };
44994
46074
  numArgs: 1,
44995
46075
  allowedInText: true
44996
46076
  },
44997
- handler: function handler(_ref, args) {
44998
- var parser = _ref.parser, funcName = _ref.funcName;
46077
+ handler: function handler(_ref2, args) {
46078
+ var parser = _ref2.parser, funcName = _ref2.funcName;
44999
46079
  var body = args[0];
45000
46080
  return {
45001
46081
  type: "lap",
@@ -45039,8 +46119,8 @@ var katex$1 = { exports: {} };
45039
46119
  allowedInText: true,
45040
46120
  allowedInMath: false
45041
46121
  },
45042
- handler: function handler(_ref, args) {
45043
- var funcName = _ref.funcName, parser = _ref.parser;
46122
+ handler: function handler(_ref2, args) {
46123
+ var funcName = _ref2.funcName, parser = _ref2.parser;
45044
46124
  var outerMode = parser.mode;
45045
46125
  parser.switchMode("math");
45046
46126
  var close = funcName === "\\(" ? "\\)" : "$";
@@ -45088,8 +46168,8 @@ var katex$1 = { exports: {} };
45088
46168
  props: {
45089
46169
  numArgs: 4
45090
46170
  },
45091
- handler: function handler(_ref, args) {
45092
- var parser = _ref.parser;
46171
+ handler: function handler(_ref2, args) {
46172
+ var parser = _ref2.parser;
45093
46173
  return {
45094
46174
  type: "mathchoice",
45095
46175
  mode: parser.mode,
@@ -45321,8 +46401,8 @@ var katex$1 = { exports: {} };
45321
46401
  props: {
45322
46402
  numArgs: 0
45323
46403
  },
45324
- handler: function handler(_ref, args) {
45325
- var parser = _ref.parser, funcName = _ref.funcName;
46404
+ handler: function handler(_ref2, args) {
46405
+ var parser = _ref2.parser, funcName = _ref2.funcName;
45326
46406
  var fName = funcName;
45327
46407
  if (fName.length === 1) {
45328
46408
  fName = singleCharBigOps[fName];
@@ -45527,8 +46607,8 @@ var katex$1 = { exports: {} };
45527
46607
  props: {
45528
46608
  numArgs: 1
45529
46609
  },
45530
- handler: function handler(_ref, args) {
45531
- var parser = _ref.parser, funcName = _ref.funcName;
46610
+ handler: function handler(_ref2, args) {
46611
+ var parser = _ref2.parser, funcName = _ref2.funcName;
45532
46612
  var body = args[0];
45533
46613
  return {
45534
46614
  type: "operatorname",
@@ -45560,8 +46640,8 @@ var katex$1 = { exports: {} };
45560
46640
  props: {
45561
46641
  numArgs: 1
45562
46642
  },
45563
- handler: function handler(_ref, args) {
45564
- var parser = _ref.parser;
46643
+ handler: function handler(_ref2, args) {
46644
+ var parser = _ref2.parser;
45565
46645
  var body = args[0];
45566
46646
  return {
45567
46647
  type: "overline",
@@ -45606,8 +46686,8 @@ var katex$1 = { exports: {} };
45606
46686
  numArgs: 1,
45607
46687
  allowedInText: true
45608
46688
  },
45609
- handler: function handler(_ref, args) {
45610
- var parser = _ref.parser;
46689
+ handler: function handler(_ref2, args) {
46690
+ var parser = _ref2.parser;
45611
46691
  var body = args[0];
45612
46692
  return {
45613
46693
  type: "phantom",
@@ -45705,8 +46785,8 @@ var katex$1 = { exports: {} };
45705
46785
  argTypes: ["size", "hbox"],
45706
46786
  allowedInText: true
45707
46787
  },
45708
- handler: function handler(_ref, args) {
45709
- var parser = _ref.parser;
46788
+ handler: function handler(_ref2, args) {
46789
+ var parser = _ref2.parser;
45710
46790
  var amount = assertNodeType(args[0], "size").value;
45711
46791
  var body = args[1];
45712
46792
  return {
@@ -45743,8 +46823,8 @@ var katex$1 = { exports: {} };
45743
46823
  numOptionalArgs: 1,
45744
46824
  argTypes: ["size", "size", "size"]
45745
46825
  },
45746
- handler: function handler(_ref, args, optArgs) {
45747
- var parser = _ref.parser;
46826
+ handler: function handler(_ref2, args, optArgs) {
46827
+ var parser = _ref2.parser;
45748
46828
  var shift = optArgs[0];
45749
46829
  var width = assertNodeType(args[0], "size");
45750
46830
  var height = assertNodeType(args[1], "size");
@@ -45817,8 +46897,8 @@ var katex$1 = { exports: {} };
45817
46897
  numArgs: 0,
45818
46898
  allowedInText: true
45819
46899
  },
45820
- handler: function handler(_ref, args) {
45821
- var breakOnTokenText = _ref.breakOnTokenText, funcName = _ref.funcName, parser = _ref.parser;
46900
+ handler: function handler(_ref2, args) {
46901
+ var breakOnTokenText = _ref2.breakOnTokenText, funcName = _ref2.funcName, parser = _ref2.parser;
45822
46902
  var body = parser.parseExpression(false, breakOnTokenText);
45823
46903
  return {
45824
46904
  type: "sizing",
@@ -45845,8 +46925,8 @@ var katex$1 = { exports: {} };
45845
46925
  numOptionalArgs: 1,
45846
46926
  allowedInText: true
45847
46927
  },
45848
- handler: function handler(_ref, args, optArgs) {
45849
- var parser = _ref.parser;
46928
+ handler: function handler(_ref2, args, optArgs) {
46929
+ var parser = _ref2.parser;
45850
46930
  var smashHeight = false;
45851
46931
  var smashDepth = false;
45852
46932
  var tbArg = optArgs[0] && assertNodeType(optArgs[0], "ordgroup");
@@ -45926,8 +47006,8 @@ var katex$1 = { exports: {} };
45926
47006
  numArgs: 1,
45927
47007
  numOptionalArgs: 1
45928
47008
  },
45929
- handler: function handler(_ref, args, optArgs) {
45930
- var parser = _ref.parser;
47009
+ handler: function handler(_ref2, args, optArgs) {
47010
+ var parser = _ref2.parser;
45931
47011
  var index2 = optArgs[0];
45932
47012
  var body = args[0];
45933
47013
  return {
@@ -46011,8 +47091,8 @@ var katex$1 = { exports: {} };
46011
47091
  numArgs: 0,
46012
47092
  allowedInText: true
46013
47093
  },
46014
- handler: function handler(_ref, args) {
46015
- var breakOnTokenText = _ref.breakOnTokenText, funcName = _ref.funcName, parser = _ref.parser;
47094
+ handler: function handler(_ref2, args) {
47095
+ var breakOnTokenText = _ref2.breakOnTokenText, funcName = _ref2.funcName, parser = _ref2.parser;
46016
47096
  var body = parser.parseExpression(true, breakOnTokenText);
46017
47097
  var style = funcName.slice(1, funcName.length - 5);
46018
47098
  return {
@@ -46397,8 +47477,8 @@ var katex$1 = { exports: {} };
46397
47477
  greediness: 2,
46398
47478
  allowedInText: true
46399
47479
  },
46400
- handler: function handler(_ref, args) {
46401
- var parser = _ref.parser, funcName = _ref.funcName;
47480
+ handler: function handler(_ref2, args) {
47481
+ var parser = _ref2.parser, funcName = _ref2.funcName;
46402
47482
  var body = args[0];
46403
47483
  return {
46404
47484
  type: "text",
@@ -46424,8 +47504,8 @@ var katex$1 = { exports: {} };
46424
47504
  numArgs: 1,
46425
47505
  allowedInText: true
46426
47506
  },
46427
- handler: function handler(_ref, args) {
46428
- var parser = _ref.parser;
47507
+ handler: function handler(_ref2, args) {
47508
+ var parser = _ref2.parser;
46429
47509
  return {
46430
47510
  type: "underline",
46431
47511
  mode: parser.mode,
@@ -49286,7 +50366,7 @@ ABConvert.factory({
49286
50366
  process_return: ABConvert_IOEnum.el,
49287
50367
  process: (el, header, content) => {
49288
50368
  list2markmap(content, el);
49289
- markmap_event(el);
50369
+ ABCSetting.obsidian.markmap_event?.(el);
49290
50370
  return el;
49291
50371
  }
49292
50372
  });
@@ -49302,13 +50382,46 @@ function list2markmap(markdown, div) {
49302
50382
  svg_div.classList.add("ab-markmap-div");
49303
50383
  svg_div.id = "ab-markmap-div-" + id;
49304
50384
  const html_str = `<svg class="ab-markmap-svg" id="ab-markmap-${id}" data-json='${JSON.stringify(root2)}' style="height:${height_adapt}px"></svg>`;
49305
- svg_div.innerHTML = html_str;
50385
+ svg_div.innerHTML = purify.sanitize(html_str, {
50386
+ USE_PROFILES: { svg: true }
50387
+ });
49306
50388
  } else {
49307
50389
  div.classList.add("ab-raw");
49308
- div.innerHTML = `<div class="ab-raw-data" type-data="markmap" content-data='${markdown}'></div>`;
50390
+ div.innerHTML = purify.sanitize(`<div class="ab-raw-data" type-data="markmap" content-data='${markdown}'></div>`);
49309
50391
  }
49310
50392
  return div;
49311
50393
  }
50394
+ async function markmap_event(d) {
50395
+ if (ABCSetting.env == "obsidian-min") return;
50396
+ if (d.querySelector(".ab-markmap-svg")) {
50397
+ console.log(" - markmap_event");
50398
+ let script_el = document.querySelector('script[script-id="ab-markmap-script"]');
50399
+ if (script_el) script_el.remove();
50400
+ const divEl = d;
50401
+ let markmapId = "";
50402
+ if (divEl.tagName === "DIV") {
50403
+ markmapId = divEl.querySelector(".ab-markmap-svg")?.id || "";
50404
+ }
50405
+ script_el = document.createElement("script");
50406
+ document.head.appendChild(script_el);
50407
+ script_el.type = "module";
50408
+ script_el.setAttribute("script-id", "ab-markmap-script");
50409
+ script_el.textContent = `
50410
+ import { Markmap, } from 'https://jspm.dev/markmap-view';
50411
+ const markmapId = "${markmapId || ""}";
50412
+ let mindmaps;
50413
+ if (markmapId) {
50414
+ mindmaps = document.querySelectorAll('#' + markmapId);
50415
+ } else {
50416
+ mindmaps = document.querySelectorAll('.ab-markmap-svg'); // 注意一下这里的选择器
50417
+ }
50418
+ for(const mindmap of mindmaps) {
50419
+ mindmap.innerHTML = "";
50420
+ Markmap.create(mindmap,null,JSON.parse(mindmap.getAttribute('data-json')));
50421
+ }`;
50422
+ }
50423
+ }
50424
+ ABCSetting.obsidian.markmap_event = markmap_event;
49312
50425
  const jsdom_api = {
49313
50426
  jsdom_enable: () => {
49314
50427
  },
@@ -49579,10 +50692,170 @@ function ab_mdit_client(md, options) {
49579
50692
  md.use(abSelector_squareInline);
49580
50693
  md.use(abSelector_container);
49581
50694
  }
50695
+ function abConvertEvent(d, isCycle = false) {
50696
+ if (d.querySelector(".ab-super-width")) {
50697
+ const els_note = d.querySelectorAll(".ab-note");
50698
+ for (const el_note of els_note) {
50699
+ if (el_note.classList.contains("ab-super-width") || el_note.querySelector(".ab-super-width")) {
50700
+ const el_replace = el_note.parentNode;
50701
+ if (el_replace && el_replace.classList.contains("ab-replace")) {
50702
+ el_replace.classList.add("ab-super-width-p");
50703
+ }
50704
+ }
50705
+ }
50706
+ const els_view = document.querySelectorAll(".app-container .workspace-leaf");
50707
+ for (const el_view of els_view) {
50708
+ el_view.style.setProperty("--ab-width-outer", (el_view.offsetWidth - 40).toString() + "px");
50709
+ }
50710
+ }
50711
+ if (d.querySelector(".ab-nodes-node")) {
50712
+ const els_min = document.querySelectorAll(".ab-nodes.min .ab-nodes-node");
50713
+ const list_children = d.querySelectorAll(".ab-nodes-node");
50714
+ for (const children2 of list_children) {
50715
+ const el_content = children2.querySelector(".ab-nodes-content");
50716
+ if (!el_content) continue;
50717
+ const el_child = children2.querySelector(".ab-nodes-children");
50718
+ if (!el_child) continue;
50719
+ const el_bracket = el_child.querySelector(".ab-nodes-bracket");
50720
+ if (!el_bracket) continue;
50721
+ const el_bracket2 = el_child.querySelector(".ab-nodes-bracket2");
50722
+ if (!el_bracket2) continue;
50723
+ const els_child = el_child.childNodes;
50724
+ if (els_child.length < 3) {
50725
+ el_bracket.style.setProperty("display", "none");
50726
+ el_bracket2.style.setProperty("display", "none");
50727
+ continue;
50728
+ }
50729
+ const el_child_first = els_child[2];
50730
+ const el_child_last = els_child[els_child.length - 1];
50731
+ const el_child_first_content = el_child_first.querySelector(".ab-nodes-content");
50732
+ const el_child_last_content = el_child_last.querySelector(".ab-nodes-content");
50733
+ let height = 0;
50734
+ let heightToReduce = (el_child_first.offsetHeight + el_child_last.offsetHeight) / 2;
50735
+ if (els_child.length == 3) {
50736
+ height = el_child_first_content.offsetHeight - 20 > 20 ? el_child_first_content.offsetHeight - 20 : 20;
50737
+ el_bracket2.style.cssText = `
50738
+ height: ${height}px;
50739
+ top: calc(50% - ${height / 2}px);
50740
+ `;
50741
+ } else {
50742
+ el_bracket2.style.cssText = `
50743
+ height: calc(100% - ${heightToReduce}px);
50744
+ top: ${el_child_first.offsetHeight / 2}px;
50745
+ `;
50746
+ }
50747
+ if (Array.prototype.includes.call(els_min, children2)) {
50748
+ if (els_child.length == 3) {
50749
+ el_bracket.style.cssText = `
50750
+ display: block;
50751
+ top: calc(50% + ${el_content.offsetHeight / 2}px - 3px);
50752
+ clip-path: circle(40% at 50% 40%);
50753
+ `;
50754
+ } else {
50755
+ el_bracket.setAttribute("display", "none");
50756
+ }
50757
+ if (els_child.length == 3 && el_content.offsetHeight == el_child_first_content.offsetHeight) {
50758
+ el_bracket2.style.cssText = `
50759
+ height: 1px;
50760
+ top: calc(50% + ${el_content.offsetHeight / 2}px - 1px);
50761
+ width: 18px; /* 可以溢出点 */
50762
+ border-radius: 0;
50763
+ border: none;
50764
+ border-bottom: 1px solid var(--node-color);
50765
+ `;
50766
+ } else {
50767
+ if (els_child.length == 3) {
50768
+ height = el_child_last_content.offsetHeight / 2 - el_content.offsetHeight / 2;
50769
+ el_bracket2.style.setProperty("height", `${height}px`);
50770
+ el_bracket2.style.setProperty("top", `calc(50% + ${el_content.offsetHeight / 2}px)`);
50771
+ el_bracket2.style.setProperty("border-radius", `0 0 0 10px`);
50772
+ el_bracket2.style.setProperty("border-top", `0`);
50773
+ } else {
50774
+ heightToReduce = el_child_first.offsetHeight / 2 + el_child_first_content.offsetHeight / 2 + el_child_last.offsetHeight / 2 - el_child_last_content.offsetHeight / 2;
50775
+ el_bracket2.style.setProperty("height", `calc(100% - ${heightToReduce}px + 1px)`);
50776
+ el_bracket2.style.setProperty("top", `${el_child_first.offsetHeight / 2 + el_child_first_content.offsetHeight / 2 - 1}px`);
50777
+ }
50778
+ el_bracket2.style.setProperty("width", "20px");
50779
+ }
50780
+ }
50781
+ }
50782
+ }
50783
+ if (d.querySelector(".ab-items.ab-lay-vfall:not(.js-waterfall):not(.ab-lay-hfall):not(.ab-lay-grid)")) {
50784
+ const root_el_list = d.querySelectorAll(".ab-items.ab-lay-vfall:not(.js-waterfall):not(.ab-lay-hfall):not(.ab-lay-grid)");
50785
+ for (const root_el of root_el_list) {
50786
+ root_el.classList.add("js-waterfall");
50787
+ const list_children = root_el.querySelectorAll(".ab-items-item");
50788
+ const columnCountTmp = parseInt(window.getComputedStyle(root_el).getPropertyValue("column-count"));
50789
+ let columnCount;
50790
+ if (columnCountTmp && !isNaN(columnCountTmp) && columnCountTmp > 0) {
50791
+ columnCount = columnCountTmp;
50792
+ } else if (root_el.classList.contains("ab-col-auto") && list_children.length <= 4) {
50793
+ columnCount = list_children.length;
50794
+ root_el.classList.add("ab-col" + columnCount);
50795
+ } else {
50796
+ columnCount = 4;
50797
+ root_el.classList.add("ab-col" + columnCount);
50798
+ }
50799
+ const height_cache = [];
50800
+ const el_cache = [];
50801
+ for (let i = 0; i < columnCount; i++) {
50802
+ height_cache.push(0);
50803
+ el_cache.push([]);
50804
+ }
50805
+ for (const children2 of list_children) {
50806
+ const minValue = Math.min.apply(null, height_cache);
50807
+ const minIndex = height_cache.indexOf(minValue);
50808
+ const heightTmp = parseInt(window.getComputedStyle(children2).getPropertyValue("height"));
50809
+ height_cache[minIndex] += heightTmp && !isNaN(heightTmp) && heightTmp > 0 ? heightTmp : 10;
50810
+ el_cache[minIndex].push(children2);
50811
+ }
50812
+ const fillNumber = columnCount - list_children.length % columnCount;
50813
+ if (fillNumber != 4) {
50814
+ for (let i = 0; i < fillNumber; i++) {
50815
+ const children2 = document.createElement("div");
50816
+ children2.classList.add(".ab-items-item.placeholder");
50817
+ children2.setAttribute("style", "height: 20px");
50818
+ const minValue = Math.min.apply(null, height_cache);
50819
+ const minIndex = height_cache.indexOf(minValue);
50820
+ height_cache[minIndex] += 20;
50821
+ el_cache[minIndex].push(children2);
50822
+ }
50823
+ }
50824
+ root_el.innerHTML = "";
50825
+ for (let i = 0; i < columnCount; i++) {
50826
+ for (const j of el_cache[i]) {
50827
+ root_el.appendChild(j);
50828
+ }
50829
+ }
50830
+ }
50831
+ }
50832
+ if (!isCycle && d.querySelector(".ab-markmap-div")) {
50833
+ const divEl = d;
50834
+ let markmapId = "";
50835
+ if (divEl.tagName === "DIV") {
50836
+ markmapId = divEl.querySelector(".ab-markmap-div")?.id || "";
50837
+ }
50838
+ let mindmaps;
50839
+ if (markmapId) {
50840
+ mindmaps = document.querySelectorAll("#" + markmapId);
50841
+ } else {
50842
+ mindmaps = document.querySelectorAll(".ab-markmap-div");
50843
+ }
50844
+ for (const el_div of mindmaps) {
50845
+ const el_svg = el_div.querySelector("svg");
50846
+ const el_g = el_svg?.querySelector("g");
50847
+ if (el_svg && el_g) {
50848
+ const scale_new = el_g.getBBox().height / el_div.offsetWidth;
50849
+ el_svg.setAttribute("style", `height:${el_g.getBBox().height * scale_new + 40}px`);
50850
+ ABCSetting.obsidian.markmap_event?.(d);
50851
+ }
50852
+ }
50853
+ }
50854
+ }
49582
50855
  exports.ABConvertManager = ABConvertManager;
49583
50856
  exports.ABReg = ABReg;
49584
50857
  exports.abConvertEvent = abConvertEvent;
49585
50858
  exports.ab_mdit = ab_mdit;
49586
50859
  exports.ab_mdit_client = ab_mdit_client;
49587
50860
  exports.jsdom_api = jsdom_api;
49588
- //# sourceMappingURL=index_mdit-CE73u7cg.cjs.map
50861
+ //# sourceMappingURL=ABConvertEvent-Bka43YZF.cjs.map