@lowlighter/markdown 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/README.md +29 -0
  2. package/deno.jsonc +119 -0
  3. package/deno.lock +2777 -0
  4. package/mod.mjs +1 -0
  5. package/mod.ts +2 -0
  6. package/mod_test.ts +1 -0
  7. package/package.json +42 -0
  8. package/plugins/anchors.mjs +1 -0
  9. package/plugins/anchors.ts +21 -0
  10. package/plugins/anchors_test.ts +8 -0
  11. package/plugins/directives.mjs +1 -0
  12. package/plugins/directives.ts +112 -0
  13. package/plugins/directives_test.ts +13 -0
  14. package/plugins/emojis.mjs +1 -0
  15. package/plugins/emojis.ts +20 -0
  16. package/plugins/emojis_test.ts +8 -0
  17. package/plugins/frontmatter.mjs +1 -0
  18. package/plugins/frontmatter.ts +43 -0
  19. package/plugins/frontmatter_test.ts +18 -0
  20. package/plugins/gfm.mjs +1 -0
  21. package/plugins/gfm.ts +14 -0
  22. package/plugins/gfm_test.ts +28 -0
  23. package/plugins/highlighting.mjs +1 -0
  24. package/plugins/highlighting.ts +24 -0
  25. package/plugins/highlighting_test.ts +8 -0
  26. package/plugins/linebreaks.mjs +1 -0
  27. package/plugins/linebreaks.ts +21 -0
  28. package/plugins/linebreaks_test.ts +8 -0
  29. package/plugins/markers.mjs +1 -0
  30. package/plugins/markers.ts +25 -0
  31. package/plugins/markers_test.ts +13 -0
  32. package/plugins/math.ts +25 -0
  33. package/plugins/math_test.ts +8 -0
  34. package/plugins/mermaid.ts +41 -0
  35. package/plugins/mermaid_test.ts +8 -0
  36. package/plugins/ruby.mjs +1 -0
  37. package/plugins/ruby.ts +20 -0
  38. package/plugins/ruby_test.ts +8 -0
  39. package/plugins/sanitize.mjs +1 -0
  40. package/plugins/sanitize.ts +26 -0
  41. package/plugins/sanitize_test.ts +15 -0
  42. package/plugins/uncomments.mjs +1 -0
  43. package/plugins/uncomments.ts +20 -0
  44. package/plugins/uncomments_test.ts +8 -0
  45. package/plugins/wikilinks.mjs +1 -0
  46. package/plugins/wikilinks.ts +40 -0
  47. package/plugins/wikilinks_test.ts +14 -0
  48. package/renderer.mjs +1 -0
  49. package/renderer.ts +124 -0
  50. package/renderer_test.ts +14 -0
package/mod.ts ADDED
@@ -0,0 +1,2 @@
1
+ export { Renderer } from "./renderer.ts"
2
+ export type * from "./renderer.ts"
package/mod_test.ts ADDED
@@ -0,0 +1 @@
1
+ import "./mod.ts"
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@lowlighter/markdown",
3
+ "version": "1.0.0",
4
+ "type": "module",
5
+ "scripts": {},
6
+ "dependencies": {},
7
+ "devDependencies": {},
8
+ "description": "Markdown renderer with optional plugins based on the unified ecosystem.",
9
+ "keywords": [
10
+ "markdown",
11
+ "plugins",
12
+ "gfm",
13
+ "github-flavored-markdown",
14
+ "unified",
15
+ "remark",
16
+ "rehype"
17
+ ],
18
+ "license": "MIT",
19
+ "author": "lowlighter (Simon Lecoq)",
20
+ "homepage": "https://github.com/lowlighter/libs",
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "git+https://github.com/lowlighter/libs.git"
24
+ },
25
+ "funding": "https://github.com/sponsors/lowlighter",
26
+ "exports": {
27
+ ".": "./mod.mjs",
28
+ "./renderer": "./renderer.mjs",
29
+ "./plugins/anchors": "./plugins/anchors.mjs",
30
+ "./plugins/highlighting": "./plugins/highlighting.mjs",
31
+ "./plugins/directives": "./plugins/directives.mjs",
32
+ "./plugins/emojis": "./plugins/emojis.mjs",
33
+ "./plugins/frontmatter": "./plugins/frontmatter.mjs",
34
+ "./plugins/gfm": "./plugins/gfm.mjs",
35
+ "./plugins/linebreaks": "./plugins/linebreaks.mjs",
36
+ "./plugins/markers": "./plugins/markers.mjs",
37
+ "./plugins/uncomments": "./plugins/uncomments.mjs",
38
+ "./plugins/ruby": "./plugins/ruby.mjs",
39
+ "./plugins/sanitize": "./plugins/sanitize.mjs",
40
+ "./plugins/wikilinks": "./plugins/wikilinks.mjs"
41
+ }
42
+ }
@@ -0,0 +1 @@
1
+ var u=/[\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-\u33F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DD4A-\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,D=Object.hasOwnProperty;function F(u){const D="element"===u.type?u.tagName.toLowerCase():"",F=2===D.length&&104===D.charCodeAt(0)?D.charCodeAt(1):0;return F>48&&F<55?F-48:void 0}function e(u){return"text"===u.type?u.value:"children"in u?t(u):""}function t(u){let D=-1;const F=[];for(;++D<u.children.length;)F[D]=e(u.children[D]);return F.join("")}var n=function(u){if(null==u)return C;if("function"==typeof u)return r(u);if("object"==typeof u)return Array.isArray(u)?function(u){const D=[];let F=-1;for(;++F<u.length;)D[F]=n(u[F]);return r(e);function e(...u){let F=-1;for(;++F<D.length;)if(D[F].apply(this,u))return!0;return!1}}(u):function(u){const D=u;return r(F);function F(F){const e=F;let t;for(t in u)if(e[t]!==D[t])return!1;return!0}}(u);if("string"==typeof u)return function(u){return r(D);function D(D){return D&&D.type===u}}(u);throw new Error("Expected function, string, or object as test")};function r(u){return function(D,F,e){return Boolean(function(u){return null!==u&&"object"==typeof u&&"type"in u}(D)&&u.call(this,D,"number"==typeof F?F:void 0,e||void 0))}}function C(){return!0}var E=[],A=!0,o=!1,B="skip";function c(u,D,F,e){let t;"function"==typeof D&&"function"!=typeof F?(e=F,F=D):t=D;const r=n(t),C=e?-1:1;!function u(t,n,c){const i=t&&"object"==typeof t?t:{};if("string"==typeof i.type){const u="string"==typeof i.tagName?i.tagName:"string"==typeof i.name?i.name:void 0;Object.defineProperty(s,"name",{value:"node ("+t.type+(u?"<"+u+">":"")+")"})}return s;function s(){let i,s,f,a=E;if((!D||r(t,n,c[c.length-1]||void 0))&&(a=function(u){if(Array.isArray(u))return u;if("number"==typeof u)return[A,u];return null==u?E:[u]}(F(t,c)),a[0]===o))return a;if("children"in t&&t.children){const D=t;if(D.children&&a[0]!==B)for(s=(e?D.children.length:-1)+C,f=c.concat(D);s>-1&&s<D.children.length;){const F=D.children[s];if(i=u(F,s,f)(),i[0]===o)return i;s="number"==typeof i[1]?i[1]:s+C}}return a}}(u,void 0,[])()}function i(u,D,F,e){let t,n,r;"function"==typeof D&&"function"!=typeof F?(n=void 0,r=D,t=F):(n=D,r=F,t=e),c(u,n,(function(u,D){const F=D[D.length-1],e=F?F.children.indexOf(u):void 0;return r(u,e,F)}),t)}var s={},f=new class{constructor(){this.occurrences,this.reset()}slug(F,e){const t=this;let n=function(D,F){if("string"!=typeof D)return"";F||(D=D.toLowerCase());return D.replace(u,"").replace(/ /g,"-")}(F,!0===e);const r=n;for(;D.call(t.occurrences,n);)t.occurrences[r]++,n=r+"-"+t.occurrences[r];return t.occurrences[n]=0,n}reset(){this.occurrences=Object.create(null)}};function a(u){const D=(u||s).prefix||"";return function(u){f.reset(),i(u,"element",(function(u){F(u)&&!u.properties.id&&(u.properties.id=D+f.slug(function(u){return"children"in u?t(u):"value"in u?u.value:""}(u)))}))}}var l="object"==typeof self?self:globalThis,p=u=>((u,D)=>{const F=(D,F)=>(u.set(F,D),D),e=t=>{if(u.has(t))return u.get(t);const[n,r]=D[t];switch(n){case 0:case-1:return F(r,t);case 1:{const u=F([],t);for(const D of r)u.push(e(D));return u}case 2:{const u=F({},t);for(const[D,F]of r)u[e(D)]=e(F);return u}case 3:return F(new Date(r),t);case 4:{const{source:u,flags:D}=r;return F(new RegExp(u,D),t)}case 5:{const u=F(new Map,t);for(const[D,F]of r)u.set(e(D),e(F));return u}case 6:{const u=F(new Set,t);for(const D of r)u.add(e(D));return u}case 7:{const{name:u,message:D}=r;return F(new l[u](D),t)}case 8:return F(BigInt(r),t);case"BigInt":return F(Object(BigInt(r)),t)}return F(new l[n](r),t)};return e})(new Map,u)(0),y="",{toString:h}={},{keys:g}=Object,d=u=>{const D=typeof u;if("object"!==D||!u)return[0,D];const F=h.call(u).slice(8,-1);switch(F){case"Array":return[1,y];case"Object":return[2,y];case"Date":return[3,y];case"RegExp":return[4,y];case"Map":return[5,y];case"Set":return[6,y]}return F.includes("Array")?[1,F]:F.includes("Error")?[7,F]:[2,F]},b=([u,D])=>0===u&&("function"===D||"symbol"===D),m=(u,{json:D,lossy:F}={})=>{const e=[];return((u,D,F,e)=>{const t=(u,D)=>{const t=e.push(u)-1;return F.set(D,t),t},n=e=>{if(F.has(e))return F.get(e);let[r,C]=d(e);switch(r){case 0:{let D=e;switch(C){case"bigint":r=8,D=e.toString();break;case"function":case"symbol":if(u)throw new TypeError("unable to serialize "+C);D=null;break;case"undefined":return t([-1],e)}return t([r,D],e)}case 1:{if(C)return t([C,[...e]],e);const u=[],D=t([r,u],e);for(const D of e)u.push(n(D));return D}case 2:{if(C)switch(C){case"BigInt":return t([C,e.toString()],e);case"Boolean":case"Number":case"String":return t([C,e.valueOf()],e)}if(D&&"toJSON"in e)return n(e.toJSON());const F=[],E=t([r,F],e);for(const D of g(e))!u&&b(d(e[D]))||F.push([n(D),n(e[D])]);return E}case 3:return t([r,e.toISOString()],e);case 4:{const{source:u,flags:D}=e;return t([r,{source:u,flags:D}],e)}case 5:{const D=[],F=t([r,D],e);for(const[F,t]of e)(u||!b(d(F))&&!b(d(t)))&&D.push([n(F),n(t)]);return F}case 6:{const D=[],F=t([r,D],e);for(const F of e)!u&&b(d(F))||D.push(n(F));return F}}const{message:E}=e;return t([r,{name:C,message:E}],e)};return n})(!(D||F),!!D,new Map,e)(u),e},w="function"==typeof structuredClone?(u,D)=>D&&("json"in D||"lossy"in D)?p(m(u,D)):structuredClone(u):(u,D)=>p(m(u,D)),v=function(u){if(null==u)return x;if("string"==typeof u)return function(u){return j(D);function D(D){return D.tagName===u}}(u);if("object"==typeof u)return function(u){const D=[];let F=-1;for(;++F<u.length;)D[F]=v(u[F]);return j(e);function e(...u){let F=-1;for(;++F<D.length;)if(D[F].apply(this,u))return!0;return!1}}(u);if("function"==typeof u)return j(u);throw new Error("Expected function, string, or array as `test`")};function j(u){return function(D,F,e){return Boolean(function(u){return null!==u&&"object"==typeof u&&"type"in u&&"tagName"in u}(D)&&u.call(this,D,"number"==typeof F?F:void 0,e||void 0))}}function x(u){return Boolean(u&&"object"==typeof u&&"type"in u&&"element"===u.type&&"tagName"in u&&"string"==typeof u.tagName)}var N={type:"element",tagName:"span",properties:{className:["icon","icon-link"]},children:[]},O={};function S(u){const D=u||O;let e=D.properties;const t=D.headingProperties,n=D.behavior||"prepend",r=D.content,C=D.group,E=v(D.test);let A;return"after"===n||"before"===n?A=function(u,D,F){if("number"!=typeof D||!F)return;const t=M(r||N,u),E=k(u,J(e,u),t);let A="before"===n?[E,u]:[u,E];if(C){const D=P(C,u);D&&!Array.isArray(D)&&"element"===D.type&&(D.children=A,A=[D])}return F.children.splice(D,1,...A),[B,D+A.length]}:"wrap"===n?A=function(u){let D=u.children,F=[];"function"==typeof r?(D=[],F=r(u)):r&&(F=I(r));return u.children=[k(u,J(e,u),Array.isArray(F)?[...D,...F]:[...D,F])],[B]}:(A=function(u){const D=M(r||N,u);return u.children["prepend"===n?"unshift":"push"](k(u,J(e,u),D)),[B]},e||(e={ariaHidden:"true",tabIndex:-1})),function(u){i(u,"element",(function(u,D,e){if(F(u)&&u.properties.id&&E(u,D,e))return Object.assign(u.properties,J(t,u)),A(u,D,e)}))}}function I(u){return w(u)}function k(u,D,F){return{type:"element",tagName:"a",properties:{...D,href:"#"+u.properties.id},children:F}}function M(u,D){const F=P(u,D);return Array.isArray(F)?F:[F]}function P(u,D){return"function"==typeof u?u(D):I(u)}function J(u,D){return"function"==typeof u?u(D):u?I(u):{}}var L={rehype:u=>u.use(a).use(S,{behavior:"wrap"})};export{L as default};
@@ -0,0 +1,21 @@
1
+ // Imports
2
+ import type { Plugin } from "../renderer.ts"
3
+ import rehypeSlug from "rehype-slug"
4
+ import rehypeAutolinkHeadings from "rehype-autolink-headings"
5
+
6
+ /**
7
+ * Add anchors to headings and autolink them.
8
+ *
9
+ * @example
10
+ * ```md
11
+ * # foo
12
+ * ```
13
+ * ```html
14
+ * <h1 id="foo"><a href="#foo">foo</a></h1>
15
+ * ```
16
+ */
17
+ export default {
18
+ rehype(processor) {
19
+ return processor.use(rehypeSlug).use(rehypeAutolinkHeadings, { behavior: "wrap" })
20
+ },
21
+ } as Plugin
@@ -0,0 +1,8 @@
1
+ import { expect, test } from "@libs/testing"
2
+ import { Renderer } from "../renderer.ts"
3
+ import plugin from "./anchors.ts"
4
+
5
+ test("deno")("Plugin.anchors renders headers with anchored links", async () => {
6
+ const markdown = new Renderer({ plugins: [plugin] })
7
+ await expect(markdown.render("# foo")).resolves.toMatch(/<h1 id="foo"><a.*href="#foo">foo<\/a><\/h1>/)
8
+ })
@@ -0,0 +1 @@
1
+ var e=Object.defineProperty;var n=["AElig","AMP","Aacute","Acirc","Agrave","Aring","Atilde","Auml","COPY","Ccedil","ETH","Eacute","Ecirc","Egrave","Euml","GT","Iacute","Icirc","Igrave","Iuml","LT","Ntilde","Oacute","Ocirc","Ograve","Oslash","Otilde","Ouml","QUOT","REG","THORN","Uacute","Ucirc","Ugrave","Uuml","Yacute","aacute","acirc","acute","aelig","agrave","amp","aring","atilde","auml","brvbar","ccedil","cedil","cent","copy","curren","deg","divide","eacute","ecirc","egrave","eth","euml","frac12","frac14","frac34","gt","iacute","icirc","iexcl","igrave","iquest","iuml","laquo","lt","macr","micro","middot","nbsp","not","ntilde","oacute","ocirc","ograve","ordf","ordm","oslash","otilde","ouml","para","plusmn","pound","quot","raquo","reg","sect","shy","sup1","sup2","sup3","szlig","thorn","times","uacute","ucirc","ugrave","uml","uuml","yacute","yen","yuml"],t={0:"�",128:"€",130:"‚",131:"ƒ",132:"„",133:"…",134:"†",135:"‡",136:"ˆ",137:"‰",138:"Š",139:"‹",140:"Œ",142:"Ž",145:"‘",146:"’",147:"“",148:"”",149:"•",150:"–",151:"—",152:"˜",153:"™",154:"š",155:"›",156:"œ",158:"ž",159:"Ÿ"};function l(e){const n="string"==typeof e?e.charCodeAt(0):e;return n>=48&&n<=57}function r(e){const n="string"==typeof e?e.charCodeAt(0):e;return n>=97&&n<=102||n>=65&&n<=70||n>=48&&n<=57}function i(e){return function(e){const n="string"==typeof e?e.charCodeAt(0):e;return n>=97&&n<=122||n>=65&&n<=90}(e)||l(e)}var o=document.createElement("i");function a(e){const n="&"+e+";";o.innerHTML=n;const t=o.textContent;return(59!==t.charCodeAt(t.length-1)||"semi"===e)&&(t!==n&&t)}var u=String.fromCharCode,c=["","Named character references must be terminated by a semicolon","Numeric character references must be terminated by a semicolon","Named character references cannot be empty","Numeric character references cannot be empty","Named character references must be known","Numeric character references cannot be disallowed","Numeric character references cannot be outside the permissible Unicode range"];function s(e,o={}){const s="string"==typeof o.additional?o.additional.charCodeAt(0):o.additional,f=[];let p,h,g=0,m=-1,v="";o.position&&("start"in o.position||"indent"in o.position?(h=o.position.indent,p=o.position.start):p=o.position);let y,b=(p?p.line:0)||1,x=(p?p.column:0)||1,C=A();for(g--;++g<=e.length;)if(10===y&&(x=(h?h[m]:0)||1),y=e.charCodeAt(g),38===y){const c=e.charCodeAt(g+1);if(9===c||10===c||12===c||32===c||38===c||60===c||Number.isNaN(c)||s&&c===s){v+=u(y),x++;continue}const p=g+1;let h,m=p,b=p;if(35===c){b=++m;const n=e.charCodeAt(b);88===n||120===n?(h="hexadecimal",b=++m):h="decimal"}else h="named";let D="",w="",M="";const P="named"===h?i:"decimal"===h?l:r;for(b--;++b<=e.length;){const t=e.charCodeAt(b);if(!P(t))break;M+=u(t),"named"===h&&n.includes(M)&&(D=M,w=a(M))}let T=59===e.charCodeAt(b);if(T){b++;const e="named"===h&&a(M);e&&(D=M,w=e)}let O=1+b-p,E="";if(T||!1!==o.nonTerminated)if(M)if("named"===h){if(T&&!w)S(5,1);else if(D!==M&&(b=m+D.length,O=1+b-m,T=!1),!T){const n=D?1:3;if(o.attribute){const t=e.charCodeAt(b);61===t?(S(n,O),w=""):i(t)?w="":S(n,O)}else S(n,O)}E=w}else{T||S(2,O);let e=Number.parseInt(M,"hexadecimal"===h?16:10);if((k=e)>=55296&&k<=57343||k>1114111)S(7,O),E=u(65533);else if(e in t)S(6,O),E=t[e];else{let n="";d(e)&&S(6,O),e>65535&&(e-=65536,n+=u(e>>>10|55296),e=56320|1023&e),E=n+u(e)}}else"named"!==h&&S(4,O);else;if(E){L(),C=A(),g=b-1,x+=b-p+1,f.push(E);const n=A();n.offset++,o.reference&&o.reference.call(o.referenceContext,E,{start:C,end:n},e.slice(p-1,b)),C=n}else M=e.slice(p-1,b),v+=M,x+=M.length,g=b-1}else 10===y&&(b++,m++,x=0),Number.isNaN(y)?L():(v+=u(y),x++);var k;return f.join("");function A(){return{line:b,column:x,offset:g+((p?p.offset:0)||0)}}function S(e,n){let t;o.warning&&(t=A(),t.column+=n,t.offset+=n,o.warning.call(o.warningContext,c[e],t,e))}function L(){v&&(f.push(v),o.text&&o.text.call(o.textContext,v,{start:C,end:A()}),v="")}}function d(e){return e>=1&&e<=8||11===e||e>=13&&e<=31||e>=127&&e<=159||e>=64976&&e<=65007||!(65535&~e)||65534==(65535&e)}var f=/["&'<>`]/g,p=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,h=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,g=/[|\\{}()[\]^$+*?.]/g,m=new WeakMap;function v(e,n){return e=e.replace(n.subset?function(e){let n=m.get(e);n||(n=function(e){const n=[];let t=-1;for(;++t<e.length;)n.push(e[t].replace(g,"\\$&"));return new RegExp("(?:"+n.join("|")+")","g")}(e),m.set(e,n));return n}(n.subset):f,t),n.subset||n.escapeOnly?e:e.replace(p,(function(e,t,l){return n.format(1024*(e.charCodeAt(0)-55296)+e.charCodeAt(1)-56320+65536,l.charCodeAt(t+2),n)})).replace(h,t);function t(e,t,l){return n.format(e.charCodeAt(0),l.charCodeAt(t+1),n)}}function y(e){return"&#x"+e.toString(16).toUpperCase()+";"}var b=function(e){if(null==e)return C;if("function"==typeof e)return x(e);if("object"==typeof e)return Array.isArray(e)?function(e){const n=[];let t=-1;for(;++t<e.length;)n[t]=b(e[t]);return x(l);function l(...e){let t=-1;for(;++t<n.length;)if(n[t].apply(this,e))return!0;return!1}}(e):function(e){const n=e;return x(t);function t(t){const l=t;let r;for(r in e)if(l[r]!==n[r])return!1;return!0}}(e);if("string"==typeof e)return function(e){return x(n);function n(n){return n&&n.type===e}}(e);throw new Error("Expected function, string, or object as test")};function x(e){return function(n,t,l){return Boolean(function(e){return null!==e&&"object"==typeof e&&"type"in e}(n)&&e.call(this,n,"number"==typeof t?t:void 0,l||void 0))}}function C(){return!0}var k=[],A=!0,S=!1,L="skip";function D(e,n,t,l){let r;"function"==typeof n&&"function"!=typeof t?(l=t,t=n):r=n;const i=b(r),o=l?-1:1;!function e(r,a,u){const c=r&&"object"==typeof r?r:{};if("string"==typeof c.type){const e="string"==typeof c.tagName?c.tagName:"string"==typeof c.name?c.name:void 0;Object.defineProperty(s,"name",{value:"node ("+r.type+(e?"<"+e+">":"")+")"})}return s;function s(){let c,s,d,f=k;if((!n||i(r,a,u[u.length-1]||void 0))&&(f=function(e){if(Array.isArray(e))return e;if("number"==typeof e)return[A,e];return null==e?k:[e]}(t(r,u)),f[0]===S))return f;if("children"in r&&r.children){const n=r;if(n.children&&f[0]!==L)for(s=(l?n.children.length:-1)+o,d=u.concat(n);s>-1&&s<n.children.length;){const t=n.children[s];if(c=e(t,s,d)(),c[0]===S)return c;s="number"==typeof c[1]?c[1]:s+o}}return f}}(e,void 0,[])()}var w={}.hasOwnProperty,M=/^[^\t\n\r "#'.<=>`}]+$/;function P(e){E.call(this,"containerDirective",e)}function T(e){E.call(this,"leafDirective",e)}function O(e){E.call(this,"textDirective",e)}function E(e,n){this.enter({type:e,name:"",attributes:{},children:[]},n)}function N(e){const n=this.stack[this.stack.length-1];"containerDirective"===n.type||"leafDirective"===n.type||n.type,n.name=this.sliceSerialize(e)}function z(e){this.enter({type:"paragraph",data:{directiveLabel:!0},children:[]},e)}function R(e){this.exit(e)}function I(){this.data.directiveAttributes=[],this.buffer()}function F(e){const n=this.data.directiveAttributes;n.push(["id",s(this.sliceSerialize(e),{attribute:!0})])}function U(e){const n=this.data.directiveAttributes;n.push(["class",s(this.sliceSerialize(e),{attribute:!0})])}function V(e){const n=this.data.directiveAttributes;n[n.length-1][1]=s(this.sliceSerialize(e),{attribute:!0})}function B(e){const n=this.data.directiveAttributes;n.push([this.sliceSerialize(e),""])}function j(){const e=this.data.directiveAttributes,n={};let t=-1;for(;++t<e.length;){const l=e[t];"class"===l[0]&&n.class?n.class+=" "+l[1]:n[l[0]]=l[1]}this.data.directiveAttributes=void 0,this.resume();const l=this.stack[this.stack.length-1];"containerDirective"===l.type||"leafDirective"===l.type||l.type,l.attributes=n}function H(e){this.exit(e)}function q(e,n,t,l){const r=t.createTracker(l),i=function(e){let n=0;"containerDirective"===e.type?(D(e,(function(e,t){if("containerDirective"===e.type){let e=t.length,l=0;for(;e--;)"containerDirective"===t[e].type&&l++;l>n&&(n=l)}})),n+=3):n="leafDirective"===e.type?2:1;return":".repeat(n)}(e),o=t.enter(e.type);let a,u=r.move(i+(e.name||""));if("containerDirective"===e.type){const n=(e.children||[])[0];a=W(n)?n:void 0}else a=e;if(a&&a.children&&a.children.length>0){const n=t.enter("label"),l=`${e.type}Label`,i=t.enter(l);u+=r.move("["),u+=r.move(t.containerPhrasing(a,{...r.current(),before:u,after:"]"})),u+=r.move("]"),i(),n()}if(u+=r.move(function(e,n){const t=n.options.quote||'"',l="textDirective"===e.type?[t]:[t,"\n","\r"],r=e.attributes||{},i=[];let o,a,u,c;for(c in r)if(w.call(r,c)&&void 0!==r[c]&&null!==r[c]){const e=String(r[c]);if("id"===c)u=M.test(e)?"#"+e:s("id",e);else if("class"===c){const n=e.split(/[\t\n\r ]+/g),t=[],l=[];let r=-1;for(;++r<n.length;)(M.test(n[r])?l:t).push(n[r]);o=t.length>0?s("class",t.join(" ")):"",a=l.length>0?"."+l.join("."):""}else i.push(s(c,e))}o&&i.unshift(o);a&&i.unshift(a);u&&i.unshift(u);return i.length>0?"{"+i.join(" ")+"}":"";function s(e,n){return e+(n?"="+t+function(e,n){return v(e,Object.assign({format:y},n))}(n,{subset:l})+t:"")}}(e,t)),"containerDirective"===e.type){let n=e;W((e.children||[])[0])&&(n=Object.assign({},e,{children:e.children.slice(1)})),n&&n.children&&n.children.length>0&&(u+=r.move("\n"),u+=r.move(t.containerFlow(n,r.current()))),u+=r.move("\n"+i)}return o(),u}function W(e){return Boolean(e&&"paragraph"===e.type&&e.data&&e.data.directiveLabel)}q.peek=function(){return":"};var K=$(/[A-Za-z]/),Y=$(/[\dA-Za-z]/);$(/[#-'*+\--9=?A-Z^-~]/),$(/\d/),$(/[\dA-Fa-f]/),$(/[!-/:-@[-`{-~]/);function G(e){return null!==e&&e<-2}function X(e){return null!==e&&(e<0||32===e)}function Z(e){return-2===e||-1===e||32===e}$(/\p{P}|\p{S}/u),$(/\s/);function $(e){return function(n){return null!==n&&n>-1&&e.test(String.fromCharCode(n))}}function J(e,n,t,l){const r=l?l-1:Number.POSITIVE_INFINITY;let i=0;return function(l){if(Z(l))return e.enter(t),o(l);return n(l)};function o(l){return Z(l)&&i++<r?(e.consume(l),o):(e.exit(t),n(l))}}function Q(e,n){let t;return function l(r){if(G(r))return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),t=!0,l;if(Z(r))return J(e,l,t?"linePrefix":"lineSuffix")(r);return n(r)}}function _(e,n,t,l,r,i,o,a,u,c,s,d,f,p,h){let g,m;return function(n){return e.enter(l),e.enter(r),e.consume(n),e.exit(r),v};function v(n){return 35===n?(g=o,y(n)):46===n?(g=a,y(n)):58===n||95===n||K(n)?(e.enter(i),e.enter(u),e.consume(n),C):h&&Z(n)?J(e,v,"whitespace")(n):!h&&X(n)?Q(e,v)(n):P(n)}function y(n){const t=g+"Marker";return e.enter(i),e.enter(g),e.enter(t),e.consume(n),e.exit(t),b}function b(n){if(null===n||34===n||35===n||39===n||46===n||60===n||61===n||62===n||96===n||125===n||X(n))return t(n);const l=g+"Value";return e.enter(l),e.consume(n),x}function x(n){if(null===n||34===n||39===n||60===n||61===n||62===n||96===n)return t(n);if(35===n||46===n||125===n||X(n)){const t=g+"Value";return e.exit(t),e.exit(g),e.exit(i),v(n)}return e.consume(n),x}function C(n){return 45===n||46===n||58===n||95===n||Y(n)?(e.consume(n),C):(e.exit(u),h&&Z(n)?J(e,k,"whitespace")(n):!h&&X(n)?Q(e,k)(n):k(n))}function k(n){return 61===n?(e.enter(c),e.consume(n),e.exit(c),A):(e.exit(i),v(n))}function A(n){return null===n||60===n||61===n||62===n||96===n||125===n||h&&G(n)?t(n):34===n||39===n?(e.enter(s),e.enter(f),e.consume(n),e.exit(f),m=n,L):h&&Z(n)?J(e,A,"whitespace")(n):!h&&X(n)?Q(e,A)(n):(e.enter(d),e.enter(p),e.consume(n),m=void 0,S)}function S(n){return null===n||34===n||39===n||60===n||61===n||62===n||96===n?t(n):125===n||X(n)?(e.exit(p),e.exit(d),e.exit(i),v(n)):(e.consume(n),S)}function L(n){return n===m?(e.enter(f),e.consume(n),e.exit(f),e.exit(s),e.exit(i),M):(e.enter(d),D(n))}function D(n){return n===m?(e.exit(d),L(n)):null===n?t(n):G(n)?h?t(n):Q(e,D)(n):(e.enter(p),e.consume(n),w)}function w(n){return n===m||null===n||G(n)?(e.exit(p),D(n)):(e.consume(n),w)}function M(e){return 125===e||X(e)?v(e):P(e)}function P(i){return 125===i?(e.enter(r),e.consume(i),e.exit(r),e.exit(l),n):t(i)}}function ee(e,n,t,l,r,i,o){let a,u=0,c=0;return function(n){return e.enter(l),e.enter(r),e.consume(n),e.exit(r),s};function s(t){return 93===t?(e.enter(r),e.consume(t),e.exit(r),e.exit(l),n):(e.enter(i),d(t))}function d(n){if(93===n&&!c)return h(n);const t=e.enter("chunkText",{contentType:"text",previous:a});return a&&(a.next=t),a=t,f(n)}function f(n){return null===n||u>999||91===n&&++c>32?t(n):93!==n||c--?G(n)?o?t(n):(e.consume(n),e.exit("chunkText"),d):(e.consume(n),92===n?p:f):(e.exit("chunkText"),h(n))}function p(n){return 91===n||92===n||93===n?(e.consume(n),u++,f):f(n)}function h(t){return e.exit(i),e.enter(r),e.consume(t),e.exit(r),e.exit(l),n}}function ne(e,n,t,l){const r=this;return function(n){if(K(n))return e.enter(l),e.consume(n),i;return t(n)};function i(o){return 45===o||95===o||Y(o)?(e.consume(o),i):(e.exit(l),45===r.previous||95===r.previous?t(o):n(o))}}var te={tokenize:function(e,n,t){const l=this,r=l.events[l.events.length-1],i=r&&"linePrefix"===r[1].type?r[2].sliceSerialize(r[1],!0).length:0;let o,a=0;return function(n){return e.enter("directiveContainer"),e.enter("directiveContainerFence"),e.enter("directiveContainerSequence"),u(n)};function u(n){return 58===n?(e.consume(n),a++,u):a<3?t(n):(e.exit("directiveContainerSequence"),ne.call(l,e,c,t,"directiveContainerName")(n))}function c(n){return 91===n?e.attempt(le,s,s)(n):s(n)}function s(n){return 123===n?e.attempt(re,d,d)(n):d(n)}function d(n){return J(e,f,"whitespace")(n)}function f(r){return e.exit("directiveContainerFence"),null===r?p(r):G(r)?l.interrupt?n(r):e.attempt(ie,h,p)(r):t(r)}function p(t){return e.exit("directiveContainer"),n(t)}function h(t){return null===t?(e.exit("directiveContainer"),n(t)):(e.enter("directiveContainerContent"),g(t))}function g(n){return null===n?x(n):e.attempt({tokenize:C,partial:!0},x,i?J(e,m,"linePrefix",i+1):m)(n)}function m(n){if(null===n)return x(n);const t=e.enter("chunkDocument",{contentType:"document",previous:o});return o&&(o.next=t),o=t,v(n)}function v(n){if(null===n){const t=e.exit("chunkDocument");return l.parser.lazy[t.start.line]=!1,x(n)}return G(n)?e.check(ie,y,b)(n):(e.consume(n),v)}function y(n){e.consume(n);const t=e.exit("chunkDocument");return l.parser.lazy[t.start.line]=!1,g}function b(n){const t=e.exit("chunkDocument");return l.parser.lazy[t.start.line]=!1,x(n)}function x(t){return e.exit("directiveContainerContent"),e.exit("directiveContainer"),n(t)}function C(e,n,t){let r=0;return J(e,(function(n){return e.enter("directiveContainerFence"),e.enter("directiveContainerSequence"),i(n)}),"linePrefix",l.parser.constructs.disable.null.includes("codeIndented")?void 0:4);function i(n){return 58===n?(e.consume(n),r++,i):r<a?t(n):(e.exit("directiveContainerSequence"),J(e,o,"whitespace")(n))}function o(l){return null===l||G(l)?(e.exit("directiveContainerFence"),n(l)):t(l)}}},concrete:!0},le={tokenize:function(e,n,t){return ee(e,n,t,"directiveContainerLabel","directiveContainerLabelMarker","directiveContainerLabelString",!0)},partial:!0},re={tokenize:function(e,n,t){return _(e,n,t,"directiveContainerAttributes","directiveContainerAttributesMarker","directiveContainerAttribute","directiveContainerAttributeId","directiveContainerAttributeClass","directiveContainerAttributeName","directiveContainerAttributeInitializerMarker","directiveContainerAttributeValueLiteral","directiveContainerAttributeValue","directiveContainerAttributeValueMarker","directiveContainerAttributeValueData",!0)},partial:!0},ie={tokenize:function(e,n,t){const l=this;return function(n){return e.enter("lineEnding"),e.consume(n),e.exit("lineEnding"),r};function r(e){return l.parser.lazy[l.now().line]?t(e):n(e)}},partial:!0};var oe={tokenize:function(e,n,t){const l=this;return function(n){return e.enter("directiveLeaf"),e.enter("directiveLeafSequence"),e.consume(n),r};function r(n){return 58===n?(e.consume(n),e.exit("directiveLeafSequence"),ne.call(l,e,i,t,"directiveLeafName")):t(n)}function i(n){return 91===n?e.attempt(ae,o,o)(n):o(n)}function o(n){return 123===n?e.attempt(ue,a,a)(n):a(n)}function a(n){return J(e,u,"whitespace")(n)}function u(l){return null===l||G(l)?(e.exit("directiveLeaf"),n(l)):t(l)}}},ae={tokenize:function(e,n,t){return ee(e,n,t,"directiveLeafLabel","directiveLeafLabelMarker","directiveLeafLabelString",!0)},partial:!0},ue={tokenize:function(e,n,t){return _(e,n,t,"directiveLeafAttributes","directiveLeafAttributesMarker","directiveLeafAttribute","directiveLeafAttributeId","directiveLeafAttributeClass","directiveLeafAttributeName","directiveLeafAttributeInitializerMarker","directiveLeafAttributeValueLiteral","directiveLeafAttributeValue","directiveLeafAttributeValueMarker","directiveLeafAttributeValueData",!0)},partial:!0};var ce={tokenize:function(e,n,t){const l=this;return function(n){return e.enter("directiveText"),e.enter("directiveTextMarker"),e.consume(n),e.exit("directiveTextMarker"),ne.call(l,e,r,t,"directiveTextName")};function r(n){return 58===n?t(n):91===n?e.attempt(se,i,i)(n):i(n)}function i(n){return 123===n?e.attempt(de,o,o)(n):o(n)}function o(t){return e.exit("directiveText"),n(t)}},previous:function(e){return 58!==e||"characterEscape"===this.events[this.events.length-1][1].type}},se={tokenize:function(e,n,t){return ee(e,n,t,"directiveTextLabel","directiveTextLabelMarker","directiveTextLabelString")},partial:!0},de={tokenize:function(e,n,t){return _(e,n,t,"directiveTextAttributes","directiveTextAttributesMarker","directiveTextAttribute","directiveTextAttributeId","directiveTextAttributeClass","directiveTextAttributeName","directiveTextAttributeInitializerMarker","directiveTextAttributeValueLiteral","directiveTextAttributeValue","directiveTextAttributeValueMarker","directiveTextAttributeValueData")},partial:!0};function fe(){const e=this.data(),n=e.micromarkExtensions||(e.micromarkExtensions=[]),t=e.fromMarkdownExtensions||(e.fromMarkdownExtensions=[]),l=e.toMarkdownExtensions||(e.toMarkdownExtensions=[]);n.push({text:{58:ce},flow:{58:[te,oe]}}),t.push({canContainEols:["textDirective"],enter:{directiveContainer:P,directiveContainerAttributes:I,directiveContainerLabel:z,directiveLeaf:T,directiveLeafAttributes:I,directiveText:O,directiveTextAttributes:I},exit:{directiveContainer:H,directiveContainerAttributeClassValue:U,directiveContainerAttributeIdValue:F,directiveContainerAttributeName:B,directiveContainerAttributeValue:V,directiveContainerAttributes:j,directiveContainerLabel:R,directiveContainerName:N,directiveLeaf:H,directiveLeafAttributeClassValue:U,directiveLeafAttributeIdValue:F,directiveLeafAttributeName:B,directiveLeafAttributeValue:V,directiveLeafAttributes:j,directiveLeafName:N,directiveText:H,directiveTextAttributeClassValue:U,directiveTextAttributeIdValue:F,directiveTextAttributeName:B,directiveTextAttributeValue:V,directiveTextAttributes:j,directiveTextName:N}}),l.push({unsafe:[{character:"\r",inConstruct:["leafDirectiveLabel","containerDirectiveLabel"]},{character:"\n",inConstruct:["leafDirectiveLabel","containerDirectiveLabel"]},{before:"[^:]",character:":",after:"[A-Za-z]",inConstruct:["phrasing"]},{atBreak:!0,character:":",after:":"}],handlers:{containerDirective:q,leafDirective:q,textDirective:q}})}var pe=class{constructor(e,n,t){this.property=e,this.normal=n,t&&(this.space=t)}};function he(e,n){const t={},l={};let r=-1;for(;++r<e.length;)Object.assign(t,e[r].property),Object.assign(l,e[r].normal);return new pe(t,l,n)}function ge(e){return e.toLowerCase()}pe.prototype.property={},pe.prototype.normal={},pe.prototype.space=null;var me=class{constructor(e,n){this.property=e,this.attribute=n}};me.prototype.space=null,me.prototype.boolean=!1,me.prototype.booleanish=!1,me.prototype.overloadedBoolean=!1,me.prototype.number=!1,me.prototype.commaSeparated=!1,me.prototype.spaceSeparated=!1,me.prototype.commaOrSpaceSeparated=!1,me.prototype.mustUseProperty=!1,me.prototype.defined=!1;var ve={};((n,t)=>{for(var l in t)e(n,l,{get:t[l],enumerable:!0})})(ve,{boolean:()=>be,booleanish:()=>xe,commaOrSpaceSeparated:()=>Le,commaSeparated:()=>Se,number:()=>ke,overloadedBoolean:()=>Ce,spaceSeparated:()=>Ae});var ye=0,be=De(),xe=De(),Ce=De(),ke=De(),Ae=De(),Se=De(),Le=De();function De(){return 2**++ye}var we=Object.keys(ve),Me=class extends me{constructor(e,n,t,l){let r=-1;if(super(e,n),Pe(this,"space",l),"number"==typeof t)for(;++r<we.length;){const e=we[r];Pe(this,we[r],(t&ve[e])===ve[e])}}};function Pe(e,n,t){t&&(e[n]=t)}Me.prototype.defined=!0;var Te={}.hasOwnProperty;function Oe(e){const n={},t={};let l;for(l in e.properties)if(Te.call(e.properties,l)){const r=e.properties[l],i=new Me(l,e.transform(e.attributes||{},l),r,e.space);e.mustUseProperty&&e.mustUseProperty.includes(l)&&(i.mustUseProperty=!0),n[l]=i,t[ge(l)]=l,t[ge(i.attribute)]=l}return new pe(n,t,e.space)}var Ee=Oe({space:"xlink",transform:(e,n)=>"xlink:"+n.slice(5).toLowerCase(),properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null}}),Ne=Oe({space:"xml",transform:(e,n)=>"xml:"+n.slice(3).toLowerCase(),properties:{xmlLang:null,xmlBase:null,xmlSpace:null}});function ze(e,n){return n in e?e[n]:n}function Re(e,n){return ze(e,n.toLowerCase())}var Ie=Oe({space:"xmlns",attributes:{xmlnsxlink:"xmlns:xlink"},transform:Re,properties:{xmlns:null,xmlnsXLink:null}}),Fe=Oe({transform:(e,n)=>"role"===n?n:"aria-"+n.slice(4).toLowerCase(),properties:{ariaActiveDescendant:null,ariaAtomic:xe,ariaAutoComplete:null,ariaBusy:xe,ariaChecked:xe,ariaColCount:ke,ariaColIndex:ke,ariaColSpan:ke,ariaControls:Ae,ariaCurrent:null,ariaDescribedBy:Ae,ariaDetails:null,ariaDisabled:xe,ariaDropEffect:Ae,ariaErrorMessage:null,ariaExpanded:xe,ariaFlowTo:Ae,ariaGrabbed:xe,ariaHasPopup:null,ariaHidden:xe,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Ae,ariaLevel:ke,ariaLive:null,ariaModal:xe,ariaMultiLine:xe,ariaMultiSelectable:xe,ariaOrientation:null,ariaOwns:Ae,ariaPlaceholder:null,ariaPosInSet:ke,ariaPressed:xe,ariaReadOnly:xe,ariaRelevant:null,ariaRequired:xe,ariaRoleDescription:Ae,ariaRowCount:ke,ariaRowIndex:ke,ariaRowSpan:ke,ariaSelected:xe,ariaSetSize:ke,ariaSort:null,ariaValueMax:ke,ariaValueMin:ke,ariaValueNow:ke,ariaValueText:null,role:null}}),Ue=Oe({space:"html",attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},transform:Re,mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Se,acceptCharset:Ae,accessKey:Ae,action:null,allow:null,allowFullScreen:be,allowPaymentRequest:be,allowUserMedia:be,alt:null,as:null,async:be,autoCapitalize:null,autoComplete:Ae,autoFocus:be,autoPlay:be,blocking:Ae,capture:null,charSet:null,checked:be,cite:null,className:Ae,cols:ke,colSpan:null,content:null,contentEditable:xe,controls:be,controlsList:Ae,coords:ke|Se,crossOrigin:null,data:null,dateTime:null,decoding:null,default:be,defer:be,dir:null,dirName:null,disabled:be,download:Ce,draggable:xe,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:be,formTarget:null,headers:Ae,height:ke,hidden:be,high:ke,href:null,hrefLang:null,htmlFor:Ae,httpEquiv:Ae,id:null,imageSizes:null,imageSrcSet:null,inert:be,inputMode:null,integrity:null,is:null,isMap:be,itemId:null,itemProp:Ae,itemRef:Ae,itemScope:be,itemType:Ae,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:be,low:ke,manifest:null,max:null,maxLength:ke,media:null,method:null,min:null,minLength:ke,multiple:be,muted:be,name:null,nonce:null,noModule:be,noValidate:be,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:be,optimum:ke,pattern:null,ping:Ae,placeholder:null,playsInline:be,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:be,referrerPolicy:null,rel:Ae,required:be,reversed:be,rows:ke,rowSpan:ke,sandbox:Ae,scope:null,scoped:be,seamless:be,selected:be,shadowRootClonable:be,shadowRootDelegatesFocus:be,shadowRootMode:null,shape:null,size:ke,sizes:null,slot:null,span:ke,spellCheck:xe,src:null,srcDoc:null,srcLang:null,srcSet:null,start:ke,step:null,style:null,tabIndex:ke,target:null,title:null,translate:null,type:null,typeMustMatch:be,useMap:null,value:xe,width:ke,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Ae,axis:null,background:null,bgColor:null,border:ke,borderColor:null,bottomMargin:ke,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:be,declare:be,event:null,face:null,frame:null,frameBorder:null,hSpace:ke,leftMargin:ke,link:null,longDesc:null,lowSrc:null,marginHeight:ke,marginWidth:ke,noResize:be,noHref:be,noShade:be,noWrap:be,object:null,profile:null,prompt:null,rev:null,rightMargin:ke,rules:null,scheme:null,scrolling:xe,standby:null,summary:null,text:null,topMargin:ke,valueType:null,version:null,vAlign:null,vLink:null,vSpace:ke,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:be,disableRemotePlayback:be,prefix:null,property:null,results:ke,security:null,unselectable:null}}),Ve=Oe({space:"svg",attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},transform:ze,properties:{about:Le,accentHeight:ke,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:ke,amplitude:ke,arabicForm:null,ascent:ke,attributeName:null,attributeType:null,azimuth:ke,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:ke,by:null,calcMode:null,capHeight:ke,className:Ae,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:ke,diffuseConstant:ke,direction:null,display:null,dur:null,divisor:ke,dominantBaseline:null,download:be,dx:null,dy:null,edgeMode:null,editable:null,elevation:ke,enableBackground:null,end:null,event:null,exponent:ke,externalResourcesRequired:null,fill:null,fillOpacity:ke,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Se,g2:Se,glyphName:Se,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:ke,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:ke,horizOriginX:ke,horizOriginY:ke,id:null,ideographic:ke,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:ke,k:ke,k1:ke,k2:ke,k3:ke,k4:ke,kernelMatrix:Le,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:ke,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:ke,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:ke,overlineThickness:ke,paintOrder:null,panose1:null,path:null,pathLength:ke,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Ae,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:ke,pointsAtY:ke,pointsAtZ:ke,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Le,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Le,rev:Le,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Le,requiredFeatures:Le,requiredFonts:Le,requiredFormats:Le,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:ke,specularExponent:ke,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:ke,strikethroughThickness:ke,string:null,stroke:null,strokeDashArray:Le,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:ke,strokeOpacity:ke,strokeWidth:null,style:null,surfaceScale:ke,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Le,tabIndex:ke,tableValues:null,target:null,targetX:ke,targetY:ke,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Le,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:ke,underlineThickness:ke,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:ke,values:null,vAlphabetic:ke,vMathematical:ke,vectorEffect:null,vHanging:ke,vIdeographic:ke,version:null,vertAdvY:ke,vertOriginX:ke,vertOriginY:ke,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:ke,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null}}),Be=/^data[-\w.:]+$/i,je=/-[a-z]/g,He=/[A-Z]/g;function qe(e){return"-"+e.toLowerCase()}function We(e){return e.charAt(1).toUpperCase()}var Ke=he([Ne,Ee,Ie,Fe,Ue],"html"),Ye=he([Ne,Ee,Ie,Fe,Ve],"svg");function Ge(e){const n=[],t=String(e||"");let l=t.indexOf(","),r=0,i=!1;for(;!i;){-1===l&&(l=t.length,i=!0);const e=t.slice(r,l).trim();!e&&i||n.push(e),r=l+1,l=t.indexOf(",",r)}return n}var Xe=/[#.]/g;function Ze(e){const n=String(e||"").trim();return n?n.split(/[ \t\n\r\f]+/g):[]}var $e={}.hasOwnProperty;function Je(e,n,t){const l=t&&function(e){const n={};let t=-1;for(;++t<e.length;)n[e[t].toLowerCase()]=e[t];return n}(t);return function(t,r,...i){let o,a=-1;if(null==t){o={type:"root",children:[]};const e=r;i.unshift(e)}else if(o=function(e,n){const t=e||"",l={};let r,i,o=0;for(;o<t.length;){Xe.lastIndex=o;const e=Xe.exec(t),n=t.slice(o,e?e.index:t.length);n&&(r?"#"===r?l.id=n:Array.isArray(l.className)?l.className.push(n):l.className=[n]:i=n,o+=n.length),e&&(r=e[0],o++)}return{type:"element",tagName:i||n||"div",properties:l,children:[]}}(t,n),o.tagName=o.tagName.toLowerCase(),l&&$e.call(l,o.tagName)&&(o.tagName=l[o.tagName]),function(e){if(null===e||"object"!=typeof e||Array.isArray(e))return!0;if("string"!=typeof e.type)return!1;const n=e,t=Object.keys(e);for(const e of t){const t=n[e];if(t&&"object"==typeof t){if(!Array.isArray(t))return!0;const e=t;for(const n of e)if("number"!=typeof n&&"string"!=typeof n)return!0}}if("children"in e&&Array.isArray(e.children))return!0;return!1}(r))i.unshift(r);else{let n;for(n in r)$e.call(r,n)&&Qe(e,o.properties,n,r[n])}for(;++a<i.length;)_e(o.children,i[a]);return"element"===o.type&&"template"===o.tagName&&(o.content={type:"root",children:o.children},o.children=[]),o}}function Qe(e,n,t,l){const r=function(e,n){const t=ge(n);let l=n,r=me;if(t in e.normal)return e.property[e.normal[t]];if(t.length>4&&"data"===t.slice(0,4)&&Be.test(n)){if("-"===n.charAt(4)){const e=n.slice(5).replace(je,We);l="data"+e.charAt(0).toUpperCase()+e.slice(1)}else{const e=n.slice(4);if(!je.test(e)){let t=e.replace(He,qe);"-"!==t.charAt(0)&&(t="-"+t),n="data"+t}}r=Me}return new r(l,n)}(e,t);let i,o=-1;if(null!=l){if("number"==typeof l){if(Number.isNaN(l))return;i=l}else i="boolean"==typeof l?l:"string"==typeof l?r.spaceSeparated?Ze(l):r.commaSeparated?Ge(l):r.commaOrSpaceSeparated?Ze(Ge(l).join(" ")):en(r,r.property,l):Array.isArray(l)?l.concat():"style"===r.property?function(e){const n=[];let t;for(t in e)$e.call(e,t)&&n.push([t,e[t]].join(": "));return n.join("; ")}(l):String(l);if(Array.isArray(i)){const e=[];for(;++o<i.length;){const n=en(r,r.property,i[o]);e[o]=n}i=e}if("className"===r.property&&Array.isArray(n.className)){const e=i;i=n.className.concat(e)}n[r.property]=i}}function _e(e,n){let t=-1;if(null==n);else if("string"==typeof n||"number"==typeof n)e.push({type:"text",value:String(n)});else if(Array.isArray(n))for(;++t<n.length;)_e(e,n[t]);else{if("object"!=typeof n||!("type"in n))throw new Error("Expected node, nodes, or string, got `"+n+"`");"root"===n.type?_e(e,n.children):e.push(n)}}function en(e,n,t){if("string"==typeof t){if(e.number&&t&&!Number.isNaN(Number(t)))return Number(t);if((e.boolean||e.overloadedBoolean)&&(""===t||ge(t)===ge(n)))return!0}return t}var nn=Je(Ke,"div"),tn=(Je(Ye,"g",["altGlyph","altGlyphDef","altGlyphItem","animateColor","animateMotion","animateTransform","clipPath","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","foreignObject","glyphRef","linearGradient","radialGradient","solidColor","textArea","textPath"]),{remark:e=>e.use(fe)});function ln(e){return{remark:n=>n.use((function(){return function(n){!function(e,n,t,l){let r,i,o;"function"==typeof n&&"function"!=typeof t?(i=void 0,o=n,r=t):(i=n,o=t,r=l),D(e,i,(function(e,n){const t=n[n.length-1],l=t?t.children.indexOf(e):void 0;return o(e,l,t)}),r)}(n,(n=>{/(?:container|leaf|text)Directive/.test(n.type)&&e(n)}))}}))}}export{tn as default,ln as directive,nn as h};
@@ -0,0 +1,112 @@
1
+ // Imports
2
+ import type { Plugin } from "../renderer.ts"
3
+ import type { Arg, Nullable, Optional } from "@libs/typing/types"
4
+ import remarkDirective from "remark-directive"
5
+ import { visit } from "unist-util-visit"
6
+ export { h } from "hastscript"
7
+ import type { Data, ElementContent, Properties } from "hast"
8
+
9
+ /**
10
+ * Add support for custom directives.
11
+ *
12
+ * {@link https://github.com/remarkjs/remark-directive?tab=readme-ov-file#examples | See remark-directive for more information}.
13
+ */
14
+ export default {
15
+ remark(processor) {
16
+ return processor.use(remarkDirective)
17
+ },
18
+ } as Plugin
19
+
20
+ /**
21
+ * Create a new custom directive.
22
+ *
23
+ * @example
24
+ * ```ts
25
+ * import { Renderer } from "../renderer.ts"
26
+ * import directives, { directive, h } from "./directives.ts"
27
+ *
28
+ * const foo = directive((node) => {
29
+ * node.data ??= {}
30
+ * node.data.hName = "div"
31
+ * node.data.hProperties = h(node.data.hName, { bar: "qux" }).properties
32
+ * })
33
+ *
34
+ * const markdown = new Renderer({ plugins: [directives, foo] })
35
+ * await markdown.render(`
36
+ * :::foo
37
+ * baz
38
+ * :::
39
+ * `.trim())
40
+ * ```
41
+ */
42
+ export function directive(callback: (node: AugmentedNode) => void): Plugin {
43
+ return {
44
+ remark(processor) {
45
+ return processor.use(function () {
46
+ return function (tree: Arg<typeof visit>) {
47
+ visit(tree, (node) => {
48
+ if (!/(?:container|leaf|text)Directive/.test(node.type)) {
49
+ return
50
+ }
51
+ callback(node as AugmentedNode)
52
+ })
53
+ }
54
+ })
55
+ },
56
+ } as Plugin
57
+ }
58
+
59
+ /**
60
+ * Node.
61
+ *
62
+ * Augmented from {@link https://github.com/syntax-tree/mdast-util-directive/blob/main/index.d.ts | mdast-util-directive}.
63
+ */
64
+ interface AugmentedNode extends Arg<typeof visit> {
65
+ /**
66
+ * Directive name.
67
+ */
68
+ name: string
69
+ /**
70
+ * Directive attributes.
71
+ */
72
+ attributes?: Nullable<Record<string, Optional<Nullable<string>>>>
73
+
74
+ /**
75
+ * Info from the ecosystem.
76
+ */
77
+ data?: AugmentedData
78
+
79
+ /**
80
+ * Children of the directive.
81
+ */
82
+ children: AugmentedNode[]
83
+ }
84
+
85
+ /**
86
+ * Info associated with hast nodes by the ecosystem.
87
+ *
88
+ * Augmented from {@link https://github.com/syntax-tree/mdast-util-to-hast/blob/main/index.d.ts | mdast-util-to-hast}.
89
+ */
90
+ interface AugmentedData extends Data {
91
+ /**
92
+ * Signal that a node should result in something with these children.
93
+ *
94
+ * When this is defined, when a parent is created, these children will be used.
95
+ */
96
+ hChildren?: ElementContent[]
97
+
98
+ /**
99
+ * Signal that a node should result in a particular element, instead of its default behavior.
100
+ *
101
+ * When this is defined, an element with the given tag name is created.
102
+ * For example, when setting `hName` to `'b'`, a `<b>` element is created.
103
+ */
104
+ hName?: string
105
+
106
+ /**
107
+ * Signal that a node should result in an element with these properties.
108
+ *
109
+ * When this is defined, when an element is created, these properties will be used.
110
+ */
111
+ hProperties?: Properties
112
+ }
@@ -0,0 +1,13 @@
1
+ import { expect, test } from "@libs/testing"
2
+ import { Renderer } from "../renderer.ts"
3
+ import plugin, { directive, h } from "./directives.ts"
4
+
5
+ test("deno")("Plugin.directives renders custom directive blocks", async () => {
6
+ const custom = directive((node) => {
7
+ node.data ??= {}
8
+ node.data.hName = "div"
9
+ node.data.hProperties = h(node.data.hName, { bar: "qux" }).properties
10
+ })
11
+ const markdown = new Renderer({ plugins: [plugin, custom] })
12
+ await expect(markdown.render(":::foo\nbaz\n:::")).resolves.toMatch(/<div bar="qux"><p>baz<\/p><\/div>/)
13
+ })