8 lines
28 KiB
JavaScript
8 lines
28 KiB
JavaScript
import{d as j,aX as Ze,s as ne,e as qe,C as x,k as q,aF as f,br as Xe,aU as Z,aV as Ye,aH as Pe,r as S,K as Ie,be as Ge,aZ as Je,bT as _e,bR as Qe,ad as X,bq as Te,aM as ge,aN as ie,cq as U,aT as et,aS as tt,b1 as nt,b9 as be,cw as ot,aI as st,a0 as xe,bO as it,bW as at,H as G,y as $,I as g,z as w,F as se,U as rt,D as Y,a1 as ee,aw as Me,J as te,av as we,ah as Be,A as c,a6 as ye,ai as Fe,B as R,S as oe,a2 as ve,cD as lt,o as Ne,N as ut,u as Ee,a4 as ct,a3 as ce,a8 as de,a7 as dt,Q as he,cF as pt,cG as mt}from"./BAjARngS.js";import{B as Re}from"./CLgN2r-F.js";import{a as je}from"./4rHVhLBf.js";import{e as ae}from"./DWEdiVkG.js";import{_ as Ae}from"./Bnczqe4x.js";import{C as ft}from"./96trYotg.js";import{U as gt}from"./7dlk9GfV.js";import"./B7wqwN_w.js";import{B as vt}from"./DlKYmSOP.js";import{B as re}from"./sroyubh1.js";import{T as ht}from"./DlKvdlGZ.js";import{M as xt,_ as pe,u as wt}from"./D19XOyLS.js";import{S as He}from"./n5o86z8W.js";import{B as yt}from"./DyeV-5jh.js";import{u as _t,b as bt}from"./BvUK-b93.js";import{g as Ct,a as Ce}from"./dWia4Hno.js";import{i as St,g as kt,c as $t,d as Lt,a as Ot,e as Pt}from"./D8uJfFT-.js";import"./C18GdnBI.js";import{u as It}from"./BTKf4LLU.js";function Tt(e){const{selectionStart:o}=e;return e.value.slice(0,o)}function Mt(e){let o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";return(Array.isArray(o)?o:[o]).reduce((t,i)=>{const a=e.lastIndexOf(i);return a>t.location?{location:a,prefix:i}:t},{location:-1,prefix:""})}function Se(e){return(e||"").toLowerCase()}function Bt(e,o,n){const t=e[0];if(!t||t===n)return e;let i=e;const a=o.length;for(let s=0;s<a;s+=1)if(Se(i[s])!==Se(o[s])){i=i.slice(s);break}else s===a-1&&(i=i.slice(a));return i}function Ft(e,o){const{measureLocation:n,prefix:t,targetText:i,selectionStart:a,split:s}=o;let l=e.slice(0,n);l[l.length-s.length]===s&&(l=l.slice(0,l.length-s.length)),l&&(l=`${l}${s}`);let d=Bt(e.slice(a),i.slice(a-n-t.length),s);d.slice(0,s.length)===s&&(d=d.slice(s.length));const r=`${l}${t}${i}${s}`;return{text:`${r}${d}`,selectionLocation:r.length}}function Nt(e,o){e.setSelectionRange(o,o),e.blur(),e.focus()}function Et(e,o){const{split:n}=o;return!n||e.indexOf(n)===-1}function Rt(e,o){let{value:n=""}=o;const t=e.toLowerCase();return n.toLowerCase().indexOf(t)!==-1}const ze=Symbol("MentionsContextKey");function jt(){}const At=j({compatConfig:{MODE:3},name:"DropdownMenu",props:{prefixCls:String,options:{type:Array,default:()=>[]}},setup(e,o){let{slots:n}=o;const{activeIndex:t,setActiveIndex:i,selectOption:a,onFocus:s=jt,loading:l}=Ze(ze,{activeIndex:ne(),loading:ne(!1)});let d;const r=y=>{clearTimeout(d),d=setTimeout(()=>{s(y)})};return qe(()=>{clearTimeout(d)}),()=>{var y;const{prefixCls:_,options:L}=e,v=L[t.value]||{};return x(xt,{prefixCls:`${_}-menu`,activeKey:v.value,onSelect:O=>{let{key:I}=O;const B=L.find(N=>{let{value:T}=N;return T===I});a(B)},onMousedown:r},{default:()=>[!l.value&&L.map((O,I)=>{var B,N;const{value:T,disabled:E,label:H=O.value,class:z,style:W}=O;return x(pe,{key:T,disabled:E,onMouseenter:()=>{i(I)},class:z,style:W},{default:()=>[(N=(B=n.option)===null||B===void 0?void 0:B.call(n,O))!==null&&N!==void 0?N:typeof H=="function"?H(O):H]})}),!l.value&&L.length===0?x(pe,{key:"notFoundContent",disabled:!0},{default:()=>[(y=n.notFoundContent)===null||y===void 0?void 0:y.call(n)]}):null,l.value&&x(pe,{key:"loading",disabled:!0},{default:()=>[x(He,{size:"small"},null)]})]})}}}),Ht={bottomRight:{points:["tl","br"],offset:[0,4],overflow:{adjustX:0,adjustY:1}},bottomLeft:{points:["tr","bl"],offset:[0,4],overflow:{adjustX:0,adjustY:1}},topRight:{points:["bl","tr"],offset:[0,-4],overflow:{adjustX:0,adjustY:1}},topLeft:{points:["br","tl"],offset:[0,-4],overflow:{adjustX:0,adjustY:1}}},zt=j({compatConfig:{MODE:3},name:"KeywordTrigger",props:{loading:{type:Boolean,default:void 0},options:{type:Array,default:()=>[]},prefixCls:String,placement:String,visible:{type:Boolean,default:void 0},transitionName:String,getPopupContainer:Function,direction:String,dropdownClassName:String},setup(e,o){let{slots:n}=o;const t=()=>`${e.prefixC
|
|||
|
|
user:users(name, avatar),
|
||
|
|
like:likes(user_id),
|
||
|
|
replies:comments(*,
|
||
|
|
user:users(name, avatar),
|
||
|
|
like:likes(user_id)
|
||
|
|
)`).eq("product_id",e).is("parent_id",null).range(t,i).order("created_at",{ascending:!1}))?.data},Oe=async(e,o,n=void 0)=>await we.post("/media/add-comment",{message:e,product_id:o,parent_id:n}),En={flex:"","justify-center":"","items-center":"","flex-col":"","p-2":""},Rn={"mt-1":"","font-semibold":""},jn={class:"flex items-center"},An={class:"me-1"},Hn={class:"flex items-center p1"},zn=j({__name:"CommentAddEdit",props:{open:{type:Boolean},id:{}},emits:["update:open","addCommentId"],setup(e,{emit:o}){const n=Ee(),t=G(),i=te(),a=S(null),s=S(!0),l=S(null),d=S(!1),r=S(!1),y=S(!1);te();const _=S(void 0),L=()=>{s.value=l.value.scrollTop<=5};function v(){_.value=void 0}function O(){setTimeout(()=>{document.activeElement?.scrollIntoView({behavior:"smooth",block:"center"}),d.value=!0},300)}Ne(()=>{X(()=>{l.value&&L()})});const I=e,B=o,N=S(!1),T=S([]),E=S(""),H=S(null),z=S(!1),W=S(0),K=S(20),D=async()=>{try{if(!z.value){N.value=!0;const m=await Nn(I.id,++W.value,K.value);m?.length<K.value&&(z.value=!0),T.value.push(...m)}}catch(m){console.log("e ===>",m)}finally{N.value=!1}};async function le(){await D(),await X(),await a.value?.setOpen(),await H.value?.focus()}async function ue(){await X(),await a.value?.setClose(),p(),v()}function p(){T.value=[],W.value=0,z.value=!1}const u=async()=>{try{if(E.value?.length>0){if(r.value=!0,_.value){const m=await Oe(E.value,I.id,_.value.id);_.value?.replies||(_.value.replies=[]),_.value?.replies.push({message:E.value,user:{name:i.user.name,avatar:i.user.avatar},like:[],...m}),B("addCommentId",m.id)}else{const m=await Oe(E.value,I.id);T.value?.unshift({message:E.value,user:{name:i.user.name,avatar:i.user.avatar},like:[],replies:[],...m}),B("addCommentId",m.id)}await X(()=>{E.value="",_.value=void 0})}}catch(m){console.log(m)}finally{r.value=!1}};function h(m,C,A,k){try{if(y.value=!0,de())if(m)if(gn(C),A){const M=T.value.find(P=>P.id===k)?.replies.find(P=>P.id===C);M?.like.splice(M.like?.findIndex(P=>P.user_id===i.user?.id))}else{const F=T.value.find(M=>M.id===k);F?.like.splice(F?.like?.findIndex(M=>M.user_id===i.user?.id))}else fn(C),A?T.value.find(P=>P.id===k)?.replies.find(P=>P.id===C)?.like.push({product_id:C,user_id:i.user.id}):T.value.find(M=>M.id===k)?.like?.push({product_id:C,user_id:i.user.id});else n.push({name:"auth-login"}),he.warn(t.useString("pleaseLoginOrRegister"))}catch(F){console.log(F)}finally{y.value=!1}}const b=S();return ct(b,([{isIntersecting:m}])=>{m&&I.open&&setTimeout(()=>{D()},100)}),xe(I,m=>{m.open?le():ue()}),(m,C)=>{const A=Yt;return w(),se(Re,{title:"",ref_key:"sheetRef",ref:a,headerCls:"",allowCloseScrollup:s.value,closeOnClickOutside:"",onOnClickOutside:C[3]||(C[3]=k=>B("update:open",!1)),onOnClose:C[4]||(C[4]=k=>B("update:open",!1))},{header:Y(()=>[c("div",En,[C[5]||(C[5]=c("div",{"bg-gray-500":"","h-2px":"","w-2.5rem":""},null,-1)),c("div",Rn,R(g(t).useString("comments")),1)])]),default:Y(()=>[c("div",{class:ce(["h-70vh w-full relative relative",g(de)()?"pb-4rem":""])},[c("div",{class:"h-full px-4 overflow-auto",ref_key:"scrollArea",ref:l,onScroll:L},[(w(!0),$(ee,null,ve(T.value,k=>(w(),se(Mn,{item:k,onLikeComment:h,onReply:F=>_.value=k,addLikeLoading:y.value},null,8,["item","onReply","addLikeLoading"]))),256)),N.value?(w(),$(ee,{key:0},ve(5,k=>x(Fn)),64)):oe("",!0),ye(c("div",{ref_key:"observer",ref:b,class:"w-full opacity-0 relative"}," load ",512),[[dt,!N.value]])],544),g(de)()?(w(),$("div",{key:0,class:"flex w-inherit fixed gap-1 items-center my-2 px2 py-1 bottom-1",onFocusin:O,onFocusout:C[2]||(C[2]=k=>d.value=!1)},[x(gt,{width:"40",class:"w-40 ms-2",src:g(i).user?.avatar,"just-show-profile":""},null,8,["src"]),c("div",{class:ce(["border-solid flex-1 border-1 comment_input",_.value?"rounded-3xl":"rounded-full"])},[_.value?(w(),$("div",{key:0,class:ce(["rounded-t-3xl text-xs p3 mb1 flex justify-between",g(t).isNightStore?"bg-zinc-7 text-gray-2":"bg-gray-50 text-gray-4"])},[c("div",jn,[c("span",null,[c("span",An,R(g(t).useString("replyingTo")),1),c("span",null,R(_.value?.user?.name),1)])]),x(re,{icon:"vuesax-linear:add",class:"rotate-45",color:g(t).isN
|