1import{r as Se,t as Ae,j as e,P as ue,v as Ce,c as f,m as ee,q as _e,d as O,w as Ee,x as Te,X as Ie,M as Le,h as ze}from"./index-0qbe4j-K.js";import{b as o,L as Y,i as De}from"./react-vendor-CuqwDvgQ.js";import{M as Me}from"./index-DWmYNhMG.js";import{S as Re}from"./index-8V6Idf2H.js";import{A as me}from"./app-icon-AzWZizR9.js";import{C as Fe,B as Oe}from"./base-layout-DaMwzoR8.js";import{B as P}from"./badge-DDqArN_7.js";import{E as Pe}from"./empty-ynZ7YKNF.js";import{S as V}from"./skeleton-BJ8OkINw.js";import{C as xe}from"./index-DRrqZmx6.js";import{g as Be,h as de,j as Ue,k as W,m as $e,l as Ge,s as Ve}from"./engagements-service-CdOU7Cm3.js";import{p as fe,F as We}from"./file-preview-sheet-BCbksk91.js";import{S as Xe}from"./spinner-AOg6zabj.js";import{C as qe}from"./index-BC12iQKI.js";import{c as Ke,a as He,f as ce,g as Ye}from"./engagements-fHqvU0Sw.js";import{S as Qe,t as Ze,f as X,s as Je,r as et}from"./support-service-DbV5G2Gd.js";import{f as tt}from"./account-DmcpO8wl.js";import{m as st,g as rt,M as q}from"./messages-DOk92uVf.js";import{b as at,d as nt,t as it,e as K,G as lt}from"./conversations-D3imhUx9.js";import"./separator-y_AUlMtH.js";import"./index-RMECr4EV.js";import"./index-BqofzlGR.js";import"./index-CiYLqn6R.js";import"./highlight-7Lme_vfI.js";import"./index-fQbr3YLv.js";import"./index-DMNugQWA.js";import"./sidebar-CkKgxlKr.js";import"./sheet-C6SrAI_i.js";import"./tooltip-CyqT2N0J.js";import"./index-DTk4Cdmh.js";import"./index-DjQahpwR.js";import"./index-Cpz9K9gG.js";import"./use-spring-D9a5Y3Ix.js";import"./index-l9j0_l5U.js";import"./index-D17hSi50.js";import"./page-transition-DPFLNUVD.js";import"./index-BCqtSsgj.js";const ot=[["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"}]],F=Se("paperclip",ot);var dt=Object.defineProperty,S=(s,r)=>dt(s,"name",{value:r,configurable:!0}),pe="Avatar",[ct,xs]=Ae(pe),ut=[0,()=>{}],[mt,xt]=ct(pe),ft=o.forwardRef(S(function(r,n){const{__scopeAvatar:d,...c}=r,[i,u]=o.useState("idle"),[x,p]=he();return e.jsx(mt,{scope:d,imageLoadingStatus:i,setImageLoadingStatus:u,imageCount:x,setImageCount:p,children:e.jsx(ue.span,{...c,ref:n})})},"Avatar")),pt="AvatarFallback",ht=o.forwardRef(S(function(r,n){const{__scopeAvatar:d,delayMs:c,...i}=r,u=xt(pt,d),[x,p]=o.useState(c===void 0);return o.useEffect(()=>{if(c!==void 0){const b=window.setTimeout(()=>p(!0),c);return()=>window.clearTimeout(b)}},[c]),x&&u.imageLoadingStatus!=="loaded"?e.jsx(ue.span,{...i,ref:n}):null},"AvatarFallback"));function gt(s,{loadingStatus:r,setLoadingStatus:n,referrerPolicy:d,crossOrigin:c}){return Ce(()=>{if(!s){n("error");return}const i=new window.Image,u=S(p=>{const b=p.currentTarget;n(Q(b))},"handleLoad"),x=S(()=>n("error"),"handleError");return i.addEventListener("load",u),i.addEventListener("error",x),d&&(i.referrerPolicy=d),i.crossOrigin=c??null,i.src=s,n(Q(i)),()=>{i.removeEventListener("load",u),i.removeEventListener("error",x),n("idle")}},[s,c,d,n]),r}S(gt,"useImageLoadingStatus");function Q(s){return s.complete?s.naturalWidth>0?"loaded":"error":"loading"}S(Q,"getImageLoadingStatus");function he(){return ut}S(he,"useImageCount");function bt(s){}S(bt,"useUpdateImageCount");function Z({className:s,...r}){return e.jsx(ft,{"data-slot":"avatar",className:f("relative flex size-8 shrink-0 overflow-hidden rounded-full",s),...r})}function J({className:s,...r}){return e.jsx(ht,{"data-slot":"avatar-fallback",className:f("bg-muted flex size-full items-center justify-center rounded-full",s),...r})}function jt({className:s}){return e.jsx("span",{className:f("inline-flex items-center gap-0.5",s),role:"status","aria-label":"Sending",children:[0,1,2].map(r=>e.jsx(ee.span,{className:"inline-block size-1 rounded-full bg-current",animate:{y:[0,-2,0],opacity:[.4,1,.4]},transition:{duration:.9,repeat:1/0,ease:"easeInOut",delay:r*.15}},r))})}function ge({message:s}){if(s.sender!=="client")return null;const r=s.id.startsWith("pending-"),n=!!s.read_at,d=r?"sending":n?"read":"sent";return e.jsx(_e,{mode:"wait",initial:!1,children:e.jsx(ee.span,{initial:{opacity:0,scale:.6}
1,animate:{opacity:1,scale:1},exit:{opacity:0,scale:.6},transition:{duration:.15,ease:"easeOut"},className:f("inline-flex",n?"text-primary":"text-muted-foreground"),title:r?"Sending":n?"Read":"Sent","aria-label":r?"Sending":n?"Read":"Sent",children:r?e.jsx(jt,{}):n?e.jsx(Fe,{className:"size-3.5"}):e.jsx(xe,{className:"size-3.5"})},d)})}function yt(s,r){const[n,d]=o.useState(null),[c,i]=o.useState(!1),u=o.useRef(null);return o.useEffect(()=>{if(!r||u.current===s)return;u.current=s;let x=!0;return Be(s).then(p=>{x&&(p?d(p):i(!0))}).catch(()=>x&&i(!0)),()=>{x=!1}},[s,r]),{url:n,failed:c}}function vt({file:s,mine:r,onOpen:n}){const d=fe(s.title),c=d==="image"||d==="audio"||d==="video",{url:i,failed:u}=yt(s.storage_path,c),x=e.jsxs("button",{type:"button",onClick:n,className:f("flex w-full items-center gap-2 rounded-lg border px-2.5 py-2 text-left text-xs font-medium transition-colors",r?"border-primary-foreground/25 hover:bg-primary-foreground/10":"border-border hover:bg-background/60"),children:[e.jsx(F,{className:"size-4 shrink-0"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:s.title}),e.jsx("span",{className:"shrink-0 opacity-70",children:"Open"})]});return!c||u?x:i?d==="image"?e.jsx("button",{type:"button",onClick:n,className:"focus-visible:ring-ring/50 block overflow-hidden rounded-lg focus-visible:ring-[3px] focus-visible:outline-none","aria-label":`Open ${s.title}`,children:e.jsx("img",{src:i,alt:s.title,loading:"lazy",className:"max-h-64 w-auto max-w-full rounded-lg object-cover"})}):d==="audio"?e.jsx("audio",{controls:!0,preload:"none",src:i,className:"w-56 max-w-full sm:w-72"}):e.jsx("video",{controls:!0,preload:"metadata",src:i,className:"max-h-64 w-full max-w-sm rounded-lg bg-black"}):e.jsx("div",{className:f("bg-muted/40 animate-pulse rounded-lg",d==="audio"?"h-10 w-56":"h-40 w-56")})}function Nt({id:s}){const[r,n]=o.useState(!1),d=Ze(s);return e.jsxs("button",{type:"button",onClick:()=>{navigator.clipboard?.writeText(d),n(!0),window.setTimeout(()=>n(!1),1600)},className:"hover:bg-muted/60 group flex w-full items-center justify-between gap-2 rounded-lg border px-3 py-2 transition-colors","aria-label":`Copy reference ${d}`,children:[e.jsx("span",{className:"font-mono text-xs",children:d}),e.jsx(me,{icon:r?xe:qe,size:14,className:r?"text-emerald-500":"text-muted-foreground"})]})}function wt({conversation:s,documents:r,onPreview:n,onResolve:d,resolving:c}){const{engagement:i,ticket:u}=s,x=new Map(r.map(l=>[l.id,l])),p=s.messages.map(l=>l.document_id?x.get(l.document_id):void 0).filter(l=>!!l),b=u?.status==="resolved";return e.jsxs("aside",{className:"flex h-full min-h-0 flex-col gap-4",children:[u&&e.jsxs("section",{className:"space-y-3 rounded-xl border p-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-sm font-medium",children:"Status"}),e.jsx(P,{variant:b?"outline":u.status==="answered"?"default":"secondary",children:Qe[u.status]})]}),e.jsx(Nt,{id:u.id}),e.jsx(O,{variant:"outline",size:"sm",className:"w-full",disabled:c,onClick:()=>d(!b),children:c?e.jsxs(e.Fragment,{children:[e.jsx(Xe,{size:"sm",className:"mr-2"}),"Savingâ¦"]}):b?"Reopen this ticket":"Close this ticket"})]}),i&&e.jsxs("section",{className:"space-y-3 rounded-xl border p-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-sm font-medium",children:"Order"}),e.jsx(P,{variant:s.active?"default":"outline",children:Ke(i)})]}),e.jsx(Ee,{value:He(i),className:"h-1.5"}),e.jsxs("dl",{className:"space-y-1 text-xs",children:[e.jsxs("div",{className:"flex justify-between gap-2",children:[e.jsx("dt",{className:"text-muted-foreground",children:"Started"}),e.jsx("dd",{children:ce(i.created_at)})]}),i.delivered_at&&e.jsxs("div",{className:"flex justify-between gap-2",children:[e.jsx("dt",{className:"text-muted-foreground",children:"Report"}),e.jsx("dd",{children:ce(i.delivered_at)})]})]}),e.jsx(O,{variant:"outline",size:"sm",className:"w-full",asChild:!0,children:e.jsx(Y,{to:`/orders/${i.id}`,children:"Open the order"})})]}),e.jsxs("section",{className:"flex min-h-0 flex-1 flex-col gap-3 rounded-xl border p-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-sm font-medium",children:"Attachments"}),p.length>0&&e.jsx("span",{className:"text-muted-foreground text-xs tabular-nums",children:p.length})]}),p.length===0?e.jsx("p",{className:"text-muted-foreground flex flex-1 items-center justify-center text-xs",children:"Nothing attached yet"}):e.jsx("ul",{className:"thin-scrollbar grid min-h-0 flex-1 grid-cols-3 content-start gap-2 overflow-y-auto",children:p.map(l=>{const j=fe(l.title);return e.jsx("li",{children:e.jsx("button",{type:"button",onClick:()=>n(l),title:l.title,className:f("bg-muted/50 hover:border-primary/40 flex aspect-square w-full items-center justify-center rounded-lg border p-1 transition-colors","focus-visible:ring-ring/50 focus-visible:ring-[3px] focus-visible:outline-none"),children:e.jsx("span",{className:"text-muted-foreground text-[10px] font-medium uppercase",children:j==="image"?"IMG":l.title.split(".").pop()?.slice(0,4)})})},l.id)})})]})]})}const kt=6;function St(s){const r=s.replace(/[^a-zA-Z ]/g," ").split(/\s+/).filter(
1Boolean);return r.length===0?"SX":(r[0][0]+(r[1]?.[0]??"")).toUpperCase()}function At(s){if(!s)return"";const r=new Date(s);if(Number.isNaN(r.getTime()))return"";const n=new Date;if(r.toDateString()===n.toDateString())return r.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"});const c=Math.floor((n.getTime()-r.getTime())/864e5);return c<1?"Yesterday":c<7?r.toLocaleDateString(void 0,{weekday:"short"}):r.toLocaleDateString(void 0,{day:"numeric",month:"short"})}const Ct=[{value:"all",label:"All"},{value:"waiting",label:"Waiting"},{value:"closed",label:"Closed"}];function H(s,r){if(r==="all")return!0;if(r==="closed")return!s.active;if(!s.active)return!1;const n=s.last;return!n||n.sender==="securoxen"}function _t({conversations:s,total:r,openId:n,onSelect:d,query:c,onQueryChange:i,filter:u,onFilterChange:x,counts:p}){const b=r>=kt;return e.jsxs("div",{className:"border-border bg-card flex h-full min-h-0 flex-col overflow-hidden rounded-xl border",children:[b&&e.jsx("div",{className:"border-border border-b p-3",children:e.jsxs("div",{className:"relative",children:[e.jsx(Te,{className:"text-muted-foreground pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2"}),e.jsx("input",{type:"search",value:c,onChange:l=>i(l.target.value),placeholder:"Search tickets","aria-label":"Search tickets",className:"border-border bg-background focus:border-primary w-full rounded-lg border py-2 pr-9 pl-9 text-sm outline-none"}),c&&e.jsx("button",{type:"button",onClick:()=>i(""),"aria-label":"Clear search",className:"text-muted-foreground hover:text-foreground absolute top-1/2 right-2 flex size-6 -translate-y-1/2 items-center justify-center rounded-md",children:e.jsx(Ie,{className:"size-3.5"})})]})}),e.jsx("div",{className:"border-border flex gap-1 border-b p-2",children:Ct.map(l=>{const j=l.value===u;return e.jsxs("button",{type:"button",onClick:()=>x(l.value),"aria-pressed":j,className:f("flex flex-1 items-center justify-center gap-1.5 rounded-md px-2 py-1.5 text-xs font-medium transition-colors",j?"bg-muted text-foreground":"text-muted-foreground hover:text-foreground"),children:[l.label,e.jsx("span",{className:"tabular-nums opacity-60",children:p[l.value]})]},l.value)})}),e.jsxs("ul",{"data-slot":"thread-list",className:"thin-scrollbar min-h-0 flex-1 overflow-y-auto",children:[s.length===0&&e.jsxs("li",{className:"text-muted-foreground p-4 text-sm",children:["Nothing matches â",c.trim(),"â."]}),s.map(l=>{const j=l.id===n,A=l.last;return e.jsx("li",{children:e.jsxs("button",{type:"button",onClick:()=>d(l.id),"aria-current":j?"true":void 0,className:f("flex w-full items-center gap-3 px-4 py-3 text-left transition-colors",j?"bg-muted":"hover:bg-muted/50"),children:[e.jsx(Z,{className:"size-9 shrink-0",children:e.jsx(J,{className:f("text-[11px] font-semibold",l.active?"bg-primary/10 text-primary":"bg-muted text-muted-foreground"),children:St(l.title)})}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsxs("span",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("span",{className:"flex min-w-0 items-center gap-1.5",children:e.jsx("span",{className:"truncate text-sm font-medium",children:l.title})}),e.jsx("span",{className:"text-muted-foreground shrink-0 text-xs tabular-nums",children:At(A?.created_at)})]}),e.jsxs("span",{className:"mt-0.5 flex items-center gap-1.5",children:[A&&e.jsx(ge,{message:A}),e.jsx("span",{className:f("min-w-0 flex-1 truncate text-xs",l.unread>0?"text-foreground font-medium":"text-muted-foreground"),children:A?A.body:"No messages yet"}),l.unread>0&&e.jsx(P,{className:"size-5 shrink-0 justify-center rounded-full p-0 text-[11px]",children:l.unread}),!l.active&&l.unread===0&&e.jsx("span",{className:"text-muted-foreground shrink-0 text-[11px]",children:l.ticket?"resolved":"closed"})]})]})]})},l.id)})]})]})}function Et(s,r){const n=o.useRef(s);o.useEffect(()=>{n.current=s},[s]),o.useEffect(()=>{if(typeof document>"u")return;let d;const c=()=>{d&&clearInterval(d),d=void 0},i=()=>{c(),d=setInterval(()=>n.current(),r)},u=()=>{document.visibilityState==="visible"?(n.current(),i()):c()};return document.visibilityState==="visible"&&i(),document.addEventListener("visibilitychange",u),window.addEventListener("focus",u),()=>{c(),document.removeEventListener("visibilitychange",u),window.removeEventListener("focus",u)}},[r])}
1function fs(){const[s,r]=o.useState("loading"),[n,d]=o.useState([]),[c,i]=o.useState([]),[u,x]=o.useState([]),[p]=De(),[b,l]=o.useState(()=>p.get("thread")),[j,A]=o.useState(""),[C,I]=o.useState(""),[L,B]=o.useState(!1),[te,_]=o.useState(null),[k,T]=o.useState(null),[se,U]=o.useState(null),[be,re]=o.useState(!1),[$,je]=o.useState("all"),[ye,G]=o.useState(!1),ae=o.useRef(null);o.useEffect(()=>{let t=!1;return de().then(a=>!t&&r(a)),Ue().then(a=>{!t&&a.status==="ok"&&d(Ye(a.engagements))}),W().then(a=>!t&&a&&i(a)),X().then(a=>!t&&x(a)).catch(()=>{}),()=>{t=!0}},[]),Et(()=>{L||(de().then(t=>{Array.isArray(t)&&r(a=>{const g=Array.isArray(a)?a.filter(h=>h.id.startsWith("pending-")):[];return[...t,...g]})}),W().then(t=>t&&i(t)),X().then(x).catch(()=>{}))},8e3);const z=o.useMemo(()=>Array.isArray(s)?s:[],[s]),w=o.useMemo(()=>at(z,n,u),[z,n,u]),m=w.find(t=>t.id===b)??nt(w),ne=o.useMemo(()=>{const t=j.trim().toLowerCase(),a=w.filter(g=>H(g,$));return t.length<2?a:a.filter(g=>g.title.toLowerCase().includes(t)||g.messages.some(h=>h.body.toLowerCase().includes(t)))},[w,j,$]),ve=o.useMemo(()=>({all:w.length,waiting:w.filter(t=>H(t,"waiting")).length,closed:w.filter(t=>H(t,"closed")).length}),[w]);o.useEffect(()=>{const t=ae.current;typeof t?.scrollIntoView=="function"&&t.scrollIntoView({block:"end"})},[m?.id,z.length]);const D=m?.id,ie=m?.unread??0;o.useEffect(()=>{if(!D||ie===0)return;let t=!1;return $e(D===lt?null:D).then(a=>{if(t||a.length===0)return;const g=new Set(a),h=new Date().toISOString();r(E=>Array.isArray(E)?E.map(v=>g.has(v.id)?{...v,read_at:h}:v):E)}),()=>{t=!0}},[D,ie]);const le=st(C),Ne=rt(m?.messages??[]),we=o.useMemo(()=>{const t=new Map;for(const a of c)t.set(a.id,a);return t},[c]);async function oe(t){if(t.preventDefault(),L||!m||!k&&le)return;const a=C.trim()||(k?k.name:"");if(!a)return;
1const g=it(m),h=`pending-${Date.now()}`,E={id:h,engagement_id:K(m),ticket_id:g,sender:"client",body:a,read_at:null,created_at:new Date().toISOString()};B(!0),_(null),I(""),r([...z,E]);let v=null;if(k){const y=await Ge(k,K(m));if(!y.ok){B(!1),r(M=>Array.isArray(M)?M.filter(R=>R.id!==h):M),_(y.error),I(C);return}v=y.documentId}const N=g?await et(g,a).then(y=>({ok:!0,message:{...y,engagement_id:null,ticket_id:g}})).catch(()=>({ok:!1,error:"That reply did not send."})):await Ve(a,K(m),v);if(B(!1),T(null),v){const y=await W();y&&i(y)}r(y=>{const R=(Array.isArray(y)?y:[]).filter(ke=>ke.id!==h);return N.ok?[...R,N.message]:R}),N.ok||(_(N.error),I(a))}return e.jsxs(Oe,{title:"Tickets",description:"Every conversation with us, one per job or question.",icon:Le,children:[s==="loading"&&e.jsxs("div",{className:"border-border grid gap-4 rounded-xl md:grid-cols-[280px_1fr]","aria-busy":"true",children:[e.jsx("div",{className:"border-border space-y-3 rounded-xl border p-4",children:[0,1,2].map(t=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(V,{className:"size-9 rounded-full"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx(V,{className:"h-3 w-32"}),e.jsx(V,{className:"h-3 w-40"})]})]},t))}),e.jsx("div",{className:"border-border h-[60vh] rounded-xl border"})]}),s===null&&e.jsxs("div",{className:"flex gap-3 rounded-xl border border-amber-500/40 p-4",children:[e.jsx(ze,{className:"mt-0.5 size-5 shrink-0 text-amber-500"}),e.jsxs("p",{className:"text-muted-foreground text-sm leading-relaxed",children:["Could not load your messages. Email us instead â"," ",e.jsx("a",{href:"mailto:[email protected]",className:"text-primary underline underline-offset-2",children:"[email protected]"})," ","reaches the same person."]})]}),Array.isArray(s)&&m&&e.jsxs("div",{className:"grid h-[calc(100vh-13rem)] min-h-[30rem] gap-4 md:grid-cols-[280px_1fr] xl:grid-cols-[300px_1fr_300px]",children:[e.jsx("div",{className:"hidden min-h-0 md:block",children:e.jsx(_t,{conversations:ne,total:w.length,openId:m.id,onSelect:l,query:j,onQueryChange:A,filter:$,onFilterChange:je,counts:ve})}),e.jsx("div",{className:"no-scrollbar -mx-1 flex gap-2 overflow-x-auto px-1 md:hidden",children:ne.map(t=>e.jsxs("button",{type:"button",onClick:()=>l(t.id),className:f("shrink-0 rounded-full border px-3 py-1.5 text-xs transition-colors",t.id===m.id?"border-primary bg-primary/10 text-foreground":"border-border text-muted-foreground"),children:[t.title,t.unread>0&&e.jsx("span",{className:"bg-primary text-primary-foreground ml-1.5 rounded-full px-1.5",children:t.unread})]},t.id))}),e.jsxs("div",{className:"border-border bg-card flex min-h-0 flex-col overflow-hidden rounded-xl border",children:[e.jsxs("div",{className:"border-border flex items-center gap-3 border-b p-4",children:[e.jsx(Z,{className:"size-9 shrink-0",children:e.jsx(J,{className:"bg-primary/10 text-primary text-[11px] font-semibold",children:"SX"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate text-sm font-medium",children:m.title}),e.jsx("p",{className:"text-muted-foreground truncate text-xs",children:m.engagement?m.active?"Securoxen · replies reach the person doing the work":"Securoxen · this order is closed":"Securoxen · anything not about a specific order"})]}),!m.active&&e.jsx(P,{variant:"secondary",children:"closed"}),m.engagement&&e.jsx(O,{variant:"ghost",size:"sm",className:"xl:hidden",asChild:!0,children:e.jsx(Y,{to:`/orders/${m.engagement.id}`,children:"Open the order"})})]}),e.jsx("div",{className:"thin-scrollbar min-h-0 flex-1 overflow-y-auto p-4 sm:p-6",children:m.messages.length===0?e.jsx(Pe,{icon:e.jsx(Me,{className:"size-8"}),title:"Nothing here yet",description:m.engagement?"Ask anything about this order. It reaches the person doing the work, not a support queue.":"Anything you send here reaches the person doing your work."}):e.jsxs("div",{className:"space-y-6",children:[Ne.map(t=>e.jsxs("div",{children:[e.jsxs("div",{className:"mb-4 flex items-center gap-3",children:[e.jsx("span",{className:"bg-border h-px flex-1"}),e.jsx("span",{className:"text-muted-foreground text-[11px]",children:t.day}),e.jsx("span",{className:"bg-border h-px flex-1"})]}),e.jsx("div",{className:"space-y-2",children:t.messages.map((a,g)=>{const h=a.sender==="client",v=t.messages[g-1]?.sender===a.sender;return e.jsxs(ee.div,{"data-slot":"message","data-align":h?"end":"start",initial:{opacity:0,y:8}
1,animate:{opacity:1,y:0},transition:{duration:.2,ease:"easeOut"},className:f("flex items-end gap-2",h?"justify-end":"justify-start",v?"mt-0.5":"mt-3"),children:[!h&&(v?e.jsx("span",{className:"w-7 shrink-0","aria-hidden":!0}):e.jsx("span",{"data-slot":"message-avatar",className:"shrink-0",children:e.jsx(Z,{className:"size-7",children:e.jsx(J,{className:"bg-primary/10 text-primary text-[10px] font-semibold",children:"SX"})})})),e.jsxs("div",{className:f("max-w-[75%] min-w-0",h&&"items-end"),children:[e.jsx("div",{"data-slot":"bubble",className:f("rounded-2xl px-3.5 py-2 text-sm leading-relaxed whitespace-pre-wrap",h?"bg-primary text-primary-foreground rounded-br-sm":"bg-muted rounded-bl-sm"),children:(()=>{const N=a.document_id?we.get(a.document_id):void 0;return a.document_id&&!N?e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"flex items-center gap-2 text-xs opacity-70",children:[e.jsx(F,{className:"size-3.5 shrink-0"}),"Attachment unavailable"]}),e.jsx("p",{className:"mt-1.5",children:a.body})]}):N?e.jsxs(e.Fragment,{children:[e.jsx(vt,{file:N,mine:h,onOpen:()=>U(N)}),a.body!==N.title&&e.jsx("p",{className:"mt-1.5",children:a.body})]}):a.body})()}),e.jsxs("div",{className:f("text-muted-foreground mt-1 flex items-center gap-1 text-[11px]",h?"justify-end":"justify-start"),children:[e.jsx("span",{title:tt(a.created_at),children:new Date(a.created_at).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"})}),e.jsx(ge,{message:a})]})]})]},a.id)})})]},t.day)),e.jsx("div",{ref:ae})]})}),e.jsxs("form",{onSubmit:oe,onPaste:t=>{const a=Array.from(t.clipboardData?.files??[])[0];a&&(t.preventDefault(),T(a))},onDragOver:t=>{t.dataTransfer.types.includes("Files")&&(t.preventDefault(),G(!0))},onDragLeave:t=>{t.currentTarget.contains(t.relatedTarget)||G(!1)},onDrop:t=>{t.preventDefault(),G(!1);const a=Array.from(t.dataTransfer.files)[0];a&&T(a)},className:f("border-border border-t p-3 transition-colors sm:p-4",ye&&"bg-primary/5 border-primary"),children:[k&&e.jsxs("div",{className:"border-border mb-2 flex items-center gap-2 rounded-lg border px-3 py-2",children:[e.jsx(F,{className:"text-muted-foreground size-4 shrink-0"}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:k.name}),e.jsx("button",{type:"button",onClick:()=>T(null),className:"text-muted-foreground hover:text-foreground text-xs transition-colors",children:"Remove"})]}),e.jsxs("div",{className:"border-border focus-within:border-primary flex items-end gap-2 rounded-xl border p-2 transition-colors",children:[e.jsxs("label",{className:"text-muted-foreground hover:text-foreground hover:bg-muted flex size-9 shrink-0 cursor-pointer items-center justify-center rounded-lg transition-colors",title:"Attach a file",children:[e.jsx(F,{className:"size-4"}),e.jsx("span",{className:"sr-only",children:"Attach a file"}),e.jsx("input",{type:"file",className:"sr-only",disabled:L,onChange:t=>{const a=t.target.files?.[0];if(t.target.value="",!!a){if(a.size>20*1024*1024){_("That file is larger than 20 MB.");return}_(null),T(a)}}})]}),e.jsx("label",{htmlFor:"message-body",className:"sr-only",children:"Message"}),e.jsx("textarea",{id:"message-body",value:C,onChange:t=>I(t.target.value),onKeyDown:t=>{t.key==="Enter"&&!t.shiftKey&&(t.preventDefault(),oe(t))},rows:1,maxLength:q+200,placeholder:m.engagement?`Message about ${m.title}â¦`:"Write a messageâ¦",className:"thin-scrollbar max-h-32 min-h-9 flex-1 resize-none bg-transparent px-2 py-1.5 text-sm outline-none"}),e.jsxs(O,{type:"submit",size:"icon",disabled:L||!k&&!!le,children:[e.jsx(me,{icon:Re,size:16}),e.jsx("span",{className:"sr-only",children:"Send"})]})]}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("p",{className:"text-muted-foreground text-[11px]",children:["Do not paste passwords or keys here."," ",e.jsx(Y,{to:"/tools/secret-sharing",className:"text-primary underline underline-offset-2",children:"Split a secret instead"}),"."]}),e.jsxs("span",{className:f("text-[11px] tabular-nums",C.length>q?"text-destructive":"text-muted-foreground"),children:[C.length," / ",q]})]}),te&&e.jsxs("p",{className:"mt-2 text-sm text-amber-500",children:["Could not send: ",te,". Your text is still here â copy it somewhere safe if you need to."]})]})]}),m&&e.jsx("div",{className:"hidden min-h-0 xl:block",children:e.jsx(wt,{conversation:m,documents:c,onPreview:U,resolving:be,onResolve:async t=>{const a=m.ticket?.id;if(a){re(!0);try{await Je(a,t),x(await X())}catch{_("That could not be saved. Try again.")}finally{re(!1)}}}})})]}),e.jsx(We,{document:se,open:!!se,onOpenChange:t=>!t&&U(null),context:m?.engagement?m.title:void 0})]})}export{fs as default};
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.