@waline/client 3.7.0 → 3.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/comment.js +1 -1
- package/dist/component.js +2 -2
- package/dist/component.js.map +1 -1
- package/dist/pageview.js +1 -1
- package/dist/slim.js +2 -2
- package/dist/slim.js.map +1 -1
- package/dist/waline.css +1 -1
- package/dist/waline.css.map +1 -1
- package/dist/waline.js +21 -21
- package/dist/waline.js.map +1 -1
- package/dist/waline.umd.js +17 -17
- package/dist/waline.umd.js.map +1 -1
- package/package.json +6 -7
package/dist/comment.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const h=e=>`${e.replace(/\/?$/,"/")}api/`,i=(e,n="")=>{if(typeof e=="object"&&e.errno)throw new TypeError(`${n} failed with ${e.errno}: ${e.errmsg}`);return e},g=({serverURL:e,lang:n,paths:r,signal:o})=>fetch(`${h(e)}comment?type=count&url=${encodeURIComponent(r.join(","))}&lang=${n}`,{signal:o}).then(t=>t.json()).then(t=>i(t,"Get comment count").data),p=e=>{try{e=decodeURI(e)}catch{}return e},m=(e="")=>e.replace(/\/$/u,""),u=e=>/^(https?:)?\/\//.test(e),d=e=>{const n=m(e);return u(n)?n:`https://${n}`},$=e=>{e.name!=="AbortError"&&console.error(e.message)},f=e=>{const{path:n}=e.dataset;return n!=null&&n.length?n:null},v=({serverURL:e,path:n=window.location.pathname,selector:r=".waline-comment-count",lang:o=navigator.language})=>{const t=new AbortController,a=document.querySelectorAll(r);return a.length&&g({serverURL:d(e),paths:Array.from(a).map(c=>p(f(c)??n)),lang:o,signal:t.signal}).then(c=>{a.forEach((s,l)=>{s.innerText=c[l].toString()})}).catch($),t.abort.bind(t)},w="3.7.
|
|
1
|
+
const h=e=>`${e.replace(/\/?$/,"/")}api/`,i=(e,n="")=>{if(typeof e=="object"&&e.errno)throw new TypeError(`${n} failed with ${e.errno}: ${e.errmsg}`);return e},g=({serverURL:e,lang:n,paths:r,signal:o})=>fetch(`${h(e)}comment?type=count&url=${encodeURIComponent(r.join(","))}&lang=${n}`,{signal:o}).then(t=>t.json()).then(t=>i(t,"Get comment count").data),p=e=>{try{e=decodeURI(e)}catch{}return e},m=(e="")=>e.replace(/\/$/u,""),u=e=>/^(https?:)?\/\//.test(e),d=e=>{const n=m(e);return u(n)?n:`https://${n}`},$=e=>{e.name!=="AbortError"&&console.error(e.message)},f=e=>{const{path:n}=e.dataset;return n!=null&&n.length?n:null},v=({serverURL:e,path:n=window.location.pathname,selector:r=".waline-comment-count",lang:o=navigator.language})=>{const t=new AbortController,a=document.querySelectorAll(r);return a.length&&g({serverURL:d(e),paths:Array.from(a).map(c=>p(f(c)??n)),lang:o,signal:t.signal}).then(c=>{a.forEach((s,l)=>{s.innerText=c[l].toString()})}).catch($),t.abort.bind(t)},w="3.7.1";export{v as commentCount,w as version};
|
|
2
2
|
//# sourceMappingURL=comment.js.map
|
package/dist/component.js
CHANGED
|
@@ -7,6 +7,6 @@ import{h as L,defineComponent as re,inject as we,ref as z,computed as W,createEl
|
|
|
7
7
|
Номер текущего слова: $2`,"Анонимный","Dwarves","Hobbits","Ents","Wizards","Elves","Maiar","GIF","Поиск GIF","Персональные данные","Одобренный","Ожидающий","Спам","Нелипкий","самый старый","последний","самый горячий","Что вы думаете?"]),Ze=J(["Tên","Tên không được nhỏ hơn 3 ký tự.","E-Mail","Vui lòng xác nhập địa chỉ email của bạn.","Website","Tùy chọn","Hãy bình luận có văn hoá!","Chưa có bình luận","Gửi","Thích","Bỏ thích","Trả lời","Hủy bỏ","bình luận","Làm mới","Tải thêm...","Xem trước","Emoji","Tải lên hình ảnh","giây trước","phút trước","giờ trước","ngày trước","Vừa xong","Đang tải lên","Đăng nhập","đăng xuất","Quản trị viên","Dính","từ",`Bình luận phải có độ dài giữa $0 và $1 từ!
|
|
8
8
|
Số từ hiện tại: $2`,"Vô danh","Người lùn","Người tí hon","Thần rừng","Pháp sư","Tiên tộc","Maiar","Ảnh GIF","Tìm kiếm ảnh GIF","thông tin cá nhân","Đã được phê duyệt","Đang chờ đợi","Thư rác","Không dính","lâu đời nhất","muộn nhất","nóng nhất","What do you think?"]),Xe=J(["昵称","昵称不能少于3个字符","邮箱","请填写正确的邮件地址","网址","可选","欢迎评论","来发评论吧~","提交","喜欢","取消喜欢","回复","取消回复","评论","刷新","加载更多...","预览","表情","上传图片","秒前","分钟前","小时前","天前","刚刚","正在上传","登录","退出","博主","置顶","字",`评论字数应在 $0 到 $1 字之间!
|
|
9
9
|
当前字数:$2`,"匿名","潜水","冒泡","吐槽","活跃","话痨","传说","表情包","搜索表情包","个人资料","通过","待审核","垃圾","取消置顶","按倒序","按正序","按热度","你认为这篇文章怎么样?"]),pl=J(["暱稱","暱稱不能少於3個字元","郵箱","請填寫正確的郵件地址","網址","可選","歡迎留言","來發留言吧~","送出","喜歡","取消喜歡","回覆","取消回覆","留言","重整","載入更多...","預覽","表情","上傳圖片","秒前","分鐘前","小時前","天前","剛剛","正在上傳","登入","登出","管理者","置頂","字",`留言字數應在 $0 到 $1 字之間!
|
|
10
|
-
目前字數:$2`,"匿名","潛水","冒泡","吐槽","活躍","多話","傳說","表情包","搜尋表情包","個人資料","通過","待審核","垃圾","取消置頂","最早","最新","熱門","你認為這篇文章怎麼樣?"]);const Ye="en-US",$e={zh:Xe,"zh-cn":Xe,"zh-tw":pl,en:Pe,"en-us":Pe,fr:Ge,"fr-fr":Ge,jp:Oe,"jp-jp":Oe,"pt-br":dl,ru:Ke,"ru-ru":Ke,vi:Ze,"vi-vn":Ze,de:vl,es:qe,"es-mx":qe},gl=e=>$e[e.toLowerCase()]||$e[Ye.toLowerCase()],Je=e=>Object.keys($e).includes(e.toLowerCase())?e:Ye,Qe={latest:"insertedAt_desc",oldest:"insertedAt_asc",hottest:"like_desc"},hl=Object.keys(Qe),he=Symbol("waline-config"),fl={key:0,class:"wl-reaction"},yl=["textContent"],wl={class:"wl-reaction-list"},kl=["onClick"],bl={class:"wl-reaction-img"},Cl=["src","alt"],$l=["textContent"],Ll=["textContent"];var Il=re({__name:"ArticleReaction",setup(e){const a=Zt(),t=we(he),l=z(-1),r=z([]),m=W(()=>t.value.locale),M=W(()=>{const{reaction:v}=t.value;return v!=null&&v.length?v:null}),w=W(()=>{var v;const{path:A}=t.value;return((v=M.value)==null?void 0:v.map((U,$)=>({icon:U,desc:m.value[`reaction${$}`],active:a.value[A]===$})))??null});let b;const k=async()=>{const{serverURL:v,lang:A,path:U}=t.value;if(!M.value)return;const $=new AbortController;b=$.abort.bind($);const[y]=await Lt({serverURL:v,lang:A,paths:[U],type:M.value.map((S,R)=>`reaction${R}`),signal:$.signal});r.value=M.value.map((S,R)=>y[`reaction${R}`])},x=async v=>{if(l.value!==-1)return;const{serverURL:A,lang:U,path:$}=t.value,y=a.value[$];l.value=v,y!==void 0&&(await _e({serverURL:A,lang:U,path:$,type:`reaction${y}`,action:"desc"}),r.value[y]=Math.max(r.value[y]-1,0)),y!==v&&(await _e({serverURL:A,lang:U,path:$,type:`reaction${v}`}),r.value[v]=(r.value[v]||0)+1),y===v?delete a.value[$]:a.value[$]=v,l.value=-1};return de(()=>{oe(()=>[t.value.serverURL,t.value.path],()=>k())}),je(()=>{b==null||b()}),(v,A)=>w.value?(i(),o("div",fl,[s("div",{class:"wl-reaction-title",textContent:E(m.value.reactionTitle)},null,8,yl),s("ul",wl,[(i(!0),o(B,null,Z(w.value,({active:U,icon:$,desc:y},S)=>(i(),o("li",{key:S,class:P(["wl-reaction-item",{active:U}]),onClick:R=>x(S)},[s("div",bl,[s("img",{src:$,alt:y},null,8,Cl),l.value===S?(i(),Q(f(se),{key:0,class:"wl-reaction-loading"})):(i(),o("div",{key:1,class:"wl-reaction-votes",textContent:E(r.value[S]||0)},null,8,$l))]),s("div",{class:"wl-reaction-text",textContent:E(y)},null,8,Ll)],10,kl))),128))])])):C("v-if",!0)}});const El=["data-index"],Ml=["src","title","onClick"];var xl=re({__name:"ImageWall",props:{items:{default:()=>[]},columnWidth:{default:300},gap:{default:0}},emits:["insert"],setup(e){const a=e;let t=null;const l=te("wall"),r=z({}),m=z([]),M=()=>{const v=Math.floor((l.value.getBoundingClientRect().width+a.gap)/(a.columnWidth+a.gap));return v>0?v:1},w=v=>new Array(v).fill(null).map(()=>[]),b=async v=>{var A;if(v>=a.items.length)return;await Re();const U=Array.from(((A=l.value)==null?void 0:A.children)??[]).reduce(($,y)=>y.getBoundingClientRect().height<$.getBoundingClientRect().height?y:$);m.value[Number(U.dataset.index)].push(v),await b(v+1)},k=async(v=!1)=>{if(m.value.length===M()&&!v)return;m.value=w(M());const A=window.scrollY;await b(0),window.scrollTo({top:A})},x=v=>{r.value[v.target.src]=!0};return de(()=>{k(!0),t=new ResizeObserver(()=>{k()}),t.observe(l.value),ke(()=>[a.items],()=>{r.value={},k(!0)}),ke(()=>[a.columnWidth,a.gap],()=>{k()})}),dt(()=>{t.unobserve(l.value)}),(v,A)=>(i(),o("div",{ref_key:"wall",ref:l,class:"wl-gallery",style:ze({gap:`${e.gap}px`})},[(i(!0),o(B,null,Z(m.value,(U,$)=>(i(),o("div",{key:$,class:"wl-gallery-column","data-index":$,style:ze({gap:`${e.gap}px`})},[(i(!0),o(B,null,Z(U,y=>(i(),o(B,{key:y},[r.value[e.items[y].src]?C("v-if",!0):(i(),Q(f(se),{key:0,size:36,style:{margin:"20px auto"}})),s("img",{class:"wl-gallery-item",src:e.items[y].src,title:e.items[y].title,loading:"lazy",onLoad:x,onClick:S=>v.$emit("insert",``)},null,40,Ml)],64))),128))],12,El))),128))],4))}});const Al=e=>{try{e=decodeURI(e)}catch{}return e},et=(e="")=>e.replace(/\/$/u,""),tt=e=>/^(https?:)?\/\//.test(e),Sl=e=>{const a=et(e);return tt(a)?a:`https://${a}`},jl=e=>Array.isArray(e)?e:e?[0,e]:!1,ce=(e,a)=>e==null||e===!0?a:e===!1?null:e,zl=({serverURL:e,path:a=location.pathname,lang:t=typeof navigator>"u"?"en-US":navigator.language,locale:l,meta:r=["nick","mail","link"],requiredMeta:m=[],dark:M=!1,pageSize:w=10,wordLimit:b,noCopyright:k=!1,login:x="enable",recaptchaV3Key:v="",turnstileKey:A="",commentSorting:U="latest",emoji:$=Be,imageUploader:y,highlighter:S,texRenderer:R,search:c,reaction:K,...X})=>({serverURL:Sl(e),path:Al(a),lang:Je(t),locale:{...gl(Je(t)),...typeof l=="object"?l:{}},wordLimit:jl(b),meta:We(r),requiredMeta:We(m),dark:M,pageSize:w,commentSorting:U,login:x,noCopyright:k,recaptchaV3Key:v,turnstileKey:A,...X,reaction:K===!0?tl:K||null,imageUploader:ce(y,ll),highlighter:ce(S,ul),texRenderer:ce(R,al),emoji:ce($,Be),search:ce(c,nl(t))}),Le=e=>typeof e=="string",Ie="{--waline-white:#000;--waline-light-grey:#666;--waline-dark-grey:#999;--waline-color:#888;--waline-bg-color:#1e1e1e;--waline-bg-color-light:#272727;--waline-bg-color-hover: #444;--waline-border-color:#333;--waline-disable-bg-color:#444;--waline-disable-color:#272727;--waline-bq-color:#272727;--waline-info-bg-color:#272727;--waline-info-color:#666}",Rl=e=>Le(e)?e==="auto"?`@media(prefers-color-scheme:dark){body${Ie}}`:`${e}${Ie}`:e===!0?`:root${Ie}`:"",Ee=(e,a)=>{let t=e.toString();for(;t.length<a;)t="0"+t;return t},Vl=e=>{const a=Ee(e.getDate(),2),t=Ee(e.getMonth()+1,2);return`${Ee(e.getFullYear(),2)}-${t}-${a}`},Ul=(e,a,t)=>{if(!e)return"";const l=Le(e)?new Date(e.includes(" ")?e.replace(/-/g,"/"):e):e,r=a.getTime()-l.getTime(),m=Math.floor(r/(24*3600*1e3));if(m===0){const M=r%864e5,w=Math.floor(M/(3600*1e3));if(w===0){const b=M%36e5,k=Math.floor(b/(60*1e3));if(k===0){const x=b%6e4;return`${Math.round(x/1e3)} ${t.seconds}`}return`${k} ${t.minutes}`}return`${w} ${t.hours}`}return m<0?t.now:m<8?`${m} ${t.days}`:Vl(l)},_l=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,Hl=e=>_l.test(e),Tl="WALINE_EMOJI",lt=ne(Tl,{}),Fl=e=>/@[0-9]+\.[0-9]+\.[0-9]+/.test(e),Nl=e=>{const a=Fl(e);if(a){const t=lt.value[e];if(t)return Promise.resolve(t)}return fetch(`${e}/info.json`).then(t=>t.json()).then(t=>{const l={folder:e,...t};return a&&(lt.value[e]=l),l})},at=(e,a="",t="",l="")=>`${a?`${a}/`:""}${t}${e}${l?`.${l}`:""}`,Wl=e=>Promise.all(e?e.map(a=>Le(a)?Nl(et(a)):Promise.resolve(a)):[]).then(a=>{const t={tabs:[],map:{}};return a.forEach(l=>{const{name:r,folder:m,icon:M,prefix:w="",type:b,items:k}=l;t.tabs.push({name:r,icon:at(M,m,w,b),items:k.map(x=>{const v=`${w}${x}`;return t.map[v]=at(x,m,w,b),v})})}),t}),Bl=e=>e.type.includes("image"),nt=e=>{const a=Array.from(e).find(Bl);return a?a.getAsFile():null},Dl=/\$.*?\$/,Pl=/^\$(.*?)\$/,ql=/^(?:\s{0,3})\$\$((?:[^\n]|\n[^\n])+?)\n{0,1}\$\$/,Gl=e=>[{name:"blockMath",level:"block",tokenizer(a){const t=ql.exec(a);if(t!==null)return{type:"html",raw:t[0],text:e(!0,t[1])}}},{name:"inlineMath",level:"inline",start(a){const t=a.search(Dl);return t!==-1?t:a.length},tokenizer(a){const t=Pl.exec(a);if(t!==null)return{type:"html",raw:t[0],text:e(!1,t[1])}}}],it=(e="",a={})=>e.replace(/:(.+?):/g,(t,l)=>a[l]?`<img class="wl-emoji" src="${a[l]}" alt="${l}">`:t),Ol=(e,{emojiMap:a,highlighter:t,texRenderer:l})=>{const r=new At;if(r.setOptions({breaks:!0}),t&&r.use(St({highlight:t})),l){const m=Gl(l);r.use({extensions:m})}return r.parse(it(e,a))},Kl=e=>e.match(/[\w\d\s,.\u00C0-\u024F\u0400-\u04FF]+/giu),Zl=e=>e.match(/[\u4E00-\u9FD5]/gu),Xl=e=>{var a,t;return(((a=Kl(e))==null?void 0:a.reduce((l,r)=>l+(["",",","."].includes(r.trim())?0:r.trim().split(/\s+/u).length),0))??0)+(((t=Zl(e))==null?void 0:t.length)??0)},Yl=async()=>{const{userAgentData:e}=navigator;let a=navigator.userAgent;if(
|
|
11
|
-
`)}catch(h){alert(h.message),m.value=m.value.replace(n,"")}finally{d.value=!1}},fe=u=>{var n;if((n=u.dataTransfer)!=null&&n.items){const h=nt(u.dataTransfer.items);h&&q.value&&(me(h),u.preventDefault())}},st=u=>{if(u.clipboardData){const n=nt(u.clipboardData.items);n&&q.value&&me(n)}},ct=()=>{const u=x.value;u.files&&q.value&&me(u.files[0]).then(()=>{u.value=""})},Me=async()=>{var u;const{serverURL:n,lang:h,login:H,wordLimit:g,requiredMeta:D,recaptchaV3Key:N,turnstileKey:Y}=r.value,_={comment:ue.value,nick:M.value.nick,mail:M.value.mail,link:M.value.link,url:r.value.path,ua:await Yl()};if(!t.edit)if(w.value.token)_.nick=w.value.display_name,_.mail=w.value.email,_.link=w.value.url;else{if(H==="force")return;if(D.includes("nick")&&!_.nick){b.value.nick.focus(),alert(p.value.nickError);return}if(D.includes("mail")&&!_.mail||_.mail&&!Hl(_.mail)){b.value.mail.focus(),alert(p.value.mailError);return}_.nick||(_.nick=p.value.anonymous)}if(!_.comment){k.value.focus();return}if(!ee.value){alert(p.value.wordHint.replace("$0",g[0].toString()).replace("$1",g[1].toString()).replace("$2",V.value.toString()));return}_.comment=it(_.comment,S.value.map),t.replyId&&t.rootId&&(_.pid=t.replyId,_.rid=t.rootId,_.at=t.replyUser),d.value=!0;try{N&&(_.recaptchaV3=await Xt(N).execute("social")),Y&&(_.turnstile=await Yt(Y).execute("social"));const ve={serverURL:n,lang:h,token:w.value.token,comment:_},ye=await(t.edit?ge({objectId:t.edit.objectId,...ve}):It(ve));if(d.value=!1,ye.errmsg){alert(ye.errmsg);return}l("submit",ye.data),m.value="",I.value="",await Re(),t.replyId&&l("cancelReply"),(u=t.edit)!=null&&u.objectId&&l("cancelEdit")}catch(ve){d.value=!1,alert(ve.message)}},ut=u=>{u.preventDefault();const{lang:n,serverURL:h}=r.value;Et({serverURL:h,lang:n}).then(H=>{w.value=H,(H.remember?localStorage:sessionStorage).setItem("WALINE_USER",JSON.stringify(H)),l("log")})},mt=()=>{w.value={},localStorage.setItem("WALINE_USER","null"),sessionStorage.setItem("WALINE_USER","null"),l("log")},xe=u=>{u.preventDefault();const{lang:n,serverURL:h}=r.value,H=800,g=800,D=(window.innerWidth-H)/2,N=(window.innerHeight-g)/2,Y=new URLSearchParams({lng:n,token:w.value.token}),_=window.open(`${h}/ui/profile?${Y.toString()}`,"_blank",`width=${H},height=${g},left=${D},top=${N},scrollbars=no,resizable=no,status=no,location=no,toolbar=no,menubar=no`);_==null||_.postMessage({type:"TOKEN",data:w.value.token},"*")},vt=u=>{var n,h,H,g;!((n=v.value)!=null&&n.contains(u.target))&&!((h=A.value)!=null&&h.contains(u.target))&&(c.value=!1),!((H=U.value)!=null&&H.contains(u.target))&&!((g=$.value)!=null&&g.contains(u.target))&&(K.value=!1)},Ae=async u=>{var n;const{scrollTop:h,clientHeight:H,scrollHeight:g}=u.target,D=(H+h)/g,N=r.value.search,Y=((n=y.value)==null?void 0:n.value)??"";D<.9||T.loading||j.value||(T.loading=!0,(N.more&&T.list.length?await N.more(Y,T.list.length):await N.search(Y)).length?T.list=[...T.list,...N.more&&T.list.length?await N.more(Y,T.list.length):await N.search(Y)]:j.value=!0,T.loading=!1,setTimeout(()=>{u.target.scrollTop=h},50))},Se=bt(u=>{T.list=[],j.value=!1,Ae(u)},300);return Ue("click",vt),Ue("message",({data:u})=>{!u||u.type!=="profile"||(w.value={...w.value,...u.data},[localStorage,sessionStorage].filter(n=>n.getItem("WALINE_USER")).forEach(n=>{n.setItem("WALINE_USER",JSON.stringify(w))}))}),oe([r,V],([u,n])=>{const{wordLimit:h}=u;h?n<h[0]&&h[0]!==0?(ae.value=h[0],ee.value=!1):n>h[1]?(ae.value=h[1],ee.value=!1):(ae.value=h[1],ee.value=!0):(ae.value=0,ee.value=!0)}),ke(K,async u=>{var n;if(!u)return;const h=r.value.search;y.value&&(y.value.value=""),T.loading=!0,T.list=await(((n=h.default)==null?void 0:n.call(h))??h.search("")),T.loading=!1}),de(()=>{var u;(u=t.edit)!=null&&u.objectId&&(m.value=t.edit.orig),oe(()=>m.value,n=>{const{highlighter:h,texRenderer:H}=r.value;ue.value=n,I.value=Ol(n,{emojiMap:S.value.map,highlighter:h,texRenderer:H}),V.value=Xl(n),n?He(k.value):He.destroy(k.value)}),oe(()=>r.value.emoji,async n=>{S.value=await Wl(n)})}),(u,n)=>{var h,H;return i(),o("div",{key:f(w).token,class:"wl-comment"},[f(r).login!=="disable"&&F.value&&!((h=e.edit)!=null&&h.objectId)?(i(),o("div",Jl,[s("div",Ql,[s("button",{type:"submit",class:"wl-logout-btn",title:p.value.logout,onClick:mt},[O(f(Te),{size:14})],8,ea),s("a",{href:"#",class:"wl-login-nick","aria-label":"Profile",title:p.value.profile,onClick:xe},[s("img",{src:f(w).avatar,alt:"avatar"},null,8,la)],8,ta)]),s("a",{href:"#",class:"wl-login-nick","aria-label":"Profile",title:p.value.profile,onClick:xe,textContent:E(f(w).display_name)},null,8,aa)])):C("v-if",!0),s("div",na,[f(r).login!=="force"&&f(r).meta.length&&!F.value?(i(),o("div",{key:0,class:P(["wl-header",`item${f(r).meta.length}`])},[(i(!0),o(B,null,Z(f(r).meta,g=>(i(),o("div",{key:g,class:"wl-header-item"},[s("label",{for:`wl-${g}`,textContent:E(p.value[g]+(f(r).requiredMeta.includes(g)||!f(r).requiredMeta.length?"":`(${p.value.optional})`))},null,8,ia),pe(s("input",{id:`wl-${g}`,ref_for:!0,ref:D=>{D&&(b.value[g]=D)},"onUpdate:modelValue":D=>f(M)[g]=D,class:P(["wl-input",`wl-${g}`]),name:g,type:g==="mail"?"email":"text"},null,10,ra),[[gt,f(M)[g]]])]))),128))],2)):C("v-if",!0),pe(s("textarea",{id:"wl-edit",ref:"textarea","onUpdate:modelValue":n[0]||(n[0]=g=>ht(m)?m.value=g:null),class:"wl-editor",placeholder:e.replyUser?`@${e.replyUser}`:p.value.placeholder,onKeydown:ie,onDrop:fe,onPaste:st},null,40,oa),[[ft,f(m)]]),pe(s("div",sa,[n[7]||(n[7]=s("hr",null,null,-1)),s("h4",null,E(p.value.preview)+":",1),s("div",{class:"wl-content",innerHTML:I.value},null,8,ca)],512),[[Ve,X.value]]),s("div",ua,[s("div",ma,[s("a",va,[O(f(Ht))]),pe(s("button",{ref:"emoji-button",type:"button",class:P(["wl-action",{active:c.value}]),title:p.value.emoji,onClick:n[1]||(n[1]=g=>c.value=!c.value)},[O(f(Rt))],10,da),[[Ve,S.value.tabs.length]]),f(r).search?(i(),o("button",{key:0,ref:"gif-button",type:"button",class:P(["wl-action",{active:K.value}]),title:p.value.gif,onClick:n[2]||(n[2]=g=>K.value=!K.value)},[O(f(Bt))],10,pa)):C("v-if",!0),s("input",{id:"wl-image-upload",ref:"image-uploader",class:"upload","aria-hidden":"true",type:"file",accept:".png,.jpg,.jpeg,.webp,.bmp,.gif",onChange:ct},null,544),q.value?(i(),o("label",{key:1,for:"wl-image-upload",class:"wl-action",title:p.value.uploadImage,"aria-label":p.value.uploadImage},[O(f(Vt))],8,ga)):C("v-if",!0),s("button",{type:"button",class:P(["wl-action",{active:X.value}]),title:p.value.preview,onClick:n[3]||(n[3]=g=>X.value=!X.value)},[O(f(_t))],10,ha)]),s("div",fa,[n[9]||(n[9]=s("div",{class:"wl-captcha-container"},null,-1)),s("div",ya,[le(E(V.value)+" ",1),f(r).wordLimit?(i(),o("span",wa,[n[8]||(n[8]=le(" / ",-1)),s("span",{class:P({illegal:!ee.value}),textContent:E(ae.value)},null,10,ka)])):C("v-if",!0),le(" "+E(p.value.word),1)]),f(r).login!=="disable"&&!F.value?(i(),o("button",{key:0,type:"button",class:"wl-btn",onClick:ut,textContent:E(p.value.login)},null,8,ba)):C("v-if",!0),f(r).login!=="force"||F.value?(i(),o("button",{key:1,type:"submit",class:"primary wl-btn",title:"Cmd|Ctrl + Enter",disabled:d.value,onClick:Me},[d.value?(i(),Q(f(se),{key:0,size:16})):(i(),o(B,{key:1},[le(E(p.value.submit),1)],64))],8,Ca)):C("v-if",!0)]),s("div",{ref:"gif-popup",class:P(["wl-gif-popup",{display:K.value}])},[s("input",{ref:"gif-search",type:"text",placeholder:p.value.gifSearchPlaceholder,onInput:n[4]||(n[4]=(...g)=>f(Se)&&f(Se)(...g))},null,40,$a),T.list.length?(i(),Q(xl,{key:0,items:T.list,"column-width":200,gap:6,onInsert:n[5]||(n[5]=g=>G(g)),onScroll:Ae},null,8,["items"])):C("v-if",!0),T.loading?(i(),o("div",La,[O(f(se),{size:30})])):C("v-if",!0)],2),s("div",{ref:"emoji-popup",class:P(["wl-emoji-popup",{display:c.value}])},[(i(!0),o(B,null,Z(S.value.tabs,(g,D)=>(i(),o(B,{key:g.name},[D===R.value?(i(),o("div",Ia,[(i(!0),o(B,null,Z(g.items,N=>(i(),o("button",{key:N,type:"button",title:N,onClick:Y=>G(`:${N}:`)},[c.value?(i(),o("img",{key:0,class:"wl-emoji",src:S.value.map[N],alt:N,loading:"lazy",referrerPolicy:"no-referrer"},null,8,Ma)):C("v-if",!0)],8,Ea))),128))])):C("v-if",!0)],64))),128)),S.value.tabs.length>1?(i(),o("div",xa,[(i(!0),o(B,null,Z(S.value.tabs,(g,D)=>(i(),o("button",{key:g.name,type:"button",class:P(["wl-tab",{active:R.value===D}]),onClick:N=>R.value=D},[s("img",{class:"wl-emoji",src:g.icon,alt:g.name,title:g.name,loading:"lazy",referrerPolicy:"no-referrer"},null,8,Sa)],10,Aa))),128))])):C("v-if",!0)],2)])]),e.replyId||(H=e.edit)!=null&&H.objectId?(i(),o("button",{key:1,type:"button",class:"wl-close",title:p.value.cancelReply,onClick:n[6]||(n[6]=g=>e.replyId?l("cancelReply"):l("cancelEdit"))},[O(f(Te),{size:24})],8,ja)):C("v-if",!0)])}}});const za=["id"],Ra={class:"wl-user","aria-hidden":"true"},Va=["src"],Ua={class:"wl-card"},_a={class:"wl-head"},Ha=["href"],Ta={key:1,class:"wl-nick"},Fa=["textContent"],Na=["textContent"],Wa=["textContent"],Ba=["textContent"],Da={class:"wl-comment-actions"},Pa=["title"],qa=["title"],Ga={class:"wl-meta","aria-hidden":"true"},Oa=["data-value","textContent"],Ka={key:0,class:"wl-content"},Za={key:0},Xa=["href"],Ya=["innerHTML"],Ja={key:1,class:"wl-admin-actions"},Qa={class:"wl-comment-status"},en=["disabled","onClick","textContent"],tn={key:3,class:"wl-quote"};var ln=re({__name:"CommentCard",props:{comment:{},edit:{},rootId:{},reply:{}},emits:["log","submit","delete","like","sticky","edit","reply","status"],setup(e,{emit:a}){const t=e,l=a,r=["approved","waiting","spam"],m=we(he),M=Fe(),w=Ct(),b=be(),k=W(()=>m.value.locale),x=W(()=>{const{link:R}=t.comment;return R?tt(R)?R:`https://${R}`:""}),v=W(()=>M.value.includes(t.comment.objectId)),A=W(()=>Ul(new Date(t.comment.time),w.value,k.value)),U=W(()=>b.value.type==="administrator"),$=W(()=>t.comment.user_id&&b.value.objectId===t.comment.user_id),y=W(()=>{var R;return t.comment.objectId===((R=t.reply)==null?void 0:R.objectId)}),S=W(()=>{var R;return t.comment.objectId===((R=t.edit)==null?void 0:R.objectId)});return(R,c)=>{var K;const X=yt("CommentCard",!0);return i(),o("div",{id:e.comment.objectId.toString(),class:"wl-card-item"},[s("div",Ra,[e.comment.avatar?(i(),o("img",{key:0,class:"wl-user-avatar",src:e.comment.avatar,alt:""},null,8,Va)):C("v-if",!0),e.comment.type==="guest"?(i(),Q(f(Nt),{key:1})):C("v-if",!0),e.comment.type==="administrator"?(i(),Q(f(Wt),{key:2})):C("v-if",!0)]),s("div",Ua,[s("div",_a,[x.value?(i(),o("a",{key:0,class:"wl-nick",href:x.value,target:"_blank",rel:"nofollow noopener noreferrer"},E(e.comment.nick),9,Ha)):(i(),o("span",Ta,E(e.comment.nick),1)),e.comment.label?(i(),o("span",{key:2,class:"wl-badge",textContent:E(e.comment.label)},null,8,Fa)):C("v-if",!0),e.comment.sticky?(i(),o("span",{key:3,class:"wl-badge",textContent:E(k.value.sticky)},null,8,Na)):C("v-if",!0),typeof e.comment.level=="number"?(i(),o("span",{key:4,class:P(`wl-badge level${e.comment.level}`),textContent:E(k.value[`level${e.comment.level}`]||`Level ${e.comment.level}`)},null,10,Wa)):C("v-if",!0),s("span",{class:"wl-time",textContent:E(A.value)},null,8,Ba),s("div",Da,[U.value||$.value?(i(),o(B,{key:0},[s("button",{type:"button",class:"wl-edit",onClick:c[0]||(c[0]=I=>l("edit",e.comment))},[O(f(Ft))]),s("button",{type:"button",class:"wl-delete",onClick:c[1]||(c[1]=I=>l("delete",e.comment))},[O(f(zt))])],64)):C("v-if",!0),s("button",{type:"button",class:"wl-like",title:v.value?k.value.cancelLike:k.value.like,onClick:c[2]||(c[2]=I=>l("like",e.comment))},[O(f(Ut),{active:v.value},null,8,["active"]),le(" "+E("like"in e.comment?e.comment.like:""),1)],8,Pa),s("button",{type:"button",class:P(["wl-reply",{active:y.value}]),title:y.value?k.value.cancelReply:k.value.reply,onClick:c[3]||(c[3]=I=>l("reply",y.value?null:e.comment))},[O(f(Tt))],10,qa)])]),s("div",Ga,[(i(),o(B,null,Z(["addr","browser","os"],I=>(i(),o(B,null,[e.comment[I]?(i(),o("span",{key:I,class:P(`wl-${I}`),"data-value":e.comment[I],textContent:E(e.comment[I])},null,10,Oa)):C("v-if",!0)],64))),64))]),S.value?C("v-if",!0):(i(),o("div",Ka,["reply_user"in e.comment&&e.comment.reply_user?(i(),o("p",Za,[s("a",{href:"#"+e.comment.pid},"@"+E(e.comment.reply_user.nick),9,Xa),c[17]||(c[17]=s("span",null,": ",-1))])):C("v-if",!0),s("div",{innerHTML:e.comment.comment},null,8,Ya)])),U.value&&!S.value?(i(),o("div",Ja,[s("span",Qa,[(i(),o(B,null,Z(r,I=>s("button",{key:I,type:"submit",class:P(`wl-btn wl-${I}`),disabled:e.comment.status===I,onClick:V=>l("status",{status:I,comment:e.comment}),textContent:E(k.value[I])},null,10,en)),64))]),U.value&&!("rid"in e.comment)?(i(),o("button",{key:0,type:"submit",class:"wl-btn wl-sticky",onClick:c[4]||(c[4]=I=>l("sticky",e.comment))},E(e.comment.sticky?k.value.unsticky:k.value.sticky),1)):C("v-if",!0)])):C("v-if",!0),y.value||S.value?(i(),o("div",{key:2,class:P({"wl-reply-wrapper":y.value,"wl-edit-wrapper":S.value})},[O(rt,{edit:e.edit,"reply-id":(K=e.reply)==null?void 0:K.objectId,"reply-user":e.comment.nick,"root-id":e.rootId,onLog:c[5]||(c[5]=I=>l("log")),onCancelReply:c[6]||(c[6]=I=>l("reply",null)),onCancelEdit:c[7]||(c[7]=I=>l("edit",null)),onSubmit:c[8]||(c[8]=I=>l("submit",I))},null,8,["edit","reply-id","reply-user","root-id"])],2)):C("v-if",!0),"children"in e.comment?(i(),o("div",tn,[(i(!0),o(B,null,Z(e.comment.children,I=>(i(),Q(X,{key:I.objectId,comment:I,reply:e.reply,edit:e.edit,"root-id":e.rootId,onLog:c[9]||(c[9]=V=>l("log")),onDelete:c[10]||(c[10]=V=>l("delete",V)),onEdit:c[11]||(c[11]=V=>l("edit",V)),onLike:c[12]||(c[12]=V=>l("like",V)),onReply:c[13]||(c[13]=V=>l("reply",V)),onStatus:c[14]||(c[14]=V=>l("status",V)),onSticky:c[15]||(c[15]=V=>l("sticky",V)),onSubmit:c[16]||(c[16]=V=>l("submit",V))},null,8,["comment","reply","edit","root-id"]))),128))])):C("v-if",!0)])],8,za)}}});const ot="3.7.0",an={"data-waline":""},nn={class:"wl-meta-head"},rn={class:"wl-count"},on=["textContent"],sn={class:"wl-sort"},cn=["onClick"],un={class:"wl-cards"},mn={key:1,class:"wl-operation"},vn=["textContent"],dn={key:2,class:"wl-loading"},pn=["textContent"],gn={key:4,class:"wl-operation"},hn=["textContent"],fn={key:5,class:"wl-power"};var yn=re({__name:"WalineComment",props:{serverURL:{},path:{},meta:{},requiredMeta:{},wordLimit:{},pageSize:{},lang:{},locale:{},commentSorting:{},dark:{type:[String,Boolean]},login:{},noCopyright:{type:Boolean},recaptchaV3Key:{},turnstileKey:{},reaction:{type:[Array,Boolean]},emoji:{},search:{},highlighter:{type:Function},imageUploader:{type:Function},texRenderer:{type:Function}},setup(e){const a=e,t=be(),l=Fe(),r=z("loading"),m=z(0),M=z(1),w=z(0),b=W(()=>zl(a)),k=z(b.value.commentSorting),x=z([]),v=z(null),A=z(null),U=W(()=>Rl(b.value.dark)),$=W(()=>b.value.locale);$t(U,{id:"waline-darkmode"});let y=null;const S=d=>{const{serverURL:j,path:p,pageSize:F}=b.value,q=new AbortController;r.value="loading",y==null||y(),xt({serverURL:j,lang:b.value.lang,path:p,pageSize:F,sortBy:Qe[k.value],page:d,signal:q.signal,token:t.value.token}).then(G=>{r.value="success",m.value=G.count,x.value.push(...G.data),M.value=d,w.value=G.totalPages}).catch(G=>{G.name!=="AbortError"&&(console.error(G.message),r.value="error")}),y=q.abort.bind(q)},R=()=>{S(M.value+1)},c=()=>{m.value=0,x.value=[],S(1)},K=d=>{k.value!==d&&(k.value=d,c())},X=d=>{v.value=d},I=d=>{A.value=d},V=d=>{if(A.value)A.value.comment=d.comment,A.value.orig=d.orig;else if("rid"in d){const j=x.value.find(({objectId:p})=>p===d.rid);if(!j)return;Array.isArray(j.children)||(j.children=[]),j.children.push(d)}else x.value.unshift(d),m.value+=1},T=async({comment:d,status:j})=>{if(d.status===j)return;const{serverURL:p,lang:F}=b.value;await ge({serverURL:p,lang:F,token:t.value.token,objectId:d.objectId,comment:{status:j}}),d.status=j},ae=async d=>{if("rid"in d)return;const{serverURL:j,lang:p}=b.value;await ge({serverURL:j,lang:p,token:t.value.token,objectId:d.objectId,comment:{sticky:d.sticky?0:1}}),d.sticky=!d.sticky},ee=async({objectId:d})=>{if(!confirm("Are you sure you want to delete this comment?"))return;const{serverURL:j,lang:p}=b.value;await Mt({serverURL:j,lang:p,token:t.value.token,objectId:d}),x.value.some((F,q)=>F.objectId===d?(x.value=x.value.filter((G,ie)=>ie!==q),!0):F.children.some((G,ie)=>G.objectId===d?(x.value[q].children=F.children.filter((me,fe)=>fe!==ie),!0):!1))},ue=async d=>{const{serverURL:j,lang:p}=b.value,{objectId:F}=d,q=l.value.includes(F);await ge({serverURL:j,lang:p,objectId:F,token:t.value.token,comment:{like:!q}}),q?l.value=l.value.filter(G=>G!==F):(l.value=[...l.value,F],l.value.length>50&&(l.value=l.value.slice(-50))),d.like=Math.max(0,(d.like||0)+(q?-1:1))};return wt(he,b),de(()=>{oe(()=>[a.serverURL,a.path],()=>{c()})}),je(()=>{y==null||y()}),(d,j)=>(i(),o("div",an,[O(Il),!v.value&&!A.value?(i(),Q(rt,{key:0,onLog:c,onSubmit:V})):C("v-if",!0),s("div",nn,[s("div",rn,[m.value?(i(),o("span",{key:0,class:"wl-num",textContent:E(m.value)},null,8,on)):C("v-if",!0),le(" "+E($.value.comment),1)]),s("ul",sn,[(i(!0),o(B,null,Z(f(hl),p=>(i(),o("li",{key:p,class:P([p===k.value?"active":""]),onClick:F=>K(p)},E($.value[p]),11,cn))),128))])]),s("div",un,[(i(!0),o(B,null,Z(x.value,p=>(i(),Q(ln,{key:p.objectId,"root-id":p.objectId,comment:p,reply:v.value,edit:A.value,onLog:c,onReply:X,onEdit:I,onSubmit:V,onStatus:T,onDelete:ee,onSticky:ae,onLike:ue},null,8,["root-id","comment","reply","edit"]))),128))]),r.value==="error"?(i(),o("div",mn,[s("button",{type:"button",class:"wl-btn",onClick:c,textContent:E($.value.refresh)},null,8,vn)])):r.value==="loading"?(i(),o("div",dn,[O(f(se),{size:30})])):x.value.length?M.value<w.value?(i(),o("div",gn,[s("button",{type:"button",class:"wl-btn",onClick:R,textContent:E($.value.more)},null,8,hn)])):C("v-if",!0):(i(),o("div",{key:3,class:"wl-empty",textContent:E($.value.sofa)},null,8,pn)),b.value.noCopyright?C("v-if",!0):(i(),o("div",fn,[j[0]||(j[0]=le(" Powered by ",-1)),j[1]||(j[1]=s("a",{href:"https://github.com/walinejs/waline",target:"_blank",rel:"noopener noreferrer"}," Waline ",-1)),le(" v"+E(f(ot)),1)]))]))}});export{yn as Waline,ot as version};
|
|
10
|
+
目前字數:$2`,"匿名","潛水","冒泡","吐槽","活躍","多話","傳說","表情包","搜尋表情包","個人資料","通過","待審核","垃圾","取消置頂","最早","最新","熱門","你認為這篇文章怎麼樣?"]);const Ye="en-US",$e={zh:Xe,"zh-cn":Xe,"zh-tw":pl,en:Pe,"en-us":Pe,fr:Ge,"fr-fr":Ge,jp:Oe,"jp-jp":Oe,"pt-br":dl,ru:Ke,"ru-ru":Ke,vi:Ze,"vi-vn":Ze,de:vl,es:qe,"es-mx":qe},gl=e=>$e[e.toLowerCase()]||$e[Ye.toLowerCase()],Je=e=>Object.keys($e).includes(e.toLowerCase())?e:Ye,Qe={latest:"insertedAt_desc",oldest:"insertedAt_asc",hottest:"like_desc"},hl=Object.keys(Qe),he=Symbol("waline-config"),fl={key:0,class:"wl-reaction"},yl=["textContent"],wl={class:"wl-reaction-list"},kl=["onClick"],bl={class:"wl-reaction-img"},Cl=["src","alt"],$l=["textContent"],Ll=["textContent"];var Il=re({__name:"ArticleReaction",setup(e){const a=Zt(),t=we(he),l=z(-1),r=z([]),m=W(()=>t.value.locale),M=W(()=>{const{reaction:v}=t.value;return v!=null&&v.length?v:null}),w=W(()=>{var v;const{path:A}=t.value;return((v=M.value)==null?void 0:v.map((U,$)=>({icon:U,desc:m.value[`reaction${$}`],active:a.value[A]===$})))??null});let b;const k=async()=>{const{serverURL:v,lang:A,path:U}=t.value;if(!M.value)return;const $=new AbortController;b=$.abort.bind($);const[y]=await Lt({serverURL:v,lang:A,paths:[U],type:M.value.map((S,R)=>`reaction${R}`),signal:$.signal});r.value=M.value.map((S,R)=>y[`reaction${R}`])},x=async v=>{if(l.value!==-1)return;const{serverURL:A,lang:U,path:$}=t.value,y=a.value[$];l.value=v,y!==void 0&&(await _e({serverURL:A,lang:U,path:$,type:`reaction${y}`,action:"desc"}),r.value[y]=Math.max(r.value[y]-1,0)),y!==v&&(await _e({serverURL:A,lang:U,path:$,type:`reaction${v}`}),r.value[v]=(r.value[v]||0)+1),y===v?delete a.value[$]:a.value[$]=v,l.value=-1};return de(()=>{oe(()=>[t.value.serverURL,t.value.path],()=>k())}),je(()=>{b==null||b()}),(v,A)=>w.value?(i(),o("div",fl,[s("div",{class:"wl-reaction-title",textContent:E(m.value.reactionTitle)},null,8,yl),s("ul",wl,[(i(!0),o(B,null,Z(w.value,({active:U,icon:$,desc:y},S)=>(i(),o("li",{key:S,class:P(["wl-reaction-item",{active:U}]),onClick:R=>x(S)},[s("div",bl,[s("img",{src:$,alt:y},null,8,Cl),l.value===S?(i(),Q(f(se),{key:0,class:"wl-reaction-loading"})):(i(),o("div",{key:1,class:"wl-reaction-votes",textContent:E(r.value[S]||0)},null,8,$l))]),s("div",{class:"wl-reaction-text",textContent:E(y)},null,8,Ll)],10,kl))),128))])])):C("v-if",!0)}});const El=["data-index"],Ml=["src","title","onClick"];var xl=re({__name:"ImageWall",props:{items:{default:()=>[]},columnWidth:{default:300},gap:{default:0}},emits:["insert"],setup(e){const a=e;let t=null;const l=te("wall"),r=z({}),m=z([]),M=()=>{const v=Math.floor((l.value.getBoundingClientRect().width+a.gap)/(a.columnWidth+a.gap));return v>0?v:1},w=v=>new Array(v).fill(null).map(()=>[]),b=async v=>{var A;if(v>=a.items.length)return;await Re();const U=Array.from(((A=l.value)==null?void 0:A.children)??[]).reduce(($,y)=>y.getBoundingClientRect().height<$.getBoundingClientRect().height?y:$);m.value[Number(U.dataset.index)].push(v),await b(v+1)},k=async(v=!1)=>{if(m.value.length===M()&&!v)return;m.value=w(M());const A=window.scrollY;await b(0),window.scrollTo({top:A})},x=v=>{r.value[v.target.src]=!0};return de(()=>{k(!0),t=new ResizeObserver(()=>{k()}),t.observe(l.value),ke(()=>[a.items],()=>{r.value={},k(!0)}),ke(()=>[a.columnWidth,a.gap],()=>{k()})}),dt(()=>{t.unobserve(l.value)}),(v,A)=>(i(),o("div",{ref_key:"wall",ref:l,class:"wl-gallery",style:ze({gap:`${e.gap}px`})},[(i(!0),o(B,null,Z(m.value,(U,$)=>(i(),o("div",{key:$,class:"wl-gallery-column","data-index":$,style:ze({gap:`${e.gap}px`})},[(i(!0),o(B,null,Z(U,y=>(i(),o(B,{key:y},[r.value[e.items[y].src]?C("v-if",!0):(i(),Q(f(se),{key:0,size:36,style:{margin:"20px auto"}})),s("img",{class:"wl-gallery-item",src:e.items[y].src,title:e.items[y].title,loading:"lazy",onLoad:x,onClick:S=>v.$emit("insert",``)},null,40,Ml)],64))),128))],12,El))),128))],4))}});const Al=e=>{try{e=decodeURI(e)}catch{}return e},et=(e="")=>e.replace(/\/$/u,""),tt=e=>/^(https?:)?\/\//.test(e),Sl=e=>{const a=et(e);return tt(a)?a:`https://${a}`},jl=e=>Array.isArray(e)?e:e?[0,e]:!1,ce=(e,a)=>e==null||e===!0?a:e===!1?null:e,zl=({serverURL:e,path:a=location.pathname,lang:t=typeof navigator>"u"?"en-US":navigator.language,locale:l,meta:r=["nick","mail","link"],requiredMeta:m=[],dark:M=!1,pageSize:w=10,wordLimit:b,noCopyright:k=!1,login:x="enable",recaptchaV3Key:v="",turnstileKey:A="",commentSorting:U="latest",emoji:$=Be,imageUploader:y,highlighter:S,texRenderer:R,search:c,reaction:K,...X})=>({serverURL:Sl(e),path:Al(a),lang:Je(t),locale:{...gl(Je(t)),...typeof l=="object"?l:{}},wordLimit:jl(b),meta:We(r),requiredMeta:We(m),dark:M,pageSize:w,commentSorting:U,login:x,noCopyright:k,recaptchaV3Key:v,turnstileKey:A,...X,reaction:K===!0?tl:K||null,imageUploader:ce(y,ll),highlighter:ce(S,ul),texRenderer:ce(R,al),emoji:ce($,Be),search:ce(c,nl(t))}),Le=e=>typeof e=="string",Ie="{--waline-white:#000;--waline-light-grey:#666;--waline-dark-grey:#999;--waline-color:#888;--waline-bg-color:#1e1e1e;--waline-bg-color-light:#272727;--waline-bg-color-hover: #444;--waline-border-color:#333;--waline-disable-bg-color:#444;--waline-disable-color:#272727;--waline-bq-color:#272727;--waline-info-bg-color:#272727;--waline-info-color:#666}",Rl=e=>Le(e)?e==="auto"?`@media(prefers-color-scheme:dark){body${Ie}}`:`${e}${Ie}`:e===!0?`:root${Ie}`:"",Ee=(e,a)=>{let t=e.toString();for(;t.length<a;)t="0"+t;return t},Vl=e=>{const a=Ee(e.getDate(),2),t=Ee(e.getMonth()+1,2);return`${Ee(e.getFullYear(),2)}-${t}-${a}`},Ul=(e,a,t)=>{if(!e)return"";const l=Le(e)?new Date(e.includes(" ")?e.replace(/-/g,"/"):e):e,r=a.getTime()-l.getTime(),m=Math.floor(r/(24*3600*1e3));if(m===0){const M=r%864e5,w=Math.floor(M/(3600*1e3));if(w===0){const b=M%36e5,k=Math.floor(b/(60*1e3));if(k===0){const x=b%6e4;return`${Math.round(x/1e3)} ${t.seconds}`}return`${k} ${t.minutes}`}return`${w} ${t.hours}`}return m<0?t.now:m<8?`${m} ${t.days}`:Vl(l)},_l=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,Hl=e=>_l.test(e),Tl="WALINE_EMOJI",lt=ne(Tl,{}),Fl=e=>/@[0-9]+\.[0-9]+\.[0-9]+/.test(e),Nl=e=>{const a=Fl(e);if(a){const t=lt.value[e];if(t)return Promise.resolve(t)}return fetch(`${e}/info.json`).then(t=>t.json()).then(t=>{const l={folder:e,...t};return a&&(lt.value[e]=l),l})},at=(e,a="",t="",l="")=>`${a?`${a}/`:""}${t}${e}${l?`.${l}`:""}`,Wl=e=>Promise.all(e?e.map(a=>Le(a)?Nl(et(a)):Promise.resolve(a)):[]).then(a=>{const t={tabs:[],map:{}};return a.forEach(l=>{const{name:r,folder:m,icon:M,prefix:w="",type:b,items:k}=l;t.tabs.push({name:r,icon:at(M,m,w,b),items:k.map(x=>{const v=`${w}${x}`;return t.map[v]=at(x,m,w,b),v})})}),t}),Bl=e=>e.type.includes("image"),nt=e=>{const a=Array.from(e).find(Bl);return a?a.getAsFile():null},Dl=/\$.*?\$/,Pl=/^\$(.*?)\$/,ql=/^(?:\s{0,3})\$\$((?:[^\n]|\n[^\n])+?)\n{0,1}\$\$/,Gl=e=>[{name:"blockMath",level:"block",tokenizer(a){const t=ql.exec(a);if(t!==null)return{type:"html",raw:t[0],text:e(!0,t[1])}}},{name:"inlineMath",level:"inline",start(a){const t=a.search(Dl);return t!==-1?t:a.length},tokenizer(a){const t=Pl.exec(a);if(t!==null)return{type:"html",raw:t[0],text:e(!1,t[1])}}}],it=(e="",a={})=>e.replace(/:(.+?):/g,(t,l)=>a[l]?`<img class="wl-emoji" src="${a[l]}" alt="${l}">`:t),Ol=(e,{emojiMap:a,highlighter:t,texRenderer:l})=>{const r=new At;if(r.setOptions({breaks:!0}),t&&r.use(St({highlight:t})),l){const m=Gl(l);r.use({extensions:m})}return r.parse(it(e,a))},Kl=e=>e.match(/[\w\d\s,.\u00C0-\u024F\u0400-\u04FF]+/giu),Zl=e=>e.match(/[\u4E00-\u9FD5]/gu),Xl=e=>{var a,t;return(((a=Kl(e))==null?void 0:a.reduce((l,r)=>l+(["",",","."].includes(r.trim())?0:r.trim().split(/\s+/u).length),0))??0)+(((t=Zl(e))==null?void 0:t.length)??0)},Yl=async()=>{const{userAgentData:e}=navigator;let a=navigator.userAgent;if((e==null?void 0:e.platform)!=="Windows")return a;const{platformVersion:t}=await e.getHighEntropyValues(["platformVersion"]);return t&&parseInt(t.split(".")[0])>=13&&(a=a.replace("Windows NT 10.0","Windows NT 11.0")),a},Jl={key:0,class:"wl-login-info"},Ql={class:"wl-avatar"},ea=["title"],ta=["title"],la=["src"],aa=["title","textContent"],na={class:"wl-panel"},ia=["for","textContent"],ra=["id","onUpdate:modelValue","name","type"],oa=["placeholder"],sa={class:"wl-preview"},ca=["innerHTML"],ua={class:"wl-footer"},ma={class:"wl-actions"},va={href:"https://guides.github.com/features/mastering-markdown/",title:"Markdown Guide","aria-label":"Markdown is supported",class:"wl-action",target:"_blank",rel:"noopener noreferrer"},da=["title"],pa=["title"],ga=["title","aria-label"],ha=["title"],fa={class:"wl-info"},ya={class:"wl-text-number"},wa={key:0},ka=["textContent"],ba=["textContent"],Ca=["disabled"],$a=["placeholder"],La={key:1,class:"wl-loading"},Ia={key:0,class:"wl-tab-wrapper"},Ea=["title","onClick"],Ma=["src","alt"],xa={key:0,class:"wl-tabs"},Aa=["onClick"],Sa=["src","alt","title"],ja=["title"];var rt=re({__name:"CommentBox",props:{edit:{},rootId:{},replyId:{},replyUser:{}},emits:["log","cancelEdit","cancelReply","submit"],setup(e,{emit:a}){const t=e,l=a,r=we(he),m=Pt(),M=Dt(),w=be(),b=z({}),k=te("textarea"),x=te("image-uploader"),v=te("emoji-button"),A=te("emoji-popup"),U=te("gif-button"),$=te("gif-popup"),y=te("gif-search"),S=z({tabs:[],map:{}}),R=z(0),c=z(!1),K=z(!1),X=z(!1),I=z(""),V=z(0),T=pt({loading:!0,list:[]}),ae=z(0),ee=z(!1),ue=z(""),d=z(!1),j=z(!1),p=W(()=>r.value.locale),F=W(()=>!!w.value.token),q=W(()=>r.value.imageUploader!==null),G=u=>{const n=k.value,h=n.selectionStart,H=n.selectionEnd||0,g=n.scrollTop;m.value=n.value.substring(0,h)+u+n.value.substring(H,n.value.length),n.focus(),n.selectionStart=h+u.length,n.selectionEnd=h+u.length,n.scrollTop=g},ie=({key:u,ctrlKey:n,metaKey:h})=>{d.value||(n||h)&&u==="Enter"&&Me()},me=async u=>{const n=`![${r.value.locale.uploading} ${u.name}]()`;G(n),d.value=!0;try{const h=await r.value.imageUploader(u);m.value=m.value.replace(n,`\r
|
|
11
|
+
`)}catch(h){alert(h.message),m.value=m.value.replace(n,"")}finally{d.value=!1}},fe=u=>{var n;if((n=u.dataTransfer)!=null&&n.items){const h=nt(u.dataTransfer.items);h&&q.value&&(me(h),u.preventDefault())}},st=u=>{if(u.clipboardData){const n=nt(u.clipboardData.items);n&&q.value&&me(n)}},ct=()=>{const u=x.value;u.files&&q.value&&me(u.files[0]).then(()=>{u.value=""})},Me=async()=>{var u;const{serverURL:n,lang:h,login:H,wordLimit:g,requiredMeta:D,recaptchaV3Key:N,turnstileKey:Y}=r.value,_={comment:ue.value,nick:M.value.nick,mail:M.value.mail,link:M.value.link,url:r.value.path,ua:await Yl()};if(!t.edit)if(w.value.token)_.nick=w.value.display_name,_.mail=w.value.email,_.link=w.value.url;else{if(H==="force")return;if(D.includes("nick")&&!_.nick){b.value.nick.focus(),alert(p.value.nickError);return}if(D.includes("mail")&&!_.mail||_.mail&&!Hl(_.mail)){b.value.mail.focus(),alert(p.value.mailError);return}_.nick||(_.nick=p.value.anonymous)}if(!_.comment){k.value.focus();return}if(!ee.value){alert(p.value.wordHint.replace("$0",g[0].toString()).replace("$1",g[1].toString()).replace("$2",V.value.toString()));return}_.comment=it(_.comment,S.value.map),t.replyId&&t.rootId&&(_.pid=t.replyId,_.rid=t.rootId,_.at=t.replyUser),d.value=!0;try{N&&(_.recaptchaV3=await Xt(N).execute("social")),Y&&(_.turnstile=await Yt(Y).execute("social"));const ve={serverURL:n,lang:h,token:w.value.token,comment:_},ye=await(t.edit?ge({objectId:t.edit.objectId,...ve}):It(ve));if(d.value=!1,ye.errmsg){alert(ye.errmsg);return}l("submit",ye.data),m.value="",I.value="",await Re(),t.replyId&&l("cancelReply"),(u=t.edit)!=null&&u.objectId&&l("cancelEdit")}catch(ve){d.value=!1,alert(ve.message)}},ut=u=>{u.preventDefault();const{lang:n,serverURL:h}=r.value;Et({serverURL:h,lang:n}).then(H=>{w.value=H,(H.remember?localStorage:sessionStorage).setItem("WALINE_USER",JSON.stringify(H)),l("log")})},mt=()=>{w.value={},localStorage.setItem("WALINE_USER","null"),sessionStorage.setItem("WALINE_USER","null"),l("log")},xe=u=>{u.preventDefault();const{lang:n,serverURL:h}=r.value,H=800,g=800,D=(window.innerWidth-H)/2,N=(window.innerHeight-g)/2,Y=new URLSearchParams({lng:n,token:w.value.token}),_=window.open(`${h}/ui/profile?${Y.toString()}`,"_blank",`width=${H},height=${g},left=${D},top=${N},scrollbars=no,resizable=no,status=no,location=no,toolbar=no,menubar=no`);_==null||_.postMessage({type:"TOKEN",data:w.value.token},"*")},vt=u=>{var n,h,H,g;!((n=v.value)!=null&&n.contains(u.target))&&!((h=A.value)!=null&&h.contains(u.target))&&(c.value=!1),!((H=U.value)!=null&&H.contains(u.target))&&!((g=$.value)!=null&&g.contains(u.target))&&(K.value=!1)},Ae=async u=>{var n;const{scrollTop:h,clientHeight:H,scrollHeight:g}=u.target,D=(H+h)/g,N=r.value.search,Y=((n=y.value)==null?void 0:n.value)??"";D<.9||T.loading||j.value||(T.loading=!0,(N.more&&T.list.length?await N.more(Y,T.list.length):await N.search(Y)).length?T.list=[...T.list,...N.more&&T.list.length?await N.more(Y,T.list.length):await N.search(Y)]:j.value=!0,T.loading=!1,setTimeout(()=>{u.target.scrollTop=h},50))},Se=bt(u=>{T.list=[],j.value=!1,Ae(u)},300);return Ue("click",vt),Ue("message",({data:u})=>{(u==null?void 0:u.type)==="profile"&&(w.value={...w.value,...u.data},[localStorage,sessionStorage].filter(n=>n.getItem("WALINE_USER")).forEach(n=>{n.setItem("WALINE_USER",JSON.stringify(w))}))}),oe([r,V],([u,n])=>{const{wordLimit:h}=u;h?n<h[0]&&h[0]!==0?(ae.value=h[0],ee.value=!1):n>h[1]?(ae.value=h[1],ee.value=!1):(ae.value=h[1],ee.value=!0):(ae.value=0,ee.value=!0)}),ke(K,async u=>{var n;if(!u)return;const h=r.value.search;y.value&&(y.value.value=""),T.loading=!0,T.list=await(((n=h.default)==null?void 0:n.call(h))??h.search("")),T.loading=!1}),de(()=>{var u;(u=t.edit)!=null&&u.objectId&&(m.value=t.edit.orig),oe(()=>m.value,n=>{const{highlighter:h,texRenderer:H}=r.value;ue.value=n,I.value=Ol(n,{emojiMap:S.value.map,highlighter:h,texRenderer:H}),V.value=Xl(n),n?He(k.value):He.destroy(k.value)}),oe(()=>r.value.emoji,async n=>{S.value=await Wl(n)})}),(u,n)=>{var h,H;return i(),o("div",{key:f(w).token,class:"wl-comment"},[f(r).login!=="disable"&&F.value&&!((h=e.edit)!=null&&h.objectId)?(i(),o("div",Jl,[s("div",Ql,[s("button",{type:"submit",class:"wl-logout-btn",title:p.value.logout,onClick:mt},[O(f(Te),{size:14})],8,ea),s("a",{href:"#",class:"wl-login-nick","aria-label":"Profile",title:p.value.profile,onClick:xe},[s("img",{src:f(w).avatar,alt:"avatar"},null,8,la)],8,ta)]),s("a",{href:"#",class:"wl-login-nick","aria-label":"Profile",title:p.value.profile,onClick:xe,textContent:E(f(w).display_name)},null,8,aa)])):C("v-if",!0),s("div",na,[f(r).login!=="force"&&f(r).meta.length&&!F.value?(i(),o("div",{key:0,class:P(["wl-header",`item${f(r).meta.length}`])},[(i(!0),o(B,null,Z(f(r).meta,g=>(i(),o("div",{key:g,class:"wl-header-item"},[s("label",{for:`wl-${g}`,textContent:E(p.value[g]+(f(r).requiredMeta.includes(g)||!f(r).requiredMeta.length?"":`(${p.value.optional})`))},null,8,ia),pe(s("input",{id:`wl-${g}`,ref_for:!0,ref:D=>{D&&(b.value[g]=D)},"onUpdate:modelValue":D=>f(M)[g]=D,class:P(["wl-input",`wl-${g}`]),name:g,type:g==="mail"?"email":"text"},null,10,ra),[[gt,f(M)[g]]])]))),128))],2)):C("v-if",!0),pe(s("textarea",{id:"wl-edit",ref:"textarea","onUpdate:modelValue":n[0]||(n[0]=g=>ht(m)?m.value=g:null),class:"wl-editor",placeholder:e.replyUser?`@${e.replyUser}`:p.value.placeholder,onKeydown:ie,onDrop:fe,onPaste:st},null,40,oa),[[ft,f(m)]]),pe(s("div",sa,[n[7]||(n[7]=s("hr",null,null,-1)),s("h4",null,E(p.value.preview)+":",1),s("div",{class:"wl-content",innerHTML:I.value},null,8,ca)],512),[[Ve,X.value]]),s("div",ua,[s("div",ma,[s("a",va,[O(f(Ht))]),pe(s("button",{ref:"emoji-button",type:"button",class:P(["wl-action",{active:c.value}]),title:p.value.emoji,onClick:n[1]||(n[1]=g=>c.value=!c.value)},[O(f(Rt))],10,da),[[Ve,S.value.tabs.length]]),f(r).search?(i(),o("button",{key:0,ref:"gif-button",type:"button",class:P(["wl-action",{active:K.value}]),title:p.value.gif,onClick:n[2]||(n[2]=g=>K.value=!K.value)},[O(f(Bt))],10,pa)):C("v-if",!0),s("input",{id:"wl-image-upload",ref:"image-uploader",class:"upload","aria-hidden":"true",type:"file",accept:".png,.jpg,.jpeg,.webp,.bmp,.gif",onChange:ct},null,544),q.value?(i(),o("label",{key:1,for:"wl-image-upload",class:"wl-action",title:p.value.uploadImage,"aria-label":p.value.uploadImage},[O(f(Vt))],8,ga)):C("v-if",!0),s("button",{type:"button",class:P(["wl-action",{active:X.value}]),title:p.value.preview,onClick:n[3]||(n[3]=g=>X.value=!X.value)},[O(f(_t))],10,ha)]),s("div",fa,[n[9]||(n[9]=s("div",{class:"wl-captcha-container"},null,-1)),s("div",ya,[le(E(V.value)+" ",1),f(r).wordLimit?(i(),o("span",wa,[n[8]||(n[8]=le(" / ",-1)),s("span",{class:P({illegal:!ee.value}),textContent:E(ae.value)},null,10,ka)])):C("v-if",!0),le(" "+E(p.value.word),1)]),f(r).login!=="disable"&&!F.value?(i(),o("button",{key:0,type:"button",class:"wl-btn",onClick:ut,textContent:E(p.value.login)},null,8,ba)):C("v-if",!0),f(r).login!=="force"||F.value?(i(),o("button",{key:1,type:"submit",class:"primary wl-btn",title:"Cmd|Ctrl + Enter",disabled:d.value,onClick:Me},[d.value?(i(),Q(f(se),{key:0,size:16})):(i(),o(B,{key:1},[le(E(p.value.submit),1)],64))],8,Ca)):C("v-if",!0)]),s("div",{ref:"gif-popup",class:P(["wl-gif-popup",{display:K.value}])},[s("input",{ref:"gif-search",type:"text",placeholder:p.value.gifSearchPlaceholder,onInput:n[4]||(n[4]=(...g)=>f(Se)&&f(Se)(...g))},null,40,$a),T.list.length?(i(),Q(xl,{key:0,items:T.list,"column-width":200,gap:6,onInsert:n[5]||(n[5]=g=>G(g)),onScroll:Ae},null,8,["items"])):C("v-if",!0),T.loading?(i(),o("div",La,[O(f(se),{size:30})])):C("v-if",!0)],2),s("div",{ref:"emoji-popup",class:P(["wl-emoji-popup",{display:c.value}])},[(i(!0),o(B,null,Z(S.value.tabs,(g,D)=>(i(),o(B,{key:g.name},[D===R.value?(i(),o("div",Ia,[(i(!0),o(B,null,Z(g.items,N=>(i(),o("button",{key:N,type:"button",title:N,onClick:Y=>G(`:${N}:`)},[c.value?(i(),o("img",{key:0,class:"wl-emoji",src:S.value.map[N],alt:N,loading:"lazy",referrerPolicy:"no-referrer"},null,8,Ma)):C("v-if",!0)],8,Ea))),128))])):C("v-if",!0)],64))),128)),S.value.tabs.length>1?(i(),o("div",xa,[(i(!0),o(B,null,Z(S.value.tabs,(g,D)=>(i(),o("button",{key:g.name,type:"button",class:P(["wl-tab",{active:R.value===D}]),onClick:N=>R.value=D},[s("img",{class:"wl-emoji",src:g.icon,alt:g.name,title:g.name,loading:"lazy",referrerPolicy:"no-referrer"},null,8,Sa)],10,Aa))),128))])):C("v-if",!0)],2)])]),e.replyId||(H=e.edit)!=null&&H.objectId?(i(),o("button",{key:1,type:"button",class:"wl-close",title:p.value.cancelReply,onClick:n[6]||(n[6]=g=>e.replyId?l("cancelReply"):l("cancelEdit"))},[O(f(Te),{size:24})],8,ja)):C("v-if",!0)])}}});const za=["id"],Ra={class:"wl-user","aria-hidden":"true"},Va=["src"],Ua={class:"wl-card"},_a={class:"wl-head"},Ha=["href"],Ta={key:1,class:"wl-nick"},Fa=["textContent"],Na=["textContent"],Wa=["textContent"],Ba=["textContent"],Da={class:"wl-comment-actions"},Pa=["title"],qa=["title"],Ga={class:"wl-meta","aria-hidden":"true"},Oa=["data-value","textContent"],Ka={key:0,class:"wl-content"},Za={key:0},Xa=["href"],Ya=["innerHTML"],Ja={key:1,class:"wl-admin-actions"},Qa={class:"wl-comment-status"},en=["disabled","onClick","textContent"],tn={key:3,class:"wl-quote"};var ln=re({__name:"CommentCard",props:{comment:{},edit:{},rootId:{},reply:{}},emits:["log","submit","delete","like","sticky","edit","reply","status"],setup(e,{emit:a}){const t=e,l=a,r=["approved","waiting","spam"],m=we(he),M=Fe(),w=Ct(),b=be(),k=W(()=>m.value.locale),x=W(()=>{const{link:R}=t.comment;return R?tt(R)?R:`https://${R}`:""}),v=W(()=>M.value.includes(t.comment.objectId)),A=W(()=>Ul(new Date(t.comment.time),w.value,k.value)),U=W(()=>b.value.type==="administrator"),$=W(()=>t.comment.user_id&&b.value.objectId===t.comment.user_id),y=W(()=>{var R;return t.comment.objectId===((R=t.reply)==null?void 0:R.objectId)}),S=W(()=>{var R;return t.comment.objectId===((R=t.edit)==null?void 0:R.objectId)});return(R,c)=>{var K;const X=yt("CommentCard",!0);return i(),o("div",{id:e.comment.objectId.toString(),class:"wl-card-item"},[s("div",Ra,[e.comment.avatar?(i(),o("img",{key:0,class:"wl-user-avatar",src:e.comment.avatar,alt:""},null,8,Va)):C("v-if",!0),e.comment.type==="guest"?(i(),Q(f(Nt),{key:1})):C("v-if",!0),e.comment.type==="administrator"?(i(),Q(f(Wt),{key:2})):C("v-if",!0)]),s("div",Ua,[s("div",_a,[x.value?(i(),o("a",{key:0,class:"wl-nick",href:x.value,target:"_blank",rel:"nofollow noopener noreferrer"},E(e.comment.nick),9,Ha)):(i(),o("span",Ta,E(e.comment.nick),1)),e.comment.label?(i(),o("span",{key:2,class:"wl-badge",textContent:E(e.comment.label)},null,8,Fa)):C("v-if",!0),e.comment.sticky?(i(),o("span",{key:3,class:"wl-badge",textContent:E(k.value.sticky)},null,8,Na)):C("v-if",!0),typeof e.comment.level=="number"?(i(),o("span",{key:4,class:P(`wl-badge level${e.comment.level}`),textContent:E(k.value[`level${e.comment.level}`]||`Level ${e.comment.level}`)},null,10,Wa)):C("v-if",!0),s("span",{class:"wl-time",textContent:E(A.value)},null,8,Ba),s("div",Da,[U.value||$.value?(i(),o(B,{key:0},[s("button",{type:"button",class:"wl-edit",onClick:c[0]||(c[0]=I=>l("edit",e.comment))},[O(f(Ft))]),s("button",{type:"button",class:"wl-delete",onClick:c[1]||(c[1]=I=>l("delete",e.comment))},[O(f(zt))])],64)):C("v-if",!0),s("button",{type:"button",class:"wl-like",title:v.value?k.value.cancelLike:k.value.like,onClick:c[2]||(c[2]=I=>l("like",e.comment))},[O(f(Ut),{active:v.value},null,8,["active"]),le(" "+E("like"in e.comment?e.comment.like:""),1)],8,Pa),s("button",{type:"button",class:P(["wl-reply",{active:y.value}]),title:y.value?k.value.cancelReply:k.value.reply,onClick:c[3]||(c[3]=I=>l("reply",y.value?null:e.comment))},[O(f(Tt))],10,qa)])]),s("div",Ga,[(i(),o(B,null,Z(["addr","browser","os"],I=>(i(),o(B,null,[e.comment[I]?(i(),o("span",{key:I,class:P(`wl-${I}`),"data-value":e.comment[I],textContent:E(e.comment[I])},null,10,Oa)):C("v-if",!0)],64))),64))]),S.value?C("v-if",!0):(i(),o("div",Ka,["reply_user"in e.comment&&e.comment.reply_user?(i(),o("p",Za,[s("a",{href:"#"+e.comment.pid},"@"+E(e.comment.reply_user.nick),9,Xa),c[17]||(c[17]=s("span",null,": ",-1))])):C("v-if",!0),s("div",{innerHTML:e.comment.comment},null,8,Ya)])),U.value&&!S.value?(i(),o("div",Ja,[s("span",Qa,[(i(),o(B,null,Z(r,I=>s("button",{key:I,type:"submit",class:P(`wl-btn wl-${I}`),disabled:e.comment.status===I,onClick:V=>l("status",{status:I,comment:e.comment}),textContent:E(k.value[I])},null,10,en)),64))]),U.value&&!("rid"in e.comment)?(i(),o("button",{key:0,type:"submit",class:"wl-btn wl-sticky",onClick:c[4]||(c[4]=I=>l("sticky",e.comment))},E(e.comment.sticky?k.value.unsticky:k.value.sticky),1)):C("v-if",!0)])):C("v-if",!0),y.value||S.value?(i(),o("div",{key:2,class:P({"wl-reply-wrapper":y.value,"wl-edit-wrapper":S.value})},[O(rt,{edit:e.edit,"reply-id":(K=e.reply)==null?void 0:K.objectId,"reply-user":e.comment.nick,"root-id":e.rootId,onLog:c[5]||(c[5]=I=>l("log")),onCancelReply:c[6]||(c[6]=I=>l("reply",null)),onCancelEdit:c[7]||(c[7]=I=>l("edit",null)),onSubmit:c[8]||(c[8]=I=>l("submit",I))},null,8,["edit","reply-id","reply-user","root-id"])],2)):C("v-if",!0),"children"in e.comment?(i(),o("div",tn,[(i(!0),o(B,null,Z(e.comment.children,I=>(i(),Q(X,{key:I.objectId,comment:I,reply:e.reply,edit:e.edit,"root-id":e.rootId,onLog:c[9]||(c[9]=V=>l("log")),onDelete:c[10]||(c[10]=V=>l("delete",V)),onEdit:c[11]||(c[11]=V=>l("edit",V)),onLike:c[12]||(c[12]=V=>l("like",V)),onReply:c[13]||(c[13]=V=>l("reply",V)),onStatus:c[14]||(c[14]=V=>l("status",V)),onSticky:c[15]||(c[15]=V=>l("sticky",V)),onSubmit:c[16]||(c[16]=V=>l("submit",V))},null,8,["comment","reply","edit","root-id"]))),128))])):C("v-if",!0)])],8,za)}}});const ot="3.7.1",an={"data-waline":""},nn={class:"wl-meta-head"},rn={class:"wl-count"},on=["textContent"],sn={class:"wl-sort"},cn=["onClick"],un={class:"wl-cards"},mn={key:1,class:"wl-operation"},vn=["textContent"],dn={key:2,class:"wl-loading"},pn=["textContent"],gn={key:4,class:"wl-operation"},hn=["textContent"],fn={key:5,class:"wl-power"};var yn=re({__name:"WalineComment",props:{serverURL:{},path:{},meta:{},requiredMeta:{},wordLimit:{},pageSize:{},lang:{},locale:{},commentSorting:{},dark:{type:[String,Boolean]},login:{},noCopyright:{type:Boolean},recaptchaV3Key:{},turnstileKey:{},reaction:{type:[Array,Boolean]},emoji:{},search:{},highlighter:{type:Function},imageUploader:{type:Function},texRenderer:{type:Function}},setup(e){const a=e,t=be(),l=Fe(),r=z("loading"),m=z(0),M=z(1),w=z(0),b=W(()=>zl(a)),k=z(b.value.commentSorting),x=z([]),v=z(null),A=z(null),U=W(()=>Rl(b.value.dark)),$=W(()=>b.value.locale);$t(U,{id:"waline-darkmode"});let y=null;const S=d=>{const{serverURL:j,path:p,pageSize:F}=b.value,q=new AbortController;r.value="loading",y==null||y(),xt({serverURL:j,lang:b.value.lang,path:p,pageSize:F,sortBy:Qe[k.value],page:d,signal:q.signal,token:t.value.token}).then(G=>{r.value="success",m.value=G.count,x.value.push(...G.data),M.value=d,w.value=G.totalPages}).catch(G=>{G.name!=="AbortError"&&(console.error(G.message),r.value="error")}),y=q.abort.bind(q)},R=()=>{S(M.value+1)},c=()=>{m.value=0,x.value=[],S(1)},K=d=>{k.value!==d&&(k.value=d,c())},X=d=>{v.value=d},I=d=>{A.value=d},V=d=>{if(A.value)A.value.comment=d.comment,A.value.orig=d.orig;else if("rid"in d){const j=x.value.find(({objectId:p})=>p===d.rid);if(!j)return;Array.isArray(j.children)||(j.children=[]),j.children.push(d)}else x.value.unshift(d),m.value+=1},T=async({comment:d,status:j})=>{if(d.status===j)return;const{serverURL:p,lang:F}=b.value;await ge({serverURL:p,lang:F,token:t.value.token,objectId:d.objectId,comment:{status:j}}),d.status=j},ae=async d=>{if("rid"in d)return;const{serverURL:j,lang:p}=b.value;await ge({serverURL:j,lang:p,token:t.value.token,objectId:d.objectId,comment:{sticky:d.sticky?0:1}}),d.sticky=!d.sticky},ee=async({objectId:d})=>{if(!confirm("Are you sure you want to delete this comment?"))return;const{serverURL:j,lang:p}=b.value;await Mt({serverURL:j,lang:p,token:t.value.token,objectId:d}),x.value.some((F,q)=>F.objectId===d?(x.value=x.value.filter((G,ie)=>ie!==q),!0):F.children.some((G,ie)=>G.objectId===d?(x.value[q].children=F.children.filter((me,fe)=>fe!==ie),!0):!1))},ue=async d=>{const{serverURL:j,lang:p}=b.value,{objectId:F}=d,q=l.value.includes(F);await ge({serverURL:j,lang:p,objectId:F,token:t.value.token,comment:{like:!q}}),q?l.value=l.value.filter(G=>G!==F):(l.value=[...l.value,F],l.value.length>50&&(l.value=l.value.slice(-50))),d.like=Math.max(0,(d.like||0)+(q?-1:1))};return wt(he,b),de(()=>{oe(()=>[a.serverURL,a.path],()=>{c()})}),je(()=>{y==null||y()}),(d,j)=>(i(),o("div",an,[O(Il),!v.value&&!A.value?(i(),Q(rt,{key:0,onLog:c,onSubmit:V})):C("v-if",!0),s("div",nn,[s("div",rn,[m.value?(i(),o("span",{key:0,class:"wl-num",textContent:E(m.value)},null,8,on)):C("v-if",!0),le(" "+E($.value.comment),1)]),s("ul",sn,[(i(!0),o(B,null,Z(f(hl),p=>(i(),o("li",{key:p,class:P([p===k.value?"active":""]),onClick:F=>K(p)},E($.value[p]),11,cn))),128))])]),s("div",un,[(i(!0),o(B,null,Z(x.value,p=>(i(),Q(ln,{key:p.objectId,"root-id":p.objectId,comment:p,reply:v.value,edit:A.value,onLog:c,onReply:X,onEdit:I,onSubmit:V,onStatus:T,onDelete:ee,onSticky:ae,onLike:ue},null,8,["root-id","comment","reply","edit"]))),128))]),r.value==="error"?(i(),o("div",mn,[s("button",{type:"button",class:"wl-btn",onClick:c,textContent:E($.value.refresh)},null,8,vn)])):r.value==="loading"?(i(),o("div",dn,[O(f(se),{size:30})])):x.value.length?M.value<w.value?(i(),o("div",gn,[s("button",{type:"button",class:"wl-btn",onClick:R,textContent:E($.value.more)},null,8,hn)])):C("v-if",!0):(i(),o("div",{key:3,class:"wl-empty",textContent:E($.value.sofa)},null,8,pn)),b.value.noCopyright?C("v-if",!0):(i(),o("div",fn,[j[0]||(j[0]=le(" Powered by ",-1)),j[1]||(j[1]=s("a",{href:"https://github.com/walinejs/waline",target:"_blank",rel:"noopener noreferrer"}," Waline ",-1)),le(" v"+E(f(ot)),1)]))]))}});export{yn as Waline,ot as version};
|
|
12
12
|
//# sourceMappingURL=component.js.map
|