1import{r as b,j as e,N as B,F as O,v as C}from"./index-Dz7N0PDB.js";import{buildabilityTag as L}from"./blueprint-8PSim0SF.js";import{L as Q}from"./lock-Bwo15yRd.js";import"./pulse-strip-i7OhrMf_.js";const S="roomready_admin_pw";function F(o){try{const t=JSON.parse(o);return Array.isArray(t)?t:[]}catch{return[]}}function j(o){if(!o)return[];try{const t=JSON.parse(o);return Array.isArray(t)?t.map(String):[]}catch{return[]}}const R={Draft:0,Assist:1,Act:2};function P(o){const t=new Map,a=[];for(const s of o)s.mergeKey?(t.has(s.mergeKey)||t.set(s.mergeKey,[]),t.get(s.mergeKey).push(s)):a.push(s);const r=[];for(const s of Array.from(t.values()))r.push({rep:s[0],members:s,sponsors:Array.from(new Set(s.map(l=>l.submitterName?.trim()).filter(Boolean))),minutes:s.reduce((l,m)=>l+(m.costMinutes??0),0)});for(const s of a)r.push({rep:s,members:[s],sponsors:s.submitterName?.trim()?[s.submitterName.trim()]:[],minutes:s.costMinutes??0});return r}function V(o){const t=o.rep,a=[...j(t.tools),t.toolsOther].filter(Boolean).join(", "),r=[t.impact?.trim()?`${t.impact.trim().replace(/\.$/,"")}.`:"Not set.",o.minutes?`Currently costs about ${o.minutes} minutes a week.`:""].filter(Boolean).join(" ");return[t.agentName,o.sponsors.length?`Sponsors: ${o.sponsors.join(", ")} (${o.members.length} ${o.members.length===1?"person":"people"})`:"",`Seat: ${t.owner}`,`Autonomy: ${t.autonomy||"Not set"}`,`What it does: ${t.whatItDoes}`,`Trigger and frequency: ${[t.trigger,t.frequency].filter(Boolean).join(", ")||"Not set"}.`,`Tools: ${a||"Not set"}.`,"Workflow:",...F(t.steps).map((l,m)=>` ${m+1}. ${l.humanCheck?"[Human review] ":""}${l.what}${l.tool?` (${l.tool})`:""}`),`Impact: ${r}`,`Complexity: ${t.complexity||"Not set"}.`,`Key risk: ${t.worstCase}`,`Buildability: ${L([...j(t.tools),t.toolsOther??""].filter(Boolean))}`].filter(Boolean).join(` 2`)}function E(o,t){const a=P(o),r=M(a),s=[];t?(s.push("AGENT BLUEPRINT PORTFOLIO â FOR SYNTHESIS",""),s.push("This is the room's own contribution from the RoomReady workshop. Each entry below is one agent blueprint. Merged entries carry a sponsor count â the strongest priority signal. Please synthesise into a prioritised build portfolio.","")):s.push("AGENT BLUEPRINT PORTFOLIO","The room's own contribution. The twelve blueprints mithAI pre-built for RoomReady are held separately and get merged into the final portfolio afterwards.","");for(const[l,m]of r){s.push("=".repeat(l.length),l.toUpperCase(),"=".repeat(l.length),"");for(const x of m)s.push(V(x),"")}return s.join(` 3`)}function M(o){const t=new Map;for(const a of o){const r=a.rep.deptFunction?.trim()||"Function not given";t.has(r)||t.set(r,[]),t.get(r).push(a)}for(const a of Array.from(t.values()))a.sort((r,s)=>(R[r.rep.autonomy??""]??3)-(R[s.rep.autonomy??""]??3));return Array.from(t.entries()).sort((a,r)=>a[0].localeCompare(r[0]))}const X=new Set(["the","and","that","this","with","from","into","have","what","when","then","them","they","each","every","would","could","should","about","your","their","there","does","agent","drafts","draft","weekly","week"]);function I(o){const t=`${o.agentName} ${o.whatItDoes}`.toLowerCase().replace(/[^a-z0-9\s]/g," ").split(/\s+/);return new Set(t.filter(a=>a.length>3&&!X.has(a)))}function Z(o){const t=o.filter(r=>!r.mergeKey),a=[];for(let r=0;r<t.length;r++){const s=I(t[r]);for(let l=r+1;l<t.length;l++){const m=I(t[l]);let x=0;s.forEach(u=>{m.has(u)&&x++}),x>=3&&a.push([t[r],t[l],x])}}return a.sort((r,s)=>s[2]-r[2]).slice(0,5).map(([r,s])=>[r,s])}const p=o=>e.jsx("span",{className:"font-mono text-[10px] tracking-widest uppercase text-cardamom/60",children:o});function re(){const[o,t]=b.useState(null),[a,r]=b.useState(!1),[s,l]=b.useState(null),[m,x]=b.useState([]),[u,T]=b.useState(!1),[D,$]=b.useState(!1);async function w(n){try{const d=await fetch("/api/roomready/admin/blueprint/plans",{headers:{"x-roomready-admin":n}});if(d.status===401){r(!0),t(null);try{sessionStorage.removeItem(S)}catch{}return}const i=await d.json();if(Array.isArray(i)){l(i),r(!1),t(n);try{sessionStorage.setItem(S,n)}catch{}}}catch{}}b.useEffect(()=>{let n="";try{n=sessionStorage.getItem(S)??""}catch{}n&&w(n)},[]);async function N(n,d){if(!(!o||u)){T(!0);try{(await fetch("/api/roomready/admin/blueprint/merge",{method:"POST",headers:{"Content-Type":"application/json","x-roomready-admin":o},body:JSON.stringify({ids:n,group:d,kind:"plan"})})).ok&&(x([]),await w(o))}finally{T(!1)}}}if(!o)return e.jsxs("div",{className:"min-h-screen bg-background text-foreground",children:[e.jsx(B,{}),e.jsx("div",{className:"flex items-center justify-center min-h-[calc(100vh-64px)] px-6 py-20",children:e.jsxs("div",{className:"w-full max-w-sm bg-card border border-card-border rounded-2xl p-10",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("div",{className:"inline-flex items-center justify-center w-12 h-12 rounded-full bg-cardamom/10 border border-cardamom/20 mb-5",children:e.jsx(Q,{className:"w-5 h-5 text-cardamom"})}),e.jsx("h2",{className:"font-display text-2xl text-cardamom mb-2",children:"Blueprint portfolio"}),e.jsx("p",{className:"text-sm text-ink-soft",children:"Admin password required."})]}),e.jsxs("form",{onSubmit:n=>{n.preventDefault();const d=new FormData(n.currentTarget),i=String(d.get("pw")??"").trim();i&&w(i)},className:"space-y-3",children:[e.jsx("input",{name:"pw",type:"password",placeholder:"Admin password",autoFocus:!0,style:{fontSize:"16px"},className:`w-full px-4 py-3 rounded-xl bg-background border text-sm text-foreground placeholder:text-ink-soft/40 outline-none transition-colors ${a?"border-red-400":"border-card-border focus:border-cardamom/50"}`}),a&&e.jsx("p",{className:"text-red-500 text-xs",children:"Incorrect password."}),e.jsx("button",{type:"submit",className:"w-full py-3 rounded-xl bg-cardamom text-parchment text-sm font-mono tracking-wide hover:opacity-90 transition-opacity",children:"Enter"})]})]})}),e.jsx(O,{})]});const h=s??[],g=P(h),U=g.length,K=g.reduce((n,d)=>n+d.minutes,0),k=n=>
3L([...j(n.tools),n.toolsOther??""].filter(Boolean)),W=g.filter(n=>k(n.rep)==="Buildable now").length,q=g.filter(n=>k(n.rep)==="Needs a connector").length,_=M(g),A=Z(h);function H(){const n=new Blob([E(h,!1)],{type:"text/plain"}),d=URL.createObjectURL(n),i=document.createElement("a");i.href=d,i.download="roomready-blueprint-portfolio.txt",i.click(),URL.revokeObjectURL(d)}async function J(){try{await navigator.clipboard.writeText(E(h,!0)),$(!0),setTimeout(()=>$(!1),2e3)}catch{}}return e.jsxs("div",{className:"min-h-screen bg-background text-foreground pb-20",children:[e.jsx(B,{}),e.jsxs("div",{className:"max-w-3xl mx-auto px-6 pt-16 pb-32",children:[e.jsx("p",{className:"font-mono text-xs tracking-widest uppercase text-saffron mb-4",children:"Agent blueprints · Portfolio"}),e.jsx("h1",{className:"font-display text-3xl text-cardamom mb-4",children:"The room's blueprints, end to end"}),e.jsx("p",{className:"text-sm text-ink-soft leading-relaxed mb-8",children:"Every blueprint from the room as one document, grouped by function, ordered by autonomy â Draft first, then Assist, then Act â roughly the order they can be built in. The twelve blueprints mithAI pre-built for RoomReady are held separately and get merged into the final portfolio afterwards, so this view is the room's own contribution."}),e.jsxs("p",{className:"font-mono text-sm text-saffron tracking-wide mb-8",children:[h.length," ",h.length===1?"blueprint":"blueprints"," · ",U," distinct after merging · ",K," minutes a week represented · ",W," buildable now vs ",q," needing a connector"]}),e.jsxs("div",{className:"flex flex-wrap gap-3 mb-6",children:[e.jsx("button",{onClick:H,className:"px-4 py-2.5 rounded-xl bg-cardamom text-parchment text-sm font-mono tracking-wide hover:opacity-90 transition-opacity",children:"Download the portfolio"}),e.jsx("button",{onClick:J,className:"px-4 py-2.5 rounded-xl border border-card-border text-sm text-foreground hover:border-cardamom/50 transition-colors",children:D?"Copied":"Copy as text for AI"}),m.length>=2&&e.jsx("button",{onClick:()=>N(m,!0),disabled:u,className:"px-4 py-2.5 rounded-xl bg-saffron text-parchment text-sm font-mono tracking-wide hover:opacity-90 transition-opacity disabled:opacity-60",children:u?"Merging...":`Merge ${m.length} as one agent`})]}),A.length>0&&e.jsxs("div",{className:"mb-8 border border-saffron/30 rounded-xl px-4 py-3",children:[e.jsx("p",{className:"font-mono text-[10px] tracking-widest uppercase text-saffron mb-2",children:"Possible duplicates"}),e.jsx("div",{className:"space-y-2",children:A.map(([n,d])=>e.jsxs("div",{className:"flex items-start justify-between gap-3 text-xs",children:[e.jsxs("p",{className:"text-ink-soft flex-1",children:['"',n.agentName,'" and "',d.agentName,'" look like the same task.']}),e.jsx("button",{onClick:()=>N([n.id,d.id],!0),disabled:u,className:"text-cardamom underline underline-offset-2 hover:opacity-80 whitespace-nowrap disabled:opacity-50",children:"Merge these"})]},`${n.id}-${d.id}`))})]}),s===null?e.jsx("p",{className:"text-sm text-ink-soft/50",children:"Loading..."}):h.length===0?e.jsx("p",{className:"text-sm text-ink-soft/50",children:"No blueprints yet. They will appear here as the room builds them."}):_.map(([n,d])=>e.jsxs("div",{className:"mb-12",children:[e.jsx("p",{className:"font-mono text-[10px] tracking-widest uppercase text-ink-soft/50 border-b border-card-border/60 pb-2 mb-5",children:n}),e.jsx("div",{className:"space-y-6",children:d.map(i=>{const c=i.rep,Y=[...j(c.tools),c.toolsOther].filter(Boolean).join(", "),v=k(c),z=[c.impact?.trim()?`${c.impact.trim().replace(/\.$/,"")}.`:"Not set.",i.minutes?`Currently costs about ${i.minutes} minutes a week.`:""].filter(Boolean).join(" ");return e.jsxs("div",{className:"bg-parchment border border-cardamom/15 rounded-2xl px-6 py-6",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 mb-1",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[i.members.length>1&&e.jsxs("span",{className:"font-mono text-[10px] tracking-widest uppercase text-parchment bg-saffron px-2 py-1 rounded-full",children:[i.members.length," sponsors"]}),c.isTest&&e.jsx("span",{className:"font-mono text-[10px] tracking-widest uppercase text-ink-soft/40",children:"Test"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`font-mono text-[10px] tracking-widest uppercase px-2 py-1 rounded-full border ${v==="Buildable now"?"text-cardamom border-cardamom/40":v==="Needs a connector"?"text-saffron border-saffron/40":"text-ink-soft/50 border-card-border"}`,children:v}),i.members.length>1?e.jsx("button",{onClick:()=>N(i.members.map(f=>f.id),!1),disabled:u,className:"text-xs text-ink-soft/50 underline underline-offset-2 hover:text-ink-soft disabled:opacity-50",children:"Unmerge"}):e.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-ink-soft/50 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:m.includes(c.id),onChange:f=>x(y=>f.target.checked?[...y,c.id]:y.filter(G=>G!==c.id)),className:"accent-[#5B6B4E]"}),"Merge"]})]})]}),e.jsx("p",{className:"font-display text-xl text-cardamom mb-1",children:c.agentName}),i.sponsors.length>0&&e.jsxs("p",{className:"text-xs text-ink-soft/60 mb-4",children:["Sponsored by ",e.jsx("span",{className:"text-saffron",children:i.sponsors.join(", ")}),i.members.length>1&&e.jsxs(e.Fragment,{children:[" â ",i.members.length," people asked for this"]})]}),e.jsxs("div",{className:"space-y-3 text-sm text-foreground leading-relaxed mt-3",children:[e.jsxs("p",{children:[p("Seat"),e.jsx("br",{}),c.owner]}),e.jsxs("p",{children:[p("Autonomy"),e.jsx("br",{}),e.jsx("span",{className:"font-mono text-xs tracking-wide text-saffron",children:c.autonomy||"Not set"})]}),e.jsxs("p",{children:[p("What it does"),e.jsx("br",{}),c.whatItDoes]}),e.jsxs("p",{children:[p("Trigger and frequency"),e.jsx("br",{}
3),[c.trigger,c.frequency].filter(Boolean).join(", ")||"Not set","."]}),e.jsxs("p",{children:[p("Tools"),e.jsx("br",{}),Y||"Not set","."]}),e.jsxs("div",{children:[p("Workflow"),e.jsx("ol",{className:"mt-1 space-y-1",children:F(c.steps).map((f,y)=>e.jsxs("li",{className:"flex gap-2",children:[e.jsxs("span",{className:"font-mono text-xs text-ink-soft/50 pt-0.5",children:[y+1,"."]}),e.jsxs("span",{children:[f.humanCheck&&e.jsx("span",{className:"font-mono text-xs text-saffron mr-1",children:"[Human review]"}),f.what,f.tool&&e.jsxs("span",{className:"text-ink-soft/60",children:[" (",f.tool,")"]})]})]},y))})]}),e.jsxs("p",{children:[p("Impact"),e.jsx("br",{}),z]}),e.jsxs("p",{children:[p("Complexity"),e.jsx("br",{}),c.complexity||"Not set","."]}),e.jsxs("p",{children:[p("Key risk"),e.jsx("br",{}),c.worstCase]})]})]},c.id)})})]},n)),e.jsxs("div",{className:"mt-12 flex items-center gap-5",children:[e.jsx(C,{href:"/roomready/control",className:"text-xs text-ink-soft/50 underline underline-offset-2 hover:text-ink-soft transition-colors",children:"Back to control"}),e.jsx(C,{href:"/roomready/blueprint/live",className:"text-xs text-ink-soft/50 underline underline-offset-2 hover:text-ink-soft transition-colors",children:"Live board"})]})]}),e.jsx(O,{})]})}export{re 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.