1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,850912,e=>{"use strict";e.i(639057);var t=e.i(848277),r=e.i(330668),a=e.i(696086),s=e.i(195032),l=e.i(442588),o=e.i(816506),i=e.i(942944),n=e.i(235884);let c=(0,n.default)("ShieldCheck",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);var d=e.i(307203),u=e.i(541428);let h={active:{badge:"bg-primary text-primary-foreground border-primary",title:"text-card-foreground",subtitle:"text-muted-foreground"},complete:{badge:"bg-emerald-600 text-white border-emerald-600",title:"text-card-foreground",subtitle:"text-muted-foreground"},disabled:{badge:"bg-muted text-muted-foreground border-border",title:"text-muted-foreground",subtitle:"text-muted-foreground"}};function m({canSelectAgent:e,selectedProjectLabel:r,onStepOneClick:a}){let s=e?"complete":"active",l=e?"active":"disabled";return(0,t.jsx)("section",{"aria-label":"Setup steps",className:"rounded-2xl border bg-card px-5 py-4 sm:px-6 sm:py-5 shadow-sm",children:(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,t.jsxs)("button",{type:"button",className:(0,u.cn)("flex min-w-0 items-center gap-3 text-left",e?"cursor-pointer":"cursor-default"),onClick:()=>{e&&a()},disabled:!e,children:[(0,t.jsx)("div",{className:`flex h-8 w-8 items-center justify-center rounded-full border text-sm font-semibold ${h[s].badge}`,"aria-hidden":"true",children:"1"}),(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("p",{className:`text-sm font-medium ${h[s].title}`,children:"Project selection"}),(0,t.jsx)("p",{className:`text-xs ${h[s].subtitle} truncate`,title:"complete"===s&&r?.trim()?r.trim():void 0,children:"complete"===s?r?.trim()?r.trim():"Completed":""})]})]}),(0,t.jsx)("div",{className:"h-px flex-1 bg-border","aria-hidden":"true"}),(0,t.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,t.jsx)("div",{className:`flex h-8 w-8 items-center justify-center rounded-full border text-sm font-semibold ${h[l].badge}`,"aria-hidden":"true",children:"2"}),(0,t.jsx)("div",{className:"min-w-0",children:(0,t.jsx)("p",{className:`text-sm font-medium ${h[l].title}`,children:"Agent selection"})})]})]})})}var p=e.i(531261),x=e.i(123207);let g=(0,n.default)("LayoutGrid",[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]]),f=(0,n.default)("List",[["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 18h.01",key:"1tta3j"}],["path",{d:"M3 6h.01",key:"1rqtza"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 18h13",key:"1lx6n3"}],["path",{d:"M8 6h13",key:"ik3vkj"}]]);var j=e.i(232890),b=e.i(487635),y=e.i(54976),v=e.i(599486);let w=(0,n.default)("Palette",[["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["path",{d:"M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.926 0 1.648-.746 1.648-1.688 0-.437-.18-.835-.437-1.125-.29-.289-.438-.652-.438-1.125a1.64 1.64 0 0 1 1.668-1.668h1.996c3.051 0 5.555-2.503 5.555-5.554C21.965 6.012 17.461 2 12 2z",key:"12rzf8"}]]);var C=e.i(696134);function _({id:e,label:r,value:a,onChange:s,disabled:l,placeholder:o}){let i,n=(i=a.trim(),/^#[0-9A-Fa-f]{6}$/.test(i)?i.toLowerCase():"#000000");return(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("label",{htmlFor:e,className:"text-sm font-medium",children:r}),(0,t.jsxs)("div",{className:"relative focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2 rounded-md",children:[(0,t.jsx)(C.Input,{id:e,value:a,onChange:e=>s(e.target.value),disabled:l,placeholder:o,className:"pr-12"}),(0,t.jsxs)("div",{"aria-hidden":"true",className:(0,u.cn)("absolute right-1 top-1/2 flex size-7 -translate-y-1/2 items-center justify-center rounded border border-border bg-background text-muted-foreground shadow-xs transition-colors",l?"opacity-50":"hover:text-foreground"),children:[(0,t.jsx)("span",{"aria-hidden":"true",className:"absolute inset-1 rounded-sm",style:{backgroundColor:n}}),(0,t.jsx)(w,{className:"relative size-3.5 mix-blend-difference"})]}),(0,t.jsx)("input",{type:"color","aria-label":`Pick ${r} colour`,className:"absolute right-1 top-1/2 size-7 -translate-y-1/2 cursor-pointer opacity-0 disabled:pointer-events-none disabled:cursor-not-allowed",value:n,disabled:l,onInput:e=>s(e.currentTarget.value.toLowerCase()),onChange:e=>s(e.target.value.toLowerCase())})]})]})}var N=e.i(885205),S=e.i(137651),k=e.i(600547),E=e.i(621013),T=e.i(779598);function A(e){return e.endsWith("/")?e.slice(0,-1):e}async function O(e,t){try{let t=await e.json(),r=t?.detail;if("string"==typeof r)return r;if(r&&"object"==typeof r){let e=r.message;if("string"==typeof e)return e}}catch{}return`${t} (HTTP ${e.status})`}async function R(e){let t=await fetch(`${A(e)}/orchestrator-groups`,{credentials:"include"});if(!t.ok)throw Error(await O(t,"Unable to load groups"));let r=await t.json();return Array.isArray(r.groups)?r.groups:[]}async function D(e,t){let r=await fetch(`${A(e)}/orchestrator-groups`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:t})});if(!r.ok)throw Error(await O(r,"Unable to create group"));let a=await r.json();if(!a.group?.id)throw Error("Invalid create group response");return a.group}async function $(e,t,r){let a=await fetch(`${A(e)}/orchestrator-groups/${encodeURIComponent(t)}`,{method:"PATCH",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:r})});if(!a.ok)throw Error(await O(a,"Unable to rename group"));let s=await a.json();if(!s.group?.id)throw Error("Invalid rename group response");return s.group}async function P(e,t){let r=await fetch(`${A(e)}/orchestrator-groups/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"include"});if(!r.ok)throw Error(await O(r,"Unable to delete group"))}let I="__create_group__",L=e=>e&&"gemini_non_thinking"!==e?e:"";function U({apiUrl:e,orchestrator:s,isSuperAdmin:l=!0,open:o,onOpenChange:i,onArchived:n,onSaved:c,projects:d=[]}){let u=(0,a.useRouter)(),h=(0,r.useId)(),m=`${h}-orch-edit-title`,p=`${h}-orch-edit-welcome`,x=`${h}-orch-edit-description`,g=`${h}-orch-edit-colour-from`,f=`${h}-orch-edit-colour-to`,j=`${h}-orch-edit-text-colour`,b=`${h}-orch-edit-model-mode`,v=`${h}-orch-edit-project`,w=`${h}-orch-edit-speech-mode`,A=`${h}-orch-edit-memory-scope`,O=`${h}-orch-edit-prerequisites`,[G,F]=(0,r.useState)(s.title),[z,B]=(0,r.useState)(s.welcome_msg??""),[K,Y]=(0,r.useState)(s.description??""),[H,M]=(0,r.useState)(!!s.hide_description),J=`${h}-orch-edit-hide-description`,[q,V]=(0,r.useState)(s.bundle_colour_from??""),[W,Q]=(0,r.useState)(s.bundle_colour_to??""),[X,Z]=(0,r.useState)(s.bundle_text_colour??""),[ee,et]=(0,r.useState)(L(s.model_mode)),[er,ea]=(0,r.useState)(s.project_id??""),[es,el]=(0,r.useState)(s.speech_mode??""),[eo,ei]=(0,r.useState)(s.memory_scope??""),[en,ec]=(0,r.useState)((s.prerequisite_course_ids??[]).join(", ")),ed=!Array.isArray(s.prerequisite_course_ids),[eu,eh]=(0,r.useState)(!1),[em,ep]=(0,r.useState)(!!s.auto_first_message),ex=`${h}-orch-edit-auto-first-message`,eg=`${h}-orch-edit-group`,[ef,ej]=(0,r.useState)(s.group_id??""),[eb,ey]=(0,r.useState)([]),[ev,ew]=(0,r.useState)(!1),[eC,e_]=(0,r.useState)(""),[eN,eS]=(0,r.useState)(!1),[ek,eE]=(0,r.useState)(!1),[eT,eA]=(0,r.useState)(!1),[eO,eR]=(0,r.useState)(!1);(0,r.useEffect)(()=>{o&&(F(s.title),B(s.welcome_msg??""),Y(s.description??""),M(!!s.hide_description),V(s.bundle_colour_from??""),Q(s.bundle_colour_to??""),Z(s.bundle_text_colour??""),et(L(s.model_mode)),ea(s.project_id??""),el(s.speech_mode??""),ei(s.memory_scope??""),ec((s.prerequisite_course_ids??[]).join(", ")),eh(!1),ep(!!s.auto_first_message),ej(s.group_id??""),ew(!1),e_(""),eE(!1))},[o,s]),(0,r.useEffect)(()=>
1{if(!o)return;let t=!0;return(async()=>{try{let r=await R(e);t&&ey(r)}catch{}})(),()=>{t=!1}},[o,e]);let eD=(0,r.useCallback)(async()=>{let t=eC.trim();if(!t)return void y.toast.error("Group name is required");eS(!0);try{let r=await D(e,t);ey(e=>[...e.filter(e=>e.id!==r.id),r].sort((e,t)=>e.name.localeCompare(t.name))),ej(r.id),ew(!1),e_(""),y.toast.success("Group created")}catch(e){y.toast.error("Unable to create group",{description:e instanceof Error?e.message:void 0})}finally{eS(!1)}},[e,eC]),e$=(0,r.useCallback)(async t=>{let r=window.prompt("Rename group",t.name)?.trim();if(r&&r!==t.name){eS(!0);try{let a=await $(e,t.id,r);ey(e=>e.map(e=>e.id===a.id?a:e).sort((e,t)=>e.name.localeCompare(t.name))),y.toast.success("Group renamed")}catch(e){y.toast.error("Unable to rename group",{description:e instanceof Error?e.message:void 0})}finally{eS(!1)}}},[e]),eP=(0,r.useCallback)(async t=>{if(window.confirm(`Delete group "${t.name}"? Its workflows become ungrouped (none are lost).`)){eS(!0);try{await P(e,t.id),ey(e=>e.filter(e=>e.id!==t.id)),ej(e=>e===t.id?"":e),y.toast.success("Group deleted")}catch(e){y.toast.error("Unable to delete group",{description:e instanceof Error?e.message:void 0})}finally{eS(!1)}}},[e]),eI=(0,r.useCallback)(async()=>{let t=G.trim();if(l&&!t)return void y.toast.error("Title is required");eA(!0);try{let r=z.trim(),a=K.trim(),o=q.trim(),n=W.trim(),d=X.trim(),u={welcome_msg:r.length>0?r:null,description:a.length>0?a:null,hide_description:H,bundle_colour_from:o.length>0?o:null,bundle_colour_to:n.length>0?n:null,bundle_text_colour:"light"===d||"dark"===d?d:null,group_id:ef.length>0?ef:null};if(l){u.title=t,u.model_mode=ee.length>0?ee:null,u.project_id=er.length>0?er:null,u.speech_mode=es.length>0?es:null,u.memory_scope=eo.trim().length>0?eo.trim():null;let e=en.split(",").map(e=>e.trim()).filter(e=>e.length>0);(!ed||eu)&&(u.prerequisite_course_ids=e),u.auto_first_message=em}let h=await fetch(`${e}/orchestrators/${s.id}`,{method:"PUT",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify(u)});if(!h.ok){let e=`HTTP ${h.status}`;try{let t=await h.json();if("string"==typeof t.detail)e=t.detail;else if(t.detail&&"object"==typeof t.detail){let r="string"==typeof t.detail.detail?t.detail.detail:e;e="number"==typeof t.detail.row&&"string"==typeof t.detail.agent_id?`Row ${t.detail.row} (agent_id: ${t.detail.agent_id}): ${r}`:r}}catch{}throw Error(e)}let m=(await h.json()).orchestrator;if(!m?.id||!m.title||!Array.isArray(m.agent_list))throw Error("Invalid update orchestrator response");c(m),y.toast.success("Orchestrator updated"),i(!1)}catch(t){let e=t instanceof Error&&t.message?t.message:"Please check the backend and try again.";y.toast.error("Unable to save orchestrator",{description:e})}finally{eA(!1)}},[e,l,ed,eu,q,W,G,X,ee,er,es,eo,en,em,ef,z,K,H,s.id,i,c]),eL=(0,r.useCallback)(async()=>{if(window.confirm(`Archive "${s.title}"? This will remove it from the active orchestrator list.`)){eR(!0);try{let t=await fetch(`${e}/orchestrators/${s.id}`,{method:"DELETE",credentials:"include"});if(!t.ok){let e=`HTTP ${t.status}`;try{let r=await t.json();"string"==typeof r.detail&&(e=r.detail)}catch{}throw Error(e)}n(s.id),y.toast.success("Orchestrator archived"),i(!1)}catch(t){let e=t instanceof Error&&t.message?t.message:"Please check the backend and try again.";y.toast.error("Unable to archive orchestrator",{description:e})}finally{eR(!1)}}},[e,n,i,s.id,s.title]),eU=eT||eO,eG=(0,r.useCallback)(async()=>{let t=await (0,E.exportOrchestratorBundleCsv)({apiUrl:e,orchestratorId:s.id,title:s.title});if(!t.ok&&"no_window"!==t.error){if("http"===t.error)return void y.toast.error("Unable to export CSV",{description:`HTTP ${t.status}`});y.toast.error("Unable to export CSV",{description:"Please check the backend and try again."})}},[e,s.id,s.title]);return(0,t.jsx)(S.Dialog,{open:o,onOpenChange:e=>{(e||!eU)&&i(e)},children:(0,t.jsxs)(S.DialogContent,{children:[(0,t.jsxs)(S.DialogHeader,{children:[(0,t.jsx)(S.DialogTitle,{children:l?"Edit orchestrator":"Edit workflow"}),(0,t.jsx)(S.DialogDescription,{children:l?"Update the card title, description and welcome message shown on this screen.":"Update the description, welcome message, colours and group shown on this screen."})]}),(0,t.jsxs)("div",{className:"space-y-3 py-2",children:[l?(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("label",{htmlFor:m,className:"text-sm font-medium",children:"Title"}),(0,t.jsx)(C.Input,{id:m,value:G,onChange:e=>F(e.target.value),disabled:eU,autoFocus:!0})]}):null,(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("label",{htmlFor:x,className:"text-sm font-medium",children:"Description"}),(0,t.jsx)(k.Textarea,{id:x,value:K,onChange:e=>Y(e.target.value),disabled:eU||H,rows:3,placeholder:"Shown on the orchestrator tile (falls back to the welcome message)"}),(0,t.jsxs)("label",{htmlFor:J,className:"flex items-center gap-2 pt-1 text-sm text-muted-foreground",children:[(0,t.jsx)("input",{id:J,type:"checkbox",checked:H,onChange:e=>M(e.target.checked),disabled:eU,className:"h-4 w-4"}),"Empty description (show no subtitle â don't fall back to the welcome message)"]})]}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("label",{htmlFor:p,className:"text-sm font-medium",children:"Welcome message"}),(0,t.jsx)(k.Textarea,{id:p,value:z,onChange:e=>B(e.target.value),disabled:eU,rows:4,placeholder:"Optional"})]}),(0,t.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2",children:[(0,t.jsx)(_,{id:g,label:"Gradient from",value:q,onChange:V,disabled:eU,placeholder:"#123456"}),(0,t.jsx)(_,{id:f,label:"Gradient to",value:W,onChange:Q,disabled:eU,placeholder:"#abcdef"})]}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("label",{htmlFor:j,className:"text-sm font-medium",children:"Text colour"}),(0,t.jsxs)("select",{id:j,value:X,onChange:e=>Z(e.target.value),disabled:eU,className:"border-input bg-background flex h-9 w-full rounded-md border px-3 py-1 text-base shadow-xs outline-none transition-[color,box-shadow] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",children:[(0,t.jsx)("option",{value:"",children:"Default"}),(0,t.jsx)("option",{value:"light",children:"Light"}),(0,t.jsx)("option",{value:"dark",children:"Dark"})]})]}),l?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("label",{htmlFor:b,className:"text-sm font-medium",children:"Model mode"}),(0,t.jsxs)("select",{id:b,value:ee,onChange:e=>et(e.target.value),disabled:eU,className:"border-input bg-background flex h-9 w-full rounded-md border px-3 py-1 text-base shadow-xs outline-none transition-[color,box-shadow] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",children:[(0,t.jsx)("option",{value:"",children:"Non-thinking â minimal reasoning (default)"}),(0,t.jsx)("option",{value:"gemini_thinking",children:"Thinking â high reasoning"})]})]}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("label",{htmlFor:v,className:"text-sm font-medium",children:"Linked project"}
1),(0,t.jsxs)("select",{id:v,value:er,onChange:e=>ea(e.target.value),disabled:eU,className:"border-input bg-background flex h-9 w-full rounded-md border px-3 py-1 text-base shadow-xs outline-none transition-[color,box-shadow] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",children:[(0,t.jsx)("option",{value:"",children:"None (use first active project)"}),d.map(e=>(0,t.jsx)("option",{value:e.project_id,children:e.name},e.project_id))]})]}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("label",{htmlFor:w,className:"text-sm font-medium",children:"Speech (read replies aloud)"}),(0,t.jsxs)("select",{id:w,value:es,onChange:e=>el(e.target.value),disabled:eU,className:"border-input bg-background flex h-9 w-full rounded-md border px-3 py-1 text-base shadow-xs outline-none transition-[color,box-shadow] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",children:[(0,t.jsx)("option",{value:"",children:"Off (no speech)"}),(0,t.jsx)("option",{value:"per_message",children:"Speak button on each reply"}),(0,t.jsx)("option",{value:"auto",children:"Auto â read every reply aloud"})]})]}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("label",{htmlFor:A,className:"text-sm font-medium",children:"Memory scope"}),(0,t.jsx)(C.Input,{id:A,value:eo,onChange:e=>ei(e.target.value),disabled:eU,placeholder:"blank = private to this bundle"}),(0,t.jsx)("p",{className:"text-muted-foreground text-xs",children:"Bundles in the same project that share this name share one project memory (lower-case letters, digits, - or _)."})]}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("label",{htmlFor:O,className:"text-sm font-medium",children:"Prerequisite course ids"}),(0,t.jsx)(C.Input,{id:O,value:en,onChange:e=>{eh(!0),ec(e.target.value)},disabled:eU,placeholder:"e.g. mbai_u01, mbai_u02"}),ed?(0,t.jsx)("p",{className:"text-destructive text-xs",children:"The stored value could not be read, so it is not shown here. This tile stays LOCKED for every student until it is repaired. Type the course ids it should require, or clear this box to remove the gate; leaving it untouched keeps the unreadable value as it is."}):null,(0,t.jsx)("p",{className:"text-muted-foreground text-xs",children:"Until the signed-in student has completed every course listed, this tile only says that the content is not yet available."})]}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsxs)("label",{htmlFor:ex,className:"flex items-center gap-2 text-sm font-medium",children:[(0,t.jsx)("input",{id:ex,type:"checkbox",checked:em,onChange:e=>ep(e.target.checked),disabled:eU,className:"h-4 w-4"}),"Start the conversation automatically"]}),(0,t.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Every new chat opens by sending â",T.AUTO_FIRST_MESSAGE,"â as the user's first message, so the agent replies before the user types. It is visible in the transcript and counts as a conversation turn."]})]})]}):null,(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("label",{htmlFor:eg,className:"text-sm font-medium",children:"Group"}),l?(0,t.jsx)("button",{type:"button",className:"text-xs text-muted-foreground hover:text-foreground",disabled:eU||eN||0===eb.length,onClick:()=>eE(e=>!e),children:ek?"Done":"Manage groups"}):null]}),(0,t.jsxs)("select",{id:eg,value:ev?I:ef,onChange:e=>{let t=e.target.value;t===I?ew(!0):(ew(!1),ej(t))},disabled:eU||eN,className:"border-input bg-background flex h-9 w-full rounded-md border px-3 py-1 text-base shadow-xs outline-none transition-[color,box-shadow] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",children:[(0,t.jsx)("option",{value:"",children:"None"}),eb.map(e=>(0,t.jsx)("option",{value:e.id,children:e.name},e.id)),(0,t.jsx)("option",{value:I,children:"Create new groupâ¦"})]}),ev?(0,t.jsxs)("div",{className:"flex gap-2 pt-1",children:[(0,t.jsx)(C.Input,{value:eC,onChange:e=>e_(e.target.value),placeholder:"New group name",disabled:eN,onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),eD())}}),(0,t.jsx)(N.Button,{type:"button",size:"sm",onClick:()=>void eD(),disabled:eN,children:"Create"})]}):null,ek?(0,t.jsx)("ul",{className:"space-y-1 pt-1",children:eb.map(e=>(0,t.jsxs)("li",{className:"flex items-center justify-between gap-2 text-sm",children:[(0,t.jsx)("span",{className:"truncate",children:e.name}),(0,t.jsxs)("span",{className:"flex shrink-0 gap-1",children:[(0,t.jsx)(N.Button,{type:"button",variant:"ghost",size:"sm",disabled:eN,onClick:()=>void e$(e),children:"Rename"}),(0,t.jsx)(N.Button,{type:"button",variant:"ghost",size:"sm",className:"text-destructive",disabled:eN,onClick:()=>void eP(e),children:"Delete"})]})]},e.id))}):null]})]}),(0,t.jsxs)(S.DialogFooter,{children:[l?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(N.Button,{type:"button",variant:"outline",disabled:eU,onClick:()=>{eU||u.push(`/orchestrators/bundle-editor?orchestratorId=${encodeURIComponent(s.id)}`)},children:"Edit bundle"}),(0,t.jsx)(N.Button,{type:"button",variant:"outline",onClick:()=>void eG(),disabled:eU,children:"Export CSV"}),(0,t.jsx)(N.Button,{type:"button",variant:"destructive",className:"sm:mr-auto",onClick:()=>
1void eL(),disabled:eU,children:eO?"Archiving...":"Archive"})]}):null,(0,t.jsx)(N.Button,{type:"button",variant:"ghost",onClick:()=>{eU||i(!1)},disabled:eU,children:"Cancel"}),(0,t.jsx)(N.Button,{type:"button",onClick:()=>void eI(),disabled:eU,children:eT?"Saving...":"Save"})]})]})})}let G=(0,n.default)("Star",[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]]);function F({favorite:e,title:r,onToggle:a,disabled:s,className:l}){return(0,t.jsx)("button",{type:"button","aria-pressed":e,"aria-label":e?`Unstar ${r}`:`Star ${r}`,disabled:s,onClick:e=>{e.preventDefault(),e.stopPropagation(),a()},className:(0,u.cn)("inline-flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground transition-colors hover:text-amber-500 disabled:cursor-not-allowed disabled:opacity-50",e&&"text-amber-500",l),children:(0,t.jsx)(G,{className:(0,u.cn)("h-4 w-4",e&&"fill-current")})})}var z=e.i(321205),B=e.i(854455);function K({apiUrl:e,orchestrator:a,canEdit:s,isSuperAdmin:l=!1,theme:i,onEnterChat:n,onOrchestratorArchived:c,onOrchestratorSaved:d,projects:h=[],favorite:m,onToggleFavorite:p}){let[x,g]=(0,r.useState)(!1),f=(0,z.bundleGradientBackgroundStyle)(a.bundle_colour_from,a.bundle_colour_to),j="light"===a.bundle_text_colour,b="dark"===a.bundle_text_colour,y=a.hide_description?null:a.description?.trim()||a.welcome_msg;return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{"data-testid":"orchestrator-card",className:"flex flex-col overflow-hidden rounded-2xl border border-border bg-card shadow-sm transition-colors hover:bg-muted/50",style:i?{backgroundColor:i.background,borderColor:i.border,color:i.foreground}:f,children:[p||s?(0,t.jsxs)("div",{className:"flex shrink-0 items-center justify-between px-2 pt-2",children:[p?(0,t.jsx)(F,{favorite:!!m,title:a.title,onToggle:()=>p(a.id),className:(0,u.cn)(j&&"text-white/80 hover:text-amber-300",b&&"text-neutral-950/70 hover:text-amber-600")}):(0,t.jsx)("span",{"aria-hidden":"true"}),s?(0,t.jsx)(N.Button,{type:"button",variant:"ghost",size:"icon",className:(0,u.cn)("h-8 w-8 shrink-0 text-muted-foreground hover:text-foreground",j&&"text-white/80 hover:text-white",b&&"text-neutral-950/70 hover:text-neutral-950"),"aria-label":`Edit ${a.title}`,onClick:()=>{g(!0)},children:(0,t.jsx)(v.Pencil,{className:"h-4 w-4"})}):null]}):null,(0,t.jsxs)("div",{className:"min-h-0 flex-1 space-y-2 px-5 pb-4 pt-3 sm:px-6 sm:pb-5 sm:pt-4",children:[(0,t.jsx)(o.default,{href:"/chat",className:"group block",onClick:()=>{n(a)},children:(0,t.jsx)("h2",{className:(0,u.cn)("text-base font-semibold tracking-tight sm:text-lg",i?"text-current":"text-card-foreground",!i&&j&&"text-white",!i&&b&&"text-neutral-950"),children:a.title})}),y?(0,t.jsx)("div",{"data-testid":"orchestrator-card-subtitle",className:(0,u.cn)("text-sm",i?"text-current/75":"text-muted-foreground",!i&&j&&"text-white/80",!i&&b&&"text-neutral-950/75"),children:(0,t.jsx)(B.MarkdownText,{children:y})}):null,(0,t.jsxs)(o.default,{href:"/chat",className:(0,u.cn)("flex items-center gap-1 text-xs",i?"text-current":"text-primary",!i&&j&&"text-white",!i&&b&&"text-neutral-950"),onClick:()=>{n(a)},children:[(0,t.jsx)("span",{children:"Enter chat"}),(0,t.jsx)("span",{"aria-hidden":"true",children:"â"})]})]})]}),s?(0,t.jsx)(U,{apiUrl:e,orchestrator:a,isSuperAdmin:l,open:x,onOpenChange:g,onArchived:c,onSaved:d,projects:h}):null]})}function Y({apiUrl:e,orchestrator:a,canEdit:s,isSuperAdmin:l=!1,projects:i=[],favorite:n,onToggleFavorite:c,onEnterChat:d,onOrchestratorArchived:u,onOrchestratorSaved:h}){let[m,p]=(0,r.useState)(!1),x=a.hide_description?null:a.description?.trim()||a.welcome_msg;return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{"data-testid":"workflow-row",className:"flex items-center gap-2 rounded-lg border border-border bg-card px-2 py-2 transition-colors hover:bg-muted/50",children:[c?(0,t.jsx)(F,{favorite:!!n,title:a.title,onToggle:()=>c(a.id)}):null,(0,t.jsxs)(o.default,{href:"/chat",className:"group flex min-w-0 flex-1 flex-col",onClick:()=>d(a),children:[(0,t.jsxs)("span",{className:"flex min-w-0 flex-wrap items-baseline gap-x-2 gap-y-1",children:[(0,t.jsx)("span",{title:a.title,className:"break-words text-base font-bold text-card-foreground",children:a.title}),a.group_name?(0,t.jsx)("span",{className:"shrink-0 rounded bg-muted px-1.5 py-0.5 text-[11px] text-muted-foreground",children:a.group_name}):null]}),x?(0,t.jsx)("span",{title:x,className:"truncate text-xs text-muted-foreground",children:x}):null]}),s?(0,t.jsx)(N.Button,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0 text-muted-foreground hover:text-foreground","aria-label":`Edit ${a.title}`,onClick:()=>p(!0),children:(0,t.jsx)(v.Pencil,{className:"h-4 w-4"})}):null]}),s?(0,t.jsx)(U,{apiUrl:e,orchestrator:a,isSuperAdmin:l,projects:i,open:m,onOpenChange:p,onArchived:u,onSaved:h}):null]})}let H="ui.favorite_orchestrators",M="ui.workflow_view_mode",J="ui.workflow_sort",q="ui.workflow_folded_sections",V={mode:"alpha",dir:"asc"};async function W(e){try{let t=await fetch(`${e}/me/preferences`,{credentials:"include"});if(!t.ok)return{};let r=await t.json(),a={};
1for(let e of r.preferences??[])e.key&&void 0!==e.value&&(a[e.key]=e.value);return a}catch{return{}}}async function Q(e,t){try{let r=await fetch(`${e}/me/preferences?key=${encodeURIComponent(t)}`,{credentials:"include"});if(!r.ok)return null;let a=await r.json(),s=a.preferences?.[0];return s&&void 0!==s.value?s.value:null}catch{return null}}async function X(e,t,r){let a=await fetch(`${e}/me/preferences/${encodeURIComponent(t)}`,{method:"PUT",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({value:r})});if(!a.ok)throw Error(`HTTP ${a.status}`)}async function Z(e,t){let r=await Q(e,H)??[],a=Array.isArray(r)?r.filter(e=>"string"==typeof e):[],s=a.includes(t)?a.filter(e=>e!==t):[...a,t];return await X(e,H,s),s}function ee(e){if(!e)return null;let t=Date.parse(e);return Number.isNaN(t)?null:t}function et(e,t){return[...e].sort((e,r)=>(function(e,t,r){let a="desc"===r.dir?-1:1;if("alpha"===r.mode)return a*e.title.localeCompare(t.title);let s="accessed"===r.mode?"last_accessed_at":"created_at",l=ee(e[s]),o=ee(t[s]);return null===l&&null===o?e.title.localeCompare(t.title):null===l?1:null===o?-1:l===o?e.title.localeCompare(t.title):a*(l-o)})(e,r,t))}let er={alpha:"Alphabetical",accessed:"Date accessed",added:"Date added"};function ea(e){return"alpha"===e.mode?"asc"===e.dir?"AâZ":"ZâA":"desc"===e.dir?"Newest":"Oldest"}function es(e){return Array.isArray(e)?e.filter(e=>"string"==typeof e):[]}function el({apiUrl:e,orchestrators:a,isSuperAdmin:s,isRbacAdmin:l=!1,onEnterChat:o,onOrchestratorArchived:i,onOrchestratorSaved:n,projects:c=[],resolveTheme:d}){let h=s||l,[m,v]=(0,r.useState)("grid"),[w,_]=(0,r.useState)(V),[S,k]=(0,r.useState)(""),[E,T]=(0,r.useState)([]),[A,O]=(0,r.useState)([]);(0,r.useEffect)(()=>{let t=!0;return(async()=>{let r=await W(e);if(!t)return;let a=r[M],s=r[J];O(es(r[H])),("grid"===a||"list"===a)&&v(a),s&&"object"==typeof s&&("alpha"===s.mode||"accessed"===s.mode||"added"===s.mode)&&("asc"===s.dir||"desc"===s.dir)&&_(s),T(es(r[q]))})(),()=>{t=!1}},[e]);let R=(0,r.useMemo)(()=>(function(e){let t,{workflows:r,favoriteIds:a,sort:s,search:l}=e,o=r.filter(e=>{let t;return!(t=l.trim().toLowerCase())||[e.title,e.welcome_msg,e.group_name].some(e=>(e??"").toLowerCase().includes(t))}),i=[],n=(t=new Map(o.map(e=>[e.id,e])),a.map(e=>t.get(e)).filter(e=>void 0!==e));n.length>0&&i.push({id:"favorites",title:"Favorites",workflows:et(n,s)});let c=new Map;for(let e of o){if(!e.group_id)continue;let t=c.get(e.group_id)??{name:e.group_name??"Group",items:[]};t.items.push(e),c.set(e.group_id,t)}for(let[e,t]of[...c.entries()].sort((e,t)=>e[1].name.localeCompare(t[1].name)))i.push({id:`group:${e}`,title:t.name,workflows:et(t.items,s)});let d=r.some(e=>e.group_id),u=o.filter(e=>!e.group_id);return u.length>0&&i.push({id:"all",title:d?"Other workflows":"All workflows",workflows:et(u,s)}),i})({workflows:a,favoriteIds:A,sort:w,search:S}),[a,A,w,S]),D=(0,r.useMemo)(()=>new Set(A),[A]),$=(0,r.useMemo)(()=>new Set(E),[E]),P=(0,r.useCallback)((t,r)=>{X(e,t,r).catch(()=>{})},[e]),I=(0,r.useCallback)(e=>{v(e),P(M,e)},[P]),L=(0,r.useCallback)(e=>{_(t=>{let r={...t,mode:e};return P(J,r),r})},[P]),U=(0,r.useCallback)(()=>{_(e=>{let t={...e,dir:"asc"===e.dir?"desc":"asc"};return P(J,t),t})},[P]),G=(0,r.useCallback)(e=>{T(t=>{let r=t.includes(e)?t.filter(t=>t!==e):[...t,e];return P(q,r),r})},[P]),F=(0,r.useCallback)(async t=>{let r=A.includes(t);O(e=>r?e.filter(e=>e!==t):[...e,t]);try{let r=await Z(e,t);O(es(r))}catch{O(e=>r?e.includes(t)?e:[...e,t]:e.filter(e=>e!==t)),y.toast.error("Unable to update favourites")}},[e,A]);return 0===a.length?(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"No orchestrators are currently configured for your account."}):(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsxs)("div",{className:"relative min-w-[180px] flex-1",children:[(0,t.jsx)(j.Search,{className:"pointer-events-none absolute left-2 top-1/2 size-4 -translate-y-1/2 text-muted-foreground"}),(0,t.jsx)(C.Input,{type:"search",value:S,onChange:e=>k(e.target.value),placeholder:"Search workflows...","aria-label":"Search workflows",className:"pl-8 pr-8"}),S?(0,t.jsx)("button",{type:"button","aria-label":"Clear search",onClick:()=>k(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:(0,t.jsx)(b.X,{className:"size-4"})}):null]}
1),(0,t.jsx)("select",{"aria-label":"Sort by",value:w.mode,onChange:e=>L(e.target.value),className:"border-input bg-background h-9 rounded-md border px-3 py-1 text-sm shadow-xs outline-none",children:Object.keys(er).map(e=>(0,t.jsx)("option",{value:e,children:er[e]},e))}),(0,t.jsx)(N.Button,{type:"button",variant:"outline",size:"sm","aria-label":`Toggle sort direction (currently ${ea(w)})`,onClick:U,children:ea(w)}),(0,t.jsxs)("div",{className:"flex items-center rounded-md border border-input",children:[(0,t.jsx)(N.Button,{type:"button",variant:"ghost",size:"icon","aria-label":"Grid view","aria-pressed":"grid"===m,className:(0,u.cn)("h-9 w-9 rounded-r-none","grid"===m&&"bg-muted"),onClick:()=>I("grid"),children:(0,t.jsx)(g,{className:"size-4"})}),(0,t.jsx)(N.Button,{type:"button",variant:"ghost",size:"icon","aria-label":"List view","aria-pressed":"list"===m,className:(0,u.cn)("h-9 w-9 rounded-l-none","list"===m&&"bg-muted"),onClick:()=>I("list"),children:(0,t.jsx)(f,{className:"size-4"})})]})]}),0===R.length?(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"No workflows match your search."}):R.map(r=>{let a=$.has(r.id);return(0,t.jsxs)("section",{className:"space-y-3",children:[(0,t.jsxs)("button",{type:"button","aria-expanded":!a,onClick:()=>G(r.id),className:"flex w-full items-center gap-1.5 text-left text-sm font-semibold text-foreground",children:[a?(0,t.jsx)(x.ChevronRight,{className:"size-4"}):(0,t.jsx)(p.ChevronDown,{className:"size-4"}),(0,t.jsx)("span",{children:r.title}),(0,t.jsxs)("span",{className:"text-xs font-normal text-muted-foreground",children:["(",r.workflows.length,")"]})]}),a?null:"grid"===m?(0,t.jsx)("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2 sm:gap-6 lg:grid-cols-3",children:r.workflows.map(a=>(0,t.jsx)(K,{apiUrl:e,orchestrator:a,canEdit:h,isSuperAdmin:s,theme:d?d(a):null,favorite:D.has(a.id),onToggleFavorite:F,onEnterChat:o,onOrchestratorArchived:i,onOrchestratorSaved:n,projects:c},`${r.id}:${a.id}`))}):(0,t.jsx)("div",{className:"space-y-2",children:r.workflows.map(a=>(0,t.jsx)(Y,{apiUrl:e,orchestrator:a,canEdit:h,isSuperAdmin:s,projects:c,favorite:D.has(a.id),onToggleFavorite:F,onEnterChat:o,onOrchestratorArchived:i,onOrchestratorSaved:n},`${r.id}:${a.id}`))})]},r.id)})]})}var eo=e.i(958600),ei=e.i(272596),en=e.i(280218),ec=e.i(800216),ed=e.i(130751),eu=e.i(607154),eh=e.i(340043);function em({projects:e,value:a,onChange:s,disabled:l=!1}){let[o,i]=r.useState(!1),n=e.find(e=>e.project_id===a);return(0,t.jsxs)(eh.Popover,{open:o,onOpenChange:i,children:[(0,t.jsx)(eh.PopoverTrigger,{asChild:!0,children:(0,t.jsxs)(N.Button,{variant:"outline",role:"combobox","aria-expanded":o,className:"w-full justify-between",disabled:l,children:[n?n.name:"Select project...",(0,t.jsx)(ed.ChevronsUpDown,{className:"opacity-50"})]})}),(0,t.jsx)(eh.PopoverContent,{className:"w-(--radix-popover-trigger-width) p-0",children:(0,t.jsxs)(eu.Command,{children:[(0,t.jsx)(eu.CommandInput,{placeholder:"Search project...",className:"h-9"}),(0,t.jsxs)(eu.CommandList,{children:[(0,t.jsx)(eu.CommandEmpty,{children:"No project found."}),(0,t.jsx)(eu.CommandGroup,{children:e.map(e=>(0,t.jsxs)(eu.CommandItem,{value:`${e.name} ${e.project_id}`,onSelect:()=>{s(e.project_id),i(!1)},children:[e.name,(0,t.jsx)(ec.Check,{className:(0,u.cn)("ml-auto",a===e.project_id?"opacity-100":"opacity-0")})]},e.project_id))})]})]})})]})}var ep=e.i(775680),ex=e.i(62304),eg=e.i(480380),ef=e.i(623646),ej=e.i(407027),eb=e.i(489205),ey=e.i(165429);let ev=[{value:"owner",label:"Owner only",hint:"Only you, plus access-control admins, can see this project and its memories."},{value:"whitelist",label:"White list",hint:"Only the team members you name below."},{value:"open",label:"Open access",hint:"Everyone with access to this site."}];function ew(e){return e.full_name||e.email||e.user_id}function eC({apiUrl:e,projectId:a,projectName:s,open:l,onOpenChange:o}){let[i,n]=(0,r.useState)(!1),[c,d]=(0,r.useState)(!1),[u,h]=(0,r.useState)("owner"),[m,p]=(0,r.useState)(null),[x,g]=(0,r.useState)([]),[f,j]=(0,r.useState)(""),v=(0,r.useMemo)(()=>(e,t)=>(0,ef.lookupProjectUserByEmail)(e,a??"",t),[a]);(0,r.useEffect)(()=>
1{if(!l||!a)return;let t=!1;return n(!0),(async()=>{try{let r=await (0,ef.fetchProjectAccess)(e,a);if(t)return;p(r.owner_user_id),h((0,ef.projectAccessChoice)(r)),j(r.member_domains.join("\n")),g(r.members??[])}catch(e){if(t)return;y.toast.error(e instanceof Error?e.message:"Failed to load access settings"),o(!1)}finally{t||n(!1)}})(),()=>{t=!0}},[l,e,a,o]);let w=async()=>{if(a){d(!0);try{await (0,ef.saveProjectAccess)(e,a,{mode:"open"===u?"open":"whitelist",member_user_ids:"owner"===u?[]:x.map(e=>e.user_id),member_domains:"owner"===u?[]:f.split(/[\n,]/).map(e=>e.trim()).filter(Boolean)}),y.toast.success("Access updated"),o(!1)}catch(e){y.toast.error(e instanceof Error?e.message:"Failed to save access")}finally{d(!1)}}};return(0,t.jsx)(S.Dialog,{open:l,onOpenChange:o,children:(0,t.jsxs)(S.DialogContent,{children:[(0,t.jsxs)(S.DialogHeader,{children:[(0,t.jsxs)(S.DialogTitle,{children:["Access control â ",s]}),(0,t.jsx)(S.DialogDescription,{children:"Choose who can see this project and everything remembered in it."})]}),i?(0,t.jsxs)("p",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[(0,t.jsx)(eg.Loader2,{className:"size-4 animate-spin"})," Loadingâ¦"]}):(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("fieldset",{className:"space-y-2",children:[(0,t.jsx)("legend",{className:"sr-only",children:"Who can access this project"}),ev.map(e=>(0,t.jsxs)("label",{className:"flex cursor-pointer items-start gap-2 rounded-md border p-3 text-sm",children:[(0,t.jsx)("input",{type:"radio",name:"project-access",className:"mt-1",value:e.value,checked:u===e.value,onChange:()=>h(e.value)}),(0,t.jsxs)("span",{children:[(0,t.jsx)("span",{className:"font-medium",children:e.label}),(0,t.jsx)("span",{className:"block text-muted-foreground",children:e.hint})]})]},e.value))]}),"whitelist"===u?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(ey.Label,{children:"Team members"}),x.length>0?(0,t.jsx)("ul",{className:"flex flex-wrap gap-2",children:x.map(e=>(0,t.jsxs)("li",{className:"flex items-center gap-1.5 rounded-full border bg-muted py-1 pl-1 pr-1 text-sm",children:[(0,t.jsx)(ej.UserAvatar,{user:e,className:"size-5"}),(0,t.jsx)("span",{className:"max-w-[16rem] truncate",title:e.email,children:ew(e)}),(0,t.jsx)(N.Button,{type:"button",size:"icon",variant:"ghost",className:"size-5 rounded-full","aria-label":`Remove ${ew(e)}`,onClick:()=>g(t=>t.filter(t=>t.user_id!==e.user_id)),children:(0,t.jsx)(b.X,{className:"size-3.5"})})]},e.user_id))}):(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"No one added yet â search to add people."}),(0,t.jsx)(eb.UserPicker,{apiUrl:e,excludeIds:[...x.map(e=>e.user_id),...m?[m]:[]],onSelect:e=>g(t=>t.some(t=>t.user_id===e.user_id)?t:[...t,e]),closeOnSelect:!1,triggerLabel:"Add a team memberâ¦",placeholder:"Type their full email address",search:v})]}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)(ey.Label,{children:"Email domains (one per line)"}),(0,t.jsx)(k.Textarea,{rows:2,placeholder:"thinkerbell.com",value:f,onChange:e=>j(e.target.value)})]})]}):null,(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"You keep access whichever option you choose."})]}),(0,t.jsxs)(S.DialogFooter,{children:[(0,t.jsx)(N.Button,{variant:"outline",onClick:()=>o(!1),children:"Cancel"}),(0,t.jsx)(N.Button,{onClick:w,disabled:i||c,children:c?"Savingâ¦":"Save"})]})]})})}let e_="A project is a place where the memories of all work done with any agents is shared. Any new project you create will default to only you having access to these memories, but you can control which team members (or nominate everyone) to have access. To start agentic work afresh with no memories, create a new project. Use the ACCESS CONTROL button on the next page to add or remove access to team members to your projects.",eN="A project is a place where the memories of all work done with any agents is shared. Everyone with access to this site shares the projects set up here. To start agentic work afresh with no memories, create a new project.";function eS(e){d.selectionStorage.setItem(d.SELECTED_ORCHESTRATOR_STORAGE_KEY,JSON.stringify(e));let t=(0,d.getPrimaryAgentId)(e);if(t)d.selectionStorage.setItem(d.SELECTED_AGENT_STORAGE_KEY,t);else d.selectionStorage.removeItem(d.SELECTED_AGENT_STORAGE_KEY);window.dispatchEvent(new Event(d.AGENT_STORAGE_SYNC_EVENT))}function ek(e,t){d.selectionStorage.setItem(d.SELECTED_PROJECT_STORAGE_KEY,e),t&&d.selectionStorage.setItem(d.SELECTED_PROJECT_NAME_STORAGE_KEY,t),window.dispatchEvent(new Event(d.PROJECT_STORAGE_SYNC_EVENT))}function eE(){d.selectionStorage.removeItem(d.SELECTED_ORCHESTRATOR_STORAGE_KEY),d.selectionStorage.removeItem(d.SELECTED_AGENT_STORAGE_KEY)}function eT(){let e=(0,a.useSearchParams)(),n=(0,a.useRouter)().replace,u=(0,a.usePathname)(),h=(0,ei.resolveApiUrl)("https://api.dev.inclusivelymade.ai"),p=(0,ex.currentEnvLicense)(),x=p.heroLogo??p.signInLogo,g=p.kioskMode,[f,j]=r.default.useState([]),[b,v]=r.default.useState([]),[w,_]=r.default.useState(null),[k,E]=r.default.useState(()=>{try{let e=new URLSearchParams(window.location.search).get(d.LANDING_FOCUS_PROJECT_QUERY_KEY);
1return e===d.LANDING_FOCUS_PROJECT_QUERY_VALUE||"true"===e}catch{return!1}}),[T,A]=r.default.useState(!0),[O,R]=r.default.useState(!0),[D,$]=r.default.useState(!1),[P,I]=r.default.useState(!1),[L,U]=r.default.useState(!1),[G,F]=r.default.useState(!1),[z,B]=r.default.useState(!1),[K,Y]=r.default.useState(!1),[H,M]=r.default.useState(!1),[J,q]=r.default.useState(!1),[V,W]=r.default.useState(!1),[Q,X]=r.default.useState(!1),[Z,ee]=r.default.useState(""),[et,er]=r.default.useState(!1),[ea,es]=r.default.useState(""),[ec,ed]=r.default.useState(""),[eu,eh]=r.default.useState(null),[eg,ef]=r.default.useState(!1),[ej,eb]=r.default.useState(!1),ey=r.default.useContext(s.AuthGateUserContext);r.default.useEffect(()=>{let t=e.get(d.LANDING_FOCUS_PROJECT_QUERY_KEY);(t===d.LANDING_FOCUS_PROJECT_QUERY_VALUE||"true"===t)&&(E(!0),n(u||"/",{scroll:!1}))},[e,n,u]),r.default.useEffect(()=>{let e=!0;return(async()=>{A(!0),R(!0);try{var t;let r=await (0,en.fetchLandingData)(h,(0,d.getSelectedStoredProjectId)());if(!e)return;j(r.projects),v(r.orchestrators),_(r.selectedProjectId),$(r.isSuperAdmin),I(r.isRbacAdmin),U(r.superUsersOnlyCanMakeProjects),M(r.orchestratorLinkedProject),F(r.personalProjects);let a=r.autoGenerateProject||g;B(r.autoGenerateProject),Y(!0);let s=r.singleAgentOrchestratorKey||(g?p.customerId:null);(t={autoGenerateProject:a,singleAgentOrchestratorKey:s,projectSwitcherHidden:r.orchestratorLinkedProject&&!r.isSuperAdmin}).autoGenerateProject?d.selectionStorage.setItem(d.AUTO_GENERATE_PROJECT_STORAGE_KEY,"true"):d.selectionStorage.removeItem(d.AUTO_GENERATE_PROJECT_STORAGE_KEY),t.singleAgentOrchestratorKey?d.selectionStorage.setItem(d.SINGLE_AGENT_ORCHESTRATOR_KEY_STORAGE_KEY,t.singleAgentOrchestratorKey):d.selectionStorage.removeItem(d.SINGLE_AGENT_ORCHESTRATOR_KEY_STORAGE_KEY),t.projectSwitcherHidden?d.selectionStorage.setItem(d.PROJECT_SWITCHER_HIDDEN_STORAGE_KEY,"true"):d.selectionStorage.removeItem(d.PROJECT_SWITCHER_HIDDEN_STORAGE_KEY);let l=r.selectedProjectId;if(l){let e=r.projects.find(e=>e.project_id===l);ek(l,e?.name)}("/"===u||""===u)&&(g||a&&s&&l)&&(1===r.orchestrators.length?eS(r.orchestrators[0]):s&&eE(),eb(!0),n("/chat"))}catch{if(!e)return;let t="/"===u||""===u;if(g&&t){eb(!0),n("/chat");return}y.toast.error("Unable to load projects",{description:"Please make sure the backend is running and try again."})}finally{e&&(A(!1),R(!1))}})(),()=>{e=!1}},[h,g,p.customerId,u,n]);let ev=r.default.useCallback(async()=>{let e=Z.trim();if(!e)return void y.toast.error("Project name is required");q(!0);try{let t=await fetch(`${h}/projects`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e})});if(!t.ok)throw Error(`HTTP ${t.status}`);let r=await t.json();if(!r.project?.project_id)throw Error("Invalid create project response");let a=r.project;j(e=>[...e.filter(e=>e.project_id!==a.project_id),a].sort((e,t)=>e.name.localeCompare(t.name))),_(a.project_id),ek(a.project_id,a.name),E(!1),ee(""),W(!1),y.toast.success("Project created",{description:`Selected ${a.name}.`})}catch{y.toast.error("Unable to create project",{description:"Please check the backend and try again."})}finally{q(!1)}},[h,Z]),ew=r.default.useCallback(e=>{v(t=>t.map(t=>t.id===e.id?{...e}:t));let t=(0,d.parseStoredOrchestrator)(d.selectionStorage.getItem(d.SELECTED_ORCHESTRATOR_STORAGE_KEY));t?.id===e.id&&eS(e)},[]),eT=r.default.useCallback(e=>{v(t=>t.filter(t=>t.id!==e));let t=(0,d.parseStoredOrchestrator)(d.selectionStorage.getItem(d.SELECTED_ORCHESTRATOR_STORAGE_KEY));t?.id===e&&eE()},[]),eA=r.default.useCallback(async()=>{let e=ea.trim();if(!e)return void y.toast.error("Title is required");if(!eu)return void y.toast.error("CSV Definition is required");ef(!0);try{let t=await (0,en.createOrchestrator)(h,{title:e,welcomeMessage:ec.trim(),csvFile:eu});v(e=>[...e.filter(e=>e.id!==t.id),t].sort((e,t)=>e.title.localeCompare(t.title))),er(!1),es(""),ed(""),eh(null),y.toast.success("Orchestrator created")}catch(a){let e=a.message??"Please check the backend and try again.",t=a.agentKey??a.agentId,r="";"number"==typeof a.row&&t?r=`Row ${a.row} (agent_key: ${t}): `:"number"==typeof a.row?r=`Row ${a.row}: `:t&&(r=`agent_key: ${t}: `),y.toast.error("Unable to create orchestrator",{description:`${r}${e}`})}finally{ef(!1)}},[h,eu,ea,ec]),eO=!!w,eR=!L||D,eD=z||H&&!D,e$=eD||eO,eP=eD||!K,eI=z||!K,eL=!eP&&(!eO||k),eU=eD||eO&&!k,eG=r.default.useCallback(e=>{if(eD){let t=z?null:e.project_id?.trim()||null,r=f[0]?.project_id??null,a=t||r;if(a){let e=f.find(e=>e.project_id===a);ek(a,e?.name)}}eS(e)},[z,eD,f]),eF=null!=w?f.find(e=>e.project_id===w)?.name?.trim()||w:null,ez=!!(null!=w&&f.find(e=>e.project_id===w)?.can_admin);return ej||g&&(T||O)?(0,t.jsx)("main",{className:"min-h-screen text-white im-chat-surface-inactive flex items-center justify-center px-4",children:(0,t.jsx)("p",{className:"text-sm uppercase tracking-[0.3em]",children:"Loading chat..."})}):(0,t.jsxs)("main",{className:"min-h-screen text-foreground flex items-center justify-center px-4",children:[ey&&!g?(0,t.jsx)(eo.UserMenu,{user:ey,apiUrl:h}):null,(0,t.jsxs)("div",{className:"max-w-4xl w-full space-y-10",children:[(0,t.jsxs)("header",{className:"text-center space-y-3",children:[p.landingLogos?(0,t.jsxs)("div",{className:"flex items-center justify-between gap-6",children:[(0,t.jsx)(l.default,{src:p.landingLogos.left.src,alt:p.landingLogos.left.alt,width:p.landingLogos.left.width,height:p.landingLogos.left.height,className:p.landingLogos.left.className}),(0,t.jsx)(l.default,{src:p.landingLogos.right.src,alt:p.landingLogos.right.alt,width:p.landingLogos.right.width,height:p.landingLogos.right.height,className:p.landingLogos.right.className})]}):(0,t.jsxs)("div",{className:"flex items-center justify-center gap-2",children:[(0,t.jsx)(l.default,{src:x.src,alt:x.alt,width:x.width,height:x.height,className:"h-16 w-auto"}),p.heroLogo?null:(0,t.jsx)("p",{className:"uppercase tracking-[0.3em] text-muted-foreground",children:p.brandTitle})]}),eI?null:(0,t.jsx)("h1",{className:"text-3xl sm:text-4xl md:text-5xl font-semibold tracking-tight",children:"Start your chat"})]}),eP?null:(0,t.jsx)(m,{canSelectAgent:e$,selectedProjectLabel:eF,onStepOneClick:()=>{e$&&E(!0)}}),eL?(0,t.jsxs)(ep.Card,{children:[(0,t.jsxs)(ep.CardHeader,{className:"space-y-1",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,t.jsx)(ep.CardTitle,{className:"min-w-0 flex-1 text-sm",children:"Step 1: Choose project"}),eR?(0,t.jsx)(N.Button,{type:"button",variant:"outline",size:"sm",className:"shrink-0",onClick:()=>W(!0),disabled:T||J,children:"+ New Project"}):null]}),(0,t.jsx)(ep.CardDescription,{className:"sr-only",children:"Your project choice is stored in the browser and applied when you start a chat."})]}),(0,t.jsx)(ep.CardContent,{children:(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:G?e_:eN}),(0,t.jsx)(em,{projects:f,value:w,disabled:T||J,onChange:e=>{_(e);let t=f.find(t=>t.project_id===e);
1ek(e,t?.name),E(!1)}}),k&&eO?(0,t.jsx)(N.Button,{type:"button",className:"w-full",onClick:()=>E(!1),children:"Continue to agent selection"}):null]})})]}):null,eU?(0,t.jsxs)(ep.Card,{children:[(0,t.jsxs)(ep.CardHeader,{className:"space-y-1",children:[z?null:(0,t.jsx)(ep.CardTitle,{className:"text-sm",children:"Step 2: Choose agent"}),(0,t.jsx)(ep.CardDescription,{className:"sr-only",children:"Pick how you want to start the conversation."})]}),(0,t.jsxs)(ep.CardContent,{children:[(0,t.jsx)("div",{className:"mb-4 flex justify-end",children:D||P||ez?(0,t.jsxs)("div",{className:"flex flex-wrap justify-end gap-2",children:[!P&&ez?(0,t.jsxs)(N.Button,{type:"button",variant:"outline",onClick:()=>X(!0),children:[(0,t.jsx)(c,{className:"size-4"}),"Access control"]}):null,D?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(N.Button,{asChild:!0,type:"button",variant:"outline",children:(0,t.jsxs)(o.default,{href:"/analytics",children:[(0,t.jsx)(i.BarChart3,{className:"size-4"}),"Analytics"]})}),(0,t.jsx)(N.Button,{type:"button",variant:"outline",onClick:()=>er(!0),children:"+ New Orchestrator"})]}):null,P?(0,t.jsx)(N.Button,{asChild:!0,type:"button",variant:"outline",children:(0,t.jsxs)(o.default,{href:"/admin/rbac",children:[(0,t.jsx)(c,{className:"size-4"}),"Access control"]})}):null]}):null}),O?(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Loading orchestrators..."}):(0,t.jsx)(el,{apiUrl:h,orchestrators:b,isSuperAdmin:D,isRbacAdmin:P,onEnterChat:eG,onOrchestratorArchived:eT,onOrchestratorSaved:ew,projects:f,resolveTheme:e=>(0,ex.themeForOrchestratorKey)(p.orchestratorCardTheme,e.agent_list[0]?.trim()||e.title.trim()||null)})]})]}):null,eI?null:e$?(0,t.jsx)("p",{className:"text-[11px] sm:text-xs text-center text-muted-foreground",children:"You can change Agent at any time from within the chat."}):(0,t.jsx)("p",{className:"text-[11px] sm:text-xs text-center text-muted-foreground",children:"Complete project selection to continue to agent selection."})]}),(0,t.jsx)(eC,{apiUrl:h,projectId:w,projectName:eF??"",open:Q,onOpenChange:X}),(0,t.jsx)(S.Dialog,{open:V,onOpenChange:e=>{W(e),e||J||ee("")},children:(0,t.jsxs)(S.DialogContent,{children:[(0,t.jsxs)(S.DialogHeader,{children:[(0,t.jsx)(S.DialogTitle,{children:"Create new project"}),(0,t.jsx)(S.DialogDescription,{children:"Enter a project name."})]}),(0,t.jsx)("div",{className:"py-2",children:(0,t.jsx)(C.Input,{value:Z,onChange:e=>ee(e.target.value),placeholder:"e.g. Q2 Campaign Planning",autoFocus:!0,disabled:J,onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),ev())}})}),(0,t.jsxs)(S.DialogFooter,{children:[(0,t.jsx)(N.Button,{type:"button",variant:"ghost",onClick:()=>{J||W(!1)},disabled:J,children:"Cancel"}),(0,t.jsx)(N.Button,{type:"button",onClick:()=>void ev(),disabled:J,children:J?"Creating...":"Create project"})]})]})}),(0,t.jsx)(S.Dialog,{open:et,onOpenChange:e=>{er(e),e||eg||(es(""),ed(""),eh(null))},children:(0,t.jsxs)(S.DialogContent,{children:[(0,t.jsxs)(S.DialogHeader,{children:[(0,t.jsx)(S.DialogTitle,{children:"Create new orchestrator"}),(0,t.jsx)(S.DialogDescription,{children:"Upload a CSV bundle definition and set landing card details."})]}),(0,t.jsxs)("div",{className:"space-y-3 py-2",children:[(0,t.jsx)(C.Input,{value:ea,onChange:e=>es(e.target.value),placeholder:"Title",disabled:eg}),(0,t.jsx)(C.Input,{value:ec,onChange:e=>ed(e.target.value),placeholder:"Welcome Message",disabled:eg}),(0,t.jsx)(C.Input,{type:"file",accept:".csv,text/csv","aria-label":"CSV Definition",disabled:eg,onChange:e=>{eh(e.currentTarget.files?.[0]??null)}})]}),(0,t.jsxs)(S.DialogFooter,{children:[(0,t.jsx)(N.Button,{type:"button",variant:"ghost",onClick:()=>{eg||er(!1)},disabled:eg,children:"Cancel"}),(0,t.jsx)(N.Button,{type:"button",onClick:()=>void eA(),disabled:eg,children:eg?"Creating...":"Create orchestrator"})]})]})})]})}e.s(["PROJECT_EXPLAINER",0,e_,"SHARED_PROJECT_EXPLAINER",0,eN,"default",0,function(){return(0,t.jsx)(s.AuthGate,{children:(0,t.jsx)(r.Suspense,{fallback:null,children:(0,t.jsx)(eT,{})})})}],850912)}]);
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.