artalk 2.1.3 → 2.1.4
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/dist/Artalk.css +1 -1
- package/dist/Artalk.es.js +285 -323
- package/dist/Artalk.iife.js +1 -1
- package/dist/Artalk.js +1 -1
- package/package.json +6 -9
- package/src/api/index.ts +2 -3
- package/src/artalk.ts +2 -2
- package/src/components/action-btn.ts +1 -1
- package/src/components/comment.ts +88 -3
- package/src/components/editor-plugs/emoticons-plug.less +21 -11
- package/src/components/editor-plugs/emoticons-plug.ts +18 -18
- package/src/components/editor-plugs/preview-plug.less +1 -1
- package/src/components/editor.ts +15 -20
- package/src/components/html/comment.html +6 -13
- package/src/components/html/editor.html +8 -9
- package/src/components/html/list.html +1 -1
- package/src/components/list-lite.ts +203 -299
- package/src/components/list.ts +11 -9
- package/src/components/pagination.ts +2 -2
- package/src/components/read-more-btn.ts +27 -4
- package/src/components/sidebar-views/comments-view.ts +4 -5
- package/src/defaults.ts +1 -1
- package/src/lib/utils.ts +2 -1
- package/src/style/_color.less +19 -23
- package/src/style/_extend.less +3 -3
- package/src/style/_variables.less +0 -24
- package/src/style/comment.less +191 -197
- package/src/style/editor.less +69 -94
- package/src/style/item-text-editor.less +2 -2
- package/src/style/list.less +13 -13
- package/src/style/main.less +31 -31
- package/src/style/page-list.less +4 -4
- package/src/style/pagination.less +6 -6
- package/src/style/sidebar.less +35 -35
- package/src/style/site-list.less +13 -13
- package/types/artalk-data.d.ts +2 -2
package/dist/Artalk.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var __defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,t,i)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,__spreadValues=(e,t)=>{for(var i in t||(t={}))__hasOwnProp.call(t,i)&&__defNormalProp(e,i,t[i]);if(__getOwnPropSymbols)for(var i of __getOwnPropSymbols(t))__propIsEnum.call(t,i)&&__defNormalProp(e,i,t[i]);return e},__spreadProps=(e,t)=>__defProps(e,__getOwnPropDescs(t)),__publicField=(e,t,i)=>(__defNormalProp(e,"symbol"!=typeof t?t+"":t,i),i),__async=(e,t,i)=>new Promise(((s,n)=>{var r=e=>{try{l(i.next(e))}catch(t){n(t)}},a=e=>{try{l(i.throw(e))}catch(t){n(t)}},l=e=>e.done?s(e.value):Promise.resolve(e.value).then(r,a);l((i=i.apply(e,t)).next())}));!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).Artalk=t()}(this,(function(){"use strict";class e{constructor(e){__publicField(this,"data");const t=JSON.parse(window.localStorage.getItem("ArtalkUser")||"{}");this.data={nick:t.nick||"",email:t.email||"",link:t.link||"",token:t.token||"",isAdmin:t.isAdmin||!1}}save(){window.localStorage.setItem("ArtalkUser",JSON.stringify(this.data))}checkHasBasicUserInfo(){return!!this.data.nick&&!!this.data.email}}class t{constructor(t,i){__publicField(this,"cid"),__publicField(this,"$root"),__publicField(this,"conf"),__publicField(this,"user"),__publicField(this,"eventList",[]),this.cid=+new Date,this.$root=t,this.conf=i,this.user=new e(this.conf),this.$root.setAttribute("atk-run-id",this.cid.toString())}on(e,t,i="internal"){this.eventList.push({name:e,handler:t,scope:i})}off(e,t,i="internal"){this.eventList=this.eventList.filter((s=>t?!(s.name===e&&s.handler===t&&s.scope===i):!(s.name===e&&s.scope===i)))}trigger(e,t,i){this.eventList.filter((t=>t.name===e&&(!i||t.scope===i))).map((e=>e.handler)).forEach((e=>e(t)))}}class i{constructor(e){__publicField(this,"$el"),__publicField(this,"ctx"),__publicField(this,"conf"),this.ctx=e,this.conf=e.conf}}function s(){return{baseUrl:null,breaks:!1,extensions:null,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartLists:!1,smartypants:!1,tokenizer:null,walkTokens:null,xhtml:!1}}let n={baseUrl:null,breaks:!1,extensions:null,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartLists:!1,smartypants:!1,tokenizer:null,walkTokens:null,xhtml:!1};const r=/[&<>"']/,a=/[&<>"']/g,l=/[<>"']|&(?!#?\w+;)/,o=/[<>"']|&(?!#?\w+;)/g,c={"&":"&","<":"<",">":">",'"':""","'":"'"},h=e=>c[e];function d(e,t){if(t){if(r.test(e))return e.replace(a,h)}else if(l.test(e))return e.replace(o,h);return e}const u=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi;function p(e){return e.replace(u,((e,t)=>"colon"===(t=t.toLowerCase())?":":"#"===t.charAt(0)?"x"===t.charAt(1)?String.fromCharCode(parseInt(t.substring(2),16)):String.fromCharCode(+t.substring(1)):""))}const m=/(^|[^\[])\^/g;function g(e,t){e=e.source||e,t=t||"";const i={replace:(t,s)=>(s=(s=s.source||s).replace(m,"$1"),e=e.replace(t,s),i),getRegex:()=>new RegExp(e,t)};return i}const f=/[^\w:]/g,k=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function y(e,t,i){if(e){let e;try{e=decodeURIComponent(p(i)).replace(f,"").toLowerCase()}catch(s){return null}if(0===e.indexOf("javascript:")||0===e.indexOf("vbscript:")||0===e.indexOf("data:"))return null}t&&!k.test(i)&&(i=function(e,t){b[" "+e]||($.test(e)?b[" "+e]=e+"/":b[" "+e]=T(e,"/",!0));const i=-1===(e=b[" "+e]).indexOf(":");return"//"===t.substring(0,2)?i?t:e.replace(v,"$1")+t:"/"===t.charAt(0)?i?t:e.replace(x,"$1")+t:e+t}(t,i));try{i=encodeURI(i).replace(/%25/g,"%")}catch(s){return null}return i}const b={},$=/^[^:]+:\/*[^/]*$/,v=/^([^:]+:)[\s\S]*$/,x=/^([^:]+:\/*[^/]*)[\s\S]*$/;const _={exec:function(){}};function w(e){let t,i,s=1;for(;s<arguments.length;s++)for(i in t=arguments[s],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}function S(e,t){const i=e.replace(/\|/g,((e,t,i)=>{let s=!1,n=t;for(;--n>=0&&"\\"===i[n];)s=!s;return s?"|":" |"})).split(/ \|/);let s=0;if(i[0].trim()||i.shift(),i[i.length-1].trim()||i.pop(),i.length>t)i.splice(t);else for(;i.length<t;)i.push("");for(;s<i.length;s++)i[s]=i[s].trim().replace(/\\\|/g,"|");return i}function T(e,t,i){const s=e.length;if(0===s)return"";let n=0;for(;n<s;){const r=e.charAt(s-n-1);if(r!==t||i){if(r===t||!i)break;n++}else n++}return e.substr(0,s-n)}function L(e){e&&e.sanitize&&!e.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 C(e,t){if(t<1)return"";let i="";for(;t>1;)1&t&&(i+=e),t>>=1,e+=e;return i+e}function F(e,t,i,s){const n=t.href,r=t.title?d(t.title):null,a=e[1].replace(/\\([\[\]])/g,"$1");if("!"!==e[0].charAt(0)){s.state.inLink=!0;const e={type:"link",raw:i,href:n,title:r,text:a,tokens:s.inlineTokens(a,[])};return s.state.inLink=!1,e}return{type:"image",raw:i,href:n,title:r,text:d(a)}}class E{constructor(e){this.options=e||n}space(e){const t=this.rules.block.newline.exec(e);if(t)return t[0].length>1?{type:"space",raw:t[0]}:{raw:"\n"}}code(e){const t=this.rules.block.code.exec(e);if(t){const e=t[0].replace(/^ {1,4}/gm,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?e:T(e,"\n")}}}fences(e){const t=this.rules.block.fences.exec(e);if(t){const e=t[0],i=function(e,t){const i=e.match(/^(\s+)(?:```)/);if(null===i)return t;const s=i[1];return t.split("\n").map((e=>{const t=e.match(/^\s+/);if(null===t)return e;const[i]=t;return i.length>=s.length?e.slice(s.length):e})).join("\n")}(e,t[3]||"");return{type:"code",raw:e,lang:t[2]?t[2].trim():t[2],text:i}}}heading(e){const t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(/#$/.test(e)){const t=T(e,"#");this.options.pedantic?e=t.trim():t&&!/ $/.test(t)||(e=t.trim())}const i={type:"heading",raw:t[0],depth:t[1].length,text:e,tokens:[]};return this.lexer.inline(i.text,i.tokens),i}}hr(e){const t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:t[0]}}blockquote(e){const t=this.rules.block.blockquote.exec(e);if(t){const e=t[0].replace(/^ *> ?/gm,"");return{type:"blockquote",raw:t[0],tokens:this.lexer.blockTokens(e,[]),text:e}}}list(e){let t=this.rules.block.list.exec(e);if(t){let i,s,n,r,a,l,o,c,h,d,u=t[1].trim();const p=u.length>1,m={type:"list",raw:"",ordered:p,start:p?+u.slice(0,-1):"",loose:!1,items:[]};u=p?`\\d{1,9}\\${u.slice(-1)}`:`\\${u}`,this.options.pedantic&&(u=p?u:"[*+-]");const g=new RegExp(`^( {0,3}${u})((?: [^\\n]*| *)(?:\\n[^\\n]*)*(?:\\n|$))`);for(;e&&!this.rules.block.hr.test(e)&&(t=g.exec(e));){h=t[2].split("\n"),this.options.pedantic?(r=2,d=h[0].trimLeft()):(r=t[2].search(/[^ ]/),r=t[1].length+(r>4?1:r),d=h[0].slice(r-t[1].length)),l=!1,i=t[0],!h[0]&&/^ *$/.test(h[1])&&(i=t[1]+h.slice(0,2).join("\n")+"\n",m.loose=!0,h=[]);const u=new RegExp(`^ {0,${Math.min(3,r-1)}}(?:[*+-]|\\d{1,9}[.)])`);for(a=1;a<h.length;a++){if(c=h[a],this.options.pedantic&&(c=c.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),u.test(c)){i=t[1]+h.slice(0,a).join("\n")+"\n";break}if(l){if(!(c.search(/[^ ]/)>=r)&&c.trim()){i=t[1]+h.slice(0,a).join("\n")+"\n";break}d+="\n"+c.slice(r)}else c.trim()||(l=!0),c.search(/[^ ]/)>=r?d+="\n"+c.slice(r):d+="\n"+c}m.loose||(o?m.loose=!0:/\n *\n *$/.test(i)&&(o=!0)),this.options.gfm&&(s=/^\[[ xX]\] /.exec(d),s&&(n="[ ] "!==s[0],d=d.replace(/^\[[ xX]\] +/,""))),m.items.push({type:"list_item",raw:i,task:!!s,checked:n,loose:!1,text:d}),m.raw+=i,e=e.slice(i.length)}m.items[m.items.length-1].raw=i.trimRight(),m.items[m.items.length-1].text=d.trimRight(),m.raw=m.raw.trimRight();const f=m.items.length;for(a=0;a<f;a++)this.lexer.state.top=!1,m.items[a].tokens=this.lexer.blockTokens(m.items[a].text,[]),m.items[a].tokens.some((e=>"space"===e.type))&&(m.loose=!0,m.items[a].loose=!0);return m}}html(e){const t=this.rules.block.html.exec(e);if(t){const e={type:"html",raw:t[0],pre:!this.options.sanitizer&&("pre"===t[1]||"script"===t[1]||"style"===t[1]),text:t[0]};return this.options.sanitize&&(e.type="paragraph",e.text=this.options.sanitizer?this.options.sanitizer(t[0]):d(t[0]),e.tokens=[],this.lexer.inline(e.text,e.tokens)),e}}def(e){const t=this.rules.block.def.exec(e);if(t){t[3]&&(t[3]=t[3].substring(1,t[3].length-1));return{type:"def",tag:t[1].toLowerCase().replace(/\s+/g," "),raw:t[0],href:t[2],title:t[3]}}}table(e){const t=this.rules.block.table.exec(e);if(t){const e={type:"table",header:S(t[1]).map((e=>({text:e}))),align:t[2].replace(/^ *|\| *$/g,"").split(/ *\| */),rows:t[3]?t[3].replace(/\n$/,"").split("\n"):[]};if(e.header.length===e.align.length){e.raw=t[0];let i,s,n,r,a=e.align.length;for(i=0;i<a;i++)/^ *-+: *$/.test(e.align[i])?e.align[i]="right":/^ *:-+: *$/.test(e.align[i])?e.align[i]="center":/^ *:-+ *$/.test(e.align[i])?e.align[i]="left":e.align[i]=null;for(a=e.rows.length,i=0;i<a;i++)e.rows[i]=S(e.rows[i],e.header.length).map((e=>({text:e})));for(a=e.header.length,s=0;s<a;s++)e.header[s].tokens=[],this.lexer.inlineTokens(e.header[s].text,e.header[s].tokens);for(a=e.rows.length,s=0;s<a;s++)for(r=e.rows[s],n=0;n<r.length;n++)r[n].tokens=[],this.lexer.inlineTokens(r[n].text,r[n].tokens);return e}}}lheading(e){const t=this.rules.block.lheading.exec(e);if(t){const e={type:"heading",raw:t[0],depth:"="===t[2].charAt(0)?1:2,text:t[1],tokens:[]};return this.lexer.inline(e.text,e.tokens),e}}paragraph(e){const t=this.rules.block.paragraph.exec(e);if(t){const e={type:"paragraph",raw:t[0],text:"\n"===t[1].charAt(t[1].length-1)?t[1].slice(0,-1):t[1],tokens:[]};return this.lexer.inline(e.text,e.tokens),e}}text(e){const t=this.rules.block.text.exec(e);if(t){const e={type:"text",raw:t[0],text:t[0],tokens:[]};return this.lexer.inline(e.text,e.tokens),e}}escape(e){const t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:d(t[1])}}tag(e){const t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&/^<a /i.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&/^<\/a>/i.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:this.options.sanitize?"text":"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(t[0]):d(t[0]):t[0]}}link(e){const t=this.rules.inline.link.exec(e);if(t){const e=t[2].trim();if(!this.options.pedantic&&/^</.test(e)){if(!/>$/.test(e))return;const t=T(e.slice(0,-1),"\\");if((e.length-t.length)%2==0)return}else{const e=function(e,t){if(-1===e.indexOf(t[1]))return-1;const i=e.length;let s=0,n=0;for(;n<i;n++)if("\\"===e[n])n++;else if(e[n]===t[0])s++;else if(e[n]===t[1]&&(s--,s<0))return n;return-1}(t[2],"()");if(e>-1){const i=(0===t[0].indexOf("!")?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,i).trim(),t[3]=""}}let i=t[2],s="";if(this.options.pedantic){const e=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(i);e&&(i=e[1],s=e[3])}else s=t[3]?t[3].slice(1,-1):"";return i=i.trim(),/^</.test(i)&&(i=this.options.pedantic&&!/>$/.test(e)?i.slice(1):i.slice(1,-1)),F(t,{href:i?i.replace(this.rules.inline._escapes,"$1"):i,title:s?s.replace(this.rules.inline._escapes,"$1"):s},t[0],this.lexer)}}reflink(e,t){let i;if((i=this.rules.inline.reflink.exec(e))||(i=this.rules.inline.nolink.exec(e))){let e=(i[2]||i[1]).replace(/\s+/g," ");if(e=t[e.toLowerCase()],!e||!e.href){const e=i[0].charAt(0);return{type:"text",raw:e,text:e}}return F(i,e,i[0],this.lexer)}}emStrong(e,t,i=""){let s=this.rules.inline.emStrong.lDelim.exec(e);if(!s)return;if(s[3]&&i.match(/[\p{L}\p{N}]/u))return;const n=s[1]||s[2]||"";if(!n||n&&(""===i||this.rules.inline.punctuation.exec(i))){const i=s[0].length-1;let n,r,a=i,l=0;const o="*"===s[0][0]?this.rules.inline.emStrong.rDelimAst:this.rules.inline.emStrong.rDelimUnd;for(o.lastIndex=0,t=t.slice(-1*e.length+i);null!=(s=o.exec(t));){if(n=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!n)continue;if(r=n.length,s[3]||s[4]){a+=r;continue}if((s[5]||s[6])&&i%3&&!((i+r)%3)){l+=r;continue}if(a-=r,a>0)continue;if(r=Math.min(r,r+a+l),Math.min(i,r)%2){const t=e.slice(1,i+s.index+r);return{type:"em",raw:e.slice(0,i+s.index+r+1),text:t,tokens:this.lexer.inlineTokens(t,[])}}const t=e.slice(2,i+s.index+r-1);return{type:"strong",raw:e.slice(0,i+s.index+r+1),text:t,tokens:this.lexer.inlineTokens(t,[])}}}}codespan(e){const t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(/\n/g," ");const i=/[^ ]/.test(e),s=/^ /.test(e)&&/ $/.test(e);return i&&s&&(e=e.substring(1,e.length-1)),e=d(e,!0),{type:"codespan",raw:t[0],text:e}}}br(e){const t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e){const t=this.rules.inline.del.exec(e);if(t)return{type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2],[])}}autolink(e,t){const i=this.rules.inline.autolink.exec(e);if(i){let e,s;return"@"===i[2]?(e=d(this.options.mangle?t(i[1]):i[1]),s="mailto:"+e):(e=d(i[1]),s=e),{type:"link",raw:i[0],text:e,href:s,tokens:[{type:"text",raw:e,text:e}]}}}url(e,t){let i;if(i=this.rules.inline.url.exec(e)){let e,s;if("@"===i[2])e=d(this.options.mangle?t(i[0]):i[0]),s="mailto:"+e;else{let t;do{t=i[0],i[0]=this.rules.inline._backpedal.exec(i[0])[0]}while(t!==i[0]);e=d(i[0]),s="www."===i[1]?"http://"+e:e}return{type:"link",raw:i[0],text:e,href:s,tokens:[{type:"text",raw:e,text:e}]}}}inlineText(e,t){const i=this.rules.inline.text.exec(e);if(i){let e;return e=this.lexer.state.inRawBlock?this.options.sanitize?this.options.sanitizer?this.options.sanitizer(i[0]):d(i[0]):i[0]:d(this.options.smartypants?t(i[0]):i[0]),{type:"text",raw:i[0],text:e}}}}const A={newline:/^(?: *(?:\n|$))+/,code:/^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,fences:/^ {0,3}(`{3,}(?=[^`\n]*\n)|~{3,})([^\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(?=\n|$)|$)/,hr:/^ {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\* *){3,})(?:\n+|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,blockquote:/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,list:/^( {0,3}bull)( [^\n]+?)?(?:\n|$)/,html:"^ {0,3}(?:<(script|pre|style|textarea)[\\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 *)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))",def:/^ {0,3}\[(label)\]: *\n? *<?([^\s>]+)>?(?:(?: +\n? *| *\n *)(title))? *(?:\n+|$)/,table:_,lheading:/^([^\n]+)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html| +\n)[^\n]+)*)/,text:/^[^\n]+/,_label:/(?!\s*\])(?:\\[\[\]]|[^\[\]])+/,_title:/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/};A.def=g(A.def).replace("label",A._label).replace("title",A._title).getRegex(),A.bullet=/(?:[*+-]|\d{1,9}[.)])/,A.listItemStart=g(/^( *)(bull) */).replace("bull",A.bullet).getRegex(),A.list=g(A.list).replace(/bull/g,A.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+A.def.source+")").getRegex(),A._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",A._comment=/<!--(?!-?>)[\s\S]*?(?:-->|$)/,A.html=g(A.html,"i").replace("comment",A._comment).replace("tag",A._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),A.paragraph=g(A._paragraph).replace("hr",A.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",A._tag).getRegex(),A.blockquote=g(A.blockquote).replace("paragraph",A.paragraph).getRegex(),A.normal=w({},A),A.gfm=w({},A.normal,{table:"^ *([^\\n ].*\\|.*)\\n {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"}),A.gfm.table=g(A.gfm.table).replace("hr",A.hr).replace("heading"," {0,3}#{1,6} ").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",A._tag).getRegex(),A.pedantic=w({},A.normal,{html:g("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:\"[^\"]*\"|'[^']*'|\\s[^'\"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment",A._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+|$)/,fences:_,paragraph:g(A.normal._paragraph).replace("hr",A.hr).replace("heading"," *#{1,6} *[^\n]").replace("lheading",A.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()});const O={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:_,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*\])((?:\[[^\[\]]*\]|\\[\[\]]|[^\[\]])*)\](?:\[\])?/,reflinkSearch:"reflink|nolink(?!\\()",emStrong:{lDelim:/^(?:\*+(?:([punct_])|[^\s*]))|^_+(?:([punct*])|([^\s_]))/,rDelimAst:/^[^_*]*?\_\_[^_*]*?\*[^_*]*?(?=\_\_)|[punct_](\*+)(?=[\s]|$)|[^punct*_\s](\*+)(?=[punct_\s]|$)|[punct_\s](\*+)(?=[^punct*_\s])|[\s](\*+)(?=[punct_])|[punct_](\*+)(?=[punct_])|[^punct*_\s](\*+)(?=[^punct*_\s])/,rDelimUnd:/^[^_*]*?\*\*[^_*]*?\_[^_*]*?(?=\*\*)|[punct*](\_+)(?=[\s]|$)|[^punct*_\s](\_+)(?=[punct*\s]|$)|[punct*\s](\_+)(?=[^punct*_\s])|[\s](\_+)(?=[punct*])|[punct*](\_+)(?=[punct*])/},code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,br:/^( {2,}|\\)\n(?!\s*$)/,del:_,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,punctuation:/^([\spunctuation])/};function q(e){return e.replace(/---/g,"—").replace(/--/g,"–").replace(/(^|[-\u2014/(\[{"\s])'/g,"$1‘").replace(/'/g,"’").replace(/(^|[-\u2014/(\[{\u2018\s])"/g,"$1“").replace(/"/g,"”").replace(/\.{3}/g,"…")}function B(e){let t,i,s="";const n=e.length;for(t=0;t<n;t++)i=e.charCodeAt(t),Math.random()>.5&&(i="x"+i.toString(16)),s+="&#"+i+";";return s}O._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",O.punctuation=g(O.punctuation).replace(/punctuation/g,O._punctuation).getRegex(),O.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g,O.escapedEmSt=/\\\*|\\_/g,O._comment=g(A._comment).replace("(?:--\x3e|$)","--\x3e").getRegex(),O.emStrong.lDelim=g(O.emStrong.lDelim).replace(/punct/g,O._punctuation).getRegex(),O.emStrong.rDelimAst=g(O.emStrong.rDelimAst,"g").replace(/punct/g,O._punctuation).getRegex(),O.emStrong.rDelimUnd=g(O.emStrong.rDelimUnd,"g").replace(/punct/g,O._punctuation).getRegex(),O._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,O._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,O._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])?)+(?![-_])/,O.autolink=g(O.autolink).replace("scheme",O._scheme).replace("email",O._email).getRegex(),O._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,O.tag=g(O.tag).replace("comment",O._comment).replace("attribute",O._attribute).getRegex(),O._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,O._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/,O._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,O.link=g(O.link).replace("label",O._label).replace("href",O._href).replace("title",O._title).getRegex(),O.reflink=g(O.reflink).replace("label",O._label).getRegex(),O.reflinkSearch=g(O.reflinkSearch,"g").replace("reflink",O.reflink).replace("nolink",O.nolink).getRegex(),O.normal=w({},O),O.pedantic=w({},O.normal,{strong:{start:/^__|\*\*/,middle:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,endAst:/\*\*(?!\*)/g,endUnd:/__(?!_)/g},em:{start:/^_|\*/,middle:/^()\*(?=\S)([\s\S]*?\S)\*(?!\*)|^_(?=\S)([\s\S]*?\S)_(?!_)/,endAst:/\*(?!\*)/g,endUnd:/_(?!_)/g},link:g(/^!?\[(label)\]\((.*?)\)/).replace("label",O._label).getRegex(),reflink:g(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",O._label).getRegex()}),O.gfm=w({},O.normal,{escape:g(O.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~])\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/}),O.gfm.url=g(O.gfm.url,"i").replace("email",O.gfm._extended_email).getRegex(),O.breaks=w({},O.gfm,{br:g(O.br).replace("{2,}","*").getRegex(),text:g(O.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()});class M{constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||n,this.options.tokenizer=this.options.tokenizer||new E,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const t={block:A.normal,inline:O.normal};this.options.pedantic?(t.block=A.pedantic,t.inline=O.pedantic):this.options.gfm&&(t.block=A.gfm,this.options.breaks?t.inline=O.breaks:t.inline=O.gfm),this.tokenizer.rules=t}static get rules(){return{block:A,inline:O}}static lex(e,t){return new M(t).lex(e)}static lexInline(e,t){return new M(t).inlineTokens(e)}lex(e){let t;for(e=e.replace(/\r\n|\r/g,"\n").replace(/\t/g," "),this.blockTokens(e,this.tokens);t=this.inlineQueue.shift();)this.inlineTokens(t.src,t.tokens);return this.tokens}blockTokens(e,t=[]){let i,s,n,r;for(this.options.pedantic&&(e=e.replace(/^ +$/gm,""));e;)if(!(this.options.extensions&&this.options.extensions.block&&this.options.extensions.block.some((s=>!!(i=s.call({lexer:this},e,t))&&(e=e.substring(i.raw.length),t.push(i),!0)))))if(i=this.tokenizer.space(e))e=e.substring(i.raw.length),i.type&&t.push(i);else if(i=this.tokenizer.code(e))e=e.substring(i.raw.length),s=t[t.length-1],!s||"paragraph"!==s.type&&"text"!==s.type?t.push(i):(s.raw+="\n"+i.raw,s.text+="\n"+i.text,this.inlineQueue[this.inlineQueue.length-1].src=s.text);else if(i=this.tokenizer.fences(e))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.heading(e))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.hr(e))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.blockquote(e))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.list(e))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.html(e))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.def(e))e=e.substring(i.raw.length),s=t[t.length-1],!s||"paragraph"!==s.type&&"text"!==s.type?this.tokens.links[i.tag]||(this.tokens.links[i.tag]={href:i.href,title:i.title}):(s.raw+="\n"+i.raw,s.text+="\n"+i.raw,this.inlineQueue[this.inlineQueue.length-1].src=s.text);else if(i=this.tokenizer.table(e))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.lheading(e))e=e.substring(i.raw.length),t.push(i);else{if(n=e,this.options.extensions&&this.options.extensions.startBlock){let t=1/0;const i=e.slice(1);let s;this.options.extensions.startBlock.forEach((function(e){s=e.call({lexer:this},i),"number"==typeof s&&s>=0&&(t=Math.min(t,s))})),t<1/0&&t>=0&&(n=e.substring(0,t+1))}if(this.state.top&&(i=this.tokenizer.paragraph(n)))s=t[t.length-1],r&&"paragraph"===s.type?(s.raw+="\n"+i.raw,s.text+="\n"+i.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=s.text):t.push(i),r=n.length!==e.length,e=e.substring(i.raw.length);else if(i=this.tokenizer.text(e))e=e.substring(i.raw.length),s=t[t.length-1],s&&"text"===s.type?(s.raw+="\n"+i.raw,s.text+="\n"+i.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=s.text):t.push(i);else if(e){const t="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw new Error(t)}}return this.state.top=!0,t}inline(e,t){this.inlineQueue.push({src:e,tokens:t})}inlineTokens(e,t=[]){let i,s,n,r,a,l,o=e;if(this.tokens.links){const e=Object.keys(this.tokens.links);if(e.length>0)for(;null!=(r=this.tokenizer.rules.inline.reflinkSearch.exec(o));)e.includes(r[0].slice(r[0].lastIndexOf("[")+1,-1))&&(o=o.slice(0,r.index)+"["+C("a",r[0].length-2)+"]"+o.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;null!=(r=this.tokenizer.rules.inline.blockSkip.exec(o));)o=o.slice(0,r.index)+"["+C("a",r[0].length-2)+"]"+o.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;null!=(r=this.tokenizer.rules.inline.escapedEmSt.exec(o));)o=o.slice(0,r.index)+"++"+o.slice(this.tokenizer.rules.inline.escapedEmSt.lastIndex);for(;e;)if(a||(l=""),a=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some((s=>!!(i=s.call({lexer:this},e,t))&&(e=e.substring(i.raw.length),t.push(i),!0)))))if(i=this.tokenizer.escape(e))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.tag(e))e=e.substring(i.raw.length),s=t[t.length-1],s&&"text"===i.type&&"text"===s.type?(s.raw+=i.raw,s.text+=i.text):t.push(i);else if(i=this.tokenizer.link(e))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.reflink(e,this.tokens.links))e=e.substring(i.raw.length),s=t[t.length-1],s&&"text"===i.type&&"text"===s.type?(s.raw+=i.raw,s.text+=i.text):t.push(i);else if(i=this.tokenizer.emStrong(e,o,l))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.codespan(e))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.br(e))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.del(e))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.autolink(e,B))e=e.substring(i.raw.length),t.push(i);else if(this.state.inLink||!(i=this.tokenizer.url(e,B))){if(n=e,this.options.extensions&&this.options.extensions.startInline){let t=1/0;const i=e.slice(1);let s;this.options.extensions.startInline.forEach((function(e){s=e.call({lexer:this},i),"number"==typeof s&&s>=0&&(t=Math.min(t,s))})),t<1/0&&t>=0&&(n=e.substring(0,t+1))}if(i=this.tokenizer.inlineText(n,q))e=e.substring(i.raw.length),"_"!==i.raw.slice(-1)&&(l=i.raw.slice(-1)),a=!0,s=t[t.length-1],s&&"text"===s.type?(s.raw+=i.raw,s.text+=i.text):t.push(i);else if(e){const t="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw new Error(t)}}else e=e.substring(i.raw.length),t.push(i);return t}}class R{constructor(e){this.options=e||n}code(e,t,i){const s=(t||"").match(/\S*/)[0];if(this.options.highlight){const t=this.options.highlight(e,s);null!=t&&t!==e&&(i=!0,e=t)}return e=e.replace(/\n$/,"")+"\n",s?'<pre><code class="'+this.options.langPrefix+d(s,!0)+'">'+(i?e:d(e,!0))+"</code></pre>\n":"<pre><code>"+(i?e:d(e,!0))+"</code></pre>\n"}blockquote(e){return"<blockquote>\n"+e+"</blockquote>\n"}html(e){return e}heading(e,t,i,s){return this.options.headerIds?"<h"+t+' id="'+this.options.headerPrefix+s.slug(i)+'">'+e+"</h"+t+">\n":"<h"+t+">"+e+"</h"+t+">\n"}hr(){return this.options.xhtml?"<hr/>\n":"<hr>\n"}list(e,t,i){const s=t?"ol":"ul";return"<"+s+(t&&1!==i?' start="'+i+'"':"")+">\n"+e+"</"+s+">\n"}listitem(e){return"<li>"+e+"</li>\n"}checkbox(e){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox"'+(this.options.xhtml?" /":"")+"> "}paragraph(e){return"<p>"+e+"</p>\n"}table(e,t){return t&&(t="<tbody>"+t+"</tbody>"),"<table>\n<thead>\n"+e+"</thead>\n"+t+"</table>\n"}tablerow(e){return"<tr>\n"+e+"</tr>\n"}tablecell(e,t){const i=t.header?"th":"td";return(t.align?"<"+i+' align="'+t.align+'">':"<"+i+">")+e+"</"+i+">\n"}strong(e){return"<strong>"+e+"</strong>"}em(e){return"<em>"+e+"</em>"}codespan(e){return"<code>"+e+"</code>"}br(){return this.options.xhtml?"<br/>":"<br>"}del(e){return"<del>"+e+"</del>"}link(e,t,i){if(null===(e=y(this.options.sanitize,this.options.baseUrl,e)))return i;let s='<a href="'+d(e)+'"';return t&&(s+=' title="'+t+'"'),s+=">"+i+"</a>",s}image(e,t,i){if(null===(e=y(this.options.sanitize,this.options.baseUrl,e)))return i;let s='<img src="'+e+'" alt="'+i+'"';return t&&(s+=' title="'+t+'"'),s+=this.options.xhtml?"/>":">",s}text(e){return e}}class I{strong(e){return e}em(e){return e}codespan(e){return e}del(e){return e}html(e){return e}text(e){return e}link(e,t,i){return""+i}image(e,t,i){return""+i}br(){return""}}class P{constructor(){this.seen={}}serialize(e){return e.toLowerCase().trim().replace(/<[!\/a-z].*?>/gi,"").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g,"").replace(/\s/g,"-")}getNextSafeSlug(e,t){let i=e,s=0;if(this.seen.hasOwnProperty(i)){s=this.seen[e];do{s++,i=e+"-"+s}while(this.seen.hasOwnProperty(i))}return t||(this.seen[e]=s,this.seen[i]=0),i}slug(e,t={}){const i=this.serialize(e);return this.getNextSafeSlug(i,t.dryrun)}}class U{constructor(e){this.options=e||n,this.options.renderer=this.options.renderer||new R,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new I,this.slugger=new P}static parse(e,t){return new U(t).parse(e)}static parseInline(e,t){return new U(t).parseInline(e)}parse(e,t=!0){let i,s,n,r,a,l,o,c,h,d,u,m,g,f,k,y,b,$,v,x="";const _=e.length;for(i=0;i<_;i++)if(d=e[i],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[d.type]&&(v=this.options.extensions.renderers[d.type].call({parser:this},d),!1!==v||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(d.type)))x+=v||"";else switch(d.type){case"space":continue;case"hr":x+=this.renderer.hr();continue;case"heading":x+=this.renderer.heading(this.parseInline(d.tokens),d.depth,p(this.parseInline(d.tokens,this.textRenderer)),this.slugger);continue;case"code":x+=this.renderer.code(d.text,d.lang,d.escaped);continue;case"table":for(c="",o="",r=d.header.length,s=0;s<r;s++)o+=this.renderer.tablecell(this.parseInline(d.header[s].tokens),{header:!0,align:d.align[s]});for(c+=this.renderer.tablerow(o),h="",r=d.rows.length,s=0;s<r;s++){for(l=d.rows[s],o="",a=l.length,n=0;n<a;n++)o+=this.renderer.tablecell(this.parseInline(l[n].tokens),{header:!1,align:d.align[n]});h+=this.renderer.tablerow(o)}x+=this.renderer.table(c,h);continue;case"blockquote":h=this.parse(d.tokens),x+=this.renderer.blockquote(h);continue;case"list":for(u=d.ordered,m=d.start,g=d.loose,r=d.items.length,h="",s=0;s<r;s++)k=d.items[s],y=k.checked,b=k.task,f="",k.task&&($=this.renderer.checkbox(y),g?k.tokens.length>0&&"paragraph"===k.tokens[0].type?(k.tokens[0].text=$+" "+k.tokens[0].text,k.tokens[0].tokens&&k.tokens[0].tokens.length>0&&"text"===k.tokens[0].tokens[0].type&&(k.tokens[0].tokens[0].text=$+" "+k.tokens[0].tokens[0].text)):k.tokens.unshift({type:"text",text:$}):f+=$),f+=this.parse(k.tokens,g),h+=this.renderer.listitem(f,b,y);x+=this.renderer.list(h,u,m);continue;case"html":x+=this.renderer.html(d.text);continue;case"paragraph":x+=this.renderer.paragraph(this.parseInline(d.tokens));continue;case"text":for(h=d.tokens?this.parseInline(d.tokens):d.text;i+1<_&&"text"===e[i+1].type;)d=e[++i],h+="\n"+(d.tokens?this.parseInline(d.tokens):d.text);x+=t?this.renderer.paragraph(h):h;continue;default:{const e='Token with "'+d.type+'" type was not found.';if(this.options.silent)return void console.error(e);throw new Error(e)}}return x}parseInline(e,t){t=t||this.renderer;let i,s,n,r="";const a=e.length;for(i=0;i<a;i++)if(s=e[i],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[s.type]&&(n=this.options.extensions.renderers[s.type].call({parser:this},s),!1!==n||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type)))r+=n||"";else switch(s.type){case"escape":case"text":r+=t.text(s.text);break;case"html":r+=t.html(s.text);break;case"link":r+=t.link(s.href,s.title,this.parseInline(s.tokens,t));break;case"image":r+=t.image(s.href,s.title,s.text);break;case"strong":r+=t.strong(this.parseInline(s.tokens,t));break;case"em":r+=t.em(this.parseInline(s.tokens,t));break;case"codespan":r+=t.codespan(s.text);break;case"br":r+=t.br();break;case"del":r+=t.del(this.parseInline(s.tokens,t));break;default:{const e='Token with "'+s.type+'" type was not found.';if(this.options.silent)return void console.error(e);throw new Error(e)}}return r}}function z(e,t,i){if(null==e)throw new Error("marked(): input parameter is undefined or null");if("string"!=typeof e)throw new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected");if("function"==typeof t&&(i=t,t=null),L(t=w({},z.defaults,t||{})),i){const n=t.highlight;let r;try{r=M.lex(e,t)}catch(s){return i(s)}const a=function(e){let a;if(!e)try{t.walkTokens&&z.walkTokens(r,t.walkTokens),a=U.parse(r,t)}catch(s){e=s}return t.highlight=n,e?i(e):i(null,a)};if(!n||n.length<3)return a();if(delete t.highlight,!r.length)return a();let l=0;return z.walkTokens(r,(function(e){"code"===e.type&&(l++,setTimeout((()=>{n(e.text,e.lang,(function(t,i){if(t)return a(t);null!=i&&i!==e.text&&(e.text=i,e.escaped=!0),l--,0===l&&a()}))}),0))})),void(0===l&&a())}try{const i=M.lex(e,t);return t.walkTokens&&z.walkTokens(i,t.walkTokens),U.parse(i,t)}catch(s){if(s.message+="\nPlease report this to https://github.com/markedjs/marked.",t.silent)return"<p>An error occurred:</p><pre>"+d(s.message+"",!0)+"</pre>";throw s}}z.options=z.setOptions=function(e){var t;return w(z.defaults,e),t=z.defaults,n=t,z},z.getDefaults=s,z.defaults=n,z.use=function(...e){const t=w({},...e),i=z.defaults.extensions||{renderers:{},childTokens:{}};let s;e.forEach((e=>{if(e.extensions&&(s=!0,e.extensions.forEach((e=>{if(!e.name)throw new Error("extension name required");if(e.renderer){const t=i.renderers?i.renderers[e.name]:null;i.renderers[e.name]=t?function(...i){let s=e.renderer.apply(this,i);return!1===s&&(s=t.apply(this,i)),s}:e.renderer}if(e.tokenizer){if(!e.level||"block"!==e.level&&"inline"!==e.level)throw new Error("extension level must be 'block' or 'inline'");i[e.level]?i[e.level].unshift(e.tokenizer):i[e.level]=[e.tokenizer],e.start&&("block"===e.level?i.startBlock?i.startBlock.push(e.start):i.startBlock=[e.start]:"inline"===e.level&&(i.startInline?i.startInline.push(e.start):i.startInline=[e.start]))}e.childTokens&&(i.childTokens[e.name]=e.childTokens)}))),e.renderer){const i=z.defaults.renderer||new R;for(const t in e.renderer){const s=i[t];i[t]=(...n)=>{let r=e.renderer[t].apply(i,n);return!1===r&&(r=s.apply(i,n)),r}}t.renderer=i}if(e.tokenizer){const i=z.defaults.tokenizer||new E;for(const t in e.tokenizer){const s=i[t];i[t]=(...n)=>{let r=e.tokenizer[t].apply(i,n);return!1===r&&(r=s.apply(i,n)),r}}t.tokenizer=i}if(e.walkTokens){const i=z.defaults.walkTokens;t.walkTokens=function(t){e.walkTokens.call(this,t),i&&i.call(this,t)}}s&&(t.extensions=i),z.setOptions(t)}))},z.walkTokens=function(e,t){for(const i of e)switch(t.call(z,i),i.type){case"table":for(const e of i.header)z.walkTokens(e.tokens,t);for(const e of i.rows)for(const i of e)z.walkTokens(i.tokens,t);break;case"list":z.walkTokens(i.items,t);break;default:z.defaults.extensions&&z.defaults.extensions.childTokens&&z.defaults.extensions.childTokens[i.type]?z.defaults.extensions.childTokens[i.type].forEach((function(e){z.walkTokens(i[e],t)})):i.tokens&&z.walkTokens(i.tokens,t)}},z.parseInline=function(e,t){if(null==e)throw new Error("marked.parseInline(): input parameter is undefined or null");if("string"!=typeof e)throw new Error("marked.parseInline(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected");L(t=w({},z.defaults,t||{}));try{const i=M.lexInline(e,t);return t.walkTokens&&z.walkTokens(i,t.walkTokens),U.parseInline(i,t)}catch(i){if(i.message+="\nPlease report this to https://github.com/markedjs/marked.",t.silent)return"<p>An error occurred:</p><pre>"+d(i.message+"",!0)+"</pre>";throw i}},z.Parser=U,z.parser=U.parse,z.Renderer=R,z.TextRenderer=I,z.Lexer=M,z.lexer=M.lex,z.Tokenizer=E,z.Slugger=P,z.parse=z,U.parse,M.lex;"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var N={"&":"&","<":"<",">":">",'"':""","'":"'"},H={"&":"&","<":"<",">":">",""":'"',"'":"'"},W=/(&|<|>|"|')/g,D=/[&<>"']/g;function V(e){return N[e]}function j(e){return H[e]}function Q(e){return null==e?"":String(e).replace(D,V)}function G(e){return null==e?"":String(e).replace(W,j)}Q.options=G.options={};var Y={encode:Q,escape:Q,decode:G,unescape:G,version:"1.0.0-browser"};var Z=function e(t){for(var i,s,n=Array.prototype.slice.call(arguments,1);n.length;)for(s in i=n.shift())i.hasOwnProperty(s)&&("[object Object]"===Object.prototype.toString.call(t[s])?t[s]=e(t[s],i[s]):t[s]=i[s]);return t},K=function(e){return"string"==typeof e?e.toLowerCase():e};function X(e,t){return e[t]=!0,e}var J=function(e){return e.reduce(X,{})},ee={uris:J(["background","base","cite","href","longdesc","src","usemap"])},te={voids:J(["area","br","col","hr","img","wbr","input","base","basefont","link","meta"])},ie=Y,se=K,ne=te,re=/^<\s*([\w:-]+)((?:\s+[\w:-]+(?:\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|[^>\s]+))?)*)\s*(\/?)\s*>/,ae=/^<\s*\/\s*([\w:-]+)[^>]*>/,le=/([\w:-]+)(?:\s*=\s*(?:(?:"((?:[^"])*)")|(?:'((?:[^'])*)')|([^>\s]+)))?/g,oe=/^</,ce=/^<\s*\//;var he=Y,de=K,ue=ee,pe=te;var me=Z,ge=function(e,t){for(var i,s=function(){var e=[];return e.lastItem=function(){return e[e.length-1]},e}(),n=e;e;)r();function r(){i=!0,function(){"\x3c!--"===e.substr(0,4)?(s=e.indexOf("--\x3e"))>=0&&(t.comment&&t.comment(e.substring(4,s)),e=e.substring(s+3),i=!1):ce.test(e)?a(ae,o):oe.test(e)&&a(re,l);var s;!function(){if(!i)return;var s,n=e.indexOf("<");n>=0?(s=e.substring(0,n),e=e.substring(n)):(s=e,e="");t.chars&&t.chars(s)}()}();var s=e===n;n=e,s&&(e="")}function a(t,s){var n=e.match(t);n&&(e=e.substring(n[0].length),n[0].replace(t,s),i=!1)}function l(e,i,n,r){var a={},l=se(i),o=ne.voids[l]||!!r;n.replace(le,(function(e,t,i,s,n){a[t]=void 0===i&&void 0===s&&void 0===n?void 0:ie.decode(i||s||n||"")})),o||s.push(l),t.start&&t.start(l,a,o)}function o(e,i){var n,r=0,a=se(i);if(a)for(r=s.length-1;r>=0&&s[r]!==a;r--);if(r>=0){for(n=s.length-1;n>=r;n--)t.end&&t.end(s[n]);s.length=r}}o()},fe=function(e,t){var i,s=t||{};return l(),{start:function(e,t,a){var l=de(e);if(i.ignoring)return void r(l);if(-1===(s.allowedTags||[]).indexOf(l))return void r(l);if(s.filter&&!s.filter({tag:l,attrs:t}))return void r(l);n("<"),n(l),Object.keys(t).forEach((function(e){var i=t[e],r=(s.allowedClasses||{})[l]||[],a=(s.allowedAttributes||{})[l]||[],o=de(e);("class"===o&&-1===a.indexOf(o)?(i=i.split(" ").filter((function(e){return r&&-1!==r.indexOf(e)})).join(" ").trim()).length:-1!==a.indexOf(o)&&(!0!==ue.uris[o]||function(e){var t=e[0];if("#"===t||"/"===t)return!0;var i=e.indexOf(":");if(-1===i)return!0;var n=e.indexOf("?");if(-1!==n&&i>n)return!0;var r=e.indexOf("#");return-1!==r&&i>r||s.allowedSchemes.some(a);function a(t){return 0===e.indexOf(t+":")}}(i)))&&(n(" "),n(e),"string"==typeof i&&(n('="'),n(he.encode(i)),n('"')))})),n(a?"/>":">")},end:function(e){var t=de(e);-1!==(s.allowedTags||[]).indexOf(t)&&!1===i.ignoring?(n("</"),n(t),n(">")):a(t)},chars:function(e){!1===i.ignoring&&n(s.transformText?s.transformText(e):e)}};function n(t){e.push(t)}function r(e){pe.voids[e]||(!1===i.ignoring?i={ignoring:e,depth:1}:i.ignoring===e&&i.depth++)}function a(e){i.ignoring===e&&--i.depth<=0&&l()}function l(){i={ignoring:!1,depth:0}}},ke={allowedAttributes:{a:["href","name","target","title","aria-label"],iframe:["allowfullscreen","frameborder","src"],img:["src","alt","title","aria-label"]},allowedClasses:{},allowedSchemes:["http","https","mailto"],allowedTags:["a","abbr","article","b","blockquote","br","caption","code","del","details","div","em","h1","h2","h3","h4","h5","h6","hr","i","img","ins","kbd","li","main","mark","ol","p","pre","section","span","strike","strong","sub","summary","sup","table","tbody","td","th","thead","tr","u","ul"],filter:null};function ye(e,t,i){var s=[],n=!0===i?t:me({},ke,t),r=fe(s,n);return ge(e,r),s.join("")}ye.defaults=ke;var be=ye,$e={exports:{}};$e.exports=function(){function e(e,t){return e(t={exports:{}},t.exports),t.exports}var t=e((function(e){var t=e.exports=function(){return new RegExp("(?:"+t.line().source+")|(?:"+t.block().source+")","gm")};t.line=function(){return/(?:^|\s)\/\/(.+?)$/gm},t.block=function(){return/\/\*([\S\s]*?)\*\//gm}})),i=["23AC69","91C132","F19726","E8552D","1AAB8E","E1147F","2980C1","1BA1E6","9FA0A0","F19726","E30B20","E30B20","A3338B"];function s(e){return'<span style="color: slategray">'+e+"</span>"}return function(e,n){void 0===n&&(n={});var r=n.colors;void 0===r&&(r=i);var a=0,l={},o=new RegExp("("+/[\u4E00-\u9FFF\u3400-\u4dbf\uf900-\ufaff\u3040-\u309f\uac00-\ud7af\u0400-\u04FF]+|\w+/.source+"|"+/</.source+")|("+t().source+")","gmi");return e.replace(o,(function(e,t,i){if(i)return s(i);if("<"===t)return"<";var n;l[t]?n=l[t]:(n=r[a],l[t]=n);var o='<span style="color: #'+n+'">'+t+"</span>";return a=++a%r.length,o}))}}();var ve=$e.exports;function xe(e=""){const t=document.createElement("div");return t.innerHTML=e.trim(),t.firstElementChild||t}function _e(e){return parseFloat(getComputedStyle(e,null).height.replace("px",""))}function we(e){const t=RegExp(`[?&]${e}=([^&]*)`).exec(window.location.search);return t&&decodeURIComponent(t[1].replace(/\+/g," "))}function Se(e){const t=e.getBoundingClientRect();return{top:t.top+window.scrollY,left:t.left+window.scrollX}}function Te(e,t){let i=e.toString();for(;i.length<t;)i=`0${i}`;return i}function Le(e){try{const t=e.getTime(),i=(new Date).getTime()-t,s=Math.floor(i/864e5);if(0===s){const e=i%864e5,t=Math.floor(e/36e5);if(0===t){const t=e%36e5,i=Math.floor(t/6e4);if(0===i){const e=t%6e4;return`${Math.round(e/1e3)} 秒前`}return`${i} 分钟前`}return`${t} 小时前`}return s<0?"刚刚":s<8?`${s} 天前`:function(e){const t=Te(e.getDate(),2),i=Te(e.getMonth()+1,2);return`${Te(e.getFullYear(),2)}-${i}-${t}`}(e)}catch(t){return console.error(t)," - "}}function Ce(e,t){var i,s;return`${((null==(i=e.conf.gravatar)?void 0:i.mirror)||"").replace(/\/$/,"")}/${t}?d=${encodeURIComponent((null==(s=e.conf.gravatar)?void 0:s.default)||"")}&s=80`}let Fe;function Ee(e,t){if(!Fe){const e=new z.Renderer,t=e.link;e.link=(i,s,n)=>{const r=null==i?void 0:i.startsWith(`${window.location.protocol}//${window.location.hostname}`);return t.call(e,i,s,n).replace(/^<a /,`<a target="_blank" ${r?"":'rel="noreferrer noopener nofollow"'} `)};const i=z;z.setOptions({renderer:e,highlight:e=>ve(e),pedantic:!1,gfm:!0,breaks:!0,smartLists:!0,smartypants:!0,xhtml:!1,sanitize:!0,sanitizer:e=>be(e,__spreadProps(__spreadValues({},be.defaults),{allowedAttributes:__spreadProps(__spreadValues({},be.defaults.allowedAttributes),{img:["src","atk-emoticon"]})})),silent:!0}),Fe=i}return Fe.parse(t)}function Ae(e){e instanceof t&&(e=e.$root);let i=e.querySelector(".atk-loading");i||(i=xe('<div class="atk-loading atk-fade-in" 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>'),e.appendChild(i)),i.style.display="";const s=i.querySelector(".atk-loading-spinner");s&&(s.style.display="none",window.setTimeout((()=>{s.style.display=""}),500))}function Oe(e){e instanceof t&&(e=e.$root);const i=e.querySelector(".atk-loading");i&&(i.style.display="none")}function qe(e,t=!0){const i=Se(e).top+_e(e)/2-document.documentElement.clientHeight/2;t?window.scroll({top:i>0?i:0,left:0}):window.scroll(0,i>0?i:0)}function Be(e,t,i){const s=xe(`<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>`);s.querySelector(".atk-notify-content").innerHTML=function(e){const t=document.createElement("div");return t.innerText=e,t.innerHTML}(t).replace("\n","<br/>"),e.appendChild(s);const n=()=>{s.classList.add("atk-fade-out"),setTimeout((()=>{s.remove()}),200)};let r;r=window.setTimeout((()=>{n()}),3e3),s.addEventListener("click",(()=>{n(),window.clearTimeout(r)}))}function Me(e,t){!function(e,t,i="in"){e.classList.add(`atk-fade-${i}`);const s=()=>{e.classList.remove(`atk-fade-${i}`),e.removeEventListener("animationend",s),t&&t()};e.addEventListener("animationend",s)}(e,t,"in")}function Re(e,i,s='<span class="atk-error-title">Artalk Error</span>'){e instanceof t&&(e=e.$root);let n=e.querySelector(".atk-error-layer");if(null===i)return void(null!==n&&n.remove());n||(n=xe(`<div class="atk-error-layer">${s}<span class="atk-error-text"></span></div>`),e.appendChild(n));const r=n.querySelector(".atk-error-text");r.innerHTML="",null!==i&&(i instanceof HTMLElement?r.appendChild(i):r.innerText=i)}const Ie=class extends i{constructor(e,t,i){super(e),__publicField(this,"name"),__publicField(this,"$wrap"),__publicField(this,"$mask"),__publicField(this,"maskClickHideEnable",!0),__publicField(this,"bodyStyleOrgOverflow",""),__publicField(this,"bodyStyleOrgPaddingRight",""),__publicField(this,"afterHide"),this.name=t;const{$wrap:s,$mask:n}=Ue(e);this.$wrap=s,this.$mask=n,this.$el=this.$wrap.querySelector(`[data-layer-name="${t}"].atk-layer-item`),null===this.$el&&(i?this.$el=i:(this.$el=xe(),this.$el.classList.add("atk-layer-item"))),this.$el.setAttribute("data-layer-name",t),this.$el.style.display="none",this.$wrap.append(this.$el)}getName(){return this.name}getWrapEl(){return this.$wrap}getEl(){return this.$el}show(){this.fireAllActionTimer(),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 e=parseInt(window.getComputedStyle(document.body,null).getPropertyValue("padding-right"),10);document.body.style.paddingRight=`${function(){const e=document.createElement("p");e.style.width="100%",e.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(e),document.body.appendChild(t);const i=e.offsetWidth;t.style.overflow="scroll";let s=e.offsetWidth;return i===s&&(s=t.clientWidth),document.body.removeChild(t),i-s}()+e||0}px`}hide(){this.afterHide&&this.afterHide(),this.$wrap.classList.add("atk-fade-out"),this.$el.style.display="none",this.newActionTimer((()=>{this.$wrap.style.display="none",document.body.style.overflow=this.bodyStyleOrgOverflow,document.body.style.paddingRight=this.bodyStyleOrgPaddingRight,this.checkCleanLayer()}),450),this.newActionTimer((()=>{this.$wrap.style.display="none",this.$wrap.classList.remove("atk-fade-out")}),200)}setMaskClickHide(e){this.maskClickHideEnable=e}newActionTimer(e,t){const i=()=>{e(),Ie.actionTimers=Ie.actionTimers.filter((e=>e.act!==i))},s=window.setTimeout((()=>i()),t);Ie.actionTimers.push({act:i,tid:s})}fireAllActionTimer(){Ie.actionTimers.forEach((e=>{clearTimeout(e.tid),e.act()}))}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.$wrap.style.display="none")}};let Pe=Ie;function Ue(e){let t=document.querySelector(`.atk-layer-wrap#ctx-${e.cid}`);t||(t=xe(`<div class="atk-layer-wrap" id="ctx-${e.cid}" style="display: none;"><div class="atk-layer-mask"></div></div>`),document.body.appendChild(t));const i=t.querySelector(".atk-layer-mask");return{$wrap:t,$mask:i}}__publicField(Pe,"actionTimers",[]);class ze{constructor(e){return __publicField(this,"$el"),__publicField(this,"$content"),__publicField(this,"$actions"),this.$el=xe('<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-actions"></div>\n </div>\n </div>'),this.$actions=this.$el.querySelector(".atk-layer-dialog-actions"),this.$content=this.$el.querySelector(".atk-layer-dialog-content"),this.$content.appendChild(e),this}setYes(e){const t=xe('<button data-action="confirm">确定</button>');return t.onclick=this.onBtnClick(e),this.$actions.appendChild(t),this}setNo(e){const t=xe('<button data-action="cancel">取消</button>');return t.onclick=this.onBtnClick(e),this.$actions.appendChild(t),this}onBtnClick(e){return t=>{const i=e(t.currentTarget,this);void 0!==i&&!0!==i||this.$el.remove()}}}function Ne(e,t,i,s){return __async(this,null,(function*(){if(e.user.data.token){const t=new Headers;t.set("Authorization",`Bearer ${e.user.data.token}`),i.headers=t}try{let a;if(a="number"!=typeof s&&0===e.conf.reqTimeout||0===s?yield fetch(t,i):yield(n=s||e.conf.reqTimeout||15e3,r=fetch(t,i),new Promise(((e,t)=>{const i=setTimeout((()=>{t(new Error("请求超时"))}),n);r.then((t=>{clearTimeout(i),e(t)}),(e=>{clearTimeout(i),t(e)}))}))),!a.ok&&401!==a.status)throw new Error(`请求响应 ${a.status}`);let l=yield a.json();const o=(s,n)=>{Ne(e,t,i).then((e=>{s(e)})).catch((e=>{n(e)}))};if(l.data&&l.data.need_captcha?l=yield new Promise(((t,i)=>{e.trigger("checker-captcha",{imgData:l.data.img_data,onSuccess:()=>{o(t,i)},onCancel:()=>{i(l)}})})):(l.data&&l.data.need_login||401===a.status)&&(l=yield new Promise(((t,i)=>{e.trigger("checker-admin",{onSuccess:()=>{o(t,i)},onCancel:()=>{i(l)}})}))),!l.success)throw l;return l}catch(a){if(console.error(a),a instanceof TypeError)throw new Error("网络错误");throw a}var n,r}))}function He(e,t,i){return __async(this,null,(function*(){const s={method:"POST"};i&&(s.body=De(i));return(yield Ne(e,t,s)).data||{}}))}function We(e,t,i){return __async(this,null,(function*(){return(yield Ne(e,t+(i?`?${new URLSearchParams(i)}`:""),{method:"GET"})).data||{}}))}function De(e){const t=new FormData;return Object.keys(e).forEach((i=>t.append(i,String(e[i])))),t}class Ve{constructor(e){__publicField(this,"ctx"),__publicField(this,"baseURL"),this.ctx=e,this.baseURL=e.conf.server}get(e,t,i,s){var n;const r={page_key:this.ctx.conf.pageKey,site_name:this.ctx.conf.site||"",limit:(null==(n=this.ctx.conf.pagination)?void 0:n.pageSize)||15,offset:e};return t&&(r.type=t),i&&(r.flat_mode=i),this.ctx.user.checkHasBasicUserInfo()&&(r.name=this.ctx.user.data.nick,r.email=this.ctx.user.data.email),s&&s(r),He(this.ctx,`${this.baseURL}/get`,r)}add(e){return __async(this,null,(function*(){const t={name:e.nick,email:e.email,link:e.link,content:e.content,rid:e.rid,page_key:e.page_key};e.page_title&&(t.page_title=e.page_title),e.site_name&&(t.site_name=e.site_name);return(yield He(this.ctx,`${this.baseURL}/add`,t)).comment}))}commentEdit(e){return __async(this,null,(function*(){const t=__spreadValues({},e);return(yield He(this.ctx,`${this.baseURL}/admin/comment-edit`,t)).comment}))}commentDel(e,t){const i={id:String(e),site_name:t||""};return He(this.ctx,`${this.baseURL}/admin/comment-del`,i)}login(e,t,i){return __async(this,null,(function*(){const s={name:e,email:t,password:i};this.ctx.conf.site&&(s.site_name=this.ctx.conf.site);return(yield He(this.ctx,`${this.baseURL}/login`,s)).token}))}userGet(e,t){const i=new AbortController,{signal:s}=i,n={name:e,email:t,site_name:this.ctx.conf.site||""};return{req:Ne(this.ctx,`${this.baseURL}/user-get`,{method:"POST",body:De(n),signal:s}).then((e=>({user:e.data.user,is_login:e.data.is_login,unread:e.data.unread||[],unread_count:e.data.unread_count||0}))),abort:()=>{i.abort()}}}pageGet(e,t,i){return __async(this,null,(function*(){const s={site_name:e||"",offset:t||0,limit:i||15};return yield He(this.ctx,`${this.baseURL}/admin/page-get`,s)}))}pageEdit(e){return __async(this,null,(function*(){const t={id:e.id,key:e.key,title:e.title,admin_only:e.admin_only,site_name:e.site_name||this.ctx.conf.site};return(yield He(this.ctx,`${this.baseURL}/admin/page-edit`,t)).page}))}pageDel(e,t){const i={key:String(e),site_name:t||""};return He(this.ctx,`${this.baseURL}/admin/page-del`,i)}pageFetch(e){return __async(this,null,(function*(){const t={id:e};return(yield He(this.ctx,`${this.baseURL}/admin/page-fetch`,t)).page}))}siteGet(){return __async(this,null,(function*(){return(yield He(this.ctx,`${this.baseURL}/admin/site-get`,{})).sites}))}siteAdd(e,t){return __async(this,null,(function*(){const i={name:e,urls:t};return(yield He(this.ctx,`${this.baseURL}/admin/site-add`,i)).site}))}siteEdit(e){return __async(this,null,(function*(){const t={id:e.id,name:e.name||"",urls:e.urls||""};return(yield He(this.ctx,`${this.baseURL}/admin/site-edit`,t)).site}))}siteDel(e,t=!1){const i={id:e,del_content:t};return He(this.ctx,`${this.baseURL}/admin/site-del`,i)}export(){return __async(this,null,(function*(){var e;return(null==(e=(yield Ne(this.ctx,`${this.baseURL}/admin/export`,{method:"POST"},0)).data)?void 0:e.data)||""}))}vote(e,t){return __async(this,null,(function*(){const i={site_name:this.ctx.conf.site||"",target_id:e,type:t};this.ctx.user.checkHasBasicUserInfo()&&(i.name=this.ctx.user.data.nick,i.email=this.ctx.user.data.email);return yield He(this.ctx,`${this.baseURL}/vote`,i)}))}markRead(e,t=!1){const i={site_name:this.ctx.conf.site||"",notify_key:e};return t&&(delete i.notify_key,i.read_all=!0,i.name=this.ctx.user.data.nick,i.email=this.ctx.user.data.email),He(this.ctx,`${this.baseURL}/mark-read`,i)}captchaGet(){return __async(this,null,(function*(){return(yield We(this.ctx,`${this.baseURL}/captcha/refresh`)).img_data||""}))}captchaCheck(e){return __async(this,null,(function*(){return(yield We(this.ctx,`${this.baseURL}/captcha/check`,{value:e})).img_data||""}))}}const je={request:(e,t)=>new Ve(e.ctx).captchaCheck(t),body(e){const t=xe(`<span><img class="atk-captcha-img" src="${e.submitCaptchaImgData||""}" alt="验证码">敲入验证码继续:</span>`);return t.querySelector(".atk-captcha-img").onclick=()=>{const i=t.querySelector(".atk-captcha-img");new Ve(e.ctx).captchaGet().then((e=>{i.setAttribute("src",e)})).catch((e=>{console.error("验证码获取失败 ",e)}))},t},onSuccess(e,t,i,s){e.submitCaptchaVal=i},onError(e,t,i,s){s.querySelector(".atk-captcha-img").click()}},Qe={inputType:"password",request(e,t){const i={name:e.ctx.user.data.nick,email:e.ctx.user.data.email,password:t};return new Ve(e.ctx).login(i.name,i.email,i.password)},body:()=>xe("<span>敲入密码来验证管理员身份:</span>"),onSuccess(e,t,i,s){e.ctx.user.data.isAdmin=!0,e.ctx.user.data.token=t,e.ctx.user.save(),e.ctx.trigger("user-changed",e.ctx.user.data),e.ctx.trigger("list-reload")},onError(e,t,i,s){}};class Ge{constructor(e){__publicField(this,"ctx"),__publicField(this,"launched",[]),__publicField(this,"submitCaptchaVal"),__publicField(this,"submitCaptchaImgData"),this.ctx=e,this.initEventBind()}initEventBind(){this.ctx.on("checker-captcha",(e=>{e.imgData&&(this.submitCaptchaImgData=e.imgData),this.fire(je,e)})),this.ctx.on("checker-admin",(e=>{this.fire(Qe,e)}))}fire(e,t){if(this.launched.includes(e))return;this.launched.push(e);const i=new Pe(this.ctx,`checker-${(new Date).getTime()}`);i.setMaskClickHide(!1),i.show();const s=xe();s.appendChild(e.body(this));const n=xe(`<input id="check" type="${e.inputType||"text"}" autocomplete="off" required placeholder="">`);let r;s.appendChild(n),setTimeout((()=>n.focus()),80),n.onkeyup=e=>{"Enter"!==e.key&&13!==e.keyCode||(e.preventDefault(),i.getEl().querySelector('button[data-action="confirm"]').click())};const a=new ze(s);a.setYes((l=>{const o=n.value.trim();r||(r=l.innerText);const c=()=>{l.innerText=r||"",l.classList.remove("error")};return l.innerText="加载中...",e.request(this,o).then((n=>{this.done(e,i),e.onSuccess&&e.onSuccess(this,n,o,s),t.onSuccess&&t.onSuccess(o,a.$el)})).catch((t=>{var i;i=String(t.msg||String(t)),l.innerText=i,l.classList.add("error"),e.onError&&e.onError(this,t,o,s);const r=setTimeout((()=>c()),3e3);n.onfocus=()=>{c(),clearTimeout(r)}})),!1})),a.setNo((()=>(this.done(e,i),t.onCancel&&t.onCancel(),!1))),i.getEl().append(a.$el),t.onMount&&t.onMount(a.$el)}done(e,t){t.disposeNow(),this.launched=this.launched.filter((t=>t!==e))}}class Ye{constructor(e){__publicField(this,"editor"),__publicField(this,"ctx"),this.editor=e,this.ctx=e.ctx}}__publicField(Ye,"Name"),__publicField(Ye,"BtnHTML");class Ze extends Ye{constructor(e){super(e),__publicField(this,"$el"),__publicField(this,"emoticons",[]),__publicField(this,"$listWrap"),__publicField(this,"$types"),this.editor=e,this.$el=xe('<div class="atk-editor-plug-emoticons"></div>'),this.init()}init(){return __async(this,null,(function*(){Ae(this.$el),this.emoticons=yield this.handleData(this.ctx.conf.emoticons),Oe(this.$el),this.initEmoticonsList()}))}handleData(e){return __async(this,null,(function*(){if(!Array.isArray(e)&&["object","string"].includes(typeof e)&&(e=[e]),!Array.isArray(e))return Re(this.$el,"表情包数据必须为 Array/Object/String 类型"),Oe(this.$el),[];const t=t=>{"object"==typeof t&&(t.name&&e.find((e=>e.name===t.name))||e.push(t))},i=e=>__async(this,null,(function*(){yield Promise.all(e.map(((e,s)=>__async(this,null,(function*(){if("object"!=typeof e||Array.isArray(e)){if(Array.isArray(e))yield i(e);else if("string"==typeof e){const s=yield this.remoteLoad(e);Array.isArray(s)?yield i(s):"object"==typeof s&&t(s)}}else t(e)})))))}));return yield i(e),e.forEach((e=>{if(this.isOwOFormat(e)){this.convertOwO(e).forEach((e=>{t(e)}))}else Array.isArray(e)&&e.forEach((e=>{t(e)}))})),e=e.filter((e=>"object"==typeof e&&!Array.isArray(e)&&!!e&&!!e.name)),console.log(e),this.solveNullKey(e),this.solveSameKey(e),e}))}remoteLoad(e){return __async(this,null,(function*(){if(!e)return[];try{const t=yield fetch(e);return yield t.json()}catch(t){return Oe(this.$el),Re(this.$el,`表情加载失败 ${String(t)}`),[]}}))}solveNullKey(e){e.forEach((e=>{e.items.forEach(((t,i)=>{t.key||(t.key=`${e.name} ${i+1}`)}))}))}solveSameKey(e){const t={};e.forEach((e=>{e.items.forEach((e=>{e.key&&""!==String(e.key).trim()&&(t[e.key]?t[e.key]++:t[e.key]=1,t[e.key]>1&&(e.key=`${e.key} ${t[e.key]}`))}))}))}isOwOFormat(e){try{return"object"==typeof e&&!!Object.values(e).length&&Array.isArray(Object.keys(Object.values(e)[0].container))&&Object.keys(Object.values(e)[0].container[0]).includes("icon")}catch(t){return!1}}convertOwO(e){const t=[];return Object.entries(e).forEach((([e,i])=>{const s={name:e,type:i.type,items:[]};i.container.forEach(((t,i)=>{const n=t.icon;if(/<(img|IMG)/.test(n)){const e=/src=["'](.*?)["']/.exec(n);e&&e.length>1&&(t.icon=e[1])}s.items.push({key:t.text||`${e} ${i+1}`,val:t.icon})})),t.push(s)})),t}initEmoticonsList(){this.$listWrap=xe('<div class="atk-emoticons-list-wrap"></div>'),this.$el.append(this.$listWrap),this.emoticons.forEach(((e,t)=>{const i=xe('<div class="atk-emoticons-list" style="display: none;"></div>');this.$listWrap.append(i),i.setAttribute("data-index",String(t)),i.setAttribute("data-grp-name",e.name),i.setAttribute("data-type",e.type),e.items.forEach((t=>{const s=xe('<span class="atk-emoticons-item"></span>');if(i.append(s),t.key&&!new RegExp(`^(${e.name})?\\s?[0-9]+$`).test(t.key)&&s.setAttribute("title",t.key),"image"===e.type){const e=document.createElement("img");e.src=t.val,e.alt=t.key,s.append(e)}else s.innerText=t.val;s.onclick=()=>{"image"===e.type?this.editor.insertContent(`:[${t.key}]`):this.editor.insertContent(t.val||"")}}))})),this.$types=xe('<div class="atk-emoticons-types"></div>'),this.$el.append(this.$types),this.emoticons.forEach(((e,t)=>{const i=xe("<span />");i.innerText=e.name,i.setAttribute("data-index",String(t)),i.onclick=()=>this.openGrp(t),this.$types.append(i)})),this.emoticons.length>0&&this.openGrp(0)}openGrp(e){var t;Array.from(this.$listWrap.children).forEach((t=>{const i=t;i.getAttribute("data-index")!==String(e)?i.style.display="none":i.style.display=""})),this.$types.querySelectorAll("span.active").forEach((e=>e.classList.remove("active"))),null==(t=this.$types.querySelector(`span[data-index="${e}"]`))||t.classList.add("active"),this.changeListHeight()}getEl(){return this.$el}changeListHeight(){}onShow(){setTimeout((()=>{this.changeListHeight()}),30)}onHide(){this.$el.parentElement.style.height=""}transEmoticonImageText(e){return this.emoticons&&Array.isArray(this.emoticons)?(this.emoticons.forEach((t=>{"image"===t.type&&Object.entries(t.items).forEach((([t,i])=>{e=e.split(`:[${i.key}]`).join(`<img src="${i.val}" atk-emoticon="${i.key}">`)}))})),e):e}}__publicField(Ze,"Name","emoticons"),__publicField(Ze,"BtnHTML","表情");class Ke extends Ye{constructor(e){super(e),__publicField(this,"$el"),__publicField(this,"binded",!1),this.initEl()}initEl(){this.$el=xe('<div class="atk-editor-plug-preview"></div>'),this.binded=!1}getEl(){return this.$el}onShow(){if(this.updateContent(),!this.binded){const e=()=>{this.updateContent()};this.editor.$textarea.addEventListener("input",e),this.editor.$textarea.addEventListener("change",e),this.binded=!0}}onHide(){}updateContent(){"none"!==this.$el.style.display&&(this.$el.innerHTML=this.editor.getContentMarked())}}__publicField(Ke,"Name","preview"),__publicField(Ke,"BtnHTML",'预览 <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>');class Xe extends i{constructor(e){super(e),__publicField(this,"LOADABLE_PLUG_LIST",[Ze,Ke]),__publicField(this,"plugList",{}),__publicField(this,"$header"),__publicField(this,"$textareaWrap"),__publicField(this,"$textarea"),__publicField(this,"$closeComment"),__publicField(this,"$plugWrap"),__publicField(this,"$bottom"),__publicField(this,"$bottomPartLeft"),__publicField(this,"$plugSwitcherWrap"),__publicField(this,"$bottomPartRight"),__publicField(this,"$submitBtn"),__publicField(this,"$notifyWrap"),__publicField(this,"replyComment",null),__publicField(this,"$sendReply",null),__publicField(this,"isTraveling",!1),__publicField(this,"queryUserInfo",{timeout:null,abortFunc:null}),__publicField(this,"openedPlugName",null),this.$el=xe('<div class="atk-main-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.$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.data,e.$el,e.scroll))),this.ctx.on("editor-reply-cancel",(()=>this.cancelReply())),this.ctx.on("editor-show-loading",(()=>Ae(this.$el))),this.ctx.on("editor-hide-loading",(()=>Oe(this.$el))),this.ctx.on("editor-notify",(e=>this.showNotify(e.msg,e.type))),this.ctx.on("editor-travel",(e=>this.travel(e))),this.ctx.on("editor-travel-back",(()=>this.travelBack()))}get user(){return this.ctx.user}initLocalStorage(){const e=window.localStorage.getItem("ArtalkContent")||"";""!==e.trim()&&(this.showNotify("已自动恢复","i"),this.setContent(e)),this.$textarea.addEventListener("input",(()=>{this.saveContent()}))}initHeader(){Object.keys(this.user.data).forEach((e=>{const t=this.getInputEl(e);t&&t instanceof HTMLInputElement&&(t.value=this.user.data[e]||"",t.addEventListener("input",(()=>this.onHeaderInputChanged(e,t))))}))}getInputEl(e){return this.$header.querySelector(`[name="${e}"]`)}onHeaderInputChanged(e,t){this.user.data[e]=t.value.trim(),"nick"!==e&&"email"!==e||(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:e,abort:t}=new Ve(this.ctx).userGet(this.user.data.nick,this.user.data.email);this.queryUserInfo.abortFunc=t,e.then((e=>{e.is_login||(this.user.data.token="",this.user.data.isAdmin=!1),this.ctx.trigger("unread-update",{notifies:e.unread}),this.user.checkHasBasicUserInfo()&&!e.is_login&&e.user&&e.user.is_admin&&this.showLoginDialog(),e.user&&e.user.link&&(this.user.data.link=e.user.link,this.getInputEl("link").value=e.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",(e=>{9===(e.keyCode||e.which)&&(e.preventDefault(),this.insertContent("\t"))})),this.$textarea.addEventListener("input",(e=>{this.adjustTextareaHeight()}))}adjustTextareaHeight(){const e=this.$textarea.offsetHeight-this.$textarea.clientHeight;this.$textarea.style.height="0px",this.$textarea.style.height=`${this.$textarea.scrollHeight+e}px`}initEditorPlug(){this.plugList={},this.$plugWrap.innerHTML="",this.$plugWrap.style.display="none",this.openedPlugName=null,this.$plugSwitcherWrap.innerHTML="",this.LOADABLE_PLUG_LIST.forEach((e=>{const t=xe(`<span class="atk-editor-action atk-editor-plug-switcher">${e.BtnHTML}</span>`);this.$plugSwitcherWrap.appendChild(t),t.addEventListener("click",(()=>{let i=this.plugList[e.Name];if(i||(i=new e(this),this.plugList[e.Name]=i),this.$plugSwitcherWrap.querySelectorAll(".active").forEach((e=>e.classList.remove("active"))),e.Name===this.openedPlugName)return i.onHide(),this.$plugWrap.style.display="none",void(this.openedPlugName=null);if(null===this.$plugWrap.querySelector(`[data-plug-name="${e.Name}"]`)){const t=i.getEl();t.setAttribute("data-plug-name",e.Name),t.style.display="none",this.$plugWrap.appendChild(t)}Array.from(this.$plugWrap.children).forEach((t=>{const i=t.getAttribute("data-plug-name");i===e.Name?(t.style.display="",this.plugList[i].onShow()):(t.style.display="none",this.plugList[i].onHide())})),this.$plugWrap.style.display="",this.openedPlugName=e.Name,t.classList.add("active")}))}))}closePlug(){this.$plugWrap.innerHTML="",this.$plugWrap.style.display="none",this.openedPlugName=null}insertContent(e){if(document.selection)this.$textarea.focus(),document.selection.createRange().text=e,this.$textarea.focus();else if(this.$textarea.selectionStart||0===this.$textarea.selectionStart){const t=this.$textarea.selectionStart,i=this.$textarea.selectionEnd,s=this.$textarea.scrollTop;this.setContent(this.$textarea.value.substring(0,t)+e+this.$textarea.value.substring(i,this.$textarea.value.length)),this.$textarea.focus(),this.$textarea.selectionStart=t+e.length,this.$textarea.selectionEnd=t+e.length,this.$textarea.scrollTop=s}else this.$textarea.focus(),this.$textarea.value+=e}setContent(e){this.$textarea.value=e,this.saveContent(),this.plugList&&this.plugList.preview&&this.plugList.preview.updateContent(),this.adjustTextareaHeight()}clearEditor(){this.setContent(""),this.cancelReply()}getContent(){let e=this.getContentOriginal();if(this.plugList&&this.plugList.emoticons){e=this.plugList.emoticons.transEmoticonImageText(e)}return e}getContentOriginal(){return this.$textarea.value||""}getContentMarked(){return Ee(this.ctx,this.getContent())}initBottomPart(){this.initReply(),this.initSubmit()}initReply(){this.replyComment=null,this.$sendReply=null}setReply(e,t,i=!0){null!==this.replyComment&&this.cancelReply(),null===this.$sendReply&&(this.$sendReply=xe('<div class="atk-send-reply">回复 <span class="atk-text"></span><span class="atk-cancel" title="取消 AT">×</span></div>'),this.$sendReply.querySelector(".atk-text").innerText=`@${e.nick}`,this.$sendReply.addEventListener("click",(()=>{this.cancelReply()})),this.$textareaWrap.append(this.$sendReply)),this.replyComment=e,!0===this.ctx.conf.editorTravel&&this.travel(t),i&&qe(this.$el),this.$textarea.focus()}cancelReply(){null!==this.$sendReply&&(this.$sendReply.remove(),this.$sendReply=null),this.replyComment=null,!0===this.ctx.conf.editorTravel&&this.travelBack()}initSubmit(){this.$submitBtn.innerText=this.ctx.conf.sendBtn||"Send",this.$submitBtn.addEventListener("click",(e=>{e.currentTarget,this.submit()}))}submit(){return __async(this,null,(function*(){if(""!==this.getContent().trim()){this.ctx.trigger("editor-submit"),Ae(this.$el);try{const e=yield new Ve(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,page_key:null===this.replyComment?this.ctx.conf.pageKey:this.replyComment.page_key,page_title:null===this.replyComment?this.ctx.conf.pageTitle:void 0,site_name:null===this.replyComment?this.ctx.conf.site:this.replyComment.site_name});null!==this.replyComment&&this.replyComment.page_key!==this.ctx.conf.pageKey&&window.open(`${this.replyComment.page_key}#atk-comment-${e.id}`),this.ctx.trigger("list-insert",e),this.clearEditor(),this.ctx.trigger("editor-submitted")}catch(e){return console.error(e),void this.showNotify(`评论失败,${e.msg||String(e)}`,"e")}finally{Oe(this.$el)}}else this.$textarea.focus()}))}showNotify(e,t){Be(this.$notifyWrap,e,t)}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=""}travel(e){if(this.isTraveling)return;this.isTraveling=!0,this.$el.after(xe('<div class="atk-editor-travel-placeholder"></div>'));const t=xe("<div></div>");e.after(t),t.replaceWith(this.$el)}travelBack(){var e;this.isTraveling&&(this.isTraveling=!1,null==(e=this.ctx.$root.querySelector(".atk-editor-travel-placeholder"))||e.replaceWith(this.$el),null!==this.replyComment&&this.cancelReply())}}var Je=window||{},et=navigator||{};function tt(e){var t=e||et.userAgent,i=this,s={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};s.Mobile?s.Mobile=!(t.indexOf("iPad")>-1):Je.showModalDialog&&Je.chrome&&(s[360]=!0);var n,r={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 a in i.device="PC",i.language=((n=(et.browserLanguage||et.language).split("-"))[1]&&(n[1]=n[1].toUpperCase()),n.join("_")),r)for(var l=0;l<r[a].length;l++){var o=r[a][l];s[o]&&(i[a]=o)}var c={Windows:function(){var e=t.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"}[e]||e},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")}};i.osVersion="",c[i.os]&&(i.osVersion=c[i.os](),i.osVersion===t&&(i.osVersion=""));var h={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")}};i.version="",h[i.browser]&&(i.version=h[i.browser](),i.version===t&&(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 it(e){return new tt(e)}class st{constructor(e){__publicField(this,"conf"),__publicField(this,"$el"),__publicField(this,"isLoading",!1),__publicField(this,"msgRecTimer"),__publicField(this,"msgRecTimerFunc"),__publicField(this,"isConfirming",!1),__publicField(this,"confirmRecTimer"),this.$el=xe('<span class="atk-common-action-btn"></span>'),this.conf="object"!=typeof e?{text:e}:e,this.$el.innerText=this.getText(),this.conf.adminOnly&&this.$el.setAttribute("atk-only-admin-show","")}get isMessaging(){return!!this.msgRecTimer}appendTo(e){return e.append(this.$el),this}getText(){return"string"==typeof this.conf.text?this.conf.text:this.conf.text()}setClick(e){this.$el.onclick=t=>{if(t.stopPropagation(),!this.isLoading){if(this.conf.confirm&&!this.isMessaging){const e=()=>{this.isConfirming=!1,this.$el.classList.remove("atk-btn-confirm"),this.$el.innerText=this.getText()};if(!this.isConfirming)return this.isConfirming=!0,this.$el.classList.add("atk-btn-confirm"),this.$el.innerText=this.conf.confirmText||"确认操作",void(this.confirmRecTimer=window.setTimeout((()=>e()),5e3));this.confirmRecTimer&&window.clearTimeout(this.confirmRecTimer),e()}if(this.msgRecTimer)return this.fireMsgRecTimer(),void this.clearMsgRecTimer();e()}}}updateText(e){e&&(this.conf.text=e),this.setLoading(!1),this.$el.innerText=this.getText()}setLoading(e=!0,t){this.isLoading!==e&&(this.isLoading=e,e?(this.$el.classList.add("atk-btn-loading"),this.$el.innerText=t||"加载中..."):(this.$el.classList.remove("atk-btn-loading"),this.$el.innerText=this.getText()))}setError(e){this.setMsg(e,"atk-btn-error")}setWarn(e){this.setMsg(e,"atk-btn-warn")}setSuccess(e){this.setMsg(e,"atk-btn-success")}setMsg(e,t,i,s){this.setLoading(!1),t&&this.$el.classList.add(t),this.$el.innerText=e,this.setMsgRecTimer((()=>{this.$el.innerText=this.getText(),t&&this.$el.classList.remove(t),s&&s()}),i||2500)}setMsgRecTimer(e,t){this.fireMsgRecTimer(),this.clearMsgRecTimer(),this.msgRecTimerFunc=e,this.msgRecTimer=window.setTimeout((()=>{e(),this.clearMsgRecTimer()}),t)}fireMsgRecTimer(){this.msgRecTimerFunc&&this.msgRecTimerFunc()}clearMsgRecTimer(){this.msgRecTimer&&window.clearTimeout(this.msgRecTimer),this.msgRecTimer=void 0,this.msgRecTimerFunc=void 0}}class nt extends i{constructor(e,t){super(e),__publicField(this,"data"),__publicField(this,"$main"),__publicField(this,"$header"),__publicField(this,"$body"),__publicField(this,"$content"),__publicField(this,"$children"),__publicField(this,"$actions"),__publicField(this,"voteBtnUp"),__publicField(this,"voteBtnDown"),__publicField(this,"parent"),__publicField(this,"nestedNum"),__publicField(this,"maxNestingNum"),__publicField(this,"children",[]),__publicField(this,"replyTo"),__publicField(this,"$replyTo"),__publicField(this,"afterRender"),__publicField(this,"unread",!1),__publicField(this,"openable",!1),__publicField(this,"openURL"),__publicField(this,"openEvt"),__publicField(this,"onReplyBtnClick"),__publicField(this,"onDelete"),this.maxNestingNum=e.conf.maxNesting||3,this.data=__spreadValues({},t),this.data.date=this.data.date.replace(/-/g,"/"),this.parent=null,this.nestedNum=1}render(){return this.$el=xe('<div class="atk-comment-wrap" data-comment-id="">\n <div class="atk-comment">\n\n <div class="atk-avatar"></div>\n\n <div class="atk-comment-main">\n\n <div class="atk-header">\n <span class="atk-nick"></span>\n <span class="atk-badge"></span>\n <span class="atk-date"></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.$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",(e=>{this.openable&&this.openURL&&(e.preventDefault(),window.open(this.openURL)),this.openEvt&&this.openEvt()}))}renderAvatar(){const e=this.$el.querySelector(".atk-avatar"),t=xe("<img />");if(t.src=this.getGravatarUrl(),this.data.link){const i=xe('<a target="_blank" rel="noreferrer noopener nofollow"></a>');i.href=this.data.link,i.append(t),e.append(i)}else e.append(t)}renderHeader(){const e=this.$el.querySelector(".atk-nick");if(this.data.link){const t=xe('<a target="_blank" rel="noreferrer noopener nofollow"></a>');t.innerText=this.data.nick,t.href=this.data.link,e.append(t)}else e.innerText=this.data.nick;const t=this.$el.querySelector(".atk-badge");this.data.badge_name?(t.innerText=this.data.badge_name,this.data.badge_color&&(t.style.backgroundColor=this.data.badge_color)):t.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 e=xe('<span class="atk-ua-wrap"></span>'),t=xe('<span class="atk-ua ua-browser"></span>'),i=xe('<span class="atk-ua ua-os"></span>');t.innerText=this.getUserUaBrowser(),i.innerText=this.getUserUaOS(),e.append(t),e.append(i),this.$header.append(e)}}renderContent(){if(!this.data.is_collapsed)return void(this.$content.innerHTML=this.getContentMarked());this.$content.classList.add("atk-hide","atk-type-collapsed");const e=xe('\n <div class="atk-collapsed">\n <span class="atk-text">该评论已被系统或管理员折叠</span>\n <span class="atk-show-btn">查看内容</span>\n </div>');this.$body.insertAdjacentElement("beforeend",e);const t=e.querySelector(".atk-show-btn");t.addEventListener("click",(e=>{e.stopPropagation(),this.$content.classList.contains("atk-hide")?(this.$content.innerHTML=this.getContentMarked(),this.$content.classList.remove("atk-hide"),Me(this.$content),t.innerHTML="收起内容"):(this.$content.innerHTML="",this.$content.classList.add("atk-hide"),t.innerHTML="查看内容")}))}renderReplyTo(){if(!this.replyTo)return;this.$replyTo=xe('\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>'),this.$replyTo.querySelector(".atk-nick").innerText=`@${this.replyTo.nick}`;let e=Ee(this.ctx,this.replyTo.content);this.replyTo.is_collapsed&&(e="[已折叠]"),this.$replyTo.querySelector(".atk-content").innerHTML=e,this.$body.prepend(this.$replyTo)}renderPending(){if(!this.data.is_pending)return;const e=xe('<div class="atk-pending">审核中,仅本人可见。</div>');this.$body.prepend(e)}renderActionBtn(){if(this.ctx.conf.vote&&(this.voteBtnUp=new st((()=>`赞同 (${this.data.vote_up||0})`)).appendTo(this.$actions),this.voteBtnUp.setClick((()=>{this.vote("up")})),this.ctx.conf.voteDown&&(this.voteBtnDown=new st((()=>`反对 (${this.data.vote_down||0})`)).appendTo(this.$actions),this.voteBtnDown.setClick((()=>{this.vote("down")})))),this.data.is_allow_reply){const e=xe('<span data-atk-action="comment-reply">回复</span>');this.$actions.append(e),e.addEventListener("click",(e=>{e.stopPropagation(),this.onReplyBtnClick?this.onReplyBtnClick():this.ctx.trigger("editor-reply",{data:this.data,$el:this.$el})}))}const e=new st({text:()=>this.data.is_collapsed?"取消折叠":"折叠",adminOnly:!0});e.appendTo(this.$actions),e.setClick((()=>{this.adminEdit("collapsed",e)}));const t=new st({text:()=>this.data.is_pending?"待审":"已审",adminOnly:!0});t.appendTo(this.$actions),t.setClick((()=>{this.adminEdit("pending",t)}));const i=new st({text:"删除",confirm:!0,confirmText:"确认删除",adminOnly:!0});i.appendTo(this.$actions),i.setClick((()=>{this.adminDelete(i)}))}refreshUI(){const e=this.$el,t=this.render();e.replaceWith(t),this.playFadeInAnim(),this.eachComment(this.children,(e=>{var t;null==(t=e.parent)||t.getChildrenEl().appendChild(e.render()),e.playFadeInAnim()})),this.ctx.trigger("comments-loaded")}eachComment(e,t){0!==e.length&&e.every((i=>!1!==t(i,e)&&(this.eachComment(i.getChildren(),t),!0)))}getIsRoot(){return null===this.parent}getChildren(){return this.children}putChild(e){e.parent=this,e.nestedNum=this.nestedNum+1,this.children.push(e),this.getChildrenEl().appendChild(e.getEl()),e.playFadeInAnim()}getChildrenEl(){return null===this.$children&&(this.nestedNum<this.maxNestingNum?(this.$children=xe('<div class="atk-comment-children"></div>'),this.$main.appendChild(this.$children)):this.parent&&(this.$children=this.parent.getChildrenEl())),this.$children}getParent(){return this.parent}getParents(){const e=[],t=i=>{i.parent&&(e.push(i.parent),t(i.parent))};return t(this),e}getEl(){return this.$el}getData(){return this.data}getGravatarUrl(){return Ce(this.ctx,this.data.email_encrypted)}getContentMarked(){return Ee(this.ctx,this.data.content)}getDateFormatted(){return Le(new Date(this.data.date))}getUserUaBrowser(){const e=it(this.data.ua);return`${e.browser} ${e.version}`}getUserUaOS(){const e=it(this.data.ua);return`${e.os} ${e.osVersion}`}playFadeInAnim(){Me(this.$el)}vote(e){const t="up"===e?this.voteBtnUp:this.voteBtnDown;new Ve(this.ctx).vote(this.data.id,`comment_${e}`).then((e=>{var t,i;this.data.vote_up=e.up,this.data.vote_down=e.down,null==(t=this.voteBtnUp)||t.updateText(),null==(i=this.voteBtnDown)||i.updateText()})).catch((e=>{null==t||t.setError("投票失败"),console.log(e)}))}adminEdit(e,t){if(t.isLoading)return;t.setLoading(!0,"修改中...");const i=__spreadValues({},this.data);"collapsed"===e?i.is_collapsed=!i.is_collapsed:"pending"===e&&(i.is_pending=!i.is_pending),new Ve(this.ctx).commentEdit(i).then((e=>{t.setLoading(!1),this.data=e,this.refreshUI(),Me(this.$body),this.ctx.trigger("list-refresh-ui")})).catch((e=>{console.error(e),t.setError("修改失败")}))}adminDelete(e){e.isLoading||(e.setLoading(!0,"删除中..."),new Ve(this.ctx).commentDel(this.data.id,this.data.site_name).then((()=>{e.setLoading(!1),this.onDelete&&this.onDelete(this)})).catch((t=>{console.error(t),e.setError("删除失败")})))}setUnread(e){this.unread=e,this.unread?this.$el.classList.add("atk-unread"):this.$el.classList.remove("atk-unread")}setOpenURL(e){e||(this.openable=!1,this.$el.classList.remove("atk-openable")),this.openable=!0,this.openURL=e,this.$el.classList.add("atk-openable")}}class rt{constructor(e,t){__publicField(this,"conf"),__publicField(this,"total"),__publicField(this,"$el"),__publicField(this,"$input"),__publicField(this,"inputTimer"),__publicField(this,"$prevBtn"),__publicField(this,"$nextBtn"),__publicField(this,"page",1),this.total=e,this.conf=t,this.$el=xe('<div class="atk-pagination-wrap">\n <div class="atk-pagination">\n <div class="atk-btn atk-btn-prev">Prev</div>\n <input type="text" class="atk-input" />\n <div class="atk-btn atk-btn-next">Next</div>\n </div>\n </div>'),this.$input=this.$el.querySelector(".atk-input"),this.$input.value=`${this.page}`,this.$input.oninput=()=>this.input(),this.$input.onkeydown=e=>this.keydown(e),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()}get pageSize(){return this.conf.pageSize||15}get offset(){return this.pageSize*(this.page-1)}get maxPage(){return Math.ceil(this.total/this.pageSize)}update(e,t){this.page=Math.ceil(e/this.pageSize)+1,this.total=t,this.setInput(this.page),this.checkDisabled()}setInput(e){this.$input.value=`${e}`}input(e=!1){window.clearTimeout(this.inputTimer);const t=this.$input.value.trim(),i=()=>{if(""===t)return void this.setInput(this.page);let e=Number(t);Number.isNaN(e)||e<1?this.setInput(this.page):(e>this.maxPage&&(this.setInput(this.maxPage),e=this.maxPage),this.change(e))};e?i():this.inputTimer=window.setTimeout((()=>i()),800)}prev(){const e=this.page-1;e<1||this.change(e)}next(){const e=this.page+1;e>this.maxPage||this.change(e)}change(e){this.page=e,this.conf.onChange(this.offset),this.setInput(e),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(e){const t=e.keyCode||e.which;if(38===t){const e=Number(this.$input.value)+1;if(e>this.maxPage)return;this.setInput(e),this.input()}else if(40===t){const e=Number(this.$input.value)-1;if(e<1)return;this.setInput(e),this.input()}else 13===t&&this.input(!0)}setLoading(e){e?Ae(this.$el):Oe(this.$el)}}class at{constructor(e){__publicField(this,"conf"),__publicField(this,"$el"),__publicField(this,"$loading"),__publicField(this,"$text"),this.conf=e,this.$el=xe('<div class="atk-list-read-more" style="display: none;">\n <div class="atk-list-read-more-inner">\n <div class="atk-loading-icon" style="display: none;"></div>\n <span class="atk-text">查看更多</span>\n </div>\n </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(e){this.$loading.style.display=e?"":"none",this.$text.style.display=e?"none":""}showErr(e){this.setLoading(!1),this.$text.innerText=e,this.$el.classList.add("atk-err"),window.setTimeout((()=>{this.$text.innerText="查看更多",this.$el.classList.remove("atk-err")}),2e3)}}class lt extends i{constructor(e,t){super(e),__publicField(this,"$parent"),__publicField(this,"$commentsWrap"),__publicField(this,"comments",[]),__publicField(this,"data"),__publicField(this,"pageSize",15),__publicField(this,"offset",0),__publicField(this,"type"),__publicField(this,"noCommentText"),__publicField(this,"renderComment"),__publicField(this,"paramsEditor"),__publicField(this,"onAfterLoad"),__publicField(this,"isLoading",!1),__publicField(this,"isFirstLoad",!0),__publicField(this,"flatMode"),__publicField(this,"pageMode","pagination"),__publicField(this,"pagination"),__publicField(this,"readMoreBtn"),__publicField(this,"autoLoadScrollEvent"),__publicField(this,"autoLoadListenerAt"),__publicField(this,"unread",[]),__publicField(this,"unreadHighlight",!1),this.$parent=t,this.$el=xe('<div class="atk-list-lite">\n <div class="atk-list-comments-wrap"></div>\n </div>'),this.$commentsWrap=this.$el.querySelector(".atk-list-comments-wrap"),this.pageSize=this.conf.pagination&&this.conf.pagination.pageSize||this.pageSize,this.noCommentText=this.conf.noComment||"无评论",window.setInterval((()=>{this.$el.querySelectorAll("[data-atk-comment-date]").forEach((e=>{const t=e.getAttribute("data-atk-comment-date");e.innerText=Le(new Date(Number(t)))}))}),3e4),this.ctx.on("unread-update",(e=>this.updateUnread(e.notifies)))}reqComments(e=0){return __async(this,null,(function*(){0===e&&"pagination"!==this.pageMode&&this.clearAllComments();const t=()=>{this.isLoading=!1,0===e?Oe(this.$el):"read-more"===this.pageMode?this.readMoreBtn.setLoading(!1):"pagination"===this.pageMode&&this.pagination.setLoading(!1)};let i;(()=>{this.isLoading=!0,0===e?Ae(this.$el):"read-more"===this.pageMode?this.readMoreBtn.setLoading(!0):"pagination"===this.pageMode&&this.pagination.setLoading(!0)})(),this.ctx.trigger("comments-load");try{i=yield new Ve(this.ctx).get(e,this.type,this.flatMode,this.paramsEditor)}catch(s){throw this.onError(s.msg||String(s)),s}finally{t()}if(this.ctx.conf.versionCheck){if(this.apiVersionCheck(i.api_version||{}))return}this.offset=e;try{this.onLoad(i,e),this.onAfterLoad&&this.onAfterLoad(i)}catch(s){throw this.onError(String(s)),s}finally{t()}}))}onLoad(e,t){var i;Re(this.$el,null),"pagination"===this.pageMode&&this.clearAllComments(),this.data=e,this.importComments(e.comments),this.isFirstLoad&&this.onLoadInit(),"pagination"===this.pageMode&&this.pagination.update(t,(null==(i=this.data)?void 0:i.total_parents)||0),"read-more"===this.pageMode&&(this.hasMoreComments?this.readMoreBtn.show():this.readMoreBtn.hide()),this.ctx.trigger("unread-update",{notifies:e.unread||[]}),this.isFirstLoad=!1}onLoadInit(){var e;if(this.autoLoadScrollEvent){(this.autoLoadListenerAt||document).removeEventListener("scroll",this.autoLoadScrollEvent)}if("read-more"===this.pageMode){const t=new at({onClick:()=>__async(this,null,(function*(){const e=this.offset+this.pageSize;yield this.reqComments(e)}))});if(this.readMoreBtn?this.readMoreBtn.$el.replaceWith(t.$el):this.$el.append(t.$el),this.readMoreBtn=t,null==(e=this.conf.pagination)?void 0:e.autoLoad){this.autoLoadScrollEvent=()=>{if("read-more"!==this.pageMode)return;if(!this.hasMoreComments)return;if(this.isLoading)return;const e=this.$el.querySelector(".atk-list-comments-wrap > .atk-comment-wrap:nth-last-child(3)");e&&function(e,t=document.documentElement){const i=t.clientHeight,s=t.scrollTop,n=s+i,r=e.getBoundingClientRect();return r.top+s+r.height<=n}(e,this.autoLoadListenerAt)&&this.readMoreBtn.click()};(this.autoLoadListenerAt||document).addEventListener("scroll",this.autoLoadScrollEvent)}}else if("pagination"===this.pageMode){const e=new rt(this.parentCommentsCount,{pageSize:this.pageSize,onChange:e=>__async(this,null,(function*(){if(!0===this.ctx.conf.editorTravel&&this.ctx.trigger("editor-travel-back"),yield this.reqComments(e),this.$parent){let e=0;!this.autoLoadListenerAt&&this.$parent&&(e=Se(this.$parent).top);(this.autoLoadListenerAt||window).scroll({top:e,left:0})}}))});this.pagination?this.pagination.$el.replaceWith(e.$el):this.$el.append(e.$el),this.pagination=e}}onError(e){var t;if(e=String(e),console.error(e),this.isFirstLoad||"pagination"===this.pageMode){const t=xe(`<span>${e},无法获取评论列表数据<br/></span>`),i=xe('<span style="cursor:pointer;">点击重新获取</span>');i.onclick=()=>{this.reqComments(this.offset)},t.appendChild(i);const s=xe('<span atk-only-admin-show> | <span style="cursor:pointer;">打开控制台</span></span>');s.onclick=()=>{this.ctx.trigger("sidebar-show")},this.ctx.user.data.isAdmin||s.classList.add("atk-hide"),t.appendChild(s),Re(this.$el,t)}else null==(t=this.readMoreBtn)||t.showErr("获取失败")}refreshUI(){const e=this.comments.length<=0;let t=this.$commentsWrap.querySelector(".atk-list-no-comment");e&&(t||(t=xe('<div class="atk-list-no-comment"></div>'),this.$commentsWrap.appendChild(t),t.innerHTML=this.noCommentText)),!e&&t&&t.remove(),this.ctx.trigger("check-admin-show-el")}createComment(e){const t=new nt(this.ctx,e);return t.afterRender=()=>{this.renderComment&&this.renderComment(t)},t.onDelete=e=>{this.deleteComment(e),this.refreshUI()},t}importComments(e){const t=i=>{const s=e.filter((e=>e.rid===i.data.id));0!==s.length&&s.forEach((e=>{e.is_allow_reply=i.data.is_allow_reply;const s=this.createComment(e);s.render(),i.putChild(s),t(s)}))};this.flatMode?e.forEach((t=>{this.putCommentFlatMode(t,e,"append")})):e.filter((e=>0===e.rid)).forEach((e=>{e.is_collapsed&&(e.is_allow_reply=!1);const i=this.createComment(e);i.render(),this.comments.push(i),this.$commentsWrap.appendChild(i.getEl()),i.playFadeInAnim(),t(i)})),this.eachComment(this.comments,(e=>{e.getIsRoot()&&this.checkMoreHide(e)})),this.refreshUI(),this.ctx.trigger("comments-loaded")}putCommentFlatMode(e,t,i){e.is_collapsed&&(e.is_allow_reply=!1);const s=this.createComment(e);if(0!==e.rid){const i=t.find((t=>t.id===e.rid));i&&(s.replyTo=i)}return s.render(),"append"===i?this.comments.push(s):this.comments.unshift(s),e.visible&&("append"===i?this.$commentsWrap.appendChild(s.getEl()):this.$commentsWrap.prepend(s.getEl()),s.playFadeInAnim()),this.checkMoreHide(s),s}insertComment(e){if(this.flatMode){qe(this.putCommentFlatMode(e,this.comments.map((e=>e.data)),"prepend").getEl())}else{const t=this.createComment(e);if(t.render(),0===e.rid)this.$commentsWrap.prepend(t.getEl()),this.comments.unshift(t),this.checkMoreHide(t);else{const i=this.findComment(e.rid);i&&(i.putChild(t),i.$children&&this.removeHideMore(i.$children),this.eachComment(i.children,(e=>{this.checkMoreHide(e)})))}qe(t.getEl()),t.playFadeInAnim()}this.data&&(this.data.total+=1),this.refreshUI(),this.ctx.trigger("comments-loaded")}checkMoreHide(e){const t=()=>{this.checkMoreHideEl(e,"children"),this.checkMoreHideEl(e,"content"),e.$replyTo&&this.checkMoreHideEl(e,"replyTo")};t(),e.$content.querySelectorAll("img").length&&function(e,t){const i=e.getElementsByTagName("img");if(!i.length)return;let s=i.length;for(let n=0;n<i.length;n++)i[n].complete?s--:i[n].addEventListener("load",(()=>{s--,0===s&&t()})),0===s&&t()}(e.$content,(()=>{t()}))}checkMoreHideEl(e,t,i=300){var s,n;const r=null==(s=this.ctx.conf.heightLimit)?void 0:s.children,a=null==(n=this.ctx.conf.heightLimit)?void 0:n.content;if("children"===t&&!r)return;if(("content"===t||"replyTo"===t)&&!a)return;let l;if(i="children"===t?r||300:a||200,"children"===t?l=e.$children:"content"===t?l=e.$content:"replyTo"===t&&(l=e.$replyTo),!l)return;let o=l.querySelector(".atk-more-hide-open-btn");_e(l)>i&&(l.classList.add("atk-comment-more-hide"),l.style.height=`${i}px`,l.style.overflow="hidden",o||(o=xe('<div class="atk-more-hide-open-btn">阅读更多</span>'),o.onclick=t=>{if(t.stopPropagation(),l.classList.remove("atk-comment-more-hide"),o&&o.remove(),l.style.height="",l.style.overflow="",e.getIsRoot()){const t=e.getChildren();t.length>1&&this.eachComment(t,(e=>{this.checkMoreHideEl(e,"content",a||200)}))}},l.append(o)))}removeHideMore(e){const t=e.querySelector(".atk-more-hide-open-btn");e.classList.remove("atk-comment-more-hide"),t&&t.remove(),e.style.height="",e.style.overflow=""}get commentsCount(){var e;return Number(null==(e=this.data)?void 0:e.total)||0}get parentCommentsCount(){var e;return Number(null==(e=this.data)?void 0:e.total_parents)||0}get hasMoreComments(){return!!this.data&&(this.flatMode?this.data.total:this.data.total_parents)>this.offset+this.pageSize}eachComment(e,t){0!==e.length&&e.every((i=>!1!==t(i,e)&&(this.eachComment(i.getChildren(),t),!0)))}findComment(e,t){t||(t=this.comments);let i=null;return this.eachComment(t,(t=>t.data.id!==e||(i=t,!1))),i}getCommentCount(){let e=0;return this.eachComment(this.comments,(()=>{e++})),e}deleteComment(e){let t;if("number"==typeof e){if(t=this.findComment(e),!t)throw Error(`未找到评论 ${e}`)}else t=e;t.getEl().remove(),this.eachComment(this.comments,((e,i)=>e!==t||(i.splice(i.indexOf(e),1),!1))),this.data&&(this.data.total-=1),this.refreshUI()}clearAllComments(){this.$commentsWrap.innerHTML="",this.data=void 0,this.comments=[]}updateUnread(e){this.unread=e,this.unreadHighlight&&this.eachComment(this.comments,(e=>{const t=this.unread.find((t=>t.comment_id===e.data.id));t?(e.setUnread(!0),e.setOpenURL(t.read_link),e.openEvt=()=>{this.unread=this.unread.filter((t=>t.comment_id!==e.data.id)),this.ctx.trigger("unread-update",{notifies:this.unread})}):e.setUnread(!1)}))}apiVersionCheck(e){const t=(null==e?void 0:e.fe_min_version)||"0.0.0",i=1===function(e,t){const i=e.split("."),s=t.split(".");for(let n=0;n<3;n++){const e=Number(i[n]),t=Number(s[n]);if(e>t)return 1;if(t>e)return-1;if(!Number.isNaN(e)&&Number.isNaN(t))return 1;if(Number.isNaN(e)&&!Number.isNaN(t))return-1}return 0}(t,"2.1.3");if(i){const e=xe(`<div>前端 Artalk 版本已过时,请更新以获得完整体验<br/>若您是站点管理员,请前往 “<a href="https://artalk.js.org/" target="_blank">官方文档</a>” 获取帮助<br/><br/><span style="color: var(--at-color-meta);">前端版本 2.1.3,需求版本 >= ${t}</span><br/><br/></div>`),i=xe('<span style="cursor:pointer;">忽略</span>');i.onclick=()=>{Re(this.ctx,null),this.ctx.conf.versionCheck=!1,this.reqComments(0)},e.append(i),Re(this.ctx,e,'<span class="atk-warn-title">Artalk Warn</span>')}return i}}class ot extends lt{constructor(e){var t;const i=xe('<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-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');super(e,i),__publicField(this,"$closeCommentBtn"),__publicField(this,"$openSidebarBtn"),__publicField(this,"$unreadBadge"),i.querySelector(".atk-list-body").append(this.$el),this.$el=i;let s=!1;"auto"===this.ctx.conf.flatMode?window.matchMedia("(max-width: 768px)").matches&&(s=!0):!0===this.ctx.conf.flatMode&&(s=!0),this.flatMode=s,this.pageMode=(null==(t=this.conf.pagination)?void 0:t.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.3">Artalk</a>',this.ctx.on("list-reload",(()=>this.reqComments(0))),this.ctx.on("list-refresh-ui",(()=>this.refreshUI())),this.ctx.on("list-import",(e=>this.importComments(e))),this.ctx.on("list-insert",(e=>this.insertComment(e))),this.ctx.on("list-delete",(e=>this.deleteComment(e.id))),this.ctx.on("list-update",(e=>{e(this.data),this.refreshUI()})),this.ctx.on("unread-update",(e=>{var t;return this.showUnreadBadge((null==(t=e.notifies)?void 0:t.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?"控制中心":"通知中心",this.data&&this.data.page&&!0===this.data.page.admin_only?(this.ctx.trigger("editor-close"),this.$closeCommentBtn.innerHTML="打开评论"):(this.ctx.trigger("editor-open"),this.$closeCommentBtn.innerHTML="关闭评论")}onLoad(e,t){super.onLoad(e,t),this.checkGoToCommentByUrlHash()}checkGoToCommentByUrlHash(){return __async(this,null,(function*(){let e=Number(we("atk_comment"));if(!e){const t=window.location.hash.match(/#atk-comment-([0-9]+)/);if(!t||!t[1]||Number.isNaN(Number(t[1])))return;e=Number(t[1])}if(!e)return;const t=we("atk_notify_key");t&&new Ve(this.ctx).markRead(t).then((()=>{this.unread=this.unread.filter((t=>t.comment_id!==e)),this.ctx.trigger("unread-update",{notifies:this.unread})}));const i=this.findComment(e);i&&(qe(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 Ve(this.ctx).pageEdit(this.data.page).then((e=>{this.data&&(this.data.page=__spreadValues({},e)),this.refreshUI()})).catch((e=>{this.ctx.trigger("editor-notify",{msg:`修改页面数据失败:${e.msg||String(e)}`,type:"e"})})).finally((()=>{this.ctx.trigger("editor-hide-loading")})))}showUnreadBadge(e){e>0?(this.$unreadBadge.innerText=`${Number(e||0)}`,this.$unreadBadge.style.display="block"):this.$unreadBadge.style.display="none"}}var ct=function(e){var t=function(e){for(var t,i="0123456789ABCDEF",s="",n=0;n<e.length;n++)t=e.charCodeAt(n),s+=i.charAt(t>>>4&15)+i.charAt(15&t);return s}(function(e){for(var t="",i=0;i<32*e.length;i+=8)t+=String.fromCharCode(e[i>>5]>>>i%32&255);return t}(function(e,t){e[t>>5]|=128<<t%32,e[14+(t+64>>>9<<4)]=t;for(var i=1732584193,s=-271733879,n=-1732584194,r=271733878,a=0;a<e.length;a+=16){var l=i,o=s,c=n,h=r;s=mt(s=mt(s=mt(s=mt(s=pt(s=pt(s=pt(s=pt(s=ut(s=ut(s=ut(s=ut(s=dt(s=dt(s=dt(s=dt(s,n=dt(n,r=dt(r,i=dt(i,s,n,r,e[a+0],7,-680876936),s,n,e[a+1],12,-389564586),i,s,e[a+2],17,606105819),r,i,e[a+3],22,-1044525330),n=dt(n,r=dt(r,i=dt(i,s,n,r,e[a+4],7,-176418897),s,n,e[a+5],12,1200080426),i,s,e[a+6],17,-1473231341),r,i,e[a+7],22,-45705983),n=dt(n,r=dt(r,i=dt(i,s,n,r,e[a+8],7,1770035416),s,n,e[a+9],12,-1958414417),i,s,e[a+10],17,-42063),r,i,e[a+11],22,-1990404162),n=dt(n,r=dt(r,i=dt(i,s,n,r,e[a+12],7,1804603682),s,n,e[a+13],12,-40341101),i,s,e[a+14],17,-1502002290),r,i,e[a+15],22,1236535329),n=ut(n,r=ut(r,i=ut(i,s,n,r,e[a+1],5,-165796510),s,n,e[a+6],9,-1069501632),i,s,e[a+11],14,643717713),r,i,e[a+0],20,-373897302),n=ut(n,r=ut(r,i=ut(i,s,n,r,e[a+5],5,-701558691),s,n,e[a+10],9,38016083),i,s,e[a+15],14,-660478335),r,i,e[a+4],20,-405537848),n=ut(n,r=ut(r,i=ut(i,s,n,r,e[a+9],5,568446438),s,n,e[a+14],9,-1019803690),i,s,e[a+3],14,-187363961),r,i,e[a+8],20,1163531501),n=ut(n,r=ut(r,i=ut(i,s,n,r,e[a+13],5,-1444681467),s,n,e[a+2],9,-51403784),i,s,e[a+7],14,1735328473),r,i,e[a+12],20,-1926607734),n=pt(n,r=pt(r,i=pt(i,s,n,r,e[a+5],4,-378558),s,n,e[a+8],11,-2022574463),i,s,e[a+11],16,1839030562),r,i,e[a+14],23,-35309556),n=pt(n,r=pt(r,i=pt(i,s,n,r,e[a+1],4,-1530992060),s,n,e[a+4],11,1272893353),i,s,e[a+7],16,-155497632),r,i,e[a+10],23,-1094730640),n=pt(n,r=pt(r,i=pt(i,s,n,r,e[a+13],4,681279174),s,n,e[a+0],11,-358537222),i,s,e[a+3],16,-722521979),r,i,e[a+6],23,76029189),n=pt(n,r=pt(r,i=pt(i,s,n,r,e[a+9],4,-640364487),s,n,e[a+12],11,-421815835),i,s,e[a+15],16,530742520),r,i,e[a+2],23,-995338651),n=mt(n,r=mt(r,i=mt(i,s,n,r,e[a+0],6,-198630844),s,n,e[a+7],10,1126891415),i,s,e[a+14],15,-1416354905),r,i,e[a+5],21,-57434055),n=mt(n,r=mt(r,i=mt(i,s,n,r,e[a+12],6,1700485571),s,n,e[a+3],10,-1894986606),i,s,e[a+10],15,-1051523),r,i,e[a+1],21,-2054922799),n=mt(n,r=mt(r,i=mt(i,s,n,r,e[a+8],6,1873313359),s,n,e[a+15],10,-30611744),i,s,e[a+6],15,-1560198380),r,i,e[a+13],21,1309151649),n=mt(n,r=mt(r,i=mt(i,s,n,r,e[a+4],6,-145523070),s,n,e[a+11],10,-1120210379),i,s,e[a+2],15,718787259),r,i,e[a+9],21,-343485551),i=gt(i,l),s=gt(s,o),n=gt(n,c),r=gt(r,h)}return Array(i,s,n,r)}(function(e){for(var t=Array(e.length>>2),i=0;i<t.length;i++)t[i]=0;for(i=0;i<8*e.length;i+=8)t[i>>5]|=(255&e.charCodeAt(i/8))<<i%32;return t}(e),8*e.length)));return t.toLowerCase()};function ht(e,t,i,s,n,r){return gt(function(e,t){return e<<t|e>>>32-t}(gt(gt(t,e),gt(s,r)),n),i)}function dt(e,t,i,s,n,r,a){return ht(t&i|~t&s,e,t,n,r,a)}function ut(e,t,i,s,n,r,a){return ht(t&s|i&~s,e,t,n,r,a)}function pt(e,t,i,s,n,r,a){return ht(t^i^s,e,t,n,r,a)}function mt(e,t,i,s,n,r,a){return ht(i^(t|~s),e,t,n,r,a)}function gt(e,t){var i=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(i>>16)<<16|65535&i}class ft extends i{constructor(e,t){super(e),__publicField(this,"viewTabs",{}),__publicField(this,"viewActiveTab",""),__publicField(this,"$parent"),this.$parent=t,this.$el=xe('<div class="atk-sidebar-view"></div>')}mount(e){}switchTab(e,t){}}__publicField(ft,"viewName",""),__publicField(ft,"viewTitle",""),__publicField(ft,"viewAdminOnly",!1);class kt extends ft{constructor(){super(...arguments),__publicField(this,"viewTabs",{}),__publicField(this,"viewActiveTab",""),__publicField(this,"list")}mount(e){this.ctx.user.data.isAdmin?(this.viewTabs={admin_all:"全部",admin_pending:"待审",all:"个人"},this.viewActiveTab="admin_all"):(this.viewTabs={mentions:"提及",all:"全部",mine:"我的",pending:"待审"},this.viewActiveTab="mentions"),this.list=new lt(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">无内容</div>',this.list.renderComment=e=>{e.setOpenURL(`${e.data.page_key}#atk-comment-${e.data.id}`),e.onReplyBtnClick=()=>{!0===this.ctx.conf.editorTravel?this.ctx.trigger("editor-reply",{data:e.data,$el:e.$el,scroll:!1}):(this.ctx.trigger("sidebar-hide"),this.ctx.trigger("editor-reply",{data:e.data,$el:e.$el,scroll:!0}))}},this.list.paramsEditor=t=>{t.site_name=e},this.$el.innerHTML="",this.$el.append(this.list.$el),this.switchTab(this.viewActiveTab,e)}switchTab(e,t){return this.viewActiveTab=e,this.list.type=e,this.list.isFirstLoad=!0,this.list.paramsEditor=e=>{e.site_name=t},this.list.reqComments(),!0}}__publicField(kt,"viewName","comments"),__publicField(kt,"viewTitle","评论");class yt{constructor(e){__publicField(this,"conf"),__publicField(this,"$el"),__publicField(this,"$input"),__publicField(this,"$yesBtn"),__publicField(this,"$noBtn"),__publicField(this,"value",""),__publicField(this,"allowSubmit",!0),this.conf=e,this.$el=xe('<div class="atk-item-text-editor-layer">\n <div class="atk-edit-form">\n <input class="atk-main-input" type="text" placeholder="输入内容..." autocomplete="off" autofocus>\n </div>\n <div class="atk-actions">\n <div class="atk-item atk-yes-btn">\n <i class="atk-icon atk-icon-yes"></i>\n </div>\n <div class="atk-item atk-no-btn">\n <i class="atk-icon atk-icon-no"></i>\n </div>\n </div>\n </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=e.initValue||"",this.value=e.initValue||"",this.conf.placeholder&&(this.$input.placeholder=this.conf.placeholder),this.$input.oninput=()=>this.onInput(),this.$input.onkeyup=e=>{"Enter"!==e.key&&13!==e.keyCode||(e.preventDefault(),this.submit())},window.setTimeout((()=>this.$input.focus()),80),this.$yesBtn.onclick=()=>{this.submit()},this.$noBtn.onclick=()=>{this.cancel()}}appendTo(e){return e.append(this.$el),this}onInput(){if(this.value=this.$input.value,this.conf.validator){const e=this.conf.validator(this.value);this.setAllowSubmit(e),e?this.$input.classList.remove("atk-invalid"):this.$input.classList.add("atk-invalid")}}setAllowSubmit(e){this.allowSubmit!==e&&(this.allowSubmit=e,e?this.$yesBtn.classList.remove(".atk-disabled"):this.$yesBtn.classList.add(".atk-disabled"))}submit(){return __async(this,null,(function*(){if(this.allowSubmit)if(this.conf.onYes){let e;e=this.conf.onYes instanceof(()=>__async(this,null,(function*(){}))).constructor?yield this.conf.onYes(this.value):this.conf.onYes(this.value),void 0!==e&&!0!==e||this.closeEditor()}else this.closeEditor()}))}cancel(){return __async(this,null,(function*(){if(this.conf.onNo){let e;e=this.conf.onNo instanceof(()=>__async(this,null,(function*(){}))).constructor?yield this.conf.onNo():this.conf.onNo(),void 0!==e&&!0!==e||this.closeEditor()}else this.closeEditor()}))}closeEditor(){this.$el.remove()}}class bt extends i{constructor(e){super(e),__publicField(this,"$editor"),__publicField(this,"$inputer"),__publicField(this,"pages",[]),this.$el=xe('<div class="atk-page-list"></div>')}clearAll(){this.pages=[],this.$el.innerHTML=""}importPages(e){this.pages.push(...e),e.forEach((e=>{const t=this.renderPage(e);this.$el.append(t)}))}renderPage(e){const t=xe('<div class="atk-page-item">\n <div class="atk-page-main">\n <div class="atk-title"></div>\n <div class="atk-sub"></div>\n </div>\n <div class="atk-page-actions">\n <div class="atk-item atk-edit-btn">\n <i class="atk-icon atk-icon-edit"></i>\n </div>\n </div>\n </div>'),i=t.querySelector(".atk-page-main"),s=i.querySelector(".atk-title"),n=i.querySelector(".atk-sub"),r=t.querySelector(".atk-edit-btn");return s.innerText=e.title,n.innerText=e.url||e.key,r.onclick=()=>this.showEditor(e,t),t}showEditor(e,t){this.closeEditor(),this.$editor=xe('<div class="atk-page-edit-layer">\n <div class="atk-page-main-actions">\n <div class="atk-item atk-title-edit-btn">标题修改</div>\n <div class="atk-item atk-key-edit-btn">KEY 变更</div>\n <div class="atk-item atk-admin-only-btn"></div>\n </div>\n <div class="atk-page-actions">\n <div class="atk-item atk-sync-btn">\n <i class="atk-icon atk-icon-sync"></i>\n </div>\n <div class="atk-item atk-del-btn">\n <i class="atk-icon atk-icon-del"></i>\n </div>\n <div class="atk-item atk-close-btn">\n <i class="atk-icon atk-icon-close"></i>\n </div>\n </div>\n </div>'),t.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"),r=this.$editor.querySelector(".atk-sync-btn"),a=this.$editor.querySelector(".atk-del-btn"),l=this.$editor.querySelector(".atk-close-btn"),o=()=>{Ae(this.$editor)},c=()=>{Oe(this.$editor)},h=e=>{window.alert(e)};l.onclick=()=>this.closeEditor();const d=i=>{const s=new yt({initValue:e[i]||"",onYes:n=>__async(this,null,(function*(){let r;Ae(s.$el);try{r=yield new Ve(this.ctx).pageEdit(__spreadProps(__spreadValues({},e),{[i]:n}))}catch(a){return h(`修改失败:${a.msg||"未知错误"}`),console.error(a),!1}finally{Oe(s.$el)}return t.replaceWith(this.renderPage(r)),!0}))});s.appendTo(this.$editor)};i.onclick=()=>d("title"),s.onclick=()=>d("key");const u=new st({text:()=>(n.classList.remove("atk-green","atk-yellow"),n.classList.add(e.admin_only?"atk-yellow":"atk-green"),e.admin_only?"管理员可评":"所有人可评")}).appendTo(n);n.onclick=()=>__async(this,null,(function*(){let t;o();try{t=yield new Ve(this.ctx).pageEdit(__spreadProps(__spreadValues({},e),{admin_only:!e.admin_only}))}catch(i){return h(`修改失败:${i.msg||"未知错误"}`),void console.log(i)}finally{c()}e.admin_only=t.admin_only,u.updateText()})),r.onclick=()=>__async(this,null,(function*(){let i;o();try{i=yield new Ve(this.ctx).pageFetch(e.id)}catch(s){return h(`同步失败:${s.msg||"未知错误"}`),void console.log(s)}finally{c()}t.replaceWith(this.renderPage(i))})),a.onclick=()=>{window.confirm(`确认删除页面 "${e.title||e.key}"?将会删除所有相关数据`)&&(()=>{__async(this,null,(function*(){o();try{yield new Ve(this.ctx).pageDel(e.key,e.site_name)}catch(i){return console.log(i),void h(`删除失败 ${String(i)}`)}finally{c()}t.remove()}))})()}}closeEditor(){this.$editor&&this.$editor.remove()}}class $t extends ft{constructor(){super(...arguments),__publicField(this,"viewTabs",{}),__publicField(this,"viewActiveTab",""),__publicField(this,"pageList"),__publicField(this,"pagination")}mount(e){this.pageList||(this.pageList=new bt(this.ctx),this.$el.append(this.pageList.$el)),this.switchTab(this.viewActiveTab,e)}switchTab(e,t){this.reqPages(t,0)}reqPages(e,t){return __async(this,null,(function*(){var i;this.pageList.clearAll(),null==(i=this.$el.parentNode)||i.scrollTo(0,0),Ae(this.$el);const s=yield new Ve(this.ctx).pageGet(e,t,20);this.pageList.importPages(s.pages||[]),Oe(this.$el),this.pagination||(this.pagination=new rt(s.total,{pageSize:20,onChange:t=>{this.reqPages(e,t)}}),this.$el.append(this.pagination.$el)),this.pagination&&0===t&&this.pagination.update(t,s.total)}))}}__publicField($t,"viewName","pages"),__publicField($t,"viewTitle","页面"),__publicField($t,"viewAdminOnly",!0);class vt extends i{constructor(e){super(e),__publicField(this,"sites",[]),__publicField(this,"$header"),__publicField(this,"$headerTitle"),__publicField(this,"$headerActions"),__publicField(this,"$rowsWrap"),__publicField(this,"$editor"),__publicField(this,"activeSite",""),__publicField(this,"$add"),this.$el=xe('<div class="atk-site-list">\n <div class="atk-header">\n <div class="atk-title"></div>\n <div class="atk-actions">\n <div class="atk-item atk-site-add-btn"><i class="atk-icon atk-icon-plus"></i></div>\n </div>\n </div>\n <div class="atk-site-rows-wrap"></div>\n </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="共 0 个站点";this.$headerActions.querySelector(".atk-site-add-btn").onclick=()=>{this.closeEditor(),this.showAdd()}}loadSites(e){let t;this.sites=e,this.activeSite="",this.$rowsWrap.innerHTML="",this.$headerTitle.innerText="共 0 个站点";for(let i=0;i<e.length;i++){const s=e[i];i%4==0&&(t=xe('<div class="atk-site-row">'),this.$rowsWrap.append(t));const n=this.renderSite(s,t);t.append(n)}this.$headerTitle.innerText=`共 ${e.length} 个站点`}renderSite(e,t){const i=xe('<div class="atk-site-item">\n <div class="atk-site-logo"></div>\n <div class="atk-site-name"></div>\n </div>'),s=i.querySelector(".atk-site-logo"),n=i.querySelector(".atk-site-name"),r=()=>{i.classList.add("atk-active")};return s.innerText=e.name.substr(0,1),n.innerText=e.name,i.onclick=()=>{this.closeEditor(),this.closeAdd(),r(),this.showEditor(e,i,t)},this.activeSite===e.name&&r(),i}showEditor(e,t,i){this.activeSite=e.name,this.$editor=xe('\n <div class="atk-site-edit">\n <div class="atk-header">\n <div class="atk-site-info">\n <span class="atk-site-name"></span>\n <span class="atk-site-urls"></span>\n </div>\n <div class="atk-close-btn">\n <i class="atk-icon atk-icon-close"></i>\n </div>\n </div>\n <div class="atk-main">\n <div class="atk-site-text-actions">\n <div class="atk-item atk-rename-btn">重命名</div>\n <div class="atk-item atk-edit-url-btn">修改 URL</div>\n \x3c!--<div class="atk-item atk-export-btn">导出</div>\n <div class="atk-item atk-import-btn">导入</div>--\x3e\n </div>\n <div class="atk-site-btn-actions">\n <div class="atk-item atk-del-btn">\n <i class="atk-icon atk-icon-del"></i>\n </div>\n </div>\n </div>\n </div>'),i.before(this.$editor);const s=this.$editor.querySelector(".atk-site-name"),n=this.$editor.querySelector(".atk-site-urls");this.$editor.querySelector(".atk-close-btn").onclick=()=>this.closeEditor();const r=t=>{var i;e=t,s.innerText=e.name,s.onclick=()=>{e.first_url&&window.open(e.first_url)},n.innerHTML="",null==(i=e.urls)||i.forEach((e=>{const t=xe('<span class="atk-url-item"></span>');n.append(t),t.innerText=(e||"").replace(/\/$/,""),t.onclick=()=>{window.open(e)}}))};r(e);const a=this.$editor.querySelector(".atk-main"),l=this.$editor.querySelector(".atk-site-text-actions"),o=l.querySelector(".atk-rename-btn"),c=l.querySelector(".atk-edit-url-btn"),h=this.$editor.querySelector(".atk-del-btn"),d=()=>{Ae(this.$editor)},u=()=>{Oe(this.$editor)},p=e=>{window.alert(e)},m=s=>{let n=e[s]||"";"urls"===s&&(n=e.urls_raw||"");const l=new yt({initValue:n,onYes:n=>__async(this,null,(function*(){let a;Ae(l.$el);try{a=yield new Ve(this.ctx).siteEdit(__spreadProps(__spreadValues({},e),{[s]:n}))}catch(o){return p(`修改失败:${o.msg||"未知错误"}`),console.error(o),!1}finally{Oe(l.$el)}return t.replaceWith(this.renderSite(a,i)),r(a),!0}))});l.appendTo(a)};o.onclick=()=>m("name"),c.onclick=()=>m("urls"),h.onclick=()=>{window.confirm(`确认删除站点 "${e.name}"?将会删除所有相关数据`)&&(()=>{__async(this,null,(function*(){d();try{yield new Ve(this.ctx).siteDel(e.id,!0)}catch(i){return console.log(i),void p(`删除失败 ${String(i)}`)}finally{u()}this.closeEditor(),t.remove(),this.sites=this.sites.filter((t=>t.name!==e.name))}))})()}}closeEditor(){this.$editor&&(this.$editor.remove(),this.$rowsWrap.querySelectorAll(".atk-site-item").forEach((e=>e.classList.remove("atk-active"))),this.activeSite="")}showAdd(){this.closeAdd(),this.$add=xe('\n <div class="atk-site-add">\n <div class="atk-header">\n <div class="atk-title">新增站点</div>\n <div class="atk-close-btn">\n <i class="atk-icon atk-icon-close"></i>\n </div>\n </div>\n <div class="atk-form">\n <input type="text" name="AtkSiteName" placeholder="站点名称" autocomplete="off">\n <input type="text" name="AtkSiteUrls" placeholder="站点 URL(多个用逗号隔开)" autocomplete="off">\n <button class="atk-btn" name="AtkSubmit">创建</button>\n </div>\n </div>'),this.$header.after(this.$add);this.$add.querySelector(".atk-close-btn").onclick=()=>this.closeAdd();const e=this.$add.querySelector('[name="AtkSiteName"]'),t=this.$add.querySelector('[name="AtkSiteUrls"]'),i=this.$add.querySelector('[name="AtkSubmit"]');i.onclick=()=>__async(this,null,(function*(){const i=e.value.trim(),s=t.value.trim();if(""===i)return void e.focus();let n;Ae(this.$add);try{n=yield new Ve(this.ctx).siteAdd(i,s)}catch(r){return window.alert(`创建失败:${r.msg||""}`),void console.error(r)}finally{Oe(this.$add)}this.sites.push(n),this.loadSites(this.sites),this.closeAdd()}));const s=e=>{"Enter"===e.key&&i.click()};e.onkeyup=e=>s(e),t.onkeyup=e=>s(e)}closeAdd(){var e;null==(e=this.$add)||e.remove()}}class xt extends ft{constructor(){super(...arguments),__publicField(this,"viewTabs",{}),__publicField(this,"viewActiveTab",""),__publicField(this,"siteList")}mount(e){this.siteList||(this.siteList=new vt(this.ctx),this.$el.append(this.siteList.$el)),this.reqSites()}switchTab(e,t){this.reqSites()}reqSites(){return __async(this,null,(function*(){const e=yield new Ve(this.ctx).siteGet();this.siteList.loadSites(e)}))}}__publicField(xt,"viewName","sites"),__publicField(xt,"viewTitle","站点"),__publicField(xt,"viewAdminOnly",!0);class _t extends ft{constructor(){super(...arguments),__publicField(this,"ß"),__publicField(this,"viewTabs",{import:"导入",export:"导出"}),__publicField(this,"viewActiveTab","import")}mount(e){this.switchTab("import",e)}switchTab(e,t){if("import"===e)this.initImport();else if("export"===e)return this.initExport(),!1;return!0}initImport(){this.$el.innerHTML='<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-form">\n <div class="atk-label">数据类型</div>\n <select name="AtkDataType">\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 <div class="atk-label atk-data-file-label">数据文件</div>\n <input type="file" name="AtkDataFile" accept="text/plain,.json">\n <div class="atk-label">目标站点名</div>\n <input type="text" name="AtkSiteName" placeholder="输入内容..." autocomplete="off">\n <div class="atk-label">目标站点 URL</div>\n <input type="text" name="AtkSiteURL" placeholder="输入内容..." autocomplete="off">\n <div class="atk-label">启动参数(可选)</div>\n <textarea name="AtkPayload"></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="AtkSubmit">导入</button>\n </div>';const e=this.$el.querySelector(".atk-form"),t=e.querySelector('[name="AtkDataType"]'),i=e.querySelector('[name="AtkDataFile"]'),s=e.querySelector(".atk-data-file-label"),n=e.querySelector('[name="AtkSiteName"]'),r=e.querySelector('[name="AtkSiteURL"]'),a=e.querySelector('[name="AtkPayload"]'),l=e.querySelector('[name="AtkSubmit"]'),o=e=>window.alert(e);t.onchange=()=>{["typecho"].includes(t.value)?(i.style.display="none",s.style.display="none"):(i.style.display="",s.style.display="")},l.onclick=()=>{var s;const l=t.value.trim(),c=n.value.trim(),h=r.value.trim(),d=a.value.trim();if(""===l)return void o("请选择数据类型");let u={};if(d){try{u=JSON.parse(d)}catch(g){return void o(`Payload JSON 格式有误:${String(g)}`)}if(u instanceof Object)return void o("Payload 需为 JSON 对象")}c&&(u.t_name=c),h&&(u.t_url=h);const p=t=>{const i=this.$el.querySelector(".atk-log-wrap"),s=i.querySelector(".atk-log"),n=this.$el.querySelector(".atk-log-back-btn");i.style.display="",e.style.display="none",n.onclick=()=>{i.style.display="none",e.style.display=""},t&&(u.json_data=t);const r="f_"+ +new Date,a=document.createElement("iframe");a.className="atk-iframe",a.name=r,s.innerHTML="",s.append(a);const o={type:l,payload:JSON.stringify(u),token:this.ctx.user.data.token||""},c=document.createElement("form");c.style.display="none",c.setAttribute("method","post"),c.setAttribute("action",`${this.ctx.conf.server}/admin/import`),c.setAttribute("target",r),Object.entries(o).forEach((([e,t])=>{const i=document.createElement("input");i.setAttribute("type","hidden"),i.setAttribute("name",e),i.value=t,c.appendChild(i)})),i.append(c),c.submit(),c.remove()},m=new FileReader;m.onload=()=>{const e=String(m.result);p(e)},(null==(s=i.files)?void 0:s.length)?m.readAsText(i.files[0]):p()}}initExport(){return __async(this,null,(function*(){Ae(this.$el);try{const e=yield new Ve(this.ctx).export();this.download(`artrans-${this.getYmdHisFilename()}.json`,e)}catch(e){return console.log(e),void window.alert(`${String(e)}`)}finally{Oe(this.$el)}}))}download(e,t){const i=document.createElement("a");i.setAttribute("href",`data:text/json;charset=utf-8,${encodeURIComponent(t)}`),i.setAttribute("download",e),i.style.display="none",document.body.appendChild(i),i.click(),document.body.removeChild(i)}getYmdHisFilename(){const e=new Date,t=e.getFullYear(),i=e.getMonth()+1,s=e.getDate(),n=e.getHours(),r=e.getMinutes(),a=e.getSeconds();return`${t}${i}${s}-${n}${Te(r,2)}${Te(a,2)}`}}__publicField(_t,"viewName","transfer"),__publicField(_t,"viewTitle","迁移"),__publicField(_t,"viewAdminOnly",!0);class wt{constructor(e,t){__publicField(this,"ctx"),__publicField(this,"conf"),__publicField(this,"$el"),__publicField(this,"sites",[]),__publicField(this,"$sites"),__publicField(this,"outsideChecker"),this.ctx=e,this.conf=t,this.$el=xe('<div class="atk-site-list-floater" style="display: none;">\n <div class="atk-sites"></div>\n </div>'),this.$sites=this.$el.querySelector(".atk-sites")}load(e){return __async(this,null,(function*(){this.$sites.innerHTML="";const t=(t,i,s,n)=>{const r=xe('<div class="atk-site-item">\n <div class="atk-site-logo"></div>\n <div class="atk-site-name"></div>\n </div>');r.onclick=n?()=>n():()=>this.switch(s||t),r.setAttribute("data-name",s||t);const a=r.querySelector(".atk-site-logo"),l=r.querySelector(".atk-site-name");a.innerText=i,l.innerText=t,e===(s||t)&&r.classList.add("atk-active"),this.$sites.append(r)};t("所有站点","_","__ATK_SITE_ALL");(yield new Ve(this.ctx).siteGet()).forEach((e=>{t(e.name,e.name.substr(0,1))})),t("站点管理","+","",(()=>{this.conf.onClickSitesViewBtn(),this.hide()}))}))}switch(e){!1!==this.conf.onSwitchSite(e)&&(this.$sites.querySelectorAll(".atk-site-item").forEach((t=>{t.getAttribute("data-name")!==e?t.classList.remove("atk-active"):t.classList.add("atk-active")})),this.hide())}show(e){this.$el.style.display="",e&&(this.outsideChecker=t=>{e.contains(t.target)||this.$el.contains(t.target)||this.hide()},document.addEventListener("click",this.outsideChecker))}hide(){this.$el.style.display="none",this.outsideChecker&&document.removeEventListener("click",this.outsideChecker)}}const St="comments",Tt=[kt,$t,xt,_t];class Lt extends i{constructor(e){super(e),__publicField(this,"layer"),__publicField(this,"$header"),__publicField(this,"$headerMenu"),__publicField(this,"$title"),__publicField(this,"$avatar"),__publicField(this,"$siteLogo"),__publicField(this,"$closeBtn"),__publicField(this,"$nav"),__publicField(this,"$curtViewBtn"),__publicField(this,"$curtViewBtnIcon"),__publicField(this,"$curtViewBtnText"),__publicField(this,"$navTabs"),__publicField(this,"$navViews"),__publicField(this,"$viewWrap"),__publicField(this,"siteSwitcher"),__publicField(this,"curtSite"),__publicField(this,"curtView",St),__publicField(this,"curtTab"),__publicField(this,"viewInstances",{}),__publicField(this,"viewSwitcherShow",!1),__publicField(this,"firstShow",!0),this.$el=xe('<div class="atk-sidebar">\n <div class="atk-sidebar-inner">\n <div class="atk-sidebar-header">\n <span class="atk-avatar">\n <span class="atk-site-logo"></span>\n </span>\n <span class="atk-menu">\n <span class="atk-item atk-active atk-sidebar-title">控制中心</span>\n </span>\n <div class="atk-sidebar-close"><i class="atk-icon atk-icon-close"></i></div>\n </div>\n <div class="atk-sidebar-nav">\n <div class="akt-curt-view-btn">\n <div class="atk-icon"><span></span><span></span><span></span></div>\n <div class="atk-text"></div>\n </div>\n <div class="atk-tabs"></div>\n <div class="atk-tabs atk-views" style="display: none;"></div>\n </div>\n <div class="atk-sidebar-view-wrap"></div>\n </div>\n</div>\n'),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}))}get isAdmin(){return this.ctx.user.data.isAdmin}get curtViewInstance(){return this.curtView?this.viewInstances[this.curtView]:void 0}initViewSwitcher(){this.$curtViewBtn.onclick=()=>{this.toggleViewSwitcher()},this.$navViews.innerHTML="",Tt.forEach((e=>{const t=xe('<div class="atk-tab-item"></div>');this.$navViews.append(t),t.setAttribute("data-name",e.viewName),t.innerText=e.viewTitle,e.viewName===this.curtView&&(t.classList.add("atk-active"),this.$curtViewBtnText.innerText=e.viewTitle),t.onclick=()=>{this.switchView(e.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}show(){return __async(this,null,(function*(){if(this.$el.style.transform="",this.layer=new Pe(this.ctx,"sidebar",this.$el),this.layer.afterHide=()=>{!0===this.ctx.conf.editorTravel&&this.ctx.trigger("editor-travel-back")},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="控制中心",this.$curtViewBtn.style.display="",this.siteSwitcher||(this.siteSwitcher=new wt(this.ctx,{onSwitchSite:e=>{this.switchSite(e)},onClickSitesViewBtn:()=>{this.switchView("sites")}}),this.$viewWrap.before(this.siteSwitcher.$el),this.$avatar.onclick=e=>{var t;this.isAdmin&&(null==(t=this.siteSwitcher)||t.show(e.target))}),this.curtSite=this.conf.site,Ae(this.$el);try{yield this.siteSwitcher.load(this.curtSite)}catch(e){const t=xe(`<span>加载失败:${e.msg||"网络错误"}<br/></span>`),i=xe('<span style="cursor:pointer;">点击重新获取</span>');return t.appendChild(i),i.onclick=()=>{Re(this.$el,null),this.show()},void Re(this.$el,t)}finally{Oe(this.$el)}this.$avatar.innerHTML="",this.$siteLogo=xe('<div class="atk-site-logo"></div>'),this.$siteLogo.innerText=(this.curtSite||"").substr(0,1),this.$avatar.append(this.$siteLogo)}else{this.$title.innerText="通知中心",this.$curtViewBtn.style.display="none",this.curtSite=this.conf.site;const e=document.createElement("img");e.src=Ce(this.ctx,ct(this.ctx.user.data.email.toLowerCase())),this.$avatar.innerHTML="",this.$avatar.append(e)}this.switchView(St),this.firstShow=!1}}))}hide(){var e;this.$el.style.transform="",null==(e=this.layer)||e.hide()}switchView(e){let t=this.viewInstances[e];if(!t){t=new(Tt.find((t=>t.viewName===e)))(this.ctx,this.$viewWrap),this.viewInstances[e]=t}t.mount(this.curtSite),this.curtView=e,this.curtTab=t.viewActiveTab,this.$curtViewBtnText.innerText=t.constructor.viewTitle,this.$navViews.querySelectorAll(".atk-tab-item").forEach((t=>{t.getAttribute("data-name")===e?t.classList.add("atk-active"):t.classList.remove("atk-active")})),this.loadViewTabs(t),this.$viewWrap.innerHTML="",this.$viewWrap.append(t.$el),this.$viewWrap.classList.forEach((e=>{e.startsWith("atk-view-name-")&&this.$viewWrap.classList.remove(e)})),this.$viewWrap.classList.add(`atk-view-name-${t.constructor.viewName}`)}loadViewTabs(e){this.$navTabs.innerHTML="",Object.entries(e.viewTabs).forEach((([t,i])=>{const s=xe('<div class="atk-tab-item"></div>');this.$navTabs.append(s),s.innerText=i,e.viewActiveTab===t&&s.classList.add("atk-active"),s.onclick=()=>{!1!==e.switchTab(t,this.curtSite)&&(this.$navTabs.querySelectorAll(".atk-active").forEach((e=>e.classList.remove("atk-active"))),s.classList.add("atk-active"),this.curtTab=t)}}))}switchSite(e){this.curtSite=e;const t=this.curtViewInstance;null==t||t.switchTab(this.curtTab,e),this.$siteLogo&&(this.$siteLogo.innerText=this.curtSite.substr(0,1))}}const Ct=class{constructor(e){__publicField(this,"ctx"),__publicField(this,"conf"),__publicField(this,"$root"),__publicField(this,"checkerLauncher"),__publicField(this,"editor"),__publicField(this,"list"),__publicField(this,"sidebar"),this.conf=__spreadValues(__spreadValues({},Ct.defaults),e),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(i){throw console.error(i),new Error("Please check your Artalk `el` config.")}this.ctx=new t(this.$root,this.conf),this.$root.classList.add("artalk"),this.$root.innerHTML="",this.initDarkMode(),this.checkerLauncher=new Ge(this.ctx),this.editor=new Xe(this.ctx),this.$root.appendChild(this.editor.$el),this.list=new ot(this.ctx),this.$root.appendChild(this.list.$el),this.sidebar=new Lt(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 e=[];this.$root.querySelectorAll("[atk-only-admin-show]").forEach((t=>e.push(t)));const{$wrap:t}=Ue(this.ctx);t&&t.querySelectorAll("[atk-only-admin-show]").forEach((t=>e.push(t))),e.forEach((e=>{this.ctx.user.data.isAdmin?e.classList.remove("atk-hide"):e.classList.add("atk-hide")}))})),this.ctx.on("user-changed",(()=>{this.ctx.trigger("check-admin-show-el"),this.ctx.trigger("list-refresh-ui")}))}reload(){this.list.reqComments()}initDarkMode(){const e="atk-dark-mode";this.conf.darkMode?this.$root.classList.add(e):this.$root.classList.remove(e);const{$wrap:t}=Ue(this.ctx);t&&(this.conf.darkMode?t.classList.add(e):t.classList.remove(e))}setDarkMode(e){this.ctx.conf.darkMode=e,this.initDarkMode()}on(e,t){this.ctx.on(e,t,"external")}off(e,t){this.ctx.off(e,t,"external")}trigger(e,t){this.ctx.trigger(e,t,"external")}};let Ft=Ct;return __publicField(Ft,"defaults",{el:"",pageKey:"",server:"",site:"",placeholder:"键入内容...",noComment:"「此时无声胜有声」",sendBtn:"发送评论",darkMode:!1,editorTravel:!0,emoticons:"https://cdn.jsdelivr.net/gh/ArtalkJS/Emoticons/grps/default.json",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:300,children:400},reqTimeout:15e3,versionCheck:!0}),Ft}));
|
|
1
|
+
var __defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(t,e,i)=>e in t?__defProp(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,__spreadValues=(t,e)=>{for(var i in e||(e={}))__hasOwnProp.call(e,i)&&__defNormalProp(t,i,e[i]);if(__getOwnPropSymbols)for(var i of __getOwnPropSymbols(e))__propIsEnum.call(e,i)&&__defNormalProp(t,i,e[i]);return t},__spreadProps=(t,e)=>__defProps(t,__getOwnPropDescs(e)),__publicField=(t,e,i)=>(__defNormalProp(t,"symbol"!=typeof e?e+"":e,i),i),__async=(t,e,i)=>new Promise(((s,n)=>{var r=t=>{try{l(i.next(t))}catch(e){n(e)}},a=t=>{try{l(i.throw(t))}catch(e){n(e)}},l=t=>t.done?s(t.value):Promise.resolve(t.value).then(r,a);l((i=i.apply(t,e)).next())}));!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";class t{constructor(t){__publicField(this,"data");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 e{constructor(e,i){__publicField(this,"cid"),__publicField(this,"$root"),__publicField(this,"conf"),__publicField(this,"user"),__publicField(this,"eventList",[]),this.cid=+new Date,this.$root=e,this.conf=i,this.user=new t(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((e=>e.name===t&&(!i||e.scope===i))).map((t=>t.handler)).forEach((t=>t(e)))}}class i{constructor(t){__publicField(this,"$el"),__publicField(this,"ctx"),__publicField(this,"conf"),this.ctx=t,this.conf=t.conf}}function s(){return{baseUrl:null,breaks:!1,extensions:null,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartLists:!1,smartypants:!1,tokenizer:null,walkTokens:null,xhtml:!1}}let n={baseUrl:null,breaks:!1,extensions:null,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartLists:!1,smartypants:!1,tokenizer:null,walkTokens:null,xhtml:!1};const r=/[&<>"']/,a=/[&<>"']/g,l=/[<>"']|&(?!#?\w+;)/,o=/[<>"']|&(?!#?\w+;)/g,c={"&":"&","<":"<",">":">",'"':""","'":"'"},h=t=>c[t];function d(t,e){if(e){if(r.test(t))return t.replace(a,h)}else if(l.test(t))return t.replace(o,h);return t}const u=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi;function p(t){return t.replace(u,((t,e)=>"colon"===(e=e.toLowerCase())?":":"#"===e.charAt(0)?"x"===e.charAt(1)?String.fromCharCode(parseInt(e.substring(2),16)):String.fromCharCode(+e.substring(1)):""))}const m=/(^|[^\[])\^/g;function g(t,e){t=t.source||t,e=e||"";const i={replace:(e,s)=>(s=(s=s.source||s).replace(m,"$1"),t=t.replace(e,s),i),getRegex:()=>new RegExp(t,e)};return i}const f=/[^\w:]/g,k=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function b(t,e,i){if(t){let t;try{t=decodeURIComponent(p(i)).replace(f,"").toLowerCase()}catch(s){return null}if(0===t.indexOf("javascript:")||0===t.indexOf("vbscript:")||0===t.indexOf("data:"))return null}e&&!k.test(i)&&(i=function(t,e){y[" "+t]||($.test(t)?y[" "+t]=t+"/":y[" "+t]=T(t,"/",!0));const i=-1===(t=y[" "+t]).indexOf(":");return"//"===e.substring(0,2)?i?e:t.replace(v,"$1")+e:"/"===e.charAt(0)?i?e:t.replace(x,"$1")+e:t+e}(e,i));try{i=encodeURI(i).replace(/%25/g,"%")}catch(s){return null}return i}const y={},$=/^[^:]+:\/*[^/]*$/,v=/^([^:]+:)[\s\S]*$/,x=/^([^:]+:\/*[^/]*)[\s\S]*$/;const _={exec:function(){}};function w(t){let e,i,s=1;for(;s<arguments.length;s++)for(i in e=arguments[s],e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}function S(t,e){const i=t.replace(/\|/g,((t,e,i)=>{let s=!1,n=e;for(;--n>=0&&"\\"===i[n];)s=!s;return s?"|":" |"})).split(/ \|/);let s=0;if(i[0].trim()||i.shift(),i[i.length-1].trim()||i.pop(),i.length>e)i.splice(e);else for(;i.length<e;)i.push("");for(;s<i.length;s++)i[s]=i[s].trim().replace(/\\\|/g,"|");return i}function T(t,e,i){const s=t.length;if(0===s)return"";let n=0;for(;n<s;){const r=t.charAt(s-n-1);if(r!==e||i){if(r===e||!i)break;n++}else n++}return t.substr(0,s-n)}function L(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 A(t,e){if(e<1)return"";let i="";for(;e>1;)1&e&&(i+=t),e>>=1,t+=t;return i+t}function C(t,e,i,s){const n=e.href,r=e.title?d(e.title):null,a=t[1].replace(/\\([\[\]])/g,"$1");if("!"!==t[0].charAt(0)){s.state.inLink=!0;const t={type:"link",raw:i,href:n,title:r,text:a,tokens:s.inlineTokens(a,[])};return s.state.inLink=!1,t}return{type:"image",raw:i,href:n,title:r,text:d(a)}}class E{constructor(t){this.options=t||n}space(t){const e=this.rules.block.newline.exec(t);if(e)return e[0].length>1?{type:"space",raw:e[0]}:{raw:"\n"}}code(t){const e=this.rules.block.code.exec(t);if(e){const t=e[0].replace(/^ {1,4}/gm,"");return{type:"code",raw:e[0],codeBlockStyle:"indented",text:this.options.pedantic?t:T(t,"\n")}}}fences(t){const e=this.rules.block.fences.exec(t);if(e){const t=e[0],i=function(t,e){const i=t.match(/^(\s+)(?:```)/);if(null===i)return e;const s=i[1];return e.split("\n").map((t=>{const e=t.match(/^\s+/);if(null===e)return t;const[i]=e;return i.length>=s.length?t.slice(s.length):t})).join("\n")}(t,e[3]||"");return{type:"code",raw:t,lang:e[2]?e[2].trim():e[2],text:i}}}heading(t){const e=this.rules.block.heading.exec(t);if(e){let t=e[2].trim();if(/#$/.test(t)){const e=T(t,"#");this.options.pedantic?t=e.trim():e&&!/ $/.test(e)||(t=e.trim())}const i={type:"heading",raw:e[0],depth:e[1].length,text:t,tokens:[]};return this.lexer.inline(i.text,i.tokens),i}}hr(t){const e=this.rules.block.hr.exec(t);if(e)return{type:"hr",raw:e[0]}}blockquote(t){const e=this.rules.block.blockquote.exec(t);if(e){const t=e[0].replace(/^ *> ?/gm,"");return{type:"blockquote",raw:e[0],tokens:this.lexer.blockTokens(t,[]),text:t}}}list(t){let e=this.rules.block.list.exec(t);if(e){let i,s,n,r,a,l,o,c,h,d,u=e[1].trim();const p=u.length>1,m={type:"list",raw:"",ordered:p,start:p?+u.slice(0,-1):"",loose:!1,items:[]};u=p?`\\d{1,9}\\${u.slice(-1)}`:`\\${u}`,this.options.pedantic&&(u=p?u:"[*+-]");const g=new RegExp(`^( {0,3}${u})((?: [^\\n]*| *)(?:\\n[^\\n]*)*(?:\\n|$))`);for(;t&&!this.rules.block.hr.test(t)&&(e=g.exec(t));){h=e[2].split("\n"),this.options.pedantic?(r=2,d=h[0].trimLeft()):(r=e[2].search(/[^ ]/),r=e[1].length+(r>4?1:r),d=h[0].slice(r-e[1].length)),l=!1,i=e[0],!h[0]&&/^ *$/.test(h[1])&&(i=e[1]+h.slice(0,2).join("\n")+"\n",m.loose=!0,h=[]);const u=new RegExp(`^ {0,${Math.min(3,r-1)}}(?:[*+-]|\\d{1,9}[.)])`);for(a=1;a<h.length;a++){if(c=h[a],this.options.pedantic&&(c=c.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),u.test(c)){i=e[1]+h.slice(0,a).join("\n")+"\n";break}if(l){if(!(c.search(/[^ ]/)>=r)&&c.trim()){i=e[1]+h.slice(0,a).join("\n")+"\n";break}d+="\n"+c.slice(r)}else c.trim()||(l=!0),c.search(/[^ ]/)>=r?d+="\n"+c.slice(r):d+="\n"+c}m.loose||(o?m.loose=!0:/\n *\n *$/.test(i)&&(o=!0)),this.options.gfm&&(s=/^\[[ xX]\] /.exec(d),s&&(n="[ ] "!==s[0],d=d.replace(/^\[[ xX]\] +/,""))),m.items.push({type:"list_item",raw:i,task:!!s,checked:n,loose:!1,text:d}),m.raw+=i,t=t.slice(i.length)}m.items[m.items.length-1].raw=i.trimRight(),m.items[m.items.length-1].text=d.trimRight(),m.raw=m.raw.trimRight();const f=m.items.length;for(a=0;a<f;a++)this.lexer.state.top=!1,m.items[a].tokens=this.lexer.blockTokens(m.items[a].text,[]),m.items[a].tokens.some((t=>"space"===t.type))&&(m.loose=!0,m.items[a].loose=!0);return m}}html(t){const e=this.rules.block.html.exec(t);if(e){const t={type:"html",raw:e[0],pre:!this.options.sanitizer&&("pre"===e[1]||"script"===e[1]||"style"===e[1]),text:e[0]};return this.options.sanitize&&(t.type="paragraph",t.text=this.options.sanitizer?this.options.sanitizer(e[0]):d(e[0]),t.tokens=[],this.lexer.inline(t.text,t.tokens)),t}}def(t){const e=this.rules.block.def.exec(t);if(e){e[3]&&(e[3]=e[3].substring(1,e[3].length-1));return{type:"def",tag:e[1].toLowerCase().replace(/\s+/g," "),raw:e[0],href:e[2],title:e[3]}}}table(t){const e=this.rules.block.table.exec(t);if(e){const t={type:"table",header:S(e[1]).map((t=>({text:t}))),align:e[2].replace(/^ *|\| *$/g,"").split(/ *\| */),rows:e[3]?e[3].replace(/\n$/,"").split("\n"):[]};if(t.header.length===t.align.length){t.raw=e[0];let i,s,n,r,a=t.align.length;for(i=0;i<a;i++)/^ *-+: *$/.test(t.align[i])?t.align[i]="right":/^ *:-+: *$/.test(t.align[i])?t.align[i]="center":/^ *:-+ *$/.test(t.align[i])?t.align[i]="left":t.align[i]=null;for(a=t.rows.length,i=0;i<a;i++)t.rows[i]=S(t.rows[i],t.header.length).map((t=>({text:t})));for(a=t.header.length,s=0;s<a;s++)t.header[s].tokens=[],this.lexer.inlineTokens(t.header[s].text,t.header[s].tokens);for(a=t.rows.length,s=0;s<a;s++)for(r=t.rows[s],n=0;n<r.length;n++)r[n].tokens=[],this.lexer.inlineTokens(r[n].text,r[n].tokens);return t}}}lheading(t){const e=this.rules.block.lheading.exec(t);if(e){const t={type:"heading",raw:e[0],depth:"="===e[2].charAt(0)?1:2,text:e[1],tokens:[]};return this.lexer.inline(t.text,t.tokens),t}}paragraph(t){const e=this.rules.block.paragraph.exec(t);if(e){const t={type:"paragraph",raw:e[0],text:"\n"===e[1].charAt(e[1].length-1)?e[1].slice(0,-1):e[1],tokens:[]};return this.lexer.inline(t.text,t.tokens),t}}text(t){const e=this.rules.block.text.exec(t);if(e){const t={type:"text",raw:e[0],text:e[0],tokens:[]};return this.lexer.inline(t.text,t.tokens),t}}escape(t){const e=this.rules.inline.escape.exec(t);if(e)return{type:"escape",raw:e[0],text:d(e[1])}}tag(t){const e=this.rules.inline.tag.exec(t);if(e)return!this.lexer.state.inLink&&/^<a /i.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&/^<\/a>/i.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:this.options.sanitize?"text":"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(e[0]):d(e[0]):e[0]}}link(t){const e=this.rules.inline.link.exec(t);if(e){const t=e[2].trim();if(!this.options.pedantic&&/^</.test(t)){if(!/>$/.test(t))return;const e=T(t.slice(0,-1),"\\");if((t.length-e.length)%2==0)return}else{const t=function(t,e){if(-1===t.indexOf(e[1]))return-1;const i=t.length;let s=0,n=0;for(;n<i;n++)if("\\"===t[n])n++;else if(t[n]===e[0])s++;else if(t[n]===e[1]&&(s--,s<0))return n;return-1}(e[2],"()");if(t>-1){const i=(0===e[0].indexOf("!")?5:4)+e[1].length+t;e[2]=e[2].substring(0,t),e[0]=e[0].substring(0,i).trim(),e[3]=""}}let i=e[2],s="";if(this.options.pedantic){const t=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(i);t&&(i=t[1],s=t[3])}else s=e[3]?e[3].slice(1,-1):"";return i=i.trim(),/^</.test(i)&&(i=this.options.pedantic&&!/>$/.test(t)?i.slice(1):i.slice(1,-1)),C(e,{href:i?i.replace(this.rules.inline._escapes,"$1"):i,title:s?s.replace(this.rules.inline._escapes,"$1"):s},e[0],this.lexer)}}reflink(t,e){let i;if((i=this.rules.inline.reflink.exec(t))||(i=this.rules.inline.nolink.exec(t))){let t=(i[2]||i[1]).replace(/\s+/g," ");if(t=e[t.toLowerCase()],!t||!t.href){const t=i[0].charAt(0);return{type:"text",raw:t,text:t}}return C(i,t,i[0],this.lexer)}}emStrong(t,e,i=""){let s=this.rules.inline.emStrong.lDelim.exec(t);if(!s)return;if(s[3]&&i.match(/[\p{L}\p{N}]/u))return;const n=s[1]||s[2]||"";if(!n||n&&(""===i||this.rules.inline.punctuation.exec(i))){const i=s[0].length-1;let n,r,a=i,l=0;const o="*"===s[0][0]?this.rules.inline.emStrong.rDelimAst:this.rules.inline.emStrong.rDelimUnd;for(o.lastIndex=0,e=e.slice(-1*t.length+i);null!=(s=o.exec(e));){if(n=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!n)continue;if(r=n.length,s[3]||s[4]){a+=r;continue}if((s[5]||s[6])&&i%3&&!((i+r)%3)){l+=r;continue}if(a-=r,a>0)continue;if(r=Math.min(r,r+a+l),Math.min(i,r)%2){const e=t.slice(1,i+s.index+r);return{type:"em",raw:t.slice(0,i+s.index+r+1),text:e,tokens:this.lexer.inlineTokens(e,[])}}const e=t.slice(2,i+s.index+r-1);return{type:"strong",raw:t.slice(0,i+s.index+r+1),text:e,tokens:this.lexer.inlineTokens(e,[])}}}}codespan(t){const e=this.rules.inline.code.exec(t);if(e){let t=e[2].replace(/\n/g," ");const i=/[^ ]/.test(t),s=/^ /.test(t)&&/ $/.test(t);return i&&s&&(t=t.substring(1,t.length-1)),t=d(t,!0),{type:"codespan",raw:e[0],text:t}}}br(t){const e=this.rules.inline.br.exec(t);if(e)return{type:"br",raw:e[0]}}del(t){const e=this.rules.inline.del.exec(t);if(e)return{type:"del",raw:e[0],text:e[2],tokens:this.lexer.inlineTokens(e[2],[])}}autolink(t,e){const i=this.rules.inline.autolink.exec(t);if(i){let t,s;return"@"===i[2]?(t=d(this.options.mangle?e(i[1]):i[1]),s="mailto:"+t):(t=d(i[1]),s=t),{type:"link",raw:i[0],text:t,href:s,tokens:[{type:"text",raw:t,text:t}]}}}url(t,e){let i;if(i=this.rules.inline.url.exec(t)){let t,s;if("@"===i[2])t=d(this.options.mangle?e(i[0]):i[0]),s="mailto:"+t;else{let e;do{e=i[0],i[0]=this.rules.inline._backpedal.exec(i[0])[0]}while(e!==i[0]);t=d(i[0]),s="www."===i[1]?"http://"+t:t}return{type:"link",raw:i[0],text:t,href:s,tokens:[{type:"text",raw:t,text:t}]}}}inlineText(t,e){const i=this.rules.inline.text.exec(t);if(i){let t;return t=this.lexer.state.inRawBlock?this.options.sanitize?this.options.sanitizer?this.options.sanitizer(i[0]):d(i[0]):i[0]:d(this.options.smartypants?e(i[0]):i[0]),{type:"text",raw:i[0],text:t}}}}const F={newline:/^(?: *(?:\n|$))+/,code:/^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,fences:/^ {0,3}(`{3,}(?=[^`\n]*\n)|~{3,})([^\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(?=\n|$)|$)/,hr:/^ {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\* *){3,})(?:\n+|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,blockquote:/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,list:/^( {0,3}bull)( [^\n]+?)?(?:\n|$)/,html:"^ {0,3}(?:<(script|pre|style|textarea)[\\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 *)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))",def:/^ {0,3}\[(label)\]: *\n? *<?([^\s>]+)>?(?:(?: +\n? *| *\n *)(title))? *(?:\n+|$)/,table:_,lheading:/^([^\n]+)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html| +\n)[^\n]+)*)/,text:/^[^\n]+/,_label:/(?!\s*\])(?:\\[\[\]]|[^\[\]])+/,_title:/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/};F.def=g(F.def).replace("label",F._label).replace("title",F._title).getRegex(),F.bullet=/(?:[*+-]|\d{1,9}[.)])/,F.listItemStart=g(/^( *)(bull) */).replace("bull",F.bullet).getRegex(),F.list=g(F.list).replace(/bull/g,F.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+F.def.source+")").getRegex(),F._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",F._comment=/<!--(?!-?>)[\s\S]*?(?:-->|$)/,F.html=g(F.html,"i").replace("comment",F._comment).replace("tag",F._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),F.paragraph=g(F._paragraph).replace("hr",F.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",F._tag).getRegex(),F.blockquote=g(F.blockquote).replace("paragraph",F.paragraph).getRegex(),F.normal=w({},F),F.gfm=w({},F.normal,{table:"^ *([^\\n ].*\\|.*)\\n {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"}),F.gfm.table=g(F.gfm.table).replace("hr",F.hr).replace("heading"," {0,3}#{1,6} ").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",F._tag).getRegex(),F.pedantic=w({},F.normal,{html:g("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:\"[^\"]*\"|'[^']*'|\\s[^'\"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment",F._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+|$)/,fences:_,paragraph:g(F.normal._paragraph).replace("hr",F.hr).replace("heading"," *#{1,6} *[^\n]").replace("lheading",F.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()});const O={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:_,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*\])((?:\[[^\[\]]*\]|\\[\[\]]|[^\[\]])*)\](?:\[\])?/,reflinkSearch:"reflink|nolink(?!\\()",emStrong:{lDelim:/^(?:\*+(?:([punct_])|[^\s*]))|^_+(?:([punct*])|([^\s_]))/,rDelimAst:/^[^_*]*?\_\_[^_*]*?\*[^_*]*?(?=\_\_)|[punct_](\*+)(?=[\s]|$)|[^punct*_\s](\*+)(?=[punct_\s]|$)|[punct_\s](\*+)(?=[^punct*_\s])|[\s](\*+)(?=[punct_])|[punct_](\*+)(?=[punct_])|[^punct*_\s](\*+)(?=[^punct*_\s])/,rDelimUnd:/^[^_*]*?\*\*[^_*]*?\_[^_*]*?(?=\*\*)|[punct*](\_+)(?=[\s]|$)|[^punct*_\s](\_+)(?=[punct*\s]|$)|[punct*\s](\_+)(?=[^punct*_\s])|[\s](\_+)(?=[punct*])|[punct*](\_+)(?=[punct*])/},code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,br:/^( {2,}|\\)\n(?!\s*$)/,del:_,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,punctuation:/^([\spunctuation])/};function B(t){return t.replace(/---/g,"—").replace(/--/g,"–").replace(/(^|[-\u2014/(\[{"\s])'/g,"$1‘").replace(/'/g,"’").replace(/(^|[-\u2014/(\[{\u2018\s])"/g,"$1“").replace(/"/g,"”").replace(/\.{3}/g,"…")}function q(t){let e,i,s="";const n=t.length;for(e=0;e<n;e++)i=t.charCodeAt(e),Math.random()>.5&&(i="x"+i.toString(16)),s+="&#"+i+";";return s}O._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",O.punctuation=g(O.punctuation).replace(/punctuation/g,O._punctuation).getRegex(),O.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g,O.escapedEmSt=/\\\*|\\_/g,O._comment=g(F._comment).replace("(?:--\x3e|$)","--\x3e").getRegex(),O.emStrong.lDelim=g(O.emStrong.lDelim).replace(/punct/g,O._punctuation).getRegex(),O.emStrong.rDelimAst=g(O.emStrong.rDelimAst,"g").replace(/punct/g,O._punctuation).getRegex(),O.emStrong.rDelimUnd=g(O.emStrong.rDelimUnd,"g").replace(/punct/g,O._punctuation).getRegex(),O._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,O._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,O._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])?)+(?![-_])/,O.autolink=g(O.autolink).replace("scheme",O._scheme).replace("email",O._email).getRegex(),O._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,O.tag=g(O.tag).replace("comment",O._comment).replace("attribute",O._attribute).getRegex(),O._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,O._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/,O._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,O.link=g(O.link).replace("label",O._label).replace("href",O._href).replace("title",O._title).getRegex(),O.reflink=g(O.reflink).replace("label",O._label).getRegex(),O.reflinkSearch=g(O.reflinkSearch,"g").replace("reflink",O.reflink).replace("nolink",O.nolink).getRegex(),O.normal=w({},O),O.pedantic=w({},O.normal,{strong:{start:/^__|\*\*/,middle:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,endAst:/\*\*(?!\*)/g,endUnd:/__(?!_)/g},em:{start:/^_|\*/,middle:/^()\*(?=\S)([\s\S]*?\S)\*(?!\*)|^_(?=\S)([\s\S]*?\S)_(?!_)/,endAst:/\*(?!\*)/g,endUnd:/_(?!_)/g},link:g(/^!?\[(label)\]\((.*?)\)/).replace("label",O._label).getRegex(),reflink:g(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",O._label).getRegex()}),O.gfm=w({},O.normal,{escape:g(O.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~])\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/}),O.gfm.url=g(O.gfm.url,"i").replace("email",O.gfm._extended_email).getRegex(),O.breaks=w({},O.gfm,{br:g(O.br).replace("{2,}","*").getRegex(),text:g(O.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()});class M{constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||n,this.options.tokenizer=this.options.tokenizer||new E,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const e={block:F.normal,inline:O.normal};this.options.pedantic?(e.block=F.pedantic,e.inline=O.pedantic):this.options.gfm&&(e.block=F.gfm,this.options.breaks?e.inline=O.breaks:e.inline=O.gfm),this.tokenizer.rules=e}static get rules(){return{block:F,inline:O}}static lex(t,e){return new M(e).lex(t)}static lexInline(t,e){return new M(e).inlineTokens(t)}lex(t){let e;for(t=t.replace(/\r\n|\r/g,"\n").replace(/\t/g," "),this.blockTokens(t,this.tokens);e=this.inlineQueue.shift();)this.inlineTokens(e.src,e.tokens);return this.tokens}blockTokens(t,e=[]){let i,s,n,r;for(this.options.pedantic&&(t=t.replace(/^ +$/gm,""));t;)if(!(this.options.extensions&&this.options.extensions.block&&this.options.extensions.block.some((s=>!!(i=s.call({lexer:this},t,e))&&(t=t.substring(i.raw.length),e.push(i),!0)))))if(i=this.tokenizer.space(t))t=t.substring(i.raw.length),i.type&&e.push(i);else if(i=this.tokenizer.code(t))t=t.substring(i.raw.length),s=e[e.length-1],!s||"paragraph"!==s.type&&"text"!==s.type?e.push(i):(s.raw+="\n"+i.raw,s.text+="\n"+i.text,this.inlineQueue[this.inlineQueue.length-1].src=s.text);else if(i=this.tokenizer.fences(t))t=t.substring(i.raw.length),e.push(i);else if(i=this.tokenizer.heading(t))t=t.substring(i.raw.length),e.push(i);else if(i=this.tokenizer.hr(t))t=t.substring(i.raw.length),e.push(i);else if(i=this.tokenizer.blockquote(t))t=t.substring(i.raw.length),e.push(i);else if(i=this.tokenizer.list(t))t=t.substring(i.raw.length),e.push(i);else if(i=this.tokenizer.html(t))t=t.substring(i.raw.length),e.push(i);else if(i=this.tokenizer.def(t))t=t.substring(i.raw.length),s=e[e.length-1],!s||"paragraph"!==s.type&&"text"!==s.type?this.tokens.links[i.tag]||(this.tokens.links[i.tag]={href:i.href,title:i.title}):(s.raw+="\n"+i.raw,s.text+="\n"+i.raw,this.inlineQueue[this.inlineQueue.length-1].src=s.text);else if(i=this.tokenizer.table(t))t=t.substring(i.raw.length),e.push(i);else if(i=this.tokenizer.lheading(t))t=t.substring(i.raw.length),e.push(i);else{if(n=t,this.options.extensions&&this.options.extensions.startBlock){let e=1/0;const i=t.slice(1);let s;this.options.extensions.startBlock.forEach((function(t){s=t.call({lexer:this},i),"number"==typeof s&&s>=0&&(e=Math.min(e,s))})),e<1/0&&e>=0&&(n=t.substring(0,e+1))}if(this.state.top&&(i=this.tokenizer.paragraph(n)))s=e[e.length-1],r&&"paragraph"===s.type?(s.raw+="\n"+i.raw,s.text+="\n"+i.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=s.text):e.push(i),r=n.length!==t.length,t=t.substring(i.raw.length);else if(i=this.tokenizer.text(t))t=t.substring(i.raw.length),s=e[e.length-1],s&&"text"===s.type?(s.raw+="\n"+i.raw,s.text+="\n"+i.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=s.text):e.push(i);else if(t){const e="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(e);break}throw new Error(e)}}return this.state.top=!0,e}inline(t,e){this.inlineQueue.push({src:t,tokens:e})}inlineTokens(t,e=[]){let i,s,n,r,a,l,o=t;if(this.tokens.links){const t=Object.keys(this.tokens.links);if(t.length>0)for(;null!=(r=this.tokenizer.rules.inline.reflinkSearch.exec(o));)t.includes(r[0].slice(r[0].lastIndexOf("[")+1,-1))&&(o=o.slice(0,r.index)+"["+A("a",r[0].length-2)+"]"+o.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;null!=(r=this.tokenizer.rules.inline.blockSkip.exec(o));)o=o.slice(0,r.index)+"["+A("a",r[0].length-2)+"]"+o.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;null!=(r=this.tokenizer.rules.inline.escapedEmSt.exec(o));)o=o.slice(0,r.index)+"++"+o.slice(this.tokenizer.rules.inline.escapedEmSt.lastIndex);for(;t;)if(a||(l=""),a=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some((s=>!!(i=s.call({lexer:this},t,e))&&(t=t.substring(i.raw.length),e.push(i),!0)))))if(i=this.tokenizer.escape(t))t=t.substring(i.raw.length),e.push(i);else if(i=this.tokenizer.tag(t))t=t.substring(i.raw.length),s=e[e.length-1],s&&"text"===i.type&&"text"===s.type?(s.raw+=i.raw,s.text+=i.text):e.push(i);else if(i=this.tokenizer.link(t))t=t.substring(i.raw.length),e.push(i);else if(i=this.tokenizer.reflink(t,this.tokens.links))t=t.substring(i.raw.length),s=e[e.length-1],s&&"text"===i.type&&"text"===s.type?(s.raw+=i.raw,s.text+=i.text):e.push(i);else if(i=this.tokenizer.emStrong(t,o,l))t=t.substring(i.raw.length),e.push(i);else if(i=this.tokenizer.codespan(t))t=t.substring(i.raw.length),e.push(i);else if(i=this.tokenizer.br(t))t=t.substring(i.raw.length),e.push(i);else if(i=this.tokenizer.del(t))t=t.substring(i.raw.length),e.push(i);else if(i=this.tokenizer.autolink(t,q))t=t.substring(i.raw.length),e.push(i);else if(this.state.inLink||!(i=this.tokenizer.url(t,q))){if(n=t,this.options.extensions&&this.options.extensions.startInline){let e=1/0;const i=t.slice(1);let s;this.options.extensions.startInline.forEach((function(t){s=t.call({lexer:this},i),"number"==typeof s&&s>=0&&(e=Math.min(e,s))})),e<1/0&&e>=0&&(n=t.substring(0,e+1))}if(i=this.tokenizer.inlineText(n,B))t=t.substring(i.raw.length),"_"!==i.raw.slice(-1)&&(l=i.raw.slice(-1)),a=!0,s=e[e.length-1],s&&"text"===s.type?(s.raw+=i.raw,s.text+=i.text):e.push(i);else if(t){const e="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(e);break}throw new Error(e)}}else t=t.substring(i.raw.length),e.push(i);return e}}class R{constructor(t){this.options=t||n}code(t,e,i){const s=(e||"").match(/\S*/)[0];if(this.options.highlight){const e=this.options.highlight(t,s);null!=e&&e!==t&&(i=!0,t=e)}return t=t.replace(/\n$/,"")+"\n",s?'<pre><code class="'+this.options.langPrefix+d(s,!0)+'">'+(i?t:d(t,!0))+"</code></pre>\n":"<pre><code>"+(i?t:d(t,!0))+"</code></pre>\n"}blockquote(t){return"<blockquote>\n"+t+"</blockquote>\n"}html(t){return t}heading(t,e,i,s){return this.options.headerIds?"<h"+e+' id="'+this.options.headerPrefix+s.slug(i)+'">'+t+"</h"+e+">\n":"<h"+e+">"+t+"</h"+e+">\n"}hr(){return this.options.xhtml?"<hr/>\n":"<hr>\n"}list(t,e,i){const s=e?"ol":"ul";return"<"+s+(e&&1!==i?' start="'+i+'"':"")+">\n"+t+"</"+s+">\n"}listitem(t){return"<li>"+t+"</li>\n"}checkbox(t){return"<input "+(t?'checked="" ':"")+'disabled="" type="checkbox"'+(this.options.xhtml?" /":"")+"> "}paragraph(t){return"<p>"+t+"</p>\n"}table(t,e){return e&&(e="<tbody>"+e+"</tbody>"),"<table>\n<thead>\n"+t+"</thead>\n"+e+"</table>\n"}tablerow(t){return"<tr>\n"+t+"</tr>\n"}tablecell(t,e){const i=e.header?"th":"td";return(e.align?"<"+i+' align="'+e.align+'">':"<"+i+">")+t+"</"+i+">\n"}strong(t){return"<strong>"+t+"</strong>"}em(t){return"<em>"+t+"</em>"}codespan(t){return"<code>"+t+"</code>"}br(){return this.options.xhtml?"<br/>":"<br>"}del(t){return"<del>"+t+"</del>"}link(t,e,i){if(null===(t=b(this.options.sanitize,this.options.baseUrl,t)))return i;let s='<a href="'+d(t)+'"';return e&&(s+=' title="'+e+'"'),s+=">"+i+"</a>",s}image(t,e,i){if(null===(t=b(this.options.sanitize,this.options.baseUrl,t)))return i;let s='<img src="'+t+'" alt="'+i+'"';return e&&(s+=' title="'+e+'"'),s+=this.options.xhtml?"/>":">",s}text(t){return t}}class I{strong(t){return t}em(t){return t}codespan(t){return t}del(t){return t}html(t){return t}text(t){return t}link(t,e,i){return""+i}image(t,e,i){return""+i}br(){return""}}class P{constructor(){this.seen={}}serialize(t){return t.toLowerCase().trim().replace(/<[!\/a-z].*?>/gi,"").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g,"").replace(/\s/g,"-")}getNextSafeSlug(t,e){let i=t,s=0;if(this.seen.hasOwnProperty(i)){s=this.seen[t];do{s++,i=t+"-"+s}while(this.seen.hasOwnProperty(i))}return e||(this.seen[t]=s,this.seen[i]=0),i}slug(t,e={}){const i=this.serialize(t);return this.getNextSafeSlug(i,e.dryrun)}}class U{constructor(t){this.options=t||n,this.options.renderer=this.options.renderer||new R,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new I,this.slugger=new P}static parse(t,e){return new U(e).parse(t)}static parseInline(t,e){return new U(e).parseInline(t)}parse(t,e=!0){let i,s,n,r,a,l,o,c,h,d,u,m,g,f,k,b,y,$,v,x="";const _=t.length;for(i=0;i<_;i++)if(d=t[i],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[d.type]&&(v=this.options.extensions.renderers[d.type].call({parser:this},d),!1!==v||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(d.type)))x+=v||"";else switch(d.type){case"space":continue;case"hr":x+=this.renderer.hr();continue;case"heading":x+=this.renderer.heading(this.parseInline(d.tokens),d.depth,p(this.parseInline(d.tokens,this.textRenderer)),this.slugger);continue;case"code":x+=this.renderer.code(d.text,d.lang,d.escaped);continue;case"table":for(c="",o="",r=d.header.length,s=0;s<r;s++)o+=this.renderer.tablecell(this.parseInline(d.header[s].tokens),{header:!0,align:d.align[s]});for(c+=this.renderer.tablerow(o),h="",r=d.rows.length,s=0;s<r;s++){for(l=d.rows[s],o="",a=l.length,n=0;n<a;n++)o+=this.renderer.tablecell(this.parseInline(l[n].tokens),{header:!1,align:d.align[n]});h+=this.renderer.tablerow(o)}x+=this.renderer.table(c,h);continue;case"blockquote":h=this.parse(d.tokens),x+=this.renderer.blockquote(h);continue;case"list":for(u=d.ordered,m=d.start,g=d.loose,r=d.items.length,h="",s=0;s<r;s++)k=d.items[s],b=k.checked,y=k.task,f="",k.task&&($=this.renderer.checkbox(b),g?k.tokens.length>0&&"paragraph"===k.tokens[0].type?(k.tokens[0].text=$+" "+k.tokens[0].text,k.tokens[0].tokens&&k.tokens[0].tokens.length>0&&"text"===k.tokens[0].tokens[0].type&&(k.tokens[0].tokens[0].text=$+" "+k.tokens[0].tokens[0].text)):k.tokens.unshift({type:"text",text:$}):f+=$),f+=this.parse(k.tokens,g),h+=this.renderer.listitem(f,y,b);x+=this.renderer.list(h,u,m);continue;case"html":x+=this.renderer.html(d.text);continue;case"paragraph":x+=this.renderer.paragraph(this.parseInline(d.tokens));continue;case"text":for(h=d.tokens?this.parseInline(d.tokens):d.text;i+1<_&&"text"===t[i+1].type;)d=t[++i],h+="\n"+(d.tokens?this.parseInline(d.tokens):d.text);x+=e?this.renderer.paragraph(h):h;continue;default:{const t='Token with "'+d.type+'" type was not found.';if(this.options.silent)return void console.error(t);throw new Error(t)}}return x}parseInline(t,e){e=e||this.renderer;let i,s,n,r="";const a=t.length;for(i=0;i<a;i++)if(s=t[i],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[s.type]&&(n=this.options.extensions.renderers[s.type].call({parser:this},s),!1!==n||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type)))r+=n||"";else switch(s.type){case"escape":case"text":r+=e.text(s.text);break;case"html":r+=e.html(s.text);break;case"link":r+=e.link(s.href,s.title,this.parseInline(s.tokens,e));break;case"image":r+=e.image(s.href,s.title,s.text);break;case"strong":r+=e.strong(this.parseInline(s.tokens,e));break;case"em":r+=e.em(this.parseInline(s.tokens,e));break;case"codespan":r+=e.codespan(s.text);break;case"br":r+=e.br();break;case"del":r+=e.del(this.parseInline(s.tokens,e));break;default:{const t='Token with "'+s.type+'" type was not found.';if(this.options.silent)return void console.error(t);throw new Error(t)}}return r}}function z(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("function"==typeof e&&(i=e,e=null),L(e=w({},z.defaults,e||{})),i){const n=e.highlight;let r;try{r=M.lex(t,e)}catch(s){return i(s)}const a=function(t){let a;if(!t)try{e.walkTokens&&z.walkTokens(r,e.walkTokens),a=U.parse(r,e)}catch(s){t=s}return e.highlight=n,t?i(t):i(null,a)};if(!n||n.length<3)return a();if(delete e.highlight,!r.length)return a();let l=0;return z.walkTokens(r,(function(t){"code"===t.type&&(l++,setTimeout((()=>{n(t.text,t.lang,(function(e,i){if(e)return a(e);null!=i&&i!==t.text&&(t.text=i,t.escaped=!0),l--,0===l&&a()}))}),0))})),void(0===l&&a())}try{const i=M.lex(t,e);return e.walkTokens&&z.walkTokens(i,e.walkTokens),U.parse(i,e)}catch(s){if(s.message+="\nPlease report this to https://github.com/markedjs/marked.",e.silent)return"<p>An error occurred:</p><pre>"+d(s.message+"",!0)+"</pre>";throw s}}z.options=z.setOptions=function(t){var e;return w(z.defaults,t),e=z.defaults,n=e,z},z.getDefaults=s,z.defaults=n,z.use=function(...t){const e=w({},...t),i=z.defaults.extensions||{renderers:{},childTokens:{}};let s;t.forEach((t=>{if(t.extensions&&(s=!0,t.extensions.forEach((t=>{if(!t.name)throw new Error("extension name required");if(t.renderer){const e=i.renderers?i.renderers[t.name]:null;i.renderers[t.name]=e?function(...i){let s=t.renderer.apply(this,i);return!1===s&&(s=e.apply(this,i)),s}:t.renderer}if(t.tokenizer){if(!t.level||"block"!==t.level&&"inline"!==t.level)throw new Error("extension level must be 'block' or 'inline'");i[t.level]?i[t.level].unshift(t.tokenizer):i[t.level]=[t.tokenizer],t.start&&("block"===t.level?i.startBlock?i.startBlock.push(t.start):i.startBlock=[t.start]:"inline"===t.level&&(i.startInline?i.startInline.push(t.start):i.startInline=[t.start]))}t.childTokens&&(i.childTokens[t.name]=t.childTokens)}))),t.renderer){const i=z.defaults.renderer||new R;for(const e in t.renderer){const s=i[e];i[e]=(...n)=>{let r=t.renderer[e].apply(i,n);return!1===r&&(r=s.apply(i,n)),r}}e.renderer=i}if(t.tokenizer){const i=z.defaults.tokenizer||new E;for(const e in t.tokenizer){const s=i[e];i[e]=(...n)=>{let r=t.tokenizer[e].apply(i,n);return!1===r&&(r=s.apply(i,n)),r}}e.tokenizer=i}if(t.walkTokens){const i=z.defaults.walkTokens;e.walkTokens=function(e){t.walkTokens.call(this,e),i&&i.call(this,e)}}s&&(e.extensions=i),z.setOptions(e)}))},z.walkTokens=function(t,e){for(const i of t)switch(e.call(z,i),i.type){case"table":for(const t of i.header)z.walkTokens(t.tokens,e);for(const t of i.rows)for(const i of t)z.walkTokens(i.tokens,e);break;case"list":z.walkTokens(i.items,e);break;default:z.defaults.extensions&&z.defaults.extensions.childTokens&&z.defaults.extensions.childTokens[i.type]?z.defaults.extensions.childTokens[i.type].forEach((function(t){z.walkTokens(i[t],e)})):i.tokens&&z.walkTokens(i.tokens,e)}},z.parseInline=function(t,e){if(null==t)throw new Error("marked.parseInline(): input parameter is undefined or null");if("string"!=typeof t)throw new Error("marked.parseInline(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected");L(e=w({},z.defaults,e||{}));try{const i=M.lexInline(t,e);return e.walkTokens&&z.walkTokens(i,e.walkTokens),U.parseInline(i,e)}catch(i){if(i.message+="\nPlease report this to https://github.com/markedjs/marked.",e.silent)return"<p>An error occurred:</p><pre>"+d(i.message+"",!0)+"</pre>";throw i}},z.Parser=U,z.parser=U.parse,z.Renderer=R,z.TextRenderer=I,z.Lexer=M,z.lexer=M.lex,z.Tokenizer=E,z.Slugger=P,z.parse=z,U.parse,M.lex;"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var N={"&":"&","<":"<",">":">",'"':""","'":"'"},D={"&":"&","<":"<",">":">",""":'"',"'":"'"},W=/(&|<|>|"|')/g,H=/[&<>"']/g;function V(t){return N[t]}function j(t){return D[t]}function Q(t){return null==t?"":String(t).replace(H,V)}function G(t){return null==t?"":String(t).replace(W,j)}Q.options=G.options={};var Y={encode:Q,escape:Q,decode:G,unescape:G,version:"1.0.0-browser"};var Z=function t(e){for(var i,s,n=Array.prototype.slice.call(arguments,1);n.length;)for(s in i=n.shift())i.hasOwnProperty(s)&&("[object Object]"===Object.prototype.toString.call(e[s])?e[s]=t(e[s],i[s]):e[s]=i[s]);return e},K=function(t){return"string"==typeof t?t.toLowerCase():t};function X(t,e){return t[e]=!0,t}var J=function(t){return t.reduce(X,{})},tt={uris:J(["background","base","cite","href","longdesc","src","usemap"])},et={voids:J(["area","br","col","hr","img","wbr","input","base","basefont","link","meta"])},it=Y,st=K,nt=et,rt=/^<\s*([\w:-]+)((?:\s+[\w:-]+(?:\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|[^>\s]+))?)*)\s*(\/?)\s*>/,at=/^<\s*\/\s*([\w:-]+)[^>]*>/,lt=/([\w:-]+)(?:\s*=\s*(?:(?:"((?:[^"])*)")|(?:'((?:[^'])*)')|([^>\s]+)))?/g,ot=/^</,ct=/^<\s*\//;var ht=Y,dt=K,ut=tt,pt=et;var mt=Z,gt=function(t,e){for(var i,s=function(){var t=[];return t.lastItem=function(){return t[t.length-1]},t}(),n=t;t;)r();function r(){i=!0,function(){"\x3c!--"===t.substr(0,4)?(s=t.indexOf("--\x3e"))>=0&&(e.comment&&e.comment(t.substring(4,s)),t=t.substring(s+3),i=!1):ct.test(t)?a(at,o):ot.test(t)&&a(rt,l);var s;!function(){if(!i)return;var s,n=t.indexOf("<");n>=0?(s=t.substring(0,n),t=t.substring(n)):(s=t,t="");e.chars&&e.chars(s)}()}();var s=t===n;n=t,s&&(t="")}function a(e,s){var n=t.match(e);n&&(t=t.substring(n[0].length),n[0].replace(e,s),i=!1)}function l(t,i,n,r){var a={},l=st(i),o=nt.voids[l]||!!r;n.replace(lt,(function(t,e,i,s,n){a[e]=void 0===i&&void 0===s&&void 0===n?void 0:it.decode(i||s||n||"")})),o||s.push(l),e.start&&e.start(l,a,o)}function o(t,i){var n,r=0,a=st(i);if(a)for(r=s.length-1;r>=0&&s[r]!==a;r--);if(r>=0){for(n=s.length-1;n>=r;n--)e.end&&e.end(s[n]);s.length=r}}o()},ft=function(t,e){var i,s=e||{};return l(),{start:function(t,e,a){var l=dt(t);if(i.ignoring)return void r(l);if(-1===(s.allowedTags||[]).indexOf(l))return void r(l);if(s.filter&&!s.filter({tag:l,attrs:e}))return void r(l);n("<"),n(l),Object.keys(e).forEach((function(t){var i=e[t],r=(s.allowedClasses||{})[l]||[],a=(s.allowedAttributes||{})[l]||[],o=dt(t);("class"===o&&-1===a.indexOf(o)?(i=i.split(" ").filter((function(t){return r&&-1!==r.indexOf(t)})).join(" ").trim()).length:-1!==a.indexOf(o)&&(!0!==ut.uris[o]||function(t){var e=t[0];if("#"===e||"/"===e)return!0;var i=t.indexOf(":");if(-1===i)return!0;var n=t.indexOf("?");if(-1!==n&&i>n)return!0;var r=t.indexOf("#");return-1!==r&&i>r||s.allowedSchemes.some(a);function a(e){return 0===t.indexOf(e+":")}}(i)))&&(n(" "),n(t),"string"==typeof i&&(n('="'),n(ht.encode(i)),n('"')))})),n(a?"/>":">")},end:function(t){var e=dt(t);-1!==(s.allowedTags||[]).indexOf(e)&&!1===i.ignoring?(n("</"),n(e),n(">")):a(e)},chars:function(t){!1===i.ignoring&&n(s.transformText?s.transformText(t):t)}};function n(e){t.push(e)}function r(t){pt.voids[t]||(!1===i.ignoring?i={ignoring:t,depth:1}:i.ignoring===t&&i.depth++)}function a(t){i.ignoring===t&&--i.depth<=0&&l()}function l(){i={ignoring:!1,depth:0}}},kt={allowedAttributes:{a:["href","name","target","title","aria-label"],iframe:["allowfullscreen","frameborder","src"],img:["src","alt","title","aria-label"]},allowedClasses:{},allowedSchemes:["http","https","mailto"],allowedTags:["a","abbr","article","b","blockquote","br","caption","code","del","details","div","em","h1","h2","h3","h4","h5","h6","hr","i","img","ins","kbd","li","main","mark","ol","p","pre","section","span","strike","strong","sub","summary","sup","table","tbody","td","th","thead","tr","u","ul"],filter:null};function bt(t,e,i){var s=[],n=!0===i?e:mt({},kt,e),r=ft(s,n);return gt(t,r),s.join("")}bt.defaults=kt;var yt=bt,$t={exports:{}};$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 s(t){return'<span style="color: slategray">'+t+"</span>"}return function(t,n){void 0===n&&(n={});var r=n.colors;void 0===r&&(r=i);var a=0,l={},o=new RegExp("("+/[\u4E00-\u9FFF\u3400-\u4dbf\uf900-\ufaff\u3040-\u309f\uac00-\ud7af\u0400-\u04FF]+|\w+/.source+"|"+/</.source+")|("+e().source+")","gmi");return t.replace(o,(function(t,e,i){if(i)return s(i);if("<"===e)return"<";var n;l[e]?n=l[e]:(n=r[a],l[e]=n);var o='<span style="color: #'+n+'">'+e+"</span>";return a=++a%r.length,o}))}}();var vt=$t.exports;function xt(t=""){const e=document.createElement("div");return e.innerHTML=t.trim(),e.firstElementChild||e}function _t(t){return parseFloat(getComputedStyle(t,null).height.replace("px",""))}function wt(t){const e=RegExp(`[?&]${t}=([^&]*)`).exec(window.location.search);return e&&decodeURIComponent(e[1].replace(/\+/g," "))}function St(t){const e=t.getBoundingClientRect();return{top:e.top+window.scrollY,left:e.left+window.scrollX}}function Tt(t,e){let i=t.toString();for(;i.length<e;)i=`0${i}`;return i}function Lt(t){try{const e=t.getTime(),i=(new Date).getTime()-e,s=Math.floor(i/864e5);if(0===s){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 s<0?"刚刚":s<8?`${s} 天前`:function(t){const e=Tt(t.getDate(),2),i=Tt(t.getMonth()+1,2);return`${Tt(t.getFullYear(),2)}-${i}-${e}`}(t)}catch(e){return console.error(e)," - "}}function At(t,e){if(!t)return;const i=t.getElementsByTagName("img");if(!i.length)return;let s=i.length;for(let n=0;n<i.length;n++)i[n].complete?s--:i[n].addEventListener("load",(()=>{s--,0===s&&e()})),0===s&&e()}function Ct(t,e){var i,s;return`${((null==(i=t.conf.gravatar)?void 0:i.mirror)||"").replace(/\/$/,"")}/${e}?d=${encodeURIComponent((null==(s=t.conf.gravatar)?void 0:s.default)||"")}&s=80`}let Et;function Ft(t,e){if(!Et){const t=new z.Renderer,e=t.link;t.link=(i,s,n)=>{const r=null==i?void 0:i.startsWith(`${window.location.protocol}//${window.location.hostname}`);return e.call(t,i,s,n).replace(/^<a /,`<a target="_blank" ${r?"":'rel="noreferrer noopener nofollow"'} `)};const i=z;z.setOptions({renderer:t,highlight:t=>vt(t),pedantic:!1,gfm:!0,breaks:!0,smartLists:!0,smartypants:!0,xhtml:!1,sanitize:!0,sanitizer:t=>yt(t,__spreadProps(__spreadValues({},yt.defaults),{allowedAttributes:__spreadProps(__spreadValues({},yt.defaults.allowedAttributes),{img:["src","atk-emoticon"]})})),silent:!0}),Et=i}return Et.parse(e)}function Ot(t){t instanceof e&&(t=t.$root);let i=t.querySelector(".atk-loading");i||(i=xt('<div class="atk-loading atk-fade-in" 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(i)),i.style.display="";const s=i.querySelector(".atk-loading-spinner");s&&(s.style.display="none",window.setTimeout((()=>{s.style.display=""}),500))}function Bt(t){t instanceof e&&(t=t.$root);const i=t.querySelector(".atk-loading");i&&(i.style.display="none")}function qt(t,e=!0){const i=St(t).top+_t(t)/2-document.documentElement.clientHeight/2;e?window.scroll({top:i>0?i:0,left:0}):window.scroll(0,i>0?i:0)}function Mt(t,e,i){const s=xt(`<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>`);s.querySelector(".atk-notify-content").innerHTML=function(t){const e=document.createElement("div");return e.innerText=t,e.innerHTML}(e).replace("\n","<br/>"),t.appendChild(s);const n=()=>{s.classList.add("atk-fade-out"),setTimeout((()=>{s.remove()}),200)};let r;r=window.setTimeout((()=>{n()}),3e3),s.addEventListener("click",(()=>{n(),window.clearTimeout(r)}))}function Rt(t,e){!function(t,e,i="in"){t.classList.add(`atk-fade-${i}`);const s=()=>{t.classList.remove(`atk-fade-${i}`),t.removeEventListener("animationend",s),e&&e()};t.addEventListener("animationend",s)}(t,e,"in")}function It(t,i,s='<span class="atk-error-title">Artalk Error</span>'){t instanceof e&&(t=t.$root);let n=t.querySelector(".atk-error-layer");if(null===i)return void(null!==n&&n.remove());n||(n=xt(`<div class="atk-error-layer">${s}<span class="atk-error-text"></span></div>`),t.appendChild(n));const r=n.querySelector(".atk-error-text");r.innerHTML="",null!==i&&(i instanceof HTMLElement?r.appendChild(i):r.innerText=i)}const Pt=class extends i{constructor(t,e,i){super(t),__publicField(this,"name"),__publicField(this,"$wrap"),__publicField(this,"$mask"),__publicField(this,"maskClickHideEnable",!0),__publicField(this,"bodyStyleOrgOverflow",""),__publicField(this,"bodyStyleOrgPaddingRight",""),__publicField(this,"afterHide"),this.name=e;const{$wrap:s,$mask:n}=zt(t);this.$wrap=s,this.$mask=n,this.$el=this.$wrap.querySelector(`[data-layer-name="${e}"].atk-layer-item`),null===this.$el&&(i?this.$el=i:(this.$el=xt(),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}show(){this.fireAllActionTimer(),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=`${function(){const t=document.createElement("p");t.style.width="100%",t.style.height="200px";const e=document.createElement("div");e.style.position="absolute",e.style.top="0px",e.style.left="0px",e.style.visibility="hidden",e.style.width="200px",e.style.height="150px",e.style.overflow="hidden",e.appendChild(t),document.body.appendChild(e);const i=t.offsetWidth;e.style.overflow="scroll";let s=t.offsetWidth;return i===s&&(s=e.clientWidth),document.body.removeChild(e),i-s}()+t||0}px`}hide(){this.afterHide&&this.afterHide(),this.$wrap.classList.add("atk-fade-out"),this.$el.style.display="none",this.newActionTimer((()=>{this.$wrap.style.display="none",document.body.style.overflow=this.bodyStyleOrgOverflow,document.body.style.paddingRight=this.bodyStyleOrgPaddingRight,this.checkCleanLayer()}),450),this.newActionTimer((()=>{this.$wrap.style.display="none",this.$wrap.classList.remove("atk-fade-out")}),200)}setMaskClickHide(t){this.maskClickHideEnable=t}newActionTimer(t,e){const i=()=>{t(),Pt.actionTimers=Pt.actionTimers.filter((t=>t.act!==i))},s=window.setTimeout((()=>i()),e);Pt.actionTimers.push({act:i,tid:s})}fireAllActionTimer(){Pt.actionTimers.forEach((t=>{clearTimeout(t.tid),t.act()}))}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.$wrap.style.display="none")}};let Ut=Pt;function zt(t){let e=document.querySelector(`.atk-layer-wrap#ctx-${t.cid}`);e||(e=xt(`<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{$wrap:e,$mask:i}}__publicField(Ut,"actionTimers",[]);class Nt{constructor(t){return __publicField(this,"$el"),__publicField(this,"$content"),__publicField(this,"$actions"),this.$el=xt('<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-actions"></div>\n </div>\n </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=xt('<button data-action="confirm">确定</button>');return e.onclick=this.onBtnClick(t),this.$actions.appendChild(e),this}setNo(t){const e=xt('<button data-action="cancel">取消</button>');return e.onclick=this.onBtnClick(t),this.$actions.appendChild(e),this}onBtnClick(t){return e=>{const i=t(e.currentTarget,this);void 0!==i&&!0!==i||this.$el.remove()}}}function Dt(t,e,i,s){return __async(this,null,(function*(){if(t.user.data.token){const e=new Headers;e.set("Authorization",`Bearer ${t.user.data.token}`),i.headers=e}try{let a;if(a="number"!=typeof s&&0===t.conf.reqTimeout||0===s?yield fetch(e,i):yield(n=s||t.conf.reqTimeout||15e3,r=fetch(e,i),new Promise(((t,e)=>{const i=setTimeout((()=>{e(new Error("请求超时"))}),n);r.then((e=>{clearTimeout(i),t(e)}),(t=>{clearTimeout(i),e(t)}))}))),!a.ok&&401!==a.status)throw new Error(`请求响应 ${a.status}`);let l=yield a.json();const o=(s,n)=>{Dt(t,e,i).then((t=>{s(t)})).catch((t=>{n(t)}))};if(l.data&&l.data.need_captcha?l=yield new Promise(((e,i)=>{t.trigger("checker-captcha",{imgData:l.data.img_data,onSuccess:()=>{o(e,i)},onCancel:()=>{i(l)}})})):(l.data&&l.data.need_login||401===a.status)&&(l=yield new Promise(((e,i)=>{t.trigger("checker-admin",{onSuccess:()=>{o(e,i)},onCancel:()=>{i(l)}})}))),!l.success)throw l;return l}catch(a){if(console.error(a),a instanceof TypeError)throw new Error("网络错误");throw a}var n,r}))}function Wt(t,e,i){return __async(this,null,(function*(){const s={method:"POST"};i&&(s.body=Vt(i));return(yield Dt(t,e,s)).data||{}}))}function Ht(t,e,i){return __async(this,null,(function*(){return(yield Dt(t,e+(i?`?${new URLSearchParams(i)}`:""),{method:"GET"})).data||{}}))}function Vt(t){const e=new FormData;return Object.keys(t).forEach((i=>e.append(i,String(t[i])))),e}class jt{constructor(t){__publicField(this,"ctx"),__publicField(this,"baseURL"),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:e,offset:t};return 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),Wt(this.ctx,`${this.baseURL}/get`,n)}add(t){return __async(this,null,(function*(){const e={name:t.nick,email:t.email,link:t.link,content:t.content,rid:t.rid,page_key:t.page_key};t.page_title&&(e.page_title=t.page_title),t.site_name&&(e.site_name=t.site_name);return(yield Wt(this.ctx,`${this.baseURL}/add`,e)).comment}))}commentEdit(t){return __async(this,null,(function*(){const e=__spreadValues({},t);return(yield Wt(this.ctx,`${this.baseURL}/admin/comment-edit`,e)).comment}))}commentDel(t,e){const i={id:String(t),site_name:e||""};return Wt(this.ctx,`${this.baseURL}/admin/comment-del`,i)}login(t,e,i){return __async(this,null,(function*(){const s={name:t,email:e,password:i};this.ctx.conf.site&&(s.site_name=this.ctx.conf.site);return(yield Wt(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:Dt(this.ctx,`${this.baseURL}/user-get`,{method:"POST",body:Vt(n),signal:s}).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()}}}pageGet(t,e,i){return __async(this,null,(function*(){const s={site_name:t||"",offset:e||0,limit:i||15};return yield Wt(this.ctx,`${this.baseURL}/admin/page-get`,s)}))}pageEdit(t){return __async(this,null,(function*(){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(yield Wt(this.ctx,`${this.baseURL}/admin/page-edit`,e)).page}))}pageDel(t,e){const i={key:String(t),site_name:e||""};return Wt(this.ctx,`${this.baseURL}/admin/page-del`,i)}pageFetch(t){return __async(this,null,(function*(){const e={id:t};return(yield Wt(this.ctx,`${this.baseURL}/admin/page-fetch`,e)).page}))}siteGet(){return __async(this,null,(function*(){return(yield Wt(this.ctx,`${this.baseURL}/admin/site-get`,{})).sites}))}siteAdd(t,e){return __async(this,null,(function*(){const i={name:t,urls:e};return(yield Wt(this.ctx,`${this.baseURL}/admin/site-add`,i)).site}))}siteEdit(t){return __async(this,null,(function*(){const e={id:t.id,name:t.name||"",urls:t.urls||""};return(yield Wt(this.ctx,`${this.baseURL}/admin/site-edit`,e)).site}))}siteDel(t,e=!1){const i={id:t,del_content:e};return Wt(this.ctx,`${this.baseURL}/admin/site-del`,i)}export(){return __async(this,null,(function*(){var t;return(null==(t=(yield Dt(this.ctx,`${this.baseURL}/admin/export`,{method:"POST"},0)).data)?void 0:t.data)||""}))}vote(t,e){return __async(this,null,(function*(){const i={site_name:this.ctx.conf.site||"",target_id:t,type:e};this.ctx.user.checkHasBasicUserInfo()&&(i.name=this.ctx.user.data.nick,i.email=this.ctx.user.data.email);return yield Wt(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),Wt(this.ctx,`${this.baseURL}/mark-read`,i)}captchaGet(){return __async(this,null,(function*(){return(yield Ht(this.ctx,`${this.baseURL}/captcha/refresh`)).img_data||""}))}captchaCheck(t){return __async(this,null,(function*(){return(yield Ht(this.ctx,`${this.baseURL}/captcha/check`,{value:t})).img_data||""}))}}const Qt={request:(t,e)=>new jt(t.ctx).captchaCheck(e),body(t){const e=xt(`<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 jt(t.ctx).captchaGet().then((t=>{i.setAttribute("src",t)})).catch((t=>{console.error("验证码获取失败 ",t)}))},e},onSuccess(t,e,i,s){t.submitCaptchaVal=i},onError(t,e,i,s){s.querySelector(".atk-captcha-img").click()}},Gt={inputType:"password",request(t,e){const i={name:t.ctx.user.data.nick,email:t.ctx.user.data.email,password:e};return new jt(t.ctx).login(i.name,i.email,i.password)},body:()=>xt("<span>敲入密码来验证管理员身份:</span>"),onSuccess(t,e,i,s){t.ctx.user.data.isAdmin=!0,t.ctx.user.data.token=e,t.ctx.user.save(),t.ctx.trigger("user-changed",t.ctx.user.data),t.ctx.trigger("list-reload")},onError(t,e,i,s){}};class Yt{constructor(t){__publicField(this,"ctx"),__publicField(this,"launched",[]),__publicField(this,"submitCaptchaVal"),__publicField(this,"submitCaptchaImgData"),this.ctx=t,this.initEventBind()}initEventBind(){this.ctx.on("checker-captcha",(t=>{t.imgData&&(this.submitCaptchaImgData=t.imgData),this.fire(Qt,t)})),this.ctx.on("checker-admin",(t=>{this.fire(Gt,t)}))}fire(t,e){if(this.launched.includes(t))return;this.launched.push(t);const i=new Ut(this.ctx,`checker-${(new Date).getTime()}`);i.setMaskClickHide(!1),i.show();const s=xt();s.appendChild(t.body(this));const n=xt(`<input id="check" type="${t.inputType||"text"}" autocomplete="off" required placeholder="">`);let r;s.appendChild(n),setTimeout((()=>n.focus()),80),n.onkeyup=t=>{"Enter"!==t.key&&13!==t.keyCode||(t.preventDefault(),i.getEl().querySelector('button[data-action="confirm"]').click())};const a=new Nt(s);a.setYes((l=>{const o=n.value.trim();r||(r=l.innerText);const c=()=>{l.innerText=r||"",l.classList.remove("error")};return l.innerText="加载中...",t.request(this,o).then((n=>{this.done(t,i),t.onSuccess&&t.onSuccess(this,n,o,s),e.onSuccess&&e.onSuccess(o,a.$el)})).catch((e=>{var i;i=String(e.msg||String(e)),l.innerText=i,l.classList.add("error"),t.onError&&t.onError(this,e,o,s);const r=setTimeout((()=>c()),3e3);n.onfocus=()=>{c(),clearTimeout(r)}})),!1})),a.setNo((()=>(this.done(t,i),e.onCancel&&e.onCancel(),!1))),i.getEl().append(a.$el),e.onMount&&e.onMount(a.$el)}done(t,e){e.disposeNow(),this.launched=this.launched.filter((e=>e!==t))}}class Zt{constructor(t){__publicField(this,"editor"),__publicField(this,"ctx"),this.editor=t,this.ctx=t.ctx}}__publicField(Zt,"Name"),__publicField(Zt,"BtnHTML");class Kt extends Zt{constructor(t){super(t),__publicField(this,"$el"),__publicField(this,"emoticons",[]),__publicField(this,"$grpWrap"),__publicField(this,"$grpSwitcher"),this.editor=t,this.$el=xt('<div class="atk-editor-plug-emoticons"></div>'),this.init()}init(){return __async(this,null,(function*(){Ot(this.$el),this.emoticons=yield this.handleData(this.ctx.conf.emoticons),Bt(this.$el),this.initEmoticonsList()}))}handleData(t){return __async(this,null,(function*(){if(!Array.isArray(t)&&["object","string"].includes(typeof t)&&(t=[t]),!Array.isArray(t))return It(this.$el,"表情包数据必须为 Array/Object/String 类型"),Bt(this.$el),[];const e=e=>{"object"==typeof e&&(e.name&&t.find((t=>t.name===e.name))||t.push(e))},i=t=>__async(this,null,(function*(){yield Promise.all(t.map(((t,s)=>__async(this,null,(function*(){if("object"!=typeof t||Array.isArray(t)){if(Array.isArray(t))yield i(t);else if("string"==typeof t){const s=yield this.remoteLoad(t);Array.isArray(s)?yield i(s):"object"==typeof s&&e(s)}}else e(t)})))))}));return yield i(t),t.forEach((t=>{if(this.isOwOFormat(t)){this.convertOwO(t).forEach((t=>{e(t)}))}else Array.isArray(t)&&t.forEach((t=>{e(t)}))})),t=t.filter((t=>"object"==typeof t&&!Array.isArray(t)&&!!t&&!!t.name)),console.log(t),this.solveNullKey(t),this.solveSameKey(t),t}))}remoteLoad(t){return __async(this,null,(function*(){if(!t)return[];try{const e=yield fetch(t);return yield e.json()}catch(e){return Bt(this.$el),It(this.$el,`表情加载失败 ${String(e)}`),[]}}))}solveNullKey(t){t.forEach((t=>{t.items.forEach(((e,i)=>{e.key||(e.key=`${t.name} ${i+1}`)}))}))}solveSameKey(t){const e={};t.forEach((t=>{t.items.forEach((t=>{t.key&&""!==String(t.key).trim()&&(e[t.key]?e[t.key]++:e[t.key]=1,e[t.key]>1&&(t.key=`${t.key} ${e[t.key]}`))}))}))}isOwOFormat(t){try{return"object"==typeof t&&!!Object.values(t).length&&Array.isArray(Object.keys(Object.values(t)[0].container))&&Object.keys(Object.values(t)[0].container[0]).includes("icon")}catch(e){return!1}}convertOwO(t){const e=[];return Object.entries(t).forEach((([t,i])=>{const s={name:t,type:i.type,items:[]};i.container.forEach(((e,i)=>{const n=e.icon;if(/<(img|IMG)/.test(n)){const t=/src=["'](.*?)["']/.exec(n);t&&t.length>1&&(e.icon=t[1])}s.items.push({key:e.text||`${t} ${i+1}`,val:e.icon})})),e.push(s)})),e}initEmoticonsList(){this.$grpWrap=xt('<div class="atk-grp-wrap"></div>'),this.$el.append(this.$grpWrap),this.emoticons.forEach(((t,e)=>{const i=xt('<div class="atk-grp" style="display: none;"></div>');this.$grpWrap.append(i),i.setAttribute("data-index",String(e)),i.setAttribute("data-grp-name",t.name),i.setAttribute("data-type",t.type),t.items.forEach((e=>{const s=xt('<span class="atk-item"></span>');if(i.append(s),e.key&&!new RegExp(`^(${t.name})?\\s?[0-9]+$`).test(e.key)&&s.setAttribute("title",e.key),"image"===t.type){const t=document.createElement("img");t.src=e.val,t.alt=e.key,s.append(t)}else s.innerText=e.val;s.onclick=()=>{"image"===t.type?this.editor.insertContent(`:[${e.key}]`):this.editor.insertContent(e.val||"")}}))})),this.$grpSwitcher=xt('<div class="atk-grp-switcher"></div>'),this.$el.append(this.$grpSwitcher),this.emoticons.forEach(((t,e)=>{const i=xt("<span />");i.innerText=t.name,i.setAttribute("data-index",String(e)),i.onclick=()=>this.openGrp(e),this.$grpSwitcher.append(i)})),this.emoticons.length>0&&this.openGrp(0)}openGrp(t){var e;Array.from(this.$grpWrap.children).forEach((e=>{const i=e;i.getAttribute("data-index")!==String(t)?i.style.display="none":i.style.display=""})),this.$grpSwitcher.querySelectorAll("span.active").forEach((t=>t.classList.remove("active"))),null==(e=this.$grpSwitcher.querySelector(`span[data-index="${t}"]`))||e.classList.add("active"),this.changeListHeight()}getEl(){return this.$el}changeListHeight(){}onShow(){setTimeout((()=>{this.changeListHeight()}),30)}onHide(){this.$el.parentElement.style.height=""}transEmoticonImageText(t){return this.emoticons&&Array.isArray(this.emoticons)?(this.emoticons.forEach((e=>{"image"===e.type&&Object.entries(e.items).forEach((([e,i])=>{t=t.split(`:[${i.key}]`).join(`<img src="${i.val}" atk-emoticon="${i.key}">`)}))})),t):t}}__publicField(Kt,"Name","emoticons"),__publicField(Kt,"BtnHTML","表情");class Xt extends Zt{constructor(t){super(t),__publicField(this,"$el"),__publicField(this,"binded",!1),this.initEl()}initEl(){this.$el=xt('<div class="atk-editor-plug-preview"></div>'),this.binded=!1}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(){"none"!==this.$el.style.display&&(this.$el.innerHTML=this.editor.getContentMarked())}}__publicField(Xt,"Name","preview"),__publicField(Xt,"BtnHTML",'预览 <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>');class Jt extends i{constructor(t){super(t),__publicField(this,"LOADABLE_PLUG_LIST",[Kt,Xt]),__publicField(this,"plugList",{}),__publicField(this,"$header"),__publicField(this,"$textareaWrap"),__publicField(this,"$textarea"),__publicField(this,"$plugWrap"),__publicField(this,"$bottom"),__publicField(this,"$plugBtnWrap"),__publicField(this,"$submitBtn"),__publicField(this,"$notifyWrap"),__publicField(this,"replyComment",null),__publicField(this,"$sendReply",null),__publicField(this,"isTraveling",!1),__publicField(this,"queryUserInfo",{timeout:null,abortFunc:null}),__publicField(this,"openedPlugName",null),this.$el=xt('<div class="atk-main-editor">\n <div class="atk-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-textarea-wrap">\n <textarea class="atk-textarea" placeholder=""></textarea>\n </div>\n <div class="atk-plug-wrap" style="display: none;"></div>\n <div class="atk-bottom">\n <div class="atk-item atk-plug-btn-wrap"></div>\n <div class="atk-item">\n <button type="button" class="atk-send-btn"></button>\n </div>\n </div>\n <div class="atk-notify-wrap"></div>\n</div>\n'),this.$header=this.$el.querySelector(".atk-header"),this.$textareaWrap=this.$el.querySelector(".atk-textarea-wrap"),this.$textarea=this.$el.querySelector(".atk-textarea"),this.$plugWrap=this.$el.querySelector(".atk-plug-wrap"),this.$bottom=this.$el.querySelector(".atk-bottom"),this.$plugBtnWrap=this.$el.querySelector(".atk-plug-btn-wrap"),this.$submitBtn=this.$el.querySelector(".atk-send-btn"),this.$notifyWrap=this.$el.querySelector(".atk-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",(t=>this.setReply(t.data,t.$el,t.scroll))),this.ctx.on("editor-reply-cancel",(()=>this.cancelReply())),this.ctx.on("editor-show-loading",(()=>Ot(this.$el))),this.ctx.on("editor-hide-loading",(()=>Bt(this.$el))),this.ctx.on("editor-notify",(t=>this.showNotify(t.msg,t.type))),this.ctx.on("editor-travel",(t=>this.travel(t))),this.ctx.on("editor-travel-back",(()=>this.travelBack()))}get user(){return this.ctx.user}initLocalStorage(){const t=window.localStorage.getItem("ArtalkContent")||"";""!==t.trim()&&(this.showNotify("已自动恢复","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}"]`)}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 jt(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.trigger("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.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=>{9===(t.keyCode||t.which)&&(t.preventDefault(),this.insertContent("\t"))})),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`}initEditorPlug(){this.plugList={},this.$plugWrap.innerHTML="",this.$plugWrap.style.display="none",this.openedPlugName=null,this.$plugBtnWrap.innerHTML="",this.LOADABLE_PLUG_LIST.forEach((t=>{const e=xt(`<span class="atk-plug-btn">${t.BtnHTML}</span>`);this.$plugBtnWrap.appendChild(e),e.addEventListener("click",(()=>{let i=this.plugList[t.Name];if(i||(i=new t(this),this.plugList[t.Name]=i),this.$plugBtnWrap.querySelectorAll(".active").forEach((t=>t.classList.remove("active"))),t.Name===this.openedPlugName)return i.onHide(),this.$plugWrap.style.display="none",void(this.openedPlugName=null);if(null===this.$plugWrap.querySelector(`[data-plug-name="${t.Name}"]`)){const e=i.getEl();e.setAttribute("data-plug-name",t.Name),e.style.display="none",this.$plugWrap.appendChild(e)}Array.from(this.$plugWrap.children).forEach((e=>{const i=e.getAttribute("data-plug-name");i===t.Name?(e.style.display="",this.plugList[i].onShow()):(e.style.display="none",this.plugList[i].onHide())})),this.$plugWrap.style.display="",this.openedPlugName=t.Name,e.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||0===this.$textarea.selectionStart){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();if(this.plugList&&this.plugList.emoticons){t=this.plugList.emoticons.transEmoticonImageText(t)}return t}getContentOriginal(){return this.$textarea.value||""}getContentMarked(){return Ft(this.ctx,this.getContent())}initBottomPart(){this.initReply(),this.initSubmit()}initReply(){this.replyComment=null,this.$sendReply=null}setReply(t,e,i=!0){null!==this.replyComment&&this.cancelReply(),null===this.$sendReply&&(this.$sendReply=xt('<div class="atk-send-reply">回复 <span class="atk-text"></span><span class="atk-cancel" title="取消 AT">×</span></div>'),this.$sendReply.querySelector(".atk-text").innerText=`@${t.nick}`,this.$sendReply.addEventListener("click",(()=>{this.cancelReply()})),this.$textareaWrap.append(this.$sendReply)),this.replyComment=t,!0===this.ctx.conf.editorTravel&&this.travel(e),i&&qt(this.$el),this.$textarea.focus()}cancelReply(){null!==this.$sendReply&&(this.$sendReply.remove(),this.$sendReply=null),this.replyComment=null,!0===this.ctx.conf.editorTravel&&this.travelBack()}initSubmit(){this.$submitBtn.innerText=this.ctx.conf.sendBtn||"Send",this.$submitBtn.addEventListener("click",(t=>{t.currentTarget,this.submit()}))}submit(){return __async(this,null,(function*(){if(""!==this.getContent().trim()){this.ctx.trigger("editor-submit"),Ot(this.$el);try{const t=yield new jt(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,page_key:null===this.replyComment?this.ctx.conf.pageKey:this.replyComment.page_key,page_title:null===this.replyComment?this.ctx.conf.pageTitle:void 0,site_name:null===this.replyComment?this.ctx.conf.site:this.replyComment.site_name});null!==this.replyComment&&this.replyComment.page_key!==this.ctx.conf.pageKey&&window.open(`${this.replyComment.page_key}#atk-comment-${t.id}`),this.ctx.trigger("list-insert",t),this.clearEditor(),this.ctx.trigger("editor-submitted")}catch(t){return console.error(t),void this.showNotify(`评论失败,${t.msg||String(t)}`,"e")}finally{Bt(this.$el)}}else this.$textarea.focus()}))}showNotify(t,e){Mt(this.$notifyWrap,t,e)}close(){this.$textareaWrap.querySelector(".atk-comment-closed")||this.$textareaWrap.prepend(xt('<div class="atk-comment-closed">仅管理员可评论</div>')),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(){var t;null==(t=this.$textareaWrap.querySelector(".atk-comment-closed"))||t.remove(),this.$textarea.style.display="",this.$bottom.style.display=""}travel(t){if(this.isTraveling)return;this.isTraveling=!0,this.$el.after(xt('<div class="atk-editor-travel-placeholder"></div>'));const e=xt("<div></div>");t.after(e),e.replaceWith(this.$el)}travelBack(){var t;this.isTraveling&&(this.isTraveling=!1,null==(t=this.ctx.$root.querySelector(".atk-editor-travel-placeholder"))||t.replaceWith(this.$el),null!==this.replyComment&&this.cancelReply())}}var te=window||{},ee=navigator||{};function ie(t){var e=t||ee.userAgent,i=this,s={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};s.Mobile?s.Mobile=!(e.indexOf("iPad")>-1):te.showModalDialog&&te.chrome&&(s[360]=!0);var n,r={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 a in i.device="PC",i.language=((n=(ee.browserLanguage||ee.language).split("-"))[1]&&(n[1]=n[1].toUpperCase()),n.join("_")),r)for(var l=0;l<r[a].length;l++){var o=r[a][l];s[o]&&(i[a]=o)}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 h={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="",h[i.browser]&&(i.version=h[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 se(t){return new ie(t)}class ne{constructor(t){__publicField(this,"conf"),__publicField(this,"$el"),__publicField(this,"isLoading",!1),__publicField(this,"msgRecTimer"),__publicField(this,"msgRecTimerFunc"),__publicField(this,"isConfirming",!1),__publicField(this,"confirmRecTimer"),this.$el=xt('<span class="atk-common-action-btn"></span>'),this.conf="object"!=typeof t?{text:t}:t,this.$el.innerText=this.getText(),this.conf.adminOnly&&this.$el.setAttribute("atk-only-admin-show","")}get isMessaging(){return!!this.msgRecTimer}appendTo(t){return t.append(this.$el),this}getText(){return"string"==typeof this.conf.text?this.conf.text:this.conf.text()}setClick(t){this.$el.onclick=e=>{if(e.stopPropagation(),!this.isLoading){if(this.conf.confirm&&!this.isMessaging){const t=()=>{this.isConfirming=!1,this.$el.classList.remove("atk-btn-confirm"),this.$el.innerText=this.getText()};if(!this.isConfirming)return this.isConfirming=!0,this.$el.classList.add("atk-btn-confirm"),this.$el.innerText=this.conf.confirmText||"确认操作",void(this.confirmRecTimer=window.setTimeout((()=>t()),5e3));this.confirmRecTimer&&window.clearTimeout(this.confirmRecTimer),t()}if(this.msgRecTimer)return this.fireMsgRecTimer(),void this.clearMsgRecTimer();t()}}}updateText(t){t&&(this.conf.text=t),this.setLoading(!1),this.$el.innerText=this.getText()}setLoading(t,e){this.isLoading!==t&&(this.isLoading=t,t?(this.$el.classList.add("atk-btn-loading"),this.$el.innerText=e||"加载中..."):(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 re extends i{constructor(t,e){super(t),__publicField(this,"data"),__publicField(this,"$main"),__publicField(this,"$header"),__publicField(this,"$body"),__publicField(this,"$content"),__publicField(this,"$children"),__publicField(this,"$actions"),__publicField(this,"voteBtnUp"),__publicField(this,"voteBtnDown"),__publicField(this,"parent"),__publicField(this,"nestedNum"),__publicField(this,"maxNestingNum"),__publicField(this,"children",[]),__publicField(this,"replyTo"),__publicField(this,"$replyTo"),__publicField(this,"afterRender"),__publicField(this,"unread",!1),__publicField(this,"openable",!1),__publicField(this,"openURL"),__publicField(this,"openEvt"),__publicField(this,"onReplyBtnClick"),__publicField(this,"onDelete"),this.maxNestingNum=t.conf.maxNesting||3,this.data=__spreadValues({},e),this.data.date=this.data.date.replace(/-/g,"/"),this.parent=null,this.nestedNum=1}render(){return this.$el=xt('<div class="atk-comment-wrap">\n <div class="atk-comment">\n <div class="atk-avatar"></div>\n <div class="atk-main">\n <div class="atk-header">\n <span class="atk-item atk-nick"></span>\n <span class="atk-item atk-badge"></span>\n <span class="atk-item atk-date"></span>\n </div>\n <div class="atk-body">\n <div class="atk-content"></div>\n </div>\n <div class="atk-footer">\n <div class="atk-actions"></div>\n </div>\n </div>\n </div>\n</div>\n'),this.$main=this.$el.querySelector(".atk-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-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=xt("<img />");if(e.src=this.getGravatarUrl(),this.data.link){const i=xt('<a target="_blank" rel="noreferrer noopener nofollow"></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 e=xt('<a target="_blank" rel="noreferrer noopener nofollow"></a>');e.innerText=this.data.nick,e.href=this.data.link,t.append(e)}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 t=xt('<span class="atk-ua-wrap"></span>'),e=xt('<span class="atk-ua ua-browser"></span>'),i=xt('<span class="atk-ua ua-os"></span>');e.innerText=this.getUserUaBrowser(),i.innerText=this.getUserUaOS(),t.append(e),t.append(i),this.$header.append(t)}}renderContent(){if(!this.data.is_collapsed)return void(this.$content.innerHTML=this.getContentMarked());this.$content.classList.add("atk-hide","atk-type-collapsed");const t=xt('\n <div class="atk-collapsed">\n <span class="atk-text">该评论已被系统或管理员折叠</span>\n <span class="atk-show-btn">查看内容</span>\n </div>');this.$body.insertAdjacentElement("beforeend",t);const e=t.querySelector(".atk-show-btn");e.addEventListener("click",(t=>{t.stopPropagation(),this.$content.classList.contains("atk-hide")?(this.$content.innerHTML=this.getContentMarked(),this.$content.classList.remove("atk-hide"),Rt(this.$content),e.innerHTML="收起内容"):(this.$content.innerHTML="",this.$content.classList.add("atk-hide"),e.innerHTML="查看内容")}))}renderReplyTo(){if(!this.replyTo)return;this.$replyTo=xt('\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>'),this.$replyTo.querySelector(".atk-nick").innerText=`@${this.replyTo.nick}`;let t=Ft(this.ctx,this.replyTo.content);this.replyTo.is_collapsed&&(t="[已折叠]"),this.$replyTo.querySelector(".atk-content").innerHTML=t,this.$body.prepend(this.$replyTo)}renderPending(){if(!this.data.is_pending)return;const t=xt('<div class="atk-pending">审核中,仅本人可见。</div>');this.$body.prepend(t)}renderActionBtn(){if(this.ctx.conf.vote&&(this.voteBtnUp=new ne((()=>`赞同 (${this.data.vote_up||0})`)).appendTo(this.$actions),this.voteBtnUp.setClick((()=>{this.vote("up")})),this.ctx.conf.voteDown&&(this.voteBtnDown=new ne((()=>`反对 (${this.data.vote_down||0})`)).appendTo(this.$actions),this.voteBtnDown.setClick((()=>{this.vote("down")})))),this.data.is_allow_reply){const t=xt("<span>回复</span>");this.$actions.append(t),t.addEventListener("click",(t=>{t.stopPropagation(),this.onReplyBtnClick?this.onReplyBtnClick():this.ctx.trigger("editor-reply",{data:this.data,$el:this.$el})}))}const t=new ne({text:()=>this.data.is_collapsed?"取消折叠":"折叠",adminOnly:!0});t.appendTo(this.$actions),t.setClick((()=>{this.adminEdit("collapsed",t)}));const e=new ne({text:()=>this.data.is_pending?"待审":"已审",adminOnly:!0});e.appendTo(this.$actions),e.setClick((()=>{this.adminEdit("pending",e)}));const i=new ne({text:"删除",confirm:!0,confirmText:"确认删除",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,(t=>{var e;null==(e=t.parent)||e.getChildrenEl().appendChild(t.render()),t.playFadeInAnim()})),this.ctx.trigger("comments-loaded")}eachComment(t,e){0!==t.length&&t.every((i=>!1!==e(i,t)&&(this.eachComment(i.getChildren(),e),!0)))}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(),t.checkHeightLimitArea("content")}getChildrenEl(){return null===this.$children&&(this.nestedNum<this.maxNestingNum?(this.$children=xt('<div class="atk-comment-children"></div>'),this.$main.appendChild(this.$children)):this.parent&&(this.$children=this.parent.getChildrenEl())),this.$children}getParent(){return this.parent}getParents(){const t=[],e=i=>{i.parent&&(t.push(i.parent),e(i.parent))};return e(this),t}getEl(){return this.$el}getData(){return this.data}getGravatarUrl(){return Ct(this.ctx,this.data.email_encrypted)}getContentMarked(){return Ft(this.ctx,this.data.content)}getDateFormatted(){return Lt(new Date(this.data.date))}getUserUaBrowser(){const t=se(this.data.ua);return`${t.browser} ${t.version}`}getUserUaOS(){const t=se(this.data.ua);return`${t.os} ${t.osVersion}`}playFadeInAnim(){Rt(this.$el)}vote(t){const e="up"===t?this.voteBtnUp:this.voteBtnDown;new jt(this.ctx).vote(this.data.id,`comment_${t}`).then((t=>{var e,i;this.data.vote_up=t.up,this.data.vote_down=t.down,null==(e=this.voteBtnUp)||e.updateText(),null==(i=this.voteBtnDown)||i.updateText()})).catch((t=>{null==e||e.setError("投票失败"),console.log(t)}))}adminEdit(t,e){if(e.isLoading)return;e.setLoading(!0,"修改中...");const i=__spreadValues({},this.data);"collapsed"===t?i.is_collapsed=!i.is_collapsed:"pending"===t&&(i.is_pending=!i.is_pending),new jt(this.ctx).commentEdit(i).then((t=>{e.setLoading(!1),this.data=t,this.refreshUI(),Rt(this.$body),this.ctx.trigger("list-refresh-ui")})).catch((t=>{console.error(t),e.setError("修改失败")}))}adminDelete(t){t.isLoading||(t.setLoading(!0,"删除中..."),new jt(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("删除失败")})))}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")}checkHeightLimit(){this.checkHeightLimitArea("content"),this.checkHeightLimitArea("children")}checkHeightLimitArea(t){var e,i;const s=null==(e=this.ctx.conf.heightLimit)?void 0:e.children,n=null==(i=this.ctx.conf.heightLimit)?void 0:i.content;if("children"===t&&!s)return;if("content"===t&&!n)return;let r;"children"===t&&(r=s),"content"===t&&(r=n);const a=t=>{t&&_t(t)>r&&this.heightLimitAdd(t,r)};"children"===t?a(this.$children):"content"===t&&(a(this.$content),a(this.$replyTo),At(this.$content,(()=>{a(this.$content)})),this.$replyTo&&At(this.$replyTo,(()=>{a(this.$replyTo)})))}heightLimitRemove(t){t&&t.classList.contains("atk-height-limit")&&(t.classList.remove("atk-height-limit"),Array.from(t.children).forEach((t=>{t.classList.contains("atk-height-limit-btn")&&t.remove()})),t.style.height="",t.style.overflow="")}heightLimitAdd(t,e){if(!t)return;if(t.classList.contains("atk-height-limit"))return;t.classList.add("atk-height-limit"),t.style.height=`${e}px`,t.style.overflow="hidden";const i=xt('<div class="atk-height-limit-btn">阅读更多</span>');i.onclick=e=>{e.stopPropagation(),this.heightLimitRemove(t);const i=this.getChildren();1===i.length&&i[0].heightLimitRemove(i[0].$content)},t.append(i)}}class ae{constructor(t,e){__publicField(this,"conf"),__publicField(this,"total"),__publicField(this,"$el"),__publicField(this,"$input"),__publicField(this,"inputTimer"),__publicField(this,"$prevBtn"),__publicField(this,"$nextBtn"),__publicField(this,"page",1),this.total=t,this.conf=e,this.$el=xt('<div class="atk-pagination-wrap">\n <div class="atk-pagination">\n <div class="atk-btn atk-btn-prev">Prev</div>\n <input type="text" class="atk-input" />\n <div class="atk-btn atk-btn-next">Next</div>\n </div>\n </div>'),this.$input=this.$el.querySelector(".atk-input"),this.$input.value=`${this.page}`,this.$input.oninput=()=>this.input(),this.$input.onkeydown=t=>this.keydown(t),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()}get pageSize(){return this.conf.pageSize}get offset(){return this.pageSize*(this.page-1)}get maxPage(){return Math.ceil(this.total/this.pageSize)}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)return void this.setInput(this.page);let t=Number(e);Number.isNaN(t)||t<1?this.setInput(this.page):(t>this.maxPage&&(this.setInput(this.maxPage),t=this.maxPage),this.change(t))};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(38===e){const t=Number(this.$input.value)+1;if(t>this.maxPage)return;this.setInput(t),this.input()}else if(40===e){const t=Number(this.$input.value)-1;if(t<1)return;this.setInput(t),this.input()}else 13===e&&this.input(!0)}setLoading(t){t?Ot(this.$el):Bt(this.$el)}}class le{constructor(t){__publicField(this,"conf"),__publicField(this,"$el"),__publicField(this,"$loading"),__publicField(this,"$text"),__publicField(this,"offset",0),__publicField(this,"total",0),this.conf=t,this.$el=xt('<div class="atk-list-read-more" style="display: none;">\n <div class="atk-list-read-more-inner">\n <div class="atk-loading-icon" style="display: none;"></div>\n <span class="atk-text">加载更多</span>\n </div>\n </div>'),this.$loading=this.$el.querySelector(".atk-loading-icon"),this.$text=this.$el.querySelector(".atk-text"),this.$el.onclick=()=>{this.click()}}get hasMore(){return this.total>this.offset+this.conf.pageSize}click(){this.hasMore&&this.conf.onClick(this.offset+this.conf.pageSize),this.checkDisabled()}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="查看更多",this.$el.classList.remove("atk-err")}),2e3)}update(t,e){this.offset=t,this.total=e,this.checkDisabled()}checkDisabled(){this.hasMore?this.show():this.hide()}}class oe extends i{constructor(t){super(t),__publicField(this,"$commentsWrap"),__publicField(this,"comments",[]),__publicField(this,"data"),__publicField(this,"isLoading",!1),__publicField(this,"noCommentText","无内容"),__publicField(this,"flatMode",!1),__publicField(this,"pageMode","pagination"),__publicField(this,"pageSize",20),__publicField(this,"scrollListenerAt"),__publicField(this,"repositionAt"),__publicField(this,"pagination"),__publicField(this,"readMoreBtn"),__publicField(this,"autoLoadScrollEvent"),__publicField(this,"renderComment"),__publicField(this,"paramsEditor"),__publicField(this,"onAfterLoad"),__publicField(this,"unread",[]),__publicField(this,"unreadHighlight"),this.$el=xt('<div class="atk-list-lite">\n <div class="atk-list-comments-wrap"></div>\n </div>'),this.$commentsWrap=this.$el.querySelector(".atk-list-comments-wrap"),window.setInterval((()=>{this.$el.querySelectorAll("[data-atk-comment-date]").forEach((t=>{const e=t.getAttribute("data-atk-comment-date");t.innerText=Lt(new Date(Number(e)))}))}),3e4),this.ctx.on("unread-update",(t=>this.updateUnread(t.notifies)))}fetchComments(t){return __async(this,null,(function*(){if(this.isLoading)return;const e=()=>{this.isLoading=!1,0===t?Bt(this.$el):"read-more"===this.pageMode?this.readMoreBtn.setLoading(!1):"pagination"===this.pageMode&&this.pagination.setLoading(!1)};let i;(()=>{this.isLoading=!0,0===t?Ot(this.$el):"read-more"===this.pageMode?this.readMoreBtn.setLoading(!0):"pagination"===this.pageMode&&this.pagination.setLoading(!0)})(),this.ctx.trigger("comments-load"),"read-more"===this.pageMode&&0===t&&this.clearAllComments();try{i=yield new jt(this.ctx).get(t,this.pageSize,this.flatMode,this.paramsEditor)}catch(s){throw this.onError(s.msg||String(s),t),s}finally{e()}It(this.$el,null);try{this.onLoad(i,t)}catch(s){throw this.onError(String(s),t),s}finally{e()}}))}onLoad(t,e){"pagination"===this.pageMode&&this.clearAllComments(),this.data=t,this.ctx.conf.versionCheck&&this.versionCheck(t.api_version)||(this.importComments(t.comments),this.refreshPagination(e,this.flatMode?t.total:t.total_roots),this.refreshUI(),this.ctx.trigger("unread-update",{notifies:t.unread||[]}),this.ctx.trigger("comments-loaded"),this.onAfterLoad&&this.onAfterLoad(t))}refreshPagination(t,e){const i="pagination"===this.pageMode,s="read-more"===this.pageMode;(i?!!this.pagination:!!this.readMoreBtn)||this.initPagination(),i&&this.pagination.update(t,e),s&&this.readMoreBtn.update(t,e)}initPagination(){var t;if("read-more"===this.pageMode&&(this.readMoreBtn=new le({pageSize:this.pageSize,onClick:t=>__async(this,null,(function*(){yield this.fetchComments(t)}))}),this.$el.append(this.readMoreBtn.$el),null==(t=this.conf.pagination)?void 0:t.autoLoad)){const t=this.scrollListenerAt||document;this.autoLoadScrollEvent&&t.removeEventListener("scroll",this.autoLoadScrollEvent),this.autoLoadScrollEvent=()=>{if("read-more"!==this.pageMode)return;if(!this.readMoreBtn)return;if(!this.readMoreBtn.hasMore)return;if(this.isLoading)return;const t=this.$el.querySelector(".atk-list-comments-wrap > .atk-comment-wrap:nth-last-child(3)");t&&function(t,e=document.documentElement){const i=e.clientHeight,s=e.scrollTop,n=s+i,r=t.getBoundingClientRect();return r.top+s+r.height<=n}(t,this.scrollListenerAt)&&this.readMoreBtn.click()},t.addEventListener("scroll",this.autoLoadScrollEvent)}"pagination"===this.pageMode&&(this.pagination=new ae(this.flatMode?this.data.total:this.data.total_roots,{pageSize:this.pageSize,onChange:t=>__async(this,null,(function*(){if(!0===this.ctx.conf.editorTravel&&this.ctx.trigger("editor-travel-back"),yield this.fetchComments(t),this.repositionAt){(this.scrollListenerAt||window).scroll({top:this.repositionAt?St(this.repositionAt).top:0,left:0})}}))}),this.$el.append(this.pagination.$el))}onError(t,e){var i;if(t=String(t),console.error(t),0!==e&&"read-more"===this.pageMode)return void(null==(i=this.readMoreBtn)||i.showErr("获取失败"));const s=xt(`<span>${t},无法获取评论列表数据<br/></span>`),n=xt('<span style="cursor:pointer;">点击重新获取</span>');n.onclick=()=>this.fetchComments(0),s.appendChild(n);const r=xt('<span atk-only-admin-show> | <span style="cursor:pointer;">打开控制台</span></span>');r.onclick=()=>this.ctx.trigger("sidebar-show"),this.ctx.user.data.isAdmin||r.classList.add("atk-hide"),s.appendChild(r),It(this.$el,s)}refreshUI(){const t=this.comments.length<=0;let e=this.$commentsWrap.querySelector(".atk-list-no-comment");t?e||(e=xt('<div class="atk-list-no-comment"></div>'),e.innerHTML=this.noCommentText,this.$commentsWrap.appendChild(e)):null==e||e.remove(),this.ctx.trigger("check-admin-show-el")}createComment(t){const e=new re(this.ctx,t);return e.afterRender=()=>{this.renderComment&&this.renderComment(e)},e.onDelete=t=>{this.deleteComment(t),this.refreshUI()},e}importComments(t){this.flatMode?t.forEach((e=>{this.putCommentFlatMode(e,t,"append")})):this.importCommentsNesting(t)}importCommentsNesting(t){const e=i=>{t.filter((t=>t.rid===i.data.id)).forEach((t=>{const s=this.createComment(t);s.render(),i.putChild(s),e(s)}))};t.filter((t=>0===t.rid)).forEach((t=>{const i=this.createComment(t);i.render(),this.$commentsWrap.appendChild(i.getEl()),i.playFadeInAnim(),this.comments.push(i),e(i),i.checkHeightLimit()}))}putCommentFlatMode(t,e,i){t.is_collapsed&&(t.is_allow_reply=!1);const s=this.createComment(t);if(0!==t.rid){const i=e.find((e=>e.id===t.rid));i&&(s.replyTo=i)}return s.render(),"append"===i&&this.comments.push(s),"prepend"===i&&this.comments.unshift(s),t.visible&&("append"===i&&this.$commentsWrap.append(s.getEl()),"prepend"===i&&this.$commentsWrap.prepend(s.getEl()),s.playFadeInAnim()),s.checkHeightLimit(),s}insertComment(t){if(this.flatMode){qt(this.putCommentFlatMode(t,this.comments.map((t=>t.data)),"prepend").getEl())}else{const e=this.createComment(t);if(e.render(),0===t.rid)this.$commentsWrap.prepend(e.getEl()),this.comments.unshift(e);else{const i=this.findComment(t.rid);i&&(i.putChild(e),e.getParents().forEach((t=>{t.$children&&t.heightLimitRemove(t.$children)})))}e.checkHeightLimit(),qt(e.getEl()),e.playFadeInAnim()}this.data&&(this.data.total+=1),this.refreshUI(),this.ctx.trigger("comments-loaded")}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}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))),this.data&&(this.data.total-=1),this.refreshUI()}clearAllComments(){this.$commentsWrap.innerHTML="",this.data=void 0,this.comments=[]}updateUnread(t){this.unread=t,!0===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.trigger("unread-update",{notifies:this.unread})}):t.setUnread(!1)}))}versionCheck(t){const e=(null==t?void 0:t.fe_min_version)||"0.0.0",i=1===function(t,e){const i=t.split("."),s=e.split(".");for(let n=0;n<3;n++){const t=Number(i[n]),e=Number(s[n]);if(t>e)return 1;if(e>t)return-1;if(!Number.isNaN(t)&&Number.isNaN(e))return 1;if(Number.isNaN(t)&&!Number.isNaN(e))return-1}return 0}(e,"2.1.4");if(i){const t=xt(`<div>前端 Artalk 版本已过时,请更新以获得完整体验<br/>若您是站点管理员,请前往 “<a href="https://artalk.js.org/" target="_blank">官方文档</a>” 获取帮助<br/><br/><span style="color: var(--at-color-meta);">前端版本 2.1.4,需求版本 >= ${e}</span><br/><br/></div>`),i=xt('<span style="cursor:pointer;">忽略</span>');i.onclick=()=>{It(this.ctx,null),this.ctx.conf.versionCheck=!1,this.fetchComments(0)},t.append(i),It(this.ctx,t,'<span class="atk-warn-title">Artalk Warn</span>')}return i}}class ce extends oe{constructor(t){var e,i;const s=xt('<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-sidebar" class="atk-hide atk-on">\n <span class="atk-unread-badge" style="display: none;"></span>\n <div class="atk-text">通知中心</div>\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');super(t),__publicField(this,"$closeCommentBtn"),__publicField(this,"$openSidebarBtn"),__publicField(this,"$unreadBadge"),s.querySelector(".atk-list-body").append(this.$el),this.$el=s;let n=!1;"auto"===this.ctx.conf.flatMode?window.matchMedia("(max-width: 768px)").matches&&(n=!0):!0===this.ctx.conf.flatMode&&(n=!0),this.flatMode=n,this.pageMode=(null==(e=this.conf.pagination)?void 0:e.readMore)?"read-more":"pagination",this.pageSize=(null==(i=this.conf.pagination)?void 0:i.pageSize)||20,this.repositionAt=this.$el,this.initListActionBtn(),this.$el.querySelector(".atk-copyright").innerHTML='Powered By <a href="https://artalk.js.org" target="_blank" title="Artalk v2.1.4">Artalk</a>',this.ctx.on("list-reload",(()=>this.fetchComments(0))),this.ctx.on("list-refresh-ui",(()=>this.refreshUI())),this.ctx.on("list-import",(t=>this.importComments(t))),this.ctx.on("list-insert",(t=>this.insertComment(t))),this.ctx.on("list-delete",(t=>this.deleteComment(t.id))),this.ctx.on("list-update",(t=>{t(this.data),this.refreshUI()})),this.ctx.on("unread-update",(t=>{var e;return this.showUnreadBadge((null==(e=t.notifies)?void 0:e.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(){var t;super.refreshUI(),this.$el.querySelector(".atk-comment-count-num").innerText=String(Number(null==(t=this.data)?void 0:t.total)||0),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.querySelector(".atk-text").innerText=this.ctx.user.data.isAdmin?"控制中心":"通知中心",this.data&&this.data.page&&!0===this.data.page.admin_only?(this.ctx.trigger("editor-close"),this.$closeCommentBtn.innerHTML="打开评论"):(this.ctx.trigger("editor-open"),this.$closeCommentBtn.innerHTML="关闭评论")}onLoad(t,e){super.onLoad(t,e),this.checkGoToCommentByUrlHash()}checkGoToCommentByUrlHash(){return __async(this,null,(function*(){let t=Number(wt("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=wt("atk_notify_key");e&&new jt(this.ctx).markRead(e).then((()=>{this.unread=this.unread.filter((e=>e.comment_id!==t)),this.ctx.trigger("unread-update",{notifies:this.unread})}));const i=this.findComment(t);i&&(qt(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 jt(this.ctx).pageEdit(this.data.page).then((t=>{this.data&&(this.data.page=__spreadValues({},t)),this.refreshUI()})).catch((t=>{this.ctx.trigger("editor-notify",{msg:`修改页面数据失败:${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 he=function(t){var e=function(t){for(var e,i="0123456789ABCDEF",s="",n=0;n<t.length;n++)e=t.charCodeAt(n),s+=i.charAt(e>>>4&15)+i.charAt(15&e);return s}(function(t){for(var e="",i=0;i<32*t.length;i+=8)e+=String.fromCharCode(t[i>>5]>>>i%32&255);return e}(function(t,e){t[e>>5]|=128<<e%32,t[14+(e+64>>>9<<4)]=e;for(var i=1732584193,s=-271733879,n=-1732584194,r=271733878,a=0;a<t.length;a+=16){var l=i,o=s,c=n,h=r;s=ge(s=ge(s=ge(s=ge(s=me(s=me(s=me(s=me(s=pe(s=pe(s=pe(s=pe(s=ue(s=ue(s=ue(s=ue(s,n=ue(n,r=ue(r,i=ue(i,s,n,r,t[a+0],7,-680876936),s,n,t[a+1],12,-389564586),i,s,t[a+2],17,606105819),r,i,t[a+3],22,-1044525330),n=ue(n,r=ue(r,i=ue(i,s,n,r,t[a+4],7,-176418897),s,n,t[a+5],12,1200080426),i,s,t[a+6],17,-1473231341),r,i,t[a+7],22,-45705983),n=ue(n,r=ue(r,i=ue(i,s,n,r,t[a+8],7,1770035416),s,n,t[a+9],12,-1958414417),i,s,t[a+10],17,-42063),r,i,t[a+11],22,-1990404162),n=ue(n,r=ue(r,i=ue(i,s,n,r,t[a+12],7,1804603682),s,n,t[a+13],12,-40341101),i,s,t[a+14],17,-1502002290),r,i,t[a+15],22,1236535329),n=pe(n,r=pe(r,i=pe(i,s,n,r,t[a+1],5,-165796510),s,n,t[a+6],9,-1069501632),i,s,t[a+11],14,643717713),r,i,t[a+0],20,-373897302),n=pe(n,r=pe(r,i=pe(i,s,n,r,t[a+5],5,-701558691),s,n,t[a+10],9,38016083),i,s,t[a+15],14,-660478335),r,i,t[a+4],20,-405537848),n=pe(n,r=pe(r,i=pe(i,s,n,r,t[a+9],5,568446438),s,n,t[a+14],9,-1019803690),i,s,t[a+3],14,-187363961),r,i,t[a+8],20,1163531501),n=pe(n,r=pe(r,i=pe(i,s,n,r,t[a+13],5,-1444681467),s,n,t[a+2],9,-51403784),i,s,t[a+7],14,1735328473),r,i,t[a+12],20,-1926607734),n=me(n,r=me(r,i=me(i,s,n,r,t[a+5],4,-378558),s,n,t[a+8],11,-2022574463),i,s,t[a+11],16,1839030562),r,i,t[a+14],23,-35309556),n=me(n,r=me(r,i=me(i,s,n,r,t[a+1],4,-1530992060),s,n,t[a+4],11,1272893353),i,s,t[a+7],16,-155497632),r,i,t[a+10],23,-1094730640),n=me(n,r=me(r,i=me(i,s,n,r,t[a+13],4,681279174),s,n,t[a+0],11,-358537222),i,s,t[a+3],16,-722521979),r,i,t[a+6],23,76029189),n=me(n,r=me(r,i=me(i,s,n,r,t[a+9],4,-640364487),s,n,t[a+12],11,-421815835),i,s,t[a+15],16,530742520),r,i,t[a+2],23,-995338651),n=ge(n,r=ge(r,i=ge(i,s,n,r,t[a+0],6,-198630844),s,n,t[a+7],10,1126891415),i,s,t[a+14],15,-1416354905),r,i,t[a+5],21,-57434055),n=ge(n,r=ge(r,i=ge(i,s,n,r,t[a+12],6,1700485571),s,n,t[a+3],10,-1894986606),i,s,t[a+10],15,-1051523),r,i,t[a+1],21,-2054922799),n=ge(n,r=ge(r,i=ge(i,s,n,r,t[a+8],6,1873313359),s,n,t[a+15],10,-30611744),i,s,t[a+6],15,-1560198380),r,i,t[a+13],21,1309151649),n=ge(n,r=ge(r,i=ge(i,s,n,r,t[a+4],6,-145523070),s,n,t[a+11],10,-1120210379),i,s,t[a+2],15,718787259),r,i,t[a+9],21,-343485551),i=fe(i,l),s=fe(s,o),n=fe(n,c),r=fe(r,h)}return Array(i,s,n,r)}(function(t){for(var e=Array(t.length>>2),i=0;i<e.length;i++)e[i]=0;for(i=0;i<8*t.length;i+=8)e[i>>5]|=(255&t.charCodeAt(i/8))<<i%32;return e}(t),8*t.length)));return e.toLowerCase()};function de(t,e,i,s,n,r){return fe(function(t,e){return t<<e|t>>>32-e}(fe(fe(e,t),fe(s,r)),n),i)}function ue(t,e,i,s,n,r,a){return de(e&i|~e&s,t,e,n,r,a)}function pe(t,e,i,s,n,r,a){return de(e&s|i&~s,t,e,n,r,a)}function me(t,e,i,s,n,r,a){return de(e^i^s,t,e,n,r,a)}function ge(t,e,i,s,n,r,a){return de(i^(e|~s),t,e,n,r,a)}function fe(t,e){var i=(65535&t)+(65535&e);return(t>>16)+(e>>16)+(i>>16)<<16|65535&i}class ke extends i{constructor(t,e){super(t),__publicField(this,"viewTabs",{}),__publicField(this,"viewActiveTab",""),__publicField(this,"$parent"),this.$parent=e,this.$el=xt('<div class="atk-sidebar-view"></div>')}mount(t){}switchTab(t,e){}}__publicField(ke,"viewName",""),__publicField(ke,"viewTitle",""),__publicField(ke,"viewAdminOnly",!1);class be extends ke{constructor(){super(...arguments),__publicField(this,"viewTabs",{}),__publicField(this,"viewActiveTab",""),__publicField(this,"list")}mount(t){this.ctx.user.data.isAdmin?(this.viewTabs={admin_all:"全部",admin_pending:"待审",all:"个人"},this.viewActiveTab="admin_all"):(this.viewTabs={mentions:"提及",all:"全部",mine:"我的",pending:"待审"},this.viewActiveTab="mentions"),this.list=new oe(this.ctx),this.list.flatMode=!0,this.list.unreadHighlight=!0,this.list.scrollListenerAt=this.$parent,this.list.pageMode="pagination",this.list.noCommentText='<div class="atk-sidebar-no-content">无内容</div>',this.list.renderComment=t=>{t.setOpenURL(`${t.data.page_key}#atk-comment-${t.data.id}`),t.onReplyBtnClick=()=>{!0===this.ctx.conf.editorTravel?this.ctx.trigger("editor-reply",{data:t.data,$el:t.$el,scroll:!1}):(this.ctx.trigger("sidebar-hide"),this.ctx.trigger("editor-reply",{data:t.data,$el:t.$el,scroll:!0}))}},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.paramsEditor=i=>{i.type=t,i.site_name=e},this.list.fetchComments(0),!0}}__publicField(be,"viewName","comments"),__publicField(be,"viewTitle","评论");class ye{constructor(t){__publicField(this,"conf"),__publicField(this,"$el"),__publicField(this,"$input"),__publicField(this,"$yesBtn"),__publicField(this,"$noBtn"),__publicField(this,"value",""),__publicField(this,"allowSubmit",!0),this.conf=t,this.$el=xt('<div class="atk-item-text-editor-layer">\n <div class="atk-edit-form">\n <input class="atk-main-input" type="text" placeholder="输入内容..." autocomplete="off" autofocus>\n </div>\n <div class="atk-actions">\n <div class="atk-item atk-yes-btn">\n <i class="atk-icon atk-icon-yes"></i>\n </div>\n <div class="atk-item atk-no-btn">\n <i class="atk-icon atk-icon-no"></i>\n </div>\n </div>\n </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=t=>{"Enter"!==t.key&&13!==t.keyCode||(t.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"))}submit(){return __async(this,null,(function*(){if(this.allowSubmit)if(this.conf.onYes){let t;t=this.conf.onYes instanceof(()=>__async(this,null,(function*(){}))).constructor?yield this.conf.onYes(this.value):this.conf.onYes(this.value),void 0!==t&&!0!==t||this.closeEditor()}else this.closeEditor()}))}cancel(){return __async(this,null,(function*(){if(this.conf.onNo){let t;t=this.conf.onNo instanceof(()=>__async(this,null,(function*(){}))).constructor?yield this.conf.onNo():this.conf.onNo(),void 0!==t&&!0!==t||this.closeEditor()}else this.closeEditor()}))}closeEditor(){this.$el.remove()}}class $e extends i{constructor(t){super(t),__publicField(this,"$editor"),__publicField(this,"$inputer"),__publicField(this,"pages",[]),this.$el=xt('<div class="atk-page-list"></div>')}clearAll(){this.pages=[],this.$el.innerHTML=""}importPages(t){this.pages.push(...t),t.forEach((t=>{const e=this.renderPage(t);this.$el.append(e)}))}renderPage(t){const e=xt('<div class="atk-page-item">\n <div class="atk-page-main">\n <div class="atk-title"></div>\n <div class="atk-sub"></div>\n </div>\n <div class="atk-page-actions">\n <div class="atk-item atk-edit-btn">\n <i class="atk-icon atk-icon-edit"></i>\n </div>\n </div>\n </div>'),i=e.querySelector(".atk-page-main"),s=i.querySelector(".atk-title"),n=i.querySelector(".atk-sub"),r=e.querySelector(".atk-edit-btn");return s.innerText=t.title,n.innerText=t.url||t.key,r.onclick=()=>this.showEditor(t,e),e}showEditor(t,e){this.closeEditor(),this.$editor=xt('<div class="atk-page-edit-layer">\n <div class="atk-page-main-actions">\n <div class="atk-item atk-title-edit-btn">标题修改</div>\n <div class="atk-item atk-key-edit-btn">KEY 变更</div>\n <div class="atk-item atk-admin-only-btn"></div>\n </div>\n <div class="atk-page-actions">\n <div class="atk-item atk-sync-btn">\n <i class="atk-icon atk-icon-sync"></i>\n </div>\n <div class="atk-item atk-del-btn">\n <i class="atk-icon atk-icon-del"></i>\n </div>\n <div class="atk-item atk-close-btn">\n <i class="atk-icon atk-icon-close"></i>\n </div>\n </div>\n </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"),r=this.$editor.querySelector(".atk-sync-btn"),a=this.$editor.querySelector(".atk-del-btn"),l=this.$editor.querySelector(".atk-close-btn"),o=()=>{Ot(this.$editor)},c=()=>{Bt(this.$editor)},h=t=>{window.alert(t)};l.onclick=()=>this.closeEditor();const d=i=>{const s=new ye({initValue:t[i]||"",onYes:n=>__async(this,null,(function*(){let r;Ot(s.$el);try{r=yield new jt(this.ctx).pageEdit(__spreadProps(__spreadValues({},t),{[i]:n}))}catch(a){return h(`修改失败:${a.msg||"未知错误"}`),console.error(a),!1}finally{Bt(s.$el)}return e.replaceWith(this.renderPage(r)),!0}))});s.appendTo(this.$editor)};i.onclick=()=>d("title"),s.onclick=()=>d("key");const u=new ne({text:()=>(n.classList.remove("atk-green","atk-yellow"),n.classList.add(t.admin_only?"atk-yellow":"atk-green"),t.admin_only?"管理员可评":"所有人可评")}).appendTo(n);n.onclick=()=>__async(this,null,(function*(){let e;o();try{e=yield new jt(this.ctx).pageEdit(__spreadProps(__spreadValues({},t),{admin_only:!t.admin_only}))}catch(i){return h(`修改失败:${i.msg||"未知错误"}`),void console.log(i)}finally{c()}t.admin_only=e.admin_only,u.updateText()})),r.onclick=()=>__async(this,null,(function*(){let i;o();try{i=yield new jt(this.ctx).pageFetch(t.id)}catch(s){return h(`同步失败:${s.msg||"未知错误"}`),void console.log(s)}finally{c()}e.replaceWith(this.renderPage(i))})),a.onclick=()=>{window.confirm(`确认删除页面 "${t.title||t.key}"?将会删除所有相关数据`)&&(()=>{__async(this,null,(function*(){o();try{yield new jt(this.ctx).pageDel(t.key,t.site_name)}catch(i){return console.log(i),void h(`删除失败 ${String(i)}`)}finally{c()}e.remove()}))})()}}closeEditor(){this.$editor&&this.$editor.remove()}}class ve extends ke{constructor(){super(...arguments),__publicField(this,"viewTabs",{}),__publicField(this,"viewActiveTab",""),__publicField(this,"pageList"),__publicField(this,"pagination")}mount(t){this.pageList||(this.pageList=new $e(this.ctx),this.$el.append(this.pageList.$el)),this.switchTab(this.viewActiveTab,t)}switchTab(t,e){this.reqPages(e,0)}reqPages(t,e){return __async(this,null,(function*(){var i;this.pageList.clearAll(),null==(i=this.$el.parentNode)||i.scrollTo(0,0),Ot(this.$el);const s=yield new jt(this.ctx).pageGet(t,e,20);this.pageList.importPages(s.pages||[]),Bt(this.$el),this.pagination||(this.pagination=new ae(s.total,{pageSize:20,onChange:e=>{this.reqPages(t,e)}}),this.$el.append(this.pagination.$el)),this.pagination&&0===e&&this.pagination.update(e,s.total)}))}}__publicField(ve,"viewName","pages"),__publicField(ve,"viewTitle","页面"),__publicField(ve,"viewAdminOnly",!0);class xe extends i{constructor(t){super(t),__publicField(this,"sites",[]),__publicField(this,"$header"),__publicField(this,"$headerTitle"),__publicField(this,"$headerActions"),__publicField(this,"$rowsWrap"),__publicField(this,"$editor"),__publicField(this,"activeSite",""),__publicField(this,"$add"),this.$el=xt('<div class="atk-site-list">\n <div class="atk-header">\n <div class="atk-title"></div>\n <div class="atk-actions">\n <div class="atk-item atk-site-add-btn"><i class="atk-icon atk-icon-plus"></i></div>\n </div>\n </div>\n <div class="atk-site-rows-wrap"></div>\n </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="共 0 个站点";this.$headerActions.querySelector(".atk-site-add-btn").onclick=()=>{this.closeEditor(),this.showAdd()}}loadSites(t){let e;this.sites=t,this.activeSite="",this.$rowsWrap.innerHTML="",this.$headerTitle.innerText="共 0 个站点";for(let i=0;i<t.length;i++){const s=t[i];i%4==0&&(e=xt('<div class="atk-site-row">'),this.$rowsWrap.append(e));const n=this.renderSite(s,e);e.append(n)}this.$headerTitle.innerText=`共 ${t.length} 个站点`}renderSite(t,e){const i=xt('<div class="atk-site-item">\n <div class="atk-site-logo"></div>\n <div class="atk-site-name"></div>\n </div>'),s=i.querySelector(".atk-site-logo"),n=i.querySelector(".atk-site-name"),r=()=>{i.classList.add("atk-active")};return s.innerText=t.name.substr(0,1),n.innerText=t.name,i.onclick=()=>{this.closeEditor(),this.closeAdd(),r(),this.showEditor(t,i,e)},this.activeSite===t.name&&r(),i}showEditor(t,e,i){this.activeSite=t.name,this.$editor=xt('\n <div class="atk-site-edit">\n <div class="atk-header">\n <div class="atk-site-info">\n <span class="atk-site-name"></span>\n <span class="atk-site-urls"></span>\n </div>\n <div class="atk-close-btn">\n <i class="atk-icon atk-icon-close"></i>\n </div>\n </div>\n <div class="atk-main">\n <div class="atk-site-text-actions">\n <div class="atk-item atk-rename-btn">重命名</div>\n <div class="atk-item atk-edit-url-btn">修改 URL</div>\n \x3c!--<div class="atk-item atk-export-btn">导出</div>\n <div class="atk-item atk-import-btn">导入</div>--\x3e\n </div>\n <div class="atk-site-btn-actions">\n <div class="atk-item atk-del-btn">\n <i class="atk-icon atk-icon-del"></i>\n </div>\n </div>\n </div>\n </div>'),i.before(this.$editor);const s=this.$editor.querySelector(".atk-site-name"),n=this.$editor.querySelector(".atk-site-urls");this.$editor.querySelector(".atk-close-btn").onclick=()=>this.closeEditor();const r=e=>{var i;t=e,s.innerText=t.name,s.onclick=()=>{t.first_url&&window.open(t.first_url)},n.innerHTML="",null==(i=t.urls)||i.forEach((t=>{const e=xt('<span class="atk-url-item"></span>');n.append(e),e.innerText=(t||"").replace(/\/$/,""),e.onclick=()=>{window.open(t)}}))};r(t);const a=this.$editor.querySelector(".atk-main"),l=this.$editor.querySelector(".atk-site-text-actions"),o=l.querySelector(".atk-rename-btn"),c=l.querySelector(".atk-edit-url-btn"),h=this.$editor.querySelector(".atk-del-btn"),d=()=>{Ot(this.$editor)},u=()=>{Bt(this.$editor)},p=t=>{window.alert(t)},m=s=>{let n=t[s]||"";"urls"===s&&(n=t.urls_raw||"");const l=new ye({initValue:n,onYes:n=>__async(this,null,(function*(){let a;Ot(l.$el);try{a=yield new jt(this.ctx).siteEdit(__spreadProps(__spreadValues({},t),{[s]:n}))}catch(o){return p(`修改失败:${o.msg||"未知错误"}`),console.error(o),!1}finally{Bt(l.$el)}return e.replaceWith(this.renderSite(a,i)),r(a),!0}))});l.appendTo(a)};o.onclick=()=>m("name"),c.onclick=()=>m("urls"),h.onclick=()=>{window.confirm(`确认删除站点 "${t.name}"?将会删除所有相关数据`)&&(()=>{__async(this,null,(function*(){d();try{yield new jt(this.ctx).siteDel(t.id,!0)}catch(i){return console.log(i),void p(`删除失败 ${String(i)}`)}finally{u()}this.closeEditor(),e.remove(),this.sites=this.sites.filter((e=>e.name!==t.name))}))})()}}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=xt('\n <div class="atk-site-add">\n <div class="atk-header">\n <div class="atk-title">新增站点</div>\n <div class="atk-close-btn">\n <i class="atk-icon atk-icon-close"></i>\n </div>\n </div>\n <div class="atk-form">\n <input type="text" name="AtkSiteName" placeholder="站点名称" autocomplete="off">\n <input type="text" name="AtkSiteUrls" placeholder="站点 URL(多个用逗号隔开)" autocomplete="off">\n <button class="atk-btn" name="AtkSubmit">创建</button>\n </div>\n </div>'),this.$header.after(this.$add);this.$add.querySelector(".atk-close-btn").onclick=()=>this.closeAdd();const t=this.$add.querySelector('[name="AtkSiteName"]'),e=this.$add.querySelector('[name="AtkSiteUrls"]'),i=this.$add.querySelector('[name="AtkSubmit"]');i.onclick=()=>__async(this,null,(function*(){const i=t.value.trim(),s=e.value.trim();if(""===i)return void t.focus();let n;Ot(this.$add);try{n=yield new jt(this.ctx).siteAdd(i,s)}catch(r){return window.alert(`创建失败:${r.msg||""}`),void console.error(r)}finally{Bt(this.$add)}this.sites.push(n),this.loadSites(this.sites),this.closeAdd()}));const s=t=>{"Enter"===t.key&&i.click()};t.onkeyup=t=>s(t),e.onkeyup=t=>s(t)}closeAdd(){var t;null==(t=this.$add)||t.remove()}}class _e extends ke{constructor(){super(...arguments),__publicField(this,"viewTabs",{}),__publicField(this,"viewActiveTab",""),__publicField(this,"siteList")}mount(t){this.siteList||(this.siteList=new xe(this.ctx),this.$el.append(this.siteList.$el)),this.reqSites()}switchTab(t,e){this.reqSites()}reqSites(){return __async(this,null,(function*(){const t=yield new jt(this.ctx).siteGet();this.siteList.loadSites(t)}))}}__publicField(_e,"viewName","sites"),__publicField(_e,"viewTitle","站点"),__publicField(_e,"viewAdminOnly",!0);class we extends ke{constructor(){super(...arguments),__publicField(this,"ß"),__publicField(this,"viewTabs",{import:"导入",export:"导出"}),__publicField(this,"viewActiveTab","import")}mount(t){this.switchTab("import",t)}switchTab(t,e){if("import"===t)this.initImport();else if("export"===t)return this.initExport(),!1;return!0}initImport(){this.$el.innerHTML='<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-form">\n <div class="atk-label">数据类型</div>\n <select name="AtkDataType">\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 <div class="atk-label atk-data-file-label">数据文件</div>\n <input type="file" name="AtkDataFile" accept="text/plain,.json">\n <div class="atk-label">目标站点名</div>\n <input type="text" name="AtkSiteName" placeholder="输入内容..." autocomplete="off">\n <div class="atk-label">目标站点 URL</div>\n <input type="text" name="AtkSiteURL" placeholder="输入内容..." autocomplete="off">\n <div class="atk-label">启动参数(可选)</div>\n <textarea name="AtkPayload"></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="AtkSubmit">导入</button>\n </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"]'),r=t.querySelector('[name="AtkSiteURL"]'),a=t.querySelector('[name="AtkPayload"]'),l=t.querySelector('[name="AtkSubmit"]'),o=t=>window.alert(t);e.onchange=()=>{["typecho"].includes(e.value)?(i.style.display="none",s.style.display="none"):(i.style.display="",s.style.display="")},l.onclick=()=>{var s;const l=e.value.trim(),c=n.value.trim(),h=r.value.trim(),d=a.value.trim();if(""===l)return void o("请选择数据类型");let u={};if(d){try{u=JSON.parse(d)}catch(g){return void o(`Payload JSON 格式有误:${String(g)}`)}if(u instanceof Object)return void o("Payload 需为 JSON 对象")}c&&(u.t_name=c),h&&(u.t_url=h);const p=e=>{const i=this.$el.querySelector(".atk-log-wrap"),s=i.querySelector(".atk-log"),n=this.$el.querySelector(".atk-log-back-btn");i.style.display="",t.style.display="none",n.onclick=()=>{i.style.display="none",t.style.display=""},e&&(u.json_data=e);const r="f_"+ +new Date,a=document.createElement("iframe");a.className="atk-iframe",a.name=r,s.innerHTML="",s.append(a);const o={type:l,payload:JSON.stringify(u),token:this.ctx.user.data.token||""},c=document.createElement("form");c.style.display="none",c.setAttribute("method","post"),c.setAttribute("action",`${this.ctx.conf.server}/admin/import`),c.setAttribute("target",r),Object.entries(o).forEach((([t,e])=>{const i=document.createElement("input");i.setAttribute("type","hidden"),i.setAttribute("name",t),i.value=e,c.appendChild(i)})),i.append(c),c.submit(),c.remove()},m=new FileReader;m.onload=()=>{const t=String(m.result);p(t)},(null==(s=i.files)?void 0:s.length)?m.readAsText(i.files[0]):p()}}initExport(){return __async(this,null,(function*(){Ot(this.$el);try{const t=yield new jt(this.ctx).export();this.download(`artrans-${this.getYmdHisFilename()}.json`,t)}catch(t){return console.log(t),void window.alert(`${String(t)}`)}finally{Bt(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(),r=t.getMinutes(),a=t.getSeconds();return`${e}${i}${s}-${n}${Tt(r,2)}${Tt(a,2)}`}}__publicField(we,"viewName","transfer"),__publicField(we,"viewTitle","迁移"),__publicField(we,"viewAdminOnly",!0);class Se{constructor(t,e){__publicField(this,"ctx"),__publicField(this,"conf"),__publicField(this,"$el"),__publicField(this,"sites",[]),__publicField(this,"$sites"),__publicField(this,"outsideChecker"),this.ctx=t,this.conf=e,this.$el=xt('<div class="atk-site-list-floater" style="display: none;">\n <div class="atk-sites"></div>\n </div>'),this.$sites=this.$el.querySelector(".atk-sites")}load(t){return __async(this,null,(function*(){this.$sites.innerHTML="";const e=(e,i,s,n)=>{const r=xt('<div class="atk-site-item">\n <div class="atk-site-logo"></div>\n <div class="atk-site-name"></div>\n </div>');r.onclick=n?()=>n():()=>this.switch(s||e),r.setAttribute("data-name",s||e);const a=r.querySelector(".atk-site-logo"),l=r.querySelector(".atk-site-name");a.innerText=i,l.innerText=e,t===(s||e)&&r.classList.add("atk-active"),this.$sites.append(r)};e("所有站点","_","__ATK_SITE_ALL");(yield new jt(this.ctx).siteGet()).forEach((t=>{e(t.name,t.name.substr(0,1))})),e("站点管理","+","",(()=>{this.conf.onClickSitesViewBtn(),this.hide()}))}))}switch(t){!1!==this.conf.onSwitchSite(t)&&(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())}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 Te="comments",Le=[be,ve,_e,we];class Ae extends i{constructor(t){super(t),__publicField(this,"layer"),__publicField(this,"$header"),__publicField(this,"$headerMenu"),__publicField(this,"$title"),__publicField(this,"$avatar"),__publicField(this,"$siteLogo"),__publicField(this,"$closeBtn"),__publicField(this,"$nav"),__publicField(this,"$curtViewBtn"),__publicField(this,"$curtViewBtnIcon"),__publicField(this,"$curtViewBtnText"),__publicField(this,"$navTabs"),__publicField(this,"$navViews"),__publicField(this,"$viewWrap"),__publicField(this,"siteSwitcher"),__publicField(this,"curtSite"),__publicField(this,"curtView",Te),__publicField(this,"curtTab"),__publicField(this,"viewInstances",{}),__publicField(this,"viewSwitcherShow",!1),__publicField(this,"firstShow",!0),this.$el=xt('<div class="atk-sidebar">\n <div class="atk-sidebar-inner">\n <div class="atk-sidebar-header">\n <span class="atk-avatar">\n <span class="atk-site-logo"></span>\n </span>\n <span class="atk-menu">\n <span class="atk-item atk-active atk-sidebar-title">控制中心</span>\n </span>\n <div class="atk-sidebar-close"><i class="atk-icon atk-icon-close"></i></div>\n </div>\n <div class="atk-sidebar-nav">\n <div class="akt-curt-view-btn">\n <div class="atk-icon"><span></span><span></span><span></span></div>\n <div class="atk-text"></div>\n </div>\n <div class="atk-tabs"></div>\n <div class="atk-tabs atk-views" style="display: none;"></div>\n </div>\n <div class="atk-sidebar-view-wrap"></div>\n </div>\n</div>\n'),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}))}get isAdmin(){return this.ctx.user.data.isAdmin}get curtViewInstance(){return this.curtView?this.viewInstances[this.curtView]:void 0}initViewSwitcher(){this.$curtViewBtn.onclick=()=>{this.toggleViewSwitcher()},this.$navViews.innerHTML="",Le.forEach((t=>{const e=xt('<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}show(){return __async(this,null,(function*(){if(this.$el.style.transform="",this.layer=new Ut(this.ctx,"sidebar",this.$el),this.layer.afterHide=()=>{!0===this.ctx.conf.editorTravel&&this.ctx.trigger("editor-travel-back")},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="控制中心",this.$curtViewBtn.style.display="",this.siteSwitcher||(this.siteSwitcher=new Se(this.ctx,{onSwitchSite:t=>{this.switchSite(t)},onClickSitesViewBtn:()=>{this.switchView("sites")}}),this.$viewWrap.before(this.siteSwitcher.$el),this.$avatar.onclick=t=>{var e;this.isAdmin&&(null==(e=this.siteSwitcher)||e.show(t.target))}),this.curtSite=this.conf.site,Ot(this.$el);try{yield this.siteSwitcher.load(this.curtSite)}catch(t){const e=xt(`<span>加载失败:${t.msg||"网络错误"}<br/></span>`),i=xt('<span style="cursor:pointer;">点击重新获取</span>');return e.appendChild(i),i.onclick=()=>{It(this.$el,null),this.show()},void It(this.$el,e)}finally{Bt(this.$el)}this.$avatar.innerHTML="",this.$siteLogo=xt('<div class="atk-site-logo"></div>'),this.$siteLogo.innerText=(this.curtSite||"").substr(0,1),this.$avatar.append(this.$siteLogo)}else{this.$title.innerText="通知中心",this.$curtViewBtn.style.display="none",this.curtSite=this.conf.site;const t=document.createElement("img");t.src=Ct(this.ctx,he(this.ctx.user.data.email.toLowerCase())),this.$avatar.innerHTML="",this.$avatar.append(t)}this.switchView(Te),this.firstShow=!1}}))}hide(){var t;this.$el.style.transform="",null==(t=this.layer)||t.hide()}switchView(t){let e=this.viewInstances[t];if(!e){e=new(Le.find((e=>e.viewName===t)))(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((e=>{e.getAttribute("data-name")===t?e.classList.add("atk-active"):e.classList.remove("atk-active")})),this.loadViewTabs(e),this.$viewWrap.innerHTML="",this.$viewWrap.append(e.$el),this.$viewWrap.classList.forEach((t=>{t.startsWith("atk-view-name-")&&this.$viewWrap.classList.remove(t)})),this.$viewWrap.classList.add(`atk-view-name-${e.constructor.viewName}`)}loadViewTabs(t){this.$navTabs.innerHTML="",Object.entries(t.viewTabs).forEach((([e,i])=>{const s=xt('<div class="atk-tab-item"></div>');this.$navTabs.append(s),s.innerText=i,t.viewActiveTab===e&&s.classList.add("atk-active"),s.onclick=()=>{!1!==t.switchTab(e,this.curtSite)&&(this.$navTabs.querySelectorAll(".atk-active").forEach((t=>t.classList.remove("atk-active"))),s.classList.add("atk-active"),this.curtTab=e)}}))}switchSite(t){this.curtSite=t;const e=this.curtViewInstance;null==e||e.switchTab(this.curtTab,t),this.$siteLogo&&(this.$siteLogo.innerText=this.curtSite.substr(0,1))}}const Ce=class{constructor(t){__publicField(this,"ctx"),__publicField(this,"conf"),__publicField(this,"$root"),__publicField(this,"checkerLauncher"),__publicField(this,"editor"),__publicField(this,"list"),__publicField(this,"sidebar"),this.conf=__spreadValues(__spreadValues({},Ce.defaults),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 t=document.querySelector(this.conf.el);if(!t)throw Error(`Sorry, target element "${this.conf.el}" was not found.`);this.$root=t}catch(i){throw console.error(i),new Error("Please check your Artalk `el` config.")}this.ctx=new e(this.$root,this.conf),this.$root.classList.add("artalk"),this.$root.innerHTML="",this.initDarkMode(),this.checkerLauncher=new Yt(this.ctx),this.editor=new Jt(this.ctx),this.$root.appendChild(this.editor.$el),this.list=new ce(this.ctx),this.$root.appendChild(this.list.$el),this.sidebar=new Ae(this.ctx),this.$root.appendChild(this.sidebar.$el),this.list.fetchComments(0),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((e=>t.push(e)));const{$wrap:e}=zt(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.on("user-changed",(()=>{this.ctx.trigger("check-admin-show-el"),this.ctx.trigger("list-refresh-ui")}))}reload(){this.list.fetchComments(0)}initDarkMode(){const t="atk-dark-mode";this.conf.darkMode?this.$root.classList.add(t):this.$root.classList.remove(t);const{$wrap:e}=zt(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")}};let Ee=Ce;return __publicField(Ee,"defaults",{el:"",pageKey:"",server:"",site:"",placeholder:"键入内容...",noComment:"「此时无声胜有声」",sendBtn:"发送评论",darkMode:!1,editorTravel:!0,emoticons:"https://cdn.jsdelivr.net/gh/ArtalkJS/Emoticons/grps/default.json",vote:!0,voteDown:!1,uaBadge:!0,flatMode:"auto",maxNesting:3,gravatar:{default:"mp",mirror:"https://sdn.geekzu.org/avatar/"},pagination:{pageSize:20,readMore:!0,autoLoad:!0},heightLimit:{content:300,children:400},reqTimeout:15e3,versionCheck:!0}),Ee}));
|