1import{j as t}from"./vendor-markdown-C-I3nZWo.js";import{j,aN as v,bq as w,br as N,bs as y,q as k,X as S,B as m,L as B}from"./index-DFoQxP2Z.js";import{C}from"./CulturalShell-CRmgK6jo.js";import{P as D}from"./primitives-DwkiOsSy.js";import{R as P,a as A}from"./RecordDialog-CajPKuxO.js";import{B as E}from"./badge-DvZAazPQ.js";import{r as c}from"./vendor-charts-DphG3eWF.js";import{o as I,r as L,i as O}from"./vendor-icons-DptrxPFP.js";import{f as R}from"./vendor-date-DwvsUr7l.js";import"./vendor-office-CYA1a3lH.js";import"./vendor-query-Csct0vqx.js";import"./vendor-radix-DiGlQgnh.js";import"./vendor-supabase-C6T5JIOu.js";import"./vendor-analytics-4JMxWFgu.js";import"./vendor-forms-Crpao7PO.js";import"./alert-dialog-Co-1sklm.js";import"./textarea-DyjusVvx.js";const T={published:"bg-emerald-500/15 text-emerald-700 dark:text-emerald-300 border-emerald-500/20",review:"bg-amber-500/15 text-amber-700 dark:text-amber-300 border-amber-500/20",draft:"bg-muted text-muted-foreground border-border"},q=[{name:"title",label:"Title",type:"text",required:!0},{name:"audience",label:"Audience",type:"text",placeholder:"e.g. Leadership, Marketing"},{name:"status",label:"Status",type:"select",required:!0,options:[{value:"draft",label:"Draft"},{value:"review",label:"In review"},{value:"published",label:"Published"}]},{name:"body",label:"Body (markdown)",type:"textarea",rows:10}];function te(){const{org:s,role:u,isPlatformAdmin:p}=j(),n=u==="admin"||p,{data:l=[]}=v(s==null?void 0:s.id),f=w(),g=N(),a=y(),{toast:d}=k(),x=S(),[i,o]=c.useState(null),[b,r]=c.useState(!1),h=async()=>{if(s!=null&&s.id)try{const e=await a.mutateAsync({orgId:s.id});d({title:"Briefing drafted",description:e.briefing.title}),x(`/planning/research/${e.briefing.id}`)}catch(e){d({title:"Generation failed",description:e.message,variant:"destructive"})}};return t.jsxs(C,{children:[t.jsx(D,{eyebrow:"Synthesis",title:"Projects",description:"Weekly digests turning live cultural signals into shareable, actionable narratives.",right:n?t.jsxs("div",{className:"flex gap-2",children:[t.jsxs(m,{size:"sm",variant:"outline",onClick:h,disabled:a.isPending,children:[a.isPending?t.jsx(I,{className:"h-3.5 w-3.5 mr-1 animate-spin"}):t.jsx(L,{className:"h-3.5 w-3.5 mr-1"}),"Generate weekly"]}),t.jsxs(m,{size:"sm",onClick:()=>{o(null),r(!0)},children:[t.jsx(O,{className:"h-3.5 w-3.5 mr-1"})," New briefing"]})]}):void 0}),t.jsxs("div",{className:"rounded-lg border border-border divide-y divide-border",children:[l.map(e=>t.jsxs("div",{className:"p-4 hover:bg-muted/30 transition-colors flex items-center justify-between gap-4",children:[t.jsxs(B,{to:`/planning/research/${e.id}`,className:"block flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[t.jsx(E,{variant:"outline",className:`capitalize ${T[e.status]??""}`,children:e.status}),e.audience&&t.jsx("span",{className:"text-[10px] uppercase tracking-wide text-muted-foreground",children:e.audience})]}),t.jsx("p",{className:"font-medium text-foreground",children:e.title})]}),t.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[t.jsx("p",{className:"text-[10px] text-muted-foreground",children:R(new Date(e.updated_at),{addSuffix:!0})}),t.jsx(P,{canEdit:n,label:e.title,onEdit:()=>{o(e),r(!0)},onDelete:()=>g.mutateAsync({orgId:s.id,id:e.id})})]})]},e.id)),l.length===0&&t.jsx("p",{className:"p-8 text-sm text-muted-foreground",children:"No briefings yet."})]}),t.jsx(A,{open:b,onOpenChange:r,title:i?"Edit briefing":"New briefing",fields:q,initial:i,onSubmit:async e=>{e.status==="published"&&!(i!=null&&i.published_at)&&(e.published_at=new Date().toISOString()),await f.mutateAsync({orgId:s.id,values:e})}})]})}export{te 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.