PageSourceSearch

https://cdgapp.ai/assets/CirclesDigestPage-Cbh5UkHm.js

js cdgapp.ai collected 2026-10-05 11:54:58 UTC 43,979 bytes, 1 lines download raw bytes

1import{b as Q,a as C,e as oe,f as me,r as g,j as e,L as I,Q as xe,J as he,m as ue}from"./index-CE-Uxqu-.js";import{T as pe,a as be,b as R,c as M}from"./tabs-659OCpmW.js";import{L as ge}from"./lock-keyhole-DNeC5Q8i.js";import"./index-EpGR1ZwK.js";import"./index-CuqWmXM7.js";const je="https://nsfrxtpxzdmqlezvvjgg.supabase.co/functions/v1/admin-circles-digest";function fe({search:s,memberId:t}){const{fetchWithAuth:n,isAdmin:r,user:i}=Q(),l=async(a,x)=>{if(!r)throw new Error("Admin access is required.");const u=await n(`${je}?${a.toString()}`,{method:"GET",signal:x}),c=await u.json().catch(()=>null);if(!u.ok)throw new Error(typeof(c==null?void 0:c.error)=="string"?c.error:`Unable to load Circles digest (HTTP ${u.status}).`);if(!c||typeof c.health!="object"||c.health===null||!Array.isArray(c.members))throw new Error("The Circles digest service returned an invalid response.");return c},d=C({queryKey:["admin-circles-digest",i==null?void 0:i.id,"members",s.trim()],enabled:r,queryFn:({signal:a})=>l(new URLSearchParams({search:s.trim()}),a),staleTime:3e4,retry:!1,refetchOnWindowFocus:!1}),o=C({queryKey:["admin-circles-digest",i==null?void 0:i.id,"preview",t],enabled:r&&!!t,queryFn:async({signal:a})=>{var u;if(!t)throw new Error("Select a member to inspect their digest.");const x=await l(new URLSearchParams({member_id:t}),a);if(x.preview&&((u=x.preview.member)==null?void 0:u.id)!==t)throw new Error("The preview does not match the selected member. Please reload it.");return x},staleTime:3e4,retry:!1,refetchOnWindowFocus:!1});return{indexQuery:d,previewQuery:o,isAdmin:r}}const Ne="https://nsfrxtpxzdmqlezvvjgg.supabase.co/functions/v1/admin-circles-digest",ve="https://nsfrxtpxzdmqlezvvjgg.supabase.co/functions/v1/circles-digest-send",T="admin-circles-digest-send";async function le(s){const t=await s.json().catch(()=>null);if(!s.ok)throw new Error(typeof(t==null?void 0:t.error)=="string"?t.error:`Request failed (HTTP ${s.status}).`);return t}function E(){const{fetchWithAuth:s,isAdmin:t,user:n}=Q();return{read:async(i,l)=>le(await s(`${Ne}?${new URLSearchParams(i)}`,{method:"GET",signal:l})),isAdmin:t,userId:n==null?void 0:n.id}}function ce(){const{read:s,isAdmin:t,userId:n}=E();return C({queryKey:[T,n,"state"],enabled:t,queryFn:async({signal:r})=>(await s({view:"send"},r)).state,refetchInterval:3e4,retry:!1})}function ye(s){const{read:t,isAdmin:n,userId:r}=E();return C({queryKey:[T,r,"reports",s],enabled:n,queryFn:async({signal:i})=>await t({view:"reports",weeks:String(s)},i),staleTime:6e4,retry:!1})}function we(s){const{read:t,isAdmin:n,userId:r}=E();return C({queryKey:[T,r,"history",s],enabled:n&&!!s,queryFn:async({signal:i})=>(await t({view:"member_history",member_id:s},i)).history,retry:!1})}function _e(s){const{read:t,isAdmin:n,userId:r}=E();return C({queryKey:[T,r,"recipient",s],enabled:n&&!!s,queryFn:async({signal:i})=>(await t({view:"recipient",recipient_id:s},i)).recipient,retry:!1})}function Y(){const{fetchWithAuth:s}=Q(),t=oe();return me({mutationFn:async n=>le(await s(ve,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})),onSuccess:()=>t.invalidateQueries({queryKey:[T]})})}const de=30;function v(s,t=1){return s==null||!Number.isFinite(s)?"—":`${(s*100).toFixed(t)}%`}function te(s,t){return s==null||t==null?null:(s-t)*100}function O(s){return s==null||!Number.isFinite(s)?"—":`${s>=0?"+":"−"}${Math.abs(s).toFixed(1)} pts`}function ze(s,t){return Math.min(s,t)<de}function U(s){return s?new Date(s).toLocaleString("en-US",{timeZone:"America/New_York",weekday:"short",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})+" ET":"—"}function ke(s,t=Date.now()){const n=Math.floor((Date.parse(s)-t)/6e4);if(n<=0)return"due now";const r=Math.floor(n/1440),i=Math.floor(n%1440/60);return r>0?`in ${r}d ${i}h`:`in ${i}h ${n%60}m`}function ae(s){return Object.entries(s??{}).sort((t,n)=>n[1]-t[1])}function ne(s){return{send_dow:String(s.send_dow),send_hour_et:String(s.send_hour_et),draft_lead_hours:String(s.draft_lead_hours),holdout_pct:String(s.holdout_pct),sunset_after_sends:String(s.sunset_after_sends),from_address:s.from_address,reply_to:s.reply_to,postal_address:s.postal_address??"",subject_variants:[...s.subject_variants]}}function Se(s,t){const n={},r=["send_dow","send_hour_et","draft_lead_hours","holdout_pct","sunset_after_sends"];for(const d of r){const o=Number(t[d]);o!==s[d]&&(n[d]=o)}t.from_address.trim()!==s.from_address&&(n.from_address=t.from_address.trim()),t.reply_to.trim()!==s.reply_to&&(n.reply_to=t.reply_to.trim());const i=t.postal_address.trim()||null;i!==s.postal_address&&(n.postal_address=i);const l=[...t.subject_variants].sort();return l.join(",")!==[...s.subject_variants].sort().join(",")&&(n.subject_variants=l),n}const b="min-w-0 rounded-xl border border-zinc-800 bg-zinc-900/40",F="inline-flex items-center justify-center gap-2 rounded-md border border-zinc-700 bg-zinc-900 px-3 py-2 text-sm text-zinc-200 hover:bg-zinc-800 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-400 disabled:cursor-not-allowed disabled:opacity-50",G="inline-flex items-center justify-center gap-2 rounded-md bg-amber-400 px-3 py-2 text-sm font-semibold text-zinc-950 hover:bg-amber-300 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-200 disabled:cursor-not-allowed disabled:opacity-50",q="inline-flex items-center justify-center gap-2 rounded-md bg-red-600 px-3 py-2 text-sm font-semibold text-white hover:bg-red-500 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-red-300 disabled:cursor-not-allowed disabled:opacity-50",N="w-full rounded-md border border-zinc-700 bg-zinc-950 px-3 py-2 text-sm text-zinc-100 placeholder:text-zinc-500 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-400",f="block text-xs font-medium text-zinc-400",Ce=["Monday","Tuesday","Wednesday","Thursday","Frid
1ay","Saturday","Sunday"];function $e({settings:s}){const t=Y(),[n,r]=g.useState(()=>ne(s));g.useEffect(()=>r(ne(s)),[s]);const i=Se(s,n),l=Object.keys(i).length>0,d=a=>x=>r(u=>({...u,[a]:x.target.value})),o=a=>r(x=>({...x,subject_variants:x.subject_variants.includes(a)?x.subject_variants.filter(u=>u!==a):[...x.subject_variants,a]}));return e.jsxs("section",{className:`${b} p-4`,"aria-labelledby":"digest-settings-heading",children:[e.jsx("h2",{id:"digest-settings-heading",className:"font-semibold text-zinc-100",children:"Settings"}),e.jsxs("form",{className:"mt-4 grid gap-4 md:grid-cols-2",onSubmit:a=>{a.preventDefault(),l&&t.mutate({action:"settings",patch:i})},children:[e.jsxs("label",{className:f,children:["Send day",e.jsx("select",{className:`${N} mt-1`,value:n.send_dow,onChange:d("send_dow"),children:Ce.map((a,x)=>e.jsx("option",{value:String(x+1),children:a},a))})]}),e.jsxs("label",{className:f,children:["Send hour (Eastern)",e.jsx("select",{className:`${N} mt-1`,value:n.send_hour_et,onChange:d("send_hour_et"),children:Array.from({length:24},(a,x)=>e.jsx("option",{value:String(x),children:`${x%12||12}:00 ${x<12?"AM":"PM"}`},x))})]}),e.jsxs("label",{className:f,children:["Review window (hours before send)",e.jsx("input",{className:`${N} mt-1`,type:"number",min:1,max:144,value:n.draft_lead_hours,onChange:d("draft_lead_hours")})]}),e.jsxs("label",{className:f,children:["Holdout % (new members only)",e.jsx("input",{className:`${N} mt-1`,type:"number",min:0,max:50,value:n.holdout_pct,onChange:d("holdout_pct")})]}),e.jsxs("label",{className:f,children:["Stop after N unengaged digests",e.jsx("input",{className:`${N} mt-1`,type:"number",min:2,max:52,value:n.sunset_after_sends,onChange:d("sunset_after_sends")})]}),e.jsxs("fieldset",{className:f,children:[e.jsx("legend",{children:"Subject variants"}),e.jsx("div",{className:"mt-2 flex gap-4 text-sm text-zinc-200",children:["A","B"].map(a=>e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:n.subject_variants.includes(a),onChange:()=>o(a)}),a==="A"?"A: top thread":"B: count-led"]},a))})]}),e.jsxs("label",{className:f,children:["From",e.jsx("input",{className:`${N} mt-1`,value:n.from_address,onChange:d("from_address")})]}),e.jsxs("label",{className:f,children:["Reply-to",e.jsx("input",{className:`${N} mt-1`,type:"email",value:n.reply_to,onChange:d("reply_to")})]}),e.jsxs("label",{className:`${f} md:col-span-2`,children:["Postal address (required in every email)",e.jsx("textarea",{className:`${N} mt-1`,rows:2,maxLength:300,value:n.postal_address,onChange:d("postal_address")})]}),e.jsxs("div",{className:"flex items-center gap-3 md:col-span-2",children:[e.jsx("button",{type:"submit",className:G,disabled:!l||t.isPending||n.subject_variants.length===0,children:t.isPending?"Saving…":"Save settings"}),t.error&&e.jsx("p",{role:"alert",className:"text-sm text-red-300",children:t.error.message}),t.isSuccess&&!l&&e.jsx("p",{className:"text-sm text-emerald-300",children:"Saved."})]})]})]})}function Te({member:s,settings:t}){const n=Y(),[r,i]=g.useState(""),[l,d]=g.useState("A"),o=n.data;return e.jsxs("section",{className:`${b} p-4`,"aria-labelledby":"digest-test-heading",children:[e.jsx("h2",{id:"digest-test-heading",className:"font-semibold text-zinc-100",children:"Send a test"}),e.jsx("p",{className:"mt-1 text-sm text-zinc-400",children:"Sends the selected member's current digest to any address with a [TEST] subject. Nothing is recorded, and test links never count as clicks or unsubscribes."}),s?e.jsxs("form",{className:"mt-4 flex flex-wrap items-end gap-3",onSubmit:a=>{a.preventDefault(),n.mutate({action:"test",member_id:s.id,to:r.trim(),variant:l})},children:[e.jsxs("p",{className:"w-full text-sm text-zinc-200",children:["Member: ",s.name||s.email||s.id]}),e.jsxs("label",{className:`${f} min-w-[240px] flex-1`,children:["Send to",e.jsx("input",{className:`${N} mt-1`,type:"email",required:!0,value:r,onChange:a=>i(a.target.value),placeholder:"[email protected]"})]}),e.jsxs("label",{className:f,children:["Subject variant",e.jsxs("select",{className:`${N}
1 mt-1`,value:l,onChange:a=>d(a.target.value),children:[e.jsx("option",{value:"A",children:"A"}),e.jsx("option",{value:"B",children:"B"})]})]}),e.jsx("button",{type:"submit",className:G,disabled:n.isPending||!r.trim(),children:n.isPending?"Sending…":"Send test"})]}):e.jsx("p",{className:"mt-4 text-sm text-zinc-400",children:"Select a member in the Preview tab first."}),!t.postal_address&&e.jsx("p",{className:"mt-3 text-xs text-amber-300",children:"Postal address is not set; the test shows a placeholder."}),n.error&&e.jsx("p",{role:"alert",className:"mt-3 text-sm text-red-300",children:n.error.message}),o&&e.jsxs("p",{className:"mt-3 text-sm text-emerald-300",children:["Sent “",o.subject,"” with ",o.item_count," item",o.item_count===1?"":"s",o.blockers.length?`. Real send would skip this member: ${o.blockers.join(", ")}`:"."]})]})}const Le={drafting:"bg-sky-950 text-sky-200",scheduled:"bg-amber-950 text-amber-200",sending:"bg-amber-900 text-amber-100",sent:"bg-emerald-950 text-emerald-200",paused:"bg-orange-950 text-orange-200",cancelled:"bg-zinc-800 text-zinc-300",failed:"bg-red-950 text-red-200",expired:"bg-zinc-800 text-zinc-400"},Pe=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"];function z({label:s,value:t}){return e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-zinc-400",children:s}),e.jsx("dd",{className:"mt-1 text-lg font-semibold text-zinc-100",children:t??0})]})}function Ae({member:s}){var _,k,L,P;const t=ce(),n=Y(),[r,i]=g.useState(!1),[l,d]=g.useState(null),o=_e(l);if(t.isLoading)return e.jsx("div",{className:b,children:e.jsxs("p",{className:"flex items-center gap-2 p-4 text-sm text-zinc-400",children:[e.jsx(I,{"aria-hidden":"true",className:"h-4 w-4 animate-spin"}),"Loading send state…"]})});if(t.error||!t.data)return e.jsx("div",{className:b,children:e.jsx("p",{role:"alert",className:"p-4 text-sm text-red-300",children:((_=t.error)==null?void 0:_.message)??"Send state is unavailable."})});const{settings:a,current:x,samples:u}=t.data,c=(x==null?void 0:x.send)??null,h=(c==null?void 0:c.live_counts)??{},y=p=>n.mutate(p);return e.jsxs("div",{className:"space-y-6",children:[e.jsx("section",{className:`${b} p-4`,"aria-labelledby":"digest-enabled-heading",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsxs("h2",{id:"digest-enabled-heading",className:"font-semibold text-zinc-100",children:["Member sending is ",a.enabled?e.jsx("span",{className:"text-emerald-300",children:"ON"}):e.jsx("span",{className:"text-zinc-300",children:"OFF"})]}),e.jsx("p",{className:"mt-1 text-sm text-zinc-400",children:a.enabled?"Each week's digest sends automatically at its scheduled time unless you cancel it.":"Drafts are still built each week for review, but nothing is sent."}),!a.postal_address&&e.jsx("p",{className:"mt-2 text-sm text-red-300",children:"Postal address is missing. Drafts fail until it is set (CAN-SPAM)."})]}),r?e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("button",{type:"button",className:a.enabled?q:G,disabled:n.isPending,onClick:()=>{y({action:"settings",patch:{enabled:!a.enabled}}),i(!1)},children:a.enabled?"Confirm: stop all sending":"Confirm: start sending to members"}),e.jsx("button",{type:"button",className:F,onClick:()=>i(!1),children:"Keep as is"})]}):e.jsx("button",{type:"button",className:a.enabled?q:F,onClick:()=>i(!0),children:a.enabled?"Turn sending off":"Turn sending on"})]})}),e.jsxs("section",{className:`${b} p-4`,"aria-labelledby":"digest-week-heading",children:[c?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("h2",{id:"digest-week-heading",className:"font-semibold text-zinc-100",children:["Week of ",c.week," ",e.jsx("span",{className:`ml-2 rounded px-2 py-0.5 text-xs font-medium ${Le[c.status]}`,children:c.status})]}),e.jsxs("p",{className:"mt-1 text-sm text-zinc-400",children:["Scheduled ",U(c.scheduled_for),c.status==="scheduled"&&` (${ke(c.scheduled_for)})`,c.status==="scheduled"&&!a.enabled&&". Sending is off, so this will not go out"]}),c.error&&e.jsxs("p",{className:"mt-1 text-sm text-red-300",children:["Error: ",c.error]}),c.paused_reason&&e.jsxs("p",{className:"mt-1 text-sm text-orange-300",children:["Paused: ",c.paused_reason]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[(c.status==="scheduled"||c.status==="paused")&&e.jsx("button",{type:"button",className:q,disabled:n.isPending,onClick:()=>y({action:"cancel",send_id:c.id}),children:"Cancel this week"}),(c.status==="paused"||c.status==="cancelled")&&e.jsx("button",{type:"button",className:F,disabled:n.isPending,onClick:()=>y({action:"resume",send_id:c.id}),children:"Resume"}),c.status==="failed"&&!c.dispatch_started_at&&e.jsx("button",{type:"button",className:F,disabled:n.isPending,onClick:()=>y({action:"retry_draft",send_id:c.id}),children:"Retry draft"})]})]}),e.jsxs("dl",{className:"mt-4 grid grid-cols-2 gap-4 sm:grid-cols-4 lg:grid-cols-8",children:[e.jsx(z,{label:"Will send / sent",value:c.status==="sent"?h.sent:h.drafted}),e.jsx(z,{label:"Engaged",value:(k=h.by_cohort)==null?void 0:k.engaged}),e.jsx(z,{label:"Silent",value:(L=h.by_cohort)==null?void 0:L.silent}),e.jsx(z,{label:"Holdout",value:h.holdout}),e.jsx(z,{label:"Rendering",value:h.pending_render}),e.jsx(z,{label:"Billing unknown",value:h.billing_unknown}),e.jsx(z,{label:"Cancel-scheduled",value:h.cancel_scheduled}),e.jsx(z,{label:"Failed",value:h.failed})]}),(x==null?void 0:x.rates)&&x.rates.sent>0&&e.jsxs("p",{className:"mt-3 text-sm text-zinc-300",children:["Delivered ",h.delivered??0," · bounce ",v(x.rates.bounce_rate,2)," · complaints ",v(x.rates.complaint_rate,2)]}),ae(h.skipped).length>0&&e.jsxs("div",{className:"mt-4",children:[e.jsx("h3",{className:"text-xs font-medium text-zinc-400",children:"Skipped"}),e.jsx("ul",{className:"mt-2 flex flex-wrap gap-2",children:ae(h.skipped).map(([p,A])=>e.jsxs("li",{className:"rounded border border-zinc-700 px-2 py-1 text-xs text-zinc-300",children:[p.replace(/_/g," "),": ",A]},p))})]})]}):e.jsxs("p",{className:"text-sm text-zinc-400",children:["No digest drafted yet. Drafts are built ",a.draft_lead_hours,"h before each ",Pe[a.send_dow-1]," ",a.send_hour_et%12||12,":00 ",a.send_hour_et<12?"AM":"PM"," ET slot."]}),n.error&&e.jsx("p",{role:"alert",className:"mt-3 text-sm text-red-300",children:n.error.message})]}),u.length>0&&e.jsxs("section",{className:`${b} p-4`,"aria-labelledby":"digest-samples-heading",children:[e.jsx("h2",{id:"digest-samples-heading",className:"font-semibold text-zinc-100",children:"Sample drafts"}),e.jsx("ul",{className:"mt-3 space-y-1",children:u.map(p=>e.jsx("li",{children:e.jsxs("button",{type:"button","aria-pressed":l===p.recipient_id,onClick:()=>d(p.recipient_id),className:"w-full rounded-md px-2 py-1.5 text-left text-sm text-zinc-200 hover:bg-zinc-800 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-400",children:[e.jsxs("span",{className:"text-zinc-400",children:[p.cohort," · ",p.variant??"A"," · "]}),p.member_name??"Unnamed",": ",p.subject]})},p.recipient_id))}),l&&(o.isLoading?e.jsx("p",{className:"mt-3 text-sm text-zinc-400",children:"Loading draft…"}):(P=o.data)!=null&&P.html?e.jsx("iframe",{title:"Draft email",sandbox:"",srcDoc:o.data.html,className:"mt-3 h-[720px] w-full rounded bg-white"}):e.jsx("p",{className:"mt-3 text-sm text-zinc-400",children:"Draft body unavailable (pruned or not rendered)."}))]}),e.jsx(Te,{member:s,settings:a}),e.jsx($e,{settings:a})]})}const Fe="px-3 py-2 text-left text-xs font-medium text-zinc-400",m="px-3 py-2 text-sm text-zinc-200";function S({head:s,children:t}){return e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"min-w-full divide-y divide-zinc-800",children:[e.jsx("thead",{children:e.jsx("tr",{children:s.map(n=>e.jsx("th",{className:Fe,children:n},n))})}),e.jsx("tbody",{className:"divide-y divide-zinc-800",children:t})]})})}function ie({rows:s}){return e.jsx(e.Fragment,{children:s.map(t=>{const n=ze(t.treatment_n,t.holdout_n);return e.jsxs("tr",{className:n?"opacity-60":"",children:[e.jsx("td",{className:m,children:t.week??"All weeks"}),e.jsx("td",{className:m,children:t.cohort}),e.jsxs("td",{className:m,children:[t.treatment_n," / ",t.holdout_n]}),e.jsxs("td",{className:m,children:[v(t.treatment_posted_7d)," vs ",v(t.holdout_posted_7d)]}),e.jsx("td",{className:m,children:O(te(t.treatment_posted_7d,t.holdout_posted_7d))}),e.jsx("td",{className:m,children:O(te(t.treatment_posted_14d,t.holdout_posted_14d))}),e.jsx("td",{className:m,children:n?`Too small (<${de})`:""})]},`${t.week??"pooled"}-${t.cohort}`)})})}function De(){var o;const[s,t]=g.useState(8),n=ye(s);if(n.isLoading)return e.jsx("div",{className:b,children:e.jsxs("p",{className:"flex items-center gap-2 p-4 text-sm text-zinc-400",children:[e.jsx(I,{"aria-hidden":"true",className:"h-4 w-4 animate-spin"}),"Loading reports…"]})});if(n.error||!n.data)return e.jsx("div",{className:b,children:e.jsx("p",{role:"alert",className:"p-4 text-sm text-red-300",children:((o=n.error)==null?void 0:o.message)??"Reports are unavailable."})});const{funnel:r,lift:i,content:l,trends:d}=n.data;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-end justify-between gap-4",children:[e.jsx("p",{className:"max-w-2xl text-sm text-zinc-400",children:`"Posted" means an authored, substantive message in any of the member's groups. Holdout members get no email, so the gap between the arms is the digest's effect. Read it across several weeks, not one.`}),e.jsxs("label",{className:f,children:["Window",e.jsx("select",{className:`${N} mt-1 w-32`,value:s,onChange:a=>t(Number(a.target.value)),children:[4,8,12,26].map(a=>e.jsxs("option",{value:a,children:[a," sends"]},a))})]})]}),e.jsxs("section",{className:`${b} p-4`,"aria-labelledby":"lift-heading",children:[e.jsx("h2",{id:"lift-heading",className:"font-semibold text-zinc-100",children:"Did it make people post?"}),e.jsxs("div",{className:"mt-3",children:[e.jsxs(S,{head:["Week","Cohort","Treatment / holdout","Posted in 7d","Lift 7d","Lift 14d",""],children:[e.jsx(ie,{rows:i.pooled}),e.jsx(ie,{rows:i.weeks})]}),i.weeks.length===0&&e.jsx("p",{className:"mt-3 text-sm text-zinc-400",children:"No completed sends yet."})]})]}),e.jsxs("section",{className:`${b} p-4`,"aria-labelledby":"funnel-heading",children:[e.jsx("h2",{id:"funnel-heading",className:"font-semibold text-zinc-100",children:"Latest send funnel"}),r?e.jsx("div",{className:"mt-3",children:e.jsx(S,{head:["Cohort","Arm","Billing","Eligible","Skipped","Sent","Delivered","Bounced","Complaints","Clicked","Catch-up","Posted 7d"],children:r.rows.map(a=>e.jsxs("tr",{children:[e.jsx("td",{className:m,children:a.cohort}),e.jsx("td",{className:m,children:a.arm.replace("_"," ")}),e.jsx("td",{className:m,children:a.segment.replace("_"," ")}),e.jsx("td",{className:m,children:a.eligible}),e.jsx("td",{className:m,children:a.skipped}),e.jsx("td",{className:m,children:a.sent}),e.jsx("td",{className:m,children:a.delivered}),e.jsx("td",{className:m,children:a.bounced}),e.jsx("td",{className:m,children:a.complained}),e.jsx("td",{className:m,children:a.clicked}),e.jsx("td",{className:m,children:a.used_catchup}),e.jsx("td",{className:m,children:a.posted_7d})]},`${a.cohort}-${a.arm}-${a.segment}`))})}):e.jsx("p",{className:"mt-3 text-sm text-zinc-400",children:"No send yet."})]}),e.jsxs("section",{className:`${b}
1 p-4`,"aria-labelledby":"content-heading",children:[e.jsx("h2",{id:"content-heading",className:"font-semibold text-zinc-100",children:"What people click"}),e.jsxs("div",{className:"mt-3 grid gap-6 lg:grid-cols-3",children:[e.jsx(S,{head:["Position","Shown","CTR"],children:l.by_position.map(a=>e.jsxs("tr",{children:[e.jsxs("td",{className:m,children:["#",a.position]}),e.jsx("td",{className:m,children:a.shown}),e.jsx("td",{className:m,children:v(a.shown?a.clicked/a.shown:null)})]},a.position))}),e.jsx(S,{head:["Topic","Shown","CTR"],children:l.by_topic.map(a=>e.jsxs("tr",{children:[e.jsx("td",{className:m,children:(a.topic??"untagged").replace(/_/g," ")}),e.jsx("td",{className:m,children:a.shown}),e.jsx("td",{className:m,children:v(a.shown?a.clicked/a.shown:null)})]},a.topic??"none"))}),e.jsx(S,{head:["Subject","Sent","Click rate"],children:l.by_variant.map(a=>e.jsxs("tr",{children:[e.jsx("td",{className:m,children:a.variant}),e.jsx("td",{className:m,children:a.sent}),e.jsx("td",{className:m,children:v(a.sent?a.clicked/a.sent:null)})]},a.variant))})]})]}),e.jsxs("section",{className:`${b} p-4`,"aria-labelledby":"trends-heading",children:[e.jsx("h2",{id:"trends-heading",className:"font-semibold text-zinc-100",children:"List health by week"}),e.jsx("div",{className:"mt-3",children:e.jsx(S,{head:["Week","Sent","Bounce","Complaints","Unsubscribes","Silent posted 7d","Lift 7d"],children:d.map(a=>e.jsxs("tr",{children:[e.jsx("td",{className:m,children:a.week}),e.jsx("td",{className:m,children:a.sent}),e.jsx("td",{className:`${m} ${a.bounce_rate>.02?"text-red-300":""}`,children:v(a.bounce_rate,2)}),e.jsx("td",{className:`${m} ${a.complaint_rate>.001?"text-red-300":""}`,children:v(a.complaint_rate,2)}),e.jsxs("td",{className:m,children:[a.unsubscribes," (",v(a.unsubscribe_rate),")"]}),e.jsx("td",{className:m,children:v(a.silent_posted_7d)}),e.jsx("td",{className:m,children:a.lift_7d==null?"—":O(a.lift_7d*100)})]},a.week))})})]})]})}function Ee({memberId:s}){var n,r;const t=we(s);return s?e.jsxs("section",{className:`${b} p-4`,"aria-labelledby":"member-history-heading",children:[e.jsx("h2",{id:"member-history-heading",className:"font-semibold text-zinc-100",children:"Digest history"}),t.isLoading?e.jsx("p",{className:"mt-3 text-sm text-zinc-400",children:"Loading history…"}):t.error?e.jsx("p",{role:"alert",className:"mt-3 text-sm text-red-300",children:t.error.message}):e.jsxs(e.Fragment,{children:[((n=t.data)==null?void 0:n.suppression)&&e.jsxs("p",{className:"mt-3 rounded border border-orange-800 bg-orange-950/30 p-2 text-sm text-orange-200",children:["Suppressed (",t.data.suppression.reason,", ",t.data.suppression.scope==="all"?"all email":"digest only",") since ",U(t.data.suppression.created_at)]}),(r=t.data)!=null&&r.sends.length?e.jsx("ul",{className:"mt-3 space-y-3",children:t.data.sends.map(i=>e.jsxs("li",{className:"rounded-lg border border-zinc-800 p-3",children:[e.jsxs("p",{className:"text-sm text-zinc-100",children:["Week of ",i.week,": ",e.jsx("span",{className:"font-medium",children:i.status}),i.arm&&e.jsxs("span",{className:"text-zinc-400",children:[" · ",i.arm]}),i.skip_reason&&e.jsxs("span",{className:"text-zinc-400",children:[" · ",i.skip_reason.replace(/_/g," ")]})]}),i.subject&&e.jsxs("p",{className:"mt-1 text-sm text-zinc-300",children:['"',i.subject,'"',i.sent_at&&e.jsxs("span",{className:"text-zinc-500",children:[" · sent ",U(i.sent_at)]})]}),i.items.length>0&&e.jsx("ol",{className:"mt-2 list-decimal space-y-0.5 pl-5 text-xs text-zinc-400",children:i.items.map(l=>{const d=i.clicks.filter(o=>o.thread_id===l.thread_id&&!o.suspect).length;return e.jsxs("li",{children:[l.title,d>0&&e.jsx("span",{className:"text-emerald-300",children:" · clicked"})]},l.thread_id)})}),i.clicks.some(l=>l.suspect)&&e.jsxs("p",{className:"mt-1 text-xs text-zinc-500",children:[i.clicks.filter(l=>l.suspect).length," scanner/prefetch click(s) ignored"]})]},i.recipient_id))}):e.jsx("p",{className:"mt-3 text-sm text-zinc-400",children:"This member hasn't been in any send yet."})]})]}):null}const w="min-w-0 rounded-xl border border-zinc-800 bg-zinc-900/40",D="inline-flex items-center justify-center gap-2 rounded-md border border-zinc-700 bg-zinc-900 px-3 py-2 text-sm text-zinc-200 hover:bg-zinc-800 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-400 disabled:cursor-not-allowed disabled:opacity-50";
1function B(s){return s==null?"Not reported":s.toLocaleString()}function H(s){return s==null?"Not reported":s.toLocaleString(void 0,{maximumFractionDigits:3})}function $(s){if(s===void 0)return"Not reported";if(s===null||s==="")return"None recorded";const t=new Date(s);return Number.isNaN(t.getTime())?"Invalid timestamp":t.toLocaleString()}function W({children:s}){return e.jsxs("p",{role:"status",className:"flex items-center gap-2 p-5 text-sm text-zinc-400",children:[e.jsx(I,{"aria-hidden":"true",className:"h-4 w-4 animate-spin motion-reduce:animate-none"}),s]})}function re({error:s,onRetry:t}){return e.jsxs("div",{role:"alert",className:"flex flex-wrap items-center justify-between gap-3 rounded-lg border border-red-900/60 bg-red-950/30 p-4 text-sm text-red-200",children:[e.jsx("p",{className:"min-w-0 flex-1 break-words",children:s.message}),e.jsx("button",{type:"button",onClick:t,className:D,children:"Try again"})]})}function K({blockers:s,label:t}){return s.length?e.jsxs("div",{className:"rounded-lg border border-amber-800/50 bg-amber-950/20 p-4 text-sm",children:[e.jsxs("h3",{className:"flex items-center gap-2 font-medium text-amber-200",children:[e.jsx(ue,{"aria-hidden":"true",className:"h-4 w-4 shrink-0"}),t]}),e.jsx("ul",{className:"mt-2 list-disc space-y-1 break-words pl-6 text-amber-100/80",children:s.map((n,r)=>e.jsx("li",{children:n.replace(/_/g," ")},`${r}-${n}`))})]}):null}function Re({health:s}){var r;const t=[{label:"Pending",value:s.pending_batches},{label:"Processing",value:s.processing_batches},{label:"Failed",value:s.failed_batches},{label:"Complete",value:s.completed_batches}],n=[{label:"Groups with rosters",value:s.roster_groups},{label:"Fresh roster groups",value:s.fresh_roster_groups},{label:"Monitored groups needing rosters",value:s.eligible_roster_groups},{label:"Resolved members",value:s.resolved_members},{label:"Members with affinities",value:s.affinity_members},{label:"Members with personal chat evidence",value:s.observed_members}];return e.jsxs("section",{className:w,"aria-labelledby":"digest-health-heading",children:[e.jsxs("div",{className:"border-b border-zinc-800 p-4 sm:px-5",children:[e.jsx("h2",{id:"digest-health-heading",className:"font-semibold text-zinc-100",children:"Pipeline health"}),e.jsx("p",{className:"mt-1 text-sm text-zinc-400",children:"Classification, roster freshness, and interest coverage across members."})]}),e.jsxs("div",{className:"grid gap-6 p-4 sm:p-5 xl:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"mb-3 text-sm font-medium text-zinc-300",children:"Classification batches"}),e.jsx("dl",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4",children:t.map(({label:i,value:l})=>e.jsxs("div",{className:"rounded-lg bg-zinc-950/60 p-3",children:[e.jsx("dt",{className:"text-xs text-zinc-400",children:i}),e.jsx("dd",{className:`mt-1 break-words text-lg font-semibold tabular-nums ${i==="Failed"&&l>0?"text-red-300":"text-zinc-100"}`,children:B(l)})]},i))}),e.jsxs("dl",{className:"mt-4 space-y-2 text-sm",children:[e.jsxs("div",{className:"flex flex-wrap justify-between gap-x-4 gap-y-1",children:[e.jsx("dt",{className:"text-zinc-400",children:"Latest ingestion"}),e.jsx("dd",{className:"text-zinc-200",children:$(s.latest_ingestion_at)})]}),e.jsxs("div",{className:"flex flex-wrap justify-between gap-x-4 gap-y-1",children:[e.jsx("dt",{className:"text-zinc-400",children:"Latest completed batch"}),e.jsx("dd",{className:"text-zinc-200",children:$(s.latest_completed_at)})]}),e.jsxs("div",{className:"flex flex-wrap justify-between gap-x-4 gap-y-1",children:[e.jsx("dt",{className:"text-zinc-400",children:"Latest successful worker run"}),e.jsx("dd",{className:"text-zinc-200",children:$(s.latest_worker_at)})]})]})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"mb-2 text-sm font-medium text-zinc-300",children:"Membership & affinity coverage"}),e.jsx("dl",{className:"divide-y divide-zinc-800 text-sm",children:n.map(({label:i,value:l})=>e.jsxs("div",{className:"flex items-baseline justify-between gap-4 py-2",children:[e.jsx("dt",{className:"text-zinc-400",children:i}),e.jsx("dd",{className:"text-right font-medium tabular-nums text-zinc-100",children:B(l)})]},i))}),e.jsx("p",{className:"mt-2 text-xs leading-relaxed text-zinc-400",children:"Fresh memberships require a roster snapshot less than 30 hours old. Past posting alone does not verify membership."})]})]}),!!((r=s.blockers)!=null&&r.length)&&e.jsx("div",{className:"px-4 pb-4 sm:px-5 sm:pb-5",children:e.jsx(K,{blockers:s.blockers,label:"Pipeline blockers"})})]})}function Me({affinities:s}){const t=[...s].sort((n,r)=>r.score-n.score);return e.jsxs("section",{className:w,"aria-labelledby":"digest-topics-heading",children:[e.jsxs("div",{className:"border-b border-zinc-800 p-4 sm:p-5",children:[e.jsx("h2",{id:"digest-topics-heading",className:"font-semibold text-zinc-100",children:"Top topics"}),e.jsx("p",{className:"mt-1 max-w-3xl text-sm leading-relaxed text-zinc-400",children:"Personal chat evidence is the strongest interest signal. Onboarding is a prior;
1 group membership is weaker context. Silence is not disinterest."})]}),t.length===0?e.jsx("p",{className:"p-5 text-sm text-zinc-400",children:"No topic affinities are available for this member yet."}):e.jsx("ul",{className:"divide-y divide-zinc-800",children:t.map(n=>e.jsxs("li",{className:"p-4 sm:p-5",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline justify-between gap-2",children:[e.jsx("h3",{className:"min-w-0 break-words font-medium text-zinc-100",children:n.label||n.topic_id}),e.jsxs("span",{className:"text-sm text-zinc-300",children:["Total ",e.jsx("strong",{className:"ml-1 tabular-nums text-zinc-100",children:H(n.score)})]})]}),e.jsx("dl",{className:"mt-3 grid grid-cols-2 gap-3 text-sm sm:grid-cols-4",children:[{label:"Personal chat",value:n.observed_score,strong:!0},{label:"Onboarding",value:n.declared_score},{label:"Group context",value:n.group_score},{label:"Engagement",value:n.engagement_score}].map(({label:r,value:i,strong:l})=>e.jsxs("div",{className:`border-l-2 pl-3 ${l?"border-amber-400":"border-zinc-700"}`,children:[e.jsx("dt",{className:"text-xs text-zinc-400",children:r}),e.jsx("dd",{className:`mt-1 font-medium tabular-nums ${l?"text-amber-200":"text-zinc-200"}`,children:H(i)})]},r))}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-x-4 gap-y-1 text-xs text-zinc-400",children:[e.jsxs("span",{children:["Evidence messages: ",e.jsx("span",{className:"tabular-nums text-zinc-300",children:B(n.message_count)})]}),e.jsxs("span",{children:["Last observed: ",$(n.last_observed_at)]})]})]},n.topic_id))})]})}function qe({items:s,affinities:t}){const n=new Map(t.map(r=>[r.topic_id,r.label]));return e.jsxs("section",{className:w,"aria-labelledby":"digest-discussions-heading",children:[e.jsxs("div",{className:"border-b border-zinc-800 p-4 sm:p-5",children:[e.jsxs("h2",{id:"digest-discussions-heading",className:"font-semibold text-zinc-100",children:["Recommended discussions ",e.jsxs("span",{className:"ml-1 text-zinc-400",children:["(",s.length,")"]})]}),e.jsx("p",{className:"mt-1 text-sm text-zinc-400",children:"Recent conversations this member has not joined in their verified groups."})]}),s.length===0?e.jsx("p",{className:"p-5 text-sm leading-relaxed text-zinc-400",children:"No eligible discussions to preview. Check the member blockers and roster freshness; members without verified memberships cannot receive group recommendations."}):e.jsx("ol",{className:"divide-y divide-zinc-800",children:s.map(r=>{var i;return e.jsxs("li",{className:"space-y-3 p-4 sm:p-5",children:[e.jsxs("div",{className:"flex flex-wrap gap-x-4 gap-y-1 text-xs text-zinc-400",children:[e.jsx("span",{className:"break-words text-zinc-300",children:r.group_name||`Group ${r.group_id}`}),e.jsxs("span",{children:["Last message: ",$(r.last_message_at)]})]}),e.jsx("h3",{className:"break-words font-medium text-zinc-100",children:r.title}),e.jsx("p",{className:"break-words text-sm leading-relaxed text-zinc-300",children:r.gist}),r.why_it_matters&&e.jsxs("p",{className:"break-words text-sm leading-relaxed text-zinc-400",children:[e.jsx("span",{className:"font-medium text-zinc-300",children:"Why it matters: "}),r.why_it_matters]}),e.jsxs("div",{className:"rounded-lg bg-zinc-950/60 p-3 text-sm",children:[e.jsxs("p",{className:"break-words leading-relaxed text-amber-100",children:[e.jsx("span",{className:"font-medium",children:"Why recommended: "}),r.reason||"No reason supplied."]}),e.jsxs("p",{className:"mt-2 text-xs tabular-nums text-zinc-400",children:["Recommendation score: ",H(r.score)]})]}),!!((i=r.topic_ids)!=null&&i.length)&&e.jsx("ul",{className:"flex flex-wrap gap-2",children:r.topic_ids.map(l=>e.jsx("li",{className:"max-w-full break-words rounded bg-zinc-800 px-2 py-1 text-xs text-zinc-300",children:n.get(l)||l},l))})]},r.id)})})]})}function We(s){const t="default-src 'none'; style-src 'unsafe-inline'; base-uri 'none'; form-action 'none'",n=document.createElement("template");return n.innerHTML=s,n.content.querySelectorAll("script, iframe, frame, frameset, object, embed, link, meta, base, form, input, button, textarea, select, svg, math, template").forEach(r=>r.remove()),n.content.querySelectorAll("*").forEach(r=>{for(const i of Array.from(r.attributes))(/^on/i.test(i.name)||/^(href|src|srcset|srcdoc|action|formaction|ping|background|xlink:href|autofocus|tabindex|contenteditable)$/i.test(i.name))&&r.removeAttribute(i.name)}),`<!doctype html><html><head><meta http-equiv="Content-Security-Policy" content="${t}"></head><body>${n.innerHTML}</body></html>`}function Oe({rendered:s}){const[t,n]=g.useState("html"),r=g.useMemo(()=>s!=null&&s.html?We(s.html):"",[s==null?void 0:s.html]);return e.jsxs("section",{className:w,"aria-labelledby":"digest-render-heading",children:[e.jsxs("div",{className:"space-y-3 border-b border-zinc-800 p-4 sm:p-5",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsx("h2",{id:"digest-render-heading",className:"font-semibold text-zinc-100",children:"Email preview"}),e.jsx("div",{className:"flex gap-1",role:"group","aria-label":"Preview format",children:["html","text"].map(i=>e.jsx("button",{type:"button","aria-pressed":t===i,onClick:()=>n(i),className:`${D} ${t===i?"border-amber-500/60 text-amber-200":""}`,children:i==="html"?"HTML":"Text"},i))})]}),e.jsx("p",{className:"text-xs leading-relaxed text-zinc-400",children:"Internal inspection only. Preview links and external resources are disabled; viewing this preview does not record engagement."}),s&&e.jsxs("p",{className:"break-words text-sm text-zinc-300",children:[e.jsx("span",{className:"text-zinc-400",children:"Subject: "}),s.subject||"No subject supplied"]})]}),s?t==="html"?r?e.jsx("iframe",{title:"Internal Circles digest email preview",sandbox:"",referrerPolicy:"no-referrer",srcDoc:r,className:"h-[640px] w-full rounded-b-xl border-0 bg-white"}):e.jsx("p",{className:"p-5 text-sm text-zinc-400",children:"No HTML preview was returned."}):e.jsx("pre",{className:"max-h-[640px] overflow-auto whitespace-pre-wrap break-words p-4 font-sans text-sm leading-relaxed text-zinc-200 sm:p-5",children:s.text||"No text preview was returned."}):e.jsx("p",{className:"p-5 text-sm text-zinc-400",children:"No rendered email was returned for this member."})]})}const Ie=()=>{var p,A,J,V,Z,X,ee;const[s,t]=g.useState(""),[n,r]=g.useState(""),[i,l]=g.useState(null);g.useEffect(()=>{const j=window.setTimeout(()=>r(s),300);return()=>window.clearTimeout(j)},[s]);const{indexQuery:d,previewQuery:o,isAdmin:a}=fe({search:n,memberId:(i==null?void 0:i.id)??null}),u=((p=ce().data)==null?void 0:p.settings.enabled)===!0,c=s.trim()!==n.trim(),h=(A=o.data)==null?void 0:A.preview,y=(h==null?void 0:h.member)??i,_=o.dataUpdatedAt>d.dataUpdatedAt?(J=o.data)==null?void 0:J.health:(V=d.data)==null?void 0:V.health,k=d.isFetching||o.isFetching,L=(_==null?void 0:_.send_enabled)===!0||(h==null?void 0:h.send_enabled)===!0,P=()=>{a&&(d.refetch(),i&&o.refetch())};return e.jsxs("div",{className:"mx-auto max-w-[1600px] space-y-6",children:[e.jsxs("header",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-semibold tracking-tight text-zinc-100",children:"Circles digest inspector"}),e.jsx("p",{className:"mt-1 max-w-2xl text-sm leading-relaxed text-zinc-400",children:"Inspect member interests, the evidence behind recommendations, and the rendered digest."})]}),e.jsxs("button",{type:"button",onClick:P,disabled:k||!a||c,className:D,children:[e.jsx(xe,{"aria-hidden":"true",className:`h-4 w-4 ${k?"animate-spin motion-reduce:animate-none":""}`}),k?"Refreshing…":"Refresh data"]})]}),e.jsxs("div",{className:"flex items-start gap-3 rounded-lg border border-amber-700/50 bg-amber-950/20 p-4",children:[e.jsx(ge,{"aria-hidden":"true",className:"mt-0.5 h-4 w-4 shrink-0 text-amber-300"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-amber-200",children:u?"Member sending ON • weekly digest sends automatically":"Member sending OFF"}),e.jsx("p",{className:"mt-1 text-xs text-zinc-400",children:u?"The Preview tab only reads data. Manage this week's send in the Sending tab.":"Previews only. Turn sending on in the Sending tab when you're ready."})]})]}),L&&e.jsx("div",{role:"alert",children:e.jsx(K,{blockers:["The service unexpectedly reports sending enabled. The internal preview hold remains in place; investigate the backend configuration."],label:"Send status mismatch"})}),e.jsxs(pe,{defaultValue:"preview",children:[e.jsxs(be,{className:"bg-zinc-800",children:[e.jsx(R,{value:"preview",children:"Preview"}),e.jsx(R,{value:"sending",children:"Sending"}),e.jsx(R,{value:"reports",children:"Reports"})]}),e.jsxs(M,{value:"preview",className:"space-y-6",children:[d.error&&e.jsx(re,{error:d.error,onRetry:()=>void d.refetch()}),_?e.jsx(Re,{health:_}):d.isLoading?e.jsx("div",{className:w,children:e.jsx(W,{children:"Loading pipeline health…"})}):e.jsx("p",{className:"text-sm text-zinc-400",children:"Pipeline health is unavailable."}),e.jsxs("div",{className:"grid items-start gap-6 xl:grid-cols-[280px_minmax(0,1fr)]",children:[e.jsxs("section",{className:w,"aria-labelledby":"digest-members-heading",children:[e.jsxs("div",{className:"space-y-3 border-b border-zinc-800 p-4",children:[e.jsx("h2",{id:"digest-members-heading",className:"font-semibold text-zinc-100",children:"Select a member"}),e.jsx("label",{htmlFor:"digest-member-search",className:"block text-xs text-zinc-400",children:"Search by name or email"}),e.jsxs("div",{className:"relative",children:[e.jsx(he,{"aria-hidden":"true",className:"pointer-events-none absolute left-3 top-3 h-4 w-4 text-zinc-500"}),e.jsx("input",{id:"digest-member-search",type:"search",autoComplete:"off",maxLength:120,value:s,onChange:j=>t(j.target.value),placeholder:"Name or email",className:"w-full rounded-md border border-zinc-700 bg-zinc-950 py-2 pl-9 pr-3 text-sm text-zinc-100 placeholder:text-zinc-500 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-400"})]})]}),c||d.isLoading?e.jsx(W,{children:"Searching members…"}):d.isError?e.jsx("p",{className:"p-4 text-sm text-zinc-400",children:"Member search is unavailable. Try loading it again above."}):(Z=d.data)!=null&&Z.members.length?e.jsx("ul",{className:"max-h-[480px] space-y-1 overflow-y-auto p-2",children:d.data.members.map(j=>{var se;return e.jsx("li",{children:e.jsxs("button",{type:"button",onClick:()=>l(j),"aria-pressed":(i==null?void 0:i.id)===j.id,className:`w-full rounded-lg border p-3 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-400 ${(i==null?void 0:i.id)===j.id?"border-amber-700/60 bg-amber-950/20":"border-transparent hover:bg-zinc-800"}`,children:[e.jsx("span",{className:"block break-words text-sm font-medium text-zinc-100",children:j.name||j.email||"Unnamed member"}),e.jsx("span",{className:"mt-1 block break-all text-xs text-zinc-400",children:j.email||"No email recorded"}),e.jsxs("span",{className:"mt-2 block text-xs text-zinc-400",children:["Cohort: ",((se=j.cohort)==null?void 0:se.replace(/_/g," "))||"Not reported"]})]})},j.id)})}):e.jsx("p",{role:"status",className:"p-4 text-sm text-zinc-400",children:n.trim()?"No members match this search. Try another name or email.":"No members are available to inspect yet."})]}),e.jsx("div",{className:"min-w-0 space-y-5","aria-busy":o.isFetching,children:i?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h2",{className:"break-words text-xl font-semibold text-zinc-100",children:y.name||y.email||"Unnamed member"}),e.jsx("p",{className:"mt-1 break-all text-sm text-zinc-400",children:y.email||"No email recorded"}),e.jsxs("p",{className:"mt-1 text-xs text-zinc-400",children:["Cohort: ",((X=y.cohort)==null?void 0:X.replace(/_/g," "))||"Not reported"]})]}),e.jsx("button",{type:"button",onClick:()=>l(null),className:D,children:"Clear selection"})]}),o.isLoading?e.jsx("div",{className:w,children:e.jsx(W,{children:"Loading member evidence and preview…"})}):o.error?e.jsx(re,{error:o.error,onRetry:()=>void o.refetch()}):h?e.jsxs(e.Fragment,{children:[e.jsx(K,{blockers:h.blockers??[],label:"Member preview blockers"}),e.jsx(Me,{affinities:h.affinities??[]}
1),e.jsxs("div",{className:"grid items-start gap-5 2xl:grid-cols-2",children:[e.jsx(qe,{items:h.items??[],affinities:h.affinities??[]}),e.jsx(Oe,{rendered:(ee=o.data)==null?void 0:ee.rendered},y.id)]})]}):e.jsx("div",{className:`${w} p-5 text-sm text-zinc-400`,children:"No preview is available for this member. Check pipeline health and refresh when member data is available."})]}):e.jsx("div",{className:`${w} p-6 text-sm text-zinc-400`,children:"Choose a member to inspect their topic evidence and digest preview."})})]}),e.jsx(Ee,{memberId:(i==null?void 0:i.id)??null})]}),e.jsx(M,{value:"sending",children:e.jsx(Ae,{member:i})}),e.jsx(M,{value:"reports",children:e.jsx(De,{})})]})]})};export{Ie 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.