@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.
- package/README.md +312 -0
- package/dist/cli.js +16455 -0
- package/dist/client/assets/AIView-BYoeRnLC.js +73 -0
- package/dist/client/assets/AdminSettingsView-JqCQI3K1.js +1 -0
- package/dist/client/assets/ChatSection-rpiFyFcg.js +8 -0
- package/dist/client/assets/MilestonesView-CTJ8r67W.js +1 -0
- package/dist/client/assets/ReportsView-DJ8KPr1J.js +1 -0
- package/dist/client/assets/RunExecution-BJnn0cq7.js +1 -0
- package/dist/client/assets/RunsView-oDa9JyRq.js +1 -0
- package/dist/client/assets/SettingsView-BVCLWqOk.js +1 -0
- package/dist/client/assets/SpaceView-BxtPCtW1.js +1 -0
- package/dist/client/assets/TestEditor-Dthst0HS.js +63 -0
- package/dist/client/assets/TestMuImportDialog-B2yx7BdF.js +5 -0
- package/dist/client/assets/TrashView-B5uFN2Ua.js +1 -0
- package/dist/client/assets/UserGroupsView-MGu6frpT.js +1 -0
- package/dist/client/assets/UsersView-DwWeOblN.js +1 -0
- package/dist/client/assets/comments-section-CHZSUoK5.js +53 -0
- package/dist/client/assets/hooks-BItXZ0yP.js +1 -0
- package/dist/client/assets/hooks-BM-wcPhm.js +4 -0
- package/dist/client/assets/icons-J9gKYxTz.js +41 -0
- package/dist/client/assets/index-CYPrMEmp.css +1 -0
- package/dist/client/assets/index-a9kCDHqT.js +7 -0
- package/dist/client/assets/markdown-YKl4gdXq.js +29 -0
- package/dist/client/assets/radix-ui-Cxk3sw_C.js +41 -0
- package/dist/client/assets/react-D-pHAthU.js +40 -0
- package/dist/client/assets/tiptap-Ch64zYGz.js +167 -0
- package/dist/client/index.html +62 -0
- package/dist/index.js +12990 -0
- package/dist/server/index.js +16195 -0
- package/package.json +124 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import{r,j as e}from"./react-D-pHAthU.js";import{al as Me,am as Ne,an as $e,ao as Ue,ap as Ie,aq as _e,ar as Pe,P as Ye,as as qe,at as Ke,ag as Oe,R as Je,au as Ve,aa as ke,z as Ge,ak as Ze,c as pe,a0 as we,a3 as de,J as ce,q as xe,b as Qe}from"./icons-J9gKYxTz.js";import{b as v,B as T,I as b,A as Xe,t as et}from"./index-a9kCDHqT.js";import{u as tt,i as st,a as it,b as rt,c as at,d as nt,E as lt}from"./tiptap-Ch64zYGz.js";import"./radix-ui-Cxk3sw_C.js";function S({onClick:t,active:o,title:l,children:x}){return e.jsx("button",{type:"button",title:l,onMouseDown:p=>{p.preventDefault(),t()},style:{display:"flex",alignItems:"center",justifyContent:"center",width:26,height:26,borderRadius:5,border:o?"1px solid var(--t-border-default)":"1px solid transparent",cursor:"pointer",background:o?"var(--t-bg-hover)":"transparent",color:o?"var(--t-text-primary)":"var(--t-text-muted)",transition:"background 0.1s, color 0.1s, border-color 0.1s",flexShrink:0},onMouseEnter:p=>{if(!o){const d=p.currentTarget;d.style.background="var(--t-bg-hover)",d.style.color="var(--t-text-secondary)"}},onMouseLeave:p=>{if(!o){const d=p.currentTarget;d.style.background="transparent",d.style.color="var(--t-text-muted)"}},children:x})}function le(){return e.jsx("span",{style:{width:1,height:16,background:"var(--t-border-subtle)",flexShrink:0,margin:"0 2px"}})}function A({value:t,onChange:o,placeholder:l,minHeight:x=120,autoFocus:p=!1,disabled:d=!1}){const n=r.useRef(!1),a=tt({extensions:[rt.configure({heading:{levels:[1,2,3]}}),st,it,at.configure({nested:!0}),nt.configure({placeholder:l??"",emptyEditorClass:"is-editor-empty"})],content:t||"",editable:!d,onUpdate({editor:u}){n.current=!0;const h=u.isEmpty?"":u.getHTML();o(h)},autofocus:p?"end":!1});return r.useEffect(()=>{if(!a)return;if(n.current){n.current=!1;return}(a.isEmpty?"":a.getHTML())!==t&&a.commands.setContent(t||"",!1)},[t,a]),r.useEffect(()=>{a==null||a.setEditable(!d)},[d,a]),a?e.jsxs("div",{style:{border:"1px solid var(--t-border-subtle)",borderRadius:8,overflow:"hidden",background:"var(--t-bg-surface)",transition:"border-color 0.1s"},onFocusCapture:u=>{u.currentTarget.style.borderColor="var(--t-border-strong)"},onBlurCapture:u=>{u.currentTarget.contains(u.relatedTarget)||(u.currentTarget.style.borderColor="var(--t-border-subtle)")},children:[!d&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:2,padding:"5px 8px",borderBottom:"1px solid var(--t-border-default)",flexWrap:"wrap",background:"var(--t-bg-panel)"},children:[e.jsx(S,{title:"Bold (⌘B)",active:a.isActive("bold"),onClick:()=>a.chain().focus().toggleBold().run(),children:e.jsx(Me,{size:13,weight:"bold"})}),e.jsx(S,{title:"Italic (⌘I)",active:a.isActive("italic"),onClick:()=>a.chain().focus().toggleItalic().run(),children:e.jsx(Ne,{size:13})}),e.jsx(S,{title:"Underline (⌘U)",active:a.isActive("underline"),onClick:()=>a.chain().focus().toggleUnderline().run(),children:e.jsx($e,{size:13})}),e.jsx(S,{title:"Strikethrough",active:a.isActive("strike"),onClick:()=>a.chain().focus().toggleStrike().run(),children:e.jsx(Ue,{size:13})}),e.jsx(S,{title:"Inline code",active:a.isActive("code"),onClick:()=>a.chain().focus().toggleCode().run(),children:e.jsx(Ie,{size:13})}),e.jsx(le,{}),e.jsx(S,{title:"Bullet list",active:a.isActive("bulletList"),onClick:()=>a.chain().focus().toggleBulletList().run(),children:e.jsx(_e,{size:13})}),e.jsx(S,{title:"Numbered list",active:a.isActive("orderedList"),onClick:()=>a.chain().focus().toggleOrderedList().run(),children:e.jsx(Pe,{size:13})}),e.jsx(S,{title:"Task list",active:a.isActive("taskList"),onClick:()=>a.chain().focus().toggleTaskList().run(),children:e.jsx(Ye,{size:13})}),e.jsx(le,{}),e.jsx(S,{title:"Blockquote",active:a.isActive("blockquote"),onClick:()=>a.chain().focus().toggleBlockquote().run(),children:e.jsx(qe,{size:13})}),e.jsx(S,{title:"Horizontal rule",active:!1,onClick:()=>a.chain().focus().setHorizontalRule().run(),children:e.jsx(Ke,{size:13})}),e.jsx(le,{}),e.jsx(S,{title:"Undo (⌘Z)",active:!1,onClick:()=>a.chain().focus().undo().run(),children:e.jsx(Oe,{size:13})}),e.jsx(S,{title:"Redo (⌘⇧Z)",active:!1,onClick:()=>a.chain().focus().redo().run(),children:e.jsx(Je,{size:13})})]}),e.jsx("div",{style:{minHeight:x,padding:"10px 12px"},children:e.jsx(lt,{editor:a})}),e.jsx("style",{children:`
|
|
2
|
+
.tiptap {
|
|
3
|
+
outline: none;
|
|
4
|
+
font-size: 13px;
|
|
5
|
+
line-height: 1.7;
|
|
6
|
+
color: var(--t-text-primary);
|
|
7
|
+
font-family: inherit;
|
|
8
|
+
}
|
|
9
|
+
.tiptap p { margin: 0 0 6px; }
|
|
10
|
+
.tiptap p:last-child { margin-bottom: 0; }
|
|
11
|
+
.tiptap h1 { font-size: 18px; font-weight: 700; margin: 10px 0 6px; }
|
|
12
|
+
.tiptap h2 { font-size: 15px; font-weight: 600; margin: 8px 0 4px; }
|
|
13
|
+
.tiptap h3 { font-size: 13px; font-weight: 600; margin: 6px 0 4px; }
|
|
14
|
+
.tiptap ul, .tiptap ol { padding-left: 22px; margin: 4px 0; }
|
|
15
|
+
.tiptap li { margin: 2px 0; }
|
|
16
|
+
.tiptap ul[data-type="taskList"] { list-style: none; padding-left: 4px; }
|
|
17
|
+
.tiptap ul[data-type="taskList"] li {
|
|
18
|
+
display: flex; align-items: flex-start; gap: 8px; margin: 4px 0;
|
|
19
|
+
}
|
|
20
|
+
.tiptap ul[data-type="taskList"] li label { margin-top: 2px; }
|
|
21
|
+
.tiptap ul[data-type="taskList"] li > div { flex: 1; }
|
|
22
|
+
.tiptap code {
|
|
23
|
+
font-family: 'Menlo', 'Monaco', monospace;
|
|
24
|
+
font-size: 12px;
|
|
25
|
+
background: var(--t-bg-surface);
|
|
26
|
+
border: 1px solid var(--t-border-subtle);
|
|
27
|
+
border-radius: 4px;
|
|
28
|
+
padding: 1px 5px;
|
|
29
|
+
}
|
|
30
|
+
.tiptap pre {
|
|
31
|
+
background: var(--t-bg-surface);
|
|
32
|
+
border: 1px solid var(--t-border-subtle);
|
|
33
|
+
border-radius: 6px;
|
|
34
|
+
padding: 12px 14px;
|
|
35
|
+
overflow-x: auto;
|
|
36
|
+
margin: 6px 0;
|
|
37
|
+
}
|
|
38
|
+
.tiptap pre code {
|
|
39
|
+
background: none; border: none; padding: 0; font-size: 12px;
|
|
40
|
+
}
|
|
41
|
+
.tiptap blockquote {
|
|
42
|
+
border-left: 3px solid var(--t-border-default);
|
|
43
|
+
margin: 6px 0;
|
|
44
|
+
padding-left: 14px;
|
|
45
|
+
color: var(--t-text-secondary);
|
|
46
|
+
}
|
|
47
|
+
.tiptap hr {
|
|
48
|
+
border: none;
|
|
49
|
+
border-top: 1px solid var(--t-border-subtle);
|
|
50
|
+
margin: 10px 0;
|
|
51
|
+
}
|
|
52
|
+
.tiptap strong { font-weight: 600; }
|
|
53
|
+
.tiptap em { font-style: italic; }
|
|
54
|
+
.tiptap u { text-decoration: underline; }
|
|
55
|
+
.tiptap s { text-decoration: line-through; }
|
|
56
|
+
.tiptap p.is-editor-empty:first-child::before {
|
|
57
|
+
color: var(--t-text-muted);
|
|
58
|
+
content: attr(data-placeholder);
|
|
59
|
+
float: left;
|
|
60
|
+
height: 0;
|
|
61
|
+
pointer-events: none;
|
|
62
|
+
}
|
|
63
|
+
`})]}):null}const oe="me",Ce=["given","when","then","and","but"],ot={given:"var(--t-text-primary)",when:"var(--t-text-secondary)",then:"var(--t-accent-success)",and:"var(--t-text-muted)",but:"var(--t-accent-danger)"};function m({label:t,children:o,hint:l}){return 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:t}),o,l&&e.jsx("span",{style:{fontSize:"var(--t-text-xs)",color:"var(--t-text-muted)"},children:l})]})}function G({value:t,onChange:o,children:l}){return e.jsx("select",{value:t,onChange:x=>o(x.target.value),style:{background:"var(--t-bg-surface)",border:"1px solid var(--t-border-subtle)",borderRadius:8,padding:"9px 12px",fontSize:"var(--t-text-base)",color:"var(--t-text-primary)",outline:"none",cursor:"pointer",width:"100%",appearance:"auto"},children:l})}function $({onClick:t,title:o,danger:l,children:x}){return e.jsx("button",{onClick:t,title:o,style:{width:26,height:26,borderRadius:5,border:"none",cursor:"pointer",background:"transparent",color:"var(--t-text-muted)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,transition:"all 0.1s"},onMouseEnter:p=>{const d=p.currentTarget;d.style.background=l?"rgba(229,72,77,0.1)":"var(--t-elem-hover)",d.style.color=l?"var(--t-accent-danger)":"var(--t-text-secondary)"},onMouseLeave:p=>{const d=p.currentTarget;d.style.background="transparent",d.style.color="var(--t-text-muted)"},children:x})}function dt({step:t,index:o,folderId:l,testId:x,onRefresh:p}){const[d,n]=r.useState(!1),[a,u]=r.useState(t.action),[h,z]=r.useState(t.expectedResult??""),[k,j]=r.useState(!1),E=()=>{u(t.action),z(t.expectedResult??""),n(!0)},C=()=>n(!1),B=async()=>{if(!(!a||a==="<p></p>")){j(!0);try{await v.tests.steps.update(l,x,t.id,{action:a,expectedResult:h&&h!=="<p></p>"?h:""}),await p(),n(!1)}finally{j(!1)}}};return e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:12,padding:d?"14px 16px 16px":"14px 16px",borderTop:o>0?"1px solid var(--t-border-subtle)":"none",background:d?"var(--t-bg-panel)":"transparent",transition:"background 0.1s"},children:[e.jsx("span",{style:{width:22,height:22,borderRadius:"50%",background:"var(--t-bg-panel)",border:"1px solid var(--t-border-default)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"var(--t-text-2xs)",fontWeight:700,color:"var(--t-text-muted)",flexShrink:0,marginTop:2},children:o+1}),d?e.jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:10},children:[e.jsxs("div",{children:[e.jsx("p",{style:{fontSize:11,fontWeight:600,color:"var(--t-text-muted)",textTransform:"uppercase",letterSpacing:"0.06em",marginBottom:6},children:"Step action *"}),e.jsx(A,{value:a,onChange:u,placeholder:"Describe the action to perform…",minHeight:60,autoFocus:!0})]}),e.jsxs("div",{children:[e.jsxs("p",{style:{fontSize:11,fontWeight:600,color:"var(--t-text-muted)",textTransform:"uppercase",letterSpacing:"0.06em",marginBottom:6},children:["Expected result"," ",e.jsx("span",{style:{fontWeight:400,textTransform:"none",letterSpacing:0},children:"(optional)"})]}),e.jsx(A,{value:h,onChange:z,placeholder:"What should happen after this step?",minHeight:60})]}),e.jsxs("div",{style:{display:"flex",gap:6},children:[e.jsxs(T,{onClick:B,disabled:k,style:{gap:5,height:30,fontSize:"var(--t-text-sm)"},children:[e.jsx(de,{size:12,weight:"bold"}),k?"Saving…":"Save"]}),e.jsx(T,{variant:"outline",onClick:C,style:{height:30,fontSize:"var(--t-text-sm)"},children:"Cancel"})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{className:"rich-preview",dangerouslySetInnerHTML:{__html:t.action},style:{fontSize:"var(--t-text-base)",color:"var(--t-text-primary)",lineHeight:1.6,wordBreak:"break-word"}}),t.expectedResult&&e.jsx("div",{className:"rich-preview",dangerouslySetInnerHTML:{__html:t.expectedResult},style:{fontSize:"var(--t-text-sm)",color:"var(--t-text-secondary)",marginTop:6,paddingLeft:10,borderLeft:"2px solid var(--t-border-subtle)",lineHeight:1.6,wordBreak:"break-word"}})]}),e.jsxs("div",{style:{display:"flex",gap:2,flexShrink:0},children:[e.jsx($,{onClick:E,title:"Edit step",children:e.jsx(ce,{size:12})}),e.jsx($,{onClick:()=>v.tests.steps.delete(l,x,t.id).then(p),title:"Delete step",danger:!0,children:e.jsx(xe,{size:12})})]})]})]})}function ct({steps:t,folderId:o,testId:l,onRefresh:x}){const[p,d]=r.useState(""),[n,a]=r.useState(""),[u,h]=r.useState(!1),z=async()=>{if(!(!p||p==="<p></p>"||u)){h(!0);try{await v.tests.steps.create(o,l,{action:p,expectedResult:n&&n!=="<p></p>"?n:void 0,order:t.length}),d(""),a(""),await x()}finally{h(!1)}}};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:20},children:[t.length>0?e.jsx("div",{style:{border:"1px solid var(--t-border-subtle)",borderRadius:10,overflow:"hidden"},children:t.map((k,j)=>e.jsx(dt,{step:k,index:j,folderId:o,testId:l,onRefresh:x},k.id))}):e.jsx("div",{style:{padding:"32px 0",textAlign:"center",color:"var(--t-text-muted)",fontSize:"var(--t-text-base)",border:"1px dashed var(--t-border-subtle)",borderRadius:10},children:"No steps yet — add the first one below."}),e.jsxs("div",{style:{border:"1px solid var(--t-border-subtle)",borderRadius:10,overflow:"hidden",background:"var(--t-bg-panel)"},children:[e.jsxs("div",{style:{padding:"10px 14px 6px",borderBottom:"1px solid var(--t-border-subtle)"},children:[e.jsx("p",{style:{fontSize:11,fontWeight:600,color:"var(--t-text-muted)",textTransform:"uppercase",letterSpacing:"0.06em",marginBottom:8},children:"Step action *"}),e.jsx(A,{value:p,onChange:d,placeholder:"Describe the action to perform…",minHeight:70,autoFocus:!0})]}),e.jsxs("div",{style:{padding:"10px 14px 10px"},children:[e.jsxs("p",{style:{fontSize:11,fontWeight:600,color:"var(--t-text-muted)",textTransform:"uppercase",letterSpacing:"0.06em",marginBottom:8},children:["Expected result"," ",e.jsx("span",{style:{fontWeight:400,textTransform:"none",letterSpacing:0},children:"(optional)"})]}),e.jsx(A,{value:n,onChange:a,placeholder:"What should happen after this step?",minHeight:70})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",padding:"0 14px 12px"},children:e.jsxs(T,{onClick:z,disabled:u,variant:"outline",style:{gap:6},children:[e.jsx(pe,{size:13}),u?"Adding…":"Add Step"]})})]})]})}function xt({scenario:t,folderId:o,testId:l,onRefresh:x}){const[p,d]=r.useState("given"),[n,a]=r.useState(""),[u,h]=r.useState(!1),[z,k]=r.useState(t.feature??""),[j,E]=r.useState(t.scenario),[C,B]=r.useState(!1),[R,F]=r.useState(null),[W,U]=r.useState("given"),[L,I]=r.useState(""),[_,P]=r.useState(!1),Y=async c=>{c.preventDefault(),n.trim()&&(await v.tests.scenarios.steps.create(o,l,t.id,{type:p,text:n.trim(),order:t.steps.length}),a(""),x())},Z=async()=>{if(j.trim()){B(!0);try{await v.tests.scenarios.update(o,l,t.id,{feature:z.trim()||void 0,scenario:j.trim()}),x(),h(!1)}finally{B(!1)}}},q=c=>{F(c.id),U(c.type),I(c.text)},Q=async c=>{if(L.trim()){P(!0);try{await v.tests.scenarios.steps.update(o,l,t.id,c,{type:W,text:L.trim()}),x(),F(null)}finally{P(!1)}}},M={background:"var(--t-bg-panel)",border:"1px solid var(--t-border-subtle)",borderRadius:6,padding:"7px 10px",fontSize:"var(--t-text-sm)",color:"var(--t-text-secondary)",outline:"none",width:84,cursor:"pointer"};return e.jsxs("div",{style:{border:"1px solid var(--t-border-subtle)",borderRadius:10,overflow:"hidden",marginBottom:12},children:[e.jsx("div",{style:{padding:"11px 16px",borderBottom:t.steps.length>0||u?"1px solid var(--t-border-subtle)":"none",background:"var(--t-bg-surface)"},children:u?e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[e.jsx(b,{value:z,onChange:c=>k(c.target.value),placeholder:"Feature (optional)",autoFocus:!0}),e.jsx(b,{value:j,onChange:c=>E(c.target.value),placeholder:"Scenario title *"}),e.jsxs("div",{style:{display:"flex",gap:6},children:[e.jsxs(T,{onClick:Z,disabled:C,style:{gap:5,height:30,fontSize:"var(--t-text-sm)"},children:[e.jsx(de,{size:12,weight:"bold"}),C?"Saving…":"Save"]}),e.jsx(T,{variant:"outline",onClick:()=>h(!1),style:{height:30,fontSize:"var(--t-text-sm)"},children:"Cancel"})]})]}):e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[t.feature&&e.jsxs("p",{style:{fontSize:10,color:"var(--t-text-muted)",textTransform:"uppercase",letterSpacing:"0.06em",marginBottom:2},children:["Feature: ",t.feature]}),e.jsxs("p",{style:{fontSize:"var(--t-text-base)",fontWeight:500,color:"var(--t-text-primary)"},children:["Scenario: ",t.scenario]})]}),e.jsxs("div",{style:{display:"flex",gap:2},children:[e.jsx($,{onClick:()=>{k(t.feature??""),E(t.scenario),h(!0)},title:"Edit scenario",children:e.jsx(ce,{size:12})}),e.jsx($,{onClick:()=>v.tests.scenarios.delete(o,l,t.id).then(x),title:"Delete scenario",danger:!0,children:e.jsx(xe,{size:12})})]})]})}),e.jsxs("div",{style:{padding:"8px 16px 14px"},children:[t.steps.map((c,K)=>e.jsx("div",{style:{borderBottom:K<t.steps.length-1?"1px solid var(--t-border-subtle)":"none"},children:R===c.id?e.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center",padding:"6px 0"},children:[e.jsx("select",{value:W,onChange:w=>U(w.target.value),style:M,children:Ce.map(w=>e.jsx("option",{value:w,children:w.charAt(0).toUpperCase()+w.slice(1)},w))}),e.jsx(b,{value:L,onChange:w=>I(w.target.value),placeholder:"Step text…",autoFocus:!0}),e.jsx("button",{onClick:()=>Q(c.id),disabled:_,title:"Save",style:{width:28,height:28,borderRadius:5,border:"none",cursor:"pointer",background:"var(--t-accent-success)",color:"#fff",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(de,{size:13,weight:"bold"})}),e.jsx("button",{onClick:()=>F(null),title:"Cancel",style:{width:28,height:28,borderRadius:5,border:"1px solid var(--t-border-default)",cursor:"pointer",background:"transparent",color:"var(--t-text-muted)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(Qe,{size:13})})]}):e.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:10,padding:"5px 0"},children:[e.jsx("span",{style:{fontSize:10,fontWeight:700,textTransform:"uppercase",width:36,flexShrink:0,color:ot[c.type]??"var(--t-text-muted)",letterSpacing:"0.04em"},children:c.type.charAt(0).toUpperCase()+c.type.slice(1)}),e.jsx("span",{style:{fontSize:"var(--t-text-base)",color:"var(--t-text-primary)",flex:1},children:c.text}),e.jsxs("div",{style:{display:"flex",gap:2,flexShrink:0},children:[e.jsx($,{onClick:()=>q(c),title:"Edit step",children:e.jsx(ce,{size:11})}),e.jsx($,{onClick:()=>v.tests.scenarios.steps.delete(o,l,t.id,c.id).then(x),title:"Delete step",danger:!0,children:e.jsx(xe,{size:11})})]})]})},c.id)),e.jsxs("form",{onSubmit:Y,style:{display:"flex",gap:8,marginTop:12},children:[e.jsx("select",{value:p,onChange:c=>d(c.target.value),style:M,children:Ce.map(c=>e.jsx("option",{value:c,children:c.charAt(0).toUpperCase()+c.slice(1)},c))}),e.jsx(b,{value:n,onChange:c=>a(c.target.value),placeholder:"Step text…"}),e.jsxs(T,{type:"submit",variant:"outline",style:{flexShrink:0,gap:5,fontSize:"var(--t-text-sm)"},children:[e.jsx(pe,{size:12})," Step"]})]})]})]})}function pt({scenarios:t,folderId:o,testId:l,onRefresh:x}){const[p,d]=r.useState(""),[n,a]=r.useState(""),u=async h=>{h.preventDefault(),n.trim()&&(await v.tests.scenarios.create(o,l,{feature:p.trim()||void 0,scenario:n.trim()}),d(""),a(""),x())};return e.jsxs("div",{children:[t.length===0&&e.jsx("div",{style:{padding:"32px 0",textAlign:"center",color:"var(--t-text-muted)",fontSize:"var(--t-text-base)",border:"1px dashed var(--t-border-subtle)",borderRadius:10,marginBottom:16},children:"No scenarios yet — add the first one below."}),t.map(h=>e.jsx(xt,{scenario:h,folderId:o,testId:l,onRefresh:x},h.id)),e.jsxs("form",{onSubmit:u,style:{display:"flex",gap:8},children:[e.jsx(b,{value:p,onChange:h=>d(h.target.value),placeholder:"Feature (optional)",autoFocus:!0}),e.jsx(b,{value:n,onChange:h=>a(h.target.value),placeholder:"Scenario title *"}),e.jsxs(T,{type:"submit",variant:"outline",style:{flexShrink:0,gap:6},children:[e.jsx(pe,{size:13})," Scenario"]})]})]})}function ut({folderId:t,testId:o}){const[l,x]=r.useState([]),[p,d]=r.useState(!0);return r.useEffect(()=>{v.tests.history(t,o).then(n=>{x(n),d(!1)})},[t,o]),p?e.jsx("div",{style:{padding:"48px 0",textAlign:"center",color:"var(--t-text-muted)",fontSize:"var(--t-text-base)"},children:"Loading…"}):l.length?e.jsx("div",{style:{border:"1px solid var(--t-border-subtle)",borderRadius:10,overflow:"hidden"},children:l.map((n,a)=>e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:12,padding:"12px 16px",borderTop:a>0?"1px solid var(--t-border-subtle)":"none"},children:[e.jsx(we,{size:13,color:"var(--t-text-muted)",style:{marginTop:2,flexShrink:0}}),e.jsxs("div",{style:{flex:1},children:[e.jsxs("p",{style:{fontSize:"var(--t-text-base)",color:"var(--t-text-secondary)"},children:[e.jsx("span",{style:{color:"var(--t-text-primary)",fontWeight:500},children:n.field})," ","changed by ",n.changedBy]}),e.jsxs("p",{style:{fontSize:"var(--t-text-xs)",color:"var(--t-text-muted)",marginTop:3},children:[e.jsx("span",{style:{textDecoration:"line-through",opacity:.5},children:n.oldValue??"(empty)"})," → ",n.newValue??"(empty)"]})]}),e.jsx("span",{style:{fontSize:"var(--t-text-xs)",color:"var(--t-text-muted)",flexShrink:0},children:new Date(n.changedAt).toLocaleString()})]},n.id))}):e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:10,padding:"64px 0",textAlign:"center"},children:[e.jsx(we,{size:28,weight:"duotone",color:"var(--t-text-muted)"}),e.jsx("p",{style:{fontSize:"var(--t-text-base)",color:"var(--t-text-muted)"},children:"No changes recorded yet."})]})}function f({w:t="100%",h:o=14,radius:l=6}){return e.jsx("div",{style:{width:t,height:o,borderRadius:l,background:"var(--t-border-subtle)",animation:"sk-pulse 1.4s ease-in-out infinite",flexShrink:0}})}function se({rows:t=3}){return e.jsxs("div",{style:{border:"1px solid var(--t-border-subtle)",borderRadius:8,overflow:"hidden",background:"var(--t-bg-base)"},children:[e.jsx("div",{style:{padding:"7px 10px",borderBottom:"1px solid var(--t-border-default)",background:"var(--t-bg-panel)",display:"flex",gap:6,alignItems:"center"},children:[40,24,24,24,24,1,24,24,24,1,24,24,1,24,24].map((o,l)=>o===1?e.jsx("div",{style:{width:1,height:16,background:"var(--t-border-subtle)",flexShrink:0}},l):e.jsx(f,{w:o,h:16,radius:4},l))}),e.jsx("div",{style:{padding:"12px",display:"flex",flexDirection:"column",gap:8},children:Array.from({length:t}).map((o,l)=>e.jsx(f,{w:l===t-1?"60%":"100%",h:12},l))})]})}function ht(){return e.jsxs("div",{style:{flex:1,overflow:"hidden",display:"flex",flexDirection:"column",background:"var(--t-bg-base)"},children:[e.jsx("style",{children:"@keyframes sk-pulse { 0%,100%{opacity:1} 50%{opacity:.45} }"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"0 20px",height:52,borderBottom:"1px solid var(--t-border-subtle)",flexShrink:0},children:[e.jsx(f,{w:54,h:22,radius:6}),e.jsx("div",{style:{width:1,height:16,background:"var(--t-border-subtle)"}}),e.jsx(f,{w:100,h:14,radius:6})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"0 24px",height:44,borderBottom:"1px solid var(--t-border-subtle)",flexShrink:0},children:[e.jsxs("div",{style:{display:"flex",gap:20},children:[e.jsx(f,{w:52,h:14}),e.jsx(f,{w:44,h:14})]}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx(f,{w:64,h:30,radius:7}),e.jsx(f,{w:100,h:30,radius:7})]})]}),e.jsxs("div",{style:{display:"flex",flex:1,overflow:"hidden"},children:[e.jsxs("div",{style:{flex:1,padding:"28px 28px 28px 32px",borderRight:"1px solid var(--t-border-subtle)",display:"flex",flexDirection:"column",gap:24,overflowY:"auto"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[e.jsx(f,{w:36,h:11}),e.jsx(f,{w:"100%",h:38,radius:8})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[e.jsx(f,{w:70,h:11}),e.jsx(se,{rows:4})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[e.jsx(f,{w:90,h:11}),e.jsx(se,{rows:2})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[e.jsx(f,{w:68,h:11}),e.jsx(se,{rows:2})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[e.jsx(f,{w:40,h:11}),e.jsx(se,{rows:2})]})]}),e.jsxs("div",{style:{width:400,flexShrink:0,padding:"28px 24px 28px 20px",display:"flex",flexDirection:"column",gap:24,overflowY:"auto"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[e.jsx(f,{w:60,h:11}),e.jsxs("div",{style:{display:"flex",gap:6},children:[e.jsx(f,{w:110,h:36,radius:7}),e.jsx(f,{w:120,h:36,radius:7})]})]}),[["Category",56],["Priority",52],["Status",46],["Automation Status",110],["Estimated Time (minutes)",168],["Jira Issue Key",90],["Assignee",60],["Tags",34]].map(([t,o])=>e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[e.jsx(f,{w:Number(o),h:11}),e.jsx(f,{w:"100%",h:38,radius:8})]},String(t)))]})]})]})}function jt({folderId:t,testId:o,appId:l,spaceId:x,onNavigate:p,onSaved:d}){const[n,a]=r.useState(o),[u,h]=r.useState(null),[z,k]=r.useState(!!o),[j,E]=r.useState("details"),[C,B]=r.useState("traditional"),[R,F]=r.useState(""),[W,U]=r.useState(""),[L,I]=r.useState(""),[_,P]=r.useState(""),[Y,Z]=r.useState(""),[q,Q]=r.useState("Medium"),[M,c]=r.useState("Draft"),[K,w]=r.useState(""),[ie,ue]=r.useState(""),[O,he]=r.useState(""),[re,ge]=r.useState(""),[ae,ve]=r.useState(null),[J,fe]=r.useState([]),[Te,ze]=r.useState([]),[De,ye]=r.useState([]),[X,ee]=r.useState(!1),[me,D]=r.useState(""),[je,Ee]=r.useState([]),[Ae,be]=r.useState({});r.useEffect(()=>{a(o)},[o]),r.useEffect(()=>{v.fields.list(l).then(s=>Ee(s.sort((i,y)=>i.order-y.order))).catch(()=>{}),v.globalTags.list().then(ze).catch(()=>{}),v.spaceTags.list(x).then(ye).catch(()=>{})},[l,x]),r.useEffect(()=>{n&&v.fields.values.list(l,n).then(s=>{const i={};for(const y of s)i[y.fieldId]=y.value??"";be(i)}).catch(()=>{})},[l,n]);const Be=async(s=n)=>{if(s){k(!0);try{const i=await v.tests.get(t,s);h(i),B(i.type),F(i.title),U(i.description??""),I(i.preconditions??""),P(i.testData??""),Z(i.notes??""),Q(i.priority),c(i.status),w(i.category??""),ue(i.automationStatus??""),he(i.estimatedTime!=null?String(i.estimatedTime):""),ge(i.jiraIssueKey??""),ve(i.assigneeId??null),fe(i.tags?JSON.parse(i.tags):[])}finally{k(!1)}}},Se=async(s=n)=>{if(!s)return;const i=await v.tests.get(t,s);h(i)};r.useEffect(()=>{Be()},[n]);const Re=async()=>{if(!R.trim()){D("Title is required");return}ee(!0),D("");const s={type:C,title:R.trim(),description:W.trim()||void 0,preconditions:L.trim()||void 0,testData:_.trim()||void 0,notes:Y.trim()||void 0,priority:q,status:M,category:K||void 0,automationStatus:ie||void 0,estimatedTime:O?parseInt(O,10):void 0,jiraIssueKey:re.trim()||void 0,assigneeId:ae||void 0,tags:J.length>0?J:void 0};try{if(n)return await v.tests.update(t,n,{...s,updatedBy:oe}),d(),p({type:"tests",appId:l,spaceId:x,folderId:t}),n;{const i=await v.tests.create(t,{...s,createdBy:oe});return a(i.id),h({...i,steps:[],scenarios:[]}),d(),p({type:"tests",appId:l,spaceId:x,folderId:t}),i.id}}catch(i){D(i instanceof Error?i.message:"Failed to save");return}finally{ee(!1)}},Le=async()=>{if(!R.trim()){D("Title is required");return}ee(!0),D("");const s={type:C,title:R.trim(),description:W.trim()||void 0,preconditions:L.trim()||void 0,testData:_.trim()||void 0,notes:Y.trim()||void 0,priority:q,status:M,category:K||void 0,automationStatus:ie||void 0,estimatedTime:O?parseInt(O,10):void 0,jiraIssueKey:re.trim()||void 0,assigneeId:ae||void 0,tags:J.length>0?J:void 0};try{const i=await v.tests.create(t,{...s,createdBy:oe});a(i.id),h({...i,steps:[],scenarios:[]}),d(),E("steps")}catch(i){D(i instanceof Error?i.message:"Failed to save")}finally{ee(!1)}},He=s=>{if(V&&!n&&s==="steps"){D("Click 'Save & Next' to save details before adding steps");return}E(s),D("")},V=!n;return z?e.jsx(ht,{}):e.jsxs("div",{style:{flex:1,overflow:"hidden",display:"flex",flexDirection:"column",background:"var(--t-bg-base)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"0 20px",height:52,borderBottom:"1px solid var(--t-border-subtle)",flexShrink:0},children:[e.jsx("button",{onClick:()=>p({type:"tests",appId:l,spaceId:x,folderId:t}),style:{display:"flex",alignItems:"center",justifyContent:"center",width:28,height:28,borderRadius:6,border:"none",cursor:"pointer",background:"transparent",color:"var(--t-text-secondary)",flexShrink:0,transition:"all 0.1s"},onMouseEnter:s=>{const i=s.currentTarget;i.style.background="var(--t-bg-hover)",i.style.color="var(--t-text-primary)"},onMouseLeave:s=>{const i=s.currentTarget;i.style.background="transparent",i.style.color="var(--t-text-secondary)"},children:e.jsx(Ve,{size:14})}),e.jsx("div",{style:{width:1,height:16,background:"var(--t-border-subtle)",flexShrink:0}}),e.jsx("span",{style:{fontSize:"var(--t-text-base)",color:"var(--t-text-secondary)"},children:V?"New Test":`Edit ${(u==null?void 0:u.internalId)??""}`})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"0 24px",borderBottom:"1px solid var(--t-border-subtle)",flexShrink:0},children:[e.jsx("div",{style:{display:"flex",alignItems:"flex-end",flex:1},children:(V?["details","steps"]:["details","steps","history"]).map(s=>{const i=j===s,y=s==="steps"?C==="bdd"?"Scenarios":"Steps":s==="details"?"Details":"History";return e.jsx("button",{onClick:()=>He(s),style:{padding:"10px 16px",fontSize:"var(--t-text-base)",fontWeight:i?500:400,border:"none",borderBottom:i?"2px solid var(--t-text-primary)":"2px solid transparent",background:"transparent",color:i?"var(--t-text-primary)":"var(--t-text-muted)",cursor:"pointer",transition:"color 0.1s",marginBottom:-1},onMouseEnter:H=>{i||(H.currentTarget.style.color="var(--t-text-secondary)")},onMouseLeave:H=>{i||(H.currentTarget.style.color="var(--t-text-muted)")},children:y},s)})}),e.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center",paddingBottom:1},children:[me&&e.jsx("span",{style:{fontSize:"var(--t-text-sm)",color:"var(--t-accent-danger)"},children:me}),e.jsx(T,{variant:"outline",onClick:()=>p({type:"tests",appId:l,spaceId:x,folderId:t}),style:{height:32,fontSize:"var(--t-text-sm)"},children:"Cancel"}),V&&!n?e.jsxs(T,{onClick:Le,disabled:X,style:{gap:6,height:32,fontSize:"var(--t-text-sm)"},children:[e.jsx(ke,{size:13,weight:"bold"}),X?"Saving…":"Save & Next"]}):e.jsxs(T,{onClick:Re,disabled:X,style:{gap:6,height:32,fontSize:"var(--t-text-sm)"},children:[e.jsx(ke,{size:13,weight:"bold"}),X?"Saving…":"Save Changes"]})]})]}),e.jsxs("div",{style:{flex:1,overflow:"hidden",display:"flex",flexDirection:"column"},children:[j==="details"&&e.jsxs("div",{style:{display:"flex",height:"100%"},children:[e.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"28px 28px 28px 32px",borderRight:"1px solid var(--t-border-subtle)",display:"flex",flexDirection:"column",gap:20},children:[e.jsx(m,{label:"Title *",children:e.jsx(b,{value:R,onChange:s=>F(s.target.value),placeholder:"What does this test verify?",autoFocus:V})}),e.jsx(m,{label:"Description",children:e.jsx(A,{value:W,onChange:U,placeholder:"Additional context about this test…",minHeight:120})}),e.jsx(m,{label:"Preconditions",children:e.jsx(A,{value:L,onChange:I,placeholder:"What must be true before running this test?",minHeight:90})}),e.jsx(m,{label:"Test Data",children:e.jsx(A,{value:_,onChange:P,placeholder:"Credentials, sample data, environment variables…",minHeight:90})}),e.jsx(m,{label:"Notes",children:e.jsx(A,{value:Y,onChange:Z,placeholder:"Known issues, edge cases, reminders…",minHeight:90})})]}),e.jsxs("div",{style:{width:400,flexShrink:0,overflowY:"auto",padding:"28px 24px 28px 20px",display:"flex",flexDirection:"column",gap:20},children:[e.jsx(m,{label:"Test type",children:e.jsx("div",{style:{display:"flex",flexDirection:"row",gap:6},children:["traditional","bdd"].map(s=>{const i=C===s;return e.jsxs("button",{onClick:()=>B(s),style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px",borderRadius:7,border:"1px solid",borderColor:i?"var(--t-border-default)":"var(--t-border-subtle)",cursor:"pointer",fontSize:"var(--t-text-base)",fontWeight:i?500:400,background:i?"var(--t-bg-elevated)":"transparent",color:i?"var(--t-text-primary)":"var(--t-text-muted)",transition:"all 0.1s",textAlign:"left"},children:[s==="bdd"?e.jsx(Ge,{size:13}):e.jsx(Ze,{size:13}),s==="bdd"?"BDD / Gherkin":"Traditional"]},s)})})}),e.jsx(m,{label:"Category",children:e.jsxs(G,{value:K,onChange:s=>w(s),children:[e.jsx("option",{value:"",children:"— None —"}),e.jsx("option",{value:"Functional",children:"Functional"}),e.jsx("option",{value:"Manual",children:"Manual"}),e.jsx("option",{value:"Regression",children:"Regression"}),e.jsx("option",{value:"Smoke & Sanity",children:"Smoke & Sanity"}),e.jsx("option",{value:"Acceptance",children:"Acceptance"}),e.jsx("option",{value:"Accessibility",children:"Accessibility"}),e.jsx("option",{value:"Compatibility",children:"Compatibility"}),e.jsx("option",{value:"Destructive",children:"Destructive"}),e.jsx("option",{value:"Integration",children:"Integration"}),e.jsx("option",{value:"Performance",children:"Performance"}),e.jsx("option",{value:"Security",children:"Security"}),e.jsx("option",{value:"User Interface",children:"User Interface"}),e.jsx("option",{value:"Usability",children:"Usability"}),e.jsx("option",{value:"Other",children:"Other"})]})}),e.jsx(m,{label:"Priority",children:e.jsxs(G,{value:q,onChange:s=>Q(s),children:[e.jsx("option",{value:"Lowest",children:"Lowest"}),e.jsx("option",{value:"Low",children:"Low"}),e.jsx("option",{value:"Normal",children:"Normal"}),e.jsx("option",{value:"Medium",children:"Medium"}),e.jsx("option",{value:"High",children:"High"}),e.jsx("option",{value:"Highest",children:"Highest"})]})}),e.jsx(m,{label:"Status",children:e.jsxs(G,{value:M,onChange:s=>c(s),children:[e.jsx("option",{value:"Draft",children:"Draft"}),e.jsx("option",{value:"Unverified",children:"Unverified"}),e.jsx("option",{value:"Faulty",children:"Faulty"}),e.jsx("option",{value:"Ready",children:"Ready"}),e.jsx("option",{value:"Live",children:"Live"}),e.jsx("option",{value:"Deprecated",children:"Deprecated"}),e.jsx("option",{value:"Archived",children:"Archived"})]})}),e.jsx(m,{label:"Automation Status",children:e.jsxs(G,{value:ie,onChange:s=>ue(s),children:[e.jsx("option",{value:"",children:"— None —"}),e.jsx("option",{value:"Not Automated",children:"Not Automated"}),e.jsx("option",{value:"To Be Automated",children:"To Be Automated"}),e.jsx("option",{value:"Automated",children:"Automated"})]})}),e.jsx(m,{label:"Estimated Time (minutes)",children:e.jsx(b,{type:"number",min:"0",value:O,onChange:s=>he(s.target.value),placeholder:"e.g. 30"})}),e.jsx(m,{label:"Jira Issue Key",children:e.jsx(b,{value:re,onChange:s=>ge(s.target.value),placeholder:"e.g. PROJ-123"})}),e.jsx(m,{label:"Assignee",children:e.jsx(Xe,{appId:l,value:ae,onChange:ve})}),e.jsx(m,{label:"Tags",children:e.jsx(et,{selected:J,onChange:fe,globalTags:Te,spaceTags:De,onCreateSpaceTag:async s=>{try{const i=await v.spaceTags.create(x,{name:s});return ye(y=>[...y,i]),i}catch{return null}}})}),je.length>0&&e.jsx(e.Fragment,{children:e.jsxs("div",{style:{borderTop:"1px solid var(--t-border-subtle)",paddingTop:20},children:[e.jsx("p",{style:{fontSize:11,fontWeight:600,color:"var(--t-text-muted)",textTransform:"uppercase",letterSpacing:"0.06em",marginBottom:14},children:"Custom Fields"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:16},children:je.map(s=>{const i=Ae[s.id]??s.defaultValue??"",y=async g=>{be(N=>({...N,[s.id]:g})),n&&await v.fields.values.set(l,n,s.id,g).catch(()=>{})};let H=[];try{H=s.options?JSON.parse(s.options):[]}catch{}return e.jsxs(m,{label:s.name+(s.required?" *":""),children:[s.type==="text"&&e.jsx(b,{value:i,onChange:g=>y(g.target.value),placeholder:s.defaultValue??""}),s.type==="number"&&e.jsx(b,{value:i,onChange:g=>y(g.target.value),placeholder:"0"}),s.type==="url"&&e.jsx(b,{value:i,onChange:g=>y(g.target.value),placeholder:"https://"}),s.type==="date"&&e.jsx(b,{value:i,onChange:g=>y(g.target.value),placeholder:"YYYY-MM-DD"}),s.type==="checkbox"&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("input",{type:"checkbox",checked:i==="true",onChange:g=>y(g.target.checked?"true":"false"),style:{width:14,height:14,cursor:"pointer"}}),e.jsx("span",{style:{fontSize:"var(--t-text-sm)",color:"var(--t-text-secondary)"},children:i==="true"?"Yes":"No"})]}),s.type==="dropdown"&&e.jsxs(G,{value:i,onChange:y,children:[e.jsx("option",{value:"",children:"— Select —"}),H.map(g=>e.jsx("option",{value:g,children:g},g))]}),s.type==="multiselect"&&e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:H.map(g=>{const N=i.split(",").map(te=>te.trim()).filter(Boolean).includes(g),Fe=()=>{const te=i.split(",").map(ne=>ne.trim()).filter(Boolean),We=N?te.filter(ne=>ne!==g):[...te,g];y(We.join(", "))};return e.jsx("button",{onClick:Fe,style:{padding:"3px 10px",borderRadius:99,fontSize:"var(--t-text-sm)",cursor:"pointer",border:"1px solid",background:N?"var(--t-bg-hover)":"transparent",color:N?"var(--t-text-primary)":"var(--t-text-muted)",borderColor:N?"var(--t-border-strong)":"var(--t-border-default)",transition:"all 0.1s"},children:g},g)})})]},s.id)})})]})})]})]}),j==="steps"&&e.jsx("div",{style:{flex:1,overflowY:"auto"},children:e.jsx("div",{style:{maxWidth:760,margin:"0 auto",padding:"32px 24px"},children:n?C==="traditional"?e.jsx(ct,{steps:(u==null?void 0:u.steps)??[],folderId:t,testId:n,onRefresh:()=>Se(n)}):e.jsx(pt,{scenarios:(u==null?void 0:u.scenarios)??[],folderId:t,testId:n,onRefresh:()=>Se(n)}):e.jsx("div",{style:{textAlign:"center",padding:"64px 0",color:"var(--t-text-muted)",fontSize:"var(--t-text-base)"},children:e.jsxs("p",{children:["Go to the"," ",e.jsx("button",{onClick:()=>{E("details"),D("")},style:{background:"none",border:"none",cursor:"pointer",color:"var(--t-text-secondary)",textDecoration:"underline",fontSize:"var(--t-text-base)",padding:0},children:"Details"})," ","tab and click"," ",e.jsx("span",{style:{color:"var(--t-text-primary)",fontWeight:500},children:"Save & Next"})," ","first."]})})})}),j==="history"&&e.jsx("div",{style:{flex:1,overflowY:"auto"},children:e.jsx("div",{style:{maxWidth:680,margin:"0 auto",padding:"32px 24px"},children:n?e.jsx(ut,{folderId:t,testId:n}):e.jsx("div",{style:{textAlign:"center",padding:"64px 0",color:"var(--t-text-muted)",fontSize:"var(--t-text-base)"},children:"Save the test to view history."})})})]})]})}export{jt as TestEditor};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{r as o,j as e}from"./react-D-pHAthU.js";import{D as Y,a as G,f as X,b as Z,c as ee}from"./radix-ui-Cxk3sw_C.js";import{au as te,b as re,P as F,Q as T,aL as se,V as ae,U as ne,O as oe,f as ie,ai as le}from"./icons-J9gKYxTz.js";import{B as P}from"./index-a9kCDHqT.js";async function de(u,v,m){const r=await fetch("/api/testmu/proxy",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:u,username:v,accessKey:m,endpoint:"/projects",params:{per_page:"100",page:"1"}})}),i=await r.json();if(!r.ok)throw new Error(i.error??`HTTP ${r.status}`);return i.data??i.projects??[]}function me({open:u,onClose:v,appId:m}){const[r,i]=o.useState("credentials"),[S,D]=o.useState("https://test-manager-api.lambdatest.com/api/v1"),[g,E]=o.useState(""),[f,O]=o.useState(""),[R,W]=o.useState(!1),[$,j]=o.useState(null),[l,B]=o.useState([]),[s,h]=o.useState(new Set),[K,z]=o.useState([]),[M,b]=o.useState(!1);o.useEffect(()=>{u||(i("credentials"),j(null),B([]),h(new Set),z([]),b(!1),E(""),O(""),D("https://test-manager-api.lambdatest.com/api/v1"))},[u]);const U=async()=>{if(!g.trim()||!f.trim()){j("Username and Access Key are required.");return}W(!0),j(null);try{const t=await de(S.trim(),g.trim(),f.trim());B(t),h(new Set),i("projects")}catch(t){j(t instanceof Error?t.message:"Failed to fetch projects")}finally{W(!1)}},L=t=>{h(d=>{const a=new Set(d);return a.has(t)?a.delete(t):a.add(t),a})},N=()=>{s.size===l.length?h(new Set):h(new Set(l.map(t=>String(t.project_id))))},J=async()=>{if(!m||s.size===0)return;const t=l.filter(p=>s.has(String(p.project_id))),d=t.map(p=>({projectId:String(p.project_id),name:p.name,status:"pending",foldersCreated:0,testsCreated:0,activity:"Queued"}));z(d),i("importing"),b(!0);const a=await fetch("/api/testmu/import",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:S.trim(),username:g.trim(),accessKey:f.trim(),appId:m,projects:t})});if(!a.body){b(!1),i("done");return}const c=a.body.getReader(),y=new TextDecoder;let I="";for(;;){const{done:p,value:H}=await c.read();if(p)break;I+=y.decode(H,{stream:!0});const _=I.split(`
|
|
2
|
+
|
|
3
|
+
`);I=_.pop()??"";for(const Q of _){const A=Q.trim();if(!A.startsWith("data:"))continue;let x;try{x=JSON.parse(A.slice(5).trim())}catch{continue}if(x.type==="done")break;if(!x.projectId)continue;const q=x.projectId;z(V=>V.map(n=>{if(n.projectId!==q)return n;switch(x.type){case"activity":return{...n,status:"running",activity:x.msg??n.activity};case"folder-created":return{...n,foldersCreated:n.foldersCreated+1};case"test-created":return{...n,testsCreated:n.testsCreated+1};case"project-done":return{...n,status:"done",activity:"Done"};case"project-error":return{...n,status:"error",error:x.error??"Import failed"};default:return n}}))}}b(!1),i("done")},w={width:"100%",boxSizing:"border-box",background:"var(--t-bg-surface)",border:"1px solid var(--t-border-default)",borderRadius:6,padding:"7px 10px",fontSize:"var(--t-text-base)",color:"var(--t-text-primary)",outline:"none",fontFamily:"inherit"},C={fontSize:"var(--t-text-sm)",fontWeight:500,color:"var(--t-text-muted)",marginBottom:6,display:"block"},k=l.length>0&&s.size===l.length;return e.jsxs(Y,{open:u,onOpenChange:t=>{!t&&!M&&v()},children:[e.jsxs(G,{children:[e.jsx(X,{style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.6)",backdropFilter:"blur(2px)",zIndex:50}}),e.jsxs(Z,{style:{position:"fixed",left:"50%",top:"50%",transform:"translate(-50%,-50%)",zIndex:51,width:580,maxWidth:"calc(100vw - 32px)",background:"var(--t-bg-panel)",border:"1px solid var(--t-border-default)",borderRadius:12,boxShadow:"0 24px 60px rgba(0,0,0,0.8)",maxHeight:"calc(100vh - 80px)",display:"flex",flexDirection:"column",overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"18px 24px 14px",borderBottom:"1px solid var(--t-border-subtle)",flexShrink:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[r==="projects"&&e.jsx("button",{onClick:()=>i("credentials"),style:{width:26,height:26,borderRadius:5,border:"none",background:"transparent",color:"var(--t-text-muted)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},onMouseEnter:t=>t.currentTarget.style.color="var(--t-text-secondary)",onMouseLeave:t=>t.currentTarget.style.color="var(--t-text-muted)",children:e.jsx(te,{size:14})}),e.jsxs("div",{children:[e.jsx("p",{style:{fontSize:"var(--t-text-xl)",fontWeight:600,color:"var(--t-text-primary)",margin:0},children:"Import from TestMu"}),e.jsxs("p",{style:{fontSize:"var(--t-text-sm)",color:"var(--t-text-muted)",margin:"2px 0 0"},children:[r==="credentials"&&"Connect to your TestMu workspace",r==="projects"&&`${l.length} project${l.length!==1?"s":""} found — select to import`,r==="importing"&&"Importing selected projects…",r==="done"&&"Import complete"]})]})]}),!M&&e.jsx(ee,{asChild:!0,children:e.jsx("button",{style:{width:28,height:28,borderRadius:6,border:"none",background:"transparent",color:"var(--t-text-muted)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},onMouseEnter:t=>t.currentTarget.style.color="var(--t-text-secondary)",onMouseLeave:t=>t.currentTarget.style.color="var(--t-text-muted)",children:e.jsx(re,{size:15})})})]}),e.jsxs("div",{style:{flex:1,overflowY:"auto"},children:[r==="credentials"&&e.jsxs("div",{style:{padding:"20px 24px"},children:[e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("label",{style:C,children:"API Base URL"}),e.jsx("input",{style:w,value:S,onChange:t=>D(t.target.value),spellCheck:!1,autoComplete:"off"}),e.jsxs("p",{style:{fontSize:"var(--t-text-xs)",color:"var(--t-text-muted)",marginTop:5},children:["EU region:"," ",e.jsx("code",{style:{fontFamily:"monospace"},children:"eu-test-manager-api.lambdatest.com/api/v1"})]})]}),e.jsxs("div",{style:{marginBottom:16},children:[e.jsxs("label",{style:C,children:["Username ",e.jsx("span",{style:{color:"var(--t-accent-danger, #e5484d)"},children:"*"})]}),e.jsx("input",{style:w,value:g,onChange:t=>E(t.target.value),placeholder:"your-lambdatest-username",autoFocus:!0,autoComplete:"username"})]}),e.jsxs("div",{children:[e.jsxs("label",{style:C,children:["Access Key ",e.jsx("span",{style:{color:"var(--t-accent-danger, #e5484d)"},children:"*"})]}),e.jsx("input",{style:w,type:"password",value:f,onChange:t=>O(t.target.value),placeholder:"••••••••••••••••",autoComplete:"current-password",onKeyDown:t=>{t.key==="Enter"&&U()}}),e.jsx("p",{style:{fontSize:"var(--t-text-xs)",color:"var(--t-text-muted)",marginTop:5},children:"LambdaTest → Profile → API Key"})]}),$&&e.jsx("p",{style:{fontSize:"var(--t-text-sm)",color:"var(--t-accent-danger, #e5484d)",marginTop:14},children:$})]}),r==="projects"&&e.jsxs("div",{children:[l.length>0&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"10px 24px",borderBottom:"1px solid var(--t-border-subtle)",cursor:"pointer"},onClick:N,children:[e.jsx("span",{style:{color:k?"var(--t-text-primary)":"var(--t-text-muted)",display:"flex"},children:k?e.jsx(F,{size:15}):e.jsx(T,{size:15})}),e.jsx("span",{style:{fontSize:"var(--t-text-sm)",fontWeight:500,color:"var(--t-text-muted)"},children:k?"Deselect all":"Select all"}),s.size>0&&e.jsxs("span",{style:{marginLeft:"auto",fontSize:"var(--t-text-xs)",color:"var(--t-text-muted)",background:"var(--t-bg-surface)",padding:"2px 8px",borderRadius:99},children:[s.size," selected"]})]}),l.length===0?e.jsx("div",{style:{padding:"48px 24px",textAlign:"center",color:"var(--t-text-muted)",fontSize:"var(--t-text-base)"},children:"No projects found in this workspace."}):e.jsx("ul",{style:{listStyle:"none",margin:0,padding:0},children:l.map((t,d)=>{const a=String(t.project_id),c=s.has(a);return e.jsxs("li",{onClick:()=>L(a),style:{display:"flex",alignItems:"center",gap:12,padding:"12px 24px",borderTop:d>0?"1px solid var(--t-border-subtle)":"none",cursor:"pointer",background:c?"var(--t-bg-hover)":"transparent",transition:"background 0.1s"},onMouseEnter:y=>{c||(y.currentTarget.style.background="var(--t-bg-hover)")},onMouseLeave:y=>{c||(y.currentTarget.style.background="transparent")},children:[e.jsx("span",{style:{color:c?"var(--t-text-primary)":"var(--t-text-muted)",display:"flex",flexShrink:0},children:c?e.jsx(F,{size:15}):e.jsx(T,{size:15})}),e.jsx("div",{style:{width:30,height:30,borderRadius:7,background:"var(--t-bg-surface)",border:"1px solid var(--t-border-subtle)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(se,{size:14,color:"var(--t-text-muted)"})}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("p",{style:{fontSize:"var(--t-text-base)",fontWeight:500,color:"var(--t-text-primary)",margin:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.name}),t.description&&e.jsx("p",{style:{fontSize:"var(--t-text-xs)",color:"var(--t-text-muted)",margin:"2px 0 0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.description})]}),t.test_case_count!==void 0&&e.jsxs("span",{style:{fontSize:"var(--t-text-xs)",padding:"2px 8px",borderRadius:99,background:"var(--t-bg-surface)",color:"var(--t-text-muted)",fontWeight:500,flexShrink:0},children:[t.test_case_count," tests"]})]},a)})})]}),(r==="importing"||r==="done")&&e.jsx("ul",{style:{listStyle:"none",margin:0,padding:0},children:K.map((t,d)=>e.jsxs("li",{style:{display:"flex",alignItems:"flex-start",gap:12,padding:"14px 24px",borderTop:d>0?"1px solid var(--t-border-subtle)":"none"},children:[e.jsxs("span",{style:{marginTop:2,flexShrink:0},children:[t.status==="pending"&&e.jsx(T,{size:15,color:"var(--t-border-default)"}),t.status==="running"&&e.jsx(ae,{size:15,color:"var(--t-text-muted)",style:{animation:"spin 1s linear infinite"}}),t.status==="done"&&e.jsx(ne,{size:15,color:"var(--t-accent-success, #1a9e5e)",weight:"fill"}),t.status==="error"&&e.jsx(oe,{size:15,color:"var(--t-accent-danger, #e5484d)",weight:"fill"})]}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("p",{style:{fontSize:"var(--t-text-base)",fontWeight:600,color:"var(--t-text-primary)",margin:0},children:t.name}),(t.foldersCreated>0||t.testsCreated>0)&&e.jsxs("p",{style:{fontSize:"var(--t-text-sm)",color:"var(--t-text-secondary)",margin:"4px 0 0",display:"flex",gap:12},children:[e.jsxs("span",{children:[t.foldersCreated," folder",t.foldersCreated!==1?"s":""]}),e.jsxs("span",{children:[t.testsCreated," test",t.testsCreated!==1?"s":""]})]}),t.status!=="done"&&!t.error&&e.jsx("p",{style:{fontSize:"var(--t-text-xs)",color:"var(--t-text-muted)",margin:"3px 0 0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.activity}),t.error&&e.jsx("p",{style:{fontSize:"var(--t-text-xs)",color:"var(--t-accent-danger, #e5484d)",margin:"3px 0 0"},children:t.error})]})]},t.projectId))})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:8,padding:"14px 24px",borderTop:"1px solid var(--t-border-subtle)",flexShrink:0},children:[e.jsx("div",{style:{fontSize:"var(--t-text-xs)",color:"var(--t-text-muted)"},children:r==="projects"&&s.size>0&&e.jsxs("span",{children:[s.size," project",s.size!==1?"s":""," selected → imported as spaces"]})}),e.jsxs("div",{style:{display:"flex",gap:8},children:[r!=="importing"&&e.jsx(P,{variant:"outline",size:"sm",onClick:v,children:r==="done"?"Close":"Cancel"}),r==="credentials"&&e.jsx(P,{size:"sm",onClick:()=>void U(),disabled:R||!g.trim()||!f.trim(),style:{gap:6},children:R?"Fetching…":e.jsxs(e.Fragment,{children:[e.jsx(ie,{size:13})," Search Projects"]})}),r==="projects"&&e.jsxs(P,{size:"sm",onClick:()=>void J(),disabled:s.size===0||!m,style:{gap:6},children:[e.jsx(le,{size:13}),"Import"," ",s.size>0?`${s.size} Project${s.size!==1?"s":""}`:""]})]})]})]})]}),e.jsx("style",{children:`
|
|
4
|
+
@keyframes spin { from { transform: rotate(0deg) } to { transform: rotate(360deg) } }
|
|
5
|
+
`})]})}export{me as TestMuImportDialog};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as p,j as t}from"./react-D-pHAthU.js";import{q as b,K as $,L as M,I as B,j as E,ag as A}from"./icons-J9gKYxTz.js";import{b as f,e as P,C as O}from"./index-a9kCDHqT.js";import"./radix-ui-Cxk3sw_C.js";function q(n,o){const r=new Map;for(const s of n)r.set(s.id,{...s,children:[],directTests:[]});const a=[];for(const s of n){const l=r.get(s.id),u=s.parentFolderId!=null?r.get(s.parentFolderId):null;u?u.children.push(l):a.push(l)}const i=[];for(const s of o){const l=r.get(s.folderId);l?l.directTests.push(s):i.push(s)}return{roots:a,orphanTests:i}}function C(n){let o=n.children.length,r=n.directTests.length;for(const a of n.children){const i=C(a);o+=i.folders,r+=i.tests}return{folders:o,tests:r}}function g(n){if(!n)return"";const o=Date.now()-new Date(n).getTime(),r=Math.floor(o/864e5);return r<1?"today":r===1?"1 day ago":`${r} days ago`}function Y({spaceId:n}){const[o,r]=p.useState({roots:[],orphanTests:[]}),[a,i]=p.useState(!0),[s,l]=p.useState(null),[u,z]=p.useState(new Set),x=p.useCallback(async()=>{i(!0);try{const e=await f.trash.list(n);r(q(e.folders,e.tests))}finally{i(!1)}},[n]);p.useEffect(()=>{x()},[x]);const R=e=>z(d=>{const c=new Set(d);return c.has(e)?c.delete(e):c.add(e),c}),D=async e=>{await f.trash.restoreTests(n,[e]),x()},I=async e=>{await f.trash.deleteTestPermanently(n,e),x()},F=async e=>{await f.trash.restoreFolders(n,[e]),x()},L=async e=>{await f.trash.deleteFolderPermanently(n,e),x()},j=o.roots.length===0&&o.orphanTests.length===0,T=(e,d)=>{const c=u.has(e.id),h=e.children.length>0||e.directTests.length>0,{folders:y,tests:m}=C(e),w=[y>0&&`${y} folder${y!==1?"s":""}`,m>0&&`${m} test${m!==1?"s":""}`].filter(Boolean).join(", ");return t.jsxs("div",{children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",height:44,paddingLeft:12+d*20,paddingRight:10,gap:6,borderRadius:6,border:"1px solid var(--t-border-subtle)",background:"var(--t-bg-surface)",marginBottom:2},children:[t.jsx("button",{onClick:()=>h&&R(e.id),style:{display:"flex",alignItems:"center",justifyContent:"center",width:16,height:16,background:"none",border:"none",cursor:h?"pointer":"default",color:h?"var(--t-text-muted)":"transparent",flexShrink:0,padding:0},children:c?t.jsx($,{size:11}):t.jsx(M,{size:11})}),t.jsx(B,{size:14,color:"var(--t-text-muted)",weight:"fill",style:{flexShrink:0}}),t.jsx("span",{style:{flex:1,fontSize:"var(--t-text-base)",color:"var(--t-text-secondary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name}),w&&t.jsx("span",{style:{fontSize:"var(--t-text-xs)",color:"var(--t-text-muted)",flexShrink:0},children:w}),g(e.trashedAt)&&t.jsx("span",{style:{fontSize:"var(--t-text-xs)",color:"var(--t-text-muted)",flexShrink:0},children:g(e.trashedAt)}),t.jsx(k,{onRestore:()=>F(e.id),onDelete:()=>l({id:e.id,label:e.name,kind:"folder"})})]}),!c&&h&&t.jsxs("div",{style:{marginBottom:2},children:[e.children.map(v=>T(v,d+1)),e.directTests.map(v=>S(v,d+1))]})]},e.id)},S=(e,d)=>t.jsxs("div",{style:{display:"flex",alignItems:"center",height:44,paddingLeft:12+d*20+22,paddingRight:10,gap:6,borderRadius:6,border:"1px solid var(--t-border-subtle)",background:"var(--t-bg-base)",marginBottom:2},children:[t.jsx(E,{size:13,color:"var(--t-text-muted)",style:{flexShrink:0}}),t.jsx("span",{style:{flex:1,fontSize:"var(--t-text-base)",color:"var(--t-text-secondary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.title}),t.jsx("span",{style:{fontSize:10,color:"var(--t-text-muted)",border:"1px solid var(--t-border-default)",borderRadius:4,padding:"1px 6px",flexShrink:0,textTransform:"uppercase",letterSpacing:.5},children:e.type}),g(e.trashedAt)&&t.jsx("span",{style:{fontSize:"var(--t-text-xs)",color:"var(--t-text-muted)",flexShrink:0},children:g(e.trashedAt)}),t.jsx(k,{onRestore:()=>D(e.id),onDelete:()=>l({id:e.id,label:e.title,kind:"test"})})]},e.id);return t.jsxs("div",{style:{flex:1,background:"var(--t-bg-base)",display:"flex",flexDirection:"column",overflow:"hidden"},children:[t.jsxs("div",{style:{padding:"18px 24px 12px 18px",borderBottom:"1px solid var(--t-border-subtle)",background:"var(--t-bg-elevated)",flexShrink:0},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[t.jsx(b,{size:20,color:"var(--t-text-muted)"}),t.jsx("span",{style:{fontSize:"var(--t-text-lg)",fontWeight:600,color:"var(--t-text-primary)"},children:"Trash"})]}),t.jsx("p",{style:{fontSize:"var(--t-text-sm)",color:"var(--t-text-muted)",marginTop:4},children:"Items in trash can be restored or permanently deleted."})]}),t.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"16px 24px"},children:[a&&t.jsx(P,{count:5,rowHeight:46,padding:"10px 0"}),!a&&j&&t.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",marginTop:80,gap:10,color:"var(--t-text-muted)"},children:[t.jsx(b,{size:32}),t.jsx("span",{style:{fontSize:"var(--t-text-base)"},children:"Trash is empty"})]}),!a&&!j&&t.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[o.roots.map(e=>T(e,0)),o.orphanTests.map(e=>S(e,0))]})]}),t.jsx(O,{open:s!==null,title:"Delete permanently",description:`"${s==null?void 0:s.label}" will be permanently deleted and cannot be recovered.`,confirmLabel:"Delete permanently",onConfirm:async()=>{s&&(s.kind==="test"?await I(s.id):await L(s.id),l(null))},onCancel:()=>l(null)})]})}function k({onRestore:n,onDelete:o}){return t.jsxs(t.Fragment,{children:[t.jsxs("button",{onClick:n,title:"Restore",style:{display:"flex",alignItems:"center",gap:4,fontSize:"var(--t-text-xs)",color:"var(--t-text-secondary)",background:"none",border:"1px solid var(--t-border-default)",borderRadius:5,padding:"3px 8px",cursor:"pointer",flexShrink:0},onMouseEnter:r=>{r.currentTarget.style.color="var(--t-text-primary)",r.currentTarget.style.borderColor="var(--t-border-strong)"},onMouseLeave:r=>{r.currentTarget.style.color="var(--t-text-secondary)",r.currentTarget.style.borderColor="var(--t-border-default)"},children:[t.jsx(A,{size:11}),"Restore"]}),t.jsx("button",{onClick:o,title:"Delete permanently",style:{display:"flex",alignItems:"center",padding:"3px 6px",background:"none",border:"1px solid transparent",borderRadius:5,cursor:"pointer",color:"var(--t-text-muted)",flexShrink:0},onMouseEnter:r=>{r.currentTarget.style.color="var(--t-accent-danger)",r.currentTarget.style.borderColor="var(--t-accent-danger)"},onMouseLeave:r=>{r.currentTarget.style.color="var(--t-text-muted)",r.currentTarget.style.borderColor="transparent"},children:t.jsx(b,{size:13})})]})}export{Y as TrashView};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as a,j as e}from"./react-D-pHAthU.js";import{r as O,b as R,c as N,q as X,J as Z}from"./icons-J9gKYxTz.js";import{b as i,B as d,I as c,K as q,e as ee}from"./index-a9kCDHqT.js";import"./radix-ui-Cxk3sw_C.js";function oe(){const[j,S]=a.useState([]),[W,z]=a.useState(!0),[s,g]=a.useState(null),[w,o]=a.useState(null),[G,h]=a.useState(!1),[x,k]=a.useState(""),[C,I]=a.useState(""),[F,u]=a.useState(!1),[f,M]=a.useState(""),[D,E]=a.useState(""),[n,p]=a.useState([]),[U,T]=a.useState(!1),[$,y]=a.useState(""),[B,l]=a.useState([]),[A,L]=a.useState(!1),b=a.useRef(null),v=a.useCallback(async()=>{z(!0);try{S(await i.groups.list())}catch{}finally{z(!1)}},[]);a.useEffect(()=>{v()},[v]);const Q=async t=>{g(t),u(!1),y(""),l([]),T(!0);try{p(await i.groups.members.list(t.id))}catch{p([])}finally{T(!1)}},Y=async()=>{if(x.trim()){o(null);try{await i.groups.create({name:x.trim(),description:C.trim()||void 0}),k(""),I(""),h(!1),await v()}catch(t){o(t.message)}}},H=async()=>{if(!(!s||!f.trim())){o(null);try{const t=await i.groups.update(s.id,{name:f.trim(),description:D.trim()||void 0});g(t),S(r=>r.map(m=>m.id===t.id?t:m)),u(!1)}catch(t){o(t.message)}}},J=async t=>{try{await i.groups.delete(t),(s==null?void 0:s.id)===t&&g(null),await v()}catch(r){o(r.message)}},K=t=>{if(y(t),b.current&&clearTimeout(b.current),t.length<2){l([]);return}L(!0),b.current=setTimeout(async()=>{try{l(await i.users.search(t))}catch{l([])}finally{L(!1)}},300)},P=async t=>{if(s)try{await i.groups.members.add(s.id,t),p(await i.groups.members.list(s.id)),y(""),l([])}catch(r){o(r.message)}},V=async t=>{if(s)try{await i.groups.members.remove(s.id,t),p(r=>r.filter(m=>m.userId!==t))}catch(r){o(r.message)}},_=new Set(n.map(t=>t.userId));return e.jsxs("div",{style:{flex:1,overflow:"hidden",display:"flex",flexDirection:"column",background:"var(--t-bg-base)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"0 28px",height:52,borderBottom:"1px solid var(--t-border-subtle)",background:"var(--t-bg-elevated)",flexShrink:0},children:[e.jsx(O,{size:15,color:"var(--t-text-muted)"}),e.jsx("span",{style:{fontSize:"var(--t-text-lg)",fontWeight:500,color:"var(--t-text-primary)"},children:"User Groups"})]}),w&&e.jsxs("div",{style:{margin:"8px 24px 0",padding:"8px 12px",borderRadius:6,background:"rgba(229,72,77,0.08)",border:"1px solid rgba(229,72,77,0.2)",fontSize:"var(--t-text-base)",color:"var(--t-accent-danger)"},children:[w,e.jsx("button",{onClick:()=>o(null),style:{float:"right",background:"none",border:"none",color:"var(--t-accent-danger)",cursor:"pointer"},children:e.jsx(R,{size:13})})]}),e.jsxs("div",{style:{display:"flex",flex:1,overflow:"hidden"},children:[e.jsxs("div",{style:{width:280,borderRight:"1px solid var(--t-border-subtle)",display:"flex",flexDirection:"column",overflow:"hidden",flexShrink:0},children:[e.jsx("div",{style:{padding:"12px 16px",borderBottom:"1px solid var(--t-border-subtle)"},children:e.jsxs(d,{size:"sm",variant:"outline",style:{width:"100%",gap:6},onClick:()=>{h(!0),o(null)},children:[e.jsx(N,{size:14})," New Group"]})}),G&&e.jsxs("div",{style:{padding:"10px 16px",borderBottom:"1px solid var(--t-border-subtle)",display:"flex",flexDirection:"column",gap:8},children:[e.jsx(c,{placeholder:"Group name",value:x,onChange:t=>k(t.target.value),style:{fontSize:"var(--t-text-base)"},autoFocus:!0}),e.jsx(c,{placeholder:"Description (optional)",value:C,onChange:t=>I(t.target.value),style:{fontSize:"var(--t-text-sm)"}}),e.jsxs("div",{style:{display:"flex",gap:6},children:[e.jsx(d,{size:"sm",onClick:()=>void Y(),disabled:!x.trim(),children:"Create"}),e.jsx(d,{size:"sm",variant:"outline",onClick:()=>{h(!1),o(null)},children:"Cancel"})]})]}),e.jsx("div",{style:{overflowY:"auto",flex:1},children:W?Array.from({length:4}).map((t,r)=>e.jsx(q,{i:r},r)):j.length===0?e.jsx("p",{style:{padding:16,fontSize:"var(--t-text-base)",color:"var(--t-text-muted)",margin:0,fontStyle:"italic"},children:"No groups yet. Create one above."}):j.map(t=>e.jsxs("div",{onClick:()=>void Q(t),style:{padding:"10px 16px",cursor:"pointer",background:(s==null?void 0:s.id)===t.id?"var(--t-bg-surface)":"transparent",display:"flex",alignItems:"center",justifyContent:"space-between",borderBottom:"1px solid var(--t-border-subtle)",borderLeft:(s==null?void 0:s.id)===t.id?"2px solid var(--t-border-strong)":"2px solid transparent"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"var(--t-text-base)",fontWeight:500,color:"var(--t-text-primary)"},children:t.name}),t.description&&e.jsx("div",{style:{fontSize:"var(--t-text-xs)",color:"var(--t-text-muted)",marginTop:2},children:t.description})]}),e.jsx("button",{onClick:r=>{r.stopPropagation(),J(t.id)},style:{background:"none",border:"none",color:"var(--t-text-muted)",cursor:"pointer",padding:4,opacity:.7},title:"Delete group",onMouseEnter:r=>r.currentTarget.style.color="var(--t-accent-danger)",onMouseLeave:r=>r.currentTarget.style.color="var(--t-text-muted)",children:e.jsx(X,{size:14})})]},t.id))})]}),e.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden"},children:s?e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{padding:"16px 24px",borderBottom:"1px solid var(--t-border-subtle)",flexShrink:0},children:F?e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[e.jsx(c,{value:f,onChange:t=>M(t.target.value),style:{fontSize:"var(--t-text-base)"},autoFocus:!0}),e.jsx(c,{value:D,onChange:t=>E(t.target.value),placeholder:"Description",style:{fontSize:"var(--t-text-sm)"}}),e.jsxs("div",{style:{display:"flex",gap:6},children:[e.jsx(d,{size:"sm",onClick:()=>void H(),children:"Save"}),e.jsx(d,{size:"sm",variant:"outline",onClick:()=>u(!1),children:"Cancel"})]})]}):e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"var(--t-text-xl)",fontWeight:600,color:"var(--t-text-primary)"},children:s.name}),s.description&&e.jsx("div",{style:{fontSize:"var(--t-text-sm)",color:"var(--t-text-muted)",marginTop:3},children:s.description}),e.jsxs("div",{style:{fontSize:"var(--t-text-xs)",color:"var(--t-text-muted)",marginTop:4},children:[n.length," member",n.length!==1?"s":""]})]}),e.jsx("button",{onClick:()=>{u(!0),M(s.name),E(s.description??"")},style:{background:"none",border:"none",color:"var(--t-text-muted)",cursor:"pointer",padding:4},title:"Edit group",children:e.jsx(Z,{size:15})})]})}),e.jsxs("div",{style:{padding:"10px 24px",borderBottom:"1px solid var(--t-border-subtle)",position:"relative",flexShrink:0},children:[e.jsx(c,{placeholder:"Search users to add…",value:$,onChange:t=>K(t.target.value),style:{fontSize:"var(--t-text-base)"}}),B.length>0&&e.jsx("div",{style:{position:"absolute",left:24,right:24,top:"100%",background:"var(--t-bg-elevated)",border:"1px solid var(--t-border-default)",borderRadius:6,zIndex:10,overflow:"hidden"},children:B.filter(t=>!_.has(t.id)).map(t=>e.jsxs("div",{onClick:()=>void P(t.id),style:{padding:"8px 14px",cursor:"pointer",fontSize:"var(--t-text-base)",color:"var(--t-text-secondary)",borderBottom:"1px solid var(--t-border-subtle)",display:"flex",alignItems:"center",gap:8},onMouseEnter:r=>r.currentTarget.style.background="var(--t-bg-surface)",onMouseLeave:r=>r.currentTarget.style.background="transparent",children:[e.jsx(N,{size:13,color:"var(--t-text-muted)"}),e.jsx("span",{children:t.name||t.email}),t.name&&e.jsxs("span",{style:{color:"var(--t-text-muted)",fontSize:"var(--t-text-xs)"},children:["(",t.email,")"]}),A&&e.jsx("span",{style:{color:"var(--t-text-muted)",fontSize:"var(--t-text-xs)"},children:"…"})]},t.id))})]}),e.jsx("div",{style:{flex:1,overflowY:"auto"},children:U?e.jsx(ee,{count:4,rowHeight:44,padding:"8px 16px",iconSize:24}):n.length===0?e.jsx("p",{style:{padding:24,fontSize:"var(--t-text-base)",color:"var(--t-text-muted)",margin:0,fontStyle:"italic"},children:"No members yet — search above to add."}):n.map(t=>e.jsxs("div",{style:{padding:"11px 24px",display:"flex",alignItems:"center",gap:12,borderBottom:"1px solid var(--t-border-subtle)"},children:[e.jsx("div",{style:{width:30,height:30,borderRadius:"50%",background:"var(--t-bg-elevated)",border:"1px solid var(--t-border-default)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,fontSize:"var(--t-text-sm)",fontWeight:700,color:"var(--t-text-primary)"},children:(t.name??t.email).charAt(0).toUpperCase()}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontSize:"var(--t-text-base)",color:"var(--t-text-primary)",fontWeight:500},children:t.name??t.email}),t.name&&e.jsx("div",{style:{fontSize:"var(--t-text-xs)",color:"var(--t-text-muted)"},children:t.email})]}),e.jsx("button",{onClick:()=>void V(t.userId),style:{background:"none",border:"none",color:"var(--t-text-muted)",cursor:"pointer",padding:4},title:"Remove from group",onMouseEnter:r=>r.currentTarget.style.color="var(--t-accent-danger)",onMouseLeave:r=>r.currentTarget.style.color="var(--t-text-muted)",children:e.jsx(R,{size:14})})]},t.id))})]}):e.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx("p",{style:{fontSize:"var(--t-text-base)",color:"var(--t-text-muted)",margin:0},children:"Select a group to manage its members."})})})]})]})}export{oe as UserGroupsView};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as s,j as e}from"./react-D-pHAthU.js";import{v as R,U as E,E as T,c as A,aK as B,aw as P,J as L,q as F}from"./icons-J9gKYxTz.js";import{D as M,E as U,F as $,G as O,L as b,I as z,H,B as y,b as j,e as N,C as W}from"./index-a9kCDHqT.js";import{D as q,a as J,f as _,b as G}from"./radix-ui-Cxk3sw_C.js";function K({open:t,user:n,onClose:d,onSaved:i}){const r=n!==null,[p,l]=s.useState(""),[u,c]=s.useState(""),[x,g]=s.useState(""),[v,a]=s.useState("member"),[h,m]=s.useState(!0),[f,S]=s.useState(null),[k,w]=s.useState(!1);s.useEffect(()=>{n?(l(n.name??""),c(n.email),a(n.globalRole),m(n.isActive),g("")):(l(""),c(""),g(""),a("member"),m(!0)),S(null)},[n,t]);async function I(o){o.preventDefault(),S(null),w(!0);try{if(r)await j.users.update(n.id,{name:p,email:u,globalRole:v,isActive:h});else{if(!x){S("Password is required"),w(!1);return}await j.users.create({email:u,name:p,password:x,globalRole:v})}i()}catch(D){S(D instanceof Error?D.message:"Save failed")}finally{w(!1)}}return e.jsx(M,{open:t,onOpenChange:o=>{o||d()},children:e.jsxs(U,{children:[e.jsx($,{children:e.jsx(O,{children:r?"Edit user":"New user"})}),e.jsxs("form",{onSubmit:I,style:{display:"flex",flexDirection:"column",gap:14,marginTop:4},children:[f&&e.jsx("div",{style:{background:"rgba(229,72,77,0.1)",border:"1px solid rgba(229,72,77,0.3)",borderRadius:6,padding:"10px 14px",color:"var(--t-accent-danger)",fontSize:"var(--t-text-base)"},children:f}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[e.jsx(b,{style:{color:"var(--t-text-secondary)",fontSize:"var(--t-text-sm)"},children:"Name"}),e.jsx(z,{value:p,onChange:o=>l(o.target.value),placeholder:"Jane Smith"})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[e.jsxs(b,{style:{color:"var(--t-text-secondary)",fontSize:"var(--t-text-sm)"},children:["Email ",e.jsx("span",{style:{color:"var(--t-accent-danger)"},children:"*"})]}),e.jsx(z,{type:"email",value:u,onChange:o=>c(o.target.value),placeholder:"jane@company.com",required:!0})]}),!r&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[e.jsxs(b,{style:{color:"var(--t-text-secondary)",fontSize:"var(--t-text-sm)"},children:["Password ",e.jsx("span",{style:{color:"var(--t-accent-danger)"},children:"*"})]}),e.jsx(z,{type:"password",value:x,onChange:o=>g(o.target.value),placeholder:"Min 8 characters"})]}),e.jsxs("div",{style:{display:"flex",gap:12},children:[e.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:6},children:[e.jsx(b,{style:{color:"var(--t-text-secondary)",fontSize:"var(--t-text-sm)"},children:"Role"}),e.jsxs("select",{value:v,onChange:o=>a(o.target.value),style:{height:36,borderRadius:6,padding:"0 10px",fontSize:"var(--t-text-base)",background:"var(--t-bg-elevated)",border:"1px solid var(--t-border-default)",color:"var(--t-text-primary)",cursor:"pointer"},children:[e.jsx("option",{value:"member",children:"Member"}),e.jsx("option",{value:"super_admin",children:"Super Admin"})]})]}),r&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[e.jsx(b,{style:{color:"var(--t-text-secondary)",fontSize:"var(--t-text-sm)"},children:"Status"}),e.jsxs("select",{value:h?"active":"inactive",onChange:o=>m(o.target.value==="active"),style:{height:36,borderRadius:6,padding:"0 10px",fontSize:"var(--t-text-base)",background:"var(--t-bg-elevated)",border:"1px solid var(--t-border-default)",color:"var(--t-text-primary)",cursor:"pointer"},children:[e.jsx("option",{value:"active",children:"Active"}),e.jsx("option",{value:"inactive",children:"Inactive"})]})]})]}),e.jsxs(H,{style:{marginTop:4},children:[e.jsx(y,{type:"button",variant:"outline",size:"sm",onClick:d,children:"Cancel"}),e.jsx(y,{type:"submit",size:"sm",disabled:k,children:k?"Saving…":r?"Save changes":"Create user"})]})]})]})})}function V({user:t,onClose:n}){const[d,i]=s.useState(!1),[r,p]=s.useState(null),[l,u]=s.useState(null),[c,x]=s.useState(!1);async function g(){p(null),i(!0);try{const a=await j.users.resetPassword(t.id);u(a)}catch(a){p(a instanceof Error?a.message:"Reset failed")}finally{i(!1)}}function v(){l!=null&&l.tempPassword&&(navigator.clipboard.writeText(l.tempPassword),x(!0),setTimeout(()=>x(!1),2e3))}return e.jsx(q,{open:!0,onOpenChange:a=>{a||n()},children:e.jsxs(J,{children:[e.jsx(_,{style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.6)",backdropFilter:"blur(2px)",zIndex:50}}),e.jsxs(G,{style:{position:"fixed",left:"50%",top:"50%",transform:"translate(-50%,-50%)",zIndex:51,width:420,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.4)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:16},children:[e.jsx("div",{style:{width:36,height:36,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(R,{size:18,weight:"fill",color:"var(--t-text-muted)"})}),e.jsxs("div",{children:[e.jsx("p",{style:{fontSize:"var(--t-text-lg)",fontWeight:600,color:"var(--t-text-primary)",margin:0},children:"Reset password"}),e.jsx("p",{style:{fontSize:"var(--t-text-sm)",color:"var(--t-text-muted)",margin:"2px 0 0"},children:t.name??t.email})]})]}),r&&e.jsx("div",{style:{background:"rgba(229,72,77,0.1)",border:"1px solid rgba(229,72,77,0.3)",borderRadius:6,padding:"10px 14px",color:"#e5484d",fontSize:"var(--t-text-base)",marginBottom:16},children:r}),l?e.jsxs(e.Fragment,{children:[l.tempPassword?e.jsxs(e.Fragment,{children:[e.jsx("p",{style:{fontSize:"var(--t-text-base)",color:"var(--t-text-secondary)",marginBottom:12},children:"Share this temporary password with the user. It will prompt them to change it on next login."}),e.jsxs("div",{style:{background:"var(--t-bg-elevated)",border:"1px solid var(--t-border-default)",borderRadius:8,padding:"14px 16px",display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:20},children:[e.jsx("code",{style:{fontSize:18,fontWeight:700,color:"var(--t-text-primary)",letterSpacing:"0.1em"},children:l.tempPassword}),e.jsxs("button",{onClick:v,title:"Copy",style:{background:"none",border:"none",cursor:"pointer",color:c?"#3dd68c":"var(--t-text-muted)",display:"flex",alignItems:"center",gap:4,fontSize:"var(--t-text-sm)"},children:[c?e.jsx(E,{size:16,weight:"fill",color:"#3dd68c"}):e.jsx(T,{size:16}),c?"Copied":"Copy"]})]})]}):e.jsxs("p",{style:{fontSize:"var(--t-text-base)",color:"var(--t-text-secondary)",marginBottom:20},children:["A reset link has been sent to"," ",e.jsx("strong",{style:{color:"var(--t-text-primary)"},children:t.email}),". It expires in 30 minutes."]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(y,{size:"sm",onClick:n,children:"Done"})})]}):e.jsxs(e.Fragment,{children:[e.jsxs("p",{style:{fontSize:"var(--t-text-base)",color:"var(--t-text-secondary)",lineHeight:1.6,marginBottom:20},children:["Depending on your auth configuration, this will either:",e.jsx("br",{}),"• ",e.jsx("strong",{style:{color:"var(--t-text-primary)"},children:"Email mode"})," — send a reset link to ",t.email,e.jsx("br",{}),"• ",e.jsx("strong",{style:{color:"var(--t-text-primary)"},children:"Admin mode"})," — generate a temporary password shown below"]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(y,{variant:"outline",size:"sm",onClick:n,children:"Cancel"}),e.jsx(y,{size:"sm",disabled:d,onClick:()=>void g(),children:d?"Resetting…":"Reset password"})]})]})]})]})})}function Q({user:t,onEdit:n,onResetPassword:d,onDelete:i}){return e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 180px 100px 80px 120px",alignItems:"center",padding:"10px 16px",borderBottom:"1px solid var(--t-border-subtle)",gap:8},onMouseEnter:r=>r.currentTarget.style.background="var(--t-bg-hover)",onMouseLeave:r=>r.currentTarget.style.background="transparent",children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"var(--t-text-base)",fontWeight:500,color:"var(--t-text-primary)"},children:t.name??"—"}),e.jsx("div",{style:{fontSize:"var(--t-text-sm)",color:"var(--t-text-muted)"},children:t.email})]}),e.jsx("div",{style:{fontSize:"var(--t-text-sm)",color:"var(--t-text-muted)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.createdAt?new Date(t.createdAt).toLocaleDateString():"—"}),e.jsx("div",{children:t.globalRole==="super_admin"?e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,fontSize:"var(--t-text-xs)",color:"var(--t-text-primary)",background:"var(--t-bg-surface)",border:"1px solid var(--t-border-default)",borderRadius:6,padding:"2px 8px"},children:[e.jsx(B,{size:10,weight:"fill"})," Admin"]}):e.jsx("span",{style:{fontSize:"var(--t-text-xs)",color:"var(--t-text-muted)",background:"var(--t-bg-elevated)",border:"1px solid var(--t-border-subtle)",borderRadius:6,padding:"2px 8px"},children:"Member"})}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[t.isActive?e.jsx(E,{size:14,weight:"fill",color:"#3dd68c"}):e.jsx(P,{size:14,weight:"fill",color:"#e5484d"}),e.jsx("span",{style:{fontSize:"var(--t-text-sm)",color:t.isActive?"#3dd68c":"#e5484d"},children:t.isActive?"Active":"Inactive"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4,justifyContent:"flex-end"},children:[e.jsx(C,{title:"Edit",onClick:()=>n(t),children:e.jsx(L,{size:13})}),e.jsx(C,{title:"Reset password",onClick:()=>d(t),children:e.jsx(R,{size:13})}),e.jsx(C,{title:"Delete",danger:!0,onClick:()=>i(t),children:e.jsx(F,{size:13})})]})]})}function C({children:t,title:n,onClick:d,danger:i}){return e.jsx("button",{title:n,onClick:d,style:{display:"flex",alignItems:"center",justifyContent:"center",width:26,height:26,border:"none",borderRadius:6,background:"transparent",color:i?"#e5484d":"var(--t-text-secondary)",cursor:"pointer"},onMouseEnter:r=>{r.currentTarget.style.background=i?"rgba(229,72,77,0.1)":"var(--t-bg-hover)",r.currentTarget.style.color=i?"#e5484d":"var(--t-text-primary)"},onMouseLeave:r=>{r.currentTarget.style.background="transparent",r.currentTarget.style.color=i?"#e5484d":"var(--t-text-secondary)"},children:t})}function X(){return e.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 180px 100px 80px 120px",padding:"8px 16px",borderBottom:"1px solid var(--t-border-subtle)",gap:8},children:["User","Joined","Role","Status",""].map(t=>e.jsx("div",{style:{fontSize:11,fontWeight:600,color:"var(--t-text-muted)",textTransform:"uppercase",letterSpacing:"0.06em"},children:t},t))})}function re(){const[t,n]=s.useState([]),[d,i]=s.useState(!0),[r,p]=s.useState(null),[l,u]=s.useState(!1),[c,x]=s.useState(null),[g,v]=s.useState(null),[a,h]=s.useState(null),m=s.useCallback(async()=>{i(!0),p(null);try{n(await j.users.list())}catch(f){p(f instanceof Error?f.message:"Failed to load users")}finally{i(!1)}},[]);return s.useEffect(()=>{m()},[m]),e.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden",background:"var(--t-bg-base)"},children:[e.jsxs("div",{style:{padding:"20px 24px 16px 18px",borderBottom:"1px solid var(--t-border-subtle)",background:"var(--t-bg-elevated)",display:"flex",alignItems:"center",justifyContent:"space-between",flexShrink:0},children:[e.jsxs("div",{children:[e.jsx("h1",{style:{fontSize:"var(--t-text-xl)",fontWeight:600,color:"var(--t-text-primary)",margin:0},children:"User Management"}),e.jsxs("p",{style:{fontSize:"var(--t-text-sm)",color:"var(--t-text-muted)",margin:"4px 0 0"},children:[t.length," user",t.length!==1?"s":""]})]}),e.jsxs(y,{size:"sm",onClick:()=>u(!0),style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(A,{size:14,weight:"bold"})," New user"]})]}),e.jsxs("div",{style:{flex:1,overflow:"auto"},children:[d&&e.jsx(N,{count:6,rowHeight:52,padding:"12px 16px"}),r&&e.jsx("div",{style:{padding:32,textAlign:"center",color:"var(--t-accent-danger)",fontSize:"var(--t-text-base)"},children:r}),!d&&!r&&e.jsxs(e.Fragment,{children:[e.jsx(X,{}),t.length===0?e.jsx("div",{style:{padding:48,textAlign:"center",color:"var(--t-text-muted)",fontSize:"var(--t-text-base)"},children:"No users yet. Create one to get started."}):t.map(f=>e.jsx(Q,{user:f,onEdit:x,onResetPassword:v,onDelete:h},f.id))]})]}),e.jsx(K,{open:l||c!==null,user:c,onClose:()=>{u(!1),x(null)},onSaved:()=>{u(!1),x(null),m()}}),g&&e.jsx(V,{user:g,onClose:()=>v(null)}),e.jsx(W,{open:a!==null,title:`Delete ${(a==null?void 0:a.name)??(a==null?void 0:a.email)??"user"}?`,description:"This will permanently remove the user and revoke all their sessions and API tokens.",confirmLabel:"Delete user",onConfirm:async()=>{a&&(await j.users.delete(a.id),h(null),m())},onCancel:()=>h(null)})]})}export{re as UsersView};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import{r as m,j as t,a as O}from"./react-D-pHAthU.js";import{al as q,am as K,ao as N,ap as U,aq as F,ar as P,as as G,n as H,a as J,x as V,aO as Y,J as Z,q as Q}from"./icons-J9gKYxTz.js";import{u as X,b as ee,d as te,e as ne,f as _,E as ie}from"./tiptap-Ch64zYGz.js";import{B as T,b as C}from"./index-a9kCDHqT.js";const A=new Map;async function re(e){if(A.has(e))return A.get(e);try{const n=await C.mentionables.list(e);return A.set(e,n),n}catch{return[]}}function se({state:e}){return!e.command||!e.rect||e.items.length===0?null:O.createPortal(t.jsx("div",{style:{position:"fixed",top:e.rect.bottom+4,left:e.rect.left,zIndex:9999,minWidth:180,maxWidth:260,background:"var(--t-bg-panel)",border:"1px solid var(--t-border-default)",borderRadius:8,padding:4,boxShadow:"var(--t-shadow-lg)"},children:e.items.map((n,s)=>t.jsxs("button",{type:"button",onMouseDown:d=>{var a;d.preventDefault(),(a=e.command)==null||a.call(e,n)},style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"6px 8px",borderRadius:5,border:"none",cursor:"pointer",textAlign:"left",background:s===e.selectedIndex?"var(--t-bg-elevated)":"transparent",color:"var(--t-text-primary)",fontSize:"var(--t-text-sm)"},children:[n.type==="group"?t.jsx(H,{size:14,color:"var(--t-text-muted)"}):t.jsx(J,{size:14,color:"var(--t-text-muted)"}),t.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:n.label})]},n.id))}),document.body)}function z({icon:e,title:n,active:s,onClick:d}){return t.jsx("button",{type:"button",title:n,onMouseDown:a=>{a.preventDefault(),d()},style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:26,height:26,borderRadius:5,border:`1px solid ${s?"var(--t-border-default)":"transparent"}`,background:s?"var(--t-bg-elevated)":"transparent",color:s?"var(--t-text-primary)":"var(--t-text-muted)",cursor:"pointer",padding:0,transition:"all 0.1s"},onMouseEnter:a=>{if(!s){const r=a.currentTarget;r.style.background="var(--t-bg-elevated)",r.style.color="var(--t-text-secondary)"}},onMouseLeave:a=>{if(!s){const r=a.currentTarget;r.style.background="transparent",r.style.color="var(--t-text-muted)"}},children:e})}function le({editor:e}){const n=_({editor:e,selector:s=>{var d,a,r,h,c,u,w;return{bold:((d=s.editor)==null?void 0:d.isActive("bold"))??!1,italic:((a=s.editor)==null?void 0:a.isActive("italic"))??!1,strike:((r=s.editor)==null?void 0:r.isActive("strike"))??!1,code:((h=s.editor)==null?void 0:h.isActive("code"))??!1,bulletList:((c=s.editor)==null?void 0:c.isActive("bulletList"))??!1,orderedList:((u=s.editor)==null?void 0:u.isActive("orderedList"))??!1,blockquote:((w=s.editor)==null?void 0:w.isActive("blockquote"))??!1}}});return t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:1,padding:"4px 6px",borderBottom:"1px solid var(--t-border-subtle)"},children:[t.jsx(z,{icon:t.jsx(q,{size:13,weight:"bold"}),title:"Bold (⌘B)",active:n==null?void 0:n.bold,onClick:()=>e.chain().focus().toggleBold().run()}),t.jsx(z,{icon:t.jsx(K,{size:13}),title:"Italic (⌘I)",active:n==null?void 0:n.italic,onClick:()=>e.chain().focus().toggleItalic().run()}),t.jsx(z,{icon:t.jsx(N,{size:13}),title:"Strikethrough",active:n==null?void 0:n.strike,onClick:()=>e.chain().focus().toggleStrike().run()}),t.jsx(z,{icon:t.jsx(U,{size:13}),title:"Inline code",active:n==null?void 0:n.code,onClick:()=>e.chain().focus().toggleCode().run()}),t.jsx("div",{style:{width:1,height:16,background:"var(--t-border-subtle)",margin:"0 3px"}}),t.jsx(z,{icon:t.jsx(F,{size:13}),title:"Bullet list",active:n==null?void 0:n.bulletList,onClick:()=>e.chain().focus().toggleBulletList().run()}),t.jsx(z,{icon:t.jsx(P,{size:13}),title:"Ordered list",active:n==null?void 0:n.orderedList,onClick:()=>e.chain().focus().toggleOrderedList().run()}),t.jsx(z,{icon:t.jsx(G,{size:13}),title:"Blockquote",active:n==null?void 0:n.blockquote,onClick:()=>e.chain().focus().toggleBlockquote().run()})]})}function L({appId:e,value:n,placeholder:s,onSubmit:d,onCancel:a,submitLabel:r="Comment",autoFocus:h=!1}){const[c,u]=m.useState(!1),[w,y]=m.useState({items:[],command:null,rect:null,selectedIndex:0}),S=m.useRef(w);S.current=w;const x=X({extensions:[ee.configure({heading:!1,codeBlock:!1,horizontalRule:!1}),te.configure({placeholder:s??"Write a comment…",emptyEditorClass:"is-editor-empty"}),ne.configure({HTMLAttributes:{class:"mention"},renderText({node:o}){return`@${o.attrs.label??o.attrs.id}`},suggestion:{char:"@",items:async({query:o})=>{const f=await re(e),i=o.toLowerCase();return f.filter(l=>l.label.toLowerCase().includes(i)).slice(0,5)},render:()=>({onStart:o=>{var f;y({items:o.items,command:i=>o.command({id:i.id,label:i.label}),rect:((f=o.clientRect)==null?void 0:f.call(o))??null,selectedIndex:0})},onUpdate:o=>{var f;y({items:o.items,command:i=>o.command({id:i.id,label:i.label}),rect:((f=o.clientRect)==null?void 0:f.call(o))??null,selectedIndex:0})},onKeyDown:o=>{var i;const f=S.current;if(!f.items.length)return!1;if(o.event.key==="ArrowDown")return y(l=>({...l,selectedIndex:(l.selectedIndex+1)%l.items.length})),!0;if(o.event.key==="ArrowUp")return y(l=>({...l,selectedIndex:(l.selectedIndex-1+l.items.length)%l.items.length})),!0;if(o.event.key==="Enter"){const l=f.items[f.selectedIndex];return l&&((i=f.command)==null||i.call(f,l)),!0}return o.event.key==="Escape"?(y({items:[],command:null,rect:null,selectedIndex:0}),!0):!1},onExit:()=>{y({items:[],command:null,rect:null,selectedIndex:0})}})}})],content:n||"",autofocus:h?"end":!1});m.useEffect(()=>{if(!x)return;const o=x.isEmpty?"":x.getHTML();n!=null&&o!==n&&x.commands.setContent(n||"",!1)},[x,n]);const k=_({editor:x,selector:o=>{var f;return((f=o.editor)==null?void 0:f.isEmpty)??!0}}),p=async()=>{if(!(!x||k||c)){u(!0);try{await d(x.getHTML()),x.commands.clearContent(!0)}finally{u(!1)}}};return x?t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[t.jsxs("div",{className:"comment-editor-wrap",style:{border:"1px solid var(--t-border-subtle)",borderRadius:"var(--t-radius)",background:"var(--t-bg-surface)",overflow:"hidden",transition:"border-color 0.15s"},onKeyDown:o=>{(o.metaKey||o.ctrlKey)&&o.key==="Enter"&&(o.preventDefault(),p())},children:[t.jsx(le,{editor:x}),t.jsx("div",{style:{padding:"8px 10px"},children:t.jsx(ie,{editor:x})})]}),t.jsxs("div",{style:{display:"flex",gap:6,justifyContent:"flex-end"},children:[a&&t.jsx(T,{variant:"outline",size:"sm",type:"button",onClick:a,children:"Cancel"}),t.jsx(T,{size:"sm",type:"button",onClick:()=>void p(),disabled:c||k,children:r})]}),t.jsx(se,{state:w}),t.jsx("style",{children:`
|
|
2
|
+
.tiptap { outline: none; }
|
|
3
|
+
.tiptap {
|
|
4
|
+
font-size: var(--t-text-sm);
|
|
5
|
+
line-height: 1.6;
|
|
6
|
+
color: var(--t-text-primary);
|
|
7
|
+
font-family: inherit;
|
|
8
|
+
min-height: 72px;
|
|
9
|
+
}
|
|
10
|
+
.comment-editor-wrap:focus-within {
|
|
11
|
+
border-color: var(--t-border-strong) !important;
|
|
12
|
+
}
|
|
13
|
+
.tiptap p { margin: 0 0 4px; }
|
|
14
|
+
.tiptap p:last-child { margin-bottom: 0; }
|
|
15
|
+
.tiptap ul, .tiptap ol { padding-left: 20px; margin: 4px 0; }
|
|
16
|
+
.tiptap li { margin: 2px 0; }
|
|
17
|
+
.tiptap strong { font-weight: 600; }
|
|
18
|
+
.tiptap em { font-style: italic; }
|
|
19
|
+
.tiptap code { background: var(--t-bg-elevated); padding: 1px 4px; border-radius: 3px; font-size: 0.9em; }
|
|
20
|
+
.tiptap blockquote { border-left: 3px solid var(--t-border-default); padding-left: 12px; margin: 4px 0; color: var(--t-text-muted); }
|
|
21
|
+
.tiptap .mention {
|
|
22
|
+
color: var(--t-text-primary);
|
|
23
|
+
background: var(--t-bg-elevated);
|
|
24
|
+
border-radius: 4px;
|
|
25
|
+
padding: 0 3px;
|
|
26
|
+
font-weight: 500;
|
|
27
|
+
}
|
|
28
|
+
.tiptap p.is-editor-empty:first-child::before {
|
|
29
|
+
color: var(--t-text-muted);
|
|
30
|
+
content: attr(data-placeholder);
|
|
31
|
+
float: left;
|
|
32
|
+
height: 0;
|
|
33
|
+
pointer-events: none;
|
|
34
|
+
}
|
|
35
|
+
`})]}):null}const g=new Map;let D=null;const me=()=>[...g.keys()].filter(e=>!e.startsWith("analysis:")).length,he=()=>{for(const e of[...g.keys()])e.startsWith("analysis:")||g.delete(e)},pe=()=>[...g.keys()].filter(e=>e.startsWith("analysis:")).length,ye=()=>{for(const e of[...g.keys()])e.startsWith("analysis:")&&g.delete(e)};function ae(e){var s,d,a;const n=((s=e.author)==null?void 0:s.name)||((d=e.author)==null?void 0:d.email)||e.createdBy;return(((a=n==null?void 0:n.trim())==null?void 0:a[0])??"?").toUpperCase()}function oe(e){var n,s;return((n=e.author)==null?void 0:n.name)||((s=e.author)==null?void 0:s.email)||`User ${e.createdBy}`}function de(e){const n=e.includes("T")?e:e.replace(" ","T")+"Z",s=new Date(n).getTime();if(Number.isNaN(s))return"";const d=Math.max(0,Date.now()-s),a=Math.floor(d/1e3);if(a<45)return"just now";const r=Math.floor(a/60);if(r<60)return`${r}m ago`;const h=Math.floor(r/60);if(h<24)return`${h}h ago`;const c=Math.floor(h/24);if(c<30)return`${c}d ago`;const u=Math.floor(c/30);return u<12?`${u}mo ago`:`${Math.floor(u/12)}y ago`}const E=new Map,$={admin:{bg:"rgba(245,158,11,0.12)",color:"#d97706",label:"Admin"},editor:{bg:"rgba(34,197,94,0.10)",color:"#16a34a",label:"Editor"},viewer:{bg:"rgba(99,102,241,0.10)",color:"#6366f1",label:"Viewer"},super_admin:{bg:"rgba(168,85,247,0.12)",color:"#9333ea",label:"Super Admin"}};function B({role:e}){const n=$[e]??$.viewer;return t.jsx("span",{style:{display:"inline-block",padding:"1px 7px",borderRadius:99,fontSize:11,fontWeight:600,background:n.bg,color:n.color,whiteSpace:"nowrap"},children:n.label})}function ce({id:e,label:n,rect:s,appId:d}){var k;const a=`${d}::${e}`,[r,h]=m.useState(E.get(a)??null),[c,u]=m.useState(!E.has(a));m.useEffect(()=>{if(E.has(a))return;let p=!1;return C.mentionables.detail(d,e).then(o=>{p||(E.set(a,o),h(o))}).catch(()=>{}).finally(()=>{p||u(!1)}),()=>{p=!0}},[a,d,e]);const w=e.startsWith("group::"),y=c?62:(r==null?void 0:r.type)==="user"?r.spaces.length?120:84:r!=null&&r.spaces.length?120:84,S=window.innerHeight-s.bottom<y+16?s.top-y-6:s.bottom+6,x=((k=n.trim()[0])==null?void 0:k.toUpperCase())??"?";return O.createPortal(t.jsxs("div",{style:{position:"fixed",top:S,left:Math.min(s.left,window.innerWidth-280),zIndex:9999,background:"var(--t-bg-panel)",border:"1px solid var(--t-border-default)",borderRadius:10,padding:"12px 14px",width:260,boxShadow:"var(--t-shadow-lg)",pointerEvents:"none"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:10},children:[t.jsx("div",{style:{width:34,height:34,borderRadius:w?8:"50%",background:"var(--t-bg-surface)",border:"1px solid var(--t-border-default)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,fontSize:13,fontWeight:700,color:"var(--t-text-secondary)"},children:w?t.jsx(H,{size:16,color:"var(--t-text-muted)"}):x}),t.jsxs("div",{style:{minWidth:0},children:[t.jsx("div",{style:{fontSize:"var(--t-text-sm)",fontWeight:600,color:"var(--t-text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:n}),c?t.jsx("div",{style:{marginTop:3,height:10,width:100,borderRadius:3,background:"var(--t-border-default)",animation:"pulse 1.4s ease-in-out infinite"}}):(r==null?void 0:r.type)==="user"?t.jsx("div",{style:{fontSize:11,color:"var(--t-text-muted)",marginTop:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r.email}):(r==null?void 0:r.type)==="group"?t.jsxs("div",{style:{fontSize:11,color:"var(--t-text-muted)",marginTop:1},children:[r.memberCount," member",r.memberCount!==1?"s":""]}):null]})]}),c?t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[80,60].map((p,o)=>t.jsx("div",{style:{height:10,width:`${p}%`,borderRadius:3,background:"var(--t-border-default)",animation:"pulse 1.4s ease-in-out infinite"}},o))}):r?t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6,borderTop:"1px solid var(--t-border-subtle)",paddingTop:8},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[t.jsx("span",{style:{fontSize:11,color:"var(--t-text-muted)"},children:"App access"}),r.appRole?t.jsx(B,{role:r.type==="user"&&r.globalRole==="super_admin"?"super_admin":r.appRole}):t.jsx("span",{style:{fontSize:11,color:"var(--t-text-muted)"},children:"—"})]}),r.type==="user"&&r.globalRole==="super_admin"&&t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[t.jsx("span",{style:{fontSize:11,color:"var(--t-text-muted)"},children:"Global role"}),t.jsx(B,{role:"super_admin"})]}),r.type==="group"&&r.description&&t.jsx("div",{style:{fontSize:11,color:"var(--t-text-muted)",fontStyle:"italic"},children:r.description}),r.spaces.length>0&&t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:3,marginTop:2},children:[t.jsx("span",{style:{fontSize:11,color:"var(--t-text-muted)",marginBottom:1},children:"Space access"}),r.spaces.slice(0,4).map(p=>t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[t.jsx("span",{style:{fontSize:11,color:"var(--t-text-secondary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:150},children:p.name}),t.jsx(B,{role:p.role})]},p.id)),r.spaces.length>4&&t.jsxs("span",{style:{fontSize:10,color:"var(--t-text-muted)"},children:["+",r.spaces.length-4," more"]})]})]}):null]}),document.body)}function W({comment:e,appId:n,isReply:s=!1,currentUserId:d,onReply:a,onEdit:r,onDelete:h}){const[c,u]=m.useState(!1),[w,y]=m.useState(!1),[S,x]=m.useState(!1),[k,p]=m.useState(null),o=d!=null&&e.createdBy===d,f=e.updatedAt!==e.createdAt;return t.jsxs("div",{onMouseEnter:()=>x(!0),onMouseLeave:()=>x(!1),style:{display:"flex",gap:10,padding:"8px 10px",borderRadius:8,background:S?"var(--t-bg-hover)":"transparent",transition:"background 0.12s",position:"relative"},children:[t.jsx("div",{style:{flexShrink:0,width:s?26:30,height:s?26:30,borderRadius:"50%",background:"var(--t-bg-surface)",border:"1px solid var(--t-border-default)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:s?11:12,fontWeight:700,color:"var(--t-text-primary)",letterSpacing:"-0.02em"},children:ae(e)}),t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:6,marginBottom:2},children:[t.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:6,minWidth:0},children:[t.jsx("span",{style:{fontSize:"var(--t-text-sm)",fontWeight:600,color:"var(--t-text-primary)",whiteSpace:"nowrap"},children:oe(e)}),t.jsx("span",{style:{fontSize:11,color:"var(--t-text-muted)",fontWeight:400,whiteSpace:"nowrap"},children:de(e.createdAt)}),f&&t.jsx("span",{style:{fontSize:10,color:"var(--t-text-muted)",fontStyle:"italic",whiteSpace:"nowrap"},children:"edited"})]}),!w&&t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:1,flexShrink:0,visibility:S||c?"visible":"hidden"},children:[!s&&t.jsx(M,{icon:t.jsx(Y,{size:12}),title:"Reply",active:c,onClick:()=>u(i=>!i)}),o&&t.jsx(M,{icon:t.jsx(Z,{size:12}),title:"Edit",onClick:()=>y(!0)}),o&&t.jsx(M,{icon:t.jsx(Q,{size:12}),title:"Delete",danger:!0,onClick:h})]})]}),w?t.jsx("div",{style:{marginTop:6},children:t.jsx(L,{appId:n,value:e.content,submitLabel:"Save",autoFocus:!0,onCancel:()=>y(!1),onSubmit:async i=>{await r(i),y(!1)}})}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"rich-preview",dangerouslySetInnerHTML:{__html:e.content},style:{fontSize:"var(--t-text-sm)",color:"var(--t-text-secondary)",lineHeight:1.65,wordBreak:"break-word"},onMouseOver:i=>{var b,j,v;const l=(j=(b=i.target).closest)==null?void 0:j.call(b,'[data-type="mention"]');l&&p({id:l.getAttribute("data-id")??"",label:l.getAttribute("data-label")??((v=l.textContent)==null?void 0:v.replace(/^@/,""))??"",rect:l.getBoundingClientRect()})},onMouseOut:i=>{var b;const l=i.relatedTarget;(b=l==null?void 0:l.closest)!=null&&b.call(l,'[data-type="mention"]')||p(null)}}),k&&t.jsx(ce,{...k,appId:n})]}),c&&t.jsx("div",{style:{marginTop:8},children:t.jsx(L,{appId:n,placeholder:"Write a reply…",submitLabel:"Reply",autoFocus:!0,onCancel:()=>u(!1),onSubmit:async i=>{await a(i),u(!1)}})})]})]})}function M({icon:e,title:n,onClick:s,danger:d,active:a}){const[r,h]=m.useState(!1),c=r||a;return t.jsx("button",{type:"button",title:n,onClick:s,onMouseEnter:()=>h(!0),onMouseLeave:()=>h(!1),style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:24,height:24,borderRadius:5,border:`1px solid ${c?"var(--t-border-default)":"transparent"}`,background:c?d?"rgba(239,68,68,0.08)":"var(--t-bg-hover)":"transparent",cursor:"pointer",color:c?d?"var(--t-accent-danger)":"var(--t-text-secondary)":"var(--t-text-muted)",transition:"all 0.1s",padding:0},children:e})}function be(e){const{appId:n}=e,s=e.source?e.source.cacheKey:e.stepResultId!=null?`step:${e.stepResultId}`:`result:${e.resultId}`,d=g.get(s)??null,[a,r]=m.useState(d??[]),[h,c]=m.useState(d===null),[u,w]=m.useState(D),y=m.useRef(null);if(y.current!==s){y.current=s;const i=g.get(s)??null;r(i??[]),c(i===null)}const S=m.useCallback(async()=>{const i=e.source?await e.source.load():e.stepResultId!=null?await C.comments.listStep(e.runId,e.resultId,e.stepResultId):await C.comments.list(e.runId,e.resultId);g.set(s,i),r(i)},[s]),x=m.useCallback(async()=>{g.delete(s),await S()},[s,S]);m.useEffect(()=>{let i=!1;return D===null&&C.auth.me().then(l=>{D=String(l.id),i||w(D)}).catch(()=>{}),g.has(s)?(c(!1),()=>{i=!0}):(c(!0),S().finally(()=>{i||c(!1)}),()=>{i=!0})},[S,s]);const k=async i=>{const b={id:-Date.now(),runResultId:e.source?null:e.resultId??null,runStepResultId:e.source?null:e.stepResultId??null,parentId:null,content:i,createdBy:u??"",createdAt:new Date().toISOString(),updatedAt:new Date().toISOString(),replies:[],author:{id:u??"",name:null,email:""}},j=a,v=[...a,b];r(v),g.set(s,v);try{e.source?await e.source.create(i):e.stepResultId!=null?await C.comments.createStep(e.runId,e.resultId,e.stepResultId,i):await C.comments.create(e.runId,e.resultId,i),await x()}catch{r(j),g.set(s,j)}},p=async(i,l)=>{const j={id:-Date.now(),runResultId:e.source?null:e.resultId??null,runStepResultId:e.source?null:e.stepResultId??null,parentId:i,content:l,createdBy:u??"",createdAt:new Date().toISOString(),updatedAt:new Date().toISOString(),author:{id:u??"",name:null,email:""}},v=a,R=a.map(I=>I.id===i?{...I,replies:[...I.replies??[],j]}:I);r(R),g.set(s,R);try{e.source?await e.source.reply(i,l):await C.comments.reply(e.runId,i,l),await x()}catch{r(v),g.set(s,v)}},o=async(i,l)=>{const b=a,j=a.map(v=>{var R;return v.id===i?{...v,content:l}:{...v,replies:(R=v.replies)==null?void 0:R.map(I=>I.id===i?{...I,content:l}:I)}});r(j),g.set(s,j);try{e.source?await e.source.update(i,l):await C.comments.update(e.runId,i,l)}catch{r(b),g.set(s,b)}},f=async i=>{const l=a,b=a.filter(j=>j.id!==i).map(j=>{var v;return{...j,replies:((v=j.replies)==null?void 0:v.filter(R=>R.id!==i))??[]}});r(b),g.set(s,b);try{e.source?await e.source.delete(i):await C.comments.delete(e.runId,i)}catch{r(l),g.set(s,l)}};return h?t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[[0,1].map(i=>t.jsxs("div",{style:{display:"flex",gap:10,padding:"8px 10px"},children:[t.jsx("div",{style:{width:30,height:30,borderRadius:"50%",background:"var(--t-bg-elevated)",flexShrink:0,animation:"pulse 1.4s ease-in-out infinite"}}),t.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:6,paddingTop:4},children:[t.jsx("div",{style:{width:"35%",height:10,borderRadius:4,background:"var(--t-border-default)",animation:"pulse 1.4s ease-in-out infinite"}}),t.jsx("div",{style:{width:"70%",height:10,borderRadius:4,background:"var(--t-border-default)",animation:"pulse 1.4s ease-in-out infinite"}})]})]},i)),t.jsx("style",{children:"@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.45} }"})]}):t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:2},children:[a.length===0?t.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:8,padding:"24px 0 16px",color:"var(--t-text-muted)"},children:[t.jsx(V,{size:28,weight:"light"}),t.jsx("span",{style:{fontSize:"var(--t-text-sm)"},children:"No comments yet. Be the first!"})]}):t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:2,marginBottom:8},children:a.map(i=>t.jsxs("div",{children:[t.jsx(W,{comment:i,appId:n,currentUserId:u,onReply:l=>p(i.id,l),onEdit:l=>o(i.id,l),onDelete:()=>f(i.id)}),(i.replies??[]).length>0&&t.jsx("div",{style:{marginLeft:20,paddingLeft:20,borderLeft:"2px solid var(--t-border-subtle)",display:"flex",flexDirection:"column",gap:1,marginTop:1,marginBottom:4},children:(i.replies??[]).map(l=>t.jsx(W,{comment:l,appId:n,isReply:!0,currentUserId:u,onReply:()=>Promise.resolve(),onEdit:b=>o(l.id,b),onDelete:()=>f(l.id)},l.id))})]},i.id))}),a.length>0&&t.jsx("div",{style:{height:1,background:"var(--t-border-subtle)",marginBottom:10}}),t.jsx(L,{appId:n,placeholder:"Add a comment… (⌘↵ to submit)",onSubmit:k}),t.jsx("style",{children:`
|
|
36
|
+
.rich-preview .mention {
|
|
37
|
+
display: inline;
|
|
38
|
+
background: var(--t-bg-hover);
|
|
39
|
+
border: 1px solid var(--t-border-default);
|
|
40
|
+
border-radius: 4px;
|
|
41
|
+
padding: 0 4px;
|
|
42
|
+
font-size: 0.92em;
|
|
43
|
+
font-weight: 500;
|
|
44
|
+
color: var(--t-text-primary);
|
|
45
|
+
cursor: default;
|
|
46
|
+
white-space: nowrap;
|
|
47
|
+
transition: background 0.1s, border-color 0.1s;
|
|
48
|
+
}
|
|
49
|
+
.rich-preview .mention:hover {
|
|
50
|
+
background: var(--t-bg-elevated);
|
|
51
|
+
border-color: var(--t-border-strong);
|
|
52
|
+
}
|
|
53
|
+
`})]})}export{be as C,ye as a,pe as b,he as c,me as g};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as n}from"./react-D-pHAthU.js";import{b as w}from"./index-a9kCDHqT.js";const c=new Map,h=new Map;function E(t){const u=t!==null?c.get(t)??null:null,[e,i]=n.useState(u??[]),[R,g]=n.useState(u===null&&t!==null),[m,o]=n.useState(null),a=n.useRef(0),y=n.useRef(null);if(y.current!==t){y.current=t,a.current++;const s=t!==null?c.get(t)??null:null;i(s??[]),g(s===null&&t!==null),o(null)}const r=n.useCallback(async()=>{if(t===null)return;const s=++a.current;c.has(t)||g(!0);try{o(null);const l=await w.tests.list(t);if(a.current!==s)return;c.set(t,l),i(l)}catch(l){if(a.current!==s)return;o(l instanceof Error?l.message:"Failed to fetch tests")}finally{a.current===s&&g(!1)}},[t]);n.useEffect(()=>{r()},[r]);const S=async s=>{if(t===null)return;const l=await w.tests.create(t,s);return i(T=>{const p=[...T,l];return c.set(t,p),p}),l},f=async s=>{t!==null&&(await w.tests.delete(t,s),i(l=>{const T=l.filter(p=>p.id!==s);return c.set(t,T),T}))},C=n.useCallback(async()=>{t!==null&&c.delete(t),await r()},[t,r]);return{tests:e,loading:R,error:m,addTest:S,removeTest:f,refetch:C}}function k(t,u){const e=t!==null&&u!==null?`${t}:${u}`:null,i=e?h.get(e)??null:null,[R,g]=n.useState(i),[m,o]=n.useState(i===null&&e!==null),a=n.useRef(0),y=n.useRef(null);if(y.current!==e){y.current=e,a.current++;const f=e?h.get(e)??null:null;g(f),o(f===null&&e!==null)}const r=n.useCallback(async()=>{if(t===null||u===null||!e)return;const f=++a.current;h.has(e)||o(!0);try{const C=await w.tests.get(t,u);if(a.current!==f)return;h.set(e,C),g(C)}finally{a.current===f&&o(!1)}},[t,u,e]);n.useEffect(()=>{r()},[r]);const S=n.useCallback(async()=>{e&&h.delete(e),await r()},[e,r]);return{test:R,loading:m,refetch:S}}function z(){return c.size}function v(){return h.size}function D(){c.clear()}function F(){h.clear()}function A(t){return c.get(t)}function G(t,u){c.set(t,u)}export{F as a,v as b,D as c,k as d,A as e,z as g,G as s,E as u};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{j as e,r as k}from"./react-D-pHAthU.js";import{x as te,i as Ce,aq as le,C as ae,a3 as oe,aa as J,aM as ce,L as de,K as xe,b as pe,z as Re,a4 as Ie,U as ge,a6 as $e,O as De}from"./icons-J9gKYxTz.js";import{C as We,a as Te,b as Ee}from"./comments-section-CHZSUoK5.js";import{b as E,C as he}from"./index-a9kCDHqT.js";import{M as Fe,r as Ae}from"./markdown-YKl4gdXq.js";const He={p:({children:t})=>e.jsx("p",{style:{margin:"0 0 10px",lineHeight:1.65},children:t}),h1:({children:t})=>e.jsx("h1",{style:{fontSize:"1.25em",fontWeight:600,margin:"16px 0 8px",lineHeight:1.3,color:"var(--t-text-primary)"},children:t}),h2:({children:t})=>e.jsx("h2",{style:{fontSize:"1.1em",fontWeight:600,margin:"14px 0 7px",lineHeight:1.3,color:"var(--t-text-primary)"},children:t}),h3:({children:t})=>e.jsx("h3",{style:{fontSize:"1em",fontWeight:600,margin:"12px 0 6px",lineHeight:1.3,color:"var(--t-text-primary)"},children:t}),h4:({children:t})=>e.jsx("h4",{style:{fontSize:"0.95em",fontWeight:600,margin:"10px 0 5px",color:"var(--t-text-secondary)"},children:t}),ul:({children:t})=>e.jsx("ul",{style:{margin:"0 0 10px",paddingLeft:20},children:t}),ol:({children:t})=>e.jsx("ol",{style:{margin:"0 0 10px",paddingLeft:20},children:t}),li:({children:t})=>e.jsx("li",{style:{marginBottom:4,lineHeight:1.6},children:t}),code:({children:t,className:i})=>i?e.jsx("code",{style:{fontFamily:"ui-monospace, SFMono-Regular, monospace",fontSize:"0.85em",lineHeight:1.6},children:t}):e.jsx("code",{style:{fontFamily:"ui-monospace, SFMono-Regular, monospace",fontSize:"0.875em",background:"var(--t-bg-panel)",border:"1px solid var(--t-border-subtle)",borderRadius:4,padding:"1px 5px",color:"var(--t-text-primary)"},children:t}),pre:({children:t})=>e.jsx("pre",{style:{background:"var(--t-bg-panel)",border:"1px solid var(--t-border-subtle)",borderRadius:8,padding:"12px 14px",overflowX:"auto",margin:"10px 0",fontFamily:"ui-monospace, SFMono-Regular, monospace",fontSize:"0.85em",lineHeight:1.6},children:t}),blockquote:({children:t})=>e.jsx("blockquote",{style:{margin:"10px 0",padding:"8px 12px",borderLeft:"3px solid var(--t-border-strong)",background:"var(--t-bg-panel)",borderRadius:"0 6px 6px 0",color:"var(--t-text-secondary)"},children:t}),a:({href:t,children:i})=>e.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",style:{color:"var(--t-text-primary)",textDecoration:"underline",textUnderlineOffset:2,opacity:.8},children:i}),hr:()=>e.jsx("hr",{style:{border:"none",borderTop:"1px solid var(--t-border-subtle)",margin:"14px 0"}}),strong:({children:t})=>e.jsx("strong",{style:{fontWeight:600},children:t}),em:({children:t})=>e.jsx("em",{style:{fontStyle:"italic"},children:t}),del:({children:t})=>e.jsx("del",{style:{opacity:.6},children:t}),table:({children:t})=>e.jsx("div",{style:{overflowX:"auto",margin:"10px 0"},children:e.jsx("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:"0.9em"},children:t})}),thead:({children:t})=>e.jsx("thead",{children:t}),tbody:({children:t})=>e.jsx("tbody",{children:t}),tr:({children:t})=>e.jsx("tr",{children:t}),th:({children:t})=>e.jsx("th",{style:{padding:"6px 10px",textAlign:"left",fontWeight:600,background:"var(--t-bg-panel)",color:"var(--t-text-secondary)",border:"1px solid var(--t-border-subtle)"},children:t}),td:({children:t})=>e.jsx("td",{style:{padding:"6px 10px",border:"1px solid var(--t-border-subtle)",color:"var(--t-text-primary)"},children:t}),input:({type:t,checked:i})=>t==="checkbox"?e.jsx("input",{type:"checkbox",checked:i,readOnly:!0,style:{marginRight:6,accentColor:"var(--t-text-primary)",cursor:"default"}}):null};function X({content:t,style:i}){return e.jsx("div",{style:{fontSize:"var(--t-text-base)",color:"var(--t-text-primary)",...i},children:e.jsx(Fe,{remarkPlugins:[Ae],components:He,children:t})})}function me({appId:t,analysisId:i}){const n={cacheKey:`analysis:${i}`,load:()=>E.analyses.comments.list(t,i),create:r=>E.analyses.comments.create(t,i,r).then(()=>{}),reply:(r,s)=>E.analyses.comments.reply(t,i,r,s).then(()=>{}),update:(r,s)=>E.analyses.comments.update(t,i,r,s).then(()=>{}),delete:r=>E.analyses.comments.delete(t,i,r).then(()=>{})};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,padding:"14px 16px 12px",borderBottom:"1px solid var(--t-border-subtle)",flexShrink:0},children:[e.jsx(te,{size:15,weight:"duotone",color:"var(--t-text-muted)"}),e.jsx("span",{style:{fontSize:"var(--t-text-sm)",fontWeight:600,color:"var(--t-text-secondary)"},children:"Comments"})]}),e.jsx("div",{style:{flex:1,overflowY:"auto",padding:"12px 16px"},children:e.jsx(We,{appId:t,source:n})})]})}function K({severity:t}){const n={high:{label:"High",color:"#dc2626",bg:"rgba(220,38,38,0.08)",border:"rgba(220,38,38,0.2)"},medium:{label:"Medium",color:"#b45309",bg:"rgba(180,83,9,0.08)",border:"rgba(180,83,9,0.2)"},low:{label:"Low",color:"var(--t-text-muted)",bg:"var(--t-bg-panel)",border:"var(--t-border-subtle)"}}[t];return e.jsx("span",{style:{display:"inline-flex",alignItems:"center",padding:"0 6px",borderRadius:4,height:18,fontSize:10,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase",background:n.bg,color:n.color,border:`1px solid ${n.border}`,flexShrink:0},children:n.label})}function O({complexity:t}){const i={Low:{color:"var(--t-text-muted)",bg:"var(--t-bg-panel)",border:"var(--t-border-subtle)"},Medium:{color:"#b45309",bg:"rgba(180,83,9,0.08)",border:"rgba(180,83,9,0.2)"},High:{color:"#dc2626",bg:"rgba(220,38,38,0.08)",border:"rgba(220,38,38,0.2)"},"Very High":{color:"#9333ea",bg:"rgba(147,51,234,0.08)",border:"rgba(147,51,234,0.2)"}},n=i[t]??i.Medium;return e.jsx("span",{style:{display:"inline-flex",alignItems:"center",padding:"0 7px",borderRadius:4,height:20,fontSize:11,fontWeight:600,letterSpacing:"0.03em",background:n.bg,color:n.color,border:`1px solid ${n.border}`},children:t})}function fe({path:t}){const i=t.split("/"),n=i.pop()??t,r=i.length>1?`…/${i[i.length-1]}/`:"";return e.jsxs("code",{title:t,style:{display:"inline-block",padding:"1px 6px",borderRadius:3,fontSize:11,background:"var(--t-bg-panel)",border:"1px solid var(--t-border-subtle)",color:"var(--t-text-secondary)",fontFamily:"monospace"},children:[e.jsx("span",{style:{color:"var(--t-text-muted)"},children:r}),n]})}function U(){return e.jsx("p",{style:{margin:0,fontSize:"var(--t-text-sm)",color:"var(--t-text-muted)",fontStyle:"italic"},children:"None identified."})}function q({items:t}){return t.length?e.jsx("ul",{style:{margin:0,paddingLeft:16,display:"flex",flexDirection:"column",gap:4},children:t.map((i,n)=>e.jsx("li",{style:{fontSize:"var(--t-text-sm)",color:"var(--t-text-primary)",lineHeight:1.55},children:i},n))}):e.jsx(U,{})}function V({title:t,badge:i,children:n,defaultOpen:r=!0}){const[s,l]=k.useState(r);return e.jsxs("div",{style:{border:"1px solid var(--t-border-subtle)",borderRadius:6,overflow:"hidden"},children:[e.jsxs("button",{onClick:()=>l(o=>!o),style:{width:"100%",display:"flex",alignItems:"center",gap:8,padding:"9px 14px",background:"var(--t-bg-panel)",border:"none",cursor:"pointer",color:"var(--t-text-primary)"},children:[s?e.jsx(de,{size:11,weight:"bold"}):e.jsx(xe,{size:11,weight:"bold"}),e.jsx("span",{style:{flex:1,textAlign:"left",fontSize:"var(--t-text-sm)",fontWeight:600},children:t}),i]}),s&&e.jsx("div",{style:{padding:"12px 14px",display:"flex",flexDirection:"column",gap:12,background:"var(--t-bg-elevated)",borderTop:"1px solid var(--t-border-subtle)"},children:n})]})}function v({title:t,children:i,empty:n}){return e.jsxs("div",{children:[e.jsx("p",{style:{margin:"0 0 5px",fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em",color:"var(--t-text-muted)"},children:t}),n?e.jsx(U,{}):i]})}function Y({severity:t}){const i=t==="high"?"var(--t-accent-danger)":t==="medium"?"var(--t-accent-warning)":"var(--t-border-default)";return e.jsx("span",{style:{width:3,minHeight:16,borderRadius:2,background:i,flexShrink:0,alignSelf:"stretch",marginTop:2}})}function G({title:t,meta:i,children:n}){return e.jsxs("div",{style:{background:"var(--t-bg-elevated)",border:"1px solid var(--t-border-subtle)",borderRadius:6,display:"flex",flexDirection:"column",minWidth:0,overflow:"hidden"},children:[e.jsxs("div",{style:{padding:"8px 12px",display:"flex",alignItems:"center",justifyContent:"space-between",background:"var(--t-bg-panel)",borderBottom:"1px solid var(--t-border-subtle)"},children:[e.jsx("span",{style:{fontSize:11,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.07em",color:"var(--t-text-muted)"},children:t}),i&&e.jsx("span",{style:{fontSize:11,color:"var(--t-text-muted)"},children:i})]}),e.jsx("div",{style:{padding:"11px 12px",display:"flex",flexDirection:"column",gap:10},children:n})]})}function j({label:t,children:i}){return e.jsxs("div",{children:[e.jsx("p",{style:{margin:"0 0 5px",fontSize:10,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.06em",color:"var(--t-text-muted)"},children:t}),i]})}function R(){return e.jsx("div",{style:{height:1,background:"var(--t-border-subtle)"}})}function Le({data:t}){var s,l,o,g;const i={explicit:((s=t.requirements)==null?void 0:s.explicit)??[],implicit:((l=t.requirements)==null?void 0:l.implicit)??[],missing:((o=t.requirements)==null?void 0:o.missing)??[],ambiguous:((g=t.requirements)==null?void 0:g.ambiguous)??[]},n=i.missing.length+i.ambiguous.length,r=[i.explicit.length&&`${i.explicit.length} req`,n&&`${n} issue${n!==1?"s":""}`].filter(Boolean).join(" · ")||void 0;return e.jsxs(G,{title:"Requirements",meta:r,children:[!i.explicit.length&&!i.implicit.length&&n===0&&e.jsx(U,{}),i.explicit.length>0&&e.jsx(j,{label:"Explicit",children:e.jsx("ol",{style:{margin:0,paddingLeft:16,display:"flex",flexDirection:"column",gap:5},children:i.explicit.map((p,m)=>e.jsxs("li",{style:{fontSize:"var(--t-text-sm)",color:"var(--t-text-primary)",lineHeight:1.55},children:[p.item,e.jsxs("span",{style:{marginLeft:6,fontSize:10,color:"var(--t-text-muted)",fontStyle:"italic"},children:["(",p.source,")"]})]},m))})}),i.implicit.length>0&&e.jsxs(e.Fragment,{children:[i.explicit.length>0&&e.jsx(R,{}),e.jsx(j,{label:"Implicit",children:e.jsx("ul",{style:{margin:0,paddingLeft:14,display:"flex",flexDirection:"column",gap:3},children:i.implicit.map((p,m)=>e.jsx("li",{style:{fontSize:"var(--t-text-sm)",color:"var(--t-text-secondary)",lineHeight:1.5},children:p},m))})})]}),i.missing.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(R,{}),e.jsx(j,{label:"Missing",children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:i.missing.map((p,m)=>e.jsx("div",{style:{paddingLeft:10,borderLeft:"2px solid var(--t-accent-danger)",fontSize:"var(--t-text-sm)",color:"var(--t-text-secondary)",lineHeight:1.5},children:p},m))})})]}),i.ambiguous.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(R,{}),e.jsx(j,{label:"Ambiguous",children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:i.ambiguous.map((p,m)=>e.jsxs("div",{style:{paddingLeft:10,borderLeft:"2px solid var(--t-accent-warning)"},children:[e.jsx("p",{style:{margin:"0 0 2px",fontSize:"var(--t-text-sm)",color:"var(--t-text-primary)",fontWeight:500},children:p.issue}),e.jsx("p",{style:{margin:0,fontSize:11,color:"var(--t-text-muted)"},children:p.clarification})]},m))})})]})]})}function Me({data:t}){var l,o,g,p,m,u,h,f;const i={areas:((l=t.impact)==null?void 0:l.areas)??[],dependencyRisks:((o=t.impact)==null?void 0:o.dependencyRisks)??[],configConcerns:((g=t.impact)==null?void 0:g.configConcerns)??[],compatibilityIssues:((p=t.impact)==null?void 0:p.compatibilityIssues)??[],infrastructureConcerns:((m=t.impact)==null?void 0:m.infrastructureConcerns)??[],hiddenEdgeCases:((u=t.impact)==null?void 0:u.hiddenEdgeCases)??[],testGaps:((h=t.impact)==null?void 0:h.testGaps)??[],regressionRisks:((f=t.impact)==null?void 0:f.regressionRisks)??[]},n=[...i.dependencyRisks,...i.regressionRisks,...i.testGaps].filter(c=>c.severity==="high").length,r=i.compatibilityIssues.filter(c=>c.breaking).length,s=[i.areas.length&&`${i.areas.length} area${i.areas.length!==1?"s":""}`,n&&`${n} high`,r&&`${r} breaking`].filter(Boolean).join(" · ")||void 0;return e.jsxs(G,{title:"Impact",meta:s,children:[!i.areas.length&&!i.dependencyRisks.length&&!i.testGaps.length&&!i.regressionRisks.length&&!i.hiddenEdgeCases.length&&e.jsx(U,{}),i.areas.length>0&&e.jsx(j,{label:"Affected Areas",children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:9},children:i.areas.map((c,x)=>e.jsxs("div",{style:{padding:"8px 10px",borderRadius:5,background:"var(--t-bg-panel)",border:"1px solid var(--t-border-subtle)"},children:[e.jsx("p",{style:{margin:"0 0 3px",fontSize:"var(--t-text-sm)",fontWeight:600,color:"var(--t-text-primary)"},children:c.area}),e.jsx("p",{style:{margin:"0 0 5px",fontSize:11,color:"var(--t-text-secondary)",lineHeight:1.45},children:c.description}),(c.files??[]).length>0&&e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:3},children:(c.files??[]).map((b,S)=>e.jsx(fe,{path:b},S))})]},x))})}),i.dependencyRisks.length>0&&e.jsxs(e.Fragment,{children:[i.areas.length>0&&e.jsx(R,{}),e.jsx(j,{label:"Dependency Risks",children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:5},children:i.dependencyRisks.map((c,x)=>e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:7},children:[e.jsx(Y,{severity:c.severity}),e.jsxs("div",{style:{minWidth:0},children:[e.jsx("span",{style:{fontSize:"var(--t-text-sm)",fontWeight:600,color:"var(--t-text-primary)"},children:c.name}),c.description&&e.jsxs("span",{style:{fontSize:"var(--t-text-sm)",color:"var(--t-text-secondary)"},children:[" ","— ",c.description]})]})]},x))})})]}),(i.testGaps.length>0||i.regressionRisks.length>0)&&e.jsxs(e.Fragment,{children:[(i.areas.length>0||i.dependencyRisks.length>0)&&e.jsx(R,{}),e.jsx(j,{label:"Test Gaps & Regressions",children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:5},children:[i.testGaps.map((c,x)=>e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:7},children:[e.jsx(Y,{severity:c.severity}),e.jsx("span",{style:{fontSize:"var(--t-text-sm)",color:"var(--t-text-secondary)",lineHeight:1.45},children:c.description})]},`tg${x}`)),i.regressionRisks.map((c,x)=>e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:7},children:[e.jsx(Y,{severity:c.severity}),e.jsxs("span",{style:{fontSize:"var(--t-text-sm)",color:"var(--t-text-secondary)",lineHeight:1.45},children:[e.jsx("strong",{style:{color:"var(--t-text-primary)",fontWeight:600},children:c.what})," ","— ",c.why]})]},`rr${x}`))]})})]}),i.hiddenEdgeCases.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(R,{}),e.jsx(j,{label:"Edge Cases",children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:5},children:i.hiddenEdgeCases.map((c,x)=>e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:7},children:[e.jsx("code",{style:{fontSize:9,fontWeight:700,letterSpacing:"0.05em",textTransform:"uppercase",color:"var(--t-text-muted)",padding:"2px 5px",border:"1px solid var(--t-border-default)",borderRadius:3,background:"var(--t-bg-panel)",flexShrink:0,lineHeight:1.6},children:c.category}),e.jsx("span",{style:{fontSize:"var(--t-text-sm)",color:"var(--t-text-secondary)",lineHeight:1.45},children:c.description})]},x))})})]}),(i.configConcerns.length>0||i.infrastructureConcerns.length>0)&&e.jsxs(e.Fragment,{children:[e.jsx(R,{}),e.jsx(j,{label:"Config & Infra",children:e.jsx("ul",{style:{margin:0,paddingLeft:14,display:"flex",flexDirection:"column",gap:3},children:[...i.configConcerns,...i.infrastructureConcerns].map((c,x)=>e.jsx("li",{style:{fontSize:11,color:"var(--t-text-secondary)",lineHeight:1.45},children:c},x))})})]}),i.compatibilityIssues.filter(c=>c.breaking).length>0&&e.jsxs(e.Fragment,{children:[e.jsx(R,{}),e.jsx(j,{label:"Breaking Changes",children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:i.compatibilityIssues.filter(c=>c.breaking).map((c,x)=>e.jsx("div",{style:{paddingLeft:10,borderLeft:"2px solid var(--t-accent-danger)",fontSize:"var(--t-text-sm)",color:"var(--t-text-secondary)",lineHeight:1.5},children:c.description},x))})})]})]})}function Ne({data:t}){var n,r,s,l,o,g,p,m,u,h,f,c;const i={complexity:((n=t.feasibility)==null?void 0:n.complexity)??"Medium",complexityReason:((r=t.feasibility)==null?void 0:r.complexityReason)??"",testability:{unit:((l=(s=t.feasibility)==null?void 0:s.testability)==null?void 0:l.unit)??[],integration:((g=(o=t.feasibility)==null?void 0:o.testability)==null?void 0:g.integration)??[],e2e:((m=(p=t.feasibility)==null?void 0:p.testability)==null?void 0:m.e2e)??[],difficult:((h=(u=t.feasibility)==null?void 0:u.testability)==null?void 0:h.difficult)??[]},blockers:((f=t.feasibility)==null?void 0:f.blockers)??[],risks:((c=t.feasibility)==null?void 0:c.risks)??[]};return e.jsxs(G,{title:"Feasibility",children:[e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:8},children:[e.jsx(O,{complexity:i.complexity}),i.complexityReason&&e.jsx("p",{style:{margin:0,fontSize:"var(--t-text-sm)",color:"var(--t-text-secondary)",lineHeight:1.5},children:i.complexityReason})]}),(i.testability.unit.length>0||i.testability.integration.length>0||i.testability.e2e.length>0||i.testability.difficult.length>0)&&e.jsxs(e.Fragment,{children:[e.jsx(R,{}),e.jsx(j,{label:"Testability",children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[["unit","integration","e2e"].map(x=>{const b=i.testability[x];if(!b.length)return null;const S={unit:"Unit",integration:"Integ",e2e:"E2E"};return e.jsxs("div",{style:{display:"flex",gap:10,alignItems:"flex-start"},children:[e.jsx("span",{style:{fontSize:9,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.05em",color:"var(--t-text-muted)",minWidth:36,paddingTop:2,flexShrink:0},children:S[x]}),e.jsx("span",{style:{fontSize:11,color:"var(--t-text-secondary)",lineHeight:1.5},children:b.join(", ")})]},x)}),i.testability.difficult.length>0&&e.jsxs("div",{style:{display:"flex",gap:10,alignItems:"flex-start"},children:[e.jsx("span",{style:{fontSize:9,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.05em",color:"var(--t-accent-danger)",minWidth:36,paddingTop:2,flexShrink:0},children:"Hard"}),e.jsx("span",{style:{fontSize:11,color:"var(--t-accent-danger)",lineHeight:1.5},children:i.testability.difficult.join(", ")})]})]})})]}),i.blockers.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(R,{}),e.jsx(j,{label:"Blockers",children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:i.blockers.map((x,b)=>e.jsxs("div",{style:{padding:"8px 10px",borderLeft:"3px solid var(--t-accent-danger)",background:"rgba(220,38,38,0.04)",borderRadius:"0 5px 5px 0"},children:[e.jsx("p",{style:{margin:"0 0 2px",fontSize:"var(--t-text-sm)",fontWeight:600,color:"var(--t-text-primary)"},children:x.what}),e.jsx("p",{style:{margin:0,fontSize:11,color:"var(--t-accent-warning)"},children:x.unblockNeeded})]},b))})})]}),i.risks.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(R,{}),e.jsx(j,{label:"Risks",children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:i.risks.map((x,b)=>e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:7},children:[e.jsx(Y,{severity:x.severity}),e.jsxs("div",{style:{minWidth:0},children:[e.jsx("p",{style:{margin:"0 0 2px",fontSize:"var(--t-text-sm)",color:"var(--t-text-primary)",lineHeight:1.45},children:x.description}),x.mitigation&&e.jsxs("p",{style:{margin:0,fontSize:11,color:"var(--t-text-muted)"},children:["↳ ",x.mitigation]})]})]},b))})})]})]})}function Pe({data:t}){var s,l,o;const i={knownFacts:((s=t.gaps)==null?void 0:s.knownFacts)??[],unknowns:((l=t.gaps)==null?void 0:l.unknowns)??[],assumptions:((o=t.gaps)==null?void 0:o.assumptions)??[]},n=i.knownFacts.length+i.unknowns.length+i.assumptions.length,r=n?`${n} item${n!==1?"s":""}`:void 0;return e.jsxs(G,{title:"Gaps & Unknowns",meta:r,children:[n===0&&e.jsx(U,{}),i.unknowns.length>0&&e.jsx(j,{label:"Unknowns",children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:i.unknowns.map((g,p)=>e.jsx("div",{style:{paddingLeft:10,borderLeft:"2px solid var(--t-accent-warning)",fontSize:"var(--t-text-sm)",color:"var(--t-text-secondary)",lineHeight:1.5},children:g},p))})}),i.assumptions.length>0&&e.jsxs(e.Fragment,{children:[i.unknowns.length>0&&e.jsx(R,{}),e.jsx(j,{label:"Assumptions",children:e.jsx("ul",{style:{margin:0,paddingLeft:14,display:"flex",flexDirection:"column",gap:3},children:i.assumptions.map((g,p)=>e.jsx("li",{style:{fontSize:"var(--t-text-sm)",color:"var(--t-text-secondary)",lineHeight:1.5},children:g},p))})})]}),i.knownFacts.length>0&&e.jsxs(e.Fragment,{children:[(i.unknowns.length>0||i.assumptions.length>0)&&e.jsx(R,{}),e.jsx(j,{label:"Known Facts",children:e.jsx("ul",{style:{margin:0,paddingLeft:14,display:"flex",flexDirection:"column",gap:3},children:i.knownFacts.map((g,p)=>e.jsx("li",{style:{fontSize:"var(--t-text-sm)",color:"var(--t-text-primary)",lineHeight:1.5},children:g},p))})})]})]})}function _({value:t,label:i,danger:n}){return e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",padding:"7px 16px",gap:1},children:[e.jsx("span",{style:{fontSize:15,fontWeight:700,lineHeight:1,color:n?"var(--t-accent-danger)":"var(--t-text-primary)"},children:t}),e.jsx("span",{style:{fontSize:10,color:"var(--t-text-muted)",textTransform:"uppercase",letterSpacing:"0.05em",whiteSpace:"nowrap"},children:i})]})}function ye({data:t,fullscreen:i=!1}){var g,p,m,u,h,f,c,x,b,S,z,y;const n=((g=t.feasibility)==null?void 0:g.complexity)??"Medium",r=((m=(p=t.requirements)==null?void 0:p.explicit)==null?void 0:m.length)??0,s=((h=(u=t.impact)==null?void 0:u.areas)==null?void 0:h.length)??0,l=((c=(f=t.feasibility)==null?void 0:f.blockers)==null?void 0:c.length)??0,o=[...((x=t.impact)==null?void 0:x.dependencyRisks)??[],...((b=t.impact)==null?void 0:b.regressionRisks)??[],...((S=t.impact)==null?void 0:S.testGaps)??[],...((z=t.feasibility)==null?void 0:z.risks)??[]].filter(w=>w.severity==="high").length;return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[e.jsxs("div",{style:{display:"flex",alignItems:"stretch",border:"1px solid var(--t-border-subtle)",borderRadius:6,overflow:"hidden",background:"var(--t-bg-elevated)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"7px 14px",borderRight:"1px solid var(--t-border-subtle)",background:"var(--t-bg-panel"},children:[e.jsx("span",{style:{fontSize:10,color:"var(--t-text-muted)",textTransform:"uppercase",letterSpacing:"0.05em"},children:"Complexity"}),e.jsx(O,{complexity:n})]}),e.jsx(_,{value:r,label:"Requirements"}),e.jsx("div",{style:{width:1,background:"var(--t-border-subtle)",alignSelf:"stretch"}}),e.jsx(_,{value:s,label:"Impact Areas"}),e.jsx("div",{style:{width:1,background:"var(--t-border-subtle)",alignSelf:"stretch"}}),e.jsx(_,{value:l,label:"Blockers",danger:l>0}),e.jsx("div",{style:{width:1,background:"var(--t-border-subtle)",alignSelf:"stretch"}}),e.jsx(_,{value:o,label:"High Risks",danger:o>0})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:i?"1fr 1fr":"1fr",gap:8},children:[e.jsx(Le,{data:t}),e.jsx(Me,{data:t}),e.jsx(Ne,{data:t}),e.jsx(Pe,{data:t})]}),(((y=t.highlights)==null?void 0:y.length)??0)>0&&e.jsxs("div",{style:{border:"1px solid var(--t-border-subtle)",borderRadius:6,overflow:"hidden",background:"var(--t-bg-elevated)"},children:[e.jsx("div",{style:{padding:"8px 12px",background:"var(--t-bg-panel)",borderBottom:"1px solid var(--t-border-subtle)"},children:e.jsx("span",{style:{fontSize:11,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.07em",color:"var(--t-text-muted)"},children:"Key Points"})}),e.jsx("ol",{style:{margin:0,padding:"10px 12px 10px 32px",display:"flex",flexDirection:"column",gap:7},children:(t.highlights??[]).map((w,I)=>e.jsx("li",{style:{fontSize:"var(--t-text-sm)",color:"var(--t-text-primary)",lineHeight:1.6},children:w},I))})]})]})}function ue({data:t}){var o,g,p,m,u,h,f,c,x,b,S,z,y,w,I,N,P,W,F,D,A,H,L,M,C,T,B;const i={explicit:((o=t.requirements)==null?void 0:o.explicit)??[],implicit:((g=t.requirements)==null?void 0:g.implicit)??[],missing:((p=t.requirements)==null?void 0:p.missing)??[],ambiguous:((m=t.requirements)==null?void 0:m.ambiguous)??[]},n={areas:((u=t.impact)==null?void 0:u.areas)??[],dependencyRisks:((h=t.impact)==null?void 0:h.dependencyRisks)??[],configConcerns:((f=t.impact)==null?void 0:f.configConcerns)??[],compatibilityIssues:((c=t.impact)==null?void 0:c.compatibilityIssues)??[],infrastructureConcerns:((x=t.impact)==null?void 0:x.infrastructureConcerns)??[],hiddenEdgeCases:((b=t.impact)==null?void 0:b.hiddenEdgeCases)??[],testGaps:((S=t.impact)==null?void 0:S.testGaps)??[],regressionRisks:((z=t.impact)==null?void 0:z.regressionRisks)??[]},r={complexity:((y=t.feasibility)==null?void 0:y.complexity)??"Medium",complexityReason:((w=t.feasibility)==null?void 0:w.complexityReason)??"",testability:{unit:((N=(I=t.feasibility)==null?void 0:I.testability)==null?void 0:N.unit)??[],integration:((W=(P=t.feasibility)==null?void 0:P.testability)==null?void 0:W.integration)??[],e2e:((D=(F=t.feasibility)==null?void 0:F.testability)==null?void 0:D.e2e)??[],difficult:((H=(A=t.feasibility)==null?void 0:A.testability)==null?void 0:H.difficult)??[]},blockers:((L=t.feasibility)==null?void 0:L.blockers)??[],risks:((M=t.feasibility)==null?void 0:M.risks)??[]},s={knownFacts:((C=t.gaps)==null?void 0:C.knownFacts)??[],unknowns:((T=t.gaps)==null?void 0:T.unknowns)??[],assumptions:((B=t.gaps)==null?void 0:B.assumptions)??[]},l=t.highlights??[];return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[e.jsxs(V,{title:"1. Requirements Analysis",defaultOpen:!1,children:[e.jsx(v,{title:"1.1 Explicit",empty:!i.explicit.length,children:e.jsx("ol",{style:{margin:0,paddingLeft:16,display:"flex",flexDirection:"column",gap:5},children:i.explicit.map((d,a)=>e.jsxs("li",{style:{fontSize:"var(--t-text-sm)",color:"var(--t-text-primary)",lineHeight:1.55},children:[d.item,e.jsxs("span",{style:{marginLeft:6,fontSize:11,color:"var(--t-text-muted)",fontStyle:"italic"},children:["(",d.source,")"]})]},a))})}),e.jsx(v,{title:"1.2 Implicit",empty:!i.implicit.length,children:e.jsx(q,{items:i.implicit})}),e.jsx(v,{title:"1.3 Missing",empty:!i.missing.length,children:e.jsx(q,{items:i.missing})}),e.jsx(v,{title:"1.4 Ambiguous",empty:!i.ambiguous.length,children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:i.ambiguous.map((d,a)=>e.jsxs("div",{style:{padding:"7px 10px",borderRadius:6,background:"rgba(234,179,8,0.06)",border:"1px solid rgba(234,179,8,0.2)"},children:[e.jsx("p",{style:{margin:"0 0 3px",fontSize:"var(--t-text-sm)",color:"var(--t-text-primary)",fontWeight:500},children:d.issue}),e.jsxs("p",{style:{margin:0,fontSize:11,color:"#ca8a04"},children:["Clarification needed: ",d.clarification]})]},a))})})]}),e.jsxs(V,{title:"2. Impact Analysis",defaultOpen:!0,children:[e.jsx(v,{title:"2.1 Impact Areas",empty:!n.areas.length,children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:n.areas.map((d,a)=>e.jsxs("div",{style:{padding:"8px 10px",borderRadius:6,background:"var(--t-bg-panel)",border:"1px solid var(--t-border-subtle)"},children:[e.jsx("p",{style:{margin:"0 0 4px",fontSize:"var(--t-text-sm)",fontWeight:600,color:"var(--t-text-primary)"},children:d.area}),e.jsx("p",{style:{margin:"0 0 6px",fontSize:"var(--t-text-sm)",color:"var(--t-text-secondary)",lineHeight:1.5},children:d.description}),(d.files??[]).length>0&&e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:(d.files??[]).map(($,ee)=>e.jsx(fe,{path:$},ee))})]},a))})}),e.jsx(v,{title:"2.2 Dependency Risks",empty:!n.dependencyRisks.length,children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:5},children:n.dependencyRisks.map((d,a)=>e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:8},children:[e.jsx(K,{severity:d.severity}),e.jsxs("div",{children:[e.jsx("span",{style:{fontSize:"var(--t-text-sm)",fontWeight:600,color:"var(--t-text-primary)"},children:d.name}),e.jsxs("span",{style:{fontSize:"var(--t-text-sm)",color:"var(--t-text-secondary)"},children:[" ","— ",d.description]})]})]},a))})}),e.jsx(v,{title:"2.3 Config Concerns",empty:!n.configConcerns.length,children:e.jsx(q,{items:n.configConcerns})}),e.jsx(v,{title:"2.4 Compatibility Issues",empty:!n.compatibilityIssues.length,children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:5},children:n.compatibilityIssues.map((d,a)=>e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:7},children:[e.jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase",color:d.breaking?"#dc2626":"var(--t-text-muted)",padding:"0 5px",height:18,display:"flex",alignItems:"center",border:`1px solid ${d.breaking?"rgba(220,38,38,0.3)":"var(--t-border-subtle)"}`,borderRadius:3,flexShrink:0,background:d.breaking?"rgba(220,38,38,0.07)":"var(--t-bg-panel)"},children:d.breaking?"Breaking":"Non-breaking"}),e.jsx("span",{style:{fontSize:"var(--t-text-sm)",color:"var(--t-text-secondary)",lineHeight:1.5},children:d.description})]},a))})}),e.jsx(v,{title:"2.5 Infrastructure Concerns",empty:!n.infrastructureConcerns.length,children:e.jsx(q,{items:n.infrastructureConcerns})}),e.jsx(v,{title:"2.6 Hidden Edge Cases",empty:!n.hiddenEdgeCases.length,children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:5},children:n.hiddenEdgeCases.map((d,a)=>e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:7},children:[e.jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase",color:"var(--t-text-muted)",padding:"0 5px",height:18,display:"flex",alignItems:"center",border:"1px solid var(--t-border-subtle)",borderRadius:3,flexShrink:0,background:"var(--t-bg-panel)"},children:d.category}),e.jsx("span",{style:{fontSize:"var(--t-text-sm)",color:"var(--t-text-secondary)",lineHeight:1.5},children:d.description})]},a))})}),e.jsx(v,{title:"2.7 Test Gaps",empty:!n.testGaps.length,children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:5},children:n.testGaps.map((d,a)=>e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:7},children:[e.jsx(K,{severity:d.severity}),e.jsx("span",{style:{fontSize:"var(--t-text-sm)",color:"var(--t-text-secondary)",lineHeight:1.5},children:d.description})]},a))})}),e.jsx(v,{title:"2.8 Regression Risks",empty:!n.regressionRisks.length,children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:5},children:n.regressionRisks.map((d,a)=>e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:7},children:[e.jsx(K,{severity:d.severity}),e.jsxs("div",{children:[e.jsx("span",{style:{fontSize:"var(--t-text-sm)",fontWeight:600,color:"var(--t-text-primary)"},children:d.what}),e.jsxs("span",{style:{fontSize:"var(--t-text-sm)",color:"var(--t-text-secondary)"},children:[" ","— ",d.why]})]})]},a))})})]}),e.jsxs(V,{title:"3. Feasibility Analysis",badge:e.jsx(O,{complexity:r.complexity}),defaultOpen:!1,children:[e.jsx(v,{title:"3.1 Complexity",children:e.jsx("p",{style:{margin:0,fontSize:"var(--t-text-sm)",color:"var(--t-text-secondary)",lineHeight:1.55},children:r.complexityReason})}),e.jsx(v,{title:"3.2 Testability",children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:["unit","integration","e2e","difficult"].map(d=>{const a=r.testability[d];if(!a.length)return null;const $={unit:"Unit",integration:"Integration",e2e:"E2E",difficult:"Difficult / Untestable"};return e.jsxs("div",{children:[e.jsx("span",{style:{fontSize:11,fontWeight:600,color:d==="difficult"?"#ef4444":"var(--t-text-muted)",textTransform:"uppercase",letterSpacing:"0.04em"},children:$[d]}),e.jsx("ul",{style:{margin:"3px 0 0",paddingLeft:14,display:"flex",flexDirection:"column",gap:2},children:a.map((ee,ze)=>e.jsx("li",{style:{fontSize:"var(--t-text-sm)",color:"var(--t-text-secondary)",lineHeight:1.5},children:ee},ze))})]},d)})})}),e.jsx(v,{title:"3.3 Blockers",empty:!r.blockers.length,children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:r.blockers.map((d,a)=>e.jsxs("div",{style:{padding:"7px 10px",borderRadius:6,background:"rgba(220,38,38,0.06)",border:"1px solid rgba(220,38,38,0.2)"},children:[e.jsx("p",{style:{margin:"0 0 3px",fontSize:"var(--t-text-sm)",fontWeight:600,color:"var(--t-text-primary)"},children:d.what}),e.jsxs("p",{style:{margin:0,fontSize:11,color:"#ef4444"},children:["Needs: ",d.unblockNeeded]})]},a))})}),e.jsx(v,{title:"3.4 Risks",empty:!r.risks.length,children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:r.risks.map((d,a)=>e.jsxs("div",{style:{padding:"8px 10px",borderRadius:6,background:"var(--t-bg-panel)",border:"1px solid var(--t-border-subtle)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,marginBottom:5},children:[e.jsx(K,{severity:d.severity}),e.jsx("span",{style:{fontSize:"var(--t-text-sm)",fontWeight:500,color:"var(--t-text-primary)"},children:d.description})]}),e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"3px 16px"},children:[e.jsxs("span",{style:{fontSize:11,color:"var(--t-text-muted)"},children:["Likelihood:"," ",e.jsx("span",{style:{color:"var(--t-text-secondary)"},children:d.likelihood})]}),e.jsxs("span",{style:{fontSize:11,color:"var(--t-text-muted)"},children:["Impact: ",e.jsx("span",{style:{color:"var(--t-text-secondary)"},children:d.impact})]}),e.jsxs("span",{style:{fontSize:11,color:"var(--t-text-muted)"},children:["Mitigation:"," ",e.jsx("span",{style:{color:"var(--t-text-secondary)"},children:d.mitigation})]})]})]},a))})})]}),e.jsxs(V,{title:"4. Gap Analysis",defaultOpen:!1,children:[e.jsx(v,{title:"4.1 Known Facts",empty:!s.knownFacts.length,children:e.jsx(q,{items:s.knownFacts})}),e.jsx(v,{title:"4.2 Unknowns",empty:!s.unknowns.length,children:e.jsx(q,{items:s.unknowns})}),e.jsx(v,{title:"4.3 Assumptions",empty:!s.assumptions.length,children:e.jsx(q,{items:s.assumptions})})]}),e.jsxs("div",{style:{padding:"10px 14px",borderRadius:8,background:"var(--t-bg-panel)",border:"1px solid var(--t-border-subtle)"},children:[e.jsx("p",{style:{margin:"0 0 8px",fontSize:11,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.06em",color:"var(--t-text-muted)"},children:"Key Highlights"}),e.jsx("ul",{style:{margin:0,paddingLeft:16,display:"flex",flexDirection:"column",gap:5},children:l.map((d,a)=>e.jsx("li",{style:{fontSize:"var(--t-text-sm)",color:"var(--t-text-primary)",lineHeight:1.55},children:d},a))})]})]})}function be(t){var d;const i=[],n=a=>a??[],r=a=>a.length===0,s=(...a)=>i.push(...a),l=()=>i.push(""),o=()=>{i.push(""),i.push("---"),i.push("")},g=a=>a==="high"?"🔴 High":a==="medium"?"🟡 Medium":"🟢 Low",p=a=>a==="Low"?"🟢":a==="Medium"?"🟡":a==="High"?"🔴":"🟣",m=((d=t.feasibility)==null?void 0:d.complexity)??"Medium",u=t.requirements??{},h=t.impact??{},f=t.feasibility??{},c=t.gaps??{};s("## 1. Requirements Analysis"),l(),s("### Explicit Requirements"),l();const x=n(u.explicit);r(x)?s("*None identified.*"):(s("| # | Requirement | Source |"),s("|---|-------------|--------|"),x.forEach((a,$)=>s(`| ${$+1} | ${a.item} | \`${a.source}\` |`))),l(),s("### Implicit Requirements"),l();const b=n(u.implicit);r(b)?s("*None identified.*"):b.forEach(a=>s(`- ${a}`)),l(),s("### Missing Requirements"),l();const S=n(u.missing);r(S)?s("*None identified.*"):S.forEach(a=>s(`> ⚠️ ${a}`)),l(),s("### Ambiguous Requirements"),l();const z=n(u.ambiguous);r(z)?s("*None identified.*"):z.forEach(a=>{s(`> ❓ **${a.issue}**`),s(`> Clarification needed: *${a.clarification}*`),l()}),o(),s("## 2. Impact Analysis"),l(),s("### Affected Areas"),l();const y=n(h.areas);r(y)?(s("*None identified.*"),l()):y.forEach(a=>{s(`#### ${a.area}`),s(a.description),n(a.files).length&&(l(),s("**Files:**"),n(a.files).forEach($=>s(`- \`${$}\``))),l()}),s("### Dependency Risks"),l();const w=n(h.dependencyRisks);r(w)?s("*None identified.*"):(s("| Severity | Dependency | Description |"),s("|----------|-----------|-------------|"),w.forEach(a=>s(`| ${g(a.severity)} | **${a.name}** | ${a.description} |`))),l();const I=[...n(h.configConcerns),...n(h.infrastructureConcerns)];r(I)||(s("### Config & Infrastructure"),l(),I.forEach(a=>s(`- ${a}`)),l());const N=n(h.compatibilityIssues);r(N)||(s("### Compatibility Issues"),l(),N.forEach(a=>{a.breaking?s(`> 🔴 **BREAKING:** ${a.description}`):s(`- ${a.description}`)}),l());const P=n(h.hiddenEdgeCases);r(P)||(s("### Hidden Edge Cases"),l(),s("| Category | Description |"),s("|----------|-------------|"),P.forEach(a=>s(`| \`${a.category}\` | ${a.description} |`)),l());const W=n(h.testGaps);r(W)||(s("### Test Gaps"),l(),s("| Severity | Description |"),s("|----------|-------------|"),W.forEach(a=>s(`| ${g(a.severity)} | ${a.description} |`)),l());const F=n(h.regressionRisks);r(F)||(s("### Regression Risks"),l(),s("| Severity | What | Why |"),s("|----------|------|-----|"),F.forEach(a=>s(`| ${g(a.severity)} | **${a.what}** | ${a.why} |`)),l()),o(),s("## 3. Feasibility Analysis"),l(),s(`**Complexity:** ${p(m)} ${m}`),l(),f.complexityReason&&(s(f.complexityReason),l());const D=f.testability??{},A=[["Unit",n(D.unit)],["Integration",n(D.integration)],["E2E",n(D.e2e)],["⚠️ Difficult",n(D.difficult)]].filter(([,a])=>!!a.length);r(A)||(s("### Testability"),l(),s("| Level | Scope |"),s("|-------|-------|"),A.forEach(([a,$])=>s(`| ${a} | ${$.join("; ")} |`)),l());const H=n(f.blockers);r(H)||(s("### Blockers"),l(),H.forEach(a=>{s(`> 🚫 **${a.what}**`),s(`> *Needs: ${a.unblockNeeded}*`),l()}));const L=n(f.risks);r(L)||(s("### Risks"),l(),s("| Severity | Risk | Likelihood | Impact | Mitigation |"),s("|----------|------|-----------|--------|------------|"),L.forEach(a=>s(`| ${g(a.severity)} | ${a.description} | ${a.likelihood} | ${a.impact} | ${a.mitigation} |`)),l()),o(),s("## 4. Gap Analysis"),l();const M=n(c.knownFacts);s("### Known Facts"),l(),r(M)?s("*None identified.*"):M.forEach(a=>s(`- ${a}`)),l();const C=n(c.unknowns);s("### Unknowns"),l(),r(C)?s("*None identified.*"):C.forEach(a=>s(`> ❓ ${a}`)),l();const T=n(c.assumptions);s("### Assumptions"),l(),r(T)?s("*None identified.*"):T.forEach(a=>s(`- *${a}*`)),l(),o();const B=n(t.highlights);return r(B)||(s("## Key Highlights"),l(),B.forEach((a,$)=>s(`${$+1}. ${a}`))),i.join(`
|
|
2
|
+
`)}function Be({data:t,viewMode:i,setViewMode:n,onClose:r,saveState:s,onSave:l,analysisId:o,appId:g}){var u;const[p,m]=k.useState(!1);return k.useEffect(()=>{const h=f=>{f.key==="Escape"&&r()};return document.addEventListener("keydown",h),()=>document.removeEventListener("keydown",h)},[r]),e.jsxs("div",{style:{position:"fixed",inset:0,zIndex:1e3,background:"var(--t-bg-base)",display:"flex",flexDirection:"column"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"12px 24px",borderBottom:"1px solid var(--t-border-subtle)",background:"var(--t-bg-elevated)",flexShrink:0},children:[e.jsxs("div",{style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:10},children:[e.jsx("code",{style:{fontSize:13,fontWeight:700,color:"var(--t-text-primary)",fontFamily:"monospace"},children:t.ticketId}),e.jsx(O,{complexity:((u=t.feasibility)==null?void 0:u.complexity)??"Medium"}),e.jsx("span",{style:{fontSize:"var(--t-text-sm)",color:"var(--t-text-muted)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.ticketSummary})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexShrink:0},children:[e.jsx("div",{style:{display:"flex",borderRadius:6,overflow:"hidden",border:"1px solid var(--t-border-subtle)"},children:ve.map(({mode:h,icon:f,label:c})=>e.jsxs("button",{onClick:()=>n(h),style:{display:"flex",alignItems:"center",gap:5,padding:"5px 12px",border:"none",cursor:"pointer",fontSize:11,fontWeight:500,background:i===h?"var(--t-text-primary)":"transparent",color:i===h?"var(--t-bg-base)":"var(--t-text-muted)"},children:[f,c]},h))}),l&&e.jsx("button",{onClick:l,disabled:s==="saving"||s==="saved",title:s==="saved"?"Saved to Reports":"Save analysis to Reports",style:{display:"flex",alignItems:"center",gap:5,padding:"0 12px",height:32,borderRadius:6,border:`1px solid ${s==="error"?"var(--t-accent-danger)":s==="saved"?"var(--t-accent-success)":"var(--t-border-subtle)"}`,background:s==="saved"?"rgba(22,163,74,0.08)":s==="error"?"rgba(220,38,38,0.08)":"transparent",cursor:s==="saving"||s==="saved"?"default":"pointer",color:s==="saved"?"var(--t-accent-success)":s==="error"?"var(--t-accent-danger)":"var(--t-text-muted)",fontSize:11,fontWeight:500},children:s==="saved"?e.jsxs(e.Fragment,{children:[e.jsx(oe,{size:12,weight:"bold"})," Saved"]}):s==="error"?"Failed":e.jsxs(e.Fragment,{children:[e.jsx(J,{size:12,weight:"bold"})," Save"]})}),g!=null&&o!=null&&e.jsx("button",{onClick:()=>m(h=>!h),title:"Comments",style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,borderRadius:6,border:"1px solid var(--t-border-subtle)",background:p?"var(--t-bg-elevated)":"transparent",cursor:"pointer",color:p?"var(--t-text-primary)":"var(--t-text-muted)"},children:e.jsx(te,{size:15,weight:p?"fill":"regular"})}),e.jsx("button",{onClick:r,style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,borderRadius:6,border:"1px solid var(--t-border-subtle)",background:"transparent",cursor:"pointer",color:"var(--t-text-muted)"},children:e.jsx(pe,{size:15,weight:"bold"})})]})]}),e.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden"},children:[e.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"24px"},children:[i==="cards"&&e.jsx(ye,{data:t,fullscreen:!0}),i==="list"&&e.jsx(ue,{data:t}),i==="markdown"&&e.jsx(G,{title:"Analysis",children:e.jsx(X,{content:be(t)})})]}),p&&g!=null&&o!=null&&e.jsx("div",{style:{width:380,flexShrink:0,borderLeft:"1px solid var(--t-border-subtle)",display:"flex",flexDirection:"column",overflow:"hidden",background:"var(--t-bg-surface)"},children:e.jsx(me,{appId:g,analysisId:o})})]})]})}const ve=[{mode:"cards",icon:e.jsx(Ce,{size:11}),label:"Cards"},{mode:"list",icon:e.jsx(le,{size:11}),label:"List"},{mode:"markdown",icon:e.jsx(ae,{size:11}),label:"Markdown"}];function it({data:t,label:i,appId:n,analysisId:r,hideSave:s,standalone:l,viewMode:o,setViewMode:g,expanded:p,setExpanded:m}){var M;const[u,h]=k.useState("cards"),[f,c]=k.useState(!1),x=o??u,b=g??h,S=p??f,z=m??c,[y,w]=k.useState("idle"),[I,N]=k.useState(!1),[P,W]=k.useState(!1);async function F(){w("saved");try{await E.analyses.create(n,{ticketId:t.ticketId,ticketSummary:t.ticketSummary,repoName:t.repoName??void 0,analysisData:t})}catch{w("error"),setTimeout(()=>w("idle"),3e3)}}async function D(){if(!(!n||y==="saving"||y==="saved")){w("saving");try{if((await E.analyses.list(n)).some(T=>T.ticketId===t.ticketId)){w("idle"),W(!0);return}}catch{}await F()}}const A=e.jsxs("div",{style:{flex:1,background:l?"transparent":"var(--t-bg-elevated)",border:l?"none":"1px solid var(--t-border-subtle)",borderRadius:l?0:"4px 14px 14px 14px",padding:l?0:"14px 16px",minWidth:0,display:"flex",flexDirection:"column",gap:12},children:[!l&&e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:10,flexWrap:"wrap"},children:[e.jsxs("div",{style:{flex:1,minWidth:0},children:[i&&e.jsx("p",{style:{margin:"0 0 4px",fontSize:10,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.07em",color:"var(--t-text-muted)"},children:i}),e.jsxs("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}),e.jsx(O,{complexity:((M=t.feasibility)==null?void 0:M.complexity)??"Medium"})]}),e.jsx("p",{style:{margin:"4px 0 0",fontSize:"var(--t-text-sm)",color:"var(--t-text-secondary)",lineHeight:1.4},children:t.ticketSummary})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flexShrink:0},children:[e.jsx("div",{style:{display:"flex",borderRadius:6,overflow:"hidden",border:"1px solid var(--t-border-subtle)"},children:ve.map(({mode:C,icon:T,label:B})=>e.jsxs("button",{onClick:()=>b(C),style:{display:"flex",alignItems:"center",gap:5,padding:"4px 10px",border:"none",cursor:"pointer",fontSize:11,fontWeight:500,background:x===C?"var(--t-text-primary)":"transparent",color:x===C?"var(--t-bg-base)":"var(--t-text-muted)",transition:"background 0.12s"},children:[T,B]},C))}),n&&!s&&e.jsx("button",{onClick:D,disabled:y==="saving"||y==="saved",title:y==="saved"?"Saved to Reports":"Save analysis to Reports",style:{display:"flex",alignItems:"center",gap:5,padding:"0 10px",height:28,borderRadius:6,border:`1px solid ${y==="error"?"var(--t-accent-danger)":y==="saved"?"var(--t-accent-success)":"var(--t-border-subtle)"}`,background:y==="saved"?"rgba(22,163,74,0.08)":y==="error"?"rgba(220,38,38,0.08)":"transparent",cursor:y==="saving"||y==="saved"?"default":"pointer",color:y==="saved"?"var(--t-accent-success)":y==="error"?"var(--t-accent-danger)":"var(--t-text-muted)",fontSize:11,fontWeight:500},children:y==="saved"?e.jsxs(e.Fragment,{children:[e.jsx(oe,{size:12,weight:"bold"})," Saved"]}):y==="error"?"Failed":e.jsxs(e.Fragment,{children:[e.jsx(J,{size:12,weight:"bold"})," Save"]})}),n!=null&&r!=null&&e.jsx("button",{onClick:()=>N(C=>!C),title:"Comments",style:{display:"flex",alignItems:"center",justifyContent:"center",width:28,height:28,borderRadius:6,border:"1px solid var(--t-border-subtle)",background:I?"var(--t-bg-elevated)":"transparent",cursor:"pointer",color:I?"var(--t-text-primary)":"var(--t-text-muted)"},children:e.jsx(te,{size:13,weight:I?"fill":"regular"})}),e.jsx("button",{onClick:()=>z(!0),title:"Expand to full screen",style:{display:"flex",alignItems:"center",justifyContent:"center",width:28,height:28,borderRadius:6,border:"1px solid var(--t-border-subtle)",background:"transparent",cursor:"pointer",color:"var(--t-text-muted)"},children:e.jsx(ce,{size:13,weight:"bold"})})]})]}),e.jsxs("div",{style:{display:"flex",flex:1,gap:0,minHeight:0},children:[e.jsxs("div",{style:{flex:1,minWidth:0},children:[x==="cards"&&e.jsx(ye,{data:t,fullscreen:l}),x==="list"&&e.jsx(ue,{data:t}),x==="markdown"&&e.jsx(G,{title:"Analysis",children:e.jsx(X,{content:be(t)})})]}),!l&&I&&n!=null&&r!=null&&e.jsx("div",{style:{width:360,flexShrink:0,borderLeft:"1px solid var(--t-border-subtle)",display:"flex",flexDirection:"column",overflow:"hidden"},children:e.jsx(me,{appId:n,analysisId:r})})]})]}),H=S&&e.jsx(Be,{data:t,viewMode:x,setViewMode:b,onClose:()=>z(!1),saveState:y,onSave:n&&!s?D:void 0,analysisId:r,appId:n}),L=e.jsx(he,{open:P,title:"Analysis already exists",description:`An analysis for ${t.ticketId} has already been saved. Save another copy anyway?`,confirmLabel:"Save anyway",onConfirm:()=>{W(!1),F()},onCancel:()=>W(!1)});return l?e.jsxs(e.Fragment,{children:[A,H,L]}):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("svg",{width:"13",height:"13",viewBox:"0 0 256 256",fill:"var(--t-bg-base)",children:e.jsx("path",{d:"M197.58,129.06l-51.61-19.68,19.7-51.65a15.92,15.92,0,0,0-9.27-20.49h0a15.92,15.92,0,0,0-20.49,9.27L116.3,97.86,64.67,78.18A16,16,0,0,0,44.18,87.45h0A16,16,0,0,0,53.45,107.94l51.62,19.69-19.7,51.65a15.92,15.92,0,0,0,9.27,20.49h0a15.92,15.92,0,0,0,20.49-9.27l19.61-51.55,51.62,19.68a16,16,0,0,0,20.49-9.27h0A16,16,0,0,0,197.58,129.06Z"})})}),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,display:"flex",flexDirection:"column",gap:12},children:A})]}),H,L]})}const ie=new Map,se=new Map;function qe(t,i){return`${t}:${i}`}function st(){return ie.size+se.size}function nt(){ie.clear(),se.clear()}function Ge(t){ie.delete(t)}function rt(t,i){se.delete(qe(t,i))}function Oe(t){if(!t)return"";const i=t.trim();if(i.startsWith("{"))try{const n=JSON.parse(i),r=n.notes??n.plan??n.content;if(typeof r=="string"&&r.trim())return r.trim()}catch{}return i}function Ue(t){if(!t)return[];const i=t.split(`
|
|
3
|
+
`),n=[];let r=null,s=!0;for(const l of i)l.startsWith("## ")?(r&&n.push(r),r={heading:l.replace(/^##\s+/,""),body:"",defaultOpen:s},s=!1):r&&(r.body+=l+`
|
|
4
|
+
`);return r&&n.push(r),n.length===0&&t.trim()&&n.push({heading:"Content",body:t,defaultOpen:!0}),n}function Ke({heading:t,body:i,defaultOpen:n}){const[r,s]=k.useState(n);return e.jsxs("div",{style:{border:"1px solid var(--t-border-subtle)",borderRadius:6,overflow:"hidden"},children:[e.jsxs("button",{onClick:()=>s(l=>!l),style:{width:"100%",display:"flex",alignItems:"center",gap:8,padding:"9px 14px",background:"var(--t-bg-panel)",border:"none",cursor:"pointer",color:"var(--t-text-primary)"},children:[r?e.jsx(de,{size:11,weight:"bold"}):e.jsx(xe,{size:11,weight:"bold"}),e.jsx("span",{style:{flex:1,textAlign:"left",fontSize:"var(--t-text-sm)",fontWeight:600},children:t})]}),r&&e.jsx("div",{style:{padding:"12px 14px",background:"var(--t-bg-elevated)",borderTop:"1px solid var(--t-border-subtle)"},children:e.jsx(X,{content:i.trim()})})]})}function Ve({content:t}){const i=Ue(t);return i.length?e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:i.map((n,r)=>e.jsx(Ke,{...n},r))}):null}const _e=[{mode:"list",icon:e.jsx(le,{size:11}),label:"List"},{mode:"markdown",icon:e.jsx(ae,{size:11}),label:"Markdown"}];function je({viewMode:t,setViewMode:i}){return e.jsx("div",{style:{display:"flex",borderRadius:6,overflow:"hidden",border:"1px solid var(--t-border-subtle)"},children:_e.map(({mode:n,icon:r,label:s})=>e.jsxs("button",{onClick:()=>i(n),style:{display:"flex",alignItems:"center",gap:5,padding:"4px 10px",border:"none",cursor:"pointer",fontSize:11,fontWeight:500,background:t===n?"var(--t-text-primary)":"transparent",color:t===n?"var(--t-bg-base)":"var(--t-text-muted)",transition:"background 0.12s"},children:[r,s]},n))})}function ne({data:t,viewMode:i,activeTab:n,setActiveTab:r}){const s=t.planType==="both"&&t.plan&&t.notes,l=Oe(s?n==="plan"?t.plan:t.notes:t.planType==="notes"?t.notes:t.plan);return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:0},children:[s&&e.jsx("div",{style:{display:"flex",gap:2,borderBottom:"1px solid var(--t-border-subtle)",marginBottom:12},children:["plan","notes"].map(o=>e.jsx("button",{onClick:()=>r(o),style:{padding:"6px 14px",fontSize:11,fontWeight:500,border:"none",background:"none",cursor:"pointer",borderBottom:n===o?"2px solid var(--t-accent-primary)":"2px solid transparent",color:n===o?"var(--t-accent-primary)":"var(--t-text-secondary)"},children:o==="plan"?"Test Plan":"Test Notes"},o))}),l?i==="list"?e.jsx(Ve,{content:l}):e.jsxs("div",{style:{border:"1px solid var(--t-border-subtle)",borderRadius:6,overflow:"hidden",background:"var(--t-bg-elevated)"},children:[e.jsx("div",{style:{padding:"8px 12px",background:"var(--t-bg-panel)",borderBottom:"1px solid var(--t-border-subtle)"},children:e.jsx("span",{style:{fontSize:11,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.07em",color:"var(--t-text-muted)"},children:s?n==="plan"?"Test Plan":"Test Notes":t.planType==="notes"?"Test Notes":"Test Plan"})}),e.jsx("div",{style:{padding:"11px 12px"},children:e.jsx(X,{content:l})})]}):null]})}function Ye({data:t,viewMode:i,setViewMode:n,activeTab:r,setActiveTab:s,onClose:l,saveState:o,onSave:g}){return k.useEffect(()=>{const p=m=>{m.key==="Escape"&&l()};return document.addEventListener("keydown",p),()=>document.removeEventListener("keydown",p)},[l]),e.jsxs("div",{style:{position:"fixed",inset:0,zIndex:1e3,background:"var(--t-bg-base)",display:"flex",flexDirection:"column"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"12px 24px",borderBottom:"1px solid var(--t-border-subtle)",background:"var(--t-bg-elevated)",flexShrink:0},children:[e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("p",{style:{margin:"0 0 2px",fontSize:10,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.07em",color:"var(--t-text-muted)"},children:t.planType==="notes"?"Test Notes":t.planType==="plan"?"Test Plan":"Test Plan & Notes"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},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("span",{style:{fontSize:"var(--t-text-sm)",color:"var(--t-text-muted)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.ticketSummary})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexShrink:0},children:[e.jsx(je,{viewMode:i,setViewMode:n}),g&&e.jsx("button",{onClick:g,disabled:o==="saving"||o==="saved",style:{display:"flex",alignItems:"center",gap:5,padding:"0 12px",height:32,borderRadius:6,fontSize:11,fontWeight:500,border:`1px solid ${o==="error"?"var(--t-accent-danger)":o==="saved"?"var(--t-accent-success)":"var(--t-border-subtle)"}`,background:o==="saved"?"rgba(22,163,74,0.08)":o==="error"?"rgba(220,38,38,0.08)":"transparent",cursor:o==="saving"||o==="saved"?"default":"pointer",color:o==="saved"?"var(--t-accent-success)":o==="error"?"var(--t-accent-danger)":"var(--t-text-muted)"},children:o==="saved"?e.jsxs(e.Fragment,{children:[e.jsx(ge,{size:12,weight:"fill"})," Saved"]}):o==="error"?"Failed":e.jsxs(e.Fragment,{children:[e.jsx(J,{size:12,weight:"bold"})," Save"]})}),e.jsx("button",{onClick:l,style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,borderRadius:6,border:"1px solid var(--t-border-subtle)",background:"transparent",cursor:"pointer",color:"var(--t-text-muted)"},children:e.jsx(pe,{size:15,weight:"bold"})})]})]}),e.jsx("div",{style:{flex:1,overflowY:"auto",padding:"24px"},children:e.jsx(ne,{data:t,viewMode:i,activeTab:r,setActiveTab:s})})]})}function lt({data:t,appId:i,hideSave:n}){const[r,s]=k.useState("idle"),[l,o]=k.useState("list"),[g,p]=k.useState(t.planType==="notes"?"notes":"plan"),[m,u]=k.useState(!1),[h,f]=k.useState(!1);async function c(){s("saved");try{await E.plans.create(i,{ticketId:t.ticketId,ticketSummary:t.ticketSummary,repoName:t.repoName??void 0,mrPrUrl:t.mrPrUrl??void 0,planType:t.planType,planData:t.plan??void 0,testNotes:t.notes??void 0}),i&&Ge(i)}catch{s("error"),setTimeout(()=>s("idle"),3e3)}}async function x(){if(!(!i||r==="saving"||r==="saved")){s("saving");try{if((await E.plans.list(i)).some(z=>z.ticketId===t.ticketId)){s("idle"),f(!0);return}}catch{}await c()}}const b=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.jsx("p",{style:{margin:"0 0 4px",fontSize:10,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.07em",color:"var(--t-text-muted)"},children:t.planType==="notes"?"Test Notes":t.planType==="plan"?"Test Plan":"Test Plan & Notes"}),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(Re,{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(Ie,{size:11})," MR/PR"]})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flexShrink:0},children:[e.jsx(je,{viewMode:l,setViewMode:o}),!n&&i&&e.jsx("button",{onClick:x,disabled:r==="saving"||r==="saved",title:r==="saved"?"Saved to Reports":"Save to Test Plans",style:{display:"flex",alignItems:"center",gap:5,padding:"0 10px",height:28,borderRadius:6,fontSize:11,fontWeight:500,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(ge,{size:12,weight:"fill"})," Saved"]}):r==="saving"?e.jsxs(e.Fragment,{children:[e.jsx($e,{size:12,className:"spin"})," Saving"]}):r==="error"?e.jsxs(e.Fragment,{children:[e.jsx(De,{size:12})," Failed"]}):e.jsxs(e.Fragment,{children:[e.jsx(J,{size:12,weight:"bold"})," Save"]})}),e.jsx("button",{onClick:()=>u(!0),title:"Expand to full screen",style:{display:"flex",alignItems:"center",justifyContent:"center",width:28,height:28,borderRadius:6,border:"1px solid var(--t-border-subtle)",background:"transparent",cursor:"pointer",color:"var(--t-text-muted)"},children:e.jsx(ce,{size:13,weight:"bold"})})]})]}),e.jsx(ne,{data:t,viewMode:l,activeTab:g,setActiveTab:p})]});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("svg",{width:"13",height:"13",viewBox:"0 0 256 256",fill:"var(--t-bg-base)",children:e.jsx("path",{d:"M197.58,129.06l-51.61-19.68,19.7-51.65a15.92,15.92,0,0,0-9.27-20.49h0a15.92,15.92,0,0,0-20.49,9.27L116.3,97.86,64.67,78.18A16,16,0,0,0,44.18,87.45h0A16,16,0,0,0,53.45,107.94l51.62,19.69-19.7,51.65a15.92,15.92,0,0,0,9.27,20.49h0a15.92,15.92,0,0,0,20.49-9.27l19.61-51.55,51.62,19.68a16,16,0,0,0,20.49-9.27h0A16,16,0,0,0,197.58,129.06Z"})})}),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:b})]}),m&&e.jsx(Ye,{data:t,viewMode:l,setViewMode:o,activeTab:g,setActiveTab:p,onClose:()=>u(!1),saveState:r,onSave:i&&!n?x:void 0}),e.jsx(he,{open:h,title:"Entry already exists",description:`A ${t.planType==="notes"?"test notes":t.planType==="plan"?"test plan":"test plan & notes"} for ${t.ticketId} has already been saved. Save another copy anyway?`,confirmLabel:"Save anyway",onConfirm:()=>{f(!1),c()},onCancel:()=>f(!1)})]})}function at({planData:t,testNotes:i,planType:n,viewMode:r}){const[s,l]=k.useState(n==="notes"?"notes":"plan"),o={_type:"test-plan",ticketId:"",ticketSummary:"",repoName:null,mrPrUrl:null,planType:n,plan:t,notes:i};return e.jsx(ne,{data:o,viewMode:r,activeTab:s,setActiveTab:l})}const ke=new Map,Se=new Map,re=new Map;function Je(t,i){return`${t}:${i}`}function ot(t,i){re.delete(Je(t,i))}const we=new Map,Z=new Map,Q=new Map;function ct(t,i){return`${t}:${i}`}function dt(){return ke.size+Se.size+re.size+we.size+Z.size+Q.size}function xt(){ke.clear(),Se.clear(),re.clear(),we.clear(),Z.clear(),Q.clear()}function pt(){return Z.size+Q.size+Ee()}function gt(){Z.clear(),Q.clear(),Te()}export{it as A,X as M,lt as P,ve as T,je as V,ke as a,we as b,Se as c,re as d,Je as e,xt as f,gt as g,nt as h,ot as i,dt as j,pt as k,st as l,Q as m,me as n,at as o,se as p,ct as q,Z as r,qe as s,ie as t,rt as u,Ge as v};
|