PageSourceSearch

https://tryhavyn.com/assets/messages._userId-Co2srZ8b.js

js tryhavyn.com collected 2026-10-02 01:48:43 UTC 22,848 bytes, 5 lines download raw bytes

1import{c as ge,u as pe,k as ve,r as n,a as re,bB as je,G as ye,t as ce,cf as ue,I as Ne,j as e,X as le,i as we,cg as me,ce as ke,L as K,N as _e,aD as he,ch as Se,b7 as Ie,ci as Ce}from"./index-Dm8RZsL9.js";import{u as Le}from"./useMutation-Cfd5dceh.js";import{f as ae,a as xe}from"./format-CRbf4Bhs.js";import{S as oe}from"./SmartImage-DzuZUuil.js";import{T as Ue}from"./trash-2-CV21qFRF.js";import{I as $e}from"./image-plus-COt-kJBZ.js";import{L as be}from"./loader-circle-N6dh14DN.js";const Oe=[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551",key:"1miecu"}]],Ee=ge("paperclip",Oe);const Ae=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],Re=ge("send",Ae),Te=[6,12,24,48,72];function Pe({open:d,onClose:r,buyerId:l,buyerName:m,initialListingId:b,onSent:_}){const{user:W}=pe(),p=ve(),[I,Y]=n.useState("listing"),[C,G]=n.useState(b??""),[A,g]=n.useState(""),[R,F]=n.useState(""),[B,V]=n.useState("1"),[c,Z]=n.useState(24),[S,y]=n.useState(""),[L,T]=n.useState(""),[J,P]=n.useState("1"),[M,z]=n.useState("both"),[U,Q]=n.useState(""),[$,X]=n.useState([]),[v,O]=n.useState(!1),D=n.useRef(null),N=re({...je(W?.id??""),enabled:d&&!!W?.id}),q=re({...ye,enabled:d&&I==="custom"}),E=N.data?.listings??[],ee=n.useMemo(()=>{const t=A.trim().toLowerCase(),s=E.filter(i=>(i.status??"active")!=="sold");return t?s.filter(i=>i.name.toLowerCase().includes(t)):s},[E,A]),te=E.find(t=>t.id===C)??null,H=()=>{Y("listing"),G(b??""),g(""),F(""),V("1"),Z(24),y(""),T(""),P("1"),z("both"),Q(""),X([])},ne=()=>{w.isPending||v||(H(),r())},w=Le({mutationFn:async()=>{const t=Number(R);if(!Number.isFinite(t)||t<=0)throw new Error("Enter a valid price");const s=Math.max(1,Number(B)||1);if(I==="listing"){if(!C)throw new Error("Pick a listing");return ue({buyer_id:l,listing_id:C,price_kobo:Math.round(t*100),quantity:s,valid_hours:c})}if(!S.trim())throw new Error("Add a title");if($.length===0)throw new Error("Add at least one photo");O(!0);let i=[];try{i=await Promise.all($.map((o,a)=>Ne(o,a)))}finally{O(!1)}return ue({buyer_id:l,title:S.trim(),description:L.trim()||void 0,price_kobo:Math.round(t*100),quantity:s,weight:Number(J)||1,fulfillment_type:M,pickup_address_id:U||void 0,temp_photo_keys:i,valid_hours:c})},onSuccess:t=>{ce.success(`Offer sent${m?` to ${m}`:""}`),p.invalidateQueries({queryKey:["offers","sent"]}),t?.offer_id&&_?.({offer_id:String(t.offer_id),title:String(t.title??"Offer"),expires_at:String(t.expires_at??"")}),H(),r()},onError:t=>ce.error(t.message)});if(!d)return null;const se=w.isPending||v;return e.jsx("div",{className:"fixed inset-0 z-50 flex items-end justify-center bg-black/50 p-0 sm:items-center sm:p-4",children:e.jsxs("div",{className:"max-h-[92vh] w-full max-w-lg overflow-y-auto rounded-t-3xl border border-border bg-card p-5 shadow-lg sm:rounded-3xl",children:[e.jsxs("div",{className:"mb-4 flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-bold",children:"Send an offer"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:m?`A private, time-limited price for ${m}.`:"A private, time-limited price for this buyer."})]}),e.jsx("button",{onClick:ne,"aria-label":"Close",className:"rounded-full p-1.5 hover:bg-muted",children:e.jsx(le,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"mb-4 grid grid-cols-2 gap-2 rounded-full bg-muted p-1 text-xs font-semibold",children:["listing","custom"].map(t=>e.jsx("button",{onClick:()=>Y(t),className:`rounded-full py-2 transition ${I===t?"bg-background shadow-soft":"text-muted-foreground"}`,children:t==="listing"?"Existing listing":"Custom item"},t))}),I==="listing"?e.jsxs("div",{className:"space-y-3",children:[e.jsx("input",{value:A,onChange:t=>g(t.target.value),placeholder:"Search your listings",className:"w-full rounded-xl border border-border bg-background px-3 py-2 text-sm"}),e.jsx("div",{className:"max-h-56 space-y-2 overflow-y-auto rounded-xl border border-border p-2",children:N.isLoading?e.jsx("p",{className:"py-6 text-center text-xs text-muted-foreground",children:"Loading your listings…"}):ee.length===0?e.jsx("p",{className:"py-6 text-center text-xs text-muted-foreground",children:"No listings found."}):ee.map(t=>e.jsxs("button",{onClick:()=>{G(t.id),R||F(String(t.price))},className:`flex w-full items-center gap-3 rounded-lg p-2 text-left transition ${C===t.id?"bg-primary/10 ring-1 ring-primary":"hover:bg-muted"}`,children:[e.jsx(oe,{src:t.primary_photo_url??"",alt:"",className:"h-12 w-12 rounded-lg object-cover bg-muted"}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-sm font-semibold",children:t.name}),e.jsx("span",{className:"block text-xs text-muted-foreground",children:ae(t.price)})]})]},t.id))}),te&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Normal price ",ae(te.price)]})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsx(k,{label:"Title",children:e.jsx("input",{value:S,onChange:t=>y(t.target.value),placeholder:"Custom Ankara Blazer",className:"w-full rounded-xl border border-border bg-background px-3 py-2 text-sm"})}),e.jsx(k,{label:"Description",children:e.jsx("textarea",{value:L,onChange:t=>T(t.target.value),rows:3,placeholder:"Navy blue, size M",className:"w-full rounded-xl border border-border bg-background px-3 py-2 text-sm"})}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(k,{label:"Weight (kg)",children:e.jsx("input",{type:"number",inputMode:"decimal",value:J,onChange:t=>P(t.target.value),className:"w-full rounded-xl border border-border bg-background px-3 py-2 text-sm"})}),e.jsx(k,{label:"Fulfillment",children:e.jsxs("select",{value:M,onChange:t=>z(t.target.value),className:"w-full rounded-xl border border-border bg-background px-3 py-2 text-sm",children:[e.jsx("option",{value:"both",children:"Pickup or delivery"}),e.jsx("option",{value:"pickup_only",children:"Pickup only"}),e.jsx("option",{value:"delivery_only",children:"Delivery only"})]})})]}),e.jsx(k,{label:"Pickup address",children:e.jsxs("select",{value:U,onChange:t=>Q(t.target.value),className:"w-full rounded-xl border border-border bg-background px-3 py-2 text-sm",children:[e.jsx("option",{value:"",children:"Select an address"}),(q.data??[]).map(t=>e.jsx("option",{value:t.id,children:[t.street,t.area,t.city,t.state].filter(
1Boolean).join(", ")},t.id))]})}),e.jsx(k,{label:"Photos",children:e.jsxs("div",{className:"flex flex-wrap gap-2",children:[$.map((t,s)=>e.jsxs("div",{className:"relative h-16 w-16 overflow-hidden rounded-lg border border-border",children:[e.jsx("img",{src:URL.createObjectURL(t),alt:"",className:"h-full w-full object-cover"}),e.jsx("button",{onClick:()=>X(i=>i.filter((o,a)=>a!==s)),className:"absolute right-0.5 top-0.5 rounded-full bg-background/90 p-1","aria-label":"Remove photo",children:e.jsx(Ue,{className:"h-3 w-3"})})]},s)),e.jsx("button",{onClick:()=>D.current?.click(),className:"grid h-16 w-16 place-items-center rounded-lg border border-dashed border-border text-muted-foreground hover:bg-muted","aria-label":"Add photo",children:e.jsx($e,{className:"h-5 w-5"})}),e.jsx("input",{ref:D,type:"file",accept:"image/*",multiple:!0,hidden:!0,onChange:t=>{const s=Array.from(t.target.files??[]);X(i=>[...i,...s].slice(0,6)),t.target.value=""}})]})})]}),e.jsxs("div",{className:"mt-4 grid grid-cols-2 gap-3",children:[e.jsx(k,{label:"Offer price (₦)",children:e.jsx("input",{type:"number",inputMode:"decimal",value:R,onChange:t=>F(t.target.value),placeholder:"4500",className:"w-full rounded-xl border border-border bg-background px-3 py-2 text-sm"})}),e.jsx(k,{label:"Quantity",children:e.jsx("input",{type:"number",inputMode:"numeric",min:1,value:B,onChange:t=>V(t.target.value),className:"w-full rounded-xl border border-border bg-background px-3 py-2 text-sm"})})]}),e.jsx(k,{label:"Expires in",children:e.jsx("div",{className:"flex flex-wrap gap-2",children:Te.map(t=>e.jsxs("button",{onClick:()=>Z(t),className:`rounded-full px-3 py-1.5 text-xs font-semibold transition ${c===t?"brand-gradient text-primary-foreground":"border border-border hover:bg-muted"}`,children:[t,"h"]},t))})}),e.jsxs("button",{onClick:()=>w.mutate(),disabled:se,className:"mt-5 flex w-full items-center justify-center gap-2 rounded-full brand-gradient py-3 text-sm font-semibold text-primary-foreground disabled:opacity-60",children:[se&&e.jsx(be,{className:"h-4 w-4 animate-spin"}),v?"Uploading photos…":w.isPending?"Sending…":"Send offer"]})]})})}function k({label:d,children:r}){return e.jsxs("label",{className:"mt-3 block first:mt-0",children:[e.jsx("span",{className:"mb-1 block text-xs font-semibold text-muted-foreground",children:d}),r]})}function ie(d){return d.map(r=>({id:r.id,text:r.text??"",userId:r.user?.id??"",createdAt:r.created_at?new Date(r.created_at).getTime():Date.now(),attachments:r.attachments??void 0,havynListingId:r.havyn_listing_id??void 0,havynOfferId:r.havyn_offer_id??void 0}))}const Me=10*1024*1024,De=25*1024*1024,fe=15;async function qe(d){return new Promise(r=>{const l=URL.createObjectURL(d),m=document.createElement("video");m.preload="metadata",m.onloadedmetadata=()=>{URL.revokeObjectURL(l),r(m.duration||0)},m.onerror=()=>{URL.revokeObjectURL(l),r(0)},m.src=l})}function Fe(d){return new Date(d).toLocaleTimeString([],{hour:"numeric",minute:"2-digit"})}function Be(d){return d.split(/(https?:\/\/\S+)/g).map((l,m)=>/^https?:\/\//.test(l)?e.jsx("a",{href:l,target:"_blank",rel:"noreferrer",className:"underline break-all",children:l},m):e.jsx("span",{className:"whitespace-pre-wrap",children:l},m))}function Ve(d){const r=d.match(/\/item\/([a-zA-Z0-9-]+)/);return r?r[1]:null}function ze(d){const r=Ve(d);if(!r)return{displayText:d,listingId:null};const l=/\n\n— About this item —[\s\S]*$/;return{displayText:d.replace(l,""),listingId:r}}function Qe({id:d,isMine:r}){const{data:l,isLoading:m}=re({...Se(d),staleTime:3e5}),b=r?"border-primary-foreground/25":"border-border",_=r?"text-primary-foreground/80":"text-muted-foreground";return m?e.jsxs("div",{className:`mt-2 flex items-center gap-2 rounded-xl border ${b} p-2`,children:[e.jsx("div",{className:"h-12 w-12 animate-pulse rounded-md bg-foreground
1/10"}),e.jsxs("div",{className:"flex-1 space-y-1.5",children:[e.jsx("div",{className:"h-3 w-3/4 animate-pulse rounded bg-foreground/10"}),e.jsx("div",{className:"h-3 w-1/3 animate-pulse rounded bg-foreground/10"})]})]}):l?e.jsxs(K,{to:"/item/$id",params:{id:d},className:`mt-2 flex items-center gap-2.5 rounded-xl border ${b} bg-background/40 p-2 no-underline hover:bg-background/60 transition`,children:[e.jsx(oe,{listingId:d,src:Ie(l),alt:"",className:"h-12 w-12 flex-shrink-0 rounded-md object-cover"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:`truncate text-[13px] font-semibold ${r?"text-primary-foreground":"text-foreground"}`,children:l.name}),e.jsx("p",{className:`text-[12px] ${_}`,children:ae(l.price)})]})]}):null}function Xe({id:d,isMine:r}){const{data:l,isLoading:m}=re({queryKey:["offer",d],queryFn:()=>Ce(d),staleTime:3e4}),b=r?"border-primary-foreground/25":"border-border",_=r?"text-primary-foreground/80":"text-muted-foreground";return m?e.jsxs("div",{className:`mt-2 flex items-center gap-2 rounded-xl border ${b} p-2`,children:[e.jsx("div",{className:"h-12 w-12 animate-pulse rounded-md bg-foreground
1/10"}),e.jsxs("div",{className:"flex-1 space-y-1.5",children:[e.jsx("div",{className:"h-3 w-3/4 animate-pulse rounded bg-foreground/10"}),e.jsx("div",{className:"h-3 w-1/3 animate-pulse rounded bg-foreground/10"})]})]}):l?e.jsxs(K,{to:"/offers",className:`mt-2 flex items-center gap-2.5 rounded-xl border ${b} bg-background/40 p-2 no-underline hover:bg-background/60 transition`,children:[l.photo_url?e.jsx(oe,{src:l.photo_url,alt:"",className:"h-12 w-12 flex-shrink-0 rounded-md object-cover"}):e.jsx("span",{className:`grid h-12 w-12 flex-shrink-0 place-items-center rounded-md border ${b}`,children:e.jsx(he,{className:"h-5 w-5"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:`text-[10px] font-semibold uppercase tracking-wide ${_}`,children:"Offer"}),e.jsx("p",{className:`truncate text-[13px] font-semibold ${r?"text-primary-foreground":"text-foreground"}`,children:l.title}),e.jsxs("p",{className:`text-[12px] ${_}`,children:[ae(l.price),l.quantity>1?` × ${l.quantity}`:""," ·"," ",l.is_expired||l.status==="expired"?"Expired":"Tap to view"]})]})]}):null}function et(){const d=we(),{userId:r}=me.useParams(),{name:l,image:m,listingId:b,listingTitle:_,listingImage:W}=me.useSearch(),[p,I]=n.useState(b?{id:b,title:_,image:W}:null),[Y,C]=n.useState(!1),{isAuthenticated:G}=pe(),{client:A,currentUserId:g,isConnected:R,isConnecting:F,error:B,getOrCreateDirectChannel:V}=ke(),[c,Z]=n.useState(null),[S,y]=n.useState([]),[L,T]=n.useState(""),[J,P]=n.useState(!0),[M,z]=n.useState(!1),[U,Q]=n.useState(null),[$,X]=n.useState({name:xe(l),image:m}),[v,O]=n.useState([]),[D,N]=n.useState(null),q=n.useRef(null),E=n.useRef(null),ee=n.useCallback(async s=>{if(!s||s.length===0)return;N(null);const i=[];for(const o of Array.from(s)){const a=o.type.startsWith("image/"),x=o.type.startsWith("video/");if(!a&&!x){N("Only images and videos are supported.");continue}if(a&&o.size>Me){N("Images must be under 10 MB.");continue}if(x){if(o.size>De){N("Videos must be under 25 MB.");continue}if(await qe(o)>fe){N(`Videos must be ${fe}s or shorter.`);continue}}i.push({id:`${Date.now()}-${Math.random().toString(36).slice(2,7)}`,file:o,kind:a?"image":"video",previewUrl:URL.createObjectURL(o)})}i.length>0&&O(o=>[...o,...i]),q.current&&(q.current.value="")},[]),te=n.useCallback(s=>{O(i=>{const o=i.find(a=>a.id===s);return o&&URL.revokeObjectURL(o.previewUrl),i.filter(a=>a.id!==s)})},[]);n.useEffect(()=>()=>{v.forEach(s=>URL.revokeObjectURL(s.previewUrl))},[]),n.useEffect(()=>{if(!A||!g||!R||!r)return;let s=!1;return P(!0),Q(null),(async()=>{const i=await V(r);if(s)return;if(!i){Q(r===g?"You can't open a chat with yourself.":"Couldn't open this conversation. Please try signing out and back in, then open the listing again."),P(!1);return}Z(i),y(ie(i.state.messages));const a=Object.values(i.state.members??{}).find(x=>x.user_id!==g);a?.user&&X({name:xe(a.user.name??a.user.id),image:a.user.image??void 0});try{await i.markRead()}catch{}P(!1)})(),()=>{s=!0}},[A,g,R,r,V]),n.useEffect(()=>{if(!c)return;const s=a=>{a.message&&(y(x=>x.some(h=>h.id===a.message.id)?x:[...x.filter(h=>!(h.pending&&h.text===a.message.text)),...ie([a.message])]),a.user?.id!==g&&c.markRead().catch(()=>{}))},i=a=>{a.message&&y(x=>x.map(h=>h.id===a.message.id?ie([a.message])[0]:h))},o=[c.on("message.new",s),c.on("message.updated",i)];return()=>o.forEach(a=>a.unsubscribe())},[c,g]),n.useEffect(()=>{E.current?.scrollTo({top:E.current.scrollHeight,behavior:"smooth"})},[S.length]);const H=n.useCallback(async()=>{const s=L.trim();if(!c||!g||!s&&v.length===0)return;const i=s&&p?`${s}
2
3— About this item —
4${p.title??"View listing"}
5${window.location.origin}/item/${p.id}`:s,o=s&&p?p.id:void 0,a=`temp-${Date.now()}`,x=v,h=x.map(u=>({type:u.kind,image_url:u.kind==="image"?u.previewUrl:void 0,asset_url:u.kind==="video"?u.previewUrl:void 0,mime_type:u.file.type,title:u.file.name}));T(""),O([]),z(!0),y(u=>[...u,{id:a,text:i,userId:g,createdAt:Date.now(),pending:!0,attachments:h.length?h:void 0,havynListingId:o}]);try{const u=[];for(const f of x)if(f.kind==="image"){const j=await c.sendImage(f.file,f.file.name);u.push({type:"image",image_url:j.file,mime_type:f.file.type,title:f.file.name})}else{const j=await c.sendFile(f.file,f.file.name,f.file.type);u.push({type:"video",asset_url:j.file,mime_type:f.file.type,title:f.file.name})}await c.sendMessage({text:i,attachments:u.length?u:void 0,...o?{havyn_listing_id:o}:{}}
5),x.forEach(f=>URL.revokeObjectURL(f.previewUrl)),I(null)}catch{y(u=>u.filter(f=>f.id!==a)),T(s),O(x),N("Couldn't send. Please try again.")}finally{z(!1)}},[L,c,g,p,v]),ne=n.useCallback(async s=>{if(!c||!g)return;const i=`I sent you an offer: ${s.title}`,o=`temp-offer-${Date.now()}`;y(a=>[...a,{id:o,text:i,userId:g,createdAt:Date.now(),pending:!0,havynOfferId:s.offer_id}]);try{await c.sendMessage({text:i,havyn_offer_id:s.offer_id})}catch{y(a=>a.filter(x=>x.id!==o))}},[c,g]),w=$.name??"Chat",se=n.useMemo(()=>(w??"?").split(" ").map(s=>s[0]).filter(Boolean).slice(0,2).join("").toUpperCase(),[w]);if(!G)return e.jsxs("div",{className:"mx-auto max-w-2xl px-4 py-16 text-center",children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Sign in to chat"}),e.jsx(K,{to:"/login",className:"mt-6 inline-flex rounded-full brand-gradient px-5 py-2.5 text-sm font-semibold text-primary-foreground",children:"Sign in"})]});const t=F||J&&!c;return e.jsxs("div",{className:"mx-auto flex h-[calc(100vh-65px)] max-w-2xl flex-col px-0 md:px-4 md:py-4",children:[e.jsxs("div",{className:"flex items-center gap-3 border-b border-border bg-background px-4 py-3 md:rounded-t-2xl",children:[e.jsx("button",{onClick:()=>d({to:"/messages"}),className:"grid h-9 w-9 place-items-center rounded-full bg-muted hover:bg-muted/80 transition","aria-label":"Back",children:e.jsx(_e,{className:"h-4 w-4"})}),e.jsxs(K,{to:"/seller/$userId",params:{userId:r},className:"flex min-w-0 items-center gap-3 no-underline",children:[e.jsx("div",{className:"grid h-9 w-9 place-items-center overflow-hidden rounded-full bg-primary/15 text-sm font-bold text-primary",children:$.image?e.jsx("img",{src:$.image,alt:"",className:"h-full w-full object-cover"}):se||"?"}),e.jsx("h1",{className:"truncate text-base font-semibold hover:underline",children:w})]}),e.jsxs("button",{onClick:()=>C(!0),className:"ml-auto inline-flex shrink-0 items-center gap-1.5 rounded-full border border-border px-3 py-1.5 text-xs font-semibold hover:bg-muted",children:[e.jsx(he,{className:"h-3.5 w-3.5"})," Send offer"]})]}),e.jsx(Pe,{open:Y,onClose:()=>C(!1),buyerId:r,buyerName:w,initialListingId:p?.id,onSent:ne}),e.jsx("div",{ref:E,className:"flex-1 overflow-y-auto bg-background px-4 py-4 md:border-x md:border-border",children:B?e.jsxs("div",{className:"py-16 text-center text-sm text-muted-foreground",children:["Couldn't connect to chat. ",B]}):U?e.jsx("div",{className:"py-16 text-center text-sm text-muted-foreground",children:U}):t?e.jsx("div",{className:"py-16 text-center text-sm text-muted-foreground",children:"Loading…"}):S.length===0?e.jsxs("div",{className:"py-16 text-center",children:[e.jsx("p",{className:"text-base font-semibold",children:"Say hi 👋"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Start the conversation by sending a message below."})]}):e.jsx("div",{className:"flex flex-col gap-1",children:S.map((s,i)=>{const o=s.userId===g,a=i>0?S[i-1]:null,x=!a||s.createdAt-a.createdAt>300*1e3,h=ze(s.text),u=s.havynListingId??h.listingId,f=h.displayText;return e.jsxs("div",{children:[x&&e.jsx("p",{className:"my-3 text-center text-[11px] text-muted-foreground",children:Fe(s.createdAt)}),e.jsx("div",{className:`flex ${o?"justify-end":"justify-start"}`,children:e.jsxs("div",{className:`max-w-[78%] overflow-hidden rounded-2xl text-[15px] leading-snug ${o?"bg-primary text-primary-foreground rounded-br-md":"bg-muted text-foreground rounded-bl-md"} ${s.pending?"opacity-60":""}`,children:[s.attachments&&s.attachments.length>0&&!u&&e.jsx("div",{className:"flex flex-col gap-1 p-1",children:s.attachments.map((j,de)=>j.type==="image"&&j.image_url?e.jsx("a",{href:j.image_url,target:"_blank",rel:"noreferrer",className:"block",children:e.jsx("img",{src:j.image_url,alt:j.title??"",className:"max-h-72 w-full rounded-xl object-cover"})},de):j.type==="video"&&j.asset_url?e.jsx("video",{src:j.asset_url,controls:!0,playsInline:!0,preload:"metadata",className:"max-h-72 w-full rounded-xl bg-black"},de):null)}),(f||u||s.havynOfferId)&&e.jsxs("div",{className:"px-3.5 py-2.5",children:[f&&Be(f),u&&e.jsx(Qe,{id:u,isMine:o}),s.havynOfferId&&e.jsx(Xe,{id:s.havynOfferId,isMine:o})]})]})})]},s.id)})})}),p&&e.jsxs("div",{className:"flex items-center gap-3 border-t border-border bg-muted/40 px-3 py-2",children:[p.image&&e.jsx("img",{src:p.image,alt:"",className:"h-10 w-10 rounded-md object-cover"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-muted-foreground",children:"About this item"}),e.jsx(K,{to:"/item/$id",params:{id:p.id},className:"block truncate text-sm font-medium hover:underline",children:p.title??"View listing"})]}),e.jsx("button",{onClick:()=>I(null),"aria-label":"Remove attached listing",className:"grid h-7 w-7 place-items-center rounded-full hover:bg-muted",children:e.jsx(le,{className:"h-4 w-4"})})]}),(v.length>0||D)&&e.jsxs("div",{className:"border-t border-border bg-background px-3 py-2",children:[v.length>0&&e.jsx("div",{className:"flex gap-2 overflow-x-auto pb-1",children:v.map(s=>e.jsxs("div",{className:"relative h-20 w-20 flex-shrink-0",children:[s.kind==="image"?e.jsx("img",{src:s.previewUrl,alt:"",className:"h-full w-full rounded-lg object-cover"}):e.jsx("video",{src:s.previewUrl,className:"h-full w-full rounded-lg bg-black object-cover",muted:!0,playsInl
5ine:!0}),e.jsx("button",{onClick:()=>te(s.id),"aria-label":"Remove attachment",className:"absolute -right-1.5 -top-1.5 grid h-5 w-5 place-items-center rounded-full bg-foreground text-background shadow",children:e.jsx(le,{className:"h-3 w-3"})})]},s.id))}),D&&e.jsx("p",{className:"mt-1 text-[12px] text-destructive",children:D})]}),e.jsxs("div",{className:"flex items-end gap-2 border-t border-border bg-background px-3 py-3 md:rounded-b-2xl",children:[e.jsx("input",{ref:q,type:"file",accept:"image/*,video/*",multiple:!0,className:"hidden",onChange:s=>{ee(s.target.files)}}),e.jsx("button",{onClick:()=>q.current?.click(),disabled:!c||t||!!U||M,className:"grid h-10 w-10 flex-shrink-0 place-items-center rounded-full bg-muted text-foreground hover:bg-muted/80 disabled:opacity-40","aria-label":"Attach photo or video",children:e.jsx(Ee,{className:"h-4 w-4"})}),e.jsx("textarea",{value:L,onChange:s=>T(s.target.value),onKeyDown:s=>{s.key==="Enter"&&!s.shiftKey&&(s.preventDefault(),H())},placeholder:"Type a message…",disabled:!c||t||!!U,rows:1,className:"max-h-32 min-h-[40px] flex-1 resize-none rounded-2xl bg-muted px-4 py-2.5 text-sm outline-none focus:bg-muted/80"}),e.jsx("button",{onClick:H,disabled:!L.trim()&&v.length===0||M||!c,className:"grid h-10 w-10 flex-shrink-0 place-items-center rounded-full brand-gradient text-primary-foreground shadow-soft disabled:opacity-40","aria-label":"Send",children:M?e.jsx(be,{className:"h-4 w-4 animate-spin"}):e.jsx(Re,{className:"h-4 w-4"})})]})]})}export{et as component};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.