@testver/testver 1.4.2 → 1.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1174 -800
- package/package.json +1 -1
- package/src/ui/static/assets/AIPanel-KQFq4c0Q.js +32 -0
- package/src/ui/static/assets/AIRecordPanel-CAs8fXyS.js +40 -0
- package/src/ui/static/assets/AIStreamUI-p_sMTEDQ.js +9 -0
- package/src/ui/static/assets/{AITestGenPage-D3t2gPAA.js → AITestGenPage-CHaHfmu4.js} +1 -1
- package/src/ui/static/assets/APITestingPage-BSGJY_hd.js +19 -0
- package/src/ui/static/assets/{AboutPage-CjEqKB-q.js → AboutPage-CDa24SCJ.js} +1 -1
- package/src/ui/static/assets/{AdvancedPage-4kAcpE8Y.js → AdvancedPage-BqXP0FLg.js} +1 -1
- package/src/ui/static/assets/{AnalyticsPage-64mYNK2v.js → AnalyticsPage-Lm8noJqC.js} +1 -1
- package/src/ui/static/assets/{AuditLogPage-BQjOzQje.js → AuditLogPage-BvldSIik.js} +1 -1
- package/src/ui/static/assets/ChangesSummary-Cu0_4Ucf.js +3 -0
- package/src/ui/static/assets/{CodeMapPage-B1ezmnlE.js → CodeMapPage-uEjuo3fk.js} +3 -3
- package/src/ui/static/assets/{ConfirmDialog-t7mpeeSN.js → ConfirmDialog-DtotgVmI.js} +1 -1
- package/src/ui/static/assets/{CoveragePage-YMmCbiBk.js → CoveragePage-jNkQJA1P.js} +1 -1
- package/src/ui/static/assets/{CronBuilder-Nk-K-_8I.js → CronBuilder-D2fERHt9.js} +1 -1
- package/src/ui/static/assets/{Dashboard-BDVxO2V4.js → Dashboard-BaIj_IdQ.js} +1 -1
- package/src/ui/static/assets/{DefectsPage-l8yGeCyR.js → DefectsPage-DH0njYFG.js} +3 -3
- package/src/ui/static/assets/{EmptyState-D1T3JWUr.js → EmptyState-utxlJ0fu.js} +1 -1
- package/src/ui/static/assets/{ExportButton-Dt5RhL-h.js → ExportButton-ouKqn9CU.js} +1 -1
- package/src/ui/static/assets/{FileViewer-CrKgh_cB.js → FileViewer-mU3JloJ6.js} +1 -1
- package/src/ui/static/assets/{GitPage-_4nCEzkJ.js → GitPage-TrX-RqNC.js} +5 -5
- package/src/ui/static/assets/{ImportExportPage-BcR7IQi9.js → ImportExportPage-CIhK_raX.js} +1 -1
- package/src/ui/static/assets/{JiraPushDialog-C2sP4_4h.js → JiraPushDialog-DgEZS-0u.js} +1 -1
- package/src/ui/static/assets/{KpiTile-inmeEsy3.js → KpiTile-BHLE3HVj.js} +1 -1
- package/src/ui/static/assets/{LiveExecutionView-D5BRe9jq.js → LiveExecutionView-CaIf7Jux.js} +1 -1
- package/src/ui/static/assets/{ManagePage-B8iG6Q0B.js → ManagePage-SvRQ6L19.js} +1 -1
- package/src/ui/static/assets/{MediaModal-C5n6sHYi.js → MediaModal-DNM45Uz2.js} +1 -1
- package/src/ui/static/assets/{MobileRunPicker-0h-N2c6d.js → MobileRunPicker-DFKm6_nU.js} +1 -1
- package/src/ui/static/assets/{MobileRunTarget-Bo_xekig.js → MobileRunTarget-DHDoDZ_F.js} +3 -3
- package/src/ui/static/assets/{ModuleExplorer-VGcmK167.js → ModuleExplorer-rni7JbsL.js} +1 -1
- package/src/ui/static/assets/{OutputPage-B_1nPPxE.js → OutputPage-Cn2WCpJ6.js} +1 -1
- package/src/ui/static/assets/{PipelinesPanel-PmmPu8pj.js → PipelinesPanel-D6zWcLtD.js} +1 -1
- package/src/ui/static/assets/{ProfilePage-y7tJNNFd.js → ProfilePage-BKNdkSnx.js} +1 -1
- package/src/ui/static/assets/{ProjectExplorer-DbfGhRq0.js → ProjectExplorer-5e7J8t-o.js} +1 -1
- package/src/ui/static/assets/{RemoteFileStrip-WuRKtx_h.js → RemoteFileStrip-C1S2aclP.js} +1 -1
- package/src/ui/static/assets/{ReportCard-G52Q6-2i.js → ReportCard-D4EElEe9.js} +2 -2
- package/src/ui/static/assets/{ReportFullView-Bt8UFP2J.js → ReportFullView-2w2ysKRg.js} +1 -1
- package/src/ui/static/assets/{ReportsPage-DMtDi73Q.js → ReportsPage-9Fx-IEwV.js} +2 -2
- package/src/ui/static/assets/{ResultsPage-BI9jpK2N.js → ResultsPage-DPkfGh-K.js} +1 -1
- package/src/ui/static/assets/{RunState-ifC4zi6M.js → RunState-CRuS_bC2.js} +1 -1
- package/src/ui/static/assets/{RunTargets-C7vpCbck.js → RunTargets-CPKBrefj.js} +1 -1
- package/src/ui/static/assets/{ScriptMappingPage-7vHuvhQw.js → ScriptMappingPage-C3K_uyf0.js} +1 -1
- package/src/ui/static/assets/{SearchableDevicePicker-BYxYJNWl.js → SearchableDevicePicker-DubIldKj.js} +1 -1
- package/src/ui/static/assets/{SettingsPage-DSISg7r7.js → SettingsPage-BuZrrlW2.js} +1 -1
- package/src/ui/static/assets/{SharedReportView-BOqKGJmR.js → SharedReportView-ig5hECRk.js} +1 -1
- package/src/ui/static/assets/{SourcesPage-CgqtYGBi.js → SourcesPage-BPkqRqkC.js} +1 -1
- package/src/ui/static/assets/{TestExplorerPage-gYLhCD4d.js → TestExplorerPage-C_jl93GR.js} +3 -3
- package/src/ui/static/assets/{TestManagementPage-wqYTKP7W.js → TestManagementPage-DJiWpCne.js} +2 -2
- package/src/ui/static/assets/{TestPlansPage-DOKX9p6z.js → TestPlansPage-G1lvK1C0.js} +3 -3
- package/src/ui/static/assets/{TestverCreditsDetail-cSW0SpNx.js → TestverCreditsDetail-BKpt4oLW.js} +1 -1
- package/src/ui/static/assets/{TestverCreditsRing-DpMzl3h7.js → TestverCreditsRing-CEBSy3w3.js} +1 -1
- package/src/ui/static/assets/{UncommittedDiffViewer-BxS0zi-p.js → UncommittedDiffViewer-FKvUZcRi.js} +2 -2
- package/src/ui/static/assets/{UserManagementPage-B5d0uDU_.js → UserManagementPage-gDGhaHE4.js} +3 -3
- package/src/ui/static/assets/{WorkflowsPage-Bk0DFnFS.js → WorkflowsPage-BACdnU-1.js} +1 -1
- package/src/ui/static/assets/{hiddenLlmProviders-CdhhNa5G.js → hiddenLlmProviders-DzwaR-b9.js} +1 -1
- package/src/ui/static/assets/index-D6sQYc_0.js +47 -0
- package/src/ui/static/assets/{index-DpQhqcHv.js → index-DLmlY2Ol.js} +1 -1
- package/src/ui/static/assets/index-aInN0yoR.css +1 -0
- package/src/ui/static/assets/{reportMeta-AKcU_qwq.js → reportMeta-3kxT7BIT.js} +1 -1
- package/src/ui/static/assets/{useChartTheme-BFz2QcND.js → useChartTheme-CTIe6M63.js} +1 -1
- package/src/ui/static/assets/{useDebouncedValue-BsHptIvX.js → useDebouncedValue-C9odz7b2.js} +1 -1
- package/src/ui/static/assets/{useFeatureFlags-DNkIctil.js → useFeatureFlags-DrhvBp0C.js} +1 -1
- package/src/ui/static/assets/{useJiraConnector-D5ysBBvz.js → useJiraConnector-Dwj69Rfh.js} +1 -1
- package/src/ui/static/assets/useOwnership-C1CmzcvJ.js +1 -0
- package/src/ui/static/assets/useSuites-V0AxZYex.js +1 -0
- package/src/ui/static/assets/{useTabParam-ChbOedP1.js → useTabParam-CyYAP90W.js} +1 -1
- package/src/ui/static/assets/{useTestExplorer-DT8frjCK.js → useTestExplorer-CUqC18DV.js} +1 -1
- package/src/ui/static/assets/{useTestLifecycle-OcwQaB1s.js → useTestLifecycle-C2S_vaX2.js} +1 -1
- package/src/ui/static/assets/{useTestManagement-Xm4Bcx3u.js → useTestManagement-DW6AW2mt.js} +2 -2
- package/src/ui/static/assets/{useTestResults-D5EwGIX9.js → useTestResults-yjH1aUy-.js} +1 -1
- package/src/ui/static/assets/{vendor-charts-DWFQlmCz.js → vendor-charts-By5uZ93z.js} +1 -1
- package/src/ui/static/assets/{vendor-flow-YGpC9U9I.js → vendor-flow-B61ZV-pm.js} +1 -1
- package/src/ui/static/assets/{vendor-icons-BKPiFyYV.js → vendor-icons-D_Dmmj8d.js} +277 -282
- package/src/ui/static/assets/vendor-query-DkZSMtfn.js +1 -0
- package/src/ui/static/assets/{vendor-quill-W-RoQfb6.js → vendor-quill-xJF2Jvjc.js} +1 -1
- package/src/ui/static/assets/{vendor-react-CTbHBddL.js → vendor-react-DOVfxdUy.js} +1 -1
- package/src/ui/static/index.html +5 -5
- package/src/ui/static/assets/AIPanel-B_R-CbrF.js +0 -32
- package/src/ui/static/assets/AIRecordPanel-BRQWIU5h.js +0 -40
- package/src/ui/static/assets/AIStreamUI-C3D989_6.js +0 -9
- package/src/ui/static/assets/APITestingPage-Cmwkiiys.js +0 -19
- package/src/ui/static/assets/ChangesSummary-CY_Vb27i.js +0 -2
- package/src/ui/static/assets/DiffViewer-BIU09a_i.js +0 -2
- package/src/ui/static/assets/index-BYVxKLrT.js +0 -47
- package/src/ui/static/assets/index-C2KJt7SI.css +0 -1
- package/src/ui/static/assets/useOwnership-U0AfKBRo.js +0 -1
- package/src/ui/static/assets/useSuites-DyfN9HVv.js +0 -1
- package/src/ui/static/assets/vendor-query-BrzmPFT3.js +0 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import{r as v,d as Y,j as e}from"./vendor-react-DOVfxdUy.js";import{u as X}from"./vendor-query-DkZSMtfn.js";import{gu as Z,a6 as z}from"./index-D6sQYc_0.js";import{af as G,X as ee,a0 as te,_ as re}from"./vendor-icons-D_Dmmj8d.js";function se({run:t,file:r,onClose:i}){const{data:n,isLoading:l,error:s}=X({queryKey:["explore-run-file",t,r],queryFn:()=>Z(t,r),staleTime:3e4});v.useEffect(()=>{const a=c=>{c.key==="Escape"&&i()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[i]);const d=/\.(md|markdown)$/i.test(r);return Y.createPortal(e.jsxs("div",{className:"fixed inset-0 z-[80] flex items-center justify-center p-4","data-testid":"run-file-viewer",children:[e.jsx("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:i}),e.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":`Exploration ${t} — ${r}`,className:"relative w-full max-w-3xl max-h-[85vh] flex flex-col rounded-2xl border border-gray-200 dark:border-white/10 bg-white dark:bg-surface-1 shadow-2xl",children:[e.jsxs("div",{className:"flex items-start gap-3 px-5 pt-4 pb-3 border-b border-gray-200 dark:border-white/5",children:[e.jsx("span",{className:"mt-0.5 rounded-lg bg-emerald-500/10 p-2 text-emerald-600 dark:text-emerald-400",children:e.jsx(G,{size:16})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h2",{className:"text-base font-semibold text-gray-900 dark:text-gray-100 break-all",children:r}),e.jsxs("p",{className:"text-[13px] text-gray-500 dark:text-gray-400 break-all",children:["Exploration run ",t," · read-only, credentials masked"]})]}),e.jsx("button",{type:"button",onClick:i,className:"p-1 rounded-md text-gray-400 hover:text-gray-700 dark:hover:text-gray-200",title:"Close","aria-label":"Close",children:e.jsx(ee,{size:16})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto px-5 py-4 text-[13px]",children:[l&&e.jsxs("div",{className:"flex items-center gap-2 text-gray-500",children:[e.jsx(te,{size:14,className:"animate-spin"})," Reading the file…"]}),s&&e.jsxs("p",{className:"text-red-600 dark:text-red-400",children:["This file could not be opened: ",s.message]}),n&&(d?e.jsx("div",{className:"text-gray-800 dark:text-gray-200",children:e.jsx(ue,{text:n.content})}):e.jsx("pre",{className:"whitespace-pre-wrap break-words font-mono text-[12px] text-gray-800 dark:text-gray-200",children:n.content}))]})]})]}),document.body)}const R=/\[\[cite\|([^|\]]*)\|([^|\]]*)\|([^|\]]*)(?:\|([^\]]*))?\]\]/g,ae=/\[\[cite\\?\|[^\]]*\]\]/g;function ne(t){return t.replace(/\\(?=[|[\]])/g,"")}function $e(t){return t.replace(ae,ne)}function W(t){const r=t.trim().toLowerCase();return r==="observed"||r==="reported"||r==="asserted"||r==="automated"||r==="stated"?r:"stated"}function L(t,r,i){return`${W(t)}|${r.trim()||i.trim()||"source"}`}function ie(t){const r=new Map;for(const i of t.matchAll(R)){const n=i[1]||"",l=(i[2]||"").trim(),s=(i[3]||"").trim(),d=L(n,l,s);r.has(d)||r.set(d,{index:r.size+1,tier:W(n),ref:l||s||"source",detail:l?s:"",kind:(i[4]||"").trim()||void 0})}return[...r.values()]}function Ce(t){return t.replace(R,"").replace(/[ \t]+([.,;:!?])/g,"$1")}function $(t){return t.kind||q[t.tier]}function Le(t){const r=ie(t),i=new Map(r.map(s=>[L(s.tier,s.ref,""),s])),n=t.replace(R,(s,d,a,c)=>{const m=i.get(L(d,a.trim()||c.trim(),""));return m?` [${m.index}]`:""}).replace(/[ \t]+(\[\d+\])/g," $1");if(r.length===0)return n;const l=r.map(s=>`[${s.index}] ${$(s)} · ${s.ref}${s.detail?` — ${s.detail}`:""}`);return`${n}
|
|
2
|
+
|
|
3
|
+
Sources:
|
|
4
|
+
${l.join(`
|
|
5
|
+
`)}`}const T=v.createContext(null);function Ie({citations:t,children:r}){const i=`src-${v.useId().replace(/[^a-zA-Z0-9_-]/g,"")}`,n=new Map(t.map(l=>[L(l.tier,l.ref,""),l]));return e.jsx(T.Provider,{value:{map:n,listId:i},children:r})}const V={observed:"text-emerald-600 dark:text-emerald-400 border-emerald-500/30 bg-emerald-500/10",reported:"text-rose-600 dark:text-rose-400 border-rose-500/30 bg-rose-500/10",asserted:"text-blue-600 dark:text-blue-400 border-blue-500/30 bg-blue-500/10",automated:"text-violet-600 dark:text-violet-400 border-violet-500/30 bg-violet-500/10",stated:"text-amber-600 dark:text-amber-400 border-amber-500/30 bg-amber-500/10"},oe={observed:"Observed — the app was watched doing this",reported:"Reported — a tester logged this as a defect",asserted:"Asserted — a test case says so",automated:"Automated — a test in the repository checks this",stated:"Stated — written in a document"},q={observed:"Exploration",reported:"Defect",asserted:"Test case",automated:"Automated test",stated:"Document"},le="relative -top-[3px] mx-[3px] inline-flex items-center justify-center min-w-[14px] h-[14px] px-[3px] rounded-[4px] border text-[9px] leading-none font-semibold tabular-nums align-baseline";function de(t,r){const i=document.getElementById(t);if(!i)return;i.open=!0;const n=document.getElementById(`${t}-${r}`);n==null||n.scrollIntoView({block:"nearest",behavior:"smooth"}),n==null||n.focus({preventScroll:!0})}function ce({tier:t,refId:r,detail:i,kind:n}){const l=v.useContext(T),s=l==null?void 0:l.map.get(L(t,r,i)),d=W((s==null?void 0:s.tier)??t),a=(s==null?void 0:s.ref)??(r||i||"source"),c=s?String(s.index):a,m=(s==null?void 0:s.kind)||n||q[d],f=`${m} · ${a}
|
|
6
|
+
${oe[d]}${s!=null&&s.detail||i?`
|
|
7
|
+
${(s==null?void 0:s.detail)||i}`:""}`;return e.jsx("button",{type:"button",title:f,"aria-label":`Source ${c}: ${m} ${a}`,onClick:()=>{l&&s&&de(l.listId,s.index)},className:`${le} cursor-pointer focus:outline-none focus-visible:ring-2 focus-visible:ring-cyan-400/60 ${V[d]}`,children:c})}function xe(t){var l;const r=t.ref.split(" · ")[0].trim();if(!r)return null;const i=(s,d)=>({kind:"page",href:`${s}?${new URLSearchParams(d).toString()}`});if(t.kind==="Defect register")return{kind:"page",href:"/defects"};if(t.kind==="Defect"||t.tier==="reported")return i("/defects",{defectId:r});if(t.kind==="Test run")return i("/results",{runId:r});if(t.tier==="asserted")return i("/test-cases",{tcId:r});if(t.kind==="Automation library")return{kind:"page",href:"/tests"};if(t.tier==="automated"&&t.kind==="Method"){const s=/^(.+?) · (.+):(\d+)$/.exec(t.ref.trim());if(!s)return null;const d=s[1].lastIndexOf("."),a=d>0?s[1].slice(0,d):"-",c=d>0?s[1].slice(d+1):s[1];return i("/code-map",{symbol:`${s[2]}::${a}::${c}::${s[3]}`,name:c})}if(t.tier==="automated"){const s=t.ref.indexOf(" :: ");return s<0?null:i("/tests",{file:t.ref.slice(0,s),test:t.ref.slice(s+4)})}if(t.tier==="stated"&&/^SRC-/i.test(r)){const s=t.kind==="Jira ticket"?"jira":t.kind==="Requirement"?"requirement":t.kind==="Note"?"nlp":"document";return i("/sources",{tab:s,sourceId:r})}if(t.tier==="stated"&&/^REQ-/i.test(r))return i("/coverage",{tab:"requirements",reqId:r});const n=(l=/\brun ([\w.-]+)/.exec(t.detail))==null?void 0:l[1];return t.tier==="observed"&&n&&/\.(md|markdown|txt|json)$/i.test(r)?{kind:"run-file",run:n,file:r}:null}function me(t,r){const i=t.split(" ").map(n=>n==="Jira"?n:n.toLowerCase()).join(" ");return`${r} ${r===1?i:`${i}s`}`}function Ee({citations:t}){const r=v.useContext(T),[i,n]=v.useState(null);if(t.length===0)return null;const l=a=>{a.kind==="run-file"?n({run:a.run,file:a.file}):window.open(a.href,"_blank","noopener")},s=new Map;for(const a of t){const c=$(a);s.set(c,(s.get(c)??0)+1)}const d=[...s.entries()].map(([a,c])=>me(a,c)).join(" · ");return e.jsxs("details",{id:r==null?void 0:r.listId,className:"group mt-3.5 rounded-xl border border-black/[0.07] dark:border-white/[0.08] bg-black/[0.015] dark:bg-white/[0.02] overflow-hidden",children:[e.jsxs("summary",{className:"flex items-center gap-2 cursor-pointer select-none px-3.5 py-2.5 list-none [&::-webkit-details-marker]:hidden hover:bg-black/[0.02] dark:hover:bg-white/[0.02] transition-colors",children:[e.jsx("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",className:"text-gray-400 dark:text-gray-500 transition-transform duration-150 group-open:rotate-90 flex-shrink-0","aria-hidden":"true",children:e.jsx("path",{d:"m9 18 6-6-6-6"})}),e.jsx("span",{className:"text-[12px] font-semibold text-gray-700 dark:text-gray-300",children:"Sources"}),e.jsx("span",{className:"text-[11px] text-gray-500 dark:text-gray-500",children:d})]}),e.jsx("div",{className:"border-t border-black/[0.06] dark:border-white/[0.06]",children:t.map(a=>e.jsxs("div",{id:r?`${r.listId}-${a.index}`:void 0,tabIndex:-1,className:"flex items-start gap-2.5 px-3.5 py-2.5 border-b last:border-b-0 border-black/[0.04] dark:border-white/[0.04] focus:outline-none focus:bg-cyan-500/[0.06]",children:[e.jsx("span",{className:`mt-[1px] inline-flex items-center justify-center min-w-[16px] h-[16px] px-[3px] rounded-[4px] border text-[9.5px] leading-none font-semibold tabular-nums flex-shrink-0 ${V[a.tier]}`,children:a.index}),e.jsxs("span",{className:"flex-1 min-w-0",children:[e.jsxs("span",{className:"block text-[12px] leading-snug",children:[e.jsx("span",{className:"font-semibold text-gray-700 dark:text-gray-300",children:$(a)}),a.ref!==$(a)&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-gray-400 dark:text-gray-600",children:" · "}),e.jsx("span",{className:"font-mono text-[11.5px] text-gray-800 dark:text-gray-200 break-all",children:a.ref})]})]}),a.detail&&e.jsx("span",{className:"block mt-0.5 text-[11px] leading-relaxed text-gray-500 dark:text-gray-500 break-words",children:a.detail})]}),(()=>{const c=xe(a);return c?e.jsxs("button",{type:"button",onClick:()=>l(c),title:c.kind==="run-file"?"Read this file of the exploration run":`Open ${$(a).toLowerCase()} ${a.ref.split(" · ")[0]} in a new tab`,"aria-label":`Open ${$(a)} ${a.ref}`,"data-testid":"source-open",className:"flex-shrink-0 inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[11px] font-medium text-cyan-700 dark:text-cyan-400 hover:bg-cyan-500/10 focus:outline-none focus-visible:ring-2 focus-visible:ring-cyan-400/60",children:["Open ",e.jsx(re,{size:11})]}):null})()]},`${a.tier}|${a.ref}`))}),i&&e.jsx(se,{run:i.run,file:i.file,onClose:()=>n(null)})]})}const ue=v.memo(function({text:r}){var O,D,P,B,F,U;const i=[];let n=r;const l=/EMAIL_PREVIEW_START\n([\s\S]*?)EMAIL_PREVIEW_END/g;let s;for(;(s=l.exec(r))!==null;){const x=s[1]||"",o=x.match(/^To:\s*(.+)/m),g=x.match(/^CC:\s*(.+)/m),b=x.match(/^From:\s*(.+)/m),k=x.match(/^Subject:\s*(.+)/m),y=x.match(/---BODY---\n([\s\S]*?)---END_BODY---/);i.push({to:((O=o==null?void 0:o[1])==null?void 0:O.trim())||"",cc:(D=g==null?void 0:g[1])==null?void 0:D.trim(),from:((P=b==null?void 0:b[1])==null?void 0:P.trim())||"",subject:((B=k==null?void 0:k[1])==null?void 0:B.trim())||"",body:((F=y==null?void 0:y[1])==null?void 0:F.trim())||""}),n=n.replace(s[0],`__EMAIL_PREVIEW_${i.length-1}__`)}const d=n.split(`
|
|
8
|
+
`),a=[];let c=!1,m="",f=[],N=[],u=0;const M=(x=!1)=>{if(f.length>0){const o=f.join(`
|
|
9
|
+
`);a.push(e.jsxs("div",{className:"my-2",children:[m&&e.jsxs("div",{className:"text-[10px] text-gray-500 bg-black/30 px-3 py-1 rounded-t-lg border border-b-0 border-white/5 font-mono flex items-center gap-2",children:[e.jsx("span",{children:m}),x&&e.jsx("span",{className:"text-[9px] text-gray-600 italic",children:"(streaming...)"})]}),e.jsx("pre",{className:`bg-black/30 border border-white/5 ${m?"rounded-b-lg":"rounded-lg"} p-3 text-xs text-gray-300 font-mono overflow-x-auto whitespace-pre-wrap max-h-[500px] overflow-y-auto`,children:o})]},u++)),f=[],m=""}},J=x=>{const o=[];return x.replace(/\[\[cite\\?\|[^\]]*\]\]/g,b=>(o.push(b.replace(/\\(?=[|[\]])/g,"")),`\0${o.length-1}\0`)).replace(/\\\|/g,"").replace(/^\|/,"").replace(/\|$/,"").split("|").map(b=>b.trim().replace(/\u0001/g,"|").replace(/\u0000(\d+)\u0000/g,(k,y)=>o[Number(y)]??""))},Q=x=>/^\|[\s:]*-{2,}[\s:]*(\|[\s:]*-{2,}[\s:]*)*\|?$/.test(x.trim()),I=()=>{if(N.length===0)return;const x=N.map(J);let o=null,g=[];N.length>=2&&Q(N[1])?(o=x[0],g=x.slice(2)):g=x,a.push(e.jsx(pe,{headers:o,rows:g},u++)),N=[]};for(const x of d){if(x.trimStart().startsWith("```")){I(),c?(c=!1,M()):(c=!0,m=x.trimStart().slice(3).trim());continue}if(c){f.push(x);continue}const o=x.trim();if(o.startsWith("|")){N.push(o);continue}if(I(),!o){a.push(e.jsx("div",{className:"h-2"},u++));continue}const g=o.match(/^__EMAIL_PREVIEW_(\d+)__$/);if(g){const w=parseInt(g[1],10),p=i[w];p&&a.push(e.jsxs("div",{className:"my-3 rounded-xl border border-blue-500/20 bg-blue-50/60 dark:bg-blue-500/5 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2.5 bg-blue-500/10 border-b border-blue-500/10",children:[e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-blue-500 dark:text-blue-400 shrink-0",children:[e.jsx("rect",{width:"20",height:"16",x:"2",y:"4",rx:"2"}),e.jsx("path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"})]}),e.jsx("span",{className:"text-sm font-semibold text-blue-700 dark:text-blue-300",children:"Email Preview"})]}),e.jsxs("div",{className:"px-4 py-3 space-y-1.5 border-b border-gray-200 dark:border-white/5",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"text-gray-500 w-16 shrink-0",children:"To:"}),e.jsx("span",{className:"text-gray-800 dark:text-gray-200 font-medium",children:p.to})]}),p.cc&&e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"text-gray-500 w-16 shrink-0",children:"CC:"}),e.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:p.cc})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"text-gray-500 w-16 shrink-0",children:"From:"}),e.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:p.from})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"text-gray-500 w-16 shrink-0",children:"Subject:"}),e.jsx("span",{className:"text-gray-900 dark:text-gray-100 font-medium",children:p.subject})]})]}),e.jsx("div",{className:"px-4 py-3 max-h-[300px] overflow-y-auto",children:e.jsx("div",{className:"text-xs text-gray-700 dark:text-gray-300 whitespace-pre-wrap leading-relaxed",children:p.body})}),e.jsx("div",{className:"px-4 py-2 bg-gray-50 dark:bg-white/[0.02] border-t border-gray-200 dark:border-white/5",children:e.jsx("span",{className:"text-[10px] text-gray-500 italic",children:"Confirm to send this email"})})]},u++));continue}const b=o.match(/((?:https?:\/\/[^\s/]+)?\/api\/documents\/download\/([^\s)\]"']+\.(?:png|svg|jpg|jpeg)))/);if(b){const w=z(b[1]),p=decodeURIComponent(b[2]||"").replace(/^\d+-/,"");a.push(e.jsxs("div",{className:"my-3 w-full max-w-[640px] rounded-xl border border-gray-200 dark:border-white/10 overflow-hidden bg-white dark:bg-black/20",children:[e.jsx("img",{src:w,alt:p,className:"w-full h-auto max-h-[500px] object-contain block",loading:"lazy"}),e.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-t border-gray-100 dark:border-white/5 bg-gray-50 dark:bg-white/[0.02]",children:[e.jsx("span",{className:"text-xs text-gray-600 dark:text-gray-400 truncate",children:p}),e.jsxs("button",{onClick:()=>{fetch(w).then(C=>C.blob()).then(C=>{const _=URL.createObjectURL(C),j=document.createElement("a");j.href=_,j.download=p,document.body.appendChild(j),j.click(),document.body.removeChild(j),URL.revokeObjectURL(_)}).catch(()=>window.open(w,"_blank"))},className:"flex items-center gap-1.5 px-2.5 py-1 rounded-lg bg-white dark:bg-white/5 border border-gray-200 dark:border-white/10 hover:bg-gray-100 dark:hover:bg-white/10 transition-colors text-xs text-gray-700 dark:text-gray-300 cursor-pointer",children:[e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),e.jsx("polyline",{points:"7 10 12 15 17 10"}),e.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),"Save"]})]})]},u++));continue}const k=o.match(/\[([^\]]*)\]\(((?:https?:\/\/[^)\s/]+)?\/api\/documents\/download\/([^)]+))\)/),y=k?null:o.match(/((?:https?:\/\/[^\s/]+)?\/api\/documents\/download\/(\S+))/),E=k?{url:k[2],file:k[3]}:y?{url:y[1],file:y[2]}:null;if(E){const w=z(E.url||""),p=decodeURIComponent(E.file||"document").replace(/^\d+-/,""),C=((U=p.split(".").pop())==null?void 0:U.toLowerCase())||"",j={docx:{color:"text-blue-500",label:"Word Document"},doc:{color:"text-blue-500",label:"Word Document"},pdf:{color:"text-rose-500",label:"PDF Document"},xlsx:{color:"text-emerald-500",label:"Excel Spreadsheet"},xls:{color:"text-emerald-500",label:"Excel Spreadsheet"},csv:{color:"text-gray-500",label:"CSV File"}}[C]||{color:"text-gray-500",label:"Document"};a.push(e.jsxs("a",{href:w,download:p,className:"flex items-center gap-3 p-3 my-2 rounded-xl border border-gray-200 dark:border-white/10 bg-transparent hover:bg-gray-50 dark:hover:bg-white/[0.03] transition-colors cursor-pointer no-underline group",children:[e.jsx("div",{className:"w-11 h-11 rounded-lg flex items-center justify-center shrink-0",children:e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",className:j.color,children:[e.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),e.jsx("polyline",{points:"14 2 14 8 20 8"})]})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm font-medium text-gray-800 dark:text-gray-200 truncate",children:p}),e.jsx("div",{className:"text-[11px] text-gray-500 dark:text-gray-400",children:j.label})]}),e.jsxs("div",{className:`flex items-center gap-1.5 px-3 py-1.5 rounded-lg border border-gray-200 dark:border-white/10 group-hover:bg-gray-100 dark:group-hover:bg-white/5 transition-colors shrink-0 ${j.color}`,children:[e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),e.jsx("polyline",{points:"7 10 12 15 17 10"}),e.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),e.jsx("span",{className:"text-xs font-medium",children:"Download"})]})]},u++));continue}if(/^[-*_]{3,}$/.test(o)){a.push(e.jsx("hr",{className:"border-white/5 my-3"},u++));continue}if(o.startsWith("#### ")){a.push(e.jsx("h5",{className:"text-[13px] font-semibold text-gray-200 mt-2.5 mb-1",children:h(o.slice(5))},u++));continue}if(o.startsWith("### ")){a.push(e.jsx("h4",{className:"text-sm font-semibold text-gray-200 mt-3 mb-1",children:h(o.slice(4))},u++));continue}if(o.startsWith("## ")){a.push(e.jsx("h3",{className:"text-base font-semibold text-gray-100 mt-4 mb-1",children:h(o.slice(3))},u++));continue}if(o.startsWith("# ")){a.push(e.jsx("h2",{className:"text-lg font-bold text-gray-100 mt-4 mb-1.5",children:h(o.slice(2))},u++));continue}const S=o.match(/^(\d+)\.\s+(.+)/);if(S){a.push(e.jsxs("div",{className:"flex gap-2 text-sm text-gray-300 leading-relaxed ml-2",children:[e.jsxs("span",{className:"text-gray-500 flex-shrink-0 w-4 text-right",children:[S[1],"."]}),e.jsx("span",{children:h(S[2])})]},u++));continue}if(o.startsWith("- ")||o.startsWith("* ")){a.push(e.jsxs("div",{className:"flex gap-2 text-sm text-gray-300 leading-relaxed ml-2",children:[e.jsx("span",{className:"text-gray-500 flex-shrink-0",children:"•"}),e.jsx("span",{children:h(o.slice(2))})]},u++));continue}if(o.startsWith("**")){a.push(e.jsx("p",{className:"text-sm text-gray-200 mt-2",children:h(o)},u++));continue}a.push(e.jsx("p",{className:"text-sm text-gray-300 leading-relaxed",children:h(o)},u++))}return c&&M(!0),I(),e.jsx("div",{className:"space-y-0.5",children:a})});function pe({headers:t,rows:r,alignNumbers:i=!1}){const n=t?t.findIndex(ke):-1,l=d=>d===n?" text-center w-px whitespace-nowrap":"",s=d=>i&&/^[-+]?[\d,]+(\.\d+)?\s*(%|ms|s)?$/.test(d.trim());return e.jsx("div",{className:"my-2.5 rounded-[10px] border border-gray-200 dark:border-[#2c2d36] overflow-hidden","data-testid":"ai-table",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full border-collapse text-[13px] text-gray-700 dark:text-gray-300 tabular-nums",children:[t&&e.jsx("thead",{children:e.jsx("tr",{children:t.map((d,a)=>e.jsx("th",{className:`bg-[#f7f8fa] dark:bg-[#22232a] border-b border-gray-200 dark:border-[#2c2d36] px-3.5 py-[9px] text-left text-[11.5px] font-semibold uppercase tracking-[0.05em] text-gray-500 dark:text-gray-400 whitespace-nowrap${l(a)}`,children:h(d,!0)},a))})}),e.jsxs("tbody",{children:[r.map((d,a)=>e.jsx("tr",{className:"group/row",children:d.map((c,m)=>{var f;return e.jsx("td",{className:`px-3.5 py-2.5 align-middle border-b border-[#eef0f3] dark:border-[#25262d] group-last/row:border-b-0 group-hover/row:bg-[#f5f7fa] dark:group-hover/row:bg-[#23242b]${m===0?" font-medium text-gray-800 dark:text-gray-200":""}${(f=H(c))!=null&&f.rest?" min-w-[13rem]":he(c)}${l(m)}${s(c)?" text-right":""}`,children:ye(c)},m)})},a)),r.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:Math.max(1,(t==null?void 0:t.length)??1),className:"px-3.5 py-6 text-center text-gray-400 dark:text-gray-500",children:"No rows"})})]})]})})})}const A=/\[\[cite\|[^\]]*\]\]/g;function he(t){const r=t.replace(A,"").replace(/[`*]/g,"").trim().length;return r<=18?" whitespace-nowrap":r>40?" min-w-[16rem]":""}const ge=/^(passed|pass|failed|fail|error|skipped|blocked|flaky|open|in progress|resolved|closed|fixed|rejected)(\s*\((?:error|fixed)\))?(?:\s*[—–-]\s+([\s\S]+))?$/i,be={passed:"ok",pass:"ok",resolved:"ok",closed:"ok",fixed:"ok",failed:"bad",fail:"bad",error:"bad",blocked:"bad",open:"bad",skipped:"warn",flaky:"warn","in progress":"warn",rejected:"neutral"},fe={bad:"text-red-700 bg-red-50 dark:text-red-400 dark:bg-red-500/[0.12]",ok:"text-emerald-700 bg-emerald-50 dark:text-emerald-400 dark:bg-emerald-500/[0.12]",warn:"text-amber-700 bg-amber-50 dark:text-amber-400 dark:bg-amber-500/[0.12]",neutral:"text-gray-600 bg-gray-100 dark:text-gray-300 dark:bg-white/[0.08]"};function H(t){const r=ge.exec(t.replace(A,"").trim());return r?{label:`${r[1]}${r[2]??""}`.trim(),tone:be[r[1].toLowerCase()]??"neutral",rest:(r[3]??"").trim()}:null}function ke(t){return/^sources?$/i.test((t??"").replace(/\*/g,"").trim())}function K(t){const r=t.split(/\s→\s/);return r.length===1?h(t,!0):r.map((i,n)=>e.jsxs("span",{children:[n>0&&e.jsx("span",{className:"px-1 text-[#9ca3af] dark:text-gray-500",children:"→"}),h(i,!0)]},n))}function ye(t){const r=H(t);if(!r)return K(t);const i=(t.match(A)??[]).join(" ");return e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:`inline-flex items-center gap-[5px] rounded-full px-2 py-0.5 text-[11.5px] font-semibold whitespace-nowrap ${fe[r.tone]}`,children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-current","aria-hidden":"true"}),r.label]}),i&&e.jsxs(e.Fragment,{children:[" ",h(i,!0)]}),r.rest&&e.jsx("span",{className:"mt-[3px] block text-[12px] text-gray-500 dark:text-gray-400",children:K(r.rest)})]})}function h(t,r=!1){const i=t.split(/(\*\*[^*]+\*\*|`[^`]+`|\[\[cite\|[^\]]*\]\]|\*[^\s*][^*\n]*[^\s*]\*|\*[^\s*]\*)/g);return i.length===1?t:e.jsx(e.Fragment,{children:i.map((n,l)=>{if(n.startsWith("[[cite|")){const s=/^\[\[cite\|([^|\]]*)\|([^|\]]*)\|([^|\]]*)(?:\|([^\]]*))?\]\]$/.exec(n);return s?e.jsx(ce,{tier:s[1]||"",refId:(s[2]||"").trim(),detail:(s[3]||"").trim(),kind:(s[4]||"").trim()||void 0},l):null}return n.startsWith("**")&&n.endsWith("**")?e.jsx("strong",{className:"font-semibold text-gray-200",children:h(n.slice(2,-2),r)},l):n.startsWith("`[[cite|")&&n.endsWith("]]`")?e.jsx("span",{children:h(n.slice(1,-1),r)},l):n.startsWith("`")&&n.endsWith("`")?e.jsx("code",{className:r?"bg-gray-100 text-gray-700 dark:bg-white/[0.08] dark:text-gray-200 px-[5px] py-px rounded text-[0.86em] font-mono whitespace-nowrap":"bg-white/5 text-amber-300 px-1 py-0.5 rounded text-xs font-mono",children:n.slice(1,-1)},l):n.length>2&&n.startsWith("*")&&n.endsWith("*")?e.jsx("em",{className:"italic",children:h(n.slice(1,-1),r)},l):e.jsx("span",{children:n},l)})})}export{ue as A,Ie as C,Ee as S,Le as c,ie as e,Ce as s,$e as u};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as d,j as e,b as Ye,u as $a}from"./vendor-react-CTbHBddL.js";import{a as Ia,u as qs}from"./vendor-query-BrzmPFT3.js";import{J as Ta,ah as Ea,ai as Da,ab as Ma}from"./useTestManagement-Xm4Bcx3u.js";import{gx as Fa,x as Ga,gy as Pa,gz as _s,D as za,gA as As,gB as La,gC as Rs,gD as Oa,gE as Ba,gF as $s}from"./index-BYVxKLrT.js";import{o as de,f as Et,r as Xe,S as Ze,X as pe,a0 as le,b2 as Ja,I as Ua,b as Ft,an as Gt,v as Is,dk as Ka,ag as Ts,y as Dt,t as Mt,aI as Es,Z as Qa,b0 as Ds}from"./vendor-icons-BKPiFyYV.js";import{h as Ha}from"./aiHandoff-vhtR29Fh.js";import{J as Wa}from"./JiraPushDialog-C2sP4_4h.js";import"./useJiraConnector-D5ysBBvz.js";const Ms=["happy-path","negative","boundary","equivalence","error-handling","security","performance","accessibility","compatibility","integration","data-validation"],Va={"happy-path":"HP",negative:"NEG",boundary:"BND",equivalence:"EQ","error-handling":"ERR",security:"SEC",performance:"PRF",accessibility:"A11Y",compatibility:"CMP",integration:"INT","data-validation":"DV"},Ya={critical:"text-red-300 bg-red-500/10",high:"text-orange-300 bg-orange-500/10",medium:"text-amber-300 bg-amber-500/10",low:"text-gray-400 bg-gray-500/10"};function Za({requirements:C,tests:G,depth:Q}){const T=j=>j.effectiveStrategies&&j.effectiveStrategies.length>0?j.effectiveStrategies:j.applicableStrategies||[],q=Q!=="high-level",Y=d.useMemo(()=>{const j=new Map;for(const _ of G){const D=_==null?void 0:_._requirementId,R=_==null?void 0:_._strategy;if(!D)continue;j.has(D)||j.set(D,new Map);const I=j.get(D),H=R||"unknown";I.set(H,(I.get(H)||0)+1)}return j},[G]),g=d.useMemo(()=>C.map(j=>{const _=Y.get(j.id)||new Map,D=Array.from(_.values()).reduce((f,N)=>f+N,0),R=T(j),I=R.filter(f=>(_.get(f)||0)>0).length,H=R.length>0?Math.round(I/R.length*100):100,v=q?R.filter(f=>!_.get(f)):[];return{req:j,inner:_,total:D,score:H,missing:v}}),[C,Y]),E=d.useMemo(()=>{const j=g.reduce((R,I)=>R+T(I.req).filter(H=>(I.inner.get(H)||0)>0).length,0),_=g.reduce((R,I)=>R+T(I.req).length,0),D=_>0?Math.round(j/_*100):100;return{requirementCount:C.length,testCount:G.length,coverageScore:D,gappedRequirements:g.filter(R=>R.missing.length>0).length}},[g,C.length,G.length]);return C.length===0?null:e.jsxs("details",{className:"bg-surface-1 rounded-xl border border-white/5 group",open:!0,children:[e.jsxs("summary",{className:"flex items-center justify-between px-4 py-3 cursor-pointer select-none hover:bg-surface-2 rounded-xl transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h3",{className:"text-base font-semibold text-gray-200",children:"Traceability Matrix"}),e.jsxs("span",{className:"text-xs text-gray-500",children:[E.requirementCount," req · ",E.testCount," tests · ",E.coverageScore,"%"," ",q?"strategy coverage":"of strategies touched (high-level)"]}),E.gappedRequirements>0&&e.jsxs("span",{className:"flex items-center gap-1 text-xs text-amber-300 px-2 py-0.5 bg-amber-500/10 rounded",children:[e.jsx(de,{size:11}),E.gappedRequirements," req with gaps"]})]}),e.jsx("span",{className:"text-xs text-gray-500 group-open:hidden",children:"click to expand"}),e.jsx("span",{className:"text-xs text-gray-500 hidden group-open:inline",children:"click to collapse"})]}),e.jsxs("div",{className:"overflow-x-auto px-4 pb-4",children:[e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-[10px] uppercase tracking-wide text-gray-500 border-b border-white/5",children:[e.jsx("th",{className:"text-left font-medium px-2 py-2 sticky left-0 bg-surface-1 z-10",children:"Requirement"}),e.jsx("th",{className:"text-left font-medium px-2 py-2",children:"Priority"}),e.jsx("th",{className:"text-right font-medium px-2 py-2",children:"Tests"}),e.jsx("th",{className:"text-right font-medium px-2 py-2",children:"Coverage"}),e.jsx("th",{className:"text-left font-medium px-2 py-2",children:"Personas"}),Ms.map(j=>e.jsx("th",{className:"text-center font-medium px-1.5 py-2",title:j,children:Va[j]||j},j))]})}),e.jsx("tbody",{children:g.map(({req:j,inner:_,total:D,score:R,missing:I})=>{const H=new Set(T(j)),v=new Set((j.applicableStrategies||[]).filter(f=>!H.has(f)));return e.jsxs("tr",{className:"border-b border-white/5 hover:bg-surface-2/40",children:[e.jsxs("td",{className:"px-2 py-2 sticky left-0 bg-surface-1 z-10 max-w-xs",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"font-mono text-brand-300 text-xs",children:j.id}),I.length>0&&e.jsx("span",{className:"text-amber-400",title:`Missing: ${I.join(", ")}`,children:e.jsx(de,{size:11})})]}),e.jsx("div",{className:"text-gray-300 truncate",title:j.title,children:j.title}),j.sourceTitle&&e.jsx("div",{className:"text-[10px] text-gray-600 truncate",title:j.sourceTitle,children:j.sourceTitle})]}),e.jsx("td",{className:"px-2 py-2",children:e.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] font-medium ${Ya[j.priority]??"text-gray-400"}`,children:j.priority})}),e.jsx("td",{className:"px-2 py-2 text-right tabular-nums text-gray-300",children:D}),e.jsx("td",{className:"px-2 py-2 text-right tabular-nums",children:e.jsxs("span",{className:R>=100?"text-emerald-400":R>=75?"text-amber-300":R>=50?"text-orange-300":"text-red-400",children:[R,"%"]})}),e.jsx("td",{className:"px-2 py-2",children:(()=>{const f=j.applicablePersonas??[];if(f.length===0)return e.jsx("span",{className:"text-gray-600 text-[10px]",children:"—"});const N=new Map;for(const k of G){if((k==null?void 0:k._requirementId)!==j.id)continue;const $=k==null?void 0:k._persona;typeof $=="string"&&N.set($,(N.get($)||0)+1)}return e.jsx("div",{className:"flex flex-wrap gap-1 max-w-[200px]",children:f.map(k=>{const $=N.get(k)||0;return e.jsxs("span",{title:`${$} test${$===1?"":"s"} for ${k}`,className:`text-[10px] px-1.5 py-0.5 rounded ${$>0?"bg-emerald-500/15 text-emerald-300":"bg-gray-500/15 text-gray-400"}`,children:[k," ",$>0?`(${$})`:""]},k)})})})()}),Ms.map(f=>{const N=_.get(f)||0,k=H.has(f);if(!k&&N===0){const $=v.has(f);return e.jsx("td",{className:"px-1.5 py-2 text-center text-gray-700",title:$?`${f} applies, but high-level coverage does not attempt it — use Deepen for this requirement`:`${f} not applicable to this requirement`,children:e.jsx(Et,{size:8,className:"inline"})},f)}return k&&N===0?q?e.jsx("td",{className:"px-1.5 py-2 text-center text-red-400 font-bold",title:`${f} required but not generated`,children:"✕"},f):e.jsx("td",{className:"px-1.5 py-2 text-center text-gray-600",title:`${f} applies, but a high-level run does not cover every strategy — use Deepen on this requirement for full coverage`,children:e.jsx(Et,{size:8,className:"inline"})},f):e.jsx("td",{className:"px-1.5 py-2 text-center",children:e.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[e.jsx(Xe,{size:10,className:"text-emerald-400"}),e.jsx("span",{className:"text-gray-300 tabular-nums",children:N})]})},f)})]},j.id)})})]}),e.jsxs("div",{className:"flex flex-wrap gap-3 mt-3 text-[10px] text-gray-500",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Xe,{size:10,className:"text-emerald-400"})," covered"]}),q&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-red-400 font-bold",children:"✕"})," required but missing"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Et,{size:8,className:"text-gray-700"}),q?"not applicable":"not applicable, or not attempted at this depth"]})]})]})]})}const Fs=10;function Xa({cases:C,requirementTitle:G,onApply:Q,onClose:T}){const[q,Y]=d.useState(null),[g,E]=d.useState(new Set),[j,_]=d.useState(null),[D,R]=d.useState(0);d.useEffect(()=>{let f=!0;return(async()=>{const N=[],k=(S,W)=>String(S??"").slice(0,W);let $=null;for(let S=0;S<C.length;S+=Fs){const W=C.slice(S,S+Fs);try{const{fixed:ge}=await Fa(W.map(se=>{var fe;return{title:k(se.title,2e3),preconditions:k(se.preconditions,1e4),requirement:(fe=G(se))==null?void 0:fe.slice(0,4e3),steps:(Array.isArray(se.steps)?se.steps:[]).slice(0,40).map(J=>({action:k(J==null?void 0:J.action,5e3),expectedResult:k(J==null?void 0:J.expectedResult,5e3),testData:k(J==null?void 0:J.testData,5e3)})),issues:se._critique.slice(0,10).map(J=>({kind:k(J.kind,40),message:k(J.message,1e3),suggestion:J.suggestion?k(J.suggestion,2e3):void 0}))}}));N.push(...W.map((se,fe)=>ge[fe]??null))}catch(ge){$=(ge==null?void 0:ge.message)||"The AI could not fix some of these cases.",N.push(...W.map(()=>null))}if(!f)return;R(N.length)}f&&($&&_(`${$} Those cases are left as they are.`),Y(N),E(new Set(N.map((S,W)=>S?W:-1).filter(S=>S>=0))))})(),()=>{f=!1}},[]),d.useEffect(()=>{const f=N=>{N.key==="Escape"&&T()};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[T]);const I=q?q.filter(Boolean).length:0;function H(){if(!q)return;const f=new Map;q.forEach((N,k)=>{N&&g.has(k)&&f.set(C[k],N)}),Q(f)}const v=f=>f.map((N,k)=>e.jsxs("li",{className:"leading-relaxed",children:[N.action,N.expectedResult?e.jsxs("span",{className:"text-gray-500",children:[" → ",N.expectedResult]}):null,N.testData?e.jsxs("span",{className:"text-gray-500",children:[" [",N.testData,"]"]}):null]},k));return Ye.createPortal(e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",role:"dialog","aria-modal":"true","aria-labelledby":"fix-cases-title",children:[e.jsx("div",{className:"absolute inset-0 bg-black/60",onClick:T}),e.jsxs("div",{className:"relative w-full max-w-4xl max-h-[88vh] flex flex-col rounded-xl bg-surface-1 border border-white/10 shadow-2xl",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 p-5 border-b border-white/5",children:[e.jsxs("div",{children:[e.jsxs("h3",{id:"fix-cases-title",className:"text-base font-semibold text-gray-100 flex items-center gap-2",children:[e.jsx(Ze,{className:"w-4 h-4 text-brand-300"})," Fix ",C.length," case",C.length===1?"":"s"," with AI"]}),e.jsx("p",{className:"text-xs text-gray-400 mt-1",children:"Each case is rewritten to resolve its review notes only. Pick the changes to keep — nothing is saved until you save the cases."})]}),e.jsx("button",{onClick:T,"aria-label":"Close",className:"text-gray-500 hover:text-gray-300",children:e.jsx(pe,{size:16})})]}),e.jsxs("div",{className:"flex-1 overflow-auto p-5 space-y-4",children:[j&&e.jsx("p",{className:"text-sm text-red-400",role:"alert",children:j}),!q&&!j&&e.jsxs("p",{className:"text-sm text-gray-400 flex items-center gap-2",role:"status",children:[e.jsx(le,{className:"w-4 h-4 animate-spin"})," Rewriting… ",D," of ",C.length]}),q==null?void 0:q.map((f,N)=>{const k=C[N];return e.jsxs("div",{className:"rounded-lg border border-white/10 bg-surface-2/40",children:[e.jsxs("label",{className:"flex items-start gap-2 px-3 py-2 border-b border-white/5 text-sm",children:[e.jsx("input",{type:"checkbox",disabled:!f,checked:g.has(N),onChange:$=>E(S=>{const W=new Set(S);return $.target.checked?W.add(N):W.delete(N),W}),className:"mt-0.5"}),e.jsx("span",{className:"text-gray-200",children:f?f.changes||"Rewritten":"The AI returned nothing usable for this case — it stays as it is."})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3 p-3 text-xs",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wider text-gray-500 mb-1",children:"Before"}),e.jsx("p",{className:"text-gray-200 font-medium",children:k.title}),e.jsx("ol",{className:"list-decimal ml-4 mt-1 text-gray-400 space-y-0.5",children:v(k.steps??[])})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wider text-gray-500 mb-1",children:"After"}),f?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-gray-100 font-medium",children:f.title}),f.preconditions&&f.preconditions!==(k.preconditions??"")&&e.jsxs("p",{className:"text-gray-400 mt-1",children:["Preconditions: ",f.preconditions]}),e.jsx("ol",{className:"list-decimal ml-4 mt-1 text-gray-300 space-y-0.5",children:v(f.steps)})]}):e.jsx("p",{className:"text-gray-500",children:"—"})]})]})]},N)})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 p-4 border-t border-white/5",children:[e.jsx("button",{onClick:T,className:"px-4 py-2 text-sm rounded-lg bg-surface-2 hover:bg-surface-3 text-gray-300",children:"Cancel"}),e.jsxs("button",{onClick:H,disabled:!q||g.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:["Use ",g.size," of ",I," fix",I===1?"":"es"]})]})]})]}),document.body)}const me={grounded:{label:"grounded",cls:"bg-emerald-500/20 text-emerald-300",title:"Every step maps to a control an exploration run observed."},partial:{label:"partly grounded",cls:"bg-amber-500/20 text-amber-300",title:"Some steps were never observed — those are the lines to check first."},ungrounded:{label:"navigation invented",cls:"bg-gray-500/20 text-gray-300",title:"No explored page backs these steps. The assertions still come from the requirement."}},ne={yes:{label:"automatable",cls:"bg-cyan-500/20 text-cyan-300"},"needs-setup":{label:"needs setup",cls:"bg-violet-500/20 text-violet-300"},manual:{label:"manual",cls:"bg-gray-500/20 text-gray-300"}},er={cyan:{active:"bg-cyan-500/20 text-cyan-200 border-cyan-400/40",idle:"bg-surface-2 text-gray-400 border-white/5 hover:text-gray-200"},amber:{active:"bg-amber-500/20 text-amber-200 border-amber-400/40",idle:"bg-surface-2 text-gray-400 border-white/5 hover:text-gray-200"},violet:{active:"bg-violet-500/20 text-violet-200 border-violet-400/40",idle:"bg-surface-2 text-gray-400 border-white/5 hover:text-gray-200"},emerald:{active:"bg-emerald-500/20 text-emerald-200 border-emerald-400/40",idle:"bg-surface-2 text-gray-400 border-white/5 hover:text-gray-200"},gray:{active:"bg-white/10 text-gray-100 border-white/25",idle:"bg-surface-2 text-gray-400 border-white/5 hover:text-gray-200"}};function he({label:C,active:G,onToggle:Q,color:T="cyan"}){const q=er[T];return e.jsx("button",{type:"button","aria-pressed":G,onClick:Q,className:`text-xs px-2.5 py-1 rounded-full border transition-colors ${G?q.active:q.idle}`,children:C})}function Ve(C){return!!(C!=null&&C._dupOf||C!=null&&C._dupOfRun)}const tr=[{id:"sources",label:"From Sources",icon:e.jsx(Ft,{className:"w-4 h-4"}),description:"Generate from requirements, notes & documents"},{id:"reverse",label:"Reverse Engineer",icon:e.jsx(Gt,{className:"w-4 h-4"}),description:"Extract test cases from automation scripts"}],sr={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"},ar={functional:"bg-sky-500/20 text-sky-300",regression:"bg-violet-500/20 text-violet-300",smoke:"bg-amber-500/20 text-amber-300",integration:"bg-teal-500/20 text-teal-300",e2e:"bg-indigo-500/20 text-indigo-300",api:"bg-cyan-500/20 text-cyan-300",performance:"bg-rose-500/20 text-rose-300",security:"bg-red-500/20 text-red-300"};function Gs(C,G=0){var T;const Q=[];for(const q of C)Q.push({id:q.id,name:q.name,depth:G}),(T=q.children)!=null&&T.length&&Q.push(...Gs(q.children,G+1));return Q}function rr({tc:C,onSave:G,onCancel:Q}){const[T,q]=d.useState(C.title||""),[Y,g]=d.useState(C.priority||"medium"),[E,j]=d.useState(Array.isArray(C.preconditions)?C.preconditions.join(`
|
|
1
|
+
import{r as d,j as e,d as Ye,u as $a}from"./vendor-react-DOVfxdUy.js";import{a as Ia,u as qs}from"./vendor-query-DkZSMtfn.js";import{J as Ta,ah as Ea,ai as Da,ab as Ma}from"./useTestManagement-DW6AW2mt.js";import{gC as Fa,x as Ga,gD as Pa,gE as _s,D as za,gF as As,gG as La,gH as Rs,gI as Oa,gJ as Ba,gK as $s}from"./index-D6sQYc_0.js";import{o as de,h as Et,r as Xe,S as Ze,X as pe,a0 as le,b2 as Ja,I as Ua,d as Ft,an as Gt,v as Is,dj as Ka,ag as Ts,y as Dt,t as Mt,aI as Es,Z as Qa,b0 as Ds}from"./vendor-icons-D_Dmmj8d.js";import{h as Ha}from"./aiHandoff-vhtR29Fh.js";import{J as Wa}from"./JiraPushDialog-DgEZS-0u.js";import"./useJiraConnector-Dwj69Rfh.js";const Ms=["happy-path","negative","boundary","equivalence","error-handling","security","performance","accessibility","compatibility","integration","data-validation"],Va={"happy-path":"HP",negative:"NEG",boundary:"BND",equivalence:"EQ","error-handling":"ERR",security:"SEC",performance:"PRF",accessibility:"A11Y",compatibility:"CMP",integration:"INT","data-validation":"DV"},Ya={critical:"text-red-300 bg-red-500/10",high:"text-orange-300 bg-orange-500/10",medium:"text-amber-300 bg-amber-500/10",low:"text-gray-400 bg-gray-500/10"};function Za({requirements:C,tests:G,depth:Q}){const T=j=>j.effectiveStrategies&&j.effectiveStrategies.length>0?j.effectiveStrategies:j.applicableStrategies||[],q=Q!=="high-level",Y=d.useMemo(()=>{const j=new Map;for(const _ of G){const D=_==null?void 0:_._requirementId,R=_==null?void 0:_._strategy;if(!D)continue;j.has(D)||j.set(D,new Map);const I=j.get(D),H=R||"unknown";I.set(H,(I.get(H)||0)+1)}return j},[G]),g=d.useMemo(()=>C.map(j=>{const _=Y.get(j.id)||new Map,D=Array.from(_.values()).reduce((f,N)=>f+N,0),R=T(j),I=R.filter(f=>(_.get(f)||0)>0).length,H=R.length>0?Math.round(I/R.length*100):100,v=q?R.filter(f=>!_.get(f)):[];return{req:j,inner:_,total:D,score:H,missing:v}}),[C,Y]),E=d.useMemo(()=>{const j=g.reduce((R,I)=>R+T(I.req).filter(H=>(I.inner.get(H)||0)>0).length,0),_=g.reduce((R,I)=>R+T(I.req).length,0),D=_>0?Math.round(j/_*100):100;return{requirementCount:C.length,testCount:G.length,coverageScore:D,gappedRequirements:g.filter(R=>R.missing.length>0).length}},[g,C.length,G.length]);return C.length===0?null:e.jsxs("details",{className:"bg-surface-1 rounded-xl border border-white/5 group",open:!0,children:[e.jsxs("summary",{className:"flex items-center justify-between px-4 py-3 cursor-pointer select-none hover:bg-surface-2 rounded-xl transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h3",{className:"text-base font-semibold text-gray-200",children:"Traceability Matrix"}),e.jsxs("span",{className:"text-xs text-gray-500",children:[E.requirementCount," req · ",E.testCount," tests · ",E.coverageScore,"%"," ",q?"strategy coverage":"of strategies touched (high-level)"]}),E.gappedRequirements>0&&e.jsxs("span",{className:"flex items-center gap-1 text-xs text-amber-300 px-2 py-0.5 bg-amber-500/10 rounded",children:[e.jsx(de,{size:11}),E.gappedRequirements," req with gaps"]})]}),e.jsx("span",{className:"text-xs text-gray-500 group-open:hidden",children:"click to expand"}),e.jsx("span",{className:"text-xs text-gray-500 hidden group-open:inline",children:"click to collapse"})]}),e.jsxs("div",{className:"overflow-x-auto px-4 pb-4",children:[e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-[10px] uppercase tracking-wide text-gray-500 border-b border-white/5",children:[e.jsx("th",{className:"text-left font-medium px-2 py-2 sticky left-0 bg-surface-1 z-10",children:"Requirement"}),e.jsx("th",{className:"text-left font-medium px-2 py-2",children:"Priority"}),e.jsx("th",{className:"text-right font-medium px-2 py-2",children:"Tests"}),e.jsx("th",{className:"text-right font-medium px-2 py-2",children:"Coverage"}),e.jsx("th",{className:"text-left font-medium px-2 py-2",children:"Personas"}),Ms.map(j=>e.jsx("th",{className:"text-center font-medium px-1.5 py-2",title:j,children:Va[j]||j},j))]})}),e.jsx("tbody",{children:g.map(({req:j,inner:_,total:D,score:R,missing:I})=>{const H=new Set(T(j)),v=new Set((j.applicableStrategies||[]).filter(f=>!H.has(f)));return e.jsxs("tr",{className:"border-b border-white/5 hover:bg-surface-2/40",children:[e.jsxs("td",{className:"px-2 py-2 sticky left-0 bg-surface-1 z-10 max-w-xs",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"font-mono text-brand-300 text-xs",children:j.id}),I.length>0&&e.jsx("span",{className:"text-amber-400",title:`Missing: ${I.join(", ")}`,children:e.jsx(de,{size:11})})]}),e.jsx("div",{className:"text-gray-300 truncate",title:j.title,children:j.title}),j.sourceTitle&&e.jsx("div",{className:"text-[10px] text-gray-600 truncate",title:j.sourceTitle,children:j.sourceTitle})]}),e.jsx("td",{className:"px-2 py-2",children:e.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] font-medium ${Ya[j.priority]??"text-gray-400"}`,children:j.priority})}),e.jsx("td",{className:"px-2 py-2 text-right tabular-nums text-gray-300",children:D}),e.jsx("td",{className:"px-2 py-2 text-right tabular-nums",children:e.jsxs("span",{className:R>=100?"text-emerald-400":R>=75?"text-amber-300":R>=50?"text-orange-300":"text-red-400",children:[R,"%"]})}),e.jsx("td",{className:"px-2 py-2",children:(()=>{const f=j.applicablePersonas??[];if(f.length===0)return e.jsx("span",{className:"text-gray-600 text-[10px]",children:"—"});const N=new Map;for(const k of G){if((k==null?void 0:k._requirementId)!==j.id)continue;const $=k==null?void 0:k._persona;typeof $=="string"&&N.set($,(N.get($)||0)+1)}return e.jsx("div",{className:"flex flex-wrap gap-1 max-w-[200px]",children:f.map(k=>{const $=N.get(k)||0;return e.jsxs("span",{title:`${$} test${$===1?"":"s"} for ${k}`,className:`text-[10px] px-1.5 py-0.5 rounded ${$>0?"bg-emerald-500/15 text-emerald-300":"bg-gray-500/15 text-gray-400"}`,children:[k," ",$>0?`(${$})`:""]},k)})})})()}),Ms.map(f=>{const N=_.get(f)||0,k=H.has(f);if(!k&&N===0){const $=v.has(f);return e.jsx("td",{className:"px-1.5 py-2 text-center text-gray-700",title:$?`${f} applies, but high-level coverage does not attempt it — use Deepen for this requirement`:`${f} not applicable to this requirement`,children:e.jsx(Et,{size:8,className:"inline"})},f)}return k&&N===0?q?e.jsx("td",{className:"px-1.5 py-2 text-center text-red-400 font-bold",title:`${f} required but not generated`,children:"✕"},f):e.jsx("td",{className:"px-1.5 py-2 text-center text-gray-600",title:`${f} applies, but a high-level run does not cover every strategy — use Deepen on this requirement for full coverage`,children:e.jsx(Et,{size:8,className:"inline"})},f):e.jsx("td",{className:"px-1.5 py-2 text-center",children:e.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[e.jsx(Xe,{size:10,className:"text-emerald-400"}),e.jsx("span",{className:"text-gray-300 tabular-nums",children:N})]})},f)})]},j.id)})})]}),e.jsxs("div",{className:"flex flex-wrap gap-3 mt-3 text-[10px] text-gray-500",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Xe,{size:10,className:"text-emerald-400"})," covered"]}),q&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-red-400 font-bold",children:"✕"})," required but missing"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Et,{size:8,className:"text-gray-700"}),q?"not applicable":"not applicable, or not attempted at this depth"]})]})]})]})}const Fs=10;function Xa({cases:C,requirementTitle:G,onApply:Q,onClose:T}){const[q,Y]=d.useState(null),[g,E]=d.useState(new Set),[j,_]=d.useState(null),[D,R]=d.useState(0);d.useEffect(()=>{let f=!0;return(async()=>{const N=[],k=(S,W)=>String(S??"").slice(0,W);let $=null;for(let S=0;S<C.length;S+=Fs){const W=C.slice(S,S+Fs);try{const{fixed:ge}=await Fa(W.map(se=>{var fe;return{title:k(se.title,2e3),preconditions:k(se.preconditions,1e4),requirement:(fe=G(se))==null?void 0:fe.slice(0,4e3),steps:(Array.isArray(se.steps)?se.steps:[]).slice(0,40).map(J=>({action:k(J==null?void 0:J.action,5e3),expectedResult:k(J==null?void 0:J.expectedResult,5e3),testData:k(J==null?void 0:J.testData,5e3)})),issues:se._critique.slice(0,10).map(J=>({kind:k(J.kind,40),message:k(J.message,1e3),suggestion:J.suggestion?k(J.suggestion,2e3):void 0}))}}));N.push(...W.map((se,fe)=>ge[fe]??null))}catch(ge){$=(ge==null?void 0:ge.message)||"The AI could not fix some of these cases.",N.push(...W.map(()=>null))}if(!f)return;R(N.length)}f&&($&&_(`${$} Those cases are left as they are.`),Y(N),E(new Set(N.map((S,W)=>S?W:-1).filter(S=>S>=0))))})(),()=>{f=!1}},[]),d.useEffect(()=>{const f=N=>{N.key==="Escape"&&T()};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[T]);const I=q?q.filter(Boolean).length:0;function H(){if(!q)return;const f=new Map;q.forEach((N,k)=>{N&&g.has(k)&&f.set(C[k],N)}),Q(f)}const v=f=>f.map((N,k)=>e.jsxs("li",{className:"leading-relaxed",children:[N.action,N.expectedResult?e.jsxs("span",{className:"text-gray-500",children:[" → ",N.expectedResult]}):null,N.testData?e.jsxs("span",{className:"text-gray-500",children:[" [",N.testData,"]"]}):null]},k));return Ye.createPortal(e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",role:"dialog","aria-modal":"true","aria-labelledby":"fix-cases-title",children:[e.jsx("div",{className:"absolute inset-0 bg-black/60",onClick:T}),e.jsxs("div",{className:"relative w-full max-w-4xl max-h-[88vh] flex flex-col rounded-xl bg-surface-1 border border-white/10 shadow-2xl",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 p-5 border-b border-white/5",children:[e.jsxs("div",{children:[e.jsxs("h3",{id:"fix-cases-title",className:"text-base font-semibold text-gray-100 flex items-center gap-2",children:[e.jsx(Ze,{className:"w-4 h-4 text-brand-300"})," Fix ",C.length," case",C.length===1?"":"s"," with AI"]}),e.jsx("p",{className:"text-xs text-gray-400 mt-1",children:"Each case is rewritten to resolve its review notes only. Pick the changes to keep — nothing is saved until you save the cases."})]}),e.jsx("button",{onClick:T,"aria-label":"Close",className:"text-gray-500 hover:text-gray-300",children:e.jsx(pe,{size:16})})]}),e.jsxs("div",{className:"flex-1 overflow-auto p-5 space-y-4",children:[j&&e.jsx("p",{className:"text-sm text-red-400",role:"alert",children:j}),!q&&!j&&e.jsxs("p",{className:"text-sm text-gray-400 flex items-center gap-2",role:"status",children:[e.jsx(le,{className:"w-4 h-4 animate-spin"})," Rewriting… ",D," of ",C.length]}),q==null?void 0:q.map((f,N)=>{const k=C[N];return e.jsxs("div",{className:"rounded-lg border border-white/10 bg-surface-2/40",children:[e.jsxs("label",{className:"flex items-start gap-2 px-3 py-2 border-b border-white/5 text-sm",children:[e.jsx("input",{type:"checkbox",disabled:!f,checked:g.has(N),onChange:$=>E(S=>{const W=new Set(S);return $.target.checked?W.add(N):W.delete(N),W}),className:"mt-0.5"}),e.jsx("span",{className:"text-gray-200",children:f?f.changes||"Rewritten":"The AI returned nothing usable for this case — it stays as it is."})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3 p-3 text-xs",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wider text-gray-500 mb-1",children:"Before"}),e.jsx("p",{className:"text-gray-200 font-medium",children:k.title}),e.jsx("ol",{className:"list-decimal ml-4 mt-1 text-gray-400 space-y-0.5",children:v(k.steps??[])})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wider text-gray-500 mb-1",children:"After"}),f?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-gray-100 font-medium",children:f.title}),f.preconditions&&f.preconditions!==(k.preconditions??"")&&e.jsxs("p",{className:"text-gray-400 mt-1",children:["Preconditions: ",f.preconditions]}),e.jsx("ol",{className:"list-decimal ml-4 mt-1 text-gray-300 space-y-0.5",children:v(f.steps)})]}):e.jsx("p",{className:"text-gray-500",children:"—"})]})]})]},N)})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 p-4 border-t border-white/5",children:[e.jsx("button",{onClick:T,className:"px-4 py-2 text-sm rounded-lg bg-surface-2 hover:bg-surface-3 text-gray-300",children:"Cancel"}),e.jsxs("button",{onClick:H,disabled:!q||g.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:["Use ",g.size," of ",I," fix",I===1?"":"es"]})]})]})]}),document.body)}const me={grounded:{label:"grounded",cls:"bg-emerald-500/20 text-emerald-300",title:"Every step maps to a control an exploration run observed."},partial:{label:"partly grounded",cls:"bg-amber-500/20 text-amber-300",title:"Some steps were never observed — those are the lines to check first."},ungrounded:{label:"navigation invented",cls:"bg-gray-500/20 text-gray-300",title:"No explored page backs these steps. The assertions still come from the requirement."}},ne={yes:{label:"automatable",cls:"bg-cyan-500/20 text-cyan-300"},"needs-setup":{label:"needs setup",cls:"bg-violet-500/20 text-violet-300"},manual:{label:"manual",cls:"bg-gray-500/20 text-gray-300"}},er={cyan:{active:"bg-cyan-500/20 text-cyan-200 border-cyan-400/40",idle:"bg-surface-2 text-gray-400 border-white/5 hover:text-gray-200"},amber:{active:"bg-amber-500/20 text-amber-200 border-amber-400/40",idle:"bg-surface-2 text-gray-400 border-white/5 hover:text-gray-200"},violet:{active:"bg-violet-500/20 text-violet-200 border-violet-400/40",idle:"bg-surface-2 text-gray-400 border-white/5 hover:text-gray-200"},emerald:{active:"bg-emerald-500/20 text-emerald-200 border-emerald-400/40",idle:"bg-surface-2 text-gray-400 border-white/5 hover:text-gray-200"},gray:{active:"bg-white/10 text-gray-100 border-white/25",idle:"bg-surface-2 text-gray-400 border-white/5 hover:text-gray-200"}};function he({label:C,active:G,onToggle:Q,color:T="cyan"}){const q=er[T];return e.jsx("button",{type:"button","aria-pressed":G,onClick:Q,className:`text-xs px-2.5 py-1 rounded-full border transition-colors ${G?q.active:q.idle}`,children:C})}function Ve(C){return!!(C!=null&&C._dupOf||C!=null&&C._dupOfRun)}const tr=[{id:"sources",label:"From Sources",icon:e.jsx(Ft,{className:"w-4 h-4"}),description:"Generate from requirements, notes & documents"},{id:"reverse",label:"Reverse Engineer",icon:e.jsx(Gt,{className:"w-4 h-4"}),description:"Extract test cases from automation scripts"}],sr={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"},ar={functional:"bg-sky-500/20 text-sky-300",regression:"bg-violet-500/20 text-violet-300",smoke:"bg-amber-500/20 text-amber-300",integration:"bg-teal-500/20 text-teal-300",e2e:"bg-indigo-500/20 text-indigo-300",api:"bg-cyan-500/20 text-cyan-300",performance:"bg-rose-500/20 text-rose-300",security:"bg-red-500/20 text-red-300"};function Gs(C,G=0){var T;const Q=[];for(const q of C)Q.push({id:q.id,name:q.name,depth:G}),(T=q.children)!=null&&T.length&&Q.push(...Gs(q.children,G+1));return Q}function rr({tc:C,onSave:G,onCancel:Q}){const[T,q]=d.useState(C.title||""),[Y,g]=d.useState(C.priority||"medium"),[E,j]=d.useState(Array.isArray(C.preconditions)?C.preconditions.join(`
|
|
2
2
|
`):C.preconditions||""),[_,D]=d.useState((C.steps??[]).map(v=>({action:String((v==null?void 0:v.action)??(v==null?void 0:v.description)??(typeof v=="string"?v:"")),expectedResult:String((v==null?void 0:v.expectedResult)??""),testData:String((v==null?void 0:v.testData)??"")}))),R=(v,f,N)=>D(k=>k.map(($,S)=>S===v?{...$,[f]:N}:$)),I="w-full rounded-lg bg-surface-2 border border-white/10 px-3 py-2 text-sm text-gray-200 focus:outline-none focus:border-brand-500/60",H=T.trim().length>0;return e.jsxs("div",{className:"mt-3 space-y-3",children:[e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-xs font-medium text-gray-400 uppercase tracking-wider",children:"Title"}),e.jsx("input",{className:`${I} mt-1`,value:T,onChange:v=>q(v.target.value)})]}),e.jsxs("label",{className:"block w-48",children:[e.jsx("span",{className:"text-xs font-medium text-gray-400 uppercase tracking-wider",children:"Priority"}),e.jsx("select",{className:`${I} mt-1`,value:Y,onChange:v=>g(v.target.value),children:["critical","high","medium","low"].map(v=>e.jsx("option",{value:v,children:v},v))})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-xs font-medium text-gray-400 uppercase tracking-wider",children:"Preconditions"}),e.jsx("textarea",{className:`${I} mt-1`,rows:2,value:E,onChange:v=>j(v.target.value)})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-xs font-medium text-gray-400 uppercase tracking-wider",children:"Steps"}),e.jsxs("div",{className:"space-y-2 mt-1",children:[_.map((v,f)=>e.jsxs("div",{className:"flex gap-2 items-start",children:[e.jsx("span",{className:"text-brand-400 font-mono text-xs w-6 pt-2.5 text-right shrink-0",children:f+1}),e.jsxs("div",{className:"flex-1 grid grid-cols-1 md:grid-cols-3 gap-2",children:[e.jsx("input",{className:I,"aria-label":`Step ${f+1} action`,placeholder:"Action",value:v.action,onChange:N=>R(f,"action",N.target.value)}),e.jsx("input",{className:I,"aria-label":`Step ${f+1} expected result`,placeholder:"Expected result",value:v.expectedResult,onChange:N=>R(f,"expectedResult",N.target.value)}),e.jsx("input",{className:I,"aria-label":`Step ${f+1} test data`,placeholder:"Test data",value:v.testData,onChange:N=>R(f,"testData",N.target.value)})]}),e.jsx("button",{type:"button",onClick:()=>D(N=>N.filter((k,$)=>$!==f)),"aria-label":`Remove step ${f+1}`,className:"p-2 rounded-lg text-gray-500 hover:text-red-300 hover:bg-white/5",children:e.jsx(pe,{className:"w-4 h-4"})})]},f)),e.jsx("button",{type:"button",onClick:()=>D(v=>[...v,{action:"",expectedResult:"",testData:""}]),className:"text-xs text-brand-300 hover:text-brand-200",children:"+ Add step"})]})]}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx("button",{type:"button",onClick:Q,className:"px-3 py-1.5 text-sm rounded-lg bg-surface-2 hover:bg-surface-3 text-gray-300",children:"Cancel"}),e.jsx("button",{type:"button",disabled:!H,onClick:()=>G({title:T.trim(),priority:Y,preconditions:E.trim(),steps:_.filter(v=>v.action.trim())}),className:"px-3 py-1.5 text-sm rounded-lg bg-brand-600 hover:bg-brand-500 text-white disabled:opacity-40",children:"Done editing"})]})]})}function kr(){var Cs;const C=$a(),{mode:G}=Ga(),Q=G==="mobile"?"mobile":"web",T=Q==="mobile"?"Mobile mode":"Web mode",[q,Y]=d.useState("sources"),[g,E]=d.useState(null),[j,_]=d.useState(new Set),[D,R]=d.useState(null),I=d.useRef(!1),[H,v]=d.useState(!1),[f,N]=d.useState(null),[k,$]=d.useState(new Set),[S,W]=d.useState(!1),[ge,se]=d.useState(null),[fe,J]=d.useState(null),[ht,et]=d.useState(null),[Z,we]=d.useState(null),[L,ie]=d.useState(null),[M,tt]=d.useState([]),[Pt,zt]=d.useState([]),[st,Lt]=d.useState([]),[at,Ot]=d.useState(""),[Se,Bt]=d.useState(new Set),[ke,Jt]=d.useState(new Set),[Ce,Ut]=d.useState(new Set),[B,qe]=d.useState(new Set),[ae,Ps]=d.useState("requirement"),[Kt,pt]=d.useState(new Set),rt=d.useRef(null),Fe=d.useRef(null),Ge=d.useRef(null),gt=d.useRef(null),ft=d.useRef([]),Pe=Ia(),[_e,bt]=d.useState(null),[U,nt]=d.useState(null);d.useEffect(()=>{let s=!0;return Pa().then(({job:n})=>{s&&n&&nt(n)}).catch(()=>{}),()=>{s=!1}},[]);const yt=d.useRef(!1);d.useEffect(()=>(yt.current=!1,()=>{var s,n;yt.current=!0,(s=rt.current)==null||s.abort(),(n=Fe.current)==null||n.abort()}),[]);const Qt=!_e&&(S||((g==null?void 0:g.length)??0)>0);d.useEffect(()=>{if(!Qt)return;const s=n=>{n.preventDefault(),n.returnValue=""};return window.addEventListener("beforeunload",s),()=>window.removeEventListener("beforeunload",s)},[Qt]);const Ht=d.useRef(null);d.useEffect(()=>{var s;S&&(!g||g.length===0||(s=Ht.current)==null||s.scrollIntoView({behavior:"smooth",block:"end"}))},[S,g==null?void 0:g.length]);const[lr,ir]=d.useState(""),[or,cr]=d.useState(""),[dr,xr]=d.useState(10),[ur,mr]=d.useState(""),[be,lt]=d.useState(new Set),[jt,zs]=d.useState(""),[Ls,Wt]=d.useState(new Set),[ye,Vt]=d.useState(""),[it,Os]=d.useState(!1),[te,Nt]=d.useState("high-level"),[je,Yt]=d.useState(null),[vt,Zt]=d.useState(new Set),[Bs,ze]=d.useState(!1),[wt,Js]=d.useState(null),[Us,Le]=d.useState(!1),[Oe,St]=d.useState(!1),[Be,Ks]=d.useState(!0),[Ae,Ne]=d.useState("select"),[K,kt]=d.useState(null),[xe,Re]=d.useState(new Set),[Ct,Je]=d.useState({}),[Qs,Xt]=d.useState(!1),[Hs,es]=d.useState({}),[F,ts]=d.useState(null),[ss,as]=d.useState(null),[P,rs]=d.useState(new Set),[ns,$e]=d.useState(null),[O,ot]=d.useState(null),ct=d.useRef("sources"),[ls,Ws]=d.useState(!1),[hr,pr]=d.useState(!1),[is,X]=d.useState(null),[dt,os]=d.useState("all"),[xt,qt]=d.useState(""),{data:Ue}=Ta(),{data:z}=Ea({status:"active"}),_t=d.useMemo(()=>Array.from(P).sort(),[P]),At=Ae==="select"&&M.length>0&&!S?xe.size:void 0,{data:A}=qs({queryKey:["tm-ai-estimate",_t,te,At??null],queryFn:()=>_s({sourceIds:_t,depth:te,chosenRequirements:At}),enabled:_t.length>0,staleTime:6e4}),Ie=Da(),Te=S||je!==null||Ie.isPending,{data:Ee,isLoading:Vs}=qs({queryKey:["test-explorer"],queryFn:za}),{data:ue}=Ma(),cs=Array.isArray(ue)?ue:(ue==null?void 0:ue.testCases)||(ue==null?void 0:ue.mappings)||[],{mappedKeys:Ys,mappedFileTestNames:Zs}=d.useMemo(()=>{const s=new Set,n=new Map;return cs.forEach(r=>{var c,a;const l=((c=r.mapping)==null?void 0:c.scriptPath)||r.scriptPath||"",u=((a=r.mapping)==null?void 0:a.testName)||r.testName||"";l&&(s.add(`${l}::${u}`.toLowerCase()),n.has(l.toLowerCase())||n.set(l.toLowerCase(),new Set),n.get(l.toLowerCase()).add(u.toLowerCase()))}),{mappedKeys:s,mappedFileTestNames:n}},[cs]),Xs=(Ee==null?void 0:Ee.suites)||[],ea=(s,n)=>{if(Ys.has(`${s}::${n}`.toLowerCase()))return!0;const r=Zs.get(s.toLowerCase());if(!r)return!1;const l=Xs.find(c=>{var a;return((a=c.file)==null?void 0:a.toLowerCase())===s.toLowerCase()}),u=new Set(((l==null?void 0:l.tests)||[]).map(c=>(c.name||"").toLowerCase()));for(const c of r)if(c&&!u.has(c))return!0;return!1},ds=Array.isArray(Ue)?Ue:(Ue==null?void 0:Ue.tree)??[],ta=ds.length?Gs(ds):[],oe=S||H,Ke=d.useMemo(()=>(g??[]).some(s=>s==null?void 0:s._grounding),[g]),ve=d.useMemo(()=>{const s=(g??[]).map((r,l)=>({tc:r,idx:l})),n=at.trim().toLowerCase();return s.filter(({tc:r})=>{var l,u;if(Se.size>0){const c=r==null?void 0:r._strategy;if(typeof c!="string"||!Se.has(c))return!1}if(ke.size>0&&!ke.has((r==null?void 0:r.priority)??""))return!1;if(Ce.size>0){const c=r==null?void 0:r._persona;if(typeof c!="string"||!Ce.has(c))return!1}if(B.size>0){const c=r==null?void 0:r._grounding,a=r==null?void 0:r._automatable,x=c&&c!=="grounded"||!!((l=r==null?void 0:r._specDrift)!=null&&l.appDoes)||((r==null?void 0:r.steps)??[]).some(m=>(m==null?void 0:m._grounded)===!1);if(Ke&&B.has("grounded")&&c!=="grounded"||B.has("automatable")&&a!=="yes"||B.has("duplicates")&&!Ve(r)||B.has("review-notes")&&!(((u=r==null?void 0:r._critique)==null?void 0:u.length)>0)||Ke&&B.has("needs-a-look")&&!x)return!1}return!(n&&![(r==null?void 0:r.title)??"",(r==null?void 0:r.preconditions)??"",((r==null?void 0:r.tags)??[]).join(" "),((r==null?void 0:r.steps)??[]).map(a=>`${(a==null?void 0:a.action)??""} ${(a==null?void 0:a.expectedResult)??""} ${(a==null?void 0:a.testData)??""}`).join(" ")].join(" ").toLowerCase().includes(n))})},[g,at,Se,ke,Ce,B,Ke]),De=d.useMemo(()=>{const s=new Set,n=new Set,r=new Set;for(const l of g??[]){const u=l==null?void 0:l._strategy;typeof u=="string"&&s.add(u),typeof(l==null?void 0:l.priority)=="string"&&n.add(l.priority);const c=l==null?void 0:l._persona;typeof c=="string"&&r.add(c)}return{strategies:s,priorities:n,personas:r}},[g]),xs=d.useMemo(()=>{if(ae==="flat")return[{key:"all",label:"",items:ve}];const s=new Map;for(const r of ve){const l=r.tc;let u,c;if(ae==="requirement"){u=(l==null?void 0:l._requirementId)||"ungrouped";const a=M.find(x=>x.id===u);c=a?`${a.id} — ${a.title}`:u==="ungrouped"?"Ungrouped":u}else ae==="strategy"?(u=(l==null?void 0:l._strategy)||"unspecified",c=u):(u=(l==null?void 0:l.priority)||"unset",c=u);s.has(u)||s.set(u,{key:u,label:c,items:[]}),s.get(u).items.push(r)}const n=Array.from(s.values());if(ae==="requirement")n.sort((r,l)=>{const u=parseInt(r.key.replace(/^\D+/,""),10),c=parseInt(l.key.replace(/^\D+/,""),10);return Number.isFinite(u)&&Number.isFinite(c)?u-c:r.key.localeCompare(l.key)});else if(ae==="priority"){const r={critical:0,high:1,medium:2,low:3,unset:4};n.sort((l,u)=>(r[l.key]??99)-(r[u.key]??99))}else n.sort((r,l)=>r.key.localeCompare(l.key));return n},[ve,ae,M]),us=ve.length,ms=(g==null?void 0:g.length)??0,hs=Se.size>0||ke.size>0||Ce.size>0||B.size>0||at.trim().length>0,Qe=d.useRef(null);function He(s,n){Qe.current&&clearTimeout(Qe.current),Qe.current=null,X(s),n&&(Qe.current=setTimeout(()=>{X(null),Qe.current=null},n))}function ps(s){as(s)}function gs(s){$(n=>{const r=new Set(n);return r.has(s)?r.delete(s):r.add(s),r})}function sa(s){_(n=>{const r=new Set(n);return r.has(s)?r.delete(s):r.add(s),r})}function aa(){if(!g)return;const s=ve.map(r=>r.idx);if(s.length>0&&s.every(r=>j.has(r))){const r=new Set(j);for(const l of s)r.delete(l);_(r)}else{const r=new Set(j);for(const l of s)r.add(l);_(r)}}async function We(s,n,r,l){var h;const u=new AbortController;rt.current=u,bt((l==null?void 0:l.resumeJobId)??null),nt(null),gt.current={sourceIds:Array.isArray(n==null?void 0:n.sourceIds)?n.sourceIds.filter(i=>typeof i=="string"):[]},kt(null),X(null),E([]),_(new Set),$(new Set),se(Date.now()),J(r),et(null),we(null),ie(null),l!=null&&l.keepRequirements||(tt([]),Re(new Set),Je({})),zt([]),Lt([]),Zt(new Set),Js((n==null?void 0:n.depth)??null),Ws((n==null?void 0:n.stopAfterExtraction)===!0),W(!0);let c=!1,a=[],x=[];const m=[];try{for await(const i of Rs(s,n,u.signal,l!=null&&l.resumeJobId?"GET":"POST")){if(i.event==="job"){bt(i.data.jobId);continue}if(i.event==="job-ended"){i.data.status==="cancelled"&&He("The run was cancelled. The cases it made before that are below.",1e4);continue}if(i.event==="testcase")typeof i.data.index=="number"&&i.data.data&&typeof i.data.data=="object"&&(i.data.data._runIndex=i.data.index),m.push(i.data.data),E(t=>{const o=Array.isArray(t)?t.slice():[];return o.push(i.data.data),o});else if(i.event==="script-start")et(t=>{var o;return{done:(t==null?void 0:t.done)??0,total:(t==null?void 0:t.total)??((o=n==null?void 0:n.scriptPaths)==null?void 0:o.length)??1}});else if(i.event==="script-done")et(t=>{var o;return{done:((t==null?void 0:t.done)??0)+1,total:(t==null?void 0:t.total)??((o=n==null?void 0:n.scriptPaths)==null?void 0:o.length)??1}});else if(i.event==="script-error"){const t=String(i.data.filePath??"").split(/[\\/]/).pop()||"a script";He(`Could not reverse-engineer ${t}: ${i.data.error}. The other scripts are below.`,12e3)}else if(i.event==="start"&&i.data.totalSources)we({sourceIndex:0,sourceTitle:"",sourcesDone:0,totalSources:i.data.totalSources??1,chunksDone:0,totalChunks:i.data.totalChunks??1});else if(i.event==="source-start")we(t=>t?{...t,sourceIndex:i.data.sourceIndex,sourceTitle:i.data.sourceTitle}:null);else if(i.event==="source-done")we(t=>t?{...t,sourcesDone:t.sourcesDone+1}:null);else if(i.event==="chunk-done")we(t=>t?{...t,chunksDone:t.chunksDone+1}:null);else if(i.event==="phase")ie(t=>({phase:i.data.phase,phaseLabel:i.data.label,totalRequirements:i.data.totalRequirements??(t==null?void 0:t.totalRequirements)??0,currentRequirement:(t==null?void 0:t.currentRequirement)??null,requirementsDone:(t==null?void 0:t.requirementsDone)??0,coverageGaps:(t==null?void 0:t.coverageGaps)??0,critiqueIssues:(t==null?void 0:t.critiqueIssues)??0}));else if(i.event==="requirements-extracted")l!=null&&l.keepRequirements||(ft.current=i.data.requirements),tt(i.data.requirements),Re(new Set(i.data.requirements.map(t=>t.id))),ia(i.data.requirements),ie(t=>t?{...t,totalRequirements:i.data.count}:null);else if(i.event==="critique-done"){ie(o=>o?{...o,critiqueIssues:i.data.total}:null);const t=Array.isArray(i.data.issues)?i.data.issues:[];if(t.length>0){const o=new Map;for(const p of t)o.set(p.testIndex,[...o.get(p.testIndex)??[],p]);for(const p of m){const b=o.get(p==null?void 0:p._runIndex);b&&(p._critique=[...Array.isArray(p._critique)?p._critique:[],...b])}E(p=>p&&p.slice())}}else i.event==="requirement-start"?ie(t=>t?{...t,currentRequirement:{id:i.data.requirementId,title:i.data.gapFill?`Filling gap: ${i.data.title}`:i.data.title,strategies:i.data.applicableStrategies}}:null):i.event==="requirement-done"?i.data.gapFill||ie(t=>t?{...t,requirementsDone:t.requirementsDone+1}:null):i.event==="requirement-skipped"?(Lt(t=>t.some(o=>o.id===i.data.requirementId)?t:[...t,{id:i.data.requirementId,title:i.data.title,reason:i.data.reason}]),ie(t=>t?{...t,requirementsDone:t.requirementsDone+1}:null)):i.event==="app-model"?ts({summary:i.data.summary,isEmpty:!i.data.runs,pageCount:i.data.pages??0,roles:Array.isArray(i.data.roles)?i.data.roles:[],authedRoles:Array.isArray(i.data.authedRoles)?i.data.authedRoles:[],problems:Array.isArray(i.data.problems)?i.data.problems:[]}):i.event==="domain-detected"?(zt(t=>[...t,{sourceTitle:i.data.sourceTitle,primary:i.data.primary,description:i.data.description,concerns:i.data.concerns}]),es(t=>({...t,[i.data.sourceId??""]:{primary:i.data.primary,description:i.data.description,concerns:i.data.concerns}}))):i.event==="coverage-gaps"?ie(t=>t?{...t,coverageGaps:i.data.significant}:null):i.event==="saved"?(c=!0,Array.isArray(i.data.saved)&&i.data.saved.length>0&&(a=[...a,...i.data.saved]),Array.isArray(i.data.failed)&&(x=[...x,...i.data.failed])):i.event==="save-error"?X(String(((h=i.data)==null?void 0:h.error)||"Auto Save failed.")):i.event==="error"?He(`Generation failed: ${i.data.error}`):i.event==="parse-error"?He(i.data.message,1e4):i.event}!c&&m.length>0&&(n==null?void 0:n.stopAfterExtraction)!==!0&&js(m),c&&(Pe.invalidateQueries({queryKey:["tm-test-cases"]}),Pe.invalidateQueries({queryKey:["tm-stats"]}),Pe.invalidateQueries({queryKey:["tm-sources"]}),a.length>0?It(m,m.map((i,t)=>t),a,x,m,!0):x.length>0&&X(`Auto Save saved nothing: ${x[0].error} The cases are still here.`))}catch(i){(i==null?void 0:i.name)==="AbortError"||(console.error("Streaming generation failed:",i),He(`Generation failed: ${(i==null?void 0:i.message)||"Unknown error"}`)),a.length>0&&!yt.current&&(Pe.invalidateQueries({queryKey:["tm-test-cases"]}),Pe.invalidateQueries({queryKey:["tm-sources"]}),It(m,m.map((t,o)=>o),a,x,m,!0))}finally{W(!1),rt.current=null,se(null),J(null),we(null),et(null),ie(null)}}function ra(){Le(!0)}function na(){var s;_e&&La(_e).catch(()=>{}),(s=rt.current)==null||s.abort(),Le(!1)}function Rt(){_e&&As(_e).catch(()=>{}),bt(null)}function la(s){nt(null),Y("sources"),rs(new Set(s.sourceIds)),Nt(s.depth),Ne(s.stopAfterExtraction?"select":"review"),We(`/api/tm/ai/jobs/${encodeURIComponent(s.id)}/stream`,{sourceIds:s.sourceIds,depth:s.depth,stopAfterExtraction:s.stopAfterExtraction,autoSave:s.autoSave},null,{resumeJobId:s.id})}async function ia(s){if(s.length!==0){Xt(!0),Oa().then(n=>ts({summary:n.summary,isEmpty:n.isEmpty,pageCount:n.pageCount,roles:n.roles,authedRoles:n.authedRoles,problems:n.problems})).catch(()=>{});try{const n=await Ba({requirements:s.map(l=>({id:l.id,title:l.title,description:l.description,acceptanceCriteria:l.acceptanceCriteria})),sourceIds:Array.from(P)}),r={};for(const l of n.requirements)r[l.id]=l;Je(r)}catch(n){console.warn("Grounding lookup failed (non-fatal):",n)}finally{Xt(!1)}}}function oa(){ut({extractOnly:!0},"extract",ca)}function ca(){const r=(Array.isArray(z==null?void 0:z.sources)?z.sources:[]).filter(l=>P.has(l.id)).map(l=>l.title).join(", ")||"Extract requirements from selected sources";Ne("select"),Je({}),es({}),We("/api/tm/ai/generate/requirements/stream",{requirements:r,sourceIds:Array.from(P),depth:te,useAppKnowledge:Be,stopAfterExtraction:!0},null)}function da(){const s=M.filter(n=>xe.has(n.id));s.length!==0&&ut({chosen:s.length},"generate",xa)}function xa(){if(M.filter(r=>xe.has(r.id)).length===0)return;const n=fs();if(n.length>0&&!Oe){ct.current="chosen",$e(n);return}$t(Oe)}function $t(s){const n=M.filter(c=>xe.has(c.id));if(n.length===0)return;const u=(Array.isArray(z==null?void 0:z.sources)?z.sources:[]).filter(c=>P.has(c.id)).map(c=>c.title).join(", ")||"Generate from chosen requirements";Ne("review"),We("/api/tm/ai/generate/requirements/stream",{requirements:u,folderId:ye||void 0,autoSave:it,sourceIds:Array.from(P),depth:te,useAppKnowledge:Be,selectedRequirements:n,domains:Hs,mode:s?"incremental":"full"},null,{keepRequirements:!0})}async function ut(s,n,r){if(I.current||S)return;I.current=!0,v(!0);let l=null;try{l=await _s({sourceIds:Array.from(P),depth:te,chosenRequirements:s.chosen})}catch{}finally{I.current=!1,v(!1)}if(!l){r();return}(s.extractOnly?l.extractionCalls>40:l.confirm)&&!l.tooLarge?ot({est:s.extractOnly?{...l,totalCalls:{low:l.extractionCalls,high:l.extractionCalls}}:l,what:n,proceed:r}):r()}function fs(){return(Array.isArray(z==null?void 0:z.sources)?z.sources:[]).filter(n=>P.has(n.id)).map(n=>({id:n.id,title:n.title,count:n.linkedTestCaseCount??0})).filter(n=>n.count>0)}function ua(){P.size!==0&&ut({},"generate",ma)}function ma(){const s=fs();if(s.length>0&&!Oe){ct.current="sources",$e(s);return}mt(Oe)}function mt(s){Ne("review");const l=(Array.isArray(z==null?void 0:z.sources)?z.sources:[]).filter(u=>P.has(u.id)).map(u=>u.title).join(", ")||"Generate from selected sources";We("/api/tm/ai/generate/requirements/stream",{requirements:l,folderId:ye||void 0,autoSave:it,sourceIds:Array.from(P),mode:s?"incremental":"full",depth:te,useAppKnowledge:Be},null)}function ha(){if(be.size===0)return;const s=new Set,n={};be.forEach(r=>{const l=r.indexOf("::"),u=l>=0?r.slice(0,l):r,c=l>=0?r.slice(l+2):"";u&&(s.add(u),c&&(n[u]??(n[u]=[])).push(c))}),We("/api/tm/ai/generate/reverse-engineer/stream",{scriptPaths:Array.from(s),scriptTests:n,folderId:ye||void 0,autoSave:it},null)}async function pa(s){if(je||S||s.length===0)return;const n={stop:!1};Ge.current=n;try{for(const r of s){if(n.stop)break;await bs(r,!0)}}finally{Ge.current===n&&(Ge.current=null)}}function ga(){var s;Ge.current&&(Ge.current.stop=!0),(s=Fe.current)==null||s.abort()}async function bs(s,n=!1){var c;if(!n&&je||S||vt.has(s.id))return;Yt(s.id),X(null);const r=new AbortController;Fe.current=r;let l=0;const u=[];try{const a=(g??[]).filter(m=>(m==null?void 0:m._requirementId)===s.id&&typeof(m==null?void 0:m.title)=="string").map(m=>m.title),x=((c=gt.current)==null?void 0:c.sourceIds)??[];for await(const m of Rs("/api/tm/ai/generate/requirement/deepen/stream",{requirement:s,sourceIds:x.length>0?x:void 0,folderId:ye||void 0,autoSave:!1,existingTitles:a,useAppKnowledge:Be},r.signal))m.event==="testcase"?(l++,u.push(m.data.data),E(h=>[...h??[],m.data.data])):m.event==="error"&&X(m.data.error||"Deepen failed");l>0&&(Zt(m=>new Set(m).add(s.id)),js(u,g??[]))}catch(a){(a==null?void 0:a.name)!=="AbortError"&&X(String((a==null?void 0:a.message)||a))}finally{Fe.current===r&&(Fe.current=null),Yt(null)}}function It(s,n,r,l,u,c=!1){const a=r.filter(t=>Number.isInteger(t==null?void 0:t.index)&&t.index>=0&&t.index<s.length).map(t=>({id:t.id,title:t.title,tc:s[t.index],requirementId:t.requirementId??null}));if(a.length===0){X(`Nothing was saved${l[0]?`: ${l[0].error}`:"."} Your cases are still here.`);return}const x=new Set(a.length?r.map(t=>n[t.index]):[]),m=u.filter((t,o)=>!x.has(o));kt(t=>[...t??[],...a]),_(new Set),$(new Set);const h=c?"Auto-saved":"Saved",i=l.length>0?` ${l.length} could not be saved (${l[0].error||"unknown error"}).`:"";if(m.length===0)E(null),Ne("accept"),Rt(),ps(`${h} ${a.length} test case${a.length===1?"":"s"}.`);else{E(m);const t=l.length>0?`${h} ${a.length} of ${s.length} test case${s.length===1?"":"s"}.`:`${h} ${a.length} test case${a.length===1?"":"s"}.`;ps(`${t}${i} ${m.length} still here to save.`)}}function fa(s){if(s.length===0)return;const n=`
|
|
3
3
|
`,r=s.map(u=>`- ${u.id}: ${u.title}`).join(n),l=[`Automate these ${s.length} test case${s.length===1?"":"s"} from Test Management:`,"",r,"","For each one: read the case from Test Management, write the test, run it scoped until it passes twice,","and map the script back onto the case so the Test Management entry shows its automation.","The steps were grounded in exploration — use the page and control names exactly as the case gives them."].join(n);Ha(C,{prompt:l,mode:Q})}function ys(s){(g??[]).filter(r=>!s(r)).length===0&&(Rt(),((K==null?void 0:K.length)??0)>0&&Ne("accept")),E(r=>{const l=(r??[]).filter(u=>!s(u));return l.length>0?l:null}),_(new Set),$(new Set)}async function js(s,n=[]){const r=a=>a&&typeof a.title=="string"&&a.title.trim(),l=s.filter(r);if(l.length===0)return;const u=n.filter(r).filter(a=>!l.includes(a)),c=a=>({title:a.title,steps:(a.steps??[]).slice(0,200).map(x=>`${(x==null?void 0:x.action)??""} ${(x==null?void 0:x.expectedResult)??""}`),data:(a.steps??[]).slice(0,200).map(x=>String((x==null?void 0:x.testData)??"")).filter(Boolean)});try{const a=new Map,x=new Map;if(u.length+l.length<=2e3){const m=[...u,...l],{matches:h,within:i}=await $s(m.map(c),{within:!0,from:u.length});l.forEach((t,o)=>{var b;h[o]&&a.set(t,h[o]);const p=i==null?void 0:i[o];p&&x.set(t,{title:((b=m[p.index])==null?void 0:b.title)??p.title,score:p.score})})}else for(let m=0;m<l.length;m+=1e3){const h=l.slice(m,m+1e3),{matches:i}=await $s(h.map(c));h.forEach((t,o)=>{i[o]&&a.set(t,i[o])})}if(a.size===0&&x.size===0)return;E(m=>m&&m.map(h=>(a.has(h)?Object.assign(h,{_dupOf:a.get(h)}):x.has(h)&&Object.assign(h,{_dupOfRun:x.get(h)}),h)).slice())}catch{}}function Ns(s){var c;const n=g??[],r=s.filter(a=>n[a]!=null),l=r.map(a=>n[a]);if(l.length===0)return;const u=((c=gt.current)==null?void 0:c.sourceIds)??[];X(null),Ie.mutate({testCases:l,folderId:ye||void 0,sourceIds:u.length>0?u:void 0,requirements:u.length>0&&ft.current.length>0?ft.current:void 0},{onSuccess:a=>It(l,r,Array.isArray(a==null?void 0:a.saved)?a.saved:[],Array.isArray(a==null?void 0:a.failed)?a.failed:[],n),onError:a=>X(`Save failed: ${(a==null?void 0:a.message)||"Unknown error"} Your cases are still here.`)})}function ba(){Ns((g??[]).map((s,n)=>n))}function ya(){Ns([...j].sort((s,n)=>s-n))}function vs(){return e.jsxs(e.Fragment,{children:[e.jsx("option",{value:"",children:"No folder (root)"}),ta.map(s=>e.jsxs("option",{value:s.id,children:[" ".repeat(s.depth),s.depth>0?"└ ":"",s.name]},s.id))]})}function ws(){return e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm text-gray-400 mb-1.5",htmlFor:"ai-gen-target-folder",children:"Target Folder"}),e.jsx("select",{id:"ai-gen-target-folder",value:ye,onChange:s=>Vt(s.target.value),className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-gray-200 text-sm focus:outline-none focus:ring-1 focus:ring-brand-500",children:vs()})]})}function ja(){const s=Ae==="select"&&M.length>0&&!S&&((g==null?void 0:g.length)??0)===0,n=Ae==="accept"?4:Ae==="review"||S||((g==null?void 0:g.length)??0)>0?3:s?2:1,r=[{n:1,label:"Choose a source",hint:"then Generate, or Choose requirements"},{n:2,label:"Choose requirements",hint:"optional"},{n:3,label:"Review the cases",hint:"edit, discard, fix"},{n:4,label:"Saved",hint:"automate or push to Jira"}];return e.jsx("ol",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 text-xs","aria-label":"AI Test Gen steps",children:r.map((l,u)=>{const c=l.n<n&&!(l.n===2&&!s&&n>2&&!ls),a=l.n===n;return e.jsxs("li",{className:"flex items-center gap-2","aria-current":a?"step":void 0,children:[e.jsxs("span",{className:`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full border ${a?"border-brand-500/40 bg-brand-500/15 text-brand-200":c?"border-emerald-500/25 text-emerald-300":"border-white/10 text-gray-500"}`,children:[e.jsx("span",{className:"font-semibold",children:c?"✓":l.n}),e.jsx("span",{children:l.label}),e.jsxs("span",{className:a?"text-brand-300/80":"text-gray-600",children:["· ",l.hint]})]}),u<r.length-1&&e.jsx("span",{className:"text-gray-600","aria-hidden":!0,children:"→"})]},l.n)})})}function Na(){return e.jsxs("div",{className:"flex items-center gap-2 whitespace-nowrap",children:[e.jsx("span",{className:"text-sm text-gray-300",children:"Coverage:"}),e.jsxs("div",{className:"inline-flex rounded-lg border border-white/10 bg-surface-2 p-0.5 text-sm",children:[e.jsx("button",{type:"button",onClick:()=>Nt("high-level"),className:`px-3 py-1 rounded-md transition-colors ${te==="high-level"?"bg-brand-600 text-white":"text-gray-400 hover:text-gray-200"}`,title:"Functional coverage — fewer, higher-level tests (major + medium). Fast and lean.",children:"High-level"}),e.jsx("button",{type:"button",onClick:()=>{te!=="detailed"&&ze(!0)},className:`px-3 py-1 rounded-md transition-colors ${te==="detailed"?"bg-brand-600 text-white":"text-gray-400 hover:text-gray-200"}`,title:"Exhaustive — adds edge, boundary & security detail and per-persona variants (major + medium + low).",children:"Detailed"})]})]})}function Ss(s=!1){return e.jsxs("div",{className:"flex flex-wrap gap-x-5 gap-y-2 items-center",children:[e.jsxs("label",{className:"flex items-center gap-2 text-sm text-gray-300 cursor-pointer select-none whitespace-nowrap",children:[e.jsx("input",{type:"checkbox",checked:it,onChange:n=>Os(n.target.checked),className:"rounded border-white/20 bg-surface-2 text-brand-500 focus:ring-brand-500 focus:ring-offset-0"}),"Auto Save"]}),s&&e.jsxs("label",{className:"flex items-center gap-2 text-sm text-gray-300 cursor-pointer select-none whitespace-nowrap",title:"Skip requirements that already have test cases (matched by source-quote fingerprint). Useful after editing a source document.",children:[e.jsx("input",{type:"checkbox",checked:Oe,onChange:n=>St(n.target.checked),className:"rounded border-white/20 bg-surface-2 text-brand-500 focus:ring-brand-500 focus:ring-offset-0"}),"Incremental mode ",e.jsx("span",{className:"text-xs text-gray-500",children:"(skip already-covered)"})]}),s&&e.jsxs("label",{className:"flex items-center gap-2 text-sm text-gray-300 cursor-pointer select-none whitespace-nowrap",title:"Use what exploration observed for page names, control labels and role access. Requirements still decide every expected result.",children:[e.jsx("input",{type:"checkbox",checked:Be,onChange:n=>Ks(n.target.checked),className:"rounded border-white/20 bg-surface-2 text-brand-500 focus:ring-brand-500 focus:ring-offset-0"}),"Use app knowledge",e.jsx("span",{className:"text-xs text-gray-500",children:F?F.isEmpty?"(nothing explored yet)":`(${F.summary})`:"(navigation from exploration)"})]})]})}function va(){return ss?e.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 rounded-lg bg-emerald-500/15 border border-emerald-500/30 text-emerald-300 text-sm animate-in fade-in",children:[e.jsx(Xe,{className:"w-4 h-4 shrink-0"}),e.jsx("span",{children:ss}),e.jsx("button",{onClick:()=>as(null),className:"ml-auto text-emerald-400 hover:text-emerald-200",children:e.jsx(pe,{className:"w-4 h-4"})})]}):null}function wa(){return is?e.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 rounded-lg bg-red-500/15 border border-red-500/30 text-red-300 text-sm animate-in fade-in",children:[e.jsx(de,{className:"w-4 h-4 shrink-0"}),e.jsx("span",{children:is}),e.jsx("button",{onClick:()=>X(null),className:"ml-auto text-red-400 hover:text-red-200",children:e.jsx(pe,{className:"w-4 h-4"})})]}):null}function ks(){const s=(g==null?void 0:g.length)??0;return e.jsxs("div",{className:"flex items-center justify-between gap-4 p-4 bg-surface-1 border border-brand-500/30 rounded-lg",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[e.jsxs("div",{className:"relative flex-shrink-0",children:[e.jsx("div",{className:"absolute inset-0 bg-brand-500/20 rounded-full blur-md animate-pulse"}),e.jsx(le,{className:"w-5 h-5 text-brand-400 animate-spin relative"})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"text-sm text-gray-200",children:[s===0?"Contacting AI…":"Generating test cases",fe?e.jsxs("span",{className:"text-gray-500",children:[" — ",s," of ~",fe]}):s>0&&e.jsxs("span",{className:"text-gray-500",children:[" — ",s," so far"]}),ht&&e.jsxs("span",{className:"text-gray-500",children:[" · script ",ht.done,"/",ht.total]}),Z&&Z.totalSources>1&&e.jsxs("span",{className:"text-gray-500",children:[" ","· source ",Z.sourcesDone+1,"/",Z.totalSources]}),Z&&Z.totalChunks>1&&e.jsxs("span",{className:"text-gray-500",children:[" ","· section ",Z.chunksDone+1,"/",Z.totalChunks]}),L&&e.jsxs("span",{className:"text-gray-500",children:[" ","· ",L.phaseLabel,L.totalRequirements>0&&L.phase==="generating"&&e.jsxs(e.Fragment,{children:[" (",L.requirementsDone,"/",L.totalRequirements,")"]}),L.critiqueIssues>0&&L.phase!=="critiquing"&&e.jsxs("span",{className:"ml-2 text-amber-300",children:["⚠ ",L.critiqueIssues," quality issue",L.critiqueIssues===1?"":"s"]})]})]}),Z&&Z.sourceTitle&&e.jsxs("p",{className:"text-xs text-gray-500 mt-0.5 truncate",title:Z.sourceTitle,children:["Reading: ",Z.sourceTitle]}),(L==null?void 0:L.currentRequirement)&&e.jsxs("p",{className:"text-xs text-gray-500 mt-0.5 truncate",title:`${L.currentRequirement.id} — ${L.currentRequirement.title}`,children:[e.jsx("span",{className:"font-mono text-brand-300",children:L.currentRequirement.id}),e.jsx("span",{className:"mx-1",children:"—"}),L.currentRequirement.title,L.currentRequirement.strategies.length>0&&e.jsxs("span",{className:"ml-2 text-gray-600",children:["[",L.currentRequirement.strategies.join(", "),"]"]})]}),e.jsxs("p",{className:"text-xs text-gray-500 mt-0.5",children:["Elapsed ",e.jsx(nr,{startedAt:ge,active:S}),". Results appear above as each test case is completed."]})]})]}),e.jsxs("button",{onClick:ra,className:"flex-shrink-0 flex items-center gap-1.5 px-3 py-1.5 bg-surface-2 hover:bg-surface-3 text-gray-300 hover:text-red-300 border border-white/10 rounded-md text-xs transition-colors",title:"Cancel generation (partial results will be kept)",children:[e.jsx(pe,{className:"w-3.5 h-3.5"}),"Cancel"]})]})}function Sa(){return e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 gap-4",children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 bg-brand-500/20 rounded-full blur-xl animate-pulse"}),e.jsx(le,{className:"w-10 h-10 text-brand-400 animate-spin relative"})]}),e.jsx("p",{className:"text-gray-300 text-sm",children:"AI is generating test cases..."}),e.jsx("p",{className:"text-gray-500 text-xs",children:"This may take a moment depending on complexity"})]})}function ka(){if(oe&&!S)return Sa();if(!S&&!g)return null;if(!S&&g&&g.length===0)return ls?null:e.jsxs("div",{className:"text-center py-12 text-gray-400",children:[e.jsx(de,{className:"w-8 h-8 mx-auto mb-3 text-amber-400"}),e.jsx("p",{children:"No test cases were generated. Try refining your input."})]});if(S&&(!g||g.length===0))return e.jsx("div",{className:"space-y-4",children:ks()});const s=g,n=()=>e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Xe,{className:"w-5 h-5 text-emerald-400"}),e.jsxs("span",{className:"text-gray-200 font-medium",children:["Generated ",s.length," test case",s.length!==1?"s":""]}),(()=>{const t=s.filter(w=>(w==null?void 0:w._grounding)==="grounded").length,o=s.filter(w=>(w==null?void 0:w._automatable)==="yes").length;if(!s.some(w=>(w==null?void 0:w._grounding)||(w==null?void 0:w._automatable)))return null;const b=s.some(w=>w==null?void 0:w._grounding);return e.jsxs("span",{className:"text-xs text-gray-500",children:["·"," ",b?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-emerald-300",children:t})," grounded"]}):e.jsx("span",{title:"No exploration run has recorded this app, so the navigation in these steps was not checked against anything. The requirement still decided every expected result.",children:"nothing explored"})," ","· ",e.jsx("span",{className:"text-cyan-300",children:o})," automatable"]})})()]}),e.jsxs("div",{className:"flex items-center gap-2",children:[(()=>{if(je)return e.jsx("button",{onClick:ga,className:"text-xs text-rose-300 hover:text-rose-200 transition-colors",children:"Stop deepening"});if(wt!=="high-level")return null;const t=new Set((g??[]).map(p=>p==null?void 0:p._requirementId).filter(Boolean)),o=M.filter(p=>t.has(p.id)&&!vt.has(p.id));return o.length<2?null:e.jsxs("button",{onClick:()=>void pa(o),disabled:Te,title:`Generate detailed tests (edge, boundary, security) for all ${o.length} requirements — about ${o.length} AI calls`,className:"text-xs text-brand-300 hover:text-brand-200 transition-colors disabled:opacity-40",children:["Deepen all ",o.length]})})(),(()=>{const t=(g??[]).filter(o=>{var p;return((p=o==null?void 0:o._critique)==null?void 0:p.length)>0});return t.length===0?null:e.jsxs("button",{onClick:()=>N(t),disabled:Te,title:"Have the AI rewrite the cases its review flagged — you see each change before it is used",className:"text-xs text-brand-300 hover:text-brand-200 transition-colors disabled:opacity-40",children:["Fix ",t.length," with AI"]})})(),(()=>{const t=(g??[]).filter(Ve).length;return t===0?null:e.jsxs("button",{onClick:()=>ys(Ve),disabled:Te,title:"Take the cases that look like existing ones off this list (nothing is deleted from Test Cases)",className:"text-xs text-amber-300 hover:text-amber-200 transition-colors disabled:opacity-40",children:["Discard ",t," possible duplicate",t===1?"":"s"]})})(),e.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-gray-400",children:[e.jsx("span",{children:"Save to"}),e.jsx("select",{"aria-label":"Folder to save into",value:ye,onChange:t=>Vt(t.target.value),className:"max-w-[12rem] bg-surface-2 border border-white/10 rounded-md px-2 py-1 text-gray-200 text-xs focus:outline-none focus:ring-1 focus:ring-brand-500",children:vs()})]}),(()=>{const t=ve.map(b=>b.idx),o=t.length>0&&t.every(b=>j.has(b)),p=hs?o?"Deselect Visible":`Select Visible (${t.length})`:j.size===s.length?"Deselect All":"Select All";return e.jsx("button",{onClick:aa,className:"text-xs text-gray-400 hover:text-gray-200 transition-colors",children:p})})(),e.jsxs("button",{onClick:ya,disabled:j.size===0||Ie.isPending||S||je!==null,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-lg bg-brand-600 hover:bg-brand-500 text-white disabled:opacity-40 disabled:cursor-not-allowed transition-colors",children:[Ie.isPending?e.jsx(le,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(Ds,{className:"w-3.5 h-3.5"}),"Save Selected (",j.size,")"]}),e.jsxs("button",{onClick:ba,disabled:Ie.isPending||S||je!==null,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-lg bg-gradient-to-r from-purple-600 to-brand-600 hover:from-purple-500 hover:to-brand-500 text-white disabled:opacity-40 disabled:cursor-not-allowed transition-colors",children:[Ie.isPending?e.jsx(le,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(Ds,{className:"w-3.5 h-3.5"}),"Save All"]})]})]}),r=(t,o,p)=>{const b=new Set(t);b.has(o)?b.delete(o):b.add(o),p(b)},l=t=>{const o=new Set(Kt);o.has(t)?o.delete(t):o.add(t),pt(o)},u=()=>pt(new Set),c=()=>pt(new Set(xs.map(t=>t.key))),a=()=>{Ot(""),Bt(new Set),Jt(new Set),Ut(new Set),qe(new Set)},x=(t,o)=>{E(p=>p&&p.map(b=>{if(b!==t)return b;const w=Array.isArray(b.steps)?b.steps:[],re=o.steps.map((ce,V)=>{const y=w[V];return y&&typeof y=="object"&&String(y.action??"")===ce.action?{...y,...ce}:{...ce}});return{...b,title:o.title,priority:o.priority,preconditions:o.preconditions,steps:re,_edited:!0}})),R(null)},m=(t,o)=>{E(p=>{if(!p)return p;const b=[...p],w=b[t];return w?(b[t]={...w,_automatable:o,_automatableReason:"set by a reviewer"},b):p})},h=(t,o)=>{var p,b,w,re,ce,V;return e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-3 px-4 py-3",children:[e.jsx("input",{type:"checkbox",checked:j.has(o),onChange:()=>sa(o),className:"rounded border-white/20 bg-surface-2 text-brand-500 focus:ring-brand-500 focus:ring-offset-0"}),e.jsx("button",{onClick:()=>gs(o),className:"text-gray-400 hover:text-gray-200 transition-colors",children:k.has(o)?e.jsx(Dt,{className:"w-4 h-4"}):e.jsx(Mt,{className:"w-4 h-4"})}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("button",{onClick:()=>gs(o),className:"text-left w-full text-gray-200 font-medium text-sm hover:text-white transition-colors truncate",children:t.title||t.name||`Test Case ${o+1}`})}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[t._edited&&e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-brand-500/20 text-brand-300",title:"You changed this case",children:"edited"}),t._dupOf&&e.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full bg-amber-500/20 text-amber-300",title:`Looks like ${t._dupOf.id}: "${t._dupOf.title}" (${Math.round(t._dupOf.score*100)}% alike) — already in Test Cases.`,children:["possible duplicate of ",t._dupOf.id]}),!t._dupOf&&t._dupOfRun&&e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-amber-500/20 text-amber-300",title:`Does what "${t._dupOfRun.title}" (earlier in this list) does — ${Math.round(t._dupOfRun.score*100)}% alike. That one is kept.`,children:"repeats a case above"}),((p=t._critique)==null?void 0:p.length)>0&&e.jsxs("span",{className:`text-xs px-2 py-0.5 rounded-full ${t._critique.some(y=>y.severity==="major")?"bg-rose-500/20 text-rose-300":"bg-amber-500/20 text-amber-300"}`,title:t._critique.map(y=>`${y.kind}: ${y.message}`).join(`
|
|
4
4
|
`),children:[t._critique.length," review note",t._critique.length===1?"":"s"]}),t._fixedNote&&e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-emerald-500/20 text-emerald-300",title:t._fixedNote,children:"fixed"}),t._strategy&&e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-cyan-500/15 text-cyan-300 font-mono",title:`Test strategy: ${t._strategy}`,children:t._strategy}),t.priority&&e.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full ${sr[t.priority]??"bg-gray-500/20 text-gray-300"}`,children:t.priority}),t.type&&e.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full ${ar[t.type]??"bg-gray-500/20 text-gray-300"}`,children:t.type}),t._persona&&e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-violet-500/15 text-violet-300",title:`Persona: ${t._persona}`,children:t._persona}),t._grounding&&me[t._grounding]&&e.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full ${me[t._grounding].cls}`,title:me[t._grounding].title,children:me[t._grounding].label}),t._automatable&&ne[t._automatable]&&e.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full ${ne[t._automatable].cls}`,title:t._automatableReason||"",children:ne[t._automatable].label}),t._sourceScriptName&&e.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full bg-purple-500/15 text-purple-300 border border-purple-500/20 flex items-center gap-1",title:t._sourceScript,children:[e.jsx(Es,{className:"w-3 h-3"}),t._sourceScriptName]})]})]}),k.has(o)&&e.jsxs("div",{className:"px-4 pb-4 border-t border-white/5",children:[D!==t&&e.jsxs("div",{className:"flex justify-end gap-2 mt-3",children:[e.jsx("button",{type:"button",onClick:()=>R(t),disabled:Te,className:"text-xs px-2.5 py-1 rounded-md border border-white/10 text-gray-300 hover:text-white hover:border-white/20 disabled:opacity-40",children:"Edit"}),e.jsx("button",{type:"button",onClick:()=>ys(y=>y===t),disabled:Te,title:"Take this case off the list — it will not be saved",className:"text-xs px-2.5 py-1 rounded-md border border-white/10 text-gray-400 hover:text-red-300 hover:border-red-500/30 disabled:opacity-40",children:"Discard"})]}),D===t&&e.jsx(rr,{tc:t,onSave:y=>x(t,y),onCancel:()=>R(null)}),D!==t&&((b=t._critique)==null?void 0:b.length)>0&&e.jsxs("div",{className:"mt-3 rounded-lg border border-amber-500/25 bg-amber-500/10 p-3 space-y-1.5",children:[e.jsx("p",{className:"text-xs font-medium text-amber-200",children:"The AI review found"}),t._critique.map((y,ee)=>e.jsxs("p",{className:"text-xs text-gray-300 leading-relaxed",children:[e.jsx("span",{className:y.severity==="major"?"text-rose-300":"text-amber-300",children:y.kind})," — ",y.message,y.suggestion?e.jsxs("span",{className:"text-gray-500",children:[" Suggested: ",y.suggestion]}):null]},ee))]}),D!==t&&t._fixedNote&&e.jsxs("p",{className:"mt-3 text-xs text-emerald-300",children:["Fixed by AI: ",t._fixedNote]}),D!==t&&t.description&&e.jsx("p",{className:"text-gray-400 text-sm mt-3 mb-3",children:t.description}),D!==t&&((w=t.tags)==null?void 0:w.length)>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5 mb-3",children:t.tags.map((y,ee)=>e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-brand-500/15 text-brand-300",children:y},ee))}),D!==t&&t.preconditions&&e.jsxs("div",{className:"mb-3",children:[e.jsx("h4",{className:"text-xs font-medium text-gray-400 uppercase tracking-wider mb-1",children:"Preconditions"}),e.jsx("p",{className:"text-sm text-gray-300",children:t.preconditions})]}),D!==t&&((re=t.steps)==null?void 0:re.length)>0&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-medium text-gray-400 uppercase tracking-wider mb-2",children:"Steps"}),e.jsx("div",{className:"space-y-2",children:t.steps.map((y,ee)=>e.jsxs("div",{className:"flex gap-3 text-sm",children:[e.jsx("span",{className:"text-brand-400 font-mono text-xs w-6 pt-0.5 text-right shrink-0",children:ee+1}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-gray-200",children:y.action||y.description||y}),y.expectedResult&&e.jsxs("p",{className:"text-gray-400 text-xs mt-0.5",children:[e.jsx("span",{className:"text-emerald-400 font-medium",children:"Expected:"})," ",y.expectedResult]}),y.testData&&e.jsxs("p",{className:"text-gray-400 text-xs mt-0.5",children:[e.jsx("span",{className:"text-blue-400 font-medium",children:"Data:"})," ",y.testData]}),typeof y._grounded=="boolean"&&e.jsxs("p",{className:"text-xs mt-1 flex items-center gap-1.5",children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${y._grounded?"bg-emerald-400":"bg-gray-500"}`}),e.jsx("span",{className:y._grounded?"text-emerald-400":"text-gray-500",children:y._grounded?"observed":"not observed"}),y._pageRef&&e.jsx("span",{className:"text-gray-600 font-mono",children:y._pageRef})]})]})]},ee))})]}),Array.isArray(t._groundingRefs)&&t._groundingRefs.length>0&&e.jsxs("div",{className:"mt-3 rounded-lg bg-surface-2/60 border border-white/5 px-3 py-2",children:[e.jsx("h4",{className:"text-xs font-medium text-gray-400 uppercase tracking-wider mb-1.5",children:"Grounded by"}),e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[t._groundingRefs.map((y,ee)=>e.jsx("span",{className:"text-xs font-mono px-2 py-0.5 rounded bg-emerald-500/20 text-emerald-300",children:y},ee)),t._requirementId&&e.jsxs("span",{className:"text-xs px-2 py-0.5 rounded bg-amber-500/20 text-amber-300",title:"Supplies the expected results",children:[t._requirementId," — expected results"]})]})]}),t._automatable&&ne[t._automatable]&&e.jsxs("div",{className:"mt-3 rounded-lg bg-surface-2/60 border border-white/5 px-3 py-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h4",{className:"text-xs font-medium text-gray-400 uppercase tracking-wider",children:"Automation"}),e.jsx("span",{className:"flex-1"}),e.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full ${ne[t._automatable].cls}`,children:ne[t._automatable].label})]}),t._automatableReason&&e.jsx("p",{className:"text-xs text-gray-400 mt-1.5 leading-relaxed",children:t._automatableReason}),e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:["yes","needs-setup","manual"].filter(y=>y!==t._automatable).map(y=>e.jsxs("button",{onClick:()=>m(o,y),className:"text-xs px-2 py-1 rounded-md border border-white/10 text-gray-400 hover:text-gray-200 hover:border-white/20 transition-colors",children:["Mark ",ne[y].label]},y))})]}),((ce=t._specDrift)==null?void 0:ce.requirementSays)&&((V=t._specDrift)==null?void 0:V.appDoes)&&e.jsxs("div",{className:"mt-3 rounded-lg bg-rose-500/10 border border-rose-500/25 px-3 py-2",children:[e.jsx("h4",{className:"text-xs font-medium text-rose-300 uppercase tracking-wider mb-1.5",children:"Possible spec drift"}),e.jsxs("p",{className:"text-xs text-gray-300 leading-relaxed",children:[e.jsx("span",{className:"text-gray-400",children:"The requirement says"})," ",t._specDrift.requirementSays]}),e.jsxs("p",{className:"text-xs text-gray-300 leading-relaxed mt-1",children:[e.jsx("span",{className:"text-gray-400",children:"Exploration saw"})," ",t._specDrift.appDoes,t._specDrift.citation&&e.jsx("span",{className:"text-gray-600 font-mono ml-1.5",children:t._specDrift.citation})]}),e.jsx("p",{className:"text-xs text-gray-500 mt-1.5 leading-relaxed",children:"This case asserts the requirement, so it is expected to fail until the disagreement is settled."})]})]})]},o)},i=t=>{const o=new Map;for(const{tc:b}of t){const w=b==null?void 0:b._strategy;typeof w=="string"&&o.set(w,(o.get(w)||0)+1)}const p=Array.from(o.entries()).map(([b,w])=>`${b}: ${w}`);return p.length>0?`${t.length} tests · ${p.join(", ")}`:`${t.length} tests`};return e.jsxs("div",{className:"space-y-4",children:[n(),!S&&((g==null?void 0:g.length)??0)>0&&e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-3 space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:"flex-1 min-w-[200px]",children:e.jsx("input",{type:"text",value:at,onChange:t=>Ot(t.target.value),placeholder:"Search test titles, steps, tags…",className:"w-full px-3 py-1.5 text-sm rounded-lg bg-surface-2 border border-white/5 text-gray-200 placeholder-gray-500 focus:outline-none focus:ring-1 focus:ring-brand-500"})}),e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-gray-400",children:[e.jsx("span",{children:"Group by:"}),e.jsxs("select",{value:ae,onChange:t=>Ps(t.target.value),className:"px-2 py-1 rounded bg-surface-2 border border-white/5 text-gray-200 focus:outline-none focus:ring-1 focus:ring-brand-500",children:[e.jsx("option",{value:"requirement",children:"Requirement"}),e.jsx("option",{value:"strategy",children:"Strategy"}),e.jsx("option",{value:"priority",children:"Priority"}),e.jsx("option",{value:"flat",children:"Flat (no grouping)"})]})]}),ae!=="flat"&&e.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[e.jsx("button",{onClick:u,className:"px-2 py-1 rounded bg-surface-2 hover:bg-surface-3 text-gray-400 hover:text-gray-200 transition-colors",children:"Expand all"}),e.jsx("button",{onClick:c,className:"px-2 py-1 rounded bg-surface-2 hover:bg-surface-3 text-gray-400 hover:text-gray-200 transition-colors",children:"Collapse all"})]})]}),(g??[]).some(t=>{var o;return(t==null?void 0:t._grounding)||(t==null?void 0:t._automatable)||Ve(t)||((o=t==null?void 0:t._critique)==null?void 0:o.length)})&&e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.jsx("span",{className:"text-xs text-gray-500 mr-1",children:"Quality:"}),Ke&&e.jsx(he,{label:"grounded",active:B.has("grounded"),onToggle:()=>r(B,"grounded",qe),color:"emerald"}),e.jsx(he,{label:"automatable",active:B.has("automatable"),onToggle:()=>r(B,"automatable",qe),color:"cyan"}),(g??[]).some(Ve)&&e.jsx(he,{label:"possible duplicates",active:B.has("duplicates"),onToggle:()=>r(B,"duplicates",qe),color:"amber"}),(g??[]).some(t=>{var o;return(o=t==null?void 0:t._critique)==null?void 0:o.length})&&e.jsx(he,{label:"review notes",active:B.has("review-notes"),onToggle:()=>r(B,"review-notes",qe),color:"amber"}),Ke&&e.jsx(he,{label:"needs a look",active:B.has("needs-a-look"),onToggle:()=>r(B,"needs-a-look",qe),color:"gray"})]}),De.strategies.size>0&&e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.jsx("span",{className:"text-xs text-gray-500 mr-1",children:"Strategy:"}),Array.from(De.strategies).sort().map(t=>e.jsx(he,{label:t,active:Se.has(t),onToggle:()=>r(Se,t,Bt),color:"cyan"},t))]}),De.priorities.size>0&&e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.jsx("span",{className:"text-xs text-gray-500 mr-1",children:"Priority:"}),["critical","high","medium","low"].filter(t=>De.priorities.has(t)).map(t=>e.jsx(he,{label:t,active:ke.has(t),onToggle:()=>r(ke,t,Jt),color:"amber"},t))]}),De.personas.size>0&&e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.jsx("span",{className:"text-xs text-gray-500 mr-1",children:"Persona:"}),Array.from(De.personas).sort().map(t=>e.jsx(he,{label:t,active:Ce.has(t),onToggle:()=>r(Ce,t,Ut),color:"violet"},t))]}),e.jsxs("div",{className:"flex items-center justify-between text-xs text-gray-500",children:[e.jsxs("span",{children:["Showing ",e.jsx("span",{className:"text-gray-300",children:us})," of ",e.jsx("span",{className:"text-gray-300",children:ms})," tests"]}),hs&&e.jsx("button",{onClick:a,className:"text-brand-400 hover:text-brand-300 transition-colors",children:"Clear filters"})]})]}),us===0&&ms>0?e.jsxs("div",{className:"text-center py-12 text-gray-400 bg-surface-1 rounded-xl border border-white/5",children:[e.jsx(de,{className:"w-8 h-8 mx-auto mb-3 text-amber-400"}),e.jsx("p",{children:"No test cases match the current filters."}),e.jsx("button",{onClick:a,className:"mt-3 text-sm text-brand-400 hover:text-brand-300",children:"Clear filters"})]}):ae==="flat"?ve.map(({tc:t,idx:o})=>h(t,o)):xs.map(t=>{const o=Kt.has(t.key);return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>l(t.key),className:"flex-1 min-w-0 flex items-center gap-2 px-3 py-2 bg-surface-2 hover:bg-surface-3 rounded-lg text-left transition-colors",children:[o?e.jsx(Mt,{className:"w-4 h-4 text-gray-400 flex-shrink-0"}):e.jsx(Dt,{className:"w-4 h-4 text-gray-400 flex-shrink-0"}),e.jsx("span",{className:"font-medium text-gray-200 text-sm flex-1 truncate",children:t.label}),e.jsx("span",{className:"text-xs text-gray-500 flex-shrink-0",children:i(t.items)})]}),wt==="high-level"&&ae==="requirement"&&t.key!=="ungrouped"&&(()=>{const p=M.find(re=>re.id===t.key);if(!p)return null;const b=je===t.key,w=vt.has(t.key);return e.jsxs("button",{onClick:()=>bs(p),disabled:Te||w,className:`flex-shrink-0 flex items-center gap-1 px-2.5 py-2 text-xs rounded-lg border whitespace-nowrap disabled:cursor-not-allowed ${w?"bg-emerald-500/10 text-emerald-300 border-emerald-500/20 disabled:opacity-100":"bg-brand-500/15 text-brand-300 border-brand-500/20 hover:bg-brand-500/25 disabled:opacity-50"}`,title:w?"Detailed tests already generated for this requirement":"Generate exhaustive detailed tests (edge, boundary, security) for this requirement and add them here",children:[b?e.jsx(le,{className:"w-3 h-3 animate-spin"}):w?e.jsx(Xe,{className:"w-3 h-3"}):e.jsx(Ze,{className:"w-3 h-3"}),b?"Deepening…":w?"Deepened":"Deepen"]})})()]}),!o&&e.jsx("div",{className:"space-y-2 pl-2",children:t.items.map(({tc:p,idx:b})=>h(p,b))})]},t.key)}),!1,S&&ks(),!S&&Pt.length>0&&e.jsxs("div",{className:"w-full bg-surface-1 rounded-xl border border-white/5 p-5 space-y-4",children:[e.jsx("h3",{className:"text-base font-semibold text-gray-200",children:"Detected Application Domain"}),e.jsx("div",{className:"grid gap-3 grid-cols-1",children:Pt.map((t,o)=>e.jsxs("div",{className:"w-full bg-surface-2 rounded-lg p-4 border border-white/5",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-3 mb-2",children:[e.jsx("span",{className:"text-sm font-mono font-medium text-brand-300 bg-brand-500/10 px-2 py-0.5 rounded",children:t.primary}),e.jsx("span",{className:"text-xs text-gray-500 truncate max-w-[240px]",title:t.sourceTitle,children:t.sourceTitle})]}),t.description&&e.jsx("p",{className:"text-sm text-gray-300 mb-3 leading-relaxed",children:t.description}),t.concerns.length>0&&e.jsx("ul",{className:"text-sm text-gray-400 space-y-1 list-disc list-inside marker:text-brand-400/60",children:t.concerns.slice(0,5).map((p,b)=>e.jsx("li",{className:"leading-relaxed",children:p},b))})]},o))})]}),!S&&st.length>0&&e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-amber-500/20 p-4",children:[e.jsxs("h3",{className:"text-sm font-semibold text-amber-300 mb-2",children:[st.length," requirement",st.length===1?"":"s"," skipped (already covered)"]}),e.jsx("ul",{className:"text-xs text-gray-400 space-y-1 max-h-40 overflow-y-auto",children:st.map(t=>e.jsxs("li",{className:"flex gap-2",children:[e.jsx("span",{className:"font-mono text-amber-400 flex-shrink-0",children:t.id}),e.jsx("span",{className:"truncate",title:t.title,children:t.title})]},t.id))})]}),!S&&M.length>0&&e.jsx(Za,{requirements:M,tests:s,depth:wt}),!S&&n(),e.jsx("div",{ref:Ht,"aria-hidden":!0})]})}function Ca(){return e.jsxs("div",{className:"space-y-6",children:[U&&!S&&U.id!==_e&&e.jsxs("div",{className:"flex flex-wrap items-center gap-3 px-4 py-3 rounded-lg bg-brand-500/10 border border-brand-500/25 text-sm",role:"status",children:[e.jsx(Ze,{className:"w-4 h-4 text-brand-300 shrink-0"}),e.jsx("span",{className:"text-gray-200",children:U.status==="running"?e.jsxs(e.Fragment,{children:["A generation is still running — from ",e.jsx("b",{children:U.label||"your source"}),U.cases>0?e.jsxs(e.Fragment,{children:[", ",U.cases," test case",U.cases===1?"":"s"," so far"]}):null,"."]}):U.stopAfterExtraction?e.jsxs(e.Fragment,{children:["Requirements extracted from ",e.jsx("b",{children:U.label||"your source"})," are ready to choose from."]}):e.jsxs(e.Fragment,{children:["A generation from ",e.jsx("b",{children:U.label||"your source"})," finished with ",U.cases," test case",U.cases===1?"":"s",U.saved>0?e.jsxs(e.Fragment,{children:[" (",U.saved," auto-saved)"]}):null,"."]})}),e.jsxs("span",{className:"ml-auto flex gap-2",children:[e.jsx("button",{onClick:()=>la(U),className:"px-3 py-1.5 rounded-lg bg-brand-600 hover:bg-brand-500 text-white text-xs font-medium",children:U.status==="running"?"Follow it":"Show it"}),e.jsx("button",{onClick:()=>{As(U.id).catch(()=>{}),nt(null)},className:"px-3 py-1.5 rounded-lg bg-surface-2 hover:bg-surface-3 text-gray-300 text-xs",children:"Dismiss"})]})]}),e.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3",children:tr.map(s=>e.jsxs("button",{onClick:()=>Y(s.id),className:`flex flex-col items-start gap-2 p-4 rounded-xl border transition-all text-left ${q===s.id?"bg-brand-500/10 border-brand-500/30 shadow-lg shadow-brand-500/5":"bg-surface-1 border-white/5 hover:border-white/10"}`,children:[e.jsx("div",{className:`p-2 rounded-lg ${q===s.id?"bg-brand-500/20 text-brand-300":"bg-surface-2 text-gray-400"}`,children:s.icon}),e.jsxs("div",{children:[e.jsx("p",{className:`text-sm font-medium ${q===s.id?"text-brand-300":"text-gray-200"}`,children:s.label}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:s.description})]})]},s.id))}),q==="sources"&&ja(),e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-6",children:[q==="sources"&&qa(),q==="reverse"&&Ra()]}),_a(),Aa(),va(),wa(),ka()]})}function qa(){const s=Array.isArray(z==null?void 0:z.sources)?z.sources:[],n={requirement:"📋",nlp:"💬",jira:"🎫",document:"📎"},r={requirement:"Requirement",nlp:"Note",jira:"JIRA Ticket",document:"Document"},l=["all","requirement","nlp","jira","document"],u=xt.trim().toLowerCase(),c=s.filter(a=>dt!=="all"&&a.type!==dt?!1:u?`${a.title||""} ${a.content||""}`.toLowerCase().includes(u):!0);return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3 gap-3 flex-wrap",children:[e.jsx("label",{className:"text-sm font-medium text-gray-300",children:"Select Source for Test Generation"}),e.jsx("div",{className:"flex items-center gap-1.5",children:l.map(a=>{var x;return e.jsx("button",{onClick:()=>os(a),className:`px-2.5 py-1 rounded-md text-[11px] font-medium transition-colors border ${dt===a?"bg-brand-600 hover:bg-brand-500 text-white border-brand-500":"bg-surface-2 text-gray-400 border-white/5 hover:text-gray-200 hover:bg-surface-3"}`,children:a==="all"?"All":((x=r[a])==null?void 0:x.split(" ")[0])||a},a)})})]}),e.jsxs("div",{className:"relative mb-3",children:[e.jsx(Is,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-gray-500 pointer-events-none"}),e.jsx("input",{type:"text",value:xt,onChange:a=>qt(a.target.value),placeholder:"Search sources by title or content…",className:"w-full pl-9 pr-9 py-2 text-sm rounded-lg bg-surface-2 border border-white/10 text-gray-200 placeholder-gray-500 focus:outline-none focus:ring-1 focus:ring-brand-500"}),xt&&e.jsx("button",{onClick:()=>qt(""),className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 rounded text-gray-500 hover:text-gray-300 hover:bg-surface-3 transition-colors",title:"Clear search",children:e.jsx(pe,{className:"w-3.5 h-3.5"})})]}),c.length>0?e.jsxs("div",{className:"bg-surface-2 rounded-xl border border-white/10 overflow-hidden max-h-[300px] overflow-y-auto",children:[e.jsx("div",{className:"px-4 py-2 bg-surface-2 border-b border-white/10 sticky top-0 z-10 backdrop-blur supports-[backdrop-filter]:bg-surface-2/95",children:e.jsx("span",{className:"text-xs text-gray-400",children:"Select one source to generate test cases from"})}),c.map(a=>{const x=a.linkedTestCaseCount??0,m=P.has(a.id);return e.jsxs("label",{className:`flex items-start gap-3 px-4 py-3 border-b border-white/5 last:border-b-0 cursor-pointer transition-colors ${m?"bg-brand-500/5":"hover:bg-white/[0.02]"}`,children:[e.jsx("input",{type:"radio",name:"ai-test-gen-source-main",checked:m,onChange:()=>rs(new Set([a.id])),className:"mt-0.5 border-white/20 bg-surface-1 text-brand-500 focus:ring-brand-500 focus:ring-offset-0"}),e.jsx("span",{className:"text-base flex-shrink-0",children:n[a.type]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm text-gray-200 font-medium",children:a.title}),a.content&&e.jsxs("p",{className:"text-xs text-gray-500 mt-0.5 line-clamp-2",children:[a.content.substring(0,120),a.content.length>120?"...":""]})]}),e.jsxs("span",{className:`flex-shrink-0 px-2 py-0.5 rounded text-[10px] font-medium ${x>0?"bg-emerald-500/15 text-emerald-300 border border-emerald-500/20":"bg-surface-1 text-gray-500 border border-white/5"}`,title:x>0?`${x} test case${x===1?"":"s"} already generated for this source`:"No test cases generated yet",children:[x," TC",x===1?"":"s"]}),(a.staleCases??0)>0&&e.jsxs("span",{className:"flex-shrink-0 px-2 py-0.5 rounded text-[10px] font-medium bg-amber-500/20 text-amber-300",title:"The source's text changed after these test cases were generated",children:[a.staleCases," to review"]}),e.jsx("span",{className:"flex-shrink-0 px-2 py-0.5 rounded text-[10px] font-medium bg-surface-1 text-gray-400 border border-white/5",children:r[a.type]||a.type})]},a.id)})]}):e.jsxs("div",{className:"text-center py-10 bg-surface-2 rounded-xl border border-white/10",children:[e.jsx(Ft,{size:28,className:"mx-auto mb-2 text-gray-500 opacity-50"}),(xt||dt!=="all")&&s.length>0?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-gray-400 mb-1",children:"No sources match your search"}),e.jsx("button",{onClick:()=>{qt(""),os("all")},className:"text-xs text-brand-400 hover:text-brand-300",children:"Clear search and filters"})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-gray-400 mb-1",children:"No sources available"}),e.jsxs("p",{className:"text-xs text-gray-500",children:["Add requirements, notes, or documents in the ",e.jsx("a",{href:"/sources",className:"text-brand-400 hover:text-brand-300 underline",children:"Sources"})," page first"]})]})]})]}),(()=>{const a=s.filter(m=>P.has(m.id)&&(m.staleCases??0)>0);if(a.length===0)return null;const x=a.reduce((m,h)=>m+(h.staleCases??0),0);return e.jsxs("div",{className:"flex flex-wrap items-center gap-3 px-4 py-3 rounded-lg bg-amber-500/10 border border-amber-500/25 text-sm",role:"status",children:[e.jsx(de,{className:"w-4 h-4 text-amber-300 shrink-0"}),e.jsxs("span",{className:"text-gray-200 flex-1 min-w-[16rem]",children:[e.jsx("b",{children:a[0].title})," changed after its test cases were generated — ",x," case",x===1?"":"s"," need",x===1?"s":""," review (Test Cases shows what changed). Regenerating with Incremental mode makes cases only for the requirements whose text changed."]}),e.jsx("button",{onClick:()=>{St(!0),ut({},"generate",()=>mt(!0))},disabled:oe,className:"px-3 py-1.5 rounded-lg bg-brand-600 hover:bg-brand-500 text-white text-xs font-medium disabled:opacity-50",children:"Regenerate changed requirements"})]})})(),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:[ws(),e.jsx("div",{className:"flex items-end sm:col-span-1 lg:col-span-2",children:Ss(!0)})]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 pt-2",children:[e.jsx("div",{className:"flex flex-wrap items-center gap-4",children:Na()}),e.jsxs("div",{className:"flex items-center gap-2",children:[A&&P.size>0&&(A.tooLarge?e.jsx("span",{className:"text-xs text-amber-300 mr-1",title:"One run reads up to about 400,000 characters",children:"Too large for one run — split the source"}):e.jsxs("span",{className:"text-xs text-gray-500 mr-1",title:`${A.extractionCalls} call(s) to read the document in ${A.chunks} part(s), then about one per requirement (${A.requirements.low}–${A.requirements.high} requirements)`,children:["About ",A.totalCalls.low===A.totalCalls.high?A.totalCalls.low:`${A.totalCalls.low}–${A.totalCalls.high}`," AI calls"]})),A&&P.size>0&&!A.tooLarge&&A.cases&&A.cases.high>0&&e.jsxs("span",{className:"text-xs text-gray-500 mr-1",title:te==="detailed"?"Detailed makes about one data-driven case per test type for each requirement":"High-level makes 1–3 focused cases per requirement",children:["· ",A.cases.low===A.cases.high?A.cases.low:`${A.cases.low}–${A.cases.high}`," test cases"]}),e.jsxs("button",{onClick:oa,disabled:P.size===0||oe,className:"flex items-center gap-2 px-4 py-2.5 rounded-lg bg-surface-2 border border-white/10 hover:border-white/20 text-gray-200 font-medium text-sm disabled:opacity-40 disabled:cursor-not-allowed transition-all",title:"Extract the requirements first and choose which ones to generate from. Shows how much of each would be guesswork.",children:[oe?e.jsx(le,{className:"w-4 h-4 animate-spin"}):e.jsx(Ft,{className:"w-4 h-4"}),"Choose requirements"]}),e.jsxs("button",{onClick:ua,disabled:P.size===0||oe,className:"flex items-center gap-2 px-5 py-2.5 rounded-lg bg-gradient-to-r from-purple-600 to-brand-600 hover:from-purple-500 hover:to-brand-500 text-white font-medium text-sm disabled:opacity-40 disabled:cursor-not-allowed transition-all shadow-lg shadow-brand-500/20",children:[oe?e.jsx(le,{className:"w-4 h-4 animate-spin"}):e.jsx(Ze,{className:"w-4 h-4"}),"Generate from ",P.size," Source",P.size!==1?"s":""]})]})]})]})}function _a(){if(Ae!=="select"||M.length===0||S)return null;const s=M.filter(c=>xe.has(c.id)),n=M.filter(c=>{var a;return(((a=Ct[c.id])==null?void 0:a.pagesMatched)??0)>0}).length,r=xe.size===M.length,l=((F==null?void 0:F.isEmpty)??!1)||n===0,u=c=>{Re(a=>{const x=new Set(a);return x.has(c)?x.delete(c):x.add(c),x})};return e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 overflow-hidden",children:[e.jsxs("div",{className:"flex items-start gap-4 px-5 py-4 border-b border-white/5",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("h3",{className:"text-base font-semibold text-gray-100",children:[M.length," requirement",M.length===1?"":"s"," found"]}),e.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"Pick what to generate from. The grounding column says whether exploration has reached that part of the app — it does not block anything, it tells you how much of the result will be guesswork."})]}),e.jsx("button",{onClick:()=>{tt([]),Re(new Set),Je({})},className:"text-sm text-gray-400 hover:text-gray-200 transition-colors shrink-0",children:"Back to sources"})]}),e.jsxs("div",{className:"flex",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-3 px-5 py-2.5 border-b border-white/5 bg-surface-2/40",children:[e.jsx("input",{type:"checkbox",checked:r,onChange:()=>Re(r?new Set:new Set(M.map(c=>c.id))),className:"rounded border-white/20 bg-surface-2 text-brand-500 focus:ring-brand-500 focus:ring-offset-0"}),e.jsxs("span",{className:"text-xs text-gray-400 flex-1",children:[xe.size," of ",M.length," selected"]}),e.jsx("span",{className:"text-xs text-gray-500 uppercase tracking-wider w-40 shrink-0",children:"Grounding"})]}),e.jsx("div",{className:"max-h-[420px] overflow-y-auto",children:M.map(c=>{const a=Ct[c.id],x=xe.has(c.id);return e.jsxs("div",{className:`flex items-start gap-3 px-5 py-3 border-b border-white/5 transition-colors ${x?"bg-brand-500/10":""}`,children:[e.jsx("input",{type:"checkbox",checked:x,onChange:()=>u(c.id),className:"mt-1 rounded border-white/20 bg-surface-2 text-brand-500 focus:ring-brand-500 focus:ring-offset-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:`text-sm ${x?"text-gray-100":"text-gray-400"}`,children:[e.jsx("span",{className:"font-mono text-xs text-gray-500 mr-2",children:c.id}),c.title]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 mt-1",children:[e.jsx("span",{className:"text-[11px] text-gray-500",children:c.category}),e.jsx("span",{className:"text-[11px] text-gray-600",children:"·"}),e.jsx("span",{className:"text-[11px] text-gray-500",children:c.priority}),c.sourceTitle&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-[11px] text-gray-600",children:"·"}),e.jsx("span",{className:"text-[11px] text-gray-500 truncate max-w-[180px]",children:c.sourceTitle})]})]}),(a==null?void 0:a.priorDrift)&&e.jsxs("p",{className:"text-[11px] text-rose-300 mt-1.5 leading-relaxed",children:["Disagreed before — ",a.priorDrift.testCaseId," recorded that the app ",a.priorDrift.appDoes]})]}),e.jsx("div",{className:"w-40 shrink-0 pt-0.5",children:Qs&&!a?e.jsx("span",{className:"text-xs text-gray-600",children:"checking…"}):((a==null?void 0:a.pagesMatched)??0)>0?e.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full bg-emerald-500/20 text-emerald-300 cursor-help",title:a.pages.map(m=>`${m.template} (${m.citation})`).join(`
|