2 lines
6.2 KiB
JavaScript
2 lines
6.2 KiB
JavaScript
import{d as w,C as u,c6 as q,a5 as P,K as L,k as U,r as m,a4 as H,o as N,y as p,z as c,a6 as j,cF as F,ah as V,a7 as y,A as i,B as S,u as O,H as E,bC as G,cG as K,cH as J,U as Q,I as g,F as k,D as X,an as Y,W as Z,cI as ee}from"./BYv1load.js";import{b as x,c as b,h as R,w as $,m as z,k as te,t as I,l as ae}from"./C6wbjLIE.js";import{s as se}from"./UTPBjEbh.js";import{B as W}from"./D-ODqOh1.js";import{U as re}from"./CSuAA5jZ.js";import{B as ne}from"./BInDpaeT.js";import{_ as D}from"./DlAUqK2U.js";import"./DWEdiVkG.js";const[oe,le]=b("skeleton-title"),ie={round:Boolean,titleWidth:x};var ue=w({name:oe,props:ie,setup(e){return()=>u("h3",{class:le([{round:e.round}]),style:{width:R(e.titleWidth)}},null)}});const ce=$(ue);var de=ce;const[ve,fe]=b("skeleton-avatar"),he={avatarSize:x,avatarShape:z("round")};var me=w({name:ve,props:he,setup(e){return()=>u("div",{class:fe([e.avatarShape]),style:te(e.avatarSize)},null)}});const _e=$(me);var ge=_e;const T="100%",pe={round:Boolean,rowWidth:{type:x,default:T}},[we,ye]=b("skeleton-paragraph");var ke=w({name:we,props:pe,setup(e){return()=>u("div",{class:ye([{round:e.round}]),style:{width:e.rowWidth}},null)}});const xe=$(ke);var Se=xe;const[be,A]=b("skeleton"),Ce="60%",$e={row:ae(0),round:Boolean,title:Boolean,titleWidth:x,avatar:Boolean,avatarSize:x,avatarShape:z("round"),loading:I,animate:I,rowWidth:{type:[Number,String,Array],default:T}};var Te=w({name:be,inheritAttrs:!1,props:$e,setup(e,{slots:l,attrs:s}){const f=()=>{if(e.avatar)return u(ge,{avatarShape:e.avatarShape,avatarSize:e.avatarSize},null)},d=()=>{if(e.title)return u(de,{round:e.round,titleWidth:e.titleWidth},null)},h=n=>{const{rowWidth:t}=e;return t===T&&n===+e.row-1?Ce:Array.isArray(t)?t[n]:t},r=()=>Array(+e.row).fill("").map((n,t)=>u(Se,{key:t,round:e.round,rowWidth:R(h(t))},null)),_=()=>l.template?l.template():u(P,null,[f(),u("div",{class:A("content")},[d(),r()])]);return()=>{var n;return e.loading?u("div",q({class:A({animate:e.animate,round:e.round})},s),[_()]):(n=l.default)==null?void 0:n.call(l)}}});const Be="data:image/svg+xml,%3csvg%20width='22'%20height='20'%20viewBox='0%200%2022%2020'%20fill='white'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M21.0031%201H1.00311L8.50311%208.5M21.0031%201L10.5031%2018.5L8.50311%208.5M21.0031%201L8.50311%208.5'%20stroke='%23733af9'%20stroke-width='2'%20stroke-linejoin='round'/%3e%3c/svg%3e",Ie={class:"message-bubble"},We={class:"time"},Ae=w({__name:"Conversation",props:{chatId:{}},setup(e,{expose:l}){const s=e,f=L(),d=U(()=>f.user),h=m([]),r=m(null),_=v=>new Date(v).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});async function n(){if(!s.chatId)return;const v=await F(s.chatId,1,1e3);h.value=Array.isArray(v)?v:v.data||[]}function t(){r.value&&V(()=>{const v=r.value;v.scrollTo({top:v.scrollHeight,behavior:"smooth"})})}return H(h,()=>{t()}),l({request:n,scrollToBottom:t}),N(async()=>{await n()}),(v,o)=>(c(),p("div",{class:"chat-container",ref_key:"chatContainer",ref:r},[(c(!0),p(P,null,j(h.value,a=>(c(),p("div",{key:a.id,class:y(["message",{sent:a.sender_id===d.value.id,received:a.sender_id!==d.value.id}])},[i("div",Ie,[i("p",null,S(a.text),1),i("span",We,S(_(a.created_at)),1)])],2))),128))],512))}}),Pe=D(Ae,[["__scopeId","data-v-3b999e95"]]),Le={class:"flex justify-between items-center w-full p4"},Ue={class:"flex items-center gap-5"},Ne={key:0,class:"flex gap-24px items-center"},Re={class:"font-semibold flex items-center"},ze={class:"flex font-200 text-xs items-center"},De={dir:"ltr",class:"h-98vh pb-10 overflow-hidden"},Me=["alt"],qe=w({__name:"index",setup(e){const l=O(),s=E(),f=L(),d=m(""),h=m(null),r=m(void 0);U(()=>s.sellerConfig?.store?.main&&f.user.id!==s.sellerConfig?.store?.id);const _=m(!1),n=m(!1),t=m(void 0);N(async()=>{try{if(_.value=!0,l.currentRoute.value.query?.id?.length){const o=await G(l.currentRoute.value.query?.id);f.user.id===o?.user1_id?r.value=o?.user2:o.user1&&(r.value=o?.user1),t.value={chat_id:l.currentRoute.value.query.id}}else{const o=l.currentRoute.value.query?.user_id??s.sellerConfig?.store?.id,a=await K(o,f.user.id);if(a?.length)t.valu
|