@waline/client 2.0.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e=e=>{"AbortError"!==e.name&&console.error(e.message)},t=(e,t="")=>{if("object"==typeof e&&e.errno)throw new TypeError(`Fetch ${t} failed with ${e.errno}: ${e.errmsg}`);return e},r=({serverURL:e,paths:r,signal:n})=>fetch(`${e}/article?path=${encodeURIComponent(r.join(","))}`,{signal:n}).then((e=>e.json())).then((e=>t(e,"visit count"))).then((e=>Array.isArray(e)?e:[e])),n=({serverURL:e,path:r})=>fetch(`${e}/article`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:r})}).then((e=>e.json())).then((e=>t(e,"visit count"))),o=e=>e.dataset.path||e.getAttribute("id"),a=(e,t)=>{t.forEach(((t,r)=>{t.innerText=e[r].toString()}))};exports.pageviewCount=({serverURL:t,path:s=window.location.pathname,selector:i=".waline-pageview-count",update:l=!0})=>{const h=new AbortController,c=Array.from(document.querySelectorAll(i)),p=e=>{const t=o(e);return null!==t&&s!==t},u=n=>r({serverURL:t,paths:n.map((e=>o(e)||s)),signal:h.signal}).then((e=>a(e,n))).catch(e);if(l){const e=c.filter((e=>!p(e))),r=c.filter(p);n({serverURL:t,path:s}).then((t=>a(new Array(e.length).fill(t),e))),r.length&&u(r)}else u(c);return h.abort.bind(h)},exports.version="2.0.0";
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e=e=>{"AbortError"!==e.name&&console.error(e.message)},t=(e,t="")=>{if("object"==typeof e&&e.errno)throw new TypeError(`Fetch ${t} failed with ${e.errno}: ${e.errmsg}`);return e},r=({serverURL:e,paths:r,signal:n})=>fetch(`${e}/article?path=${encodeURIComponent(r.join(","))}`,{signal:n}).then((e=>e.json())).then((e=>t(e,"visit count"))).then((e=>Array.isArray(e)?e:[e])),n=({serverURL:e,path:r})=>fetch(`${e}/article`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:r})}).then((e=>e.json())).then((e=>t(e,"visit count"))),o=e=>e.dataset.path||e.getAttribute("id"),a=(e,t)=>{t.forEach(((t,r)=>{t.innerText=e[r].toString()}))};exports.pageviewCount=({serverURL:t,path:s=window.location.pathname,selector:i=".waline-pageview-count",update:l=!0})=>{const h=new AbortController,c=Array.from(document.querySelectorAll(i)),p=e=>{const t=o(e);return null!==t&&s!==t},u=n=>r({serverURL:t,paths:n.map((e=>o(e)||s)),signal:h.signal}).then((e=>a(e,n))).catch(e);if(l){const e=c.filter((e=>!p(e))),r=c.filter(p);n({serverURL:t,path:s}).then((t=>a(new Array(e.length).fill(t),e))),r.length&&u(r)}else u(c);return h.abort.bind(h)},exports.version="2.0.1";
2
2
  //# sourceMappingURL=pageview.cjs.js.map
@@ -1,6 +1,6 @@
1
1
  declare const version: string;
2
2
 
3
- declare type WalineAbort = (reson: any) => void;
3
+ declare type WalineAbort = (reason?: any) => void;
4
4
 
5
5
  interface WalinePageviewCountOptions {
6
6
  /**
@@ -1,2 +1,2 @@
1
- const e="2.0.0",t=e=>{"AbortError"!==e.name&&console.error(e.message)},r=(e,t="")=>{if("object"==typeof e&&e.errno)throw new TypeError(`Fetch ${t} failed with ${e.errno}: ${e.errmsg}`);return e},n=({serverURL:e,paths:t,signal:n})=>fetch(`${e}/article?path=${encodeURIComponent(t.join(","))}`,{signal:n}).then((e=>e.json())).then((e=>r(e,"visit count"))).then((e=>Array.isArray(e)?e:[e])),o=({serverURL:e,path:t})=>fetch(`${e}/article`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:t})}).then((e=>e.json())).then((e=>r(e,"visit count"))),a=e=>e.dataset.path||e.getAttribute("id"),i=(e,t)=>{t.forEach(((t,r)=>{t.innerText=e[r].toString()}))},s=({serverURL:e,path:r=window.location.pathname,selector:s=".waline-pageview-count",update:h=!0})=>{const l=new AbortController,c=Array.from(document.querySelectorAll(s)),p=e=>{const t=a(e);return null!==t&&r!==t},f=o=>n({serverURL:e,paths:o.map((e=>a(e)||r)),signal:l.signal}).then((e=>i(e,o))).catch(t);if(h){const t=c.filter((e=>!p(e))),n=c.filter(p);o({serverURL:e,path:r}).then((e=>i(new Array(t.length).fill(e),t))),n.length&&f(n)}else f(c);return l.abort.bind(l)};export{s as pageviewCount,e as version};
1
+ const e="2.0.1",t=e=>{"AbortError"!==e.name&&console.error(e.message)},r=(e,t="")=>{if("object"==typeof e&&e.errno)throw new TypeError(`Fetch ${t} failed with ${e.errno}: ${e.errmsg}`);return e},n=({serverURL:e,paths:t,signal:n})=>fetch(`${e}/article?path=${encodeURIComponent(t.join(","))}`,{signal:n}).then((e=>e.json())).then((e=>r(e,"visit count"))).then((e=>Array.isArray(e)?e:[e])),o=({serverURL:e,path:t})=>fetch(`${e}/article`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:t})}).then((e=>e.json())).then((e=>r(e,"visit count"))),a=e=>e.dataset.path||e.getAttribute("id"),i=(e,t)=>{t.forEach(((t,r)=>{t.innerText=e[r].toString()}))},s=({serverURL:e,path:r=window.location.pathname,selector:s=".waline-pageview-count",update:h=!0})=>{const l=new AbortController,c=Array.from(document.querySelectorAll(s)),p=e=>{const t=a(e);return null!==t&&r!==t},f=o=>n({serverURL:e,paths:o.map((e=>a(e)||r)),signal:l.signal}).then((e=>i(e,o))).catch(t);if(h){const t=c.filter((e=>!p(e))),n=c.filter(p);o({serverURL:e,path:r}).then((e=>i(new Array(t.length).fill(e),t))),n.length&&f(n)}else f(c);return l.abort.bind(l)};export{s as pageviewCount,e as version};
2
2
  //# sourceMappingURL=pageview.esm.js.map
package/dist/pageview.js CHANGED
@@ -1,2 +1,2 @@
1
- !function(e,t){if("function"==typeof define&&define.amd)define("Waline",["exports"],t);else if("undefined"!=typeof exports)t(exports);else{var n={exports:{}};t(n.exports),e.Waline=n.exports}}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:this,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.version=e.pageviewCount=void 0;e.version="2.0.0";const t=e=>{"AbortError"!==e.name&&console.error(e.message)},n=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";if("object"==typeof e&&e.errno)throw new TypeError("Fetch ".concat(t," failed with ").concat(e.errno,": ").concat(e.errmsg));return e},r=e=>{let{serverURL:t,paths:r,signal:o}=e;return fetch("".concat(t,"/article?path=").concat(encodeURIComponent(r.join(","))),{signal:o}).then((e=>e.json())).then((e=>n(e,"visit count"))).then((e=>Array.isArray(e)?e:[e]))},o=e=>{let{serverURL:t,path:r}=e;return fetch("".concat(t,"/article"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:r})}).then((e=>e.json())).then((e=>n(e,"visit count")))},i=e=>e.dataset.path||e.getAttribute("id"),a=(e,t)=>{t.forEach(((t,n)=>{t.innerText=e[n].toString()}))};e.pageviewCount=e=>{let{serverURL:n,path:s=window.location.pathname,selector:l=".waline-pageview-count",update:c=!0}=e;const f=new AbortController,h=Array.from(document.querySelectorAll(l)),p=e=>{const t=i(e);return null!==t&&s!==t},d=e=>r({serverURL:n,paths:e.map((e=>i(e)||s)),signal:f.signal}).then((t=>a(t,e))).catch(t);if(c){const e=h.filter((e=>!p(e))),t=h.filter(p);o({serverURL:n,path:s}).then((t=>a(new Array(e.length).fill(t),e))),t.length&&d(t)}else d(h);return f.abort.bind(f)}}));
1
+ !function(e,t){if("function"==typeof define&&define.amd)define("Waline",["exports"],t);else if("undefined"!=typeof exports)t(exports);else{var n={exports:{}};t(n.exports),e.Waline=n.exports}}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:this,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.version=e.pageviewCount=void 0;e.version="2.0.1";const t=e=>{"AbortError"!==e.name&&console.error(e.message)},n=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";if("object"==typeof e&&e.errno)throw new TypeError("Fetch ".concat(t," failed with ").concat(e.errno,": ").concat(e.errmsg));return e},r=e=>{let{serverURL:t,paths:r,signal:o}=e;return fetch("".concat(t,"/article?path=").concat(encodeURIComponent(r.join(","))),{signal:o}).then((e=>e.json())).then((e=>n(e,"visit count"))).then((e=>Array.isArray(e)?e:[e]))},o=e=>{let{serverURL:t,path:r}=e;return fetch("".concat(t,"/article"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:r})}).then((e=>e.json())).then((e=>n(e,"visit count")))},i=e=>e.dataset.path||e.getAttribute("id"),a=(e,t)=>{t.forEach(((t,n)=>{t.innerText=e[n].toString()}))};e.pageviewCount=e=>{let{serverURL:n,path:s=window.location.pathname,selector:l=".waline-pageview-count",update:c=!0}=e;const f=new AbortController,h=Array.from(document.querySelectorAll(l)),p=e=>{const t=i(e);return null!==t&&s!==t},d=e=>r({serverURL:n,paths:e.map((e=>i(e)||s)),signal:f.signal}).then((t=>a(t,e))).catch(t);if(c){const e=h.filter((e=>!p(e))),t=h.filter(p);o({serverURL:n,path:s}).then((t=>a(new Array(e.length).fill(t),e))),t.length&&d(t)}else d(h);return f.abort.bind(f)}}));
2
2
  //# sourceMappingURL=pageview.js.map
package/dist/shim.d.ts CHANGED
@@ -319,7 +319,7 @@ interface WalineInitOptions extends Omit<WalineProps, 'path'> {
319
319
  */
320
320
  path?: string;
321
321
  }
322
- declare type WalineAbort = (reson: any) => void;
322
+ declare type WalineAbort = (reason?: any) => void;
323
323
 
324
324
  declare const getMeta: (meta: WalineMeta[]) => WalineMeta[];
325
325
  declare const defaultLang = "zh-CN";
@@ -319,7 +319,7 @@ interface WalineInitOptions extends Omit<WalineProps, 'path'> {
319
319
  */
320
320
  path?: string;
321
321
  }
322
- declare type WalineAbort = (reson: any) => void;
322
+ declare type WalineAbort = (reason?: any) => void;
323
323
 
324
324
  declare const getMeta: (meta: WalineMeta[]) => WalineMeta[];
325
325
  declare const defaultLang = "zh-CN";
package/dist/shim.esm.js CHANGED
@@ -1,2 +1,2 @@
1
- import{reactive as e,ref as t,readonly as n,h as o,defineComponent as l,inject as r,computed as i,watch as a,onMounted as s,onUnmounted as c,resolveComponent as m,openBlock as u,createElementBlock as d,createElementVNode as p,createVNode as v,toDisplayString as g,createCommentVNode as h,normalizeClass as f,Fragment as y,renderList as w,withDirectives as b,vModelDynamic as k,vModelText as C,normalizeStyle as $,createTextVNode as I,createBlock as L,provide as R,watchEffect as S,onBeforeUnmount as j,createApp as x}from"vue";import U from"autosize";import{marked as E}from"marked";import z from"hanabi";const A=["nick","mail","link"],M=e=>e.filter((e=>A.includes(e))),N="zh-CN",P=e=>new Promise(((t,n)=>{const o=new FileReader;o.readAsDataURL(e),o.onload=()=>{var e;return t((null===(e=o.result)||void 0===e?void 0:e.toString())||"")},o.onerror=n})),T=e=>!0===e?'<p class="vtex">Tex is not available in preview</p>':'<span class="vtex">Tex is not available in preview</span>',O=["nick","nickError","mail","mailError","link","optional","placeholder","sofa","submit","reply","cancelReply","comment","refresh","more","preview","emoji","uploadImage","seconds","minutes","hours","days","now","uploading","login","logout","admin","sticky","word","wordHint","anonymous"],B=e=>Object.fromEntries(e.map(((e,t)=>[O[t],e])));var _=B(["NickName","NickName cannot be less than 3 bytes.","E-Mail","Please confirm your email address.","Website","Optional","Comment here...","No comment yet.","Submit","Reply","Cancel reply","Comments","Refresh","Load More...","Preview","Emoji","Upload Image","seconds ago","minutes ago","hours ago","days ago","just now","Uploading","Login","logout","Admin","Sticky","Words","Please input comments between $0 and $1 words!\n Current word number: $2","Anonymous"]),H=B(["ニックネーム","3バイト以上のニックネームをご入力ください.","メールアドレス","メールアドレスをご確認ください.","サイト","オプション","ここにコメント","コメントしましょう~","提出する","返信する","キャンセル","コメント","更新","さらに読み込む","プレビュー","絵文字","画像をアップロード","秒前","分前","時間前","日前","たっだ今","アップロード","ログインする","ログアウト","管理者","トップに置く","ワード","コメントは $0 から $1 ワードの間でなければなりません!\n 現在の単語番号: $2","匿名"]),W=B(["昵称","昵称不能少于3个字符","邮箱","请填写正确的邮件地址","网址","可选","欢迎评论","来发评论吧~","提交","回复","取消回复","评论","刷新","加载更多...","预览","表情","上传图片","秒前","分钟前","小时前","天前","刚刚","正在上传","登录","退出","博主","置顶","字","评论字数应在 $0 到 $1 字之间!\n当前字数:$2","匿名"]),q=B(["暱稱","郵箱","網址","可選","暱稱不能少於3個字元","請填寫正確的郵件地址","歡迎評論","來發評論吧~","提交","回覆","取消回覆","評論","刷新","載入更多...","預覽","表情","上傳圖片","秒前","分鐘前","小時前","天前","剛剛","正在上傳","登錄","退出","博主","置頂","字","評論字數應在 $0 到 $1 字之間!\n當前字數:$2","匿名"]),V=B(["Apelido","Apelido não pode ser menor que 3 bytes.","E-Mail","Por favor, confirme seu endereço de e-mail.","Website","Opcional","Comente aqui...","Nenhum comentário, ainda.","Enviar","Responder","Cancelar resposta","Comentários","Refrescar","Carregar Mais...","Visualizar","Emoji","Enviar Imagem","segundos atrás","minutos atrás","horas atrás","dias atrás","agora mesmo","Enviando","Entrar","Sair","Admin","Sticky","Palavras","Favor enviar comentário com $0 a $1 palavras!\n Número de palavras atuais: $2","Anônimo"]),D=B(["Псевдоним","Никнейм не может быть меньше 3 байт.","Эл. адрес","Пожалуйста, подтвердите адрес вашей электронной почты.","Веб-сайт","Необязательный","Комментарий здесь...","Пока нет комментариев.","Отправить","Отвечать","Отменить ответ","Комментарии","Обновить","Загрузи больше...","Превью","эмодзи","Загрузить изображение","секунд назад","несколько минут назад","несколько часов назад","дней назад","прямо сейчас","Загрузка","Авторизоваться","Выход из системы","Админ","Липкий","Слова","Пожалуйста, введите комментарии от $0 до $1 слов!\nНомер текущего слова: $2","Анонимный"]);const J={zh:W,"zh-cn":W,"zh-CN":W,"zh-tw":q,"zh-TW":q,en:_,"en-US":_,"en-us":_,jp:H,"jp-jp":H,"jp-JP":H,"pt-br":V,"pt-BR":V,ru:D,"ru-ru":D,"ru-RU":D},F=e=>{let t={};const n=localStorage.getItem(e);if(n)try{t=JSON.parse(n)}catch(e){}return{get:e=>t[e]||null,set(n,o){try{t[n]=JSON.parse(JSON.stringify(o)),localStorage.setItem(e,JSON.stringify(t))}catch(e){}},update(n){t=JSON.parse(JSON.stringify(n)),localStorage.setItem(e,JSON.stringify(t))}}};let K,Y;const G=()=>(Y||(K=F("WALINE_USER_CACHE"),Y=e({nick:K.get("nick")||"",mail:K.get("mail")||"",link:K.get("link")||"",editor:""})),{inputs:Y,store:K}),Q=e=>{try{e=decodeURI(e)}catch(e){}return e},X=(e="")=>e.replace(/\/$/u,""),Z=e=>/^(https?:)?\/\//.test(e);let ee;const te=e=>{ee||(ee=F("WALINE_EMOJI"));const t=Boolean(/@[0-9]+\.[0-9]+\.[0-9]+/.test(e));if(t){const t=ee.get(e);if(t)return Promise.resolve(t)}return fetch(`${e}/info.json`).then((e=>e.json())).then((n=>{const o={folder:e,...n};return t&&ee.set(e,o),o}))},ne=(e,t="",n="",o="")=>`${t?`${t}/`:""}${n}${e}${o?`.${o}`:""}`,oe=e=>{const t=X(e);return Z(t)?t:`https://${t}`},le=(e,t)=>"function"==typeof e?e:!1!==e&&t,re="{--waline-white:#000;--waline-light-grey:#666;--waline-dark-grey:#999;--waline-color:#888;--waline-bgcolor:#1e1e1e;--waline-bgcolor-light:#272727;--waline-bgcolor-hover: #444;--waline-border-color:#333;--waline-disable-bgcolor:#444;--waline-disable-color:#272727;--waline-bq-color:#272727;--waline-info-bgcolor:#272727;--waline-info-color:#666}",ie=e=>e.type.includes("image"),ae=e=>{const t=Array.from(e).find(ie);return t?t.getAsFile():null},se=e=>{"AbortError"!==e.name&&console.error(e.message)},ce=(e,t="")=>{if("object"==typeof e&&e.errno)throw new TypeError(`Fetch ${t} failed with ${e.errno}: ${e.errmsg}`);return e},me=({serverURL:e,paths:t,signal:n})=>fetch(`${e}/article?path=${encodeURIComponent(t.join(","))}`,{signal:n}).then((e=>e.json())).then((e=>ce(e,"visit count"))).then((e=>Array.isArray(e)?e:[e])),ue=({serverURL:e,path:t})=>fetch(`${e}/article`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:t})}).then((e=>e.json())).then((e=>ce(e,"visit count"))),de=e=>e instanceof HTMLElement?e:"string"==typeof e?document.querySelector(e):null,pe=/\$.*?\$/,ve=/^\$(.*?)\$/,ge=/^(?:\s{0,3})\$\$((?:[^\n]|\n[^\n])+?)\n{0,1}\$\$/,he=(e="",t={})=>e.replace(/:(.+?):/g,((e,n)=>t[n]?`<img class="vemoji" src="${t[n]}" alt="${n}">`:e)),fe=(e,{emojiMap:t,highlighter:n,texRenderer:o})=>{if(E.setOptions({highlight:n||void 0,breaks:!0,smartLists:!0,smartypants:!0}),o){const e=(e=>[{name:"blockMath",level:"block",tokenizer(t){const n=ge.exec(t);if(null!==n)return{type:"html",raw:n[0],text:e(!0,n[1])}}},{name:"inlineMath",level:"inline",start(e){const t=e.search(pe);return-1!==t?t:e.length},tokenizer(t){const n=ve.exec(t);if(null!==n)return{type:"html",raw:n[0],text:e(!1,n[1])}}}])(o);E.use({extensions:e})}return E.parse(he(e,t))},ye=e=>e.dataset.path||e.getAttribute("id"),we=(e,t)=>{let n=e.toString();for(;n.length<t;)n="0"+n;return n},be=(e,t)=>{if(e)try{"string"==typeof e&&(e=new Date(-1!==e.indexOf(" ")?e.replace(/-/g,"/"):e));const n=e.getTime(),o=(new Date).getTime()-n,l=Math.floor(o/864e5);if(0===l){const e=o%864e5,n=Math.floor(e/36e5);if(0===n){const n=e%36e5,o=Math.floor(n/6e4);if(0===o){const e=n%6e4;return`${Math.round(e/1e3)} ${t.seconds}`}return`${o} ${t.minutes}`}return`${n} ${t.hours}`}return l<0?t.now:l<8?`${l} ${t.days}`:(e=>{const t=we(e.getDate(),2),n=we(e.getMonth()+1,2);return`${we(e.getFullYear(),2)}-${n}-${t}`})(e)}catch(e){console.log(e)}return""},ke=()=>{try{const e=localStorage.getItem("WALINE_USER"),t=sessionStorage.getItem("WALINE_USER");return e?JSON.parse(e):t?JSON.parse(t):null}catch(e){return null}},Ce=t({}),$e=()=>{if(!Ce.value.token){const e=ke();e&&(Ce.value=e)}return{userInfo:n(Ce),setUserInfo:e=>{Ce.value=e}}},Ie=({serverURL:e,path:t=window.location.pathname,selector:n=".waline-comment-count"})=>{var o;const l=new AbortController,r=document.querySelectorAll(n),{userInfo:i}=$e();return r.length&&(({serverURL:e,paths:t,signal:n,token:o})=>{const l={};return o&&(l.Authorization=`Bearer ${o}`),fetch(`${e}/comment?type=count&url=${encodeURIComponent(t.join(","))}`,{signal:n,headers:l}).then((e=>e.json())).then((e=>ce(e,"comment count"))).then((e=>Array.isArray(e)?e:[e]))})({serverURL:e,paths:Array.from(r).map((e=>Q(e.dataset.path||e.getAttribute("id")||t))),signal:l.signal,token:null===(o=i.value)||void 0===o?void 0:o.token}).then((e=>{r.forEach(((t,n)=>{t.innerText=e[n].toString()}))})).catch(se),l.abort.bind(l)},Le=({size:e})=>o("svg",{width:e,height:e,viewBox:"0 0 100 100",preserveAspectRatio:"xMidYMid"},o("circle",{cx:50,cy:50,fill:"none",stroke:"currentColor",strokeWidth:"4",r:"40","stroke-dasharray":"85 30"},o("animateTransform",{attributeName:"transform",type:"rotate",repeatCount:"indefinite",dur:"1s",values:"0 50 50;360 50 50",keyTimes:"0;1"})));var Re=l({name:"CommentBox",components:{CloseIcon:({size:e})=>o("svg",{class:"wl-close-icon",viewBox:"0 0 1024 1024",width:e,height:e},[o("path",{d:"M697.173 85.333h-369.92c-144.64 0-241.92 101.547-241.92 252.587v348.587c0 150.613 97.28 252.16 241.92 252.16h369.92c144.64 0 241.494-101.547 241.494-252.16V337.92c0-151.04-96.854-252.587-241.494-252.587z",fill:"currentColor"}),o("path",{d:"m640.683 587.52-75.947-75.861 75.904-75.862a37.29 37.29 0 0 0 0-52.778 37.205 37.205 0 0 0-52.779 0l-75.946 75.818-75.862-75.946a37.419 37.419 0 0 0-52.821 0 37.419 37.419 0 0 0 0 52.821l75.947 75.947-75.776 75.733a37.29 37.29 0 1 0 52.778 52.821l75.776-75.776 75.947 75.947a37.376 37.376 0 0 0 52.779-52.821z",fill:"#888"})]),EmojiIcon:()=>o("svg",{viewBox:"0 0 1024 1024",width:"24",height:"24"},o("path",{d:"M563.2 463.3 677 540c1.7 1.2 3.7 1.8 5.8 1.8.7 0 1.4-.1 2-.2 2.7-.5 5.1-2.1 6.6-4.4l25.3-37.8c1.5-2.3 2.1-5.1 1.6-7.8s-2.1-5.1-4.4-6.6l-73.6-49.1 73.6-49.1c2.3-1.5 3.9-3.9 4.4-6.6.5-2.7 0-5.5-1.6-7.8l-25.3-37.8a10.1 10.1 0 0 0-6.6-4.4c-.7-.1-1.3-.2-2-.2-2.1 0-4.1.6-5.8 1.8l-113.8 76.6c-9.2 6.2-14.7 16.4-14.7 27.5.1 11 5.5 21.3 14.7 27.4zM387 348.8h-45.5c-5.7 0-10.4 4.7-10.4 10.4v153.3c0 5.7 4.7 10.4 10.4 10.4H387c5.7 0 10.4-4.7 10.4-10.4V359.2c0-5.7-4.7-10.4-10.4-10.4zm333.8 241.3-41-20a10.3 10.3 0 0 0-8.1-.5c-2.6.9-4.8 2.9-5.9 5.4-30.1 64.9-93.1 109.1-164.4 115.2-5.7.5-9.9 5.5-9.5 11.2l3.9 45.5c.5 5.3 5 9.5 10.3 9.5h.9c94.8-8 178.5-66.5 218.6-152.7 2.4-5 .3-11.2-4.8-13.6zm186-186.1c-11.9-42-30.5-81.4-55.2-117.1-24.1-34.9-53.5-65.6-87.5-91.2-33.9-25.6-71.5-45.5-111.6-59.2-41.2-14-84.1-21.1-127.8-21.1h-1.2c-75.4 0-148.8 21.4-212.5 61.7-63.7 40.3-114.3 97.6-146.5 165.8-32.2 68.1-44.3 143.6-35.1 218.4 9.3 74.8 39.4 145 87.3 203.3.1.2.3.3.4.5l36.2 38.4c1.1 1.2 2.5 2.1 3.9 2.6 73.3 66.7 168.2 103.5 267.5 103.5 73.3 0 145.2-20.3 207.7-58.7 37.3-22.9 70.3-51.5 98.1-85 27.1-32.7 48.7-69.5 64.2-109.1 15.5-39.7 24.4-81.3 26.6-123.8 2.4-43.6-2.5-87-14.5-129zm-60.5 181.1c-8.3 37-22.8 72-43 104-19.7 31.1-44.3 58.6-73.1 81.7-28.8 23.1-61 41-95.7 53.4-35.6 12.7-72.9 19.1-110.9 19.1-82.6 0-161.7-30.6-222.8-86.2l-34.1-35.8c-23.9-29.3-42.4-62.2-55.1-97.7-12.4-34.7-18.8-71-19.2-107.9-.4-36.9 5.4-73.3 17.1-108.2 12-35.8 30-69.2 53.4-99.1 31.7-40.4 71.1-72 117.2-94.1 44.5-21.3 94-32.6 143.4-32.6 49.3 0 97 10.8 141.8 32 34.3 16.3 65.3 38.1 92 64.8 26.1 26 47.5 56 63.6 89.2 16.2 33.2 26.6 68.5 31 105.1 4.6 37.5 2.7 75.3-5.6 112.3z",fill:"currentColor"})),ImageIcon:()=>o("svg",{viewBox:"0 0 1024 1024",width:"24",height:"24"},[o("path",{d:"M784 112H240c-88 0-160 72-160 160v480c0 88 72 160 160 160h544c88 0 160-72 160-160V272c0-88-72-160-160-160zm96 640c0 52.8-43.2 96-96 96H240c-52.8 0-96-43.2-96-96V272c0-52.8 43.2-96 96-96h544c52.8 0 96 43.2 96 96v480z",fill:"currentColor"}),o("path",{d:"M352 480c52.8 0 96-43.2 96-96s-43.2-96-96-96-96 43.2-96 96 43.2 96 96 96zm0-128c17.6 0 32 14.4 32 32s-14.4 32-32 32-32-14.4-32-32 14.4-32 32-32zm462.4 379.2-3.2-3.2-177.6-177.6c-25.6-25.6-65.6-25.6-91.2 0l-80 80-36.8-36.8c-25.6-25.6-65.6-25.6-91.2 0L200 728c-4.8 6.4-8 14.4-8 24 0 17.6 14.4 32 32 32 9.6 0 16-3.2 22.4-9.6L380.8 640l134.4 134.4c6.4 6.4 14.4 9.6 24 9.6 17.6 0 32-14.4 32-32 0-9.6-4.8-17.6-9.6-24l-52.8-52.8 80-80L769.6 776c6.4 4.8 12.8 8 20.8 8 17.6 0 32-14.4 32-32 0-8-3.2-16-8-20.8z",fill:"currentColor"})]),MarkdownIcon:()=>o("svg",{width:"16",height:"16",ariaHidden:"true"},o("path",{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",fill:"currentColor"})),PreviewIcon:()=>o("svg",{viewBox:"0 0 1024 1024",width:"24",height:"24"},[o("path",{d:"M710.816 654.301c70.323-96.639 61.084-230.578-23.705-314.843-46.098-46.098-107.183-71.109-172.28-71.109-65.008 0-126.092 25.444-172.28 71.109-45.227 46.098-70.756 107.183-70.756 172.106 0 64.923 25.444 126.007 71.194 172.106 46.099 46.098 107.184 71.109 172.28 71.109 51.414 0 100.648-16.212 142.824-47.404l126.53 126.006c7.058 7.06 16.297 10.979 26.406 10.979 10.105 0 19.343-3.919 26.402-10.979 14.467-14.467 14.467-38.172 0-52.723L710.816 654.301zm-315.107-23.265c-65.88-65.88-65.88-172.54 0-238.42 32.069-32.07 74.245-49.149 119.471-49.149 45.227 0 87.407 17.603 119.472 49.149 65.88 65.879 65.88 172.539 0 238.42-63.612 63.178-175.242 63.178-238.943 0zm0 0",fill:"currentColor"}),o("path",{d:"M703.319 121.603H321.03c-109.8 0-199.469 89.146-199.469 199.38v382.034c0 109.796 89.236 199.38 199.469 199.38h207.397c20.653 0 37.384-16.645 37.384-37.299 0-20.649-16.731-37.296-37.384-37.296H321.03c-68.582 0-124.352-55.77-124.352-124.267V321.421c0-68.496 55.77-124.267 124.352-124.267h382.289c68.582 0 124.352 55.771 124.352 124.267V524.72c0 20.654 16.736 37.299 37.385 37.299 20.654 0 37.384-16.645 37.384-37.299V320.549c-.085-109.8-89.321-198.946-199.121-198.946zm0 0",fill:"currentColor"})]),LoadingIcon:Le},props:{rootId:{type:String,default:""},replyId:{type:String,default:""},replyUser:{type:String,default:""}},emits:["submit","cancel-reply"],setup(e,{emit:n}){const o=r("config"),{inputs:l,store:m}=G(),{userInfo:u,setUserInfo:d}=$e(),p=t({}),v=t(null),g=t(null),h=t(null),f=t(null),y=t({tabs:[],map:{}}),w=t(0),b=t(!1),k=t(!1),C=t(""),$=t(0),I=t(0),L=t(!1),R=t(""),S=t(!1),j=i((()=>o.value.locale)),x=i((()=>{var e;return Boolean(null===(e=u.value)||void 0===e?void 0:e.token)})),E=i((()=>!1!==o.value.imageUploader)),z=e=>{const t=v.value,n=t.selectionStart,o=t.selectionEnd||0,r=t.scrollTop;l.editor=t.value.substring(0,n)+e+t.value.substring(o,t.value.length),t.focus(),t.selectionStart=n+e.length,t.selectionEnd=n+e.length,t.scrollTop=r},A=e=>{const t=`![${o.value.locale.uploading} ${e.name}]()`;return z(t),Promise.resolve().then((()=>o.value.imageUploader(e))).then((n=>{l.editor=l.editor.replace(t,`\r\n![${e.name}](${n})`)}))},M=()=>{var t,r,i,a,s;const{serverURL:c,lang:d,login:g,wordLimit:h,requiredMeta:f}=o.value,w={comment:R.value,nick:l.nick,mail:l.mail,link:l.link,ua:navigator.userAgent,url:o.value.path};if(null===(t=u.value)||void 0===t?void 0:t.token)w.nick=u.value.display_name,w.mail=u.value.email,w.link=u.value.url;else{if("force"===g)return;if((f.indexOf("nick")>-1||w.nick)&&!w.nick)return null===(r=p.value.nick)||void 0===r||r.focus(),alert(j.value.nickError);if(f.indexOf("mail")>-1&&!w.mail)return null===(i=p.value.mail)||void 0===i||i.focus(),alert(j.value.mailError);if(!w.comment)return void(null===(a=v.value)||void 0===a||a.focus());w.nick||(w.nick=j.value.anonymous)}if(!L.value)return alert(j.value.wordHint.replace("$0",h[0].toString()).replace("$1",h[1].toString()).replace("$2",$.value.toString()));w.comment=he(w.comment,y.value.map),e.replyId&&e.rootId&&(w.pid=e.replyId,w.rid=e.rootId,w.at=e.replyUser),S.value=!0,(({serverURL:e,lang:t,token:n,comment:o})=>{const l={"Content-Type":"application/json"};return n&&(l.Authorization=`Bearer ${n}`),fetch(`${e}/comment?lang=${t}`,{method:"POST",headers:l,body:JSON.stringify(o)}).then((e=>e.json()))})({serverURL:c,lang:d,token:null===(s=u.value)||void 0===s?void 0:s.token,comment:w}).then((t=>{if(S.value=!1,m.update({nick:w.nick,link:w.link,mail:w.mail}),t.errmsg)return alert(t.errmsg);n("submit",t.data),l.editor="",C.value="",e.replyId&&n("cancel-reply")})).catch((e=>{S.value=!1,alert(e.message)}))},N=e=>{h.value.contains(e.target)||f.value.contains(e.target)||(b.value=!1)};return a((()=>l.editor),(e=>{const{highlighter:t,texRenderer:n}=o.value;R.value=e,C.value=fe(e,{emojiMap:y.value.map,highlighter:t,texRenderer:n}),$.value=(e=>(e=>e.match(/[\w\d\s\u00C0-\u024F]+/giu)||[])(e).reduce(((e,t)=>e+(""===t.trim()?0:t.trim().split(/\s+/u).length)),0)+(e=>e.match(/[\u4E00-\u9FA5]/gu)||[])(e).length)(e),v.value&&(e?U(v.value):U.destroy(v.value))}),{immediate:!0}),a((()=>o.value.emoji),(e=>e.then((e=>{y.value=e}))),{immediate:!0}),a([o,$],(([e,t])=>{const{wordLimit:n}=e;n?t<n[0]&&0!==n[0]?(I.value=n[0],L.value=!1):t>n[1]?(I.value=n[1],L.value=!1):(I.value=n[1],L.value=!0):(I.value=0,L.value=!0)}),{immediate:!0}),s((()=>{document.body.addEventListener("click",N)})),c((()=>{document.body.removeEventListener("click",N)})),{config:o,locale:j,insert:z,onChange:()=>{const e=g.value;e.files&&E.value&&A(e.files[0]).then((()=>{e.value=""}))},onDrop:e=>{var t;if(null===(t=e.dataTransfer)||void 0===t?void 0:t.items){const t=ae(e.dataTransfer.items);t&&E.value&&(A(t),e.preventDefault())}},onKeyDown:e=>{const t=e.key;(e.ctrlKey||e.metaKey)&&"Enter"===t&&M()},onPaste:e=>{if(e.clipboardData){const t=ae(e.clipboardData.items);t&&E.value&&A(t)}},onLogin:e=>{e.preventDefault();const{lang:t,serverURL:n}=o.value,l=(window.innerWidth-450)/2,r=(window.innerHeight-450)/2,i=window.open(`${n}/ui/login?lng=${encodeURIComponent(t)}`,"_blank",`width=450,height=450,left=${l},top=${r},scrollbars=no,resizable=no,status=no,location=no,toolbar=no,menubar=no`);null==i||i.postMessage({type:"TOKEN",data:null},"*");const a=({data:e})=>{e&&"userInfo"===e.type&&e.data.token&&(null==i||i.close(),d(e.data),(e.data.remember?localStorage:sessionStorage).setItem("WALINE_USER",JSON.stringify(e.data)),window.removeEventListener("message",a))};window.addEventListener("message",a)},onLogout:()=>{d({}),localStorage.setItem("WALINE_USER","null"),sessionStorage.setItem("WALINE_USER","null")},onProfile:e=>{e.preventDefault();const{lang:t,serverURL:n}=o.value,l=(window.innerWidth-800)/2,r=(window.innerHeight-800)/2,i=window.open(`${n}/ui/profile?lng=${encodeURIComponent(t)}`,"_blank",`width=800,height=800,left=${l},top=${r},scrollbars=no,resizable=no,status=no,location=no,toolbar=no,menubar=no`);null==i||i.postMessage({type:"TOKEN",data:u.value.token},"*");const a=({data:e})=>{e&&"profile"===e.type&&(d(Object.assign({},u.value,e)),[localStorage,sessionStorage].filter((e=>e.getItem("WALINE_USER"))).forEach((e=>e.setItem("WALINE_USER",JSON.stringify(u)))),window.removeEventListener("message",a))};window.addEventListener("message",a)},submitComment:M,isLogin:x,userInfo:u,isSubmitting:S,wordNumber:$,wordLimit:I,isWordNumberLegal:L,inputs:l,emoji:y,emojiTabIndex:w,showEmoji:b,canUploadImage:E,previewText:C,showPreview:k,inputRefs:p,editorRef:v,emojiButtonRef:h,emojiPopupRef:f,imageUploadRef:g}}});const Se={class:"wl-comment"},je={key:0,class:"wl-login-info"},xe={class:"wl-avatar"},Ue=["title"],Ee=["src"],ze=["textContent"],Ae={class:"wl-panel"},Me=["for","textContent"],Ne=["id","name","type","onUpdate:modelValue"],Pe=["placeholder"],Te=["innerHTML"],Oe={class:"wl-footer"},Be={class:"wl-actions"},_e={href:"https://guides.github.com/features/mastering-markdown/",title:"Markdown Guide","aria-label":"Markdown is supported",class:"wl-action",target:"_blank",rel:"noreferrer"},He=["title"],We=["title"],qe=["title"],Ve={class:"wl-info"},De={class:"wl-text-number"},Je={key:0},Fe=I("  /  "),Ke=["textContent"],Ye=["textContent"],Ge=["disabled"],Qe={key:0,class:"wl-tab-wrapper"},Xe=["title","onClick"],Ze=["src","alt"],et={key:0,class:"wl-tabs"},tt=["onClick"],nt=["src","alt","title"],ot=["title"];Re.render=function(e,t,n,o,l,r){const i=m("CloseIcon"),a=m("MarkdownIcon"),s=m("EmojiIcon"),c=m("ImageIcon"),R=m("PreviewIcon"),S=m("LoadingIcon");return u(),d("div",Se,["disable"!==e.config.login&&e.isLogin?(u(),d("div",je,[p("div",xe,[p("button",{class:"wl-logout-btn",title:e.locale.logout,onClick:t[0]||(t[0]=(...t)=>e.onLogout&&e.onLogout(...t))},[v(i,{size:14})],8,Ue),p("img",{src:e.userInfo.avatar,alt:"avatar"},null,8,Ee)]),p("a",{href:"#",class:"wl-login-nick","aria-label":"Profile",onClick:t[1]||(t[1]=(...t)=>e.onProfile&&e.onProfile(...t)),textContent:g(e.userInfo.display_name)},null,8,ze)])):h("v-if",!0),p("div",Ae,["force"!==e.config.login&&e.config.meta.length&&!e.isLogin?(u(),d("div",{key:0,class:f(["wl-header",`item${e.config.meta.length}`])},[(u(!0),d(y,null,w(e.config.meta,(t=>(u(),d("div",{class:"wl-header-item",key:t},[p("label",{for:t,textContent:g(e.locale[t]+(e.config.requiredMeta.includes(t)||!e.config.requiredMeta.length?"":`(${e.locale.optional})`))},null,8,Me),b(p("input",{ref_for:!0,ref:n=>{n&&(e.inputRefs[t]=n)},id:`wl-${t}`,class:f(["wl-input",`wl-${t}`]),name:t,type:"mail"===t?"email":"text","onUpdate:modelValue":n=>e.inputs[t]=n},null,10,Ne),[[k,e.inputs[t]]])])))),128))],2)):h("v-if",!0),b(p("textarea",{class:"wl-editor",ref:"editorRef",id:"wl-edit",placeholder:e.replyUser?`@${e.replyUser}`:e.locale.placeholder,"onUpdate:modelValue":t[2]||(t[2]=t=>e.inputs.editor=t),onKeydown:t[3]||(t[3]=(...t)=>e.onKeyDown&&e.onKeyDown(...t)),onDrop:t[4]||(t[4]=(...t)=>e.onDrop&&e.onDrop(...t)),onPaste:t[5]||(t[5]=(...t)=>e.onPaste&&e.onPaste(...t))},null,40,Pe),[[C,e.inputs.editor]]),p("div",{class:"wl-preview",style:$({display:e.showPreview?"block":"none"})},[p("h4",null,g(e.locale.preview)+":",1),p("div",{class:"wl-content",innerHTML:e.previewText},null,8,Te)],4),p("div",Oe,[p("div",Be,[p("a",_e,[v(a)]),p("button",{ref:"emojiButtonRef",class:f(["wl-action",{actived:e.showEmoji}]),title:e.locale.emoji,onClick:t[6]||(t[6]=t=>e.showEmoji=!e.showEmoji)},[v(s)],10,He),p("input",{ref:"imageUploadRef",class:"upload",id:"wl-image-upload",type:"file",accept:".png,.jpg,.jpeg,.webp,.bmp,.gif",onChange:t[7]||(t[7]=(...t)=>e.onChange&&e.onChange(...t))},null,544),e.canUploadImage?(u(),d("label",{key:0,for:"wl-image-upload",class:"wl-action",title:e.locale.uploadImage},[v(c)],8,We)):h("v-if",!0),p("button",{class:f(["wl-action",{actived:e.showPreview}]),title:e.locale.preview,onClick:t[8]||(t[8]=t=>e.showPreview=!e.showPreview)},[v(R)],10,qe)]),p("div",Ve,[p("div",De,[I(g(e.wordNumber)+" ",1),e.config.wordLimit?(u(),d("span",Je,[Fe,p("span",{class:f({illegal:!e.isWordNumberLegal}),textContent:g(e.wordLimit)},null,10,Ke)])):h("v-if",!0),I("  "+g(e.locale.word),1)]),"disable"===e.config.login||e.isLogin?h("v-if",!0):(u(),d("button",{key:0,class:"wl-btn",onClick:t[9]||(t[9]=(...t)=>e.onLogin&&e.onLogin(...t)),textContent:g(e.locale.login)},null,8,Ye)),"force"!==e.config.login||e.isLogin?(u(),d("button",{key:1,class:"wl-btn primary",title:"Cmd|Ctrl + Enter",disabled:e.isSubmitting,onClick:t[10]||(t[10]=(...t)=>e.submitComment&&e.submitComment(...t))},[e.isSubmitting?(u(),L(S,{key:0,size:16})):(u(),d(y,{key:1},[I(g(e.locale.submit),1)],2112))],8,Ge)):h("v-if",!0)]),p("div",{ref:"emojiPopupRef",class:f(["wl-emoji-popup",{display:e.showEmoji}])},[(u(!0),d(y,null,w(e.emoji.tabs,((t,n)=>(u(),d(y,{key:t.name},[n===e.emojiTabIndex?(u(),d("div",Qe,[(u(!0),d(y,null,w(t.items,(t=>(u(),d("button",{key:t,title:t,onClick:n=>e.insert(`:${t}:`)},[e.showEmoji?(u(),d("img",{key:0,class:"wl-emoji",src:e.emoji.map[t],alt:t,loading:"lazy",referrerPolicy:"no-referrer"},null,8,Ze)):h("v-if",!0)],8,Xe)))),128))])):h("v-if",!0)],64)))),128)),e.emoji.tabs.length>1?(u(),d("div",et,[(u(!0),d(y,null,w(e.emoji.tabs,((t,n)=>(u(),d("button",{key:t.name,class:f(["wl-tab",{active:e.emojiTabIndex===n}]),onClick:t=>e.emojiTabIndex=n},[p("img",{class:"wl-emoji",src:t.icon,alt:t.name,title:t.name,loading:"lazy",referrerPolicy:"no-referrer"},null,8,nt)],10,tt)))),128))])):h("v-if",!0)],2)])]),e.replyId?(u(),d("button",{key:1,class:"wl-close",title:e.locale.cancelReply,onClick:t[11]||(t[11]=t=>e.$emit("cancel-reply"))},[v(i,{size:24})],8,ot)):h("v-if",!0)])},Re.__file="src/components/CommentBox.vue";var lt=l({props:{comment:{type:Object,required:!0},rootId:{type:String,required:!0},reply:{type:Object}},components:{CommentBox:Re,ReplyIcon:()=>o("svg",{viewBox:"0 0 1024 1024",width:"18",height:"18"},o("path",{d:"M1019.2 720C1001.6 625.6 968 566.4 904 497.6c-89.6-89.6-214.4-150.4-347.2-176v-120c0-25.6-8-51.2-25.6-64-33.6-30.4-81.6-30.4-112-4.8L33.6 441.6C12.8 459.2 0 484.8 0 510.4c0 25.6 12.8 51.2 30.4 68.8l385.6 312c17.6 12.8 33.6 17.6 51.2 17.6 12.8 0 25.6-4.8 38.4-8C536 888 552 857.6 552 824v-99.2c124.8 20.8 248 86.4 339.2 140.8 25.6 17.6 59.2 17.6 89.6 0 25.6-17.6 43.2-46.4 43.2-76.8 0-33.6 0-56-4.8-68.8zm-500.8-89.6-46.4-4.8v193.6L86.4 510.4 472 201.6V400l38.4 4.8c128 12.8 248 68.8 334.4 153.6 51.2 56 76.8 102.4 94.4 179.2 0 4.8 4.8 20.8 4.8 51.2C835.2 720 672 640 518.4 630.4z",fill:"currentColor"})),VerifiedIcon:()=>o("svg",{class:"verified-icon",viewBox:"0 0 1024 1024",width:"14",height:"14"},o("path",{d:"m894.4 461.56-54.4-63.2c-10.4-12-18.8-34.4-18.8-50.4v-68c0-42.4-34.8-77.2-77.2-77.2h-68c-15.6 0-38.4-8.4-50.4-18.8l-63.2-54.4c-27.6-23.6-72.8-23.6-100.8 0l-62.8 54.8c-12 10-34.8 18.4-50.4 18.4h-69.2c-42.4 0-77.2 34.8-77.2 77.2v68.4c0 15.6-8.4 38-18.4 50l-54 63.6c-23.2 27.6-23.2 72.4 0 100l54 63.6c10 12 18.4 34.4 18.4 50v68.4c0 42.4 34.8 77.2 77.2 77.2h69.2c15.6 0 38.4 8.4 50.4 18.8l63.2 54.4c27.6 23.6 72.8 23.6 100.8 0l63.2-54.4c12-10.4 34.4-18.8 50.4-18.8h68c42.4 0 77.2-34.8 77.2-77.2v-68c0-15.6 8.4-38.4 18.8-50.4l54.4-63.2c23.2-27.6 23.2-73.2-.4-100.8zm-216-25.2-193.2 193.2a30 30 0 0 1-42.4 0l-96.8-96.8a30.16 30.16 0 0 1 0-42.4c11.6-11.6 30.8-11.6 42.4 0l75.6 75.6 172-172c11.6-11.6 30.8-11.6 42.4 0 11.6 11.6 11.6 30.8 0 42.4z",fill:"#27ae60"}))},emits:["submit","reply"],setup(e){const t=r("config"),n=i((()=>t.value.locale)),o=i((()=>{let{link:t}=e.comment;return t?Z(t)?t:`https://${t}`:""})),l=i((()=>{var t;return e.comment.objectId===(null===(t=e.reply)||void 0===t?void 0:t.objectId)}));return{config:t,locale:n,isReplyingCurrent:l,link:o,timeAgo:be}}});const rt=["id"],it={class:"wl-user","aria-hidden":"true"},at=["src"],st={class:"wl-card"},ct={class:"wl-head"},mt=["href"],ut={key:1,class:"wl-nick"},dt=["textContent"],pt=["textContent"],vt=["textContent"],gt=["title"],ht={class:"wl-meta","aria-hidden":"true"},ft=["textContent"],yt=["textContent"],wt=["innerHTML"],bt={key:0,class:"wl-reply-wrapper"},kt={key:1,class:"wl-quote"};lt.render=function(e,t,n,o,l,r){const i=m("VerifiedIcon"),a=m("ReplyIcon"),s=m("CommentBox"),c=m("CommentCard",!0);return u(),d("div",{class:"wl-item",id:e.comment.objectId},[p("div",it,[e.comment.avatar?(u(),d("img",{key:0,src:e.comment.avatar},null,8,at)):h("v-if",!0),e.comment.type?(u(),L(i,{key:1})):h("v-if",!0)]),p("div",st,[p("div",ct,[e.link?(u(),d("a",{key:0,class:"wl-nick",href:e.link,target:"_blank",rel:"nofollow noreferrer"},g(e.comment.nick),9,mt)):(u(),d("span",ut,g(e.comment.nick),1)),"administrator"===e.comment.type?(u(),d("span",{key:2,class:"wl-badge",textContent:g(e.locale.admin)},null,8,dt)):h("v-if",!0),e.comment.sticky?(u(),d("span",{key:3,class:"wl-badge",textContent:g(e.locale.sticky)},null,8,pt)):h("v-if",!0),p("span",{class:"wl-time",textContent:g(e.timeAgo(e.comment.insertedAt,e.locale))},null,8,vt),p("button",{class:f(["wl-reply",{active:e.isReplyingCurrent}]),title:e.isReplyingCurrent?e.locale.cancelReply:e.locale.reply,onClick:t[0]||(t[0]=t=>e.$emit("reply",e.isReplyingCurrent?null:e.comment))},[v(a)],10,gt)]),p("div",ht,[e.comment.browser?(u(),d("span",{key:0,textContent:g(e.comment.browser)},null,8,ft)):h("v-if",!0),e.comment.os?(u(),d("span",{key:1,textContent:g(e.comment.os)},null,8,yt)):h("v-if",!0)]),p("div",{class:"wl-content",innerHTML:e.comment.comment},null,8,wt),e.isReplyingCurrent?(u(),d("div",bt,[v(s,{replyId:e.comment.objectId,replyUser:e.comment.nick,rootId:e.rootId,onSubmit:t[1]||(t[1]=t=>e.$emit("submit",t)),onCancelReply:t[2]||(t[2]=t=>e.$emit("reply",null))},null,8,["replyId","replyUser","rootId"])])):h("v-if",!0),e.comment.children?(u(),d("div",kt,[(u(!0),d(y,null,w(e.comment.children,(n=>(u(),L(c,{key:n.objectId,comment:n,reply:e.reply,rootId:e.rootId,onReply:t[3]||(t[3]=t=>e.$emit("reply",t)),onSubmit:t[4]||(t[4]=t=>e.$emit("submit",t))},null,8,["comment","reply","rootId"])))),128))])):h("v-if",!0)])],8,rt)},lt.__file="src/components/CommentCard.vue";var Ct=l({name:"WalineRoot",components:{CommentBox:Re,CommentCard:lt,LoadingIcon:Le},props:{serverURL:{type:String,required:!0},path:{type:String,required:!0},meta:{type:Array},requiredMeta:{type:Array},visitor:{type:Boolean},dark:{type:[String,Boolean]},lang:{type:String},locale:{type:Object},pageSize:{type:Number},wordLimit:{type:[Number,Array]},emoji:{type:Array},login:{type:String},highlighter:{type:Function},imageUploader:{type:[Function,!1]},texRender:{type:Function}},setup(e){const n=i((()=>(({serverURL:e,path:t=location.pathname,lang:n="zh-CN",locale:o,emoji:l=["https://cdn.jsdelivr.net/gh/walinejs/emojis@1.0.0/weibo"],meta:r=["nick","mail","link"],requiredMeta:i=[],pageSize:a=10,wordLimit:s,imageUploader:c,highlighter:m,texRenderer:u,copyright:d=!0,login:p="enable",...v})=>{return{serverURL:oe(e),path:Q(t),lang:n,locale:{...J[n]||J["zh-CN"],..."object"==typeof o?o:{}},emoji:(g=l,Promise.all(g.map((e=>"string"==typeof e?te(X(e)):Promise.resolve(e)))).then((e=>{const t={tabs:[],map:{}};return e.forEach((e=>{const{name:n,folder:o,icon:l,prefix:r,type:i,items:a}=e;t.tabs.push({name:n,icon:ne(l,o,r,i),items:a.map((e=>{const n=`${r||""}${e}`;return t.map[n]=ne(e,o,r,i),n}))})})),t}))),wordLimit:Array.isArray(s)?s:!!s&&[0,s],meta:M(r),requiredMeta:M(i),pageSize:a,login:p,imageUploader:le(c,P),highlighter:le(m,z),texRenderer:le(u,T),copyright:d,...v};var g})(e))),{userInfo:o}=$e(),l=t("loading"),r=t(0),c=t(1),m=t(0),u=t([]),d=t(null),p=i((()=>{return"string"==typeof(e=n.value.dark)?"auto"===e?`@media(prefers-color-scheme:dark){body${re}}`:`${e}${re}`:!0===e?`:root${re}`:"";var e}));let v,g;const h=e=>{var t;const{serverURL:i,path:a,pageSize:s}=n.value,d=new AbortController;l.value="loading",null==v||v(),(({serverURL:e,path:t,page:n,pageSize:o,signal:l,token:r})=>{const i={};return r&&(i.Authorization=`Bearer ${r}`),fetch(`${e}/comment?path=${encodeURIComponent(t)}&pageSize=${o}&page=${n}`,{signal:l,headers:i}).then((e=>e.json())).then((e=>ce(e,"comment list")))})({serverURL:i,path:a,pageSize:s,page:e,signal:d.signal,token:null===(t=o.value)||void 0===t?void 0:t.token}).then((t=>{l.value="success",r.value=t.count,u.value.push(...t.data),c.value=e,m.value=t.totalPages})).catch((e=>{"AbortError"!==e.name&&(console.error(e.message),l.value="error")})),v=d.abort.bind(d)},f=()=>{r.value=0,u.value=[],h(1)};return R("config",n),a((()=>e.path),f),s((()=>{var e;f();const t=document.createElement("style");t.innerText=p.value,null===(e=document.querySelector("[data-waline]"))||void 0===e||e.appendChild(t),g=S((()=>{t.innerText=p.value}))})),j((()=>g())),{config:n,darkmodeStyle:p,i18n:i((()=>n.value.locale)),status:l,count:r,page:c,totalPages:m,data:u,reply:d,loadMore:()=>h(c.value+1),refresh:f,onReply:e=>{d.value=e},onSubmit:e=>{if(e.rid){const t=u.value.find((({objectId:t})=>t===e.rid));if(!t)return;Array.isArray(t.children)||(t.children=[]),t.children.push(e)}else u.value.unshift(e)},version:"2.0.0"}}});const $t={"data-waline":""},It={class:"wl-count"},Lt=["textContent"],Rt={class:"wl-cards"},St={key:1,class:"wl-action"},jt=["textContent"],xt={key:0,class:"wl-loading"},Ut=["textContent"],Et={class:"wl-more"},zt=["textContent"],At={key:3,class:"wl-power"},Mt=I(" Powered by "),Nt=p("a",{href:"https://github.com/walinejs/waline",target:"_blank",rel:"noreferrer"}," Waline ",-1);Ct.render=function(e,t,n,o,l,r){const i=m("CommentBox"),a=m("CommentCard"),s=m("LoadingIcon");return u(),d("div",$t,[e.reply?h("v-if",!0):(u(),L(i,{key:0,onSubmit:e.onSubmit},null,8,["onSubmit"])),p("div",It,[e.count?(u(),d("span",{key:0,class:"wl-num",textContent:g(e.count)},null,8,Lt)):h("v-if",!0),I(" "+g(e.i18n.comment),1)]),p("div",Rt,[(u(!0),d(y,null,w(e.data,(t=>(u(),L(a,{key:t.objectId,"root-id":t.objectId,comment:t,reply:e.reply,onReply:e.onReply,onSubmit:e.onSubmit},null,8,["root-id","comment","reply","onReply","onSubmit"])))),128))]),"error"===e.status?(u(),d("div",St,[p("button",{type:"button",class:"wl-btn",onClick:t[0]||(t[0]=(...t)=>e.refresh&&e.refresh(...t)),textContent:g(e.i18n.refresh)},null,8,jt)])):(u(),d(y,{key:2},["loading"===e.status?(u(),d("div",xt,[v(s,{size:30})])):e.data.length?e.page<e.totalPages?(u(),d(y,{key:2},[h(" Load more button "),p("div",Et,[p("button",{type:"button",class:"wl-btn",onClick:t[1]||(t[1]=(...t)=>e.loadMore&&e.loadMore(...t)),textContent:g(e.i18n.more)},null,8,zt)])],2112)):h("v-if",!0):(u(),d("div",{key:1,class:"wl-empty",textContent:g(e.i18n.sofa)},null,8,Ut))],2112)),h(" Copyright Information "),e.config.copyright?(u(),d("div",At,[Mt,Nt,I(" v"+g(e.version),1)])):h("v-if",!0)])},Ct.__file="src/components/Waline.vue";const Pt=(e,t)=>{t.forEach(((t,n)=>{t.innerText=e[n].toString()}))},Tt=({serverURL:e,path:t=window.location.pathname,selector:n=".waline-pageview-count",update:o=!0})=>{const l=new AbortController,r=Array.from(document.querySelectorAll(n)),i=e=>{const n=ye(e);return null!==n&&t!==n},a=n=>me({serverURL:e,paths:n.map((e=>ye(e)||t)),signal:l.signal}).then((e=>Pt(e,n))).catch(se);if(o){const n=r.filter((e=>!i(e))),o=r.filter(i);ue({serverURL:e,path:t}).then((e=>Pt(new Array(n.length).fill(e),n))),o.length&&a(o)}else a(r);return l.abort.bind(l)},Ot=({el:t="#waline",path:n=window.location.pathname,comment:l=!1,pageview:r=!1,...i})=>{const a=t?de(t):null;if(t&&!a)throw new Error("Option 'el' do not match any domElement!");if(!i.serverURL)throw new Error("Option 'serverURL' is missing!");const s=e({...i}),c=e({comment:l,pageview:r,path:n}),m=()=>{c.comment&&Ie({serverURL:s.serverURL,path:c.path,selector:"string"==typeof c.comment?c.comment:void 0})},u=()=>{c.pageview&&Tt({serverURL:s.serverURL,path:c.path,selector:"string"==typeof c.pageview?c.pageview:void 0})},d=a?x((()=>o(Ct,{path:c.path,...s}))):null;d&&d.mount(a),m(),u();const p=S(m),v=S(u);return{el:a,update:({comment:e,pageview:t,path:n=window.location.pathname,...o})=>{Object.entries(o).map((([e,t])=>{s[e]=t})),c.path=n,void 0!==e&&(c.comment=e),void 0!==t&&(c.pageview=t)},destroy:()=>{null==d||d.unmount(),p(),v()}}},Bt="2.0.0",_t=({el:e,serverURL:t,count:n})=>{var o;const l=de(e),r=new AbortController;return(({serverURL:e,count:t,signal:n,token:o})=>{const l={};return o&&(l.Authorization=`Bearer ${o}`),fetch(`${e}/comment?type=recent&count=${t}`,{signal:n,headers:l}).then((e=>e.json())).then((e=>ce(e,"recent comment")))})({serverURL:t,count:n,signal:r.signal,token:null===(o=ke())||void 0===o?void 0:o.token}).then((e=>l&&e.length?(l.innerHTML=`<ul class="wl-recent-list">${e.map((e=>`<li class="wl-recent-item"><a href="${e.url}">${e.nick}</a>:${e.comment}</li>`)).join("")}</ul>`,{comments:e,destroy:()=>{r.abort(),l.innerHTML=""}}):{comments:e,destroy:()=>r.abort()}))};export{_t as RecentComments,Ie as commentCount,N as defaultLang,T as defaultTexRenderer,P as defaultUploadImage,M as getMeta,Ot as init,J as locales,Tt as pageviewCount,Bt as version};
1
+ import{reactive as e,ref as t,readonly as n,h as o,defineComponent as l,inject as r,computed as i,watch as a,onMounted as s,onUnmounted as c,resolveComponent as m,openBlock as u,createElementBlock as d,createElementVNode as p,createVNode as v,toDisplayString as g,createCommentVNode as h,normalizeClass as f,Fragment as y,renderList as w,withDirectives as b,vModelDynamic as k,vModelText as C,normalizeStyle as $,createTextVNode as I,createBlock as L,provide as R,watchEffect as S,onBeforeUnmount as j,createApp as x}from"vue";import U from"autosize";import{marked as E}from"marked";import z from"hanabi";const A=["nick","mail","link"],M=e=>e.filter((e=>A.includes(e))),N="zh-CN",P=e=>new Promise(((t,n)=>{const o=new FileReader;o.readAsDataURL(e),o.onload=()=>{var e;return t((null===(e=o.result)||void 0===e?void 0:e.toString())||"")},o.onerror=n})),T=e=>!0===e?'<p class="vtex">Tex is not available in preview</p>':'<span class="vtex">Tex is not available in preview</span>',O=["nick","nickError","mail","mailError","link","optional","placeholder","sofa","submit","reply","cancelReply","comment","refresh","more","preview","emoji","uploadImage","seconds","minutes","hours","days","now","uploading","login","logout","admin","sticky","word","wordHint","anonymous"],B=e=>Object.fromEntries(e.map(((e,t)=>[O[t],e])));var _=B(["NickName","NickName cannot be less than 3 bytes.","E-Mail","Please confirm your email address.","Website","Optional","Comment here...","No comment yet.","Submit","Reply","Cancel reply","Comments","Refresh","Load More...","Preview","Emoji","Upload Image","seconds ago","minutes ago","hours ago","days ago","just now","Uploading","Login","logout","Admin","Sticky","Words","Please input comments between $0 and $1 words!\n Current word number: $2","Anonymous"]),H=B(["ニックネーム","3バイト以上のニックネームをご入力ください.","メールアドレス","メールアドレスをご確認ください.","サイト","オプション","ここにコメント","コメントしましょう~","提出する","返信する","キャンセル","コメント","更新","さらに読み込む","プレビュー","絵文字","画像をアップロード","秒前","分前","時間前","日前","たっだ今","アップロード","ログインする","ログアウト","管理者","トップに置く","ワード","コメントは $0 から $1 ワードの間でなければなりません!\n 現在の単語番号: $2","匿名"]),W=B(["昵称","昵称不能少于3个字符","邮箱","请填写正确的邮件地址","网址","可选","欢迎评论","来发评论吧~","提交","回复","取消回复","评论","刷新","加载更多...","预览","表情","上传图片","秒前","分钟前","小时前","天前","刚刚","正在上传","登录","退出","博主","置顶","字","评论字数应在 $0 到 $1 字之间!\n当前字数:$2","匿名"]),q=B(["暱稱","郵箱","網址","可選","暱稱不能少於3個字元","請填寫正確的郵件地址","歡迎評論","來發評論吧~","提交","回覆","取消回覆","評論","刷新","載入更多...","預覽","表情","上傳圖片","秒前","分鐘前","小時前","天前","剛剛","正在上傳","登錄","退出","博主","置頂","字","評論字數應在 $0 到 $1 字之間!\n當前字數:$2","匿名"]),V=B(["Apelido","Apelido não pode ser menor que 3 bytes.","E-Mail","Por favor, confirme seu endereço de e-mail.","Website","Opcional","Comente aqui...","Nenhum comentário, ainda.","Enviar","Responder","Cancelar resposta","Comentários","Refrescar","Carregar Mais...","Visualizar","Emoji","Enviar Imagem","segundos atrás","minutos atrás","horas atrás","dias atrás","agora mesmo","Enviando","Entrar","Sair","Admin","Sticky","Palavras","Favor enviar comentário com $0 a $1 palavras!\n Número de palavras atuais: $2","Anônimo"]),D=B(["Псевдоним","Никнейм не может быть меньше 3 байт.","Эл. адрес","Пожалуйста, подтвердите адрес вашей электронной почты.","Веб-сайт","Необязательный","Комментарий здесь...","Пока нет комментариев.","Отправить","Отвечать","Отменить ответ","Комментарии","Обновить","Загрузи больше...","Превью","эмодзи","Загрузить изображение","секунд назад","несколько минут назад","несколько часов назад","дней назад","прямо сейчас","Загрузка","Авторизоваться","Выход из системы","Админ","Липкий","Слова","Пожалуйста, введите комментарии от $0 до $1 слов!\nНомер текущего слова: $2","Анонимный"]);const J={zh:W,"zh-cn":W,"zh-CN":W,"zh-tw":q,"zh-TW":q,en:_,"en-US":_,"en-us":_,jp:H,"jp-jp":H,"jp-JP":H,"pt-br":V,"pt-BR":V,ru:D,"ru-ru":D,"ru-RU":D},F=e=>{let t={};const n=localStorage.getItem(e);if(n)try{t=JSON.parse(n)}catch(e){}return{get:e=>t[e]||null,set(n,o){try{t[n]=JSON.parse(JSON.stringify(o)),localStorage.setItem(e,JSON.stringify(t))}catch(e){}},update(n){t=JSON.parse(JSON.stringify(n)),localStorage.setItem(e,JSON.stringify(t))}}};let K,Y;const G=()=>(Y||(K=F("WALINE_USER_CACHE"),Y=e({nick:K.get("nick")||"",mail:K.get("mail")||"",link:K.get("link")||"",editor:""})),{inputs:Y,store:K}),Q=e=>{try{e=decodeURI(e)}catch(e){}return e},X=(e="")=>e.replace(/\/$/u,""),Z=e=>/^(https?:)?\/\//.test(e);let ee;const te=e=>{ee||(ee=F("WALINE_EMOJI"));const t=Boolean(/@[0-9]+\.[0-9]+\.[0-9]+/.test(e));if(t){const t=ee.get(e);if(t)return Promise.resolve(t)}return fetch(`${e}/info.json`).then((e=>e.json())).then((n=>{const o={folder:e,...n};return t&&ee.set(e,o),o}))},ne=(e,t="",n="",o="")=>`${t?`${t}/`:""}${n}${e}${o?`.${o}`:""}`,oe=e=>{const t=X(e);return Z(t)?t:`https://${t}`},le=(e,t)=>"function"==typeof e?e:!1!==e&&t,re="{--waline-white:#000;--waline-light-grey:#666;--waline-dark-grey:#999;--waline-color:#888;--waline-bgcolor:#1e1e1e;--waline-bgcolor-light:#272727;--waline-bgcolor-hover: #444;--waline-border-color:#333;--waline-disable-bgcolor:#444;--waline-disable-color:#272727;--waline-bq-color:#272727;--waline-info-bgcolor:#272727;--waline-info-color:#666}",ie=e=>e.type.includes("image"),ae=e=>{const t=Array.from(e).find(ie);return t?t.getAsFile():null},se=e=>{"AbortError"!==e.name&&console.error(e.message)},ce=(e,t="")=>{if("object"==typeof e&&e.errno)throw new TypeError(`Fetch ${t} failed with ${e.errno}: ${e.errmsg}`);return e},me=({serverURL:e,paths:t,signal:n})=>fetch(`${e}/article?path=${encodeURIComponent(t.join(","))}`,{signal:n}).then((e=>e.json())).then((e=>ce(e,"visit count"))).then((e=>Array.isArray(e)?e:[e])),ue=({serverURL:e,path:t})=>fetch(`${e}/article`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:t})}).then((e=>e.json())).then((e=>ce(e,"visit count"))),de=e=>e instanceof HTMLElement?e:"string"==typeof e?document.querySelector(e):null,pe=/\$.*?\$/,ve=/^\$(.*?)\$/,ge=/^(?:\s{0,3})\$\$((?:[^\n]|\n[^\n])+?)\n{0,1}\$\$/,he=(e="",t={})=>e.replace(/:(.+?):/g,((e,n)=>t[n]?`<img class="vemoji" src="${t[n]}" alt="${n}">`:e)),fe=(e,{emojiMap:t,highlighter:n,texRenderer:o})=>{if(E.setOptions({highlight:n||void 0,breaks:!0,smartLists:!0,smartypants:!0}),o){const e=(e=>[{name:"blockMath",level:"block",tokenizer(t){const n=ge.exec(t);if(null!==n)return{type:"html",raw:n[0],text:e(!0,n[1])}}},{name:"inlineMath",level:"inline",start(e){const t=e.search(pe);return-1!==t?t:e.length},tokenizer(t){const n=ve.exec(t);if(null!==n)return{type:"html",raw:n[0],text:e(!1,n[1])}}}])(o);E.use({extensions:e})}return E.parse(he(e,t))},ye=e=>e.dataset.path||e.getAttribute("id"),we=(e,t)=>{let n=e.toString();for(;n.length<t;)n="0"+n;return n},be=(e,t)=>{if(e)try{"string"==typeof e&&(e=new Date(-1!==e.indexOf(" ")?e.replace(/-/g,"/"):e));const n=e.getTime(),o=(new Date).getTime()-n,l=Math.floor(o/864e5);if(0===l){const e=o%864e5,n=Math.floor(e/36e5);if(0===n){const n=e%36e5,o=Math.floor(n/6e4);if(0===o){const e=n%6e4;return`${Math.round(e/1e3)} ${t.seconds}`}return`${o} ${t.minutes}`}return`${n} ${t.hours}`}return l<0?t.now:l<8?`${l} ${t.days}`:(e=>{const t=we(e.getDate(),2),n=we(e.getMonth()+1,2);return`${we(e.getFullYear(),2)}-${n}-${t}`})(e)}catch(e){console.log(e)}return""},ke=()=>{try{const e=localStorage.getItem("WALINE_USER"),t=sessionStorage.getItem("WALINE_USER");return e?JSON.parse(e):t?JSON.parse(t):null}catch(e){return null}},Ce=t({}),$e=()=>{if(!Ce.value.token){const e=ke();e&&(Ce.value=e)}return{userInfo:n(Ce),setUserInfo:e=>{Ce.value=e}}},Ie=({serverURL:e,path:t=window.location.pathname,selector:n=".waline-comment-count"})=>{var o;const l=new AbortController,r=document.querySelectorAll(n),{userInfo:i}=$e();return r.length&&(({serverURL:e,paths:t,signal:n,token:o})=>{const l={};return o&&(l.Authorization=`Bearer ${o}`),fetch(`${e}/comment?type=count&url=${encodeURIComponent(t.join(","))}`,{signal:n,headers:l}).then((e=>e.json())).then((e=>ce(e,"comment count"))).then((e=>Array.isArray(e)?e:[e]))})({serverURL:e,paths:Array.from(r).map((e=>Q(e.dataset.path||e.getAttribute("id")||t))),signal:l.signal,token:null===(o=i.value)||void 0===o?void 0:o.token}).then((e=>{r.forEach(((t,n)=>{t.innerText=e[n].toString()}))})).catch(se),l.abort.bind(l)},Le=({size:e})=>o("svg",{width:e,height:e,viewBox:"0 0 100 100",preserveAspectRatio:"xMidYMid"},o("circle",{cx:50,cy:50,fill:"none",stroke:"currentColor",strokeWidth:"4",r:"40","stroke-dasharray":"85 30"},o("animateTransform",{attributeName:"transform",type:"rotate",repeatCount:"indefinite",dur:"1s",values:"0 50 50;360 50 50",keyTimes:"0;1"})));var Re=l({name:"CommentBox",components:{CloseIcon:({size:e})=>o("svg",{class:"wl-close-icon",viewBox:"0 0 1024 1024",width:e,height:e},[o("path",{d:"M697.173 85.333h-369.92c-144.64 0-241.92 101.547-241.92 252.587v348.587c0 150.613 97.28 252.16 241.92 252.16h369.92c144.64 0 241.494-101.547 241.494-252.16V337.92c0-151.04-96.854-252.587-241.494-252.587z",fill:"currentColor"}),o("path",{d:"m640.683 587.52-75.947-75.861 75.904-75.862a37.29 37.29 0 0 0 0-52.778 37.205 37.205 0 0 0-52.779 0l-75.946 75.818-75.862-75.946a37.419 37.419 0 0 0-52.821 0 37.419 37.419 0 0 0 0 52.821l75.947 75.947-75.776 75.733a37.29 37.29 0 1 0 52.778 52.821l75.776-75.776 75.947 75.947a37.376 37.376 0 0 0 52.779-52.821z",fill:"#888"})]),EmojiIcon:()=>o("svg",{viewBox:"0 0 1024 1024",width:"24",height:"24"},o("path",{d:"M563.2 463.3 677 540c1.7 1.2 3.7 1.8 5.8 1.8.7 0 1.4-.1 2-.2 2.7-.5 5.1-2.1 6.6-4.4l25.3-37.8c1.5-2.3 2.1-5.1 1.6-7.8s-2.1-5.1-4.4-6.6l-73.6-49.1 73.6-49.1c2.3-1.5 3.9-3.9 4.4-6.6.5-2.7 0-5.5-1.6-7.8l-25.3-37.8a10.1 10.1 0 0 0-6.6-4.4c-.7-.1-1.3-.2-2-.2-2.1 0-4.1.6-5.8 1.8l-113.8 76.6c-9.2 6.2-14.7 16.4-14.7 27.5.1 11 5.5 21.3 14.7 27.4zM387 348.8h-45.5c-5.7 0-10.4 4.7-10.4 10.4v153.3c0 5.7 4.7 10.4 10.4 10.4H387c5.7 0 10.4-4.7 10.4-10.4V359.2c0-5.7-4.7-10.4-10.4-10.4zm333.8 241.3-41-20a10.3 10.3 0 0 0-8.1-.5c-2.6.9-4.8 2.9-5.9 5.4-30.1 64.9-93.1 109.1-164.4 115.2-5.7.5-9.9 5.5-9.5 11.2l3.9 45.5c.5 5.3 5 9.5 10.3 9.5h.9c94.8-8 178.5-66.5 218.6-152.7 2.4-5 .3-11.2-4.8-13.6zm186-186.1c-11.9-42-30.5-81.4-55.2-117.1-24.1-34.9-53.5-65.6-87.5-91.2-33.9-25.6-71.5-45.5-111.6-59.2-41.2-14-84.1-21.1-127.8-21.1h-1.2c-75.4 0-148.8 21.4-212.5 61.7-63.7 40.3-114.3 97.6-146.5 165.8-32.2 68.1-44.3 143.6-35.1 218.4 9.3 74.8 39.4 145 87.3 203.3.1.2.3.3.4.5l36.2 38.4c1.1 1.2 2.5 2.1 3.9 2.6 73.3 66.7 168.2 103.5 267.5 103.5 73.3 0 145.2-20.3 207.7-58.7 37.3-22.9 70.3-51.5 98.1-85 27.1-32.7 48.7-69.5 64.2-109.1 15.5-39.7 24.4-81.3 26.6-123.8 2.4-43.6-2.5-87-14.5-129zm-60.5 181.1c-8.3 37-22.8 72-43 104-19.7 31.1-44.3 58.6-73.1 81.7-28.8 23.1-61 41-95.7 53.4-35.6 12.7-72.9 19.1-110.9 19.1-82.6 0-161.7-30.6-222.8-86.2l-34.1-35.8c-23.9-29.3-42.4-62.2-55.1-97.7-12.4-34.7-18.8-71-19.2-107.9-.4-36.9 5.4-73.3 17.1-108.2 12-35.8 30-69.2 53.4-99.1 31.7-40.4 71.1-72 117.2-94.1 44.5-21.3 94-32.6 143.4-32.6 49.3 0 97 10.8 141.8 32 34.3 16.3 65.3 38.1 92 64.8 26.1 26 47.5 56 63.6 89.2 16.2 33.2 26.6 68.5 31 105.1 4.6 37.5 2.7 75.3-5.6 112.3z",fill:"currentColor"})),ImageIcon:()=>o("svg",{viewBox:"0 0 1024 1024",width:"24",height:"24"},[o("path",{d:"M784 112H240c-88 0-160 72-160 160v480c0 88 72 160 160 160h544c88 0 160-72 160-160V272c0-88-72-160-160-160zm96 640c0 52.8-43.2 96-96 96H240c-52.8 0-96-43.2-96-96V272c0-52.8 43.2-96 96-96h544c52.8 0 96 43.2 96 96v480z",fill:"currentColor"}),o("path",{d:"M352 480c52.8 0 96-43.2 96-96s-43.2-96-96-96-96 43.2-96 96 43.2 96 96 96zm0-128c17.6 0 32 14.4 32 32s-14.4 32-32 32-32-14.4-32-32 14.4-32 32-32zm462.4 379.2-3.2-3.2-177.6-177.6c-25.6-25.6-65.6-25.6-91.2 0l-80 80-36.8-36.8c-25.6-25.6-65.6-25.6-91.2 0L200 728c-4.8 6.4-8 14.4-8 24 0 17.6 14.4 32 32 32 9.6 0 16-3.2 22.4-9.6L380.8 640l134.4 134.4c6.4 6.4 14.4 9.6 24 9.6 17.6 0 32-14.4 32-32 0-9.6-4.8-17.6-9.6-24l-52.8-52.8 80-80L769.6 776c6.4 4.8 12.8 8 20.8 8 17.6 0 32-14.4 32-32 0-8-3.2-16-8-20.8z",fill:"currentColor"})]),MarkdownIcon:()=>o("svg",{width:"16",height:"16",ariaHidden:"true"},o("path",{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",fill:"currentColor"})),PreviewIcon:()=>o("svg",{viewBox:"0 0 1024 1024",width:"24",height:"24"},[o("path",{d:"M710.816 654.301c70.323-96.639 61.084-230.578-23.705-314.843-46.098-46.098-107.183-71.109-172.28-71.109-65.008 0-126.092 25.444-172.28 71.109-45.227 46.098-70.756 107.183-70.756 172.106 0 64.923 25.444 126.007 71.194 172.106 46.099 46.098 107.184 71.109 172.28 71.109 51.414 0 100.648-16.212 142.824-47.404l126.53 126.006c7.058 7.06 16.297 10.979 26.406 10.979 10.105 0 19.343-3.919 26.402-10.979 14.467-14.467 14.467-38.172 0-52.723L710.816 654.301zm-315.107-23.265c-65.88-65.88-65.88-172.54 0-238.42 32.069-32.07 74.245-49.149 119.471-49.149 45.227 0 87.407 17.603 119.472 49.149 65.88 65.879 65.88 172.539 0 238.42-63.612 63.178-175.242 63.178-238.943 0zm0 0",fill:"currentColor"}),o("path",{d:"M703.319 121.603H321.03c-109.8 0-199.469 89.146-199.469 199.38v382.034c0 109.796 89.236 199.38 199.469 199.38h207.397c20.653 0 37.384-16.645 37.384-37.299 0-20.649-16.731-37.296-37.384-37.296H321.03c-68.582 0-124.352-55.77-124.352-124.267V321.421c0-68.496 55.77-124.267 124.352-124.267h382.289c68.582 0 124.352 55.771 124.352 124.267V524.72c0 20.654 16.736 37.299 37.385 37.299 20.654 0 37.384-16.645 37.384-37.299V320.549c-.085-109.8-89.321-198.946-199.121-198.946zm0 0",fill:"currentColor"})]),LoadingIcon:Le},props:{rootId:{type:String,default:""},replyId:{type:String,default:""},replyUser:{type:String,default:""}},emits:["submit","cancel-reply"],setup(e,{emit:n}){const o=r("config"),{inputs:l,store:m}=G(),{userInfo:u,setUserInfo:d}=$e(),p=t({}),v=t(null),g=t(null),h=t(null),f=t(null),y=t({tabs:[],map:{}}),w=t(0),b=t(!1),k=t(!1),C=t(""),$=t(0),I=t(0),L=t(!1),R=t(""),S=t(!1),j=i((()=>o.value.locale)),x=i((()=>{var e;return Boolean(null===(e=u.value)||void 0===e?void 0:e.token)})),E=i((()=>!1!==o.value.imageUploader)),z=e=>{const t=v.value,n=t.selectionStart,o=t.selectionEnd||0,r=t.scrollTop;l.editor=t.value.substring(0,n)+e+t.value.substring(o,t.value.length),t.focus(),t.selectionStart=n+e.length,t.selectionEnd=n+e.length,t.scrollTop=r},A=e=>{const t=`![${o.value.locale.uploading} ${e.name}]()`;return z(t),Promise.resolve().then((()=>o.value.imageUploader(e))).then((n=>{l.editor=l.editor.replace(t,`\r\n![${e.name}](${n})`)}))},M=()=>{var t,r,i,a,s;const{serverURL:c,lang:d,login:g,wordLimit:h,requiredMeta:f}=o.value,w={comment:R.value,nick:l.nick,mail:l.mail,link:l.link,ua:navigator.userAgent,url:o.value.path};if(null===(t=u.value)||void 0===t?void 0:t.token)w.nick=u.value.display_name,w.mail=u.value.email,w.link=u.value.url;else{if("force"===g)return;if((f.indexOf("nick")>-1||w.nick)&&!w.nick)return null===(r=p.value.nick)||void 0===r||r.focus(),alert(j.value.nickError);if(f.indexOf("mail")>-1&&!w.mail)return null===(i=p.value.mail)||void 0===i||i.focus(),alert(j.value.mailError);if(!w.comment)return void(null===(a=v.value)||void 0===a||a.focus());w.nick||(w.nick=j.value.anonymous)}if(!L.value)return alert(j.value.wordHint.replace("$0",h[0].toString()).replace("$1",h[1].toString()).replace("$2",$.value.toString()));w.comment=he(w.comment,y.value.map),e.replyId&&e.rootId&&(w.pid=e.replyId,w.rid=e.rootId,w.at=e.replyUser),S.value=!0,(({serverURL:e,lang:t,token:n,comment:o})=>{const l={"Content-Type":"application/json"};return n&&(l.Authorization=`Bearer ${n}`),fetch(`${e}/comment?lang=${t}`,{method:"POST",headers:l,body:JSON.stringify(o)}).then((e=>e.json()))})({serverURL:c,lang:d,token:null===(s=u.value)||void 0===s?void 0:s.token,comment:w}).then((t=>{if(S.value=!1,m.update({nick:w.nick,link:w.link,mail:w.mail}),t.errmsg)return alert(t.errmsg);n("submit",t.data),l.editor="",C.value="",e.replyId&&n("cancel-reply")})).catch((e=>{S.value=!1,alert(e.message)}))},N=e=>{h.value.contains(e.target)||f.value.contains(e.target)||(b.value=!1)};return a((()=>l.editor),(e=>{const{highlighter:t,texRenderer:n}=o.value;R.value=e,C.value=fe(e,{emojiMap:y.value.map,highlighter:t,texRenderer:n}),$.value=(e=>(e=>e.match(/[\w\d\s\u00C0-\u024F]+/giu)||[])(e).reduce(((e,t)=>e+(""===t.trim()?0:t.trim().split(/\s+/u).length)),0)+(e=>e.match(/[\u4E00-\u9FA5]/gu)||[])(e).length)(e),v.value&&(e?U(v.value):U.destroy(v.value))}),{immediate:!0}),a((()=>o.value.emoji),(e=>e.then((e=>{y.value=e}))),{immediate:!0}),a([o,$],(([e,t])=>{const{wordLimit:n}=e;n?t<n[0]&&0!==n[0]?(I.value=n[0],L.value=!1):t>n[1]?(I.value=n[1],L.value=!1):(I.value=n[1],L.value=!0):(I.value=0,L.value=!0)}),{immediate:!0}),s((()=>{document.body.addEventListener("click",N)})),c((()=>{document.body.removeEventListener("click",N)})),{config:o,locale:j,insert:z,onChange:()=>{const e=g.value;e.files&&E.value&&A(e.files[0]).then((()=>{e.value=""}))},onDrop:e=>{var t;if(null===(t=e.dataTransfer)||void 0===t?void 0:t.items){const t=ae(e.dataTransfer.items);t&&E.value&&(A(t),e.preventDefault())}},onKeyDown:e=>{const t=e.key;(e.ctrlKey||e.metaKey)&&"Enter"===t&&M()},onPaste:e=>{if(e.clipboardData){const t=ae(e.clipboardData.items);t&&E.value&&A(t)}},onLogin:e=>{e.preventDefault();const{lang:t,serverURL:n}=o.value,l=(window.innerWidth-450)/2,r=(window.innerHeight-450)/2,i=window.open(`${n}/ui/login?lng=${encodeURIComponent(t)}`,"_blank",`width=450,height=450,left=${l},top=${r},scrollbars=no,resizable=no,status=no,location=no,toolbar=no,menubar=no`);null==i||i.postMessage({type:"TOKEN",data:null},"*");const a=({data:e})=>{e&&"userInfo"===e.type&&e.data.token&&(null==i||i.close(),d(e.data),(e.data.remember?localStorage:sessionStorage).setItem("WALINE_USER",JSON.stringify(e.data)),window.removeEventListener("message",a))};window.addEventListener("message",a)},onLogout:()=>{d({}),localStorage.setItem("WALINE_USER","null"),sessionStorage.setItem("WALINE_USER","null")},onProfile:e=>{e.preventDefault();const{lang:t,serverURL:n}=o.value,l=(window.innerWidth-800)/2,r=(window.innerHeight-800)/2,i=window.open(`${n}/ui/profile?lng=${encodeURIComponent(t)}`,"_blank",`width=800,height=800,left=${l},top=${r},scrollbars=no,resizable=no,status=no,location=no,toolbar=no,menubar=no`);null==i||i.postMessage({type:"TOKEN",data:u.value.token},"*");const a=({data:e})=>{e&&"profile"===e.type&&(d(Object.assign({},u.value,e)),[localStorage,sessionStorage].filter((e=>e.getItem("WALINE_USER"))).forEach((e=>e.setItem("WALINE_USER",JSON.stringify(u)))),window.removeEventListener("message",a))};window.addEventListener("message",a)},submitComment:M,isLogin:x,userInfo:u,isSubmitting:S,wordNumber:$,wordLimit:I,isWordNumberLegal:L,inputs:l,emoji:y,emojiTabIndex:w,showEmoji:b,canUploadImage:E,previewText:C,showPreview:k,inputRefs:p,editorRef:v,emojiButtonRef:h,emojiPopupRef:f,imageUploadRef:g}}});const Se={class:"wl-comment"},je={key:0,class:"wl-login-info"},xe={class:"wl-avatar"},Ue=["title"],Ee=["src"],ze=["textContent"],Ae={class:"wl-panel"},Me=["for","textContent"],Ne=["id","name","type","onUpdate:modelValue"],Pe=["placeholder"],Te=["innerHTML"],Oe={class:"wl-footer"},Be={class:"wl-actions"},_e={href:"https://guides.github.com/features/mastering-markdown/",title:"Markdown Guide","aria-label":"Markdown is supported",class:"wl-action",target:"_blank",rel:"noreferrer"},He=["title"],We=["title"],qe=["title"],Ve={class:"wl-info"},De={class:"wl-text-number"},Je={key:0},Fe=I("  /  "),Ke=["textContent"],Ye=["textContent"],Ge=["disabled"],Qe={key:0,class:"wl-tab-wrapper"},Xe=["title","onClick"],Ze=["src","alt"],et={key:0,class:"wl-tabs"},tt=["onClick"],nt=["src","alt","title"],ot=["title"];Re.render=function(e,t,n,o,l,r){const i=m("CloseIcon"),a=m("MarkdownIcon"),s=m("EmojiIcon"),c=m("ImageIcon"),R=m("PreviewIcon"),S=m("LoadingIcon");return u(),d("div",Se,["disable"!==e.config.login&&e.isLogin?(u(),d("div",je,[p("div",xe,[p("button",{class:"wl-logout-btn",title:e.locale.logout,onClick:t[0]||(t[0]=(...t)=>e.onLogout&&e.onLogout(...t))},[v(i,{size:14})],8,Ue),p("img",{src:e.userInfo.avatar,alt:"avatar"},null,8,Ee)]),p("a",{href:"#",class:"wl-login-nick","aria-label":"Profile",onClick:t[1]||(t[1]=(...t)=>e.onProfile&&e.onProfile(...t)),textContent:g(e.userInfo.display_name)},null,8,ze)])):h("v-if",!0),p("div",Ae,["force"!==e.config.login&&e.config.meta.length&&!e.isLogin?(u(),d("div",{key:0,class:f(["wl-header",`item${e.config.meta.length}`])},[(u(!0),d(y,null,w(e.config.meta,(t=>(u(),d("div",{class:"wl-header-item",key:t},[p("label",{for:t,textContent:g(e.locale[t]+(e.config.requiredMeta.includes(t)||!e.config.requiredMeta.length?"":`(${e.locale.optional})`))},null,8,Me),b(p("input",{ref_for:!0,ref:n=>{n&&(e.inputRefs[t]=n)},id:`wl-${t}`,class:f(["wl-input",`wl-${t}`]),name:t,type:"mail"===t?"email":"text","onUpdate:modelValue":n=>e.inputs[t]=n},null,10,Ne),[[k,e.inputs[t]]])])))),128))],2)):h("v-if",!0),b(p("textarea",{class:"wl-editor",ref:"editorRef",id:"wl-edit",placeholder:e.replyUser?`@${e.replyUser}`:e.locale.placeholder,"onUpdate:modelValue":t[2]||(t[2]=t=>e.inputs.editor=t),onKeydown:t[3]||(t[3]=(...t)=>e.onKeyDown&&e.onKeyDown(...t)),onDrop:t[4]||(t[4]=(...t)=>e.onDrop&&e.onDrop(...t)),onPaste:t[5]||(t[5]=(...t)=>e.onPaste&&e.onPaste(...t))},null,40,Pe),[[C,e.inputs.editor]]),p("div",{class:"wl-preview",style:$({display:e.showPreview?"block":"none"})},[p("h4",null,g(e.locale.preview)+":",1),p("div",{class:"wl-content",innerHTML:e.previewText},null,8,Te)],4),p("div",Oe,[p("div",Be,[p("a",_e,[v(a)]),p("button",{ref:"emojiButtonRef",class:f(["wl-action",{actived:e.showEmoji}]),title:e.locale.emoji,onClick:t[6]||(t[6]=t=>e.showEmoji=!e.showEmoji)},[v(s)],10,He),p("input",{ref:"imageUploadRef",class:"upload",id:"wl-image-upload",type:"file",accept:".png,.jpg,.jpeg,.webp,.bmp,.gif",onChange:t[7]||(t[7]=(...t)=>e.onChange&&e.onChange(...t))},null,544),e.canUploadImage?(u(),d("label",{key:0,for:"wl-image-upload",class:"wl-action",title:e.locale.uploadImage},[v(c)],8,We)):h("v-if",!0),p("button",{class:f(["wl-action",{actived:e.showPreview}]),title:e.locale.preview,onClick:t[8]||(t[8]=t=>e.showPreview=!e.showPreview)},[v(R)],10,qe)]),p("div",Ve,[p("div",De,[I(g(e.wordNumber)+" ",1),e.config.wordLimit?(u(),d("span",Je,[Fe,p("span",{class:f({illegal:!e.isWordNumberLegal}),textContent:g(e.wordLimit)},null,10,Ke)])):h("v-if",!0),I("  "+g(e.locale.word),1)]),"disable"===e.config.login||e.isLogin?h("v-if",!0):(u(),d("button",{key:0,class:"wl-btn",onClick:t[9]||(t[9]=(...t)=>e.onLogin&&e.onLogin(...t)),textContent:g(e.locale.login)},null,8,Ye)),"force"!==e.config.login||e.isLogin?(u(),d("button",{key:1,class:"wl-btn primary",title:"Cmd|Ctrl + Enter",disabled:e.isSubmitting,onClick:t[10]||(t[10]=(...t)=>e.submitComment&&e.submitComment(...t))},[e.isSubmitting?(u(),L(S,{key:0,size:16})):(u(),d(y,{key:1},[I(g(e.locale.submit),1)],2112))],8,Ge)):h("v-if",!0)]),p("div",{ref:"emojiPopupRef",class:f(["wl-emoji-popup",{display:e.showEmoji}])},[(u(!0),d(y,null,w(e.emoji.tabs,((t,n)=>(u(),d(y,{key:t.name},[n===e.emojiTabIndex?(u(),d("div",Qe,[(u(!0),d(y,null,w(t.items,(t=>(u(),d("button",{key:t,title:t,onClick:n=>e.insert(`:${t}:`)},[e.showEmoji?(u(),d("img",{key:0,class:"wl-emoji",src:e.emoji.map[t],alt:t,loading:"lazy",referrerPolicy:"no-referrer"},null,8,Ze)):h("v-if",!0)],8,Xe)))),128))])):h("v-if",!0)],64)))),128)),e.emoji.tabs.length>1?(u(),d("div",et,[(u(!0),d(y,null,w(e.emoji.tabs,((t,n)=>(u(),d("button",{key:t.name,class:f(["wl-tab",{active:e.emojiTabIndex===n}]),onClick:t=>e.emojiTabIndex=n},[p("img",{class:"wl-emoji",src:t.icon,alt:t.name,title:t.name,loading:"lazy",referrerPolicy:"no-referrer"},null,8,nt)],10,tt)))),128))])):h("v-if",!0)],2)])]),e.replyId?(u(),d("button",{key:1,class:"wl-close",title:e.locale.cancelReply,onClick:t[11]||(t[11]=t=>e.$emit("cancel-reply"))},[v(i,{size:24})],8,ot)):h("v-if",!0)])},Re.__file="src/components/CommentBox.vue";var lt=l({props:{comment:{type:Object,required:!0},rootId:{type:String,required:!0},reply:{type:Object}},components:{CommentBox:Re,ReplyIcon:()=>o("svg",{viewBox:"0 0 1024 1024",width:"18",height:"18"},o("path",{d:"M1019.2 720C1001.6 625.6 968 566.4 904 497.6c-89.6-89.6-214.4-150.4-347.2-176v-120c0-25.6-8-51.2-25.6-64-33.6-30.4-81.6-30.4-112-4.8L33.6 441.6C12.8 459.2 0 484.8 0 510.4c0 25.6 12.8 51.2 30.4 68.8l385.6 312c17.6 12.8 33.6 17.6 51.2 17.6 12.8 0 25.6-4.8 38.4-8C536 888 552 857.6 552 824v-99.2c124.8 20.8 248 86.4 339.2 140.8 25.6 17.6 59.2 17.6 89.6 0 25.6-17.6 43.2-46.4 43.2-76.8 0-33.6 0-56-4.8-68.8zm-500.8-89.6-46.4-4.8v193.6L86.4 510.4 472 201.6V400l38.4 4.8c128 12.8 248 68.8 334.4 153.6 51.2 56 76.8 102.4 94.4 179.2 0 4.8 4.8 20.8 4.8 51.2C835.2 720 672 640 518.4 630.4z",fill:"currentColor"})),VerifiedIcon:()=>o("svg",{class:"verified-icon",viewBox:"0 0 1024 1024",width:"14",height:"14"},o("path",{d:"m894.4 461.56-54.4-63.2c-10.4-12-18.8-34.4-18.8-50.4v-68c0-42.4-34.8-77.2-77.2-77.2h-68c-15.6 0-38.4-8.4-50.4-18.8l-63.2-54.4c-27.6-23.6-72.8-23.6-100.8 0l-62.8 54.8c-12 10-34.8 18.4-50.4 18.4h-69.2c-42.4 0-77.2 34.8-77.2 77.2v68.4c0 15.6-8.4 38-18.4 50l-54 63.6c-23.2 27.6-23.2 72.4 0 100l54 63.6c10 12 18.4 34.4 18.4 50v68.4c0 42.4 34.8 77.2 77.2 77.2h69.2c15.6 0 38.4 8.4 50.4 18.8l63.2 54.4c27.6 23.6 72.8 23.6 100.8 0l63.2-54.4c12-10.4 34.4-18.8 50.4-18.8h68c42.4 0 77.2-34.8 77.2-77.2v-68c0-15.6 8.4-38.4 18.8-50.4l54.4-63.2c23.2-27.6 23.2-73.2-.4-100.8zm-216-25.2-193.2 193.2a30 30 0 0 1-42.4 0l-96.8-96.8a30.16 30.16 0 0 1 0-42.4c11.6-11.6 30.8-11.6 42.4 0l75.6 75.6 172-172c11.6-11.6 30.8-11.6 42.4 0 11.6 11.6 11.6 30.8 0 42.4z",fill:"#27ae60"}))},emits:["submit","reply"],setup(e){const t=r("config"),n=i((()=>t.value.locale)),o=i((()=>{let{link:t}=e.comment;return t?Z(t)?t:`https://${t}`:""})),l=i((()=>{var t;return e.comment.objectId===(null===(t=e.reply)||void 0===t?void 0:t.objectId)}));return{config:t,locale:n,isReplyingCurrent:l,link:o,timeAgo:be}}});const rt=["id"],it={class:"wl-user","aria-hidden":"true"},at=["src"],st={class:"wl-card"},ct={class:"wl-head"},mt=["href"],ut={key:1,class:"wl-nick"},dt=["textContent"],pt=["textContent"],vt=["textContent"],gt=["title"],ht={class:"wl-meta","aria-hidden":"true"},ft=["textContent"],yt=["textContent"],wt=["innerHTML"],bt={key:0,class:"wl-reply-wrapper"},kt={key:1,class:"wl-quote"};lt.render=function(e,t,n,o,l,r){const i=m("VerifiedIcon"),a=m("ReplyIcon"),s=m("CommentBox"),c=m("CommentCard",!0);return u(),d("div",{class:"wl-item",id:e.comment.objectId},[p("div",it,[e.comment.avatar?(u(),d("img",{key:0,src:e.comment.avatar},null,8,at)):h("v-if",!0),e.comment.type?(u(),L(i,{key:1})):h("v-if",!0)]),p("div",st,[p("div",ct,[e.link?(u(),d("a",{key:0,class:"wl-nick",href:e.link,target:"_blank",rel:"nofollow noreferrer"},g(e.comment.nick),9,mt)):(u(),d("span",ut,g(e.comment.nick),1)),"administrator"===e.comment.type?(u(),d("span",{key:2,class:"wl-badge",textContent:g(e.locale.admin)},null,8,dt)):h("v-if",!0),e.comment.sticky?(u(),d("span",{key:3,class:"wl-badge",textContent:g(e.locale.sticky)},null,8,pt)):h("v-if",!0),p("span",{class:"wl-time",textContent:g(e.timeAgo(e.comment.insertedAt,e.locale))},null,8,vt),p("button",{class:f(["wl-reply",{active:e.isReplyingCurrent}]),title:e.isReplyingCurrent?e.locale.cancelReply:e.locale.reply,onClick:t[0]||(t[0]=t=>e.$emit("reply",e.isReplyingCurrent?null:e.comment))},[v(a)],10,gt)]),p("div",ht,[e.comment.browser?(u(),d("span",{key:0,textContent:g(e.comment.browser)},null,8,ft)):h("v-if",!0),e.comment.os?(u(),d("span",{key:1,textContent:g(e.comment.os)},null,8,yt)):h("v-if",!0)]),p("div",{class:"wl-content",innerHTML:e.comment.comment},null,8,wt),e.isReplyingCurrent?(u(),d("div",bt,[v(s,{replyId:e.comment.objectId,replyUser:e.comment.nick,rootId:e.rootId,onSubmit:t[1]||(t[1]=t=>e.$emit("submit",t)),onCancelReply:t[2]||(t[2]=t=>e.$emit("reply",null))},null,8,["replyId","replyUser","rootId"])])):h("v-if",!0),e.comment.children?(u(),d("div",kt,[(u(!0),d(y,null,w(e.comment.children,(n=>(u(),L(c,{key:n.objectId,comment:n,reply:e.reply,rootId:e.rootId,onReply:t[3]||(t[3]=t=>e.$emit("reply",t)),onSubmit:t[4]||(t[4]=t=>e.$emit("submit",t))},null,8,["comment","reply","rootId"])))),128))])):h("v-if",!0)])],8,rt)},lt.__file="src/components/CommentCard.vue";var Ct=l({name:"WalineRoot",components:{CommentBox:Re,CommentCard:lt,LoadingIcon:Le},props:{serverURL:{type:String,required:!0},path:{type:String,required:!0},meta:{type:Array},requiredMeta:{type:Array},visitor:{type:Boolean},dark:{type:[String,Boolean]},lang:{type:String},locale:{type:Object},pageSize:{type:Number},wordLimit:{type:[Number,Array]},emoji:{type:Array},login:{type:String},highlighter:{type:Function},imageUploader:{type:[Function,!1]},texRender:{type:Function}},setup(e){const n=i((()=>(({serverURL:e,path:t=location.pathname,lang:n="zh-CN",locale:o,emoji:l=["https://cdn.jsdelivr.net/gh/walinejs/emojis@1.0.0/weibo"],meta:r=["nick","mail","link"],requiredMeta:i=[],pageSize:a=10,wordLimit:s,imageUploader:c,highlighter:m,texRenderer:u,copyright:d=!0,login:p="enable",...v})=>{return{serverURL:oe(e),path:Q(t),lang:n,locale:{...J[n]||J["zh-CN"],..."object"==typeof o?o:{}},emoji:(g=l,Promise.all(g.map((e=>"string"==typeof e?te(X(e)):Promise.resolve(e)))).then((e=>{const t={tabs:[],map:{}};return e.forEach((e=>{const{name:n,folder:o,icon:l,prefix:r,type:i,items:a}=e;t.tabs.push({name:n,icon:ne(l,o,r,i),items:a.map((e=>{const n=`${r||""}${e}`;return t.map[n]=ne(e,o,r,i),n}))})})),t}))),wordLimit:Array.isArray(s)?s:!!s&&[0,s],meta:M(r),requiredMeta:M(i),pageSize:a,login:p,imageUploader:le(c,P),highlighter:le(m,z),texRenderer:le(u,T),copyright:d,...v};var g})(e))),{userInfo:o}=$e(),l=t("loading"),r=t(0),c=t(1),m=t(0),u=t([]),d=t(null),p=i((()=>{return"string"==typeof(e=n.value.dark)?"auto"===e?`@media(prefers-color-scheme:dark){body${re}}`:`${e}${re}`:!0===e?`:root${re}`:"";var e}));let v,g;const h=e=>{var t;const{serverURL:i,path:a,pageSize:s}=n.value,d=new AbortController;l.value="loading",null==v||v(),(({serverURL:e,path:t,page:n,pageSize:o,signal:l,token:r})=>{const i={};return r&&(i.Authorization=`Bearer ${r}`),fetch(`${e}/comment?path=${encodeURIComponent(t)}&pageSize=${o}&page=${n}`,{signal:l,headers:i}).then((e=>e.json())).then((e=>ce(e,"comment list")))})({serverURL:i,path:a,pageSize:s,page:e,signal:d.signal,token:null===(t=o.value)||void 0===t?void 0:t.token}).then((t=>{l.value="success",r.value=t.count,u.value.push(...t.data),c.value=e,m.value=t.totalPages})).catch((e=>{"AbortError"!==e.name&&(console.error(e.message),l.value="error")})),v=d.abort.bind(d)},f=()=>{r.value=0,u.value=[],h(1)};return R("config",n),a((()=>e.path),f),s((()=>{var e;f();const t=document.createElement("style");t.innerText=p.value,null===(e=document.querySelector("[data-waline]"))||void 0===e||e.appendChild(t),g=S((()=>{t.innerText=p.value}))})),j((()=>g())),{config:n,darkmodeStyle:p,i18n:i((()=>n.value.locale)),status:l,count:r,page:c,totalPages:m,data:u,reply:d,loadMore:()=>h(c.value+1),refresh:f,onReply:e=>{d.value=e},onSubmit:e=>{if(e.rid){const t=u.value.find((({objectId:t})=>t===e.rid));if(!t)return;Array.isArray(t.children)||(t.children=[]),t.children.push(e)}else u.value.unshift(e)},version:"2.0.1"}}});const $t={"data-waline":""},It={class:"wl-count"},Lt=["textContent"],Rt={class:"wl-cards"},St={key:1,class:"wl-action"},jt=["textContent"],xt={key:0,class:"wl-loading"},Ut=["textContent"],Et={class:"wl-more"},zt=["textContent"],At={key:3,class:"wl-power"},Mt=I(" Powered by "),Nt=p("a",{href:"https://github.com/walinejs/waline",target:"_blank",rel:"noreferrer"}," Waline ",-1);Ct.render=function(e,t,n,o,l,r){const i=m("CommentBox"),a=m("CommentCard"),s=m("LoadingIcon");return u(),d("div",$t,[e.reply?h("v-if",!0):(u(),L(i,{key:0,onSubmit:e.onSubmit},null,8,["onSubmit"])),p("div",It,[e.count?(u(),d("span",{key:0,class:"wl-num",textContent:g(e.count)},null,8,Lt)):h("v-if",!0),I(" "+g(e.i18n.comment),1)]),p("div",Rt,[(u(!0),d(y,null,w(e.data,(t=>(u(),L(a,{key:t.objectId,"root-id":t.objectId,comment:t,reply:e.reply,onReply:e.onReply,onSubmit:e.onSubmit},null,8,["root-id","comment","reply","onReply","onSubmit"])))),128))]),"error"===e.status?(u(),d("div",St,[p("button",{type:"button",class:"wl-btn",onClick:t[0]||(t[0]=(...t)=>e.refresh&&e.refresh(...t)),textContent:g(e.i18n.refresh)},null,8,jt)])):(u(),d(y,{key:2},["loading"===e.status?(u(),d("div",xt,[v(s,{size:30})])):e.data.length?e.page<e.totalPages?(u(),d(y,{key:2},[h(" Load more button "),p("div",Et,[p("button",{type:"button",class:"wl-btn",onClick:t[1]||(t[1]=(...t)=>e.loadMore&&e.loadMore(...t)),textContent:g(e.i18n.more)},null,8,zt)])],2112)):h("v-if",!0):(u(),d("div",{key:1,class:"wl-empty",textContent:g(e.i18n.sofa)},null,8,Ut))],2112)),h(" Copyright Information "),e.config.copyright?(u(),d("div",At,[Mt,Nt,I(" v"+g(e.version),1)])):h("v-if",!0)])},Ct.__file="src/components/Waline.vue";const Pt=(e,t)=>{t.forEach(((t,n)=>{t.innerText=e[n].toString()}))},Tt=({serverURL:e,path:t=window.location.pathname,selector:n=".waline-pageview-count",update:o=!0})=>{const l=new AbortController,r=Array.from(document.querySelectorAll(n)),i=e=>{const n=ye(e);return null!==n&&t!==n},a=n=>me({serverURL:e,paths:n.map((e=>ye(e)||t)),signal:l.signal}).then((e=>Pt(e,n))).catch(se);if(o){const n=r.filter((e=>!i(e))),o=r.filter(i);ue({serverURL:e,path:t}).then((e=>Pt(new Array(n.length).fill(e),n))),o.length&&a(o)}else a(r);return l.abort.bind(l)},Ot=({el:t="#waline",path:n=window.location.pathname,comment:l=!1,pageview:r=!1,...i})=>{const a=t?de(t):null;if(t&&!a)throw new Error("Option 'el' do not match any domElement!");if(!i.serverURL)throw new Error("Option 'serverURL' is missing!");const s=e({...i}),c=e({comment:l,pageview:r,path:n}),m=()=>{c.comment&&Ie({serverURL:s.serverURL,path:c.path,selector:"string"==typeof c.comment?c.comment:void 0})},u=()=>{c.pageview&&Tt({serverURL:s.serverURL,path:c.path,selector:"string"==typeof c.pageview?c.pageview:void 0})},d=a?x((()=>o(Ct,{path:c.path,...s}))):null;d&&d.mount(a),m(),u();const p=S(m),v=S(u);return{el:a,update:({comment:e,pageview:t,path:n=window.location.pathname,...o})=>{Object.entries(o).map((([e,t])=>{s[e]=t})),c.path=n,void 0!==e&&(c.comment=e),void 0!==t&&(c.pageview=t)},destroy:()=>{null==d||d.unmount(),p(),v()}}},Bt="2.0.1",_t=({el:e,serverURL:t,count:n})=>{var o;const l=de(e),r=new AbortController;return(({serverURL:e,count:t,signal:n,token:o})=>{const l={};return o&&(l.Authorization=`Bearer ${o}`),fetch(`${e}/comment?type=recent&count=${t}`,{signal:n,headers:l}).then((e=>e.json())).then((e=>ce(e,"recent comment")))})({serverURL:t,count:n,signal:r.signal,token:null===(o=ke())||void 0===o?void 0:o.token}).then((e=>l&&e.length?(l.innerHTML=`<ul class="wl-recent-list">${e.map((e=>`<li class="wl-recent-item"><a href="${e.url}">${e.nick}</a>:${e.comment}</li>`)).join("")}</ul>`,{comments:e,destroy:()=>{r.abort(),l.innerHTML=""}}):{comments:e,destroy:()=>r.abort()}))};export{_t as RecentComments,Ie as commentCount,N as defaultLang,T as defaultTexRenderer,P as defaultUploadImage,M as getMeta,Ot as init,J as locales,Tt as pageviewCount,Bt as version};
2
2
  //# sourceMappingURL=shim.esm.js.map
package/dist/shim.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("vue"),t=require("autosize"),o=require("marked"),n=require("hanabi");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r=l(t),a=l(n);const i=["nick","mail","link"],c=e=>e.filter((e=>i.includes(e))),s=e=>new Promise(((t,o)=>{const n=new FileReader;n.readAsDataURL(e),n.onload=()=>{var e;return t((null===(e=n.result)||void 0===e?void 0:e.toString())||"")},n.onerror=o})),m=e=>!0===e?'<p class="vtex">Tex is not available in preview</p>':'<span class="vtex">Tex is not available in preview</span>',d=["nick","nickError","mail","mailError","link","optional","placeholder","sofa","submit","reply","cancelReply","comment","refresh","more","preview","emoji","uploadImage","seconds","minutes","hours","days","now","uploading","login","logout","admin","sticky","word","wordHint","anonymous"],u=e=>Object.fromEntries(e.map(((e,t)=>[d[t],e])));var p=u(["NickName","NickName cannot be less than 3 bytes.","E-Mail","Please confirm your email address.","Website","Optional","Comment here...","No comment yet.","Submit","Reply","Cancel reply","Comments","Refresh","Load More...","Preview","Emoji","Upload Image","seconds ago","minutes ago","hours ago","days ago","just now","Uploading","Login","logout","Admin","Sticky","Words","Please input comments between $0 and $1 words!\n Current word number: $2","Anonymous"]),g=u(["ニックネーム","3バイト以上のニックネームをご入力ください.","メールアドレス","メールアドレスをご確認ください.","サイト","オプション","ここにコメント","コメントしましょう~","提出する","返信する","キャンセル","コメント","更新","さらに読み込む","プレビュー","絵文字","画像をアップロード","秒前","分前","時間前","日前","たっだ今","アップロード","ログインする","ログアウト","管理者","トップに置く","ワード","コメントは $0 から $1 ワードの間でなければなりません!\n 現在の単語番号: $2","匿名"]),v=u(["昵称","昵称不能少于3个字符","邮箱","请填写正确的邮件地址","网址","可选","欢迎评论","来发评论吧~","提交","回复","取消回复","评论","刷新","加载更多...","预览","表情","上传图片","秒前","分钟前","小时前","天前","刚刚","正在上传","登录","退出","博主","置顶","字","评论字数应在 $0 到 $1 字之间!\n当前字数:$2","匿名"]),h=u(["暱稱","郵箱","網址","可選","暱稱不能少於3個字元","請填寫正確的郵件地址","歡迎評論","來發評論吧~","提交","回覆","取消回覆","評論","刷新","載入更多...","預覽","表情","上傳圖片","秒前","分鐘前","小時前","天前","剛剛","正在上傳","登錄","退出","博主","置頂","字","評論字數應在 $0 到 $1 字之間!\n當前字數:$2","匿名"]),f=u(["Apelido","Apelido não pode ser menor que 3 bytes.","E-Mail","Por favor, confirme seu endereço de e-mail.","Website","Opcional","Comente aqui...","Nenhum comentário, ainda.","Enviar","Responder","Cancelar resposta","Comentários","Refrescar","Carregar Mais...","Visualizar","Emoji","Enviar Imagem","segundos atrás","minutos atrás","horas atrás","dias atrás","agora mesmo","Enviando","Entrar","Sair","Admin","Sticky","Palavras","Favor enviar comentário com $0 a $1 palavras!\n Número de palavras atuais: $2","Anônimo"]),y=u(["Псевдоним","Никнейм не может быть меньше 3 байт.","Эл. адрес","Пожалуйста, подтвердите адрес вашей электронной почты.","Веб-сайт","Необязательный","Комментарий здесь...","Пока нет комментариев.","Отправить","Отвечать","Отменить ответ","Комментарии","Обновить","Загрузи больше...","Превью","эмодзи","Загрузить изображение","секунд назад","несколько минут назад","несколько часов назад","дней назад","прямо сейчас","Загрузка","Авторизоваться","Выход из системы","Админ","Липкий","Слова","Пожалуйста, введите комментарии от $0 до $1 слов!\nНомер текущего слова: $2","Анонимный"]);const k={zh:v,"zh-cn":v,"zh-CN":v,"zh-tw":h,"zh-TW":h,en:p,"en-US":p,"en-us":p,jp:g,"jp-jp":g,"jp-JP":g,"pt-br":f,"pt-BR":f,ru:y,"ru-ru":y,"ru-RU":y},w=e=>{let t={};const o=localStorage.getItem(e);if(o)try{t=JSON.parse(o)}catch(e){}return{get:e=>t[e]||null,set(o,n){try{t[o]=JSON.parse(JSON.stringify(n)),localStorage.setItem(e,JSON.stringify(t))}catch(e){}},update(o){t=JSON.parse(JSON.stringify(o)),localStorage.setItem(e,JSON.stringify(t))}}};let C,b;const E=()=>(b||(C=w("WALINE_USER_CACHE"),b=e.reactive({nick:C.get("nick")||"",mail:C.get("mail")||"",link:C.get("link")||"",editor:""})),{inputs:b,store:C}),N=e=>{try{e=decodeURI(e)}catch(e){}return e},B=(e="")=>e.replace(/\/$/u,""),$=e=>/^(https?:)?\/\//.test(e);let S;const L=e=>{S||(S=w("WALINE_EMOJI"));const t=Boolean(/@[0-9]+\.[0-9]+\.[0-9]+/.test(e));if(t){const t=S.get(e);if(t)return Promise.resolve(t)}return fetch(`${e}/info.json`).then((e=>e.json())).then((o=>{const n={folder:e,...o};return t&&S.set(e,n),n}))},x=(e,t="",o="",n="")=>`${t?`${t}/`:""}${o}${e}${n?`.${n}`:""}`,I=e=>{const t=B(e);return $(t)?t:`https://${t}`},V=(e,t)=>"function"==typeof e?e:!1!==e&&t,R="{--waline-white:#000;--waline-light-grey:#666;--waline-dark-grey:#999;--waline-color:#888;--waline-bgcolor:#1e1e1e;--waline-bgcolor-light:#272727;--waline-bgcolor-hover: #444;--waline-border-color:#333;--waline-disable-bgcolor:#444;--waline-disable-color:#272727;--waline-bq-color:#272727;--waline-info-bgcolor:#272727;--waline-info-color:#666}",j=e=>e.type.includes("image"),U=e=>{const t=Array.from(e).find(j);return t?t.getAsFile():null},z=e=>{"AbortError"!==e.name&&console.error(e.message)},A=(e,t="")=>{if("object"==typeof e&&e.errno)throw new TypeError(`Fetch ${t} failed with ${e.errno}: ${e.errmsg}`);return e},M=({serverURL:e,paths:t,signal:o})=>fetch(`${e}/article?path=${encodeURIComponent(t.join(","))}`,{signal:o}).then((e=>e.json())).then((e=>A(e,"visit count"))).then((e=>Array.isArray(e)?e:[e])),T=({serverURL:e,path:t})=>fetch(`${e}/article`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:t})}).then((e=>e.json())).then((e=>A(e,"visit count"))),D=e=>e instanceof HTMLElement?e:"string"==typeof e?document.querySelector(e):null,P=/\$.*?\$/,O=/^\$(.*?)\$/,_=/^(?:\s{0,3})\$\$((?:[^\n]|\n[^\n])+?)\n{0,1}\$\$/,q=(e="",t={})=>e.replace(/:(.+?):/g,((e,o)=>t[o]?`<img class="vemoji" src="${t[o]}" alt="${o}">`:e)),H=(e,{emojiMap:t,highlighter:n,texRenderer:l})=>{if(o.marked.setOptions({highlight:n||void 0,breaks:!0,smartLists:!0,smartypants:!0}),l){const e=(e=>[{name:"blockMath",level:"block",tokenizer(t){const o=_.exec(t);if(null!==o)return{type:"html",raw:o[0],text:e(!0,o[1])}}},{name:"inlineMath",level:"inline",start(e){const t=e.search(P);return-1!==t?t:e.length},tokenizer(t){const o=O.exec(t);if(null!==o)return{type:"html",raw:o[0],text:e(!1,o[1])}}}])(l);o.marked.use({extensions:e})}return o.marked.parse(q(e,t))},W=e=>e.dataset.path||e.getAttribute("id"),F=(e,t)=>{let o=e.toString();for(;o.length<t;)o="0"+o;return o},J=(e,t)=>{if(e)try{"string"==typeof e&&(e=new Date(-1!==e.indexOf(" ")?e.replace(/-/g,"/"):e));const o=e.getTime(),n=(new Date).getTime()-o,l=Math.floor(n/864e5);if(0===l){const e=n%864e5,o=Math.floor(e/36e5);if(0===o){const o=e%36e5,n=Math.floor(o/6e4);if(0===n){const e=o%6e4;return`${Math.round(e/1e3)} ${t.seconds}`}return`${n} ${t.minutes}`}return`${o} ${t.hours}`}return l<0?t.now:l<8?`${l} ${t.days}`:(e=>{const t=F(e.getDate(),2),o=F(e.getMonth()+1,2);return`${F(e.getFullYear(),2)}-${o}-${t}`})(e)}catch(e){console.log(e)}return""},K=()=>{try{const e=localStorage.getItem("WALINE_USER"),t=sessionStorage.getItem("WALINE_USER");return e?JSON.parse(e):t?JSON.parse(t):null}catch(e){return null}},Y=e.ref({}),G=()=>{if(!Y.value.token){const e=K();e&&(Y.value=e)}return{userInfo:e.readonly(Y),setUserInfo:e=>{Y.value=e}}},Q=({serverURL:e,path:t=window.location.pathname,selector:o=".waline-comment-count"})=>{var n;const l=new AbortController,r=document.querySelectorAll(o),{userInfo:a}=G();return r.length&&(({serverURL:e,paths:t,signal:o,token:n})=>{const l={};return n&&(l.Authorization=`Bearer ${n}`),fetch(`${e}/comment?type=count&url=${encodeURIComponent(t.join(","))}`,{signal:o,headers:l}).then((e=>e.json())).then((e=>A(e,"comment count"))).then((e=>Array.isArray(e)?e:[e]))})({serverURL:e,paths:Array.from(r).map((e=>N(e.dataset.path||e.getAttribute("id")||t))),signal:l.signal,token:null===(n=a.value)||void 0===n?void 0:n.token}).then((e=>{r.forEach(((t,o)=>{t.innerText=e[o].toString()}))})).catch(z),l.abort.bind(l)},X=({size:t})=>e.h("svg",{width:t,height:t,viewBox:"0 0 100 100",preserveAspectRatio:"xMidYMid"},e.h("circle",{cx:50,cy:50,fill:"none",stroke:"currentColor",strokeWidth:"4",r:"40","stroke-dasharray":"85 30"},e.h("animateTransform",{attributeName:"transform",type:"rotate",repeatCount:"indefinite",dur:"1s",values:"0 50 50;360 50 50",keyTimes:"0;1"})));var Z=e.defineComponent({name:"CommentBox",components:{CloseIcon:({size:t})=>e.h("svg",{class:"wl-close-icon",viewBox:"0 0 1024 1024",width:t,height:t},[e.h("path",{d:"M697.173 85.333h-369.92c-144.64 0-241.92 101.547-241.92 252.587v348.587c0 150.613 97.28 252.16 241.92 252.16h369.92c144.64 0 241.494-101.547 241.494-252.16V337.92c0-151.04-96.854-252.587-241.494-252.587z",fill:"currentColor"}),e.h("path",{d:"m640.683 587.52-75.947-75.861 75.904-75.862a37.29 37.29 0 0 0 0-52.778 37.205 37.205 0 0 0-52.779 0l-75.946 75.818-75.862-75.946a37.419 37.419 0 0 0-52.821 0 37.419 37.419 0 0 0 0 52.821l75.947 75.947-75.776 75.733a37.29 37.29 0 1 0 52.778 52.821l75.776-75.776 75.947 75.947a37.376 37.376 0 0 0 52.779-52.821z",fill:"#888"})]),EmojiIcon:()=>e.h("svg",{viewBox:"0 0 1024 1024",width:"24",height:"24"},e.h("path",{d:"M563.2 463.3 677 540c1.7 1.2 3.7 1.8 5.8 1.8.7 0 1.4-.1 2-.2 2.7-.5 5.1-2.1 6.6-4.4l25.3-37.8c1.5-2.3 2.1-5.1 1.6-7.8s-2.1-5.1-4.4-6.6l-73.6-49.1 73.6-49.1c2.3-1.5 3.9-3.9 4.4-6.6.5-2.7 0-5.5-1.6-7.8l-25.3-37.8a10.1 10.1 0 0 0-6.6-4.4c-.7-.1-1.3-.2-2-.2-2.1 0-4.1.6-5.8 1.8l-113.8 76.6c-9.2 6.2-14.7 16.4-14.7 27.5.1 11 5.5 21.3 14.7 27.4zM387 348.8h-45.5c-5.7 0-10.4 4.7-10.4 10.4v153.3c0 5.7 4.7 10.4 10.4 10.4H387c5.7 0 10.4-4.7 10.4-10.4V359.2c0-5.7-4.7-10.4-10.4-10.4zm333.8 241.3-41-20a10.3 10.3 0 0 0-8.1-.5c-2.6.9-4.8 2.9-5.9 5.4-30.1 64.9-93.1 109.1-164.4 115.2-5.7.5-9.9 5.5-9.5 11.2l3.9 45.5c.5 5.3 5 9.5 10.3 9.5h.9c94.8-8 178.5-66.5 218.6-152.7 2.4-5 .3-11.2-4.8-13.6zm186-186.1c-11.9-42-30.5-81.4-55.2-117.1-24.1-34.9-53.5-65.6-87.5-91.2-33.9-25.6-71.5-45.5-111.6-59.2-41.2-14-84.1-21.1-127.8-21.1h-1.2c-75.4 0-148.8 21.4-212.5 61.7-63.7 40.3-114.3 97.6-146.5 165.8-32.2 68.1-44.3 143.6-35.1 218.4 9.3 74.8 39.4 145 87.3 203.3.1.2.3.3.4.5l36.2 38.4c1.1 1.2 2.5 2.1 3.9 2.6 73.3 66.7 168.2 103.5 267.5 103.5 73.3 0 145.2-20.3 207.7-58.7 37.3-22.9 70.3-51.5 98.1-85 27.1-32.7 48.7-69.5 64.2-109.1 15.5-39.7 24.4-81.3 26.6-123.8 2.4-43.6-2.5-87-14.5-129zm-60.5 181.1c-8.3 37-22.8 72-43 104-19.7 31.1-44.3 58.6-73.1 81.7-28.8 23.1-61 41-95.7 53.4-35.6 12.7-72.9 19.1-110.9 19.1-82.6 0-161.7-30.6-222.8-86.2l-34.1-35.8c-23.9-29.3-42.4-62.2-55.1-97.7-12.4-34.7-18.8-71-19.2-107.9-.4-36.9 5.4-73.3 17.1-108.2 12-35.8 30-69.2 53.4-99.1 31.7-40.4 71.1-72 117.2-94.1 44.5-21.3 94-32.6 143.4-32.6 49.3 0 97 10.8 141.8 32 34.3 16.3 65.3 38.1 92 64.8 26.1 26 47.5 56 63.6 89.2 16.2 33.2 26.6 68.5 31 105.1 4.6 37.5 2.7 75.3-5.6 112.3z",fill:"currentColor"})),ImageIcon:()=>e.h("svg",{viewBox:"0 0 1024 1024",width:"24",height:"24"},[e.h("path",{d:"M784 112H240c-88 0-160 72-160 160v480c0 88 72 160 160 160h544c88 0 160-72 160-160V272c0-88-72-160-160-160zm96 640c0 52.8-43.2 96-96 96H240c-52.8 0-96-43.2-96-96V272c0-52.8 43.2-96 96-96h544c52.8 0 96 43.2 96 96v480z",fill:"currentColor"}),e.h("path",{d:"M352 480c52.8 0 96-43.2 96-96s-43.2-96-96-96-96 43.2-96 96 43.2 96 96 96zm0-128c17.6 0 32 14.4 32 32s-14.4 32-32 32-32-14.4-32-32 14.4-32 32-32zm462.4 379.2-3.2-3.2-177.6-177.6c-25.6-25.6-65.6-25.6-91.2 0l-80 80-36.8-36.8c-25.6-25.6-65.6-25.6-91.2 0L200 728c-4.8 6.4-8 14.4-8 24 0 17.6 14.4 32 32 32 9.6 0 16-3.2 22.4-9.6L380.8 640l134.4 134.4c6.4 6.4 14.4 9.6 24 9.6 17.6 0 32-14.4 32-32 0-9.6-4.8-17.6-9.6-24l-52.8-52.8 80-80L769.6 776c6.4 4.8 12.8 8 20.8 8 17.6 0 32-14.4 32-32 0-8-3.2-16-8-20.8z",fill:"currentColor"})]),MarkdownIcon:()=>e.h("svg",{width:"16",height:"16",ariaHidden:"true"},e.h("path",{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",fill:"currentColor"})),PreviewIcon:()=>e.h("svg",{viewBox:"0 0 1024 1024",width:"24",height:"24"},[e.h("path",{d:"M710.816 654.301c70.323-96.639 61.084-230.578-23.705-314.843-46.098-46.098-107.183-71.109-172.28-71.109-65.008 0-126.092 25.444-172.28 71.109-45.227 46.098-70.756 107.183-70.756 172.106 0 64.923 25.444 126.007 71.194 172.106 46.099 46.098 107.184 71.109 172.28 71.109 51.414 0 100.648-16.212 142.824-47.404l126.53 126.006c7.058 7.06 16.297 10.979 26.406 10.979 10.105 0 19.343-3.919 26.402-10.979 14.467-14.467 14.467-38.172 0-52.723L710.816 654.301zm-315.107-23.265c-65.88-65.88-65.88-172.54 0-238.42 32.069-32.07 74.245-49.149 119.471-49.149 45.227 0 87.407 17.603 119.472 49.149 65.88 65.879 65.88 172.539 0 238.42-63.612 63.178-175.242 63.178-238.943 0zm0 0",fill:"currentColor"}),e.h("path",{d:"M703.319 121.603H321.03c-109.8 0-199.469 89.146-199.469 199.38v382.034c0 109.796 89.236 199.38 199.469 199.38h207.397c20.653 0 37.384-16.645 37.384-37.299 0-20.649-16.731-37.296-37.384-37.296H321.03c-68.582 0-124.352-55.77-124.352-124.267V321.421c0-68.496 55.77-124.267 124.352-124.267h382.289c68.582 0 124.352 55.771 124.352 124.267V524.72c0 20.654 16.736 37.299 37.385 37.299 20.654 0 37.384-16.645 37.384-37.299V320.549c-.085-109.8-89.321-198.946-199.121-198.946zm0 0",fill:"currentColor"})]),LoadingIcon:X},props:{rootId:{type:String,default:""},replyId:{type:String,default:""},replyUser:{type:String,default:""}},emits:["submit","cancel-reply"],setup(t,{emit:o}){const n=e.inject("config"),{inputs:l,store:a}=E(),{userInfo:i,setUserInfo:c}=G(),s=e.ref({}),m=e.ref(null),d=e.ref(null),u=e.ref(null),p=e.ref(null),g=e.ref({tabs:[],map:{}}),v=e.ref(0),h=e.ref(!1),f=e.ref(!1),y=e.ref(""),k=e.ref(0),w=e.ref(0),C=e.ref(!1),b=e.ref(""),N=e.ref(!1),B=e.computed((()=>n.value.locale)),$=e.computed((()=>{var e;return Boolean(null===(e=i.value)||void 0===e?void 0:e.token)})),S=e.computed((()=>!1!==n.value.imageUploader)),L=e=>{const t=m.value,o=t.selectionStart,n=t.selectionEnd||0,r=t.scrollTop;l.editor=t.value.substring(0,o)+e+t.value.substring(n,t.value.length),t.focus(),t.selectionStart=o+e.length,t.selectionEnd=o+e.length,t.scrollTop=r},x=e=>{const t=`![${n.value.locale.uploading} ${e.name}]()`;return L(t),Promise.resolve().then((()=>n.value.imageUploader(e))).then((o=>{l.editor=l.editor.replace(t,`\r\n![${e.name}](${o})`)}))},I=()=>{var e,r,c,d,u;const{serverURL:p,lang:v,login:h,wordLimit:f,requiredMeta:w}=n.value,E={comment:b.value,nick:l.nick,mail:l.mail,link:l.link,ua:navigator.userAgent,url:n.value.path};if(null===(e=i.value)||void 0===e?void 0:e.token)E.nick=i.value.display_name,E.mail=i.value.email,E.link=i.value.url;else{if("force"===h)return;if((w.indexOf("nick")>-1||E.nick)&&!E.nick)return null===(r=s.value.nick)||void 0===r||r.focus(),alert(B.value.nickError);if(w.indexOf("mail")>-1&&!E.mail)return null===(c=s.value.mail)||void 0===c||c.focus(),alert(B.value.mailError);if(!E.comment)return void(null===(d=m.value)||void 0===d||d.focus());E.nick||(E.nick=B.value.anonymous)}if(!C.value)return alert(B.value.wordHint.replace("$0",f[0].toString()).replace("$1",f[1].toString()).replace("$2",k.value.toString()));E.comment=q(E.comment,g.value.map),t.replyId&&t.rootId&&(E.pid=t.replyId,E.rid=t.rootId,E.at=t.replyUser),N.value=!0,(({serverURL:e,lang:t,token:o,comment:n})=>{const l={"Content-Type":"application/json"};return o&&(l.Authorization=`Bearer ${o}`),fetch(`${e}/comment?lang=${t}`,{method:"POST",headers:l,body:JSON.stringify(n)}).then((e=>e.json()))})({serverURL:p,lang:v,token:null===(u=i.value)||void 0===u?void 0:u.token,comment:E}).then((e=>{if(N.value=!1,a.update({nick:E.nick,link:E.link,mail:E.mail}),e.errmsg)return alert(e.errmsg);o("submit",e.data),l.editor="",y.value="",t.replyId&&o("cancel-reply")})).catch((e=>{N.value=!1,alert(e.message)}))},V=e=>{u.value.contains(e.target)||p.value.contains(e.target)||(h.value=!1)};return e.watch((()=>l.editor),(e=>{const{highlighter:t,texRenderer:o}=n.value;b.value=e,y.value=H(e,{emojiMap:g.value.map,highlighter:t,texRenderer:o}),k.value=(e=>(e=>e.match(/[\w\d\s\u00C0-\u024F]+/giu)||[])(e).reduce(((e,t)=>e+(""===t.trim()?0:t.trim().split(/\s+/u).length)),0)+(e=>e.match(/[\u4E00-\u9FA5]/gu)||[])(e).length)(e),m.value&&(e?r.default(m.value):r.default.destroy(m.value))}),{immediate:!0}),e.watch((()=>n.value.emoji),(e=>e.then((e=>{g.value=e}))),{immediate:!0}),e.watch([n,k],(([e,t])=>{const{wordLimit:o}=e;o?t<o[0]&&0!==o[0]?(w.value=o[0],C.value=!1):t>o[1]?(w.value=o[1],C.value=!1):(w.value=o[1],C.value=!0):(w.value=0,C.value=!0)}),{immediate:!0}),e.onMounted((()=>{document.body.addEventListener("click",V)})),e.onUnmounted((()=>{document.body.removeEventListener("click",V)})),{config:n,locale:B,insert:L,onChange:()=>{const e=d.value;e.files&&S.value&&x(e.files[0]).then((()=>{e.value=""}))},onDrop:e=>{var t;if(null===(t=e.dataTransfer)||void 0===t?void 0:t.items){const t=U(e.dataTransfer.items);t&&S.value&&(x(t),e.preventDefault())}},onKeyDown:e=>{const t=e.key;(e.ctrlKey||e.metaKey)&&"Enter"===t&&I()},onPaste:e=>{if(e.clipboardData){const t=U(e.clipboardData.items);t&&S.value&&x(t)}},onLogin:e=>{e.preventDefault();const{lang:t,serverURL:o}=n.value,l=(window.innerWidth-450)/2,r=(window.innerHeight-450)/2,a=window.open(`${o}/ui/login?lng=${encodeURIComponent(t)}`,"_blank",`width=450,height=450,left=${l},top=${r},scrollbars=no,resizable=no,status=no,location=no,toolbar=no,menubar=no`);null==a||a.postMessage({type:"TOKEN",data:null},"*");const i=({data:e})=>{e&&"userInfo"===e.type&&e.data.token&&(null==a||a.close(),c(e.data),(e.data.remember?localStorage:sessionStorage).setItem("WALINE_USER",JSON.stringify(e.data)),window.removeEventListener("message",i))};window.addEventListener("message",i)},onLogout:()=>{c({}),localStorage.setItem("WALINE_USER","null"),sessionStorage.setItem("WALINE_USER","null")},onProfile:e=>{e.preventDefault();const{lang:t,serverURL:o}=n.value,l=(window.innerWidth-800)/2,r=(window.innerHeight-800)/2,a=window.open(`${o}/ui/profile?lng=${encodeURIComponent(t)}`,"_blank",`width=800,height=800,left=${l},top=${r},scrollbars=no,resizable=no,status=no,location=no,toolbar=no,menubar=no`);null==a||a.postMessage({type:"TOKEN",data:i.value.token},"*");const s=({data:e})=>{e&&"profile"===e.type&&(c(Object.assign({},i.value,e)),[localStorage,sessionStorage].filter((e=>e.getItem("WALINE_USER"))).forEach((e=>e.setItem("WALINE_USER",JSON.stringify(i)))),window.removeEventListener("message",s))};window.addEventListener("message",s)},submitComment:I,isLogin:$,userInfo:i,isSubmitting:N,wordNumber:k,wordLimit:w,isWordNumberLegal:C,inputs:l,emoji:g,emojiTabIndex:v,showEmoji:h,canUploadImage:S,previewText:y,showPreview:f,inputRefs:s,editorRef:m,emojiButtonRef:u,emojiPopupRef:p,imageUploadRef:d}}});const ee={class:"wl-comment"},te={key:0,class:"wl-login-info"},oe={class:"wl-avatar"},ne=["title"],le=["src"],re=["textContent"],ae={class:"wl-panel"},ie=["for","textContent"],ce=["id","name","type","onUpdate:modelValue"],se=["placeholder"],me=["innerHTML"],de={class:"wl-footer"},ue={class:"wl-actions"},pe={href:"https://guides.github.com/features/mastering-markdown/",title:"Markdown Guide","aria-label":"Markdown is supported",class:"wl-action",target:"_blank",rel:"noreferrer"},ge=["title"],ve=["title"],he=["title"],fe={class:"wl-info"},ye={class:"wl-text-number"},ke={key:0},we=e.createTextVNode("  /  "),Ce=["textContent"],be=["textContent"],Ee=["disabled"],Ne={key:0,class:"wl-tab-wrapper"},Be=["title","onClick"],$e=["src","alt"],Se={key:0,class:"wl-tabs"},Le=["onClick"],xe=["src","alt","title"],Ie=["title"];Z.render=function(t,o,n,l,r,a){const i=e.resolveComponent("CloseIcon"),c=e.resolveComponent("MarkdownIcon"),s=e.resolveComponent("EmojiIcon"),m=e.resolveComponent("ImageIcon"),d=e.resolveComponent("PreviewIcon"),u=e.resolveComponent("LoadingIcon");return e.openBlock(),e.createElementBlock("div",ee,["disable"!==t.config.login&&t.isLogin?(e.openBlock(),e.createElementBlock("div",te,[e.createElementVNode("div",oe,[e.createElementVNode("button",{class:"wl-logout-btn",title:t.locale.logout,onClick:o[0]||(o[0]=(...e)=>t.onLogout&&t.onLogout(...e))},[e.createVNode(i,{size:14})],8,ne),e.createElementVNode("img",{src:t.userInfo.avatar,alt:"avatar"},null,8,le)]),e.createElementVNode("a",{href:"#",class:"wl-login-nick","aria-label":"Profile",onClick:o[1]||(o[1]=(...e)=>t.onProfile&&t.onProfile(...e)),textContent:e.toDisplayString(t.userInfo.display_name)},null,8,re)])):e.createCommentVNode("v-if",!0),e.createElementVNode("div",ae,["force"!==t.config.login&&t.config.meta.length&&!t.isLogin?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["wl-header",`item${t.config.meta.length}`])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.config.meta,(o=>(e.openBlock(),e.createElementBlock("div",{class:"wl-header-item",key:o},[e.createElementVNode("label",{for:o,textContent:e.toDisplayString(t.locale[o]+(t.config.requiredMeta.includes(o)||!t.config.requiredMeta.length?"":`(${t.locale.optional})`))},null,8,ie),e.withDirectives(e.createElementVNode("input",{ref_for:!0,ref:e=>{e&&(t.inputRefs[o]=e)},id:`wl-${o}`,class:e.normalizeClass(["wl-input",`wl-${o}`]),name:o,type:"mail"===o?"email":"text","onUpdate:modelValue":e=>t.inputs[o]=e},null,10,ce),[[e.vModelDynamic,t.inputs[o]]])])))),128))],2)):e.createCommentVNode("v-if",!0),e.withDirectives(e.createElementVNode("textarea",{class:"wl-editor",ref:"editorRef",id:"wl-edit",placeholder:t.replyUser?`@${t.replyUser}`:t.locale.placeholder,"onUpdate:modelValue":o[2]||(o[2]=e=>t.inputs.editor=e),onKeydown:o[3]||(o[3]=(...e)=>t.onKeyDown&&t.onKeyDown(...e)),onDrop:o[4]||(o[4]=(...e)=>t.onDrop&&t.onDrop(...e)),onPaste:o[5]||(o[5]=(...e)=>t.onPaste&&t.onPaste(...e))},null,40,se),[[e.vModelText,t.inputs.editor]]),e.createElementVNode("div",{class:"wl-preview",style:e.normalizeStyle({display:t.showPreview?"block":"none"})},[e.createElementVNode("h4",null,e.toDisplayString(t.locale.preview)+":",1),e.createElementVNode("div",{class:"wl-content",innerHTML:t.previewText},null,8,me)],4),e.createElementVNode("div",de,[e.createElementVNode("div",ue,[e.createElementVNode("a",pe,[e.createVNode(c)]),e.createElementVNode("button",{ref:"emojiButtonRef",class:e.normalizeClass(["wl-action",{actived:t.showEmoji}]),title:t.locale.emoji,onClick:o[6]||(o[6]=e=>t.showEmoji=!t.showEmoji)},[e.createVNode(s)],10,ge),e.createElementVNode("input",{ref:"imageUploadRef",class:"upload",id:"wl-image-upload",type:"file",accept:".png,.jpg,.jpeg,.webp,.bmp,.gif",onChange:o[7]||(o[7]=(...e)=>t.onChange&&t.onChange(...e))},null,544),t.canUploadImage?(e.openBlock(),e.createElementBlock("label",{key:0,for:"wl-image-upload",class:"wl-action",title:t.locale.uploadImage},[e.createVNode(m)],8,ve)):e.createCommentVNode("v-if",!0),e.createElementVNode("button",{class:e.normalizeClass(["wl-action",{actived:t.showPreview}]),title:t.locale.preview,onClick:o[8]||(o[8]=e=>t.showPreview=!t.showPreview)},[e.createVNode(d)],10,he)]),e.createElementVNode("div",fe,[e.createElementVNode("div",ye,[e.createTextVNode(e.toDisplayString(t.wordNumber)+" ",1),t.config.wordLimit?(e.openBlock(),e.createElementBlock("span",ke,[we,e.createElementVNode("span",{class:e.normalizeClass({illegal:!t.isWordNumberLegal}),textContent:e.toDisplayString(t.wordLimit)},null,10,Ce)])):e.createCommentVNode("v-if",!0),e.createTextVNode("  "+e.toDisplayString(t.locale.word),1)]),"disable"===t.config.login||t.isLogin?e.createCommentVNode("v-if",!0):(e.openBlock(),e.createElementBlock("button",{key:0,class:"wl-btn",onClick:o[9]||(o[9]=(...e)=>t.onLogin&&t.onLogin(...e)),textContent:e.toDisplayString(t.locale.login)},null,8,be)),"force"!==t.config.login||t.isLogin?(e.openBlock(),e.createElementBlock("button",{key:1,class:"wl-btn primary",title:"Cmd|Ctrl + Enter",disabled:t.isSubmitting,onClick:o[10]||(o[10]=(...e)=>t.submitComment&&t.submitComment(...e))},[t.isSubmitting?(e.openBlock(),e.createBlock(u,{key:0,size:16})):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createTextVNode(e.toDisplayString(t.locale.submit),1)],2112))],8,Ee)):e.createCommentVNode("v-if",!0)]),e.createElementVNode("div",{ref:"emojiPopupRef",class:e.normalizeClass(["wl-emoji-popup",{display:t.showEmoji}])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.emoji.tabs,((o,n)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:o.name},[n===t.emojiTabIndex?(e.openBlock(),e.createElementBlock("div",Ne,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.items,(o=>(e.openBlock(),e.createElementBlock("button",{key:o,title:o,onClick:e=>t.insert(`:${o}:`)},[t.showEmoji?(e.openBlock(),e.createElementBlock("img",{key:0,class:"wl-emoji",src:t.emoji.map[o],alt:o,loading:"lazy",referrerPolicy:"no-referrer"},null,8,$e)):e.createCommentVNode("v-if",!0)],8,Be)))),128))])):e.createCommentVNode("v-if",!0)],64)))),128)),t.emoji.tabs.length>1?(e.openBlock(),e.createElementBlock("div",Se,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.emoji.tabs,((o,n)=>(e.openBlock(),e.createElementBlock("button",{key:o.name,class:e.normalizeClass(["wl-tab",{active:t.emojiTabIndex===n}]),onClick:e=>t.emojiTabIndex=n},[e.createElementVNode("img",{class:"wl-emoji",src:o.icon,alt:o.name,title:o.name,loading:"lazy",referrerPolicy:"no-referrer"},null,8,xe)],10,Le)))),128))])):e.createCommentVNode("v-if",!0)],2)])]),t.replyId?(e.openBlock(),e.createElementBlock("button",{key:1,class:"wl-close",title:t.locale.cancelReply,onClick:o[11]||(o[11]=e=>t.$emit("cancel-reply"))},[e.createVNode(i,{size:24})],8,Ie)):e.createCommentVNode("v-if",!0)])},Z.__file="src/components/CommentBox.vue";var Ve=e.defineComponent({props:{comment:{type:Object,required:!0},rootId:{type:String,required:!0},reply:{type:Object}},components:{CommentBox:Z,ReplyIcon:()=>e.h("svg",{viewBox:"0 0 1024 1024",width:"18",height:"18"},e.h("path",{d:"M1019.2 720C1001.6 625.6 968 566.4 904 497.6c-89.6-89.6-214.4-150.4-347.2-176v-120c0-25.6-8-51.2-25.6-64-33.6-30.4-81.6-30.4-112-4.8L33.6 441.6C12.8 459.2 0 484.8 0 510.4c0 25.6 12.8 51.2 30.4 68.8l385.6 312c17.6 12.8 33.6 17.6 51.2 17.6 12.8 0 25.6-4.8 38.4-8C536 888 552 857.6 552 824v-99.2c124.8 20.8 248 86.4 339.2 140.8 25.6 17.6 59.2 17.6 89.6 0 25.6-17.6 43.2-46.4 43.2-76.8 0-33.6 0-56-4.8-68.8zm-500.8-89.6-46.4-4.8v193.6L86.4 510.4 472 201.6V400l38.4 4.8c128 12.8 248 68.8 334.4 153.6 51.2 56 76.8 102.4 94.4 179.2 0 4.8 4.8 20.8 4.8 51.2C835.2 720 672 640 518.4 630.4z",fill:"currentColor"})),VerifiedIcon:()=>e.h("svg",{class:"verified-icon",viewBox:"0 0 1024 1024",width:"14",height:"14"},e.h("path",{d:"m894.4 461.56-54.4-63.2c-10.4-12-18.8-34.4-18.8-50.4v-68c0-42.4-34.8-77.2-77.2-77.2h-68c-15.6 0-38.4-8.4-50.4-18.8l-63.2-54.4c-27.6-23.6-72.8-23.6-100.8 0l-62.8 54.8c-12 10-34.8 18.4-50.4 18.4h-69.2c-42.4 0-77.2 34.8-77.2 77.2v68.4c0 15.6-8.4 38-18.4 50l-54 63.6c-23.2 27.6-23.2 72.4 0 100l54 63.6c10 12 18.4 34.4 18.4 50v68.4c0 42.4 34.8 77.2 77.2 77.2h69.2c15.6 0 38.4 8.4 50.4 18.8l63.2 54.4c27.6 23.6 72.8 23.6 100.8 0l63.2-54.4c12-10.4 34.4-18.8 50.4-18.8h68c42.4 0 77.2-34.8 77.2-77.2v-68c0-15.6 8.4-38.4 18.8-50.4l54.4-63.2c23.2-27.6 23.2-73.2-.4-100.8zm-216-25.2-193.2 193.2a30 30 0 0 1-42.4 0l-96.8-96.8a30.16 30.16 0 0 1 0-42.4c11.6-11.6 30.8-11.6 42.4 0l75.6 75.6 172-172c11.6-11.6 30.8-11.6 42.4 0 11.6 11.6 11.6 30.8 0 42.4z",fill:"#27ae60"}))},emits:["submit","reply"],setup(t){const o=e.inject("config"),n=e.computed((()=>o.value.locale)),l=e.computed((()=>{let{link:e}=t.comment;return e?$(e)?e:`https://${e}`:""})),r=e.computed((()=>{var e;return t.comment.objectId===(null===(e=t.reply)||void 0===e?void 0:e.objectId)}));return{config:o,locale:n,isReplyingCurrent:r,link:l,timeAgo:J}}});const Re=["id"],je={class:"wl-user","aria-hidden":"true"},Ue=["src"],ze={class:"wl-card"},Ae={class:"wl-head"},Me=["href"],Te={key:1,class:"wl-nick"},De=["textContent"],Pe=["textContent"],Oe=["textContent"],_e=["title"],qe={class:"wl-meta","aria-hidden":"true"},He=["textContent"],We=["textContent"],Fe=["innerHTML"],Je={key:0,class:"wl-reply-wrapper"},Ke={key:1,class:"wl-quote"};Ve.render=function(t,o,n,l,r,a){const i=e.resolveComponent("VerifiedIcon"),c=e.resolveComponent("ReplyIcon"),s=e.resolveComponent("CommentBox"),m=e.resolveComponent("CommentCard",!0);return e.openBlock(),e.createElementBlock("div",{class:"wl-item",id:t.comment.objectId},[e.createElementVNode("div",je,[t.comment.avatar?(e.openBlock(),e.createElementBlock("img",{key:0,src:t.comment.avatar},null,8,Ue)):e.createCommentVNode("v-if",!0),t.comment.type?(e.openBlock(),e.createBlock(i,{key:1})):e.createCommentVNode("v-if",!0)]),e.createElementVNode("div",ze,[e.createElementVNode("div",Ae,[t.link?(e.openBlock(),e.createElementBlock("a",{key:0,class:"wl-nick",href:t.link,target:"_blank",rel:"nofollow noreferrer"},e.toDisplayString(t.comment.nick),9,Me)):(e.openBlock(),e.createElementBlock("span",Te,e.toDisplayString(t.comment.nick),1)),"administrator"===t.comment.type?(e.openBlock(),e.createElementBlock("span",{key:2,class:"wl-badge",textContent:e.toDisplayString(t.locale.admin)},null,8,De)):e.createCommentVNode("v-if",!0),t.comment.sticky?(e.openBlock(),e.createElementBlock("span",{key:3,class:"wl-badge",textContent:e.toDisplayString(t.locale.sticky)},null,8,Pe)):e.createCommentVNode("v-if",!0),e.createElementVNode("span",{class:"wl-time",textContent:e.toDisplayString(t.timeAgo(t.comment.insertedAt,t.locale))},null,8,Oe),e.createElementVNode("button",{class:e.normalizeClass(["wl-reply",{active:t.isReplyingCurrent}]),title:t.isReplyingCurrent?t.locale.cancelReply:t.locale.reply,onClick:o[0]||(o[0]=e=>t.$emit("reply",t.isReplyingCurrent?null:t.comment))},[e.createVNode(c)],10,_e)]),e.createElementVNode("div",qe,[t.comment.browser?(e.openBlock(),e.createElementBlock("span",{key:0,textContent:e.toDisplayString(t.comment.browser)},null,8,He)):e.createCommentVNode("v-if",!0),t.comment.os?(e.openBlock(),e.createElementBlock("span",{key:1,textContent:e.toDisplayString(t.comment.os)},null,8,We)):e.createCommentVNode("v-if",!0)]),e.createElementVNode("div",{class:"wl-content",innerHTML:t.comment.comment},null,8,Fe),t.isReplyingCurrent?(e.openBlock(),e.createElementBlock("div",Je,[e.createVNode(s,{replyId:t.comment.objectId,replyUser:t.comment.nick,rootId:t.rootId,onSubmit:o[1]||(o[1]=e=>t.$emit("submit",e)),onCancelReply:o[2]||(o[2]=e=>t.$emit("reply",null))},null,8,["replyId","replyUser","rootId"])])):e.createCommentVNode("v-if",!0),t.comment.children?(e.openBlock(),e.createElementBlock("div",Ke,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.comment.children,(n=>(e.openBlock(),e.createBlock(m,{key:n.objectId,comment:n,reply:t.reply,rootId:t.rootId,onReply:o[3]||(o[3]=e=>t.$emit("reply",e)),onSubmit:o[4]||(o[4]=e=>t.$emit("submit",e))},null,8,["comment","reply","rootId"])))),128))])):e.createCommentVNode("v-if",!0)])],8,Re)},Ve.__file="src/components/CommentCard.vue";var Ye=e.defineComponent({name:"WalineRoot",components:{CommentBox:Z,CommentCard:Ve,LoadingIcon:X},props:{serverURL:{type:String,required:!0},path:{type:String,required:!0},meta:{type:Array},requiredMeta:{type:Array},visitor:{type:Boolean},dark:{type:[String,Boolean]},lang:{type:String},locale:{type:Object},pageSize:{type:Number},wordLimit:{type:[Number,Array]},emoji:{type:Array},login:{type:String},highlighter:{type:Function},imageUploader:{type:[Function,!1]},texRender:{type:Function}},setup(t){const o=e.computed((()=>(({serverURL:e,path:t=location.pathname,lang:o="zh-CN",locale:n,emoji:l=["https://cdn.jsdelivr.net/gh/walinejs/emojis@1.0.0/weibo"],meta:r=["nick","mail","link"],requiredMeta:i=[],pageSize:d=10,wordLimit:u,imageUploader:p,highlighter:g,texRenderer:v,copyright:h=!0,login:f="enable",...y})=>{return{serverURL:I(e),path:N(t),lang:o,locale:{...k[o]||k["zh-CN"],..."object"==typeof n?n:{}},emoji:(w=l,Promise.all(w.map((e=>"string"==typeof e?L(B(e)):Promise.resolve(e)))).then((e=>{const t={tabs:[],map:{}};return e.forEach((e=>{const{name:o,folder:n,icon:l,prefix:r,type:a,items:i}=e;t.tabs.push({name:o,icon:x(l,n,r,a),items:i.map((e=>{const o=`${r||""}${e}`;return t.map[o]=x(e,n,r,a),o}))})})),t}))),wordLimit:Array.isArray(u)?u:!!u&&[0,u],meta:c(r),requiredMeta:c(i),pageSize:d,login:f,imageUploader:V(p,s),highlighter:V(g,a.default),texRenderer:V(v,m),copyright:h,...y};var w})(t))),{userInfo:n}=G(),l=e.ref("loading"),r=e.ref(0),i=e.ref(1),d=e.ref(0),u=e.ref([]),p=e.ref(null),g=e.computed((()=>{return"string"==typeof(e=o.value.dark)?"auto"===e?`@media(prefers-color-scheme:dark){body${R}}`:`${e}${R}`:!0===e?`:root${R}`:"";var e}));let v,h;const f=e=>{var t;const{serverURL:a,path:c,pageSize:s}=o.value,m=new AbortController;l.value="loading",null==v||v(),(({serverURL:e,path:t,page:o,pageSize:n,signal:l,token:r})=>{const a={};return r&&(a.Authorization=`Bearer ${r}`),fetch(`${e}/comment?path=${encodeURIComponent(t)}&pageSize=${n}&page=${o}`,{signal:l,headers:a}).then((e=>e.json())).then((e=>A(e,"comment list")))})({serverURL:a,path:c,pageSize:s,page:e,signal:m.signal,token:null===(t=n.value)||void 0===t?void 0:t.token}).then((t=>{l.value="success",r.value=t.count,u.value.push(...t.data),i.value=e,d.value=t.totalPages})).catch((e=>{"AbortError"!==e.name&&(console.error(e.message),l.value="error")})),v=m.abort.bind(m)},y=()=>{r.value=0,u.value=[],f(1)};return e.provide("config",o),e.watch((()=>t.path),y),e.onMounted((()=>{var t;y();const o=document.createElement("style");o.innerText=g.value,null===(t=document.querySelector("[data-waline]"))||void 0===t||t.appendChild(o),h=e.watchEffect((()=>{o.innerText=g.value}))})),e.onBeforeUnmount((()=>h())),{config:o,darkmodeStyle:g,i18n:e.computed((()=>o.value.locale)),status:l,count:r,page:i,totalPages:d,data:u,reply:p,loadMore:()=>f(i.value+1),refresh:y,onReply:e=>{p.value=e},onSubmit:e=>{if(e.rid){const t=u.value.find((({objectId:t})=>t===e.rid));if(!t)return;Array.isArray(t.children)||(t.children=[]),t.children.push(e)}else u.value.unshift(e)},version:"2.0.0"}}});const Ge={"data-waline":""},Qe={class:"wl-count"},Xe=["textContent"],Ze={class:"wl-cards"},et={key:1,class:"wl-action"},tt=["textContent"],ot={key:0,class:"wl-loading"},nt=["textContent"],lt={class:"wl-more"},rt=["textContent"],at={key:3,class:"wl-power"},it=e.createTextVNode(" Powered by "),ct=e.createElementVNode("a",{href:"https://github.com/walinejs/waline",target:"_blank",rel:"noreferrer"}," Waline ",-1);Ye.render=function(t,o,n,l,r,a){const i=e.resolveComponent("CommentBox"),c=e.resolveComponent("CommentCard"),s=e.resolveComponent("LoadingIcon");return e.openBlock(),e.createElementBlock("div",Ge,[t.reply?e.createCommentVNode("v-if",!0):(e.openBlock(),e.createBlock(i,{key:0,onSubmit:t.onSubmit},null,8,["onSubmit"])),e.createElementVNode("div",Qe,[t.count?(e.openBlock(),e.createElementBlock("span",{key:0,class:"wl-num",textContent:e.toDisplayString(t.count)},null,8,Xe)):e.createCommentVNode("v-if",!0),e.createTextVNode(" "+e.toDisplayString(t.i18n.comment),1)]),e.createElementVNode("div",Ze,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.data,(o=>(e.openBlock(),e.createBlock(c,{key:o.objectId,"root-id":o.objectId,comment:o,reply:t.reply,onReply:t.onReply,onSubmit:t.onSubmit},null,8,["root-id","comment","reply","onReply","onSubmit"])))),128))]),"error"===t.status?(e.openBlock(),e.createElementBlock("div",et,[e.createElementVNode("button",{type:"button",class:"wl-btn",onClick:o[0]||(o[0]=(...e)=>t.refresh&&t.refresh(...e)),textContent:e.toDisplayString(t.i18n.refresh)},null,8,tt)])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},["loading"===t.status?(e.openBlock(),e.createElementBlock("div",ot,[e.createVNode(s,{size:30})])):t.data.length?t.page<t.totalPages?(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[e.createCommentVNode(" Load more button "),e.createElementVNode("div",lt,[e.createElementVNode("button",{type:"button",class:"wl-btn",onClick:o[1]||(o[1]=(...e)=>t.loadMore&&t.loadMore(...e)),textContent:e.toDisplayString(t.i18n.more)},null,8,rt)])],2112)):e.createCommentVNode("v-if",!0):(e.openBlock(),e.createElementBlock("div",{key:1,class:"wl-empty",textContent:e.toDisplayString(t.i18n.sofa)},null,8,nt))],2112)),e.createCommentVNode(" Copyright Information "),t.config.copyright?(e.openBlock(),e.createElementBlock("div",at,[it,ct,e.createTextVNode(" v"+e.toDisplayString(t.version),1)])):e.createCommentVNode("v-if",!0)])},Ye.__file="src/components/Waline.vue";const st=(e,t)=>{t.forEach(((t,o)=>{t.innerText=e[o].toString()}))},mt=({serverURL:e,path:t=window.location.pathname,selector:o=".waline-pageview-count",update:n=!0})=>{const l=new AbortController,r=Array.from(document.querySelectorAll(o)),a=e=>{const o=W(e);return null!==o&&t!==o},i=o=>M({serverURL:e,paths:o.map((e=>W(e)||t)),signal:l.signal}).then((e=>st(e,o))).catch(z);if(n){const o=r.filter((e=>!a(e))),n=r.filter(a);T({serverURL:e,path:t}).then((e=>st(new Array(o.length).fill(e),o))),n.length&&i(n)}else i(r);return l.abort.bind(l)};exports.RecentComments=({el:e,serverURL:t,count:o})=>{var n;const l=D(e),r=new AbortController;return(({serverURL:e,count:t,signal:o,token:n})=>{const l={};return n&&(l.Authorization=`Bearer ${n}`),fetch(`${e}/comment?type=recent&count=${t}`,{signal:o,headers:l}).then((e=>e.json())).then((e=>A(e,"recent comment")))})({serverURL:t,count:o,signal:r.signal,token:null===(n=K())||void 0===n?void 0:n.token}).then((e=>l&&e.length?(l.innerHTML=`<ul class="wl-recent-list">${e.map((e=>`<li class="wl-recent-item"><a href="${e.url}">${e.nick}</a>:${e.comment}</li>`)).join("")}</ul>`,{comments:e,destroy:()=>{r.abort(),l.innerHTML=""}}):{comments:e,destroy:()=>r.abort()}))},exports.commentCount=Q,exports.defaultLang="zh-CN",exports.defaultTexRenderer=m,exports.defaultUploadImage=s,exports.getMeta=c,exports.init=({el:t="#waline",path:o=window.location.pathname,comment:n=!1,pageview:l=!1,...r})=>{const a=t?D(t):null;if(t&&!a)throw new Error("Option 'el' do not match any domElement!");if(!r.serverURL)throw new Error("Option 'serverURL' is missing!");const i=e.reactive({...r}),c=e.reactive({comment:n,pageview:l,path:o}),s=()=>{c.comment&&Q({serverURL:i.serverURL,path:c.path,selector:"string"==typeof c.comment?c.comment:void 0})},m=()=>{c.pageview&&mt({serverURL:i.serverURL,path:c.path,selector:"string"==typeof c.pageview?c.pageview:void 0})},d=a?e.createApp((()=>e.h(Ye,{path:c.path,...i}))):null;d&&d.mount(a),s(),m();const u=e.watchEffect(s),p=e.watchEffect(m);return{el:a,update:({comment:e,pageview:t,path:o=window.location.pathname,...n})=>{Object.entries(n).map((([e,t])=>{i[e]=t})),c.path=o,void 0!==e&&(c.comment=e),void 0!==t&&(c.pageview=t)},destroy:()=>{null==d||d.unmount(),u(),p()}}},exports.locales=k,exports.pageviewCount=mt,exports.version="2.0.0";
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("vue"),t=require("autosize"),o=require("marked"),n=require("hanabi");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r=l(t),a=l(n);const i=["nick","mail","link"],c=e=>e.filter((e=>i.includes(e))),s=e=>new Promise(((t,o)=>{const n=new FileReader;n.readAsDataURL(e),n.onload=()=>{var e;return t((null===(e=n.result)||void 0===e?void 0:e.toString())||"")},n.onerror=o})),m=e=>!0===e?'<p class="vtex">Tex is not available in preview</p>':'<span class="vtex">Tex is not available in preview</span>',d=["nick","nickError","mail","mailError","link","optional","placeholder","sofa","submit","reply","cancelReply","comment","refresh","more","preview","emoji","uploadImage","seconds","minutes","hours","days","now","uploading","login","logout","admin","sticky","word","wordHint","anonymous"],u=e=>Object.fromEntries(e.map(((e,t)=>[d[t],e])));var p=u(["NickName","NickName cannot be less than 3 bytes.","E-Mail","Please confirm your email address.","Website","Optional","Comment here...","No comment yet.","Submit","Reply","Cancel reply","Comments","Refresh","Load More...","Preview","Emoji","Upload Image","seconds ago","minutes ago","hours ago","days ago","just now","Uploading","Login","logout","Admin","Sticky","Words","Please input comments between $0 and $1 words!\n Current word number: $2","Anonymous"]),g=u(["ニックネーム","3バイト以上のニックネームをご入力ください.","メールアドレス","メールアドレスをご確認ください.","サイト","オプション","ここにコメント","コメントしましょう~","提出する","返信する","キャンセル","コメント","更新","さらに読み込む","プレビュー","絵文字","画像をアップロード","秒前","分前","時間前","日前","たっだ今","アップロード","ログインする","ログアウト","管理者","トップに置く","ワード","コメントは $0 から $1 ワードの間でなければなりません!\n 現在の単語番号: $2","匿名"]),v=u(["昵称","昵称不能少于3个字符","邮箱","请填写正确的邮件地址","网址","可选","欢迎评论","来发评论吧~","提交","回复","取消回复","评论","刷新","加载更多...","预览","表情","上传图片","秒前","分钟前","小时前","天前","刚刚","正在上传","登录","退出","博主","置顶","字","评论字数应在 $0 到 $1 字之间!\n当前字数:$2","匿名"]),h=u(["暱稱","郵箱","網址","可選","暱稱不能少於3個字元","請填寫正確的郵件地址","歡迎評論","來發評論吧~","提交","回覆","取消回覆","評論","刷新","載入更多...","預覽","表情","上傳圖片","秒前","分鐘前","小時前","天前","剛剛","正在上傳","登錄","退出","博主","置頂","字","評論字數應在 $0 到 $1 字之間!\n當前字數:$2","匿名"]),f=u(["Apelido","Apelido não pode ser menor que 3 bytes.","E-Mail","Por favor, confirme seu endereço de e-mail.","Website","Opcional","Comente aqui...","Nenhum comentário, ainda.","Enviar","Responder","Cancelar resposta","Comentários","Refrescar","Carregar Mais...","Visualizar","Emoji","Enviar Imagem","segundos atrás","minutos atrás","horas atrás","dias atrás","agora mesmo","Enviando","Entrar","Sair","Admin","Sticky","Palavras","Favor enviar comentário com $0 a $1 palavras!\n Número de palavras atuais: $2","Anônimo"]),y=u(["Псевдоним","Никнейм не может быть меньше 3 байт.","Эл. адрес","Пожалуйста, подтвердите адрес вашей электронной почты.","Веб-сайт","Необязательный","Комментарий здесь...","Пока нет комментариев.","Отправить","Отвечать","Отменить ответ","Комментарии","Обновить","Загрузи больше...","Превью","эмодзи","Загрузить изображение","секунд назад","несколько минут назад","несколько часов назад","дней назад","прямо сейчас","Загрузка","Авторизоваться","Выход из системы","Админ","Липкий","Слова","Пожалуйста, введите комментарии от $0 до $1 слов!\nНомер текущего слова: $2","Анонимный"]);const k={zh:v,"zh-cn":v,"zh-CN":v,"zh-tw":h,"zh-TW":h,en:p,"en-US":p,"en-us":p,jp:g,"jp-jp":g,"jp-JP":g,"pt-br":f,"pt-BR":f,ru:y,"ru-ru":y,"ru-RU":y},w=e=>{let t={};const o=localStorage.getItem(e);if(o)try{t=JSON.parse(o)}catch(e){}return{get:e=>t[e]||null,set(o,n){try{t[o]=JSON.parse(JSON.stringify(n)),localStorage.setItem(e,JSON.stringify(t))}catch(e){}},update(o){t=JSON.parse(JSON.stringify(o)),localStorage.setItem(e,JSON.stringify(t))}}};let C,b;const E=()=>(b||(C=w("WALINE_USER_CACHE"),b=e.reactive({nick:C.get("nick")||"",mail:C.get("mail")||"",link:C.get("link")||"",editor:""})),{inputs:b,store:C}),N=e=>{try{e=decodeURI(e)}catch(e){}return e},B=(e="")=>e.replace(/\/$/u,""),$=e=>/^(https?:)?\/\//.test(e);let S;const L=e=>{S||(S=w("WALINE_EMOJI"));const t=Boolean(/@[0-9]+\.[0-9]+\.[0-9]+/.test(e));if(t){const t=S.get(e);if(t)return Promise.resolve(t)}return fetch(`${e}/info.json`).then((e=>e.json())).then((o=>{const n={folder:e,...o};return t&&S.set(e,n),n}))},x=(e,t="",o="",n="")=>`${t?`${t}/`:""}${o}${e}${n?`.${n}`:""}`,I=e=>{const t=B(e);return $(t)?t:`https://${t}`},V=(e,t)=>"function"==typeof e?e:!1!==e&&t,R="{--waline-white:#000;--waline-light-grey:#666;--waline-dark-grey:#999;--waline-color:#888;--waline-bgcolor:#1e1e1e;--waline-bgcolor-light:#272727;--waline-bgcolor-hover: #444;--waline-border-color:#333;--waline-disable-bgcolor:#444;--waline-disable-color:#272727;--waline-bq-color:#272727;--waline-info-bgcolor:#272727;--waline-info-color:#666}",j=e=>e.type.includes("image"),U=e=>{const t=Array.from(e).find(j);return t?t.getAsFile():null},z=e=>{"AbortError"!==e.name&&console.error(e.message)},A=(e,t="")=>{if("object"==typeof e&&e.errno)throw new TypeError(`Fetch ${t} failed with ${e.errno}: ${e.errmsg}`);return e},M=({serverURL:e,paths:t,signal:o})=>fetch(`${e}/article?path=${encodeURIComponent(t.join(","))}`,{signal:o}).then((e=>e.json())).then((e=>A(e,"visit count"))).then((e=>Array.isArray(e)?e:[e])),T=({serverURL:e,path:t})=>fetch(`${e}/article`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:t})}).then((e=>e.json())).then((e=>A(e,"visit count"))),D=e=>e instanceof HTMLElement?e:"string"==typeof e?document.querySelector(e):null,P=/\$.*?\$/,O=/^\$(.*?)\$/,_=/^(?:\s{0,3})\$\$((?:[^\n]|\n[^\n])+?)\n{0,1}\$\$/,q=(e="",t={})=>e.replace(/:(.+?):/g,((e,o)=>t[o]?`<img class="vemoji" src="${t[o]}" alt="${o}">`:e)),H=(e,{emojiMap:t,highlighter:n,texRenderer:l})=>{if(o.marked.setOptions({highlight:n||void 0,breaks:!0,smartLists:!0,smartypants:!0}),l){const e=(e=>[{name:"blockMath",level:"block",tokenizer(t){const o=_.exec(t);if(null!==o)return{type:"html",raw:o[0],text:e(!0,o[1])}}},{name:"inlineMath",level:"inline",start(e){const t=e.search(P);return-1!==t?t:e.length},tokenizer(t){const o=O.exec(t);if(null!==o)return{type:"html",raw:o[0],text:e(!1,o[1])}}}])(l);o.marked.use({extensions:e})}return o.marked.parse(q(e,t))},W=e=>e.dataset.path||e.getAttribute("id"),F=(e,t)=>{let o=e.toString();for(;o.length<t;)o="0"+o;return o},J=(e,t)=>{if(e)try{"string"==typeof e&&(e=new Date(-1!==e.indexOf(" ")?e.replace(/-/g,"/"):e));const o=e.getTime(),n=(new Date).getTime()-o,l=Math.floor(n/864e5);if(0===l){const e=n%864e5,o=Math.floor(e/36e5);if(0===o){const o=e%36e5,n=Math.floor(o/6e4);if(0===n){const e=o%6e4;return`${Math.round(e/1e3)} ${t.seconds}`}return`${n} ${t.minutes}`}return`${o} ${t.hours}`}return l<0?t.now:l<8?`${l} ${t.days}`:(e=>{const t=F(e.getDate(),2),o=F(e.getMonth()+1,2);return`${F(e.getFullYear(),2)}-${o}-${t}`})(e)}catch(e){console.log(e)}return""},K=()=>{try{const e=localStorage.getItem("WALINE_USER"),t=sessionStorage.getItem("WALINE_USER");return e?JSON.parse(e):t?JSON.parse(t):null}catch(e){return null}},Y=e.ref({}),G=()=>{if(!Y.value.token){const e=K();e&&(Y.value=e)}return{userInfo:e.readonly(Y),setUserInfo:e=>{Y.value=e}}},Q=({serverURL:e,path:t=window.location.pathname,selector:o=".waline-comment-count"})=>{var n;const l=new AbortController,r=document.querySelectorAll(o),{userInfo:a}=G();return r.length&&(({serverURL:e,paths:t,signal:o,token:n})=>{const l={};return n&&(l.Authorization=`Bearer ${n}`),fetch(`${e}/comment?type=count&url=${encodeURIComponent(t.join(","))}`,{signal:o,headers:l}).then((e=>e.json())).then((e=>A(e,"comment count"))).then((e=>Array.isArray(e)?e:[e]))})({serverURL:e,paths:Array.from(r).map((e=>N(e.dataset.path||e.getAttribute("id")||t))),signal:l.signal,token:null===(n=a.value)||void 0===n?void 0:n.token}).then((e=>{r.forEach(((t,o)=>{t.innerText=e[o].toString()}))})).catch(z),l.abort.bind(l)},X=({size:t})=>e.h("svg",{width:t,height:t,viewBox:"0 0 100 100",preserveAspectRatio:"xMidYMid"},e.h("circle",{cx:50,cy:50,fill:"none",stroke:"currentColor",strokeWidth:"4",r:"40","stroke-dasharray":"85 30"},e.h("animateTransform",{attributeName:"transform",type:"rotate",repeatCount:"indefinite",dur:"1s",values:"0 50 50;360 50 50",keyTimes:"0;1"})));var Z=e.defineComponent({name:"CommentBox",components:{CloseIcon:({size:t})=>e.h("svg",{class:"wl-close-icon",viewBox:"0 0 1024 1024",width:t,height:t},[e.h("path",{d:"M697.173 85.333h-369.92c-144.64 0-241.92 101.547-241.92 252.587v348.587c0 150.613 97.28 252.16 241.92 252.16h369.92c144.64 0 241.494-101.547 241.494-252.16V337.92c0-151.04-96.854-252.587-241.494-252.587z",fill:"currentColor"}),e.h("path",{d:"m640.683 587.52-75.947-75.861 75.904-75.862a37.29 37.29 0 0 0 0-52.778 37.205 37.205 0 0 0-52.779 0l-75.946 75.818-75.862-75.946a37.419 37.419 0 0 0-52.821 0 37.419 37.419 0 0 0 0 52.821l75.947 75.947-75.776 75.733a37.29 37.29 0 1 0 52.778 52.821l75.776-75.776 75.947 75.947a37.376 37.376 0 0 0 52.779-52.821z",fill:"#888"})]),EmojiIcon:()=>e.h("svg",{viewBox:"0 0 1024 1024",width:"24",height:"24"},e.h("path",{d:"M563.2 463.3 677 540c1.7 1.2 3.7 1.8 5.8 1.8.7 0 1.4-.1 2-.2 2.7-.5 5.1-2.1 6.6-4.4l25.3-37.8c1.5-2.3 2.1-5.1 1.6-7.8s-2.1-5.1-4.4-6.6l-73.6-49.1 73.6-49.1c2.3-1.5 3.9-3.9 4.4-6.6.5-2.7 0-5.5-1.6-7.8l-25.3-37.8a10.1 10.1 0 0 0-6.6-4.4c-.7-.1-1.3-.2-2-.2-2.1 0-4.1.6-5.8 1.8l-113.8 76.6c-9.2 6.2-14.7 16.4-14.7 27.5.1 11 5.5 21.3 14.7 27.4zM387 348.8h-45.5c-5.7 0-10.4 4.7-10.4 10.4v153.3c0 5.7 4.7 10.4 10.4 10.4H387c5.7 0 10.4-4.7 10.4-10.4V359.2c0-5.7-4.7-10.4-10.4-10.4zm333.8 241.3-41-20a10.3 10.3 0 0 0-8.1-.5c-2.6.9-4.8 2.9-5.9 5.4-30.1 64.9-93.1 109.1-164.4 115.2-5.7.5-9.9 5.5-9.5 11.2l3.9 45.5c.5 5.3 5 9.5 10.3 9.5h.9c94.8-8 178.5-66.5 218.6-152.7 2.4-5 .3-11.2-4.8-13.6zm186-186.1c-11.9-42-30.5-81.4-55.2-117.1-24.1-34.9-53.5-65.6-87.5-91.2-33.9-25.6-71.5-45.5-111.6-59.2-41.2-14-84.1-21.1-127.8-21.1h-1.2c-75.4 0-148.8 21.4-212.5 61.7-63.7 40.3-114.3 97.6-146.5 165.8-32.2 68.1-44.3 143.6-35.1 218.4 9.3 74.8 39.4 145 87.3 203.3.1.2.3.3.4.5l36.2 38.4c1.1 1.2 2.5 2.1 3.9 2.6 73.3 66.7 168.2 103.5 267.5 103.5 73.3 0 145.2-20.3 207.7-58.7 37.3-22.9 70.3-51.5 98.1-85 27.1-32.7 48.7-69.5 64.2-109.1 15.5-39.7 24.4-81.3 26.6-123.8 2.4-43.6-2.5-87-14.5-129zm-60.5 181.1c-8.3 37-22.8 72-43 104-19.7 31.1-44.3 58.6-73.1 81.7-28.8 23.1-61 41-95.7 53.4-35.6 12.7-72.9 19.1-110.9 19.1-82.6 0-161.7-30.6-222.8-86.2l-34.1-35.8c-23.9-29.3-42.4-62.2-55.1-97.7-12.4-34.7-18.8-71-19.2-107.9-.4-36.9 5.4-73.3 17.1-108.2 12-35.8 30-69.2 53.4-99.1 31.7-40.4 71.1-72 117.2-94.1 44.5-21.3 94-32.6 143.4-32.6 49.3 0 97 10.8 141.8 32 34.3 16.3 65.3 38.1 92 64.8 26.1 26 47.5 56 63.6 89.2 16.2 33.2 26.6 68.5 31 105.1 4.6 37.5 2.7 75.3-5.6 112.3z",fill:"currentColor"})),ImageIcon:()=>e.h("svg",{viewBox:"0 0 1024 1024",width:"24",height:"24"},[e.h("path",{d:"M784 112H240c-88 0-160 72-160 160v480c0 88 72 160 160 160h544c88 0 160-72 160-160V272c0-88-72-160-160-160zm96 640c0 52.8-43.2 96-96 96H240c-52.8 0-96-43.2-96-96V272c0-52.8 43.2-96 96-96h544c52.8 0 96 43.2 96 96v480z",fill:"currentColor"}),e.h("path",{d:"M352 480c52.8 0 96-43.2 96-96s-43.2-96-96-96-96 43.2-96 96 43.2 96 96 96zm0-128c17.6 0 32 14.4 32 32s-14.4 32-32 32-32-14.4-32-32 14.4-32 32-32zm462.4 379.2-3.2-3.2-177.6-177.6c-25.6-25.6-65.6-25.6-91.2 0l-80 80-36.8-36.8c-25.6-25.6-65.6-25.6-91.2 0L200 728c-4.8 6.4-8 14.4-8 24 0 17.6 14.4 32 32 32 9.6 0 16-3.2 22.4-9.6L380.8 640l134.4 134.4c6.4 6.4 14.4 9.6 24 9.6 17.6 0 32-14.4 32-32 0-9.6-4.8-17.6-9.6-24l-52.8-52.8 80-80L769.6 776c6.4 4.8 12.8 8 20.8 8 17.6 0 32-14.4 32-32 0-8-3.2-16-8-20.8z",fill:"currentColor"})]),MarkdownIcon:()=>e.h("svg",{width:"16",height:"16",ariaHidden:"true"},e.h("path",{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",fill:"currentColor"})),PreviewIcon:()=>e.h("svg",{viewBox:"0 0 1024 1024",width:"24",height:"24"},[e.h("path",{d:"M710.816 654.301c70.323-96.639 61.084-230.578-23.705-314.843-46.098-46.098-107.183-71.109-172.28-71.109-65.008 0-126.092 25.444-172.28 71.109-45.227 46.098-70.756 107.183-70.756 172.106 0 64.923 25.444 126.007 71.194 172.106 46.099 46.098 107.184 71.109 172.28 71.109 51.414 0 100.648-16.212 142.824-47.404l126.53 126.006c7.058 7.06 16.297 10.979 26.406 10.979 10.105 0 19.343-3.919 26.402-10.979 14.467-14.467 14.467-38.172 0-52.723L710.816 654.301zm-315.107-23.265c-65.88-65.88-65.88-172.54 0-238.42 32.069-32.07 74.245-49.149 119.471-49.149 45.227 0 87.407 17.603 119.472 49.149 65.88 65.879 65.88 172.539 0 238.42-63.612 63.178-175.242 63.178-238.943 0zm0 0",fill:"currentColor"}),e.h("path",{d:"M703.319 121.603H321.03c-109.8 0-199.469 89.146-199.469 199.38v382.034c0 109.796 89.236 199.38 199.469 199.38h207.397c20.653 0 37.384-16.645 37.384-37.299 0-20.649-16.731-37.296-37.384-37.296H321.03c-68.582 0-124.352-55.77-124.352-124.267V321.421c0-68.496 55.77-124.267 124.352-124.267h382.289c68.582 0 124.352 55.771 124.352 124.267V524.72c0 20.654 16.736 37.299 37.385 37.299 20.654 0 37.384-16.645 37.384-37.299V320.549c-.085-109.8-89.321-198.946-199.121-198.946zm0 0",fill:"currentColor"})]),LoadingIcon:X},props:{rootId:{type:String,default:""},replyId:{type:String,default:""},replyUser:{type:String,default:""}},emits:["submit","cancel-reply"],setup(t,{emit:o}){const n=e.inject("config"),{inputs:l,store:a}=E(),{userInfo:i,setUserInfo:c}=G(),s=e.ref({}),m=e.ref(null),d=e.ref(null),u=e.ref(null),p=e.ref(null),g=e.ref({tabs:[],map:{}}),v=e.ref(0),h=e.ref(!1),f=e.ref(!1),y=e.ref(""),k=e.ref(0),w=e.ref(0),C=e.ref(!1),b=e.ref(""),N=e.ref(!1),B=e.computed((()=>n.value.locale)),$=e.computed((()=>{var e;return Boolean(null===(e=i.value)||void 0===e?void 0:e.token)})),S=e.computed((()=>!1!==n.value.imageUploader)),L=e=>{const t=m.value,o=t.selectionStart,n=t.selectionEnd||0,r=t.scrollTop;l.editor=t.value.substring(0,o)+e+t.value.substring(n,t.value.length),t.focus(),t.selectionStart=o+e.length,t.selectionEnd=o+e.length,t.scrollTop=r},x=e=>{const t=`![${n.value.locale.uploading} ${e.name}]()`;return L(t),Promise.resolve().then((()=>n.value.imageUploader(e))).then((o=>{l.editor=l.editor.replace(t,`\r\n![${e.name}](${o})`)}))},I=()=>{var e,r,c,d,u;const{serverURL:p,lang:v,login:h,wordLimit:f,requiredMeta:w}=n.value,E={comment:b.value,nick:l.nick,mail:l.mail,link:l.link,ua:navigator.userAgent,url:n.value.path};if(null===(e=i.value)||void 0===e?void 0:e.token)E.nick=i.value.display_name,E.mail=i.value.email,E.link=i.value.url;else{if("force"===h)return;if((w.indexOf("nick")>-1||E.nick)&&!E.nick)return null===(r=s.value.nick)||void 0===r||r.focus(),alert(B.value.nickError);if(w.indexOf("mail")>-1&&!E.mail)return null===(c=s.value.mail)||void 0===c||c.focus(),alert(B.value.mailError);if(!E.comment)return void(null===(d=m.value)||void 0===d||d.focus());E.nick||(E.nick=B.value.anonymous)}if(!C.value)return alert(B.value.wordHint.replace("$0",f[0].toString()).replace("$1",f[1].toString()).replace("$2",k.value.toString()));E.comment=q(E.comment,g.value.map),t.replyId&&t.rootId&&(E.pid=t.replyId,E.rid=t.rootId,E.at=t.replyUser),N.value=!0,(({serverURL:e,lang:t,token:o,comment:n})=>{const l={"Content-Type":"application/json"};return o&&(l.Authorization=`Bearer ${o}`),fetch(`${e}/comment?lang=${t}`,{method:"POST",headers:l,body:JSON.stringify(n)}).then((e=>e.json()))})({serverURL:p,lang:v,token:null===(u=i.value)||void 0===u?void 0:u.token,comment:E}).then((e=>{if(N.value=!1,a.update({nick:E.nick,link:E.link,mail:E.mail}),e.errmsg)return alert(e.errmsg);o("submit",e.data),l.editor="",y.value="",t.replyId&&o("cancel-reply")})).catch((e=>{N.value=!1,alert(e.message)}))},V=e=>{u.value.contains(e.target)||p.value.contains(e.target)||(h.value=!1)};return e.watch((()=>l.editor),(e=>{const{highlighter:t,texRenderer:o}=n.value;b.value=e,y.value=H(e,{emojiMap:g.value.map,highlighter:t,texRenderer:o}),k.value=(e=>(e=>e.match(/[\w\d\s\u00C0-\u024F]+/giu)||[])(e).reduce(((e,t)=>e+(""===t.trim()?0:t.trim().split(/\s+/u).length)),0)+(e=>e.match(/[\u4E00-\u9FA5]/gu)||[])(e).length)(e),m.value&&(e?r.default(m.value):r.default.destroy(m.value))}),{immediate:!0}),e.watch((()=>n.value.emoji),(e=>e.then((e=>{g.value=e}))),{immediate:!0}),e.watch([n,k],(([e,t])=>{const{wordLimit:o}=e;o?t<o[0]&&0!==o[0]?(w.value=o[0],C.value=!1):t>o[1]?(w.value=o[1],C.value=!1):(w.value=o[1],C.value=!0):(w.value=0,C.value=!0)}),{immediate:!0}),e.onMounted((()=>{document.body.addEventListener("click",V)})),e.onUnmounted((()=>{document.body.removeEventListener("click",V)})),{config:n,locale:B,insert:L,onChange:()=>{const e=d.value;e.files&&S.value&&x(e.files[0]).then((()=>{e.value=""}))},onDrop:e=>{var t;if(null===(t=e.dataTransfer)||void 0===t?void 0:t.items){const t=U(e.dataTransfer.items);t&&S.value&&(x(t),e.preventDefault())}},onKeyDown:e=>{const t=e.key;(e.ctrlKey||e.metaKey)&&"Enter"===t&&I()},onPaste:e=>{if(e.clipboardData){const t=U(e.clipboardData.items);t&&S.value&&x(t)}},onLogin:e=>{e.preventDefault();const{lang:t,serverURL:o}=n.value,l=(window.innerWidth-450)/2,r=(window.innerHeight-450)/2,a=window.open(`${o}/ui/login?lng=${encodeURIComponent(t)}`,"_blank",`width=450,height=450,left=${l},top=${r},scrollbars=no,resizable=no,status=no,location=no,toolbar=no,menubar=no`);null==a||a.postMessage({type:"TOKEN",data:null},"*");const i=({data:e})=>{e&&"userInfo"===e.type&&e.data.token&&(null==a||a.close(),c(e.data),(e.data.remember?localStorage:sessionStorage).setItem("WALINE_USER",JSON.stringify(e.data)),window.removeEventListener("message",i))};window.addEventListener("message",i)},onLogout:()=>{c({}),localStorage.setItem("WALINE_USER","null"),sessionStorage.setItem("WALINE_USER","null")},onProfile:e=>{e.preventDefault();const{lang:t,serverURL:o}=n.value,l=(window.innerWidth-800)/2,r=(window.innerHeight-800)/2,a=window.open(`${o}/ui/profile?lng=${encodeURIComponent(t)}`,"_blank",`width=800,height=800,left=${l},top=${r},scrollbars=no,resizable=no,status=no,location=no,toolbar=no,menubar=no`);null==a||a.postMessage({type:"TOKEN",data:i.value.token},"*");const s=({data:e})=>{e&&"profile"===e.type&&(c(Object.assign({},i.value,e)),[localStorage,sessionStorage].filter((e=>e.getItem("WALINE_USER"))).forEach((e=>e.setItem("WALINE_USER",JSON.stringify(i)))),window.removeEventListener("message",s))};window.addEventListener("message",s)},submitComment:I,isLogin:$,userInfo:i,isSubmitting:N,wordNumber:k,wordLimit:w,isWordNumberLegal:C,inputs:l,emoji:g,emojiTabIndex:v,showEmoji:h,canUploadImage:S,previewText:y,showPreview:f,inputRefs:s,editorRef:m,emojiButtonRef:u,emojiPopupRef:p,imageUploadRef:d}}});const ee={class:"wl-comment"},te={key:0,class:"wl-login-info"},oe={class:"wl-avatar"},ne=["title"],le=["src"],re=["textContent"],ae={class:"wl-panel"},ie=["for","textContent"],ce=["id","name","type","onUpdate:modelValue"],se=["placeholder"],me=["innerHTML"],de={class:"wl-footer"},ue={class:"wl-actions"},pe={href:"https://guides.github.com/features/mastering-markdown/",title:"Markdown Guide","aria-label":"Markdown is supported",class:"wl-action",target:"_blank",rel:"noreferrer"},ge=["title"],ve=["title"],he=["title"],fe={class:"wl-info"},ye={class:"wl-text-number"},ke={key:0},we=e.createTextVNode("  /  "),Ce=["textContent"],be=["textContent"],Ee=["disabled"],Ne={key:0,class:"wl-tab-wrapper"},Be=["title","onClick"],$e=["src","alt"],Se={key:0,class:"wl-tabs"},Le=["onClick"],xe=["src","alt","title"],Ie=["title"];Z.render=function(t,o,n,l,r,a){const i=e.resolveComponent("CloseIcon"),c=e.resolveComponent("MarkdownIcon"),s=e.resolveComponent("EmojiIcon"),m=e.resolveComponent("ImageIcon"),d=e.resolveComponent("PreviewIcon"),u=e.resolveComponent("LoadingIcon");return e.openBlock(),e.createElementBlock("div",ee,["disable"!==t.config.login&&t.isLogin?(e.openBlock(),e.createElementBlock("div",te,[e.createElementVNode("div",oe,[e.createElementVNode("button",{class:"wl-logout-btn",title:t.locale.logout,onClick:o[0]||(o[0]=(...e)=>t.onLogout&&t.onLogout(...e))},[e.createVNode(i,{size:14})],8,ne),e.createElementVNode("img",{src:t.userInfo.avatar,alt:"avatar"},null,8,le)]),e.createElementVNode("a",{href:"#",class:"wl-login-nick","aria-label":"Profile",onClick:o[1]||(o[1]=(...e)=>t.onProfile&&t.onProfile(...e)),textContent:e.toDisplayString(t.userInfo.display_name)},null,8,re)])):e.createCommentVNode("v-if",!0),e.createElementVNode("div",ae,["force"!==t.config.login&&t.config.meta.length&&!t.isLogin?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["wl-header",`item${t.config.meta.length}`])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.config.meta,(o=>(e.openBlock(),e.createElementBlock("div",{class:"wl-header-item",key:o},[e.createElementVNode("label",{for:o,textContent:e.toDisplayString(t.locale[o]+(t.config.requiredMeta.includes(o)||!t.config.requiredMeta.length?"":`(${t.locale.optional})`))},null,8,ie),e.withDirectives(e.createElementVNode("input",{ref_for:!0,ref:e=>{e&&(t.inputRefs[o]=e)},id:`wl-${o}`,class:e.normalizeClass(["wl-input",`wl-${o}`]),name:o,type:"mail"===o?"email":"text","onUpdate:modelValue":e=>t.inputs[o]=e},null,10,ce),[[e.vModelDynamic,t.inputs[o]]])])))),128))],2)):e.createCommentVNode("v-if",!0),e.withDirectives(e.createElementVNode("textarea",{class:"wl-editor",ref:"editorRef",id:"wl-edit",placeholder:t.replyUser?`@${t.replyUser}`:t.locale.placeholder,"onUpdate:modelValue":o[2]||(o[2]=e=>t.inputs.editor=e),onKeydown:o[3]||(o[3]=(...e)=>t.onKeyDown&&t.onKeyDown(...e)),onDrop:o[4]||(o[4]=(...e)=>t.onDrop&&t.onDrop(...e)),onPaste:o[5]||(o[5]=(...e)=>t.onPaste&&t.onPaste(...e))},null,40,se),[[e.vModelText,t.inputs.editor]]),e.createElementVNode("div",{class:"wl-preview",style:e.normalizeStyle({display:t.showPreview?"block":"none"})},[e.createElementVNode("h4",null,e.toDisplayString(t.locale.preview)+":",1),e.createElementVNode("div",{class:"wl-content",innerHTML:t.previewText},null,8,me)],4),e.createElementVNode("div",de,[e.createElementVNode("div",ue,[e.createElementVNode("a",pe,[e.createVNode(c)]),e.createElementVNode("button",{ref:"emojiButtonRef",class:e.normalizeClass(["wl-action",{actived:t.showEmoji}]),title:t.locale.emoji,onClick:o[6]||(o[6]=e=>t.showEmoji=!t.showEmoji)},[e.createVNode(s)],10,ge),e.createElementVNode("input",{ref:"imageUploadRef",class:"upload",id:"wl-image-upload",type:"file",accept:".png,.jpg,.jpeg,.webp,.bmp,.gif",onChange:o[7]||(o[7]=(...e)=>t.onChange&&t.onChange(...e))},null,544),t.canUploadImage?(e.openBlock(),e.createElementBlock("label",{key:0,for:"wl-image-upload",class:"wl-action",title:t.locale.uploadImage},[e.createVNode(m)],8,ve)):e.createCommentVNode("v-if",!0),e.createElementVNode("button",{class:e.normalizeClass(["wl-action",{actived:t.showPreview}]),title:t.locale.preview,onClick:o[8]||(o[8]=e=>t.showPreview=!t.showPreview)},[e.createVNode(d)],10,he)]),e.createElementVNode("div",fe,[e.createElementVNode("div",ye,[e.createTextVNode(e.toDisplayString(t.wordNumber)+" ",1),t.config.wordLimit?(e.openBlock(),e.createElementBlock("span",ke,[we,e.createElementVNode("span",{class:e.normalizeClass({illegal:!t.isWordNumberLegal}),textContent:e.toDisplayString(t.wordLimit)},null,10,Ce)])):e.createCommentVNode("v-if",!0),e.createTextVNode("  "+e.toDisplayString(t.locale.word),1)]),"disable"===t.config.login||t.isLogin?e.createCommentVNode("v-if",!0):(e.openBlock(),e.createElementBlock("button",{key:0,class:"wl-btn",onClick:o[9]||(o[9]=(...e)=>t.onLogin&&t.onLogin(...e)),textContent:e.toDisplayString(t.locale.login)},null,8,be)),"force"!==t.config.login||t.isLogin?(e.openBlock(),e.createElementBlock("button",{key:1,class:"wl-btn primary",title:"Cmd|Ctrl + Enter",disabled:t.isSubmitting,onClick:o[10]||(o[10]=(...e)=>t.submitComment&&t.submitComment(...e))},[t.isSubmitting?(e.openBlock(),e.createBlock(u,{key:0,size:16})):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createTextVNode(e.toDisplayString(t.locale.submit),1)],2112))],8,Ee)):e.createCommentVNode("v-if",!0)]),e.createElementVNode("div",{ref:"emojiPopupRef",class:e.normalizeClass(["wl-emoji-popup",{display:t.showEmoji}])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.emoji.tabs,((o,n)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:o.name},[n===t.emojiTabIndex?(e.openBlock(),e.createElementBlock("div",Ne,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.items,(o=>(e.openBlock(),e.createElementBlock("button",{key:o,title:o,onClick:e=>t.insert(`:${o}:`)},[t.showEmoji?(e.openBlock(),e.createElementBlock("img",{key:0,class:"wl-emoji",src:t.emoji.map[o],alt:o,loading:"lazy",referrerPolicy:"no-referrer"},null,8,$e)):e.createCommentVNode("v-if",!0)],8,Be)))),128))])):e.createCommentVNode("v-if",!0)],64)))),128)),t.emoji.tabs.length>1?(e.openBlock(),e.createElementBlock("div",Se,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.emoji.tabs,((o,n)=>(e.openBlock(),e.createElementBlock("button",{key:o.name,class:e.normalizeClass(["wl-tab",{active:t.emojiTabIndex===n}]),onClick:e=>t.emojiTabIndex=n},[e.createElementVNode("img",{class:"wl-emoji",src:o.icon,alt:o.name,title:o.name,loading:"lazy",referrerPolicy:"no-referrer"},null,8,xe)],10,Le)))),128))])):e.createCommentVNode("v-if",!0)],2)])]),t.replyId?(e.openBlock(),e.createElementBlock("button",{key:1,class:"wl-close",title:t.locale.cancelReply,onClick:o[11]||(o[11]=e=>t.$emit("cancel-reply"))},[e.createVNode(i,{size:24})],8,Ie)):e.createCommentVNode("v-if",!0)])},Z.__file="src/components/CommentBox.vue";var Ve=e.defineComponent({props:{comment:{type:Object,required:!0},rootId:{type:String,required:!0},reply:{type:Object}},components:{CommentBox:Z,ReplyIcon:()=>e.h("svg",{viewBox:"0 0 1024 1024",width:"18",height:"18"},e.h("path",{d:"M1019.2 720C1001.6 625.6 968 566.4 904 497.6c-89.6-89.6-214.4-150.4-347.2-176v-120c0-25.6-8-51.2-25.6-64-33.6-30.4-81.6-30.4-112-4.8L33.6 441.6C12.8 459.2 0 484.8 0 510.4c0 25.6 12.8 51.2 30.4 68.8l385.6 312c17.6 12.8 33.6 17.6 51.2 17.6 12.8 0 25.6-4.8 38.4-8C536 888 552 857.6 552 824v-99.2c124.8 20.8 248 86.4 339.2 140.8 25.6 17.6 59.2 17.6 89.6 0 25.6-17.6 43.2-46.4 43.2-76.8 0-33.6 0-56-4.8-68.8zm-500.8-89.6-46.4-4.8v193.6L86.4 510.4 472 201.6V400l38.4 4.8c128 12.8 248 68.8 334.4 153.6 51.2 56 76.8 102.4 94.4 179.2 0 4.8 4.8 20.8 4.8 51.2C835.2 720 672 640 518.4 630.4z",fill:"currentColor"})),VerifiedIcon:()=>e.h("svg",{class:"verified-icon",viewBox:"0 0 1024 1024",width:"14",height:"14"},e.h("path",{d:"m894.4 461.56-54.4-63.2c-10.4-12-18.8-34.4-18.8-50.4v-68c0-42.4-34.8-77.2-77.2-77.2h-68c-15.6 0-38.4-8.4-50.4-18.8l-63.2-54.4c-27.6-23.6-72.8-23.6-100.8 0l-62.8 54.8c-12 10-34.8 18.4-50.4 18.4h-69.2c-42.4 0-77.2 34.8-77.2 77.2v68.4c0 15.6-8.4 38-18.4 50l-54 63.6c-23.2 27.6-23.2 72.4 0 100l54 63.6c10 12 18.4 34.4 18.4 50v68.4c0 42.4 34.8 77.2 77.2 77.2h69.2c15.6 0 38.4 8.4 50.4 18.8l63.2 54.4c27.6 23.6 72.8 23.6 100.8 0l63.2-54.4c12-10.4 34.4-18.8 50.4-18.8h68c42.4 0 77.2-34.8 77.2-77.2v-68c0-15.6 8.4-38.4 18.8-50.4l54.4-63.2c23.2-27.6 23.2-73.2-.4-100.8zm-216-25.2-193.2 193.2a30 30 0 0 1-42.4 0l-96.8-96.8a30.16 30.16 0 0 1 0-42.4c11.6-11.6 30.8-11.6 42.4 0l75.6 75.6 172-172c11.6-11.6 30.8-11.6 42.4 0 11.6 11.6 11.6 30.8 0 42.4z",fill:"#27ae60"}))},emits:["submit","reply"],setup(t){const o=e.inject("config"),n=e.computed((()=>o.value.locale)),l=e.computed((()=>{let{link:e}=t.comment;return e?$(e)?e:`https://${e}`:""})),r=e.computed((()=>{var e;return t.comment.objectId===(null===(e=t.reply)||void 0===e?void 0:e.objectId)}));return{config:o,locale:n,isReplyingCurrent:r,link:l,timeAgo:J}}});const Re=["id"],je={class:"wl-user","aria-hidden":"true"},Ue=["src"],ze={class:"wl-card"},Ae={class:"wl-head"},Me=["href"],Te={key:1,class:"wl-nick"},De=["textContent"],Pe=["textContent"],Oe=["textContent"],_e=["title"],qe={class:"wl-meta","aria-hidden":"true"},He=["textContent"],We=["textContent"],Fe=["innerHTML"],Je={key:0,class:"wl-reply-wrapper"},Ke={key:1,class:"wl-quote"};Ve.render=function(t,o,n,l,r,a){const i=e.resolveComponent("VerifiedIcon"),c=e.resolveComponent("ReplyIcon"),s=e.resolveComponent("CommentBox"),m=e.resolveComponent("CommentCard",!0);return e.openBlock(),e.createElementBlock("div",{class:"wl-item",id:t.comment.objectId},[e.createElementVNode("div",je,[t.comment.avatar?(e.openBlock(),e.createElementBlock("img",{key:0,src:t.comment.avatar},null,8,Ue)):e.createCommentVNode("v-if",!0),t.comment.type?(e.openBlock(),e.createBlock(i,{key:1})):e.createCommentVNode("v-if",!0)]),e.createElementVNode("div",ze,[e.createElementVNode("div",Ae,[t.link?(e.openBlock(),e.createElementBlock("a",{key:0,class:"wl-nick",href:t.link,target:"_blank",rel:"nofollow noreferrer"},e.toDisplayString(t.comment.nick),9,Me)):(e.openBlock(),e.createElementBlock("span",Te,e.toDisplayString(t.comment.nick),1)),"administrator"===t.comment.type?(e.openBlock(),e.createElementBlock("span",{key:2,class:"wl-badge",textContent:e.toDisplayString(t.locale.admin)},null,8,De)):e.createCommentVNode("v-if",!0),t.comment.sticky?(e.openBlock(),e.createElementBlock("span",{key:3,class:"wl-badge",textContent:e.toDisplayString(t.locale.sticky)},null,8,Pe)):e.createCommentVNode("v-if",!0),e.createElementVNode("span",{class:"wl-time",textContent:e.toDisplayString(t.timeAgo(t.comment.insertedAt,t.locale))},null,8,Oe),e.createElementVNode("button",{class:e.normalizeClass(["wl-reply",{active:t.isReplyingCurrent}]),title:t.isReplyingCurrent?t.locale.cancelReply:t.locale.reply,onClick:o[0]||(o[0]=e=>t.$emit("reply",t.isReplyingCurrent?null:t.comment))},[e.createVNode(c)],10,_e)]),e.createElementVNode("div",qe,[t.comment.browser?(e.openBlock(),e.createElementBlock("span",{key:0,textContent:e.toDisplayString(t.comment.browser)},null,8,He)):e.createCommentVNode("v-if",!0),t.comment.os?(e.openBlock(),e.createElementBlock("span",{key:1,textContent:e.toDisplayString(t.comment.os)},null,8,We)):e.createCommentVNode("v-if",!0)]),e.createElementVNode("div",{class:"wl-content",innerHTML:t.comment.comment},null,8,Fe),t.isReplyingCurrent?(e.openBlock(),e.createElementBlock("div",Je,[e.createVNode(s,{replyId:t.comment.objectId,replyUser:t.comment.nick,rootId:t.rootId,onSubmit:o[1]||(o[1]=e=>t.$emit("submit",e)),onCancelReply:o[2]||(o[2]=e=>t.$emit("reply",null))},null,8,["replyId","replyUser","rootId"])])):e.createCommentVNode("v-if",!0),t.comment.children?(e.openBlock(),e.createElementBlock("div",Ke,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.comment.children,(n=>(e.openBlock(),e.createBlock(m,{key:n.objectId,comment:n,reply:t.reply,rootId:t.rootId,onReply:o[3]||(o[3]=e=>t.$emit("reply",e)),onSubmit:o[4]||(o[4]=e=>t.$emit("submit",e))},null,8,["comment","reply","rootId"])))),128))])):e.createCommentVNode("v-if",!0)])],8,Re)},Ve.__file="src/components/CommentCard.vue";var Ye=e.defineComponent({name:"WalineRoot",components:{CommentBox:Z,CommentCard:Ve,LoadingIcon:X},props:{serverURL:{type:String,required:!0},path:{type:String,required:!0},meta:{type:Array},requiredMeta:{type:Array},visitor:{type:Boolean},dark:{type:[String,Boolean]},lang:{type:String},locale:{type:Object},pageSize:{type:Number},wordLimit:{type:[Number,Array]},emoji:{type:Array},login:{type:String},highlighter:{type:Function},imageUploader:{type:[Function,!1]},texRender:{type:Function}},setup(t){const o=e.computed((()=>(({serverURL:e,path:t=location.pathname,lang:o="zh-CN",locale:n,emoji:l=["https://cdn.jsdelivr.net/gh/walinejs/emojis@1.0.0/weibo"],meta:r=["nick","mail","link"],requiredMeta:i=[],pageSize:d=10,wordLimit:u,imageUploader:p,highlighter:g,texRenderer:v,copyright:h=!0,login:f="enable",...y})=>{return{serverURL:I(e),path:N(t),lang:o,locale:{...k[o]||k["zh-CN"],..."object"==typeof n?n:{}},emoji:(w=l,Promise.all(w.map((e=>"string"==typeof e?L(B(e)):Promise.resolve(e)))).then((e=>{const t={tabs:[],map:{}};return e.forEach((e=>{const{name:o,folder:n,icon:l,prefix:r,type:a,items:i}=e;t.tabs.push({name:o,icon:x(l,n,r,a),items:i.map((e=>{const o=`${r||""}${e}`;return t.map[o]=x(e,n,r,a),o}))})})),t}))),wordLimit:Array.isArray(u)?u:!!u&&[0,u],meta:c(r),requiredMeta:c(i),pageSize:d,login:f,imageUploader:V(p,s),highlighter:V(g,a.default),texRenderer:V(v,m),copyright:h,...y};var w})(t))),{userInfo:n}=G(),l=e.ref("loading"),r=e.ref(0),i=e.ref(1),d=e.ref(0),u=e.ref([]),p=e.ref(null),g=e.computed((()=>{return"string"==typeof(e=o.value.dark)?"auto"===e?`@media(prefers-color-scheme:dark){body${R}}`:`${e}${R}`:!0===e?`:root${R}`:"";var e}));let v,h;const f=e=>{var t;const{serverURL:a,path:c,pageSize:s}=o.value,m=new AbortController;l.value="loading",null==v||v(),(({serverURL:e,path:t,page:o,pageSize:n,signal:l,token:r})=>{const a={};return r&&(a.Authorization=`Bearer ${r}`),fetch(`${e}/comment?path=${encodeURIComponent(t)}&pageSize=${n}&page=${o}`,{signal:l,headers:a}).then((e=>e.json())).then((e=>A(e,"comment list")))})({serverURL:a,path:c,pageSize:s,page:e,signal:m.signal,token:null===(t=n.value)||void 0===t?void 0:t.token}).then((t=>{l.value="success",r.value=t.count,u.value.push(...t.data),i.value=e,d.value=t.totalPages})).catch((e=>{"AbortError"!==e.name&&(console.error(e.message),l.value="error")})),v=m.abort.bind(m)},y=()=>{r.value=0,u.value=[],f(1)};return e.provide("config",o),e.watch((()=>t.path),y),e.onMounted((()=>{var t;y();const o=document.createElement("style");o.innerText=g.value,null===(t=document.querySelector("[data-waline]"))||void 0===t||t.appendChild(o),h=e.watchEffect((()=>{o.innerText=g.value}))})),e.onBeforeUnmount((()=>h())),{config:o,darkmodeStyle:g,i18n:e.computed((()=>o.value.locale)),status:l,count:r,page:i,totalPages:d,data:u,reply:p,loadMore:()=>f(i.value+1),refresh:y,onReply:e=>{p.value=e},onSubmit:e=>{if(e.rid){const t=u.value.find((({objectId:t})=>t===e.rid));if(!t)return;Array.isArray(t.children)||(t.children=[]),t.children.push(e)}else u.value.unshift(e)},version:"2.0.1"}}});const Ge={"data-waline":""},Qe={class:"wl-count"},Xe=["textContent"],Ze={class:"wl-cards"},et={key:1,class:"wl-action"},tt=["textContent"],ot={key:0,class:"wl-loading"},nt=["textContent"],lt={class:"wl-more"},rt=["textContent"],at={key:3,class:"wl-power"},it=e.createTextVNode(" Powered by "),ct=e.createElementVNode("a",{href:"https://github.com/walinejs/waline",target:"_blank",rel:"noreferrer"}," Waline ",-1);Ye.render=function(t,o,n,l,r,a){const i=e.resolveComponent("CommentBox"),c=e.resolveComponent("CommentCard"),s=e.resolveComponent("LoadingIcon");return e.openBlock(),e.createElementBlock("div",Ge,[t.reply?e.createCommentVNode("v-if",!0):(e.openBlock(),e.createBlock(i,{key:0,onSubmit:t.onSubmit},null,8,["onSubmit"])),e.createElementVNode("div",Qe,[t.count?(e.openBlock(),e.createElementBlock("span",{key:0,class:"wl-num",textContent:e.toDisplayString(t.count)},null,8,Xe)):e.createCommentVNode("v-if",!0),e.createTextVNode(" "+e.toDisplayString(t.i18n.comment),1)]),e.createElementVNode("div",Ze,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.data,(o=>(e.openBlock(),e.createBlock(c,{key:o.objectId,"root-id":o.objectId,comment:o,reply:t.reply,onReply:t.onReply,onSubmit:t.onSubmit},null,8,["root-id","comment","reply","onReply","onSubmit"])))),128))]),"error"===t.status?(e.openBlock(),e.createElementBlock("div",et,[e.createElementVNode("button",{type:"button",class:"wl-btn",onClick:o[0]||(o[0]=(...e)=>t.refresh&&t.refresh(...e)),textContent:e.toDisplayString(t.i18n.refresh)},null,8,tt)])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},["loading"===t.status?(e.openBlock(),e.createElementBlock("div",ot,[e.createVNode(s,{size:30})])):t.data.length?t.page<t.totalPages?(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[e.createCommentVNode(" Load more button "),e.createElementVNode("div",lt,[e.createElementVNode("button",{type:"button",class:"wl-btn",onClick:o[1]||(o[1]=(...e)=>t.loadMore&&t.loadMore(...e)),textContent:e.toDisplayString(t.i18n.more)},null,8,rt)])],2112)):e.createCommentVNode("v-if",!0):(e.openBlock(),e.createElementBlock("div",{key:1,class:"wl-empty",textContent:e.toDisplayString(t.i18n.sofa)},null,8,nt))],2112)),e.createCommentVNode(" Copyright Information "),t.config.copyright?(e.openBlock(),e.createElementBlock("div",at,[it,ct,e.createTextVNode(" v"+e.toDisplayString(t.version),1)])):e.createCommentVNode("v-if",!0)])},Ye.__file="src/components/Waline.vue";const st=(e,t)=>{t.forEach(((t,o)=>{t.innerText=e[o].toString()}))},mt=({serverURL:e,path:t=window.location.pathname,selector:o=".waline-pageview-count",update:n=!0})=>{const l=new AbortController,r=Array.from(document.querySelectorAll(o)),a=e=>{const o=W(e);return null!==o&&t!==o},i=o=>M({serverURL:e,paths:o.map((e=>W(e)||t)),signal:l.signal}).then((e=>st(e,o))).catch(z);if(n){const o=r.filter((e=>!a(e))),n=r.filter(a);T({serverURL:e,path:t}).then((e=>st(new Array(o.length).fill(e),o))),n.length&&i(n)}else i(r);return l.abort.bind(l)};exports.RecentComments=({el:e,serverURL:t,count:o})=>{var n;const l=D(e),r=new AbortController;return(({serverURL:e,count:t,signal:o,token:n})=>{const l={};return n&&(l.Authorization=`Bearer ${n}`),fetch(`${e}/comment?type=recent&count=${t}`,{signal:o,headers:l}).then((e=>e.json())).then((e=>A(e,"recent comment")))})({serverURL:t,count:o,signal:r.signal,token:null===(n=K())||void 0===n?void 0:n.token}).then((e=>l&&e.length?(l.innerHTML=`<ul class="wl-recent-list">${e.map((e=>`<li class="wl-recent-item"><a href="${e.url}">${e.nick}</a>:${e.comment}</li>`)).join("")}</ul>`,{comments:e,destroy:()=>{r.abort(),l.innerHTML=""}}):{comments:e,destroy:()=>r.abort()}))},exports.commentCount=Q,exports.defaultLang="zh-CN",exports.defaultTexRenderer=m,exports.defaultUploadImage=s,exports.getMeta=c,exports.init=({el:t="#waline",path:o=window.location.pathname,comment:n=!1,pageview:l=!1,...r})=>{const a=t?D(t):null;if(t&&!a)throw new Error("Option 'el' do not match any domElement!");if(!r.serverURL)throw new Error("Option 'serverURL' is missing!");const i=e.reactive({...r}),c=e.reactive({comment:n,pageview:l,path:o}),s=()=>{c.comment&&Q({serverURL:i.serverURL,path:c.path,selector:"string"==typeof c.comment?c.comment:void 0})},m=()=>{c.pageview&&mt({serverURL:i.serverURL,path:c.path,selector:"string"==typeof c.pageview?c.pageview:void 0})},d=a?e.createApp((()=>e.h(Ye,{path:c.path,...i}))):null;d&&d.mount(a),s(),m();const u=e.watchEffect(s),p=e.watchEffect(m);return{el:a,update:({comment:e,pageview:t,path:o=window.location.pathname,...n})=>{Object.entries(n).map((([e,t])=>{i[e]=t})),c.path=o,void 0!==e&&(c.comment=e),void 0!==t&&(c.pageview=t)},destroy:()=>{null==d||d.unmount(),u(),p()}}},exports.locales=k,exports.pageviewCount=mt,exports.version="2.0.1";
2
2
  //# sourceMappingURL=shim.js.map
@@ -319,7 +319,7 @@ interface WalineInitOptions extends Omit<WalineProps, 'path'> {
319
319
  */
320
320
  path?: string;
321
321
  }
322
- declare type WalineAbort = (reson: any) => void;
322
+ declare type WalineAbort = (reason?: any) => void;
323
323
 
324
324
  declare const getMeta: (meta: WalineMeta[]) => WalineMeta[];
325
325
  declare const defaultLang = "zh-CN";