artalk 2.9.1 → 2.10.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.cjs +2 -11
- package/dist/Artalk.cjs.map +1 -1
- package/dist/Artalk.css +2 -1
- package/dist/Artalk.iife.js +2 -11
- package/dist/Artalk.iife.js.map +1 -1
- package/dist/Artalk.js +2 -11
- package/dist/Artalk.js.map +1 -1
- package/dist/Artalk.mjs +4 -9419
- package/dist/Artalk.mjs.map +1 -1
- package/dist/ArtalkLite.cjs +2 -11
- package/dist/ArtalkLite.cjs.map +1 -1
- package/dist/ArtalkLite.css +2 -1
- package/dist/ArtalkLite.d.cts +3343 -0
- package/dist/ArtalkLite.d.ts +3343 -0
- package/dist/ArtalkLite.iife.js +2 -11
- package/dist/ArtalkLite.iife.js.map +1 -1
- package/dist/ArtalkLite.js +2 -11
- package/dist/ArtalkLite.js.map +1 -1
- package/dist/ArtalkLite.mjs +4 -7354
- package/dist/ArtalkLite.mjs.map +1 -1
- package/dist/i18n/fr.cjs +1 -1
- package/dist/i18n/fr.js +1 -1
- package/dist/i18n/fr.mjs +1 -123
- package/dist/i18n/ja.cjs +1 -1
- package/dist/i18n/ja.js +1 -1
- package/dist/i18n/ja.mjs +1 -123
- package/dist/i18n/ko.cjs +1 -1
- package/dist/i18n/ko.js +1 -1
- package/dist/i18n/ko.mjs +1 -123
- package/dist/i18n/ru.cjs +1 -1
- package/dist/i18n/ru.js +1 -1
- package/dist/i18n/ru.mjs +1 -123
- package/dist/i18n/tr.cjs +1 -0
- package/dist/i18n/tr.d.cts +3 -0
- package/dist/i18n/tr.d.ts +3 -0
- package/dist/i18n/tr.js +1 -0
- package/dist/i18n/tr.mjs +1 -0
- package/dist/i18n/zh-TW.cjs +1 -1
- package/dist/i18n/zh-TW.js +1 -1
- package/dist/i18n/zh-TW.mjs +1 -115
- package/dist/main.d.cts +591 -423
- package/dist/main.d.ts +591 -423
- package/package.json +57 -47
package/dist/ArtalkLite.js
CHANGED
|
@@ -1,11 +1,2 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("marked")):"function"==typeof define&&define.amd?define(["exports","marked"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Artalk={},t.marked)}(this,(function(t,e){"use strict";var s=Object.defineProperty,n=Object.defineProperties,i=Object.getOwnPropertyDescriptors,o=Object.getOwnPropertySymbols,a=Object.prototype.hasOwnProperty,r=Object.prototype.propertyIsEnumerable,l=(t,e,n)=>e in t?s(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,c=(t,e)=>{for(var s in e||(e={}))a.call(e,s)&&l(t,s,e[s]);if(o)for(var s of o(e))r.call(e,s)&&l(t,s,e[s]);return t},d=(t,e)=>n(t,i(e)),h=(t,e,s)=>l(t,"symbol"!=typeof e?e+"":e,s),u=(t,e,s)=>new Promise(((n,i)=>{var o=t=>{try{r(s.next(t))}catch(e){i(e)}},a=t=>{try{r(s.throw(t))}catch(e){i(e)}},r=t=>t.done?n(t.value):Promise.resolve(t.value).then(o,a);r((s=s.apply(t,e)).next())}));class p{constructor(t={}){h(this,"baseUrl","/api/v2"),h(this,"securityData",null),h(this,"securityWorker"),h(this,"abortControllers",new Map),h(this,"customFetch",((...t)=>fetch(...t))),h(this,"baseApiParams",{credentials:"same-origin",headers:{},redirect:"follow",referrerPolicy:"no-referrer"}),h(this,"setSecurityData",(t=>{this.securityData=t})),h(this,"contentFormatters",{"application/json":t=>null===t||"object"!=typeof t&&"string"!=typeof t?t:JSON.stringify(t),"text/plain":t=>null!==t&&"string"!=typeof t?JSON.stringify(t):t,"multipart/form-data":t=>Object.keys(t||{}).reduce(((e,s)=>{const n=t[s];return e.append(s,n instanceof Blob?n:"object"==typeof n&&null!==n?JSON.stringify(n):`${n}`),e}),new FormData),"application/x-www-form-urlencoded":t=>this.toQueryString(t)}),h(this,"createAbortSignal",(t=>{if(this.abortControllers.has(t)){const e=this.abortControllers.get(t);return e?e.signal:void 0}const e=new AbortController;return this.abortControllers.set(t,e),e.signal})),h(this,"abortRequest",(t=>{const e=this.abortControllers.get(t);e&&(e.abort(),this.abortControllers.delete(t))})),h(this,"request",(t=>u(this,null,(function*(){var e=t,{body:s,secure:n,path:i,type:l,query:h,format:p,baseUrl:m,cancelToken:g}=e,f=((t,e)=>{var s={};for(var n in t)a.call(t,n)&&e.indexOf(n)<0&&(s[n]=t[n]);if(null!=t&&o)for(var n of o(t))e.indexOf(n)<0&&r.call(t,n)&&(s[n]=t[n]);return s})(e,["body","secure","path","type","query","format","baseUrl","cancelToken"]);const y=("boolean"==typeof n?n:this.baseApiParams.secure)&&this.securityWorker&&(yield this.securityWorker(this.securityData))||{},k=this.mergeRequestParams(f,y),v=h&&this.toQueryString(h),$=this.contentFormatters[l||"application/json"],w=p||k.format;return this.customFetch(`${m||this.baseUrl||""}${i}${v?`?${v}`:""}`,d(c({},k),{headers:c(c({},k.headers||{}),l&&"multipart/form-data"!==l?{"Content-Type":l}:{}),signal:(g?this.createAbortSignal(g):k.signal)||null,body:null==s?null:$(s)})).then((t=>u(this,null,(function*(){const e=t.clone();e.data=null,e.error=null;const s=w?yield t[w]().then((t=>(e.ok?e.data=t:e.error=t,e))).catch((t=>(e.error=t,e))):e;if(g&&this.abortControllers.delete(g),!t.ok)throw s;return s}))))})))),Object.assign(this,t)}encodeQueryParam(t,e){return`${encodeURIComponent(t)}=${encodeURIComponent("number"==typeof e?e:`${e}`)}`}addQueryParam(t,e){return this.encodeQueryParam(e,t[e])}addArrayQueryParam(t,e){return t[e].map((t=>this.encodeQueryParam(e,t))).join("&")}toQueryString(t){const e=t||{};return Object.keys(e).filter((t=>void 0!==e[t])).map((t=>Array.isArray(e[t])?this.addArrayQueryParam(e,t):this.addQueryParam(e,t))).join("&")}addQueryParams(t){const e=this.toQueryString(t);return e?`?${e}`:""}mergeRequestParams(t,e){return d(c(c(c({},this.baseApiParams),t),e||{}),{headers:c(c(c({},this.baseApiParams.headers||{}),t.headers||{}),e&&e.headers||{})})}}
|
|
2
|
-
|
|
3
|
-
* @title Artalk API
|
|
4
|
-
* @version 2.0
|
|
5
|
-
* @license MIT (https://github.com/ArtalkJS/Artalk/blob/master/LICENSE)
|
|
6
|
-
* @baseUrl /api/v2
|
|
7
|
-
* @contact API Support <artalkjs@gmail.com> (https://artalk.js.org)
|
|
8
|
-
*
|
|
9
|
-
* Artalk is a modern comment system based on Golang.
|
|
10
|
-
*/let m=class extends p{constructor(){super(...arguments),h(this,"auth",{loginByEmail:(t,e={})=>this.request(c({path:"/auth/email/login",method:"POST",body:t,type:"application/json",format:"json"},e)),registerByEmail:(t,e={})=>this.request(c({path:"/auth/email/register",method:"POST",body:t,type:"application/json",format:"json"},e)),sendVerifyEmail:(t,e={})=>this.request(c({path:"/auth/email/send",method:"POST",body:t,type:"application/json",format:"json"},e)),checkDataMerge:(t={})=>this.request(c({path:"/auth/merge",method:"GET",secure:!0,format:"json"},t)),applyDataMerge:(t,e={})=>this.request(c({path:"/auth/merge",method:"POST",body:t,secure:!0,type:"application/json",format:"json"},e))}),h(this,"cache",{flushCache:(t={})=>this.request(c({path:"/cache/flush",method:"POST",secure:!0,format:"json"},t)),warmUpCache:(t={})=>this.request(c({path:"/cache/warm_up",method:"POST",secure:!0,format:"json"},t))}),h(this,"captcha",{getCaptcha:(t={})=>this.request(c({path:"/captcha",method:"GET",format:"json"},t)),getCaptchaStatus:(t={})=>this.request(c({path:"/captcha/status",method:"GET",format:"json"},t)),verifyCaptcha:(t,e={})=>this.request(c({path:"/captcha/verify",method:"POST",body:t,type:"application/json",format:"json"},e))}),h(this,"comments",{getComments:(t,e={})=>this.request(c({path:"/comments",method:"GET",query:t,secure:!0,type:"application/json",format:"json"},e)),createComment:(t,e={})=>this.request(c({path:"/comments",method:"POST",body:t,secure:!0,type:"application/json",format:"json"},e)),getComment:(t,e={})=>this.request(c({path:`/comments/${t}`,method:"GET",type:"application/json",format:"json"},e)),updateComment:(t,e,s={})=>this.request(c({path:`/comments/${t}`,method:"PUT",body:e,secure:!0,type:"application/json",format:"json"},s)),deleteComment:(t,e={})=>this.request(c({path:`/comments/${t}`,method:"DELETE",secure:!0,format:"json"},e))}),h(this,"conf",{conf:(t={})=>this.request(c({path:"/conf",method:"GET",format:"json"},t)),getSocialLoginProviders:(t={})=>this.request(c({path:"/conf/auth/providers",method:"GET",format:"json"},t)),getDomain:(t,e={})=>this.request(c({path:"/conf/domain",method:"GET",query:t,format:"json"},e))}),h(this,"notifies",{getNotifies:(t,e={})=>this.request(c({path:"/notifies",method:"GET",query:t,type:"application/json",format:"json"},e)),markAllNotifyRead:(t,e={})=>this.request(c({path:"/notifies/read",method:"POST",body:t,type:"application/json",format:"json"},e)),markNotifyRead:(t,e,s={})=>this.request(c({path:`/notifies/${t}/${e}`,method:"POST",format:"json"},s))}),h(this,"pages",{getPages:(t,e={})=>this.request(c({path:"/pages",method:"GET",query:t,secure:!0,type:"application/json",format:"json"},e)),fetchAllPages:(t,e={})=>this.request(c({path:"/pages/fetch",method:"POST",body:t,secure:!0,type:"application/json",format:"json"},e)),getPageFetchStatus:(t={})=>this.request(c({path:"/pages/fetch/status",method:"GET",secure:!0,format:"json"},t)),logPv:(t,e={})=>this.request(c({path:"/pages/pv",method:"POST",body:t,type:"application/json",format:"json"},e)),updatePage:(t,e,s={})=>this.request(c({path:`/pages/${t}`,method:"PUT",body:e,secure:!0,type:"application/json",format:"json"},s)),deletePage:(t,e={})=>this.request(c({path:`/pages/${t}`,method:"DELETE",secure:!0,format:"json"},e)),fetchPage:(t,e={})=>this.request(c({path:`/pages/${t}/fetch`,method:"POST",secure:!0,type:"application/json",format:"json"},e))}),h(this,"sendEmail",{sendEmail:(t,e={})=>this.request(c({path:"/send_email",method:"POST",body:t,secure:!0,type:"application/json",format:"json"},e))}),h(this,"settings",{getSettings:(t={})=>this.request(c({path:"/settings",method:"GET",secure:!0,format:"json"},t)),applySettings:(t,e={})=>this.request(c({path:"/settings",method:"PUT",body:t,secure:!0,type:"application/json",format:"json"},e)),getSettingsTemplate:(t,e={})=>this.request(c({path:`/settings/template/${t}`,method:"GET",secure:!0,format:"json"},e))}),h(this,"sites",{getSites:(t={})=>this.request(c({path:"/sites",method:"GET",secure:!0,format:"json"},t)),createSite:(t,e={})=>this.request(c({path:"/sites",method:"POST",body:t,secure:!0,type:"application/json",format:"json"},e)),updateSite:(t,e,s={})=>this.request(c({path:`/sites/${t}`,method:"PUT",body:e,secure:!0,type:"application/json",format:"json"},s)),deleteSite:(t,e={})=>this.request(c({path:`/sites/${t}`,method:"DELETE",secure:!0,format:"json"},e))}),h(this,"stats",{getStats:(t,e,s={})=>this.request(c({path:`/stats/${t}`,method:"GET",query:e,type:"application/json",format:"json"},s))}),h(this,"transfer",{exportArtrans:(t={})=>this.request(c({path:"/transfer/export",method:"GET",secure:!0,format:"json"},t)),importArtrans:(t,e={})=>this.request(c({path:"/transfer/import",method:"POST",body:t,secure:!0,type:"application/json"},e)),uploadArtrans:(t,e={})=>this.request(c({path:"/transfer/upload",method:"POST",body:t,secure:!0,type:"multipart/form-data",format:"json"},e))}),h(this,"upload",{upload:(t,e={})=>this.request(c({path:"/upload",method:"POST",body:t,secure:!0,type:"multipart/form-data",format:"json"},e))}),h(this,"user",{getUser:(t,e={})=>this.request(c({path:"/user",method:"GET",query:t,secure:!0,format:"json"},e)),updateProfile:(t,e={})=>this.request(c({path:"/user",method:"POST",body:t,secure:!0,type:"application/json",format:"json"},e)),login:(t,e={})=>this.request(c({path:"/user/access_token",method:"POST",body:t,type:"application/json",format:"json"},e)),getUserStatus:(t,e={})=>this.request(c({path:"/user/status",method:"GET",query:t,secure:!0,format:"json"},e))}),h(this,"users",{createUser:(t,e={})=>this.request(c({path:"/users",method:"POST",body:t,secure:!0,type:"application/json",format:"json"},e)),updateUser:(t,e,s={})=>this.request(c({path:`/users/${t}`,method:"PUT",body:e,secure:!0,type:"application/json",format:"json"},s)),deleteUser:(t,e={})=>this.request(c({path:`/users/${t}`,method:"DELETE",secure:!0,format:"json"},e)),getUsers:(t,e,s={})=>this.request(c({path:`/users/${t}`,method:"GET",query:e,secure:!0,type:"application/json",format:"json"},s))}),h(this,"version",{getVersion:(t={})=>this.request(c({path:"/version",method:"GET",format:"json"},t))}),h(this,"votes",{syncVotes:(t={})=>this.request(c({path:"/votes/sync",method:"POST",secure:!0,format:"json"},t)),vote:(t,e,s,n={})=>this.request(c({path:`/votes/${t}/${e}`,method:"POST",body:s,type:"application/json",format:"json"},n))})}};const g=(t,e,s)=>u(this,null,(function*(){const n=t.getApiToken&&t.getApiToken(),i=new Headers(c({Authorization:n?`Bearer ${n}`:""},null==s?void 0:s.headers));i.get("Authorization")||i.delete("Authorization");const o=yield fetch(e,d(c({},s),{headers:i}));if(!o.ok){const n=(yield o.json().catch((()=>{})))||{};let i=!1;if(t.handlers&&(yield t.handlers.get().reduce(((t,e)=>u(this,null,(function*(){yield t,!0===n[e.action]&&(yield e.handler(n),i=!0)}))),Promise.resolve())),i)return g(t,e,s);throw function(t,e){const s=new f;return s.message=e.msg||e.message||"fetch error",s.code=t,s.data=e,console.error(s),s}(o.status,n)}return o}));class f extends Error{constructor(){super(...arguments),h(this,"code",0),h(this,"message","fetch error"),h(this,"data")}}class y extends m{constructor(t){super({baseUrl:t.baseURL,customFetch:(e,s)=>g(t,e,s)}),h(this,"_opts"),this._opts=t}getUserFields(){const t=this._opts.userInfo;if((null==t?void 0:t.name)&&(null==t?void 0:t.email))return{name:t.name,email:t.email}}}"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function k(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var v={"&":"&","<":"<",">":">",'"':""","'":"'"},$={"&":"&","<":"<",">":">",""":'"',"'":"'"},w=/(&|<|>|"|')/g,b=/[&<>"']/g;function C(t){return v[t]}function x(t){return $[t]}function E(t){return null==t?"":String(t).replace(b,C)}function S(t){return null==t?"":String(t).replace(w,x)}E.options=S.options={};var T={encode:E,escape:E,decode:S,unescape:S,version:"1.0.0-browser"};var L=function t(e){for(var s,n,i=Array.prototype.slice.call(arguments,1);i.length;)for(n in s=i.shift())s.hasOwnProperty(n)&&("[object Object]"===Object.prototype.toString.call(e[n])?e[n]=t(e[n],s[n]):e[n]=s[n]);return e},A=function(t){return"string"==typeof t?t.toLowerCase():t};function M(t,e){return t[e]=!0,t}var P=function(t){return t.reduce(M,{})},U={uris:P(["background","base","cite","href","longdesc","src","usemap"])},I={voids:P(["area","br","col","hr","img","wbr","input","base","basefont","link","meta"])},O=T,q=A,D=I,R=/^<\s*([\w:-]+)((?:\s+[\w:-]+(?:\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|[^>\s]+))?)*)\s*(\/?)\s*>/,B=/^<\s*\/\s*([\w:-]+)[^>]*>/,j=/([\w:-]+)(?:\s*=\s*(?:(?:"((?:[^"])*)")|(?:'((?:[^'])*)')|([^>\s]+)))?/g,F=/^</,_=/^<\s*\//;var W=T,N=A,H=U,z=I;var V=L,G=function(t,e){for(var s,n=function(){var t=[];return t.lastItem=function(){return t[t.length-1]},t}(),i=t;t;)o();function o(){s=!0,function(){"\x3c!--"===t.substr(0,4)?(n=t.indexOf("--\x3e"))>=0&&(e.comment&&e.comment(t.substring(4,n)),t=t.substring(n+3),s=!1):_.test(t)?a(B,l):F.test(t)&&a(R,r);var n;!function(){if(!s)return;var n,i=t.indexOf("<");i>=0?(n=t.substring(0,i),t=t.substring(i)):(n=t,t="");e.chars&&e.chars(n)}()}();var n=t===i;i=t,n&&(t="")}function a(e,n){var i=t.match(e);i&&(t=t.substring(i[0].length),i[0].replace(e,n),s=!1)}function r(t,s,i,o){var a={},r=q(s),l=D.voids[r]||!!o;i.replace(j,(function(t,e,s,n,i){a[e]=void 0===s&&void 0===n&&void 0===i?void 0:O.decode(s||n||i||"")})),l||n.push(r),e.start&&e.start(r,a,l)}function l(t,s){var i,o=0,a=q(s);if(a)for(o=n.length-1;o>=0&&n[o]!==a;o--);if(o>=0){for(i=n.length-1;i>=o;i--)e.end&&e.end(n[i]);n.length=o}}l()},K=function(t,e){var s,n=e||{};return r(),{start:function(t,e,a){var r=N(t);if(s.ignoring)return void o(r);if(-1===(n.allowedTags||[]).indexOf(r))return void o(r);if(n.filter&&!n.filter({tag:r,attrs:e}))return void o(r);i("<"),i(r),Object.keys(e).forEach((function(t){var s=e[t],o=(n.allowedClasses||{})[r]||[],a=(n.allowedAttributes||{})[r]||[],l=N(t);("class"===l&&-1===a.indexOf(l)?(s=s.split(" ").filter((function(t){return o&&-1!==o.indexOf(t)})).join(" ").trim()).length:-1!==a.indexOf(l)&&(!0!==H.uris[l]||function(t){var e=t[0];if("#"===e||"/"===e)return!0;var s=t.indexOf(":");if(-1===s)return!0;var i=t.indexOf("?");if(-1!==i&&s>i)return!0;var o=t.indexOf("#");return-1!==o&&s>o||n.allowedSchemes.some(a);function a(e){return 0===t.indexOf(e+":")}}(s)))&&(i(" "),i(t),"string"==typeof s&&(i('="'),i(W.encode(s)),i('"')))})),i(a?"/>":">")},end:function(t){var e=N(t);-1!==(n.allowedTags||[]).indexOf(e)&&!1===s.ignoring?(i("</"),i(e),i(">")):a(e)},chars:function(t){!1===s.ignoring&&i(n.transformText?n.transformText(t):t)}};function i(e){t.push(e)}function o(t){z.voids[t]||(!1===s.ignoring?s={ignoring:t,depth:1}:s.ignoring===t&&s.depth++)}function a(t){s.ignoring===t&&--s.depth<=0&&r()}function r(){s={ignoring:!1,depth:0}}},Q={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 Y(t,e,s){var n=[],i=!0===s?e:V({},Q,e),o=K(n,i);return G(t,o),n.join("")}Y.defaults=Q;const J=k(Y),X={allowedClasses:{},allowedSchemes:["http","https","mailto","data"],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"],allowedAttributes:{"*":["title","accesskey"],a:["href","name","target","aria-label","rel"],img:["src","alt","title","atk-emoticon","aria-label","data-src","class","loading"],code:["class"],span:["class","style"]},filter:t=>([["code",/^hljs\W+language-(.*)$/],["span",/^(hljs-.*)$/],["img",/^lazyload$/]].forEach((([e,s])=>{t.tag===e&&t.attrs.class&&!s.test(t.attrs.class)&&delete t.attrs.class})),"span"===t.tag&&t.attrs.style&&!/^color:(\W+)?#[0-9a-f]{3,6};?$/i.test(t.attrs.style)&&delete t.attrs.style,!0)};function Z(t){return J(t,X)}var tt={exports:{}};tt.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}})),s=["23AC69","91C132","F19726","E8552D","1AAB8E","E1147F","2980C1","1BA1E6","9FA0A0","F19726","E30B20","E30B20","A3338B"];function n(t){return'<span style="color: slategray">'+t+"</span>"}return function(t,i){void 0===i&&(i={});var o=i.colors;void 0===o&&(o=s);var a=0,r={},l=new RegExp("("+/[\u4E00-\u9FFF\u3400-\u4dbf\uf900-\ufaff\u3040-\u309f\uac00-\ud7af\u0400-\u04FF]+|\w+/.source+"|"+/</.source+")|("+e().source+")","gmi");return t.replace(l,(function(t,e,s){if(s)return n(s);if("<"===e)return"<";var i;r[e]?i=r[e]:(i=o[a],r[e]=i);var l='<span style="color: #'+i+'">'+e+"</span>";return a=++a%o.length,l}))}}();const et=k(tt.exports);function st(t){return et(t)}function nt(t){const s=new e.marked.Renderer;return s.link=it(s,s.link),s.code=ot(),s.image=at(s,s.image,t),s}const it=(t,e)=>s=>{const n=(t=>{try{return new URL(t).origin}catch(e){return""}})(s.href)===window.location.origin;return e.call(t,s).replace(/^<a /,`<a target="_blank" ${n?"":'rel="noreferrer noopener nofollow"'} `)},ot=()=>({lang:t,text:e})=>{const s=t||"plaintext";let n=e;return window.hljs?s&&window.hljs.getLanguage(s)&&(n=window.hljs.highlight(s,e).value):n=st(e),`<pre rel="${s}">\n<code class="hljs language-${s}">${n.replace(/&/g,"&")}</code>\n</pre>`},at=(t,e,{imgLazyLoad:s})=>n=>{const i=e.call(t,n);return s?"native"===s||!0===s?i.replace(/^<img /,'<img class="lazyload" loading="lazy" '):"data-src"===s?i.replace(/^<img /,'<img class="lazyload" ').replace("src=","data-src="):i:i};let rt,lt=[];const ct={gfm:!0,breaks:!0,async:!1};function dt(){return rt}function ht(t){var e;let s=null==(e=dt())?void 0:e.parse(t);s||(s=function(t){return t.replace(/```\s*([^]+?.*?[^]+?[^]+?)```/g,((t,e)=>`<pre><code>${st(e)}</code></pre>`)).replace(/!\[(.*?)\]\((.*?)\)/g,((t,e,s)=>`<img src="${s}" alt="${e}" />`)).replace(/\[(.*?)\]\((.*?)\)/g,((t,e,s)=>`<a href="${s}" target="_blank">${e}</a>`)).replace(/\n/g,"<br>")}(t));let n=Z(s);return lt.forEach((t=>{"function"==typeof t&&(n=t(n))})),n}function ut(...t){const e=t=>t&&"object"==typeof t&&t.constructor===Object;return t.reduce(((t,s)=>(Object.keys(null!=s?s:{}).forEach((n=>{if("__proto__"===n||"constructor"===n||"prototype"===n)return;const i=t[n],o=s[n];Array.isArray(i)&&Array.isArray(o)?t[n]=i.concat(...o):e(i)&&e(o)?t[n]=ut(i,o):t[n]=o})),t)),{})}class pt{constructor(t){h(this,"loading",!1),h(this,"listLastFetch"),h(this,"comments",[]),h(this,"notifies",[]),h(this,"page"),this.events=t}getLoading(){return this.loading}setLoading(t){this.loading=t}getListLastFetch(){return this.listLastFetch}setListLastFetch(t){this.listLastFetch=t}getComments(){return this.comments}fetchComments(t){this.events.trigger("list-fetch",t)}findComment(t){return this.comments.find((e=>e.id===t))}clearComments(){this.comments=[],this.events.trigger("list-loaded",this.comments)}loadComments(t){this.events.trigger("list-load",t),this.comments.push(...t),this.events.trigger("list-loaded",this.comments)}insertComment(t){this.comments.push(t),this.events.trigger("comment-inserted",t),this.events.trigger("list-loaded",this.comments)}updateComment(t){this.comments=this.comments.map((e=>e.id===t.id?t:e)),this.events.trigger("comment-updated",t),this.events.trigger("list-loaded",this.comments)}deleteComment(t){const e=this.comments.find((e=>e.id===t));if(!e)throw new Error(`Comment ${t} not found`);this.comments=this.comments.filter((e=>e.id!==t)),this.events.trigger("comment-deleted",e),this.events.trigger("list-loaded",this.comments)}getNotifies(){return this.notifies}updateNotifies(t){this.notifies=t,this.events.trigger("notifies-updated",this.notifies)}getPage(){return this.page}updatePage(t){this.page=t,this.events.trigger("page-loaded",t)}}function mt(t=""){const e=document.createElement("div");return e.innerHTML=t.trim(),e.firstElementChild||e}function gt(t){const e=document.createElement("div");e.innerText=t;return e.innerHTML}function ft(t){const e=RegExp(`[?&]${t}=([^&]*)`).exec(window.location.search);return e&&decodeURIComponent(e[1].replace(/\+/g," "))}function yt(t,e){const s=t=>{const e=t.getBoundingClientRect(),s=window.pageXOffset||document.documentElement.scrollLeft,n=window.pageYOffset||document.documentElement.scrollTop;return{top:e.top+n,left:e.left+s}},n=s(t);if(!e)return n;const i=s(e);return{top:n.top-i.top,left:n.left-i.left}}function kt(t,e){let s=t.toString();for(;s.length<e;)s=`0${s}`;return s}function vt(t,e=t=>t){try{const s=t.getTime(),n=(new Date).getTime()-s,i=Math.floor(n/864e5);if(0===i){const t=n%864e5,s=Math.floor(t/36e5);if(0===s){const s=t%36e5,n=Math.floor(s/6e4);if(0===n){const t=s%6e4,n=Math.round(t/1e3);return n<10?e("now"):`${n} ${e("seconds")}`}return`${n} ${e("minutes")}`}return`${s} ${e("hours")}`}return i<0?e("now"):i<8?`${i} ${e("days")}`:function(t){const e=kt(t.getDate(),2),s=kt(t.getMonth()+1,2);return`${kt(t.getFullYear(),2)}-${s}-${e}`}(t)}catch(s){return console.error(s)," - "}}function $t(){return u(this,null,(function*(){const t=navigator.userAgent;if(!navigator.userAgentData||!navigator.userAgentData.getHighEntropyValues)return t;const e=navigator.userAgentData;let s=null;try{s=yield e.getHighEntropyValues(["platformVersion"])}catch(i){return console.error(i),t}const n=Number(s.platformVersion.split(".")[0]);return"Windows"===e.platform&&n>=13?t.replace(/Windows NT 10.0/,"Windows NT 11.0"):"macOS"===e.platform&&n>=11?t.replace(/(Mac OS X \d+_\d+_\d+|Mac OS X)/,`Mac OS X ${s.platformVersion.replace(/\./g,"_")}`):t}))}function wt(t){let e;try{e=new URL(t)}catch(s){return!1}return"http:"===e.protocol||"https:"===e.protocol}function bt(t){return e=t.base,s=t.path,`${e.replace(/\/$/,"")}/${s.replace(/^\//,"")}`;var e,s}const Ct={placeholder:"Leave a comment",noComment:"No Comment",send:"Send",signIn:"Sign in",signUp:"Sign up",save:"Save",nick:"Nickname",email:"Email",link:"Website",emoticon:"Emoji",preview:"Preview",uploadImage:"Upload Image",uploadFail:"Upload Failed",commentFail:"Failed to comment",restoredMsg:"Content has been restored",onlyAdminCanReply:"Only admin can reply",uploadLoginMsg:"Please fill in your name and email to upload",counter:"{count} Comments",sortLatest:"Latest",sortOldest:"Oldest",sortBest:"Best",sortAuthor:"Author",openComment:"Open Comment",closeComment:"Close Comment",listLoadFailMsg:"Failed to load comments",listRetry:"Retry",loadMore:"Load More",admin:"Admin",reply:"Reply",voteUp:"Up",voteDown:"Down",voteFail:"Vote Failed",readMore:"Read More",actionConfirm:"Confirm",collapse:"Collapse",collapsed:"Collapsed",collapsedMsg:"This comment has been collapsed",expand:"Expand",approved:"Approved",pending:"Pending",pendingMsg:"Pending, visible only to commenter.",edit:"Edit",editCancel:"Cancel Edit",delete:"Delete",deleteConfirm:"Confirm",pin:"Pin",unpin:"Unpin",seconds:"seconds ago",minutes:"minutes ago",hours:"hours ago",days:"days ago",now:"just now",adminCheck:"Enter admin password:",captchaCheck:"Enter the CAPTCHA to continue:",confirm:"Confirm",cancel:"Cancel",msgCenter:"Messages",ctrlCenter:"Dashboard",userProfile:"Profile",noAccountPrompt:"Don't have an account?",haveAccountPrompt:"Already have an account?",forgetPassword:"Forget Password",resetPassword:"Reset Password",changePassword:"Change Password",confirmPassword:"Confirm Password",passwordMismatch:"Passwords do not match",verificationCode:"Verification Code",verifySend:"Send Code",verifyResend:"Resend",waitSeconds:"Wait {seconds}s",emailVerified:"Email has been verified",password:"Password",username:"Username",nextStep:"Next Step",skipVerify:"Skip verification",logoutConfirm:"Are you sure to logout?",accountMergeNotice:"Your email has multiple accounts with different id.",accountMergeSelectOne:"Please select one you want to merge all the data into it.",accountMergeConfirm:"All data will be merged into one account, the id is {id}.",dismiss:"Dismiss",merge:"Merge",frontend:"Frontend",backend:"Backend",loading:"Loading",loadFail:"Load Failed",editing:"Editing",editFail:"Edit Failed",deleting:"Deleting",deleteFail:"Delete Failed",reqGot:"Request got",reqAborted:"Request timed out or terminated unexpectedly",updateMsg:"Please update Artalk {name} to get the best experience!",currentVersion:"Current Version",ignore:"Ignore",open:"Open",openName:"Open {name}"},xt="ArtalkI18n",Et={en:Ct,"en-US":Ct,"zh-CN":{placeholder:"键入内容...",noComment:"「此时无声胜有声」",send:"发送",signIn:"登录",signUp:"注册",save:"保存",nick:"昵称",email:"邮箱",link:"网址",emoticon:"表情",preview:"预览",uploadImage:"上传图片",uploadFail:"上传失败",commentFail:"评论失败",restoredMsg:"内容已自动恢复",onlyAdminCanReply:"仅管理员可评论",uploadLoginMsg:"填入你的名字邮箱才能上传哦",counter:"{count} 条评论",sortLatest:"最新",sortOldest:"最早",sortBest:"最热",sortAuthor:"作者",openComment:"打开评论",closeComment:"关闭评论",listLoadFailMsg:"无法获取评论列表数据",listRetry:"点击重新获取",loadMore:"加载更多",admin:"管理员",reply:"回复",voteUp:"赞同",voteDown:"反对",voteFail:"投票失败",readMore:"阅读更多",actionConfirm:"确认操作",collapse:"折叠",collapsed:"已折叠",collapsedMsg:"该评论已被系统或管理员折叠",expand:"展开",approved:"已审",pending:"待审",pendingMsg:"审核中,仅本人可见。",edit:"编辑",editCancel:"取消编辑",delete:"删除",deleteConfirm:"确认删除",pin:"置顶",unpin:"取消置顶",seconds:"秒前",minutes:"分钟前",hours:"小时前",days:"天前",now:"刚刚",adminCheck:"键入密码来验证管理员身份:",captchaCheck:"键入验证码继续:",confirm:"确认",cancel:"取消",msgCenter:"通知中心",ctrlCenter:"控制中心",userProfile:"个人资料",noAccountPrompt:"没有账号?",haveAccountPrompt:"已有账号?",forgetPassword:"忘记密码",resetPassword:"重置密码",changePassword:"修改密码",confirmPassword:"确认密码",passwordMismatch:"两次输入的密码不一致",verificationCode:"验证码",verifySend:"发送验证码",verifyResend:"重新发送",waitSeconds:"等待 {seconds}秒",emailVerified:"邮箱已验证",password:"密码",username:"用户名",nextStep:"下一步",skipVerify:"跳过验证",logoutConfirm:"确定要退出登录吗?",accountMergeNotice:"您的电子邮件下有多个不同 ID 的账户。",accountMergeSelectOne:"请选择将所有数据合并到其中的一个。",accountMergeConfirm:"所有数据将合并到 ID 为 {id} 的账户中。",dismiss:"忽略",merge:"合并",frontend:"前端",backend:"后端",loading:"加载中",loadFail:"加载失败",editing:"修改中",editFail:"修改失败",deleting:"删除中",deleteFail:"删除失败",reqGot:"请求响应",reqAborted:"请求超时或意外终止",updateMsg:"请更新 Artalk {name} 以获得更好的体验!",currentVersion:"当前版本",ignore:"忽略",open:"打开",openName:"打开{name}"}};function St(t){return t=t.replace(/^([a-zA-Z]+)(-[a-zA-Z]+)?$/,((t,e,s)=>e.toLowerCase()+(s||"").toUpperCase())),Et[t]?Et[t]:window[xt]&&window[xt][t]?window[xt][t]:Et.en}let Tt="en",Lt=St(Tt);function At(t){t!==Tt&&(Tt=t,Lt="string"==typeof t?St(t):t)}function Mt(t,e={}){let s=(null==Lt?void 0:Lt[t])||t;return s=s.replace(/\{\s*(\w+?)\s*\}/g,((t,s)=>e[s]||"")),gt(s)}class Pt{constructor(){h(this,"events",[])}on(t,e,s={}){this.events.push(c({name:t,handler:e},s))}off(t,e){e&&(this.events=this.events.filter((s=>!(s.name===t&&s.handler===e))))}trigger(t,e){this.events.slice(0).filter((e=>e.name===t&&"function"==typeof e.handler)).forEach((s=>{s.once&&this.off(t,s.handler),s.handler(e)}))}}const Ut={el:"",pageKey:"",pageTitle:"",server:"",site:"",placeholder:"",noComment:"",sendBtn:"",darkMode:!1,editorTravel:!0,flatMode:"auto",nestMax:2,nestSort:"DATE_ASC",emoticons:"https://cdn.jsdelivr.net/gh/ArtalkJS/Emoticons/grps/default.json",vote:!0,voteDown:!1,uaBadge:!0,listSort:!0,preview:!0,countEl:".artalk-comment-count",pvEl:".artalk-pv-count",statPageKeyAttr:"data-page-key",gravatar:{mirror:"https://www.gravatar.com/avatar/",params:"sha256=1&d=mp&s=240"},pagination:{pageSize:20,readMore:!0,autoLoad:!0},heightLimit:{content:300,children:400,scrollable:!1},imgUpload:!0,reqTimeout:15e3,versionCheck:!0,useBackendConf:!0,locale:"en"};function It(t,e=!1){const s=e?ut(Ut,t):t;if(s.el&&"string"==typeof s.el)try{const t=document.querySelector(s.el);if(!t)throw Error(`Target element "${s.el}" was not found.`);s.el=t}catch(n){throw console.error(n),new Error("Please check your Artalk `el` config.")}return""===s.pageKey&&(s.pageKey=`${window.location.pathname}`),""===s.pageTitle&&(s.pageTitle=`${document.title}`),s.server&&(s.server=s.server.replace(/\/$/,"").replace(/\/api\/?$/,"")),"auto"===s.locale&&(s.locale=navigator.language),"auto"===s.flatMode&&(s.flatMode=window.matchMedia("(max-width: 768px)").matches),"number"==typeof s.nestMax&&Number(s.nestMax)<=1&&(s.flatMode=!0),s}function Ot(t,e){return{baseURL:`${t.server}/api/v2`,siteName:t.site||"",pageKey:t.pageKey||"",pageTitle:t.pageTitle||"",timeout:t.reqTimeout,getApiToken:()=>null==e?void 0:e.get("user").getData().token,userInfo:(null==e?void 0:e.get("user").checkHasBasicUserInfo())?{name:null==e?void 0:e.get("user").getData().name,email:null==e?void 0:e.get("user").getData().email}:void 0,handlers:null==e?void 0:e.getApiHandlers()}}function qt(t,e,s){let n=null;const i=()=>{const i=(()=>{const s=t.getConf(),n={};return e.forEach((t=>{n[t]=s[t]})),n})();var o,a;(null==n||(o=n,a=i,!(JSON.stringify(o)===JSON.stringify(a))))&&(n=i,s(i))};t.on("mounted",i),t.on("updated",i)}class Dt{constructor(t){h(this,"conf"),h(this,"data"),h(this,"$root"),h(this,"events",new Pt),h(this,"mounted",!1),h(this,"apiHandlers",null),h(this,"getCommentList",this.getCommentNodes),h(this,"getCommentDataList",this.getComments),this.conf=t,this.$root=t.el,this.$root.classList.add("artalk"),this.$root.innerHTML="",t.darkMode&&this.$root.classList.add("atk-dark-mode"),this.data=new pt(this.events),this.on("mounted",(()=>{this.mounted=!0}))}inject(t,e){this[t]=e}get(t){return this[t]}getApi(){return new y(Ot(this.conf,this))}getApiHandlers(){return this.apiHandlers||(this.apiHandlers=function(t){const e=function(){const t=[];return{add:(e,s)=>{t.push({action:e,handler:s})},remove:e=>{const s=t.findIndex((t=>t.action===e));-1!==s&&t.splice(s,1)},get:()=>t}}();return e.add("need_captcha",(e=>t.checkCaptcha(e))),e.add("need_login",(()=>t.checkAdmin({}))),e}(this)),this.apiHandlers}getData(){return this.data}replyComment(t,e){this.editor.setReply(t,e)}editComment(t,e){this.editor.setEditComment(t,e)}fetch(t){this.data.fetchComments(t)}reload(){this.data.fetchComments({offset:0})}listGotoFirst(){this.events.trigger("list-goto-first")}getCommentNodes(){return this.list.getCommentNodes()}getComments(){return this.data.getComments()}editorShowLoading(){this.editor.showLoading()}editorHideLoading(){this.editor.hideLoading()}editorShowNotify(t,e){this.editor.showNotify(t,e)}editorResetState(){this.editor.resetState()}showSidebar(t){this.sidebarLayer.show(t)}hideSidebar(){this.sidebarLayer.hide()}checkAdmin(t){return this.checkerLauncher.checkAdmin(t)}checkCaptcha(t){return this.checkerLauncher.checkCaptcha(t)}on(t,e){this.events.on(t,e)}off(t,e){this.events.off(t,e)}trigger(t,e){this.events.trigger(t,e)}$t(t,e={}){return Mt(t,e)}setDarkMode(t){this.updateConf({darkMode:t})}updateConf(t){this.conf=ut(this.conf,It(t,!1)),this.mounted&&this.events.trigger("updated",this.conf)}getConf(){return this.conf}getEl(){return this.$root}getMarked(){return dt()}watchConf(t,e){qt(this,t,e)}}function Rt(t,e){let s=t.querySelector(":scope > .atk-loading");s||(s=mt('<div class="atk-loading" style="display: none;">\n <div class="atk-loading-spinner">\n <svg viewBox="25 25 50 50"><circle cx="50" cy="50" r="20" fill="none" stroke-width="2" stroke-miterlimit="10"></circle></svg>\n </div>\n </div>'),(null==e?void 0:e.transparentBg)&&(s.style.background="transparent"),t.appendChild(s)),s.style.display="";const n=s.querySelector(".atk-loading-spinner");n&&(n.style.display="none",window.setTimeout((()=>{n.isConnected&&(n.style.display="")}),500))}function Bt(t){const e=t.querySelector(":scope > .atk-loading");e&&(e.style.display="none")}function jt(t,e){t?Rt(e):Bt(e)}function Ft(t,e=!0,s){let n;if(s){const e=s.getBoundingClientRect();n=t.getBoundingClientRect().top-e.top+s.scrollTop-s.clientHeight/2+t.clientHeight/2}else{const e=t.getBoundingClientRect();n=e.top+window.scrollY-(window.innerHeight/2-e.height/2)}const i={top:n,left:0,behavior:"instant"};s?s.scroll(i):window.scroll(i)}function _t(t,e){!function(t,e,s="in"){t.classList.add(`atk-fade-${s}`);const n=()=>{t.classList.remove(`atk-fade-${s}`),t.removeEventListener("animationend",n)};t.addEventListener("animationend",n)}(t,0,"in")}function Wt(t,e,s='<span class="atk-error-title">Artalk Error</span>'){let n=t.querySelector(".atk-error-layer");if(null===e)return void(null!==n&&n.remove());n||(n=mt(`<div class="atk-error-layer">${s}<span class="atk-error-text"></span></div>`),t.appendChild(n));const i=n.querySelector(".atk-error-text");i.innerHTML="",null!==e&&(e instanceof HTMLElement?i.appendChild(e):i.innerText=e)}function Nt(t){const e=mt('<div class="atk-checker-iframe-wrap"></div>'),s=mt('<iframe class="atk-fade-in" referrerpolicy="strict-origin-when-cross-origin"></iframe>');s.style.display="none",Rt(e,{transparentBg:!0}),s.src=t.getOpts().getCaptchaIframeURL(),s.onload=()=>{s.style.display="",Bt(e)},e.append(s);const n=mt('<div class="atk-close-btn"><i class="atk-icon atk-icon-close"></i></div>');e.append(n),t.hideInteractInput();let i=!1;return function e(){return u(this,null,(function*(){var s;if(yield(s=1e3,new Promise((t=>{window.setTimeout((()=>{t(null)}),s)}))),i)return;let n=!1;try{n=(yield t.getApi().captcha.getCaptchaStatus()).data.is_pass}catch(o){n=!1}n?t.triggerSuccess():e()}))}(),n.onclick=()=>{i=!0,t.cancel()},e}const Ht={request:(t,e)=>t.getApi().captcha.verifyCaptcha({value:e}),body:t=>t.get("iframe")?Nt(t):function(t){const e=mt(`<span><img class="atk-captcha-img" src="${t.get("img_data")||""}">${Mt("captchaCheck")}</span>`);return e.querySelector(".atk-captcha-img").onclick=()=>{const s=e.querySelector(".atk-captcha-img");t.getApi().captcha.getCaptcha().then((t=>{s.setAttribute("src",t.data.img_data)})).catch((t=>{console.error("Failed to get captcha image ",t)}))},e}(t),onSuccess(t,e,s,n){t.set("val",s)},onError(t,e,s,n){n.querySelector(".atk-captcha-img").click(),n.querySelector('input[type="text"]').value=""}},zt={inputType:"password",request(t,e){return u(this,null,(function*(){return(yield t.getApi().user.login({name:t.getUser().getData().name,email:t.getUser().getData().email,password:e})).data}))},body:t=>mt(`<span>${Mt("adminCheck")}</span>`),onSuccess(t,e,s,n){t.getUser().update({is_admin:!0,token:e.token}),t.getOpts().onReload()},onError(t,e,s,n){}};class Vt{constructor(t){h(this,"$el"),h(this,"$content"),h(this,"$actions"),this.$el=mt('<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)}setYes(t){const e=mt(`<button data-action="confirm">${Mt("confirm")}</button>`);return e.onclick=this.onBtnClick(t),this.$actions.appendChild(e),this}setNo(t){const e=mt(`<button data-action="cancel">${Mt("cancel")}</button>`);return e.onclick=this.onBtnClick(t),this.$actions.appendChild(e),this}onBtnClick(t){return e=>{const s=t(e.currentTarget,this);void 0!==s&&!0!==s||this.$el.remove()}}}function Gt(t){return e=>new Promise(((s,n)=>{const i=e.onCancel;e.onCancel=()=>{i&&i(),n(new Error("user canceled the checker"))};const o=e.onSuccess;e.onSuccess=()=>{o&&o(),s()},t(e)}))}class Kt{constructor(t){h(this,"checkCaptcha",Gt((t=>{this.fire(Ht,t,(e=>{e.set("img_data",t.img_data),e.set("iframe",t.iframe)}))}))),h(this,"checkAdmin",Gt((t=>{this.fire(zt,t)}))),this.opts=t}fire(t,e,s){const n=this.opts.getCtx().get("layerManager").create(`checker-${(new Date).getTime()}`);n.show();const i=()=>{n.destroy()},o={};let a=!1;const r={set:(t,e)=>{o[t]=e},get:t=>o[t],getOpts:()=>this.opts,getUser:()=>this.opts.getCtx().get("user"),getApi:()=>this.opts.getApi(),hideInteractInput:()=>{a=!0},triggerSuccess:()=>{i(),t.onSuccess&&t.onSuccess(r,"","",l),e.onSuccess&&e.onSuccess()},cancel:()=>{i(),e.onCancel&&e.onCancel()}};s&&s(r);const l=mt();l.appendChild(t.body(r));const c=mt(`<input id="check" type="${t.inputType||"text"}" autocomplete="off" required placeholder="">`);let d;l.appendChild(c),setTimeout((()=>c.focus()),80),c.onkeyup=t=>{"Enter"!==t.key&&13!==t.keyCode||(t.preventDefault(),n.getEl().querySelector('button[data-action="confirm"]').click())};const h=new Vt(l);h.setYes((s=>{const n=c.value.trim();d||(d=s.innerText);const o=()=>{s.innerText=d||"",s.classList.remove("error")};return s.innerText=`${Mt("loading")}...`,t.request(r,n).then((s=>{i(),t.onSuccess&&t.onSuccess(r,s,n,l),e.onSuccess&&e.onSuccess()})).catch((e=>{var i;i=String(e.message||String(e)),s.innerText=i,s.classList.add("error"),t.onError&&t.onError(r,e,n,l);const a=setTimeout((()=>o()),3e3);c.onfocus=()=>{o(),clearTimeout(a)}})),!1})),h.setNo((()=>(i(),e.onCancel&&e.onCancel(),!1))),a&&(c.style.display="none",h.$el.querySelector(".atk-layer-dialog-actions").style.display="none"),n.getEl().append(h.$el),e.onMount&&e.onMount(h.$el)}}class Qt{constructor(t){h(this,"$el"),this.ctx=t}get conf(){return this.ctx.conf}getEl(){return this.$el}}const Yt={$header:".atk-header",$name:'.atk-header [name="name"]',$email:'.atk-header [name="email"]',$link:'.atk-header [name="link"]',$textareaWrap:".atk-textarea-wrap",$textarea:".atk-textarea",$bottom:".atk-bottom",$submitBtn:".atk-send-btn",$notifyWrap:".atk-notify-wrap",$bottomLeft:".atk-bottom-left",$stateWrap:".atk-state-wrap",$plugBtnWrap:".atk-plug-btn-wrap",$plugPanelWrap:".atk-plug-panel-wrap"};class Jt{constructor(t){h(this,"$btn"),h(this,"$panel"),h(this,"editorStateEffectWhen"),this.kit=t}useBtn(t="<div></div>"){return this.$btn=mt(`<span class="atk-plug-btn">${t}</span>`),this.$btn}usePanel(t="<div></div>"){return this.$panel=mt(t),this.$panel}useContentTransformer(t){this.contentTransformer=t}usePanelShow(t){this.kit.useEvents().on("panel-show",(e=>{e===this&&t()}))}usePanelHide(t){this.kit.useEvents().on("panel-hide",(e=>{e===this&&t()}))}useEditorStateEffect(t,e){this.editorStateEffectWhen=t,this.editorStateEffect=e}}class Xt extends Jt{constructor(){super(...arguments),h(this,"isMoved",!1)}move(t){if(this.isMoved)return;this.isMoved=!0;const e=this.kit.useUI().$el;e.after(mt('<div class="atk-editor-travel-placeholder"></div>'));const s=mt("<div></div>");t.after(s),s.replaceWith(e),e.classList.add("atk-fade-in"),e.classList.add("editor-traveling")}back(){var t;this.isMoved&&(this.isMoved=!1,null==(t=this.kit.useGlobalCtx().$root.querySelector(".atk-editor-travel-placeholder"))||t.replaceWith(this.kit.useUI().$el),this.kit.useUI().$el.classList.remove("editor-traveling"))}}class Zt{constructor(t){h(this,"stateCurt","normal"),h(this,"stateUnmountFn",null),this.editor=t}get(){return this.stateCurt}switch(t,e){var s,n,i,o,a;if(this.stateUnmountFn&&(this.stateUnmountFn(),this.stateUnmountFn=null,null==(n=null==(s=this.editor.getPlugs())?void 0:s.get(Xt))||n.back()),"normal"!==t&&e){let s=e.$comment;this.editor.conf.flatMode||(s=s.querySelector(".atk-footer")),null==(o=null==(i=this.editor.getPlugs())?void 0:i.get(Xt))||o.move(s);const n=this.editor.ctx.conf.scrollRelativeTo&&this.editor.ctx.conf.scrollRelativeTo();Ft(this.editor.getUI().$el,!0,n);const r=null==(a=this.editor.getPlugs())?void 0:a.getPlugs().find((e=>e.editorStateEffectWhen===t));r&&r.editorStateEffect&&(this.stateUnmountFn=r.editorStateEffect(e.comment))}this.stateCurt=t}}class te extends Qt{constructor(t){super(t),h(this,"ui"),h(this,"state"),this.ui=function(){const t=mt('<div class="atk-main-editor">\n <div class="atk-header">\n <input name="name" class="atk-name" type="text" required="required" />\n <input name="email" class="atk-email" type="email" required="required" />\n <input name="link" class="atk-link" type="url" />\n </div>\n <div class="atk-textarea-wrap">\n <textarea class="atk-textarea"></textarea>\n </div>\n <div class="atk-plug-panel-wrap" style="display: none"></div>\n <div class="atk-bottom">\n <div class="atk-item atk-bottom-left">\n <span class="atk-state-wrap"></span>\n <span class="atk-plug-btn-wrap"></span>\n </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'),e={$el:t};return Object.entries(Yt).forEach((([s,n])=>{e[s]=t.querySelector(n)})),e}(),this.$el=this.ui.$el,this.state=new Zt(this)}getUI(){return this.ui}getPlugs(){return this.ctx.get("editorPlugs")}getState(){return this.state.get()}getHeaderInputEls(){return{name:this.ui.$name,email:this.ui.$email,link:this.ui.$link}}getContentFinal(){let t=this.getContentRaw();const e=this.getPlugs();return e&&(t=e.getTransformedContent(t)),t}getContentRaw(){return this.ui.$textarea.value||""}getContentMarked(){return ht(this.getContentFinal())}setContent(t){var e;this.ui.$textarea.value=t,null==(e=this.getPlugs())||e.getEvents().trigger("content-updated",t)}insertContent(t){if(document.selection)this.ui.$textarea.focus(),document.selection.createRange().text=t,this.ui.$textarea.focus();else if(this.ui.$textarea.selectionStart||0===this.ui.$textarea.selectionStart){const e=this.ui.$textarea.selectionStart,s=this.ui.$textarea.selectionEnd,n=this.ui.$textarea.scrollTop;this.setContent(this.ui.$textarea.value.substring(0,e)+t+this.ui.$textarea.value.substring(s,this.ui.$textarea.value.length)),this.ui.$textarea.focus(),this.ui.$textarea.selectionStart=e+t.length,this.ui.$textarea.selectionEnd=e+t.length,this.ui.$textarea.scrollTop=n}else this.ui.$textarea.focus(),this.ui.$textarea.value+=t}focus(){this.ui.$textarea.focus()}reset(){this.setContent(""),this.resetState()}resetState(){this.state.switch("normal")}setReply(t,e){this.state.switch("reply",{comment:t,$comment:e})}setEditComment(t,e){this.state.switch("edit",{comment:t,$comment:e})}showNotify(t,e){!function(t,e,s){const n=mt(`<div class="atk-notify atk-fade-in" style="background-color: ${{s:"#57d59f",e:"#ff6f6c",w:"#ffc721",i:"#2ebcfc"}[s]}"><span class="atk-notify-content"></span></div>`);n.querySelector(".atk-notify-content").innerHTML=gt(e).replace("\n","<br/>"),t.appendChild(n);const i=()=>{n.classList.add("atk-fade-out"),setTimeout((()=>{n.remove()}),200)};let o;o=window.setTimeout((()=>{i()}),3e3),n.addEventListener("click",(()=>{i(),window.clearTimeout(o)}))}(this.ui.$notifyWrap,t,e)}showLoading(){Rt(this.ui.$el)}hideLoading(){Bt(this.ui.$el)}submit(){const t=()=>this.ctx.trigger("editor-submit");this.ctx.conf.beforeSubmit?this.ctx.conf.beforeSubmit(this,t):t()}}class ee extends Qt{constructor(t){super(t),h(this,"layer"),h(this,"$header"),h(this,"$closeBtn"),h(this,"$iframeWrap"),h(this,"$iframe"),h(this,"refreshWhenShow",!0),h(this,"animTimer"),this.$el=mt('<div class="atk-sidebar-layer">\n <div class="atk-sidebar-inner">\n <div class="atk-sidebar-header">\n <div class="atk-sidebar-close">\n <i class="atk-icon atk-icon-close-slim"></i>\n </div>\n </div>\n <div class="atk-sidebar-iframe-wrap"></div>\n </div>\n</div>\n'),this.$header=this.$el.querySelector(".atk-sidebar-header"),this.$closeBtn=this.$header.querySelector(".atk-sidebar-close"),this.$iframeWrap=this.$el.querySelector(".atk-sidebar-iframe-wrap"),this.$closeBtn.onclick=()=>{this.hide()},this.ctx.on("user-changed",(()=>{this.refreshWhenShow=!0}))}show(){return u(this,arguments,(function*(t={}){if(this.$el.style.transform="",this.initLayer(),this.layer.show(),this.refreshWhenShow)this.refreshWhenShow=!1,this.$iframeWrap.innerHTML="",this.$iframe=this.createIframe(t.view),this.$iframeWrap.append(this.$iframe);else{const t=this.$iframe,e=t.src;this.getDarkMode()!==e.includes("&darkMode=1")&&this.iframeLoad(t,e.replace(/&darkMode=\d/,`&darkMode=${Number(this.getDarkMode())}`))}this.authCheck({onSuccess:()=>this.show(t)}),this.animTimer=setTimeout((()=>{this.animTimer=void 0,this.$el.style.transform="translate(0, 0)",setTimeout((()=>{this.ctx.getData().updateNotifies([])}),0),this.ctx.trigger("sidebar-show")}),100)}))}hide(){var t;null==(t=this.layer)||t.hide()}authCheck(t){return u(this,null,(function*(){const e=(yield this.ctx.getApi().user.getUserStatus(c({},this.ctx.getApi().getUserFields()))).data;e.is_admin&&!e.is_login&&(this.refreshWhenShow=!0,this.ctx.checkAdmin({onSuccess:()=>{setTimeout((()=>{t.onSuccess()}),500)},onCancel:()=>{this.hide()}}),this.hide())}))}initLayer(){this.layer||(this.layer=this.ctx.get("layerManager").create("sidebar",this.$el),this.layer.setOnAfterHide((()=>{this.ctx.editorResetState(),this.animTimer&&clearTimeout(this.animTimer),this.$el.style.transform="",this.ctx.trigger("sidebar-hide")})))}createIframe(t){const e=mt('<iframe referrerpolicy="strict-origin-when-cross-origin"></iframe>'),s=bt({base:this.ctx.conf.server,path:"/sidebar/"}),n={pageKey:this.conf.pageKey,site:this.conf.site||"",user:JSON.stringify(this.ctx.get("user").getData()),time:+new Date};t&&(n.view=t),n.darkMode=this.getDarkMode()?"1":"0";const i=new URLSearchParams(n);return this.iframeLoad(e,`${s}?${i.toString()}`),e}getDarkMode(){return"auto"===this.conf.darkMode?window.matchMedia("(prefers-color-scheme: dark)").matches:this.conf.darkMode}iframeLoad(t,e){t.src=e,Rt(this.$iframeWrap),t.onload=()=>{Bt(this.$iframeWrap)}}}const se=t=>({import:e=>{(function(t,e="DATE_DESC",s=2){const n=[];t.filter((t=>0===t.rid)).forEach((e=>{const i={id:e.id,comment:e,children:[],level:1};i.parent=i,n.push(i),function e(n){const i=t.filter((t=>t.rid===n.id));0!==i.length&&(n.level>=s&&(n=n.parent),i.forEach((t=>{const s={id:t.id,comment:t,children:[],parent:n,level:n.level+1};n.children.push(s),e(s)})))}(i)}));const i=(s,n)=>{let i=s.id-n.id;return"DATE_ASC"===e?i=+new Date(s.comment.date)-+new Date(n.comment.date):"DATE_DESC"===e?i=+new Date(n.comment.date)-+new Date(s.comment.date):"SRC_INDEX"===e?i=t.indexOf(s.comment)-t.indexOf(n.comment):"VOTE_UP_DESC"===e&&(i=n.comment.vote_up-s.comment.vote_up),i};return function t(e){e.forEach((e=>{e.children=e.children.sort(i),t(e.children)}))}(n),n})(e,t.nestSortBy,t.nestMax).forEach((s=>{var n;const i=t.createCommentNode(s.comment);null==(n=t.$commentsWrap)||n.appendChild(i.getEl()),i.getRender().playFadeAnim();const o=(s,n)=>{n.children.forEach((n=>{const i=e.find((t=>t.id===n.comment.rid)),a=n.comment,r=t.createCommentNode(a,i);s.putChild(r),o(r,n)}))};o(i,s),i.getRender().checkHeightLimit()}))},insert:(e,s)=>{var n;const i=t.createCommentNode(e,s);if(0===e.rid)null==(n=t.$commentsWrap)||n.prepend(i.getEl());else{const s=t.findCommentNode(e.rid);s&&(s.putChild(i,"DATE_ASC"===t.nestSortBy?"append":"prepend"),i.getParents().forEach((t=>{t.getRender().heightLimitRemoveForChildren()})))}i.getRender().checkHeightLimit(),i.scrollIntoView(),i.getRender().playFadeAnim()}});function ne(t,e,s,n){s.is_collapsed&&(s.is_allow_reply=!1);const i=t.createCommentNode(s,n);if(s.visible){const s=i.getEl(),n=t.$commentsWrap;"append"===e&&(null==n||n.append(s)),"prepend"===e&&(null==n||n.prepend(s)),i.getRender().playFadeAnim()}return i.getRender().checkHeightLimit(),i}class ie{constructor(t){this.options=t}getStrategy(){return this.options.flatMode?(t=this.options,{import:e=>{e.forEach((s=>{const n=0===s.rid?void 0:e.find((t=>t.id===s.rid));ne(t,"append",s,n)}))},insert:(e,s)=>{ne(t,"prepend",e,s).scrollIntoView()}}):se(this.options);var t}import(t){this.getStrategy().import(t)}insert(t,e){this.getStrategy().insert(t,e)}}function oe(t,e){e.forEach((({el:e,max:s,imgCheck:n})=>{if(!e)return;n&&(e.style.maxHeight=`${s+1}px`);let i=!1;const o=()=>{if(i)return;if(function(t){return parseFloat(getComputedStyle(t,null).height.replace("px",""))||0}(e)<=s)return;t.scrollable?function(t){if(!t.el)return;if(t.el.classList.contains(le))return;t.el.classList.add(le),t.el.style.height=`${t.max}px`}({el:e,max:s}):function(t){if(!t.el)return;if(!t.max)return;if(t.el.classList.contains(ae))return;t.el.classList.add(ae),t.el.style.height=`${t.max}px`,t.el.style.overflow="hidden";const e=mt(`<div class="atk-height-limit-btn">${Mt("readMore")}</span>`);e.onclick=e=>{e.stopPropagation(),re(t.el),t.afterExpandBtnClick&&t.afterExpandBtnClick(e)},t.el.append(e)}({el:e,max:s,afterExpandBtnClick:()=>{var e;i=!0,null==(e=t.afterExpandBtnClick)||e.call(t)}})};if(o(),n){const t=e.querySelectorAll(".atk-content img");0===t.length&&(e.style.maxHeight=""),t.forEach((t=>{t.onload=()=>o()}))}}))}const ae="atk-height-limit";function re(t){t&&t.classList.contains(ae)&&(t.classList.remove(ae),Array.from(t.children).forEach((t=>{t.classList.contains("atk-height-limit-btn")&&t.remove()})),t.style.height="",t.style.maxHeight="",t.style.overflow="")}const le="atk-height-limit-scroll";function ce(t){if(t.$headerNick=t.$el.querySelector(".atk-nick"),t.data.link){const e=mt('<a target="_blank" rel="noreferrer noopener nofollow"></a>');e.innerText=t.data.nick,e.href=wt(t.data.link)?t.data.link:`https://${t.data.link}`,t.$headerNick.append(e)}else t.$headerNick.innerText=t.data.nick}function de(t){t.$headerBadgeWrap=t.$el.querySelector(".atk-badge-wrap"),t.$headerBadgeWrap.innerHTML="";const e=t.data.badge_name,s=t.data.badge_color;if(e){const n=mt('<span class="atk-badge"></span>');n.innerText=e.replace("管理员",Mt("admin")),n.style.backgroundColor=s||"",t.$headerBadgeWrap.append(n)}else if(t.data.is_verified){const e=mt(`<span class="atk-verified-icon" title="${Mt("emailVerified")}"></span>`);t.$headerBadgeWrap.append(e)}if(t.data.is_pinned){const e=mt(`<span class="atk-pinned-badge">${Mt("pin")}</span>`);t.$headerBadgeWrap.append(e)}}function he(t){const e=t.$el.querySelector(".atk-date");e.innerText=t.comment.getDateFormatted(),e.setAttribute("data-atk-comment-date",String(+new Date(t.data.date)))}function ue(t){if(!t.opts.uaBadge&&!t.data.ip_region)return;let e=t.$header.querySelector("atk-ua-wrap");if(e||(e=mt('<span class="atk-ua-wrap"></span>'),t.$header.append(e)),e.innerHTML="",t.data.ip_region){const s=mt('<span class="atk-region-badge"></span>');s.innerText=t.data.ip_region,e.append(s)}if(t.opts.uaBadge){const{browser:s,os:n}=t.comment.getUserUA();if(String(s).trim()){const t=mt('<span class="atk-ua ua-browser"></span>');t.innerText=s,e.append(t)}if(String(n).trim()){const t=mt('<span class="atk-ua ua-os"></span>');t.innerText=n,e.append(t)}}}class pe{constructor(t){h(this,"opts"),h(this,"$el"),h(this,"isLoading",!1),h(this,"msgRecTimer"),h(this,"msgRecTimerFunc"),h(this,"isConfirming",!1),h(this,"confirmRecTimer"),this.$el=mt('<span class="atk-common-action-btn"></span>'),this.opts="object"!=typeof t?{text:t}:t,this.$el.innerText=this.getText(),this.opts.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.opts.text?this.opts.text:this.opts.text()}setClick(t){this.$el.onclick=e=>{if(e.stopPropagation(),!this.isLoading){if(this.opts.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.opts.confirmText||Mt("actionConfirm"),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.opts.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||`${Mt("loading")}...`):(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,s,n){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),n&&n()}),s||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}}function me(t){t.opts.vote&&(t.voteBtnUp=new pe((()=>`${Mt("voteUp")} (${t.data.vote_up||0})`)).appendTo(t.$actions),t.voteBtnUp.setClick((()=>{t.comment.getActions().vote("up")})),t.opts.voteDown&&(t.voteBtnDown=new pe((()=>`${Mt("voteDown")} (${t.data.vote_down||0})`)).appendTo(t.$actions),t.voteBtnDown.setClick((()=>{t.comment.getActions().vote("down")}))))}function ge(t){if(!t.data.is_allow_reply)return;const e=mt(`<span>${Mt("reply")}</span>`);t.$actions.append(e),e.addEventListener("click",(e=>{e.stopPropagation(),t.opts.replyComment(t.data,t.$el)}))}function fe(t){const e=new pe({text:()=>t.data.is_collapsed?Mt("expand"):Mt("collapse"),adminOnly:!0});e.appendTo(t.$actions),e.setClick((()=>{t.comment.getActions().adminEdit("collapsed",e)}))}function ye(t){const e=new pe({text:()=>t.data.is_pending?Mt("pending"):Mt("approved"),adminOnly:!0});e.appendTo(t.$actions),e.setClick((()=>{t.comment.getActions().adminEdit("pending",e)}))}function ke(t){const e=new pe({text:()=>t.data.is_pinned?Mt("unpin"):Mt("pin"),adminOnly:!0});e.appendTo(t.$actions),e.setClick((()=>{t.comment.getActions().adminEdit("pinned",e)}))}function ve(t){const e=new pe({text:Mt("edit"),adminOnly:!0});e.appendTo(t.$actions),e.setClick((()=>{t.opts.editComment(t.data,t.$el)}))}function $e(t){const e=new pe({text:Mt("delete"),confirm:!0,confirmText:Mt("deleteConfirm"),adminOnly:!0});e.appendTo(t.$actions),e.setClick((()=>{t.comment.getActions().adminDelete(e)}))}const we={Avatar:function(t){const e=t.$el.querySelector(".atk-avatar"),s=mt("<img />"),n=t.opts.avatarURLBuilder;if(s.src=n?n(t.data):t.comment.getGravatarURL(),t.data.link){const n=mt('<a target="_blank" rel="noreferrer noopener nofollow"></a>');n.href=wt(t.data.link)?t.data.link:`https://${t.data.link}`,n.append(s),e.append(n)}else e.append(s)},Header:function(t){Object.entries({renderNick:ce,renderVerifyBadge:de,renderDate:he,renderUABadge:ue}).forEach((([e,s])=>{s(t)}))},Content:function(t){if(!t.data.is_collapsed)return t.$content.innerHTML=t.comment.getContentMarked(),void t.$content.classList.remove("atk-hide","atk-collapsed");t.$content.classList.add("atk-hide","atk-type-collapsed");const e=mt(`\n <div class="atk-collapsed">\n <span class="atk-text">${Mt("collapsedMsg")}</span>\n <span class="atk-show-btn">${Mt("expand")}</span>\n </div>`);t.$body.insertAdjacentElement("beforeend",e);const s=e.querySelector(".atk-show-btn");s.addEventListener("click",(e=>{e.stopPropagation(),t.$content.classList.contains("atk-hide")?(t.$content.innerHTML=t.comment.getContentMarked(),t.$content.classList.remove("atk-hide"),_t(t.$content),s.innerText=Mt("collapse")):(t.$content.innerHTML="",t.$content.classList.add("atk-hide"),s.innerText=Mt("expand"))}))},ReplyAt:function(t){t.opts.flatMode||0===t.data.rid||t.opts.replyTo&&(t.$replyAt=mt('<span class="atk-item atk-reply-at"><span class="atk-arrow"></span><span class="atk-nick"></span></span>'),t.$replyAt.querySelector(".atk-nick").innerText=`${t.opts.replyTo.nick}`,t.$replyAt.onclick=()=>{t.comment.getActions().goToReplyComment()},t.$headerBadgeWrap.insertAdjacentElement("afterend",t.$replyAt))},ReplyTo:function(t){if(!t.opts.flatMode)return;if(!t.opts.replyTo)return;t.$replyTo=mt(`\n <div class="atk-reply-to">\n <div class="atk-meta">${Mt("reply")} <span class="atk-nick"></span>:</div>\n <div class="atk-content"></div>\n </div>`);const e=t.$replyTo.querySelector(".atk-nick");e.innerText=`@${t.opts.replyTo.nick}`,e.onclick=()=>{t.comment.getActions().goToReplyComment()};let s=ht(t.opts.replyTo.content);t.opts.replyTo.is_collapsed&&(s=`[${Mt("collapsed")}]`),t.$replyTo.querySelector(".atk-content").innerHTML=s,t.$body.prepend(t.$replyTo)},Pending:function(t){if(!t.data.is_pending)return;const e=mt(`<div class="atk-pending">${Mt("pendingMsg")}</div>`);t.$body.prepend(e)},Actions:function(t){Object.entries({renderVote:me,renderReply:ge,renderCollapse:fe,renderModerator:ye,renderPin:ke,renderEdit:ve,renderDel:$e}).forEach((([e,s])=>{s(t)}))}};class be{constructor(t){h(this,"comment"),h(this,"$el"),h(this,"$main"),h(this,"$header"),h(this,"$headerNick"),h(this,"$headerBadgeWrap"),h(this,"$body"),h(this,"$content"),h(this,"$childrenWrap"),h(this,"$actions"),h(this,"voteBtnUp"),h(this,"voteBtnDown"),h(this,"$replyTo"),h(this,"$replyAt"),this.comment=t}get data(){return this.comment.getData()}get opts(){return this.comment.getOpts()}render(){var t;return this.$el=mt('<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-badge-wrap"></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.$el.setAttribute("id",`atk-comment-${this.data.id}`),t=this,Object.entries(we).forEach((([e,s])=>{s(t)})),this.$childrenWrap&&this.$main.append(this.$childrenWrap),this.$el}checkHeightLimit(){const t=this.opts.heightLimit;if(!t||!t.content||!t.children)return;const e=t.content,s=t.children;oe({afterExpandBtnClick:()=>{const t=this.comment.getChildren();1===t.length&&re(t[0].getRender().$content)},scrollable:t.scrollable},[{el:this.$content,max:e,imgCheck:!0},{el:this.$replyTo,max:e,imgCheck:!0},{el:this.$childrenWrap,max:s,imgCheck:!1}])}heightLimitRemoveForChildren(){this.$childrenWrap&&re(this.$childrenWrap)}playFadeAnim(){_t(this.comment.getRender().$el)}playFadeAnimForBody(){_t(this.comment.getRender().$body)}playFlashAnim(){this.$el.classList.remove("atk-flash-once"),window.setTimeout((()=>{this.$el.classList.add("atk-flash-once")}),150)}getChildrenWrap(){return this.$childrenWrap||(this.$childrenWrap=mt('<div class="atk-comment-children"></div>'),this.$main.append(this.$childrenWrap)),this.$childrenWrap}setUnread(t){t?this.$el.classList.add("atk-unread"):this.$el.classList.remove("atk-unread")}setOpenable(t){t?this.$el.classList.add("atk-openable"):this.$el.classList.remove("atk-openable")}setOpenURL(t){this.setOpenable(!0),this.$el.onclick=e=>{e.stopPropagation(),window.open(t)}}setOpenAction(t){this.setOpenable(!0),this.$el.onclick=e=>{e.stopPropagation(),t()}}}class Ce{constructor(t){h(this,"comment"),this.comment=t}get data(){return this.comment.getData()}get opts(){return this.comment.getOpts()}getApi(){return this.comment.getOpts().getApi()}vote(t){const e="up"===t?this.comment.getRender().voteBtnUp:this.comment.getRender().voteBtnDown;this.getApi().votes.vote(`comment_${t}`,this.data.id,c({},this.getApi().getUserFields())).then((t=>{var e,s;this.data.vote_up=t.data.up,this.data.vote_down=t.data.down,null==(e=this.comment.getRender().voteBtnUp)||e.updateText(),null==(s=this.comment.getRender().voteBtnDown)||s.updateText()})).catch((t=>{null==e||e.setError(Mt("voteFail")),console.error(t)}))}adminEdit(t,e){if(e.isLoading)return;e.setLoading(!0,`${Mt("editing")}...`);const s=c({},this.data);"collapsed"===t?s.is_collapsed=!s.is_collapsed:"pending"===t?s.is_pending=!s.is_pending:"pinned"===t&&(s.is_pinned=!s.is_pinned),this.getApi().comments.updateComment(this.data.id,c({},s)).then((t=>{e.setLoading(!1),this.comment.setData(t.data)})).catch((t=>{console.error(t),e.setError(Mt("editFail"))}))}adminDelete(t){t.isLoading||(t.setLoading(!0,`${Mt("deleting")}...`),this.getApi().comments.deleteComment(this.data.id).then((()=>{t.setLoading(!1),this.opts.onDelete&&this.opts.onDelete(this.comment)})).catch((e=>{console.error(e),t.setError(Mt("deleteFail"))})))}goToReplyComment(){const t=window.location.hash,e=`#atk-comment-${this.data.rid}`;window.location.hash=e,e===t&&window.dispatchEvent(new Event("hashchange"))}}class xe{constructor(t,e){h(this,"$el"),h(this,"renderInstance"),h(this,"actionInstance"),h(this,"data"),h(this,"opts"),h(this,"parent"),h(this,"children",[]),h(this,"nestCurt"),this.opts=e,this.data=c({},t),this.data.date=this.data.date.replace(/-/g,"/"),this.parent=null,this.nestCurt=1,this.actionInstance=new Ce(this),this.renderInstance=new be(this)}render(){const t=this.renderInstance.render();this.$el&&this.$el.replaceWith(t),this.$el=t,this.opts.onAfterRender&&this.opts.onAfterRender()}getActions(){return this.actionInstance}getRender(){return this.renderInstance}getData(){return this.data}setData(t){this.data=t,this.render(),this.getRender().playFadeAnimForBody()}getParent(){return this.parent}getChildren(){return this.children}getNestCurt(){return this.nestCurt}getIsRoot(){return 0===this.data.rid}getID(){return this.data.id}putChild(t,e="append"){t.parent=this,t.nestCurt=this.nestCurt+1,this.children.push(t);const s=this.getChildrenWrapEl(),n=t.getEl();"append"===e?s.append(n):"prepend"===e&&s.prepend(n),t.getRender().playFadeAnim(),t.getRender().checkHeightLimit()}getChildrenWrapEl(){return this.nestCurt>=this.opts.nestMax?this.parent.getChildrenWrapEl():this.getRender().getChildrenWrap()}getParents(){const t=[];let e=this.parent;for(;e;)t.push(e),e=e.getParent();return t}getEl(){if(!this.$el)throw new Error("comment element not initialized before `getEl()`");return this.$el}focus(){if(!this.$el)throw new Error("comment element not initialized before `focus()`");this.getParents().forEach((t=>{t.getRender().heightLimitRemoveForChildren()})),this.scrollIntoView(),this.getRender().playFlashAnim()}scrollIntoView(){this.$el&&Ft(this.$el,!1,this.opts.scrollRelativeTo&&this.opts.scrollRelativeTo())}remove(){var t;null==(t=this.$el)||t.remove()}getGravatarURL(){return`${(t={mirror:this.opts.gravatar.mirror,params:this.opts.gravatar.params,emailHash:this.data.email_encrypted}).mirror.replace(/\/$/,"")}/${t.emailHash}?${t.params.replace(/^\?/,"")}`;var t}getContentMarked(){return ht(this.data.content)}getDateFormatted(){var t,e;const s=new Date(this.data.date);return(null==(e=(t=this.opts).dateFormatter)?void 0:e.call(t,s))||vt(s,Mt)}getUserUA(){const t=function(t){const e=window||{},s=navigator||{},n=String(t||s.userAgent),i={os:"",osVersion:"",engine:"",browser:"",device:"",language:"",version:""},o={Trident:n.includes("Trident")||n.includes("NET CLR"),Presto:n.includes("Presto"),WebKit:n.includes("AppleWebKit"),Gecko:n.includes("Gecko/")},a={Safari:n.includes("Safari"),Chrome:n.includes("Chrome")||n.includes("CriOS"),IE:n.includes("MSIE")||n.includes("Trident"),Edge:n.includes("Edge")||n.includes("Edg"),Firefox:n.includes("Firefox")||n.includes("FxiOS"),"Firefox Focus":n.includes("Focus"),Chromium:n.includes("Chromium"),Opera:n.includes("Opera")||n.includes("OPR"),Vivaldi:n.includes("Vivaldi"),Yandex:n.includes("YaBrowser"),Kindle:n.includes("Kindle")||n.includes("Silk/"),360:n.includes("360EE")||n.includes("360SE"),UC:n.includes("UC")||n.includes(" UBrowser"),QQBrowser:n.includes("QQBrowser"),QQ:n.includes("QQ/"),Baidu:n.includes("Baidu")||n.includes("BIDUBrowser"),Maxthon:n.includes("Maxthon"),Sogou:n.includes("MetaSr")||n.includes("Sogou"),LBBROWSER:n.includes("LBBROWSER"),"2345Explorer":n.includes("2345Explorer"),TheWorld:n.includes("TheWorld"),MIUI:n.includes("MiuiBrowser"),Quark:n.includes("Quark"),Qiyu:n.includes("Qiyu"),Wechat:n.includes("MicroMessenger"),Taobao:n.includes("AliApp(TB"),Alipay:n.includes("AliApp(AP"),Weibo:n.includes("Weibo"),Douban:n.includes("com.douban.frodo"),Suning:n.includes("SNEBUY-APP"),iQiYi:n.includes("IqiyiApp")},r={Windows:n.includes("Windows"),Linux:n.includes("Linux")||n.includes("X11"),macOS:n.includes("Macintosh"),Android:n.includes("Android")||n.includes("Adr"),Ubuntu:n.includes("Ubuntu"),FreeBSD:n.includes("FreeBSD"),Debian:n.includes("Debian"),"Windows Phone":n.includes("IEMobile")||n.includes("Windows Phone"),BlackBerry:n.includes("BlackBerry")||n.includes("RIM"),MeeGo:n.includes("MeeGo"),Symbian:n.includes("Symbian"),iOS:n.includes("like Mac OS X"),"Chrome OS":n.includes("CrOS"),WebOS:n.includes("hpwOS")},l={Mobile:n.includes("Mobi")||n.includes("iPh")||n.includes("480"),Tablet:n.includes("Tablet")||n.includes("Pad")||n.includes("Nexus 7")};l.Mobile?l.Mobile=!n.includes("iPad"):a.Chrome&&n.includes("Edg")?(a.Chrome=!1,a.Edge=!0):e.showModalDialog&&e.chrome&&(a.Chrome=!1,a[360]=!0),i.device="PC",i.language=(()=>{const t=(s.browserLanguage||s.language).split("-");return t[1]&&(t[1]=t[1].toUpperCase()),t.join("_")})();const c={engine:o,browser:a,os:r,device:l};Object.entries(c).forEach((([t,e])=>{Object.entries(e).forEach((([e,s])=>{!0===s&&(i[t]=e)}))}));const d={Windows:()=>{const t=n.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","10.0":"10","11.0":"11"}[t]||t},Android:()=>n.replace(/^.*Android ([\d.]+);.*$/,"$1"),iOS:()=>n.replace(/^.*OS ([\d_]+) like.*$/,"$1").replace(/_/g,"."),Debian:()=>n.replace(/^.*Debian\/([\d.]+).*$/,"$1"),"Windows Phone":()=>n.replace(/^.*Windows Phone( OS)? ([\d.]+);.*$/,"$2"),macOS:()=>n.replace(/^.*Mac OS X ([\d_]+).*$/,"$1").replace(/_/g,"."),WebOS:()=>n.replace(/^.*hpwOS\/([\d.]+);.*$/,"$1")};i.osVersion="",d[i.os]&&(i.osVersion=d[i.os](),i.osVersion===n&&(i.osVersion=""));const h={Safari:()=>n.replace(/^.*Version\/([\d.]+).*$/,"$1"),Chrome:()=>n.replace(/^.*Chrome\/([\d.]+).*$/,"$1").replace(/^.*CriOS\/([\d.]+).*$/,"$1"),IE:()=>n.replace(/^.*MSIE ([\d.]+).*$/,"$1").replace(/^.*rv:([\d.]+).*$/,"$1"),Edge:()=>n.replace(/^.*(Edge|Edg|Edg[A-Z]{1})\/([\d.]+).*$/,"$2"),Firefox:()=>n.replace(/^.*Firefox\/([\d.]+).*$/,"$1").replace(/^.*FxiOS\/([\d.]+).*$/,"$1"),"Firefox Focus":()=>n.replace(/^.*Focus\/([\d.]+).*$/,"$1"),Chromium:()=>n.replace(/^.*Chromium\/([\d.]+).*$/,"$1"),Opera:()=>n.replace(/^.*Opera\/([\d.]+).*$/,"$1").replace(/^.*OPR\/([\d.]+).*$/,"$1"),Vivaldi:()=>n.replace(/^.*Vivaldi\/([\d.]+).*$/,"$1"),Yandex:()=>n.replace(/^.*YaBrowser\/([\d.]+).*$/,"$1"),Kindle:()=>n.replace(/^.*Version\/([\d.]+).*$/,"$1"),Maxthon:()=>n.replace(/^.*Maxthon\/([\d.]+).*$/,"$1"),QQBrowser:()=>n.replace(/^.*QQBrowser\/([\d.]+).*$/,"$1"),QQ:()=>n.replace(/^.*QQ\/([\d.]+).*$/,"$1"),Baidu:()=>n.replace(/^.*BIDUBrowser[\s/]([\d.]+).*$/,"$1"),UC:()=>n.replace(/^.*UC?Browser\/([\d.]+).*$/,"$1"),Sogou:()=>n.replace(/^.*SE ([\d.X]+).*$/,"$1").replace(/^.*SogouMobileBrowser\/([\d.]+).*$/,"$1"),"2345Explorer":()=>n.replace(/^.*2345Explorer\/([\d.]+).*$/,"$1"),TheWorld:()=>n.replace(/^.*TheWorld ([\d.]+).*$/,"$1"),MIUI:()=>n.replace(/^.*MiuiBrowser\/([\d.]+).*$/,"$1"),Quark:()=>n.replace(/^.*Quark\/([\d.]+).*$/,"$1"),Qiyu:()=>n.replace(/^.*Qiyu\/([\d.]+).*$/,"$1"),Wechat:()=>n.replace(/^.*MicroMessenger\/([\d.]+).*$/,"$1"),Taobao:()=>n.replace(/^.*AliApp\(TB\/([\d.]+).*$/,"$1"),Alipay:()=>n.replace(/^.*AliApp\(AP\/([\d.]+).*$/,"$1"),Weibo:()=>n.replace(/^.*weibo__([\d.]+).*$/,"$1"),Douban:()=>n.replace(/^.*com.douban.frodo\/([\d.]+).*$/,"$1"),Suning:()=>n.replace(/^.*SNEBUY-APP([\d.]+).*$/,"$1"),iQiYi:()=>n.replace(/^.*IqiyiVersion\/([\d.]+).*$/,"$1")};return i.version="",h[i.browser]&&(i.version=h[i.browser](),i.version===n&&(i.version="")),i.version.indexOf(".")&&(i.version=i.version.substring(0,i.version.indexOf("."))),"iOS"===i.os&&n.includes("iPad")?i.os="iPadOS":"Edge"!==i.browser||n.includes("Edg")?"MIUI"===i.browser?i.os="Android":"Chrome"===i.browser&&Number(i.version)>27||"Opera"===i.browser&&Number(i.version)>12||"Yandex"===i.browser?i.engine="Blink":void 0===i.browser&&(i.browser="Unknow App"):i.engine="EdgeHTML",i}(this.data.ua);return{browser:`${t.browser} ${t.version}`,os:`${t.os} ${t.osVersion}`}}getOpts(){return this.opts}}class Ee{constructor(t){h(this,"opts"),h(this,"$el"),h(this,"$loading"),h(this,"$text"),h(this,"offset",0),h(this,"total",0),h(this,"origText","Load More"),this.opts=t,this.origText=this.opts.text||this.origText,this.$el=mt(`<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">${this.origText}</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.opts.pageSize}click(){this.hasMore&&this.opts.onClick(this.offset+this.opts.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.origText,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 Se{constructor(){h(this,"instance"),h(this,"onReachedBottom",null),h(this,"opt")}create(t){return this.opt=t,this.instance=new Ee({pageSize:t.pageSize,onClick:e=>u(this,null,(function*(){t.ctx.fetch({offset:e})})),text:Mt("loadMore")}),t.readMoreAutoLoad&&(this.onReachedBottom=()=>{this.instance.hasMore&&!this.opt.ctx.getData().getLoading()&&this.instance.click()},this.opt.ctx.on("list-reach-bottom",this.onReachedBottom)),this.instance.$el}setLoading(t){this.instance.setLoading(t)}update(t,e){this.instance.update(t,e)}showErr(t){this.instance.showErr(t)}next(){this.instance.click()}getHasMore(){return this.instance.hasMore}getIsClearComments(t){return 0===t.offset}dispose(){this.onReachedBottom&&this.opt.ctx.off("list-reach-bottom",this.onReachedBottom),this.instance.$el.remove()}}class Te{constructor(t,e){h(this,"opts"),h(this,"total"),h(this,"$el"),h(this,"$input"),h(this,"inputTimer"),h(this,"$prevBtn"),h(this,"$nextBtn"),h(this,"page",1),this.total=t,this.opts=e,this.$el=mt('<div class="atk-pagination-wrap">\n <div class="atk-pagination">\n <div class="atk-btn atk-btn-prev" aria-label="Previous page">\n <svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 512 512" height="14px" width="14px" xmlns="http://www.w3.org/2000/svg"><path d="M217.9 256L345 129c9.4-9.4 9.4-24.6 0-33.9-9.4-9.4-24.6-9.3-34 0L167 239c-9.1 9.1-9.3 23.7-.7 33.1L310.9 417c4.7 4.7 10.9 7 17 7s12.3-2.3 17-7c9.4-9.4 9.4-24.6 0-33.9L217.9 256z"></path></svg>\n </div>\n <input type="text" class="atk-input" aria-label="Enter the number of page" />\n <div class="atk-btn atk-btn-next" aria-label="Next page">\n <svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 512 512" height="14px" width="14px" xmlns="http://www.w3.org/2000/svg"><path d="M294.1 256L167 129c-9.4-9.4-9.4-24.6 0-33.9s24.6-9.3 34 0L345 239c9.1 9.1 9.3 23.7.7 33.1L201.1 417c-4.7 4.7-10.9 7-17 7s-12.3-2.3-17-7c-9.4-9.4-9.4-24.6 0-33.9l127-127.1z"></path></svg>\n </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.opts.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(),s=()=>{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?s():this.inputTimer=window.setTimeout((()=>s()),800)}prev(){const t=this.page-1;t<1||this.change(t)}next(){const t=this.page+1;t>this.maxPage||this.change(t)}getHasMore(){return this.page+1<=this.maxPage}change(t){this.page=t,this.opts.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?Rt(this.$el):Bt(this.$el)}}class Le{constructor(){h(this,"instance")}create(t){return this.instance=new Te(t.total,{pageSize:t.pageSize,onChange:e=>u(this,null,(function*(){t.ctx.editorResetState(),t.ctx.fetch({offset:e,onSuccess:()=>{t.ctx.listGotoFirst()}})}))}),this.instance.$el}setLoading(t){this.instance.setLoading(t)}update(t,e){this.instance.update(t,e)}next(){this.instance.next()}getHasMore(){return this.instance.getHasMore()}getIsClearComments(){return!0}dispose(){this.instance.$el.remove()}}function Ae(t){const e=t.getData().getListLastFetch(),s={offset:0,total:0};return e?(s.offset=e.params.offset,e.data&&(s.total=e.params.flatMode?e.data.count:e.data.roots_count),s):s}const Me=t=>{let e=null;t.watchConf(["pagination","locale"],(s=>{const n=t.get("list");e&&e.dispose(),e=function(t){return t.pagination.readMore?new Se:new Le}(s);const{offset:i,total:o}=Ae(t),a=e.create({ctx:t,pageSize:s.pagination.pageSize,total:o,readMoreAutoLoad:s.pagination.autoLoad});n.$commentsWrap.after(a),null==e||e.update(i,o)})),t.on("list-loaded",(s=>{const{offset:n,total:i}=Ae(t);null==e||e.update(n,i)})),t.on("list-fetch",(s=>{t.getData().getComments().length>0&&(null==e?void 0:e.getIsClearComments(s))&&t.getData().clearComments()})),t.on("list-failed",(()=>{var t;null==(t=null==e?void 0:e.showErr)||t.call(e,Mt("loadFail"))})),t.on("list-fetch",(t=>{null==e||e.setLoading(!0)})),t.on("list-fetched",(({params:t})=>{null==e||e.setLoading(!1)}))};class Pe extends Qt{constructor(t){super(t),h(this,"$commentsWrap"),h(this,"commentNodes",[]),this.$el=mt('<div class="atk-list">\n <div class="atk-list-header">\n <div class="atk-comment-count">\n <div class="atk-text"></div>\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">\n <div class="atk-list-comments-wrap"></div>\n </div>\n <div class="atk-list-footer">\n <div class="atk-copyright"></div>\n </div>\n</div>\n'),this.$commentsWrap=this.$el.querySelector(".atk-list-comments-wrap"),Me(t),this.initCrudEvents()}getCommentsWrapEl(){return this.$commentsWrap}getCommentNodes(){return this.commentNodes}getListLayout({forceFlatMode:t}={}){return new ie({$commentsWrap:this.$commentsWrap,nestSortBy:this.ctx.conf.nestSort,nestMax:this.ctx.conf.nestMax,flatMode:"boolean"==typeof t?t:this.ctx.conf.flatMode,createCommentNode:(e,s)=>{const n=function(t,e,s,n){const i=new xe(e,{onAfterRender:()=>{t.trigger("comment-rendered",i)},onDelete:e=>{t.getData().deleteComment(e.getID())},replyTo:s,flatMode:"boolean"==typeof(null==n?void 0:n.forceFlatMode)?null==n?void 0:n.forceFlatMode:t.conf.flatMode,gravatar:t.conf.gravatar,nestMax:t.conf.nestMax,heightLimit:t.conf.heightLimit,avatarURLBuilder:t.conf.avatarURLBuilder,scrollRelativeTo:t.conf.scrollRelativeTo,vote:t.conf.vote,voteDown:t.conf.voteDown,uaBadge:t.conf.uaBadge,dateFormatter:t.conf.dateFormatter,getApi:()=>t.getApi(),replyComment:(e,s)=>t.replyComment(e,s),editComment:(e,s)=>t.editComment(e,s)});return i.render(),i}(this.ctx,e,s,{forceFlatMode:t});return this.commentNodes.push(n),n},findCommentNode:t=>this.commentNodes.find((e=>e.getID()===t))})}initCrudEvents(){this.ctx.on("list-load",(t=>{this.getListLayout().import(t)})),this.ctx.on("list-loaded",(t=>{0===t.length&&(this.commentNodes=[],this.$commentsWrap.innerHTML="")})),this.ctx.on("comment-inserted",(t=>{var e;const s=t.rid?null==(e=this.commentNodes.find((e=>e.getID()===t.rid)))?void 0:e.getData():void 0;this.getListLayout().insert(t,s)})),this.ctx.on("comment-deleted",(t=>{const e=this.commentNodes.find((e=>e.getID()===t.id));e?(e.remove(),this.commentNodes=this.commentNodes.filter((e=>e.getID()!==t.id))):console.error(`comment node id=${t.id} not found`)})),this.ctx.on("comment-updated",(t=>{const e=this.commentNodes.find((e=>e.getID()===t.id));e&&e.setData(t)}))}}let Ue,Ie;function Oe(){return{init(){Ue=document.body.style.overflow,Ie=document.body.style.paddingRight},unlock(){document.body.style.overflow=Ue,document.body.style.paddingRight=Ie},lock(){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 s=t.offsetWidth;e.style.overflow="scroll";let n=t.offsetWidth;return s===n&&(n=e.clientWidth),document.body.removeChild(e),s-n}()+t||0}px`}}}class qe{constructor(t,e){h(this,"allowMaskClose",!0),h(this,"onAfterHide"),this.$el=t,this.opts=e}setOnAfterHide(t){this.onAfterHide=t}setAllowMaskClose(t){this.allowMaskClose=t}getAllowMaskClose(){return this.allowMaskClose}getEl(){return this.$el}show(){this.opts.onShow(),this.$el.style.display=""}hide(){this.opts.onHide(),this.$el.style.display="none",this.onAfterHide&&this.onAfterHide()}destroy(){this.opts.onHide(),this.$el.remove(),this.onAfterHide&&this.onAfterHide()}}class De{constructor(){h(this,"$wrap"),h(this,"$mask"),h(this,"items",[]),this.$wrap=mt('<div class="atk-layer-wrap" style="display: none;"><div class="atk-layer-mask"></div></div>'),this.$mask=this.$wrap.querySelector(".atk-layer-mask")}createItem(t,e){(e=e||this.createItemElement(t)).setAttribute("data-layer-name",t),this.$wrap.appendChild(e);const s=new qe(e,{onHide:()=>this.hideWrap(e),onShow:()=>this.showWrap()});return this.getMask().addEventListener("click",(()=>{s.getAllowMaskClose()&&s.hide()})),this.items.push(s),s}createItemElement(t){const e=document.createElement("div");return e.classList.add("atk-layer-item"),e.style.display="none",this.$wrap.appendChild(e),e}getWrap(){return this.$wrap}getMask(){return this.$mask}showWrap(){this.$wrap.style.display="block",this.$mask.style.display="block",this.$mask.classList.add("atk-fade-in"),Oe().lock()}hideWrap(t){this.items.map((t=>t.getEl())).filter((e=>e!==t&&e.isConnected&&"none"!==e.style.display)).length>0||(this.$wrap.style.display="none",Oe().unlock())}}class Re{constructor(t){h(this,"wrap"),this.wrap=new De,document.body.appendChild(this.wrap.getWrap()),t.on("unmounted",(()=>{this.wrap.getWrap().remove()})),Oe().init()}getEl(){return this.wrap.getWrap()}create(t,e){return this.wrap.createItem(t,e)}}const Be="ArtalkUser";class je{constructor(t){h(this,"data"),this.opts=t;const e=JSON.parse(window.localStorage.getItem(Be)||"{}");this.data={name:e.name||e.nick||"",email:e.email||"",link:e.link||"",token:e.token||"",is_admin:e.is_admin||e.isAdmin||!1}}getData(){return this.data}update(t={}){Object.entries(t).forEach((([t,e])=>{this.data[t]=e})),window.localStorage.setItem(Be,JSON.stringify(this.data)),this.opts.onUserChanged&&this.opts.onUserChanged(this.data)}logout(){this.update({token:"",is_admin:!1})}checkHasBasicUserInfo(){return!!this.data.name&&!!this.data.email}}const Fe={i18n(t){At(t.conf.locale),t.watchConf(["locale"],(t=>{At(t.locale)}))},user:t=>new je({onUserChanged:e=>{t.trigger("user-changed",e)}}),layerManager:t=>new Re(t),checkerLauncher:t=>new Kt({getCtx:()=>t,getApi:()=>t.getApi(),onReload:()=>t.reload(),getCaptchaIframeURL:()=>`${t.conf.server}/api/v2/captcha/?t=${+new Date}`}),editor(t){const e=new te(t);return t.$root.appendChild(e.$el),e},list(t){const e=new Pe(t);return t.$root.appendChild(e.$el),e},sidebarLayer:t=>new ee(t),editorPlugs(){}};function _e(t){return u(this,null,(function*(){yield function(t){return u(this,null,(function*(){yield We({opt:t,query:"page_comment",containers:[t.countEl,"#ArtalkCount"]})}))}(t);const e=yield function(t){return u(this,null,(function*(){if(!t.pvAdd||!t.pageKey)return;const e=(yield t.getApi().pages.logPv({page_key:t.pageKey,page_title:t.pageTitle,site_name:t.siteName})).data.pv;return{[t.pageKey]:e}}))}(t);yield function(t,e){return u(this,null,(function*(){yield We({opt:t,query:"page_pv",containers:[t.pvEl,"#ArtalkPV"],cache:e})}))}(t,e)}))}function We(t){return u(this,null,(function*(){const{opt:e}=t;let s=t.cache||{};const n=function(t){const e=new Set;return new Set(t).forEach((t=>{document.querySelectorAll(t).forEach((t=>e.add(t)))})),e}(t.containers),i=function(t,e,s,n){const i=Array.from(t).map((t=>t.getAttribute(e)||s)).filter((t=>t&&"number"!=typeof n[t]));return[...new Set(i)]}(n,e.pageKeyAttr,e.pageKey,s);if(i.length>0){const n=(yield e.getApi().stats.getStats(t.query,{page_keys:i.join(","),site_name:e.siteName})).data.data;s=c(c({},s),n)}!function(t,e,s){t.forEach((t=>{const n=t.getAttribute("data-page-key"),i=n&&e[n]||s&&e[s]||0;t.innerText=`${Number(i)}`}))}(n,s,e.pageKey)}))}const Ne="ArtalkContent";class He{constructor(t){this.kit=t}reqAdd(){return u(this,null,(function*(){return(yield this.kit.useApi().comments.createComment(c({},yield this.getSubmitAddParams()))).data}))}getSubmitAddParams(){return u(this,null,(function*(){const{name:t,email:e,link:s}=this.kit.useUser().getData(),n=this.kit.useConf();return{content:this.kit.useEditor().getContentFinal(),name:t,email:e,link:s,rid:0,page_key:n.pageKey,page_title:n.pageTitle,site_name:n.site,ua:yield $t()}}))}postSubmitAdd(t){this.kit.useGlobalCtx().getData().insertComment(t)}}class ze extends Jt{constructor(t){super(t),h(this,"customs",[]),h(this,"defaultPreset"),this.defaultPreset=new He(this.kit);const e=()=>this.do();this.kit.useMounted((()=>{this.kit.useGlobalCtx().on("editor-submit",e)})),this.kit.useUnmounted((()=>{this.kit.useGlobalCtx().off("editor-submit",e)}))}registerCustom(t){this.customs.push(t)}do(){return u(this,null,(function*(){if(""===this.kit.useEditor().getContentFinal().trim())return void this.kit.useEditor().focus();const t=this.customs.find((t=>t.activeCond()));this.kit.useEditor().showLoading();try{let e;(null==t?void 0:t.pre)&&t.pre(),e=(null==t?void 0:t.req)?yield t.req():yield this.defaultPreset.reqAdd(),(null==t?void 0:t.post)?t.post(e):this.defaultPreset.postSubmitAdd(e)}catch(e){return console.error(e),void this.kit.useEditor().showNotify(`${Mt("commentFail")}: ${e.message||String(e)}`,"e")}finally{this.kit.useEditor().hideLoading()}this.kit.useEditor().reset(),this.kit.useGlobalCtx().trigger("editor-submitted")}))}}class Ve extends Jt{constructor(t){super(t),h(this,"emoticons",[]),h(this,"loadingTask",null),h(this,"$grpWrap"),h(this,"$grpSwitcher"),h(this,"isListLoaded",!1),h(this,"isImgLoaded",!1),this.kit.useMounted((()=>{this.usePanel('<div class="atk-editor-plug-emoticons"></div>'),this.useBtn(`<i aria-label="${Mt("emoticon")}"><svg fill="currentColor" aria-hidden="true" height="14" viewBox="0 0 14 14" width="14"><path d="m4.26829 5.29294c0-.94317.45893-1.7074 1.02439-1.7074.56547 0 1.02439.76423 1.02439 1.7074s-.45892 1.7074-1.02439 1.7074c-.56546 0-1.02439-.76423-1.02439-1.7074zm4.43903 1.7074c.56546 0 1.02439-.76423 1.02439-1.7074s-.45893-1.7074-1.02439-1.7074c-.56547 0-1.02439.76423-1.02439 1.7074s.45892 1.7074 1.02439 1.7074zm-1.70732 2.73184c-1.51883 0-2.06312-1.52095-2.08361-1.58173l-1.29551.43231c.03414.10244.868 2.51604 3.3798 2.51604 2.51181 0 3.34502-2.41291 3.37982-2.51604l-1.29484-.43573c-.02254.06488-.56683 1.58583-2.08498 1.58583zm7-2.73252c0 3.86004-3.1401 7.00034-7 7.00034s-7-3.1396-7-6.99966c0-3.86009 3.1401-7.00034 7-7.00034s7 3.14025 7 7.00034zm-1.3659 0c0-3.10679-2.5275-5.63442-5.6341-5.63442-3.10663 0-5.63415 2.52832-5.63415 5.6351 0 3.10676 2.52752 5.63446 5.63415 5.63446 3.1066 0 5.6341-2.5277 5.6341-5.63446z"/></svg></i>`)})),this.kit.useUnmounted((()=>{})),this.useContentTransformer((t=>this.transEmoticonImageText(t))),this.usePanelShow((()=>{(()=>{u(this,null,(function*(){yield this.loadEmoticonsData(),this.isImgLoaded||(this.initEmoticonsList(),this.isImgLoaded=!0),setTimeout((()=>{this.changeListHeight()}),30)}))})()})),this.usePanelHide((()=>{this.$panel.parentElement.style.height=""})),window.setTimeout((()=>{this.loadEmoticonsData()}),1e3)}loadEmoticonsData(){return u(this,null,(function*(){this.isListLoaded||(null===this.loadingTask?(this.loadingTask=(()=>u(this,null,(function*(){Rt(this.$panel),this.emoticons=yield this.handleData(this.kit.useConf().emoticons),Bt(this.$panel),this.loadingTask=null,this.isListLoaded=!0})))(),yield this.loadingTask):yield this.loadingTask)}))}handleData(t){return u(this,null,(function*(){if(!Array.isArray(t)&&["object","string"].includes(typeof t)&&(t=[t]),!Array.isArray(t))return Wt(this.$panel,`[${Mt("emoticon")}] Data must be of Array/Object/String type`),Bt(this.$panel),[];const e=e=>{"object"==typeof e&&(e.name&&t.find((t=>t.name===e.name))||t.push(e))},s=t=>u(this,null,(function*(){yield Promise.all(t.map(((t,n)=>u(this,null,(function*(){if("object"!=typeof t||Array.isArray(t)){if(Array.isArray(t))yield s(t);else if("string"==typeof t){const n=yield this.remoteLoad(t);Array.isArray(n)?yield s(n):"object"==typeof n&&e(n)}}else e(t)})))))}));return yield s(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)),this.solveNullKey(t),this.solveSameKey(t),t}))}remoteLoad(t){return u(this,null,(function*(){if(!t)return[];try{const e=yield fetch(t);return yield e.json()}catch(e){return Bt(this.$panel),console.error("[Emoticons] Load Failed:",e),Wt(this.$panel,`[${Mt("emoticon")}] ${Mt("loadFail")}: ${String(e)}`),[]}}))}solveNullKey(t){t.forEach((t=>{t.items.forEach(((e,s)=>{e.key||(e.key=`${t.name} ${s+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,s])=>{const n={name:t,type:s.type,items:[]};s.container.forEach(((e,s)=>{const i=e.icon;if(/<(img|IMG)/.test(i)){const t=/src=["'](.*?)["']/.exec(i);t&&t.length>1&&(e.icon=t[1])}n.items.push({key:e.text||`${t} ${s+1}`,val:e.icon})})),e.push(n)})),e}initEmoticonsList(){this.$grpWrap=mt('<div class="atk-grp-wrap"></div>'),this.$panel.append(this.$grpWrap),this.emoticons.forEach(((t,e)=>{const s=mt('<div class="atk-grp" style="display: none;"></div>');this.$grpWrap.append(s),s.setAttribute("data-index",String(e)),s.setAttribute("data-grp-name",t.name),s.setAttribute("data-type",t.type),t.items.forEach((e=>{const n=mt('<span class="atk-item"></span>');if(s.append(n),e.key&&!new RegExp(`^(${t.name})?\\s?[0-9]+$`).test(e.key)&&n.setAttribute("title",e.key),"image"===t.type){const t=document.createElement("img");t.src=e.val,t.alt=e.key,n.append(t)}else n.innerText=e.val;n.onclick=()=>{"image"===t.type?this.kit.useEditor().insertContent(`:[${e.key}]`):this.kit.useEditor().insertContent(e.val||"")}}))})),this.emoticons.length>1&&(this.$grpSwitcher=mt('<div class="atk-grp-switcher"></div>'),this.$panel.append(this.$grpSwitcher),this.emoticons.forEach(((t,e)=>{const s=mt("<span />");s.innerText=t.name,s.setAttribute("data-index",String(e)),s.onclick=()=>this.openGrp(e),this.$grpSwitcher.append(s)}))),this.emoticons.length>0&&this.openGrp(0)}openGrp(t){var e,s,n;Array.from(this.$grpWrap.children).forEach((e=>{const s=e;s.getAttribute("data-index")!==String(t)?s.style.display="none":s.style.display=""})),null==(e=this.$grpSwitcher)||e.querySelectorAll("span.active").forEach((t=>t.classList.remove("active"))),null==(n=null==(s=this.$grpSwitcher)?void 0:s.querySelector(`span[data-index="${t}"]`))||n.classList.add("active"),this.changeListHeight()}changeListHeight(){}transEmoticonImageText(t){return this.emoticons&&Array.isArray(this.emoticons)?(this.emoticons.forEach((e=>{"image"===e.type&&Object.entries(e.items).forEach((([e,s])=>{t=t.split(`:[${s.key}]`).join(`<img src="${s.val}" atk-emoticon="${s.key}">`)}))})),t):t}}const Ge=["png","jpg","jpeg","gif","bmp","svg","webp"];class Ke extends Jt{constructor(t){super(t),h(this,"$imgUploadInput"),this.kit.useMounted((()=>this.init())),this.initDragImg()}init(){this.$imgUploadInput=document.createElement("input"),this.$imgUploadInput.type="file",this.$imgUploadInput.style.display="none",this.$imgUploadInput.accept=Ge.map((t=>`.${t}`)).join(",");const t=this.useBtn(`<i aria-label="${Mt("uploadImage")}"><svg fill="currentColor" aria-hidden="true" height="14" viewBox="0 0 14 14" width="14"><path d="m0 1.94444c0-1.074107.870333-1.94444 1.94444-1.94444h10.11116c1.0741 0 1.9444.870333 1.9444 1.94444v10.11116c0 1.0741-.8703 1.9444-1.9444 1.9444h-10.11116c-1.074107 0-1.94444-.8703-1.94444-1.9444zm1.94444-.38888c-.21466 0-.38888.17422-.38888.38888v7.06689l2.33333-2.33333 2.33333 2.33333 3.88888-3.88889 2.3333 2.33334v-5.51134c0-.21466-.1742-.38888-.3888-.38888zm10.49996 8.09977-2.3333-2.33333-3.88888 3.8889-2.33333-2.33334-2.33333 2.33334v.8447c0 .2146.17422.3888.38888.3888h10.11116c.2146 0 .3888-.1742.3888-.3888zm-7.1944-6.54422c-.75133 0-1.36111.60978-1.36111 1.36111 0 .75134.60978 1.36111 1.36111 1.36111s1.36111-.60977 1.36111-1.36111c0-.75133-.60978-1.36111-1.36111-1.36111z"/></svg></i>`);t.after(this.$imgUploadInput),t.onclick=()=>{const t=this.$imgUploadInput;t.onchange=()=>{(()=>{u(this,null,(function*(){if(!t.files||0===t.files.length)return;const e=t.files[0];this.uploadImg(e)}))})()},t.click()},this.kit.useConf().imgUpload||this.$btn.setAttribute("atk-only-admin-show","")}initDragImg(){const t=t=>{if(t)for(let e=0;e<t.length;e++){const s=t[e];this.uploadImg(s)}},e=t=>{t.stopPropagation(),t.preventDefault()},s=e=>{var s;const n=null==(s=e.dataTransfer)?void 0:s.files;(null==n?void 0:n.length)&&(e.preventDefault(),t(n))},n=e=>{var s;const n=null==(s=e.clipboardData)?void 0:s.files;(null==n?void 0:n.length)&&(e.preventDefault(),t(n))};this.kit.useMounted((()=>{this.kit.useUI().$textarea.addEventListener("dragover",e),this.kit.useUI().$textarea.addEventListener("drop",s),this.kit.useUI().$textarea.addEventListener("paste",n)})),this.kit.useUnmounted((()=>{this.kit.useUI().$textarea.removeEventListener("dragover",e),this.kit.useUI().$textarea.removeEventListener("drop",s),this.kit.useUI().$textarea.removeEventListener("paste",n)}))}uploadImg(t){return u(this,null,(function*(){const e=/[^.]+$/.exec(t.name);if(!e||!Ge.includes(String(e[0]).toLowerCase()))return;if(!this.kit.useUser().checkHasBasicUserInfo())return void this.kit.useEditor().showNotify(Mt("uploadLoginMsg"),"w");let s="\n";""===this.kit.useUI().$textarea.value.trim()&&(s="");const n=`${s}`;let i;this.kit.useEditor().insertContent(n);try{const e=this.kit.useConf().imgUploader;i=e?{public_url:yield e(t)}:(yield this.kit.useApi().upload.upload({file:t})).data}catch(o){console.error(o),this.kit.useEditor().showNotify(`${Mt("uploadFail")}: ${o.message}`,"e")}if(i&&i.public_url){let t=i.public_url;wt(t)||(t=bt({base:this.kit.useConf().server,path:t})),this.kit.useEditor().setContent(this.kit.useUI().$textarea.value.replace(n,`${s}`))}else this.kit.useEditor().setContent(this.kit.useUI().$textarea.value.replace(n,""))}))}}class Qe extends Jt{constructor(t){super(t),h(this,"isPlugPanelShow",!1),this.kit.useMounted((()=>{this.usePanel('<div class="atk-editor-plug-preview"></div>'),this.useBtn(`<i aria-label="${Mt("preview")}"><svg fill="currentColor" aria-hidden="true" viewBox="0 0 16 16" width="16" height="16"><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>`)})),this.kit.useUnmounted((()=>{})),this.kit.useEvents().on("content-updated",(t=>{this.isPlugPanelShow&&this.updateContent()})),this.usePanelShow((()=>{this.isPlugPanelShow=!0,this.updateContent()})),this.usePanelHide((()=>{this.isPlugPanelShow=!1}))}updateContent(){this.$panel.innerHTML=this.kit.useEditor().getContentMarked()}}const Ye=[class extends Jt{constructor(t){super(t);const e=()=>{this.save()};this.kit.useMounted((()=>{const t=window.localStorage.getItem(Ne)||"";""!==t.trim()&&(this.kit.useEditor().showNotify(Mt("restoredMsg"),"i"),this.kit.useEditor().setContent(t)),this.kit.useEvents().on("content-updated",e)})),this.kit.useUnmounted((()=>{this.kit.useEvents().off("content-updated",e)}))}save(){window.localStorage.setItem(Ne,this.kit.useEditor().getContentRaw().trim())}},class extends Jt{get $inputs(){return this.kit.useEditor().getHeaderInputEls()}constructor(t){super(t);const e={},s={},n=(t,e,s)=>()=>{this.kit.useEvents().trigger(t,{field:s,$input:e})};this.kit.useMounted((()=>{Object.entries(this.$inputs).forEach((([t,i])=>{i.addEventListener("input",e[t]=n("header-input",i,t)),i.addEventListener("change",s[t]=n("header-change",i,t))}))})),this.kit.useUnmounted((()=>{Object.entries(this.$inputs).forEach((([t,n])=>{n.removeEventListener("input",e[t]),n.removeEventListener("change",s[t])}))}))}},class extends Jt{constructor(t){super(t),h(this,"query",{timer:null,abortFn:null});const e=({$input:t,field:e})=>{"edit"!==this.kit.useEditor().getState()&&(this.kit.useUser().update({[e]:t.value.trim()}),"name"!==e&&"email"!==e||this.fetchUserInfo())},s={name:Mt("nick"),email:Mt("email"),link:Mt("link")};this.kit.useMounted((()=>{Object.entries(this.kit.useEditor().getHeaderInputEls()).forEach((([t,e])=>{e.placeholder=s[t],e.value=this.kit.useUser().getData()[t]||""})),this.kit.useEvents().on("header-input",e)})),this.kit.useUnmounted((()=>{this.kit.useEvents().off("header-input",e)}))}fetchUserInfo(){this.kit.useUser().logout(),this.query.timer&&window.clearTimeout(this.query.timer),this.query.abortFn&&this.query.abortFn(),this.query.timer=window.setTimeout((()=>{this.query.timer=null;const t=this.kit.useApi(),e="getUserCancelToken";this.query.abortFn=()=>t.abortRequest(e),t.user.getUser(c({},t.getUserFields()),{cancelToken:e}).then((t=>this.onUserInfoFetched(t.data))).catch((t=>{})).finally((()=>{this.query.abortFn=null}))}),400)}onUserInfoFetched(t){var e;t.is_login||this.kit.useUser().logout(),this.kit.useGlobalCtx().getData().updateNotifies(t.notifies),this.kit.useUser().checkHasBasicUserInfo()&&!t.is_login&&(null==(e=t.user)?void 0:e.is_admin)&&this.kit.useGlobalCtx().checkAdmin({onSuccess:()=>{}}),t.user&&t.user.link&&(this.kit.useUI().$link.value=t.user.link,this.kit.useUser().update({link:t.user.link}))}},class extends Jt{constructor(t){super(t);const e=({field:t})=>{"link"===t&&this.onLinkInputChange()};this.kit.useMounted((()=>{this.kit.useEvents().on("header-change",e)})),this.kit.useUnmounted((()=>{this.kit.useEvents().off("header-change",e)}))}onLinkInputChange(){const t=this.kit.useUI().$link.value.trim();t&&!/^(http|https):\/\//.test(t)&&(this.kit.useUI().$link.value=`https://${t}`,this.kit.useUser().update({link:this.kit.useUI().$link.value}))}},class extends Jt{constructor(t){super(t);const e=t=>this.onKeydown(t),s=()=>this.onInput();this.kit.useMounted((()=>{this.kit.useUI().$textarea.placeholder=this.kit.useConf().placeholder||Mt("placeholder"),this.kit.useUI().$textarea.addEventListener("keydown",e),this.kit.useUI().$textarea.addEventListener("input",s)})),this.kit.useUnmounted((()=>{this.kit.useUI().$textarea.removeEventListener("keydown",e),this.kit.useUI().$textarea.removeEventListener("input",s)})),this.kit.useEvents().on("content-updated",(()=>{window.setTimeout((()=>{this.adaptiveHeightByContent()}),80)}))}onKeydown(t){9===(t.keyCode||t.which)&&(t.preventDefault(),this.kit.useEditor().insertContent("\t"))}onInput(){this.kit.useEvents().trigger("content-updated",this.kit.useEditor().getContentRaw())}adaptiveHeightByContent(){const t=this.kit.useUI().$textarea.offsetHeight-this.kit.useUI().$textarea.clientHeight;this.kit.useUI().$textarea.style.height="0px",this.kit.useUI().$textarea.style.height=`${this.kit.useUI().$textarea.scrollHeight+t}px`}},ze,class extends Jt{constructor(t){super(t);const e=()=>{this.kit.useEditor().submit()};this.kit.useMounted((()=>{this.kit.useUI().$submitBtn.innerText=this.kit.useConf().sendBtn||Mt("send"),this.kit.useUI().$submitBtn.addEventListener("click",e)})),this.kit.useUnmounted((()=>{this.kit.useUI().$submitBtn.removeEventListener("click",e)}))}},Xt,class extends Jt{constructor(t){super(t),h(this,"comment"),this.useEditorStateEffect("reply",(t=>(this.setReply(t),()=>{this.cancelReply()}))),this.kit.useEvents().on("mounted",(()=>{const t=this.kit.useDeps(ze);if(!t)throw Error("SubmitPlug not initialized");const e=new He(this.kit);t.registerCustom({activeCond:()=>!!this.comment,req:()=>u(this,null,(function*(){if(!this.comment)throw new Error("reply comment cannot be empty");return(yield this.kit.useApi().comments.createComment(d(c({},yield e.getSubmitAddParams()),{rid:this.comment.id,page_key:this.comment.page_key,page_title:void 0,site_name:this.comment.site_name}))).data})),post:t=>{const s=this.kit.useConf();t.page_key!==s.pageKey&&window.open(`${t.page_url}#atk-comment-${t.id}`),e.postSubmitAdd(t)}})}))}setReply(t){const e=this.kit.useUI();if(!e.$sendReplyBtn){const s=mt(`<span class="atk-state-btn"><span class="atk-text-wrap">${Mt("reply")} <span class="atk-text"></span></span><span class="atk-cancel atk-icon-close atk-icon"></span></span>`);s.querySelector(".atk-text").innerText=`@${t.nick}`,s.addEventListener("click",(()=>{this.kit.useEditor().resetState()})),e.$stateWrap.append(s),e.$sendReplyBtn=s}this.comment=t,e.$textarea.focus()}cancelReply(){if(!this.comment)return;const t=this.kit.useUI();t.$sendReplyBtn&&(t.$sendReplyBtn.remove(),t.$sendReplyBtn=void 0),this.comment=void 0}},class extends Jt{constructor(t){super(t),h(this,"comment"),h(this,"originalSubmitBtnText","Send"),this.useEditorStateEffect("edit",(t=>(this.edit(t),()=>{this.cancelEdit()}))),this.kit.useMounted((()=>{const t=this.kit.useDeps(ze);if(!t)throw Error("SubmitPlug not initialized");t.registerCustom({activeCond:()=>!!this.comment,req:()=>u(this,null,(function*(){const t={content:this.kit.useEditor().getContentFinal(),nick:this.kit.useUI().$name.value,email:this.kit.useUI().$email.value,link:this.kit.useUI().$link.value},e=this.comment;return(yield this.kit.useApi().comments.updateComment(e.id,c(c({},e),t))).data})),post:t=>{this.kit.useGlobalCtx().getData().updateComment(t)}})}))}edit(t){const e=this.kit.useUI();if(!e.$editCancelBtn){const t=mt(`<span class="atk-state-btn"><span class="atk-text-wrap">${Mt("editCancel")}</span><span class="atk-cancel atk-icon-close atk-icon"></span></span>`);t.onclick=()=>{this.kit.useEditor().resetState()},e.$stateWrap.append(t),e.$editCancelBtn=t}this.comment=t,e.$header.style.display="none",e.$name.value=t.nick||"",e.$email.value=t.email||"",e.$link.value=t.link||"",this.kit.useEditor().setContent(t.content),e.$textarea.focus(),this.updateSubmitBtnText(Mt("save"))}cancelEdit(){if(!this.comment)return;const t=this.kit.useUI();t.$editCancelBtn&&(t.$editCancelBtn.remove(),t.$editCancelBtn=void 0),this.comment=void 0;const{name:e,email:s,link:n}=this.kit.useUser().getData();t.$name.value=e,t.$email.value=s,t.$link.value=n,this.kit.useEditor().setContent(""),this.restoreSubmitBtnText(),t.$header.style.display=""}updateSubmitBtnText(t){this.originalSubmitBtnText=this.kit.useUI().$submitBtn.innerText,this.kit.useUI().$submitBtn.innerText=t}restoreSubmitBtnText(){this.kit.useUI().$submitBtn.innerText=this.originalSubmitBtnText}},class extends Jt{constructor(t){super(t);const e=()=>this.open(),s=()=>this.close();this.kit.useMounted((()=>{this.kit.useEvents().on("editor-open",e),this.kit.useEvents().on("editor-close",s)})),this.kit.useUnmounted((()=>{this.kit.useEvents().off("editor-open",e),this.kit.useEvents().off("editor-close",s)}))}open(){var t;null==(t=this.kit.useUI().$textareaWrap.querySelector(".atk-comment-closed"))||t.remove(),this.kit.useUI().$textarea.style.display="",this.kit.useUI().$bottom.style.display=""}close(){this.kit.useUI().$textareaWrap.querySelector(".atk-comment-closed")||this.kit.useUI().$textareaWrap.prepend(mt(`<div class="atk-comment-closed">${Mt("onlyAdminCanReply")}</div>`)),this.kit.useUser().getData().is_admin?(this.kit.useUI().$textarea.style.display="",this.kit.useUI().$bottom.style.display=""):(this.kit.useUI().$textarea.style.display="none",this.kit.useEvents().trigger("panel-close"),this.kit.useUI().$bottom.style.display="none")}},Ve,Ke,Qe];class Je{constructor(t){this.plugs=t}useEditor(){return this.plugs.editor}useGlobalCtx(){return this.plugs.editor.ctx}useConf(){return this.plugs.editor.ctx.conf}useApi(){return this.plugs.editor.ctx.getApi()}useUser(){return this.plugs.editor.ctx.get("user")}useUI(){return this.plugs.editor.getUI()}useEvents(){return this.plugs.getEvents()}useMounted(t){this.useEvents().on("mounted",t)}useUnmounted(t){this.useEvents().on("unmounted",t)}useDeps(t){return this.plugs.get(t)}}class Xe{constructor(t){h(this,"plugs",[]),h(this,"openedPlug",null),h(this,"events",new Pt),this.editor=t;let e=!1;this.editor.ctx.watchConf(["imgUpload","emoticons","preview","editorTravel","locale"],(t=>{e&&this.getEvents().trigger("unmounted"),this.clear(),function(t){const e=new Map;return e.set(Ke,t.imgUpload),e.set(Ve,t.emoticons),e.set(Qe,t.preview),e.set(Xt,t.editorTravel),Ye.filter((t=>!e.has(t)||!!e.get(t)))}(t).forEach((t=>{const e=new Je(this);this.plugs.push(new t(e))})),this.getEvents().trigger("mounted"),e=!0,this.loadPluginUI()})),this.events.on("panel-close",(()=>this.closePlugPanel()))}getPlugs(){return this.plugs}getEvents(){return this.events}clear(){this.plugs=[],this.events=new Pt,this.openedPlug&&this.closePlugPanel()}loadPluginUI(){this.editor.getUI().$plugPanelWrap.innerHTML="",this.editor.getUI().$plugPanelWrap.style.display="none",this.editor.getUI().$plugBtnWrap.innerHTML="",this.plugs.forEach((t=>this.loadPluginItem(t)))}loadPluginItem(t){const e=t.$btn;if(!e)return;this.editor.getUI().$plugBtnWrap.appendChild(e),!e.onclick&&(e.onclick=()=>{this.editor.getUI().$plugBtnWrap.querySelectorAll(".active").forEach((t=>t.classList.remove("active"))),t!==this.openedPlug?(this.openPlugPanel(t),e.classList.add("active")):this.closePlugPanel()});const s=t.$panel;s&&(s.style.display="none",this.editor.getUI().$plugPanelWrap.appendChild(s))}get(t){return this.plugs.find((e=>e instanceof t))}openPlugPanel(t){this.plugs.forEach((e=>{const s=e.$panel;s&&(e===t?(s.style.display="",this.events.trigger("panel-show",t)):(s.style.display="none",this.events.trigger("panel-hide",t)))})),this.editor.getUI().$plugPanelWrap.style.display="",this.openedPlug=t}closePlugPanel(){this.openedPlug&&(this.editor.getUI().$plugPanelWrap.style.display="none",this.events.trigger("panel-hide",this.openedPlug),this.openedPlug=null)}getTransformedContent(t){let e=t;return this.plugs.forEach((t=>{t.contentTransformer&&(e=t.contentTransformer(e))})),e}}const Ze="2.9.1";function ts(t){const e=mt('<span><span class="error-message"></span><br/><br/></span>');if(e.querySelector(".error-message").innerText=`${Mt("listLoadFailMsg")}\n${t.errMsg}`,t.retryFn){const s=mt(`<span style="cursor:pointer;">${Mt("listRetry")}</span>`);s.onclick=()=>t.retryFn&&t.retryFn(),e.appendChild(s)}if(t.onOpenSidebar){const s=mt(`<span atk-only-admin-show> | <span style="cursor:pointer;">${Mt("openName",{name:Mt("ctrlCenter")})}</span></span>`);e.appendChild(s),s.onclick=()=>t.onOpenSidebar&&t.onOpenSidebar()}Wt(t.$err,e)}let es=!1;let ss;function ns(t,e){const s="atk-dark-mode";t.forEach((t=>{e?t.classList.add(s):t.classList.remove(s)}))}const is=[t=>{t.watchConf(["imgLazyLoad","markedOptions"],(s=>{!function(t){try{if(!e.Marked.name)return}catch(n){return}const s=new e.Marked;s.setOptions(c(c({renderer:nt({imgLazyLoad:t.imgLazyLoad})},ct),t.markedOptions)),rt=s}({markedOptions:t.getConf().markedOptions,imgLazyLoad:t.getConf().imgLazyLoad})})),t.watchConf(["markedReplacers"],(t=>{var e;t.markedReplacers&&(e=t.markedReplacers,lt=e)}))},t=>{const e=t.get("editor"),s=new Xe(e);t.inject("editorPlugs",s)},t=>{const e=()=>{var e;e=t.get("user").getData().is_admin,function(t){const e=[];t.$root.querySelectorAll("[atk-only-admin-show]").forEach((t=>e.push(t)));const s=document.querySelector(".atk-sidebar");return s&&s.querySelectorAll("[atk-only-admin-show]").forEach((t=>e.push(t))),e}({$root:t.$root}).forEach((t=>{e?t.classList.remove("atk-hide"):t.classList.add("atk-hide")}))};t.on("list-loaded",(()=>{e()})),t.on("user-changed",(t=>{e()}))},...[t=>{t.on("list-fetch",(e=>{if(t.getData().getLoading())return;t.getData().setLoading(!0);const s=c({offset:0,limit:t.conf.pagination.pageSize,flatMode:t.conf.flatMode,paramsModifier:t.conf.listFetchParamsModifier},e);t.getData().setListLastFetch({params:s});const n={limit:s.limit,offset:s.offset,flat_mode:s.flatMode,page_key:t.getConf().pageKey,site_name:t.getConf().site};s.paramsModifier&&s.paramsModifier(n),t.getApi().comments.getComments(c(c({},n),t.getApi().getUserFields())).then((({data:e})=>{t.getData().setListLastFetch({params:s,data:e}),t.getData().loadComments(e.comments),t.getData().updatePage(e.page),s.onSuccess&&s.onSuccess(e),t.trigger("list-fetched",{params:s,data:e})})).catch((e=>{const n={msg:e.msg||String(e),data:e.data};throw s.onError&&s.onError(n),t.trigger("list-failed",n),t.trigger("list-fetched",{params:s,error:n}),e})).finally((()=>{t.getData().setLoading(!1)}))}))},t=>{t.on("list-fetch",(e=>{const s=t.get("list");0===e.offset&&jt(!0,s.$el)})),t.on("list-fetched",(()=>{jt(!1,t.get("list").$el)}))},t=>{t.on("comment-rendered",(e=>{if(!0===t.conf.listUnreadHighlight){const s=t.getData().getNotifies(),n=s.find((t=>t.comment_id===e.getID()));n?(e.getRender().setUnread(!0),e.getRender().setOpenAction((()=>{window.open(n.read_link),t.getData().updateNotifies(s.filter((t=>t.comment_id!==e.getID())))}))):e.getRender().setUnread(!1)}})),t.on("list-goto",(e=>{const s=ft("atk_notify_key");s&&t.getApi().notifies.markNotifyRead(e,s).then((()=>{t.getData().updateNotifies(t.getData().getNotifies().filter((t=>t.comment_id!==e)))}))}))},t=>{let e;t.on("mounted",(()=>{const s=t.get("list");e=s.$el.querySelector('[data-action="admin-close-comment"]'),e.addEventListener("click",(()=>{const e=t.getData().getPage();if(!e)throw new Error("Page data not found");e.admin_only=!e.admin_only,function(t,e){t.editorShowLoading(),t.getApi().pages.updatePage(e.id,e).then((({data:e})=>{t.getData().updatePage(e)})).catch((e=>{t.editorShowNotify(`${Mt("editFail")}: ${e.message||String(e)}`,"e")})).finally((()=>{t.editorHideLoading()}))}(t,e)}))})),t.on("page-loaded",(s=>{var n,i;const o=t.get("editor");!0===(null==s?void 0:s.admin_only)?(null==(n=o.getPlugs())||n.getEvents().trigger("editor-close"),e&&(e.innerText=Mt("openComment"))):(null==(i=o.getPlugs())||i.getEvents().trigger("editor-open"),e&&(e.innerText=Mt("closeComment")))})),t.on("list-loaded",(e=>{t.editorResetState()}))},t=>{t.on("list-loaded",(()=>{(()=>{var e,s;const n=t.get("list").$el.querySelector(".atk-comment-count .atk-text");if(!n)return;const i=gt(Mt("counter",{count:`${Number(null==(s=null==(e=t.getData().getListLastFetch())?void 0:e.data)?void 0:s.count)||0}`}));n.innerHTML=i.replace(/(\d+)/,'<span class="atk-comment-count-num">$1</span>')})()})),t.on("comment-inserted",(()=>{const e=t.getData().getListLastFetch();(null==e?void 0:e.data)&&(e.data.count+=1)})),t.on("comment-deleted",(()=>{const e=t.getData().getListLastFetch();(null==e?void 0:e.data)&&(e.data.count-=1)}))},t=>{let e=null;const s=()=>{if(!e)return;const s=t.get("user").getData();if(s.name&&s.email){e.classList.remove("atk-hide");const t=e.querySelector(".atk-text");t&&(t.innerText=s.is_admin?Mt("ctrlCenter"):Mt("msgCenter"))}else e.classList.add("atk-hide")};t.watchConf(["locale"],(n=>{const i=t.get("list");e=i.$el.querySelector('[data-action="open-sidebar"]'),e&&(e.onclick=()=>{t.showSidebar()},s())})),t.on("user-changed",(t=>{s()}))},t=>{let e=null;t.on("mounted",(()=>{const s=t.get("list");e=s.$el.querySelector(".atk-unread-badge")})),t.on("notifies-updated",(t=>{var s;s=t.length||0,e&&(s>0?(e.innerText=`${Number(s||0)}`,e.style.display="block"):e.style.display="none")}))},t=>{const e=e=>{t.conf.listFetchParamsModifier=e,t.reload()},s=t=>{!function(t){const{$dropdownWrap:e,dropdownList:s}=t;if(e.querySelector(".atk-dropdown"))return;e.classList.add("atk-dropdown-wrap"),e.append(mt('<span class="atk-arrow-down-icon"></span>'));let n=0;const i=(t,e,s,i)=>{i(),n=t,o.querySelectorAll(".active").forEach((t=>{t.classList.remove("active")})),e.classList.add("active"),o.style.display="none",setTimeout((()=>{o.style.display=""}),80)},o=mt('<ul class="atk-dropdown atk-fade-in"></ul>');s.forEach(((t,e)=>{const[s,a]=t,r=mt('<li class="atk-dropdown-item"><span></span></li>'),l=r.querySelector("span");l.innerText=s,l.onclick=()=>{i(e,r,s,a)},o.append(r),e===n&&r.classList.add("active")})),e.append(o)}({$dropdownWrap:t,dropdownList:[[Mt("sortLatest"),()=>{e((t=>{t.sort_by="date_desc"}))}],[Mt("sortBest"),()=>{e((t=>{t.sort_by="vote"}))}],[Mt("sortOldest"),()=>{e((t=>{t.sort_by="date_asc"}))}],[Mt("sortAuthor"),()=>{e((t=>{t.view_only_admin=!0}))}]]})};t.watchConf(["listSort","locale"],(e=>{const n=t.get("list").$el.querySelector(".atk-comment-count");n&&(e.listSort?s(n):function(t){var e,s;const{$dropdownWrap:n}=t;n.classList.remove("atk-dropdown-wrap"),null==(e=n.querySelector(".atk-arrow-down-icon"))||e.remove(),null==(s=n.querySelector(".atk-dropdown"))||s.remove()}({$dropdownWrap:n}))}))},t=>{let e=0;const s=({locker:s})=>{const n=function(){const t=window.location.hash.match(/#atk-comment-([0-9]+)/);let e=t&&t[1]&&!Number.isNaN(parseFloat(t[1]))?parseFloat(t[1]):null;e||(e=Number(ft("atk_comment")));return e||null}();n&&(s&&e===n||(e=n,t.trigger("list-goto",n)))},n=()=>s({locker:!1}),i=()=>s({locker:!0});t.on("mounted",(()=>{window.addEventListener("hashchange",n),t.on("list-loaded",i)})),t.on("unmounted",(()=>{window.removeEventListener("hashchange",n),t.off("list-loaded",i)}))},t=>{t.on("list-goto",(e=>u(this,null,(function*(){let s=t.getCommentNodes().find((t=>t.getID()===e));if(!s){const n=(yield t.getApi().comments.getComment(e)).data;t.get("list").getListLayout({forceFlatMode:!0}).insert(n.comment,n.reply_comment),s=t.getCommentNodes().find((t=>t.getID()===e))}s&&s.focus()}))))},t=>{t.on("list-loaded",(e=>{const s=t.get("list"),n=e.length<=0;let i=s.getCommentsWrapEl().querySelector(".atk-list-no-comment");n?i||(i=mt('<div class="atk-list-no-comment"></div>'),i.innerHTML=Z(s.ctx.conf.noComment||s.ctx.$t("noComment")),s.getCommentsWrapEl().appendChild(i)):null==i||i.remove()}))},t=>{t.on("mounted",(()=>{const e=t.get("list").$el.querySelector(".atk-copyright");e&&(e.innerHTML=`Powered By <a href="https://artalk.js.org" target="_blank" title="Artalk v${Ze}">Artalk</a>`)}))},t=>{let e=null;t.on("mounted",(()=>{e=window.setInterval((()=>{t.get("list").$el.querySelectorAll("[data-atk-comment-date]").forEach((e=>{var s,n;const i=new Date(Number(e.getAttribute("data-atk-comment-date")));e.innerText=(null==(n=(s=t.getConf()).dateFormatter)?void 0:n.call(s,i))||vt(i,t.$t)}))}),3e4)})),t.on("unmounted",(()=>{e&&window.clearInterval(e)}))},t=>{t.on("list-fetch",(()=>{Wt(t.get("list").$el,null)})),t.on("list-failed",(e=>{ts({$err:t.get("list").$el,errMsg:e.msg,errData:e.data,retryFn:()=>t.fetch({offset:0})})}))},t=>{let e=null;const s=()=>{null==e||e.disconnect(),e=null};t.on("list-loaded",(()=>{s();const n=t.get("list").getCommentsWrapEl().childNodes,i=n.length>2?n[n.length-2]:null;i&&("IntersectionObserver"in window?(n=>{const i=t.conf.scrollRelativeTo&&t.conf.scrollRelativeTo()||null;e=new IntersectionObserver((([e])=>{e.isIntersecting&&(s(),t.trigger("list-reach-bottom"))}),{threshold:.9,root:i}),e.observe(n)})(i):console.warn("IntersectionObserver api not supported"))})),t.on("unmounted",(()=>{s()}))},t=>{const e=()=>{const e=t.get("list"),s=t.conf.scrollRelativeTo&&t.conf.scrollRelativeTo();(s||window).scroll({top:yt(e.$el,s).top,left:0})};t.on("mounted",(()=>{t.on("list-goto-first",e)})),t.on("unmounted",(()=>{t.off("list-goto-first",e)}))}],t=>{t.on("list-fetch",(e=>{if(0!==e.offset)return;const s=t.getApi().getUserFields();s&&t.getApi().notifies.getNotifies(s).then((e=>{t.getData().updateNotifies(e.data.notifies)}))}))},t=>{t.watchConf(["site","pageKey","pageTitle","countEl","pvEl","statPageKeyAttr"],(e=>{_e({getApi:()=>t.getApi(),siteName:e.site,pageKey:e.pageKey,pageTitle:e.pageTitle,countEl:e.countEl,pvEl:e.pvEl,pageKeyAttr:e.statPageKeyAttr,pvAdd:"boolean"!=typeof t.conf.pvAdd||t.conf.pvAdd})}))},t=>{t.watchConf(["apiVersion","versionCheck"],(e=>{const s=t.get("list");e.apiVersion&&e.versionCheck&&!es&&function(t,e,s){const n=function(t,e){const s=t.split("."),n=e.split(".");for(let i=0;i<3;i++){const t=Number(s[i]),e=Number(n[i]);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,s);if(0===n)return;const i=mt(`<div class="atk-version-check-notice">${Mt("updateMsg",{name:Mt(n<0?"frontend":"backend")})} <span class="atk-info">${Mt("currentVersion")}: ${Mt("frontend")} ${e} / ${Mt("backend")} ${s}</span></div>`),o=mt(`<span class="atk-ignore-btn">${Mt("ignore")}</span>`);o.onclick=()=>{i.remove(),es=!0},i.append(o),t.$el.parentElement.prepend(i)}(s,Ze,e.apiVersion)}))},t=>{let e;const s=s=>{const n=[t.$root,t.get("layerManager").getEl()];ss||(ss=window.matchMedia("(prefers-color-scheme: dark)")),"auto"===s?(e||(e=t=>ns(n,t.matches),ss.addEventListener("change",e)),ns(n,ss.matches)):(e&&(ss.removeEventListener("change",e),e=void 0),ns(n,s))};t.watchConf(["darkMode"],(t=>s(t.darkMode))),t.on("created",(()=>s(t.conf.darkMode))),t.on("unmounted",(()=>{e&&(null==ss||ss.removeEventListener("change",e)),e=void 0}))}],os=new Set([...is]),as=new WeakMap;function rs(t){return u(this,null,(function*(){var e;const s=new Set,n=e=>{e.forEach((e=>{"function"!=typeof e||s.has(e)||(e(t,as.get(e)),s.add(e))}))};n(os);const{data:i}=yield t.getApi().conf.conf().catch((e=>{throw function(t,e){var s;let n="";if(null==(s=e.data)?void 0:s.err_no_site){const e={create_name:t.conf.site,create_urls:`${window.location.protocol}//${window.location.host}`};n=`sites|${JSON.stringify(e)}`}ts({$err:t.get("list").$el,errMsg:e.msg||String(e),errData:e.data,retryFn:()=>rs(t),onOpenSidebar:t.get("user").getData().is_admin?()=>t.showSidebar({view:n}):void 0})}(t,e),e}));let o={apiVersion:null==(e=i.version)?void 0:e.version};if(t.conf.useBackendConf){if(!i.frontend_conf)throw new Error("The remote backend does not respond to the frontend conf, but `useBackendConf` conf is enabled");o=c(c({},o),function(t){const e=["el","pageKey","pageTitle","server","site","pvEl","countEl","statPageKeyAttr"];return Object.keys(t).forEach((s=>{e.includes(s)&&delete t[s],"darkMode"===s&&"auto"!==t[s]&&delete t[s]})),t.emoticons&&"string"==typeof t.emoticons&&(t.emoticons=t.emoticons.trim(),t.emoticons.startsWith("[")||t.emoticons.startsWith("{")?t.emoticons=JSON.parse(t.emoticons):"false"===t.emoticons&&(t.emoticons=!1)),t}(i.frontend_conf))}t.conf.remoteConfModifier&&t.conf.remoteConfModifier(o),o.pluginURLs&&(yield function(t,e){return u(this,null,(function*(){const s=new Set;if(!t||!Array.isArray(t))return s;const n=[];return t.forEach((t=>{/^(http|https):\/\//.test(t)||(t=`${e.replace(/\/$/,"")}/${t.replace(/^\//,"")}`),n.push(new Promise((e=>{if(document.querySelector(`script[src="${t}"]`))return void e();const s=document.createElement("script");s.src=t,document.head.appendChild(s),s.onload=()=>e(),s.onerror=t=>{console.error("[artalk] Failed to load plugin",t),e()}})))})),yield Promise.all(n),Object.values(window.ArtalkPlugins||{}).forEach((t=>{"function"==typeof t&&s.add(t)})),s}))}(o.pluginURLs,t.conf.server).then((t=>{n(t)})).catch((t=>{console.error("Failed to load plugin",t)}))),t.trigger("created"),t.updateConf(o),t.trigger("mounted"),t.conf.remoteConfModifier||t.fetch({offset:0})}))}class ls{constructor(t){h(this,"ctx");const e=It(t,!0);this.ctx=new Dt(e),Object.entries(Fe).forEach((([t,e])=>{const s=e(this.ctx);s&&this.ctx.inject(t,s)})),rs(this.ctx)}getConf(){return this.ctx.getConf()}getEl(){return this.ctx.$root}update(t){return this.ctx.updateConf(t),this}reload(){this.ctx.reload()}destroy(){for(this.ctx.trigger("unmounted");this.ctx.$root.firstChild;)this.ctx.$root.removeChild(this.ctx.$root.firstChild)}on(t,e){this.ctx.on(t,e)}off(t,e){this.ctx.off(t,e)}trigger(t,e){this.ctx.trigger(t,e)}setDarkMode(t){this.ctx.setDarkMode(t)}static init(t){return new ls(t)}static use(t,e){os.add(t),as.set(t,e)}static loadCountWidget(t){const e=It(t,!0);_e({getApi:()=>new y(Ot(e)),siteName:e.site,countEl:e.countEl,pvEl:e.pvEl,pageKeyAttr:e.statPageKeyAttr,pvAdd:!1})}get $root(){return this.ctx.$root}get conf(){return this.ctx.getConf()}}const cs=ls.init,ds=ls.use,hs=ls.loadCountWidget;t.default=ls,t.init=cs,t.loadCountWidget=hs,t.use=ds,Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
|
|
11
|
-
//# sourceMappingURL=ArtalkLite.js.map
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("marked")):"function"==typeof define&&define.amd?define(["exports","marked"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Artalk={},e.marked)}(this,function(e,t){Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var n=Object.create,i=Object.defineProperty,o=Object.getOwnPropertyDescriptor,s=Object.getOwnPropertyNames,r=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,l=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),c=(e,t,l)=>(l=null!=e?n(r(e)):{},((e,t,n,r)=>{if(t&&"object"==typeof t||"function"==typeof t)for(var l,c=s(t),d=0,u=c.length;d<u;d++)l=c[d],a.call(e,l)||l===n||i(e,l,{get:(e=>t[e]).bind(null,l),enumerable:!(r=o(t,l))||r.enumerable});return e})(!t&&e&&e.__esModule?l:i(l,"default",{value:e,enumerable:!0}),e));function d(e,t,n,i,o,s,r){try{var a=e[s](r),l=a.value}catch(e){return void n(e)}a.done?t(l):Promise.resolve(l).then(i,o)}function u(e){return function(){var t=this,n=arguments;return new Promise(function(i,o){var s=e.apply(t,n);function r(e){d(s,i,o,r,a,"next",e)}function a(e){d(s,i,o,r,a,"throw",e)}r(void 0)})}}function p(e=""){const t=document.createElement("div");return t.innerHTML=e.trim(),t.firstElementChild||t}function h(e){const t=document.createElement("div");return t.innerText=e,t.innerHTML}function m(e){const t=RegExp(`[?&]${e}=([^&]*)`).exec(window.location.search);return t&&decodeURIComponent(t[1].replace(/\+/g," "))}function g(e,t){const n=e=>{const t=e.getBoundingClientRect(),n=window.pageXOffset||document.documentElement.scrollLeft,i=window.pageYOffset||document.documentElement.scrollTop;return{top:t.top+i,left:t.left+n}},i=n(e);if(!t)return i;const o=n(t);return{top:i.top-o.top,left:i.left-o.left}}function f(e,t){let n=e.toString();for(;n.length<t;)n=`0${n}`;return n}function v(e,t=e=>e){try{const n=e.getTime(),i=(new Date).getTime()-n,o=Math.floor(i/864e5);if(0===o){const e=i%864e5,n=Math.floor(e/36e5);if(0===n){const n=e%36e5,i=Math.floor(n/6e4);if(0===i){const e=n%6e4,i=Math.round(e/1e3);return i<10?t("now"):`${i} ${t("seconds")}`}return`${i} ${t("minutes")}`}return`${n} ${t("hours")}`}return o<0?t("now"):o<8?`${o} ${t("days")}`:function(e){const t=f(e.getDate(),2),n=f(e.getMonth()+1,2);return`${f(e.getFullYear(),2)}-${n}-${t}`}(e)}catch(n){return console.error(n)," - "}}function y(){return k.apply(this,arguments)}function k(){return(k=u(function*(){const e=navigator.userAgent,t=navigator.userAgentData;if("function"!=typeof(null==t?void 0:t.getHighEntropyValues))return e;let n;try{n=yield t.getHighEntropyValues(["platformVersion"])}catch(s){return console.error(s),e}const i=null==n?void 0:n.platformVersion;if("string"!=typeof i||!/^\d+(\.\d+)*$/.test(i))return e;const o=Number(i.split(".")[0]);return"Windows"===t.platform&&o>=13?e.replace(/Windows NT 10.0/,"Windows NT 11.0"):"macOS"===t.platform&&o>=11?e.replace(/(Mac OS X \d+_\d+_\d+|Mac OS X)/,`Mac OS X ${i.replace(/\./g,"_")}`):e})).apply(this,arguments)}function w(e){let t;try{t=new URL(e)}catch(n){return!1}return"http:"===t.protocol||"https:"===t.protocol}function $(e){return t=e.base,n=e.path,`${t.replace(/\/$/,"")}/${n.replace(/^\//,"")}`;var t,n}var b={placeholder:"Leave a comment",noComment:"No Comment",send:"Send",signIn:"Sign in",signUp:"Sign up",save:"Save",nick:"Nickname",email:"Email",link:"Website",emoticon:"Emoji",preview:"Preview",uploadImage:"Upload Image",uploadFail:"Upload Failed",commentFail:"Failed to comment",restoredMsg:"Content has been restored",onlyAdminCanReply:"Only admin can reply",uploadLoginMsg:"Please fill in your name and email to upload",counter:"{count} Comments",sortLatest:"Latest",sortOldest:"Oldest",sortBest:"Best",sortAuthor:"Author",openComment:"Open Comment",closeComment:"Close Comment",listLoadFailMsg:"Failed to load comments",listRetry:"Retry",loadMore:"Load More",admin:"Admin",reply:"Reply",voteUp:"Up",voteDown:"Down",voteFail:"Vote Failed",readMore:"Read More",actionConfirm:"Confirm",collapse:"Collapse",collapsed:"Collapsed",collapsedMsg:"This comment has been collapsed",expand:"Expand",approved:"Approved",pending:"Pending",pendingMsg:"Pending, visible only to commenter.",edit:"Edit",editCancel:"Cancel Edit",delete:"Delete",deleteConfirm:"Confirm",pin:"Pin",unpin:"Unpin",seconds:"seconds ago",minutes:"minutes ago",hours:"hours ago",days:"days ago",now:"just now",adminCheck:"Enter admin password:",captchaCheck:"Enter the CAPTCHA to continue:",confirm:"Confirm",cancel:"Cancel",msgCenter:"Messages",ctrlCenter:"Dashboard",userProfile:"Profile",noAccountPrompt:"Don't have an account?",haveAccountPrompt:"Already have an account?",forgetPassword:"Forget Password",resetPassword:"Reset Password",changePassword:"Change Password",confirmPassword:"Confirm Password",passwordMismatch:"Passwords do not match",verificationCode:"Verification Code",verifySend:"Send Code",verifyResend:"Resend",waitSeconds:"Wait {seconds}s",emailVerified:"Email has been verified",password:"Password",username:"Username",nextStep:"Next Step",skipVerify:"Skip verification",logoutConfirm:"Are you sure to logout?",accountMergeNotice:"Your email has multiple accounts with different id.",accountMergeSelectOne:"Please select one you want to merge all the data into it.",accountMergeConfirm:"All data will be merged into one account, the id is {id}.",dismiss:"Dismiss",merge:"Merge",client:"Client",server:"Server",loading:"Loading",loadFail:"Load Failed",editing:"Editing",editFail:"Edit Failed",deleting:"Deleting",deleteFail:"Delete Failed",reqGot:"Request got",reqAborted:"Request timed out or terminated unexpectedly",updateMsg:"Please update Artalk {name} to get the best experience!",currentVersion:"Current Version",ignore:"Ignore",open:"Open",openName:"Open {name}"},E={en:b,"en-US":b,"zh-CN":{placeholder:"键入内容...",noComment:"「此时无声胜有声」",send:"发送",signIn:"登录",signUp:"注册",save:"保存",nick:"昵称",email:"邮箱",link:"网址",emoticon:"表情",preview:"预览",uploadImage:"上传图片",uploadFail:"上传失败",commentFail:"评论失败",restoredMsg:"内容已自动恢复",onlyAdminCanReply:"仅管理员可评论",uploadLoginMsg:"填入你的名字邮箱才能上传哦",counter:"{count} 条评论",sortLatest:"最新",sortOldest:"最早",sortBest:"最热",sortAuthor:"作者",openComment:"打开评论",closeComment:"关闭评论",listLoadFailMsg:"无法获取评论列表数据",listRetry:"点击重新获取",loadMore:"加载更多",admin:"管理员",reply:"回复",voteUp:"赞同",voteDown:"反对",voteFail:"投票失败",readMore:"阅读更多",actionConfirm:"确认操作",collapse:"折叠",collapsed:"已折叠",collapsedMsg:"该评论已被系统或管理员折叠",expand:"展开",approved:"已审",pending:"待审",pendingMsg:"审核中,仅本人可见。",edit:"编辑",editCancel:"取消编辑",delete:"删除",deleteConfirm:"确认删除",pin:"置顶",unpin:"取消置顶",seconds:"秒前",minutes:"分钟前",hours:"小时前",days:"天前",now:"刚刚",adminCheck:"键入密码来验证管理员身份:",captchaCheck:"键入验证码继续:",confirm:"确认",cancel:"取消",msgCenter:"通知中心",ctrlCenter:"控制中心",userProfile:"个人资料",noAccountPrompt:"没有账号?",haveAccountPrompt:"已有账号?",forgetPassword:"忘记密码",resetPassword:"重置密码",changePassword:"修改密码",confirmPassword:"确认密码",passwordMismatch:"两次输入的密码不一致",verificationCode:"验证码",verifySend:"发送验证码",verifyResend:"重新发送",waitSeconds:"等待 {seconds}秒",emailVerified:"邮箱已验证",password:"密码",username:"用户名",nextStep:"下一步",skipVerify:"跳过验证",logoutConfirm:"确定要退出登录吗?",accountMergeNotice:"您的电子邮件下有多个不同 ID 的账户。",accountMergeSelectOne:"请选择将所有数据合并到其中的一个。",accountMergeConfirm:"所有数据将合并到 ID 为 {id} 的账户中。",dismiss:"忽略",merge:"合并",client:"客户端",server:"服务器",loading:"加载中",loadFail:"加载失败",editing:"修改中",editFail:"修改失败",deleting:"删除中",deleteFail:"删除失败",reqGot:"请求响应",reqAborted:"请求超时或意外终止",updateMsg:"请更新 Artalk {name} 以获得更好的体验!",currentVersion:"当前版本",ignore:"忽略",open:"打开",openName:"打开{name}"}};function C(e){return e=e.replace(/^([a-zA-Z]+)(-[a-zA-Z]+)?$/,(e,t,n)=>t.toLowerCase()+(n||"").toUpperCase()),E[e]?E[e]:window.ArtalkI18n&&window.ArtalkI18n[e]?window.ArtalkI18n[e]:E.en}var S="en",T=C(S);function A(e,t={}){let n=(null==T?void 0:T[e])||e;return n=n.replace(/\{\s*(\w+?)\s*\}/g,(e,n)=>t[n]||""),h(n)}function x(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}function L(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var i,o,s,r,a=[],l=!0,c=!1;try{if(s=(n=n.call(e)).next,0===t);else for(;!(l=(i=s.call(n)).done)&&(a.push(i.value),a.length!==t);l=!0);}catch(e){c=!0,o=e}finally{try{if(!l&&null!=n.return&&(r=n.return(),Object(r)!==r))return}finally{if(c)throw o}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return x(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?x(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var O=Object.entries,M=Object.setPrototypeOf,P=Object.isFrozen,D=Object.getPrototypeOf,_=Object.getOwnPropertyDescriptor,I=Object.freeze,R=Object.seal,U=Object.create,N="undefined"!=typeof Reflect&&Reflect,j=N.apply,B=N.construct;I||(I=function(e){return e}),R||(R=function(e){return e}),j||(j=function(e,t){for(var n=arguments.length,i=new Array(n>2?n-2:0),o=2;o<n;o++)i[o-2]=arguments[o];return e.apply(t,i)}),B||(B=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];return new e(...n)});var F,q=le(Array.prototype.forEach),W=le(Array.prototype.lastIndexOf),H=le(Array.prototype.pop),z=le(Array.prototype.push),G=le(Array.prototype.splice),V=Array.isArray,K=le(String.prototype.toLowerCase),Y=le(String.prototype.toString),Q=le(String.prototype.match),X=le(String.prototype.replace),J=le(String.prototype.indexOf),Z=le(String.prototype.trim),ee=le(Number.prototype.toString),te=le(Boolean.prototype.toString),ne="undefined"==typeof BigInt?null:le(BigInt.prototype.toString),ie="undefined"==typeof Symbol?null:le(Symbol.prototype.toString),oe=le(Object.prototype.hasOwnProperty),se=le(Object.prototype.toString),re=le(RegExp.prototype.test),ae=(F=TypeError,function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return B(F,t)});function le(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,i=new Array(n>1?n-1:0),o=1;o<n;o++)i[o-1]=arguments[o];return j(e,t,i)}}function ce(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:K;if(M&&M(e,null),!V(t))return e;let i=t.length;for(;i--;){let o=t[i];if("string"==typeof o){const e=n(o);e!==o&&(P(t)||(t[i]=e),o=e)}e[o]=!0}return e}function de(e){for(let t=0;t<e.length;t++)oe(e,t)||(e[t]=null);return e}function ue(e){const t=U(null);for(const i of O(e)){var n=L(i,2);const o=n[0],s=n[1];oe(e,o)&&(V(s)?t[o]=de(s):s&&"object"==typeof s&&s.constructor===Object?t[o]=ue(s):t[o]=s)}return t}function pe(e,t){for(;null!==e;){const n=_(e,t);if(n){if(n.get)return le(n.get);if("function"==typeof n.value)return le(n.value)}e=D(e)}return function(){return null}}var he=I(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),me=I(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),ge=I(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),fe=I(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),ve=I(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),ye=I(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),ke=I(["#text"]),we=I(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),$e=I(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dominant-baseline","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-orientation","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),be=I(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Ee=I(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Ce=R(/{{[\w\W]*|^[\w\W]*}}/g),Se=R(/<%[\w\W]*|^[\w\W]*%>/g),Te=R(/\${[\w\W]*/g),Ae=R(/^data-[\-\w.\u00B7-\uFFFF]+$/),xe=R(/^aria-[\-\w]+$/),Le=R(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Oe=R(/^(?:\w+script|data):/i),Me=R(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Pe=R(/^html$/i),De=R(/^[a-z][.\w]*(-[.\w]+)+$/i),_e=R(/<[/\w!]/g),Ie=R(/<[/\w]/g),Re=R(/<\/no(script|embed|frames)/i),Ue=R(/\/>/i),Ne=1,je=3,Be=7,Fe=8,qe=9,We=11,He=function(){return"undefined"==typeof window?null:window},ze=function(e,t,n,i){return oe(e,t)&&V(e[t])?ce(i.base?ue(i.base):{},e[t],i.transform):n};var Ge=function e(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:He();const n=t=>e(t);if(n.version="3.4.12",n.removed=[],!t||!t.document||t.document.nodeType!==qe||!t.Element)return n.isSupported=!1,n;let i=t.document;const o=i,s=o.currentScript;t.DocumentFragment;const r=t.HTMLTemplateElement,a=t.Node,l=t.Element,c=t.NodeFilter;void 0===t.NamedNodeMap&&(t.NamedNodeMap||t.MozNamedAttrMap),t.HTMLFormElement;const d=t.DOMParser,u=t.trustedTypes,p=l.prototype,h=pe(p,"cloneNode"),m=pe(p,"remove"),g=pe(p,"nextSibling"),f=pe(p,"childNodes"),v=pe(p,"parentNode"),y=pe(p,"shadowRoot"),k=pe(p,"attributes"),w=a&&a.prototype?pe(a.prototype,"nodeType"):null,$=a&&a.prototype?pe(a.prototype,"nodeName"):null;if("function"==typeof r){const e=i.createElement("template");e.content&&e.content.ownerDocument&&(i=e.content.ownerDocument)}let b,E,C="",S=!1,T=0;const A=function(){if(T>0)throw ae('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},x=function(e){A(),T++;try{return b.createHTML(e)}finally{T--}},L=function(){return S||(E=function(e,t){if("object"!=typeof e||"function"!=typeof e.createPolicy)return null;let n=null;const i="data-tt-policy-suffix";t&&t.hasAttribute(i)&&(n=t.getAttribute(i));const o="dompurify"+(n?"#"+n:"");try{return e.createPolicy(o,{createHTML:e=>e,createScriptURL:e=>e})}catch(s){return console.warn("TrustedTypes policy "+o+" could not be created."),null}}(u,s),S=!0),E},M=i,P=M.implementation,D=M.createNodeIterator,_=M.createDocumentFragment,N=M.getElementsByTagName,j=o.importNode;let B={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]};n.isSupported="function"==typeof O&&"function"==typeof v&&P&&void 0!==P.createHTMLDocument;const F=Ce,le=Se,de=Te,Ge=Ae,Ve=xe,Ke=Oe,Ye=Me,Qe=De;let Xe=Le,Je=null;const Ze=ce({},[...he,...me,...ge,...ve,...ke]);let et=null;const tt=ce({},[...we,...$e,...be,...Ee]);let nt=Object.seal(U(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),it=null,ot=null;const st=Object.seal(U(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let rt=!0,at=!0,lt=!1,ct=!0,dt=!1,ut=!0,pt=!1,ht=!1,mt=null,gt=null,ft=!1,vt=!1,yt=!1,kt=!1,wt=!0,$t=!1;const bt="user-content-";let Et=!0,Ct=!1,St={},Tt=null;const At=ce({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]);let xt=null;const Lt=ce({},["audio","video","img","source","image","track"]);let Ot=null;const Mt=ce({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Pt="http://www.w3.org/1998/Math/MathML",Dt="http://www.w3.org/2000/svg",_t="http://www.w3.org/1999/xhtml";let It=_t,Rt=!1,Ut=null;const Nt=ce({},[Pt,Dt,_t],Y),jt=I(["mi","mo","mn","ms","mtext"]);let Bt=ce({},jt);const Ft=I(["annotation-xml"]);let qt=ce({},Ft);const Wt=ce({},["title","style","font","a","script"]);let Ht=null;const zt=["application/xhtml+xml","text/html"];let Gt=null,Vt=null;const Kt=i.createElement("form"),Yt=function(e){return e instanceof RegExp||e instanceof Function},Qt=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(Vt&&Vt===e)return;e&&"object"==typeof e||(e={}),e=ue(e),Ht=-1===zt.indexOf(e.PARSER_MEDIA_TYPE)?"text/html":e.PARSER_MEDIA_TYPE,Gt="application/xhtml+xml"===Ht?Y:K,Je=ze(e,"ALLOWED_TAGS",Ze,{transform:Gt}),et=ze(e,"ALLOWED_ATTR",tt,{transform:Gt}),Ut=ze(e,"ALLOWED_NAMESPACES",Nt,{transform:Y}),Ot=ze(e,"ADD_URI_SAFE_ATTR",Mt,{transform:Gt,base:Mt}),xt=ze(e,"ADD_DATA_URI_TAGS",Lt,{transform:Gt,base:Lt}),Tt=ze(e,"FORBID_CONTENTS",At,{transform:Gt}),it=ze(e,"FORBID_TAGS",ue({}),{transform:Gt}),ot=ze(e,"FORBID_ATTR",ue({}),{transform:Gt}),St=!!oe(e,"USE_PROFILES")&&(e.USE_PROFILES&&"object"==typeof e.USE_PROFILES?ue(e.USE_PROFILES):e.USE_PROFILES),rt=!1!==e.ALLOW_ARIA_ATTR,at=!1!==e.ALLOW_DATA_ATTR,lt=e.ALLOW_UNKNOWN_PROTOCOLS||!1,ct=!1!==e.ALLOW_SELF_CLOSE_IN_ATTR,dt=e.SAFE_FOR_TEMPLATES||!1,ut=!1!==e.SAFE_FOR_XML,pt=e.WHOLE_DOCUMENT||!1,vt=e.RETURN_DOM||!1,yt=e.RETURN_DOM_FRAGMENT||!1,kt=e.RETURN_TRUSTED_TYPE||!1,ft=e.FORCE_BODY||!1,wt=!1!==e.SANITIZE_DOM,$t=e.SANITIZE_NAMED_PROPS||!1,Et=!1!==e.KEEP_CONTENT,Ct=e.IN_PLACE||!1,Xe=function(e){try{return re(e,""),!0}catch(t){return!1}}(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:Le,It="string"==typeof e.NAMESPACE?e.NAMESPACE:_t,Bt=oe(e,"MATHML_TEXT_INTEGRATION_POINTS")&&e.MATHML_TEXT_INTEGRATION_POINTS&&"object"==typeof e.MATHML_TEXT_INTEGRATION_POINTS?ue(e.MATHML_TEXT_INTEGRATION_POINTS):ce({},jt),qt=oe(e,"HTML_INTEGRATION_POINTS")&&e.HTML_INTEGRATION_POINTS&&"object"==typeof e.HTML_INTEGRATION_POINTS?ue(e.HTML_INTEGRATION_POINTS):ce({},Ft);const t=oe(e,"CUSTOM_ELEMENT_HANDLING")&&e.CUSTOM_ELEMENT_HANDLING&&"object"==typeof e.CUSTOM_ELEMENT_HANDLING?ue(e.CUSTOM_ELEMENT_HANDLING):U(null);if(nt=U(null),oe(t,"tagNameCheck")&&Yt(t.tagNameCheck)&&(nt.tagNameCheck=t.tagNameCheck),oe(t,"attributeNameCheck")&&Yt(t.attributeNameCheck)&&(nt.attributeNameCheck=t.attributeNameCheck),oe(t,"allowCustomizedBuiltInElements")&&"boolean"==typeof t.allowCustomizedBuiltInElements&&(nt.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),R(nt),dt&&(at=!1),yt&&(vt=!0),St&&(Je=ce({},ke),et=U(null),!0===St.html&&(ce(Je,he),ce(et,we)),!0===St.svg&&(ce(Je,me),ce(et,$e),ce(et,Ee)),!0===St.svgFilters&&(ce(Je,ge),ce(et,$e),ce(et,Ee)),!0===St.mathMl&&(ce(Je,ve),ce(et,be),ce(et,Ee))),st.tagCheck=null,st.attributeCheck=null,oe(e,"ADD_TAGS")&&("function"==typeof e.ADD_TAGS?st.tagCheck=e.ADD_TAGS:V(e.ADD_TAGS)&&(Je===Ze&&(Je=ue(Je)),ce(Je,e.ADD_TAGS,Gt))),oe(e,"ADD_ATTR")&&("function"==typeof e.ADD_ATTR?st.attributeCheck=e.ADD_ATTR:V(e.ADD_ATTR)&&(et===tt&&(et=ue(et)),ce(et,e.ADD_ATTR,Gt))),oe(e,"ADD_URI_SAFE_ATTR")&&V(e.ADD_URI_SAFE_ATTR)&&ce(Ot,e.ADD_URI_SAFE_ATTR,Gt),oe(e,"FORBID_CONTENTS")&&V(e.FORBID_CONTENTS)&&(Tt===At&&(Tt=ue(Tt)),ce(Tt,e.FORBID_CONTENTS,Gt)),oe(e,"ADD_FORBID_CONTENTS")&&V(e.ADD_FORBID_CONTENTS)&&(Tt===At&&(Tt=ue(Tt)),ce(Tt,e.ADD_FORBID_CONTENTS,Gt)),Et&&(Je["#text"]=!0),pt&&ce(Je,["html","head","body"]),Je.table&&(ce(Je,["tbody"]),delete it.tbody),e.TRUSTED_TYPES_POLICY){if("function"!=typeof e.TRUSTED_TYPES_POLICY.createHTML)throw ae('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof e.TRUSTED_TYPES_POLICY.createScriptURL)throw ae('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const t=b;b=e.TRUSTED_TYPES_POLICY;try{C=x("")}catch(n){throw b=t,n}}else null===e.TRUSTED_TYPES_POLICY?(b=void 0,C=""):(void 0===b&&(b=L()),b&&"string"==typeof C&&(C=x("")));I&&I(e),Vt=e},Xt=ce({},[...me,...ge,...fe]),Jt=ce({},[...ve,...ye]),Zt=function(e){let t=v(e);t&&t.tagName||(t={namespaceURI:It,tagName:"template"});const n=K(e.tagName),i=K(t.tagName);return!!Ut[e.namespaceURI]&&(e.namespaceURI===Dt?function(e,t,n){return t.namespaceURI===_t?"svg"===e:t.namespaceURI===Pt?"svg"===e&&("annotation-xml"===n||Bt[n]):Boolean(Xt[e])}(n,t,i):e.namespaceURI===Pt?function(e,t,n){return t.namespaceURI===_t?"math"===e:t.namespaceURI===Dt?"math"===e&&qt[n]:Boolean(Jt[e])}(n,t,i):e.namespaceURI===_t?function(e,t,n){return!(t.namespaceURI===Dt&&!qt[n])&&!(t.namespaceURI===Pt&&!Bt[n])&&!Jt[e]&&(Wt[e]||!Xt[e])}(n,t,i):!("application/xhtml+xml"!==Ht||!Ut[e.namespaceURI]))},en=function(e){z(n.removed,{element:e});try{v(e).removeChild(e)}catch(t){if(m(e),!v(e))throw ae("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},tn=function(e){sn(e);const t=f(e);if(t){const e=[];q(t,t=>{z(e,t)}),q(e,e=>{try{m(e)}catch(t){}})}const n=k(e);if(n)for(let o=n.length-1;o>=0;--o){const t=n[o],s=t&&t.name;if("string"==typeof s)try{e.removeAttribute(s)}catch(i){}}},nn=function(e,t){try{z(n.removed,{attribute:t.getAttributeNode(e),from:t})}catch(i){z(n.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e)if(vt||yt)try{en(t)}catch(i){}else try{t.setAttribute(e,"")}catch(i){}},on=function(e){const t=k(e);if(t)for(let i=t.length-1;i>=0;--i){const o=t[i],s=o&&o.name;if("string"==typeof s&&!et[Gt(s)])try{e.removeAttribute(s)}catch(n){}}},sn=function(e){const t=[e];for(;t.length>0;){const e=t.pop();(w?w(e):e.nodeType)===Ne&&on(e);const n=f(e);if(n)for(let i=n.length-1;i>=0;--i)t.push(n[i])}},rn=function(e){let t=null,n=null;if(ft)e="<remove></remove>"+e;else{const t=Q(e,/^[\r\n\t ]+/);n=t&&t[0]}"application/xhtml+xml"===Ht&&It===_t&&(e='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+e+"</body></html>");const o=b?x(e):e;if(It===_t)try{t=(new d).parseFromString(o,Ht)}catch(r){}if(!t||!t.documentElement){t=P.createDocument(It,"template",null);try{t.documentElement.innerHTML=Rt?C:o}catch(r){}}const s=t.body||t.documentElement;return e&&n&&s.insertBefore(i.createTextNode(n),s.childNodes[0]||null),It===_t?N.call(t,pt?"html":"body")[0]:pt?t.documentElement:s},an=function(e){return D.call(e.ownerDocument||e,e,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},ln=function(e){return e=X(e,F," "),e=X(e,le," "),e=X(e,de," ")},cn=function(e){var t;e.normalize();const n=D.call(e.ownerDocument||e,e,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null);let i=n.nextNode();for(;i;)i.data=ln(i.data),i=n.nextNode();const o=null===(t=e.querySelectorAll)||void 0===t?void 0:t.call(e,"template");o&&q(o,e=>{un(e.content)&&cn(e.content)})},dn=function(e){const t=$?$(e):null;return"string"==typeof t&&("form"===Gt(t)&&("string"!=typeof e.nodeName||"string"!=typeof e.textContent||"function"!=typeof e.removeChild||e.attributes!==k(e)||"function"!=typeof e.removeAttribute||"function"!=typeof e.setAttribute||"string"!=typeof e.namespaceURI||"function"!=typeof e.insertBefore||"function"!=typeof e.hasChildNodes||e.nodeType!==w(e)||e.childNodes!==f(e)))},un=function(e){if(!w||"object"!=typeof e||null===e)return!1;try{return w(e)===We}catch(t){return!1}},pn=function(e){if(!w||"object"!=typeof e||null===e)return!1;try{return"number"==typeof w(e)}catch(t){return!1}};function hn(e,t,i){0!==e.length&&q(e,e=>{e.call(n,t,i,Vt)})}const mn=function(e,t){if(hn(B.beforeSanitizeElements,e,null),e!==t&&null===v(e))return!0;if(dn(e))return en(e),!0;const i=Gt($?$(e):e.nodeName);if(hn(B.uponSanitizeElement,e,{tagName:i,allowedTags:Je}),e!==t&&null===v(e))return!0;if(function(e,t){return!!(ut&&e.hasChildNodes()&&!pn(e.firstElementChild)&&re(_e,e.textContent)&&re(_e,e.innerHTML))||!(!ut||e.namespaceURI!==_t||"style"!==t||!pn(e.firstElementChild))||e.nodeType===Be||!(!ut||e.nodeType!==Fe||!re(Ie,e.data))}(e,i))return en(e),!0;if(it[i]||!(st.tagCheck instanceof Function&&st.tagCheck(i))&&!Je[i]){const t=function(e,t){if(!it[t]&&vn(t)){if(nt.tagNameCheck instanceof RegExp&&re(nt.tagNameCheck,t))return!1;if(nt.tagNameCheck instanceof Function&&nt.tagNameCheck(t))return!1}if(Et&&!Tt[t]){const t=v(e),n=f(e);if(n&&t)for(let i=n.length-1;i>=0;--i){const o=Ct?n[i]:h(n[i],!0);t.insertBefore(o,g(e))}}return en(e),!0}(e,i);return!1===t&&hn(B.afterSanitizeElements,e,null),t}if((w?w(e):e.nodeType)===Ne&&!Zt(e))return en(e),!0;if(("noscript"===i||"noembed"===i||"noframes"===i)&&re(Re,e.innerHTML))return en(e),!0;if(dt&&e.nodeType===je){const t=ln(e.textContent);e.textContent!==t&&(z(n.removed,{element:e.cloneNode()}),e.textContent=t)}return hn(B.afterSanitizeElements,e,null),!1},gn=function(e,t,n){if(ot[t])return!1;if(ut&&"patchsrc"===t)return!1;if(ut&&"for"===t&&"label"!==e&&"output"!==e)return!1;if(wt&&("id"===t||"name"===t)&&(n in i||n in Kt))return!1;const o=et[t]||st.attributeCheck instanceof Function&&st.attributeCheck(t,e);if(at&&re(Ge,t));else if(rt&&re(Ve,t));else if(o)if(Ot[t]);else if(re(Xe,X(n,Ye,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==J(n,"data:")||!xt[e]){if(lt&&!re(Ke,X(n,Ye,"")));else if(n)return!1}else;else if(!(vn(e)&&(nt.tagNameCheck instanceof RegExp&&re(nt.tagNameCheck,e)||nt.tagNameCheck instanceof Function&&nt.tagNameCheck(e))&&(nt.attributeNameCheck instanceof RegExp&&re(nt.attributeNameCheck,t)||nt.attributeNameCheck instanceof Function&&nt.attributeNameCheck(t,e))||"is"===t&&nt.allowCustomizedBuiltInElements&&(nt.tagNameCheck instanceof RegExp&&re(nt.tagNameCheck,n)||nt.tagNameCheck instanceof Function&&nt.tagNameCheck(n))))return!1;return!0},fn=ce({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),vn=function(e){return!fn[K(e)]&&re(Qe,e)},yn=function(e,t,n,i){if(b&&"object"==typeof u&&"function"==typeof u.getAttributeType&&!n)switch(u.getAttributeType(e,t)){case"TrustedHTML":return x(i);case"TrustedScriptURL":return function(e){A(),T++;try{return b.createScriptURL(e)}finally{T--}}(i)}return i},kn=function(e,t,i,o){try{i?e.setAttributeNS(i,t,o):e.setAttribute(t,o),dn(e)?en(e):H(n.removed)}catch(s){nn(t,e)}},wn=function(e){hn(B.beforeSanitizeAttributes,e,null);const t=e.attributes;if(!t||dn(e))return;const n={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:et,forceKeepAttr:void 0};let i=t.length;const o=Gt(e.nodeName);for(;i--;){const s=t[i],r=s.name,a=s.namespaceURI,l=s.value,c=Gt(r),d=l;let u="value"===r?d:Z(d);n.attrName=c,n.attrValue=u,n.keepAttr=!0,n.forceKeepAttr=void 0,hn(B.uponSanitizeAttribute,e,n),u=n.attrValue,!$t||"id"!==c&&"name"!==c||0===J(u,bt)||(nn(r,e),u=bt+u),ut&&re(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,u)?nn(r,e):"attributename"===c&&Q(u,"href")?nn(r,e):n.forceKeepAttr||(n.keepAttr&&(ct||!re(Ue,u))?(dt&&(u=ln(u)),gn(o,c,u)?(u=yn(o,c,a,u),u!==d&&kn(e,r,a,u)):nn(r,e)):nn(r,e))}hn(B.afterSanitizeAttributes,e,null)},$n=function(e){let t=null;const n=an(e);for(hn(B.beforeSanitizeShadowDOM,e,null);t=n.nextNode();)if(hn(B.uponSanitizeShadowNode,t,null),mn(t,e),wn(t),un(t.content)&&$n(t.content),(w?w(t):t.nodeType)===Ne){const e=y(t);un(e)&&(bn(e),$n(e))}hn(B.afterSanitizeShadowDOM,e,null)},bn=function(e){const t=[{node:e,shadow:null}];for(;t.length>0;){const e=t.pop();if(e.shadow){$n(e.shadow);continue}const n=e.node,i=(w?w(n):n.nodeType)===Ne,o=f(n);if(o)for(let s=o.length-1;s>=0;--s)t.push({node:o[s],shadow:null});if(i){const e=$?$(n):null;if("string"==typeof e&&"template"===Gt(e)){const e=n.content;un(e)&&t.push({node:e,shadow:null})}}if(i){const e=y(n);un(e)&&t.push({node:null,shadow:e},{node:e,shadow:null})}}};return n.sanitize=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=null,s=null,r=null,a=null;if(Rt=!e,Rt&&(e="\x3c!--\x3e"),"string"!=typeof e&&!pn(e)&&"string"!=typeof(e=function(e){switch(typeof e){case"string":return e;case"number":return ee(e);case"boolean":return te(e);case"bigint":return ne?ne(e):"0";case"symbol":return ie?ie(e):"Symbol()";case"undefined":default:return se(e);case"function":case"object":{if(null===e)return se(e);const t=e,n=pe(t,"toString");if("function"==typeof n){const e=n(t);return"string"==typeof e?e:se(e)}return se(e)}}}(e)))throw ae("dirty is not a string, aborting");if(!n.isSupported)return e;ht?(Je=mt,et=gt):Qt(t),(B.uponSanitizeElement.length>0||B.uponSanitizeAttribute.length>0)&&(Je=ue(Je)),B.uponSanitizeAttribute.length>0&&(et=ue(et)),n.removed=[];const l=Ct&&"string"!=typeof e&&pn(e);if(l){!function(e){if(!ut)return;const t=[e];for(;t.length>0;){const e=t.pop(),i=w?w(e):e.nodeType;if(i===Be||i===Fe&&re(Ie,e.data)){try{m(e)}catch(n){}continue}if(i===Ne){const t=e,i=Gt($?$(e):e.nodeName);try{t.hasAttribute&&t.hasAttribute("patchsrc")&&t.removeAttribute("patchsrc"),t.hasAttribute&&t.hasAttribute("for")&&"label"!==i&&"output"!==i&&t.removeAttribute("for")}catch(n){}}const o=f(e);if(o)for(let n=o.length-1;n>=0;--n)t.push(o[n])}}(e);const t=$?$(e):e.nodeName;if("string"==typeof t){const n=Gt(t);if(!Je[n]||it[n])throw tn(e),ae("root node is forbidden and cannot be sanitized in-place")}if(dn(e))throw tn(e),ae("root node is clobbered and cannot be sanitized in-place");try{bn(e)}catch(p){throw tn(e),p}}else if(pn(e))i=rn("\x3c!----\x3e"),s=i.ownerDocument.importNode(e,!0),s.nodeType===Ne&&"BODY"===s.nodeName||"HTML"===s.nodeName?i=s:i.appendChild(s),bn(s);else{if(!vt&&!dt&&!pt&&-1===e.indexOf("<"))return b&&kt?x(e):e;if(i=rn(e),!i)return vt?null:kt?C:""}i&&ft&&en(i.firstChild);const c=l?e:i,d=an(c);try{for(;r=d.nextNode();)mn(r,c),wn(r),un(r.content)&&$n(r.content)}catch(p){throw l&&(tn(e),q(n.removed,e=>{e.element&&sn(e.element)})),p}if(l)return q(n.removed,e=>{e.element&&sn(e.element)}),dt&&cn(e),e;if(vt){if(dt&&cn(i),yt)for(a=_.call(i.ownerDocument);i.firstChild;)a.appendChild(i.firstChild);else a=i;return(et.shadowroot||et.shadowrootmode)&&(a=j.call(o,a,!0)),a}let u=pt?i.outerHTML:i.innerHTML;return pt&&Je["!doctype"]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&re(Pe,i.ownerDocument.doctype.name)&&(u="<!DOCTYPE "+i.ownerDocument.doctype.name+">\n"+u),dt&&(u=ln(u)),b&&kt?x(u):u},n.setConfig=function(){Qt(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),ht=!0,mt=Je,gt=et},n.clearConfig=function(){Vt=null,ht=!1,mt=null,gt=null,b=E,C=""},n.isValidAttribute=function(e,t,n){Vt||Qt({});const i=Gt(e),o=Gt(t);return gn(i,o,n)},n.addHook=function(e,t){"function"==typeof t&&oe(B,e)&&z(B[e],t)},n.removeHook=function(e,t){if(oe(B,e)){if(void 0!==t){const n=W(B[e],t);return-1===n?void 0:G(B[e],n,1)[0]}return H(B[e])}},n.removeHooks=function(e){oe(B,e)&&(B[e]=[])},n.removeAllHooks=function(){B={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},n}(),Ve=["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"],Ke=new Set(["title","accesskey"]),Ye={a:new Set(["href","name","target","aria-label","rel"]),img:new Set(["src","alt","title","atk-emoticon","aria-label","data-src","class","loading"]),code:new Set(["class"]),span:new Set(["class","style"])},Qe=[...new Set([...Ke,...Object.values(Ye).flatMap(e=>[...e])])],Xe=new Set(["href","src","data-src"]),Je=new Set(["http","https","mailto"]);function Ze(e,t,n){var i;const o=[...e].filter(e=>{const t=e.codePointAt(0)||0;return t>32&&(t<127||t>159)}).join(""),s=null===(i=/^([a-z][a-z\d+.-]*):/i.exec(o))||void 0===i?void 0:i[1].toLowerCase();return"data"===s?"img"===t&&("src"===n||"data-src"===n)&&/^data:image\/(?:png|jpeg|gif|webp|avif|bmp)(?:;base64)?,/i.test(o):!s||Je.has(s)}function et(e){const t=Ge.sanitize(e,{ALLOWED_TAGS:Ve,ALLOWED_ATTR:Qe,ALLOW_ARIA_ATTR:!1,ALLOW_DATA_ATTR:!1,ALLOW_UNKNOWN_PROTOCOLS:!0,ADD_URI_SAFE_ATTR:["data-src"]}),n=document.createElement("template");return n.innerHTML=t,n.content.querySelectorAll("*").forEach(e=>{const t=e.tagName.toLowerCase(),n=Ye[t];for(const r of[...e.attributes])Ke.has(r.name)||(null==n?void 0:n.has(r.name))?Xe.has(r.name)&&!Ze(r.value,t,r.name)&&e.removeAttribute(r.name):e.removeAttribute(r.name);const i=e.getAttribute("class"),o="code"===t&&/^hljs\W+language-(.*)$/.test(i||"")||"span"===t&&/^(hljs-.*)$/.test(i||"")||"img"===t&&/^lazyload$/.test(i||"");i&&!o&&e.removeAttribute("class");const s=e.getAttribute("style");"span"===t&&s&&!/^color:(\W+)?#[0-9a-f]{3,6};?$/i.test(s)&&e.removeAttribute("style")}),n.innerHTML}var tt=l((e,t)=>{var n,i;n=e,i=function(){"use strict";var e,t,n,i=(t=e={exports:{}},(n=t.exports=function(){return new RegExp("(?:"+n.line().source+")|(?:"+n.block().source+")","gm")}).line=function(){return/(?:^|\s)\/\/(.+?)$/gm},n.block=function(){return/\/\*([\S\s]*?)\*\//gm},e.exports),o=["23AC69","91C132","F19726","E8552D","1AAB8E","E1147F","2980C1","1BA1E6","9FA0A0","F19726","E30B20","E30B20","A3338B"];return function(e,t){void 0===t&&(t={});var n=t.colors;void 0===n&&(n=o);var s=0,r={},a=new RegExp("("+/[\u4E00-\u9FFF\u3400-\u4dbf\uf900-\ufaff\u3040-\u309f\uac00-\ud7af\u0400-\u04FF]+|\w+/.source+"|"+/</.source+")|("+i().source+")","gmi");return e.replace(a,function(e,t,i){if(i)return function(e){return'<span style="color: slategray">'+e+"</span>"}(i);if("<"===t)return"<";var o;r[t]?o=r[t]:(o=n[s],r[t]=o);var a='<span style="color: #'+o+'">'+t+"</span>";return s=++s%n.length,a})}},"object"==typeof e&&void 0!==t?t.exports=i():"function"==typeof define&&define.amd?define(i):n.hanabi=i()}),nt=c(tt(),1);function it(e){return(0,nt.default)(e)}function ot(e){const n=new t.marked.Renderer;return n.link=rt(n,n.link),n.code=at(),n.image=lt(n,n.image,e),n}var st,rt=(e,t)=>n=>{const i=(e=>{try{return new URL(e).origin}catch(t){return""}})(n.href)===window.location.origin;return t.call(e,n).replace(/^<a /,`<a target="_blank" ${i?"":'rel="noreferrer noopener nofollow ugc"'} `)},at=()=>({lang:e,text:t})=>{const n=e||"plaintext";let i=t;return window.hljs?n&&window.hljs.getLanguage(n)&&(i=window.hljs.highlight(n,t).value):i=it(t),`<pre rel="${n}">\n<code class="hljs language-${n}">${i.replace(/&/g,"&")}</code>\n</pre>`},lt=(e,t,{imgLazyLoad:n})=>i=>{const o=t.call(e,i);return n?"native"===n||!0===n?o.replace(/^<img /,'<img class="lazyload" loading="lazy" '):"data-src"===n?o.replace(/^<img /,'<img class="lazyload" ').replace("src=","data-src="):o:o};function ct(e){return ct="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},ct(e)}function dt(e){var t=function(e,t){if("object"!=ct(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t||"default");if("object"!=ct(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==ct(t)?t:t+""}function ut(e,t,n){return(t=dt(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function pt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,i)}return n}function ht(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?pt(Object(n),!0).forEach(function(t){ut(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):pt(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var mt=[],gt={gfm:!0,breaks:!0,async:!1};function ft(){return st}function vt(e){var t;let n=null===(t=ft())||void 0===t?void 0:t.parse(e);n||(n=function(e){return e.replace(/```\s*([^]+?.*?[^]+?[^]+?)```/g,(e,t)=>`<pre><code>${it(t)}</code></pre>`).replace(/!\[(.*?)\]\((.*?)\)/g,(e,t,n)=>`<img src="${n}" alt="${t}" />`).replace(/\[(.*?)\]\((.*?)\)/g,(e,t,n)=>`<a href="${n}" target="_blank">${t}</a>`).replace(/\n/g,"<br>")}(e));let i=et(n);return mt.forEach(e=>{"function"==typeof e&&(i=e(i))}),i}var yt=class{constructor(e){ut(this,"_$root",void 0),ut(this,"_deps",function(){const e=new Map,t=new Map,n=i=>{const o=e.get(i);if(!o)throw new Error(`No provide for ${String(i)}`);if("singleton"===o.lifecycle&&t.has(i))return t.get(i);const{impl:s,deps:r}=o,a=s(...r.map(e=>n(e)));return t.set(i,a),a};return{provide:(t,n,i,o={})=>{e.set(t,{impl:n,deps:i||[],lifecycle:o.lifecycle||"singleton"})},inject:n}}()),ut(this,"_destroyed",!1),ut(this,"provide",(e,t,n,i)=>{this._deps.provide(e,t,n,i)}),ut(this,"inject",e=>this._deps.inject(e)),ut(this,"get",this.inject),ut(this,"on",(e,t)=>{this.inject("events").on(e,t)}),ut(this,"off",(e,t)=>{this.inject("events").off(e,t)}),ut(this,"trigger",(e,t)=>{this.inject("events").trigger(e,t)}),ut(this,"getCommentList",this.getCommentNodes),ut(this,"getCommentDataList",this.getComments),this._$root=e}getEl(){return this._$root}destroy(){if(!this._destroyed)for(this._destroyed=!0,this.trigger("unmounted");this._$root.firstChild;)this._$root.removeChild(this._$root.firstChild)}isDestroyed(){return this._destroyed}get data(){return this.inject("data")}get user(){return this.inject("user")}get editor(){return this.inject("editor")}get list(){return this.inject("list")}get layerManager(){return this.inject("layers")}get checkerLauncher(){return this.inject("checkers")}get sidebarLayer(){return this.inject("sidebar")}get editorPlugs(){return this.inject("editorPlugs")}getConf(){return this.inject("config").get()}updateConf(e){this.inject("config").update(e)}watchConf(e,t){this.inject("config").watchConf(e,t)}getMarked(){return ft()}setDarkMode(e){this.updateConf({darkMode:e})}get conf(){return this.getConf()}set conf(e){throw new Error("Cannot replace ctx.conf directly; call ctx.updateConf() instead")}get $root(){return this.getEl()}set $root(e){throw new Error("Cannot replace ctx.$root; create a new Artalk instance instead")}$t(e,t={}){return A(e,t)}getApi(){return this.inject("api")}getApiHandlers(){return this.inject("apiHandlers")}getUser(){return this.inject("user")}getData(){return this.inject("data")}fetch(e){this.getData().fetchComments(e)}reload(){this.getData().fetchComments({offset:0})}listGotoFirst(){this.trigger("list-goto-first")}getCommentNodes(){return this.inject("list").getCommentNodes()}getComments(){return this.getData().getComments()}replyComment(e,t){this.inject("editor").setReplyComment(e,t)}editComment(e,t){this.inject("editor").setEditComment(e,t)}editorShowLoading(){this.inject("editor").showLoading()}editorHideLoading(){this.inject("editor").hideLoading()}editorShowNotify(e,t){this.inject("editor").showNotify(e,t)}editorResetState(){this.inject("editor").resetState()}showSidebar(e){this.inject("sidebar").show(e)}hideSidebar(){this.inject("sidebar").hide()}checkAdmin(e){return this.inject("checkers").checkAdmin(e)}checkCaptcha(e){return this.inject("checkers").checkCaptcha(e)}};function kt(...e){const t=e=>e&&"object"==typeof e&&e.constructor===Object;return e.reduce((e,n)=>(Object.keys(null!=n?n:{}).forEach(i=>{if("__proto__"===i||"constructor"===i||"prototype"===i)return;const o=e[i],s=n[i];Array.isArray(o)&&Array.isArray(s)?e[i]=o.concat(...s):t(o)&&t(s)?e[i]=kt(o,s):e[i]=s}),e),{})}var wt={el:"",pageKey:"",pageTitle:"",server:"",site:"",placeholder:"",noComment:"",sendBtn:"",darkMode:!1,editorTravel:!0,flatMode:"auto",nestMax:2,nestSort:"DATE_ASC",emoticons:"https://cdn.jsdelivr.net/gh/ArtalkJS/Emoticons/grps/default.json",pageVote:!0,vote:!0,voteDown:!1,uaBadge:!0,listSort:!0,preview:!0,countEl:".artalk-comment-count",pvEl:".artalk-pv-count",statPageKeyAttr:"data-page-key",gravatar:{mirror:"https://www.gravatar.com/avatar/",params:"sha256=1&d=mp&s=240"},pagination:{pageSize:20,readMore:!0,autoLoad:!0},heightLimit:{content:300,children:400,scrollable:!1},imgUpload:!0,imgLazyLoad:!1,reqTimeout:15e3,versionCheck:!0,useBackendConf:!0,preferRemoteConf:!1,listUnreadHighlight:!1,pvAdd:!0,fetchCommentsOnInit:!0,locale:"en",apiVersion:"",pluginURLs:[],markedReplacers:[],markedOptions:{}};function $t(e,t=!1){const n=t?kt(wt,e):e;return""===n.pageKey&&(n.pageKey=`${window.location.pathname}`),""===n.pageTitle&&(n.pageTitle=`${document.title}`),n.server&&(n.server=n.server.replace(/\/$/,"").replace(/\/api\/?$/,"")),"auto"===n.locale&&(n.locale=navigator.language),"auto"===n.flatMode&&(n.flatMode=window.matchMedia("(max-width: 768px)").matches),"number"==typeof n.nestMax&&Number(n.nestMax)<=1&&(n.flatMode=!0),n}function bt(e,t,n){return{baseURL:`${e.server}/api/v2`,siteName:e.site||"",pageKey:e.pageKey||"",pageTitle:e.pageTitle||"",timeout:e.reqTimeout,getApiToken:()=>null==t?void 0:t.getData().token,getGuestToken:(n=!1)=>{var i;return null==t||null===(i=t.getGuestToken)||void 0===i?void 0:i.call(t,e.server||"",n)},userInfo:(null==t?void 0:t.checkHasBasicUserInfo())?{name:null==t?void 0:t.getData().name,email:null==t?void 0:t.getData().email}:void 0,handlers:n}}function Et(e){return Ct.apply(this,arguments)}function Ct(){return Ct=u(function*(e){yield function(e){return Tt.apply(this,arguments)}(e),yield function(e,t){return At.apply(this,arguments)}(e,yield function(e){return St.apply(this,arguments)}(e))}),Ct.apply(this,arguments)}function St(){return(St=u(function*(e){if(!e.pvAdd||!e.pageKey)return;const t=(yield e.getApi().pages.logPv({page_key:e.pageKey,page_title:e.pageTitle,site_name:e.siteName})).data.pv;return{[e.pageKey]:t}})).apply(this,arguments)}function Tt(){return(Tt=u(function*(e){yield xt({opt:e,query:"page_comment",containers:[e.countEl,"#ArtalkCount"]})})).apply(this,arguments)}function At(){return(At=u(function*(e,t){yield xt({opt:e,query:"page_pv",containers:[e.pvEl,"#ArtalkPV"],cache:t})})).apply(this,arguments)}function xt(e){return Lt.apply(this,arguments)}function Lt(){return(Lt=u(function*(e){const{opt:t}=e;let n=e.cache||{};const i=function(e){const t=new Set;return new Set(e).forEach(e=>{document.querySelectorAll(e).forEach(e=>t.add(e))}),t}(e.containers),o=function(e,t,n,i){const o=Array.from(e).map(e=>e.getAttribute(t)||n).filter(e=>e&&"number"!=typeof i[e]);return[...new Set(o)]}(i,t.pageKeyAttr,t.pageKey,n);if(o.length>0){const i=(yield t.getApi().stats.getStats(e.query,{page_keys:o.join(","),site_name:t.siteName})).data.data;n=ht(ht({},n),i)}!function(e,t,n){e.forEach(e=>{const i=e.getAttribute("data-page-key"),o=i&&t[i]||n&&t[n]||0;e.innerText=`${Number(o)}`})}(i,n,t.pageKey)})).apply(this,arguments)}var Ot,Mt=["body","secure","path","type","query","format","baseUrl","cancelToken"],Pt=class{constructor(e={}){var t,n=this;ut(this,"baseUrl","/api/v2"),ut(this,"securityData",null),ut(this,"securityWorker",void 0),ut(this,"abortControllers",new Map),ut(this,"customFetch",(...e)=>fetch(...e)),ut(this,"baseApiParams",{credentials:"same-origin",headers:{},redirect:"follow",referrerPolicy:"no-referrer"}),ut(this,"setSecurityData",e=>{this.securityData=e}),ut(this,"contentFormatters",{"application/json":e=>null===e||"object"!=typeof e&&"string"!=typeof e?e:JSON.stringify(e),"application/vnd.api+json":e=>null===e||"object"!=typeof e&&"string"!=typeof e?e:JSON.stringify(e),"text/plain":e=>null!==e&&"string"!=typeof e?JSON.stringify(e):e,"multipart/form-data":e=>e instanceof FormData?e:Object.keys(e||{}).reduce((t,n)=>{const i=e[n];return t.append(n,i instanceof Blob?i:"object"==typeof i&&null!==i?JSON.stringify(i):`${i}`),t},new FormData),"application/x-www-form-urlencoded":e=>this.toQueryString(e)}),ut(this,"createAbortSignal",e=>{if(this.abortControllers.has(e)){const t=this.abortControllers.get(e);return t?t.signal:void 0}const t=new AbortController;return this.abortControllers.set(e,t),t.signal}),ut(this,"abortRequest",e=>{const t=this.abortControllers.get(e);t&&(t.abort(),this.abortControllers.delete(e))}),ut(this,"request",(t=u(function*(e){let{body:t,secure:i,path:o,type:s,query:r,format:a,baseUrl:l,cancelToken:c}=e,d=function(e,t){if(null==e)return{};var n,i,o=function(e,t){if(null==e)return{};var n={};for(var i in e)if({}.hasOwnProperty.call(e,i)){if(t.includes(i))continue;n[i]=e[i]}return n}(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(i=0;i<s.length;i++)n=s[i],t.includes(n)||{}.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,Mt);const p=("boolean"==typeof i?i:n.baseApiParams.secure)&&n.securityWorker&&(yield n.securityWorker(n.securityData))||{},h=n.mergeRequestParams(d,p),m=r&&n.toQueryString(r),g=n.contentFormatters[s||"application/json"],f=a||h.format;return n.customFetch(`${l||n.baseUrl||""}${o}${m?`?${m}`:""}`,ht(ht({},h),{},{headers:ht(ht({},h.headers||{}),s&&"multipart/form-data"!==s?{"Content-Type":s}:{}),signal:(c?n.createAbortSignal(c):h.signal)||null,body:null==t?null:g(t)})).then((v=u(function*(e){const t=e;t.data=null,t.error=null;const i=f?e.clone():e,o=f?yield i[f]().then(e=>(t.ok?t.data=e:t.error=e,t)).catch(e=>(t.error=e,t)):t;if(c&&n.abortControllers.delete(c),!e.ok)throw o;return o}),function(e){return v.apply(this,arguments)}));var v}),function(e){return t.apply(this,arguments)})),Object.assign(this,e)}encodeQueryParam(e,t){return`${encodeURIComponent(e)}=${encodeURIComponent("number"==typeof t?t:`${t}`)}`}addQueryParam(e,t){return this.encodeQueryParam(t,e[t])}addArrayQueryParam(e,t){return e[t].map(e=>this.encodeQueryParam(t,e)).join("&")}toQueryString(e){const t=e||{};return Object.keys(t).filter(e=>void 0!==t[e]).map(e=>Array.isArray(t[e])?this.addArrayQueryParam(t,e):this.addQueryParam(t,e)).join("&")}addQueryParams(e){const t=this.toQueryString(e);return t?`?${t}`:""}mergeRequestParams(e,t){return ht(ht(ht(ht({},this.baseApiParams),e),t||{}),{},{headers:ht(ht(ht({},this.baseApiParams.headers||{}),e.headers||{}),t&&t.headers||{})})}},Dt=class extends Pt{constructor(...e){super(...e),ut(this,"auth",{loginByEmail:(e,t={})=>this.request(ht({path:"/auth/email/login",method:"POST",body:e,type:"application/json",format:"json"},t)),registerByEmail:(e,t={})=>this.request(ht({path:"/auth/email/register",method:"POST",body:e,type:"application/json",format:"json"},t)),sendVerifyEmail:(e,t={})=>this.request(ht({path:"/auth/email/send",method:"POST",body:e,type:"application/json",format:"json"},t)),checkDataMerge:(e={})=>this.request(ht({path:"/auth/merge",method:"GET",secure:!0,format:"json"},e)),applyDataMerge:(e,t={})=>this.request(ht({path:"/auth/merge",method:"POST",body:e,secure:!0,type:"application/json",format:"json"},t))}),ut(this,"cache",{flushCache:(e={})=>this.request(ht({path:"/cache/flush",method:"POST",secure:!0,format:"json"},e)),warmUpCache:(e={})=>this.request(ht({path:"/cache/warm_up",method:"POST",secure:!0,format:"json"},e))}),ut(this,"captcha",{getCaptcha:(e={})=>this.request(ht({path:"/captcha",method:"GET",format:"json"},e)),getCaptchaStatus:(e={})=>this.request(ht({path:"/captcha/status",method:"GET",format:"json"},e)),verifyCaptcha:(e,t={})=>this.request(ht({path:"/captcha/verify",method:"POST",body:e,type:"application/json",format:"json"},t))}),ut(this,"comments",{getComments:(e,t={})=>this.request(ht({path:"/comments",method:"GET",query:e,secure:!0,type:"application/json",format:"json"},t)),createComment:(e,t={})=>this.request(ht({path:"/comments",method:"POST",body:e,secure:!0,type:"application/json",format:"json"},t)),getComment:(e,t={})=>this.request(ht({path:`/comments/${e}`,method:"GET",type:"application/json",format:"json"},t)),updateComment:(e,t,n={})=>this.request(ht({path:`/comments/${e}`,method:"PUT",body:t,secure:!0,type:"application/json",format:"json"},n)),deleteComment:(e,t={})=>this.request(ht({path:`/comments/${e}`,method:"DELETE",secure:!0,format:"json"},t))}),ut(this,"conf",{conf:(e={})=>this.request(ht({path:"/conf",method:"GET",format:"json"},e)),getSocialLoginProviders:(e={})=>this.request(ht({path:"/conf/auth/providers",method:"GET",format:"json"},e)),getDomain:(e,t={})=>this.request(ht({path:"/conf/domain",method:"GET",query:e,format:"json"},t))}),ut(this,"notifies",{getNotifies:(e,t={})=>this.request(ht({path:"/notifies",method:"GET",query:e,secure:!0,type:"application/json",format:"json"},t)),markAllNotifyRead:(e,t={})=>this.request(ht({path:"/notifies/read",method:"POST",body:e,secure:!0,type:"application/json",format:"json"},t)),markNotifyRead:(e,t,n={})=>this.request(ht({path:`/notifies/${e}/${t}`,method:"POST",format:"json"},n))}),ut(this,"pages",{getPages:(e,t={})=>this.request(ht({path:"/pages",method:"GET",query:e,secure:!0,type:"application/json",format:"json"},t)),fetchAllPages:(e,t={})=>this.request(ht({path:"/pages/fetch",method:"POST",body:e,secure:!0,type:"application/json",format:"json"},t)),getPageFetchStatus:(e={})=>this.request(ht({path:"/pages/fetch/status",method:"GET",secure:!0,format:"json"},e)),logPv:(e,t={})=>this.request(ht({path:"/pages/pv",method:"POST",body:e,type:"application/json",format:"json"},t)),updatePage:(e,t,n={})=>this.request(ht({path:`/pages/${e}`,method:"PUT",body:t,secure:!0,type:"application/json",format:"json"},n)),deletePage:(e,t={})=>this.request(ht({path:`/pages/${e}`,method:"DELETE",secure:!0,format:"json"},t)),fetchPage:(e,t={})=>this.request(ht({path:`/pages/${e}/fetch`,method:"POST",secure:!0,type:"application/json",format:"json"},t))}),ut(this,"sendEmail",{sendEmail:(e,t={})=>this.request(ht({path:"/send_email",method:"POST",body:e,secure:!0,type:"application/json",format:"json"},t))}),ut(this,"settings",{getSettings:(e={})=>this.request(ht({path:"/settings",method:"GET",secure:!0,format:"json"},e)),applySettings:(e,t={})=>this.request(ht({path:"/settings",method:"PUT",body:e,secure:!0,type:"application/json",format:"json"},t)),getSettingsTemplate:(e,t={})=>this.request(ht({path:`/settings/template/${e}`,method:"GET",secure:!0,format:"json"},t))}),ut(this,"sites",{getSites:(e={})=>this.request(ht({path:"/sites",method:"GET",secure:!0,format:"json"},e)),createSite:(e,t={})=>this.request(ht({path:"/sites",method:"POST",body:e,secure:!0,type:"application/json",format:"json"},t)),updateSite:(e,t,n={})=>this.request(ht({path:`/sites/${e}`,method:"PUT",body:t,secure:!0,type:"application/json",format:"json"},n)),deleteSite:(e,t={})=>this.request(ht({path:`/sites/${e}`,method:"DELETE",secure:!0,format:"json"},t))}),ut(this,"sso",{authSsoExchange:(e,t={})=>this.request(ht({path:"/sso/exchange",method:"POST",body:e,type:"application/json",format:"json"},t))}),ut(this,"stats",{getStats:(e,t,n={})=>this.request(ht({path:`/stats/${e}`,method:"GET",query:t,type:"application/json",format:"json"},n))}),ut(this,"transfer",{exportArtrans:(e={})=>this.request(ht({path:"/transfer/export",method:"GET",secure:!0,format:"json"},e)),importArtrans:(e,t={})=>this.request(ht({path:"/transfer/import",method:"POST",body:e,secure:!0,type:"application/json"},t)),uploadArtrans:(e,t={})=>this.request(ht({path:"/transfer/upload",method:"POST",body:e,secure:!0,type:"multipart/form-data",format:"json"},t))}),ut(this,"upload",{upload:(e,t={})=>this.request(ht({path:"/upload",method:"POST",body:e,secure:!0,type:"multipart/form-data",format:"json"},t))}),ut(this,"user",{getUser:(e,t={})=>this.request(ht({path:"/user",method:"GET",query:e,secure:!0,format:"json"},t)),updateProfile:(e,t={})=>this.request(ht({path:"/user",method:"POST",body:e,secure:!0,type:"application/json",format:"json"},t)),login:(e,t={})=>this.request(ht({path:"/user/access_token",method:"POST",body:e,type:"application/json",format:"json"},t)),getUserStatus:(e,t={})=>this.request(ht({path:"/user/status",method:"GET",query:e,secure:!0,format:"json"},t))}),ut(this,"users",{createUser:(e,t={})=>this.request(ht({path:"/users",method:"POST",body:e,secure:!0,type:"application/json",format:"json"},t)),updateUser:(e,t,n={})=>this.request(ht({path:`/users/${e}`,method:"PUT",body:t,secure:!0,type:"application/json",format:"json"},n)),deleteUser:(e,t={})=>this.request(ht({path:`/users/${e}`,method:"DELETE",secure:!0,format:"json"},t)),getUsers:(e,t,n={})=>this.request(ht({path:`/users/${e}`,method:"GET",query:t,secure:!0,type:"application/json",format:"json"},n))}),ut(this,"version",{getVersion:(e={})=>this.request(ht({path:"/version",method:"GET",format:"json"},e))}),ut(this,"votes",{syncVotes:(e={})=>this.request(ht({path:"/votes/sync",method:"POST",secure:!0,format:"json"},e)),getVote:(e,t,n={})=>this.request(ht({path:`/votes/${e}/${t}`,method:"GET",type:"application/json",format:"json"},n)),createVote:(e,t,n,i,o={})=>this.request(ht({path:`/votes/${e}/${t}/${n}`,method:"POST",body:i,type:"application/json",format:"json"},o))})}},_t=(Ot=u(function*(e,t,n){const i=e.getApiToken&&e.getApiToken(),o=new Headers(ht({Authorization:i?`Bearer ${i}`:""},null==n?void 0:n.headers));o.get("Authorization")||o.delete("Authorization");const s=new URL(t instanceof Request?t.url:String(t),window.location.href),r=new URL(e.baseURL,window.location.href),a=s.pathname.slice(r.pathname.replace(/\/$/,"").length);if(!o.has("Authorization")&&s.origin===r.origin&&s.pathname.startsWith(`${r.pathname.replace(/\/$/,"")}/`)&&/^(\/comments(?:\/\d+)?|\/notifies(?:\/read)?|\/user)$/.test(a)){var l,c;const t="/comments"===a&&"POST"===(null==n||null===(l=n.method)||void 0===l?void 0:l.toUpperCase()),i=null===(c=e.getGuestToken)||void 0===c?void 0:c.call(e,t);i&&o.set("X-Artalk-Guest",i)}const d=yield fetch(t,ht(ht({},n),{},{headers:o}));if(!d.ok){const i=(yield d.json().catch(()=>{}))||{};let o=!1;if(e.handlers&&(yield e.handlers.get().reduce(function(){var e=u(function*(e,t){yield e,!0===i[t.action]&&(yield t.handler(i),o=!0)});return function(t,n){return e.apply(this,arguments)}}(),Promise.resolve())),o)return _t(e,t,n);throw function(e,t){const n=new It;return n.message=t.msg||t.message||"fetch error",n.code=e,n.data=t,console.error(n),n}(d.status,i)}return d}),function(e,t,n){return Ot.apply(this,arguments)}),It=class extends Error{constructor(...e){super(...e),ut(this,"code",0),ut(this,"message","fetch error"),ut(this,"data",void 0)}};var Rt=class extends Dt{constructor(e){super({baseUrl:e.baseURL,customFetch:(t,n)=>_t(e,t,n)}),ut(this,"_opts",void 0),this._opts=e}getUserFields(){const e=this._opts.userInfo;if((null==e?void 0:e.name)&&(null==e?void 0:e.email))return{name:e.name,email:e.email}}},Ut=class{constructor(e){ut(this,"kit",void 0),ut(this,"$btn",void 0),ut(this,"$panel",void 0),ut(this,"editorStateEffectWhen",void 0),this.kit=e}useBtn(e="<div></div>"){return this.$btn=p(`<span class="atk-plug-btn">${e}</span>`),this.$btn}usePanel(e="<div></div>"){return this.$panel=p(e),this.$panel}useContentTransformer(e){this.contentTransformer=e}usePanelShow(e){this.kit.useEvents().on("panel-show",t=>{t===this&&e()})}usePanelHide(e){this.kit.useEvents().on("panel-hide",t=>{t===this&&e()})}useEditorStateEffect(e,t){this.editorStateEffectWhen=e,this.editorStateEffect=t}},Nt="ArtalkContent",jt=class{constructor(e){ut(this,"kit",void 0),this.kit=e}reqAdd(){var e=this;return u(function*(){return(yield e.kit.useApi().comments.createComment(ht({},yield e.getSubmitAddParams()))).data})()}getSubmitAddParams(){var e=this;return u(function*(){const{name:t,email:n,link:i}=e.kit.useUser().getData(),o=e.kit.useConf();return{content:e.kit.useEditor().getContentFinal(),name:t,email:n,link:i,rid:0,page_key:o.pageKey,page_title:o.pageTitle,site_name:o.site,ua:yield y()}})()}postSubmitAdd(e){this.kit.useData().insertComment(e)}},Bt=class extends Ut{constructor(e){super(e),ut(this,"customs",[]),ut(this,"defaultPreset",void 0),this.defaultPreset=new jt(this.kit);const t=()=>this.do();this.kit.useMounted(()=>{this.kit.useEvents().on("editor-submit",t)}),this.kit.useUnmounted(()=>{this.kit.useEvents().off("editor-submit",t)})}registerCustom(e){this.customs.push(e)}do(){var e=this;return u(function*(){if(""===e.kit.useEditor().getContentFinal().trim())return void e.kit.useEditor().focus();const t=e.customs.find(e=>e.activeCond());e.kit.useEditor().showLoading();try{let n;(null==t?void 0:t.pre)&&t.pre(),n=(null==t?void 0:t.req)?yield t.req():yield e.defaultPreset.reqAdd(),(null==t?void 0:t.post)?t.post(n):e.defaultPreset.postSubmitAdd(n)}catch(n){return console.error(n),void e.kit.useEditor().showNotify(`${A("commentFail")}: ${n.message||String(n)}`,"e")}finally{e.kit.useEditor().hideLoading()}e.kit.useEditor().reset(),e.kit.useEvents().trigger("editor-submitted")})()}},Ft=class extends Ut{constructor(...e){super(...e),ut(this,"isMoved",!1)}move(e){if(this.isMoved)return;this.isMoved=!0;const t=this.kit.useUI().$el;t.after(p('<div class="atk-editor-travel-placeholder"></div>'));const n=p("<div></div>");e.after(n),n.replaceWith(t),t.classList.add("atk-fade-in"),t.classList.add("editor-traveling")}back(){var e;this.isMoved&&(this.isMoved=!1,null===(e=this.kit.useArtalkRootEl().querySelector(".atk-editor-travel-placeholder"))||void 0===e||e.replaceWith(this.kit.useUI().$el),this.kit.useUI().$el.classList.remove("editor-traveling"))}};function qt(e,t){let n=e.querySelector(":scope > .atk-loading");n||(n=p('<div class="atk-loading" style="display: none;">\n <div class="atk-loading-spinner">\n <svg viewBox="25 25 50 50"><circle cx="50" cy="50" r="20" fill="none" stroke-width="2" stroke-miterlimit="10"></circle></svg>\n </div>\n </div>'),(null==t?void 0:t.transparentBg)&&(n.style.background="transparent"),e.appendChild(n)),n.style.display="";const i=n.querySelector(".atk-loading-spinner");i&&(i.style.display="none",window.setTimeout(()=>{i.isConnected&&(i.style.display="")},500))}function Wt(e){const t=e.querySelector(":scope > .atk-loading");t&&(t.style.display="none")}function Ht(e,t){e?qt(t):Wt(t)}function zt(e,t=!0,n){let i;if(n){const t=n.getBoundingClientRect();i=e.getBoundingClientRect().top-t.top+n.scrollTop-n.clientHeight/2+e.clientHeight/2}else{const t=e.getBoundingClientRect();i=t.top+window.scrollY-(window.innerHeight/2-t.height/2)}const o={top:i,left:0,behavior:"instant"};n?n.scroll(o):window.scroll(o)}function Gt(e,t){!function(e,t,n="in"){e.classList.add(`atk-fade-${n}`);const i=()=>{e.classList.remove(`atk-fade-${n}`),e.removeEventListener("animationend",i),t&&t()};e.addEventListener("animationend",i)}(e,t,"in")}function Vt(e,t,n='<span class="atk-error-title">Artalk Error</span>'){let i=e.querySelector(".atk-error-layer");if(null===t)return void(null!==i&&i.remove());i||(i=p(`<div class="atk-error-layer">${n}<span class="atk-error-text"></span></div>`),e.appendChild(i));const o=i.querySelector(".atk-error-text");o.innerHTML="",null!==t&&(t instanceof HTMLElement?o.appendChild(t):o.innerText=t)}var Kt=class extends Ut{constructor(e){var t;super(e),t=this,ut(this,"emoticons",[]),ut(this,"loadingTask",null),ut(this,"$grpWrap",void 0),ut(this,"$grpSwitcher",void 0),ut(this,"isListLoaded",!1),ut(this,"isImgLoaded",!1),this.kit.useMounted(()=>{this.usePanel('<div class="atk-editor-plug-emoticons"></div>'),this.useBtn(`<i role="img" aria-label="${A("emoticon")}"><svg fill="currentColor" aria-hidden="true" height="14" viewBox="0 0 14 14" width="14"><path d="m4.26829 5.29294c0-.94317.45893-1.7074 1.02439-1.7074.56547 0 1.02439.76423 1.02439 1.7074s-.45892 1.7074-1.02439 1.7074c-.56546 0-1.02439-.76423-1.02439-1.7074zm4.43903 1.7074c.56546 0 1.02439-.76423 1.02439-1.7074s-.45893-1.7074-1.02439-1.7074c-.56547 0-1.02439.76423-1.02439 1.7074s.45892 1.7074 1.02439 1.7074zm-1.70732 2.73184c-1.51883 0-2.06312-1.52095-2.08361-1.58173l-1.29551.43231c.03414.10244.868 2.51604 3.3798 2.51604 2.51181 0 3.34502-2.41291 3.37982-2.51604l-1.29484-.43573c-.02254.06488-.56683 1.58583-2.08498 1.58583zm7-2.73252c0 3.86004-3.1401 7.00034-7 7.00034s-7-3.1396-7-6.99966c0-3.86009 3.1401-7.00034 7-7.00034s7 3.14025 7 7.00034zm-1.3659 0c0-3.10679-2.5275-5.63442-5.6341-5.63442-3.10663 0-5.63415 2.52832-5.63415 5.6351 0 3.10676 2.52752 5.63446 5.63415 5.63446 3.1066 0 5.6341-2.5277 5.6341-5.63446z"/></svg></i>`)}),this.kit.useUnmounted(()=>{}),this.useContentTransformer(e=>this.transEmoticonImageText(e)),this.usePanelShow(()=>{u(function*(){yield t.loadEmoticonsData(),t.isImgLoaded||(t.initEmoticonsList(),t.isImgLoaded=!0),setTimeout(()=>{t.changeListHeight()},30)})()}),this.usePanelHide(()=>{this.$panel.parentElement.style.height=""}),window.setTimeout(()=>{this.loadEmoticonsData()},1e3)}loadEmoticonsData(){var e=this;return u(function*(){e.isListLoaded||(null===e.loadingTask?(e.loadingTask=u(function*(){qt(e.$panel),e.emoticons=yield e.handleData(e.kit.useConf().emoticons),Wt(e.$panel),e.loadingTask=null,e.isListLoaded=!0})(),yield e.loadingTask):yield e.loadingTask)})()}handleData(e){var t=this;return u(function*(){if(!Array.isArray(e)&&["object","string"].includes(typeof e)&&(e=[e]),!Array.isArray(e))return Vt(t.$panel,`[${A("emoticon")}] Data must be of Array/Object/String type`),Wt(t.$panel),[];const n=t=>{"object"==typeof t&&(t.name&&e.find(e=>e.name===t.name)||e.push(t))},i=function(){var e=u(function*(e){yield Promise.all(e.map(function(){var e=u(function*(e,o){if("object"!=typeof e||Array.isArray(e)){if(Array.isArray(e))yield i(e);else if("string"==typeof e){const o=yield t.remoteLoad(e);Array.isArray(o)?yield i(o):"object"==typeof o&&n(o)}}else n(e)});return function(t,n){return e.apply(this,arguments)}}()))});return function(t){return e.apply(this,arguments)}}();return yield i(e),e.forEach(e=>{t.isOwOFormat(e)?t.convertOwO(e).forEach(e=>{n(e)}):Array.isArray(e)&&e.forEach(e=>{n(e)})}),e=e.filter(e=>"object"==typeof e&&!Array.isArray(e)&&!!e&&!!e.name),t.solveNullKey(e),t.solveSameKey(e),e})()}remoteLoad(e){var t=this;return u(function*(){if(!e)return[];try{return yield(yield fetch(e)).json()}catch(n){return Wt(t.$panel),console.error("[Emoticons] Load Failed:",n),Vt(t.$panel,`[${A("emoticon")}] ${A("loadFail")}: ${String(n)}`),[]}})()}solveNullKey(e){e.forEach(e=>{e.items.forEach((t,n)=>{t.key||(t.key=`${e.name} ${n+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,n])=>{const i={name:e,type:n.type,items:[]};n.container.forEach((t,n)=>{const o=t.icon;if(/<(img|IMG)/.test(o)){const e=/src=["'](.*?)["']/.exec(o);e&&e.length>1&&(t.icon=e[1])}i.items.push({key:t.text||`${e} ${n+1}`,val:t.icon})}),t.push(i)}),t}initEmoticonsList(){this.$grpWrap=p('<div class="atk-grp-wrap"></div>'),this.$panel.append(this.$grpWrap),this.emoticons.forEach((e,t)=>{const n=p('<div class="atk-grp" style="display: none;"></div>');this.$grpWrap.append(n),n.setAttribute("data-index",String(t)),n.setAttribute("data-grp-name",e.name),n.setAttribute("data-type",e.type),e.items.forEach(t=>{const i=p('<span class="atk-item"></span>');if(n.append(i),t.key&&!new RegExp(`^(${e.name})?\\s?[0-9]+$`).test(t.key)&&i.setAttribute("title",t.key),"image"===e.type){const e=document.createElement("img");e.src=t.val,e.alt=t.key,i.append(e)}else i.innerText=t.val;i.onclick=()=>{"image"===e.type?this.kit.useEditor().insertContent(`:[${t.key}]`):this.kit.useEditor().insertContent(t.val||"")}})}),this.emoticons.length>1&&(this.$grpSwitcher=p('<div class="atk-grp-switcher"></div>'),this.$panel.append(this.$grpSwitcher),this.emoticons.forEach((e,t)=>{const n=p("<span />");n.innerText=e.name,n.setAttribute("data-index",String(t)),n.onclick=()=>this.openGrp(t),this.$grpSwitcher.append(n)})),this.emoticons.length>0&&this.openGrp(0)}openGrp(e){var t,n;Array.from(this.$grpWrap.children).forEach(t=>{const n=t;n.getAttribute("data-index")!==String(e)?n.style.display="none":n.style.display=""}),null===(t=this.$grpSwitcher)||void 0===t||t.querySelectorAll("span.active").forEach(e=>e.classList.remove("active")),null===(n=this.$grpSwitcher)||void 0===n||null===(n=n.querySelector(`span[data-index="${e}"]`))||void 0===n||n.classList.add("active"),this.changeListHeight()}changeListHeight(){}transEmoticonImageText(e){return this.emoticons&&Array.isArray(this.emoticons)?(this.emoticons.forEach(t=>{"image"===t.type&&Object.entries(t.items).forEach(([t,n])=>{e=e.split(`:[${n.key}]`).join(`<img src="${n.val}" atk-emoticon="${n.key}">`)})}),e):e}},Yt=["png","jpg","jpeg","gif","bmp","svg","webp"],Qt=class extends Ut{constructor(e){super(e),ut(this,"$imgUploadInput",void 0),this.kit.useMounted(()=>this.init()),this.initDragImg()}init(){var e=this;this.$imgUploadInput=document.createElement("input"),this.$imgUploadInput.type="file",this.$imgUploadInput.style.display="none",this.$imgUploadInput.accept=Yt.map(e=>`.${e}`).join(",");const t=this.useBtn(`<i role="img" aria-label="${A("uploadImage")}"><svg fill="currentColor" aria-hidden="true" height="14" viewBox="0 0 14 14" width="14"><path d="m0 1.94444c0-1.074107.870333-1.94444 1.94444-1.94444h10.11116c1.0741 0 1.9444.870333 1.9444 1.94444v10.11116c0 1.0741-.8703 1.9444-1.9444 1.9444h-10.11116c-1.074107 0-1.94444-.8703-1.94444-1.9444zm1.94444-.38888c-.21466 0-.38888.17422-.38888.38888v7.06689l2.33333-2.33333 2.33333 2.33333 3.88888-3.88889 2.3333 2.33334v-5.51134c0-.21466-.1742-.38888-.3888-.38888zm10.49996 8.09977-2.3333-2.33333-3.88888 3.8889-2.33333-2.33334-2.33333 2.33334v.8447c0 .2146.17422.3888.38888.3888h10.11116c.2146 0 .3888-.1742.3888-.3888zm-7.1944-6.54422c-.75133 0-1.36111.60978-1.36111 1.36111 0 .75134.60978 1.36111 1.36111 1.36111s1.36111-.60977 1.36111-1.36111c0-.75133-.60978-1.36111-1.36111-1.36111z"/></svg></i>`);t.after(this.$imgUploadInput),t.onclick=()=>{const t=this.$imgUploadInput;t.onchange=()=>{u(function*(){if(!t.files||0===t.files.length)return;const n=t.files[0];e.uploadImg(n)})()},t.click()},this.kit.useConf().imgUpload||this.$btn.setAttribute("atk-only-admin-show","")}initDragImg(){const e=e=>{if(e)for(let t=0;t<e.length;t++){const n=e[t];this.uploadImg(n)}},t=e=>{e.stopPropagation(),e.preventDefault()},n=t=>{var n;const i=null===(n=t.dataTransfer)||void 0===n?void 0:n.files;(null==i?void 0:i.length)&&(t.preventDefault(),e(i))},i=t=>{var n;const i=null===(n=t.clipboardData)||void 0===n?void 0:n.files;(null==i?void 0:i.length)&&(t.preventDefault(),e(i))};this.kit.useMounted(()=>{this.kit.useUI().$textarea.addEventListener("dragover",t),this.kit.useUI().$textarea.addEventListener("drop",n),this.kit.useUI().$textarea.addEventListener("paste",i)}),this.kit.useUnmounted(()=>{this.kit.useUI().$textarea.removeEventListener("dragover",t),this.kit.useUI().$textarea.removeEventListener("drop",n),this.kit.useUI().$textarea.removeEventListener("paste",i)})}uploadImg(e){var t=this;return u(function*(){const n=/[^.]+$/.exec(e.name);if(!n||!Yt.includes(String(n[0]).toLowerCase()))return;if(!t.kit.useUser().checkHasBasicUserInfo())return void t.kit.useEditor().showNotify(A("uploadLoginMsg"),"w");let i="\n";""===t.kit.useUI().$textarea.value.trim()&&(i="");const o=`${i}`;let s;t.kit.useEditor().insertContent(o);try{const n=t.kit.useConf().imgUploader;s=n?{public_url:yield n(e)}:(yield t.kit.useApi().upload.upload({file:e})).data}catch(r){console.error(r),t.kit.useEditor().showNotify(`${A("uploadFail")}: ${r.message}`,"e")}if(s&&s.public_url){let e=s.public_url;w(e)||(e=$({base:t.kit.useConf().server,path:e})),t.kit.useEditor().setContent(t.kit.useUI().$textarea.value.replace(o,`${i}`))}else t.kit.useEditor().setContent(t.kit.useUI().$textarea.value.replace(o,""))})()}},Xt=class extends Ut{constructor(e){super(e),ut(this,"isPlugPanelShow",!1),this.kit.useMounted(()=>{this.usePanel('<div class="atk-editor-plug-preview"></div>'),this.useBtn(`<i role="img" aria-label="${A("preview")}"><svg fill="currentColor" aria-hidden="true" viewBox="0 0 16 16" width="16" height="16"><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>`)}),this.kit.useUnmounted(()=>{}),this.kit.useEvents().on("content-updated",e=>{this.isPlugPanelShow&&this.updateContent()}),this.usePanelShow(()=>{this.isPlugPanelShow=!0,this.updateContent()}),this.usePanelHide(()=>{this.isPlugPanelShow=!1})}updateContent(){this.$panel.innerHTML=this.kit.useEditor().getContentMarked()}},Jt=[class extends Ut{constructor(e){super(e);const t=()=>{this.save()};this.kit.useMounted(()=>{const e=window.localStorage.getItem(Nt)||"";""!==e.trim()&&(this.kit.useEditor().showNotify(A("restoredMsg"),"i"),this.kit.useEditor().setContent(e)),this.kit.useEvents().on("content-updated",t)}),this.kit.useUnmounted(()=>{this.kit.useEvents().off("content-updated",t)})}save(){window.localStorage.setItem(Nt,this.kit.useEditor().getContentRaw().trim())}},class extends Ut{get $inputs(){return this.kit.useEditor().getHeaderInputEls()}constructor(e){super(e);const t={},n={},i=(e,t,n)=>()=>{this.kit.useEvents().trigger(e,{field:n,$input:t})};this.kit.useMounted(()=>{Object.entries(this.$inputs).forEach(([e,o])=>{o.addEventListener("input",t[e]=i("header-input",o,e)),o.addEventListener("change",n[e]=i("header-change",o,e))})}),this.kit.useUnmounted(()=>{Object.entries(this.$inputs).forEach(([e,i])=>{i.removeEventListener("input",t[e]),i.removeEventListener("change",n[e])})})}},class extends Ut{constructor(e){super(e),ut(this,"query",{timer:null,abortFn:null});const t=({$input:e,field:t})=>{"edit"!==this.kit.useEditor().getState()&&(this.kit.useUser().update({[t]:e.value.trim()}),"name"!==t&&"email"!==t||this.fetchUserInfo())},n={name:A("nick"),email:A("email"),link:A("link")};this.kit.useMounted(()=>{Object.entries(this.kit.useEditor().getHeaderInputEls()).forEach(([e,t])=>{t.placeholder=n[e],t.value=this.kit.useUser().getData()[e]||""}),this.kit.useEvents().on("header-input",t)}),this.kit.useUnmounted(()=>{this.kit.useEvents().off("header-input",t)})}fetchUserInfo(){this.kit.useUser().logout(),this.query.timer&&window.clearTimeout(this.query.timer),this.query.abortFn&&this.query.abortFn(),this.query.timer=window.setTimeout(()=>{this.query.timer=null;const e=this.kit.useApi(),t="getUserCancelToken";this.query.abortFn=()=>e.abortRequest(t),e.user.getUser(ht({},e.getUserFields()),{cancelToken:t}).then(e=>this.onUserInfoFetched(e.data)).catch(e=>{}).finally(()=>{this.query.abortFn=null})},400)}onUserInfoFetched(e){var t;e.is_login||this.kit.useUser().logout(),this.kit.useData().updateNotifies(e.notifies),this.kit.useUser().checkHasBasicUserInfo()&&!e.is_login&&(null===(t=e.user)||void 0===t?void 0:t.is_admin)&&this.kit.useCheckers().checkAdmin({onSuccess:()=>{}}),e.user&&e.user.link&&(this.kit.useUI().$link.value=e.user.link,this.kit.useUser().update({link:e.user.link}))}},class extends Ut{constructor(e){super(e);const t=({field:e})=>{"link"===e&&this.onLinkInputChange()};this.kit.useMounted(()=>{this.kit.useEvents().on("header-change",t)}),this.kit.useUnmounted(()=>{this.kit.useEvents().off("header-change",t)})}onLinkInputChange(){const e=this.kit.useUI().$link.value.trim();e&&!/^(http|https):\/\//.test(e)&&(this.kit.useUI().$link.value=`https://${e}`,this.kit.useUser().update({link:this.kit.useUI().$link.value}))}},class extends Ut{constructor(e){super(e);const t=e=>this.onKeydown(e),n=()=>this.onInput();this.kit.useMounted(()=>{this.kit.useUI().$textarea.placeholder=this.kit.useConf().placeholder||A("placeholder"),this.kit.useUI().$textarea.addEventListener("keydown",t),this.kit.useUI().$textarea.addEventListener("input",n)}),this.kit.useUnmounted(()=>{this.kit.useUI().$textarea.removeEventListener("keydown",t),this.kit.useUI().$textarea.removeEventListener("input",n)}),this.kit.useEvents().on("content-updated",()=>{window.setTimeout(()=>{this.adaptiveHeightByContent()},80)})}onKeydown(e){9===(e.keyCode||e.which)&&(e.preventDefault(),this.kit.useEditor().insertContent("\t"))}onInput(){this.kit.useEvents().trigger("content-updated",this.kit.useEditor().getContentRaw())}adaptiveHeightByContent(){const e=this.kit.useUI().$textarea.offsetHeight-this.kit.useUI().$textarea.clientHeight;this.kit.useUI().$textarea.style.height="0px",this.kit.useUI().$textarea.style.height=`${this.kit.useUI().$textarea.scrollHeight+e}px`}},Bt,class extends Ut{constructor(e){super(e);const t=()=>{this.kit.useEditor().submit()};this.kit.useMounted(()=>{this.kit.useUI().$submitBtn.innerText=this.kit.useConf().sendBtn||A("send"),this.kit.useUI().$submitBtn.addEventListener("click",t)}),this.kit.useUnmounted(()=>{this.kit.useUI().$submitBtn.removeEventListener("click",t)})}},Ft,class extends Ut{constructor(e){var t;super(e),t=this,ut(this,"comment",void 0),this.useEditorStateEffect("reply",e=>(this.setReply(e),()=>{this.cancelReply()})),this.kit.useEvents().on("mounted",()=>{const e=this.kit.useDeps(Bt);if(!e)throw Error("SubmitPlug not initialized");const n=new jt(this.kit);e.registerCustom({activeCond:()=>!!this.comment,req:function(){var e=u(function*(){if(!t.comment)throw new Error("reply comment cannot be empty");return(yield t.kit.useApi().comments.createComment(ht(ht({},yield n.getSubmitAddParams()),{},{rid:t.comment.id,page_key:t.comment.page_key,page_title:void 0,site_name:t.comment.site_name}))).data});return function(){return e.apply(this,arguments)}}(),post:e=>{const t=this.kit.useConf();e.page_key!==t.pageKey&&window.open(`${e.page_url}#atk-comment-${e.id}`),n.postSubmitAdd(e)}})})}setReply(e){const t=this.kit.useUI();if(!t.$sendReplyBtn){const n=p(`<span class="atk-state-btn"><span class="atk-text-wrap">${A("reply")} <span class="atk-text"></span></span><span class="atk-cancel atk-icon-close atk-icon"></span></span>`);n.querySelector(".atk-text").innerText=`@${e.nick}`,n.addEventListener("click",()=>{this.kit.useEditor().resetState()}),t.$stateWrap.append(n),t.$sendReplyBtn=n}this.comment=e,t.$textarea.focus()}cancelReply(){if(!this.comment)return;const e=this.kit.useUI();e.$sendReplyBtn&&(e.$sendReplyBtn.remove(),e.$sendReplyBtn=void 0),this.comment=void 0}},class extends Ut{constructor(e){var t;super(e),t=this,ut(this,"comment",void 0),ut(this,"originalSubmitBtnText","Send"),this.useEditorStateEffect("edit",e=>(this.edit(e),()=>{this.cancelEdit()})),this.kit.useMounted(()=>{const e=this.kit.useDeps(Bt);if(!e)throw Error("SubmitPlug not initialized");e.registerCustom({activeCond:()=>!!this.comment,req:function(){var e=u(function*(){const e={content:t.kit.useEditor().getContentFinal(),nick:t.kit.useUI().$name.value,email:t.kit.useUI().$email.value,link:t.kit.useUI().$link.value},n=t.comment;return(yield t.kit.useApi().comments.updateComment(n.id,ht(ht({},n),e))).data});return function(){return e.apply(this,arguments)}}(),post:e=>{this.kit.useData().updateComment(e)}})})}edit(e){const t=this.kit.useUI();if(!t.$editCancelBtn){const e=p(`<span class="atk-state-btn"><span class="atk-text-wrap">${A("editCancel")}</span><span class="atk-cancel atk-icon-close atk-icon"></span></span>`);e.onclick=()=>{this.kit.useEditor().resetState()},t.$stateWrap.append(e),t.$editCancelBtn=e}this.comment=e,t.$header.style.display="none",t.$name.value=e.nick||"",t.$email.value=e.email||"",t.$link.value=e.link||"",this.kit.useEditor().setContent(e.content),t.$textarea.focus(),this.updateSubmitBtnText(A("save"))}cancelEdit(){if(!this.comment)return;const e=this.kit.useUI();e.$editCancelBtn&&(e.$editCancelBtn.remove(),e.$editCancelBtn=void 0),this.comment=void 0;const{name:t,email:n,link:i}=this.kit.useUser().getData();e.$name.value=t,e.$email.value=n,e.$link.value=i,this.kit.useEditor().setContent(""),this.restoreSubmitBtnText(),e.$header.style.display=""}updateSubmitBtnText(e){this.originalSubmitBtnText=this.kit.useUI().$submitBtn.innerText,this.kit.useUI().$submitBtn.innerText=e}restoreSubmitBtnText(){this.kit.useUI().$submitBtn.innerText=this.originalSubmitBtnText}},class extends Ut{constructor(e){super(e);const t=()=>this.open(),n=()=>this.close();this.kit.useMounted(()=>{this.kit.useEvents().on("editor-open",t),this.kit.useEvents().on("editor-close",n)}),this.kit.useUnmounted(()=>{this.kit.useEvents().off("editor-open",t),this.kit.useEvents().off("editor-close",n)})}open(){var e;null===(e=this.kit.useUI().$textareaWrap.querySelector(".atk-comment-closed"))||void 0===e||e.remove(),this.kit.useUI().$textarea.style.display="",this.kit.useUI().$bottom.style.display=""}close(){this.kit.useUI().$textareaWrap.querySelector(".atk-comment-closed")||this.kit.useUI().$textareaWrap.prepend(p(`<div class="atk-comment-closed">${A("onlyAdminCanReply")}</div>`)),this.kit.useUser().getData().is_admin?(this.kit.useUI().$textarea.style.display="",this.kit.useUI().$bottom.style.display=""):(this.kit.useUI().$textarea.style.display="none",this.kit.useEvents().trigger("panel-close"),this.kit.useUI().$bottom.style.display="none")}},Kt,Qt,Xt];var Zt=class{constructor(e){ut(this,"plugins",void 0),this.plugins=e}useEditor(){return this.plugins.getEditor()}useConf(){return this.plugins.getOptions().getConf().get()}useApi(){return this.plugins.getOptions().getApi()}useData(){return this.plugins.getOptions().getData()}useUser(){return this.plugins.getOptions().getUser()}useCheckers(){return this.plugins.getOptions().getCheckers()}useUI(){return this.plugins.getEditor().getUI()}useEvents(){return this.plugins.getEvents()}useMounted(e){this.useEvents().on("mounted",e)}useUnmounted(e){this.useEvents().on("unmounted",e)}useDeps(e){return this.plugins.get(e)}useArtalkRootEl(){return this.plugins.getOptions().getArtalkRootEl()}},en=class{constructor(){ut(this,"events",[])}on(e,t,n={}){this.events.push(ht({name:e,handler:t},n))}off(e,t){t&&(this.events=this.events.filter(n=>!(n.name===e&&n.handler===t)))}trigger(e,t){this.events.slice(0).filter(t=>t.name===e&&"function"==typeof t.handler).forEach(n=>{n.once&&this.off(e,n.handler),n.handler(t)})}},tn=class{constructor(e){ut(this,"opts",void 0),ut(this,"plugins",[]),ut(this,"openedPlug",null),ut(this,"events",new en),this.opts=e;let t=!1;this.opts.getConf().watchConf(["imgUpload","emoticons","preview","editorTravel","locale"],e=>{t&&this.getEvents().trigger("unmounted"),this.clear(),function(e){const t=new Map;return t.set(Qt,e.imgUpload),t.set(Kt,e.emoticons),t.set(Xt,e.preview),t.set(Ft,e.editorTravel),Jt.filter(e=>!t.has(e)||!!t.get(e))}(e).forEach(e=>{const t=new Zt(this);this.plugins.push(new e(t))}),this.getEvents().trigger("mounted"),t=!0,this.loadPluginUI()}),this.events.on("panel-close",()=>this.closePluginPanel()),this.events.on("editor-submitted",()=>e.onSubmitted())}getPlugins(){return this.plugins}getEvents(){return this.events}getEditor(){return this.opts.getEditor()}getOptions(){return this.opts}clear(){this.plugins=[],this.events=new en,this.openedPlug&&this.closePluginPanel()}loadPluginUI(){this.getEditor().getUI().$plugPanelWrap.innerHTML="",this.getEditor().getUI().$plugPanelWrap.style.display="none",this.getEditor().getUI().$plugBtnWrap.innerHTML="",this.plugins.forEach(e=>this.loadPluginItem(e))}loadPluginItem(e){const t=e.$btn;if(!t)return;this.getEditor().getUI().$plugBtnWrap.appendChild(t),!t.onclick&&(t.onclick=()=>{this.opts.getEditor().getUI().$plugBtnWrap.querySelectorAll(".active").forEach(e=>e.classList.remove("active")),e!==this.openedPlug?(this.openPluginPanel(e),t.classList.add("active")):this.closePluginPanel()});const n=e.$panel;n&&(n.style.display="none",this.getEditor().getUI().$plugPanelWrap.appendChild(n))}get(e){return this.plugins.find(t=>t instanceof e)}openPluginPanel(e){this.plugins.forEach(t=>{const n=t.$panel;n&&(t===e?(n.style.display="",this.events.trigger("panel-show",e)):(n.style.display="none",this.events.trigger("panel-hide",e)))}),this.getEditor().getUI().$plugPanelWrap.style.display="",this.openedPlug=e}closePluginPanel(){this.openedPlug&&(this.getEditor().getUI().$plugPanelWrap.style.display="none",this.events.trigger("panel-hide",this.openedPlug),this.openedPlug=null)}getTransformedContent(e){let t=e;return this.plugins.forEach(e=>{e.contentTransformer&&(t=e.contentTransformer(t))}),t}};var nn="2.10.1";function on(e){const t=p('<span><span class="error-message"></span><br/><br/></span>');if(t.querySelector(".error-message").innerText=`${A("listLoadFailMsg")}\n${e.errMsg}`,e.retryFn){const n=p(`<span style="cursor:pointer;">${A("listRetry")}</span>`);n.onclick=()=>e.retryFn&&e.retryFn(),t.appendChild(n)}if(e.onOpenSidebar){const n=p(`<span atk-only-admin-show> | <span style="cursor:pointer;">${A("openName",{name:A("ctrlCenter")})}</span></span>`);t.appendChild(n),n.onclick=()=>e.onOpenSidebar&&e.onOpenSidebar()}Vt(e.$err,t)}var sn=[e=>{const t=e.inject("config");e.on("list-fetch",n=>{if(e.getData().getLoading())return;e.getData().setLoading(!0);const i=ht({offset:0,limit:t.get().pagination.pageSize,flatMode:t.get().flatMode,paramsModifier:t.get().listFetchParamsModifier},n);e.getData().setListLastFetch({params:i});const o={limit:i.limit,offset:i.offset,flat_mode:i.flatMode,page_key:t.get().pageKey,site_name:t.get().site};i.paramsModifier&&i.paramsModifier(o),e.getApi().comments.getComments(ht(ht({},o),e.getApi().getUserFields())).then(({data:t})=>{const n=o.scope;if(!(n&&"page"!==n||t.page))throw new Error("Page data is missing from comment list response");const s=t;e.getData().setListLastFetch({params:i,data:s}),e.getData().loadComments(s.comments),t.page&&e.getData().updatePage(t.page),i.onSuccess&&i.onSuccess(s),e.trigger("list-fetched",{params:i,data:s})}).catch(t=>{const n={msg:t.msg||String(t),data:t.data};throw i.onError&&i.onError(n),e.trigger("list-failed",n),e.trigger("list-fetched",{params:i,error:n}),t}).finally(()=>{e.getData().setLoading(!1)})})},e=>{const t=e.inject("list");e.on("list-fetch",e=>{0===e.offset&&Ht(!0,t.getEl())}),e.on("list-fetched",()=>{Ht(!1,t.getEl())})},e=>{const t=e.inject("config");e.on("comment-rendered",n=>{if(t.get().listUnreadHighlight){const t=e.getData().getNotifies(),i=t.find(e=>e.comment_id===n.getID());i?(n.getRender().setUnread(!0),n.getRender().setOpenAction(()=>{window.open(i.read_link),e.getData().updateNotifies(t.filter(e=>e.comment_id!==n.getID()))})):n.getRender().setUnread(!1)}}),e.on("list-goto",t=>{const n=m("atk_notify_key");n&&e.getApi().notifies.markNotifyRead(t,n).then(()=>{e.getData().updateNotifies(e.getData().getNotifies().filter(e=>e.comment_id!==t))})})},e=>{const t=e.inject("list"),n=e.inject("editorPlugs");let i;e.on("mounted",()=>{i=t.getEl().querySelector('[data-action="admin-close-comment"]'),i.addEventListener("click",()=>{const t=e.getData().getPage();if(!t)throw new Error("Page data not found");t.admin_only=!t.admin_only,function(e,t){e.editorShowLoading(),e.getApi().pages.updatePage(t.id,t).then(({data:t})=>{e.getData().updatePage(t)}).catch(t=>{e.editorShowNotify(`${A("editFail")}: ${t.message||String(t)}`,"e")}).finally(()=>{e.editorHideLoading()})}(e,t)})}),e.on("page-loaded",e=>{!0===(null==e?void 0:e.admin_only)?(null==n||n.getEvents().trigger("editor-close"),i&&(i.innerText=A("openComment"))):(null==n||n.getEvents().trigger("editor-open"),i&&(i.innerText=A("closeComment")))}),e.on("list-loaded",t=>{e.editorResetState()})},e=>{const t=e.inject("list");e.on("list-loaded",()=>{(()=>{var n;const i=t.getEl().querySelector(".atk-comment-count .atk-text");i&&(i.innerHTML=h(A("counter",{count:`${Number(null===(n=e.getData().getListLastFetch())||void 0===n||null===(n=n.data)||void 0===n?void 0:n.count)||0}`})).replace(/(\d+)/,'<span class="atk-comment-count-num">$1</span>'))})()}),e.on("comment-inserted",()=>{const t=e.getData().getListLastFetch();(null==t?void 0:t.data)&&(t.data.count+=1)}),e.on("comment-deleted",()=>{const t=e.getData().getListLastFetch();(null==t?void 0:t.data)&&(t.data.count-=1)})},e=>{const t=e.inject("list");let n=null;const i=()=>{if(!n)return;const t=e.inject("user").getData();if(t.name&&t.email){n.classList.remove("atk-hide");const e=n.querySelector(".atk-text");e&&(e.innerText=t.is_admin?A("ctrlCenter"):A("msgCenter"))}else n.classList.add("atk-hide")};e.watchConf(["locale"],o=>{n=t.getEl().querySelector('[data-action="open-sidebar"]'),n&&(n.onclick=()=>{e.showSidebar()},i())}),e.on("user-changed",e=>{i()})},e=>{const t=e.inject("list");let n=null;e.on("mounted",()=>{n=t.getEl().querySelector(".atk-unread-badge")}),e.on("notifies-updated",e=>{var t;t=e.length||0,n&&(t>0?(n.innerText=`${Number(t||0)}`,n.style.display="block"):n.style.display="none")})},e=>{const t=e.inject("list"),n=e.inject("config"),i=t=>{n.update({listFetchParamsModifier:t}),e.reload()},o=e=>{!function(e){const{$dropdownWrap:t,dropdownList:n}=e;if(t.querySelector(".atk-dropdown"))return;t.classList.add("atk-dropdown-wrap"),t.append(p('<span class="atk-arrow-down-icon"></span>'));let i=0;const o=(e,t,n,o)=>{o(),i=e,s.querySelectorAll(".active").forEach(e=>{e.classList.remove("active")}),t.classList.add("active"),s.style.display="none",setTimeout(()=>{s.style.display=""},80)},s=p('<ul class="atk-dropdown atk-fade-in"></ul>');n.forEach((e,t)=>{const[n,r]=e,a=p('<li class="atk-dropdown-item"><span></span></li>'),l=a.querySelector("span");l.innerText=n,l.onclick=()=>{o(t,a,n,r)},s.append(a),t===i&&a.classList.add("active")}),t.append(s)}({$dropdownWrap:e,dropdownList:[[A("sortLatest"),()=>{i(e=>{e.sort_by="date_desc"})}],[A("sortBest"),()=>{i(e=>{e.sort_by="vote"})}],[A("sortOldest"),()=>{i(e=>{e.sort_by="date_asc"})}],[A("sortAuthor"),()=>{i(e=>{e.view_only_admin=!0})}]]})};e.watchConf(["listSort","locale"],e=>{const n=t.getEl().querySelector(".atk-comment-count");n&&(e.listSort?o(n):function(e){var t,n;const{$dropdownWrap:i}=e;i.classList.remove("atk-dropdown-wrap"),null===(t=i.querySelector(".atk-arrow-down-icon"))||void 0===t||t.remove(),null===(n=i.querySelector(".atk-dropdown"))||void 0===n||n.remove()}({$dropdownWrap:n}))})},e=>{let t=0;const n=({locker:n})=>{const i=function(){const e=window.location.hash.match(/#atk-comment-([0-9]+)/);let t=e&&e[1]&&!Number.isNaN(parseFloat(e[1]))?parseFloat(e[1]):null;t||(t=Number(m("atk_comment")));return t||null}();i&&(n&&t===i||(t=i,e.trigger("list-goto",i)))},i=()=>n({locker:!1}),o=()=>n({locker:!0});e.on("mounted",()=>{window.addEventListener("hashchange",i),e.on("list-loaded",o)}),e.on("unmounted",()=>{window.removeEventListener("hashchange",i),e.off("list-loaded",o)})},e=>{const t=e.inject("list");e.on("list-goto",function(){var n=u(function*(n){let i=e.getCommentNodes().find(e=>e.getID()===n);if(!i){const o=(yield e.getApi().comments.getComment(n)).data;t.getLayout({forceFlatMode:!0}).insert(o.comment,o.reply_comment),i=e.getCommentNodes().find(e=>e.getID()===n)}i&&i.focus()});return function(e){return n.apply(this,arguments)}}())},e=>{const t=e.inject("list"),n=e.inject("config");e.on("list-loaded",i=>{const o=i.length<=0;let s=t.getCommentsWrapEl().querySelector(".atk-list-no-comment");o?s||(s=p('<div class="atk-list-no-comment"></div>'),s.innerHTML=et(n.get().noComment||e.$t("noComment")),t.getCommentsWrapEl().appendChild(s)):null==s||s.remove()})},e=>{const t=e.inject("list");e.on("mounted",()=>{const e=t.getEl().querySelector(".atk-copyright");e&&(e.innerHTML=`Powered By <a href="https://artalk.js.org" target="_blank" title="Artalk v${nn}">Artalk</a>`)})},e=>{const t=e.inject("list"),n=e.inject("config");let i=null;e.on("mounted",()=>{i=window.setInterval(()=>{t.getEl().querySelectorAll("[data-atk-comment-date]").forEach(t=>{var i,o;const s=new Date(Number(t.getAttribute("data-atk-comment-date")));t.innerText=(null===(i=(o=n.get()).dateFormatter)||void 0===i?void 0:i.call(o,s))||v(s,e.$t)})},3e4)}),e.on("unmounted",()=>{i&&window.clearInterval(i)})},e=>{const t=e.inject("list");e.on("list-fetch",()=>{Vt(t.getEl(),null)}),e.on("list-failed",n=>{on({$err:t.getEl(),errMsg:n.msg,errData:n.data,retryFn:()=>e.fetch({offset:0})})})},e=>{const t=e.inject("list"),n=e.inject("config");let i=null;const o=()=>{null==i||i.disconnect(),i=null};e.on("list-loaded",()=>{o();const s=t.getCommentsWrapEl().childNodes,r=s.length>2?s[s.length-2]:null;r&&("IntersectionObserver"in window?(t=>{var s,r;const a=(null===(s=(r=n.get()).scrollRelativeTo)||void 0===s?void 0:s.call(r))||null;i=new IntersectionObserver(([t])=>{t.isIntersecting&&(o(),e.trigger("list-reach-bottom"))},{threshold:.9,root:a}),i.observe(t)})(r):console.warn("IntersectionObserver api not supported"))}),e.on("unmounted",()=>{o()})},e=>{const t=e.inject("list"),n=e.inject("config"),i=()=>{var e,i;const o=null===(e=(i=n.get()).scrollRelativeTo)||void 0===e?void 0:e.call(i);(o||window).scroll({top:g(t.getEl(),o).top,left:0})};e.on("mounted",()=>{e.on("list-goto-first",i)}),e.on("unmounted",()=>{e.off("list-goto-first",i)})}],rn=!1;var an;function ln(e,t){const n="atk-dark-mode";e.forEach(e=>{t?e.classList.add(n):e.classList.remove(n)})}var cn={upBtnEl:".artalk-page-vote-up",downBtnEl:".artalk-page-vote-down",upCountEl:".artalk-page-vote-up-count",downCountEl:".artalk-page-vote-down-count",activeClass:"active"};function dn(e,t,n,i,o){var s,r;e.upCountEl?e.upCountEl.innerText=String(t):e.upBtnEl&&(e.upBtnEl.innerText=`${A("voteUp")} (${t})`),e.downCountEl?e.downCountEl.innerText=String(n):e.downBtnEl&&(e.downBtnEl.innerText=`${A("voteDown")} (${n})`),"boolean"==typeof i&&(null===(s=e.upBtnEl)||void 0===s||s.classList.toggle(e.activeClass||"active",i)),"boolean"==typeof o&&(null===(r=e.downBtnEl)||void 0===r||r.classList.toggle(e.activeClass||"active",o))}var un=(e,t)=>n=>{n.preventDefault();const{state:i,pageId:o,httpApi:s}=t();o&&s.votes.createVote("page",o,e,ht({},s.getUserFields())).then(({data:e})=>{dn(i,e.up,e.down,e.is_up,e.is_down)}).catch(e=>{window.alert(A("voteFail")),console.error("[ArtalkPageVote]",e)})};var pn=new Map,hn=e=>"string"==typeof e&&/^[a-f0-9]{64}$/.test(e);function mn(e){const t=new URL(e,window.location.href);return`ArtalkGuest:${t.origin}${t.pathname.replace(/\/+$/,"")}`}function gn(e,t=!1){var n;const i=mn(e);if(pn.has(i))return pn.get(i);try{const e=window.localStorage.getItem(i);if(hn(e))return pn.set(i,e),e}catch(r){}if(!t||!(null===(n=window.crypto)||void 0===n?void 0:n.getRandomValues))return;const o=window.crypto.getRandomValues(new Uint8Array(32)),s=Array.from(o,e=>e.toString(16).padStart(2,"0")).join("");return fn(e,s),s}function fn(e,t){if(!hn(t))return;const n=mn(e);pn.set(n,t);try{window.localStorage.setItem(n,t)}catch(i){}}var vn="ArtalkUser",yn=class{constructor(e){ut(this,"opts",void 0),ut(this,"data",void 0),ut(this,"getGuestToken",gn),ut(this,"setGuestToken",fn),this.opts=e;let t={};try{t=JSON.parse(window.localStorage.getItem(vn)||"{}")||{}}catch(n){}this.data={name:t.name||t.nick||"",email:t.email||"",link:t.link||"",token:t.token||"",is_admin:t.is_admin||t.isAdmin||!1}}getData(){return this.data}update(e={}){Object.entries(e).forEach(([e,t])=>{this.data[e]=t});try{window.localStorage.setItem(vn,JSON.stringify(this.data))}catch(t){}this.opts.onUserChanged&&this.opts.onUserChanged(this.data)}logout(){this.update({token:"",is_admin:!1})}checkHasBasicUserInfo(){return!!this.data.name&&!!this.data.email}};function kn(e){const t=p('<div class="atk-checker-iframe-wrap"></div>'),n=p('<iframe class="atk-fade-in" referrerpolicy="strict-origin-when-cross-origin"></iframe>');n.style.display="none",qt(t,{transparentBg:!0}),n.src=e.getOpts().getCaptchaIframeURL(),n.onload=()=>{n.style.display="",Wt(t)},t.append(n);const i=p('<div class="atk-close-btn"><i class="atk-icon atk-icon-close"></i></div>');t.append(i),e.hideInteractInput();let o=!1;return function(){var t=u(function*(){var t;if(yield(t=1e3,new Promise(e=>{window.setTimeout(()=>{e(null)},t)})),o)return;let i;try{i=(yield e.getApi().captcha.getCaptchaStatus()).data.is_pass}catch(s){i=!1}i?e.triggerSuccess():n()});function n(){return t.apply(this,arguments)}return n}()(),i.onclick=()=>{o=!0,e.cancel()},t}var wn={request:(e,t)=>e.getApi().captcha.verifyCaptcha({value:t}),body:e=>e.get("iframe")?kn(e):function(e){const t=p(`<span><img class="atk-captcha-img" src="${e.get("img_data")||""}">${A("captchaCheck")}</span>`);return t.querySelector(".atk-captcha-img").onclick=()=>{const n=t.querySelector(".atk-captcha-img");e.getApi().captcha.getCaptcha().then(e=>{n.setAttribute("src",e.data.img_data)}).catch(e=>{console.error("Failed to get captcha image ",e)})},t}(e),onSuccess(e,t,n,i){e.set("val",n)},onError(e,t,n,i){i.querySelector(".atk-captcha-img").click(),i.querySelector('input[type="text"]').value=""}},$n={inputType:"password",request:(e,t)=>u(function*(){return(yield e.getApi().user.login({name:e.getUser().getData().name,email:e.getUser().getData().email,password:t})).data})(),body:e=>p(`<span>${A("adminCheck")}</span>`),onSuccess(e,t,n,i){e.getUser().update({is_admin:!0,token:t.token}),e.getOpts().onReload()},onError(e,t,n,i){}},bn=class{constructor(e){ut(this,"$el",void 0),ut(this,"$content",void 0),ut(this,"$actions",void 0),this.$el=p('<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)}setYes(e){const t=p(`<button data-action="confirm">${A("confirm")}</button>`);return t.onclick=this.onBtnClick(e),this.$actions.appendChild(t),this}setNo(e){const t=p(`<button data-action="cancel">${A("cancel")}</button>`);return t.onclick=this.onBtnClick(e),this.$actions.appendChild(t),this}onBtnClick(e){return t=>{const n=e(t.currentTarget,this);void 0!==n&&!0!==n||this.$el.remove()}}};function En(e){return t=>new Promise((n,i)=>{const o=t.onCancel;t.onCancel=()=>{o&&o(),i(new Error("user canceled the checker"))};const s=t.onSuccess;t.onSuccess=()=>{s&&s(),n()},e(t)})}var Cn=class{constructor(e){ut(this,"opts",void 0),ut(this,"checkCaptcha",En(e=>{this.check(wn,e,t=>{t.set("img_data",e.img_data),t.set("iframe",e.iframe)})})),ut(this,"checkAdmin",En(e=>{this.check($n,e)})),this.opts=e}check(e,t,n){const i=this.opts.getLayers().create(`checker-${(new Date).getTime()}`);i.show();const o=()=>{i.destroy()},s={};let r=!1;const a={set:(e,t)=>{s[e]=t},get:e=>s[e],getOpts:()=>this.opts,getUser:()=>this.opts.getUser(),getApi:()=>this.opts.getApi(),hideInteractInput:()=>{r=!0},triggerSuccess:()=>{o(),e.onSuccess&&e.onSuccess(a,"","",l),t.onSuccess&&t.onSuccess()},cancel:()=>{o(),t.onCancel&&t.onCancel()}};n&&n(a);const l=p();l.appendChild(e.body(a));const c=p(`<input id="check" type="${e.inputType||"text"}" autocomplete="off" required placeholder="">`);let d;l.appendChild(c),setTimeout(()=>c.focus(),80),c.onkeyup=e=>{"Enter"!==e.key&&13!==e.keyCode||(e.preventDefault(),i.getEl().querySelector('button[data-action="confirm"]').click())};const u=new bn(l);u.setYes(n=>{const i=c.value.trim();d||(d=n.innerText);const s=()=>{n.innerText=d||"",n.classList.remove("error")};return n.innerText=`${A("loading")}...`,e.request(a,i).then(n=>{o(),e.onSuccess&&e.onSuccess(a,n,i,l),t.onSuccess&&t.onSuccess()}).catch(t=>{var o;o=String(t.message||String(t)),n.innerText=o,n.classList.add("error"),e.onError&&e.onError(a,t,i,l);const r=setTimeout(()=>s(),3e3);c.onfocus=()=>{s(),clearTimeout(r)}}),!1}),u.setNo(()=>(o(),t.onCancel&&t.onCancel(),!1)),r&&(c.style.display="none",u.$el.querySelector(".atk-layer-dialog-actions").style.display="none"),i.getEl().append(u.$el),t.onMount&&t.onMount(u.$el)}},Sn={$header:".atk-header",$name:'.atk-header [name="name"]',$email:'.atk-header [name="email"]',$link:'.atk-header [name="link"]',$textareaWrap:".atk-textarea-wrap",$textarea:".atk-textarea",$bottom:".atk-bottom",$submitBtn:".atk-send-btn",$notifyWrap:".atk-notify-wrap",$bottomLeft:".atk-bottom-left",$stateWrap:".atk-state-wrap",$plugBtnWrap:".atk-plug-btn-wrap",$plugPanelWrap:".atk-plug-panel-wrap"};var Tn,An,xn=class{constructor(e){ut(this,"editor",void 0),ut(this,"stateCurt","normal"),ut(this,"stateUnmountFn",null),this.editor=e}get(){return this.stateCurt}switch(e,t){var n;this.stateUnmountFn&&(this.stateUnmountFn(),this.stateUnmountFn=null,null===(n=this.editor.getPlugins())||void 0===n||null===(n=n.get(Ft))||void 0===n||n.back());if("normal"!==e&&t){var i,o,s,r;let n=t.$comment;this.editor.getOptions().getConf().get().flatMode||(n=n.querySelector(".atk-footer")),null===(i=this.editor.getPlugins())||void 0===i||null===(i=i.get(Ft))||void 0===i||i.move(n);const a=null===(o=(s=this.editor.getOptions().getConf().get()).scrollRelativeTo)||void 0===o?void 0:o.call(s);zt(this.editor.getUI().$el,!0,a);const l=null===(r=this.editor.getPlugins())||void 0===r?void 0:r.getPlugins().find(t=>t.editorStateEffectWhen===e);l&&l.editorStateEffect&&(this.stateUnmountFn=l.editorStateEffect(t.comment))}this.stateCurt=e}},Ln=class{constructor(e){ut(this,"opts",void 0),ut(this,"_$el",void 0),ut(this,"ui",void 0),ut(this,"state",void 0),ut(this,"plugins",void 0),this.opts=e,this.ui=function(){const e=p('<div class="atk-main-editor">\n <div class="atk-header">\n <input name="name" class="atk-name" type="text" required="required" />\n <input name="email" class="atk-email" type="email" required="required" />\n <input name="link" class="atk-link" type="url" />\n </div>\n <div class="atk-textarea-wrap">\n <textarea class="atk-textarea"></textarea>\n </div>\n <div class="atk-plug-panel-wrap" style="display: none"></div>\n <div class="atk-bottom">\n <div class="atk-item atk-bottom-left">\n <span class="atk-state-wrap"></span>\n <span class="atk-plug-btn-wrap"></span>\n </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'),t={$el:e};return Object.entries(Sn).forEach(([n,i])=>{t[n]=e.querySelector(i)}),t}(),this._$el=this.ui.$el,this.state=new xn(this)}getOptions(){return this.opts}getEl(){return this._$el}get $el(){return this.getEl()}getUI(){return this.ui}getPlugins(){return this.plugins}getPlugs(){return this.getPlugins()}setPlugins(e){this.plugins=e}getState(){return this.state.get()}getHeaderInputEls(){return{name:this.ui.$name,email:this.ui.$email,link:this.ui.$link}}getContentFinal(){let e=this.getContentRaw();const t=this.getPlugins();return t&&(e=t.getTransformedContent(e)),e}getContentRaw(){return this.ui.$textarea.value||""}getContentMarked(){return vt(this.getContentFinal())}setContent(e){var t;this.ui.$textarea.value=e,null===(t=this.getPlugins())||void 0===t||t.getEvents().trigger("content-updated",e)}insertContent(e){if(document.selection)this.ui.$textarea.focus(),document.selection.createRange().text=e,this.ui.$textarea.focus();else if(this.ui.$textarea.selectionStart||0===this.ui.$textarea.selectionStart){const t=this.ui.$textarea.selectionStart,n=this.ui.$textarea.selectionEnd,i=this.ui.$textarea.scrollTop;this.setContent(this.ui.$textarea.value.substring(0,t)+e+this.ui.$textarea.value.substring(n,this.ui.$textarea.value.length)),this.ui.$textarea.focus(),this.ui.$textarea.selectionStart=t+e.length,this.ui.$textarea.selectionEnd=t+e.length,this.ui.$textarea.scrollTop=i}else this.ui.$textarea.focus(),this.ui.$textarea.value+=e}focus(){this.ui.$textarea.focus()}reset(){this.setContent(""),this.resetState()}resetState(){this.state.switch("normal")}setReplyComment(e,t){this.state.switch("reply",{comment:e,$comment:t})}setReply(e,t,n){this.setReplyComment(e,t)}setEditComment(e,t){this.state.switch("edit",{comment:e,$comment:t})}showNotify(e,t){!function(e,t,n){const i=p(`<div class="atk-notify atk-fade-in" style="background-color: ${{s:"#57d59f",e:"#ff6f6c",w:"#ffc721",i:"#2ebcfc"}[n]}"><span class="atk-notify-content"></span></div>`);i.querySelector(".atk-notify-content").innerHTML=h(t).replace("\n","<br/>"),e.appendChild(i);const o=()=>{i.classList.add("atk-fade-out"),setTimeout(()=>{i.remove()},200)};let s;s=window.setTimeout(()=>{o()},3e3),i.addEventListener("click",()=>{o(),window.clearTimeout(s)})}(this.ui.$notifyWrap,e,t)}showLoading(){qt(this.ui.$el)}hideLoading(){Wt(this.ui.$el)}submit(){const e=()=>{var e;null===(e=this.getPlugins())||void 0===e||e.getEvents().trigger("editor-submit"),this.opts.getEvents().trigger("editor-submit")},t=this.opts.getConf().get().beforeSubmit;t?t(this,e):e()}},On=class{constructor(e){ut(this,"events",void 0),ut(this,"loading",!1),ut(this,"listLastFetch",void 0),ut(this,"comments",[]),ut(this,"notifies",[]),ut(this,"page",void 0),this.events=e}getLoading(){return this.loading}setLoading(e){this.loading=e}getListLastFetch(){return this.listLastFetch}setListLastFetch(e){this.listLastFetch=e}getComments(){return this.comments}fetchComments(e){this.events.trigger("list-fetch",e)}findComment(e){return this.comments.find(t=>t.id===e)}clearComments(){this.comments=[],this.events.trigger("list-loaded",this.comments)}loadComments(e){this.events.trigger("list-load",e),this.comments.push(...e),this.events.trigger("list-loaded",this.comments)}insertComment(e){this.comments.push(e),this.events.trigger("comment-inserted",e),this.events.trigger("list-loaded",this.comments)}updateComment(e){this.comments=this.comments.map(t=>t.id===e.id?e:t),this.events.trigger("comment-updated",e),this.events.trigger("list-loaded",this.comments)}deleteComment(e){const t=this.comments.find(t=>t.id===e);if(!t)throw new Error(`Comment ${e} not found`);this.comments=this.comments.filter(t=>t.id!==e),this.events.trigger("comment-deleted",t),this.events.trigger("list-loaded",this.comments)}getNotifies(){return this.notifies}updateNotifies(e){this.notifies=e,this.events.trigger("notifies-updated",this.notifies)}getPage(){return this.page}updatePage(e){this.page=e,this.events.trigger("page-loaded",e)}},Mn=class{constructor(e,t){ut(this,"$el",void 0),ut(this,"opts",void 0),ut(this,"allowMaskClose",!0),ut(this,"onAfterHide",void 0),this.$el=e,this.opts=t}setOnAfterHide(e){this.onAfterHide=e}setAllowMaskClose(e){this.allowMaskClose=e}getAllowMaskClose(){return this.allowMaskClose}getEl(){return this.$el}show(){this.opts.onShow(),this.$el.style.display=""}hide(){this.opts.onHide(),this.$el.style.display="none",this.onAfterHide&&this.onAfterHide()}destroy(){this.opts.onHide(),this.$el.remove(),this.onAfterHide&&this.onAfterHide()}};function Pn(){return{init(){Tn=document.body.style.overflow,An=document.body.style.paddingRight},unlock(){document.body.style.overflow=Tn,document.body.style.paddingRight=An},lock(){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 n=e.offsetWidth;t.style.overflow="scroll";let i=e.offsetWidth;return n===i&&(i=t.clientWidth),document.body.removeChild(t),n-i}()+e||0}px`}}}var Dn=class{constructor(){ut(this,"$wrap",void 0),ut(this,"$mask",void 0),ut(this,"items",[]),this.$wrap=p('<div class="atk-layer-wrap" style="display: none;"><div class="atk-layer-mask"></div></div>'),this.$mask=this.$wrap.querySelector(".atk-layer-mask")}createItem(e,t){(t=t||this.createItemElement(e)).setAttribute("data-layer-name",e),this.$wrap.appendChild(t);const n=new Mn(t,{onHide:()=>this.hideWrap(t),onShow:()=>this.showWrap()});return this.getMask().addEventListener("click",()=>{n.getAllowMaskClose()&&n.hide()}),this.items.push(n),n}createItemElement(e){const t=document.createElement("div");return t.classList.add("atk-layer-item"),t.style.display="none",this.$wrap.appendChild(t),t}getWrap(){return this.$wrap}getMask(){return this.$mask}showWrap(){this.$wrap.style.display="block",this.$mask.style.display="block",this.$mask.classList.add("atk-fade-in"),Pn().lock()}hideWrap(e){this.items.map(e=>e.getEl()).filter(t=>t!==e&&t.isConnected&&"none"!==t.style.display).length>0||(this.$wrap.style.display="none",Pn().unlock())}},_n=class{constructor(){ut(this,"wrap",new Dn),Pn().init()}getEl(){return this.wrap.getWrap()}create(e,t){return this.wrap.createItem(e,t)}destroy(){this.wrap.getWrap().remove()}};var In=e=>({import:t=>{(function(e,t="DATE_DESC",n=2){const i=[];e.filter(e=>0===e.rid).forEach(t=>{const o={id:t.id,comment:t,children:[],level:1};o.parent=o,i.push(o),function t(i){const o=e.filter(e=>e.rid===i.id);0!==o.length&&(i.level>=n&&(i=i.parent),o.forEach(e=>{const n={id:e.id,comment:e,children:[],parent:i,level:i.level+1};i.children.push(n),t(n)}))}(o)});const o=(n,i)=>{let o=n.id-i.id;return"DATE_ASC"===t?o=+new Date(n.comment.date)-+new Date(i.comment.date):"DATE_DESC"===t?o=+new Date(i.comment.date)-+new Date(n.comment.date):"SRC_INDEX"===t?o=e.indexOf(n.comment)-e.indexOf(i.comment):"VOTE_UP_DESC"===t&&(o=i.comment.vote_up-n.comment.vote_up),o};return function e(t){t.forEach(t=>{t.children=t.children.sort(o),e(t.children)})}(i),i})(t,e.nestSortBy,e.nestMax).forEach(n=>{var i;const o=e.createCommentNode(n.comment);null===(i=e.$commentsWrap)||void 0===i||i.appendChild(o.getEl()),o.getRender().playFadeAnim();const s=(n,i)=>{i.children.forEach(i=>{const o=t.find(e=>e.id===i.comment.rid),r=i.comment,a=e.createCommentNode(r,o);n.putChild(a),s(a,i)})};s(o,n),o.getRender().checkHeightLimit()})},insert:(t,n)=>{const i=e.createCommentNode(t,n);if(0===t.rid){var o;null===(o=e.$commentsWrap)||void 0===o||o.prepend(i.getEl())}else{const n=e.findCommentNode(t.rid);n&&(n.putChild(i,"DATE_ASC"===e.nestSortBy?"append":"prepend"),i.getParents().forEach(e=>{e.getRender().heightLimitRemoveForChildren()}))}i.getRender().checkHeightLimit(),i.scrollIntoView(),i.getRender().playFadeAnim()}});function Rn(e,t,n,i){n.is_collapsed&&(n.is_allow_reply=!1);const o=e.createCommentNode(n,i);if(n.visible){const n=o.getEl(),i=e.$commentsWrap;"append"===t&&(null==i||i.append(n)),"prepend"===t&&(null==i||i.prepend(n)),o.getRender().playFadeAnim()}return o.getRender().checkHeightLimit(),o}var Un=class{constructor(e){ut(this,"options",void 0),this.options=e}getStrategy(){return this.options.flatMode?(e=this.options,{import:t=>{t.forEach(n=>{Rn(e,"append",n,0===n.rid?void 0:t.find(e=>e.id===n.rid))})},insert:(t,n)=>{Rn(e,"prepend",t,n).scrollIntoView()}}):In(this.options);var e}import(e){this.getStrategy().import(e)}insert(e,t){this.getStrategy().insert(e,t)}};function Nn(e,t){t.forEach(({el:t,max:n,imgCheck:i})=>{if(!t)return;i&&(t.style.maxHeight=`${n+1}px`);let o=!1;const s=()=>{if(o)return;if(function(e){return parseFloat(getComputedStyle(e,null).height.replace("px",""))||0}(t)<=n)return;e.scrollable?function(e){if(!e.el)return;if(e.el.classList.contains(Fn))return;e.el.classList.add(Fn),e.el.style.height=`${e.max}px`}({el:t,max:n}):function(e){if(!e.el)return;if(!e.max)return;if(e.el.classList.contains(jn))return;e.el.classList.add(jn),e.el.style.height=`${e.max}px`,e.el.style.overflow="hidden";const t=p(`<div class="atk-height-limit-btn">${A("readMore")}</span>`);t.onclick=t=>{t.stopPropagation(),Bn(e.el),e.afterExpandBtnClick&&e.afterExpandBtnClick(t)},e.el.append(t)}({el:t,max:n,afterExpandBtnClick:()=>{var t;o=!0,null===(t=e.afterExpandBtnClick)||void 0===t||t.call(e)}})};if(s(),i){const e=t.querySelectorAll(".atk-content img");0===e.length&&(t.style.maxHeight=""),e.forEach(e=>{e.onload=()=>s()})}})}var jn="atk-height-limit";function Bn(e){e&&e.classList.contains(jn)&&(e.classList.remove(jn),Array.from(e.children).forEach(e=>{e.classList.contains("atk-height-limit-btn")&&e.remove()}),e.style.height="",e.style.maxHeight="",e.style.overflow="")}var Fn="atk-height-limit-scroll";function qn(e){if(e.$headerNick=e.$el.querySelector(".atk-nick"),e.data.link){const t=p('<a target="_blank" rel="noreferrer noopener nofollow ugc"></a>');t.innerText=e.data.nick,t.href=w(e.data.link)?e.data.link:`https://${e.data.link}`,e.$headerNick.append(t)}else e.$headerNick.innerText=e.data.nick}function Wn(e){e.$headerBadgeWrap=e.$el.querySelector(".atk-badge-wrap"),e.$headerBadgeWrap.innerHTML="";const t=e.data.badge_name,n=e.data.badge_color;if(t){const i=p('<span class="atk-badge"></span>');i.innerText=t.replace("管理员",A("admin")),i.style.backgroundColor=n||"",e.$headerBadgeWrap.append(i)}else if(e.data.is_verified){const t=p(`<span class="atk-icon-verified" title="${A("emailVerified")}"></span>`);e.$headerBadgeWrap.append(t)}if(e.data.is_pinned){const t=p(`<span class="atk-pinned-badge">${A("pin")}</span>`);e.$headerBadgeWrap.append(t)}}function Hn(e){const t=e.$el.querySelector(".atk-date");t.innerText=e.comment.getDateFormatted(),t.setAttribute("data-atk-comment-date",String(+new Date(e.data.date)))}function zn(e){if(!e.opts.uaBadge&&!e.data.ip_region)return;let t=e.$header.querySelector("atk-ua-wrap");if(t||(t=p('<span class="atk-ua-wrap"></span>'),e.$header.append(t)),t.innerHTML="",e.data.ip_region){const n=p('<span class="atk-region-badge"></span>');n.innerText=e.data.ip_region,t.append(n)}if(e.opts.uaBadge){const{browser:n,os:i}=e.comment.getUserUA();if(String(n).trim()){const e=p('<span class="atk-ua ua-browser"></span>');e.innerText=n,t.append(e)}if(String(i).trim()){const e=p('<span class="atk-ua ua-os"></span>');e.innerText=i,t.append(e)}}}var Gn=class{get isMessaging(){return!!this.msgRecTimer}constructor(e){ut(this,"opts",void 0),ut(this,"$el",void 0),ut(this,"isLoading",!1),ut(this,"msgRecTimer",void 0),ut(this,"msgRecTimerFunc",void 0),ut(this,"isConfirming",!1),ut(this,"confirmRecTimer",void 0),this.$el=p('<span class="atk-common-action-btn"></span>'),this.opts="object"!=typeof e?{text:e}:e,this.$el.innerText=this.getText(),this.opts.adminOnly&&this.$el.setAttribute("atk-only-admin-show","")}appendTo(e){return e.append(this.$el),this}getText(){return"string"==typeof this.opts.text?this.opts.text:this.opts.text()}setClick(e){this.$el.onclick=t=>{if(t.stopPropagation(),!this.isLoading){if(this.opts.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.opts.confirmText||A("actionConfirm"),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.opts.text=e),this.setLoading(!1),this.$el.innerText=this.getText()}setLoading(e,t){this.isLoading!==e&&(this.isLoading=e,e?(this.$el.classList.add("atk-btn-loading"),this.$el.innerText=t||`${A("loading")}...`):(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,n,i){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),i&&i()},n||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}};function Vn(e){e.opts.vote&&(e.voteBtnUp=new Gn(()=>`${A("voteUp")} (${e.data.vote_up||0})`).appendTo(e.$actions),e.voteBtnUp.setClick(()=>{e.comment.getActions().vote("up")}),e.opts.voteDown&&(e.voteBtnDown=new Gn(()=>`${A("voteDown")} (${e.data.vote_down||0})`).appendTo(e.$actions),e.voteBtnDown.setClick(()=>{e.comment.getActions().vote("down")})))}function Kn(e){if(!e.data.is_allow_reply)return;const t=new Gn({text:A("reply")});t.appendTo(e.$actions),t.setClick(()=>{e.opts.replyComment(e.data,e.$el)})}function Yn(e){const t=new Gn({text:()=>e.data.is_collapsed?A("expand"):A("collapse"),adminOnly:!0});t.appendTo(e.$actions),t.setClick(()=>{e.comment.getActions().adminEdit("collapsed",t)})}function Qn(e){const t=new Gn({text:()=>e.data.is_pending?A("pending"):A("approved"),adminOnly:!0});t.appendTo(e.$actions),t.setClick(()=>{e.comment.getActions().adminEdit("pending",t)})}function Xn(e){const t=new Gn({text:()=>e.data.is_pinned?A("unpin"):A("pin"),adminOnly:!0});t.appendTo(e.$actions),t.setClick(()=>{e.comment.getActions().adminEdit("pinned",t)})}function Jn(e){const t=new Gn({text:A("edit"),adminOnly:!0});t.appendTo(e.$actions),t.setClick(()=>{e.opts.editComment(e.data,e.$el)})}function Zn(e){const t=new Gn({text:A("delete"),confirm:!0,confirmText:A("deleteConfirm"),adminOnly:!0});t.appendTo(e.$actions),t.setClick(()=>{e.comment.getActions().adminDelete(t)})}var ei={Avatar:function(e){const t=e.$el.querySelector(".atk-avatar"),n=p("<img />"),i=e.opts.avatarURLBuilder;if(n.src=i?i(e.data):e.comment.getGravatarURL(),e.data.link){const i=p('<a target="_blank" rel="noreferrer noopener nofollow ugc"></a>');i.href=w(e.data.link)?e.data.link:`https://${e.data.link}`,i.append(n),t.append(i)}else t.append(n)},Header:function(e){Object.entries({renderNick:qn,renderVerifyBadge:Wn,renderDate:Hn,renderUABadge:zn}).forEach(([t,n])=>{n(e)})},Content:function(e){if(!e.data.is_collapsed)return e.$content.innerHTML=e.comment.getContentMarked(),void e.$content.classList.remove("atk-hide","atk-collapsed");e.$content.classList.add("atk-hide","atk-type-collapsed");const t=p(`\n <div class="atk-collapsed">\n <span class="atk-text">${A("collapsedMsg")}</span>\n <span class="atk-show-btn">${A("expand")}</span>\n </div>`);e.$body.insertAdjacentElement("beforeend",t);const n=t.querySelector(".atk-show-btn");n.addEventListener("click",t=>{t.stopPropagation(),e.$content.classList.contains("atk-hide")?(e.$content.innerHTML=e.comment.getContentMarked(),e.$content.classList.remove("atk-hide"),Gt(e.$content),n.innerText=A("collapse")):(e.$content.innerHTML="",e.$content.classList.add("atk-hide"),n.innerText=A("expand"))})},ReplyAt:function(e){e.opts.flatMode||0===e.data.rid||e.opts.replyTo&&(e.$replyAt=p('<span class="atk-item atk-reply-at"><span class="atk-arrow"></span><span class="atk-nick"></span></span>'),e.$replyAt.querySelector(".atk-nick").innerText=`${e.opts.replyTo.nick}`,e.$replyAt.onclick=()=>{e.comment.getActions().goToReplyComment()},e.$headerBadgeWrap.insertAdjacentElement("afterend",e.$replyAt))},ReplyTo:function(e){if(!e.opts.flatMode)return;if(!e.opts.replyTo)return;e.$replyTo=p(`\n <div class="atk-reply-to">\n <div class="atk-meta">${A("reply")} <span class="atk-nick"></span>:</div>\n <div class="atk-content"></div>\n </div>`);const t=e.$replyTo.querySelector(".atk-nick");t.innerText=`@${e.opts.replyTo.nick}`,t.onclick=()=>{e.comment.getActions().goToReplyComment()};let n=vt(e.opts.replyTo.content);e.opts.replyTo.is_collapsed&&(n=`[${A("collapsed")}]`),e.$replyTo.querySelector(".atk-content").innerHTML=n,e.$body.prepend(e.$replyTo)},Pending:function(e){if(!e.data.is_pending)return;const t=p(`<div class="atk-pending">${A("pendingMsg")}</div>`);e.$body.prepend(t)},Actions:function(e){Object.entries({renderVote:Vn,renderReply:Kn,renderCollapse:Yn,renderModerator:Qn,renderPin:Xn,renderEdit:Jn,renderDel:Zn}).forEach(([t,n])=>{n(e)})}};var ti=class{get data(){return this.comment.getData()}get opts(){return this.comment.getOpts()}constructor(e){ut(this,"comment",void 0),ut(this,"$el",void 0),ut(this,"$main",void 0),ut(this,"$header",void 0),ut(this,"$headerNick",void 0),ut(this,"$headerBadgeWrap",void 0),ut(this,"$body",void 0),ut(this,"$content",void 0),ut(this,"$childrenWrap",void 0),ut(this,"$actions",void 0),ut(this,"voteBtnUp",void 0),ut(this,"voteBtnDown",void 0),ut(this,"$replyTo",void 0),ut(this,"$replyAt",void 0),this.comment=e}render(){var e;return this.$el=p('<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-badge-wrap"></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.$el.setAttribute("id",`atk-comment-${this.data.id}`),e=this,Object.entries(ei).forEach(([t,n])=>{n(e)}),this.$childrenWrap&&this.$main.append(this.$childrenWrap),this.$el}checkHeightLimit(){const e=this.opts.heightLimit;if(!e||!e.content||!e.children)return;const t=e.content,n=e.children;Nn({afterExpandBtnClick:()=>{const e=this.comment.getChildren();1===e.length&&Bn(e[0].getRender().$content)},scrollable:e.scrollable},[{el:this.$content,max:t,imgCheck:!0},{el:this.$replyTo,max:t,imgCheck:!0},{el:this.$childrenWrap,max:n,imgCheck:!1}])}heightLimitRemoveForChildren(){this.$childrenWrap&&Bn(this.$childrenWrap)}playFadeAnim(){Gt(this.comment.getRender().$el)}playFadeAnimForBody(){Gt(this.comment.getRender().$body)}playFlashAnim(){this.$el.classList.remove("atk-flash-once"),window.setTimeout(()=>{this.$el.classList.add("atk-flash-once")},150)}getChildrenWrap(){return this.$childrenWrap||(this.$childrenWrap=p('<div class="atk-comment-children"></div>'),this.$main.append(this.$childrenWrap)),this.$childrenWrap}setUnread(e){e?this.$el.classList.add("atk-unread"):this.$el.classList.remove("atk-unread")}setOpenable(e){e?this.$el.classList.add("atk-openable"):this.$el.classList.remove("atk-openable")}setOpenURL(e){this.setOpenable(!0),this.$el.onclick=t=>{t.stopPropagation(),window.open(e)}}setOpenAction(e){this.setOpenable(!0),this.$el.onclick=t=>{t.stopPropagation(),e()}}},ni=class{get data(){return this.comment.getData()}get opts(){return this.comment.getOpts()}getApi(){return this.comment.getOpts().getApi()}constructor(e){ut(this,"comment",void 0),this.comment=e}vote(e){const t="up"===e?this.comment.getRender().voteBtnUp:this.comment.getRender().voteBtnDown;this.getApi().votes.createVote("comment",this.data.id,e,ht({},this.getApi().getUserFields())).then(e=>{var t,n;this.data.vote_up=e.data.up,this.data.vote_down=e.data.down,null===(t=this.comment.getRender().voteBtnUp)||void 0===t||t.updateText(),null===(n=this.comment.getRender().voteBtnDown)||void 0===n||n.updateText()}).catch(e=>{null==t||t.setError(A("voteFail")),console.error(e)})}adminEdit(e,t){if(t.isLoading)return;t.setLoading(!0,`${A("editing")}...`);const n=ht({},this.data);"collapsed"===e?n.is_collapsed=!n.is_collapsed:"pending"===e?n.is_pending=!n.is_pending:"pinned"===e&&(n.is_pinned=!n.is_pinned),this.getApi().comments.updateComment(this.data.id,ht({},n)).then(e=>{t.setLoading(!1),this.comment.setData(e.data)}).catch(e=>{console.error(e),t.setError(A("editFail"))})}adminDelete(e){e.isLoading||(e.setLoading(!0,`${A("deleting")}...`),this.getApi().comments.deleteComment(this.data.id).then(()=>{e.setLoading(!1),this.opts.onDelete&&this.opts.onDelete(this.comment)}).catch(t=>{console.error(t),e.setError(A("deleteFail"))}))}goToReplyComment(){const e=window.location.hash,t=`#atk-comment-${this.data.rid}`;window.location.hash=t,t===e&&window.dispatchEvent(new Event("hashchange"))}},ii=class{constructor(e,t){ut(this,"$el",void 0),ut(this,"renderInstance",void 0),ut(this,"actionInstance",void 0),ut(this,"data",void 0),ut(this,"opts",void 0),ut(this,"parent",void 0),ut(this,"children",[]),ut(this,"nestCurt",void 0),this.opts=t,this.data=ht({},e),this.data.date=this.data.date.replace(/-/g,"/"),this.parent=null,this.nestCurt=1,this.actionInstance=new ni(this),this.renderInstance=new ti(this)}render(){const e=this.renderInstance.render();this.$el&&this.$el.replaceWith(e),this.$el=e,this.opts.onAfterRender&&this.opts.onAfterRender()}getActions(){return this.actionInstance}getRender(){return this.renderInstance}getData(){return this.data}setData(e){this.data=e,this.render(),this.getRender().playFadeAnimForBody()}getParent(){return this.parent}getChildren(){return this.children}getNestCurt(){return this.nestCurt}getIsRoot(){return 0===this.data.rid}getID(){return this.data.id}putChild(e,t="append"){e.parent=this,e.nestCurt=this.nestCurt+1,this.children.push(e);const n=this.getChildrenWrapEl(),i=e.getEl();"append"===t?n.append(i):"prepend"===t&&n.prepend(i),e.getRender().playFadeAnim(),e.getRender().checkHeightLimit()}getChildrenWrapEl(){return this.nestCurt>=this.opts.nestMax?this.parent.getChildrenWrapEl():this.getRender().getChildrenWrap()}getParents(){const e=[];let t=this.parent;for(;t;)e.push(t),t=t.getParent();return e}getEl(){if(!this.$el)throw new Error("comment element not initialized before `getEl()`");return this.$el}focus(){if(!this.$el)throw new Error("comment element not initialized before `focus()`");this.getParents().forEach(e=>{e.getRender().heightLimitRemoveForChildren()}),this.scrollIntoView(),this.getRender().playFlashAnim()}scrollIntoView(){this.$el&&zt(this.$el,!1,this.opts.scrollRelativeTo&&this.opts.scrollRelativeTo())}remove(){var e;null===(e=this.$el)||void 0===e||e.remove()}getGravatarURL(){return`${(e={mirror:this.opts.gravatar.mirror,params:this.opts.gravatar.params,emailHash:this.data.email_encrypted}).mirror.replace(/\/$/,"")}/${e.emailHash}?${e.params.replace(/^\?/,"")}`;var e}getContentMarked(){return vt(this.data.content)}getDateFormatted(){var e,t;const n=new Date(this.data.date);return(null===(e=(t=this.opts).dateFormatter)||void 0===e?void 0:e.call(t,n))||v(n,A)}getUserUA(){const e=function(e){const t=window||{},n=navigator||{},i=String(e||n.userAgent),o={os:"",osVersion:"",engine:"",browser:"",device:"",language:"",version:""},s={Trident:i.includes("Trident")||i.includes("NET CLR"),Presto:i.includes("Presto"),WebKit:i.includes("AppleWebKit"),Gecko:i.includes("Gecko/")},r={Safari:i.includes("Safari"),Chrome:i.includes("Chrome")||i.includes("CriOS"),IE:i.includes("MSIE")||i.includes("Trident"),Edge:i.includes("Edge")||i.includes("Edg"),Firefox:i.includes("Firefox")||i.includes("FxiOS"),"Firefox Focus":i.includes("Focus"),Servo:i.includes("Servo"),Chromium:i.includes("Chromium"),Opera:i.includes("Opera")||i.includes("OPR"),Vivaldi:i.includes("Vivaldi"),Yandex:i.includes("YaBrowser"),Kindle:i.includes("Kindle")||i.includes("Silk/"),360:i.includes("360EE")||i.includes("360SE"),UC:i.includes("UC")||i.includes(" UBrowser"),QQBrowser:i.includes("QQBrowser"),QQ:i.includes("QQ/"),Baidu:i.includes("Baidu")||i.includes("BIDUBrowser"),Maxthon:i.includes("Maxthon"),Sogou:i.includes("MetaSr")||i.includes("Sogou"),LBBROWSER:i.includes("LBBROWSER"),"2345Explorer":i.includes("2345Explorer"),TheWorld:i.includes("TheWorld"),MIUI:i.includes("MiuiBrowser"),HuaweiBrowser:i.includes("HuaweiBrowser"),Quark:i.includes("Quark"),Qiyu:i.includes("Qiyu"),"360Browser":i.includes("360Browser"),Wechat:i.includes("MicroMessenger"),Taobao:i.includes("AliApp(TB"),Alipay:i.includes("AliApp(AP"),Weibo:i.includes("Weibo"),Douban:i.includes("com.douban.frodo"),Suning:i.includes("SNEBUY-APP"),iQiYi:i.includes("IqiyiApp")},a={Windows:i.includes("Windows"),Linux:i.includes("Linux")||i.includes("X11"),macOS:i.includes("Macintosh"),Android:i.includes("Android")||i.includes("Adr"),Ubuntu:i.includes("Ubuntu"),FreeBSD:i.includes("FreeBSD"),Debian:i.includes("Debian"),"Windows Phone":i.includes("IEMobile")||i.includes("Windows Phone"),BlackBerry:i.includes("BlackBerry")||i.includes("RIM"),MeeGo:i.includes("MeeGo"),Symbian:i.includes("Symbian"),iOS:i.includes("like Mac OS X"),OpenHarmony:i.includes("OpenHarmony"),"Chrome OS":i.includes("CrOS"),WebOS:i.includes("hpwOS")},l={Mobile:i.includes("Mobi")||i.includes("iPh")||i.includes("480")||i.includes("Phone"),Tablet:i.includes("Tablet")||i.includes("Pad")||i.includes("Nexus 7")};l.Mobile?l.Mobile=!i.includes("iPad"):r.Chrome&&i.includes("Edg")?(r.Chrome=!1,r.Edge=!0):t.showModalDialog&&t.chrome&&(r.Chrome=!1,r[360]=!0),o.device="PC",o.language=(()=>{const e=(n.browserLanguage||n.language).split("-");return e[1]&&(e[1]=e[1].toUpperCase()),e.join("_")})(),Object.entries({engine:s,browser:r,os:a,device:l}).forEach(([e,t])=>{Object.entries(t).forEach(([t,n])=>{!0===n&&(o[e]=t)})});const c={Windows:()=>{const e=i.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","10.0":"10","11.0":"11"}[e]||e},Android:()=>i.replace(/^.*Android ([\d.]+);.*$/,"$1"),iOS:()=>i.replace(/^.*OS ([\d_]+) like.*$/,"$1").replace(/_/g,"."),Debian:()=>i.replace(/^.*Debian\/([\d.]+).*$/,"$1"),"Windows Phone":()=>i.replace(/^.*Windows Phone( OS)? ([\d.]+);.*$/,"$2"),macOS:()=>i.replace(/^.*Mac OS X ([\d_]+).*$/,"$1").replace(/_/g,"."),OpenHarmony:()=>i.replace(/^.*OpenHarmony ([\d.]+).*$/,"$1"),WebOS:()=>i.replace(/^.*hpwOS\/([\d.]+);.*$/,"$1")};o.osVersion="",c[o.os]&&(o.osVersion=c[o.os](),o.osVersion===i&&(o.osVersion=""));const d={Safari:()=>i.replace(/^.*Version\/([\d.]+).*$/,"$1"),Chrome:()=>i.replace(/^.*Chrome\/([\d.]+).*$/,"$1").replace(/^.*CriOS\/([\d.]+).*$/,"$1"),IE:()=>i.replace(/^.*MSIE ([\d.]+).*$/,"$1").replace(/^.*rv:([\d.]+).*$/,"$1"),Edge:()=>i.replace(/^.*(Edge|Edg|Edg[A-Z]{1})\/([\d.]+).*$/,"$2"),Firefox:()=>i.replace(/^.*Firefox\/([\d.]+).*$/,"$1").replace(/^.*FxiOS\/([\d.]+).*$/,"$1"),"Firefox Focus":()=>i.replace(/^.*Focus\/([\d.]+).*$/,"$1"),Servo:()=>i.replace(/^.*Servo\/?([\d.]+).*$/,"$1"),Chromium:()=>i.replace(/^.*Chromium\/([\d.]+).*$/,"$1"),Opera:()=>i.replace(/^.*Opera\/([\d.]+).*$/,"$1").replace(/^.*OPR\/([\d.]+).*$/,"$1"),Vivaldi:()=>i.replace(/^.*Vivaldi\/([\d.]+).*$/,"$1"),Yandex:()=>i.replace(/^.*YaBrowser\/([\d.]+).*$/,"$1"),Kindle:()=>i.replace(/^.*Version\/([\d.]+).*$/,"$1"),Maxthon:()=>i.replace(/^.*Maxthon\/([\d.]+).*$/,"$1"),QQBrowser:()=>i.replace(/^.*QQBrowser\/([\d.]+).*$/,"$1"),QQ:()=>i.replace(/^.*QQ\/([\d.]+).*$/,"$1"),Baidu:()=>i.replace(/^.*BIDUBrowser[\s/]([\d.]+).*$/,"$1"),UC:()=>i.replace(/^.*UC?Browser\/([\d.]+).*$/,"$1"),Sogou:()=>i.replace(/^.*SE ([\d.X]+).*$/,"$1").replace(/^.*SogouMobileBrowser\/([\d.]+).*$/,"$1"),"2345Explorer":()=>i.replace(/^.*2345Explorer\/([\d.]+).*$/,"$1"),TheWorld:()=>i.replace(/^.*TheWorld ([\d.]+).*$/,"$1"),MIUI:()=>i.replace(/^.*MiuiBrowser\/([\d.]+).*$/,"$1"),HuaweiBrowser:()=>i.replace(/^.*HuaweiBrowser\/([\d.]+).*$/,"$1"),Quark:()=>i.replace(/^.*Quark\/([\d.]+).*$/,"$1"),Qiyu:()=>i.replace(/^.*Qiyu\/([\d.]+).*$/,"$1"),"360Browser":()=>i.replace(/^.*360Browser\/([\d.]+).*$/,"$1"),Wechat:()=>i.replace(/^.*MicroMessenger\/([\d.]+).*$/,"$1"),Taobao:()=>i.replace(/^.*AliApp\(TB\/([\d.]+).*$/,"$1"),Alipay:()=>i.replace(/^.*AliApp\(AP\/([\d.]+).*$/,"$1"),Weibo:()=>i.replace(/^.*weibo__([\d.]+).*$/,"$1"),Douban:()=>i.replace(/^.*com.douban.frodo\/([\d.]+).*$/,"$1"),Suning:()=>i.replace(/^.*SNEBUY-APP([\d.]+).*$/,"$1"),iQiYi:()=>i.replace(/^.*IqiyiVersion\/([\d.]+).*$/,"$1")};return o.version="",d[o.browser]&&(o.version=d[o.browser](),o.version===i&&(o.version="")),o.version.indexOf(".")&&(o.version=o.version.substring(0,o.version.indexOf("."))),"iOS"===o.os&&i.includes("iPad")?o.os="iPadOS":"Edge"!==o.browser||i.includes("Edg")?"MIUI"===o.browser?o.os="Android":"Chrome"===o.browser&&Number(o.version)>27||"Opera"===o.browser&&Number(o.version)>12||"Yandex"===o.browser?o.engine="Blink":void 0===o.browser&&(o.browser="Unknow App"):o.engine="EdgeHTML",o}(this.data.ua);return{browser:`${e.browser} ${e.version}`,os:`${e.os} ${e.osVersion}`}}getOpts(){return this.opts}};var oi=class{get hasMore(){return this.total>this.offset+this.opts.pageSize}constructor(e){ut(this,"opts",void 0),ut(this,"$el",void 0),ut(this,"$loading",void 0),ut(this,"$text",void 0),ut(this,"offset",0),ut(this,"total",0),ut(this,"origText","Load More"),this.opts=e,this.origText=this.opts.text||this.origText,this.$el=p(`<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">${this.origText}</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.hasMore&&this.opts.onClick(this.offset+this.opts.pageSize),this.checkDisabled()}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.origText,this.$el.classList.remove("atk-err")},2e3)}update(e,t){this.offset=e,this.total=t,this.checkDisabled()}checkDisabled(){this.hasMore?this.show():this.hide()}},si=class{constructor(){ut(this,"instance",void 0),ut(this,"onReachedBottom",null),ut(this,"opt",void 0)}create(e){return this.opt=e,this.instance=new oi({pageSize:e.pageSize,onClick:function(){var t=u(function*(t){e.getData().fetchComments({offset:t})});return function(e){return t.apply(this,arguments)}}(),text:A("loadMore")}),e.readMoreAutoLoad&&(this.onReachedBottom=()=>{this.instance.hasMore&&!this.opt.getData().getLoading()&&this.instance.click()},this.opt.getEvents().on("list-reach-bottom",this.onReachedBottom)),this.instance.$el}setLoading(e){this.instance.setLoading(e)}update(e,t){this.instance.update(e,t)}showErr(e){this.instance.showErr(e)}next(){this.instance.click()}getHasMore(){return this.instance.hasMore}getIsClearComments(e){return 0===e.offset}dispose(){this.onReachedBottom&&this.opt.getEvents().off("list-reach-bottom",this.onReachedBottom),this.instance.$el.remove()}},ri=class{get pageSize(){return this.opts.pageSize}get offset(){return this.pageSize*(this.page-1)}get maxPage(){return Math.ceil(this.total/this.pageSize)}constructor(e,t){ut(this,"opts",void 0),ut(this,"total",void 0),ut(this,"$el",void 0),ut(this,"$input",void 0),ut(this,"inputTimer",void 0),ut(this,"$prevBtn",void 0),ut(this,"$nextBtn",void 0),ut(this,"page",1),this.total=e,this.opts=t,this.$el=p('<div class="atk-pagination-wrap">\n <div class="atk-pagination">\n <div class="atk-btn atk-btn-prev" aria-label="Previous page">\n <svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 512 512" height="14px" width="14px" xmlns="http://www.w3.org/2000/svg"><path d="M217.9 256L345 129c9.4-9.4 9.4-24.6 0-33.9-9.4-9.4-24.6-9.3-34 0L167 239c-9.1 9.1-9.3 23.7-.7 33.1L310.9 417c4.7 4.7 10.9 7 17 7s12.3-2.3 17-7c9.4-9.4 9.4-24.6 0-33.9L217.9 256z"></path></svg>\n </div>\n <input type="text" class="atk-input" aria-label="Enter the number of page" />\n <div class="atk-btn atk-btn-next" aria-label="Next page">\n <svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 512 512" height="14px" width="14px" xmlns="http://www.w3.org/2000/svg"><path d="M294.1 256L167 129c-9.4-9.4-9.4-24.6 0-33.9s24.6-9.3 34 0L345 239c9.1 9.1 9.3 23.7.7 33.1L201.1 417c-4.7 4.7-10.9 7-17 7s-12.3-2.3-17-7c-9.4-9.4-9.4-24.6 0-33.9l127-127.1z"></path></svg>\n </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()}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(),n=()=>{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?n():this.inputTimer=window.setTimeout(()=>n(),800)}prev(){const e=this.page-1;e<1||this.change(e)}next(){const e=this.page+1;e>this.maxPage||this.change(e)}getHasMore(){return this.page+1<=this.maxPage}change(e){this.page=e,this.opts.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?qt(this.$el):Wt(this.$el)}},ai=class{constructor(){ut(this,"instance",void 0)}create(e){return this.instance=new ri(e.total,{pageSize:e.pageSize,onChange:function(){var t=u(function*(t){e.resetEditorState(),e.getData().fetchComments({offset:t,onSuccess:()=>{var t;null===(t=e.onListGotoFirst)||void 0===t||t.call(e)}})});return function(e){return t.apply(this,arguments)}}()}),this.instance.$el}setLoading(e){this.instance.setLoading(e)}update(e,t){this.instance.update(e,t)}next(){this.instance.next()}getHasMore(){return this.instance.getHasMore()}getIsClearComments(){return!0}dispose(){this.instance.$el.remove()}};function li(e){const t={offset:0,total:0};return e?(t.offset=e.params.offset,e.data&&(t.total=e.params.flatMode?e.data.count:e.data.roots_count),t):t}var ci=e=>{let t=null;e.getConf().watchConf(["pagination","locale"],n=>{const i=e.getList(),o=e.getData();t&&t.dispose(),t=function(e){return e.pagination.readMore?new si:new ai}(n);const{offset:s,total:r}=li(o.getListLastFetch()),a=t.create(ht({pageSize:n.pagination.pageSize,total:r,readMoreAutoLoad:n.pagination.autoLoad},e));i.getCommentsWrapEl().after(a),null==t||t.update(s,r)}),e.getEvents().on("list-loaded",n=>{const{offset:i,total:o}=li(e.getData().getListLastFetch());null==t||t.update(i,o)}),e.getEvents().on("list-fetch",n=>{e.getData().getComments().length>0&&(null==t?void 0:t.getIsClearComments(n))&&e.getData().clearComments()}),e.getEvents().on("list-failed",()=>{var e;null==t||null===(e=t.showErr)||void 0===e||e.call(t,A("loadFail"))}),e.getEvents().on("list-fetch",e=>{null==t||t.setLoading(!0)}),e.getEvents().on("list-fetched",({params:e})=>{null==t||t.setLoading(!1)})},di=class{getEl(){return this.$el}getCommentsWrapEl(){return this.$commentsWrap}getCommentNodes(){return this.commentNodes}constructor(e){ut(this,"opts",void 0),ut(this,"$el",void 0),ut(this,"$commentsWrap",void 0),ut(this,"commentNodes",[]),this.opts=e,this.$el=p('<div class="atk-list">\n <div class="atk-list-header">\n <div class="atk-comment-count">\n <div class="atk-text"></div>\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">\n <div class="atk-list-comments-wrap"></div>\n </div>\n <div class="atk-list-footer">\n <div class="atk-copyright"></div>\n </div>\n</div>\n'),this.$commentsWrap=this.$el.querySelector(".atk-list-comments-wrap"),ci(ht({getList:()=>this},e)),this.initCrudEvents()}getLayout({forceFlatMode:e}={}){return new Un({$commentsWrap:this.$commentsWrap,nestSortBy:this.opts.getConf().get().nestSort,nestMax:this.opts.getConf().get().nestMax,flatMode:"boolean"==typeof e?e:this.opts.getConf().get().flatMode,createCommentNode:(t,n)=>{const i=function(e,t,n){const i=e.getConf().get(),o=new ii(t,{onAfterRender:()=>{e.getEvents().trigger("comment-rendered",o)},onDelete:t=>{e.getData().deleteComment(t.getID())},replyTo:n,flatMode:"boolean"==typeof(null==e?void 0:e.forceFlatMode)?null==e?void 0:e.forceFlatMode:i.flatMode,gravatar:i.gravatar,nestMax:i.nestMax,heightLimit:i.heightLimit,avatarURLBuilder:i.avatarURLBuilder,scrollRelativeTo:i.scrollRelativeTo,vote:i.vote,voteDown:i.voteDown,uaBadge:i.uaBadge,dateFormatter:i.dateFormatter,getApi:e.getApi,replyComment:e.replyComment,editComment:e.editComment});return o.render(),o}(ht({forceFlatMode:e},this.opts),t,n);return this.commentNodes.push(i),i},findCommentNode:e=>this.commentNodes.find(t=>t.getID()===e)})}initCrudEvents(){this.opts.getEvents().on("list-load",e=>{this.getLayout().import(e)}),this.opts.getEvents().on("list-loaded",e=>{0===e.length&&(this.commentNodes=[],this.$commentsWrap.innerHTML="")}),this.opts.getEvents().on("comment-inserted",e=>{var t;const n=e.rid?null===(t=this.commentNodes.find(t=>t.getID()===e.rid))||void 0===t?void 0:t.getData():void 0;this.getLayout().insert(e,n)}),this.opts.getEvents().on("comment-deleted",e=>{const t=this.commentNodes.find(t=>t.getID()===e.id);t?(t.remove(),this.commentNodes=this.commentNodes.filter(t=>t.getID()!==e.id)):console.error(`comment node id=${e.id} not found`)}),this.opts.getEvents().on("comment-updated",e=>{const t=this.commentNodes.find(t=>t.getID()===e.id);t&&t.setData(e)})}},ui=class{constructor(e){ut(this,"opts",void 0),ut(this,"$el",void 0),ut(this,"layer",void 0),ut(this,"$header",void 0),ut(this,"$closeBtn",void 0),ut(this,"$iframeWrap",void 0),ut(this,"$iframe",void 0),ut(this,"refreshWhenShow",!0),ut(this,"animTimer",void 0),this.opts=e,this.$el=p('<div class="atk-sidebar-layer">\n <div class="atk-sidebar-inner">\n <div class="atk-sidebar-header">\n <div class="atk-sidebar-close">\n <i class="atk-icon atk-icon-close-slim"></i>\n </div>\n </div>\n <div class="atk-sidebar-iframe-wrap"></div>\n </div>\n</div>\n'),this.$header=this.$el.querySelector(".atk-sidebar-header"),this.$closeBtn=this.$header.querySelector(".atk-sidebar-close"),this.$iframeWrap=this.$el.querySelector(".atk-sidebar-iframe-wrap"),this.$closeBtn.onclick=()=>{this.hide()}}onUserChanged(){var e=this;return u(function*(){e.refreshWhenShow=!0})()}show(){var e=this;return u(function*(t={}){if(e.$el.style.transform="",e.initLayer(),e.layer.show(),e.refreshWhenShow)e.refreshWhenShow=!1,e.$iframeWrap.innerHTML="",e.$iframe=e.createIframe(t.view),e.$iframeWrap.append(e.$iframe);else{const t=e.$iframe,n=t.src;e.getDarkMode()!==n.includes("&darkMode=1")&&e.iframeLoad(t,n.replace(/&darkMode=\d/,`&darkMode=${Number(e.getDarkMode())}`))}e.authCheck({onSuccess:()=>e.show(t)}),e.animTimer=setTimeout(()=>{var t,n;e.animTimer=void 0,e.$el.style.transform="translate(0, 0)",null===(t=(n=e.opts).onShow)||void 0===t||t.call(n)},100)}).apply(this,arguments)}hide(){var e;null===(e=this.layer)||void 0===e||e.hide()}authCheck(e){var t=this;return u(function*(){const n=(yield t.opts.getApi().user.getUserStatus(ht({},t.opts.getApi().getUserFields()))).data;n.is_admin&&!n.is_login&&(t.refreshWhenShow=!0,t.opts.getCheckers().checkAdmin({onSuccess:()=>{setTimeout(()=>{e.onSuccess()},500)},onCancel:()=>{t.hide()}}),t.hide())})()}initLayer(){this.layer||(this.layer=this.opts.getLayers().create("sidebar",this.$el),this.layer.setOnAfterHide(()=>{var e,t;this.animTimer&&clearTimeout(this.animTimer),this.$el.style.transform="",null===(e=(t=this.opts).onHide)||void 0===e||e.call(t)}))}createIframe(e){var t,n;const i=p('<iframe referrerpolicy="strict-origin-when-cross-origin"></iframe>'),o=$({base:this.opts.getConf().get().server,path:"/sidebar/"}),{name:s,email:r,link:a,is_admin:l,token:c}=this.opts.getUser().getData(),d={pageKey:this.opts.getConf().get().pageKey,site:this.opts.getConf().get().site||"",user:JSON.stringify({name:s,email:r,link:a,is_admin:l}),time:+new Date};e&&(d.view=e),d.darkMode=this.getDarkMode()?"1":"0";const u=new URLSearchParams(d),h=new URLSearchParams;c&&h.set("token",c);const m=null===(t=(n=this.opts.getUser()).getGuestToken)||void 0===t?void 0:t.call(n,this.opts.getConf().get().server);m&&h.set("guest_token",m);const g=h.size?`#${h.toString()}`:"";return this.iframeLoad(i,`${o}?${u.toString()}${g}`),i}getDarkMode(){return"auto"===this.opts.getConf().get().darkMode?window.matchMedia("(prefers-color-scheme: dark)").matches:this.opts.getConf().get().darkMode}iframeLoad(e,t){e.src=t,qt(this.$iframeWrap),e.onload=()=>{Wt(this.$iframeWrap)}}},pi=new Set([e=>{e.provide("data",e=>new On(e),["events"]),e.on("mounted",()=>{e.getConf().fetchCommentsOnInit&&e.getData().fetchComments({offset:0})})},e=>{e.provide("apiHandlers",()=>function(){const e=[];return{add:(t,n)=>{e.push({action:t,handler:n})},remove:t=>{const n=e.findIndex(e=>e.action===t);-1!==n&&e.splice(n,1)},get:()=>e}}(),[]),e.provide("api",(e,t,n)=>new Rt(bt(t.get(),e,n)),["user","config","apiHandlers"],{lifecycle:"transient"})},e=>{e.watchConf(["locale"],e=>{var t;(t=e.locale)!==S&&(S=t,T="string"==typeof t?C(t):t)})},e=>{e.provide("user",()=>new yn({onUserChanged:t=>{e.trigger("user-changed",t)}}),[])},e=>{e.provide("editor",(t,n)=>{const i=new Ln({getEvents:()=>t,getConf:()=>n});return e.getEl().appendChild(i.getEl()),i},["events","config"])},e=>{e.provide("list",(t,n,i,o,s)=>{const r=new di({getApi:()=>t,getEvents:()=>n,getConf:()=>i,getData:()=>o,replyComment:(e,t)=>s.setReplyComment(e,t),editComment:(e,t)=>s.setEditComment(e,t),resetEditorState:()=>s.resetState(),onListGotoFirst:()=>e.listGotoFirst()});return e.getEl().appendChild(r.getEl()),r},["api","events","config","data","editor"])},e=>{e.provide("checkers",(t,n,i,o,s)=>{const r=new Cn({getApi:()=>t,getLayers:()=>i,getUser:()=>o,onReload:()=>e.reload(),getCaptchaIframeURL:()=>`${s.get().server}/api/v2/captcha/?t=${+new Date}`});return n.add("need_captcha",e=>r.checkCaptcha(e)),n.add("need_login",()=>r.checkAdmin({})),r},["api","apiHandlers","layers","user","config"])},e=>{e.provide("layers",()=>{const t=new _n;return document.body.appendChild(t.getEl()),e.on("unmounted",()=>{null==t||t.destroy()}),t})},e=>{e.provide("sidebar",(t,n,i,o,s,r,a,l)=>{const c=new ui({onShow:()=>{setTimeout(()=>{n.updateNotifies([])},0),t.trigger("sidebar-show")},onHide:()=>{i.resetState(),t.trigger("sidebar-hide")},getCheckers:()=>o,getApi:()=>s,getConf:()=>r,getUser:()=>a,getLayers:()=>l});return e.on("user-changed",()=>{null==c||c.onUserChanged()}),c},["events","data","editor","checkers","api","config","user","layers"])}]),hi=[...pi,e=>{e.watchConf(["imgLazyLoad","markedOptions"],e=>{!function(e){try{if(!t.Marked.name)return}catch(i){return}const n=new t.Marked;n.setOptions(ht(ht({renderer:ot({imgLazyLoad:e.imgLazyLoad})},gt),e.markedOptions)),st=n}({markedOptions:e.markedOptions,imgLazyLoad:e.imgLazyLoad})}),e.watchConf(["markedReplacers"],e=>{var t;e.markedReplacers&&(t=e.markedReplacers,mt=t)})},e=>{e.provide("editorPlugs",(t,n,i,o,s,r)=>{const a=new tn({getArtalkRootEl:()=>e.getEl(),getEditor:()=>t,getConf:()=>n,getUser:()=>i,getApi:()=>r,getData:()=>o,getCheckers:()=>s,onSubmitted:()=>e.trigger("editor-submitted")});return t.setPlugins(a),a},["editor","config","user","data","checkers","api"])},e=>{const t=e.inject("user"),n=()=>{var n;n=t.getData().is_admin,function(e){const t=[];e.$root.querySelectorAll("[atk-only-admin-show]").forEach(e=>t.push(e));const n=document.querySelector(".atk-sidebar");return n&&n.querySelectorAll("[atk-only-admin-show]").forEach(e=>t.push(e)),t}({$root:e.getEl()}).forEach(e=>{n?e.classList.remove("atk-hide"):e.classList.add("atk-hide")})};e.on("list-loaded",()=>{n()}),e.on("user-changed",e=>{n()})},...sn,e=>{e.on("list-fetch",t=>{if(0!==t.offset)return;const n=e.getApi().getUserFields();n&&e.getApi().notifies.getNotifies(n).then(t=>{e.getData().updateNotifies(t.data.notifies)})})},e=>{e.watchConf(["site","pageKey","pageTitle","countEl","pvEl","statPageKeyAttr","pvAdd"],t=>{Et({getApi:()=>e.getApi(),siteName:t.site,pageKey:t.pageKey,pageTitle:t.pageTitle,countEl:t.countEl,pvEl:t.pvEl,pageKeyAttr:t.statPageKeyAttr,pvAdd:t.pvAdd})})},e=>{const t=e.inject("list");e.watchConf(["apiVersion","versionCheck"],e=>{e.apiVersion&&e.versionCheck&&!rn&&function(e,t,n){const i=function(e,t){const n=e.split("."),i=t.split(".");for(let o=0;o<3;o++){const e=Number(n[o]),t=Number(i[o]);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,n);if(0===i)return;const o=p(`<div class="atk-version-check-notice">${A("updateMsg",{name:A(i<0?"client":"server")})} <span class="atk-info">${A("currentVersion")}: ${A("client")} ${t} / ${A("server")} ${n}</span></div>`),s=p(`<span class="atk-ignore-btn">${A("ignore")}</span>`);s.onclick=()=>{o.remove(),rn=!0},o.append(s),e.getEl().parentElement.prepend(o)}(t,nn,e.apiVersion)})},e=>{const t=e.inject("config"),n=e.inject("layers");let i;const o=t=>{const o=[e.getEl(),n.getEl()];an||(an=window.matchMedia("(prefers-color-scheme: dark)")),"auto"===t?(i||(i=e=>ln(o,e.matches),an.addEventListener("change",i)),ln(o,an.matches)):(i&&(an.removeEventListener("change",i),i=void 0),ln(o,t))};e.watchConf(["darkMode"],e=>o(e.darkMode)),e.on("created",()=>o(t.get().darkMode)),e.on("unmounted",()=>{i&&(null==an||an.removeEventListener("change",i)),i=void 0})},e=>{const t=e.inject("config");let n,i={};e.watchConf(["pageVote"],e=>{const t=ht(ht({},cn),"object"==typeof e.pageVote?e.pageVote:{});null==n||n(),e.pageVote&&(i=function(e,t,n,i){var o,s;const r=ht({},e);return r.upBtnEl=document.querySelector(t.upBtnEl),r.downBtnEl=document.querySelector(t.downBtnEl),r.upCountEl=document.querySelector(t.upCountEl),r.downCountEl=document.querySelector(t.downCountEl),r.activeClass=t.activeClass,r.voteUpHandler=n,r.voteDownHandler=i,null===(o=r.upBtnEl)||void 0===o||o.addEventListener("click",n),null===(s=r.downBtnEl)||void 0===s||s.addEventListener("click",i),r}(i,t,a,l),n=()=>i=function(e){var t,n;return e.voteUpHandler&&(null===(t=e.upBtnEl)||void 0===t||t.removeEventListener("click",e.voteUpHandler)),e.voteDownHandler&&(null===(n=e.downBtnEl)||void 0===n||n.removeEventListener("click",e.voteDownHandler)),{}}(i))}),e.on("unmounted",()=>{null==n||n(),e.off("list-fetched",s)}),e.on("list-fetched",s);let o=0;function s({data:n}){t.get().pageVote&&function(e){return e.upBtnEl||e.downBtnEl||e.upCountEl||e.downCountEl}(i)&&n&&(o!==n.page.id?(o=n.page.id,dn(i,n.page.vote_up,n.page.vote_down,!1,!1),function(e,t,n){n.votes.getVote("page",t).then(({data:t})=>{dn(e,t.up,t.down,t.is_up,t.is_down)}).catch(e=>{console.error("[ArtalkPageVote]",e)})}(i,o,e.getApi())):dn(i,n.page.vote_up,n.page.vote_down))}const r=()=>{var t;return{state:i,pageId:(null===(t=e.getData().getPage())||void 0===t?void 0:t.id)||0,httpApi:e.getApi()}},a=un("up",r),l=un("down",r)}],mi=new Set([...hi]),gi=new WeakMap;function fi(e,t){return vi.apply(this,arguments)}function vi(){return vi=u(function*(e,t){var n;if(t.isDestroyed())return;const i=new Set,o=e=>{e.forEach(e=>{"function"==typeof e&&(i.has(e)||(e(t,gi.get(e)),i.add(e)))})};o(pi);const s=yield t.getApi().conf.conf().catch(n=>{if(t.isDestroyed())return null;throw((e,t={})=>{var n;const i=e.inject("list"),o=e.inject("user"),s=e.inject("config"),r=t.err;if(!r)throw new Error("MountError: `err` is required");let a="";if(null===(n=r.data)||void 0===n?void 0:n.err_no_site){const e={create_name:s.get().site,create_urls:`${window.location.protocol}//${window.location.host}`};a=`sites|${JSON.stringify(e)}`}on({$err:i.getEl(),errMsg:r.msg||String(r),errData:r.data,retryFn:()=>{var e;return null===(e=t.onRetry)||void 0===e?void 0:e.call(t)},onOpenSidebar:o.getData().is_admin?()=>e.showSidebar({view:a}):void 0})})(t,{err:n,onRetry:()=>fi(e,t)}),n});if(!s||t.isDestroyed())return;const{data:r}=s;let a=ht(ht({},e),{},{apiVersion:null===(n=r.version)||void 0===n?void 0:n.version});const l=function(e){const t=["el","pageKey","pageTitle","server","site","pvEl","countEl","statPageKeyAttr","pageVote"];return Object.keys(e).forEach(n=>{t.includes(n)&&delete e[n],"darkMode"===n&&"auto"!==e[n]&&delete e[n]}),e.emoticons&&"string"==typeof e.emoticons&&(e.emoticons=e.emoticons.trim(),e.emoticons.startsWith("[")||e.emoticons.startsWith("{")?e.emoticons=JSON.parse(e.emoticons):"false"===e.emoticons&&(e.emoticons=!1)),e}(r.frontend_conf||{});a=a.preferRemoteConf?kt(a,l):kt(l,a),t.updateConf(a);let c=new Set;a.pluginURLs&&(c=yield function(e,t){return yi.apply(this,arguments)}(a.pluginURLs,t.getConf().server).catch(e=>(console.error("Failed to load plugin",e),new Set))),t.isDestroyed()||(o(mi),o(c))}),vi.apply(this,arguments)}function yi(){return(yi=u(function*(e,t){const n=new Set;if(!e||!Array.isArray(e))return n;const i=[];return e.forEach(e=>{/^(http|https):\/\//.test(e)||(e=`${t.replace(/\/$/,"")}/${e.replace(/^\//,"")}`),i.push(new Promise(t=>{if(document.querySelector(`script[src="${e}"]`))return void t();const n=document.createElement("script");n.src=e,document.head.appendChild(n),n.onload=()=>t(),n.onerror=e=>{console.error("[artalk] Failed to load plugin",e),t()}}))}),yield Promise.all(i),Object.values(window.ArtalkPlugins||{}).forEach(e=>{"function"==typeof e&&n.add(e)}),n})).apply(this,arguments)}function ki({keys:e,effect:t,getConf:n,getEvents:i}){let o=null;const s=()=>{const i=(()=>{const t=n(),i={};return e.forEach(e=>{i[e]=t[e]}),i})();var s,r;null!=o&&(s=o,r=i,JSON.stringify(s)===JSON.stringify(r))||(o=i,t(i))};i().on("mounted",s),i().on("updated",s)}var wi=class e{constructor(e){ut(this,"ctx",void 0);const t=function(e){let t;if("string"==typeof e.el){const n=document.querySelector(e.el);if(!n)throw new Error(`Element "${e.el}" not found.`);t=n}else{if(!(e.el instanceof HTMLElement))throw new Error("Please provide a valid `el` config for Artalk.");t=e.el}return t}(e);t.classList.add("artalk"),t.innerHTML="",1==e.darkMode&&t.classList.add("atk-dark-mode");const n=this.ctx=new yt(t);(e=>{e.provide("events",()=>new en)})(n),(e=>{let t=$t({},!0);e.provide("config",e=>{let n=!1;return e.on("mounted",()=>n=!0),{watchConf:(n,i)=>{ki({keys:n,effect:i,getConf:()=>t,getEvents:()=>e})},get:()=>t,update:i=>{t=kt(t,$t(i,!1)),n&&e.trigger("updated",t)}}},["events"])})(n),n.updateConf(e),function(){var t=u(function*(){yield fi(e,n),n.isDestroyed()||(n.trigger("created"),n.trigger("mounted"))});return function(){return t.apply(this,arguments)}}()()}getConf(){return this.ctx.getConf()}getEl(){return this.ctx.getEl()}update(e){this.ctx.updateConf(e)}reload(){this.ctx.reload()}destroy(){this.ctx.destroy()}on(e,t){this.ctx.on(e,t)}off(e,t){this.ctx.off(e,t)}trigger(e,t){this.ctx.trigger(e,t)}setDarkMode(e){this.ctx.setDarkMode(e)}static init(t){return new e(t)}static use(e,t){mi.add(e),gi.set(e,t)}static loadCountWidget(e){const t=$t(e,!0);Et({getApi:()=>new Rt(bt(t)),siteName:t.site,countEl:t.countEl,pvEl:t.pvEl,pageKeyAttr:t.statPageKeyAttr,pvAdd:!1})}get $root(){return console.warn("`$root` is deprecated, please use `getEl()` instead"),this.getEl()}get conf(){return console.warn("`conf` is deprecated, please use `getConf()` instead"),this.getConf()}},$i=wi,bi=wi.init,Ei=wi.use,Ci=wi.loadCountWidget;e.Defaults=wt,e.default=$i,e.init=bi,e.loadCountWidget=Ci,e.use=Ei});
|
|
2
|
+
//# sourceMappingURL=ArtalkLite.js.map
|