@waline/client 3.5.5 → 3.5.6

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 CHANGED
@@ -1,2 +1,2 @@
1
- const i=e=>`${e.replace(/\/?$/,"/")}api/`,h=(e,t="")=>{if(typeof e=="object"&&e.errno)throw new TypeError(`${t} failed with ${e.errno}: ${e.errmsg}`);return e},g=({serverURL:e,lang:t,paths:r,signal:o})=>fetch(`${i(e)}comment?type=count&url=${encodeURIComponent(r.join(","))}&lang=${t}`,{signal:o}).then(n=>n.json()).then(n=>h(n,"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 t=m(e);return u(t)?t:`https://${t}`},$=e=>{e.name!=="AbortError"&&console.error(e.message)},f=e=>{const{path:t}=e.dataset;return t!=null&&t.length?t:null},v=({serverURL:e,path:t=window.location.pathname,selector:r=".waline-comment-count",lang:o=navigator.language})=>{const n=new AbortController,a=document.querySelectorAll(r);return a.length&&g({serverURL:d(e),paths:Array.from(a).map(c=>p(f(c)??t)),lang:o,signal:n.signal}).then(c=>{a.forEach((s,l)=>{s.innerText=c[l].toString()})}).catch($),n.abort.bind(n)},w="3.5.5";export{v as commentCount,w as version};
1
+ const i=e=>`${e.replace(/\/?$/,"/")}api/`,h=(e,t="")=>{if(typeof e=="object"&&e.errno)throw new TypeError(`${t} failed with ${e.errno}: ${e.errmsg}`);return e},g=({serverURL:e,lang:t,paths:r,signal:o})=>fetch(`${i(e)}comment?type=count&url=${encodeURIComponent(r.join(","))}&lang=${t}`,{signal:o}).then(n=>n.json()).then(n=>h(n,"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 t=m(e);return u(t)?t:`https://${t}`},$=e=>{e.name!=="AbortError"&&console.error(e.message)},f=e=>{const{path:t}=e.dataset;return t!=null&&t.length?t:null},v=({serverURL:e,path:t=window.location.pathname,selector:r=".waline-comment-count",lang:o=navigator.language})=>{const n=new AbortController,a=document.querySelectorAll(r);return a.length&&g({serverURL:d(e),paths:Array.from(a).map(c=>p(f(c)??t)),lang:o,signal:n.signal}).then(c=>{a.forEach((s,l)=>{s.innerText=c[l].toString()})}).catch($),n.abort.bind(n)},w="3.5.6";export{v as commentCount,w as version};
2
2
  //# sourceMappingURL=comment.js.map
package/dist/component.js CHANGED
@@ -8,5 +8,5 @@ import{h as x,defineComponent as oe,inject as we,ref as R,computed as W,createEl
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
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"],Il=["textContent"];var El=oe({__name:"ArticleReaction",setup(e){const a=Zt(),t=we(he),l=R(-1),r=R([]),d=W(()=>t.value.locale),M=W(()=>{const{reaction:m}=t.value;return m!=null&&m.length?m:null}),k=W(()=>{var m;const{path:S}=t.value;return((m=M.value)==null?void 0:m.map((U,I)=>({icon:U,desc:d.value[`reaction${I}`],active:a.value[S]===I})))??null});let C;const b=async()=>{const{serverURL:m,lang:S,path:U}=t.value;if(!M.value)return;const I=new AbortController;C=I.abort.bind(I);const[y]=await Et({serverURL:m,lang:S,paths:[U],type:M.value.map((j,o)=>`reaction${o}`),signal:I.signal});r.value=M.value.map((j,o)=>y[`reaction${o}`])},A=async m=>{if(l.value!==-1)return;const{serverURL:S,lang:U,path:I}=t.value,y=a.value[I];l.value=m,y!==void 0&&(await _e({serverURL:S,lang:U,path:I,type:`reaction${y}`,action:"desc"}),r.value[y]=Math.max(r.value[y]-1,0)),y!==m&&(await _e({serverURL:S,lang:U,path:I,type:`reaction${m}`}),r.value[m]=(r.value[m]||0)+1),y===m?delete a.value[I]:a.value[I]=m,l.value=-1};return de(()=>{se(()=>[t.value.serverURL,t.value.path],()=>b())}),je(()=>{C==null||C()}),(m,S)=>k.value?(i(),s("div",fl,[u("div",{class:"wl-reaction-title",textContent:L(d.value.reactionTitle)},null,8,yl),u("ul",wl,[(i(!0),s(B,null,Z(k.value,({active:U,icon:I,desc:y},j)=>(i(),s("li",{key:j,class:P(["wl-reaction-item",{active:U}]),onClick:o=>A(j)},[u("div",bl,[u("img",{src:I,alt:y},null,8,Cl),l.value===j?(i(),ee(w(ce),{key:0,class:"wl-reaction-loading"})):(i(),s("div",{key:1,class:"wl-reaction-votes",textContent:L(r.value[j]||0)},null,8,$l))]),u("div",{class:"wl-reaction-text",textContent:L(y)},null,8,Il)],10,kl))),128))])])):$("v-if",!0)}});const Ll=["data-index"],xl=["src","title","onClick"];var Ml=oe({__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=R({}),d=R([]),M=()=>{const m=Math.floor((l.value.getBoundingClientRect().width+a.gap)/(a.columnWidth+a.gap));return m>0?m:1},k=m=>new Array(m).fill(null).map(()=>[]),C=async m=>{var S;if(m>=a.items.length)return;await Re();const U=Array.from(((S=l.value)==null?void 0:S.children)??[]).reduce((I,y)=>y.getBoundingClientRect().height<I.getBoundingClientRect().height?y:I);d.value[Number(U.dataset.index)].push(m),await C(m+1)},b=async(m=!1)=>{if(d.value.length===M()&&!m)return;d.value=k(M());const S=window.scrollY;await C(0),window.scrollTo({top:S})},A=m=>{r.value[m.target.src]=!0};return de(()=>{b(!0),t=new ResizeObserver(()=>{b()}),t.observe(l.value),ke(()=>[a.items],()=>{r.value={},b(!0)}),ke(()=>[a.columnWidth,a.gap],()=>{b()})}),dt(()=>{t.unobserve(l.value)}),(m,S)=>(i(),s("div",{ref_key:"wall",ref:l,class:"wl-gallery",style:ze({gap:`${m.gap}px`})},[(i(!0),s(B,null,Z(d.value,(U,I)=>(i(),s("div",{key:I,class:"wl-gallery-column","data-index":I,style:ze({gap:`${m.gap}px`})},[(i(!0),s(B,null,Z(U,y=>(i(),s(B,{key:y},[r.value[m.items[y].src]?$("v-if",!0):(i(),ee(w(ce),{key:0,size:36,style:{margin:"20px auto"}})),u("img",{class:"wl-gallery-item",src:m.items[y].src,title:m.items[y].title,loading:"lazy",onLoad:A,onClick:j=>m.$emit("insert",`![](${m.items[y].src})`)},null,40,xl)],64))),128))],12,Ll))),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,ie=(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:d=[],dark:M=!1,pageSize:k=10,wordLimit:C,noCopyright:b=!1,login:A="enable",recaptchaV3Key:m="",turnstileKey:S="",commentSorting:U="latest",emoji:I=Be,imageUploader:y,highlighter:j,texRenderer:o,search:v,reaction:K,...X})=>({serverURL:Sl(e),path:Al(a),lang:Je(t),locale:{...gl(Je(t)),...typeof l=="object"?l:{}},wordLimit:jl(C),meta:We(r),requiredMeta:We(d),dark:M,pageSize:k,commentSorting:U,login:A,noCopyright:b,recaptchaV3Key:m,turnstileKey:S,...X,reaction:ie(K,tl),imageUploader:ie(y,ll),highlighter:ie(j,ul),texRenderer:ie(o,al),emoji:ie(I,Be),search:ie(v,nl(t))}),Ie=e=>typeof e=="string",Ee="{--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=>Ie(e)?e==="auto"?`@media(prefers-color-scheme:dark){body${Ee}}`:`${e}${Ee}`:e===!0?`:root${Ee}`:"",Le=(e,a)=>{let t=e.toString();for(;t.length<a;)t="0"+t;return t},Vl=e=>{const a=Le(e.getDate(),2),t=Le(e.getMonth()+1,2);return`${Le(e.getFullYear(),2)}-${t}-${a}`},Ul=(e,a,t)=>{if(!e)return"";const l=Ie(e)?new Date(e.includes(" ")?e.replace(/-/g,"/"):e):e,r=a.getTime()-l.getTime(),d=Math.floor(r/(24*3600*1e3));if(d===0){const M=r%864e5,k=Math.floor(M/(3600*1e3));if(k===0){const C=M%36e5,b=Math.floor(C/(60*1e3));if(b===0){const A=C%6e4;return`${Math.round(A/1e3)} ${t.seconds}`}return`${b} ${t.minutes}`}return`${k} ${t.hours}`}return d<0?t.now:d<8?`${d} ${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=>Ie(a)?Nl(et(a)):Promise.resolve(a)):[]).then(a=>{const t={tabs:[],map:{}};return a.forEach(l=>{const{name:r,folder:d,icon:M,prefix:k="",type:C,items:b}=l;t.tabs.push({name:r,icon:at(M,d,k,C),items:b.map(A=>{const m=`${k}${A}`;return t.map[m]=at(A,d,k,C),m})})}),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 St;if(r.setOptions({breaks:!0}),t&&r.use(jt({highlight:t})),l){const d=Gl(l);r.use({extensions:d})}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||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"],Ia={key:1,class:"wl-loading"},Ea={key:0,class:"wl-tab-wrapper"},La=["title","onClick"],xa=["src","alt"],Ma={key:0,class:"wl-tabs"},Aa=["onClick"],Sa=["src","alt","title"],ja=["title"];var rt=oe({__name:"CommentBox",props:{edit:{},rootId:{},replyId:{},replyUser:{}},emits:["log","cancelEdit","cancelReply","submit"],setup(e,{emit:a}){const t=e,l=a,r=we(he),d=Pt(),M=Dt(),k=be(),C=R({}),b=te("textarea"),A=te("image-uploader"),m=te("emoji-button"),S=te("emoji-popup"),U=te("gif-button"),I=te("gif-popup"),y=te("gif-search"),j=R({tabs:[],map:{}}),o=R(0),v=R(!1),K=R(!1),X=R(!1),E=R(""),V=R(0),T=pt({loading:!0,list:[]}),ae=R(0),Q=R(!1),ue=R(""),p=R(!1),z=R(!1),g=W(()=>r.value.locale),F=W(()=>!!k.value.token),q=W(()=>bt(r.value.imageUploader)),G=c=>{const n=b.value,f=n.selectionStart,H=n.selectionEnd||0,h=n.scrollTop;d.value=n.value.substring(0,f)+c+n.value.substring(H,n.value.length),n.focus(),n.selectionStart=f+c.length,n.selectionEnd=f+c.length,n.scrollTop=h},re=({key:c,ctrlKey:n,metaKey:f})=>{p.value||(n||f)&&c==="Enter"&&xe()},me=async c=>{const n=`![${r.value.locale.uploading} ${c.name}]()`;G(n),p.value=!0;try{const f=await r.value.imageUploader(c);d.value=d.value.replace(n,`\r
11
- ![${c.name}](${f})`)}catch(f){alert(f.message),d.value=d.value.replace(n,"")}finally{p.value=!1}},fe=c=>{var n;if((n=c.dataTransfer)!=null&&n.items){const f=nt(c.dataTransfer.items);f&&q.value&&(me(f),c.preventDefault())}},st=c=>{if(c.clipboardData){const n=nt(c.clipboardData.items);n&&q.value&&me(n)}},ct=()=>{const c=A.value;c.files&&q.value&&me(c.files[0]).then(()=>{c.value=""})},xe=async()=>{var c;const{serverURL:n,lang:f,login:H,wordLimit:h,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(k.value.token)_.nick=k.value.display_name,_.mail=k.value.email,_.link=k.value.url;else{if(H==="force")return;if(D.includes("nick")&&!_.nick){C.value.nick.focus(),alert(g.value.nickError);return}if(D.includes("mail")&&!_.mail||_.mail&&!Hl(_.mail)){C.value.mail.focus(),alert(g.value.mailError);return}_.nick||(_.nick=g.value.anonymous)}if(!_.comment){b.value.focus();return}if(!Q.value){alert(g.value.wordHint.replace("$0",h[0].toString()).replace("$1",h[1].toString()).replace("$2",V.value.toString()));return}_.comment=it(_.comment,j.value.map),t.replyId&&t.rootId&&(_.pid=t.replyId,_.rid=t.rootId,_.at=t.replyUser),p.value=!0;try{N&&(_.recaptchaV3=await Xt(N).execute("social")),Y&&(_.turnstile=await Yt(Y).execute("social"));const ve={serverURL:n,lang:f,token:k.value.token,comment:_},ye=await(t.edit?ge({objectId:t.edit.objectId,...ve}):Lt(ve));if(p.value=!1,ye.errmsg){alert(ye.errmsg);return}l("submit",ye.data),d.value="",E.value="",await Re(),t.replyId&&l("cancelReply"),(c=t.edit)!=null&&c.objectId&&l("cancelEdit")}catch(ve){p.value=!1,alert(ve.message)}},ut=c=>{c.preventDefault();const{lang:n,serverURL:f}=r.value;xt({serverURL:f,lang:n}).then(H=>{k.value=H,(H.remember?localStorage:sessionStorage).setItem("WALINE_USER",JSON.stringify(H)),l("log")})},mt=()=>{k.value={},localStorage.setItem("WALINE_USER","null"),sessionStorage.setItem("WALINE_USER","null"),l("log")},Me=c=>{c.preventDefault();const{lang:n,serverURL:f}=r.value,H=800,h=800,D=(window.innerWidth-H)/2,N=(window.innerHeight-h)/2,Y=new URLSearchParams({lng:n,token:k.value.token}),_=window.open(`${f}/ui/profile?${Y.toString()}`,"_blank",`width=${H},height=${h},left=${D},top=${N},scrollbars=no,resizable=no,status=no,location=no,toolbar=no,menubar=no`);_==null||_.postMessage({type:"TOKEN",data:k.value.token},"*")},vt=c=>{var n,f,H,h;!((n=m.value)!=null&&n.contains(c.target))&&!((f=S.value)!=null&&f.contains(c.target))&&(v.value=!1),!((H=U.value)!=null&&H.contains(c.target))&&!((h=I.value)!=null&&h.contains(c.target))&&(K.value=!1)},Ae=async c=>{var n;const{scrollTop:f,clientHeight:H,scrollHeight:h}=c.target,D=(H+f)/h,N=r.value.search,Y=((n=y.value)==null?void 0:n.value)??"";D<.9||T.loading||z.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)]:z.value=!0,T.loading=!1,setTimeout(()=>{c.target.scrollTop=f},50))},Se=Ct(c=>{T.list=[],z.value=!1,Ae(c)},300);return Ue("click",vt),Ue("message",({data:c})=>{!c||c.type!=="profile"||(k.value={...k.value,...c.data},[localStorage,sessionStorage].filter(n=>n.getItem("WALINE_USER")).forEach(n=>{n.setItem("WALINE_USER",JSON.stringify(k))}))}),se([r,V],([c,n])=>{const{wordLimit:f}=c;f?n<f[0]&&f[0]!==0?(ae.value=f[0],Q.value=!1):n>f[1]?(ae.value=f[1],Q.value=!1):(ae.value=f[1],Q.value=!0):(ae.value=0,Q.value=!0)}),ke(K,async c=>{var n;if(!c)return;const f=r.value.search;y.value&&(y.value.value=""),T.loading=!0,T.list=await(((n=f.default)==null?void 0:n.call(f))??f.search("")),T.loading=!1}),de(()=>{var c;(c=t.edit)!=null&&c.objectId&&(d.value=t.edit.orig),se(()=>d.value,n=>{const{highlighter:f,texRenderer:H}=r.value;ue.value=n,E.value=Ol(n,{emojiMap:j.value.map,highlighter:f,texRenderer:H}),V.value=Xl(n),n?He(b.value):He.destroy(b.value)}),se(()=>r.value.emoji,async n=>{j.value=await Wl(n)})}),(c,n)=>{var f,H;return i(),s("div",{key:w(k).token,class:"wl-comment"},[w(r).login!=="disable"&&F.value&&!((f=c.edit)!=null&&f.objectId)?(i(),s("div",Jl,[u("div",Ql,[u("button",{type:"submit",class:"wl-logout-btn",title:g.value.logout,onClick:mt},[O(w(Te),{size:14})],8,ea),u("a",{href:"#",class:"wl-login-nick","aria-label":"Profile",title:g.value.profile,onClick:Me},[u("img",{src:w(k).avatar,alt:"avatar"},null,8,la)],8,ta)]),u("a",{href:"#",class:"wl-login-nick","aria-label":"Profile",title:g.value.profile,onClick:Me,textContent:L(w(k).display_name)},null,8,aa)])):$("v-if",!0),u("div",na,[w(r).login!=="force"&&w(r).meta.length&&!F.value?(i(),s("div",{key:0,class:P(["wl-header",`item${w(r).meta.length}`])},[(i(!0),s(B,null,Z(w(r).meta,h=>(i(),s("div",{key:h,class:"wl-header-item"},[u("label",{for:`wl-${h}`,textContent:L(g.value[h]+(w(r).requiredMeta.includes(h)||!w(r).requiredMeta.length?"":`(${g.value.optional})`))},null,8,ia),pe(u("input",{id:`wl-${h}`,ref_for:!0,ref:D=>{D&&(C.value[h]=D)},"onUpdate:modelValue":D=>w(M)[h]=D,class:P(["wl-input",`wl-${h}`]),name:h,type:h==="mail"?"email":"text"},null,10,ra),[[gt,w(M)[h]]])]))),128))],2)):$("v-if",!0),pe(u("textarea",{id:"wl-edit",ref:"textarea","onUpdate:modelValue":n[0]||(n[0]=h=>ht(d)?d.value=h:null),class:"wl-editor",placeholder:c.replyUser?`@${c.replyUser}`:g.value.placeholder,onKeydown:re,onDrop:fe,onPaste:st},null,40,oa),[[ft,w(d)]]),pe(u("div",sa,[n[7]||(n[7]=u("hr",null,null,-1)),u("h4",null,L(g.value.preview)+":",1),u("div",{class:"wl-content",innerHTML:E.value},null,8,ca)],512),[[Ve,X.value]]),u("div",ua,[u("div",ma,[u("a",va,[O(w(Tt))]),pe(u("button",{ref:"emoji-button",type:"button",class:P(["wl-action",{active:v.value}]),title:g.value.emoji,onClick:n[1]||(n[1]=h=>v.value=!v.value)},[O(w(Vt))],10,da),[[Ve,j.value.tabs.length]]),w(r).search?(i(),s("button",{key:0,ref:"gif-button",type:"button",class:P(["wl-action",{active:K.value}]),title:g.value.gif,onClick:n[2]||(n[2]=h=>K.value=!K.value)},[O(w(Bt))],10,pa)):$("v-if",!0),u("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(),s("label",{key:1,for:"wl-image-upload",class:"wl-action",title:g.value.uploadImage,"aria-label":g.value.uploadImage},[O(w(Ut))],8,ga)):$("v-if",!0),u("button",{type:"button",class:P(["wl-action",{active:X.value}]),title:g.value.preview,onClick:n[3]||(n[3]=h=>X.value=!X.value)},[O(w(Ht))],10,ha)]),u("div",fa,[n[9]||(n[9]=u("div",{class:"wl-captcha-container"},null,-1)),u("div",ya,[le(L(V.value)+" ",1),w(r).wordLimit?(i(),s("span",wa,[n[8]||(n[8]=le("  /  ")),u("span",{class:P({illegal:!Q.value}),textContent:L(ae.value)},null,10,ka)])):$("v-if",!0),le("  "+L(g.value.word),1)]),w(r).login!=="disable"&&!F.value?(i(),s("button",{key:0,type:"button",class:"wl-btn",onClick:ut,textContent:L(g.value.login)},null,8,ba)):$("v-if",!0),w(r).login!=="force"||F.value?(i(),s("button",{key:1,type:"submit",class:"primary wl-btn",title:"Cmd|Ctrl + Enter",disabled:p.value,onClick:xe},[p.value?(i(),ee(w(ce),{key:0,size:16})):(i(),s(B,{key:1},[le(L(g.value.submit),1)],64))],8,Ca)):$("v-if",!0)]),u("div",{ref:"gif-popup",class:P(["wl-gif-popup",{display:K.value}])},[u("input",{ref:"gif-search",type:"text",placeholder:g.value.gifSearchPlaceholder,onInput:n[4]||(n[4]=(...h)=>w(Se)&&w(Se)(...h))},null,40,$a),T.list.length?(i(),ee(Ml,{key:0,items:T.list,"column-width":200,gap:6,onInsert:n[5]||(n[5]=h=>G(h)),onScroll:Ae},null,8,["items"])):$("v-if",!0),T.loading?(i(),s("div",Ia,[O(w(ce),{size:30})])):$("v-if",!0)],2),u("div",{ref:"emoji-popup",class:P(["wl-emoji-popup",{display:v.value}])},[(i(!0),s(B,null,Z(j.value.tabs,(h,D)=>(i(),s(B,{key:h.name},[D===o.value?(i(),s("div",Ea,[(i(!0),s(B,null,Z(h.items,N=>(i(),s("button",{key:N,type:"button",title:N,onClick:Y=>G(`:${N}:`)},[v.value?(i(),s("img",{key:0,class:"wl-emoji",src:j.value.map[N],alt:N,loading:"lazy",referrerPolicy:"no-referrer"},null,8,xa)):$("v-if",!0)],8,La))),128))])):$("v-if",!0)],64))),128)),j.value.tabs.length>1?(i(),s("div",Ma,[(i(!0),s(B,null,Z(j.value.tabs,(h,D)=>(i(),s("button",{key:h.name,type:"button",class:P(["wl-tab",{active:o.value===D}]),onClick:N=>o.value=D},[u("img",{class:"wl-emoji",src:h.icon,alt:h.name,title:h.name,loading:"lazy",referrerPolicy:"no-referrer"},null,8,Sa)],10,Aa))),128))])):$("v-if",!0)],2)])]),c.replyId||(H=c.edit)!=null&&H.objectId?(i(),s("button",{key:1,type:"button",class:"wl-close",title:g.value.cancelReply,onClick:n[6]||(n[6]=h=>c.replyId?l("cancelReply"):l("cancelEdit"))},[O(w(Te),{size:24})],8,ja)):$("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=["textContent"],Pa={class:"wl-comment-actions"},qa=["title"],Ga=["title"],Oa={class:"wl-meta","aria-hidden":"true"},Ka=["data-value","textContent"],Za={key:0,class:"wl-content"},Xa={key:0},Ya=["href"],Ja=["innerHTML"],Qa={key:1,class:"wl-admin-actions"},en={class:"wl-comment-status"},tn=["disabled","onClick","textContent"],ln={key:3,class:"wl-quote"};var an=oe({__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"],d=we(he),M=Fe(),k=$t(),C=be(),b=W(()=>d.value.locale),A=W(()=>{const{link:o}=t.comment;return o?tt(o)?o:`https://${o}`:""}),m=W(()=>M.value.includes(t.comment.objectId)),S=W(()=>Ul(new Date(t.comment.time),k.value,b.value)),U=W(()=>C.value.type==="administrator"),I=W(()=>t.comment.user_id&&C.value.objectId===t.comment.user_id),y=W(()=>{var o;return t.comment.objectId===((o=t.reply)==null?void 0:o.objectId)}),j=W(()=>{var o;return t.comment.objectId===((o=t.edit)==null?void 0:o.objectId)});return(o,v)=>{var K;const X=yt("CommentCard",!0);return i(),s("div",{id:o.comment.objectId.toString(),class:"wl-card-item"},[u("div",Ra,[o.comment.avatar?(i(),s("img",{key:0,class:"wl-user-avatar",src:o.comment.avatar,alt:""},null,8,Va)):$("v-if",!0),o.comment.type?(i(),ee(w(Wt),{key:1})):$("v-if",!0)]),u("div",Ua,[u("div",_a,[A.value?(i(),s("a",{key:0,class:"wl-nick",href:A.value,target:"_blank",rel:"nofollow noopener noreferrer"},L(o.comment.nick),9,Ha)):(i(),s("span",Ta,L(o.comment.nick),1)),o.comment.type==="administrator"?(i(),s("span",{key:2,class:"wl-badge",textContent:L(b.value.admin)},null,8,Fa)):$("v-if",!0),o.comment.label?(i(),s("span",{key:3,class:"wl-badge",textContent:L(o.comment.label)},null,8,Na)):$("v-if",!0),o.comment.sticky?(i(),s("span",{key:4,class:"wl-badge",textContent:L(b.value.sticky)},null,8,Wa)):$("v-if",!0),typeof o.comment.level=="number"?(i(),s("span",{key:5,class:P(`wl-badge level${o.comment.level}`),textContent:L(b.value[`level${o.comment.level}`]||`Level ${o.comment.level}`)},null,10,Ba)):$("v-if",!0),u("span",{class:"wl-time",textContent:L(S.value)},null,8,Da),u("div",Pa,[U.value||I.value?(i(),s(B,{key:0},[u("button",{type:"button",class:"wl-edit",onClick:v[0]||(v[0]=E=>l("edit",o.comment))},[O(w(Nt))]),u("button",{type:"button",class:"wl-delete",onClick:v[1]||(v[1]=E=>l("delete",o.comment))},[O(w(Rt))])],64)):$("v-if",!0),u("button",{type:"button",class:"wl-like",title:m.value?b.value.cancelLike:b.value.like,onClick:v[2]||(v[2]=E=>l("like",o.comment))},[O(w(_t),{active:m.value},null,8,["active"]),le(" "+L("like"in o.comment?o.comment.like:""),1)],8,qa),u("button",{type:"button",class:P(["wl-reply",{active:y.value}]),title:y.value?b.value.cancelReply:b.value.reply,onClick:v[3]||(v[3]=E=>l("reply",y.value?null:o.comment))},[O(w(Ft))],10,Ga)])]),u("div",Oa,[(i(),s(B,null,Z(["addr","browser","os"],E=>(i(),s(B,null,[o.comment[E]?(i(),s("span",{key:E,class:P(`wl-${E}`),"data-value":o.comment[E],textContent:L(o.comment[E])},null,10,Ka)):$("v-if",!0)],64))),64))]),j.value?$("v-if",!0):(i(),s("div",Za,["reply_user"in o.comment&&o.comment.reply_user?(i(),s("p",Xa,[u("a",{href:"#"+o.comment.pid},"@"+L(o.comment.reply_user.nick),9,Ya),v[17]||(v[17]=u("span",null,": ",-1))])):$("v-if",!0),u("div",{innerHTML:o.comment.comment},null,8,Ja)])),U.value&&!j.value?(i(),s("div",Qa,[u("span",en,[(i(),s(B,null,Z(r,E=>u("button",{key:E,type:"submit",class:P(`wl-btn wl-${E}`),disabled:o.comment.status===E,onClick:V=>l("status",{status:E,comment:o.comment}),textContent:L(b.value[E])},null,10,tn)),64))]),U.value&&!("rid"in o.comment)?(i(),s("button",{key:0,type:"submit",class:"wl-btn wl-sticky",onClick:v[4]||(v[4]=E=>l("sticky",o.comment))},L(o.comment.sticky?b.value.unsticky:b.value.sticky),1)):$("v-if",!0)])):$("v-if",!0),y.value||j.value?(i(),s("div",{key:2,class:P({"wl-reply-wrapper":y.value,"wl-edit-wrapper":j.value})},[O(rt,{edit:o.edit,"reply-id":(K=o.reply)==null?void 0:K.objectId,"reply-user":o.comment.nick,"root-id":o.rootId,onLog:v[5]||(v[5]=E=>l("log")),onCancelReply:v[6]||(v[6]=E=>l("reply",null)),onCancelEdit:v[7]||(v[7]=E=>l("edit",null)),onSubmit:v[8]||(v[8]=E=>l("submit",E))},null,8,["edit","reply-id","reply-user","root-id"])],2)):$("v-if",!0),"children"in o.comment?(i(),s("div",ln,[(i(!0),s(B,null,Z(o.comment.children,E=>(i(),ee(X,{key:E.objectId,comment:E,reply:o.reply,edit:o.edit,"root-id":o.rootId,onLog:v[9]||(v[9]=V=>l("log")),onDelete:v[10]||(v[10]=V=>l("delete",V)),onEdit:v[11]||(v[11]=V=>l("edit",V)),onLike:v[12]||(v[12]=V=>l("like",V)),onReply:v[13]||(v[13]=V=>l("reply",V)),onStatus:v[14]||(v[14]=V=>l("status",V)),onSticky:v[15]||(v[15]=V=>l("sticky",V)),onSubmit:v[16]||(v[16]=V=>l("submit",V))},null,8,["comment","reply","edit","root-id"]))),128))])):$("v-if",!0)])],8,za)}}});const ot="3.5.5",nn={"data-waline":""},rn={class:"wl-meta-head"},on={class:"wl-count"},sn=["textContent"],cn={class:"wl-sort"},un=["onClick"],mn={class:"wl-cards"},vn={key:1,class:"wl-operation"},dn=["textContent"],pn={key:2,class:"wl-loading"},gn=["textContent"],hn={key:4,class:"wl-operation"},fn=["textContent"],yn={key:5,class:"wl-power"};var wn=oe({__name:"WalineComment",props:{serverURL:{},path:{},meta:{},requiredMeta:{},wordLimit:{},pageSize:{},lang:{},locale:{},commentSorting:{},dark:{type:[String,Boolean]},login:{},noCopyright:{type:Boolean},recaptchaV3Key:{},turnstileKey:{},reaction:{},emoji:{},search:{},highlighter:{type:Function},imageUploader:{type:Function},texRenderer:{type:Function}},setup(e){const a=e,t=be(),l=Fe(),r=R("loading"),d=R(0),M=R(1),k=R(0),C=W(()=>zl(a)),b=R(C.value.commentSorting),A=R([]),m=R(null),S=R(null),U=W(()=>Rl(C.value.dark)),I=W(()=>C.value.locale);It(U,{id:"waline-darkmode"});let y=null;const j=p=>{const{serverURL:z,path:g,pageSize:F}=C.value,q=new AbortController;r.value="loading",y==null||y(),At({serverURL:z,lang:C.value.lang,path:g,pageSize:F,sortBy:Qe[b.value],page:p,signal:q.signal,token:t.value.token}).then(G=>{r.value="success",d.value=G.count,A.value.push(...G.data),M.value=p,k.value=G.totalPages}).catch(G=>{G.name!=="AbortError"&&(console.error(G.message),r.value="error")}),y=q.abort.bind(q)},o=()=>{j(M.value+1)},v=()=>{d.value=0,A.value=[],j(1)},K=p=>{b.value!==p&&(b.value=p,v())},X=p=>{m.value=p},E=p=>{S.value=p},V=p=>{if(S.value)S.value.comment=p.comment,S.value.orig=p.orig;else if("rid"in p){const z=A.value.find(({objectId:g})=>g===p.rid);if(!z)return;Array.isArray(z.children)||(z.children=[]),z.children.push(p)}else A.value.unshift(p),d.value+=1},T=async({comment:p,status:z})=>{if(p.status===z)return;const{serverURL:g,lang:F}=C.value;await ge({serverURL:g,lang:F,token:t.value.token,objectId:p.objectId,comment:{status:z}}),p.status=z},ae=async p=>{if("rid"in p)return;const{serverURL:z,lang:g}=C.value;await ge({serverURL:z,lang:g,token:t.value.token,objectId:p.objectId,comment:{sticky:p.sticky?0:1}}),p.sticky=!p.sticky},Q=async({objectId:p})=>{if(!confirm("Are you sure you want to delete this comment?"))return;const{serverURL:z,lang:g}=C.value;await Mt({serverURL:z,lang:g,token:t.value.token,objectId:p}),A.value.some((F,q)=>F.objectId===p?(A.value=A.value.filter((G,re)=>re!==q),!0):F.children.some((G,re)=>G.objectId===p?(A.value[q].children=F.children.filter((me,fe)=>fe!==re),!0):!1))},ue=async p=>{const{serverURL:z,lang:g}=C.value,{objectId:F}=p,q=l.value.includes(F);await ge({serverURL:z,lang:g,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))),p.like=Math.max(0,(p.like||0)+(q?-1:1))};return wt(he,C),de(()=>{se(()=>[a.serverURL,a.path],()=>{v()})}),je(()=>{y==null||y()}),(p,z)=>(i(),s("div",nn,[O(El),!m.value&&!S.value?(i(),ee(rt,{key:0,onLog:v,onSubmit:V})):$("v-if",!0),u("div",rn,[u("div",on,[d.value?(i(),s("span",{key:0,class:"wl-num",textContent:L(d.value)},null,8,sn)):$("v-if",!0),le(" "+L(I.value.comment),1)]),u("ul",cn,[(i(!0),s(B,null,Z(w(hl),g=>(i(),s("li",{key:g,class:P([g===b.value?"active":""]),onClick:F=>K(g)},L(I.value[g]),11,un))),128))])]),u("div",mn,[(i(!0),s(B,null,Z(A.value,g=>(i(),ee(an,{key:g.objectId,"root-id":g.objectId,comment:g,reply:m.value,edit:S.value,onLog:v,onReply:X,onEdit:E,onSubmit:V,onStatus:T,onDelete:Q,onSticky:ae,onLike:ue},null,8,["root-id","comment","reply","edit"]))),128))]),r.value==="error"?(i(),s("div",vn,[u("button",{type:"button",class:"wl-btn",onClick:v,textContent:L(I.value.refresh)},null,8,dn)])):r.value==="loading"?(i(),s("div",pn,[O(w(ce),{size:30})])):A.value.length?M.value<k.value?(i(),s("div",hn,[u("button",{type:"button",class:"wl-btn",onClick:o,textContent:L(I.value.more)},null,8,fn)])):$("v-if",!0):(i(),s("div",{key:3,class:"wl-empty",textContent:L(I.value.sofa)},null,8,gn)),C.value.noCopyright?$("v-if",!0):(i(),s("div",yn,[z[0]||(z[0]=le(" Powered by ")),z[1]||(z[1]=u("a",{href:"https://github.com/walinejs/waline",target:"_blank",rel:"noopener noreferrer"}," Waline ",-1)),le(" v"+L(w(ot)),1)]))]))}});export{wn as Waline,ot as version};
11
+ ![${c.name}](${f})`)}catch(f){alert(f.message),d.value=d.value.replace(n,"")}finally{p.value=!1}},fe=c=>{var n;if((n=c.dataTransfer)!=null&&n.items){const f=nt(c.dataTransfer.items);f&&q.value&&(me(f),c.preventDefault())}},st=c=>{if(c.clipboardData){const n=nt(c.clipboardData.items);n&&q.value&&me(n)}},ct=()=>{const c=A.value;c.files&&q.value&&me(c.files[0]).then(()=>{c.value=""})},xe=async()=>{var c;const{serverURL:n,lang:f,login:H,wordLimit:h,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(k.value.token)_.nick=k.value.display_name,_.mail=k.value.email,_.link=k.value.url;else{if(H==="force")return;if(D.includes("nick")&&!_.nick){C.value.nick.focus(),alert(g.value.nickError);return}if(D.includes("mail")&&!_.mail||_.mail&&!Hl(_.mail)){C.value.mail.focus(),alert(g.value.mailError);return}_.nick||(_.nick=g.value.anonymous)}if(!_.comment){b.value.focus();return}if(!Q.value){alert(g.value.wordHint.replace("$0",h[0].toString()).replace("$1",h[1].toString()).replace("$2",V.value.toString()));return}_.comment=it(_.comment,j.value.map),t.replyId&&t.rootId&&(_.pid=t.replyId,_.rid=t.rootId,_.at=t.replyUser),p.value=!0;try{N&&(_.recaptchaV3=await Xt(N).execute("social")),Y&&(_.turnstile=await Yt(Y).execute("social"));const ve={serverURL:n,lang:f,token:k.value.token,comment:_},ye=await(t.edit?ge({objectId:t.edit.objectId,...ve}):Lt(ve));if(p.value=!1,ye.errmsg){alert(ye.errmsg);return}l("submit",ye.data),d.value="",E.value="",await Re(),t.replyId&&l("cancelReply"),(c=t.edit)!=null&&c.objectId&&l("cancelEdit")}catch(ve){p.value=!1,alert(ve.message)}},ut=c=>{c.preventDefault();const{lang:n,serverURL:f}=r.value;xt({serverURL:f,lang:n}).then(H=>{k.value=H,(H.remember?localStorage:sessionStorage).setItem("WALINE_USER",JSON.stringify(H)),l("log")})},mt=()=>{k.value={},localStorage.setItem("WALINE_USER","null"),sessionStorage.setItem("WALINE_USER","null"),l("log")},Me=c=>{c.preventDefault();const{lang:n,serverURL:f}=r.value,H=800,h=800,D=(window.innerWidth-H)/2,N=(window.innerHeight-h)/2,Y=new URLSearchParams({lng:n,token:k.value.token}),_=window.open(`${f}/ui/profile?${Y.toString()}`,"_blank",`width=${H},height=${h},left=${D},top=${N},scrollbars=no,resizable=no,status=no,location=no,toolbar=no,menubar=no`);_==null||_.postMessage({type:"TOKEN",data:k.value.token},"*")},vt=c=>{var n,f,H,h;!((n=m.value)!=null&&n.contains(c.target))&&!((f=S.value)!=null&&f.contains(c.target))&&(v.value=!1),!((H=U.value)!=null&&H.contains(c.target))&&!((h=I.value)!=null&&h.contains(c.target))&&(K.value=!1)},Ae=async c=>{var n;const{scrollTop:f,clientHeight:H,scrollHeight:h}=c.target,D=(H+f)/h,N=r.value.search,Y=((n=y.value)==null?void 0:n.value)??"";D<.9||T.loading||z.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)]:z.value=!0,T.loading=!1,setTimeout(()=>{c.target.scrollTop=f},50))},Se=Ct(c=>{T.list=[],z.value=!1,Ae(c)},300);return Ue("click",vt),Ue("message",({data:c})=>{!c||c.type!=="profile"||(k.value={...k.value,...c.data},[localStorage,sessionStorage].filter(n=>n.getItem("WALINE_USER")).forEach(n=>{n.setItem("WALINE_USER",JSON.stringify(k))}))}),se([r,V],([c,n])=>{const{wordLimit:f}=c;f?n<f[0]&&f[0]!==0?(ae.value=f[0],Q.value=!1):n>f[1]?(ae.value=f[1],Q.value=!1):(ae.value=f[1],Q.value=!0):(ae.value=0,Q.value=!0)}),ke(K,async c=>{var n;if(!c)return;const f=r.value.search;y.value&&(y.value.value=""),T.loading=!0,T.list=await(((n=f.default)==null?void 0:n.call(f))??f.search("")),T.loading=!1}),de(()=>{var c;(c=t.edit)!=null&&c.objectId&&(d.value=t.edit.orig),se(()=>d.value,n=>{const{highlighter:f,texRenderer:H}=r.value;ue.value=n,E.value=Ol(n,{emojiMap:j.value.map,highlighter:f,texRenderer:H}),V.value=Xl(n),n?He(b.value):He.destroy(b.value)}),se(()=>r.value.emoji,async n=>{j.value=await Wl(n)})}),(c,n)=>{var f,H;return i(),s("div",{key:w(k).token,class:"wl-comment"},[w(r).login!=="disable"&&F.value&&!((f=c.edit)!=null&&f.objectId)?(i(),s("div",Jl,[u("div",Ql,[u("button",{type:"submit",class:"wl-logout-btn",title:g.value.logout,onClick:mt},[O(w(Te),{size:14})],8,ea),u("a",{href:"#",class:"wl-login-nick","aria-label":"Profile",title:g.value.profile,onClick:Me},[u("img",{src:w(k).avatar,alt:"avatar"},null,8,la)],8,ta)]),u("a",{href:"#",class:"wl-login-nick","aria-label":"Profile",title:g.value.profile,onClick:Me,textContent:L(w(k).display_name)},null,8,aa)])):$("v-if",!0),u("div",na,[w(r).login!=="force"&&w(r).meta.length&&!F.value?(i(),s("div",{key:0,class:P(["wl-header",`item${w(r).meta.length}`])},[(i(!0),s(B,null,Z(w(r).meta,h=>(i(),s("div",{key:h,class:"wl-header-item"},[u("label",{for:`wl-${h}`,textContent:L(g.value[h]+(w(r).requiredMeta.includes(h)||!w(r).requiredMeta.length?"":`(${g.value.optional})`))},null,8,ia),pe(u("input",{id:`wl-${h}`,ref_for:!0,ref:D=>{D&&(C.value[h]=D)},"onUpdate:modelValue":D=>w(M)[h]=D,class:P(["wl-input",`wl-${h}`]),name:h,type:h==="mail"?"email":"text"},null,10,ra),[[gt,w(M)[h]]])]))),128))],2)):$("v-if",!0),pe(u("textarea",{id:"wl-edit",ref:"textarea","onUpdate:modelValue":n[0]||(n[0]=h=>ht(d)?d.value=h:null),class:"wl-editor",placeholder:c.replyUser?`@${c.replyUser}`:g.value.placeholder,onKeydown:re,onDrop:fe,onPaste:st},null,40,oa),[[ft,w(d)]]),pe(u("div",sa,[n[7]||(n[7]=u("hr",null,null,-1)),u("h4",null,L(g.value.preview)+":",1),u("div",{class:"wl-content",innerHTML:E.value},null,8,ca)],512),[[Ve,X.value]]),u("div",ua,[u("div",ma,[u("a",va,[O(w(Tt))]),pe(u("button",{ref:"emoji-button",type:"button",class:P(["wl-action",{active:v.value}]),title:g.value.emoji,onClick:n[1]||(n[1]=h=>v.value=!v.value)},[O(w(Vt))],10,da),[[Ve,j.value.tabs.length]]),w(r).search?(i(),s("button",{key:0,ref:"gif-button",type:"button",class:P(["wl-action",{active:K.value}]),title:g.value.gif,onClick:n[2]||(n[2]=h=>K.value=!K.value)},[O(w(Bt))],10,pa)):$("v-if",!0),u("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(),s("label",{key:1,for:"wl-image-upload",class:"wl-action",title:g.value.uploadImage,"aria-label":g.value.uploadImage},[O(w(Ut))],8,ga)):$("v-if",!0),u("button",{type:"button",class:P(["wl-action",{active:X.value}]),title:g.value.preview,onClick:n[3]||(n[3]=h=>X.value=!X.value)},[O(w(Ht))],10,ha)]),u("div",fa,[n[9]||(n[9]=u("div",{class:"wl-captcha-container"},null,-1)),u("div",ya,[le(L(V.value)+" ",1),w(r).wordLimit?(i(),s("span",wa,[n[8]||(n[8]=le("  /  ")),u("span",{class:P({illegal:!Q.value}),textContent:L(ae.value)},null,10,ka)])):$("v-if",!0),le("  "+L(g.value.word),1)]),w(r).login!=="disable"&&!F.value?(i(),s("button",{key:0,type:"button",class:"wl-btn",onClick:ut,textContent:L(g.value.login)},null,8,ba)):$("v-if",!0),w(r).login!=="force"||F.value?(i(),s("button",{key:1,type:"submit",class:"primary wl-btn",title:"Cmd|Ctrl + Enter",disabled:p.value,onClick:xe},[p.value?(i(),ee(w(ce),{key:0,size:16})):(i(),s(B,{key:1},[le(L(g.value.submit),1)],64))],8,Ca)):$("v-if",!0)]),u("div",{ref:"gif-popup",class:P(["wl-gif-popup",{display:K.value}])},[u("input",{ref:"gif-search",type:"text",placeholder:g.value.gifSearchPlaceholder,onInput:n[4]||(n[4]=(...h)=>w(Se)&&w(Se)(...h))},null,40,$a),T.list.length?(i(),ee(Ml,{key:0,items:T.list,"column-width":200,gap:6,onInsert:n[5]||(n[5]=h=>G(h)),onScroll:Ae},null,8,["items"])):$("v-if",!0),T.loading?(i(),s("div",Ia,[O(w(ce),{size:30})])):$("v-if",!0)],2),u("div",{ref:"emoji-popup",class:P(["wl-emoji-popup",{display:v.value}])},[(i(!0),s(B,null,Z(j.value.tabs,(h,D)=>(i(),s(B,{key:h.name},[D===o.value?(i(),s("div",Ea,[(i(!0),s(B,null,Z(h.items,N=>(i(),s("button",{key:N,type:"button",title:N,onClick:Y=>G(`:${N}:`)},[v.value?(i(),s("img",{key:0,class:"wl-emoji",src:j.value.map[N],alt:N,loading:"lazy",referrerPolicy:"no-referrer"},null,8,xa)):$("v-if",!0)],8,La))),128))])):$("v-if",!0)],64))),128)),j.value.tabs.length>1?(i(),s("div",Ma,[(i(!0),s(B,null,Z(j.value.tabs,(h,D)=>(i(),s("button",{key:h.name,type:"button",class:P(["wl-tab",{active:o.value===D}]),onClick:N=>o.value=D},[u("img",{class:"wl-emoji",src:h.icon,alt:h.name,title:h.name,loading:"lazy",referrerPolicy:"no-referrer"},null,8,Sa)],10,Aa))),128))])):$("v-if",!0)],2)])]),c.replyId||(H=c.edit)!=null&&H.objectId?(i(),s("button",{key:1,type:"button",class:"wl-close",title:g.value.cancelReply,onClick:n[6]||(n[6]=h=>c.replyId?l("cancelReply"):l("cancelEdit"))},[O(w(Te),{size:24})],8,ja)):$("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=["textContent"],Pa={class:"wl-comment-actions"},qa=["title"],Ga=["title"],Oa={class:"wl-meta","aria-hidden":"true"},Ka=["data-value","textContent"],Za={key:0,class:"wl-content"},Xa={key:0},Ya=["href"],Ja=["innerHTML"],Qa={key:1,class:"wl-admin-actions"},en={class:"wl-comment-status"},tn=["disabled","onClick","textContent"],ln={key:3,class:"wl-quote"};var an=oe({__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"],d=we(he),M=Fe(),k=$t(),C=be(),b=W(()=>d.value.locale),A=W(()=>{const{link:o}=t.comment;return o?tt(o)?o:`https://${o}`:""}),m=W(()=>M.value.includes(t.comment.objectId)),S=W(()=>Ul(new Date(t.comment.time),k.value,b.value)),U=W(()=>C.value.type==="administrator"),I=W(()=>t.comment.user_id&&C.value.objectId===t.comment.user_id),y=W(()=>{var o;return t.comment.objectId===((o=t.reply)==null?void 0:o.objectId)}),j=W(()=>{var o;return t.comment.objectId===((o=t.edit)==null?void 0:o.objectId)});return(o,v)=>{var K;const X=yt("CommentCard",!0);return i(),s("div",{id:o.comment.objectId.toString(),class:"wl-card-item"},[u("div",Ra,[o.comment.avatar?(i(),s("img",{key:0,class:"wl-user-avatar",src:o.comment.avatar,alt:""},null,8,Va)):$("v-if",!0),o.comment.type?(i(),ee(w(Wt),{key:1})):$("v-if",!0)]),u("div",Ua,[u("div",_a,[A.value?(i(),s("a",{key:0,class:"wl-nick",href:A.value,target:"_blank",rel:"nofollow noopener noreferrer"},L(o.comment.nick),9,Ha)):(i(),s("span",Ta,L(o.comment.nick),1)),o.comment.type==="administrator"?(i(),s("span",{key:2,class:"wl-badge",textContent:L(b.value.admin)},null,8,Fa)):$("v-if",!0),o.comment.label?(i(),s("span",{key:3,class:"wl-badge",textContent:L(o.comment.label)},null,8,Na)):$("v-if",!0),o.comment.sticky?(i(),s("span",{key:4,class:"wl-badge",textContent:L(b.value.sticky)},null,8,Wa)):$("v-if",!0),typeof o.comment.level=="number"?(i(),s("span",{key:5,class:P(`wl-badge level${o.comment.level}`),textContent:L(b.value[`level${o.comment.level}`]||`Level ${o.comment.level}`)},null,10,Ba)):$("v-if",!0),u("span",{class:"wl-time",textContent:L(S.value)},null,8,Da),u("div",Pa,[U.value||I.value?(i(),s(B,{key:0},[u("button",{type:"button",class:"wl-edit",onClick:v[0]||(v[0]=E=>l("edit",o.comment))},[O(w(Nt))]),u("button",{type:"button",class:"wl-delete",onClick:v[1]||(v[1]=E=>l("delete",o.comment))},[O(w(Rt))])],64)):$("v-if",!0),u("button",{type:"button",class:"wl-like",title:m.value?b.value.cancelLike:b.value.like,onClick:v[2]||(v[2]=E=>l("like",o.comment))},[O(w(_t),{active:m.value},null,8,["active"]),le(" "+L("like"in o.comment?o.comment.like:""),1)],8,qa),u("button",{type:"button",class:P(["wl-reply",{active:y.value}]),title:y.value?b.value.cancelReply:b.value.reply,onClick:v[3]||(v[3]=E=>l("reply",y.value?null:o.comment))},[O(w(Ft))],10,Ga)])]),u("div",Oa,[(i(),s(B,null,Z(["addr","browser","os"],E=>(i(),s(B,null,[o.comment[E]?(i(),s("span",{key:E,class:P(`wl-${E}`),"data-value":o.comment[E],textContent:L(o.comment[E])},null,10,Ka)):$("v-if",!0)],64))),64))]),j.value?$("v-if",!0):(i(),s("div",Za,["reply_user"in o.comment&&o.comment.reply_user?(i(),s("p",Xa,[u("a",{href:"#"+o.comment.pid},"@"+L(o.comment.reply_user.nick),9,Ya),v[17]||(v[17]=u("span",null,": ",-1))])):$("v-if",!0),u("div",{innerHTML:o.comment.comment},null,8,Ja)])),U.value&&!j.value?(i(),s("div",Qa,[u("span",en,[(i(),s(B,null,Z(r,E=>u("button",{key:E,type:"submit",class:P(`wl-btn wl-${E}`),disabled:o.comment.status===E,onClick:V=>l("status",{status:E,comment:o.comment}),textContent:L(b.value[E])},null,10,tn)),64))]),U.value&&!("rid"in o.comment)?(i(),s("button",{key:0,type:"submit",class:"wl-btn wl-sticky",onClick:v[4]||(v[4]=E=>l("sticky",o.comment))},L(o.comment.sticky?b.value.unsticky:b.value.sticky),1)):$("v-if",!0)])):$("v-if",!0),y.value||j.value?(i(),s("div",{key:2,class:P({"wl-reply-wrapper":y.value,"wl-edit-wrapper":j.value})},[O(rt,{edit:o.edit,"reply-id":(K=o.reply)==null?void 0:K.objectId,"reply-user":o.comment.nick,"root-id":o.rootId,onLog:v[5]||(v[5]=E=>l("log")),onCancelReply:v[6]||(v[6]=E=>l("reply",null)),onCancelEdit:v[7]||(v[7]=E=>l("edit",null)),onSubmit:v[8]||(v[8]=E=>l("submit",E))},null,8,["edit","reply-id","reply-user","root-id"])],2)):$("v-if",!0),"children"in o.comment?(i(),s("div",ln,[(i(!0),s(B,null,Z(o.comment.children,E=>(i(),ee(X,{key:E.objectId,comment:E,reply:o.reply,edit:o.edit,"root-id":o.rootId,onLog:v[9]||(v[9]=V=>l("log")),onDelete:v[10]||(v[10]=V=>l("delete",V)),onEdit:v[11]||(v[11]=V=>l("edit",V)),onLike:v[12]||(v[12]=V=>l("like",V)),onReply:v[13]||(v[13]=V=>l("reply",V)),onStatus:v[14]||(v[14]=V=>l("status",V)),onSticky:v[15]||(v[15]=V=>l("sticky",V)),onSubmit:v[16]||(v[16]=V=>l("submit",V))},null,8,["comment","reply","edit","root-id"]))),128))])):$("v-if",!0)])],8,za)}}});const ot="3.5.6",nn={"data-waline":""},rn={class:"wl-meta-head"},on={class:"wl-count"},sn=["textContent"],cn={class:"wl-sort"},un=["onClick"],mn={class:"wl-cards"},vn={key:1,class:"wl-operation"},dn=["textContent"],pn={key:2,class:"wl-loading"},gn=["textContent"],hn={key:4,class:"wl-operation"},fn=["textContent"],yn={key:5,class:"wl-power"};var wn=oe({__name:"WalineComment",props:{serverURL:{},path:{},meta:{},requiredMeta:{},wordLimit:{},pageSize:{},lang:{},locale:{},commentSorting:{},dark:{type:[String,Boolean]},login:{},noCopyright:{type:Boolean},recaptchaV3Key:{},turnstileKey:{},reaction:{},emoji:{},search:{},highlighter:{type:Function},imageUploader:{type:Function},texRenderer:{type:Function}},setup(e){const a=e,t=be(),l=Fe(),r=R("loading"),d=R(0),M=R(1),k=R(0),C=W(()=>zl(a)),b=R(C.value.commentSorting),A=R([]),m=R(null),S=R(null),U=W(()=>Rl(C.value.dark)),I=W(()=>C.value.locale);It(U,{id:"waline-darkmode"});let y=null;const j=p=>{const{serverURL:z,path:g,pageSize:F}=C.value,q=new AbortController;r.value="loading",y==null||y(),At({serverURL:z,lang:C.value.lang,path:g,pageSize:F,sortBy:Qe[b.value],page:p,signal:q.signal,token:t.value.token}).then(G=>{r.value="success",d.value=G.count,A.value.push(...G.data),M.value=p,k.value=G.totalPages}).catch(G=>{G.name!=="AbortError"&&(console.error(G.message),r.value="error")}),y=q.abort.bind(q)},o=()=>{j(M.value+1)},v=()=>{d.value=0,A.value=[],j(1)},K=p=>{b.value!==p&&(b.value=p,v())},X=p=>{m.value=p},E=p=>{S.value=p},V=p=>{if(S.value)S.value.comment=p.comment,S.value.orig=p.orig;else if("rid"in p){const z=A.value.find(({objectId:g})=>g===p.rid);if(!z)return;Array.isArray(z.children)||(z.children=[]),z.children.push(p)}else A.value.unshift(p),d.value+=1},T=async({comment:p,status:z})=>{if(p.status===z)return;const{serverURL:g,lang:F}=C.value;await ge({serverURL:g,lang:F,token:t.value.token,objectId:p.objectId,comment:{status:z}}),p.status=z},ae=async p=>{if("rid"in p)return;const{serverURL:z,lang:g}=C.value;await ge({serverURL:z,lang:g,token:t.value.token,objectId:p.objectId,comment:{sticky:p.sticky?0:1}}),p.sticky=!p.sticky},Q=async({objectId:p})=>{if(!confirm("Are you sure you want to delete this comment?"))return;const{serverURL:z,lang:g}=C.value;await Mt({serverURL:z,lang:g,token:t.value.token,objectId:p}),A.value.some((F,q)=>F.objectId===p?(A.value=A.value.filter((G,re)=>re!==q),!0):F.children.some((G,re)=>G.objectId===p?(A.value[q].children=F.children.filter((me,fe)=>fe!==re),!0):!1))},ue=async p=>{const{serverURL:z,lang:g}=C.value,{objectId:F}=p,q=l.value.includes(F);await ge({serverURL:z,lang:g,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))),p.like=Math.max(0,(p.like||0)+(q?-1:1))};return wt(he,C),de(()=>{se(()=>[a.serverURL,a.path],()=>{v()})}),je(()=>{y==null||y()}),(p,z)=>(i(),s("div",nn,[O(El),!m.value&&!S.value?(i(),ee(rt,{key:0,onLog:v,onSubmit:V})):$("v-if",!0),u("div",rn,[u("div",on,[d.value?(i(),s("span",{key:0,class:"wl-num",textContent:L(d.value)},null,8,sn)):$("v-if",!0),le(" "+L(I.value.comment),1)]),u("ul",cn,[(i(!0),s(B,null,Z(w(hl),g=>(i(),s("li",{key:g,class:P([g===b.value?"active":""]),onClick:F=>K(g)},L(I.value[g]),11,un))),128))])]),u("div",mn,[(i(!0),s(B,null,Z(A.value,g=>(i(),ee(an,{key:g.objectId,"root-id":g.objectId,comment:g,reply:m.value,edit:S.value,onLog:v,onReply:X,onEdit:E,onSubmit:V,onStatus:T,onDelete:Q,onSticky:ae,onLike:ue},null,8,["root-id","comment","reply","edit"]))),128))]),r.value==="error"?(i(),s("div",vn,[u("button",{type:"button",class:"wl-btn",onClick:v,textContent:L(I.value.refresh)},null,8,dn)])):r.value==="loading"?(i(),s("div",pn,[O(w(ce),{size:30})])):A.value.length?M.value<k.value?(i(),s("div",hn,[u("button",{type:"button",class:"wl-btn",onClick:o,textContent:L(I.value.more)},null,8,fn)])):$("v-if",!0):(i(),s("div",{key:3,class:"wl-empty",textContent:L(I.value.sofa)},null,8,gn)),C.value.noCopyright?$("v-if",!0):(i(),s("div",yn,[z[0]||(z[0]=le(" Powered by ")),z[1]||(z[1]=u("a",{href:"https://github.com/walinejs/waline",target:"_blank",rel:"noopener noreferrer"}," Waline ",-1)),le(" v"+L(w(ot)),1)]))]))}});export{wn as Waline,ot as version};
12
12
  //# sourceMappingURL=component.js.map