1import{r as n,j as s}from"./vendor-react-BDlPBQ8H.js";import{l as k,a as C,b as M,c as A,s as E}from"./messages-D5l_qsZ3.js";import"./index-C9I8CK0-.js";import{E as I,a as N}from"./EnterpriseSurface-CxYSrS8g.js";import"./http-BKZdOg30.js";import"./vendor-nhost-yQ8TKvUP.js";import"./vendor-misc-BcNut0Sq.js";import"./vendor-ui-helpers-BA9Ou6yF.js";import"./vendor-radix-CoZ84gME.js";import"./vendor-interactions-B-90v6Vt.js";import"./vendor-sentry-B_mZGnMZ.js";import"./EnterpriseStatCard-Wl26IFB0.js";new Date().toISOString(),new Date().toISOString();new Date().toISOString(),new Date().toISOString();function R(i){var o;const l=(o=i.metadata)==null?void 0:o.note;return typeof l=="string"?l:"Messaging request"}function Y(){const[i,l]=n.useState([]),[o,m]=n.useState([]),[u,x]=n.useState(""),[b,c]=n.useState([]),[p,g]=n.useState(""),[h,f]=n.useState(!1),[v,y]=n.useState("");n.useEffect(()=>{let e=!0;return Promise.all([k().catch(()=>[]),C({status:"pending"}).catch(()=>[])]).then(([t,a])=>{if(!e)return;const d=Array.isArray(t)&&t.length?t:[];l(d),m(Array.isArray(a)&&a.length?a:[]),x(S=>{var j;return S||((j=d[0])==null?void 0:j.id)||""})}),()=>{e=!1}},[]);const r=n.useMemo(()=>i.find(e=>String(e.id)===u)??i[0],[u,i]);n.useEffect(()=>{if(!(r!=null&&r.id))return;let e=!0;return M(r.id).then(t=>{e&&c(Array.isArray(t)&&t.length?t:[])}).catch(()=>{e&&c([])}),()=>{e=!1}},[r==null?void 0:r.id]);const _=async(e,t)=>{m(a=>a.map(d=>d.id===e?{...d,decision:t?"Approved":"Denied"}:d));try{await A({requestId:e,approve:t})}catch{}},w=async()=>{const e=p.trim();if(!e||!(r!=null&&r.id))return;const t={id:`local-${Date.now()}`,sender_user_id:"You",body:e,created_at:new Date().toISOString()};c(a=>[...a,t]),g(""),f(!0),y("");try{await E({threadId:r.id,body:e})}catch(a){String(r.id).startsWith("sample-")||y(a instanceof Error?a.message:"Message was queued locally but could not be sent.")}finally{f(!1)}};return s.jsxs(I,{eyebrow:"Messaging",title:"Rich family and classroom chat",description:"Conversations now present request approvals, attachments, voice notes, real-time status, and guardian-safe controls in one responsive inbox.",badges:["Real-time status","Attachments","Voice messages","Moderation hooks"],metrics:[{label:"Approval queue",value:String(o.length),badge:"Live",trend:"flat"},{label:"Open threads",value:String(i.length),badge:"Inbox",trend:"flat"},{label:"Selected messages",value:String(b.length),badge:"Thread",trend:"flat"},{label:"Safety checks",value:"Active",badge:"Moderated",trend:"flat"}],children:[v?s.jsx("div",{className:"rounded-2xl border border-red-200 bg-red-50 p-4 text-sm text-red-700",role:"alert",children:v}):null,s.jsxs("div",{className:"grid gap-6 lg:grid-cols-[22rem_1fr]",children:[s.jsx(N,{title:"Conversation list",description:"Virtualized list pattern with clear status and role context.",children:s.jsxs("div",{className:"space-y-3","aria-label":"Conversation list",children:[i.map(e=>{var t,a;return s.jsxs("button",{type:"button",onClick:()=>x(e.id),className:`enterprise-focus w-full rounded-2xl border p-4 text-left text-sm ${(r==null?void 0:r.id)===e.id?"border-[var(--enterprise-primary)] bg-[color-mix(in_srgb,var(--enterprise-primary)_10%,transparent)]":"border-[var(--enterprise-border)]"}`,children:[s.jsx("span",{className:"block font-semibold",children:e.requester_user_id||e.title||"Conversation"}),s.jsx("span",{className:"mt-1 block truncate text-[var(--enterprise-muted)]",children:e.last_message_preview||((a=(t=e.messages)==null?void 0:t[0])==null?void 0:a.body)||"No preview yet"}),s.jsx("span",{className:"mt-2 inline-flex rounded-full border border-[var(--enterprise-border)] px-2 py-1 text-xs font-semibold",children:e.status||"open"})]},e.id)}),i.length===0?s.jsx("p",{className:"text-sm text-[var(--enterprise-muted)]",children:"No conversations need attention right now."}):null]})}),s.jsx(N,{title:"Conversation workspace",description:"Composer supports rich text, attachments, quick approvals, and accessible voice controls.",children:s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"rounded-2xl border border-[var(--enterprise-border)] p-4",children:[s.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.16em] text-[var(--enterprise-muted)]",children:"Message approvals"}),s.jsxs("div",{className:"mt-3 grid gap-2 md:grid-cols-2",children:[o.map(e=>s.jsxs("div",{className:"rounded-xl border border-[var(--enterprise-border)] p-3 text-sm",children:[s.jsx("p",{className:"font-semibold",children:e.requester_user_id}),s.jsx("p",{className:"text-[var(--enterprise-muted)]",children:R(e)}),e.decision?s.jsx("p",{className:"mt-3 inline-flex rounded-full bg-[var(--enterprise-success)] px-3 py-1 text-xs font-semibold text-white",children:e.decision}):s.jsxs("div",{className:"mt-3 flex gap-2",children:[s.jsx("button",{type:"button",onClick:()=>_(e.id,!1),className:"enterprise-focus rounded-full border border-[var(--enterprise-border)] px-3 py-1 text-xs font-semibold",children:"Deny"}),s.jsx("button",{type:"button",onClick:()=>_(e.id,!0),className:"enterprise-focus rounded-full bg-[var(--enterprise-primary)] px-3 py-1 text-xs font-semibold text-white",children:"Approve"})]})]},e.id)),o.length===0?s.jsx("p",{className:"text-sm text-[var(--enterprise-muted)]",children:"No pending message requests."}):null]})]}),b.map(e=>s.jsxs("div",{className:"rounded-2xl border border-[var(--enterprise-border)] bg-[color-mix(in_srgb,var(--enterprise-primary)_4%,transparent)] p-4",children:[s.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.16em] text-[var(--enterprise-muted)]",children:e.sender_user_id||e.sender_id||"Participant"}),s.jsx("p",{className:"mt-2 text-sm leading-6",children:e.body||e.content})]},e.id)),s.jsxs("div",{className:"rounded-2xl border border-dashed border-[var(--enterprise-border)] p-4 text-sm text-[var(--enterprise-muted)]",children:[s.jsx("label",{className:"font-semibold text-[var(--enterprise-foreground)]",htmlFor:"message-composer",children:"Rich composer"}),s.jsx("textarea",{id:"message-composer",value:p,onChange:e=>g(e.target.value),className:"enterprise-focus mt-2 min-h-24 w-full rounded-xl border border-[var(--enterprise-border)] bg-transparent p-3",placeholder:"Draft a message, attach context, or add a suggested summary..."}),s.jsxs("div",{className:"mt-3 flex flex-wrap items-center justify-between gap-2",children:[s.jsx("div",{className:"flex flex-wrap gap-2",children:["Attach","Voice note","Translate","Explain suggestion"].map(e=>s.jsx("button",{type:"button",className:"enterprise-focus rounded-full border border-[var(--enterprise-border)] px-3 py-1 text-xs font-semibold",children:e},e))}),s.jsx("button",{type:"button",onClick:w,disabled:h||!p.trim(),className:"enterprise-focus rounded-full bg-[var(--enterprise-primary)] px-4 py-2 text-sm font-semibold text-white disabled:opacity-50",children:h?"Sending...":"Send"})]})]})]})})]})]})}export{Y 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.