@waline/client 3.2.5 → 3.2.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 h=t=>`${t.replace(/\/?$/,"/")}api/`,i=(t,e="")=>{if(typeof t=="object"&&t.errno)throw new TypeError(`${e} failed with ${t.errno}: ${t.errmsg}`);return t},g=({serverURL:t,lang:e,paths:r,signal:o})=>fetch(`${h(t)}comment?type=count&url=${encodeURIComponent(r.join(","))}&lang=${e}`,{signal:o}).then(n=>n.json()).then(n=>i(n,"Get comment count").data),p=t=>{try{t=decodeURI(t)}catch{}return t},m=(t="")=>t.replace(/\/$/u,""),u=t=>/^(https?:)?\/\//.test(t),d=t=>{const e=m(t);return u(e)?e:`https://${e}`},$=t=>{t.name!=="AbortError"&&console.error(t.message)},f=t=>{const{path:e}=t.dataset;return e!=null&&e.length?e:null},v=({serverURL:t,path:e=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(t),paths:Array.from(a).map(c=>p(f(c)??e)),lang:o,signal:n.signal}).then(c=>{a.forEach((s,l)=>{s.innerText=c[l].toString()})}).catch($),n.abort.bind(n)},w="3.2.5";export{v as commentCount,w as version};
1
+ const h=t=>`${t.replace(/\/?$/,"/")}api/`,i=(t,e="")=>{if(typeof t=="object"&&t.errno)throw new TypeError(`${e} failed with ${t.errno}: ${t.errmsg}`);return t},g=({serverURL:t,lang:e,paths:r,signal:o})=>fetch(`${h(t)}comment?type=count&url=${encodeURIComponent(r.join(","))}&lang=${e}`,{signal:o}).then(n=>n.json()).then(n=>i(n,"Get comment count").data),p=t=>{try{t=decodeURI(t)}catch{}return t},m=(t="")=>t.replace(/\/$/u,""),u=t=>/^(https?:)?\/\//.test(t),d=t=>{const e=m(t);return u(e)?e:`https://${e}`},$=t=>{t.name!=="AbortError"&&console.error(t.message)},f=t=>{const{path:e}=t.dataset;return e!=null&&e.length?e:null},v=({serverURL:t,path:e=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(t),paths:Array.from(a).map(c=>p(f(c)??e)),lang:o,signal:n.signal}).then(c=>{a.forEach((s,l)=>{s.innerText=c[l].toString()})}).catch($),n.abort.bind(n)},w="3.2.6";export{v as commentCount,w as version};
2
2
  //# sourceMappingURL=comment.js.map
package/dist/component.js CHANGED
@@ -7,5 +7,5 @@ import{h as C,defineComponent as ue,inject as Ce,ref as b,computed as U,onMounte
7
7
  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?"]),it=te(["昵称","昵称不能少于3个字符","邮箱","请填写正确的邮件地址","网址","可选","欢迎评论","来发评论吧~","提交","喜欢","取消喜欢","回复","取消回复","评论","刷新","加载更多...","预览","表情","上传图片","秒前","分钟前","小时前","天前","刚刚","正在上传","登录","退出","博主","置顶","字",`评论字数应在 $0 到 $1 字之间!
8
8
  当前字数:$2`,"匿名","潜水","冒泡","吐槽","活跃","话痨","传说","表情包","搜索表情包","个人资料","通过","待审核","垃圾","取消置顶","按倒序","按正序","按热度","你认为这篇文章怎么样?"]),jn=te(["暱稱","暱稱不能少於3個字元","郵箱","請填寫正確的郵件地址","網址","可選","歡迎留言","來發留言吧~","送出","喜歡","取消喜歡","回覆","取消回覆","留言","重整","載入更多...","預覽","表情","上傳圖片","秒前","分鐘前","小時前","天前","剛剛","正在上傳","登入","登出","管理者","置頂","字",`留言字數應在 $0 到 $1 字之間!
9
9
  目前字數:$2`,"匿名","潛水","冒泡","吐槽","活躍","多話","傳說","表情包","搜尋表情包","個人資料","通過","待審核","垃圾","取消置頂","最早","最新","熱門","你認為這篇文章怎麼樣?"]);const at="en-US",Le={zh:it,"zh-cn":it,"zh-tw":jn,en:et,"en-us":et,fr:tt,"fr-fr":tt,jp:nt,"jp-jp":nt,"pt-br":Sn,ru:ot,"ru-ru":ot,vi:lt,"vi-vn":lt},Mn=o=>Le[o.toLowerCase()]||Le[at],An=o=>Object.keys(Le).includes(o.toLowerCase())?o:at,zn=o=>{const n=Xe(o);return Ye(n)?n:`https://${n}`},Un=o=>Array.isArray(o)?o:o?[0,o]:!1,Ee=(o,n)=>typeof o=="function"?o:o===!1?!1:n,Vn=({serverURL:o,path:n=location.pathname,lang:t=typeof navigator>"u"?"en-US":navigator.language,locale:e,emoji:r=Qe,meta:s=["nick","mail","link"],requiredMeta:d=[],dark:h=!1,pageSize:l=10,wordLimit:c,imageUploader:y,highlighter:I,texRenderer:A,copyright:g=!0,login:R="enable",search:x,reaction:p,recaptchaV3Key:E="",turnstileKey:T="",commentSorting:S="latest",...G})=>({serverURL:zn(o),path:fn(n),lang:An(t),locale:{...Mn(t),...typeof e=="object"?e:{}},wordLimit:Un(c),meta:Je(s),requiredMeta:Je(d),imageUploader:Ee(y,bn),highlighter:Ee(I,xn),texRenderer:Ee(A,kn),dark:h,emoji:typeof r=="boolean"?r?Qe:[]:r,pageSize:l,login:R,copyright:g,search:x===!1?!1:typeof x=="object"?x:_n(t),recaptchaV3Key:E,turnstileKey:T,reaction:Array.isArray(p)?p:p===!0?yn:[],commentSorting:S,...G}),xe=o=>typeof o=="string",Re="{--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}",Tn=o=>xe(o)?o==="auto"?`@media(prefers-color-scheme:dark){body${Re}}`:`${o}${Re}`:o===!0?`:root${Re}`:"",Se=(o,n)=>{let t=o.toString();for(;t.length<n;)t="0"+t;return t},Hn=o=>{const n=Se(o.getDate(),2),t=Se(o.getMonth()+1,2);return`${Se(o.getFullYear(),2)}-${t}-${n}`},Pn=(o,n,t)=>{if(!o)return"";const e=xe(o)?new Date(o.indexOf(" ")!==-1?o.replace(/-/g,"/"):o):o,r=n.getTime()-e.getTime(),s=Math.floor(r/(24*3600*1e3));if(s===0){const d=r%864e5,h=Math.floor(d/(3600*1e3));if(h===0){const l=d%36e5,c=Math.floor(l/(60*1e3));if(c===0){const y=l%6e4;return`${Math.round(y/1e3)} ${t.seconds}`}return`${c} ${t.minutes}`}return`${h} ${t.hours}`}return s<0?t.now:s<8?`${s} ${t.days}`:Hn(e)},Nn=/^[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])?)*$/,Wn=o=>Nn.test(o),Dn=o=>!!/@[0-9]+\.[0-9]+\.[0-9]+/.test(o),Bn=o=>{const n=ae("WALINE_EMOJI",{}),t=Dn(o);if(t){const e=n.value[o];if(e)return Promise.resolve(e)}return fetch(`${o}/info.json`).then(e=>e.json()).then(e=>{const r={folder:o,...e};return t&&(n.value[o]=r),r})},rt=(o,n="",t="",e="")=>`${n?`${n}/`:""}${t}${o}${e?`.${e}`:""}`,Fn=o=>Promise.all(o.map(n=>xe(n)?Bn(Xe(n)):Promise.resolve(n))).then(n=>{const t={tabs:[],map:{}};return n.forEach(e=>{const{name:r,folder:s,icon:d,prefix:h="",type:l,items:c}=e;t.tabs.push({name:r,icon:rt(d,s,h,l),items:c.map(y=>{const I=`${h}${y}`;return t.map[I]=rt(y,s,h,l),I})})}),t}),On=o=>o.type.includes("image"),ct=o=>{const n=Array.from(o).find(On);return n?n.getAsFile():null},Gn=/\$.*?\$/,qn=/^\$(.*?)\$/,Kn=/^(?:\s{0,3})\$\$((?:[^\n]|\n[^\n])+?)\n{0,1}\$\$/,Zn=o=>[{name:"blockMath",level:"block",tokenizer(n){const t=Kn.exec(n);if(t!==null)return{type:"html",raw:t[0],text:o(!0,t[1])}}},{name:"inlineMath",level:"inline",start(n){const t=n.search(Gn);return t!==-1?t:n.length},tokenizer(n){const t=qn.exec(n);if(t!==null)return{type:"html",raw:t[0],text:o(!1,t[1])}}}],st=(o="",n={})=>o.replace(/:(.+?):/g,(t,e)=>n[e]?`<img class="wl-emoji" src="${n[e]}" alt="${e}">`:t),Xn=(o,{emojiMap:n,highlighter:t,texRenderer:e})=>{const r=new Mt;if(r.setOptions({breaks:!0}),t&&r.use(At({highlight:t})),e){const s=Zn(e);r.use({extensions:s})}return r.parse(st(o,n))},Yn=o=>o.match(/[\w\d\s,.\u00C0-\u024F\u0400-\u04FF]+/giu),Jn=o=>o.match(/[\u4E00-\u9FD5]/gu),Qn=o=>{var n,t;return(((n=Yn(o))==null?void 0:n.reduce((e,r)=>e+(["",",","."].includes(r.trim())?0:r.trim().split(/\s+/u).length),0))??0)+(((t=Jn(o))==null?void 0:t.length)??0)},$n=async()=>{if(!navigator)return"";const{userAgentData:o}=navigator;let n=navigator.userAgent;if(!o||o.platform!=="Windows")return n;const{platformVersion:t}=await o.getHighEntropyValues(["platformVersion"]);return t&&parseInt(t.split(".")[0])>=13&&(n=n.replace("Windows NT 10.0","Windows NT 11.0")),n};var eo=ue({__name:"CommentBox",props:{edit:{default:null},rootId:{default:""},replyId:{default:""},replyUser:{default:""}},emits:["log","cancelEdit","cancelReply","submit"],setup(o,{expose:n,emit:t}){n();const e=o,r=t,s=Ce("config"),d=qt(),h=Gt(),l=pe(),c=b({}),y=b(null),I=b(null),A=b(null),g=b(null),R=b(null),x=b(null),p=b(null),E=b({tabs:[],map:{}}),T=b(0),S=b(!1),G=b(!1),re=b(!1),ce=b(""),oe=b(0),H=wt({loading:!0,list:[]}),ne=b(0),Z=b(!1),se=b(""),X=b(!1),le=b(!1),Y=U(()=>s.value.locale),w=U(()=>{var m;return!!((m=l.value)!=null&&m.token)}),L=U(()=>s.value.imageUploader!==!1),N=m=>{const v=y.value,f=v.selectionStart,j=v.selectionEnd||0,F=v.scrollTop;d.value=v.value.substring(0,f)+m+v.value.substring(j,v.value.length),v.focus(),v.selectionStart=f+m.length,v.selectionEnd=f+m.length,v.scrollTop=F},q=m=>{const v=m.key;(m.ctrlKey||m.metaKey)&&v==="Enter"&&be()},z=m=>{const v=`![${s.value.locale.uploading} ${m.name}]()`;return N(v),X.value=!0,Promise.resolve().then(()=>s.value.imageUploader(m)).then(f=>{d.value=d.value.replace(v,`\r
10
- ![${m.name}](${f})`)}).catch(f=>{alert(f.message),d.value=d.value.replace(v,"")}).then(()=>{X.value=!1})},B=m=>{var v;if((v=m.dataTransfer)!=null&&v.items){const f=ct(m.dataTransfer.items);f&&L.value&&(z(f),m.preventDefault())}},D=m=>{if(m.clipboardData){const v=ct(m.clipboardData.items);v&&L.value&&z(v)}},de=()=>{const m=I.value;m.files&&L.value&&z(m.files[0]).then(()=>{m.value=""})},be=async()=>{var m,v,f,j,F,ie;const{serverURL:K,lang:J,login:ve,wordLimit:ze,requiredMeta:Ue,recaptchaV3Key:Ve,turnstileKey:Te}=s.value,ht=await $n(),M={comment:se.value,nick:h.value.nick,mail:h.value.mail,link:h.value.link,url:s.value.path,ua:ht};if((m=l.value)!=null&&m.token&&!e.edit)M.nick=l.value.display_name,M.mail=l.value.email,M.link=l.value.url;else{if(ve==="force")return;if(Ue.indexOf("nick")>-1&&!M.nick)return(v=c.value.nick)==null||v.focus(),alert(Y.value.nickError);if(Ue.indexOf("mail")>-1&&!M.mail||M.mail&&!Wn(M.mail))return(f=c.value.mail)==null||f.focus(),alert(Y.value.mailError);M.nick||(M.nick=Y.value.anonymous)}if(!M.comment){(j=y.value)==null||j.focus();return}if(!Z.value)return alert(Y.value.wordHint.replace("$0",ze[0].toString()).replace("$1",ze[1].toString()).replace("$2",oe.value.toString()));M.comment=st(M.comment,E.value.map),e.replyId&&e.rootId&&(M.pid=e.replyId,M.rid=e.rootId,M.at=e.replyUser),X.value=!0;try{Ve&&(M.recaptchaV3=await Yt(Ve).execute("social")),Te&&(M.turnstile=await Jt(Te).execute("social"));const ge={serverURL:K,lang:J,token:(F=l.value)==null?void 0:F.token,comment:M},_e=await(e.edit?we({objectId:e.edit.objectId,...ge}):xt(ge));if(X.value=!1,_e.errmsg)return alert(_e.errmsg);r("submit",_e.data),d.value="",ce.value="",await Pe(),e.replyId&&r("cancelReply"),(ie=e.edit)!=null&&ie.objectId&&r("cancelEdit")}catch(ge){X.value=!1,alert(ge.message)}},ke=m=>{m.preventDefault();const{lang:v,serverURL:f}=s.value;Rt({serverURL:f,lang:v}).then(j=>{l.value=j,(j.remember?localStorage:sessionStorage).setItem("WALINE_USER",JSON.stringify(j)),r("log")})},mt=()=>{l.value={},localStorage.setItem("WALINE_USER","null"),sessionStorage.setItem("WALINE_USER","null"),r("log")},vt=m=>{m.preventDefault();const{lang:v,serverURL:f}=s.value,j=800,F=800,ie=(window.innerWidth-j)/2,K=(window.innerHeight-F)/2,J=new URLSearchParams({lng:v,token:l.value.token}),ve=window.open(`${f}/ui/profile?${J.toString()}`,"_blank",`width=${j},height=${F},left=${ie},top=${K},scrollbars=no,resizable=no,status=no,location=no,toolbar=no,menubar=no`);ve==null||ve.postMessage({type:"TOKEN",data:l.value.token},"*")},je=m=>{var v,f,j,F;!((v=A.value)!=null&&v.contains(m.target))&&!((f=g.value)!=null&&f.contains(m.target))&&(S.value=!1),!((j=R.value)!=null&&j.contains(m.target))&&!((F=x.value)!=null&&F.contains(m.target))&&(G.value=!1)},Me=async m=>{var v;const{scrollTop:f,clientHeight:j,scrollHeight:F}=m.target,ie=(j+f)/F,K=s.value.search,J=((v=p.value)==null?void 0:v.value)??"";ie<.9||H.loading||le.value||(H.loading=!0,(K.more&&H.list.length?await K.more(J,H.list.length):await K.search(J)).length?H.list=[...H.list,...K.more&&H.list.length?await K.more(J,H.list.length):await K.search(J)]:le.value=!0,H.loading=!1,setTimeout(()=>{m.target.scrollTop=f},50))},gt=pt(m=>{H.list=[],le.value=!1,Me(m)},300);Q([s,oe],([m,v])=>{const{wordLimit:f}=m;f?v<f[0]&&f[0]!==0?(ne.value=f[0],Z.value=!1):v>f[1]?(ne.value=f[1],Z.value=!1):(ne.value=f[1],Z.value=!0):(ne.value=0,Z.value=!0)},{immediate:!0}),De("click",je),De("message",({data:m})=>{!m||m.type!=="profile"||(l.value={...l.value,...m.data},[localStorage,sessionStorage].filter(v=>v.getItem("WALINE_USER")).forEach(v=>v.setItem("WALINE_USER",JSON.stringify(l))))}),Q(G,async m=>{var v;if(!m)return;const f=s.value.search;p.value&&(p.value.value=""),H.loading=!0,H.list=await(((v=f.default)==null?void 0:v.call(f))??f.search("")),H.loading=!1}),he(()=>{var m;(m=e.edit)!=null&&m.objectId&&(d.value=e.edit.orig),Q(()=>d.value,v=>{const{highlighter:f,texRenderer:j}=s.value;se.value=v,ce.value=Xn(v,{emojiMap:E.value.map,highlighter:f,texRenderer:j}),oe.value=Qn(v),v?Fe(y.value):Fe.destroy(y.value)},{immediate:!0}),Q(()=>s.value.emoji,v=>Fn(v).then(f=>{E.value=f}),{immediate:!0})});const Ae={props:e,emit:r,config:s,editor:d,userMeta:h,userInfo:l,inputRefs:c,editorRef:y,imageUploadRef:I,emojiButtonRef:A,emojiPopupRef:g,gifButtonRef:R,gifPopupRef:x,gifSearchInputRef:p,emoji:E,emojiTabIndex:T,showEmoji:S,showGif:G,showPreview:re,previewText:ce,wordNumber:oe,searchResults:H,wordLimit:ne,isWordNumberLegal:Z,content:se,isSubmitting:X,isImageListEnd:le,locale:Y,isLogin:w,canUploadImage:L,insert:N,onKeyDown:q,uploadImage:z,onDrop:B,onPaste:D,onChange:de,submitComment:be,onLogin:ke,onLogout:mt,onProfile:vt,popupHandler:je,onImageWallScroll:Me,onGifSearch:gt,get CloseIcon(){return Ut},get EmojiIcon(){return Tt},get GifIcon(){return Ot},get ImageIcon(){return Ht},get LoadingIcon(){return ye},get MarkdownIcon(){return Wt},get PreviewIcon(){return Nt},ImageWall:hn};return Object.defineProperty(Ae,"__isScriptSetup",{enumerable:!1,value:!0}),Ae}});const to={key:0,class:"wl-login-info"},no={class:"wl-avatar"},oo=["title"],lo=["title"],io=["src"],ao=["title","textContent"],ro={class:"wl-panel"},co=["for","textContent"],so=["id","onUpdate:modelValue","name","type"],uo=["placeholder"],mo={class:"wl-preview"},vo=u("hr",null,null,-1),go=["innerHTML"],ho={class:"wl-footer"},fo={class:"wl-actions"},wo={href:"https://guides.github.com/features/mastering-markdown/",title:"Markdown Guide","aria-label":"Markdown is supported",class:"wl-action",target:"_blank",rel:"noopener noreferrer"},yo=["title"],bo=["title"],ko=["title"],_o=["title"],Co={class:"wl-info"},po=u("div",{class:"wl-captcha-container"},null,-1),Io={class:"wl-text-number"},Lo={key:0},Eo=["textContent"],xo=["textContent"],Ro=["disabled"],So=["placeholder"],jo={key:1,class:"wl-loading"},Mo={key:0,class:"wl-tab-wrapper"},Ao=["title","onClick"],zo=["src","alt"],Uo={key:0,class:"wl-tabs"},Vo=["onClick"],To=["src","alt","title"],Ho=["title"];function Po(o,n,t,e,r,s){var d,h;return i(),a("div",{key:Number(e.isLogin),class:"wl-comment"},[e.config.login!=="disable"&&e.isLogin&&!((d=t.edit)!=null&&d.objectId)?(i(),a("div",to,[u("div",no,[u("button",{type:"submit",class:"wl-logout-btn",title:e.locale.logout,onClick:e.onLogout},[W(e.CloseIcon,{size:14})],8,oo),u("a",{href:"#",class:"wl-login-nick","aria-label":"Profile",title:e.locale.profile,onClick:e.onProfile},[u("img",{src:e.userInfo.avatar,alt:"avatar"},null,8,io)],8,lo)]),u("a",{href:"#",class:"wl-login-nick","aria-label":"Profile",title:e.locale.profile,onClick:e.onProfile,textContent:_(e.userInfo.display_name)},null,8,ao)])):k("v-if",!0),u("div",ro,[e.config.login!=="force"&&e.config.meta.length&&!e.isLogin?(i(),a("div",{key:0,class:P(["wl-header",`item${e.config.meta.length}`])},[(i(!0),a(V,null,O(e.config.meta,l=>(i(),a("div",{key:l,class:"wl-header-item"},[u("label",{for:`wl-${l}`,textContent:_(e.locale[l]+(e.config.requiredMeta.includes(l)||!e.config.requiredMeta.length?"":`(${e.locale.optional})`))},null,8,co),fe(u("input",{id:`wl-${l}`,ref_for:!0,ref:c=>{c&&(e.inputRefs[l]=c)},"onUpdate:modelValue":c=>e.userMeta[l]=c,class:P(["wl-input",`wl-${l}`]),name:l,type:l==="mail"?"email":"text"},null,10,so),[[yt,e.userMeta[l]]])]))),128))],2)):k("v-if",!0),fe(u("textarea",{id:"wl-edit",ref:"editorRef","onUpdate:modelValue":n[0]||(n[0]=l=>e.editor=l),class:"wl-editor",placeholder:t.replyUser?`@${t.replyUser}`:e.locale.placeholder,onKeydown:e.onKeyDown,onDrop:e.onDrop,onPaste:e.onPaste},null,40,uo),[[bt,e.editor]]),fe(u("div",mo,[vo,u("h4",null,_(e.locale.preview)+":",1),u("div",{class:"wl-content",innerHTML:e.previewText},null,8,go)],512),[[We,e.showPreview]]),u("div",ho,[u("div",fo,[u("a",wo,[W(e.MarkdownIcon)]),fe(u("button",{ref:"emojiButtonRef",type:"button",class:P(["wl-action",{active:e.showEmoji}]),title:e.locale.emoji,onClick:n[1]||(n[1]=l=>e.showEmoji=!e.showEmoji)},[W(e.EmojiIcon)],10,yo),[[We,e.emoji.tabs.length]]),e.config.search?(i(),a("button",{key:0,ref:"gifButtonRef",type:"button",class:P(["wl-action",{active:e.showGif}]),title:e.locale.gif,onClick:n[2]||(n[2]=l=>e.showGif=!e.showGif)},[W(e.GifIcon)],10,bo)):k("v-if",!0),u("input",{id:"wl-image-upload",ref:"imageUploadRef",class:"upload",type:"file",accept:".png,.jpg,.jpeg,.webp,.bmp,.gif",onChange:e.onChange},null,544),e.canUploadImage?(i(),a("label",{key:1,for:"wl-image-upload",class:"wl-action",title:e.locale.uploadImage},[W(e.ImageIcon)],8,ko)):k("v-if",!0),u("button",{type:"button",class:P(["wl-action",{active:e.showPreview}]),title:e.locale.preview,onClick:n[3]||(n[3]=l=>e.showPreview=!e.showPreview)},[W(e.PreviewIcon)],10,_o)]),u("div",Co,[po,u("div",Io,[ee(_(e.wordNumber)+" ",1),e.config.wordLimit?(i(),a("span",Lo,[ee("  /  "),u("span",{class:P({illegal:!e.isWordNumberLegal}),textContent:_(e.wordLimit)},null,10,Eo)])):k("v-if",!0),ee("  "+_(e.locale.word),1)]),e.config.login!=="disable"&&!e.isLogin?(i(),a("button",{key:0,type:"button",class:"wl-btn",onClick:e.onLogin,textContent:_(e.locale.login)},null,8,xo)):k("v-if",!0),e.config.login!=="force"||e.isLogin?(i(),a("button",{key:1,type:"submit",class:"primary wl-btn",title:"Cmd|Ctrl + Enter",disabled:e.isSubmitting,onClick:e.submitComment},[e.isSubmitting?(i(),$(e.LoadingIcon,{key:0,size:16})):(i(),a(V,{key:1},[ee(_(e.locale.submit),1)],64))],8,Ro)):k("v-if",!0)]),u("div",{ref:"gifPopupRef",class:P(["wl-gif-popup",{display:e.showGif}])},[u("input",{ref:"gifSearchInputRef",type:"text",placeholder:e.locale.gifSearchPlaceholder,onInput:n[4]||(n[4]=(...l)=>e.onGifSearch&&e.onGifSearch(...l))},null,40,So),e.searchResults.list.length?(i(),$(e.ImageWall,{key:0,items:e.searchResults.list,"column-width":200,gap:6,onInsert:n[5]||(n[5]=l=>e.insert(l)),onScroll:e.onImageWallScroll},null,8,["items"])):k("v-if",!0),e.searchResults.loading?(i(),a("div",jo,[W(e.LoadingIcon,{size:30})])):k("v-if",!0)],2),u("div",{ref:"emojiPopupRef",class:P(["wl-emoji-popup",{display:e.showEmoji}])},[(i(!0),a(V,null,O(e.emoji.tabs,(l,c)=>(i(),a(V,{key:l.name},[c===e.emojiTabIndex?(i(),a("div",Mo,[(i(!0),a(V,null,O(l.items,y=>(i(),a("button",{key:y,type:"button",title:y,onClick:I=>e.insert(`:${y}:`)},[e.showEmoji?(i(),a("img",{key:0,class:"wl-emoji",src:e.emoji.map[y],alt:y,loading:"lazy",referrerPolicy:"no-referrer"},null,8,zo)):k("v-if",!0)],8,Ao))),128))])):k("v-if",!0)],64))),128)),e.emoji.tabs.length>1?(i(),a("div",Uo,[(i(!0),a(V,null,O(e.emoji.tabs,(l,c)=>(i(),a("button",{key:l.name,type:"button",class:P(["wl-tab",{active:e.emojiTabIndex===c}]),onClick:y=>e.emojiTabIndex=c},[u("img",{class:"wl-emoji",src:l.icon,alt:l.name,title:l.name,loading:"lazy",referrerPolicy:"no-referrer"},null,8,To)],10,Vo))),128))])):k("v-if",!0)],2)])]),t.replyId||(h=t.edit)!=null&&h.objectId?(i(),a("button",{key:1,type:"button",class:"wl-close",title:e.locale.cancelReply,onClick:n[6]||(n[6]=l=>t.replyId?e.emit("cancelReply"):e.emit("cancelEdit"))},[W(e.CloseIcon,{size:24})],8,Ho)):k("v-if",!0)])}var dt=me(eo,[["render",Po],["__file","CommentBox.vue"]]),No=ue({__name:"CommentCard",props:{comment:{},edit:{default:null},rootId:{},reply:{default:null}},emits:["log","submit","delete","edit","like","status","sticky","reply"],setup(o,{expose:n,emit:t}){n();const e=o,r=t,s=["approved","waiting","spam"],d=Ce("config"),h=Ge(),l=It(),c=pe(),y=U(()=>d.value.locale),I=U(()=>{const{link:S}=e.comment;return S?Ye(S)?S:`https://${S}`:""}),A=U(()=>h.value.includes(e.comment.objectId)),g=U(()=>Pn(new Date(e.comment.time),l.value,y.value)),R=U(()=>c.value.type==="administrator"),x=U(()=>e.comment.user_id&&c.value.objectId===e.comment.user_id),p=U(()=>{var S;return e.comment.objectId===((S=e.reply)==null?void 0:S.objectId)}),E=U(()=>{var S;return e.comment.objectId===((S=e.edit)==null?void 0:S.objectId)}),T={props:e,emit:r,commentStatus:s,config:d,likes:h,now:l,userInfo:c,locale:y,link:I,like:A,time:g,isAdmin:R,isOwner:x,isReplyingCurrent:p,isEditingCurrent:E,CommentBox:dt,get DeleteIcon(){return Vt},get EditIcon(){return Bt},get LikeIcon(){return Pt},get ReplyIcon(){return Dt},get VerifiedIcon(){return Ft}};return Object.defineProperty(T,"__isScriptSetup",{enumerable:!1,value:!0}),T}});const Wo=["id"],Do={class:"wl-user","aria-hidden":"true"},Bo=["src"],Fo={class:"wl-card"},Oo={class:"wl-head"},Go=["href"],qo={key:1,class:"wl-nick"},Ko=["textContent"],Zo=["textContent"],Xo=["textContent"],Yo=["textContent"],Jo=["textContent"],Qo={class:"wl-comment-actions"},$o=["title"],el=["title"],tl={class:"wl-meta","aria-hidden":"true"},nl=["data-value","textContent"],ol={key:0,class:"wl-content"},ll={key:0},il=["href"],al=u("span",null,": ",-1),rl=["innerHTML"],cl={key:1,class:"wl-admin-actions"},sl={class:"wl-comment-status"},dl=["disabled","onClick","textContent"],ul={key:3,class:"wl-quote"};function ml(o,n,t,e,r,s){var h;const d=kt("CommentCard",!0);return i(),a("div",{id:t.comment.objectId,class:"wl-card-item"},[u("div",Do,[t.comment.avatar?(i(),a("img",{key:0,class:"wl-user-avatar",src:t.comment.avatar},null,8,Bo)):k("v-if",!0),t.comment.type?(i(),$(e.VerifiedIcon,{key:1})):k("v-if",!0)]),u("div",Fo,[u("div",Oo,[e.link?(i(),a("a",{key:0,class:"wl-nick",href:e.link,target:"_blank",rel:"nofollow noopener noreferrer"},_(t.comment.nick),9,Go)):(i(),a("span",qo,_(t.comment.nick),1)),t.comment.type==="administrator"?(i(),a("span",{key:2,class:"wl-badge",textContent:_(e.locale.admin)},null,8,Ko)):k("v-if",!0),t.comment.label?(i(),a("span",{key:3,class:"wl-badge",textContent:_(t.comment.label)},null,8,Zo)):k("v-if",!0),t.comment.sticky?(i(),a("span",{key:4,class:"wl-badge",textContent:_(e.locale.sticky)},null,8,Xo)):k("v-if",!0),typeof t.comment.level=="number"?(i(),a("span",{key:5,class:P(`wl-badge level${t.comment.level}`),textContent:_(e.locale[`level${t.comment.level}`]||`Level ${t.comment.level}`)},null,10,Yo)):k("v-if",!0),u("span",{class:"wl-time",textContent:_(e.time)},null,8,Jo),u("div",Qo,[e.isAdmin||e.isOwner?(i(),a(V,{key:0},[u("button",{type:"button",class:"wl-edit",onClick:n[0]||(n[0]=l=>e.emit("edit",t.comment))},[W(e.EditIcon)]),u("button",{type:"button",class:"wl-delete",onClick:n[1]||(n[1]=l=>e.emit("delete",t.comment))},[W(e.DeleteIcon)])],64)):k("v-if",!0),u("button",{type:"button",class:"wl-like",title:e.like?e.locale.cancelLike:e.locale.like,onClick:n[2]||(n[2]=l=>e.emit("like",t.comment))},[W(e.LikeIcon,{active:e.like},null,8,["active"]),ee(" "+_("like"in t.comment?t.comment.like:""),1)],8,$o),u("button",{type:"button",class:P(["wl-reply",{active:e.isReplyingCurrent}]),title:e.isReplyingCurrent?e.locale.cancelReply:e.locale.reply,onClick:n[3]||(n[3]=l=>e.emit("reply",e.isReplyingCurrent?null:t.comment))},[W(e.ReplyIcon)],10,el)])]),u("div",tl,[(i(),a(V,null,O(["addr","browser","os"],l=>(i(),a(V,null,[t.comment[l]?(i(),a("span",{key:l,class:P(`wl-${l}`),"data-value":t.comment[l],textContent:_(t.comment[l])},null,10,nl)):k("v-if",!0)],64))),64))]),e.isEditingCurrent?k("v-if",!0):(i(),a("div",ol,[t.comment.reply_user?(i(),a("p",ll,[u("a",{href:"#"+t.comment.pid},"@"+_(t.comment.reply_user.nick),9,il),al])):k("v-if",!0),u("div",{innerHTML:t.comment.comment},null,8,rl)])),e.isAdmin&&!e.isEditingCurrent?(i(),a("div",cl,[u("span",sl,[(i(),a(V,null,O(e.commentStatus,l=>u("button",{key:l,type:"submit",class:P(`wl-btn wl-${l}`),disabled:t.comment.status===l,onClick:c=>e.emit("status",{status:l,comment:t.comment}),textContent:_(e.locale[l])},null,10,dl)),64))]),e.isAdmin&&!("rid"in t.comment)?(i(),a("button",{key:0,type:"submit",class:"wl-btn wl-sticky",onClick:n[4]||(n[4]=l=>e.emit("sticky",t.comment))},_(t.comment.sticky?e.locale.unsticky:e.locale.sticky),1)):k("v-if",!0)])):k("v-if",!0),e.isReplyingCurrent||e.isEditingCurrent?(i(),a("div",{key:2,class:P({"wl-reply-wrapper":e.isReplyingCurrent,"wl-edit-wrapper":e.isEditingCurrent})},[W(e.CommentBox,{edit:t.edit,"reply-id":(h=t.reply)==null?void 0:h.objectId,"reply-user":t.comment.nick,"root-id":t.rootId,onLog:n[5]||(n[5]=l=>e.emit("log")),onCancelReply:n[6]||(n[6]=l=>e.emit("reply",null)),onCancelEdit:n[7]||(n[7]=l=>e.emit("edit",null)),onSubmit:n[8]||(n[8]=l=>e.emit("submit",l))},null,8,["edit","reply-id","reply-user","root-id"])],2)):k("v-if",!0),"children"in t.comment?(i(),a("div",ul,[(i(!0),a(V,null,O(t.comment.children,l=>(i(),$(d,{key:l.objectId,comment:l,reply:t.reply,edit:t.edit,"root-id":t.rootId,onLog:n[9]||(n[9]=c=>e.emit("log")),onDelete:n[10]||(n[10]=c=>e.emit("delete",c)),onEdit:n[11]||(n[11]=c=>e.emit("edit",c)),onLike:n[12]||(n[12]=c=>e.emit("like",c)),onReply:n[13]||(n[13]=c=>e.emit("reply",c)),onStatus:n[14]||(n[14]=c=>e.emit("status",c)),onSticky:n[15]||(n[15]=c=>e.emit("sticky",c)),onSubmit:n[16]||(n[16]=c=>e.emit("submit",c))},null,8,["comment","reply","edit","root-id"]))),128))])):k("v-if",!0)])],8,Wo)}var vl=me(No,[["render",ml],["__file","CommentCard.vue"]]);const ut="3.2.5";var gl=ue({__name:"WalineComment",props:["serverURL","path","meta","requiredMeta","dark","commentSorting","lang","locale","pageSize","wordLimit","emoji","login","highlighter","texRenderer","imageUploader","search","copyright","recaptchaV3Key","turnstileKey","reaction"],setup(o,{expose:n}){n();const t=o,e={latest:"insertedAt_desc",oldest:"insertedAt_asc",hottest:"like_desc"},r=Object.keys(e),s=pe(),d=Ge(),h=b("loading"),l=b(0),c=b(1),y=b(0),I=U(()=>Vn(t)),A=b(I.value.commentSorting),g=b([]),R=b(null),x=b(null),p=U(()=>Tn(I.value.dark)),E=U(()=>I.value.locale);Lt(p,{id:"waline-darkmode"});let T;const S=w=>{var L;const{serverURL:N,path:q,pageSize:z}=I.value,B=new AbortController;h.value="loading",T==null||T(),St({serverURL:N,lang:I.value.lang,path:q,pageSize:z,sortBy:e[A.value],page:w,signal:B.signal,token:(L=s.value)==null?void 0:L.token}).then(D=>{h.value="success",l.value=D.count,g.value.push(...D.data),c.value=w,y.value=D.totalPages}).catch(D=>{D.name!=="AbortError"&&(console.error(D.message),h.value="error")}),T=B.abort.bind(B)},G=()=>S(c.value+1),re=()=>{l.value=0,g.value=[],S(1)},ce=w=>{A.value!==w&&(A.value=w,re())},oe=w=>{R.value=w},H=w=>{x.value=w},ne=w=>{if(x.value)x.value.comment=w.comment,x.value.orig=w.orig;else if("rid"in w){const L=g.value.find(({objectId:N})=>N===w.rid);if(!L)return;Array.isArray(L.children)||(L.children=[]),L.children.push(w)}else g.value.unshift(w),l.value+=1},Z=async({comment:w,status:L})=>{var N;if(w.status===L)return;const{serverURL:q,lang:z}=I.value;await we({serverURL:q,lang:z,token:(N=s.value)==null?void 0:N.token,objectId:w.objectId,comment:{status:L}}),w.status=L},se=async w=>{var L;if("rid"in w)return;const{serverURL:N,lang:q}=I.value;await we({serverURL:N,lang:q,token:(L=s.value)==null?void 0:L.token,objectId:w.objectId,comment:{sticky:w.sticky?0:1}}),w.sticky=!w.sticky},X=async({objectId:w})=>{var L;if(!confirm("Are you sure you want to delete this comment?"))return;const{serverURL:N,lang:q}=I.value;await jt({serverURL:N,lang:q,token:(L=s.value)==null?void 0:L.token,objectId:w}),g.value.some((z,B)=>z.objectId===w?(g.value=g.value.filter((D,de)=>de!==B),!0):z.children.some((D,de)=>D.objectId===w?(g.value[B].children=z.children.filter((be,ke)=>ke!==de),!0):!1))},le=async w=>{var L;const{serverURL:N,lang:q}=I.value,{objectId:z}=w,B=d.value.includes(z);await we({serverURL:N,lang:q,objectId:z,token:(L=s.value)==null?void 0:L.token,comment:{like:!B}}),B?d.value=d.value.filter(D=>D!==z):(d.value=[...d.value,z],d.value.length>50&&(d.value=d.value.slice(-50))),w.like=(w.like||0)+(B?-1:1)};_t("config",I),he(()=>{Q(()=>[t.serverURL,t.path],()=>re(),{immediate:!0})}),He(()=>T==null?void 0:T());const Y={props:t,sortKeyMap:e,sortingMethods:r,userInfo:s,likeStorage:d,status:h,count:l,page:c,totalPages:y,config:I,commentSortingRef:A,data:g,reply:R,edit:x,darkmodeStyle:p,i18n:E,get abort(){return T},set abort(w){T=w},getCommentData:S,loadMore:G,refresh:re,onSortByChange:ce,onReply:oe,onEdit:H,onSubmit:ne,onStatusChange:Z,onSticky:se,onDelete:X,onLike:le,Reaction:dn,CommentBox:dt,CommentCard:vl,get LoadingIcon(){return ye},get version(){return ut}};return Object.defineProperty(Y,"__isScriptSetup",{enumerable:!1,value:!0}),Y}});const hl={"data-waline":""},fl={class:"wl-meta-head"},wl={class:"wl-count"},yl=["textContent"],bl={class:"wl-sort"},kl=["onClick"],_l={class:"wl-cards"},Cl={key:1,class:"wl-operation"},pl=["textContent"],Il={key:2,class:"wl-loading"},Ll=["textContent"],El={key:4,class:"wl-operation"},xl=["textContent"],Rl={key:5,class:"wl-power"},Sl=u("a",{href:"https://github.com/walinejs/waline",target:"_blank",rel:"noopener noreferrer"}," Waline ",-1);function jl(o,n,t,e,r,s){return i(),a("div",hl,[W(e.Reaction),e.reply?k("v-if",!0):(i(),$(e.CommentBox,{key:0,onLog:e.refresh,onSubmit:e.onSubmit})),u("div",fl,[u("div",wl,[e.count?(i(),a("span",{key:0,class:"wl-num",textContent:_(e.count)},null,8,yl)):k("v-if",!0),ee(" "+_(e.i18n.comment),1)]),u("ul",bl,[(i(!0),a(V,null,O(e.sortingMethods,d=>(i(),a("li",{key:d,class:P([d===e.commentSortingRef?"active":""]),onClick:h=>e.onSortByChange(d)},_(e.i18n[d]),11,kl))),128))])]),u("div",_l,[(i(!0),a(V,null,O(e.data,d=>(i(),$(e.CommentCard,{key:d.objectId,"root-id":d.objectId,comment:d,reply:e.reply,edit:e.edit,onLog:e.refresh,onReply:e.onReply,onEdit:e.onEdit,onSubmit:e.onSubmit,onStatus:e.onStatusChange,onDelete:e.onDelete,onSticky:e.onSticky,onLike:e.onLike},null,8,["root-id","comment","reply","edit"]))),128))]),e.status==="error"?(i(),a("div",Cl,[u("button",{type:"button",class:"wl-btn",onClick:e.refresh,textContent:_(e.i18n.refresh)},null,8,pl)])):e.status==="loading"?(i(),a("div",Il,[W(e.LoadingIcon,{size:30})])):e.data.length?e.page<e.totalPages?(i(),a("div",El,[u("button",{type:"button",class:"wl-btn",onClick:e.loadMore,textContent:_(e.i18n.more)},null,8,xl)])):k("v-if",!0):(i(),a("div",{key:3,class:"wl-empty",textContent:_(e.i18n.sofa)},null,8,Ll)),e.config.copyright?(i(),a("div",Rl,[ee(" Powered by "),Sl,ee(" v"+_(e.version),1)])):k("v-if",!0)])}var Ml=me(gl,[["render",jl],["__file","WalineComment.vue"]]);export{Ml as Waline,ut as version};
10
+ ![${m.name}](${f})`)}).catch(f=>{alert(f.message),d.value=d.value.replace(v,"")}).then(()=>{X.value=!1})},B=m=>{var v;if((v=m.dataTransfer)!=null&&v.items){const f=ct(m.dataTransfer.items);f&&L.value&&(z(f),m.preventDefault())}},D=m=>{if(m.clipboardData){const v=ct(m.clipboardData.items);v&&L.value&&z(v)}},de=()=>{const m=I.value;m.files&&L.value&&z(m.files[0]).then(()=>{m.value=""})},be=async()=>{var m,v,f,j,F,ie;const{serverURL:K,lang:J,login:ve,wordLimit:ze,requiredMeta:Ue,recaptchaV3Key:Ve,turnstileKey:Te}=s.value,ht=await $n(),M={comment:se.value,nick:h.value.nick,mail:h.value.mail,link:h.value.link,url:s.value.path,ua:ht};if((m=l.value)!=null&&m.token&&!e.edit)M.nick=l.value.display_name,M.mail=l.value.email,M.link=l.value.url;else{if(ve==="force")return;if(Ue.indexOf("nick")>-1&&!M.nick)return(v=c.value.nick)==null||v.focus(),alert(Y.value.nickError);if(Ue.indexOf("mail")>-1&&!M.mail||M.mail&&!Wn(M.mail))return(f=c.value.mail)==null||f.focus(),alert(Y.value.mailError);M.nick||(M.nick=Y.value.anonymous)}if(!M.comment){(j=y.value)==null||j.focus();return}if(!Z.value)return alert(Y.value.wordHint.replace("$0",ze[0].toString()).replace("$1",ze[1].toString()).replace("$2",oe.value.toString()));M.comment=st(M.comment,E.value.map),e.replyId&&e.rootId&&(M.pid=e.replyId,M.rid=e.rootId,M.at=e.replyUser),X.value=!0;try{Ve&&(M.recaptchaV3=await Yt(Ve).execute("social")),Te&&(M.turnstile=await Jt(Te).execute("social"));const ge={serverURL:K,lang:J,token:(F=l.value)==null?void 0:F.token,comment:M},_e=await(e.edit?we({objectId:e.edit.objectId,...ge}):xt(ge));if(X.value=!1,_e.errmsg)return alert(_e.errmsg);r("submit",_e.data),d.value="",ce.value="",await Pe(),e.replyId&&r("cancelReply"),(ie=e.edit)!=null&&ie.objectId&&r("cancelEdit")}catch(ge){X.value=!1,alert(ge.message)}},ke=m=>{m.preventDefault();const{lang:v,serverURL:f}=s.value;Rt({serverURL:f,lang:v}).then(j=>{l.value=j,(j.remember?localStorage:sessionStorage).setItem("WALINE_USER",JSON.stringify(j)),r("log")})},mt=()=>{l.value={},localStorage.setItem("WALINE_USER","null"),sessionStorage.setItem("WALINE_USER","null"),r("log")},vt=m=>{m.preventDefault();const{lang:v,serverURL:f}=s.value,j=800,F=800,ie=(window.innerWidth-j)/2,K=(window.innerHeight-F)/2,J=new URLSearchParams({lng:v,token:l.value.token}),ve=window.open(`${f}/ui/profile?${J.toString()}`,"_blank",`width=${j},height=${F},left=${ie},top=${K},scrollbars=no,resizable=no,status=no,location=no,toolbar=no,menubar=no`);ve==null||ve.postMessage({type:"TOKEN",data:l.value.token},"*")},je=m=>{var v,f,j,F;!((v=A.value)!=null&&v.contains(m.target))&&!((f=g.value)!=null&&f.contains(m.target))&&(S.value=!1),!((j=R.value)!=null&&j.contains(m.target))&&!((F=x.value)!=null&&F.contains(m.target))&&(G.value=!1)},Me=async m=>{var v;const{scrollTop:f,clientHeight:j,scrollHeight:F}=m.target,ie=(j+f)/F,K=s.value.search,J=((v=p.value)==null?void 0:v.value)??"";ie<.9||H.loading||le.value||(H.loading=!0,(K.more&&H.list.length?await K.more(J,H.list.length):await K.search(J)).length?H.list=[...H.list,...K.more&&H.list.length?await K.more(J,H.list.length):await K.search(J)]:le.value=!0,H.loading=!1,setTimeout(()=>{m.target.scrollTop=f},50))},gt=pt(m=>{H.list=[],le.value=!1,Me(m)},300);Q([s,oe],([m,v])=>{const{wordLimit:f}=m;f?v<f[0]&&f[0]!==0?(ne.value=f[0],Z.value=!1):v>f[1]?(ne.value=f[1],Z.value=!1):(ne.value=f[1],Z.value=!0):(ne.value=0,Z.value=!0)},{immediate:!0}),De("click",je),De("message",({data:m})=>{!m||m.type!=="profile"||(l.value={...l.value,...m.data},[localStorage,sessionStorage].filter(v=>v.getItem("WALINE_USER")).forEach(v=>v.setItem("WALINE_USER",JSON.stringify(l))))}),Q(G,async m=>{var v;if(!m)return;const f=s.value.search;p.value&&(p.value.value=""),H.loading=!0,H.list=await(((v=f.default)==null?void 0:v.call(f))??f.search("")),H.loading=!1}),he(()=>{var m;(m=e.edit)!=null&&m.objectId&&(d.value=e.edit.orig),Q(()=>d.value,v=>{const{highlighter:f,texRenderer:j}=s.value;se.value=v,ce.value=Xn(v,{emojiMap:E.value.map,highlighter:f,texRenderer:j}),oe.value=Qn(v),v?Fe(y.value):Fe.destroy(y.value)},{immediate:!0}),Q(()=>s.value.emoji,v=>Fn(v).then(f=>{E.value=f}),{immediate:!0})});const Ae={props:e,emit:r,config:s,editor:d,userMeta:h,userInfo:l,inputRefs:c,editorRef:y,imageUploadRef:I,emojiButtonRef:A,emojiPopupRef:g,gifButtonRef:R,gifPopupRef:x,gifSearchInputRef:p,emoji:E,emojiTabIndex:T,showEmoji:S,showGif:G,showPreview:re,previewText:ce,wordNumber:oe,searchResults:H,wordLimit:ne,isWordNumberLegal:Z,content:se,isSubmitting:X,isImageListEnd:le,locale:Y,isLogin:w,canUploadImage:L,insert:N,onKeyDown:q,uploadImage:z,onDrop:B,onPaste:D,onChange:de,submitComment:be,onLogin:ke,onLogout:mt,onProfile:vt,popupHandler:je,onImageWallScroll:Me,onGifSearch:gt,get CloseIcon(){return Ut},get EmojiIcon(){return Tt},get GifIcon(){return Ot},get ImageIcon(){return Ht},get LoadingIcon(){return ye},get MarkdownIcon(){return Wt},get PreviewIcon(){return Nt},ImageWall:hn};return Object.defineProperty(Ae,"__isScriptSetup",{enumerable:!1,value:!0}),Ae}});const to={key:0,class:"wl-login-info"},no={class:"wl-avatar"},oo=["title"],lo=["title"],io=["src"],ao=["title","textContent"],ro={class:"wl-panel"},co=["for","textContent"],so=["id","onUpdate:modelValue","name","type"],uo=["placeholder"],mo={class:"wl-preview"},vo=u("hr",null,null,-1),go=["innerHTML"],ho={class:"wl-footer"},fo={class:"wl-actions"},wo={href:"https://guides.github.com/features/mastering-markdown/",title:"Markdown Guide","aria-label":"Markdown is supported",class:"wl-action",target:"_blank",rel:"noopener noreferrer"},yo=["title"],bo=["title"],ko=["title"],_o=["title"],Co={class:"wl-info"},po=u("div",{class:"wl-captcha-container"},null,-1),Io={class:"wl-text-number"},Lo={key:0},Eo=["textContent"],xo=["textContent"],Ro=["disabled"],So=["placeholder"],jo={key:1,class:"wl-loading"},Mo={key:0,class:"wl-tab-wrapper"},Ao=["title","onClick"],zo=["src","alt"],Uo={key:0,class:"wl-tabs"},Vo=["onClick"],To=["src","alt","title"],Ho=["title"];function Po(o,n,t,e,r,s){var d,h;return i(),a("div",{key:e.userInfo.token,class:"wl-comment"},[e.config.login!=="disable"&&e.isLogin&&!((d=t.edit)!=null&&d.objectId)?(i(),a("div",to,[u("div",no,[u("button",{type:"submit",class:"wl-logout-btn",title:e.locale.logout,onClick:e.onLogout},[W(e.CloseIcon,{size:14})],8,oo),u("a",{href:"#",class:"wl-login-nick","aria-label":"Profile",title:e.locale.profile,onClick:e.onProfile},[u("img",{src:e.userInfo.avatar,alt:"avatar"},null,8,io)],8,lo)]),u("a",{href:"#",class:"wl-login-nick","aria-label":"Profile",title:e.locale.profile,onClick:e.onProfile,textContent:_(e.userInfo.display_name)},null,8,ao)])):k("v-if",!0),u("div",ro,[e.config.login!=="force"&&e.config.meta.length&&!e.isLogin?(i(),a("div",{key:0,class:P(["wl-header",`item${e.config.meta.length}`])},[(i(!0),a(V,null,O(e.config.meta,l=>(i(),a("div",{key:l,class:"wl-header-item"},[u("label",{for:`wl-${l}`,textContent:_(e.locale[l]+(e.config.requiredMeta.includes(l)||!e.config.requiredMeta.length?"":`(${e.locale.optional})`))},null,8,co),fe(u("input",{id:`wl-${l}`,ref_for:!0,ref:c=>{c&&(e.inputRefs[l]=c)},"onUpdate:modelValue":c=>e.userMeta[l]=c,class:P(["wl-input",`wl-${l}`]),name:l,type:l==="mail"?"email":"text"},null,10,so),[[yt,e.userMeta[l]]])]))),128))],2)):k("v-if",!0),fe(u("textarea",{id:"wl-edit",ref:"editorRef","onUpdate:modelValue":n[0]||(n[0]=l=>e.editor=l),class:"wl-editor",placeholder:t.replyUser?`@${t.replyUser}`:e.locale.placeholder,onKeydown:e.onKeyDown,onDrop:e.onDrop,onPaste:e.onPaste},null,40,uo),[[bt,e.editor]]),fe(u("div",mo,[vo,u("h4",null,_(e.locale.preview)+":",1),u("div",{class:"wl-content",innerHTML:e.previewText},null,8,go)],512),[[We,e.showPreview]]),u("div",ho,[u("div",fo,[u("a",wo,[W(e.MarkdownIcon)]),fe(u("button",{ref:"emojiButtonRef",type:"button",class:P(["wl-action",{active:e.showEmoji}]),title:e.locale.emoji,onClick:n[1]||(n[1]=l=>e.showEmoji=!e.showEmoji)},[W(e.EmojiIcon)],10,yo),[[We,e.emoji.tabs.length]]),e.config.search?(i(),a("button",{key:0,ref:"gifButtonRef",type:"button",class:P(["wl-action",{active:e.showGif}]),title:e.locale.gif,onClick:n[2]||(n[2]=l=>e.showGif=!e.showGif)},[W(e.GifIcon)],10,bo)):k("v-if",!0),u("input",{id:"wl-image-upload",ref:"imageUploadRef",class:"upload",type:"file",accept:".png,.jpg,.jpeg,.webp,.bmp,.gif",onChange:e.onChange},null,544),e.canUploadImage?(i(),a("label",{key:1,for:"wl-image-upload",class:"wl-action",title:e.locale.uploadImage},[W(e.ImageIcon)],8,ko)):k("v-if",!0),u("button",{type:"button",class:P(["wl-action",{active:e.showPreview}]),title:e.locale.preview,onClick:n[3]||(n[3]=l=>e.showPreview=!e.showPreview)},[W(e.PreviewIcon)],10,_o)]),u("div",Co,[po,u("div",Io,[ee(_(e.wordNumber)+" ",1),e.config.wordLimit?(i(),a("span",Lo,[ee("  /  "),u("span",{class:P({illegal:!e.isWordNumberLegal}),textContent:_(e.wordLimit)},null,10,Eo)])):k("v-if",!0),ee("  "+_(e.locale.word),1)]),e.config.login!=="disable"&&!e.isLogin?(i(),a("button",{key:0,type:"button",class:"wl-btn",onClick:e.onLogin,textContent:_(e.locale.login)},null,8,xo)):k("v-if",!0),e.config.login!=="force"||e.isLogin?(i(),a("button",{key:1,type:"submit",class:"primary wl-btn",title:"Cmd|Ctrl + Enter",disabled:e.isSubmitting,onClick:e.submitComment},[e.isSubmitting?(i(),$(e.LoadingIcon,{key:0,size:16})):(i(),a(V,{key:1},[ee(_(e.locale.submit),1)],64))],8,Ro)):k("v-if",!0)]),u("div",{ref:"gifPopupRef",class:P(["wl-gif-popup",{display:e.showGif}])},[u("input",{ref:"gifSearchInputRef",type:"text",placeholder:e.locale.gifSearchPlaceholder,onInput:n[4]||(n[4]=(...l)=>e.onGifSearch&&e.onGifSearch(...l))},null,40,So),e.searchResults.list.length?(i(),$(e.ImageWall,{key:0,items:e.searchResults.list,"column-width":200,gap:6,onInsert:n[5]||(n[5]=l=>e.insert(l)),onScroll:e.onImageWallScroll},null,8,["items"])):k("v-if",!0),e.searchResults.loading?(i(),a("div",jo,[W(e.LoadingIcon,{size:30})])):k("v-if",!0)],2),u("div",{ref:"emojiPopupRef",class:P(["wl-emoji-popup",{display:e.showEmoji}])},[(i(!0),a(V,null,O(e.emoji.tabs,(l,c)=>(i(),a(V,{key:l.name},[c===e.emojiTabIndex?(i(),a("div",Mo,[(i(!0),a(V,null,O(l.items,y=>(i(),a("button",{key:y,type:"button",title:y,onClick:I=>e.insert(`:${y}:`)},[e.showEmoji?(i(),a("img",{key:0,class:"wl-emoji",src:e.emoji.map[y],alt:y,loading:"lazy",referrerPolicy:"no-referrer"},null,8,zo)):k("v-if",!0)],8,Ao))),128))])):k("v-if",!0)],64))),128)),e.emoji.tabs.length>1?(i(),a("div",Uo,[(i(!0),a(V,null,O(e.emoji.tabs,(l,c)=>(i(),a("button",{key:l.name,type:"button",class:P(["wl-tab",{active:e.emojiTabIndex===c}]),onClick:y=>e.emojiTabIndex=c},[u("img",{class:"wl-emoji",src:l.icon,alt:l.name,title:l.name,loading:"lazy",referrerPolicy:"no-referrer"},null,8,To)],10,Vo))),128))])):k("v-if",!0)],2)])]),t.replyId||(h=t.edit)!=null&&h.objectId?(i(),a("button",{key:1,type:"button",class:"wl-close",title:e.locale.cancelReply,onClick:n[6]||(n[6]=l=>t.replyId?e.emit("cancelReply"):e.emit("cancelEdit"))},[W(e.CloseIcon,{size:24})],8,Ho)):k("v-if",!0)])}var dt=me(eo,[["render",Po],["__file","CommentBox.vue"]]),No=ue({__name:"CommentCard",props:{comment:{},edit:{default:null},rootId:{},reply:{default:null}},emits:["log","submit","delete","edit","like","status","sticky","reply"],setup(o,{expose:n,emit:t}){n();const e=o,r=t,s=["approved","waiting","spam"],d=Ce("config"),h=Ge(),l=It(),c=pe(),y=U(()=>d.value.locale),I=U(()=>{const{link:S}=e.comment;return S?Ye(S)?S:`https://${S}`:""}),A=U(()=>h.value.includes(e.comment.objectId)),g=U(()=>Pn(new Date(e.comment.time),l.value,y.value)),R=U(()=>c.value.type==="administrator"),x=U(()=>e.comment.user_id&&c.value.objectId===e.comment.user_id),p=U(()=>{var S;return e.comment.objectId===((S=e.reply)==null?void 0:S.objectId)}),E=U(()=>{var S;return e.comment.objectId===((S=e.edit)==null?void 0:S.objectId)}),T={props:e,emit:r,commentStatus:s,config:d,likes:h,now:l,userInfo:c,locale:y,link:I,like:A,time:g,isAdmin:R,isOwner:x,isReplyingCurrent:p,isEditingCurrent:E,CommentBox:dt,get DeleteIcon(){return Vt},get EditIcon(){return Bt},get LikeIcon(){return Pt},get ReplyIcon(){return Dt},get VerifiedIcon(){return Ft}};return Object.defineProperty(T,"__isScriptSetup",{enumerable:!1,value:!0}),T}});const Wo=["id"],Do={class:"wl-user","aria-hidden":"true"},Bo=["src"],Fo={class:"wl-card"},Oo={class:"wl-head"},Go=["href"],qo={key:1,class:"wl-nick"},Ko=["textContent"],Zo=["textContent"],Xo=["textContent"],Yo=["textContent"],Jo=["textContent"],Qo={class:"wl-comment-actions"},$o=["title"],el=["title"],tl={class:"wl-meta","aria-hidden":"true"},nl=["data-value","textContent"],ol={key:0,class:"wl-content"},ll={key:0},il=["href"],al=u("span",null,": ",-1),rl=["innerHTML"],cl={key:1,class:"wl-admin-actions"},sl={class:"wl-comment-status"},dl=["disabled","onClick","textContent"],ul={key:3,class:"wl-quote"};function ml(o,n,t,e,r,s){var h;const d=kt("CommentCard",!0);return i(),a("div",{id:t.comment.objectId,class:"wl-card-item"},[u("div",Do,[t.comment.avatar?(i(),a("img",{key:0,class:"wl-user-avatar",src:t.comment.avatar},null,8,Bo)):k("v-if",!0),t.comment.type?(i(),$(e.VerifiedIcon,{key:1})):k("v-if",!0)]),u("div",Fo,[u("div",Oo,[e.link?(i(),a("a",{key:0,class:"wl-nick",href:e.link,target:"_blank",rel:"nofollow noopener noreferrer"},_(t.comment.nick),9,Go)):(i(),a("span",qo,_(t.comment.nick),1)),t.comment.type==="administrator"?(i(),a("span",{key:2,class:"wl-badge",textContent:_(e.locale.admin)},null,8,Ko)):k("v-if",!0),t.comment.label?(i(),a("span",{key:3,class:"wl-badge",textContent:_(t.comment.label)},null,8,Zo)):k("v-if",!0),t.comment.sticky?(i(),a("span",{key:4,class:"wl-badge",textContent:_(e.locale.sticky)},null,8,Xo)):k("v-if",!0),typeof t.comment.level=="number"?(i(),a("span",{key:5,class:P(`wl-badge level${t.comment.level}`),textContent:_(e.locale[`level${t.comment.level}`]||`Level ${t.comment.level}`)},null,10,Yo)):k("v-if",!0),u("span",{class:"wl-time",textContent:_(e.time)},null,8,Jo),u("div",Qo,[e.isAdmin||e.isOwner?(i(),a(V,{key:0},[u("button",{type:"button",class:"wl-edit",onClick:n[0]||(n[0]=l=>e.emit("edit",t.comment))},[W(e.EditIcon)]),u("button",{type:"button",class:"wl-delete",onClick:n[1]||(n[1]=l=>e.emit("delete",t.comment))},[W(e.DeleteIcon)])],64)):k("v-if",!0),u("button",{type:"button",class:"wl-like",title:e.like?e.locale.cancelLike:e.locale.like,onClick:n[2]||(n[2]=l=>e.emit("like",t.comment))},[W(e.LikeIcon,{active:e.like},null,8,["active"]),ee(" "+_("like"in t.comment?t.comment.like:""),1)],8,$o),u("button",{type:"button",class:P(["wl-reply",{active:e.isReplyingCurrent}]),title:e.isReplyingCurrent?e.locale.cancelReply:e.locale.reply,onClick:n[3]||(n[3]=l=>e.emit("reply",e.isReplyingCurrent?null:t.comment))},[W(e.ReplyIcon)],10,el)])]),u("div",tl,[(i(),a(V,null,O(["addr","browser","os"],l=>(i(),a(V,null,[t.comment[l]?(i(),a("span",{key:l,class:P(`wl-${l}`),"data-value":t.comment[l],textContent:_(t.comment[l])},null,10,nl)):k("v-if",!0)],64))),64))]),e.isEditingCurrent?k("v-if",!0):(i(),a("div",ol,[t.comment.reply_user?(i(),a("p",ll,[u("a",{href:"#"+t.comment.pid},"@"+_(t.comment.reply_user.nick),9,il),al])):k("v-if",!0),u("div",{innerHTML:t.comment.comment},null,8,rl)])),e.isAdmin&&!e.isEditingCurrent?(i(),a("div",cl,[u("span",sl,[(i(),a(V,null,O(e.commentStatus,l=>u("button",{key:l,type:"submit",class:P(`wl-btn wl-${l}`),disabled:t.comment.status===l,onClick:c=>e.emit("status",{status:l,comment:t.comment}),textContent:_(e.locale[l])},null,10,dl)),64))]),e.isAdmin&&!("rid"in t.comment)?(i(),a("button",{key:0,type:"submit",class:"wl-btn wl-sticky",onClick:n[4]||(n[4]=l=>e.emit("sticky",t.comment))},_(t.comment.sticky?e.locale.unsticky:e.locale.sticky),1)):k("v-if",!0)])):k("v-if",!0),e.isReplyingCurrent||e.isEditingCurrent?(i(),a("div",{key:2,class:P({"wl-reply-wrapper":e.isReplyingCurrent,"wl-edit-wrapper":e.isEditingCurrent})},[W(e.CommentBox,{edit:t.edit,"reply-id":(h=t.reply)==null?void 0:h.objectId,"reply-user":t.comment.nick,"root-id":t.rootId,onLog:n[5]||(n[5]=l=>e.emit("log")),onCancelReply:n[6]||(n[6]=l=>e.emit("reply",null)),onCancelEdit:n[7]||(n[7]=l=>e.emit("edit",null)),onSubmit:n[8]||(n[8]=l=>e.emit("submit",l))},null,8,["edit","reply-id","reply-user","root-id"])],2)):k("v-if",!0),"children"in t.comment?(i(),a("div",ul,[(i(!0),a(V,null,O(t.comment.children,l=>(i(),$(d,{key:l.objectId,comment:l,reply:t.reply,edit:t.edit,"root-id":t.rootId,onLog:n[9]||(n[9]=c=>e.emit("log")),onDelete:n[10]||(n[10]=c=>e.emit("delete",c)),onEdit:n[11]||(n[11]=c=>e.emit("edit",c)),onLike:n[12]||(n[12]=c=>e.emit("like",c)),onReply:n[13]||(n[13]=c=>e.emit("reply",c)),onStatus:n[14]||(n[14]=c=>e.emit("status",c)),onSticky:n[15]||(n[15]=c=>e.emit("sticky",c)),onSubmit:n[16]||(n[16]=c=>e.emit("submit",c))},null,8,["comment","reply","edit","root-id"]))),128))])):k("v-if",!0)])],8,Wo)}var vl=me(No,[["render",ml],["__file","CommentCard.vue"]]);const ut="3.2.6";var gl=ue({__name:"WalineComment",props:["serverURL","path","meta","requiredMeta","dark","commentSorting","lang","locale","pageSize","wordLimit","emoji","login","highlighter","texRenderer","imageUploader","search","copyright","recaptchaV3Key","turnstileKey","reaction"],setup(o,{expose:n}){n();const t=o,e={latest:"insertedAt_desc",oldest:"insertedAt_asc",hottest:"like_desc"},r=Object.keys(e),s=pe(),d=Ge(),h=b("loading"),l=b(0),c=b(1),y=b(0),I=U(()=>Vn(t)),A=b(I.value.commentSorting),g=b([]),R=b(null),x=b(null),p=U(()=>Tn(I.value.dark)),E=U(()=>I.value.locale);Lt(p,{id:"waline-darkmode"});let T;const S=w=>{var L;const{serverURL:N,path:q,pageSize:z}=I.value,B=new AbortController;h.value="loading",T==null||T(),St({serverURL:N,lang:I.value.lang,path:q,pageSize:z,sortBy:e[A.value],page:w,signal:B.signal,token:(L=s.value)==null?void 0:L.token}).then(D=>{h.value="success",l.value=D.count,g.value.push(...D.data),c.value=w,y.value=D.totalPages}).catch(D=>{D.name!=="AbortError"&&(console.error(D.message),h.value="error")}),T=B.abort.bind(B)},G=()=>S(c.value+1),re=()=>{l.value=0,g.value=[],S(1)},ce=w=>{A.value!==w&&(A.value=w,re())},oe=w=>{R.value=w},H=w=>{x.value=w},ne=w=>{if(x.value)x.value.comment=w.comment,x.value.orig=w.orig;else if("rid"in w){const L=g.value.find(({objectId:N})=>N===w.rid);if(!L)return;Array.isArray(L.children)||(L.children=[]),L.children.push(w)}else g.value.unshift(w),l.value+=1},Z=async({comment:w,status:L})=>{var N;if(w.status===L)return;const{serverURL:q,lang:z}=I.value;await we({serverURL:q,lang:z,token:(N=s.value)==null?void 0:N.token,objectId:w.objectId,comment:{status:L}}),w.status=L},se=async w=>{var L;if("rid"in w)return;const{serverURL:N,lang:q}=I.value;await we({serverURL:N,lang:q,token:(L=s.value)==null?void 0:L.token,objectId:w.objectId,comment:{sticky:w.sticky?0:1}}),w.sticky=!w.sticky},X=async({objectId:w})=>{var L;if(!confirm("Are you sure you want to delete this comment?"))return;const{serverURL:N,lang:q}=I.value;await jt({serverURL:N,lang:q,token:(L=s.value)==null?void 0:L.token,objectId:w}),g.value.some((z,B)=>z.objectId===w?(g.value=g.value.filter((D,de)=>de!==B),!0):z.children.some((D,de)=>D.objectId===w?(g.value[B].children=z.children.filter((be,ke)=>ke!==de),!0):!1))},le=async w=>{var L;const{serverURL:N,lang:q}=I.value,{objectId:z}=w,B=d.value.includes(z);await we({serverURL:N,lang:q,objectId:z,token:(L=s.value)==null?void 0:L.token,comment:{like:!B}}),B?d.value=d.value.filter(D=>D!==z):(d.value=[...d.value,z],d.value.length>50&&(d.value=d.value.slice(-50))),w.like=(w.like||0)+(B?-1:1)};_t("config",I),he(()=>{Q(()=>[t.serverURL,t.path],()=>re(),{immediate:!0})}),He(()=>T==null?void 0:T());const Y={props:t,sortKeyMap:e,sortingMethods:r,userInfo:s,likeStorage:d,status:h,count:l,page:c,totalPages:y,config:I,commentSortingRef:A,data:g,reply:R,edit:x,darkmodeStyle:p,i18n:E,get abort(){return T},set abort(w){T=w},getCommentData:S,loadMore:G,refresh:re,onSortByChange:ce,onReply:oe,onEdit:H,onSubmit:ne,onStatusChange:Z,onSticky:se,onDelete:X,onLike:le,Reaction:dn,CommentBox:dt,CommentCard:vl,get LoadingIcon(){return ye},get version(){return ut}};return Object.defineProperty(Y,"__isScriptSetup",{enumerable:!1,value:!0}),Y}});const hl={"data-waline":""},fl={class:"wl-meta-head"},wl={class:"wl-count"},yl=["textContent"],bl={class:"wl-sort"},kl=["onClick"],_l={class:"wl-cards"},Cl={key:1,class:"wl-operation"},pl=["textContent"],Il={key:2,class:"wl-loading"},Ll=["textContent"],El={key:4,class:"wl-operation"},xl=["textContent"],Rl={key:5,class:"wl-power"},Sl=u("a",{href:"https://github.com/walinejs/waline",target:"_blank",rel:"noopener noreferrer"}," Waline ",-1);function jl(o,n,t,e,r,s){return i(),a("div",hl,[W(e.Reaction),e.reply?k("v-if",!0):(i(),$(e.CommentBox,{key:0,onLog:e.refresh,onSubmit:e.onSubmit})),u("div",fl,[u("div",wl,[e.count?(i(),a("span",{key:0,class:"wl-num",textContent:_(e.count)},null,8,yl)):k("v-if",!0),ee(" "+_(e.i18n.comment),1)]),u("ul",bl,[(i(!0),a(V,null,O(e.sortingMethods,d=>(i(),a("li",{key:d,class:P([d===e.commentSortingRef?"active":""]),onClick:h=>e.onSortByChange(d)},_(e.i18n[d]),11,kl))),128))])]),u("div",_l,[(i(!0),a(V,null,O(e.data,d=>(i(),$(e.CommentCard,{key:d.objectId,"root-id":d.objectId,comment:d,reply:e.reply,edit:e.edit,onLog:e.refresh,onReply:e.onReply,onEdit:e.onEdit,onSubmit:e.onSubmit,onStatus:e.onStatusChange,onDelete:e.onDelete,onSticky:e.onSticky,onLike:e.onLike},null,8,["root-id","comment","reply","edit"]))),128))]),e.status==="error"?(i(),a("div",Cl,[u("button",{type:"button",class:"wl-btn",onClick:e.refresh,textContent:_(e.i18n.refresh)},null,8,pl)])):e.status==="loading"?(i(),a("div",Il,[W(e.LoadingIcon,{size:30})])):e.data.length?e.page<e.totalPages?(i(),a("div",El,[u("button",{type:"button",class:"wl-btn",onClick:e.loadMore,textContent:_(e.i18n.more)},null,8,xl)])):k("v-if",!0):(i(),a("div",{key:3,class:"wl-empty",textContent:_(e.i18n.sofa)},null,8,Ll)),e.config.copyright?(i(),a("div",Rl,[ee(" Powered by "),Sl,ee(" v"+_(e.version),1)])):k("v-if",!0)])}var Ml=me(gl,[["render",jl],["__file","WalineComment.vue"]]);export{Ml as Waline,ut as version};
11
11
  //# sourceMappingURL=component.js.map