@ai-sdet/test-manager 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/README.md +312 -0
  2. package/dist/cli.js +16455 -0
  3. package/dist/client/assets/AIView-BYoeRnLC.js +73 -0
  4. package/dist/client/assets/AdminSettingsView-JqCQI3K1.js +1 -0
  5. package/dist/client/assets/ChatSection-rpiFyFcg.js +8 -0
  6. package/dist/client/assets/MilestonesView-CTJ8r67W.js +1 -0
  7. package/dist/client/assets/ReportsView-DJ8KPr1J.js +1 -0
  8. package/dist/client/assets/RunExecution-BJnn0cq7.js +1 -0
  9. package/dist/client/assets/RunsView-oDa9JyRq.js +1 -0
  10. package/dist/client/assets/SettingsView-BVCLWqOk.js +1 -0
  11. package/dist/client/assets/SpaceView-BxtPCtW1.js +1 -0
  12. package/dist/client/assets/TestEditor-Dthst0HS.js +63 -0
  13. package/dist/client/assets/TestMuImportDialog-B2yx7BdF.js +5 -0
  14. package/dist/client/assets/TrashView-B5uFN2Ua.js +1 -0
  15. package/dist/client/assets/UserGroupsView-MGu6frpT.js +1 -0
  16. package/dist/client/assets/UsersView-DwWeOblN.js +1 -0
  17. package/dist/client/assets/comments-section-CHZSUoK5.js +53 -0
  18. package/dist/client/assets/hooks-BItXZ0yP.js +1 -0
  19. package/dist/client/assets/hooks-BM-wcPhm.js +4 -0
  20. package/dist/client/assets/icons-J9gKYxTz.js +41 -0
  21. package/dist/client/assets/index-CYPrMEmp.css +1 -0
  22. package/dist/client/assets/index-a9kCDHqT.js +7 -0
  23. package/dist/client/assets/markdown-YKl4gdXq.js +29 -0
  24. package/dist/client/assets/radix-ui-Cxk3sw_C.js +41 -0
  25. package/dist/client/assets/react-D-pHAthU.js +40 -0
  26. package/dist/client/assets/tiptap-Ch64zYGz.js +167 -0
  27. package/dist/client/index.html +62 -0
  28. package/dist/index.js +12990 -0
  29. package/dist/server/index.js +16195 -0
  30. package/package.json +124 -0
@@ -0,0 +1 @@
1
+ import{r as s,j as e}from"./react-D-pHAthU.js";import{a8 as gt,b as $,U as ie,O as ue,a9 as es,aa as er,a1 as te,c as ee,a5 as ts,B as xt,R as He,s as rs,W as Bt,q as ze,ab as at,ac as nt,t as ss,ad as Et,ae as Ft,g as Kt,af as Mt,v as lt,ag as Ht,E as as}from"./icons-J9gKYxTz.js";import{b as v,I as S,B as j,L as A,S as ns,u as ls,c as is,d as os,e as it,T as ds,f as cs,g as $t,h as Nt,i as Ut,j as qt,k as Gt,l as Yt,m as xs,n as ps,o as gs,p as us,q as fs,r as hs}from"./index-a9kCDHqT.js";import{D as tr,a as rr,f as sr,b as ar,c as nr}from"./radix-ui-Cxk3sw_C.js";import{c as _t,a as Qt,g as ys,b as vs}from"./hooks-BItXZ0yP.js";import{c as Vt,g as ms,a as bs}from"./comments-section-CHZSUoK5.js";import{f as Xt,g as js,h as Jt,j as Ss,k as ks,l as Cs}from"./hooks-BM-wcPhm.js";import{c as Zt,g as zs}from"./ChatSection-rpiFyFcg.js";import"./tiptap-Ch64zYGz.js";import"./markdown-YKl4gdXq.js";const ws={host:"",port:"587",secure:!1,user:"",pass:"",from:""},Ds={apiKey:"",from:""};function ot({label:i}){return e.jsx("div",{style:{fontSize:10,fontWeight:700,color:"var(--t-text-muted)",textTransform:"uppercase",letterSpacing:"0.08em",marginBottom:8},children:i})}function le({label:i,required:d,children:h}){return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:5},children:[e.jsxs(A,{style:{fontSize:"var(--t-text-sm)",color:"var(--t-text-secondary)"},children:[i,d&&e.jsx("span",{style:{color:"var(--t-accent-danger)",marginLeft:2},children:"*"})]}),h]})}function Ce({label:i,active:d,onClick:h}){return e.jsx("button",{type:"button",onClick:h,style:{flex:1,padding:"8px 0",borderRadius:8,border:`1px solid ${d?"var(--t-border-strong)":"var(--t-border-default)"}`,background:d?"var(--t-bg-hover)":"var(--t-bg-elevated)",color:d?"var(--t-text-primary)":"var(--t-text-secondary)",fontSize:"var(--t-text-sm)",fontWeight:d?600:400,cursor:"pointer",transition:"all 0.15s"},children:i})}function Ts({open:i,onClose:d}){const[h,k]=s.useState(!0),[p,H]=s.useState(!1),[T,r]=s.useState(!1),[m,W]=s.useState("admin"),[u,z]=s.useState("smtp"),[C,P]=s.useState(ws),[F,L]=s.useState(Ds),[b,O]=s.useState("7"),[w,B]=s.useState(null);s.useEffect(()=>{i&&(B(null),k(!0),v.authConfig.get().then(g=>{const y=g;O(String(y.sessionDays??7));const D=y.passwordReset;if(W(D.type==="email"?"email":"admin"),D.type==="email"&&D.emailProvider){const E=D.emailProvider;z(E.type??"smtp"),E.type==="smtp"?P({host:E.host??"",port:String(E.port??587),secure:E.secure??!1,user:E.user??"",pass:E.pass??"",from:E.from??""}):L({apiKey:E.apiKey??"",from:E.from??""})}}).catch(()=>{}).finally(()=>k(!1)))},[i]);function x(){const g={sessionDays:Number(b)};if(m==="admin")return{...g,passwordReset:{type:"admin"}};const y={type:u,from:u==="smtp"?C.from:F.from},D=u==="smtp"?{...y,host:C.host,port:Number(C.port),secure:C.secure,user:C.user,pass:C.pass}:{...y,apiKey:F.apiKey};return{...g,passwordReset:{type:"email",emailProvider:D}}}async function R(g){g.preventDefault(),H(!0),B(null);try{await v.authConfig.update(x()),B({ok:!0,message:"Configuration saved."})}catch(y){B({ok:!1,message:y instanceof Error?y.message:"Save failed"})}finally{H(!1)}}async function U(){r(!0),B(null);try{const g=await v.authConfig.testEmail(x());B({ok:g.ok,message:g.ok?`Test email sent to ${g.sentTo}`:g.error??"Test failed"})}catch(g){B({ok:!1,message:g instanceof Error?g.message:"Test failed"})}finally{r(!1)}}return e.jsx(tr,{open:i,onOpenChange:g=>{g||d()},children:e.jsxs(rr,{children:[e.jsx(sr,{style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.6)",backdropFilter:"blur(2px)",zIndex:50}}),e.jsxs(ar,{style:{position:"fixed",left:"50%",top:"50%",transform:"translate(-50%,-50%)",zIndex:51,width:500,maxHeight:"90vh",overflowY:"auto",background:"var(--t-bg-panel)",border:"1px solid var(--t-border-default)",borderRadius:12,padding:24,boxShadow:"0 24px 60px rgba(0,0,0,0.8)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:20},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[e.jsx("div",{style:{width:32,height:32,borderRadius:8,background:"var(--t-bg-elevated)",border:"1px solid var(--t-border-default)",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(gt,{size:16,weight:"fill",color:"var(--t-text-secondary)"})}),e.jsxs("div",{children:[e.jsx("p",{style:{margin:0,fontSize:"var(--t-text-lg)",fontWeight:600,color:"var(--t-text-primary)"},children:"Auth Configuration"}),e.jsx("p",{style:{margin:"1px 0 0",fontSize:"var(--t-text-xs)",color:"var(--t-text-muted)"},children:"Password reset & session duration"})]})]}),e.jsx(nr,{asChild:!0,children:e.jsx("button",{style:{background:"none",border:"none",cursor:"pointer",color:"var(--t-text-muted)",display:"flex"},children:e.jsx($,{size:16})})})]}),h?e.jsx("p",{style:{textAlign:"center",color:"var(--t-text-muted)",fontSize:"var(--t-text-base)",padding:"32px 0"},children:"Loading…"}):e.jsxs("form",{onSubmit:g=>void R(g),children:[e.jsxs("div",{style:{marginBottom:20},children:[e.jsx(ot,{label:"Session"}),e.jsx(le,{label:"Session length (days)",children:e.jsx(S,{type:"number",min:1,max:365,value:b,onChange:g=>O(g.target.value),style:{width:120}})})]}),e.jsxs("div",{style:{marginBottom:20},children:[e.jsx(ot,{label:"Password Reset Mode"}),e.jsxs("div",{style:{display:"flex",gap:8,marginBottom:12},children:[e.jsx(Ce,{label:"Admin only",active:m==="admin",onClick:()=>W("admin")}),e.jsx(Ce,{label:"Email link",active:m==="email",onClick:()=>W("email")})]}),m==="admin"&&e.jsx("p",{style:{fontSize:"var(--t-text-sm)",color:"var(--t-text-muted)",lineHeight:1.6},children:"Admins generate a one-time temporary password via the User Management panel. No email provider needed."})]}),m==="email"&&e.jsxs("div",{style:{marginBottom:20},children:[e.jsx(ot,{label:"Email Provider"}),e.jsxs("div",{style:{display:"flex",gap:8,marginBottom:16},children:[e.jsx(Ce,{label:"SMTP",active:u==="smtp",onClick:()=>z("smtp")}),e.jsx(Ce,{label:"Resend",active:u==="resend",onClick:()=>z("resend")}),e.jsx(Ce,{label:"SendGrid",active:u==="sendgrid",onClick:()=>z("sendgrid")})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[e.jsx(le,{label:"From address",required:!0,children:e.jsx(S,{type:"email",placeholder:"noreply@company.com",value:u==="smtp"?C.from:F.from,onChange:g=>u==="smtp"?P(y=>({...y,from:g.target.value})):L(y=>({...y,from:g.target.value})),required:!0})}),u==="smtp"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",gap:10},children:[e.jsx(le,{label:"SMTP host",required:!0,children:e.jsx(S,{placeholder:"smtp.gmail.com",value:C.host,onChange:g=>P(y=>({...y,host:g.target.value})),required:!0})}),e.jsx(le,{label:"Port",required:!0,children:e.jsx(S,{type:"number",placeholder:"587",style:{width:80},value:C.port,onChange:g=>P(y=>({...y,port:g.target.value})),required:!0})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("input",{type:"checkbox",id:"smtpSecure",checked:C.secure,onChange:g=>P(y=>({...y,secure:g.target.checked})),style:{accentColor:"var(--t-text-muted)",width:14,height:14}}),e.jsx("label",{htmlFor:"smtpSecure",style:{fontSize:"var(--t-text-sm)",color:"var(--t-text-secondary)",cursor:"pointer"},children:"Use TLS (port 465)"})]}),e.jsx(le,{label:"SMTP user",children:e.jsx(S,{placeholder:"user@company.com",value:C.user,onChange:g=>P(y=>({...y,user:g.target.value}))})}),e.jsx(le,{label:"SMTP password",children:e.jsx(S,{type:"password",placeholder:"••••••••",value:C.pass,onChange:g=>P(y=>({...y,pass:g.target.value}))})})]}),(u==="resend"||u==="sendgrid")&&e.jsx(le,{label:"API key",required:!0,children:e.jsx(S,{type:"password",placeholder:u==="resend"?"re_...":"SG....",value:F.apiKey,onChange:g=>L(y=>({...y,apiKey:g.target.value})),required:!0})})]})]}),w&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"10px 14px",borderRadius:8,background:w.ok?"rgba(34,197,94,0.08)":"rgba(229,72,77,0.08)",border:`1px solid ${w.ok?"rgba(34,197,94,0.2)":"rgba(229,72,77,0.2)"}`,marginBottom:16,fontSize:"var(--t-text-base)",color:w.ok?"var(--t-accent-success)":"var(--t-accent-danger)"},children:[w.ok?e.jsx(ie,{size:15,weight:"fill"}):e.jsx(ue,{size:15,weight:"fill"}),w.message]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(j,{type:"button",variant:"outline",size:"sm",onClick:d,children:"Cancel"}),m==="email"&&e.jsxs(j,{type:"button",variant:"outline",size:"sm",disabled:T,onClick:()=>void U(),style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(es,{size:13,weight:"fill"}),T?"Sending…":"Test email"]}),e.jsxs(j,{type:"submit",size:"sm",disabled:p,style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(er,{size:13,weight:"fill"}),p?"Saving…":"Save"]})]})]})]})]})})}function Is({label:i}){return e.jsx("div",{style:{fontSize:10,fontWeight:700,color:"var(--t-text-muted)",textTransform:"uppercase",letterSpacing:"0.08em",marginBottom:8},children:i})}function dt({label:i,required:d,children:h}){return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:5},children:[e.jsxs(A,{style:{fontSize:"var(--t-text-sm)",color:"var(--t-text-secondary)"},children:[i,d&&e.jsx("span",{style:{color:"var(--t-accent-danger)",marginLeft:2},children:"*"})]}),h]})}function ct({label:i,active:d,onClick:h}){return e.jsx("button",{type:"button",onClick:h,style:{flex:1,padding:"8px 0",borderRadius:8,border:`1px solid ${d?"var(--t-border-strong)":"var(--t-border-default)"}`,background:d?"var(--t-bg-surface)":"var(--t-bg-elevated)",color:d?"var(--t-text-primary)":"var(--t-text-secondary)",fontSize:"var(--t-text-sm)",fontWeight:d?600:400,cursor:"pointer",transition:"all 0.15s"},children:i})}function Rs({open:i,onClose:d,onSaved:h}){const[k,p]=s.useState(!0),[H,T]=s.useState(!1),[r,m]=s.useState("none"),[W,u]=s.useState(""),[z,C]=s.useState(""),[P,F]=s.useState(""),[L,b]=s.useState(!0),[O,w]=s.useState(null);s.useEffect(()=>{i&&(w(null),p(!0),v.authConfig.get().then(x=>{var U;const R=x;(U=R.sso)!=null&&U.type?(m(R.sso.type),u(R.sso.clientId??""),C(R.sso.clientSecret??""),F(R.sso.discoveryUrl??""),b(R.sso.autoProvision!==!1)):(m("none"),u(""),C(""),F(""),b(!0))}).catch(()=>{}).finally(()=>p(!1)))},[i]);async function B(x){x.preventDefault(),T(!0),w(null);try{const R=r==="none"?null:r==="oidc"?{type:r,clientId:W,clientSecret:z,discoveryUrl:P,autoProvision:L}:{type:r,clientId:W,clientSecret:z,autoProvision:L};await v.authConfig.update(R?{sso:R}:{sso:null}),w({ok:!0,message:"SSO configuration saved."}),h==null||h(r)}catch(R){w({ok:!1,message:R instanceof Error?R.message:"Save failed"})}finally{T(!1)}}return e.jsx(tr,{open:i,onOpenChange:x=>{x||d()},children:e.jsxs(rr,{children:[e.jsx(sr,{style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.6)",backdropFilter:"blur(2px)",zIndex:50}}),e.jsxs(ar,{style:{position:"fixed",left:"50%",top:"50%",transform:"translate(-50%,-50%)",zIndex:51,width:500,maxHeight:"90vh",overflowY:"auto",background:"var(--t-bg-panel)",border:"1px solid var(--t-border-default)",borderRadius:12,padding:24,boxShadow:"0 24px 60px rgba(0,0,0,0.8)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:20},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[e.jsx("div",{style:{width:32,height:32,borderRadius:8,background:"var(--t-bg-elevated)",border:"1px solid var(--t-border-default)",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(gt,{size:16,weight:"fill",color:"var(--t-text-secondary)"})}),e.jsxs("div",{children:[e.jsx("p",{style:{margin:0,fontSize:"var(--t-text-lg)",fontWeight:600,color:"var(--t-text-primary)"},children:"Single Sign-On (SSO)"}),e.jsx("p",{style:{margin:"1px 0 0",fontSize:"var(--t-text-xs)",color:"var(--t-text-muted)"},children:"OIDC & GitHub OAuth configuration"})]})]}),e.jsx(nr,{asChild:!0,children:e.jsx("button",{style:{background:"none",border:"none",cursor:"pointer",color:"var(--t-text-muted)",display:"flex",padding:4},children:e.jsx($,{size:16})})})]}),k?e.jsx("p",{style:{textAlign:"center",color:"var(--t-text-muted)",fontSize:"var(--t-text-base)",padding:"32px 0"},children:"Loading…"}):e.jsxs("form",{onSubmit:x=>void B(x),children:[e.jsxs("div",{style:{marginBottom:20},children:[e.jsx(Is,{label:"Provider"}),e.jsxs("div",{style:{display:"flex",gap:8,marginBottom:12},children:[e.jsx(ct,{label:"Disabled",active:r==="none",onClick:()=>m("none")}),e.jsx(ct,{label:"OIDC",active:r==="oidc",onClick:()=>m("oidc")}),e.jsx(ct,{label:"GitHub",active:r==="github",onClick:()=>m("github")})]}),r==="none"&&e.jsx("p",{style:{fontSize:"var(--t-text-sm)",color:"var(--t-text-muted)",lineHeight:1.6},children:"SSO is disabled. Users sign in with email and password. Enable OIDC for Google, Okta, Azure AD, Keycloak, etc., or GitHub for GitHub OAuth."}),r!=="none"&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[e.jsx(dt,{label:"Client ID",required:!0,children:e.jsx(S,{placeholder:"your-client-id",value:W,onChange:x=>u(x.target.value),required:!0})}),e.jsx(dt,{label:"Client Secret",required:!0,children:e.jsx(S,{type:"password",placeholder:"••••••••",value:z,onChange:x=>C(x.target.value),required:!0})}),r==="oidc"&&e.jsxs(dt,{label:"Discovery / Issuer URL",required:!0,children:[e.jsx(S,{placeholder:"https://accounts.google.com",value:P,onChange:x=>F(x.target.value),required:!0}),e.jsxs("p",{style:{fontSize:"var(--t-text-xs)",color:"var(--t-text-muted)",margin:"4px 0 0"},children:["The issuer URL — discovery doc is fetched from"," ",e.jsxs("code",{style:{color:"var(--t-text-secondary)"},children:["{issuer}","/.well-known/openid-configuration"]})]})]}),r==="github"&&e.jsxs("p",{style:{fontSize:"var(--t-text-sm)",color:"var(--t-text-muted)",lineHeight:1.6},children:["Create an OAuth App at"," ",e.jsx("strong",{style:{color:"var(--t-text-secondary)"},children:"github.com → Settings → Developer settings → OAuth Apps"}),". Set the callback URL to"," ",e.jsxs("code",{style:{color:"var(--t-text-secondary)",fontSize:"var(--t-text-xs)"},children:[window.location.origin,"/api/auth/sso/callback"]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("input",{type:"checkbox",id:"ssoAutoProvision",checked:L,onChange:x=>b(x.target.checked),style:{accentColor:"var(--t-text-secondary)",width:14,height:14}}),e.jsx("label",{htmlFor:"ssoAutoProvision",style:{fontSize:"var(--t-text-sm)",color:"var(--t-text-secondary)",cursor:"pointer"},children:"Auto-create user account on first SSO sign-in"})]})]})]}),O&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"10px 14px",borderRadius:8,background:O.ok?"rgba(34,197,94,0.08)":"rgba(229,72,77,0.08)",border:`1px solid ${O.ok?"rgba(34,197,94,0.2)":"rgba(229,72,77,0.2)"}`,marginBottom:16,fontSize:"var(--t-text-base)",color:O.ok?"var(--t-accent-success)":"var(--t-accent-danger)"},children:[O.ok?e.jsx(ie,{size:15,weight:"fill"}):e.jsx(ue,{size:15,weight:"fill"}),O.message]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(j,{type:"button",variant:"outline",size:"sm",onClick:d,children:"Cancel"}),e.jsxs(j,{type:"submit",size:"sm",disabled:H,style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(er,{size:13,weight:"fill"}),H?"Saving…":"Save"]})]})]})]})]})})}const lr=[{value:"orchestrator",label:"Orchestrator"},{value:"sub-orchestrator",label:"Sub-Orchestrator"},{value:"jira",label:"Jira"},{value:"confluence",label:"Confluence"},{value:"repo",label:"Repo"},{value:"mr_pr",label:"MR / PR"},{value:"test",label:"Test"},{value:"run",label:"Run"},{value:"e2e",label:"E2E"},{value:"report",label:"Report"},{value:"custom",label:"Custom"}],ir=[{value:"jira",label:"Jira"},{value:"confluence",label:"Confluence"},{value:"repo",label:"Repo"},{value:"mr_pr",label:"MR / PR"},{value:"test",label:"Test"},{value:"run",label:"Run"},{value:"e2e",label:"E2E"},{value:"report",label:"Report"},{value:"qa_task",label:"QA Task"},{value:"custom",label:"Custom"}],As={orchestrator:"#818cf8","sub-orchestrator":"#a78bfa",jira:"#60a5fa",confluence:"#34d399",repo:"#f59e0b",mr_pr:"#a78bfa",test:"#fb923c",run:"#4ade80",e2e:"#f472b6",report:"#94a3b8",qa_task:"#e879f9",custom:"var(--t-text-muted)"};function pt(i){var k;const d=((k=[...lr,...ir].find(p=>p.value===i))==null?void 0:k.label)??i,h=As[i]??"var(--t-text-muted)";return e.jsx("span",{style:{fontSize:10,fontWeight:700,padding:"1px 6px",borderRadius:4,border:`1px solid ${h}33`,color:h,background:`${h}11`,letterSpacing:"0.04em"},children:d})}function Ws({initial:i,allAgents:d,allTools:h,onSave:k,onDelete:p,onReset:H,saving:T}){const r=!!i.builtin,[m,W]=s.useState(i.name??""),[u,z]=s.useState(i.description??""),[C,P]=s.useState(i.type??"custom"),[F,L]=s.useState(i.model??""),[b,O]=s.useState(i.systemPrompt??""),[w,B]=s.useState(String(i.temperature??.7)),[x,R]=s.useState(String(i.maxTokens??4096)),[U,g]=s.useState(i.tools??[]),[y,D]=s.useState(i.subAgents??[]),[E,Q]=s.useState(i.isDefault??!1),[J,X]=s.useState(i.enabled??!0),[G,n]=s.useState(!1),[o,K]=s.useState(""),[q,oe]=s.useState(!1),re=C==="orchestrator",de=C==="sub-orchestrator";d.filter(l=>l.type==="orchestrator"&&l.id!==i.id);const se=l=>g(I=>I.includes(l)?I.filter(V=>V!==l):[...I,l]),fe=l=>D(I=>I.includes(l)?I.filter(V=>V!==l):[...I,l]),he=async()=>{if(u.trim()){n(!0),K("");try{const l=await v.agents.generatePrompt(C,u);O(l.systemPrompt)}catch(l){K(l.message)}finally{n(!1)}}},ce=()=>{const l=parseFloat(w),I=parseInt(x,10);k({name:m.trim(),description:u.trim(),type:C,model:F.trim(),systemPrompt:b,temperature:isNaN(l)?void 0:Math.min(1,Math.max(0,l)),maxTokens:isNaN(I)?void 0:I,tools:U,subAgents:re||de?y:[],isDefault:re?E:void 0,enabled:J})},Z=m.trim().length>0&&C;return e.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden"},children:[e.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"24px 28px",display:"flex",flexDirection:"column",gap:20},children:[r&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"10px 14px",borderRadius:8,background:"rgba(99,102,241,0.06)",border:"1px solid rgba(99,102,241,0.2)",fontSize:"var(--t-text-sm)",color:"var(--t-text-secondary)"},children:[e.jsx(te,{size:13,weight:"fill",style:{color:"var(--t-accent-primary)",flexShrink:0}}),e.jsxs("span",{style:{flex:1},children:[e.jsx("strong",{style:{color:"var(--t-text-primary)"},children:"Built-in agent"})," — your changes are preserved. Use Reset to restore defaults."]}),H&&e.jsxs("button",{onClick:H,style:{display:"flex",alignItems:"center",gap:4,padding:"3px 8px",borderRadius:5,fontSize:11,fontWeight:600,border:"1px solid rgba(99,102,241,0.3)",background:"transparent",color:"var(--t-accent-primary)",cursor:"pointer",flexShrink:0},children:[e.jsx(He,{size:11}),"Reset to defaults"]})]}),e.jsxs("div",{style:{display:"flex",gap:16},children:[e.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:6},children:[e.jsxs("label",{style:{fontSize:"var(--t-text-sm)",fontWeight:500,color:"var(--t-text-secondary)"},children:["Name ",e.jsx("span",{style:{color:"var(--t-accent-danger)"},children:"*"})]}),e.jsx(S,{value:m,onChange:l=>W(l.target.value),placeholder:"e.g. Main Orchestrator",autoFocus:!r})]}),e.jsxs("div",{style:{width:180,display:"flex",flexDirection:"column",gap:6},children:[e.jsxs("label",{style:{fontSize:"var(--t-text-sm)",fontWeight:500,color:"var(--t-text-secondary)"},children:["Type ",e.jsx("span",{style:{color:"var(--t-accent-danger)"},children:"*"})]}),e.jsx("select",{value:C,onChange:l=>P(l.target.value),style:{height:36,borderRadius:6,border:"1px solid var(--t-border-default)",background:"var(--t-bg-surface)",color:"var(--t-text-primary)",fontSize:"var(--t-text-sm)",padding:"0 10px"},children:lr.map(l=>e.jsx("option",{value:l.value,children:l.label},l.value))})]})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[e.jsx("label",{style:{fontSize:"var(--t-text-sm)",fontWeight:500,color:"var(--t-text-secondary)"},children:"Model"}),e.jsx(S,{value:F,onChange:l=>L(l.target.value),placeholder:"e.g. claude-3-5-sonnet-20241022 (inherits from AI Settings if blank)",style:{fontFamily:"monospace",fontSize:"var(--t-text-sm)"}}),e.jsx("p",{style:{margin:0,fontSize:"var(--t-text-xs)",color:"var(--t-text-muted)"},children:"Leave blank to use the model configured in AI Settings."})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("label",{style:{fontSize:"var(--t-text-sm)",fontWeight:500,color:"var(--t-text-secondary)"},children:"Description"}),e.jsxs("button",{onClick:he,disabled:!u.trim()||G,style:{display:"flex",alignItems:"center",gap:5,padding:"4px 10px",borderRadius:6,fontSize:11,fontWeight:600,border:"1px solid var(--t-border-default)",background:u.trim()&&!G?"var(--t-bg-elevated)":"transparent",color:u.trim()&&!G?"var(--t-accent-primary)":"var(--t-text-muted)",cursor:u.trim()&&!G?"pointer":"not-allowed",transition:"all 0.15s"},children:[G?e.jsx(He,{size:11,style:{animation:"ga-spin 1s linear infinite"}}):e.jsx(rs,{size:11,weight:"fill"}),G?"Generating…":"Generate System Prompt"]})]}),e.jsx("textarea",{value:u,onChange:l=>z(l.target.value),placeholder:"Describe what this agent does in plain English. Used to generate the system prompt.",rows:2,style:{resize:"vertical",borderRadius:6,border:"1px solid var(--t-border-default)",background:"var(--t-bg-surface)",color:"var(--t-text-primary)",fontSize:"var(--t-text-sm)",padding:"8px 10px",lineHeight:1.5,fontFamily:"inherit",outline:"none"}}),o&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,fontSize:"var(--t-text-xs)",color:"var(--t-accent-danger)"},children:[e.jsx(ue,{size:11,weight:"fill"}),o]})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[e.jsx("label",{style:{fontSize:"var(--t-text-sm)",fontWeight:500,color:"var(--t-text-secondary)"},children:"System Prompt"}),e.jsx("textarea",{value:b,onChange:l=>O(l.target.value),placeholder:"The full system prompt for this agent. Use Generate above to auto-draft it.",rows:8,style:{resize:"vertical",borderRadius:6,border:"1px solid var(--t-border-default)",background:"var(--t-bg-surface)",color:"var(--t-text-primary)",fontSize:"var(--t-text-sm)",padding:"10px 12px",lineHeight:1.6,fontFamily:"inherit",outline:"none"}})]}),e.jsxs("div",{style:{display:"flex",gap:16},children:[e.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:6},children:[e.jsx("label",{style:{fontSize:"var(--t-text-sm)",fontWeight:500,color:"var(--t-text-secondary)"},children:"Temperature"}),e.jsx(S,{value:w,onChange:l=>B(l.target.value),placeholder:"0.7",style:{fontFamily:"monospace",fontSize:"var(--t-text-sm)"}}),e.jsx("p",{style:{margin:0,fontSize:"var(--t-text-xs)",color:"var(--t-text-muted)"},children:"0.0 – 1.0"})]}),e.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:6},children:[e.jsx("label",{style:{fontSize:"var(--t-text-sm)",fontWeight:500,color:"var(--t-text-secondary)"},children:"Max Tokens"}),e.jsx(S,{value:x,onChange:l=>R(l.target.value),placeholder:"4096",style:{fontFamily:"monospace",fontSize:"var(--t-text-sm)"}})]})]}),h.length>0&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[e.jsx("label",{style:{fontSize:"var(--t-text-sm)",fontWeight:500,color:"var(--t-text-secondary)"},children:"Tools"}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:8},children:h.map(l=>{const I=U.includes(l.id);return e.jsxs("button",{onClick:()=>se(l.id),style:{display:"flex",alignItems:"center",gap:6,padding:"5px 10px",borderRadius:6,fontSize:"var(--t-text-sm)",border:`1px solid ${I?"var(--t-accent-primary)":"var(--t-border-default)"}`,background:I?"rgba(99,102,241,0.06)":"var(--t-bg-surface)",color:I?"var(--t-accent-primary)":"var(--t-text-secondary)",cursor:"pointer",transition:"all 0.15s"},children:[I?e.jsx(ie,{size:13,weight:"fill",style:{color:"var(--t-accent-primary)"}}):e.jsx(Bt,{size:13,style:{color:"var(--t-text-muted)"}}),l.name,pt(l.type)]},l.id)})})]}),(re||de)&&d.filter(l=>l.id!==i.id).length>0&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[e.jsx("label",{style:{fontSize:"var(--t-text-sm)",fontWeight:500,color:"var(--t-text-secondary)"},children:"Sub-agents"}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:8},children:d.filter(l=>l.id!==i.id).map(l=>{const I=y.includes(l.id);return e.jsxs("button",{onClick:()=>fe(l.id),style:{display:"flex",alignItems:"center",gap:6,padding:"5px 10px",borderRadius:6,fontSize:"var(--t-text-sm)",border:`1px solid ${I?"var(--t-accent-primary)":"var(--t-border-default)"}`,background:I?"rgba(99,102,241,0.06)":"var(--t-bg-surface)",color:I?"var(--t-accent-primary)":"var(--t-text-secondary)",cursor:"pointer",transition:"all 0.15s"},children:[I?e.jsx(ie,{size:13,weight:"fill"}):e.jsx(Bt,{size:13,style:{color:"var(--t-text-muted)"}}),l.name,pt(l.type)]},l.id)})})]}),re&&e.jsx("div",{style:{display:"flex",gap:24},children:e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:"var(--t-text-sm)",color:"var(--t-text-secondary)"},children:[e.jsx("input",{type:"checkbox",checked:E,onChange:l=>Q(l.target.checked),style:{accentColor:"var(--t-accent-primary)"}}),"Set as default orchestrator"]})}),!E&&e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:"var(--t-text-sm)",color:"var(--t-text-secondary)"},children:[e.jsx("input",{type:"checkbox",checked:J,onChange:l=>X(l.target.checked),style:{accentColor:"var(--t-accent-primary)"}}),"Enabled"]})]}),e.jsxs("div",{style:{padding:"14px 28px",borderTop:"1px solid var(--t-border-subtle)",display:"flex",justifyContent:"space-between",alignItems:"center",flexShrink:0},children:[e.jsxs("div",{children:[!r&&p&&!q&&e.jsxs("button",{onClick:()=>oe(!0),style:{background:"none",border:"none",cursor:"pointer",color:"var(--t-text-muted)",display:"flex",alignItems:"center",gap:5,fontSize:"var(--t-text-sm)",padding:"4px 8px",borderRadius:6},onMouseEnter:l=>{l.currentTarget.style.color="var(--t-accent-danger)"},onMouseLeave:l=>{l.currentTarget.style.color="var(--t-text-muted)"},children:[e.jsx(ze,{size:13})," Delete"]}),!r&&q&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{fontSize:"var(--t-text-sm)",color:"var(--t-accent-danger)"},children:"Delete this agent?"}),e.jsx(j,{variant:"outline",onClick:()=>oe(!1),children:"Cancel"}),e.jsx(j,{onClick:()=>p(),style:{background:"var(--t-accent-danger)",borderColor:"var(--t-accent-danger)"},children:"Delete"})]})]}),e.jsxs(j,{disabled:!Z||T,onClick:ce,style:{gap:6},children:[T?e.jsx(He,{size:14,style:{animation:"ga-spin 1s linear infinite"}}):e.jsx(te,{size:14}),T?"Saving…":r?"Save Changes":"Save Agent"]})]})]})}const Ps={GET:"#34d399",POST:"#60a5fa",PUT:"#f59e0b",PATCH:"#a78bfa",DELETE:"#f87171",UTIL:"#94a3b8"};function Ls({op:i}){const[d,h]=s.useState(!1),k=Ps[i.method]??"var(--t-text-muted)";return e.jsxs("div",{style:{borderRadius:8,border:"1px solid var(--t-border-subtle)",overflow:"hidden",background:"var(--t-bg-surface)"},children:[e.jsxs("button",{onClick:()=>h(p=>!p),style:{width:"100%",display:"flex",alignItems:"center",gap:10,padding:"10px 14px",background:"none",border:"none",cursor:"pointer",textAlign:"left"},children:[e.jsx("span",{style:{fontSize:10,fontWeight:700,padding:"2px 6px",borderRadius:4,background:`${k}22`,color:k,border:`1px solid ${k}44`,letterSpacing:"0.05em",flexShrink:0},children:i.method}),e.jsx("span",{style:{fontFamily:"monospace",fontSize:13,fontWeight:600,color:"var(--t-text-primary)",flex:1},children:i.name}),e.jsx("span",{style:{fontSize:"var(--t-text-xs)",color:"var(--t-text-muted)",marginRight:4},children:i.api}),e.jsx("span",{style:{color:"var(--t-text-muted)",fontSize:11,transform:d?"rotate(90deg)":"none",transition:"transform 0.15s"},children:"▶"})]}),d&&e.jsxs("div",{style:{padding:"0 14px 14px",display:"flex",flexDirection:"column",gap:10,borderTop:"1px solid var(--t-border-subtle)"},children:[e.jsx("p",{style:{margin:"10px 0 0",fontSize:"var(--t-text-sm)",color:"var(--t-text-secondary)",lineHeight:1.5},children:i.description}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:3},children:[e.jsx("p",{style:{margin:0,fontSize:10,fontWeight:600,color:"var(--t-text-muted)",textTransform:"uppercase",letterSpacing:"0.06em"},children:"Endpoint"}),e.jsx("p",{style:{margin:0,fontFamily:"monospace",fontSize:12,color:"var(--t-text-primary)",background:"var(--t-bg-elevated)",padding:"6px 10px",borderRadius:5,wordBreak:"break-all",lineHeight:1.6},children:i.endpoint})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:5},children:[e.jsx("p",{style:{margin:0,fontSize:10,fontWeight:600,color:"var(--t-text-muted)",textTransform:"uppercase",letterSpacing:"0.06em"},children:"Parameters"}),i.params.map((p,H)=>{const T=p.indexOf(":"),r=T>-1?p.slice(0,T):p,m=T>-1?p.slice(T+1).trim():"";return e.jsxs("div",{style:{display:"flex",gap:8,fontSize:"var(--t-text-xs)",lineHeight:1.5},children:[e.jsx("span",{style:{fontFamily:"monospace",color:"var(--t-accent-primary)",flexShrink:0,paddingTop:1},children:r}),e.jsx("span",{style:{color:"var(--t-text-muted)"},children:m})]},H)})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:3},children:[e.jsx("p",{style:{margin:0,fontSize:10,fontWeight:600,color:"var(--t-text-muted)",textTransform:"uppercase",letterSpacing:"0.06em"},children:"Auth"}),e.jsx("p",{style:{margin:0,fontSize:"var(--t-text-xs)",color:"var(--t-text-secondary)"},children:i.auth})]})]})]})}function Os({initial:i,onSave:d,onDelete:h,saving:k}){var w,B;const p=!!i.builtin,[H,T]=s.useState(i.name??""),[r,m]=s.useState(i.description??""),[W,u]=s.useState(i.type??"custom"),[z,C]=s.useState(i.enabled??!0),[P,F]=s.useState(!1),L=((w=i.config)==null?void 0:w.operations)??[],b=((B=i.config)==null?void 0:B.providerDetection)??null,O=H.trim().length>0&&W;return e.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden"},children:[e.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"24px 28px",display:"flex",flexDirection:"column",gap:20},children:[p&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"10px 14px",borderRadius:8,background:"rgba(99,102,241,0.06)",border:"1px solid rgba(99,102,241,0.2)",fontSize:"var(--t-text-sm)",color:"var(--t-text-secondary)"},children:[e.jsx(xt,{size:13,weight:"fill",style:{color:"var(--t-accent-primary)",flexShrink:0}}),e.jsxs("span",{children:[e.jsx("strong",{style:{color:"var(--t-text-primary)"},children:"Built-in tool"})," — name and type are fixed. You can toggle it enabled or disabled."]})]}),e.jsxs("div",{style:{display:"flex",gap:16},children:[e.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:6},children:[e.jsxs("label",{style:{fontSize:"var(--t-text-sm)",fontWeight:500,color:"var(--t-text-secondary)"},children:["Name ",!p&&e.jsx("span",{style:{color:"var(--t-accent-danger)"},children:"*"})]}),e.jsx(S,{value:H,onChange:x=>!p&&T(x.target.value),readOnly:p,placeholder:"e.g. Jira Ticket Search",autoFocus:!p,style:p?{opacity:.6,cursor:"default"}:void 0})]}),e.jsxs("div",{style:{width:180,display:"flex",flexDirection:"column",gap:6},children:[e.jsxs("label",{style:{fontSize:"var(--t-text-sm)",fontWeight:500,color:"var(--t-text-secondary)"},children:["Type ",!p&&e.jsx("span",{style:{color:"var(--t-accent-danger)"},children:"*"})]}),p?e.jsx("div",{style:{height:36,display:"flex",alignItems:"center"},children:pt(W)}):e.jsx("select",{value:W,onChange:x=>u(x.target.value),style:{height:36,borderRadius:6,border:"1px solid var(--t-border-default)",background:"var(--t-bg-surface)",color:"var(--t-text-primary)",fontSize:"var(--t-text-sm)",padding:"0 10px"},children:ir.map(x=>e.jsx("option",{value:x.value,children:x.label},x.value))})]})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[e.jsx("label",{style:{fontSize:"var(--t-text-sm)",fontWeight:500,color:"var(--t-text-secondary)"},children:"Description"}),e.jsx("textarea",{value:r,onChange:x=>!p&&m(x.target.value),readOnly:p,placeholder:"What this tool does and when the agent should use it.",rows:3,style:{resize:p?"none":"vertical",borderRadius:6,border:"1px solid var(--t-border-default)",background:"var(--t-bg-surface)",color:"var(--t-text-primary)",fontSize:"var(--t-text-sm)",padding:"8px 10px",lineHeight:1.5,fontFamily:"inherit",outline:"none",opacity:p?.7:1}})]}),p&&b&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8,padding:"12px 14px",borderRadius:8,background:"rgba(245,158,11,0.06)",border:"1px solid rgba(245,158,11,0.2)"},children:[e.jsx("p",{style:{margin:0,fontSize:"var(--t-text-sm)",fontWeight:600,color:"var(--t-text-primary)"},children:"Provider Auto-Detection"}),e.jsx("p",{style:{margin:0,fontSize:"var(--t-text-xs)",color:"var(--t-text-secondary)",lineHeight:1.5},children:b.description}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:3},children:b.patterns.map((x,R)=>e.jsx("p",{style:{margin:0,fontFamily:"monospace",fontSize:11,color:"var(--t-text-secondary)",background:"var(--t-bg-elevated)",padding:"3px 8px",borderRadius:4},children:x},R))}),e.jsxs("p",{style:{margin:0,fontSize:"var(--t-text-xs)",color:"var(--t-text-muted)",lineHeight:1.5},children:[e.jsx("strong",{children:"Fallback:"})," ",b.fallback]})]}),p&&L.length>0&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[e.jsxs("label",{style:{fontSize:"var(--t-text-sm)",fontWeight:500,color:"var(--t-text-secondary)"},children:["Available Operations (",L.length,")"]}),L.map(x=>e.jsx(Ls,{op:x},x.name))]}),W==="qa_task"&&e.jsxs("div",{style:{padding:"12px 14px",borderRadius:8,background:"rgba(232,121,249,0.06)",border:"1px solid rgba(232,121,249,0.2)",fontSize:"var(--t-text-sm)",color:"var(--t-text-secondary)",lineHeight:1.5},children:[e.jsx("strong",{style:{color:"var(--t-text-primary)"},children:"QA Task"})," — implementation coming soon. You can configure this tool now and it will be activated once the QA Task runner is ready."]}),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:"var(--t-text-sm)",color:"var(--t-text-secondary)"},children:[e.jsx("input",{type:"checkbox",checked:z,onChange:x=>C(x.target.checked),style:{accentColor:"var(--t-accent-primary)"}}),"Enabled"]})]}),e.jsxs("div",{style:{padding:"14px 28px",borderTop:"1px solid var(--t-border-subtle)",display:"flex",justifyContent:"space-between",alignItems:"center",flexShrink:0},children:[e.jsxs("div",{children:[!p&&h&&!P&&e.jsxs("button",{onClick:()=>F(!0),style:{background:"none",border:"none",cursor:"pointer",color:"var(--t-text-muted)",display:"flex",alignItems:"center",gap:5,fontSize:"var(--t-text-sm)",padding:"4px 8px",borderRadius:6},onMouseEnter:x=>{x.currentTarget.style.color="var(--t-accent-danger)"},onMouseLeave:x=>{x.currentTarget.style.color="var(--t-text-muted)"},children:[e.jsx(ze,{size:13})," Delete"]}),!p&&P&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{fontSize:"var(--t-text-sm)",color:"var(--t-accent-danger)"},children:"Delete this tool?"}),e.jsx(j,{variant:"outline",onClick:()=>F(!1),children:"Cancel"}),e.jsx(j,{onClick:()=>h(),style:{background:"var(--t-accent-danger)",borderColor:"var(--t-accent-danger)"},children:"Delete"})]})]}),e.jsxs(j,{disabled:!O||k,onClick:()=>d({name:H.trim(),description:r.trim(),type:W,enabled:z}),style:{gap:6},children:[k?e.jsx(He,{size:14,style:{animation:"ga-spin 1s linear infinite"}}):e.jsx(xt,{size:14}),k?"Saving…":p?"Save Changes":"Save Tool"]})]})]})}function Bs({onClose:i}){var G;const[d,h]=s.useState([]),[k,p]=s.useState([]),[H,T]=s.useState(!0),[r,m]=s.useState(null),[W,u]=s.useState(!1),[z,C]=s.useState("orchestrators"),P=s.useCallback(async()=>{try{const[n,o]=await Promise.all([v.agents.list(),v.tools.list()]);h(n),p(o)}catch{}finally{T(!1)}},[]);s.useEffect(()=>{P()},[P]);const F=d.filter(n=>n.type==="orchestrator"),L=d.filter(n=>n.type==="sub-orchestrator"),b=d.filter(n=>n.type!=="orchestrator"&&n.type!=="sub-orchestrator"),O=[{key:"orchestrators",label:"Orchestrators",count:F.length},{key:"sub-orchestrators",label:"Sub-Orchestrators",count:L.length},{key:"task-agents",label:"Task Agents",count:b.length},{key:"tools",label:"Tools",count:k.length}],w=z==="orchestrators"?F.map(n=>({kind:"agent",agent:n})):z==="sub-orchestrators"?L.map(n=>({kind:"agent",agent:n})):z==="task-agents"?b.map(n=>({kind:"agent",agent:n})):k.map(n=>({kind:"tool",tool:n})),B=async n=>{if((r==null?void 0:r.kind)==="agent"){u(!0);try{if(r.id==="new"){const o=await v.agents.create(n);h(K=>[...K,o]),m({kind:"agent",id:o.id})}else{const o=await v.agents.update(r.id,n);h(K=>K.map(q=>q.id===r.id?o:q))}await P()}catch{}finally{u(!1)}}},x=async()=>{if(!((r==null?void 0:r.kind)!=="agent"||r.id==="new")){u(!0);try{await v.agents.delete(r.id),h(n=>n.filter(o=>o.id!==r.id)),m(null)}catch{}finally{u(!1)}}},R=async()=>{if(!((r==null?void 0:r.kind)!=="agent"||r.id==="new")){u(!0);try{const n=await v.agents.reset(r.id);h(o=>o.map(K=>K.id===r.id?n:K))}catch{}finally{u(!1)}}},U=async n=>{if((r==null?void 0:r.kind)==="tool"){u(!0);try{if(r.id==="new"){const o=await v.tools.create(n);p(K=>[...K,o]),m({kind:"tool",id:o.id})}else{const o=await v.tools.update(r.id,n);p(K=>K.map(q=>q.id===r.id?o:q))}}catch{}finally{u(!1)}}},g=async()=>{if(!((r==null?void 0:r.kind)!=="tool"||r.id==="new")){u(!0);try{await v.tools.delete(r.id),p(n=>n.filter(o=>o.id!==r.id)),m(null)}catch{}finally{u(!1)}}},y=(r==null?void 0:r.kind)==="agent"&&r.id!=="new"?d.find(n=>n.id===r.id)??null:null,D=(r==null?void 0:r.kind)==="tool"&&r.id!=="new"?k.find(n=>n.id===r.id)??null:null;function E({agent:n}){const o=(r==null?void 0:r.kind)==="agent"&&r.id===n.id,K=!n.enabled&&!n.isDefault;return e.jsxs("button",{onClick:()=>m({kind:"agent",id:n.id}),style:{display:"flex",alignItems:"center",gap:10,padding:"9px 10px",borderRadius:7,width:"100%",border:o?"1px solid var(--t-border-strong)":"1px solid transparent",background:o?"var(--t-bg-elevated)":"transparent",cursor:"pointer",textAlign:"left",transition:"all 0.12s",opacity:K?.45:1},children:[e.jsx("div",{style:{width:28,height:28,borderRadius:6,flexShrink:0,background:o?"rgba(255,255,255,0.06)":"var(--t-bg-surface)",border:"1px solid var(--t-border-default)",display:"flex",alignItems:"center",justifyContent:"center",color:o?"var(--t-text-primary)":"var(--t-text-muted)"},children:e.jsx(te,{size:13,weight:o?"fill":"regular"})}),e.jsx("div",{style:{flex:1,minWidth:0},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4,minWidth:0},children:[e.jsx("p",{style:{margin:0,fontSize:"var(--t-text-sm)",fontWeight:600,color:o?"var(--t-text-primary)":"var(--t-text-secondary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",lineHeight:1.3,minWidth:0},children:n.name}),n.builtin&&e.jsx("span",{style:{fontSize:9,fontWeight:700,padding:"1px 4px",borderRadius:3,background:"rgba(99,102,241,0.12)",color:"var(--t-accent-primary)",border:"1px solid rgba(99,102,241,0.2)",letterSpacing:"0.05em",flexShrink:0},children:"BUILT-IN"})]})}),n.isDefault&&e.jsx(ts,{size:11,weight:"fill",style:{color:"#f59e0b",flexShrink:0},title:"Default orchestrator"}),!n.isDefault&&n.enabled&&e.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:"var(--t-accent-success)",flexShrink:0}})]})}function Q({tool:n}){const o=(r==null?void 0:r.kind)==="tool"&&r.id===n.id;return e.jsxs("button",{onClick:()=>m({kind:"tool",id:n.id}),style:{display:"flex",alignItems:"center",gap:10,padding:"9px 10px",borderRadius:7,width:"100%",border:o?"1px solid var(--t-border-strong)":"1px solid transparent",background:o?"var(--t-bg-elevated)":"transparent",cursor:"pointer",textAlign:"left",transition:"all 0.12s",opacity:n.enabled?1:.45},children:[e.jsx("div",{style:{width:28,height:28,borderRadius:6,flexShrink:0,background:o?"rgba(255,255,255,0.06)":"var(--t-bg-surface)",border:"1px solid var(--t-border-default)",display:"flex",alignItems:"center",justifyContent:"center",color:o?"var(--t-text-primary)":"var(--t-text-muted)"},children:e.jsx(xt,{size:13,weight:o?"fill":"regular"})}),e.jsx("div",{style:{flex:1,minWidth:0},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4,minWidth:0},children:[e.jsx("p",{style:{margin:0,fontSize:"var(--t-text-sm)",fontWeight:600,color:o?"var(--t-text-primary)":"var(--t-text-secondary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",lineHeight:1.3,minWidth:0},children:n.name}),n.builtin&&e.jsx("span",{style:{fontSize:9,fontWeight:700,padding:"1px 4px",borderRadius:3,background:"rgba(99,102,241,0.12)",color:"var(--t-accent-primary)",border:"1px solid rgba(99,102,241,0.2)",letterSpacing:"0.05em",flexShrink:0},children:"BUILT-IN"})]})}),n.enabled&&e.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:"var(--t-accent-success)",flexShrink:0}})]})}const J=()=>r?r.kind==="agent"?e.jsx(Ws,{initial:r.id==="new"?{}:y??{},allAgents:d,allTools:k,onSave:B,onDelete:r.id!=="new"?x:void 0,onReset:y!=null&&y.builtin?R:void 0,saving:W},r.id):e.jsx(Os,{initial:r.id==="new"?{}:D??{},onSave:U,onDelete:r.id!=="new"&&!(D!=null&&D.builtin)?g:void 0,saving:W},r.id):e.jsx(Es,{label:"Select an agent or tool from the left panel"}),X=z==="tools";return e.jsxs("div",{style:{position:"fixed",inset:0,zIndex:200,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.6)",backdropFilter:"blur(2px)"},onClick:n=>{n.target===n.currentTarget&&i()},children:[e.jsx("style",{children:"@keyframes ga-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }"}),e.jsxs("div",{style:{width:"100vw",height:"100vh",background:"var(--t-bg-panel)",display:"flex",flexDirection:"column",overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"20px 24px 16px",borderBottom:"1px solid var(--t-border-subtle)",flexShrink:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[e.jsx("div",{style:{width:32,height:32,borderRadius:8,background:"var(--t-bg-elevated)",border:"1px solid var(--t-border-default)",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(te,{size:16,color:"var(--t-text-secondary)"})}),e.jsxs("div",{children:[e.jsx("p",{style:{margin:0,fontSize:"var(--t-text-lg)",fontWeight:600,color:"var(--t-text-primary)"},children:"Global Agents"}),e.jsx("p",{style:{margin:"1px 0 0",fontSize:"var(--t-text-xs)",color:"var(--t-text-muted)"},children:"Org-wide — applies to all spaces. Super admins only."})]})]}),e.jsx("button",{onClick:i,style:{background:"none",border:"none",cursor:"pointer",color:"var(--t-text-muted)",display:"flex",padding:4},children:e.jsx($,{size:16})})]}),e.jsxs("div",{style:{display:"flex",flex:1,minHeight:0,overflow:"hidden"},children:[e.jsxs("div",{style:{width:220,borderRight:"1px solid var(--t-border-subtle)",padding:"12px 8px",display:"flex",flexDirection:"column",gap:2,flexShrink:0,overflowY:"auto"},children:[e.jsx("p",{style:{margin:"0 0 8px 6px",fontSize:10,fontWeight:600,color:"var(--t-text-muted)",textTransform:"uppercase",letterSpacing:"0.06em"},children:"Category"}),O.map(n=>{const o=z===n.key;return e.jsxs("button",{onClick:()=>{C(n.key),m(null)},style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 10px",borderRadius:6,width:"100%",border:o?"1px solid var(--t-border-strong)":"1px solid transparent",background:o?"var(--t-bg-elevated)":"transparent",cursor:"pointer",textAlign:"left",transition:"all 0.12s"},children:[e.jsx("span",{style:{fontSize:"var(--t-text-sm)",fontWeight:o?600:400,color:o?"var(--t-text-primary)":"var(--t-text-secondary)"},children:n.label}),e.jsx("span",{style:{fontSize:10,fontWeight:600,padding:"1px 5px",borderRadius:10,background:o?"rgba(99,102,241,0.15)":"var(--t-bg-surface)",color:o?"var(--t-accent-primary)":"var(--t-text-muted)",border:`1px solid ${o?"rgba(99,102,241,0.25)":"var(--t-border-default)"}`},children:n.count})]},n.key)})]}),e.jsxs("div",{style:{width:240,borderRight:"1px solid var(--t-border-subtle)",padding:"12px 10px",display:"flex",flexDirection:"column",gap:2,flexShrink:0,overflowY:"auto"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",margin:"0 0 6px 4px"},children:[e.jsx("p",{style:{margin:0,fontSize:11,fontWeight:600,color:"var(--t-text-muted)",textTransform:"uppercase",letterSpacing:"0.06em"},children:(G=O.find(n=>n.key===z))==null?void 0:G.label}),e.jsx("button",{onClick:()=>m({kind:X?"tool":"agent",id:"new"}),title:`Add ${X?"tool":"agent"}`,style:{background:"none",border:"none",cursor:"pointer",color:"var(--t-text-muted)",display:"flex",padding:2,borderRadius:4,lineHeight:1},onMouseEnter:n=>{n.currentTarget.style.color="var(--t-text-primary)"},onMouseLeave:n=>{n.currentTarget.style.color="var(--t-text-muted)"},children:e.jsx(ee,{size:13})})]}),H?e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[0,1,2].map(n=>e.jsx(ns,{height:44,borderRadius:7},n))}):e.jsxs(e.Fragment,{children:[(r==null?void 0:r.id)==="new"&&e.jsxs("button",{style:{display:"flex",alignItems:"center",gap:10,padding:"9px 10px",borderRadius:7,width:"100%",border:"1px solid var(--t-border-strong)",background:"var(--t-bg-elevated)",cursor:"default",textAlign:"left"},children:[e.jsx("div",{style:{width:28,height:28,borderRadius:6,flexShrink:0,background:"rgba(255,255,255,0.06)",border:"1px solid var(--t-border-default)",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--t-text-muted)"},children:e.jsx(ee,{size:13})}),e.jsxs("div",{children:[e.jsx("p",{style:{margin:0,fontSize:"var(--t-text-sm)",fontWeight:600,color:"var(--t-text-primary)",lineHeight:1.3},children:X?"New tool":"New agent"}),e.jsx("p",{style:{margin:"2px 0 0",fontSize:"var(--t-text-xs)",color:"var(--t-text-muted)",lineHeight:1.3},children:"Unsaved"})]})]}),w.length===0&&(r==null?void 0:r.id)!=="new"&&e.jsx("p",{style:{margin:"0 0 0 4px",fontSize:"var(--t-text-xs)",color:"var(--t-text-muted)"},children:"None yet."}),w.map(n=>n.kind==="agent"?e.jsx(E,{agent:n.agent},n.agent.id):e.jsx(Q,{tool:n.tool},n.tool.id))]})]}),e.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden"},children:J()})]})]})]})}function Es({label:i}){return e.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx("p",{style:{fontSize:"var(--t-text-sm)",color:"var(--t-text-muted)"},children:i})})}function _({icon:i,title:d,description:h,badge:k,onConfigure:p}){return e.jsxs("div",{style:{background:"var(--t-bg-surface)",border:"1px solid var(--t-border-subtle)",borderRadius:12,padding:24,display:"flex",flexDirection:"column",gap:16,minWidth:280,maxWidth:340},children:[e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:14},children:[e.jsx("div",{style:{width:40,height:40,borderRadius:10,background:"rgba(255,255,255,0.05)",border:"1px solid var(--t-border-default)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,color:"var(--t-text-secondary)"},children:i}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontSize:"var(--t-text-xl)",fontWeight:600,color:"var(--t-text-primary)",lineHeight:1.3},children:d}),e.jsx("div",{style:{fontSize:"var(--t-text-sm)",color:"var(--t-text-muted)",marginTop:3,lineHeight:1.4},children:h})]})]}),k&&e.jsx("div",{style:{display:"inline-flex",alignSelf:"flex-start",padding:"3px 10px",borderRadius:20,background:"rgba(255,255,255,0.04)",border:"1px solid var(--t-border-default)",fontSize:"var(--t-text-xs)",color:"var(--t-text-muted)",fontFamily:"monospace"},children:k}),e.jsx(j,{variant:"outline",style:{alignSelf:"flex-start"},onClick:p,children:"Configure"})]})}function _s(){const{user:i}=ls(),d=(i==null?void 0:i.globalRole)==="super_admin",{theme:h,setTheme:k,resetTheme:p}=is(),[H,T]=s.useState(!1),[r,m]=s.useState({...h}),[W,u]=s.useState(!1);s.useEffect(()=>{m({...h})},[h]);const z=s.useCallback(t=>{const a={...r,...t};m(a),k(a,!1)},[r,k]),C=async()=>{u(!0);try{await k(r,!0),T(!1)}finally{u(!1)}},P=async()=>{await p(),T(!1)},[F,L]=s.useState(!1),[b,O]=s.useState("sqlite"),[w,B]=s.useState(""),[x,R]=s.useState(""),[U,g]=s.useState("10"),[y,D]=s.useState(null),[E,Q]=s.useState(!1),[J,X]=s.useState("sqlite"),[G,n]=s.useState(!1),[o,K]=s.useState("none"),[q,oe]=s.useState("none"),[re,de]=s.useState("500"),[se,fe]=s.useState(""),[he,ce]=s.useState("30"),[Z,l]=s.useState(null),[I,V]=s.useState(!1),[or,ut]=s.useState(!1),[dr,cr]=s.useState("admin"),[xr,ft]=s.useState(!1),[ht,yt]=s.useState("none"),[pr,we]=s.useState(!1),[$e,Ne]=s.useState([]),De=()=>[{label:"Apps",description:"List of all applications",size:xs(),clear:$t},{label:"Spaces",description:"Spaces per application",size:ps(),clear:Nt},{label:"Folders",description:"Folders per space",size:gs(),clear:Ut},{label:"Tests",description:"Test lists per folder",size:ys(),clear:_t},{label:"Test Details",description:"Full test detail with steps",size:vs(),clear:Qt},{label:"Runs",description:"Test runs per application",size:us(),clear:qt},{label:"Run Results",description:"Test results and report per run",size:fs(),clear:Gt},{label:"Milestones",description:"Milestones per application",size:hs(),clear:Yt},{label:"Comments",description:"Comments and replies per run result",size:ms(),clear:Vt},{label:"AI Repos & Tickets",description:"AI repos and Jira filter tickets per app",size:Ss(),clear:Xt},{label:"Analyses",description:"Saved analysis list, detail, and comments per app",size:ks(),clear:js},{label:"Test Plans",description:"Saved test plan and test notes list and detail per app",size:Cs(),clear:Jt},{label:"Chat Conversations",description:"In-memory cache of loaded conversation message lists",size:zs(),clear:Zt}],gr=()=>{Ne(De()),we(!0)},ur=t=>{$e[t].clear(),Ne(De())},fr=()=>{$t(),Nt(),Ut(),_t(),Qt(),qt(),Gt(),Yt(),Vt(),Xt(),bs(),Jt(),Zt(),Ne(De())},Ue=$e.reduce((t,a)=>t+a.size,0),{branding:Y,setBranding:hr,resetBranding:yr}=os(),[vr,xe]=s.useState(!1),[pe,vt]=s.useState(""),[ye,qe]=s.useState(null),[ve,Ge]=s.useState(null),[me,Ye]=s.useState(null),[be,_e]=s.useState(null),[mt,bt]=s.useState(!1),mr=()=>{vt(Y.appTitle),qe(Y.iconDataDark),Ge(Y.iconDataLight),Ye(Y.logoData),_e(Y.logoDataDark),xe(!0)},Te=t=>a=>{var ne;const c=(ne=a.target.files)==null?void 0:ne[0];if(!c||!["image/svg+xml","image/png"].includes(c.type))return;const M=new FileReader;M.onload=()=>{typeof M.result=="string"&&t(M.result)},M.readAsDataURL(c),a.target.value=""},br=async()=>{if(pe.trim()){bt(!0);try{await hr({appTitle:pe.trim(),iconDataDark:ye,iconDataLight:ve,logoData:me,logoDataDark:be}),xe(!1)}finally{bt(!1)}}},jr=async()=>{await yr(),xe(!1)},[Sr,Ie]=s.useState(!1),[je,Qe]=s.useState([]),[kr,jt]=s.useState(!1),[Re,Ve]=s.useState(""),[St,Cr]=s.useState("#6366f1"),[kt,Se]=s.useState(""),[Xe,Ct]=s.useState(!1),[zr,Ae]=s.useState(!1),[We,Pe]=s.useState([]),[wr,zt]=s.useState(!1),[Le,Je]=s.useState(""),[wt,Ze]=s.useState(""),[et,Dt]=s.useState(!1),[Tt,Oe]=s.useState(""),[ge,Be]=s.useState(null),[It,Ee]=s.useState(!1),[Dr,Rt]=s.useState(!1),[Tr,Ir]=s.useState("");s.useEffect(()=>{d&&Promise.all([v.agents.list(),v.tools.list()]).then(([t,a])=>Ir(`${t.length} agent${t.length!==1?"s":""} · ${a.length} tool${a.length!==1?"s":""}`)).catch(()=>{})},[d]);const[Rr,Fe]=s.useState(!1),[N,At]=s.useState("llm"),[Ar,Wt]=s.useState(!1),[Wr,ke]=s.useState("Not configured"),Pt=()=>({provider:"",model:"",apiKey:"",region:"",hasKey:!1,status:null,saving:!1,testing:!1}),[tt,Ke]=s.useState(Pt()),[rt,Me]=s.useState(Pt()),f=N==="llm"?tt:rt,ae=N==="llm"?Ke:Me,st=t=>t.hasKey||!!t.apiKey.trim();s.useEffect(()=>{v.dbConfig.get().then(t=>{X(t.type),O(t.type),B(t.type==="sqlite"?"":t.url),g(String(t.poolMax??10))}).catch(()=>{}),v.cacheConfig.get().then(t=>{oe(t.active),K(t.type),de(String(t.lruMax??500)),fe(t.redisUrl??""),ce(String(t.ttl??30))}).catch(()=>{}),d&&v.authConfig.get().then(t=>{var c;cr(((c=t.passwordReset)==null?void 0:c.type)??"admin");const a=t.sso;yt((a==null?void 0:a.type)??"none")}).catch(()=>{}),v.tokens.list().then(Pe).catch(()=>{}),v.aiConfig.get().then(t=>{t.llm.hasApiKey&&t.vector.hasApiKey?ke("Set"):(t.llm.hasApiKey||t.vector.hasApiKey)&&ke("Partially set"),Ke(a=>({...a,provider:t.llm.provider,model:t.llm.model,region:t.llm.region,hasKey:t.llm.hasApiKey})),Me(a=>({...a,provider:t.vector.provider,model:t.vector.model,region:t.vector.region,hasKey:t.vector.hasApiKey}))}).catch(()=>{})},[d]);const Pr=async()=>{D(null),Q(!0);try{const t=await v.dbConfig.get();X(t.type),O(t.type),B(t.type==="sqlite"?"":t.url),R(""),g(String(t.poolMax??10))}catch{}finally{Q(!1)}L(!0)},Lr=async()=>{Q(!0),D(null);try{const t=b==="sqlite"?"file:noob-sdet.db":w.trim(),a=await v.dbConfig.test({type:b,url:t,token:x.trim()||void 0});D({ok:a.ok,message:a.error??a.message??(a.ok?"Connection successful!":"Failed")})}catch(t){D({ok:!1,message:t.message})}finally{Q(!1)}},Or=async()=>{Q(!0),D(null);try{const t=b==="sqlite"?"file:noob-sdet.db":w.trim(),a=await v.dbConfig.update({type:b,url:t,token:x.trim()||void 0,...b==="postgres"?{poolMax:parseInt(U,10)||10}:{}});a.ok||a.type?(X(b),D({ok:!0,message:a.message??"Configuration saved."})):D({ok:!1,message:a.error??"Failed to save."})}catch(t){D({ok:!1,message:t.message})}finally{Q(!1)}},Br=async()=>{l(null),V(!0);try{const t=await v.cacheConfig.get();oe(t.active),K(t.type),de(String(t.lruMax??500)),fe(t.redisUrl??""),ce(String(t.ttl??30))}catch{}finally{V(!1)}n(!0)},Er=async()=>{V(!0),l(null);try{const t=await v.cacheConfig.test({type:o,redisUrl:o==="redis"?se.trim():void 0});l({ok:t.ok,message:t.error??t.message??(t.ok?"OK":"Failed")})}catch(t){l({ok:!1,message:t.message})}finally{V(!1)}},Fr=async()=>{V(!0),l(null);try{const t=await v.cacheConfig.update({type:o,lruMax:parseInt(re,10)||500,redisUrl:o==="redis"?se.trim():void 0,ttl:parseInt(he,10)||30});t.ok?(oe(o),l({ok:!0,message:t.message??"Cache configuration saved."})):l({ok:!1,message:t.error??"Failed to save."})}catch(t){l({ok:!1,message:t.message})}finally{V(!1)}},Kr=async()=>{Ie(!0),Se(""),Ve(""),jt(!0);try{const t=await v.globalTags.list();Qe(t)}catch{}finally{jt(!1)}},Lt=async()=>{if(!Re.trim()||Xe)return;const t=Re.trim();if(je.some(a=>a.name.toLowerCase()===t.toLowerCase())){Se("A global tag with this name already exists");return}Ct(!0),Se("");try{const a=await v.globalTags.create({name:t,color:St});Qe(c=>[...c,a].sort((M,ne)=>M.name.localeCompare(ne.name))),Ve("")}catch(a){Se(a.message)}finally{Ct(!1)}},Mr=async t=>{try{await v.globalTags.delete(t),Qe(a=>a.filter(c=>c.id!==t))}catch{}},Hr=async()=>{Ae(!0),Oe(""),Je(""),Ze(""),Be(null),Ee(!1),zt(!0);try{const t=await v.tokens.list();Pe(t)}catch{}finally{zt(!1)}},Ot=async()=>{if(!(!Le.trim()||et)){Dt(!0),Oe(""),Be(null),Ee(!1);try{const t=await v.tokens.create(Le.trim(),wt||void 0);Pe(a=>[t,...a]),Be({id:t.id,token:t.token}),Je(""),Ze("")}catch(t){Oe(t.message)}finally{Dt(!1)}}},$r=async t=>{try{await v.tokens.delete(t),Pe(a=>a.filter(c=>c.id!==t)),(ge==null?void 0:ge.id)===t&&Be(null)}catch{}},Nr=t=>{navigator.clipboard.writeText(t).then(()=>{Ee(!0),setTimeout(()=>Ee(!1),2e3)})},Ur=["Anthropic","OpenAI","Google","Mistral","Cohere","Amazon Bedrock","Amazon Bedrock (API Key)","Ollama Cloud"],qr=["OpenAI","Amazon Bedrock"],Gr=async()=>{At("llm"),Ke(t=>({...t,apiKey:"",status:null})),Me(t=>({...t,apiKey:"",status:null})),Fe(!0),Wt(!0);try{const t=await v.aiConfig.get();Ke({provider:t.llm.provider,model:t.llm.model,region:t.llm.region,apiKey:"",hasKey:t.llm.hasApiKey,status:null,saving:!1,testing:!1}),Me({provider:t.vector.provider,model:t.vector.model,region:t.vector.region,apiKey:"",hasKey:t.vector.hasApiKey,status:null,saving:!1,testing:!1})}catch{}finally{Wt(!1)}},Yr=async()=>{if(f.testing||f.saving)return;const t=f,a=ae;if(!t.provider.trim()||!t.model.trim()){a(c=>({...c,status:{ok:!1,message:"Provider and model are required."}}));return}if(!st(t)){a(c=>({...c,status:{ok:!1,message:"API key is required to test the connection."}}));return}a(c=>({...c,testing:!0,status:null}));try{const c=await v.aiConfig.test(N,{provider:t.provider.trim(),model:t.model.trim(),...t.apiKey.trim()?{apiKey:t.apiKey.trim()}:{},region:t.region.trim()});a(M=>({...M,testing:!1,status:{ok:c.ok,message:c.ok?c.message??"Connection successful.":c.error??"Connection failed."}}))}catch(c){a(M=>({...M,testing:!1,status:{ok:!1,message:c.message}}))}},_r=async()=>{if(f.saving)return;const t=f,a=ae;if(!t.provider.trim()||!t.model.trim()){a(c=>({...c,status:{ok:!1,message:"Provider and model are required."}}));return}a(c=>({...c,saving:!0,status:null}));try{const c=await v.aiConfig.save(N,{provider:t.provider.trim(),model:t.model.trim(),...t.apiKey.trim()?{apiKey:t.apiKey.trim()}:{},region:t.region.trim()});a(Zr=>({...Zr,hasKey:c.hasApiKey,apiKey:"",saving:!1,status:{ok:!0,message:N==="vector"?"Configuration saved. Existing repo indexes were cleared if the embedding model changed — sync repos to re-index.":"Configuration saved."}}));const M=N==="llm"?c.hasApiKey:tt.hasKey,ne=N==="vector"?c.hasApiKey:rt.hasKey;ke(M&&ne?"Set":M||ne?"Partially set":"Not configured")}catch(c){a(M=>({...M,saving:!1,status:{ok:!1,message:c.message}}))}},Qr=J==="sqlite"?"SQLite (local file)":J==="turso"?"Turso (cloud)":"PostgreSQL",Vr=q==="none"?"No cache":q==="lru"?"LRU (in-memory)":"Redis",Xr=dr==="email"?"Email link reset":"Admin-managed reset",Jr=ht==="oidc"?"OIDC enabled":ht==="github"?"GitHub OAuth":"Disabled";return e.jsxs("div",{style:{flex:1,padding:"32px 40px",overflowY:"auto"},children:[e.jsxs("div",{style:{marginBottom:32},children:[e.jsx("h1",{style:{margin:0,fontSize:22,fontWeight:700,color:"var(--t-text-primary)"},children:"Admin Settings"}),e.jsx("p",{style:{margin:"6px 0 0",fontSize:"var(--t-text-base)",color:"var(--t-text-muted)"},children:"Configure database, caching, and authentication for this instance."})]}),e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:16},children:[e.jsx(_,{icon:e.jsx(at,{size:20}),title:"Database Connection",description:"Switch between SQLite (local), Turso (cloud), or PostgreSQL.",badge:Qr,onConfigure:Pr}),e.jsx(_,{icon:e.jsx(nt,{size:20}),title:"Cache Settings",description:"None (always fresh), LRU (single-server), or Redis (multi-server).",badge:Vr,onConfigure:Br}),d&&e.jsx(_,{icon:e.jsx(ss,{size:20}),title:"Auth Config",description:"Control password reset mode and session duration.",badge:Xr,onConfigure:()=>ut(!0)}),d&&e.jsx(_,{icon:e.jsx(gt,{size:20}),title:"Single Sign-On (SSO)",description:"Configure OIDC or GitHub OAuth for SSO login.",badge:Jr,onConfigure:()=>ft(!0)}),e.jsx(_,{icon:e.jsx(Et,{size:20}),title:"Themes",description:"Customise colours, fonts and border radius for the entire app.",badge:h.name,onConfigure:()=>{m({...h}),T(!0)}}),e.jsx(_,{icon:e.jsx(Ft,{size:20}),title:"Customisation",description:"Set the app title and icon shown on the login screen and in the header bar after login.",badge:(()=>{const t=[Y.iconDataDark,Y.iconDataLight].filter(Boolean).length,a=[Y.logoData,Y.logoDataDark].filter(Boolean).length,c=[];return t===2?c.push("Both icons"):t===1&&c.push("Icon"),a===2?c.push("Both logos"):a===1&&c.push("Logo"),c.length?`${c.join(" + ")} · ${Y.appTitle}`:Y.appTitle})(),onConfigure:mr}),d&&e.jsx(_,{icon:e.jsx(Kt,{size:20}),title:"Global Tags",description:"Define tags available across all spaces and apps. Space tags cannot duplicate these.",badge:`${je.length} tag${je.length!==1?"s":""}`,onConfigure:Kr}),e.jsx(_,{icon:e.jsx(Mt,{size:20}),title:"Client Cache",description:"In-browser SWR cache for apps, spaces, folders, tests and runs. Clear to force a fresh fetch.",badge:`${De().reduce((t,a)=>t+a.size,0)} entries`,onConfigure:gr}),e.jsx(_,{icon:e.jsx(lt,{size:20}),title:"API Tokens",description:"Create Bearer tokens for external integrations like the Jira Forge app.",badge:`${We.length} token${We.length!==1?"s":""}`,onConfigure:Hr}),d&&e.jsx(_,{icon:e.jsx(te,{size:20}),title:"AI Settings",description:"Configure the AI provider, API key, and model for agent features.",badge:Wr,onConfigure:Gr}),d&&e.jsx(_,{icon:e.jsx(te,{size:20}),title:"Global Agents",description:"Build and configure AI agents and tools for the multi-agent workflow.",badge:Tr||void 0,onConfigure:()=>Rt(!0)})]}),F&&e.jsx("div",{style:{position:"fixed",inset:0,zIndex:100,background:"rgba(0,0,0,0.6)",backdropFilter:"blur(2px)",display:"flex",alignItems:"center",justifyContent:"center"},onClick:()=>L(!1),children:e.jsxs("div",{onClick:t=>t.stopPropagation(),style:{background:"var(--t-bg-panel)",border:"1px solid var(--t-border-default)",borderRadius:12,padding:28,width:480,display:"flex",flexDirection:"column",gap:20},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:4},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[e.jsx("div",{style:{width:32,height:32,borderRadius:8,background:"var(--t-bg-elevated)",border:"1px solid var(--t-border-default)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(at,{size:16,weight:"fill",color:"var(--t-text-secondary)"})}),e.jsxs("div",{children:[e.jsx("p",{style:{margin:0,fontSize:"var(--t-text-lg)",fontWeight:600,color:"var(--t-text-primary)"},children:"Database Connection"}),e.jsx("p",{style:{margin:"1px 0 0",fontSize:"var(--t-text-xs)",color:"var(--t-text-muted)"},children:"SQLite, Turso, or PostgreSQL"})]})]}),e.jsx("button",{onClick:()=>L(!1),style:{background:"none",border:"none",cursor:"pointer",color:"var(--t-text-muted)",display:"flex",padding:4},children:e.jsx($,{size:16})})]}),e.jsx("div",{style:{display:"flex",gap:8},children:["sqlite","turso","postgres"].map(t=>e.jsxs("button",{onClick:()=>{O(t),D(null)},style:{flex:1,padding:"10px 8px",borderRadius:8,border:b===t?"1px solid var(--t-border-strong)":"1px solid var(--t-border-default)",background:b===t?"var(--t-bg-surface)":"transparent",color:b===t?"var(--t-text-primary)":"var(--t-text-muted)",cursor:"pointer",display:"flex",flexDirection:"column",alignItems:"center",gap:4,transition:"all 0.12s",position:"relative"},children:[e.jsx(at,{size:18,weight:b===t?"fill":"regular"}),e.jsx("span",{style:{fontSize:"var(--t-text-sm)",fontWeight:500},children:t==="sqlite"?"SQLite":t==="turso"?"Turso":"PostgreSQL"}),J===t&&e.jsx("span",{style:{position:"absolute",top:4,right:4,width:6,height:6,borderRadius:"50%",background:"var(--t-accent-success)"}})]},t))}),b==="sqlite"&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[e.jsx(A,{style:{color:"var(--t-text-secondary)",fontSize:"var(--t-text-sm)"},children:"Storage"}),e.jsx("div",{style:{padding:"8px 12px",background:"var(--t-bg-base)",border:"1px solid var(--t-border-default)",borderRadius:8,fontSize:"var(--t-text-base)",color:"var(--t-text-muted)",fontFamily:"monospace"},children:"file: noob-sdet.db (local)"})]}),b==="turso"&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[e.jsxs(A,{style:{color:"var(--t-text-secondary)",fontSize:"var(--t-text-sm)"},children:["Database URL ",e.jsx("span",{style:{color:"var(--t-accent-danger)"},children:"*"})]}),e.jsx(S,{value:w,onChange:t=>{B(t.target.value),D(null)},placeholder:"libsql://your-db.turso.io",style:{fontFamily:"monospace",fontSize:"var(--t-text-base)"}})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[e.jsx(A,{style:{color:"var(--t-text-secondary)",fontSize:"var(--t-text-sm)"},children:"Auth Token"}),e.jsx(S,{type:"password",value:x,onChange:t=>{R(t.target.value),D(null)},placeholder:"eyJ… (leave blank if none)",style:{fontFamily:"monospace",fontSize:"var(--t-text-base)"}})]})]}),b==="postgres"&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[e.jsxs(A,{style:{color:"var(--t-text-secondary)",fontSize:"var(--t-text-sm)"},children:["Connection String ",e.jsx("span",{style:{color:"var(--t-accent-danger)"},children:"*"})]}),e.jsx(S,{value:w,onChange:t=>{B(t.target.value),D(null)},placeholder:"postgresql://user:pass@host:5432/db",style:{fontFamily:"monospace",fontSize:"var(--t-text-base)"}}),e.jsx("p",{style:{margin:"2px 0 0",fontSize:"var(--t-text-xs)",color:"var(--t-text-muted)"},children:"Supports Neon, Supabase, RDS, Aurora, and self-hosted PostgreSQL."})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[e.jsx(A,{style:{color:"var(--t-text-secondary)",fontSize:"var(--t-text-sm)"},children:"Max Pool Connections"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[e.jsx(S,{type:"number",min:1,max:100,value:U,onChange:t=>{g(t.target.value),D(null)},style:{width:80,fontFamily:"monospace",fontSize:"var(--t-text-base)"}}),e.jsx("p",{style:{margin:0,fontSize:"var(--t-text-xs)",color:"var(--t-text-muted)"},children:"Connections in the pool (default 10)."})]})]})]}),y&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px",borderRadius:8,background:y.ok?"rgba(34,197,94,0.08)":"rgba(229,72,77,0.08)",border:`1px solid ${y.ok?"rgba(34,197,94,0.2)":"rgba(229,72,77,0.2)"}`,fontSize:"var(--t-text-base)",color:y.ok?"var(--t-accent-success)":"var(--t-accent-danger)"},children:[y.ok?e.jsx(ie,{size:15,weight:"fill"}):e.jsx(ue,{size:15,weight:"fill"}),y.message]}),e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[e.jsx(j,{variant:"outline",onClick:()=>L(!1),children:"Close"}),e.jsx(j,{variant:"outline",disabled:E||b!=="sqlite"&&!w.trim(),onClick:Lr,children:E?"Testing…":"Test Connection"}),e.jsx(j,{disabled:E||b!=="sqlite"&&!w.trim(),onClick:Or,children:E?"Saving…":"Save & Apply"})]})]})}),G&&e.jsx("div",{style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.6)",backdropFilter:"blur(2px)",zIndex:100,display:"flex",alignItems:"center",justifyContent:"center"},onClick:()=>n(!1),children:e.jsxs("div",{style:{background:"var(--t-bg-panel)",border:"1px solid var(--t-border-subtle)",borderRadius:12,padding:24,width:420,maxWidth:"90vw",display:"flex",flexDirection:"column",gap:20},onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:4},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[e.jsx("div",{style:{width:32,height:32,borderRadius:8,background:"var(--t-bg-elevated)",border:"1px solid var(--t-border-default)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(nt,{size:16,weight:"fill",color:"var(--t-text-secondary)"})}),e.jsxs("div",{children:[e.jsx("p",{style:{margin:0,fontSize:"var(--t-text-lg)",fontWeight:600,color:"var(--t-text-primary)"},children:"Cache Settings"}),e.jsx("p",{style:{margin:"1px 0 0",fontSize:"var(--t-text-xs)",color:"var(--t-text-muted)"},children:"None, LRU, or Redis"})]})]}),e.jsx("button",{onClick:()=>n(!1),style:{background:"none",border:"none",cursor:"pointer",color:"var(--t-text-muted)",display:"flex",padding:4},children:e.jsx($,{size:16})})]}),e.jsx("div",{style:{display:"flex",gap:8},children:["none","lru","redis"].map(t=>e.jsxs("button",{onClick:()=>{K(t),l(null)},style:{flex:1,padding:"10px 4px",borderRadius:8,border:o===t?"1px solid var(--t-border-strong)":"1px solid var(--t-border-default)",background:o===t?"var(--t-bg-surface)":"transparent",color:o===t?"var(--t-text-primary)":"var(--t-text-muted)",cursor:"pointer",display:"flex",flexDirection:"column",alignItems:"center",gap:6,position:"relative"},children:[e.jsx(nt,{size:18,weight:o===t?"fill":"regular"}),e.jsx("span",{style:{fontSize:"var(--t-text-sm)",fontWeight:500},children:t==="none"?"None":t==="lru"?"LRU":"Redis"}),q===t&&e.jsx("span",{style:{position:"absolute",top:6,right:6,width:6,height:6,borderRadius:"50%",background:"var(--t-accent-success)"}})]},t))}),o==="none"&&e.jsx("p",{style:{margin:0,fontSize:"var(--t-text-base)",color:"var(--t-text-muted)"},children:"Every request goes directly to the database. No stale data, no setup required."}),o==="lru"&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[e.jsx(A,{style:{color:"var(--t-text-secondary)",fontSize:"var(--t-text-sm)"},children:"Max Entries"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[e.jsx(S,{type:"number",min:10,max:1e4,value:re,onChange:t=>{de(t.target.value),l(null)},style:{width:90,fontFamily:"monospace",fontSize:"var(--t-text-base)"}}),e.jsx("p",{style:{margin:0,fontSize:"var(--t-text-xs)",color:"var(--t-text-muted)"},children:"Max cached items (default 500). Oldest evicted when full."})]})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[e.jsx(A,{style:{color:"var(--t-text-secondary)",fontSize:"var(--t-text-sm)"},children:"TTL (seconds)"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[e.jsx(S,{type:"number",min:1,max:3600,value:he,onChange:t=>{ce(t.target.value),l(null)},style:{width:90,fontFamily:"monospace",fontSize:"var(--t-text-base)"}}),e.jsx("p",{style:{margin:0,fontSize:"var(--t-text-xs)",color:"var(--t-text-muted)"},children:"How long entries stay fresh (default 30 s)."})]})]})]}),o==="redis"&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[e.jsxs(A,{style:{color:"var(--t-text-secondary)",fontSize:"var(--t-text-sm)"},children:["Redis URL ",e.jsx("span",{style:{color:"var(--t-accent-danger)"},children:"*"})]}),e.jsx(S,{value:se,onChange:t=>{fe(t.target.value),l(null)},placeholder:"redis://localhost:6379",style:{fontFamily:"monospace",fontSize:"var(--t-text-base)"}}),e.jsx("p",{style:{margin:"2px 0 0",fontSize:"var(--t-text-xs)",color:"var(--t-text-muted)"},children:"Supports local Redis, Upstash, Valkey, and self-hosted instances."})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[e.jsx(A,{style:{color:"var(--t-text-secondary)",fontSize:"var(--t-text-sm)"},children:"TTL (seconds)"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[e.jsx(S,{type:"number",min:1,max:3600,value:he,onChange:t=>{ce(t.target.value),l(null)},style:{width:90,fontFamily:"monospace",fontSize:"var(--t-text-base)"}}),e.jsx("p",{style:{margin:0,fontSize:"var(--t-text-xs)",color:"var(--t-text-muted)"},children:"How long entries stay fresh (default 30 s)."})]})]})]}),Z&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px",borderRadius:6,background:Z.ok?"rgba(34,197,94,0.08)":"rgba(229,72,77,0.08)",border:`1px solid ${Z.ok?"rgba(34,197,94,0.2)":"rgba(229,72,77,0.2)"}`,fontSize:"var(--t-text-base)",color:Z.ok?"var(--t-accent-success)":"var(--t-accent-danger)"},children:[Z.ok?e.jsx(ie,{size:15,weight:"fill"}):e.jsx(ue,{size:15,weight:"fill"}),Z.message]}),e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[e.jsx(j,{variant:"outline",onClick:()=>n(!1),children:"Close"}),e.jsx(j,{variant:"outline",disabled:I||o==="redis"&&!se.trim(),onClick:Er,children:I?"Testing…":"Test Connection"}),e.jsx(j,{disabled:I||o==="redis"&&!se.trim(),onClick:Fr,children:I?"Saving…":"Save & Apply"})]})]})}),d&&e.jsx(Ts,{open:or,onClose:()=>ut(!1)}),d&&e.jsx(Rs,{open:xr,onClose:()=>ft(!1),onSaved:t=>yt(t)}),!1,Sr&&d&&e.jsx("div",{style:{position:"fixed",inset:0,zIndex:100,background:"rgba(0,0,0,0.6)",backdropFilter:"blur(2px)",display:"flex",alignItems:"center",justifyContent:"center"},onClick:()=>Ie(!1),children:e.jsxs("div",{onClick:t=>t.stopPropagation(),style:{background:"var(--t-bg-panel)",border:"1px solid var(--t-border-default)",borderRadius:12,width:480,maxHeight:"80vh",display:"flex",flexDirection:"column",overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"20px 24px 16px",borderBottom:"1px solid var(--t-border-subtle)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[e.jsx("div",{style:{width:32,height:32,borderRadius:8,background:"var(--t-bg-elevated)",border:"1px solid var(--t-border-default)",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(Kt,{size:16,color:"var(--t-text-secondary)"})}),e.jsxs("div",{children:[e.jsx("p",{style:{margin:0,fontSize:"var(--t-text-lg)",fontWeight:600,color:"var(--t-text-primary)"},children:"Global Tags"}),e.jsx("p",{style:{margin:"1px 0 0",fontSize:"var(--t-text-xs)",color:"var(--t-text-muted)"},children:"Available across all spaces"})]})]}),e.jsx("button",{onClick:()=>Ie(!1),style:{background:"none",border:"none",cursor:"pointer",color:"var(--t-text-muted)",display:"flex",padding:4},children:e.jsx($,{size:16})})]}),e.jsxs("div",{style:{padding:"16px 24px",borderBottom:"1px solid var(--t-border-subtle)"},children:[e.jsx("p",{style:{margin:"0 0 10px",fontSize:12,fontWeight:600,color:"var(--t-text-muted)",textTransform:"uppercase",letterSpacing:"0.06em"},children:"Add New Tag"}),e.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[e.jsx("input",{type:"color",value:St,onChange:t=>Cr(t.target.value),title:"Pick tag color",style:{width:36,height:36,padding:2,borderRadius:6,border:"1px solid var(--t-border-default)",background:"var(--t-bg-elevated)",cursor:"pointer",flexShrink:0}}),e.jsx(S,{value:Re,onChange:t=>{Ve(t.target.value),Se("")},onKeyDown:t=>{t.key==="Enter"&&Lt()},placeholder:"Tag name…",style:{flex:1}}),e.jsxs(j,{onClick:Lt,disabled:!Re.trim()||Xe,style:{gap:6,flexShrink:0},children:[e.jsx(ee,{size:14}),Xe?"Adding…":"Add"]})]}),kt&&e.jsx("p",{style:{margin:"8px 0 0",fontSize:"var(--t-text-sm)",color:"var(--t-accent-danger)"},children:kt})]}),e.jsx("div",{style:{flex:1,overflowY:"auto",padding:"12px 24px 20px"},children:kr?e.jsx(it,{count:4,rowHeight:40,padding:"6px 0",showIcon:!1}):je.length===0?e.jsx("p",{style:{fontSize:"var(--t-text-base)",color:"var(--t-text-muted)",padding:"8px 0"},children:"No global tags yet. Add one above."}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:je.map(t=>e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 12px",borderRadius:8,background:"var(--t-bg-surface)",border:"1px solid var(--t-border-subtle)"},children:[e.jsx(ds,{name:t.name,color:t.color}),e.jsx("button",{onClick:()=>Mr(t.id),title:"Delete global tag",style:{background:"none",border:"none",cursor:"pointer",color:"var(--t-text-muted)",display:"flex",padding:4,borderRadius:4,transition:"color 0.1s"},onMouseEnter:a=>{a.currentTarget.style.color="var(--t-accent-danger)"},onMouseLeave:a=>{a.currentTarget.style.color="var(--t-text-muted)"},children:e.jsx(ze,{size:14})})]},t.id))})}),e.jsx("div",{style:{padding:"14px 24px",borderTop:"1px solid var(--t-border-subtle)",display:"flex",justifyContent:"flex-end"},children:e.jsx(j,{variant:"outline",onClick:()=>Ie(!1),children:"Close"})})]})}),pr&&e.jsx("div",{style:{position:"fixed",inset:0,zIndex:100,background:"rgba(0,0,0,0.6)",backdropFilter:"blur(2px)",display:"flex",alignItems:"center",justifyContent:"center"},onClick:()=>we(!1),children:e.jsxs("div",{onClick:t=>t.stopPropagation(),style:{background:"var(--t-bg-panel)",border:"1px solid var(--t-border-default)",borderRadius:12,width:480,maxHeight:"80vh",display:"flex",flexDirection:"column",overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"20px 24px 16px",borderBottom:"1px solid var(--t-border-subtle)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[e.jsx("div",{style:{width:32,height:32,borderRadius:8,background:"var(--t-bg-elevated)",border:"1px solid var(--t-border-default)",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(Mt,{size:16,color:"var(--t-text-secondary)"})}),e.jsxs("div",{children:[e.jsx("p",{style:{margin:0,fontSize:"var(--t-text-lg)",fontWeight:600,color:"var(--t-text-primary)"},children:"Client Cache"}),e.jsxs("p",{style:{margin:"1px 0 0",fontSize:"var(--t-text-xs)",color:"var(--t-text-muted)"},children:[Ue," entr",Ue!==1?"ies":"y"," ","cached in this browser session"]})]})]}),e.jsx("button",{onClick:()=>we(!1),style:{background:"none",border:"none",cursor:"pointer",color:"var(--t-text-muted)",display:"flex",padding:4},children:e.jsx($,{size:16})})]}),e.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"16px 24px"},children:[e.jsx("p",{style:{margin:"0 0 12px",fontSize:"var(--t-text-xs)",color:"var(--t-text-muted)",lineHeight:1.5},children:"Each row shows how many keyed slices are currently cached for that resource. Clearing a cache forces the next navigation to re-fetch from the server instead of serving stale data."}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:$e.map((t,a)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 14px",borderRadius:8,background:"var(--t-bg-surface)",border:"1px solid var(--t-border-subtle)"},children:[e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontSize:"var(--t-text-base)",fontWeight:500,color:"var(--t-text-primary)"},children:t.label}),e.jsx("div",{style:{fontSize:"var(--t-text-xs)",color:"var(--t-text-muted)",marginTop:1},children:t.description})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,flexShrink:0,marginLeft:12},children:[e.jsx("span",{style:{fontSize:"var(--t-text-sm)",fontFamily:"monospace",color:t.size>0?"var(--t-text-secondary)":"var(--t-text-muted)",minWidth:20,textAlign:"right"},children:t.size}),e.jsx(j,{variant:"outline",size:"sm",disabled:t.size===0,onClick:()=>ur(a),style:{fontSize:"var(--t-text-xs)",padding:"3px 10px",height:"auto"},children:"Clear"})]})]},t.label))})]}),e.jsxs("div",{style:{padding:"14px 24px",borderTop:"1px solid var(--t-border-subtle)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs(j,{variant:"outline",disabled:Ue===0,onClick:fr,style:{gap:6},children:[e.jsx(ze,{size:14}),"Clear All"]}),e.jsx(j,{variant:"outline",onClick:()=>we(!1),children:"Close"})]})]})}),vr&&e.jsx("div",{style:{position:"fixed",inset:0,zIndex:100,background:"rgba(0,0,0,0.6)",backdropFilter:"blur(2px)",display:"flex",alignItems:"center",justifyContent:"center"},onClick:()=>xe(!1),children:e.jsxs("div",{onClick:t=>t.stopPropagation(),style:{background:"var(--t-bg-panel)",border:"1px solid var(--t-border-default)",borderRadius:12,width:500,maxHeight:"90vh",display:"flex",flexDirection:"column",overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"20px 24px 16px",borderBottom:"1px solid var(--t-border-subtle)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[e.jsx("div",{style:{width:32,height:32,borderRadius:8,background:"var(--t-bg-elevated)",border:"1px solid var(--t-border-default)",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(Ft,{size:16,color:"var(--t-text-secondary)"})}),e.jsxs("div",{children:[e.jsx("p",{style:{margin:0,fontSize:"var(--t-text-lg)",fontWeight:600,color:"var(--t-text-primary)"},children:"Customisation"}),e.jsx("p",{style:{margin:"1px 0 0",fontSize:"var(--t-text-xs)",color:"var(--t-text-muted)"},children:"App title & icon"})]})]}),e.jsx("button",{onClick:()=>xe(!1),style:{background:"none",border:"none",cursor:"pointer",color:"var(--t-text-muted)",display:"flex",padding:4},children:e.jsx($,{size:16})})]}),e.jsxs("div",{style:{padding:"20px 24px",display:"flex",flexDirection:"column",gap:20,overflowY:"auto"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[e.jsx(A,{style:{fontSize:"var(--t-text-sm)",color:"var(--t-text-secondary)"},children:"App Title"}),e.jsx(S,{value:pe,onChange:t=>vt(t.target.value),placeholder:"noob-sdet",maxLength:40})]}),e.jsx("p",{style:{margin:0,fontSize:"var(--t-text-xs)",color:"var(--t-text-muted)",lineHeight:1.5},children:"Upload separate icons for dark and light themes — each shown in the top header bar and on the login screen. Use SVG or PNG, square, 64×64 px or larger (max ~512 KB). SVG scales perfectly at any size."}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[e.jsx(A,{style:{fontSize:"var(--t-text-sm)",color:"var(--t-text-secondary)"},children:"Icon — Dark Background"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"12px 14px",borderRadius:8,background:"#0d0d0d",border:"1px solid var(--t-border-subtle)"},children:[ye?e.jsx("img",{src:ye,alt:"Dark icon preview",style:{width:36,height:36,objectFit:"contain",borderRadius:6,flexShrink:0}}):e.jsx("div",{style:{width:36,height:36,borderRadius:6,background:"#1a1a1a",border:"1px solid #2a2a2a",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"var(--t-text-xl)",fontWeight:700,color:"#666",flexShrink:0},children:(pe||"N").charAt(0).toUpperCase()}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsxs("label",{style:{display:"inline-flex",alignItems:"center",gap:6,padding:"6px 12px",borderRadius:6,border:"1px solid #333",background:"#1a1a1a",color:"#aaa",fontSize:"var(--t-text-sm)",fontWeight:500,cursor:"pointer"},children:[e.jsx(ee,{size:12}),ye?"Replace":"Upload",e.jsx("input",{type:"file",accept:"image/svg+xml,image/png",style:{display:"none"},onChange:Te(qe)})]}),ye&&e.jsxs("button",{onClick:()=>qe(null),style:{display:"inline-flex",alignItems:"center",gap:4,padding:"6px 10px",borderRadius:6,border:"1px solid #333",background:"none",color:"var(--t-accent-danger)",fontSize:"var(--t-text-sm)",cursor:"pointer"},children:[e.jsx($,{size:11}),"Remove"]})]})]})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[e.jsx(A,{style:{fontSize:"var(--t-text-sm)",color:"var(--t-text-secondary)"},children:"Icon — Light Background"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"12px 14px",borderRadius:8,background:"#f5f5f5",border:"1px solid var(--t-border-subtle)"},children:[ve?e.jsx("img",{src:ve,alt:"Light icon preview",style:{width:36,height:36,objectFit:"contain",borderRadius:6,flexShrink:0}}):e.jsx("div",{style:{width:36,height:36,borderRadius:6,background:"#e0e0e0",border:"1px solid #ccc",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"var(--t-text-xl)",fontWeight:700,color:"#888",flexShrink:0},children:(pe||"N").charAt(0).toUpperCase()}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsxs("label",{style:{display:"inline-flex",alignItems:"center",gap:6,padding:"6px 12px",borderRadius:6,border:"1px solid #ccc",background:"#e8e8e8",color:"#555",fontSize:"var(--t-text-sm)",fontWeight:500,cursor:"pointer"},children:[e.jsx(ee,{size:12}),ve?"Replace":"Upload",e.jsx("input",{type:"file",accept:"image/svg+xml,image/png",style:{display:"none"},onChange:Te(Ge)})]}),ve&&e.jsxs("button",{onClick:()=>Ge(null),style:{display:"inline-flex",alignItems:"center",gap:4,padding:"6px 10px",borderRadius:6,border:"1px solid #ccc",background:"none",color:"var(--t-accent-danger)",fontSize:"var(--t-text-sm)",cursor:"pointer"},children:[e.jsx($,{size:11}),"Remove"]})]})]})]}),e.jsx("p",{style:{margin:0,fontSize:"var(--t-text-xs)",color:"var(--t-text-muted)",lineHeight:1.5},children:"Upload separate logos for the login screen depending on the active theme. Can be a full wordmark, banner, or brand mark. SVG or PNG, recommended 200×64 px or wider (max ~512 KB). Falls back to the theme-aware icon if not set."}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[e.jsx(A,{style:{fontSize:"var(--t-text-sm)",color:"var(--t-text-secondary)"},children:"Login Logo — Light Background"}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:10,padding:"16px",borderRadius:8,background:"#f5f5f5",border:"1px solid var(--t-border-subtle)"},children:[me?e.jsx("img",{src:me,alt:"Light login logo preview",style:{maxWidth:"100%",maxHeight:72,objectFit:"contain",borderRadius:6}}):e.jsx("div",{style:{width:120,height:48,borderRadius:8,background:"#e0e0e0",border:"1px dashed #bbb",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"var(--t-text-xs)",color:"#888"},children:"No logo set"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsxs("label",{style:{display:"inline-flex",alignItems:"center",gap:6,padding:"6px 12px",borderRadius:6,border:"1px solid #ccc",background:"#e8e8e8",color:"#555",fontSize:"var(--t-text-sm)",fontWeight:500,cursor:"pointer"},children:[e.jsx(ee,{size:12}),me?"Replace":"Upload",e.jsx("input",{type:"file",accept:"image/svg+xml,image/png",style:{display:"none"},onChange:Te(Ye)})]}),me&&e.jsxs("button",{onClick:()=>Ye(null),style:{display:"inline-flex",alignItems:"center",gap:4,padding:"6px 10px",borderRadius:6,border:"1px solid #ccc",background:"none",color:"var(--t-accent-danger)",fontSize:"var(--t-text-sm)",cursor:"pointer"},children:[e.jsx($,{size:11}),"Remove"]})]})]})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[e.jsx(A,{style:{fontSize:"var(--t-text-sm)",color:"var(--t-text-secondary)"},children:"Login Logo — Dark Background"}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:10,padding:"16px",borderRadius:8,background:"#0d0d0d",border:"1px solid var(--t-border-subtle)"},children:[be?e.jsx("img",{src:be,alt:"Dark login logo preview",style:{maxWidth:"100%",maxHeight:72,objectFit:"contain",borderRadius:6}}):e.jsx("div",{style:{width:120,height:48,borderRadius:8,background:"#1a1a1a",border:"1px dashed #333",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"var(--t-text-xs)",color:"#666"},children:"No logo set"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsxs("label",{style:{display:"inline-flex",alignItems:"center",gap:6,padding:"6px 12px",borderRadius:6,border:"1px solid #333",background:"#1a1a1a",color:"#aaa",fontSize:"var(--t-text-sm)",fontWeight:500,cursor:"pointer"},children:[e.jsx(ee,{size:12}),be?"Replace":"Upload",e.jsx("input",{type:"file",accept:"image/svg+xml,image/png",style:{display:"none"},onChange:Te(_e)})]}),be&&e.jsxs("button",{onClick:()=>_e(null),style:{display:"inline-flex",alignItems:"center",gap:4,padding:"6px 10px",borderRadius:6,border:"1px solid #333",background:"none",color:"var(--t-accent-danger)",fontSize:"var(--t-text-sm)",cursor:"pointer"},children:[e.jsx($,{size:11}),"Remove"]})]})]})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"14px 24px",borderTop:"1px solid var(--t-border-subtle)"},children:[e.jsxs("button",{onClick:jr,style:{display:"flex",alignItems:"center",gap:6,background:"none",border:"none",color:"var(--t-text-muted)",fontSize:"var(--t-text-sm)",cursor:"pointer",padding:"6px 10px",borderRadius:6,transition:"color 0.1s"},onMouseEnter:t=>{t.currentTarget.style.color="var(--t-text-secondary)"},onMouseLeave:t=>{t.currentTarget.style.color="var(--t-text-muted)"},children:[e.jsx(Ht,{size:14}),"Reset to default"]}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx(j,{variant:"outline",onClick:()=>xe(!1),children:"Cancel"}),e.jsx(j,{onClick:()=>void br(),disabled:mt||!pe.trim(),children:mt?"Saving…":"Save"})]})]})]})}),H&&e.jsx("div",{style:{position:"fixed",inset:0,zIndex:100,background:"rgba(0,0,0,0.7)",backdropFilter:"blur(3px)",display:"flex",alignItems:"center",justifyContent:"center"},onClick:()=>T(!1),children:e.jsxs("div",{onClick:t=>t.stopPropagation(),style:{background:"var(--t-bg-panel)",border:"1px solid var(--t-border-default)",borderRadius:14,width:680,maxHeight:"90vh",display:"flex",flexDirection:"column",overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"20px 24px 16px",borderBottom:"1px solid var(--t-border-subtle)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[e.jsx("div",{style:{width:32,height:32,borderRadius:8,background:"var(--t-bg-elevated)",border:"1px solid var(--t-border-default)",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(Et,{size:16,color:"var(--t-text-secondary)"})}),e.jsxs("div",{children:[e.jsx("p",{style:{margin:0,fontSize:"var(--t-text-lg)",fontWeight:600,color:"var(--t-text-primary)"},children:"Themes"}),e.jsx("p",{style:{margin:"1px 0 0",fontSize:"var(--t-text-xs)",color:"var(--t-text-muted)"},children:"Customise colors, fonts and shape"})]})]}),e.jsx("button",{onClick:()=>T(!1),style:{background:"none",border:"none",color:"var(--t-text-muted)",cursor:"pointer",padding:4},children:e.jsx($,{size:16})})]}),e.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"20px 24px"},children:[e.jsx("p",{style:{margin:"0 0 10px",fontSize:12,fontWeight:600,color:"var(--t-text-muted)",textTransform:"uppercase",letterSpacing:"0.06em"},children:"Presets"}),e.jsx("div",{style:{display:"flex",gap:8,flexWrap:"wrap",marginBottom:24},children:cs.map(t=>e.jsxs("button",{onClick:()=>z(t),style:{padding:"6px 14px",borderRadius:8,border:`1px solid ${r.name===t.name?"var(--t-border-strong)":"var(--t-border-default)"}`,background:r.name===t.name?"var(--t-bg-surface)":"transparent",color:r.name===t.name?"var(--t-text-primary)":"var(--t-text-muted)",fontSize:"var(--t-text-sm)",fontWeight:500,cursor:"pointer",display:"flex",alignItems:"center",gap:8,transition:"all 0.1s"},children:[e.jsx("span",{style:{display:"flex",gap:3},children:[t.bgBase,t.bgPanel,t.textPrimary,t.accentDanger].map((a,c)=>e.jsx("span",{style:{width:10,height:10,borderRadius:3,background:a,border:"1px solid rgba(255,255,255,0.1)"}},c))}),t.name]},t.name))}),[{label:"Backgrounds",fields:[{key:"bgBase",label:"Base"},{key:"bgSurface",label:"Surface"},{key:"bgPanel",label:"Panel"},{key:"bgElevated",label:"Elevated"},{key:"bgHover",label:"Hover"}]},{label:"Borders",fields:[{key:"borderSubtle",label:"Subtle"},{key:"borderDefault",label:"Default"},{key:"borderStrong",label:"Strong"}]},{label:"Text",fields:[{key:"textPrimary",label:"Primary"},{key:"textSecondary",label:"Secondary"},{key:"textMuted",label:"Muted"}]},{label:"Accents",fields:[{key:"accentDanger",label:"Danger"},{key:"accentSuccess",label:"Success"},{key:"accentWarning",label:"Warning"},{key:"accentBlocked",label:"Blocked"}]}].map(t=>e.jsxs("div",{style:{marginBottom:22},children:[e.jsx("p",{style:{margin:"0 0 10px",fontSize:12,fontWeight:600,color:"var(--t-text-muted)",textTransform:"uppercase",letterSpacing:"0.06em"},children:t.label}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(140px, 1fr))",gap:10},children:t.fields.map(({key:a,label:c})=>e.jsxs("div",{children:[e.jsx("p",{style:{margin:"0 0 5px",fontSize:"var(--t-text-xs)",color:"var(--t-text-muted)"},children:c}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx("input",{type:"color",value:String(r[a]).startsWith("#")?String(r[a]).slice(0,7):"#000000",onChange:M=>z({[a]:M.target.value}),style:{width:32,height:32,padding:2,borderRadius:6,border:"1px solid var(--t-border-default)",background:"var(--t-bg-elevated)",cursor:"pointer",flexShrink:0}}),e.jsx("input",{type:"text",value:String(r[a]),onChange:M=>z({[a]:M.target.value}),style:{flex:1,background:"var(--t-bg-surface)",border:"1px solid var(--t-border-default)",borderRadius:6,padding:"5px 8px",fontSize:"var(--t-text-xs)",color:"var(--t-text-secondary)",fontFamily:"monospace",minWidth:0}})]})]},a))})]},t.label)),e.jsxs("div",{style:{marginBottom:22},children:[e.jsx("p",{style:{margin:"0 0 10px",fontSize:12,fontWeight:600,color:"var(--t-text-muted)",textTransform:"uppercase",letterSpacing:"0.06em"},children:"Typography"}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[e.jsxs("div",{children:[e.jsx("p",{style:{margin:"0 0 5px",fontSize:"var(--t-text-xs)",color:"var(--t-text-muted)"},children:"Sans-serif font stack"}),e.jsx("input",{type:"text",value:r.fontSans,onChange:t=>z({fontSans:t.target.value}),style:{width:"100%",background:"var(--t-bg-surface)",border:"1px solid var(--t-border-default)",borderRadius:6,padding:"6px 10px",fontSize:"var(--t-text-sm)",color:"var(--t-text-secondary)",fontFamily:"monospace"}})]}),e.jsxs("div",{children:[e.jsx("p",{style:{margin:"0 0 5px",fontSize:"var(--t-text-xs)",color:"var(--t-text-muted)"},children:"Monospace font stack"}),e.jsx("input",{type:"text",value:r.fontMono,onChange:t=>z({fontMono:t.target.value}),style:{width:"100%",background:"var(--t-bg-surface)",border:"1px solid var(--t-border-default)",borderRadius:6,padding:"6px 10px",fontSize:"var(--t-text-sm)",color:"var(--t-text-secondary)",fontFamily:"monospace"}})]})]})]}),e.jsxs("div",{style:{marginBottom:8},children:[e.jsx("p",{style:{margin:"0 0 10px",fontSize:12,fontWeight:600,color:"var(--t-text-muted)",textTransform:"uppercase",letterSpacing:"0.06em"},children:"Shape & Size"}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:14},children:[e.jsx("span",{style:{fontSize:"var(--t-text-sm)",color:"var(--t-text-secondary)",minWidth:72,flexShrink:0},children:"Font size"}),e.jsx("input",{type:"range",min:11,max:16,step:1,value:r.fontSize??14,onChange:t=>z({fontSize:Number(t.target.value)}),style:{flex:1,accentColor:"var(--t-text-primary)"}}),e.jsxs("span",{style:{fontSize:"var(--t-text-sm)",color:"var(--t-text-secondary)",minWidth:36,textAlign:"right"},children:[r.fontSize??14,"px"]}),e.jsx("span",{style:{fontSize:r.fontSize??14,color:"var(--t-text-secondary)",minWidth:36,textAlign:"center"},children:"Aa"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:14},children:[e.jsx("span",{style:{fontSize:"var(--t-text-sm)",color:"var(--t-text-secondary)",minWidth:72,flexShrink:0},children:"Radius"}),e.jsx("input",{type:"range",min:0,max:24,value:r.radius,onChange:t=>z({radius:Number(t.target.value)}),style:{flex:1,accentColor:"var(--t-text-primary)"}}),e.jsxs("span",{style:{fontSize:"var(--t-text-sm)",color:"var(--t-text-secondary)",minWidth:36,textAlign:"right"},children:[r.radius,"px"]}),e.jsx("div",{style:{width:36,height:36,borderRadius:r.radius,border:"1px solid var(--t-border-strong)",background:"var(--t-bg-elevated)",flexShrink:0}})]})]})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"14px 24px",borderTop:"1px solid var(--t-border-subtle)"},children:[e.jsxs("button",{onClick:P,style:{display:"flex",alignItems:"center",gap:6,background:"none",border:"none",color:"var(--t-text-muted)",fontSize:"var(--t-text-sm)",cursor:"pointer",padding:"6px 10px",borderRadius:6,transition:"color 0.1s"},onMouseEnter:t=>{t.currentTarget.style.color="var(--t-text-secondary)"},onMouseLeave:t=>{t.currentTarget.style.color="var(--t-text-muted)"},children:[e.jsx(Ht,{size:14}),"Reset to default"]}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx(j,{variant:"outline",onClick:()=>T(!1),children:"Cancel"}),e.jsx(j,{onClick:C,disabled:W,children:W?"Saving…":"Save Theme"})]})]})]})}),zr&&e.jsx("div",{style:{position:"fixed",inset:0,zIndex:100,background:"rgba(0,0,0,0.6)",backdropFilter:"blur(2px)",display:"flex",alignItems:"center",justifyContent:"center"},onClick:()=>Ae(!1),children:e.jsxs("div",{onClick:t=>t.stopPropagation(),style:{background:"var(--t-bg-panel)",border:"1px solid var(--t-border-default)",borderRadius:12,width:540,maxHeight:"80vh",display:"flex",flexDirection:"column",overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"20px 24px 16px",borderBottom:"1px solid var(--t-border-subtle)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[e.jsx("div",{style:{width:32,height:32,borderRadius:8,background:"var(--t-bg-elevated)",border:"1px solid var(--t-border-default)",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(lt,{size:16,color:"var(--t-text-secondary)"})}),e.jsxs("div",{children:[e.jsx("p",{style:{margin:0,fontSize:"var(--t-text-lg)",fontWeight:600,color:"var(--t-text-primary)"},children:"API Tokens"}),e.jsx("p",{style:{margin:"1px 0 0",fontSize:"var(--t-text-xs)",color:"var(--t-text-muted)"},children:"Bearer tokens for external integrations"})]})]}),e.jsx("button",{onClick:()=>Ae(!1),style:{background:"none",border:"none",cursor:"pointer",color:"var(--t-text-muted)",display:"flex",padding:4},children:e.jsx($,{size:16})})]}),e.jsxs("div",{style:{padding:"16px 24px",borderBottom:"1px solid var(--t-border-subtle)"},children:[e.jsx("p",{style:{margin:"0 0 10px",fontSize:12,fontWeight:600,color:"var(--t-text-muted)",textTransform:"uppercase",letterSpacing:"0.06em"},children:"New Token"}),e.jsxs("div",{style:{display:"flex",gap:8,alignItems:"flex-end"},children:[e.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:4},children:[e.jsx(A,{style:{color:"var(--t-text-secondary)",fontSize:"var(--t-text-xs)"},children:"Name"}),e.jsx(S,{value:Le,onChange:t=>{Je(t.target.value),Oe("")},onKeyDown:t=>{t.key==="Enter"&&Ot()},placeholder:"e.g. Jira Forge App",style:{fontSize:"var(--t-text-base)"}})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[e.jsx(A,{style:{color:"var(--t-text-secondary)",fontSize:"var(--t-text-xs)"},children:"Expires (optional)"}),e.jsx(S,{type:"date",value:wt,onChange:t=>Ze(t.target.value),style:{fontSize:"var(--t-text-base)",width:150}})]}),e.jsxs(j,{onClick:Ot,disabled:!Le.trim()||et,style:{gap:6,flexShrink:0},children:[e.jsx(ee,{size:14}),et?"Creating…":"Create"]})]}),Tt&&e.jsx("p",{style:{margin:"8px 0 0",fontSize:"var(--t-text-sm)",color:"var(--t-accent-danger)"},children:Tt}),ge&&e.jsxs("div",{style:{marginTop:12,padding:"10px 12px",borderRadius:8,background:"rgba(34,197,94,0.06)",border:"1px solid rgba(34,197,94,0.25)",display:"flex",flexDirection:"column",gap:6},children:[e.jsx("p",{style:{margin:0,fontSize:"var(--t-text-xs)",color:"var(--t-accent-success)",fontWeight:600},children:"Token created — copy it now. It will not be shown again."}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("code",{style:{flex:1,fontSize:"var(--t-text-sm)",fontFamily:"monospace",color:"var(--t-text-primary)",background:"var(--t-bg-base)",border:"1px solid var(--t-border-default)",borderRadius:6,padding:"6px 10px",wordBreak:"break-all"},children:ge.token}),e.jsxs("button",{onClick:()=>Nr(ge.token),title:"Copy token",style:{background:"none",border:"1px solid var(--t-border-default)",borderRadius:6,cursor:"pointer",color:It?"var(--t-accent-success)":"var(--t-text-secondary)",display:"flex",alignItems:"center",gap:4,padding:"6px 10px",fontSize:"var(--t-text-sm)",flexShrink:0,transition:"color 0.15s"},children:[e.jsx(as,{size:14}),It?"Copied!":"Copy"]})]})]})]}),e.jsx("div",{style:{flex:1,overflowY:"auto",padding:"12px 24px 20px"},children:wr?e.jsx(it,{count:3,rowHeight:44,padding:"6px 0",showIcon:!1}):We.length===0?e.jsx("p",{style:{fontSize:"var(--t-text-base)",color:"var(--t-text-muted)",padding:"8px 0"},children:"No tokens yet. Create one above."}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:We.map(t=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"10px 14px",borderRadius:8,background:"var(--t-bg-surface)",border:"1px solid var(--t-border-subtle)"},children:[e.jsx(lt,{size:14,color:"var(--t-text-muted)",style:{flexShrink:0}}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontSize:"var(--t-text-base)",fontWeight:500,color:"var(--t-text-primary)"},children:t.name}),e.jsxs("div",{style:{fontSize:"var(--t-text-xs)",color:"var(--t-text-muted)",marginTop:1},children:["Created ",new Date(t.createdAt).toLocaleDateString(),t.lastUsedAt&&` · Last used ${new Date(t.lastUsedAt).toLocaleDateString()}`,t.expiresAt&&` · Expires ${new Date(t.expiresAt).toLocaleDateString()}`]})]}),e.jsx("button",{onClick:()=>$r(t.id),title:"Revoke token",style:{background:"none",border:"none",cursor:"pointer",color:"var(--t-text-muted)",display:"flex",padding:4,borderRadius:4,flexShrink:0,transition:"color 0.1s"},onMouseEnter:a=>{a.currentTarget.style.color="var(--t-accent-danger)"},onMouseLeave:a=>{a.currentTarget.style.color="var(--t-text-muted)"},children:e.jsx(ze,{size:14})})]},t.id))})}),e.jsx("div",{style:{padding:"14px 24px",borderTop:"1px solid var(--t-border-subtle)",display:"flex",justifyContent:"flex-end"},children:e.jsx(j,{variant:"outline",onClick:()=>Ae(!1),children:"Close"})})]})}),Rr&&d&&e.jsx("div",{style:{position:"fixed",inset:0,zIndex:100,background:"rgba(0,0,0,0.6)",backdropFilter:"blur(2px)",display:"flex",alignItems:"center",justifyContent:"center"},onClick:()=>Fe(!1),children:e.jsxs("div",{onClick:t=>t.stopPropagation(),style:{background:"var(--t-bg-panel)",border:"1px solid var(--t-border-default)",borderRadius:12,width:700,maxWidth:"95vw",maxHeight:"85vh",display:"flex",flexDirection:"column",overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"20px 24px 16px",borderBottom:"1px solid var(--t-border-subtle)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[e.jsx("div",{style:{width:32,height:32,borderRadius:8,background:"var(--t-bg-elevated)",border:"1px solid var(--t-border-default)",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(te,{size:16,color:"var(--t-text-secondary)"})}),e.jsxs("div",{children:[e.jsx("p",{style:{margin:0,fontSize:"var(--t-text-lg)",fontWeight:600,color:"var(--t-text-primary)"},children:"AI Settings"}),e.jsx("p",{style:{margin:"1px 0 0",fontSize:"var(--t-text-xs)",color:"var(--t-text-muted)"},children:"Org-wide — applies to all users. Super admins only."})]})]}),e.jsx("button",{onClick:()=>Fe(!1),style:{background:"none",border:"none",cursor:"pointer",color:"var(--t-text-muted)",display:"flex",padding:4},children:e.jsx($,{size:16})})]}),e.jsxs("div",{style:{display:"flex",flex:1,minHeight:0,overflow:"hidden"},children:[e.jsxs("div",{style:{width:196,borderRight:"1px solid var(--t-border-subtle)",padding:"16px 12px",display:"flex",flexDirection:"column",gap:4,flexShrink:0},children:[e.jsx("p",{style:{margin:"0 0 8px 4px",fontSize:11,fontWeight:600,color:"var(--t-text-muted)",textTransform:"uppercase",letterSpacing:"0.06em"},children:"Connection"}),["llm","vector"].map(t=>{const a=t==="llm"?tt:rt,c=N===t;return e.jsxs("button",{onClick:()=>At(t),style:{display:"flex",alignItems:"center",gap:10,padding:"10px 12px",borderRadius:8,border:c?"1px solid var(--t-border-strong)":"1px solid transparent",cursor:"pointer",background:c?"var(--t-bg-elevated)":"transparent",textAlign:"left",transition:"all 0.12s",position:"relative"},children:[e.jsx("div",{style:{width:32,height:32,borderRadius:7,background:c?"rgba(255,255,255,0.06)":"var(--t-bg-surface)",border:"1px solid var(--t-border-default)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,color:c?"var(--t-text-primary)":"var(--t-text-muted)"},children:e.jsx(te,{size:14,weight:c?"fill":"regular"})}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("p",{style:{margin:0,fontSize:"var(--t-text-sm)",fontWeight:600,color:c?"var(--t-text-primary)":"var(--t-text-secondary)",lineHeight:1.3},children:t==="llm"?"LLM":"Vector DB"}),e.jsx("p",{style:{margin:"2px 0 0",fontSize:"var(--t-text-xs)",color:"var(--t-text-muted)",lineHeight:1.3,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:a.hasKey?"Configured":"Not set"})]}),a.hasKey&&e.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:"var(--t-accent-success)",flexShrink:0}})]},t)})]}),e.jsx("div",{style:{flex:1,padding:"20px 24px",display:"flex",flexDirection:"column",gap:18,overflowY:"auto",minHeight:360},children:Ar?e.jsx(it,{count:3,rowHeight:40,padding:"4px 0",showIcon:!1}):e.jsxs(e.Fragment,{children:[e.jsx("p",{style:{margin:"0 0 4px",fontSize:11,fontWeight:600,color:"var(--t-text-muted)",textTransform:"uppercase",letterSpacing:"0.06em"},children:N==="llm"?"Language Model":"Vector Database"}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[e.jsxs(A,{style:{color:"var(--t-text-secondary)",fontSize:"var(--t-text-sm)"},children:["Provider ",e.jsx("span",{style:{color:"var(--t-accent-danger)"},children:"*"})]}),e.jsxs("select",{value:f.provider,onChange:t=>ae(a=>({...a,provider:t.target.value,status:null})),style:{width:"100%",padding:"8px 12px",borderRadius:8,border:"1px solid var(--t-border-default)",background:"var(--t-bg-base)",color:f.provider?"var(--t-text-primary)":"var(--t-text-muted)",fontSize:"var(--t-text-base)",cursor:"pointer"},children:[e.jsx("option",{value:"",children:"Select a provider…"}),(N==="llm"?Ur:qr).map(t=>e.jsx("option",{value:t,children:t},t))]})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[e.jsxs(A,{style:{color:"var(--t-text-secondary)",fontSize:"var(--t-text-sm)"},children:["Model name ",e.jsx("span",{style:{color:"var(--t-accent-danger)"},children:"*"})]}),e.jsx(S,{value:f.model,onChange:t=>ae(a=>({...a,model:t.target.value,status:null})),placeholder:f.provider==="Ollama Cloud"?"e.g. gpt-oss:120b-cloud":f.provider.startsWith("Amazon Bedrock")?N==="llm"?"e.g. amazon.titan-text-premier-v1:0":"e.g. amazon.titan-embed-text-v2:0":N==="llm"?"e.g. claude-sonnet-4-6":"e.g. text-embedding-3-small",style:{fontFamily:"monospace",fontSize:"var(--t-text-base)"}})]}),f.provider.startsWith("Amazon Bedrock")&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[e.jsxs(A,{style:{color:"var(--t-text-secondary)",fontSize:"var(--t-text-sm)"},children:["AWS Region ",e.jsx("span",{style:{color:"var(--t-accent-danger)"},children:"*"})]}),e.jsx(S,{value:f.region,onChange:t=>ae(a=>({...a,region:t.target.value,status:null})),placeholder:"e.g. eu-central-1",style:{fontFamily:"monospace",fontSize:"var(--t-text-base)"}})]}),N==="vector"&&f.provider==="OpenAI"&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[e.jsx(A,{style:{color:"var(--t-text-secondary)",fontSize:"var(--t-text-sm)"},children:"Embedding dimensions"}),e.jsx(S,{value:f.region,onChange:t=>ae(a=>({...a,region:t.target.value,status:null})),placeholder:"1536 (matches storage; leave blank for default)",style:{fontFamily:"monospace",fontSize:"var(--t-text-base)"}}),e.jsxs("p",{style:{margin:"2px 0 0",fontSize:"var(--t-text-xs)",color:"var(--t-text-muted)"},children:["Use ",e.jsx("code",{children:"text-embedding-3-small"})," at 1536 dims. Changing model or dimensions clears existing repo indexes — re-sync each repo after save."]})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[e.jsxs(A,{style:{color:"var(--t-text-secondary)",fontSize:"var(--t-text-sm)"},children:[f.provider==="Amazon Bedrock (API Key)"?"Bearer Token":"API Key"," ",!f.hasKey&&e.jsx("span",{style:{color:"var(--t-accent-danger)"},children:"*"})]}),e.jsx(S,{type:"password",value:f.apiKey,onChange:t=>ae(a=>({...a,apiKey:t.target.value,status:null})),placeholder:f.hasKey?"Leave blank to keep existing key":f.provider==="Ollama Cloud"?"API key from ollama.com/settings/keys":f.provider==="Amazon Bedrock (API Key)"?"bedrock-api-key-…":f.provider==="Amazon Bedrock"?"AKIAXXXXXXXX:secretAccessKey":"Paste API key…",style:{fontFamily:"monospace",fontSize:"var(--t-text-base)"}}),f.hasKey&&e.jsx("p",{style:{margin:"2px 0 0",fontSize:"var(--t-text-xs)",color:"var(--t-text-muted)"},children:"A key is already stored. Enter a new one to replace it."})]}),f.status&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px",borderRadius:8,background:f.status.ok?"rgba(34,197,94,0.08)":"rgba(229,72,77,0.08)",border:`1px solid ${f.status.ok?"rgba(34,197,94,0.2)":"rgba(229,72,77,0.2)"}`,fontSize:"var(--t-text-base)",color:f.status.ok?"var(--t-accent-success)":"var(--t-accent-danger)"},children:[f.status.ok?e.jsx(ie,{size:15,weight:"fill"}):e.jsx(ue,{size:15,weight:"fill"}),f.status.message]})]})})]}),e.jsxs("div",{style:{padding:"14px 24px",borderTop:"1px solid var(--t-border-subtle)",display:"flex",gap:8,justifyContent:"flex-end"},children:[e.jsx(j,{variant:"outline",onClick:()=>Fe(!1),children:"Close"}),e.jsx(j,{variant:"outline",disabled:f.testing||f.saving||!f.provider.trim()||!f.model.trim()||!st(f),onClick:Yr,children:f.testing?"Testing…":"Test connection"}),e.jsx(j,{disabled:f.testing||f.saving||!f.provider.trim()||!f.model.trim()||!st(f),onClick:_r,children:f.saving?"Saving…":"Save"})]})]})}),Dr&&d&&e.jsx(Bs,{onClose:()=>Rt(!1)})]})}export{_s as AdminSettingsView};
@@ -0,0 +1,8 @@
1
+ import{r as d,j as e}from"./react-D-pHAthU.js";import{z as $e,a4 as Le,U as ae,a6 as te,O as Ee,aa as Ne,j as Fe,L as re,K as le,b as ve,c as be,a1 as Oe,Y as He,s as me,ah as Be,h as je,V as ke,x as Pe,q as Ye,W as Ue}from"./icons-J9gKYxTz.js";import{b as M,S as q}from"./index-a9kCDHqT.js";import{P as Je,A as Ke,M as Se}from"./hooks-BM-wcPhm.js";function _e({tc:t}){const[n,r]=d.useState(!0),a=i=>{switch(i){case"Given":return"var(--t-accent-primary)";case"When":return"#f59e0b";case"Then":return"var(--t-accent-success)";default:return"var(--t-text-muted)"}};return e.jsxs("div",{style:{border:"1px solid var(--t-border-subtle)",borderRadius:8,overflow:"hidden"},children:[e.jsxs("button",{onClick:()=>r(i=>!i),style:{width:"100%",display:"flex",alignItems:"center",gap:8,padding:"10px 14px",background:"var(--t-bg-surface)",border:"none",cursor:"pointer",textAlign:"left"},children:[n?e.jsx(re,{size:12,weight:"bold",style:{flexShrink:0,color:"var(--t-text-muted)"}}):e.jsx(le,{size:12,weight:"bold",style:{flexShrink:0,color:"var(--t-text-muted)"}}),e.jsx("span",{style:{flex:1,fontSize:"var(--t-text-sm)",fontWeight:600,color:"var(--t-text-primary)"},children:t.title}),e.jsx("span",{style:{fontSize:10,fontWeight:600,padding:"1px 6px",borderRadius:4,background:t.priority==="High"?"rgba(239,68,68,0.1)":t.priority==="Medium"?"rgba(245,158,11,0.1)":"rgba(96,165,250,0.1)",color:t.priority==="High"?"#ef4444":t.priority==="Medium"?"#f59e0b":"#60a5fa",flexShrink:0},children:t.priority})]}),n&&e.jsxs("div",{style:{padding:"10px 14px",display:"flex",flexDirection:"column",gap:6,background:"var(--t-bg-base)"},children:[t.feature&&e.jsxs("p",{style:{margin:0,fontSize:11,color:"var(--t-text-muted)",fontStyle:"italic"},children:["Feature: ",t.feature]}),t.preconditions&&e.jsxs("p",{style:{margin:0,fontSize:11,color:"var(--t-text-muted)"},children:["Preconditions: ",t.preconditions]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:3,marginTop:4},children:t.steps.map((i,p)=>e.jsxs("div",{style:{display:"flex",gap:8,alignItems:"flex-start"},children:[e.jsx("span",{style:{fontSize:10,fontWeight:700,minWidth:42,paddingTop:1,color:a(i.type),flexShrink:0},children:i.type}),e.jsx("span",{style:{fontSize:"var(--t-text-sm)",color:"var(--t-text-secondary)",lineHeight:1.5},children:i.text})]},p))})]})]})}function qe({tc:t}){const[n,r]=d.useState(!0);return e.jsxs("div",{style:{border:"1px solid var(--t-border-subtle)",borderRadius:8,overflow:"hidden"},children:[e.jsxs("button",{onClick:()=>r(a=>!a),style:{width:"100%",display:"flex",alignItems:"center",gap:8,padding:"10px 14px",background:"var(--t-bg-surface)",border:"none",cursor:"pointer",textAlign:"left"},children:[n?e.jsx(re,{size:12,weight:"bold",style:{flexShrink:0,color:"var(--t-text-muted)"}}):e.jsx(le,{size:12,weight:"bold",style:{flexShrink:0,color:"var(--t-text-muted)"}}),e.jsx("span",{style:{flex:1,fontSize:"var(--t-text-sm)",fontWeight:600,color:"var(--t-text-primary)"},children:t.title}),e.jsx("span",{style:{fontSize:10,fontWeight:600,padding:"1px 6px",borderRadius:4,background:t.priority==="High"?"rgba(239,68,68,0.1)":t.priority==="Medium"?"rgba(245,158,11,0.1)":"rgba(96,165,250,0.1)",color:t.priority==="High"?"#ef4444":t.priority==="Medium"?"#f59e0b":"#60a5fa",flexShrink:0},children:t.priority})]}),n&&e.jsxs("div",{style:{padding:"0 0 10px",background:"var(--t-bg-base)"},children:[t.preconditions&&e.jsxs("p",{style:{margin:"0 14px 8px",fontSize:11,color:"var(--t-text-muted)",fontStyle:"italic"},children:["Preconditions: ",t.preconditions]}),e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:"var(--t-text-sm)"},children:[e.jsx("thead",{children:e.jsxs("tr",{style:{borderBottom:"1px solid var(--t-border-subtle)",background:"var(--t-bg-panel)"},children:[e.jsx("th",{style:{padding:"5px 14px",textAlign:"left",fontSize:10,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.05em",color:"var(--t-text-muted)",width:36},children:"#"}),e.jsx("th",{style:{padding:"5px 14px",textAlign:"left",fontSize:10,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.05em",color:"var(--t-text-muted)"},children:"Action"}),e.jsx("th",{style:{padding:"5px 14px",textAlign:"left",fontSize:10,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.05em",color:"var(--t-text-muted)"},children:"Expected Result"})]})}),e.jsx("tbody",{children:t.steps.map((a,i)=>e.jsxs("tr",{style:{borderBottom:"1px solid var(--t-border-subtle)"},children:[e.jsx("td",{style:{padding:"6px 14px",color:"var(--t-text-muted)",fontSize:11},children:i+1}),e.jsx("td",{style:{padding:"6px 14px",color:"var(--t-text-secondary)"},children:a.action}),e.jsx("td",{style:{padding:"6px 14px",color:"var(--t-text-muted)"},children:a.expectedResult})]},i))})]})]})]})}function Ge({appId:t,onClose:n,onSave:r,saving:a}){const[i,p]=d.useState([]),[u,L]=d.useState(!0),[b,H]=d.useState(null),[T,S]=d.useState("pick"),[c,I]=d.useState(""),[h,w]=d.useState(!1),[R,o]=d.useState("");d.useEffect(()=>{M.spaces.list(t).then(l=>{p(l),l.length&&H(l[0].id)}).catch(()=>{}).finally(()=>L(!1))},[t]);async function x(){if(c.trim()){w(!0),o("");try{const l=await M.spaces.create(t,{name:c.trim()});r(l.id,l.name)}catch(l){o(l.message||"Failed to create space"),w(!1)}}}function z(){if(!b)return;const l=i.find(N=>N.id===b);l&&r(l.id,l.name)}return e.jsx("div",{style:{position:"fixed",inset:0,zIndex:1e3,background:"rgba(0,0,0,0.5)",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsxs("div",{style:{background:"var(--t-bg-elevated)",border:"1px solid var(--t-border-subtle)",borderRadius:12,padding:24,width:420,maxWidth:"90vw",display:"flex",flexDirection:"column",gap:16},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("p",{style:{margin:0,fontSize:"var(--t-text-sm)",fontWeight:700,color:"var(--t-text-primary)"},children:"Save test cases to a space"}),e.jsx("button",{onClick:n,style:{background:"none",border:"none",cursor:"pointer",color:"var(--t-text-muted)",display:"flex"},children:e.jsx(ve,{size:16})})]}),e.jsx("div",{style:{display:"flex",gap:4,background:"var(--t-bg-surface)",borderRadius:8,padding:3},children:["pick","create"].map(l=>e.jsx("button",{onClick:()=>S(l),style:{flex:1,padding:"5px 10px",borderRadius:6,border:"none",cursor:"pointer",fontSize:"var(--t-text-sm)",fontWeight:500,background:T===l?"var(--t-bg-elevated)":"transparent",color:T===l?"var(--t-text-primary)":"var(--t-text-muted)",boxShadow:T===l?"0 1px 3px rgba(0,0,0,0.1)":"none"},children:l==="pick"?"Choose existing":"Create new"},l))}),T==="pick"?e.jsxs(e.Fragment,{children:[u?e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:20},children:e.jsx(te,{size:18,style:{color:"var(--t-text-muted)"},className:"spin"})}):i.length===0?e.jsx("div",{style:{textAlign:"center",color:"var(--t-text-muted)",fontSize:"var(--t-text-sm)",padding:"12px 0"},children:"No spaces yet. Create one first."}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4,maxHeight:240,overflowY:"auto"},children:i.map(l=>e.jsxs("button",{onClick:()=>H(l.id),style:{display:"flex",alignItems:"center",gap:10,padding:"10px 12px",borderRadius:8,border:`1px solid ${b===l.id?"var(--t-accent-primary)":"var(--t-border-subtle)"}`,background:b===l.id?"var(--t-accent-primary-subtle)":"var(--t-bg-surface)",cursor:"pointer",textAlign:"left"},children:[e.jsx("div",{style:{width:8,height:8,borderRadius:"50%",flexShrink:0,background:b===l.id?"var(--t-accent-primary)":"var(--t-border-default)"}}),e.jsx("span",{style:{fontSize:"var(--t-text-sm)",color:"var(--t-text-primary)",fontWeight:b===l.id?600:400},children:l.name})]},l.id))}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx("button",{onClick:n,style:{padding:"7px 14px",borderRadius:6,border:"1px solid var(--t-border-subtle)",background:"transparent",cursor:"pointer",fontSize:"var(--t-text-sm)",color:"var(--t-text-muted)"},children:"Cancel"}),e.jsx("button",{onClick:z,disabled:!b||a,style:{padding:"7px 14px",borderRadius:6,border:"none",background:b?"var(--t-accent-primary)":"var(--t-border-subtle)",color:b?"#fff":"var(--t-text-muted)",cursor:!b||a?"default":"pointer",fontSize:"var(--t-text-sm)",fontWeight:600,display:"flex",alignItems:"center",gap:6},children:a?e.jsxs(e.Fragment,{children:[e.jsx(te,{size:12,className:"spin"})," Saving…"]}):"Save here"})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[e.jsx("label",{style:{fontSize:"var(--t-text-sm)",fontWeight:600,color:"var(--t-text-secondary)"},children:"Space name"}),e.jsx("input",{value:c,onChange:l=>I(l.target.value),onKeyDown:l=>{l.key==="Enter"&&x()},placeholder:"e.g. SP-1234 Test Cases",style:{padding:"8px 12px",borderRadius:6,border:"1px solid var(--t-border-default)",background:"var(--t-bg-surface)",color:"var(--t-text-primary)",fontSize:"var(--t-text-sm)",outline:"none",width:"100%",boxSizing:"border-box"}}),R&&e.jsx("p",{style:{margin:0,fontSize:11,color:"var(--t-accent-danger)"},children:R})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx("button",{onClick:n,style:{padding:"7px 14px",borderRadius:6,border:"1px solid var(--t-border-subtle)",background:"transparent",cursor:"pointer",fontSize:"var(--t-text-sm)",color:"var(--t-text-muted)"},children:"Cancel"}),e.jsx("button",{onClick:x,disabled:!c.trim()||h,style:{padding:"7px 14px",borderRadius:6,border:"none",background:c.trim()?"var(--t-accent-primary)":"var(--t-border-subtle)",color:c.trim()?"#fff":"var(--t-text-muted)",cursor:!c.trim()||h?"default":"pointer",fontSize:"var(--t-text-sm)",fontWeight:600,display:"flex",alignItems:"center",gap:6},children:h?e.jsxs(e.Fragment,{children:[e.jsx(te,{size:12,className:"spin"})," Creating…"]}):e.jsxs(e.Fragment,{children:[e.jsx(be,{size:12,weight:"bold"})," Create & Save"]})})]})]})]})})}function Ve({data:t,appId:n}){const[r,a]=d.useState("idle"),[i,p]=d.useState(!1),[u,L]=d.useState(null);async function b(T,S){a("saving");try{const c=await M.folders.create(T,{name:t.ticketId});for(const I of t.testCases)if(I.type==="bdd"){const h=I,w=await M.tests.create(c.id,{type:"bdd",title:h.title,preconditions:h.preconditions,priority:h.priority,createdBy:"AI"}),R=await M.tests.scenarios.create(c.id,w.id,{feature:h.feature,scenario:h.title});for(const[o,x]of h.steps.entries())await M.tests.scenarios.steps.create(c.id,w.id,R.id,{type:x.type.toLowerCase(),text:x.text,order:o})}else{const h=I,w=await M.tests.create(c.id,{type:"traditional",title:h.title,preconditions:h.preconditions,priority:h.priority,createdBy:"AI"});for(const[R,o]of h.steps.entries())await M.tests.steps.create(c.id,w.id,{action:o.action,expectedResult:o.expectedResult,order:R})}L(S),a("saved"),p(!1)}catch{a("error"),setTimeout(()=>a("idle"),3e3)}}const H=e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:10,flexWrap:"wrap"},children:[e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("p",{style:{margin:"0 0 4px",fontSize:10,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.07em",color:"var(--t-text-muted)"},children:[t.testFormat==="bdd"?"BDD Test Cases":"Traditional Test Cases"," ·"," ",t.testCases.length," scenario",t.testCases.length!==1?"s":""]}),e.jsx("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:e.jsx("code",{style:{fontSize:13,fontWeight:700,color:"var(--t-text-primary)",fontFamily:"monospace"},children:t.ticketId})}),t.ticketSummary&&t.ticketSummary!==t.ticketId&&e.jsx("p",{style:{margin:"4px 0 0",fontSize:"var(--t-text-sm)",color:"var(--t-text-secondary)",lineHeight:1.4},children:t.ticketSummary}),(t.repoName||t.mrPrUrl)&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,flexWrap:"wrap",marginTop:6,fontSize:12,color:"var(--t-text-muted)"},children:[t.repoName&&e.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[e.jsx($e,{size:11})," ",t.repoName]}),t.mrPrUrl&&e.jsxs("a",{href:t.mrPrUrl,target:"_blank",rel:"noreferrer",style:{display:"flex",alignItems:"center",gap:4,color:"var(--t-accent-primary)",textDecoration:"none"},children:[e.jsx(Le,{size:11})," MR/PR"]})]}),u&&e.jsxs("p",{style:{margin:"4px 0 0",fontSize:11,color:"var(--t-accent-success)",display:"flex",alignItems:"center",gap:4},children:[e.jsx(ae,{size:11,weight:"fill"})," Saved to ",e.jsx("strong",{children:u})]})]}),n&&e.jsx("button",{onClick:()=>{r==="saving"||r==="saved"||p(!0)},disabled:r==="saving"||r==="saved",title:r==="saved"?`Saved to ${u}`:"Save test cases to a space",style:{display:"flex",alignItems:"center",gap:5,padding:"0 10px",height:28,borderRadius:6,fontSize:11,fontWeight:500,flexShrink:0,cursor:r==="saving"||r==="saved"?"default":"pointer",background:r==="saved"?"rgba(22,163,74,0.08)":r==="error"?"rgba(220,38,38,0.08)":"transparent",border:`1px solid ${r==="error"?"var(--t-accent-danger)":r==="saved"?"var(--t-accent-success)":"var(--t-border-subtle)"}`,color:r==="saved"?"var(--t-accent-success)":r==="error"?"var(--t-accent-danger)":"var(--t-text-muted)"},children:r==="saved"?e.jsxs(e.Fragment,{children:[e.jsx(ae,{size:12,weight:"fill"})," Saved"]}):r==="saving"?e.jsxs(e.Fragment,{children:[e.jsx(te,{size:12,className:"spin"})," Saving"]}):r==="error"?e.jsxs(e.Fragment,{children:[e.jsx(Ee,{size:12})," Failed"]}):e.jsxs(e.Fragment,{children:[e.jsx(Ne,{size:12,weight:"bold"})," Save"]})})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:t.testCases.map((T,S)=>T.type==="bdd"?e.jsx(_e,{tc:T},S):e.jsx(qe,{tc:T},S))})]});return e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",gap:10,alignItems:"flex-start"},children:[e.jsx("div",{style:{width:26,height:26,borderRadius:"50%",background:"var(--t-text-primary)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,alignSelf:"flex-start",marginTop:2},children:e.jsx(Fe,{size:13,weight:"fill",style:{color:"var(--t-bg-base)"}})}),e.jsx("div",{style:{flex:1,background:"var(--t-bg-elevated)",border:"1px solid var(--t-border-subtle)",borderRadius:"4px 14px 14px 14px",padding:"14px 16px",minWidth:0},children:H})]}),i&&n&&e.jsx(Ge,{appId:n,onClose:()=>p(!1),onSave:b,saving:r==="saving"})]})}const O=new Map;function bt(){return O.size}function mt(){O.clear()}function oe(t,n){return`noob-sdet:chat:active:${t}:${n}`}function Qe(t,n){try{const r=localStorage.getItem(oe(t,n));return r?JSON.parse(r).conversationId??null:null}catch{return null}}function ee(t,n,r){try{r?localStorage.setItem(oe(t,n),JSON.stringify({conversationId:r})):localStorage.removeItem(oe(t,n))}catch{}}function we(t){const n=[];for(const r of t.messages){const a=r.id;if(r.role==="user"){n.push({id:a,role:"user",content:r.content});continue}if(r.messageType==="text"||r.messageType==="error"){n.push({id:a,role:"assistant",kind:r.messageType,content:r.content,label:r.label??void 0});continue}if(r.structuredData)try{const i=JSON.parse(r.structuredData);r.messageType==="structured-plan"?n.push({id:a,role:"assistant",kind:"structured-plan",data:i,label:r.label??void 0}):r.messageType==="structured-testcases"?n.push({id:a,role:"assistant",kind:"structured-testcases",data:i,label:r.label??void 0}):r.messageType==="structured-analysis"?n.push({id:a,role:"assistant",kind:"structured-analysis",data:i,label:r.label??void 0}):r.messageType==="gap-analysis"?n.push({id:a,role:"assistant",kind:"gap-analysis",data:i}):r.messageType==="writer-progress"&&n.push({id:a,role:"assistant",kind:"writer-progress",agentName:i.agentName??"",coverageType:i.coverageType??"",count:i.count??0})}catch{}}return n}class Xe extends d.Component{constructor(n){super(n),this.state={error:null}}static getDerivedStateFromError(n){return{error:n instanceof Error?n.message:String(n)}}componentDidCatch(n,r){}render(){return this.state.error?e.jsxs("div",{style:{margin:"8px 0",padding:"12px 14px",borderRadius:8,background:"color-mix(in srgb, var(--t-accent-danger) 6%, var(--t-bg-elevated))",border:"1px solid color-mix(in srgb, var(--t-accent-danger) 25%, transparent)",display:"flex",flexDirection:"column",gap:6},children:[e.jsx("span",{style:{fontSize:12,fontWeight:600,color:"var(--t-accent-danger)"},children:"Failed to render message"}),e.jsx("span",{style:{fontSize:11,color:"var(--t-text-muted)",fontFamily:"monospace"},children:this.state.error}),e.jsx("button",{onClick:()=>this.setState({error:null}),style:{alignSelf:"flex-start",fontSize:11,padding:"2px 10px",borderRadius:6,border:"1px solid var(--t-border-default)",background:"transparent",cursor:"pointer",color:"var(--t-text-secondary)"},children:"Dismiss"})]}):this.props.children}}function Ze({agentName:t,coverageType:n,count:r}){const a=n.replace(/-/g," ").replace(/\b\w/g,i=>i.toUpperCase());return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"8px 14px",borderRadius:8,background:"var(--t-bg-surface)",border:"1px solid var(--t-border-subtle)",fontSize:"var(--t-text-sm)",color:"var(--t-text-secondary)"},children:[e.jsx("span",{style:{fontSize:16},children:"✓"}),e.jsxs("span",{children:[e.jsx("strong",{style:{color:"var(--t-text-primary)"},children:t})," — generated ",e.jsx("strong",{style:{color:"var(--t-accent-primary)"},children:r}),` ${a} test case${r!==1?"s":""}`]})]})}function et({data:t}){return e.jsxs("div",{style:{borderRadius:10,border:"1px solid var(--t-border-subtle)",overflow:"hidden",fontSize:"var(--t-text-sm)"},children:[e.jsxs("div",{style:{padding:"10px 14px",background:"var(--t-bg-surface)",borderBottom:"1px solid var(--t-border-subtle)",display:"flex",alignItems:"center",gap:8},children:[e.jsxs("span",{style:{fontWeight:700,color:"var(--t-text-primary)"},children:["Gap Analysis — ",t.ticketId]}),e.jsxs("span",{style:{marginLeft:"auto",fontSize:10,fontWeight:700,padding:"2px 8px",borderRadius:4,background:"var(--t-accent-primary-subtle)",color:"var(--t-accent-primary)"},children:[t.totalTestCases," tests saved"]})]}),e.jsxs("div",{style:{padding:"12px 14px",display:"flex",flexDirection:"column",gap:10,background:"var(--t-bg-base)"},children:[t.coveredACs.length>0&&e.jsxs("div",{children:[e.jsxs("p",{style:{margin:"0 0 4px",fontWeight:600,color:"var(--t-accent-success)",fontSize:11,textTransform:"uppercase",letterSpacing:"0.05em"},children:["Covered (",t.coveredACs.length,")"]}),e.jsx("ul",{style:{margin:0,paddingLeft:16,display:"flex",flexDirection:"column",gap:2},children:t.coveredACs.map((n,r)=>e.jsx("li",{style:{color:"var(--t-text-secondary)"},children:n},r))})]}),t.uncoveredACs.length>0&&e.jsxs("div",{children:[e.jsxs("p",{style:{margin:"0 0 4px",fontWeight:600,color:"var(--t-accent-danger)",fontSize:11,textTransform:"uppercase",letterSpacing:"0.05em"},children:["Needs Manual Review (",t.uncoveredACs.length,")"]}),e.jsx("ul",{style:{margin:0,paddingLeft:16,display:"flex",flexDirection:"column",gap:2},children:t.uncoveredACs.map((n,r)=>e.jsx("li",{style:{color:"var(--t-text-secondary)"},children:n},r))})]}),t.recommendations.length>0&&e.jsxs("div",{children:[e.jsx("p",{style:{margin:"0 0 4px",fontWeight:600,color:"var(--t-text-muted)",fontSize:11,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Recommendations"}),e.jsx("ul",{style:{margin:0,paddingLeft:16,display:"flex",flexDirection:"column",gap:2},children:t.recommendations.map((n,r)=>e.jsx("li",{style:{color:"var(--t-text-secondary)"},children:n},r))})]})]})]})}function E(){return Math.random().toString(36).slice(2)}function tt({status:t}){return t==="done"?e.jsx(ae,{size:14,weight:"fill",color:"var(--t-accent-success)"}):t==="error"?e.jsx(je,{size:14,weight:"fill",color:"var(--t-accent-danger)"}):t==="running"?e.jsx(ke,{size:14,color:"var(--t-text-muted)",style:{animation:"spin 1s linear infinite"}}):e.jsx(Ue,{size:14,color:"var(--t-border-default)"})}function ze(){return e.jsx("div",{style:{width:26,height:26,borderRadius:"50%",background:"var(--t-text-primary)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,alignSelf:"flex-start",marginTop:2},children:e.jsx(me,{size:13,color:"var(--t-bg-base)",weight:"fill"})})}function rt({content:t}){return e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx("div",{style:{maxWidth:"72%",background:"var(--t-text-primary)",color:"var(--t-bg-base)",borderRadius:"14px 14px 4px 14px",padding:"10px 14px",fontSize:"var(--t-text-base)",lineHeight:1.5,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:t})})}function de({label:t,children:n}){return e.jsxs("div",{style:{display:"flex",gap:10,alignItems:"flex-start"},children:[e.jsx(ze,{}),e.jsxs("div",{style:{flex:1,background:"var(--t-bg-elevated)",border:"1px solid var(--t-border-subtle)",borderRadius:"4px 14px 14px 14px",padding:"12px 14px",minWidth:0},children:[t&&e.jsx("p",{style:{margin:"0 0 8px",fontSize:10,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.07em",color:"var(--t-text-muted)"},children:t}),n]})]})}function nt({content:t,label:n}){return e.jsx(de,{label:n,children:e.jsx(Se,{content:t})})}function st(t){var r;const n=t.indexOf("{");if(n!==-1)try{const a=JSON.parse(t.slice(n)),i=((r=a.error)==null?void 0:r.message)??a.message;if(typeof i=="string"){const p=t.slice(0,n).replace(/:\s*$/,"").trim();return p?`${p}: ${i}`:i}}catch{}return t}function it({content:t,label:n}){return e.jsxs("div",{style:{display:"flex",gap:10,alignItems:"flex-start"},children:[e.jsx(ze,{}),e.jsxs("div",{style:{flex:1,background:"color-mix(in srgb, var(--t-accent-danger) 8%, var(--t-bg-elevated))",border:"1px solid color-mix(in srgb, var(--t-accent-danger) 30%, transparent)",borderRadius:"4px 14px 14px 14px",padding:"12px 14px",minWidth:0},children:[n&&e.jsx("p",{style:{margin:"0 0 8px",fontSize:10,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.07em",color:"var(--t-text-muted)"},children:n}),e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:8},children:[e.jsx(je,{size:16,weight:"fill",color:"var(--t-accent-danger)",style:{flexShrink:0,marginTop:1}}),e.jsx("span",{style:{fontSize:"var(--t-text-sm)",color:"var(--t-accent-danger)",lineHeight:1.55,wordBreak:"break-word"},children:t})]})]})]})}function at(){return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx("div",{style:{display:"flex",gap:4},children:[0,1,2].map(t=>e.jsx("div",{style:{width:6,height:6,borderRadius:"50%",background:"var(--t-text-muted)",animation:"thinkPulse 1.4s ease-in-out infinite",animationDelay:`${t*.22}s`}},t))}),e.jsx("span",{style:{fontSize:11,color:"var(--t-text-muted)",letterSpacing:"0.03em"},children:"Thinking…"})]})}function ot({label:t,content:n}){return e.jsxs(de,{label:t,children:[e.jsx(at,{}),n&&e.jsx("div",{style:{marginTop:10,paddingTop:10,borderTop:"1px solid var(--t-border-subtle)",opacity:.75},children:e.jsx(Se,{content:n,style:{fontSize:"0.78rem",lineHeight:1.55}})})]})}function lt({steps:t}){const[n,r]=d.useState(!0),a=t.every(u=>u.status==="done"||u.status==="error"),i=t.find(u=>u.status==="running"),p=t.filter(u=>u.status==="done").length;return e.jsxs("div",{style:{display:"flex",gap:10,alignItems:"flex-start"},children:[e.jsx("div",{style:{width:26,flexShrink:0}}),e.jsxs("div",{style:{flex:1,border:"1px solid var(--t-border-subtle)",borderRadius:8,overflow:"hidden",background:"var(--t-bg-surface)"},children:[e.jsxs("button",{onClick:()=>r(u=>!u),style:{width:"100%",display:"flex",alignItems:"center",gap:8,padding:"9px 12px",background:"none",border:"none",cursor:"pointer",color:"var(--t-text-secondary)",fontSize:"var(--t-text-sm)"},children:[n?e.jsx(re,{size:11}):e.jsx(le,{size:11}),e.jsx("span",{style:{flex:1,textAlign:"left",fontWeight:500},children:a?`${p} step${p!==1?"s":""} completed`:i?i.label:"Agent steps"}),!a&&e.jsx(ke,{size:12,style:{animation:"spin 1s linear infinite",flexShrink:0},color:"var(--t-text-muted)"})]}),n&&e.jsx("div",{style:{borderTop:"1px solid var(--t-border-subtle)",padding:"6px 0"},children:t.map(u=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"5px 14px",opacity:u.status==="pending"?.45:1,transition:"opacity 0.2s"},children:[e.jsx(tt,{status:u.status}),e.jsx("span",{style:{fontSize:"var(--t-text-sm)",color:u.status==="running"?"var(--t-text-primary)":u.status==="done"?"var(--t-text-secondary)":"var(--t-text-muted)",fontWeight:u.status==="running"?500:400},children:u.label}),u.detail&&e.jsxs("span",{style:{fontSize:"var(--t-text-xs)",color:"var(--t-text-muted)"},children:["— ",u.detail]})]},u.id))})]})]})}function dt({content:t}){return e.jsx(de,{label:"Output",children:e.jsx("p",{style:{margin:0,fontSize:"var(--t-text-base)",color:"var(--t-text-primary)",lineHeight:1.6,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:t})})}function ct(){const t=[{side:"assistant",widths:["72%","55%"]},{side:"user",widths:["48%"]},{side:"assistant",widths:["80%","60%","40%"]},{side:"user",widths:["35%"]},{side:"assistant",widths:["65%","45%"]}];return e.jsx("div",{style:{flex:1,overflowY:"auto",padding:"28px 0",display:"flex",flexDirection:"column",gap:20},children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:20,maxWidth:760,width:"100%",margin:"0 auto",padding:"0 24px"},children:t.map((n,r)=>n.side==="assistant"?e.jsxs("div",{style:{display:"flex",gap:10,alignItems:"flex-start"},children:[e.jsx(q,{width:26,height:26,borderRadius:"50%",style:{flexShrink:0,marginTop:2}}),e.jsx("div",{style:{flex:1,background:"var(--t-bg-elevated)",border:"1px solid var(--t-border-subtle)",borderRadius:"4px 14px 14px 14px",padding:"12px 14px",display:"flex",flexDirection:"column",gap:7},children:n.widths.map((a,i)=>e.jsx(q,{height:12,width:a,borderRadius:4},i))})]},r):e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:7,alignItems:"flex-end",maxWidth:"72%"},children:n.widths.map((a,i)=>e.jsx(q,{height:36,width:a,borderRadius:10},i))})},r))})})}function xt(){return e.jsx("div",{style:{padding:"8px 0"},children:[{count:2},{count:3}].map((t,n)=>e.jsxs("div",{style:{marginBottom:4},children:[e.jsx("div",{style:{padding:"10px 14px 6px"},children:e.jsx(q,{height:10,width:60,borderRadius:3})}),Array.from({length:t.count}).map((r,a)=>e.jsxs("div",{style:{padding:"8px 14px",display:"flex",flexDirection:"column",gap:5},children:[e.jsx(q,{height:12,width:`${55+a*19%30}%`,borderRadius:3}),e.jsx(q,{height:10,width:`${70+a*11%20}%`,borderRadius:3}),e.jsx(q,{height:9,width:40,borderRadius:3})]},a))]},n))})}function pt(t){const r=Date.now()-new Date(t).getTime(),a=Math.floor(r/6e4);if(a<2)return"Just now";if(a<60)return`${a}m ago`;const i=Math.floor(r/36e5);if(i<24)return`${i}h ago`;const p=Math.floor(r/864e5);return p===1?"Yesterday":p<7?`${p} days ago`:new Date(t).toLocaleDateString(void 0,{month:"short",day:"numeric"})}function ut(t){const r=Date.now()-new Date(t).getTime(),a=Math.floor(r/864e5);return a===0?"Today":a===1?"Yesterday":a<7?"Last 7 days":a<30?"Last 30 days":"Older"}function gt({onClose:t,appId:n,activeConversationId:r,onNewConversation:a,onLoadConversation:i}){const[p,u]=d.useState(!0),[L,b]=d.useState([]),[H,T]=d.useState(null),[S,c]=d.useState(null);d.useEffect(()=>{if(!n){u(!1);return}M.conversations.list(n).then(o=>{b(o),u(!1)}).catch(()=>u(!1))},[n]);const I=async o=>{if(!(o===r||H)){if(O.has(o)){i(o,O.get(o)),t();return}if(n){T(o);try{const x=await M.conversations.get(n,o),z=we(x);i(o,z),t()}catch{}finally{T(null)}}}},h=async(o,x)=>{if(o.stopPropagation(),!(!n||S)){c(x);try{await M.conversations.delete(n,x),b(z=>z.filter(l=>l.id!==x)),O.delete(x),x===r&&a()}catch{}finally{c(null)}}},w=["Today","Yesterday","Last 7 days","Last 30 days","Older"],R={};for(const o of L){const x=ut(o.updatedAt);R[x]||(R[x]=[]),R[x].push(o)}return e.jsxs("div",{style:{width:320,flexShrink:0,borderLeft:"1px solid var(--t-border-subtle)",background:"var(--t-bg-surface)",display:"flex",flexDirection:"column",overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"0 10px 0 14px",height:52,borderBottom:"1px solid var(--t-border-subtle)",flexShrink:0},children:[e.jsx(Pe,{size:14,color:"var(--t-text-muted)"}),e.jsx("span",{style:{flex:1,fontSize:"var(--t-text-base)",fontWeight:500,color:"var(--t-text-primary)"},children:"History"}),e.jsx("button",{onClick:()=>{a(),t()},title:"New conversation",style:{width:26,height:26,border:"none",borderRadius:6,background:"transparent",color:"var(--t-text-muted)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},onMouseEnter:o=>{o.currentTarget.style.background="var(--t-bg-elevated)",o.currentTarget.style.color="var(--t-text-secondary)"},onMouseLeave:o=>{o.currentTarget.style.background="transparent",o.currentTarget.style.color="var(--t-text-muted)"},children:e.jsx(be,{size:13})}),e.jsx("button",{onClick:t,title:"Close history",style:{width:26,height:26,border:"none",borderRadius:6,background:"transparent",color:"var(--t-text-muted)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},onMouseEnter:o=>{o.currentTarget.style.background="var(--t-bg-elevated)",o.currentTarget.style.color="var(--t-text-secondary)"},onMouseLeave:o=>{o.currentTarget.style.background="transparent",o.currentTarget.style.color="var(--t-text-muted)"},children:e.jsx(ve,{size:13})})]}),e.jsx("div",{style:{flex:1,overflowY:"auto",padding:"8px 0"},children:p?e.jsx(xt,{}):L.length===0?e.jsx("div",{style:{padding:"32px 16px",textAlign:"center"},children:e.jsx("p",{style:{margin:0,fontSize:"var(--t-text-sm)",color:"var(--t-text-muted)"},children:"No conversations yet"})}):w.filter(o=>{var x;return(x=R[o])==null?void 0:x.length}).map(o=>e.jsxs("div",{children:[e.jsx("p",{style:{margin:0,padding:"10px 14px 4px",fontSize:11,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em",color:"var(--t-text-muted)"},children:o}),R[o].map(x=>{const z=r===x.id,l=H===x.id,N=S===x.id;return e.jsxs("div",{style:{position:"relative",display:"flex",alignItems:"center"},onMouseEnter:D=>{const B=D.currentTarget.querySelector("[data-del]");B&&(B.style.opacity="1")},onMouseLeave:D=>{const B=D.currentTarget.querySelector("[data-del]");B&&(B.style.opacity="0")},children:[e.jsxs("button",{onClick:()=>void I(x.id),disabled:l||N,style:{flex:1,textAlign:"left",padding:"8px 36px 8px 14px",border:"none",background:z?"var(--t-bg-elevated)":"transparent",cursor:l?"wait":"pointer",borderLeft:z?"2px solid var(--t-border-strong)":"2px solid transparent",transition:"background 0.1s",opacity:N?.4:1},onMouseEnter:D=>{z||(D.currentTarget.style.background="var(--t-bg-panel)")},onMouseLeave:D=>{z||(D.currentTarget.style.background="transparent")},children:[e.jsx("p",{style:{margin:"0 0 2px",fontSize:"var(--t-text-base)",fontWeight:500,color:"var(--t-text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:x.title}),e.jsxs("p",{style:{margin:0,fontSize:11,color:"var(--t-text-muted)",opacity:.75},children:[pt(x.updatedAt),x.messageCount!=null?` · ${x.messageCount} msg${x.messageCount!==1?"s":""}`:""]})]}),e.jsx("button",{"data-del":!0,onClick:D=>void h(D,x.id),disabled:N,title:"Delete conversation",style:{position:"absolute",right:8,width:22,height:22,border:"none",borderRadius:4,background:"var(--t-bg-elevated)",color:"var(--t-text-muted)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",opacity:0,transition:"opacity 0.1s",flexShrink:0},onMouseEnter:D=>{D.currentTarget.style.color="var(--t-accent-danger)"},onMouseLeave:D=>{D.currentTarget.style.color="var(--t-text-muted)"},children:e.jsx(Ye,{size:11})})]},x.id)})]},o))})]})}function jt({historyOpen:t,onCloseHistory:n,orchestratorId:r,orchestratorName:a,appId:i,userId:p,profiles:u=[],selectedProfileId:L,onProfileChange:b}){const[H,T]=d.useState(!0),[S,c]=d.useState([]),[I,h]=d.useState(""),[w,R]=d.useState(!1),[o,x]=d.useState(!1),[z,l]=d.useState(null),N=d.useRef(null),D=d.useRef(null),B=d.useRef(null),Y=u.find(s=>s.id===L)??null,K=Y!=null&&!Y.isComplete,[F,ne]=d.useState("unknown");d.useEffect(()=>{M.aiConfig.get().then(s=>{s.llm.hasApiKey?ne("ready"):ne("none")}).catch(()=>ne("unknown"))},[]),d.useEffect(()=>{if(!i||!p)return;const s=Qe(p,i);if(s){if(O.has(s)){c(O.get(s)),l(s);return}M.conversations.get(i,s).then(W=>{const X=we(W);O.set(s,X),c(X),l(s)}).catch(()=>{ee(p,i,null)})}},[i,p]),d.useEffect(()=>()=>{var s;(s=B.current)==null||s.abort()},[]),d.useEffect(()=>{const s=setTimeout(()=>T(!1),800);return()=>clearTimeout(s)},[]);const V=d.useCallback(()=>{N.current&&(N.current.scrollTop=N.current.scrollHeight)},[]);d.useEffect(()=>{V()},[S,V]);const ce=d.useCallback(s=>{c(W=>[...W,s])},[]),Q=d.useCallback(()=>{z&&O.set(z,S)},[z,S]),Ce=d.useCallback(()=>{Q(),l(null),c([]),i&&p&&ee(p,i,null)},[Q,i,p]),Te=d.useCallback((s,W)=>{Q(),O.set(s,W),l(s),c(W),i&&p&&ee(p,i,s)},[Q,i,p]),xe=async()=>{var ge,fe;const s=I.trim();if(!s||w||!r)return;R(!0),h(""),ce({id:E(),role:"user",content:s});const W=E();ce({id:W,role:"assistant",kind:"thinking",label:a??void 0});const X=S.filter(g=>g.role==="user"||g.role==="assistant"&&g.kind==="text").map(g=>({role:g.role,content:g.content}));let P=W,_=!0,G=a??void 0,Z=!1,m=W;const We=g=>{const y=E(),A=P,C=G;c($=>$.map(U=>U.id===A?{id:y,role:"assistant",kind:"text",content:g,label:C}:U)),P=y,_=!1,m=null},Ie=g=>{const y=E(),A=G;c(C=>[...C,{id:y,role:"assistant",kind:"text",content:g,label:A}]),P=y,_=!1,Z=!1},pe=()=>{if(!m)return;const g=m;c(y=>y.filter(A=>A.id!==g)),m=null},se=g=>{const y=st(g),A=E(),C=G;if(m){const $=m;c(U=>U.map(J=>J.id===$?{id:A,role:"assistant",kind:"error",content:y,label:C}:J)),m=null}else c($=>[...$,{id:A,role:"assistant",kind:"error",content:y,label:C}]);_=!1},Ae=g=>{const y=E(),A=m??P,C=G,$=g._type;c(U=>U.map(J=>J.id===A?$==="test-plan"?{id:y,role:"assistant",kind:"structured-plan",data:g,label:C}:$==="test-cases"?{id:y,role:"assistant",kind:"structured-testcases",data:g,label:C}:{id:y,role:"assistant",kind:"structured-analysis",data:g,label:C}:J)),m=null,_=!1};(ge=B.current)==null||ge.abort();const ue=new AbortController;B.current=ue;try{const g=await fetch(M.chat.streamUrl(),{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",signal:ue.signal,body:JSON.stringify({message:s,orchestratorId:r,appId:i,history:X,profileId:L??void 0,conversationId:z??void 0})});if(g.ok&&((fe=g.headers.get("content-type"))!=null&&fe.includes("text/event-stream"))){const y=g.body.getReader(),A=new TextDecoder;let C="";for(;;){const{done:$,value:U}=await y.read();if($)break;C+=A.decode(U,{stream:!0});const J=C.split(`
2
+ `);C=J.pop()??"";for(const he of J)if(he.startsWith("data: "))try{const j=JSON.parse(he.slice(6));if(j.structuredData){const v=j.structuredData;if(v._type==="writer-progress"){const k=v;c(f=>[...f,{id:E(),role:"assistant",kind:"writer-progress",agentName:k.agentName,coverageType:k.coverageType,count:k.count}])}else v._type==="gap-analysis"?c(k=>[...k,{id:E(),role:"assistant",kind:"gap-analysis",data:v}]):Ae(v)}else if(j.agentDone){if(m){if(m===P){const v=j.summary??"",k=E(),f=m,ie=G;c(Me=>Me.map(ye=>ye.id===f?{id:k,role:"assistant",kind:"text",content:v,label:ie}:ye)),P=k}else{const v=m;c(k=>k.filter(f=>f.id!==v))}m=null}_=!1,V()}else if(j.done){if(pe(),j.conversationId&&i&&p){const v=j.conversationId;l(v),ee(p,i,v)}}else if(j.error)se(j.error);else if(j.thinkingToken){Z=!0;const v=P;c(k=>k.map(f=>f.id!==v||f.role!=="assistant"||f.kind!=="thinking"?f:{...f,content:(f.content??"")+j.thinkingToken})),V()}else if(j.newMessage){if(m){const k=m;c(f=>f.filter(ie=>ie.id!==k)),m=null}const v=E();G=j.label,Z=!1,m=v,c(k=>[...k,{id:v,role:"assistant",kind:"thinking",label:j.label}]),P=v,_=!0}else if(j.token){if(_)Z?Ie(j.token):We(j.token);else{const v=P;c(k=>k.map(f=>f.id===v&&f.role==="assistant"&&f.kind==="text"?{...f,content:f.content+j.token}:f))}V()}}catch{}}}else{const y=await g.json();if(y.error)se(y.error);else{const A=y.reply??"No response from AI";pe(),c(C=>C.map($=>$.id===W?{id:E(),role:"assistant",kind:"text",content:A,label:a??void 0}:$))}}}catch(g){if((g==null?void 0:g.name)==="AbortError")return;se(`Failed to connect to AI: ${g.message}`)}R(!1)},Re=s=>{s.key==="Enter"&&!s.shiftKey&&(s.preventDefault(),xe())},De=s=>{h(s.target.value);const W=s.target;W.style.height="auto",W.style.height=`${Math.min(W.scrollHeight,140)}px`};return e.jsxs(e.Fragment,{children:[e.jsx("style",{children:`
3
+ @keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
4
+ @keyframes thinkPulse {
5
+ 0%, 80%, 100% { opacity: 0.25; transform: scale(0.75); }
6
+ 40% { opacity: 1; transform: scale(1); }
7
+ }
8
+ `}),e.jsxs("div",{style:{flex:1,overflow:"hidden",display:"flex",flexDirection:"column"},children:[a&&F==="ready"&&e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"8px 0 0",flexShrink:0},children:e.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:5,padding:"3px 10px",borderRadius:20,background:"var(--t-bg-elevated)",border:"1px solid var(--t-border-subtle)",fontSize:11,color:"var(--t-text-muted)"},children:[e.jsx(Oe,{size:11}),a]})}),Y&&!Y.isComplete&&e.jsxs("div",{style:{margin:"12px 16px 0",padding:"10px 14px",borderRadius:8,background:"color-mix(in srgb, var(--t-accent-warning, #f59e0b) 10%, transparent)",border:"1px solid color-mix(in srgb, var(--t-accent-warning, #f59e0b) 35%, transparent)",fontSize:"var(--t-text-sm)",color:"var(--t-text-secondary)",flexShrink:0},children:[e.jsxs("strong",{style:{color:"var(--t-text-primary)"},children:['Profile "',Y.name,'" is incomplete']})," — generate all five knowledge blocks in AI Settings before using this profile for test case generation."]}),F==="none"&&e.jsxs("div",{style:{margin:"12px 16px 0",padding:"10px 14px",borderRadius:8,background:"rgba(229,72,77,0.07)",border:"1px solid rgba(229,72,77,0.25)",display:"flex",alignItems:"center",gap:10,fontSize:"var(--t-text-sm)",color:"var(--t-accent-danger)",flexShrink:0},children:[e.jsx(He,{size:15,weight:"fill",style:{flexShrink:0}}),e.jsxs("span",{children:["AI is not configured. A super admin must set up the LLM in"," ",e.jsx("strong",{children:"Admin Settings → AI Settings"}),"."]})]}),H?e.jsx(ct,{}):e.jsx("div",{ref:N,style:{flex:1,overflowY:"auto",padding:"24px 0",display:"flex",flexDirection:"column"},children:S.length===0?e.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:12,color:"var(--t-text-muted)",padding:"0 24px"},children:[e.jsx("div",{style:{width:48,height:48,borderRadius:"50%",background:"var(--t-bg-panel)",border:"1px solid var(--t-border-subtle)",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(me,{size:22,weight:"duotone",color:"var(--t-text-muted)"})}),e.jsx("p",{style:{margin:0,fontSize:"var(--t-text-lg)",fontWeight:500,color:"var(--t-text-secondary)"},children:"What are we testing today?"}),e.jsx("p",{style:{margin:0,fontSize:"var(--t-text-sm)",color:"var(--t-text-muted)",textAlign:"center",maxWidth:360,lineHeight:1.6},children:"Describe a feature or share a ticket and I'll analyze it, explore the repo and MRs, then generate a test plan and test cases for you."})]}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:16,maxWidth:760,width:"100%",margin:"0 auto",padding:"0 24px"},children:S.map(s=>s.role==="user"?e.jsx(rt,{content:s.content},s.id):e.jsx(Xe,{children:s.kind==="thinking"?e.jsx(ot,{label:s.label,content:s.content}):s.kind==="structured-plan"?e.jsx(Je,{data:s.data,appId:i}):s.kind==="structured-testcases"?e.jsx(Ve,{data:s.data,appId:i}):s.kind==="writer-progress"?e.jsx(Ze,{agentName:s.agentName,coverageType:s.coverageType,count:s.count}):s.kind==="gap-analysis"?e.jsx(et,{data:s.data}):s.kind==="structured-analysis"?e.jsx(Ke,{data:s.data,label:s.label,appId:i}):s.kind==="error"?e.jsx(it,{content:s.content,label:s.label}):s.kind==="text"&&s.content.trim()?e.jsx(nt,{content:s.content,label:s.label}):s.kind==="steps"?e.jsx(lt,{steps:s.steps}):s.kind==="output"?e.jsx(dt,{content:s.content}):null},s.id))})}),e.jsxs("div",{style:{flexShrink:0,padding:"12px 24px 20px",background:"var(--t-bg-base)"},children:[e.jsxs("div",{style:{maxWidth:760,margin:"0 auto",display:"flex",alignItems:"center",gap:8,background:"var(--t-bg-surface)",border:"1px solid var(--t-border-default)",borderRadius:12,padding:"6px 8px 6px 10px",transition:"border-color 0.15s"},onFocusCapture:s=>s.currentTarget.style.borderColor="var(--t-border-strong)",onBlurCapture:s=>s.currentTarget.style.borderColor="var(--t-border-default)",children:[u.length>1&&e.jsxs("div",{style:{position:"relative",flexShrink:0},children:[e.jsxs("button",{title:"Select test case profile",onClick:()=>x(s=>!s),style:{display:"flex",alignItems:"center",gap:4,background:"var(--t-bg-elevated)",border:"1px solid var(--t-border-subtle)",borderRadius:6,padding:"3px 8px",cursor:"pointer",fontSize:11,color:"var(--t-text-muted)",whiteSpace:"nowrap",maxWidth:120,overflow:"hidden",textOverflow:"ellipsis"},children:[e.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis"},children:(Y==null?void 0:Y.name)??"Profile"}),e.jsx(re,{size:10})]}),o&&e.jsx("div",{style:{position:"absolute",bottom:"calc(100% + 6px)",left:0,zIndex:60,background:"var(--t-bg-surface)",border:"1px solid var(--t-border-default)",borderRadius:8,boxShadow:"0 8px 24px rgba(0,0,0,0.14)",minWidth:160,overflow:"hidden"},children:u.map(s=>e.jsxs("button",{onClick:()=>{b==null||b(s.id),x(!1)},style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"7px 11px",border:"none",cursor:"pointer",textAlign:"left",fontSize:"var(--t-text-sm)",color:s.id===L?"var(--t-accent-primary)":"var(--t-text-primary)",background:s.id===L?"var(--t-accent-primary-subtle)":"transparent"},children:[e.jsx("span",{children:s.name}),s.isDefault&&e.jsx("span",{style:{marginLeft:"auto",fontSize:9,color:"var(--t-accent-primary)",fontWeight:700},children:"DEFAULT"})]},s.id))})]}),e.jsx("textarea",{ref:D,value:I,onChange:De,onKeyDown:Re,placeholder:r?K?"Profile incomplete — generate all blocks in AI Settings first…":F==="ready"||F==="unknown"?"Message AI…":"AI is not fully configured…":"No orchestrator selected…",rows:1,disabled:w||F==="none"||!r||K,style:{flex:1,background:"none",border:"none",outline:"none",resize:"none",fontSize:"var(--t-text-base)",color:"var(--t-text-primary)",lineHeight:1.5,padding:0,minHeight:22,maxHeight:140,overflowY:"auto",fontFamily:"inherit",opacity:F==="none"||!r||K?.45:1}}),e.jsx("button",{onClick:()=>void xe(),disabled:!I.trim()||w||F==="none"||!r||K,style:{width:34,height:34,borderRadius:8,border:"none",background:I.trim()&&!w&&F==="ready"&&r&&!K?"var(--t-text-primary)":"var(--t-border-default)",color:I.trim()&&!w&&F==="ready"&&r&&!K?"var(--t-bg-base)":"var(--t-text-muted)",cursor:I.trim()&&!w&&F==="ready"&&r&&!K?"pointer":"default",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,transition:"background 0.15s, color 0.15s"},children:e.jsx(Be,{size:15,weight:"fill"})})]}),e.jsx("p",{style:{margin:"6px 0 0",fontSize:11,color:"var(--t-text-muted)",textAlign:"center"},children:"Enter to send · Shift+Enter for new line"})]})]}),t&&e.jsx(gt,{onClose:n,appId:i,activeConversationId:z,onNewConversation:Ce,onLoadConversation:Te})]})}export{jt as C,mt as c,bt as g};
@@ -0,0 +1 @@
1
+ import{r as c,j as e}from"./react-D-pHAthU.js";import{au as L,J as O,q as A,_ as B,k as K,c as z,l as _}from"./icons-J9gKYxTz.js";import{w as C,a as I,b as W,B as f,C as F,S as v,D as $,E as H,F as P,G as J,L as h,I as b,A as N,H as U}from"./index-a9kCDHqT.js";import"./radix-ui-Cxk3sw_C.js";const Y={open:"Open",in_progress:"In Progress",completed:"Completed",archived:"Archived"},S={open:"#6b7280",in_progress:"#d97706",completed:"#22c55e",archived:"#94a3b8"},G={open:"rgba(107,114,128,0.1)",in_progress:"rgba(217,119,6,0.1)",completed:"rgba(34,197,94,0.1)",archived:"rgba(148,163,184,0.1)"};function R({status:t}){return e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:5,padding:"2px 8px",borderRadius:99,fontSize:"var(--t-text-xs)",fontWeight:500,color:S[t],background:G[t],border:`1px solid ${S[t]}33`,flexShrink:0},children:[e.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:S[t],display:"inline-block",flexShrink:0}}),Y[t]]})}const m={fontSize:"var(--t-text-xs)",fontWeight:600,color:"var(--t-text-muted)",textTransform:"uppercase",letterSpacing:"0.06em"};function M({appId:t,open:n,onClose:l,initial:o,onSave:u,title:g}){const[a,x]=c.useState(o),[s,d]=c.useState(!1);c.useEffect(()=>{n&&x(o)},[n]);const p=(r,y)=>x(j=>({...j,[r]:y}));return e.jsx($,{open:n,onOpenChange:r=>!r&&l(),children:e.jsxs(H,{className:"max-w-125",children:[e.jsx(P,{children:e.jsx(J,{children:g})}),e.jsxs("form",{onSubmit:async r=>{if(r.preventDefault(),!(!a.name.trim()||s)){d(!0);try{await u(a),l()}finally{d(!1)}}},style:{display:"flex",flexDirection:"column",gap:14,marginTop:8},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[e.jsxs(h,{children:["Name ",e.jsx("span",{style:{color:"var(--t-accent-danger, #e5484d)"},children:"*"})]}),e.jsx(b,{value:a.name,onChange:r=>p("name",r.target.value),placeholder:"e.g. v2.0 Release",autoFocus:!0})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[e.jsx(h,{children:"Description"}),e.jsx("textarea",{value:a.description,onChange:r=>p("description",r.target.value),placeholder:"What's included in this milestone?",rows:3,style:{padding:"8px 10px",borderRadius:6,border:"1px solid var(--t-border-default)",background:"var(--t-bg-surface)",color:"var(--t-text-primary)",fontSize:"var(--t-text-base)",outline:"none",width:"100%",boxSizing:"border-box",resize:"vertical",fontFamily:"inherit",lineHeight:"1.5"}})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[e.jsx(h,{children:"Status"}),e.jsxs("select",{value:a.status,onChange:r=>p("status",r.target.value),style:{height:36,padding:"0 8px",borderRadius:6,border:"1px solid var(--t-border-default)",background:"var(--t-bg-surface)",color:"var(--t-text-primary)",fontSize:"var(--t-text-base)",outline:"none",cursor:"pointer",width:"100%"},children:[e.jsx("option",{value:"open",children:"Open"}),e.jsx("option",{value:"in_progress",children:"In Progress"}),e.jsx("option",{value:"completed",children:"Completed"}),e.jsx("option",{value:"archived",children:"Archived"})]})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[e.jsx(h,{children:"Jira Issue Key"}),e.jsx(b,{value:a.jiraIssueKey,onChange:r=>p("jiraIssueKey",r.target.value),placeholder:"e.g. PROJ-123"})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[e.jsx(h,{children:"Reference Document"}),e.jsx(b,{value:a.referenceDoc,onChange:r=>p("referenceDoc",r.target.value),placeholder:"Confluence URL"})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[e.jsx(h,{children:"Assignee"}),e.jsx(N,{appId:t,value:a.assigneeId,onChange:r=>p("assigneeId",r)})]}),e.jsxs(U,{style:{marginTop:4},children:[e.jsx(f,{type:"button",variant:"outline",onClick:l,children:"Cancel"}),e.jsx(f,{type:"submit",disabled:!a.name.trim()||s,children:s?"Saving…":"Save"})]})]})]})})}const V={name:"",description:"",jiraIssueKey:"",referenceDoc:"",assigneeId:null,status:"open"};function se({appId:t,onNavigate:n}){const{milestones:l,loading:o,createMilestone:u}=C(t),{isEditor:g}=I(t),[a,x]=c.useState(!1);return e.jsxs("div",{style:{flex:1,background:"var(--t-bg-base)",display:"flex",flexDirection:"column",overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"0 24px 0 18px",height:48,borderBottom:"1px solid var(--t-border-subtle)",background:"var(--t-bg-elevated)",flexShrink:0},children:[e.jsx("span",{style:{fontSize:"var(--t-text-base)",fontWeight:600,color:"var(--t-text-primary)"},children:"Milestones"}),g&&e.jsxs(f,{onClick:()=>x(!0),variant:"outline",style:{gap:6,height:30,fontSize:"var(--t-text-sm)",padding:"0 12px"},children:[e.jsx(z,{size:13}),"New Milestone"]})]}),e.jsx("div",{style:{flex:1,overflowY:"auto",padding:"16px 24px"},children:o?e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[75,55,65,45,60].map((s,d)=>e.jsxs("div",{style:{padding:"12px 16px",borderRadius:8,border:"1px solid var(--t-border-subtle)",background:"var(--t-bg-surface)",display:"flex",flexDirection:"column",gap:8},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[e.jsx(v,{height:13,width:`${s}%`,borderRadius:4,style:{flex:1}}),e.jsx(v,{width:60,height:20,borderRadius:99})]}),d%2===0&&e.jsx(v,{height:10,width:"50%",borderRadius:3}),e.jsxs("div",{style:{display:"flex",gap:12,alignItems:"center"},children:[e.jsx(v,{width:70,height:9,borderRadius:3}),e.jsx(v,{width:90,height:9,borderRadius:3})]})]},d))}):l.length===0?e.jsxs("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",flexDirection:"column",gap:10,paddingTop:80},children:[e.jsx(_,{size:36,style:{color:"var(--t-text-muted)",opacity:.4}}),e.jsx("p",{style:{fontSize:"var(--t-text-base)",color:"var(--t-text-muted)",fontWeight:500},children:"No milestones yet"}),e.jsx("p",{style:{fontSize:"var(--t-text-sm)",color:"var(--t-text-muted)",opacity:.7},children:"Group test runs into releases or sprints"}),g&&e.jsxs(f,{onClick:()=>x(!0),variant:"outline",style:{marginTop:6,gap:6,height:30,fontSize:"var(--t-text-sm)",padding:"0 14px"},children:[e.jsx(z,{size:13}),"New Milestone"]})]}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:l.map(s=>e.jsx(q,{milestone:s,onClick:()=>n({type:"milestone-detail",appId:t,milestoneId:s.id})},s.id))})}),g&&e.jsx(M,{appId:t,open:a,onClose:()=>x(!1),initial:V,title:"New Milestone",onSave:async s=>{const d=await u({name:s.name.trim(),description:s.description.trim()||void 0,jiraIssueKey:s.jiraIssueKey.trim()||void 0,referenceDoc:s.referenceDoc.trim()||void 0,assigneeId:s.assigneeId||void 0,status:s.status,createdBy:"me"});d&&n({type:"milestone-detail",appId:t,milestoneId:d.id})}})]})}function q({milestone:t,onClick:n}){const[l,o]=c.useState(!1);return e.jsxs("div",{onClick:n,onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),style:{padding:"12px 16px",borderRadius:8,border:"1px solid var(--t-border-default)",background:l?"var(--t-bg-panel)":"var(--t-bg-surface)",cursor:"pointer",transition:"background 0.1s",display:"flex",flexDirection:"column",gap:5},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{fontSize:"var(--t-text-base)",fontWeight:600,color:"var(--t-text-primary)",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.name}),e.jsx(R,{status:t.status})]}),t.description&&e.jsx("p",{style:{fontSize:"var(--t-text-sm)",color:"var(--t-text-secondary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",margin:0},children:t.description}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginTop:2},children:[t.jiraIssueKey&&e.jsx("span",{style:{fontSize:"var(--t-text-xs)",color:"var(--t-text-muted)"},children:t.jiraIssueKey}),t.assigneeId&&e.jsx("span",{style:{fontSize:"var(--t-text-xs)",color:"var(--t-text-muted)"},children:t.assigneeId.replace(/^(user|group):/,"")}),e.jsx("span",{style:{fontSize:"var(--t-text-xs)",color:"var(--t-text-muted)",marginLeft:"auto"},children:new Date(t.createdAt).toLocaleDateString()})]})]})}function ie({appId:t,milestoneId:n,onNavigate:l}){const{milestones:o,updateMilestone:u,removeMilestone:g}=C(t),{isEditor:a,isAdmin:x}=I(t),s=o.find(i=>i.id===n)??null,[d,p]=c.useState([]),[r,y]=c.useState(!1),[j,D]=c.useState(!1),[T,w]=c.useState(!1);if(c.useEffect(()=>{y(!0),W.milestones.runs(t,n).then(p).catch(()=>{}).finally(()=>y(!1))},[t,n]),!s)return e.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",background:"var(--t-bg-base)"},children:e.jsx("p",{style:{fontSize:"var(--t-text-base)",color:"var(--t-text-muted)"},children:"Milestone not found"})});const E={name:s.name,description:s.description??"",jiraIssueKey:s.jiraIssueKey??"",referenceDoc:s.referenceDoc??"",assigneeId:s.assigneeId??null,status:s.status};return e.jsxs("div",{style:{flex:1,background:"var(--t-bg-base)",display:"flex",flexDirection:"column",overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"0 16px 0 12px",height:48,borderBottom:"1px solid var(--t-border-subtle)",background:"var(--t-bg-elevated)",flexShrink:0},children:[e.jsx("button",{onClick:()=>l({type:"milestones",appId:t}),title:"Back to milestones",style:{width:28,height:28,borderRadius:6,border:"none",background:"transparent",color:"var(--t-text-muted)",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",flexShrink:0},onMouseEnter:i=>{i.currentTarget.style.background="var(--t-elem-hover)",i.currentTarget.style.color="var(--t-text-primary)"},onMouseLeave:i=>{i.currentTarget.style.background="transparent",i.currentTarget.style.color="var(--t-text-muted)"},children:e.jsx(L,{size:14})}),e.jsx("span",{style:{fontSize:"var(--t-text-base)",fontWeight:600,color:"var(--t-text-primary)",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:s.name}),e.jsx(R,{status:s.status}),(a||x)&&e.jsxs("div",{style:{display:"flex",gap:6,marginLeft:8},children:[a&&e.jsxs(f,{size:"sm",variant:"outline",onClick:()=>D(!0),style:{gap:5,height:28,fontSize:"var(--t-text-sm)",padding:"0 10px"},children:[e.jsx(O,{size:12}),"Edit"]}),x&&e.jsx(f,{size:"sm",variant:"outline",onClick:()=>w(!0),style:{height:28,width:28,padding:0,color:"var(--t-accent-danger)",borderColor:"transparent"},children:e.jsx(A,{size:13})})]})]}),e.jsxs("div",{style:{flex:1,overflowY:"auto",display:"flex",flexDirection:"column",gap:0},children:[e.jsxs("div",{style:{padding:"20px 24px",borderBottom:"1px solid var(--t-border-subtle)",display:"flex",flexDirection:"column",gap:16},children:[s.description&&e.jsx("p",{style:{fontSize:"var(--t-text-base)",color:"var(--t-text-secondary)",lineHeight:"1.6",margin:0},children:s.description}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(200px, 1fr))",gap:16},children:[s.jiraIssueKey&&e.jsxs("div",{children:[e.jsx("div",{style:{...m,marginBottom:4},children:"Jira Issue"}),e.jsx("span",{style:{fontSize:"var(--t-text-base)",color:"var(--t-text-primary)",fontWeight:500},children:s.jiraIssueKey})]}),s.referenceDoc&&e.jsxs("div",{children:[e.jsx("div",{style:{...m,marginBottom:4},children:"Reference Doc"}),e.jsxs("a",{href:s.referenceDoc,target:"_blank",rel:"noopener noreferrer",style:{fontSize:"var(--t-text-base)",color:"var(--t-text-link, #3b82f6)",display:"inline-flex",alignItems:"center",gap:4,textDecoration:"none"},onMouseEnter:i=>i.currentTarget.style.textDecoration="underline",onMouseLeave:i=>i.currentTarget.style.textDecoration="none",children:["Open link",e.jsx(B,{size:11})]})]}),s.assigneeId&&e.jsxs("div",{children:[e.jsx("div",{style:{...m,marginBottom:4},children:"Assignee"}),e.jsx("span",{style:{fontSize:"var(--t-text-base)",color:"var(--t-text-primary)"},children:s.assigneeId.replace(/^(user|group):/,"")})]}),e.jsxs("div",{children:[e.jsx("div",{style:{...m,marginBottom:4},children:"Created"}),e.jsx("span",{style:{fontSize:"var(--t-text-base)",color:"var(--t-text-secondary)"},children:new Date(s.createdAt).toLocaleDateString()})]})]})]}),e.jsxs("div",{style:{padding:"16px 24px",display:"flex",flexDirection:"column",gap:10},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(K,{size:13,style:{color:"var(--t-text-muted)"}}),e.jsxs("span",{style:{fontSize:12,fontWeight:600,color:"var(--t-text-muted)",textTransform:"uppercase",letterSpacing:"0.06em"},children:["Runs (",d.length,")"]})]}),r?e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:Array.from({length:2}).map((i,k)=>e.jsx("div",{style:{height:44,borderRadius:6,background:"var(--t-elem-hover)",opacity:1-k*.3}},k))}):d.length===0?e.jsx("p",{style:{fontSize:"var(--t-text-sm)",color:"var(--t-text-muted)",fontStyle:"italic",margin:0},children:"No runs linked to this milestone yet. Edit a run and select this milestone."}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:d.map(i=>e.jsx(Q,{run:i,onClick:()=>l({type:"run-execution",appId:t,runId:i.id})},i.id))})]})]}),a&&e.jsx(M,{appId:t,open:j,onClose:()=>D(!1),initial:E,title:"Edit Milestone",onSave:async i=>{await u(n,{name:i.name.trim(),description:i.description.trim()||void 0,jiraIssueKey:i.jiraIssueKey.trim()||void 0,referenceDoc:i.referenceDoc.trim()||void 0,assigneeId:i.assigneeId||void 0,status:i.status})}}),x&&e.jsx(F,{open:T,title:"Delete Milestone",description:`"${s.name}" will be permanently deleted. Linked runs will be unlinked.`,confirmLabel:"Delete",onConfirm:async()=>{await g(n),l({type:"milestones",appId:t})},onCancel:()=>w(!1)})]})}function Q({run:t,onClick:n}){const[l,o]=c.useState(!1),u=t.status==="passed"?"#22c55e":t.status==="failed"?"#ef4444":t.status==="running"?"#d97706":"var(--t-text-muted)";return e.jsxs("div",{onClick:n,onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),style:{display:"flex",alignItems:"center",gap:10,padding:"8px 12px",borderRadius:6,background:l?"var(--t-elem-hover)":"transparent",cursor:"pointer",transition:"background 0.1s",border:"1px solid transparent"},children:[e.jsx("span",{style:{width:7,height:7,borderRadius:"50%",background:u,flexShrink:0}}),e.jsx("span",{style:{fontSize:"var(--t-text-base)",color:"var(--t-text-primary)",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.name}),t.environment&&e.jsx("span",{style:{fontSize:"var(--t-text-xs)",color:"var(--t-text-muted)",padding:"1px 6px",borderRadius:4,border:"1px solid var(--t-border-default)",background:"var(--t-bg-surface)"},children:t.environment})]})}export{ie as MilestoneDetailView,se as MilestonesView};