2024-05-11 22:49:29 +08:00
// See the "/licenses" URI for full package license details
2024-12-23 19:55:23 +08:00
var Kt = Object . create ; var ne = Object . defineProperty ; var Yt = Object . getOwnPropertyDescriptor ; var Qt = Object . getOwnPropertyNames ; var ur = Object . getPrototypeOf , er = Object . prototype . hasOwnProperty ; var F0 = u => { throw TypeError ( u ) } ; var tr = ( u , e ) => ( ) => ( e || u ( ( e = { exports : { } } ) . exports , e ) , e . exports ) , Eu = ( u , e ) => { for ( var t in e ) ne ( u , t , { get : e [ t ] , enumerable : ! 0 } ) } , rr = ( u , e , t , r ) => { if ( e && typeof e == "object" || typeof e == "function" ) for ( let n of Qt ( e ) ) ! er . call ( u , n ) && n !== t && ne ( u , n , { get : ( ) => e [ n ] , enumerable : ! ( r = Yt ( e , n ) ) || r . enumerable } ) ; return u } ; var nr = ( u , e , t ) => ( t = u != null ? Kt ( ur ( u ) ) : { } , rr ( e || ! u || ! u . _ _esModule ? ne ( t , "default" , { value : u , enumerable : ! 0 } ) : t , u ) ) ; var or = ( u , e , t ) => e . has ( u ) || F0 ( "Cannot " + t ) ; var v0 = ( u , e , t ) => e . has ( u ) ? F0 ( "Cannot add the same private member more than once" ) : e instanceof WeakSet ? e . add ( u ) : e . set ( u , t ) ; var E = ( u , e , t ) => ( or ( u , e , "access private method" ) , t ) ; var Bt = tr ( ( ls , qt ) => { var a0 = ! 0 , Rt = ! 1 , It = ! 1 ; qt . exports = function ( u , e ) { e && ( a0 = ! e . enabled , Rt = ! ! e . label , It = ! ! e . labelAfter ) , u . core . ruler . after ( "inline" , "github-task-lists" , function ( t ) { for ( var r = t . tokens , n = 2 ; n < r . length ; n ++ ) to ( r , n ) && ( ro ( r [ n ] , t . Token ) , Mt ( r [ n - 2 ] , "class" , "task-list-item" + ( a0 ? "" : " enabled" ) ) , Mt ( r [ eo ( r , n - 2 ) ] , "class" , "contains-task-list" ) ) } ) } ; function Mt ( u , e , t ) { var r = u . attrIndex ( e ) , n = [ e , t ] ; r < 0 ? u . attrPush ( n ) : u . attrs [ r ] = n } function eo ( u , e ) { for ( var t = u [ e ] . level - 1 , r = e - 1 ; r >= 0 ; r -- ) if ( u [ r ] . level === t ) return r ; return - 1 } function to ( u , e ) { return ao ( u [ e ] ) && so ( u [ e - 1 ] ) && lo ( u [ e - 2 ] ) && fo ( u [ e ] ) } function ro ( u , e ) { if ( u . children . unshift ( no ( u , e ) ) , u . children [ 1 ] . content = u . children [ 1 ] . content . slice ( 3 ) , u . content = u . content . slice ( 3 ) , Rt ) if ( It ) { u . children . pop ( ) ; var t = "task-item-" + Math . ceil ( Math . random ( ) * ( 1e4 * 1e3 ) - 1e3 ) ; u . children [ 0 ] . content = u . children [ 0 ] . content . slice ( 0 , - 1 ) + ' id="' + t + '">' , u . children . push ( co ( u . content , t , e ) ) } else u . children . unshift ( oo ( e ) ) , u . children . push ( io ( e ) ) } function no ( u , e ) { var t = new e ( "html_inline" , "" , 0 ) , r = a0 ? ' disabled="" ' : "" ; return u . content . indexOf ( "[ ] " ) === 0 ? t . content = '<input class="task-list-item-checkbox"' + r + 'type="checkbox">' : ( u . content . indexOf ( "[x] " ) === 0 || u . content . indexOf ( "[X] " ) === 0 ) && ( t . content = '<input class="task-list-item-checkbox" checked=""' + r + 'type="checkbox">' ) , t } function oo ( u ) { var e = new u ( "html_inline" , "" , 0 ) ; return e . content = "<label>" , e } function io ( u ) { var e = new u ( "html_inline" , "" , 0 ) ; return e . content = "</label>" , e } function co ( u , e , t ) { var r = new t ( "html_inline" , "" , 0 ) ; return r . content = '<label class="task-list-item-label" for="' + e + '">' + u + "</label>" , r . attrs = [ { for : e } ] , r } function ao ( u ) { return u . type === "inline" } function so ( u ) { return u . type === "paragraph_open" } function lo ( u ) { return u . type === "list_item_open" } function fo ( u ) { return u . content . indexOf ( "[ ] " ) === 0 || u . content . indexOf ( "[x] " ) === 0 || u . content . indexOf ( "[X] " ) === 0 } } ) ; var pe = { } ; Eu ( pe , { arrayReplaceAt : ( ) => de , assign : ( ) => fu , escapeHtml : ( ) => W , escapeRE : ( ) => $r , fromCodePoint : ( ) => gu , has : ( ) => Lr , isMdAsciiPunct : ( ) => nu , isPunctChar : ( ) => ru , isSpace : ( ) => F , isString : ( ) => Bu , isValidEntityCode : ( ) => Pu , isWhiteSpace : ( ) => tu , lib : ( ) => Ur , normalizeReference : ( ) => ou , unescapeAll : ( ) => G , unescapeMd : ( ) => Br } ) ; var Su = { } ; Eu ( Su , { decode : ( ) => mu , encode : ( ) => Fu , format : ( ) => su , parse : ( ) => xu } ) ; var S0 = { } ; function ir ( u ) { let e = S0 [ u ] ; if ( e ) return e ; e = S0 [ u ] = [ ] ; for ( let t = 0 ; t < 128 ; t ++ ) { let r = String . fromCharCode ( t ) ; e . push ( r ) } for ( let t = 0 ; t < u . length ; t ++ ) { let r = u . charCodeAt ( t ) ; e [ r ] = "%" + ( "0" + r . toString ( 16 ) . toUpperCase ( ) ) . slice ( - 2 ) } return e } function wu ( u , e ) { typeof e != "string" && ( e = wu . defaultChars ) ; let t = ir ( e ) ; return u . replace ( /(%[a-f0-9]{2})+/gi , function ( r ) { let n = "" ; for ( let o = 0 , i = r . length ; o < i ; o += 3 ) { let c = parseInt ( r . slice ( o + 1 , o + 3 ) , 16 ) ; if ( c < 128 ) { n += t [ c ] ; continue } if ( ( c & 224 ) === 192 && o + 3 < i ) { let a = parseInt ( r . slice ( o + 4 , o + 6 ) , 16 ) ; if ( ( a & 192 ) === 128 ) { let s = c << 6 & 1984 | a & 63 ; s < 128 ? n += "\uFFFD\uFFFD" : n += String . fromCharCode ( s ) , o += 3 ; continue } } if ( ( c & 240 ) === 224 && o + 6 < i ) { let a = parseInt ( r . slice ( o + 4 , o + 6 ) , 16 ) , s = parseInt ( r . slice ( o + 7 , o + 9 ) , 16 ) ; if ( ( a & 192 ) === 128 && ( s & 192 ) === 128 ) { let f = c << 12 & 61440 | a << 6 & 4032 | s & 63 ; f < 2048 || f >= 55296 && f <= 57343 ? n += "\uFFFD\uFFFD\uFFFD" : n += String . fromCharCode ( f ) , o += 6 ; continue } } if ( ( c & 248 ) === 240 && o + 9 < i ) { let a = parseInt ( r . slice ( o + 4 , o + 6 ) , 16 ) , s = parseInt ( r . slice ( o + 7 , o + 9 ) , 16 ) , f = parseInt ( r . slice ( o + 10 , o + 12 ) , 16 ) ; if ( ( a & 192 ) === 128 && (
` ," "],dr=["{","}","|"," \\ ","^"," ` "].concat(fr),pr=[" ' "].concat(dr),L0=[" % "," / "," ? "," ; "," # "].concat(pr),M0=[" / "," ? "," # "],hr=255,R0=/^[+a-z0-9A-Z_-]{0,63}$/,br=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,I0={javascript:!0," javascript : ":!0},q0={http:!0,https:!0,ftp:!0,gopher:!0,file:!0," http : ":!0," https : ":!0," ftp : ":!0," gopher : ":!0," file : ":!0};function mr(u,e){if(u&&u instanceof vu)return u;let t=new vu;return t.parse(u,e),t}vu.prototype.parse=function(u,e){let t,r,n,o=u;if(o=o.trim(),!e&&u.split(" # ").length===1){let s=lr.exec(o);if(s)return this.pathname=s[1],s[2]&&(this.search=s[2]),this}let i=ar.exec(o);if(i&&(i=i[0],t=i.toLowerCase(),this.protocol=i,o=o.substr(i.length)),(e||i||o.match(/^\/\/[^@\/]+@[^@\/]+/))&&(n=o.substr(0,2)===" //",n&&!(i&&I0[i])&&(o=o.substr(2),this.slashes=!0)),!I0[i]&&(n||i&&!q0[i])){let s=-1;for(let l=0;l<M0.length;l++)r=o.indexOf(M0[l]),r!==-1&&(s===-1||r<s)&&(s=r);let f,d;s===-1?d=o.lastIndexOf("@"):d=o.lastIndexOf("@",s),d!==-1&&(f=o.slice(0,d),o=o.slice(d+1),this.auth=f),s=-1;for(let l=0;l<L0.length;l++)r=o.indexOf(L0[l]),r!==-1&&(s===-1||r<s)&&(s=r);s===-1&&(s=o.length),o[s-1]===":"&&s--;let _=o.slice(0,s);o=o.slice(s),this.parseHost(_),this.hostname=this.hostname||"";let h=this.hostname[0]==="["&&this.hostname[this.hostname.length-1]==="]";if(!h){let l=this.hostname.split(/\./);for(let p=0,m=l.length;p<m;p++){let k=l[p];if(k&&!k.match(R0)){let x="";for(let g=0,b=k.length;g<b;g++)k.charCodeAt(g)>127?x+="x":x+=k[g];if(!x.match(R0)){let g=l.slice(0,p),b=l.slice(p+1),y=k.match(br);y&&(g.push(y[1]),b.unshift(y[2])),b.length&&(o=b.join(".")+o),this.hostname=g.join(".");break}}}}this.hostname.length>hr&&(this.hostname=""),h&&(this.hostname=this.hostname.substr(1,this.hostname.length-2))}let c=o.indexOf("#");c!==-1&&(this.hash=o.substr(c),o=o.slice(0,c));let a=o.indexOf("?");return a!==-1&&(this.search=o.substr(a),o=o.slice(0,a)),o&&(this.pathname=o),q0[t]&&this.hostname&&!this.pathname&&(this.pathname=""),this};vu.prototype.parseHost=function(u){let e=sr.exec(u);e&&(e=e[0],e!==":"&&(this.port=e.substr(1)),u=u.substr(0,u.length-e.length)),u&&(this.hostname=u)};var xu=mr;var oe={};Eu(oe,{Any:()=>Tu,Cc:()=>Lu,Cf:()=>B0,P:()=>lu,S:()=>Mu,Z:()=>Ru});var Tu=/[\0-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;var Lu=/[\0-\x1F\x7F-\x9F]/;var B0=/[\xAD\u0600-\u0605\u061C\u06DD\u070F\u0890\u0891\u08E2\u180E\u200B-\u200F\u202A-\u202E\u2060-\u2064\u2066-\u206F\uFEFF\uFFF9-\uFFFB]|\uD804[\uDCBD\uDCCD]|\uD80D[\uDC30-\uDC3F]|\uD82F[\uDCA0-\uDCA3]|\uD834[\uDD73-\uDD7A]|\uDB40[\uDC01\uDC20-\uDC7F]/;var lu=/[!-#%-\*,-\/:;\?@\[-\]_\{\}\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061D-\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C77\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1B7D\u1B7E\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4F\u2E52-\u2E5D\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD803[\uDEAD\uDF55-\uDF59\uDF86-\uDF89]|\
2024-10-09 17:48:34 +08:00
` };U.fence=function(u,e,t,r,n){let o=u[e],i=o.info?G(o.info).trim():"",c="",a="";if(i){let f=i.split(/( \s +)/g);c=f[0],a=f.slice(2).join("")}let s;if(t.highlight?s=t.highlight(o.content,c,a)||W(o.content):s=W(o.content),s.indexOf("<pre")===0)return s+ `
2024-05-11 22:49:29 +08:00
` ;if(i){let f=o.attrIndex("class"),d=o.attrs?o.attrs.slice():[];f<0?d.push(["class",t.langPrefix+c]):(d[f]=d[f].slice(),d[f][1]+=" "+t.langPrefix+c);let _={attrs:d};return ` < pre > < code$ { n . renderAttrs ( _ ) } > $ { s } < / c o d e > < / p r e >
` }return ` < pre > < code$ { n . renderAttrs ( o ) } > $ { s } < / c o d e > < / p r e >
2024-10-09 17:48:34 +08:00
` };U.image=function(u,e,t,r,n){let o=u[e];return o.attrs[o.attrIndex("alt")][1]=n.renderInlineAsText(o.children,t,r),n.renderToken(u,e,t)};U.hardbreak=function(u,e,t){return t.xhtmlOut? ` < br / >
2024-05-11 22:49:29 +08:00
` : ` < br >
2024-10-09 17:48:34 +08:00
` };U.softbreak=function(u,e,t){return t.breaks?t.xhtmlOut? ` < br / >
2024-05-11 22:49:29 +08:00
` : ` < br >
` : `
2024-10-09 17:48:34 +08:00
` };U.text=function(u,e){return W(u[e].content)};U.html_block=function(u,e){return u[e].content};U.html_inline=function(u,e){return u[e].content};function du(){this.rules=fu({},U)}du.prototype.renderAttrs=function(e){let t,r,n;if(!e.attrs)return"";for(n="",t=0,r=e.attrs.length;t<r;t++)n+=" "+W(e.attrs[t][0])+'="'+W(e.attrs[t][1])+'"';return n};du.prototype.renderToken=function(e,t,r){let n=e[t],o="";if(n.hidden)return"";n.block&&n.nesting!==-1&&t&&e[t-1].hidden&&(o+= `
2024-05-11 22:49:29 +08:00
` ),o+=(n.nesting===-1?"</":"<")+n.tag,o+=this.renderAttrs(n),n.nesting===0&&r.xhtmlOut&&(o+=" /");let i=!1;if(n.block&&(i=!0,n.nesting===1&&t+1<e.length)){let c=e[t+1];(c.type==="inline"||c.hidden||c.nesting===-1&&c.tag===n.tag)&&(i=!1)}return o+=i? ` >
2024-08-29 23:04:51 +08:00
` :">",o};du.prototype.renderInline=function(u,e,t){let r="",n=this.rules;for(let o=0,i=u.length;o<i;o++){let c=u[o].type;typeof n[c]<"u"?r+=n[c](u,o,e,t,this):r+=this.renderToken(u,o,e)}return r};du.prototype.renderInlineAsText=function(u,e,t){let r="";for(let n=0,o=u.length;n<o;n++)switch(u[n].type){case"text":r+=u[n].content;break;case"image":r+=this.renderInlineAsText(u[n].children,e,t);break;case"html_inline":case"html_block":r+=u[n].content;break;case"softbreak":case"hardbreak":r+= `
2024-10-09 17:48:34 +08:00
` ;break;default:}return r};du.prototype.render=function(u,e,t){let r="",n=this.rules;for(let o=0,i=u.length;o<i;o++){let c=u[o].type;c==="inline"?r+=this.renderInline(u[o].children,e,t):typeof n[c]<"u"?r+=n[c](u,o,e,t,this):r+=this.renderToken(u,o,e,t)}return r};var W0=du;function O(){this.__rules__=[],this.__cache__=null}O.prototype.__find__=function(u){for(let e=0;e<this.__rules__.length;e++)if(this.__rules__[e].name===u)return e;return-1};O.prototype.__compile__=function(){let u=this,e=[""];u.__rules__.forEach(function(t){t.enabled&&t.alt.forEach(function(r){e.indexOf(r)<0&&e.push(r)})}),u.__cache__={},e.forEach(function(t){u.__cache__[t]=[],u.__rules__.forEach(function(r){r.enabled&&(t&&r.alt.indexOf(t)<0||u.__cache__[t].push(r.fn))})})};O.prototype.at=function(u,e,t){let r=this.__find__(u),n=t||{};if(r===-1)throw new Error("Parser rule not found: "+u);this.__rules__[r].fn=e,this.__rules__[r].alt=n.alt||[],this.__cache__=null};O.prototype.before=function(u,e,t,r){let n=this.__find__(u),o=r||{};if(n===-1)throw new Error("Parser rule not found: "+u);this.__rules__.splice(n,0,{name:e,enabled:!0,fn:t,alt:o.alt||[]}),this.__cache__=null};O.prototype.after=function(u,e,t,r){let n=this.__find__(u),o=r||{};if(n===-1)throw new Error("Parser rule not found: "+u);this.__rules__.splice(n+1,0,{name:e,enabled:!0,fn:t,alt:o.alt||[]}),this.__cache__=null};O.prototype.push=function(u,e,t){let r=t||{};this.__rules__.push({name:u,enabled:!0,fn:e,alt:r.alt||[]}),this.__cache__=null};O.prototype.enable=function(u,e){Array.isArray(u)||(u=[u]);let t=[];return u.forEach(function(r){let n=this.__find__(r);if(n<0){if(e)return;throw new Error("Rules manager: invalid rule name "+r)}this.__rules__[n].enabled=!0,t.push(r)},this),this.__cache__=null,t};O.prototype.enableOnly=function(u,e){Array.isArray(u)||(u=[u]),this.__rules__.forEach(function(t){t.enabled=!1}),this.enable(u,e)};O.prototype.disable=function(u,e){Array.isArray(u)||(u=[u]);let t=[];return u.forEach(function(r){let n=this.__find__(r);if(n<0){if(e)return;throw new Error("Rules manager: invalid rule name "+r)}this.__rules__[n].enabled=!1,t.push(r)},this),this.__cache__=null,t};O.prototype.getRules=function(u){return this.__cache__===null&&this.__compile__(),this.__cache__[u]||[]};var iu=O;function pu(u,e,t){this.type=u,this.tag=e,this.attrs=null,this.map=null,this.nesting=t,this.level=0,this.children=null,this.content="",this.markup="",this.info="",this.meta=null,this.block=!1,this.hidden=!1}pu.prototype.attrIndex=function(e){if(!this.attrs)return-1;let t=this.attrs;for(let r=0,n=t.length;r<n;r++)if(t[r][0]===e)return r;return-1};pu.prototype.attrPush=function(e){this.attrs?this.attrs.push(e):this.attrs=[e]};pu.prototype.attrSet=function(e,t){let r=this.attrIndex(e),n=[e,t];r<0?this.attrPush(n):this.attrs[r]=n};pu.prototype.attrGet=function(e){let t=this.attrIndex(e),r=null;return t>=0&&(r=this.attrs[t][1]),r};pu.prototype.attrJoin=function(e,t){let r=this.attrIndex(e);r<0?this.attrPush([e,t]):this.attrs[r][1]=this.attrs[r][1]+" "+t};var X=pu;function X0(u,e,t){this.src=u,this.env=t,this.tokens=[],this.inlineMode=!1,this.md=e}X0.prototype.Token=X;var J0=X0;var jr=/ \r \n ?| \n /g,Vr=/ \0 /g;function ge(u){let e;e=u.src.replace(jr, `
2024-12-23 19:55:23 +08:00
` ),e=e.replace(Vr," \u FFFD"),u.src=e}function _e(u){let e;u.inlineMode?(e=new u.Token("inline","",0),e.content=u.src,e.map=[0,1],e.children=[],u.tokens.push(e)):u.md.block.parse(u.src,u.md,u.env,u.tokens)}function ke(u){let e=u.tokens;for(let t=0,r=e.length;t<r;t++){let n=e[t];n.type==="inline"&&u.md.inline.parse(n.content,u.md,u.env,n.children)}}function Zr(u){return/^<a[> \s ]/i.test(u)}function Gr(u){return/^< \/ a \s *>/i.test(u)}function ye(u){let e=u.tokens;if(u.md.options.linkify)for(let t=0,r=e.length;t<r;t++){if(e[t].type!=="inline"||!u.md.linkify.pretest(e[t].content))continue;let n=e[t].children,o=0;for(let i=n.length-1;i>=0;i--){let c=n[i];if(c.type==="link_close"){for(i--;n[i].level!==c.level&&n[i].type!=="link_open";)i--;continue}if(c.type==="html_inline"&&(Zr(c.content)&&o>0&&o--,Gr(c.content)&&o++),!(o>0)&&c.type==="text"&&u.md.linkify.test(c.content)){let a=c.content,s=u.md.linkify.match(a),f=[],d=c.level,_=0;s.length>0&&s[0].index===0&&i>0&&n[i-1].type==="text_special"&&(s=s.slice(1));for(let h=0;h<s.length;h++){let l=s[h].url,p=u.md.normalizeLink(l);if(!u.md.validateLink(p))continue;let m=s[h].text;s[h].schema?s[h].schema==="mailto:"&&!/^mailto:/i.test(m)?m=u.md.normalizeLinkText("mailto:"+m).replace(/^mailto:/,""):m=u.md.normalizeLinkText(m):m=u.md.normalizeLinkText("http://"+m).replace(/^http: \/ \/ /,"");let k=s[h].index;if(k>_){let y=new u.Token("text","",0);y.content=a.slice(_,k),y.level=d,f.push(y)}let x=new u.Token("link_open","a",1);x.attrs=[["href",p]],x.level=d++,x.markup="linkify",x.info="auto",f.push(x);let g=new u.Token("text","",0);g.content=m,g.level=d,f.push(g);let b=new u.Token("link_close","a",-1);b.level=--d,b.markup="linkify",b.info="auto",f.push(b),_=s[h].lastIndex}if(_<a.length){let h=new u.Token("text","",0);h.content=a.slice(_),h.level=d,f.push(h)}e[t].children=n=de(n,i,f)}}}}var K0=/ \+ -| \. \. | \? \? \? \? |!!!!|,,|--/,Wr=/ \( (c|tm|r) \) /i,Xr=/ \( (c|tm|r) \) /ig,Jr={c:" \x A9",r:" \x AE",tm:" \u 2122"};function Kr(u,e){return Jr[e.toLowerCase()]}function Yr(u){let e=0;for(let t=u.length-1;t>=0;t--){let r=u[t];r.type==="text"&&!e&&(r.content=r.content.replace(Xr,Kr)),r.type==="link_open"&&r.info==="auto"&&e--,r.type==="link_close"&&r.info==="auto"&&e++}}function Qr(u){let e=0;for(let t=u.length-1;t>=0;t--){let r=u[t];r.type==="text"&&!e&&K0.test(r.content)&&(r.content=r.content.replace(/ \+ -/g," \x B1").replace(/ \. {2,}/g," \u 2026").replace(/([?!])…/g," $ 1..").replace(/([?!]){4,}/g," $ 1 $ 1 $ 1").replace(/,{2,}/g,",").replace(/(^|[^-])---(?=[^-]| $ )/mg," $ 1 \u 2014").replace(/(^| \s )--(?= \s | $ )/mg," $ 1 \u 2013").replace(/(^|[^- \s ])--(?=[^- \s ]| $ )/mg," $ 1 \u 2013")),r.type==="link_open"&&r.info==="auto"&&e--,r.type==="link_close"&&r.info==="auto"&&e++}}function De(u){let e;if(u.md.options.typographer)for(e=u.tokens.length-1;e>=0;e--)u.tokens[e].type==="inline"&&(Wr.test(u.tokens[e].content)&&Yr(u.tokens[e].children),K0.test(u.tokens[e].content)&&Qr(u.tokens[e].children))}var un=/['"]/,Y0=/['"]/g,Q0=" \u 2019";function Nu(u,e,t){return u.slice(0,e)+t+u.slice(e+1)}function en(u,e){let t,r=[];for(let n=0;n<u.length;n++){let o=u[n],i=u[n].level;for(t=r.length-1;t>=0&&!(r[t].level<=i);t--);if(r.length=t+1,o.type!=="text")continue;let c=o.content,a=0,s=c.length;u:for(;a<s;){Y0.lastIndex=a;let f=Y0.exec(c);if(!f)break;let d=!0,_=!0;a=f.index+1;let h=f[0]==="'",l=32;if(f.index-1>=0)l=c.charCodeAt(f.index-1);else for(t=n-1;t>=0&&!(u[t].type==="softbreak"||u[t].type==="hardbreak");t--)if(u[t].content){l=u[t].content.charCodeAt(u[t].content.length-1);break}let p=32;if(a<s)p=c.charCodeAt(a);else for(t=n+1;t<u.length&&!(u[t].type==="softbreak"||u[t].type==="hardbreak");t++)if(u[t].content){p=u[t].content.charCodeAt(0);break}let m=nu(l)||ru(String.fromCharCode(l)),k=nu(p)||ru(String.fromCharCode(p)),x=tu(l),g=tu(p);if(g?d=!1:k&&(x||m||(d=!1)),x?_=!1:m&&(g||k||(_=!1)),p===34&&f[0]==='"'&&l>=48&&l<=57&&(_=d=!1),d&&_&&(d=m,_=k),!d&&!_){h&&(o.content=Nu(o.content,f.index,Q0));continue}if(_)for(t=r.length-1;t>=0;t--){let b=r[t];if(r[t].level<i)break;if(b.single===h&&r[t].level===i){b=r[t];let y,D;h?(y=e.md.options.quotes[2],D=e.md.options.quotes[3]
2025-05-31 21:27:44 +08:00
` ,o.map=[e,u.line],!0}function Te(u,e,t,r){let n=u.bMarks[e]+u.tShift[e],o=u.eMarks[e];if(u.sCount[e]-u.blkIndent>=4||n+3>o)return!1;let i=u.src.charCodeAt(n);if(i!==126&&i!==96)return!1;let c=n;n=u.skipChars(n,i);let a=n-c;if(a<3)return!1;let s=u.src.slice(c,n),f=u.src.slice(n,o);if(i===96&&f.indexOf(String.fromCharCode(i))>=0)return!1;if(r)return!0;let d=e,_=!1;for(;d++,!(d>=t||(n=c=u.bMarks[d]+u.tShift[d],o=u.eMarks[d],n<o&&u.sCount[d]<u.blkIndent));)if(u.src.charCodeAt(n)===i&&!(u.sCount[d]-u.blkIndent>=4)&&(n=u.skipChars(n,i),!(n-c<a)&&(n=u.skipSpaces(n),!(n<o)))){_=!0;break}a=u.sCount[e],u.line=d+(_?1:0);let h=u.push("fence","code",0);return h.info=f,h.content=u.getLines(e+1,d,a,!0),h.markup=s,h.map=[e,u.line],!0}function Le(u,e,t,r){let n=u.bMarks[e]+u.tShift[e],o=u.eMarks[e],i=u.lineMax;if(u.sCount[e]-u.blkIndent>=4||u.src.charCodeAt(n)!==62)return!1;if(r)return!0;let c=[],a=[],s=[],f=[],d=u.md.block.ruler.getRules("blockquote"),_=u.parentType;u.parentType="blockquote";let h=!1,l;for(l=e;l<t;l++){let g=u.sCount[l]<u.blkIndent;if(n=u.bMarks[l]+u.tShift[l],o=u.eMarks[l],n>=o)break;if(u.src.charCodeAt(n++)===62&&!g){let y=u.sCount[l]+1,D,w;u.src.charCodeAt(n)===32?(n++,y++,w=!1,D=!0):u.src.charCodeAt(n)===9?(D=!0,(u.bsCount[l]+y)%4===3?(n++,y++,w=!1):w=!0):D=!1;let A=y;for(c.push(u.bMarks[l]),u.bMarks[l]=n;n<o;){let v=u.src.charCodeAt(n);if(F(v))v===9?A+=4-(A+u.bsCount[l]+(w?1:0))%4:A++;else break;n++}h=n>=o,a.push(u.bsCount[l]),u.bsCount[l]=u.sCount[l]+1+(D?1:0),s.push(u.sCount[l]),u.sCount[l]=A-y,f.push(u.tShift[l]),u.tShift[l]=n-u.bMarks[l];continue}if(h)break;let b=!1;for(let y=0,D=d.length;y<D;y++)if(d[y](u,l,t,!0)){b=!0;break}if(b){u.lineMax=l,u.blkIndent!==0&&(c.push(u.bMarks[l]),a.push(u.bsCount[l]),f.push(u.tShift[l]),s.push(u.sCount[l]),u.sCount[l]-=u.blkIndent);break}c.push(u.bMarks[l]),a.push(u.bsCount[l]),f.push(u.tShift[l]),s.push(u.sCount[l]),u.sCount[l]=-1}let p=u.blkIndent;u.blkIndent=0;let m=u.push("blockquote_open","blockquote",1);m.markup=">";let k=[e,0];m.map=k,u.md.block.tokenize(u,e,l);let x=u.push("blockquote_close","blockquote",-1);x.markup=">",u.lineMax=i,u.parentType=_,k[1]=u.line;for(let g=0;g<f.length;g++)u.bMarks[g+e]=c[g],u.tShift[g+e]=f[g],u.sCount[g+e]=s[g],u.bsCount[g+e]=a[g];return u.blkIndent=p,!0}function Me(u,e,t,r){let n=u.eMarks[e];if(u.sCount[e]-u.blkIndent>=4)return!1;let o=u.bMarks[e]+u.tShift[e],i=u.src.charCodeAt(o++);if(i!==42&&i!==45&&i!==95)return!1;let c=1;for(;o<n;){let s=u.src.charCodeAt(o++);if(s!==i&&!F(s))return!1;s===i&&c++}if(c<3)return!1;if(r)return!0;u.line=e+1;let a=u.push("hr","hr",0);return a.map=[e,u.line],a.markup=Array(c+1).join(String.fromCharCode(i)),!0}function rt(u,e){let t=u.eMarks[e],r=u.bMarks[e]+u.tShift[e],n=u.src.charCodeAt(r++);if(n!==42&&n!==45&&n!==43)return-1;if(r<t){let o=u.src.charCodeAt(r);if(!F(o))return-1}return r}function nt(u,e){let t=u.bMarks[e]+u.tShift[e],r=u.eMarks[e],n=t;if(n+1>=r)return-1;let o=u.src.charCodeAt(n++);if(o<48||o>57)return-1;for(;;){if(n>=r)return-1;if(o=u.src.charCodeAt(n++),o>=48&&o<=57){if(n-t>=10)return-1;continue}if(o===41||o===46)break;return-1}return n<r&&(o=u.src.charCodeAt(n),!F(o))?-1:n}function rn(u,e){let t=u.level+2;for(let r=e+2,n=u.tokens.length-2;r<n;r++)u.tokens[r].level===t&&u.tokens[r].type==="paragraph_open"&&(u.tokens[r+2].hidden=!0,u.tokens[r].hidden=!0,r+=2)}function Re(u,e,t,r){let n,o,i,c,a=e,s=!0;if(u.sCount[a]-u.blkIndent>=4||u.listIndent>=0&&u.sCount[a]-u.listIndent>=4&&u.sCount[a]<u.blkIndent)return!1;let f=!1;r&&u.parentType==="paragraph"&&u.sCount[a]>=u.blkIndent&&(f=!0);let d,_,h;if((h=nt(u,a))>=0){if(d=!0,i=u.bMarks[a]+u.tShift[a],_=Number(u.src.slice(i,h-1)),f&&_!==1)return!1}else if((h=rt(u,a))>=0)d=!1;else return!1;if(f&&u.skipSpaces(h)>=u.eMarks[a])return!1;if(r)return!0;let l=u.src.charCodeAt(h-1),p=u.tokens.length;d?(c=u.push("ordered_list_open","ol",1),_!==1&&(c.attrs=[["start",_]])):c=u.push("bullet_list_open","ul",1);let m=[a,0];c.map=m,c.markup=String.fromCharCode(l);let k=!1,x=u.md.block.ruler.getRules("list"),g=u.parentType;for(u.parentType="list";a<t;){o=h,n=u.eMarks
2024-05-11 22:49:29 +08:00
` ).map(f=>f.indexOf( ` drawio - diagram = "${n}" ` )!==-1?a:f).join( `
2024-12-23 19:55:23 +08:00
` );E(this,C,Qu).call(this,s,r),Ku()}catch(c){throw this.handleDrawingUploadError(c),new Error( ` Failed to save image with error : $ { c } ` )}})}handleDrawingUploadError(e){e.status===413?window. $ events.emit("error",this.editor.config.text.serverUploadLimit):window. $ events.emit("error",this.editor.config.text.imageUploadError),console.error(e)}fullScreen(){let{container:e}=this.editor.config,t=e.classList.contains("fullscreen");e.classList.toggle("fullscreen",!t),document.body.classList.toggle("markdown-fullscreen",!t)}scrollToText(e){if(!e)return;let t=this.editor.cm.state.doc,r=1,n=-1;for(let i of t.iterLines()){if(i.includes(e)){n=r;break}r+=1}if(n===-1)return;let o=t.line(n);E(this,C,Vt).call(this,o.from,o.to,!0),this.focus()}focus(){this.editor.cm.hasFocus||this.editor.cm.focus()}insertContent(e){E(this,C,au).call(this,e,e.length)}prependContent(e){e=E(this,C,w0).call(this,e);let r=E(this,C,q).call(this).from+e.length+1;E(this,C,z).call(this,0,0, ` $ { e }
` ,r),this.focus()}appendContent(e){e=E(this,C,w0).call(this,e),E(this,C,z).call(this,this.editor.cm.state.doc.length, `
2025-01-05 06:22:17 +08:00
$ { e } ` ),this.focus()}replaceContent(e){E(this,C,Qu).call(this,e)}replaceLineStart(e){let t=E(this,C,q).call(this),r=this.editor.cm.state.doc.lineAt(t.from),n=r.text,o=n.split(" ")[0];if(o===e){let s=n.replace( ` $ { e } ` ,""),f=t.from+(s.length-n.length);E(this,C,z).call(this,r.from,r.to,s,f);return}let i=n;/^[#> ` ] / . test ( o ) ? i = n . replace ( o , e ) . trim ( ) : e !== "" && ( i = ` ${ e } ${ n } ` ) ; let a = t . from + ( i . length - n . length ) ; E ( this , C , z ) . call ( this , r . from , r . to , i , a ) } wrapSelection ( e , t ) { let r = E ( this , C , q ) . call ( this ) , n = E ( this , C , bu ) . call ( this , r ) ; if ( ! n ) { E ( this , C , ue ) . call ( this , e , t ) ; return } let o = n , i ; n . startsWith ( e ) && n . endsWith ( t ) ? ( o = n . slice ( e . length , n . length - t . length ) , i = r . extend ( r . from , r . to - ( e . length + t . length ) ) ) : ( o = ` ${ e } ${ n } ${ t } ` , i = r . extend ( r . from , r . to + ( e . length + t . length ) ) ) , E ( this , C , z ) . call ( this , r . from , r . to , o , i . anchor , i . head ) } replaceLineStartForOrderedList ( ) { let e = E ( this , C , q ) . call ( this ) , t = this . editor . cm . state . doc . lineAt ( e . from ) , n = this . editor . cm . state . doc . line ( t . number - 1 ) . text . match ( /^(\s*)(\d)([).])\s/ ) || [ ] , o = ( Number ( n [ 2 ] ) || 0 ) + 1 , i = n [ 1 ] || "" , c = n [ 3 ] || "." , a = ` ${ i } ${ o } ${ c } ` ; return this . replaceLineStart ( a ) } cycleCalloutTypeAtSelection ( ) { let e = E ( this , C , q ) . call ( this ) , t = this . editor . cm . state . doc . lineAt ( e . from ) , r = [ "info" , "success" , "warning" , "danger" ] , n = r . join ( "|" ) , i = new RegExp ( ` class="(( ${ n } ) \\ s+callout|callout \\ s+( ${ n } ))" ` , "i" ) . exec ( t . text ) , c = ( i ? i [ 2 ] || i [ 3 ] : "" ) . toLowerCase ( ) ; if ( c === r [ r . length - 1 ] ) E ( this , C , ue ) . call ( this , ` <p class="callout ${ r [ r . length - 1 ] } "> ` , "</p>" ) ; else if ( c === "" ) E ( this , C , ue ) . call ( this , '<p class="callout info">' , "</p>" ) ; else { let a = r . indexOf ( c ) + 1 , s = r [ a ] , f = t . text . replace ( i [ 0 ] , i [ 0 ] . replace ( c , s ) ) , d = f . length - t . text . length ; E ( this , C , z ) . call ( this , t . from , t . to , f , e . anchor + d , e . head + d ) } } syncDisplayPosition ( e ) { let t = e . target ; if ( Math . abs ( t . scrollHeight - t . clientHeight - t . scrollTop ) < 1 ) { this . editor . display . scrollToIndex ( - 1 ) ; return } let n = this . editor . cm . lineBlockAtHeight ( t . scrollTop ) , o = this . editor . cm . state . sliceDoc ( 0 , n . from ) , a = new DOMParser ( ) . parseFromString ( this . editor . markdown . render ( o ) , "text/html" ) . documentElement . querySelectorAll ( "body > *" ) ; this . editor . display . scrollToIndex ( a . length ) } async insertTemplate ( e , t , r ) { let n = this . editor . cm . posAtCoords ( { x : t , y : r } , ! 1 ) , { data : o } = await window . $http . get ( ` /templates/ ${ e } ` ) , i = o . markdown || o . html ; E ( this , C , z ) . call ( this , n , n , i , n ) } insertClipboardImages ( e , t , r ) { let n = this . editor . cm . posAtCoords ( { x : t , y : r } , ! 1 ) ; for ( let o of e ) this . uploadImage ( o , n ) } async uploadImage ( e , t = null ) { if ( e === null || e . type . indexOf ( "image" ) !== 0 ) return ; let r = "png" ; if ( t === null && ( t = E ( this , C , q ) . call ( this ) . from ) , e . name ) { let s = e . name . match ( /\.(.+)$/ ) ; s . length > 1 && ( r = s [ 1 ] ) } let n = ` image- ${ Math . random ( ) . toString ( 16 ) . slice ( 2 ) } ` , i = `  } ) ` ; E ( this , C , z ) . call ( this , t , t , i , t ) ; let c = ` image- ${ Date . now ( ) } . ${ r } ` , a = new FormData ; a . append ( "file" , e , c ) , a . append ( "uploaded_to" , this . editor . config . pageId ) ; try { let { data : s } = await window . $http . post ( "/images/gallery" , a ) , f = ` []( ${ s . url } ) ` ; E ( this , C , A0 ) . call ( this , i , f ) } catch ( s ) { window . $events . error ( s ? . data ? . message || this . editor . config . text . imageUploadError ) , E ( this , C , A0 ) . call ( this , i , "" ) , console . error ( s ) } } } ; C = new WeakSet , E0 = function ( e , t ) { let r = ` <div drawio-diagram=" ${ e . id } "><img src=" ${ e . url } "></div> ` ; E ( this , C , au ) . call ( this , r , r . length , t ) } , Yu = function ( ) { return this . editor . cm . state . doc . toString ( ) } , Qu = function ( e , t = null ) { t = t || E ( this , C , q ) . call ( this ) ; let r = this . editor . cm . state . toText ( e ) , n = Math . min ( t . from , r . length ) , o = this . editor . cm . scrollDOM . scrollTop ; E ( this , C , z ) . call ( this , 0 , this . editor . cm . state . doc . length , e , n ) , this . focus ( ) , window . requestAnimationFrame ( ( ) => { this . editor . cm . scrollDOM . scrollTop = o } ) } , au = function ( e , t = 0 , r = null ) { r = r || this . editor . cm . state . selection . main ; let n = r . from + t ; E ( this , C , z ) . call ( this , r . from , r . to , e , n ) , this . focus ( ) } , bu = function ( e = null ) { return e = e || E ( this , C , q ) . call ( this ) , this . editor . cm . state . sliceDoc ( e . from , e . to ) } , q = function ( ) { return this . editor . cm . state . selection . main } , w0 = function ( e ) { return e . replace ( /\r\n|\r/g , `
2024-12-23 19:55:23 +08:00
` )},A0=function(e,t){let r=E(this,C,Yu).call(this).replace(e,t);E(this,C,Qu).call(this,r)},ue=function(e,t){let r=E(this,C,q).call(this),n=this.editor.cm.state.doc.lineAt(r.from),o=n.text,i,c=0;o.startsWith(e)&&o.endsWith(t)?(i=o.slice(e.length,o.length-t.length),c=-e.length):(i= ` $ { e } $ { o } $ { t } ` ,c=e.length),E(this,C,z).call(this,n.from,n.to,i,r.from+c)},z=function(e,t=null,r=null,n=null,o=null){let i={changes:{from:e,to:t,insert:r}};n&&(i.selection={anchor:n},o&&(i.selection.head=o)),this.editor.cm.dispatch(i)},Vt=function(e,t,r=!1){this.editor.cm.dispatch({selection:{anchor:e,head:t},scrollIntoView:r})};var te=class{constructor(e){this.settingMap={scrollSync:!0,showPreview:!0,editorWidth:50},this.changeListeners={},this.loadFromLocalStorage(),this.applyToInputs(e),this.listenToInputChanges(e)}applyToInputs(e){for(let t of e){let r=t.getAttribute("name").replace("md-","");t.checked=this.settingMap[r]}}listenToInputChanges(e){for(let t of e)t.addEventListener("change",()=>{let r=t.getAttribute("name").replace("md-","");this.set(r,t.checked)})}loadFromLocalStorage(){let e=window.localStorage.getItem("md-editor-settings");if(!e)return;let t=JSON.parse(e);for(let[r,n]of Object.entries(t))n!==null&&this.settingMap[r]!==void 0&&(this.settingMap[r]=n)}set(e,t){this.settingMap[e]=t,window.localStorage.setItem("md-editor-settings",JSON.stringify(this.settingMap));for(let r of this.changeListeners[e]||[])r(t)}get(e){return this.settingMap[e]||null}onChange(e,t){let r=this.changeListeners[e]||[];r.push(t),this.changeListeners[e]=r}};function re({html:u,markdown:e}){return e||u}function Zt(u){window. $ events.listen("editor::replace",e=>{let t=re(e);u.actions.replaceContent(t)}),window. $ events.listen("editor::append",e=>{let t=re(e);u.actions.appendContent(t)}),window. $ events.listen("editor::prepend",e=>{let t=re(e);u.actions.prependContent(t)}),window. $ events.listen("editor::insert",e=>{let t=re(e);u.actions.insertContent(t)}),window. $ events.listen("editor::focus",()=>{u.actions.focus()})}function Zo(u){let e={};return e["Shift-Mod-i"]=()=>u.actions.insertImage(),e["Mod-s"]=()=>window. $ events.emit("editor-save-draft"),e["Mod-Enter"]=()=>window. $ events.emit("editor-save-page"),e["Shift-Mod-k"]=()=>u.actions.showLinkSelector(),e["Mod-k"]=()=>u.actions.insertLink(),e["Mod-1"]=()=>u.actions.replaceLineStart("##"),e["Mod-2"]=()=>u.actions.replaceLineStart("###"),e["Mod-3"]=()=>u.actions.replaceLineStart("####"),e["Mod-4"]=()=>u.actions.replaceLineStart("#####"),e["Mod-5"]=()=>u.actions.replaceLineStart(""),e["Mod-d"]=()=>u.actions.replaceLineStart(""),e["Mod-6"]=()=>u.actions.replaceLineStart(">"),e["Mod-q"]=()=>u.actions.replaceLineStart(">"),e["Mod-7"]=()=>u.actions.wrapSelection(" \n ` ` ` \ n "," \ n ` ` ` "),e["Mod-8"]=()=>u.actions.wrapSelection(" ` "," ` "),e["Shift-Mod-e"]=()=>u.actions.wrapSelection(" ` "," ` "),e["Mod-9"]=()=>u.actions.cycleCalloutTypeAtSelection(),e["Mod-p"]=()=>u.actions.replaceLineStart("-"),e["Mod-o"]=()=>u.actions.replaceLineStartForOrderedList(),e}function Gt(u){let e=Zo(u),t=[],r=n=>()=>(n(),!0);for(let[n,o]of Object.entries(e))t.push({key:n,run:r(o),preventDefault:!0});return t}function Wt(u,e,t){let r=null;return function(...o){let i=this,c=function(){r=null,t||u.apply(i,o)},a=t&&!r;r&&clearTimeout(r),r=window.setTimeout(c,e),a&&u.apply(i,o)}}var Cu=class{constructor(e){this.data=e}hasItems(){return!!this.data&&!!this.data.types&&this.data.types.length>0}containsTabularData(){let e=this.data.getData("text/rtf");return!!e&&e.includes(" \\ trowd")}getImages(){return this.getFiles().filter(e=>e.type.includes("image"))}getFiles(){let{files:e}=this.data;return[...e]}};async function Xt(u){let e=await window.importVersioned("code");function t(c){c.docChanged&&u.actions.updateAndRender()}let r=Wt(u.actions.syncDisplayPosition.bind(u.actions),100,!1),n=u.settings.get("scrollSync");u.settings.onChange("scrollSync",c=>{n=c});let o={scroll:c=>n&&r(c),drop:c=>{let a=c.dataTransfer.getData("bookstack/template");a&&(c.preventDefault(),u.actions.insertTemplate(a,c.pageX,c.pageY));let f=new Cu(c.dataTransfer).getImages();f.length>0&&(c.stopPr
2024-05-11 22:49:29 +08:00
//# sourceMappingURL=markdown.js.map