artalk 2.1.0 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/Artalk.es.js CHANGED
@@ -4551,20 +4551,16 @@ class ListLite extends Component {
4551
4551
  }
4552
4552
  }
4553
4553
  get commentsCount() {
4554
- let count = 0;
4555
- this.eachComment(this.comments, () => {
4556
- count++;
4557
- });
4558
- return count;
4554
+ return Number(this.data?.total) || 0;
4555
+ }
4556
+ get parentCommentsCount() {
4557
+ return Number(this.data?.total_parents) || 0;
4559
4558
  }
4560
4559
  get hasMoreComments() {
4561
4560
  if (!this.data)
4562
4561
  return false;
4563
4562
  return this.data.total_parents > this.offset + this.pageSize;
4564
4563
  }
4565
- get parentCommentsCount() {
4566
- return this.comments.length;
4567
- }
4568
4564
  eachComment(commentList, action) {
4569
4565
  if (commentList.length === 0)
4570
4566
  return;
@@ -4640,9 +4636,9 @@ class ListLite extends Component {
4640
4636
  }
4641
4637
  apiVersionCheck(versionData) {
4642
4638
  const needVersion = versionData?.fe_min_version || "0.0.0";
4643
- const needUpdate = versionCompare(needVersion, "2.1.0") === 1;
4639
+ const needUpdate = versionCompare(needVersion, "2.1.1") === 1;
4644
4640
  if (needUpdate) {
4645
- const errEl = createElement(`<div>\u524D\u7AEF Artalk \u7248\u672C\u5DF2\u8FC7\u65F6\uFF0C\u8BF7\u66F4\u65B0\u4EE5\u83B7\u5F97\u5B8C\u6574\u4F53\u9A8C<br/>\u82E5\u60A8\u662F\u7AD9\u70B9\u7BA1\u7406\u5458\uFF0C\u8BF7\u524D\u5F80 \u201C<a href="https://artalk.js.org/" target="_blank">\u5B98\u65B9\u6587\u6863</a>\u201D \u83B7\u53D6\u5E2E\u52A9<br/><br/><span style="color: var(--at-color-meta);">\u524D\u7AEF\u7248\u672C ${"2.1.0"}\uFF0C\u9700\u6C42\u7248\u672C >= ${needVersion}</span><br/><br/></div>`);
4641
+ const errEl = createElement(`<div>\u524D\u7AEF Artalk \u7248\u672C\u5DF2\u8FC7\u65F6\uFF0C\u8BF7\u66F4\u65B0\u4EE5\u83B7\u5F97\u5B8C\u6574\u4F53\u9A8C<br/>\u82E5\u60A8\u662F\u7AD9\u70B9\u7BA1\u7406\u5458\uFF0C\u8BF7\u524D\u5F80 \u201C<a href="https://artalk.js.org/" target="_blank">\u5B98\u65B9\u6587\u6863</a>\u201D \u83B7\u53D6\u5E2E\u52A9<br/><br/><span style="color: var(--at-color-meta);">\u524D\u7AEF\u7248\u672C ${"2.1.1"}\uFF0C\u9700\u6C42\u7248\u672C >= ${needVersion}</span><br/><br/></div>`);
4646
4642
  const ignoreBtn = createElement('<span style="cursor:pointer;">\u5FFD\u7565</span>');
4647
4643
  ignoreBtn.onclick = () => {
4648
4644
  setError(this.ctx, null);
@@ -4675,7 +4671,7 @@ class List extends ListLite {
4675
4671
  this.flatMode = flatMode;
4676
4672
  this.pageMode = this.conf.pagination?.readMore ? "read-more" : "pagination";
4677
4673
  this.initListActionBtn();
4678
- this.$el.querySelector(".atk-copyright").innerHTML = `Powered By <a href="https://artalk.js.org" target="_blank" title="Artalk v${"2.1.0"}">Artalk</a>`;
4674
+ this.$el.querySelector(".atk-copyright").innerHTML = `Powered By <a href="https://artalk.js.org" target="_blank" title="Artalk v${"2.1.1"}">Artalk</a>`;
4679
4675
  this.ctx.on("list-reload", () => this.reqComments(0));
4680
4676
  this.ctx.on("list-refresh-ui", () => this.refreshUI());
4681
4677
  this.ctx.on("list-import", (data) => this.importComments(data));
@@ -123,7 +123,7 @@ Please report this to https://github.com/markedjs/marked.`,(l||v.defaults).silen
123
123
  </div>
124
124
  </div>`),this.$loading=this.$el.querySelector(".atk-loading-icon"),this.$text=this.$el.querySelector(".atk-text"),this.$el.onclick=()=>this.click()}click(){this.conf.onClick()}show(){this.$el.style.display=""}hide(){this.$el.style.display="none"}setLoading(t){this.$loading.style.display=t?"":"none",this.$text.style.display=t?"none":""}showErr(t){this.setLoading(!1),this.$text.innerText=t,this.$el.classList.add("atk-err"),window.setTimeout(()=>{this.$text.innerText="\u67E5\u770B\u66F4\u591A",this.$el.classList.remove("atk-err")},2e3)}}class Bt extends H{$parent;$commentsWrap;comments=[];data;pageSize=15;offset=0;type;noCommentText;renderComment;paramsEditor;onAfterLoad;isLoading=!1;isFirstLoad=!0;flatMode;pageMode="pagination";pagination;readMoreBtn;autoLoadScrollEvent;autoLoadListenerAt;unread=[];unreadHighlight=!1;constructor(t,e){super(t);this.$parent=e,this.$el=m(`<div class="atk-list-lite">
125
125
  <div class="atk-list-comments-wrap"></div>
126
- </div>`),this.$commentsWrap=this.$el.querySelector(".atk-list-comments-wrap"),this.pageSize=this.conf.pagination?this.conf.pagination.pageSize||this.pageSize:this.pageSize,this.noCommentText=this.conf.noComment||"\u65E0\u8BC4\u8BBA",window.setInterval(()=>{this.$el.querySelectorAll("[data-atk-comment-date]").forEach(i=>{const s=i.getAttribute("data-atk-comment-date");i.innerText=wt(new Date(Number(s)))})},30*1e3),this.ctx.on("unread-update",i=>this.updateUnread(i.notifies))}async reqComments(t=0){t===0&&this.pageMode!=="pagination"&&this.clearAllComments();const e=()=>{this.isLoading=!0,t===0?I(this.$el):this.pageMode==="read-more"?this.readMoreBtn.setLoading(!0):this.pageMode==="pagination"&&this.pagination.setLoading(!0)},i=()=>{this.isLoading=!1,t===0?P(this.$el):this.pageMode==="read-more"?this.readMoreBtn.setLoading(!1):this.pageMode==="pagination"&&this.pagination.setLoading(!1)};e(),this.ctx.trigger("comments-load");let s;try{s=await new B(this.ctx).get(t,this.type,this.flatMode,this.paramsEditor)}catch(n){throw this.onError(n.msg||String(n)),n}finally{i()}if(!(this.ctx.conf.versionCheck&&this.apiVersionCheck(s.api_version||{}))){this.offset=t;try{this.onLoad(s,t),this.onAfterLoad&&this.onAfterLoad(s)}catch(n){throw this.onError(String(n)),n}finally{i()}}}onLoad(t,e){Y(this.$el,null),this.pageMode==="pagination"&&this.clearAllComments(),this.data=t,this.importComments(t.comments),this.isFirstLoad&&this.onLoadInit(),this.pageMode==="pagination"&&this.pagination.update(e,this.data?.total_parents||0),this.pageMode==="read-more"&&(this.hasMoreComments?this.readMoreBtn.show():this.readMoreBtn.hide()),this.ctx.trigger("unread-update",{notifies:t.unread||[]}),this.isFirstLoad=!1}onLoadInit(){if(this.autoLoadScrollEvent&&(this.autoLoadListenerAt||document).removeEventListener("scroll",this.autoLoadScrollEvent),this.pageMode==="read-more"){const t=new ae({pageSize:this.pageSize,total:0,onClick:async()=>{const e=this.offset+this.pageSize;await this.reqComments(e)}});this.readMoreBtn?this.readMoreBtn.$el.replaceWith(t.$el):this.$el.append(t.$el),this.readMoreBtn=t,this.conf.pagination?.autoLoad&&(this.autoLoadScrollEvent=()=>{if(this.pageMode!=="read-more"||!this.hasMoreComments||this.isLoading)return;const i=this.$el.querySelector(".atk-list-comments-wrap > .atk-comment-wrap:nth-last-child(3)");!i||Nt(i,this.autoLoadListenerAt)&&this.readMoreBtn.click()},(this.autoLoadListenerAt||document).addEventListener("scroll",this.autoLoadScrollEvent))}else if(this.pageMode==="pagination"){const t=new At(this.parentCommentsCount,{pageSize:this.pageSize,onChange:async e=>{if(await this.reqComments(e),this.$parent){let i=0;!this.autoLoadListenerAt&&this.$parent&&(i=vt(this.$parent).top),(this.autoLoadListenerAt||window).scroll({top:i,left:0})}}});this.pagination?this.pagination.$el.replaceWith(t.$el):this.$el.append(t.$el),this.pagination=t}}onError(t){if(t=String(t),console.error(t),this.isFirstLoad||this.pageMode==="pagination"){const e=m(`<span>${t}\uFF0C\u65E0\u6CD5\u83B7\u53D6\u8BC4\u8BBA\u5217\u8868\u6570\u636E<br/></span>`),i=m('<span style="cursor:pointer;">\u70B9\u51FB\u91CD\u65B0\u83B7\u53D6</span>');i.onclick=()=>{this.reqComments(this.offset)},e.appendChild(i);const s=m('<span atk-only-admin-show> | <span style="cursor:pointer;">\u6253\u5F00\u63A7\u5236\u53F0</span></span>');s.onclick=()=>{this.ctx.trigger("sidebar-show")},this.ctx.user.data.isAdmin||s.classList.add("atk-hide"),e.appendChild(s),Y(this.$el,e)}else this.readMoreBtn?.showErr("\u83B7\u53D6\u5931\u8D25")}refreshUI(){const t=this.comments.length<=0;let e=this.$commentsWrap.querySelector(".atk-list-no-comment");t&&(e||(e=m('<div class="atk-list-no-comment"></div>'),this.$commentsWrap.appendChild(e),e.innerHTML=this.noCommentText)),!t&&e&&e.remove(),this.ctx.trigger("check-admin-show-el")}createComment(t){const e=new ne(this.ctx,t);return e.afterRender=()=>{this.renderComment&&this.renderComment(e)},e.onDelete=i=>{this.deleteComment(i),this.refreshUI()},e}importComments(t){const e=i=>{const s=t.filter(n=>n.rid===i.data.id);s.length!==0&&s.forEach(n=>{n.is_allow_reply=i.data.is_allow_reply;const o=this.createComment(n);o.render(),i.putChild(o),e(o)})};this.flatMode?t.forEach(i=>{this.putCommentFlatMode(i,t,"append")}):t.filter(i=>i.rid===0).forEach(i=>{i.is_collapsed&&(i.is_allow_reply=!1);const s=this.createComment(i);s.render(),this.comments.push(s),this.$commentsWrap.appendChild(s.getEl()),s.playFadeInAnim(),e(s)}),this.eachComment(this.comments,i=>{this.checkMoreHide(i)}),this.refreshUI(),this.ctx.trigger("comments-loaded")}putCommentFlatMode(t,e,i){t.is_collapsed&&(t.is_allow_reply=!1);const s=this.createComment(t);if(t.rid!==0){const n=e.find(o=>o.id===t.rid);n&&(s.replyTo=n)}s.render(),i==="append"?this.comments.push(s):this.comments.unshift(s),t.visible&&(i==="append"?this.$commentsWrap.appendChild(s.getEl()):this.$commentsWrap.prepend(s.getEl()),s.playFadeInAnim()),this.checkMoreHide(s)}insertComment(t){if(this.flatMode)this.putCommentFlatMode(t,this.comments.map(e=>e.data),"prepend");else{const e=this.createComment(t);e.render(),t.rid!==0?this.findComment(t.rid)?.putChild(e):(this.$commentsWrap.prepend(e.getEl()),this.comments.unshift(e)),rt(e.getEl()),e.playFadeInAnim(),this.checkMoreHide(e)}this.data&&(this.data.total+=1),this.refreshUI(),this.ctx.trigger("comments-loaded")}checkMoreHide(t){const e=this.ctx.conf.heightLimit?.children,i=this.ctx.conf.heightLimit?.content,s=typeof e=="number"&&e>0,n=typeof i=="number"&&i>0;s&&t.getIsRoot()&&t.checkMoreHide(t.$children,e||300),n&&(t.checkMoreHide(t.$content,i||200),t.$replyTo&&t.checkMoreHide(t.$replyTo,i||200))}get commentsCount(){let t=0;return this.eachComment(this.comments,()=>{t++}),t}get hasMoreComments(){return this.data?this.data.total_parents>this.offset+this.pageSize:!1}get parentCommentsCount(){return this.comments.length}eachComment(t,e){t.length!==0&&t.every(i=>e(i,t)===!1?!1:(this.eachComment(i.getChildren(),e),!0))}findComment(t,e){e||(e=this.comments);let i=null;return this.eachComment(e,s=>s.data.id===t?(i=s,!1):!0),i}getCommentCount(){let t=0;return this.eachComment(this.comments,()=>{t++}),t}deleteComment(t){let e;if(typeof t=="number"){if(e=this.findComment(t),!e)throw Error(`\u672A\u627E\u5230\u8BC4\u8BBA ${t}`)}else e=t;e.getEl().remove(),this.eachComment(this.comments,(i,s)=>i===e?(s.splice(s.indexOf(i),1),!1):!0),this.refreshUI()}clearAllComments(){this.$commentsWrap.innerHTML="",this.data=void 0,this.comments=[]}updateUnread(t){this.unread=t,this.unreadHighlight&&this.eachComment(this.comments,e=>{const i=this.unread.find(s=>s.comment_id===e.data.id);i?(e.setUnread(!0),e.setOpenURL(i.read_link),e.openEvt=()=>{this.unread=this.unread.filter(s=>s.comment_id!==e.data.id),this.ctx.trigger("unread-update",{notifies:this.unread})}):e.setUnread(!1)})}apiVersionCheck(t){const e=t?.fe_min_version||"0.0.0",i=Wt(e,"2.1.0")===1;if(i){const s=m(`<div>\u524D\u7AEF Artalk \u7248\u672C\u5DF2\u8FC7\u65F6\uFF0C\u8BF7\u66F4\u65B0\u4EE5\u83B7\u5F97\u5B8C\u6574\u4F53\u9A8C<br/>\u82E5\u60A8\u662F\u7AD9\u70B9\u7BA1\u7406\u5458\uFF0C\u8BF7\u524D\u5F80 \u201C<a href="https://artalk.js.org/" target="_blank">\u5B98\u65B9\u6587\u6863</a>\u201D \u83B7\u53D6\u5E2E\u52A9<br/><br/><span style="color: var(--at-color-meta);">\u524D\u7AEF\u7248\u672C 2.1.0\uFF0C\u9700\u6C42\u7248\u672C >= ${e}</span><br/><br/></div>`),n=m('<span style="cursor:pointer;">\u5FFD\u7565</span>');n.onclick=()=>{Y(this.ctx,null),this.ctx.conf.versionCheck=!1,this.reqComments(0)},s.append(n),Y(this.ctx,s,'<span class="atk-warn-title">Artalk Warn</span>')}return i}}class re extends Bt{$closeCommentBtn;$openSidebarBtn;$unreadBadge;constructor(t){const e=m(ee);super(t,e);e.querySelector(".atk-list-body").append(this.$el),this.$el=e;let i=!1;this.ctx.conf.flatMode==="auto"?window.matchMedia("(max-width: 768px)").matches&&(i=!0):this.ctx.conf.flatMode===!0&&(i=!0),this.flatMode=i,this.pageMode=this.conf.pagination?.readMore?"read-more":"pagination",this.initListActionBtn(),this.$el.querySelector(".atk-copyright").innerHTML='Powered By <a href="https://artalk.js.org" target="_blank" title="Artalk v2.1.0">Artalk</a>',this.ctx.on("list-reload",()=>this.reqComments(0)),this.ctx.on("list-refresh-ui",()=>this.refreshUI()),this.ctx.on("list-import",s=>this.importComments(s)),this.ctx.on("list-insert",s=>this.insertComment(s)),this.ctx.on("list-delete",s=>this.deleteComment(s.id)),this.ctx.on("list-update",s=>{s(this.data),this.refreshUI()}),this.ctx.on("unread-update",s=>this.showUnreadBadge(s.notifies?.length||0))}initListActionBtn(){this.$openSidebarBtn=this.$el.querySelector('[data-action="open-sidebar"]'),this.$closeCommentBtn=this.$el.querySelector('[data-action="admin-close-comment"]'),this.$unreadBadge=this.$el.querySelector(".atk-unread-badge"),this.$openSidebarBtn.addEventListener("click",()=>{this.ctx.trigger("sidebar-show")}),this.$closeCommentBtn.addEventListener("click",()=>{!this.data||(this.data.page.admin_only=!this.data.page.admin_only,this.adminPageEditSave())})}refreshUI(){super.refreshUI(),this.$el.querySelector(".atk-comment-count-num").innerText=String(this.commentsCount),!!this.ctx.user.data.nick&&!!this.ctx.user.data.email?this.$openSidebarBtn.classList.remove("atk-hide"):this.$openSidebarBtn.classList.add("atk-hide"),this.ctx.trigger("check-admin-show-el"),this.$openSidebarBtn.innerText=this.ctx.user.data.isAdmin?"\u63A7\u5236\u4E2D\u5FC3":"\u901A\u77E5\u4E2D\u5FC3",!!this.data&&!!this.data.page&&this.data.page.admin_only===!0?(this.ctx.trigger("editor-close"),this.$closeCommentBtn.innerHTML="\u6253\u5F00\u8BC4\u8BBA"):(this.ctx.trigger("editor-open"),this.$closeCommentBtn.innerHTML="\u5173\u95ED\u8BC4\u8BBA")}onLoad(t,e){super.onLoad(t,e),this.checkGoToCommentByUrlHash()}async checkGoToCommentByUrlHash(){let t=Number(yt("atk_comment"));if(!t){const s=window.location.hash.match(/#atk-comment-([0-9]+)/);if(!s||!s[1]||Number.isNaN(Number(s[1])))return;t=Number(s[1])}if(!t)return;const e=yt("atk_notify_key");e&&new B(this.ctx).markRead(e).then(()=>{this.unread=this.unread.filter(s=>s.comment_id!==t),this.ctx.trigger("unread-update",{notifies:this.unread})});const i=this.findComment(t);!i||(rt(i.getEl(),!1),window.setTimeout(()=>{i.getEl().classList.add("atk-flash-once")},800))}adminPageEditSave(){!this.data||!this.data.page||(this.ctx.trigger("editor-show-loading"),new B(this.ctx).pageEdit(this.data.page).then(t=>{this.data&&(this.data.page={...t}),this.refreshUI()}).catch(t=>{this.ctx.trigger("editor-notify",{msg:`\u4FEE\u6539\u9875\u9762\u6570\u636E\u5931\u8D25\uFF1A${t.msg||String(t)}`,type:"e"})}).finally(()=>{this.ctx.trigger("editor-hide-loading")}))}showUnreadBadge(t){t>0?(this.$unreadBadge.innerText=`${Number(t||0)}`,this.$unreadBadge.style.display="block"):this.$unreadBadge.style.display="none"}}var Fe="",oe=function(r){var t=le(he(ue(ce(r),8*r.length)));return t.toLowerCase()};function le(r){for(var t,e="0123456789ABCDEF",i="",s=0;s<r.length;s++)t=r.charCodeAt(s),i+=e.charAt(t>>>4&15)+e.charAt(15&t);return i}function ce(r){for(var t=Array(r.length>>2),e=0;e<t.length;e++)t[e]=0;for(e=0;e<8*r.length;e+=8)t[e>>5]|=(255&r.charCodeAt(e/8))<<e%32;return t}function he(r){for(var t="",e=0;e<32*r.length;e+=8)t+=String.fromCharCode(r[e>>5]>>>e%32&255);return t}function ue(r,t){r[t>>5]|=128<<t%32,r[14+(t+64>>>9<<4)]=t;for(var e=1732584193,i=-271733879,s=-1732584194,n=271733878,o=0;o<r.length;o+=16){var p=e,f=i,$=s,b=n;i=R(i=R(i=R(i=R(i=O(i=O(i=O(i=O(i=M(i=M(i=M(i=M(i=D(i=D(i=D(i=D(i,s=D(s,n=D(n,e=D(e,i,s,n,r[o+0],7,-680876936),i,s,r[o+1],12,-389564586),e,i,r[o+2],17,606105819),n,e,r[o+3],22,-1044525330),s=D(s,n=D(n,e=D(e,i,s,n,r[o+4],7,-176418897),i,s,r[o+5],12,1200080426),e,i,r[o+6],17,-1473231341),n,e,r[o+7],22,-45705983),s=D(s,n=D(n,e=D(e,i,s,n,r[o+8],7,1770035416),i,s,r[o+9],12,-1958414417),e,i,r[o+10],17,-42063),n,e,r[o+11],22,-1990404162),s=D(s,n=D(n,e=D(e,i,s,n,r[o+12],7,1804603682),i,s,r[o+13],12,-40341101),e,i,r[o+14],17,-1502002290),n,e,r[o+15],22,1236535329),s=M(s,n=M(n,e=M(e,i,s,n,r[o+1],5,-165796510),i,s,r[o+6],9,-1069501632),e,i,r[o+11],14,643717713),n,e,r[o+0],20,-373897302),s=M(s,n=M(n,e=M(e,i,s,n,r[o+5],5,-701558691),i,s,r[o+10],9,38016083),e,i,r[o+15],14,-660478335),n,e,r[o+4],20,-405537848),s=M(s,n=M(n,e=M(e,i,s,n,r[o+9],5,568446438),i,s,r[o+14],9,-1019803690),e,i,r[o+3],14,-187363961),n,e,r[o+8],20,1163531501),s=M(s,n=M(n,e=M(e,i,s,n,r[o+13],5,-1444681467),i,s,r[o+2],9,-51403784),e,i,r[o+7],14,1735328473),n,e,r[o+12],20,-1926607734),s=O(s,n=O(n,e=O(e,i,s,n,r[o+5],4,-378558),i,s,r[o+8],11,-2022574463),e,i,r[o+11],16,1839030562),n,e,r[o+14],23,-35309556),s=O(s,n=O(n,e=O(e,i,s,n,r[o+1],4,-1530992060),i,s,r[o+4],11,1272893353),e,i,r[o+7],16,-155497632),n,e,r[o+10],23,-1094730640),s=O(s,n=O(n,e=O(e,i,s,n,r[o+13],4,681279174),i,s,r[o+0],11,-358537222),e,i,r[o+3],16,-722521979),n,e,r[o+6],23,76029189),s=O(s,n=O(n,e=O(e,i,s,n,r[o+9],4,-640364487),i,s,r[o+12],11,-421815835),e,i,r[o+15],16,530742520),n,e,r[o+2],23,-995338651),s=R(s,n=R(n,e=R(e,i,s,n,r[o+0],6,-198630844),i,s,r[o+7],10,1126891415),e,i,r[o+14],15,-1416354905),n,e,r[o+5],21,-57434055),s=R(s,n=R(n,e=R(e,i,s,n,r[o+12],6,1700485571),i,s,r[o+3],10,-1894986606),e,i,r[o+10],15,-1051523),n,e,r[o+1],21,-2054922799),s=R(s,n=R(n,e=R(e,i,s,n,r[o+8],6,1873313359),i,s,r[o+15],10,-30611744),e,i,r[o+6],15,-1560198380),n,e,r[o+13],21,1309151649),s=R(s,n=R(n,e=R(e,i,s,n,r[o+4],6,-145523070),i,s,r[o+11],10,-1120210379),e,i,r[o+2],15,718787259),n,e,r[o+9],21,-343485551),e=V(e,p),i=V(i,f),s=V(s,$),n=V(n,b)}return Array(e,i,s,n)}function et(r,t,e,i,s,n){return V(de(V(V(t,r),V(i,n)),s),e)}function D(r,t,e,i,s,n,o){return et(t&e|~t&i,r,t,s,n,o)}function M(r,t,e,i,s,n,o){return et(t&i|e&~i,r,t,s,n,o)}function O(r,t,e,i,s,n,o){return et(t^e^i,r,t,s,n,o)}function R(r,t,e,i,s,n,o){return et(e^(t|~i),r,t,s,n,o)}function V(r,t){var e=(65535&r)+(65535&t);return(r>>16)+(t>>16)+(e>>16)<<16|65535&e}function de(r,t){return r<<t|r>>>32-t}var pe=`<div class="atk-sidebar">
126
+ </div>`),this.$commentsWrap=this.$el.querySelector(".atk-list-comments-wrap"),this.pageSize=this.conf.pagination?this.conf.pagination.pageSize||this.pageSize:this.pageSize,this.noCommentText=this.conf.noComment||"\u65E0\u8BC4\u8BBA",window.setInterval(()=>{this.$el.querySelectorAll("[data-atk-comment-date]").forEach(i=>{const s=i.getAttribute("data-atk-comment-date");i.innerText=wt(new Date(Number(s)))})},30*1e3),this.ctx.on("unread-update",i=>this.updateUnread(i.notifies))}async reqComments(t=0){t===0&&this.pageMode!=="pagination"&&this.clearAllComments();const e=()=>{this.isLoading=!0,t===0?I(this.$el):this.pageMode==="read-more"?this.readMoreBtn.setLoading(!0):this.pageMode==="pagination"&&this.pagination.setLoading(!0)},i=()=>{this.isLoading=!1,t===0?P(this.$el):this.pageMode==="read-more"?this.readMoreBtn.setLoading(!1):this.pageMode==="pagination"&&this.pagination.setLoading(!1)};e(),this.ctx.trigger("comments-load");let s;try{s=await new B(this.ctx).get(t,this.type,this.flatMode,this.paramsEditor)}catch(n){throw this.onError(n.msg||String(n)),n}finally{i()}if(!(this.ctx.conf.versionCheck&&this.apiVersionCheck(s.api_version||{}))){this.offset=t;try{this.onLoad(s,t),this.onAfterLoad&&this.onAfterLoad(s)}catch(n){throw this.onError(String(n)),n}finally{i()}}}onLoad(t,e){Y(this.$el,null),this.pageMode==="pagination"&&this.clearAllComments(),this.data=t,this.importComments(t.comments),this.isFirstLoad&&this.onLoadInit(),this.pageMode==="pagination"&&this.pagination.update(e,this.data?.total_parents||0),this.pageMode==="read-more"&&(this.hasMoreComments?this.readMoreBtn.show():this.readMoreBtn.hide()),this.ctx.trigger("unread-update",{notifies:t.unread||[]}),this.isFirstLoad=!1}onLoadInit(){if(this.autoLoadScrollEvent&&(this.autoLoadListenerAt||document).removeEventListener("scroll",this.autoLoadScrollEvent),this.pageMode==="read-more"){const t=new ae({pageSize:this.pageSize,total:0,onClick:async()=>{const e=this.offset+this.pageSize;await this.reqComments(e)}});this.readMoreBtn?this.readMoreBtn.$el.replaceWith(t.$el):this.$el.append(t.$el),this.readMoreBtn=t,this.conf.pagination?.autoLoad&&(this.autoLoadScrollEvent=()=>{if(this.pageMode!=="read-more"||!this.hasMoreComments||this.isLoading)return;const i=this.$el.querySelector(".atk-list-comments-wrap > .atk-comment-wrap:nth-last-child(3)");!i||Nt(i,this.autoLoadListenerAt)&&this.readMoreBtn.click()},(this.autoLoadListenerAt||document).addEventListener("scroll",this.autoLoadScrollEvent))}else if(this.pageMode==="pagination"){const t=new At(this.parentCommentsCount,{pageSize:this.pageSize,onChange:async e=>{if(await this.reqComments(e),this.$parent){let i=0;!this.autoLoadListenerAt&&this.$parent&&(i=vt(this.$parent).top),(this.autoLoadListenerAt||window).scroll({top:i,left:0})}}});this.pagination?this.pagination.$el.replaceWith(t.$el):this.$el.append(t.$el),this.pagination=t}}onError(t){if(t=String(t),console.error(t),this.isFirstLoad||this.pageMode==="pagination"){const e=m(`<span>${t}\uFF0C\u65E0\u6CD5\u83B7\u53D6\u8BC4\u8BBA\u5217\u8868\u6570\u636E<br/></span>`),i=m('<span style="cursor:pointer;">\u70B9\u51FB\u91CD\u65B0\u83B7\u53D6</span>');i.onclick=()=>{this.reqComments(this.offset)},e.appendChild(i);const s=m('<span atk-only-admin-show> | <span style="cursor:pointer;">\u6253\u5F00\u63A7\u5236\u53F0</span></span>');s.onclick=()=>{this.ctx.trigger("sidebar-show")},this.ctx.user.data.isAdmin||s.classList.add("atk-hide"),e.appendChild(s),Y(this.$el,e)}else this.readMoreBtn?.showErr("\u83B7\u53D6\u5931\u8D25")}refreshUI(){const t=this.comments.length<=0;let e=this.$commentsWrap.querySelector(".atk-list-no-comment");t&&(e||(e=m('<div class="atk-list-no-comment"></div>'),this.$commentsWrap.appendChild(e),e.innerHTML=this.noCommentText)),!t&&e&&e.remove(),this.ctx.trigger("check-admin-show-el")}createComment(t){const e=new ne(this.ctx,t);return e.afterRender=()=>{this.renderComment&&this.renderComment(e)},e.onDelete=i=>{this.deleteComment(i),this.refreshUI()},e}importComments(t){const e=i=>{const s=t.filter(n=>n.rid===i.data.id);s.length!==0&&s.forEach(n=>{n.is_allow_reply=i.data.is_allow_reply;const o=this.createComment(n);o.render(),i.putChild(o),e(o)})};this.flatMode?t.forEach(i=>{this.putCommentFlatMode(i,t,"append")}):t.filter(i=>i.rid===0).forEach(i=>{i.is_collapsed&&(i.is_allow_reply=!1);const s=this.createComment(i);s.render(),this.comments.push(s),this.$commentsWrap.appendChild(s.getEl()),s.playFadeInAnim(),e(s)}),this.eachComment(this.comments,i=>{this.checkMoreHide(i)}),this.refreshUI(),this.ctx.trigger("comments-loaded")}putCommentFlatMode(t,e,i){t.is_collapsed&&(t.is_allow_reply=!1);const s=this.createComment(t);if(t.rid!==0){const n=e.find(o=>o.id===t.rid);n&&(s.replyTo=n)}s.render(),i==="append"?this.comments.push(s):this.comments.unshift(s),t.visible&&(i==="append"?this.$commentsWrap.appendChild(s.getEl()):this.$commentsWrap.prepend(s.getEl()),s.playFadeInAnim()),this.checkMoreHide(s)}insertComment(t){if(this.flatMode)this.putCommentFlatMode(t,this.comments.map(e=>e.data),"prepend");else{const e=this.createComment(t);e.render(),t.rid!==0?this.findComment(t.rid)?.putChild(e):(this.$commentsWrap.prepend(e.getEl()),this.comments.unshift(e)),rt(e.getEl()),e.playFadeInAnim(),this.checkMoreHide(e)}this.data&&(this.data.total+=1),this.refreshUI(),this.ctx.trigger("comments-loaded")}checkMoreHide(t){const e=this.ctx.conf.heightLimit?.children,i=this.ctx.conf.heightLimit?.content,s=typeof e=="number"&&e>0,n=typeof i=="number"&&i>0;s&&t.getIsRoot()&&t.checkMoreHide(t.$children,e||300),n&&(t.checkMoreHide(t.$content,i||200),t.$replyTo&&t.checkMoreHide(t.$replyTo,i||200))}get commentsCount(){return Number(this.data?.total)||0}get parentCommentsCount(){return Number(this.data?.total_parents)||0}get hasMoreComments(){return this.data?this.data.total_parents>this.offset+this.pageSize:!1}eachComment(t,e){t.length!==0&&t.every(i=>e(i,t)===!1?!1:(this.eachComment(i.getChildren(),e),!0))}findComment(t,e){e||(e=this.comments);let i=null;return this.eachComment(e,s=>s.data.id===t?(i=s,!1):!0),i}getCommentCount(){let t=0;return this.eachComment(this.comments,()=>{t++}),t}deleteComment(t){let e;if(typeof t=="number"){if(e=this.findComment(t),!e)throw Error(`\u672A\u627E\u5230\u8BC4\u8BBA ${t}`)}else e=t;e.getEl().remove(),this.eachComment(this.comments,(i,s)=>i===e?(s.splice(s.indexOf(i),1),!1):!0),this.refreshUI()}clearAllComments(){this.$commentsWrap.innerHTML="",this.data=void 0,this.comments=[]}updateUnread(t){this.unread=t,this.unreadHighlight&&this.eachComment(this.comments,e=>{const i=this.unread.find(s=>s.comment_id===e.data.id);i?(e.setUnread(!0),e.setOpenURL(i.read_link),e.openEvt=()=>{this.unread=this.unread.filter(s=>s.comment_id!==e.data.id),this.ctx.trigger("unread-update",{notifies:this.unread})}):e.setUnread(!1)})}apiVersionCheck(t){const e=t?.fe_min_version||"0.0.0",i=Wt(e,"2.1.1")===1;if(i){const s=m(`<div>\u524D\u7AEF Artalk \u7248\u672C\u5DF2\u8FC7\u65F6\uFF0C\u8BF7\u66F4\u65B0\u4EE5\u83B7\u5F97\u5B8C\u6574\u4F53\u9A8C<br/>\u82E5\u60A8\u662F\u7AD9\u70B9\u7BA1\u7406\u5458\uFF0C\u8BF7\u524D\u5F80 \u201C<a href="https://artalk.js.org/" target="_blank">\u5B98\u65B9\u6587\u6863</a>\u201D \u83B7\u53D6\u5E2E\u52A9<br/><br/><span style="color: var(--at-color-meta);">\u524D\u7AEF\u7248\u672C 2.1.1\uFF0C\u9700\u6C42\u7248\u672C >= ${e}</span><br/><br/></div>`),n=m('<span style="cursor:pointer;">\u5FFD\u7565</span>');n.onclick=()=>{Y(this.ctx,null),this.ctx.conf.versionCheck=!1,this.reqComments(0)},s.append(n),Y(this.ctx,s,'<span class="atk-warn-title">Artalk Warn</span>')}return i}}class re extends Bt{$closeCommentBtn;$openSidebarBtn;$unreadBadge;constructor(t){const e=m(ee);super(t,e);e.querySelector(".atk-list-body").append(this.$el),this.$el=e;let i=!1;this.ctx.conf.flatMode==="auto"?window.matchMedia("(max-width: 768px)").matches&&(i=!0):this.ctx.conf.flatMode===!0&&(i=!0),this.flatMode=i,this.pageMode=this.conf.pagination?.readMore?"read-more":"pagination",this.initListActionBtn(),this.$el.querySelector(".atk-copyright").innerHTML='Powered By <a href="https://artalk.js.org" target="_blank" title="Artalk v2.1.1">Artalk</a>',this.ctx.on("list-reload",()=>this.reqComments(0)),this.ctx.on("list-refresh-ui",()=>this.refreshUI()),this.ctx.on("list-import",s=>this.importComments(s)),this.ctx.on("list-insert",s=>this.insertComment(s)),this.ctx.on("list-delete",s=>this.deleteComment(s.id)),this.ctx.on("list-update",s=>{s(this.data),this.refreshUI()}),this.ctx.on("unread-update",s=>this.showUnreadBadge(s.notifies?.length||0))}initListActionBtn(){this.$openSidebarBtn=this.$el.querySelector('[data-action="open-sidebar"]'),this.$closeCommentBtn=this.$el.querySelector('[data-action="admin-close-comment"]'),this.$unreadBadge=this.$el.querySelector(".atk-unread-badge"),this.$openSidebarBtn.addEventListener("click",()=>{this.ctx.trigger("sidebar-show")}),this.$closeCommentBtn.addEventListener("click",()=>{!this.data||(this.data.page.admin_only=!this.data.page.admin_only,this.adminPageEditSave())})}refreshUI(){super.refreshUI(),this.$el.querySelector(".atk-comment-count-num").innerText=String(this.commentsCount),!!this.ctx.user.data.nick&&!!this.ctx.user.data.email?this.$openSidebarBtn.classList.remove("atk-hide"):this.$openSidebarBtn.classList.add("atk-hide"),this.ctx.trigger("check-admin-show-el"),this.$openSidebarBtn.innerText=this.ctx.user.data.isAdmin?"\u63A7\u5236\u4E2D\u5FC3":"\u901A\u77E5\u4E2D\u5FC3",!!this.data&&!!this.data.page&&this.data.page.admin_only===!0?(this.ctx.trigger("editor-close"),this.$closeCommentBtn.innerHTML="\u6253\u5F00\u8BC4\u8BBA"):(this.ctx.trigger("editor-open"),this.$closeCommentBtn.innerHTML="\u5173\u95ED\u8BC4\u8BBA")}onLoad(t,e){super.onLoad(t,e),this.checkGoToCommentByUrlHash()}async checkGoToCommentByUrlHash(){let t=Number(yt("atk_comment"));if(!t){const s=window.location.hash.match(/#atk-comment-([0-9]+)/);if(!s||!s[1]||Number.isNaN(Number(s[1])))return;t=Number(s[1])}if(!t)return;const e=yt("atk_notify_key");e&&new B(this.ctx).markRead(e).then(()=>{this.unread=this.unread.filter(s=>s.comment_id!==t),this.ctx.trigger("unread-update",{notifies:this.unread})});const i=this.findComment(t);!i||(rt(i.getEl(),!1),window.setTimeout(()=>{i.getEl().classList.add("atk-flash-once")},800))}adminPageEditSave(){!this.data||!this.data.page||(this.ctx.trigger("editor-show-loading"),new B(this.ctx).pageEdit(this.data.page).then(t=>{this.data&&(this.data.page={...t}),this.refreshUI()}).catch(t=>{this.ctx.trigger("editor-notify",{msg:`\u4FEE\u6539\u9875\u9762\u6570\u636E\u5931\u8D25\uFF1A${t.msg||String(t)}`,type:"e"})}).finally(()=>{this.ctx.trigger("editor-hide-loading")}))}showUnreadBadge(t){t>0?(this.$unreadBadge.innerText=`${Number(t||0)}`,this.$unreadBadge.style.display="block"):this.$unreadBadge.style.display="none"}}var Fe="",oe=function(r){var t=le(he(ue(ce(r),8*r.length)));return t.toLowerCase()};function le(r){for(var t,e="0123456789ABCDEF",i="",s=0;s<r.length;s++)t=r.charCodeAt(s),i+=e.charAt(t>>>4&15)+e.charAt(15&t);return i}function ce(r){for(var t=Array(r.length>>2),e=0;e<t.length;e++)t[e]=0;for(e=0;e<8*r.length;e+=8)t[e>>5]|=(255&r.charCodeAt(e/8))<<e%32;return t}function he(r){for(var t="",e=0;e<32*r.length;e+=8)t+=String.fromCharCode(r[e>>5]>>>e%32&255);return t}function ue(r,t){r[t>>5]|=128<<t%32,r[14+(t+64>>>9<<4)]=t;for(var e=1732584193,i=-271733879,s=-1732584194,n=271733878,o=0;o<r.length;o+=16){var p=e,f=i,$=s,b=n;i=R(i=R(i=R(i=R(i=O(i=O(i=O(i=O(i=M(i=M(i=M(i=M(i=D(i=D(i=D(i=D(i,s=D(s,n=D(n,e=D(e,i,s,n,r[o+0],7,-680876936),i,s,r[o+1],12,-389564586),e,i,r[o+2],17,606105819),n,e,r[o+3],22,-1044525330),s=D(s,n=D(n,e=D(e,i,s,n,r[o+4],7,-176418897),i,s,r[o+5],12,1200080426),e,i,r[o+6],17,-1473231341),n,e,r[o+7],22,-45705983),s=D(s,n=D(n,e=D(e,i,s,n,r[o+8],7,1770035416),i,s,r[o+9],12,-1958414417),e,i,r[o+10],17,-42063),n,e,r[o+11],22,-1990404162),s=D(s,n=D(n,e=D(e,i,s,n,r[o+12],7,1804603682),i,s,r[o+13],12,-40341101),e,i,r[o+14],17,-1502002290),n,e,r[o+15],22,1236535329),s=M(s,n=M(n,e=M(e,i,s,n,r[o+1],5,-165796510),i,s,r[o+6],9,-1069501632),e,i,r[o+11],14,643717713),n,e,r[o+0],20,-373897302),s=M(s,n=M(n,e=M(e,i,s,n,r[o+5],5,-701558691),i,s,r[o+10],9,38016083),e,i,r[o+15],14,-660478335),n,e,r[o+4],20,-405537848),s=M(s,n=M(n,e=M(e,i,s,n,r[o+9],5,568446438),i,s,r[o+14],9,-1019803690),e,i,r[o+3],14,-187363961),n,e,r[o+8],20,1163531501),s=M(s,n=M(n,e=M(e,i,s,n,r[o+13],5,-1444681467),i,s,r[o+2],9,-51403784),e,i,r[o+7],14,1735328473),n,e,r[o+12],20,-1926607734),s=O(s,n=O(n,e=O(e,i,s,n,r[o+5],4,-378558),i,s,r[o+8],11,-2022574463),e,i,r[o+11],16,1839030562),n,e,r[o+14],23,-35309556),s=O(s,n=O(n,e=O(e,i,s,n,r[o+1],4,-1530992060),i,s,r[o+4],11,1272893353),e,i,r[o+7],16,-155497632),n,e,r[o+10],23,-1094730640),s=O(s,n=O(n,e=O(e,i,s,n,r[o+13],4,681279174),i,s,r[o+0],11,-358537222),e,i,r[o+3],16,-722521979),n,e,r[o+6],23,76029189),s=O(s,n=O(n,e=O(e,i,s,n,r[o+9],4,-640364487),i,s,r[o+12],11,-421815835),e,i,r[o+15],16,530742520),n,e,r[o+2],23,-995338651),s=R(s,n=R(n,e=R(e,i,s,n,r[o+0],6,-198630844),i,s,r[o+7],10,1126891415),e,i,r[o+14],15,-1416354905),n,e,r[o+5],21,-57434055),s=R(s,n=R(n,e=R(e,i,s,n,r[o+12],6,1700485571),i,s,r[o+3],10,-1894986606),e,i,r[o+10],15,-1051523),n,e,r[o+1],21,-2054922799),s=R(s,n=R(n,e=R(e,i,s,n,r[o+8],6,1873313359),i,s,r[o+15],10,-30611744),e,i,r[o+6],15,-1560198380),n,e,r[o+13],21,1309151649),s=R(s,n=R(n,e=R(e,i,s,n,r[o+4],6,-145523070),i,s,r[o+11],10,-1120210379),e,i,r[o+2],15,718787259),n,e,r[o+9],21,-343485551),e=V(e,p),i=V(i,f),s=V(s,$),n=V(n,b)}return Array(e,i,s,n)}function et(r,t,e,i,s,n){return V(de(V(V(t,r),V(i,n)),s),e)}function D(r,t,e,i,s,n,o){return et(t&e|~t&i,r,t,s,n,o)}function M(r,t,e,i,s,n,o){return et(t&i|e&~i,r,t,s,n,o)}function O(r,t,e,i,s,n,o){return et(t^e^i,r,t,s,n,o)}function R(r,t,e,i,s,n,o){return et(e^(t|~i),r,t,s,n,o)}function V(r,t){var e=(65535&r)+(65535&t);return(r>>16)+(t>>16)+(e>>16)<<16|65535&e}function de(r,t){return r<<t|r>>>32-t}var pe=`<div class="atk-sidebar">
127
127
  <div class="atk-sidebar-inner">
128
128
  <div class="atk-sidebar-header">
129
129
  <span class="atk-avatar">
package/dist/Artalk.js CHANGED
@@ -123,7 +123,7 @@ Please report this to https://github.com/markedjs/marked.`,(l||v.defaults).silen
123
123
  </div>
124
124
  </div>`),this.$loading=this.$el.querySelector(".atk-loading-icon"),this.$text=this.$el.querySelector(".atk-text"),this.$el.onclick=()=>this.click()}click(){this.conf.onClick()}show(){this.$el.style.display=""}hide(){this.$el.style.display="none"}setLoading(t){this.$loading.style.display=t?"":"none",this.$text.style.display=t?"none":""}showErr(t){this.setLoading(!1),this.$text.innerText=t,this.$el.classList.add("atk-err"),window.setTimeout(()=>{this.$text.innerText="\u67E5\u770B\u66F4\u591A",this.$el.classList.remove("atk-err")},2e3)}}class Ft extends H{$parent;$commentsWrap;comments=[];data;pageSize=15;offset=0;type;noCommentText;renderComment;paramsEditor;onAfterLoad;isLoading=!1;isFirstLoad=!0;flatMode;pageMode="pagination";pagination;readMoreBtn;autoLoadScrollEvent;autoLoadListenerAt;unread=[];unreadHighlight=!1;constructor(t,e){super(t);this.$parent=e,this.$el=m(`<div class="atk-list-lite">
125
125
  <div class="atk-list-comments-wrap"></div>
126
- </div>`),this.$commentsWrap=this.$el.querySelector(".atk-list-comments-wrap"),this.pageSize=this.conf.pagination?this.conf.pagination.pageSize||this.pageSize:this.pageSize,this.noCommentText=this.conf.noComment||"\u65E0\u8BC4\u8BBA",window.setInterval(()=>{this.$el.querySelectorAll("[data-atk-comment-date]").forEach(i=>{const s=i.getAttribute("data-atk-comment-date");i.innerText=bt(new Date(Number(s)))})},30*1e3),this.ctx.on("unread-update",i=>this.updateUnread(i.notifies))}async reqComments(t=0){t===0&&this.pageMode!=="pagination"&&this.clearAllComments();const e=()=>{this.isLoading=!0,t===0?I(this.$el):this.pageMode==="read-more"?this.readMoreBtn.setLoading(!0):this.pageMode==="pagination"&&this.pagination.setLoading(!0)},i=()=>{this.isLoading=!1,t===0?P(this.$el):this.pageMode==="read-more"?this.readMoreBtn.setLoading(!1):this.pageMode==="pagination"&&this.pagination.setLoading(!1)};e(),this.ctx.trigger("comments-load");let s;try{s=await new B(this.ctx).get(t,this.type,this.flatMode,this.paramsEditor)}catch(n){throw this.onError(n.msg||String(n)),n}finally{i()}if(!(this.ctx.conf.versionCheck&&this.apiVersionCheck(s.api_version||{}))){this.offset=t;try{this.onLoad(s,t),this.onAfterLoad&&this.onAfterLoad(s)}catch(n){throw this.onError(String(n)),n}finally{i()}}}onLoad(t,e){Y(this.$el,null),this.pageMode==="pagination"&&this.clearAllComments(),this.data=t,this.importComments(t.comments),this.isFirstLoad&&this.onLoadInit(),this.pageMode==="pagination"&&this.pagination.update(e,this.data?.total_parents||0),this.pageMode==="read-more"&&(this.hasMoreComments?this.readMoreBtn.show():this.readMoreBtn.hide()),this.ctx.trigger("unread-update",{notifies:t.unread||[]}),this.isFirstLoad=!1}onLoadInit(){if(this.autoLoadScrollEvent&&(this.autoLoadListenerAt||document).removeEventListener("scroll",this.autoLoadScrollEvent),this.pageMode==="read-more"){const t=new re({pageSize:this.pageSize,total:0,onClick:async()=>{const e=this.offset+this.pageSize;await this.reqComments(e)}});this.readMoreBtn?this.readMoreBtn.$el.replaceWith(t.$el):this.$el.append(t.$el),this.readMoreBtn=t,this.conf.pagination?.autoLoad&&(this.autoLoadScrollEvent=()=>{if(this.pageMode!=="read-more"||!this.hasMoreComments||this.isLoading)return;const i=this.$el.querySelector(".atk-list-comments-wrap > .atk-comment-wrap:nth-last-child(3)");!i||Ht(i,this.autoLoadListenerAt)&&this.readMoreBtn.click()},(this.autoLoadListenerAt||document).addEventListener("scroll",this.autoLoadScrollEvent))}else if(this.pageMode==="pagination"){const t=new Lt(this.parentCommentsCount,{pageSize:this.pageSize,onChange:async e=>{if(await this.reqComments(e),this.$parent){let i=0;!this.autoLoadListenerAt&&this.$parent&&(i=xt(this.$parent).top),(this.autoLoadListenerAt||window).scroll({top:i,left:0})}}});this.pagination?this.pagination.$el.replaceWith(t.$el):this.$el.append(t.$el),this.pagination=t}}onError(t){if(t=String(t),console.error(t),this.isFirstLoad||this.pageMode==="pagination"){const e=m(`<span>${t}\uFF0C\u65E0\u6CD5\u83B7\u53D6\u8BC4\u8BBA\u5217\u8868\u6570\u636E<br/></span>`),i=m('<span style="cursor:pointer;">\u70B9\u51FB\u91CD\u65B0\u83B7\u53D6</span>');i.onclick=()=>{this.reqComments(this.offset)},e.appendChild(i);const s=m('<span atk-only-admin-show> | <span style="cursor:pointer;">\u6253\u5F00\u63A7\u5236\u53F0</span></span>');s.onclick=()=>{this.ctx.trigger("sidebar-show")},this.ctx.user.data.isAdmin||s.classList.add("atk-hide"),e.appendChild(s),Y(this.$el,e)}else this.readMoreBtn?.showErr("\u83B7\u53D6\u5931\u8D25")}refreshUI(){const t=this.comments.length<=0;let e=this.$commentsWrap.querySelector(".atk-list-no-comment");t&&(e||(e=m('<div class="atk-list-no-comment"></div>'),this.$commentsWrap.appendChild(e),e.innerHTML=this.noCommentText)),!t&&e&&e.remove(),this.ctx.trigger("check-admin-show-el")}createComment(t){const e=new ae(this.ctx,t);return e.afterRender=()=>{this.renderComment&&this.renderComment(e)},e.onDelete=i=>{this.deleteComment(i),this.refreshUI()},e}importComments(t){const e=i=>{const s=t.filter(n=>n.rid===i.data.id);s.length!==0&&s.forEach(n=>{n.is_allow_reply=i.data.is_allow_reply;const o=this.createComment(n);o.render(),i.putChild(o),e(o)})};this.flatMode?t.forEach(i=>{this.putCommentFlatMode(i,t,"append")}):t.filter(i=>i.rid===0).forEach(i=>{i.is_collapsed&&(i.is_allow_reply=!1);const s=this.createComment(i);s.render(),this.comments.push(s),this.$commentsWrap.appendChild(s.getEl()),s.playFadeInAnim(),e(s)}),this.eachComment(this.comments,i=>{this.checkMoreHide(i)}),this.refreshUI(),this.ctx.trigger("comments-loaded")}putCommentFlatMode(t,e,i){t.is_collapsed&&(t.is_allow_reply=!1);const s=this.createComment(t);if(t.rid!==0){const n=e.find(o=>o.id===t.rid);n&&(s.replyTo=n)}s.render(),i==="append"?this.comments.push(s):this.comments.unshift(s),t.visible&&(i==="append"?this.$commentsWrap.appendChild(s.getEl()):this.$commentsWrap.prepend(s.getEl()),s.playFadeInAnim()),this.checkMoreHide(s)}insertComment(t){if(this.flatMode)this.putCommentFlatMode(t,this.comments.map(e=>e.data),"prepend");else{const e=this.createComment(t);e.render(),t.rid!==0?this.findComment(t.rid)?.putChild(e):(this.$commentsWrap.prepend(e.getEl()),this.comments.unshift(e)),lt(e.getEl()),e.playFadeInAnim(),this.checkMoreHide(e)}this.data&&(this.data.total+=1),this.refreshUI(),this.ctx.trigger("comments-loaded")}checkMoreHide(t){const e=this.ctx.conf.heightLimit?.children,i=this.ctx.conf.heightLimit?.content,s=typeof e=="number"&&e>0,n=typeof i=="number"&&i>0;s&&t.getIsRoot()&&t.checkMoreHide(t.$children,e||300),n&&(t.checkMoreHide(t.$content,i||200),t.$replyTo&&t.checkMoreHide(t.$replyTo,i||200))}get commentsCount(){let t=0;return this.eachComment(this.comments,()=>{t++}),t}get hasMoreComments(){return this.data?this.data.total_parents>this.offset+this.pageSize:!1}get parentCommentsCount(){return this.comments.length}eachComment(t,e){t.length!==0&&t.every(i=>e(i,t)===!1?!1:(this.eachComment(i.getChildren(),e),!0))}findComment(t,e){e||(e=this.comments);let i=null;return this.eachComment(e,s=>s.data.id===t?(i=s,!1):!0),i}getCommentCount(){let t=0;return this.eachComment(this.comments,()=>{t++}),t}deleteComment(t){let e;if(typeof t=="number"){if(e=this.findComment(t),!e)throw Error(`\u672A\u627E\u5230\u8BC4\u8BBA ${t}`)}else e=t;e.getEl().remove(),this.eachComment(this.comments,(i,s)=>i===e?(s.splice(s.indexOf(i),1),!1):!0),this.refreshUI()}clearAllComments(){this.$commentsWrap.innerHTML="",this.data=void 0,this.comments=[]}updateUnread(t){this.unread=t,this.unreadHighlight&&this.eachComment(this.comments,e=>{const i=this.unread.find(s=>s.comment_id===e.data.id);i?(e.setUnread(!0),e.setOpenURL(i.read_link),e.openEvt=()=>{this.unread=this.unread.filter(s=>s.comment_id!==e.data.id),this.ctx.trigger("unread-update",{notifies:this.unread})}):e.setUnread(!1)})}apiVersionCheck(t){const e=t?.fe_min_version||"0.0.0",i=Nt(e,"2.1.0")===1;if(i){const s=m(`<div>\u524D\u7AEF Artalk \u7248\u672C\u5DF2\u8FC7\u65F6\uFF0C\u8BF7\u66F4\u65B0\u4EE5\u83B7\u5F97\u5B8C\u6574\u4F53\u9A8C<br/>\u82E5\u60A8\u662F\u7AD9\u70B9\u7BA1\u7406\u5458\uFF0C\u8BF7\u524D\u5F80 \u201C<a href="https://artalk.js.org/" target="_blank">\u5B98\u65B9\u6587\u6863</a>\u201D \u83B7\u53D6\u5E2E\u52A9<br/><br/><span style="color: var(--at-color-meta);">\u524D\u7AEF\u7248\u672C 2.1.0\uFF0C\u9700\u6C42\u7248\u672C >= ${e}</span><br/><br/></div>`),n=m('<span style="cursor:pointer;">\u5FFD\u7565</span>');n.onclick=()=>{Y(this.ctx,null),this.ctx.conf.versionCheck=!1,this.reqComments(0)},s.append(n),Y(this.ctx,s,'<span class="atk-warn-title">Artalk Warn</span>')}return i}}class oe extends Ft{$closeCommentBtn;$openSidebarBtn;$unreadBadge;constructor(t){const e=m(ie);super(t,e);e.querySelector(".atk-list-body").append(this.$el),this.$el=e;let i=!1;this.ctx.conf.flatMode==="auto"?window.matchMedia("(max-width: 768px)").matches&&(i=!0):this.ctx.conf.flatMode===!0&&(i=!0),this.flatMode=i,this.pageMode=this.conf.pagination?.readMore?"read-more":"pagination",this.initListActionBtn(),this.$el.querySelector(".atk-copyright").innerHTML='Powered By <a href="https://artalk.js.org" target="_blank" title="Artalk v2.1.0">Artalk</a>',this.ctx.on("list-reload",()=>this.reqComments(0)),this.ctx.on("list-refresh-ui",()=>this.refreshUI()),this.ctx.on("list-import",s=>this.importComments(s)),this.ctx.on("list-insert",s=>this.insertComment(s)),this.ctx.on("list-delete",s=>this.deleteComment(s.id)),this.ctx.on("list-update",s=>{s(this.data),this.refreshUI()}),this.ctx.on("unread-update",s=>this.showUnreadBadge(s.notifies?.length||0))}initListActionBtn(){this.$openSidebarBtn=this.$el.querySelector('[data-action="open-sidebar"]'),this.$closeCommentBtn=this.$el.querySelector('[data-action="admin-close-comment"]'),this.$unreadBadge=this.$el.querySelector(".atk-unread-badge"),this.$openSidebarBtn.addEventListener("click",()=>{this.ctx.trigger("sidebar-show")}),this.$closeCommentBtn.addEventListener("click",()=>{!this.data||(this.data.page.admin_only=!this.data.page.admin_only,this.adminPageEditSave())})}refreshUI(){super.refreshUI(),this.$el.querySelector(".atk-comment-count-num").innerText=String(this.commentsCount),!!this.ctx.user.data.nick&&!!this.ctx.user.data.email?this.$openSidebarBtn.classList.remove("atk-hide"):this.$openSidebarBtn.classList.add("atk-hide"),this.ctx.trigger("check-admin-show-el"),this.$openSidebarBtn.innerText=this.ctx.user.data.isAdmin?"\u63A7\u5236\u4E2D\u5FC3":"\u901A\u77E5\u4E2D\u5FC3",!!this.data&&!!this.data.page&&this.data.page.admin_only===!0?(this.ctx.trigger("editor-close"),this.$closeCommentBtn.innerHTML="\u6253\u5F00\u8BC4\u8BBA"):(this.ctx.trigger("editor-open"),this.$closeCommentBtn.innerHTML="\u5173\u95ED\u8BC4\u8BBA")}onLoad(t,e){super.onLoad(t,e),this.checkGoToCommentByUrlHash()}async checkGoToCommentByUrlHash(){let t=Number(wt("atk_comment"));if(!t){const s=window.location.hash.match(/#atk-comment-([0-9]+)/);if(!s||!s[1]||Number.isNaN(Number(s[1])))return;t=Number(s[1])}if(!t)return;const e=wt("atk_notify_key");e&&new B(this.ctx).markRead(e).then(()=>{this.unread=this.unread.filter(s=>s.comment_id!==t),this.ctx.trigger("unread-update",{notifies:this.unread})});const i=this.findComment(t);!i||(lt(i.getEl(),!1),window.setTimeout(()=>{i.getEl().classList.add("atk-flash-once")},800))}adminPageEditSave(){!this.data||!this.data.page||(this.ctx.trigger("editor-show-loading"),new B(this.ctx).pageEdit(this.data.page).then(t=>{this.data&&(this.data.page={...t}),this.refreshUI()}).catch(t=>{this.ctx.trigger("editor-notify",{msg:`\u4FEE\u6539\u9875\u9762\u6570\u636E\u5931\u8D25\uFF1A${t.msg||String(t)}`,type:"e"})}).finally(()=>{this.ctx.trigger("editor-hide-loading")}))}showUnreadBadge(t){t>0?(this.$unreadBadge.innerText=`${Number(t||0)}`,this.$unreadBadge.style.display="block"):this.$unreadBadge.style.display="none"}}var Fe="",le=function(r){var t=ce(ue(de(he(r),8*r.length)));return t.toLowerCase()};function ce(r){for(var t,e="0123456789ABCDEF",i="",s=0;s<r.length;s++)t=r.charCodeAt(s),i+=e.charAt(t>>>4&15)+e.charAt(15&t);return i}function he(r){for(var t=Array(r.length>>2),e=0;e<t.length;e++)t[e]=0;for(e=0;e<8*r.length;e+=8)t[e>>5]|=(255&r.charCodeAt(e/8))<<e%32;return t}function ue(r){for(var t="",e=0;e<32*r.length;e+=8)t+=String.fromCharCode(r[e>>5]>>>e%32&255);return t}function de(r,t){r[t>>5]|=128<<t%32,r[14+(t+64>>>9<<4)]=t;for(var e=1732584193,i=-271733879,s=-1732584194,n=271733878,o=0;o<r.length;o+=16){var p=e,f=i,$=s,b=n;i=R(i=R(i=R(i=R(i=O(i=O(i=O(i=O(i=M(i=M(i=M(i=M(i=D(i=D(i=D(i=D(i,s=D(s,n=D(n,e=D(e,i,s,n,r[o+0],7,-680876936),i,s,r[o+1],12,-389564586),e,i,r[o+2],17,606105819),n,e,r[o+3],22,-1044525330),s=D(s,n=D(n,e=D(e,i,s,n,r[o+4],7,-176418897),i,s,r[o+5],12,1200080426),e,i,r[o+6],17,-1473231341),n,e,r[o+7],22,-45705983),s=D(s,n=D(n,e=D(e,i,s,n,r[o+8],7,1770035416),i,s,r[o+9],12,-1958414417),e,i,r[o+10],17,-42063),n,e,r[o+11],22,-1990404162),s=D(s,n=D(n,e=D(e,i,s,n,r[o+12],7,1804603682),i,s,r[o+13],12,-40341101),e,i,r[o+14],17,-1502002290),n,e,r[o+15],22,1236535329),s=M(s,n=M(n,e=M(e,i,s,n,r[o+1],5,-165796510),i,s,r[o+6],9,-1069501632),e,i,r[o+11],14,643717713),n,e,r[o+0],20,-373897302),s=M(s,n=M(n,e=M(e,i,s,n,r[o+5],5,-701558691),i,s,r[o+10],9,38016083),e,i,r[o+15],14,-660478335),n,e,r[o+4],20,-405537848),s=M(s,n=M(n,e=M(e,i,s,n,r[o+9],5,568446438),i,s,r[o+14],9,-1019803690),e,i,r[o+3],14,-187363961),n,e,r[o+8],20,1163531501),s=M(s,n=M(n,e=M(e,i,s,n,r[o+13],5,-1444681467),i,s,r[o+2],9,-51403784),e,i,r[o+7],14,1735328473),n,e,r[o+12],20,-1926607734),s=O(s,n=O(n,e=O(e,i,s,n,r[o+5],4,-378558),i,s,r[o+8],11,-2022574463),e,i,r[o+11],16,1839030562),n,e,r[o+14],23,-35309556),s=O(s,n=O(n,e=O(e,i,s,n,r[o+1],4,-1530992060),i,s,r[o+4],11,1272893353),e,i,r[o+7],16,-155497632),n,e,r[o+10],23,-1094730640),s=O(s,n=O(n,e=O(e,i,s,n,r[o+13],4,681279174),i,s,r[o+0],11,-358537222),e,i,r[o+3],16,-722521979),n,e,r[o+6],23,76029189),s=O(s,n=O(n,e=O(e,i,s,n,r[o+9],4,-640364487),i,s,r[o+12],11,-421815835),e,i,r[o+15],16,530742520),n,e,r[o+2],23,-995338651),s=R(s,n=R(n,e=R(e,i,s,n,r[o+0],6,-198630844),i,s,r[o+7],10,1126891415),e,i,r[o+14],15,-1416354905),n,e,r[o+5],21,-57434055),s=R(s,n=R(n,e=R(e,i,s,n,r[o+12],6,1700485571),i,s,r[o+3],10,-1894986606),e,i,r[o+10],15,-1051523),n,e,r[o+1],21,-2054922799),s=R(s,n=R(n,e=R(e,i,s,n,r[o+8],6,1873313359),i,s,r[o+15],10,-30611744),e,i,r[o+6],15,-1560198380),n,e,r[o+13],21,1309151649),s=R(s,n=R(n,e=R(e,i,s,n,r[o+4],6,-145523070),i,s,r[o+11],10,-1120210379),e,i,r[o+2],15,718787259),n,e,r[o+9],21,-343485551),e=V(e,p),i=V(i,f),s=V(s,$),n=V(n,b)}return Array(e,i,s,n)}function st(r,t,e,i,s,n){return V(pe(V(V(t,r),V(i,n)),s),e)}function D(r,t,e,i,s,n,o){return st(t&e|~t&i,r,t,s,n,o)}function M(r,t,e,i,s,n,o){return st(t&i|e&~i,r,t,s,n,o)}function O(r,t,e,i,s,n,o){return st(t^e^i,r,t,s,n,o)}function R(r,t,e,i,s,n,o){return st(e^(t|~i),r,t,s,n,o)}function V(r,t){var e=(65535&r)+(65535&t);return(r>>16)+(t>>16)+(e>>16)<<16|65535&e}function pe(r,t){return r<<t|r>>>32-t}var fe=`<div class="atk-sidebar">
126
+ </div>`),this.$commentsWrap=this.$el.querySelector(".atk-list-comments-wrap"),this.pageSize=this.conf.pagination?this.conf.pagination.pageSize||this.pageSize:this.pageSize,this.noCommentText=this.conf.noComment||"\u65E0\u8BC4\u8BBA",window.setInterval(()=>{this.$el.querySelectorAll("[data-atk-comment-date]").forEach(i=>{const s=i.getAttribute("data-atk-comment-date");i.innerText=bt(new Date(Number(s)))})},30*1e3),this.ctx.on("unread-update",i=>this.updateUnread(i.notifies))}async reqComments(t=0){t===0&&this.pageMode!=="pagination"&&this.clearAllComments();const e=()=>{this.isLoading=!0,t===0?I(this.$el):this.pageMode==="read-more"?this.readMoreBtn.setLoading(!0):this.pageMode==="pagination"&&this.pagination.setLoading(!0)},i=()=>{this.isLoading=!1,t===0?P(this.$el):this.pageMode==="read-more"?this.readMoreBtn.setLoading(!1):this.pageMode==="pagination"&&this.pagination.setLoading(!1)};e(),this.ctx.trigger("comments-load");let s;try{s=await new B(this.ctx).get(t,this.type,this.flatMode,this.paramsEditor)}catch(n){throw this.onError(n.msg||String(n)),n}finally{i()}if(!(this.ctx.conf.versionCheck&&this.apiVersionCheck(s.api_version||{}))){this.offset=t;try{this.onLoad(s,t),this.onAfterLoad&&this.onAfterLoad(s)}catch(n){throw this.onError(String(n)),n}finally{i()}}}onLoad(t,e){Y(this.$el,null),this.pageMode==="pagination"&&this.clearAllComments(),this.data=t,this.importComments(t.comments),this.isFirstLoad&&this.onLoadInit(),this.pageMode==="pagination"&&this.pagination.update(e,this.data?.total_parents||0),this.pageMode==="read-more"&&(this.hasMoreComments?this.readMoreBtn.show():this.readMoreBtn.hide()),this.ctx.trigger("unread-update",{notifies:t.unread||[]}),this.isFirstLoad=!1}onLoadInit(){if(this.autoLoadScrollEvent&&(this.autoLoadListenerAt||document).removeEventListener("scroll",this.autoLoadScrollEvent),this.pageMode==="read-more"){const t=new re({pageSize:this.pageSize,total:0,onClick:async()=>{const e=this.offset+this.pageSize;await this.reqComments(e)}});this.readMoreBtn?this.readMoreBtn.$el.replaceWith(t.$el):this.$el.append(t.$el),this.readMoreBtn=t,this.conf.pagination?.autoLoad&&(this.autoLoadScrollEvent=()=>{if(this.pageMode!=="read-more"||!this.hasMoreComments||this.isLoading)return;const i=this.$el.querySelector(".atk-list-comments-wrap > .atk-comment-wrap:nth-last-child(3)");!i||Ht(i,this.autoLoadListenerAt)&&this.readMoreBtn.click()},(this.autoLoadListenerAt||document).addEventListener("scroll",this.autoLoadScrollEvent))}else if(this.pageMode==="pagination"){const t=new Lt(this.parentCommentsCount,{pageSize:this.pageSize,onChange:async e=>{if(await this.reqComments(e),this.$parent){let i=0;!this.autoLoadListenerAt&&this.$parent&&(i=xt(this.$parent).top),(this.autoLoadListenerAt||window).scroll({top:i,left:0})}}});this.pagination?this.pagination.$el.replaceWith(t.$el):this.$el.append(t.$el),this.pagination=t}}onError(t){if(t=String(t),console.error(t),this.isFirstLoad||this.pageMode==="pagination"){const e=m(`<span>${t}\uFF0C\u65E0\u6CD5\u83B7\u53D6\u8BC4\u8BBA\u5217\u8868\u6570\u636E<br/></span>`),i=m('<span style="cursor:pointer;">\u70B9\u51FB\u91CD\u65B0\u83B7\u53D6</span>');i.onclick=()=>{this.reqComments(this.offset)},e.appendChild(i);const s=m('<span atk-only-admin-show> | <span style="cursor:pointer;">\u6253\u5F00\u63A7\u5236\u53F0</span></span>');s.onclick=()=>{this.ctx.trigger("sidebar-show")},this.ctx.user.data.isAdmin||s.classList.add("atk-hide"),e.appendChild(s),Y(this.$el,e)}else this.readMoreBtn?.showErr("\u83B7\u53D6\u5931\u8D25")}refreshUI(){const t=this.comments.length<=0;let e=this.$commentsWrap.querySelector(".atk-list-no-comment");t&&(e||(e=m('<div class="atk-list-no-comment"></div>'),this.$commentsWrap.appendChild(e),e.innerHTML=this.noCommentText)),!t&&e&&e.remove(),this.ctx.trigger("check-admin-show-el")}createComment(t){const e=new ae(this.ctx,t);return e.afterRender=()=>{this.renderComment&&this.renderComment(e)},e.onDelete=i=>{this.deleteComment(i),this.refreshUI()},e}importComments(t){const e=i=>{const s=t.filter(n=>n.rid===i.data.id);s.length!==0&&s.forEach(n=>{n.is_allow_reply=i.data.is_allow_reply;const o=this.createComment(n);o.render(),i.putChild(o),e(o)})};this.flatMode?t.forEach(i=>{this.putCommentFlatMode(i,t,"append")}):t.filter(i=>i.rid===0).forEach(i=>{i.is_collapsed&&(i.is_allow_reply=!1);const s=this.createComment(i);s.render(),this.comments.push(s),this.$commentsWrap.appendChild(s.getEl()),s.playFadeInAnim(),e(s)}),this.eachComment(this.comments,i=>{this.checkMoreHide(i)}),this.refreshUI(),this.ctx.trigger("comments-loaded")}putCommentFlatMode(t,e,i){t.is_collapsed&&(t.is_allow_reply=!1);const s=this.createComment(t);if(t.rid!==0){const n=e.find(o=>o.id===t.rid);n&&(s.replyTo=n)}s.render(),i==="append"?this.comments.push(s):this.comments.unshift(s),t.visible&&(i==="append"?this.$commentsWrap.appendChild(s.getEl()):this.$commentsWrap.prepend(s.getEl()),s.playFadeInAnim()),this.checkMoreHide(s)}insertComment(t){if(this.flatMode)this.putCommentFlatMode(t,this.comments.map(e=>e.data),"prepend");else{const e=this.createComment(t);e.render(),t.rid!==0?this.findComment(t.rid)?.putChild(e):(this.$commentsWrap.prepend(e.getEl()),this.comments.unshift(e)),lt(e.getEl()),e.playFadeInAnim(),this.checkMoreHide(e)}this.data&&(this.data.total+=1),this.refreshUI(),this.ctx.trigger("comments-loaded")}checkMoreHide(t){const e=this.ctx.conf.heightLimit?.children,i=this.ctx.conf.heightLimit?.content,s=typeof e=="number"&&e>0,n=typeof i=="number"&&i>0;s&&t.getIsRoot()&&t.checkMoreHide(t.$children,e||300),n&&(t.checkMoreHide(t.$content,i||200),t.$replyTo&&t.checkMoreHide(t.$replyTo,i||200))}get commentsCount(){return Number(this.data?.total)||0}get parentCommentsCount(){return Number(this.data?.total_parents)||0}get hasMoreComments(){return this.data?this.data.total_parents>this.offset+this.pageSize:!1}eachComment(t,e){t.length!==0&&t.every(i=>e(i,t)===!1?!1:(this.eachComment(i.getChildren(),e),!0))}findComment(t,e){e||(e=this.comments);let i=null;return this.eachComment(e,s=>s.data.id===t?(i=s,!1):!0),i}getCommentCount(){let t=0;return this.eachComment(this.comments,()=>{t++}),t}deleteComment(t){let e;if(typeof t=="number"){if(e=this.findComment(t),!e)throw Error(`\u672A\u627E\u5230\u8BC4\u8BBA ${t}`)}else e=t;e.getEl().remove(),this.eachComment(this.comments,(i,s)=>i===e?(s.splice(s.indexOf(i),1),!1):!0),this.refreshUI()}clearAllComments(){this.$commentsWrap.innerHTML="",this.data=void 0,this.comments=[]}updateUnread(t){this.unread=t,this.unreadHighlight&&this.eachComment(this.comments,e=>{const i=this.unread.find(s=>s.comment_id===e.data.id);i?(e.setUnread(!0),e.setOpenURL(i.read_link),e.openEvt=()=>{this.unread=this.unread.filter(s=>s.comment_id!==e.data.id),this.ctx.trigger("unread-update",{notifies:this.unread})}):e.setUnread(!1)})}apiVersionCheck(t){const e=t?.fe_min_version||"0.0.0",i=Nt(e,"2.1.1")===1;if(i){const s=m(`<div>\u524D\u7AEF Artalk \u7248\u672C\u5DF2\u8FC7\u65F6\uFF0C\u8BF7\u66F4\u65B0\u4EE5\u83B7\u5F97\u5B8C\u6574\u4F53\u9A8C<br/>\u82E5\u60A8\u662F\u7AD9\u70B9\u7BA1\u7406\u5458\uFF0C\u8BF7\u524D\u5F80 \u201C<a href="https://artalk.js.org/" target="_blank">\u5B98\u65B9\u6587\u6863</a>\u201D \u83B7\u53D6\u5E2E\u52A9<br/><br/><span style="color: var(--at-color-meta);">\u524D\u7AEF\u7248\u672C 2.1.1\uFF0C\u9700\u6C42\u7248\u672C >= ${e}</span><br/><br/></div>`),n=m('<span style="cursor:pointer;">\u5FFD\u7565</span>');n.onclick=()=>{Y(this.ctx,null),this.ctx.conf.versionCheck=!1,this.reqComments(0)},s.append(n),Y(this.ctx,s,'<span class="atk-warn-title">Artalk Warn</span>')}return i}}class oe extends Ft{$closeCommentBtn;$openSidebarBtn;$unreadBadge;constructor(t){const e=m(ie);super(t,e);e.querySelector(".atk-list-body").append(this.$el),this.$el=e;let i=!1;this.ctx.conf.flatMode==="auto"?window.matchMedia("(max-width: 768px)").matches&&(i=!0):this.ctx.conf.flatMode===!0&&(i=!0),this.flatMode=i,this.pageMode=this.conf.pagination?.readMore?"read-more":"pagination",this.initListActionBtn(),this.$el.querySelector(".atk-copyright").innerHTML='Powered By <a href="https://artalk.js.org" target="_blank" title="Artalk v2.1.1">Artalk</a>',this.ctx.on("list-reload",()=>this.reqComments(0)),this.ctx.on("list-refresh-ui",()=>this.refreshUI()),this.ctx.on("list-import",s=>this.importComments(s)),this.ctx.on("list-insert",s=>this.insertComment(s)),this.ctx.on("list-delete",s=>this.deleteComment(s.id)),this.ctx.on("list-update",s=>{s(this.data),this.refreshUI()}),this.ctx.on("unread-update",s=>this.showUnreadBadge(s.notifies?.length||0))}initListActionBtn(){this.$openSidebarBtn=this.$el.querySelector('[data-action="open-sidebar"]'),this.$closeCommentBtn=this.$el.querySelector('[data-action="admin-close-comment"]'),this.$unreadBadge=this.$el.querySelector(".atk-unread-badge"),this.$openSidebarBtn.addEventListener("click",()=>{this.ctx.trigger("sidebar-show")}),this.$closeCommentBtn.addEventListener("click",()=>{!this.data||(this.data.page.admin_only=!this.data.page.admin_only,this.adminPageEditSave())})}refreshUI(){super.refreshUI(),this.$el.querySelector(".atk-comment-count-num").innerText=String(this.commentsCount),!!this.ctx.user.data.nick&&!!this.ctx.user.data.email?this.$openSidebarBtn.classList.remove("atk-hide"):this.$openSidebarBtn.classList.add("atk-hide"),this.ctx.trigger("check-admin-show-el"),this.$openSidebarBtn.innerText=this.ctx.user.data.isAdmin?"\u63A7\u5236\u4E2D\u5FC3":"\u901A\u77E5\u4E2D\u5FC3",!!this.data&&!!this.data.page&&this.data.page.admin_only===!0?(this.ctx.trigger("editor-close"),this.$closeCommentBtn.innerHTML="\u6253\u5F00\u8BC4\u8BBA"):(this.ctx.trigger("editor-open"),this.$closeCommentBtn.innerHTML="\u5173\u95ED\u8BC4\u8BBA")}onLoad(t,e){super.onLoad(t,e),this.checkGoToCommentByUrlHash()}async checkGoToCommentByUrlHash(){let t=Number(wt("atk_comment"));if(!t){const s=window.location.hash.match(/#atk-comment-([0-9]+)/);if(!s||!s[1]||Number.isNaN(Number(s[1])))return;t=Number(s[1])}if(!t)return;const e=wt("atk_notify_key");e&&new B(this.ctx).markRead(e).then(()=>{this.unread=this.unread.filter(s=>s.comment_id!==t),this.ctx.trigger("unread-update",{notifies:this.unread})});const i=this.findComment(t);!i||(lt(i.getEl(),!1),window.setTimeout(()=>{i.getEl().classList.add("atk-flash-once")},800))}adminPageEditSave(){!this.data||!this.data.page||(this.ctx.trigger("editor-show-loading"),new B(this.ctx).pageEdit(this.data.page).then(t=>{this.data&&(this.data.page={...t}),this.refreshUI()}).catch(t=>{this.ctx.trigger("editor-notify",{msg:`\u4FEE\u6539\u9875\u9762\u6570\u636E\u5931\u8D25\uFF1A${t.msg||String(t)}`,type:"e"})}).finally(()=>{this.ctx.trigger("editor-hide-loading")}))}showUnreadBadge(t){t>0?(this.$unreadBadge.innerText=`${Number(t||0)}`,this.$unreadBadge.style.display="block"):this.$unreadBadge.style.display="none"}}var Fe="",le=function(r){var t=ce(ue(de(he(r),8*r.length)));return t.toLowerCase()};function ce(r){for(var t,e="0123456789ABCDEF",i="",s=0;s<r.length;s++)t=r.charCodeAt(s),i+=e.charAt(t>>>4&15)+e.charAt(15&t);return i}function he(r){for(var t=Array(r.length>>2),e=0;e<t.length;e++)t[e]=0;for(e=0;e<8*r.length;e+=8)t[e>>5]|=(255&r.charCodeAt(e/8))<<e%32;return t}function ue(r){for(var t="",e=0;e<32*r.length;e+=8)t+=String.fromCharCode(r[e>>5]>>>e%32&255);return t}function de(r,t){r[t>>5]|=128<<t%32,r[14+(t+64>>>9<<4)]=t;for(var e=1732584193,i=-271733879,s=-1732584194,n=271733878,o=0;o<r.length;o+=16){var p=e,f=i,$=s,b=n;i=R(i=R(i=R(i=R(i=O(i=O(i=O(i=O(i=M(i=M(i=M(i=M(i=D(i=D(i=D(i=D(i,s=D(s,n=D(n,e=D(e,i,s,n,r[o+0],7,-680876936),i,s,r[o+1],12,-389564586),e,i,r[o+2],17,606105819),n,e,r[o+3],22,-1044525330),s=D(s,n=D(n,e=D(e,i,s,n,r[o+4],7,-176418897),i,s,r[o+5],12,1200080426),e,i,r[o+6],17,-1473231341),n,e,r[o+7],22,-45705983),s=D(s,n=D(n,e=D(e,i,s,n,r[o+8],7,1770035416),i,s,r[o+9],12,-1958414417),e,i,r[o+10],17,-42063),n,e,r[o+11],22,-1990404162),s=D(s,n=D(n,e=D(e,i,s,n,r[o+12],7,1804603682),i,s,r[o+13],12,-40341101),e,i,r[o+14],17,-1502002290),n,e,r[o+15],22,1236535329),s=M(s,n=M(n,e=M(e,i,s,n,r[o+1],5,-165796510),i,s,r[o+6],9,-1069501632),e,i,r[o+11],14,643717713),n,e,r[o+0],20,-373897302),s=M(s,n=M(n,e=M(e,i,s,n,r[o+5],5,-701558691),i,s,r[o+10],9,38016083),e,i,r[o+15],14,-660478335),n,e,r[o+4],20,-405537848),s=M(s,n=M(n,e=M(e,i,s,n,r[o+9],5,568446438),i,s,r[o+14],9,-1019803690),e,i,r[o+3],14,-187363961),n,e,r[o+8],20,1163531501),s=M(s,n=M(n,e=M(e,i,s,n,r[o+13],5,-1444681467),i,s,r[o+2],9,-51403784),e,i,r[o+7],14,1735328473),n,e,r[o+12],20,-1926607734),s=O(s,n=O(n,e=O(e,i,s,n,r[o+5],4,-378558),i,s,r[o+8],11,-2022574463),e,i,r[o+11],16,1839030562),n,e,r[o+14],23,-35309556),s=O(s,n=O(n,e=O(e,i,s,n,r[o+1],4,-1530992060),i,s,r[o+4],11,1272893353),e,i,r[o+7],16,-155497632),n,e,r[o+10],23,-1094730640),s=O(s,n=O(n,e=O(e,i,s,n,r[o+13],4,681279174),i,s,r[o+0],11,-358537222),e,i,r[o+3],16,-722521979),n,e,r[o+6],23,76029189),s=O(s,n=O(n,e=O(e,i,s,n,r[o+9],4,-640364487),i,s,r[o+12],11,-421815835),e,i,r[o+15],16,530742520),n,e,r[o+2],23,-995338651),s=R(s,n=R(n,e=R(e,i,s,n,r[o+0],6,-198630844),i,s,r[o+7],10,1126891415),e,i,r[o+14],15,-1416354905),n,e,r[o+5],21,-57434055),s=R(s,n=R(n,e=R(e,i,s,n,r[o+12],6,1700485571),i,s,r[o+3],10,-1894986606),e,i,r[o+10],15,-1051523),n,e,r[o+1],21,-2054922799),s=R(s,n=R(n,e=R(e,i,s,n,r[o+8],6,1873313359),i,s,r[o+15],10,-30611744),e,i,r[o+6],15,-1560198380),n,e,r[o+13],21,1309151649),s=R(s,n=R(n,e=R(e,i,s,n,r[o+4],6,-145523070),i,s,r[o+11],10,-1120210379),e,i,r[o+2],15,718787259),n,e,r[o+9],21,-343485551),e=V(e,p),i=V(i,f),s=V(s,$),n=V(n,b)}return Array(e,i,s,n)}function st(r,t,e,i,s,n){return V(pe(V(V(t,r),V(i,n)),s),e)}function D(r,t,e,i,s,n,o){return st(t&e|~t&i,r,t,s,n,o)}function M(r,t,e,i,s,n,o){return st(t&i|e&~i,r,t,s,n,o)}function O(r,t,e,i,s,n,o){return st(t^e^i,r,t,s,n,o)}function R(r,t,e,i,s,n,o){return st(e^(t|~i),r,t,s,n,o)}function V(r,t){var e=(65535&r)+(65535&t);return(r>>16)+(t>>16)+(e>>16)<<16|65535&e}function pe(r,t){return r<<t|r>>>32-t}var fe=`<div class="atk-sidebar">
127
127
  <div class="atk-sidebar-inner">
128
128
  <div class="atk-sidebar-header">
129
129
  <span class="atk-avatar">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "artalk",
3
- "version": "2.1.0",
3
+ "version": "2.1.1",
4
4
  "description": "A Selfhosted Comment System",
5
5
  "keywords": [
6
6
  "comment-system",
@@ -387,9 +387,11 @@ export default class ListLite extends Component {
387
387
 
388
388
  /** 获取评论总数 (包括子评论) */
389
389
  get commentsCount(): number {
390
- let count = 0
391
- this.eachComment(this.comments, () => { count++ })
392
- return count
390
+ return Number(this.data?.total) || 0
391
+ }
392
+
393
+ get parentCommentsCount() {
394
+ return Number(this.data?.total_parents) || 0
393
395
  }
394
396
 
395
397
  /** 是否还有更多的评论 */
@@ -398,10 +400,6 @@ export default class ListLite extends Component {
398
400
  return this.data.total_parents > (this.offset + this.pageSize)
399
401
  }
400
402
 
401
- get parentCommentsCount() {
402
- return this.comments.length
403
- }
404
-
405
403
  /** 遍历操作 Comment (包括子评论) */
406
404
  public eachComment(commentList: Comment[], action: (comment: Comment, levelList: Comment[]) => boolean|void) {
407
405
  if (commentList.length === 0) return