Files
appco_dist/.output/public/_nuxt/CjmezUVO.js
T
2025-08-24 13:00:31 +03:30

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.value=a[0];else{const C=await J(o,f.user.id);t.value=C}f.user.id===t.value?.user1_id?r.value=t.value?.user2:t.value.user1&&(r.value=t.value?.user1)}}catch(o){console.log("e ===>",o)}finally{_.value=!1}});const v=async()=>{if(d.value.length)try{n.value=!0;const o=await ee(t.value.chat_id,d.value);await h.value.request(),h.value.scrollToBottom(),setTimeout(()=>{d.value=""},100)}catch(o){console.log("e ===>",o)}finally{n.value=!1}};return(o,a)=>{const C=Te,M=se;return c(),p("div",null,[i("div",{class:y(["fixed top-0 w-inherit right-0 left-0",g(s).isNightStore?"bg-black":"bg-white"])},[i("div",Le,[i("div",Ue,[u(W,{icon:g(s).isRTL?"vuesax-linear:arrow-right":"vuesax-linear:arrow-left",onClick:a[0]||(a[0]=B=>g(l).back())},null,8,["icon"]),r.value?.id?(c(),p("div",Ne,[u(re,{width:"40",src:r.value?.avatar,justShowProfile:""},null,8,["src"]),i("div",null,[i("div",Re,S(r.value?.name),1),i("div",ze,S(r.value?.username),1)])])):Q("",!0)]),a[2]||(a[2]=i("div",{class:"flex w-fit gap-4 h-1.3rem items-center"},null,-1))])],2),i("div",De,[_.value?(c(),k(C,{key:0})):(c(),k(Pe,{key:1,ref_key:"conversation",ref:h,chatId:t.value?.chat_id},null,8,["chatId"]))]),i("div",{class:y(["fixed bottom-0 w-inherit right-0 left-0 p-3",g(s).isNightStore?"bg-black":"bg-white"])},[i("div",{class:y(["flex items-center gap-5 rounded-full px-2",g(s).isNightStore?"bg-gray-700":"bg-gray-100"])},[u(ne,{value:d.value,"onUpdate:value":a[1]||(a[1]=B=>d.value=B),"place-holder":`${g(s).useString("message")}...`,class:"!rounded-full border-transparent !bg-transparent message-placeholder !py-3 flex-1",rows:1},null,8,["value","place-holder"]),u(Z,{name:"fade",mode:"out-in"},{default:X(()=>[d.value===""?(c(),k(W,{key:0,icon:"vuesax-linear:add-circle"})):(c(),p("div",{key:1,class:y(["w-4rem h-2rem bg-#733af9 flex items-center rounded-full p-1 pt-2 text-white justify-center",{"bg-gray-500":n.value}]),onClick:v},[n.value?(c(),k(M,{key:1,class:"!text-white",type:"spinner",size:"20px"})):(c(),p("img",{key:0,src:Be,alt:g(Y),class:"h-full rtl:-scale-x-100"},null,8,Me))],2))]),_:1})],2)],2)])}}}),He=D(qe,[["__scopeId","data-v-61d04548"]]),Qe=w({__name:"detail_message",setup(e){return(l,s)=>(c(),k(He))}});export{Qe as default};