artalk 2.0.4 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -60
- package/dist/Artalk.css +1 -1
- package/dist/Artalk.es.js +5996 -1
- package/dist/Artalk.iife.js +266 -1
- package/dist/Artalk.js +266 -1
- package/package.json +3 -4
- package/src/api/index.ts +269 -0
- package/src/api/request.ts +125 -0
- package/src/artalk.ts +153 -0
- package/src/components/_component.ts.txt +10 -0
- package/src/components/action-btn.ts +169 -0
- package/src/components/admin/page-list.ts +194 -0
- package/src/components/admin/site-list-floater.ts +98 -0
- package/src/components/admin/site-list.ts +289 -0
- package/src/components/comment.ts +478 -0
- package/src/components/dialog.ts +63 -0
- package/src/components/editor-plugs/{_ExamplePlug.ts.txt → _example-plug.ts.txt} +0 -0
- package/src/components/editor-plugs/{EditorPlug.ts → editor-plug.ts} +3 -3
- package/src/components/editor-plugs/{EmoticonsPlug.less → emoticons-plug.less} +0 -0
- package/src/components/editor-plugs/{EmoticonsPlug.ts → emoticons-plug.ts} +9 -9
- package/src/components/editor-plugs/{PreviewPlug.less → preview-plug.less} +0 -0
- package/src/components/editor-plugs/{PreviewPlug.ts → preview-plug.ts} +10 -10
- package/src/components/{Editor.ts → editor.ts} +104 -102
- package/src/components/html/comment.html +2 -6
- package/src/components/html/list.html +0 -1
- package/src/components/html/sidebar.html +18 -4
- package/src/components/item-text-editor.ts +136 -0
- package/src/components/layer.ts +135 -0
- package/src/components/list-lite.ts +507 -0
- package/src/components/list.ts +172 -0
- package/src/components/pagination.ts +150 -0
- package/src/components/read-more-btn.ts +71 -0
- package/src/components/sidebar-view.ts +26 -0
- package/src/components/sidebar-views/comments-view.ts +66 -0
- package/src/components/sidebar-views/pages-view.ts +61 -0
- package/src/components/sidebar-views/setting-view.ts +21 -0
- package/src/components/sidebar-views/sites-view.ts +42 -0
- package/src/components/sidebar-views/transfer-view.ts +218 -0
- package/src/components/sidebar.ts +288 -0
- package/src/context.ts +42 -0
- package/src/default-conf.ts +42 -0
- package/src/lib/checker/admin-checker.ts +33 -0
- package/src/lib/checker/captcha-checker.ts +38 -0
- package/src/lib/checker/index.ts +134 -0
- package/src/lib/component.ts +3 -3
- package/src/lib/md5.js +6 -0
- package/src/lib/ui.ts +64 -74
- package/src/lib/user.ts +2 -8
- package/src/lib/utils.ts +30 -11
- package/src/main.ts +1 -1
- package/src/style/_color.less +8 -2
- package/src/style/_extend.less +81 -0
- package/src/style/_variables.less +3 -0
- package/src/style/comment.less +60 -24
- package/src/style/editor.less +3 -0
- package/src/style/item-text-editor.less +35 -0
- package/src/style/list.less +51 -32
- package/src/style/main.less +75 -1
- package/src/style/page-list.less +50 -0
- package/src/style/pagination.less +58 -0
- package/src/style/sidebar.less +274 -199
- package/src/style/site-list.less +208 -0
- package/tsconfig.json +27 -0
- package/types/artalk-config.d.ts +68 -51
- package/types/artalk-data.d.ts +38 -1
- package/types/event.d.ts +73 -0
- package/types/index.d.ts +1 -6
- package/.github/workflows/npm.yml +0 -31
- package/.github/workflows/pages.yml +0 -30
- package/dist/src/Event.d.ts +0 -59
- package/dist/types/artalk-config.d.ts +0 -79
- package/dist/types/artalk-data.d.ts +0 -153
- package/dist/types/global.d.ts +0 -1
- package/dist/types/index.d.ts +0 -8
- package/dist/types/vite-env.d.ts +0 -1
- package/example/pjax/res1.html +0 -41
- package/example/pjax/res2.html +0 -41
- package/src/Artalk.ts +0 -160
- package/src/Constant.ts +0 -6
- package/src/Context.ts +0 -34
- package/src/Event.d.ts +0 -59
- package/src/components/Comment.ts +0 -402
- package/src/components/Layer.ts +0 -138
- package/src/components/List.ts +0 -162
- package/src/components/ListLite.ts +0 -407
- package/src/components/Sidebar.ts +0 -141
- package/src/components/sidebar-views/AdminView.ts +0 -523
- package/src/components/sidebar-views/MessageView.ts +0 -48
- package/src/components/sidebar-views/SidebarView.ts +0 -24
- package/src/lib/api.ts +0 -380
- package/src/lib/checker.ts +0 -164
package/dist/Artalk.js
CHANGED
|
@@ -1 +1,266 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).Artalk=e()}(this,(function(){"use strict";"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var t={exports:{}};!function(t,e){!function(e){var i={newline:/^\n+/,code:/^( {4}[^\n]+\n*)+/,fences:/^ {0,3}(`{3,}|~{3,})([^`~\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(?:\n+|$)|$)/,hr:/^ {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\* *){3,})(?:\n+|$)/,heading:/^ {0,3}(#{1,6}) +([^\n]*?)(?: +#+)? *(?:\n+|$)/,blockquote:/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,list:/^( {0,3})(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,html:"^ {0,3}(?:<(script|pre|style)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?\\?>\\n*|<![A-Z][\\s\\S]*?>\\n*|<!\\[CDATA\\[[\\s\\S]*?\\]\\]>\\n*|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:\\n{2,}|$)|<(?!script|pre|style)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n{2,}|$)|</(?!script|pre|style)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n{2,}|$))",def:/^ {0,3}\[(label)\]: *\n? *<?([^\s>]+)>?(?:(?: +\n? *| *\n *)(title))? *(?:\n+|$)/,nptable:f,table:f,lheading:/^([^\n]+)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html)[^\n]+)*)/,text:/^[^\n]+/};function n(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||b.defaults,this.rules=i.normal,this.options.pedantic?this.rules=i.pedantic:this.options.gfm&&(this.rules=i.gfm)}i._label=/(?!\s*\])(?:\\[\[\]]|[^\[\]])+/,i._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,i.def=p(i.def).replace("label",i._label).replace("title",i._title).getRegex(),i.bullet=/(?:[*+-]|\d{1,9}\.)/,i.item=/^( *)(bull) ?[^\n]*(?:\n(?!\1bull ?)[^\n]*)*/,i.item=p(i.item,"gm").replace(/bull/g,i.bullet).getRegex(),i.list=p(i.list).replace(/bull/g,i.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+i.def.source+")").getRegex(),i._tag="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",i._comment=/<!--(?!-?>)[\s\S]*?-->/,i.html=p(i.html,"i").replace("comment",i._comment).replace("tag",i._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),i.paragraph=p(i._paragraph).replace("hr",i.hr).replace("heading"," {0,3}#{1,6} +").replace("|lheading","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}|~{3,})[^`\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)").replace("tag",i._tag).getRegex(),i.blockquote=p(i.blockquote).replace("paragraph",i.paragraph).getRegex(),i.normal=k({},i),i.gfm=k({},i.normal,{nptable:/^ *([^|\n ].*\|.*)\n *([-:]+ *\|[-| :]*)(?:\n((?:.*[^>\n ].*(?:\n|$))*)\n*|$)/,table:/^ *\|(.+)\n *\|?( *[-:]+[-| :]*)(?:\n((?: *[^>\n ].*(?:\n|$))*)\n*|$)/}),i.pedantic=k({},i.normal,{html:p("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:\"[^\"]*\"|'[^']*'|\\s[^'\"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment",i._comment).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/,fences:f,paragraph:p(i.normal._paragraph).replace("hr",i.hr).replace("heading"," *#{1,6} *[^\n]").replace("lheading",i.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()}),n.rules=i,n.lex=function(t,e){return new n(e).lex(t)},n.prototype.lex=function(t){return t=t.replace(/\r\n|\r/g,"\n").replace(/\t/g," ").replace(/\u00a0/g," ").replace(/\u2424/g,"\n"),this.token(t,!0)},n.prototype.token=function(t,e){var n,s,a,r,o,l,c,h,p,u,m,g,f,k,x,E;for(t=t.replace(/^ +$/gm,"");t;)if((a=this.rules.newline.exec(t))&&(t=t.substring(a[0].length),a[0].length>1&&this.tokens.push({type:"space"})),a=this.rules.code.exec(t)){var b=this.tokens[this.tokens.length-1];t=t.substring(a[0].length),b&&"paragraph"===b.type?b.text+="\n"+a[0].trimRight():(a=a[0].replace(/^ {4}/gm,""),this.tokens.push({type:"code",codeBlockStyle:"indented",text:this.options.pedantic?a:v(a,"\n")}))}else if(a=this.rules.fences.exec(t))t=t.substring(a[0].length),this.tokens.push({type:"code",lang:a[2]?a[2].trim():a[2],text:a[3]||""});else if(a=this.rules.heading.exec(t))t=t.substring(a[0].length),this.tokens.push({type:"heading",depth:a[1].length,text:a[2]});else if((a=this.rules.nptable.exec(t))&&(l={type:"table",header:y(a[1].replace(/^ *| *\| *$/g,"")),align:a[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:a[3]?a[3].replace(/\n$/,"").split("\n"):[]}).header.length===l.align.length){for(t=t.substring(a[0].length),m=0;m<l.align.length;m++)/^ *-+: *$/.test(l.align[m])?l.align[m]="right":/^ *:-+: *$/.test(l.align[m])?l.align[m]="center":/^ *:-+ *$/.test(l.align[m])?l.align[m]="left":l.align[m]=null;for(m=0;m<l.cells.length;m++)l.cells[m]=y(l.cells[m],l.header.length);this.tokens.push(l)}else if(a=this.rules.hr.exec(t))t=t.substring(a[0].length),this.tokens.push({type:"hr"});else if(a=this.rules.blockquote.exec(t))t=t.substring(a[0].length),this.tokens.push({type:"blockquote_start"}),a=a[0].replace(/^ *> ?/gm,""),this.token(a,e),this.tokens.push({type:"blockquote_end"});else if(a=this.rules.list.exec(t)){for(t=t.substring(a[0].length),c={type:"list_start",ordered:k=(r=a[2]).length>1,start:k?+r:"",loose:!1},this.tokens.push(c),h=[],n=!1,f=(a=a[0].match(this.rules.item)).length,m=0;m<f;m++)u=(l=a[m]).length,~(l=l.replace(/^ *([*+-]|\d+\.) */,"")).indexOf("\n ")&&(u-=l.length,l=this.options.pedantic?l.replace(/^ {1,4}/gm,""):l.replace(new RegExp("^ {1,"+u+"}","gm"),"")),m!==f-1&&(o=i.bullet.exec(a[m+1])[0],(r.length>1?1===o.length:o.length>1||this.options.smartLists&&o!==r)&&(t=a.slice(m+1).join("\n")+t,m=f-1)),s=n||/\n\n(?!\s*$)/.test(l),m!==f-1&&(n="\n"===l.charAt(l.length-1),s||(s=n)),s&&(c.loose=!0),E=void 0,(x=/^\[[ xX]\] /.test(l))&&(E=" "!==l[1],l=l.replace(/^\[[ xX]\] +/,"")),p={type:"list_item_start",task:x,checked:E,loose:s},h.push(p),this.tokens.push(p),this.token(l,!1),this.tokens.push({type:"list_item_end"});if(c.loose)for(f=h.length,m=0;m<f;m++)h[m].loose=!0;this.tokens.push({type:"list_end"})}else if(a=this.rules.html.exec(t))t=t.substring(a[0].length),this.tokens.push({type:this.options.sanitize?"paragraph":"html",pre:!this.options.sanitizer&&("pre"===a[1]||"script"===a[1]||"style"===a[1]),text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(a[0]):d(a[0]):a[0]});else if(e&&(a=this.rules.def.exec(t)))t=t.substring(a[0].length),a[3]&&(a[3]=a[3].substring(1,a[3].length-1)),g=a[1].toLowerCase().replace(/\s+/g," "),this.tokens.links[g]||(this.tokens.links[g]={href:a[2],title:a[3]});else if((a=this.rules.table.exec(t))&&(l={type:"table",header:y(a[1].replace(/^ *| *\| *$/g,"")),align:a[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:a[3]?a[3].replace(/\n$/,"").split("\n"):[]}).header.length===l.align.length){for(t=t.substring(a[0].length),m=0;m<l.align.length;m++)/^ *-+: *$/.test(l.align[m])?l.align[m]="right":/^ *:-+: *$/.test(l.align[m])?l.align[m]="center":/^ *:-+ *$/.test(l.align[m])?l.align[m]="left":l.align[m]=null;for(m=0;m<l.cells.length;m++)l.cells[m]=y(l.cells[m].replace(/^ *\| *| *\| *$/g,""),l.header.length);this.tokens.push(l)}else if(a=this.rules.lheading.exec(t))t=t.substring(a[0].length),this.tokens.push({type:"heading",depth:"="===a[2].charAt(0)?1:2,text:a[1]});else if(e&&(a=this.rules.paragraph.exec(t)))t=t.substring(a[0].length),this.tokens.push({type:"paragraph",text:"\n"===a[1].charAt(a[1].length-1)?a[1].slice(0,-1):a[1]});else if(a=this.rules.text.exec(t))t=t.substring(a[0].length),this.tokens.push({type:"text",text:a[0]});else if(t)throw new Error("Infinite loop on byte: "+t.charCodeAt(0));return this.tokens};var s={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:f,tag:"^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>",link:/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/,reflink:/^!?\[(label)\]\[(?!\s*\])((?:\\[\[\]]?|[^\[\]\\])+)\]/,nolink:/^!?\[(?!\s*\])((?:\[[^\[\]]*\]|\\[\[\]]|[^\[\]])*)\](?:\[\])?/,strong:/^__([^\s_])__(?!_)|^\*\*([^\s*])\*\*(?!\*)|^__([^\s][\s\S]*?[^\s])__(?!_)|^\*\*([^\s][\s\S]*?[^\s])\*\*(?!\*)/,em:/^_([^\s_])_(?!_)|^\*([^\s*<\[])\*(?!\*)|^_([^\s<][\s\S]*?[^\s_])_(?!_|[^\spunctuation])|^_([^\s_<][\s\S]*?[^\s])_(?!_|[^\spunctuation])|^\*([^\s<"][\s\S]*?[^\s\*])\*(?!\*|[^\spunctuation])|^\*([^\s*"<\[][\s\S]*?[^\s])\*(?!\*)/,code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,br:/^( {2,}|\\)\n(?!\s*$)/,del:f,text:/^(`+|[^`])(?:[\s\S]*?(?:(?=[\\<!\[`*]|\b_|$)|[^ ](?= {2,}\n))|(?= {2,}\n))/};function a(t,e){if(this.options=e||b.defaults,this.links=t,this.rules=s.normal,this.renderer=this.options.renderer||new r,this.renderer.options=this.options,!this.links)throw new Error("Tokens array requires a `links` property.");this.options.pedantic?this.rules=s.pedantic:this.options.gfm&&(this.options.breaks?this.rules=s.breaks:this.rules=s.gfm)}function r(t){this.options=t||b.defaults}function o(){}function l(t){this.tokens=[],this.token=null,this.options=t||b.defaults,this.options.renderer=this.options.renderer||new r,this.renderer=this.options.renderer,this.renderer.options=this.options,this.slugger=new c}function c(){this.seen={}}function d(t,e){if(e){if(d.escapeTest.test(t))return t.replace(d.escapeReplace,(function(t){return d.replacements[t]}))}else if(d.escapeTestNoEncode.test(t))return t.replace(d.escapeReplaceNoEncode,(function(t){return d.replacements[t]}));return t}function h(t){return t.replace(/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi,(function(t,e){return"colon"===(e=e.toLowerCase())?":":"#"===e.charAt(0)?"x"===e.charAt(1)?String.fromCharCode(parseInt(e.substring(2),16)):String.fromCharCode(+e.substring(1)):""}))}function p(t,e){return t=t.source||t,e=e||"",{replace:function(e,i){return i=(i=i.source||i).replace(/(^|[^\[])\^/g,"$1"),t=t.replace(e,i),this},getRegex:function(){return new RegExp(t,e)}}}function u(t,e,i){if(t){try{var n=decodeURIComponent(h(i)).replace(/[^\w:]/g,"").toLowerCase()}catch(s){return null}if(0===n.indexOf("javascript:")||0===n.indexOf("vbscript:")||0===n.indexOf("data:"))return null}e&&!g.test(i)&&(i=function(t,e){m[" "+t]||(/^[^:]+:\/*[^/]*$/.test(t)?m[" "+t]=t+"/":m[" "+t]=v(t,"/",!0));return t=m[" "+t],"//"===e.slice(0,2)?t.replace(/:[\s\S]*/,":")+e:"/"===e.charAt(0)?t.replace(/(:\/*[^/]*)[\s\S]*/,"$1")+e:t+e}(e,i));try{i=encodeURI(i).replace(/%25/g,"%")}catch(s){return null}return i}s._punctuation="!\"#$%&'()*+,\\-./:;<=>?@\\[^_{|}~",s.em=p(s.em).replace(/punctuation/g,s._punctuation).getRegex(),s._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,s._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,s._email=/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/,s.autolink=p(s.autolink).replace("scheme",s._scheme).replace("email",s._email).getRegex(),s._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,s.tag=p(s.tag).replace("comment",i._comment).replace("attribute",s._attribute).getRegex(),s._label=/(?:\[[^\[\]]*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,s._href=/<(?:\\[<>]?|[^\s<>\\])*>|[^\s\x00-\x1f]*/,s._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,s.link=p(s.link).replace("label",s._label).replace("href",s._href).replace("title",s._title).getRegex(),s.reflink=p(s.reflink).replace("label",s._label).getRegex(),s.normal=k({},s),s.pedantic=k({},s.normal,{strong:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,em:/^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/,link:p(/^!?\[(label)\]\((.*?)\)/).replace("label",s._label).getRegex(),reflink:p(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",s._label).getRegex()}),s.gfm=k({},s.normal,{escape:p(s.escape).replace("])","~|])").getRegex(),_extended_email:/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,url:/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,_backpedal:/(?:[^?!.,:;*_~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_~)]+(?!$))+/,del:/^~+(?=\S)([\s\S]*?\S)~+/,text:/^(`+|[^`])(?:[\s\S]*?(?:(?=[\\<!\[`*~]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))|(?= {2,}\n|[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))/}),s.gfm.url=p(s.gfm.url,"i").replace("email",s.gfm._extended_email).getRegex(),s.breaks=k({},s.gfm,{br:p(s.br).replace("{2,}","*").getRegex(),text:p(s.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()}),a.rules=s,a.output=function(t,e,i){return new a(e,i).output(t)},a.prototype.output=function(t){for(var e,i,n,s,r,o,l="";t;)if(r=this.rules.escape.exec(t))t=t.substring(r[0].length),l+=d(r[1]);else if(r=this.rules.tag.exec(t))!this.inLink&&/^<a /i.test(r[0])?this.inLink=!0:this.inLink&&/^<\/a>/i.test(r[0])&&(this.inLink=!1),!this.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(r[0])?this.inRawBlock=!0:this.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(r[0])&&(this.inRawBlock=!1),t=t.substring(r[0].length),l+=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(r[0]):d(r[0]):r[0];else if(r=this.rules.link.exec(t)){var c=x(r[2],"()");if(c>-1){var h=4+r[1].length+c;r[2]=r[2].substring(0,c),r[0]=r[0].substring(0,h).trim(),r[3]=""}t=t.substring(r[0].length),this.inLink=!0,n=r[2],this.options.pedantic?(e=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(n))?(n=e[1],s=e[3]):s="":s=r[3]?r[3].slice(1,-1):"",n=n.trim().replace(/^<([\s\S]*)>$/,"$1"),l+=this.outputLink(r,{href:a.escapes(n),title:a.escapes(s)}),this.inLink=!1}else if((r=this.rules.reflink.exec(t))||(r=this.rules.nolink.exec(t))){if(t=t.substring(r[0].length),e=(r[2]||r[1]).replace(/\s+/g," "),!(e=this.links[e.toLowerCase()])||!e.href){l+=r[0].charAt(0),t=r[0].substring(1)+t;continue}this.inLink=!0,l+=this.outputLink(r,e),this.inLink=!1}else if(r=this.rules.strong.exec(t))t=t.substring(r[0].length),l+=this.renderer.strong(this.output(r[4]||r[3]||r[2]||r[1]));else if(r=this.rules.em.exec(t))t=t.substring(r[0].length),l+=this.renderer.em(this.output(r[6]||r[5]||r[4]||r[3]||r[2]||r[1]));else if(r=this.rules.code.exec(t))t=t.substring(r[0].length),l+=this.renderer.codespan(d(r[2].trim(),!0));else if(r=this.rules.br.exec(t))t=t.substring(r[0].length),l+=this.renderer.br();else if(r=this.rules.del.exec(t))t=t.substring(r[0].length),l+=this.renderer.del(this.output(r[1]));else if(r=this.rules.autolink.exec(t))t=t.substring(r[0].length),n="@"===r[2]?"mailto:"+(i=d(this.mangle(r[1]))):i=d(r[1]),l+=this.renderer.link(n,null,i);else if(this.inLink||!(r=this.rules.url.exec(t))){if(r=this.rules.text.exec(t))t=t.substring(r[0].length),this.inRawBlock?l+=this.renderer.text(this.options.sanitize?this.options.sanitizer?this.options.sanitizer(r[0]):d(r[0]):r[0]):l+=this.renderer.text(d(this.smartypants(r[0])));else if(t)throw new Error("Infinite loop on byte: "+t.charCodeAt(0))}else{if("@"===r[2])n="mailto:"+(i=d(r[0]));else{do{o=r[0],r[0]=this.rules._backpedal.exec(r[0])[0]}while(o!==r[0]);i=d(r[0]),n="www."===r[1]?"http://"+i:i}t=t.substring(r[0].length),l+=this.renderer.link(n,null,i)}return l},a.escapes=function(t){return t?t.replace(a.rules._escapes,"$1"):t},a.prototype.outputLink=function(t,e){var i=e.href,n=e.title?d(e.title):null;return"!"!==t[0].charAt(0)?this.renderer.link(i,n,this.output(t[1])):this.renderer.image(i,n,d(t[1]))},a.prototype.smartypants=function(t){return this.options.smartypants?t.replace(/---/g,"—").replace(/--/g,"–").replace(/(^|[-\u2014/(\[{"\s])'/g,"$1‘").replace(/'/g,"’").replace(/(^|[-\u2014/(\[{\u2018\s])"/g,"$1“").replace(/"/g,"”").replace(/\.{3}/g,"…"):t},a.prototype.mangle=function(t){if(!this.options.mangle)return t;for(var e,i="",n=t.length,s=0;s<n;s++)e=t.charCodeAt(s),Math.random()>.5&&(e="x"+e.toString(16)),i+="&#"+e+";";return i},r.prototype.code=function(t,e,i){var n=(e||"").match(/\S*/)[0];if(this.options.highlight){var s=this.options.highlight(t,n);null!=s&&s!==t&&(i=!0,t=s)}return n?'<pre><code class="'+this.options.langPrefix+d(n,!0)+'">'+(i?t:d(t,!0))+"</code></pre>\n":"<pre><code>"+(i?t:d(t,!0))+"</code></pre>"},r.prototype.blockquote=function(t){return"<blockquote>\n"+t+"</blockquote>\n"},r.prototype.html=function(t){return t},r.prototype.heading=function(t,e,i,n){return this.options.headerIds?"<h"+e+' id="'+this.options.headerPrefix+n.slug(i)+'">'+t+"</h"+e+">\n":"<h"+e+">"+t+"</h"+e+">\n"},r.prototype.hr=function(){return this.options.xhtml?"<hr/>\n":"<hr>\n"},r.prototype.list=function(t,e,i){var n=e?"ol":"ul";return"<"+n+(e&&1!==i?' start="'+i+'"':"")+">\n"+t+"</"+n+">\n"},r.prototype.listitem=function(t){return"<li>"+t+"</li>\n"},r.prototype.checkbox=function(t){return"<input "+(t?'checked="" ':"")+'disabled="" type="checkbox"'+(this.options.xhtml?" /":"")+"> "},r.prototype.paragraph=function(t){return"<p>"+t+"</p>\n"},r.prototype.table=function(t,e){return e&&(e="<tbody>"+e+"</tbody>"),"<table>\n<thead>\n"+t+"</thead>\n"+e+"</table>\n"},r.prototype.tablerow=function(t){return"<tr>\n"+t+"</tr>\n"},r.prototype.tablecell=function(t,e){var i=e.header?"th":"td";return(e.align?"<"+i+' align="'+e.align+'">':"<"+i+">")+t+"</"+i+">\n"},r.prototype.strong=function(t){return"<strong>"+t+"</strong>"},r.prototype.em=function(t){return"<em>"+t+"</em>"},r.prototype.codespan=function(t){return"<code>"+t+"</code>"},r.prototype.br=function(){return this.options.xhtml?"<br/>":"<br>"},r.prototype.del=function(t){return"<del>"+t+"</del>"},r.prototype.link=function(t,e,i){if(null===(t=u(this.options.sanitize,this.options.baseUrl,t)))return i;var n='<a href="'+d(t)+'"';return e&&(n+=' title="'+e+'"'),n+=">"+i+"</a>"},r.prototype.image=function(t,e,i){if(null===(t=u(this.options.sanitize,this.options.baseUrl,t)))return i;var n='<img src="'+t+'" alt="'+i+'"';return e&&(n+=' title="'+e+'"'),n+=this.options.xhtml?"/>":">"},r.prototype.text=function(t){return t},o.prototype.strong=o.prototype.em=o.prototype.codespan=o.prototype.del=o.prototype.text=function(t){return t},o.prototype.link=o.prototype.image=function(t,e,i){return""+i},o.prototype.br=function(){return""},l.parse=function(t,e){return new l(e).parse(t)},l.prototype.parse=function(t){this.inline=new a(t.links,this.options),this.inlineText=new a(t.links,k({},this.options,{renderer:new o})),this.tokens=t.reverse();for(var e="";this.next();)e+=this.tok();return e},l.prototype.next=function(){return this.token=this.tokens.pop(),this.token},l.prototype.peek=function(){return this.tokens[this.tokens.length-1]||0},l.prototype.parseText=function(){for(var t=this.token.text;"text"===this.peek().type;)t+="\n"+this.next().text;return this.inline.output(t)},l.prototype.tok=function(){switch(this.token.type){case"space":return"";case"hr":return this.renderer.hr();case"heading":return this.renderer.heading(this.inline.output(this.token.text),this.token.depth,h(this.inlineText.output(this.token.text)),this.slugger);case"code":return this.renderer.code(this.token.text,this.token.lang,this.token.escaped);case"table":var t,e,i,n,s="",a="";for(i="",t=0;t<this.token.header.length;t++)i+=this.renderer.tablecell(this.inline.output(this.token.header[t]),{header:!0,align:this.token.align[t]});for(s+=this.renderer.tablerow(i),t=0;t<this.token.cells.length;t++){for(e=this.token.cells[t],i="",n=0;n<e.length;n++)i+=this.renderer.tablecell(this.inline.output(e[n]),{header:!1,align:this.token.align[n]});a+=this.renderer.tablerow(i)}return this.renderer.table(s,a);case"blockquote_start":for(a="";"blockquote_end"!==this.next().type;)a+=this.tok();return this.renderer.blockquote(a);case"list_start":a="";for(var r=this.token.ordered,o=this.token.start;"list_end"!==this.next().type;)a+=this.tok();return this.renderer.list(a,r,o);case"list_item_start":a="";var l=this.token.loose,c=this.token.checked,d=this.token.task;for(this.token.task&&(a+=this.renderer.checkbox(c));"list_item_end"!==this.next().type;)a+=l||"text"!==this.token.type?this.tok():this.parseText();return this.renderer.listitem(a,d,c);case"html":return this.renderer.html(this.token.text);case"paragraph":return this.renderer.paragraph(this.inline.output(this.token.text));case"text":return this.renderer.paragraph(this.parseText());default:var p='Token with "'+this.token.type+'" type was not found.';if(!this.options.silent)throw new Error(p);console.log(p)}},c.prototype.slug=function(t){var e=t.toLowerCase().trim().replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g,"").replace(/\s/g,"-");if(this.seen.hasOwnProperty(e)){var i=e;do{this.seen[i]++,e=i+"-"+this.seen[i]}while(this.seen.hasOwnProperty(e))}return this.seen[e]=0,e},d.escapeTest=/[&<>"']/,d.escapeReplace=/[&<>"']/g,d.replacements={"&":"&","<":"<",">":">",'"':""","'":"'"},d.escapeTestNoEncode=/[<>"']|&(?!#?\w+;)/,d.escapeReplaceNoEncode=/[<>"']|&(?!#?\w+;)/g;var m={},g=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function f(){}function k(t){for(var e,i,n=1;n<arguments.length;n++)for(i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}function y(t,e){var i=t.replace(/\|/g,(function(t,e,i){for(var n=!1,s=e;--s>=0&&"\\"===i[s];)n=!n;return n?"|":" |"})).split(/ \|/),n=0;if(i.length>e)i.splice(e);else for(;i.length<e;)i.push("");for(;n<i.length;n++)i[n]=i[n].trim().replace(/\\\|/g,"|");return i}function v(t,e,i){if(0===t.length)return"";for(var n=0;n<t.length;){var s=t.charAt(t.length-n-1);if(s!==e||i){if(s===e||!i)break;n++}else n++}return t.substr(0,t.length-n)}function x(t,e){if(-1===t.indexOf(e[1]))return-1;for(var i=0,n=0;n<t.length;n++)if("\\"===t[n])n++;else if(t[n]===e[0])i++;else if(t[n]===e[1]&&--i<0)return n;return-1}function E(t){t&&t.sanitize&&!t.silent&&console.warn("marked(): sanitize and sanitizer parameters are deprecated since version 0.7.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/#/USING_ADVANCED.md#options")}function b(t,e,i){if(null==t)throw new Error("marked(): input parameter is undefined or null");if("string"!=typeof t)throw new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected");if(i||"function"==typeof e){i||(i=e,e=null),E(e=k({},b.defaults,e||{}));var s,a,r=e.highlight,o=0;try{s=n.lex(t,e)}catch(h){return i(h)}a=s.length;var c=function(t){if(t)return e.highlight=r,i(t);var n;try{n=l.parse(s,e)}catch(h){t=h}return e.highlight=r,t?i(t):i(null,n)};if(!r||r.length<3)return c();if(delete e.highlight,!a)return c();for(;o<s.length;o++)!function(t){"code"!==t.type?--a||c():r(t.text,t.lang,(function(e,i){return e?c(e):null==i||i===t.text?--a||c():(t.text=i,t.escaped=!0,void(--a||c()))}))}(s[o])}else try{return e&&(e=k({},b.defaults,e)),E(e),l.parse(n.lex(t,e),e)}catch(h){if(h.message+="\nPlease report this to https://github.com/markedjs/marked.",(e||b.defaults).silent)return"<p>An error occurred:</p><pre>"+d(h.message+"",!0)+"</pre>";throw h}}f.exec=f,b.options=b.setOptions=function(t){return k(b.defaults,t),b},b.getDefaults=function(){return{baseUrl:null,breaks:!1,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:new r,sanitize:!1,sanitizer:null,silent:!1,smartLists:!1,smartypants:!1,xhtml:!1}},b.defaults=b.getDefaults(),b.Parser=l,b.parser=l.parse,b.Renderer=r,b.TextRenderer=o,b.Lexer=n,b.lexer=n.lex,b.InlineLexer=a,b.inlineLexer=a.output,b.Slugger=c,b.parse=b,t.exports=b}()}(t);var e=t.exports,i={exports:{}};!function(t,e){t.exports=function(){function t(t,e){return t(e={exports:{}},e.exports),e.exports}var e=t((function(t){var e=t.exports=function(){return new RegExp("(?:"+e.line().source+")|(?:"+e.block().source+")","gm")};e.line=function(){return/(?:^|\s)\/\/(.+?)$/gm},e.block=function(){return/\/\*([\S\s]*?)\*\//gm}})),i=["23AC69","91C132","F19726","E8552D","1AAB8E","E1147F","2980C1","1BA1E6","9FA0A0","F19726","E30B20","E30B20","A3338B"];function n(t){return'<span style="color: slategray">'+t+"</span>"}return function(t,s){void 0===s&&(s={});var a=s.colors;void 0===a&&(a=i);var r=0,o={},l=new RegExp("("+/[\u4E00-\u9FFF\u3400-\u4dbf\uf900-\ufaff\u3040-\u309f\uac00-\ud7af\u0400-\u04FF]+|\w+/.source+"|"+/</.source+")|("+e().source+")","gmi");return t.replace(l,(function(t,e,i){if(i)return n(i);if("<"===e)return"<";var s;o[e]?s=o[e]:(s=a[r],o[e]=s);var l='<span style="color: #'+s+'">'+e+"</span>";return r=++r%a.length,l}))}}()}(i);var n=i.exports;function s(t=""){const e=document.createElement("div");return e.innerHTML=t.trim(),e.firstElementChild||e}function a(t){const e=RegExp(`[?&]${t}=([^&]*)`).exec(window.location.search);return e&&decodeURIComponent(e[1].replace(/\+/g," "))}function r(t){const e=t.getBoundingClientRect();return{top:e.top+window.scrollY,left:e.left+window.scrollX}}function o(t,e){let i=t.toString();for(;i.length<e;)i=`0${i}`;return i}function l(t){try{const e=t.getTime(),i=(new Date).getTime()-e,n=Math.floor(i/864e5);if(0===n){const t=i%864e5,e=Math.floor(t/36e5);if(0===e){const e=t%36e5,i=Math.floor(e/6e4);if(0===i){const t=e%6e4;return`${Math.round(t/1e3)} 秒前`}return`${i} 分钟前`}return`${e} 小时前`}return n<0?"刚刚":n<8?`${n} 天前`:function(t){const e=o(t.getDate(),2),i=o(t.getMonth()+1,2);return`${o(t.getFullYear(),2)}-${i}-${e}`}(t)}catch(e){return console.error(e)," - "}}let c=null;function d(t,i){if(!c){const t=new e.Renderer,i=t.link;t.link=(e,n,s)=>i.call(t,e,n,s).replace(/^<a /,'<a target="_blank" rel="nofollow" ');const s=e;s.setOptions({renderer:t,highlight:t=>n(t),pedantic:!1,gfm:!0,tables:!0,breaks:!0,sanitize:!0,smartLists:!0,smartypants:!0,xhtml:!1}),c=s}return c(i)}class h{data;constructor(t){const e=JSON.parse(window.localStorage.getItem("ArtalkUser")||"{}");this.data={nick:e.nick||"",email:e.email||"",link:e.link||"",token:e.token||"",isAdmin:e.isAdmin||!1}}save(){window.localStorage.setItem("ArtalkUser",JSON.stringify(this.data))}checkHasBasicUserInfo(){return!!this.data.nick&&!!this.data.email}}class p{cid;rootEl;conf;user;eventList=[];constructor(t,e){this.cid=+new Date,this.rootEl=t,this.conf=e,this.user=new h(this.conf)}addEventListener(t,e){this.eventList.push({name:t,listener:e})}removeEventListener(t){this.eventList=this.eventList.filter((e=>e.name!==t))}dispatchEvent(t,e){this.eventList.filter((e=>e.name===t)).map((t=>t.listener)).forEach((t=>t(e)))}}function u(t){t instanceof p&&(t=t.rootEl);let e=t.querySelector(".atk-loading");e||(e=s('\n <div class="atk-loading" style="display: none;">\n <div class="atk-loading-spinner">\n <svg viewBox="25 25 50 50"><circle cx="50" cy="50" r="20" fill="none" stroke-width="2" stroke-miterlimit="10"></circle></svg>\n </div>\n </div>'),t.appendChild(e)),e.style.display=""}function m(t){t instanceof p&&(t=t.rootEl);const e=t.querySelector(".atk-loading");e&&(e.style.display="none")}function g(t){const e=window.scrollY,i=e+document.documentElement.clientHeight,n=r(t).top;return n+t.offsetHeight<=i&&n>=e}function f(t,e=!0){if(g(t))return;const i=r(t).top+parseFloat(getComputedStyle(t,null).height.replace("px",""))/2-document.documentElement.clientHeight/2;e?window.scroll({top:i>0?i:0,left:0,behavior:"smooth"}):window.scroll(0,i>0?i:0)}function k(t,e,i){const n=s(`<div class="atk-notify atk-fade-in" style="background-color: ${{s:"#57d59f",e:"#ff6f6c",w:"#ffc721",i:"#2ebcfc"}[i]}"><span class="atk-notify-content"></span></div>`);n.querySelector(".atk-notify-content").innerHTML=function(t){const e=document.createElement("div");return e.innerText=t,e.innerHTML}(e).replace("\n","<br/>"),t.appendChild(n);const a=()=>{n.classList.add("atk-fade-out"),setTimeout((()=>{n.remove()}),200)};let r;r=window.setTimeout((()=>{a()}),3e3),n.addEventListener("click",(()=>{a(),window.clearTimeout(r)}))}function y(t,e){!function(t,e,i="in"){t.classList.add(`atk-fade-${i}`);const n=()=>{t.classList.remove(`atk-fade-${i}`),t.removeEventListener("animationend",n),e&&e()};t.addEventListener("animationend",n)}(t,e,"in")}function v(t,e){t instanceof p&&(t=t.rootEl);let i=t.querySelector(".atk-error-layer");if(null===e)return void(null!==i&&i.remove());i||(i=s('<div class="atk-error-layer"><span class="atk-error-title">Artalk Error</span><span class="atk-error-text"></span></div>'),t.appendChild(i));const n=i.querySelector(".atk-error-text");n.innerHTML="",null!==e&&(e instanceof HTMLElement?n.appendChild(e):n.innerText=e)}class x{el;ctx;conf;constructor(t){this.ctx=t,this.conf=t.conf}}const E="atk-dark-mode";function b(t){let e=document.querySelector(`.atk-layer-wrap#ctx-${t.cid}`);e||(e=s(`<div class="atk-layer-wrap" id="ctx-${t.cid}" style="display: none;"><div class="atk-layer-mask"></div></div>`),document.body.appendChild(e));const i=e.querySelector(".atk-layer-mask");return e&&(t.conf.darkMode?e.classList.add(E):e.classList.remove(E)),{wrapEl:e,maskEl:i}}function w(t,e,i){return new S(t,e,i)}class S extends x{name;wrapEl;maskEl;maskClickHideEnable=!0;constructor(t,e,i){super(t),this.name=e;const{wrapEl:n,maskEl:a}=b(t);this.wrapEl=n,this.maskEl=a,this.el=this.wrapEl.querySelector(`[data-layer-name="${e}"].atk-layer-item`),null===this.el&&(i?this.el=i:(this.el=s(),this.el.classList.add("atk-layer-item"))),this.el.setAttribute("data-layer-name",e),this.el.style.display="none",this.wrapEl.append(this.el)}getName(){return this.name}getWrapEl(){return this.wrapEl}getEl(){return this.el}static hideTimeoutList=[];show(){S.hideTimeoutList.forEach((t=>{clearTimeout(t)})),S.hideTimeoutList=[],this.wrapEl.style.display="block",this.maskEl.style.display="block",this.maskEl.classList.add("atk-fade-in"),this.el.style.display="",this.maskEl.onclick=()=>{this.maskClickHideEnable&&this.hide()},document.body.style.overflow="hidden"}hide(){S.hideTimeoutList.push(window.setTimeout((()=>{this.wrapEl.style.display="none",document.body.style.overflow=""}),450)),this.wrapEl.classList.add("atk-fade-out"),S.hideTimeoutList.push(window.setTimeout((()=>{this.wrapEl.style.display="none",this.wrapEl.classList.remove("atk-fade-out")}),200)),this.el.style.display="none"}setMaskClickHide(t){this.maskClickHideEnable=t}disposeNow(){document.body.style.overflow="",this.el.remove(),this.checkCleanLayer()}dispose(){this.hide(),this.el.remove(),this.checkCleanLayer()}checkCleanLayer(){0===this.getWrapEl().querySelectorAll(".atk-layer-item").length&&(this.wrapEl.style.display="none")}}class L{ctx;serverURL;constructor(t){this.ctx=t,this.serverURL=t.conf.server}get(t,e,i){const n={page_key:this.ctx.conf.pageKey,limit:this.ctx.conf.readMore?.pageSize||15,offset:t};return e&&(n.type=e),this.ctx.user.checkHasBasicUserInfo()&&(n.name=this.ctx.user.data.nick,n.email=this.ctx.user.data.email),this.ctx.conf.site&&(n.site_name=this.ctx.conf.site),i&&i(n),_(this.ctx,`${this.serverURL}/get`,{method:"POST",body:$(n)}).then((t=>t.data))}add(t){const e={name:t.nick,email:t.email,link:t.link,content:t.content,rid:t.rid,page_key:this.ctx.conf.pageKey,page_url:this.ctx.conf.pageUrl||"",page_title:this.ctx.conf.pageTitle||""};return this.ctx.conf.site&&(e.site_name=this.ctx.conf.site),_(this.ctx,`${this.serverURL}/add`,{method:"POST",body:$(e)}).then((t=>t.data.comment))}login(t,e,i){const n={name:t,email:e,password:i};return this.ctx.conf.site&&(n.site_name=this.ctx.conf.site),_(this.ctx,`${this.serverURL}/login`,{method:"POST",body:$(n)}).then((t=>t.data.token))}userGet(t,e){const i=new AbortController,{signal:n}=i,s={name:t,email:e};this.ctx.conf.site&&(s.site_name=this.ctx.conf.site);return{req:_(this.ctx,`${this.serverURL}/user-get`,{method:"POST",body:$(s),signal:n}).then((t=>({user:t.data.user,is_login:t.data.is_login,unread:t.data.unread||[],unread_count:t.data.unread_count||0}))),abort:()=>{i.abort()}}}vote(t,e){const i={target_id:t,type:e};return this.ctx.user.checkHasBasicUserInfo()&&(i.name=this.ctx.user.data.nick,i.email=this.ctx.user.data.email),this.ctx.conf.site&&(i.site_name=this.ctx.conf.site),_(this.ctx,`${this.serverURL}/vote`,{method:"POST",body:$(i)}).then((t=>t.data?.vote_num||0))}markRead(t,e=!1){const i={notify_key:t};return e&&(delete i.notify_key,i.read_all=!0,i.name=this.ctx.user.data.nick,i.email=this.ctx.user.data.email),this.ctx.conf.site&&(i.site_name=this.ctx.conf.site),_(this.ctx,`${this.serverURL}/mark-read`,{method:"POST",body:$(i)}).then((t=>t.success))}captchaGet(){return _(this.ctx,`${this.serverURL}/captcha/refresh`,{method:"GET"}).then((t=>t.success&&t.data.img_data?t.data.img_data:""))}captchaCheck(t){return _(this.ctx,`${this.serverURL}/captcha/check?${new URLSearchParams({value:t})}`,{method:"GET"}).then((t=>!t.success&&t.data.img_data?t.data.img_data:""))}commentEdit(t){const e={...t};return void 0!==e.is_collapsed&&(e.is_collapsed=e.is_collapsed?"1":"0"),void 0!==e.is_pending&&(e.is_pending=e.is_pending?"1":"0"),this.ctx.conf.site&&(e.site_name=this.ctx.conf.site),_(this.ctx,`${this.serverURL}/admin/comment-edit`,{method:"POST",body:$(e)}).then((t=>t.data.comment))}pageEdit(t){const e={id:t.id,key:t.key,title:t.title,admin_only:t.admin_only?"1":"0"};return this.ctx.conf.site&&(e.site_name=this.ctx.conf.site),_(this.ctx,`${this.serverURL}/admin/page-edit`,{method:"POST",body:$(e)}).then((t=>t.data.page))}pageFetch(t){const e={id:t};return _(this.ctx,`${this.serverURL}/admin/page-fetch`,{method:"POST",body:$(e)}).then((t=>t.data.page))}siteGet(){return _(this.ctx,`${this.serverURL}/admin/site-get`,{method:"POST",body:$({})}).then((t=>t.data.sites))}pageGet(t){const e={site_name:t||""};return _(this.ctx,`${this.serverURL}/admin/page-get`,{method:"POST",body:$(e)}).then((t=>t.data.pages))}pageDel(t,e){const i={key:String(t),site_name:e||""};return _(this.ctx,`${this.serverURL}/admin/page-del`,{method:"POST",body:$(i)}).then((t=>t.success))}siteDel(t,e=!1){const i={id:t,del_content:e?"1":"0"};return _(this.ctx,`${this.serverURL}/admin/site-del`,{method:"POST",body:$(i)}).then((t=>t.success))}siteAdd(t,e){const i={name:t,urls:e};return _(this.ctx,`${this.serverURL}/admin/site-add`,{method:"POST",body:$(i)}).then((t=>t.site))}siteEdit(t,e){const i={id:t,name:e.name,urls:e.urls};return _(this.ctx,`${this.serverURL}/admin/site-edit`,{method:"POST",body:$(i)}).then((t=>t.site))}commentDel(t,e){const i={id:String(t),site_name:e||""};return _(this.ctx,`${this.serverURL}/admin/comment-del`,{method:"POST",body:$(i)}).then((t=>t.success))}}function _(t,e,i){if(t.user.data.token){const e=new Headers;e.set("Authorization",`Bearer ${t.user.data.token}`),i.headers=e}return(n=15e3,s=fetch(e,i),new Promise(((t,e)=>{const i=setTimeout((()=>{e(new Error("请求超时"))}),n);s.then((e=>{clearTimeout(i),t(e)}),(t=>{clearTimeout(i),e(t)}))}))).then((async n=>{if(!n.ok&&401!==n.status)throw new Error(`请求响应 ${n.status}`);let s=await n.json();const a=(n,s)=>{_(t,e,i).then((t=>{n(t)})).catch((t=>{s(t)}))};if(s.data&&s.data.need_captcha?s=await new Promise(((e,i)=>{t.dispatchEvent("checker-captcha",{imgData:s.data.img_data,onSuccess:()=>{a(e,i)},onCancel:()=>{i(s)}})})):(s.data&&s.data.need_login||401===n.status)&&(s=await new Promise(((e,i)=>{t.dispatchEvent("checker-admin",{onSuccess:()=>{a(e,i)},onCancel:()=>{i(s)}})}))),s.success)return s;throw s})).catch((t=>{if(console.error(t),t instanceof TypeError)throw new Error("网络错误");throw t}));var n,s}function $(t){const e=new FormData;return Object.keys(t).forEach((i=>e.append(i,String(t[i])))),e}const T={request:(t,e)=>{const i={name:t.user.data.nick,email:t.user.data.email,password:e};return new L(t.ctx).login(i.name,i.email,i.password)},body:()=>s("<span>敲入密码来验证管理员身份:</span>"),onSuccess:(t,e,i,n)=>{t.user.data.isAdmin=!0,t.user.data.token=e,t.user.save(),t.ctx.dispatchEvent("user-changed"),t.ctx.dispatchEvent("list-reload")},onError:(t,e,i,n)=>{}},C={request:(t,e)=>new L(t.ctx).captchaCheck(e),body:t=>{const e=s(`<span><img class="atk-captcha-img" src="${t.submitCaptchaImgData||""}" alt="验证码">敲入验证码继续:</span>`);return e.querySelector(".atk-captcha-img").onclick=()=>{const i=e.querySelector(".atk-captcha-img");new L(t.ctx).captchaGet().then((t=>{i.setAttribute("src",t)})).catch((t=>{console.error("验证码获取失败 ",t)}))},e},onSuccess:(t,e,i,n,s)=>{t.submitCaptchaVal=n},onError:(t,e,i,n)=>{n.querySelector(".atk-captcha-img").click()}};class A{ctx;user;submitCaptchaVal;submitCaptchaImgData;constructor(t){this.ctx=t,this.user=t.user,this.ctx.addEventListener("checker-captcha",(t=>{t.imgData&&(this.submitCaptchaImgData=t.imgData),this.check("captcha",t)})),this.ctx.addEventListener("checker-admin",(t=>{this.check("admin",t)}))}check(t,e){const i={admin:T,captcha:C}[t],n=w(this.ctx,`checker-${(new Date).getTime()}`);n.setMaskClickHide(!1),n.show();const a=s();a.appendChild(i.body(this));const r=s(`<input id="check" type="${"admin"===t?"password":"text"}" required placeholder="">`);let o;a.appendChild(r),setTimeout((()=>{r.focus()}),80),r.onkeyup=t=>{"Enter"!==t.key&&13!==t.keyCode||(t.preventDefault(),n.getEl().querySelector('button[data-action="confirm"]').click())};const l=function(t,e,i){const n=s('<div class="atk-layer-dialog-wrap">\n <div class="atk-layer-dialog">\n <div class="atk-layer-dialog-content"></div>\n <div class="atk-layer-dialog-action">\n </div>'),a=n.querySelector(".atk-layer-dialog-action"),r=t=>e=>{const i=t(e.currentTarget);void 0!==i&&!0!==i||n.remove()};if("function"==typeof e){const t=s('<button data-action="confirm">确定</button>');t.onclick=r(e),a.appendChild(t)}if("function"==typeof i){const t=s('<button data-action="cancel">取消</button>');t.onclick=r(i),a.appendChild(t)}return n.querySelector(".atk-layer-dialog-content").appendChild(t),n}(a,(t=>{const s=r.value.trim();o||(o=t.innerText);const c=()=>{t.innerText=o||"",t.classList.remove("error")};return t.innerText="加载中...",i.request(this,s).then((t=>{n.disposeNow(),i.onSuccess&&i.onSuccess(this,t,s,a),e.onSuccess&&e.onSuccess(s,l)})).catch((e=>{var n;n=String(e.msg||String(e)),t.innerText=n,t.classList.add("error"),i.onError&&i.onError(this,e,s,a);const o=setTimeout((()=>{c()}),3e3);r.onfocus=()=>{c(),clearTimeout(o)}})),!1}),(()=>(n.disposeNow(),e.onCancel&&e.onCancel(),!1)));n.getEl().append(l),e.onMount&&e.onMount(l)}}class O{editor;ctx;el;constructor(t){this.editor=t,this.ctx=t.ctx}}class q extends O{constructor(t){super(t),this.editor=t,this.emoticons=this.ctx.conf.emoticons,this.initEl()}el;emoticons;listWrapEl;typesEl;initEl(){this.el=s('<div class="atk-editor-plug-emoticons"></div>'),this.listWrapEl=s('<div class="atk-emoticons-list-wrap"></div>'),this.el.append(this.listWrapEl),Object.entries(this.emoticons).forEach((([t,e])=>{const i=s('<div class="atk-emoticons-list" style="display: none;"></div>');this.listWrapEl.append(i),i.setAttribute("data-key",t),i.setAttribute("data-input-type",e.inputType),Object.entries(e.container).forEach((([t,n])=>{const a=s('<span class="atk-emoticons-item"></span>');if(i.append(a),a.setAttribute("title",t),a.setAttribute("data-content",n),"image"===e.inputType){const e=document.createElement("img");e.src=n,e.alt=t,a.append(e)}else a.innerText=n}))})),this.typesEl=s('<div class="atk-emoticons-types"></div>'),this.el.append(this.typesEl),Object.entries(this.emoticons).forEach((([t,e])=>{const i=s("<span />");this.typesEl.append(i),i.setAttribute("data-key",t),i.innerText=t})),this.typesEl.querySelectorAll("span").forEach((t=>{t.addEventListener("click",(t=>{const e=t.currentTarget.getAttribute("data-key");e&&this.openType(e)}))})),Object.keys(this.emoticons).length>0&&this.openType(Object.keys(this.emoticons)[0]),this.listWrapEl.querySelectorAll(".atk-emoticons-item").forEach((t=>{t.onclick=t=>{const e=t.currentTarget,i=e.closest(".atk-emoticons-list").getAttribute("data-input-type"),n=e.getAttribute("title"),s=e.getAttribute("data-content");"image"===i?this.editor.insertContent(`:[${n}]`):this.editor.insertContent(s||"")}}))}openType(t){Array.from(this.listWrapEl.children).forEach((e=>{const i=e;i.getAttribute("data-key")!==t?i.style.display="none":i.style.display=""})),this.typesEl.querySelectorAll("span.active").forEach((t=>t.classList.remove("active"))),this.typesEl.querySelector(`span[data-key="${t}"]`)?.classList.add("active"),this.changeListHeight()}getName(){return"emoticons"}getBtnHtml(){return"表情"}getEl(){return this.el}changeListHeight(){}onShow(){setTimeout((()=>{this.changeListHeight()}),30)}onHide(){this.el.parentElement.style.height=""}transEmoticonImageText(t){return Object.entries(this.emoticons).forEach((([e,i])=>{"image"===i.inputType&&Object.entries(i.container).forEach((([e,i])=>{t=t.split(`:[${e}]`).join(` `)}))})),t}}class M extends O{el;binded=!1;constructor(t){super(t),this.initEl()}initEl(){this.el=s('<div class="atk-editor-plug-preview"></div>'),this.binded=!1}getName(){return"preview"}getBtnHtml(){return'预览 <i title="Markdown is supported"><svg class="markdown" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M14.85 3H1.15C.52 3 0 3.52 0 4.15v7.69C0 12.48.52 13 1.15 13h13.69c.64 0 1.15-.52 1.15-1.15v-7.7C16 3.52 15.48 3 14.85 3zM9 11H7V8L5.5 9.92 4 8v3H2V5h2l1.5 2L7 5h2v6zm2.99.5L9.5 8H11V5h2v3h1.5l-2.51 3.5z"></path></svg></i>'}getEl(){return this.el}onShow(){if(this.updateContent(),!this.binded){const t=()=>{this.updateContent()};this.editor.textareaEl.addEventListener("input",t),this.editor.textareaEl.addEventListener("change",t),this.binded=!0}}onHide(){}updateContent(){"none"!==this.el.style.display&&(this.el.innerHTML=this.editor.getContentMarked())}}class B extends x{LOADABLE_PLUG_LIST=[q,M];plugList={};el;headerEl;textareaWrapEl;textareaEl;closeCommentEl;plugWrapEl;bottomEl;bottomPartLeftEl;plugSwitcherWrapEl;bottomPartRightEl;submitBtn;notifyWrapEl;replyComment=null;sendReplyEl=null;get user(){return this.ctx.user}constructor(t){super(t),this.el=s('<div class="atk-editor">\n <div class="atk-editor-header">\n <input name="nick" placeholder="昵称" class="atk-nick" type="text" required="required">\n <input name="email" placeholder="邮箱" class="atk-email" type="email" required="required">\n <input name="link" placeholder="网址 (https://)" class="atk-link" type="url">\n </div>\n <div class="atk-editor-textarea-wrap">\n <div class="atk-close-comment" style="display: none;"><span>仅管理员可评论</span></div>\n <textarea id="atk-editor-textarea" class="atk-editor-textarea" placeholder=""></textarea>\n </div>\n <div class="atk-editor-plug-wrap" style="display: none;"></div>\n <div class="atk-editor-bottom">\n <div class="atk-editor-bottom-part atk-left atk-editor-plug-switcher-wrap"></div>\n <div class="atk-editor-bottom-part atk-right">\n <button type="button" class="atk-send-btn"></button>\n </div>\n </div>\n <div class="atk-editor-notify-wrap"></div>\n</div>\n'),this.headerEl=this.el.querySelector(".atk-editor-header"),this.textareaWrapEl=this.el.querySelector(".atk-editor-textarea-wrap"),this.textareaEl=this.el.querySelector(".atk-editor-textarea"),this.closeCommentEl=this.el.querySelector(".atk-close-comment"),this.plugWrapEl=this.el.querySelector(".atk-editor-plug-wrap"),this.bottomEl=this.el.querySelector(".atk-editor-bottom"),this.bottomPartLeftEl=this.el.querySelector(".atk-editor-bottom-part.atk-left"),this.plugSwitcherWrapEl=this.el.querySelector(".atk-editor-plug-switcher-wrap"),this.bottomPartRightEl=this.el.querySelector(".atk-editor-bottom-part.atk-right"),this.submitBtn=this.el.querySelector(".atk-send-btn"),this.notifyWrapEl=this.el.querySelector(".atk-editor-notify-wrap"),this.initLocalStorage(),this.initHeader(),this.initTextarea(),this.initEditorPlug(),this.initBottomPart(),this.ctx.addEventListener("editor-open-comment",(()=>this.openComment())),this.ctx.addEventListener("editor-close-comment",(()=>this.closeComment())),this.ctx.addEventListener("editor-reply",(t=>this.setReply(t))),this.ctx.addEventListener("editor-show-loading",(()=>u(this.el))),this.ctx.addEventListener("editor-hide-loading",(()=>m(this.el))),this.ctx.addEventListener("editor-notify",(t=>this.showNotify(t.msg,t.type)))}initLocalStorage(){const t=window.localStorage.getItem("ArtalkContent")||"";""!==t.trim()&&(this.showNotify("已自动恢复","i"),this.setContent(t)),this.textareaEl.addEventListener("input",(()=>{this.saveContent()}))}initHeader(){Object.keys(this.user.data).forEach((t=>{const e=this.getInputEl(t);e&&e instanceof HTMLInputElement&&(e.value=this.user.data[t]||"",e.addEventListener("input",(()=>this.onHeaderInputChanged(t,e))))}))}getInputEl(t){return this.headerEl.querySelector(`[name="${t}"]`)}queryUserInfo={timeout:null,abortFunc:null};onHeaderInputChanged(t,e){this.user.data[t]=e.value.trim(),"nick"!==t&&"email"!==t||(this.user.data.token="",this.user.data.isAdmin=!1,null!==this.queryUserInfo.timeout&&window.clearTimeout(this.queryUserInfo.timeout),null!==this.queryUserInfo.abortFunc&&this.queryUserInfo.abortFunc(),this.queryUserInfo.timeout=window.setTimeout((()=>{this.queryUserInfo.timeout=null;const{req:t,abort:e}=new L(this.ctx).userGet(this.user.data.nick,this.user.data.email);this.queryUserInfo.abortFunc=e,t.then((t=>{t.is_login||(this.user.data.token="",this.user.data.isAdmin=!1),this.ctx.dispatchEvent("unread-update",{notifies:t.unread}),this.user.checkHasBasicUserInfo()&&!t.is_login&&t.user&&t.user.is_admin&&this.showLoginDialog(),t.user&&t.user.link&&(this.user.data.link=t.user.link,this.getInputEl("link").value=t.user.link)})).finally((()=>{this.queryUserInfo.abortFunc=null}))}),400)),this.saveUser()}showLoginDialog(){this.ctx.dispatchEvent("checker-admin",{onSuccess:()=>{}})}saveUser(){this.user.save(),this.ctx.dispatchEvent("user-changed")}saveContent(){window.localStorage.setItem("ArtalkContent",this.getContentOriginal().trim())}initTextarea(){this.textareaEl.placeholder=this.ctx.conf.placeholder||"",this.textareaEl.addEventListener("keydown",(t=>{9===(t.keyCode||t.which)&&(t.preventDefault(),this.insertContent("\t"))})),this.textareaEl.addEventListener("input",(t=>{this.adjustTextareaHeight()}))}adjustTextareaHeight(){const t=this.textareaEl.offsetHeight-this.textareaEl.clientHeight;this.textareaEl.style.height="0px",this.textareaEl.style.height=`${this.textareaEl.scrollHeight+t}px`}openedPlugName=null;initEditorPlug(){this.plugList={},this.plugWrapEl.innerHTML="",this.plugWrapEl.style.display="none",this.openedPlugName=null,this.plugSwitcherWrapEl.innerHTML="",this.LOADABLE_PLUG_LIST.forEach((t=>{const e=new t(this);this.plugList[e.getName()]=e;const i=s(`<span class="atk-editor-action atk-editor-plug-switcher">${e.getBtnHtml()}</span>`);this.plugSwitcherWrapEl.appendChild(i),i.addEventListener("click",(()=>{if(this.plugSwitcherWrapEl.querySelectorAll(".active").forEach((t=>t.classList.remove("active"))),e.getName()===this.openedPlugName)return e.onHide(),this.plugWrapEl.style.display="none",void(this.openedPlugName=null);if(null===this.plugWrapEl.querySelector(`[data-plug-name="${e.getName()}"]`)){const t=e.getEl();t.setAttribute("data-plug-name",e.getName()),t.style.display="none",this.plugWrapEl.appendChild(t)}Array.from(this.plugWrapEl.children).forEach((t=>{const i=t.getAttribute("data-plug-name");i===e.getName()?(t.style.display="",this.plugList[i].onShow()):(t.style.display="none",this.plugList[i].onHide())})),this.plugWrapEl.style.display="",this.openedPlugName=e.getName(),i.classList.add("active")}))}))}closePlug(){this.plugWrapEl.innerHTML="",this.plugWrapEl.style.display="none",this.openedPlugName=null}insertContent(t){if(document.selection)this.textareaEl.focus(),document.selection.createRange().text=t,this.textareaEl.focus();else if(this.textareaEl.selectionStart||0===this.textareaEl.selectionStart){const e=this.textareaEl.selectionStart,i=this.textareaEl.selectionEnd,n=this.textareaEl.scrollTop;this.setContent(this.textareaEl.value.substring(0,e)+t+this.textareaEl.value.substring(i,this.textareaEl.value.length)),this.textareaEl.focus(),this.textareaEl.selectionStart=e+t.length,this.textareaEl.selectionEnd=e+t.length,this.textareaEl.scrollTop=n}else this.textareaEl.focus(),this.textareaEl.value+=t}setContent(t){this.textareaEl.value=t,this.saveContent(),this.plugList&&this.plugList.preview&&this.plugList.preview.updateContent(),this.adjustTextareaHeight()}clearEditor(){this.setContent(""),this.cancelReply()}getContent(){let t=this.getContentOriginal();if(this.plugList&&this.plugList.emoticons){t=this.plugList.emoticons.transEmoticonImageText(t)}return t}getContentOriginal(){return this.textareaEl.value||""}getContentMarked(){return d(this.ctx,this.getContent())}initBottomPart(){this.initReply(),this.initSubmit()}initReply(){this.replyComment=null,this.sendReplyEl=null}setReply(t){null!==this.replyComment&&this.cancelReply(),null===this.sendReplyEl&&(this.sendReplyEl=s('<div class="atk-send-reply-wrap"><div class="atk-send-reply">回复 <span class="atk-text"></span><span class="atk-cancel" title="取消 AT">×</span></div></div>'),this.sendReplyEl.querySelector(".atk-text").innerText=`@${t.nick}`,this.sendReplyEl.addEventListener("click",(()=>{this.cancelReply()})),this.textareaWrapEl.prepend(this.sendReplyEl)),this.replyComment=t,f(this.el),this.textareaEl.focus()}cancelReply(){null!==this.sendReplyEl&&(this.sendReplyEl.remove(),this.sendReplyEl=null),this.replyComment=null}initSubmit(){this.submitBtn.innerText=this.ctx.conf.sendBtn||"Send",this.submitBtn.addEventListener("click",(t=>{t.currentTarget,this.submit()}))}async submit(){if(""!==this.getContent().trim()){u(this.el);try{const t=await new L(this.ctx).add({content:this.getContent(),nick:this.user.data.nick,email:this.user.data.email,link:this.user.data.link,rid:null===this.replyComment?0:this.replyComment.id});this.ctx.dispatchEvent("list-insert",t),this.clearEditor()}catch(t){this.showNotify(`评论失败,${t.msg||String(t)}`,"e")}finally{m(this.el)}}else this.textareaEl.focus()}showNotify(t,e){k(this.notifyWrapEl,t,e)}closeComment(){this.closeCommentEl.style.display="",this.user.data.isAdmin?(this.textareaEl.style.display="",this.bottomEl.style.display=""):(this.textareaEl.style.display="none",this.closePlug(),this.bottomEl.style.display="none")}openComment(){this.closeCommentEl.style.display="none",this.textareaEl.style.display="",this.bottomEl.style.display=""}}var R=window||{},U=navigator||{};function P(t){var e=t||U.userAgent,i=this,n={Trident:e.indexOf("Trident")>-1||e.indexOf("NET CLR")>-1,Presto:e.indexOf("Presto")>-1,WebKit:e.indexOf("AppleWebKit")>-1,Gecko:e.indexOf("Gecko/")>-1,Safari:e.indexOf("Safari")>-1,Chrome:e.indexOf("Chrome")>-1||e.indexOf("CriOS")>-1,IE:e.indexOf("MSIE")>-1||e.indexOf("Trident")>-1,Edge:e.indexOf("Edge")>-1,Firefox:e.indexOf("Firefox")>-1||e.indexOf("FxiOS")>-1,"Firefox Focus":e.indexOf("Focus")>-1,Chromium:e.indexOf("Chromium")>-1,Opera:e.indexOf("Opera")>-1||e.indexOf("OPR")>-1,Vivaldi:e.indexOf("Vivaldi")>-1,Yandex:e.indexOf("YaBrowser")>-1,Kindle:e.indexOf("Kindle")>-1||e.indexOf("Silk/")>-1,360:e.indexOf("360EE")>-1||e.indexOf("360SE")>-1,UC:e.indexOf("UC")>-1||e.indexOf(" UBrowser")>-1,QQBrowser:e.indexOf("QQBrowser")>-1,QQ:e.indexOf("QQ/")>-1,Baidu:e.indexOf("Baidu")>-1||e.indexOf("BIDUBrowser")>-1,Maxthon:e.indexOf("Maxthon")>-1,Sogou:e.indexOf("MetaSr")>-1||e.indexOf("Sogou")>-1,LBBROWSER:e.indexOf("LBBROWSER")>-1,"2345Explorer":e.indexOf("2345Explorer")>-1,TheWorld:e.indexOf("TheWorld")>-1,XiaoMi:e.indexOf("MiuiBrowser")>-1,Quark:e.indexOf("Quark")>-1,Qiyu:e.indexOf("Qiyu")>-1,Wechat:e.indexOf("MicroMessenger")>-1,Taobao:e.indexOf("AliApp(TB")>-1,Alipay:e.indexOf("AliApp(AP")>-1,Weibo:e.indexOf("Weibo")>-1,Douban:e.indexOf("com.douban.frodo")>-1,Suning:e.indexOf("SNEBUY-APP")>-1,iQiYi:e.indexOf("IqiyiApp")>-1,Windows:e.indexOf("Windows")>-1,Linux:e.indexOf("Linux")>-1||e.indexOf("X11")>-1,"Mac OS":e.indexOf("Macintosh")>-1,Android:e.indexOf("Android")>-1||e.indexOf("Adr")>-1,Ubuntu:e.indexOf("Ubuntu")>-1,FreeBSD:e.indexOf("FreeBSD")>-1,Debian:e.indexOf("Debian")>-1,"Windows Phone":e.indexOf("IEMobile")>-1||e.indexOf("Windows Phone")>-1,BlackBerry:e.indexOf("BlackBerry")>-1||e.indexOf("RIM")>-1,MeeGo:e.indexOf("MeeGo")>-1,Symbian:e.indexOf("Symbian")>-1,iOS:e.indexOf("like Mac OS X")>-1,"Chrome OS":e.indexOf("CrOS")>-1,WebOS:e.indexOf("hpwOS")>-1,Mobile:e.indexOf("Mobi")>-1||e.indexOf("iPh")>-1||e.indexOf("480")>-1,Tablet:e.indexOf("Tablet")>-1||e.indexOf("Pad")>-1||e.indexOf("Nexus 7")>-1};n.Mobile?n.Mobile=!(e.indexOf("iPad")>-1):R.showModalDialog&&R.chrome&&(n[360]=!0);var s,a={engine:["WebKit","Trident","Gecko","Presto"],browser:["Safari","Chrome","Edge","IE","Firefox","Firefox Focus","Chromium","Opera","Vivaldi","Yandex","Kindle","360","UC","QQBrowser","QQ","Baidu","Maxthon","Sogou","LBBROWSER","2345Explorer","TheWorld","XiaoMi","Quark","Qiyu","Wechat","Taobao","Alipay","Weibo","Douban","Suning","iQiYi"],os:["Windows","Linux","Mac OS","Android","Ubuntu","FreeBSD","Debian","iOS","Windows Phone","BlackBerry","MeeGo","Symbian","Chrome OS","WebOS"],device:["Mobile","Tablet"]};for(var r in i.device="PC",i.language=((s=(U.browserLanguage||U.language).split("-"))[1]&&(s[1]=s[1].toUpperCase()),s.join("_")),a)for(var o=0;o<a[r].length;o++){var l=a[r][o];n[l]&&(i[r]=l)}var c={Windows:function(){var t=e.replace(/^.*Windows NT ([\d.]+);.*$/,"$1");return{6.4:"10",6.3:"8.1",6.2:"8",6.1:"7","6.0":"Vista",5.2:"XP",5.1:"XP","5.0":"2000"}[t]||t},Android:function(){return e.replace(/^.*Android ([\d.]+);.*$/,"$1")},iOS:function(){return e.replace(/^.*OS ([\d_]+) like.*$/,"$1").replace(/_/g,".")},Debian:function(){return e.replace(/^.*Debian\/([\d.]+).*$/,"$1")},"Windows Phone":function(){return e.replace(/^.*Windows Phone( OS)? ([\d.]+);.*$/,"$2")},"Mac OS":function(){return e.replace(/^.*Mac OS X ([\d_]+).*$/,"$1").replace(/_/g,".")},WebOS:function(){return e.replace(/^.*hpwOS\/([\d.]+);.*$/,"$1")}};i.osVersion="",c[i.os]&&(i.osVersion=c[i.os](),i.osVersion===e&&(i.osVersion=""));var d={Safari:function(){return e.replace(/^.*Version\/([\d.]+).*$/,"$1")},Chrome:function(){return e.replace(/^.*Chrome\/([\d.]+).*$/,"$1").replace(/^.*CriOS\/([\d.]+).*$/,"$1")},IE:function(){return e.replace(/^.*MSIE ([\d.]+).*$/,"$1").replace(/^.*rv:([\d.]+).*$/,"$1")},Edge:function(){return e.replace(/^.*Edge\/([\d.]+).*$/,"$1")},Firefox:function(){return e.replace(/^.*Firefox\/([\d.]+).*$/,"$1").replace(/^.*FxiOS\/([\d.]+).*$/,"$1")},"Firefox Focus":function(){return e.replace(/^.*Focus\/([\d.]+).*$/,"$1")},Chromium:function(){return e.replace(/^.*Chromium\/([\d.]+).*$/,"$1")},Opera:function(){return e.replace(/^.*Opera\/([\d.]+).*$/,"$1").replace(/^.*OPR\/([\d.]+).*$/,"$1")},Vivaldi:function(){return e.replace(/^.*Vivaldi\/([\d.]+).*$/,"$1")},Yandex:function(){return e.replace(/^.*YaBrowser\/([\d.]+).*$/,"$1")},Kindle:function(){return e.replace(/^.*Version\/([\d.]+).*$/,"$1")},Maxthon:function(){return e.replace(/^.*Maxthon\/([\d.]+).*$/,"$1")},QQBrowser:function(){return e.replace(/^.*QQBrowser\/([\d.]+).*$/,"$1")},QQ:function(){return e.replace(/^.*QQ\/([\d.]+).*$/,"$1")},Baidu:function(){return e.replace(/^.*BIDUBrowser[\s/]([\d.]+).*$/,"$1")},UC:function(){return e.replace(/^.*UC?Browser\/([\d.]+).*$/,"$1")},Sogou:function(){return e.replace(/^.*SE ([\d.X]+).*$/,"$1").replace(/^.*SogouMobileBrowser\/([\d.]+).*$/,"$1")},"2345Explorer":function(){return e.replace(/^.*2345Explorer\/([\d.]+).*$/,"$1")},TheWorld:function(){return e.replace(/^.*TheWorld ([\d.]+).*$/,"$1")},XiaoMi:function(){return e.replace(/^.*MiuiBrowser\/([\d.]+).*$/,"$1")},Quark:function(){return e.replace(/^.*Quark\/([\d.]+).*$/,"$1")},Qiyu:function(){return e.replace(/^.*Qiyu\/([\d.]+).*$/,"$1")},Wechat:function(){return e.replace(/^.*MicroMessenger\/([\d.]+).*$/,"$1")},Taobao:function(){return e.replace(/^.*AliApp\(TB\/([\d.]+).*$/,"$1")},Alipay:function(){return e.replace(/^.*AliApp\(AP\/([\d.]+).*$/,"$1")},Weibo:function(){return e.replace(/^.*weibo__([\d.]+).*$/,"$1")},Douban:function(){return e.replace(/^.*com.douban.frodo\/([\d.]+).*$/,"$1")},Suning:function(){return e.replace(/^.*SNEBUY-APP([\d.]+).*$/,"$1")},iQiYi:function(){return e.replace(/^.*IqiyiVersion\/([\d.]+).*$/,"$1")}};i.version="",d[i.browser]&&(i.version=d[i.browser](),i.version===e&&(i.version="")),i.version.indexOf(".")&&(i.version=i.version.substring(0,i.version.indexOf("."))),"Edge"===i.browser?i.engine="EdgeHTML":"Chrome"===i.browser&&parseInt(i.version)>27||"Opera"===i.browser&&parseInt(i.version)>12||"Yandex"===i.browser?i.engine="Blink":void 0===i.browser&&(i.browser="Unknow App")}function I(t){return new P(t)}class H extends x{data;mainEl;bodyEl;contentEl;childrenEl;actionsEl;parent;nestedNum;maxNestingNum=3;children=[];replyTo;afterRender;unread=!1;openable=!1;openURL;openEvt;constructor(t,e){super(t),this.data={...e},this.data.date=this.data.date.replace(/-/g,"/"),this.parent=null,this.nestedNum=1}renderElem(){this.el=s('<div class="atk-comment-wrap" data-comment-id="">\n <div class="atk-comment">\n\n <div class="atk-avatar">\n <a target="_blank"><img src=""></a>\n </div>\n\n <div class="atk-comment-main">\n\n <div class="atk-header">\n <span class="atk-nick"><a target="_blank"></a></span>\n <span class="atk-badge"></span>\n <span class="atk-date"></span>\n <span class="atk-ua ua-browser"></span>\n <span class="atk-ua ua-os"></span>\n </div>\n\n <div class="atk-body">\n <div class="atk-content"></div>\n </div>\n\n <div class="atk-footer">\n <div class="atk-comment-actions"></div>\n </div>\n\n </div>\n\n </div>\n</div>\n'),this.mainEl=this.el.querySelector(".atk-comment-main"),this.bodyEl=this.el.querySelector(".atk-body"),this.contentEl=this.bodyEl.querySelector(".atk-content"),this.actionsEl=this.el.querySelector(".atk-comment-actions"),this.childrenEl=null,this.unread?this.el.classList.add("atk-unread"):this.el.classList.remove("atk-unread"),this.openable?this.el.classList.add("atk-openable"):this.el.classList.remove("atk-openable"),this.el.addEventListener("click",(t=>{this.openable&&this.openURL&&(t.preventDefault(),window.open(this.openURL)),this.openEvt&&this.openEvt()})),this.el.setAttribute("data-comment-id",`${this.data.id}`),this.el.querySelector(".atk-avatar a").setAttribute("href",this.data.link),this.el.querySelector(".atk-avatar img").setAttribute("src",this.getGravatarUrl());const t=this.el.querySelector(".atk-nick > a");t.innerText=this.data.nick,t.href=this.data.link;const e=this.el.querySelector(".atk-badge");this.data.badge_name?(e.innerText=this.data.badge_name,this.data.badge_color&&(e.style.backgroundColor=this.data.badge_color)):e.remove();const i=this.el.querySelector(".atk-date");if(i.innerText=this.getDateFormatted(),i.setAttribute("data-atk-comment-date",String(+new Date(this.data.date))),this.el.querySelector(".atk-ua.ua-browser").innerText=this.getUserUaBrowser(),this.el.querySelector(".atk-ua.ua-os").innerText=this.getUserUaOS(),this.data.is_collapsed){this.contentEl.classList.add("atk-hide","atk-type-collapsed");const t=s('\n <div class="atk-collapsed">\n <span class="atk-text">该评论已被系统或管理员折叠</span>\n <span class="atk-show-btn">查看内容</span>\n </div>');this.bodyEl.insertAdjacentElement("beforeend",t);const e=t.querySelector(".atk-show-btn");e.addEventListener("click",(t=>{this.contentEl.classList.contains("atk-hide")?(this.contentEl.innerHTML=this.getContentMarked(),this.contentEl.classList.remove("atk-hide"),y(this.contentEl),e.innerHTML="收起内容"):(this.contentEl.innerHTML="",this.contentEl.classList.add("atk-hide"),e.innerHTML="查看内容"),t.stopPropagation()}))}else this.contentEl.innerHTML=this.getContentMarked();if(this.replyTo){const t=s('\n <div class="atk-reply-to">\n <div class="atk-meta">回复 <span class="atk-nick"></span>:</div>\n <div class="atk-content"></div>\n </div>');t.querySelector(".atk-nick").innerText=`@${this.replyTo.nick}`,t.querySelector(".atk-content").innerHTML=d(this.ctx,this.replyTo.content),this.bodyEl.prepend(t)}if(this.data.is_pending){const t=s('<div class="atk-pending">审核中,仅本人可见。</div>');this.bodyEl.prepend(t)}return this.initActionBtn(),this.afterRender&&this.afterRender(),this.el}eachComment(t,e){0!==t.length&&t.every((i=>!1!==e(i,t)&&(this.eachComment(i.getChildren(),e),!0)))}refreshUI(){const t=this.el,e=this.renderElem();t.replaceWith(e),this.playFadeInAnim(),this.eachComment(this.children,(t=>{t.parent?.getChildrenEl().appendChild(t.renderElem()),t.playFadeInAnim()}))}initActionBtn(){const t=s("<span></span>"),e=s("<span></span>");this.actionsEl.append(t),this.actionsEl.append(e);const i=()=>{t.innerText=`赞同 (${this.data.vote_up||0})`,e.innerText=`反对 (${this.data.vote_down||0})`};if(i(),t.onclick=()=>{new L(this.ctx).vote(this.data.id,"comment_up").then((t=>{this.data.vote_up=t,i()})).catch((t=>{window.alert(`投票失败:${t.msg||String(t)}`)}))},e.onclick=()=>{new L(this.ctx).vote(this.data.id,"comment_down").then((t=>{this.data.vote_down=t,i()})).catch((t=>{window.alert(`投票失败:${t.msg||String(t)}`)}))},this.data.is_allow_reply){const t=s('<span data-atk-action="comment-reply">回复</span>');this.actionsEl.append(t),t.addEventListener("click",(t=>{this.ctx.dispatchEvent("editor-reply",this.data),t.stopPropagation()}))}const n=s(`<span atk-only-admin-show>${this.data.is_collapsed?"取消折叠":"折叠"}</span>`);this.actionsEl.append(n),n.addEventListener("click",(t=>{this.adminEdit("collapsed",n),t.stopPropagation()}));const a=s(`<span atk-only-admin-show>${this.data.is_pending?"待审":"已审"}</span>`);this.actionsEl.append(a),a.addEventListener("click",(t=>{this.adminEdit("pending",a),t.stopPropagation()}));const r=s("<span atk-only-admin-show>删除</span>");this.actionsEl.append(r),r.addEventListener("click",(t=>{this.adminDelete(r),t.stopPropagation()}))}getIsRoot(){return null===this.parent}getChildren(){return this.children}putChild(t){t.parent=this,t.nestedNum=this.nestedNum+1,this.children.push(t),this.getChildrenEl().appendChild(t.getEl()),t.playFadeInAnim()}getChildrenEl(){return null===this.childrenEl&&(this.nestedNum<this.maxNestingNum?(this.childrenEl=s('<div class="atk-comment-children"></div>'),this.mainEl.appendChild(this.childrenEl)):this.parent&&(this.childrenEl=this.parent.getChildrenEl())),this.childrenEl}getParent(){return this.parent}getEl(){return this.el}getData(){return this.data}getGravatarUrl(){return`${this.ctx.conf.gravatar?.cdn||""}${this.data.email_encrypted}?d=${encodeURIComponent(this.ctx.conf.defaultAvatar||"")}&s=80`}getContentMarked(){return d(this.ctx,this.data.content)}getDateFormatted(){return l(new Date(this.data.date))}getUserUaBrowser(){const t=I(this.data.ua);return`${t.browser} ${t.version}`}getUserUaOS(){const t=I(this.data.ua);return`${t.os} ${t.osVersion}`}playFadeInAnim(){y(this.el)}adminEdit(t,e){if(e.classList.contains("atk-in-process"))return;const i=e.innerText;e.classList.add("atk-in-process"),e.innerText="修改中...","collapsed"===t?this.data.is_collapsed=!this.data.is_collapsed:"pending"===t&&(this.data.is_pending=!this.data.is_pending),new L(this.ctx).commentEdit(this.data).then((t=>{e.classList.remove("atk-in-process"),this.data=t,this.refreshUI(),y(this.bodyEl),this.ctx.dispatchEvent("list-refresh-ui")})).catch((t=>{console.error(t),e.classList.add("atk-error"),e.innerText="修改失败",setTimeout((()=>{e.innerText=i,e.classList.remove("atk-error"),e.classList.remove("atk-in-process")}),2e3)}))}onDelete;adminDelete(t){if(t.classList.contains("atk-in-process"))return;const e=Number(t.getAttribute("data-btn-clicked")||1);if(e<2){if(1===e){const i=t.innerText;t.innerText="确认删除",setTimeout((()=>{t.innerText=i,t.setAttribute("data-btn-clicked","")}),2e3),t.setAttribute("data-btn-clicked",String(e+1))}return}const i=t.innerText;t.classList.add("atk-in-process"),t.innerText="删除中...",new L(this.ctx).commentDel(this.data.id,this.data.site_name).then((()=>{t.innerText=i,t.classList.remove("atk-in-process"),this.onDelete&&this.onDelete(this)})).catch((e=>{console.error(e),t.classList.add("atk-error"),t.innerText="删除失败",setTimeout((()=>{t.innerText=i,t.classList.remove("atk-error"),t.classList.remove("atk-in-process")}),2e3)}))}setUnread(t){this.unread=t,this.unread?this.el.classList.add("atk-unread"):this.el.classList.remove("atk-unread")}setOpenURL(t){t||(this.openable=!1,this.el.classList.remove("atk-openable")),this.openable=!0,this.openURL=t,this.el.classList.add("atk-openable")}}class N extends x{el;commentsWrapEl;comments=[];data;pageSize=15;offset=0;type;readMoreEl;readMoreLoadingEl;readMoreTextEl;noCommentText;renderComment;paramsEditor;onAfterLoad;isLoading=!1;isFirstLoad=!0;flatMode=!1;unread=[];unreadHighlight=!1;constructor(t){super(t),this.el=s('\n <div class="atk-list-lite">\n <div class="atk-list-comments-wrap"></div>\n <div class="atk-list-read-more" style="display: none;">\n <div class="atk-loading-icon" style="display: none;"></div>\n <span class="atk-text">查看更多</span>\n </div>\n </div>\n '),this.commentsWrapEl=this.el.querySelector(".atk-list-comments-wrap"),this.pageSize=this.conf.readMore&&this.conf.readMore.pageSize||this.pageSize,this.readMoreEl=this.el.querySelector(".atk-list-read-more"),this.readMoreLoadingEl=this.readMoreEl.querySelector(".atk-loading-icon"),this.readMoreTextEl=this.readMoreEl.querySelector(".atk-text"),this.readMoreEl.addEventListener("click",(()=>{this.readMore()})),this.noCommentText=this.conf.noComment||"无评论",setInterval((()=>{this.el.querySelectorAll("[data-atk-comment-date]").forEach((t=>{const e=t.getAttribute("data-atk-comment-date");t.innerText=l(new Date(Number(e)))}))}),3e4),this.ctx.addEventListener("unread-update",(t=>this.updateUnread(t.notifies)))}async reqComments(t=0){0===t&&this.clearComments(),this.isLoading=!0,0===t?u(this.el):this.readMoreBtnSetLoading(!0);const e=()=>{this.isLoading=!1,0===t?m(this.el):this.readMoreBtnSetLoading(!1)};let i;try{i=await new L(this.ctx).get(t,this.type,this.paramsEditor)}catch(n){throw this.onError(n.msg||String(n)),n}finally{e()}this.offset=t;try{this.onLoad(i),this.onAfterLoad&&this.onAfterLoad(i)}catch(n){throw this.onError(String(n)),n}finally{e()}}onLoad(t){this.data=t,v(this.el,null),this.importComments(t.comments),this.hasMoreComments?this.showReadMoreBtn():this.hideReadMoreBtn(),this.isFirstLoad&&this.hasMoreComments&&this.initScrollBottomAutoLoad(),this.ctx.dispatchEvent("unread-update",{notifies:t.unread||[]}),this.isFirstLoad=!1}onError(t){if(t=String(t),console.error(t),this.isFirstLoad){const e=s(`<span>${t},无法获取评论列表数据<br/></span>`),i=s('<span style="cursor:pointer;">点击重新获取</span>');i.onclick=()=>{this.reqComments(0)},e.appendChild(i);const n=s('<span atk-only-admin-show> | <span style="cursor:pointer;">打开控制台</span></span>');n.onclick=()=>{this.ctx.dispatchEvent("sidebar-show",{viewName:"admin"})},this.ctx.user.data.isAdmin||n.classList.add("atk-hide"),e.appendChild(n),v(this.el,e)}else this.readMoreBtnShowErr(`${t} 获取失败`)}createComment(t){const e=new H(this.ctx,t);return e.afterRender=()=>{this.renderComment&&this.renderComment(e)},e.onDelete=t=>{this.deleteComment(t),this.refreshUI()},e}importComments(t){const e=i=>{const n=t.filter((t=>t.rid===i.data.id));0!==n.length&&n.forEach((t=>{t.is_allow_reply=i.data.is_allow_reply;const n=this.createComment(t);n.renderElem(),i.putChild(n),e(n)}))};this.flatMode?t.forEach((e=>{e.is_collapsed&&(e.is_allow_reply=!1);const i=this.createComment(e);if(0!==e.rid){const n=t.find((t=>t.id===e.rid));n&&(i.replyTo=n)}i.renderElem(),this.comments.push(i),e.visible&&(this.commentsWrapEl.appendChild(i.getEl()),i.playFadeInAnim())})):t.filter((t=>0===t.rid)).forEach((t=>{t.is_collapsed&&(t.is_allow_reply=!1);const i=this.createComment(t);i.renderElem(),this.comments.push(i),this.commentsWrapEl.appendChild(i.getEl()),i.playFadeInAnim(),e(i)})),this.refreshUI()}insertComment(t){const e=this.createComment(t);e.renderElem(),0!==t.rid?this.findComment(t.rid)?.putChild(e):(this.commentsWrapEl.prepend(e.getEl()),this.comments.unshift(e)),f(e.getEl()),e.playFadeInAnim(),this.data&&(this.data.total+=1),this.refreshUI()}refreshUI(){const t=this.comments.length<=0;let e=this.commentsWrapEl.querySelector(".atk-list-no-comment");t&&(e||(e=s('<div class="atk-list-no-comment"></div>'),this.commentsWrapEl.appendChild(e),e.innerHTML=this.noCommentText)),!t&&e&&e.remove(),this.ctx.dispatchEvent("check-admin-show-el")}getListCommentCount(){return this.data&&this.data.total?Number(this.data.total||"0"):0}get hasMoreComments(){return!!this.data&&this.data.total_parents>this.offset+this.pageSize}async readMore(){const t=this.offset+this.pageSize;await this.reqComments(t)}showReadMoreBtn(){this.readMoreEl.style.display=""}hideReadMoreBtn(){this.readMoreEl.style.display="none"}readMoreBtnSetLoading(t){this.readMoreLoadingEl.style.display=t?"":"none",this.readMoreTextEl.style.display=t?"none":""}readMoreBtnShowErr(t){this.readMoreBtnSetLoading(!1);const e=this.readMoreTextEl.innerText;this.readMoreTextEl.innerText=t,this.readMoreEl.classList.add("atk-err"),setTimeout((()=>{this.readMoreTextEl.innerText=e,this.readMoreEl.classList.remove("atk-err")}),2e3)}initScrollBottomAutoLoad(){this.conf.readMore&&this.conf.readMore.autoLoad&&document.addEventListener("scroll",(()=>{const t=this.el.querySelector(".atk-list-comments-wrap > .atk-comment-wrap:nth-last-child(3)");t&&this.hasMoreComments&&(this.isLoading||g(t)&&this.readMore())}))}eachComment(t,e){0!==t.length&&t.every((i=>!1!==e(i,t)&&(this.eachComment(i.getChildren(),e),!0)))}findComment(t,e){e||(e=this.comments);let i=null;return this.eachComment(e,(e=>e.data.id!==t||(i=e,!1))),i}getCommentCount(){let t=0;return this.eachComment(this.comments,(()=>{t++})),t}deleteComment(t){let e;if("number"==typeof t){if(e=this.findComment(t),!e)throw Error(`未找到评论 ${t}`)}else e=t;e.getEl().remove(),this.eachComment(this.comments,((t,i)=>t!==e||(i.splice(i.indexOf(t),1),!1)))}clearComments(){this.commentsWrapEl.innerHTML="",this.data=void 0,this.comments=[]}updateUnread(t){this.unread=t,this.unreadHighlight&&this.eachComment(this.comments,(t=>{const e=this.unread.find((e=>e.comment_id===t.data.id));e?(t.setUnread(!0),t.setOpenURL(e.read_link),t.openEvt=()=>{this.unread=this.unread.filter((e=>e.comment_id!==t.data.id)),this.ctx.dispatchEvent("unread-update",{notifies:this.unread})}):t.setUnread(!1)}))}}class W extends N{closeCommentBtnEl;openSidebarBtnEl;openAdminPanelBtnEl;unreadBadgeEl;constructor(t){super(t);const e=s('<div class="atk-list">\n <div class="atk-list-header">\n <div class="atk-comment-count">\n <span class="atk-comment-count-num">0</span>\n 条评论\n </div>\n <div class="atk-right-action">\n <span data-action="admin-close-comment" class="atk-hide" atk-only-admin-show>关闭评论</span>\n <span data-action="open-admin-panel" class="atk-hide atk-on" atk-only-admin-show>控制台</span>\n <span data-action="open-sidebar" class="atk-hide atk-on">\n <span class="atk-unread-badge" style="display: none;"></span>\n 通知中心\n </span>\n </div>\n </div>\n <div class="atk-list-body"></div>\n <div class="atk-list-footer">\n <div class="atk-copyright"></div>\n </div>\n</div>\n');e.querySelector(".atk-list-body").append(this.el),this.el=e,this.initListActionBtn(),this.el.querySelector(".atk-copyright").innerHTML='Powered By <a href="https://artalk.js.org" target="_blank" title="Artalk v2.0.4">Artalk</a>',this.ctx.addEventListener("list-reload",(()=>this.reqComments(0))),this.ctx.addEventListener("list-clear",(()=>this.clearComments())),this.ctx.addEventListener("list-refresh-ui",(()=>this.refreshUI())),this.ctx.addEventListener("list-import",(t=>this.importComments(t))),this.ctx.addEventListener("list-insert",(t=>this.insertComment(t))),this.ctx.addEventListener("list-comment-del",(t=>this.deleteComment(t.id))),this.ctx.addEventListener("list-update-data",(t=>{t(this.data),this.refreshUI()})),this.ctx.addEventListener("unread-update",(t=>this.showUnreadBadge(t.notifies?.length||0)))}refreshUI(){super.refreshUI(),this.el.querySelector(".atk-comment-count-num").innerText=String(this.getListCommentCount()),this.ctx.user.data.nick&&this.ctx.user.data.email?this.openSidebarBtnEl.classList.remove("atk-hide"):this.openSidebarBtnEl.classList.add("atk-hide"),this.ctx.dispatchEvent("check-admin-show-el"),this.data&&this.data.page&&!0===this.data.page.admin_only?(this.ctx.dispatchEvent("editor-close-comment"),this.closeCommentBtnEl.innerHTML="打开评论"):(this.ctx.dispatchEvent("editor-open-comment"),this.closeCommentBtnEl.innerHTML="关闭评论")}onLoad(t){super.onLoad(t),this.checkGoToCommentByUrlHash()}async checkGoToCommentByUrlHash(){let t=Number(a("atk_comment"));if(!t){const e=window.location.hash.match(/#atk-comment-([0-9]+)/);if(!e||!e[1]||Number.isNaN(Number(e[1])))return;t=Number(e[1])}if(!t)return;const e=this.findComment(t);e||this.hasMoreComments&&await this.readMore(),e&&(f(e.getEl(),!1),setTimeout((()=>{e.getEl().classList.add("atk-flash-once");const t=a("atk_notify_key");t&&new L(this.ctx).markRead(t).then((()=>{this.unread=this.unread.filter((t=>t.comment_id!==e.data.id)),this.ctx.dispatchEvent("unread-update",{notifies:this.unread})}))}),800))}initListActionBtn(){this.openSidebarBtnEl=this.el.querySelector('[data-action="open-sidebar"]'),this.openSidebarBtnEl.addEventListener("click",(()=>{this.ctx.dispatchEvent("sidebar-show",{viewName:"message"})})),this.openAdminPanelBtnEl=this.el.querySelector('[data-action="open-admin-panel"]'),this.openAdminPanelBtnEl.addEventListener("click",(()=>{this.ctx.dispatchEvent("sidebar-show",{viewName:"admin"})})),this.closeCommentBtnEl=this.el.querySelector('[data-action="admin-close-comment"]'),this.closeCommentBtnEl.addEventListener("click",(()=>{this.data&&(this.data.page.admin_only=!this.data.page.admin_only,this.adminPageEditSave())})),this.unreadBadgeEl=this.el.querySelector(".atk-unread-badge")}adminPageEditSave(){this.data&&this.data.page&&(this.ctx.dispatchEvent("editor-show-loading"),new L(this.ctx).pageEdit(this.data.page).then((t=>{this.data&&(this.data.page={...t}),this.refreshUI()})).catch((t=>{this.ctx.dispatchEvent("editor-notify",{msg:`修改页面数据失败:${t.msg||String(t)}`,type:"e"})})).finally((()=>{this.ctx.dispatchEvent("editor-hide-loading")})))}showUnreadBadge(t){t>0?(this.unreadBadgeEl.innerText=`${Number(t||0)}`,this.unreadBadgeEl.style.display="block"):this.unreadBadgeEl.style.display="none"}}class j extends x{constructor(t){super(t),this.el=s('<div class="atk-sidebar-view"></div>')}name="";title=this.name;actions={};activeAction;adminOnly=!1;init(){}switch(t){}}class F extends j{name="message";title="通知中心";actions={mentions:"提及",all:"全部",mine:"我的",pending:"待审"};activeAction="";list;type="mentions";init(){this.list=D(this.ctx),this.el.innerHTML="",this.el.append(this.list.el),this.activeAction=this.type,this.switch(this.type)}switch(t){this.list&&(this.type=t,this.list.type=t,this.list.isFirstLoad=!0,this.list.reqComments())}}function D(t){const e=new N(t);return e.flatMode=!0,e.unreadHighlight=!0,e.noCommentText='<div class="atk-sidebar-no-content">无内容</div>',e.renderComment=t=>{t.setOpenURL(`${t.data.page_key}#atk-comment-${t.data.id}`)},e}class z extends j{name="admin";title="控制台";actions={comment:"评论",page:"页面",site:"站点",setting:"配置"};activeAction="";adminOnly=!0;cListInstance;get cList(){return this.cListInstance||(this.cListInstance=D(this.ctx)),this.cListInstance}constructor(t){super(t),this.el=s('<div class="atk-msg-center"></div>')}init(){this.activeAction="comment",this.switch("comment")}switch(t){this.el.innerHTML="","comment"===t?this.initCommentList():"page"===t?this.initPageList():"site"===t?this.initSiteList():"setting"===t&&this.initSetting()}async initSiteFilterBar(t){const e=await new L(this.ctx).siteGet(),i=[{name:"__ATK_SITE_ALL",label:"全部站点"}];e&&e.forEach((t=>{i.push({name:t.name,label:t.name})}));return Q(i,(e=>t(e)))}async initCommentList(){const t=s('<div class="atk-admin-comment-list"></div>');t.append(this.cList.el);const e=(t,e)=>{this.cList&&(this.cList.type=`admin_${t}`,this.cList.isFirstLoad=!0,this.cList.paramsEditor=t=>{t.site_name=e},this.cList.reqComments())};let i=!1;const n={typeName:"all",siteName:""},a=Q([{name:"all",label:"全部"},{name:"pending",label:"待审"}],(t=>{i&&(n.typeName=t.name,e(n.typeName,n.siteName))}));t.prepend(a);const r=await this.initSiteFilterBar((t=>{n.siteName=t.name,e(n.typeName,n.siteName)}));t.prepend(r),i=!0,this.el.innerHTML="",this.el.append(t)}async initPageList(){const t=s('<div class="atk-admin-page-list"></div>'),e=s('<div class="atk-sidebar-list"></div>');t.append(e);const i=await this.initSiteFilterBar((t=>{this.reqPages(e,t.name)}));t.prepend(i),this.el.innerHTML="",this.el.append(t)}async reqPages(t,e){t.innerHTML="";const i=await new L(this.ctx).pageGet(e);i?i.forEach((i=>{const n=s('\n <div class="atk-item">\n <div class="atk-title"></div>\n <div class="atk-sub"></div>\n <div class="atk-actions">\n <div class="atk-item" data-action="page-edit-title">修改标题</div>\n <div class="atk-item" data-action="page-fetch">获取标题</div>\n <div class="atk-item" data-action="page-edit-key">修改 KEY</div>\n <div class="atk-item" data-action="page-admin-only"></div>\n <div class="atk-item" data-action="page-del">删除</div>\n </div>\n </div>');t.append(n),n.setAttribute("data-page-id",String(i.id));const a=n.querySelector(".atk-title"),r=n.querySelector(".atk-sub");a.innerText=i.title||i.key,r.innerText=i.key,a.onclick=()=>{window.open(`${i.url}`)},r.onclick=()=>{window.open(`${i.url}`)};const o=n.querySelector('[data-action="page-admin-only"]'),l=()=>{o.innerText=i.admin_only?"仅管理员可评":"所有人可评"};l(),o.onclick=t=>{t.stopPropagation(),i.admin_only=!i.admin_only,new L(this.ctx).pageEdit(i).then((t=>{i=t,l()}))};n.querySelector('[data-action="page-edit-title"]').onclick=()=>{const n=window.prompt("修改标题:",i.title);null!==n&&(i.title=n,new L(this.ctx).pageEdit(i).then((()=>{this.reqPages(t,e)})).catch((t=>{window.alert(`修改失败:${t.msg||"未知错误"}`)})))};const c=n.querySelector('[data-action="page-fetch"]');c.onclick=()=>{const t=c.innerText;c.innerText="获取中...",new L(this.ctx).pageFetch(i.id).then((t=>{i=t,n.querySelector(".atk-title").innerText=t.title})).catch((t=>{window.alert(`获取失败:${t.msg||"未知错误"}`)})).finally((()=>{c.innerText=t}))};n.querySelector('[data-action="page-edit-key"]').onclick=()=>{const n=window.prompt("修改 Key:",i.key);null!==n&&(i.key=n,new L(this.ctx).pageEdit(i).then((()=>{this.reqPages(t,e)})).catch((t=>{window.alert(`修改失败:${t.msg||"未知错误"}`)})))};n.querySelector('[data-action="page-del"]').onclick=()=>{window.confirm(`确认删除页面 "${i.title||i.key}"?将会删除所有相关数据`)&&(()=>{new L(this.ctx).pageDel(i.key,i.site_name).then((t=>{t&&n.remove()}))})()}})):t.innerHTML='<div class="atk-sidebar-no-content">无内容</div>'}async initSiteList(){const t=s('<div class="atk-site-list"></div>'),e=s('\n <div class="atk-sidebar-list">\n <div class="atk-site-add atk-form-inline-wrap">\n <input type="text" name="siteAdd_name" placeholder="Name..." />\n <input type="text" name="siteAdd_urls" placeholder="URL..." />\n <button name="siteAdd_submit">Add</button>\n </div>\n </div>\n ');t.append(e);const i=e.querySelector('[name="siteAdd_name"]'),n=e.querySelector('[name="siteAdd_urls"]');e.querySelector('[name="siteAdd_submit"]').onclick=()=>{const t=i.value.trim(),e=n.value.trim();""!==t?new L(this.ctx).siteAdd(t,e).then((()=>{this.initSiteList()})).catch((t=>{window.alert(`创建失败:${t.msg||""}`)})):i.focus()};const a=await new L(this.ctx).siteGet();a?(a.forEach((t=>{const i=s('\n <div class="atk-item">\n <div class="atk-title"></div>\n <div class="atk-sub"></div>\n <div class="atk-actions">\n <div class="atk-item" data-action="site-rename">重命名</div>\n <div class="atk-item" data-action="site-edit-urls">修改 URL</div>\n <div class="atk-item" data-action="site-del">删除</div>\n </div>\n </div>');e.append(i),i.setAttribute("data-site-id",String(t.id));const n=i.querySelector(".atk-title"),a=i.querySelector(".atk-sub");n.innerText=t.name||t.first_url,n.onclick=()=>{window.open(`${t.first_url}`)},t.urls&&t.urls.forEach((t=>{const e=s('<span style="margin-right: 10px;" />');e.innerText=t,e.onclick=()=>{window.open(`${t}`)},a.append(e)}));i.querySelector('[data-action="site-del"]').onclick=()=>{window.confirm(`确认删除站点 "${t.name||t.first_url}"?将会删除所有相关数据`)&&(()=>{new L(this.ctx).siteDel(t.id,!0).then((t=>{t&&i.remove()}))})()};i.querySelector('[data-action="site-edit-urls"]').onclick=()=>{const e=window.prompt("修改 URL (多个 URL 用逗号隔开):",t.urls_raw);null!==e&&new L(this.ctx).siteEdit(t.id,{name:t.name,urls:e}).then((()=>{this.initSiteList()})).catch((t=>{window.alert(`修改失败:${t.msg||"未知错误"}`)}))};i.querySelector('[data-action="site-rename"]').onclick=()=>{const e=window.prompt("编辑站点名称:",t.name);null!==e&&new L(this.ctx).siteEdit(t.id,{name:e,urls:t.urls_raw}).then((()=>{this.initSiteList()})).catch((t=>{window.alert(`修改失败:${t.msg||"未知错误"}`)}))}})),this.el.innerHTML="",this.el.append(t)):t.append(s('<div class="atk-sidebar-no-content">无内容</div>'))}initSetting(){const t=s('<div class="atk-admin-setting"></div>'),e=s('\n <div class="atk-setting">\n <div class="atk-log-wrap" style="display: none;">\n <div class="atk-log-back-btn">返回</div>\n <div class="atk-log"></div>\n </div>\n <div class="atk-group atk-importer atk-form-wrap">\n <div class="atk-title">导入评论数据</div>\n <div class="atk-label">数据类型</div>\n <select name="importer_dataType">\n <option value="artrans">Artrans (数据行囊)</option>\n <option value="artalk_v1">Artalk v1 (PHP 旧版)</option>\n <option value="typecho">Typecho</option>\n <option value="wordpress">WordPress</option>\n <option value="disqus">Disqus</option>\n <option value="commento">Commento</option>\n <option value="valine">Valine</option>\n <option value="twikoo">Twikoo</option>\n </select>\n <input type="file" name="importer_dataFile" accept="text/plain,.json" />\n <div class="atk-label">目标站点名</div>\n <input type="text" name="importer_siteName" />\n <div class="atk-label">目标站点 URL</div>\n <input type="text" name="importer_siteUrl" />\n <div class="atk-label">启动参数</div>\n <textarea name="importer_payload"></textarea>\n <span class="atk-desc">启动参数请查阅:“<a href="https://artalk.js.org/guide/transfer.html" target="_blank">文档 · 数据搬家</a>”</span>\n <button class="atk-btn" name="importer_submit">导入</button>\n </div>\n </div>');t.append(e);const i=e.querySelector(".atk-form-wrap"),n=e.querySelector(".atk-log-wrap"),a=n.querySelector(".atk-log"),r=n?.querySelector(".atk-log-back-btn");r.onclick=()=>{n.style.display="none",i.style.display=""};const o=e.querySelector('[name="importer_dataType"]'),l=e.querySelector('[name="importer_dataFile"]'),c=e.querySelector('[name="importer_siteName"]'),d=e.querySelector('[name="importer_siteUrl"]'),h=e.querySelector('[name="importer_payload"]');o.onchange=()=>{["typecho"].includes(o.value)?l.style.display="none":l.style.display=""};e.querySelector('[name="importer_submit"]').onclick=()=>{const t=o.value.trim(),e=c.value.trim(),s=d.value.trim(),r=h.value.trim();if(""===t)return void window.alert("请选择数据类型");const p=o=>{n.style.display="",i.style.display="none";const l="f_"+ +new Date,c=document.createElement("iframe");c.className="atk-iframe",c.name=l,a.innerHTML="",a.append(c);const d=document.createElement("form");d.style.display="none",d.setAttribute("method","post"),d.setAttribute("action",`${this.ctx.conf.server}/admin/artransfer`),d.setAttribute("target",l);let h={};if(r){try{h=JSON.parse(r)}catch(u){window.alert(`Payload JSON 格式有误:${String(u)}`)}h instanceof Object&&window.alert("Payload 需为 JSON 对象")}e&&(h.t_name=e),s&&(h.t_url=s),o&&(h.json_data=o);const p={type:t,payload:JSON.stringify(h),token:this.ctx.user.data.token||""};Object.entries(p).forEach((([t,e])=>{const i=document.createElement("input");i.setAttribute("type","hidden"),i.setAttribute("name",t),i.value=e,d.appendChild(i)})),n.append(d),d.submit(),d.remove()},u=new FileReader;u.onload=()=>{const t=String(u.result);p(t)},l.files?.length?u.readAsText(l.files[0]):p()},this.el.innerHTML="",this.el.append(t)}}function Q(t,e){const i=s('<div class="atk-filter-bar"></div>');return t.forEach((t=>{const n=s("<span></span>");i.append(n),n.innerText=t.label,n.addEventListener("click",(()=>{e(t),i.querySelectorAll(".atk-active").forEach((t=>t.classList.remove("atk-active"))),n.classList.add("atk-active")}))})),i.firstChild.click(),i}class V extends x{el;layer;actionsEl;contentEl;titleWrapEl;view;action;isFirstShow=!0;viewInstances={};registerViews=[F,z];constructor(t){super(t),this.el=s('<div class="atk-sidebar">\n <div class="atk-sidebar-inner">\n <div class="atk-sidebar-title-wrap"><span class="atk-title-item atk-active"></span></div>\n <div class="atk-sidebar-close"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/><path d="M0 0h24v24H0z" fill="none"/></svg></div>\n <div class="atk-sidebar-actions"></div>\n <div class="atk-sidebar-content"></div>\n </div>\n</div>\n'),this.contentEl=this.el.querySelector(".atk-sidebar-content"),this.titleWrapEl=this.el.querySelector(".atk-sidebar-title-wrap"),this.actionsEl=this.el.querySelector(".atk-sidebar-actions"),this.el.querySelector(".atk-sidebar-close").addEventListener("click",(()=>{this.hide()})),this.ctx.addEventListener("sidebar-show",(t=>this.show(t?.viewName))),this.ctx.addEventListener("sidebar-hide",(()=>this.hide())),this.registerViews.forEach((t=>{const e=new t(this.ctx);this.viewInstances[e.name]=e,e.el.classList.add(`atk-sidebar-view-${e.name}`);const i=s(`\n <span class="atk-title-item" data-name="${e.name}">${e.title}</span>\n `);e.adminOnly&&(i.setAttribute("atk-only-admin-show",""),this.ctx.user.data.isAdmin||i.classList.add("atk-hide")),this.titleWrapEl.append(i),i.addEventListener("click",(()=>{this.switchView(e)}))}))}show(t){this.el.style.transform="",this.layer=w(this.ctx,"sidebar",this.el),this.layer.show(),this.contentEl.scrollTo(0,0),setTimeout((()=>{this.el.style.transform="translate(0, 0)"}),20),t&&this.switchViewByName(t),this.isFirstShow&&(t||this.switchViewByName("message"),this.isFirstShow=!1)}hide(){this.el.style.transform="",this.layer?.dispose()}switchViewByName(t){this.viewInstances[t]?this.switchView(this.viewInstances[t]):console.error(`未找到 view: ${t}`)}switchView(t){this.view=t;const e=this.titleWrapEl.querySelector(`[data-name=${t.name}]`);this.titleWrapEl.querySelector(".atk-active").innerText=t.title,this.titleWrapEl.querySelectorAll(".atk-title-item").forEach((t=>{t.classList.contains("atk-active")||(t.style.display="")})),e.style.display="none",t.init(),this.contentEl.innerHTML="",this.contentEl.append(t.el),this.actionsEl.innerHTML="",Object.entries(t.actions).forEach((([e,i])=>{const n=s(`<span class="atk-action-item">${i}</span>`);this.actionsEl.append(n),t.activeAction===e&&n.classList.add("atk-active"),n.addEventListener("click",(()=>{t.switch(e),t.activeAction=e,this.actionsEl.querySelectorAll(".atk-active").forEach((t=>{t.classList.remove("atk-active")})),n.classList.add("atk-active")}))}))}}const G={el:"",placeholder:"来啊,快活啊 ( ゜- ゜)",noComment:"快来成为第一个评论的人吧~",sendBtn:"发送评论",defaultAvatar:"mp",pageKey:"",server:"",site:"",emoticons:{"颜表情":{inputType:"emoticon",container:{Hi:"|´・ω・)ノ","开心":"ヾ(≧∇≦*)ゝ","星星眼":"(☆ω☆)","掀桌":"(╯‵□′)╯︵┴─┴","流口水":" ̄﹃ ̄","捂脸":"(/ω\)","给跪":"∠( ᐛ 」∠)_","哈?":"(๑•̀ㅁ•́ฅ)","斜眼":"→_→","加油":"୧(๑•̀⌄•́๑)૭","有木有WiFi":"٩(ˊᗜˋ*)و","前方高能预警":"(ノ°ο°)ノ","纳尼":"(´இ皿இ`)","吓死惹":"⌇●﹏●⌇","已阅留爪":"(ฅ´ω`ฅ)","去吧大师球":"(╯°A°)╯︵○○○","太萌惹":"φ( ̄∇ ̄o)","咦咦咦":'ヾ(´・ ・`。)ノ"',"气呼呼":"( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃","我受到了惊吓":"(ó﹏ò。)","什么鬼":"Σ(っ °Д °;)っ","摸摸头":'( ,,´・ω・)ノ"(´っω・`。)',"无奈":"╮(╯▽╰)╭ ","脸红":"o(*////▽////*)q ","悲哀":">﹏<","静静地看着你":'( ๑´•ω•) "(ㆆᴗㆆ)',"不要哇":"(。•ˇ‸ˇ•。)"}},Emoji:{inputType:"emoji",container:["😀","😃","😄","😁","😆","😅","😂","😊","😉","👀","😌","😍","😘","😋","😜","😝","😎","😏","😒","😟","😕","😖","😫","😩","😠","😲","😵","😳","😱","😨","😢","😭","😷","✋","✌️","👊","👋","👏","👍","👎","❤️","🎉","🚀"]},"滑稽":{inputType:"image",container:{"原味稽":"https://i.loli.net/2019/02/01/5c53d26b7ae13.png","还是算了":"https://i.loli.net/2020/04/30/riySFlu75fJdG4p.png","蓝纹稽":"https://i.loli.net/2020/04/30/jyh5IVzpqXsHuvU.jpg","随稽应变":"https://i.loli.net/2017/02/05/5896e6ec1d528.jpg","蠕动":"https://i.loli.net/2017/02/05/5896e9712a3c1.gif","束手无稽":"https://i.loli.net/2020/04/30/dF8sTOpgomj7qf5.jpg","微笑默叹以为妙绝":"https://i.loli.net/2019/02/01/5c53daa84f24a.png","喝嘤料":"https://i.loli.net/2019/02/01/5c53d63d8c6af.jpg","暗中观察":"https://i.loli.net/2019/02/01/5c53dd21a2e7b.jpg","高兴":"https://i.loli.net/2019/02/01/5c53d1b9e5f38.jpg","惊稽":"https://i.loli.net/2019/02/01/5c53d1e2ad89f.jpg","可这和我的帅有什么关系":"https://i.loli.net/2017/02/05/5896ece29a8e0.jpg","狱稽":"https://i.loli.net/2020/04/30/cUEQrVYGFiDjqhy.jpg","梆":"https://i.loli.net/2020/04/30/TlAGjm6IvJSMVpq.jpg","吃鱼摆摆":"https://i.loli.net/2017/02/05/5896ec2cb7f39.gif","跃跃欲试 3":"https://i.loli.net/2017/02/05/5896ece2ac5a2.gif","突然滑稽":"https://i.loli.net/2019/02/01/5c53cf2a457f1.jpg","扶墙怂":"https://i.loli.net/2017/02/05/5896ece2ab57a.jpg","阔以":"https://i.loli.net/2020/04/30/7EYyq1TcBKa3eQ2.jpg","不得行":"https://i.loli.net/2020/04/30/KoqBGauX7TEfeyn.jpg","少儿不宜":"https://i.loli.net/2020/04/30/nt2ZWRozUNjBxAK.jpg","稽日可期":"https://i.loli.net/2020/04/30/FmfYcoMJesi2Ddq.jpg","哎":"https://i.loli.net/2020/04/30/ps7PTIANgSErqnU.jpg","别看丢人":"https://i.loli.net/2019/02/01/5c53d4f89ea29.jpg","地稽 2":"https://i.loli.net/2019/02/01/5c53dbae85687.jpg","地稽":"https://i.loli.net/2020/04/30/BnTMX35EPxleVmA.jpg","老阔有点扣":"https://i.loli.net/2020/04/30/fhDXbA9T1zJPlKk.gif","啊哈哈":"https://i.loli.net/2019/02/01/5c53dc2947d84.jpg","无稽可奈":"https://i.loli.net/2020/04/30/UyxTzB2fS3LtH7Q.jpg","老实巴交":"https://i.loli.net/2020/04/30/7DgSoyqwtYBxchE.jpg","紧张":"https://i.loli.net/2017/02/05/5896e8a408253.jpg","摇摆稽":"https://i.loli.net/2019/02/01/5c53d1904dcb2.gif","又不是不能用":"https://i.loli.net/2019/02/01/5c53ce897ab55.jpg","一时滑稽":"https://i.loli.net/2019/02/01/5c53d5d28e22c.jpg","无法接受":"https://i.loli.net/2019/02/01/5c53cee8422fc.jpg","嘤雄豪稽":"https://i.loli.net/2020/04/30/sbtw6o7iKaM4Nmq.jpg","相视双稽":"https://i.loli.net/2019/02/01/5c53d5a093149.jpg","稽皮发麻":"https://i.loli.net/2017/02/05/5896ece2a019f.jpg","地稽 3":"https://i.loli.net/2019/02/01/5c53dbe510bcf.jpg","地稽委屈":"https://i.loli.net/2019/02/01/5c53d76e250da.jpg","地稽抚摸":"https://i.loli.net/2020/04/30/cavZ6nNzMPimLy7.gif","地稽捶打":"https://i.loli.net/2020/04/30/vFVPynXaHR5sitk.gif","绝望":"https://i.loli.net/2019/02/01/5c53dc0ba2303.jpg","气稽败坏":"https://i.loli.net/2019/02/01/5c53d216f3c60.jpg","当场去世":"https://i.loli.net/2020/04/30/sogxHMTFWbE2lrP.jpg","喝酒":"https://i.loli.net/2019/02/01/5c53d78c3f4a5.jpg","老衲摆摊算命":"https://i.loli.net/2017/02/05/5896ece29d8a5.gif","老哥,稳":"https://i.loli.net/2017/02/05/5896ece29ebb0.jpg","自闭稽":"https://i.loli.net/2019/02/01/5c53d6603ee24.jpg","无话可说":"https://i.loli.net/2019/02/01/5c53d6a77b7e4.jpg","跃跃欲试":"https://i.loli.net/2017/02/05/5896e9710dfd5.jpg","跃跃欲试 2":"https://i.loli.net/2019/02/01/5c53dcc057350.jpg","满脑子骚操作":"https://i.loli.net/2020/04/30/xJXcUtO2BryHAsa.gif","稽之舞":"https://i.loli.net/2019/02/01/5c53de1a4d14d.gif","将稽就稽":"https://i.loli.net/2020/04/30/KVwf8qCrZts6WOT.gif"}}},gravatar:{cdn:"https://sdn.geekzu.org/avatar/"},darkMode:!1};return class{conf;ctx;el;contextID=(new Date).getTime();checker;editor;list;sidebar;comments=[];constructor(t){console.log("\n %c Artalk v2.0.4 %c 一款简洁有趣的可拓展评论系统 \n\n%c> https://artalk.js.org\n> https://github.com/ArtalkJS/Artalk\n","color: #FFF; background: #1DAAFF; padding:5px 0;","color: #FFF; background: #656565; padding:5px 0;",""),this.conf={...G,...t},this.conf.server=this.conf.server.replace(/\/$/,""),this.conf.pageKey||(this.conf.pageKey=window.location.href.split("#")[0]);try{const t=document.querySelector(this.conf.el);if(null===t)throw Error(`Sorry, Target element "${this.conf.el}" was not found.`);this.el=t}catch(e){throw console.error(e),new Error("Artalk config `el` error")}this.ctx=new p(this.el,this.conf),this.el.classList.add("artalk"),this.el.setAttribute("atk-run-id",this.contextID.toString()),""!==this.el.innerHTML.trim()&&(this.el.innerHTML=""),this.initDarkMode(),this.checker=new A(this.ctx),this.editor=new B(this.ctx),this.list=new W(this.ctx),this.sidebar=new V(this.ctx),this.el.appendChild(this.editor.el),this.el.appendChild(this.list.el),this.el.appendChild(this.sidebar.el),this.list.reqComments(),window.addEventListener("hashchange",(()=>{this.list.checkGoToCommentByUrlHash()})),this.ctx.addEventListener("check-admin-show-el",(()=>{const t=[];this.el.querySelectorAll("[atk-only-admin-show]").forEach((e=>t.push(e)));const{wrapEl:e}=b(this.ctx);e&&e.querySelectorAll("[atk-only-admin-show]").forEach((e=>t.push(e))),t.forEach((t=>{this.ctx.user.data.isAdmin?t.classList.remove("atk-hide"):t.classList.add("atk-hide")}))})),this.ctx.addEventListener("user-changed",(()=>{this.ctx.dispatchEvent("check-admin-show-el"),this.ctx.dispatchEvent("list-refresh-ui")}))}initDarkMode(){this.conf.darkMode?this.el.classList.add(E):this.el.classList.remove(E);const{wrapEl:t}=b(this.ctx);t&&(this.conf.darkMode?t.classList.add(E):t.classList.remove(E))}setDarkMode(t){this.ctx.conf.darkMode=t,this.initDarkMode()}openDarkMode(){this.setDarkMode(!0)}closeDarkMode(){this.setDarkMode(!1)}}}));
|
|
1
|
+
(function(et,X){typeof exports=="object"&&typeof module!="undefined"?module.exports=X():typeof define=="function"&&define.amd?define(X):(et=typeof globalThis!="undefined"?globalThis:et||self,et.Artalk=X())})(this,function(){"use strict";var et="";class X{data;constructor(t){const e=JSON.parse(window.localStorage.getItem("ArtalkUser")||"{}");this.data={nick:e.nick||"",email:e.email||"",link:e.link||"",token:e.token||"",isAdmin:e.isAdmin||!1}}save(){window.localStorage.setItem("ArtalkUser",JSON.stringify(this.data))}checkHasBasicUserInfo(){return!!this.data.nick&&!!this.data.email}}class it{cid;$root;conf;user;eventList=[];constructor(t,e){this.cid=+new Date,this.$root=t,this.conf=e,this.user=new X(this.conf),this.$root.setAttribute("atk-run-id",this.cid.toString())}on(t,e,i="internal"){this.eventList.push({name:t,handler:e,scope:i})}off(t,e,i="internal"){this.eventList=this.eventList.filter(s=>e?!(s.name===t&&s.handler===e&&s.scope===i):!(s.name===t&&s.scope===i))}trigger(t,e,i){this.eventList.filter(s=>s.name===t&&(i?s.scope===i:!0)).map(s=>s.handler).forEach(s=>s(e))}}var Ot={\u989C\u8868\u60C5:{inputType:"emoticon",container:{Hi:"|\xB4\u30FB\u03C9\u30FB)\u30CE",\u5F00\u5FC3:"\u30FE(\u2267\u2207\u2266*)\u309D",\u661F\u661F\u773C:"(\u2606\u03C9\u2606)",\u6380\u684C:"\uFF08\u256F\u2035\u25A1\u2032\uFF09\u256F\uFE35\u2534\u2500\u2534",\u6D41\u53E3\u6C34:"\uFFE3\uFE43\uFFE3",\u6342\u8138:"(/\u03C9\uFF3C)",\u7ED9\u8DEA:"\u2220( \u141B \u300D\u2220)\uFF3F","\u54C8\uFF1F":"(\u0E51\u2022\u0300\u3141\u2022\u0301\u0E05)",\u659C\u773C:"\u2192_\u2192",\u52A0\u6CB9:"\u0B67(\u0E51\u2022\u0300\u2304\u2022\u0301\u0E51)\u0AED",\u6709\u6728\u6709WiFi:"\u0669(\u02CA\u15DC\u02CB*)\u0648",\u524D\u65B9\u9AD8\u80FD\u9884\u8B66:"(\u30CE\xB0\u03BF\xB0)\u30CE",\u7EB3\u5C3C:"(\xB4\u0B87\u76BF\u0B87\uFF40)",\u5413\u6B7B\u60F9:"\u2307\u25CF\uFE4F\u25CF\u2307",\u5DF2\u9605\u7559\u722A:"(\u0E05\xB4\u03C9`\u0E05)",\u53BB\u5427\u5927\u5E08\u7403:"(\u256F\xB0A\xB0)\u256F\uFE35\u25CB\u25CB\u25CB",\u592A\u840C\u60F9:"\u03C6(\uFFE3\u2207\uFFE3o)",\u54A6\u54A6\u54A6:'\u30FE(\xB4\uFF65 \uFF65\uFF40\uFF61)\u30CE"',\u6C14\u547C\u547C:"( \u0E07 \u1D52\u030C\u76BF\u1D52\u030C)\u0E07\u207C\xB3\u208C\u2083",\u6211\u53D7\u5230\u4E86\u60CA\u5413:"(\xF3\uFE4F\xF2\uFF61)",\u4EC0\u4E48\u9B3C:"\u03A3(\u3063 \xB0\u0414 \xB0;)\u3063",\u6478\u6478\u5934:'( ,,\xB4\uFF65\u03C9\uFF65)\uFF89"(\xB4\u3063\u03C9\uFF65\uFF40\uFF61)',\u65E0\u5948:"\u256E(\u256F\u25BD\u2570)\u256D ",\u8138\u7EA2:"o(*////\u25BD////*)q ",\u60B2\u54C0:"\uFF1E\uFE4F\uFF1C",\u9759\u9759\u5730\u770B\u7740\u4F60:'( \u0E51\xB4\u2022\u03C9\u2022) "(\u3186\u1D17\u3186)',\u4E0D\u8981\u54C7:"(\uFF61\u2022\u02C7\u2038\u02C7\u2022\uFF61)"}},Emoji:{inputType:"emoji",container:["\u{1F600}","\u{1F603}","\u{1F604}","\u{1F601}","\u{1F606}","\u{1F605}","\u{1F602}","\u{1F60A}","\u{1F609}","\u{1F440}","\u{1F60C}","\u{1F60D}","\u{1F618}","\u{1F60B}","\u{1F61C}","\u{1F61D}","\u{1F60E}","\u{1F60F}","\u{1F612}","\u{1F61F}","\u{1F615}","\u{1F616}","\u{1F62B}","\u{1F629}","\u{1F620}","\u{1F632}","\u{1F635}","\u{1F633}","\u{1F631}","\u{1F628}","\u{1F622}","\u{1F62D}","\u{1F637}","\u270B","\u270C\uFE0F","\u{1F44A}","\u{1F44B}","\u{1F44F}","\u{1F44D}","\u{1F44E}","\u2764\uFE0F","\u{1F389}","\u{1F680}"]},\u6ED1\u7A3D:{inputType:"image",container:{\u539F\u5473\u7A3D:"https://i.loli.net/2019/02/01/5c53d26b7ae13.png",\u8FD8\u662F\u7B97\u4E86:"https://i.loli.net/2020/04/30/riySFlu75fJdG4p.png",\u84DD\u7EB9\u7A3D:"https://i.loli.net/2020/04/30/jyh5IVzpqXsHuvU.jpg",\u968F\u7A3D\u5E94\u53D8:"https://i.loli.net/2017/02/05/5896e6ec1d528.jpg",\u8815\u52A8:"https://i.loli.net/2017/02/05/5896e9712a3c1.gif",\u675F\u624B\u65E0\u7A3D:"https://i.loli.net/2020/04/30/dF8sTOpgomj7qf5.jpg",\u5FAE\u7B11\u9ED8\u53F9\u4EE5\u4E3A\u5999\u7EDD:"https://i.loli.net/2019/02/01/5c53daa84f24a.png",\u559D\u5624\u6599:"https://i.loli.net/2019/02/01/5c53d63d8c6af.jpg",\u6697\u4E2D\u89C2\u5BDF:"https://i.loli.net/2019/02/01/5c53dd21a2e7b.jpg",\u9AD8\u5174:"https://i.loli.net/2019/02/01/5c53d1b9e5f38.jpg",\u60CA\u7A3D:"https://i.loli.net/2019/02/01/5c53d1e2ad89f.jpg",\u53EF\u8FD9\u548C\u6211\u7684\u5E05\u6709\u4EC0\u4E48\u5173\u7CFB:"https://i.loli.net/2017/02/05/5896ece29a8e0.jpg",\u72F1\u7A3D:"https://i.loli.net/2020/04/30/cUEQrVYGFiDjqhy.jpg",\u6886:"https://i.loli.net/2020/04/30/TlAGjm6IvJSMVpq.jpg",\u5403\u9C7C\u6446\u6446:"https://i.loli.net/2017/02/05/5896ec2cb7f39.gif","\u8DC3\u8DC3\u6B32\u8BD5 3":"https://i.loli.net/2017/02/05/5896ece2ac5a2.gif",\u7A81\u7136\u6ED1\u7A3D:"https://i.loli.net/2019/02/01/5c53cf2a457f1.jpg",\u6276\u5899\u6002:"https://i.loli.net/2017/02/05/5896ece2ab57a.jpg",\u9614\u4EE5:"https://i.loli.net/2020/04/30/7EYyq1TcBKa3eQ2.jpg",\u4E0D\u5F97\u884C:"https://i.loli.net/2020/04/30/KoqBGauX7TEfeyn.jpg",\u5C11\u513F\u4E0D\u5B9C:"https://i.loli.net/2020/04/30/nt2ZWRozUNjBxAK.jpg",\u7A3D\u65E5\u53EF\u671F:"https://i.loli.net/2020/04/30/FmfYcoMJesi2Ddq.jpg",\u54CE:"https://i.loli.net/2020/04/30/ps7PTIANgSErqnU.jpg",\u522B\u770B\u4E22\u4EBA:"https://i.loli.net/2019/02/01/5c53d4f89ea29.jpg","\u5730\u7A3D 2":"https://i.loli.net/2019/02/01/5c53dbae85687.jpg",\u5730\u7A3D:"https://i.loli.net/2020/04/30/BnTMX35EPxleVmA.jpg",\u8001\u9614\u6709\u70B9\u6263:"https://i.loli.net/2020/04/30/fhDXbA9T1zJPlKk.gif",\u554A\u54C8\u54C8:"https://i.loli.net/2019/02/01/5c53dc2947d84.jpg",\u65E0\u7A3D\u53EF\u5948:"https://i.loli.net/2020/04/30/UyxTzB2fS3LtH7Q.jpg",\u8001\u5B9E\u5DF4\u4EA4:"https://i.loli.net/2020/04/30/7DgSoyqwtYBxchE.jpg",\u7D27\u5F20:"https://i.loli.net/2017/02/05/5896e8a408253.jpg",\u6447\u6446\u7A3D:"https://i.loli.net/2019/02/01/5c53d1904dcb2.gif",\u53C8\u4E0D\u662F\u4E0D\u80FD\u7528:"https://i.loli.net/2019/02/01/5c53ce897ab55.jpg",\u4E00\u65F6\u6ED1\u7A3D:"https://i.loli.net/2019/02/01/5c53d5d28e22c.jpg",\u65E0\u6CD5\u63A5\u53D7:"https://i.loli.net/2019/02/01/5c53cee8422fc.jpg",\u5624\u96C4\u8C6A\u7A3D:"https://i.loli.net/2020/04/30/sbtw6o7iKaM4Nmq.jpg",\u76F8\u89C6\u53CC\u7A3D:"https://i.loli.net/2019/02/01/5c53d5a093149.jpg",\u7A3D\u76AE\u53D1\u9EBB:"https://i.loli.net/2017/02/05/5896ece2a019f.jpg","\u5730\u7A3D 3":"https://i.loli.net/2019/02/01/5c53dbe510bcf.jpg",\u5730\u7A3D\u59D4\u5C48:"https://i.loli.net/2019/02/01/5c53d76e250da.jpg",\u5730\u7A3D\u629A\u6478:"https://i.loli.net/2020/04/30/cavZ6nNzMPimLy7.gif",\u5730\u7A3D\u6376\u6253:"https://i.loli.net/2020/04/30/vFVPynXaHR5sitk.gif",\u7EDD\u671B:"https://i.loli.net/2019/02/01/5c53dc0ba2303.jpg",\u6C14\u7A3D\u8D25\u574F:"https://i.loli.net/2019/02/01/5c53d216f3c60.jpg",\u5F53\u573A\u53BB\u4E16:"https://i.loli.net/2020/04/30/sogxHMTFWbE2lrP.jpg",\u559D\u9152:"https://i.loli.net/2019/02/01/5c53d78c3f4a5.jpg",\u8001\u8872\u6446\u644A\u7B97\u547D:"https://i.loli.net/2017/02/05/5896ece29d8a5.gif","\u8001\u54E5\uFF0C\u7A33":"https://i.loli.net/2017/02/05/5896ece29ebb0.jpg",\u81EA\u95ED\u7A3D:"https://i.loli.net/2019/02/01/5c53d6603ee24.jpg",\u65E0\u8BDD\u53EF\u8BF4:"https://i.loli.net/2019/02/01/5c53d6a77b7e4.jpg",\u8DC3\u8DC3\u6B32\u8BD5:"https://i.loli.net/2017/02/05/5896e9710dfd5.jpg","\u8DC3\u8DC3\u6B32\u8BD5 2":"https://i.loli.net/2019/02/01/5c53dcc057350.jpg",\u6EE1\u8111\u5B50\u9A9A\u64CD\u4F5C:"https://i.loli.net/2020/04/30/xJXcUtO2BryHAsa.gif",\u7A3D\u4E4B\u821E:"https://i.loli.net/2019/02/01/5c53de1a4d14d.gif",\u5C06\u7A3D\u5C31\u7A3D:"https://i.loli.net/2020/04/30/KVwf8qCrZts6WOT.gif"}}};const Rt={el:"",pageKey:"",server:"",site:"",placeholder:"\u952E\u5165\u5185\u5BB9...",noComment:"\u300C\u6B64\u65F6\u65E0\u58F0\u80DC\u6709\u58F0\u300D",sendBtn:"\u53D1\u9001\u8BC4\u8BBA",darkMode:!1,emoticons:Ot,vote:!0,voteDown:!1,uaBadge:!0,flatMode:"auto",maxNesting:3,gravatar:{default:"mp",mirror:"https://sdn.geekzu.org/avatar/"},pagination:{pageSize:15,readMore:!0,autoLoad:!0},heightLimit:{content:200,children:300},reqTimeout:15e3,versionCheck:!0};class H{$el;ctx;conf;constructor(t){this.ctx=t,this.conf=t.conf}}var Ut=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{},kt={exports:{}};(function(r,t){(function(e){var i={newline:/^\n+/,code:/^( {4}[^\n]+\n*)+/,fences:/^ {0,3}(`{3,}|~{3,})([^`~\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(?:\n+|$)|$)/,hr:/^ {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\* *){3,})(?:\n+|$)/,heading:/^ {0,3}(#{1,6}) +([^\n]*?)(?: +#+)? *(?:\n+|$)/,blockquote:/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,list:/^( {0,3})(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,html:"^ {0,3}(?:<(script|pre|style)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?\\?>\\n*|<![A-Z][\\s\\S]*?>\\n*|<!\\[CDATA\\[[\\s\\S]*?\\]\\]>\\n*|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:\\n{2,}|$)|<(?!script|pre|style)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n{2,}|$)|</(?!script|pre|style)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n{2,}|$))",def:/^ {0,3}\[(label)\]: *\n? *<?([^\s>]+)>?(?:(?: +\n? *| *\n *)(title))? *(?:\n+|$)/,nptable:x,table:x,lheading:/^([^\n]+)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html)[^\n]+)*)/,text:/^[^\n]+/};i._label=/(?!\s*\])(?:\\[\[\]]|[^\[\]])+/,i._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,i.def=S(i.def).replace("label",i._label).replace("title",i._title).getRegex(),i.bullet=/(?:[*+-]|\d{1,9}\.)/,i.item=/^( *)(bull) ?[^\n]*(?:\n(?!\1bull ?)[^\n]*)*/,i.item=S(i.item,"gm").replace(/bull/g,i.bullet).getRegex(),i.list=S(i.list).replace(/bull/g,i.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+i.def.source+")").getRegex(),i._tag="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",i._comment=/<!--(?!-?>)[\s\S]*?-->/,i.html=S(i.html,"i").replace("comment",i._comment).replace("tag",i._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),i.paragraph=S(i._paragraph).replace("hr",i.hr).replace("heading"," {0,3}#{1,6} +").replace("|lheading","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}|~{3,})[^`\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)").replace("tag",i._tag).getRegex(),i.blockquote=S(i.blockquote).replace("paragraph",i.paragraph).getRegex(),i.normal=T({},i),i.gfm=T({},i.normal,{nptable:/^ *([^|\n ].*\|.*)\n *([-:]+ *\|[-| :]*)(?:\n((?:.*[^>\n ].*(?:\n|$))*)\n*|$)/,table:/^ *\|(.+)\n *\|?( *[-:]+[-| :]*)(?:\n((?: *[^>\n ].*(?:\n|$))*)\n*|$)/}),i.pedantic=T({},i.normal,{html:S(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",i._comment).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/,fences:x,paragraph:S(i.normal._paragraph).replace("hr",i.hr).replace("heading",` *#{1,6} *[^
|
|
2
|
+
]`).replace("lheading",i.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()});function s(a){this.tokens=[],this.tokens.links=Object.create(null),this.options=a||v.defaults,this.rules=i.normal,this.options.pedantic?this.rules=i.pedantic:this.options.gfm&&(this.rules=i.gfm)}s.rules=i,s.lex=function(a,l){var h=new s(l);return h.lex(a)},s.prototype.lex=function(a){return a=a.replace(/\r\n|\r/g,`
|
|
3
|
+
`).replace(/\t/g," ").replace(/\u00a0/g," ").replace(/\u2424/g,`
|
|
4
|
+
`),this.token(a,!0)},s.prototype.token=function(a,l){a=a.replace(/^ +$/gm,"");for(var h,u,c,A,d,g,w,q,W,K,y,dt,G,pt,ft,mt;a;){if((c=this.rules.newline.exec(a))&&(a=a.substring(c[0].length),c[0].length>1&&this.tokens.push({type:"space"})),c=this.rules.code.exec(a)){var gt=this.tokens[this.tokens.length-1];a=a.substring(c[0].length),gt&>.type==="paragraph"?gt.text+=`
|
|
5
|
+
`+c[0].trimRight():(c=c[0].replace(/^ {4}/gm,""),this.tokens.push({type:"code",codeBlockStyle:"indented",text:this.options.pedantic?c:N(c,`
|
|
6
|
+
`)}));continue}if(c=this.rules.fences.exec(a)){a=a.substring(c[0].length),this.tokens.push({type:"code",lang:c[2]?c[2].trim():c[2],text:c[3]||""});continue}if(c=this.rules.heading.exec(a)){a=a.substring(c[0].length),this.tokens.push({type:"heading",depth:c[1].length,text:c[2]});continue}if((c=this.rules.nptable.exec(a))&&(g={type:"table",header:j(c[1].replace(/^ *| *\| *$/g,"")),align:c[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:c[3]?c[3].replace(/\n$/,"").split(`
|
|
7
|
+
`):[]},g.header.length===g.align.length)){for(a=a.substring(c[0].length),y=0;y<g.align.length;y++)/^ *-+: *$/.test(g.align[y])?g.align[y]="right":/^ *:-+: *$/.test(g.align[y])?g.align[y]="center":/^ *:-+ *$/.test(g.align[y])?g.align[y]="left":g.align[y]=null;for(y=0;y<g.cells.length;y++)g.cells[y]=j(g.cells[y],g.header.length);this.tokens.push(g);continue}if(c=this.rules.hr.exec(a)){a=a.substring(c[0].length),this.tokens.push({type:"hr"});continue}if(c=this.rules.blockquote.exec(a)){a=a.substring(c[0].length),this.tokens.push({type:"blockquote_start"}),c=c[0].replace(/^ *> ?/gm,""),this.token(c,l),this.tokens.push({type:"blockquote_end"});continue}if(c=this.rules.list.exec(a)){for(a=a.substring(c[0].length),A=c[2],pt=A.length>1,w={type:"list_start",ordered:pt,start:pt?+A:"",loose:!1},this.tokens.push(w),c=c[0].match(this.rules.item),q=[],h=!1,G=c.length,y=0;y<G;y++)g=c[y],K=g.length,g=g.replace(/^ *([*+-]|\d+\.) */,""),~g.indexOf(`
|
|
8
|
+
`)&&(K-=g.length,g=this.options.pedantic?g.replace(/^ {1,4}/gm,""):g.replace(new RegExp("^ {1,"+K+"}","gm"),"")),y!==G-1&&(d=i.bullet.exec(c[y+1])[0],(A.length>1?d.length===1:d.length>1||this.options.smartLists&&d!==A)&&(a=c.slice(y+1).join(`
|
|
9
|
+
`)+a,y=G-1)),u=h||/\n\n(?!\s*$)/.test(g),y!==G-1&&(h=g.charAt(g.length-1)===`
|
|
10
|
+
`,u||(u=h)),u&&(w.loose=!0),ft=/^\[[ xX]\] /.test(g),mt=void 0,ft&&(mt=g[1]!==" ",g=g.replace(/^\[[ xX]\] +/,"")),W={type:"list_item_start",task:ft,checked:mt,loose:u},q.push(W),this.tokens.push(W),this.token(g,!1),this.tokens.push({type:"list_item_end"});if(w.loose)for(G=q.length,y=0;y<G;y++)q[y].loose=!0;this.tokens.push({type:"list_end"});continue}if(c=this.rules.html.exec(a)){a=a.substring(c[0].length),this.tokens.push({type:this.options.sanitize?"paragraph":"html",pre:!this.options.sanitizer&&(c[1]==="pre"||c[1]==="script"||c[1]==="style"),text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(c[0]):k(c[0]):c[0]});continue}if(l&&(c=this.rules.def.exec(a))){a=a.substring(c[0].length),c[3]&&(c[3]=c[3].substring(1,c[3].length-1)),dt=c[1].toLowerCase().replace(/\s+/g," "),this.tokens.links[dt]||(this.tokens.links[dt]={href:c[2],title:c[3]});continue}if((c=this.rules.table.exec(a))&&(g={type:"table",header:j(c[1].replace(/^ *| *\| *$/g,"")),align:c[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:c[3]?c[3].replace(/\n$/,"").split(`
|
|
11
|
+
`):[]},g.header.length===g.align.length)){for(a=a.substring(c[0].length),y=0;y<g.align.length;y++)/^ *-+: *$/.test(g.align[y])?g.align[y]="right":/^ *:-+: *$/.test(g.align[y])?g.align[y]="center":/^ *:-+ *$/.test(g.align[y])?g.align[y]="left":g.align[y]=null;for(y=0;y<g.cells.length;y++)g.cells[y]=j(g.cells[y].replace(/^ *\| *| *\| *$/g,""),g.header.length);this.tokens.push(g);continue}if(c=this.rules.lheading.exec(a)){a=a.substring(c[0].length),this.tokens.push({type:"heading",depth:c[2].charAt(0)==="="?1:2,text:c[1]});continue}if(l&&(c=this.rules.paragraph.exec(a))){a=a.substring(c[0].length),this.tokens.push({type:"paragraph",text:c[1].charAt(c[1].length-1)===`
|
|
12
|
+
`?c[1].slice(0,-1):c[1]});continue}if(c=this.rules.text.exec(a)){a=a.substring(c[0].length),this.tokens.push({type:"text",text:c[0]});continue}if(a)throw new Error("Infinite loop on byte: "+a.charCodeAt(0))}return this.tokens};var n={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:x,tag:"^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>",link:/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/,reflink:/^!?\[(label)\]\[(?!\s*\])((?:\\[\[\]]?|[^\[\]\\])+)\]/,nolink:/^!?\[(?!\s*\])((?:\[[^\[\]]*\]|\\[\[\]]|[^\[\]])*)\](?:\[\])?/,strong:/^__([^\s_])__(?!_)|^\*\*([^\s*])\*\*(?!\*)|^__([^\s][\s\S]*?[^\s])__(?!_)|^\*\*([^\s][\s\S]*?[^\s])\*\*(?!\*)/,em:/^_([^\s_])_(?!_)|^\*([^\s*<\[])\*(?!\*)|^_([^\s<][\s\S]*?[^\s_])_(?!_|[^\spunctuation])|^_([^\s_<][\s\S]*?[^\s])_(?!_|[^\spunctuation])|^\*([^\s<"][\s\S]*?[^\s\*])\*(?!\*|[^\spunctuation])|^\*([^\s*"<\[][\s\S]*?[^\s])\*(?!\*)/,code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,br:/^( {2,}|\\)\n(?!\s*$)/,del:x,text:/^(`+|[^`])(?:[\s\S]*?(?:(?=[\\<!\[`*]|\b_|$)|[^ ](?= {2,}\n))|(?= {2,}\n))/};n._punctuation=`!"#$%&'()*+,\\-./:;<=>?@\\[^_{|}~`,n.em=S(n.em).replace(/punctuation/g,n._punctuation).getRegex(),n._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,n._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,n._email=/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/,n.autolink=S(n.autolink).replace("scheme",n._scheme).replace("email",n._email).getRegex(),n._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,n.tag=S(n.tag).replace("comment",i._comment).replace("attribute",n._attribute).getRegex(),n._label=/(?:\[[^\[\]]*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,n._href=/<(?:\\[<>]?|[^\s<>\\])*>|[^\s\x00-\x1f]*/,n._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,n.link=S(n.link).replace("label",n._label).replace("href",n._href).replace("title",n._title).getRegex(),n.reflink=S(n.reflink).replace("label",n._label).getRegex(),n.normal=T({},n),n.pedantic=T({},n.normal,{strong:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,em:/^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/,link:S(/^!?\[(label)\]\((.*?)\)/).replace("label",n._label).getRegex(),reflink:S(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",n._label).getRegex()}),n.gfm=T({},n.normal,{escape:S(n.escape).replace("])","~|])").getRegex(),_extended_email:/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,url:/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,_backpedal:/(?:[^?!.,:;*_~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_~)]+(?!$))+/,del:/^~+(?=\S)([\s\S]*?\S)~+/,text:/^(`+|[^`])(?:[\s\S]*?(?:(?=[\\<!\[`*~]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))|(?= {2,}\n|[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))/}),n.gfm.url=S(n.gfm.url,"i").replace("email",n.gfm._extended_email).getRegex(),n.breaks=T({},n.gfm,{br:S(n.br).replace("{2,}","*").getRegex(),text:S(n.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()});function o(a,l){if(this.options=l||v.defaults,this.links=a,this.rules=n.normal,this.renderer=this.options.renderer||new p,this.renderer.options=this.options,!this.links)throw new Error("Tokens array requires a `links` property.");this.options.pedantic?this.rules=n.pedantic:this.options.gfm&&(this.options.breaks?this.rules=n.breaks:this.rules=n.gfm)}o.rules=n,o.output=function(a,l,h){var u=new o(l,h);return u.output(a)},o.prototype.output=function(a){for(var l="",h,u,c,A,d,g;a;){if(d=this.rules.escape.exec(a)){a=a.substring(d[0].length),l+=k(d[1]);continue}if(d=this.rules.tag.exec(a)){!this.inLink&&/^<a /i.test(d[0])?this.inLink=!0:this.inLink&&/^<\/a>/i.test(d[0])&&(this.inLink=!1),!this.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(d[0])?this.inRawBlock=!0:this.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(d[0])&&(this.inRawBlock=!1),a=a.substring(d[0].length),l+=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(d[0]):k(d[0]):d[0];continue}if(d=this.rules.link.exec(a)){var w=z(d[2],"()");if(w>-1){var q=4+d[1].length+w;d[2]=d[2].substring(0,w),d[0]=d[0].substring(0,q).trim(),d[3]=""}a=a.substring(d[0].length),this.inLink=!0,c=d[2],this.options.pedantic?(h=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(c),h?(c=h[1],A=h[3]):A=""):A=d[3]?d[3].slice(1,-1):"",c=c.trim().replace(/^<([\s\S]*)>$/,"$1"),l+=this.outputLink(d,{href:o.escapes(c),title:o.escapes(A)}),this.inLink=!1;continue}if((d=this.rules.reflink.exec(a))||(d=this.rules.nolink.exec(a))){if(a=a.substring(d[0].length),h=(d[2]||d[1]).replace(/\s+/g," "),h=this.links[h.toLowerCase()],!h||!h.href){l+=d[0].charAt(0),a=d[0].substring(1)+a;continue}this.inLink=!0,l+=this.outputLink(d,h),this.inLink=!1;continue}if(d=this.rules.strong.exec(a)){a=a.substring(d[0].length),l+=this.renderer.strong(this.output(d[4]||d[3]||d[2]||d[1]));continue}if(d=this.rules.em.exec(a)){a=a.substring(d[0].length),l+=this.renderer.em(this.output(d[6]||d[5]||d[4]||d[3]||d[2]||d[1]));continue}if(d=this.rules.code.exec(a)){a=a.substring(d[0].length),l+=this.renderer.codespan(k(d[2].trim(),!0));continue}if(d=this.rules.br.exec(a)){a=a.substring(d[0].length),l+=this.renderer.br();continue}if(d=this.rules.del.exec(a)){a=a.substring(d[0].length),l+=this.renderer.del(this.output(d[1]));continue}if(d=this.rules.autolink.exec(a)){a=a.substring(d[0].length),d[2]==="@"?(u=k(this.mangle(d[1])),c="mailto:"+u):(u=k(d[1]),c=u),l+=this.renderer.link(c,null,u);continue}if(!this.inLink&&(d=this.rules.url.exec(a))){if(d[2]==="@")u=k(d[0]),c="mailto:"+u;else{do g=d[0],d[0]=this.rules._backpedal.exec(d[0])[0];while(g!==d[0]);u=k(d[0]),d[1]==="www."?c="http://"+u:c=u}a=a.substring(d[0].length),l+=this.renderer.link(c,null,u);continue}if(d=this.rules.text.exec(a)){a=a.substring(d[0].length),this.inRawBlock?l+=this.renderer.text(this.options.sanitize?this.options.sanitizer?this.options.sanitizer(d[0]):k(d[0]):d[0]):l+=this.renderer.text(k(this.smartypants(d[0])));continue}if(a)throw new Error("Infinite loop on byte: "+a.charCodeAt(0))}return l},o.escapes=function(a){return a&&a.replace(o.rules._escapes,"$1")},o.prototype.outputLink=function(a,l){var h=l.href,u=l.title?k(l.title):null;return a[0].charAt(0)!=="!"?this.renderer.link(h,u,this.output(a[1])):this.renderer.image(h,u,k(a[1]))},o.prototype.smartypants=function(a){return this.options.smartypants?a.replace(/---/g,"\u2014").replace(/--/g,"\u2013").replace(/(^|[-\u2014/(\[{"\s])'/g,"$1\u2018").replace(/'/g,"\u2019").replace(/(^|[-\u2014/(\[{\u2018\s])"/g,"$1\u201C").replace(/"/g,"\u201D").replace(/\.{3}/g,"\u2026"):a},o.prototype.mangle=function(a){if(!this.options.mangle)return a;for(var l="",h=a.length,u=0,c;u<h;u++)c=a.charCodeAt(u),Math.random()>.5&&(c="x"+c.toString(16)),l+="&#"+c+";";return l};function p(a){this.options=a||v.defaults}p.prototype.code=function(a,l,h){var u=(l||"").match(/\S*/)[0];if(this.options.highlight){var c=this.options.highlight(a,u);c!=null&&c!==a&&(h=!0,a=c)}return u?'<pre><code class="'+this.options.langPrefix+k(u,!0)+'">'+(h?a:k(a,!0))+`</code></pre>
|
|
13
|
+
`:"<pre><code>"+(h?a:k(a,!0))+"</code></pre>"},p.prototype.blockquote=function(a){return`<blockquote>
|
|
14
|
+
`+a+`</blockquote>
|
|
15
|
+
`},p.prototype.html=function(a){return a},p.prototype.heading=function(a,l,h,u){return this.options.headerIds?"<h"+l+' id="'+this.options.headerPrefix+u.slug(h)+'">'+a+"</h"+l+`>
|
|
16
|
+
`:"<h"+l+">"+a+"</h"+l+`>
|
|
17
|
+
`},p.prototype.hr=function(){return this.options.xhtml?`<hr/>
|
|
18
|
+
`:`<hr>
|
|
19
|
+
`},p.prototype.list=function(a,l,h){var u=l?"ol":"ul",c=l&&h!==1?' start="'+h+'"':"";return"<"+u+c+`>
|
|
20
|
+
`+a+"</"+u+`>
|
|
21
|
+
`},p.prototype.listitem=function(a){return"<li>"+a+`</li>
|
|
22
|
+
`},p.prototype.checkbox=function(a){return"<input "+(a?'checked="" ':"")+'disabled="" type="checkbox"'+(this.options.xhtml?" /":"")+"> "},p.prototype.paragraph=function(a){return"<p>"+a+`</p>
|
|
23
|
+
`},p.prototype.table=function(a,l){return l&&(l="<tbody>"+l+"</tbody>"),`<table>
|
|
24
|
+
<thead>
|
|
25
|
+
`+a+`</thead>
|
|
26
|
+
`+l+`</table>
|
|
27
|
+
`},p.prototype.tablerow=function(a){return`<tr>
|
|
28
|
+
`+a+`</tr>
|
|
29
|
+
`},p.prototype.tablecell=function(a,l){var h=l.header?"th":"td",u=l.align?"<"+h+' align="'+l.align+'">':"<"+h+">";return u+a+"</"+h+`>
|
|
30
|
+
`},p.prototype.strong=function(a){return"<strong>"+a+"</strong>"},p.prototype.em=function(a){return"<em>"+a+"</em>"},p.prototype.codespan=function(a){return"<code>"+a+"</code>"},p.prototype.br=function(){return this.options.xhtml?"<br/>":"<br>"},p.prototype.del=function(a){return"<del>"+a+"</del>"},p.prototype.link=function(a,l,h){if(a=E(this.options.sanitize,this.options.baseUrl,a),a===null)return h;var u='<a href="'+k(a)+'"';return l&&(u+=' title="'+l+'"'),u+=">"+h+"</a>",u},p.prototype.image=function(a,l,h){if(a=E(this.options.sanitize,this.options.baseUrl,a),a===null)return h;var u='<img src="'+a+'" alt="'+h+'"';return l&&(u+=' title="'+l+'"'),u+=this.options.xhtml?"/>":">",u},p.prototype.text=function(a){return a};function f(){}f.prototype.strong=f.prototype.em=f.prototype.codespan=f.prototype.del=f.prototype.text=function(a){return a},f.prototype.link=f.prototype.image=function(a,l,h){return""+h},f.prototype.br=function(){return""};function $(a){this.tokens=[],this.token=null,this.options=a||v.defaults,this.options.renderer=this.options.renderer||new p,this.renderer=this.options.renderer,this.renderer.options=this.options,this.slugger=new b}$.parse=function(a,l){var h=new $(l);return h.parse(a)},$.prototype.parse=function(a){this.inline=new o(a.links,this.options),this.inlineText=new o(a.links,T({},this.options,{renderer:new f})),this.tokens=a.reverse();for(var l="";this.next();)l+=this.tok();return l},$.prototype.next=function(){return this.token=this.tokens.pop(),this.token},$.prototype.peek=function(){return this.tokens[this.tokens.length-1]||0},$.prototype.parseText=function(){for(var a=this.token.text;this.peek().type==="text";)a+=`
|
|
31
|
+
`+this.next().text;return this.inline.output(a)},$.prototype.tok=function(){switch(this.token.type){case"space":return"";case"hr":return this.renderer.hr();case"heading":return this.renderer.heading(this.inline.output(this.token.text),this.token.depth,F(this.inlineText.output(this.token.text)),this.slugger);case"code":return this.renderer.code(this.token.text,this.token.lang,this.token.escaped);case"table":{var a="",l="",h,u,c,A;for(c="",h=0;h<this.token.header.length;h++)c+=this.renderer.tablecell(this.inline.output(this.token.header[h]),{header:!0,align:this.token.align[h]});for(a+=this.renderer.tablerow(c),h=0;h<this.token.cells.length;h++){for(u=this.token.cells[h],c="",A=0;A<u.length;A++)c+=this.renderer.tablecell(this.inline.output(u[A]),{header:!1,align:this.token.align[A]});l+=this.renderer.tablerow(c)}return this.renderer.table(a,l)}case"blockquote_start":{for(l="";this.next().type!=="blockquote_end";)l+=this.tok();return this.renderer.blockquote(l)}case"list_start":{l="";for(var d=this.token.ordered,g=this.token.start;this.next().type!=="list_end";)l+=this.tok();return this.renderer.list(l,d,g)}case"list_item_start":{l="";var w=this.token.loose,q=this.token.checked,W=this.token.task;for(this.token.task&&(l+=this.renderer.checkbox(q));this.next().type!=="list_item_end";)l+=!w&&this.token.type==="text"?this.parseText():this.tok();return this.renderer.listitem(l,W,q)}case"html":return this.renderer.html(this.token.text);case"paragraph":return this.renderer.paragraph(this.inline.output(this.token.text));case"text":return this.renderer.paragraph(this.parseText());default:{var K='Token with "'+this.token.type+'" type was not found.';if(this.options.silent)console.log(K);else throw new Error(K)}}};function b(){this.seen={}}b.prototype.slug=function(a){var l=a.toLowerCase().trim().replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g,"").replace(/\s/g,"-");if(this.seen.hasOwnProperty(l)){var h=l;do this.seen[h]++,l=h+"-"+this.seen[h];while(this.seen.hasOwnProperty(l))}return this.seen[l]=0,l};function k(a,l){if(l){if(k.escapeTest.test(a))return a.replace(k.escapeReplace,function(h){return k.replacements[h]})}else if(k.escapeTestNoEncode.test(a))return a.replace(k.escapeReplaceNoEncode,function(h){return k.replacements[h]});return a}k.escapeTest=/[&<>"']/,k.escapeReplace=/[&<>"']/g,k.replacements={"&":"&","<":"<",">":">",'"':""","'":"'"},k.escapeTestNoEncode=/[<>"']|&(?!#?\w+;)/,k.escapeReplaceNoEncode=/[<>"']|&(?!#?\w+;)/g;function F(a){return a.replace(/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,function(l,h){return h=h.toLowerCase(),h==="colon"?":":h.charAt(0)==="#"?h.charAt(1)==="x"?String.fromCharCode(parseInt(h.substring(2),16)):String.fromCharCode(+h.substring(1)):""})}function S(a,l){return a=a.source||a,l=l||"",{replace:function(h,u){return u=u.source||u,u=u.replace(/(^|[^\[])\^/g,"$1"),a=a.replace(h,u),this},getRegex:function(){return new RegExp(a,l)}}}function E(a,l,h){if(a){try{var u=decodeURIComponent(F(h)).replace(/[^\w:]/g,"").toLowerCase()}catch{return null}if(u.indexOf("javascript:")===0||u.indexOf("vbscript:")===0||u.indexOf("data:")===0)return null}l&&!C.test(h)&&(h=L(l,h));try{h=encodeURI(h).replace(/%25/g,"%")}catch{return null}return h}function L(a,l){return _[" "+a]||(/^[^:]+:\/*[^/]*$/.test(a)?_[" "+a]=a+"/":_[" "+a]=N(a,"/",!0)),a=_[" "+a],l.slice(0,2)==="//"?a.replace(/:[\s\S]*/,":")+l:l.charAt(0)==="/"?a.replace(/(:\/*[^/]*)[\s\S]*/,"$1")+l:a+l}var _={},C=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function x(){}x.exec=x;function T(a){for(var l=1,h,u;l<arguments.length;l++){h=arguments[l];for(u in h)Object.prototype.hasOwnProperty.call(h,u)&&(a[u]=h[u])}return a}function j(a,l){var h=a.replace(/\|/g,function(A,d,g){for(var w=!1,q=d;--q>=0&&g[q]==="\\";)w=!w;return w?"|":" |"}),u=h.split(/ \|/),c=0;if(u.length>l)u.splice(l);else for(;u.length<l;)u.push("");for(;c<u.length;c++)u[c]=u[c].trim().replace(/\\\|/g,"|");return u}function N(a,l,h){if(a.length===0)return"";for(var u=0;u<a.length;){var c=a.charAt(a.length-u-1);if(c===l&&!h)u++;else if(c!==l&&h)u++;else break}return a.substr(0,a.length-u)}function z(a,l){if(a.indexOf(l[1])===-1)return-1;for(var h=0,u=0;u<a.length;u++)if(a[u]==="\\")u++;else if(a[u]===l[0])h++;else if(a[u]===l[1]&&(h--,h<0))return u;return-1}function at(a){a&&a.sanitize&&!a.silent&&console.warn("marked(): sanitize and sanitizer parameters are deprecated since version 0.7.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/#/USING_ADVANCED.md#options")}function v(a,l,h){if(typeof a=="undefined"||a===null)throw new Error("marked(): input parameter is undefined or null");if(typeof a!="string")throw new Error("marked(): input parameter is of type "+Object.prototype.toString.call(a)+", string expected");if(h||typeof l=="function"){h||(h=l,l=null),l=T({},v.defaults,l||{}),at(l);var u=l.highlight,c,A,d=0;try{c=s.lex(a,l)}catch(w){return h(w)}A=c.length;var g=function(w){if(w)return l.highlight=u,h(w);var q;try{q=$.parse(c,l)}catch(W){w=W}return l.highlight=u,w?h(w):h(null,q)};if(!u||u.length<3||(delete l.highlight,!A))return g();for(;d<c.length;d++)(function(w){return w.type!=="code"?--A||g():u(w.text,w.lang,function(q,W){if(q)return g(q);if(W==null||W===w.text)return--A||g();w.text=W,w.escaped=!0,--A||g()})})(c[d]);return}try{return l&&(l=T({},v.defaults,l)),at(l),$.parse(s.lex(a,l),l)}catch(w){if(w.message+=`
|
|
32
|
+
Please report this to https://github.com/markedjs/marked.`,(l||v.defaults).silent)return"<p>An error occurred:</p><pre>"+k(w.message+"",!0)+"</pre>";throw w}}v.options=v.setOptions=function(a){return T(v.defaults,a),v},v.getDefaults=function(){return{baseUrl:null,breaks:!1,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:new p,sanitize:!1,sanitizer:null,silent:!1,smartLists:!1,smartypants:!1,xhtml:!1}},v.defaults=v.getDefaults(),v.Parser=$,v.parser=$.parse,v.Renderer=p,v.TextRenderer=f,v.Lexer=s,v.lexer=s.lex,v.InlineLexer=o,v.inlineLexer=o.output,v.Slugger=b,v.parse=v,r.exports=v})()})(kt);var $t=kt.exports,yt={exports:{}};(function(r,t){(function(e,i){r.exports=i()})(Ut,function(){function e(p,f){return f={exports:{}},p(f,f.exports),f.exports}var i=e(function(p){var f=p.exports=function(){return new RegExp("(?:"+f.line().source+")|(?:"+f.block().source+")","gm")};f.line=function(){return/(?:^|\s)\/\/(.+?)$/gm},f.block=function(){return/\/\*([\S\s]*?)\*\//gm}}),s=["23AC69","91C132","F19726","E8552D","1AAB8E","E1147F","2980C1","1BA1E6","9FA0A0","F19726","E30B20","E30B20","A3338B"],n=function(p,f){f===void 0&&(f={});var $=f.colors;$===void 0&&($=s);var b=0,k={},F=/[\u4E00-\u9FFF\u3400-\u4dbf\uf900-\ufaff\u3040-\u309f\uac00-\ud7af\u0400-\u04FF]+|\w+/,S=/</,E=new RegExp("("+F.source+"|"+S.source+")|("+i().source+")","gmi");return p.replace(E,function(L,_,C){if(C)return o(C);if(_==="<")return"<";var x;k[_]?x=k[_]:(x=$[b],k[_]=x);var T='<span style="color: #'+x+'">'+_+"</span>";return b=++b%$.length,T})};function o(p){return'<span style="color: slategray">'+p+"</span>"}return n})})(yt);var It=yt.exports;function m(r=""){const t=document.createElement("div");return t.innerHTML=r.trim(),t.firstElementChild||t}function vt(r){return parseFloat(getComputedStyle(r,null).height.replace("px",""))}function Pt(r){const t=document.createElement("div");return t.innerText=r,t.innerHTML}function wt(r){const t=RegExp(`[?&]${r}=([^&]*)`).exec(window.location.search);return t&&decodeURIComponent(t[1].replace(/\+/g," "))}function xt(r){const t=r.getBoundingClientRect();return{top:t.top+window.scrollY,left:t.left+window.scrollX}}function J(r,t){let e=r.toString();for(;e.length<t;)e=`0${e}`;return e}function Wt(r){const t=J(r.getDate(),2),e=J(r.getMonth()+1,2);return`${J(r.getFullYear(),2)}-${e}-${t}`}function bt(r){try{const t=r.getTime(),i=new Date().getTime()-t,s=Math.floor(i/(24*3600*1e3));if(s===0){const n=i%(24*3600*1e3),o=Math.floor(n/(3600*1e3));if(o===0){const p=n%(3600*1e3),f=Math.floor(p/(60*1e3));if(f===0){const $=p%(60*1e3);return`${Math.round($/1e3)} \u79D2\u524D`}return`${f} \u5206\u949F\u524D`}return`${o} \u5C0F\u65F6\u524D`}return s<0?"\u521A\u521A":s<8?`${s} \u5929\u524D`:Wt(r)}catch(t){return console.error(t)," - "}}function St(r,t){return`${(r.conf.gravatar?.mirror||"").replace(/\/$/,"")}/${t}?d=${encodeURIComponent(r.conf.gravatar?.default||"")}&s=80`}function Nt(r,t){const e=r.split("."),i=t.split(".");for(let s=0;s<3;s++){const n=Number(e[s]),o=Number(i[s]);if(n>o)return 1;if(o>n)return-1;if(!Number.isNaN(n)&&Number.isNaN(o))return 1;if(Number.isNaN(n)&&!Number.isNaN(o))return-1}return 0}let rt=null;function ot(r,t){if(!rt){const e=new $t.Renderer,i=e.link;e.link=(n,o,p)=>i.call(e,n,o,p).replace(/^<a /,'<a target="_blank" rel="nofollow" ');const s=$t;s.setOptions({renderer:e,highlight:n=>It(n),pedantic:!1,gfm:!0,tables:!0,breaks:!0,sanitize:!0,smartLists:!0,smartypants:!0,xhtml:!1}),rt=s}return rt(t)}function I(r){r instanceof it&&(r=r.$root);let t=r.querySelector(".atk-loading");t||(t=m(`<div class="atk-loading atk-fade-in" style="display: none;">
|
|
33
|
+
<div class="atk-loading-spinner">
|
|
34
|
+
<svg viewBox="25 25 50 50"><circle cx="50" cy="50" r="20" fill="none" stroke-width="2" stroke-miterlimit="10"></circle></svg>
|
|
35
|
+
</div>
|
|
36
|
+
</div>`),r.appendChild(t)),t.style.display="";const e=t.querySelector(".atk-loading-spinner");e&&(e.style.display="none",window.setTimeout(()=>{e.style.display=""},500))}function P(r){r instanceof it&&(r=r.$root);const t=r.querySelector(".atk-loading");t&&(t.style.display="none")}function Ht(r,t=document.documentElement){const e=t.clientHeight,i=t.scrollTop,s=i+e,n=r.getBoundingClientRect();return n.top+i+n.height<=s}function lt(r,t=!0){const e=xt(r).top+vt(r)/2-document.documentElement.clientHeight/2;t?window.scroll({top:e>0?e:0,left:0}):window.scroll(0,e>0?e:0)}function Vt(r,t,e){const i={s:"#57d59f",e:"#ff6f6c",w:"#ffc721",i:"#2ebcfc"},s=3e3,n=m(`<div class="atk-notify atk-fade-in" style="background-color: ${i[e]}"><span class="atk-notify-content"></span></div>`),o=n.querySelector(".atk-notify-content");o.innerHTML=Pt(t).replace(`
|
|
37
|
+
`,"<br/>"),r.appendChild(n);const p=()=>{n.classList.add("atk-fade-out"),setTimeout(()=>{n.remove()},200)};let f;f=window.setTimeout(()=>{p()},s),n.addEventListener("click",()=>{p(),window.clearTimeout(f)})}function jt(r,t,e="in"){r.classList.add(`atk-fade-${e}`);const i=()=>{r.classList.remove(`atk-fade-${e}`),r.removeEventListener("animationend",i),t&&t()};r.addEventListener("animationend",i)}function ct(r,t){jt(r,t,"in")}function Y(r,t,e='<span class="atk-error-title">Artalk Error</span>'){r instanceof it&&(r=r.$root);let i=r.querySelector(".atk-error-layer");if(t===null){i!==null&&i.remove();return}i||(i=m(`<div class="atk-error-layer">${e}<span class="atk-error-text"></span></div>`),r.appendChild(i));const s=i.querySelector(".atk-error-text");s.innerHTML="",t!==null&&(t instanceof HTMLElement?s.appendChild(t):s.innerText=t)}function zt(){const r=document.createElement("p");r.style.width="100%",r.style.height="200px";const t=document.createElement("div");t.style.position="absolute",t.style.top="0px",t.style.left="0px",t.style.visibility="hidden",t.style.width="200px",t.style.height="150px",t.style.overflow="hidden",t.appendChild(r),document.body.appendChild(t);const e=r.offsetWidth;t.style.overflow="scroll";let i=r.offsetWidth;return e===i&&(i=t.clientWidth),document.body.removeChild(t),e-i}class Q extends H{name;$wrap;$mask;maskClickHideEnable=!0;bodyStyleOrgOverflow="";bodyStyleOrgPaddingRight="";constructor(t,e,i){super(t);this.name=e;const{$wrap:s,$mask:n}=ht(t);this.$wrap=s,this.$mask=n,this.$el=this.$wrap.querySelector(`[data-layer-name="${e}"].atk-layer-item`),this.$el===null&&(i?this.$el=i:(this.$el=m(),this.$el.classList.add("atk-layer-item"))),this.$el.setAttribute("data-layer-name",e),this.$el.style.display="none",this.$wrap.append(this.$el)}getName(){return this.name}getWrapEl(){return this.$wrap}getEl(){return this.$el}static hideTimeoutList=[];show(){Q.hideTimeoutList.forEach(e=>{clearTimeout(e)}),Q.hideTimeoutList=[],this.$wrap.style.display="block",this.$mask.style.display="block",this.$mask.classList.add("atk-fade-in"),this.$el.style.display="",this.$mask.onclick=()=>{this.maskClickHideEnable&&this.hide()},this.bodyStyleOrgOverflow=document.body.style.overflow,this.bodyStyleOrgPaddingRight=document.body.style.paddingRight,document.body.style.overflow="hidden";const t=parseInt(window.getComputedStyle(document.body,null).getPropertyValue("padding-right"),10);document.body.style.paddingRight=`${zt()+t||0}px`}hide(){Q.hideTimeoutList.push(window.setTimeout(()=>{this.$wrap.style.display="none",document.body.style.overflow=this.bodyStyleOrgOverflow,document.body.style.paddingRight=this.bodyStyleOrgPaddingRight},450)),this.$wrap.classList.add("atk-fade-out"),Q.hideTimeoutList.push(window.setTimeout(()=>{this.$wrap.style.display="none",this.$wrap.classList.remove("atk-fade-out")},200)),this.$el.style.display="none"}setMaskClickHide(t){this.maskClickHideEnable=t}disposeNow(){document.body.style.overflow="",this.$el.remove(),this.checkCleanLayer()}dispose(){this.hide(),this.$el.remove(),this.checkCleanLayer()}checkCleanLayer(){this.getWrapEl().querySelectorAll(".atk-layer-item").length===0&&(this.$wrap.style.display="none")}}function ht(r){let t=document.querySelector(`.atk-layer-wrap#ctx-${r.cid}`);t||(t=m(`<div class="atk-layer-wrap" id="ctx-${r.cid}" style="display: none;"><div class="atk-layer-mask"></div></div>`),document.body.appendChild(t));const e=t.querySelector(".atk-layer-mask");return{$wrap:t,$mask:e}}class Qt{$el;$content;$actions;constructor(t){return this.$el=m(`<div class="atk-layer-dialog-wrap">
|
|
38
|
+
<div class="atk-layer-dialog">
|
|
39
|
+
<div class="atk-layer-dialog-content"></div>
|
|
40
|
+
<div class="atk-layer-dialog-actions"></div>
|
|
41
|
+
</div>
|
|
42
|
+
</div>`),this.$actions=this.$el.querySelector(".atk-layer-dialog-actions"),this.$content=this.$el.querySelector(".atk-layer-dialog-content"),this.$content.appendChild(t),this}setYes(t){const e=m('<button data-action="confirm">\u786E\u5B9A</button>');return e.onclick=this.onBtnClick(t),this.$actions.appendChild(e),this}setNo(t){const e=m('<button data-action="cancel">\u53D6\u6D88</button>');return e.onclick=this.onBtnClick(t),this.$actions.appendChild(e),this}onBtnClick(t){return e=>{const i=t(e.currentTarget,this);(i===void 0||i===!0)&&this.$el.remove()}}}async function tt(r,t,e,i){if(r.user.data.token){const s=new Headers;s.set("Authorization",`Bearer ${r.user.data.token}`),e.headers=s}try{let s;if(typeof i!="number"&&r.conf.reqTimeout===0||i===0?s=await fetch(t,e):s=await Gt(i||r.conf.reqTimeout||15e3,fetch(t,e)),!s.ok&&s.status!==401)throw new Error(`\u8BF7\u6C42\u54CD\u5E94 ${s.status}`);let n=await s.json();const o=(p,f)=>{tt(r,t,e).then($=>{p($)}).catch($=>{f($)})};if(n.data&&n.data.need_captcha?n=await new Promise((p,f)=>{r.trigger("checker-captcha",{imgData:n.data.img_data,onSuccess:()=>{o(p,f)},onCancel:()=>{f(n)}})}):(n.data&&n.data.need_login||s.status===401)&&(n=await new Promise((p,f)=>{r.trigger("checker-admin",{onSuccess:()=>{o(p,f)},onCancel:()=>{f(n)}})})),!n.success)throw n;return n}catch(s){throw console.error(s),s instanceof TypeError?new Error("\u7F51\u7EDC\u9519\u8BEF"):s}}async function U(r,t,e){const i={method:"POST"};return e&&(i.body=Ct(e)),(await tt(r,t,i)).data||{}}async function Et(r,t,e){return(await tt(r,t+(e?`?${new URLSearchParams(e)}`:""),{method:"GET"})).data||{}}function Ct(r){const t=new FormData;return Object.keys(r).forEach(e=>t.append(e,String(r[e]))),t}function Gt(r,t){return new Promise((e,i)=>{const s=setTimeout(()=>{i(new Error("\u8BF7\u6C42\u8D85\u65F6"))},r);t.then(n=>{clearTimeout(s),e(n)},n=>{clearTimeout(s),i(n)})})}class B{ctx;baseURL;constructor(t){this.ctx=t,this.baseURL=t.conf.server}get(t,e,i,s){const n={page_key:this.ctx.conf.pageKey,site_name:this.ctx.conf.site||"",limit:this.ctx.conf.pagination?.pageSize||15,offset:t};return e&&(n.type=e),i&&(n.flat_mode=i),this.ctx.user.checkHasBasicUserInfo()&&(n.name=this.ctx.user.data.nick,n.email=this.ctx.user.data.email),s&&s(n),U(this.ctx,`${this.baseURL}/get`,n)}async add(t){const e={name:t.nick,email:t.email,link:t.link,content:t.content,rid:t.rid,page_key:this.ctx.conf.pageKey,page_title:this.ctx.conf.pageTitle||""};return this.ctx.conf.site&&(e.site_name=this.ctx.conf.site),(await U(this.ctx,`${this.baseURL}/add`,e)).comment}async commentEdit(t){const e={...t};return(await U(this.ctx,`${this.baseURL}/admin/comment-edit`,e)).comment}commentDel(t,e){const i={id:String(t),site_name:e||""};return U(this.ctx,`${this.baseURL}/admin/comment-del`,i)}async login(t,e,i){const s={name:t,email:e,password:i};return this.ctx.conf.site&&(s.site_name=this.ctx.conf.site),(await U(this.ctx,`${this.baseURL}/login`,s)).token}userGet(t,e){const i=new AbortController,{signal:s}=i,n={name:t,email:e,site_name:this.ctx.conf.site||""};return{req:tt(this.ctx,`${this.baseURL}/user-get`,{method:"POST",body:Ct(n),signal:s}).then(p=>({user:p.data.user,is_login:p.data.is_login,unread:p.data.unread||[],unread_count:p.data.unread_count||0})),abort:()=>{i.abort()}}}async pageGet(t,e,i){const s={site_name:t||"",offset:e||0,limit:i||15};return await U(this.ctx,`${this.baseURL}/admin/page-get`,s)}async pageEdit(t){const e={id:t.id,key:t.key,title:t.title,admin_only:t.admin_only,site_name:t.site_name||this.ctx.conf.site};return(await U(this.ctx,`${this.baseURL}/admin/page-edit`,e)).page}pageDel(t,e){const i={key:String(t),site_name:e||""};return U(this.ctx,`${this.baseURL}/admin/page-del`,i)}async pageFetch(t){const e={id:t};return(await U(this.ctx,`${this.baseURL}/admin/page-fetch`,e)).page}async siteGet(){const t={};return(await U(this.ctx,`${this.baseURL}/admin/site-get`,t)).sites}async siteAdd(t,e){const i={name:t,urls:e};return(await U(this.ctx,`${this.baseURL}/admin/site-add`,i)).site}async siteEdit(t){const e={id:t.id,name:t.name||"",urls:t.urls||""};return(await U(this.ctx,`${this.baseURL}/admin/site-edit`,e)).site}siteDel(t,e=!1){const i={id:t,del_content:e};return U(this.ctx,`${this.baseURL}/admin/site-del`,i)}async export(){return(await tt(this.ctx,`${this.baseURL}/admin/export`,{method:"POST"},0)).data?.data||""}async vote(t,e){const i={site_name:this.ctx.conf.site||"",target_id:t,type:e};return this.ctx.user.checkHasBasicUserInfo()&&(i.name=this.ctx.user.data.nick,i.email=this.ctx.user.data.email),await U(this.ctx,`${this.baseURL}/vote`,i)}markRead(t,e=!1){const i={site_name:this.ctx.conf.site||"",notify_key:t};return e&&(delete i.notify_key,i.read_all=!0,i.name=this.ctx.user.data.nick,i.email=this.ctx.user.data.email),U(this.ctx,`${this.baseURL}/mark-read`,i)}async captchaGet(){return(await Et(this.ctx,`${this.baseURL}/captcha/refresh`)).img_data||""}async captchaCheck(t){return(await Et(this.ctx,`${this.baseURL}/captcha/check`,{value:t})).img_data||""}}const Yt={request(r,t){return new B(r.ctx).captchaCheck(t)},body(r){const t=m(`<span><img class="atk-captcha-img" src="${r.submitCaptchaImgData||""}" alt="\u9A8C\u8BC1\u7801">\u6572\u5165\u9A8C\u8BC1\u7801\u7EE7\u7EED\uFF1A</span>`);return t.querySelector(".atk-captcha-img").onclick=()=>{const e=t.querySelector(".atk-captcha-img");new B(r.ctx).captchaGet().then(i=>{e.setAttribute("src",i)}).catch(i=>{console.error("\u9A8C\u8BC1\u7801\u83B7\u53D6\u5931\u8D25 ",i)})},t},onSuccess(r,t,e,i){r.submitCaptchaVal=e},onError(r,t,e,i){i.querySelector(".atk-captcha-img").click()}},Zt={inputType:"password",request(r,t){const e={name:r.ctx.user.data.nick,email:r.ctx.user.data.email,password:t};return new B(r.ctx).login(e.name,e.email,e.password)},body(){return m("<span>\u6572\u5165\u5BC6\u7801\u6765\u9A8C\u8BC1\u7BA1\u7406\u5458\u8EAB\u4EFD\uFF1A</span>")},onSuccess(r,t,e,i){r.ctx.user.data.isAdmin=!0,r.ctx.user.data.token=t,r.ctx.user.save(),r.ctx.trigger("user-changed",r.ctx.user.data),r.ctx.trigger("list-reload")},onError(r,t,e,i){}};class Kt{ctx;launched=[];submitCaptchaVal;submitCaptchaImgData;constructor(t){this.ctx=t,this.initEventBind()}initEventBind(){this.ctx.on("checker-captcha",t=>{t.imgData&&(this.submitCaptchaImgData=t.imgData),this.fire(Yt,t)}),this.ctx.on("checker-admin",t=>{this.fire(Zt,t)})}fire(t,e){if(this.launched.includes(t))return;this.launched.push(t);const i=new Q(this.ctx,`checker-${new Date().getTime()}`);i.setMaskClickHide(!1),i.show();const s=m();s.appendChild(t.body(this));const n=m(`<input id="check" type="${t.inputType||"text"}" autocomplete="off" required placeholder="">`);s.appendChild(n),setTimeout(()=>n.focus(),80),n.onkeyup=f=>{(f.key==="Enter"||f.keyCode===13)&&(f.preventDefault(),i.getEl().querySelector('button[data-action="confirm"]').click())};let o;const p=new Qt(s);p.setYes(f=>{const $=n.value.trim();o||(o=f.innerText);const b=F=>{f.innerText=F,f.classList.add("error")},k=()=>{f.innerText=o||"",f.classList.remove("error")};return f.innerText="\u52A0\u8F7D\u4E2D...",t.request(this,$).then(F=>{this.done(t,i),t.onSuccess&&t.onSuccess(this,F,$,s),e.onSuccess&&e.onSuccess($,p.$el)}).catch(F=>{b(String(F.msg||String(F))),t.onError&&t.onError(this,F,$,s);const S=setTimeout(()=>k(),3e3);n.onfocus=()=>{k(),clearTimeout(S)}}),!1}),p.setNo(()=>(this.done(t,i),e.onCancel&&e.onCancel(),!1)),i.getEl().append(p.$el),e.onMount&&e.onMount(p.$el)}done(t,e){e.disposeNow(),this.launched=this.launched.filter(i=>i!==t)}}var Ee="",Xt=`<div class="atk-editor">
|
|
43
|
+
<div class="atk-editor-header">
|
|
44
|
+
<input name="nick" placeholder="\u6635\u79F0" class="atk-nick" type="text" required="required">
|
|
45
|
+
<input name="email" placeholder="\u90AE\u7BB1" class="atk-email" type="email" required="required">
|
|
46
|
+
<input name="link" placeholder="\u7F51\u5740 (https://)" class="atk-link" type="url">
|
|
47
|
+
</div>
|
|
48
|
+
<div class="atk-editor-textarea-wrap">
|
|
49
|
+
<div class="atk-close-comment" style="display: none;"><span>\u4EC5\u7BA1\u7406\u5458\u53EF\u8BC4\u8BBA</span></div>
|
|
50
|
+
<textarea id="atk-editor-textarea" class="atk-editor-textarea" placeholder=""></textarea>
|
|
51
|
+
</div>
|
|
52
|
+
<div class="atk-editor-plug-wrap" style="display: none;"></div>
|
|
53
|
+
<div class="atk-editor-bottom">
|
|
54
|
+
<div class="atk-editor-bottom-part atk-left atk-editor-plug-switcher-wrap"></div>
|
|
55
|
+
<div class="atk-editor-bottom-part atk-right">
|
|
56
|
+
<button type="button" class="atk-send-btn"></button>
|
|
57
|
+
</div>
|
|
58
|
+
</div>
|
|
59
|
+
<div class="atk-editor-notify-wrap"></div>
|
|
60
|
+
</div>
|
|
61
|
+
`,Ce="";class Tt{editor;ctx;constructor(t){this.editor=t,this.ctx=t.ctx}}class Jt extends Tt{constructor(t){super(t);this.editor=t,this.emoticons=this.ctx.conf.emoticons,this.initEl()}$el;emoticons;listWrapEl;typesEl;initEl(){this.$el=m('<div class="atk-editor-plug-emoticons"></div>'),this.listWrapEl=m('<div class="atk-emoticons-list-wrap"></div>'),this.$el.append(this.listWrapEl),Object.entries(this.emoticons).forEach(([t,e])=>{const i=m('<div class="atk-emoticons-list" style="display: none;"></div>');this.listWrapEl.append(i),i.setAttribute("data-key",t),i.setAttribute("data-input-type",e.inputType),Object.entries(e.container).forEach(([s,n])=>{const o=m('<span class="atk-emoticons-item"></span>');if(i.append(o),o.setAttribute("title",s),o.setAttribute("data-content",n),e.inputType==="image"){const p=document.createElement("img");p.src=n,p.alt=s,o.append(p)}else o.innerText=n})}),this.typesEl=m('<div class="atk-emoticons-types"></div>'),this.$el.append(this.typesEl),Object.entries(this.emoticons).forEach(([t,e])=>{const i=m("<span />");this.typesEl.append(i),i.setAttribute("data-key",t),i.innerText=t}),this.typesEl.querySelectorAll("span").forEach(t=>{t.addEventListener("click",e=>{const s=e.currentTarget.getAttribute("data-key");s&&this.openType(s)})}),Object.keys(this.emoticons).length>0&&this.openType(Object.keys(this.emoticons)[0]),this.listWrapEl.querySelectorAll(".atk-emoticons-item").forEach(t=>{t.onclick=e=>{const i=e.currentTarget,s=i.closest(".atk-emoticons-list").getAttribute("data-input-type"),n=i.getAttribute("title"),o=i.getAttribute("data-content");s==="image"?this.editor.insertContent(`:[${n}]`):this.editor.insertContent(o||"")}})}openType(t){Array.from(this.listWrapEl.children).forEach(e=>{const i=e;i.getAttribute("data-key")!==t?i.style.display="none":i.style.display=""}),this.typesEl.querySelectorAll("span.active").forEach(e=>e.classList.remove("active")),this.typesEl.querySelector(`span[data-key="${t}"]`)?.classList.add("active"),this.changeListHeight()}getName(){return"emoticons"}getBtnHtml(){return"\u8868\u60C5"}getEl(){return this.$el}changeListHeight(){}onShow(){setTimeout(()=>{this.changeListHeight()},30)}onHide(){this.$el.parentElement.style.height=""}transEmoticonImageText(t){return Object.entries(this.emoticons).forEach(([e,i])=>{i.inputType==="image"&&Object.entries(i.container).forEach(([s,n])=>{t=t.split(`:[${s}]`).join(` `)})}),t}}var Te="";class te extends Tt{$el;binded=!1;constructor(t){super(t);this.initEl()}initEl(){this.$el=m('<div class="atk-editor-plug-preview"></div>'),this.binded=!1}getName(){return"preview"}getBtnHtml(){return'\u9884\u89C8 <i title="Markdown is supported"><svg class="markdown" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M14.85 3H1.15C.52 3 0 3.52 0 4.15v7.69C0 12.48.52 13 1.15 13h13.69c.64 0 1.15-.52 1.15-1.15v-7.7C16 3.52 15.48 3 14.85 3zM9 11H7V8L5.5 9.92 4 8v3H2V5h2l1.5 2L7 5h2v6zm2.99.5L9.5 8H11V5h2v3h1.5l-2.51 3.5z"></path></svg></i>'}getEl(){return this.$el}onShow(){if(this.updateContent(),!this.binded){const t=()=>{this.updateContent()};this.editor.$textarea.addEventListener("input",t),this.editor.$textarea.addEventListener("change",t),this.binded=!0}}onHide(){}updateContent(){this.$el.style.display!=="none"&&(this.$el.innerHTML=this.editor.getContentMarked())}}class ee extends H{LOADABLE_PLUG_LIST=[Jt,te];plugList={};$header;$textareaWrap;$textarea;$closeComment;$plugWrap;$bottom;$bottomPartLeft;$plugSwitcherWrap;$bottomPartRight;$submitBtn;$notifyWrap;replyComment=null;$sendReply=null;get user(){return this.ctx.user}constructor(t){super(t);this.$el=m(Xt),this.$header=this.$el.querySelector(".atk-editor-header"),this.$textareaWrap=this.$el.querySelector(".atk-editor-textarea-wrap"),this.$textarea=this.$el.querySelector(".atk-editor-textarea"),this.$closeComment=this.$el.querySelector(".atk-close-comment"),this.$plugWrap=this.$el.querySelector(".atk-editor-plug-wrap"),this.$bottom=this.$el.querySelector(".atk-editor-bottom"),this.$bottomPartLeft=this.$el.querySelector(".atk-editor-bottom-part.atk-left"),this.$plugSwitcherWrap=this.$el.querySelector(".atk-editor-plug-switcher-wrap"),this.$bottomPartRight=this.$el.querySelector(".atk-editor-bottom-part.atk-right"),this.$submitBtn=this.$el.querySelector(".atk-send-btn"),this.$notifyWrap=this.$el.querySelector(".atk-editor-notify-wrap"),this.initLocalStorage(),this.initHeader(),this.initTextarea(),this.initEditorPlug(),this.initBottomPart(),this.ctx.on("editor-open",()=>this.open()),this.ctx.on("editor-close",()=>this.close()),this.ctx.on("editor-reply",e=>this.setReply(e)),this.ctx.on("editor-show-loading",()=>I(this.$el)),this.ctx.on("editor-hide-loading",()=>P(this.$el)),this.ctx.on("editor-notify",e=>this.showNotify(e.msg,e.type))}initLocalStorage(){const t=window.localStorage.getItem("ArtalkContent")||"";t.trim()!==""&&(this.showNotify("\u5DF2\u81EA\u52A8\u6062\u590D","i"),this.setContent(t)),this.$textarea.addEventListener("input",()=>{this.saveContent()})}initHeader(){Object.keys(this.user.data).forEach(t=>{const e=this.getInputEl(t);e&&e instanceof HTMLInputElement&&(e.value=this.user.data[t]||"",e.addEventListener("input",()=>this.onHeaderInputChanged(t,e)))})}getInputEl(t){return this.$header.querySelector(`[name="${t}"]`)}queryUserInfo={timeout:null,abortFunc:null};onHeaderInputChanged(t,e){this.user.data[t]=e.value.trim(),(t==="nick"||t==="email")&&(this.user.data.token="",this.user.data.isAdmin=!1,this.queryUserInfo.timeout!==null&&window.clearTimeout(this.queryUserInfo.timeout),this.queryUserInfo.abortFunc!==null&&this.queryUserInfo.abortFunc(),this.queryUserInfo.timeout=window.setTimeout(()=>{this.queryUserInfo.timeout=null;const{req:i,abort:s}=new B(this.ctx).userGet(this.user.data.nick,this.user.data.email);this.queryUserInfo.abortFunc=s,i.then(n=>{n.is_login||(this.user.data.token="",this.user.data.isAdmin=!1),this.ctx.trigger("unread-update",{notifies:n.unread}),this.user.checkHasBasicUserInfo()&&!n.is_login&&n.user&&n.user.is_admin&&this.showLoginDialog(),n.user&&n.user.link&&(this.user.data.link=n.user.link,this.getInputEl("link").value=n.user.link)}).finally(()=>{this.queryUserInfo.abortFunc=null})},400)),this.saveUser()}showLoginDialog(){this.ctx.trigger("checker-admin",{onSuccess:()=>{}})}saveUser(){this.user.save(),this.ctx.trigger("user-changed",this.ctx.user.data)}saveContent(){window.localStorage.setItem("ArtalkContent",this.getContentOriginal().trim())}initTextarea(){this.$textarea.placeholder=this.ctx.conf.placeholder||"",this.$textarea.addEventListener("keydown",t=>{(t.keyCode||t.which)===9&&(t.preventDefault(),this.insertContent(" "))}),this.$textarea.addEventListener("input",t=>{this.adjustTextareaHeight()})}adjustTextareaHeight(){const t=this.$textarea.offsetHeight-this.$textarea.clientHeight;this.$textarea.style.height="0px",this.$textarea.style.height=`${this.$textarea.scrollHeight+t}px`}openedPlugName=null;initEditorPlug(){this.plugList={},this.$plugWrap.innerHTML="",this.$plugWrap.style.display="none",this.openedPlugName=null,this.$plugSwitcherWrap.innerHTML="",this.LOADABLE_PLUG_LIST.forEach(t=>{const e=new t(this);this.plugList[e.getName()]=e;const i=m(`<span class="atk-editor-action atk-editor-plug-switcher">${e.getBtnHtml()}</span>`);this.$plugSwitcherWrap.appendChild(i),i.addEventListener("click",()=>{if(this.$plugSwitcherWrap.querySelectorAll(".active").forEach(s=>s.classList.remove("active")),e.getName()===this.openedPlugName){e.onHide(),this.$plugWrap.style.display="none",this.openedPlugName=null;return}if(this.$plugWrap.querySelector(`[data-plug-name="${e.getName()}"]`)===null){const s=e.getEl();s.setAttribute("data-plug-name",e.getName()),s.style.display="none",this.$plugWrap.appendChild(s)}Array.from(this.$plugWrap.children).forEach(s=>{const n=s.getAttribute("data-plug-name");n===e.getName()?(s.style.display="",this.plugList[n].onShow()):(s.style.display="none",this.plugList[n].onHide())}),this.$plugWrap.style.display="",this.openedPlugName=e.getName(),i.classList.add("active")})})}closePlug(){this.$plugWrap.innerHTML="",this.$plugWrap.style.display="none",this.openedPlugName=null}insertContent(t){if(document.selection)this.$textarea.focus(),document.selection.createRange().text=t,this.$textarea.focus();else if(this.$textarea.selectionStart||this.$textarea.selectionStart===0){const e=this.$textarea.selectionStart,i=this.$textarea.selectionEnd,s=this.$textarea.scrollTop;this.setContent(this.$textarea.value.substring(0,e)+t+this.$textarea.value.substring(i,this.$textarea.value.length)),this.$textarea.focus(),this.$textarea.selectionStart=e+t.length,this.$textarea.selectionEnd=e+t.length,this.$textarea.scrollTop=s}else this.$textarea.focus(),this.$textarea.value+=t}setContent(t){this.$textarea.value=t,this.saveContent(),!!this.plugList&&!!this.plugList.preview&&this.plugList.preview.updateContent(),this.adjustTextareaHeight()}clearEditor(){this.setContent(""),this.cancelReply()}getContent(){let t=this.getContentOriginal();return this.plugList&&this.plugList.emoticons&&(t=this.plugList.emoticons.transEmoticonImageText(t)),t}getContentOriginal(){return this.$textarea.value||""}getContentMarked(){return ot(this.ctx,this.getContent())}initBottomPart(){this.initReply(),this.initSubmit()}initReply(){this.replyComment=null,this.$sendReply=null}setReply(t){this.replyComment!==null&&this.cancelReply(),this.$sendReply===null&&(this.$sendReply=m('<div class="atk-send-reply-wrap"><div class="atk-send-reply">\u56DE\u590D <span class="atk-text"></span><span class="atk-cancel" title="\u53D6\u6D88 AT">\xD7</span></div></div>'),this.$sendReply.querySelector(".atk-text").innerText=`@${t.nick}`,this.$sendReply.addEventListener("click",()=>{this.cancelReply()}),this.$textareaWrap.prepend(this.$sendReply)),this.replyComment=t,lt(this.$el),this.$textarea.focus()}cancelReply(){this.$sendReply!==null&&(this.$sendReply.remove(),this.$sendReply=null),this.replyComment=null}initSubmit(){this.$submitBtn.innerText=this.ctx.conf.sendBtn||"Send",this.$submitBtn.addEventListener("click",t=>{t.currentTarget,this.submit()})}async submit(){if(this.getContent().trim()===""){this.$textarea.focus();return}this.ctx.trigger("editor-submit"),I(this.$el);try{const t=await new B(this.ctx).add({content:this.getContent(),nick:this.user.data.nick,email:this.user.data.email,link:this.user.data.link,rid:this.replyComment===null?0:this.replyComment.id});this.ctx.trigger("list-insert",t),this.clearEditor(),this.ctx.trigger("editor-submitted")}catch(t){console.error(t),this.showNotify(`\u8BC4\u8BBA\u5931\u8D25\uFF0C${t.msg||String(t)}`,"e")}finally{P(this.$el)}}showNotify(t,e){Vt(this.$notifyWrap,t,e)}close(){this.$closeComment.style.display="",this.user.data.isAdmin?(this.$textarea.style.display="",this.$bottom.style.display=""):(this.$textarea.style.display="none",this.closePlug(),this.$bottom.style.display="none")}open(){this.$closeComment.style.display="none",this.$textarea.style.display="",this.$bottom.style.display=""}}var Ae="",ie=`<div class="atk-list">
|
|
62
|
+
<div class="atk-list-header">
|
|
63
|
+
<div class="atk-comment-count">
|
|
64
|
+
<span class="atk-comment-count-num">0</span>
|
|
65
|
+
\u6761\u8BC4\u8BBA
|
|
66
|
+
</div>
|
|
67
|
+
<div class="atk-right-action">
|
|
68
|
+
<span data-action="admin-close-comment" class="atk-hide" atk-only-admin-show>\u5173\u95ED\u8BC4\u8BBA</span>
|
|
69
|
+
<span data-action="open-sidebar" class="atk-hide atk-on">
|
|
70
|
+
<span class="atk-unread-badge" style="display: none;"></span>
|
|
71
|
+
\u901A\u77E5\u4E2D\u5FC3
|
|
72
|
+
</span>
|
|
73
|
+
</div>
|
|
74
|
+
</div>
|
|
75
|
+
<div class="atk-list-body"></div>
|
|
76
|
+
<div class="atk-list-footer">
|
|
77
|
+
<div class="atk-copyright"></div>
|
|
78
|
+
</div>
|
|
79
|
+
</div>
|
|
80
|
+
`,Be="",At=window||{},ut=navigator||{};function se(r){var t=r||ut.userAgent,e=this,i={Trident:t.indexOf("Trident")>-1||t.indexOf("NET CLR")>-1,Presto:t.indexOf("Presto")>-1,WebKit:t.indexOf("AppleWebKit")>-1,Gecko:t.indexOf("Gecko/")>-1,Safari:t.indexOf("Safari")>-1,Chrome:t.indexOf("Chrome")>-1||t.indexOf("CriOS")>-1,IE:t.indexOf("MSIE")>-1||t.indexOf("Trident")>-1,Edge:t.indexOf("Edge")>-1,Firefox:t.indexOf("Firefox")>-1||t.indexOf("FxiOS")>-1,"Firefox Focus":t.indexOf("Focus")>-1,Chromium:t.indexOf("Chromium")>-1,Opera:t.indexOf("Opera")>-1||t.indexOf("OPR")>-1,Vivaldi:t.indexOf("Vivaldi")>-1,Yandex:t.indexOf("YaBrowser")>-1,Kindle:t.indexOf("Kindle")>-1||t.indexOf("Silk/")>-1,360:t.indexOf("360EE")>-1||t.indexOf("360SE")>-1,UC:t.indexOf("UC")>-1||t.indexOf(" UBrowser")>-1,QQBrowser:t.indexOf("QQBrowser")>-1,QQ:t.indexOf("QQ/")>-1,Baidu:t.indexOf("Baidu")>-1||t.indexOf("BIDUBrowser")>-1,Maxthon:t.indexOf("Maxthon")>-1,Sogou:t.indexOf("MetaSr")>-1||t.indexOf("Sogou")>-1,LBBROWSER:t.indexOf("LBBROWSER")>-1,"2345Explorer":t.indexOf("2345Explorer")>-1,TheWorld:t.indexOf("TheWorld")>-1,XiaoMi:t.indexOf("MiuiBrowser")>-1,Quark:t.indexOf("Quark")>-1,Qiyu:t.indexOf("Qiyu")>-1,Wechat:t.indexOf("MicroMessenger")>-1,Taobao:t.indexOf("AliApp(TB")>-1,Alipay:t.indexOf("AliApp(AP")>-1,Weibo:t.indexOf("Weibo")>-1,Douban:t.indexOf("com.douban.frodo")>-1,Suning:t.indexOf("SNEBUY-APP")>-1,iQiYi:t.indexOf("IqiyiApp")>-1,Windows:t.indexOf("Windows")>-1,Linux:t.indexOf("Linux")>-1||t.indexOf("X11")>-1,"Mac OS":t.indexOf("Macintosh")>-1,Android:t.indexOf("Android")>-1||t.indexOf("Adr")>-1,Ubuntu:t.indexOf("Ubuntu")>-1,FreeBSD:t.indexOf("FreeBSD")>-1,Debian:t.indexOf("Debian")>-1,"Windows Phone":t.indexOf("IEMobile")>-1||t.indexOf("Windows Phone")>-1,BlackBerry:t.indexOf("BlackBerry")>-1||t.indexOf("RIM")>-1,MeeGo:t.indexOf("MeeGo")>-1,Symbian:t.indexOf("Symbian")>-1,iOS:t.indexOf("like Mac OS X")>-1,"Chrome OS":t.indexOf("CrOS")>-1,WebOS:t.indexOf("hpwOS")>-1,Mobile:t.indexOf("Mobi")>-1||t.indexOf("iPh")>-1||t.indexOf("480")>-1,Tablet:t.indexOf("Tablet")>-1||t.indexOf("Pad")>-1||t.indexOf("Nexus 7")>-1};i.Mobile?i.Mobile=!(t.indexOf("iPad")>-1):At.showModalDialog&&At.chrome&&(i["360"]=!0);var s={engine:["WebKit","Trident","Gecko","Presto"],browser:["Safari","Chrome","Edge","IE","Firefox","Firefox Focus","Chromium","Opera","Vivaldi","Yandex","Kindle","360","UC","QQBrowser","QQ","Baidu","Maxthon","Sogou","LBBROWSER","2345Explorer","TheWorld","XiaoMi","Quark","Qiyu","Wechat","Taobao","Alipay","Weibo","Douban","Suning","iQiYi"],os:["Windows","Linux","Mac OS","Android","Ubuntu","FreeBSD","Debian","iOS","Windows Phone","BlackBerry","MeeGo","Symbian","Chrome OS","WebOS"],device:["Mobile","Tablet"]};e.device="PC",e.language=function(){var b=ut.browserLanguage||ut.language,k=b.split("-");return k[1]&&(k[1]=k[1].toUpperCase()),k.join("_")}();for(var n in s)for(var o=0;o<s[n].length;o++){var p=s[n][o];i[p]&&(e[n]=p)}var f={Windows:function(){var b=t.replace(/^.*Windows NT ([\d.]+);.*$/,"$1"),k={6.4:"10",6.3:"8.1",6.2:"8",6.1:"7","6.0":"Vista",5.2:"XP",5.1:"XP","5.0":"2000"};return k[b]||b},Android:function(){return t.replace(/^.*Android ([\d.]+);.*$/,"$1")},iOS:function(){return t.replace(/^.*OS ([\d_]+) like.*$/,"$1").replace(/_/g,".")},Debian:function(){return t.replace(/^.*Debian\/([\d.]+).*$/,"$1")},"Windows Phone":function(){return t.replace(/^.*Windows Phone( OS)? ([\d.]+);.*$/,"$2")},"Mac OS":function(){return t.replace(/^.*Mac OS X ([\d_]+).*$/,"$1").replace(/_/g,".")},WebOS:function(){return t.replace(/^.*hpwOS\/([\d.]+);.*$/,"$1")}};e.osVersion="",f[e.os]&&(e.osVersion=f[e.os](),e.osVersion===t&&(e.osVersion=""));var $={Safari:function(){return t.replace(/^.*Version\/([\d.]+).*$/,"$1")},Chrome:function(){return t.replace(/^.*Chrome\/([\d.]+).*$/,"$1").replace(/^.*CriOS\/([\d.]+).*$/,"$1")},IE:function(){return t.replace(/^.*MSIE ([\d.]+).*$/,"$1").replace(/^.*rv:([\d.]+).*$/,"$1")},Edge:function(){return t.replace(/^.*Edge\/([\d.]+).*$/,"$1")},Firefox:function(){return t.replace(/^.*Firefox\/([\d.]+).*$/,"$1").replace(/^.*FxiOS\/([\d.]+).*$/,"$1")},"Firefox Focus":function(){return t.replace(/^.*Focus\/([\d.]+).*$/,"$1")},Chromium:function(){return t.replace(/^.*Chromium\/([\d.]+).*$/,"$1")},Opera:function(){return t.replace(/^.*Opera\/([\d.]+).*$/,"$1").replace(/^.*OPR\/([\d.]+).*$/,"$1")},Vivaldi:function(){return t.replace(/^.*Vivaldi\/([\d.]+).*$/,"$1")},Yandex:function(){return t.replace(/^.*YaBrowser\/([\d.]+).*$/,"$1")},Kindle:function(){return t.replace(/^.*Version\/([\d.]+).*$/,"$1")},Maxthon:function(){return t.replace(/^.*Maxthon\/([\d.]+).*$/,"$1")},QQBrowser:function(){return t.replace(/^.*QQBrowser\/([\d.]+).*$/,"$1")},QQ:function(){return t.replace(/^.*QQ\/([\d.]+).*$/,"$1")},Baidu:function(){return t.replace(/^.*BIDUBrowser[\s/]([\d.]+).*$/,"$1")},UC:function(){return t.replace(/^.*UC?Browser\/([\d.]+).*$/,"$1")},Sogou:function(){return t.replace(/^.*SE ([\d.X]+).*$/,"$1").replace(/^.*SogouMobileBrowser\/([\d.]+).*$/,"$1")},"2345Explorer":function(){return t.replace(/^.*2345Explorer\/([\d.]+).*$/,"$1")},TheWorld:function(){return t.replace(/^.*TheWorld ([\d.]+).*$/,"$1")},XiaoMi:function(){return t.replace(/^.*MiuiBrowser\/([\d.]+).*$/,"$1")},Quark:function(){return t.replace(/^.*Quark\/([\d.]+).*$/,"$1")},Qiyu:function(){return t.replace(/^.*Qiyu\/([\d.]+).*$/,"$1")},Wechat:function(){return t.replace(/^.*MicroMessenger\/([\d.]+).*$/,"$1")},Taobao:function(){return t.replace(/^.*AliApp\(TB\/([\d.]+).*$/,"$1")},Alipay:function(){return t.replace(/^.*AliApp\(AP\/([\d.]+).*$/,"$1")},Weibo:function(){return t.replace(/^.*weibo__([\d.]+).*$/,"$1")},Douban:function(){return t.replace(/^.*com.douban.frodo\/([\d.]+).*$/,"$1")},Suning:function(){return t.replace(/^.*SNEBUY-APP([\d.]+).*$/,"$1")},iQiYi:function(){return t.replace(/^.*IqiyiVersion\/([\d.]+).*$/,"$1")}};e.version="",$[e.browser]&&(e.version=$[e.browser](),e.version===t&&(e.version="")),e.version.indexOf(".")&&(e.version=e.version.substring(0,e.version.indexOf("."))),e.browser==="Edge"?e.engine="EdgeHTML":e.browser==="Chrome"&&parseInt(e.version)>27||e.browser==="Opera"&&parseInt(e.version)>12||e.browser==="Yandex"?e.engine="Blink":e.browser===void 0&&(e.browser="Unknow App")}function Bt(r){return new se(r)}var ne=`<div class="atk-comment-wrap" data-comment-id="">
|
|
81
|
+
<div class="atk-comment">
|
|
82
|
+
|
|
83
|
+
<div class="atk-avatar"></div>
|
|
84
|
+
|
|
85
|
+
<div class="atk-comment-main">
|
|
86
|
+
|
|
87
|
+
<div class="atk-header">
|
|
88
|
+
<span class="atk-nick"></span>
|
|
89
|
+
<span class="atk-badge"></span>
|
|
90
|
+
<span class="atk-date"></span>
|
|
91
|
+
</div>
|
|
92
|
+
|
|
93
|
+
<div class="atk-body">
|
|
94
|
+
<div class="atk-content"></div>
|
|
95
|
+
</div>
|
|
96
|
+
|
|
97
|
+
<div class="atk-footer">
|
|
98
|
+
<div class="atk-comment-actions"></div>
|
|
99
|
+
</div>
|
|
100
|
+
|
|
101
|
+
</div>
|
|
102
|
+
|
|
103
|
+
</div>
|
|
104
|
+
</div>
|
|
105
|
+
`;class Z{conf;$el;isLoading=!1;msgRecTimer;msgRecTimerFunc;get isMessaging(){return!!this.msgRecTimer}isConfirming=!1;confirmRecTimer;constructor(t){this.$el=m('<span class="atk-common-action-btn"></span>'),this.conf=typeof t!="object"?{text:t}:t,this.$el.innerText=this.getText(),this.conf.adminOnly&&this.$el.setAttribute("atk-only-admin-show","")}appendTo(t){return t.append(this.$el),this}getText(){return typeof this.conf.text=="string"?this.conf.text:this.conf.text()}setClick(t){this.$el.onclick=e=>{if(e.stopPropagation(),!this.isLoading){if(this.conf.confirm&&!this.isMessaging){const i=()=>{this.isConfirming=!1,this.$el.classList.remove("atk-btn-confirm"),this.$el.innerText=this.getText()};if(!this.isConfirming){this.isConfirming=!0,this.$el.classList.add("atk-btn-confirm"),this.$el.innerText=this.conf.confirmText||"\u786E\u8BA4\u64CD\u4F5C",this.confirmRecTimer=window.setTimeout(()=>i(),5e3);return}this.confirmRecTimer&&window.clearTimeout(this.confirmRecTimer),i()}if(this.msgRecTimer){this.fireMsgRecTimer(),this.clearMsgRecTimer();return}t()}}}updateText(t){t&&(this.conf.text=t),this.setLoading(!1),this.$el.innerText=this.getText()}setLoading(t=!0,e){this.isLoading!==t&&(this.isLoading=t,t?(this.$el.classList.add("atk-btn-loading"),this.$el.innerText=e||"\u52A0\u8F7D\u4E2D..."):(this.$el.classList.remove("atk-btn-loading"),this.$el.innerText=this.getText()))}setError(t){this.setMsg(t,"atk-btn-error")}setWarn(t){this.setMsg(t,"atk-btn-warn")}setSuccess(t){this.setMsg(t,"atk-btn-success")}setMsg(t,e,i,s){this.setLoading(!1),e&&this.$el.classList.add(e),this.$el.innerText=t,this.setMsgRecTimer(()=>{this.$el.innerText=this.getText(),e&&this.$el.classList.remove(e),s&&s()},i||2500)}setMsgRecTimer(t,e){this.fireMsgRecTimer(),this.clearMsgRecTimer(),this.msgRecTimerFunc=t,this.msgRecTimer=window.setTimeout(()=>{t(),this.clearMsgRecTimer()},e)}fireMsgRecTimer(){this.msgRecTimerFunc&&this.msgRecTimerFunc()}clearMsgRecTimer(){this.msgRecTimer&&window.clearTimeout(this.msgRecTimer),this.msgRecTimer=void 0,this.msgRecTimerFunc=void 0}}class ae extends H{data;$main;$header;$body;$content;$children;$actions;voteBtnUp;voteBtnDown;parent;nestedNum;maxNestingNum;children=[];replyTo;$replyTo;afterRender;unread=!1;openable=!1;openURL;openEvt;constructor(t,e){super(t);this.maxNestingNum=t.conf.maxNesting||3,this.data={...e},this.data.date=this.data.date.replace(/-/g,"/"),this.parent=null,this.nestedNum=1}render(){return this.$el=m(ne),this.$main=this.$el.querySelector(".atk-comment-main"),this.$header=this.$el.querySelector(".atk-header"),this.$body=this.$el.querySelector(".atk-body"),this.$content=this.$body.querySelector(".atk-content"),this.$actions=this.$el.querySelector(".atk-comment-actions"),this.$children=null,this.$el.setAttribute("data-comment-id",`${this.data.id}`),this.renderCheckUnread(),this.renderCheckClickable(),this.renderAvatar(),this.renderHeader(),this.renderContent(),this.renderReplyTo(),this.renderPending(),this.renderActionBtn(),this.afterRender&&this.afterRender(),this.$el}renderCheckUnread(){this.unread?this.$el.classList.add("atk-unread"):this.$el.classList.remove("atk-unread")}renderCheckClickable(){this.openable?this.$el.classList.add("atk-openable"):this.$el.classList.remove("atk-openable"),this.$el.addEventListener("click",t=>{this.openable&&this.openURL&&(t.preventDefault(),window.open(this.openURL)),this.openEvt&&this.openEvt()})}renderAvatar(){const t=this.$el.querySelector(".atk-avatar"),e=m("<img />");if(e.src=this.getGravatarUrl(),this.data.link){const i=m('<a target="_blank"></a>');i.href=this.data.link,i.append(e),t.append(i)}else t.append(e)}renderHeader(){const t=this.$el.querySelector(".atk-nick");if(this.data.link){const s=m('<a target="_blank"></a>');s.innerText=this.data.nick,s.href=this.data.link,t.append(s)}else t.innerText=this.data.nick;const e=this.$el.querySelector(".atk-badge");this.data.badge_name?(e.innerText=this.data.badge_name,this.data.badge_color&&(e.style.backgroundColor=this.data.badge_color)):e.remove();const i=this.$el.querySelector(".atk-date");if(i.innerText=this.getDateFormatted(),i.setAttribute("data-atk-comment-date",String(+new Date(this.data.date))),this.conf.uaBadge){const s=m('<span class="atk-ua-wrap"></span>'),n=m('<span class="atk-ua ua-browser"></span>'),o=m('<span class="atk-ua ua-os"></span>');n.innerText=this.getUserUaBrowser(),o.innerText=this.getUserUaOS(),s.append(n),s.append(o),this.$header.append(s)}}renderContent(){if(!this.data.is_collapsed){this.$content.innerHTML=this.getContentMarked();return}this.$content.classList.add("atk-hide","atk-type-collapsed");const t=m(`
|
|
106
|
+
<div class="atk-collapsed">
|
|
107
|
+
<span class="atk-text">\u8BE5\u8BC4\u8BBA\u5DF2\u88AB\u7CFB\u7EDF\u6216\u7BA1\u7406\u5458\u6298\u53E0</span>
|
|
108
|
+
<span class="atk-show-btn">\u67E5\u770B\u5185\u5BB9</span>
|
|
109
|
+
</div>`);this.$body.insertAdjacentElement("beforeend",t);const e=t.querySelector(".atk-show-btn");e.addEventListener("click",i=>{i.stopPropagation(),this.$content.classList.contains("atk-hide")?(this.$content.innerHTML=this.getContentMarked(),this.$content.classList.remove("atk-hide"),ct(this.$content),e.innerHTML="\u6536\u8D77\u5185\u5BB9"):(this.$content.innerHTML="",this.$content.classList.add("atk-hide"),e.innerHTML="\u67E5\u770B\u5185\u5BB9")})}renderReplyTo(){if(!this.replyTo)return;this.$replyTo=m(`
|
|
110
|
+
<div class="atk-reply-to">
|
|
111
|
+
<div class="atk-meta">\u56DE\u590D <span class="atk-nick"></span>:</div>
|
|
112
|
+
<div class="atk-content"></div>
|
|
113
|
+
</div>`),this.$replyTo.querySelector(".atk-nick").innerText=`@${this.replyTo.nick}`;let t=ot(this.ctx,this.replyTo.content);this.replyTo.is_collapsed&&(t="[\u5DF2\u6298\u53E0]"),this.$replyTo.querySelector(".atk-content").innerHTML=t,this.$body.prepend(this.$replyTo)}renderPending(){if(!this.data.is_pending)return;const t=m('<div class="atk-pending">\u5BA1\u6838\u4E2D\uFF0C\u4EC5\u672C\u4EBA\u53EF\u89C1\u3002</div>');this.$body.prepend(t)}renderActionBtn(){if(this.ctx.conf.vote&&(this.voteBtnUp=new Z(()=>`\u8D5E\u540C (${this.data.vote_up||0})`).appendTo(this.$actions),this.voteBtnUp.setClick(()=>{this.vote("up")}),this.ctx.conf.voteDown&&(this.voteBtnDown=new Z(()=>`\u53CD\u5BF9 (${this.data.vote_down||0})`).appendTo(this.$actions),this.voteBtnDown.setClick(()=>{this.vote("down")}))),this.data.is_allow_reply){const s=m('<span data-atk-action="comment-reply">\u56DE\u590D</span>');this.$actions.append(s),s.addEventListener("click",n=>{n.stopPropagation(),this.ctx.trigger("editor-reply",this.data)})}const t=new Z({text:()=>this.data.is_collapsed?"\u53D6\u6D88\u6298\u53E0":"\u6298\u53E0",adminOnly:!0});t.appendTo(this.$actions),t.setClick(()=>{this.adminEdit("collapsed",t)});const e=new Z({text:()=>this.data.is_pending?"\u5F85\u5BA1":"\u5DF2\u5BA1",adminOnly:!0});e.appendTo(this.$actions),e.setClick(()=>{this.adminEdit("pending",e)});const i=new Z({text:"\u5220\u9664",confirm:!0,confirmText:"\u786E\u8BA4\u5220\u9664",adminOnly:!0});i.appendTo(this.$actions),i.setClick(()=>{this.adminDelete(i)})}refreshUI(){const t=this.$el,e=this.render();t.replaceWith(e),this.playFadeInAnim(),this.eachComment(this.children,i=>{i.parent?.getChildrenEl().appendChild(i.render()),i.playFadeInAnim()}),this.ctx.trigger("comments-loaded")}eachComment(t,e){t.length!==0&&t.every(i=>e(i,t)===!1?!1:(this.eachComment(i.getChildren(),e),!0))}getIsRoot(){return this.parent===null}getChildren(){return this.children}putChild(t){t.parent=this,t.nestedNum=this.nestedNum+1,this.children.push(t),this.getChildrenEl().appendChild(t.getEl()),t.playFadeInAnim()}getChildrenEl(){return this.$children===null&&(this.nestedNum<this.maxNestingNum?(this.$children=m('<div class="atk-comment-children"></div>'),this.$main.appendChild(this.$children)):this.parent&&(this.$children=this.parent.getChildrenEl())),this.$children}getParent(){return this.parent}getEl(){return this.$el}getData(){return this.data}getGravatarUrl(){return St(this.ctx,this.data.email_encrypted)}getContentMarked(){return ot(this.ctx,this.data.content)}getDateFormatted(){return bt(new Date(this.data.date))}getUserUaBrowser(){const t=Bt(this.data.ua);return`${t.browser} ${t.version}`}getUserUaOS(){const t=Bt(this.data.ua);return`${t.os} ${t.osVersion}`}playFadeInAnim(){ct(this.$el)}vote(t){const e=t==="up"?this.voteBtnUp:this.voteBtnDown;new B(this.ctx).vote(this.data.id,`comment_${t}`).then(i=>{this.data.vote_up=i.up,this.data.vote_down=i.down,this.voteBtnUp?.updateText(),this.voteBtnDown?.updateText()}).catch(i=>{e?.setError("\u6295\u7968\u5931\u8D25"),console.log(i)})}adminEdit(t,e){if(e.isLoading)return;e.setLoading(!0,"\u4FEE\u6539\u4E2D...");const i={...this.data};t==="collapsed"?i.is_collapsed=!i.is_collapsed:t==="pending"&&(i.is_pending=!i.is_pending),new B(this.ctx).commentEdit(i).then(s=>{e.setLoading(!1),this.data=s,this.refreshUI(),ct(this.$body),this.ctx.trigger("list-refresh-ui")}).catch(s=>{console.error(s),e.setError("\u4FEE\u6539\u5931\u8D25")})}onDelete;adminDelete(t){t.isLoading||(t.setLoading(!0,"\u5220\u9664\u4E2D..."),new B(this.ctx).commentDel(this.data.id,this.data.site_name).then(()=>{t.setLoading(!1),this.onDelete&&this.onDelete(this)}).catch(e=>{console.error(e),t.setError("\u5220\u9664\u5931\u8D25")}))}setUnread(t){this.unread=t,this.unread?this.$el.classList.add("atk-unread"):this.$el.classList.remove("atk-unread")}setOpenURL(t){t||(this.openable=!1,this.$el.classList.remove("atk-openable")),this.openable=!0,this.openURL=t,this.$el.classList.add("atk-openable")}checkMoreHide(t,e=300){if(!t)return;let i=t?.querySelector(".atk-more-hide-open-btn");const s=()=>{t.classList.remove("atk-comment-more-hide"),i&&i.remove(),t.style.height="",t.style.overflow=""};vt(t)>e&&(t.classList.add("atk-comment-more-hide"),t.style.height=`${e}px`,t.style.overflow="hidden",i||(i=m('<div class="atk-more-hide-open-btn">\u9605\u8BFB\u66F4\u591A</span>'),i.onclick=n=>{n.stopPropagation(),s()},t.append(i)))}}var Le="";class Lt{conf;total;$el;$input;inputTimer;$prevBtn;$nextBtn;page=1;get pageSize(){return this.conf.pageSize||15}get offset(){return this.pageSize*(this.page-1)}get maxPage(){return Math.ceil(this.total/this.pageSize)}constructor(t,e){this.total=t,this.conf=e,this.$el=m(`<div class="atk-pagination-wrap">
|
|
114
|
+
<div class="atk-pagination">
|
|
115
|
+
<div class="atk-btn atk-btn-prev">Prev</div>
|
|
116
|
+
<input type="text" class="atk-input" />
|
|
117
|
+
<div class="atk-btn atk-btn-next">Next</div>
|
|
118
|
+
</div>
|
|
119
|
+
</div>`),this.$input=this.$el.querySelector(".atk-input"),this.$input.value=`${this.page}`,this.$input.oninput=()=>this.input(),this.$input.onkeydown=i=>this.keydown(i),this.$prevBtn=this.$el.querySelector(".atk-btn-prev"),this.$nextBtn=this.$el.querySelector(".atk-btn-next"),this.$prevBtn.onclick=()=>this.prev(),this.$nextBtn.onclick=()=>this.next(),this.checkDisabled()}update(t,e){this.page=Math.ceil(t/this.pageSize)+1,this.total=e,this.setInput(this.page),this.checkDisabled()}setInput(t){this.$input.value=`${t}`}input(t=!1){window.clearTimeout(this.inputTimer);const e=this.$input.value.trim(),i=()=>{if(e===""){this.setInput(this.page);return}let s=Number(e);if(Number.isNaN(s)){this.setInput(this.page);return}if(s<1){this.setInput(this.page);return}s>this.maxPage&&(this.setInput(this.maxPage),s=this.maxPage),this.change(s)};t?i():this.inputTimer=window.setTimeout(()=>i(),800)}prev(){const t=this.page-1;t<1||this.change(t)}next(){const t=this.page+1;t>this.maxPage||this.change(t)}change(t){this.page=t,this.conf.onChange(this.offset),this.setInput(t),this.checkDisabled()}checkDisabled(){this.page+1>this.maxPage?this.$nextBtn.classList.add("atk-disabled"):this.$nextBtn.classList.remove("atk-disabled"),this.page-1<1?this.$prevBtn.classList.add("atk-disabled"):this.$prevBtn.classList.remove("atk-disabled")}keydown(t){const e=t.keyCode||t.which;if(e===38){const i=Number(this.$input.value)+1;if(i>this.maxPage)return;this.setInput(i),this.input()}else if(e===40){const i=Number(this.$input.value)-1;if(i<1)return;this.setInput(i),this.input()}else e===13&&this.input(!0)}setLoading(t){t?I(this.$el):P(this.$el)}}class re{conf;$el;$loading;$text;constructor(t){this.conf=t,this.$el=m(`<div class="atk-list-read-more" style="display: none;">
|
|
120
|
+
<div class="atk-list-read-more-inner">
|
|
121
|
+
<div class="atk-loading-icon" style="display: none;"></div>
|
|
122
|
+
<span class="atk-text">\u67E5\u770B\u66F4\u591A</span>
|
|
123
|
+
</div>
|
|
124
|
+
</div>`),this.$loading=this.$el.querySelector(".atk-loading-icon"),this.$text=this.$el.querySelector(".atk-text"),this.$el.onclick=()=>this.click()}click(){this.conf.onClick()}show(){this.$el.style.display=""}hide(){this.$el.style.display="none"}setLoading(t){this.$loading.style.display=t?"":"none",this.$text.style.display=t?"none":""}showErr(t){this.setLoading(!1),this.$text.innerText=t,this.$el.classList.add("atk-err"),window.setTimeout(()=>{this.$text.innerText="\u67E5\u770B\u66F4\u591A",this.$el.classList.remove("atk-err")},2e3)}}class Ft extends H{$parent;$commentsWrap;comments=[];data;pageSize=15;offset=0;type;noCommentText;renderComment;paramsEditor;onAfterLoad;isLoading=!1;isFirstLoad=!0;flatMode;pageMode="pagination";pagination;readMoreBtn;autoLoadScrollEvent;autoLoadListenerAt;unread=[];unreadHighlight=!1;constructor(t,e){super(t);this.$parent=e,this.$el=m(`<div class="atk-list-lite">
|
|
125
|
+
<div class="atk-list-comments-wrap"></div>
|
|
126
|
+
</div>`),this.$commentsWrap=this.$el.querySelector(".atk-list-comments-wrap"),this.pageSize=this.conf.pagination?this.conf.pagination.pageSize||this.pageSize:this.pageSize,this.noCommentText=this.conf.noComment||"\u65E0\u8BC4\u8BBA",window.setInterval(()=>{this.$el.querySelectorAll("[data-atk-comment-date]").forEach(i=>{const s=i.getAttribute("data-atk-comment-date");i.innerText=bt(new Date(Number(s)))})},30*1e3),this.ctx.on("unread-update",i=>this.updateUnread(i.notifies))}async reqComments(t=0){t===0&&this.pageMode!=="pagination"&&this.clearAllComments();const e=()=>{this.isLoading=!0,t===0?I(this.$el):this.pageMode==="read-more"?this.readMoreBtn.setLoading(!0):this.pageMode==="pagination"&&this.pagination.setLoading(!0)},i=()=>{this.isLoading=!1,t===0?P(this.$el):this.pageMode==="read-more"?this.readMoreBtn.setLoading(!1):this.pageMode==="pagination"&&this.pagination.setLoading(!1)};e(),this.ctx.trigger("comments-load");let s;try{s=await new B(this.ctx).get(t,this.type,this.flatMode,this.paramsEditor)}catch(n){throw this.onError(n.msg||String(n)),n}finally{i()}if(!(this.ctx.conf.versionCheck&&this.apiVersionCheck(s.api_version||{}))){this.offset=t;try{this.onLoad(s,t),this.onAfterLoad&&this.onAfterLoad(s)}catch(n){throw this.onError(String(n)),n}finally{i()}}}onLoad(t,e){Y(this.$el,null),this.pageMode==="pagination"&&this.clearAllComments(),this.data=t,this.importComments(t.comments),this.isFirstLoad&&this.onLoadInit(),this.pageMode==="pagination"&&this.pagination.update(e,this.data?.total_parents||0),this.pageMode==="read-more"&&(this.hasMoreComments?this.readMoreBtn.show():this.readMoreBtn.hide()),this.ctx.trigger("unread-update",{notifies:t.unread||[]}),this.isFirstLoad=!1}onLoadInit(){if(this.autoLoadScrollEvent&&(this.autoLoadListenerAt||document).removeEventListener("scroll",this.autoLoadScrollEvent),this.pageMode==="read-more"){const t=new re({pageSize:this.pageSize,total:0,onClick:async()=>{const e=this.offset+this.pageSize;await this.reqComments(e)}});this.readMoreBtn?this.readMoreBtn.$el.replaceWith(t.$el):this.$el.append(t.$el),this.readMoreBtn=t,this.conf.pagination?.autoLoad&&(this.autoLoadScrollEvent=()=>{if(this.pageMode!=="read-more"||!this.hasMoreComments||this.isLoading)return;const i=this.$el.querySelector(".atk-list-comments-wrap > .atk-comment-wrap:nth-last-child(3)");!i||Ht(i,this.autoLoadListenerAt)&&this.readMoreBtn.click()},(this.autoLoadListenerAt||document).addEventListener("scroll",this.autoLoadScrollEvent))}else if(this.pageMode==="pagination"){const t=new Lt(this.parentCommentsCount,{pageSize:this.pageSize,onChange:async e=>{if(await this.reqComments(e),this.$parent){let i=0;!this.autoLoadListenerAt&&this.$parent&&(i=xt(this.$parent).top),(this.autoLoadListenerAt||window).scroll({top:i,left:0})}}});this.pagination?this.pagination.$el.replaceWith(t.$el):this.$el.append(t.$el),this.pagination=t}}onError(t){if(t=String(t),console.error(t),this.isFirstLoad||this.pageMode==="pagination"){const e=m(`<span>${t}\uFF0C\u65E0\u6CD5\u83B7\u53D6\u8BC4\u8BBA\u5217\u8868\u6570\u636E<br/></span>`),i=m('<span style="cursor:pointer;">\u70B9\u51FB\u91CD\u65B0\u83B7\u53D6</span>');i.onclick=()=>{this.reqComments(this.offset)},e.appendChild(i);const s=m('<span atk-only-admin-show> | <span style="cursor:pointer;">\u6253\u5F00\u63A7\u5236\u53F0</span></span>');s.onclick=()=>{this.ctx.trigger("sidebar-show")},this.ctx.user.data.isAdmin||s.classList.add("atk-hide"),e.appendChild(s),Y(this.$el,e)}else this.readMoreBtn?.showErr("\u83B7\u53D6\u5931\u8D25")}refreshUI(){const t=this.comments.length<=0;let e=this.$commentsWrap.querySelector(".atk-list-no-comment");t&&(e||(e=m('<div class="atk-list-no-comment"></div>'),this.$commentsWrap.appendChild(e),e.innerHTML=this.noCommentText)),!t&&e&&e.remove(),this.ctx.trigger("check-admin-show-el")}createComment(t){const e=new ae(this.ctx,t);return e.afterRender=()=>{this.renderComment&&this.renderComment(e)},e.onDelete=i=>{this.deleteComment(i),this.refreshUI()},e}importComments(t){const e=i=>{const s=t.filter(n=>n.rid===i.data.id);s.length!==0&&s.forEach(n=>{n.is_allow_reply=i.data.is_allow_reply;const o=this.createComment(n);o.render(),i.putChild(o),e(o)})};this.flatMode?t.forEach(i=>{this.putCommentFlatMode(i,t,"append")}):t.filter(i=>i.rid===0).forEach(i=>{i.is_collapsed&&(i.is_allow_reply=!1);const s=this.createComment(i);s.render(),this.comments.push(s),this.$commentsWrap.appendChild(s.getEl()),s.playFadeInAnim(),e(s)}),this.eachComment(this.comments,i=>{this.checkMoreHide(i)}),this.refreshUI(),this.ctx.trigger("comments-loaded")}putCommentFlatMode(t,e,i){t.is_collapsed&&(t.is_allow_reply=!1);const s=this.createComment(t);if(t.rid!==0){const n=e.find(o=>o.id===t.rid);n&&(s.replyTo=n)}s.render(),i==="append"?this.comments.push(s):this.comments.unshift(s),t.visible&&(i==="append"?this.$commentsWrap.appendChild(s.getEl()):this.$commentsWrap.prepend(s.getEl()),s.playFadeInAnim()),this.checkMoreHide(s)}insertComment(t){if(this.flatMode)this.putCommentFlatMode(t,this.comments.map(e=>e.data),"prepend");else{const e=this.createComment(t);e.render(),t.rid!==0?this.findComment(t.rid)?.putChild(e):(this.$commentsWrap.prepend(e.getEl()),this.comments.unshift(e)),lt(e.getEl()),e.playFadeInAnim(),this.checkMoreHide(e)}this.data&&(this.data.total+=1),this.refreshUI(),this.ctx.trigger("comments-loaded")}checkMoreHide(t){const e=this.ctx.conf.heightLimit?.children,i=this.ctx.conf.heightLimit?.content,s=typeof e=="number"&&e>0,n=typeof i=="number"&&i>0;s&&t.getIsRoot()&&t.checkMoreHide(t.$children,e||300),n&&(t.checkMoreHide(t.$content,i||200),t.$replyTo&&t.checkMoreHide(t.$replyTo,i||200))}get commentsCount(){return Number(this.data?.total)||0}get parentCommentsCount(){return Number(this.data?.total_parents)||0}get hasMoreComments(){return this.data?this.data.total_parents>this.offset+this.pageSize:!1}eachComment(t,e){t.length!==0&&t.every(i=>e(i,t)===!1?!1:(this.eachComment(i.getChildren(),e),!0))}findComment(t,e){e||(e=this.comments);let i=null;return this.eachComment(e,s=>s.data.id===t?(i=s,!1):!0),i}getCommentCount(){let t=0;return this.eachComment(this.comments,()=>{t++}),t}deleteComment(t){let e;if(typeof t=="number"){if(e=this.findComment(t),!e)throw Error(`\u672A\u627E\u5230\u8BC4\u8BBA ${t}`)}else e=t;e.getEl().remove(),this.eachComment(this.comments,(i,s)=>i===e?(s.splice(s.indexOf(i),1),!1):!0),this.refreshUI()}clearAllComments(){this.$commentsWrap.innerHTML="",this.data=void 0,this.comments=[]}updateUnread(t){this.unread=t,this.unreadHighlight&&this.eachComment(this.comments,e=>{const i=this.unread.find(s=>s.comment_id===e.data.id);i?(e.setUnread(!0),e.setOpenURL(i.read_link),e.openEvt=()=>{this.unread=this.unread.filter(s=>s.comment_id!==e.data.id),this.ctx.trigger("unread-update",{notifies:this.unread})}):e.setUnread(!1)})}apiVersionCheck(t){const e=t?.fe_min_version||"0.0.0",i=Nt(e,"2.1.1")===1;if(i){const s=m(`<div>\u524D\u7AEF Artalk \u7248\u672C\u5DF2\u8FC7\u65F6\uFF0C\u8BF7\u66F4\u65B0\u4EE5\u83B7\u5F97\u5B8C\u6574\u4F53\u9A8C<br/>\u82E5\u60A8\u662F\u7AD9\u70B9\u7BA1\u7406\u5458\uFF0C\u8BF7\u524D\u5F80 \u201C<a href="https://artalk.js.org/" target="_blank">\u5B98\u65B9\u6587\u6863</a>\u201D \u83B7\u53D6\u5E2E\u52A9<br/><br/><span style="color: var(--at-color-meta);">\u524D\u7AEF\u7248\u672C 2.1.1\uFF0C\u9700\u6C42\u7248\u672C >= ${e}</span><br/><br/></div>`),n=m('<span style="cursor:pointer;">\u5FFD\u7565</span>');n.onclick=()=>{Y(this.ctx,null),this.ctx.conf.versionCheck=!1,this.reqComments(0)},s.append(n),Y(this.ctx,s,'<span class="atk-warn-title">Artalk Warn</span>')}return i}}class oe extends Ft{$closeCommentBtn;$openSidebarBtn;$unreadBadge;constructor(t){const e=m(ie);super(t,e);e.querySelector(".atk-list-body").append(this.$el),this.$el=e;let i=!1;this.ctx.conf.flatMode==="auto"?window.matchMedia("(max-width: 768px)").matches&&(i=!0):this.ctx.conf.flatMode===!0&&(i=!0),this.flatMode=i,this.pageMode=this.conf.pagination?.readMore?"read-more":"pagination",this.initListActionBtn(),this.$el.querySelector(".atk-copyright").innerHTML='Powered By <a href="https://artalk.js.org" target="_blank" title="Artalk v2.1.1">Artalk</a>',this.ctx.on("list-reload",()=>this.reqComments(0)),this.ctx.on("list-refresh-ui",()=>this.refreshUI()),this.ctx.on("list-import",s=>this.importComments(s)),this.ctx.on("list-insert",s=>this.insertComment(s)),this.ctx.on("list-delete",s=>this.deleteComment(s.id)),this.ctx.on("list-update",s=>{s(this.data),this.refreshUI()}),this.ctx.on("unread-update",s=>this.showUnreadBadge(s.notifies?.length||0))}initListActionBtn(){this.$openSidebarBtn=this.$el.querySelector('[data-action="open-sidebar"]'),this.$closeCommentBtn=this.$el.querySelector('[data-action="admin-close-comment"]'),this.$unreadBadge=this.$el.querySelector(".atk-unread-badge"),this.$openSidebarBtn.addEventListener("click",()=>{this.ctx.trigger("sidebar-show")}),this.$closeCommentBtn.addEventListener("click",()=>{!this.data||(this.data.page.admin_only=!this.data.page.admin_only,this.adminPageEditSave())})}refreshUI(){super.refreshUI(),this.$el.querySelector(".atk-comment-count-num").innerText=String(this.commentsCount),!!this.ctx.user.data.nick&&!!this.ctx.user.data.email?this.$openSidebarBtn.classList.remove("atk-hide"):this.$openSidebarBtn.classList.add("atk-hide"),this.ctx.trigger("check-admin-show-el"),this.$openSidebarBtn.innerText=this.ctx.user.data.isAdmin?"\u63A7\u5236\u4E2D\u5FC3":"\u901A\u77E5\u4E2D\u5FC3",!!this.data&&!!this.data.page&&this.data.page.admin_only===!0?(this.ctx.trigger("editor-close"),this.$closeCommentBtn.innerHTML="\u6253\u5F00\u8BC4\u8BBA"):(this.ctx.trigger("editor-open"),this.$closeCommentBtn.innerHTML="\u5173\u95ED\u8BC4\u8BBA")}onLoad(t,e){super.onLoad(t,e),this.checkGoToCommentByUrlHash()}async checkGoToCommentByUrlHash(){let t=Number(wt("atk_comment"));if(!t){const s=window.location.hash.match(/#atk-comment-([0-9]+)/);if(!s||!s[1]||Number.isNaN(Number(s[1])))return;t=Number(s[1])}if(!t)return;const e=wt("atk_notify_key");e&&new B(this.ctx).markRead(e).then(()=>{this.unread=this.unread.filter(s=>s.comment_id!==t),this.ctx.trigger("unread-update",{notifies:this.unread})});const i=this.findComment(t);!i||(lt(i.getEl(),!1),window.setTimeout(()=>{i.getEl().classList.add("atk-flash-once")},800))}adminPageEditSave(){!this.data||!this.data.page||(this.ctx.trigger("editor-show-loading"),new B(this.ctx).pageEdit(this.data.page).then(t=>{this.data&&(this.data.page={...t}),this.refreshUI()}).catch(t=>{this.ctx.trigger("editor-notify",{msg:`\u4FEE\u6539\u9875\u9762\u6570\u636E\u5931\u8D25\uFF1A${t.msg||String(t)}`,type:"e"})}).finally(()=>{this.ctx.trigger("editor-hide-loading")}))}showUnreadBadge(t){t>0?(this.$unreadBadge.innerText=`${Number(t||0)}`,this.$unreadBadge.style.display="block"):this.$unreadBadge.style.display="none"}}var Fe="",le=function(r){var t=ce(ue(de(he(r),8*r.length)));return t.toLowerCase()};function ce(r){for(var t,e="0123456789ABCDEF",i="",s=0;s<r.length;s++)t=r.charCodeAt(s),i+=e.charAt(t>>>4&15)+e.charAt(15&t);return i}function he(r){for(var t=Array(r.length>>2),e=0;e<t.length;e++)t[e]=0;for(e=0;e<8*r.length;e+=8)t[e>>5]|=(255&r.charCodeAt(e/8))<<e%32;return t}function ue(r){for(var t="",e=0;e<32*r.length;e+=8)t+=String.fromCharCode(r[e>>5]>>>e%32&255);return t}function de(r,t){r[t>>5]|=128<<t%32,r[14+(t+64>>>9<<4)]=t;for(var e=1732584193,i=-271733879,s=-1732584194,n=271733878,o=0;o<r.length;o+=16){var p=e,f=i,$=s,b=n;i=R(i=R(i=R(i=R(i=O(i=O(i=O(i=O(i=M(i=M(i=M(i=M(i=D(i=D(i=D(i=D(i,s=D(s,n=D(n,e=D(e,i,s,n,r[o+0],7,-680876936),i,s,r[o+1],12,-389564586),e,i,r[o+2],17,606105819),n,e,r[o+3],22,-1044525330),s=D(s,n=D(n,e=D(e,i,s,n,r[o+4],7,-176418897),i,s,r[o+5],12,1200080426),e,i,r[o+6],17,-1473231341),n,e,r[o+7],22,-45705983),s=D(s,n=D(n,e=D(e,i,s,n,r[o+8],7,1770035416),i,s,r[o+9],12,-1958414417),e,i,r[o+10],17,-42063),n,e,r[o+11],22,-1990404162),s=D(s,n=D(n,e=D(e,i,s,n,r[o+12],7,1804603682),i,s,r[o+13],12,-40341101),e,i,r[o+14],17,-1502002290),n,e,r[o+15],22,1236535329),s=M(s,n=M(n,e=M(e,i,s,n,r[o+1],5,-165796510),i,s,r[o+6],9,-1069501632),e,i,r[o+11],14,643717713),n,e,r[o+0],20,-373897302),s=M(s,n=M(n,e=M(e,i,s,n,r[o+5],5,-701558691),i,s,r[o+10],9,38016083),e,i,r[o+15],14,-660478335),n,e,r[o+4],20,-405537848),s=M(s,n=M(n,e=M(e,i,s,n,r[o+9],5,568446438),i,s,r[o+14],9,-1019803690),e,i,r[o+3],14,-187363961),n,e,r[o+8],20,1163531501),s=M(s,n=M(n,e=M(e,i,s,n,r[o+13],5,-1444681467),i,s,r[o+2],9,-51403784),e,i,r[o+7],14,1735328473),n,e,r[o+12],20,-1926607734),s=O(s,n=O(n,e=O(e,i,s,n,r[o+5],4,-378558),i,s,r[o+8],11,-2022574463),e,i,r[o+11],16,1839030562),n,e,r[o+14],23,-35309556),s=O(s,n=O(n,e=O(e,i,s,n,r[o+1],4,-1530992060),i,s,r[o+4],11,1272893353),e,i,r[o+7],16,-155497632),n,e,r[o+10],23,-1094730640),s=O(s,n=O(n,e=O(e,i,s,n,r[o+13],4,681279174),i,s,r[o+0],11,-358537222),e,i,r[o+3],16,-722521979),n,e,r[o+6],23,76029189),s=O(s,n=O(n,e=O(e,i,s,n,r[o+9],4,-640364487),i,s,r[o+12],11,-421815835),e,i,r[o+15],16,530742520),n,e,r[o+2],23,-995338651),s=R(s,n=R(n,e=R(e,i,s,n,r[o+0],6,-198630844),i,s,r[o+7],10,1126891415),e,i,r[o+14],15,-1416354905),n,e,r[o+5],21,-57434055),s=R(s,n=R(n,e=R(e,i,s,n,r[o+12],6,1700485571),i,s,r[o+3],10,-1894986606),e,i,r[o+10],15,-1051523),n,e,r[o+1],21,-2054922799),s=R(s,n=R(n,e=R(e,i,s,n,r[o+8],6,1873313359),i,s,r[o+15],10,-30611744),e,i,r[o+6],15,-1560198380),n,e,r[o+13],21,1309151649),s=R(s,n=R(n,e=R(e,i,s,n,r[o+4],6,-145523070),i,s,r[o+11],10,-1120210379),e,i,r[o+2],15,718787259),n,e,r[o+9],21,-343485551),e=V(e,p),i=V(i,f),s=V(s,$),n=V(n,b)}return Array(e,i,s,n)}function st(r,t,e,i,s,n){return V(pe(V(V(t,r),V(i,n)),s),e)}function D(r,t,e,i,s,n,o){return st(t&e|~t&i,r,t,s,n,o)}function M(r,t,e,i,s,n,o){return st(t&i|e&~i,r,t,s,n,o)}function O(r,t,e,i,s,n,o){return st(t^e^i,r,t,s,n,o)}function R(r,t,e,i,s,n,o){return st(e^(t|~i),r,t,s,n,o)}function V(r,t){var e=(65535&r)+(65535&t);return(r>>16)+(t>>16)+(e>>16)<<16|65535&e}function pe(r,t){return r<<t|r>>>32-t}var fe=`<div class="atk-sidebar">
|
|
127
|
+
<div class="atk-sidebar-inner">
|
|
128
|
+
<div class="atk-sidebar-header">
|
|
129
|
+
<span class="atk-avatar">
|
|
130
|
+
<span class="atk-site-logo"></span>
|
|
131
|
+
</span>
|
|
132
|
+
<span class="atk-menu">
|
|
133
|
+
<span class="atk-item atk-active atk-sidebar-title">\u63A7\u5236\u4E2D\u5FC3</span>
|
|
134
|
+
</span>
|
|
135
|
+
<div class="atk-sidebar-close"><i class="atk-icon atk-icon-close"></i></div>
|
|
136
|
+
</div>
|
|
137
|
+
<div class="atk-sidebar-nav">
|
|
138
|
+
<div class="akt-curt-view-btn">
|
|
139
|
+
<div class="atk-icon"><span></span><span></span><span></span></div>
|
|
140
|
+
<div class="atk-text"></div>
|
|
141
|
+
</div>
|
|
142
|
+
<div class="atk-tabs"></div>
|
|
143
|
+
<div class="atk-tabs atk-views" style="display: none;"></div>
|
|
144
|
+
</div>
|
|
145
|
+
<div class="atk-sidebar-view-wrap"></div>
|
|
146
|
+
</div>
|
|
147
|
+
</div>
|
|
148
|
+
`;class nt extends H{static viewName="";static viewTitle="";static viewAdminOnly=!1;viewTabs={};viewActiveTab="";$parent;constructor(t,e){super(t);this.$parent=e,this.$el=m('<div class="atk-sidebar-view"></div>')}mount(t){}switchTab(t,e){}}class me extends nt{static viewName="comments";static viewTitle="\u8BC4\u8BBA";viewTabs={};viewActiveTab="";list;mount(t){this.ctx.user.data.isAdmin?(this.viewTabs={admin_all:"\u5168\u90E8",admin_pending:"\u5F85\u5BA1",all:"\u4E2A\u4EBA"},this.viewActiveTab="admin_all"):(this.viewTabs={mentions:"\u63D0\u53CA",all:"\u5168\u90E8",mine:"\u6211\u7684",pending:"\u5F85\u5BA1"},this.viewActiveTab="mentions"),this.list=new Ft(this.ctx,this.$el),this.list.flatMode=!0,this.list.unreadHighlight=!0,this.list.autoLoadListenerAt=this.$parent,this.list.pageMode="pagination",this.list.noCommentText='<div class="atk-sidebar-no-content">\u65E0\u5185\u5BB9</div>',this.list.renderComment=e=>{e.setOpenURL(`${e.data.page_key}#atk-comment-${e.data.id}`)},this.list.paramsEditor=e=>{e.site_name=t},this.$el.innerHTML="",this.$el.append(this.list.$el),this.switchTab(this.viewActiveTab,t)}switchTab(t,e){return this.viewActiveTab=t,this.list.type=t,this.list.isFirstLoad=!0,this.list.paramsEditor=i=>{i.site_name=e},this.list.reqComments(),!0}}var _e="",qe="";class _t{conf;$el;$input;$yesBtn;$noBtn;value="";allowSubmit=!0;constructor(t){this.conf=t,this.$el=m(`<div class="atk-item-text-editor-layer">
|
|
149
|
+
<div class="atk-edit-form">
|
|
150
|
+
<input class="atk-main-input" type="text" placeholder="\u8F93\u5165\u5185\u5BB9..." autocomplete="off" autofocus>
|
|
151
|
+
</div>
|
|
152
|
+
<div class="atk-actions">
|
|
153
|
+
<div class="atk-item atk-yes-btn">
|
|
154
|
+
<i class="atk-icon atk-icon-yes"></i>
|
|
155
|
+
</div>
|
|
156
|
+
<div class="atk-item atk-no-btn">
|
|
157
|
+
<i class="atk-icon atk-icon-no"></i>
|
|
158
|
+
</div>
|
|
159
|
+
</div>
|
|
160
|
+
</div>`),this.$input=this.$el.querySelector(".atk-main-input"),this.$yesBtn=this.$el.querySelector(".atk-yes-btn"),this.$noBtn=this.$el.querySelector(".atk-no-btn"),this.$input.value=t.initValue||"",this.value=t.initValue||"",this.conf.placeholder&&(this.$input.placeholder=this.conf.placeholder),this.$input.oninput=()=>this.onInput(),this.$input.onkeyup=e=>{(e.key==="Enter"||e.keyCode===13)&&(e.preventDefault(),this.submit())},window.setTimeout(()=>this.$input.focus(),80),this.$yesBtn.onclick=()=>{this.submit()},this.$noBtn.onclick=()=>{this.cancel()}}appendTo(t){return t.append(this.$el),this}onInput(){if(this.value=this.$input.value,this.conf.validator){const t=this.conf.validator(this.value);this.setAllowSubmit(t),t?this.$input.classList.remove("atk-invalid"):this.$input.classList.add("atk-invalid")}}setAllowSubmit(t){this.allowSubmit!==t&&(this.allowSubmit=t,t?this.$yesBtn.classList.remove(".atk-disabled"):this.$yesBtn.classList.add(".atk-disabled"))}async submit(){if(!!this.allowSubmit)if(this.conf.onYes){let t;this.conf.onYes instanceof(async()=>{}).constructor?t=await this.conf.onYes(this.value):t=this.conf.onYes(this.value),(t===void 0||t===!0)&&this.closeEditor()}else this.closeEditor()}async cancel(){if(this.conf.onNo){let t;this.conf.onNo instanceof(async()=>{}).constructor?t=await this.conf.onNo():t=this.conf.onNo(),(t===void 0||t===!0)&&this.closeEditor()}else this.closeEditor()}closeEditor(){this.$el.remove()}}class ge extends H{$editor;$inputer;pages=[];constructor(t){super(t);this.$el=m('<div class="atk-page-list"></div>')}clearAll(){this.pages=[],this.$el.innerHTML=""}importPages(t){this.pages.push(...t),t.forEach(e=>{const i=this.renderPage(e);this.$el.append(i)})}renderPage(t){const e=m(`<div class="atk-page-item">
|
|
161
|
+
<div class="atk-page-main">
|
|
162
|
+
<div class="atk-title"></div>
|
|
163
|
+
<div class="atk-sub"></div>
|
|
164
|
+
</div>
|
|
165
|
+
<div class="atk-page-actions">
|
|
166
|
+
<div class="atk-item atk-edit-btn">
|
|
167
|
+
<i class="atk-icon atk-icon-edit"></i>
|
|
168
|
+
</div>
|
|
169
|
+
</div>
|
|
170
|
+
</div>`),i=e.querySelector(".atk-page-main"),s=i.querySelector(".atk-title"),n=i.querySelector(".atk-sub"),o=e.querySelector(".atk-edit-btn");return s.innerText=t.title,n.innerText=t.url||t.key,o.onclick=()=>this.showEditor(t,e),e}showEditor(t,e){this.closeEditor(),this.$editor=m(`<div class="atk-page-edit-layer">
|
|
171
|
+
<div class="atk-page-main-actions">
|
|
172
|
+
<div class="atk-item atk-title-edit-btn">\u6807\u9898\u4FEE\u6539</div>
|
|
173
|
+
<div class="atk-item atk-key-edit-btn">KEY \u53D8\u66F4</div>
|
|
174
|
+
<div class="atk-item atk-admin-only-btn"></div>
|
|
175
|
+
</div>
|
|
176
|
+
<div class="atk-page-actions">
|
|
177
|
+
<div class="atk-item atk-sync-btn">
|
|
178
|
+
<i class="atk-icon atk-icon-sync"></i>
|
|
179
|
+
</div>
|
|
180
|
+
<div class="atk-item atk-del-btn">
|
|
181
|
+
<i class="atk-icon atk-icon-del"></i>
|
|
182
|
+
</div>
|
|
183
|
+
<div class="atk-item atk-close-btn">
|
|
184
|
+
<i class="atk-icon atk-icon-close"></i>
|
|
185
|
+
</div>
|
|
186
|
+
</div>
|
|
187
|
+
</div>`),e.prepend(this.$editor);const i=this.$editor.querySelector(".atk-title-edit-btn"),s=this.$editor.querySelector(".atk-key-edit-btn"),n=this.$editor.querySelector(".atk-admin-only-btn"),o=this.$editor.querySelector(".atk-sync-btn"),p=this.$editor.querySelector(".atk-del-btn"),f=this.$editor.querySelector(".atk-close-btn"),$=()=>{I(this.$editor)},b=()=>{P(this.$editor)},k=E=>{window.alert(E)};f.onclick=()=>this.closeEditor();const F=E=>{const L=new _t({initValue:t[E]||"",onYes:async _=>{I(L.$el);let C;try{C=await new B(this.ctx).pageEdit({...t,[E]:_})}catch(x){return k(`\u4FEE\u6539\u5931\u8D25\uFF1A${x.msg||"\u672A\u77E5\u9519\u8BEF"}`),console.error(x),!1}finally{P(L.$el)}return e.replaceWith(this.renderPage(C)),!0}});L.appendTo(this.$editor)};i.onclick=()=>F("title"),s.onclick=()=>F("key");const S=new Z({text:()=>(n.classList.remove("atk-green","atk-yellow"),n.classList.add(t.admin_only?"atk-yellow":"atk-green"),t.admin_only?"\u7BA1\u7406\u5458\u53EF\u8BC4":"\u6240\u6709\u4EBA\u53EF\u8BC4")}).appendTo(n);n.onclick=async()=>{$();let E;try{E=await new B(this.ctx).pageEdit({...t,admin_only:!t.admin_only})}catch(L){k(`\u4FEE\u6539\u5931\u8D25\uFF1A${L.msg||"\u672A\u77E5\u9519\u8BEF"}`),console.log(L);return}finally{b()}t.admin_only=E.admin_only,S.updateText()},o.onclick=async()=>{$();let E;try{E=await new B(this.ctx).pageFetch(t.id)}catch(L){k(`\u540C\u6B65\u5931\u8D25\uFF1A${L.msg||"\u672A\u77E5\u9519\u8BEF"}`),console.log(L);return}finally{b()}e.replaceWith(this.renderPage(E))},p.onclick=()=>{const E=async()=>{$();try{await new B(this.ctx).pageDel(t.key,t.site_name)}catch(L){console.log(L),k(`\u5220\u9664\u5931\u8D25 ${String(L)}`);return}finally{b()}e.remove()};window.confirm(`\u786E\u8BA4\u5220\u9664\u9875\u9762 "${t.title||t.key}"\uFF1F\u5C06\u4F1A\u5220\u9664\u6240\u6709\u76F8\u5173\u6570\u636E`)&&E()}}closeEditor(){!this.$editor||this.$editor.remove()}}const qt=20;class ke extends nt{static viewName="pages";static viewTitle="\u9875\u9762";static viewAdminOnly=!0;viewTabs={};viewActiveTab="";pageList;pagination;mount(t){this.pageList||(this.pageList=new ge(this.ctx),this.$el.append(this.pageList.$el)),this.switchTab(this.viewActiveTab,t)}switchTab(t,e){this.reqPages(e,0)}async reqPages(t,e){this.pageList.clearAll(),this.$el.parentNode?.scrollTo(0,0),I(this.$el);const i=await new B(this.ctx).pageGet(t,e,qt);this.pageList.importPages(i.pages||[]),P(this.$el),this.pagination||(this.pagination=new Lt(i.total,{pageSize:qt,onChange:s=>{this.reqPages(t,s)}}),this.$el.append(this.pagination.$el)),this.pagination&&e===0&&this.pagination.update(e,i.total)}}var De="";class $e extends H{sites=[];$header;$headerTitle;$headerActions;$rowsWrap;$editor;activeSite="";$add;constructor(t){super(t);this.$el=m(`<div class="atk-site-list">
|
|
188
|
+
<div class="atk-header">
|
|
189
|
+
<div class="atk-title"></div>
|
|
190
|
+
<div class="atk-actions">
|
|
191
|
+
<div class="atk-item atk-site-add-btn"><i class="atk-icon atk-icon-plus"></i></div>
|
|
192
|
+
</div>
|
|
193
|
+
</div>
|
|
194
|
+
<div class="atk-site-rows-wrap"></div>
|
|
195
|
+
</div>`),this.$header=this.$el.querySelector(".atk-header"),this.$headerTitle=this.$header.querySelector(".atk-title"),this.$headerActions=this.$header.querySelector(".atk-actions"),this.$rowsWrap=this.$el.querySelector(".atk-site-rows-wrap"),this.$headerTitle.innerText="\u5171 0 \u4E2A\u7AD9\u70B9";const e=this.$headerActions.querySelector(".atk-site-add-btn");e.onclick=()=>{this.closeEditor(),this.showAdd()}}loadSites(t){this.sites=t,this.activeSite="",this.$rowsWrap.innerHTML="",this.$headerTitle.innerText="\u5171 0 \u4E2A\u7AD9\u70B9";let e;for(let i=0;i<t.length;i++){const s=t[i];i%4==0&&(e=m('<div class="atk-site-row">'),this.$rowsWrap.append(e));const n=this.renderSite(s,e);e.append(n)}this.$headerTitle.innerText=`\u5171 ${t.length} \u4E2A\u7AD9\u70B9`}renderSite(t,e){const i=m(`<div class="atk-site-item">
|
|
196
|
+
<div class="atk-site-logo"></div>
|
|
197
|
+
<div class="atk-site-name"></div>
|
|
198
|
+
</div>`),s=i.querySelector(".atk-site-logo"),n=i.querySelector(".atk-site-name"),o=()=>{i.classList.add("atk-active")};return s.innerText=t.name.substr(0,1),n.innerText=t.name,i.onclick=()=>{this.closeEditor(),this.closeAdd(),o(),this.showEditor(t,i,e)},this.activeSite===t.name&&o(),i}showEditor(t,e,i){this.activeSite=t.name,this.$editor=m(`
|
|
199
|
+
<div class="atk-site-edit">
|
|
200
|
+
<div class="atk-header">
|
|
201
|
+
<div class="atk-site-info">
|
|
202
|
+
<span class="atk-site-name"></span>
|
|
203
|
+
<span class="atk-site-urls"></span>
|
|
204
|
+
</div>
|
|
205
|
+
<div class="atk-close-btn">
|
|
206
|
+
<i class="atk-icon atk-icon-close"></i>
|
|
207
|
+
</div>
|
|
208
|
+
</div>
|
|
209
|
+
<div class="atk-main">
|
|
210
|
+
<div class="atk-site-text-actions">
|
|
211
|
+
<div class="atk-item atk-rename-btn">\u91CD\u547D\u540D</div>
|
|
212
|
+
<div class="atk-item atk-edit-url-btn">\u4FEE\u6539 URL</div>
|
|
213
|
+
<!--<div class="atk-item atk-export-btn">\u5BFC\u51FA</div>
|
|
214
|
+
<div class="atk-item atk-import-btn">\u5BFC\u5165</div>-->
|
|
215
|
+
</div>
|
|
216
|
+
<div class="atk-site-btn-actions">
|
|
217
|
+
<div class="atk-item atk-del-btn">
|
|
218
|
+
<i class="atk-icon atk-icon-del"></i>
|
|
219
|
+
</div>
|
|
220
|
+
</div>
|
|
221
|
+
</div>
|
|
222
|
+
</div>`),i.before(this.$editor);const s=this.$editor.querySelector(".atk-site-name"),n=this.$editor.querySelector(".atk-site-urls"),o=this.$editor.querySelector(".atk-close-btn");o.onclick=()=>this.closeEditor();const p=C=>{t=C,s.innerText=t.name,s.onclick=()=>{t.first_url&&window.open(t.first_url)},n.innerHTML="",t.urls?.forEach(x=>{const T=m('<span class="atk-url-item"></span>');n.append(T),T.innerText=(x||"").replace(/\/$/,""),T.onclick=()=>{window.open(x)}})};p(t);const f=this.$editor.querySelector(".atk-main"),$=this.$editor.querySelector(".atk-site-text-actions"),b=$.querySelector(".atk-rename-btn"),k=$.querySelector(".atk-edit-url-btn"),F=this.$editor.querySelector(".atk-del-btn"),S=()=>{I(this.$editor)},E=()=>{P(this.$editor)},L=C=>{window.alert(C)},_=C=>{let x=t[C]||"";C==="urls"&&(x=t.urls_raw||"");const T=new _t({initValue:x,onYes:async j=>{I(T.$el);let N;try{N=await new B(this.ctx).siteEdit({...t,[C]:j})}catch(z){return L(`\u4FEE\u6539\u5931\u8D25\uFF1A${z.msg||"\u672A\u77E5\u9519\u8BEF"}`),console.error(z),!1}finally{P(T.$el)}return e.replaceWith(this.renderSite(N,i)),p(N),!0}});T.appendTo(f)};b.onclick=()=>_("name"),k.onclick=()=>_("urls"),F.onclick=()=>{const C=async()=>{S();try{await new B(this.ctx).siteDel(t.id,!0)}catch(x){console.log(x),L(`\u5220\u9664\u5931\u8D25 ${String(x)}`);return}finally{E()}this.closeEditor(),e.remove(),this.sites=this.sites.filter(x=>x.name!==t.name)};window.confirm(`\u786E\u8BA4\u5220\u9664\u7AD9\u70B9 "${t.name}"\uFF1F\u5C06\u4F1A\u5220\u9664\u6240\u6709\u76F8\u5173\u6570\u636E`)&&C()}}closeEditor(){!this.$editor||(this.$editor.remove(),this.$rowsWrap.querySelectorAll(".atk-site-item").forEach(t=>t.classList.remove("atk-active")),this.activeSite="")}showAdd(){this.closeAdd(),this.$add=m(`
|
|
223
|
+
<div class="atk-site-add">
|
|
224
|
+
<div class="atk-header">
|
|
225
|
+
<div class="atk-title">\u65B0\u589E\u7AD9\u70B9</div>
|
|
226
|
+
<div class="atk-close-btn">
|
|
227
|
+
<i class="atk-icon atk-icon-close"></i>
|
|
228
|
+
</div>
|
|
229
|
+
</div>
|
|
230
|
+
<div class="atk-form">
|
|
231
|
+
<input type="text" name="AtkSiteName" placeholder="\u7AD9\u70B9\u540D\u79F0" autocomplete="off">
|
|
232
|
+
<input type="text" name="AtkSiteUrls" placeholder="\u7AD9\u70B9 URL\uFF08\u591A\u4E2A\u7528\u9017\u53F7\u9694\u5F00\uFF09" autocomplete="off">
|
|
233
|
+
<button class="atk-btn" name="AtkSubmit">\u521B\u5EFA</button>
|
|
234
|
+
</div>
|
|
235
|
+
</div>`),this.$header.after(this.$add);const t=this.$add.querySelector(".atk-close-btn");t.onclick=()=>this.closeAdd();const e=this.$add.querySelector('[name="AtkSiteName"]'),i=this.$add.querySelector('[name="AtkSiteUrls"]'),s=this.$add.querySelector('[name="AtkSubmit"]');s.onclick=async()=>{const o=e.value.trim(),p=i.value.trim();if(o===""){e.focus();return}I(this.$add);let f;try{f=await new B(this.ctx).siteAdd(o,p)}catch($){window.alert(`\u521B\u5EFA\u5931\u8D25\uFF1A${$.msg||""}`),console.error($);return}finally{P(this.$add)}this.sites.push(f),this.loadSites(this.sites),this.closeAdd()};const n=o=>{o.key==="Enter"&&s.click()};e.onkeyup=o=>n(o),i.onkeyup=o=>n(o)}closeAdd(){this.$add?.remove()}}class ye extends nt{static viewName="sites";static viewTitle="\u7AD9\u70B9";static viewAdminOnly=!0;viewTabs={};viewActiveTab="";siteList;constructor(t){super(t);this.$el=m('<div class="atk-sidebar-view"></div>')}mount(t){this.siteList||(this.siteList=new $e(this.ctx),this.$el.append(this.siteList.$el)),this.reqSites()}switchTab(t,e){this.reqSites()}async reqSites(){const t=await new B(this.ctx).siteGet();this.siteList.loadSites(t)}}class ve extends nt{\u00DF;static viewName="transfer";static viewTitle="\u8FC1\u79FB";static viewAdminOnly=!0;viewTabs={import:"\u5BFC\u5165",export:"\u5BFC\u51FA"};viewActiveTab="import";mount(t){this.switchTab("import",t)}switchTab(t,e){if(t==="import")this.initImport();else if(t==="export")return this.initExport(),!1;return!0}initImport(){this.$el.innerHTML=`<div class="atk-log-wrap" style="display: none;">
|
|
236
|
+
<div class="atk-log-back-btn">\u8FD4\u56DE</div>
|
|
237
|
+
<div class="atk-log"></div>
|
|
238
|
+
</div>
|
|
239
|
+
<div class="atk-form">
|
|
240
|
+
<div class="atk-label">\u6570\u636E\u7C7B\u578B</div>
|
|
241
|
+
<select name="AtkDataType">
|
|
242
|
+
<option value="artrans">Artrans (\u6570\u636E\u884C\u56CA)</option>
|
|
243
|
+
<option value="artalk_v1">Artalk v1 (PHP \u65E7\u7248)</option>
|
|
244
|
+
<option value="typecho">Typecho</option>
|
|
245
|
+
<option value="wordpress">WordPress</option>
|
|
246
|
+
<option value="disqus">Disqus</option>
|
|
247
|
+
<option value="commento">Commento</option>
|
|
248
|
+
<option value="valine">Valine</option>
|
|
249
|
+
<option value="twikoo">Twikoo</option>
|
|
250
|
+
</select>
|
|
251
|
+
<div class="atk-label atk-data-file-label">\u6570\u636E\u6587\u4EF6</div>
|
|
252
|
+
<input type="file" name="AtkDataFile" accept="text/plain,.json">
|
|
253
|
+
<div class="atk-label">\u76EE\u6807\u7AD9\u70B9\u540D</div>
|
|
254
|
+
<input type="text" name="AtkSiteName" placeholder="\u8F93\u5165\u5185\u5BB9..." autocomplete="off">
|
|
255
|
+
<div class="atk-label">\u76EE\u6807\u7AD9\u70B9 URL</div>
|
|
256
|
+
<input type="text" name="AtkSiteURL" placeholder="\u8F93\u5165\u5185\u5BB9..." autocomplete="off">
|
|
257
|
+
<div class="atk-label">\u542F\u52A8\u53C2\u6570\uFF08\u53EF\u9009\uFF09</div>
|
|
258
|
+
<textarea name="AtkPayload"></textarea>
|
|
259
|
+
<span class="atk-desc">\u542F\u52A8\u53C2\u6570\u67E5\u9605\uFF1A\u201C<a href="https://artalk.js.org/guide/transfer.html" target="_blank">\u6587\u6863 \xB7 \u6570\u636E\u642C\u5BB6</a>\u201D</span>
|
|
260
|
+
<button class="atk-btn" name="AtkSubmit">\u5BFC\u5165</button>
|
|
261
|
+
</div>`;const t=this.$el.querySelector(".atk-form"),e=t.querySelector('[name="AtkDataType"]'),i=t.querySelector('[name="AtkDataFile"]'),s=t.querySelector(".atk-data-file-label"),n=t.querySelector('[name="AtkSiteName"]'),o=t.querySelector('[name="AtkSiteURL"]'),p=t.querySelector('[name="AtkPayload"]'),f=t.querySelector('[name="AtkSubmit"]'),$=b=>window.alert(b);e.onchange=()=>{["typecho"].includes(e.value)?(i.style.display="none",s.style.display="none"):(i.style.display="",s.style.display="")},f.onclick=()=>{const b=e.value.trim(),k=n.value.trim(),F=o.value.trim(),S=p.value.trim();if(b===""){$("\u8BF7\u9009\u62E9\u6570\u636E\u7C7B\u578B");return}let E={};if(S){try{E=JSON.parse(S)}catch(C){$(`Payload JSON \u683C\u5F0F\u6709\u8BEF\uFF1A${String(C)}`);return}if(E instanceof Object){$("Payload \u9700\u4E3A JSON \u5BF9\u8C61");return}}k&&(E.t_name=k),F&&(E.t_url=F);const L=C=>{const x=this.$el.querySelector(".atk-log-wrap"),T=x.querySelector(".atk-log"),j=this.$el.querySelector(".atk-log-back-btn");x.style.display="",t.style.display="none",j.onclick=()=>{x.style.display="none",t.style.display=""},C&&(E.json_data=C);const N=`f_${+new Date}`,z=document.createElement("iframe");z.className="atk-iframe",z.name=N,T.innerHTML="",T.append(z);const at={type:b,payload:JSON.stringify(E),token:this.ctx.user.data.token||""},v=document.createElement("form");v.style.display="none",v.setAttribute("method","post"),v.setAttribute("action",`${this.ctx.conf.server}/admin/import`),v.setAttribute("target",N),Object.entries(at).forEach(([a,l])=>{const h=document.createElement("input");h.setAttribute("type","hidden"),h.setAttribute("name",a),h.value=l,v.appendChild(h)}),x.append(v),v.submit(),v.remove()},_=new FileReader;_.onload=()=>{const C=String(_.result);L(C)},i.files?.length?_.readAsText(i.files[0]):L()}}async initExport(){I(this.$el);try{const t=await new B(this.ctx).export();this.download(`artrans-${this.getYmdHisFilename()}.json`,t)}catch(t){console.log(t),window.alert(`${String(t)}`);return}finally{P(this.$el)}}download(t,e){const i=document.createElement("a");i.setAttribute("href",`data:text/json;charset=utf-8,${encodeURIComponent(e)}`),i.setAttribute("download",t),i.style.display="none",document.body.appendChild(i),i.click(),document.body.removeChild(i)}getYmdHisFilename(){const t=new Date,e=t.getFullYear(),i=t.getMonth()+1,s=t.getDate(),n=t.getHours(),o=t.getMinutes(),p=t.getSeconds();return`${e}${i}${s}-${n}${J(o,2)}${J(p,2)}`}}class we{ctx;conf;$el;sites=[];$sites;constructor(t,e){this.ctx=t,this.conf=e,this.$el=m(`<div class="atk-site-list-floater" style="display: none;">
|
|
262
|
+
<div class="atk-sites"></div>
|
|
263
|
+
</div>`),this.$sites=this.$el.querySelector(".atk-sites")}async load(t){this.$sites.innerHTML="";const e=(s,n,o,p)=>{const f=m(`<div class="atk-site-item">
|
|
264
|
+
<div class="atk-site-logo"></div>
|
|
265
|
+
<div class="atk-site-name"></div>
|
|
266
|
+
</div>`);f.onclick=p?()=>p():()=>this.switch(o||s),f.setAttribute("data-name",o||s);const $=f.querySelector(".atk-site-logo"),b=f.querySelector(".atk-site-name");$.innerText=n,b.innerText=s,t===(o||s)&&f.classList.add("atk-active"),this.$sites.append(f)};e("\u6240\u6709\u7AD9\u70B9","_","__ATK_SITE_ALL"),(await new B(this.ctx).siteGet()).forEach(s=>{e(s.name,s.name.substr(0,1))}),e("\u7AD9\u70B9\u7BA1\u7406","+","",()=>{this.conf.onClickSitesViewBtn(),this.hide()})}switch(t){this.conf.onSwitchSite(t)!==!1&&(this.$sites.querySelectorAll(".atk-site-item").forEach(e=>{e.getAttribute("data-name")!==t?e.classList.remove("atk-active"):e.classList.add("atk-active")}),this.hide())}outsideChecker;show(t){this.$el.style.display="",t&&(this.outsideChecker=e=>{t.contains(e.target)||this.$el.contains(e.target)||this.hide()},document.addEventListener("click",this.outsideChecker))}hide(){this.$el.style.display="none",this.outsideChecker&&document.removeEventListener("click",this.outsideChecker)}}const Dt="comments",Mt=[me,ke,ye,ve];class xe extends H{layer;$header;$headerMenu;$title;$avatar;$siteLogo;$closeBtn;$nav;$curtViewBtn;$curtViewBtnIcon;$curtViewBtnText;$navTabs;$navViews;$viewWrap;siteSwitcher;get isAdmin(){return this.ctx.user.data.isAdmin}curtSite;curtView=Dt;get curtViewInstance(){return this.curtView?this.viewInstances[this.curtView]:void 0}curtTab;viewInstances={};viewSwitcherShow=!1;constructor(t){super(t);this.$el=m(fe),this.$header=this.$el.querySelector(".atk-sidebar-header"),this.$headerMenu=this.$header.querySelector(".atk-menu"),this.$title=this.$header.querySelector(".atk-sidebar-title"),this.$avatar=this.$header.querySelector(".atk-avatar"),this.$closeBtn=this.$header.querySelector(".atk-sidebar-close"),this.$nav=this.$el.querySelector(".atk-sidebar-nav"),this.$curtViewBtn=this.$nav.querySelector(".akt-curt-view-btn"),this.$curtViewBtnIcon=this.$curtViewBtn.querySelector(".atk-icon"),this.$curtViewBtnText=this.$curtViewBtn.querySelector(".atk-text"),this.$navTabs=this.$nav.querySelector(".atk-tabs"),this.$navViews=this.$nav.querySelector(".atk-views"),this.$viewWrap=this.$el.querySelector(".atk-sidebar-view-wrap"),this.initViewSwitcher(),this.$closeBtn.onclick=()=>{this.hide()},this.ctx.on("sidebar-show",()=>this.show()),this.ctx.on("sidebar-hide",()=>this.hide()),this.ctx.on("user-changed",()=>{this.firstShow=!0})}initViewSwitcher(){this.$curtViewBtn.onclick=()=>{this.toggleViewSwitcher()},this.$navViews.innerHTML="",Mt.forEach(t=>{const e=m('<div class="atk-tab-item"></div>');this.$navViews.append(e),e.setAttribute("data-name",t.viewName),e.innerText=t.viewTitle,t.viewName===this.curtView&&(e.classList.add("atk-active"),this.$curtViewBtnText.innerText=t.viewTitle),e.onclick=()=>{this.switchView(t.viewName),this.toggleViewSwitcher()}})}toggleViewSwitcher(){this.viewSwitcherShow?(this.$navViews.style.display="none",this.$navTabs.style.display="",this.$curtViewBtnIcon.classList.remove("atk-arrow")):(this.$navViews.style.display="",this.$navTabs.style.display="none",this.$curtViewBtnIcon.classList.add("atk-arrow")),this.viewSwitcherShow=!this.viewSwitcherShow}firstShow=!0;async show(){if(this.$el.style.transform="",this.layer=new Q(this.ctx,"sidebar",this.$el),this.layer.show(),this.$viewWrap.scrollTo(0,0),setTimeout(()=>{this.$el.style.transform="translate(0, 0)"},20),this.firstShow){if(this.isAdmin){this.$title.innerText="\u63A7\u5236\u4E2D\u5FC3",this.$curtViewBtn.style.display="",this.siteSwitcher||(this.siteSwitcher=new we(this.ctx,{onSwitchSite:t=>{this.switchSite(t)},onClickSitesViewBtn:()=>{this.switchView("sites")}}),this.$viewWrap.before(this.siteSwitcher.$el),this.$avatar.onclick=t=>{!this.isAdmin||this.siteSwitcher?.show(t.target)}),this.curtSite=this.conf.site,I(this.$el);try{await this.siteSwitcher.load(this.curtSite)}catch(t){const e=m(`<span>\u52A0\u8F7D\u5931\u8D25\uFF1A${t.msg||"\u7F51\u7EDC\u9519\u8BEF"}<br/></span>`),i=m('<span style="cursor:pointer;">\u70B9\u51FB\u91CD\u65B0\u83B7\u53D6</span>');e.appendChild(i),i.onclick=()=>{Y(this.$el,null),this.show()},Y(this.$el,e);return}finally{P(this.$el)}this.$avatar.innerHTML="",this.$siteLogo=m('<div class="atk-site-logo"></div>'),this.$siteLogo.innerText=(this.curtSite||"").substr(0,1),this.$avatar.append(this.$siteLogo)}else{this.$title.innerText="\u901A\u77E5\u4E2D\u5FC3",this.$curtViewBtn.style.display="none",this.curtSite=this.conf.site;const t=document.createElement("img");t.src=St(this.ctx,le(this.ctx.user.data.email.toLowerCase())),this.$avatar.innerHTML="",this.$avatar.append(t)}this.switchView(Dt),this.firstShow=!1}}hide(){this.$el.style.transform="",this.layer?.dispose()}switchView(t){let e=this.viewInstances[t];if(!e){const i=Mt.find(s=>s.viewName===t);e=new i(this.ctx,this.$viewWrap),this.viewInstances[t]=e}e.mount(this.curtSite),this.curtView=t,this.curtTab=e.viewActiveTab,this.$curtViewBtnText.innerText=e.constructor.viewTitle,this.$navViews.querySelectorAll(".atk-tab-item").forEach(i=>{i.getAttribute("data-name")===t?i.classList.add("atk-active"):i.classList.remove("atk-active")}),this.loadViewTabs(e),this.$viewWrap.innerHTML="",this.$viewWrap.append(e.$el),this.$viewWrap.classList.forEach(i=>{i.startsWith("atk-view-name-")&&this.$viewWrap.classList.remove(i)}),this.$viewWrap.classList.add(`atk-view-name-${e.constructor.viewName}`)}loadViewTabs(t){this.$navTabs.innerHTML="",Object.entries(t.viewTabs).forEach(([e,i])=>{const s=m('<div class="atk-tab-item"></div>');this.$navTabs.append(s),s.innerText=i,t.viewActiveTab===e&&s.classList.add("atk-active"),s.onclick=()=>{t.switchTab(e,this.curtSite)!==!1&&(this.$navTabs.querySelectorAll(".atk-active").forEach(n=>n.classList.remove("atk-active")),s.classList.add("atk-active"),this.curtTab=e)}})}switchSite(t){this.curtSite=t,this.curtViewInstance?.switchTab(this.curtTab,t),this.$siteLogo&&(this.$siteLogo.innerText=this.curtSite.substr(0,1))}}class be{ctx;conf;$root;checkerLauncher;editor;list;sidebar;constructor(t){this.conf={...Rt,...t},this.conf.server=this.conf.server.replace(/\/$/,""),this.conf.pageKey||(this.conf.pageKey=`${window.location.protocol}//'${window.location.host}/${window.location.pathname}`);try{const e=document.querySelector(this.conf.el);if(!e)throw Error(`Sorry, target element "${this.conf.el}" was not found.`);this.$root=e}catch(e){throw console.error(e),new Error("Please check your Artalk `el` config.")}this.ctx=new it(this.$root,this.conf),this.$root.classList.add("artalk"),this.$root.innerHTML="",this.initDarkMode(),this.checkerLauncher=new Kt(this.ctx),this.editor=new ee(this.ctx),this.$root.appendChild(this.editor.$el),this.list=new oe(this.ctx),this.$root.appendChild(this.list.$el),this.sidebar=new xe(this.ctx),this.$root.appendChild(this.sidebar.$el),this.list.reqComments(),this.initEventBind()}initEventBind(){window.addEventListener("hashchange",()=>{this.list.checkGoToCommentByUrlHash()}),this.ctx.on("check-admin-show-el",()=>{const t=[];this.$root.querySelectorAll("[atk-only-admin-show]").forEach(i=>t.push(i));const{$wrap:e}=ht(this.ctx);e&&e.querySelectorAll("[atk-only-admin-show]").forEach(i=>t.push(i)),t.forEach(i=>{this.ctx.user.data.isAdmin?i.classList.remove("atk-hide"):i.classList.add("atk-hide")})}),this.ctx.on("user-changed",()=>{this.ctx.trigger("check-admin-show-el"),this.ctx.trigger("list-refresh-ui")})}initDarkMode(){const t="atk-dark-mode";this.conf.darkMode?this.$root.classList.add(t):this.$root.classList.remove(t);const{$wrap:e}=ht(this.ctx);e&&(this.conf.darkMode?e.classList.add(t):e.classList.remove(t))}setDarkMode(t){this.ctx.conf.darkMode=t,this.initDarkMode()}on(t,e){this.ctx.on(t,e,"external")}off(t,e){this.ctx.off(t,e,"external")}trigger(t,e){this.ctx.trigger(t,e,"external")}}return be});
|