@testver/testver 1.4.3 → 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/LICENSE +88 -69
  2. package/README.md +6 -2
  3. package/bin/testver.js +9 -1
  4. package/dist/index.js +38415 -21751
  5. package/package.json +179 -178
  6. package/src/ui/static/agents/antigravity.svg +76 -0
  7. package/src/ui/static/agents/codex.svg +3 -0
  8. package/src/ui/static/agents/gemini.svg +1 -0
  9. package/src/ui/static/agents/opencode.svg +4 -0
  10. package/src/ui/static/agents/vscode.svg +17 -0
  11. package/src/ui/static/assets/{AIPanel-KQFq4c0Q.js → AIPanel-RWO8Cd9w.js} +32 -32
  12. package/src/ui/static/assets/{AIRecordPanel-CAs8fXyS.js → AIRecordPanel-DnreS585.js} +40 -40
  13. package/src/ui/static/assets/{AIStreamUI-p_sMTEDQ.js → AIStreamUI-C1gHJtlF.js} +9 -9
  14. package/src/ui/static/assets/{AITestGenPage-CHaHfmu4.js → AITestGenPage-C8bWUelu.js} +5 -5
  15. package/src/ui/static/assets/{APITestingPage-BSGJY_hd.js → APITestingPage-DwL67hqL.js} +19 -19
  16. package/src/ui/static/assets/AboutPage-CynLB95E.js +1 -0
  17. package/src/ui/static/assets/AccessTokensTab-BdevOmpE.js +1 -0
  18. package/src/ui/static/assets/AdvancedPage-BeM7aB8b.js +3 -0
  19. package/src/ui/static/assets/{AnalyticsPage-Lm8noJqC.js → AnalyticsPage-C5ddYfRk.js} +1 -1
  20. package/src/ui/static/assets/AuditLogPage-DYcUdJoj.js +1 -0
  21. package/src/ui/static/assets/{ChangesSummary-Cu0_4Ucf.js → ChangesSummary-BjNMwGIZ.js} +3 -3
  22. package/src/ui/static/assets/{CodeMapPage-uEjuo3fk.js → CodeMapPage-BQOEtv-R.js} +3 -3
  23. package/src/ui/static/assets/{ConfirmDialog-DtotgVmI.js → ConfirmDialog-D_N9188T.js} +1 -1
  24. package/src/ui/static/assets/{CoveragePage-jNkQJA1P.js → CoveragePage-8bDSphY1.js} +2 -2
  25. package/src/ui/static/assets/{CronBuilder-D2fERHt9.js → CronBuilder-C7_JADb7.js} +1 -1
  26. package/src/ui/static/assets/{Dashboard-BaIj_IdQ.js → Dashboard-B22yRPyV.js} +1 -1
  27. package/src/ui/static/assets/{DefectsPage-DH0njYFG.js → DefectsPage-Arv4Ac-b.js} +72 -72
  28. package/src/ui/static/assets/{EmptyState-utxlJ0fu.js → EmptyState-BShNSbLf.js} +1 -1
  29. package/src/ui/static/assets/{ExportButton-ouKqn9CU.js → ExportButton-xrS_AnfS.js} +1 -1
  30. package/src/ui/static/assets/{FileViewer-mU3JloJ6.js → FileViewer-Bcr9T1jW.js} +18 -18
  31. package/src/ui/static/assets/{GitPage-TrX-RqNC.js → GitPage-DXL2Sv40.js} +12 -12
  32. package/src/ui/static/assets/{ImportExportPage-CIhK_raX.js → ImportExportPage-BcjzRd7T.js} +36 -36
  33. package/src/ui/static/assets/{JiraPushDialog-DgEZS-0u.js → JiraPushDialog-DNYU9Ce0.js} +1 -1
  34. package/src/ui/static/assets/{KpiTile-BHLE3HVj.js → KpiTile-BKlWqjgN.js} +1 -1
  35. package/src/ui/static/assets/{LiveExecutionView-CaIf7Jux.js → LiveExecutionView-1LlyEDEe.js} +1 -1
  36. package/src/ui/static/assets/{MediaModal-DNM45Uz2.js → MediaModal-Dyy_iHl9.js} +1 -1
  37. package/src/ui/static/assets/MobileRunPicker-Cf5rm469.js +1 -0
  38. package/src/ui/static/assets/MobileRunTarget-C4M4YJJh.js +6 -0
  39. package/src/ui/static/assets/{ModuleExplorer-rni7JbsL.js → ModuleExplorer-BKVbxFZK.js} +1 -1
  40. package/src/ui/static/assets/{OutputPage-Cn2WCpJ6.js → OutputPage-Bi-28tJi.js} +1 -1
  41. package/src/ui/static/assets/PipelinesPanel-BtO3iSJ4.js +1 -0
  42. package/src/ui/static/assets/{ProfilePage-BKNdkSnx.js → ProfilePage-BgZ4VDC-.js} +1 -1
  43. package/src/ui/static/assets/{ProjectExplorer-5e7J8t-o.js → ProjectExplorer-BVGbmVP7.js} +1 -1
  44. package/src/ui/static/assets/{RemoteFileStrip-C1S2aclP.js → RemoteFileStrip-dzPInzgb.js} +1 -1
  45. package/src/ui/static/assets/{ReportCard-D4EElEe9.js → ReportCard-LOf1PXlb.js} +2 -2
  46. package/src/ui/static/assets/{ReportFullView-2w2ysKRg.js → ReportFullView-Ce4OI8lf.js} +1 -1
  47. package/src/ui/static/assets/{ReportsPage-9Fx-IEwV.js → ReportsPage-DFxCQ8cY.js} +48 -48
  48. package/src/ui/static/assets/{ResultsPage-DPkfGh-K.js → ResultsPage-DD-uj8gk.js} +115 -115
  49. package/src/ui/static/assets/{RunState-CRuS_bC2.js → RunState-DDwFB4tA.js} +1 -1
  50. package/src/ui/static/assets/{RunTargets-CPKBrefj.js → RunTargets-CkIpY3v3.js} +1 -1
  51. package/src/ui/static/assets/ScriptMappingPage-DQQoR6sR.js +1 -0
  52. package/src/ui/static/assets/{SearchableDevicePicker-DubIldKj.js → SearchableDevicePicker-CenIxD7b.js} +1 -1
  53. package/src/ui/static/assets/{SettingsPage-BuZrrlW2.js → SettingsPage-DAV_0y0m.js} +83 -83
  54. package/src/ui/static/assets/{SharedReportView-ig5hECRk.js → SharedReportView-CqSLFKT1.js} +1 -1
  55. package/src/ui/static/assets/{SourcesPage-BPkqRqkC.js → SourcesPage-BvqC9oKw.js} +14 -14
  56. package/src/ui/static/assets/TestExplorerPage-Bdnll77k.js +7 -0
  57. package/src/ui/static/assets/{TestManagementPage-DJiWpCne.js → TestManagementPage-CCNE688A.js} +10 -10
  58. package/src/ui/static/assets/{TestPlansPage-G1lvK1C0.js → TestPlansPage-T6D25i6-.js} +5 -5
  59. package/src/ui/static/assets/{TestverCreditsRing-CEBSy3w3.js → TestverCreditsRing-CoDk5eAS.js} +1 -1
  60. package/src/ui/static/assets/TestverMcpPage-Dte0qSXp.js +34 -0
  61. package/src/ui/static/assets/{UncommittedDiffViewer-FKvUZcRi.js → UncommittedDiffViewer-BNroxCoo.js} +2 -2
  62. package/src/ui/static/assets/{UserManagementPage-gDGhaHE4.js → UserManagementPage-BU4MuDJZ.js} +10 -10
  63. package/src/ui/static/assets/{WorkflowsPage-BACdnU-1.js → WorkflowsPage-BP5k7AqE.js} +83 -83
  64. package/src/ui/static/assets/clipboard-BIEd7Ccc.js +1 -0
  65. package/src/ui/static/assets/{hiddenLlmProviders-DzwaR-b9.js → hiddenLlmProviders-BPORgy-e.js} +1 -1
  66. package/src/ui/static/assets/index-BlA8ntjb.js +47 -0
  67. package/src/ui/static/assets/index-Co4_SlGD.css +1 -0
  68. package/src/ui/static/assets/{reportMeta-3kxT7BIT.js → reportMeta-B9ZRW6ts.js} +1 -1
  69. package/src/ui/static/assets/runSelected-BoPm1sz-.js +1 -0
  70. package/src/ui/static/assets/{useFeatureFlags-DrhvBp0C.js → useFeatureFlags-B4Otsv-N.js} +1 -1
  71. package/src/ui/static/assets/{useJiraConnector-Dwj69Rfh.js → useJiraConnector--JZhbYrT.js} +1 -1
  72. package/src/ui/static/assets/{useOwnership-C1CmzcvJ.js → useOwnership-BhPOiYzy.js} +1 -1
  73. package/src/ui/static/assets/useSuites-GN_K2mHc.js +1 -0
  74. package/src/ui/static/assets/{useTestExplorer-CUqC18DV.js → useTestExplorer-BGhkGHKy.js} +1 -1
  75. package/src/ui/static/assets/{useTestLifecycle-C2S_vaX2.js → useTestLifecycle-DX5ES6x8.js} +1 -1
  76. package/src/ui/static/assets/{useTestManagement-DW6AW2mt.js → useTestManagement-ommXjx0q.js} +2 -2
  77. package/src/ui/static/assets/{useTestResults-yjH1aUy-.js → useTestResults-DWjvm8gm.js} +1 -1
  78. package/src/ui/static/assets/{vendor-icons-D_Dmmj8d.js → vendor-icons-Cm92aSc5.js} +1426 -1416
  79. package/src/ui/static/index.html +479 -479
  80. package/src/ui/static/assets/AboutPage-CDa24SCJ.js +0 -1
  81. package/src/ui/static/assets/AdvancedPage-BqXP0FLg.js +0 -3
  82. package/src/ui/static/assets/AuditLogPage-BvldSIik.js +0 -1
  83. package/src/ui/static/assets/MobileRunPicker-DFKm6_nU.js +0 -1
  84. package/src/ui/static/assets/MobileRunTarget-DHDoDZ_F.js +0 -6
  85. package/src/ui/static/assets/PipelinesPanel-D6zWcLtD.js +0 -1
  86. package/src/ui/static/assets/ScriptMappingPage-C3K_uyf0.js +0 -1
  87. package/src/ui/static/assets/TestExplorerPage-C_jl93GR.js +0 -7
  88. package/src/ui/static/assets/index-D6sQYc_0.js +0 -47
  89. package/src/ui/static/assets/index-aInN0yoR.css +0 -1
  90. package/src/ui/static/assets/runSelected-WlgnZcSF.js +0 -1
  91. package/src/ui/static/assets/useSuites-V0AxZYex.js +0 -1
@@ -1,10 +1,10 @@
1
- import{r as o,j as e,d as Kt,u as Ht}from"./vendor-react-DOVfxdUy.js";import{a as mt,f as Je}from"./formatDate-T65-Y6Mi.js";import{ImportExportPage as Zt}from"./ImportExportPage-CIhK_raX.js";import{a as Qt,b as Wt,u as Yt}from"./useTabParam-CyYAP90W.js";import{u as Xt}from"./useDebouncedValue-C9odz7b2.js";import{f as es}from"./formatTestName-BKd2Uqhs.js";import{E as ts,J as ss,K as as,L as rs,D as ns,M as ls,N as is,F as ds,O as os,P as cs,Q as xs,R as ms,S as us,T as ps,U as hs,V as gs,W as bs,X as fs,Y as ys,Z as js,_ as ut,$ as vs,a0 as Ns,a1 as ws,a2 as ks,a3 as Ss,a4 as Ts,a5 as zs,a6 as Cs,a7 as pt,a8 as As,a9 as Ms}from"./useTestManagement-DW6AW2mt.js";import{E as Rs}from"./ExportButton-ouKqn9CU.js";import{b as ht,ae as Ds,gB as $s,x as Es}from"./index-D6sQYc_0.js";import{u as gt,b as Ls,a as Is,c as _s}from"./useJiraConnector-Dwj69Rfh.js";import{h as Fs}from"./aiHandoff-vhtR29Fh.js";import{J as Ps}from"./JiraPushDialog-DgEZS-0u.js";import{a as Bs}from"./vendor-query-DkZSMtfn.js";import{B as Us,X as ee,y as ne,v as $e,ag as pe,bt,d as ce,i as Pe,Z as Be,o as me,m as Os,b4 as Me,dh as et,c0 as Js,e as qs,aM as ve,bv as Gs,r as xe,ap as ft,b7 as ue,bL as tt,b8 as st,cc as Vs,aJ as yt,aa as Ue,bb as Ee,t as qe,F as Ks,b0 as Hs,a2 as at,bj as rt,f as nt,a_ as jt,G as _e,u as Fe,bd as Zs,a5 as Qs,_ as Ae,al as je,as as Ws,g as lt,ah as it,S as dt,a0 as vt,a6 as Ys,an as ot,b1 as Xs,C as ea,aS as ta,di as sa,cx as aa}from"./vendor-icons-D_Dmmj8d.js";import"./excel-BrxuVus5.js";import"./vendor-excel-BFHGVHVC.js";const Nt=["critical","high","medium","low"],wt=["web","ui","api","mobile","database","integration","e2e","security","performance","usability","accessibility","compatibility","localization"],kt=["draft","active","deprecated","archived"],St=["manual","automated","needs_update"],Tt=["draft","in_review","approved","rejected"],Ce=20,ct={critical:"bg-red-500/20 text-red-300",high:"bg-orange-500/20 text-orange-300",medium:"bg-amber-500/20 text-amber-300",low:"bg-emerald-500/20 text-emerald-300"},Oe={web:"bg-sky-500/20 text-sky-300",ui:"bg-indigo-500/20 text-indigo-300",api:"bg-cyan-500/20 text-cyan-300",mobile:"bg-violet-500/20 text-violet-300",database:"bg-teal-500/20 text-teal-300",integration:"bg-emerald-500/20 text-emerald-300",e2e:"bg-blue-500/20 text-blue-300",security:"bg-red-500/20 text-red-300",performance:"bg-rose-500/20 text-rose-300",usability:"bg-amber-500/20 text-amber-300",accessibility:"bg-fuchsia-500/20 text-fuchsia-300",compatibility:"bg-purple-500/20 text-purple-300",localization:"bg-orange-500/20 text-orange-300"},xt={draft:"bg-gray-500/20 text-gray-300",active:"bg-brand-500/20 text-brand-300",deprecated:"bg-red-500/20 text-red-300",archived:"bg-slate-500/20 text-slate-400"},Re={manual:"Manual",automated:"Automated",needs_update:"Needs Update"},De={draft:"Draft",in_review:"In Review",approved:"Approved",rejected:"Rejected"};function Z(t){const y={api:"API",ui:"UI",e2e:"E2E"};return y[t]?y[t]:t.replace(/_/g," ").replace(/\b\w/g,u=>u.toUpperCase())}function zt({node:t,depth:y,selectedFolderId:u,onSelect:g,onEdit:p,onDelete:b}){const[v,h]=o.useState(!0),[d,j]=o.useState(!1),[f,c]=o.useState(t.name),[N,i]=o.useState(!1),r=t.children&&t.children.length>0,x=u===t.id,T=hs(),z=()=>{f.trim()&&f!==t.name&&T.mutate({id:t.id,data:{name:f.trim()}}),j(!1)};return e.jsxs("div",{children:[e.jsxs("div",{className:`group flex items-center gap-1 px-2 py-1.5 rounded-lg cursor-pointer transition-colors text-sm ${x?"bg-brand-500/15 text-brand-300":"text-gray-300 hover:bg-surface-2"}`,style:{paddingLeft:`${y*16+8}px`},onClick:()=>g(t.id),onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),children:[r?e.jsx("button",{onClick:m=>{m.stopPropagation(),h(!v)},className:"p-0.5 hover:bg-white/10 rounded",children:v?e.jsx(ne,{size:14}):e.jsx(qe,{size:14})}):e.jsx("span",{className:"w-5"}),v&&r?e.jsx(Ks,{size:15,className:"text-brand-400 flex-shrink-0"}):e.jsx(ve,{size:15,className:"text-gray-500 flex-shrink-0"}),d?e.jsx("input",{className:"flex-1 bg-surface-2 border border-white/10 rounded px-1.5 py-0.5 text-sm text-gray-200 outline-none focus:border-brand-500",value:f,onChange:m=>c(m.target.value),onBlur:z,onKeyDown:m=>{m.key==="Enter"&&z(),m.key==="Escape"&&j(!1)},onClick:m=>m.stopPropagation(),autoFocus:!0}):e.jsx("span",{className:"flex-1 truncate",children:t.name}),e.jsx("span",{className:"text-xs text-gray-500 mr-1",children:t.testCaseCount??0}),N&&!d&&e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx("button",{onClick:m=>{m.stopPropagation(),c(t.name),j(!0)},className:"p-1 rounded hover:bg-white/10 text-gray-400 hover:text-gray-200",children:e.jsx(Ee,{size:12})}),e.jsx("button",{onClick:m=>{m.stopPropagation(),b(t.id)},className:"p-1 rounded hover:bg-white/10 text-gray-400 hover:text-red-400",children:e.jsx(ue,{size:12})})]})]}),v&&r&&e.jsx("div",{children:t.children.map(m=>e.jsx(zt,{node:m,depth:y+1,selectedFolderId:u,onSelect:g,onEdit:p,onDelete:b},m.id))})]})}function ra({testCase:t,folders:y,tags:u,onClose:g,onSaved:p,currentUserName:b}){var F,Y;const v=!!(t!=null&&t.id),h=gs(),d=bs(),j=fs(),f=ys(),c=js(),{data:N}=ut(t==null?void 0:t.id),[i,r]=o.useState({title:(t==null?void 0:t.title)||"",preconditions:(t==null?void 0:t.preconditions)||"",priority:(t==null?void 0:t.priority)||"medium",type:(t==null?void 0:t.type)||"web",status:(t==null?void 0:t.status)||"draft",automationStatus:(t==null?void 0:t.automationStatus)||"manual",reviewStatus:(t==null?void 0:t.reviewStatus)||"draft",folderId:(t==null?void 0:t.folderId)||"",estimatedDuration:(t==null?void 0:t.estimatedDuration)||""}),[x,T]=o.useState((F=t==null?void 0:t.steps)!=null&&F.length?t.steps.map(n=>({id:n.id,action:n.action||"",expectedResult:n.expectedResult||"",testData:n.testData||""})):[{action:"",expectedResult:"",testData:""}]),[z,m]=o.useState(new Set(((Y=t==null?void 0:t.tags)==null?void 0:Y.map(n=>n.id))||[])),[I,D]=o.useState(""),[G,U]=o.useState(!1);o.useEffect(()=>{const n=(N==null?void 0:N.steps)||[];n.length>0&&v&&T(n.map(w=>({id:w.id,action:w.action||"",expectedResult:w.expectedResult||"",testData:w.testData||""})))},[N,v]);const A=o.useCallback((n,w=0)=>{const k=[];for(const S of n)k.push({id:S.id,name:S.name,depth:w}),S.children&&k.push(...A(S.children,w+1));return k},[]),l=o.useMemo(()=>A(y||[]),[y,A]),P=()=>T([...x,{action:"",expectedResult:"",testData:""}]),V=n=>{x.length>1&&T(x.filter((w,k)=>k!==n))},M=(n,w,k)=>{T(x.map((S,K)=>K===n?{...S,[w]:k}:S))},_=n=>{const w=new Set(z);w.has(n)?w.delete(n):w.add(n),m(w)},B=async()=>{if(!I.trim())return;const n=["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6","#ec4899","#06b6d4","#84cc16"],w=n[Math.floor(Math.random()*n.length)];try{const k=await c.mutateAsync({name:I.trim(),color:w});k!=null&&k.id&&m(S=>new Set([...S,k.id])),D("")}catch{}},E=async()=>{var n;if(i.title.trim()){U(!0);try{const w={title:i.title.trim(),preconditions:i.preconditions,priority:i.priority,type:i.type,status:i.status,automationStatus:i.automationStatus,reviewStatus:i.reviewStatus,folderId:i.folderId||null,estimatedDuration:i.estimatedDuration?parseInt(i.estimatedDuration,10):null};let k;if(v)await d.mutateAsync({id:t.id,data:{...w,changedBy:b||""}}),k=t.id;else{const S=await h.mutateAsync({...w,createdBy:b||""});k=(S==null?void 0:S.id)||((n=S==null?void 0:S.testCase)==null?void 0:n.id)}if(k){const S=x.filter(K=>K.action.trim());S.length>0&&await j.mutateAsync({testCaseId:k,steps:S.map((K,le)=>({stepNumber:le+1,action:K.action,expectedResult:K.expectedResult,testData:K.testData}))}),z.size>0&&await f.mutateAsync({testCaseId:k,tagIds:Array.from(z)})}p(),g()}catch(w){console.error("Failed to save test case:",w)}finally{U(!1)}}};return e.jsxs("div",{className:"fixed inset-0 z-50 flex items-start justify-center overflow-y-auto",children:[e.jsx("div",{className:"absolute inset-0 bg-black/70",onClick:g}),e.jsxs("div",{className:"relative bg-surface-1 rounded-xl border border-white/10 w-full max-w-3xl my-8 mx-4 animate-fade-in",children:[e.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-white/5",children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-100",children:v?"Edit Test Case":"Create Test Case"}),e.jsx("button",{onClick:g,className:"p-1.5 rounded-lg hover:bg-surface-2 text-gray-400 hover:text-gray-200",children:e.jsx(ee,{size:18})})]}),e.jsxs("div",{className:"px-6 py-5 space-y-5 max-h-[calc(100vh-200px)] overflow-y-auto",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-1.5",children:"Title *"}),e.jsx("input",{className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 outline-none focus:border-brand-500 transition-colors",value:i.title,onChange:n=>r({...i,title:n.target.value}),placeholder:"Enter test case title..."})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-1.5",children:"Preconditions"}),e.jsx("textarea",{className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 outline-none focus:border-brand-500 transition-colors resize-none",rows:3,value:i.preconditions,onChange:n=>r({...i,preconditions:n.target.value}),placeholder:"Any preconditions or setup steps..."})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-1.5",children:"Priority"}),e.jsx("select",{className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 outline-none focus:border-brand-500",value:i.priority,onChange:n=>r({...i,priority:n.target.value}),children:Nt.map(n=>e.jsx("option",{value:n,children:Z(n)},n))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-1.5",children:"Type"}),e.jsx("select",{className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 outline-none focus:border-brand-500",value:i.type,onChange:n=>r({...i,type:n.target.value}),children:wt.map(n=>e.jsx("option",{value:n,children:Z(n)},n))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-1.5",children:"Status"}),e.jsx("select",{className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 outline-none focus:border-brand-500",value:i.status,onChange:n=>r({...i,status:n.target.value}),children:kt.map(n=>e.jsx("option",{value:n,children:Z(n)},n))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-1.5",children:"Automation Status"}),e.jsx("select",{className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 outline-none focus:border-brand-500",value:i.automationStatus,onChange:n=>r({...i,automationStatus:n.target.value}),children:St.map(n=>e.jsx("option",{value:n,children:Re[n]},n))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-1.5",children:"Review Status"}),e.jsx("select",{className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 outline-none focus:border-brand-500",value:i.reviewStatus,onChange:n=>r({...i,reviewStatus:n.target.value}),children:Tt.map(n=>e.jsx("option",{value:n,children:De[n]},n))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-1.5",children:"Folder"}),e.jsxs("select",{className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 outline-none focus:border-brand-500",value:i.folderId,onChange:n=>r({...i,folderId:n.target.value}),children:[e.jsx("option",{value:"",children:"No Folder (Uncategorized)"}),l.map(n=>e.jsxs("option",{value:n.id,children:[" ".repeat(n.depth),n.name]},n.id))]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-1.5",children:"Estimated Duration (minutes)"}),e.jsx("input",{type:"number",className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 outline-none focus:border-brand-500",value:i.estimatedDuration,onChange:n=>r({...i,estimatedDuration:n.target.value}),placeholder:"e.g. 15",min:0})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("label",{className:"text-sm font-medium text-gray-300",children:"Test Steps"}),e.jsxs("button",{onClick:P,className:"flex items-center gap-1 text-xs text-brand-400 hover:text-brand-300 transition-colors",children:[e.jsx(Me,{size:14}),"Add Step"]})]}),e.jsx("div",{className:"space-y-3",children:x.map((n,w)=>e.jsxs("div",{className:"bg-surface-2 rounded-lg border border-white/5 p-3",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("span",{className:"text-xs font-medium text-gray-400",children:["Step ",w+1]}),x.length>1&&e.jsx("button",{onClick:()=>V(w),className:"p-1 rounded hover:bg-white/10 text-gray-500 hover:text-red-400",children:e.jsx(ue,{size:13})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("textarea",{className:"w-full bg-surface-1 border border-white/10 rounded px-2.5 py-1.5 text-sm text-gray-200 placeholder-gray-500 outline-none focus:border-brand-500 resize-none",rows:2,value:n.action,onChange:k=>M(w,"action",k.target.value),placeholder:"Action / Step description..."}),e.jsx("textarea",{className:"w-full bg-surface-1 border border-white/10 rounded px-2.5 py-1.5 text-sm text-gray-200 placeholder-gray-500 outline-none focus:border-brand-500 resize-none",rows:2,value:n.expectedResult,onChange:k=>M(w,"expectedResult",k.target.value),placeholder:"Expected result..."}),e.jsx("input",{className:"w-full bg-surface-1 border border-white/10 rounded px-2.5 py-1.5 text-sm text-gray-200 placeholder-gray-500 outline-none focus:border-brand-500",value:n.testData,onChange:k=>M(w,"testData",k.target.value),placeholder:"Test data (optional)..."})]})]},w))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-2",children:"Tags"}),e.jsx("div",{className:"flex flex-wrap gap-2 mb-2",children:u==null?void 0:u.map(n=>e.jsxs("button",{onClick:()=>_(n.id),className:`inline-flex items-center gap-1 px-2.5 py-1 rounded-full text-xs font-medium transition-colors border ${z.has(n.id)?"border-brand-500 bg-brand-500/20 text-brand-300":"border-white/10 bg-surface-2 text-gray-400 hover:text-gray-300"}`,children:[z.has(n.id)&&e.jsx(pe,{size:12}),n.name]},n.id))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{className:"flex-1 bg-surface-2 border border-white/10 rounded-lg px-3 py-1.5 text-sm text-gray-200 outline-none focus:border-brand-500",placeholder:"Create new tag...",value:I,onChange:n=>D(n.target.value),onKeyDown:n=>{n.key==="Enter"&&B()}}),e.jsx("button",{onClick:B,disabled:!I.trim(),className:"px-3 py-1.5 text-sm rounded-lg bg-surface-2 hover:bg-surface-3 text-gray-300 border border-white/10 disabled:opacity-40",children:"Add"})]})]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 px-6 py-4 border-t border-white/5",children:[e.jsx("button",{onClick:g,className:"px-4 py-2 text-sm rounded-lg bg-surface-2 hover:bg-surface-3 text-gray-300 transition-colors",children:"Cancel"}),e.jsxs("button",{onClick:E,disabled:G||!i.title.trim(),className:"flex items-center gap-2 px-5 py-2 text-sm rounded-lg bg-brand-600 hover:bg-brand-500 text-white font-medium transition-colors disabled:opacity-50",children:[e.jsx(Hs,{size:15}),G?"Saving...":v?"Update":"Create"]})]})]})]})}function na({testCase:t,versions:y,onToast:u,currentUserName:g}){const[p,b]=o.useState(null),[v,h]=o.useState(null),d=Ms();if(!y||y.length===0)return e.jsxs("div",{className:"text-center py-8 text-gray-500 text-sm",children:[e.jsx(jt,{size:24,className:"mx-auto mb-2 opacity-50"}),"No version history available"]});const j=y.map(i=>{let r={};try{r=JSON.parse(i.snapshot)}catch{}return{...i,snap:r}});function f(i,r){const x=[],T=[{key:"title",label:"Title"},{key:"preconditions",label:"Preconditions"},{key:"priority",label:"Priority"},{key:"type",label:"Type"},{key:"status",label:"Status"},{key:"automationStatus",label:"Automation Status"},{key:"reviewStatus",label:"Review Status"},{key:"estimatedDuration",label:"Duration (min)"}];for(const l of T){const P=String(i[l.key]??""),V=String(r[l.key]??"");P!==V&&x.push({field:l.label,from:P||"(empty)",to:V||"(empty)"})}const z=(i.tags||[]).map(l=>l.name||l.id).sort().join(", "),m=(r.tags||[]).map(l=>l.name||l.id).sort().join(", ");z!==m&&x.push({field:"Tags",from:z||"(none)",to:m||"(none)"});const I=i.steps||[],D=r.steps||[],G=Math.max(I.length,D.length),U=[];let A=!1;for(let l=0;l<G;l++){const P=I[l],V=D[l],M=E=>E?{action:E.action||"",expectedResult:E.expectedResult||"",testData:E.testData||""}:void 0,_=M(P),B=M(V);if(!_&&B)U.push({type:"added",stepNum:l+1,newStep:B}),A=!0;else if(_&&!B)U.push({type:"removed",stepNum:l+1,oldStep:_}),A=!0;else if(_&&B){const E=_.action!==B.action||_.expectedResult!==B.expectedResult||_.testData!==B.testData;U.push({type:E?"modified":"unchanged",stepNum:l+1,oldStep:_,newStep:B}),E&&(A=!0)}}return{fieldDiffs:x,stepDiffs:U,hasStepChanges:A}}const c=i=>{var r;return i.version===((r=j[0])==null?void 0:r.version)};function N(i){d.mutate({testCaseId:t.id,versionId:i,changedBy:g},{onSuccess:()=>{h(null),b(null),u==null||u(`Test case restored to version ${i} successfully`,"success")},onError:()=>{u==null||u("Failed to restore version. Please try again.","error")}})}return e.jsx("div",{className:"space-y-2",children:j.map((i,r)=>{const x=p===i.version,T=r===0,z=r<j.length-1?j[r+1].snap:{},{fieldDiffs:m,stepDiffs:I,hasStepChanges:D}=f(z,i.snap),G=m.length+(D?1:0),U=v===i.version,A=I.filter(l=>l.type!=="unchanged");return e.jsxs("div",{className:"relative",children:[!T&&e.jsx("div",{className:"absolute left-[15px] -top-2 w-px h-2 bg-white/10"}),r<j.length-1&&e.jsx("div",{className:"absolute left-[15px] -bottom-2 w-px h-2 bg-white/10"}),e.jsx("button",{onClick:()=>b(x?null:i.version),className:`w-full text-left rounded-xl border transition-all ${x?"bg-surface-2 border-brand-500/30 shadow-lg shadow-brand-500/5":"bg-surface-2/60 border-white/5 hover:border-white/10 hover:bg-surface-2"}`,children:e.jsxs("div",{className:"flex items-center gap-3 px-4 py-3",children:[e.jsxs("div",{className:`flex-shrink-0 w-8 h-8 rounded-full flex items-center justify-center text-xs font-bold ${T?"bg-brand-500/20 text-brand-300 ring-2 ring-brand-500/30":"bg-surface-0 text-gray-400 ring-1 ring-white/10"}`,children:["v",i.version]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-sm font-medium text-gray-200",children:i.changeSummary||`Version ${i.version}`}),T&&e.jsx("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-semibold bg-brand-500/15 text-brand-300 uppercase tracking-wider",children:"Current"}),G>0&&!T&&e.jsxs("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-medium bg-amber-500/15 text-amber-300",children:[m.length>0&&`${m.length} field${m.length!==1?"s":""}`,m.length>0&&D&&" + ",D&&`${A.length} step${A.length!==1?"s":""}`]})]}),e.jsxs("div",{className:"flex items-center gap-3 mt-0.5",children:[i.changedBy&&e.jsxs("span",{className:"text-xs text-gray-500",children:["by ",i.changedBy]}),e.jsx("span",{className:"text-xs text-gray-500",children:i.changedAt?Je(i.changedAt):""})]})]}),e.jsx(qe,{size:16,className:`text-gray-500 transition-transform ${x?"rotate-90":""}`})]})}),x&&e.jsxs("div",{className:"mt-1 ml-5 mr-1 rounded-lg border border-white/5 bg-surface-1 overflow-hidden",children:[m.length>0&&e.jsxs("div",{children:[e.jsx("div",{className:"px-4 py-2.5 bg-surface-2/50 border-b border-white/5",children:e.jsx("h4",{className:"text-xs font-semibold text-gray-400 uppercase tracking-wider",children:"Field Changes"})}),e.jsx("div",{className:"divide-y divide-white/5",children:m.map((l,P)=>e.jsxs("div",{className:"grid grid-cols-[100px_1fr_24px_1fr] items-start gap-2 px-4 py-2.5",children:[e.jsx("span",{className:"text-xs font-medium text-gray-400 pt-0.5",children:l.field}),e.jsx("div",{className:"bg-red-500/8 border border-red-500/15 rounded px-2 py-1",children:e.jsx("p",{className:"text-xs text-red-300 line-through break-words",children:l.from})}),e.jsx(je,{size:14,className:"text-gray-600 mt-1 flex-shrink-0"}),e.jsx("div",{className:"bg-emerald-500/8 border border-emerald-500/15 rounded px-2 py-1",children:e.jsx("p",{className:"text-xs text-emerald-300 break-words",children:l.to})})]},P))})]}),D&&e.jsxs("div",{className:"border-t border-white/5",children:[e.jsx("div",{className:"px-4 py-2.5 bg-surface-2/50 border-b border-white/5",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h4",{className:"text-xs font-semibold text-gray-400 uppercase tracking-wider",children:"Step Changes"}),e.jsxs("div",{className:"flex items-center gap-3",children:[A.filter(l=>l.type==="added").length>0&&e.jsxs("span",{className:"flex items-center gap-1 text-[10px] text-emerald-400",children:[e.jsx(sa,{size:10})," ",A.filter(l=>l.type==="added").length," added"]}),A.filter(l=>l.type==="removed").length>0&&e.jsxs("span",{className:"flex items-center gap-1 text-[10px] text-red-400",children:[e.jsx(aa,{size:10})," ",A.filter(l=>l.type==="removed").length," removed"]}),A.filter(l=>l.type==="modified").length>0&&e.jsxs("span",{className:"flex items-center gap-1 text-[10px] text-amber-400",children:[e.jsx(Ee,{size:10})," ",A.filter(l=>l.type==="modified").length," modified"]})]})]})}),e.jsx("div",{className:"divide-y divide-white/5",children:I.filter(l=>l.type!=="unchanged").map((l,P)=>e.jsxs("div",{className:"px-4 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("span",{className:`inline-flex items-center justify-center w-5 h-5 rounded-full text-[10px] font-bold ${l.type==="added"?"bg-emerald-500/20 text-emerald-300":l.type==="removed"?"bg-red-500/20 text-red-300":"bg-amber-500/20 text-amber-300"}`,children:l.stepNum}),e.jsx("span",{className:`text-[10px] font-semibold uppercase tracking-wider ${l.type==="added"?"text-emerald-400":l.type==="removed"?"text-red-400":"text-amber-400"}`,children:l.type==="added"?"New Step":l.type==="removed"?"Removed Step":"Modified Step"})]}),l.type==="added"&&l.newStep&&e.jsxs("div",{className:"ml-7 space-y-1.5 bg-emerald-500/5 border border-emerald-500/15 rounded-lg p-3",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-gray-500 font-medium",children:"Action:"}),e.jsx("p",{className:"text-xs text-emerald-300 mt-0.5",children:l.newStep.action})]}),l.newStep.expectedResult&&e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-gray-500 font-medium",children:"Expected:"}),e.jsx("p",{className:"text-xs text-emerald-300 mt-0.5",children:l.newStep.expectedResult})]}),l.newStep.testData&&e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-gray-500 font-medium",children:"Test Data:"}),e.jsx("p",{className:"text-xs text-emerald-300 font-mono mt-0.5",children:l.newStep.testData})]})]}),l.type==="removed"&&l.oldStep&&e.jsxs("div",{className:"ml-7 space-y-1.5 bg-red-500/5 border border-red-500/15 rounded-lg p-3",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-gray-500 font-medium",children:"Action:"}),e.jsx("p",{className:"text-xs text-red-300 line-through mt-0.5",children:l.oldStep.action})]}),l.oldStep.expectedResult&&e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-gray-500 font-medium",children:"Expected:"}),e.jsx("p",{className:"text-xs text-red-300 line-through mt-0.5",children:l.oldStep.expectedResult})]}),l.oldStep.testData&&e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-gray-500 font-medium",children:"Test Data:"}),e.jsx("p",{className:"text-xs text-red-300 line-through font-mono mt-0.5",children:l.oldStep.testData})]})]}),l.type==="modified"&&l.oldStep&&l.newStep&&e.jsxs("div",{className:"ml-7 space-y-2",children:[l.oldStep.action!==l.newStep.action&&e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-gray-500 font-medium block mb-1",children:"Action"}),e.jsxs("div",{className:"grid grid-cols-[1fr_20px_1fr] gap-1 items-start",children:[e.jsx("div",{className:"bg-red-500/8 border border-red-500/15 rounded px-2 py-1.5",children:e.jsx("p",{className:"text-[11px] text-red-300 line-through leading-relaxed",children:l.oldStep.action})}),e.jsx(je,{size:12,className:"text-gray-600 mt-1.5 mx-auto"}),e.jsx("div",{className:"bg-emerald-500/8 border border-emerald-500/15 rounded px-2 py-1.5",children:e.jsx("p",{className:"text-[11px] text-emerald-300 leading-relaxed",children:l.newStep.action})})]})]}),l.oldStep.expectedResult!==l.newStep.expectedResult&&e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-gray-500 font-medium block mb-1",children:"Expected Result"}),e.jsxs("div",{className:"grid grid-cols-[1fr_20px_1fr] gap-1 items-start",children:[e.jsx("div",{className:"bg-red-500/8 border border-red-500/15 rounded px-2 py-1.5",children:e.jsx("p",{className:"text-[11px] text-red-300 line-through leading-relaxed",children:l.oldStep.expectedResult||"(empty)"})}),e.jsx(je,{size:12,className:"text-gray-600 mt-1.5 mx-auto"}),e.jsx("div",{className:"bg-emerald-500/8 border border-emerald-500/15 rounded px-2 py-1.5",children:e.jsx("p",{className:"text-[11px] text-emerald-300 leading-relaxed",children:l.newStep.expectedResult||"(empty)"})})]})]}),l.oldStep.testData!==l.newStep.testData&&e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-gray-500 font-medium block mb-1",children:"Test Data"}),e.jsxs("div",{className:"grid grid-cols-[1fr_20px_1fr] gap-1 items-start",children:[e.jsx("div",{className:"bg-red-500/8 border border-red-500/15 rounded px-2 py-1.5",children:e.jsx("p",{className:"text-[11px] text-red-300 line-through font-mono leading-relaxed",children:l.oldStep.testData||"(empty)"})}),e.jsx(je,{size:12,className:"text-gray-600 mt-1.5 mx-auto"}),e.jsx("div",{className:"bg-emerald-500/8 border border-emerald-500/15 rounded px-2 py-1.5",children:e.jsx("p",{className:"text-[11px] text-emerald-300 font-mono leading-relaxed",children:l.newStep.testData||"(empty)"})})]})]})]})]},P))})]}),m.length===0&&!D&&e.jsx("div",{className:"px-4 py-4 text-center",children:e.jsx("p",{className:"text-xs text-gray-500",children:r===j.length-1?"Initial version — no previous version to compare":"No changes detected"})}),!c(i)&&e.jsx("div",{className:"border-t border-white/5 px-4 py-3 bg-surface-2/20",children:U?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-xs text-amber-300 flex-1",children:["Restore test case to version ",i.version,"?"]}),e.jsx("button",{onClick:()=>h(null),className:"px-3 py-1.5 text-xs rounded-lg bg-surface-2 hover:bg-surface-1 text-gray-400 transition-colors",children:"Cancel"}),e.jsxs("button",{onClick:()=>N(i.version),disabled:d.isPending,className:"px-3 py-1.5 text-xs rounded-lg bg-amber-600 hover:bg-amber-500 text-white font-medium transition-colors disabled:opacity-50 flex items-center gap-1.5",children:[e.jsx(ot,{size:12,className:d.isPending?"animate-spin":""}),d.isPending?"Restoring...":"Confirm Restore"]})]}):e.jsxs("button",{onClick:()=>h(i.version),className:"flex items-center gap-1.5 px-3 py-1.5 text-xs rounded-lg bg-surface-2 hover:bg-amber-500/15 text-gray-400 hover:text-amber-300 border border-white/5 hover:border-amber-500/20 transition-all",children:[e.jsx(ot,{size:12}),"Restore to this version"]})})]})]},i.id)})})}function Ct(t,y,u){const g=(t==null?void 0:t.id)||"",p=(t==null?void 0:t.title)||"(untitled test case)",b=((t==null?void 0:t.preconditions)||"").trim(),v=((t==null?void 0:t.tags)||[]).map(d=>d==null?void 0:d.name).filter(Boolean);if(u==="json")return JSON.stringify({id:g,title:p,priority:t==null?void 0:t.priority,type:t==null?void 0:t.type,preconditions:b||void 0,tags:v.length?v:void 0,steps:y.map((d,j)=>({step:j+1,action:d.action||"",expected:d.expectedResult||d.expected_result||void 0,testData:d.testData||d.test_data||void 0}))},null,2);if(u==="plain"){const d=[];return d.push(`${g?g+" — ":""}${p}`),b&&d.push(`Preconditions: ${b}`),d.push(""),y.forEach((j,f)=>{d.push(`${f+1}. ${j.action||""}`);const c=j.expectedResult||j.expected_result,N=j.testData||j.test_data;c&&d.push(` Expected: ${c}`),N&&d.push(` Test data: ${N}`)}),d.join(`
2
- `)}const h=[];return h.push(`Test case: ${g?g+" — ":""}${p}`),t!=null&&t.priority&&h.push(`Priority: ${t.priority}`),t!=null&&t.type&&h.push(`Type: ${t.type}`),v.length&&h.push(`Tags: ${v.join(", ")}`),h.push(""),b&&h.push(`Given ${b}`),y.forEach((d,j)=>{const f=j===0&&!b?"Given":j===0?"When":"And",c=d.testData||d.test_data,N=(d.action||"").trim();h.push(`${f} ${N}${c?` (data: ${c})`:""}`);const i=(d.expectedResult||d.expected_result||"").trim();i&&h.push(` Then ${i}`)}),h.join(`
3
- `)}function la(t,y){return["Please help me automate the following manual test case.","Generate idiomatic, maintainable code with stable locators, reasonable assertions","for each expected outcome, and a clear test/file name derived from the title below.","",Ct(t,y,"gherkin")].join(`
4
- `)}function ia({testCase:t,steps:y,onToast:u,isAutomated:g}){const p=Ht(),{mode:b}=Es(),[v,h]=o.useState(!1),[d,j]=o.useState(null),f=o.useRef(null);o.useEffect(()=>{if(!v)return;const r=x=>{f.current&&!f.current.contains(x.target)&&h(!1)};return document.addEventListener("mousedown",r),()=>document.removeEventListener("mousedown",r)},[v]);const c=async r=>{try{const x=Ct(t,y,r);await navigator.clipboard.writeText(x),j(r),u==null||u(`Copied as ${r==="gherkin"?"Gherkin":r==="plain"?"text":"JSON"}`),setTimeout(()=>j(null),2e3),h(!1)}catch{u==null||u("Could not copy to clipboard","error")}},N=()=>{Fs(p,{prompt:la(t,y),mode:b==="mobile"?"mobile":"web"})},i=v&&e.jsxs("div",{className:"absolute right-0 top-full mt-1 z-40 w-56 bg-surface-1 border border-white/10 rounded-lg shadow-xl overflow-hidden",children:[e.jsxs("button",{type:"button",onClick:()=>c("gherkin"),className:"w-full flex items-center gap-2 px-3 py-2 text-xs text-left text-gray-300 hover:bg-surface-2 hover:text-gray-100",children:[d==="gherkin"?e.jsx(xe,{size:13,className:"text-emerald-400"}):e.jsx(dt,{size:13,className:"text-brand-300"}),"Copy as Gherkin (AI-friendly)"]}),e.jsxs("button",{type:"button",onClick:()=>c("plain"),className:"w-full flex items-center gap-2 px-3 py-2 text-xs text-left text-gray-300 hover:bg-surface-2 hover:text-gray-100",children:[d==="plain"?e.jsx(xe,{size:13,className:"text-emerald-400"}):e.jsx(it,{size:13,className:"text-gray-400"}),"Copy as text"]}),e.jsxs("button",{type:"button",onClick:()=>c("json"),className:"w-full flex items-center gap-2 px-3 py-2 text-xs text-left text-gray-300 hover:bg-surface-2 hover:text-gray-100",children:[d==="json"?e.jsx(xe,{size:13,className:"text-emerald-400"}):e.jsx(ta,{size:13,className:"text-sky-400"}),"Copy as JSON"]})]});return g?e.jsxs("div",{ref:f,className:"relative inline-flex",children:[e.jsxs("button",{type:"button",onClick:()=>h(r=>!r),className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-lg bg-surface-2 hover:bg-surface-3 text-gray-300 border border-white/10 transition-colors",title:"Copy steps in a chosen format",children:[e.jsx(it,{size:13}),"Copy steps",e.jsx(ne,{size:13,className:"text-gray-500"})]}),i]}):e.jsxs("div",{ref:f,className:"relative inline-flex items-stretch",children:[e.jsxs("button",{type:"button",onClick:N,className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-l-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors",title:"Send these steps to the AI Assistant to generate automation code",children:[e.jsx(dt,{size:13}),"Automate with AI"]}),e.jsx("button",{type:"button",onClick:()=>h(r=>!r),className:"flex items-center px-1.5 py-1.5 rounded-r-lg bg-brand-600 hover:bg-brand-500 text-white border-l border-brand-500/40 transition-colors",title:"Copy steps in another format",children:e.jsx(ne,{size:13})}),i]})}function da({testCase:t,onClose:y,onEdit:u,onToast:g,currentUserName:p}){var ie,O;const[b,v]=Yt("detail",["steps","attachments","links","history","mapping","executions"],"steps"),[h,d]=o.useState(null),{data:j}=ut(t==null?void 0:t.id),{data:f}=vs(t==null?void 0:t.id),{data:c}=Ns(t==null?void 0:t.id),{data:N}=ws(t==null?void 0:t.id),{data:i}=ks(t==null?void 0:t.id),{data:r}=Ss(t==null?void 0:t.id),{data:x}=Ts(t==null?void 0:t.id),T=zs(),z=Cs(),m=pt(),I=As(),D=(j==null?void 0:j.steps)||[],G=(f==null?void 0:f.versions)||[],U=(N==null?void 0:N.attachments)||[],A=(i==null?void 0:i.links)||[],l=(x==null?void 0:x.sources)||[],[P,V]=o.useState(!1),[M,_]=o.useState({title:"",url:"",linkType:"other"}),[B,E]=o.useState(!1),[F,Y]=o.useState(null);if(!t)return null;const n=({size:s=18})=>e.jsxs("svg",{width:s,height:s,viewBox:"0 0 256 256",xmlns:"http://www.w3.org/2000/svg",children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{x1:"98.03%",y1:"0.16%",x2:"58.89%",y2:"40.77%",id:"tmjg1",children:[e.jsx("stop",{stopColor:"#0052CC",offset:"18%"}),e.jsx("stop",{stopColor:"#2684FF",offset:"100%"})]}),e.jsxs("linearGradient",{x1:"100.67%",y1:"0.46%",x2:"55.4%",y2:"44.73%",id:"tmjg2",children:[e.jsx("stop",{stopColor:"#0052CC",offset:"18%"}),e.jsx("stop",{stopColor:"#2684FF",offset:"100%"})]})]}),e.jsxs("g",{children:[e.jsx("path",{d:"M244.658,0 L121.707,0 C121.707,14.72 127.554,28.837 137.963,39.246 C148.372,49.655 162.489,55.502 177.209,55.502 L199.858,55.502 L199.858,77.369 C199.877,107.994 224.699,132.816 255.324,132.836 L255.324,10.667 C255.324,4.776 250.549,0 244.658,0 Z",fill:"#2684FF"}),e.jsx("path",{d:"M183.822,61.262 L60.871,61.262 C60.891,91.887 85.713,116.709 116.338,116.729 L138.987,116.729 L138.987,138.667 C139.026,169.292 163.864,194.098 194.489,194.098 L194.489,71.929 C194.489,66.038 189.713,61.262 183.822,61.262 Z",fill:"url(#tmjg1)"}),e.jsx("path",{d:"M122.951,122.489 L0,122.489 C0,153.142 24.849,177.991 55.502,177.991 L78.222,177.991 L78.222,199.858 C78.242,230.455 103.02,255.266 133.618,255.324 L133.618,133.156 C133.618,127.265 128.842,122.489 122.951,122.489 Z",fill:"url(#tmjg2)"})]})]}),w=({size:s=18})=>e.jsxs("svg",{width:s,height:s,viewBox:"0 0 32 32",xmlns:"http://www.w3.org/2000/svg",children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"cg1",x1:"28.607",y1:"-60.825",x2:"11.085",y2:"-50.756",gradientTransform:"matrix(1,0,0,-1,0,-29.66)",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:"0.18",stopColor:"#0052cc"}),e.jsx("stop",{offset:"1",stopColor:"#2684ff"})]}),e.jsxs("linearGradient",{id:"cg2",x1:"621.442",y1:"1817.567",x2:"603.915",y2:"1827.64",gradientTransform:"matrix(-1,0,0,1,624.83,-1816.71)",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:"0.18",stopColor:"#0052cc"}),e.jsx("stop",{offset:"1",stopColor:"#2684ff"})]})]}),e.jsx("path",{d:"M3.015,23.087c-.289.472-.614,1.02-.891,1.456a.892.892,0,0,0,.3,1.212l5.792,3.564a.89.89,0,0,0,1.226-.29l.008-.013c.231-.387.53-.891.855-1.43,2.294-3.787,4.6-3.323,8.763-1.336l5.743,2.731A.892.892,0,0,0,26,28.559l.011-.024L28.766,22.3a.891.891,0,0,0-.445-1.167c-1.212-.57-3.622-1.707-5.792-2.754C14.724,14.586,8.09,14.831,3.015,23.087Z",fill:"url(#cg1)"}),e.jsx("path",{d:"M28.985,8.932c.289-.472.614-1.02.891-1.456a.892.892,0,0,0-.3-1.212L23.785,2.7a.89.89,0,0,0-1.236.241.584.584,0,0,0-.033.053c-.232.387-.53.891-.856,1.43-2.294,3.787-4.6,3.323-8.763,1.336L7.172,3.043a.89.89,0,0,0-1.187.421l-.011.024L3.216,9.726a.891.891,0,0,0,.445,1.167c1.212.57,3.622,1.706,5.792,2.753C17.276,17.433,23.91,17.179,28.985,8.932Z",fill:"url(#cg2)"})]}),k=({size:s=18})=>e.jsx("svg",{width:s,height:s,viewBox:"0 0 20 20",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M10,0 C15.523,0 20,4.59 20,10.253 C20,14.782 17.138,18.624 13.167,19.981 C12.66,20.082 12.48,19.762 12.48,19.489 C12.48,19.151 12.492,18.047 12.492,16.675 C12.492,15.719 12.172,15.095 11.813,14.777 C14.04,14.523 16.38,13.656 16.38,9.718 C16.38,8.598 15.992,7.684 15.35,6.966 C15.454,6.707 15.797,5.664 15.252,4.252 C15.252,4.252 14.414,3.977 12.505,5.303 C11.706,5.076 10.85,4.962 10,4.958 C9.15,4.962 8.295,5.076 7.497,5.303 C5.586,3.977 4.746,4.252 4.746,4.252 C4.203,5.664 4.546,6.707 4.649,6.966 C4.01,7.684 3.619,8.598 3.619,9.718 C3.619,13.646 5.954,14.526 8.175,14.785 C7.889,15.041 7.63,15.493 7.54,16.156 C6.97,16.418 5.522,16.871 4.63,15.304 C4.63,15.304 4.101,14.319 3.097,14.247 C3.097,14.247 2.122,14.234 3.029,14.87 C3.029,14.87 3.684,15.185 4.139,16.37 C4.139,16.37 4.726,18.2 7.508,17.58 C7.513,18.437 7.522,19.245 7.522,19.489 C7.522,19.76 7.338,20.077 6.839,19.982 C2.865,18.627 0,14.783 0,10.253 C0,4.59 4.478,0 10,0",fill:"currentColor"})}),S={jira:{label:"Jira",color:"text-blue-400"},confluence:{label:"Confluence",color:"text-blue-300"},github:{label:"GitHub",color:"text-gray-300"},docs:{label:"Docs",emoji:"📑",color:"text-emerald-400"},design:{label:"Design",emoji:"🎨",color:"text-purple-400"},other:{label:"Other",emoji:"🔗",color:"text-gray-400"}},K=({type:s,size:C=18})=>{if(s==="jira")return e.jsx(n,{size:C});if(s==="confluence")return e.jsx(w,{size:C});if(s==="github")return e.jsx(k,{size:C});const L=S[s]||S.other;return e.jsx("span",{style:{fontSize:C},children:L.emoji})},le=async s=>{const C=s.target.files;if(!(!C||!(t!=null&&t.id))){for(const L of Array.from(C)){if(L.size>10*1024*1024){g==null||g(`File "${L.name}" exceeds 10MB limit`,"error");continue}const W=new FileReader;W.onload=()=>{const be=W.result.split(",")[1]||"";T.mutate({testCaseId:t.id,data:{fileName:L.name,fileType:L.type,fileSize:L.size,fileData:be,uploadedBy:p||""}})},W.readAsDataURL(L)}s.target.value=""}},Ne=s=>{z.mutate({id:s,testCaseId:t.id})},se=()=>{!M.title.trim()||!M.url.trim()||(m.mutate({testCaseId:t.id,data:{title:M.title.trim(),url:M.url.trim(),linkType:M.linkType,addedBy:p||""}}),_({title:"",url:"",linkType:"other"}),V(!1))},X=s=>{I.mutate({id:s,testCaseId:t.id})},he=s=>{const C=document.createElement("a");C.href=`data:${s.fileType};base64,${s.fileData}`,C.download=s.fileName,C.click()},Le=s=>s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:`${(s/(1024*1024)).toFixed(1)} MB`,te=s=>s.startsWith("image/"),Q=Array.isArray(r==null?void 0:r.history)?r.history:[],we=Q.length>0?Math.round(Q.filter(s=>s.status==="passed").length/Q.length*100):0,ge=[{key:"steps",label:"Steps",icon:ce,count:D.length},{key:"executions",label:"Executions",icon:at,count:Q.length},{key:"attachments",label:"Attachments",icon:rt,count:U.length},{key:"links",label:"Links",icon:nt,count:A.length},{key:"history",label:"History",icon:jt},{key:"mapping",label:"Mapping",icon:_e}];return e.jsxs("div",{className:"fixed inset-0 z-50 flex justify-end",children:[e.jsx("div",{className:"absolute inset-0 bg-black/50",onClick:y}),e.jsxs("div",{className:"relative bg-surface-1 w-full max-w-3xl border-l border-white/10 animate-slide-in-right overflow-y-auto",children:[e.jsx("div",{className:"sticky top-0 bg-surface-1 z-10 px-6 py-4 border-b border-white/5",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-100 pr-4 break-words",children:t.title}),e.jsxs("div",{className:"flex items-center gap-2.5 mt-2",children:[t.id&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-[13px] text-gray-400 font-mono",children:[e.jsx(yt,{size:13,className:"flex-shrink-0"}),t.id]}),e.jsxs("span",{className:"inline-flex items-center gap-1 text-[13px] text-gray-400",children:[e.jsx(ve,{size:13,className:"flex-shrink-0"}),((ie=t.folder)==null?void 0:ie.name)||"Uncategorized"]}),D.length>0&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-[13px] text-gray-400",children:[e.jsx(ce,{size:13,className:"flex-shrink-0"}),D.length," step",D.length!==1?"s":""]})]})]}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[e.jsx("button",{onClick:()=>u(t),title:"Edit test case",className:"p-1.5 rounded-lg hover:bg-surface-2 text-gray-400 hover:text-gray-200 transition-colors",children:e.jsx(Ee,{size:18})}),e.jsx("button",{onClick:y,title:"Close",className:"p-1.5 rounded-lg hover:bg-surface-2 text-gray-400 hover:text-gray-200 transition-colors",children:e.jsx(ee,{size:18})})]})]})}),e.jsxs("div",{className:"px-6 py-5 space-y-5",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("span",{className:`inline-flex items-center px-2.5 py-1 rounded-md text-xs font-medium ${ct[t.priority]||ct.medium}`,children:Z(t.priority||"medium")}),e.jsx("span",{className:`inline-flex items-center px-2.5 py-1 rounded-md text-xs font-medium ${Oe[t.type]||Oe.web}`,children:Z(t.type||"web")}),e.jsx("span",{className:`inline-flex items-center px-2.5 py-1 rounded-md text-xs font-medium ${xt[t.status]||xt.draft}`,children:Z(t.status||"draft")}),e.jsxs("span",{className:"inline-flex items-center gap-1 px-2.5 py-1 rounded-md text-xs font-medium bg-surface-2 text-gray-300",children:[e.jsx(Be,{size:12}),Re[t.automationStatus]||"Manual"]}),e.jsxs("span",{className:"inline-flex items-center gap-1 px-2.5 py-1 rounded-md text-xs font-medium bg-surface-2 text-gray-300",children:[e.jsx(Ue,{size:12}),De[t.reviewStatus]||"Not Reviewed"]})]}),t.staleAt?e.jsx(ha,{id:t.id,reason:t.staleReason}):null,t.preconditions&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-medium text-gray-400 uppercase tracking-wider mb-1.5",children:"Preconditions"}),e.jsx("p",{className:"text-sm text-gray-300 bg-surface-2 rounded-lg p-3 border border-white/5 whitespace-pre-wrap",children:t.preconditions})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[!!t.estimatedDuration&&e.jsxs("div",{className:"bg-surface-2 rounded-lg p-3 border border-white/5",children:[e.jsx("span",{className:"text-xs text-gray-400 block mb-0.5",children:"Duration"}),e.jsxs("span",{className:"text-sm text-gray-200 flex items-center gap-1.5",children:[e.jsx(Fe,{size:13})," ",t.estimatedDuration," min"]})]}),e.jsxs("div",{className:"bg-surface-2 rounded-lg p-3 border border-white/5",children:[e.jsx("span",{className:"text-xs text-gray-400 block mb-0.5",children:"Folder"}),e.jsxs("span",{className:"text-sm text-gray-200 flex items-center gap-1.5",children:[e.jsx(ve,{size:13})," ",((O=t.folder)==null?void 0:O.name)||"Uncategorized"]})]})]}),t.tags&&t.tags.length>0&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-medium text-gray-400 uppercase tracking-wider mb-1.5",children:"Tags"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:t.tags.map(s=>e.jsx("span",{className:"inline-flex items-center px-2.5 py-1 rounded-full text-xs font-medium bg-surface-2 text-gray-300 border border-white/5",children:s.name},s.id))})]}),e.jsx("div",{className:"flex border-b border-white/5 overflow-x-auto",children:ge.map(s=>e.jsxs("button",{onClick:()=>v(s.key),className:`flex items-center gap-1.5 px-3.5 py-2.5 text-sm font-medium border-b-2 transition-colors whitespace-nowrap ${b===s.key?"border-brand-500 text-brand-300":"border-transparent text-gray-400 hover:text-gray-300"}`,children:[e.jsx(s.icon,{size:14}),s.label,"count"in s&&typeof s.count=="number"&&s.count>0&&e.jsx("span",{className:"ml-1 px-1.5 py-0.5 rounded-full text-[10px] font-bold bg-surface-2 text-gray-400",children:s.count})]},s.key))}),b==="steps"&&e.jsxs("div",{children:[D&&D.length>0&&e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h4",{className:"text-sm font-medium text-gray-300",children:"Test Steps"}),e.jsx(ia,{testCase:t,steps:D,onToast:g,isAutomated:(t==null?void 0:t.automationStatus)==="automated"||(t==null?void 0:t.automation_status)==="automated"||!!(c!=null&&c.scriptPath)})]}),D&&D.length>0?e.jsxs("div",{className:"rounded-xl border border-white/10 overflow-hidden",children:[e.jsxs("div",{className:"grid grid-cols-[48px_1fr_1fr_140px] bg-surface-2/80 border-b border-white/10",children:[e.jsx("div",{className:"px-3 py-2.5 text-xs font-semibold text-gray-400 uppercase tracking-wider text-center",children:"#"}),e.jsx("div",{className:"px-3 py-2.5 text-xs font-semibold text-gray-400 uppercase tracking-wider",children:"Action"}),e.jsx("div",{className:"px-3 py-2.5 text-xs font-semibold text-gray-400 uppercase tracking-wider",children:"Expected Result"}),e.jsx("div",{className:"px-3 py-2.5 text-xs font-semibold text-gray-400 uppercase tracking-wider",children:"Test Data"})]}),D.map((s,C)=>e.jsxs("div",{className:`grid grid-cols-[48px_1fr_1fr_140px] border-b border-white/5 last:border-b-0 transition-colors hover:bg-white/[0.02] ${C%2===0?"bg-surface-1":"bg-surface-2/30"}`,children:[e.jsx("div",{className:"px-3 py-3 flex items-start justify-center",children:e.jsx("span",{className:"w-6 h-6 rounded-full bg-brand-500/20 text-brand-300 text-xs font-bold flex items-center justify-center flex-shrink-0",children:s.stepNumber||C+1})}),e.jsx("div",{className:"px-3 py-3",children:e.jsx("p",{className:"text-sm text-gray-200 leading-relaxed whitespace-pre-wrap",children:s.action})}),e.jsx("div",{className:"px-3 py-3",children:e.jsx("p",{className:"text-sm text-teal-200 leading-relaxed whitespace-pre-wrap",children:s.expectedResult||e.jsx("span",{className:"text-gray-600 italic",children:"—"})})}),e.jsx("div",{className:"px-3 py-3",children:s.testData?e.jsx("p",{className:"text-sm text-sky-300 font-mono leading-relaxed break-all",children:s.testData}):e.jsx("span",{className:"text-gray-600 text-sm italic",children:"—"})})]},s.id||C)),e.jsx("div",{className:"bg-surface-2/50 px-4 py-2 border-t border-white/10",children:e.jsxs("span",{className:"text-xs text-gray-500",children:[D.length," step",D.length!==1?"s":""," total"]})})]}):e.jsxs("div",{className:"text-center py-8 text-gray-500 text-sm",children:[e.jsx(ce,{size:24,className:"mx-auto mb-2 opacity-50"}),"No steps defined yet"]})]}),b==="attachments"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h4",{className:"text-sm font-medium text-gray-300",children:"Attachments"}),e.jsxs("label",{className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-lg bg-brand-600 hover:bg-brand-500 text-white cursor-pointer transition-colors",children:[e.jsx(Zs,{size:13}),"Upload Files",e.jsx("input",{type:"file",multiple:!0,accept:"image/*,.pdf,.doc,.docx,.xls,.xlsx,.ppt,.pptx,.txt,.csv,.json,.xml,.yaml,.yml,.md",className:"hidden",onChange:le})]})]}),e.jsx("p",{className:"text-xs text-gray-500",children:"Max 10MB per file. Supported: Images, PDFs, Office documents, text files."}),U.length>0?e.jsx("div",{className:"space-y-2",children:U.map(s=>{var C;return e.jsxs("div",{className:"flex items-center gap-3 bg-surface-2 rounded-lg p-3 border border-white/5 group hover:border-white/10 transition-colors",children:[e.jsx("div",{className:"flex-shrink-0 w-10 h-10 rounded-lg bg-surface-1 border border-white/5 flex items-center justify-center overflow-hidden",children:te(s.fileType)?e.jsx("button",{onClick:()=>Y(s),className:"w-full h-full",children:e.jsx("img",{src:`data:${s.fileType};base64,${s.fileData}`,alt:s.fileName,className:"w-full h-full object-cover rounded-lg"})}):(C=s.fileType)!=null&&C.includes("pdf")?e.jsx(Pe,{size:18,className:"text-red-400"}):e.jsx(Pe,{size:18,className:"text-gray-400"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm text-gray-200 font-medium truncate",children:s.fileName}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500",children:[e.jsx("span",{children:Le(s.fileSize)}),s.uploadedBy&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"·"}),e.jsx("span",{children:s.uploadedBy})]}),e.jsx("span",{children:"·"}),e.jsx("span",{children:mt(s.createdAt)})]})]}),e.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[te(s.fileType)&&e.jsx("button",{onClick:()=>Y(s),className:"p-1.5 rounded-lg hover:bg-white/10 text-gray-400 hover:text-gray-200",title:"Preview",children:e.jsx(Ue,{size:14})}),e.jsx("button",{onClick:()=>he(s),className:"p-1.5 rounded-lg hover:bg-white/10 text-gray-400 hover:text-gray-200",title:"Download",children:e.jsx(Qs,{size:14})}),e.jsx("button",{onClick:()=>Ne(s.id),className:"p-1.5 rounded-lg hover:bg-white/10 text-gray-400 hover:text-red-400",title:"Delete",children:e.jsx(ue,{size:14})})]})]},s.id)})}):e.jsxs("div",{className:"text-center py-8 text-gray-500 text-sm",children:[e.jsx(rt,{size:24,className:"mx-auto mb-2 opacity-50"}),"No attachments yet"]}),F&&e.jsx("div",{className:"fixed inset-0 z-[60] flex items-center justify-center bg-black/80 backdrop-blur-sm",onClick:()=>Y(null),children:e.jsxs("div",{className:"relative max-w-4xl max-h-[90vh] mx-4",onClick:s=>s.stopPropagation(),children:[e.jsx("button",{onClick:()=>Y(null),className:"absolute -top-3 -right-3 z-10 p-1.5 rounded-full bg-surface-2 border border-white/10 text-gray-300 hover:text-white shadow-xl",children:e.jsx(ee,{size:16})}),e.jsx("img",{src:`data:${F.fileType};base64,${F.fileData}`,alt:F.fileName,className:"max-w-full max-h-[85vh] rounded-xl shadow-2xl object-contain"}),e.jsx("p",{className:"text-center text-sm text-gray-400 mt-2",children:F.fileName})]})})]}),b==="links"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h4",{className:"text-sm font-medium text-gray-300",children:"Reference Links"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(pa,{testCaseId:t.id,onLinked:()=>{}}),e.jsxs("button",{onClick:()=>V(!P),className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors",children:[e.jsx(Me,{size:13}),"Add Link"]})]})]}),P&&e.jsxs("div",{className:"bg-surface-2 rounded-lg border border-white/10 p-4 space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-400 mb-1",children:"Title *"}),e.jsx("input",{className:"w-full bg-surface-1 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 outline-none focus:border-brand-500",value:M.title,onChange:s=>_({...M,title:s.target.value}),placeholder:"e.g. JIRA-1234 Login Bug, Design Mockup..."})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-400 mb-1",children:"URL *"}),e.jsx("input",{className:"w-full bg-surface-1 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 outline-none focus:border-brand-500",value:M.url,onChange:s=>_({...M,url:s.target.value}),placeholder:"https://..."})]}),e.jsxs("div",{className:"relative",children:[e.jsx("label",{className:"block text-xs font-medium text-gray-400 mb-1",children:"Type"}),e.jsxs("button",{type:"button",onClick:()=>E(!B),className:"w-full bg-surface-1 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 outline-none focus:border-brand-500 flex items-center gap-2 text-left",children:[e.jsx(K,{type:M.linkType,size:16}),e.jsx("span",{className:"flex-1",children:{jira:"Jira Ticket",confluence:"Confluence Page",github:"GitHub Issue / PR",docs:"Documentation",design:"Design (Figma, etc.)",other:"Other"}[M.linkType]||"Other"}),e.jsx(ne,{size:14,className:`text-gray-400 transition-transform ${B?"rotate-180":""}`})]}),B&&e.jsx("div",{className:"absolute z-20 mt-1 w-full bg-surface-1 border border-white/10 rounded-lg shadow-xl overflow-hidden",children:[{value:"jira",label:"Jira Ticket"},{value:"confluence",label:"Confluence Page"},{value:"github",label:"GitHub Issue / PR"},{value:"docs",label:"Documentation"},{value:"design",label:"Design (Figma, etc.)"},{value:"other",label:"Other"}].map(s=>e.jsxs("button",{type:"button",onClick:()=>{_({...M,linkType:s.value}),E(!1)},className:`w-full flex items-center gap-2.5 px-3 py-2.5 text-sm text-left hover:bg-surface-2 transition-colors ${M.linkType===s.value?"bg-surface-2 text-brand-300":"text-gray-200"}`,children:[e.jsx(K,{type:s.value,size:16}),e.jsx("span",{children:s.label}),M.linkType===s.value&&e.jsx(pe,{size:14,className:"ml-auto text-brand-400"})]},s.value))})]}),e.jsxs("div",{className:"flex gap-2 justify-end pt-1",children:[e.jsx("button",{onClick:()=>{V(!1),_({title:"",url:"",linkType:"other"})},className:"px-3 py-1.5 text-xs rounded-lg bg-surface-1 hover:bg-surface-0 text-gray-400 border border-white/10",children:"Cancel"}),e.jsx("button",{onClick:se,disabled:!M.title.trim()||!M.url.trim(),className:"px-3 py-1.5 text-xs rounded-lg bg-brand-600 hover:bg-brand-500 text-white font-medium disabled:opacity-50",children:"Add Link"})]})]}),A.length>0?e.jsx("div",{className:"space-y-2",children:A.map(s=>e.jsxs("div",{className:"flex items-center gap-3 bg-surface-2 rounded-lg p-3 border border-white/5 group hover:border-white/10 transition-colors",children:[e.jsx("div",{className:"flex-shrink-0 w-7 h-7 rounded-md bg-surface-1 border border-white/5 flex items-center justify-center",children:e.jsx(K,{type:s.linkType,size:16})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm text-gray-200 font-medium truncate",children:s.title}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500",children:[e.jsx("span",{className:`font-medium ${(S[s.linkType]||S.other).color}`,children:(S[s.linkType]||S.other).label}),e.jsx("span",{children:"·"}),e.jsx("span",{className:"truncate max-w-[200px]",children:s.url}),s.addedBy&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"·"}),e.jsx("span",{children:s.addedBy})]})]})]}),e.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsx("a",{href:s.url,target:"_blank",rel:"noopener noreferrer",className:"p-1.5 rounded-lg hover:bg-white/10 text-gray-400 hover:text-brand-300",title:"Open Link",children:e.jsx(Ae,{size:14})}),s.linkType==="jira"&&e.jsx(ga,{jiraUrl:s.url,testCaseTitle:t.title||t.name||""}),e.jsx("button",{onClick:()=>X(s.id),className:"p-1.5 rounded-lg hover:bg-white/10 text-gray-400 hover:text-red-400",title:"Delete",children:e.jsx(ue,{size:14})})]})]},s.id))}):e.jsxs("div",{className:"text-center py-8 text-gray-500 text-sm",children:[e.jsx(nt,{size:24,className:"mx-auto mb-2 opacity-50"}),"No reference links yet"]})]}),b==="history"&&e.jsx(na,{testCase:t,versions:G,onToast:g,currentUserName:p}),b==="mapping"&&e.jsxs("div",{className:"space-y-5",children:[l.length>0&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-medium text-gray-400 uppercase tracking-wider mb-2",children:"Generated From Sources"}),e.jsx("div",{className:"space-y-1.5",children:l.map(s=>{const C={requirement:"Requirement",nlp:"NLP",jira:"JIRA",document:"Document"},L=()=>{if(s.type==="jira")return e.jsx(n,{size:16});const W={requirement:"📋",nlp:"💬",document:"📎"};return e.jsx("span",{className:"text-sm",children:W[s.type]||"📎"})};return e.jsxs("div",{className:"flex items-center gap-2.5 bg-surface-2 rounded-lg px-3 py-2.5 border border-white/5",children:[e.jsx("span",{className:"flex-shrink-0",children:e.jsx(L,{})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm text-gray-200 font-medium truncate",children:s.title}),e.jsx("span",{className:"text-[10px] text-gray-500",children:C[s.type]||"Source"})]}),s.externalUrl&&e.jsx("a",{href:s.externalUrl,target:"_blank",rel:"noopener noreferrer",className:"p-1 rounded hover:bg-white/10 text-gray-400 hover:text-brand-300",children:e.jsx(Ae,{size:12})})]},s.id)})})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-medium text-gray-400 uppercase tracking-wider mb-2",children:"Script Mapping"}),c?e.jsxs("div",{className:"bg-surface-2 rounded-lg border border-white/5 px-4 py-3 flex items-start gap-3",children:[e.jsx("div",{className:"w-9 h-9 rounded-lg bg-brand-500/10 border border-brand-500/20 flex items-center justify-center shrink-0 mt-0.5",children:e.jsx(_e,{size:16,className:"text-brand-400"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[c.testName&&e.jsx("p",{className:"text-sm font-medium text-gray-200 mb-0.5",title:c.testName,children:es(c.testName)}),e.jsx("p",{className:"text-xs font-mono text-gray-400 truncate",title:c.scriptPath,children:c.scriptPath}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mt-2",children:[c.framework&&e.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-[10px] font-medium bg-sky-500/20 text-sky-200 border border-sky-500/25",children:c.framework}),c.syncStatus&&e.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded text-[10px] font-medium ${c.syncStatus==="synced"?"bg-emerald-500/15 text-emerald-300 border border-emerald-500/20":c.syncStatus==="case_updated"?"bg-blue-500/15 text-blue-300 border border-blue-500/20":c.syncStatus==="script_updated"?"bg-amber-500/15 text-amber-300 border border-amber-500/20":"bg-red-500/15 text-red-300 border border-red-500/20"}`,children:[c.syncStatus==="synced"?e.jsx(xe,{size:9}):e.jsx(me,{size:9}),Z(c.syncStatus)]}),c.lastSynced&&e.jsxs("span",{className:"text-[10px] text-gray-500",children:["Synced: ",new Date(c.lastSynced).toLocaleString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})]})]})]}),e.jsx("button",{onClick:()=>{const s=c.scriptPath.replace(/\\/g,"/"),C=`/tests?file=${encodeURIComponent(s)}&test=${encodeURIComponent(c.testName||"")}`;window.open(C,"_blank","noopener")},className:"p-2 rounded-lg hover:bg-white/10 text-gray-400 hover:text-brand-400 transition-colors shrink-0",title:"View Script (new tab)",children:e.jsx(Ae,{size:16})})]}):e.jsxs("div",{className:"text-center py-6 text-gray-500 text-sm bg-surface-2 rounded-lg border border-white/5",children:[e.jsx(_e,{size:20,className:"mx-auto mb-1.5 opacity-50"}),"No script mapping configured",e.jsx("p",{className:"text-xs text-gray-600 mt-1",children:"Map this test case to a script in the Script Mapping screen"})]})]})]}),b==="executions"&&e.jsxs("div",{className:"space-y-4",children:[Q.length>0&&e.jsxs("div",{className:"bg-surface-2 rounded-xl border border-white/5 p-4",children:[e.jsxs("div",{className:"grid grid-cols-4 gap-4 text-center",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xl font-bold text-gray-100",children:Q.length}),e.jsx("div",{className:"text-xs text-gray-500",children:"Total Runs"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xl font-bold text-emerald-400",children:Q.filter(s=>s.status==="passed").length}),e.jsx("div",{className:"text-xs text-gray-500",children:"Passed"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xl font-bold text-red-400",children:Q.filter(s=>s.status==="failed").length}),e.jsx("div",{className:"text-xs text-gray-500",children:"Failed"})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"text-xl font-bold text-brand-400",children:[we,"%"]}),e.jsx("div",{className:"text-xs text-gray-500",children:"Pass Rate"})]})]}),e.jsx("div",{className:"mt-3 h-2 bg-surface-1 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-emerald-500 rounded-full transition-all",style:{width:`${we}%`}})})]}),Q.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx(at,{className:"w-8 h-8 text-gray-600 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-gray-500",children:"No executions yet"}),e.jsx("p",{className:"text-xs text-gray-600 mt-1",children:"This test case has not been executed in any cycle."})]}):e.jsx("div",{className:"space-y-2",children:Q.map(s=>{var Se,J;const C=h===s.executionId,L={passed:"bg-emerald-500/10 text-emerald-400 border-emerald-500/20",failed:"bg-red-500/10 text-red-400 border-red-500/20",blocked:"bg-orange-500/10 text-orange-400 border-orange-500/20",skipped:"bg-gray-500/10 text-gray-400 border-gray-500/20",not_run:"bg-slate-500/10 text-slate-400 border-slate-500/20",in_progress:"bg-blue-500/10 text-blue-400 border-blue-500/20"},W={passed:e.jsx(ea,{className:"w-4 h-4 text-emerald-400"}),failed:e.jsx(ft,{className:"w-4 h-4 text-red-400"}),blocked:e.jsx(me,{className:"w-4 h-4 text-orange-400"}),skipped:e.jsx(Xs,{className:"w-4 h-4 text-gray-400"}),not_run:e.jsx(Fe,{className:"w-4 h-4 text-slate-400"})},be=s.executedAt?Je(s.executedAt):"—",ke=s.duration?`${s.duration}s`:"—";return e.jsxs("div",{className:"bg-surface-2 rounded-xl border border-white/5 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 cursor-pointer hover:bg-white/[0.02] transition-colors",onClick:()=>d(C?null:s.executionId),children:[C?e.jsx(ne,{className:"w-4 h-4 text-gray-500 shrink-0"}):e.jsx(qe,{className:"w-4 h-4 text-gray-500 shrink-0"}),W[s.status]||e.jsx(Fe,{className:"w-4 h-4 text-gray-500"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-sm font-medium text-gray-200 truncate",children:s.planName||"Plan"}),e.jsx(je,{className:"w-3 h-3 text-gray-600 shrink-0"}),e.jsx("span",{className:"text-sm text-gray-300 truncate",children:s.cycleName||"Cycle"})]}),e.jsxs("div",{className:"flex items-center gap-3 mt-0.5 text-xs text-gray-500",children:[e.jsx("span",{children:be}),s.executedBy&&e.jsxs("span",{children:["by ",s.executedBy]}),s.duration>0&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(Ws,{className:"w-3 h-3"})," ",ke]})]})]}),e.jsx("span",{className:`text-xs px-2.5 py-1 rounded-full border font-medium capitalize ${L[s.status]||L.not_run}`,children:(s.status||"not_run").replace("_"," ")}),((Se=s.stepSummary)==null?void 0:Se.total)>0&&e.jsxs("span",{className:"text-[10px] text-gray-500 shrink-0",children:[s.stepSummary.passed,"/",s.stepSummary.total," steps"]}),s.defect&&e.jsxs("span",{className:`text-[10px] px-2 py-0.5 rounded border flex items-center gap-1 shrink-0 ${s.defect.status==="open"?"bg-red-500/10 text-red-400 border-red-500/20":s.defect.status==="resolved"?"bg-emerald-500/10 text-emerald-400 border-emerald-500/20":"bg-amber-500/10 text-amber-400 border-amber-500/20"}`,children:[e.jsx(lt,{className:"w-3 h-3"}),s.defect.id]})]}),C&&e.jsxs("div",{className:"border-t border-white/5 px-4 py-3 bg-surface-1/50",children:[((J=s.stepResults)==null?void 0:J.length)>0?e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-white/5",children:[e.jsx("th",{className:"text-left px-3 py-2 text-gray-500 font-medium w-8",children:"#"}),e.jsx("th",{className:"text-left px-3 py-2 text-gray-500 font-medium w-16",children:"Status"}),e.jsx("th",{className:"text-left px-3 py-2 text-gray-500 font-medium",children:"Action"}),e.jsx("th",{className:"text-left px-3 py-2 text-gray-500 font-medium",children:"Expected"}),e.jsx("th",{className:"text-left px-3 py-2 text-gray-500 font-medium",children:"Actual"})]})}),e.jsx("tbody",{children:s.stepResults.map((q,Ie)=>e.jsxs("tr",{className:`border-b border-white/5 ${q.status==="failed"?"bg-red-500/5":""}`,children:[e.jsx("td",{className:"px-3 py-2 text-gray-600 font-mono",children:q.stepNumber}),e.jsx("td",{className:"px-3 py-2",children:e.jsx("span",{className:`inline-flex items-center gap-1 ${q.status==="passed"?"text-emerald-400":q.status==="failed"?"text-red-400":q.status==="blocked"?"text-orange-400":"text-gray-500"}`,children:q.status==="passed"?"✅":q.status==="failed"?"❌":q.status==="blocked"?"🚫":q.status==="skipped"?"⏭":"⬜"})}),e.jsx("td",{className:"px-3 py-2 text-gray-300 max-w-[180px]",children:e.jsx("span",{className:"line-clamp-2",children:q.action||"—"})}),e.jsx("td",{className:"px-3 py-2 text-gray-400 max-w-[150px]",children:e.jsx("span",{className:"line-clamp-2",children:q.expectedResult||"—"})}),e.jsx("td",{className:`px-3 py-2 max-w-[150px] ${q.status==="failed"?"text-red-400 font-medium":"text-gray-400"}`,children:e.jsx("span",{className:"line-clamp-2",children:q.actualResult||"—"})})]},Ie))})]})}):e.jsx("p",{className:"text-xs text-gray-500 text-center py-4",children:"No step-level results recorded for this execution."}),s.defect&&e.jsxs("div",{className:`mt-3 p-3 rounded-lg border flex items-center gap-2 ${s.defect.status==="open"?"bg-red-500/5 border-red-500/20":s.defect.status==="resolved"?"bg-emerald-500/5 border-emerald-500/20":"bg-amber-500/5 border-amber-500/20"}`,children:[e.jsx(lt,{className:"w-4 h-4 text-red-400 shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("span",{className:"text-xs font-medium text-gray-200",children:s.defect.id}),e.jsx("span",{className:"text-xs text-gray-400 ml-2 truncate",children:s.defect.title})]}),e.jsx("span",{className:`text-[10px] px-2 py-0.5 rounded-full capitalize ${s.defect.status==="open"?"bg-red-500/10 text-red-400":s.defect.status==="resolved"?"bg-emerald-500/10 text-emerald-400":"bg-amber-500/10 text-amber-400"}`,children:s.defect.status.replace("_"," ")}),e.jsx("span",{className:"text-[10px] text-gray-500 capitalize",children:s.defect.severity})]}),s.comments&&e.jsxs("div",{className:"mt-3 p-3 rounded-lg bg-surface-2 border border-white/5",children:[e.jsx("span",{className:"text-[10px] font-medium text-gray-500 uppercase tracking-wider",children:"Execution Notes"}),e.jsx("p",{className:"text-xs text-gray-300 mt-1",children:s.comments})]})]})]},s.executionId)})})]})]})]})]})}function oa({folders:t,count:y,onMove:u,onClose:g}){const[p,b]=o.useState(""),v=(d,j=0)=>{const f=[];for(const c of d)f.push({id:c.id,name:c.name,depth:j}),c.children&&f.push(...v(c.children,j+1));return f},h=v(t||[]);return e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[e.jsx("div",{className:"absolute inset-0 bg-black/60",onClick:g}),e.jsxs("div",{className:"relative bg-surface-1 rounded-xl border border-white/10 p-6 w-96 animate-fade-in",children:[e.jsxs("h3",{className:"text-base font-semibold text-gray-100 mb-1",children:["Move ",y," Test Case",y>1?"s":""]}),e.jsx("p",{className:"text-sm text-gray-400 mb-4",children:"Select a destination folder"}),e.jsxs("select",{className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 outline-none focus:border-brand-500 mb-4",value:p,onChange:d=>b(d.target.value),children:[e.jsx("option",{value:"",children:"Select folder..."}),h.map(d=>e.jsxs("option",{value:d.id,children:[" ".repeat(d.depth),d.name]},d.id))]}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx("button",{onClick:g,className:"px-4 py-2 text-sm rounded-lg bg-surface-2 hover:bg-surface-3 text-gray-300",children:"Cancel"}),e.jsx("button",{onClick:()=>{p&&u(p)},disabled:!p,className:"px-4 py-2 text-sm rounded-lg bg-brand-600 hover:bg-brand-500 text-white font-medium disabled:opacity-50",children:"Move"})]})]})]})}function ca({tags:t,count:y,onApply:u,onClose:g}){const[p,b]=o.useState(new Set),v=h=>{const d=new Set(p);d.has(h)?d.delete(h):d.add(h),b(d)};return e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[e.jsx("div",{className:"absolute inset-0 bg-black/60",onClick:g}),e.jsxs("div",{className:"relative bg-surface-1 rounded-xl border border-white/10 p-6 w-96 animate-fade-in",children:[e.jsxs("h3",{className:"text-base font-semibold text-gray-100 mb-1",children:["Tag ",y," Test Case",y>1?"s":""]}),e.jsx("p",{className:"text-sm text-gray-400 mb-4",children:"Select tags to apply"}),e.jsxs("div",{className:"flex flex-wrap gap-2 mb-4 max-h-48 overflow-y-auto",children:[t==null?void 0:t.map(h=>e.jsxs("button",{onClick:()=>v(h.id),className:`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium transition-colors border ${p.has(h.id)?"border-brand-500 bg-brand-500/20 text-brand-300":"border-white/10 bg-surface-2 text-gray-400 hover:text-gray-300"}`,children:[p.has(h.id)&&e.jsx(pe,{size:12}),h.name]},h.id)),(!t||t.length===0)&&e.jsx("p",{className:"text-sm text-gray-500",children:"No tags available. Create tags first."})]}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx("button",{onClick:g,className:"px-4 py-2 text-sm rounded-lg bg-surface-2 hover:bg-surface-3 text-gray-300",children:"Cancel"}),e.jsx("button",{onClick:()=>u(Array.from(p)),disabled:p.size===0,className:"px-4 py-2 text-sm rounded-lg bg-brand-600 hover:bg-brand-500 text-white font-medium disabled:opacity-50",children:"Apply Tags"})]})]})]})}function xa({title:t,message:y,confirmLabel:u="Delete",onConfirm:g,onCancel:p}){return e.jsx("div",{className:"fixed inset-0 z-[110] flex items-center justify-center bg-black/60 backdrop-blur-sm animate-fade-in",children:e.jsxs("div",{className:"bg-surface-2 border border-border-1 rounded-2xl shadow-2xl w-full max-w-md mx-4 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-3 px-6 pt-6 pb-2",children:[e.jsx("div",{className:"flex items-center justify-center w-10 h-10 rounded-full bg-red-500/15",children:e.jsx(me,{size:20,className:"text-red-400"})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-100",children:t})]}),e.jsx("div",{className:"px-6 py-4",children:e.jsx("p",{className:"text-sm text-gray-400 leading-relaxed",children:y})}),e.jsxs("div",{className:"flex items-center justify-end gap-3 px-6 py-4 border-t border-border-1 bg-surface-1/50",children:[e.jsx("button",{onClick:p,className:"px-4 py-2 text-sm font-medium text-gray-300 bg-surface-1 border border-border-1 rounded-lg hover:bg-surface-2 hover:text-gray-100 transition-colors",children:"Cancel"}),e.jsx("button",{onClick:g,className:"px-4 py-2 text-sm font-medium text-white bg-red-600 rounded-lg hover:bg-red-500 transition-colors shadow-lg shadow-red-600/20",children:u})]})]})})}function ma({tags:t,selectedIds:y,onChange:u}){var i;const[g,p]=o.useState(!1),[b,v]=o.useState(""),h=o.useRef(null);o.useEffect(()=>{if(!g)return;const r=x=>{h.current&&!h.current.contains(x.target)&&p(!1)};return document.addEventListener("mousedown",r),()=>document.removeEventListener("mousedown",r)},[g]);const d=o.useMemo(()=>{const r=b.trim().toLowerCase();return r?t.filter(x=>x.name.toLowerCase().includes(r)):t},[t,b]),j=r=>{const x=new Set(y);x.has(r)?x.delete(r):x.add(r),u(x)},f=r=>{r.stopPropagation(),u(new Set)},c=y.size,N=c===0?"Tags":c===1?((i=t.find(r=>r.id===Array.from(y)[0]))==null?void 0:i.name)||"1 tag":`${c} tags`;return e.jsxs("div",{ref:h,className:"relative",children:[e.jsxs("button",{type:"button",onClick:()=>p(r=>!r),className:`flex items-center gap-1.5 bg-surface-1 border rounded-lg px-3 py-2 text-sm outline-none transition-colors ${c>0?"border-brand-500/40 text-gray-200":"border-white/10 text-gray-300 hover:border-white/20"}`,children:[e.jsx(bt,{size:13,className:c>0?"text-brand-400":"text-gray-500"}),e.jsx("span",{children:N}),c>0?e.jsx("span",{onClick:f,role:"button",className:"ml-0.5 p-0.5 rounded hover:bg-white/10 text-gray-400 hover:text-gray-200",title:"Clear tag filter",children:e.jsx(ee,{size:12})}):e.jsx(ne,{size:12,className:"text-gray-500"})]}),g&&e.jsxs("div",{className:"absolute left-0 top-full mt-1 z-40 w-64 bg-surface-1 border border-white/10 rounded-lg shadow-xl overflow-hidden",children:[e.jsx("div",{className:"p-2 border-b border-white/5",children:e.jsxs("div",{className:"relative",children:[e.jsx($e,{size:12,className:"absolute left-2 top-1/2 -translate-y-1/2 text-gray-500"}),e.jsx("input",{autoFocus:!0,value:b,onChange:r=>v(r.target.value),placeholder:"Search tags…",className:"w-full bg-surface-2 border border-white/10 rounded pl-7 pr-2 py-1.5 text-xs text-gray-200 outline-none focus:border-brand-500"})]})}),e.jsx("div",{className:"max-h-64 overflow-y-auto py-1",children:d.length===0?e.jsx("div",{className:"px-3 py-3 text-xs text-gray-500 text-center",children:"No tags found"}):d.map(r=>{const x=y.has(r.id);return e.jsxs("button",{type:"button",onClick:()=>j(r.id),className:`w-full flex items-center gap-2 px-3 py-1.5 text-xs text-left transition-colors ${x?"bg-brand-500/10 text-gray-100":"text-gray-300 hover:bg-surface-2"}`,children:[e.jsx("span",{className:`w-3.5 h-3.5 rounded border flex items-center justify-center flex-shrink-0 ${x?"bg-brand-600 border-brand-500 text-white":"border-white/20"}`,children:x&&e.jsx(pe,{size:10})}),r.color&&e.jsx("span",{className:"w-2 h-2 rounded-full flex-shrink-0",style:{background:r.color}}),e.jsx("span",{className:"truncate",children:r.name})]},r.id)})}),c>0&&e.jsxs("div",{className:"border-t border-white/5 px-2 py-1.5 flex items-center justify-between",children:[e.jsxs("span",{className:"text-[10px] text-gray-500",children:[c," selected"]}),e.jsx("button",{type:"button",onClick:()=>u(new Set),className:"text-[10px] text-gray-400 hover:text-gray-200 px-2 py-0.5 rounded hover:bg-white/5",children:"Clear all"})]})]})]})}function ua({sources:t,selectedId:y,onChange:u}){const[g,p]=o.useState(!1),[b,v]=o.useState(""),h=o.useRef(null),[d,j]=o.useState(!1);o.useEffect(()=>{var m;if(!g)return;const r=(m=h.current)==null?void 0:m.getBoundingClientRect();if(!r)return;const z=r.left+288+16>window.innerWidth;j(z)},[g]),o.useEffect(()=>{if(!g)return;const r=x=>{h.current&&!h.current.contains(x.target)&&p(!1)};return document.addEventListener("mousedown",r),()=>document.removeEventListener("mousedown",r)},[g]);const f=o.useMemo(()=>{const r=b.trim().toLowerCase();return r?t.filter(x=>x.title.toLowerCase().includes(r)):t},[t,b]),c=t.find(r=>r.id===y)||null,N={requirement:"Requirement",nlp:"Notes",jira:"JIRA",document:"Document"},i=c?c.title:"Source";return e.jsxs("div",{ref:h,className:"relative",children:[e.jsxs("button",{type:"button",onClick:()=>p(r=>!r),className:`flex items-center gap-1.5 bg-surface-1 border rounded-lg px-3 py-2 text-sm outline-none transition-colors max-w-[220px] ${c?"border-brand-500/40 text-gray-200":"border-white/10 text-gray-300 hover:border-white/20"}`,children:[e.jsx(Us,{size:13,className:c?"text-brand-400":"text-gray-500"}),e.jsx("span",{className:"truncate",children:i}),c?e.jsx("span",{onClick:r=>{r.stopPropagation(),u(null)},role:"button",className:"ml-0.5 p-0.5 rounded hover:bg-white/10 text-gray-400 hover:text-gray-200 flex-shrink-0",title:"Clear source filter",children:e.jsx(ee,{size:12})}):e.jsx(ne,{size:12,className:"text-gray-500 flex-shrink-0"})]}),g&&e.jsxs("div",{className:`absolute top-full mt-1 z-40 w-72 bg-surface-1 border border-white/10 rounded-lg shadow-xl overflow-hidden ${d?"right-0":"left-0"}`,children:[e.jsx("div",{className:"p-2 border-b border-white/5",children:e.jsxs("div",{className:"relative",children:[e.jsx($e,{size:12,className:"absolute left-2 top-1/2 -translate-y-1/2 text-gray-500"}),e.jsx("input",{autoFocus:!0,value:b,onChange:r=>v(r.target.value),placeholder:"Search sources…",className:"w-full bg-surface-2 border border-white/10 rounded pl-7 pr-2 py-1.5 text-xs text-gray-200 outline-none focus:border-brand-500"})]})}),e.jsx("div",{className:"max-h-64 overflow-y-auto py-1",children:f.length===0?e.jsx("div",{className:"px-3 py-3 text-xs text-gray-500 text-center",children:t.length===0?"No sources have linked test cases yet":"No sources match your search"}):f.map(r=>{const x=r.id===y;return e.jsxs("button",{type:"button",onClick:()=>{u(x?null:r.id),p(!1)},title:r.title,className:`w-full flex items-center gap-2 px-3 py-1.5 text-xs text-left transition-colors ${x?"bg-brand-500/10 text-gray-100":"text-gray-300 hover:bg-surface-2"}`,children:[e.jsx("span",{className:"flex-1 min-w-0 truncate",children:r.title}),e.jsxs("span",{title:`${N[r.type]||r.type} · ${r.testCaseCount} test case${r.testCaseCount===1?"":"s"}`,className:"text-[10px] text-gray-500 flex-shrink-0",children:[N[r.type]||r.type," · ",r.testCaseCount]}),x&&e.jsx(pe,{size:12,className:"text-brand-300 flex-shrink-0"})]},r.id)})})]})]})}function $a(){var Qe,We,Ye;const{toast:t}=ht(),y=o.useCallback((a,R="success")=>{t(R,a)},[t]),{user:u}=Ds(),g=(u==null?void 0:u.displayName)||(u==null?void 0:u.username)||"",[p,b]=o.useState(null),[v,h]=o.useState(""),[d,j]=o.useState(!1);o.useEffect(()=>{if(!d)return;const a=R=>{R.key==="Escape"&&j(!1)};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[d]);const[f,c]=o.useState({}),[N,i]=o.useState(new Set),[r,x]=o.useState(null),{data:T}=ts(),z=(T==null?void 0:T.sources)??[],[m,I]=o.useState(new Set),[D,G]=o.useState(!1),[U,A]=o.useState(null),[l]=Qt("tcId"),P=Wt(),[V,M]=o.useState(!1),[_,B]=o.useState(""),[E,F]=o.useState(1),[Y,n]=o.useState(!1),[w,k]=o.useState(!1),[S,K]=o.useState("createdAt"),[le,Ne]=o.useState("desc"),[se,X]=o.useState(null),{data:he,isLoading:Le}=ss(),te=(he==null?void 0:he.tree)||[],Q=as(),we=rs(),{data:ge}=ns(),ie=(ge==null?void 0:ge.tags)||[],{data:O}=ls(),{data:s}=is(),C=(s==null?void 0:s.dots)||{},L=Xt(v,250),[W,be]=o.useState(L),ke=W===L?E:1;o.useEffect(()=>{W!==L&&(be(L),F(1))},[L,W]);const Se=o.useMemo(()=>{const a={page:ke,limit:Ce,sort:S,order:le};return p&&(a.folderId=p),p==="__uncategorized__"&&(a.folderId=null),L.trim()&&(a.search=L.trim()),f.priority&&(a.priority=f.priority),f.type&&(a.type=f.type),f.status&&(a.status=f.status),f.automationStatus&&(a.automationStatus=f.automationStatus),f.reviewStatus&&(a.reviewStatus=f.reviewStatus),N.size>0&&(a.tagIds=Array.from(N)),r&&(a.sourceId=r),a},[p,L,f,N,r,ke,S,le]),{data:J,isLoading:q}=ds(Se),Ie=os(),At=cs(),Mt=xs(),Te=ms(),Rt=us(),H=(J==null?void 0:J.testCases)||[],ae=(J==null?void 0:J.total)||H.length,re=Math.ceil(ae/Ce)||1,Ge=((Qe=J==null?void 0:J.aggregates)==null?void 0:Qe.byPriority)||{},Dt=((We=J==null?void 0:J.aggregates)==null?void 0:We.byAutomation)||{},Ve=o.useMemo(()=>{if(!l)return null;const a=l.toLowerCase();return H.find(R=>{var $;return(($=R.id)==null?void 0:$.toLowerCase())===a})||null},[l,H]),{data:$t}=ps(l&&!Ve?l:null),Ke=Ve||($t??null),He=()=>{_.trim()&&(Q.mutate({name:_.trim(),parentId:p}),B(""),M(!1))},Et=a=>{X({title:"Delete Folder",message:"Are you sure you want to delete this folder? All test cases inside it will become uncategorized. This action cannot be undone.",confirmLabel:"Delete Folder",onConfirm:()=>{we.mutate(a),p===a&&b(null),X(null)}})},Lt=a=>{X({title:"Delete Test Case",message:"Are you sure you want to delete this test case? This action cannot be undone and all associated versions, steps, and data will be permanently removed.",confirmLabel:"Delete Test Case",onConfirm:()=>{Ie.mutate(a),I(R=>{const $=new Set(R);return $.delete(a),$}),X(null)}})},It=()=>{m.size!==0&&X({title:"Delete Selected Test Cases",message:`Are you sure you want to delete ${m.size} selected test case(s)? This action cannot be undone and all associated data will be permanently removed.`,confirmLabel:`Delete ${m.size} Test Case(s)`,onConfirm:()=>{At.mutate(Array.from(m)),I(new Set),X(null)}})},_t=a=>{Mt.mutate({ids:Array.from(m),folderId:a}),I(new Set),n(!1)},Ft=a=>{Rt.mutate({ids:Array.from(m),tagIds:a}),I(new Set),k(!1)},Pt=a=>{I(R=>{const $=new Set(R);return $.has(a)?$.delete(a):$.add(a),$})},Bt=()=>{m.size===H.length?I(new Set):I(new Set(H.map(a=>a.id)))},Ut=a=>{S===a?Ne(R=>R==="asc"?"desc":"asc"):(K(a),Ne("asc"))},fe=(a,R)=>{c($=>{const de={...$};return R?de[a]=R:delete de[a],de}),F(1)},Ot=()=>{c({}),i(new Set),x(null),h(""),F(1)},ze=Object.keys(f).length+(v?1:0)+(N.size>0?1:0)+(r?1:0);((Ye=O==null?void 0:O.byAutomation)==null?void 0:Ye.automated)??(O==null||O.automatedCount);const Ze=(O==null?void 0:O.totalCases)??(O==null?void 0:O.totalCount)??ae??0,Jt=o.useMemo(()=>(te||[]).reduce((a,R)=>a+(R.testCaseCount??0),0),[te]),qt=Math.max(0,Ze-Jt);return e.jsxs("div",{className:"h-full flex flex-col bg-surface-0 animate-fade-in",children:[e.jsx("div",{className:"flex-shrink-0 border-b border-white/5 bg-surface-1",children:e.jsx("div",{className:"max-w-[1400px] mx-auto px-6 py-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold text-gray-100 flex items-center gap-3",children:[e.jsx(ce,{size:24,className:"text-brand-300"}),"Test Cases"]}),e.jsxs("div",{className:"flex items-center gap-3 mt-2",children:[e.jsx("p",{className:"text-sm text-gray-400",children:"Manage, organize, and track your test cases"}),e.jsx("span",{className:"text-xs text-gray-500",children:"|"}),e.jsxs("div",{className:"flex items-center gap-2.5 text-sm",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 bg-brand-500/15 text-brand-300 px-3 py-1 rounded-full font-medium",children:[e.jsx(Pe,{size:14}),ae," Cases"]}),(()=>{const a=Dt.automated??0,R=ae>0?Math.round(a/ae*100):0;return e.jsxs("span",{className:"inline-flex items-center gap-1.5 bg-emerald-500/15 text-emerald-300 px-3 py-1 rounded-full font-medium",children:[e.jsx(Be,{size:14}),R,"% Automated"]})})(),(()=>{const a=Ge.critical??0;return a>0?e.jsxs("span",{className:"inline-flex items-center gap-1.5 bg-red-500/15 text-red-300 px-3 py-1 rounded-full font-medium",children:[e.jsx(me,{size:14}),a," Critical"]}):null})(),(()=>{const a=Ge.high??0;return a>0?e.jsxs("span",{className:"inline-flex items-center gap-1.5 bg-orange-500/15 text-orange-300 px-3 py-1 rounded-full font-medium",children:[e.jsx(Os,{size:14}),a," High"]}):null})()]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[m.size>0&&e.jsx(Rs,{type:"test-cases",formats:["docx","xlsx","csv"],label:`Export (${m.size})`,params:{ids:Array.from(m)}}),e.jsxs("button",{onClick:()=>{A(null),G(!0)},className:"inline-flex items-center justify-center gap-2 h-9 px-4 rounded-lg border border-transparent bg-brand-600 hover:bg-brand-500 text-white text-[13px] font-medium leading-none transition-colors",children:[e.jsx(Me,{size:15}),"New Test Case"]}),e.jsxs("button",{onClick:()=>j(!0),className:"inline-flex items-center justify-center gap-2 h-9 px-4 rounded-lg border border-white/10 text-gray-300 hover:text-gray-100 hover:border-white/20 hover:bg-white/[0.03] text-[13px] font-medium leading-none transition-colors",title:"Import test cases from a file or another tool, or export this catalogue",children:[e.jsx(et,{size:15}),"Import / Export"]})]})]})})}),e.jsxs("div",{className:"flex-1 flex min-h-0",children:[e.jsxs("div",{className:"w-72 flex-shrink-0 border-r border-white/5 flex flex-col bg-surface-0",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-white/5",children:[e.jsx("span",{className:"text-sm font-semibold text-gray-300 uppercase tracking-wider",children:"Folders"}),e.jsx("button",{onClick:()=>M(!V),className:"p-1.5 rounded-lg hover:bg-surface-2 text-gray-400 hover:text-brand-300 transition-colors",title:"Add folder",children:e.jsx(Js,{size:16})})]}),V&&e.jsx("div",{className:"px-3 py-2 border-b border-white/5",children:e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx("input",{className:"flex-1 bg-surface-2 border border-white/10 rounded-lg px-2.5 py-1.5 text-sm text-gray-200 outline-none focus:border-brand-500",placeholder:"Folder name...",value:_,onChange:a=>B(a.target.value),onKeyDown:a=>{a.key==="Enter"&&He(),a.key==="Escape"&&M(!1)},autoFocus:!0}),e.jsx("button",{onClick:He,disabled:!_.trim(),className:"p-1.5 rounded-lg bg-brand-600 hover:bg-brand-500 text-white disabled:opacity-40",children:e.jsx(pe,{size:14})})]})}),e.jsxs("div",{className:"flex-1 overflow-y-auto py-2 px-2 space-y-0.5",children:[e.jsxs("button",{onClick:()=>{b(null),F(1)},className:`w-full flex items-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors ${p===null?"bg-brand-500/15 text-brand-300":"text-gray-300 hover:bg-surface-2"}`,children:[e.jsx(qs,{size:15}),e.jsx("span",{className:"flex-1 text-left",children:"All Test Cases"}),e.jsx("span",{className:"text-xs text-gray-500",children:Ze})]}),Le?e.jsx("div",{className:"px-3 py-6 text-center text-sm text-gray-500",children:"Loading folders..."}):e.jsx(e.Fragment,{children:(te||[]).map(a=>e.jsx(zt,{node:a,depth:0,selectedFolderId:p,onSelect:R=>{b(R),F(1)},onEdit:()=>{},onDelete:Et},a.id))}),e.jsxs("button",{onClick:()=>{b("__uncategorized__"),F(1)},className:`w-full flex items-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors mt-1 ${p==="__uncategorized__"?"bg-brand-500/15 text-brand-300":"text-gray-400 hover:bg-surface-2"}`,children:[e.jsx(ve,{size:15,className:"text-gray-500"}),e.jsx("span",{className:"flex-1 text-left",children:"Uncategorized"}),e.jsx("span",{className:"text-xs text-gray-500",children:qt})]})]})]}),e.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[e.jsxs("div",{className:"flex-shrink-0 px-5 py-3 border-b border-white/5 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsxs("div",{className:"relative flex-1 min-w-[200px] max-w-md",children:[e.jsx($e,{size:15,className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-500"}),e.jsx("input",{className:"w-full bg-surface-1 border border-white/10 rounded-lg pl-9 pr-3 py-2 text-sm text-gray-200 outline-none focus:border-brand-500 transition-colors placeholder-gray-500",placeholder:"Search test cases...",value:v,onChange:a=>h(a.target.value)})]}),e.jsxs("select",{className:"bg-surface-1 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-300 outline-none focus:border-brand-500",value:f.priority||"",onChange:a=>fe("priority",a.target.value),children:[e.jsx("option",{value:"",children:"Priority"}),Nt.map(a=>e.jsx("option",{value:a,children:Z(a)},a))]}),e.jsxs("select",{className:"bg-surface-1 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-300 outline-none focus:border-brand-500",value:f.type||"",onChange:a=>fe("type",a.target.value),children:[e.jsx("option",{value:"",children:"Type"}),wt.map(a=>e.jsx("option",{value:a,children:Z(a)},a))]}),e.jsxs("select",{className:"bg-surface-1 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-300 outline-none focus:border-brand-500",value:f.status||"",onChange:a=>fe("status",a.target.value),children:[e.jsx("option",{value:"",children:"Status"}),kt.map(a=>e.jsx("option",{value:a,children:Z(a)},a))]}),e.jsxs("select",{className:"bg-surface-1 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-300 outline-none focus:border-brand-500",value:f.automationStatus||"",onChange:a=>fe("automationStatus",a.target.value),children:[e.jsx("option",{value:"",children:"Automation"}),St.map(a=>e.jsx("option",{value:a,children:Re[a]},a))]}),e.jsxs("select",{className:"bg-surface-1 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-300 outline-none focus:border-brand-500",value:f.reviewStatus||"",onChange:a=>fe("reviewStatus",a.target.value),children:[e.jsx("option",{value:"",children:"Review"}),Tt.map(a=>e.jsx("option",{value:a,children:De[a]},a))]}),e.jsx(ma,{tags:ie||[],selectedIds:N,onChange:a=>{i(a),F(1)}}),e.jsx(ua,{sources:z,selectedId:r,onChange:a=>{x(a),F(1)}}),ze>0&&e.jsxs("button",{onClick:Ot,className:"flex items-center gap-1 px-3 py-2 text-sm text-gray-400 hover:text-gray-200 transition-colors",children:[e.jsx(ee,{size:14}),"Clear (",ze,")"]})]}),m.size>0&&e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 bg-brand-500/10 rounded-lg border border-brand-500/20",children:[e.jsxs("span",{className:"text-sm font-medium text-brand-300",children:[m.size," selected"]}),e.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[e.jsxs("button",{onClick:()=>n(!0),className:"flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-lg bg-surface-2 hover:bg-surface-3 text-gray-300 border border-white/10 transition-colors",children:[e.jsx(Gs,{size:14}),"Move"]}),e.jsxs("button",{onClick:()=>k(!0),className:"flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-lg bg-surface-2 hover:bg-surface-3 text-gray-300 border border-white/10 transition-colors",children:[e.jsx(bt,{size:14}),"Tag"]}),e.jsxs("button",{onClick:()=>Te.mutate({ids:Array.from(m),reviewStatus:"approved"},{onError:a=>t("error",(a==null?void 0:a.message)||"Could not approve the test cases")}),disabled:Te.isPending,title:"Mark the selected test cases as approved",className:"flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-lg bg-surface-2 hover:bg-surface-3 text-emerald-300 border border-white/10 transition-colors disabled:opacity-50",children:[e.jsx(xe,{size:14}),"Approve"]}),e.jsxs("button",{onClick:()=>Te.mutate({ids:Array.from(m),reviewStatus:"rejected"},{onError:a=>t("error",(a==null?void 0:a.message)||"Could not reject the test cases")}),disabled:Te.isPending,title:"Mark the selected test cases as rejected — they are left out of quick plans",className:"flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-lg bg-surface-2 hover:bg-surface-3 text-amber-300 border border-white/10 transition-colors disabled:opacity-50",children:[e.jsx(ft,{size:14}),"Reject"]}),e.jsx(Ps,{ids:Array.from(m)}),e.jsxs("button",{onClick:It,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-lg bg-red-600/80 hover:bg-red-600 text-white transition-colors",children:[e.jsx(ue,{size:14}),"Delete"]}),e.jsx("button",{onClick:()=>I(new Set),className:"p-1.5 rounded-lg hover:bg-white/10 text-gray-400 hover:text-gray-200",children:e.jsx(ee,{size:14})})]})]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[q?e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"w-8 h-8 border-2 border-brand-500 border-t-transparent rounded-full animate-spin mx-auto mb-3"}),e.jsx("p",{className:"text-sm text-gray-400",children:"Loading test cases..."})]})}):H.length===0?e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsxs("div",{className:"text-center",children:[e.jsx(ce,{size:40,className:"mx-auto mb-3 text-gray-600"}),e.jsx("h3",{className:"text-base font-medium text-gray-300 mb-1",children:"No test cases found"}),e.jsx("p",{className:"text-sm text-gray-500 mb-4",children:ze>0?"Try adjusting your filters":"Create your first test case to get started"}),ze===0&&e.jsxs("button",{onClick:()=>{A(null),G(!0)},className:"inline-flex items-center gap-2 px-4 py-2 rounded-lg bg-brand-600 hover:bg-brand-500 text-white text-sm font-medium transition-colors",children:[e.jsx(Me,{size:15}),"New Test Case"]})]})}):e.jsxs("div",{className:"rounded-xl border border-white/10 overflow-hidden bg-surface-1 shadow-sm",children:[e.jsxs("div",{className:"grid grid-cols-[40px_1fr_90px_100px_80px_105px_90px_130px_90px] bg-surface-2/80 border-b border-white/10",children:[e.jsx("div",{className:"px-3 py-3 flex items-center justify-center",children:e.jsx("button",{onClick:Bt,role:"checkbox","aria-checked":m.size===H.length&&H.length>0,"aria-label":"Select all test cases on this page",className:"text-gray-400 hover:text-gray-200",children:m.size===H.length&&H.length>0?e.jsx(tt,{size:15,className:"text-brand-500"}):e.jsx(st,{size:15})})}),e.jsx("div",{className:"px-3 py-3",children:e.jsxs("button",{onClick:()=>Ut("title"),className:"flex items-center gap-1.5 text-[11px] font-semibold text-gray-400 uppercase tracking-wider hover:text-gray-200 transition-colors",children:["Test Case",e.jsx(Vs,{size:11,className:"opacity-60"})]})}),e.jsx("div",{className:"px-3 py-3",children:e.jsx("span",{className:"text-[11px] font-semibold text-gray-400 uppercase tracking-wider",children:"Priority"})}),e.jsx("div",{className:"px-3 py-3",children:e.jsx("span",{className:"text-[11px] font-semibold text-gray-400 uppercase tracking-wider",children:"Type"})}),e.jsx("div",{className:"px-3 py-3",children:e.jsx("span",{className:"text-[11px] font-semibold text-gray-400 uppercase tracking-wider",children:"Status"})}),e.jsx("div",{className:"px-3 py-3",children:e.jsx("span",{className:"text-[11px] font-semibold text-gray-400 uppercase tracking-wider",children:"Automation"})}),e.jsx("div",{className:"px-3 py-3",children:e.jsx("span",{className:"text-[11px] font-semibold text-gray-400 uppercase tracking-wider",children:"Review"})}),e.jsx("div",{className:"px-3 py-3",children:e.jsx("span",{className:"text-[11px] font-semibold text-gray-400 uppercase tracking-wider",children:"Executions"})}),e.jsx("div",{className:"px-3 py-3 text-center",children:e.jsx("span",{className:"text-[11px] font-semibold text-gray-400 uppercase tracking-wider",children:"Actions"})})]}),H.map((a,R)=>{var de;const $=m.has(a.id);return e.jsxs("div",{className:`grid grid-cols-[40px_1fr_90px_100px_80px_105px_90px_130px_90px] border-b border-white/5 last:border-b-0 transition-all group ${$?"bg-brand-500/10 border-l-2 border-l-brand-500":R%2===0?"bg-surface-1 hover:bg-white/[0.02]":"bg-surface-2/30 hover:bg-white/[0.04]"}`,children:[e.jsx("div",{className:"px-3 py-3.5 flex items-center justify-center",children:e.jsx("button",{onClick:()=>Pt(a.id),role:"checkbox","aria-checked":$,"aria-label":`Select ${a.title||a.id}`,className:"text-gray-400 hover:text-gray-200 transition-colors",children:$?e.jsx(tt,{size:15,className:"text-brand-500"}):e.jsx(st,{size:15,className:"group-hover:text-gray-300"})})}),e.jsxs("div",{className:"px-3 py-3.5 min-w-0",children:[e.jsx("button",{onClick:()=>P({tcId:a.id,detail:null}),className:"text-sm text-gray-200 hover:text-brand-300 transition-colors text-left font-medium leading-snug line-clamp-2 w-full",children:a.title}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[a.id&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] text-gray-500 font-mono",children:[e.jsx(yt,{size:10,className:"flex-shrink-0"}),a.id]}),e.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] text-gray-500",children:[e.jsx(ve,{size:10,className:"flex-shrink-0"}),((de=a.folder)==null?void 0:de.name)||"Uncategorized"]}),a.steps&&a.steps.length>0&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] text-gray-500",children:[e.jsx(ce,{size:10,className:"flex-shrink-0"}),a.steps.length," step",a.steps.length!==1?"s":""]})]})]}),e.jsx("div",{className:"px-3 py-3.5 flex items-center",children:e.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-md text-[11px] font-semibold ${a.priority==="critical"?"bg-red-500/20 text-red-300":a.priority==="high"?"bg-orange-500/20 text-orange-300":a.priority==="medium"?"bg-amber-500/20 text-amber-300":"bg-emerald-500/20 text-emerald-300"}`,children:Z(a.priority||"medium")})}),e.jsx("div",{className:"px-3 py-3.5 flex items-center",children:e.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-md text-[11px] font-semibold ${Oe[a.type]||"bg-gray-500/20 text-gray-300"}`,children:Z(a.type||"web")})}),e.jsx("div",{className:"px-3 py-3.5 flex items-center",children:e.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-md text-[11px] font-semibold ${a.status==="active"?"bg-brand-500/20 text-brand-300":a.status==="draft"?"bg-gray-500/20 text-gray-300":a.status==="deprecated"?"bg-red-500/20 text-red-300":"bg-slate-500/20 text-slate-400"}`,children:Z(a.status||"draft")})}),e.jsx("div",{className:"px-3 py-3.5 flex items-center",children:e.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-md text-[11px] font-semibold ${a.automationStatus==="automated"?"bg-emerald-500/20 text-emerald-300":a.automationStatus==="needs_update"?"bg-amber-500/20 text-amber-300":"bg-gray-500/20 text-gray-400"}`,children:[e.jsx(Be,{size:10}),Re[a.automationStatus]||"Manual"]})}),e.jsxs("div",{className:"px-3 py-3.5 flex flex-col items-start justify-center gap-1",children:[a.staleAt?e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-md text-[11px] font-semibold bg-amber-500/20 text-amber-300",title:a.staleReason||"The requirement this case was written from changed",children:[e.jsx(me,{size:10}),"Source changed"]}):null,e.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-md text-[11px] font-semibold ${a.reviewStatus==="approved"?"bg-emerald-500/20 text-emerald-300":a.reviewStatus==="rejected"?"bg-red-500/20 text-red-300":a.reviewStatus==="in_review"?"bg-sky-500/20 text-sky-300":"bg-gray-500/20 text-gray-400"}`,children:De[a.reviewStatus]||"Draft"})]}),e.jsx("div",{className:"px-3 py-3.5 flex items-center",children:(()=>{const ye=C[a.id];if(!ye||ye.length===0)return e.jsx("span",{className:"text-[10px] text-gray-600 italic",children:"No runs"});const Gt=[...ye].reverse().slice(-5),Xe={passed:"bg-emerald-300/70",failed:"bg-rose-300/70",blocked:"bg-amber-300/70",skipped:"bg-slate-300/60",in_progress:"bg-sky-300/70",not_run:"bg-gray-400/40"};return e.jsx("div",{className:"flex items-center gap-1.5",title:`${ye.length} execution${ye.length!==1?"s":""}`,children:Gt.map((oe,Vt)=>e.jsxs("div",{className:"relative group/dot",children:[e.jsx("div",{className:`w-2.5 h-2.5 rounded-full ${Xe[oe.status]||Xe.not_run} transition-transform hover:scale-150`}),e.jsx("div",{className:"absolute bottom-full left-1/2 -translate-x-1/2 mb-2 hidden group-hover/dot:block z-50 pointer-events-none",children:e.jsxs("div",{className:"bg-surface-2 text-gray-200 text-[10px] rounded-lg px-2.5 py-1.5 whitespace-nowrap shadow-xl border border-white/10",children:[e.jsx("div",{className:"font-medium capitalize",children:oe.status.replace("_"," ")}),e.jsxs("div",{className:"text-gray-400",children:[oe.planName," > ",oe.cycleName]}),oe.executedAt&&e.jsx("div",{className:"text-gray-500",children:mt(oe.executedAt)})]})})]},Vt))})})()}),e.jsx("div",{className:"px-3 py-3.5 flex items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-0.5 opacity-40 group-hover:opacity-100 transition-opacity",children:[e.jsx("button",{onClick:()=>P({tcId:a.id,detail:null}),className:"p-1.5 rounded-lg hover:bg-brand-500/10 text-gray-400 hover:text-brand-300 transition-colors",title:"View details",children:e.jsx(Ue,{size:14})}),e.jsx("button",{onClick:()=>{A(a),G(!0)},className:"p-1.5 rounded-lg hover:bg-white/10 text-gray-400 hover:text-gray-200 transition-colors",title:"Edit",children:e.jsx(Ee,{size:14})}),e.jsx("button",{onClick:()=>Lt(a.id),className:"p-1.5 rounded-lg hover:bg-red-500/10 text-gray-400 hover:text-red-400 transition-colors",title:"Delete",children:e.jsx(ue,{size:14})})]})})]},a.id)}),e.jsxs("div",{className:"bg-surface-2/50 px-4 py-2 border-t border-white/10 flex items-center justify-between",children:[e.jsxs("span",{className:"text-[11px] text-gray-500",children:[H.length," test case",H.length!==1?"s":""," on this page"]}),m.size>0&&e.jsxs("span",{className:"text-[11px] text-brand-300 font-medium",children:[m.size," selected"]})]})]}),re>1&&e.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-t border-white/5",children:[e.jsxs("span",{className:"text-sm text-gray-400",children:["Showing ",(E-1)*Ce+1,"-",Math.min(E*Ce,ae)," of ",ae]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:()=>F(a=>Math.max(1,a-1)),disabled:E<=1,className:"px-3 py-1.5 text-sm rounded-lg bg-surface-1 hover:bg-surface-2 text-gray-300 border border-white/10 disabled:opacity-40 transition-colors",children:"Previous"}),Array.from({length:Math.min(re,7)},(a,R)=>{let $;return re<=7||E<=4?$=R+1:E>=re-3?$=re-6+R:$=E-3+R,e.jsx("button",{onClick:()=>F($),className:`w-8 h-8 text-sm rounded-lg transition-colors ${E===$?"bg-brand-600 text-white":"hover:bg-surface-2 text-gray-400"}`,children:$},$)}),e.jsx("button",{onClick:()=>F(a=>Math.min(re,a+1)),disabled:E>=re,className:"px-3 py-1.5 text-sm rounded-lg bg-surface-1 hover:bg-surface-2 text-gray-300 border border-white/10 disabled:opacity-40 transition-colors",children:"Next"})]})]})]})]})]}),d&&Kt.createPortal(e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 overflow-y-auto",children:[e.jsx("div",{className:"absolute inset-0 bg-black/60",onClick:()=>j(!1)}),e.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Import and export test cases",className:"relative bg-surface-1 rounded-2xl border border-white/10 w-[1320px] max-w-[96vw] max-h-[92vh] flex flex-col animate-fade-in",children:[e.jsxs("div",{className:"flex items-center gap-3 px-6 py-4 border-b border-white/5 flex-shrink-0",children:[e.jsx(et,{size:18,className:"text-brand-300"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h2",{className:"text-base font-semibold text-gray-100",children:"Import / Export"}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"Move test cases in from a file or another tool, or take this catalogue out."})]}),e.jsx("button",{onClick:()=>j(!1),className:"p-1.5 rounded-lg text-gray-500 hover:text-gray-200 hover:bg-white/5 transition-colors","aria-label":"Close",children:e.jsx(ee,{size:18})})]}),e.jsx("div",{className:"flex-1 overflow-y-auto px-6 py-5",children:e.jsx(Zt,{embedded:!0})})]})]}),document.body),D&&e.jsx(ra,{testCase:U,folders:te||[],tags:ie||[],onClose:()=>{G(!1),A(null)},onSaved:()=>{y(U?"Test case updated successfully":"Test case created successfully")},currentUserName:g}),Ke&&e.jsx(da,{testCase:Ke,onClose:()=>P({tcId:null,detail:null}),onEdit:a=>{P({tcId:null,detail:null}),A(a),G(!0)},currentUserName:g,onToast:y}),se&&e.jsx(xa,{title:se.title,message:se.message,confirmLabel:se.confirmLabel,onConfirm:se.onConfirm,onCancel:()=>X(null)}),Y&&e.jsx(oa,{folders:te||[],count:m.size,onMove:_t,onClose:()=>n(!1)}),w&&e.jsx(ca,{tags:ie||[],count:m.size,onApply:Ft,onClose:()=>k(!1)})]})}function pa({testCaseId:t,onLinked:y}){const{connectorId:u,isConfigured:g,baseUrl:p}=gt(),b=Ls(),v=pt(),[h,d]=o.useState(!1),[j,f]=o.useState(""),[c,N]=o.useState([]);if(!g)return null;const i=()=>{if(!u||!j.trim())return;const T=/^[A-Z][A-Z0-9]+-\d+$/i.test(j.trim())?`key = "${j.trim()}"`:`summary ~ "${j.trim()}" ORDER BY updated DESC`;b.mutate({connectorId:u,jql:T,maxResults:10},{onSuccess:z=>N((z==null?void 0:z.issues)||[])})},r=x=>{var m;const T=x.key,z=((m=x.fields)==null?void 0:m.summary)||"";v.mutate({testCaseId:t,data:{title:`${T}: ${z}`,url:_s(p,T),linkType:"jira"}},{onSuccess:()=>{d(!1),f(""),N([]),y()}})};return e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>d(!h),className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-lg bg-blue-500/10 hover:bg-blue-500/20 text-blue-400 border border-blue-500/20 transition-colors",children:[e.jsx(Ae,{size:12})," Link JIRA"]}),h&&e.jsxs("div",{className:"fixed inset-0 z-[60] flex items-center justify-center",children:[e.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:()=>d(!1)}),e.jsxs("div",{className:"relative z-10 bg-surface-1 rounded-xl border border-white/10 shadow-2xl w-full max-w-lg mx-4",children:[e.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-b border-white/5",children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-100",children:"Link JIRA Issue"}),e.jsx("button",{onClick:()=>d(!1),className:"text-gray-400 hover:text-gray-200",children:e.jsx(ee,{size:16})})]}),e.jsxs("div",{className:"p-5 space-y-3",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:j,onChange:x=>f(x.target.value),onKeyDown:x=>x.key==="Enter"&&i(),placeholder:"Search by JIRA key or text...",className:"flex-1 bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 outline-none focus:border-brand-500"}),e.jsx("button",{onClick:i,disabled:b.isPending,className:"px-4 py-2 text-sm font-medium text-white bg-blue-600 hover:bg-blue-500 rounded-lg disabled:opacity-50",children:b.isPending?e.jsx(vt,{size:14,className:"animate-spin"}):e.jsx($e,{size:14})})]}),c.length>0&&e.jsx("div",{className:"max-h-[300px] overflow-y-auto divide-y divide-white/5 border border-white/5 rounded-lg",children:c.map(x=>{var T,z,m;return e.jsxs("button",{onClick:()=>r(x),className:"w-full text-left px-4 py-3 hover:bg-brand-500/10 transition-colors flex items-center gap-3",children:[e.jsx("span",{className:"text-xs font-mono text-blue-400 shrink-0",children:x.key}),e.jsx("span",{className:"text-sm text-gray-200 truncate flex-1",children:(T=x.fields)==null?void 0:T.summary}),e.jsx("span",{className:"text-[10px] text-gray-500 shrink-0",children:(m=(z=x.fields)==null?void 0:z.status)==null?void 0:m.name})]},x.key)})}),b.isSuccess&&c.length===0&&e.jsx("p",{className:"text-xs text-gray-500 text-center py-4",children:"No issues found"})]})]})]})]})}function ha({id:t,reason:y}){const u=Bs(),{toast:g}=ht(),[p,b]=o.useState(!1);return e.jsxs("div",{className:"flex items-start gap-3 rounded-lg border border-amber-500/30 bg-amber-500/10 p-3",role:"status",children:[e.jsx(me,{size:16,className:"text-amber-300 shrink-0 mt-0.5"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-sm font-medium text-amber-200",children:"The requirement this case was written from changed"}),y?e.jsx("p",{className:"text-xs text-gray-300 mt-1 leading-relaxed break-words",children:y}):null,e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"Update the case to match, then mark it reviewed — or regenerate the changed requirements in AI Test Gen."})]}),e.jsx("button",{disabled:p,onClick:async()=>{b(!0);try{await $s([t]),u.invalidateQueries({queryKey:["tm-test-cases"]}),u.invalidateQueries({queryKey:["tm-test-case",t]}),u.invalidateQueries({queryKey:["tm-sources"]})}catch(v){g("error",(v==null?void 0:v.message)||"Could not mark the case reviewed")}finally{b(!1)}},className:"shrink-0 px-3 py-1.5 text-xs rounded-lg bg-surface-2 hover:bg-surface-3 text-gray-200 border border-white/10 disabled:opacity-50",children:"Mark reviewed"})]})}function ga({jiraUrl:t,testCaseTitle:y}){const{connectorId:u}=gt(),g=Is(),[p,b]=o.useState(!1);if(!u)return null;const v=t.match(/\/browse\/([A-Z][A-Z0-9]+-\d+)/i),h=v?v[1]:null;if(!h)return null;const d=()=>{const j=`🧪 Testver Test Case Update
5
-
6
- Test Case: ${y}
7
- Status: Linked in Testver
8
- Date: ${Je(new Date)}
9
-
10
- This test case is being tracked in Testver Test Management.`;g.mutate({connectorId:u,issueKey:h,comment:j},{onSuccess:()=>b(!0)})};return e.jsx("button",{onClick:d,disabled:g.isPending||p,className:`p-1.5 rounded-lg hover:bg-white/10 transition-colors ${p?"text-emerald-400":"text-gray-400 hover:text-blue-400"}`,title:p?"Comment posted to JIRA":"Post update to JIRA",children:g.isPending?e.jsx(vt,{size:14,className:"animate-spin"}):p?e.jsx(xe,{size:14}):e.jsx(Ys,{size:14})})}export{ua as SourceSingleSelectFilter,ma as TagMultiSelectFilter,$a as TestManagementPage};
1
+ import{r as o,j as e,d as Vt,u as Ht}from"./vendor-react-DOVfxdUy.js";import{a as mt,f as Je}from"./formatDate-T65-Y6Mi.js";import{ImportExportPage as Zt}from"./ImportExportPage-BcjzRd7T.js";import{a as Qt,b as Wt,u as Yt}from"./useTabParam-CyYAP90W.js";import{u as Xt}from"./useDebouncedValue-C9odz7b2.js";import{f as es}from"./formatTestName-BKd2Uqhs.js";import{E as ts,J as ss,K as as,L as rs,D as ns,M as ls,N as is,F as ds,O as os,P as cs,Q as xs,R as ms,S as us,T as ps,U as hs,V as gs,W as bs,X as fs,Y as ys,Z as js,_ as ut,$ as vs,a0 as Ns,a1 as ws,a2 as ks,a3 as Ss,a4 as Ts,a5 as zs,a6 as Cs,a7 as pt,a8 as As,a9 as Ms}from"./useTestManagement-ommXjx0q.js";import{E as Rs}from"./ExportButton-xrS_AnfS.js";import{b as ht,ae as Ds,gJ as $s,x as Es}from"./index-BlA8ntjb.js";import{u as gt,b as Ls,a as Is,c as _s}from"./useJiraConnector--JZhbYrT.js";import{h as Fs}from"./aiHandoff-vhtR29Fh.js";import{J as Ps}from"./JiraPushDialog-DNYU9Ce0.js";import{a as Bs}from"./vendor-query-DkZSMtfn.js";import{B as Us,X as ee,z as ne,w as $e,ah as pe,bu as bt,d as ce,j as Pe,Z as Be,p as me,n as Os,b5 as Me,dj as et,c1 as Js,e as qs,aN as ve,bw as Gs,s as xe,aq as ft,b8 as ue,bM as tt,b9 as st,cf as Ks,aK as yt,ab as Ue,bc as Ee,u as qe,F as Vs,b1 as Hs,a3 as at,bk as rt,f as nt,a$ as jt,G as _e,v as Fe,be as Zs,a6 as Qs,$ as Ae,am as je,at as Ws,g as lt,ai as it,S as dt,a1 as vt,a7 as Ys,ao as ot,b2 as Xs,C as ea,aT as ta,dk as sa,cA as aa}from"./vendor-icons-Cm92aSc5.js";import"./excel-BrxuVus5.js";import"./vendor-excel-BFHGVHVC.js";const Nt=["critical","high","medium","low"],wt=["web","ui","api","mobile","database","integration","e2e","security","performance","usability","accessibility","compatibility","localization"],kt=["draft","active","deprecated","archived"],St=["manual","automated","needs_update"],Tt=["draft","in_review","approved","rejected"],Ce=20,ct={critical:"bg-red-500/20 text-red-300",high:"bg-orange-500/20 text-orange-300",medium:"bg-amber-500/20 text-amber-300",low:"bg-emerald-500/20 text-emerald-300"},Oe={web:"bg-sky-500/20 text-sky-300",ui:"bg-indigo-500/20 text-indigo-300",api:"bg-cyan-500/20 text-cyan-300",mobile:"bg-violet-500/20 text-violet-300",database:"bg-teal-500/20 text-teal-300",integration:"bg-emerald-500/20 text-emerald-300",e2e:"bg-blue-500/20 text-blue-300",security:"bg-red-500/20 text-red-300",performance:"bg-rose-500/20 text-rose-300",usability:"bg-amber-500/20 text-amber-300",accessibility:"bg-fuchsia-500/20 text-fuchsia-300",compatibility:"bg-purple-500/20 text-purple-300",localization:"bg-orange-500/20 text-orange-300"},xt={draft:"bg-gray-500/20 text-gray-300",active:"bg-brand-500/20 text-brand-300",deprecated:"bg-red-500/20 text-red-300",archived:"bg-slate-500/20 text-slate-400"},Re={manual:"Manual",automated:"Automated",needs_update:"Needs Update"},De={draft:"Draft",in_review:"In Review",approved:"Approved",rejected:"Rejected"};function Z(t){const y={api:"API",ui:"UI",e2e:"E2E"};return y[t]?y[t]:t.replace(/_/g," ").replace(/\b\w/g,u=>u.toUpperCase())}function zt({node:t,depth:y,selectedFolderId:u,onSelect:g,onEdit:p,onDelete:b}){const[v,h]=o.useState(!0),[d,j]=o.useState(!1),[f,c]=o.useState(t.name),[N,i]=o.useState(!1),r=t.children&&t.children.length>0,x=u===t.id,T=hs(),z=()=>{f.trim()&&f!==t.name&&T.mutate({id:t.id,data:{name:f.trim()}}),j(!1)};return e.jsxs("div",{children:[e.jsxs("div",{className:`group flex items-center gap-1 px-2 py-1.5 rounded-lg cursor-pointer transition-colors text-sm ${x?"bg-brand-500/15 text-brand-300":"text-gray-300 hover:bg-surface-2"}`,style:{paddingLeft:`${y*16+8}px`},onClick:()=>g(t.id),onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),children:[r?e.jsx("button",{onClick:m=>{m.stopPropagation(),h(!v)},className:"p-0.5 hover:bg-white/10 rounded",children:v?e.jsx(ne,{size:14}):e.jsx(qe,{size:14})}):e.jsx("span",{className:"w-5"}),v&&r?e.jsx(Vs,{size:15,className:"text-brand-400 flex-shrink-0"}):e.jsx(ve,{size:15,className:"text-gray-500 flex-shrink-0"}),d?e.jsx("input",{className:"flex-1 bg-surface-2 border border-white/10 rounded px-1.5 py-0.5 text-sm text-gray-200 outline-none focus:border-brand-500",value:f,onChange:m=>c(m.target.value),onBlur:z,onKeyDown:m=>{m.key==="Enter"&&z(),m.key==="Escape"&&j(!1)},onClick:m=>m.stopPropagation(),autoFocus:!0}):e.jsx("span",{className:"flex-1 truncate",children:t.name}),e.jsx("span",{className:"text-xs text-gray-500 mr-1",children:t.testCaseCount??0}),N&&!d&&e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx("button",{onClick:m=>{m.stopPropagation(),c(t.name),j(!0)},className:"p-1 rounded hover:bg-white/10 text-gray-400 hover:text-gray-200",children:e.jsx(Ee,{size:12})}),e.jsx("button",{onClick:m=>{m.stopPropagation(),b(t.id)},className:"p-1 rounded hover:bg-white/10 text-gray-400 hover:text-red-400",children:e.jsx(ue,{size:12})})]})]}),v&&r&&e.jsx("div",{children:t.children.map(m=>e.jsx(zt,{node:m,depth:y+1,selectedFolderId:u,onSelect:g,onEdit:p,onDelete:b},m.id))})]})}function ra({testCase:t,folders:y,tags:u,onClose:g,onSaved:p,currentUserName:b}){var F,Y;const v=!!(t!=null&&t.id),h=gs(),d=bs(),j=fs(),f=ys(),c=js(),{data:N}=ut(t==null?void 0:t.id),[i,r]=o.useState({title:(t==null?void 0:t.title)||"",preconditions:(t==null?void 0:t.preconditions)||"",priority:(t==null?void 0:t.priority)||"medium",type:(t==null?void 0:t.type)||"web",status:(t==null?void 0:t.status)||"draft",automationStatus:(t==null?void 0:t.automationStatus)||"manual",reviewStatus:(t==null?void 0:t.reviewStatus)||"draft",folderId:(t==null?void 0:t.folderId)||"",estimatedDuration:(t==null?void 0:t.estimatedDuration)||""}),[x,T]=o.useState((F=t==null?void 0:t.steps)!=null&&F.length?t.steps.map(n=>({id:n.id,action:n.action||"",expectedResult:n.expectedResult||"",testData:n.testData||""})):[{action:"",expectedResult:"",testData:""}]),[z,m]=o.useState(new Set(((Y=t==null?void 0:t.tags)==null?void 0:Y.map(n=>n.id))||[])),[I,D]=o.useState(""),[G,U]=o.useState(!1);o.useEffect(()=>{const n=(N==null?void 0:N.steps)||[];n.length>0&&v&&T(n.map(w=>({id:w.id,action:w.action||"",expectedResult:w.expectedResult||"",testData:w.testData||""})))},[N,v]);const A=o.useCallback((n,w=0)=>{const k=[];for(const S of n)k.push({id:S.id,name:S.name,depth:w}),S.children&&k.push(...A(S.children,w+1));return k},[]),l=o.useMemo(()=>A(y||[]),[y,A]),P=()=>T([...x,{action:"",expectedResult:"",testData:""}]),K=n=>{x.length>1&&T(x.filter((w,k)=>k!==n))},M=(n,w,k)=>{T(x.map((S,V)=>V===n?{...S,[w]:k}:S))},_=n=>{const w=new Set(z);w.has(n)?w.delete(n):w.add(n),m(w)},B=async()=>{if(!I.trim())return;const n=["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6","#ec4899","#06b6d4","#84cc16"],w=n[Math.floor(Math.random()*n.length)];try{const k=await c.mutateAsync({name:I.trim(),color:w});k!=null&&k.id&&m(S=>new Set([...S,k.id])),D("")}catch{}},E=async()=>{var n;if(i.title.trim()){U(!0);try{const w={title:i.title.trim(),preconditions:i.preconditions,priority:i.priority,type:i.type,status:i.status,automationStatus:i.automationStatus,reviewStatus:i.reviewStatus,folderId:i.folderId||null,estimatedDuration:i.estimatedDuration?parseInt(i.estimatedDuration,10):null};let k;if(v)await d.mutateAsync({id:t.id,data:{...w,changedBy:b||""}}),k=t.id;else{const S=await h.mutateAsync({...w,createdBy:b||""});k=(S==null?void 0:S.id)||((n=S==null?void 0:S.testCase)==null?void 0:n.id)}if(k){const S=x.filter(V=>V.action.trim());S.length>0&&await j.mutateAsync({testCaseId:k,steps:S.map((V,le)=>({stepNumber:le+1,action:V.action,expectedResult:V.expectedResult,testData:V.testData}))}),z.size>0&&await f.mutateAsync({testCaseId:k,tagIds:Array.from(z)})}p(),g()}catch(w){console.error("Failed to save test case:",w)}finally{U(!1)}}};return e.jsxs("div",{className:"fixed inset-0 z-50 flex items-start justify-center overflow-y-auto",children:[e.jsx("div",{className:"absolute inset-0 bg-black/70",onClick:g}),e.jsxs("div",{className:"relative bg-surface-1 rounded-xl border border-white/10 w-full max-w-3xl my-8 mx-4 animate-fade-in",children:[e.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-white/5",children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-100",children:v?"Edit Test Case":"Create Test Case"}),e.jsx("button",{onClick:g,className:"p-1.5 rounded-lg hover:bg-surface-2 text-gray-400 hover:text-gray-200",children:e.jsx(ee,{size:18})})]}),e.jsxs("div",{className:"px-6 py-5 space-y-5 max-h-[calc(100vh-200px)] overflow-y-auto",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-1.5",children:"Title *"}),e.jsx("input",{className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 outline-none focus:border-brand-500 transition-colors",value:i.title,onChange:n=>r({...i,title:n.target.value}),placeholder:"Enter test case title..."})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-1.5",children:"Preconditions"}),e.jsx("textarea",{className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 outline-none focus:border-brand-500 transition-colors resize-none",rows:3,value:i.preconditions,onChange:n=>r({...i,preconditions:n.target.value}),placeholder:"Any preconditions or setup steps..."})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-1.5",children:"Priority"}),e.jsx("select",{className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 outline-none focus:border-brand-500",value:i.priority,onChange:n=>r({...i,priority:n.target.value}),children:Nt.map(n=>e.jsx("option",{value:n,children:Z(n)},n))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-1.5",children:"Type"}),e.jsx("select",{className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 outline-none focus:border-brand-500",value:i.type,onChange:n=>r({...i,type:n.target.value}),children:wt.map(n=>e.jsx("option",{value:n,children:Z(n)},n))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-1.5",children:"Status"}),e.jsx("select",{className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 outline-none focus:border-brand-500",value:i.status,onChange:n=>r({...i,status:n.target.value}),children:kt.map(n=>e.jsx("option",{value:n,children:Z(n)},n))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-1.5",children:"Automation Status"}),e.jsx("select",{className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 outline-none focus:border-brand-500",value:i.automationStatus,onChange:n=>r({...i,automationStatus:n.target.value}),children:St.map(n=>e.jsx("option",{value:n,children:Re[n]},n))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-1.5",children:"Review Status"}),e.jsx("select",{className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 outline-none focus:border-brand-500",value:i.reviewStatus,onChange:n=>r({...i,reviewStatus:n.target.value}),children:Tt.map(n=>e.jsx("option",{value:n,children:De[n]},n))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-1.5",children:"Folder"}),e.jsxs("select",{className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 outline-none focus:border-brand-500",value:i.folderId,onChange:n=>r({...i,folderId:n.target.value}),children:[e.jsx("option",{value:"",children:"No Folder (Uncategorized)"}),l.map(n=>e.jsxs("option",{value:n.id,children:[" ".repeat(n.depth),n.name]},n.id))]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-1.5",children:"Estimated Duration (minutes)"}),e.jsx("input",{type:"number",className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 outline-none focus:border-brand-500",value:i.estimatedDuration,onChange:n=>r({...i,estimatedDuration:n.target.value}),placeholder:"e.g. 15",min:0})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("label",{className:"text-sm font-medium text-gray-300",children:"Test Steps"}),e.jsxs("button",{onClick:P,className:"flex items-center gap-1 text-xs text-brand-400 hover:text-brand-300 transition-colors",children:[e.jsx(Me,{size:14}),"Add Step"]})]}),e.jsx("div",{className:"space-y-3",children:x.map((n,w)=>e.jsxs("div",{className:"bg-surface-2 rounded-lg border border-white/5 p-3",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("span",{className:"text-xs font-medium text-gray-400",children:["Step ",w+1]}),x.length>1&&e.jsx("button",{onClick:()=>K(w),className:"p-1 rounded hover:bg-white/10 text-gray-500 hover:text-red-400",children:e.jsx(ue,{size:13})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("textarea",{className:"w-full bg-surface-1 border border-white/10 rounded px-2.5 py-1.5 text-sm text-gray-200 placeholder-gray-500 outline-none focus:border-brand-500 resize-none",rows:2,value:n.action,onChange:k=>M(w,"action",k.target.value),placeholder:"Action / Step description..."}),e.jsx("textarea",{className:"w-full bg-surface-1 border border-white/10 rounded px-2.5 py-1.5 text-sm text-gray-200 placeholder-gray-500 outline-none focus:border-brand-500 resize-none",rows:2,value:n.expectedResult,onChange:k=>M(w,"expectedResult",k.target.value),placeholder:"Expected result..."}),e.jsx("input",{className:"w-full bg-surface-1 border border-white/10 rounded px-2.5 py-1.5 text-sm text-gray-200 placeholder-gray-500 outline-none focus:border-brand-500",value:n.testData,onChange:k=>M(w,"testData",k.target.value),placeholder:"Test data (optional)..."})]})]},w))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-2",children:"Tags"}),e.jsx("div",{className:"flex flex-wrap gap-2 mb-2",children:u==null?void 0:u.map(n=>e.jsxs("button",{onClick:()=>_(n.id),className:`inline-flex items-center gap-1 px-2.5 py-1 rounded-full text-xs font-medium transition-colors border ${z.has(n.id)?"border-brand-500 bg-brand-500/20 text-brand-300":"border-white/10 bg-surface-2 text-gray-400 hover:text-gray-300"}`,children:[z.has(n.id)&&e.jsx(pe,{size:12}),n.name]},n.id))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{className:"flex-1 bg-surface-2 border border-white/10 rounded-lg px-3 py-1.5 text-sm text-gray-200 outline-none focus:border-brand-500",placeholder:"Create new tag...",value:I,onChange:n=>D(n.target.value),onKeyDown:n=>{n.key==="Enter"&&B()}}),e.jsx("button",{onClick:B,disabled:!I.trim(),className:"px-3 py-1.5 text-sm rounded-lg bg-surface-2 hover:bg-surface-3 text-gray-300 border border-white/10 disabled:opacity-40",children:"Add"})]})]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 px-6 py-4 border-t border-white/5",children:[e.jsx("button",{onClick:g,className:"px-4 py-2 text-sm rounded-lg bg-surface-2 hover:bg-surface-3 text-gray-300 transition-colors",children:"Cancel"}),e.jsxs("button",{onClick:E,disabled:G||!i.title.trim(),className:"flex items-center gap-2 px-5 py-2 text-sm rounded-lg bg-brand-600 hover:bg-brand-500 text-white font-medium transition-colors disabled:opacity-50",children:[e.jsx(Hs,{size:15}),G?"Saving...":v?"Update":"Create"]})]})]})]})}function na({testCase:t,versions:y,onToast:u,currentUserName:g}){const[p,b]=o.useState(null),[v,h]=o.useState(null),d=Ms();if(!y||y.length===0)return e.jsxs("div",{className:"text-center py-8 text-gray-500 text-sm",children:[e.jsx(jt,{size:24,className:"mx-auto mb-2 opacity-50"}),"No version history available"]});const j=y.map(i=>{let r={};try{r=JSON.parse(i.snapshot)}catch{}return{...i,snap:r}});function f(i,r){const x=[],T=[{key:"title",label:"Title"},{key:"preconditions",label:"Preconditions"},{key:"priority",label:"Priority"},{key:"type",label:"Type"},{key:"status",label:"Status"},{key:"automationStatus",label:"Automation Status"},{key:"reviewStatus",label:"Review Status"},{key:"estimatedDuration",label:"Duration (min)"}];for(const l of T){const P=String(i[l.key]??""),K=String(r[l.key]??"");P!==K&&x.push({field:l.label,from:P||"(empty)",to:K||"(empty)"})}const z=(i.tags||[]).map(l=>l.name||l.id).sort().join(", "),m=(r.tags||[]).map(l=>l.name||l.id).sort().join(", ");z!==m&&x.push({field:"Tags",from:z||"(none)",to:m||"(none)"});const I=i.steps||[],D=r.steps||[],G=Math.max(I.length,D.length),U=[];let A=!1;for(let l=0;l<G;l++){const P=I[l],K=D[l],M=E=>E?{action:E.action||"",expectedResult:E.expectedResult||"",testData:E.testData||""}:void 0,_=M(P),B=M(K);if(!_&&B)U.push({type:"added",stepNum:l+1,newStep:B}),A=!0;else if(_&&!B)U.push({type:"removed",stepNum:l+1,oldStep:_}),A=!0;else if(_&&B){const E=_.action!==B.action||_.expectedResult!==B.expectedResult||_.testData!==B.testData;U.push({type:E?"modified":"unchanged",stepNum:l+1,oldStep:_,newStep:B}),E&&(A=!0)}}return{fieldDiffs:x,stepDiffs:U,hasStepChanges:A}}const c=i=>{var r;return i.version===((r=j[0])==null?void 0:r.version)};function N(i){d.mutate({testCaseId:t.id,versionId:i,changedBy:g},{onSuccess:()=>{h(null),b(null),u==null||u(`Test case restored to version ${i} successfully`,"success")},onError:()=>{u==null||u("Failed to restore version. Please try again.","error")}})}return e.jsx("div",{className:"space-y-2",children:j.map((i,r)=>{const x=p===i.version,T=r===0,z=r<j.length-1?j[r+1].snap:{},{fieldDiffs:m,stepDiffs:I,hasStepChanges:D}=f(z,i.snap),G=m.length+(D?1:0),U=v===i.version,A=I.filter(l=>l.type!=="unchanged");return e.jsxs("div",{className:"relative",children:[!T&&e.jsx("div",{className:"absolute left-[15px] -top-2 w-px h-2 bg-white/10"}),r<j.length-1&&e.jsx("div",{className:"absolute left-[15px] -bottom-2 w-px h-2 bg-white/10"}),e.jsx("button",{onClick:()=>b(x?null:i.version),className:`w-full text-left rounded-xl border transition-all ${x?"bg-surface-2 border-brand-500/30 shadow-lg shadow-brand-500/5":"bg-surface-2/60 border-white/5 hover:border-white/10 hover:bg-surface-2"}`,children:e.jsxs("div",{className:"flex items-center gap-3 px-4 py-3",children:[e.jsxs("div",{className:`flex-shrink-0 w-8 h-8 rounded-full flex items-center justify-center text-xs font-bold ${T?"bg-brand-500/20 text-brand-300 ring-2 ring-brand-500/30":"bg-surface-0 text-gray-400 ring-1 ring-white/10"}`,children:["v",i.version]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-sm font-medium text-gray-200",children:i.changeSummary||`Version ${i.version}`}),T&&e.jsx("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-semibold bg-brand-500/15 text-brand-300 uppercase tracking-wider",children:"Current"}),G>0&&!T&&e.jsxs("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-medium bg-amber-500/15 text-amber-300",children:[m.length>0&&`${m.length} field${m.length!==1?"s":""}`,m.length>0&&D&&" + ",D&&`${A.length} step${A.length!==1?"s":""}`]})]}),e.jsxs("div",{className:"flex items-center gap-3 mt-0.5",children:[i.changedBy&&e.jsxs("span",{className:"text-xs text-gray-500",children:["by ",i.changedBy]}),e.jsx("span",{className:"text-xs text-gray-500",children:i.changedAt?Je(i.changedAt):""})]})]}),e.jsx(qe,{size:16,className:`text-gray-500 transition-transform ${x?"rotate-90":""}`})]})}),x&&e.jsxs("div",{className:"mt-1 ml-5 mr-1 rounded-lg border border-white/5 bg-surface-1 overflow-hidden",children:[m.length>0&&e.jsxs("div",{children:[e.jsx("div",{className:"px-4 py-2.5 bg-surface-2/50 border-b border-white/5",children:e.jsx("h4",{className:"text-xs font-semibold text-gray-400 uppercase tracking-wider",children:"Field Changes"})}),e.jsx("div",{className:"divide-y divide-white/5",children:m.map((l,P)=>e.jsxs("div",{className:"grid grid-cols-[100px_1fr_24px_1fr] items-start gap-2 px-4 py-2.5",children:[e.jsx("span",{className:"text-xs font-medium text-gray-400 pt-0.5",children:l.field}),e.jsx("div",{className:"bg-red-500/8 border border-red-500/15 rounded px-2 py-1",children:e.jsx("p",{className:"text-xs text-red-300 line-through break-words",children:l.from})}),e.jsx(je,{size:14,className:"text-gray-600 mt-1 flex-shrink-0"}),e.jsx("div",{className:"bg-emerald-500/8 border border-emerald-500/15 rounded px-2 py-1",children:e.jsx("p",{className:"text-xs text-emerald-300 break-words",children:l.to})})]},P))})]}),D&&e.jsxs("div",{className:"border-t border-white/5",children:[e.jsx("div",{className:"px-4 py-2.5 bg-surface-2/50 border-b border-white/5",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h4",{className:"text-xs font-semibold text-gray-400 uppercase tracking-wider",children:"Step Changes"}),e.jsxs("div",{className:"flex items-center gap-3",children:[A.filter(l=>l.type==="added").length>0&&e.jsxs("span",{className:"flex items-center gap-1 text-[10px] text-emerald-400",children:[e.jsx(sa,{size:10})," ",A.filter(l=>l.type==="added").length," added"]}),A.filter(l=>l.type==="removed").length>0&&e.jsxs("span",{className:"flex items-center gap-1 text-[10px] text-red-400",children:[e.jsx(aa,{size:10})," ",A.filter(l=>l.type==="removed").length," removed"]}),A.filter(l=>l.type==="modified").length>0&&e.jsxs("span",{className:"flex items-center gap-1 text-[10px] text-amber-400",children:[e.jsx(Ee,{size:10})," ",A.filter(l=>l.type==="modified").length," modified"]})]})]})}),e.jsx("div",{className:"divide-y divide-white/5",children:I.filter(l=>l.type!=="unchanged").map((l,P)=>e.jsxs("div",{className:"px-4 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("span",{className:`inline-flex items-center justify-center w-5 h-5 rounded-full text-[10px] font-bold ${l.type==="added"?"bg-emerald-500/20 text-emerald-300":l.type==="removed"?"bg-red-500/20 text-red-300":"bg-amber-500/20 text-amber-300"}`,children:l.stepNum}),e.jsx("span",{className:`text-[10px] font-semibold uppercase tracking-wider ${l.type==="added"?"text-emerald-400":l.type==="removed"?"text-red-400":"text-amber-400"}`,children:l.type==="added"?"New Step":l.type==="removed"?"Removed Step":"Modified Step"})]}),l.type==="added"&&l.newStep&&e.jsxs("div",{className:"ml-7 space-y-1.5 bg-emerald-500/5 border border-emerald-500/15 rounded-lg p-3",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-gray-500 font-medium",children:"Action:"}),e.jsx("p",{className:"text-xs text-emerald-300 mt-0.5",children:l.newStep.action})]}),l.newStep.expectedResult&&e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-gray-500 font-medium",children:"Expected:"}),e.jsx("p",{className:"text-xs text-emerald-300 mt-0.5",children:l.newStep.expectedResult})]}),l.newStep.testData&&e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-gray-500 font-medium",children:"Test Data:"}),e.jsx("p",{className:"text-xs text-emerald-300 font-mono mt-0.5",children:l.newStep.testData})]})]}),l.type==="removed"&&l.oldStep&&e.jsxs("div",{className:"ml-7 space-y-1.5 bg-red-500/5 border border-red-500/15 rounded-lg p-3",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-gray-500 font-medium",children:"Action:"}),e.jsx("p",{className:"text-xs text-red-300 line-through mt-0.5",children:l.oldStep.action})]}),l.oldStep.expectedResult&&e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-gray-500 font-medium",children:"Expected:"}),e.jsx("p",{className:"text-xs text-red-300 line-through mt-0.5",children:l.oldStep.expectedResult})]}),l.oldStep.testData&&e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-gray-500 font-medium",children:"Test Data:"}),e.jsx("p",{className:"text-xs text-red-300 line-through font-mono mt-0.5",children:l.oldStep.testData})]})]}),l.type==="modified"&&l.oldStep&&l.newStep&&e.jsxs("div",{className:"ml-7 space-y-2",children:[l.oldStep.action!==l.newStep.action&&e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-gray-500 font-medium block mb-1",children:"Action"}),e.jsxs("div",{className:"grid grid-cols-[1fr_20px_1fr] gap-1 items-start",children:[e.jsx("div",{className:"bg-red-500/8 border border-red-500/15 rounded px-2 py-1.5",children:e.jsx("p",{className:"text-[11px] text-red-300 line-through leading-relaxed",children:l.oldStep.action})}),e.jsx(je,{size:12,className:"text-gray-600 mt-1.5 mx-auto"}),e.jsx("div",{className:"bg-emerald-500/8 border border-emerald-500/15 rounded px-2 py-1.5",children:e.jsx("p",{className:"text-[11px] text-emerald-300 leading-relaxed",children:l.newStep.action})})]})]}),l.oldStep.expectedResult!==l.newStep.expectedResult&&e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-gray-500 font-medium block mb-1",children:"Expected Result"}),e.jsxs("div",{className:"grid grid-cols-[1fr_20px_1fr] gap-1 items-start",children:[e.jsx("div",{className:"bg-red-500/8 border border-red-500/15 rounded px-2 py-1.5",children:e.jsx("p",{className:"text-[11px] text-red-300 line-through leading-relaxed",children:l.oldStep.expectedResult||"(empty)"})}),e.jsx(je,{size:12,className:"text-gray-600 mt-1.5 mx-auto"}),e.jsx("div",{className:"bg-emerald-500/8 border border-emerald-500/15 rounded px-2 py-1.5",children:e.jsx("p",{className:"text-[11px] text-emerald-300 leading-relaxed",children:l.newStep.expectedResult||"(empty)"})})]})]}),l.oldStep.testData!==l.newStep.testData&&e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-gray-500 font-medium block mb-1",children:"Test Data"}),e.jsxs("div",{className:"grid grid-cols-[1fr_20px_1fr] gap-1 items-start",children:[e.jsx("div",{className:"bg-red-500/8 border border-red-500/15 rounded px-2 py-1.5",children:e.jsx("p",{className:"text-[11px] text-red-300 line-through font-mono leading-relaxed",children:l.oldStep.testData||"(empty)"})}),e.jsx(je,{size:12,className:"text-gray-600 mt-1.5 mx-auto"}),e.jsx("div",{className:"bg-emerald-500/8 border border-emerald-500/15 rounded px-2 py-1.5",children:e.jsx("p",{className:"text-[11px] text-emerald-300 font-mono leading-relaxed",children:l.newStep.testData||"(empty)"})})]})]})]})]},P))})]}),m.length===0&&!D&&e.jsx("div",{className:"px-4 py-4 text-center",children:e.jsx("p",{className:"text-xs text-gray-500",children:r===j.length-1?"Initial version — no previous version to compare":"No changes detected"})}),!c(i)&&e.jsx("div",{className:"border-t border-white/5 px-4 py-3 bg-surface-2/20",children:U?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-xs text-amber-300 flex-1",children:["Restore test case to version ",i.version,"?"]}),e.jsx("button",{onClick:()=>h(null),className:"px-3 py-1.5 text-xs rounded-lg bg-surface-2 hover:bg-surface-1 text-gray-400 transition-colors",children:"Cancel"}),e.jsxs("button",{onClick:()=>N(i.version),disabled:d.isPending,className:"px-3 py-1.5 text-xs rounded-lg bg-amber-600 hover:bg-amber-500 text-white font-medium transition-colors disabled:opacity-50 flex items-center gap-1.5",children:[e.jsx(ot,{size:12,className:d.isPending?"animate-spin":""}),d.isPending?"Restoring...":"Confirm Restore"]})]}):e.jsxs("button",{onClick:()=>h(i.version),className:"flex items-center gap-1.5 px-3 py-1.5 text-xs rounded-lg bg-surface-2 hover:bg-amber-500/15 text-gray-400 hover:text-amber-300 border border-white/5 hover:border-amber-500/20 transition-all",children:[e.jsx(ot,{size:12}),"Restore to this version"]})})]})]},i.id)})})}function Ct(t,y,u){const g=(t==null?void 0:t.id)||"",p=(t==null?void 0:t.title)||"(untitled test case)",b=((t==null?void 0:t.preconditions)||"").trim(),v=((t==null?void 0:t.tags)||[]).map(d=>d==null?void 0:d.name).filter(Boolean);if(u==="json")return JSON.stringify({id:g,title:p,priority:t==null?void 0:t.priority,type:t==null?void 0:t.type,preconditions:b||void 0,tags:v.length?v:void 0,steps:y.map((d,j)=>({step:j+1,action:d.action||"",expected:d.expectedResult||d.expected_result||void 0,testData:d.testData||d.test_data||void 0}))},null,2);if(u==="plain"){const d=[];return d.push(`${g?g+" — ":""}${p}`),b&&d.push(`Preconditions: ${b}`),d.push(""),y.forEach((j,f)=>{d.push(`${f+1}. ${j.action||""}`);const c=j.expectedResult||j.expected_result,N=j.testData||j.test_data;c&&d.push(` Expected: ${c}`),N&&d.push(` Test data: ${N}`)}),d.join(`
2
+ `)}const h=[];return h.push(`Test case: ${g?g+" — ":""}${p}`),t!=null&&t.priority&&h.push(`Priority: ${t.priority}`),t!=null&&t.type&&h.push(`Type: ${t.type}`),v.length&&h.push(`Tags: ${v.join(", ")}`),h.push(""),b&&h.push(`Given ${b}`),y.forEach((d,j)=>{const f=j===0&&!b?"Given":j===0?"When":"And",c=d.testData||d.test_data,N=(d.action||"").trim();h.push(`${f} ${N}${c?` (data: ${c})`:""}`);const i=(d.expectedResult||d.expected_result||"").trim();i&&h.push(` Then ${i}`)}),h.join(`
3
+ `)}function la(t,y){return["Please help me automate the following manual test case.","Generate idiomatic, maintainable code with stable locators, reasonable assertions","for each expected outcome, and a clear test/file name derived from the title below.","",Ct(t,y,"gherkin")].join(`
4
+ `)}function ia({testCase:t,steps:y,onToast:u,isAutomated:g}){const p=Ht(),{mode:b}=Es(),[v,h]=o.useState(!1),[d,j]=o.useState(null),f=o.useRef(null);o.useEffect(()=>{if(!v)return;const r=x=>{f.current&&!f.current.contains(x.target)&&h(!1)};return document.addEventListener("mousedown",r),()=>document.removeEventListener("mousedown",r)},[v]);const c=async r=>{try{const x=Ct(t,y,r);await navigator.clipboard.writeText(x),j(r),u==null||u(`Copied as ${r==="gherkin"?"Gherkin":r==="plain"?"text":"JSON"}`),setTimeout(()=>j(null),2e3),h(!1)}catch{u==null||u("Could not copy to clipboard","error")}},N=()=>{Fs(p,{prompt:la(t,y),mode:b==="mobile"?"mobile":"web"})},i=v&&e.jsxs("div",{className:"absolute right-0 top-full mt-1 z-40 w-56 bg-surface-1 border border-white/10 rounded-lg shadow-xl overflow-hidden",children:[e.jsxs("button",{type:"button",onClick:()=>c("gherkin"),className:"w-full flex items-center gap-2 px-3 py-2 text-xs text-left text-gray-300 hover:bg-surface-2 hover:text-gray-100",children:[d==="gherkin"?e.jsx(xe,{size:13,className:"text-emerald-400"}):e.jsx(dt,{size:13,className:"text-brand-300"}),"Copy as Gherkin (AI-friendly)"]}),e.jsxs("button",{type:"button",onClick:()=>c("plain"),className:"w-full flex items-center gap-2 px-3 py-2 text-xs text-left text-gray-300 hover:bg-surface-2 hover:text-gray-100",children:[d==="plain"?e.jsx(xe,{size:13,className:"text-emerald-400"}):e.jsx(it,{size:13,className:"text-gray-400"}),"Copy as text"]}),e.jsxs("button",{type:"button",onClick:()=>c("json"),className:"w-full flex items-center gap-2 px-3 py-2 text-xs text-left text-gray-300 hover:bg-surface-2 hover:text-gray-100",children:[d==="json"?e.jsx(xe,{size:13,className:"text-emerald-400"}):e.jsx(ta,{size:13,className:"text-sky-400"}),"Copy as JSON"]})]});return g?e.jsxs("div",{ref:f,className:"relative inline-flex",children:[e.jsxs("button",{type:"button",onClick:()=>h(r=>!r),className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-lg bg-surface-2 hover:bg-surface-3 text-gray-300 border border-white/10 transition-colors",title:"Copy steps in a chosen format",children:[e.jsx(it,{size:13}),"Copy steps",e.jsx(ne,{size:13,className:"text-gray-500"})]}),i]}):e.jsxs("div",{ref:f,className:"relative inline-flex items-stretch",children:[e.jsxs("button",{type:"button",onClick:N,className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-l-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors",title:"Send these steps to the AI Assistant to generate automation code",children:[e.jsx(dt,{size:13}),"Automate with AI"]}),e.jsx("button",{type:"button",onClick:()=>h(r=>!r),className:"flex items-center px-1.5 py-1.5 rounded-r-lg bg-brand-600 hover:bg-brand-500 text-white border-l border-brand-500/40 transition-colors",title:"Copy steps in another format",children:e.jsx(ne,{size:13})}),i]})}function da({testCase:t,onClose:y,onEdit:u,onToast:g,currentUserName:p}){var ie,O;const[b,v]=Yt("detail",["steps","attachments","links","history","mapping","executions"],"steps"),[h,d]=o.useState(null),{data:j}=ut(t==null?void 0:t.id),{data:f}=vs(t==null?void 0:t.id),{data:c}=Ns(t==null?void 0:t.id),{data:N}=ws(t==null?void 0:t.id),{data:i}=ks(t==null?void 0:t.id),{data:r}=Ss(t==null?void 0:t.id),{data:x}=Ts(t==null?void 0:t.id),T=zs(),z=Cs(),m=pt(),I=As(),D=(j==null?void 0:j.steps)||[],G=(f==null?void 0:f.versions)||[],U=(N==null?void 0:N.attachments)||[],A=(i==null?void 0:i.links)||[],l=(x==null?void 0:x.sources)||[],[P,K]=o.useState(!1),[M,_]=o.useState({title:"",url:"",linkType:"other"}),[B,E]=o.useState(!1),[F,Y]=o.useState(null);if(!t)return null;const n=({size:s=18})=>e.jsxs("svg",{width:s,height:s,viewBox:"0 0 256 256",xmlns:"http://www.w3.org/2000/svg",children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{x1:"98.03%",y1:"0.16%",x2:"58.89%",y2:"40.77%",id:"tmjg1",children:[e.jsx("stop",{stopColor:"#0052CC",offset:"18%"}),e.jsx("stop",{stopColor:"#2684FF",offset:"100%"})]}),e.jsxs("linearGradient",{x1:"100.67%",y1:"0.46%",x2:"55.4%",y2:"44.73%",id:"tmjg2",children:[e.jsx("stop",{stopColor:"#0052CC",offset:"18%"}),e.jsx("stop",{stopColor:"#2684FF",offset:"100%"})]})]}),e.jsxs("g",{children:[e.jsx("path",{d:"M244.658,0 L121.707,0 C121.707,14.72 127.554,28.837 137.963,39.246 C148.372,49.655 162.489,55.502 177.209,55.502 L199.858,55.502 L199.858,77.369 C199.877,107.994 224.699,132.816 255.324,132.836 L255.324,10.667 C255.324,4.776 250.549,0 244.658,0 Z",fill:"#2684FF"}),e.jsx("path",{d:"M183.822,61.262 L60.871,61.262 C60.891,91.887 85.713,116.709 116.338,116.729 L138.987,116.729 L138.987,138.667 C139.026,169.292 163.864,194.098 194.489,194.098 L194.489,71.929 C194.489,66.038 189.713,61.262 183.822,61.262 Z",fill:"url(#tmjg1)"}),e.jsx("path",{d:"M122.951,122.489 L0,122.489 C0,153.142 24.849,177.991 55.502,177.991 L78.222,177.991 L78.222,199.858 C78.242,230.455 103.02,255.266 133.618,255.324 L133.618,133.156 C133.618,127.265 128.842,122.489 122.951,122.489 Z",fill:"url(#tmjg2)"})]})]}),w=({size:s=18})=>e.jsxs("svg",{width:s,height:s,viewBox:"0 0 32 32",xmlns:"http://www.w3.org/2000/svg",children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"cg1",x1:"28.607",y1:"-60.825",x2:"11.085",y2:"-50.756",gradientTransform:"matrix(1,0,0,-1,0,-29.66)",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:"0.18",stopColor:"#0052cc"}),e.jsx("stop",{offset:"1",stopColor:"#2684ff"})]}),e.jsxs("linearGradient",{id:"cg2",x1:"621.442",y1:"1817.567",x2:"603.915",y2:"1827.64",gradientTransform:"matrix(-1,0,0,1,624.83,-1816.71)",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:"0.18",stopColor:"#0052cc"}),e.jsx("stop",{offset:"1",stopColor:"#2684ff"})]})]}),e.jsx("path",{d:"M3.015,23.087c-.289.472-.614,1.02-.891,1.456a.892.892,0,0,0,.3,1.212l5.792,3.564a.89.89,0,0,0,1.226-.29l.008-.013c.231-.387.53-.891.855-1.43,2.294-3.787,4.6-3.323,8.763-1.336l5.743,2.731A.892.892,0,0,0,26,28.559l.011-.024L28.766,22.3a.891.891,0,0,0-.445-1.167c-1.212-.57-3.622-1.707-5.792-2.754C14.724,14.586,8.09,14.831,3.015,23.087Z",fill:"url(#cg1)"}),e.jsx("path",{d:"M28.985,8.932c.289-.472.614-1.02.891-1.456a.892.892,0,0,0-.3-1.212L23.785,2.7a.89.89,0,0,0-1.236.241.584.584,0,0,0-.033.053c-.232.387-.53.891-.856,1.43-2.294,3.787-4.6,3.323-8.763,1.336L7.172,3.043a.89.89,0,0,0-1.187.421l-.011.024L3.216,9.726a.891.891,0,0,0,.445,1.167c1.212.57,3.622,1.706,5.792,2.753C17.276,17.433,23.91,17.179,28.985,8.932Z",fill:"url(#cg2)"})]}),k=({size:s=18})=>e.jsx("svg",{width:s,height:s,viewBox:"0 0 20 20",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M10,0 C15.523,0 20,4.59 20,10.253 C20,14.782 17.138,18.624 13.167,19.981 C12.66,20.082 12.48,19.762 12.48,19.489 C12.48,19.151 12.492,18.047 12.492,16.675 C12.492,15.719 12.172,15.095 11.813,14.777 C14.04,14.523 16.38,13.656 16.38,9.718 C16.38,8.598 15.992,7.684 15.35,6.966 C15.454,6.707 15.797,5.664 15.252,4.252 C15.252,4.252 14.414,3.977 12.505,5.303 C11.706,5.076 10.85,4.962 10,4.958 C9.15,4.962 8.295,5.076 7.497,5.303 C5.586,3.977 4.746,4.252 4.746,4.252 C4.203,5.664 4.546,6.707 4.649,6.966 C4.01,7.684 3.619,8.598 3.619,9.718 C3.619,13.646 5.954,14.526 8.175,14.785 C7.889,15.041 7.63,15.493 7.54,16.156 C6.97,16.418 5.522,16.871 4.63,15.304 C4.63,15.304 4.101,14.319 3.097,14.247 C3.097,14.247 2.122,14.234 3.029,14.87 C3.029,14.87 3.684,15.185 4.139,16.37 C4.139,16.37 4.726,18.2 7.508,17.58 C7.513,18.437 7.522,19.245 7.522,19.489 C7.522,19.76 7.338,20.077 6.839,19.982 C2.865,18.627 0,14.783 0,10.253 C0,4.59 4.478,0 10,0",fill:"currentColor"})}),S={jira:{label:"Jira",color:"text-blue-400"},confluence:{label:"Confluence",color:"text-blue-300"},github:{label:"GitHub",color:"text-gray-300"},docs:{label:"Docs",emoji:"📑",color:"text-emerald-400"},design:{label:"Design",emoji:"🎨",color:"text-purple-400"},other:{label:"Other",emoji:"🔗",color:"text-gray-400"}},V=({type:s,size:C=18})=>{if(s==="jira")return e.jsx(n,{size:C});if(s==="confluence")return e.jsx(w,{size:C});if(s==="github")return e.jsx(k,{size:C});const L=S[s]||S.other;return e.jsx("span",{style:{fontSize:C},children:L.emoji})},le=async s=>{const C=s.target.files;if(!(!C||!(t!=null&&t.id))){for(const L of Array.from(C)){if(L.size>10*1024*1024){g==null||g(`File "${L.name}" exceeds 10MB limit`,"error");continue}const W=new FileReader;W.onload=()=>{const be=W.result.split(",")[1]||"";T.mutate({testCaseId:t.id,data:{fileName:L.name,fileType:L.type,fileSize:L.size,fileData:be,uploadedBy:p||""}})},W.readAsDataURL(L)}s.target.value=""}},Ne=s=>{z.mutate({id:s,testCaseId:t.id})},se=()=>{!M.title.trim()||!M.url.trim()||(m.mutate({testCaseId:t.id,data:{title:M.title.trim(),url:M.url.trim(),linkType:M.linkType,addedBy:p||""}}),_({title:"",url:"",linkType:"other"}),K(!1))},X=s=>{I.mutate({id:s,testCaseId:t.id})},he=s=>{const C=document.createElement("a");C.href=`data:${s.fileType};base64,${s.fileData}`,C.download=s.fileName,C.click()},Le=s=>s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:`${(s/(1024*1024)).toFixed(1)} MB`,te=s=>s.startsWith("image/"),Q=Array.isArray(r==null?void 0:r.history)?r.history:[],we=Q.length>0?Math.round(Q.filter(s=>s.status==="passed").length/Q.length*100):0,ge=[{key:"steps",label:"Steps",icon:ce,count:D.length},{key:"executions",label:"Executions",icon:at,count:Q.length},{key:"attachments",label:"Attachments",icon:rt,count:U.length},{key:"links",label:"Links",icon:nt,count:A.length},{key:"history",label:"History",icon:jt},{key:"mapping",label:"Mapping",icon:_e}];return e.jsxs("div",{className:"fixed inset-0 z-50 flex justify-end",children:[e.jsx("div",{className:"absolute inset-0 bg-black/50",onClick:y}),e.jsxs("div",{className:"relative bg-surface-1 w-full max-w-3xl border-l border-white/10 animate-slide-in-right overflow-y-auto",children:[e.jsx("div",{className:"sticky top-0 bg-surface-1 z-10 px-6 py-4 border-b border-white/5",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-100 pr-4 break-words",children:t.title}),e.jsxs("div",{className:"flex items-center gap-2.5 mt-2",children:[t.id&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-[13px] text-gray-400 font-mono",children:[e.jsx(yt,{size:13,className:"flex-shrink-0"}),t.id]}),e.jsxs("span",{className:"inline-flex items-center gap-1 text-[13px] text-gray-400",children:[e.jsx(ve,{size:13,className:"flex-shrink-0"}),((ie=t.folder)==null?void 0:ie.name)||"Uncategorized"]}),D.length>0&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-[13px] text-gray-400",children:[e.jsx(ce,{size:13,className:"flex-shrink-0"}),D.length," step",D.length!==1?"s":""]})]})]}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[e.jsx("button",{onClick:()=>u(t),title:"Edit test case",className:"p-1.5 rounded-lg hover:bg-surface-2 text-gray-400 hover:text-gray-200 transition-colors",children:e.jsx(Ee,{size:18})}),e.jsx("button",{onClick:y,title:"Close",className:"p-1.5 rounded-lg hover:bg-surface-2 text-gray-400 hover:text-gray-200 transition-colors",children:e.jsx(ee,{size:18})})]})]})}),e.jsxs("div",{className:"px-6 py-5 space-y-5",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("span",{className:`inline-flex items-center px-2.5 py-1 rounded-md text-xs font-medium ${ct[t.priority]||ct.medium}`,children:Z(t.priority||"medium")}),e.jsx("span",{className:`inline-flex items-center px-2.5 py-1 rounded-md text-xs font-medium ${Oe[t.type]||Oe.web}`,children:Z(t.type||"web")}),e.jsx("span",{className:`inline-flex items-center px-2.5 py-1 rounded-md text-xs font-medium ${xt[t.status]||xt.draft}`,children:Z(t.status||"draft")}),e.jsxs("span",{className:"inline-flex items-center gap-1 px-2.5 py-1 rounded-md text-xs font-medium bg-surface-2 text-gray-300",children:[e.jsx(Be,{size:12}),Re[t.automationStatus]||"Manual"]}),e.jsxs("span",{className:"inline-flex items-center gap-1 px-2.5 py-1 rounded-md text-xs font-medium bg-surface-2 text-gray-300",children:[e.jsx(Ue,{size:12}),De[t.reviewStatus]||"Not Reviewed"]})]}),t.staleAt?e.jsx(ha,{id:t.id,reason:t.staleReason}):null,t.preconditions&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-medium text-gray-400 uppercase tracking-wider mb-1.5",children:"Preconditions"}),e.jsx("p",{className:"text-sm text-gray-300 bg-surface-2 rounded-lg p-3 border border-white/5 whitespace-pre-wrap",children:t.preconditions})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[!!t.estimatedDuration&&e.jsxs("div",{className:"bg-surface-2 rounded-lg p-3 border border-white/5",children:[e.jsx("span",{className:"text-xs text-gray-400 block mb-0.5",children:"Duration"}),e.jsxs("span",{className:"text-sm text-gray-200 flex items-center gap-1.5",children:[e.jsx(Fe,{size:13})," ",t.estimatedDuration," min"]})]}),e.jsxs("div",{className:"bg-surface-2 rounded-lg p-3 border border-white/5",children:[e.jsx("span",{className:"text-xs text-gray-400 block mb-0.5",children:"Folder"}),e.jsxs("span",{className:"text-sm text-gray-200 flex items-center gap-1.5",children:[e.jsx(ve,{size:13})," ",((O=t.folder)==null?void 0:O.name)||"Uncategorized"]})]})]}),t.tags&&t.tags.length>0&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-medium text-gray-400 uppercase tracking-wider mb-1.5",children:"Tags"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:t.tags.map(s=>e.jsx("span",{className:"inline-flex items-center px-2.5 py-1 rounded-full text-xs font-medium bg-surface-2 text-gray-300 border border-white/5",children:s.name},s.id))})]}),e.jsx("div",{className:"flex border-b border-white/5 overflow-x-auto",children:ge.map(s=>e.jsxs("button",{onClick:()=>v(s.key),className:`flex items-center gap-1.5 px-3.5 py-2.5 text-sm font-medium border-b-2 transition-colors whitespace-nowrap ${b===s.key?"border-brand-500 text-brand-300":"border-transparent text-gray-400 hover:text-gray-300"}`,children:[e.jsx(s.icon,{size:14}),s.label,"count"in s&&typeof s.count=="number"&&s.count>0&&e.jsx("span",{className:"ml-1 px-1.5 py-0.5 rounded-full text-[10px] font-bold bg-surface-2 text-gray-400",children:s.count})]},s.key))}),b==="steps"&&e.jsxs("div",{children:[D&&D.length>0&&e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h4",{className:"text-sm font-medium text-gray-300",children:"Test Steps"}),e.jsx(ia,{testCase:t,steps:D,onToast:g,isAutomated:(t==null?void 0:t.automationStatus)==="automated"||(t==null?void 0:t.automation_status)==="automated"||!!(c!=null&&c.scriptPath)})]}),D&&D.length>0?e.jsxs("div",{className:"rounded-xl border border-white/10 overflow-hidden",children:[e.jsxs("div",{className:"grid grid-cols-[48px_1fr_1fr_140px] bg-surface-2/80 border-b border-white/10",children:[e.jsx("div",{className:"px-3 py-2.5 text-xs font-semibold text-gray-400 uppercase tracking-wider text-center",children:"#"}),e.jsx("div",{className:"px-3 py-2.5 text-xs font-semibold text-gray-400 uppercase tracking-wider",children:"Action"}),e.jsx("div",{className:"px-3 py-2.5 text-xs font-semibold text-gray-400 uppercase tracking-wider",children:"Expected Result"}),e.jsx("div",{className:"px-3 py-2.5 text-xs font-semibold text-gray-400 uppercase tracking-wider",children:"Test Data"})]}),D.map((s,C)=>e.jsxs("div",{className:`grid grid-cols-[48px_1fr_1fr_140px] border-b border-white/5 last:border-b-0 transition-colors hover:bg-white/[0.02] ${C%2===0?"bg-surface-1":"bg-surface-2/30"}`,children:[e.jsx("div",{className:"px-3 py-3 flex items-start justify-center",children:e.jsx("span",{className:"w-6 h-6 rounded-full bg-brand-500/20 text-brand-300 text-xs font-bold flex items-center justify-center flex-shrink-0",children:s.stepNumber||C+1})}),e.jsx("div",{className:"px-3 py-3",children:e.jsx("p",{className:"text-sm text-gray-200 leading-relaxed whitespace-pre-wrap",children:s.action})}),e.jsx("div",{className:"px-3 py-3",children:e.jsx("p",{className:"text-sm text-teal-200 leading-relaxed whitespace-pre-wrap",children:s.expectedResult||e.jsx("span",{className:"text-gray-600 italic",children:"—"})})}),e.jsx("div",{className:"px-3 py-3",children:s.testData?e.jsx("p",{className:"text-sm text-sky-300 font-mono leading-relaxed break-all",children:s.testData}):e.jsx("span",{className:"text-gray-600 text-sm italic",children:"—"})})]},s.id||C)),e.jsx("div",{className:"bg-surface-2/50 px-4 py-2 border-t border-white/10",children:e.jsxs("span",{className:"text-xs text-gray-500",children:[D.length," step",D.length!==1?"s":""," total"]})})]}):e.jsxs("div",{className:"text-center py-8 text-gray-500 text-sm",children:[e.jsx(ce,{size:24,className:"mx-auto mb-2 opacity-50"}),"No steps defined yet"]})]}),b==="attachments"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h4",{className:"text-sm font-medium text-gray-300",children:"Attachments"}),e.jsxs("label",{className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-lg bg-brand-600 hover:bg-brand-500 text-white cursor-pointer transition-colors",children:[e.jsx(Zs,{size:13}),"Upload Files",e.jsx("input",{type:"file",multiple:!0,accept:"image/*,.pdf,.doc,.docx,.xls,.xlsx,.ppt,.pptx,.txt,.csv,.json,.xml,.yaml,.yml,.md",className:"hidden",onChange:le})]})]}),e.jsx("p",{className:"text-xs text-gray-500",children:"Max 10MB per file. Supported: Images, PDFs, Office documents, text files."}),U.length>0?e.jsx("div",{className:"space-y-2",children:U.map(s=>{var C;return e.jsxs("div",{className:"flex items-center gap-3 bg-surface-2 rounded-lg p-3 border border-white/5 group hover:border-white/10 transition-colors",children:[e.jsx("div",{className:"flex-shrink-0 w-10 h-10 rounded-lg bg-surface-1 border border-white/5 flex items-center justify-center overflow-hidden",children:te(s.fileType)?e.jsx("button",{onClick:()=>Y(s),className:"w-full h-full",children:e.jsx("img",{src:`data:${s.fileType};base64,${s.fileData}`,alt:s.fileName,className:"w-full h-full object-cover rounded-lg"})}):(C=s.fileType)!=null&&C.includes("pdf")?e.jsx(Pe,{size:18,className:"text-red-400"}):e.jsx(Pe,{size:18,className:"text-gray-400"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm text-gray-200 font-medium truncate",children:s.fileName}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500",children:[e.jsx("span",{children:Le(s.fileSize)}),s.uploadedBy&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"·"}),e.jsx("span",{children:s.uploadedBy})]}),e.jsx("span",{children:"·"}),e.jsx("span",{children:mt(s.createdAt)})]})]}),e.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[te(s.fileType)&&e.jsx("button",{onClick:()=>Y(s),className:"p-1.5 rounded-lg hover:bg-white/10 text-gray-400 hover:text-gray-200",title:"Preview",children:e.jsx(Ue,{size:14})}),e.jsx("button",{onClick:()=>he(s),className:"p-1.5 rounded-lg hover:bg-white/10 text-gray-400 hover:text-gray-200",title:"Download",children:e.jsx(Qs,{size:14})}),e.jsx("button",{onClick:()=>Ne(s.id),className:"p-1.5 rounded-lg hover:bg-white/10 text-gray-400 hover:text-red-400",title:"Delete",children:e.jsx(ue,{size:14})})]})]},s.id)})}):e.jsxs("div",{className:"text-center py-8 text-gray-500 text-sm",children:[e.jsx(rt,{size:24,className:"mx-auto mb-2 opacity-50"}),"No attachments yet"]}),F&&e.jsx("div",{className:"fixed inset-0 z-[60] flex items-center justify-center bg-black/80 backdrop-blur-sm",onClick:()=>Y(null),children:e.jsxs("div",{className:"relative max-w-4xl max-h-[90vh] mx-4",onClick:s=>s.stopPropagation(),children:[e.jsx("button",{onClick:()=>Y(null),className:"absolute -top-3 -right-3 z-10 p-1.5 rounded-full bg-surface-2 border border-white/10 text-gray-300 hover:text-white shadow-xl",children:e.jsx(ee,{size:16})}),e.jsx("img",{src:`data:${F.fileType};base64,${F.fileData}`,alt:F.fileName,className:"max-w-full max-h-[85vh] rounded-xl shadow-2xl object-contain"}),e.jsx("p",{className:"text-center text-sm text-gray-400 mt-2",children:F.fileName})]})})]}),b==="links"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h4",{className:"text-sm font-medium text-gray-300",children:"Reference Links"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(pa,{testCaseId:t.id,onLinked:()=>{}}),e.jsxs("button",{onClick:()=>K(!P),className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors",children:[e.jsx(Me,{size:13}),"Add Link"]})]})]}),P&&e.jsxs("div",{className:"bg-surface-2 rounded-lg border border-white/10 p-4 space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-400 mb-1",children:"Title *"}),e.jsx("input",{className:"w-full bg-surface-1 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 outline-none focus:border-brand-500",value:M.title,onChange:s=>_({...M,title:s.target.value}),placeholder:"e.g. JIRA-1234 Login Bug, Design Mockup..."})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-400 mb-1",children:"URL *"}),e.jsx("input",{className:"w-full bg-surface-1 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 outline-none focus:border-brand-500",value:M.url,onChange:s=>_({...M,url:s.target.value}),placeholder:"https://..."})]}),e.jsxs("div",{className:"relative",children:[e.jsx("label",{className:"block text-xs font-medium text-gray-400 mb-1",children:"Type"}),e.jsxs("button",{type:"button",onClick:()=>E(!B),className:"w-full bg-surface-1 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 outline-none focus:border-brand-500 flex items-center gap-2 text-left",children:[e.jsx(V,{type:M.linkType,size:16}),e.jsx("span",{className:"flex-1",children:{jira:"Jira Ticket",confluence:"Confluence Page",github:"GitHub Issue / PR",docs:"Documentation",design:"Design (Figma, etc.)",other:"Other"}[M.linkType]||"Other"}),e.jsx(ne,{size:14,className:`text-gray-400 transition-transform ${B?"rotate-180":""}`})]}),B&&e.jsx("div",{className:"absolute z-20 mt-1 w-full bg-surface-1 border border-white/10 rounded-lg shadow-xl overflow-hidden",children:[{value:"jira",label:"Jira Ticket"},{value:"confluence",label:"Confluence Page"},{value:"github",label:"GitHub Issue / PR"},{value:"docs",label:"Documentation"},{value:"design",label:"Design (Figma, etc.)"},{value:"other",label:"Other"}].map(s=>e.jsxs("button",{type:"button",onClick:()=>{_({...M,linkType:s.value}),E(!1)},className:`w-full flex items-center gap-2.5 px-3 py-2.5 text-sm text-left hover:bg-surface-2 transition-colors ${M.linkType===s.value?"bg-surface-2 text-brand-300":"text-gray-200"}`,children:[e.jsx(V,{type:s.value,size:16}),e.jsx("span",{children:s.label}),M.linkType===s.value&&e.jsx(pe,{size:14,className:"ml-auto text-brand-400"})]},s.value))})]}),e.jsxs("div",{className:"flex gap-2 justify-end pt-1",children:[e.jsx("button",{onClick:()=>{K(!1),_({title:"",url:"",linkType:"other"})},className:"px-3 py-1.5 text-xs rounded-lg bg-surface-1 hover:bg-surface-0 text-gray-400 border border-white/10",children:"Cancel"}),e.jsx("button",{onClick:se,disabled:!M.title.trim()||!M.url.trim(),className:"px-3 py-1.5 text-xs rounded-lg bg-brand-600 hover:bg-brand-500 text-white font-medium disabled:opacity-50",children:"Add Link"})]})]}),A.length>0?e.jsx("div",{className:"space-y-2",children:A.map(s=>e.jsxs("div",{className:"flex items-center gap-3 bg-surface-2 rounded-lg p-3 border border-white/5 group hover:border-white/10 transition-colors",children:[e.jsx("div",{className:"flex-shrink-0 w-7 h-7 rounded-md bg-surface-1 border border-white/5 flex items-center justify-center",children:e.jsx(V,{type:s.linkType,size:16})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm text-gray-200 font-medium truncate",children:s.title}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500",children:[e.jsx("span",{className:`font-medium ${(S[s.linkType]||S.other).color}`,children:(S[s.linkType]||S.other).label}),e.jsx("span",{children:"·"}),e.jsx("span",{className:"truncate max-w-[200px]",children:s.url}),s.addedBy&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"·"}),e.jsx("span",{children:s.addedBy})]})]})]}),e.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsx("a",{href:s.url,target:"_blank",rel:"noopener noreferrer",className:"p-1.5 rounded-lg hover:bg-white/10 text-gray-400 hover:text-brand-300",title:"Open Link",children:e.jsx(Ae,{size:14})}),s.linkType==="jira"&&e.jsx(ga,{jiraUrl:s.url,testCaseTitle:t.title||t.name||""}),e.jsx("button",{onClick:()=>X(s.id),className:"p-1.5 rounded-lg hover:bg-white/10 text-gray-400 hover:text-red-400",title:"Delete",children:e.jsx(ue,{size:14})})]})]},s.id))}):e.jsxs("div",{className:"text-center py-8 text-gray-500 text-sm",children:[e.jsx(nt,{size:24,className:"mx-auto mb-2 opacity-50"}),"No reference links yet"]})]}),b==="history"&&e.jsx(na,{testCase:t,versions:G,onToast:g,currentUserName:p}),b==="mapping"&&e.jsxs("div",{className:"space-y-5",children:[l.length>0&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-medium text-gray-400 uppercase tracking-wider mb-2",children:"Generated From Sources"}),e.jsx("div",{className:"space-y-1.5",children:l.map(s=>{const C={requirement:"Requirement",nlp:"NLP",jira:"JIRA",document:"Document"},L=()=>{if(s.type==="jira")return e.jsx(n,{size:16});const W={requirement:"📋",nlp:"💬",document:"📎"};return e.jsx("span",{className:"text-sm",children:W[s.type]||"📎"})};return e.jsxs("div",{className:"flex items-center gap-2.5 bg-surface-2 rounded-lg px-3 py-2.5 border border-white/5",children:[e.jsx("span",{className:"flex-shrink-0",children:e.jsx(L,{})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm text-gray-200 font-medium truncate",children:s.title}),e.jsx("span",{className:"text-[10px] text-gray-500",children:C[s.type]||"Source"})]}),s.externalUrl&&e.jsx("a",{href:s.externalUrl,target:"_blank",rel:"noopener noreferrer",className:"p-1 rounded hover:bg-white/10 text-gray-400 hover:text-brand-300",children:e.jsx(Ae,{size:12})})]},s.id)})})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-medium text-gray-400 uppercase tracking-wider mb-2",children:"Script Mapping"}),c?e.jsxs("div",{className:"bg-surface-2 rounded-lg border border-white/5 px-4 py-3 flex items-start gap-3",children:[e.jsx("div",{className:"w-9 h-9 rounded-lg bg-brand-500/10 border border-brand-500/20 flex items-center justify-center shrink-0 mt-0.5",children:e.jsx(_e,{size:16,className:"text-brand-400"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[c.testName&&e.jsx("p",{className:"text-sm font-medium text-gray-200 mb-0.5",title:c.testName,children:es(c.testName)}),e.jsx("p",{className:"text-xs font-mono text-gray-400 truncate",title:c.scriptPath,children:c.scriptPath}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mt-2",children:[c.framework&&e.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-[10px] font-medium bg-sky-500/20 text-sky-200 border border-sky-500/25",children:c.framework}),c.syncStatus&&e.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded text-[10px] font-medium ${c.syncStatus==="synced"?"bg-emerald-500/15 text-emerald-300 border border-emerald-500/20":c.syncStatus==="case_updated"?"bg-blue-500/15 text-blue-300 border border-blue-500/20":c.syncStatus==="script_updated"?"bg-amber-500/15 text-amber-300 border border-amber-500/20":"bg-red-500/15 text-red-300 border border-red-500/20"}`,children:[c.syncStatus==="synced"?e.jsx(xe,{size:9}):e.jsx(me,{size:9}),Z(c.syncStatus)]}),c.lastSynced&&e.jsxs("span",{className:"text-[10px] text-gray-500",children:["Synced: ",new Date(c.lastSynced).toLocaleString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})]})]})]}),e.jsx("button",{onClick:()=>{const s=c.scriptPath.replace(/\\/g,"/"),C=`/tests?file=${encodeURIComponent(s)}&test=${encodeURIComponent(c.testName||"")}`;window.open(C,"_blank","noopener")},className:"p-2 rounded-lg hover:bg-white/10 text-gray-400 hover:text-brand-400 transition-colors shrink-0",title:"View Script (new tab)",children:e.jsx(Ae,{size:16})})]}):e.jsxs("div",{className:"text-center py-6 text-gray-500 text-sm bg-surface-2 rounded-lg border border-white/5",children:[e.jsx(_e,{size:20,className:"mx-auto mb-1.5 opacity-50"}),"No script mapping configured",e.jsx("p",{className:"text-xs text-gray-600 mt-1",children:"Map this test case to a script in the Script Mapping screen"})]})]})]}),b==="executions"&&e.jsxs("div",{className:"space-y-4",children:[Q.length>0&&e.jsxs("div",{className:"bg-surface-2 rounded-xl border border-white/5 p-4",children:[e.jsxs("div",{className:"grid grid-cols-4 gap-4 text-center",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xl font-bold text-gray-100",children:Q.length}),e.jsx("div",{className:"text-xs text-gray-500",children:"Total Runs"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xl font-bold text-emerald-400",children:Q.filter(s=>s.status==="passed").length}),e.jsx("div",{className:"text-xs text-gray-500",children:"Passed"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xl font-bold text-red-400",children:Q.filter(s=>s.status==="failed").length}),e.jsx("div",{className:"text-xs text-gray-500",children:"Failed"})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"text-xl font-bold text-brand-400",children:[we,"%"]}),e.jsx("div",{className:"text-xs text-gray-500",children:"Pass Rate"})]})]}),e.jsx("div",{className:"mt-3 h-2 bg-surface-1 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-emerald-500 rounded-full transition-all",style:{width:`${we}%`}})})]}),Q.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx(at,{className:"w-8 h-8 text-gray-600 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-gray-500",children:"No executions yet"}),e.jsx("p",{className:"text-xs text-gray-600 mt-1",children:"This test case has not been executed in any cycle."})]}):e.jsx("div",{className:"space-y-2",children:Q.map(s=>{var Se,J;const C=h===s.executionId,L={passed:"bg-emerald-500/10 text-emerald-400 border-emerald-500/20",failed:"bg-red-500/10 text-red-400 border-red-500/20",blocked:"bg-orange-500/10 text-orange-400 border-orange-500/20",skipped:"bg-gray-500/10 text-gray-400 border-gray-500/20",not_run:"bg-slate-500/10 text-slate-400 border-slate-500/20",in_progress:"bg-blue-500/10 text-blue-400 border-blue-500/20"},W={passed:e.jsx(ea,{className:"w-4 h-4 text-emerald-400"}),failed:e.jsx(ft,{className:"w-4 h-4 text-red-400"}),blocked:e.jsx(me,{className:"w-4 h-4 text-orange-400"}),skipped:e.jsx(Xs,{className:"w-4 h-4 text-gray-400"}),not_run:e.jsx(Fe,{className:"w-4 h-4 text-slate-400"})},be=s.executedAt?Je(s.executedAt):"—",ke=s.duration?`${s.duration}s`:"—";return e.jsxs("div",{className:"bg-surface-2 rounded-xl border border-white/5 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 cursor-pointer hover:bg-white/[0.02] transition-colors",onClick:()=>d(C?null:s.executionId),children:[C?e.jsx(ne,{className:"w-4 h-4 text-gray-500 shrink-0"}):e.jsx(qe,{className:"w-4 h-4 text-gray-500 shrink-0"}),W[s.status]||e.jsx(Fe,{className:"w-4 h-4 text-gray-500"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-sm font-medium text-gray-200 truncate",children:s.planName||"Plan"}),e.jsx(je,{className:"w-3 h-3 text-gray-600 shrink-0"}),e.jsx("span",{className:"text-sm text-gray-300 truncate",children:s.cycleName||"Cycle"})]}),e.jsxs("div",{className:"flex items-center gap-3 mt-0.5 text-xs text-gray-500",children:[e.jsx("span",{children:be}),s.executedBy&&e.jsxs("span",{children:["by ",s.executedBy]}),s.duration>0&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(Ws,{className:"w-3 h-3"})," ",ke]})]})]}),e.jsx("span",{className:`text-xs px-2.5 py-1 rounded-full border font-medium capitalize ${L[s.status]||L.not_run}`,children:(s.status||"not_run").replace("_"," ")}),((Se=s.stepSummary)==null?void 0:Se.total)>0&&e.jsxs("span",{className:"text-[10px] text-gray-500 shrink-0",children:[s.stepSummary.passed,"/",s.stepSummary.total," steps"]}),s.defect&&e.jsxs("span",{className:`text-[10px] px-2 py-0.5 rounded border flex items-center gap-1 shrink-0 ${s.defect.status==="open"?"bg-red-500/10 text-red-400 border-red-500/20":s.defect.status==="resolved"?"bg-emerald-500/10 text-emerald-400 border-emerald-500/20":"bg-amber-500/10 text-amber-400 border-amber-500/20"}`,children:[e.jsx(lt,{className:"w-3 h-3"}),s.defect.id]})]}),C&&e.jsxs("div",{className:"border-t border-white/5 px-4 py-3 bg-surface-1/50",children:[((J=s.stepResults)==null?void 0:J.length)>0?e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-white/5",children:[e.jsx("th",{className:"text-left px-3 py-2 text-gray-500 font-medium w-8",children:"#"}),e.jsx("th",{className:"text-left px-3 py-2 text-gray-500 font-medium w-16",children:"Status"}),e.jsx("th",{className:"text-left px-3 py-2 text-gray-500 font-medium",children:"Action"}),e.jsx("th",{className:"text-left px-3 py-2 text-gray-500 font-medium",children:"Expected"}),e.jsx("th",{className:"text-left px-3 py-2 text-gray-500 font-medium",children:"Actual"})]})}),e.jsx("tbody",{children:s.stepResults.map((q,Ie)=>e.jsxs("tr",{className:`border-b border-white/5 ${q.status==="failed"?"bg-red-500/5":""}`,children:[e.jsx("td",{className:"px-3 py-2 text-gray-600 font-mono",children:q.stepNumber}),e.jsx("td",{className:"px-3 py-2",children:e.jsx("span",{className:`inline-flex items-center gap-1 ${q.status==="passed"?"text-emerald-400":q.status==="failed"?"text-red-400":q.status==="blocked"?"text-orange-400":"text-gray-500"}`,children:q.status==="passed"?"✅":q.status==="failed"?"❌":q.status==="blocked"?"🚫":q.status==="skipped"?"⏭":"⬜"})}),e.jsx("td",{className:"px-3 py-2 text-gray-300 max-w-[180px]",children:e.jsx("span",{className:"line-clamp-2",children:q.action||"—"})}),e.jsx("td",{className:"px-3 py-2 text-gray-400 max-w-[150px]",children:e.jsx("span",{className:"line-clamp-2",children:q.expectedResult||"—"})}),e.jsx("td",{className:`px-3 py-2 max-w-[150px] ${q.status==="failed"?"text-red-400 font-medium":"text-gray-400"}`,children:e.jsx("span",{className:"line-clamp-2",children:q.actualResult||"—"})})]},Ie))})]})}):e.jsx("p",{className:"text-xs text-gray-500 text-center py-4",children:"No step-level results recorded for this execution."}),s.defect&&e.jsxs("div",{className:`mt-3 p-3 rounded-lg border flex items-center gap-2 ${s.defect.status==="open"?"bg-red-500/5 border-red-500/20":s.defect.status==="resolved"?"bg-emerald-500/5 border-emerald-500/20":"bg-amber-500/5 border-amber-500/20"}`,children:[e.jsx(lt,{className:"w-4 h-4 text-red-400 shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("span",{className:"text-xs font-medium text-gray-200",children:s.defect.id}),e.jsx("span",{className:"text-xs text-gray-400 ml-2 truncate",children:s.defect.title})]}),e.jsx("span",{className:`text-[10px] px-2 py-0.5 rounded-full capitalize ${s.defect.status==="open"?"bg-red-500/10 text-red-400":s.defect.status==="resolved"?"bg-emerald-500/10 text-emerald-400":"bg-amber-500/10 text-amber-400"}`,children:s.defect.status.replace("_"," ")}),e.jsx("span",{className:"text-[10px] text-gray-500 capitalize",children:s.defect.severity})]}),s.comments&&e.jsxs("div",{className:"mt-3 p-3 rounded-lg bg-surface-2 border border-white/5",children:[e.jsx("span",{className:"text-[10px] font-medium text-gray-500 uppercase tracking-wider",children:"Execution Notes"}),e.jsx("p",{className:"text-xs text-gray-300 mt-1",children:s.comments})]})]})]},s.executionId)})})]})]})]})]})}function oa({folders:t,count:y,onMove:u,onClose:g}){const[p,b]=o.useState(""),v=(d,j=0)=>{const f=[];for(const c of d)f.push({id:c.id,name:c.name,depth:j}),c.children&&f.push(...v(c.children,j+1));return f},h=v(t||[]);return e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[e.jsx("div",{className:"absolute inset-0 bg-black/60",onClick:g}),e.jsxs("div",{className:"relative bg-surface-1 rounded-xl border border-white/10 p-6 w-96 animate-fade-in",children:[e.jsxs("h3",{className:"text-base font-semibold text-gray-100 mb-1",children:["Move ",y," Test Case",y>1?"s":""]}),e.jsx("p",{className:"text-sm text-gray-400 mb-4",children:"Select a destination folder"}),e.jsxs("select",{className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 outline-none focus:border-brand-500 mb-4",value:p,onChange:d=>b(d.target.value),children:[e.jsx("option",{value:"",children:"Select folder..."}),h.map(d=>e.jsxs("option",{value:d.id,children:[" ".repeat(d.depth),d.name]},d.id))]}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx("button",{onClick:g,className:"px-4 py-2 text-sm rounded-lg bg-surface-2 hover:bg-surface-3 text-gray-300",children:"Cancel"}),e.jsx("button",{onClick:()=>{p&&u(p)},disabled:!p,className:"px-4 py-2 text-sm rounded-lg bg-brand-600 hover:bg-brand-500 text-white font-medium disabled:opacity-50",children:"Move"})]})]})]})}function ca({tags:t,count:y,onApply:u,onClose:g}){const[p,b]=o.useState(new Set),v=h=>{const d=new Set(p);d.has(h)?d.delete(h):d.add(h),b(d)};return e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[e.jsx("div",{className:"absolute inset-0 bg-black/60",onClick:g}),e.jsxs("div",{className:"relative bg-surface-1 rounded-xl border border-white/10 p-6 w-96 animate-fade-in",children:[e.jsxs("h3",{className:"text-base font-semibold text-gray-100 mb-1",children:["Tag ",y," Test Case",y>1?"s":""]}),e.jsx("p",{className:"text-sm text-gray-400 mb-4",children:"Select tags to apply"}),e.jsxs("div",{className:"flex flex-wrap gap-2 mb-4 max-h-48 overflow-y-auto",children:[t==null?void 0:t.map(h=>e.jsxs("button",{onClick:()=>v(h.id),className:`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium transition-colors border ${p.has(h.id)?"border-brand-500 bg-brand-500/20 text-brand-300":"border-white/10 bg-surface-2 text-gray-400 hover:text-gray-300"}`,children:[p.has(h.id)&&e.jsx(pe,{size:12}),h.name]},h.id)),(!t||t.length===0)&&e.jsx("p",{className:"text-sm text-gray-500",children:"No tags available. Create tags first."})]}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx("button",{onClick:g,className:"px-4 py-2 text-sm rounded-lg bg-surface-2 hover:bg-surface-3 text-gray-300",children:"Cancel"}),e.jsx("button",{onClick:()=>u(Array.from(p)),disabled:p.size===0,className:"px-4 py-2 text-sm rounded-lg bg-brand-600 hover:bg-brand-500 text-white font-medium disabled:opacity-50",children:"Apply Tags"})]})]})]})}function xa({title:t,message:y,confirmLabel:u="Delete",onConfirm:g,onCancel:p}){return e.jsx("div",{className:"fixed inset-0 z-[110] flex items-center justify-center bg-black/60 backdrop-blur-sm animate-fade-in",children:e.jsxs("div",{className:"bg-surface-2 border border-border-1 rounded-2xl shadow-2xl w-full max-w-md mx-4 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-3 px-6 pt-6 pb-2",children:[e.jsx("div",{className:"flex items-center justify-center w-10 h-10 rounded-full bg-red-500/15",children:e.jsx(me,{size:20,className:"text-red-400"})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-100",children:t})]}),e.jsx("div",{className:"px-6 py-4",children:e.jsx("p",{className:"text-sm text-gray-400 leading-relaxed",children:y})}),e.jsxs("div",{className:"flex items-center justify-end gap-3 px-6 py-4 border-t border-border-1 bg-surface-1/50",children:[e.jsx("button",{onClick:p,className:"px-4 py-2 text-sm font-medium text-gray-300 bg-surface-1 border border-border-1 rounded-lg hover:bg-surface-2 hover:text-gray-100 transition-colors",children:"Cancel"}),e.jsx("button",{onClick:g,className:"px-4 py-2 text-sm font-medium text-white bg-red-600 rounded-lg hover:bg-red-500 transition-colors shadow-lg shadow-red-600/20",children:u})]})]})})}function ma({tags:t,selectedIds:y,onChange:u}){var i;const[g,p]=o.useState(!1),[b,v]=o.useState(""),h=o.useRef(null);o.useEffect(()=>{if(!g)return;const r=x=>{h.current&&!h.current.contains(x.target)&&p(!1)};return document.addEventListener("mousedown",r),()=>document.removeEventListener("mousedown",r)},[g]);const d=o.useMemo(()=>{const r=b.trim().toLowerCase();return r?t.filter(x=>x.name.toLowerCase().includes(r)):t},[t,b]),j=r=>{const x=new Set(y);x.has(r)?x.delete(r):x.add(r),u(x)},f=r=>{r.stopPropagation(),u(new Set)},c=y.size,N=c===0?"Tags":c===1?((i=t.find(r=>r.id===Array.from(y)[0]))==null?void 0:i.name)||"1 tag":`${c} tags`;return e.jsxs("div",{ref:h,className:"relative",children:[e.jsxs("button",{type:"button",onClick:()=>p(r=>!r),className:`flex items-center gap-1.5 bg-surface-1 border rounded-lg px-3 py-2 text-sm outline-none transition-colors ${c>0?"border-brand-500/40 text-gray-200":"border-white/10 text-gray-300 hover:border-white/20"}`,children:[e.jsx(bt,{size:13,className:c>0?"text-brand-400":"text-gray-500"}),e.jsx("span",{children:N}),c>0?e.jsx("span",{onClick:f,role:"button",className:"ml-0.5 p-0.5 rounded hover:bg-white/10 text-gray-400 hover:text-gray-200",title:"Clear tag filter",children:e.jsx(ee,{size:12})}):e.jsx(ne,{size:12,className:"text-gray-500"})]}),g&&e.jsxs("div",{className:"absolute left-0 top-full mt-1 z-40 w-64 bg-surface-1 border border-white/10 rounded-lg shadow-xl overflow-hidden",children:[e.jsx("div",{className:"p-2 border-b border-white/5",children:e.jsxs("div",{className:"relative",children:[e.jsx($e,{size:12,className:"absolute left-2 top-1/2 -translate-y-1/2 text-gray-500"}),e.jsx("input",{autoFocus:!0,value:b,onChange:r=>v(r.target.value),placeholder:"Search tags…",className:"w-full bg-surface-2 border border-white/10 rounded pl-7 pr-2 py-1.5 text-xs text-gray-200 outline-none focus:border-brand-500"})]})}),e.jsx("div",{className:"max-h-64 overflow-y-auto py-1",children:d.length===0?e.jsx("div",{className:"px-3 py-3 text-xs text-gray-500 text-center",children:"No tags found"}):d.map(r=>{const x=y.has(r.id);return e.jsxs("button",{type:"button",onClick:()=>j(r.id),className:`w-full flex items-center gap-2 px-3 py-1.5 text-xs text-left transition-colors ${x?"bg-brand-500/10 text-gray-100":"text-gray-300 hover:bg-surface-2"}`,children:[e.jsx("span",{className:`w-3.5 h-3.5 rounded border flex items-center justify-center flex-shrink-0 ${x?"bg-brand-600 border-brand-500 text-white":"border-white/20"}`,children:x&&e.jsx(pe,{size:10})}),r.color&&e.jsx("span",{className:"w-2 h-2 rounded-full flex-shrink-0",style:{background:r.color}}),e.jsx("span",{className:"truncate",children:r.name})]},r.id)})}),c>0&&e.jsxs("div",{className:"border-t border-white/5 px-2 py-1.5 flex items-center justify-between",children:[e.jsxs("span",{className:"text-[10px] text-gray-500",children:[c," selected"]}),e.jsx("button",{type:"button",onClick:()=>u(new Set),className:"text-[10px] text-gray-400 hover:text-gray-200 px-2 py-0.5 rounded hover:bg-white/5",children:"Clear all"})]})]})]})}function ua({sources:t,selectedId:y,onChange:u}){const[g,p]=o.useState(!1),[b,v]=o.useState(""),h=o.useRef(null),[d,j]=o.useState(!1);o.useEffect(()=>{var m;if(!g)return;const r=(m=h.current)==null?void 0:m.getBoundingClientRect();if(!r)return;const z=r.left+288+16>window.innerWidth;j(z)},[g]),o.useEffect(()=>{if(!g)return;const r=x=>{h.current&&!h.current.contains(x.target)&&p(!1)};return document.addEventListener("mousedown",r),()=>document.removeEventListener("mousedown",r)},[g]);const f=o.useMemo(()=>{const r=b.trim().toLowerCase();return r?t.filter(x=>x.title.toLowerCase().includes(r)):t},[t,b]),c=t.find(r=>r.id===y)||null,N={requirement:"Requirement",nlp:"Notes",jira:"JIRA",document:"Document"},i=c?c.title:"Source";return e.jsxs("div",{ref:h,className:"relative",children:[e.jsxs("button",{type:"button",onClick:()=>p(r=>!r),className:`flex items-center gap-1.5 bg-surface-1 border rounded-lg px-3 py-2 text-sm outline-none transition-colors max-w-[220px] ${c?"border-brand-500/40 text-gray-200":"border-white/10 text-gray-300 hover:border-white/20"}`,children:[e.jsx(Us,{size:13,className:c?"text-brand-400":"text-gray-500"}),e.jsx("span",{className:"truncate",children:i}),c?e.jsx("span",{onClick:r=>{r.stopPropagation(),u(null)},role:"button",className:"ml-0.5 p-0.5 rounded hover:bg-white/10 text-gray-400 hover:text-gray-200 flex-shrink-0",title:"Clear source filter",children:e.jsx(ee,{size:12})}):e.jsx(ne,{size:12,className:"text-gray-500 flex-shrink-0"})]}),g&&e.jsxs("div",{className:`absolute top-full mt-1 z-40 w-72 bg-surface-1 border border-white/10 rounded-lg shadow-xl overflow-hidden ${d?"right-0":"left-0"}`,children:[e.jsx("div",{className:"p-2 border-b border-white/5",children:e.jsxs("div",{className:"relative",children:[e.jsx($e,{size:12,className:"absolute left-2 top-1/2 -translate-y-1/2 text-gray-500"}),e.jsx("input",{autoFocus:!0,value:b,onChange:r=>v(r.target.value),placeholder:"Search sources…",className:"w-full bg-surface-2 border border-white/10 rounded pl-7 pr-2 py-1.5 text-xs text-gray-200 outline-none focus:border-brand-500"})]})}),e.jsx("div",{className:"max-h-64 overflow-y-auto py-1",children:f.length===0?e.jsx("div",{className:"px-3 py-3 text-xs text-gray-500 text-center",children:t.length===0?"No sources have linked test cases yet":"No sources match your search"}):f.map(r=>{const x=r.id===y;return e.jsxs("button",{type:"button",onClick:()=>{u(x?null:r.id),p(!1)},title:r.title,className:`w-full flex items-center gap-2 px-3 py-1.5 text-xs text-left transition-colors ${x?"bg-brand-500/10 text-gray-100":"text-gray-300 hover:bg-surface-2"}`,children:[e.jsx("span",{className:"flex-1 min-w-0 truncate",children:r.title}),e.jsxs("span",{title:`${N[r.type]||r.type} · ${r.testCaseCount} test case${r.testCaseCount===1?"":"s"}`,className:"text-[10px] text-gray-500 flex-shrink-0",children:[N[r.type]||r.type," · ",r.testCaseCount]}),x&&e.jsx(pe,{size:12,className:"text-brand-300 flex-shrink-0"})]},r.id)})})]})]})}function $a(){var Qe,We,Ye;const{toast:t}=ht(),y=o.useCallback((a,R="success")=>{t(R,a)},[t]),{user:u}=Ds(),g=(u==null?void 0:u.displayName)||(u==null?void 0:u.username)||"",[p,b]=o.useState(null),[v,h]=o.useState(""),[d,j]=o.useState(!1);o.useEffect(()=>{if(!d)return;const a=R=>{R.key==="Escape"&&j(!1)};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[d]);const[f,c]=o.useState({}),[N,i]=o.useState(new Set),[r,x]=o.useState(null),{data:T}=ts(),z=(T==null?void 0:T.sources)??[],[m,I]=o.useState(new Set),[D,G]=o.useState(!1),[U,A]=o.useState(null),[l]=Qt("tcId"),P=Wt(),[K,M]=o.useState(!1),[_,B]=o.useState(""),[E,F]=o.useState(1),[Y,n]=o.useState(!1),[w,k]=o.useState(!1),[S,V]=o.useState("createdAt"),[le,Ne]=o.useState("desc"),[se,X]=o.useState(null),{data:he,isLoading:Le}=ss(),te=(he==null?void 0:he.tree)||[],Q=as(),we=rs(),{data:ge}=ns(),ie=(ge==null?void 0:ge.tags)||[],{data:O}=ls(),{data:s}=is(),C=(s==null?void 0:s.dots)||{},L=Xt(v,250),[W,be]=o.useState(L),ke=W===L?E:1;o.useEffect(()=>{W!==L&&(be(L),F(1))},[L,W]);const Se=o.useMemo(()=>{const a={page:ke,limit:Ce,sort:S,order:le};return p&&(a.folderId=p),p==="__uncategorized__"&&(a.folderId=null),L.trim()&&(a.search=L.trim()),f.priority&&(a.priority=f.priority),f.type&&(a.type=f.type),f.status&&(a.status=f.status),f.automationStatus&&(a.automationStatus=f.automationStatus),f.reviewStatus&&(a.reviewStatus=f.reviewStatus),N.size>0&&(a.tagIds=Array.from(N)),r&&(a.sourceId=r),a},[p,L,f,N,r,ke,S,le]),{data:J,isLoading:q}=ds(Se),Ie=os(),At=cs(),Mt=xs(),Te=ms(),Rt=us(),H=(J==null?void 0:J.testCases)||[],ae=(J==null?void 0:J.total)||H.length,re=Math.ceil(ae/Ce)||1,Ge=((Qe=J==null?void 0:J.aggregates)==null?void 0:Qe.byPriority)||{},Dt=((We=J==null?void 0:J.aggregates)==null?void 0:We.byAutomation)||{},Ke=o.useMemo(()=>{if(!l)return null;const a=l.toLowerCase();return H.find(R=>{var $;return(($=R.id)==null?void 0:$.toLowerCase())===a})||null},[l,H]),{data:$t}=ps(l&&!Ke?l:null),Ve=Ke||($t??null),He=()=>{_.trim()&&(Q.mutate({name:_.trim(),parentId:p}),B(""),M(!1))},Et=a=>{X({title:"Delete Folder",message:"Are you sure you want to delete this folder? All test cases inside it will become uncategorized. This action cannot be undone.",confirmLabel:"Delete Folder",onConfirm:()=>{we.mutate(a),p===a&&b(null),X(null)}})},Lt=a=>{X({title:"Delete Test Case",message:"Are you sure you want to delete this test case? This action cannot be undone and all associated versions, steps, and data will be permanently removed.",confirmLabel:"Delete Test Case",onConfirm:()=>{Ie.mutate(a),I(R=>{const $=new Set(R);return $.delete(a),$}),X(null)}})},It=()=>{m.size!==0&&X({title:"Delete Selected Test Cases",message:`Are you sure you want to delete ${m.size} selected test case(s)? This action cannot be undone and all associated data will be permanently removed.`,confirmLabel:`Delete ${m.size} Test Case(s)`,onConfirm:()=>{At.mutate(Array.from(m)),I(new Set),X(null)}})},_t=a=>{Mt.mutate({ids:Array.from(m),folderId:a}),I(new Set),n(!1)},Ft=a=>{Rt.mutate({ids:Array.from(m),tagIds:a}),I(new Set),k(!1)},Pt=a=>{I(R=>{const $=new Set(R);return $.has(a)?$.delete(a):$.add(a),$})},Bt=()=>{m.size===H.length?I(new Set):I(new Set(H.map(a=>a.id)))},Ut=a=>{S===a?Ne(R=>R==="asc"?"desc":"asc"):(V(a),Ne("asc"))},fe=(a,R)=>{c($=>{const de={...$};return R?de[a]=R:delete de[a],de}),F(1)},Ot=()=>{c({}),i(new Set),x(null),h(""),F(1)},ze=Object.keys(f).length+(v?1:0)+(N.size>0?1:0)+(r?1:0);((Ye=O==null?void 0:O.byAutomation)==null?void 0:Ye.automated)??(O==null||O.automatedCount);const Ze=(O==null?void 0:O.totalCases)??(O==null?void 0:O.totalCount)??ae??0,Jt=o.useMemo(()=>(te||[]).reduce((a,R)=>a+(R.testCaseCount??0),0),[te]),qt=Math.max(0,Ze-Jt);return e.jsxs("div",{className:"h-full flex flex-col bg-surface-0 animate-fade-in",children:[e.jsx("div",{className:"flex-shrink-0 border-b border-white/5 bg-surface-1",children:e.jsx("div",{className:"max-w-[1400px] mx-auto px-6 py-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold text-gray-100 flex items-center gap-3",children:[e.jsx(ce,{size:24,className:"text-brand-300"}),"Test Cases"]}),e.jsxs("div",{className:"flex items-center gap-3 mt-2",children:[e.jsx("p",{className:"text-sm text-gray-400",children:"Manage, organize, and track your test cases"}),e.jsx("span",{className:"text-xs text-gray-500",children:"|"}),e.jsxs("div",{className:"flex items-center gap-2.5 text-sm",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 bg-brand-500/15 text-brand-300 px-3 py-1 rounded-full font-medium",children:[e.jsx(Pe,{size:14}),ae," Cases"]}),(()=>{const a=Dt.automated??0,R=ae>0?Math.round(a/ae*100):0;return e.jsxs("span",{className:"inline-flex items-center gap-1.5 bg-emerald-500/15 text-emerald-300 px-3 py-1 rounded-full font-medium",children:[e.jsx(Be,{size:14}),R,"% Automated"]})})(),(()=>{const a=Ge.critical??0;return a>0?e.jsxs("span",{className:"inline-flex items-center gap-1.5 bg-red-500/15 text-red-300 px-3 py-1 rounded-full font-medium",children:[e.jsx(me,{size:14}),a," Critical"]}):null})(),(()=>{const a=Ge.high??0;return a>0?e.jsxs("span",{className:"inline-flex items-center gap-1.5 bg-orange-500/15 text-orange-300 px-3 py-1 rounded-full font-medium",children:[e.jsx(Os,{size:14}),a," High"]}):null})()]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[m.size>0&&e.jsx(Rs,{type:"test-cases",formats:["docx","xlsx","csv"],label:`Export (${m.size})`,params:{ids:Array.from(m)}}),e.jsxs("button",{onClick:()=>{A(null),G(!0)},className:"inline-flex items-center justify-center gap-2 h-9 px-4 rounded-lg border border-transparent bg-brand-600 hover:bg-brand-500 text-white text-[13px] font-medium leading-none transition-colors",children:[e.jsx(Me,{size:15}),"New Test Case"]}),e.jsxs("button",{onClick:()=>j(!0),className:"inline-flex items-center justify-center gap-2 h-9 px-4 rounded-lg border border-white/10 text-gray-300 hover:text-gray-100 hover:border-white/20 hover:bg-white/[0.03] text-[13px] font-medium leading-none transition-colors",title:"Import test cases from a file or another tool, or export this catalogue",children:[e.jsx(et,{size:15}),"Import / Export"]})]})]})})}),e.jsxs("div",{className:"flex-1 flex min-h-0",children:[e.jsxs("div",{className:"w-72 flex-shrink-0 border-r border-white/5 flex flex-col bg-surface-0",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-white/5",children:[e.jsx("span",{className:"text-sm font-semibold text-gray-300 uppercase tracking-wider",children:"Folders"}),e.jsx("button",{onClick:()=>M(!K),className:"p-1.5 rounded-lg hover:bg-surface-2 text-gray-400 hover:text-brand-300 transition-colors",title:"Add folder",children:e.jsx(Js,{size:16})})]}),K&&e.jsx("div",{className:"px-3 py-2 border-b border-white/5",children:e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx("input",{className:"flex-1 bg-surface-2 border border-white/10 rounded-lg px-2.5 py-1.5 text-sm text-gray-200 outline-none focus:border-brand-500",placeholder:"Folder name...",value:_,onChange:a=>B(a.target.value),onKeyDown:a=>{a.key==="Enter"&&He(),a.key==="Escape"&&M(!1)},autoFocus:!0}),e.jsx("button",{onClick:He,disabled:!_.trim(),className:"p-1.5 rounded-lg bg-brand-600 hover:bg-brand-500 text-white disabled:opacity-40",children:e.jsx(pe,{size:14})})]})}),e.jsxs("div",{className:"flex-1 overflow-y-auto py-2 px-2 space-y-0.5",children:[e.jsxs("button",{onClick:()=>{b(null),F(1)},className:`w-full flex items-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors ${p===null?"bg-brand-500/15 text-brand-300":"text-gray-300 hover:bg-surface-2"}`,children:[e.jsx(qs,{size:15}),e.jsx("span",{className:"flex-1 text-left",children:"All Test Cases"}),e.jsx("span",{className:"text-xs text-gray-500",children:Ze})]}),Le?e.jsx("div",{className:"px-3 py-6 text-center text-sm text-gray-500",children:"Loading folders..."}):e.jsx(e.Fragment,{children:(te||[]).map(a=>e.jsx(zt,{node:a,depth:0,selectedFolderId:p,onSelect:R=>{b(R),F(1)},onEdit:()=>{},onDelete:Et},a.id))}),e.jsxs("button",{onClick:()=>{b("__uncategorized__"),F(1)},className:`w-full flex items-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors mt-1 ${p==="__uncategorized__"?"bg-brand-500/15 text-brand-300":"text-gray-400 hover:bg-surface-2"}`,children:[e.jsx(ve,{size:15,className:"text-gray-500"}),e.jsx("span",{className:"flex-1 text-left",children:"Uncategorized"}),e.jsx("span",{className:"text-xs text-gray-500",children:qt})]})]})]}),e.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[e.jsxs("div",{className:"flex-shrink-0 px-5 py-3 border-b border-white/5 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsxs("div",{className:"relative flex-1 min-w-[200px] max-w-md",children:[e.jsx($e,{size:15,className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-500"}),e.jsx("input",{className:"w-full bg-surface-1 border border-white/10 rounded-lg pl-9 pr-3 py-2 text-sm text-gray-200 outline-none focus:border-brand-500 transition-colors placeholder-gray-500",placeholder:"Search test cases...",value:v,onChange:a=>h(a.target.value)})]}),e.jsxs("select",{className:"bg-surface-1 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-300 outline-none focus:border-brand-500",value:f.priority||"",onChange:a=>fe("priority",a.target.value),children:[e.jsx("option",{value:"",children:"Priority"}),Nt.map(a=>e.jsx("option",{value:a,children:Z(a)},a))]}),e.jsxs("select",{className:"bg-surface-1 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-300 outline-none focus:border-brand-500",value:f.type||"",onChange:a=>fe("type",a.target.value),children:[e.jsx("option",{value:"",children:"Type"}),wt.map(a=>e.jsx("option",{value:a,children:Z(a)},a))]}),e.jsxs("select",{className:"bg-surface-1 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-300 outline-none focus:border-brand-500",value:f.status||"",onChange:a=>fe("status",a.target.value),children:[e.jsx("option",{value:"",children:"Status"}),kt.map(a=>e.jsx("option",{value:a,children:Z(a)},a))]}),e.jsxs("select",{className:"bg-surface-1 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-300 outline-none focus:border-brand-500",value:f.automationStatus||"",onChange:a=>fe("automationStatus",a.target.value),children:[e.jsx("option",{value:"",children:"Automation"}),St.map(a=>e.jsx("option",{value:a,children:Re[a]},a))]}),e.jsxs("select",{className:"bg-surface-1 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-300 outline-none focus:border-brand-500",value:f.reviewStatus||"",onChange:a=>fe("reviewStatus",a.target.value),children:[e.jsx("option",{value:"",children:"Review"}),Tt.map(a=>e.jsx("option",{value:a,children:De[a]},a))]}),e.jsx(ma,{tags:ie||[],selectedIds:N,onChange:a=>{i(a),F(1)}}),e.jsx(ua,{sources:z,selectedId:r,onChange:a=>{x(a),F(1)}}),ze>0&&e.jsxs("button",{onClick:Ot,className:"flex items-center gap-1 px-3 py-2 text-sm text-gray-400 hover:text-gray-200 transition-colors",children:[e.jsx(ee,{size:14}),"Clear (",ze,")"]})]}),m.size>0&&e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 bg-brand-500/10 rounded-lg border border-brand-500/20",children:[e.jsxs("span",{className:"text-sm font-medium text-brand-300",children:[m.size," selected"]}),e.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[e.jsxs("button",{onClick:()=>n(!0),className:"flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-lg bg-surface-2 hover:bg-surface-3 text-gray-300 border border-white/10 transition-colors",children:[e.jsx(Gs,{size:14}),"Move"]}),e.jsxs("button",{onClick:()=>k(!0),className:"flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-lg bg-surface-2 hover:bg-surface-3 text-gray-300 border border-white/10 transition-colors",children:[e.jsx(bt,{size:14}),"Tag"]}),e.jsxs("button",{onClick:()=>Te.mutate({ids:Array.from(m),reviewStatus:"approved"},{onError:a=>t("error",(a==null?void 0:a.message)||"Could not approve the test cases")}),disabled:Te.isPending,title:"Mark the selected test cases as approved",className:"flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-lg bg-surface-2 hover:bg-surface-3 text-emerald-300 border border-white/10 transition-colors disabled:opacity-50",children:[e.jsx(xe,{size:14}),"Approve"]}),e.jsxs("button",{onClick:()=>Te.mutate({ids:Array.from(m),reviewStatus:"rejected"},{onError:a=>t("error",(a==null?void 0:a.message)||"Could not reject the test cases")}),disabled:Te.isPending,title:"Mark the selected test cases as rejected — they are left out of quick plans",className:"flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-lg bg-surface-2 hover:bg-surface-3 text-amber-300 border border-white/10 transition-colors disabled:opacity-50",children:[e.jsx(ft,{size:14}),"Reject"]}),e.jsx(Ps,{ids:Array.from(m)}),e.jsxs("button",{onClick:It,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-lg bg-red-600/80 hover:bg-red-600 text-white transition-colors",children:[e.jsx(ue,{size:14}),"Delete"]}),e.jsx("button",{onClick:()=>I(new Set),className:"p-1.5 rounded-lg hover:bg-white/10 text-gray-400 hover:text-gray-200",children:e.jsx(ee,{size:14})})]})]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[q?e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"w-8 h-8 border-2 border-brand-500 border-t-transparent rounded-full animate-spin mx-auto mb-3"}),e.jsx("p",{className:"text-sm text-gray-400",children:"Loading test cases..."})]})}):H.length===0?e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsxs("div",{className:"text-center",children:[e.jsx(ce,{size:40,className:"mx-auto mb-3 text-gray-600"}),e.jsx("h3",{className:"text-base font-medium text-gray-300 mb-1",children:"No test cases found"}),e.jsx("p",{className:"text-sm text-gray-500 mb-4",children:ze>0?"Try adjusting your filters":"Create your first test case to get started"}),ze===0&&e.jsxs("button",{onClick:()=>{A(null),G(!0)},className:"inline-flex items-center gap-2 px-4 py-2 rounded-lg bg-brand-600 hover:bg-brand-500 text-white text-sm font-medium transition-colors",children:[e.jsx(Me,{size:15}),"New Test Case"]})]})}):e.jsxs("div",{className:"rounded-xl border border-white/10 overflow-hidden bg-surface-1 shadow-sm",children:[e.jsxs("div",{className:"grid grid-cols-[40px_1fr_90px_100px_80px_105px_90px_130px_90px] bg-surface-2/80 border-b border-white/10",children:[e.jsx("div",{className:"px-3 py-3 flex items-center justify-center",children:e.jsx("button",{onClick:Bt,role:"checkbox","aria-checked":m.size===H.length&&H.length>0,"aria-label":"Select all test cases on this page",className:"text-gray-400 hover:text-gray-200",children:m.size===H.length&&H.length>0?e.jsx(tt,{size:15,className:"text-brand-500"}):e.jsx(st,{size:15})})}),e.jsx("div",{className:"px-3 py-3",children:e.jsxs("button",{onClick:()=>Ut("title"),className:"flex items-center gap-1.5 text-[11px] font-semibold text-gray-400 uppercase tracking-wider hover:text-gray-200 transition-colors",children:["Test Case",e.jsx(Ks,{size:11,className:"opacity-60"})]})}),e.jsx("div",{className:"px-3 py-3",children:e.jsx("span",{className:"text-[11px] font-semibold text-gray-400 uppercase tracking-wider",children:"Priority"})}),e.jsx("div",{className:"px-3 py-3",children:e.jsx("span",{className:"text-[11px] font-semibold text-gray-400 uppercase tracking-wider",children:"Type"})}),e.jsx("div",{className:"px-3 py-3",children:e.jsx("span",{className:"text-[11px] font-semibold text-gray-400 uppercase tracking-wider",children:"Status"})}),e.jsx("div",{className:"px-3 py-3",children:e.jsx("span",{className:"text-[11px] font-semibold text-gray-400 uppercase tracking-wider",children:"Automation"})}),e.jsx("div",{className:"px-3 py-3",children:e.jsx("span",{className:"text-[11px] font-semibold text-gray-400 uppercase tracking-wider",children:"Review"})}),e.jsx("div",{className:"px-3 py-3",children:e.jsx("span",{className:"text-[11px] font-semibold text-gray-400 uppercase tracking-wider",children:"Executions"})}),e.jsx("div",{className:"px-3 py-3 text-center",children:e.jsx("span",{className:"text-[11px] font-semibold text-gray-400 uppercase tracking-wider",children:"Actions"})})]}),H.map((a,R)=>{var de;const $=m.has(a.id);return e.jsxs("div",{className:`grid grid-cols-[40px_1fr_90px_100px_80px_105px_90px_130px_90px] border-b border-white/5 last:border-b-0 transition-all group ${$?"bg-brand-500/10 border-l-2 border-l-brand-500":R%2===0?"bg-surface-1 hover:bg-white/[0.02]":"bg-surface-2/30 hover:bg-white/[0.04]"}`,children:[e.jsx("div",{className:"px-3 py-3.5 flex items-center justify-center",children:e.jsx("button",{onClick:()=>Pt(a.id),role:"checkbox","aria-checked":$,"aria-label":`Select ${a.title||a.id}`,className:"text-gray-400 hover:text-gray-200 transition-colors",children:$?e.jsx(tt,{size:15,className:"text-brand-500"}):e.jsx(st,{size:15,className:"group-hover:text-gray-300"})})}),e.jsxs("div",{className:"px-3 py-3.5 min-w-0",children:[e.jsx("button",{onClick:()=>P({tcId:a.id,detail:null}),className:"text-sm text-gray-200 hover:text-brand-300 transition-colors text-left font-medium leading-snug line-clamp-2 w-full",children:a.title}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[a.id&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] text-gray-500 font-mono",children:[e.jsx(yt,{size:10,className:"flex-shrink-0"}),a.id]}),e.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] text-gray-500",children:[e.jsx(ve,{size:10,className:"flex-shrink-0"}),((de=a.folder)==null?void 0:de.name)||"Uncategorized"]}),a.steps&&a.steps.length>0&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] text-gray-500",children:[e.jsx(ce,{size:10,className:"flex-shrink-0"}),a.steps.length," step",a.steps.length!==1?"s":""]})]})]}),e.jsx("div",{className:"px-3 py-3.5 flex items-center",children:e.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-md text-[11px] font-semibold ${a.priority==="critical"?"bg-red-500/20 text-red-300":a.priority==="high"?"bg-orange-500/20 text-orange-300":a.priority==="medium"?"bg-amber-500/20 text-amber-300":"bg-emerald-500/20 text-emerald-300"}`,children:Z(a.priority||"medium")})}),e.jsx("div",{className:"px-3 py-3.5 flex items-center",children:e.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-md text-[11px] font-semibold ${Oe[a.type]||"bg-gray-500/20 text-gray-300"}`,children:Z(a.type||"web")})}),e.jsx("div",{className:"px-3 py-3.5 flex items-center",children:e.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-md text-[11px] font-semibold ${a.status==="active"?"bg-brand-500/20 text-brand-300":a.status==="draft"?"bg-gray-500/20 text-gray-300":a.status==="deprecated"?"bg-red-500/20 text-red-300":"bg-slate-500/20 text-slate-400"}`,children:Z(a.status||"draft")})}),e.jsx("div",{className:"px-3 py-3.5 flex items-center",children:e.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-md text-[11px] font-semibold ${a.automationStatus==="automated"?"bg-emerald-500/20 text-emerald-300":a.automationStatus==="needs_update"?"bg-amber-500/20 text-amber-300":"bg-gray-500/20 text-gray-400"}`,children:[e.jsx(Be,{size:10}),Re[a.automationStatus]||"Manual"]})}),e.jsxs("div",{className:"px-3 py-3.5 flex flex-col items-start justify-center gap-1",children:[a.staleAt?e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-md text-[11px] font-semibold bg-amber-500/20 text-amber-300",title:a.staleReason||"The requirement this case was written from changed",children:[e.jsx(me,{size:10}),"Source changed"]}):null,e.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-md text-[11px] font-semibold ${a.reviewStatus==="approved"?"bg-emerald-500/20 text-emerald-300":a.reviewStatus==="rejected"?"bg-red-500/20 text-red-300":a.reviewStatus==="in_review"?"bg-sky-500/20 text-sky-300":"bg-gray-500/20 text-gray-400"}`,children:De[a.reviewStatus]||"Draft"})]}),e.jsx("div",{className:"px-3 py-3.5 flex items-center",children:(()=>{const ye=C[a.id];if(!ye||ye.length===0)return e.jsx("span",{className:"text-[10px] text-gray-600 italic",children:"No runs"});const Gt=[...ye].reverse().slice(-5),Xe={passed:"bg-emerald-300/70",failed:"bg-rose-300/70",blocked:"bg-amber-300/70",skipped:"bg-slate-300/60",in_progress:"bg-sky-300/70",not_run:"bg-gray-400/40"};return e.jsx("div",{className:"flex items-center gap-1.5",title:`${ye.length} execution${ye.length!==1?"s":""}`,children:Gt.map((oe,Kt)=>e.jsxs("div",{className:"relative group/dot",children:[e.jsx("div",{className:`w-2.5 h-2.5 rounded-full ${Xe[oe.status]||Xe.not_run} transition-transform hover:scale-150`}),e.jsx("div",{className:"absolute bottom-full left-1/2 -translate-x-1/2 mb-2 hidden group-hover/dot:block z-50 pointer-events-none",children:e.jsxs("div",{className:"bg-surface-2 text-gray-200 text-[10px] rounded-lg px-2.5 py-1.5 whitespace-nowrap shadow-xl border border-white/10",children:[e.jsx("div",{className:"font-medium capitalize",children:oe.status.replace("_"," ")}),e.jsxs("div",{className:"text-gray-400",children:[oe.planName," > ",oe.cycleName]}),oe.executedAt&&e.jsx("div",{className:"text-gray-500",children:mt(oe.executedAt)})]})})]},Kt))})})()}),e.jsx("div",{className:"px-3 py-3.5 flex items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-0.5 opacity-40 group-hover:opacity-100 transition-opacity",children:[e.jsx("button",{onClick:()=>P({tcId:a.id,detail:null}),className:"p-1.5 rounded-lg hover:bg-brand-500/10 text-gray-400 hover:text-brand-300 transition-colors",title:"View details",children:e.jsx(Ue,{size:14})}),e.jsx("button",{onClick:()=>{A(a),G(!0)},className:"p-1.5 rounded-lg hover:bg-white/10 text-gray-400 hover:text-gray-200 transition-colors",title:"Edit",children:e.jsx(Ee,{size:14})}),e.jsx("button",{onClick:()=>Lt(a.id),className:"p-1.5 rounded-lg hover:bg-red-500/10 text-gray-400 hover:text-red-400 transition-colors",title:"Delete",children:e.jsx(ue,{size:14})})]})})]},a.id)}),e.jsxs("div",{className:"bg-surface-2/50 px-4 py-2 border-t border-white/10 flex items-center justify-between",children:[e.jsxs("span",{className:"text-[11px] text-gray-500",children:[H.length," test case",H.length!==1?"s":""," on this page"]}),m.size>0&&e.jsxs("span",{className:"text-[11px] text-brand-300 font-medium",children:[m.size," selected"]})]})]}),re>1&&e.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-t border-white/5",children:[e.jsxs("span",{className:"text-sm text-gray-400",children:["Showing ",(E-1)*Ce+1,"-",Math.min(E*Ce,ae)," of ",ae]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:()=>F(a=>Math.max(1,a-1)),disabled:E<=1,className:"px-3 py-1.5 text-sm rounded-lg bg-surface-1 hover:bg-surface-2 text-gray-300 border border-white/10 disabled:opacity-40 transition-colors",children:"Previous"}),Array.from({length:Math.min(re,7)},(a,R)=>{let $;return re<=7||E<=4?$=R+1:E>=re-3?$=re-6+R:$=E-3+R,e.jsx("button",{onClick:()=>F($),className:`w-8 h-8 text-sm rounded-lg transition-colors ${E===$?"bg-brand-600 text-white":"hover:bg-surface-2 text-gray-400"}`,children:$},$)}),e.jsx("button",{onClick:()=>F(a=>Math.min(re,a+1)),disabled:E>=re,className:"px-3 py-1.5 text-sm rounded-lg bg-surface-1 hover:bg-surface-2 text-gray-300 border border-white/10 disabled:opacity-40 transition-colors",children:"Next"})]})]})]})]})]}),d&&Vt.createPortal(e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 overflow-y-auto",children:[e.jsx("div",{className:"absolute inset-0 bg-black/60",onClick:()=>j(!1)}),e.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Import and export test cases",className:"relative bg-surface-1 rounded-2xl border border-white/10 w-[1320px] max-w-[96vw] max-h-[92vh] flex flex-col animate-fade-in",children:[e.jsxs("div",{className:"flex items-center gap-3 px-6 py-4 border-b border-white/5 flex-shrink-0",children:[e.jsx(et,{size:18,className:"text-brand-300"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h2",{className:"text-base font-semibold text-gray-100",children:"Import / Export"}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"Move test cases in from a file or another tool, or take this catalogue out."})]}),e.jsx("button",{onClick:()=>j(!1),className:"p-1.5 rounded-lg text-gray-500 hover:text-gray-200 hover:bg-white/5 transition-colors","aria-label":"Close",children:e.jsx(ee,{size:18})})]}),e.jsx("div",{className:"flex-1 overflow-y-auto px-6 py-5",children:e.jsx(Zt,{embedded:!0})})]})]}),document.body),D&&e.jsx(ra,{testCase:U,folders:te||[],tags:ie||[],onClose:()=>{G(!1),A(null)},onSaved:()=>{y(U?"Test case updated successfully":"Test case created successfully")},currentUserName:g}),Ve&&e.jsx(da,{testCase:Ve,onClose:()=>P({tcId:null,detail:null}),onEdit:a=>{P({tcId:null,detail:null}),A(a),G(!0)},currentUserName:g,onToast:y}),se&&e.jsx(xa,{title:se.title,message:se.message,confirmLabel:se.confirmLabel,onConfirm:se.onConfirm,onCancel:()=>X(null)}),Y&&e.jsx(oa,{folders:te||[],count:m.size,onMove:_t,onClose:()=>n(!1)}),w&&e.jsx(ca,{tags:ie||[],count:m.size,onApply:Ft,onClose:()=>k(!1)})]})}function pa({testCaseId:t,onLinked:y}){const{connectorId:u,isConfigured:g,baseUrl:p}=gt(),b=Ls(),v=pt(),[h,d]=o.useState(!1),[j,f]=o.useState(""),[c,N]=o.useState([]);if(!g)return null;const i=()=>{if(!u||!j.trim())return;const T=/^[A-Z][A-Z0-9]+-\d+$/i.test(j.trim())?`key = "${j.trim()}"`:`summary ~ "${j.trim()}" ORDER BY updated DESC`;b.mutate({connectorId:u,jql:T,maxResults:10},{onSuccess:z=>N((z==null?void 0:z.issues)||[])})},r=x=>{var m;const T=x.key,z=((m=x.fields)==null?void 0:m.summary)||"";v.mutate({testCaseId:t,data:{title:`${T}: ${z}`,url:_s(p,T),linkType:"jira"}},{onSuccess:()=>{d(!1),f(""),N([]),y()}})};return e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>d(!h),className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-lg bg-blue-500/10 hover:bg-blue-500/20 text-blue-400 border border-blue-500/20 transition-colors",children:[e.jsx(Ae,{size:12})," Link JIRA"]}),h&&e.jsxs("div",{className:"fixed inset-0 z-[60] flex items-center justify-center",children:[e.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:()=>d(!1)}),e.jsxs("div",{className:"relative z-10 bg-surface-1 rounded-xl border border-white/10 shadow-2xl w-full max-w-lg mx-4",children:[e.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-b border-white/5",children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-100",children:"Link JIRA Issue"}),e.jsx("button",{onClick:()=>d(!1),className:"text-gray-400 hover:text-gray-200",children:e.jsx(ee,{size:16})})]}),e.jsxs("div",{className:"p-5 space-y-3",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:j,onChange:x=>f(x.target.value),onKeyDown:x=>x.key==="Enter"&&i(),placeholder:"Search by JIRA key or text...",className:"flex-1 bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 outline-none focus:border-brand-500"}),e.jsx("button",{onClick:i,disabled:b.isPending,className:"px-4 py-2 text-sm font-medium text-white bg-blue-600 hover:bg-blue-500 rounded-lg disabled:opacity-50",children:b.isPending?e.jsx(vt,{size:14,className:"animate-spin"}):e.jsx($e,{size:14})})]}),c.length>0&&e.jsx("div",{className:"max-h-[300px] overflow-y-auto divide-y divide-white/5 border border-white/5 rounded-lg",children:c.map(x=>{var T,z,m;return e.jsxs("button",{onClick:()=>r(x),className:"w-full text-left px-4 py-3 hover:bg-brand-500/10 transition-colors flex items-center gap-3",children:[e.jsx("span",{className:"text-xs font-mono text-blue-400 shrink-0",children:x.key}),e.jsx("span",{className:"text-sm text-gray-200 truncate flex-1",children:(T=x.fields)==null?void 0:T.summary}),e.jsx("span",{className:"text-[10px] text-gray-500 shrink-0",children:(m=(z=x.fields)==null?void 0:z.status)==null?void 0:m.name})]},x.key)})}),b.isSuccess&&c.length===0&&e.jsx("p",{className:"text-xs text-gray-500 text-center py-4",children:"No issues found"})]})]})]})]})}function ha({id:t,reason:y}){const u=Bs(),{toast:g}=ht(),[p,b]=o.useState(!1);return e.jsxs("div",{className:"flex items-start gap-3 rounded-lg border border-amber-500/30 bg-amber-500/10 p-3",role:"status",children:[e.jsx(me,{size:16,className:"text-amber-300 shrink-0 mt-0.5"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-sm font-medium text-amber-200",children:"The requirement this case was written from changed"}),y?e.jsx("p",{className:"text-xs text-gray-300 mt-1 leading-relaxed break-words",children:y}):null,e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"Update the case to match, then mark it reviewed — or regenerate the changed requirements in AI Test Gen."})]}),e.jsx("button",{disabled:p,onClick:async()=>{b(!0);try{await $s([t]),u.invalidateQueries({queryKey:["tm-test-cases"]}),u.invalidateQueries({queryKey:["tm-test-case",t]}),u.invalidateQueries({queryKey:["tm-sources"]})}catch(v){g("error",(v==null?void 0:v.message)||"Could not mark the case reviewed")}finally{b(!1)}},className:"shrink-0 px-3 py-1.5 text-xs rounded-lg bg-surface-2 hover:bg-surface-3 text-gray-200 border border-white/10 disabled:opacity-50",children:"Mark reviewed"})]})}function ga({jiraUrl:t,testCaseTitle:y}){const{connectorId:u}=gt(),g=Is(),[p,b]=o.useState(!1);if(!u)return null;const v=t.match(/\/browse\/([A-Z][A-Z0-9]+-\d+)/i),h=v?v[1]:null;if(!h)return null;const d=()=>{const j=`🧪 Testver Test Case Update
5
+
6
+ Test Case: ${y}
7
+ Status: Linked in Testver
8
+ Date: ${Je(new Date)}
9
+
10
+ This test case is being tracked in Testver Test Management.`;g.mutate({connectorId:u,issueKey:h,comment:j},{onSuccess:()=>b(!0)})};return e.jsx("button",{onClick:d,disabled:g.isPending||p,className:`p-1.5 rounded-lg hover:bg-white/10 transition-colors ${p?"text-emerald-400":"text-gray-400 hover:text-blue-400"}`,title:p?"Comment posted to JIRA":"Post update to JIRA",children:g.isPending?e.jsx(vt,{size:14,className:"animate-spin"}):p?e.jsx(xe,{size:14}):e.jsx(Ys,{size:14})})}export{ua as SourceSingleSelectFilter,ma as TagMultiSelectFilter,$a as TestManagementPage};