artalk 2.9.0 → 2.10.0
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 -9412
- 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 +3329 -0
- package/dist/ArtalkLite.d.ts +3329 -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 -7351
- 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 +575 -421
- package/dist/main.d.ts +575 -421
- package/package.json +48 -48
package/dist/Artalk.cjs
CHANGED
|
@@ -1,11 +1,2 @@
|
|
|
1
|
-
"use strict";var e=Object.defineProperty,t=Object.defineProperties,n=Object.getOwnPropertyDescriptors,s=Object.getOwnPropertySymbols,i=Object.prototype.hasOwnProperty,r=Object.prototype.propertyIsEnumerable,o=(t,n,s)=>n in t?e(t,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[n]=s,a=(e,t)=>{for(var n in t||(t={}))i.call(t,n)&&o(e,n,t[n]);if(s)for(var n of s(t))r.call(t,n)&&o(e,n,t[n]);return e},l=(e,s)=>t(e,n(s)),c=(e,t,n)=>o(e,"symbol"!=typeof t?t+"":t,n),d=(e,t,n)=>new Promise(((s,i)=>{var r=e=>{try{a(n.next(e))}catch(t){i(t)}},o=e=>{try{a(n.throw(e))}catch(t){i(t)}},a=e=>e.done?s(e.value):Promise.resolve(e.value).then(r,o);a((n=n.apply(e,t)).next())}));Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});class h{constructor(e={}){c(this,"baseUrl","/api/v2"),c(this,"securityData",null),c(this,"securityWorker"),c(this,"abortControllers",new Map),c(this,"customFetch",((...e)=>fetch(...e))),c(this,"baseApiParams",{credentials:"same-origin",headers:{},redirect:"follow",referrerPolicy:"no-referrer"}),c(this,"setSecurityData",(e=>{this.securityData=e})),c(this,"contentFormatters",{"application/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=>Object.keys(e||{}).reduce(((t,n)=>{const s=e[n];return t.append(n,s instanceof Blob?s:"object"==typeof s&&null!==s?JSON.stringify(s):`${s}`),t}),new FormData),"application/x-www-form-urlencoded":e=>this.toQueryString(e)}),c(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})),c(this,"abortRequest",(e=>{const t=this.abortControllers.get(e);t&&(t.abort(),this.abortControllers.delete(e))})),c(this,"request",(e=>d(this,null,(function*(){var t=e,{body:n,secure:o,path:c,type:h,query:u,format:p,baseUrl:g,cancelToken:m}=t,f=((e,t)=>{var n={};for(var o in e)i.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&s)for(var o of s(e))t.indexOf(o)<0&&r.call(e,o)&&(n[o]=e[o]);return n})(t,["body","secure","path","type","query","format","baseUrl","cancelToken"]);const k=("boolean"==typeof o?o:this.baseApiParams.secure)&&this.securityWorker&&(yield this.securityWorker(this.securityData))||{},y=this.mergeRequestParams(f,k),$=u&&this.toQueryString(u),v=this.contentFormatters[h||"application/json"],w=p||y.format;return this.customFetch(`${g||this.baseUrl||""}${c}${$?`?${$}`:""}`,l(a({},y),{headers:a(a({},y.headers||{}),h&&"multipart/form-data"!==h?{"Content-Type":h}:{}),signal:(m?this.createAbortSignal(m):y.signal)||null,body:null==n?null:v(n)})).then((e=>d(this,null,(function*(){const t=e.clone();t.data=null,t.error=null;const n=w?yield e[w]().then((e=>(t.ok?t.data=e:t.error=e,t))).catch((e=>(t.error=e,t))):t;if(m&&this.abortControllers.delete(m),!e.ok)throw n;return n}))))})))),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 l(a(a(a({},this.baseApiParams),e),t||{}),{headers:a(a(a({},this.baseApiParams.headers||{}),e.headers||{}),t&&t.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 u=class extends h{constructor(){super(...arguments),c(this,"auth",{loginByEmail:(e,t={})=>this.request(a({path:"/auth/email/login",method:"POST",body:e,type:"application/json",format:"json"},t)),registerByEmail:(e,t={})=>this.request(a({path:"/auth/email/register",method:"POST",body:e,type:"application/json",format:"json"},t)),sendVerifyEmail:(e,t={})=>this.request(a({path:"/auth/email/send",method:"POST",body:e,type:"application/json",format:"json"},t)),checkDataMerge:(e={})=>this.request(a({path:"/auth/merge",method:"GET",secure:!0,format:"json"},e)),applyDataMerge:(e,t={})=>this.request(a({path:"/auth/merge",method:"POST",body:e,secure:!0,type:"application/json",format:"json"},t))}),c(this,"cache",{flushCache:(e={})=>this.request(a({path:"/cache/flush",method:"POST",secure:!0,format:"json"},e)),warmUpCache:(e={})=>this.request(a({path:"/cache/warm_up",method:"POST",secure:!0,format:"json"},e))}),c(this,"captcha",{getCaptcha:(e={})=>this.request(a({path:"/captcha",method:"GET",format:"json"},e)),getCaptchaStatus:(e={})=>this.request(a({path:"/captcha/status",method:"GET",format:"json"},e)),verifyCaptcha:(e,t={})=>this.request(a({path:"/captcha/verify",method:"POST",body:e,type:"application/json",format:"json"},t))}),c(this,"comments",{getComments:(e,t={})=>this.request(a({path:"/comments",method:"GET",query:e,secure:!0,type:"application/json",format:"json"},t)),createComment:(e,t={})=>this.request(a({path:"/comments",method:"POST",body:e,secure:!0,type:"application/json",format:"json"},t)),getComment:(e,t={})=>this.request(a({path:`/comments/${e}`,method:"GET",type:"application/json",format:"json"},t)),updateComment:(e,t,n={})=>this.request(a({path:`/comments/${e}`,method:"PUT",body:t,secure:!0,type:"application/json",format:"json"},n)),deleteComment:(e,t={})=>this.request(a({path:`/comments/${e}`,method:"DELETE",secure:!0,format:"json"},t))}),c(this,"conf",{conf:(e={})=>this.request(a({path:"/conf",method:"GET",format:"json"},e)),getSocialLoginProviders:(e={})=>this.request(a({path:"/conf/auth/providers",method:"GET",format:"json"},e)),getDomain:(e,t={})=>this.request(a({path:"/conf/domain",method:"GET",query:e,format:"json"},t))}),c(this,"notifies",{getNotifies:(e,t={})=>this.request(a({path:"/notifies",method:"GET",query:e,type:"application/json",format:"json"},t)),markAllNotifyRead:(e,t={})=>this.request(a({path:"/notifies/read",method:"POST",body:e,type:"application/json",format:"json"},t)),markNotifyRead:(e,t,n={})=>this.request(a({path:`/notifies/${e}/${t}`,method:"POST",format:"json"},n))}),c(this,"pages",{getPages:(e,t={})=>this.request(a({path:"/pages",method:"GET",query:e,secure:!0,type:"application/json",format:"json"},t)),fetchAllPages:(e,t={})=>this.request(a({path:"/pages/fetch",method:"POST",body:e,secure:!0,type:"application/json",format:"json"},t)),getPageFetchStatus:(e={})=>this.request(a({path:"/pages/fetch/status",method:"GET",secure:!0,format:"json"},e)),logPv:(e,t={})=>this.request(a({path:"/pages/pv",method:"POST",body:e,type:"application/json",format:"json"},t)),updatePage:(e,t,n={})=>this.request(a({path:`/pages/${e}`,method:"PUT",body:t,secure:!0,type:"application/json",format:"json"},n)),deletePage:(e,t={})=>this.request(a({path:`/pages/${e}`,method:"DELETE",secure:!0,format:"json"},t)),fetchPage:(e,t={})=>this.request(a({path:`/pages/${e}/fetch`,method:"POST",secure:!0,type:"application/json",format:"json"},t))}),c(this,"sendEmail",{sendEmail:(e,t={})=>this.request(a({path:"/send_email",method:"POST",body:e,secure:!0,type:"application/json",format:"json"},t))}),c(this,"settings",{getSettings:(e={})=>this.request(a({path:"/settings",method:"GET",secure:!0,format:"json"},e)),applySettings:(e,t={})=>this.request(a({path:"/settings",method:"PUT",body:e,secure:!0,type:"application/json",format:"json"},t)),getSettingsTemplate:(e,t={})=>this.request(a({path:`/settings/template/${e}`,method:"GET",secure:!0,format:"json"},t))}),c(this,"sites",{getSites:(e={})=>this.request(a({path:"/sites",method:"GET",secure:!0,format:"json"},e)),createSite:(e,t={})=>this.request(a({path:"/sites",method:"POST",body:e,secure:!0,type:"application/json",format:"json"},t)),updateSite:(e,t,n={})=>this.request(a({path:`/sites/${e}`,method:"PUT",body:t,secure:!0,type:"application/json",format:"json"},n)),deleteSite:(e,t={})=>this.request(a({path:`/sites/${e}`,method:"DELETE",secure:!0,format:"json"},t))}),c(this,"stats",{getStats:(e,t,n={})=>this.request(a({path:`/stats/${e}`,method:"GET",query:t,type:"application/json",format:"json"},n))}),c(this,"transfer",{exportArtrans:(e={})=>this.request(a({path:"/transfer/export",method:"GET",secure:!0,format:"json"},e)),importArtrans:(e,t={})=>this.request(a({path:"/transfer/import",method:"POST",body:e,secure:!0,type:"application/json"},t)),uploadArtrans:(e,t={})=>this.request(a({path:"/transfer/upload",method:"POST",body:e,secure:!0,type:"multipart/form-data",format:"json"},t))}),c(this,"upload",{upload:(e,t={})=>this.request(a({path:"/upload",method:"POST",body:e,secure:!0,type:"multipart/form-data",format:"json"},t))}),c(this,"user",{getUser:(e,t={})=>this.request(a({path:"/user",method:"GET",query:e,secure:!0,format:"json"},t)),updateProfile:(e,t={})=>this.request(a({path:"/user",method:"POST",body:e,secure:!0,type:"application/json",format:"json"},t)),login:(e,t={})=>this.request(a({path:"/user/access_token",method:"POST",body:e,type:"application/json",format:"json"},t)),getUserStatus:(e,t={})=>this.request(a({path:"/user/status",method:"GET",query:e,secure:!0,format:"json"},t))}),c(this,"users",{createUser:(e,t={})=>this.request(a({path:"/users",method:"POST",body:e,secure:!0,type:"application/json",format:"json"},t)),updateUser:(e,t,n={})=>this.request(a({path:`/users/${e}`,method:"PUT",body:t,secure:!0,type:"application/json",format:"json"},n)),deleteUser:(e,t={})=>this.request(a({path:`/users/${e}`,method:"DELETE",secure:!0,format:"json"},t)),getUsers:(e,t,n={})=>this.request(a({path:`/users/${e}`,method:"GET",query:t,secure:!0,type:"application/json",format:"json"},n))}),c(this,"version",{getVersion:(e={})=>this.request(a({path:"/version",method:"GET",format:"json"},e))}),c(this,"votes",{syncVotes:(e={})=>this.request(a({path:"/votes/sync",method:"POST",secure:!0,format:"json"},e)),vote:(e,t,n,s={})=>this.request(a({path:`/votes/${e}/${t}`,method:"POST",body:n,type:"application/json",format:"json"},s))})}};const p=(e,t,n)=>d(exports,null,(function*(){const s=e.getApiToken&&e.getApiToken(),i=new Headers(a({Authorization:s?`Bearer ${s}`:""},null==n?void 0:n.headers));i.get("Authorization")||i.delete("Authorization");const r=yield fetch(t,l(a({},n),{headers:i}));if(!r.ok){const s=(yield r.json().catch((()=>{})))||{};let i=!1;if(e.handlers&&(yield e.handlers.get().reduce(((e,t)=>d(exports,null,(function*(){yield e,!0===s[t.action]&&(yield t.handler(s),i=!0)}))),Promise.resolve())),i)return p(e,t,n);throw function(e,t){const n=new g;return n.message=t.msg||t.message||"fetch error",n.code=e,n.data=t,console.error(n),n}(r.status,s)}return r}));class g extends Error{constructor(){super(...arguments),c(this,"code",0),c(this,"message","fetch error"),c(this,"data")}}class m extends u{constructor(e){super({baseUrl:e.baseURL,customFetch:(t,n)=>p(e,t,n)}),c(this,"_opts"),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}}}function f(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}let k={async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null};function y(e){k=e}const $=/[&<>"']/,v=new RegExp($.source,"g"),w=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,b=new RegExp(w.source,"g"),x={"&":"&","<":"<",">":">",'"':""","'":"'"},C=e=>x[e];function E(e,t){if(t){if($.test(e))return e.replace(v,C)}else if(w.test(e))return e.replace(b,C);return e}const S=/(^|[^\[])\^/g;function T(e,t){let n="string"==typeof e?e:e.source;t=t||"";const s={replace:(e,t)=>{let i="string"==typeof t?t:t.source;return i=i.replace(S,"$1"),n=n.replace(e,i),s},getRegex:()=>new RegExp(n,t)};return s}function A(e){try{e=encodeURI(e).replace(/%25/g,"%")}catch(t){return null}return e}const L={exec:()=>null};function M(e,t){const n=e.replace(/\|/g,((e,t,n)=>{let s=!1,i=t;for(;--i>=0&&"\\"===n[i];)s=!s;return s?"|":" |"})).split(/ \|/);let s=0;if(n[0].trim()||n.shift(),n.length>0&&!n[n.length-1].trim()&&n.pop(),t)if(n.length>t)n.splice(t);else for(;n.length<t;)n.push("");for(;s<n.length;s++)n[s]=n[s].trim().replace(/\\\|/g,"|");return n}function P(e,t,n){const s=e.length;if(0===s)return"";let i=0;for(;i<s;){const r=e.charAt(s-i-1);if(r!==t||n){if(r===t||!n)break;i++}else i++}return e.slice(0,s-i)}function I(e,t,n,s){const i=t.href,r=t.title?E(t.title):null,o=e[1].replace(/\\([\[\]])/g,"$1");if("!"!==e[0].charAt(0)){s.state.inLink=!0;const e={type:"link",raw:n,href:i,title:r,text:o,tokens:s.inlineTokens(o)};return s.state.inLink=!1,e}return{type:"image",raw:n,href:i,title:r,text:E(o)}}class R{constructor(e){c(this,"options"),c(this,"rules"),c(this,"lexer"),this.options=e||k}space(e){const t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){const t=this.rules.block.code.exec(e);if(t){const e=t[0].replace(/^ {1,4}/gm,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?e:P(e,"\n")}}}fences(e){const t=this.rules.block.fences.exec(e);if(t){const e=t[0],n=function(e,t){const n=e.match(/^(\s+)(?:```)/);if(null===n)return t;const s=n[1];return t.split("\n").map((e=>{const t=e.match(/^\s+/);if(null===t)return e;const[n]=t;return n.length>=s.length?e.slice(s.length):e})).join("\n")}(e,t[3]||"");return{type:"code",raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:n}}}heading(e){const t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(/#$/.test(e)){const t=P(e,"#");this.options.pedantic?e=t.trim():t&&!/ $/.test(t)||(e=t.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){const t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:P(t[0],"\n")}}blockquote(e){const t=this.rules.block.blockquote.exec(e);if(t){let e=P(t[0],"\n").split("\n"),n="",s="";const i=[];for(;e.length>0;){let t=!1;const r=[];let o;for(o=0;o<e.length;o++)if(/^ {0,3}>/.test(e[o]))r.push(e[o]),t=!0;else{if(t)break;r.push(e[o])}e=e.slice(o);const a=r.join("\n"),l=a.replace(/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,"\n $1").replace(/^ {0,3}>[ \t]?/gm,"");n=n?`${n}\n${a}`:a,s=s?`${s}\n${l}`:l;const c=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(l,i,!0),this.lexer.state.top=c,0===e.length)break;const d=i[i.length-1];if("code"===(null==d?void 0:d.type))break;if("blockquote"===(null==d?void 0:d.type)){const t=d,r=t.raw+"\n"+e.join("\n"),o=this.blockquote(r);i[i.length-1]=o,n=n.substring(0,n.length-t.raw.length)+o.raw,s=s.substring(0,s.length-t.text.length)+o.text;break}if("list"!==(null==d?void 0:d.type));else{const t=d,r=t.raw+"\n"+e.join("\n"),o=this.list(r);i[i.length-1]=o,n=n.substring(0,n.length-d.raw.length)+o.raw,s=s.substring(0,s.length-t.raw.length)+o.raw,e=r.substring(i[i.length-1].raw.length).split("\n")}}return{type:"blockquote",raw:n,tokens:i,text:s}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim();const s=n.length>1,i={type:"list",raw:"",ordered:s,start:s?+n.slice(0,-1):"",loose:!1,items:[]};n=s?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=s?n:"[*+-]");const r=new RegExp(`^( {0,3}${n})((?:[\t ][^\\n]*)?(?:\\n|$))`);let o=!1;for(;e;){let n=!1,s="",a="";if(!(t=r.exec(e)))break;if(this.rules.block.hr.test(e))break;s=t[0],e=e.substring(s.length);let l=t[2].split("\n",1)[0].replace(/^\t+/,(e=>" ".repeat(3*e.length))),c=e.split("\n",1)[0],d=!l.trim(),h=0;if(this.options.pedantic?(h=2,a=l.trimStart()):d?h=t[1].length+1:(h=t[2].search(/[^ ]/),h=h>4?1:h,a=l.slice(h),h+=t[1].length),d&&/^ *$/.test(c)&&(s+=c+"\n",e=e.substring(c.length+1),n=!0),!n){const t=new RegExp(`^ {0,${Math.min(3,h-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ \t][^\\n]*)?(?:\\n|$))`),n=new RegExp(`^ {0,${Math.min(3,h-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),i=new RegExp(`^ {0,${Math.min(3,h-1)}}(?:\`\`\`|~~~)`),r=new RegExp(`^ {0,${Math.min(3,h-1)}}#`);for(;e;){const o=e.split("\n",1)[0];if(c=o,this.options.pedantic&&(c=c.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),i.test(c))break;if(r.test(c))break;if(t.test(c))break;if(n.test(e))break;if(c.search(/[^ ]/)>=h||!c.trim())a+="\n"+c.slice(h);else{if(d)break;if(l.search(/[^ ]/)>=4)break;if(i.test(l))break;if(r.test(l))break;if(n.test(l))break;a+="\n"+c}d||c.trim()||(d=!0),s+=o+"\n",e=e.substring(o.length+1),l=c.slice(h)}}i.loose||(o?i.loose=!0:/\n *\n *$/.test(s)&&(o=!0));let u,p=null;this.options.gfm&&(p=/^\[[ xX]\] /.exec(a),p&&(u="[ ] "!==p[0],a=a.replace(/^\[[ xX]\] +/,""))),i.items.push({type:"list_item",raw:s,task:!!p,checked:u,loose:!1,text:a,tokens:[]}),i.raw+=s}i.items[i.items.length-1].raw=i.items[i.items.length-1].raw.trimEnd(),i.items[i.items.length-1].text=i.items[i.items.length-1].text.trimEnd(),i.raw=i.raw.trimEnd();for(let e=0;e<i.items.length;e++)if(this.lexer.state.top=!1,i.items[e].tokens=this.lexer.blockTokens(i.items[e].text,[]),!i.loose){const t=i.items[e].tokens.filter((e=>"space"===e.type)),n=t.length>0&&t.some((e=>/\n.*\n/.test(e.raw)));i.loose=n}if(i.loose)for(let e=0;e<i.items.length;e++)i.items[e].loose=!0;return i}}html(e){const t=this.rules.block.html.exec(e);if(t){return{type:"html",block:!0,raw:t[0],pre:"pre"===t[1]||"script"===t[1]||"style"===t[1],text:t[0]}}}def(e){const t=this.rules.block.def.exec(e);if(t){const e=t[1].toLowerCase().replace(/\s+/g," "),n=t[2]?t[2].replace(/^<(.*)>$/,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",s=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:e,raw:t[0],href:n,title:s}}}table(e){const t=this.rules.block.table.exec(e);if(!t)return;if(!/[:|]/.test(t[2]))return;const n=M(t[1]),s=t[2].replace(/^\||\| *$/g,"").split("|"),i=t[3]&&t[3].trim()?t[3].replace(/\n[ \t]*$/,"").split("\n"):[],r={type:"table",raw:t[0],header:[],align:[],rows:[]};if(n.length===s.length){for(const e of s)/^ *-+: *$/.test(e)?r.align.push("right"):/^ *:-+: *$/.test(e)?r.align.push("center"):/^ *:-+ *$/.test(e)?r.align.push("left"):r.align.push(null);for(let e=0;e<n.length;e++)r.header.push({text:n[e],tokens:this.lexer.inline(n[e]),header:!0,align:r.align[e]});for(const e of i)r.rows.push(M(e,r.header.length).map(((e,t)=>({text:e,tokens:this.lexer.inline(e),header:!1,align:r.align[t]}))));return r}}lheading(e){const t=this.rules.block.lheading.exec(e);if(t)return{type:"heading",raw:t[0],depth:"="===t[2].charAt(0)?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){const t=this.rules.block.paragraph.exec(e);if(t){const e="\n"===t[1].charAt(t[1].length-1)?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){const t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){const t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:E(t[1])}}tag(e){const t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&/^<a /i.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&/^<\/a>/i.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){const t=this.rules.inline.link.exec(e);if(t){const e=t[2].trim();if(!this.options.pedantic&&/^</.test(e)){if(!/>$/.test(e))return;const t=P(e.slice(0,-1),"\\");if((e.length-t.length)%2==0)return}else{const e=function(e,t){if(-1===e.indexOf(t[1]))return-1;let n=0;for(let s=0;s<e.length;s++)if("\\"===e[s])s++;else if(e[s]===t[0])n++;else if(e[s]===t[1]&&(n--,n<0))return s;return-1}(t[2],"()");if(e>-1){const n=(0===t[0].indexOf("!")?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,n).trim(),t[3]=""}}let n=t[2],s="";if(this.options.pedantic){const e=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(n);e&&(n=e[1],s=e[3])}else s=t[3]?t[3].slice(1,-1):"";return n=n.trim(),/^</.test(n)&&(n=this.options.pedantic&&!/>$/.test(e)?n.slice(1):n.slice(1,-1)),I(t,{href:n?n.replace(this.rules.inline.anyPunctuation,"$1"):n,title:s?s.replace(this.rules.inline.anyPunctuation,"$1"):s},t[0],this.lexer)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){const e=t[(n[2]||n[1]).replace(/\s+/g," ").toLowerCase()];if(!e){const e=n[0].charAt(0);return{type:"text",raw:e,text:e}}return I(n,e,n[0],this.lexer)}}emStrong(e,t,n=""){let s=this.rules.inline.emStrongLDelim.exec(e);if(!s)return;if(s[3]&&n.match(/[\p{L}\p{N}]/u))return;if(!(s[1]||s[2]||"")||!n||this.rules.inline.punctuation.exec(n)){const n=[...s[0]].length-1;let i,r,o=n,a=0;const l="*"===s[0][0]?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(l.lastIndex=0,t=t.slice(-1*e.length+n);null!=(s=l.exec(t));){if(i=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!i)continue;if(r=[...i].length,s[3]||s[4]){o+=r;continue}if((s[5]||s[6])&&n%3&&!((n+r)%3)){a+=r;continue}if(o-=r,o>0)continue;r=Math.min(r,r+o+a);const t=[...s[0]][0].length,l=e.slice(0,n+s.index+t+r);if(Math.min(n,r)%2){const e=l.slice(1,-1);return{type:"em",raw:l,text:e,tokens:this.lexer.inlineTokens(e)}}const c=l.slice(2,-2);return{type:"strong",raw:l,text:c,tokens:this.lexer.inlineTokens(c)}}}}codespan(e){const t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(/\n/g," ");const n=/[^ ]/.test(e),s=/^ /.test(e)&&/ $/.test(e);return n&&s&&(e=e.substring(1,e.length-1)),e=E(e,!0),{type:"codespan",raw:t[0],text:e}}}br(e){const t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e){const t=this.rules.inline.del.exec(e);if(t)return{type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e){const t=this.rules.inline.autolink.exec(e);if(t){let e,n;return"@"===t[2]?(e=E(t[1]),n="mailto:"+e):(e=E(t[1]),n=e),{type:"link",raw:t[0],text:e,href:n,tokens:[{type:"text",raw:e,text:e}]}}}url(e){var t,n;let s;if(s=this.rules.inline.url.exec(e)){let e,i;if("@"===s[2])e=E(s[0]),i="mailto:"+e;else{let r;do{r=s[0],s[0]=null!=(n=null==(t=this.rules.inline._backpedal.exec(s[0]))?void 0:t[0])?n:""}while(r!==s[0]);e=E(s[0]),i="www."===s[1]?"http://"+s[0]:s[0]}return{type:"link",raw:s[0],text:e,href:i,tokens:[{type:"text",raw:e,text:e}]}}}inlineText(e){const t=this.rules.inline.text.exec(e);if(t){let e;return e=this.lexer.state.inRawBlock?t[0]:E(t[0]),{type:"text",raw:t[0],text:e}}}}const U=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,q=/(?:[*+-]|\d{1,9}[.)])/,_=T(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g,q).replace(/blockCode/g,/ {4}/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).getRegex(),O=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,D=/(?!\s*\])(?:\\.|[^\[\]\\])+/,B=T(/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/).replace("label",D).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),j=T(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,q).getRegex(),F="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",W=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,z=T("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n *)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))","i").replace("comment",W).replace("tag",F).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),N=T(O).replace("hr",U).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",F).getRegex(),H={blockquote:T(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",N).getRegex(),code:/^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,def:B,fences:/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,hr:U,html:z,lheading:_,list:j,newline:/^(?: *(?:\n|$))+/,paragraph:N,table:L,text:/^[^\n]+/},Q=T("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",U).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",F).getRegex(),V=l(a({},H),{table:Q,paragraph:T(O).replace("hr",U).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Q).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",F).getRegex()}),G=l(a({},H),{html:T("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:\"[^\"]*\"|'[^']*'|\\s[^'\"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment",W).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:L,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:T(O).replace("hr",U).replace("heading"," *#{1,6} *[^\n]").replace("lheading",_).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()}),K=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Z=/^( {2,}|\\)\n(?!\s*$)/,Y="\\p{P}\\p{S}",X=T(/^((?![*_])[\spunctuation])/,"u").replace(/punctuation/g,Y).getRegex(),J=T(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/,"u").replace(/punct/g,Y).getRegex(),ee=T("^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)[punct](\\*+)(?=[\\s]|$)|[^punct\\s](\\*+)(?!\\*)(?=[punct\\s]|$)|(?!\\*)[punct\\s](\\*+)(?=[^punct\\s])|[\\s](\\*+)(?!\\*)(?=[punct])|(?!\\*)[punct](\\*+)(?!\\*)(?=[punct])|[^punct\\s](\\*+)(?=[^punct\\s])","gu").replace(/punct/g,Y).getRegex(),te=T("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\\s]|$)|[^punct\\s](_+)(?!_)(?=[punct\\s]|$)|(?!_)[punct\\s](_+)(?=[^punct\\s])|[\\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])","gu").replace(/punct/g,Y).getRegex(),ne=T(/\\([punct])/,"gu").replace(/punct/g,Y).getRegex(),se=T(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),ie=T(W).replace("(?:--\x3e|$)","--\x3e").getRegex(),re=T("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",ie).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),oe=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,ae=T(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label",oe).replace("href",/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),le=T(/^!?\[(label)\]\[(ref)\]/).replace("label",oe).replace("ref",D).getRegex(),ce=T(/^!?\[(ref)\](?:\[\])?/).replace("ref",D).getRegex(),de={_backpedal:L,anyPunctuation:ne,autolink:se,blockSkip:/\[[^[\]]*?\]\([^\(\)]*?\)|`[^`]*?`|<[^<>]*?>/g,br:Z,code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,del:L,emStrongLDelim:J,emStrongRDelimAst:ee,emStrongRDelimUnd:te,escape:K,link:ae,nolink:ce,punctuation:X,reflink:le,reflinkSearch:T("reflink|nolink(?!\\()","g").replace("reflink",le).replace("nolink",ce).getRegex(),tag:re,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,url:L},he=l(a({},de),{link:T(/^!?\[(label)\]\((.*?)\)/).replace("label",oe).getRegex(),reflink:T(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",oe).getRegex()}),ue=l(a({},de),{escape:T(K).replace("])","~|])").getRegex(),url:T(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,"i").replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/}),pe=l(a({},ue),{br:T(Z).replace("{2,}","*").getRegex(),text:T(ue.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()}),ge={normal:H,gfm:V,pedantic:G},me={normal:de,gfm:ue,breaks:pe,pedantic:he};class fe{constructor(e){c(this,"tokens"),c(this,"options"),c(this,"state"),c(this,"tokenizer"),c(this,"inlineQueue"),this.tokens=[],this.tokens.links=Object.create(null),this.options=e||k,this.options.tokenizer=this.options.tokenizer||new R,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const t={block:ge.normal,inline:me.normal};this.options.pedantic?(t.block=ge.pedantic,t.inline=me.pedantic):this.options.gfm&&(t.block=ge.gfm,this.options.breaks?t.inline=me.breaks:t.inline=me.gfm),this.tokenizer.rules=t}static get rules(){return{block:ge,inline:me}}static lex(e,t){return new fe(t).lex(e)}static lexInline(e,t){return new fe(t).inlineTokens(e)}lex(e){e=e.replace(/\r\n|\r/g,"\n"),this.blockTokens(e,this.tokens);for(let t=0;t<this.inlineQueue.length;t++){const e=this.inlineQueue[t];this.inlineTokens(e.src,e.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],n=!1){let s,i,r;for(e=this.options.pedantic?e.replace(/\t/g," ").replace(/^ +$/gm,""):e.replace(/^( *)(\t+)/gm,((e,t,n)=>t+" ".repeat(n.length)));e;)if(!(this.options.extensions&&this.options.extensions.block&&this.options.extensions.block.some((n=>!!(s=n.call({lexer:this},e,t))&&(e=e.substring(s.raw.length),t.push(s),!0)))))if(s=this.tokenizer.space(e))e=e.substring(s.raw.length),1===s.raw.length&&t.length>0?t[t.length-1].raw+="\n":t.push(s);else if(s=this.tokenizer.code(e))e=e.substring(s.raw.length),i=t[t.length-1],!i||"paragraph"!==i.type&&"text"!==i.type?t.push(s):(i.raw+="\n"+s.raw,i.text+="\n"+s.text,this.inlineQueue[this.inlineQueue.length-1].src=i.text);else if(s=this.tokenizer.fences(e))e=e.substring(s.raw.length),t.push(s);else if(s=this.tokenizer.heading(e))e=e.substring(s.raw.length),t.push(s);else if(s=this.tokenizer.hr(e))e=e.substring(s.raw.length),t.push(s);else if(s=this.tokenizer.blockquote(e))e=e.substring(s.raw.length),t.push(s);else if(s=this.tokenizer.list(e))e=e.substring(s.raw.length),t.push(s);else if(s=this.tokenizer.html(e))e=e.substring(s.raw.length),t.push(s);else if(s=this.tokenizer.def(e))e=e.substring(s.raw.length),i=t[t.length-1],!i||"paragraph"!==i.type&&"text"!==i.type?this.tokens.links[s.tag]||(this.tokens.links[s.tag]={href:s.href,title:s.title}):(i.raw+="\n"+s.raw,i.text+="\n"+s.raw,this.inlineQueue[this.inlineQueue.length-1].src=i.text);else if(s=this.tokenizer.table(e))e=e.substring(s.raw.length),t.push(s);else if(s=this.tokenizer.lheading(e))e=e.substring(s.raw.length),t.push(s);else{if(r=e,this.options.extensions&&this.options.extensions.startBlock){let t=1/0;const n=e.slice(1);let s;this.options.extensions.startBlock.forEach((e=>{s=e.call({lexer:this},n),"number"==typeof s&&s>=0&&(t=Math.min(t,s))})),t<1/0&&t>=0&&(r=e.substring(0,t+1))}if(this.state.top&&(s=this.tokenizer.paragraph(r)))i=t[t.length-1],n&&"paragraph"===(null==i?void 0:i.type)?(i.raw+="\n"+s.raw,i.text+="\n"+s.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=i.text):t.push(s),n=r.length!==e.length,e=e.substring(s.raw.length);else if(s=this.tokenizer.text(e))e=e.substring(s.raw.length),i=t[t.length-1],i&&"text"===i.type?(i.raw+="\n"+s.raw,i.text+="\n"+s.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=i.text):t.push(s);else if(e){const t="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw new Error(t)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let n,s,i,r,o,a,l=e;if(this.tokens.links){const e=Object.keys(this.tokens.links);if(e.length>0)for(;null!=(r=this.tokenizer.rules.inline.reflinkSearch.exec(l));)e.includes(r[0].slice(r[0].lastIndexOf("[")+1,-1))&&(l=l.slice(0,r.index)+"["+"a".repeat(r[0].length-2)+"]"+l.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;null!=(r=this.tokenizer.rules.inline.blockSkip.exec(l));)l=l.slice(0,r.index)+"["+"a".repeat(r[0].length-2)+"]"+l.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;null!=(r=this.tokenizer.rules.inline.anyPunctuation.exec(l));)l=l.slice(0,r.index)+"++"+l.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;e;)if(o||(a=""),o=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some((s=>!!(n=s.call({lexer:this},e,t))&&(e=e.substring(n.raw.length),t.push(n),!0)))))if(n=this.tokenizer.escape(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.tag(e))e=e.substring(n.raw.length),s=t[t.length-1],s&&"text"===n.type&&"text"===s.type?(s.raw+=n.raw,s.text+=n.text):t.push(n);else if(n=this.tokenizer.link(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.reflink(e,this.tokens.links))e=e.substring(n.raw.length),s=t[t.length-1],s&&"text"===n.type&&"text"===s.type?(s.raw+=n.raw,s.text+=n.text):t.push(n);else if(n=this.tokenizer.emStrong(e,l,a))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.codespan(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.br(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.del(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.autolink(e))e=e.substring(n.raw.length),t.push(n);else if(this.state.inLink||!(n=this.tokenizer.url(e))){if(i=e,this.options.extensions&&this.options.extensions.startInline){let t=1/0;const n=e.slice(1);let s;this.options.extensions.startInline.forEach((e=>{s=e.call({lexer:this},n),"number"==typeof s&&s>=0&&(t=Math.min(t,s))})),t<1/0&&t>=0&&(i=e.substring(0,t+1))}if(n=this.tokenizer.inlineText(i))e=e.substring(n.raw.length),"_"!==n.raw.slice(-1)&&(a=n.raw.slice(-1)),o=!0,s=t[t.length-1],s&&"text"===s.type?(s.raw+=n.raw,s.text+=n.text):t.push(n);else if(e){const t="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw new Error(t)}}else e=e.substring(n.raw.length),t.push(n);return t}}class ke{constructor(e){c(this,"options"),c(this,"parser"),this.options=e||k}space(e){return""}code({text:e,lang:t,escaped:n}){var s;const i=null==(s=(t||"").match(/^\S*/))?void 0:s[0],r=e.replace(/\n$/,"")+"\n";return i?'<pre><code class="language-'+E(i)+'">'+(n?r:E(r,!0))+"</code></pre>\n":"<pre><code>"+(n?r:E(r,!0))+"</code></pre>\n"}blockquote({tokens:e}){return`<blockquote>\n${this.parser.parse(e)}</blockquote>\n`}html({text:e}){return e}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>\n`}hr(e){return"<hr>\n"}list(e){const t=e.ordered,n=e.start;let s="";for(let r=0;r<e.items.length;r++){const t=e.items[r];s+=this.listitem(t)}const i=t?"ol":"ul";return"<"+i+(t&&1!==n?' start="'+n+'"':"")+">\n"+s+"</"+i+">\n"}listitem(e){let t="";if(e.task){const n=this.checkbox({checked:!!e.checked});e.loose?e.tokens.length>0&&"paragraph"===e.tokens[0].type?(e.tokens[0].text=n+" "+e.tokens[0].text,e.tokens[0].tokens&&e.tokens[0].tokens.length>0&&"text"===e.tokens[0].tokens[0].type&&(e.tokens[0].tokens[0].text=n+" "+e.tokens[0].tokens[0].text)):e.tokens.unshift({type:"text",raw:n+" ",text:n+" "}):t+=n+" "}return t+=this.parser.parse(e.tokens,!!e.loose),`<li>${t}</li>\n`}checkbox({checked:e}){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox">'}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>\n`}table(e){let t="",n="";for(let i=0;i<e.header.length;i++)n+=this.tablecell(e.header[i]);t+=this.tablerow({text:n});let s="";for(let i=0;i<e.rows.length;i++){const t=e.rows[i];n="";for(let e=0;e<t.length;e++)n+=this.tablecell(t[e]);s+=this.tablerow({text:n})}return s&&(s=`<tbody>${s}</tbody>`),"<table>\n<thead>\n"+t+"</thead>\n"+s+"</table>\n"}tablerow({text:e}){return`<tr>\n${e}</tr>\n`}tablecell(e){const t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>\n`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${e}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){const s=this.parser.parseInline(n),i=A(e);if(null===i)return s;let r='<a href="'+(e=i)+'"';return t&&(r+=' title="'+t+'"'),r+=">"+s+"</a>",r}image({href:e,title:t,text:n}){const s=A(e);if(null===s)return n;let i=`<img src="${e=s}" alt="${n}"`;return t&&(i+=` title="${t}"`),i+=">",i}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):e.text}}class ye{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}}class $e{constructor(e){c(this,"options"),c(this,"renderer"),c(this,"textRenderer"),this.options=e||k,this.options.renderer=this.options.renderer||new ke,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new ye}static parse(e,t){return new $e(t).parse(e)}static parseInline(e,t){return new $e(t).parseInline(e)}parse(e,t=!0){let n="";for(let s=0;s<e.length;s++){const i=e[s];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[i.type]){const e=i,t=this.options.extensions.renderers[e.type].call({parser:this},e);if(!1!==t||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(e.type)){n+=t||"";continue}}const r=i;switch(r.type){case"space":n+=this.renderer.space(r);continue;case"hr":n+=this.renderer.hr(r);continue;case"heading":n+=this.renderer.heading(r);continue;case"code":n+=this.renderer.code(r);continue;case"table":n+=this.renderer.table(r);continue;case"blockquote":n+=this.renderer.blockquote(r);continue;case"list":n+=this.renderer.list(r);continue;case"html":n+=this.renderer.html(r);continue;case"paragraph":n+=this.renderer.paragraph(r);continue;case"text":{let i=r,o=this.renderer.text(i);for(;s+1<e.length&&"text"===e[s+1].type;)i=e[++s],o+="\n"+this.renderer.text(i);n+=t?this.renderer.paragraph({type:"paragraph",raw:o,text:o,tokens:[{type:"text",raw:o,text:o}]}):o;continue}default:{const e='Token with "'+r.type+'" type was not found.';if(this.options.silent)return console.error(e),"";throw new Error(e)}}}return n}parseInline(e,t){t=t||this.renderer;let n="";for(let s=0;s<e.length;s++){const i=e[s];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[i.type]){const e=this.options.extensions.renderers[i.type].call({parser:this},i);if(!1!==e||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(i.type)){n+=e||"";continue}}const r=i;switch(r.type){case"escape":case"text":n+=t.text(r);break;case"html":n+=t.html(r);break;case"link":n+=t.link(r);break;case"image":n+=t.image(r);break;case"strong":n+=t.strong(r);break;case"em":n+=t.em(r);break;case"codespan":n+=t.codespan(r);break;case"br":n+=t.br(r);break;case"del":n+=t.del(r);break;default:{const e='Token with "'+r.type+'" type was not found.';if(this.options.silent)return console.error(e),"";throw new Error(e)}}}return n}}class ve{constructor(e){c(this,"options"),c(this,"block"),this.options=e||k}preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}provideLexer(){return this.block?fe.lex:fe.lexInline}provideParser(){return this.block?$e.parse:$e.parseInline}}c(ve,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens"]));class we{constructor(...e){c(this,"defaults",{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}),c(this,"options",this.setOptions),c(this,"parse",this.parseMarkdown(!0)),c(this,"parseInline",this.parseMarkdown(!1)),c(this,"Parser",$e),c(this,"Renderer",ke),c(this,"TextRenderer",ye),c(this,"Lexer",fe),c(this,"Tokenizer",R),c(this,"Hooks",ve),this.use(...e)}walkTokens(e,t){var n,s;let i=[];for(const r of e)switch(i=i.concat(t.call(this,r)),r.type){case"table":{const e=r;for(const n of e.header)i=i.concat(this.walkTokens(n.tokens,t));for(const n of e.rows)for(const e of n)i=i.concat(this.walkTokens(e.tokens,t));break}case"list":{const e=r;i=i.concat(this.walkTokens(e.items,t));break}default:{const e=r;(null==(s=null==(n=this.defaults.extensions)?void 0:n.childTokens)?void 0:s[e.type])?this.defaults.extensions.childTokens[e.type].forEach((n=>{const s=e[n].flat(1/0);i=i.concat(this.walkTokens(s,t))})):e.tokens&&(i=i.concat(this.walkTokens(e.tokens,t)))}}return i}use(...e){const t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach((e=>{const n=a({},e);if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach((e=>{if(!e.name)throw new Error("extension name required");if("renderer"in e){const n=t.renderers[e.name];t.renderers[e.name]=n?function(...t){let s=e.renderer.apply(this,t);return!1===s&&(s=n.apply(this,t)),s}:e.renderer}if("tokenizer"in e){if(!e.level||"block"!==e.level&&"inline"!==e.level)throw new Error("extension level must be 'block' or 'inline'");const n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&("block"===e.level?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:"inline"===e.level&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}"childTokens"in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)})),n.extensions=t),e.renderer){const t=this.defaults.renderer||new ke(this.defaults);for(const n in e.renderer){if(!(n in t))throw new Error(`renderer '${n}' does not exist`);if(["options","parser"].includes(n))continue;const s=n,i=e.renderer[s],r=t[s];t[s]=(...e)=>{let n=i.apply(t,e);return!1===n&&(n=r.apply(t,e)),n||""}}n.renderer=t}if(e.tokenizer){const t=this.defaults.tokenizer||new R(this.defaults);for(const n in e.tokenizer){if(!(n in t))throw new Error(`tokenizer '${n}' does not exist`);if(["options","rules","lexer"].includes(n))continue;const s=n,i=e.tokenizer[s],r=t[s];t[s]=(...e)=>{let n=i.apply(t,e);return!1===n&&(n=r.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){const t=this.defaults.hooks||new ve;for(const n in e.hooks){if(!(n in t))throw new Error(`hook '${n}' does not exist`);if(["options","block"].includes(n))continue;const s=n,i=e.hooks[s],r=t[s];ve.passThroughHooks.has(n)?t[s]=e=>{if(this.defaults.async)return Promise.resolve(i.call(t,e)).then((e=>r.call(t,e)));const n=i.call(t,e);return r.call(t,n)}:t[s]=(...e)=>{let n=i.apply(t,e);return!1===n&&(n=r.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){const t=this.defaults.walkTokens,s=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(s.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults=a(a({},this.defaults),n)})),this}setOptions(e){return this.defaults=a(a({},this.defaults),e),this}lexer(e,t){return fe.lex(e,null!=t?t:this.defaults)}parser(e,t){return $e.parse(e,null!=t?t:this.defaults)}parseMarkdown(e){return(t,n)=>{const s=a({},n),i=a(a({},this.defaults),s),r=this.onError(!!i.silent,!!i.async);if(!0===this.defaults.async&&!1===s.async)return r(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(null==t)return r(new Error("marked(): input parameter is undefined or null"));if("string"!=typeof t)return r(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));i.hooks&&(i.hooks.options=i,i.hooks.block=e);const o=i.hooks?i.hooks.provideLexer():e?fe.lex:fe.lexInline,l=i.hooks?i.hooks.provideParser():e?$e.parse:$e.parseInline;if(i.async)return Promise.resolve(i.hooks?i.hooks.preprocess(t):t).then((e=>o(e,i))).then((e=>i.hooks?i.hooks.processAllTokens(e):e)).then((e=>i.walkTokens?Promise.all(this.walkTokens(e,i.walkTokens)).then((()=>e)):e)).then((e=>l(e,i))).then((e=>i.hooks?i.hooks.postprocess(e):e)).catch(r);try{i.hooks&&(t=i.hooks.preprocess(t));let e=o(t,i);i.hooks&&(e=i.hooks.processAllTokens(e)),i.walkTokens&&this.walkTokens(e,i.walkTokens);let n=l(e,i);return i.hooks&&(n=i.hooks.postprocess(n)),n}catch(c){return r(c)}}}onError(e,t){return n=>{if(n.message+="\nPlease report this to https://github.com/markedjs/marked.",e){const e="<p>An error occurred:</p><pre>"+E(n.message+"",!0)+"</pre>";return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}}const be=new we;function xe(e,t){return be.parse(e,t)}xe.options=xe.setOptions=function(e){return be.setOptions(e),xe.defaults=be.defaults,y(xe.defaults),xe},xe.getDefaults=f,xe.defaults=k,xe.use=function(...e){return be.use(...e),xe.defaults=be.defaults,y(xe.defaults),xe},xe.walkTokens=function(e,t){return be.walkTokens(e,t)},xe.parseInline=be.parseInline,xe.Parser=$e,xe.parser=$e.parse,xe.Renderer=ke,xe.TextRenderer=ye,xe.Lexer=fe,xe.lexer=fe.lex,xe.Tokenizer=R,xe.Hooks=ve,xe.parse=xe,xe.options,xe.setOptions,xe.use,xe.walkTokens,xe.parseInline,$e.parse,fe.lex;"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function Ce(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Ee={"&":"&","<":"<",">":">",'"':""","'":"'"},Se={"&":"&","<":"<",">":">",""":'"',"'":"'"},Te=/(&|<|>|"|')/g,Ae=/[&<>"']/g;function Le(e){return Ee[e]}function Me(e){return Se[e]}function Pe(e){return null==e?"":String(e).replace(Ae,Le)}function Ie(e){return null==e?"":String(e).replace(Te,Me)}Pe.options=Ie.options={};var Re={encode:Pe,escape:Pe,decode:Ie,unescape:Ie,version:"1.0.0-browser"};var Ue=function e(t){for(var n,s,i=Array.prototype.slice.call(arguments,1);i.length;)for(s in n=i.shift())n.hasOwnProperty(s)&&("[object Object]"===Object.prototype.toString.call(t[s])?t[s]=e(t[s],n[s]):t[s]=n[s]);return t},qe=function(e){return"string"==typeof e?e.toLowerCase():e};function _e(e,t){return e[t]=!0,e}var Oe=function(e){return e.reduce(_e,{})},De={uris:Oe(["background","base","cite","href","longdesc","src","usemap"])},Be={voids:Oe(["area","br","col","hr","img","wbr","input","base","basefont","link","meta"])},je=Re,Fe=qe,We=Be,ze=/^<\s*([\w:-]+)((?:\s+[\w:-]+(?:\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|[^>\s]+))?)*)\s*(\/?)\s*>/,Ne=/^<\s*\/\s*([\w:-]+)[^>]*>/,He=/([\w:-]+)(?:\s*=\s*(?:(?:"((?:[^"])*)")|(?:'((?:[^'])*)')|([^>\s]+)))?/g,Qe=/^</,Ve=/^<\s*\//;var Ge=Re,Ke=qe,Ze=De,Ye=Be;var Xe=Ue,Je=function(e,t){for(var n,s=function(){var e=[];return e.lastItem=function(){return e[e.length-1]},e}(),i=e;e;)r();function r(){n=!0,function(){"\x3c!--"===e.substr(0,4)?(s=e.indexOf("--\x3e"))>=0&&(t.comment&&t.comment(e.substring(4,s)),e=e.substring(s+3),n=!1):Ve.test(e)?o(Ne,l):Qe.test(e)&&o(ze,a);var s;!function(){if(!n)return;var s,i=e.indexOf("<");i>=0?(s=e.substring(0,i),e=e.substring(i)):(s=e,e="");t.chars&&t.chars(s)}()}();var s=e===i;i=e,s&&(e="")}function o(t,s){var i=e.match(t);i&&(e=e.substring(i[0].length),i[0].replace(t,s),n=!1)}function a(e,n,i,r){var o={},a=Fe(n),l=We.voids[a]||!!r;i.replace(He,(function(e,t,n,s,i){o[t]=void 0===n&&void 0===s&&void 0===i?void 0:je.decode(n||s||i||"")})),l||s.push(a),t.start&&t.start(a,o,l)}function l(e,n){var i,r=0,o=Fe(n);if(o)for(r=s.length-1;r>=0&&s[r]!==o;r--);if(r>=0){for(i=s.length-1;i>=r;i--)t.end&&t.end(s[i]);s.length=r}}l()},et=function(e,t){var n,s=t||{};return a(),{start:function(e,t,o){var a=Ke(e);if(n.ignoring)return void r(a);if(-1===(s.allowedTags||[]).indexOf(a))return void r(a);if(s.filter&&!s.filter({tag:a,attrs:t}))return void r(a);i("<"),i(a),Object.keys(t).forEach((function(e){var n=t[e],r=(s.allowedClasses||{})[a]||[],o=(s.allowedAttributes||{})[a]||[],l=Ke(e);("class"===l&&-1===o.indexOf(l)?(n=n.split(" ").filter((function(e){return r&&-1!==r.indexOf(e)})).join(" ").trim()).length:-1!==o.indexOf(l)&&(!0!==Ze.uris[l]||function(e){var t=e[0];if("#"===t||"/"===t)return!0;var n=e.indexOf(":");if(-1===n)return!0;var i=e.indexOf("?");if(-1!==i&&n>i)return!0;var r=e.indexOf("#");return-1!==r&&n>r||s.allowedSchemes.some(o);function o(t){return 0===e.indexOf(t+":")}}(n)))&&(i(" "),i(e),"string"==typeof n&&(i('="'),i(Ge.encode(n)),i('"')))})),i(o?"/>":">")},end:function(e){var t=Ke(e);-1!==(s.allowedTags||[]).indexOf(t)&&!1===n.ignoring?(i("</"),i(t),i(">")):o(t)},chars:function(e){!1===n.ignoring&&i(s.transformText?s.transformText(e):e)}};function i(t){e.push(t)}function r(e){Ye.voids[e]||(!1===n.ignoring?n={ignoring:e,depth:1}:n.ignoring===e&&n.depth++)}function o(e){n.ignoring===e&&--n.depth<=0&&a()}function a(){n={ignoring:!1,depth:0}}},tt={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 nt(e,t,n){var s=[],i=!0===n?t:Xe({},tt,t),r=et(s,i);return Je(e,r),s.join("")}nt.defaults=tt;const st=Ce(nt),it={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:e=>([["code",/^hljs\W+language-(.*)$/],["span",/^(hljs-.*)$/],["img",/^lazyload$/]].forEach((([t,n])=>{e.tag===t&&e.attrs.class&&!n.test(e.attrs.class)&&delete e.attrs.class})),"span"===e.tag&&e.attrs.style&&!/^color:(\W+)?#[0-9a-f]{3,6};?$/i.test(e.attrs.style)&&delete e.attrs.style,!0)};function rt(e){return st(e,it)}var ot={exports:{}};const at=Ce(ot.exports=function(){function e(e,t){return e(t={exports:{}},t.exports),t.exports}var t=e((function(e){var t=e.exports=function(){return new RegExp("(?:"+t.line().source+")|(?:"+t.block().source+")","gm")};t.line=function(){return/(?:^|\s)\/\/(.+?)$/gm},t.block=function(){return/\/\*([\S\s]*?)\*\//gm}})),n=["23AC69","91C132","F19726","E8552D","1AAB8E","E1147F","2980C1","1BA1E6","9FA0A0","F19726","E30B20","E30B20","A3338B"];function s(e){return'<span style="color: slategray">'+e+"</span>"}return function(e,i){void 0===i&&(i={});var r=i.colors;void 0===r&&(r=n);var o=0,a={},l=new RegExp("("+/[\u4E00-\u9FFF\u3400-\u4dbf\uf900-\ufaff\u3040-\u309f\uac00-\ud7af\u0400-\u04FF]+|\w+/.source+"|"+/</.source+")|("+t().source+")","gmi");return e.replace(l,(function(e,t,n){if(n)return s(n);if("<"===t)return"<";var i;a[t]?i=a[t]:(i=r[o],a[t]=i);var l='<span style="color: #'+i+'">'+t+"</span>";return o=++o%r.length,l}))}}());function lt(e){return at(e)}function ct(e){const t=new xe.Renderer;return t.link=dt(t,t.link),t.code=ht(),t.image=ut(t,t.image,e),t}const dt=(e,t)=>n=>{const s=(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" ${s?"":'rel="noreferrer noopener nofollow"'} `)},ht=()=>({lang:e,text:t})=>{const n=e||"plaintext";let s=t;return window.hljs?n&&window.hljs.getLanguage(n)&&(s=window.hljs.highlight(n,t).value):s=lt(t),`<pre rel="${n}">\n<code class="hljs language-${n}">${s.replace(/&/g,"&")}</code>\n</pre>`},ut=(e,t,{imgLazyLoad:n})=>s=>{const i=t.call(e,s);return n?"native"===n||!0===n?i.replace(/^<img /,'<img class="lazyload" loading="lazy" '):"data-src"===n?i.replace(/^<img /,'<img class="lazyload" ').replace("src=","data-src="):i:i};let pt,gt=[];const mt={gfm:!0,breaks:!0,async:!1};function ft(){return pt}function kt(e){var t;let n=null==(t=ft())?void 0:t.parse(e);n||(n=function(e){return e.replace(/```\s*([^]+?.*?[^]+?[^]+?)```/g,((e,t)=>`<pre><code>${lt(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 s=rt(n);return gt.forEach((e=>{"function"==typeof e&&(s=e(s))})),s}function yt(...e){const t=e=>e&&"object"==typeof e&&e.constructor===Object;return e.reduce(((e,n)=>(Object.keys(null!=n?n:{}).forEach((s=>{if("__proto__"===s||"constructor"===s||"prototype"===s)return;const i=e[s],r=n[s];Array.isArray(i)&&Array.isArray(r)?e[s]=i.concat(...r):t(i)&&t(r)?e[s]=yt(i,r):e[s]=r})),e)),{})}class $t{constructor(e){c(this,"loading",!1),c(this,"listLastFetch"),c(this,"comments",[]),c(this,"notifies",[]),c(this,"page"),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)}}function vt(e=""){const t=document.createElement("div");return t.innerHTML=e.trim(),t.firstElementChild||t}function wt(e){const t=document.createElement("div");t.innerText=e;return t.innerHTML}function bt(e){const t=RegExp(`[?&]${e}=([^&]*)`).exec(window.location.search);return t&&decodeURIComponent(t[1].replace(/\+/g," "))}function xt(e,t){const n=e=>{const t=e.getBoundingClientRect(),n=window.pageXOffset||document.documentElement.scrollLeft,s=window.pageYOffset||document.documentElement.scrollTop;return{top:t.top+s,left:t.left+n}},s=n(e);if(!t)return s;const i=n(t);return{top:s.top-i.top,left:s.left-i.left}}function Ct(e,t){let n=e.toString();for(;n.length<t;)n=`0${n}`;return n}function Et(e,t=e=>e){try{const n=e.getTime(),s=(new Date).getTime()-n,i=Math.floor(s/864e5);if(0===i){const e=s%864e5,n=Math.floor(e/36e5);if(0===n){const n=e%36e5,s=Math.floor(n/6e4);if(0===s){const e=n%6e4,s=Math.round(e/1e3);return s<10?t("now"):`${s} ${t("seconds")}`}return`${s} ${t("minutes")}`}return`${n} ${t("hours")}`}return i<0?t("now"):i<8?`${i} ${t("days")}`:function(e){const t=Ct(e.getDate(),2),n=Ct(e.getMonth()+1,2);return`${Ct(e.getFullYear(),2)}-${n}-${t}`}(e)}catch(n){return console.error(n)," - "}}function St(){return d(this,null,(function*(){const e=navigator.userAgent;if(!navigator.userAgentData||!navigator.userAgentData.getHighEntropyValues)return e;const t=navigator.userAgentData;let n=null;try{n=yield t.getHighEntropyValues(["platformVersion"])}catch(i){return console.error(i),e}const s=Number(n.platformVersion.split(".")[0]);return"Windows"===t.platform&&s>=13?e.replace(/Windows NT 10.0/,"Windows NT 11.0"):"macOS"===t.platform&&s>=11?e.replace(/(Mac OS X \d+_\d+_\d+|Mac OS X)/,`Mac OS X ${n.platformVersion.replace(/\./g,"_")}`):e}))}function Tt(e){let t;try{t=new URL(e)}catch(n){return!1}return"http:"===t.protocol||"https:"===t.protocol}function At(e){return t=e.base,n=e.path,`${t.replace(/\/$/,"")}/${n.replace(/^\//,"")}`;var t,n}const Lt={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}"},Mt="ArtalkI18n",Pt={en:Lt,"en-US":Lt,"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 It(e){return e=e.replace(/^([a-zA-Z]+)(-[a-zA-Z]+)?$/,((e,t,n)=>t.toLowerCase()+(n||"").toUpperCase())),Pt[e]?Pt[e]:window[Mt]&&window[Mt][e]?window[Mt][e]:Pt.en}let Rt="en",Ut=It(Rt);function qt(e){e!==Rt&&(Rt=e,Ut="string"==typeof e?It(e):e)}function _t(e,t={}){let n=(null==Ut?void 0:Ut[e])||e;return n=n.replace(/\{\s*(\w+?)\s*\}/g,((e,n)=>t[n]||"")),wt(n)}class Ot{constructor(){c(this,"events",[])}on(e,t,n={}){this.events.push(a({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)}))}}const Dt={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 Bt(e,t=!1){const n=t?yt(Dt,e):e;if(n.el&&"string"==typeof n.el)try{const e=document.querySelector(n.el);if(!e)throw Error(`Target element "${n.el}" was not found.`);n.el=e}catch(s){throw console.error(s),new Error("Please check your Artalk `el` config.")}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 jt(e,t){return{baseURL:`${e.server}/api/v2`,siteName:e.site||"",pageKey:e.pageKey||"",pageTitle:e.pageTitle||"",timeout:e.reqTimeout,getApiToken:()=>null==t?void 0:t.get("user").getData().token,userInfo:(null==t?void 0:t.get("user").checkHasBasicUserInfo())?{name:null==t?void 0:t.get("user").getData().name,email:null==t?void 0:t.get("user").getData().email}:void 0,handlers:null==t?void 0:t.getApiHandlers()}}function Ft(e,t,n){let s=null;const i=()=>{const i=(()=>{const n=e.getConf(),s={};return t.forEach((e=>{s[e]=n[e]})),s})();var r,o;(null==s||(r=s,o=i,!(JSON.stringify(r)===JSON.stringify(o))))&&(s=i,n(i))};e.on("mounted",i),e.on("updated",i)}class Wt{constructor(e){c(this,"conf"),c(this,"data"),c(this,"$root"),c(this,"events",new Ot),c(this,"mounted",!1),c(this,"apiHandlers",null),c(this,"getCommentList",this.getCommentNodes),c(this,"getCommentDataList",this.getComments),this.conf=e,this.$root=e.el,this.$root.classList.add("artalk"),this.$root.innerHTML="",e.darkMode&&this.$root.classList.add("atk-dark-mode"),this.data=new $t(this.events),this.on("mounted",(()=>{this.mounted=!0}))}inject(e,t){this[e]=t}get(e){return this[e]}getApi(){return new m(jt(this.conf,this))}getApiHandlers(){return this.apiHandlers||(this.apiHandlers=function(e){const t=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}}();return t.add("need_captcha",(t=>e.checkCaptcha(t))),t.add("need_login",(()=>e.checkAdmin({}))),t}(this)),this.apiHandlers}getData(){return this.data}replyComment(e,t){this.editor.setReply(e,t)}editComment(e,t){this.editor.setEditComment(e,t)}fetch(e){this.data.fetchComments(e)}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(e,t){this.editor.showNotify(e,t)}editorResetState(){this.editor.resetState()}showSidebar(e){this.sidebarLayer.show(e)}hideSidebar(){this.sidebarLayer.hide()}checkAdmin(e){return this.checkerLauncher.checkAdmin(e)}checkCaptcha(e){return this.checkerLauncher.checkCaptcha(e)}on(e,t){this.events.on(e,t)}off(e,t){this.events.off(e,t)}trigger(e,t){this.events.trigger(e,t)}$t(e,t={}){return _t(e,t)}setDarkMode(e){this.updateConf({darkMode:e})}updateConf(e){this.conf=yt(this.conf,Bt(e,!1)),this.mounted&&this.events.trigger("updated",this.conf)}getConf(){return this.conf}getEl(){return this.$root}getMarked(){return ft()}watchConf(e,t){Ft(this,e,t)}}function zt(e,t){let n=e.querySelector(":scope > .atk-loading");n||(n=vt('<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 s=n.querySelector(".atk-loading-spinner");s&&(s.style.display="none",window.setTimeout((()=>{s.isConnected&&(s.style.display="")}),500))}function Nt(e){const t=e.querySelector(":scope > .atk-loading");t&&(t.style.display="none")}function Ht(e,t){e?zt(t):Nt(t)}function Qt(e,t=!0,n){let s;if(n){const t=n.getBoundingClientRect();s=e.getBoundingClientRect().top-t.top+n.scrollTop-n.clientHeight/2+e.clientHeight/2}else{const t=e.getBoundingClientRect();s=t.top+window.scrollY-(window.innerHeight/2-t.height/2)}const i={top:s,left:0,behavior:"instant"};n?n.scroll(i):window.scroll(i)}function Vt(e,t){!function(e,t,n="in"){e.classList.add(`atk-fade-${n}`);const s=()=>{e.classList.remove(`atk-fade-${n}`),e.removeEventListener("animationend",s)};e.addEventListener("animationend",s)}(e,0,"in")}function Gt(e,t,n='<span class="atk-error-title">Artalk Error</span>'){let s=e.querySelector(".atk-error-layer");if(null===t)return void(null!==s&&s.remove());s||(s=vt(`<div class="atk-error-layer">${n}<span class="atk-error-text"></span></div>`),e.appendChild(s));const i=s.querySelector(".atk-error-text");i.innerHTML="",null!==t&&(t instanceof HTMLElement?i.appendChild(t):i.innerText=t)}function Kt(e){const t=vt('<div class="atk-checker-iframe-wrap"></div>'),n=vt('<iframe class="atk-fade-in" referrerpolicy="strict-origin-when-cross-origin"></iframe>');n.style.display="none",zt(t,{transparentBg:!0}),n.src=e.getOpts().getCaptchaIframeURL(),n.onload=()=>{n.style.display="",Nt(t)},t.append(n);const s=vt('<div class="atk-close-btn"><i class="atk-icon atk-icon-close"></i></div>');t.append(s),e.hideInteractInput();let i=!1;return function t(){return d(this,null,(function*(){var n;if(yield(n=1e3,new Promise((e=>{window.setTimeout((()=>{e(null)}),n)}))),i)return;let s=!1;try{s=(yield e.getApi().captcha.getCaptchaStatus()).data.is_pass}catch(r){s=!1}s?e.triggerSuccess():t()}))}(),s.onclick=()=>{i=!0,e.cancel()},t}const Zt={request:(e,t)=>e.getApi().captcha.verifyCaptcha({value:t}),body:e=>e.get("iframe")?Kt(e):function(e){const t=vt(`<span><img class="atk-captcha-img" src="${e.get("img_data")||""}">${_t("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,s){e.set("val",n)},onError(e,t,n,s){s.querySelector(".atk-captcha-img").click(),s.querySelector('input[type="text"]').value=""}},Yt={inputType:"password",request(e,t){return d(this,null,(function*(){return(yield e.getApi().user.login({name:e.getUser().getData().name,email:e.getUser().getData().email,password:t})).data}))},body:e=>vt(`<span>${_t("adminCheck")}</span>`),onSuccess(e,t,n,s){e.getUser().update({is_admin:!0,token:t.token}),e.getOpts().onReload()},onError(e,t,n,s){}};class Xt{constructor(e){c(this,"$el"),c(this,"$content"),c(this,"$actions"),this.$el=vt('<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=vt(`<button data-action="confirm">${_t("confirm")}</button>`);return t.onclick=this.onBtnClick(e),this.$actions.appendChild(t),this}setNo(e){const t=vt(`<button data-action="cancel">${_t("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 Jt(e){return t=>new Promise(((n,s)=>{const i=t.onCancel;t.onCancel=()=>{i&&i(),s(new Error("user canceled the checker"))};const r=t.onSuccess;t.onSuccess=()=>{r&&r(),n()},e(t)}))}class en{constructor(e){c(this,"checkCaptcha",Jt((e=>{this.fire(Zt,e,(t=>{t.set("img_data",e.img_data),t.set("iframe",e.iframe)}))}))),c(this,"checkAdmin",Jt((e=>{this.fire(Yt,e)}))),this.opts=e}fire(e,t,n){const s=this.opts.getCtx().get("layerManager").create(`checker-${(new Date).getTime()}`);s.show();const i=()=>{s.destroy()},r={};let o=!1;const a={set:(e,t)=>{r[e]=t},get:e=>r[e],getOpts:()=>this.opts,getUser:()=>this.opts.getCtx().get("user"),getApi:()=>this.opts.getApi(),hideInteractInput:()=>{o=!0},triggerSuccess:()=>{i(),e.onSuccess&&e.onSuccess(a,"","",l),t.onSuccess&&t.onSuccess()},cancel:()=>{i(),t.onCancel&&t.onCancel()}};n&&n(a);const l=vt();l.appendChild(e.body(a));const c=vt(`<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(),s.getEl().querySelector('button[data-action="confirm"]').click())};const h=new Xt(l);h.setYes((n=>{const s=c.value.trim();d||(d=n.innerText);const r=()=>{n.innerText=d||"",n.classList.remove("error")};return n.innerText=`${_t("loading")}...`,e.request(a,s).then((n=>{i(),e.onSuccess&&e.onSuccess(a,n,s,l),t.onSuccess&&t.onSuccess()})).catch((t=>{var i;i=String(t.message||String(t)),n.innerText=i,n.classList.add("error"),e.onError&&e.onError(a,t,s,l);const o=setTimeout((()=>r()),3e3);c.onfocus=()=>{r(),clearTimeout(o)}})),!1})),h.setNo((()=>(i(),t.onCancel&&t.onCancel(),!1))),o&&(c.style.display="none",h.$el.querySelector(".atk-layer-dialog-actions").style.display="none"),s.getEl().append(h.$el),t.onMount&&t.onMount(h.$el)}}class tn{constructor(e){c(this,"$el"),this.ctx=e}get conf(){return this.ctx.conf}getEl(){return this.$el}}const nn={$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 sn{constructor(e){c(this,"$btn"),c(this,"$panel"),c(this,"editorStateEffectWhen"),this.kit=e}useBtn(e="<div></div>"){return this.$btn=vt(`<span class="atk-plug-btn">${e}</span>`),this.$btn}usePanel(e="<div></div>"){return this.$panel=vt(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}}class rn extends sn{constructor(){super(...arguments),c(this,"isMoved",!1)}move(e){if(this.isMoved)return;this.isMoved=!0;const t=this.kit.useUI().$el;t.after(vt('<div class="atk-editor-travel-placeholder"></div>'));const n=vt("<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.useGlobalCtx().$root.querySelector(".atk-editor-travel-placeholder"))||e.replaceWith(this.kit.useUI().$el),this.kit.useUI().$el.classList.remove("editor-traveling"))}}class on{constructor(e){c(this,"stateCurt","normal"),c(this,"stateUnmountFn",null),this.editor=e}get(){return this.stateCurt}switch(e,t){var n,s,i,r,o;if(this.stateUnmountFn&&(this.stateUnmountFn(),this.stateUnmountFn=null,null==(s=null==(n=this.editor.getPlugs())?void 0:n.get(rn))||s.back()),"normal"!==e&&t){let n=t.$comment;this.editor.conf.flatMode||(n=n.querySelector(".atk-footer")),null==(r=null==(i=this.editor.getPlugs())?void 0:i.get(rn))||r.move(n);const s=this.editor.ctx.conf.scrollRelativeTo&&this.editor.ctx.conf.scrollRelativeTo();Qt(this.editor.getUI().$el,!0,s);const a=null==(o=this.editor.getPlugs())?void 0:o.getPlugs().find((t=>t.editorStateEffectWhen===e));a&&a.editorStateEffect&&(this.stateUnmountFn=a.editorStateEffect(t.comment))}this.stateCurt=e}}class an extends tn{constructor(e){super(e),c(this,"ui"),c(this,"state"),this.ui=function(){const e=vt('<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(nn).forEach((([n,s])=>{t[n]=e.querySelector(s)})),t}(),this.$el=this.ui.$el,this.state=new on(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 e=this.getContentRaw();const t=this.getPlugs();return t&&(e=t.getTransformedContent(e)),e}getContentRaw(){return this.ui.$textarea.value||""}getContentMarked(){return kt(this.getContentFinal())}setContent(e){var t;this.ui.$textarea.value=e,null==(t=this.getPlugs())||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,s=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=s}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")}setReply(e,t){this.state.switch("reply",{comment:e,$comment:t})}setEditComment(e,t){this.state.switch("edit",{comment:e,$comment:t})}showNotify(e,t){!function(e,t,n){const s=vt(`<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>`);s.querySelector(".atk-notify-content").innerHTML=wt(t).replace("\n","<br/>"),e.appendChild(s);const i=()=>{s.classList.add("atk-fade-out"),setTimeout((()=>{s.remove()}),200)};let r;r=window.setTimeout((()=>{i()}),3e3),s.addEventListener("click",(()=>{i(),window.clearTimeout(r)}))}(this.ui.$notifyWrap,e,t)}showLoading(){zt(this.ui.$el)}hideLoading(){Nt(this.ui.$el)}submit(){const e=()=>this.ctx.trigger("editor-submit");this.ctx.conf.beforeSubmit?this.ctx.conf.beforeSubmit(this,e):e()}}class ln extends tn{constructor(e){super(e),c(this,"layer"),c(this,"$header"),c(this,"$closeBtn"),c(this,"$iframeWrap"),c(this,"$iframe"),c(this,"refreshWhenShow",!0),c(this,"animTimer"),this.$el=vt('<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 d(this,arguments,(function*(e={}){if(this.$el.style.transform="",this.initLayer(),this.layer.show(),this.refreshWhenShow)this.refreshWhenShow=!1,this.$iframeWrap.innerHTML="",this.$iframe=this.createIframe(e.view),this.$iframeWrap.append(this.$iframe);else{const e=this.$iframe,t=e.src;this.getDarkMode()!==t.includes("&darkMode=1")&&this.iframeLoad(e,t.replace(/&darkMode=\d/,`&darkMode=${Number(this.getDarkMode())}`))}this.authCheck({onSuccess:()=>this.show(e)}),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 e;null==(e=this.layer)||e.hide()}authCheck(e){return d(this,null,(function*(){const t=(yield this.ctx.getApi().user.getUserStatus(a({},this.ctx.getApi().getUserFields()))).data;t.is_admin&&!t.is_login&&(this.refreshWhenShow=!0,this.ctx.checkAdmin({onSuccess:()=>{setTimeout((()=>{e.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(e){const t=vt('<iframe referrerpolicy="strict-origin-when-cross-origin"></iframe>'),n=At({base:this.ctx.conf.server,path:"/sidebar/"}),s={pageKey:this.conf.pageKey,site:this.conf.site||"",user:JSON.stringify(this.ctx.get("user").getData()),time:+new Date};e&&(s.view=e),s.darkMode=this.getDarkMode()?"1":"0";const i=new URLSearchParams(s);return this.iframeLoad(t,`${n}?${i.toString()}`),t}getDarkMode(){return"auto"===this.conf.darkMode?window.matchMedia("(prefers-color-scheme: dark)").matches:this.conf.darkMode}iframeLoad(e,t){e.src=t,zt(this.$iframeWrap),e.onload=()=>{Nt(this.$iframeWrap)}}}const cn=e=>({import:t=>{(function(e,t="DATE_DESC",n=2){const s=[];e.filter((e=>0===e.rid)).forEach((t=>{const i={id:t.id,comment:t,children:[],level:1};i.parent=i,s.push(i),function t(s){const i=e.filter((e=>e.rid===s.id));0!==i.length&&(s.level>=n&&(s=s.parent),i.forEach((e=>{const n={id:e.id,comment:e,children:[],parent:s,level:s.level+1};s.children.push(n),t(n)})))}(i)}));const i=(n,s)=>{let i=n.id-s.id;return"DATE_ASC"===t?i=+new Date(n.comment.date)-+new Date(s.comment.date):"DATE_DESC"===t?i=+new Date(s.comment.date)-+new Date(n.comment.date):"SRC_INDEX"===t?i=e.indexOf(n.comment)-e.indexOf(s.comment):"VOTE_UP_DESC"===t&&(i=s.comment.vote_up-n.comment.vote_up),i};return function e(t){t.forEach((t=>{t.children=t.children.sort(i),e(t.children)}))}(s),s})(t,e.nestSortBy,e.nestMax).forEach((n=>{var s;const i=e.createCommentNode(n.comment);null==(s=e.$commentsWrap)||s.appendChild(i.getEl()),i.getRender().playFadeAnim();const r=(n,s)=>{s.children.forEach((s=>{const i=t.find((e=>e.id===s.comment.rid)),o=s.comment,a=e.createCommentNode(o,i);n.putChild(a),r(a,s)}))};r(i,n),i.getRender().checkHeightLimit()}))},insert:(t,n)=>{var s;const i=e.createCommentNode(t,n);if(0===t.rid)null==(s=e.$commentsWrap)||s.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 dn(e,t,n,s){n.is_collapsed&&(n.is_allow_reply=!1);const i=e.createCommentNode(n,s);if(n.visible){const n=i.getEl(),s=e.$commentsWrap;"append"===t&&(null==s||s.append(n)),"prepend"===t&&(null==s||s.prepend(n)),i.getRender().playFadeAnim()}return i.getRender().checkHeightLimit(),i}class hn{constructor(e){this.options=e}getStrategy(){return this.options.flatMode?(e=this.options,{import:t=>{t.forEach((n=>{const s=0===n.rid?void 0:t.find((e=>e.id===n.rid));dn(e,"append",n,s)}))},insert:(t,n)=>{dn(e,"prepend",t,n).scrollIntoView()}}):cn(this.options);var e}import(e){this.getStrategy().import(e)}insert(e,t){this.getStrategy().insert(e,t)}}function un(e,t){t.forEach((({el:t,max:n,imgCheck:s})=>{if(!t)return;s&&(t.style.maxHeight=`${n+1}px`);let i=!1;const r=()=>{if(i)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(mn))return;e.el.classList.add(mn),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(pn))return;e.el.classList.add(pn),e.el.style.height=`${e.max}px`,e.el.style.overflow="hidden";const t=vt(`<div class="atk-height-limit-btn">${_t("readMore")}</span>`);t.onclick=t=>{t.stopPropagation(),gn(e.el),e.afterExpandBtnClick&&e.afterExpandBtnClick(t)},e.el.append(t)}({el:t,max:n,afterExpandBtnClick:()=>{var t;i=!0,null==(t=e.afterExpandBtnClick)||t.call(e)}})};if(r(),s){const e=t.querySelectorAll(".atk-content img");0===e.length&&(t.style.maxHeight=""),e.forEach((e=>{e.onload=()=>r()}))}}))}const pn="atk-height-limit";function gn(e){e&&e.classList.contains(pn)&&(e.classList.remove(pn),Array.from(e.children).forEach((e=>{e.classList.contains("atk-height-limit-btn")&&e.remove()})),e.style.height="",e.style.maxHeight="",e.style.overflow="")}const mn="atk-height-limit-scroll";function fn(e){if(e.$headerNick=e.$el.querySelector(".atk-nick"),e.data.link){const t=vt('<a target="_blank" rel="noreferrer noopener nofollow"></a>');t.innerText=e.data.nick,t.href=Tt(e.data.link)?e.data.link:`https://${e.data.link}`,e.$headerNick.append(t)}else e.$headerNick.innerText=e.data.nick}function kn(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 s=vt('<span class="atk-badge"></span>');s.innerText=t.replace("管理员",_t("admin")),s.style.backgroundColor=n||"",e.$headerBadgeWrap.append(s)}else if(e.data.is_verified){const t=vt(`<span class="atk-verified-icon" title="${_t("emailVerified")}"></span>`);e.$headerBadgeWrap.append(t)}if(e.data.is_pinned){const t=vt(`<span class="atk-pinned-badge">${_t("pin")}</span>`);e.$headerBadgeWrap.append(t)}}function yn(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 $n(e){if(!e.opts.uaBadge&&!e.data.ip_region)return;let t=e.$header.querySelector("atk-ua-wrap");if(t||(t=vt('<span class="atk-ua-wrap"></span>'),e.$header.append(t)),t.innerHTML="",e.data.ip_region){const n=vt('<span class="atk-region-badge"></span>');n.innerText=e.data.ip_region,t.append(n)}if(e.opts.uaBadge){const{browser:n,os:s}=e.comment.getUserUA();if(String(n).trim()){const e=vt('<span class="atk-ua ua-browser"></span>');e.innerText=n,t.append(e)}if(String(s).trim()){const e=vt('<span class="atk-ua ua-os"></span>');e.innerText=s,t.append(e)}}}class vn{constructor(e){c(this,"opts"),c(this,"$el"),c(this,"isLoading",!1),c(this,"msgRecTimer"),c(this,"msgRecTimerFunc"),c(this,"isConfirming",!1),c(this,"confirmRecTimer"),this.$el=vt('<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","")}get isMessaging(){return!!this.msgRecTimer}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||_t("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||`${_t("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,s){this.setLoading(!1),t&&this.$el.classList.add(t),this.$el.innerText=e,this.setMsgRecTimer((()=>{this.$el.innerText=this.getText(),t&&this.$el.classList.remove(t),s&&s()}),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 wn(e){e.opts.vote&&(e.voteBtnUp=new vn((()=>`${_t("voteUp")} (${e.data.vote_up||0})`)).appendTo(e.$actions),e.voteBtnUp.setClick((()=>{e.comment.getActions().vote("up")})),e.opts.voteDown&&(e.voteBtnDown=new vn((()=>`${_t("voteDown")} (${e.data.vote_down||0})`)).appendTo(e.$actions),e.voteBtnDown.setClick((()=>{e.comment.getActions().vote("down")}))))}function bn(e){if(!e.data.is_allow_reply)return;const t=vt(`<span>${_t("reply")}</span>`);e.$actions.append(t),t.addEventListener("click",(t=>{t.stopPropagation(),e.opts.replyComment(e.data,e.$el)}))}function xn(e){const t=new vn({text:()=>e.data.is_collapsed?_t("expand"):_t("collapse"),adminOnly:!0});t.appendTo(e.$actions),t.setClick((()=>{e.comment.getActions().adminEdit("collapsed",t)}))}function Cn(e){const t=new vn({text:()=>e.data.is_pending?_t("pending"):_t("approved"),adminOnly:!0});t.appendTo(e.$actions),t.setClick((()=>{e.comment.getActions().adminEdit("pending",t)}))}function En(e){const t=new vn({text:()=>e.data.is_pinned?_t("unpin"):_t("pin"),adminOnly:!0});t.appendTo(e.$actions),t.setClick((()=>{e.comment.getActions().adminEdit("pinned",t)}))}function Sn(e){const t=new vn({text:_t("edit"),adminOnly:!0});t.appendTo(e.$actions),t.setClick((()=>{e.opts.editComment(e.data,e.$el)}))}function Tn(e){const t=new vn({text:_t("delete"),confirm:!0,confirmText:_t("deleteConfirm"),adminOnly:!0});t.appendTo(e.$actions),t.setClick((()=>{e.comment.getActions().adminDelete(t)}))}const An={Avatar:function(e){const t=e.$el.querySelector(".atk-avatar"),n=vt("<img />"),s=e.opts.avatarURLBuilder;if(n.src=s?s(e.data):e.comment.getGravatarURL(),e.data.link){const s=vt('<a target="_blank" rel="noreferrer noopener nofollow"></a>');s.href=Tt(e.data.link)?e.data.link:`https://${e.data.link}`,s.append(n),t.append(s)}else t.append(n)},Header:function(e){Object.entries({renderNick:fn,renderVerifyBadge:kn,renderDate:yn,renderUABadge:$n}).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=vt(`\n <div class="atk-collapsed">\n <span class="atk-text">${_t("collapsedMsg")}</span>\n <span class="atk-show-btn">${_t("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"),Vt(e.$content),n.innerText=_t("collapse")):(e.$content.innerHTML="",e.$content.classList.add("atk-hide"),n.innerText=_t("expand"))}))},ReplyAt:function(e){e.opts.flatMode||0===e.data.rid||e.opts.replyTo&&(e.$replyAt=vt('<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=vt(`\n <div class="atk-reply-to">\n <div class="atk-meta">${_t("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=kt(e.opts.replyTo.content);e.opts.replyTo.is_collapsed&&(n=`[${_t("collapsed")}]`),e.$replyTo.querySelector(".atk-content").innerHTML=n,e.$body.prepend(e.$replyTo)},Pending:function(e){if(!e.data.is_pending)return;const t=vt(`<div class="atk-pending">${_t("pendingMsg")}</div>`);e.$body.prepend(t)},Actions:function(e){Object.entries({renderVote:wn,renderReply:bn,renderCollapse:xn,renderModerator:Cn,renderPin:En,renderEdit:Sn,renderDel:Tn}).forEach((([t,n])=>{n(e)}))}};class Ln{constructor(e){c(this,"comment"),c(this,"$el"),c(this,"$main"),c(this,"$header"),c(this,"$headerNick"),c(this,"$headerBadgeWrap"),c(this,"$body"),c(this,"$content"),c(this,"$childrenWrap"),c(this,"$actions"),c(this,"voteBtnUp"),c(this,"voteBtnDown"),c(this,"$replyTo"),c(this,"$replyAt"),this.comment=e}get data(){return this.comment.getData()}get opts(){return this.comment.getOpts()}render(){var e;return this.$el=vt('<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(An).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;un({afterExpandBtnClick:()=>{const e=this.comment.getChildren();1===e.length&&gn(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&&gn(this.$childrenWrap)}playFadeAnim(){Vt(this.comment.getRender().$el)}playFadeAnimForBody(){Vt(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=vt('<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()}}}class Mn{constructor(e){c(this,"comment"),this.comment=e}get data(){return this.comment.getData()}get opts(){return this.comment.getOpts()}getApi(){return this.comment.getOpts().getApi()}vote(e){const t="up"===e?this.comment.getRender().voteBtnUp:this.comment.getRender().voteBtnDown;this.getApi().votes.vote(`comment_${e}`,this.data.id,a({},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)||t.updateText(),null==(n=this.comment.getRender().voteBtnDown)||n.updateText()})).catch((e=>{null==t||t.setError(_t("voteFail")),console.error(e)}))}adminEdit(e,t){if(t.isLoading)return;t.setLoading(!0,`${_t("editing")}...`);const n=a({},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,a({},n)).then((e=>{t.setLoading(!1),this.comment.setData(e.data)})).catch((e=>{console.error(e),t.setError(_t("editFail"))}))}adminDelete(e){e.isLoading||(e.setLoading(!0,`${_t("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(_t("deleteFail"))})))}goToReplyComment(){const e=window.location.hash,t=`#atk-comment-${this.data.rid}`;window.location.hash=t,t===e&&window.dispatchEvent(new Event("hashchange"))}}class Pn{constructor(e,t){c(this,"$el"),c(this,"renderInstance"),c(this,"actionInstance"),c(this,"data"),c(this,"opts"),c(this,"parent"),c(this,"children",[]),c(this,"nestCurt"),this.opts=t,this.data=a({},e),this.data.date=this.data.date.replace(/-/g,"/"),this.parent=null,this.nestCurt=1,this.actionInstance=new Mn(this),this.renderInstance=new Ln(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(),s=e.getEl();"append"===t?n.append(s):"prepend"===t&&n.prepend(s),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&&Qt(this.$el,!1,this.opts.scrollRelativeTo&&this.opts.scrollRelativeTo())}remove(){var e;null==(e=this.$el)||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 kt(this.data.content)}getDateFormatted(){var e,t;const n=new Date(this.data.date);return(null==(t=(e=this.opts).dateFormatter)?void 0:t.call(e,n))||Et(n,_t)}getUserUA(){const e=function(e){const t=window||{},n=navigator||{},s=String(e||n.userAgent),i={os:"",osVersion:"",engine:"",browser:"",device:"",language:"",version:""},r={Trident:s.includes("Trident")||s.includes("NET CLR"),Presto:s.includes("Presto"),WebKit:s.includes("AppleWebKit"),Gecko:s.includes("Gecko/")},o={Safari:s.includes("Safari"),Chrome:s.includes("Chrome")||s.includes("CriOS"),IE:s.includes("MSIE")||s.includes("Trident"),Edge:s.includes("Edge")||s.includes("Edg"),Firefox:s.includes("Firefox")||s.includes("FxiOS"),"Firefox Focus":s.includes("Focus"),Chromium:s.includes("Chromium"),Opera:s.includes("Opera")||s.includes("OPR"),Vivaldi:s.includes("Vivaldi"),Yandex:s.includes("YaBrowser"),Kindle:s.includes("Kindle")||s.includes("Silk/"),360:s.includes("360EE")||s.includes("360SE"),UC:s.includes("UC")||s.includes(" UBrowser"),QQBrowser:s.includes("QQBrowser"),QQ:s.includes("QQ/"),Baidu:s.includes("Baidu")||s.includes("BIDUBrowser"),Maxthon:s.includes("Maxthon"),Sogou:s.includes("MetaSr")||s.includes("Sogou"),LBBROWSER:s.includes("LBBROWSER"),"2345Explorer":s.includes("2345Explorer"),TheWorld:s.includes("TheWorld"),MIUI:s.includes("MiuiBrowser"),Quark:s.includes("Quark"),Qiyu:s.includes("Qiyu"),Wechat:s.includes("MicroMessenger"),Taobao:s.includes("AliApp(TB"),Alipay:s.includes("AliApp(AP"),Weibo:s.includes("Weibo"),Douban:s.includes("com.douban.frodo"),Suning:s.includes("SNEBUY-APP"),iQiYi:s.includes("IqiyiApp")},a={Windows:s.includes("Windows"),Linux:s.includes("Linux")||s.includes("X11"),macOS:s.includes("Macintosh"),Android:s.includes("Android")||s.includes("Adr"),Ubuntu:s.includes("Ubuntu"),FreeBSD:s.includes("FreeBSD"),Debian:s.includes("Debian"),"Windows Phone":s.includes("IEMobile")||s.includes("Windows Phone"),BlackBerry:s.includes("BlackBerry")||s.includes("RIM"),MeeGo:s.includes("MeeGo"),Symbian:s.includes("Symbian"),iOS:s.includes("like Mac OS X"),"Chrome OS":s.includes("CrOS"),WebOS:s.includes("hpwOS")},l={Mobile:s.includes("Mobi")||s.includes("iPh")||s.includes("480"),Tablet:s.includes("Tablet")||s.includes("Pad")||s.includes("Nexus 7")};l.Mobile?l.Mobile=!s.includes("iPad"):o.Chrome&&s.includes("Edg")?(o.Chrome=!1,o.Edge=!0):t.showModalDialog&&t.chrome&&(o.Chrome=!1,o[360]=!0),i.device="PC",i.language=(()=>{const e=(n.browserLanguage||n.language).split("-");return e[1]&&(e[1]=e[1].toUpperCase()),e.join("_")})();const c={engine:r,browser:o,os:a,device:l};Object.entries(c).forEach((([e,t])=>{Object.entries(t).forEach((([t,n])=>{!0===n&&(i[e]=t)}))}));const d={Windows:()=>{const e=s.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:()=>s.replace(/^.*Android ([\d.]+);.*$/,"$1"),iOS:()=>s.replace(/^.*OS ([\d_]+) like.*$/,"$1").replace(/_/g,"."),Debian:()=>s.replace(/^.*Debian\/([\d.]+).*$/,"$1"),"Windows Phone":()=>s.replace(/^.*Windows Phone( OS)? ([\d.]+);.*$/,"$2"),macOS:()=>s.replace(/^.*Mac OS X ([\d_]+).*$/,"$1").replace(/_/g,"."),WebOS:()=>s.replace(/^.*hpwOS\/([\d.]+);.*$/,"$1")};i.osVersion="",d[i.os]&&(i.osVersion=d[i.os](),i.osVersion===s&&(i.osVersion=""));const h={Safari:()=>s.replace(/^.*Version\/([\d.]+).*$/,"$1"),Chrome:()=>s.replace(/^.*Chrome\/([\d.]+).*$/,"$1").replace(/^.*CriOS\/([\d.]+).*$/,"$1"),IE:()=>s.replace(/^.*MSIE ([\d.]+).*$/,"$1").replace(/^.*rv:([\d.]+).*$/,"$1"),Edge:()=>s.replace(/^.*(Edge|Edg|Edg[A-Z]{1})\/([\d.]+).*$/,"$2"),Firefox:()=>s.replace(/^.*Firefox\/([\d.]+).*$/,"$1").replace(/^.*FxiOS\/([\d.]+).*$/,"$1"),"Firefox Focus":()=>s.replace(/^.*Focus\/([\d.]+).*$/,"$1"),Chromium:()=>s.replace(/^.*Chromium\/([\d.]+).*$/,"$1"),Opera:()=>s.replace(/^.*Opera\/([\d.]+).*$/,"$1").replace(/^.*OPR\/([\d.]+).*$/,"$1"),Vivaldi:()=>s.replace(/^.*Vivaldi\/([\d.]+).*$/,"$1"),Yandex:()=>s.replace(/^.*YaBrowser\/([\d.]+).*$/,"$1"),Kindle:()=>s.replace(/^.*Version\/([\d.]+).*$/,"$1"),Maxthon:()=>s.replace(/^.*Maxthon\/([\d.]+).*$/,"$1"),QQBrowser:()=>s.replace(/^.*QQBrowser\/([\d.]+).*$/,"$1"),QQ:()=>s.replace(/^.*QQ\/([\d.]+).*$/,"$1"),Baidu:()=>s.replace(/^.*BIDUBrowser[\s/]([\d.]+).*$/,"$1"),UC:()=>s.replace(/^.*UC?Browser\/([\d.]+).*$/,"$1"),Sogou:()=>s.replace(/^.*SE ([\d.X]+).*$/,"$1").replace(/^.*SogouMobileBrowser\/([\d.]+).*$/,"$1"),"2345Explorer":()=>s.replace(/^.*2345Explorer\/([\d.]+).*$/,"$1"),TheWorld:()=>s.replace(/^.*TheWorld ([\d.]+).*$/,"$1"),MIUI:()=>s.replace(/^.*MiuiBrowser\/([\d.]+).*$/,"$1"),Quark:()=>s.replace(/^.*Quark\/([\d.]+).*$/,"$1"),Qiyu:()=>s.replace(/^.*Qiyu\/([\d.]+).*$/,"$1"),Wechat:()=>s.replace(/^.*MicroMessenger\/([\d.]+).*$/,"$1"),Taobao:()=>s.replace(/^.*AliApp\(TB\/([\d.]+).*$/,"$1"),Alipay:()=>s.replace(/^.*AliApp\(AP\/([\d.]+).*$/,"$1"),Weibo:()=>s.replace(/^.*weibo__([\d.]+).*$/,"$1"),Douban:()=>s.replace(/^.*com.douban.frodo\/([\d.]+).*$/,"$1"),Suning:()=>s.replace(/^.*SNEBUY-APP([\d.]+).*$/,"$1"),iQiYi:()=>s.replace(/^.*IqiyiVersion\/([\d.]+).*$/,"$1")};return i.version="",h[i.browser]&&(i.version=h[i.browser](),i.version===s&&(i.version="")),i.version.indexOf(".")&&(i.version=i.version.substring(0,i.version.indexOf("."))),"iOS"===i.os&&s.includes("iPad")?i.os="iPadOS":"Edge"!==i.browser||s.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:`${e.browser} ${e.version}`,os:`${e.os} ${e.osVersion}`}}getOpts(){return this.opts}}class In{constructor(e){c(this,"opts"),c(this,"$el"),c(this,"$loading"),c(this,"$text"),c(this,"offset",0),c(this,"total",0),c(this,"origText","Load More"),this.opts=e,this.origText=this.opts.text||this.origText,this.$el=vt(`<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(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()}}class Rn{constructor(){c(this,"instance"),c(this,"onReachedBottom",null),c(this,"opt")}create(e){return this.opt=e,this.instance=new In({pageSize:e.pageSize,onClick:t=>d(this,null,(function*(){e.ctx.fetch({offset:t})})),text:_t("loadMore")}),e.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(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.ctx.off("list-reach-bottom",this.onReachedBottom),this.instance.$el.remove()}}class Un{constructor(e,t){c(this,"opts"),c(this,"total"),c(this,"$el"),c(this,"$input"),c(this,"inputTimer"),c(this,"$prevBtn"),c(this,"$nextBtn"),c(this,"page",1),this.total=e,this.opts=t,this.$el=vt('<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()}get pageSize(){return this.opts.pageSize}get offset(){return this.pageSize*(this.page-1)}get maxPage(){return Math.ceil(this.total/this.pageSize)}update(e,t){this.page=Math.ceil(e/this.pageSize)+1,this.total=t,this.setInput(this.page),this.checkDisabled()}setInput(e){this.$input.value=`${e}`}input(e=!1){window.clearTimeout(this.inputTimer);const t=this.$input.value.trim(),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?zt(this.$el):Nt(this.$el)}}class qn{constructor(){c(this,"instance")}create(e){return this.instance=new Un(e.total,{pageSize:e.pageSize,onChange:t=>d(this,null,(function*(){e.ctx.editorResetState(),e.ctx.fetch({offset:t,onSuccess:()=>{e.ctx.listGotoFirst()}})}))}),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 _n(e){const t=e.getData().getListLastFetch(),n={offset:0,total:0};return t?(n.offset=t.params.offset,t.data&&(n.total=t.params.flatMode?t.data.count:t.data.roots_count),n):n}const On=e=>{let t=null;e.watchConf(["pagination","locale"],(n=>{const s=e.get("list");t&&t.dispose(),t=function(e){return e.pagination.readMore?new Rn:new qn}(n);const{offset:i,total:r}=_n(e),o=t.create({ctx:e,pageSize:n.pagination.pageSize,total:r,readMoreAutoLoad:n.pagination.autoLoad});s.$commentsWrap.after(o),null==t||t.update(i,r)})),e.on("list-loaded",(n=>{const{offset:s,total:i}=_n(e);null==t||t.update(s,i)})),e.on("list-fetch",(n=>{e.getData().getComments().length>0&&(null==t?void 0:t.getIsClearComments(n))&&e.getData().clearComments()})),e.on("list-failed",(()=>{var e;null==(e=null==t?void 0:t.showErr)||e.call(t,_t("loadFail"))})),e.on("list-fetch",(e=>{null==t||t.setLoading(!0)})),e.on("list-fetched",(({params:e})=>{null==t||t.setLoading(!1)}))};class Dn extends tn{constructor(e){super(e),c(this,"$commentsWrap"),c(this,"commentNodes",[]),this.$el=vt('<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"),On(e),this.initCrudEvents()}getCommentsWrapEl(){return this.$commentsWrap}getCommentNodes(){return this.commentNodes}getListLayout({forceFlatMode:e}={}){return new hn({$commentsWrap:this.$commentsWrap,nestSortBy:this.ctx.conf.nestSort,nestMax:this.ctx.conf.nestMax,flatMode:"boolean"==typeof e?e:this.ctx.conf.flatMode,createCommentNode:(t,n)=>{const s=function(e,t,n,s){const i=new Pn(t,{onAfterRender:()=>{e.trigger("comment-rendered",i)},onDelete:t=>{e.getData().deleteComment(t.getID())},replyTo:n,flatMode:"boolean"==typeof(null==s?void 0:s.forceFlatMode)?null==s?void 0:s.forceFlatMode:e.conf.flatMode,gravatar:e.conf.gravatar,nestMax:e.conf.nestMax,heightLimit:e.conf.heightLimit,avatarURLBuilder:e.conf.avatarURLBuilder,scrollRelativeTo:e.conf.scrollRelativeTo,vote:e.conf.vote,voteDown:e.conf.voteDown,uaBadge:e.conf.uaBadge,dateFormatter:e.conf.dateFormatter,getApi:()=>e.getApi(),replyComment:(t,n)=>e.replyComment(t,n),editComment:(t,n)=>e.editComment(t,n)});return i.render(),i}(this.ctx,t,n,{forceFlatMode:e});return this.commentNodes.push(s),s},findCommentNode:e=>this.commentNodes.find((t=>t.getID()===e))})}initCrudEvents(){this.ctx.on("list-load",(e=>{this.getListLayout().import(e)})),this.ctx.on("list-loaded",(e=>{0===e.length&&(this.commentNodes=[],this.$commentsWrap.innerHTML="")})),this.ctx.on("comment-inserted",(e=>{var t;const n=e.rid?null==(t=this.commentNodes.find((t=>t.getID()===e.rid)))?void 0:t.getData():void 0;this.getListLayout().insert(e,n)})),this.ctx.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.ctx.on("comment-updated",(e=>{const t=this.commentNodes.find((t=>t.getID()===e.id));t&&t.setData(e)}))}}let Bn,jn;function Fn(){return{init(){Bn=document.body.style.overflow,jn=document.body.style.paddingRight},unlock(){document.body.style.overflow=Bn,document.body.style.paddingRight=jn},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 s=e.offsetWidth;return n===s&&(s=t.clientWidth),document.body.removeChild(t),n-s}()+e||0}px`}}}class Wn{constructor(e,t){c(this,"allowMaskClose",!0),c(this,"onAfterHide"),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()}}class zn{constructor(){c(this,"$wrap"),c(this,"$mask"),c(this,"items",[]),this.$wrap=vt('<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 Wn(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"),Fn().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",Fn().unlock())}}class Nn{constructor(e){c(this,"wrap"),this.wrap=new zn,document.body.appendChild(this.wrap.getWrap()),e.on("unmounted",(()=>{this.wrap.getWrap().remove()})),Fn().init()}getEl(){return this.wrap.getWrap()}create(e,t){return this.wrap.createItem(e,t)}}const Hn="ArtalkUser";class Qn{constructor(e){c(this,"data"),this.opts=e;const t=JSON.parse(window.localStorage.getItem(Hn)||"{}");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})),window.localStorage.setItem(Hn,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 Vn={i18n(e){qt(e.conf.locale),e.watchConf(["locale"],(e=>{qt(e.locale)}))},user:e=>new Qn({onUserChanged:t=>{e.trigger("user-changed",t)}}),layerManager:e=>new Nn(e),checkerLauncher:e=>new en({getCtx:()=>e,getApi:()=>e.getApi(),onReload:()=>e.reload(),getCaptchaIframeURL:()=>`${e.conf.server}/api/v2/captcha/?t=${+new Date}`}),editor(e){const t=new an(e);return e.$root.appendChild(t.$el),t},list(e){const t=new Dn(e);return e.$root.appendChild(t.$el),t},sidebarLayer:e=>new ln(e),editorPlugs(){}};function Gn(e){return d(this,null,(function*(){yield function(e){return d(this,null,(function*(){yield Kn({opt:e,query:"page_comment",containers:[e.countEl,"#ArtalkCount"]})}))}(e);const t=yield function(e){return d(this,null,(function*(){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}}))}(e);yield function(e,t){return d(this,null,(function*(){yield Kn({opt:e,query:"page_pv",containers:[e.pvEl,"#ArtalkPV"],cache:t})}))}(e,t)}))}function Kn(e){return d(this,null,(function*(){const{opt:t}=e;let n=e.cache||{};const s=function(e){const t=new Set;return new Set(e).forEach((e=>{document.querySelectorAll(e).forEach((e=>t.add(e)))})),t}(e.containers),i=function(e,t,n,s){const i=Array.from(e).map((e=>e.getAttribute(t)||n)).filter((e=>e&&"number"!=typeof s[e]));return[...new Set(i)]}(s,t.pageKeyAttr,t.pageKey,n);if(i.length>0){const s=(yield t.getApi().stats.getStats(e.query,{page_keys:i.join(","),site_name:t.siteName})).data.data;n=a(a({},n),s)}!function(e,t,n){e.forEach((e=>{const s=e.getAttribute("data-page-key"),i=s&&t[s]||n&&t[n]||0;e.innerText=`${Number(i)}`}))}(s,n,t.pageKey)}))}const Zn="ArtalkContent";class Yn{constructor(e){this.kit=e}reqAdd(){return d(this,null,(function*(){return(yield this.kit.useApi().comments.createComment(a({},yield this.getSubmitAddParams()))).data}))}getSubmitAddParams(){return d(this,null,(function*(){const{name:e,email:t,link:n}=this.kit.useUser().getData(),s=this.kit.useConf();return{content:this.kit.useEditor().getContentFinal(),name:e,email:t,link:n,rid:0,page_key:s.pageKey,page_title:s.pageTitle,site_name:s.site,ua:yield St()}}))}postSubmitAdd(e){this.kit.useGlobalCtx().getData().insertComment(e)}}class Xn extends sn{constructor(e){super(e),c(this,"customs",[]),c(this,"defaultPreset"),this.defaultPreset=new Yn(this.kit);const t=()=>this.do();this.kit.useMounted((()=>{this.kit.useGlobalCtx().on("editor-submit",t)})),this.kit.useUnmounted((()=>{this.kit.useGlobalCtx().off("editor-submit",t)}))}registerCustom(e){this.customs.push(e)}do(){return d(this,null,(function*(){if(""===this.kit.useEditor().getContentFinal().trim())return void this.kit.useEditor().focus();const e=this.customs.find((e=>e.activeCond()));this.kit.useEditor().showLoading();try{let t;(null==e?void 0:e.pre)&&e.pre(),t=(null==e?void 0:e.req)?yield e.req():yield this.defaultPreset.reqAdd(),(null==e?void 0:e.post)?e.post(t):this.defaultPreset.postSubmitAdd(t)}catch(t){return console.error(t),void this.kit.useEditor().showNotify(`${_t("commentFail")}: ${t.message||String(t)}`,"e")}finally{this.kit.useEditor().hideLoading()}this.kit.useEditor().reset(),this.kit.useGlobalCtx().trigger("editor-submitted")}))}}class Jn extends sn{constructor(e){super(e),c(this,"emoticons",[]),c(this,"loadingTask",null),c(this,"$grpWrap"),c(this,"$grpSwitcher"),c(this,"isListLoaded",!1),c(this,"isImgLoaded",!1),this.kit.useMounted((()=>{this.usePanel('<div class="atk-editor-plug-emoticons"></div>'),this.useBtn(`<i aria-label="${_t("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((()=>{(()=>{d(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 d(this,null,(function*(){this.isListLoaded||(null===this.loadingTask?(this.loadingTask=(()=>d(this,null,(function*(){zt(this.$panel),this.emoticons=yield this.handleData(this.kit.useConf().emoticons),Nt(this.$panel),this.loadingTask=null,this.isListLoaded=!0})))(),yield this.loadingTask):yield this.loadingTask)}))}handleData(e){return d(this,null,(function*(){if(!Array.isArray(e)&&["object","string"].includes(typeof e)&&(e=[e]),!Array.isArray(e))return Gt(this.$panel,`[${_t("emoticon")}] Data must be of Array/Object/String type`),Nt(this.$panel),[];const t=t=>{"object"==typeof t&&(t.name&&e.find((e=>e.name===t.name))||e.push(t))},n=e=>d(this,null,(function*(){yield Promise.all(e.map(((e,s)=>d(this,null,(function*(){if("object"!=typeof e||Array.isArray(e)){if(Array.isArray(e))yield n(e);else if("string"==typeof e){const s=yield this.remoteLoad(e);Array.isArray(s)?yield n(s):"object"==typeof s&&t(s)}}else t(e)})))))}));return yield n(e),e.forEach((e=>{if(this.isOwOFormat(e)){this.convertOwO(e).forEach((e=>{t(e)}))}else Array.isArray(e)&&e.forEach((e=>{t(e)}))})),e=e.filter((e=>"object"==typeof e&&!Array.isArray(e)&&!!e&&!!e.name)),this.solveNullKey(e),this.solveSameKey(e),e}))}remoteLoad(e){return d(this,null,(function*(){if(!e)return[];try{const t=yield fetch(e);return yield t.json()}catch(t){return Nt(this.$panel),console.error("[Emoticons] Load Failed:",t),Gt(this.$panel,`[${_t("emoticon")}] ${_t("loadFail")}: ${String(t)}`),[]}}))}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 s={name:e,type:n.type,items:[]};n.container.forEach(((t,n)=>{const i=t.icon;if(/<(img|IMG)/.test(i)){const e=/src=["'](.*?)["']/.exec(i);e&&e.length>1&&(t.icon=e[1])}s.items.push({key:t.text||`${e} ${n+1}`,val:t.icon})})),t.push(s)})),t}initEmoticonsList(){this.$grpWrap=vt('<div class="atk-grp-wrap"></div>'),this.$panel.append(this.$grpWrap),this.emoticons.forEach(((e,t)=>{const n=vt('<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 s=vt('<span class="atk-item"></span>');if(n.append(s),t.key&&!new RegExp(`^(${e.name})?\\s?[0-9]+$`).test(t.key)&&s.setAttribute("title",t.key),"image"===e.type){const e=document.createElement("img");e.src=t.val,e.alt=t.key,s.append(e)}else s.innerText=t.val;s.onclick=()=>{"image"===e.type?this.kit.useEditor().insertContent(`:[${t.key}]`):this.kit.useEditor().insertContent(t.val||"")}}))})),this.emoticons.length>1&&(this.$grpSwitcher=vt('<div class="atk-grp-switcher"></div>'),this.$panel.append(this.$grpSwitcher),this.emoticons.forEach(((e,t)=>{const n=vt("<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,s;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)||t.querySelectorAll("span.active").forEach((e=>e.classList.remove("active"))),null==(s=null==(n=this.$grpSwitcher)?void 0:n.querySelector(`span[data-index="${e}"]`))||s.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}}const es=["png","jpg","jpeg","gif","bmp","svg","webp"];class ts extends sn{constructor(e){super(e),c(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=es.map((e=>`.${e}`)).join(",");const e=this.useBtn(`<i aria-label="${_t("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>`);e.after(this.$imgUploadInput),e.onclick=()=>{const e=this.$imgUploadInput;e.onchange=()=>{(()=>{d(this,null,(function*(){if(!e.files||0===e.files.length)return;const t=e.files[0];this.uploadImg(t)}))})()},e.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 s=null==(n=t.dataTransfer)?void 0:n.files;(null==s?void 0:s.length)&&(t.preventDefault(),e(s))},s=t=>{var n;const s=null==(n=t.clipboardData)?void 0:n.files;(null==s?void 0:s.length)&&(t.preventDefault(),e(s))};this.kit.useMounted((()=>{this.kit.useUI().$textarea.addEventListener("dragover",t),this.kit.useUI().$textarea.addEventListener("drop",n),this.kit.useUI().$textarea.addEventListener("paste",s)})),this.kit.useUnmounted((()=>{this.kit.useUI().$textarea.removeEventListener("dragover",t),this.kit.useUI().$textarea.removeEventListener("drop",n),this.kit.useUI().$textarea.removeEventListener("paste",s)}))}uploadImg(e){return d(this,null,(function*(){const t=/[^.]+$/.exec(e.name);if(!t||!es.includes(String(t[0]).toLowerCase()))return;if(!this.kit.useUser().checkHasBasicUserInfo())return void this.kit.useEditor().showNotify(_t("uploadLoginMsg"),"w");let n="\n";""===this.kit.useUI().$textarea.value.trim()&&(n="");const s=`${n}`;let i;this.kit.useEditor().insertContent(s);try{const t=this.kit.useConf().imgUploader;i=t?{public_url:yield t(e)}:(yield this.kit.useApi().upload.upload({file:e})).data}catch(r){console.error(r),this.kit.useEditor().showNotify(`${_t("uploadFail")}: ${r.message}`,"e")}if(i&&i.public_url){let e=i.public_url;Tt(e)||(e=At({base:this.kit.useConf().server,path:e})),this.kit.useEditor().setContent(this.kit.useUI().$textarea.value.replace(s,`${n}`))}else this.kit.useEditor().setContent(this.kit.useUI().$textarea.value.replace(s,""))}))}}class ns extends sn{constructor(e){super(e),c(this,"isPlugPanelShow",!1),this.kit.useMounted((()=>{this.usePanel('<div class="atk-editor-plug-preview"></div>'),this.useBtn(`<i aria-label="${_t("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()}}const ss=[class extends sn{constructor(e){super(e);const t=()=>{this.save()};this.kit.useMounted((()=>{const e=window.localStorage.getItem(Zn)||"";""!==e.trim()&&(this.kit.useEditor().showNotify(_t("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(Zn,this.kit.useEditor().getContentRaw().trim())}},class extends sn{get $inputs(){return this.kit.useEditor().getHeaderInputEls()}constructor(e){super(e);const t={},n={},s=(e,t,n)=>()=>{this.kit.useEvents().trigger(e,{field:n,$input:t})};this.kit.useMounted((()=>{Object.entries(this.$inputs).forEach((([e,i])=>{i.addEventListener("input",t[e]=s("header-input",i,e)),i.addEventListener("change",n[e]=s("header-change",i,e))}))})),this.kit.useUnmounted((()=>{Object.entries(this.$inputs).forEach((([e,s])=>{s.removeEventListener("input",t[e]),s.removeEventListener("change",n[e])}))}))}},class extends sn{constructor(e){super(e),c(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:_t("nick"),email:_t("email"),link:_t("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(a({},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.useGlobalCtx().getData().updateNotifies(e.notifies),this.kit.useUser().checkHasBasicUserInfo()&&!e.is_login&&(null==(t=e.user)?void 0:t.is_admin)&&this.kit.useGlobalCtx().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 sn{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 sn{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||_t("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`}},Xn,class extends sn{constructor(e){super(e);const t=()=>{this.kit.useEditor().submit()};this.kit.useMounted((()=>{this.kit.useUI().$submitBtn.innerText=this.kit.useConf().sendBtn||_t("send"),this.kit.useUI().$submitBtn.addEventListener("click",t)})),this.kit.useUnmounted((()=>{this.kit.useUI().$submitBtn.removeEventListener("click",t)}))}},rn,class extends sn{constructor(e){super(e),c(this,"comment"),this.useEditorStateEffect("reply",(e=>(this.setReply(e),()=>{this.cancelReply()}))),this.kit.useEvents().on("mounted",(()=>{const e=this.kit.useDeps(Xn);if(!e)throw Error("SubmitPlug not initialized");const t=new Yn(this.kit);e.registerCustom({activeCond:()=>!!this.comment,req:()=>d(this,null,(function*(){if(!this.comment)throw new Error("reply comment cannot be empty");return(yield this.kit.useApi().comments.createComment(l(a({},yield t.getSubmitAddParams()),{rid:this.comment.id,page_key:this.comment.page_key,page_title:void 0,site_name:this.comment.site_name}))).data})),post:e=>{const n=this.kit.useConf();e.page_key!==n.pageKey&&window.open(`${e.page_url}#atk-comment-${e.id}`),t.postSubmitAdd(e)}})}))}setReply(e){const t=this.kit.useUI();if(!t.$sendReplyBtn){const n=vt(`<span class="atk-state-btn"><span class="atk-text-wrap">${_t("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 sn{constructor(e){super(e),c(this,"comment"),c(this,"originalSubmitBtnText","Send"),this.useEditorStateEffect("edit",(e=>(this.edit(e),()=>{this.cancelEdit()}))),this.kit.useMounted((()=>{const e=this.kit.useDeps(Xn);if(!e)throw Error("SubmitPlug not initialized");e.registerCustom({activeCond:()=>!!this.comment,req:()=>d(this,null,(function*(){const e={content:this.kit.useEditor().getContentFinal(),nick:this.kit.useUI().$name.value,email:this.kit.useUI().$email.value,link:this.kit.useUI().$link.value},t=this.comment;return(yield this.kit.useApi().comments.updateComment(t.id,a(a({},t),e))).data})),post:e=>{this.kit.useGlobalCtx().getData().updateComment(e)}})}))}edit(e){const t=this.kit.useUI();if(!t.$editCancelBtn){const e=vt(`<span class="atk-state-btn"><span class="atk-text-wrap">${_t("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(_t("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:s}=this.kit.useUser().getData();e.$name.value=t,e.$email.value=n,e.$link.value=s,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 sn{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"))||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(vt(`<div class="atk-comment-closed">${_t("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")}},Jn,ts,ns];class is{constructor(e){this.plugs=e}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(e){this.useEvents().on("mounted",e)}useUnmounted(e){this.useEvents().on("unmounted",e)}useDeps(e){return this.plugs.get(e)}}class rs{constructor(e){c(this,"plugs",[]),c(this,"openedPlug",null),c(this,"events",new Ot),this.editor=e;let t=!1;this.editor.ctx.watchConf(["imgUpload","emoticons","preview","editorTravel","locale"],(e=>{t&&this.getEvents().trigger("unmounted"),this.clear(),function(e){const t=new Map;return t.set(ts,e.imgUpload),t.set(Jn,e.emoticons),t.set(ns,e.preview),t.set(rn,e.editorTravel),ss.filter((e=>!t.has(e)||!!t.get(e)))}(e).forEach((e=>{const t=new is(this);this.plugs.push(new e(t))})),this.getEvents().trigger("mounted"),t=!0,this.loadPluginUI()})),this.events.on("panel-close",(()=>this.closePlugPanel()))}getPlugs(){return this.plugs}getEvents(){return this.events}clear(){this.plugs=[],this.events=new Ot,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((e=>this.loadPluginItem(e)))}loadPluginItem(e){const t=e.$btn;if(!t)return;this.editor.getUI().$plugBtnWrap.appendChild(t),!t.onclick&&(t.onclick=()=>{this.editor.getUI().$plugBtnWrap.querySelectorAll(".active").forEach((e=>e.classList.remove("active"))),e!==this.openedPlug?(this.openPlugPanel(e),t.classList.add("active")):this.closePlugPanel()});const n=e.$panel;n&&(n.style.display="none",this.editor.getUI().$plugPanelWrap.appendChild(n))}get(e){return this.plugs.find((t=>t instanceof e))}openPlugPanel(e){this.plugs.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.editor.getUI().$plugPanelWrap.style.display="",this.openedPlug=e}closePlugPanel(){this.openedPlug&&(this.editor.getUI().$plugPanelWrap.style.display="none",this.events.trigger("panel-hide",this.openedPlug),this.openedPlug=null)}getTransformedContent(e){let t=e;return this.plugs.forEach((e=>{e.contentTransformer&&(t=e.contentTransformer(t))})),t}}const os="2.9.0";function as(e){const t=vt('<span><span class="error-message"></span><br/><br/></span>');if(t.querySelector(".error-message").innerText=`${_t("listLoadFailMsg")}\n${e.errMsg}`,e.retryFn){const n=vt(`<span style="cursor:pointer;">${_t("listRetry")}</span>`);n.onclick=()=>e.retryFn&&e.retryFn(),t.appendChild(n)}if(e.onOpenSidebar){const n=vt(`<span atk-only-admin-show> | <span style="cursor:pointer;">${_t("openName",{name:_t("ctrlCenter")})}</span></span>`);t.appendChild(n),n.onclick=()=>e.onOpenSidebar&&e.onOpenSidebar()}Gt(e.$err,t)}let ls=!1;let cs;function ds(e,t){const n="atk-dark-mode";e.forEach((e=>{t?e.classList.add(n):e.classList.remove(n)}))}const hs=[e=>{e.watchConf(["imgLazyLoad","markedOptions"],(t=>{!function(e){try{if(!we.name)return}catch(n){return}const t=new we;t.setOptions(a(a({renderer:ct({imgLazyLoad:e.imgLazyLoad})},mt),e.markedOptions)),pt=t}({markedOptions:e.getConf().markedOptions,imgLazyLoad:e.getConf().imgLazyLoad})})),e.watchConf(["markedReplacers"],(e=>{var t;e.markedReplacers&&(t=e.markedReplacers,gt=t)}))},e=>{const t=e.get("editor"),n=new rs(t);e.inject("editorPlugs",n)},e=>{const t=()=>{var t;t=e.get("user").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.$root}).forEach((e=>{t?e.classList.remove("atk-hide"):e.classList.add("atk-hide")}))};e.on("list-loaded",(()=>{t()})),e.on("user-changed",(e=>{t()}))},...[e=>{e.on("list-fetch",(t=>{if(e.getData().getLoading())return;e.getData().setLoading(!0);const n=a({offset:0,limit:e.conf.pagination.pageSize,flatMode:e.conf.flatMode,paramsModifier:e.conf.listFetchParamsModifier},t);e.getData().setListLastFetch({params:n});const s={limit:n.limit,offset:n.offset,flat_mode:n.flatMode,page_key:e.getConf().pageKey,site_name:e.getConf().site};n.paramsModifier&&n.paramsModifier(s),e.getApi().comments.getComments(a(a({},s),e.getApi().getUserFields())).then((({data:t})=>{e.getData().setListLastFetch({params:n,data:t}),e.getData().loadComments(t.comments),e.getData().updatePage(t.page),n.onSuccess&&n.onSuccess(t),e.trigger("list-fetched",{params:n,data:t})})).catch((t=>{const s={msg:t.msg||String(t),data:t.data};throw n.onError&&n.onError(s),e.trigger("list-failed",s),e.trigger("list-fetched",{params:n,error:s}),t})).finally((()=>{e.getData().setLoading(!1)}))}))},e=>{e.on("list-fetch",(t=>{const n=e.get("list");0===t.offset&&Ht(!0,n.$el)})),e.on("list-fetched",(()=>{Ht(!1,e.get("list").$el)}))},e=>{e.on("comment-rendered",(t=>{if(!0===e.conf.listUnreadHighlight){const n=e.getData().getNotifies(),s=n.find((e=>e.comment_id===t.getID()));s?(t.getRender().setUnread(!0),t.getRender().setOpenAction((()=>{window.open(s.read_link),e.getData().updateNotifies(n.filter((e=>e.comment_id!==t.getID())))}))):t.getRender().setUnread(!1)}})),e.on("list-goto",(t=>{const n=bt("atk_notify_key");n&&e.getApi().notifies.markNotifyRead(t,n).then((()=>{e.getData().updateNotifies(e.getData().getNotifies().filter((e=>e.comment_id!==t)))}))}))},e=>{let t;e.on("mounted",(()=>{const n=e.get("list");t=n.$el.querySelector('[data-action="admin-close-comment"]'),t.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(`${_t("editFail")}: ${t.message||String(t)}`,"e")})).finally((()=>{e.editorHideLoading()}))}(e,t)}))})),e.on("page-loaded",(n=>{var s,i;const r=e.get("editor");!0===(null==n?void 0:n.admin_only)?(null==(s=r.getPlugs())||s.getEvents().trigger("editor-close"),t&&(t.innerText=_t("openComment"))):(null==(i=r.getPlugs())||i.getEvents().trigger("editor-open"),t&&(t.innerText=_t("closeComment")))})),e.on("list-loaded",(t=>{e.editorResetState()}))},e=>{e.on("list-loaded",(()=>{(()=>{var t,n;const s=e.get("list").$el.querySelector(".atk-comment-count .atk-text");if(!s)return;const i=wt(_t("counter",{count:`${Number(null==(n=null==(t=e.getData().getListLastFetch())?void 0:t.data)?void 0:n.count)||0}`}));s.innerHTML=i.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=>{let t=null;const n=()=>{if(!t)return;const n=e.get("user").getData();if(n.name&&n.email){t.classList.remove("atk-hide");const e=t.querySelector(".atk-text");e&&(e.innerText=n.is_admin?_t("ctrlCenter"):_t("msgCenter"))}else t.classList.add("atk-hide")};e.watchConf(["locale"],(s=>{const i=e.get("list");t=i.$el.querySelector('[data-action="open-sidebar"]'),t&&(t.onclick=()=>{e.showSidebar()},n())})),e.on("user-changed",(e=>{n()}))},e=>{let t=null;e.on("mounted",(()=>{const n=e.get("list");t=n.$el.querySelector(".atk-unread-badge")})),e.on("notifies-updated",(e=>{var n;n=e.length||0,t&&(n>0?(t.innerText=`${Number(n||0)}`,t.style.display="block"):t.style.display="none")}))},e=>{const t=t=>{e.conf.listFetchParamsModifier=t,e.reload()},n=e=>{!function(e){const{$dropdownWrap:t,dropdownList:n}=e;if(t.querySelector(".atk-dropdown"))return;t.classList.add("atk-dropdown-wrap"),t.append(vt('<span class="atk-arrow-down-icon"></span>'));let s=0;const i=(e,t,n,i)=>{i(),s=e,r.querySelectorAll(".active").forEach((e=>{e.classList.remove("active")})),t.classList.add("active"),r.style.display="none",setTimeout((()=>{r.style.display=""}),80)},r=vt('<ul class="atk-dropdown atk-fade-in"></ul>');n.forEach(((e,t)=>{const[n,o]=e,a=vt('<li class="atk-dropdown-item"><span></span></li>'),l=a.querySelector("span");l.innerText=n,l.onclick=()=>{i(t,a,n,o)},r.append(a),t===s&&a.classList.add("active")})),t.append(r)}({$dropdownWrap:e,dropdownList:[[_t("sortLatest"),()=>{t((e=>{e.sort_by="date_desc"}))}],[_t("sortBest"),()=>{t((e=>{e.sort_by="vote"}))}],[_t("sortOldest"),()=>{t((e=>{e.sort_by="date_asc"}))}],[_t("sortAuthor"),()=>{t((e=>{e.view_only_admin=!0}))}]]})};e.watchConf(["listSort","locale"],(t=>{const s=e.get("list").$el.querySelector(".atk-comment-count");s&&(t.listSort?n(s):function(e){var t,n;const{$dropdownWrap:s}=e;s.classList.remove("atk-dropdown-wrap"),null==(t=s.querySelector(".atk-arrow-down-icon"))||t.remove(),null==(n=s.querySelector(".atk-dropdown"))||n.remove()}({$dropdownWrap:s}))}))},e=>{let t=0;const n=({locker:n})=>{const s=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(bt("atk_comment")));return t||null}();s&&(n&&t===s||(t=s,e.trigger("list-goto",s)))},s=()=>n({locker:!1}),i=()=>n({locker:!0});e.on("mounted",(()=>{window.addEventListener("hashchange",s),e.on("list-loaded",i)})),e.on("unmounted",(()=>{window.removeEventListener("hashchange",s),e.off("list-loaded",i)}))},e=>{e.on("list-goto",(t=>d(exports,null,(function*(){let n=e.getCommentNodes().find((e=>e.getID()===t));if(!n){const s=(yield e.getApi().comments.getComment(t)).data;e.get("list").getListLayout({forceFlatMode:!0}).insert(s.comment,s.reply_comment),n=e.getCommentNodes().find((e=>e.getID()===t))}n&&n.focus()}))))},e=>{e.on("list-loaded",(t=>{const n=e.get("list"),s=t.length<=0;let i=n.getCommentsWrapEl().querySelector(".atk-list-no-comment");s?i||(i=vt('<div class="atk-list-no-comment"></div>'),i.innerHTML=rt(n.ctx.conf.noComment||n.ctx.$t("noComment")),n.getCommentsWrapEl().appendChild(i)):null==i||i.remove()}))},e=>{e.on("mounted",(()=>{const t=e.get("list").$el.querySelector(".atk-copyright");t&&(t.innerHTML=`Powered By <a href="https://artalk.js.org" target="_blank" title="Artalk v${os}">Artalk</a>`)}))},e=>{let t=null;e.on("mounted",(()=>{t=window.setInterval((()=>{e.get("list").$el.querySelectorAll("[data-atk-comment-date]").forEach((t=>{var n,s;const i=new Date(Number(t.getAttribute("data-atk-comment-date")));t.innerText=(null==(s=(n=e.getConf()).dateFormatter)?void 0:s.call(n,i))||Et(i,e.$t)}))}),3e4)})),e.on("unmounted",(()=>{t&&window.clearInterval(t)}))},e=>{e.on("list-fetch",(()=>{Gt(e.get("list").$el,null)})),e.on("list-failed",(t=>{as({$err:e.get("list").$el,errMsg:t.msg,errData:t.data,retryFn:()=>e.fetch({offset:0})})}))},e=>{let t=null;const n=()=>{null==t||t.disconnect(),t=null};e.on("list-loaded",(()=>{n();const s=e.get("list").getCommentsWrapEl().childNodes,i=s.length>2?s[s.length-2]:null;i&&("IntersectionObserver"in window?(s=>{const i=e.conf.scrollRelativeTo&&e.conf.scrollRelativeTo()||null;t=new IntersectionObserver((([t])=>{t.isIntersecting&&(n(),e.trigger("list-reach-bottom"))}),{threshold:.9,root:i}),t.observe(s)})(i):console.warn("IntersectionObserver api not supported"))})),e.on("unmounted",(()=>{n()}))},e=>{const t=()=>{const t=e.get("list"),n=e.conf.scrollRelativeTo&&e.conf.scrollRelativeTo();(n||window).scroll({top:xt(t.$el,n).top,left:0})};e.on("mounted",(()=>{e.on("list-goto-first",t)})),e.on("unmounted",(()=>{e.off("list-goto-first",t)}))}],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"],(t=>{Gn({getApi:()=>e.getApi(),siteName:t.site,pageKey:t.pageKey,pageTitle:t.pageTitle,countEl:t.countEl,pvEl:t.pvEl,pageKeyAttr:t.statPageKeyAttr,pvAdd:"boolean"!=typeof e.conf.pvAdd||e.conf.pvAdd})}))},e=>{e.watchConf(["apiVersion","versionCheck"],(t=>{const n=e.get("list");t.apiVersion&&t.versionCheck&&!ls&&function(e,t,n){const s=function(e,t){const n=e.split("."),s=t.split(".");for(let i=0;i<3;i++){const e=Number(n[i]),t=Number(s[i]);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===s)return;const i=vt(`<div class="atk-version-check-notice">${_t("updateMsg",{name:_t(s<0?"frontend":"backend")})} <span class="atk-info">${_t("currentVersion")}: ${_t("frontend")} ${t} / ${_t("backend")} ${n}</span></div>`),r=vt(`<span class="atk-ignore-btn">${_t("ignore")}</span>`);r.onclick=()=>{i.remove(),ls=!0},i.append(r),e.$el.parentElement.prepend(i)}(n,os,t.apiVersion)}))},e=>{let t;const n=n=>{const s=[e.$root,e.get("layerManager").getEl()];cs||(cs=window.matchMedia("(prefers-color-scheme: dark)")),"auto"===n?(t||(t=e=>ds(s,e.matches),cs.addEventListener("change",t)),ds(s,cs.matches)):(t&&(cs.removeEventListener("change",t),t=void 0),ds(s,n))};e.watchConf(["darkMode"],(e=>n(e.darkMode))),e.on("created",(()=>n(e.conf.darkMode))),e.on("unmounted",(()=>{t&&(null==cs||cs.removeEventListener("change",t)),t=void 0}))}],us=new Set([...hs]),ps=new WeakMap;function gs(e){return d(this,null,(function*(){var t;const n=new Set,s=t=>{t.forEach((t=>{"function"!=typeof t||n.has(t)||(t(e,ps.get(t)),n.add(t))}))};s(us);const{data:i}=yield e.getApi().conf.conf().catch((t=>{throw function(e,t){var n;let s="";if(null==(n=t.data)?void 0:n.err_no_site){const t={create_name:e.conf.site,create_urls:`${window.location.protocol}//${window.location.host}`};s=`sites|${JSON.stringify(t)}`}as({$err:e.get("list").$el,errMsg:t.msg||String(t),errData:t.data,retryFn:()=>gs(e),onOpenSidebar:e.get("user").getData().is_admin?()=>e.showSidebar({view:s}):void 0})}(e,t),t}));let r={apiVersion:null==(t=i.version)?void 0:t.version};if(e.conf.useBackendConf){if(!i.frontend_conf)throw new Error("The remote backend does not respond to the frontend conf, but `useBackendConf` conf is enabled");r=a(a({},r),function(e){const t=["el","pageKey","pageTitle","server","site","pvEl","countEl","statPageKeyAttr"];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}(i.frontend_conf))}e.conf.remoteConfModifier&&e.conf.remoteConfModifier(r),r.pluginURLs&&(yield function(e,t){return d(this,null,(function*(){const n=new Set;if(!e||!Array.isArray(e))return n;const s=[];return e.forEach((e=>{/^(http|https):\/\//.test(e)||(e=`${t.replace(/\/$/,"")}/${e.replace(/^\//,"")}`),s.push(new Promise(((t,n)=>{if(document.querySelector(`script[src="${e}"]`))return void t();const s=document.createElement("script");s.src=e,document.head.appendChild(s),s.onload=()=>t(),s.onerror=e=>n(e)})))})),yield Promise.all(s),Object.values(window.ArtalkPlugins||{}).forEach((e=>{"function"==typeof e&&n.add(e)})),n}))}(r.pluginURLs,e.conf.server).then((e=>{s(e)})).catch((e=>{console.error("Failed to load plugin",e)}))),e.trigger("created"),e.updateConf(r),e.trigger("mounted"),e.conf.remoteConfModifier||e.fetch({offset:0})}))}class ms{constructor(e){c(this,"ctx");const t=Bt(e,!0);this.ctx=new Wt(t),Object.entries(Vn).forEach((([e,t])=>{const n=t(this.ctx);n&&this.ctx.inject(e,n)})),gs(this.ctx)}getConf(){return this.ctx.getConf()}getEl(){return this.ctx.$root}update(e){return this.ctx.updateConf(e),this}reload(){this.ctx.reload()}destroy(){for(this.ctx.trigger("unmounted");this.ctx.$root.firstChild;)this.ctx.$root.removeChild(this.ctx.$root.firstChild)}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(e){return new ms(e)}static use(e,t){us.add(e),ps.set(e,t)}static loadCountWidget(e){const t=Bt(e,!0);Gn({getApi:()=>new m(jt(t)),siteName:t.site,countEl:t.countEl,pvEl:t.pvEl,pageKeyAttr:t.statPageKeyAttr,pvAdd:!1})}get $root(){return this.ctx.$root}get conf(){return this.ctx.getConf()}}const fs=ms.init,ks=ms.use,ys=ms.loadCountWidget;exports.default=ms,exports.init=fs,exports.loadCountWidget=ys,exports.use=ks;
|
|
11
|
-
//# sourceMappingURL=Artalk.cjs.map
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,s=Object.getPrototypeOf,r=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),a=(o,a,l)=>(l=null!=o?e(s(o)):{},((e,s,o,a)=>{if(s&&"object"==typeof s||"function"==typeof s)for(var l,c=i(s),d=0,u=c.length;d<u;d++)l=c[d],r.call(e,l)||l===o||t(e,l,{get:(e=>s[e]).bind(null,l),enumerable:!(a=n(s,l))||a.enumerable});return e})(!a&&o&&o.__esModule?l:t(l,"default",{value:o,enumerable:!0}),o));function l(e,t,n,i,s,r,o){try{var a=e[r](o),l=a.value}catch(e){return void n(e)}a.done?t(l):Promise.resolve(l).then(i,s)}function c(e){return function(){var t=this,n=arguments;return new Promise(function(i,s){var r=e.apply(t,n);function o(e){l(r,i,s,o,a,"next",e)}function a(e){l(r,i,s,o,a,"throw",e)}o(void 0)})}}function d(e=""){const t=document.createElement("div");return t.innerHTML=e.trim(),t.firstElementChild||t}function u(e){const t=document.createElement("div");return t.innerText=e,t.innerHTML}function h(e){const t=RegExp(`[?&]${e}=([^&]*)`).exec(window.location.search);return t&&decodeURIComponent(t[1].replace(/\+/g," "))}function p(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 s=n(t);return{top:i.top-s.top,left:i.left-s.left}}function g(e,t){let n=e.toString();for(;n.length<t;)n=`0${n}`;return n}function m(e,t=e=>e){try{const n=e.getTime(),i=(new Date).getTime()-n,s=Math.floor(i/864e5);if(0===s){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 s<0?t("now"):s<8?`${s} ${t("days")}`:function(e){const t=g(e.getDate(),2),n=g(e.getMonth()+1,2);return`${g(e.getFullYear(),2)}-${n}-${t}`}(e)}catch(n){return console.error(n)," - "}}function f(){return k.apply(this,arguments)}function k(){return(k=c(function*(){const e=navigator.userAgent;if(!navigator.userAgentData||!navigator.userAgentData.getHighEntropyValues)return e;const t=navigator.userAgentData;let n;try{n=yield t.getHighEntropyValues(["platformVersion"])}catch(s){return console.error(s),e}const i=Number(n.platformVersion.split(".")[0]);return"Windows"===t.platform&&i>=13?e.replace(/Windows NT 10.0/,"Windows NT 11.0"):"macOS"===t.platform&&i>=11?e.replace(/(Mac OS X \d+_\d+_\d+|Mac OS X)/,`Mac OS X ${n.platformVersion.replace(/\./g,"_")}`):e})).apply(this,arguments)}function y(e){let t;try{t=new URL(e)}catch(M){return!1}return"http:"===t.protocol||"https:"===t.protocol}function v(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}"},w={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 $(e){return e=e.replace(/^([a-zA-Z]+)(-[a-zA-Z]+)?$/,(e,t,n)=>t.toLowerCase()+(n||"").toUpperCase()),w[e]?w[e]:window.ArtalkI18n&&window.ArtalkI18n[e]?window.ArtalkI18n[e]:w.en}var x,E="en",S=$(E);function C(e,t={}){let n=(null==S?void 0:S[e])||e;return n=n.replace(/\{\s*(\w+?)\s*\}/g,(e,n)=>t[n]||""),u(n)}function T(e){return T="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},T(e)}function A(e){var t=function(e,t){if("object"!=T(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t||"default");if("object"!=T(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==T(t)?t:t+""}function L(e,t,n){return(t=A(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function R(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 P(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?R(Object(n),!0).forEach(function(t){L(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):R(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function _(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var O={async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null};function I(e){O=e}var M={exec:()=>null};function D(e){let t=[];return n=>{let i=Math.max(0,Math.min(3,n-1)),s=t[i];return s||(s=e(i),t[i]=s),s}}function N(e,t=""){let n="string"==typeof e?e:e.source,i={replace:(e,t)=>{let s="string"==typeof t?t:t.source;return s=s.replace(j.caret,"$1"),n=n.replace(e,s),i},getRegex:()=>new RegExp(n,t)};return i}var U=((e="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+e)}catch(t){return!1}})(),j={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:new RegExp("[\\p{L}\\p{N}]","u"),escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>new RegExp(`^( {0,3}${e})((?:[\t ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:D(e=>new RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ \t][^\\n]*)?(?:\\n|$))`)),hrRegex:D(e=>new RegExp(`^ {0,${e}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:D(e=>new RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:D(e=>new RegExp(`^ {0,${e}}#`)),htmlBeginRegex:D(e=>new RegExp(`^ {0,${e}}<(?:[a-z].*>|!--)`,"i")),blockquoteBeginRegex:D(e=>new RegExp(`^ {0,${e}}>`))},B=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,q=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,F=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,z=N(F).replace(/bull/g,q).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),W=N(F).replace(/bull/g,q).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),H=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,G=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,V=N(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",G).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Q=N(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,q).getRegex(),K="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Y=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Z=N("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n*|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>[^\\n]*\\n*|$)|<![A-Z][\\s\\S]*?(?:>[^\\n]*\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>[^\\n]*\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$))","i").replace("comment",Y).replace("tag",K).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),X=e=>N(H).replace("hr",B).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~~~)[^\\n]*\\n").replace("list",e).replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",K).getRegex(),J=X(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),ee=X(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),te={blockquote:N(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",ee).getRegex(),code:/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,def:V,fences:/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,hr:B,html:Z,lheading:z,list:Q,newline:/^(?:[ \t]*(?:\n|$))+/,paragraph:J,table:M,text:/^[^\n]+/},ne=N("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",B).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3}\t)[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~~~)[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",K).getRegex(),ie=P(P({},te),{},{lheading:W,table:ne,paragraph:N(H).replace("hr",B).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",ne).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~~~)[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",K).getRegex()}),se=P(P({},te),{},{html:N("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:\"[^\"]*\"|'[^']*'|\\s[^'\"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment",Y).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:M,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:N(H).replace("hr",B).replace("heading"," *#{1,6} *[^\n]").replace("lheading",z).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()}),re=/^( {2,}|\\)\n(?!\s*$)/,oe=new RegExp("[\\p{P}\\p{S}]","u"),ae=new RegExp("[\\s\\p{P}\\p{S}]","u"),le=new RegExp("[^\\s\\p{P}\\p{S}]","u"),ce=N(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,ae).getRegex(),de=new RegExp("(?!~)[\\p{P}\\p{S}]","u"),ue=new RegExp("(?!~)[\\s\\p{P}\\p{S}]","u"),he=new RegExp("(?:[^\\s\\p{P}\\p{S}]|~)","u"),pe=N(/link|precode-code|html/,"g").replace("link",new RegExp("\\[(?:[^\\[\\]`]|(?<a>`+)[^`]+\\k<a>(?!`))*?\\]\\((?:\\\\[\\s\\S]|[^\\\\\\(\\)]|\\((?:\\\\[\\s\\S]|[^\\\\\\(\\)])*\\))*\\)","")).replace("precode-",U?"(?<!`)()":"(^^|[^`])").replace("code",new RegExp("(?<b>`+)[^`]+\\k<b>(?!`)","")).replace("html",/<(?! )[^<>]*?>/).getRegex(),ge=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,me=N(ge,"u").replace(/punct/g,oe).getRegex(),fe=N(ge,"u").replace(/punct/g,de).getRegex(),ke="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",ye=N(ke,"gu").replace(/notPunctSpace/g,le).replace(/punctSpace/g,ae).replace(/punct/g,oe).getRegex(),ve=N(ke,"gu").replace(/notPunctSpace/g,he).replace(/punctSpace/g,ue).replace(/punct/g,de).getRegex(),be=N("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,le).replace(/punctSpace/g,ae).replace(/punct/g,oe).getRegex(),we=N(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,oe).getRegex(),$e=N("^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)","gu").replace(/notPunctSpace/g,le).replace(/punctSpace/g,ae).replace(/punct/g,oe).getRegex(),xe=N(/\\(punct)/,"gu").replace(/punct/g,oe).getRegex(),Ee=N(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),Se=N(Y).replace("(?:--\x3e|$)","--\x3e").getRegex(),Ce=N("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",Se).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Te=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,Ae=N(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",Te).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Le=N(/^!?\[(label)\]\[(ref)\]/).replace("label",Te).replace("ref",G).getRegex(),Re=N(/^!?\[(ref)\](?:\[\])?/).replace("ref",G).getRegex(),Pe=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,_e={_backpedal:M,anyPunctuation:xe,autolink:Ee,blockSkip:pe,br:re,code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,del:M,delLDelim:M,delRDelim:M,emStrongLDelim:me,emStrongRDelimAst:ye,emStrongRDelimUnd:be,escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,link:Ae,nolink:Re,punctuation:ce,reflink:Le,reflinkSearch:N("reflink|nolink(?!\\()","g").replace("reflink",Le).replace("nolink",Re).getRegex(),tag:Ce,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,url:M},Oe=P(P({},_e),{},{link:N(/^!?\[(label)\]\((.*?)\)/).replace("label",Te).getRegex(),reflink:N(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Te).getRegex()}),Ie=P(P({},_e),{},{emStrongRDelimAst:ve,emStrongLDelim:fe,delLDelim:we,delRDelim:$e,url:N(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Pe).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:N(/^(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",Pe).getRegex()}),Me=P(P({},Ie),{},{br:N(re).replace("{2,}","*").getRegex(),text:N(Ie.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()}),De={normal:te,gfm:ie,pedantic:se},Ne={normal:_e,gfm:Ie,breaks:Me,pedantic:Oe},Ue={"&":"&","<":"<",">":">",'"':""","'":"'"},je=e=>Ue[e];function Be(e,t){if(t){if(j.escapeTest.test(e))return e.replace(j.escapeReplace,je)}else if(j.escapeTestNoEncode.test(e))return e.replace(j.escapeReplaceNoEncode,je);return e}function qe(e){try{e=encodeURI(e).replace(j.percentDecode,"%")}catch(t){return null}return e}function Fe(e,t){var n;let i=e.replace(j.findPipe,(e,t,n)=>{let i=!1,s=t;for(;--s>=0&&"\\"===n[s];)i=!i;return i?"|":" |"}).split(j.splitPipe),s=0;if(i[0].trim()||i.shift(),i.length>0&&!(null===(n=i.at(-1))||void 0===n?void 0:n.trim())&&i.pop(),t)if(i.length>t)i.splice(t);else for(;i.length<t;)i.push("");for(;s<i.length;s++)i[s]=i[s].trim().replace(j.slashPipe,"|");return i}function ze(e,t,n){let i=e.length;if(0===i)return"";let s=0;for(;s<i;){let r=e.charAt(i-s-1);if(r!==t||n){if(r===t||!n)break;s++}else s++}return e.slice(0,i-s)}function We(e){let t=e.split("\n"),n=t.length-1;for(;n>=0&&j.blankLine.test(t[n]);)n--;return t.length-n<=2?e:t.slice(0,n+1).join("\n")}function He(e,t=0){let n=t,i="";for(let s of e)if("\t"===s){let e=4-n%4;i+=" ".repeat(e),n+=e}else i+=s,n++;return i}function Ge(e,t,n,i,s){let r=t.href,o=t.title||null,a=e[1].replace(s.other.outputLinkReplace,"$1");i.state.inLink=!0;let l={type:"!"===e[0].charAt(0)?"image":"link",raw:n,href:r,title:o,text:a,tokens:i.inlineTokens(a)};return i.state.inLink=!1,l}var Ve=class{constructor(e){L(this,"options",void 0),L(this,"rules",void 0),L(this,"lexer",void 0),this.options=e||O}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let e=this.options.pedantic?t[0]:We(t[0]);return{type:"code",raw:e,codeBlockStyle:"indented",text:e.replace(this.rules.other.codeRemoveIndent,"")}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n=function(e,t,n){let i=e.match(n.other.indentCodeCompensation);if(null===i)return t;let s=i[1];return t.split("\n").map(e=>{let t=e.match(n.other.beginningSpace);if(null===t)return e;let[i]=t;return i.length>=s.length?e.slice(s.length):e}).join("\n")}(e,t[3]||"",this.rules);return{type:"code",raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:n}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){let t=ze(e,"#");(this.options.pedantic||!t||this.rules.other.endingSpaceChar.test(t))&&(e=t.trim())}return{type:"heading",raw:ze(t[0],"\n"),depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:ze(t[0],"\n")}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=ze(t[0],"\n").split("\n"),n="",i="",s=[];for(;e.length>0;){let t,r=!1,o=[];for(t=0;t<e.length;t++)if(this.rules.other.blockquoteStart.test(e[t]))o.push(e[t]),r=!0;else{if(r)break;o.push(e[t])}e=e.slice(t);let a=o.join("\n"),l=a.replace(this.rules.other.blockquoteSetextReplace,"\n $1").replace(this.rules.other.blockquoteSetextReplace2,"");n=n?`${n}\n${a}`:a,i=i?`${i}\n${l}`:l;let c=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(l,s,!0),this.lexer.state.top=c,0===e.length)break;let d=s.at(-1);if("code"===(null==d?void 0:d.type))break;if("blockquote"===(null==d?void 0:d.type)){let t=d,r=t.raw+"\n"+e.join("\n"),o=this.blockquote(r);s[s.length-1]=o,n=n.substring(0,n.length-t.raw.length)+o.raw,i=i.substring(0,i.length-t.text.length)+o.text;break}if("list"===(null==d?void 0:d.type)){let t=d,r=t.raw+"\n"+e.join("\n"),o=this.list(r);s[s.length-1]=o,n=n.substring(0,n.length-d.raw.length)+o.raw,i=i.substring(0,i.length-t.raw.length)+o.raw,e=r.substring(s.at(-1).raw.length).split("\n");continue}}return{type:"blockquote",raw:n,tokens:s,text:i}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),i=n.length>1,s={type:"list",raw:"",ordered:i,start:i?+n.slice(0,-1):"",loose:!1,items:[]};n=i?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=i?n:"[*+-]");let r=this.rules.other.listItemRegex(n),o=!1;for(;e;){let n=!1,i="",a="";if(!(t=r.exec(e))||this.rules.block.hr.test(e))break;i=t[0],e=e.substring(i.length);let l=He(t[2].split("\n",1)[0],t[1].length),c=e.split("\n",1)[0],d=!l.trim(),u=0;if(this.options.pedantic?(u=2,a=l.trimStart()):d?u=t[1].length+1:(u=l.search(this.rules.other.nonSpaceChar),u=u>4?1:u,a=l.slice(u),u+=t[1].length),d&&this.rules.other.blankLine.test(c)&&(i+=c+"\n",e=e.substring(c.length+1),n=!0),!n){let t=this.rules.other.nextBulletRegex(u),n=this.rules.other.hrRegex(u),s=this.rules.other.fencesBeginRegex(u),r=this.rules.other.headingBeginRegex(u),o=this.rules.other.htmlBeginRegex(u),h=this.rules.other.blockquoteBeginRegex(u);for(;e;){let p,g=e.split("\n",1)[0];if(c=g,this.options.pedantic?(c=c.replace(this.rules.other.listReplaceNesting," "),p=c):p=c.replace(this.rules.other.tabCharGlobal," "),s.test(c)||r.test(c)||o.test(c)||h.test(c)||t.test(c)||n.test(c))break;if(p.search(this.rules.other.nonSpaceChar)>=u||!c.trim())a+="\n"+p.slice(u);else{if(d||l.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||s.test(l)||r.test(l)||n.test(l))break;a+="\n"+c}d=!c.trim(),i+=g+"\n",e=e.substring(g.length+1),l=p.slice(u)}}s.loose||(o?s.loose=!0:this.rules.other.doubleBlankLine.test(i)&&(o=!0)),s.items.push({type:"list_item",raw:i,task:!!this.options.gfm&&this.rules.other.listIsTask.test(a),loose:!1,text:a,tokens:[]}),s.raw+=i}let a=s.items.at(-1);if(!a)return;a.raw=a.raw.trimEnd(),a.text=a.text.trimEnd(),s.raw=s.raw.trimEnd();for(let e of s.items){this.lexer.state.top=!1,e.tokens=this.lexer.blockTokens(e.text,[]);let t=e.tokens[0];if(!e.task||"text"!==(null==t?void 0:t.type)&&"paragraph"!==(null==t?void 0:t.type))e.task&&(e.task=!1);else{e.text=e.text.replace(this.rules.other.listReplaceTask,""),t.raw=t.raw.replace(this.rules.other.listReplaceTask,""),t.text=t.text.replace(this.rules.other.listReplaceTask,"");for(let e=this.lexer.inlineQueue.length-1;e>=0;e--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[e].src)){this.lexer.inlineQueue[e].src=this.lexer.inlineQueue[e].src.replace(this.rules.other.listReplaceTask,"");break}let n=this.rules.other.listTaskCheckbox.exec(e.raw);if(n){let t={type:"checkbox",raw:n[0]+" ",checked:"[ ]"!==n[0]};e.checked=t.checked,s.loose?e.tokens[0]&&["paragraph","text"].includes(e.tokens[0].type)&&"tokens"in e.tokens[0]&&e.tokens[0].tokens?(e.tokens[0].raw=t.raw+e.tokens[0].raw,e.tokens[0].text=t.raw+e.tokens[0].text,e.tokens[0].tokens.unshift(t)):e.tokens.unshift({type:"paragraph",raw:t.raw,text:t.raw,tokens:[t]}):e.tokens.unshift(t)}}if(!s.loose){let t=e.tokens.filter(e=>"space"===e.type);s.loose=t.length>0&&t.some(e=>this.rules.other.anyLine.test(e.raw))}}if(s.loose)for(let e of s.items){e.loose=!0;for(let t of e.tokens)"text"===t.type&&(t.type="paragraph")}return s}}html(e){let t=this.rules.block.html.exec(e);if(t){let e=We(t[0]);return{type:"html",block:!0,raw:e,pre:"pre"===t[1]||"script"===t[1]||"style"===t[1],text:e}}}def(e){let t=this.rules.block.def.exec(e);if(t){let e=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),n=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",i=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:e,raw:ze(t[0],"\n"),href:n,title:i}}}table(e){var t;let n=this.rules.block.table.exec(e);if(!n||!this.rules.other.tableDelimiter.test(n[2]))return;let i=Fe(n[1]),s=n[2].replace(this.rules.other.tableAlignChars,"").split("|"),r=(null===(t=n[3])||void 0===t?void 0:t.trim())?n[3].replace(this.rules.other.tableRowBlankLine,"").split("\n"):[],o={type:"table",raw:ze(n[0],"\n"),header:[],align:[],rows:[]};if(i.length===s.length){for(let e of s)this.rules.other.tableAlignRight.test(e)?o.align.push("right"):this.rules.other.tableAlignCenter.test(e)?o.align.push("center"):this.rules.other.tableAlignLeft.test(e)?o.align.push("left"):o.align.push(null);for(let e=0;e<i.length;e++)o.header.push({text:i[e],tokens:this.lexer.inline(i[e]),header:!0,align:o.align[e]});for(let e of r)o.rows.push(Fe(e,o.header.length).map((e,t)=>({text:e,tokens:this.lexer.inline(e),header:!1,align:o.align[t]})));return o}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t){let e=t[1].trim();return{type:"heading",raw:ze(t[0],"\n"),depth:"="===t[2].charAt(0)?1:2,text:e,tokens:this.lexer.inline(e)}}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let e="\n"===t[1].charAt(t[1].length-1)?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let e=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;let t=ze(e.slice(0,-1),"\\");if((e.length-t.length)%2==0)return}else{let e=function(e,t){if(-1===e.indexOf(t[1]))return-1;let n=0;for(let i=0;i<e.length;i++)if("\\"===e[i])i++;else if(e[i]===t[0])n++;else if(e[i]===t[1]&&(n--,n<0))return i;return n>0?-2:-1}(t[2],"()");if(-2===e)return;if(e>-1){let n=(0===t[0].indexOf("!")?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,n).trim(),t[3]=""}}let n=t[2],i="";if(this.options.pedantic){let e=this.rules.other.pedanticHrefTitle.exec(n);e&&(n=e[1],i=e[3])}else i=t[3]?t[3].slice(1,-1):"";return n=n.trim(),this.rules.other.startAngleBracket.test(n)&&(n=this.options.pedantic&&!this.rules.other.endAngleBracket.test(e)?n.slice(1):n.slice(1,-1)),Ge(t,{href:n&&n.replace(this.rules.inline.anyPunctuation,"$1"),title:i&&i.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let e=t[(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," ").toLowerCase()];if(!e){let e=n[0].charAt(0);return{type:"text",raw:e,text:e}}return Ge(n,e,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let i=this.rules.inline.emStrongLDelim.exec(e);if(i&&(i[1]||i[2]||i[3]||i[4])&&(!i[4]||!n.match(this.rules.other.unicodeAlphaNumeric))&&(!i[1]&&!i[3]||!n||this.rules.inline.punctuation.exec(n))){let n,s,r=[...i[0]].length-1,o=r,a=0,l="*"===i[0][0]?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(l.lastIndex=0,t=t.slice(-1*e.length+r);null!==(i=l.exec(t));){if(n=i[1]||i[2]||i[3]||i[4]||i[5]||i[6],!n)continue;if(s=[...n].length,i[3]||i[4]){o+=s;continue}if((i[5]||i[6])&&r%3&&!((r+s)%3)){a+=s;continue}if(o-=s,o>0)continue;s=Math.min(s,s+o+a);let t=[...i[0]][0].length,l=e.slice(0,r+i.index+t+s);if(Math.min(r,s)%2){let e=l.slice(1,-1);return{type:"em",raw:l,text:e,tokens:this.lexer.inlineTokens(e)}}let c=l.slice(2,-2);return{type:"strong",raw:l,text:c,tokens:this.lexer.inlineTokens(c)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal," "),n=this.rules.other.nonSpaceChar.test(e),i=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return n&&i&&(e=e.substring(1,e.length-1)),{type:"codespan",raw:t[0],text:e}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e,t,n=""){let i=this.rules.inline.delLDelim.exec(e);if(i&&(!i[1]||!n||this.rules.inline.punctuation.exec(n))){let n,s,r=[...i[0]].length-1,o=r,a=this.rules.inline.delRDelim;for(a.lastIndex=0,t=t.slice(-1*e.length+r);null!==(i=a.exec(t));){if(n=i[1]||i[2]||i[3]||i[4]||i[5]||i[6],!n||(s=[...n].length,s!==r))continue;if(i[3]||i[4]){o+=s;continue}if(o-=s,o>0)continue;s=Math.min(s,s+o);let t=[...i[0]][0].length,a=e.slice(0,r+i.index+t+s),l=a.slice(r,-r);return{type:"del",raw:a,text:l,tokens:this.lexer.inlineTokens(l)}}}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let e,n;return"@"===t[2]?(e=t[1],n="mailto:"+e):(e=t[1],n=e),{type:"link",raw:t[0],text:e,href:n,tokens:[{type:"text",raw:e,text:e}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let e,s;if("@"===t[2])e=t[0],s="mailto:"+e;else{var n,i;let r;do{r=t[0],t[0]=null!==(n=null===(i=this.rules.inline._backpedal.exec(t[0]))||void 0===i?void 0:i[0])&&void 0!==n?n:""}while(r!==t[0]);e=t[0],s="www."===t[1]?"http://"+t[0]:t[0]}return{type:"link",raw:t[0],text:e,href:s,tokens:[{type:"text",raw:e,text:e}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let e=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:e}}}},Qe=class e{constructor(e){L(this,"tokens",void 0),L(this,"options",void 0),L(this,"state",void 0),L(this,"inlineQueue",void 0),L(this,"tokenizer",void 0),this.tokens=[],this.tokens.links=Object.create(null),this.options=e||O,this.options.tokenizer=this.options.tokenizer||new Ve,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let t={other:j,block:De.normal,inline:Ne.normal};this.options.pedantic?(t.block=De.pedantic,t.inline=Ne.pedantic):this.options.gfm&&(t.block=De.gfm,this.options.breaks?t.inline=Ne.breaks:t.inline=Ne.gfm),this.tokenizer.rules=t}static get rules(){return{block:De,inline:Ne}}static lex(t,n){return new e(n).lex(t)}static lexInline(t,n){return new e(n).inlineTokens(t)}lex(e){e=e.replace(j.carriageReturn,"\n"),this.blockTokens(e,this.tokens);for(let t=0;t<this.inlineQueue.length;t++){let e=this.inlineQueue[t];this.inlineTokens(e.src,e.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],n=!1){this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(j.tabCharGlobal," ").replace(j.spaceLine,""));let i=1/0;for(;e;){var s,r;if(!(e.length<i)){this.infiniteLoopError(e.charCodeAt(0));break}let o;if(i=e.length,null===(s=this.options.extensions)||void 0===s||null===(s=s.block)||void 0===s?void 0:s.some(n=>!!(o=n.call({lexer:this},e,t))&&(e=e.substring(o.raw.length),t.push(o),!0)))continue;if(o=this.tokenizer.space(e)){e=e.substring(o.raw.length);let n=t.at(-1);1===o.raw.length&&void 0!==n?n.raw+="\n":t.push(o);continue}if(o=this.tokenizer.code(e)){e=e.substring(o.raw.length);let n=t.at(-1);"paragraph"===(null==n?void 0:n.type)||"text"===(null==n?void 0:n.type)?(n.raw+=(n.raw.endsWith("\n")?"":"\n")+o.raw,n.text+="\n"+o.text,this.inlineQueue.at(-1).src=n.text):t.push(o);continue}if(o=this.tokenizer.fences(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.heading(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.hr(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.blockquote(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.list(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.html(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.def(e)){e=e.substring(o.raw.length);let n=t.at(-1);"paragraph"===(null==n?void 0:n.type)||"text"===(null==n?void 0:n.type)?(n.raw+=(n.raw.endsWith("\n")?"":"\n")+o.raw,n.text+="\n"+o.raw,this.inlineQueue.at(-1).src=n.text):this.tokens.links[o.tag]||(this.tokens.links[o.tag]={href:o.href,title:o.title},t.push(o));continue}if(o=this.tokenizer.table(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.lheading(e)){e=e.substring(o.raw.length),t.push(o);continue}let a=e;if(null===(r=this.options.extensions)||void 0===r?void 0:r.startBlock){let t,n=1/0,i=e.slice(1);this.options.extensions.startBlock.forEach(e=>{t=e.call({lexer:this},i),"number"==typeof t&&t>=0&&(n=Math.min(n,t))}),n<1/0&&n>=0&&(a=e.substring(0,n+1))}if(this.state.top&&(o=this.tokenizer.paragraph(a))){let i=t.at(-1);n&&"paragraph"===(null==i?void 0:i.type)?(i.raw+=(i.raw.endsWith("\n")?"":"\n")+o.raw,i.text+="\n"+o.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=i.text):t.push(o),n=a.length!==e.length,e=e.substring(o.raw.length);continue}if(o=this.tokenizer.text(e)){e=e.substring(o.raw.length);let n=t.at(-1);"text"===(null==n?void 0:n.type)?(n.raw+=(n.raw.endsWith("\n")?"":"\n")+o.raw,n.text+="\n"+o.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(o);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){var n,i;this.tokenizer.lexer=this;let s=e;if(this.tokens.links){let e=Object.keys(this.tokens.links);e.length>0&&(s=s.replace(this.tokenizer.rules.inline.reflinkSearch,t=>e.includes(t.slice(t.lastIndexOf("[")+1,-1))?"["+"a".repeat(t.length-2)+"]":t))}s=s.replace(this.tokenizer.rules.inline.anyPunctuation,"++"),s=s.replace(this.tokenizer.rules.inline.blockSkip,(e,t,n)=>{let i=n?n.length:0;return e.slice(0,i)+"["+"a".repeat(e.length-i-2)+"]"}),s=null!==(n=null===(i=this.options.hooks)||void 0===i||null===(i=i.emStrongMask)||void 0===i?void 0:i.call({lexer:this},s))&&void 0!==n?n:s;let r=!1,o="",a=1/0;for(;e;){var l,c;if(!(e.length<a)){this.infiniteLoopError(e.charCodeAt(0));break}let n;if(a=e.length,r||(o=""),r=!1,null===(l=this.options.extensions)||void 0===l||null===(l=l.inline)||void 0===l?void 0:l.some(i=>!!(n=i.call({lexer:this},e,t))&&(e=e.substring(n.raw.length),t.push(n),!0)))continue;if(n=this.tokenizer.escape(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.tag(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.link(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(n.raw.length);let i=t.at(-1);"text"===n.type&&"text"===(null==i?void 0:i.type)?(i.raw+=n.raw,i.text+=n.text):t.push(n);continue}if(n=this.tokenizer.emStrong(e,s,o)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.codespan(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.br(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.del(e,s,o)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.autolink(e)){e=e.substring(n.raw.length),t.push(n);continue}if(!this.state.inLink&&(n=this.tokenizer.url(e))){e=e.substring(n.raw.length),t.push(n);continue}let i=e;if(null===(c=this.options.extensions)||void 0===c?void 0:c.startInline){let t,n=1/0,s=e.slice(1);this.options.extensions.startInline.forEach(e=>{t=e.call({lexer:this},s),"number"==typeof t&&t>=0&&(n=Math.min(n,t))}),n<1/0&&n>=0&&(i=e.substring(0,n+1))}if(n=this.tokenizer.inlineText(i)){e=e.substring(n.raw.length),"_"!==n.raw.slice(-1)&&(o=n.raw.slice(-1)),r=!0;let i=t.at(-1);"text"===(null==i?void 0:i.type)?(i.raw+=n.raw,i.text+=n.text):t.push(n);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return t}infiniteLoopError(e){let t="Infinite loop on byte: "+e;if(!this.options.silent)throw new Error(t);console.error(t)}},Ke=class{constructor(e){L(this,"options",void 0),L(this,"parser",void 0),this.options=e||O}space(e){return""}code({text:e,lang:t,escaped:n}){var i;let s=null===(i=(t||"").match(j.notSpaceStart))||void 0===i?void 0:i[0],r=e.replace(j.endingNewline,"")+"\n";return s?'<pre><code class="language-'+Be(s)+'">'+(n?r:Be(r,!0))+"</code></pre>\n":"<pre><code>"+(n?r:Be(r,!0))+"</code></pre>\n"}blockquote({tokens:e}){return`<blockquote>\n${this.parser.parse(e)}</blockquote>\n`}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>\n`}hr(e){return"<hr>\n"}list(e){let t=e.ordered,n=e.start,i="";for(let r=0;r<e.items.length;r++){let t=e.items[r];i+=this.listitem(t)}let s=t?"ol":"ul";return"<"+s+(t&&1!==n?' start="'+n+'"':"")+">\n"+i+"</"+s+">\n"}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>\n`}checkbox({checked:e}){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>\n`}table(e){let t="",n="";for(let s=0;s<e.header.length;s++)n+=this.tablecell(e.header[s]);t+=this.tablerow({text:n});let i="";for(let s=0;s<e.rows.length;s++){let t=e.rows[s];n="";for(let e=0;e<t.length;e++)n+=this.tablecell(t[e]);i+=this.tablerow({text:n})}return i&&(i=`<tbody>${i}</tbody>`),"<table>\n<thead>\n"+t+"</thead>\n"+i+"</table>\n"}tablerow({text:e}){return`<tr>\n${e}</tr>\n`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>\n`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${Be(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let i=this.parser.parseInline(n),s=qe(e);if(null===s)return i;let r='<a href="'+(e=s)+'"';return t&&(r+=' title="'+Be(t)+'"'),r+=">"+i+"</a>",r}image({href:e,title:t,text:n,tokens:i}){i&&(n=this.parser.parseInline(i,this.parser.textRenderer));let s=qe(e);if(null===s)return Be(n);let r=`<img src="${e=s}" alt="${Be(n)}"`;return t&&(r+=` title="${Be(t)}"`),r+=">",r}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:Be(e.text)}},Ye=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}checkbox({raw:e}){return e}},Ze=class e{constructor(e){L(this,"options",void 0),L(this,"renderer",void 0),L(this,"textRenderer",void 0),this.options=e||O,this.options.renderer=this.options.renderer||new Ke,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Ye}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e){this.renderer.parser=this;let t="";for(let i=0;i<e.length;i++){var n;let s=e[i];if(null===(n=this.options.extensions)||void 0===n||null===(n=n.renderers)||void 0===n?void 0:n[s.type]){let e=s,n=this.options.extensions.renderers[e.type].call({parser:this},e);if(!1!==n||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(e.type)){t+=n||"";continue}}let r=s;switch(r.type){case"space":t+=this.renderer.space(r);break;case"hr":t+=this.renderer.hr(r);break;case"heading":t+=this.renderer.heading(r);break;case"code":t+=this.renderer.code(r);break;case"table":t+=this.renderer.table(r);break;case"blockquote":t+=this.renderer.blockquote(r);break;case"list":t+=this.renderer.list(r);break;case"checkbox":t+=this.renderer.checkbox(r);break;case"html":t+=this.renderer.html(r);break;case"def":t+=this.renderer.def(r);break;case"paragraph":t+=this.renderer.paragraph(r);break;case"text":t+=this.renderer.text(r);break;default:{let e='Token with "'+r.type+'" type was not found.';if(this.options.silent)return console.error(e),"";throw new Error(e)}}}return t}parseInline(e,t=this.renderer){this.renderer.parser=this;let n="";for(let s=0;s<e.length;s++){var i;let r=e[s];if(null===(i=this.options.extensions)||void 0===i||null===(i=i.renderers)||void 0===i?void 0:i[r.type]){let e=this.options.extensions.renderers[r.type].call({parser:this},r);if(!1!==e||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(r.type)){n+=e||"";continue}}let o=r;switch(o.type){case"escape":case"text":n+=t.text(o);break;case"html":n+=t.html(o);break;case"link":n+=t.link(o);break;case"image":n+=t.image(o);break;case"checkbox":n+=t.checkbox(o);break;case"strong":n+=t.strong(o);break;case"em":n+=t.em(o);break;case"codespan":n+=t.codespan(o);break;case"br":n+=t.br(o);break;case"del":n+=t.del(o);break;default:{let e='Token with "'+o.type+'" type was not found.';if(this.options.silent)return console.error(e),"";throw new Error(e)}}}return n}},Xe=(x=class{constructor(e){L(this,"options",void 0),L(this,"block",void 0),this.options=e||O}preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?Qe.lex:Qe.lexInline}provideParser(e=this.block){return e?Ze.parse:Ze.parseInline}},L(x,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),L(x,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),x),Je=class{constructor(...e){L(this,"defaults",{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}),L(this,"options",this.setOptions),L(this,"parse",this.parseMarkdown(!0)),L(this,"parseInline",this.parseMarkdown(!1)),L(this,"Parser",Ze),L(this,"Renderer",Ke),L(this,"TextRenderer",Ye),L(this,"Lexer",Qe),L(this,"Tokenizer",Ve),L(this,"Hooks",Xe),this.use(...e)}walkTokens(e,t){let n=[];for(let s of e)switch(n=n.concat(t.call(this,s)),s.type){case"table":{let e=s;for(let i of e.header)n=n.concat(this.walkTokens(i.tokens,t));for(let i of e.rows)for(let e of i)n=n.concat(this.walkTokens(e.tokens,t));break}case"list":{let e=s;n=n.concat(this.walkTokens(e.items,t));break}default:{var i;let e=s;(null===(i=this.defaults.extensions)||void 0===i||null===(i=i.childTokens)||void 0===i?void 0:i[e.type])?this.defaults.extensions.childTokens[e.type].forEach(i=>{let s=e[i].flat(1/0);n=n.concat(this.walkTokens(s,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let n=P({},e);if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw new Error("extension name required");if("renderer"in e){let n=t.renderers[e.name];t.renderers[e.name]=n?function(...t){let i=e.renderer.apply(this,t);return!1===i&&(i=n.apply(this,t)),i}:e.renderer}if("tokenizer"in e){if(!e.level||"block"!==e.level&&"inline"!==e.level)throw new Error("extension level must be 'block' or 'inline'");let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&("block"===e.level?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:"inline"===e.level&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}"childTokens"in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new Ke(this.defaults);for(let n in e.renderer){if(!(n in t))throw new Error(`renderer '${n}' does not exist`);if(["options","parser"].includes(n))continue;let i=n,s=e.renderer[i],r=t[i];t[i]=(...e)=>{let n=s.apply(t,e);return!1===n&&(n=r.apply(t,e)),n||""}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new Ve(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw new Error(`tokenizer '${n}' does not exist`);if(["options","rules","lexer"].includes(n))continue;let i=n,s=e.tokenizer[i],r=t[i];t[i]=(...e)=>{let n=s.apply(t,e);return!1===n&&(n=r.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new Xe;for(let n in e.hooks){if(!(n in t))throw new Error(`hook '${n}' does not exist`);if(["options","block"].includes(n))continue;let i=n,s=e.hooks[i],r=t[i];Xe.passThroughHooks.has(n)?t[i]=e=>{if(this.defaults.async&&Xe.passThroughHooksRespectAsync.has(n))return c(function*(){let n=yield s.call(t,e);return r.call(t,n)})();let i=s.call(t,e);return r.call(t,i)}:t[i]=(...e)=>{if(this.defaults.async)return c(function*(){let n=yield s.apply(t,e);return!1===n&&(n=yield r.apply(t,e)),n})();let n=s.apply(t,e);return!1===n&&(n=r.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,i=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(i.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults=P(P({},this.defaults),n)}),this}setOptions(e){return this.defaults=P(P({},this.defaults),e),this}lexer(e,t){return Qe.lex(e,null!=t?t:this.defaults)}parser(e,t){return Ze.parse(e,null!=t?t:this.defaults)}parseMarkdown(e){var t=this;return(n,i)=>{let s=P({},i),r=P(P({},this.defaults),s),o=this.onError(!!r.silent,!!r.async);if(!0===this.defaults.async&&!1===s.async)return o(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof n>"u"||null===n)return o(new Error("marked(): input parameter is undefined or null"));if("string"!=typeof n)return o(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));if(r.hooks&&(r.hooks.options=r,r.hooks.block=e),r.async)return c(function*(){let i=r.hooks?yield r.hooks.preprocess(n):n,s=yield(r.hooks?yield r.hooks.provideLexer(e):e?Qe.lex:Qe.lexInline)(i,r),o=r.hooks?yield r.hooks.processAllTokens(s):s;r.walkTokens&&(yield Promise.all(t.walkTokens(o,r.walkTokens)));let a=yield(r.hooks?yield r.hooks.provideParser(e):e?Ze.parse:Ze.parseInline)(o,r);return r.hooks?yield r.hooks.postprocess(a):a})().catch(o);try{r.hooks&&(n=r.hooks.preprocess(n));let t=(r.hooks?r.hooks.provideLexer(e):e?Qe.lex:Qe.lexInline)(n,r);r.hooks&&(t=r.hooks.processAllTokens(t)),r.walkTokens&&this.walkTokens(t,r.walkTokens);let i=(r.hooks?r.hooks.provideParser(e):e?Ze.parse:Ze.parseInline)(t,r);return r.hooks&&(i=r.hooks.postprocess(i)),i}catch(a){return o(a)}}}onError(e,t){return n=>{if(n.message+="\nPlease report this to https://github.com/markedjs/marked.",e){let e="<p>An error occurred:</p><pre>"+Be(n.message+"",!0)+"</pre>";return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}},et=new Je;function tt(e,t){return et.parse(e,t)}tt.options=tt.setOptions=function(e){return et.setOptions(e),tt.defaults=et.defaults,I(tt.defaults),tt},tt.getDefaults=_,tt.defaults=O,tt.use=function(...e){return et.use(...e),tt.defaults=et.defaults,I(tt.defaults),tt},tt.walkTokens=function(e,t){return et.walkTokens(e,t)},tt.parseInline=et.parseInline,tt.Parser=Ze,tt.parser=Ze.parse,tt.Renderer=Ke,tt.TextRenderer=Ye,tt.Lexer=Qe,tt.lexer=Qe.lex,tt.Tokenizer=Ve,tt.Hooks=Xe,tt.parse=tt;tt.options,tt.setOptions,tt.use,tt.walkTokens,tt.parseInline,Ze.parse,Qe.lex;function nt(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 it(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,s,r,o,a=[],l=!0,c=!1;try{if(r=(n=n.call(e)).next,0===t);else for(;!(l=(i=r.call(n)).done)&&(a.push(i.value),a.length!==t);l=!0);}catch(e){c=!0,s=e}finally{try{if(!l&&null!=n.return&&(o=n.return(),Object(o)!==o))return}finally{if(c)throw s}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return nt(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)?nt(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 st=Object.entries,rt=Object.setPrototypeOf,ot=Object.isFrozen,at=Object.getPrototypeOf,lt=Object.getOwnPropertyDescriptor,ct=Object.freeze,dt=Object.seal,ut=Object.create,ht="undefined"!=typeof Reflect&&Reflect,pt=ht.apply,gt=ht.construct;ct||(ct=function(e){return e}),dt||(dt=function(e){return e}),pt||(pt=function(e,t){for(var n=arguments.length,i=new Array(n>2?n-2:0),s=2;s<n;s++)i[s-2]=arguments[s];return e.apply(t,i)}),gt||(gt=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 mt,ft=Dt(Array.prototype.forEach),kt=Dt(Array.prototype.lastIndexOf),yt=Dt(Array.prototype.pop),vt=Dt(Array.prototype.push),bt=Dt(Array.prototype.splice),wt=Array.isArray,$t=Dt(String.prototype.toLowerCase),xt=Dt(String.prototype.toString),Et=Dt(String.prototype.match),St=Dt(String.prototype.replace),Ct=Dt(String.prototype.indexOf),Tt=Dt(String.prototype.trim),At=Dt(Number.prototype.toString),Lt=Dt(Boolean.prototype.toString),Rt="undefined"==typeof BigInt?null:Dt(BigInt.prototype.toString),Pt="undefined"==typeof Symbol?null:Dt(Symbol.prototype.toString),_t=Dt(Object.prototype.hasOwnProperty),Ot=Dt(Object.prototype.toString),It=Dt(RegExp.prototype.test),Mt=(mt=TypeError,function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return gt(mt,t)});function Dt(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,i=new Array(n>1?n-1:0),s=1;s<n;s++)i[s-1]=arguments[s];return pt(e,t,i)}}function Nt(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:$t;if(rt&&rt(e,null),!wt(t))return e;let i=t.length;for(;i--;){let s=t[i];if("string"==typeof s){const e=n(s);e!==s&&(ot(t)||(t[i]=e),s=e)}e[s]=!0}return e}function Ut(e){for(let t=0;t<e.length;t++)_t(e,t)||(e[t]=null);return e}function jt(e){const t=ut(null);for(const i of st(e)){var n=it(i,2);const s=n[0],r=n[1];_t(e,s)&&(wt(r)?t[s]=Ut(r):r&&"object"==typeof r&&r.constructor===Object?t[s]=jt(r):t[s]=r)}return t}function Bt(e,t){for(;null!==e;){const n=lt(e,t);if(n){if(n.get)return Dt(n.get);if("function"==typeof n.value)return Dt(n.value)}e=at(e)}return function(){return null}}var qt=ct(["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"]),Ft=ct(["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"]),zt=ct(["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"]),Wt=ct(["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"]),Ht=ct(["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"]),Gt=ct(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Vt=ct(["#text"]),Qt=ct(["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"]),Kt=ct(["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"]),Yt=ct(["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"]),Zt=ct(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Xt=dt(/{{[\w\W]*|^[\w\W]*}}/g),Jt=dt(/<%[\w\W]*|^[\w\W]*%>/g),en=dt(/\${[\w\W]*/g),tn=dt(/^data-[\-\w.\u00B7-\uFFFF]+$/),nn=dt(/^aria-[\-\w]+$/),sn=dt(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),rn=dt(/^(?:\w+script|data):/i),on=dt(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),an=dt(/^html$/i),ln=dt(/^[a-z][.\w]*(-[.\w]+)+$/i),cn=dt(/<[/\w!]/g),dn=dt(/<[/\w]/g),un=dt(/<\/no(script|embed|frames)/i),hn=dt(/\/>/i),pn=1,gn=3,mn=7,fn=8,kn=9,yn=11,vn=function(){return"undefined"==typeof window?null:window},bn=function(e,t,n,i){return _t(e,t)&&wt(e[t])?Nt(i.base?jt(i.base):{},e[t],i.transform):n};var wn=function e(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:vn();const n=t=>e(t);if(n.version="3.4.12",n.removed=[],!t||!t.document||t.document.nodeType!==kn||!t.Element)return n.isSupported=!1,n;let i=t.document;const s=i,r=s.currentScript;t.DocumentFragment;const o=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,h=l.prototype,p=Bt(h,"cloneNode"),g=Bt(h,"remove"),m=Bt(h,"nextSibling"),f=Bt(h,"childNodes"),k=Bt(h,"parentNode"),y=Bt(h,"shadowRoot"),v=Bt(h,"attributes"),b=a&&a.prototype?Bt(a.prototype,"nodeType"):null,w=a&&a.prototype?Bt(a.prototype,"nodeName"):null;if("function"==typeof o){const e=i.createElement("template");e.content&&e.content.ownerDocument&&(i=e.content.ownerDocument)}let $,x,E="",S=!1,C=0;const T=function(){if(C>0)throw Mt('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.')},A=function(e){T(),C++;try{return $.createHTML(e)}finally{C--}},L=function(){return S||(x=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 s="dompurify"+(n?"#"+n:"");try{return e.createPolicy(s,{createHTML:e=>e,createScriptURL:e=>e})}catch(M){return console.warn("TrustedTypes policy "+s+" could not be created."),null}}(u,r),S=!0),x},R=i,P=R.implementation,_=R.createNodeIterator,O=R.createDocumentFragment,I=R.getElementsByTagName,D=s.importNode;let N={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]};n.isSupported="function"==typeof st&&"function"==typeof k&&P&&void 0!==P.createHTMLDocument;const U=Xt,j=Jt,B=en,q=tn,F=nn,z=rn,W=on,H=ln;let G=sn,V=null;const Q=Nt({},[...qt,...Ft,...zt,...Ht,...Vt]);let K=null;const Y=Nt({},[...Qt,...Kt,...Yt,...Zt]);let Z=Object.seal(ut(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}})),X=null,J=null;const ee=Object.seal(ut(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let te=!0,ne=!0,ie=!1,se=!0,re=!1,oe=!0,ae=!1,le=!1,ce=null,de=null,ue=!1,he=!1,pe=!1,ge=!1,me=!0,fe=!1;const ke="user-content-";let ye=!0,ve=!1,be={},we=null;const $e=Nt({},["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 xe=null;const Ee=Nt({},["audio","video","img","source","image","track"]);let Se=null;const Ce=Nt({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Te="http://www.w3.org/1998/Math/MathML",Ae="http://www.w3.org/2000/svg",Le="http://www.w3.org/1999/xhtml";let Re=Le,Pe=!1,_e=null;const Oe=Nt({},[Te,Ae,Le],xt),Ie=ct(["mi","mo","mn","ms","mtext"]);let Me=Nt({},Ie);const De=ct(["annotation-xml"]);let Ne=Nt({},De);const Ue=Nt({},["title","style","font","a","script"]);let je=null;const Be=["application/xhtml+xml","text/html"];let qe=null,Fe=null;const ze=i.createElement("form"),We=function(e){return e instanceof RegExp||e instanceof Function},He=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(Fe&&Fe===e)return;e&&"object"==typeof e||(e={}),e=jt(e),je=-1===Be.indexOf(e.PARSER_MEDIA_TYPE)?"text/html":e.PARSER_MEDIA_TYPE,qe="application/xhtml+xml"===je?xt:$t,V=bn(e,"ALLOWED_TAGS",Q,{transform:qe}),K=bn(e,"ALLOWED_ATTR",Y,{transform:qe}),_e=bn(e,"ALLOWED_NAMESPACES",Oe,{transform:xt}),Se=bn(e,"ADD_URI_SAFE_ATTR",Ce,{transform:qe,base:Ce}),xe=bn(e,"ADD_DATA_URI_TAGS",Ee,{transform:qe,base:Ee}),we=bn(e,"FORBID_CONTENTS",$e,{transform:qe}),X=bn(e,"FORBID_TAGS",jt({}),{transform:qe}),J=bn(e,"FORBID_ATTR",jt({}),{transform:qe}),be=!!_t(e,"USE_PROFILES")&&(e.USE_PROFILES&&"object"==typeof e.USE_PROFILES?jt(e.USE_PROFILES):e.USE_PROFILES),te=!1!==e.ALLOW_ARIA_ATTR,ne=!1!==e.ALLOW_DATA_ATTR,ie=e.ALLOW_UNKNOWN_PROTOCOLS||!1,se=!1!==e.ALLOW_SELF_CLOSE_IN_ATTR,re=e.SAFE_FOR_TEMPLATES||!1,oe=!1!==e.SAFE_FOR_XML,ae=e.WHOLE_DOCUMENT||!1,he=e.RETURN_DOM||!1,pe=e.RETURN_DOM_FRAGMENT||!1,ge=e.RETURN_TRUSTED_TYPE||!1,ue=e.FORCE_BODY||!1,me=!1!==e.SANITIZE_DOM,fe=e.SANITIZE_NAMED_PROPS||!1,ye=!1!==e.KEEP_CONTENT,ve=e.IN_PLACE||!1,G=function(e){try{return It(e,""),!0}catch(t){return!1}}(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:sn,Re="string"==typeof e.NAMESPACE?e.NAMESPACE:Le,Me=_t(e,"MATHML_TEXT_INTEGRATION_POINTS")&&e.MATHML_TEXT_INTEGRATION_POINTS&&"object"==typeof e.MATHML_TEXT_INTEGRATION_POINTS?jt(e.MATHML_TEXT_INTEGRATION_POINTS):Nt({},Ie),Ne=_t(e,"HTML_INTEGRATION_POINTS")&&e.HTML_INTEGRATION_POINTS&&"object"==typeof e.HTML_INTEGRATION_POINTS?jt(e.HTML_INTEGRATION_POINTS):Nt({},De);const t=_t(e,"CUSTOM_ELEMENT_HANDLING")&&e.CUSTOM_ELEMENT_HANDLING&&"object"==typeof e.CUSTOM_ELEMENT_HANDLING?jt(e.CUSTOM_ELEMENT_HANDLING):ut(null);if(Z=ut(null),_t(t,"tagNameCheck")&&We(t.tagNameCheck)&&(Z.tagNameCheck=t.tagNameCheck),_t(t,"attributeNameCheck")&&We(t.attributeNameCheck)&&(Z.attributeNameCheck=t.attributeNameCheck),_t(t,"allowCustomizedBuiltInElements")&&"boolean"==typeof t.allowCustomizedBuiltInElements&&(Z.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),dt(Z),re&&(ne=!1),pe&&(he=!0),be&&(V=Nt({},Vt),K=ut(null),!0===be.html&&(Nt(V,qt),Nt(K,Qt)),!0===be.svg&&(Nt(V,Ft),Nt(K,Kt),Nt(K,Zt)),!0===be.svgFilters&&(Nt(V,zt),Nt(K,Kt),Nt(K,Zt)),!0===be.mathMl&&(Nt(V,Ht),Nt(K,Yt),Nt(K,Zt))),ee.tagCheck=null,ee.attributeCheck=null,_t(e,"ADD_TAGS")&&("function"==typeof e.ADD_TAGS?ee.tagCheck=e.ADD_TAGS:wt(e.ADD_TAGS)&&(V===Q&&(V=jt(V)),Nt(V,e.ADD_TAGS,qe))),_t(e,"ADD_ATTR")&&("function"==typeof e.ADD_ATTR?ee.attributeCheck=e.ADD_ATTR:wt(e.ADD_ATTR)&&(K===Y&&(K=jt(K)),Nt(K,e.ADD_ATTR,qe))),_t(e,"ADD_URI_SAFE_ATTR")&&wt(e.ADD_URI_SAFE_ATTR)&&Nt(Se,e.ADD_URI_SAFE_ATTR,qe),_t(e,"FORBID_CONTENTS")&&wt(e.FORBID_CONTENTS)&&(we===$e&&(we=jt(we)),Nt(we,e.FORBID_CONTENTS,qe)),_t(e,"ADD_FORBID_CONTENTS")&&wt(e.ADD_FORBID_CONTENTS)&&(we===$e&&(we=jt(we)),Nt(we,e.ADD_FORBID_CONTENTS,qe)),ye&&(V["#text"]=!0),ae&&Nt(V,["html","head","body"]),V.table&&(Nt(V,["tbody"]),delete X.tbody),e.TRUSTED_TYPES_POLICY){if("function"!=typeof e.TRUSTED_TYPES_POLICY.createHTML)throw Mt('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof e.TRUSTED_TYPES_POLICY.createScriptURL)throw Mt('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const t=$;$=e.TRUSTED_TYPES_POLICY;try{E=A("")}catch(n){throw $=t,n}}else null===e.TRUSTED_TYPES_POLICY?($=void 0,E=""):(void 0===$&&($=L()),$&&"string"==typeof E&&(E=A("")));ct&&ct(e),Fe=e},Ge=Nt({},[...Ft,...zt,...Wt]),Ve=Nt({},[...Ht,...Gt]),Qe=function(e){let t=k(e);t&&t.tagName||(t={namespaceURI:Re,tagName:"template"});const n=$t(e.tagName),i=$t(t.tagName);return!!_e[e.namespaceURI]&&(e.namespaceURI===Ae?function(e,t,n){return t.namespaceURI===Le?"svg"===e:t.namespaceURI===Te?"svg"===e&&("annotation-xml"===n||Me[n]):Boolean(Ge[e])}(n,t,i):e.namespaceURI===Te?function(e,t,n){return t.namespaceURI===Le?"math"===e:t.namespaceURI===Ae?"math"===e&&Ne[n]:Boolean(Ve[e])}(n,t,i):e.namespaceURI===Le?function(e,t,n){return!(t.namespaceURI===Ae&&!Ne[n])&&!(t.namespaceURI===Te&&!Me[n])&&!Ve[e]&&(Ue[e]||!Ge[e])}(n,t,i):!("application/xhtml+xml"!==je||!_e[e.namespaceURI]))},Ke=function(e){vt(n.removed,{element:e});try{k(e).removeChild(e)}catch(M){if(g(e),!k(e))throw Mt("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},Ye=function(e){Je(e);const t=f(e);if(t){const e=[];ft(t,t=>{vt(e,t)}),ft(e,e=>{try{g(e)}catch(M){}})}const n=v(e);if(n)for(let i=n.length-1;i>=0;--i){const t=n[i],s=t&&t.name;if("string"==typeof s)try{e.removeAttribute(s)}catch(M){}}},Ze=function(e,t){try{vt(n.removed,{attribute:t.getAttributeNode(e),from:t})}catch(M){vt(n.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e)if(he||pe)try{Ke(t)}catch(M){}else try{t.setAttribute(e,"")}catch(M){}},Xe=function(e){const t=v(e);if(t)for(let n=t.length-1;n>=0;--n){const i=t[n],s=i&&i.name;if("string"==typeof s&&!K[qe(s)])try{e.removeAttribute(s)}catch(M){}}},Je=function(e){const t=[e];for(;t.length>0;){const e=t.pop();(b?b(e):e.nodeType)===pn&&Xe(e);const n=f(e);if(n)for(let i=n.length-1;i>=0;--i)t.push(n[i])}},et=function(e){let t=null,n=null;if(ue)e="<remove></remove>"+e;else{const t=Et(e,/^[\r\n\t ]+/);n=t&&t[0]}"application/xhtml+xml"===je&&Re===Le&&(e='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+e+"</body></html>");const s=$?A(e):e;if(Re===Le)try{t=(new d).parseFromString(s,je)}catch(M){}if(!t||!t.documentElement){t=P.createDocument(Re,"template",null);try{t.documentElement.innerHTML=Pe?E:s}catch(M){}}const r=t.body||t.documentElement;return e&&n&&r.insertBefore(i.createTextNode(n),r.childNodes[0]||null),Re===Le?I.call(t,ae?"html":"body")[0]:ae?t.documentElement:r},tt=function(e){return _.call(e.ownerDocument||e,e,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},nt=function(e){return e=St(e,U," "),e=St(e,j," "),e=St(e,B," ")},it=function(e){var t;e.normalize();const n=_.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=nt(i.data),i=n.nextNode();const s=null===(t=e.querySelectorAll)||void 0===t?void 0:t.call(e,"template");s&&ft(s,e=>{ot(e.content)&&it(e.content)})},rt=function(e){const t=w?w(e):null;return"string"==typeof t&&("form"===qe(t)&&("string"!=typeof e.nodeName||"string"!=typeof e.textContent||"function"!=typeof e.removeChild||e.attributes!==v(e)||"function"!=typeof e.removeAttribute||"function"!=typeof e.setAttribute||"string"!=typeof e.namespaceURI||"function"!=typeof e.insertBefore||"function"!=typeof e.hasChildNodes||e.nodeType!==b(e)||e.childNodes!==f(e)))},ot=function(e){if(!b||"object"!=typeof e||null===e)return!1;try{return b(e)===yn}catch(M){return!1}},at=function(e){if(!b||"object"!=typeof e||null===e)return!1;try{return"number"==typeof b(e)}catch(M){return!1}};function lt(e,t,i){0!==e.length&&ft(e,e=>{e.call(n,t,i,Fe)})}const ht=function(e,t){if(lt(N.beforeSanitizeElements,e,null),e!==t&&null===k(e))return!0;if(rt(e))return Ke(e),!0;const i=qe(w?w(e):e.nodeName);if(lt(N.uponSanitizeElement,e,{tagName:i,allowedTags:V}),e!==t&&null===k(e))return!0;if(function(e,t){return!!(oe&&e.hasChildNodes()&&!at(e.firstElementChild)&&It(cn,e.textContent)&&It(cn,e.innerHTML))||!(!oe||e.namespaceURI!==Le||"style"!==t||!at(e.firstElementChild))||e.nodeType===mn||!(!oe||e.nodeType!==fn||!It(dn,e.data))}(e,i))return Ke(e),!0;if(X[i]||!(ee.tagCheck instanceof Function&&ee.tagCheck(i))&&!V[i]){const t=function(e,t){if(!X[t]&&mt(t)){if(Z.tagNameCheck instanceof RegExp&&It(Z.tagNameCheck,t))return!1;if(Z.tagNameCheck instanceof Function&&Z.tagNameCheck(t))return!1}if(ye&&!we[t]){const t=k(e),n=f(e);if(n&&t)for(let i=n.length-1;i>=0;--i){const s=ve?n[i]:p(n[i],!0);t.insertBefore(s,m(e))}}return Ke(e),!0}(e,i);return!1===t&<(N.afterSanitizeElements,e,null),t}if((b?b(e):e.nodeType)===pn&&!Qe(e))return Ke(e),!0;if(("noscript"===i||"noembed"===i||"noframes"===i)&&It(un,e.innerHTML))return Ke(e),!0;if(re&&e.nodeType===gn){const t=nt(e.textContent);e.textContent!==t&&(vt(n.removed,{element:e.cloneNode()}),e.textContent=t)}return lt(N.afterSanitizeElements,e,null),!1},pt=function(e,t,n){if(J[t])return!1;if(oe&&"patchsrc"===t)return!1;if(oe&&"for"===t&&"label"!==e&&"output"!==e)return!1;if(me&&("id"===t||"name"===t)&&(n in i||n in ze))return!1;const s=K[t]||ee.attributeCheck instanceof Function&&ee.attributeCheck(t,e);if(ne&&It(q,t));else if(te&&It(F,t));else if(s)if(Se[t]);else if(It(G,St(n,W,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==Ct(n,"data:")||!xe[e]){if(ie&&!It(z,St(n,W,"")));else if(n)return!1}else;else if(!(mt(e)&&(Z.tagNameCheck instanceof RegExp&&It(Z.tagNameCheck,e)||Z.tagNameCheck instanceof Function&&Z.tagNameCheck(e))&&(Z.attributeNameCheck instanceof RegExp&&It(Z.attributeNameCheck,t)||Z.attributeNameCheck instanceof Function&&Z.attributeNameCheck(t,e))||"is"===t&&Z.allowCustomizedBuiltInElements&&(Z.tagNameCheck instanceof RegExp&&It(Z.tagNameCheck,n)||Z.tagNameCheck instanceof Function&&Z.tagNameCheck(n))))return!1;return!0},gt=Nt({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),mt=function(e){return!gt[$t(e)]&&It(H,e)},Dt=function(e,t,n,i){if($&&"object"==typeof u&&"function"==typeof u.getAttributeType&&!n)switch(u.getAttributeType(e,t)){case"TrustedHTML":return A(i);case"TrustedScriptURL":return function(e){T(),C++;try{return $.createScriptURL(e)}finally{C--}}(i)}return i},Ut=function(e,t,i,s){try{i?e.setAttributeNS(i,t,s):e.setAttribute(t,s),rt(e)?Ke(e):yt(n.removed)}catch(M){Ze(t,e)}},wn=function(e){lt(N.beforeSanitizeAttributes,e,null);const t=e.attributes;if(!t||rt(e))return;const n={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:K,forceKeepAttr:void 0};let i=t.length;const s=qe(e.nodeName);for(;i--;){const r=t[i],o=r.name,a=r.namespaceURI,l=r.value,c=qe(o),d=l;let u="value"===o?d:Tt(d);n.attrName=c,n.attrValue=u,n.keepAttr=!0,n.forceKeepAttr=void 0,lt(N.uponSanitizeAttribute,e,n),u=n.attrValue,!fe||"id"!==c&&"name"!==c||0===Ct(u,ke)||(Ze(o,e),u=ke+u),oe&&It(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,u)?Ze(o,e):"attributename"===c&&Et(u,"href")?Ze(o,e):n.forceKeepAttr||(n.keepAttr&&(se||!It(hn,u))?(re&&(u=nt(u)),pt(s,c,u)?(u=Dt(s,c,a,u),u!==d&&Ut(e,o,a,u)):Ze(o,e)):Ze(o,e))}lt(N.afterSanitizeAttributes,e,null)},$n=function(e){let t=null;const n=tt(e);for(lt(N.beforeSanitizeShadowDOM,e,null);t=n.nextNode();)if(lt(N.uponSanitizeShadowNode,t,null),ht(t,e),wn(t),ot(t.content)&&$n(t.content),(b?b(t):t.nodeType)===pn){const e=y(t);ot(e)&&(xn(e),$n(e))}lt(N.afterSanitizeShadowDOM,e,null)},xn=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=(b?b(n):n.nodeType)===pn,s=f(n);if(s)for(let r=s.length-1;r>=0;--r)t.push({node:s[r],shadow:null});if(i){const e=w?w(n):null;if("string"==typeof e&&"template"===qe(e)){const e=n.content;ot(e)&&t.push({node:e,shadow:null})}}if(i){const e=y(n);ot(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,r=null,o=null,a=null;if(Pe=!e,Pe&&(e="\x3c!--\x3e"),"string"!=typeof e&&!at(e)&&"string"!=typeof(e=function(e){switch(typeof e){case"string":return e;case"number":return At(e);case"boolean":return Lt(e);case"bigint":return Rt?Rt(e):"0";case"symbol":return Pt?Pt(e):"Symbol()";case"undefined":default:return Ot(e);case"function":case"object":{if(null===e)return Ot(e);const t=e,n=Bt(t,"toString");if("function"==typeof n){const e=n(t);return"string"==typeof e?e:Ot(e)}return Ot(e)}}}(e)))throw Mt("dirty is not a string, aborting");if(!n.isSupported)return e;le?(V=ce,K=de):He(t),(N.uponSanitizeElement.length>0||N.uponSanitizeAttribute.length>0)&&(V=jt(V)),N.uponSanitizeAttribute.length>0&&(K=jt(K)),n.removed=[];const l=ve&&"string"!=typeof e&&at(e);if(l){!function(e){if(!oe)return;const t=[e];for(;t.length>0;){const e=t.pop(),n=b?b(e):e.nodeType;if(n===mn||n===fn&&It(dn,e.data)){try{g(e)}catch(M){}continue}if(n===pn){const t=e,n=qe(w?w(e):e.nodeName);try{t.hasAttribute&&t.hasAttribute("patchsrc")&&t.removeAttribute("patchsrc"),t.hasAttribute&&t.hasAttribute("for")&&"label"!==n&&"output"!==n&&t.removeAttribute("for")}catch(M){}}const i=f(e);if(i)for(let s=i.length-1;s>=0;--s)t.push(i[s])}}(e);const t=w?w(e):e.nodeName;if("string"==typeof t){const n=qe(t);if(!V[n]||X[n])throw Ye(e),Mt("root node is forbidden and cannot be sanitized in-place")}if(rt(e))throw Ye(e),Mt("root node is clobbered and cannot be sanitized in-place");try{xn(e)}catch(h){throw Ye(e),h}}else if(at(e))i=et("\x3c!----\x3e"),r=i.ownerDocument.importNode(e,!0),r.nodeType===pn&&"BODY"===r.nodeName||"HTML"===r.nodeName?i=r:i.appendChild(r),xn(r);else{if(!he&&!re&&!ae&&-1===e.indexOf("<"))return $&&ge?A(e):e;if(i=et(e),!i)return he?null:ge?E:""}i&&ue&&Ke(i.firstChild);const c=l?e:i,d=tt(c);try{for(;o=d.nextNode();)ht(o,c),wn(o),ot(o.content)&&$n(o.content)}catch(h){throw l&&(Ye(e),ft(n.removed,e=>{e.element&&Je(e.element)})),h}if(l)return ft(n.removed,e=>{e.element&&Je(e.element)}),re&&it(e),e;if(he){if(re&&it(i),pe)for(a=O.call(i.ownerDocument);i.firstChild;)a.appendChild(i.firstChild);else a=i;return(K.shadowroot||K.shadowrootmode)&&(a=D.call(s,a,!0)),a}let u=ae?i.outerHTML:i.innerHTML;return ae&&V["!doctype"]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&It(an,i.ownerDocument.doctype.name)&&(u="<!DOCTYPE "+i.ownerDocument.doctype.name+">\n"+u),re&&(u=nt(u)),$&&ge?A(u):u},n.setConfig=function(){He(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),le=!0,ce=V,de=K},n.clearConfig=function(){Fe=null,le=!1,ce=null,de=null,$=x,E=""},n.isValidAttribute=function(e,t,n){Fe||He({});const i=qe(e),s=qe(t);return pt(i,s,n)},n.addHook=function(e,t){"function"==typeof t&&_t(N,e)&&vt(N[e],t)},n.removeHook=function(e,t){if(_t(N,e)){if(void 0!==t){const n=kt(N[e],t);return-1===n?void 0:bt(N[e],n,1)[0]}return yt(N[e])}},n.removeHooks=function(e){_t(N,e)&&(N[e]=[])},n.removeAllHooks=function(){N={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},n}(),$n=["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"],xn=new Set(["title","accesskey"]),En={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"])},Sn=[...new Set([...xn,...Object.values(En).flatMap(e=>[...e])])],Cn=new Set(["href","src","data-src"]),Tn=new Set(["http","https","mailto","data"]);function An(e){var t;const n=[...e].filter(e=>{const t=e.codePointAt(0)||0;return t>32&&(t<127||t>159)}).join(""),i=null===(t=/^([a-z][a-z\d+.-]*):/i.exec(n))||void 0===t?void 0:t[1].toLowerCase();return!i||Tn.has(i)}function Ln(e){const t=wn.sanitize(e,{ALLOWED_TAGS:$n,ALLOWED_ATTR:Sn,ALLOW_ARIA_ATTR:!1,ALLOW_DATA_ATTR:!1,ALLOW_UNKNOWN_PROTOCOLS:!0,ADD_DATA_URI_TAGS:["a"]}),n=document.createElement("template");return n.innerHTML=t,n.content.querySelectorAll("*").forEach(e=>{const t=e.tagName.toLowerCase(),n=En[t];for(const o of[...e.attributes])xn.has(o.name)||(null==n?void 0:n.has(o.name))?Cn.has(o.name)&&!An(o.value)&&e.removeAttribute(o.name):e.removeAttribute(o.name);const i=e.getAttribute("class"),s="code"===t&&/^hljs\W+language-(.*)$/.test(i||"")||"span"===t&&/^(hljs-.*)$/.test(i||"")||"img"===t&&/^lazyload$/.test(i||"");i&&!s&&e.removeAttribute("class");const r=e.getAttribute("style");"span"===t&&r&&!/^color:(\W+)?#[0-9a-f]{3,6};?$/i.test(r)&&e.removeAttribute("style")}),n.innerHTML}var Rn=a(o((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),s=["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=s);var r=0,o={},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 s;o[t]?s=o[t]:(s=n[r],o[t]=s);var a='<span style="color: #'+s+'">'+t+"</span>";return r=++r%n.length,a})}},"object"==typeof e&&void 0!==t?t.exports=i():"function"==typeof define&&define.amd?define(i):n.hanabi=i()})(),1);function Pn(e){return(0,Rn.default)(e)}function _n(e){const t=new tt.Renderer;return t.link=In(t,t.link),t.code=Mn(),t.image=Dn(t,t.image,e),t}var On,In=(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"'} `)},Mn=()=>({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=Pn(t),`<pre rel="${n}">\n<code class="hljs language-${n}">${i.replace(/&/g,"&")}</code>\n</pre>`},Dn=(e,t,{imgLazyLoad:n})=>i=>{const s=t.call(e,i);return n?"native"===n||!0===n?s.replace(/^<img /,'<img class="lazyload" loading="lazy" '):"data-src"===n?s.replace(/^<img /,'<img class="lazyload" ').replace("src=","data-src="):s:s},Nn=[],Un={gfm:!0,breaks:!0,async:!1};function jn(){return On}function Bn(e){var t;let n=null===(t=jn())||void 0===t?void 0:t.parse(e);n||(n=function(e){return e.replace(/```\s*([^]+?.*?[^]+?[^]+?)```/g,(e,t)=>`<pre><code>${Pn(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=Ln(n);return Nn.forEach(e=>{"function"==typeof e&&(i=e(i))}),i}var qn=class{constructor(e){L(this,"_$root",void 0),L(this,"_deps",function(){const e=new Map,t=new Map,n=i=>{const s=e.get(i);if(!s)throw new Error(`No provide for ${String(i)}`);if("singleton"===s.lifecycle&&t.has(i))return t.get(i);const{impl:r,deps:o}=s,a=r(...o.map(e=>n(e)));return t.set(i,a),a};return{provide:(t,n,i,s={})=>{e.set(t,{impl:n,deps:i||[],lifecycle:s.lifecycle||"singleton"})},inject:n}}()),L(this,"provide",(e,t,n,i)=>{this._deps.provide(e,t,n,i)}),L(this,"inject",e=>this._deps.inject(e)),L(this,"get",this.inject),L(this,"on",(e,t)=>{this.inject("events").on(e,t)}),L(this,"off",(e,t)=>{this.inject("events").off(e,t)}),L(this,"trigger",(e,t)=>{this.inject("events").trigger(e,t)}),L(this,"getCommentList",this.getCommentNodes),L(this,"getCommentDataList",this.getComments),this._$root=e}getEl(){return this._$root}destroy(){for(this.trigger("unmounted");this._$root.firstChild;)this._$root.removeChild(this._$root.firstChild)}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 jn()}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 C(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 Fn(...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 s=e[i],r=n[i];Array.isArray(s)&&Array.isArray(r)?e[i]=s.concat(...r):t(s)&&t(r)?e[i]=Fn(s,r):e[i]=r}),e),{})}var zn={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 Wn(e,t=!1){const n=t?Fn(zn,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 Hn(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,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 Gn(e){return Vn.apply(this,arguments)}function Vn(){return Vn=c(function*(e){yield function(e){return Kn.apply(this,arguments)}(e),yield function(e,t){return Yn.apply(this,arguments)}(e,yield function(e){return Qn.apply(this,arguments)}(e))}),Vn.apply(this,arguments)}function Qn(){return(Qn=c(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 Kn(){return(Kn=c(function*(e){yield Zn({opt:e,query:"page_comment",containers:[e.countEl,"#ArtalkCount"]})})).apply(this,arguments)}function Yn(){return(Yn=c(function*(e,t){yield Zn({opt:e,query:"page_pv",containers:[e.pvEl,"#ArtalkPV"],cache:t})})).apply(this,arguments)}function Zn(e){return Xn.apply(this,arguments)}function Xn(){return(Xn=c(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),s=function(e,t,n,i){const s=Array.from(e).map(e=>e.getAttribute(t)||n).filter(e=>e&&"number"!=typeof i[e]);return[...new Set(s)]}(i,t.pageKeyAttr,t.pageKey,n);if(s.length>0){const i=(yield t.getApi().stats.getStats(e.query,{page_keys:s.join(","),site_name:t.siteName})).data.data;n=P(P({},n),i)}!function(e,t,n){e.forEach(e=>{const i=e.getAttribute("data-page-key"),s=i&&t[i]||n&&t[n]||0;e.innerText=`${Number(s)}`})}(i,n,t.pageKey)})).apply(this,arguments)}var Jn,ei=["body","secure","path","type","query","format","baseUrl","cancelToken"],ti=class{constructor(e={}){var t,n=this;L(this,"baseUrl","/api/v2"),L(this,"securityData",null),L(this,"securityWorker",void 0),L(this,"abortControllers",new Map),L(this,"customFetch",(...e)=>fetch(...e)),L(this,"baseApiParams",{credentials:"same-origin",headers:{},redirect:"follow",referrerPolicy:"no-referrer"}),L(this,"setSecurityData",e=>{this.securityData=e}),L(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)}),L(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}),L(this,"abortRequest",e=>{const t=this.abortControllers.get(e);t&&(t.abort(),this.abortControllers.delete(e))}),L(this,"request",(t=c(function*(e){let{body:t,secure:i,path:s,type:r,query:o,format:a,baseUrl:l,cancelToken:d}=e,u=function(e,t){if(null==e)return{};var n,i,s=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 r=Object.getOwnPropertySymbols(e);for(i=0;i<r.length;i++)n=r[i],t.includes(n)||{}.propertyIsEnumerable.call(e,n)&&(s[n]=e[n])}return s}(e,ei);const h=("boolean"==typeof i?i:n.baseApiParams.secure)&&n.securityWorker&&(yield n.securityWorker(n.securityData))||{},p=n.mergeRequestParams(u,h),g=o&&n.toQueryString(o),m=n.contentFormatters[r||"application/json"],f=a||p.format;return n.customFetch(`${l||n.baseUrl||""}${s}${g?`?${g}`:""}`,P(P({},p),{},{headers:P(P({},p.headers||{}),r&&"multipart/form-data"!==r?{"Content-Type":r}:{}),signal:(d?n.createAbortSignal(d):p.signal)||null,body:null==t?null:m(t)})).then((k=c(function*(e){const t=e;t.data=null,t.error=null;const i=f?e.clone():e,s=f?yield i[f]().then(e=>(t.ok?t.data=e:t.error=e,t)).catch(e=>(t.error=e,t)):t;if(d&&n.abortControllers.delete(d),!e.ok)throw s;return s}),function(e){return k.apply(this,arguments)}));var k}),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 P(P(P(P({},this.baseApiParams),e),t||{}),{},{headers:P(P(P({},this.baseApiParams.headers||{}),e.headers||{}),t&&t.headers||{})})}},ni=class extends ti{constructor(...e){super(...e),L(this,"auth",{loginByEmail:(e,t={})=>this.request(P({path:"/auth/email/login",method:"POST",body:e,type:"application/json",format:"json"},t)),registerByEmail:(e,t={})=>this.request(P({path:"/auth/email/register",method:"POST",body:e,type:"application/json",format:"json"},t)),sendVerifyEmail:(e,t={})=>this.request(P({path:"/auth/email/send",method:"POST",body:e,type:"application/json",format:"json"},t)),checkDataMerge:(e={})=>this.request(P({path:"/auth/merge",method:"GET",secure:!0,format:"json"},e)),applyDataMerge:(e,t={})=>this.request(P({path:"/auth/merge",method:"POST",body:e,secure:!0,type:"application/json",format:"json"},t))}),L(this,"cache",{flushCache:(e={})=>this.request(P({path:"/cache/flush",method:"POST",secure:!0,format:"json"},e)),warmUpCache:(e={})=>this.request(P({path:"/cache/warm_up",method:"POST",secure:!0,format:"json"},e))}),L(this,"captcha",{getCaptcha:(e={})=>this.request(P({path:"/captcha",method:"GET",format:"json"},e)),getCaptchaStatus:(e={})=>this.request(P({path:"/captcha/status",method:"GET",format:"json"},e)),verifyCaptcha:(e,t={})=>this.request(P({path:"/captcha/verify",method:"POST",body:e,type:"application/json",format:"json"},t))}),L(this,"comments",{getComments:(e,t={})=>this.request(P({path:"/comments",method:"GET",query:e,secure:!0,type:"application/json",format:"json"},t)),createComment:(e,t={})=>this.request(P({path:"/comments",method:"POST",body:e,secure:!0,type:"application/json",format:"json"},t)),getComment:(e,t={})=>this.request(P({path:`/comments/${e}`,method:"GET",type:"application/json",format:"json"},t)),updateComment:(e,t,n={})=>this.request(P({path:`/comments/${e}`,method:"PUT",body:t,secure:!0,type:"application/json",format:"json"},n)),deleteComment:(e,t={})=>this.request(P({path:`/comments/${e}`,method:"DELETE",secure:!0,format:"json"},t))}),L(this,"conf",{conf:(e={})=>this.request(P({path:"/conf",method:"GET",format:"json"},e)),getSocialLoginProviders:(e={})=>this.request(P({path:"/conf/auth/providers",method:"GET",format:"json"},e)),getDomain:(e,t={})=>this.request(P({path:"/conf/domain",method:"GET",query:e,format:"json"},t))}),L(this,"notifies",{getNotifies:(e,t={})=>this.request(P({path:"/notifies",method:"GET",query:e,type:"application/json",format:"json"},t)),markAllNotifyRead:(e,t={})=>this.request(P({path:"/notifies/read",method:"POST",body:e,type:"application/json",format:"json"},t)),markNotifyRead:(e,t,n={})=>this.request(P({path:`/notifies/${e}/${t}`,method:"POST",format:"json"},n))}),L(this,"pages",{getPages:(e,t={})=>this.request(P({path:"/pages",method:"GET",query:e,secure:!0,type:"application/json",format:"json"},t)),fetchAllPages:(e,t={})=>this.request(P({path:"/pages/fetch",method:"POST",body:e,secure:!0,type:"application/json",format:"json"},t)),getPageFetchStatus:(e={})=>this.request(P({path:"/pages/fetch/status",method:"GET",secure:!0,format:"json"},e)),logPv:(e,t={})=>this.request(P({path:"/pages/pv",method:"POST",body:e,type:"application/json",format:"json"},t)),updatePage:(e,t,n={})=>this.request(P({path:`/pages/${e}`,method:"PUT",body:t,secure:!0,type:"application/json",format:"json"},n)),deletePage:(e,t={})=>this.request(P({path:`/pages/${e}`,method:"DELETE",secure:!0,format:"json"},t)),fetchPage:(e,t={})=>this.request(P({path:`/pages/${e}/fetch`,method:"POST",secure:!0,type:"application/json",format:"json"},t))}),L(this,"sendEmail",{sendEmail:(e,t={})=>this.request(P({path:"/send_email",method:"POST",body:e,secure:!0,type:"application/json",format:"json"},t))}),L(this,"settings",{getSettings:(e={})=>this.request(P({path:"/settings",method:"GET",secure:!0,format:"json"},e)),applySettings:(e,t={})=>this.request(P({path:"/settings",method:"PUT",body:e,secure:!0,type:"application/json",format:"json"},t)),getSettingsTemplate:(e,t={})=>this.request(P({path:`/settings/template/${e}`,method:"GET",secure:!0,format:"json"},t))}),L(this,"sites",{getSites:(e={})=>this.request(P({path:"/sites",method:"GET",secure:!0,format:"json"},e)),createSite:(e,t={})=>this.request(P({path:"/sites",method:"POST",body:e,secure:!0,type:"application/json",format:"json"},t)),updateSite:(e,t,n={})=>this.request(P({path:`/sites/${e}`,method:"PUT",body:t,secure:!0,type:"application/json",format:"json"},n)),deleteSite:(e,t={})=>this.request(P({path:`/sites/${e}`,method:"DELETE",secure:!0,format:"json"},t))}),L(this,"sso",{authSsoExchange:(e,t={})=>this.request(P({path:"/sso/exchange",method:"POST",body:e,type:"application/json",format:"json"},t))}),L(this,"stats",{getStats:(e,t,n={})=>this.request(P({path:`/stats/${e}`,method:"GET",query:t,type:"application/json",format:"json"},n))}),L(this,"transfer",{exportArtrans:(e={})=>this.request(P({path:"/transfer/export",method:"GET",secure:!0,format:"json"},e)),importArtrans:(e,t={})=>this.request(P({path:"/transfer/import",method:"POST",body:e,secure:!0,type:"application/json"},t)),uploadArtrans:(e,t={})=>this.request(P({path:"/transfer/upload",method:"POST",body:e,secure:!0,type:"multipart/form-data",format:"json"},t))}),L(this,"upload",{upload:(e,t={})=>this.request(P({path:"/upload",method:"POST",body:e,secure:!0,type:"multipart/form-data",format:"json"},t))}),L(this,"user",{getUser:(e,t={})=>this.request(P({path:"/user",method:"GET",query:e,secure:!0,format:"json"},t)),updateProfile:(e,t={})=>this.request(P({path:"/user",method:"POST",body:e,secure:!0,type:"application/json",format:"json"},t)),login:(e,t={})=>this.request(P({path:"/user/access_token",method:"POST",body:e,type:"application/json",format:"json"},t)),getUserStatus:(e,t={})=>this.request(P({path:"/user/status",method:"GET",query:e,secure:!0,format:"json"},t))}),L(this,"users",{createUser:(e,t={})=>this.request(P({path:"/users",method:"POST",body:e,secure:!0,type:"application/json",format:"json"},t)),updateUser:(e,t,n={})=>this.request(P({path:`/users/${e}`,method:"PUT",body:t,secure:!0,type:"application/json",format:"json"},n)),deleteUser:(e,t={})=>this.request(P({path:`/users/${e}`,method:"DELETE",secure:!0,format:"json"},t)),getUsers:(e,t,n={})=>this.request(P({path:`/users/${e}`,method:"GET",query:t,secure:!0,type:"application/json",format:"json"},n))}),L(this,"version",{getVersion:(e={})=>this.request(P({path:"/version",method:"GET",format:"json"},e))}),L(this,"votes",{syncVotes:(e={})=>this.request(P({path:"/votes/sync",method:"POST",secure:!0,format:"json"},e)),getVote:(e,t,n={})=>this.request(P({path:`/votes/${e}/${t}`,method:"GET",type:"application/json",format:"json"},n)),createVote:(e,t,n,i,s={})=>this.request(P({path:`/votes/${e}/${t}/${n}`,method:"POST",body:i,type:"application/json",format:"json"},s))})}},ii=(Jn=c(function*(e,t,n){const i=e.getApiToken&&e.getApiToken(),s=new Headers(P({Authorization:i?`Bearer ${i}`:""},null==n?void 0:n.headers));s.get("Authorization")||s.delete("Authorization");const r=yield fetch(t,P(P({},n),{},{headers:s}));if(!r.ok){const i=(yield r.json().catch(()=>{}))||{};let s=!1;if(e.handlers&&(yield e.handlers.get().reduce(function(){var e=c(function*(e,t){yield e,!0===i[t.action]&&(yield t.handler(i),s=!0)});return function(t,n){return e.apply(this,arguments)}}(),Promise.resolve())),s)return ii(e,t,n);throw function(e,t){const n=new si;return n.message=t.msg||t.message||"fetch error",n.code=e,n.data=t,console.error(n),n}(r.status,i)}return r}),function(e,t,n){return Jn.apply(this,arguments)}),si=class extends Error{constructor(...e){super(...e),L(this,"code",0),L(this,"message","fetch error"),L(this,"data",void 0)}};var ri=class extends ni{constructor(e){super({baseUrl:e.baseURL,customFetch:(t,n)=>ii(e,t,n)}),L(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}}},oi=class{constructor(e){L(this,"kit",void 0),L(this,"$btn",void 0),L(this,"$panel",void 0),L(this,"editorStateEffectWhen",void 0),this.kit=e}useBtn(e="<div></div>"){return this.$btn=d(`<span class="atk-plug-btn">${e}</span>`),this.$btn}usePanel(e="<div></div>"){return this.$panel=d(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}},ai="ArtalkContent",li=class{constructor(e){L(this,"kit",void 0),this.kit=e}reqAdd(){var e=this;return c(function*(){return(yield e.kit.useApi().comments.createComment(P({},yield e.getSubmitAddParams()))).data})()}getSubmitAddParams(){var e=this;return c(function*(){const{name:t,email:n,link:i}=e.kit.useUser().getData(),s=e.kit.useConf();return{content:e.kit.useEditor().getContentFinal(),name:t,email:n,link:i,rid:0,page_key:s.pageKey,page_title:s.pageTitle,site_name:s.site,ua:yield f()}})()}postSubmitAdd(e){this.kit.useData().insertComment(e)}},ci=class extends oi{constructor(e){super(e),L(this,"customs",[]),L(this,"defaultPreset",void 0),this.defaultPreset=new li(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 c(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(`${C("commentFail")}: ${n.message||String(n)}`,"e")}finally{e.kit.useEditor().hideLoading()}e.kit.useEditor().reset(),e.kit.useEvents().trigger("editor-submitted")})()}},di=class extends oi{constructor(...e){super(...e),L(this,"isMoved",!1)}move(e){if(this.isMoved)return;this.isMoved=!0;const t=this.kit.useUI().$el;t.after(d('<div class="atk-editor-travel-placeholder"></div>'));const n=d("<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 ui(e,t){let n=e.querySelector(":scope > .atk-loading");n||(n=d('<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 hi(e){const t=e.querySelector(":scope > .atk-loading");t&&(t.style.display="none")}function pi(e,t){e?ui(t):hi(t)}function gi(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 s={top:i,left:0,behavior:"instant"};n?n.scroll(s):window.scroll(s)}function mi(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 fi(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=d(`<div class="atk-error-layer">${n}<span class="atk-error-text"></span></div>`),e.appendChild(i));const s=i.querySelector(".atk-error-text");s.innerHTML="",null!==t&&(t instanceof HTMLElement?s.appendChild(t):s.innerText=t)}var ki=class extends oi{constructor(e){var t;super(e),t=this,L(this,"emoticons",[]),L(this,"loadingTask",null),L(this,"$grpWrap",void 0),L(this,"$grpSwitcher",void 0),L(this,"isListLoaded",!1),L(this,"isImgLoaded",!1),this.kit.useMounted(()=>{this.usePanel('<div class="atk-editor-plug-emoticons"></div>'),this.useBtn(`<i aria-label="${C("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(()=>{c(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 c(function*(){e.isListLoaded||(null===e.loadingTask?(e.loadingTask=c(function*(){ui(e.$panel),e.emoticons=yield e.handleData(e.kit.useConf().emoticons),hi(e.$panel),e.loadingTask=null,e.isListLoaded=!0})(),yield e.loadingTask):yield e.loadingTask)})()}handleData(e){var t=this;return c(function*(){if(!Array.isArray(e)&&["object","string"].includes(typeof e)&&(e=[e]),!Array.isArray(e))return fi(t.$panel,`[${C("emoticon")}] Data must be of Array/Object/String type`),hi(t.$panel),[];const n=t=>{"object"==typeof t&&(t.name&&e.find(e=>e.name===t.name)||e.push(t))},i=function(){var e=c(function*(e){yield Promise.all(e.map(function(){var e=c(function*(e,s){if("object"!=typeof e||Array.isArray(e)){if(Array.isArray(e))yield i(e);else if("string"==typeof e){const s=yield t.remoteLoad(e);Array.isArray(s)?yield i(s):"object"==typeof s&&n(s)}}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 c(function*(){if(!e)return[];try{return yield(yield fetch(e)).json()}catch(n){return hi(t.$panel),console.error("[Emoticons] Load Failed:",n),fi(t.$panel,`[${C("emoticon")}] ${C("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 s=t.icon;if(/<(img|IMG)/.test(s)){const e=/src=["'](.*?)["']/.exec(s);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=d('<div class="atk-grp-wrap"></div>'),this.$panel.append(this.$grpWrap),this.emoticons.forEach((e,t)=>{const n=d('<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=d('<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=d('<div class="atk-grp-switcher"></div>'),this.$panel.append(this.$grpSwitcher),this.emoticons.forEach((e,t)=>{const n=d("<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}},yi=["png","jpg","jpeg","gif","bmp","svg","webp"],vi=class extends oi{constructor(e){super(e),L(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=yi.map(e=>`.${e}`).join(",");const t=this.useBtn(`<i aria-label="${C("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=()=>{c(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 c(function*(){const n=/[^.]+$/.exec(e.name);if(!n||!yi.includes(String(n[0]).toLowerCase()))return;if(!t.kit.useUser().checkHasBasicUserInfo())return void t.kit.useEditor().showNotify(C("uploadLoginMsg"),"w");let i="\n";""===t.kit.useUI().$textarea.value.trim()&&(i="");const s=`${i}`;let r;t.kit.useEditor().insertContent(s);try{const n=t.kit.useConf().imgUploader;r=n?{public_url:yield n(e)}:(yield t.kit.useApi().upload.upload({file:e})).data}catch(o){console.error(o),t.kit.useEditor().showNotify(`${C("uploadFail")}: ${o.message}`,"e")}if(r&&r.public_url){let e=r.public_url;y(e)||(e=v({base:t.kit.useConf().server,path:e})),t.kit.useEditor().setContent(t.kit.useUI().$textarea.value.replace(s,`${i}`))}else t.kit.useEditor().setContent(t.kit.useUI().$textarea.value.replace(s,""))})()}},bi=class extends oi{constructor(e){super(e),L(this,"isPlugPanelShow",!1),this.kit.useMounted(()=>{this.usePanel('<div class="atk-editor-plug-preview"></div>'),this.useBtn(`<i aria-label="${C("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()}},wi=[class extends oi{constructor(e){super(e);const t=()=>{this.save()};this.kit.useMounted(()=>{const e=window.localStorage.getItem(ai)||"";""!==e.trim()&&(this.kit.useEditor().showNotify(C("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(ai,this.kit.useEditor().getContentRaw().trim())}},class extends oi{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,s])=>{s.addEventListener("input",t[e]=i("header-input",s,e)),s.addEventListener("change",n[e]=i("header-change",s,e))})}),this.kit.useUnmounted(()=>{Object.entries(this.$inputs).forEach(([e,i])=>{i.removeEventListener("input",t[e]),i.removeEventListener("change",n[e])})})}},class extends oi{constructor(e){super(e),L(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:C("nick"),email:C("email"),link:C("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(P({},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 oi{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 oi{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||C("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`}},ci,class extends oi{constructor(e){super(e);const t=()=>{this.kit.useEditor().submit()};this.kit.useMounted(()=>{this.kit.useUI().$submitBtn.innerText=this.kit.useConf().sendBtn||C("send"),this.kit.useUI().$submitBtn.addEventListener("click",t)}),this.kit.useUnmounted(()=>{this.kit.useUI().$submitBtn.removeEventListener("click",t)})}},di,class extends oi{constructor(e){var t;super(e),t=this,L(this,"comment",void 0),this.useEditorStateEffect("reply",e=>(this.setReply(e),()=>{this.cancelReply()})),this.kit.useEvents().on("mounted",()=>{const e=this.kit.useDeps(ci);if(!e)throw Error("SubmitPlug not initialized");const n=new li(this.kit);e.registerCustom({activeCond:()=>!!this.comment,req:function(){var e=c(function*(){if(!t.comment)throw new Error("reply comment cannot be empty");return(yield t.kit.useApi().comments.createComment(P(P({},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=d(`<span class="atk-state-btn"><span class="atk-text-wrap">${C("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 oi{constructor(e){var t;super(e),t=this,L(this,"comment",void 0),L(this,"originalSubmitBtnText","Send"),this.useEditorStateEffect("edit",e=>(this.edit(e),()=>{this.cancelEdit()})),this.kit.useMounted(()=>{const e=this.kit.useDeps(ci);if(!e)throw Error("SubmitPlug not initialized");e.registerCustom({activeCond:()=>!!this.comment,req:function(){var e=c(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,P(P({},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=d(`<span class="atk-state-btn"><span class="atk-text-wrap">${C("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(C("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 oi{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(d(`<div class="atk-comment-closed">${C("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")}},ki,vi,bi];var $i=class{constructor(e){L(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()}},xi=class{constructor(){L(this,"events",[])}on(e,t,n={}){this.events.push(P({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)})}},Ei=class{constructor(e){L(this,"opts",void 0),L(this,"plugins",[]),L(this,"openedPlug",null),L(this,"events",new xi),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(vi,e.imgUpload),t.set(ki,e.emoticons),t.set(bi,e.preview),t.set(di,e.editorTravel),wi.filter(e=>!t.has(e)||!!t.get(e))}(e).forEach(e=>{const t=new $i(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 xi,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 Si="2.10.0";function Ci(e){const t=d('<span><span class="error-message"></span><br/><br/></span>');if(t.querySelector(".error-message").innerText=`${C("listLoadFailMsg")}\n${e.errMsg}`,e.retryFn){const n=d(`<span style="cursor:pointer;">${C("listRetry")}</span>`);n.onclick=()=>e.retryFn&&e.retryFn(),t.appendChild(n)}if(e.onOpenSidebar){const n=d(`<span atk-only-admin-show> | <span style="cursor:pointer;">${C("openName",{name:C("ctrlCenter")})}</span></span>`);t.appendChild(n),n.onclick=()=>e.onOpenSidebar&&e.onOpenSidebar()}fi(e.$err,t)}var Ti=[e=>{const t=e.inject("config");e.on("list-fetch",n=>{if(e.getData().getLoading())return;e.getData().setLoading(!0);const i=P({offset:0,limit:t.get().pagination.pageSize,flatMode:t.get().flatMode,paramsModifier:t.get().listFetchParamsModifier},n);e.getData().setListLastFetch({params:i});const s={limit:i.limit,offset:i.offset,flat_mode:i.flatMode,page_key:t.get().pageKey,site_name:t.get().site};i.paramsModifier&&i.paramsModifier(s),e.getApi().comments.getComments(P(P({},s),e.getApi().getUserFields())).then(({data:t})=>{const n=s.scope;if(!(n&&"page"!==n||t.page))throw new Error("Page data is missing from comment list response");const r=t;e.getData().setListLastFetch({params:i,data:r}),e.getData().loadComments(r.comments),t.page&&e.getData().updatePage(t.page),i.onSuccess&&i.onSuccess(r),e.trigger("list-fetched",{params:i,data:r})}).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&&pi(!0,t.getEl())}),e.on("list-fetched",()=>{pi(!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=h("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(`${C("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=C("openComment"))):(null==n||n.getEvents().trigger("editor-open"),i&&(i.innerText=C("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=u(C("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?C("ctrlCenter"):C("msgCenter"))}else n.classList.add("atk-hide")};e.watchConf(["locale"],s=>{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()},s=e=>{!function(e){const{$dropdownWrap:t,dropdownList:n}=e;if(t.querySelector(".atk-dropdown"))return;t.classList.add("atk-dropdown-wrap"),t.append(d('<span class="atk-arrow-down-icon"></span>'));let i=0;const s=(e,t,n,s)=>{s(),i=e,r.querySelectorAll(".active").forEach(e=>{e.classList.remove("active")}),t.classList.add("active"),r.style.display="none",setTimeout(()=>{r.style.display=""},80)},r=d('<ul class="atk-dropdown atk-fade-in"></ul>');n.forEach((e,t)=>{const[n,o]=e,a=d('<li class="atk-dropdown-item"><span></span></li>'),l=a.querySelector("span");l.innerText=n,l.onclick=()=>{s(t,a,n,o)},r.append(a),t===i&&a.classList.add("active")}),t.append(r)}({$dropdownWrap:e,dropdownList:[[C("sortLatest"),()=>{i(e=>{e.sort_by="date_desc"})}],[C("sortBest"),()=>{i(e=>{e.sort_by="vote"})}],[C("sortOldest"),()=>{i(e=>{e.sort_by="date_asc"})}],[C("sortAuthor"),()=>{i(e=>{e.view_only_admin=!0})}]]})};e.watchConf(["listSort","locale"],e=>{const n=t.getEl().querySelector(".atk-comment-count");n&&(e.listSort?s(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(h("atk_comment")));return t||null}();i&&(n&&t===i||(t=i,e.trigger("list-goto",i)))},i=()=>n({locker:!1}),s=()=>n({locker:!0});e.on("mounted",()=>{window.addEventListener("hashchange",i),e.on("list-loaded",s)}),e.on("unmounted",()=>{window.removeEventListener("hashchange",i),e.off("list-loaded",s)})},e=>{const t=e.inject("list");e.on("list-goto",function(){var n=c(function*(n){let i=e.getCommentNodes().find(e=>e.getID()===n);if(!i){const s=(yield e.getApi().comments.getComment(n)).data;t.getLayout({forceFlatMode:!0}).insert(s.comment,s.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 s=i.length<=0;let r=t.getCommentsWrapEl().querySelector(".atk-list-no-comment");s?r||(r=d('<div class="atk-list-no-comment"></div>'),r.innerHTML=Ln(n.get().noComment||e.$t("noComment")),t.getCommentsWrapEl().appendChild(r)):null==r||r.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${Si}">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,s;const r=new Date(Number(t.getAttribute("data-atk-comment-date")));t.innerText=(null===(i=(s=n.get()).dateFormatter)||void 0===i?void 0:i.call(s,r))||m(r,e.$t)})},3e4)}),e.on("unmounted",()=>{i&&window.clearInterval(i)})},e=>{const t=e.inject("list");e.on("list-fetch",()=>{fi(t.getEl(),null)}),e.on("list-failed",n=>{Ci({$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 s=()=>{null==i||i.disconnect(),i=null};e.on("list-loaded",()=>{s();const r=t.getCommentsWrapEl().childNodes,o=r.length>2?r[r.length-2]:null;o&&("IntersectionObserver"in window?(t=>{var r,o;const a=(null===(r=(o=n.get()).scrollRelativeTo)||void 0===r?void 0:r.call(o))||null;i=new IntersectionObserver(([t])=>{t.isIntersecting&&(s(),e.trigger("list-reach-bottom"))},{threshold:.9,root:a}),i.observe(t)})(o):console.warn("IntersectionObserver api not supported"))}),e.on("unmounted",()=>{s()})},e=>{const t=e.inject("list"),n=e.inject("config"),i=()=>{var e,i;const s=null===(e=(i=n.get()).scrollRelativeTo)||void 0===e?void 0:e.call(i);(s||window).scroll({top:p(t.getEl(),s).top,left:0})};e.on("mounted",()=>{e.on("list-goto-first",i)}),e.on("unmounted",()=>{e.off("list-goto-first",i)})}],Ai=!1;var Li;function Ri(e,t){const n="atk-dark-mode";e.forEach(e=>{t?e.classList.add(n):e.classList.remove(n)})}var Pi={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 _i(e,t,n,i,s){var r,o;e.upCountEl?e.upCountEl.innerText=String(t):e.upBtnEl&&(e.upBtnEl.innerText=`${C("voteUp")} (${t})`),e.downCountEl?e.downCountEl.innerText=String(n):e.downBtnEl&&(e.downBtnEl.innerText=`${C("voteDown")} (${n})`),"boolean"==typeof i&&(null===(r=e.upBtnEl)||void 0===r||r.classList.toggle(e.activeClass||"active",i)),"boolean"==typeof s&&(null===(o=e.downBtnEl)||void 0===o||o.classList.toggle(e.activeClass||"active",s))}var Oi=(e,t)=>n=>{n.preventDefault();const{state:i,pageId:s,httpApi:r}=t();s&&r.votes.createVote("page",s,e,P({},r.getUserFields())).then(({data:e})=>{_i(i,e.up,e.down,e.is_up,e.is_down)}).catch(e=>{window.alert(C("voteFail")),console.error("[ArtalkPageVote]",e)})};var Ii="ArtalkUser",Mi=class{constructor(e){L(this,"opts",void 0),L(this,"data",void 0),this.opts=e;const t=JSON.parse(window.localStorage.getItem(Ii)||"{}");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}),window.localStorage.setItem(Ii,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}};function Di(e){const t=d('<div class="atk-checker-iframe-wrap"></div>'),n=d('<iframe class="atk-fade-in" referrerpolicy="strict-origin-when-cross-origin"></iframe>');n.style.display="none",ui(t,{transparentBg:!0}),n.src=e.getOpts().getCaptchaIframeURL(),n.onload=()=>{n.style.display="",hi(t)},t.append(n);const i=d('<div class="atk-close-btn"><i class="atk-icon atk-icon-close"></i></div>');t.append(i),e.hideInteractInput();let s=!1;return function(){var t=c(function*(){var t;if(yield(t=1e3,new Promise(e=>{window.setTimeout(()=>{e(null)},t)})),s)return;let i;try{i=(yield e.getApi().captcha.getCaptchaStatus()).data.is_pass}catch(r){i=!1}i?e.triggerSuccess():n()});function n(){return t.apply(this,arguments)}return n}()(),i.onclick=()=>{s=!0,e.cancel()},t}var Ni={request:(e,t)=>e.getApi().captcha.verifyCaptcha({value:t}),body:e=>e.get("iframe")?Di(e):function(e){const t=d(`<span><img class="atk-captcha-img" src="${e.get("img_data")||""}">${C("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=""}},Ui={inputType:"password",request:(e,t)=>c(function*(){return(yield e.getApi().user.login({name:e.getUser().getData().name,email:e.getUser().getData().email,password:t})).data})(),body:e=>d(`<span>${C("adminCheck")}</span>`),onSuccess(e,t,n,i){e.getUser().update({is_admin:!0,token:t.token}),e.getOpts().onReload()},onError(e,t,n,i){}},ji=class{constructor(e){L(this,"$el",void 0),L(this,"$content",void 0),L(this,"$actions",void 0),this.$el=d('<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=d(`<button data-action="confirm">${C("confirm")}</button>`);return t.onclick=this.onBtnClick(e),this.$actions.appendChild(t),this}setNo(e){const t=d(`<button data-action="cancel">${C("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 Bi(e){return t=>new Promise((n,i)=>{const s=t.onCancel;t.onCancel=()=>{s&&s(),i(new Error("user canceled the checker"))};const r=t.onSuccess;t.onSuccess=()=>{r&&r(),n()},e(t)})}var qi=class{constructor(e){L(this,"opts",void 0),L(this,"checkCaptcha",Bi(e=>{this.check(Ni,e,t=>{t.set("img_data",e.img_data),t.set("iframe",e.iframe)})})),L(this,"checkAdmin",Bi(e=>{this.check(Ui,e)})),this.opts=e}check(e,t,n){const i=this.opts.getLayers().create(`checker-${(new Date).getTime()}`);i.show();const s=()=>{i.destroy()},r={};let o=!1;const a={set:(e,t)=>{r[e]=t},get:e=>r[e],getOpts:()=>this.opts,getUser:()=>this.opts.getUser(),getApi:()=>this.opts.getApi(),hideInteractInput:()=>{o=!0},triggerSuccess:()=>{s(),e.onSuccess&&e.onSuccess(a,"","",l),t.onSuccess&&t.onSuccess()},cancel:()=>{s(),t.onCancel&&t.onCancel()}};n&&n(a);const l=d();l.appendChild(e.body(a));const c=d(`<input id="check" type="${e.inputType||"text"}" autocomplete="off" required placeholder="">`);let u;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 h=new ji(l);h.setYes(n=>{const i=c.value.trim();u||(u=n.innerText);const r=()=>{n.innerText=u||"",n.classList.remove("error")};return n.innerText=`${C("loading")}...`,e.request(a,i).then(n=>{s(),e.onSuccess&&e.onSuccess(a,n,i,l),t.onSuccess&&t.onSuccess()}).catch(t=>{var s;s=String(t.message||String(t)),n.innerText=s,n.classList.add("error"),e.onError&&e.onError(a,t,i,l);const o=setTimeout(()=>r(),3e3);c.onfocus=()=>{r(),clearTimeout(o)}}),!1}),h.setNo(()=>(s(),t.onCancel&&t.onCancel(),!1)),o&&(c.style.display="none",h.$el.querySelector(".atk-layer-dialog-actions").style.display="none"),i.getEl().append(h.$el),t.onMount&&t.onMount(h.$el)}},Fi={$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 zi,Wi,Hi=class{constructor(e){L(this,"editor",void 0),L(this,"stateCurt","normal"),L(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(di))||void 0===n||n.back());if("normal"!==e&&t){var i,s,r,o;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(di))||void 0===i||i.move(n);const a=null===(s=(r=this.editor.getOptions().getConf().get()).scrollRelativeTo)||void 0===s?void 0:s.call(r);gi(this.editor.getUI().$el,!0,a);const l=null===(o=this.editor.getPlugins())||void 0===o?void 0:o.getPlugins().find(t=>t.editorStateEffectWhen===e);l&&l.editorStateEffect&&(this.stateUnmountFn=l.editorStateEffect(t.comment))}this.stateCurt=e}},Gi=class{constructor(e){L(this,"opts",void 0),L(this,"_$el",void 0),L(this,"ui",void 0),L(this,"state",void 0),L(this,"plugins",void 0),this.opts=e,this.ui=function(){const e=d('<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(Fi).forEach(([n,i])=>{t[n]=e.querySelector(i)}),t}(),this._$el=this.ui.$el,this.state=new Hi(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 Bn(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=d(`<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=u(t).replace("\n","<br/>"),e.appendChild(i);const s=()=>{i.classList.add("atk-fade-out"),setTimeout(()=>{i.remove()},200)};let r;r=window.setTimeout(()=>{s()},3e3),i.addEventListener("click",()=>{s(),window.clearTimeout(r)})}(this.ui.$notifyWrap,e,t)}showLoading(){ui(this.ui.$el)}hideLoading(){hi(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()}},Vi=class{constructor(e){L(this,"events",void 0),L(this,"loading",!1),L(this,"listLastFetch",void 0),L(this,"comments",[]),L(this,"notifies",[]),L(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)}},Qi=class{constructor(e,t){L(this,"$el",void 0),L(this,"opts",void 0),L(this,"allowMaskClose",!0),L(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 Ki(){return{init(){zi=document.body.style.overflow,Wi=document.body.style.paddingRight},unlock(){document.body.style.overflow=zi,document.body.style.paddingRight=Wi},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 Yi=class{constructor(){L(this,"$wrap",void 0),L(this,"$mask",void 0),L(this,"items",[]),this.$wrap=d('<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 Qi(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"),Ki().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",Ki().unlock())}},Zi=class{constructor(){L(this,"wrap",new Yi),Ki().init()}getEl(){return this.wrap.getWrap()}create(e,t){return this.wrap.createItem(e,t)}destroy(){this.wrap.getWrap().remove()}};var Xi=e=>({import:t=>{(function(e,t="DATE_DESC",n=2){const i=[];e.filter(e=>0===e.rid).forEach(t=>{const s={id:t.id,comment:t,children:[],level:1};s.parent=s,i.push(s),function t(i){const s=e.filter(e=>e.rid===i.id);0!==s.length&&(i.level>=n&&(i=i.parent),s.forEach(e=>{const n={id:e.id,comment:e,children:[],parent:i,level:i.level+1};i.children.push(n),t(n)}))}(s)});const s=(n,i)=>{let s=n.id-i.id;return"DATE_ASC"===t?s=+new Date(n.comment.date)-+new Date(i.comment.date):"DATE_DESC"===t?s=+new Date(i.comment.date)-+new Date(n.comment.date):"SRC_INDEX"===t?s=e.indexOf(n.comment)-e.indexOf(i.comment):"VOTE_UP_DESC"===t&&(s=i.comment.vote_up-n.comment.vote_up),s};return function e(t){t.forEach(t=>{t.children=t.children.sort(s),e(t.children)})}(i),i})(t,e.nestSortBy,e.nestMax).forEach(n=>{var i;const s=e.createCommentNode(n.comment);null===(i=e.$commentsWrap)||void 0===i||i.appendChild(s.getEl()),s.getRender().playFadeAnim();const r=(n,i)=>{i.children.forEach(i=>{const s=t.find(e=>e.id===i.comment.rid),o=i.comment,a=e.createCommentNode(o,s);n.putChild(a),r(a,i)})};r(s,n),s.getRender().checkHeightLimit()})},insert:(t,n)=>{const i=e.createCommentNode(t,n);if(0===t.rid){var s;null===(s=e.$commentsWrap)||void 0===s||s.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 Ji(e,t,n,i){n.is_collapsed&&(n.is_allow_reply=!1);const s=e.createCommentNode(n,i);if(n.visible){const n=s.getEl(),i=e.$commentsWrap;"append"===t&&(null==i||i.append(n)),"prepend"===t&&(null==i||i.prepend(n)),s.getRender().playFadeAnim()}return s.getRender().checkHeightLimit(),s}var es=class{constructor(e){L(this,"options",void 0),this.options=e}getStrategy(){return this.options.flatMode?(e=this.options,{import:t=>{t.forEach(n=>{Ji(e,"append",n,0===n.rid?void 0:t.find(e=>e.id===n.rid))})},insert:(t,n)=>{Ji(e,"prepend",t,n).scrollIntoView()}}):Xi(this.options);var e}import(e){this.getStrategy().import(e)}insert(e,t){this.getStrategy().insert(e,t)}};function ts(e,t){t.forEach(({el:t,max:n,imgCheck:i})=>{if(!t)return;i&&(t.style.maxHeight=`${n+1}px`);let s=!1;const r=()=>{if(s)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(ss))return;e.el.classList.add(ss),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(ns))return;e.el.classList.add(ns),e.el.style.height=`${e.max}px`,e.el.style.overflow="hidden";const t=d(`<div class="atk-height-limit-btn">${C("readMore")}</span>`);t.onclick=t=>{t.stopPropagation(),is(e.el),e.afterExpandBtnClick&&e.afterExpandBtnClick(t)},e.el.append(t)}({el:t,max:n,afterExpandBtnClick:()=>{var t;s=!0,null===(t=e.afterExpandBtnClick)||void 0===t||t.call(e)}})};if(r(),i){const e=t.querySelectorAll(".atk-content img");0===e.length&&(t.style.maxHeight=""),e.forEach(e=>{e.onload=()=>r()})}})}var ns="atk-height-limit";function is(e){e&&e.classList.contains(ns)&&(e.classList.remove(ns),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 ss="atk-height-limit-scroll";function rs(e){if(e.$headerNick=e.$el.querySelector(".atk-nick"),e.data.link){const t=d('<a target="_blank" rel="noreferrer noopener nofollow ugc"></a>');t.innerText=e.data.nick,t.href=y(e.data.link)?e.data.link:`https://${e.data.link}`,e.$headerNick.append(t)}else e.$headerNick.innerText=e.data.nick}function os(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=d('<span class="atk-badge"></span>');i.innerText=t.replace("管理员",C("admin")),i.style.backgroundColor=n||"",e.$headerBadgeWrap.append(i)}else if(e.data.is_verified){const t=d(`<span class="atk-icon-verified" title="${C("emailVerified")}"></span>`);e.$headerBadgeWrap.append(t)}if(e.data.is_pinned){const t=d(`<span class="atk-pinned-badge">${C("pin")}</span>`);e.$headerBadgeWrap.append(t)}}function as(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 ls(e){if(!e.opts.uaBadge&&!e.data.ip_region)return;let t=e.$header.querySelector("atk-ua-wrap");if(t||(t=d('<span class="atk-ua-wrap"></span>'),e.$header.append(t)),t.innerHTML="",e.data.ip_region){const n=d('<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=d('<span class="atk-ua ua-browser"></span>');e.innerText=n,t.append(e)}if(String(i).trim()){const e=d('<span class="atk-ua ua-os"></span>');e.innerText=i,t.append(e)}}}var cs=class{get isMessaging(){return!!this.msgRecTimer}constructor(e){L(this,"opts",void 0),L(this,"$el",void 0),L(this,"isLoading",!1),L(this,"msgRecTimer",void 0),L(this,"msgRecTimerFunc",void 0),L(this,"isConfirming",!1),L(this,"confirmRecTimer",void 0),this.$el=d('<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||C("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||`${C("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 ds(e){e.opts.vote&&(e.voteBtnUp=new cs(()=>`${C("voteUp")} (${e.data.vote_up||0})`).appendTo(e.$actions),e.voteBtnUp.setClick(()=>{e.comment.getActions().vote("up")}),e.opts.voteDown&&(e.voteBtnDown=new cs(()=>`${C("voteDown")} (${e.data.vote_down||0})`).appendTo(e.$actions),e.voteBtnDown.setClick(()=>{e.comment.getActions().vote("down")})))}function us(e){if(!e.data.is_allow_reply)return;const t=new cs({text:C("reply")});t.appendTo(e.$actions),t.setClick(()=>{e.opts.replyComment(e.data,e.$el)})}function hs(e){const t=new cs({text:()=>e.data.is_collapsed?C("expand"):C("collapse"),adminOnly:!0});t.appendTo(e.$actions),t.setClick(()=>{e.comment.getActions().adminEdit("collapsed",t)})}function ps(e){const t=new cs({text:()=>e.data.is_pending?C("pending"):C("approved"),adminOnly:!0});t.appendTo(e.$actions),t.setClick(()=>{e.comment.getActions().adminEdit("pending",t)})}function gs(e){const t=new cs({text:()=>e.data.is_pinned?C("unpin"):C("pin"),adminOnly:!0});t.appendTo(e.$actions),t.setClick(()=>{e.comment.getActions().adminEdit("pinned",t)})}function ms(e){const t=new cs({text:C("edit"),adminOnly:!0});t.appendTo(e.$actions),t.setClick(()=>{e.opts.editComment(e.data,e.$el)})}function fs(e){const t=new cs({text:C("delete"),confirm:!0,confirmText:C("deleteConfirm"),adminOnly:!0});t.appendTo(e.$actions),t.setClick(()=>{e.comment.getActions().adminDelete(t)})}var ks={Avatar:function(e){const t=e.$el.querySelector(".atk-avatar"),n=d("<img />"),i=e.opts.avatarURLBuilder;if(n.src=i?i(e.data):e.comment.getGravatarURL(),e.data.link){const i=d('<a target="_blank" rel="noreferrer noopener nofollow ugc"></a>');i.href=y(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:rs,renderVerifyBadge:os,renderDate:as,renderUABadge:ls}).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=d(`\n <div class="atk-collapsed">\n <span class="atk-text">${C("collapsedMsg")}</span>\n <span class="atk-show-btn">${C("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"),mi(e.$content),n.innerText=C("collapse")):(e.$content.innerHTML="",e.$content.classList.add("atk-hide"),n.innerText=C("expand"))})},ReplyAt:function(e){e.opts.flatMode||0===e.data.rid||e.opts.replyTo&&(e.$replyAt=d('<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=d(`\n <div class="atk-reply-to">\n <div class="atk-meta">${C("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=Bn(e.opts.replyTo.content);e.opts.replyTo.is_collapsed&&(n=`[${C("collapsed")}]`),e.$replyTo.querySelector(".atk-content").innerHTML=n,e.$body.prepend(e.$replyTo)},Pending:function(e){if(!e.data.is_pending)return;const t=d(`<div class="atk-pending">${C("pendingMsg")}</div>`);e.$body.prepend(t)},Actions:function(e){Object.entries({renderVote:ds,renderReply:us,renderCollapse:hs,renderModerator:ps,renderPin:gs,renderEdit:ms,renderDel:fs}).forEach(([t,n])=>{n(e)})}};var ys=class{get data(){return this.comment.getData()}get opts(){return this.comment.getOpts()}constructor(e){L(this,"comment",void 0),L(this,"$el",void 0),L(this,"$main",void 0),L(this,"$header",void 0),L(this,"$headerNick",void 0),L(this,"$headerBadgeWrap",void 0),L(this,"$body",void 0),L(this,"$content",void 0),L(this,"$childrenWrap",void 0),L(this,"$actions",void 0),L(this,"voteBtnUp",void 0),L(this,"voteBtnDown",void 0),L(this,"$replyTo",void 0),L(this,"$replyAt",void 0),this.comment=e}render(){var e;return this.$el=d('<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(ks).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;ts({afterExpandBtnClick:()=>{const e=this.comment.getChildren();1===e.length&&is(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&&is(this.$childrenWrap)}playFadeAnim(){mi(this.comment.getRender().$el)}playFadeAnimForBody(){mi(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=d('<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()}}},vs=class{get data(){return this.comment.getData()}get opts(){return this.comment.getOpts()}getApi(){return this.comment.getOpts().getApi()}constructor(e){L(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,P({},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(C("voteFail")),console.error(e)})}adminEdit(e,t){if(t.isLoading)return;t.setLoading(!0,`${C("editing")}...`);const n=P({},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,P({},n)).then(e=>{t.setLoading(!1),this.comment.setData(e.data)}).catch(e=>{console.error(e),t.setError(C("editFail"))})}adminDelete(e){e.isLoading||(e.setLoading(!0,`${C("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(C("deleteFail"))}))}goToReplyComment(){const e=window.location.hash,t=`#atk-comment-${this.data.rid}`;window.location.hash=t,t===e&&window.dispatchEvent(new Event("hashchange"))}},bs=class{constructor(e,t){L(this,"$el",void 0),L(this,"renderInstance",void 0),L(this,"actionInstance",void 0),L(this,"data",void 0),L(this,"opts",void 0),L(this,"parent",void 0),L(this,"children",[]),L(this,"nestCurt",void 0),this.opts=t,this.data=P({},e),this.data.date=this.data.date.replace(/-/g,"/"),this.parent=null,this.nestCurt=1,this.actionInstance=new vs(this),this.renderInstance=new ys(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&&gi(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 Bn(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))||m(n,C)}getUserUA(){const e=function(e){const t=window||{},n=navigator||{},i=String(e||n.userAgent),s={os:"",osVersion:"",engine:"",browser:"",device:"",language:"",version:""},r={Trident:i.includes("Trident")||i.includes("NET CLR"),Presto:i.includes("Presto"),WebKit:i.includes("AppleWebKit"),Gecko:i.includes("Gecko/")},o={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"):o.Chrome&&i.includes("Edg")?(o.Chrome=!1,o.Edge=!0):t.showModalDialog&&t.chrome&&(o.Chrome=!1,o[360]=!0),s.device="PC",s.language=(()=>{const e=(n.browserLanguage||n.language).split("-");return e[1]&&(e[1]=e[1].toUpperCase()),e.join("_")})(),Object.entries({engine:r,browser:o,os:a,device:l}).forEach(([e,t])=>{Object.entries(t).forEach(([t,n])=>{!0===n&&(s[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")};s.osVersion="",c[s.os]&&(s.osVersion=c[s.os](),s.osVersion===i&&(s.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 s.version="",d[s.browser]&&(s.version=d[s.browser](),s.version===i&&(s.version="")),s.version.indexOf(".")&&(s.version=s.version.substring(0,s.version.indexOf("."))),"iOS"===s.os&&i.includes("iPad")?s.os="iPadOS":"Edge"!==s.browser||i.includes("Edg")?"MIUI"===s.browser?s.os="Android":"Chrome"===s.browser&&Number(s.version)>27||"Opera"===s.browser&&Number(s.version)>12||"Yandex"===s.browser?s.engine="Blink":void 0===s.browser&&(s.browser="Unknow App"):s.engine="EdgeHTML",s}(this.data.ua);return{browser:`${e.browser} ${e.version}`,os:`${e.os} ${e.osVersion}`}}getOpts(){return this.opts}};var ws=class{get hasMore(){return this.total>this.offset+this.opts.pageSize}constructor(e){L(this,"opts",void 0),L(this,"$el",void 0),L(this,"$loading",void 0),L(this,"$text",void 0),L(this,"offset",0),L(this,"total",0),L(this,"origText","Load More"),this.opts=e,this.origText=this.opts.text||this.origText,this.$el=d(`<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()}},$s=class{constructor(){L(this,"instance",void 0),L(this,"onReachedBottom",null),L(this,"opt",void 0)}create(e){return this.opt=e,this.instance=new ws({pageSize:e.pageSize,onClick:function(){var t=c(function*(t){e.getData().fetchComments({offset:t})});return function(e){return t.apply(this,arguments)}}(),text:C("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()}},xs=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){L(this,"opts",void 0),L(this,"total",void 0),L(this,"$el",void 0),L(this,"$input",void 0),L(this,"inputTimer",void 0),L(this,"$prevBtn",void 0),L(this,"$nextBtn",void 0),L(this,"page",1),this.total=e,this.opts=t,this.$el=d('<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?ui(this.$el):hi(this.$el)}},Es=class{constructor(){L(this,"instance",void 0)}create(e){return this.instance=new xs(e.total,{pageSize:e.pageSize,onChange:function(){var t=c(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 Ss(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 Cs=e=>{let t=null;e.getConf().watchConf(["pagination","locale"],n=>{const i=e.getList(),s=e.getData();t&&t.dispose(),t=function(e){return e.pagination.readMore?new $s:new Es}(n);const{offset:r,total:o}=Ss(s.getListLastFetch()),a=t.create(P({pageSize:n.pagination.pageSize,total:o,readMoreAutoLoad:n.pagination.autoLoad},e));i.getCommentsWrapEl().after(a),null==t||t.update(r,o)}),e.getEvents().on("list-loaded",n=>{const{offset:i,total:s}=Ss(e.getData().getListLastFetch());null==t||t.update(i,s)}),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,C("loadFail"))}),e.getEvents().on("list-fetch",e=>{null==t||t.setLoading(!0)}),e.getEvents().on("list-fetched",({params:e})=>{null==t||t.setLoading(!1)})},Ts=class{getEl(){return this.$el}getCommentsWrapEl(){return this.$commentsWrap}getCommentNodes(){return this.commentNodes}constructor(e){L(this,"opts",void 0),L(this,"$el",void 0),L(this,"$commentsWrap",void 0),L(this,"commentNodes",[]),this.opts=e,this.$el=d('<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"),Cs(P({getList:()=>this},e)),this.initCrudEvents()}getLayout({forceFlatMode:e}={}){return new es({$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(),s=new bs(t,{onAfterRender:()=>{e.getEvents().trigger("comment-rendered",s)},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 s.render(),s}(P({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)})}},As=class{constructor(e){L(this,"opts",void 0),L(this,"$el",void 0),L(this,"layer",void 0),L(this,"$header",void 0),L(this,"$closeBtn",void 0),L(this,"$iframeWrap",void 0),L(this,"$iframe",void 0),L(this,"refreshWhenShow",!0),L(this,"animTimer",void 0),this.opts=e,this.$el=d('<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 c(function*(){e.refreshWhenShow=!0})()}show(){var e=this;return c(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 c(function*(){const n=(yield t.opts.getApi().user.getUserStatus(P({},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){const t=d('<iframe referrerpolicy="strict-origin-when-cross-origin"></iframe>'),n=v({base:this.opts.getConf().get().server,path:"/sidebar/"}),i={pageKey:this.opts.getConf().get().pageKey,site:this.opts.getConf().get().site||"",user:JSON.stringify(this.opts.getUser().getData()),time:+new Date};e&&(i.view=e),i.darkMode=this.getDarkMode()?"1":"0";const s=new URLSearchParams(i);return this.iframeLoad(t,`${n}?${s.toString()}`),t}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,ui(this.$iframeWrap),e.onload=()=>{hi(this.$iframeWrap)}}},Ls=new Set([e=>{e.provide("data",e=>new Vi(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 ri(Hn(t.get(),e,n)),["user","config","apiHandlers"],{lifecycle:"transient"})},e=>{e.watchConf(["locale"],e=>{var t;(t=e.locale)!==E&&(E=t,S="string"==typeof t?$(t):t)})},e=>{e.provide("user",()=>new Mi({onUserChanged:t=>{e.trigger("user-changed",t)}}),[])},e=>{e.provide("editor",(t,n)=>{const i=new Gi({getEvents:()=>t,getConf:()=>n});return e.getEl().appendChild(i.getEl()),i},["events","config"])},e=>{e.provide("list",(t,n,i,s,r)=>{const o=new Ts({getApi:()=>t,getEvents:()=>n,getConf:()=>i,getData:()=>s,replyComment:(e,t)=>r.setReplyComment(e,t),editComment:(e,t)=>r.setEditComment(e,t),resetEditorState:()=>r.resetState(),onListGotoFirst:()=>e.listGotoFirst()});return e.getEl().appendChild(o.getEl()),o},["api","events","config","data","editor"])},e=>{e.provide("checkers",(t,n,i,s,r)=>{const o=new qi({getApi:()=>t,getLayers:()=>i,getUser:()=>s,onReload:()=>e.reload(),getCaptchaIframeURL:()=>`${r.get().server}/api/v2/captcha/?t=${+new Date}`});return n.add("need_captcha",e=>o.checkCaptcha(e)),n.add("need_login",()=>o.checkAdmin({})),o},["api","apiHandlers","layers","user","config"])},e=>{e.provide("layers",()=>{const t=new Zi;return document.body.appendChild(t.getEl()),e.on("unmounted",()=>{null==t||t.destroy()}),t})},e=>{e.provide("sidebar",(t,n,i,s,r,o,a,l)=>{const c=new As({onShow:()=>{setTimeout(()=>{n.updateNotifies([])},0),t.trigger("sidebar-show")},onHide:()=>{i.resetState(),t.trigger("sidebar-hide")},getCheckers:()=>s,getApi:()=>r,getConf:()=>o,getUser:()=>a,getLayers:()=>l});return e.on("user-changed",()=>{null==c||c.onUserChanged()}),c},["events","data","editor","checkers","api","config","user","layers"])}]),Rs=[...Ls,e=>{e.watchConf(["imgLazyLoad","markedOptions"],e=>{!function(e){try{if(!Je.name)return}catch(n){return}const t=new Je;t.setOptions(P(P({renderer:_n({imgLazyLoad:e.imgLazyLoad})},Un),e.markedOptions)),On=t}({markedOptions:e.markedOptions,imgLazyLoad:e.imgLazyLoad})}),e.watchConf(["markedReplacers"],e=>{var t;e.markedReplacers&&(t=e.markedReplacers,Nn=t)})},e=>{e.provide("editorPlugs",(t,n,i,s,r,o)=>{const a=new Ei({getArtalkRootEl:()=>e.getEl(),getEditor:()=>t,getConf:()=>n,getUser:()=>i,getApi:()=>o,getData:()=>s,getCheckers:()=>r,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()})},...Ti,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=>{Gn({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&&!Ai&&function(e,t,n){const i=function(e,t){const n=e.split("."),i=t.split(".");for(let s=0;s<3;s++){const e=Number(n[s]),t=Number(i[s]);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 s=d(`<div class="atk-version-check-notice">${C("updateMsg",{name:C(i<0?"client":"server")})} <span class="atk-info">${C("currentVersion")}: ${C("client")} ${t} / ${C("server")} ${n}</span></div>`),r=d(`<span class="atk-ignore-btn">${C("ignore")}</span>`);r.onclick=()=>{s.remove(),Ai=!0},s.append(r),e.getEl().parentElement.prepend(s)}(t,Si,e.apiVersion)})},e=>{const t=e.inject("config"),n=e.inject("layers");let i;const s=t=>{const s=[e.getEl(),n.getEl()];Li||(Li=window.matchMedia("(prefers-color-scheme: dark)")),"auto"===t?(i||(i=e=>Ri(s,e.matches),Li.addEventListener("change",i)),Ri(s,Li.matches)):(i&&(Li.removeEventListener("change",i),i=void 0),Ri(s,t))};e.watchConf(["darkMode"],e=>s(e.darkMode)),e.on("created",()=>s(t.get().darkMode)),e.on("unmounted",()=>{i&&(null==Li||Li.removeEventListener("change",i)),i=void 0})},e=>{const t=e.inject("config");let n,i={};e.watchConf(["pageVote"],e=>{const t=P(P({},Pi),"object"==typeof e.pageVote?e.pageVote:{});null==n||n(),e.pageVote&&(i=function(e,t,n,i){var s,r;const o=P({},e);return o.upBtnEl=document.querySelector(t.upBtnEl),o.downBtnEl=document.querySelector(t.downBtnEl),o.upCountEl=document.querySelector(t.upCountEl),o.downCountEl=document.querySelector(t.downCountEl),o.activeClass=t.activeClass,o.voteUpHandler=n,o.voteDownHandler=i,null===(s=o.upBtnEl)||void 0===s||s.addEventListener("click",n),null===(r=o.downBtnEl)||void 0===r||r.addEventListener("click",i),o}(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",r)}),e.on("list-fetched",r);let s=0;function r({data:n}){t.get().pageVote&&function(e){return e.upBtnEl||e.downBtnEl||e.upCountEl||e.downCountEl}(i)&&n&&(s!==n.page.id?(s=n.page.id,_i(i,n.page.vote_up,n.page.vote_down,!1,!1),function(e,t,n){n.votes.getVote("page",t).then(({data:t})=>{_i(e,t.up,t.down,t.is_up,t.is_down)}).catch(e=>{console.error("[ArtalkPageVote]",e)})}(i,s,e.getApi())):_i(i,n.page.vote_up,n.page.vote_down))}const o=()=>{var t;return{state:i,pageId:(null===(t=e.getData().getPage())||void 0===t?void 0:t.id)||0,httpApi:e.getApi()}},a=Oi("up",o),l=Oi("down",o)}],Ps=new Set([...Rs]),_s=new WeakMap;function Os(e,t){return Is.apply(this,arguments)}function Is(){return Is=c(function*(e,t){var n;const i=new Set,s=e=>{e.forEach(e=>{"function"==typeof e&&(i.has(e)||(e(t,_s.get(e)),i.add(e)))})};s(Ls);const{data:r}=yield t.getApi().conf.conf().catch(n=>{throw((e,t={})=>{var n;const i=e.inject("list"),s=e.inject("user"),r=e.inject("config"),o=t.err;if(!o)throw new Error("MountError: `err` is required");let a="";if(null===(n=o.data)||void 0===n?void 0:n.err_no_site){const e={create_name:r.get().site,create_urls:`${window.location.protocol}//${window.location.host}`};a=`sites|${JSON.stringify(e)}`}Ci({$err:i.getEl(),errMsg:o.msg||String(o),errData:o.data,retryFn:()=>{var e;return null===(e=t.onRetry)||void 0===e?void 0:e.call(t)},onOpenSidebar:s.getData().is_admin?()=>e.showSidebar({view:a}):void 0})})(t,{err:n,onRetry:()=>Os(e,t)}),n});let o=P(P({},e),{},{apiVersion:null===(n=r.version)||void 0===n?void 0:n.version});const a=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||{});o=o.preferRemoteConf?Fn(o,a):Fn(a,o),t.updateConf(o);let l=new Set;o.pluginURLs&&(l=yield function(e,t){return Ms.apply(this,arguments)}(o.pluginURLs,t.getConf().server).catch(e=>(console.error("Failed to load plugin",e),new Set))),s(Ps),s(l)}),Is.apply(this,arguments)}function Ms(){return(Ms=c(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 Ds({keys:e,effect:t,getConf:n,getEvents:i}){let s=null;const r=()=>{const i=(()=>{const t=n(),i={};return e.forEach(e=>{i[e]=t[e]}),i})();null!=s&&((e,t)=>JSON.stringify(e)===JSON.stringify(t))(s,i)||(s=i,t(i))};i().on("mounted",r),i().on("updated",r)}var Ns=class e{constructor(e){L(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 qn(t);(e=>{e.provide("events",()=>new xi)})(n),(e=>{let t=Wn({},!0);e.provide("config",e=>{let n=!1;return e.on("mounted",()=>n=!0),{watchConf:(n,i)=>{Ds({keys:n,effect:i,getConf:()=>t,getEvents:()=>e})},get:()=>t,update:i=>{t=Fn(t,Wn(i,!1)),n&&e.trigger("updated",t)}}},["events"])})(n),n.updateConf(e),function(){var t=c(function*(){yield Os(e,n),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){Ps.add(e),_s.set(e,t)}static loadCountWidget(e){const t=Wn(e,!0);Gn({getApi:()=>new ri(Hn(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()}},Us=Ns,js=Ns.init,Bs=Ns.use,qs=Ns.loadCountWidget;exports.Defaults=zn,exports.default=Us,exports.init=js,exports.loadCountWidget=qs,exports.use=Bs;
|
|
2
|
+
//# sourceMappingURL=Artalk.cjs.map
|