1import{a as ue}from"./rolldown-runtime-M0oDzQ_3.js";import{O as he,i as A,k as pe,o as G,r as Y}from"./vendor-data-BwcWGEsa.js";import{n as re,t as H}from"./supabase-C5lAo7mf.js";import{t as ae}from"./createLucideIcon-BBBB7OBy.js";import{t as ge}from"./activity-CCb4V9Nz.js";import{t as ne}from"./book-open-PWQIawMS.js";import{t as be}from"./bot-BAHaeQUc.js";import{t as fe}from"./brain-Dhuvxm-r.js";import{t as je}from"./chart-column-CN26UbjN.js";import{t as oe}from"./chevron-down-Bi5BlOmC.js";import{t as le}from"./chevron-right-CejzDIR0.js";import{t as ie}from"./circle-alert-CBdHC6QX.js";import{t as Z}from"./circle-check-DpATGgU0.js";import{t as V}from"./circle-pause-B-t5RG42.js";import{t as de}from"./circle-x-BWv_pDsq.js";import{t as ee}from"./clock-DTQt8uc9.js";import{t as ve}from"./dollar-sign-bBRwvLg0.js";import{t as W}from"./external-link-CJfwKTEY.js";import{t as Ne}from"./funnel-Cd_INQOT.js";import{t as ce}from"./image-CaYZDweo.js";import{t as O}from"./loader-circle-CdxwvVl2.js";import{t as ye}from"./octagon-alert-CyG9Jlpa.js";import{t as xe}from"./play-C1rzHH5w.js";import{t as ke}from"./plus-DkAbSNHZ.js";import{t as R}from"./refresh-cw-dz9G8Tu5.js";import{t as we}from"./rotate-ccw-DuSNkFOM.js";import{t as _e}from"./skip-forward-Bv9JAPLj.js";import{t as Se}from"./sparkles-B_ubz5O3.js";import{n as Ce,t as $e}from"./toggle-right-BLS5ceeQ.js";import{t as Ae}from"./trending-up-BVnyltGL.js";import{t as Te}from"./triangle-alert-n-SskdNm.js";import{t as Be}from"./wifi-off-DJbYWqls.js";import{t as K}from"./zap-DdqMYNHk.js";import{D as B,Nt as Ee,kt as Pe}from"./index-Bhvx0-ct.js";import"./ui-DMgQNDEI.js";import{n as Re}from"./AdminToast-DqMvvxiF.js";import{t as I}from"./AgentOrchestrationService-BOGBOApV.js";import{t as Oe}from"./AgentRunBadge-CFatFdfK.js";import{t as qe}from"./AdminDeepAnalyticsService-CNqiZ5qI.js";var Fe=[["path",{d:"M11 5h10",key:"1cz7ny"}],["path",{d:"M11 12h10",key:"1438ji"}],["path",{d:"M11 19h10",key:"11t30w"}],["path",{d:"M4 4h1v5",key:"10yrso"}],["path",{d:"M4 9h2",key:"r1h2o0"}],["path",{d:"M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02",key:"xtkcd5"}]],Le=ae("list-ordered",Fe),De=[["path",{d:"M9 18V5l12-2v13",key:"1jmyc2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["circle",{cx:"18",cy:"16",r:"3",key:"1hluhg"}]],Ie=ae("music",De),c=ue(pe(),1),v=H,X=re.url?.trim()||"";function Me(){if(!X)throw new Error("Agent API unavailable. Set VITE_AGENT_API_URL to use admin agent monitoring.");return X}var He=class{async checkAgentHealth(){if(!X)return!1;try{return(await fetch(`${Me()}/health`,{signal:AbortSignal.timeout(3e3)})).status===200}catch{return!1}}async getPipelineOverview(){const{data:t,error:s}=await v.from("book_catalog").select("id, status, total_chapters, completed_chapters");if(s)throw s;const{data:r,error:n}=await v.from("chapter_pipeline").select("infographic_status, audio_status, blueprint_status");if(n)throw n;const a=t||[],u=r||[],d=a.length,o=a.filter(h=>h.status==="published").length,l=a.filter(h=>h.status==="in_progress").length,m=a.filter(h=>h.status==="planned").length,x=a.filter(h=>h.status==="completed").length,p=a.filter(h=>h.status==="needs_review").length;let N=0,f=0;a.forEach(h=>{N+=h.total_chapters||0,f+=h.completed_chapters||0});const C=u.filter(h=>h.infographic_status==="error"||h.audio_status==="error"||h.blueprint_status==="error").length,w=u.filter(h=>h.infographic_status==="pending"||h.audio_status==="pending").length,q=u.filter(h=>h.infographic_status==="generating"||h.audio_status==="generating").length,y=new Set,{data:E,error:S}=await v.from("chapter_pipeline").select("book_id").or("infographic_status.eq.error,audio_status.eq.error,blueprint_status.eq.error");if(S)throw S;return(E||[]).forEach(h=>y.add(h.book_id)),{totalBooks:d,publishedBooks:o,inProgressBooks:l,plannedBooks:m,completedBooks:x,needsReviewBooks:p,errorBooks:y.size,totalChapters:N,completedChapters:f,pendingChapters:w,generatingChapters:q,errorChapters:C,completionPercentage:N>0?Math.round(f/N*100):0}}async getBooksPipeline(t){let s=v.from("book_catalog").select("id, title, author, slug, domain_slug, status, total_chapters, completed_chapters, created_at, cover_url, consecutive_failures, paused_at, pause_reason, last_error").order("created_at",{ascending:!1});t?.status&&t.status!=="all"&&(s=s.eq("status",t.status)),t?.search&&(s=s.or(`title.ilike.%${t.search}%,author.ilike.%${t.search}%,slug.ilike.%${t.search}%`));const{data:r,error:n}=await s;if(n)return console.error("Failed to fetch books pipeline:",n),[];const a=(r||[]).map(o=>o.id);if(a.length===0)return[];const{data:u}=await v.from("chapter_pipeline").select("book_id, infographic_status, audio_status, blueprint_status, last_error").in("book_id",a),d=new Map;
1return(u||[]).forEach(o=>{d.has(o.book_id)||d.set(o.book_id,{errorCount:0,pendingCount:0,generatingCount:0,lastError:null});const l=d.get(o.book_id);(o.infographic_status==="error"||o.audio_status==="error"||o.blueprint_status==="error")&&(l.errorCount++,o.last_error&&(l.lastError=o.last_error)),(o.infographic_status==="pending"||o.audio_status==="pending")&&l.pendingCount++,(o.infographic_status==="generating"||o.audio_status==="generating")&&l.generatingCount++}),(r||[]).map(o=>{const l=d.get(o.id)||{errorCount:0,pendingCount:0,generatingCount:0,lastError:null};return{...o,cover_url:o.cover_url||null,last_error:o.last_error||l.lastError,consecutive_failures:o.consecutive_failures||0,paused_at:o.paused_at||null,pause_reason:o.pause_reason||null,errorCount:l.errorCount,pendingCount:l.pendingCount,generatingCount:l.generatingCount}})}async getChapterDetails(t){const{data:s,error:r}=await v.from("chapter_pipeline").select("id, book_id, chapter_number, title, slug, blueprint_status, infographic_status, audio_status, infographic_url, audio_url, last_error, context_generated, created_at, updated_at").eq("book_id",t).order("chapter_number");return r?(console.error("Failed to fetch chapter details:",r),[]):s||[]}async getRecentSessions(t=20){const{data:s,error:r}=await v.from("agent_sessions").select("id, session_id, started_at, ended_at, status, books_processed, chapters_attempted, chapters_completed, chapters_failed, total_decisions, success_rate, first_attempt_success_rate, learnings").order("started_at",{ascending:!1}).limit(t);return r?(console.error("Failed to fetch sessions:",r),[]):s||[]}async getSessionDecisions(t){const{data:s,error:r}=await v.from("agent_decisions").select("id, session_id, decision_id, timestamp, book_slug, chapter_number, decision_type, decision, reasoning, alternatives, outcome, outcome_details, execution_time_ms").eq("session_id",t).order("timestamp",{ascending:!0});return r?(console.error("Failed to fetch session decisions:",r),[]):s||[]}async getRecentDecisions(t=50,s){let r=v.from("agent_decisions").select("id, session_id, decision_id, timestamp, book_slug, chapter_number, decision_type, decision, reasoning, alternatives, outcome, outcome_details, execution_time_ms").order("timestamp",{ascending:!1}).limit(t);s&&(r=r.eq("decision_type",s));const{data:n,error:a}=await r;return a?(console.error("Failed to fetch decisions:",a),[]):n||[]}async getRecentEvents(t=30){const{data:s,error:r}=await v.from("agent_significant_events").select("id, session_id, event_type, timestamp, book_slug, chapter_number, context, impact, applied_learning").order("timestamp",{ascending:!1}).limit(t);return r?(console.error("Failed to fetch events:",r),[]):s||[]}async getLearningInsights(){const[t,s,r,n]=await Promise.all([v.from("agent_domain_knowledge").select("*").order("total_chapters",{ascending:!1}),v.from("agent_quality_patterns").select("*").order("usage_count",{ascending:!1}),v.from("agent_strategies").select("*").eq("is_active",!0).order("uses_count",{ascending:!1}),v.from("agent_failure_patterns").select("*").order("occurrences",{ascending:!1})]);return{domainKnowledge:t.data||[],qualityPatterns:s.data||[],strategies:r.data||[],failurePatterns:n.data||[]}}async resetChapterStatus(t,s){const r={last_error:null};s==="blueprint"?r.blueprint_status="pending":s==="infographic"?(r.infographic_status="pending",r.infographic_url=null):s==="audio"&&(r.audio_status="pending",r.audio_url=null);const{error:n}=await v.from("chapter_pipeline").update(r).eq("id",t);if(n)throw new Error(`Failed to reset chapter: ${n.message}`)}async unpauseBook(t){const{error:s}=await v.from("book_catalog").update({status:"in_progress",consecutive_failures:0,paused_at:null,pause_reason:null,last_error:null}).eq("id",t);if(s)throw new Error(`Failed to unpause book: ${s.message}`)}async resetBookErrors(t){const{data:s}=await v.from("chapter_pipeline").select("id, infographic_status, audio_status, blueprint_status").eq("book_id",t).or("infographic_status.eq.error,audio_status.eq.error,blueprint_status.eq.error");if(!s||s.length===0)return 0;for(const r of s){const n={last_error:null};r.blueprint_status==="error"&&(n.blueprint_status="pending"),r.infographic_status==="error"&&(n.infographic_status="pending"),r.audio_status==="error"&&(n.audio_status="pending"),await v.from("chapter_pipeline").update(n).eq("id",r.id)}return s.length}},k=new He,b={all:["agent"],health:()=>[...b.all,"health"],overview:()=>[...b.all,"overview"],pipeline:{all:()=>[...b.all,"pipeline"],books:t=>[...b.all,"pipeline","books",t],chapters:t=>[...b.all,"pipeline","chapters",t]},sessions:{all:()=>[...b.all,"sessions"],list:t=>[...b.all,"sessions","list",t],decisions:t=>[...b.all,"sessions","decisions",t]},decisions:{all:()=>[...b.all,"decisions"],list:(t,s)=>[...b.all,"decisions","list",t,s]},events:t=>[...b.all,"events",t],learning:()=>[...b.all,"learning"]};function me(){return A({queryKey:b.health(),queryFn:()=>k.checkAgentHealth(),refetchInterval:15e3,staleTime:1e4})}function Ke(){return A({queryKey:b.overview(),queryFn:()=>k.getPipelineOverview(),refetchInterval:3e4,staleTime:15e3})}function Ue(t){return A({queryKey:b.pipeline.books(t),queryFn:()=>k.getBooksPipeline(t),refetchInterval:3e4,staleTime:15e3})}function Ge(t){return A({queryKey:b.pipeline.chapters(t||""),queryFn:()=>k.getChapterDetails(t),refetchInterval:1e4,staleTime:5e3,enabled:!!t})}function Je(t=20){return A({queryKey:b.sessions.list(t),queryFn:()=>k.getRecentSessions(t),refetchInterval:6e4,staleTime:3e4})}function Qe(t){return A({queryKey:b.sessions.decisions(t||""),queryFn:()=>k.getSessionDecisions(t),enabled:!!t,staleTime:3e4})}function ze(t=50,s){return A({queryKey:b.decisions.list(t,s),queryFn:()=>k.getRecentDecisions(t,s),refetchInterval:3e4,staleTime:15e3})}function Ve(t=30){return A({queryKey:b.events(t),queryFn:()=>k.getRecentEvents(t),refetchInterval:3e4,staleTime:15e3})}function We(){return A({queryKey:b.learning(),queryFn:()=>k.getLearningInsights(),staleTime:1e3*60*5})}function Xe(){const t=G();return Y({mutationFn:({chapterId:s,field:r})=>k.resetChapterStatus(s,r),onSuccess:()=>{t.invalidateQueries({queryKey:b.pipeline.all()}),t.invalidateQueries({queryKey:b.overview()})}})}function Ye(){const t=G();return Y({mutationFn:s=>k.resetBookErrors(s),onSuccess:()=>{t.invalidateQueries({queryKey:b.pipeline.all()}),t.invalidateQueries({queryKey:b.overview()})}})}function Ze(){const t=G();return Y({mutationFn:s=>k.unpauseBook(s),onSuccess:()=>{t.invalidateQueries({queryKey:b.pipeline.all()}),t.invalidateQueries({queryKey:b.overview()})}})}var e=he();function P({label:t,value:s,icon:r,color:n,sub:a}){return(0,e.jsxs)("div",{className:"bg-white dark:bg-stone-900 border border-stone-200 dark:border-stone-700 rounded-xl p-4",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,e.jsx)("span",{className:"text-xs font-medium text-stone-500 uppercase tracking-wider",children:t}),(0,e.jsx)("div",{className:`p-1.5 rounded-lg ${n}`,children:(0,e.jsx)(r,{className:"w-4 h-4"})})]}),(0,e.jsx)("div",{className:"text-2xl font-bold text-stone-900 dark:text-white",children:s}),a&&(0,e.jsx)("div",{className:"text-xs text-stone-500 mt-1",children:a})]})}function M({label:t,count:s,total:r,color:n}){const a=r>0?s/r*100:0;return(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[(0,e.jsx)("span",{className:"text-xs text-stone-500 w-20 shrink-0",children:t}
1),(0,e.jsx)("div",{className:"flex-1 h-2 bg-stone-100 dark:bg-stone-800 rounded-full overflow-hidden",children:(0,e.jsx)("div",{className:`h-full rounded-full ${n}`,style:{width:`${a}%`}})}),(0,e.jsx)("span",{className:"text-xs font-medium text-stone-700 dark:text-stone-300 w-12 text-right",children:s})]})}var et={breakthrough:"text-emerald-600 bg-emerald-50",failure:"text-red-600 bg-red-50",discovery:"text-blue-600 bg-blue-50",optimization:"text-gold-600 bg-gold-50"};function tt(){const{data:t,isLoading:s}=Ke(),{data:r}=Ve(10);return s||!t?(0,e.jsx)("div",{className:"flex items-center justify-center h-64",children:(0,e.jsx)(O,{className:"w-6 h-6 animate-spin text-stone-400"})}):(0,e.jsxs)("div",{className:"p-6 space-y-6",children:[(0,e.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-4",children:[(0,e.jsx)(P,{label:"Total Books",value:t.totalBooks,icon:ne,color:"bg-gold-100 text-gold-600"}),(0,e.jsx)(P,{label:"Published",value:t.publishedBooks,icon:Z,color:"bg-emerald-100 text-emerald-600"}),(0,e.jsx)(P,{label:"In Progress",value:t.inProgressBooks,icon:ee,color:"bg-gold-100 text-gold-600"}),(0,e.jsx)(P,{label:"Completion",value:`${t.completionPercentage}%`,icon:Ae,color:"bg-blue-100 text-blue-600",sub:`${t.completedChapters}/${t.totalChapters} chapters`}),(0,e.jsx)(P,{label:"Error Chapters",value:t.errorChapters,icon:Te,color:"bg-red-100 text-red-600",sub:`${t.errorBooks} books affected`}),(0,e.jsx)(P,{label:"Generating",value:t.generatingChapters,icon:K,color:"bg-cyan-100 text-cyan-600",sub:`${t.pendingChapters} pending`}),t.needsReviewBooks>0&&(0,e.jsx)(P,{label:"Needs Review",value:t.needsReviewBooks,icon:V,color:"bg-yellow-100 text-yellow-600",sub:"Auto-paused books"})]}),(0,e.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[(0,e.jsxs)("div",{className:"bg-white dark:bg-stone-900 border border-stone-200 dark:border-stone-700 rounded-xl p-5",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 mb-4",children:[(0,e.jsx)(je,{className:"w-4 h-4 text-stone-500"}),(0,e.jsx)("h3",{className:"font-semibold text-stone-900 dark:text-white",children:"Chapter Status Distribution"})]}),(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsx)(M,{label:"Complete",count:t.completedChapters,total:t.totalChapters,color:"bg-emerald-500"}),(0,e.jsx)(M,{label:"Pending",count:t.pendingChapters,total:t.totalChapters,color:"bg-stone-400"}),(0,e.jsx)(M,{label:"Generating",count:t.generatingChapters,total:t.totalChapters,color:"bg-gold-500"}),(0,e.jsx)(M,{label:"Error",count:t.errorChapters,total:t.totalChapters,color:"bg-red-500"})]}),(0,e.jsxs)("div",{className:"mt-6 pt-4 border-t border-stone-100 dark:border-stone-800",children:[(0,e.jsx)("h4",{className:"text-xs font-medium text-stone-500 uppercase tracking-wider mb-3",children:"Book Status"}),(0,e.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("div",{className:"w-2.5 h-2.5 rounded-full bg-emerald-500"}
1),(0,e.jsxs)("span",{className:"text-sm text-stone-600 dark:text-stone-400",children:["Published: ",t.publishedBooks]})]}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("div",{className:"w-2.5 h-2.5 rounded-full bg-gold-500"}),(0,e.jsxs)("span",{className:"text-sm text-stone-600 dark:text-stone-400",children:["In Progress: ",t.inProgressBooks]})]}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("div",{className:"w-2.5 h-2.5 rounded-full bg-blue-500"}),(0,e.jsxs)("span",{className:"text-sm text-stone-600 dark:text-stone-400",children:["Completed: ",t.completedBooks]})]}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("div",{className:"w-2.5 h-2.5 rounded-full bg-stone-400"}),(0,e.jsxs)("span",{className:"text-sm text-stone-600 dark:text-stone-400",children:["Planned: ",t.plannedBooks]})]}),t.needsReviewBooks>0&&(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("div",{className:"w-2.5 h-2.5 rounded-full bg-yellow-500"}
1),(0,e.jsxs)("span",{className:"text-sm text-stone-600 dark:text-stone-400",children:["Needs Review: ",t.needsReviewBooks]})]})]})]})]}),(0,e.jsxs)("div",{className:"bg-white dark:bg-stone-900 border border-stone-200 dark:border-stone-700 rounded-xl p-5",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 mb-4",children:[(0,e.jsx)(ge,{className:"w-4 h-4 text-stone-500"}),(0,e.jsx)("h3",{className:"font-semibold text-stone-900 dark:text-white",children:"Recent Agent Activity"})]}),(0,e.jsx)("div",{className:"space-y-3 max-h-72 overflow-y-auto",children:!r||r.length===0?(0,e.jsx)("div",{className:"text-sm text-stone-400 text-center py-8",children:"No recent events recorded"}):r.map(n=>(0,e.jsxs)("div",{className:"flex items-start gap-3 py-2 border-b border-stone-50 dark:border-stone-800 last:border-0",children:[(0,e.jsx)("span",{className:`px-2 py-0.5 rounded text-[10px] uppercase font-medium shrink-0 ${et[n.event_type]||"text-stone-600 bg-stone-100"}`,children:n.event_type}),(0,e.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,e.jsx)("p",{className:"text-sm text-stone-700 dark:text-stone-300 line-clamp-2",children:n.context}),(0,e.jsxs)("div",{className:"flex items-center gap-2 mt-1 text-xs text-stone-400",children:[n.book_slug&&(0,e.jsx)("span",{children:n.book_slug}),n.chapter_number!=null&&(0,e.jsxs)("span",{children:["Ch.",n.chapter_number]}),(0,e.jsx)("span",{children:new Date(n.timestamp).toLocaleString()})]})]})]},n.id))})]})]})]})}function z({status:t}){const s={pending:"bg-stone-100 text-stone-500 dark:bg-stone-800 dark:text-stone-400",generating:"bg-gold-100 text-gold-700 dark:bg-gold-900/30 dark:text-gold-400",passed:"bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400",complete:"bg-emerald-100 text-emerald-700 dark:bg-emerald-900/30 dark:text-emerald-400",error:"bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400"};return(0,e.jsx)("span",{className:`px-2 py-0.5 rounded text-[10px] uppercase tracking-wide font-medium ${s[t||"pending"]||s.pending}`,children:t||"pending"})}function st({status:t}){const s={planned:"bg-stone-100 text-stone-600",in_progress:"bg-gold-100 text-gold-800",completed:"bg-blue-100 text-blue-800",published:"bg-emerald-100 text-emerald-800",needs_review:"bg-yellow-100 text-yellow-800"};return(0,e.jsx)("span",{className:`px-2 py-1 text-xs rounded-full font-medium ${s[t]||s.planned}`,children:t})}function rt({completed:t,total:s}){const r=s>0?Math.round(t/s*100):0;return(0,e.jsxs)("div",{className:"flex items-center gap-2 min-w-[120px]",children:[(0,e.jsx)("div",{className:"flex-1 h-1.5 bg-stone-100 dark:bg-stone-800 rounded-full overflow-hidden",children:(0,e.jsx)("div",{className:`h-full rounded-full transition-all ${r===100?"bg-emerald-500":r>0?"bg-gold-500":"bg-stone-300"}`,style:{width:`${r}%`}})}),(0,e.jsxs)("span",{className:"text-xs text-stone-500 w-14 text-right",children:[t,"/",s]})]})}function at({bookId:t,bookSlug:s}){const{data:r,isLoading:n}=Ge(t),a=Xe();if(n)return(0,e.jsx)("div",{className:"p-4 text-center",children:(0,e.jsx)(O,{className:"w-4 h-4 animate-spin inline-block text-stone-400"})});if(!r||r.length===0)return(0,e.jsx)("div",{className:"p-4 text-center text-sm text-stone-400",children:"No chapters found"});const u=(d,o)=>{a.mutate({chapterId:d,field:o})};return(0,e.jsx)("div",{className:"overflow-x-auto",children:(0,e.jsxs)("table",{className:"w-full text-sm",children:[(0,e.jsx)("thead",{children:(0,e.jsxs)("tr",{className:"text-left text-stone-500 border-b border-stone-100 dark:border-stone-800",children:[(0,e.jsx)("th",{className:"pb-2 px-3 font-medium w-12",children:"Ch"}),(0,e.jsx)("th",{className:"pb-2 px-3 font-medium",children:"Title"}),(0,e.jsx)("th",{className:"pb-2 px-3 font-medium",children:"Blueprint"}),(0,e.jsx)("th",{className:"pb-2 px-3 font-medium",children:"Infographic"}),(0,e.jsx)("th",{className:"pb-2 px-3 font-medium",children:"Audio"}),(0,e.jsx)("th",{className:"pb-2 px-3 font-medium",children:"Error"}),(0,e.jsx)("th",{className:"pb-2 px-3 font-medium text-right",children:"Actions"})]})}),(0,e.jsx)("tbody",{className:"divide-y divide-stone-50 dark:divide-stone-800",children:r.map(d=>(0,e.jsxs)("tr",{className:"hover:bg-stone-50/50 dark:hover:bg-stone-800/30",children:[(0,e.jsxs)("td",{className:"py-2.5 px-3 text-stone-400",children:["#",d.chapter_number]}),(0,e.jsx)("td",{className:"py-2.5 px-3 font-medium text-stone-800 dark:text-stone-200 max-w-[200px] truncate",children:d.title||"Untitled"}),(0,e.jsx)("td",{className:"py-2.5 px-3",children:(0,e.jsx)(z,{status:d.blueprint_status})}),(0,e.jsx)("td",{className:"py-2.5 px-3",children:(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(z,{status:d.infographic_status}),d.infographic_url&&(0,e.jsx)("a",{href:d.infographic_url,target:"_blank",rel:"noopener noreferrer",className:"text-stone-400 hover:text-gold-500",children:(0,e.jsx)(W,{className:"w-3 h-3"})})]})}),(0,e.jsx)("td",{className:"py-2.5 px-3",children:(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(z,{status:d.audio_status}),d.audio_url&&(0,e.jsx)("a",{href:d.audio_url,target:"_blank",rel:"noopener noreferrer",className:"text-stone-400 hover:text-gold-500",children:(0,e.jsx)(W,{className:"w-3 h-3"})})]})}),(0,e.jsx)("td",{className:"py-2.5 px-3 max-w-[200px]",children:d.last_error?(0,e.jsx)("span",{className:"text-xs text-red-600 line-clamp-2",title:d.last_error,children:d.last_error}):(0,e.jsx)("span",{className:"text-stone-300",children:"-"})}),(0,e.jsx)("td",{className:"py-2.5 px-3 text-right",children:(0,e.jsxs)("div",{className:"flex items-center justify-end gap-1",children:[d.blueprint_status==="error"&&(0,e.jsx)("button",{onClick:()=>u(d.id,"blueprint"),className:"text-xs text-gold-600 hover:bg-gold-50 dark:hover:bg-gold-900/20 px-2 py-1 rounded",title:"Reset blueprint",children:"BP"}),(d.infographic_status==="error"||d.infographic_status==="generating")&&(0,e.jsx)("button",{onClick:()=>u(d.id,"infographic"),className:"text-xs text-blue-600 hover:bg-blue-50 dark:hover:bg-blue-900/20 px-2 py-1 rounded",title:"Reset infographic",children:(0,e.jsx)(ce,{className:"w-3 h-3"})}),(d.audio_status==="error"||d.audio_status==="generating")&&(0,e.jsx)("button",{onClick:()=>u(d.id,"audio"),className:"text-xs text-orange-600 hover:bg-orange-50 dark:hover:bg-orange-900/20 px-2 py-1 rounded",title:"Reset audio",children:(0,e.jsx)(Ie,{className:"w-3 h-3"})})]})})]},d.id))})]})})}function nt(){const[t,s]=(0,c.useState)({status:"all",search:""}),[r,n]=(0,c.useState)(null),{data:a,isLoading:u}=Ue(t),d=Ye(),o=Ze();return u?(0,e.jsx)("div",{className:"flex items-center justify-center h-64",children:(0,e.jsx)(O,{className:"w-6 h-6 animate-spin text-stone-400"})}):(0,e.jsxs)("div",{className:"p-6 space-y-4",children:[(0,e.jsxs)("div",{className:"flex items-center gap-4",children:[(0,e.jsxs)("div",{className:"relative flex-1 max-w-sm",children:[(0,e.jsx)(Pe,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-stone-400"}),(0,e.jsx)("input",{type:"text",placeholder:"Search books...",value:t.search||"",onChange:l=>s(m=>({...m,search:l.target.value})),className:"w-full pl-10 pr-3 py-2 text-sm border border-stone-200 dark:border-stone-700 rounded-lg bg-white dark:bg-stone-900 focus:ring-2 focus:ring-gold-500 outline-none"})]}),(0,e.jsx)("div",{className:"flex items-center gap-1 bg-stone-100 dar
1k:bg-stone-800 p-1 rounded-lg",children:["all","in_progress","published","completed","planned","needs_review"].map(l=>(0,e.jsx)("button",{onClick:()=>s(m=>({...m,status:l})),className:`px-3 py-1.5 text-xs font-medium rounded-md transition-colors ${t.status===l?"bg-white dark:bg-stone-700 text-stone-900 dark:text-white shadow-sm":"text-stone-500 hover:text-stone-700 dark:hover:text-stone-300"}`,children:l==="all"?"All":l.replace("_"," ")},l))})]}),(0,e.jsx)("div",{className:"space-y-2",children:!a||a.length===0?(0,e.jsx)("div",{className:"text-center py-12 text-stone-400",children:"No books found"}):a.map(l=>(0,e.jsxs)("div",{className:"border border-stone-200 dark:border-stone-700 rounded-lg overflow-hidden",children:[(0,e.jsxs)("div",{className:"p-4 bg-white dark:bg-stone-900 flex items-center justify-between cursor-pointer hover:bg-stone-50 dark:hover:bg-stone-800/50 transition-colors",onClick:()=>n(r===l.id?null:l.id),children:[(0,e.jsxs)("div",{className:"flex items-center gap-4 min-w-0",children:[(0,e.jsx)("div",{className:"text-stone-400",children:r===l.id?(0,e.jsx)(oe,{className:"w-4 h-4"}):(0,e.jsx)(le,{className:"w-4 h-4"})}),(0,e.jsx)("div",{className:"w-8 h-11 bg-stone-100 dark:bg-stone-800 rounded flex items-center justify-center overflow-hidden shrink-0",children:l.cover_url?(0,e.jsx)("img",{src:l.cover_url,className:"w-full h-full object-cover",alt:"",loading:"lazy"}):(0,e.jsx)("span",{className:"text-[8px] text-stone-400",children:"N/A"})}),(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsx)("h3",{className:"font-medium text-stone-900 dark:text-white truncate",children:l.title}),(0,e.jsxs)("p",{className:"text-xs text-stone-500",children:[l.author," · ",l.domain_slug]})]})]}),(0,e.jsxs)("div",{className:"flex items-center gap-4 shrink-0",children:[l.status==="needs_review"&&(0,e.jsxs)("div",{className:"flex items-center gap-1.5 text-yellow-600",children:[(0,e.jsx)(V,{className:"w-3.5 h-3.5"}),(0,e.jsx)("span",{className:"text-xs font-medium",children:"Paused"})]}),l.errorCount>0&&(0,e.jsxs)("div",{className:"flex items-center gap-1.5 text-red-600",children:[(0,e.jsx)(ie,{className:"w-3.5 h-3.5"}),(0,e.jsx)("span",{className:"text-xs font-medium",children:l.errorCount})]}),(0,e.jsx)(rt,{completed:l.completed_chapters,total:l.total_chapters}),(0,e.jsx)(st,{status:l.status})]})]}),r===l.id&&(0,e.jsxs)("div",{className:"border-t border-stone-200 dark:border-stone-700 bg-stone-50/50 dark:bg-stone-950/50",children:[l.status==="needs_review"&&(0,e.jsxs)("div",{className:"px-4 pt-3 flex items-center justify-between bg-yellow-50 dark:bg-yellow-900/10 border-b border-yellow-200 dark:border-yellow-800",children:[(0,e.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 text-yellow-800 dark:text-yellow-400",children:[(0,e.jsx)(V,{className:"w-4 h-4 shrink-0"}),(0,e.jsx)("span",{className:"text-xs font-medium",children:"Auto-paused"}),l.paused_at&&(0,e.jsxs)("span",{className:"text-[10px] text-yellow-600",children:["(",new Date(l.paused_at).toLocaleString(),")"]})]}),l.pause_reason&&(0,e.jsx)("p",{className:"text-xs text-yellow-700 dark:text-yellow-500 mt-1 line-clamp-2",children:l.pause_reason})]}),(0,e.jsxs)("button",{onClick:m=>{m.stopPropagation(),o.mutate(l.id)},disabled:o.isPending,className:"flex items-center gap-1 text-xs font-medium text-yellow-800 hover:bg-yellow-100 dark:hover:bg-yellow-900/30 px-3 py-1.5 rounded-md border border-yellow-300 dark:border-yellow-700 shrink-0 ml-3",children:[(0,e.jsx)(xe,{className:"w-3 h-3"}),"Unpause"]})]}),l.errorCount>0&&(0,e.jsxs)("div",{className:"px-4 pt-3 flex items-center justify-between",children:[(0,e.jsxs)("span",{className:"text-xs text-red-600",children:[l.errorCount," chapter(s) with errors"]}),(0,e.jsxs)("button",{onClick:m=>{m.stopPropagation(),d.mutate(l.id)},disabled:d.isPending,className:"flex items-center gap-1 text-xs text-red-600 hover:bg-red-50 dark:hover:bg-red-900/20 px-2 py-1 rounded",children:[(0,e.jsx)(we,{className:"w-3 h-3"}),"Reset All Errors"]})]}),(0,e.jsx)("div",{className:"p-4",children:(0,e.jsx)(at,{bookId:l.id,bookSlug:l.slug})})]})]},l.id))})]})}function ot(t,s){if(!s)return"Running...";const r=new Date(s).getTime()-new Date(t).getTime(),n=Math.floor(r/6e4),a=Math.floor(r%6e4/1e3);return n>60?`${Math.floor(n/60)}h ${n%60}m`:n>0?`${n}m ${a}s`:`${a}s`}function lt({sessionId:t}){const{data:s,isLoading:r}=Qe(t);return r?(0,e.jsx)("div",{className:"p-4 text-center",children:(0,e.jsx)(O,{className:"w-4 h-4 animate-spin inline-block text-stone-400"})}):!s||s.length===0?(0,e.jsx)("div",{className:"p-4 text-center text-sm text-stone-400",children:"No decisions recorded for this session"}):(0,e.jsx)("div",{className:"overflow-x-auto",children:(0,e.jsxs)("table",{className:"w-full text-sm",children:[(0,e.jsx)("thead",{children:(0,e.jsxs)("tr",{className:"text-left text-stone-500 border-b border-stone-100 dar
1k:border-stone-800",children:[(0,e.jsx)("th",{className:"pb-2 px-3 font-medium",children:"Time"}),(0,e.jsx)("th",{className:"pb-2 px-3 font-medium",children:"Type"}),(0,e.jsx)("th",{className:"pb-2 px-3 font-medium",children:"Book"}),(0,e.jsx)("th",{className:"pb-2 px-3 font-medium",children:"Decision"}),(0,e.jsx)("th",{className:"pb-2 px-3 font-medium",children:"Outcome"}),(0,e.jsx)("th",{className:"pb-2 px-3 font-medium",children:"Duration"})]})}),(0,e.jsx)("tbody",{className:"divide-y divide-stone-50 dark:divide-stone-800",children:s.map(n=>(0,e.jsxs)("tr",{className:"hover:bg-stone-50/50 dark:hover:bg-stone-800/30",children:[(0,e.jsx)("td",{className:"py-2 px-3 text-xs text-stone-400 whitespace-nowrap",children:new Date(n.timestamp).toLocaleTimeString()}),(0,e.jsx)("td",{className:"py-2 px-3",children:(0,e.jsx)("span",{className:"px-2 py-0.5 rounded text-[10px] uppercase font-medium bg-stone-100 text-stone-600 dark:bg-stone-800 dark:text-stone-400",children:n.decision_type})}),(0,e.jsxs)("td",{className:"py-2 px-3 text-xs text-stone-600 dar
1k:text-stone-400",children:[n.book_slug||"-",n.chapter_number!=null&&(0,e.jsxs)("span",{className:"text-stone-400",children:[" Ch.",n.chapter_number]})]}),(0,e.jsxs)("td",{className:"py-2 px-3 max-w-[300px]",children:[(0,e.jsx)("p",{className:"text-sm text-stone-700 dark:text-stone-300 truncate",children:n.decision}),n.reasoning&&(0,e.jsx)("p",{className:"text-xs text-stone-400 truncate mt-0.5",title:n.reasoning,children:n.reasoning})]}),(0,e.jsxs)("td",{className:"py-2 px-3",children:[n.outcome==="success"&&(0,e.jsx)("span",{className:"text-emerald-600 text-xs font-medium",children:"Success"}),n.outcome==="failure"&&(0,e.jsx)("span",{className:"text-red-600 text-xs font-medium",children:"Failed"}),n.outcome==="partial"&&(0,e.jsx)("span",{className:"text-gold-600 text-xs font-medium",children:"Partial"}),!n.outcome&&(0,e.jsx)("span",{className:"text-stone-300 text-xs",children:"-"})]}),(0,e.jsx)("td",{className:"py-2 px-3 text-xs text-stone-400",children:n.execution_time_ms?`${(n.execution_time_ms/1e3).toFixed(1)}s`:"-"})]},n.id))})]})})}function it(){const{data:t,isLoading:s}=Je(),[r,n]=(0,c.useState)(null);return s?(0,e.jsx)("div",{className:"flex items-center justify-center h-64",children:(0,e.jsx)(O,{className:"w-6 h-6 animate-spin text-stone-400"})}):!t||t.length===0?(0,e.jsx)("div",{className:"flex items-center justify-center h-64 text-stone-400",children:"No agent sessions found. Sessions are recorded when the agent runs."}):(0,e.jsx)("div",{className:"p-6 space-y-3",children:t.map(a=>(0,e.jsxs)("div",{className:"border border-stone-200 dark:border-stone-700 rounded-lg overflow-hidden",children:[(0,e.jsxs)("div",{className:"p-4 bg-white dark:bg-stone-900 flex items-center justify-between cursor-pointer hover:bg-stone-50 dark:hover:bg-stone-800/50 transition-colors",onClick:()=>n(r===a.session_id?null:a.session_id),children:[(0,e.jsxs)("div",{className:"flex items-center gap-4",children:[(0,e.jsx)("div",{className:"text-stone-400",children:r===a.session_id?(0,e.jsx)(oe,{className:"w-4 h-4"}):(0,e.jsx)(le,{className:"w-4 h-4"})}),(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("span",{className:`w-2 h-2 rounded-full ${a.status==="running"?"bg-gold-500 animate-pulse":a.status==="completed"?"bg-emerald-500":"bg-red-500"}`}),(0,e.jsx)("span",{className:"font-medium text-stone-900 dark:text-white text-sm",children:new Date(a.started_at).toLocaleString()}),(0,e.jsxs)("span",{className:"text-xs text-stone-400",children:["(",ot(a.started_at,a.ended_at),")"]})]}),(0,e.jsxs)("div",{className:"text-xs text-stone-500 mt-1",children:[(a.books_processed||[]).length," books · ",a.total_decisions," decisions"]})]})]}),(0,e.jsxs)("div",{className:"flex items-center gap-6 text-sm",children:[(0,e.jsxs)("div",{className:"flex items-center gap-1.5 text-emerald-600",children:[(0,e.jsx)(Z,{className:"w-3.5 h-3.5"}),(0,e.jsx)("span",{children:a.chapters_completed})]}),(0,e.jsxs)("div",{className:"flex items-center gap-1.5 text-red-600",children:[(0,e.jsx)(de,{className:"w-3.5 h-3.5"}),(0,e.jsx)("span",{children:a.chapters_failed})]}),(0,e.jsxs)("div",{className:"flex items-center gap-1.5 text-stone-500",children:[(0,e.jsx)(ee,{className:"w-3.5 h-3.5"}),(0,e.jsx)("span",{children:a.chapters_attempted})]}),(0,e.jsxs)("div",{className:"text-xs text-stone-500",children:[(a.success_rate*100).toFixed(0),"% success"]})]})]}),r===a.session_id&&(0,e.jsxs)("div",{className:"border-t border-stone-200 dark:border-stone-700 bg-stone-50/50 dark:bg-stone-950/50 p-4",children:[a.learnings&&a.learnings.length>0&&(0,e.jsxs)("div",{className:"mb-4 p-3 bg-blue-50 dark:bg-blue-900/20 rounded-lg",children:[(0,e.jsx)("h4",{className:"text-xs font-semibold text-blue-700 dark:text-blue-400 uppercase mb-2",children:"Session Learnings"}),(0,e.jsx)("ul",{className:"space-y-1",children:a.learnings.map((u,d)=>(0,e.jsx)("li",{className:"text-sm text-blue-800 dark:text-blue-300",children:typeof u=="string"?u:JSON.stringify(u)},d))})]}),(0,e.jsx)(lt,{sessionId:a.session_id})]})]},a.id))})}var dt=["all","book_selection","chapter_priority","repair_action","qa_retry","skip_chapter"],ct={success:"bg-emerald-100 text-emerald-700 dark:bg-emerald-900/30 dark:text-emerald-400",failure:"bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400",partial:"bg-gold-100 text-gold-700 dark:bg-gold-900/30 dark:text-gold-400"};
1function xt(){const[t,s]=(0,c.useState)("all"),{data:r,isLoading:n}=ze(50,t==="all"?void 0:t);return n?(0,e.jsx)("div",{className:"flex items-center justify-center h-64",children:(0,e.jsx)(O,{className:"w-6 h-6 animate-spin text-stone-400"})}):(0,e.jsxs)("div",{className:"p-6 space-y-4",children:[(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[(0,e.jsx)(Ne,{className:"w-4 h-4 text-stone-400"}),(0,e.jsx)("div",{className:"flex items-center gap-1 bg-stone-100 dark:bg-stone-800 p-1 rounded-lg flex-wrap",children:dt.map(a=>(0,e.jsx)("button",{onClick:()=>s(a),className:`px-3 py-1.5 text-xs font-medium rounded-md transition-colors ${t===a?"bg-white dark:bg-stone-700 text-stone-900 dark:text-white shadow-sm":"text-stone-500 hover:text-stone-700 dark:hover:text-stone-300"}`,children:a==="all"?"All":a.replace(/_/g," ")},a))})]}),!r||r.length===0?(0,e.jsx)("div",{className:"text-center py-12 text-stone-400",children:"No decisions found"}):(0,e.jsx)("div",{className:"overflow-x-auto border border-stone-200 dark:border-stone-700 rounded-lg",children:(0,e.jsxs)("table",{className:"w-full text-sm",children:[(0,e.jsx)("thead",{children:(0,e.jsxs)("tr",{className:"text-left text-stone-500 bg-stone-50 dark:bg-stone-800/50 border-b border-stone-200 dark:border-stone-700",children:[(0,e.jsx)("th",{className:"py-3 px-4 font-medium",children:"Timestamp"}),(0,e.jsx)("th",{className:"py-3 px-4 font-medium",children:"Type"}),(0,e.jsx)("th",{className:"py-3 px-4 font-medium",children:"Book / Chapter"}),(0,e.jsx)("th",{className:"py-3 px-4 font-medium",children:"Decision"}),(0,e.jsx)("th",{className:"py-3 px-4 font-medium",children:"Reasoning"}),(0,e.jsx)("th",{className:"py-3 px-4 font-medium",children:"Outcome"}),(0,e.jsx)("th",{className:"py-3 px-4 font-medium",children:"Time"})]})}),(0,e.jsx)("tbody",{className:"divide-y divide-stone-100 dark:divide-stone-800",children:r.map(a=>(0,e.jsxs)("tr",{className:"hover:bg-stone-50/50 dark:hover:bg-stone-800/30",children:[(0,e.jsx)("td",{className:"py-3 px-4 text-xs text-stone-400 whitespace-nowrap",children:new Date(a.timestamp).toLocaleString()}),(0,e.jsx)("td",{className:"py-3 px-4",children:(0,e.jsx)("span",{className:"px-2 py-0.5 rounded text-[10px] uppercase font-medium bg-gold-100 text-gold-700 dark:bg-gold-900/30 dark:text-gold-400",children:a.decision_type})}
1),(0,e.jsx)("td",{className:"py-3 px-4 text-stone-600 dark:text-stone-400",children:(0,e.jsxs)("div",{className:"text-xs",children:[a.book_slug||"-",a.chapter_number!=null&&(0,e.jsxs)("span",{className:"text-stone-400 ml-1",children:["Ch.",a.chapter_number]})]})}),(0,e.jsx)("td",{className:"py-3 px-4 max-w-[250px]",children:(0,e.jsx)("p",{className:"text-sm text-stone-700 dark:text-stone-300 truncate",title:a.decision,children:a.decision})}),(0,e.jsx)("td",{className:"py-3 px-4 max-w-[250px]",children:(0,e.jsx)("p",{className:"text-xs text-stone-500 truncate",title:a.reasoning||"",children:a.reasoning||"-"})}),(0,e.jsx)("td",{className:"py-3 px-4",children:a.outcome?(0,e.jsx)("span",{className:`px-2 py-0.5 rounded text-[10px] uppercase font-medium ${ct[a.outcome]||"bg-stone-100 text-stone-500"}`,children:a.outcome}):(0,e.jsx)("span",{className:"text-stone-300 text-xs",children:"-"})}),(0,e.jsx)("td",{className:"py-3 px-4 text-xs text-stone-400",children:a.execution_time_ms?`${(a.execution_time_ms/1e3).toFixed(1)}s`:"-"})]},a.id))})]})})]})}function J({message:t}){return(0,e.jsx)("div",{className:"text-center py-8 text-stone-400 text-sm",children:t})}function mt({domains:t}){return t.length===0?(0,e.jsx)(J,{message:"No domain knowledge recorded yet"}):(0,e.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:t.map(s=>(0,e.jsxs)("div",{className:"bg-white dark:bg-stone-900 border border-stone-200 dark:border-stone-700 rounded-xl p-4",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,e.jsx)("h4",{className:"font-semibold text-stone-900 dark:text-white capitalize",children:s.domain_slug}),(0,e.jsxs)("div",{className:"flex items-center gap-2 text-xs text-stone-500",children:[(0,e.jsxs)("span",{children:[s.total_chapters," chapters"]}),(0,e.jsx)("span",{children:"·"}),(0,e.jsxs)("span",{children:[(s.success_rate*100).toFixed(0),"% success"]})]})]}),s.characteristics&&s.characteristics.length>0&&(0,e.jsxs)("div",{className:"mb-3",children:[(0,e.jsx)("h5",{className:"text-xs font-medium text-stone-500 uppercase mb-1",children:"Characteristics"}),(0,e.jsx)("div",{className:"flex flex-wrap gap-1",children:s.characteristics.slice(0,5).map((r,n)=>(0,e.jsx)("span",{className:"px-2 py-0.5 bg-stone-100 dark:bg-stone-800 text-stone-600 dar
1k:text-stone-400 text-xs rounded",children:typeof r=="string"?r:r.name||JSON.stringify(r)},n))})]}),s.successful_patterns&&s.successful_patterns.length>0&&(0,e.jsxs)("div",{className:"mb-3",children:[(0,e.jsx)("h5",{className:"text-xs font-medium text-emerald-600 uppercase mb-1",children:"Successful Patterns"}),(0,e.jsx)("ul",{className:"space-y-1",children:s.successful_patterns.slice(0,3).map((r,n)=>(0,e.jsx)("li",{className:"text-xs text-stone-600 dark:text-stone-400",children:typeof r=="string"?r:r.pattern||JSON.stringify(r)},n))})]}),s.avoid_patterns&&s.avoid_patterns.length>0&&(0,e.jsxs)("div",{children:[(0,e.jsx)("h5",{className:"text-xs font-medium text-red-600 uppercase mb-1",children:"Avoid"}),(0,e.jsx)("ul",{className:"space-y-1",children:s.avoid_patterns.slice(0,3).map((r,n)=>(0,e.jsx)("li",{className:"text-xs text-stone-500",children:typeof r=="string"?r:r.pattern||JSON.stringify(r)},n))})]})]},s.id))})}function ut({patterns:t}){if(t.length===0)return(0,e.jsx)(J,{message:"No quality patterns learned yet"});const s=t.reduce((r,n)=>{const a=n.pattern_type||"other";return r[a]||(r[a]=[]),r[a].push(n),r},{});return(0,e.jsx)("div",{className:"space-y-4",children:Object.entries(s).map(([r,n])=>(0,e.jsxs)("div",{children:[(0,e.jsx)("h4",{className:"text-xs font-semibold text-stone-500 uppercase tracking-wider mb-2",children:r}),(0,e.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:n.map(a=>(0,e.jsxs)("div",{className:"bg-white dark:bg-stone-900 border border-stone-200 dark:border-stone-700 rounded-lg p-3",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,e.jsx)("span",{className:"font-medium text-sm text-stone-800 dark:text-stone-200",children:a.pattern_name}),(0,e.jsxs)("span",{className:"text-xs text-stone-400",children:[a.usage_count," uses · ",(a.success_rate*100).toFixed(0),"%"]})]}),a.description&&(0,e.jsx)("p",{className:"text-xs text-stone-500 line-clamp-2",children:a.description})]},a.id))})]},r))})}function ht({strategies:t}){return t.length===0?(0,e.jsx)(J,{message:"No active strategies yet"}):(0,e.jsx)("div",{className:"space-y-3",children:t.map(s=>(0,e.jsxs)("div",{className:"bg-white dark:bg-stone-900 border border-stone-200 dark:border-stone-700 rounded-lg p-4",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("h4",{className:"font-medium text-stone-900 dark:text-white",children:s.name}),(0,e.jsx)("span",{className:"text-xs text-stone-400",children:s.scenario_type})]}),(0,e.jsxs)("div",{className:"text-right text-xs text-stone-500",children:[(0,e.jsxs)("div",{children:[s.uses_count," uses · ",(s.success_rate*100).toFixed(0),"% success"]}),s.last_used&&(0,e.jsxs)("div",{className:"text-stone-400",children:["Last: ",new Date(s.last_used).toLocaleDateString()]})]})]}),s.description&&(0,e.jsx)("p",{className:"text-sm text-stone-600 dar
1k:text-stone-400 mb-2",children:s.description}),s.steps&&Array.isArray(s.steps)&&s.steps.length>0&&(0,e.jsxs)("div",{className:"mt-2 pt-2 border-t border-stone-100 dark:border-stone-800",children:[(0,e.jsx)("h5",{className:"text-xs font-medium text-stone-500 mb-1",children:"Steps"}),(0,e.jsx)("ol",{className:"list-decimal list-inside space-y-0.5",children:s.steps.slice(0,5).map((r,n)=>(0,e.jsx)("li",{className:"text-xs text-stone-500",children:typeof r=="string"?r:r.description||JSON.stringify(r)},n))})]})]},s.id))})}function pt({patterns:t}){return t.length===0?(0,e.jsx)(J,{message:"No failure patterns recorded yet"}):(0,e.jsx)("div",{className:"space-y-3",children:t.map(s=>(0,e.jsxs)("div",{className:`border rounded-lg p-4 ${s.is_resolved?"border-stone-200 dark:border-stone-700 bg-white dark:bg-stone-900":"border-red-200 dark:border-red-900/50 bg-red-50/50 dark:bg-red-900/10"}`,children:[(0,e.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("span",{className:`w-2 h-2 rounded-full ${s.is_resolved?"bg-emerald-500":"bg-red-500"}`}),(0,e.jsx)("h4",{className:"font-medium text-stone-900 dark:text-white text-sm",children:s.pattern_key})]}),(0,e.jsxs)("span",{className:"text-xs text-stone-400",children:[s.occurrences," occurrences"]})]}),s.description&&(0,e.jsx)("p",{className:"text-sm text-stone-600 dar
1k:text-stone-400 mb-2",children:s.description}),s.resolution&&(0,e.jsxs)("div",{className:"mt-2 p-2 bg-emerald-50 dark:bg-emerald-900/20 rounded text-xs text-emerald-700 dark:text-emerald-400",children:[(0,e.jsx)("strong",{children:"Resolution:"})," ",s.resolution]}),s.prevention_strategy&&(0,e.jsxs)("div",{className:"mt-1 p-2 bg-blue-50 dark:bg-blue-900/20 rounded text-xs text-blue-700 dark:text-blue-400",children:[(0,e.jsx)("strong",{children:"Prevention:"})," ",s.prevention_strategy]})]},s.id))})}function gt(){const{data:t,isLoading:s}=We();return s||!t?(0,e.jsx)("div",{className:"flex items-center justify-center h-64",children:(0,e.jsx)(O,{className:"w-6 h-6 animate-spin text-stone-400"})}):(0,e.jsxs)("div",{className:"p-6 space-y-8",children:[(0,e.jsxs)("section",{children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 mb-4",children:[(0,e.jsx)(ne,{className:"w-5 h-5 text-gold-500"}),(0,e.jsx)(B,{variant:"h3",as:"h2",children:"Domain Knowledge"}),(0,e.jsxs)("span",{className:"text-xs text-stone-400 ml-2",children:[t.domainKnowledge.length," domains"]})]}),(0,e.jsx)(mt,{domains:t.domainKnowledge})]}),(0,e.jsxs)("section",{children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 mb-4",children:[(0,e.jsx)(Ee,{className:"w-5 h-5 text-gold-500"}),(0,e.jsx)(B,{variant:"h3",as:"h2",children:"Quality Patterns"}),(0,e.jsxs)("span",{className:"text-xs text-stone-400 ml-2",children:[t.qualityPatterns.length," patterns"]})]}),(0,e.jsx)(ut,{patterns:t.qualityPatterns})]}),(0,e.jsxs)("section",{children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 mb-4",children:[(0,e.jsx)(fe,{className:"w-5 h-5 text-blue-500"}),(0,e.jsx)(B,{variant:"h3",as:"h2",children:"Active Strategies"}),(0,e.jsxs)("span",{className:"text-xs text-stone-400 ml-2",children:[t.strategies.length," active"]})]}),(0,e.jsx)(ht,{strategies:t.strategies})]}),(0,e.jsxs)("section",{children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 mb-4",children:[(0,e.jsx)(ye,{className:"w-5 h-5 text-red-500"}),(0,e.jsx)(B,{variant:"h3",as:"h2",children:"Failure Patterns"}),(0,e.jsxs)("span",{className:"text-xs text-stone-400 ml-2",children:[t.failurePatterns.filter(r=>!r.is_resolved).length," unresolved / ",t.failurePatterns.length," total"]})]}),(0,e.jsx)(pt,{patterns:t.failurePatterns})]})]})}var U=re.url?.trim()||"";function _(){if(!U)throw new Error("Agent API unavailable. Set VITE_AGENT_API_URL to use admin agent operations.");return U}var T={async checkHealth(){if(!U)return!1;try{return(await fetch(`${_()}/health`)).status===200}catch{return!1}},async seedBook(t){const s=await fetch(`${_()}/seed`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!s.ok){const r=await s.json();throw new Error(r.error||"Failed to seed book")}return s.json()},async authorChapter(t){const s=await fetch(`${_()}/author`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({bookSlug:t.bookSlug,chapterNumber:t.chapterNumber,chapterTitle:t.chapterTitle,text:"AUTO_GENERATE"})});if(!s.ok){const r=await s.json();throw new Error(r.error||"Failed to author chapter")}return s.json()},async produceChapter(t,s){const{data:r}=await H.from("book_catalog").select("id").eq("slug",t).single();if(!r)throw new Error("Book not found");const{data:n}=await H.from("chapter_pipeline").select("blueprint_data, title").eq("book_id",r.id).eq("chapter_number",s).single();if(!n||!n.blueprint_data)throw new Error("Blueprint not found. Author chapter first.");const a=await fetch(`${_()}/produce`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({bookSlug:t,chapterNumber:s,chapterTitle:n.title,blueprint:n.blueprint_data})});if(!a.ok){const u=await a.json();throw new Error(u.error||"Failed to produce media")}return a.json()},async runOrchestratorBook(t){const s=await fetch(`${_()}/orchestrator/run-book`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({bookSlug:t})});if(!s.ok)throw new Error((await s.json()).error);return s.json()},async runOrchestratorChapter(t,s){const r=await fetch(`${_()}/orchestrator/run-chapter`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({bookSlug:t,chapterNumber:s})});if(!r.ok)throw new Error((await r.json()).error);return r.json()},async runOrchestratorMedia(t,s){const r=await fetch(`${_()}/orchestrator/run-media`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({bookSlug:t,chapterNumber:s})});if(!r.ok)throw new Error((await r.json()).error);return r.json()},async runOrchestratorNext(){const t=await fetch(`${_()}/orchestrator/run-next`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})});if(!t.ok)throw new Error((await t.json()).error);return t.json()},async getIncompleteBooks(){const t=await fetch(`${_()}/catalog/incomplete`);if(!t.ok)throw new Error((await t.json()).error);return(await t.json()).data||[]},async getRunReport(t){const s=await fetch(`${_()}/reports/${t}`);if(!s.ok)throw new Error((await s.json()).error);return s.json()},async getAgentLogs(){if(!U)return[];try{const t=await fetch(`${_()}/stream-logs`);return t.ok?(await t.json()).logs||[]:[]}catch{return[]}}};function te(t){if(!t)return null;const s=Date.now()-new Date(t).getTime();return s>10080*60*1e3?"Stale 7d+":s>1440*60*1e3?"Stale 24h+":null}function bt(){return(0,e.jsxs)("div",{className:"mb-6 p-4 bg-gold-50 dark:bg-gold-900/20 border border-gold-200 dark:border-gold-800 rounded-lg flex items-center gap-3",children:[(0,e.jsx)(Be,{className:"w-5 h-5 text-gold-600 shrink-0"}),(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"text-sm font-medium text-gold-800 dark:text-gold-200",children:"Agent Offline"}),(0,e.jsxs)("p",{className:"text-xs text-gold-600 dark:text-gold-400",children:["Operations require a configured agent HTTP API. Set ",(0,e.jsx)("code",{className:"font-mono",children:"VITE_AGENT_API_URL"})," and start the agent to use these controls."]})]})]})}function ft({disabled:t}){const[s,r]=(0,c.useState)(!1),[n,a]=(0,c.useState)(null),[u,d]=(0,c.useState)(null),[o,l]=(0,c.useState)(""),[m,x]=(0,c.useState)({title:"",author:"",domain:"money",context:""}),p=[{value:"money",label:"Money & Investing"},{value:"growth",label:"Personal Growth"},{value:"technology",label:"Technology & AI"},{value:"business",label:"Business & Leadership"}
1,{value:"psychology",label:"Psychology & Behavior"},{value:"health",label:"Health & Wellness"},{value:"science",label:"Science & Nature"},{value:"history",label:"History & Biography"},{value:"society",label:"Society & Culture"}],N=async f=>{if(f.preventDefault(),!!window.confirm(`Seed a new book for "${m.title}" by ${m.author}?`)){r(!0),d(null),a(null);try{a(`Book seeded successfully! Slug: ${(await T.seedBook(m)).data.slug}`),l(`Seeded new book ${m.title}.`),x({title:"",author:"",domain:"money",context:""})}catch(C){d(C.message),l("Book seed failed.")}finally{r(!1)}}};return(0,e.jsxs)("div",{className:"bg-white dark:bg-stone-900 border border-stone-200 dark:border-stone-700 rounded-xl p-6",children:[(0,e.jsx)("div",{className:"sr-only","aria-live":"polite",children:o}),(0,e.jsx)(B,{variant:"h3",className:"mb-1",children:"Seed New Book"}),(0,e.jsx)("p",{className:"text-sm text-stone-500 mb-4",children:"Initialize a new book in the catalog with cover generation and chapter pipeline."}),n&&(0,e.jsxs)("div",{className:"mb-4 p-3 bg-emerald-50 text-emerald-700 rounded-lg flex items-center gap-2 text-sm",children:[(0,e.jsx)(Se,{className:"w-4 h-4"}),n]}),u&&(0,e.jsxs)("div",{className:"mb-4 p-3 bg-red-50 text-red-700 rounded-lg flex items-center gap-2 text-sm",children:[(0,e.jsx)(ie,{className:"w-4 h-4"}),u]}),(0,e.jsxs)("form",{onSubmit:N,className:"space-y-4",children:[(0,e.jsxs)("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2",children:[(0,e.jsxs)("div",{className:"space-y-1",children:[(0,e.jsx)("label",{className:"text-xs font-medium text-stone-500",children:"Book Title"}),(0,e.jsx)("input",{type:"text",required:!0,value:m.title,disabled:t,onChange:f=>x({...m,title:f.target.value}),className:"w-full px-3 py-2 text-base border border-stone-200 dark:border-stone-700 rounded-lg bg-white dark:bg-stone-900 focus:ring-2 focus:ring-gold-500 outline-none disabled:opacity-50 sm:text-sm",placeholder:"e.g. The Psychology of Money"})]}),(0,e.jsxs)("div",{className:"space-y-1",children:[(0,e.jsx)("label",{className:"text-xs font-medium text-stone-500",children:"Author"}),(0,e.jsx)("input",{type:"text",required:!0,value:m.author,disabled:t,onChange:f=>x({...m,author:f.target.value}),className:"w-full px-3 py-2 text-base border border-stone-200 dark:border-stone-700 rounded-lg bg-white dark:bg-stone-900 focus:ring-2 focus:ring-gold-500 outline-none disabled:opacity-50 sm:text-sm",placeholder:"e.g. Morgan Housel"})]})]}),(0,e.jsxs)("div",{className:"space-y-1",children:[(0,e.jsx)("label",{className:"text-xs font-medium text-stone-500",children:"Domain"}),(0,e.jsx)("select",{value:m.domain,disabled:t,onChange:f=>x({...m,domain:f.target.value}),className:"w-full px-3 py-2 text-base border border-stone-200 dark:border-stone-700 rounded-lg bg-white dark:bg-stone-900 focus:ring-2 focus:ring-gold-500 outline-none disabled:opacity-50 sm:text-sm",children:p.map(f=>(0,e.jsx)("option",{value:f.value,children:f.label},f.value))})]}),(0,e.jsxs)("div",{className:"space-y-1",children:[(0,e.jsx)("label",{className:"text-xs font-medium text-stone-500",children:"Context (Optional)"}),(0,e.jsx)("textarea",{value:m.context,disabled:t,onChange:f=>x({...m,context:f.target.value}),className:"w-full px-3 py-2 text-base border border-stone-200 dark:border-stone-700 rounded-lg bg-white dark:bg-stone-900 focus:ring-2 focus:ring-gold-500 outline-none h-24 resize-none disabled:opacity-50 sm:text-sm",placeholder:"Additional context for the AI..."})]}),(0,e.jsxs)("button",{type:"submit",disabled:s||t,className:"w-full min-h-11 py-2.5 bg-gold-600 hover:bg-gold-700 text-white text-sm font-medium rounded-lg disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-center gap-2",children:[s?(0,e.jsx)(R,{className:"w-4 h-4 animate-spin"}):(0,e.jsx)(ke,{className:"w-4 h-4"}),s?"Seeding...":"Seed Book"]})]})]})}function jt({disabled:t}){const[s,r]=(0,c.useState)(""),[n,a]=(0,c.useState)(1),[u,d]=(0,c.useState)([]),[o,l]=(0,c.useState)([]),[m,x]=(0,c.useState)(!1),[p,N]=(0,c.useState)(!1),[f,C]=(0,c.useState)(null),[w,q]=(0,c.useState)(null),[y,E]=(0,c.useState)(null),[S,h]=(0,c.useState)(""),L=async()=>{try{const g=await T.getIncompleteBooks();d(g),C(null),!s&&g.length>0&&r(g[0].slug)}catch{d([]),C("Could not load available books from the agent. Try again after the agent is fully running.")}};(0,c.useEffect)(()=>{t||L()},[t]),(0,c.useEffect)(()=>{!m||t||T.getAgentLogs().then(g=>{g.length&&l(g)}).catch(()=>{})},[m,t]),(0,c.useEffect)(()=>
1{if(!p||t)return;const g=setInterval(async()=>{const $=await T.getAgentLogs();$.length&&l($)},2e3);return()=>clearInterval(g)},[p,t]);const F=async g=>{q(null),E(null);const $=g==="next"?"run the next available book":g==="book"?`run the full book ${s}`:g==="chapter"?`run chapter ${n} for ${s}`:`generate media for chapter ${n} in ${s}`;if(window.confirm(`Confirm ${$}?`))try{g==="next"?await T.runOrchestratorNext():g==="book"?await T.runOrchestratorBook(s):g==="chapter"?await T.runOrchestratorChapter(s,n):g==="media"&&await T.runOrchestratorMedia(s,n),N(!0),E(`Started ${$}.`),h(`Started ${$}.`)}catch(i){q(i?.message||"Could not start that operation right now."),h(`Failed to ${$}.`)}},Q=async()=>{try{await navigator.clipboard.writeText(o.join(` 2`)),h("Copied live agent logs.")}catch{h("Failed to copy live agent logs.")}};return(0,e.jsxs)("div",{className:"space-y-6",children:[(0,e.jsx)("div",{className:"sr-only","aria-live":"polite",children:S}),(0,e.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[(0,e.jsxs)("div",{className:"space-y-4",children:[(0,e.jsxs)("div",{className:"bg-white dark:bg-stone-900 border border-stone-200 dark:border-stone-700 rounded-xl p-4",children:[(0,e.jsx)("h3",{className:"font-semibold mb-3",children:"Target Configuration"}),f&&(0,e.jsx)("div",{className:"mb-3 rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-700 dark:border-amber-800 dark:bg-amber-900/20 dark:text-amber-300",children:f}),(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"text-xs font-medium text-stone-500 uppercase",children:"Book"}),(0,e.jsxs)("select",{value:s,disabled:t,onChange:g=>r(g.target.value),className:"w-full mt-1 px-3 py-2 text-base border border-stone-200 dark:border-stone-700 rounded-lg bg-white dark:bg-stone-900 disabled:opacity-50 sm:text-sm",children:[u.length===0&&(0,e.jsx)("option",{value:"",children:"No books available"}),u.map(g=>(0,e.jsxs)("option",{value:g.slug,children:[g.title||g.slug," (",g.completed_chapters||0,"/",g.total_chapters||0,")"]},g.slug))]})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"text-xs font-medium text-stone-500 uppercase",children:"Chapter #"}),(0,e.jsx)("input",{type:"number",value:n,disabled:t,onChange:g=>a(parseInt(g.target.value)||1),className:"w-full mt-1 px-3 py-2 text-base border border-stone-200 dark:border-stone-700 rounded-lg bg-white dark:bg-stone-900 disabled:opacity-50 sm:text-sm"})]})]})]}),(0,e.jsxs)("div",{className:"space-y-2",children:[y&&(0,e.jsx)("div",{className:"rounded-lg border border-emerald-200 bg-emerald-50 px-3 py-2 text-sm text-emerald-700 dark:border-emerald-800 dark:bg-emerald-900/20 dark:text-emerald-300",children:y}),w&&(0,e.jsx)("div",{className:"rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-800 dark:bg-red-900/20 dark:text-red-300",children:w}),(0,e.jsx)("button",{onClick:()=>F("next"),disabled:t,className:"w-full min-h-11 text-left p-3 rounded-lg border border-stone-200 dark:border-stone-700 hover:border-emerald-500 hover:shadow-sm transition-all group disabled:opacity-50",children:(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(_e,{className:"w-4 h-4 text-stone-400 group-hover:text-emerald-600"}),(0,e.jsx)("h4",{className:"font-medium text-sm group-hover:text-emerald-600",children:"Run Next Book"})]})}),(0,e.jsx)("button",{onClick:()=>F("book"),disabled:t||!s,className:"w-full min-h-11 text-left p-3 rounded-lg border border-stone-200 dark:border-stone-700 hover:border-gold-500 hover:shadow-sm transition-all group disabled:opacity-50",children:(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(xe,{className:"w-4 h-4 text-stone-400 group-hover:text-gold-600"}),(0,e.jsx)("h4",{className:"font-medium text-sm group-hover:text-gold-600",children:"Run Entire Book"})]})}),(0,e.jsx)("button",{onClick:()=>F("chapter"),disabled:t||!s,className:"w-full min-h-11 text-left p-3 rounded-lg border border-stone-200 dark:border-stone-700 hover:border-gold-500 hover:shadow-sm transition-all group disabled:opacity-50",children:(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(K,{className:"w-4 h-4 text-stone-400 group-hover:text-gold-600"}),(0,e.jsx)("h4",{className:"font-medium text-sm group-hover:text-gold-600",children:"Run Single Chapter"})]})}),(0,e.jsx)("button",{onClick:()=>F("media"),disabled:t||!s,className:"w-full min-h-11 text-left p-3 rounded-lg border border-stone-200 dark:border-stone-700 hover:border-blue-500 hover:shadow-sm transition-all group disabled:opacity-50",children:(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(ce,{className:"w-4 h-4 text-stone-400 group-hover:text-blue-600"}),(0,e.jsx)("h4",{className:"font-medium text-sm group-hover:text-blue-600",children:"Generate Media"})]})})]})]}),(0,e.jsxs)("div",{className:"lg:col-span-2",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("h3",{className:"font-semibold",children:"Live Agent Logs"}),(0,e.jsx)("p",{className:"text-xs text-stone-500",children:"Hidden by default. Expand only when you need operational diagnostics."})]}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("button",{onClick:()=>x(g=>!g),className:"min-h-11 rounded-lg border border-stone-200 px-3 py-2 text-xs font-medium text-stone-600 hover:bg-stone-100 disabled:opacity-50 dark:border-stone-700 dark:text-stone-300 dark:hover:bg-stone-800","aria-expanded":m,"aria-controls":"agent-live-logs","aria-label":m?"Hide live logs":"Show live logs",children:m?"Hide live logs":"Show live logs"}),m&&(0,e.jsx)("button",{onClick:Q,disabled:o.length===0,className:"min-h-11 rounded-lg border border-gold-200 px-3 py-2 text-xs font-medium text-gold-700 hover:bg-gold-50 disabled:opacity-50 dark:border-gold-800 dark:text-gold-300 dark:hover:bg-gold-900/20","aria-label":"Copy live logs",children:"Copy live logs"}),(0,e.jsx)("button",{onClick:()=>N(!p),disabled:t,className:"min-h-11 rounded-lg border border-stone-200 px-3 py-2 text-xs font-medium text-stone-600 hover:bg-stone-100 disabled:opacity-50 dark:border-stone-700 dark:text-stone-300 dark:hover:bg-stone-800",children:p?"Polling Active":"Start Polling"})]})]}),m&&(0,e.jsx)("div",{id:"agent-live-logs",className:"bg-stone-950 text-emerald-400 font-mono text-xs p-4 rounded-xl h-[400px] overflow-y-auto whitespace-pre-wrap border border-stone-800",children:t?(0,e.jsx)("span",{className:"text-stone-600",children:"Agent offline â start the agent to see live logs"}):o.length===0?(0,e.jsx)("span",{className:"text-stone-600",children:"Waiting for logs... (click an action to start)"}):o.join(` 3`)})]})]})]})}
3var se={pending:{label:"Queued",icon:ee,color:"text-gold-600 bg-gold-50 dark:bg-gold-900/20"},in_progress:{label:"In progress",icon:R,color:"text-blue-600 bg-blue-50 dark:bg-blue-900/20"},complete:{label:"Completed",icon:Z,color:"text-emerald-600 bg-emerald-50 dark:bg-emerald-900/20"},error:{label:"Failed",icon:de,color:"text-red-600 bg-red-50 dark:bg-red-900/20"}};function vt(){const[t,s]=(0,c.useState)([]),[r,n]=(0,c.useState)(!0),[a,u]=(0,c.useState)(!1),d=async()=>{try{const{data:p}=await H.from("pipeline_jobs").select("id, job_type, book_id, status, priority, created_at, payload").in("status",["pending","in_progress","error"]).order("priority",{ascending:!1}).order("created_at",{ascending:!0}).limit(20);s(p||[])}catch{}finally{n(!1),u(!1)}};(0,c.useEffect)(()=>{d()},[]);const o=()=>{u(!0),d()},l=t.filter(p=>p.status==="pending").length,m=t.filter(p=>p.status==="in_progress").length,x=t.filter(p=>p.status==="error").length;return(0,e.jsxs)("div",{className:"bg-white dark:bg-stone-900 border border-stone-200 dark:border-stone-700 rounded-xl p-6",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(Le,{className:"w-5 h-5 text-gold-500"}),(0,e.jsx)(B,{variant:"h3",children:"Pipeline Job Queue"})]}),(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 text-xs text-stone-500",children:[(0,e.jsxs)("span",{className:"px-2 py-0.5 rounded-full bg-gold-50 dark:bg-gold-900/20 text-gold-700 dark:text-gold-400",children:[l," pending"]}),m>0&&(0,e.jsxs)("span",{className:"px-2 py-0.5 rounded-full bg-blue-50 dark:bg-blue-900/20 text-blue-700 dark:text-blue-400",children:[m," running"]}),x>0&&(0,e.jsxs)("span",{className:"px-2 py-0.5 rounded-full bg-red-50 dark:bg-red-900/20 text-red-700 dark:text-red-400",children:[x," errors"]})]}),(0,e.jsx)("button",{onClick:o,disabled:a,className:"p-1.5 text-stone-400 hover:text-stone-700 disabled:opacity-50",children:(0,e.jsx)(R,{className:`w-4 h-4 ${a?"animate-spin":""}`})})]})]}),r?(0,e.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,e.jsx)(R,{className:"w-4 h-4 animate-spin text-stone-400"})}):t.length===0?(0,e.jsx)("div",{className:"flex items-center justify-center py-8 text-sm text-stone-400",children:"No pending jobs in queue"}):(0,e.jsx)("div",{className:"space-y-2 max-h-64 overflow-y-auto",children:t.map(p=>{const N=se[p.status]||se.pending,f=N.icon;return(0,e.jsxs)("div",{className:"flex items-center gap-3 px-3 py-2.5 rounded-lg bg-stone-50 dark:bg-stone-800",children:[(0,e.jsxs)("span",{className:`flex items-center gap-1 text-xs font-medium px-2 py-0.5 rounded-full flex-shrink-0 ${N.color}`,children:[(0,e.jsx)(f,{className:`w-3 h-3 ${p.status==="in_progress"?"animate-spin":""}`}),N.label]}),(0,e.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,e.jsx)("span",{className:"text-xs font-mono font-medium text-stone-700 dark:text-stone-300",children:p.job_type}),p.book_id&&(0,e.jsxs)("span",{className:"ml-2 text-xs text-stone-400 truncate",children:[p.book_id.slice(0,8),"â¦"]})]}),(0,e.jsxs)("span",{className:"text-[10px] text-stone-400 flex-shrink-0",children:["p",p.priority??1]}),(0,e.jsx)("span",{className:"text-[10px] text-stone-400 flex-shrink-0",children:new Date(p.created_at).toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"})}),te(p.created_at)&&(0,e.jsx)("span",{className:"inline-flex rounded-full bg-amber-100 px-2 py-0.5 text-[10px] font-semibold text-amber-700 dark:bg-amber-900/30 dark:text-amber-300",children:te(p.created_at)})]},p.id)})})]})}function Nt(){const[t,s]=(0,c.useState)(null),[r,n]=(0,c.useState)(!0),[a,u]=(0,c.useState)(!1);(0,c.useEffect)(()=>{qe.getCostEstimate().then(s).catch(()=>{}).finally(()=>n(!1))},[]);const d={money:"#EAB308",growth:"#14B8A6",business:"#3B82F6",health:"#EC4899",technology:"#8B5CF6",science:"#06B6D4",psychology:"#F97316",history:"#84CC16",society:"#6366F1",unknown:"#94A3B8"};return(0,e.jsxs)("div",{className:"bg-white dark:bg-stone-900 border border-stone-200 dark:border-stone-700 rounded-xl p-6",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(ve,{className:"w-5 h-5 text-emerald-500"}),(0,e.jsx)(B,{variant:"h3",children:"Content Production Cost"})]}),t&&(0,e.jsx)("button",{onClick:()=>u(o=>
3!o),className:"text-xs text-stone-400 hover:text-stone-600 dark:hover:text-stone-200",children:a?"Collapse":"Show by domain"})]}),r?(0,e.jsx)("div",{className:"flex items-center justify-center py-6 text-stone-400",children:(0,e.jsx)(R,{className:"w-4 h-4 animate-spin"})}):t?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:"grid grid-cols-3 gap-4 mb-4",children:[{label:"Chapters Produced",value:t.totalCompletedChapters.toLocaleString(),color:"text-stone-900 dark:text-white"},{label:"Infographic Cost",value:`$${t.totalInfographicCost.toFixed(2)}`,color:"text-gold-600 dark:text-gold-400"},{label:"Audio Cost",value:`$${t.totalAudioCost.toFixed(2)}`,color:"text-blue-600 dark:text-blue-400"}].map(o=>(0,e.jsxs)("div",{className:"bg-stone-50 dark:bg-stone-800 rounded-lg p-3 text-center",children:[(0,e.jsx)("div",{className:`text-lg font-bold tabular-nums ${o.color}`,children:o.value}),(0,e.jsx)("div",{className:"text-[10px] text-stone-400 mt-0.5",children:o.label})]},o.label))}),(0,e.jsxs)("div",{className:"flex items-center justify-between py-3 px-4 bg-emerald-50 dark:bg-emerald-900/20 rounded-lg mb-4",children:[(0,e.jsx)("span",{className:"text-sm font-semibold text-emerald-800 dark:text-emerald-300",children:"Total API spend (estimated)"}),(0,e.jsxs)("span",{className:"text-xl font-bold tabular-nums text-emerald-700 dark:text-emerald-400",children:["$",t.grandTotal.toFixed(2)]})]}),a&&t.byDomain.length>0&&(0,e.jsxs)("div",{className:"mt-2",children:[(0,e.jsx)("p",{className:"text-xs font-semibold text-stone-400 uppercase tracking-wide mb-2",children:"By Domain"}),(0,e.jsx)("div",{className:"space-y-1.5 max-h-52 overflow-y-auto",children:t.byDomain.map(o=>(0,e.jsxs)("div",{className:"flex items-center gap-3 px-3 py-2 rounded-lg bg-stone-50 dark:bg-stone-800",children:[(0,e.jsx)("span",{className:"w-2 h-2 rounded-full flex-shrink-0",style:{backgroundColor:d[o.domain]||"#6B7280"}}),(0,e.jsx)("span",{className:"text-xs font-medium text-stone-700 dark:text-stone-300 capitalize w-20 flex-shrink-0",children:o.domain}),(0,e.jsxs)("span",{className:"text-[10px] text-stone-400 flex-1",children:[o.completedChapters," ch"]}),(0,e.jsxs)("span",{className:"text-xs font-semibold tabular-nums text-stone-700 dark:text-stone-200",children:["$",o.totalCost.toFixed(2)]})]},o.domain))}),(0,e.jsx)("p",{className:"text-[10px] text-stone-400 mt-3",children:"Rates: $0.039/infographic (Gemini Imagen-3) · $0.054/chapter (TTS)"})]})]}):(0,e.jsx)("p",{className:"text-sm text-stone-400",children:"No data available"})]})}function yt(){const{data:t}=me(),s=t===!1;return(0,e.jsxs)("div",{className:"p-6 space-y-6",children:[s&&(0,e.jsx)(bt,{}),(0,e.jsx)(vt,{}),(0,e.jsxs)("div",{className:"grid grid-cols-1 xl:grid-cols-2 gap-6",children:[(0,e.jsx)(ft,{disabled:s}),(0,e.jsx)(Nt,{})]}),(0,e.jsx)(jt,{disabled:s})]})}function kt(){const[t,s]=(0,c.useState)([]),[r,n]=(0,c.useState)(!0),[a,u]=(0,c.useState)(!1),[d,o]=(0,c.useState)(!1),[l,m]=(0,c.useState)(new Set),[x,p]=(0,c.useState)({bookSlug:"",bookId:"",chapters:"pending",mode:"full"}),[N,f]=(0,c.useState)(!1),[C,w]=(0,c.useState)(null),[q,y]=(0,c.useState)(""),E=Re(),S=i=>{i.startsWith("Failed")?E.error(i):E.info(i)},h=async()=>{n(!0);try{s((await I.getRuns()).slice(0,20))}catch(i){console.error(i)}finally{n(!1)}};(0,c.useEffect)(()=>{h(),I.getAutoRunStatus("github_actions").then(i=>u(i)).catch(()=>{})},[]);const L=i=>{const j=Date.now()-new Date(i).getTime();return j>10080*60*1e3?"Stale 7d+":j>1440*60*1e3?"Stale 24h+":null},F=i=>{m(j=>{const D=new Set(j);return D.has(i)?D.delete(i):D.add(i),D})},Q=async i=>{try{await navigator.clipboard.writeText(JSON.stringify(i,null,2)),y(`Copied diagnostics for ${i.id}.`)}catch{y(`Failed to copy diagnostics for ${i.id}.`)}},g=async()=>{const i=!a;if(window.confirm(`${i?"Enable":"Disable"} nightly auto-run for pending GitHub Actions chapters?`)){o(!0),w(`${i?"Enabling":"Disabling"} nightly auto-runâ¦`);try{await I.toggleAutoRun("github_actions",i),u(i),S(`Auto-run ${i?"enabled":"disabled"}`),w(`Nightly auto-run ${i?"enabled":"disabled"}.`),y(`Nightly auto-run ${i?"enabled":"disabled"}.`)}catch(j){S(`Failed: ${j instanceof Error?j.message:"Unknown error"}`),w("Auto-run update failed."),y("Auto-run update failed.")}finally{o(!1)}}},$=async()=>
3{if(!x.bookSlug||!x.bookId){S("Book slug and ID are required");return}if(window.confirm(`Trigger GitHub Actions for ${x.bookSlug} with mode ${x.mode} and chapters ${x.chapters}?`)){f(!0),w(`Triggering ${x.bookSlug}â¦`);try{let i=x.chapters;x.chapters!=="all"&&x.chapters!=="pending"&&(i=x.chapters.split(",").map(j=>parseInt(j.trim())).filter(j=>!isNaN(j))),await I.triggerRun("github_actions",x.bookId,x.bookSlug,i,x.mode),S(`Triggered GitHub Actions for ${x.bookSlug}`),w(`Triggered GitHub Actions for ${x.bookSlug}.`),y(`Triggered GitHub Actions for ${x.bookSlug}.`),await h()}catch(i){S(`Failed: ${i instanceof Error?i.message:"Unknown error"}`),w(`Trigger failed for ${x.bookSlug}.`),y(`Trigger failed for ${x.bookSlug}.`)}finally{f(!1)}}};return(0,e.jsxs)("div",{className:"p-6 space-y-6",children:[(0,e.jsx)("div",{className:"sr-only","aria-live":"polite",children:q}),(0,e.jsxs)("div",{className:"bg-stone-50 dark:bg-stone-800/50 rounded-xl border border-stone-200 dark:border-stone-700 p-4",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsxs)("div",{children:[(0,e.jsxs)("h3",{className:"text-sm font-semibold text-stone-900 dark:text-white flex items-center gap-2",children:[(0,e.jsx)(K,{className:"w-4 h-4 text-amber-500"}),"Nightly Auto-Run"]}),(0,e.jsx)("p",{className:"text-xs text-stone-500 mt-1",children:"Runs at 2am UTC · Auto-discovers pending chapters"}),a&&(0,e.jsx)("p",{className:"text-xs text-amber-500 mt-1",children:"â Auto-run enabled â cron will process pending chapters nightly"})]}),(0,e.jsxs)("button",{onClick:g,disabled:d,className:`min-h-11 flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-medium transition-colors disabled:opacity-50 ${a?"bg-emerald-600 hover:bg-emerald-700 text-white":"bg-stone-600 hover:bg-stone-700 text-white"}`,"aria-label":a?"Turn auto-run off":"Turn auto-run on",children:[a?(0,e.jsx)($e,{className:"w-4 h-4"}):(0,e.jsx)(Ce,{className:"w-4 h-4"}),a?"ON":"OFF"]})]}),C&&(0,e.jsx)("p",{className:"mt-3 text-xs text-stone-500 dark:text-stone-400",children:C})]}),(0,e.jsxs)("div",{className:"bg-stone-50 dark:bg-stone-800/50 rounded-xl border border-stone-200 dark:border-stone-700 p-4",children:[(0,e.jsx)("h3",{className:"text-sm font-semibold text-stone-900 dark:text-white mb-3",children:"Manual Trigger"}),(0,e.jsxs)("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"text-xs text-stone-500 block mb-1",children:"Book Slug"}),(0,e.jsx)("input",{value:x.bookSlug,onChange:i=>p(j=>({...j,bookSlug:i.target.value})),placeholder:"e.g. atomic-habits",className:"w-full bg-white dark:bg-stone-800 border border-stone-200 dark:border-stone-700 rounded px-3 py-2 text-base text-stone-900 dark:text-white placeholder-stone-400 sm:text-sm"})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"text-xs text-stone-500 block mb-1",children:"Book ID (UUID)"}),(0,e.jsx)("input",{value:x.bookId,onChange:i=>p(j=>({...j,bookId:i.target.value})),placeholder:"uuid...",className:"w-full bg-white dark:bg-stone-800 border border-stone-200 dark:border-stone-700 rounded px-3 py-2 text-base text-stone-900 dark:text-white placeholder-stone-400 sm:text-sm"})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"text-xs text-stone-500 block mb-1",children:"Chapters"}),(0,e.jsx)("input",{value:x.chapters,onChange:i=>p(j=>({...j,chapters:i.target.value})),placeholder:"pending / all / 1,2,3",className:"w-full bg-white dark:bg-stone-800 border border-stone-200 dark:border-stone-700 rounded px-3 py-2 text-base text-stone-900 dark:text-white placeholder-stone-400 sm:text-sm"})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"text-xs text-stone-500 block mb-1",children:"Mode"}),(0,e.jsxs)("select",{value:x.mode,onChange:i=>p(j=>({...j,mode:i.target.value})),className:"w-full bg-white dark:bg-stone-800 border border-stone-200 dark:border-stone-700 rounded px-3 py-2 text-base text-stone-900 dark:text-white sm:text-sm",children:[(0,e.jsx)("option",{value:"full",children:"Full (infographic + audio)"}),(0,e.jsx)("option",{value:"infographic_only",children:"Infographic only"}),(0,e.jsx)("option",{value:"audio_only",children:"Audio only"})]})]})]}),(0,e.jsxs)("button",{onClick:$,disabled:N||!x.bookSlug||!x.bookId,className:"mt-3 min-h-11 flex items-center gap-1.5 px-4 py-2 bg-violet-600 hover:bg-violet-700 disabled:opacity-50 text-white rounded-lg text-sm font-medium transition-colors",children:[(0,e.jsx)(K,{className:"w-3.5 h-3.5"}),N?"Firing...":"Fire Now"]})]}),(0,e.jsxs)("div",{className:"bg-stone-50 dark:bg-stone-800/50 rounded-xl border border-stone-200 dark:border-stone-700 p-4",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,e.jsx)("h3",{className:"text-sm font-semibold text-stone-900 dark:text-white",children:"Recent Runs"}),(0,e.jsx)("button",{onClick:h,className:"text-stone-400 hover:text-stone-600 dar
3k:hover:text-stone-300 transition-colors",children:(0,e.jsx)(R,{className:`w-3.5 h-3.5 ${r?"animate-spin":""}`})})]}),r?(0,e.jsx)("p",{className:"text-xs text-stone-500 text-center py-4",children:"Loading..."}):t.length===0?(0,e.jsx)("p",{className:"text-xs text-stone-500 text-center py-4",children:"No runs yet. Trigger one above."}):(0,e.jsx)("div",{className:"space-y-2",children:t.map(i=>(0,e.jsxs)("div",{className:"border-b border-stone-200 py-2 last:border-0 dark:border-stone-700",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:gap-3",children:[(0,e.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,e.jsx)("span",{className:"text-xs font-mono text-stone-700 dark:text-stone-300 truncate block",children:i.book_slug}),(0,e.jsx)("span",{className:"text-xs text-stone-400",children:new Date(i.created_at).toLocaleString()}),L(i.created_at)&&(0,e.jsx)("span",{className:"ml-2 inline-flex rounded-full bg-amber-100 px-2 py-0.5 text-[10px] font-semibold text-amber-700 dark:bg-amber-900/30 dark:text-amber-300",children:L(i.created_at)})]}),(0,e.jsx)(Oe,{run:i,compact:!0}),i.run_url&&(0,e.jsx)("a",{href:i.run_url,target:"_blank",rel:"noopener noreferrer",className:"text-stone-400 hover:text-stone-600 dar
3k:hover:text-stone-300 flex-shrink-0",children:(0,e.jsx)(W,{className:"w-3.5 h-3.5"})}),(0,e.jsx)("button",{type:"button",onClick:()=>F(i.id),className:"min-h-11 rounded-lg border border-stone-200 px-3 py-2 text-xs font-medium text-stone-600 hover:bg-stone-100 dark:border-stone-700 dark:text-stone-300 dark:hover:bg-stone-800","aria-expanded":l.has(i.id),"aria-label":`Show diagnostics for ${i.id}`,children:l.has(i.id)?"Hide diagnostics":"Show diagnostics"})]}),l.has(i.id)&&(0,e.jsxs)("div",{className:"mt-2 rounded-lg border border-stone-200 bg-white p-3 dark:border-stone-700 dark:bg-stone-950",children:[(0,e.jsx)("pre",{className:"max-h-40 overflow-auto whitespace-pre-wrap text-[11px] leading-relaxed text-stone-700 dark:text-stone-300",children:JSON.stringify(i,null,2)}),(0,e.jsx)("button",{type:"button",onClick:()=>Q(i),className:"mt-2 min-h-11 rounded-lg border border-violet-300 px-3 py-2 text-xs font-medium text-violet-700 hover:bg-violet-50 dark:border-violet-800 dark:text-violet-300 dark:hover:bg-violet-950/30","aria-label":`Copy diagnostics for ${i.id}`,children:"Copy diagnostics"})]})]},i.id))})]})]})}var wt=[{id:"overview",label:"Overview"},{id:"pipeline",label:"Pipeline"},{id:"sessions",label:"Sessions"},{id:"decisions",label:"Decisions"},{id:"learning",label:"Learning"},{id:"operations",label:"Operations"},{id:"github",label:"â¡ GitHub"}];function cs(){const[t,s]=(0,c.useState)("overview"),[r,n]=(0,c.useState)(""),{data:a}=me(),u=G(),d=()=>{u.invalidateQueries({queryKey:b.all}),n("Refreshing agent console data.")};return(0,e.jsxs)("div",{className:"max-w-7xl mx-auto space-y-6",children:[(0,e.jsx)("div",{className:"sr-only","aria-live":"polite",children:r}),(0,e.jsxs)("div",{className:"flex flex-col gap-4 md:flex-row md:items-center md:justify-between",children:[(0,e.jsxs)("div",{children:[(0,e.jsxs)(B,{variant:"h1",className:"flex items-center gap-2",children:[(0,e.jsx)(be,{className:"w-6 h-6 text-gold-500"}),"Agent Monitoring Console"]}),(0,e.jsx)("p",{className:"text-sm text-stone-500 mt-1",children:"Real-time pipeline monitoring, agent history, and learning insights"})]}),(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,e.jsxs)("div",{className:`flex items-center gap-2 px-3 py-1.5 rounded-full text-xs font-medium border ${a?"bg-emerald-50 dark:bg-emerald-900/20 text-emerald-700 dark:text-emerald-400 border-emerald-200 dark:border-emerald-800":"bg-red-50 dark:bg-red-900/20 text-red-700 dark:text-red-400 border-red-200 dark:border-red-800"}`,children:[(0,e.jsx)("div",{className:`w-2 h-2 rounded-full ${a?"bg-emerald-500 animate-pulse":"bg-red-500"}`}),a===void 0?"Checking...":a?"Agent Online":"Agent Offline"]}),(0,e.jsx)("button",{onClick:d,className:"min-h-11 rounded-lg p-2 text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-600 dar
3k:hover:bg-stone-800",title:"Refresh all data","aria-label":"Refresh all data",children:(0,e.jsx)(R,{className:"w-4 h-4"})})]})]}),(0,e.jsx)("div",{className:"overflow-x-auto",children:(0,e.jsx)("div",{role:"tablist","aria-label":"Agent console sections",className:"flex min-w-max items-center gap-1 rounded-lg bg-stone-100 p-1 dark:bg-stone-800",children:wt.map(o=>(0,e.jsx)("button",{role:"tab",id:`agent-console-tab-${o.id}`,"aria-controls":`agent-console-panel-${o.id}`,"aria-selected":t===o.id,onClick:()=>s(o.id),className:`min-h-11 px-4 py-2 text-sm font-medium rounded-md transition-colors ${t===o.id?"bg-white dark:bg-stone-700 text-stone-900 dark:text-white shadow-sm":"text-stone-500 hover:text-stone-700 dark:hover:text-stone-300"}`,children:o.label},o.id))})}),(0,e.jsxs)("div",{id:`agent-console-panel-${t}`,role:"tabpanel","aria-labelledby":`agent-console-tab-${t}`,className:"bg-white dark:bg-stone-900 border border-stone-200 dark:border-stone-700 rounded-xl min-h-[500px]",children:[t==="overview"&&(0,e.jsx)(tt,{}),t==="pipeline"&&(0,e.jsx)(nt,{}),t==="sessions"&&(0,e.jsx)(it,{}),t==="decisions"&&(0,e.jsx)(xt,{}),t==="learning"&&(0,e.jsx)(gt,{}),t==="operations"&&(0,e.jsx)(yt,{}),t==="github"&&(0,e.jsx)(kt,{})]})]})}export{cs 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.