1import{u as us,e as xs,r as a,j as e,L as ps,R as gs}from"./react-vendor-zQZQejYb.js";import{u as ms,f as ie,A as fs,z as Pe,y as hs,d as L,H as bs,l as Ss}from"./index-B6OEjisV.js";import{e as ys,s as he,a as vs}from"./ChatMessages-BLeHdvut.js";import{C as _s,I as js}from"./ContentAwareLoading-CojPr3D_.js";import{c as Ns}from"./recentActivity-BfemHGu-.js";import{A as ws,S as Cs,J as Fs,I as $e,u as z,y as re,a4 as Us,t as ks}from"./icons-vendor-D-B0TJjP.js";import"./query-vendor-BZK5hxKT.js";import"./jspdf-vendor-3_3_SuWG.js";import"./graph-vendor-EJKc4302.js";import"./editor-vendor-3719hrbx.js";import"./markdown-vendor-BYufjUlz.js";const Rs=typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,me=12,Oe=t=>!t||typeof t!="object"||Array.isArray(t)?null:t,He=t=>{var f,x;if(!Ss.isAxiosError(t))return{message:"Unable to delete this session right now.",shouldRemoveLocally:!1};const d=(f=t.response)==null?void 0:f.status,c=Oe((x=t.response)==null?void 0:x.data),l=Oe(c==null?void 0:c.detail),p=(typeof(c==null?void 0:c.error_code)=="string"?c.error_code:null)||(typeof(l==null?void 0:l.error_code)=="string"?l.error_code:null),y=(typeof(c==null?void 0:c.message)=="string"?c.message:null)||(typeof(l==null?void 0:l.message)=="string"?l.message:null)||(typeof(c==null?void 0:c.detail)=="string"?c.detail:null);return p==="AUTH_SCOPE_INVALID"?{message:"Your login is not authorized to delete this session. Please sign in again and retry.",shouldRemoveLocally:!1}:p&&p.startsWith("AUTH_")||d===401?{message:"Your login has expired. Please sign in again and retry.",shouldRemoveLocally:!1}:p==="RESOURCE_OWNER_MISSING"?{message:"This session cannot be deleted because its ownership record is missing.",shouldRemoveLocally:!1}:p==="RESOURCE_ACCESS_DENIED"||p==="USER_ID_MISMATCH"||d===403?{message:"You do not have permission to delete this session.",shouldRemoveLocally:!1}:p==="SESSION_NOT_FOUND"||d===404||y==="Session not found"?{message:"This session no longer exists. It may have already been deleted.",shouldRemoveLocally:!0}:y?{message:y,shouldRemoveLocally:!1}:{message:"Unable to delete this session right now.",shouldRemoveLocally:!1}},oe=t=>{const d=new Map,c=[];for(const l of t){const p=d.get(l.id);p===void 0?(d.set(l.id,c.length),c.push(l)):c[p]={...c[p],...l}}return c},Es=(t,d)=>({id:t.id,user_id:t.user_id,title:t.title,message_count:d,created_at:t.created_at,updated_at:t.updated_at}),Ds=(t,d)=>{const c=[];return d.forEach((l,p)=>{l.role!=="user"&&l.role!=="assistant"||l.role==="assistant"&&!he(l.content||"").trim()||c.push({role:l.role,content:l.content??"",timestamp:new Date(l.created_at).getTime(),sessionId:t,isFirstInSession:p===0,sources:l.role==="assistant"?vs(l.sources):void 0})}),c},fe=t=>{var y;const d=t.filter(f=>f.role==="assistant"?!!he(f.content||"").trim():f.role==="user"||f.role==="system"),c=((y=d.find(f=>f.role==="user"))==null?void 0:y.content.trim().replace(/\s+/g," ").slice(0,140))||"No user prompt captured yet.",l=d[d.length-1],p=l?he(l.content||"").trim().replace(/\s+/g," ").slice(0,180)||l.content.trim().replace(/\s+/g," ").slice(0,180):"No visible reply yet.";return{firstUserSnippet:c,lastMessageSnippet:p,messageCount:d.length}},de=t=>{if(!t)return"Unknown date";const d=new Date(t);if(Number.isNaN(d.getTime()))return"Unknown date";const l=Math.floor((new Date().getTime()-d.getTime())/(1e3*60*60*24));return l===0?`Today at ${d.toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"})}`:l===1?`Yesterday at ${d.toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"})}`:d.toLocaleString(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})},le=(t,d)=>{var c;return(c=t.title)!=null&&c.trim()?t.title.trim():d!=null&&d.firstUserSnippet&&d.firstUserSnippet!=="No user prompt captured yet."?d.firstUserSnippet:`Conversation from ${de(t.updated_at||t.created_at)}`},qe=(t,d=72)=>{const c=String(t||"").replace(/\s+/g," ").trim();return c?c.length>d?`${c.slice(0,d).trimEnd()}...`:c:""};let ce=null;const qs=()=>{const{t}=ms(),d=us(),c=xs(),l=a.useMemo(()=>new URLSearchParams(d.search).get("session"),[d.search]),p=a.useRef(l),y=a.useMemo(()=>{try{return ie()}catch{return"guest"}},[]),f=a.useMemo(()=>fs(y),[y]),x=ce&&ce.userKey===y?ce:null,Y=a.useRef(new Set((x==null?void 0:x.sessions.map(s=>s.id))??[])),R=a.useRef(0),B=a.useRef(!1),A=a.useRef((x==null?void 0:x.sessions)??[]),G=a.useRef(l),be=a.useRef((x==null?void 0:x.messages)??{}),Q=a.useRef(new Set(Object.keys((x==null?void 0:x.previews)??{}))),[w,J]=a.useState((x==null?void 0:x.sessions)??[]),[E,ue]=a.useState((x==null?void 0:x.previews)??{}),[Z,Se]=a.useState((x==null?void 0:x.messages)??{}),[h,T]=a.useState(l??(x==null?void 0:x.selectedSessionId)??null),[Ke,I]=a.use
1State([]),[P,Ve]=a.useState(""),[We,ye]=a.useState(!x),[X,ve]=a.useState(!1),[Ye,_e]=a.useState(!1),[$,je]=a.useState(null),[xe,O]=a.useState(null),[S,Ne]=a.useState(!1),[C,H]=a.useState(new Set),[Ge,D]=a.useState(!1),[v,we]=a.useState(!1),[Ce,ee]=a.useState(null),[Qe,pe]=a.useState(new Set),[q,Je]=a.useState((x==null?void 0:x.hasMore)??!0),[se,Fe]=a.useState((x==null?void 0:x.offset)??0),[Ue,ke]=a.useState(null),[Re,K]=a.useState(null),[Ee,M]=a.useState(null),[De,ge]=a.useState(null),[Me,Le]=a.useState(null);a.useEffect(()=>{A.current=w},[w]),a.useEffect(()=>{G.current=h},[h]),a.useEffect(()=>{be.current=Z},[Z]),a.useEffect(()=>{B.current&&(ce={userKey:y,sessions:w,previews:E,messages:Z,offset:se,hasMore:q,selectedSessionId:h})},[w,E,Z,se,q,h,y]),a.useEffect(()=>{(!h||xe!==h)&&O(null)},[xe,h]),a.useEffect(()=>{M(null)},[h]),a.useEffect(()=>{ge(null)},[h]);const F=a.useCallback(s=>{Pe(f.recentSessions,s)},[f.recentSessions]),ze=a.useCallback((s,n)=>{const i=qe(le(s,n),64),r=qe((n==null?void 0:n.lastMessageSnippet)||(n==null?void 0:n.firstUserSnippet),96);hs(f.recentSessions,{id:s.id,title:s.title,message_count:s.message_count,created_at:s.created_at,updated_at:s.updated_at,display_label:i||void 0,preview_snippet:r||void 0}),Ns(ie(),{activityKey:`counselor:session:${s.id}`,sectionKey:"counselor",actionKey:"session_updated",route:`/consultant/sessions?session=${encodeURIComponent(s.id)}`,detail:i||s.title||void 0})},[f.recentSessions]),Be=a.useCallback((s,n)=>{Q.current.add(s),ue(i=>({...i,[s]:fe(n)}))},[]),te=a.useCallback(async s=>{const i=(await L.getSession(s)).data,r=Es(i.session,i.messages.filter(m=>m.role==="user"||m.role==="assistant").length),o=Ds(s,i.messages),u=fe(i.messages);return J(m=>{const b=m.findIndex(k=>k.id===r.id);if(b===-1)return oe([r,...m]);const j=[...m];return j[b]={...j[b],...r},j}),Be(s,i.messages),Se(m=>({...m,[s]:o})),ze(r,u),{session:r,messages:o}},[Be,ze]),U=a.useCallback(async s=>{const n=A.current.find(r=>r.id===s);return n||(await te(s)).session},[te]),Ae=a.useCallback(async s=>{const n=be.current[s];if(n){K(null),I(n);return}const i=R.current+1;R.current=i,_e(!0),K(null);try{const r=await te(s);if(R.current!==i)return;I(r.messages)}catch(r){if(R.current!==i)return;console.error("Failed to load selected session:",r),K(t("pagesUi.consultantSessions.errLoadSession")),I([])}finally{R.current===i&&_e(!1)}},[te]),ne=a.useCallback(async s=>{const n=s.filter(o=>!Q.current.has(o.id));if(n.length===0)return;n.forEach(o=>{Q.current.add(o.id)});const i=await Promise.allSettled(n.map(o=>L.getSession(o.id))),r={};i.forEach((o,u)=>{if(o.status!=="fulfilled")return;const m=n[u];r[m.id]=fe(o.value.data.messages)}),Object.keys(r).length>0&&ue(o=>({...o,...r}))},[]),ae=a.useCallback(async(s,n)=>{n==="initial"?(ye(!0),ke(null)):ve(!0);try{const i=await L.listSessions(ie(),me,s,{scope:"main"}),r=oe(i.data||[]);return r.forEach(o=>{Y.current.add(o.id)}),J(o=>n==="initial"?r:oe([...o,...r])),Fe(s+r.length),Je(r.length===me),ne(r),r}catch(i){return console.error("Failed to load sessions page:",i),ke(t("pagesUi.consultantSessions.errLoadSessions")),[]}finally{n==="initial"?ye(!1):ve(!1)}},[ne]);a.useEffect(()=>{var i;if(B.current)return;let s=!1;if(A.current.length>0){B.current=!0;const r=G.current||((i=A.current[0])==null?void 0:i.id)||null;return T(u=>u??r),(async()=>{try{const u=await L.listSessions(ie(),me,0,{scope:"main"});if(s)return;const m=oe(u.data||[]);m.forEach(b=>{Y.current.add(b.id)}),J(b=>{const j=new Map(b.map(N=>[N.id,N])),k=new Set(m.map(N=>N.id));return[...m.map(N=>({...j.get(N.id),...N})),...b.filter(N=>!k.has(N.id))]}),ne(m)}catch{}})(),()=>{s=!0}}return(async()=>{var u,m;const r=await ae(0,"initial");if(s)return;let o=p.current;if(p.current&&!r.some(b=>b.id===p.current))try{await U(p.current)}catch(b){console.warn(`Requested session ${p.current} is unavailable:`,b),F(p.current),o=null}if(!o){const b=bs(f.recentSessions),j=((u=b[0])==null?void 0:u.id)||null;if(j)try{await U(j),o=j}catch(k){console.warn(`Recent session ${j} is unavailable:`,k),F(j)}if(!o){const k=b.find(N=>r.some(ds=>ds.id===N.id));o=(k==null?void 0:k.id)||((m=r[0])==null?void 0:m.id)||null}}B.current=!0,T(o)})(),()=>{s=!0}},[U,ae,ne,F,f.recentSessions]),a.useEffect(()=>{if(!B.current||!l||l===G.current)return;let s=!1;return(async()=>{try{await U(l),s||T(l)}catch(i){console.warn(`Requested session ${l} is unavailable:`,i),F(l)}})(),()=>{s=!0}},[U,F,l]),a.useEffect(()=>{if(!h){R.current+=1,I([]),K(null);return}Ae(h)},[Ae,h]);const _=a.useMemo(()=>{const s=P.trim().toLowerCase();return s?w.filter(n=>{const i=E[n.id];return[le(n,i),i==null?void 0:i.firstUserSnippet,i==null?void 0:i.lastMessageSnippet,de(n.updated_at||n.created_at),n.id].filter(
1Boolean).join(" ").toLowerCase().includes(s)}):w},[P,E,w]),g=a.useMemo(()=>w.find(s=>s.id===h)||null,[h,w]),Ze=g?E[g.id]:void 0,Xe=g?le(g,Ze):t("pagesUi.consultantSessions.noSessionSelected"),es=_.length>5,Te=a.useCallback(s=>{const n=new URLSearchParams(d.search),i=n.get("session");if(s){if(i===s)return;n.set("session",s)}else if(i)n.delete("session");else return;const r=n.toString();c(`${d.pathname}${r?`?${r}`:""}`,{replace:!0})},[d.pathname,d.search,c]),Ie=a.useCallback(s=>{const n=_,i=n.findIndex(r=>r.id===s);if(i===-1)return null;for(let r=i+1;r<n.length;r+=1)if(n[r].id!==s)return n[r].id;for(let r=i-1;r>=0;r-=1)if(n[r].id!==s)return n[r].id;return null},[_]),V=a.useCallback(s=>{var r;const n=Ie(s);if(Y.current.has(s)&&(Y.current.delete(s),Fe(o=>Math.max(0,o-1))),Q.current.delete(s),J(o=>o.filter(u=>u.id!==s)),ue(o=>{const u={...o};return delete u[s],u}),Se(o=>{const u={...o};return delete u[s],u}),H(o=>{if(!o.has(s))return o;const u=new Set(o);return u.delete(s),u}),pe(o=>{if(!o.has(s))return o;const u=new Set(o);return u.delete(s),u}),Pe(f.recentSessions,s),G.current===s){const o=n||((r=A.current.find(u=>u.id!==s))==null?void 0:r.id)||null;T(o),I([])}},[Ie,f.recentSessions]);a.useEffect(()=>{Te(h)},[h,Te]);const ss=a.useCallback(async s=>{ge(null),Le(s);try{await U(s),c(`/consultant?session=${encodeURIComponent(s)}`)}catch(n){console.error("Failed to resume session in workspace:",n),F(s),ge(t("pagesUi.consultantSessions.errResume"))}finally{Le(null)}},[U,c,F]),ts=a.useCallback(async s=>{try{M(null),await U(s),T(s)}catch(n){console.error("Failed to select session:",n),F(s),K(t("pagesUi.consultantSessions.errOpen"))}},[U,F]),ns=a.useCallback(async s=>{je(s),O(null),M(null);try{await L.deleteSession(s),V(s)}catch(n){console.error("Failed to delete session:",n);const i=He(n);i.shouldRemoveLocally&&V(s),M(i.message)}finally{je(null)}},[V]),as=a.useCallback(s=>{M(null),O(n=>n===s?null:s)},[]),W=a.useCallback(()=>{Ne(!1),H(new Set),D(!1),ee(null),pe(new Set)},[]),is=a.useCallback(()=>{if(S){W();return}O(null),M(null),Ne(!0)},[W,S]),rs=a.useCallback(s=>{D(!1),H(n=>{const i=new Set(n);return i.has(s)?i.delete(s):i.add(s),i})},[]),os=a.useCallback(()=>{D(!1),H(new Set(_.map(s=>s.id)))},[_]),ls=a.useCallback(async()=>{const s=Array.from(C);if(!(s.length===0||v)){we(!0),ee(null);try{const n=[];for(let i=0;i<s.length;i+=50){const r=s.slice(i,i+50),o=await L.bulkDeleteSessions(r);for(const u of o.results)u.outcome==="deleted"||u.outcome==="already_deleted"||u.outcome==="not_found"?V(u.session_id):n.push({id:u.session_id,detail:u.detail})}n.length>0?(H(new Set(n.map(i=>i.id))),pe(new Set(n.map(i=>i.id))),ee(n.length>1?t("pagesUi.consultantSessions.bulkFailedMany",{count:n.length}):t("pagesUi.consultantSessions.bulkFailedOne",{count:n.length}))):W()}catch(n){console.error("Failed to bulk delete sessions:",n),ee(He(n).message)}finally{we(!1),D(!1)}}},[W,V,v,C]),cs=a.useCallback(async()=>{!q||X||await ae(se,"more")},[q,X,ae,se]);return e.jsx("div",{className:"min-h-[70vh] bg-[#F7F3EE] page-transition-wrapper animate-fade",children:e.jsxs("div",{className:"mx-auto max-w-[1440px] px-4 pb-8 pt-4 sm:px-6 lg:px-8",children:[e.jsxs(ps,{to:"/consultant",className:"mb-4 inline-flex items-center gap-2 rounded-lg border border-slate-200 bg-white px-3 py-2 text-sm font-semibold text-slate-700 shadow-sm transition hover:-translate-y-0.5 hover:border-slate-300 hover:text-[#16335F]",children:[e.jsx(ws,{size:16}),t("pagesUi.consultantSessions.backToWorkspace")]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-[390px_minmax(0,1fr)] lg:items-start",children:[e.jsx("aside",{className:"h-fit self-start rounded-[28px] border border-[#D8DDE6] bg-[linear-gradient(180deg,#FFFDF8_0%,#F6F1E8_100%)] p-3 shadow-[0_24px_70px_rgba(11,58,110,0.08)] lg:sticky lg:top-[88px] sm:p-4",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"rounded-[22px] border border-[#D6DEE9] bg-[radial-gradient(circle_at_top_left,_rgba(217,228,244,0.95),_rgba(255,255,255,0.94)_58%,_rgba(247,243,238,0.98)_100%)] px-4 py-4 shadow-[0_10px_30px_rgba(15,23,42,0.05)]",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("h1",{className:"m-0 text-[22px] font-semibold leading-tight tracking-tight text-[#0B1525]",children:t("pagesUi.consultantSessions.sessionLibrary")}),e.jsx("span",{className:"rounded-md bg-[#16335F]/[0.07] px-2 py-0.5 text-xs font-medium text-slate-600",children:t("pagesUi.consultantSessions.sessionsCount",{count:_.length})})]}),e.jsxs("div",{className:"relative mt-3",children:[e.jsx(Cs,{size:16,className:"pointer-events-none absolute left-4 top-1/2 -translate-y-1/2 text-slate-400"}),e.jsx("input",{value:P,onChange:s=>Ve(s.target.value),placeholder:t("pagesUi.consultantSessions.searchPlaceholder"),className:"h-11 w-full rounded-2xl border border-slate-200 bg-white/95 pl-11 pr-4 text-sm text-slate-700 shadow-sm outline-none transition focus:border-[#16335F] focus:ring-2 focus:ring-[#16335F]/10"})]})]}),e.jsxs("div",{className:"overflow-hidden rounded-[22px] border border-slate-200 bg-white shadow-[0_14px_30px_rgba(15,23,42,0.05)]",children:[e.jsx("div",{className:"border-b border-slate-100 px-4 pb-3 pt-3",children:e.jsxs("div",{className:"flex items-end justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[15px] font-semibold tracking-tight text-[#0B1525]",children:t("pagesUi.consultantSessions.counselorHistory")}),e.jsx("div",{className:"text-[11px] text-slate-500",children:t(S?"pagesUi.consultantSessions.historyHintSelect":"pagesUi.consultantSessions.historyHintDefault")})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[_.length>0||S?e.jsx("button",{type:"button",onClick:is,disabled:v,"aria-pressed":S,className:`inline-flex items-center justify-center rounded-full px-3 py-1.5 text-[11px] font-semibold transition-all duration-150 disabled:opacity-60 ${S?"border border-[#0F2848] bg-[linear-gradient(180deg,#1E4478_0%,#16335F_52%,#10284B_100%)] text-white shadow-[inset_0_1px_0_rgba(255,255,255,0.18),0_2px_6px_rgba(22,51,95,0.35),0_1px_2px_rgba(15,23,42,0.12)] hover:-translate-y-
1px hover:border-[#0B2545] hover:shadow-[inset_0_1px_0_rgba(255,255,255,0.22),0_4px_10px_rgba(22,51,95,0.4)] active:translate-y-0 active:shadow-[inset_0_2px_6px_rgba(11,21,37,0.45)]":"border border-[#C8D4E2] bg-[linear-gradient(180deg,#FFFFFF_0%,#EEF2F7_100%)] text-[#526B88] shadow-[inset_0_1px_0_rgba(255,255,255,0.9),0_1px_2px_rgba(15,23,42,0.08),0_2px_5px_rgba(15,23,42,0.04)] hover:-translate-y-px hover:border-[#8CA5C1] hover:text-[#16335F] hover:shadow-[inset_0_1px_0_rgba(255,255,255,0.95),0_3px_8px_rgba(22,51,95,0.12)] active:translate-y-0 active:shadow-[inset_0_2px_4px_rgba(15,23,42,0.08)]"}`,children:t(S?"pagesUi.consultantSessions.done":"pagesUi.consultantSessions.manage")}):null,e.jsx("span",{className:"rounded-full bg-[#F4F6F9] px-2.5 py-1 text-[11px] font-semibold text-slate-500",children:_.length})]})]})}),e.jsx("div",{className:`fx-ambient px-3 pb-3 pt-2.5 ${es?"lg:max-h-[calc(100vh-360px)] lg:overflow-y-auto":"overflow-visible"}`,children:We?e.jsx("div",{className:"flex h-[220px] items-center justify-center",children:e.jsx(_s,{variant:"chat",title:t("pagesUi.consultantSessions.loadingHistoryTitle"),detail:t("pagesUi.consultantSessions.loadingHistoryDetail"),compact:!0,className:"w-full"})}):Ue?e.jsx("div",{className:"rounded-2xl border border-rose-200 bg-rose-50 px-4 py-3 text-sm text-rose-700",children:Ue}):_.length===0?e.jsxs("div",{className:"rounded-3xl border border-dashed border-slate-200 bg-white px-6 py-8 text-center shadow-sm",children:[e.jsx(Fs,{size:28,className:"mx-auto text-slate-300"}),e.jsx("div",{className:"mt-3 text-sm font-semibold text-slate-700",children:P.trim()?t("pagesUi.consultantSessions.emptySearchTitle"):t("pagesUi.consultantSessions.emptyTitle")}),e.jsx("p",{className:"mt-2 text-sm text-slate-500",children:P.trim()?t("pagesUi.consultantSessions.emptySearchBody"):t("pagesUi.consultantSessions.emptyBody")})]}):e.jsxs("div",{className:"space-y-2.5",children:[e.jsx("div",{className:"rounded-[16px] border border-[#DCE6F2] bg-[linear-gradient(180deg,#F8FBFF_0%,#F4F7FB_100%)] px-3 py-2 text-[11px] font-medium leading-5 text-[#526B88] shadow-[inset_0_1px_0_rgba(255,255,255,0.8)]",children:t(S?"pagesUi.consultantSessions.selectBanner":"pagesUi.consultantSessions.switcherBanner")}),_.map(s=>{const n=E[s.id],i=s.id===h,r=C.has(s.id),o=Qe.has(s.id),u=i&&!Rs&&!S,m=(n==null?void 0:n.lastMessageSnippet)||(n==null?void 0:n.firstUserSnippet)||t("pagesUi.consultantSessions.loadingPreview"),b=e.jsxs("button",{type:"button",onClick:()=>S?rs(s.id):void ts(s.id),disabled:v,"aria-pressed":S?r:i,className:`group relative w-full cursor-pointer overflow-hidden rounded-[18px] border px-3.5 py-3 text-left transition duration-200 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#16335F]/25 disabled:cursor-wait disabled:opacity-60 ${o?"border-rose-300 bg-rose-50/70 shadow-[0_4px_10px_rgba(190,18,60,0.08)]":S&&r?"border-[#16335F]/45 bg-[#EEF3FA] shadow-[0_8px_18px_rgba(22,51,95,0.10)]":i?`selected-card-glass ${u?"border-transparent":"border-[#16335F]/45 ring-1 ring-[#16335F]/12"}`:"card-glass-rest border-slate-200/90 shadow-[0_4px_10px_rgba(15,23,42,0.04)] hover:-translate-y-0.5 hover:border-[#8CA5C1] hover:shadow-[0_12px_24px_rgba(22,51,95,0.08)]"}`,children:[S?e.jsx("span",{"aria-hidden":"true",className:`absolute left-2.5 top-1/2 flex h-[16px] w-[16px] -translate-y-1/2 items-center justify-center rounded-[5px] border text-[10px] font-bold text-white transition ${r?"border-[#16335F] bg-[#16335F]":"border-slate-300 bg-white group-hover:border-[#8CA5C1]"}`,children:r?"â":""}):e.jsx("span",{className:`absolute inset-y-3 left-2 w-[3px] rounded-full transition ${i?"bg-[#16335F]":"bg-[#D7E0EB] group-hover:bg-[#8CA5C1]"}`}),e.jsxs("div",{className:S?"pl-6":"pl-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:`line-clamp-2 text-[13px] font-semibold leading-[1.35] tracking-tight transition ${i?"text-[#10284B]":"text-[#0B1525] group-hover:text-[#16335F]"}`,children:le(s,n)}),e.jsxs("div",{className:"mt-1.5 flex flex-wrap items-center gap-1.5 text-[10px] font-medium leading-none text-slate-400",children:[e.jsx("span",{children:t("pagesUi.consultantSessions.messagesCount",{count:s.message_count})}),e.jsx("span",{children:"â¢"}),e.jsx("span",{children:de(s.updated_at||s.created_at)}),o?e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"â¢"}),e.jsx("span",{className:"font-semibold text-rose-600",children:t("pagesUi.consultantSessions.deleteFailed")})]}):null]})]}),e.jsx("span",{className:`shrink-0 rounded-full px-2.5 py-1 text-[10px] font-semibold uppercase tracking-[0.14em] transition ${S?r?"bg-[#16335F] text-white shadow-sm":"border border-[#D9E3EF] bg-white text-[#607792]":i?`bg-[#16335F] text-white shadow-sm ${u?"badge-shimmer"
1:""}`:"bg-white/80 text-[#607792] group-hover:text-[#16335F]"}`,children:t(S?r?"pagesUi.consultantSessions.badgeSelected":"pagesUi.consultantSessions.badgeSelect":i?"pagesUi.consultantSessions.badgeFocused":"pagesUi.consultantSessions.badgeView")})]}),e.jsx("p",{className:"mt-2 line-clamp-2 text-[11px] leading-[1.45] text-slate-500 transition group-hover:text-slate-600",children:m})]})]});return u?e.jsx("div",{className:"metal-ring metal-ring--lg",children:b},s.id):e.jsx(gs.Fragment,{children:b},s.id)}),q?e.jsx("button",{type:"button",onClick:()=>void cs(),disabled:X,className:"flex w-full items-center justify-center gap-2 rounded-[16px] border border-slate-200 bg-white px-4 py-2.5 text-sm font-medium text-slate-600 transition hover:border-slate-300 hover:bg-slate-50 disabled:opacity-60",children:X?e.jsx(js,{label:t("pagesUi.consultantSessions.loadingOlder")}):e.jsxs(e.Fragment,{children:[e.jsx($e,{size:16}),t("pagesUi.consultantSessions.loadOlder")]})}):w.length>0?e.jsx("div",{className:"rounded-[16px] border border-dashed border-slate-200 bg-white px-4 py-2.5 text-center text-[11px] font-medium uppercase tracking-[0.14em] text-slate-400",children:t("pagesUi.consultantSessions.oldestReached")}):null,S?e.jsxs("div",{className:"space-y-2 pt-1",children:[Ce?e.jsx("div",{className:"rounded-xl border border-rose-200 bg-rose-50 px-3 py-2 text-xs text-rose-700",children:Ce}):null,Ge?e.jsxs("div",{className:"rounded-xl border border-rose-200 bg-rose-50 px-3 py-2.5 text-xs text-rose-700",children:[e.jsx("div",{className:"font-semibold",children:C.size>1?t("pagesUi.consultantSessions.bulkConfirmMany",{count:C.size}):t("pagesUi.consultantSessions.bulkConfirmOne",{count:C.size})}),e.jsx("p",{className:"mt-1 text-rose-600",children:t("pagesUi.consultantSessions.bulkConfirmNote")}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>void ls(),disabled:v,className:"inline-flex items-center gap-1.5 rounded-lg bg-rose-600 px-2.5 py-1.5 font-semibold text-white transition hover:bg-rose-700 disabled:opacity-60",children:[v?e.jsx(z,{size:13,className:"animate-spin"}):e.jsx(re,{size:13}),t("pagesUi.consultantSessions.confirmDelete")]}),e.jsx("button",{type:"button",onClick:()=>D(!1),disabled:v,className:"rounded-lg border border-rose-200 bg-white px-2.5 py-1.5 font-semibold text-rose-700 transition hover:bg-rose-100 disabled:opacity-60",children:t("pagesUi.consultantSessions.cancel")})]})]}):null,e.jsxs("div",{className:"flex flex-wrap items-center gap-2 rounded-[16px] bg-[#16335F] px-3 py-2.5 text-[11.5px] font-medium text-white shadow-[0_10px_24px_rgba(22,51,95,0.25)]",children:[e.jsx("button",{type:"button",onClick:os,disabled:v||_.length===0,className:"underline decoration-white/50 underline-offset-2 transition hover:decoration-white disabled:opacity-50",children:t("pagesUi.consultantSessions.selectAllLoaded")}),e.jsx("span",{className:"text-white/80",children:t("pagesUi.consultantSessions.selectedCount",{count:C.size})}),e.jsxs("button",{type:"button",onClick:()=>D(!0),disabled:v||C.size===0,className:"inline-flex items-center gap-1.5 rounded-lg bg-rose-500 px-2.5 py-1.5 font-semibold transition hover:bg-rose-600 disabled:opacity-50",children:[v?e.jsx(z,{size:13,className:"animate-spin"}):e.jsx(re,{size:13}),t("pagesUi.consultantSessions.deleteCount",{count:C.size})]}),e.jsx("button",{type:"button",onClick:W,disabled:v,className:"ml-auto text-white/75 transition hover:text-white disabled:opacity-50",children:t("pagesUi.consultantSessions.cancel")})]})]}):null]})})]})]})}),e.jsxs("div",{className:"overflow-hidden rounded-[28px] border border-[#D8DDE6] bg-white shadow-[0_24px_70px_rgba(11,58,110,0.08)]",children:[e.jsx("div",{className:"border-b border-slate-200/80 bg-[linear-gradient(180deg,#FFFFFF_0%,#FBF8F3_100%)] px-6 py-5 sm:px-7",children:e.jsxs("div",{className:"flex flex-col gap-4 lg:flex-row lg:items-start lg:justify-between",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-[0.2em] text-slate-400",children:t("pagesUi.consultantSessions.focusedPreview")}),e.jsx("h2",{className:"mt-2 line-clamp-2 text-[28px] font-semibold leading-tight tracking-tight text-[#0B1525]",children:Xe}),e.jsx("div",{className:"mt-3 flex flex-wrap items-center gap-3 text-xs text-slate-500",children:g?e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full bg-slate-100 px-3 py-1",children:[e.jsx(Us,{size:12}),de(g.updated_at||g.created_at)]}),e.jsx("span",{className:"rounded-full bg-slate-100 px-3 py-1",children:t("pagesUi.consultantSessions.totalMessages",{count:g.message_count})})]}):e.jsx("span",{className:"rounded-full bg-slate-100 px-3 py-1",children:t("pagesUi.consultantSessions.selectFromRail")})})]}),g?e.jsx("div",{className:"flex flex-wrap items-center gap-2 lg:justify-end",children:e.jsx("button",{type:"button",onClick:()=>void ss(g.id),disabled:!!Me,className:"inline-flex items-center gap-2 rounded-xl bg-[#16335F] px-4 py-3 text-sm font-semibold text-white transition hover:bg-[#0B1525] disabled:opacity-60",children:Me===g.
1id?e.jsxs(e.Fragment,{children:[e.jsx(z,{size:15,className:"animate-spin"}),t("pagesUi.consultantSessions.opening")]}):e.jsxs(e.Fragment,{children:[t("pagesUi.consultantSessions.resumeInCounselor"),e.jsx(ks,{size:15})]})})}):null]})}),e.jsx("div",{className:"bg-[#FCFBF8] p-4 sm:p-5 lg:p-6",children:e.jsxs("div",{className:"min-h-[520px] overflow-hidden rounded-[24px] border border-slate-200 bg-white shadow-[0_18px_40px_rgba(15,23,42,0.04)]",children:[e.jsxs("div",{className:"border-b border-slate-100 px-5 py-4",children:[e.jsxs("div",{className:"flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-semibold text-[#0B1525]",children:t("pagesUi.consultantSessions.sessionTranscript")}),e.jsx("div",{className:"mt-1 text-xs text-slate-500",children:t("pagesUi.consultantSessions.transcriptSubhead")}),De&&g?e.jsx("div",{className:"mt-3 rounded-xl border border-rose-200 bg-rose-50 px-3 py-2 text-xs text-rose-700",children:De}):null]}),g?e.jsx("div",{className:"flex flex-wrap items-center gap-2 lg:justify-end",children:xe===g.id?e.jsxs("div",{className:"flex flex-wrap items-center gap-2 rounded-xl border border-rose-200 bg-rose-50 px-3 py-2 text-xs text-rose-700",children:[e.jsx("span",{className:"font-semibold",children:t("pagesUi.consultantSessions.deletePermanentQ")}),e.jsxs("button",{type:"button",onClick:()=>void ns(g.id),disabled:$===g.id,className:"inline-flex items-center gap-1.5 rounded-lg bg-rose-600 px-2.5 py-1.5 font-semibold text-white transition hover:bg-rose-700 disabled:opacity-60",children:[$===g.id?e.jsx(z,{size:13,className:"animate-spin"}):e.jsx(re,{size:13}),t("pagesUi.consultantSessions.confirmDelete")]}),e.jsx("button",{type:"button",onClick:()=>O(null),disabled:$===g.id,className:"rounded-lg border border-rose-200 bg-white px-2.5 py-1.5 font-semibold text-rose-700 transition hover:bg-rose-100 disabled:opacity-60",children:t("pagesUi.consultantSessions.cancel")})]}):e.jsxs("button",{type:"button",onClick:()=>as(g.id),disabled:$===g.id,className:"inline-flex items-center gap-2 rounded-xl border border-rose-200 bg-rose-50/80 px-3 py-2 text-xs font-semibold text-rose-600 transition hover:bg-rose-100 hover:border-rose-300 disabled:opacity-60",children:[$===g.id?e.jsx(z,{size:13,className:"animate-spin"}):e.jsx(re,{size:13}),t("pagesUi.consultantSessions.deleteSession")]})}):null]}),Ee?e.jsx("div",{className:"mt-3 rounded-xl border border-rose-200 bg-rose-50 px-3 py-2 text-xs text-rose-700",children:Ee}):null]}),e.jsx("div",{className:"max-h-[70vh] overflow-y-auto px-5 py-5 lg:max-h-[calc(100vh-180px)] lg:min-h-[calc(100vh-180px)]",children:h?Ye?e.jsxs("div",{className:"flex h-full min-h-[360px] flex-col items-center justify-center gap-3 px-4",children:[e.jsx(z,{size:28,className:"animate-spin text-[#16335F]"}),e.jsx("div",{className:"text-sm font-medium text-slate-500",children:t("pagesUi.consultantSessions.loadingConversation")})]}):Re?e.jsx("div",{className:"rounded-2xl border border-rose-200 bg-rose-50 px-4 py-3 text-sm text-rose-700",children:Re}):e.jsx(ys,{messages:Ke,className:"space-y-4"}):e.jsxs("div",{className:"flex h-full min-h-[360px] flex-col items-center justify-center text-center",children:[e.jsx($e,{size:30,className:"text-slate-300"}),e.jsx("div",{className:"mt-4 text-base font-semibold text-slate-700",children:t("pagesUi.consultantSessions.chooseToInspect")}),e.jsx("p",{className:"mt-2 max-w-md text-sm leading-6 text-slate-500",children:t("pagesUi.consultantSessions.chooseToInspectBody")})]})})]})})]})]})]})})};export{qs 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.