@uiw/react-md-editor 3.24.1 → 3.25.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/README.md +47 -2
  2. package/dist/mdeditor.js +1828 -1806
  3. package/dist/mdeditor.min.js +1 -1
  4. package/esm/Context.d.ts +1 -1
  5. package/esm/Editor.d.ts +4 -149
  6. package/esm/Editor.js +0 -1
  7. package/esm/Editor.nohighlight.d.ts +12 -0
  8. package/esm/Editor.nohighlight.js +255 -0
  9. package/esm/Types.d.ts +148 -0
  10. package/esm/Types.js +1 -0
  11. package/esm/components/DragBar/index.d.ts +1 -1
  12. package/esm/components/TextArea/Markdown.d.ts +1 -1
  13. package/esm/components/TextArea/Textarea.d.ts +1 -1
  14. package/esm/components/TextArea/index.d.ts +1 -1
  15. package/esm/components/TextArea/index.nohighlight.d.ts +27 -0
  16. package/esm/components/TextArea/index.nohighlight.js +93 -0
  17. package/esm/components/Toolbar/Child.d.ts +1 -1
  18. package/esm/components/Toolbar/index.d.ts +1 -1
  19. package/esm/index.d.ts +2 -0
  20. package/esm/index.js +2 -0
  21. package/esm/index.nohighlight.d.ts +13 -0
  22. package/esm/index.nohighlight.js +13 -0
  23. package/lib/Context.d.ts +1 -1
  24. package/lib/Editor.d.ts +4 -149
  25. package/lib/Editor.nohighlight.d.ts +12 -0
  26. package/lib/Editor.nohighlight.js +317 -0
  27. package/lib/Types.d.ts +148 -0
  28. package/lib/Types.js +1 -0
  29. package/lib/components/DragBar/index.d.ts +1 -1
  30. package/lib/components/TextArea/Markdown.d.ts +1 -1
  31. package/lib/components/TextArea/Textarea.d.ts +1 -1
  32. package/lib/components/TextArea/index.d.ts +1 -1
  33. package/lib/components/TextArea/index.nohighlight.d.ts +27 -0
  34. package/lib/components/TextArea/index.nohighlight.js +98 -0
  35. package/lib/components/Toolbar/Child.d.ts +1 -1
  36. package/lib/components/Toolbar/index.d.ts +1 -1
  37. package/lib/index.d.ts +2 -0
  38. package/lib/index.js +12 -0
  39. package/lib/index.nohighlight.d.ts +13 -0
  40. package/lib/index.nohighlight.js +98 -0
  41. package/nohighlight.d.ts +13 -0
  42. package/package.json +17 -2
  43. package/src/Context.tsx +1 -1
  44. package/src/Editor.nohighlight.tsx +264 -0
  45. package/src/Editor.tsx +5 -151
  46. package/src/Types.ts +151 -0
  47. package/src/components/DragBar/index.tsx +1 -1
  48. package/src/components/TextArea/Markdown.tsx +2 -2
  49. package/src/components/TextArea/Textarea.tsx +1 -1
  50. package/src/components/TextArea/index.nohighlight.tsx +109 -0
  51. package/src/components/TextArea/index.tsx +1 -1
  52. package/src/components/Toolbar/Child.tsx +1 -1
  53. package/src/components/Toolbar/index.tsx +1 -1
  54. package/src/index.nohighlight.tsx +16 -0
  55. package/src/index.tsx +2 -0
package/dist/mdeditor.js CHANGED
@@ -33824,6 +33824,7 @@ const html_html = create({
33824
33824
  onAuxClick: null,
33825
33825
  onBeforeMatch: null,
33826
33826
  onBeforePrint: null,
33827
+ onBeforeToggle: null,
33827
33828
  onBeforeUnload: null,
33828
33829
  onBlur: null,
33829
33830
  onCancel: null,
@@ -33929,6 +33930,8 @@ const html_html = create({
33929
33930
  scoped: types_boolean,
33930
33931
  seamless: types_boolean,
33931
33932
  selected: types_boolean,
33933
+ shadowRootDelegatesFocus: types_boolean,
33934
+ shadowRootMode: null,
33932
33935
  shape: null,
33933
33936
  size: number,
33934
33937
  sizes: null,
@@ -43310,161 +43313,112 @@ function rehypeRaw(options = {}) {
43310
43313
  }
43311
43314
  }
43312
43315
 
43313
- ;// CONCATENATED MODULE: ../node_modules/github-slugger/regex.js
43314
- // This module is generated by `script/`.
43315
- /* eslint-disable no-control-regex, no-misleading-character-class, no-useless-escape */
43316
- const regex = /[\0-\x1F!-,\.\/:-@\[-\^`\{-\xA9\xAB-\xB4\xB6-\xB9\xBB-\xBF\xD7\xF7\u02C2-\u02C5\u02D2-\u02DF\u02E5-\u02EB\u02ED\u02EF-\u02FF\u0375\u0378\u0379\u037E\u0380-\u0385\u0387\u038B\u038D\u03A2\u03F6\u0482\u0530\u0557\u0558\u055A-\u055F\u0589-\u0590\u05BE\u05C0\u05C3\u05C6\u05C8-\u05CF\u05EB-\u05EE\u05F3-\u060F\u061B-\u061F\u066A-\u066D\u06D4\u06DD\u06DE\u06E9\u06FD\u06FE\u0700-\u070F\u074B\u074C\u07B2-\u07BF\u07F6-\u07F9\u07FB\u07FC\u07FE\u07FF\u082E-\u083F\u085C-\u085F\u086B-\u089F\u08B5\u08C8-\u08D2\u08E2\u0964\u0965\u0970\u0984\u098D\u098E\u0991\u0992\u09A9\u09B1\u09B3-\u09B5\u09BA\u09BB\u09C5\u09C6\u09C9\u09CA\u09CF-\u09D6\u09D8-\u09DB\u09DE\u09E4\u09E5\u09F2-\u09FB\u09FD\u09FF\u0A00\u0A04\u0A0B-\u0A0E\u0A11\u0A12\u0A29\u0A31\u0A34\u0A37\u0A3A\u0A3B\u0A3D\u0A43-\u0A46\u0A49\u0A4A\u0A4E-\u0A50\u0A52-\u0A58\u0A5D\u0A5F-\u0A65\u0A76-\u0A80\u0A84\u0A8E\u0A92\u0AA9\u0AB1\u0AB4\u0ABA\u0ABB\u0AC6\u0ACA\u0ACE\u0ACF\u0AD1-\u0ADF\u0AE4\u0AE5\u0AF0-\u0AF8\u0B00\u0B04\u0B0D\u0B0E\u0B11\u0B12\u0B29\u0B31\u0B34\u0B3A\u0B3B\u0B45\u0B46\u0B49\u0B4A\u0B4E-\u0B54\u0B58-\u0B5B\u0B5E\u0B64\u0B65\u0B70\u0B72-\u0B81\u0B84\u0B8B-\u0B8D\u0B91\u0B96-\u0B98\u0B9B\u0B9D\u0BA0-\u0BA2\u0BA5-\u0BA7\u0BAB-\u0BAD\u0BBA-\u0BBD\u0BC3-\u0BC5\u0BC9\u0BCE\u0BCF\u0BD1-\u0BD6\u0BD8-\u0BE5\u0BF0-\u0BFF\u0C0D\u0C11\u0C29\u0C3A-\u0C3C\u0C45\u0C49\u0C4E-\u0C54\u0C57\u0C5B-\u0C5F\u0C64\u0C65\u0C70-\u0C7F\u0C84\u0C8D\u0C91\u0CA9\u0CB4\u0CBA\u0CBB\u0CC5\u0CC9\u0CCE-\u0CD4\u0CD7-\u0CDD\u0CDF\u0CE4\u0CE5\u0CF0\u0CF3-\u0CFF\u0D0D\u0D11\u0D45\u0D49\u0D4F-\u0D53\u0D58-\u0D5E\u0D64\u0D65\u0D70-\u0D79\u0D80\u0D84\u0D97-\u0D99\u0DB2\u0DBC\u0DBE\u0DBF\u0DC7-\u0DC9\u0DCB-\u0DCE\u0DD5\u0DD7\u0DE0-\u0DE5\u0DF0\u0DF1\u0DF4-\u0E00\u0E3B-\u0E3F\u0E4F\u0E5A-\u0E80\u0E83\u0E85\u0E8B\u0EA4\u0EA6\u0EBE\u0EBF\u0EC5\u0EC7\u0ECE\u0ECF\u0EDA\u0EDB\u0EE0-\u0EFF\u0F01-\u0F17\u0F1A-\u0F1F\u0F2A-\u0F34\u0F36\u0F38\u0F3A-\u0F3D\u0F48\u0F6D-\u0F70\u0F85\u0F98\u0FBD-\u0FC5\u0FC7-\u0FFF\u104A-\u104F\u109E\u109F\u10C6\u10C8-\u10CC\u10CE\u10CF\u10FB\u1249\u124E\u124F\u1257\u1259\u125E\u125F\u1289\u128E\u128F\u12B1\u12B6\u12B7\u12BF\u12C1\u12C6\u12C7\u12D7\u1311\u1316\u1317\u135B\u135C\u1360-\u137F\u1390-\u139F\u13F6\u13F7\u13FE-\u1400\u166D\u166E\u1680\u169B-\u169F\u16EB-\u16ED\u16F9-\u16FF\u170D\u1715-\u171F\u1735-\u173F\u1754-\u175F\u176D\u1771\u1774-\u177F\u17D4-\u17D6\u17D8-\u17DB\u17DE\u17DF\u17EA-\u180A\u180E\u180F\u181A-\u181F\u1879-\u187F\u18AB-\u18AF\u18F6-\u18FF\u191F\u192C-\u192F\u193C-\u1945\u196E\u196F\u1975-\u197F\u19AC-\u19AF\u19CA-\u19CF\u19DA-\u19FF\u1A1C-\u1A1F\u1A5F\u1A7D\u1A7E\u1A8A-\u1A8F\u1A9A-\u1AA6\u1AA8-\u1AAF\u1AC1-\u1AFF\u1B4C-\u1B4F\u1B5A-\u1B6A\u1B74-\u1B7F\u1BF4-\u1BFF\u1C38-\u1C3F\u1C4A-\u1C4C\u1C7E\u1C7F\u1C89-\u1C8F\u1CBB\u1CBC\u1CC0-\u1CCF\u1CD3\u1CFB-\u1CFF\u1DFA\u1F16\u1F17\u1F1E\u1F1F\u1F46\u1F47\u1F4E\u1F4F\u1F58\u1F5A\u1F5C\u1F5E\u1F7E\u1F7F\u1FB5\u1FBD\u1FBF-\u1FC1\u1FC5\u1FCD-\u1FCF\u1FD4\u1FD5\u1FDC-\u1FDF\u1FED-\u1FF1\u1FF5\u1FFD-\u203E\u2041-\u2053\u2055-\u2070\u2072-\u207E\u2080-\u208F\u209D-\u20CF\u20F1-\u2101\u2103-\u2106\u2108\u2109\u2114\u2116-\u2118\u211E-\u2123\u2125\u2127\u2129\u212E\u213A\u213B\u2140-\u2144\u214A-\u214D\u214F-\u215F\u2189-\u24B5\u24EA-\u2BFF\u2C2F\u2C5F\u2CE5-\u2CEA\u2CF4-\u2CFF\u2D26\u2D28-\u2D2C\u2D2E\u2D2F\u2D68-\u2D6E\u2D70-\u2D7E\u2D97-\u2D9F\u2DA7\u2DAF\u2DB7\u2DBF\u2DC7\u2DCF\u2DD7\u2DDF\u2E00-\u2E2E\u2E30-\u3004\u3008-\u3020\u3030\u3036\u3037\u303D-\u3040\u3097\u3098\u309B\u309C\u30A0\u30FB\u3100-\u3104\u3130\u318F-\u319F\u31C0-\u31EF\u3200-\u33FF\u4DC0-\u4DFF\u9FFD-\u9FFF\uA48D-\uA4CF\uA4FE\uA4FF\uA60D-\uA60F\uA62C-\uA63F\uA673\uA67E\uA6F2-\uA716\uA720\uA721\uA789\uA78A\uA7C0\uA7C1\uA7CB-\uA7F4\uA828-\uA82B\uA82D-\uA83F\uA874-\uA87F\uA8C6-\uA8CF\uA8DA-\uA8DF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA954-\uA95F\uA97D-\uA97F\uA9C1-\uA9CE\uA9DA-\uA9DF\uA9FF\uAA37-\uAA3F\uAA4E\uAA4F\uAA5A-\uAA5F\uAA77-\uAA79\uAAC3-\uAADA\uAADE\uAADF\uAAF0\uAAF1\uAAF7-\uAB00\uAB07\uAB08\uAB0F\uAB10\uAB17-\uAB1F\uAB27\uAB2F\uAB5B\uAB6A-\uAB6F\uABEB\uABEE\uABEF\uABFA-\uABFF\uD7A4-\uD7AF\uD7C7-\uD7CA\uD7FC-\uD7FF\uE000-\uF8FF\uFA6E\uFA6F\uFADA-\uFAFF\uFB07-\uFB12\uFB18-\uFB1C\uFB29\uFB37\uFB3D\uFB3F\uFB42\uFB45\uFBB2-\uFBD2\uFD3E-\uFD4F\uFD90\uFD91\uFDC8-\uFDEF\uFDFC-\uFDFF\uFE10-\uFE1F\uFE30-\uFE32\uFE35-\uFE4C\uFE50-\uFE6F\uFE75\uFEFD-\uFF0F\uFF1A-\uFF20\uFF3B-\uFF3E\uFF40\uFF5B-\uFF65\uFFBF-\uFFC1\uFFC8\uFFC9\uFFD0\uFFD1\uFFD8\uFFD9\uFFDD-\uFFFF]|\uD800[\uDC0C\uDC27\uDC3B\uDC3E\uDC4E\uDC4F\uDC5E-\uDC7F\uDCFB-\uDD3F\uDD75-\uDDFC\uDDFE-\uDE7F\uDE9D-\uDE9F\uDED1-\uDEDF\uDEE1-\uDEFF\uDF20-\uDF2C\uDF4B-\uDF4F\uDF7B-\uDF7F\uDF9E\uDF9F\uDFC4-\uDFC7\uDFD0\uDFD6-\uDFFF]|\uD801[\uDC9E\uDC9F\uDCAA-\uDCAF\uDCD4-\uDCD7\uDCFC-\uDCFF\uDD28-\uDD2F\uDD64-\uDDFF\uDF37-\uDF3F\uDF56-\uDF5F\uDF68-\uDFFF]|\uD802[\uDC06\uDC07\uDC09\uDC36\uDC39-\uDC3B\uDC3D\uDC3E\uDC56-\uDC5F\uDC77-\uDC7F\uDC9F-\uDCDF\uDCF3\uDCF6-\uDCFF\uDD16-\uDD1F\uDD3A-\uDD7F\uDDB8-\uDDBD\uDDC0-\uDDFF\uDE04\uDE07-\uDE0B\uDE14\uDE18\uDE36\uDE37\uDE3B-\uDE3E\uDE40-\uDE5F\uDE7D-\uDE7F\uDE9D-\uDEBF\uDEC8\uDEE7-\uDEFF\uDF36-\uDF3F\uDF56-\uDF5F\uDF73-\uDF7F\uDF92-\uDFFF]|\uD803[\uDC49-\uDC7F\uDCB3-\uDCBF\uDCF3-\uDCFF\uDD28-\uDD2F\uDD3A-\uDE7F\uDEAA\uDEAD-\uDEAF\uDEB2-\uDEFF\uDF1D-\uDF26\uDF28-\uDF2F\uDF51-\uDFAF\uDFC5-\uDFDF\uDFF7-\uDFFF]|\uD804[\uDC47-\uDC65\uDC70-\uDC7E\uDCBB-\uDCCF\uDCE9-\uDCEF\uDCFA-\uDCFF\uDD35\uDD40-\uDD43\uDD48-\uDD4F\uDD74\uDD75\uDD77-\uDD7F\uDDC5-\uDDC8\uDDCD\uDDDB\uDDDD-\uDDFF\uDE12\uDE38-\uDE3D\uDE3F-\uDE7F\uDE87\uDE89\uDE8E\uDE9E\uDEA9-\uDEAF\uDEEB-\uDEEF\uDEFA-\uDEFF\uDF04\uDF0D\uDF0E\uDF11\uDF12\uDF29\uDF31\uDF34\uDF3A\uDF45\uDF46\uDF49\uDF4A\uDF4E\uDF4F\uDF51-\uDF56\uDF58-\uDF5C\uDF64\uDF65\uDF6D-\uDF6F\uDF75-\uDFFF]|\uD805[\uDC4B-\uDC4F\uDC5A-\uDC5D\uDC62-\uDC7F\uDCC6\uDCC8-\uDCCF\uDCDA-\uDD7F\uDDB6\uDDB7\uDDC1-\uDDD7\uDDDE-\uDDFF\uDE41-\uDE43\uDE45-\uDE4F\uDE5A-\uDE7F\uDEB9-\uDEBF\uDECA-\uDEFF\uDF1B\uDF1C\uDF2C-\uDF2F\uDF3A-\uDFFF]|\uD806[\uDC3B-\uDC9F\uDCEA-\uDCFE\uDD07\uDD08\uDD0A\uDD0B\uDD14\uDD17\uDD36\uDD39\uDD3A\uDD44-\uDD4F\uDD5A-\uDD9F\uDDA8\uDDA9\uDDD8\uDDD9\uDDE2\uDDE5-\uDDFF\uDE3F-\uDE46\uDE48-\uDE4F\uDE9A-\uDE9C\uDE9E-\uDEBF\uDEF9-\uDFFF]|\uD807[\uDC09\uDC37\uDC41-\uDC4F\uDC5A-\uDC71\uDC90\uDC91\uDCA8\uDCB7-\uDCFF\uDD07\uDD0A\uDD37-\uDD39\uDD3B\uDD3E\uDD48-\uDD4F\uDD5A-\uDD5F\uDD66\uDD69\uDD8F\uDD92\uDD99-\uDD9F\uDDAA-\uDEDF\uDEF7-\uDFAF\uDFB1-\uDFFF]|\uD808[\uDF9A-\uDFFF]|\uD809[\uDC6F-\uDC7F\uDD44-\uDFFF]|[\uD80A\uD80B\uD80E-\uD810\uD812-\uD819\uD824-\uD82B\uD82D\uD82E\uD830-\uD833\uD837\uD839\uD83D\uD83F\uD87B-\uD87D\uD87F\uD885-\uDB3F\uDB41-\uDBFF][\uDC00-\uDFFF]|\uD80D[\uDC2F-\uDFFF]|\uD811[\uDE47-\uDFFF]|\uD81A[\uDE39-\uDE3F\uDE5F\uDE6A-\uDECF\uDEEE\uDEEF\uDEF5-\uDEFF\uDF37-\uDF3F\uDF44-\uDF4F\uDF5A-\uDF62\uDF78-\uDF7C\uDF90-\uDFFF]|\uD81B[\uDC00-\uDE3F\uDE80-\uDEFF\uDF4B-\uDF4E\uDF88-\uDF8E\uDFA0-\uDFDF\uDFE2\uDFE5-\uDFEF\uDFF2-\uDFFF]|\uD821[\uDFF8-\uDFFF]|\uD823[\uDCD6-\uDCFF\uDD09-\uDFFF]|\uD82C[\uDD1F-\uDD4F\uDD53-\uDD63\uDD68-\uDD6F\uDEFC-\uDFFF]|\uD82F[\uDC6B-\uDC6F\uDC7D-\uDC7F\uDC89-\uDC8F\uDC9A-\uDC9C\uDC9F-\uDFFF]|\uD834[\uDC00-\uDD64\uDD6A-\uDD6C\uDD73-\uDD7A\uDD83\uDD84\uDD8C-\uDDA9\uDDAE-\uDE41\uDE45-\uDFFF]|\uD835[\uDC55\uDC9D\uDCA0\uDCA1\uDCA3\uDCA4\uDCA7\uDCA8\uDCAD\uDCBA\uDCBC\uDCC4\uDD06\uDD0B\uDD0C\uDD15\uDD1D\uDD3A\uDD3F\uDD45\uDD47-\uDD49\uDD51\uDEA6\uDEA7\uDEC1\uDEDB\uDEFB\uDF15\uDF35\uDF4F\uDF6F\uDF89\uDFA9\uDFC3\uDFCC\uDFCD]|\uD836[\uDC00-\uDDFF\uDE37-\uDE3A\uDE6D-\uDE74\uDE76-\uDE83\uDE85-\uDE9A\uDEA0\uDEB0-\uDFFF]|\uD838[\uDC07\uDC19\uDC1A\uDC22\uDC25\uDC2B-\uDCFF\uDD2D-\uDD2F\uDD3E\uDD3F\uDD4A-\uDD4D\uDD4F-\uDEBF\uDEFA-\uDFFF]|\uD83A[\uDCC5-\uDCCF\uDCD7-\uDCFF\uDD4C-\uDD4F\uDD5A-\uDFFF]|\uD83B[\uDC00-\uDDFF\uDE04\uDE20\uDE23\uDE25\uDE26\uDE28\uDE33\uDE38\uDE3A\uDE3C-\uDE41\uDE43-\uDE46\uDE48\uDE4A\uDE4C\uDE50\uDE53\uDE55\uDE56\uDE58\uDE5A\uDE5C\uDE5E\uDE60\uDE63\uDE65\uDE66\uDE6B\uDE73\uDE78\uDE7D\uDE7F\uDE8A\uDE9C-\uDEA0\uDEA4\uDEAA\uDEBC-\uDFFF]|\uD83C[\uDC00-\uDD2F\uDD4A-\uDD4F\uDD6A-\uDD6F\uDD8A-\uDFFF]|\uD83E[\uDC00-\uDFEF\uDFFA-\uDFFF]|\uD869[\uDEDE-\uDEFF]|\uD86D[\uDF35-\uDF3F]|\uD86E[\uDC1E\uDC1F]|\uD873[\uDEA2-\uDEAF]|\uD87A[\uDFE1-\uDFFF]|\uD87E[\uDE1E-\uDFFF]|\uD884[\uDF4B-\uDFFF]|\uDB40[\uDC00-\uDCFF\uDDF0-\uDFFF]/g
43317
-
43318
- ;// CONCATENATED MODULE: ../node_modules/github-slugger/index.js
43319
-
43320
-
43321
- const github_slugger_own = Object.hasOwnProperty
43322
-
43323
- /**
43324
- * Slugger.
43325
- */
43326
- class BananaSlug {
43327
- /**
43328
- * Create a new slug class.
43329
- */
43330
- constructor () {
43331
- /** @type {Record<string, number>} */
43332
- // eslint-disable-next-line no-unused-expressions
43333
- this.occurrences
43334
-
43335
- this.reset()
43336
- }
43337
-
43338
- /**
43339
- * Generate a unique slug.
43340
- *
43341
- * Tracks previously generated slugs: repeated calls with the same value
43342
- * will result in different slugs.
43343
- * Use the `slug` function to get same slugs.
43344
- *
43345
- * @param {string} value
43346
- * String of text to slugify
43347
- * @param {boolean} [maintainCase=false]
43348
- * Keep the current case, otherwise make all lowercase
43349
- * @return {string}
43350
- * A unique slug string
43351
- */
43352
- slug (value, maintainCase) {
43353
- const self = this
43354
- let result = slug(value, maintainCase === true)
43355
- const originalSlug = result
43356
-
43357
- while (github_slugger_own.call(self.occurrences, result)) {
43358
- self.occurrences[originalSlug]++
43359
- result = originalSlug + '-' + self.occurrences[originalSlug]
43360
- }
43316
+ // EXTERNAL MODULE: ../node_modules/@uiw/copy-to-clipboard/dist/copy-to-clipboard.umd.js
43317
+ var copy_to_clipboard_umd = __webpack_require__(5028);
43318
+ var copy_to_clipboard_umd_default = /*#__PURE__*/__webpack_require__.n(copy_to_clipboard_umd);
43319
+ ;// CONCATENATED MODULE: ../node_modules/@uiw/react-markdown-preview/esm/plugins/useCopied.js
43361
43320
 
43362
- self.occurrences[result] = 0
43363
43321
 
43364
- return result
43322
+ function getParentElement(target) {
43323
+ if (!target) return null;
43324
+ var dom = target;
43325
+ if (dom.dataset.code && dom.classList.contains('copied')) {
43326
+ return dom;
43365
43327
  }
43366
-
43367
- /**
43368
- * Reset - Forget all previous slugs
43369
- *
43370
- * @return void
43371
- */
43372
- reset () {
43373
- this.occurrences = Object.create(null)
43328
+ if (dom.parentElement) {
43329
+ return getParentElement(dom.parentElement);
43374
43330
  }
43331
+ return null;
43375
43332
  }
43376
-
43377
- /**
43378
- * Generate a slug.
43379
- *
43380
- * Does not track previously generated slugs: repeated calls with the same value
43381
- * will result in the exact same slug.
43382
- * Use the `GithubSlugger` class to get unique slugs.
43383
- *
43384
- * @param {string} value
43385
- * String of text to slugify
43386
- * @param {boolean} [maintainCase=false]
43387
- * Keep the current case, otherwise make all lowercase
43388
- * @return {string}
43389
- * A unique slug string
43390
- */
43391
- function slug (value, maintainCase) {
43392
- if (typeof value !== 'string') return ''
43393
- if (!maintainCase) value = value.toLowerCase()
43394
- return value.replace(regex, '').replace(/ /g, '-')
43333
+ function useCopied(container) {
43334
+ var handle = event => {
43335
+ var target = getParentElement(event.target);
43336
+ if (!target) return;
43337
+ target.classList.add('active');
43338
+ copy_to_clipboard_umd_default()(target.dataset.code, function () {
43339
+ setTimeout(() => {
43340
+ target.classList.remove('active');
43341
+ }, 2000);
43342
+ });
43343
+ };
43344
+ (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(() => {
43345
+ var _container$current, _container$current2;
43346
+ (_container$current = container.current) == null || _container$current.removeEventListener('click', handle, false);
43347
+ (_container$current2 = container.current) == null || _container$current2.addEventListener('click', handle, false);
43348
+ return () => {
43349
+ var _container$current3;
43350
+ (_container$current3 = container.current) == null || _container$current3.removeEventListener('click', handle, false);
43351
+ };
43352
+ // eslint-disable-next-line react-hooks/exhaustive-deps
43353
+ }, [container]);
43395
43354
  }
43355
+ ;// CONCATENATED MODULE: ../node_modules/@uiw/react-markdown-preview/esm/styles/markdown.css
43356
+ // extracted by mini-css-extract-plugin
43357
+ /* harmony default export */ const markdown = ({});
43358
+ // EXTERNAL MODULE: ../node_modules/react/jsx-runtime.js
43359
+ var jsx_runtime = __webpack_require__(4246);
43360
+ ;// CONCATENATED MODULE: ../node_modules/@uiw/react-markdown-preview/esm/preview.js
43396
43361
 
43397
- ;// CONCATENATED MODULE: ../node_modules/hast-util-has-property/lib/index.js
43398
- /**
43399
- * @typedef {import('hast').Root} Root
43400
- * @typedef {import('hast').Content} Content
43401
- */
43402
43362
 
43403
- /**
43404
- * @typedef {Root | Content} Node
43405
- */
43363
+ var _excluded = ["prefixCls", "className", "source", "style", "disableCopy", "skipHtml", "onScroll", "onMouseOver", "pluginsFilter", "rehypeRewrite", "wrapperElement", "warpperElement"];
43406
43364
 
43407
- const hast_util_has_property_lib_own = {}.hasOwnProperty
43408
43365
 
43409
- /**
43410
- * Check if `node`is an element and has a `field` property.
43411
- *
43412
- * @param {unknown} node
43413
- * Thing to check (typically `Element`).
43414
- * @param {unknown} field
43415
- * Field name to check (typically `string`).
43416
- * @returns {boolean}
43417
- * Whether `node` is an element that has a `field` property.
43418
- */
43419
- function hasProperty(node, field) {
43420
- const value =
43421
- typeof field === 'string' &&
43422
- isNode(node) &&
43423
- node.type === 'element' &&
43424
- node.properties &&
43425
- hast_util_has_property_lib_own.call(node.properties, field) &&
43426
- node.properties[field]
43427
43366
 
43428
- return value !== null && value !== undefined && value !== false
43429
- }
43430
43367
 
43431
- /**
43432
- * @param {unknown} value
43433
- * @returns {value is Node}
43434
- */
43435
- function isNode(value) {
43436
- return Boolean(value && typeof value === 'object' && 'type' in value)
43437
- }
43438
43368
 
43439
- ;// CONCATENATED MODULE: ../node_modules/hast-util-heading-rank/lib/index.js
43440
- /**
43441
- * @typedef {import('hast').Root} Root
43442
- * @typedef {import('hast').Content} Content
43443
- */
43444
43369
 
43445
- /**
43446
- * @typedef {Root | Content} Node
43447
- */
43448
43370
 
43449
- // To do next major: return `undefined`.
43450
- /**
43451
- * Get the rank (`1` to `6`) of headings (`h1` to `h6`).
43452
- *
43453
- * @param {Node} node
43454
- * Node to check.
43455
- * @returns {number | null}
43456
- * Rank of the heading or `null` if not a heading.
43457
- */
43458
- function headingRank(node) {
43459
- const name =
43460
- (node && node.type === 'element' && node.tagName.toLowerCase()) || ''
43461
- const code =
43462
- name.length === 2 && name.charCodeAt(0) === 104 /* `h` */
43463
- ? name.charCodeAt(1)
43464
- : 0
43465
- return code > 48 /* `0` */ && code < 55 /* `7` */ ? code - 48 /* `0` */ : null
43466
- }
43467
43371
 
43372
+ /* harmony default export */ const preview = (/*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().forwardRef((props, ref) => {
43373
+ var {
43374
+ prefixCls = 'wmde-markdown wmde-markdown-color',
43375
+ className,
43376
+ source,
43377
+ style,
43378
+ disableCopy = false,
43379
+ skipHtml = true,
43380
+ onScroll,
43381
+ onMouseOver,
43382
+ pluginsFilter,
43383
+ wrapperElement = {},
43384
+ warpperElement = {}
43385
+ } = props,
43386
+ other = _objectWithoutPropertiesLoose(props, _excluded);
43387
+ var mdp = external_root_React_commonjs2_react_commonjs_react_amd_react_default().useRef(null);
43388
+ (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useImperativeHandle)(ref, () => _extends({}, props, {
43389
+ mdp
43390
+ }), [mdp, props]);
43391
+ var cls = (prefixCls || '') + " " + (className || '');
43392
+ useCopied(mdp);
43393
+ var rehypePlugins = [...(other.rehypePlugins || [])];
43394
+ var customProps = {
43395
+ allowElement: (element, index, parent) => {
43396
+ if (other.allowElement) {
43397
+ return other.allowElement(element, index, parent);
43398
+ }
43399
+ return /^[A-Za-z0-9]+$/.test(element.tagName);
43400
+ }
43401
+ };
43402
+ if (skipHtml) {
43403
+ rehypePlugins.push(rehypeRaw);
43404
+ }
43405
+ var remarkPlugins = [...(other.remarkPlugins || []), remarkGfm];
43406
+ var wrapperProps = _extends({}, warpperElement, wrapperElement);
43407
+ return /*#__PURE__*/(0,jsx_runtime.jsx)("div", _extends({
43408
+ ref: mdp,
43409
+ onScroll: onScroll,
43410
+ onMouseOver: onMouseOver
43411
+ }, wrapperProps, {
43412
+ className: cls,
43413
+ style: style,
43414
+ children: /*#__PURE__*/(0,jsx_runtime.jsx)(ReactMarkdown, _extends({}, customProps, other, {
43415
+ skipHtml: skipHtml,
43416
+ rehypePlugins: pluginsFilter ? pluginsFilter('rehype', rehypePlugins) : rehypePlugins,
43417
+ remarkPlugins: pluginsFilter ? pluginsFilter('remark', remarkPlugins) : remarkPlugins,
43418
+ children: source || ''
43419
+ }))
43420
+ }));
43421
+ }));
43468
43422
  ;// CONCATENATED MODULE: ../node_modules/hast-util-to-string/index.js
43469
43423
  /**
43470
43424
  * @fileoverview
@@ -43540,769 +43494,119 @@ function hast_util_to_string_all(node) {
43540
43494
  return result.join('')
43541
43495
  }
43542
43496
 
43543
- ;// CONCATENATED MODULE: ../node_modules/rehype-slug/index.js
43544
- /**
43545
- * @typedef {import('hast').Root} Root
43546
- */
43547
-
43548
- /**
43549
- * @typedef Options
43550
- * Configuration (optional).
43551
- * @property {string} [prefix='']
43552
- * Prefix to add in front of `id`s.
43553
- */
43554
-
43555
-
43556
-
43557
-
43558
-
43559
-
43560
-
43561
- const slugs = new BananaSlug()
43562
-
43563
- /**
43564
- * Plugin to add `id`s to headings.
43565
- *
43566
- * @type {import('unified').Plugin<[Options?]|Array<void>, Root>}
43567
- */
43568
- function rehypeSlug(options = {}) {
43569
- const prefix = options.prefix || ''
43570
-
43571
- return (tree) => {
43572
- slugs.reset()
43573
-
43574
- visit(tree, 'element', (node) => {
43575
- if (headingRank(node) && node.properties && !hasProperty(node, 'id')) {
43576
- node.properties.id = prefix + slugs.slug(hast_util_to_string_toString(node))
43577
- }
43578
- })
43579
- }
43580
- }
43581
-
43582
- ;// CONCATENATED MODULE: ../node_modules/hast-util-is-element/index.js
43497
+ ;// CONCATENATED MODULE: ../node_modules/unist-util-filter/lib/index.js
43583
43498
  /**
43499
+ * @typedef {import('unist').Node} Node
43584
43500
  * @typedef {import('unist').Parent} Parent
43585
- * @typedef {import('hast').Element} Element
43586
- */
43587
-
43588
- /**
43589
- * @typedef {null | undefined | string | TestFunctionAnything | Array<string | TestFunctionAnything>} Test
43590
- * Check for an arbitrary element, unaware of TypeScript inferral.
43501
+ * @typedef {import('unist-util-is').Test} Test
43591
43502
  *
43592
- * @callback TestFunctionAnything
43593
- * Check if an element passes a test, unaware of TypeScript inferral.
43594
- * @param {Element} element
43595
- * An element.
43596
- * @param {number | null | undefined} [index]
43597
- * The element’s position in its parent.
43598
- * @param {Parent | null | undefined} [parent]
43599
- * The element’s parent.
43600
- * @returns {boolean | void}
43601
- * Whether this element passes the test.
43503
+ * @typedef Options
43504
+ * Configuration (optional).
43505
+ * @property {boolean | null | undefined} [cascade=true]
43506
+ * Whether to drop parent nodes if they had children, but all their children
43507
+ * were filtered out.
43602
43508
  */
43603
43509
 
43604
- /**
43605
- * @template {Element} T
43606
- * Element type.
43607
- * @typedef {T['tagName'] | TestFunctionPredicate<T> | Array<T['tagName'] | TestFunctionPredicate<T>>} PredicateTest
43608
- * Check for an element that can be inferred by TypeScript.
43609
- */
43610
43510
 
43611
- /**
43612
- * Check if an element passes a certain node test.
43613
- *
43614
- * @template {Element} T
43615
- * Element type.
43616
- * @callback TestFunctionPredicate
43617
- * Complex test function for an element that can be inferred by TypeScript.
43618
- * @param {Element} element
43619
- * An element.
43620
- * @param {number | null | undefined} [index]
43621
- * The element’s position in its parent.
43622
- * @param {Parent | null | undefined} [parent]
43623
- * The element’s parent.
43624
- * @returns {element is T}
43625
- * Whether this element passes the test.
43626
- */
43627
43511
 
43628
- /**
43629
- * @callback AssertAnything
43630
- * Check that an arbitrary value is an element, unaware of TypeScript inferral.
43631
- * @param {unknown} [node]
43632
- * Anything (typically a node).
43633
- * @param {number | null | undefined} [index]
43634
- * The node’s position in its parent.
43635
- * @param {Parent | null | undefined} [parent]
43636
- * The node’s parent.
43637
- * @returns {boolean}
43638
- * Whether this is an element and passes a test.
43639
- */
43512
+ const unist_util_filter_lib_own = {}.hasOwnProperty
43640
43513
 
43641
43514
  /**
43642
- * Check if a node is an element and passes a certain node test
43515
+ * Create a new `tree` of copies of all nodes that pass `test`.
43643
43516
  *
43644
- * @template {Element} T
43645
- * Element type.
43646
- * @callback AssertPredicate
43647
- * Check that an arbitrary value is a specific element, aware of TypeScript.
43648
- * @param {unknown} [node]
43649
- * Anything (typically a node).
43650
- * @param {number | null | undefined} [index]
43651
- * The node’s position in its parent.
43652
- * @param {Parent | null | undefined} [parent]
43653
- * The node’s parent.
43654
- * @returns {node is T}
43655
- * Whether this is an element and passes a test.
43656
- */
43657
-
43658
- /**
43659
- * Check if `node` is an `Element` and whether it passes the given test.
43517
+ * The tree is walked in *preorder* (NLR), visiting the node itself, then its
43518
+ * head, etc.
43660
43519
  *
43661
- * @param node
43662
- * Thing to check, typically `Node`.
43520
+ * @param tree
43521
+ * Tree to filter.
43522
+ * @param options
43523
+ * Configuration (optional).
43663
43524
  * @param test
43664
- * A check for a specific element.
43665
- * @param index
43666
- * The node’s position in its parent.
43667
- * @param parent
43668
- * The node’s parent.
43525
+ * `unist-util-is` compatible test.
43669
43526
  * @returns
43670
- * Whether `node` is an element and passes a test.
43527
+ * New filtered tree.
43528
+ *
43529
+ * `null` is returned if `tree` itself didn’t pass the test, or is cascaded
43530
+ * away.
43671
43531
  */
43672
- const isElement =
43532
+ const filter =
43673
43533
  /**
43674
43534
  * @type {(
43675
- * (() => false) &
43676
- * (<T extends Element = Element>(node: unknown, test?: PredicateTest<T>, index?: number, parent?: Parent, context?: unknown) => node is T) &
43677
- * ((node: unknown, test: Test, index?: number, parent?: Parent, context?: unknown) => boolean)
43535
+ * (<Tree extends Node, Check extends Test>(node: Tree, options: Options | null | undefined, test: Check | null | undefined) => import('./complex-types.js').Matches<Tree, Check>) &
43536
+ * (<Tree extends Node, Check extends Test>(node: Tree, test: Check) => import('./complex-types.js').Matches<Tree, Check>) &
43537
+ * (<Tree extends Node>(node: Tree, options?: Options | null | undefined) => Tree)
43678
43538
  * )}
43679
43539
  */
43680
43540
  (
43681
43541
  /**
43682
- * @param {unknown} [node]
43683
- * @param {Test | undefined} [test]
43684
- * @param {number | null | undefined} [index]
43685
- * @param {Parent | null | undefined} [parent]
43686
- * @param {unknown} [context]
43687
- * @returns {boolean}
43542
+ * @param {Node} tree
43543
+ * @param {Options | Test | null | undefined} [options]
43544
+ * @param {Test | null | undefined} [test]
43545
+ * @returns {Node | null}
43688
43546
  */
43689
- // eslint-disable-next-line max-params
43690
- function (node, test, index, parent, context) {
43691
- const check = convertElement(test)
43547
+ function (tree, options, test) {
43548
+ const is = convert(test || options)
43549
+ /** @type {boolean | null | undefined} */
43550
+ const cascadeRaw =
43551
+ options && typeof options === 'object' && 'cascade' in options
43552
+ ? /** @type {boolean | null | undefined} */ (options.cascade)
43553
+ : undefined
43554
+ const cascade =
43555
+ cascadeRaw === undefined || cascadeRaw === null ? true : cascadeRaw
43692
43556
 
43693
- if (
43694
- index !== undefined &&
43695
- index !== null &&
43696
- (typeof index !== 'number' ||
43697
- index < 0 ||
43698
- index === Number.POSITIVE_INFINITY)
43699
- ) {
43700
- throw new Error('Expected positive finite index for child node')
43701
- }
43557
+ return preorder(tree)
43702
43558
 
43703
- if (
43704
- parent !== undefined &&
43705
- parent !== null &&
43706
- (!parent.type || !parent.children)
43707
- ) {
43708
- throw new Error('Expected parent node')
43709
- }
43559
+ /**
43560
+ * @param {Node} node
43561
+ * Current node.
43562
+ * @param {number | undefined} [index]
43563
+ * Index of `node` in `parent`.
43564
+ * @param {Parent | undefined} [parent]
43565
+ * Parent node.
43566
+ * @returns {Node | null}
43567
+ * Shallow copy of `node`.
43568
+ */
43569
+ function preorder(node, index, parent) {
43570
+ /** @type {Array<Node>} */
43571
+ const children = []
43710
43572
 
43711
- // @ts-expect-error Looks like a node.
43712
- if (!node || !node.type || typeof node.type !== 'string') {
43713
- return false
43714
- }
43573
+ if (!is(node, index, parent)) return null
43715
43574
 
43716
- if (
43717
- (parent === undefined || parent === null) !==
43718
- (index === undefined || index === null)
43719
- ) {
43720
- throw new Error('Expected both parent and index')
43721
- }
43575
+ // @ts-expect-error: Looks like a parent.
43576
+ if (node.children) {
43577
+ let childIndex = -1
43722
43578
 
43723
- return check.call(context, node, index, parent)
43724
- }
43725
- )
43579
+ // @ts-expect-error Looks like a parent.
43580
+ while (++childIndex < node.children.length) {
43581
+ // @ts-expect-error Looks like a parent.
43582
+ const result = preorder(node.children[childIndex], childIndex, node)
43726
43583
 
43727
- /**
43728
- * Generate an assertion from a test.
43729
- *
43730
- * Useful if you’re going to test many nodes, for example when creating a
43731
- * utility where something else passes a compatible test.
43732
- *
43733
- * The created function is a bit faster because it expects valid input only:
43734
- * a `node`, `index`, and `parent`.
43735
- *
43736
- * @param test
43737
- * * When nullish, checks if `node` is an `Element`.
43738
- * * When `string`, works like passing `(element) => element.tagName === test`.
43739
- * * When `function` checks if function passed the element is true.
43740
- * * When `array`, checks any one of the subtests pass.
43741
- * @returns
43742
- * An assertion.
43743
- */
43744
- const convertElement =
43745
- /**
43746
- * @type {(
43747
- * (<T extends Element>(test: T['tagName'] | TestFunctionPredicate<T>) => AssertPredicate<T>) &
43748
- * ((test?: Test) => AssertAnything)
43749
- * )}
43750
- */
43751
- (
43752
- /**
43753
- * @param {Test | null | undefined} [test]
43754
- * @returns {AssertAnything}
43755
- */
43756
- function (test) {
43757
- if (test === undefined || test === null) {
43758
- return hast_util_is_element_element
43759
- }
43584
+ if (result) {
43585
+ children.push(result)
43586
+ }
43587
+ }
43760
43588
 
43761
- if (typeof test === 'string') {
43762
- return tagNameFactory(test)
43763
- }
43589
+ // @ts-expect-error Looks like a parent.
43590
+ if (cascade && node.children.length > 0 && children.length === 0)
43591
+ return null
43592
+ }
43764
43593
 
43765
- if (typeof test === 'object') {
43766
- return hast_util_is_element_anyFactory(test)
43767
- }
43594
+ // Create a shallow clone, using the new children.
43595
+ /** @type {typeof node} */
43596
+ // @ts-expect-error all the fields will be copied over.
43597
+ const next = {}
43598
+ /** @type {string} */
43599
+ let key
43768
43600
 
43769
- if (typeof test === 'function') {
43770
- return hast_util_is_element_castFactory(test)
43771
- }
43601
+ for (key in node) {
43602
+ if (unist_util_filter_lib_own.call(node, key)) {
43603
+ // @ts-expect-error: Looks like a record.
43604
+ next[key] = key === 'children' ? children : node[key]
43605
+ }
43606
+ }
43772
43607
 
43773
- throw new Error('Expected function, string, or array as test')
43774
- }
43775
- )
43776
-
43777
- /**
43778
- * Handle multiple tests.
43779
- *
43780
- * @param {Array<string | TestFunctionAnything>} tests
43781
- * @returns {AssertAnything}
43782
- */
43783
- function hast_util_is_element_anyFactory(tests) {
43784
- /** @type {Array<AssertAnything>} */
43785
- const checks = []
43786
- let index = -1
43787
-
43788
- while (++index < tests.length) {
43789
- checks[index] = convertElement(tests[index])
43790
- }
43791
-
43792
- return hast_util_is_element_castFactory(any)
43793
-
43794
- /**
43795
- * @this {unknown}
43796
- * @param {Array<unknown>} parameters
43797
- * @returns {boolean}
43798
- */
43799
- function any(...parameters) {
43800
- let index = -1
43801
-
43802
- while (++index < checks.length) {
43803
- if (checks[index].call(this, ...parameters)) {
43804
- return true
43805
- }
43806
- }
43807
-
43808
- return false
43809
- }
43810
- }
43811
-
43812
- /**
43813
- * Turn a string into a test for an element with a certain tag name.
43814
- *
43815
- * @param {string} check
43816
- * @returns {AssertAnything}
43817
- */
43818
- function tagNameFactory(check) {
43819
- return tagName
43820
-
43821
- /**
43822
- * @param {unknown} node
43823
- * @returns {boolean}
43824
- */
43825
- function tagName(node) {
43826
- return hast_util_is_element_element(node) && node.tagName === check
43827
- }
43828
- }
43829
-
43830
- /**
43831
- * Turn a custom test into a test for an element that passes that test.
43832
- *
43833
- * @param {TestFunctionAnything} check
43834
- * @returns {AssertAnything}
43835
- */
43836
- function hast_util_is_element_castFactory(check) {
43837
- return assertion
43838
-
43839
- /**
43840
- * @this {unknown}
43841
- * @param {unknown} node
43842
- * @param {Array<unknown>} parameters
43843
- * @returns {boolean}
43844
- */
43845
- function assertion(node, ...parameters) {
43846
- // @ts-expect-error: fine.
43847
- return hast_util_is_element_element(node) && Boolean(check.call(this, node, ...parameters))
43848
- }
43849
- }
43850
-
43851
- /**
43852
- * Make sure something is an element.
43853
- *
43854
- * @param {unknown} node
43855
- * @returns {node is Element}
43856
- */
43857
- function hast_util_is_element_element(node) {
43858
- return Boolean(
43859
- node &&
43860
- typeof node === 'object' &&
43861
- // @ts-expect-error Looks like a node.
43862
- node.type === 'element' &&
43863
- // @ts-expect-error Looks like an element.
43864
- typeof node.tagName === 'string'
43865
- )
43866
- }
43867
-
43868
- ;// CONCATENATED MODULE: ../node_modules/rehype-autolink-headings/lib/index.js
43869
- /**
43870
- * @typedef {import('hast').Root} Root
43871
- * @typedef {import('hast').Parent} Parent
43872
- * @typedef {import('hast').Element} Element
43873
- * @typedef {Element['children'][number]} ElementChild
43874
- * @typedef {import('hast').Properties} Properties
43875
- * @typedef {import('hast-util-is-element').Test} Test
43876
- *
43877
- * @typedef {'prepend'|'append'|'wrap'|'before'|'after'} Behavior
43878
- *
43879
- * @callback Build
43880
- * @param {Element} node
43881
- * @returns {ElementChild|ElementChild[]}
43882
- *
43883
- * @typedef Options
43884
- * Configuration.
43885
- * @property {Behavior} [behavior='prepend']
43886
- * How to create links.
43887
- * @property {Behavior} [behaviour]
43888
- * Please use `behavior` instead
43889
- * @property {Properties} [properties]
43890
- * Extra properties to set on the link when injecting.
43891
- * Defaults to `{ariaHidden: true, tabIndex: -1}` when `'prepend'` or
43892
- * `'append'`.
43893
- * @property {ElementChild|ElementChild[]|Build} [content={type: 'element', tagName: 'span', properties: {className: ['icon', 'icon-link']}, children: []}]
43894
- * hast nodes to insert in the link.
43895
- * @property {ElementChild|ElementChild[]|Build} [group]
43896
- * hast node to wrap the heading and link with, if `behavior` is `'before'` or
43897
- * `'after'`.
43898
- * There is no default.
43899
- * @property {Test} [test]
43900
- * Test to define which heading elements are linked.
43901
- * Any test that can be given to `hast-util-is-element` is supported.
43902
- * The default (no test) is to link all headings.
43903
- * Can be used to link only h1-h3, or for example all except h1.
43904
- */
43905
-
43906
-
43907
-
43908
-
43909
-
43910
-
43911
-
43912
- /** @type {Element} */
43913
- const contentDefaults = {
43914
- type: 'element',
43915
- tagName: 'span',
43916
- properties: {className: ['icon', 'icon-link']},
43917
- children: []
43918
- }
43919
-
43920
- /**
43921
- * Plugin to automatically add links to headings (h1-h6).
43922
- *
43923
- * @type {import('unified').Plugin<[Options?]|void[], Root>}
43924
- */
43925
- function rehypeAutolinkHeadings(options = {}) {
43926
- let props = options.properties
43927
- const behavior = options.behaviour || options.behavior || 'prepend'
43928
- const content = options.content || contentDefaults
43929
- const group = options.group
43930
- const is = convertElement(options.test)
43931
-
43932
- /** @type {import('unist-util-visit/complex-types').Visitor<Element>} */
43933
- let method
43934
-
43935
- if (behavior === 'wrap') {
43936
- method = wrap
43937
- } else if (behavior === 'before' || behavior === 'after') {
43938
- method = around
43939
- } else {
43940
- if (!props) {
43941
- props = {ariaHidden: 'true', tabIndex: -1}
43942
- }
43943
-
43944
- method = inject
43945
- }
43946
-
43947
- return (tree) => {
43948
- visit(tree, 'element', (node, index, parent) => {
43949
- if (
43950
- headingRank(node) &&
43951
- hasProperty(node, 'id') &&
43952
- is(node, index, parent)
43953
- ) {
43954
- return method(node, index, parent)
43955
- }
43956
- })
43957
- }
43958
-
43959
- /** @type {import('unist-util-visit/complex-types').Visitor<Element>} */
43960
- function inject(node) {
43961
- node.children[behavior === 'prepend' ? 'unshift' : 'push'](
43962
- create(node, extend(true, {}, props), toChildren(content, node))
43963
- )
43964
-
43965
- return [SKIP]
43966
- }
43967
-
43968
- /** @type {import('unist-util-visit/complex-types').Visitor<Element>} */
43969
- function around(node, index, parent) {
43970
- // Uncommon.
43971
- /* c8 ignore next */
43972
- if (typeof index !== 'number' || !parent) return
43973
-
43974
- const link = create(
43975
- node,
43976
- extend(true, {}, props),
43977
- toChildren(content, node)
43978
- )
43979
- let nodes = behavior === 'before' ? [link, node] : [node, link]
43980
-
43981
- if (group) {
43982
- const grouping = toNode(group, node)
43983
-
43984
- if (grouping && !Array.isArray(grouping) && grouping.type === 'element') {
43985
- grouping.children = nodes
43986
- nodes = [grouping]
43987
- }
43988
- }
43989
-
43990
- parent.children.splice(index, 1, ...nodes)
43991
-
43992
- return [SKIP, index + nodes.length]
43993
- }
43994
-
43995
- /** @type {import('unist-util-visit/complex-types').Visitor<Element>} */
43996
- function wrap(node) {
43997
- node.children = [create(node, extend(true, {}, props), node.children)]
43998
- return [SKIP]
43999
- }
44000
-
44001
- /**
44002
- * @param {ElementChild|ElementChild[]|Build} value
44003
- * @param {Element} node
44004
- * @returns {ElementChild[]}
44005
- */
44006
- function toChildren(value, node) {
44007
- const result = toNode(value, node)
44008
- return Array.isArray(result) ? result : [result]
44009
- }
44010
-
44011
- /**
44012
- * @param {ElementChild|ElementChild[]|Build} value
44013
- * @param {Element} node
44014
- * @returns {ElementChild|ElementChild[]}
44015
- */
44016
- function toNode(value, node) {
44017
- if (typeof value === 'function') return value(node)
44018
- return extend(true, Array.isArray(value) ? [] : {}, value)
44019
- }
44020
-
44021
- /**
44022
- * @param {Element} node
44023
- * @param {Properties} props
44024
- * @param {ElementChild[]} children
44025
- * @returns {Element}
44026
- */
44027
- function create(node, props, children) {
44028
- return {
44029
- type: 'element',
44030
- tagName: 'a',
44031
- properties: Object.assign({}, props, {
44032
- // Fix hast types and make them required.
44033
- /* c8 ignore next */
44034
- href: '#' + (node.properties || {}).id
44035
- }),
44036
- children
44037
- }
44038
- }
44039
- }
44040
-
44041
- ;// CONCATENATED MODULE: ../node_modules/rehype-attr/lib/utils.js
44042
- const getURLParameters = (url = '') => (url.match(/([^?=&]+)(=([^&]*))/g) || []).reduce((a, v) => ((a[v.slice(0, v.indexOf('='))] = v.slice(v.indexOf('=') + 1)), a), {});
44043
- const prevChild = (data = [], index) => {
44044
- let i = index;
44045
- while (i > -1) {
44046
- i--;
44047
- if (!data[i])
44048
- return;
44049
- if ((data[i] && data[i].value && data[i].value.replace(/(\n|\s)/g, '') !== '') || data[i].type !== 'text') {
44050
- if (!/^rehype:/.test(data[i].value) || data[i].type !== 'comment')
44051
- return;
44052
- return data[i];
44053
- }
44054
- }
44055
- return;
44056
- };
44057
- const nextChild = (data = [], index, tagName, codeBlockParames) => {
44058
- let i = index;
44059
- while (i < data.length) {
44060
- i++;
44061
- if (tagName) {
44062
- const element = data[i];
44063
- if (element && element.value && element.value.replace(/(\n|\s)/g, '') !== '' || data[i] && data[i].type === 'element') {
44064
- return element.tagName === tagName ? element : undefined;
44065
- }
44066
- }
44067
- else {
44068
- const element = data[i];
44069
- if (!element || element.type === 'element')
44070
- return;
44071
- if (element.type === 'text' && element.value.replace(/(\n|\s)/g, '') !== '')
44072
- return;
44073
- if (element.type && /^(comment|raw)$/ig.test(element.type)) {
44074
- if (element.value && !/^rehype:/.test(element.value.replace(/^(\s+)?<!--(.*?)-->/, '$2') || '')) {
44075
- return;
44076
- }
44077
- ;
44078
- if (codeBlockParames) {
44079
- const nextNode = nextChild(data, i, 'pre', codeBlockParames);
44080
- if (nextNode)
44081
- return;
44082
- element.value = (element.value || '').replace(/^(\n|\s)+/, '');
44083
- return element;
44084
- }
44085
- else {
44086
- element.value = (element.value || '').replace(/^(\n|\s)+/, '');
44087
- return element;
44088
- }
44089
- }
44090
- }
44091
- }
44092
- return;
44093
- };
44094
- /**
44095
- * 获取代码注视的位置
44096
- * @param data 数据
44097
- * @param index 当前数据所在的位置
44098
- * @returns 返回 当前参数数据 Object,`{}`
44099
- */
44100
- const getCommentObject = ({ value = '' }) => {
44101
- const param = getURLParameters(value.replace(/^<!--(.*?)-->/, '$1').replace(/^rehype:/, ''));
44102
- Object.keys(param).forEach((keyName) => {
44103
- if (param[keyName] === 'true') {
44104
- param[keyName] = true;
44105
- }
44106
- if (param[keyName] === 'false') {
44107
- param[keyName] = false;
44108
- }
44109
- if (typeof param[keyName] === 'string' && !/^0/.test(param[keyName]) && !isNaN(+param[keyName])) {
44110
- param[keyName] = +param[keyName];
44111
- }
44112
- });
44113
- return param;
44114
- };
44115
- const propertiesHandle = (defaultAttrs, attrs, type) => {
44116
- if (type === 'string') {
44117
- return { ...defaultAttrs, 'data-config': JSON.stringify({ ...attrs, rehyp: true }) };
44118
- }
44119
- else if (type === 'attr') {
44120
- return { ...defaultAttrs, ...attrs };
44121
- }
44122
- return { ...defaultAttrs, 'data-config': { ...attrs, rehyp: true } };
44123
- };
44124
- //# sourceMappingURL=utils.js.map
44125
- ;// CONCATENATED MODULE: ../node_modules/rehype-attr/lib/index.js
44126
-
44127
-
44128
- const rehypeAttrs = (options = {}) => {
44129
- const { properties = 'data', codeBlockParames = true } = options;
44130
- return (tree) => {
44131
- visit(tree, 'element', (node, index, parent) => {
44132
- if (codeBlockParames && node.tagName === 'pre' && node && Array.isArray(node.children) && parent && Array.isArray(parent.children) && parent.children.length > 1) {
44133
- const firstChild = node.children[0];
44134
- if (firstChild && firstChild.tagName === 'code' && typeof index === 'number') {
44135
- const child = prevChild(parent.children, index);
44136
- if (child) {
44137
- const attr = getCommentObject(child);
44138
- if (Object.keys(attr).length > 0) {
44139
- node.properties = { ...node.properties, ...{ 'data-type': 'rehyp' } };
44140
- firstChild.properties = propertiesHandle(firstChild.properties, attr, properties);
44141
- }
44142
- }
44143
- }
44144
- }
44145
- if (/^(em|strong|b|a|i|p|pre|kbd|blockquote|h(1|2|3|4|5|6)|code|table|img|del|ul|ol)$/.test(node.tagName) && parent && Array.isArray(parent.children) && typeof index === 'number') {
44146
- const child = nextChild(parent.children, index, '', codeBlockParames);
44147
- if (child) {
44148
- const attr = getCommentObject(child);
44149
- if (Object.keys(attr).length > 0) {
44150
- node.properties = propertiesHandle(node.properties, attr, properties);
44151
- }
44152
- }
44153
- }
44154
- });
44155
- };
44156
- };
44157
- /* harmony default export */ const rehype_attr_lib = (rehypeAttrs);
44158
- //# sourceMappingURL=index.js.map
44159
- ;// CONCATENATED MODULE: ../node_modules/rehype-ignore/lib/index.js
44160
-
44161
- const rehypeIgnore = (options = {}) => {
44162
- const { openDelimiter = 'rehype:ignore:start', closeDelimiter = 'rehype:ignore:end' } = options;
44163
- return (tree) => {
44164
- visit(tree, (node, index, parent) => {
44165
- if (node.type === 'element' || node.type === 'root') {
44166
- // const start = node.children.findIndex((item) => item.type === 'comment' && item.value === openDelimiter);
44167
- // const end = node.children.findIndex((item) => item.type === 'comment' && item.value === closeDelimiter);
44168
- // if (start > -1 && end > -1) {
44169
- // node.children = node.children.filter((_, idx) => idx < start || idx > end);
44170
- // }
44171
- let start = false;
44172
- node.children = node.children.filter((item) => {
44173
- if (item.type === 'raw' || item.type === 'comment') {
44174
- let str = (item.value || '').trim();
44175
- str = str.replace(/^<!--(.*?)-->/, '$1');
44176
- if (str === openDelimiter) {
44177
- start = true;
44178
- return false;
44179
- }
44180
- if (str === closeDelimiter) {
44181
- start = false;
44182
- return false;
44183
- }
44184
- }
44185
- return !start;
44186
- });
44187
- }
44188
- });
44189
- };
44190
- };
44191
- /* harmony default export */ const rehype_ignore_lib = (rehypeIgnore);
44192
- //# sourceMappingURL=index.js.map
44193
- ;// CONCATENATED MODULE: ../node_modules/unist-util-filter/lib/index.js
44194
- /**
44195
- * @typedef {import('unist').Node} Node
44196
- * @typedef {import('unist').Parent} Parent
44197
- * @typedef {import('unist-util-is').Test} Test
44198
- *
44199
- * @typedef Options
44200
- * Configuration (optional).
44201
- * @property {boolean | null | undefined} [cascade=true]
44202
- * Whether to drop parent nodes if they had children, but all their children
44203
- * were filtered out.
44204
- */
44205
-
44206
-
44207
-
44208
- const unist_util_filter_lib_own = {}.hasOwnProperty
44209
-
44210
- /**
44211
- * Create a new `tree` of copies of all nodes that pass `test`.
44212
- *
44213
- * The tree is walked in *preorder* (NLR), visiting the node itself, then its
44214
- * head, etc.
44215
- *
44216
- * @param tree
44217
- * Tree to filter.
44218
- * @param options
44219
- * Configuration (optional).
44220
- * @param test
44221
- * `unist-util-is` compatible test.
44222
- * @returns
44223
- * New filtered tree.
44224
- *
44225
- * `null` is returned if `tree` itself didn’t pass the test, or is cascaded
44226
- * away.
44227
- */
44228
- const filter =
44229
- /**
44230
- * @type {(
44231
- * (<Tree extends Node, Check extends Test>(node: Tree, options: Options | null | undefined, test: Check | null | undefined) => import('./complex-types.js').Matches<Tree, Check>) &
44232
- * (<Tree extends Node, Check extends Test>(node: Tree, test: Check) => import('./complex-types.js').Matches<Tree, Check>) &
44233
- * (<Tree extends Node>(node: Tree, options?: Options | null | undefined) => Tree)
44234
- * )}
44235
- */
44236
- (
44237
- /**
44238
- * @param {Node} tree
44239
- * @param {Options | Test | null | undefined} [options]
44240
- * @param {Test | null | undefined} [test]
44241
- * @returns {Node | null}
44242
- */
44243
- function (tree, options, test) {
44244
- const is = convert(test || options)
44245
- /** @type {boolean | null | undefined} */
44246
- const cascadeRaw =
44247
- options && typeof options === 'object' && 'cascade' in options
44248
- ? /** @type {boolean | null | undefined} */ (options.cascade)
44249
- : undefined
44250
- const cascade =
44251
- cascadeRaw === undefined || cascadeRaw === null ? true : cascadeRaw
44252
-
44253
- return preorder(tree)
44254
-
44255
- /**
44256
- * @param {Node} node
44257
- * Current node.
44258
- * @param {number | undefined} [index]
44259
- * Index of `node` in `parent`.
44260
- * @param {Parent | undefined} [parent]
44261
- * Parent node.
44262
- * @returns {Node | null}
44263
- * Shallow copy of `node`.
44264
- */
44265
- function preorder(node, index, parent) {
44266
- /** @type {Array<Node>} */
44267
- const children = []
44268
-
44269
- if (!is(node, index, parent)) return null
44270
-
44271
- // @ts-expect-error: Looks like a parent.
44272
- if (node.children) {
44273
- let childIndex = -1
44274
-
44275
- // @ts-expect-error Looks like a parent.
44276
- while (++childIndex < node.children.length) {
44277
- // @ts-expect-error Looks like a parent.
44278
- const result = preorder(node.children[childIndex], childIndex, node)
44279
-
44280
- if (result) {
44281
- children.push(result)
44282
- }
44283
- }
44284
-
44285
- // @ts-expect-error Looks like a parent.
44286
- if (cascade && node.children.length > 0 && children.length === 0)
44287
- return null
44288
- }
44289
-
44290
- // Create a shallow clone, using the new children.
44291
- /** @type {typeof node} */
44292
- // @ts-expect-error all the fields will be copied over.
44293
- const next = {}
44294
- /** @type {string} */
44295
- let key
44296
-
44297
- for (key in node) {
44298
- if (unist_util_filter_lib_own.call(node, key)) {
44299
- // @ts-expect-error: Looks like a record.
44300
- next[key] = key === 'children' ? children : node[key]
44301
- }
44302
- }
44303
-
44304
- return next
44305
- }
43608
+ return next
43609
+ }
44306
43610
  }
44307
43611
  )
44308
43612
 
@@ -45944,11 +45248,11 @@ function java(Prism) {
45944
45248
 
45945
45249
  ;// CONCATENATED MODULE: ../node_modules/refractor/lang/regex.js
45946
45250
  // @ts-nocheck
45947
- regex_regex.displayName = 'regex'
45948
- regex_regex.aliases = []
45251
+ regex.displayName = 'regex'
45252
+ regex.aliases = []
45949
45253
 
45950
45254
  /** @type {import('../core.js').Syntax} */
45951
- function regex_regex(Prism) {
45255
+ function regex(Prism) {
45952
45256
  ;(function (Prism) {
45953
45257
  var specialEscape = {
45954
45258
  pattern: /\\[\\(){}[\]^$+*?|.]/,
@@ -46645,11 +45949,11 @@ function yaml(Prism) {
46645
45949
  ;// CONCATENATED MODULE: ../node_modules/refractor/lang/markdown.js
46646
45950
  // @ts-nocheck
46647
45951
 
46648
- markdown.displayName = 'markdown'
46649
- markdown.aliases = ['md']
45952
+ markdown_markdown.displayName = 'markdown'
45953
+ markdown_markdown.aliases = ['md']
46650
45954
 
46651
45955
  /** @type {import('../core.js').Syntax} */
46652
- function markdown(Prism) {
45956
+ function markdown_markdown(Prism) {
46653
45957
  Prism.register(markup)
46654
45958
  ;(function (Prism) {
46655
45959
  // Allow only one line break
@@ -50518,7 +49822,7 @@ refractor.register(diff)
50518
49822
  refractor.register(go)
50519
49823
  refractor.register(ini)
50520
49824
  refractor.register(java)
50521
- refractor.register(regex_regex)
49825
+ refractor.register(regex)
50522
49826
  refractor.register(javascript)
50523
49827
  refractor.register(json)
50524
49828
  refractor.register(kotlin)
@@ -50526,7 +49830,7 @@ refractor.register(less)
50526
49830
  refractor.register(lua)
50527
49831
  refractor.register(makefile)
50528
49832
  refractor.register(yaml)
50529
- refractor.register(markdown)
49833
+ refractor.register(markdown_markdown)
50530
49834
  refractor.register(objectivec)
50531
49835
  refractor.register(perl)
50532
49836
  refractor.register(markupTemplating)
@@ -70934,7 +70238,7 @@ function zig(Prism) {
70934
70238
  refractor.register(markup)
70935
70239
  refractor.register(css)
70936
70240
  refractor.register(clike)
70937
- refractor.register(regex_regex)
70241
+ refractor.register(regex)
70938
70242
  refractor.register(javascript)
70939
70243
  refractor.register(abap)
70940
70244
  refractor.register(abnf)
@@ -70956,7 +70260,7 @@ refractor.register(arff)
70956
70260
  refractor.register(armasm)
70957
70261
  refractor.register(bash)
70958
70262
  refractor.register(yaml)
70959
- refractor.register(markdown)
70263
+ refractor.register(markdown_markdown)
70960
70264
  refractor.register(arturo)
70961
70265
  refractor.register(asciidoc)
70962
70266
  refractor.register(csharp)
@@ -71415,6 +70719,48 @@ function dirProperty(node) {
71415
70719
  : undefined
71416
70720
  }
71417
70721
 
70722
+ ;// CONCATENATED MODULE: ../node_modules/hast-util-has-property/lib/index.js
70723
+ /**
70724
+ * @typedef {import('hast').Root} Root
70725
+ * @typedef {import('hast').Content} Content
70726
+ */
70727
+
70728
+ /**
70729
+ * @typedef {Root | Content} Node
70730
+ */
70731
+
70732
+ const hast_util_has_property_lib_own = {}.hasOwnProperty
70733
+
70734
+ /**
70735
+ * Check if `node`is an element and has a `field` property.
70736
+ *
70737
+ * @param {unknown} node
70738
+ * Thing to check (typically `Element`).
70739
+ * @param {unknown} field
70740
+ * Field name to check (typically `string`).
70741
+ * @returns {boolean}
70742
+ * Whether `node` is an element that has a `field` property.
70743
+ */
70744
+ function hasProperty(node, field) {
70745
+ const value =
70746
+ typeof field === 'string' &&
70747
+ isNode(node) &&
70748
+ node.type === 'element' &&
70749
+ node.properties &&
70750
+ hast_util_has_property_lib_own.call(node.properties, field) &&
70751
+ node.properties[field]
70752
+
70753
+ return value !== null && value !== undefined && value !== false
70754
+ }
70755
+
70756
+ /**
70757
+ * @param {unknown} value
70758
+ * @returns {value is Node}
70759
+ */
70760
+ function isNode(value) {
70761
+ return Boolean(value && typeof value === 'object' && 'type' in value)
70762
+ }
70763
+
71418
70764
  ;// CONCATENATED MODULE: ../node_modules/hast-util-select/lib/attribute.js
71419
70765
  /**
71420
70766
  * @typedef {import('./types.js').Rule} Rule
@@ -72295,553 +71641,1319 @@ function pseudo(query, element, index, parent, state) {
72295
71641
  }
72296
71642
 
72297
71643
  /**
72298
- * Check whether an element matches an `:any-link` pseudo.
71644
+ * Check whether an element matches an `:any-link` pseudo.
71645
+ *
71646
+ * @param {RulePseudo} _
71647
+ * @param {Element} element
71648
+ * @returns {boolean}
71649
+ */
71650
+ function anyLink(_, element) {
71651
+ return (
71652
+ (element.tagName === 'a' ||
71653
+ element.tagName === 'area' ||
71654
+ element.tagName === 'link') &&
71655
+ hasProperty(element, 'href')
71656
+ )
71657
+ }
71658
+
71659
+ /**
71660
+ * Check whether an element matches a `:blank` pseudo.
71661
+ *
71662
+ * @param {RulePseudo} _
71663
+ * @param {Element} element
71664
+ * @returns {boolean}
71665
+ */
71666
+ function blank(_, element) {
71667
+ return !someChildren(element, check)
71668
+
71669
+ /**
71670
+ * @param {ElementChild} child
71671
+ * @returns {boolean}
71672
+ */
71673
+ function check(child) {
71674
+ return (
71675
+ child.type === 'element' || (child.type === 'text' && !whitespace(child))
71676
+ )
71677
+ }
71678
+ }
71679
+
71680
+ /**
71681
+ * Check whether an element matches a `:checked` pseudo.
71682
+ *
71683
+ * @param {RulePseudo} _
71684
+ * @param {Element} element
71685
+ * @returns {boolean}
71686
+ */
71687
+ function checked(_, element) {
71688
+ if (element.tagName === 'input' || element.tagName === 'menuitem') {
71689
+ return Boolean(
71690
+ element.properties &&
71691
+ (element.properties.type === 'checkbox' ||
71692
+ element.properties.type === 'radio') &&
71693
+ hasProperty(element, 'checked')
71694
+ )
71695
+ }
71696
+
71697
+ if (element.tagName === 'option') {
71698
+ return hasProperty(element, 'selected')
71699
+ }
71700
+
71701
+ return false
71702
+ }
71703
+
71704
+ /**
71705
+ * Check whether an element matches a `:dir()` pseudo.
71706
+ *
71707
+ * @param {RulePseudo} query
71708
+ * @param {Element} _1
71709
+ * @param {number | undefined} _2
71710
+ * @param {Parent | undefined} _3
71711
+ * @param {SelectState} state
71712
+ * @returns {boolean}
71713
+ */
71714
+ function dir(query, _1, _2, _3, state) {
71715
+ return state.direction === query.value
71716
+ }
71717
+
71718
+ /**
71719
+ * Check whether an element matches a `:disabled` pseudo.
71720
+ *
71721
+ * @param {RulePseudo} _
71722
+ * @param {Element} element
71723
+ * @returns {boolean}
71724
+ */
71725
+ function disabled(_, element) {
71726
+ return (
71727
+ (element.tagName === 'button' ||
71728
+ element.tagName === 'input' ||
71729
+ element.tagName === 'select' ||
71730
+ element.tagName === 'textarea' ||
71731
+ element.tagName === 'optgroup' ||
71732
+ element.tagName === 'option' ||
71733
+ element.tagName === 'menuitem' ||
71734
+ element.tagName === 'fieldset') &&
71735
+ hasProperty(element, 'disabled')
71736
+ )
71737
+ }
71738
+
71739
+ /**
71740
+ * Check whether an element matches an `:empty` pseudo.
71741
+ *
71742
+ * @param {RulePseudo} _
71743
+ * @param {Element} element
71744
+ * @returns {boolean}
71745
+ */
71746
+ function empty(_, element) {
71747
+ return !someChildren(element, check)
71748
+
71749
+ /**
71750
+ * @param {ElementChild} child
71751
+ * @returns {boolean}
71752
+ */
71753
+ function check(child) {
71754
+ return child.type === 'element' || child.type === 'text'
71755
+ }
71756
+ }
71757
+
71758
+ /**
71759
+ * Check whether an element matches an `:enabled` pseudo.
71760
+ *
71761
+ * @param {RulePseudo} query
71762
+ * @param {Element} element
71763
+ * @returns {boolean}
71764
+ */
71765
+ function enabled(query, element) {
71766
+ return !disabled(query, element)
71767
+ }
71768
+
71769
+ /**
71770
+ * Check whether an element matches a `:first-child` pseudo.
71771
+ *
71772
+ * @param {RulePseudo} query
71773
+ * @param {Element} _1
71774
+ * @param {number | undefined} _2
71775
+ * @param {Parent | undefined} _3
71776
+ * @param {SelectState} state
71777
+ * @returns {boolean}
71778
+ */
71779
+ function firstChild(query, _1, _2, _3, state) {
71780
+ assertDeep(state, query)
71781
+ return state.elementIndex === 0
71782
+ }
71783
+
71784
+ /**
71785
+ * Check whether an element matches a `:first-of-type` pseudo.
71786
+ *
71787
+ * @param {RulePseudo} query
71788
+ * @param {Element} _1
71789
+ * @param {number | undefined} _2
71790
+ * @param {Parent | undefined} _3
71791
+ * @param {SelectState} state
71792
+ * @returns {boolean}
71793
+ */
71794
+ function firstOfType(query, _1, _2, _3, state) {
71795
+ assertDeep(state, query)
71796
+ return state.typeIndex === 0
71797
+ }
71798
+
71799
+ /**
71800
+ * @param {RulePseudoSelector} query
71801
+ * @param {Element} element
71802
+ * @param {number | undefined} _1
71803
+ * @param {Parent | undefined} _2
71804
+ * @param {SelectState} state
71805
+ * @returns {boolean}
71806
+ */
71807
+ function has(query, element, _1, _2, state) {
71808
+ /** @type {SelectState} */
71809
+ const childState = {
71810
+ ...state,
71811
+ // Not found yet.
71812
+ found: false,
71813
+ // Do walk deep.
71814
+ shallow: false,
71815
+ // One result is enough.
71816
+ one: true,
71817
+ scopeElements: [element],
71818
+ results: [],
71819
+ rootQuery: queryToSelectors(query.value)
71820
+ }
71821
+
71822
+ walk_walk(childState, {type: 'root', children: element.children})
71823
+
71824
+ return childState.results.length > 0
71825
+ }
71826
+
71827
+ /**
71828
+ * Check whether an element matches a `:lang()` pseudo.
71829
+ *
71830
+ * @param {RulePseudo} query
71831
+ * @param {Element} _1
71832
+ * @param {number | undefined} _2
71833
+ * @param {Parent | undefined} _3
71834
+ * @param {SelectState} state
71835
+ * @returns {boolean}
71836
+ */
71837
+ function pseudo_lang(query, _1, _2, _3, state) {
71838
+ return (
71839
+ state.language !== '' &&
71840
+ state.language !== undefined &&
71841
+ // @ts-expect-error never `selectors`.
71842
+ extendedFilter(state.language, comma_separated_tokens_parse(query.value)).length > 0
71843
+ )
71844
+ }
71845
+
71846
+ /**
71847
+ * Check whether an element matches a `:last-child` pseudo.
71848
+ *
71849
+ * @param {RulePseudo} query
71850
+ * @param {Element} _1
71851
+ * @param {number | undefined} _2
71852
+ * @param {Parent | undefined} _3
71853
+ * @param {SelectState} state
71854
+ * @returns {boolean}
71855
+ */
71856
+ function lastChild(query, _1, _2, _3, state) {
71857
+ assertDeep(state, query)
71858
+ return Boolean(
71859
+ state.elementCount && state.elementIndex === state.elementCount - 1
71860
+ )
71861
+ }
71862
+
71863
+ /**
71864
+ * Check whether an element matches a `:last-of-type` pseudo.
71865
+ *
71866
+ * @param {RulePseudo} query
71867
+ * @param {Element} _1
71868
+ * @param {number | undefined} _2
71869
+ * @param {Parent | undefined} _3
71870
+ * @param {SelectState} state
71871
+ * @returns {boolean}
71872
+ */
71873
+ function lastOfType(query, _1, _2, _3, state) {
71874
+ assertDeep(state, query)
71875
+ return (
71876
+ typeof state.typeIndex === 'number' &&
71877
+ typeof state.typeCount === 'number' &&
71878
+ state.typeIndex === state.typeCount - 1
71879
+ )
71880
+ }
71881
+
71882
+ /**
71883
+ * Check whether an element `:matches` further selectors.
71884
+ *
71885
+ * @param {RulePseudoSelector} query
71886
+ * @param {Element} element
71887
+ * @param {number | undefined} _
71888
+ * @param {Parent | undefined} parent
71889
+ * @param {SelectState} state
71890
+ * @returns {boolean}
71891
+ */
71892
+ function matches(query, element, _, parent, state) {
71893
+ /** @type {SelectState} */
71894
+ const childState = {
71895
+ ...state,
71896
+ // Not found yet.
71897
+ found: false,
71898
+ // Do walk deep.
71899
+ shallow: false,
71900
+ // One result is enough.
71901
+ one: true,
71902
+ scopeElements: [element],
71903
+ results: [],
71904
+ rootQuery: queryToSelectors(query.value)
71905
+ }
71906
+
71907
+ walk_walk(childState, element)
71908
+
71909
+ return childState.results[0] === element
71910
+ }
71911
+
71912
+ /**
71913
+ * Check whether an element does `:not` match further selectors.
71914
+ *
71915
+ * @param {RulePseudoSelector} query
71916
+ * @param {Element} element
71917
+ * @param {number | undefined} index
71918
+ * @param {Parent | undefined} parent
71919
+ * @param {SelectState} state
71920
+ * @returns {boolean}
71921
+ */
71922
+ function not(query, element, index, parent, state) {
71923
+ return !matches(query, element, index, parent, state)
71924
+ }
71925
+
71926
+ /**
71927
+ * Check whether an element matches an `:nth-child` pseudo.
71928
+ *
71929
+ * @param {RulePseudo} query
71930
+ * @param {Element} _1
71931
+ * @param {number | undefined} _2
71932
+ * @param {Parent | undefined} _3
71933
+ * @param {SelectState} state
71934
+ * @returns {boolean}
71935
+ */
71936
+ function nthChild(query, _1, _2, _3, state) {
71937
+ const fn = getCachedNthCheck(query)
71938
+ assertDeep(state, query)
71939
+ return typeof state.elementIndex === 'number' && fn(state.elementIndex)
71940
+ }
71941
+
71942
+ /**
71943
+ * Check whether an element matches an `:nth-last-child` pseudo.
71944
+ *
71945
+ * @param {RulePseudo} query
71946
+ * @param {Element} _1
71947
+ * @param {number | undefined} _2
71948
+ * @param {Parent | undefined} _3
71949
+ * @param {SelectState} state
71950
+ * @returns {boolean}
71951
+ */
71952
+ function nthLastChild(query, _1, _2, _3, state) {
71953
+ const fn = getCachedNthCheck(query)
71954
+ assertDeep(state, query)
71955
+ return Boolean(
71956
+ typeof state.elementCount === 'number' &&
71957
+ typeof state.elementIndex === 'number' &&
71958
+ fn(state.elementCount - state.elementIndex - 1)
71959
+ )
71960
+ }
71961
+
71962
+ /**
71963
+ * Check whether an element matches a `:nth-last-of-type` pseudo.
71964
+ *
71965
+ * @param {RulePseudo} query
71966
+ * @param {Element} _1
71967
+ * @param {number | undefined} _2
71968
+ * @param {Parent | undefined} _3
71969
+ * @param {SelectState} state
71970
+ * @returns {boolean}
71971
+ */
71972
+ function nthLastOfType(query, _1, _2, _3, state) {
71973
+ const fn = getCachedNthCheck(query)
71974
+ assertDeep(state, query)
71975
+ return (
71976
+ typeof state.typeCount === 'number' &&
71977
+ typeof state.typeIndex === 'number' &&
71978
+ fn(state.typeCount - 1 - state.typeIndex)
71979
+ )
71980
+ }
71981
+
71982
+ /**
71983
+ * Check whether an element matches an `:nth-of-type` pseudo.
71984
+ *
71985
+ * @param {RulePseudo} query
71986
+ * @param {Element} _1
71987
+ * @param {number | undefined} _2
71988
+ * @param {Parent | undefined} _3
71989
+ * @param {SelectState} state
71990
+ * @returns {boolean}
71991
+ */
71992
+ function nthOfType(query, _1, _2, _3, state) {
71993
+ const fn = getCachedNthCheck(query)
71994
+ assertDeep(state, query)
71995
+ return typeof state.typeIndex === 'number' && fn(state.typeIndex)
71996
+ }
71997
+
71998
+ /**
71999
+ * Check whether an element matches an `:only-child` pseudo.
72000
+ *
72001
+ * @param {RulePseudo} query
72002
+ * @param {Element} _1
72003
+ * @param {number | undefined} _2
72004
+ * @param {Parent | undefined} _3
72005
+ * @param {SelectState} state
72006
+ * @returns {boolean}
72007
+ */
72008
+ function onlyChild(query, _1, _2, _3, state) {
72009
+ assertDeep(state, query)
72010
+ return state.elementCount === 1
72011
+ }
72012
+
72013
+ /**
72014
+ * Check whether an element matches an `:only-of-type` pseudo.
72015
+ *
72016
+ * @param {RulePseudo} query
72017
+ * @param {Element} _1
72018
+ * @param {number | undefined} _2
72019
+ * @param {Parent | undefined} _3
72020
+ * @param {SelectState} state
72021
+ * @returns {boolean}
72022
+ */
72023
+ function onlyOfType(query, _1, _2, _3, state) {
72024
+ assertDeep(state, query)
72025
+ return state.typeCount === 1
72026
+ }
72027
+
72028
+ /**
72029
+ * Check whether an element matches an `:optional` pseudo.
72030
+ *
72031
+ * @param {RulePseudo} query
72032
+ * @param {Element} element
72033
+ * @returns {boolean}
72034
+ */
72035
+ function optional(query, element) {
72036
+ return !required(query, element)
72037
+ }
72038
+
72039
+ /**
72040
+ * Check whether an element matches a `:read-only` pseudo.
72041
+ *
72042
+ * @param {RulePseudo} query
72043
+ * @param {Element} element
72044
+ * @param {number | undefined} index
72045
+ * @param {Parent | undefined} parent
72046
+ * @param {SelectState} state
72047
+ * @returns {boolean}
72048
+ */
72049
+ function readOnly(query, element, index, parent, state) {
72050
+ return !readWrite(query, element, index, parent, state)
72051
+ }
72052
+
72053
+ /**
72054
+ * Check whether an element matches a `:read-write` pseudo.
72055
+ *
72056
+ * @param {RulePseudo} _
72057
+ * @param {Element} element
72058
+ * @param {number | undefined} _1
72059
+ * @param {Parent | undefined} _2
72060
+ * @param {SelectState} state
72061
+ * @returns {boolean}
72062
+ */
72063
+ function readWrite(_, element, _1, _2, state) {
72064
+ return element.tagName === 'input' || element.tagName === 'textarea'
72065
+ ? !hasProperty(element, 'readOnly') && !hasProperty(element, 'disabled')
72066
+ : Boolean(state.editableOrEditingHost)
72067
+ }
72068
+
72069
+ /**
72070
+ * Check whether an element matches a `:required` pseudo.
72071
+ *
72072
+ * @param {RulePseudo} _
72073
+ * @param {Element} element
72074
+ * @returns {boolean}
72075
+ */
72076
+ function required(_, element) {
72077
+ return (
72078
+ (element.tagName === 'input' ||
72079
+ element.tagName === 'textarea' ||
72080
+ element.tagName === 'select') &&
72081
+ hasProperty(element, 'required')
72082
+ )
72083
+ }
72084
+
72085
+ /**
72086
+ * Check whether an element matches a `:root` pseudo.
72299
72087
  *
72300
72088
  * @param {RulePseudo} _
72301
72089
  * @param {Element} element
72090
+ * @param {number | undefined} _1
72091
+ * @param {Parent | undefined} parent
72092
+ * @param {SelectState} state
72302
72093
  * @returns {boolean}
72303
72094
  */
72304
- function anyLink(_, element) {
72305
- return (
72306
- (element.tagName === 'a' ||
72307
- element.tagName === 'area' ||
72308
- element.tagName === 'link') &&
72309
- hasProperty(element, 'href')
72095
+ function pseudo_root(_, element, _1, parent, state) {
72096
+ return Boolean(
72097
+ (!parent || parent.type === 'root') &&
72098
+ state.schema &&
72099
+ (state.schema.space === 'html' || state.schema.space === 'svg') &&
72100
+ (element.tagName === 'html' || element.tagName === 'svg')
72310
72101
  )
72311
72102
  }
72312
72103
 
72313
72104
  /**
72314
- * Check whether an element matches a `:blank` pseudo.
72105
+ * Check whether an element matches a `:scope` pseudo.
72315
72106
  *
72316
72107
  * @param {RulePseudo} _
72317
72108
  * @param {Element} element
72109
+ * @param {number | undefined} _1
72110
+ * @param {Parent | undefined} _2
72111
+ * @param {SelectState} state
72318
72112
  * @returns {boolean}
72319
72113
  */
72320
- function blank(_, element) {
72321
- return !someChildren(element, check)
72114
+ function scope(_, element, _1, _2, state) {
72115
+ return state.scopeElements.includes(element)
72116
+ }
72322
72117
 
72323
- /**
72324
- * @param {ElementChild} child
72325
- * @returns {boolean}
72326
- */
72327
- function check(child) {
72328
- return (
72329
- child.type === 'element' || (child.type === 'text' && !whitespace(child))
72330
- )
72118
+ // Shouldn’t be called, parser gives correct data.
72119
+ /* c8 ignore next 3 */
72120
+ function invalidPseudo() {
72121
+ throw new Error('Invalid pseudo-selector')
72122
+ }
72123
+
72124
+ /**
72125
+ * @param {unknown} query
72126
+ * @returns {never}
72127
+ */
72128
+ function unknownPseudo(query) {
72129
+ // @ts-expect-error: indexable.
72130
+ if (query.name) {
72131
+ // @ts-expect-error: indexable.
72132
+ throw new Error('Unknown pseudo-selector `' + query.name + '`')
72331
72133
  }
72134
+
72135
+ throw new Error('Unexpected pseudo-element or empty pseudo-class')
72332
72136
  }
72333
72137
 
72334
72138
  /**
72335
- * Check whether an element matches a `:checked` pseudo.
72139
+ * Check children.
72336
72140
  *
72337
- * @param {RulePseudo} _
72338
72141
  * @param {Element} element
72142
+ * @param {(child: ElementChild) => boolean} check
72339
72143
  * @returns {boolean}
72340
72144
  */
72341
- function checked(_, element) {
72342
- if (element.tagName === 'input' || element.tagName === 'menuitem') {
72343
- return Boolean(
72344
- element.properties &&
72345
- (element.properties.type === 'checkbox' ||
72346
- element.properties.type === 'radio') &&
72347
- hasProperty(element, 'checked')
72348
- )
72349
- }
72145
+ function someChildren(element, check) {
72146
+ const children = element.children
72147
+ let index = -1
72350
72148
 
72351
- if (element.tagName === 'option') {
72352
- return hasProperty(element, 'selected')
72149
+ while (++index < children.length) {
72150
+ if (check(children[index])) return true
72353
72151
  }
72354
72152
 
72355
72153
  return false
72356
72154
  }
72357
72155
 
72358
72156
  /**
72359
- * Check whether an element matches a `:dir()` pseudo.
72360
- *
72361
- * @param {RulePseudo} query
72362
- * @param {Element} _1
72363
- * @param {number | undefined} _2
72364
- * @param {Parent | undefined} _3
72365
72157
  * @param {SelectState} state
72366
- * @returns {boolean}
72367
- */
72368
- function dir(query, _1, _2, _3, state) {
72369
- return state.direction === query.value
72370
- }
72371
-
72372
- /**
72373
- * Check whether an element matches a `:disabled` pseudo.
72374
- *
72375
- * @param {RulePseudo} _
72376
- * @param {Element} element
72377
- * @returns {boolean}
72158
+ * @param {RulePseudo} query
72378
72159
  */
72379
- function disabled(_, element) {
72380
- return (
72381
- (element.tagName === 'button' ||
72382
- element.tagName === 'input' ||
72383
- element.tagName === 'select' ||
72384
- element.tagName === 'textarea' ||
72385
- element.tagName === 'optgroup' ||
72386
- element.tagName === 'option' ||
72387
- element.tagName === 'menuitem' ||
72388
- element.tagName === 'fieldset') &&
72389
- hasProperty(element, 'disabled')
72390
- )
72160
+ function assertDeep(state, query) {
72161
+ if (state.shallow) {
72162
+ throw new Error('Cannot use `:' + query.name + '` without parent')
72163
+ }
72391
72164
  }
72392
72165
 
72393
72166
  /**
72394
- * Check whether an element matches an `:empty` pseudo.
72395
- *
72396
- * @param {RulePseudo} _
72397
- * @param {Element} element
72398
- * @returns {boolean}
72167
+ * @param {RulePseudo} query
72168
+ * @returns {(value: number) => boolean}
72399
72169
  */
72400
- function empty(_, element) {
72401
- return !someChildren(element, check)
72170
+ function getCachedNthCheck(query) {
72171
+ /** @type {(value: number) => boolean} */
72172
+ // @ts-expect-error: cache.
72173
+ let fn = query._cachedFn
72402
72174
 
72403
- /**
72404
- * @param {ElementChild} child
72405
- * @returns {boolean}
72406
- */
72407
- function check(child) {
72408
- return child.type === 'element' || child.type === 'text'
72175
+ if (!fn) {
72176
+ // @ts-expect-error: always string.
72177
+ fn = pseudo_nthCheck(query.value)
72178
+ // @ts-expect-error: cache.
72179
+ query._cachedFn = fn
72409
72180
  }
72181
+
72182
+ return fn
72410
72183
  }
72411
72184
 
72185
+ ;// CONCATENATED MODULE: ../node_modules/hast-util-select/lib/test.js
72412
72186
  /**
72413
- * Check whether an element matches an `:enabled` pseudo.
72414
- *
72415
- * @param {RulePseudo} query
72416
- * @param {Element} element
72417
- * @returns {boolean}
72187
+ * @typedef {import('./types.js').Rule} Rule
72188
+ * @typedef {import('./types.js').Element} Element
72189
+ * @typedef {import('./types.js').Parent} Parent
72190
+ * @typedef {import('./types.js').SelectState} SelectState
72418
72191
  */
72419
- function enabled(query, element) {
72420
- return !disabled(query, element)
72421
- }
72192
+
72193
+
72194
+
72195
+
72196
+
72197
+
72422
72198
 
72423
72199
  /**
72424
- * Check whether an element matches a `:first-child` pseudo.
72200
+ * Test a rule.
72425
72201
  *
72426
- * @param {RulePseudo} query
72427
- * @param {Element} _1
72428
- * @param {number | undefined} _2
72429
- * @param {Parent | undefined} _3
72202
+ * @param {Rule} query
72203
+ * @param {Element} element
72204
+ * @param {number | undefined} index
72205
+ * @param {Parent | undefined} parent
72430
72206
  * @param {SelectState} state
72431
72207
  * @returns {boolean}
72432
72208
  */
72433
- function firstChild(query, _1, _2, _3, state) {
72434
- assertDeep(state, query)
72435
- return state.elementIndex === 0
72209
+ function test(query, element, index, parent, state) {
72210
+ return Boolean(
72211
+ (!query.tagName || name_name(query, element)) &&
72212
+ (!query.classNames || className(query, element)) &&
72213
+ (!query.id || id(query, element)) &&
72214
+ (!query.attrs || attribute(query, element, state.schema)) &&
72215
+ (!query.pseudos || pseudo(query, element, index, parent, state))
72216
+ )
72436
72217
  }
72437
72218
 
72219
+ ;// CONCATENATED MODULE: ../node_modules/hast-util-select/lib/walk.js
72438
72220
  /**
72439
- * Check whether an element matches a `:first-of-type` pseudo.
72221
+ * @typedef {import('./types.js').Node} Node
72222
+ * @typedef {import('./types.js').Element} Element
72223
+ * @typedef {import('./types.js').Parent} Parent
72224
+ * @typedef {import('./types.js').RuleSet} RuleSet
72225
+ * @typedef {import('./types.js').SelectState} SelectState
72226
+ * @typedef {import('./types.js').Selectors} Selectors
72440
72227
  *
72441
- * @param {RulePseudo} query
72442
- * @param {Element} _1
72443
- * @param {number | undefined} _2
72444
- * @param {Parent | undefined} _3
72445
- * @param {SelectState} state
72446
- * @returns {boolean}
72228
+ * @typedef Nest
72229
+ * Rule sets by nesting.
72230
+ * @property {Array<RuleSet> | undefined} descendant
72231
+ * `a b`
72232
+ * @property {Array<RuleSet> | undefined} directChild
72233
+ * `a > b`
72234
+ * @property {Array<RuleSet> | undefined} adjacentSibling
72235
+ * `a + b`
72236
+ * @property {Array<RuleSet> | undefined} generalSibling
72237
+ * `a ~ b`
72238
+ *
72239
+ * @typedef Counts
72240
+ * Info on elements in a parent.
72241
+ * @property {number} count
72242
+ * Number of elements.
72243
+ * @property {Map<string, number>} types
72244
+ * Number of elements by tag name.
72447
72245
  */
72448
- function firstOfType(query, _1, _2, _3, state) {
72449
- assertDeep(state, query)
72450
- return state.typeIndex === 0
72451
- }
72246
+
72247
+
72248
+
72249
+
72250
+ /** @type {Array<never>} */
72251
+ const walk_empty = []
72452
72252
 
72453
72253
  /**
72454
- * @param {RulePseudoSelector} query
72455
- * @param {Element} element
72456
- * @param {number | undefined} _1
72457
- * @param {Parent | undefined} _2
72458
- * @param {SelectState} state
72459
- * @returns {boolean}
72254
+ * Turn a query into a uniform object.
72255
+ *
72256
+ * @param {Selectors | RuleSet | null} query
72257
+ * @returns {Selectors}
72460
72258
  */
72461
- function has(query, element, _1, _2, state) {
72462
- /** @type {SelectState} */
72463
- const childState = {
72464
- ...state,
72465
- // Not found yet.
72466
- found: false,
72467
- // Do walk deep.
72468
- shallow: false,
72469
- // One result is enough.
72470
- one: true,
72471
- scopeElements: [element],
72472
- results: [],
72473
- rootQuery: queryToSelectors(query.value)
72259
+ function queryToSelectors(query) {
72260
+ if (query === null) {
72261
+ return {type: 'selectors', selectors: []}
72474
72262
  }
72475
72263
 
72476
- walk_walk(childState, {type: 'root', children: element.children})
72264
+ if (query.type === 'ruleSet') {
72265
+ return {type: 'selectors', selectors: [query]}
72266
+ }
72477
72267
 
72478
- return childState.results.length > 0
72268
+ return query
72479
72269
  }
72480
72270
 
72481
72271
  /**
72482
- * Check whether an element matches a `:lang()` pseudo.
72272
+ * Walk a tree.
72483
72273
  *
72484
- * @param {RulePseudo} query
72485
- * @param {Element} _1
72486
- * @param {number | undefined} _2
72487
- * @param {Parent | undefined} _3
72488
72274
  * @param {SelectState} state
72489
- * @returns {boolean}
72275
+ * @param {Node | undefined} tree
72490
72276
  */
72491
- function pseudo_lang(query, _1, _2, _3, state) {
72492
- return (
72493
- state.language !== '' &&
72494
- state.language !== undefined &&
72495
- // @ts-expect-error never `selectors`.
72496
- extendedFilter(state.language, comma_separated_tokens_parse(query.value)).length > 0
72497
- )
72277
+ function walk_walk(state, tree) {
72278
+ if (tree) {
72279
+ walk_one(state, [], tree, undefined, undefined)
72280
+ }
72498
72281
  }
72499
72282
 
72500
72283
  /**
72501
- * Check whether an element matches a `:last-child` pseudo.
72284
+ * Check a node.
72502
72285
  *
72503
- * @param {RulePseudo} query
72504
- * @param {Element} _1
72505
- * @param {number | undefined} _2
72506
- * @param {Parent | undefined} _3
72507
72286
  * @param {SelectState} state
72508
- * @returns {boolean}
72287
+ * @param {Array<RuleSet>} currentRules
72288
+ * @param {Node} node
72289
+ * @param {number | undefined} index
72290
+ * @param {Parent | undefined} parent
72291
+ * @returns {Nest}
72509
72292
  */
72510
- function lastChild(query, _1, _2, _3, state) {
72511
- assertDeep(state, query)
72512
- return Boolean(
72513
- state.elementCount && state.elementIndex === state.elementCount - 1
72514
- )
72293
+ function walk_one(state, currentRules, node, index, parent) {
72294
+ /** @type {Nest} */
72295
+ let nestResult = {
72296
+ directChild: undefined,
72297
+ descendant: undefined,
72298
+ adjacentSibling: undefined,
72299
+ generalSibling: undefined
72300
+ }
72301
+ const exit = enterState(state, node)
72302
+
72303
+ if (node.type === 'element') {
72304
+ nestResult = applySelectors(
72305
+ state,
72306
+ // Try the root rules for this element too.
72307
+ combine(currentRules, state.rootQuery.selectors),
72308
+ node,
72309
+ index,
72310
+ parent
72311
+ )
72312
+ }
72313
+
72314
+ // If this is a parent, and we want to delve into them, and we haven’t found
72315
+ // our single result yet.
72316
+ if ('children' in node && !state.shallow && !(state.one && state.found)) {
72317
+ walk_all(state, nestResult, node)
72318
+ }
72319
+
72320
+ exit()
72321
+
72322
+ return nestResult
72515
72323
  }
72516
72324
 
72517
72325
  /**
72518
- * Check whether an element matches a `:last-of-type` pseudo.
72326
+ * Check a node.
72519
72327
  *
72520
- * @param {RulePseudo} query
72521
- * @param {Element} _1
72522
- * @param {number | undefined} _2
72523
- * @param {Parent | undefined} _3
72524
72328
  * @param {SelectState} state
72525
- * @returns {boolean}
72329
+ * @param {Nest} nest
72330
+ * @param {Parent} node
72331
+ * @returns {void}
72526
72332
  */
72527
- function lastOfType(query, _1, _2, _3, state) {
72528
- assertDeep(state, query)
72529
- return (
72530
- typeof state.typeIndex === 'number' &&
72531
- typeof state.typeCount === 'number' &&
72532
- state.typeIndex === state.typeCount - 1
72533
- )
72333
+ function walk_all(state, nest, node) {
72334
+ const fromParent = combine(nest.descendant, nest.directChild)
72335
+ /** @type {Array<RuleSet> | undefined} */
72336
+ let fromSibling
72337
+ let index = -1
72338
+ /**
72339
+ * Total counts.
72340
+ * @type {Counts}
72341
+ */
72342
+ const total = {count: 0, types: new Map()}
72343
+ /**
72344
+ * Counts of previous siblings.
72345
+ * @type {Counts}
72346
+ */
72347
+ const before = {count: 0, types: new Map()}
72348
+
72349
+ while (++index < node.children.length) {
72350
+ count(total, node.children[index])
72351
+ }
72352
+
72353
+ index = -1
72354
+
72355
+ while (++index < node.children.length) {
72356
+ const child = node.children[index]
72357
+ // Uppercase to prevent prototype polution, injecting `constructor` or so.
72358
+ // Normalize because HTML is insensitive.
72359
+ const name =
72360
+ child.type === 'element' ? child.tagName.toUpperCase() : undefined
72361
+ // Before counting further elements:
72362
+ state.elementIndex = before.count
72363
+ state.typeIndex = name ? before.types.get(name) || 0 : 0
72364
+ // After counting all elements.
72365
+ state.elementCount = total.count
72366
+ state.typeCount = name ? total.types.get(name) : 0
72367
+
72368
+ // Only apply if this is a parent, this should be an element, but we check
72369
+ // for parents so that we delve into custom nodes too.
72370
+ if ('children' in child) {
72371
+ const forSibling = combine(fromParent, fromSibling)
72372
+ const nest = walk_one(state, forSibling, node.children[index], index, node)
72373
+ fromSibling = combine(nest.generalSibling, nest.adjacentSibling)
72374
+ }
72375
+
72376
+ // We found one thing, and one is enough.
72377
+ if (state.one && state.found) {
72378
+ break
72379
+ }
72380
+
72381
+ count(before, node.children[index])
72382
+ }
72534
72383
  }
72535
72384
 
72536
72385
  /**
72537
- * Check whether an element `:matches` further selectors.
72386
+ * Apply selectors to an element.
72538
72387
  *
72539
- * @param {RulePseudoSelector} query
72540
- * @param {Element} element
72541
- * @param {number | undefined} _
72542
- * @param {Parent | undefined} parent
72543
72388
  * @param {SelectState} state
72544
- * @returns {boolean}
72389
+ * Current state.
72390
+ * @param {Array<RuleSet>} rules
72391
+ * Rules to apply.
72392
+ * @param {Element} node
72393
+ * Element to apply rules to.
72394
+ * @param {number | undefined} index
72395
+ * Index of node in parent.
72396
+ * @param {Parent | undefined} parent
72397
+ * Parent of node.
72398
+ * @returns {Nest}
72399
+ * Further rules.
72545
72400
  */
72546
- function matches(query, element, _, parent, state) {
72547
- /** @type {SelectState} */
72548
- const childState = {
72549
- ...state,
72550
- // Not found yet.
72551
- found: false,
72552
- // Do walk deep.
72553
- shallow: false,
72554
- // One result is enough.
72555
- one: true,
72556
- scopeElements: [element],
72557
- results: [],
72558
- rootQuery: queryToSelectors(query.value)
72401
+ function applySelectors(state, rules, node, index, parent) {
72402
+ /** @type {Nest} */
72403
+ const nestResult = {
72404
+ directChild: undefined,
72405
+ descendant: undefined,
72406
+ adjacentSibling: undefined,
72407
+ generalSibling: undefined
72559
72408
  }
72409
+ let selectorIndex = -1
72560
72410
 
72561
- walk_walk(childState, element)
72411
+ while (++selectorIndex < rules.length) {
72412
+ const ruleSet = rules[selectorIndex]
72562
72413
 
72563
- return childState.results[0] === element
72414
+ // We found one thing, and one is enough.
72415
+ if (state.one && state.found) {
72416
+ break
72417
+ }
72418
+
72419
+ // When shallow, we don’t allow nested rules.
72420
+ // Idea: we could allow a stack of parents?
72421
+ // Might get quite complex though.
72422
+ if (state.shallow && ruleSet.rule.rule) {
72423
+ throw new Error('Expected selector without nesting')
72424
+ }
72425
+
72426
+ // If this rule matches:
72427
+ if (test(ruleSet.rule, node, index, parent, state)) {
72428
+ const nest = ruleSet.rule.rule
72429
+
72430
+ // Are there more?
72431
+ if (nest) {
72432
+ /** @type {RuleSet} */
72433
+ const rule = {type: 'ruleSet', rule: nest}
72434
+ /** @type {keyof Nest} */
72435
+ const label =
72436
+ nest.nestingOperator === '+'
72437
+ ? 'adjacentSibling'
72438
+ : nest.nestingOperator === '~'
72439
+ ? 'generalSibling'
72440
+ : nest.nestingOperator === '>'
72441
+ ? 'directChild'
72442
+ : 'descendant'
72443
+ add(nestResult, label, rule)
72444
+ } else {
72445
+ // We have a match!
72446
+ state.found = true
72447
+
72448
+ if (!state.results.includes(node)) {
72449
+ state.results.push(node)
72450
+ }
72451
+ }
72452
+ }
72453
+
72454
+ // Descendant.
72455
+ if (ruleSet.rule.nestingOperator === null) {
72456
+ add(nestResult, 'descendant', ruleSet)
72457
+ }
72458
+ // Adjacent.
72459
+ else if (ruleSet.rule.nestingOperator === '~') {
72460
+ add(nestResult, 'generalSibling', ruleSet)
72461
+ }
72462
+ // Drop top-level nesting (`undefined`), direct child (`>`), adjacent sibling (`+`).
72463
+ }
72464
+
72465
+ return nestResult
72564
72466
  }
72565
72467
 
72566
72468
  /**
72567
- * Check whether an element does `:not` match further selectors.
72469
+ * Combine two lists, if needed.
72568
72470
  *
72569
- * @param {RulePseudoSelector} query
72570
- * @param {Element} element
72571
- * @param {number | undefined} index
72572
- * @param {Parent | undefined} parent
72573
- * @param {SelectState} state
72574
- * @returns {boolean}
72471
+ * This is optimized to create as few lists as possible.
72472
+ *
72473
+ * @param {Array<RuleSet> | undefined} left
72474
+ * @param {Array<RuleSet> | undefined} right
72475
+ * @returns {Array<RuleSet>}
72575
72476
  */
72576
- function not(query, element, index, parent, state) {
72577
- return !matches(query, element, index, parent, state)
72477
+ function combine(left, right) {
72478
+ return left && right && left.length > 0 && right.length > 0
72479
+ ? [...left, ...right]
72480
+ : left && left.length > 0
72481
+ ? left
72482
+ : right && right.length > 0
72483
+ ? right
72484
+ : walk_empty
72578
72485
  }
72579
72486
 
72580
72487
  /**
72581
- * Check whether an element matches an `:nth-child` pseudo.
72488
+ * Add a rule to a nesting map.
72582
72489
  *
72583
- * @param {RulePseudo} query
72584
- * @param {Element} _1
72585
- * @param {number | undefined} _2
72586
- * @param {Parent | undefined} _3
72587
- * @param {SelectState} state
72588
- * @returns {boolean}
72490
+ * @param {Nest} nest
72491
+ * @param {keyof Nest} field
72492
+ * @param {RuleSet} rule
72589
72493
  */
72590
- function nthChild(query, _1, _2, _3, state) {
72591
- const fn = getCachedNthCheck(query)
72592
- assertDeep(state, query)
72593
- return typeof state.elementIndex === 'number' && fn(state.elementIndex)
72494
+ function add(nest, field, rule) {
72495
+ const list = nest[field]
72496
+ if (list) {
72497
+ list.push(rule)
72498
+ } else {
72499
+ nest[field] = [rule]
72500
+ }
72594
72501
  }
72595
72502
 
72596
72503
  /**
72597
- * Check whether an element matches an `:nth-last-child` pseudo.
72504
+ * Count a node.
72598
72505
  *
72599
- * @param {RulePseudo} query
72600
- * @param {Element} _1
72601
- * @param {number | undefined} _2
72602
- * @param {Parent | undefined} _3
72603
- * @param {SelectState} state
72604
- * @returns {boolean}
72506
+ * @param {Counts} counts
72507
+ * Counts.
72508
+ * @param {Node} node
72509
+ * Node (we’re looking for elements).
72510
+ * @returns {void}
72511
+ * Nothing.
72605
72512
  */
72606
- function nthLastChild(query, _1, _2, _3, state) {
72607
- const fn = getCachedNthCheck(query)
72608
- assertDeep(state, query)
72609
- return Boolean(
72610
- typeof state.elementCount === 'number' &&
72611
- typeof state.elementIndex === 'number' &&
72612
- fn(state.elementCount - state.elementIndex - 1)
72613
- )
72513
+ function count(counts, node) {
72514
+ if (node.type === 'element') {
72515
+ // Uppercase to prevent prototype polution, injecting `constructor` or so.
72516
+ // Normalize because HTML is insensitive.
72517
+ const name = node.tagName.toUpperCase()
72518
+ const count = (counts.types.get(name) || 0) + 1
72519
+ counts.count++
72520
+ counts.types.set(name, count)
72521
+ }
72614
72522
  }
72615
72523
 
72524
+ // EXTERNAL MODULE: ../node_modules/css-selector-parser/lib/index.js
72525
+ var css_selector_parser_lib = __webpack_require__(301);
72526
+ ;// CONCATENATED MODULE: ../node_modules/hast-util-select/lib/parse.js
72616
72527
  /**
72617
- * Check whether an element matches a `:nth-last-of-type` pseudo.
72618
- *
72619
- * @param {RulePseudo} query
72620
- * @param {Element} _1
72621
- * @param {number | undefined} _2
72622
- * @param {Parent | undefined} _3
72623
- * @param {SelectState} state
72624
- * @returns {boolean}
72528
+ * @typedef {import('./types.js').Selectors} Selectors
72529
+ * @typedef {import('./types.js').RuleSet} RuleSet
72625
72530
  */
72626
- function nthLastOfType(query, _1, _2, _3, state) {
72627
- const fn = getCachedNthCheck(query)
72628
- assertDeep(state, query)
72629
- return (
72630
- typeof state.typeCount === 'number' &&
72631
- typeof state.typeIndex === 'number' &&
72632
- fn(state.typeCount - 1 - state.typeIndex)
72633
- )
72634
- }
72531
+
72532
+
72533
+
72534
+ const parse_parser = new css_selector_parser_lib/* CssSelectorParser */.N()
72535
+
72536
+ parse_parser.registerAttrEqualityMods('~', '|', '^', '$', '*')
72537
+ parse_parser.registerSelectorPseudos('any', 'matches', 'not', 'has')
72538
+ parse_parser.registerNestingOperators('>', '+', '~')
72635
72539
 
72636
72540
  /**
72637
- * Check whether an element matches an `:nth-of-type` pseudo.
72638
- *
72639
- * @param {RulePseudo} query
72640
- * @param {Element} _1
72641
- * @param {number | undefined} _2
72642
- * @param {Parent | undefined} _3
72643
- * @param {SelectState} state
72644
- * @returns {boolean}
72541
+ * @param {string} selector
72542
+ * @returns {Selectors | RuleSet | null}
72645
72543
  */
72646
- function nthOfType(query, _1, _2, _3, state) {
72647
- const fn = getCachedNthCheck(query)
72648
- assertDeep(state, query)
72649
- return typeof state.typeIndex === 'number' && fn(state.typeIndex)
72544
+ function lib_parse_parse(selector) {
72545
+ if (typeof selector !== 'string') {
72546
+ throw new TypeError('Expected `string` as selector, not `' + selector + '`')
72547
+ }
72548
+
72549
+ return parse_parser.parse(selector)
72650
72550
  }
72651
72551
 
72552
+ ;// CONCATENATED MODULE: ../node_modules/hast-util-select/lib/index.js
72652
72553
  /**
72653
- * Check whether an element matches an `:only-child` pseudo.
72654
- *
72655
- * @param {RulePseudo} query
72656
- * @param {Element} _1
72657
- * @param {number | undefined} _2
72658
- * @param {Parent | undefined} _3
72659
- * @param {SelectState} state
72660
- * @returns {boolean}
72554
+ * @typedef {import('./types.js').Element} Element
72555
+ * @typedef {import('./types.js').Node} Node
72556
+ * @typedef {import('./types.js').Space} Space
72557
+ * @typedef {import('./types.js').SelectState} SelectState
72661
72558
  */
72662
- function onlyChild(query, _1, _2, _3, state) {
72663
- assertDeep(state, query)
72664
- return state.elementCount === 1
72665
- }
72559
+
72560
+
72561
+
72562
+
72666
72563
 
72667
72564
  /**
72668
- * Check whether an element matches an `:only-of-type` pseudo.
72565
+ * Check that the given `node` matches `selector`.
72669
72566
  *
72670
- * @param {RulePseudo} query
72671
- * @param {Element} _1
72672
- * @param {number | undefined} _2
72673
- * @param {Parent | undefined} _3
72674
- * @param {SelectState} state
72567
+ * This only checks the element itself, not the surrounding tree.
72568
+ * Thus, nesting in selectors is not supported (`p b`, `p > b`), neither are
72569
+ * selectors like `:first-child`, etc.
72570
+ * This only checks that the given element matches the selector.
72571
+ *
72572
+ * @param {string} selector
72573
+ * CSS selector, such as (`h1`, `a, b`).
72574
+ * @param {Node | null | undefined} [node]
72575
+ * Node that might match `selector`, should be an element.
72576
+ * @param {Space | null | undefined} [space='html']
72577
+ * Name of namespace (`'svg'` or `'html'`).
72675
72578
  * @returns {boolean}
72579
+ * Whether `node` matches `selector`.
72676
72580
  */
72677
- function onlyOfType(query, _1, _2, _3, state) {
72678
- assertDeep(state, query)
72679
- return state.typeCount === 1
72581
+ function lib_matches(selector, node, space) {
72582
+ const state = lib_createState(selector, node, space)
72583
+ state.one = true
72584
+ state.shallow = true
72585
+ walk(state, node || undefined)
72586
+ return state.results.length > 0
72680
72587
  }
72681
72588
 
72682
72589
  /**
72683
- * Check whether an element matches an `:optional` pseudo.
72590
+ * Select the first element that matches `selector` in the given `tree`.
72591
+ * Searches the tree in *preorder*.
72684
72592
  *
72685
- * @param {RulePseudo} query
72686
- * @param {Element} element
72687
- * @returns {boolean}
72593
+ * @param {string} selector
72594
+ * CSS selector, such as (`h1`, `a, b`).
72595
+ * @param {Node | null | undefined} [tree]
72596
+ * Tree to search.
72597
+ * @param {Space | null | undefined} [space='html']
72598
+ * Name of namespace (`'svg'` or `'html'`).
72599
+ * @returns {Element | null}
72600
+ * First element in `tree` that matches `selector` or `null` if nothing is
72601
+ * found.
72602
+ * This could be `tree` itself.
72688
72603
  */
72689
- function optional(query, element) {
72690
- return !required(query, element)
72604
+ function lib_select(selector, tree, space) {
72605
+ const state = lib_createState(selector, tree, space)
72606
+ state.one = true
72607
+ walk(state, tree || undefined)
72608
+ // To do in major: return `undefined` instead.
72609
+ return state.results[0] || null
72691
72610
  }
72692
72611
 
72693
72612
  /**
72694
- * Check whether an element matches a `:read-only` pseudo.
72613
+ * Select all elements that match `selector` in the given `tree`.
72614
+ * Searches the tree in *preorder*.
72695
72615
  *
72696
- * @param {RulePseudo} query
72697
- * @param {Element} element
72698
- * @param {number | undefined} index
72699
- * @param {Parent | undefined} parent
72700
- * @param {SelectState} state
72701
- * @returns {boolean}
72616
+ * @param {string} selector
72617
+ * CSS selector, such as (`h1`, `a, b`).
72618
+ * @param {Node | null | undefined} [tree]
72619
+ * Tree to search.
72620
+ * @param {Space | null | undefined} [space='html']
72621
+ * Name of namespace (`'svg'` or `'html'`).
72622
+ * @returns {Array<Element>}
72623
+ * Elements in `tree` that match `selector`.
72624
+ * This could include `tree` itself.
72702
72625
  */
72703
- function readOnly(query, element, index, parent, state) {
72704
- return !readWrite(query, element, index, parent, state)
72626
+ function selectAll(selector, tree, space) {
72627
+ const state = lib_createState(selector, tree, space)
72628
+ walk_walk(state, tree || undefined)
72629
+ return state.results
72705
72630
  }
72706
72631
 
72707
72632
  /**
72708
- * Check whether an element matches a `:read-write` pseudo.
72709
- *
72710
- * @param {RulePseudo} _
72711
- * @param {Element} element
72712
- * @param {number | undefined} _1
72713
- * @param {Parent | undefined} _2
72714
- * @param {SelectState} state
72715
- * @returns {boolean}
72633
+ * @param {string} selector
72634
+ * Tree to search.
72635
+ * @param {Node | null | undefined} [tree]
72636
+ * Tree to search.
72637
+ * @param {Space | null | undefined} [space='html']
72638
+ * Name of namespace (`'svg'` or `'html'`).
72639
+ * @returns {SelectState} SelectState
72716
72640
  */
72717
- function readWrite(_, element, _1, _2, state) {
72718
- return element.tagName === 'input' || element.tagName === 'textarea'
72719
- ? !hasProperty(element, 'readOnly') && !hasProperty(element, 'disabled')
72720
- : Boolean(state.editableOrEditingHost)
72641
+ function lib_createState(selector, tree, space) {
72642
+ return {
72643
+ // State of the query.
72644
+ rootQuery: queryToSelectors(lib_parse_parse(selector)),
72645
+ results: [],
72646
+ // @ts-expect-error assume elements.
72647
+ scopeElements: tree ? (tree.type === 'root' ? tree.children : [tree]) : [],
72648
+ one: false,
72649
+ shallow: false,
72650
+ found: false,
72651
+ // State in the tree.
72652
+ schema: space === 'svg' ? property_information_svg : property_information_html,
72653
+ language: undefined,
72654
+ direction: 'ltr',
72655
+ editableOrEditingHost: false,
72656
+ typeIndex: undefined,
72657
+ elementIndex: undefined,
72658
+ typeCount: undefined,
72659
+ elementCount: undefined
72660
+ }
72721
72661
  }
72722
72662
 
72663
+ ;// CONCATENATED MODULE: ../node_modules/rehype-rewrite/lib/index.js
72664
+
72665
+
72666
+ /** Get the node tree source code string */
72667
+ const getCodeString = (data = [], code = '') => {
72668
+ data.forEach((node) => {
72669
+ if (node.type === 'text') {
72670
+ code += node.value;
72671
+ }
72672
+ else if (node.type === 'element' && node.children && Array.isArray(node.children)) {
72673
+ code += getCodeString(node.children);
72674
+ }
72675
+ });
72676
+ return code;
72677
+ };
72678
+ const remarkRewrite = (options) => {
72679
+ const { selector, rewrite } = options || {};
72680
+ return (tree) => {
72681
+ if (!rewrite || typeof rewrite !== 'function')
72682
+ return;
72683
+ if (selector && typeof selector === 'string') {
72684
+ const selected = selectAll(selector, tree);
72685
+ if (selected && selected.length > 0) {
72686
+ visit(tree, selected, (node, index, parent) => {
72687
+ rewrite(node, index, parent);
72688
+ });
72689
+ }
72690
+ return;
72691
+ }
72692
+ visit(tree, (node, index, parent) => {
72693
+ rewrite(node, index, parent);
72694
+ });
72695
+ };
72696
+ };
72697
+ /* harmony default export */ const rehype_rewrite_lib = (remarkRewrite);
72698
+ //# sourceMappingURL=index.js.map
72699
+ ;// CONCATENATED MODULE: ../node_modules/rehype-attr/lib/utils.js
72700
+ const getURLParameters = (url = '') => (url.match(/([^?=&]+)(=([^&]*))/g) || []).reduce((a, v) => ((a[v.slice(0, v.indexOf('='))] = v.slice(v.indexOf('=') + 1)), a), {});
72701
+ const prevChild = (data = [], index) => {
72702
+ let i = index;
72703
+ while (i > -1) {
72704
+ i--;
72705
+ if (!data[i])
72706
+ return;
72707
+ if ((data[i] && data[i].value && data[i].value.replace(/(\n|\s)/g, '') !== '') || data[i].type !== 'text') {
72708
+ if (!/^rehype:/.test(data[i].value) || data[i].type !== 'comment')
72709
+ return;
72710
+ return data[i];
72711
+ }
72712
+ }
72713
+ return;
72714
+ };
72715
+ const nextChild = (data = [], index, tagName, codeBlockParames) => {
72716
+ let i = index;
72717
+ while (i < data.length) {
72718
+ i++;
72719
+ if (tagName) {
72720
+ const element = data[i];
72721
+ if (element && element.value && element.value.replace(/(\n|\s)/g, '') !== '' || data[i] && data[i].type === 'element') {
72722
+ return element.tagName === tagName ? element : undefined;
72723
+ }
72724
+ }
72725
+ else {
72726
+ const element = data[i];
72727
+ if (!element || element.type === 'element')
72728
+ return;
72729
+ if (element.type === 'text' && element.value.replace(/(\n|\s)/g, '') !== '')
72730
+ return;
72731
+ if (element.type && /^(comment|raw)$/ig.test(element.type)) {
72732
+ if (element.value && !/^rehype:/.test(element.value.replace(/^(\s+)?<!--(.*?)-->/, '$2') || '')) {
72733
+ return;
72734
+ }
72735
+ ;
72736
+ if (codeBlockParames) {
72737
+ const nextNode = nextChild(data, i, 'pre', codeBlockParames);
72738
+ if (nextNode)
72739
+ return;
72740
+ element.value = (element.value || '').replace(/^(\n|\s)+/, '');
72741
+ return element;
72742
+ }
72743
+ else {
72744
+ element.value = (element.value || '').replace(/^(\n|\s)+/, '');
72745
+ return element;
72746
+ }
72747
+ }
72748
+ }
72749
+ }
72750
+ return;
72751
+ };
72723
72752
  /**
72724
- * Check whether an element matches a `:required` pseudo.
72725
- *
72726
- * @param {RulePseudo} _
72727
- * @param {Element} element
72728
- * @returns {boolean}
72753
+ * 获取代码注视的位置
72754
+ * @param data 数据
72755
+ * @param index 当前数据所在的位置
72756
+ * @returns 返回 当前参数数据 Object,`{}`
72729
72757
  */
72730
- function required(_, element) {
72731
- return (
72732
- (element.tagName === 'input' ||
72733
- element.tagName === 'textarea' ||
72734
- element.tagName === 'select') &&
72735
- hasProperty(element, 'required')
72736
- )
72737
- }
72758
+ const getCommentObject = ({ value = '' }) => {
72759
+ const param = getURLParameters(value.replace(/^<!--(.*?)-->/, '$1').replace(/^rehype:/, ''));
72760
+ Object.keys(param).forEach((keyName) => {
72761
+ if (param[keyName] === 'true') {
72762
+ param[keyName] = true;
72763
+ }
72764
+ if (param[keyName] === 'false') {
72765
+ param[keyName] = false;
72766
+ }
72767
+ if (typeof param[keyName] === 'string' && !/^0/.test(param[keyName]) && !isNaN(+param[keyName])) {
72768
+ param[keyName] = +param[keyName];
72769
+ }
72770
+ });
72771
+ return param;
72772
+ };
72773
+ const propertiesHandle = (defaultAttrs, attrs, type) => {
72774
+ if (type === 'string') {
72775
+ return { ...defaultAttrs, 'data-config': JSON.stringify({ ...attrs, rehyp: true }) };
72776
+ }
72777
+ else if (type === 'attr') {
72778
+ return { ...defaultAttrs, ...attrs };
72779
+ }
72780
+ return { ...defaultAttrs, 'data-config': { ...attrs, rehyp: true } };
72781
+ };
72782
+ //# sourceMappingURL=utils.js.map
72783
+ ;// CONCATENATED MODULE: ../node_modules/rehype-attr/lib/index.js
72784
+
72785
+
72786
+ const rehypeAttrs = (options = {}) => {
72787
+ const { properties = 'data', codeBlockParames = true } = options;
72788
+ return (tree) => {
72789
+ visit(tree, 'element', (node, index, parent) => {
72790
+ if (codeBlockParames && node.tagName === 'pre' && node && Array.isArray(node.children) && parent && Array.isArray(parent.children) && parent.children.length > 1) {
72791
+ const firstChild = node.children[0];
72792
+ if (firstChild && firstChild.tagName === 'code' && typeof index === 'number') {
72793
+ const child = prevChild(parent.children, index);
72794
+ if (child) {
72795
+ const attr = getCommentObject(child);
72796
+ if (Object.keys(attr).length > 0) {
72797
+ node.properties = { ...node.properties, ...{ 'data-type': 'rehyp' } };
72798
+ firstChild.properties = propertiesHandle(firstChild.properties, attr, properties);
72799
+ }
72800
+ }
72801
+ }
72802
+ }
72803
+ if (/^(em|strong|b|a|i|p|pre|kbd|blockquote|h(1|2|3|4|5|6)|code|table|img|del|ul|ol)$/.test(node.tagName) && parent && Array.isArray(parent.children) && typeof index === 'number') {
72804
+ const child = nextChild(parent.children, index, '', codeBlockParames);
72805
+ if (child) {
72806
+ const attr = getCommentObject(child);
72807
+ if (Object.keys(attr).length > 0) {
72808
+ node.properties = propertiesHandle(node.properties, attr, properties);
72809
+ }
72810
+ }
72811
+ }
72812
+ });
72813
+ };
72814
+ };
72815
+ /* harmony default export */ const rehype_attr_lib = (rehypeAttrs);
72816
+ //# sourceMappingURL=index.js.map
72817
+ ;// CONCATENATED MODULE: ../node_modules/@uiw/react-markdown-preview/esm/plugins/reservedMeta.js
72818
+
72819
+
72820
+ var reservedMeta = function reservedMeta(options) {
72821
+ if (options === void 0) {
72822
+ options = {};
72823
+ }
72824
+ return tree => {
72825
+ visit(tree, node => {
72826
+ if (node.type === 'element' && node.tagName === 'code' && node.data && node.data.meta) {
72827
+ node.properties = _extends({}, node.properties, {
72828
+ 'data-meta': String(node.data.meta)
72829
+ });
72830
+ }
72831
+ });
72832
+ };
72833
+ };
72834
+ ;// CONCATENATED MODULE: ../node_modules/github-slugger/regex.js
72835
+ // This module is generated by `script/`.
72836
+ /* eslint-disable no-control-regex, no-misleading-character-class, no-useless-escape */
72837
+ const regex_regex = /[\0-\x1F!-,\.\/:-@\[-\^`\{-\xA9\xAB-\xB4\xB6-\xB9\xBB-\xBF\xD7\xF7\u02C2-\u02C5\u02D2-\u02DF\u02E5-\u02EB\u02ED\u02EF-\u02FF\u0375\u0378\u0379\u037E\u0380-\u0385\u0387\u038B\u038D\u03A2\u03F6\u0482\u0530\u0557\u0558\u055A-\u055F\u0589-\u0590\u05BE\u05C0\u05C3\u05C6\u05C8-\u05CF\u05EB-\u05EE\u05F3-\u060F\u061B-\u061F\u066A-\u066D\u06D4\u06DD\u06DE\u06E9\u06FD\u06FE\u0700-\u070F\u074B\u074C\u07B2-\u07BF\u07F6-\u07F9\u07FB\u07FC\u07FE\u07FF\u082E-\u083F\u085C-\u085F\u086B-\u089F\u08B5\u08C8-\u08D2\u08E2\u0964\u0965\u0970\u0984\u098D\u098E\u0991\u0992\u09A9\u09B1\u09B3-\u09B5\u09BA\u09BB\u09C5\u09C6\u09C9\u09CA\u09CF-\u09D6\u09D8-\u09DB\u09DE\u09E4\u09E5\u09F2-\u09FB\u09FD\u09FF\u0A00\u0A04\u0A0B-\u0A0E\u0A11\u0A12\u0A29\u0A31\u0A34\u0A37\u0A3A\u0A3B\u0A3D\u0A43-\u0A46\u0A49\u0A4A\u0A4E-\u0A50\u0A52-\u0A58\u0A5D\u0A5F-\u0A65\u0A76-\u0A80\u0A84\u0A8E\u0A92\u0AA9\u0AB1\u0AB4\u0ABA\u0ABB\u0AC6\u0ACA\u0ACE\u0ACF\u0AD1-\u0ADF\u0AE4\u0AE5\u0AF0-\u0AF8\u0B00\u0B04\u0B0D\u0B0E\u0B11\u0B12\u0B29\u0B31\u0B34\u0B3A\u0B3B\u0B45\u0B46\u0B49\u0B4A\u0B4E-\u0B54\u0B58-\u0B5B\u0B5E\u0B64\u0B65\u0B70\u0B72-\u0B81\u0B84\u0B8B-\u0B8D\u0B91\u0B96-\u0B98\u0B9B\u0B9D\u0BA0-\u0BA2\u0BA5-\u0BA7\u0BAB-\u0BAD\u0BBA-\u0BBD\u0BC3-\u0BC5\u0BC9\u0BCE\u0BCF\u0BD1-\u0BD6\u0BD8-\u0BE5\u0BF0-\u0BFF\u0C0D\u0C11\u0C29\u0C3A-\u0C3C\u0C45\u0C49\u0C4E-\u0C54\u0C57\u0C5B-\u0C5F\u0C64\u0C65\u0C70-\u0C7F\u0C84\u0C8D\u0C91\u0CA9\u0CB4\u0CBA\u0CBB\u0CC5\u0CC9\u0CCE-\u0CD4\u0CD7-\u0CDD\u0CDF\u0CE4\u0CE5\u0CF0\u0CF3-\u0CFF\u0D0D\u0D11\u0D45\u0D49\u0D4F-\u0D53\u0D58-\u0D5E\u0D64\u0D65\u0D70-\u0D79\u0D80\u0D84\u0D97-\u0D99\u0DB2\u0DBC\u0DBE\u0DBF\u0DC7-\u0DC9\u0DCB-\u0DCE\u0DD5\u0DD7\u0DE0-\u0DE5\u0DF0\u0DF1\u0DF4-\u0E00\u0E3B-\u0E3F\u0E4F\u0E5A-\u0E80\u0E83\u0E85\u0E8B\u0EA4\u0EA6\u0EBE\u0EBF\u0EC5\u0EC7\u0ECE\u0ECF\u0EDA\u0EDB\u0EE0-\u0EFF\u0F01-\u0F17\u0F1A-\u0F1F\u0F2A-\u0F34\u0F36\u0F38\u0F3A-\u0F3D\u0F48\u0F6D-\u0F70\u0F85\u0F98\u0FBD-\u0FC5\u0FC7-\u0FFF\u104A-\u104F\u109E\u109F\u10C6\u10C8-\u10CC\u10CE\u10CF\u10FB\u1249\u124E\u124F\u1257\u1259\u125E\u125F\u1289\u128E\u128F\u12B1\u12B6\u12B7\u12BF\u12C1\u12C6\u12C7\u12D7\u1311\u1316\u1317\u135B\u135C\u1360-\u137F\u1390-\u139F\u13F6\u13F7\u13FE-\u1400\u166D\u166E\u1680\u169B-\u169F\u16EB-\u16ED\u16F9-\u16FF\u170D\u1715-\u171F\u1735-\u173F\u1754-\u175F\u176D\u1771\u1774-\u177F\u17D4-\u17D6\u17D8-\u17DB\u17DE\u17DF\u17EA-\u180A\u180E\u180F\u181A-\u181F\u1879-\u187F\u18AB-\u18AF\u18F6-\u18FF\u191F\u192C-\u192F\u193C-\u1945\u196E\u196F\u1975-\u197F\u19AC-\u19AF\u19CA-\u19CF\u19DA-\u19FF\u1A1C-\u1A1F\u1A5F\u1A7D\u1A7E\u1A8A-\u1A8F\u1A9A-\u1AA6\u1AA8-\u1AAF\u1AC1-\u1AFF\u1B4C-\u1B4F\u1B5A-\u1B6A\u1B74-\u1B7F\u1BF4-\u1BFF\u1C38-\u1C3F\u1C4A-\u1C4C\u1C7E\u1C7F\u1C89-\u1C8F\u1CBB\u1CBC\u1CC0-\u1CCF\u1CD3\u1CFB-\u1CFF\u1DFA\u1F16\u1F17\u1F1E\u1F1F\u1F46\u1F47\u1F4E\u1F4F\u1F58\u1F5A\u1F5C\u1F5E\u1F7E\u1F7F\u1FB5\u1FBD\u1FBF-\u1FC1\u1FC5\u1FCD-\u1FCF\u1FD4\u1FD5\u1FDC-\u1FDF\u1FED-\u1FF1\u1FF5\u1FFD-\u203E\u2041-\u2053\u2055-\u2070\u2072-\u207E\u2080-\u208F\u209D-\u20CF\u20F1-\u2101\u2103-\u2106\u2108\u2109\u2114\u2116-\u2118\u211E-\u2123\u2125\u2127\u2129\u212E\u213A\u213B\u2140-\u2144\u214A-\u214D\u214F-\u215F\u2189-\u24B5\u24EA-\u2BFF\u2C2F\u2C5F\u2CE5-\u2CEA\u2CF4-\u2CFF\u2D26\u2D28-\u2D2C\u2D2E\u2D2F\u2D68-\u2D6E\u2D70-\u2D7E\u2D97-\u2D9F\u2DA7\u2DAF\u2DB7\u2DBF\u2DC7\u2DCF\u2DD7\u2DDF\u2E00-\u2E2E\u2E30-\u3004\u3008-\u3020\u3030\u3036\u3037\u303D-\u3040\u3097\u3098\u309B\u309C\u30A0\u30FB\u3100-\u3104\u3130\u318F-\u319F\u31C0-\u31EF\u3200-\u33FF\u4DC0-\u4DFF\u9FFD-\u9FFF\uA48D-\uA4CF\uA4FE\uA4FF\uA60D-\uA60F\uA62C-\uA63F\uA673\uA67E\uA6F2-\uA716\uA720\uA721\uA789\uA78A\uA7C0\uA7C1\uA7CB-\uA7F4\uA828-\uA82B\uA82D-\uA83F\uA874-\uA87F\uA8C6-\uA8CF\uA8DA-\uA8DF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA954-\uA95F\uA97D-\uA97F\uA9C1-\uA9CE\uA9DA-\uA9DF\uA9FF\uAA37-\uAA3F\uAA4E\uAA4F\uAA5A-\uAA5F\uAA77-\uAA79\uAAC3-\uAADA\uAADE\uAADF\uAAF0\uAAF1\uAAF7-\uAB00\uAB07\uAB08\uAB0F\uAB10\uAB17-\uAB1F\uAB27\uAB2F\uAB5B\uAB6A-\uAB6F\uABEB\uABEE\uABEF\uABFA-\uABFF\uD7A4-\uD7AF\uD7C7-\uD7CA\uD7FC-\uD7FF\uE000-\uF8FF\uFA6E\uFA6F\uFADA-\uFAFF\uFB07-\uFB12\uFB18-\uFB1C\uFB29\uFB37\uFB3D\uFB3F\uFB42\uFB45\uFBB2-\uFBD2\uFD3E-\uFD4F\uFD90\uFD91\uFDC8-\uFDEF\uFDFC-\uFDFF\uFE10-\uFE1F\uFE30-\uFE32\uFE35-\uFE4C\uFE50-\uFE6F\uFE75\uFEFD-\uFF0F\uFF1A-\uFF20\uFF3B-\uFF3E\uFF40\uFF5B-\uFF65\uFFBF-\uFFC1\uFFC8\uFFC9\uFFD0\uFFD1\uFFD8\uFFD9\uFFDD-\uFFFF]|\uD800[\uDC0C\uDC27\uDC3B\uDC3E\uDC4E\uDC4F\uDC5E-\uDC7F\uDCFB-\uDD3F\uDD75-\uDDFC\uDDFE-\uDE7F\uDE9D-\uDE9F\uDED1-\uDEDF\uDEE1-\uDEFF\uDF20-\uDF2C\uDF4B-\uDF4F\uDF7B-\uDF7F\uDF9E\uDF9F\uDFC4-\uDFC7\uDFD0\uDFD6-\uDFFF]|\uD801[\uDC9E\uDC9F\uDCAA-\uDCAF\uDCD4-\uDCD7\uDCFC-\uDCFF\uDD28-\uDD2F\uDD64-\uDDFF\uDF37-\uDF3F\uDF56-\uDF5F\uDF68-\uDFFF]|\uD802[\uDC06\uDC07\uDC09\uDC36\uDC39-\uDC3B\uDC3D\uDC3E\uDC56-\uDC5F\uDC77-\uDC7F\uDC9F-\uDCDF\uDCF3\uDCF6-\uDCFF\uDD16-\uDD1F\uDD3A-\uDD7F\uDDB8-\uDDBD\uDDC0-\uDDFF\uDE04\uDE07-\uDE0B\uDE14\uDE18\uDE36\uDE37\uDE3B-\uDE3E\uDE40-\uDE5F\uDE7D-\uDE7F\uDE9D-\uDEBF\uDEC8\uDEE7-\uDEFF\uDF36-\uDF3F\uDF56-\uDF5F\uDF73-\uDF7F\uDF92-\uDFFF]|\uD803[\uDC49-\uDC7F\uDCB3-\uDCBF\uDCF3-\uDCFF\uDD28-\uDD2F\uDD3A-\uDE7F\uDEAA\uDEAD-\uDEAF\uDEB2-\uDEFF\uDF1D-\uDF26\uDF28-\uDF2F\uDF51-\uDFAF\uDFC5-\uDFDF\uDFF7-\uDFFF]|\uD804[\uDC47-\uDC65\uDC70-\uDC7E\uDCBB-\uDCCF\uDCE9-\uDCEF\uDCFA-\uDCFF\uDD35\uDD40-\uDD43\uDD48-\uDD4F\uDD74\uDD75\uDD77-\uDD7F\uDDC5-\uDDC8\uDDCD\uDDDB\uDDDD-\uDDFF\uDE12\uDE38-\uDE3D\uDE3F-\uDE7F\uDE87\uDE89\uDE8E\uDE9E\uDEA9-\uDEAF\uDEEB-\uDEEF\uDEFA-\uDEFF\uDF04\uDF0D\uDF0E\uDF11\uDF12\uDF29\uDF31\uDF34\uDF3A\uDF45\uDF46\uDF49\uDF4A\uDF4E\uDF4F\uDF51-\uDF56\uDF58-\uDF5C\uDF64\uDF65\uDF6D-\uDF6F\uDF75-\uDFFF]|\uD805[\uDC4B-\uDC4F\uDC5A-\uDC5D\uDC62-\uDC7F\uDCC6\uDCC8-\uDCCF\uDCDA-\uDD7F\uDDB6\uDDB7\uDDC1-\uDDD7\uDDDE-\uDDFF\uDE41-\uDE43\uDE45-\uDE4F\uDE5A-\uDE7F\uDEB9-\uDEBF\uDECA-\uDEFF\uDF1B\uDF1C\uDF2C-\uDF2F\uDF3A-\uDFFF]|\uD806[\uDC3B-\uDC9F\uDCEA-\uDCFE\uDD07\uDD08\uDD0A\uDD0B\uDD14\uDD17\uDD36\uDD39\uDD3A\uDD44-\uDD4F\uDD5A-\uDD9F\uDDA8\uDDA9\uDDD8\uDDD9\uDDE2\uDDE5-\uDDFF\uDE3F-\uDE46\uDE48-\uDE4F\uDE9A-\uDE9C\uDE9E-\uDEBF\uDEF9-\uDFFF]|\uD807[\uDC09\uDC37\uDC41-\uDC4F\uDC5A-\uDC71\uDC90\uDC91\uDCA8\uDCB7-\uDCFF\uDD07\uDD0A\uDD37-\uDD39\uDD3B\uDD3E\uDD48-\uDD4F\uDD5A-\uDD5F\uDD66\uDD69\uDD8F\uDD92\uDD99-\uDD9F\uDDAA-\uDEDF\uDEF7-\uDFAF\uDFB1-\uDFFF]|\uD808[\uDF9A-\uDFFF]|\uD809[\uDC6F-\uDC7F\uDD44-\uDFFF]|[\uD80A\uD80B\uD80E-\uD810\uD812-\uD819\uD824-\uD82B\uD82D\uD82E\uD830-\uD833\uD837\uD839\uD83D\uD83F\uD87B-\uD87D\uD87F\uD885-\uDB3F\uDB41-\uDBFF][\uDC00-\uDFFF]|\uD80D[\uDC2F-\uDFFF]|\uD811[\uDE47-\uDFFF]|\uD81A[\uDE39-\uDE3F\uDE5F\uDE6A-\uDECF\uDEEE\uDEEF\uDEF5-\uDEFF\uDF37-\uDF3F\uDF44-\uDF4F\uDF5A-\uDF62\uDF78-\uDF7C\uDF90-\uDFFF]|\uD81B[\uDC00-\uDE3F\uDE80-\uDEFF\uDF4B-\uDF4E\uDF88-\uDF8E\uDFA0-\uDFDF\uDFE2\uDFE5-\uDFEF\uDFF2-\uDFFF]|\uD821[\uDFF8-\uDFFF]|\uD823[\uDCD6-\uDCFF\uDD09-\uDFFF]|\uD82C[\uDD1F-\uDD4F\uDD53-\uDD63\uDD68-\uDD6F\uDEFC-\uDFFF]|\uD82F[\uDC6B-\uDC6F\uDC7D-\uDC7F\uDC89-\uDC8F\uDC9A-\uDC9C\uDC9F-\uDFFF]|\uD834[\uDC00-\uDD64\uDD6A-\uDD6C\uDD73-\uDD7A\uDD83\uDD84\uDD8C-\uDDA9\uDDAE-\uDE41\uDE45-\uDFFF]|\uD835[\uDC55\uDC9D\uDCA0\uDCA1\uDCA3\uDCA4\uDCA7\uDCA8\uDCAD\uDCBA\uDCBC\uDCC4\uDD06\uDD0B\uDD0C\uDD15\uDD1D\uDD3A\uDD3F\uDD45\uDD47-\uDD49\uDD51\uDEA6\uDEA7\uDEC1\uDEDB\uDEFB\uDF15\uDF35\uDF4F\uDF6F\uDF89\uDFA9\uDFC3\uDFCC\uDFCD]|\uD836[\uDC00-\uDDFF\uDE37-\uDE3A\uDE6D-\uDE74\uDE76-\uDE83\uDE85-\uDE9A\uDEA0\uDEB0-\uDFFF]|\uD838[\uDC07\uDC19\uDC1A\uDC22\uDC25\uDC2B-\uDCFF\uDD2D-\uDD2F\uDD3E\uDD3F\uDD4A-\uDD4D\uDD4F-\uDEBF\uDEFA-\uDFFF]|\uD83A[\uDCC5-\uDCCF\uDCD7-\uDCFF\uDD4C-\uDD4F\uDD5A-\uDFFF]|\uD83B[\uDC00-\uDDFF\uDE04\uDE20\uDE23\uDE25\uDE26\uDE28\uDE33\uDE38\uDE3A\uDE3C-\uDE41\uDE43-\uDE46\uDE48\uDE4A\uDE4C\uDE50\uDE53\uDE55\uDE56\uDE58\uDE5A\uDE5C\uDE5E\uDE60\uDE63\uDE65\uDE66\uDE6B\uDE73\uDE78\uDE7D\uDE7F\uDE8A\uDE9C-\uDEA0\uDEA4\uDEAA\uDEBC-\uDFFF]|\uD83C[\uDC00-\uDD2F\uDD4A-\uDD4F\uDD6A-\uDD6F\uDD8A-\uDFFF]|\uD83E[\uDC00-\uDFEF\uDFFA-\uDFFF]|\uD869[\uDEDE-\uDEFF]|\uD86D[\uDF35-\uDF3F]|\uD86E[\uDC1E\uDC1F]|\uD873[\uDEA2-\uDEAF]|\uD87A[\uDFE1-\uDFFF]|\uD87E[\uDE1E-\uDFFF]|\uD884[\uDF4B-\uDFFF]|\uDB40[\uDC00-\uDCFF\uDDF0-\uDFFF]/g
72838
+
72839
+ ;// CONCATENATED MODULE: ../node_modules/github-slugger/index.js
72840
+
72841
+
72842
+ const github_slugger_own = Object.hasOwnProperty
72738
72843
 
72739
72844
  /**
72740
- * Check whether an element matches a `:root` pseudo.
72741
- *
72742
- * @param {RulePseudo} _
72743
- * @param {Element} element
72744
- * @param {number | undefined} _1
72745
- * @param {Parent | undefined} parent
72746
- * @param {SelectState} state
72747
- * @returns {boolean}
72845
+ * Slugger.
72748
72846
  */
72749
- function pseudo_root(_, element, _1, parent, state) {
72750
- return Boolean(
72751
- (!parent || parent.type === 'root') &&
72752
- state.schema &&
72753
- (state.schema.space === 'html' || state.schema.space === 'svg') &&
72754
- (element.tagName === 'html' || element.tagName === 'svg')
72755
- )
72847
+ class BananaSlug {
72848
+ /**
72849
+ * Create a new slug class.
72850
+ */
72851
+ constructor () {
72852
+ /** @type {Record<string, number>} */
72853
+ // eslint-disable-next-line no-unused-expressions
72854
+ this.occurrences
72855
+
72856
+ this.reset()
72857
+ }
72858
+
72859
+ /**
72860
+ * Generate a unique slug.
72861
+ *
72862
+ * Tracks previously generated slugs: repeated calls with the same value
72863
+ * will result in different slugs.
72864
+ * Use the `slug` function to get same slugs.
72865
+ *
72866
+ * @param {string} value
72867
+ * String of text to slugify
72868
+ * @param {boolean} [maintainCase=false]
72869
+ * Keep the current case, otherwise make all lowercase
72870
+ * @return {string}
72871
+ * A unique slug string
72872
+ */
72873
+ slug (value, maintainCase) {
72874
+ const self = this
72875
+ let result = slug(value, maintainCase === true)
72876
+ const originalSlug = result
72877
+
72878
+ while (github_slugger_own.call(self.occurrences, result)) {
72879
+ self.occurrences[originalSlug]++
72880
+ result = originalSlug + '-' + self.occurrences[originalSlug]
72881
+ }
72882
+
72883
+ self.occurrences[result] = 0
72884
+
72885
+ return result
72886
+ }
72887
+
72888
+ /**
72889
+ * Reset - Forget all previous slugs
72890
+ *
72891
+ * @return void
72892
+ */
72893
+ reset () {
72894
+ this.occurrences = Object.create(null)
72895
+ }
72756
72896
  }
72757
72897
 
72758
72898
  /**
72759
- * Check whether an element matches a `:scope` pseudo.
72899
+ * Generate a slug.
72760
72900
  *
72761
- * @param {RulePseudo} _
72762
- * @param {Element} element
72763
- * @param {number | undefined} _1
72764
- * @param {Parent | undefined} _2
72765
- * @param {SelectState} state
72766
- * @returns {boolean}
72901
+ * Does not track previously generated slugs: repeated calls with the same value
72902
+ * will result in the exact same slug.
72903
+ * Use the `GithubSlugger` class to get unique slugs.
72904
+ *
72905
+ * @param {string} value
72906
+ * String of text to slugify
72907
+ * @param {boolean} [maintainCase=false]
72908
+ * Keep the current case, otherwise make all lowercase
72909
+ * @return {string}
72910
+ * A unique slug string
72767
72911
  */
72768
- function scope(_, element, _1, _2, state) {
72769
- return state.scopeElements.includes(element)
72770
- }
72771
-
72772
- // Shouldn’t be called, parser gives correct data.
72773
- /* c8 ignore next 3 */
72774
- function invalidPseudo() {
72775
- throw new Error('Invalid pseudo-selector')
72912
+ function slug (value, maintainCase) {
72913
+ if (typeof value !== 'string') return ''
72914
+ if (!maintainCase) value = value.toLowerCase()
72915
+ return value.replace(regex_regex, '').replace(/ /g, '-')
72776
72916
  }
72777
72917
 
72918
+ ;// CONCATENATED MODULE: ../node_modules/hast-util-heading-rank/lib/index.js
72778
72919
  /**
72779
- * @param {unknown} query
72780
- * @returns {never}
72920
+ * @typedef {import('hast').Root} Root
72921
+ * @typedef {import('hast').Content} Content
72781
72922
  */
72782
- function unknownPseudo(query) {
72783
- // @ts-expect-error: indexable.
72784
- if (query.name) {
72785
- // @ts-expect-error: indexable.
72786
- throw new Error('Unknown pseudo-selector `' + query.name + '`')
72787
- }
72788
-
72789
- throw new Error('Unexpected pseudo-element or empty pseudo-class')
72790
- }
72791
72923
 
72792
72924
  /**
72793
- * Check children.
72794
- *
72795
- * @param {Element} element
72796
- * @param {(child: ElementChild) => boolean} check
72797
- * @returns {boolean}
72925
+ * @typedef {Root | Content} Node
72798
72926
  */
72799
- function someChildren(element, check) {
72800
- const children = element.children
72801
- let index = -1
72802
-
72803
- while (++index < children.length) {
72804
- if (check(children[index])) return true
72805
- }
72806
-
72807
- return false
72808
- }
72809
72927
 
72928
+ // To do next major: return `undefined`.
72810
72929
  /**
72811
- * @param {SelectState} state
72812
- * @param {RulePseudo} query
72930
+ * Get the rank (`1` to `6`) of headings (`h1` to `h6`).
72931
+ *
72932
+ * @param {Node} node
72933
+ * Node to check.
72934
+ * @returns {number | null}
72935
+ * Rank of the heading or `null` if not a heading.
72813
72936
  */
72814
- function assertDeep(state, query) {
72815
- if (state.shallow) {
72816
- throw new Error('Cannot use `:' + query.name + '` without parent')
72817
- }
72937
+ function headingRank(node) {
72938
+ const name =
72939
+ (node && node.type === 'element' && node.tagName.toLowerCase()) || ''
72940
+ const code =
72941
+ name.length === 2 && name.charCodeAt(0) === 104 /* `h` */
72942
+ ? name.charCodeAt(1)
72943
+ : 0
72944
+ return code > 48 /* `0` */ && code < 55 /* `7` */ ? code - 48 /* `0` */ : null
72818
72945
  }
72819
72946
 
72947
+ ;// CONCATENATED MODULE: ../node_modules/rehype-slug/index.js
72820
72948
  /**
72821
- * @param {RulePseudo} query
72822
- * @returns {(value: number) => boolean}
72949
+ * @typedef {import('hast').Root} Root
72823
72950
  */
72824
- function getCachedNthCheck(query) {
72825
- /** @type {(value: number) => boolean} */
72826
- // @ts-expect-error: cache.
72827
- let fn = query._cachedFn
72828
-
72829
- if (!fn) {
72830
- // @ts-expect-error: always string.
72831
- fn = pseudo_nthCheck(query.value)
72832
- // @ts-expect-error: cache.
72833
- query._cachedFn = fn
72834
- }
72835
-
72836
- return fn
72837
- }
72838
72951
 
72839
- ;// CONCATENATED MODULE: ../node_modules/hast-util-select/lib/test.js
72840
72952
  /**
72841
- * @typedef {import('./types.js').Rule} Rule
72842
- * @typedef {import('./types.js').Element} Element
72843
- * @typedef {import('./types.js').Parent} Parent
72844
- * @typedef {import('./types.js').SelectState} SelectState
72953
+ * @typedef Options
72954
+ * Configuration (optional).
72955
+ * @property {string} [prefix='']
72956
+ * Prefix to add in front of `id`s.
72845
72957
  */
72846
72958
 
72847
72959
 
@@ -72850,505 +72962,519 @@ function getCachedNthCheck(query) {
72850
72962
 
72851
72963
 
72852
72964
 
72965
+ const slugs = new BananaSlug()
72966
+
72853
72967
  /**
72854
- * Test a rule.
72968
+ * Plugin to add `id`s to headings.
72855
72969
  *
72856
- * @param {Rule} query
72857
- * @param {Element} element
72858
- * @param {number | undefined} index
72859
- * @param {Parent | undefined} parent
72860
- * @param {SelectState} state
72861
- * @returns {boolean}
72970
+ * @type {import('unified').Plugin<[Options?]|Array<void>, Root>}
72862
72971
  */
72863
- function test(query, element, index, parent, state) {
72864
- return Boolean(
72865
- (!query.tagName || name_name(query, element)) &&
72866
- (!query.classNames || className(query, element)) &&
72867
- (!query.id || id(query, element)) &&
72868
- (!query.attrs || attribute(query, element, state.schema)) &&
72869
- (!query.pseudos || pseudo(query, element, index, parent, state))
72870
- )
72972
+ function rehypeSlug(options = {}) {
72973
+ const prefix = options.prefix || ''
72974
+
72975
+ return (tree) => {
72976
+ slugs.reset()
72977
+
72978
+ visit(tree, 'element', (node) => {
72979
+ if (headingRank(node) && node.properties && !hasProperty(node, 'id')) {
72980
+ node.properties.id = prefix + slugs.slug(hast_util_to_string_toString(node))
72981
+ }
72982
+ })
72983
+ }
72871
72984
  }
72872
72985
 
72873
- ;// CONCATENATED MODULE: ../node_modules/hast-util-select/lib/walk.js
72986
+ ;// CONCATENATED MODULE: ../node_modules/hast-util-is-element/index.js
72874
72987
  /**
72875
- * @typedef {import('./types.js').Node} Node
72876
- * @typedef {import('./types.js').Element} Element
72877
- * @typedef {import('./types.js').Parent} Parent
72878
- * @typedef {import('./types.js').RuleSet} RuleSet
72879
- * @typedef {import('./types.js').SelectState} SelectState
72880
- * @typedef {import('./types.js').Selectors} Selectors
72881
- *
72882
- * @typedef Nest
72883
- * Rule sets by nesting.
72884
- * @property {Array<RuleSet> | undefined} descendant
72885
- * `a b`
72886
- * @property {Array<RuleSet> | undefined} directChild
72887
- * `a > b`
72888
- * @property {Array<RuleSet> | undefined} adjacentSibling
72889
- * `a + b`
72890
- * @property {Array<RuleSet> | undefined} generalSibling
72891
- * `a ~ b`
72892
- *
72893
- * @typedef Counts
72894
- * Info on elements in a parent.
72895
- * @property {number} count
72896
- * Number of elements.
72897
- * @property {Map<string, number>} types
72898
- * Number of elements by tag name.
72988
+ * @typedef {import('unist').Parent} Parent
72989
+ * @typedef {import('hast').Element} Element
72899
72990
  */
72900
72991
 
72992
+ /**
72993
+ * @typedef {null | undefined | string | TestFunctionAnything | Array<string | TestFunctionAnything>} Test
72994
+ * Check for an arbitrary element, unaware of TypeScript inferral.
72995
+ *
72996
+ * @callback TestFunctionAnything
72997
+ * Check if an element passes a test, unaware of TypeScript inferral.
72998
+ * @param {Element} element
72999
+ * An element.
73000
+ * @param {number | null | undefined} [index]
73001
+ * The element’s position in its parent.
73002
+ * @param {Parent | null | undefined} [parent]
73003
+ * The element’s parent.
73004
+ * @returns {boolean | void}
73005
+ * Whether this element passes the test.
73006
+ */
72901
73007
 
72902
-
72903
-
72904
- /** @type {Array<never>} */
72905
- const walk_empty = []
73008
+ /**
73009
+ * @template {Element} T
73010
+ * Element type.
73011
+ * @typedef {T['tagName'] | TestFunctionPredicate<T> | Array<T['tagName'] | TestFunctionPredicate<T>>} PredicateTest
73012
+ * Check for an element that can be inferred by TypeScript.
73013
+ */
72906
73014
 
72907
73015
  /**
72908
- * Turn a query into a uniform object.
73016
+ * Check if an element passes a certain node test.
72909
73017
  *
72910
- * @param {Selectors | RuleSet | null} query
72911
- * @returns {Selectors}
73018
+ * @template {Element} T
73019
+ * Element type.
73020
+ * @callback TestFunctionPredicate
73021
+ * Complex test function for an element that can be inferred by TypeScript.
73022
+ * @param {Element} element
73023
+ * An element.
73024
+ * @param {number | null | undefined} [index]
73025
+ * The element’s position in its parent.
73026
+ * @param {Parent | null | undefined} [parent]
73027
+ * The element’s parent.
73028
+ * @returns {element is T}
73029
+ * Whether this element passes the test.
72912
73030
  */
72913
- function queryToSelectors(query) {
72914
- if (query === null) {
72915
- return {type: 'selectors', selectors: []}
72916
- }
72917
-
72918
- if (query.type === 'ruleSet') {
72919
- return {type: 'selectors', selectors: [query]}
72920
- }
72921
73031
 
72922
- return query
72923
- }
73032
+ /**
73033
+ * @callback AssertAnything
73034
+ * Check that an arbitrary value is an element, unaware of TypeScript inferral.
73035
+ * @param {unknown} [node]
73036
+ * Anything (typically a node).
73037
+ * @param {number | null | undefined} [index]
73038
+ * The node’s position in its parent.
73039
+ * @param {Parent | null | undefined} [parent]
73040
+ * The node’s parent.
73041
+ * @returns {boolean}
73042
+ * Whether this is an element and passes a test.
73043
+ */
72924
73044
 
72925
73045
  /**
72926
- * Walk a tree.
73046
+ * Check if a node is an element and passes a certain node test
72927
73047
  *
72928
- * @param {SelectState} state
72929
- * @param {Node | undefined} tree
73048
+ * @template {Element} T
73049
+ * Element type.
73050
+ * @callback AssertPredicate
73051
+ * Check that an arbitrary value is a specific element, aware of TypeScript.
73052
+ * @param {unknown} [node]
73053
+ * Anything (typically a node).
73054
+ * @param {number | null | undefined} [index]
73055
+ * The node’s position in its parent.
73056
+ * @param {Parent | null | undefined} [parent]
73057
+ * The node’s parent.
73058
+ * @returns {node is T}
73059
+ * Whether this is an element and passes a test.
72930
73060
  */
72931
- function walk_walk(state, tree) {
72932
- if (tree) {
72933
- walk_one(state, [], tree, undefined, undefined)
72934
- }
72935
- }
72936
73061
 
72937
73062
  /**
72938
- * Check a node.
73063
+ * Check if `node` is an `Element` and whether it passes the given test.
72939
73064
  *
72940
- * @param {SelectState} state
72941
- * @param {Array<RuleSet>} currentRules
72942
- * @param {Node} node
72943
- * @param {number | undefined} index
72944
- * @param {Parent | undefined} parent
72945
- * @returns {Nest}
73065
+ * @param node
73066
+ * Thing to check, typically `Node`.
73067
+ * @param test
73068
+ * A check for a specific element.
73069
+ * @param index
73070
+ * The node’s position in its parent.
73071
+ * @param parent
73072
+ * The node’s parent.
73073
+ * @returns
73074
+ * Whether `node` is an element and passes a test.
72946
73075
  */
72947
- function walk_one(state, currentRules, node, index, parent) {
72948
- /** @type {Nest} */
72949
- let nestResult = {
72950
- directChild: undefined,
72951
- descendant: undefined,
72952
- adjacentSibling: undefined,
72953
- generalSibling: undefined
72954
- }
72955
- const exit = enterState(state, node)
73076
+ const isElement =
73077
+ /**
73078
+ * @type {(
73079
+ * (() => false) &
73080
+ * (<T extends Element = Element>(node: unknown, test?: PredicateTest<T>, index?: number, parent?: Parent, context?: unknown) => node is T) &
73081
+ * ((node: unknown, test: Test, index?: number, parent?: Parent, context?: unknown) => boolean)
73082
+ * )}
73083
+ */
73084
+ (
73085
+ /**
73086
+ * @param {unknown} [node]
73087
+ * @param {Test | undefined} [test]
73088
+ * @param {number | null | undefined} [index]
73089
+ * @param {Parent | null | undefined} [parent]
73090
+ * @param {unknown} [context]
73091
+ * @returns {boolean}
73092
+ */
73093
+ // eslint-disable-next-line max-params
73094
+ function (node, test, index, parent, context) {
73095
+ const check = convertElement(test)
72956
73096
 
72957
- if (node.type === 'element') {
72958
- nestResult = applySelectors(
72959
- state,
72960
- // Try the root rules for this element too.
72961
- combine(currentRules, state.rootQuery.selectors),
72962
- node,
72963
- index,
72964
- parent
72965
- )
72966
- }
73097
+ if (
73098
+ index !== undefined &&
73099
+ index !== null &&
73100
+ (typeof index !== 'number' ||
73101
+ index < 0 ||
73102
+ index === Number.POSITIVE_INFINITY)
73103
+ ) {
73104
+ throw new Error('Expected positive finite index for child node')
73105
+ }
72967
73106
 
72968
- // If this is a parent, and we want to delve into them, and we haven’t found
72969
- // our single result yet.
72970
- if ('children' in node && !state.shallow && !(state.one && state.found)) {
72971
- walk_all(state, nestResult, node)
72972
- }
73107
+ if (
73108
+ parent !== undefined &&
73109
+ parent !== null &&
73110
+ (!parent.type || !parent.children)
73111
+ ) {
73112
+ throw new Error('Expected parent node')
73113
+ }
72973
73114
 
72974
- exit()
73115
+ // @ts-expect-error Looks like a node.
73116
+ if (!node || !node.type || typeof node.type !== 'string') {
73117
+ return false
73118
+ }
72975
73119
 
72976
- return nestResult
72977
- }
73120
+ if (
73121
+ (parent === undefined || parent === null) !==
73122
+ (index === undefined || index === null)
73123
+ ) {
73124
+ throw new Error('Expected both parent and index')
73125
+ }
73126
+
73127
+ return check.call(context, node, index, parent)
73128
+ }
73129
+ )
72978
73130
 
72979
73131
  /**
72980
- * Check a node.
73132
+ * Generate an assertion from a test.
72981
73133
  *
72982
- * @param {SelectState} state
72983
- * @param {Nest} nest
72984
- * @param {Parent} node
72985
- * @returns {void}
73134
+ * Useful if you’re going to test many nodes, for example when creating a
73135
+ * utility where something else passes a compatible test.
73136
+ *
73137
+ * The created function is a bit faster because it expects valid input only:
73138
+ * a `node`, `index`, and `parent`.
73139
+ *
73140
+ * @param test
73141
+ * * When nullish, checks if `node` is an `Element`.
73142
+ * * When `string`, works like passing `(element) => element.tagName === test`.
73143
+ * * When `function` checks if function passed the element is true.
73144
+ * * When `array`, checks any one of the subtests pass.
73145
+ * @returns
73146
+ * An assertion.
72986
73147
  */
72987
- function walk_all(state, nest, node) {
72988
- const fromParent = combine(nest.descendant, nest.directChild)
72989
- /** @type {Array<RuleSet> | undefined} */
72990
- let fromSibling
72991
- let index = -1
72992
- /**
72993
- * Total counts.
72994
- * @type {Counts}
72995
- */
72996
- const total = {count: 0, types: new Map()}
73148
+ const convertElement =
72997
73149
  /**
72998
- * Counts of previous siblings.
72999
- * @type {Counts}
73150
+ * @type {(
73151
+ * (<T extends Element>(test: T['tagName'] | TestFunctionPredicate<T>) => AssertPredicate<T>) &
73152
+ * ((test?: Test) => AssertAnything)
73153
+ * )}
73000
73154
  */
73001
- const before = {count: 0, types: new Map()}
73002
-
73003
- while (++index < node.children.length) {
73004
- count(total, node.children[index])
73005
- }
73155
+ (
73156
+ /**
73157
+ * @param {Test | null | undefined} [test]
73158
+ * @returns {AssertAnything}
73159
+ */
73160
+ function (test) {
73161
+ if (test === undefined || test === null) {
73162
+ return hast_util_is_element_element
73163
+ }
73006
73164
 
73007
- index = -1
73165
+ if (typeof test === 'string') {
73166
+ return tagNameFactory(test)
73167
+ }
73008
73168
 
73009
- while (++index < node.children.length) {
73010
- const child = node.children[index]
73011
- // Uppercase to prevent prototype polution, injecting `constructor` or so.
73012
- // Normalize because HTML is insensitive.
73013
- const name =
73014
- child.type === 'element' ? child.tagName.toUpperCase() : undefined
73015
- // Before counting further elements:
73016
- state.elementIndex = before.count
73017
- state.typeIndex = name ? before.types.get(name) || 0 : 0
73018
- // After counting all elements.
73019
- state.elementCount = total.count
73020
- state.typeCount = name ? total.types.get(name) : 0
73169
+ if (typeof test === 'object') {
73170
+ return hast_util_is_element_anyFactory(test)
73171
+ }
73021
73172
 
73022
- // Only apply if this is a parent, this should be an element, but we check
73023
- // for parents so that we delve into custom nodes too.
73024
- if ('children' in child) {
73025
- const forSibling = combine(fromParent, fromSibling)
73026
- const nest = walk_one(state, forSibling, node.children[index], index, node)
73027
- fromSibling = combine(nest.generalSibling, nest.adjacentSibling)
73028
- }
73173
+ if (typeof test === 'function') {
73174
+ return hast_util_is_element_castFactory(test)
73175
+ }
73029
73176
 
73030
- // We found one thing, and one is enough.
73031
- if (state.one && state.found) {
73032
- break
73177
+ throw new Error('Expected function, string, or array as test')
73033
73178
  }
73034
-
73035
- count(before, node.children[index])
73036
- }
73037
- }
73179
+ )
73038
73180
 
73039
73181
  /**
73040
- * Apply selectors to an element.
73182
+ * Handle multiple tests.
73041
73183
  *
73042
- * @param {SelectState} state
73043
- * Current state.
73044
- * @param {Array<RuleSet>} rules
73045
- * Rules to apply.
73046
- * @param {Element} node
73047
- * Element to apply rules to.
73048
- * @param {number | undefined} index
73049
- * Index of node in parent.
73050
- * @param {Parent | undefined} parent
73051
- * Parent of node.
73052
- * @returns {Nest}
73053
- * Further rules.
73184
+ * @param {Array<string | TestFunctionAnything>} tests
73185
+ * @returns {AssertAnything}
73054
73186
  */
73055
- function applySelectors(state, rules, node, index, parent) {
73056
- /** @type {Nest} */
73057
- const nestResult = {
73058
- directChild: undefined,
73059
- descendant: undefined,
73060
- adjacentSibling: undefined,
73061
- generalSibling: undefined
73062
- }
73063
- let selectorIndex = -1
73064
-
73065
- while (++selectorIndex < rules.length) {
73066
- const ruleSet = rules[selectorIndex]
73067
-
73068
- // We found one thing, and one is enough.
73069
- if (state.one && state.found) {
73070
- break
73071
- }
73187
+ function hast_util_is_element_anyFactory(tests) {
73188
+ /** @type {Array<AssertAnything>} */
73189
+ const checks = []
73190
+ let index = -1
73072
73191
 
73073
- // When shallow, we don’t allow nested rules.
73074
- // Idea: we could allow a stack of parents?
73075
- // Might get quite complex though.
73076
- if (state.shallow && ruleSet.rule.rule) {
73077
- throw new Error('Expected selector without nesting')
73078
- }
73192
+ while (++index < tests.length) {
73193
+ checks[index] = convertElement(tests[index])
73194
+ }
73079
73195
 
73080
- // If this rule matches:
73081
- if (test(ruleSet.rule, node, index, parent, state)) {
73082
- const nest = ruleSet.rule.rule
73196
+ return hast_util_is_element_castFactory(any)
73083
73197
 
73084
- // Are there more?
73085
- if (nest) {
73086
- /** @type {RuleSet} */
73087
- const rule = {type: 'ruleSet', rule: nest}
73088
- /** @type {keyof Nest} */
73089
- const label =
73090
- nest.nestingOperator === '+'
73091
- ? 'adjacentSibling'
73092
- : nest.nestingOperator === '~'
73093
- ? 'generalSibling'
73094
- : nest.nestingOperator === '>'
73095
- ? 'directChild'
73096
- : 'descendant'
73097
- add(nestResult, label, rule)
73098
- } else {
73099
- // We have a match!
73100
- state.found = true
73198
+ /**
73199
+ * @this {unknown}
73200
+ * @param {Array<unknown>} parameters
73201
+ * @returns {boolean}
73202
+ */
73203
+ function any(...parameters) {
73204
+ let index = -1
73101
73205
 
73102
- if (!state.results.includes(node)) {
73103
- state.results.push(node)
73104
- }
73206
+ while (++index < checks.length) {
73207
+ if (checks[index].call(this, ...parameters)) {
73208
+ return true
73105
73209
  }
73106
73210
  }
73107
73211
 
73108
- // Descendant.
73109
- if (ruleSet.rule.nestingOperator === null) {
73110
- add(nestResult, 'descendant', ruleSet)
73111
- }
73112
- // Adjacent.
73113
- else if (ruleSet.rule.nestingOperator === '~') {
73114
- add(nestResult, 'generalSibling', ruleSet)
73115
- }
73116
- // Drop top-level nesting (`undefined`), direct child (`>`), adjacent sibling (`+`).
73212
+ return false
73117
73213
  }
73214
+ }
73118
73215
 
73119
- return nestResult
73216
+ /**
73217
+ * Turn a string into a test for an element with a certain tag name.
73218
+ *
73219
+ * @param {string} check
73220
+ * @returns {AssertAnything}
73221
+ */
73222
+ function tagNameFactory(check) {
73223
+ return tagName
73224
+
73225
+ /**
73226
+ * @param {unknown} node
73227
+ * @returns {boolean}
73228
+ */
73229
+ function tagName(node) {
73230
+ return hast_util_is_element_element(node) && node.tagName === check
73231
+ }
73120
73232
  }
73121
73233
 
73122
73234
  /**
73123
- * Combine two lists, if needed.
73124
- *
73125
- * This is optimized to create as few lists as possible.
73235
+ * Turn a custom test into a test for an element that passes that test.
73126
73236
  *
73127
- * @param {Array<RuleSet> | undefined} left
73128
- * @param {Array<RuleSet> | undefined} right
73129
- * @returns {Array<RuleSet>}
73237
+ * @param {TestFunctionAnything} check
73238
+ * @returns {AssertAnything}
73130
73239
  */
73131
- function combine(left, right) {
73132
- return left && right && left.length > 0 && right.length > 0
73133
- ? [...left, ...right]
73134
- : left && left.length > 0
73135
- ? left
73136
- : right && right.length > 0
73137
- ? right
73138
- : walk_empty
73240
+ function hast_util_is_element_castFactory(check) {
73241
+ return assertion
73242
+
73243
+ /**
73244
+ * @this {unknown}
73245
+ * @param {unknown} node
73246
+ * @param {Array<unknown>} parameters
73247
+ * @returns {boolean}
73248
+ */
73249
+ function assertion(node, ...parameters) {
73250
+ // @ts-expect-error: fine.
73251
+ return hast_util_is_element_element(node) && Boolean(check.call(this, node, ...parameters))
73252
+ }
73139
73253
  }
73140
73254
 
73141
73255
  /**
73142
- * Add a rule to a nesting map.
73256
+ * Make sure something is an element.
73143
73257
  *
73144
- * @param {Nest} nest
73145
- * @param {keyof Nest} field
73146
- * @param {RuleSet} rule
73258
+ * @param {unknown} node
73259
+ * @returns {node is Element}
73147
73260
  */
73148
- function add(nest, field, rule) {
73149
- const list = nest[field]
73150
- if (list) {
73151
- list.push(rule)
73152
- } else {
73153
- nest[field] = [rule]
73154
- }
73261
+ function hast_util_is_element_element(node) {
73262
+ return Boolean(
73263
+ node &&
73264
+ typeof node === 'object' &&
73265
+ // @ts-expect-error Looks like a node.
73266
+ node.type === 'element' &&
73267
+ // @ts-expect-error Looks like an element.
73268
+ typeof node.tagName === 'string'
73269
+ )
73155
73270
  }
73156
73271
 
73272
+ ;// CONCATENATED MODULE: ../node_modules/rehype-autolink-headings/lib/index.js
73157
73273
  /**
73158
- * Count a node.
73274
+ * @typedef {import('hast').Root} Root
73275
+ * @typedef {import('hast').Parent} Parent
73276
+ * @typedef {import('hast').Element} Element
73277
+ * @typedef {Element['children'][number]} ElementChild
73278
+ * @typedef {import('hast').Properties} Properties
73279
+ * @typedef {import('hast-util-is-element').Test} Test
73159
73280
  *
73160
- * @param {Counts} counts
73161
- * Counts.
73162
- * @param {Node} node
73163
- * Node (we’re looking for elements).
73164
- * @returns {void}
73165
- * Nothing.
73281
+ * @typedef {'prepend'|'append'|'wrap'|'before'|'after'} Behavior
73282
+ *
73283
+ * @callback Build
73284
+ * @param {Element} node
73285
+ * @returns {ElementChild|ElementChild[]}
73286
+ *
73287
+ * @typedef Options
73288
+ * Configuration.
73289
+ * @property {Behavior} [behavior='prepend']
73290
+ * How to create links.
73291
+ * @property {Behavior} [behaviour]
73292
+ * Please use `behavior` instead
73293
+ * @property {Properties} [properties]
73294
+ * Extra properties to set on the link when injecting.
73295
+ * Defaults to `{ariaHidden: true, tabIndex: -1}` when `'prepend'` or
73296
+ * `'append'`.
73297
+ * @property {ElementChild|ElementChild[]|Build} [content={type: 'element', tagName: 'span', properties: {className: ['icon', 'icon-link']}, children: []}]
73298
+ * hast nodes to insert in the link.
73299
+ * @property {ElementChild|ElementChild[]|Build} [group]
73300
+ * hast node to wrap the heading and link with, if `behavior` is `'before'` or
73301
+ * `'after'`.
73302
+ * There is no default.
73303
+ * @property {Test} [test]
73304
+ * Test to define which heading elements are linked.
73305
+ * Any test that can be given to `hast-util-is-element` is supported.
73306
+ * The default (no test) is to link all headings.
73307
+ * Can be used to link only h1-h3, or for example all except h1.
73166
73308
  */
73167
- function count(counts, node) {
73168
- if (node.type === 'element') {
73169
- // Uppercase to prevent prototype polution, injecting `constructor` or so.
73170
- // Normalize because HTML is insensitive.
73171
- const name = node.tagName.toUpperCase()
73172
- const count = (counts.types.get(name) || 0) + 1
73173
- counts.count++
73174
- counts.types.set(name, count)
73175
- }
73309
+
73310
+
73311
+
73312
+
73313
+
73314
+
73315
+
73316
+ /** @type {Element} */
73317
+ const contentDefaults = {
73318
+ type: 'element',
73319
+ tagName: 'span',
73320
+ properties: {className: ['icon', 'icon-link']},
73321
+ children: []
73176
73322
  }
73177
73323
 
73178
- // EXTERNAL MODULE: ../node_modules/css-selector-parser/lib/index.js
73179
- var css_selector_parser_lib = __webpack_require__(301);
73180
- ;// CONCATENATED MODULE: ../node_modules/hast-util-select/lib/parse.js
73181
73324
  /**
73182
- * @typedef {import('./types.js').Selectors} Selectors
73183
- * @typedef {import('./types.js').RuleSet} RuleSet
73325
+ * Plugin to automatically add links to headings (h1-h6).
73326
+ *
73327
+ * @type {import('unified').Plugin<[Options?]|void[], Root>}
73184
73328
  */
73329
+ function rehypeAutolinkHeadings(options = {}) {
73330
+ let props = options.properties
73331
+ const behavior = options.behaviour || options.behavior || 'prepend'
73332
+ const content = options.content || contentDefaults
73333
+ const group = options.group
73334
+ const is = convertElement(options.test)
73185
73335
 
73336
+ /** @type {import('unist-util-visit/complex-types').Visitor<Element>} */
73337
+ let method
73186
73338
 
73339
+ if (behavior === 'wrap') {
73340
+ method = wrap
73341
+ } else if (behavior === 'before' || behavior === 'after') {
73342
+ method = around
73343
+ } else {
73344
+ if (!props) {
73345
+ props = {ariaHidden: 'true', tabIndex: -1}
73346
+ }
73187
73347
 
73188
- const parse_parser = new css_selector_parser_lib/* CssSelectorParser */.N()
73348
+ method = inject
73349
+ }
73189
73350
 
73190
- parse_parser.registerAttrEqualityMods('~', '|', '^', '$', '*')
73191
- parse_parser.registerSelectorPseudos('any', 'matches', 'not', 'has')
73192
- parse_parser.registerNestingOperators('>', '+', '~')
73351
+ return (tree) => {
73352
+ visit(tree, 'element', (node, index, parent) => {
73353
+ if (
73354
+ headingRank(node) &&
73355
+ hasProperty(node, 'id') &&
73356
+ is(node, index, parent)
73357
+ ) {
73358
+ return method(node, index, parent)
73359
+ }
73360
+ })
73361
+ }
73193
73362
 
73194
- /**
73195
- * @param {string} selector
73196
- * @returns {Selectors | RuleSet | null}
73197
- */
73198
- function lib_parse_parse(selector) {
73199
- if (typeof selector !== 'string') {
73200
- throw new TypeError('Expected `string` as selector, not `' + selector + '`')
73363
+ /** @type {import('unist-util-visit/complex-types').Visitor<Element>} */
73364
+ function inject(node) {
73365
+ node.children[behavior === 'prepend' ? 'unshift' : 'push'](
73366
+ create(node, extend(true, {}, props), toChildren(content, node))
73367
+ )
73368
+
73369
+ return [SKIP]
73201
73370
  }
73202
73371
 
73203
- return parse_parser.parse(selector)
73204
- }
73372
+ /** @type {import('unist-util-visit/complex-types').Visitor<Element>} */
73373
+ function around(node, index, parent) {
73374
+ // Uncommon.
73375
+ /* c8 ignore next */
73376
+ if (typeof index !== 'number' || !parent) return
73205
73377
 
73206
- ;// CONCATENATED MODULE: ../node_modules/hast-util-select/lib/index.js
73207
- /**
73208
- * @typedef {import('./types.js').Element} Element
73209
- * @typedef {import('./types.js').Node} Node
73210
- * @typedef {import('./types.js').Space} Space
73211
- * @typedef {import('./types.js').SelectState} SelectState
73212
- */
73378
+ const link = create(
73379
+ node,
73380
+ extend(true, {}, props),
73381
+ toChildren(content, node)
73382
+ )
73383
+ let nodes = behavior === 'before' ? [link, node] : [node, link]
73213
73384
 
73385
+ if (group) {
73386
+ const grouping = toNode(group, node)
73214
73387
 
73388
+ if (grouping && !Array.isArray(grouping) && grouping.type === 'element') {
73389
+ grouping.children = nodes
73390
+ nodes = [grouping]
73391
+ }
73392
+ }
73215
73393
 
73394
+ parent.children.splice(index, 1, ...nodes)
73216
73395
 
73396
+ return [SKIP, index + nodes.length]
73397
+ }
73217
73398
 
73218
- /**
73219
- * Check that the given `node` matches `selector`.
73220
- *
73221
- * This only checks the element itself, not the surrounding tree.
73222
- * Thus, nesting in selectors is not supported (`p b`, `p > b`), neither are
73223
- * selectors like `:first-child`, etc.
73224
- * This only checks that the given element matches the selector.
73225
- *
73226
- * @param {string} selector
73227
- * CSS selector, such as (`h1`, `a, b`).
73228
- * @param {Node | null | undefined} [node]
73229
- * Node that might match `selector`, should be an element.
73230
- * @param {Space | null | undefined} [space='html']
73231
- * Name of namespace (`'svg'` or `'html'`).
73232
- * @returns {boolean}
73233
- * Whether `node` matches `selector`.
73234
- */
73235
- function lib_matches(selector, node, space) {
73236
- const state = lib_createState(selector, node, space)
73237
- state.one = true
73238
- state.shallow = true
73239
- walk(state, node || undefined)
73240
- return state.results.length > 0
73241
- }
73399
+ /** @type {import('unist-util-visit/complex-types').Visitor<Element>} */
73400
+ function wrap(node) {
73401
+ node.children = [create(node, extend(true, {}, props), node.children)]
73402
+ return [SKIP]
73403
+ }
73242
73404
 
73243
- /**
73244
- * Select the first element that matches `selector` in the given `tree`.
73245
- * Searches the tree in *preorder*.
73246
- *
73247
- * @param {string} selector
73248
- * CSS selector, such as (`h1`, `a, b`).
73249
- * @param {Node | null | undefined} [tree]
73250
- * Tree to search.
73251
- * @param {Space | null | undefined} [space='html']
73252
- * Name of namespace (`'svg'` or `'html'`).
73253
- * @returns {Element | null}
73254
- * First element in `tree` that matches `selector` or `null` if nothing is
73255
- * found.
73256
- * This could be `tree` itself.
73257
- */
73258
- function lib_select(selector, tree, space) {
73259
- const state = lib_createState(selector, tree, space)
73260
- state.one = true
73261
- walk(state, tree || undefined)
73262
- // To do in major: return `undefined` instead.
73263
- return state.results[0] || null
73264
- }
73405
+ /**
73406
+ * @param {ElementChild|ElementChild[]|Build} value
73407
+ * @param {Element} node
73408
+ * @returns {ElementChild[]}
73409
+ */
73410
+ function toChildren(value, node) {
73411
+ const result = toNode(value, node)
73412
+ return Array.isArray(result) ? result : [result]
73413
+ }
73265
73414
 
73266
- /**
73267
- * Select all elements that match `selector` in the given `tree`.
73268
- * Searches the tree in *preorder*.
73269
- *
73270
- * @param {string} selector
73271
- * CSS selector, such as (`h1`, `a, b`).
73272
- * @param {Node | null | undefined} [tree]
73273
- * Tree to search.
73274
- * @param {Space | null | undefined} [space='html']
73275
- * Name of namespace (`'svg'` or `'html'`).
73276
- * @returns {Array<Element>}
73277
- * Elements in `tree` that match `selector`.
73278
- * This could include `tree` itself.
73279
- */
73280
- function selectAll(selector, tree, space) {
73281
- const state = lib_createState(selector, tree, space)
73282
- walk_walk(state, tree || undefined)
73283
- return state.results
73284
- }
73415
+ /**
73416
+ * @param {ElementChild|ElementChild[]|Build} value
73417
+ * @param {Element} node
73418
+ * @returns {ElementChild|ElementChild[]}
73419
+ */
73420
+ function toNode(value, node) {
73421
+ if (typeof value === 'function') return value(node)
73422
+ return extend(true, Array.isArray(value) ? [] : {}, value)
73423
+ }
73285
73424
 
73286
- /**
73287
- * @param {string} selector
73288
- * Tree to search.
73289
- * @param {Node | null | undefined} [tree]
73290
- * Tree to search.
73291
- * @param {Space | null | undefined} [space='html']
73292
- * Name of namespace (`'svg'` or `'html'`).
73293
- * @returns {SelectState} SelectState
73294
- */
73295
- function lib_createState(selector, tree, space) {
73296
- return {
73297
- // State of the query.
73298
- rootQuery: queryToSelectors(lib_parse_parse(selector)),
73299
- results: [],
73300
- // @ts-expect-error assume elements.
73301
- scopeElements: tree ? (tree.type === 'root' ? tree.children : [tree]) : [],
73302
- one: false,
73303
- shallow: false,
73304
- found: false,
73305
- // State in the tree.
73306
- schema: space === 'svg' ? property_information_svg : property_information_html,
73307
- language: undefined,
73308
- direction: 'ltr',
73309
- editableOrEditingHost: false,
73310
- typeIndex: undefined,
73311
- elementIndex: undefined,
73312
- typeCount: undefined,
73313
- elementCount: undefined
73425
+ /**
73426
+ * @param {Element} node
73427
+ * @param {Properties} props
73428
+ * @param {ElementChild[]} children
73429
+ * @returns {Element}
73430
+ */
73431
+ function create(node, props, children) {
73432
+ return {
73433
+ type: 'element',
73434
+ tagName: 'a',
73435
+ properties: Object.assign({}, props, {
73436
+ // Fix hast types and make them required.
73437
+ /* c8 ignore next */
73438
+ href: '#' + (node.properties || {}).id
73439
+ }),
73440
+ children
73441
+ }
73314
73442
  }
73315
73443
  }
73316
73444
 
73317
- ;// CONCATENATED MODULE: ../node_modules/rehype-rewrite/lib/index.js
73318
-
73445
+ ;// CONCATENATED MODULE: ../node_modules/rehype-ignore/lib/index.js
73319
73446
 
73320
- /** Get the node tree source code string */
73321
- const getCodeString = (data = [], code = '') => {
73322
- data.forEach((node) => {
73323
- if (node.type === 'text') {
73324
- code += node.value;
73325
- }
73326
- else if (node.type === 'element' && node.children && Array.isArray(node.children)) {
73327
- code += getCodeString(node.children);
73328
- }
73329
- });
73330
- return code;
73331
- };
73332
- const remarkRewrite = (options) => {
73333
- const { selector, rewrite } = options || {};
73447
+ const rehypeIgnore = (options = {}) => {
73448
+ const { openDelimiter = 'rehype:ignore:start', closeDelimiter = 'rehype:ignore:end' } = options;
73334
73449
  return (tree) => {
73335
- if (!rewrite || typeof rewrite !== 'function')
73336
- return;
73337
- if (selector && typeof selector === 'string') {
73338
- const selected = selectAll(selector, tree);
73339
- if (selected && selected.length > 0) {
73340
- visit(tree, selected, (node, index, parent) => {
73341
- rewrite(node, index, parent);
73450
+ visit(tree, (node, index, parent) => {
73451
+ if (node.type === 'element' || node.type === 'root') {
73452
+ // const start = node.children.findIndex((item) => item.type === 'comment' && item.value === openDelimiter);
73453
+ // const end = node.children.findIndex((item) => item.type === 'comment' && item.value === closeDelimiter);
73454
+ // if (start > -1 && end > -1) {
73455
+ // node.children = node.children.filter((_, idx) => idx < start || idx > end);
73456
+ // }
73457
+ let start = false;
73458
+ node.children = node.children.filter((item) => {
73459
+ if (item.type === 'raw' || item.type === 'comment') {
73460
+ let str = (item.value || '').trim();
73461
+ str = str.replace(/^<!--(.*?)-->/, '$1');
73462
+ if (str === openDelimiter) {
73463
+ start = true;
73464
+ return false;
73465
+ }
73466
+ if (str === closeDelimiter) {
73467
+ start = false;
73468
+ return false;
73469
+ }
73470
+ }
73471
+ return !start;
73342
73472
  });
73343
73473
  }
73344
- return;
73345
- }
73346
- visit(tree, (node, index, parent) => {
73347
- rewrite(node, index, parent);
73348
73474
  });
73349
73475
  };
73350
73476
  };
73351
- /* harmony default export */ const rehype_rewrite_lib = (remarkRewrite);
73477
+ /* harmony default export */ const rehype_ignore_lib = (rehypeIgnore);
73352
73478
  //# sourceMappingURL=index.js.map
73353
73479
  ;// CONCATENATED MODULE: ../node_modules/@uiw/react-markdown-preview/esm/nodes/octiconLink.js
73354
73480
  var octiconLink = {
@@ -73435,77 +73561,32 @@ function copyElement(str) {
73435
73561
  }]
73436
73562
  };
73437
73563
  }
73438
- // EXTERNAL MODULE: ../node_modules/@uiw/copy-to-clipboard/dist/copy-to-clipboard.umd.js
73439
- var copy_to_clipboard_umd = __webpack_require__(5028);
73440
- var copy_to_clipboard_umd_default = /*#__PURE__*/__webpack_require__.n(copy_to_clipboard_umd);
73441
- ;// CONCATENATED MODULE: ../node_modules/@uiw/react-markdown-preview/esm/plugins/useCopied.js
73442
-
73443
-
73444
- function getParentElement(target) {
73445
- if (!target) return null;
73446
- var dom = target;
73447
- if (dom.dataset.code && dom.classList.contains('copied')) {
73448
- return dom;
73449
- }
73450
- if (dom.parentElement) {
73451
- return getParentElement(dom.parentElement);
73452
- }
73453
- return null;
73454
- }
73455
- function useCopied(container) {
73456
- var handle = event => {
73457
- var target = getParentElement(event.target);
73458
- if (!target) return;
73459
- target.classList.add('active');
73460
- copy_to_clipboard_umd_default()(target.dataset.code, function () {
73461
- setTimeout(() => {
73462
- target.classList.remove('active');
73463
- }, 2000);
73464
- });
73465
- };
73466
- (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(() => {
73467
- var _container$current, _container$current2;
73468
- (_container$current = container.current) == null || _container$current.removeEventListener('click', handle, false);
73469
- (_container$current2 = container.current) == null || _container$current2.addEventListener('click', handle, false);
73470
- return () => {
73471
- var _container$current3;
73472
- (_container$current3 = container.current) == null || _container$current3.removeEventListener('click', handle, false);
73473
- };
73474
- // eslint-disable-next-line react-hooks/exhaustive-deps
73475
- }, [container]);
73476
- }
73477
- ;// CONCATENATED MODULE: ../node_modules/@uiw/react-markdown-preview/esm/styles/markdown.css
73478
- // extracted by mini-css-extract-plugin
73479
- /* harmony default export */ const styles_markdown = ({});
73480
- ;// CONCATENATED MODULE: ../node_modules/@uiw/react-markdown-preview/esm/plugins/reservedMeta.js
73481
-
73482
-
73483
- var reservedMeta = function reservedMeta(options) {
73484
- if (options === void 0) {
73485
- options = {};
73486
- }
73487
- return tree => {
73488
- visit(tree, node => {
73489
- if (node.type === 'element' && node.tagName === 'code' && node.data && node.data.meta) {
73490
- node.properties = _extends({}, node.properties, {
73491
- 'data-meta': String(node.data.meta)
73492
- });
73493
- }
73494
- });
73495
- };
73496
- };
73497
- // EXTERNAL MODULE: ../node_modules/react/jsx-runtime.js
73498
- var jsx_runtime = __webpack_require__(4246);
73499
- ;// CONCATENATED MODULE: ../node_modules/@uiw/react-markdown-preview/esm/index.js
73500
-
73564
+ ;// CONCATENATED MODULE: ../node_modules/@uiw/react-markdown-preview/esm/rehypePlugins.js
73501
73565
 
73502
- var _excluded = ["prefixCls", "className", "source", "style", "disableCopy", "skipHtml", "onScroll", "onMouseOver", "pluginsFilter", "rehypeRewrite", "wrapperElement", "warpperElement"];
73503
73566
 
73504
73567
 
73505
73568
 
73506
73569
 
73507
73570
 
73508
73571
 
73572
+ var rehypeRewriteHandle = (disableCopy, rewrite) => (node, index, parent) => {
73573
+ if (node.type === 'element' && parent && parent.type === 'root' && /h(1|2|3|4|5|6)/.test(node.tagName)) {
73574
+ var child = node.children && node.children[0];
73575
+ if (child && child.properties && child.properties.ariaHidden === 'true') {
73576
+ child.properties = _extends({
73577
+ class: 'anchor'
73578
+ }, child.properties);
73579
+ child.children = [octiconLink];
73580
+ }
73581
+ }
73582
+ if (node.type === 'element' && node.tagName === 'pre' && !disableCopy) {
73583
+ var code = getCodeString(node.children);
73584
+ node.children.push(copyElement(code));
73585
+ }
73586
+ rewrite && rewrite(node, index, parent);
73587
+ };
73588
+ var defaultRehypePlugins = [rehypeSlug, rehypeAutolinkHeadings, rehype_ignore_lib];
73589
+ ;// CONCATENATED MODULE: ../node_modules/@uiw/react-markdown-preview/esm/index.js
73509
73590
 
73510
73591
 
73511
73592
 
@@ -73517,76 +73598,17 @@ var _excluded = ["prefixCls", "className", "source", "style", "disableCopy", "sk
73517
73598
 
73518
73599
 
73519
73600
  /* harmony default export */ const esm = (/*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().forwardRef((props, ref) => {
73520
- var {
73521
- prefixCls = 'wmde-markdown wmde-markdown-color',
73522
- className,
73523
- source,
73524
- style,
73525
- disableCopy = false,
73526
- skipHtml = true,
73527
- onScroll,
73528
- onMouseOver,
73529
- pluginsFilter,
73530
- rehypeRewrite: rewrite,
73531
- wrapperElement = {},
73532
- warpperElement = {}
73533
- } = props,
73534
- other = _objectWithoutPropertiesLoose(props, _excluded);
73535
- var mdp = external_root_React_commonjs2_react_commonjs_react_amd_react_default().useRef(null);
73536
- (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useImperativeHandle)(ref, () => _extends({}, props, {
73537
- mdp
73538
- }), [mdp, props]);
73539
- var cls = (prefixCls || '') + " " + (className || '');
73540
- useCopied(mdp);
73541
- var rehypeRewriteHandle = (node, index, parent) => {
73542
- if (node.type === 'element' && parent && parent.type === 'root' && /h(1|2|3|4|5|6)/.test(node.tagName)) {
73543
- var child = node.children && node.children[0];
73544
- if (child && child.properties && child.properties.ariaHidden === 'true') {
73545
- child.properties = _extends({
73546
- class: 'anchor'
73547
- }, child.properties);
73548
- child.children = [octiconLink];
73549
- }
73550
- }
73551
- if (node.type === 'element' && node.tagName === 'pre' && !disableCopy) {
73552
- var code = getCodeString(node.children);
73553
- node.children.push(copyElement(code));
73554
- }
73555
- rewrite && rewrite(node, index, parent);
73556
- };
73601
+ var _props$disableCopy;
73557
73602
  var rehypePlugins = [reservedMeta, [f, {
73558
73603
  ignoreMissing: true
73559
- }], rehypeSlug, rehypeAutolinkHeadings, rehype_ignore_lib, [rehype_rewrite_lib, {
73560
- rewrite: rehypeRewriteHandle
73604
+ }], ...defaultRehypePlugins, [rehype_rewrite_lib, {
73605
+ rewrite: rehypeRewriteHandle((_props$disableCopy = props.disableCopy) != null ? _props$disableCopy : false, props.rehypeRewrite)
73561
73606
  }], [rehype_attr_lib, {
73562
73607
  properties: 'attr'
73563
- }], ...(other.rehypePlugins || [])];
73564
- var customProps = {
73565
- allowElement: (element, index, parent) => {
73566
- if (other.allowElement) {
73567
- return other.allowElement(element, index, parent);
73568
- }
73569
- return /^[A-Za-z0-9]+$/.test(element.tagName);
73570
- }
73571
- };
73572
- if (skipHtml) {
73573
- rehypePlugins.push(rehypeRaw);
73574
- }
73575
- var remarkPlugins = [...(other.remarkPlugins || []), remarkGfm];
73576
- var wrapperProps = _extends({}, warpperElement, wrapperElement);
73577
- return /*#__PURE__*/(0,jsx_runtime.jsx)("div", _extends({
73578
- ref: mdp,
73579
- onScroll: onScroll,
73580
- onMouseOver: onMouseOver
73581
- }, wrapperProps, {
73582
- className: cls,
73583
- style: style,
73584
- children: /*#__PURE__*/(0,jsx_runtime.jsx)(ReactMarkdown, _extends({}, customProps, other, {
73585
- skipHtml: skipHtml,
73586
- rehypePlugins: pluginsFilter ? pluginsFilter('rehype', rehypePlugins) : rehypePlugins,
73587
- remarkPlugins: pluginsFilter ? pluginsFilter('remark', remarkPlugins) : remarkPlugins,
73588
- children: source || ''
73589
- }))
73608
+ }], ...(props.rehypePlugins || [])];
73609
+ return /*#__PURE__*/(0,jsx_runtime.jsx)(preview, _extends({}, props, {
73610
+ rehypePlugins: rehypePlugins,
73611
+ ref: ref
73590
73612
  }));
73591
73613
  }));
73592
73614
  ;// CONCATENATED MODULE: ./src/Context.tsx
@@ -76051,9 +76073,6 @@ document.body.style.overflow=originalOverflow.current;}}},[fullscreen,originalOv
76051
76073
  ;// CONCATENATED MODULE: ./src/components/DragBar/index.tsx
76052
76074
  var DragBar_DragBar=function DragBar(props){var _ref=props||{},prefixCls=_ref.prefixCls,onChange=_ref.onChange;var $dom=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);var dragRef=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)();var heightRef=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(props.height);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function(){if(heightRef.current!==props.height){heightRef.current=props.height;}},[props.height]);function handleMouseMove(event){if(dragRef.current){var _changedTouches$;var clientY=event.clientY||((_changedTouches$=event.changedTouches[0])===null||_changedTouches$===void 0?void 0:_changedTouches$.clientY);var newHeight=dragRef.current.height+clientY-dragRef.current.dragY;if(newHeight>=props.minHeight&&newHeight<=props.maxHeight){onChange&&onChange(dragRef.current.height+(clientY-dragRef.current.dragY));}}}function handleMouseUp(){var _$dom$current,_$dom$current2;dragRef.current=undefined;document.removeEventListener('mousemove',handleMouseMove);document.removeEventListener('mouseup',handleMouseUp);(_$dom$current=$dom.current)===null||_$dom$current===void 0?void 0:_$dom$current.removeEventListener('touchmove',handleMouseMove);(_$dom$current2=$dom.current)===null||_$dom$current2===void 0?void 0:_$dom$current2.removeEventListener('touchend',handleMouseUp);}function handleMouseDown(event){var _changedTouches$2,_$dom$current3,_$dom$current4;event.preventDefault();var clientY=event.clientY||((_changedTouches$2=event.changedTouches[0])===null||_changedTouches$2===void 0?void 0:_changedTouches$2.clientY);dragRef.current={height:heightRef.current,dragY:clientY};document.addEventListener('mousemove',handleMouseMove);document.addEventListener('mouseup',handleMouseUp);(_$dom$current3=$dom.current)===null||_$dom$current3===void 0?void 0:_$dom$current3.addEventListener('touchmove',handleMouseMove,{passive:false});(_$dom$current4=$dom.current)===null||_$dom$current4===void 0?void 0:_$dom$current4.addEventListener('touchend',handleMouseUp,{passive:false});}(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function(){if(document){var _$dom$current5,_$dom$current6;(_$dom$current5=$dom.current)===null||_$dom$current5===void 0?void 0:_$dom$current5.addEventListener('touchstart',handleMouseDown,{passive:false});(_$dom$current6=$dom.current)===null||_$dom$current6===void 0?void 0:_$dom$current6.addEventListener('mousedown',handleMouseDown);}return function(){if(document){var _$dom$current7;(_$dom$current7=$dom.current)===null||_$dom$current7===void 0?void 0:_$dom$current7.removeEventListener('touchstart',handleMouseDown);document.removeEventListener('mousemove',handleMouseMove);}};// eslint-disable-next-line react-hooks/exhaustive-deps
76053
76075
  },[]);var svg=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function(){return/*#__PURE__*/(0,jsx_runtime.jsx)("svg",{viewBox:"0 0 512 512",height:"100%",children:/*#__PURE__*/(0,jsx_runtime.jsx)("path",{fill:"currentColor",d:"M304 256c0 26.5-21.5 48-48 48s-48-21.5-48-48 21.5-48 48-48 48 21.5 48 48zm120-48c-26.5 0-48 21.5-48 48s21.5 48 48 48 48-21.5 48-48-21.5-48-48-48zm-336 0c-26.5 0-48 21.5-48 48s21.5 48 48 48 48-21.5 48-48-21.5-48-48-48z"})});},[]);return/*#__PURE__*/(0,jsx_runtime.jsx)("div",{className:"".concat(prefixCls,"-bar"),ref:$dom,children:svg});};/* harmony default export */ const components_DragBar = (DragBar_DragBar);
76054
- ;// CONCATENATED MODULE: ./src/index.less
76055
- // extracted by mini-css-extract-plugin
76056
- /* harmony default export */ const src = ({});
76057
76076
  ;// CONCATENATED MODULE: ./src/Editor.tsx
76058
76077
  var Editor_excluded=["prefixCls","className","value","commands","commandsFilter","direction","extraCommands","height","enableScroll","visibleDragbar","highlightEnable","preview","fullscreen","overflow","previewOptions","textareaProps","maxHeight","minHeight","autoFocus","tabSize","defaultTabEnable","onChange","onStatistics","onHeightChange","hideToolbar","toolbarBottom","components","renderTextarea"];function setGroupPopFalse(){var data=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};Object.keys(data).forEach(function(keyname){data[keyname]=false;});return data;}var InternalMDEditor=/*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().forwardRef(function(props,ref){var _ref=props||{},_ref$prefixCls=_ref.prefixCls,prefixCls=_ref$prefixCls===void 0?'w-md-editor':_ref$prefixCls,className=_ref.className,propsValue=_ref.value,_ref$commands=_ref.commands,commands=_ref$commands===void 0?commands_getCommands():_ref$commands,commandsFilter=_ref.commandsFilter,direction=_ref.direction,_ref$extraCommands=_ref.extraCommands,extraCommands=_ref$extraCommands===void 0?getExtraCommands():_ref$extraCommands,_ref$height=_ref.height,height=_ref$height===void 0?200:_ref$height,_ref$enableScroll=_ref.enableScroll,enableScroll=_ref$enableScroll===void 0?true:_ref$enableScroll,_ref$visibleDragbar=_ref.visibleDragbar,visibleDragbar=_ref$visibleDragbar===void 0?typeof props.visiableDragbar==='boolean'?props.visiableDragbar:true:_ref$visibleDragbar,_ref$highlightEnable=_ref.highlightEnable,highlightEnable=_ref$highlightEnable===void 0?true:_ref$highlightEnable,_ref$preview=_ref.preview,previewType=_ref$preview===void 0?'live':_ref$preview,_ref$fullscreen=_ref.fullscreen,fullscreen=_ref$fullscreen===void 0?false:_ref$fullscreen,_ref$overflow=_ref.overflow,overflow=_ref$overflow===void 0?true:_ref$overflow,_ref$previewOptions=_ref.previewOptions,previewOptions=_ref$previewOptions===void 0?{}:_ref$previewOptions,textareaProps=_ref.textareaProps,_ref$maxHeight=_ref.maxHeight,maxHeight=_ref$maxHeight===void 0?1200:_ref$maxHeight,_ref$minHeight=_ref.minHeight,minHeight=_ref$minHeight===void 0?100:_ref$minHeight,autoFocus=_ref.autoFocus,_ref$tabSize=_ref.tabSize,tabSize=_ref$tabSize===void 0?2:_ref$tabSize,_ref$defaultTabEnable=_ref.defaultTabEnable,defaultTabEnable=_ref$defaultTabEnable===void 0?false:_ref$defaultTabEnable,onChange=_ref.onChange,onStatistics=_ref.onStatistics,onHeightChange=_ref.onHeightChange,hideToolbar=_ref.hideToolbar,_ref$toolbarBottom=_ref.toolbarBottom,toolbarBottom=_ref$toolbarBottom===void 0?false:_ref$toolbarBottom,components=_ref.components,renderTextarea=_ref.renderTextarea,other=_objectWithoutProperties(_ref,Editor_excluded);var cmds=commands.map(function(item){return commandsFilter?commandsFilter(item,false):item;}).filter(Boolean);var extraCmds=extraCommands.map(function(item){return commandsFilter?commandsFilter(item,true):item;}).filter(Boolean);var _useReducer=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useReducer)(reducer,{markdown:propsValue,preview:previewType,components:components,height:height,highlightEnable:highlightEnable,tabSize:tabSize,defaultTabEnable:defaultTabEnable,scrollTop:0,scrollTopPreview:0,commands:cmds,extraCommands:extraCmds,fullscreen:fullscreen,barPopup:{}}),_useReducer2=_slicedToArray(_useReducer,2),state=_useReducer2[0],dispatch=_useReducer2[1];var container=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);var previewRef=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);var enableScrollRef=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(enableScroll);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useImperativeHandle)(ref,function(){return _objectSpread2(_objectSpread2({},state),{},{container:container.current,dispatch:dispatch});});(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function(){return enableScrollRef.current=enableScroll;},[enableScroll]);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function(){var stateInit={};if(container.current){stateInit.container=container.current||undefined;}stateInit.markdown=propsValue||'';stateInit.barPopup={};if(dispatch){dispatch(_objectSpread2(_objectSpread2({},state),stateInit));}// eslint-disable-next-line react-hooks/exhaustive-deps
76059
76078
  },[]);var cls=[className,'wmde-markdown-var',direction?"".concat(prefixCls,"-").concat(direction):null,prefixCls,state.preview?"".concat(prefixCls,"-show-").concat(state.preview):null,state.fullscreen?"".concat(prefixCls,"-fullscreen"):null].filter(Boolean).join(' ').trim();(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function(){return propsValue!==state.markdown&&dispatch({markdown:propsValue||''});},[propsValue,state.markdown]);// eslint-disable-next-line react-hooks/exhaustive-deps
@@ -76065,6 +76084,9 @@ var Editor_excluded=["prefixCls","className","value","commands","commandsFilter"
76065
76084
  (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function(){return height!==state.height&&dispatch({height:height});},[height]);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function(){return height!==state.height&&onHeightChange&&onHeightChange(state.height,height,state);},[height,onHeightChange,state]);// eslint-disable-next-line react-hooks/exhaustive-deps
76066
76085
  (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function(){return commands!==state.commands&&dispatch({commands:cmds});},[props.commands]);// eslint-disable-next-line react-hooks/exhaustive-deps
76067
76086
  (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function(){return extraCommands!==state.extraCommands&&dispatch({extraCommands:extraCmds});},[props.extraCommands]);var textareaDomRef=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)();var active=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)('preview');var initScroll=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(false);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function(){textareaDomRef.current=state.textareaWarp;if(state.textareaWarp){state.textareaWarp.addEventListener('mouseover',function(){active.current='text';});state.textareaWarp.addEventListener('mouseleave',function(){active.current='preview';});}},[state.textareaWarp]);var handleScroll=function handleScroll(e,type){if(!enableScrollRef.current)return;var textareaDom=textareaDomRef.current;var previewDom=previewRef.current?previewRef.current:undefined;if(!initScroll.current){active.current=type;initScroll.current=true;}if(textareaDom&&previewDom){var scale=(textareaDom.scrollHeight-textareaDom.offsetHeight)/(previewDom.scrollHeight-previewDom.offsetHeight);if(e.target===textareaDom&&active.current==='text'){previewDom.scrollTop=textareaDom.scrollTop/scale;}if(e.target===previewDom&&active.current==='preview'){textareaDom.scrollTop=previewDom.scrollTop*scale;}var scrollTop=0;if(active.current==='text'){scrollTop=textareaDom.scrollTop||0;}else if(active.current==='preview'){scrollTop=previewDom.scrollTop||0;}dispatch({scrollTop:scrollTop});}};var previewClassName="".concat(prefixCls,"-preview ").concat(previewOptions.className||'');var handlePreviewScroll=function handlePreviewScroll(e){return handleScroll(e,'preview');};var mdPreview=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function(){return/*#__PURE__*/(0,jsx_runtime.jsx)("div",{ref:previewRef,className:previewClassName,children:/*#__PURE__*/(0,jsx_runtime.jsx)(esm,_objectSpread2(_objectSpread2({},previewOptions),{},{onScroll:handlePreviewScroll,source:state.markdown||''}))});},[previewClassName,previewOptions,state.markdown]);var preview=(components===null||components===void 0?void 0:components.preview)&&(components===null||components===void 0?void 0:components.preview(state.markdown||'',state,dispatch));if(preview&&/*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().isValidElement(preview)){mdPreview=/*#__PURE__*/(0,jsx_runtime.jsx)("div",{className:previewClassName,ref:previewRef,onScroll:handlePreviewScroll,children:preview});}var containerStyle=_objectSpread2(_objectSpread2({},other.style),{},{height:state.height||'100%'});var containerClick=function containerClick(){return dispatch({barPopup:_objectSpread2({},setGroupPopFalse(state.barPopup))});};var dragBarChange=function dragBarChange(newHeight){return dispatch({height:newHeight});};var changeHandle=function changeHandle(evn){onChange&&onChange(evn.target.value,evn,state);if(textareaProps&&textareaProps.onChange){textareaProps.onChange(evn);}if(state.textarea&&state.textarea instanceof HTMLTextAreaElement&&onStatistics){var obj=new TextAreaCommandOrchestrator(state.textarea);var objState=obj.getState()||{};onStatistics(_objectSpread2(_objectSpread2({},objState),{},{lineCount:evn.target.value.split('\n').length,length:evn.target.value.length}));}};return/*#__PURE__*/(0,jsx_runtime.jsx)(EditorContext.Provider,{value:_objectSpread2(_objectSpread2({},state),{},{dispatch:dispatch}),children:/*#__PURE__*/(0,jsx_runtime.jsxs)("div",_objectSpread2(_objectSpread2({ref:container,className:cls},other),{},{onClick:containerClick,style:containerStyle,children:[!hideToolbar&&!toolbarBottom&&/*#__PURE__*/(0,jsx_runtime.jsx)(Toolbar_Toolbar,{prefixCls:prefixCls,overflow:overflow,toolbarBottom:toolbarBottom}),/*#__PURE__*/(0,jsx_runtime.jsxs)("div",{className:"".concat(prefixCls,"-content"),children:[/(edit|live)/.test(state.preview||'')&&/*#__PURE__*/(0,jsx_runtime.jsx)(TextArea_TextArea,_objectSpread2(_objectSpread2({className:"".concat(prefixCls,"-input"),prefixCls:prefixCls,autoFocus:autoFocus},textareaProps),{},{onChange:changeHandle,renderTextarea:(components===null||components===void 0?void 0:components.textarea)||renderTextarea,onScroll:function onScroll(e){return handleScroll(e,'text');}})),/(live|preview)/.test(state.preview||'')&&mdPreview]}),visibleDragbar&&!state.fullscreen&&/*#__PURE__*/(0,jsx_runtime.jsx)(components_DragBar,{prefixCls:prefixCls,height:state.height,maxHeight:maxHeight,minHeight:minHeight,onChange:dragBarChange}),!hideToolbar&&toolbarBottom&&/*#__PURE__*/(0,jsx_runtime.jsx)(Toolbar_Toolbar,{prefixCls:prefixCls,overflow:overflow,toolbarBottom:toolbarBottom})]}))});});var Editor=InternalMDEditor;Editor.Markdown=esm;/* harmony default export */ const src_Editor = (Editor);
76087
+ ;// CONCATENATED MODULE: ./src/index.less
76088
+ // extracted by mini-css-extract-plugin
76089
+ /* harmony default export */ const src = ({});
76068
76090
  ;// CONCATENATED MODULE: ./src/index.tsx
76069
76091
  /* harmony default export */ const src_0 = (src_Editor);
76070
76092
  })();