@testver/testver 1.3.1 → 1.4.0
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/bin/testver.js +8 -1
- package/dist/index.js +1414 -793
- package/dist/py-agent/__pycache__/testver_appium.cpython-313.pyc +0 -0
- package/package.json +7 -6
- package/src/ui/static/assets/AIPanel-D09Ni3a4.js +32 -0
- package/src/ui/static/assets/AIRecordPanel-DZtUZnRe.js +40 -0
- package/src/ui/static/assets/AIStreamUI-BsxKziYG.js +9 -0
- package/src/ui/static/assets/AITestGenPage-Cg21-P1W.js +5 -0
- package/src/ui/static/assets/APITestingPage-Cdc8EZz2.js +19 -0
- package/src/ui/static/assets/AboutPage-yJLCr2_q.js +1 -0
- package/src/ui/static/assets/AdvancedPage-DB-6sJ6s.js +3 -0
- package/src/ui/static/assets/AnalyticsPage-gTPFsiLZ.js +1 -0
- package/src/ui/static/assets/AuditLogPage-DE45E_PV.js +1 -0
- package/src/ui/static/assets/ChangesSummary-C-7oi_sx.js +2 -0
- package/src/ui/static/assets/CodeMapPage-DgU6ZYBO.js +3 -0
- package/src/ui/static/assets/ConfirmDialog-DNU3qoAP.js +1 -0
- package/src/ui/static/assets/CoveragePage-BpTjgcdV.js +2 -0
- package/src/ui/static/assets/CronBuilder-DsnX-vRr.js +1 -0
- package/src/ui/static/assets/Dashboard-DRWbVyTb.js +1 -0
- package/src/ui/static/assets/DefectsPage-BtMNbq6Z.js +72 -0
- package/src/ui/static/assets/DiffViewer-DPglzjPH.js +2 -0
- package/src/ui/static/assets/EmptyState-BH_aDO0P.js +1 -0
- package/src/ui/static/assets/ExportButton-Ce_MxnM1.js +1 -0
- package/src/ui/static/assets/FileViewer-iYL0lxyY.js +18 -0
- package/src/ui/static/assets/GitPage-CQqV8JBC.js +12 -0
- package/src/ui/static/assets/ImportExportPage-DXk7Koaq.js +36 -0
- package/src/ui/static/assets/JiraPushDialog-CqftoLh8.js +1 -0
- package/src/ui/static/assets/LiveExecutionView-BD0wE8sz.js +1 -0
- package/src/ui/static/assets/ManagePage-B8iG6Q0B.js +1 -0
- package/src/ui/static/assets/MediaModal-DiSINwmh.js +1 -0
- package/src/ui/static/assets/MobileRunPicker-BNs2lZFf.js +1 -0
- package/src/ui/static/assets/MobileRunTarget-D2Nqcj10.js +6 -0
- package/src/ui/static/assets/ModuleExplorer-BmkoQrHb.js +1 -0
- package/src/ui/static/assets/OutputPage-Dcsr7cmr.js +1 -0
- package/src/ui/static/assets/PipelinesPanel-CMMXCSda.js +1 -0
- package/src/ui/static/assets/ProfilePage-ByshrcwC.js +1 -0
- package/src/ui/static/assets/ProjectExplorer-B9B___ij.js +1 -0
- package/src/ui/static/assets/RemoteFileStrip-DbPnaZ-v.js +1 -0
- package/src/ui/static/assets/ReportCard-BbNfk85h.js +2 -0
- package/src/ui/static/assets/ReportFullView-Cg1rggho.js +1 -0
- package/src/ui/static/assets/ReportsPage-CFv3OAhe.js +48 -0
- package/src/ui/static/assets/ResultsPage-B4LwZH-R.js +115 -0
- package/src/ui/static/assets/RunTargets-C7Vqd4TU.js +1 -0
- package/src/ui/static/assets/ScriptMappingPage-BrANeHv0.js +1 -0
- package/src/ui/static/assets/SearchableDevicePicker-CFJ_DUAA.js +1 -0
- package/src/ui/static/assets/SettingsPage-BwOiebKG.js +83 -0
- package/src/ui/static/assets/SharedReportView-BAbW1WOs.js +1 -0
- package/src/ui/static/assets/SourcesPage-C_QVQwiA.js +14 -0
- package/src/ui/static/assets/TestExplorerPage-BRRWtwde.js +7 -0
- package/src/ui/static/assets/TestManagementPage-Ch4PthuU.js +10 -0
- package/src/ui/static/assets/TestPlansPage-Bno2vpGd.js +5 -0
- package/src/ui/static/assets/TestverCreditsDetail-cSW0SpNx.js +1 -0
- package/src/ui/static/assets/TestverCreditsRing-CUsMGEe3.js +1 -0
- package/src/ui/static/assets/UncommittedDiffViewer-B5HSURk8.js +2 -0
- package/src/ui/static/assets/UserManagementPage-BjY3ftxf.js +10 -0
- package/src/ui/static/assets/WorkflowsPage-BUu-LjZ8.js +83 -0
- package/src/ui/static/assets/aiHandoff-vhtR29Fh.js +1 -0
- package/src/ui/static/assets/ansiToHtml-DYRzYQV1.js +1 -0
- package/src/ui/static/assets/dark-logo-DCPcGDyT.svg +1 -0
- package/src/ui/static/assets/excel-BrxuVus5.js +1 -0
- package/src/ui/static/assets/formatDate-T65-Y6Mi.js +1 -0
- package/src/ui/static/assets/formatTestName-BKd2Uqhs.js +1 -0
- package/src/ui/static/assets/hiddenLlmProviders-setxgY_B.js +1 -0
- package/src/ui/static/assets/index-B0klHYbO.css +1 -0
- package/src/ui/static/assets/index-DpQhqcHv.js +11 -0
- package/src/ui/static/assets/index-DtBWNlVD.js +47 -0
- package/src/ui/static/assets/logo-C7ltqfpq.svg +1 -0
- package/src/ui/static/assets/runSelected-WlgnZcSF.js +1 -0
- package/src/ui/static/assets/sandboxStorage-BrzaG3ny.js +1 -0
- package/src/ui/static/assets/simpleMarkdown-kWs-10D8.js +5 -0
- package/src/ui/static/assets/useChartTheme-BFz2QcND.js +1 -0
- package/src/ui/static/assets/useDebouncedValue-BsHptIvX.js +1 -0
- package/src/ui/static/assets/useFeatureFlags-DqhngqgG.js +1 -0
- package/src/ui/static/assets/useJiraConnector-TM1Rfj1s.js +1 -0
- package/src/ui/static/assets/useOwnership-eW6Egd7X.js +1 -0
- package/src/ui/static/assets/useSuites-CvtMGakZ.js +1 -0
- package/src/ui/static/assets/useTabParam-ChbOedP1.js +1 -0
- package/src/ui/static/assets/useTestExplorer-HqvURJAc.js +1 -0
- package/src/ui/static/assets/useTestLifecycle-CL7-zz0Q.js +1 -0
- package/src/ui/static/assets/useTestManagement-ZTA1_VUm.js +2 -0
- package/src/ui/static/assets/useTestResults-Bm-JyMhB.js +1 -0
- package/src/ui/static/assets/vendor-charts-DWFQlmCz.js +73 -0
- package/src/ui/static/assets/vendor-excel-BFHGVHVC.js +24 -0
- package/src/ui/static/assets/vendor-flow-BnuhLJ6X.css +1 -0
- package/src/ui/static/assets/vendor-flow-YGpC9U9I.js +23 -0
- package/src/ui/static/assets/vendor-icons-B0wLOBoh.js +1421 -0
- package/src/ui/static/assets/vendor-query-BrzmPFT3.js +1 -0
- package/src/ui/static/assets/vendor-quill-CTpA5PSA.css +7 -0
- package/src/ui/static/assets/{index-xlbWNOlh.js → vendor-quill-W-RoQfb6.js} +1 -1
- package/src/ui/static/assets/vendor-react-CTbHBddL.js +61 -0
- package/src/ui/static/assets/visibleInterval-BKsLfJZ3.js +1 -0
- package/src/ui/static/dark-logo.svg +1 -1
- package/src/ui/static/index.html +5 -2
- package/src/ui/static/logo.svg +1 -1
- package/src/ui/static/assets/dark-logo-BddlJH8z.svg +0 -1
- package/src/ui/static/assets/index-8gWK1fNb.js +0 -2250
- package/src/ui/static/assets/index-DMd4ynKJ.css +0 -7
- package/src/ui/static/assets/logo-DwQCjTm_.svg +0 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-DtBWNlVD.js","assets/vendor-react-CTbHBddL.js","assets/vendor-query-BrzmPFT3.js","assets/vendor-icons-B0wLOBoh.js","assets/index-B0klHYbO.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as s,j as e,n as yt,b as wt,u as Lt}from"./vendor-react-CTbHBddL.js";import{bv as Ft,aA as vt,b6 as ct,bw as Wt,bx as Ot,aN as Bt,a$ as Ut,aB as Ht,by as Xt,bz as Vt,bA as Yt,aV as Gt,aT as Kt,b4 as dt,bB as qt,bC as Jt,V as Qt,T as Zt,bD as es,a4 as ts}from"./index-DtBWNlVD.js";import{u as ss}from"./useTabParam-ChbOedP1.js";import{N as ut,a as st,A as rs,b9 as ns,bP as as,X as je,e as is,I as os,o as ls,a2 as jt,K as kt,a7 as rt,bb as Fe,ae as ot,bQ as cs,q as ds,bR as us,bS as xs,an as hs,ap as fs,bT as ps,ba as We,y as Be,J as lt,bU as ms,bV as gs,bW as bs,bX as ys,W as ws,w as vs,bY as js,bZ as ks,aV as Ns,aW as Cs,a3 as ve,a5 as Ss,aa as Nt,l as Rs,r as nt,aK as xt,b_ as Es,ag as Ts,ak as Ct,t as Ue,ad as Ms,bu as $s,aL as Ps,bx as As,S as zs,c as _s,f as Ds,_ as Is,aE as St,by as Ls,Q as Fs,C as Ws,bz as Os,b$ as Bs,c0 as Rt,af as Et,c1 as Tt,v as Us,F as Hs,g as Xs,c2 as Vs,c3 as Mt,G as $t}from"./vendor-icons-B0wLOBoh.js";import{f as Ys}from"./formatDate-T65-Y6Mi.js";import{C as Gs}from"./ConfirmDialog-DNU3qoAP.js";import{a as Pt}from"./DiffViewer-DPglzjPH.js";import{M as Ks}from"./MediaModal-DiSINwmh.js";function qs({subscribe:t,send:i,isStreaming:a}){const[r,x]=ss("nctab",["network","console"],"console"),[n,f]=s.useState([]),[c,l]=s.useState([]),[d,p]=s.useState(!1),[E,m]=s.useState(!1),[v,T]=s.useState(""),[R,_]=s.useState("all"),[h,w]=s.useState(!0),u=s.useRef(null),b=s.useRef(null),y=s.useCallback(k=>{if(k.type==="screencast-network-request"){const L=k.entry;f(M=>{const C=M.findIndex(W=>W.id===L.id);if(C>=0){const W=[...M];return W[C]={...W[C],...L},W}const H=[...M,L];return H.length>500?H.slice(-500):H});return}if(k.type==="screencast-network-response"){const L=k.entry;f(M=>{const C=M.findIndex(W=>W.id===L.id);if(C>=0){const W=[...M];return W[C]={...W[C],...L},W}const H=[...M,L];return H.length>500?H.slice(-500):H});return}if(k.type==="screencast-console-message"){const L=k.entry;l(M=>{const C=[...M,L];return C.length>500?C.slice(-500):C});return}},[]);s.useEffect(()=>t(y),[t,y]),s.useEffect(()=>{if(!h)return;const k=r==="network"?u:b;k.current&&(k.current.scrollTop=k.current.scrollHeight)},[n,c,r,h]);const A=()=>{d?(i({type:"screencast-network-disable"}),p(!1)):(i({type:"screencast-network-enable"}),p(!0))},z=()=>{E?(i({type:"screencast-console-disable"}),m(!1)):(i({type:"screencast-console-enable"}),m(!0))};s.useEffect(()=>{a&&!d&&(i({type:"screencast-network-enable"}),p(!0)),a&&!E&&(i({type:"screencast-console-enable"}),m(!0))},[a]);const X=v?n.filter(k=>k.url.toLowerCase().includes(v.toLowerCase())||k.method.toLowerCase().includes(v.toLowerCase())):n,F=R==="all"?c:c.filter(k=>k.level===R);return e.jsxs("div",{className:"flex flex-col h-full bg-surface-0 border-t border-white/5",children:[e.jsxs("div",{className:"flex items-center gap-0.5 px-2 py-1 border-b border-white/5 bg-surface-1 flex-shrink-0",children:[e.jsxs("button",{onClick:()=>x("network"),className:`flex items-center gap-1.5 px-2.5 py-1 rounded-lg text-[11px] font-medium transition-colors ${r==="network"?"bg-blue-500/15 text-blue-300":"text-gray-500 hover:text-gray-400"}`,children:[e.jsx(ut,{size:11}),"Network",n.length>0&&e.jsx("span",{className:"text-[9px] px-1 rounded-full bg-blue-500/20 text-blue-400",children:n.length})]}),e.jsxs("button",{onClick:()=>x("console"),className:`flex items-center gap-1.5 px-2.5 py-1 rounded-lg text-[11px] font-medium transition-colors ${r==="console"?"bg-purple-500/15 text-purple-300":"text-gray-500 hover:text-gray-400"}`,children:[e.jsx(st,{size:11}),"Console",c.filter(k=>k.level==="error").length>0&&e.jsx("span",{className:"text-[9px] px-1 rounded-full bg-red-500/20 text-red-400",children:c.filter(k=>k.level==="error").length})]}),e.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[r==="network"&&e.jsx("button",{onClick:A,className:`text-[10px] px-1.5 py-0.5 rounded transition-colors ${d?"text-emerald-400 bg-emerald-500/10":"text-gray-500 hover:text-gray-400"}`,children:d?"ON":"OFF"}),r==="console"&&e.jsx("button",{onClick:z,className:`text-[10px] px-1.5 py-0.5 rounded transition-colors ${E?"text-emerald-400 bg-emerald-500/10":"text-gray-500 hover:text-gray-400"}`,children:E?"ON":"OFF"}),e.jsx("button",{onClick:()=>w(!h),className:`p-1 rounded transition-colors ${h?"text-brand-400":"text-gray-600"}`,title:h?"Auto-scroll ON":"Auto-scroll OFF",children:e.jsx(rs,{size:10})}),e.jsx("button",{onClick:()=>{r==="network"?f([]):l([])},className:"p-1 rounded text-gray-600 hover:text-gray-400 transition-colors",title:"Clear",children:e.jsx(ns,{size:10})})]})]}),r==="network"&&e.jsxs("div",{className:"flex items-center gap-2 px-2 py-1 border-b border-white/5 bg-surface-1/50",children:[e.jsx(as,{size:10,className:"text-gray-600"}),e.jsx("input",{type:"text",value:v,onChange:k=>T(k.target.value),placeholder:"Filter by URL or method...",className:"flex-1 bg-transparent text-[11px] text-gray-300 placeholder-gray-600 outline-none"}),v&&e.jsx("button",{onClick:()=>T(""),className:"text-gray-500 hover:text-gray-400",children:e.jsx(je,{size:10})})]}),r==="console"&&e.jsxs("div",{className:"flex items-center gap-1 px-2 py-1 border-b border-white/5 bg-surface-1/50",children:[e.jsx(Ee,{label:"All",active:R==="all",onClick:()=>_("all")}),e.jsx(Ee,{label:"Errors",active:R==="error",onClick:()=>_("error"),color:"red"}),e.jsx(Ee,{label:"Warnings",active:R==="warn",onClick:()=>_("warn"),color:"amber"}),e.jsx(Ee,{label:"Info",active:R==="info",onClick:()=>_("info"),color:"blue"}),e.jsx(Ee,{label:"Log",active:R==="log",onClick:()=>_("log")})]}),e.jsx("div",{className:"flex-1 overflow-hidden",children:r==="network"?e.jsx("div",{ref:u,className:"h-full overflow-y-auto",children:X.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-gray-600 gap-2",children:[e.jsx(ut,{size:20}),e.jsx("span",{className:"text-[11px]",children:d?"Waiting for requests...":"Enable network monitoring to capture requests"})]}):e.jsxs("table",{className:"w-full text-[11px]",children:[e.jsx("thead",{className:"sticky top-0 bg-surface-1 z-10",children:e.jsxs("tr",{className:"text-gray-500 text-left",children:[e.jsx("th",{className:"px-2 py-1 font-medium w-14",children:"Method"}),e.jsx("th",{className:"px-2 py-1 font-medium w-14",children:"Status"}),e.jsx("th",{className:"px-2 py-1 font-medium",children:"URL"}),e.jsx("th",{className:"px-2 py-1 font-medium w-16",children:"Type"}),e.jsx("th",{className:"px-2 py-1 font-medium w-16 text-right",children:"Time"})]})}),e.jsx("tbody",{children:X.map(k=>e.jsx(Js,{entry:k},k.id+(k.status||"")))})]})}):e.jsx("div",{ref:b,className:"h-full overflow-y-auto font-mono",children:F.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-gray-600 gap-2",children:[e.jsx(st,{size:20}),e.jsx("span",{className:"text-[11px] font-sans",children:E?"Waiting for console output...":"Enable console monitoring to capture logs"})]}):F.map((k,L)=>e.jsx(Qs,{entry:k},`${k.timestamp}-${L}`))})})]})}function Js({entry:t}){const i=t.failed||t.status&&t.status>=400?"text-red-400":t.status&&t.status>=300?"text-amber-400":t.status?"text-emerald-400":"text-gray-500",a=t.method==="POST"?"text-amber-400":t.method==="PUT"?"text-blue-400":t.method==="DELETE"?"text-red-400":t.method==="PATCH"?"text-purple-400":"text-gray-400";let r=t.url;try{const n=new URL(t.url);r=n.pathname+n.search}catch{}const x=t.mimeType?t.mimeType.replace("application/","").replace("text/","").split(";")[0]:"";return e.jsxs("tr",{className:"border-b border-white/[0.02] hover:bg-white/[0.02] transition-colors",children:[e.jsx("td",{className:`px-2 py-0.5 font-medium ${a}`,children:t.method}),e.jsx("td",{className:`px-2 py-0.5 ${i}`,children:t.failed?"ERR":t.status||"..."}),e.jsx("td",{className:"px-2 py-0.5 text-gray-300 truncate max-w-0",title:t.url,children:r}),e.jsx("td",{className:"px-2 py-0.5 text-gray-600 truncate",children:x}),e.jsx("td",{className:"px-2 py-0.5 text-gray-500 text-right",children:t.duration!=null?`${t.duration}ms`:"..."})]})}function Qs({entry:t}){const i={error:{bg:"bg-red-500/5",border:"border-red-500/20",text:"text-red-300",icon:e.jsx(jt,{size:10})},warn:{bg:"bg-amber-500/5",border:"border-amber-500/20",text:"text-amber-300",icon:e.jsx(ls,{size:10})},info:{bg:"bg-blue-500/5",border:"border-blue-500/10",text:"text-blue-300",icon:e.jsx(os,{size:10})},debug:{bg:"bg-gray-500/5",border:"border-white/5",text:"text-gray-400",icon:e.jsx(is,{size:10})},log:{bg:"",border:"border-white/[0.02]",text:"text-gray-300",icon:null}},a=i[t.level]||i.log,r=new Date(t.timestamp).toLocaleTimeString("en-US",{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"});return e.jsxs("div",{className:`flex items-start gap-2 px-2 py-0.5 border-b ${a.border} ${a.bg} text-[11px]`,children:[e.jsx("span",{className:"text-gray-600 flex-shrink-0 tabular-nums",children:r}),a.icon&&e.jsx("span",{className:a.text+" flex-shrink-0 mt-0.5",children:a.icon}),e.jsx("span",{className:`${a.text} break-all flex-1 whitespace-pre-wrap`,children:t.text}),t.source&&e.jsxs("span",{className:"text-gray-700 flex-shrink-0 truncate max-w-[120px]",title:t.source,children:[t.source.split("/").pop(),t.lineNumber!=null?`:${t.lineNumber}`:""]})]})}function Ee({label:t,active:i,onClick:a,color:r}){const n=r?{red:i?"bg-red-500/20 text-red-300":"text-gray-500",amber:i?"bg-amber-500/20 text-amber-300":"text-gray-500",blue:i?"bg-blue-500/20 text-blue-300":"text-gray-500"}[r]||"":i?"bg-white/10 text-gray-300":"text-gray-500";return e.jsx("button",{onClick:a,className:`px-1.5 py-0.5 rounded text-[10px] font-medium transition-colors hover:text-gray-300 ${n}`,children:t})}const Zs=800,er=2e3,ht=3e3;function tr({subscribe:t,canvasWidth:i,canvasHeight:a,viewportWidth:r,viewportHeight:x,enabled:n}){const f=s.useRef(null),c=s.useRef([]),[l,d]=s.useState(null),[p,E]=s.useState(null),m=s.useRef(0),v=s.useRef(0),T=s.useCallback((h,w)=>{const u=i/r,b=a/x;return{x:h*u,y:w*b}},[i,a,r,x]),R=s.useCallback(h=>{if(n&&h.type==="ai-cursor-action"){const w={id:`action-${Date.now()}-${Math.random()}`,type:h.action||"action",toolName:h.toolName,selector:h.selector,text:h.text,url:h.url,x:h.x,y:h.y,timestamp:Date.now()};if(d(w),setTimeout(()=>{d(u=>(u==null?void 0:u.id)===w.id?null:u)},er),w.type==="click"&&w.x!==void 0&&w.y!==void 0){const u=T(w.x,w.y);c.current.push({id:w.id,x:u.x,y:u.y,startTime:Date.now(),duration:Zs}),E({x:w.x,y:w.y}),m.current=Date.now()}["hover","type","select"].includes(w.type)&&w.x!==void 0&&w.y!==void 0&&(E({x:w.x,y:w.y}),m.current=Date.now())}},[n,T]);if(s.useEffect(()=>t(R),[t,R]),s.useEffect(()=>{if(!n)return;const h=()=>{const w=f.current;if(!w){v.current=requestAnimationFrame(h);return}(w.width!==i||w.height!==a)&&(w.width=i,w.height=a);const u=w.getContext("2d");if(!u){v.current=requestAnimationFrame(h);return}u.clearRect(0,0,w.width,w.height);const b=Date.now();c.current=c.current.filter(y=>b-y.startTime<y.duration);for(const y of c.current){const z=(b-y.startTime)/y.duration,F=30*z,k=1-z;u.beginPath(),u.arc(y.x,y.y,F,0,Math.PI*2),u.strokeStyle=`rgba(168, 85, 247, ${k*.8})`,u.lineWidth=2.5,u.stroke(),u.beginPath(),u.arc(y.x,y.y,F*.4,0,Math.PI*2),u.fillStyle=`rgba(168, 85, 247, ${k*.3})`,u.fill(),z<.3&&(u.beginPath(),u.arc(y.x,y.y,3,0,Math.PI*2),u.fillStyle=`rgba(168, 85, 247, ${(1-z/.3)*.9})`,u.fill())}if(p){const y=b-m.current;if(y<ht){const A=Math.max(0,1-y/ht),z=T(p.x,p.y),X=12;u.strokeStyle=`rgba(168, 85, 247, ${A*.9})`,u.lineWidth=1.5,u.beginPath(),u.moveTo(z.x-X,z.y),u.lineTo(z.x+X,z.y),u.stroke(),u.beginPath(),u.moveTo(z.x,z.y-X),u.lineTo(z.x,z.y+X),u.stroke();const F=b%1e3/1e3,k=6+Math.sin(F*Math.PI*2)*2;u.beginPath(),u.arc(z.x,z.y,k,0,Math.PI*2),u.strokeStyle=`rgba(168, 85, 247, ${A*.5})`,u.lineWidth=1,u.stroke()}}v.current=requestAnimationFrame(h)};return v.current=requestAnimationFrame(h),()=>{v.current&&cancelAnimationFrame(v.current)}},[n,i,a,p,T]),!n)return null;const _=h=>{switch(h.type){case"click":return`Click ${h.selector||""}`.trim();case"type":return`Type "${(h.text||"").slice(0,30)}${(h.text||"").length>30?"...":""}"`;case"hover":return`Hover ${h.selector||""}`.trim();case"navigate":return`Navigate → ${(h.url||"").slice(0,40)}`;case"select":return`Select ${h.selector||""}`.trim();case"key":return`Press ${h.text||"key"}`;case"screenshot":return"Taking screenshot";case"scroll":return"Scrolling";case"wait":return`Waiting for ${h.selector||"element"}`;case"launch":return"Launching browser";case"close":return"Closing browser";default:return h.toolName}};return e.jsxs(e.Fragment,{children:[e.jsx("canvas",{ref:f,className:"absolute inset-0 pointer-events-none z-10",style:{width:"100%",height:"100%"}}),l&&e.jsx("div",{className:"absolute top-2 left-1/2 -translate-x-1/2 z-20 pointer-events-none animate-in fade-in slide-in-from-top-1 duration-200",children:e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 rounded-full bg-gray-900/95 border border-purple-400/40 shadow-lg shadow-black/40 backdrop-blur-md",children:[e.jsx(sr,{type:l.type}),e.jsx("span",{className:"text-[11px] font-semibold text-white whitespace-nowrap max-w-[280px] truncate drop-shadow-sm",children:_(l)})]})})]})}function sr({type:t}){const a="text-purple-300";switch(t){case"click":return e.jsxs("svg",{width:12,height:12,viewBox:"0 0 16 16",className:a,fill:"currentColor",children:[e.jsx("circle",{cx:"8",cy:"8",r:"3"}),e.jsx("circle",{cx:"8",cy:"8",r:"7",fill:"none",stroke:"currentColor",strokeWidth:"1.5"})]});case"type":return e.jsxs("svg",{width:12,height:12,viewBox:"0 0 16 16",className:a,fill:"currentColor",children:[e.jsx("rect",{x:"2",y:"4",width:"12",height:"8",rx:"1",fill:"none",stroke:"currentColor",strokeWidth:"1.5"}),e.jsx("line",{x1:"5",y1:"7",x2:"11",y2:"7",stroke:"currentColor",strokeWidth:"1"}),e.jsx("line",{x1:"5",y1:"9",x2:"9",y2:"9",stroke:"currentColor",strokeWidth:"1"})]});case"navigate":return e.jsx("svg",{width:12,height:12,viewBox:"0 0 16 16",className:a,fill:"currentColor",children:e.jsx("path",{d:"M3 8h10M10 5l3 3-3 3",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})});case"hover":return e.jsx("svg",{width:12,height:12,viewBox:"0 0 16 16",className:a,fill:"currentColor",children:e.jsx("path",{d:"M4 2l8 6-4 1-2 4z",fill:"none",stroke:"currentColor",strokeWidth:"1.5"})});default:return e.jsx("svg",{width:12,height:12,viewBox:"0 0 16 16",className:a,fill:"currentColor",children:e.jsx("circle",{cx:"8",cy:"8",r:"2"})})}}const rr=[{label:"Mobile",icon:lt,width:375,height:812},{label:"Tablet",icon:ms,width:768,height:1024},{label:"Desktop",icon:We,width:1280,height:720},{label:"Full HD",icon:We,width:1920,height:1080}],at="testver-live-view-focus";function Fr(){window.dispatchEvent(new Event(at))}function At({browserStatus:t,sessionEpoch:i=0,subscribe:a,send:r,isPiP:x,onTogglePiP:n,onCloseBrowser:f,userControlOnly:c=!1}){var B,K;const[l,d]=s.useState(!1),[p,E]=s.useState(!1),[m,v]=s.useState({width:1280,height:720}),[T,R]=s.useState(""),[_,h]=s.useState(""),[w,u]=s.useState(0),[b,y]=s.useState(c?"user":"ai"),A=s.useRef(b);A.current=b;const[z,X]=s.useState(!1),[F,k]=s.useState(null),[L,M]=s.useState("default"),[C,H]=s.useState(!1),[W,Q]=s.useState(!1),[O,ke]=s.useState(200),[U,He]=s.useState(!c),[Y,Ne]=s.useState(!1),[J,Ce]=s.useState(!1),G=s.useRef(null),ce=s.useRef(null),Z=s.useRef(null),he=s.useRef(null),ee=s.useRef(0),pe=s.useRef(null),de=s.useRef(null);s.useEffect(()=>{const o=()=>{var $;A.current==="user"&&(($=de.current)==null||$.focus({preventScroll:!0}))};return window.addEventListener(at,o),()=>window.removeEventListener(at,o)},[]);const ne=s.useRef(0);s.useEffect(()=>{he.current||(he.current=new Image)},[]),s.useEffect(()=>(pe.current=setInterval(()=>{u(ee.current),ee.current=0},1e3),()=>{pe.current&&clearInterval(pe.current)}),[]);const Se=s.useRef(0),me=s.useRef(i),Me=s.useRef(t.active);Me.current=t.active;const $e=s.useRef(l);$e.current=l;const Pe=s.useCallback(()=>{var S,I;Se.current++;const o=G.current;o&&((S=o.getContext("2d"))==null||S.clearRect(0,0,o.width,o.height));const $=ce.current;$&&((I=$.getContext("2d"))==null||I.clearRect(0,0,$.width,$.height)),k(null)},[]);s.useEffect(()=>{const o=i!==me.current;me.current=i,t.active?o?(Pe(),fe()):!l&&!p&&fe():l&&(ae(),Pe())},[t.active,i]);const fe=s.useCallback(async()=>{E(!0);try{const o=await Ft();v({width:o.width,height:o.height}),r({type:"screencast-start",options:{quality:50}}),d(!0)}catch{r({type:"screencast-start",options:{quality:50}}),d(!0)}E(!1)},[r]),ae=s.useCallback(()=>{r({type:"screencast-stop"}),d(!1),u(0)},[r]),se=s.useRef(null),Ae=s.useCallback(()=>{se.current&&clearTimeout(se.current),se.current=setTimeout(()=>{se.current=null,Me.current&&!$e.current&&fe()},600)},[fe]);s.useEffect(()=>()=>{se.current&&clearTimeout(se.current)},[]);const ze=s.useCallback(o=>{if(o.type==="screencast-frame"){const $=o.data,S=o.metadata;S&&v(V=>V.width!==S.width||V.height!==S.height?{width:S.width,height:S.height}:V);const I=he.current;if(!I)return;const re=Se.current;I.onload=()=>{var oe;if(re!==Se.current)return;const V=G.current;V&&((V.width!==((S==null?void 0:S.width)||m.width)||V.height!==((S==null?void 0:S.height)||m.height))&&(V.width=(S==null?void 0:S.width)||m.width,V.height=(S==null?void 0:S.height)||m.height),Z.current||(Z.current=V.getContext("2d")),(oe=Z.current)==null||oe.drawImage(I,0,0,V.width,V.height),ee.current++)},I.src=`data:image/jpeg;base64,${$}`;return}if(o.type==="screencast-viewport"){v({width:o.width,height:o.height});return}if(o.type==="screencast-stopped"){d(!1),u(0),Ae();return}if(o.type==="screencast-error"){d(!1),E(!1),Ae();return}if(o.type==="screencast-highlight"){k(o.highlight);return}if(o.type==="browser-tab-switched"){o.url&&R(o.url),h("");return}if(o.type==="screencast-url-changed"){o.url&&R(o.url),o.title&&h(o.title);return}if(o.type==="screencast-cursor"){M(o.cursor||"default");return}if(o.type==="ai-orchestrator-paused"){Ne(!0);return}if(o.type==="ai-orchestrator-resumed"){Ne(!1);return}if(o.type==="ai-fix-tool"){Ce(!0);return}if(o.type==="ai-fix-done"||o.type==="ai-fix-error"){Ce(!1),Ne(!1);return}},[m]);s.useEffect(()=>a(ze),[a,ze]),s.useEffect(()=>{t.url&&R(t.url)},[t.url]),s.useEffect(()=>{h("")},[i,t.active]),s.useEffect(()=>{const o=ce.current;if(!o)return;const $=G.current;if(!$)return;(o.width!==$.width||o.height!==$.height)&&(o.width=$.width,o.height=$.height);const S=o.getContext("2d");if(S&&(S.clearRect(0,0,o.width,o.height),F&&z)){const I=F;S.fillStyle="rgba(59, 130, 246, 0.1)",S.fillRect(I.x,I.y,I.width,I.height),S.strokeStyle="rgba(59, 130, 246, 0.7)",S.lineWidth=2,S.setLineDash([]),S.strokeRect(I.x,I.y,I.width,I.height);const re=`${I.tagName}${I.id?"#"+I.id:""}${I.className?"."+I.className.split(" ")[0]:""}`;S.font="11px monospace";const V=S.measureText(re).width,oe=I.x,be=I.y>18?I.y-4:I.y+I.height+14;S.fillStyle="rgba(30, 41, 59, 0.9)",S.fillRect(oe,be-12,V+8,16),S.fillStyle="#93c5fd",S.fillText(re,oe+4,be)}},[F,z]);const q=s.useCallback((o,$)=>{const S=G.current;if(!S)return{x:0,y:0};const I=S.getBoundingClientRect(),re=o-I.left,V=$-I.top,oe=m.width/I.width,be=m.height/I.height;return{x:Math.round(re*oe),y:Math.round(V*be)}},[m]),te=o=>{let $=0;return o.altKey&&($|=1),o.ctrlKey&&($|=2),o.metaKey&&($|=4),o.shiftKey&&($|=8),$},Re=o=>o.button===2?"right":o.button===1?"middle":"left",Xe=s.useCallback(o=>{var I;if(b!=="user")return;o.preventDefault(),(I=de.current)==null||I.focus();const{x:$,y:S}=q(o.clientX,o.clientY);r({type:"screencast-mouse",mouseType:"mousePressed",x:$,y:S,button:Re(o),clickCount:o.detail||1,modifiers:te(o)})},[b,q,r]),Ve=s.useCallback(o=>{if(b!=="user")return;o.preventDefault();const{x:$,y:S}=q(o.clientX,o.clientY);r({type:"screencast-mouse",mouseType:"mouseReleased",x:$,y:S,button:Re(o),clickCount:o.detail||1,modifiers:te(o)})},[b,q,r]),Ye=s.useCallback(o=>{if(b!=="user")return;const $=Date.now();if($-ne.current<50)return;ne.current=$;const{x:S,y:I}=q(o.clientX,o.clientY);z&&r({type:"screencast-hover",x:S,y:I}),r({type:"screencast-mouse",mouseType:"mouseMoved",x:S,y:I,button:"none",modifiers:te(o)})},[b,q,r,z]),ie=s.useCallback(()=>{z&&k(null)},[z]),ge=s.useCallback(o=>{o.preventDefault()},[]),Ge=s.useCallback(o=>{if(b!=="user")return;o.preventDefault();const{x:$,y:S}=q(o.clientX,o.clientY);r({type:"screencast-mouse",mouseType:"mousePressed",x:$,y:S,button:"left",clickCount:2,modifiers:te(o)}),r({type:"screencast-mouse",mouseType:"mouseReleased",x:$,y:S,button:"left",clickCount:2,modifiers:te(o)})},[b,q,r]),Ke=s.useCallback(o=>{b==="user"&&o.target.tagName!=="INPUT"&&(o.preventDefault(),r({type:"screencast-key",keyType:"keyDown",key:o.key,code:o.code,text:o.key.length===1?o.key:void 0,modifiers:te(o)}))},[b,r]),qe=s.useCallback(o=>{b==="user"&&o.target.tagName!=="INPUT"&&(o.preventDefault(),r({type:"screencast-key",keyType:"keyUp",key:o.key,code:o.code,modifiers:te(o)}))},[b,r]),Je=s.useCallback(o=>{if(b!=="user")return;o.preventDefault();const{x:$,y:S}=q(o.clientX,o.clientY);r({type:"screencast-scroll",x:$,y:S,deltaX:o.deltaX,deltaY:o.deltaY})},[b,q,r]),_e=o=>{if(o.preventDefault(),!T.trim())return;let $=T.trim();$.match(/^https?:\/\//)||($=`https://${$}`),r({type:"screencast-navigate",url:$})},g=o=>{r({type:"screencast-tab",index:o})},N=(o,$)=>{r({type:"screencast-resize-viewport",width:o,height:$}),H(!1)},j=s.useRef(!1);s.useEffect(()=>{const o=S=>{if(!j.current||!de.current)return;const re=de.current.getBoundingClientRect().bottom-S.clientY;ke(Math.min(400,Math.max(100,re)))},$=()=>{j.current=!1,document.body.style.cursor="",document.body.style.userSelect=""};return window.addEventListener("mousemove",o),window.addEventListener("mouseup",$),()=>{window.removeEventListener("mousemove",o),window.removeEventListener("mouseup",$)}},[]);const P=t.tabs||[],D=m.width/m.height;return e.jsxs("div",{ref:de,className:"flex flex-col h-full bg-surface-0 outline-none",tabIndex:0,onKeyDown:Ke,onKeyUp:qe,children:[e.jsxs("div",{className:"flex items-center gap-0.5 px-2 py-1 border-b border-white/5 bg-surface-1 flex-shrink-0 overflow-x-auto",children:[P.map(o=>e.jsxs("button",{onClick:()=>g(o.index),className:`flex items-center gap-1.5 px-2.5 py-1 rounded-t-lg text-[11px] max-w-[150px] truncate flex-shrink-0 transition-colors ${o.active?"bg-surface-0 text-gray-200 border-t border-x border-white/10":"text-gray-500 hover:text-gray-300 hover:bg-white/5"}`,title:o.url,children:[e.jsx(kt,{size:10,className:"flex-shrink-0"}),e.jsx("span",{className:"truncate",children:o.active&&_||o.title||`Tab ${o.index+1}`})]},o.index)),P.length===0&&e.jsx("span",{className:"text-[11px] text-gray-600 px-2",children:"No tabs"}),e.jsxs("div",{className:"ml-auto flex items-center gap-1 flex-shrink-0",children:[J&&e.jsx("button",{onClick:()=>{r(Y?{type:"screencast-resume"}:{type:"screencast-pause"})},className:`flex items-center gap-1 px-2.5 py-1 rounded-md text-[10px] font-semibold transition-colors ${Y?"bg-emerald-600 text-white border border-emerald-400/50 hover:bg-emerald-500 shadow-sm shadow-emerald-500/20":"bg-orange-600 text-white border border-orange-400/50 hover:bg-orange-500 shadow-sm shadow-orange-500/20"}`,title:Y?"Resume AI execution":"Pause AI execution",children:Y?e.jsxs(e.Fragment,{children:[e.jsx(rt,{size:10})," Resume"]}):e.jsxs(e.Fragment,{children:[e.jsx(Fe,{size:10})," Pause"]})}),!c&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>He(!U),className:`p-1 rounded transition-colors ${U?"text-purple-400 bg-purple-500/15":"text-gray-500 hover:text-gray-400 hover:bg-white/5"}`,title:U?"Disable watch mode overlay":"Enable watch mode overlay",children:e.jsx(ot,{size:11})}),e.jsx("div",{className:"w-px h-3 bg-white/10"}),e.jsxs("button",{onClick:()=>y("ai"),className:`flex items-center gap-1 px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${b==="ai"?"bg-purple-500/20 text-purple-300 border border-purple-500/30":"text-gray-500 hover:text-gray-400"}`,title:"AI is controlling the browser",children:[e.jsx(cs,{size:10})," AI"]}),e.jsxs("button",{onClick:()=>y("user"),className:`flex items-center gap-1 px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${b==="user"?"bg-brand-500/20 text-brand-300 border border-brand-500/30":"text-gray-500 hover:text-gray-400"}`,title:"You are controlling the browser",children:[e.jsx(ds,{size:10})," User"]})]}),n&&e.jsxs("button",{onClick:n,className:`flex items-center gap-1 px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${x?"text-brand-400 bg-brand-500/15":"text-gray-500 hover:text-gray-400"}`,title:x?"Exit Picture-in-Picture":"Picture-in-Picture",children:[e.jsx(us,{size:11})," PiP"]}),f&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-px h-3 bg-white/10"}),e.jsxs("button",{onClick:f,className:"flex items-center gap-1 px-2 py-0.5 rounded text-[10px] font-medium text-red-400/70 hover:text-red-400 hover:bg-red-500/10 transition-colors",title:"Close browser session",children:[e.jsx(xs,{size:10})," Close"]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1 border-b border-white/5 bg-surface-1 flex-shrink-0",children:[e.jsx("button",{onClick:()=>r({type:"screencast-go-back"}),className:"p-1 rounded hover:bg-white/5 text-gray-500 hover:text-gray-400 transition-colors",title:"Go back",children:e.jsx(hs,{size:12})}),e.jsx("button",{onClick:()=>r({type:"screencast-go-forward"}),className:"p-1 rounded hover:bg-white/5 text-gray-500 hover:text-gray-400 transition-colors",title:"Go forward",children:e.jsx(fs,{size:12})}),e.jsx("button",{onClick:()=>r({type:"screencast-navigate",url:t.url||""}),className:"p-1 rounded hover:bg-white/5 text-gray-500 hover:text-gray-400 transition-colors",children:e.jsx(ps,{size:12})}),e.jsx("form",{onSubmit:_e,className:"flex-1",children:e.jsx("input",{type:"text",value:T,onChange:o=>R(o.target.value),placeholder:"Enter URL...",className:"w-full px-2.5 py-1 rounded-lg bg-surface-2 border border-white/5 text-xs text-gray-300 placeholder-gray-600 focus:outline-none focus:border-brand-500/30"})}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:()=>H(!C),className:"flex items-center gap-1 px-1.5 py-1 rounded text-[10px] text-gray-500 hover:text-gray-400 hover:bg-white/5 transition-colors",title:"Viewport presets",children:[e.jsx(We,{size:11}),e.jsx(Be,{size:9})]}),C&&e.jsx("div",{className:"absolute right-0 top-full mt-1 bg-surface-1 border border-white/10 rounded-lg z-50 py-1 w-40",children:rr.map(o=>{const $=o.icon,S=m.width===o.width&&m.height===o.height;return e.jsxs("button",{onClick:()=>N(o.width,o.height),className:`w-full text-left px-3 py-1.5 text-[11px] flex items-center gap-2 transition-colors ${S?"text-brand-300 bg-brand-500/10":"text-gray-300 hover:bg-white/5"}`,children:[e.jsx($,{size:11,className:"flex-shrink-0"}),e.jsx("span",{children:o.label}),e.jsxs("span",{className:"ml-auto text-gray-600 text-[10px]",children:[o.width,"x",o.height]})]},o.label)})})]}),e.jsx("button",{onClick:()=>X(!z),className:`p-1 rounded transition-colors ${z?"text-blue-400 bg-blue-500/15":"text-gray-500 hover:text-gray-400 hover:bg-white/5"}`,title:z?"Disable element highlight":"Enable element highlight",children:e.jsx(gs,{size:12})}),e.jsx("button",{onClick:()=>Q(!W),className:`p-1 rounded transition-colors ${W?"text-purple-400 bg-purple-500/15":"text-gray-500 hover:text-gray-400 hover:bg-white/5"}`,title:W?"Hide DevTools":"Show DevTools",children:W?e.jsx(bs,{size:12}):e.jsx(ys,{size:12})})]}),e.jsx("div",{className:"flex-1 overflow-hidden bg-black/50 flex items-center justify-center relative min-h-0",children:l?e.jsxs("div",{className:"relative max-w-full max-h-full",style:{aspectRatio:`${D}`},children:[e.jsx("canvas",{ref:G,className:"max-w-full max-h-full block",style:{aspectRatio:`${D}`,cursor:b==="user"?L:"not-allowed"},onMouseDown:Xe,onMouseUp:Ve,onMouseMove:Ye,onMouseLeave:ie,onDoubleClick:Ge,onContextMenu:ge,onWheel:Je}),z&&e.jsx("canvas",{ref:ce,className:"absolute inset-0 pointer-events-none max-w-full max-h-full",style:{aspectRatio:`${D}`}}),U&&G.current&&e.jsx(tr,{subscribe:a,canvasWidth:((B=G.current)==null?void 0:B.width)||m.width,canvasHeight:((K=G.current)==null?void 0:K.height)||m.height,viewportWidth:m.width,viewportHeight:m.height,enabled:U}),Y&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center z-30",style:{pointerEvents:"none",background:"rgba(0, 0, 0, 0.15)"},children:e.jsxs("div",{className:"flex items-center gap-4 px-5 py-3 rounded-2xl border",style:{pointerEvents:"auto",background:"rgba(20, 20, 30, 0.7)",borderColor:"rgba(251, 191, 36, 0.5)",boxShadow:"0 4px 20px rgba(0,0,0,0.4)"},children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-orange-500/25 flex items-center justify-center flex-shrink-0",children:e.jsx(Fe,{size:20,className:"text-orange-400"})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-base font-bold text-white",children:"AI Paused"}),e.jsx("div",{className:"text-xs mt-0.5",style:{color:"#ffffff"},children:"Execution paused before next action"})]}),e.jsxs("button",{onClick:()=>r({type:"screencast-resume"}),className:"ml-3 flex items-center gap-1.5 px-4 py-2 rounded-lg bg-emerald-600 text-white text-sm font-semibold hover:bg-emerald-500 transition-colors shadow-md shadow-emerald-500/20",children:[e.jsx(rt,{size:14})," Resume"]})]})})]}):p?e.jsxs("div",{className:"flex flex-col items-center gap-3 text-gray-500",children:[e.jsx("div",{className:"w-8 h-8 border-2 border-brand-500 border-t-transparent rounded-full animate-spin"}),e.jsx("span",{className:"text-xs",children:"Connecting to browser..."})]}):e.jsxs("div",{className:"flex flex-col items-center gap-3 text-gray-600",children:[e.jsx(We,{size:32}),e.jsx("span",{className:"text-xs",children:"No live view available"}),e.jsx("span",{className:"text-[10px] text-gray-700",children:"Launch a browser to see it here"})]})}),W&&l&&e.jsxs(e.Fragment,{children:[e.jsx("div",{onMouseDown:o=>{o.preventDefault(),j.current=!0,document.body.style.cursor="row-resize",document.body.style.userSelect="none"},className:"h-1 flex-shrink-0 cursor-row-resize bg-white/5 hover:bg-brand-500/40 active:bg-brand-500/40 transition-colors"}),e.jsx("div",{className:"flex-shrink-0 overflow-hidden",style:{height:`${O}px`},children:e.jsx(qs,{subscribe:a,send:r,isStreaming:l})})]}),e.jsxs("div",{className:"flex items-center justify-between px-2.5 py-1 border-t border-white/5 bg-surface-1 flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[l?e.jsx(ws,{size:10,className:"text-emerald-400"}):e.jsx(vs,{size:10,className:"text-gray-600"}),e.jsx("span",{className:`text-[10px] ${l?"text-emerald-400":"text-gray-600"}`,children:l?"Live":"Offline"})]}),l&&e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-[10px] text-gray-500",children:[w," fps"]}),e.jsxs("span",{className:"text-[10px] text-gray-600",children:[m.width,"x",m.height]})]}),z&&F&&e.jsxs("span",{className:"text-[10px] text-blue-400 font-mono truncate max-w-[200px]",children:["<",F.tagName,F.id?`#${F.id}`:"",">"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[Y&&e.jsx("span",{className:"text-[10px] text-orange-300 font-semibold animate-pulse",children:"AI Paused"}),J&&!Y&&e.jsx("span",{className:"text-[10px] text-purple-300 font-medium",children:"AI Working"}),b==="user"&&e.jsx("span",{className:"text-[10px] text-brand-400 font-medium",children:"Interactive Mode"}),l&&e.jsx("button",{onClick:ae,className:"text-[10px] text-gray-500 hover:text-gray-400 transition-colors",children:"Disconnect"}),!l&&t.active&&e.jsx("button",{onClick:fe,className:"text-[10px] text-brand-400 hover:text-brand-300 transition-colors",children:"Connect"})]})]})]})}function Wr({children:t,userControlOnly:i=!1}){const{subscribe:a,send:r}=yt(),[x,n]=s.useState({active:!1}),[f,c]=s.useState(50),[l,d]=s.useState(!1),[p,E]=s.useState({w:480,h:360}),[m,v]=s.useState({x:-1,y:-1}),[T,R]=s.useState(!1),[_,h]=s.useState(0),w=s.useRef(!1),u=s.useRef(null),b=s.useRef(null);s.useEffect(()=>{vt().then(()=>ct()).then(L=>{L.active&&n({active:!0,url:L.url||"",title:L.title||"",tabs:L.tabs||[]})}).catch(()=>{})},[]),s.useEffect(()=>{if(!x.active)return;const L=setInterval(()=>{Wt().catch(()=>{})},300*1e3);return()=>clearInterval(L)},[x.active]);const y=s.useCallback((L=0)=>{const M=()=>{ct().then(C=>{C.active&&n({active:!0,url:C.url||"",title:C.title||"",tabs:C.tabs||[]})}).catch(()=>{})};L>0?setTimeout(M,L):M()},[]);s.useEffect(()=>a(M=>{if(M.type==="browser-launched"){n(C=>({...C,active:!0,url:M.url||C.url||""})),h(C=>C+1),y(300);return}if(M.type==="browser-closed"){n({active:!1}),R(!0),b.current&&clearTimeout(b.current),b.current=setTimeout(()=>R(!1),4e3);return}if(M.type==="browser-tab-switched"){n(C=>({...C,active:!0,url:M.url||C.url||"",title:M.title||C.title||"",tabs:M.tabs||C.tabs||[]}));return}if(M.type==="screencast-url-changed"){n(C=>({...C,url:M.url||C.url||"",title:M.title||C.title||""}));return}if(M.type==="ai-fix-browser-action"){n(C=>({...C,active:!0,url:M.url||C.url||"",title:M.title||C.title||""}));return}if(M.type==="ai-fix-screenshot"){M.url&&n(C=>({...C,url:M.url||C.url||"",title:M.title||C.title||""}));return}if(M.type==="recorder-status"&&M.status==="recording"){n(C=>({...C,active:!0,url:M.url||C.url||""})),y(500);return}if(M.type==="recorder-status"&&M.status==="reset"){y(200);return}if(M.type==="ai-fix-tool"&&M.phase==="complete"){if(M.toolName==="browser_launch"){n(C=>({...C,active:!0})),h(C=>C+1),y(300);return}if(M.toolName==="browser_close"){n({active:!1});return}}}),[a,y]);const A=s.useCallback(L=>{L.preventDefault(),w.current=!0,document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[]);s.useEffect(()=>{const L=C=>{if(!w.current||!u.current)return;const H=u.current.getBoundingClientRect(),Q=100-(C.clientX-H.left)/H.width*100;c(Math.min(75,Math.max(25,Q)))},M=()=>{w.current&&(w.current=!1,document.body.style.cursor="",document.body.style.userSelect="")};return window.addEventListener("mousemove",L),window.addEventListener("mouseup",M),()=>{window.removeEventListener("mousemove",L),window.removeEventListener("mouseup",M)}},[]);const z=s.useCallback(()=>{d(L=>!L)},[]),X=s.useCallback(async()=>{try{await Ot()}catch{r({type:"screencast-close-browser"})}},[r]);s.useEffect(()=>()=>{b.current&&clearTimeout(b.current)},[]);const F=x.active,k=F&&!l;return e.jsxs("div",{ref:u,className:"flex h-full overflow-hidden relative",children:[e.jsx("div",{className:"flex-shrink-0 overflow-hidden",style:{width:k?`${100-f}%`:"100%"},children:t}),k&&e.jsx("div",{onMouseDown:A,className:"w-1 flex-shrink-0 cursor-col-resize bg-white/5 hover:bg-brand-500/40 active:bg-brand-500/40 transition-colors relative group",children:e.jsx("div",{className:"absolute inset-y-0 -left-1 -right-1"})}),k&&e.jsx("div",{className:"flex-shrink-0 overflow-hidden flex flex-col",style:{width:`${f}%`},children:e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(At,{browserStatus:x,sessionEpoch:_,subscribe:a,send:r,isPiP:!1,onTogglePiP:z,onCloseBrowser:X,userControlOnly:i})})}),F&&l&&e.jsx(nr,{browserStatus:x,sessionEpoch:_,subscribe:a,send:r,size:p,onSizeChange:E,pos:m,onPosChange:v,onTogglePiP:z,onCloseBrowser:X,containerRef:u,userControlOnly:i}),T&&e.jsx("div",{className:"absolute bottom-4 left-1/2 -translate-x-1/2 z-50 animate-fade-in",children:e.jsxs("div",{className:"flex items-center gap-2.5 px-4 py-2.5 rounded-xl bg-surface-1 border border-white/10 shadow-lg shadow-black/30",children:[e.jsx(js,{size:16,className:"text-red-400 flex-shrink-0"}),e.jsx("span",{className:"text-sm text-gray-300 font-medium",children:"Browser session closed"}),e.jsx("button",{onClick:()=>R(!1),className:"p-0.5 rounded hover:bg-white/10 text-gray-500 hover:text-gray-400 transition-colors ml-1",children:e.jsx(je,{size:12})})]})})]})}function nr({browserStatus:t,sessionEpoch:i,subscribe:a,send:r,size:x,onSizeChange:n,pos:f,onPosChange:c,onTogglePiP:l,onCloseBrowser:d,containerRef:p,userControlOnly:E=!1}){const m=s.useRef(null),v=s.useRef(!1),T=s.useRef(!1),R=s.useRef({x:0,y:0}),[_,h]=s.useState(!1),w=s.useRef(x),u=s.useCallback(()=>{if(f.x>=0&&f.y>=0)return f;const F=p.current;if(!F)return{x:20,y:20};const k=F.getBoundingClientRect();return{x:k.width-x.w-16,y:k.height-x.h-16}},[f,x,p]),b=s.useCallback(F=>{if(_)return;F.preventDefault(),v.current=!0;const k=u();R.current={x:F.clientX-k.x,y:F.clientY-k.y},document.body.style.cursor="grabbing",document.body.style.userSelect="none"},[u,_]),y=s.useCallback(F=>{F.preventDefault(),F.stopPropagation(),T.current=!0,document.body.style.cursor="nwse-resize",document.body.style.userSelect="none"},[]);s.useEffect(()=>{const F=L=>{if(v.current){const M=p.current,C=L.clientX-R.current.x,H=L.clientY-R.current.y;if(M){const W=M.getBoundingClientRect(),Q=60,O=Math.min(Math.max(-x.w+Q,C),W.width-Q),ke=Math.min(Math.max(0,H),W.height-Q);c({x:O,y:ke})}else c({x:Math.max(0,C),y:Math.max(0,H)})}if(T.current&&m.current){const M=m.current.getBoundingClientRect(),C=p.current,H=C?C.getBoundingClientRect().width-16:1200,W=C?C.getBoundingClientRect().height-16:800,Q=Math.min(H,Math.max(320,L.clientX-M.left)),O=Math.min(W,Math.max(240,L.clientY-M.top));n({w:Q,h:O})}},k=()=>{v.current=!1,T.current=!1,document.body.style.cursor="",document.body.style.userSelect=""};return window.addEventListener("mousemove",F),window.addEventListener("mouseup",k),()=>{window.removeEventListener("mousemove",F),window.removeEventListener("mouseup",k)}},[c,n]);const A=()=>{if(_)n(w.current),h(!1);else{w.current=x;const F=p.current;if(F){const k=F.getBoundingClientRect();n({w:k.width-32,h:k.height-32}),c({x:16,y:16})}h(!0)}},z=u(),X=x;return e.jsxs("div",{ref:m,className:"absolute z-50 rounded-xl overflow-hidden border border-white/10 shadow-2xl shadow-black/50 bg-surface-0",style:{left:z.x,top:z.y,width:X.w,height:X.h},children:[e.jsxs("div",{onMouseDown:b,className:"flex items-center gap-2 px-2 py-1 bg-surface-1 border-b border-white/5 cursor-grab active:cursor-grabbing flex-shrink-0",children:[e.jsx(ks,{size:10,className:"text-gray-600"}),e.jsx("span",{className:"text-[10px] text-gray-400 font-medium flex-1",children:"Live Browser"}),e.jsx("button",{onClick:A,className:"p-0.5 rounded hover:bg-white/10 text-gray-500 hover:text-gray-400 transition-colors",children:_?e.jsx(Ns,{size:10}):e.jsx(Cs,{size:10})}),e.jsx("button",{onClick:l,className:"p-0.5 rounded hover:bg-white/10 text-gray-500 hover:text-gray-400 transition-colors",children:e.jsx(je,{size:10})})]}),e.jsx("div",{className:"h-[calc(100%-24px)]",children:e.jsx(At,{browserStatus:t,sessionEpoch:i,subscribe:a,send:r,isPiP:!0,onTogglePiP:l,onCloseBrowser:d,userControlOnly:E})}),!_&&e.jsx("div",{onMouseDown:y,className:"absolute bottom-0 right-0 w-4 h-4 cursor-nwse-resize",style:{background:"linear-gradient(135deg, transparent 50%, rgba(255,255,255,0.1) 50%)"}})]})}function ar({actions:t,onActionAdded:i,onStopped:a,onCancel:r}){const[x,n]=s.useState(""),[f,c]=s.useState(!1),[l,d]=s.useState(null),p=async()=>{if(x.trim()){c(!0),d(null);try{const m=await Ut(x);i(m.action),n("")}catch(m){d(m.message)}finally{c(!1)}}},E=async()=>{c(!0),d(null);try{const m=await Bt({testName:`Recorded ${Ys(new Date)}`,formatter:"wdio-appium-ts"});a(m)}catch(m){d(m.message)}finally{c(!1)}};return e.jsxs("div",{className:"border-t border-white/[0.05] bg-surface-1 flex flex-col",style:{maxHeight:280},children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 text-[11px] border-b border-white/[0.05]",children:[e.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded bg-red-500/15 text-red-300",children:[e.jsx("span",{className:"w-1 h-1 rounded-full bg-red-400 animate-pulse"}),"REC"]}),e.jsxs("span",{className:"text-gray-400",children:[t.length," action",t.length===1?"":"s"]}),e.jsx("div",{className:"flex-1"}),e.jsx("button",{type:"button",onClick:r,disabled:f,className:"px-2 py-0.5 rounded text-gray-400 hover:text-gray-200 hover:bg-white/5 disabled:opacity-40",children:"Cancel"}),e.jsxs("button",{type:"button",onClick:E,disabled:f||t.length===0,className:"inline-flex items-center gap-1 px-2 py-0.5 rounded bg-emerald-500/15 text-emerald-300 hover:bg-emerald-500/25 disabled:opacity-40",title:"Stop recording and generate test file",children:[f?e.jsx(ve,{size:11,className:"animate-spin"}):e.jsx(Ss,{size:10}),"Stop & Generate"]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto px-3 py-2 space-y-1 text-[11px]",children:t.length===0?e.jsx("div",{className:"text-gray-500 italic",children:"Tap on the device screen above to record actions. Each tap finds the underlying element and stores a ranked locator set for the generated test."}):t.map(m=>e.jsx(ir,{action:m},m.index))}),e.jsxs("div",{className:"border-t border-white/[0.05] px-3 py-1.5 flex items-center gap-2",children:[e.jsx("input",{type:"text",value:x,onChange:m=>n(m.target.value),onKeyDown:m=>{m.key==="Enter"&&(m.preventDefault(),p())},disabled:f,placeholder:"Type text into the last tapped field…",className:"flex-1 bg-transparent border border-white/10 rounded px-2 py-1 text-[11px] text-gray-200 placeholder-gray-600 focus:outline-none focus:border-indigo-400/50"}),e.jsx("button",{type:"button",onClick:p,disabled:f||!x.trim(),className:"p-1 rounded text-indigo-300 hover:text-indigo-200 hover:bg-indigo-500/10 disabled:opacity-40",title:"Send text (Enter)",children:f?e.jsx(ve,{size:11,className:"animate-spin"}):e.jsx(Nt,{size:11})})]}),l&&e.jsxs("div",{className:"px-3 py-1 border-t border-white/[0.05] text-[11px] text-red-300 flex items-center gap-1",children:[e.jsx(Rs,{size:11}),l]})]})}function ir({action:t}){const i=t.type==="tap"?"👆":t.type==="type"?"⌨️":t.type==="swipe"?"↔︎":"⏎";return e.jsxs("div",{className:"flex items-start gap-1.5 text-gray-300",children:[e.jsxs("span",{className:"text-gray-500 tabular-nums w-5 text-right",children:[t.index+1,"."]}),e.jsx("span",{children:i}),e.jsxs("span",{className:"flex-1 break-all",children:[t.description,t.primary&&e.jsxs("span",{className:"text-gray-500 ml-1",children:["(",t.primary.strategy,"=",t.primary.value.slice(0,32),t.primary.value.length>32?"…":"",")"]})]})]})}function or({result:t,onDismiss:i}){return e.jsxs("div",{className:"border-t border-white/[0.05] bg-surface-1 px-3 py-2 text-[11px] space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-emerald-300",children:[e.jsx(nt,{size:12}),e.jsx("span",{className:"font-medium",children:"Test generated"})]}),e.jsxs("div",{className:"text-gray-400 flex items-start gap-1.5",children:[e.jsx(xt,{size:11,className:"mt-0.5 flex-shrink-0"}),e.jsx("code",{className:"break-all text-[10px]",children:t.specPath})]}),e.jsxs("div",{className:"text-gray-400 flex items-start gap-1.5",children:[e.jsx(xt,{size:11,className:"mt-0.5 flex-shrink-0 opacity-60"}),e.jsx("code",{className:"break-all text-[10px] opacity-80",children:t.healingPath})]}),e.jsxs("div",{className:"text-gray-500",children:["Wrote ",t.actions.length," action",t.actions.length===1?"":"s"," as a WDIO + Appium TypeScript spec. The companion ",e.jsx("code",{children:".healing.json"})," stores the full ranked locator set so the healing pipeline can recover from UI changes."]}),e.jsx("div",{className:"flex gap-2 pt-1",children:e.jsxs("button",{type:"button",onClick:i,className:"px-2 py-0.5 rounded text-gray-300 hover:bg-white/5 inline-flex items-center gap-1",children:[e.jsx(Es,{size:10})," Done"]})})]})}function ft(t,i,a){let r=null;const x=[];let n=0;for(const f of t){if(n=Math.max(n,ye(f.bounds)),i<f.bounds.x1||i>=f.bounds.x2||a<f.bounds.y1||a>=f.bounds.y2)continue;x.push(f);const c=(f.bounds.x2-f.bounds.x1)*(f.bounds.y2-f.bounds.y1);(!r||f.depth>r.depth||f.depth===r.depth&&c<ye(r.bounds))&&(r=f)}if(r&&!Qe(r)){const f=r;let c=null;for(const d of x)d===f||!Qe(d)||n&&ye(d.bounds)>n*.4||(!c||d.depth>c.depth||d.depth===c.depth&&ye(d.bounds)<ye(c.bounds))&&(c=d);if(c)return c;const l=x.filter(d=>d!==f&&d.depth<f.depth&&d.depth>=f.depth-4&&f.path.startsWith(d.path+"/")).sort((d,p)=>p.depth-d.depth);for(const d of l){if(n&&ye(d.bounds)>n*.4)break;if(Qe(d)||d.attrs.clickable==="true")return d}}return r}function Qe(t){const i=t.attrs["resource-id"]||"",a=[t.attrs["content-desc"],t.attrs.text,t.attrs.name,t.attrs.label,t.attrs.accessibilityIdentifier];return i.includes(":id/")&&!i.startsWith("android:")||a.some(r=>!!(r&&r.trim()))}function ye(t){return Math.max(0,t.x2-t.x1)*Math.max(0,t.y2-t.y1)}function we(t,i){const a=i==="android"?t.attrs.text||t.attrs["content-desc"]:t.attrs.label||t.attrs.name;if(a&&a.trim())return`"${a.slice(0,40)}"`;const r=t.attrs["resource-id"];return r?`#${r.split("/").pop()||r}`:t.tag.split(".").pop()||t.tag}function lr(t,i){const a=[];let r=t.path;for(a.unshift(t);;){const x=r.lastIndexOf("/");if(x<=0)break;r=r.slice(0,x);const n=i.find(f=>f.path===r);if(!n||(a.unshift(n),a.length>12))break}return a}function pt(t,i,a){const r=[],x=(c,l)=>i.filter(d=>d.attrs[c]===l).length===1,n=c=>i.filter(l=>l.attrs.text===c).length===1;if(a==="android"){const c=t.attrs["content-desc"];c&&c.trim()&&x("content-desc",c)&&r.push({strategy:"accessibility-id",value:c});const l=t.attrs["resource-id"];l&&l.includes(":id/")&&x("resource-id",l)&&r.push({strategy:"id",value:l});const d=t.attrs.text;d&&d.trim()&&n(d)&&r.push({strategy:"xpath",value:`//${t.tag}[@text=${mt(d)}]`}),l&&l.includes(":id/")&&r.push({strategy:"-android-uiautomator",value:`new UiSelector().resourceId("${l.replace(/"/g,'\\"')}")`}),r.push({strategy:"xpath",value:t.path})}else{const c=t.attrs.name||t.attrs.accessibilityIdentifier;c&&c.trim()&&r.push({strategy:"accessibility-id",value:c});const l=t.attrs.label;l&&l.trim()&&r.push({strategy:"xpath",value:`//${t.tag}[@label=${mt(l)}]`}),c&&c.trim()&&r.push({strategy:"-ios-class-chain",value:`**/${t.tag}[\`name == "${c.replace(/"/g,'\\"')}"\`]`}),r.push({strategy:"xpath",value:t.path})}const f=new Set;return r.filter(c=>{const l=`${c.strategy}:${c.value}`;return f.has(l)?!1:(f.add(l),!0)})}function mt(t){return t.includes("'")?t.includes('"')?`concat(${t.split("'").map(i=>`'${i}'`).join(`, "'", `)})`:`"${t}"`:`'${t}'`}function cr(t,i){const a=[];a.push({type:"visible",label:"Is visible",group:"visibility",editable:!1}),a.push({type:"hidden",label:"Is hidden",group:"visibility",editable:!1}),(t.attrs.enabled==="true"||t.attrs.enabled==="false"||t.attrs.clickable)&&(a.push({type:"enabled",label:"Is enabled",group:"state",editable:!1}),a.push({type:"disabled",label:"Is disabled",group:"state",editable:!1}));const r=i==="android"?t.attrs.text||t.attrs["content-desc"]:t.attrs.label||t.attrs.name||t.attrs.value;return r&&r.trim()?a.push({type:"text",label:`Has text "${r.length>30?r.slice(0,30)+"…":r}"`,expectedValue:r,group:"text",editable:!0}):a.push({type:"text",label:"Has text (custom)…",expectedValue:"",group:"text",editable:!0}),a.push({type:"attribute",label:"Has attribute (custom)…",expectedValue:"",group:"attribute",editable:!0}),a}const Ze=300,et=440,ue=12;function dr({element:t,platform:i,anchorX:a,anchorY:r,onSubmit:x,onCancel:n}){const f=s.useRef(null),[c]=s.useState(()=>cr(t,i)),[l,d]=s.useState(null),[p,E]=s.useState(""),[m,v]=s.useState({left:a,top:r});s.useEffect(()=>{const u=A=>{var z;(z=f.current)!=null&&z.contains(A.target)||n()},b=A=>{A.key==="Escape"&&n()},y=setTimeout(()=>document.addEventListener("mousedown",u),0);return document.addEventListener("keydown",b),()=>{clearTimeout(y),document.removeEventListener("mousedown",u),document.removeEventListener("keydown",b)}},[n]),s.useLayoutEffect(()=>{const u=window.innerWidth,b=window.innerHeight;let y=a+8,A=r+8;y+Ze+ue>u&&(y=Math.max(ue,a-Ze-8)),A+et+ue>b&&(A=Math.max(ue,r-et-8)),y<ue&&(y=ue),A<ue&&(A=ue),v({left:y,top:A})},[a,r]);const T={visibility:c.filter(u=>u.group==="visibility"),state:c.filter(u=>u.group==="state"),text:c.filter(u=>u.group==="text"),attribute:c.filter(u=>u.group==="attribute")},R=we(t,i),_=u=>{if(u.editable){d(u.type),E(u.expectedValue??"");return}x({type:u.type,expectedValue:u.expectedValue,label:R})},h=u=>{x({type:u.type,expectedValue:p,label:R})},w=e.jsxs("div",{ref:f,style:{position:"fixed",left:m.left,top:m.top,width:Ze,maxHeight:et},className:"z-[1000] rounded-xl border border-white/10 bg-surface-1 text-gray-200 shadow-2xl shadow-black/60 overflow-hidden flex flex-col backdrop-blur-md",role:"menu","aria-label":"Choose assertion",children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2.5 border-b border-white/10 bg-gradient-to-r from-emerald-500/15 via-green-500/10 to-transparent",children:[e.jsx("div",{className:"flex items-center justify-center w-6 h-6 rounded-md bg-emerald-500/20 border border-emerald-500/30 flex-shrink-0",children:e.jsx(Ts,{size:12,className:"text-emerald-300"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-[10px] uppercase tracking-wider text-emerald-200 font-bold leading-none",children:"Assert on"}),e.jsx("div",{className:"text-[12px] font-medium text-gray-100 truncate mt-0.5",children:R})]}),e.jsx("button",{onClick:n,className:"p-1 rounded-md text-gray-500 hover:text-gray-200 hover:bg-white/10 transition-colors","aria-label":"Close menu",children:e.jsx(je,{size:13})})]}),e.jsx("div",{className:"flex-1 overflow-y-auto py-1.5 bg-surface-1",children:["visibility","state","text","attribute"].map(u=>{const b=T[u];return b.length===0?null:e.jsxs("div",{className:"py-1",children:[e.jsx("div",{className:"px-3 pb-1 pt-1 text-[10px] uppercase tracking-wider text-gray-500 font-semibold",children:ur[u]}),b.map(y=>e.jsx("div",{children:l===y.type?e.jsxs("div",{className:"px-3 py-2.5 bg-emerald-500/[0.04] border-y border-emerald-500/10",children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[e.jsx(gt,{group:y.group}),e.jsx("span",{className:"text-[11px] text-gray-200 font-medium",children:y.type==="attribute"?"Attribute name → value":"Expected text"})]}),e.jsx("input",{type:"text",autoFocus:!0,value:p,onChange:A=>E(A.target.value),onKeyDown:A=>{A.key==="Enter"&&(A.preventDefault(),h(y)),A.key==="Escape"&&(A.preventDefault(),d(null))},placeholder:y.type==="attribute"?"e.g. enabled=true":"expected text…",className:"w-full bg-surface-0 border border-white/15 rounded-md px-2.5 py-1.5 text-[12px] text-gray-100 placeholder-gray-600 focus:outline-none focus:border-emerald-400/60 focus:ring-1 focus:ring-emerald-400/20"}),e.jsxs("div",{className:"flex justify-end gap-1.5 mt-1.5",children:[e.jsx("button",{onClick:()=>d(null),className:"px-2.5 py-1 rounded-md text-[11px] text-gray-400 hover:bg-white/5",children:"Cancel"}),e.jsxs("button",{onClick:()=>h(y),disabled:!p.trim()&&y.type!=="text",className:"inline-flex items-center gap-1 px-2.5 py-1 rounded-md text-[11px] bg-emerald-500/20 text-emerald-200 border border-emerald-500/30 hover:bg-emerald-500/30 disabled:opacity-40 transition-colors",children:[e.jsx(Ct,{size:10})," Record"]})]})]}):e.jsxs("button",{type:"button",onClick:()=>_(y),className:"w-full flex items-center gap-2 px-3 py-1.5 text-left text-[12px] text-gray-200 hover:bg-emerald-500/10 hover:text-emerald-200 transition-colors group",children:[e.jsx(gt,{group:y.group}),e.jsx("span",{className:"flex-1 truncate",children:y.label}),e.jsx(Ue,{size:11,className:"text-gray-600 group-hover:text-emerald-300 opacity-0 group-hover:opacity-100 transition-opacity"})]})},y.type+y.label))]},u)})}),e.jsxs("div",{className:"px-3 py-1.5 border-t border-white/10 bg-surface-2/40 text-[10px] text-gray-500 flex items-center justify-between",children:[e.jsxs("span",{children:["Press ",e.jsx("kbd",{className:"px-1 py-0.5 rounded bg-white/10 text-gray-300 text-[9px] font-mono",children:"Esc"})," to close"]}),e.jsxs("span",{className:"text-gray-600",children:[c.length," option",c.length===1?"":"s"]})]})]});return wt.createPortal(w,document.body)}const ur={visibility:"Visibility",state:"State",text:"Text content",attribute:"Attributes"};function gt({group:t}){const i="text-gray-500";return t==="visibility"?e.jsx(ot,{size:12,className:i}):t==="state"?e.jsx(Ms,{size:12,className:i}):t==="text"?e.jsx($s,{size:12,className:i}):e.jsx(Ps,{size:12,className:i})}const tt=400,De=520,le=16;function xr({element:t,allElements:i,platform:a,anchorX:r,anchorY:x,onSubmit:n,onCancel:f}){const c=s.useRef(null),[l,d]=s.useState(""),[p,E]=s.useState({left:r,top:x}),m=lr(t,i),v=we(t,a),T=m.map(h=>`${Ie(h.tag)}${we(h,a)===Ie(h.tag)?"":` ${we(h,a)}`}`).join(" > ");s.useEffect(()=>{const h=b=>{var y;(y=c.current)!=null&&y.contains(b.target)||f()},w=b=>{b.key==="Escape"&&f()},u=setTimeout(()=>document.addEventListener("mousedown",h),0);return document.addEventListener("keydown",w),()=>{clearTimeout(u),document.removeEventListener("mousedown",h),document.removeEventListener("keydown",w)}},[f]),s.useLayoutEffect(()=>{const h=window.innerWidth,w=window.innerHeight;let u=r+12,b=x+12;u+tt+le>h&&(u=Math.max(le,r-tt-12)),b+De+le>w&&(b=Math.max(le,Math.min(w-De-le,x-De/2))),u<le&&(u=le),b<le&&(b=le),E({left:u,top:b})},[r,x]);const R=()=>{const h=l.trim();h&&n(h,T,v)},_=e.jsx(e.Fragment,{children:e.jsxs("div",{ref:c,style:{position:"fixed",left:p.left,top:p.top,width:tt,maxHeight:De},className:"z-[1000] rounded-xl border border-white/10 bg-surface-1 text-gray-200 shadow-2xl shadow-black/70 overflow-hidden flex flex-col",role:"dialog","aria-label":"Annotate element",children:[e.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 border-b border-white/10 bg-gradient-to-r from-purple-500/15 via-violet-500/10 to-transparent",children:[e.jsx("div",{className:"flex items-center justify-center w-7 h-7 rounded-md bg-purple-500/20 border border-purple-500/30 flex-shrink-0",children:e.jsx(As,{size:13,className:"text-purple-300"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-[10px] uppercase tracking-wider text-purple-200 font-bold leading-none",children:"Annotate element"}),e.jsx("div",{className:"text-[13px] font-medium text-gray-100 truncate mt-0.5",children:v})]}),e.jsx("button",{onClick:f,className:"p-1.5 rounded-md text-gray-500 hover:text-gray-200 hover:bg-white/10 transition-colors","aria-label":"Close dialog",children:e.jsx(je,{size:14})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto px-4 py-3 space-y-3.5 bg-surface-1",children:[e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] uppercase tracking-wider text-gray-500 font-semibold mb-1.5",children:[e.jsx(zs,{size:10,className:"text-purple-400"}),"Selected"]}),e.jsxs("div",{className:"rounded-lg border border-white/10 bg-surface-2/60 p-2.5 space-y-1",children:[e.jsx("div",{className:"text-[12px] text-purple-200 font-medium",children:v}),e.jsx("div",{className:"text-[11px] text-gray-500 font-mono",children:t.tag}),e.jsx(hr,{attrs:t.attrs,platform:a})]})]}),e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] uppercase tracking-wider text-gray-500 font-semibold mb-1.5",children:[e.jsx(_s,{size:10,className:"text-purple-400"}),"Hierarchy",e.jsxs("span",{className:"text-gray-600 font-normal normal-case tracking-normal",children:["(",m.length," level",m.length===1?"":"s",")"]})]}),e.jsx("div",{className:"rounded-lg border border-white/10 bg-surface-2/60 p-2.5 font-mono text-[11px] leading-relaxed",children:m.map((h,w)=>{const u=w===m.length-1,b=we(h,a),y=b!==Ie(h.tag);return e.jsxs("div",{style:{paddingLeft:w*12},className:`flex items-baseline gap-1 truncate ${u?"text-purple-200":"text-gray-400"}`,children:[e.jsx("span",{className:"text-gray-600",children:w===0?"":"└─"}),e.jsx("span",{className:u?"font-semibold":"",children:Ie(h.tag)}),y&&e.jsx("span",{className:"text-gray-500 truncate",children:b})]},h.path)})})]}),e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center justify-between text-[10px] uppercase tracking-wider text-gray-500 font-semibold mb-1.5",children:[e.jsx("span",{children:"Your note"}),e.jsx("span",{className:"text-gray-600 font-normal normal-case tracking-normal",children:"required"})]}),e.jsx("textarea",{autoFocus:!0,value:l,onChange:h=>d(h.target.value),onKeyDown:h=>{h.key==="Enter"&&(h.metaKey||h.ctrlKey)&&(h.preventDefault(),R())},placeholder:"What about this element matters? (intent, edge case, expectation…)",rows:4,className:"w-full bg-surface-0 border border-white/15 rounded-lg px-3 py-2 text-[12px] text-gray-100 placeholder-gray-600 focus:outline-none focus:border-purple-400/60 focus:ring-1 focus:ring-purple-400/20 resize-none leading-relaxed"}),e.jsxs("div",{className:"text-[10px] text-gray-600 mt-1",children:[e.jsx("kbd",{className:"px-1 py-0.5 rounded bg-white/10 text-gray-300 text-[9px] font-mono",children:"⌘/Ctrl + Enter"}),e.jsx("span",{className:"ml-1",children:"to save"})]})]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 px-4 py-2.5 border-t border-white/10 bg-surface-2/50",children:[e.jsx("button",{onClick:f,className:"px-3 py-1.5 rounded-md text-[12px] text-gray-300 hover:bg-white/5 transition-colors",children:"Cancel"}),e.jsxs("button",{onClick:R,disabled:!l.trim(),className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md text-[12px] font-medium bg-purple-500/20 text-purple-200 border border-purple-500/30 hover:bg-purple-500/30 disabled:opacity-40 disabled:cursor-not-allowed transition-colors",children:[e.jsx(Ct,{size:12})," Save annotation"]})]})]})});return wt.createPortal(_,document.body)}function Ie(t){return t.split(".").pop()||t}function hr({attrs:t,platform:i}){const r=(i==="android"?["text","content-desc","resource-id","class"]:["name","label","value","accessibilityIdentifier"]).filter(x=>t[x]);return r.length===0?null:e.jsx("div",{className:"space-y-0.5 mt-1 pt-1.5 border-t border-white/[0.05]",children:r.map(x=>e.jsxs("div",{className:"text-[10px] font-mono flex items-baseline gap-1",children:[e.jsx(Ue,{size:9,className:"text-gray-600 flex-shrink-0 mt-0.5"}),e.jsx("span",{className:"text-gray-500",children:x}),e.jsx("span",{className:"text-gray-600",children:"="}),e.jsx("span",{className:"text-gray-300 truncate",children:t[x]})]},x))})}const fr=60;function pr({session:t,onSessionEnded:i}){const[a,r]=s.useState(null),[x,n]=s.useState(!1),[f,c]=s.useState(null),[l,d]=s.useState(null),[p,E]=s.useState(null),[m,v]=s.useState(!1),[T,R]=s.useState(!1),[_,h]=s.useState([]),[w,u]=s.useState(null),[b,y]=s.useState(!1),[A,z]=s.useState(!1),X=s.useRef(!1),F=s.useRef(0),k=s.useRef(!1),L=s.useRef([]),M=s.useRef(null),C=s.useRef(null),H=s.useRef(null),W=s.useRef(!1),Q=s.useRef(null),[O,ke]=s.useState(!1),[U,He]=s.useState(!1),[Y,Ne]=s.useState([]),[J,Ce]=s.useState(null),[G,ce]=s.useState(null),[Z,he]=s.useState(null);s.useEffect(()=>{Ht().then(g=>{g.recording&&(R(!0),z(!0))}).catch(()=>{})},[]),s.useEffect(()=>{const g=N=>{const j=N.detail;j&&(R(j.recording),j.recording&&j.owner&&j.owner!=="mobile-live-view"&&z(!0),j.recording||z(!1))};return window.addEventListener("testver-mobile-recording-changed",g),()=>window.removeEventListener("testver-mobile-recording-changed",g)},[]);const ee=s.useCallback(async()=>{try{const g=await Xt();Ne(g.elements)}catch{}},[]),pe=s.useRef(!1),de=s.useRef(!1);s.useEffect(()=>{const g=()=>{const j=window.__testver_mobile_assert_mode===!0,P=window.__testver_mobile_annotate_mode===!0;ke(j),He(P),(j&&!pe.current||P&&!de.current)&&ee(),pe.current=j,de.current=P},N=setInterval(g,250);return g(),()=>clearInterval(N)},[ee]),s.useEffect(()=>{if(!O&&!U)return;const g=setInterval(()=>void ee(),3e3);return()=>clearInterval(g)},[O,U,ee]),s.useEffect(()=>{const g=()=>{!O&&!U||setTimeout(()=>void ee(),500)};return window.addEventListener("testver-mobile-action",g),()=>window.removeEventListener("testver-mobile-action",g)},[O,U,ee]);const ne=s.useCallback(async()=>{if(X.current)return;X.current=!0;const g=Date.now();try{const N=await Vt({timeoutMs:15e3,since:F.current||void 0});if(N.unchanged){d(null);return}F.current=N.capturedAt||0,r(N.image),c(null),d(null);const j=Date.now(),P=L.current;for(P.push(j);P.length>8;)P.shift();const D=P.length>1?(P[P.length-1]-P[0])/1e3:0,B=P.length>1&&D>0?(P.length-1)/D:0;E({lastMs:j-g,fps:B})}catch(N){const j=N.message;if(Yt(N)){c(null),d(N.status===503&&j?j:"The device is slow to respond — still waiting for a frame…");return}/HTTP 404/i.test(j)?(c("Session ended."),r(null),i()):c(j)}finally{X.current=!1}},[i]);s.useEffect(()=>{if(x)return;let g=!1,N=null;const j=t.providerId==="local-appium"&&t.platform==="android",P=async()=>{if(g)return;const D=typeof document<"u"&&document.visibilityState==="hidden"||X.current||!j&&(k.current||window.__testver_mobile_action_in_flight===!0);D||await ne(),!g&&(N=setTimeout(P,D?150:fr))};return P(),()=>{g=!0,N&&clearTimeout(N)}},[x,ne,t.providerId,t.platform]);const[Se,me]=s.useState(!1),Me=async()=>{v(!0);try{await Qt()}catch{}finally{i()}},$e=s.useCallback(async()=>{y(!0);try{const g=await Gt();R(!0),h(g.actions),u(null),window.dispatchEvent(new CustomEvent("testver-mobile-recording-changed",{detail:{recording:!0,owner:"mobile-live-view"}}))}catch(g){c(`Could not start recording: ${g.message}`)}finally{y(!1)}},[]),Pe=s.useCallback(()=>{R(!1),h([]),Kt().catch(()=>{})},[]),fe=s.useCallback(g=>{R(!1),u(g),h([])},[]),ae=s.useCallback(g=>{try{const j=Math.min(1,800/g.naturalWidth),P=Math.round(g.naturalWidth*j),D=Math.round(g.naturalHeight*j),B=document.createElement("canvas");B.width=P,B.height=D;const K=B.getContext("2d");return K?(K.drawImage(g,0,0,P,D),{dataUrl:B.toDataURL("image/jpeg",.55),width:P,height:D,deviceWidth:g.naturalWidth,deviceHeight:g.naturalHeight}):null}catch{return null}},[]);s.useEffect(()=>(window.__testver_capture_mobile_frame=()=>{const g=M.current;return g?ae(g):null},()=>{try{delete window.__testver_capture_mobile_frame}catch{}}),[ae]);const se=g=>{const N=M.current;if(!N)return null;const j=N.getBoundingClientRect(),P=(g.clientX-j.left)/j.width,D=(g.clientY-j.top)/j.height;return{deviceX:Math.round(P*N.naturalWidth),deviceY:Math.round(D*N.naturalHeight),imgRect:j}},Ae=s.useCallback(g=>{if(!O&&!U||Y.length===0)return;const N=se(g);if(!N)return;const j=ft(Y,N.deviceX,N.deviceY);(j==null?void 0:j.path)!==(J==null?void 0:J.path)&&Ce(j)},[O,U,Y,J]),ze=s.useCallback(()=>{Ce(null)},[]),q=s.useCallback(async()=>{const{getStoredToken:g,getClientId:N}=await dt(async()=>{const{getStoredToken:B,getClientId:K}=await import("./index-DtBWNlVD.js").then(o=>o.iF);return{getStoredToken:B,getClientId:K}},__vite__mapDeps([0,1,2,3,4])),j=g(),P=N(),D={"Content-Type":"application/json"};return j&&(D.Authorization=`Bearer ${j}`),P&&(D["X-Client-Id"]=P),D},[]),te=s.useCallback(()=>{T&&(Q.current&&clearTimeout(Q.current),Q.current=setTimeout(async()=>{try{const g=await q();await fetch("/api/mobile/recording/prime-source",{method:"POST",headers:g})}catch{}},450))},[T,q]);s.useEffect(()=>{T&&te()},[T,te]);const Re=s.useCallback(async(g,N)=>{k.current=!0,y(!0);try{const j=await q(),P=JSON.stringify({fromX:g.x,fromY:g.y,toX:N.x,toY:N.y,durationMs:300}),D=window.__testver_mobile_record_paused===!0,B=T&&!D,o=await fetch(B?"/api/mobile/recording/swipe":"/api/mobile/session/swipe",{method:"POST",headers:j,body:P}),$=await o.json().catch(()=>({}));if(!o.ok)throw new Error(($==null?void 0:$.error)||`HTTP ${o.status}`);B&&$.action&&(A||h(S=>[...S,$.action]),window.dispatchEvent(new CustomEvent("testver-mobile-action",{detail:{action:$.action}})))}catch(j){c(`Swipe failed: ${j.message}`)}finally{y(!1),k.current=!1,await ne(),te()}},[T,A,q,ne,te]),Xe=s.useCallback(g=>{if(O||U)return;const N=se(g);N&&(H.current={deviceX:N.deviceX,deviceY:N.deviceY,clientX:g.clientX,clientY:g.clientY,t:Date.now()})},[O,U]),Ve=s.useCallback(g=>{const N=H.current;if(H.current=null,!N||O||U)return;const j=se(g);if(!j)return;const P=g.clientX-N.clientX,D=g.clientY-N.clientY;Math.hypot(P,D)>=12&&(W.current=!0,Re({x:N.deviceX,y:N.deviceY},{x:j.deviceX,y:j.deviceY}))},[O,U,Re]),Ye=s.useCallback(async g=>{if(W.current){W.current=!1;return}if(!T)return;const N=se(g);if(!N)return;if(window.__testver_mobile_record_paused===!0){k.current=!0,y(!0);try{const D=await q(),B=await fetch("/api/mobile/session/tap",{method:"POST",headers:D,body:JSON.stringify({x:N.deviceX,y:N.deviceY})}),K=await B.json().catch(()=>({}));if(!B.ok)throw new Error((K==null?void 0:K.error)||`HTTP ${B.status}`)}catch(D){c(`Tap failed: ${D.message}`)}finally{y(!1),k.current=!1,ne()}return}if(O||U){const D=Y.length>0?ft(Y,N.deviceX,N.deviceY):null;if(!D){c("No accessibility element at that point. Refreshing tree…"),await ee();return}O&&ce({el:D,x:g.clientX,y:g.clientY}),U&&he({el:D,x:g.clientX,y:g.clientY});return}const j=M.current,P=ae(j);k.current=!0,y(!0);try{const{getStoredToken:D,getClientId:B}=await dt(async()=>{const{getStoredToken:V,getClientId:oe}=await import("./index-DtBWNlVD.js").then(be=>be.iF);return{getStoredToken:V,getClientId:oe}},__vite__mapDeps([0,1,2,3,4])),K=D(),o=B(),$={"Content-Type":"application/json"};K&&($.Authorization=`Bearer ${K}`),o&&($["X-Client-Id"]=o);const S=await fetch("/api/mobile/recording/tap",{method:"POST",headers:$,body:JSON.stringify({x:N.deviceX,y:N.deviceY,screenshot:P==null?void 0:P.dataUrl,screenshotSize:P?{width:P.width,height:P.height}:void 0,deviceSize:P?{width:P.deviceWidth,height:P.deviceHeight}:void 0})}),I=await S.json();if(!S.ok)throw new Error((I==null?void 0:I.error)||`HTTP ${S.status}`);const re=I.action;A||h(V=>[...V,re]),window.dispatchEvent(new CustomEvent("testver-mobile-action",{detail:{action:re}})),(O||U)&&ee()}catch(D){c(`Tap recording failed: ${D.message}`)}finally{y(!1),k.current=!1,ne(),te()}},[T,A,ne,ae,O,U,Y,ee,q]),ie=t.platform==="ios"?"ios":"android",ge=s.useCallback(g=>{const N=M.current;if(!N)return{screenshot:void 0,screenshotSize:void 0,elementRect:void 0};const j=ae(N);if(!j)return{screenshot:void 0,screenshotSize:void 0,elementRect:void 0};const P=j.width/j.deviceWidth,D=j.height/j.deviceHeight;return{screenshot:j.dataUrl,screenshotSize:{width:j.width,height:j.height},elementRect:{x:Math.round(g.bounds.x1*P),y:Math.round(g.bounds.y1*D),width:Math.round((g.bounds.x2-g.bounds.x1)*P),height:Math.round((g.bounds.y2-g.bounds.y1)*D)}}},[ae]),Ge=s.useCallback(async g=>{if(!G)return;const N=pt(G.el,Y,ie);if(N.length===0){c("Could not derive a stable locator for that element."),ce(null);return}k.current=!0;try{const j=ge(G.el),{action:P}=await qt({locator:N[0],ranked:N,elementAttrs:G.el.attrs,elementLabel:g.label,assertType:g.type,expectedValue:g.expectedValue,...j});A||h(D=>[...D,P]),window.dispatchEvent(new CustomEvent("testver-mobile-action",{detail:{action:P}}))}catch(j){c(`Assertion failed: ${j.message}`)}finally{k.current=!1,ce(null)}},[G,Y,ie,A,ge]),Ke=s.useCallback(async(g,N,j)=>{if(!Z)return;const P=pt(Z.el,Y,ie);k.current=!0;try{const D=ge(Z.el),{action:B}=await Jt({text:g,locator:P[0],ranked:P,elementAttrs:Z.el.attrs,elementLabel:j,elementHierarchy:N,...D});A||h(K=>[...K,B]),window.dispatchEvent(new CustomEvent("testver-mobile-action",{detail:{action:B}}))}catch(D){c(`Annotation failed: ${D.message}`)}finally{k.current=!1,he(null)}},[Z,Y,ie,A,ge]),qe=s.useCallback(g=>{h(N=>[...N,g])},[]),Je=x,_e=s.useMemo(()=>a?`data:image/png;base64,${a}`:null,[a]);return e.jsxs("div",{className:"h-full flex flex-col bg-surface-0 border-l border-white/[0.05]",children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-white/[0.05] bg-surface-1",children:[e.jsx(lt,{size:13,className:"text-indigo-400"}),e.jsx("span",{className:"text-xs font-medium text-gray-200",children:t.device}),e.jsx("span",{className:"text-[10px] text-gray-500",children:"·"}),e.jsx("span",{className:"text-[10px] text-gray-500 uppercase",children:t.platform}),e.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded bg-emerald-500/10 text-[10px] text-emerald-300 ml-1",children:[e.jsx("span",{className:"w-1 h-1 rounded-full bg-emerald-400 animate-pulse"}),"LIVE"]}),e.jsx("div",{className:"flex-1"}),!A&&!T&&e.jsxs("button",{type:"button",onClick:$e,disabled:b,className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] text-red-300 hover:bg-red-500/10 disabled:opacity-40",title:"Start AI Record — capture taps and types as a runnable test",children:[b?e.jsx(ve,{size:10,className:"animate-spin"}):e.jsx(Ds,{size:10,className:"fill-red-400 text-red-400"}),"Record"]}),T&&e.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] bg-red-500/15 text-red-300",children:[e.jsx("span",{className:"w-1 h-1 rounded-full bg-red-400 animate-pulse"}),"RECORDING"]}),t.liveViewUrl&&e.jsx("a",{href:t.liveViewUrl,target:"_blank",rel:"noreferrer",className:"p-1 rounded text-gray-400 hover:text-gray-200 hover:bg-white/5",title:"Open provider dashboard in a new tab",children:e.jsx(Is,{size:11})}),e.jsx("button",{type:"button",onClick:()=>n(g=>!g),className:"p-1 rounded text-gray-400 hover:text-gray-200 hover:bg-white/5",title:x?"Resume live view":"Pause live view",children:x?e.jsx(rt,{size:11}):e.jsx(Fe,{size:11})}),e.jsx("button",{type:"button",onClick:()=>me(!0),disabled:m,className:"p-1 rounded text-red-300 hover:text-red-200 hover:bg-red-500/10 disabled:opacity-40",title:"End session",children:e.jsx(je,{size:11})}),e.jsx(Gs,{open:Se,title:"End mobile session?",description:(T?"A recording is in progress — ending the session stops it. Steps captured so far remain in the panel, but no further actions can be recorded. ":"")+`This disconnects "${t.device}" and closes the Appium session. `+(t.providerId==="local-appium"?"Starting again boots a fresh session on the device.":"Starting again boots a fresh cloud session, which takes a moment and consumes provider device minutes."),confirmLabel:"End session",cancelLabel:"Keep session",onConfirm:()=>{me(!1),Me()},onCancel:()=>me(!1)})]}),e.jsx("div",{className:"flex-1 flex items-center justify-center p-1 overflow-hidden min-h-0",children:e.jsxs("div",{ref:C,className:`relative rounded-[18px] border ${T?O?"border-green-500/40":U?"border-purple-500/40":"border-red-500/40 shadow-red-500/10":"border-white/10"} bg-black overflow-hidden shadow-2xl shadow-black/40 inline-flex h-full max-w-full`,children:[_e?e.jsx("img",{ref:M,src:_e,alt:"Mobile device live view",className:`block h-full w-auto max-w-full max-h-full ${T?O||U?"cursor-pointer":"cursor-crosshair":"cursor-default"}`,style:{imageRendering:"auto"},draggable:!1,onClick:Ye,onMouseDown:Xe,onMouseUp:Ve,onMouseMove:Ae,onMouseLeave:ze}):e.jsx("div",{className:"flex flex-col items-center justify-center w-[200px] h-[400px] text-gray-500 text-xs gap-2",children:Je?e.jsxs(e.Fragment,{children:[e.jsx(Fe,{size:20}),e.jsx("span",{children:"Paused"})]}):e.jsxs(e.Fragment,{children:[e.jsx(ve,{size:20,className:"animate-spin"}),e.jsx("span",{className:"text-center px-4",children:l??"Loading first frame…"})]})}),(O||U)&&J&&M.current&&(()=>{const g=M.current,N=g.clientWidth/g.naturalWidth,j=g.clientHeight/g.naturalHeight;return e.jsx("div",{className:`absolute pointer-events-none border-2 rounded-sm ${O?"border-green-400 bg-green-400/15 shadow-[0_0_0_2px_rgba(34,197,94,0.25)]":"border-purple-400 bg-purple-400/15 shadow-[0_0_0_2px_rgba(168,85,247,0.25)]"}`,style:{left:Math.round(J.bounds.x1*N),top:Math.round(J.bounds.y1*j),width:Math.round((J.bounds.x2-J.bounds.x1)*N),height:Math.round((J.bounds.y2-J.bounds.y1)*j)},children:e.jsxs("div",{className:`absolute -top-5 left-0 px-1.5 py-0.5 rounded text-[10px] font-medium whitespace-nowrap ${O?"bg-green-500 text-white":"bg-purple-500 text-white"}`,children:[we(J,ie)," · ",J.tag.split(".").pop()]})})})(),G&&e.jsx(dr,{element:G.el,platform:ie,anchorX:G.x,anchorY:G.y,onSubmit:Ge,onCancel:()=>ce(null)}),Z&&e.jsx(xr,{element:Z.el,allElements:Y,platform:ie,anchorX:Z.x,anchorY:Z.y,onSubmit:Ke,onCancel:()=>he(null)})]})}),e.jsx("div",{className:"px-3 py-1.5 border-t border-white/[0.05] bg-surface-1 text-[10px] flex items-center gap-2",children:f?e.jsx("span",{className:"text-red-400",children:f}):p&&!x?e.jsxs("span",{className:"text-gray-500 tabular-nums",children:[p.fps.toFixed(1)," fps · ",p.lastMs," ms",T&&(window.__testver_mobile_record_paused===!0?" · paused: taps are not recorded":" · click screen to capture tap")]}):e.jsx("span",{className:"text-gray-500",children:x?"Polling paused.":a?"Polling…":l?"Waiting for the device…":"Polling…"})}),T&&!A&&e.jsx(ar,{actions:_,onActionAdded:qe,onStopped:fe,onCancel:Pe}),w&&e.jsx(or,{result:w,onDismiss:()=>u(null)})]})}const mr=32,gr=24,br=60;function Or({children:t}){const i=yt(),[a,r]=s.useState(null),[x,n]=s.useState(mr),[f,c]=s.useState(null),[l,d]=s.useState(null),[p,E]=s.useState(()=>Date.now());s.useEffect(()=>{if(!l)return;const _=setInterval(()=>E(Date.now()),1e3);return()=>clearInterval(_)},[l]);const m=s.useRef(!1),v=s.useRef(null);s.useEffect(()=>{vt().then(()=>Zt()).then(_=>{_.session&&r(_.session)}).catch(()=>{})},[]),s.useEffect(()=>i!=null&&i.subscribe?i.subscribe(h=>{if(h.type==="mobile-session-started"){const w=h.session;w&&r(w);return}if(h.type==="mobile-session-closed"){r(null),c(null),d(null);return}if(h.type==="mobile-session-expiring"){const w=h,u=Math.max(1,Number(w.secondsLeft)||60);E(Date.now()),d({reason:w.reason==="lifetime"?"lifetime":"idle",endsAt:Date.now()+u*1e3});return}if(h.type==="mobile-session-locked"){const w=h;c({runId:String(w.runId||""),ownerLabel:String(w.ownerLabel||"Test run")});return}if(h.type==="mobile-session-unlocked"){c(null);return}}):void 0,[i]);const T=s.useCallback(_=>{_.preventDefault(),m.current=!0,document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[]);s.useEffect(()=>{const _=w=>{if(!m.current||!v.current)return;const u=v.current.getBoundingClientRect(),y=100-(w.clientX-u.left)/u.width*100;n(Math.min(br,Math.max(gr,y)))},h=()=>{m.current&&(m.current=!1,document.body.style.cursor="",document.body.style.userSelect="")};return window.addEventListener("mousemove",_),window.addEventListener("mouseup",h),()=>{window.removeEventListener("mousemove",_),window.removeEventListener("mouseup",h)}},[]);const R=a!==null;return e.jsxs("div",{ref:v,className:"flex h-full overflow-hidden relative",children:[e.jsx("div",{className:"flex-shrink-0 overflow-hidden",style:{width:R?`${100-x}%`:"100%"},children:t}),R&&e.jsxs(e.Fragment,{children:[e.jsx("div",{onMouseDown:T,className:"w-1 flex-shrink-0 cursor-col-resize bg-white/5 hover:bg-indigo-500/40 active:bg-indigo-500/40 transition-colors relative",children:e.jsx("div",{className:"absolute inset-y-0 -left-1 -right-1"})}),e.jsxs("div",{className:"flex-shrink-0 overflow-hidden relative",style:{width:`${x}%`},children:[e.jsx(pr,{session:a,onSessionEnded:()=>r(null)}),l&&e.jsxs("div",{role:"alert",className:"absolute left-2 right-2 top-2 z-40 px-3 py-2 rounded-lg bg-amber-500/20 border border-amber-500/40 text-amber-900 dark:text-amber-100 text-xs backdrop-blur flex items-start gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"font-semibold",children:[l.reason==="idle"?"Idle cloud session":"Session time limit"," — closes in ",Math.max(0,Math.ceil((l.endsAt-p)/1e3)),"s"]}),e.jsx("div",{className:"text-[10px] opacity-80 mt-0.5",children:l.reason==="idle"?"Nothing was done on the device for a while, and cloud devices bill by the minute.":"This cloud session has reached its maximum duration. Start a new session to continue."})]}),l.reason==="idle"?e.jsx("button",{type:"button",onClick:()=>{es().catch(()=>{}),d(null)},className:"flex-shrink-0 px-2 py-1 rounded-md bg-amber-500/30 hover:bg-amber-500/40 font-medium",children:"Keep session open"}):e.jsx("button",{type:"button",onClick:()=>d(null),"aria-label":"Dismiss",className:"flex-shrink-0 px-1.5 py-0.5 rounded hover:bg-amber-500/30",children:"×"})]}),f&&e.jsxs("div",{className:"absolute inset-0 z-30 flex flex-col pointer-events-none",children:[e.jsxs("div",{className:"pointer-events-auto mx-2 mt-2 px-3 py-2 rounded-lg bg-amber-500/20 border border-amber-500/40 text-amber-100 text-xs backdrop-blur flex items-start gap-2",children:[e.jsxs("span",{className:"relative flex h-2 w-2 mt-1 flex-shrink-0",children:[e.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-amber-400 opacity-75"}),e.jsx("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-amber-400"})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-semibold",children:"Test driving this session"}),e.jsxs("div",{className:"text-[10px] opacity-80 mt-0.5",children:[f.ownerLabel," — your taps are paused so they don't conflict with the test's commands. Resumes automatically when the run ends."]})]})]}),e.jsx("div",{className:"flex-1 pointer-events-auto cursor-not-allowed"})]})]})]})]})}function Br({size:t=7,className:i=""}){return e.jsx("span",{role:"status","aria-label":"AI is working",className:`inline-flex items-center gap-[5px] ${i}`,children:[0,1,2].map(a=>e.jsx("span",{style:{width:t,height:t,animationDelay:`${a*.16}s`},className:"block rounded-full bg-[#8A8A8A] dark:bg-[#C8C8C8] ai-thinking-dot shadow-[0_0_4px_rgba(150,150,150,0.45)]"},a))})}function Ur({pending:t,queuedCount:i=0,onAllow:a,onAlwaysAllow:r,onDeny:x}){return e.jsx("div",{className:"rounded-xl border border-amber-500/40 bg-white dark:bg-surface-1 p-4 shadow-2xl",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(St,{size:18,className:"text-amber-500 dark:text-amber-400 flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"text-sm font-semibold text-gray-800 dark:text-gray-200",children:t.prompt?"Over to you":"Permission required"}),i>0&&e.jsxs("span",{className:"text-[10px] text-gray-500",children:["+",i," more queued"]})]}),e.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-400 mb-1",children:t.prompt??e.jsxs(e.Fragment,{children:["AI wants to run ",e.jsx("span",{className:"font-mono text-amber-600 dark:text-amber-300",children:t.toolName})]})}),!t.prompt&&(t.fullPath||t.args)&&e.jsx("div",{className:"w-full text-[11px] text-gray-700 dark:text-gray-300 font-mono break-all max-h-20 overflow-auto mb-2 px-3 py-2 rounded-md bg-gray-100 dark:bg-gray-500/20",title:t.fullPath||t.args,children:t.fullPath||t.args}),e.jsxs("div",{className:"flex items-center gap-2 mt-3",children:[e.jsx("button",{onClick:x,className:"px-3 py-1.5 rounded-md text-xs font-medium bg-gray-100 hover:bg-gray-200 text-gray-700 border border-gray-300 dark:bg-gray-500/15 dark:text-gray-300 dark:border-gray-500/25 dark:hover:bg-gray-500/25 transition-colors",children:t.prompt?"Skip":"Deny"}),e.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[t.allowRemember!==!1&&e.jsxs("button",{onClick:r,title:`Auto-approve all future ${t.toolName} calls in this session`,className:"px-3 py-1.5 rounded-md text-xs font-medium bg-brand-500/10 hover:bg-brand-500/20 text-brand-600 border border-brand-500/30 dark:bg-brand-500/15 dark:text-brand-300 dark:border-brand-500/25 dark:hover:bg-brand-500/25 transition-colors",children:["Always allow ",t.toolName]}),e.jsx("button",{onClick:a,className:"px-3 py-1.5 rounded-md text-xs font-medium bg-emerald-500/15 hover:bg-emerald-500/25 text-emerald-700 border border-emerald-500/40 dark:bg-emerald-500/20 dark:text-emerald-300 dark:border-emerald-500/30 dark:hover:bg-emerald-500/30 transition-colors",children:t.confirmLabel??"Allow"})]})]})]})]})})}const yr=(t,i=80)=>t.length>i?`${t.slice(0,i-1)}…`:t,xe=t=>t.replace(/^(browser|mobile|api)_/,"").replace(/_/g," ");function Te(t,i,a){const r=(i||"").trim(),x=r?yr(r):"",n=(f,c,l)=>({past:x?`${f} ${x}`:`${f} ${l}`,present:x?`${c} ${x}`:`${c} ${l}`});switch(t){case"read_file":return{category:"read",icon:"read",target:r,...n("Read","Reading","a file")};case"list_directory":return{category:"list",icon:"list",target:r,...n("Listed","Listing","a folder")};case"glob_search":return{category:"search",icon:"search",target:r,...n("Searched for","Searching for","files")};case"grep":return{category:"search",icon:"search",target:r,...n("Searched for","Searching for","text")};case"file_exists":return{category:"check",icon:"search",target:r,...n("Checked","Checking","a path")};case"write_file":return(a==null?void 0:a.diffType)==="new"?{category:"create",icon:"create",target:r,...n("Created","Creating","a file")}:a?{category:"edit",icon:"edit",target:r,...n("Edited","Editing","a file")}:{category:"edit",icon:"edit",target:r,...n("Wrote","Writing","a file")};case"edit_file":return{category:"edit",icon:"edit",target:r,...n("Edited","Editing","a file")};case"find_replace":return{category:"replace",icon:"edit",target:r,...n("Replaced text in","Replacing text in","files")};case"delete_file":return{category:"delete",icon:"delete",target:r,...n("Deleted","Deleting","a file")};case"create_directory":return{category:"mkdir",icon:"folder",target:r,...n("Created folder","Creating folder","")};case"run_command":return{category:"command",icon:"command",target:r,...n("Ran","Running","a command")};case"run_tests":return{category:"tests",icon:"tests",target:r,past:x?`Ran tests: ${x}`:"Ran the tests",present:x?`Running tests: ${x}`:"Running the tests"};case"browser_navigate":return{category:"browser",icon:"browser",target:r,...n("Opened","Opening","a page")};case"browser_click":return{category:"browser",icon:"browser",target:r,...n("Clicked","Clicking","an element")};case"browser_type":return{category:"browser",icon:"browser",target:r,...n("Typed into","Typing into","a field")};case"browser_snapshot":return{category:"browser",icon:"browser",target:r,past:"Read the page",present:"Reading the page"};case"browser_screenshot":return{category:"browser",icon:"browser",target:r,past:"Took a screenshot",present:"Taking a screenshot"};case"app_knowledge":return{category:"other",icon:"knowledge",target:r,past:"Looked up app knowledge",present:"Looking up app knowledge"};case"generate_test_code":return{category:"create",icon:"create",target:r,past:"Generated test code",present:"Generating test code"}}return t.startsWith("browser_")?{category:"browser",icon:"browser",target:r,past:`Browser: ${xe(t)}`,present:`Browser: ${xe(t)}`}:t.startsWith("mobile_")?{category:"mobile",icon:"mobile",target:r,past:`App: ${xe(t)}`,present:`App: ${xe(t)}`}:t.startsWith("api_")?{category:"api",icon:"api",target:r,past:`API: ${xe(t)}`,present:`API: ${xe(t)}`}:/report|dashboard|chart|document/.test(t)?{category:"report",icon:"report",target:r,past:`Built ${xe(t).replace(/^(build|generate|save|get) /,"")}`,present:`Building ${xe(t).replace(/^(build|generate|save|get) /,"")}`}:{category:"other",icon:"tool",target:r,past:`Used ${t}`,present:`Using ${t}`}}const wr=t=>t.replace(/\\/g,"/").split("/").filter(Boolean).pop()||t;function vr(t){var f,c,l;const i=[],a=new Map,r=new Map;for(const d of t){const p=d.tool?Te(d.tool.toolName,d.tool.args,d.diff):{category:((f=d.diff)==null?void 0:f.diffType)==="new"?"create":((c=d.diff)==null?void 0:c.diffType)==="deleted"?"delete":"edit",target:(l=d.diff)==null?void 0:l.filePath};a.has(p.category)||i.push(p.category),a.set(p.category,(a.get(p.category)??0)+1),r.set(p.category,p.target||"")}const x=(d,p)=>{const E=r.get(d)?wr(r.get(d)):"",m=(v,T)=>p===1&&E?`${v} ${E}`:`${v} ${p} ${T}${p===1?"":"s"}`;switch(d){case"read":return m("read","file");case"list":return m("listed","folder");case"search":return`searched ${p} pattern${p===1?"":"s"}`;case"check":return`checked ${p} path${p===1?"":"s"}`;case"create":return m("created","file");case"edit":return m("edited","file");case"delete":return m("deleted","file");case"mkdir":return`created ${p} folder${p===1?"":"s"}`;case"replace":return`replaced text ${p===1?"once":`${p} times`}`;case"command":return`ran ${p} command${p===1?"":"s"}`;case"tests":return p===1?"ran the tests":`ran the tests ${p} times`;case"browser":return`took ${p} browser action${p===1?"":"s"}`;case"api":return`made ${p} API call${p===1?"":"s"}`;case"mobile":return`took ${p} app action${p===1?"":"s"}`;case"report":return`built ${p} report${p===1?"":"s"}`;default:return`used ${p} tool${p===1?"":"s"}`}},n=i.map(d=>x(d,a.get(d))).join(", ");return n?n.charAt(0).toUpperCase()+n.slice(1):"Worked"}function jr(t){var f,c;const i=new Map;let a=0,r=0;for(const l of t)l.diff&&!l.diff.netNoChange&&i.set(l.diff.filePath,l.diff),((f=l.tool)==null?void 0:f.phase)==="error"&&a++,((c=l.tool)==null?void 0:c.phase)==="denied"&&r++;let x=0,n=0;for(const l of i.values())x+=l.linesAdded??0,n+=l.linesRemoved??0;return{added:x,removed:n,failed:a,denied:r}}const kr=new Set(["write_file","edit_file","delete_file"]),bt=t=>t.replace(/\\/g,"/").replace(/^\.\//,"").trim();function Nr(t,i){const a=bt(t),r=bt(i);return!a||!r?!1:a===r||a.endsWith(`/${r}`)||r.endsWith(`/${a}`)}function Cr(t){const i=new Map;let a;for(const n of t){if(n.omitted){a={count:((a==null?void 0:a.count)??0)+n.omitted.count,examples:[...(a==null?void 0:a.examples)??[],...n.omitted.examples].slice(0,5)};continue}if(!n.filePath)continue;if(n.netNoChange){i.delete(n.filePath);continue}const f=i.get(n.filePath),c=(f==null?void 0:f.diffType)==="new"&&n.diffType!=="deleted"?"new":n.diffType==="new"||n.diffType==="deleted"?n.diffType:"modified";i.has(n.filePath)&&i.delete(n.filePath),i.set(n.filePath,{filePath:n.filePath,diffType:c,diff:n.diff,linesAdded:n.linesAdded??0,linesRemoved:n.linesRemoved??0,via:n.via,unavailable:n.unavailable})}const r=[];for(const n of t)n.filePath&&!r.includes(n.filePath)&&r.push(n.filePath);const x=r.filter(n=>i.has(n)).map(n=>i.get(n));return a?{files:x,omitted:a}:{files:x}}function Hr(t,i){var d,p;const a=[];let r=null,x=[],n=[],f=0;const c=()=>{r=null},l=E=>{if(c(),E&&n.length){const{files:m,omitted:v}=Cr(n);(m.length||v)&&a.push({kind:"changes",id:`changes-${f}`,files:m,...v?{omitted:v}:{}})}n=[],x=[],f++};for(const E of t){if(i.isTurnStart(E)){l(!0),a.push({kind:"entry",entry:E});continue}if((d=i.isInvisible)!=null&&d.call(i,E))continue;const m=i.toolOf(E);if(m&&!((p=i.isStandalone)!=null&&p.call(i,E))){r||(r={kind:"group",id:`group-${E.id}`,steps:[],running:!1},x.push(r),a.push(r)),r.steps.push({tool:m});continue}const v=i.diffOf(E);if(v){if(n.push(v),v.via==="detected"||v.omitted||v.netNoChange)continue;let T;for(let R=x.length-1;R>=0&&!T;R--){const _=x[R].steps;for(let h=_.length-1;h>=0;h--){const w=_[h];if(w.tool&&!w.diff&&kr.has(w.tool.toolName)&&Nr(w.tool.args,v.filePath)){T=w;break}}}T?T.diff=v:r?r.steps.push({diff:v}):(r={kind:"group",id:`group-${E.id}`,steps:[{diff:v}],running:!1},x.push(r),a.push(r));continue}c(),a.push({kind:"entry",entry:E})}if(l(!i.streaming),i.streaming)for(let E=a.length-1;E>=0;E--){const m=a[E];if(m.kind==="group"){m.running=m.steps.some(v=>{var T;return((T=v.tool)==null?void 0:T.phase)==="start"});break}}return a}const Sr={read:Xs,list:Hs,search:Us,create:Tt,edit:Et,delete:Rt,folder:Bs,command:st,tests:Os,browser:kt,api:Nt,mobile:lt,report:Ws,knowledge:Fs,tool:Ls},Rr=t=>{const i=Math.max(0,Math.round(t/1e3));return i<60?`${i} s`:`${Math.floor(i/60)}m ${String(i%60).padStart(2,"0")}s`};function zt({added:t,removed:i}){return!t&&!i?null:e.jsxs("span",{className:"flex items-center gap-1 text-[12px] font-mono tabular-nums flex-shrink-0",children:[e.jsxs("span",{className:"text-emerald-600 dark:text-emerald-400",children:["+",t]}),e.jsxs("span",{className:"text-red-600 dark:text-red-400",children:["−",i]})]})}function Er({step:t,detail:i}){if(t.diff)return t.diff.unavailable||!t.diff.diff?e.jsx("div",{className:"ml-9 mr-4 mt-1 mb-1.5 rounded-lg border border-gray-200 dark:border-white/5 bg-gray-50 dark:bg-black/20 px-3 py-2 text-[13px] text-gray-500",children:t.diff.unavailable==="binary"?"Binary file — no text diff to show.":t.diff.unavailable==="large"?"Too large to show here.":"No line changes."}):e.jsx("div",{className:"ml-9 mr-4 mt-1 mb-1.5 rounded-lg max-h-[360px] overflow-auto border border-gray-200 dark:border-white/5 bg-gray-50 dark:bg-black/30",children:e.jsx(Pt,{diff:t.diff.diff})});if(!t.tool)return null;if(i)return e.jsx(e.Fragment,{children:i(t.tool)});const a=t.tool;return e.jsxs("div",{className:"ml-9 mr-4 mt-1 mb-1.5 max-h-[240px] overflow-auto rounded-lg bg-gray-50 dark:bg-black/30 border border-gray-200 dark:border-white/5 p-2.5",children:[a.args&&e.jsx("div",{className:"text-[12px] font-mono text-gray-500 mb-1 break-all",children:a.args}),a.result&&e.jsx("div",{className:"text-[12px] font-mono text-gray-600 dark:text-gray-400 break-all whitespace-pre-wrap",children:a.result.slice(0,2e3)}),a.error&&e.jsx("div",{className:"text-[12px] font-mono text-red-500 dark:text-red-400 break-all",children:a.error})]})}function Tr({step:t,running:i,detail:a}){var m,v,T,R,_;const[r,x]=s.useState(!1),n=t.tool,f=n?Te(n.toolName,n.args,t.diff):{icon:((m=t.diff)==null?void 0:m.diffType)==="new"?"create":((v=t.diff)==null?void 0:v.diffType)==="deleted"?"delete":"edit",past:`${((T=t.diff)==null?void 0:T.diffType)==="new"?"Created":((R=t.diff)==null?void 0:R.diffType)==="deleted"?"Deleted":"Changed"} ${((_=t.diff)==null?void 0:_.filePath)??""}`,present:""},c=Sr[f.icon],l=(n==null?void 0:n.phase)==="start",d=l&&i?f.present:f.past,p=!!(t.diff||n!=null&&n.args||n!=null&&n.result||n!=null&&n.error),E=n?n.phase==="start"?i?e.jsx(ve,{size:14,className:"text-blue-500 dark:text-blue-400 animate-spin flex-shrink-0"}):e.jsx(Vs,{size:14,className:"text-gray-400 flex-shrink-0","aria-label":"Stopped"}):n.phase==="complete"?e.jsx(nt,{size:14,className:"text-emerald-500 dark:text-emerald-400 flex-shrink-0"}):n.phase==="error"?e.jsx(jt,{size:14,className:"text-red-500 dark:text-red-400 flex-shrink-0"}):e.jsx(St,{size:14,className:"text-amber-500 dark:text-amber-400 flex-shrink-0"}):e.jsx(nt,{size:14,className:"text-emerald-500 dark:text-emerald-400 flex-shrink-0"});return e.jsxs("div",{children:[e.jsxs("button",{type:"button",onClick:()=>p&&!l&&x(h=>!h),className:`flex w-full max-w-full items-center gap-2 pl-9 pr-4 py-1 text-left rounded-md transition-colors ${p&&!l?"hover:bg-gray-100/70 dark:hover:bg-white/[0.03] cursor-pointer":"cursor-default"}`,children:[E,e.jsx(c,{size:14,className:"text-gray-400 dark:text-gray-500 flex-shrink-0"}),e.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400 truncate min-w-0",title:d,children:d}),t.diff&&!t.diff.unavailable&&e.jsx(zt,{added:t.diff.linesAdded??0,removed:t.diff.linesRemoved??0}),(n==null?void 0:n.phase)==="error"&&n.error&&e.jsx("span",{className:"text-[13px] text-red-500 dark:text-red-400 truncate max-w-[320px]",title:n.error,children:n.error}),(n==null?void 0:n.phase)==="denied"&&e.jsx("span",{className:"text-[13px] text-amber-600 dark:text-amber-400 flex-shrink-0",children:"not allowed"}),p&&!l&&(r?e.jsx(Be,{size:13,className:"text-gray-400 flex-shrink-0"}):e.jsx(Ue,{size:13,className:"text-gray-400 flex-shrink-0"}))]}),r&&e.jsx(Er,{step:t,detail:a})]})}function Xr({group:t,detail:i,className:a=""}){var h,w,u;const[r,x]=s.useState(!1),[n,f]=s.useState(()=>Date.now()),{running:c,steps:l}=t;s.useEffect(()=>{if(!c)return;const b=setInterval(()=>f(Date.now()),1e3);return()=>clearInterval(b)},[c]);const d=jr(l),p=(w=(h=l.find(b=>{var y;return(y=b.tool)==null?void 0:y.startedAt}))==null?void 0:h.tool)==null?void 0:w.startedAt,E=l.reduce((b,y)=>{var A;return(A=y.tool)!=null&&A.endedAt&&(!b||y.tool.endedAt>b)?y.tool.endedAt:b},void 0),m=p?(c?n:E??p)-p:void 0,v=l.filter(b=>!b.tool||b.tool.phase!=="start").length,T=(u=[...l].reverse().find(b=>{var y;return((y=b.tool)==null?void 0:y.phase)==="start"}))==null?void 0:u.tool,R=l.length===1?l[0]:null,_=R!=null&&R.tool?Te(R.tool.toolName,R.tool.args,R.diff).past:R!=null&&R.diff?`${R.diff.diffType==="new"?"Created":R.diff.diffType==="deleted"?"Deleted":"Changed"} ${R.diff.filePath}`:vr(l);return e.jsxs("div",{className:a,children:[e.jsxs("button",{type:"button",onClick:()=>x(b=>!b),"aria-expanded":r,className:"flex max-w-full items-center gap-2 px-4 py-1 rounded-lg text-left transition-colors hover:bg-gray-100/70 dark:hover:bg-white/[0.03]",children:[c?e.jsx(ve,{size:14,className:"text-blue-500 dark:text-blue-400 animate-spin flex-shrink-0"}):r?e.jsx(Be,{size:14,className:"text-gray-400 flex-shrink-0"}):e.jsx(Ue,{size:14,className:"text-gray-400 flex-shrink-0"}),c&&T?e.jsx("span",{className:"text-sm text-blue-600 dark:text-blue-300 truncate min-w-0",title:Te(T.toolName,T.args).present,children:Te(T.toolName,T.args).present}):e.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400 truncate min-w-0",title:_,children:_}),e.jsx(zt,{added:d.added,removed:d.removed}),d.failed>0&&e.jsxs("span",{className:"text-[11px] px-1.5 py-0.5 rounded-full bg-red-500/10 text-red-600 dark:text-red-400 border border-red-500/20 flex-shrink-0",children:[d.failed," failed"]}),d.denied>0&&e.jsxs("span",{className:"text-[11px] px-1.5 py-0.5 rounded-full bg-amber-500/10 text-amber-600 dark:text-amber-400 border border-amber-500/20 flex-shrink-0",children:[d.denied," not allowed"]}),(c||l.length>1||m!==void 0&&m>=1e3)&&e.jsxs("span",{className:"text-[13px] text-gray-400 dark:text-gray-500 flex-shrink-0 tabular-nums",children:[c?`· ${v} done`:l.length>1?`· ${l.length} steps`:"",m!==void 0&&m>=1e3?` · ${Rr(m)}`:""]})]}),r&&e.jsx("div",{className:"mt-0.5 mb-1 space-y-0.5",children:l.map((b,y)=>{var A,z;return e.jsx(Tr,{step:b,running:c,detail:i},((A=b.tool)==null?void 0:A.id)??((z=b.diff)==null?void 0:z.id)??y)})})]})}const Le=6,_t=t=>t.reduce((i,a)=>({added:i.added+a.linesAdded,removed:i.removed+a.linesRemoved}),{added:0,removed:0});function it({type:t,size:i=13}){return t==="new"?e.jsx(Tt,{size:i,className:"text-emerald-500 flex-shrink-0"}):t==="deleted"?e.jsx(Rt,{size:i,className:"text-red-500 flex-shrink-0"}):e.jsx(Et,{size:i,className:"text-amber-500 flex-shrink-0"})}function Dt({file:t}){return e.jsxs(e.Fragment,{children:[t.diffType!=="modified"&&e.jsx("span",{className:`text-[11px] px-1.5 py-0.5 rounded-full border flex-shrink-0 ${t.diffType==="new"?"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border-emerald-500/20":"bg-red-500/10 text-red-600 dark:text-red-400 border-red-500/20"}`,children:t.diffType==="new"?"New":"Deleted"}),t.via==="detected"&&e.jsx("span",{className:"text-[11px] px-1.5 py-0.5 rounded-full border border-gray-300 dark:border-white/10 text-gray-500 flex-shrink-0",title:"Changed by a command or a bulk replace the AI ran — found by comparing git status before and after",children:"by a command"})]})}function It({path:t,strong:i=!0}){const a=t.lastIndexOf("/"),r=a>=0?t.slice(0,a+1):"",x=a>=0?t.slice(a+1):t;return e.jsxs("span",{className:"font-mono text-[13px] truncate min-w-0",title:t,children:[r&&e.jsx("span",{className:"text-gray-400 dark:text-gray-500",children:r}),e.jsx("span",{className:i?"text-gray-800 dark:text-gray-100 font-medium":"text-gray-700 dark:text-gray-300",children:x})]})}function Oe({added:t,removed:i}){return e.jsxs("span",{className:"flex items-center gap-1 text-[12px] font-mono tabular-nums flex-shrink-0",children:[e.jsxs("span",{className:"text-emerald-600 dark:text-emerald-400",children:["+",t]}),e.jsxs("span",{className:"text-red-600 dark:text-red-400",children:["−",i]})]})}function Mr({files:t,omitted:i,initialPath:a,onClose:r,onOpenGit:x}){const[n,f]=s.useState(()=>Math.max(0,t.findIndex(d=>d.filePath===a))),c=_t(t),l=t[n];return s.useEffect(()=>{const d=p=>{p.key==="ArrowDown"?(f(E=>Math.min(t.length-1,E+1)),p.preventDefault()):p.key==="ArrowUp"&&(f(E=>Math.max(0,E-1)),p.preventDefault())};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[t.length]),e.jsx(Ks,{title:"Review changes",subtitle:`${t.length} file${t.length===1?"":"s"} · +${c.added} −${c.removed}`,icon:e.jsx("span",{className:"rounded-md bg-brand-500/15 p-1.5 text-brand-500 dark:text-brand-300",children:e.jsx(Mt,{size:14})}),onClose:r,toolbar:x&&e.jsxs("button",{onClick:x,className:"flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-xs font-medium text-gray-600 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-white/10 transition-colors",title:"Stage and commit these changes on the Git screen",children:[e.jsx($t,{size:14})," Open in Git"]}),footer:e.jsx(e.Fragment,{children:"↑ ↓ move between files · Esc closes"}),children:e.jsxs("div",{className:"absolute inset-0 flex",children:[e.jsxs("div",{className:"w-72 flex-shrink-0 overflow-y-auto border-r border-gray-200 dark:border-white/5 py-1.5",role:"listbox","aria-label":"Changed files",children:[t.map((d,p)=>e.jsxs("button",{role:"option","aria-selected":p===n,onClick:()=>f(p),className:`flex w-full items-center gap-2 px-3 py-1.5 text-left transition-colors ${p===n?"bg-brand-500/10 dark:bg-brand-500/15":"hover:bg-gray-100 dark:hover:bg-white/[0.04]"}`,children:[e.jsx(it,{type:d.diffType,size:12}),e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-[13px] text-gray-700 dark:text-gray-300",title:d.filePath,children:d.filePath.split("/").pop()}),!d.unavailable&&e.jsx(Oe,{added:d.linesAdded,removed:d.linesRemoved})]},d.filePath)),i&&i.count>0&&e.jsxs("p",{className:"px-3 py-2 text-[12px] text-gray-500",children:["…and ",i.count," more file",i.count===1?"":"s"," changed by commands, not listed."]})]}),e.jsx("div",{className:"flex min-w-0 flex-1 flex-col",children:l?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2 border-b border-gray-200 dark:border-white/5 px-4 py-2",children:[e.jsx(it,{type:l.diffType}),e.jsx(It,{path:l.filePath}),e.jsx(Dt,{file:l}),!l.unavailable&&e.jsx(Oe,{added:l.linesAdded,removed:l.linesRemoved})]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-auto bg-gray-50 dark:bg-black/20",children:l.unavailable||!l.diff?e.jsx("p",{className:"p-6 text-sm text-gray-500",children:l.unavailable==="binary"?"Binary file — there is no text diff to show.":l.unavailable==="large"?"This file is too large to show a diff here. Open it on the Git screen.":"No line changes."}):e.jsx(Pt,{diff:l.diff,className:"py-1"})})]}):e.jsx("p",{className:"p-6 text-sm text-gray-500",children:"No files."})})]})})}function Vr({item:t}){const i=Lt(),a=ts(),[r,x]=s.useState(!1),[n,f]=s.useState(null),{files:c,omitted:l}=t,d=s.useMemo(()=>_t(c),[c]),p=r?c:c.slice(0,Le),E=c.length+((l==null?void 0:l.count)??0),m=()=>{f(null),i("/git")};return e.jsxs("div",{className:"mx-4 my-2 max-w-3xl rounded-xl border border-gray-200 dark:border-white/10 bg-gray-50/70 dark:bg-white/[0.03]",children:[e.jsxs("div",{className:"flex items-center gap-3 px-3.5 py-2.5",children:[e.jsx("span",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-white dark:bg-white/[0.06] border border-gray-200 dark:border-white/10 flex-shrink-0",children:e.jsx(Mt,{size:16,className:"text-gray-600 dark:text-gray-300"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("p",{className:"text-sm font-semibold text-gray-800 dark:text-gray-100",children:["Changed ",E," file",E===1?"":"s"]}),e.jsx(Oe,{added:d.added,removed:d.removed})]}),a&&e.jsxs("button",{onClick:m,className:"flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-[13px] font-medium text-gray-600 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-white/10 transition-colors",title:"Stage and commit these changes on the Git screen",children:[e.jsx($t,{size:14})," Open in Git"]}),c.length>0&&e.jsxs("button",{onClick:()=>f({}),className:"flex items-center gap-1.5 rounded-lg border border-gray-300 dark:border-white/15 bg-white dark:bg-white/[0.04] px-3 py-1.5 text-[13px] font-semibold text-gray-700 dark:text-gray-200 hover:bg-gray-50 dark:hover:bg-white/10 transition-colors",children:[e.jsx(ot,{size:14})," Review"]})]}),c.length>0&&e.jsxs("div",{className:"border-t border-gray-200 dark:border-white/5 py-1",children:[p.map(v=>e.jsxs("button",{onClick:()=>f({path:v.filePath}),className:"flex w-full items-center gap-2 px-3.5 py-1.5 text-left transition-colors hover:bg-gray-100/80 dark:hover:bg-white/[0.04]",title:"Review this file",children:[e.jsx(it,{type:v.diffType,size:14}),e.jsx(It,{path:v.filePath,strong:!1}),e.jsx(Dt,{file:v}),e.jsx("span",{className:"ml-auto flex items-center gap-2",children:v.unavailable?e.jsx("span",{className:"text-[12px] text-gray-400",children:v.unavailable==="binary"?"binary":"too large"}):e.jsx(Oe,{added:v.linesAdded,removed:v.linesRemoved})})]},v.filePath)),c.length>Le&&e.jsxs("button",{onClick:()=>x(v=>!v),className:"flex items-center gap-1 px-3.5 py-1 text-[13px] font-medium text-brand-500 dark:text-brand-300 hover:underline",children:[e.jsx(Be,{size:11,className:r?"rotate-180":""}),r?"Show fewer":`Show ${c.length-Le} more file${c.length-Le===1?"":"s"}`]})]}),l&&l.count>0&&e.jsxs("p",{className:"border-t border-gray-200 dark:border-white/5 px-3.5 py-1.5 text-[13px] text-gray-500",children:[c.length>0?"…and ":"",l.count," ",c.length>0?"more ":"","file",l.count===1?"":"s"," changed by commands",l.examples.length>0&&e.jsxs(e.Fragment,{children:[" (for example ",e.jsx("span",{className:"font-mono",children:l.examples.slice(0,2).join(", ")}),")"]}),a?e.jsxs(e.Fragment,{children:[" ","— see the Git screen for all of them."]}):"."]}),n&&e.jsx(Mr,{files:c,omitted:l,initialPath:n.path,onClose:()=>f(null),onOpenGit:a?m:void 0})]})}export{Br as A,Vr as C,Wr as L,Ur as P,Xr as T,Or as a,Hr as b,Fr as f};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{u as zt,e as ot,r as o,j as e,b as Xe}from"./vendor-react-CTbHBddL.js";import{u as $t,a as Et,M as Tt,i as Lt,B as Mt,C as Rt,P as At}from"./vendor-flow-YGpC9U9I.js";import{u as Dt}from"./useTabParam-ChbOedP1.js";import{h as Ot}from"./aiHandoff-vhtR29Fh.js";import{f as fe}from"./formatTestName-BKd2Uqhs.js";import{a8 as ce,b as _,cm as Ye,cn as Ft,co as Pt,cp as It,cq as Je,cr as Bt,cs as Ut,ct as _t,cu as qt,cv as Kt,cw as Ht,cx as Vt,cy as Gt,cz as Wt,cA as Qt,cB as Zt,cC as Xt,cD as Yt,cE as Jt,cF as es,cG as ts,s as ss,cH as as,cI as rs,cJ as ns,cK as ls}from"./index-DtBWNlVD.js";import{a3 as I,o as me,an as is,_ as H,bh as we,S as ne,a6 as Fe,b6 as Ae,ad as de,R as ct,$ as be,al as ue,cB as os,a_ as dt,d as cs,ac as ds,v as oe,X as xe,b9 as xs,ar as ms,aB as xt,ae as mt,bz as Be,y as us,cC as Pe,b as ps,a9 as ut,r as Ue,aK as ge,cn as et,bA as tt,cD as hs,N as _e,bB as pt,ak as Ce,a7 as bs}from"./vendor-icons-B0wLOBoh.js";import{A as ht}from"./AIStreamUI-BsxKziYG.js";import"./vendor-charts-DWFQlmCz.js";import"./vendor-query-BrzmPFT3.js";const pe={file:{label:"file",cls:"text-sky-400 bg-sky-500/10 border-sky-500/20"},provider:{label:"inline",cls:"text-violet-400 bg-violet-500/10 border-violet-500/20"},fixture:{label:"fixture",cls:"text-purple-400 bg-purple-500/10 border-purple-500/20"},hardcoded:{label:"hardcoded",cls:"text-amber-400 bg-amber-500/10 border-amber-500/20"},dynamic:{label:"dynamic",cls:"text-rose-400 bg-rose-500/10 border-rose-500/20"}},bt="••••••••",ae=t=>t==="file"||t==="fixture";function De(t,r){window.open(`/explorer?file=${encodeURIComponent(t)}${r?`&line=${r}`:""}`,"_blank","noopener")}function ft(t,r){window.open(`/tests?file=${encodeURIComponent(t)}&test=${encodeURIComponent(r)}`,"_blank","noopener")}function Oe(t){const r=(t.split(/[/\\]/).pop()||t).replace(/\.[^.]+$/,"");return r.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[-_.]+/g," ").replace(/\s+/g," ").trim().split(" ").map(n=>n&&n.charAt(0).toUpperCase()+n.slice(1)).join(" ")||r}function le({icon:t,value:r,label:n,tone:l}){const i=l==="amber"&&r>0?"bg-amber-500/10 border-amber-500/20":l==="rose"&&r>0?"bg-rose-500/10 border-rose-500/20":"bg-surface-2/50 border-white/5";return e.jsxs("div",{className:`flex items-center gap-2 px-3.5 py-2 rounded-xl border ${i}`,children:[e.jsx("span",{className:"text-gray-500",children:t}),e.jsx("span",{className:"text-lg font-bold text-gray-100 tabular-nums",children:r}),e.jsx("span",{className:"text-xs text-gray-500",children:n})]})}const ye="flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium rounded-xl bg-surface-2 hover:bg-surface-3 text-gray-400 hover:text-gray-200 border border-white/5 transition-colors disabled:opacity-50";function st({kv:t,revealed:r,onToggle:n,rk:l,tests:i,usageOpen:m,onToggleUsage:b}){const p=t.sensitive&&!r.has(l),a=t.usedBy||[],c=m.has(l);return e.jsxs("div",{className:"border-b border-white/5 last:border-0",children:[e.jsxs("div",{className:"flex items-start gap-3 px-3.5 py-2.5",children:[e.jsx("span",{className:"w-44 flex-shrink-0 font-mono text-[13px] text-gray-400 break-words",children:t.key}),e.jsx("span",{className:`flex-1 font-mono text-[13px] break-words whitespace-pre-wrap ${p?"text-gray-500":"text-gray-200"}`,children:p?bt:t.value||e.jsx("span",{className:"text-gray-600 italic",children:"empty"})}),a.length>0&&e.jsxs("button",{onClick:()=>b(l),className:`flex-shrink-0 inline-flex items-center gap-1 text-[11px] font-medium px-2 py-0.5 rounded-md border transition-colors ${c?"border-cyan-600/60 text-cyan-700 bg-cyan-500/15 dark:border-cyan-500/40 dark:text-cyan-300 dark:bg-cyan-500/10":"border-cyan-600/50 text-cyan-700 hover:bg-cyan-500/10 dark:border-cyan-500/30 dark:text-cyan-400 dark:hover:text-cyan-300"}`,title:c?"Hide tests":"Show tests that use this field",children:[e.jsx(Be,{size:11})," ",a.length," test",a.length!==1?"s":"",e.jsx(us,{size:12,className:`transition-transform ${c?"rotate-180":""}`})]}),t.sensitive?e.jsx("button",{onClick:()=>n(l),className:"flex-shrink-0 text-gray-500 hover:text-amber-300 mt-0.5",title:p?"Reveal":"Hide",children:p?e.jsx(mt,{size:14}):e.jsx(de,{size:14})}):e.jsx("span",{className:"flex-shrink-0 text-[10px] text-gray-600 mt-1 w-9 text-right",children:"plain"})]}),c&&a.length>0&&e.jsx("div",{className:"px-3.5 pb-2.5 pl-[12.5rem] space-y-0.5",children:a.map(y=>{const h=i.find(u=>u.id===y);return h?e.jsxs("button",{onClick:()=>ft(h.file,h.name),className:"flex items-center gap-1.5 w-full text-left text-xs text-gray-400 hover:text-cyan-300 truncate",children:[e.jsx(we,{size:12,className:"flex-shrink-0 text-gray-600"}),e.jsx("span",{className:"truncate",title:h.name,children:fe(h.name)}),e.jsxs("span",{className:"text-gray-600 flex-shrink-0",children:["· ",h.file.split(/[/\\]/).pop(),":",h.line]})]},y):null})})]})}function at({columns:t,rows:r,truncated:n,totalRows:l,keyPrefix:i,revealed:m,onToggle:b,bare:p,tests:a}){return e.jsxs("div",{className:`${p?"":"bg-surface-1 border border-white/5 rounded-xl "}overflow-auto max-h-[60vh]`,children:[e.jsxs("table",{className:"w-full text-sm border-collapse",children:[e.jsx("thead",{className:"sticky top-0 bg-surface-2 z-10",children:e.jsxs("tr",{children:[e.jsx("th",{className:"w-10 px-2 py-2.5 text-[11px] text-gray-600 border-b border-white/5 text-right",children:"#"}),t.map((c,y)=>e.jsx("th",{className:"text-left px-3 py-2.5 text-xs font-semibold text-gray-400 border-b border-white/5 whitespace-nowrap",children:e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[c.name,c.sensitive&&e.jsx("button",{onClick:()=>b(`${i}:${y}`),className:"text-amber-400/70 hover:text-amber-300",title:m.has(`${i}:${y}`)?"Hide column":"Reveal column",children:m.has(`${i}:${y}`)?e.jsx(de,{size:12}):e.jsx(xt,{size:12})}),c.usedBy&&c.usedBy.length>0&&e.jsxs("span",{className:"text-[10px] font-normal text-cyan-700 dark:text-cyan-400/80 normal-case",title:c.usedBy.map(h=>{var u;return(u=a.find($=>$.id===h))==null?void 0:u.name}).filter(Boolean).join(", "),children:["· ",c.usedBy.length," test",c.usedBy.length!==1?"s":""]})]})},y))]})}),e.jsx("tbody",{children:r.map((c,y)=>e.jsxs("tr",{className:"hover:bg-surface-2/40",children:[e.jsx("td",{className:"px-2 py-2 text-[11px] text-gray-600 border-b border-white/5 text-right tabular-nums",children:y+1}),t.map((h,u)=>{const $=h.sensitive&&!m.has(`${i}:${u}`),z=c[u]??"";return e.jsx("td",{title:$?void 0:z,className:`px-3 py-2 border-b border-white/5 font-mono text-xs truncate max-w-[280px] ${$?"text-gray-500":"text-gray-300"}`,children:$?bt:z},u)})]},y))})]}),n&&e.jsxs("div",{className:"px-3 py-2 text-[11px] text-gray-500 border-t border-white/5",children:["Showing first ",r.length," of ",l," rows."]})]})}function fs({p:t,revealed:r,onToggle:n,tests:l,usageOpen:i,onToggleUsage:m}){const b={revealed:r,onToggle:n,tests:l,usageOpen:i,onToggleUsage:m};if(!t)return e.jsx("div",{className:"text-sm text-gray-600",children:"No preview available for this source."});if(t.shape==="none")return e.jsxs("div",{className:"text-sm text-gray-500 flex items-center gap-2 py-3",children:[e.jsx(dt,{size:15})," ",t.note||"Not previewable."]});if(t.shape==="raw"){const p=t.masked&&!r.has("raw");return e.jsxs(e.Fragment,{children:[(t.masked||r.has("raw"))&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 mb-2",children:[e.jsx(xt,{size:12,className:"text-amber-400/70"}),p?"Secret values in this file are hidden.":"Showing secret values.",e.jsx("button",{onClick:()=>n("raw"),className:"text-amber-400/80 hover:text-amber-300 inline-flex items-center gap-1",children:p?e.jsxs(e.Fragment,{children:[e.jsx(mt,{size:12})," Reveal"]}):e.jsxs(e.Fragment,{children:[e.jsx(de,{size:12})," Hide"]})})]}),e.jsx("pre",{className:"text-[13px] font-mono text-gray-300 bg-surface-1 border border-white/5 rounded-xl p-4 overflow-auto max-h-[60vh] whitespace-pre-wrap break-words",children:t.raw})]})}return t.shape==="sections"?e.jsx("div",{className:"space-y-4",children:(t.sections||[]).map((p,a)=>{var h,u;const c=!!p.columns,y=c?p.totalRows??((h=p.rows)==null?void 0:h.length)??0:((u=p.pairs)==null?void 0:u.length)??0;return e.jsxs("div",{className:"bg-surface-1 border border-white/5 rounded-xl overflow-hidden",children:[e.jsxs("div",{className:"px-3.5 py-2.5 bg-surface-1 border-b border-white/5 flex items-center gap-2",children:[c?e.jsx(we,{size:13,className:"text-sky-400"}):e.jsx(be,{size:13,className:"text-cyan-400"}),e.jsx("span",{className:"font-mono text-sm text-gray-200",children:p.name}),e.jsxs("span",{className:"text-[11px] text-gray-600",children:["· ",y," ",c?"row":"field",y!==1?"s":""]})]}),c?e.jsx(at,{columns:p.columns,rows:p.rows||[],truncated:p.truncated,totalRows:p.totalRows,keyPrefix:`sec${a}`,revealed:r,onToggle:n,tests:l,bare:!0}):(p.pairs||[]).map(($,z)=>e.jsx(st,{kv:$,rk:`sec:${a}:${z}`,...b},z))]},a)})}):t.shape==="keyvalue"?e.jsx("div",{className:"bg-surface-1 border border-white/5 rounded-xl overflow-hidden",children:(t.pairs||[]).map((p,a)=>e.jsx(st,{kv:p,rk:`kv:${a}`,...b},a))}):e.jsx(at,{columns:t.columns||[],rows:t.rows||[],truncated:t.truncated,totalRows:t.totalRows,keyPrefix:"col",revealed:r,onToggle:n,tests:l})}function gs(){var Ze;const t=zt(),[r,n]=ot(),l=r.get("source"),[i,m]=o.useState(null),[b,p]=o.useState(!0),[a,c]=o.useState(null),[y,h]=o.useState(!1),[u,$]=o.useState(""),[z,q]=o.useState("all"),[M,T]=o.useState("all"),[x,N]=o.useState(null),[O,w]=o.useState(!1),[E,W]=o.useState(new Set),{hasRole:Q}=ce(),{toast:ee}=_(),[f,j]=o.useState(null),S=o.useRef(null),C=s=>W(k=>{const D=new Set(k);return D.has(s)?D.delete(s):D.add(s),D}),F=s=>{var D;if(E.has(s)||f||!((D=x==null?void 0:x.preview)!=null&&D.masked)){C(s);return}if(!Q("tester")){ee("info","Only testers and admins can reveal secret values.");return}const k=l;k&&Ye(k,!0).then(Re=>{S.current===k&&(j(Re.preview),C(s))}).catch(Re=>ee("error",String(Re)))},[P,Z]=o.useState(new Set),B=s=>Z(k=>{const D=new Set(k);return D.has(s)?D.delete(s):D.add(s),D}),[d,L]=o.useState({included:[],ignored:[]}),[K,v]=o.useState(!1),[A,U]=o.useState(!1),[g,R]=o.useState([]),[V,te]=o.useState(!1),[se,ze]=o.useState(""),[Ke,$e]=o.useState(null),He=()=>Pt().then(L).catch(()=>{}),Ee=(s=!1)=>{c(null),Ft(s).then(m).catch(k=>c(String(k))).finally(()=>{p(!1),h(!1)})};o.useEffect(()=>{Ee(),He()},[]);const Te=()=>{Ee(!0),He()},Le=s=>{$e(null),Ut(s).then(()=>{ze(""),Te(),Ve()}).catch(k=>$e(String(k)))},Nt=s=>{(s.manual?Je(s.file,"included"):Bt(s.file)).then(Te).catch(()=>{})},vt=s=>Je(s,"ignored").then(Te).catch(()=>{}),Ve=()=>{te(!0),_t().then(s=>R(s.candidates)).catch(()=>R([])).finally(()=>te(!1))},wt=()=>{v(!0),ze(""),$e(null),Ve()},Me=Q("tester");o.useEffect(()=>{if(S.current=l,j(null),!l){N(null);return}w(!0),W(new Set),Z(new Set),Ye(l).then(s=>N({source:s.source,preview:s.preview,tests:s.tests})).catch(()=>N(null)).finally(()=>w(!1))},[l]);const kt=()=>{h(!0),It().then(()=>Ee(!1)).catch(s=>{c(String(s)),h(!1)})},Ct=s=>n(k=>{const D=new URLSearchParams(k);return D.set("source",s.id),D},{replace:!0}),St=()=>n(s=>{const k=new URLSearchParams(s);return k.delete("source"),k},{replace:!0}),Ge=s=>Ot(t,{prompt:s,mode:"web"}),We=o.useMemo(()=>{if(!i)return[];const s=u.trim().toLowerCase();return i.sources.filter(k=>!(z!=="all"&&k.kind!==z||M==="orphans"&&!k.orphan||M==="indirect"&&!k.indirect||M==="secrets"&&!k.isSecret||s&&!(k.label.toLowerCase().includes(s)||k.file.toLowerCase().includes(s)||(k.searchText||"").includes(s)))).sort((k,D)=>D.usedByTestCount-k.usedByTestCount)},[i,u,z,M]);if(b)return e.jsxs("div",{className:"flex items-center justify-center h-full text-gray-500 gap-2",children:[e.jsx(I,{size:18,className:"animate-spin"})," Scanning test data…"]});if(a)return e.jsxs("div",{className:"flex items-center justify-center h-full text-red-400 gap-2",children:[e.jsx(me,{size:18})," ",a]});if(!i)return null;if(l){const s=x==null?void 0:x.source;return e.jsxs("div",{className:"h-full flex flex-col animate-fade-in",children:[e.jsxs("div",{className:"flex items-center gap-3 px-5 py-3 border-b border-white/5 bg-surface-1 flex-shrink-0",children:[e.jsxs("button",{onClick:St,className:ye,children:[e.jsx(is,{size:15})," Test Data"]}),s&&e.jsx("span",{className:`text-sm text-gray-200 truncate ${ae(s.kind)?"":"font-mono"}`,children:ae(s.kind)?Oe(s.label):s.label}),s&&e.jsxs("button",{onClick:()=>De(s.file,s.line),title:"Open in Project Explorer (new tab)",className:"ml-auto text-gray-500 hover:text-cyan-300 inline-flex items-center gap-1.5 text-sm",children:[e.jsx(H,{size:14})," Open file"]})]}),e.jsx("div",{className:"flex-1 overflow-auto px-5 py-4",children:e.jsx("div",{className:"max-w-[1100px] mx-auto",children:O||!s?e.jsxs("div",{className:"flex items-center gap-2 text-gray-500 text-sm py-10 justify-center",children:[e.jsx(I,{size:16,className:"animate-spin"})," Reading data…"]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"bg-surface-1 border border-white/5 rounded-xl p-4 mb-5",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap mb-2",children:[e.jsx("span",{className:`text-[11px] px-1.5 py-0.5 rounded border ${pe[s.kind].cls}`,children:pe[s.kind].label}),s.format&&e.jsx("span",{className:"text-[11px] text-gray-500 uppercase",children:s.format}),((Ze=x==null?void 0:x.preview)==null?void 0:Ze.totalRows)!=null&&e.jsxs("span",{className:"text-[11px] text-gray-500",children:[x.preview.totalRows," ",x.preview.shape==="table"?"rows":x.preview.shape==="sections"?"groups":"fields"]}),s.isDynamic&&e.jsx("span",{className:"text-[11px] text-rose-400",children:"non-deterministic"}),s.isSecret&&e.jsx("span",{className:"text-[11px] text-amber-400",children:"PII / secret"})]}),e.jsx("h1",{className:`text-lg text-gray-100 break-all ${ae(s.kind)?"":"font-mono"}`,children:ae(s.kind)?Oe(s.label):s.label}),e.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:[e.jsxs("button",{onClick:()=>De(s.file,s.line),title:"Open in Project Explorer (new tab)",className:"text-gray-500 hover:text-cyan-300 inline-flex items-center gap-1",children:[s.file,s.line?`:${s.line}`:""," ",e.jsx(H,{size:10})]})," ","· used by ",(x==null?void 0:x.tests.length)??s.usedByTestCount," test",((x==null?void 0:x.tests.length)??s.usedByTestCount)!==1?"s":""]})]}),ae(s.kind)?e.jsx(fs,{p:(f&&(f.shape!=="raw"||E.has("raw"))?f:x==null?void 0:x.preview)??null,revealed:E,onToggle:F,tests:(x==null?void 0:x.tests)??[],usageOpen:P,onToggleUsage:B}):e.jsx("div",{className:"bg-surface-1 border border-white/5 rounded-xl p-4 font-mono text-sm text-gray-300 break-all",children:s.label}),e.jsxs("div",{className:"mt-6",children:[e.jsxs("h2",{className:"text-sm font-semibold text-gray-300 mb-2",children:["Used by ",(x==null?void 0:x.tests.length)??0," test",((x==null?void 0:x.tests.length)??0)!==1?"s":""]}),((x==null?void 0:x.tests.length)??0)===0?e.jsx("div",{className:"text-sm text-gray-600",children:s.orphan?"No test references this — it may be dead data.":s.indirect?"Loaded via a helper / non-test file — not attributable to a specific test.":"No mapped tests."}):e.jsx("div",{className:"bg-surface-1 border border-white/5 rounded-xl overflow-hidden",children:x.tests.map(k=>e.jsxs("div",{className:"flex items-center gap-2 px-3.5 py-2.5 border-b border-white/5 last:border-0 hover:bg-surface-2/40 group",children:[e.jsx(we,{size:14,className:"text-gray-500 flex-shrink-0"}),e.jsx("button",{onClick:()=>ft(k.file,k.name),title:"Open in Test Explorer (new tab)",className:"flex-1 text-left text-sm text-gray-300 hover:text-cyan-300 truncate",children:fe(k.name)}),e.jsxs("button",{onClick:()=>De(k.file,k.line),title:"Open file in Project Explorer (new tab)",className:"text-[11px] text-gray-600 hover:text-gray-300 truncate max-w-[240px] inline-flex items-center gap-1 flex-shrink-0",children:[k.file.split(/[/\\]/).pop(),":",k.line," ",e.jsx(H,{size:11,className:"opacity-0 group-hover:opacity-70"})]})]},k.id))})]}),(s.kind==="hardcoded"||s.kind==="dynamic")&&e.jsx("div",{className:"mt-5",children:e.jsxs("button",{onClick:()=>Ge(s.kind==="hardcoded"?`The value "${s.label}" is hardcoded as test data in my tests (${s.file}). Analyze its usages and suggest how to externalize it into a managed dataset or environment variable. Show me the plan first.`:`The tests use dynamic/random data via "${s.label}". Analyze which tests rely on it and whether it introduces non-determinism, and suggest a strategy (seeded data / fixtures). Plan only.`),className:"inline-flex items-center gap-1.5 px-3 py-2 text-sm rounded-xl border border-cyan-500/30 text-cyan-300 hover:bg-cyan-500/10",children:[e.jsx(ne,{size:14})," ",s.kind==="hardcoded"?"Externalize with AI":"Analyze with AI"," ",e.jsx(H,{size:12})]})})]})})})]})}const Y=i.stats,Qe=s=>`px-3 py-1.5 text-sm font-medium rounded-xl border transition-colors ${s?"bg-cyan-500/15 text-cyan-300 border-cyan-500/30":"bg-surface-2 text-gray-400 border-white/5 hover:bg-surface-3 hover:text-gray-200"}`;return e.jsxs("div",{className:"h-full flex flex-col animate-fade-in",children:[e.jsxs("div",{className:"flex items-center gap-3 px-5 py-3 border-b border-white/5 bg-surface-1 flex-shrink-0",children:[e.jsx(Fe,{size:18,className:"text-gray-900 dark:text-gray-100 flex-shrink-0"}),e.jsx("span",{className:"text-sm text-gray-500 hidden md:inline flex-shrink-0",children:"Test data sources, test usage & duplicates"}),e.jsxs("span",{className:"text-xs text-gray-500",children:[Y.filesScanned," files · ",Y.durationMs,"ms"]}),e.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[Me&&e.jsxs("button",{onClick:wt,className:ye,title:"Add a test data file the scan missed",children:[e.jsx(Ae,{size:14})," Add file"]}),d.ignored.length>0&&e.jsxs("button",{onClick:()=>U(!0),className:ye,title:"Manage ignored files",children:[e.jsx(de,{size:14})," Ignored (",d.ignored.length,")"]}),e.jsxs("button",{onClick:kt,disabled:y,className:ye,children:[y?e.jsx(I,{size:14,className:"animate-spin"}):e.jsx(ct,{size:14})," Rescan"]})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2.5 px-5 py-3 border-b border-white/5 bg-surface-1/50 flex-shrink-0",children:[e.jsx(le,{icon:e.jsx(be,{size:15}),value:Y.total,label:"data sources"}),e.jsx(le,{icon:e.jsx(Fe,{size:15}),value:Y.testsMapped,label:"tests mapped"}),e.jsx(le,{icon:e.jsx(ue,{size:15}),value:Y.duplicateClusters,label:"duplicates",tone:"amber"}),e.jsx(le,{icon:e.jsx(os,{size:15}),value:Y.dynamicCount,label:"dynamic / random"}),e.jsx(le,{icon:e.jsx(dt,{size:15}),value:Y.orphanCount,label:"orphan files"}),e.jsx(le,{icon:e.jsx(cs,{size:15}),value:Y.indirectCount??0,label:"used indirectly"}),e.jsx(le,{icon:e.jsx(ds,{size:15}),value:Y.hardcodedSecrets,label:"hardcoded secrets",tone:"rose"})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 px-5 py-3 border-b border-white/5 bg-surface-1/50 flex-shrink-0",children:[e.jsxs("div",{className:"relative flex-1 min-w-[220px]",children:[e.jsx(oe,{size:15,className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-500"}),e.jsx("input",{value:u,onChange:s=>$(s.target.value),placeholder:"Search name, path, or data contents (keys & values)…",className:"w-full pl-9 pr-9 py-1.5 rounded-xl text-sm bg-surface-2 border border-white/10 text-gray-200 outline-none placeholder-gray-600 focus:border-brand-500/50 transition-colors"}),u&&e.jsx("button",{onClick:()=>$(""),title:"Clear search",className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-gray-500 hover:text-gray-300",children:e.jsx(xe,{size:15})})]}),["all","file","fixture","provider","dynamic","hardcoded"].map(s=>e.jsx("button",{onClick:()=>{q(z===s?"all":s),T("all")},className:Qe(s==="all"?z==="all"&&M==="all":z===s),children:s==="all"?"All":pe[s].label},s)),["orphans","indirect","secrets"].map(s=>e.jsx("button",{onClick:()=>{T(M===s?"all":s),q("all")},className:Qe(M===s),children:s},s))]}),e.jsxs("div",{className:"flex-1 overflow-auto",children:[We.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-gray-600 gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-2xl bg-surface-2 border border-white/5 flex items-center justify-center",children:e.jsx(oe,{size:22})}),e.jsx("span",{className:"text-sm",children:"No data sources match."})]}):e.jsxs("table",{className:"w-full text-sm border-collapse bg-surface-1",children:[e.jsx("thead",{className:"sticky top-0 bg-surface-1 z-10",children:e.jsxs("tr",{className:"text-gray-500",children:[e.jsx("th",{className:"text-left font-semibold px-5 py-2.5 border-b border-white/5",children:"Source"}),e.jsx("th",{className:"text-left font-semibold px-3 py-2.5 border-b border-white/5",children:"Kind"}),e.jsx("th",{className:"text-right font-semibold px-3 py-2.5 border-b border-white/5",children:"Rows"}),e.jsx("th",{className:"text-right font-semibold px-3 py-2.5 border-b border-white/5",children:"Used by"}),e.jsx("th",{className:"text-left font-semibold px-3 py-2.5 border-b border-white/5",children:"Flags"}),e.jsx("th",{className:"w-12 px-2 pr-5 py-2.5 border-b border-white/5"})]})}),e.jsx("tbody",{children:We.map(s=>e.jsxs("tr",{onClick:()=>Ct(s),className:"hover:bg-surface-2/40 cursor-pointer group",children:[e.jsx("td",{className:"px-5 py-2.5 border-b border-white/5 max-w-[420px]",children:ae(s.kind)?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-gray-200 truncate",children:Oe(s.label)}),e.jsx("div",{className:"text-[11px] text-gray-500 font-mono truncate",title:s.label,children:s.label})]}):e.jsx("div",{className:"font-mono text-gray-200 truncate",title:s.label,children:s.label})}),e.jsx("td",{className:"px-3 py-2.5 border-b border-white/5",children:e.jsx("span",{className:`text-[11px] px-1.5 py-0.5 rounded border ${pe[s.kind].cls}`,children:pe[s.kind].label})}),e.jsx("td",{className:"px-3 py-2.5 border-b border-white/5 text-right text-xs text-gray-500 tabular-nums",children:ae(s.kind)?`${s.rowCount??"–"} · ${s.format??""}`:"—"}),e.jsx("td",{className:"px-3 py-2.5 border-b border-white/5 text-right tabular-nums text-gray-300",children:s.usedByTestCount}),e.jsxs("td",{className:"px-3 py-2.5 border-b border-white/5 text-[11px]",children:[s.manual&&e.jsx("span",{className:"text-cyan-400 mr-1",children:"added"}),s.orphan&&e.jsx("span",{className:"text-gray-500 mr-1",children:"orphan"}),s.indirect&&e.jsx("span",{className:"text-sky-400/80 mr-1",title:"Used via a helper / non-test file",children:"indirect"}),s.isDynamic&&e.jsx("span",{className:"text-rose-400 mr-1",children:"random"}),s.isSecret&&e.jsx("span",{className:"text-amber-400",children:"PII/secret"})]}),e.jsx("td",{className:"px-2 py-2.5 pr-5 border-b border-white/5 text-right",children:Me&&ae(s.kind)&&e.jsx("button",{onClick:k=>{k.stopPropagation(),Nt(s)},title:s.manual?"Remove added file":"Hide & ignore this file",className:"text-gray-500 hover:text-rose-400 opacity-0 group-hover:opacity-100 transition-opacity",children:s.manual?e.jsx(xs,{size:14}):e.jsx(de,{size:14})})})]},s.id))})]}),i.duplicates.length>0&&e.jsxs("div",{className:"px-5 py-5",children:[e.jsxs("h2",{className:"flex items-center gap-2 mb-2 text-sm font-semibold text-gray-300",children:[e.jsx(ue,{size:15,className:"text-amber-400"})," Duplicate data (",i.duplicates.length,")"]}),e.jsxs("div",{className:"bg-surface-1 border border-white/5 rounded-xl overflow-hidden",children:[i.duplicates.slice(0,30).map(s=>e.jsxs("div",{className:"flex items-center px-4 py-2.5 text-sm border-b border-white/5 last:border-0",children:[e.jsx("span",{className:"flex-1 font-mono text-gray-200 truncate pr-2",children:s.value}),e.jsx("span",{className:"text-[11px] px-1.5 py-0.5 rounded text-amber-400 bg-amber-500/10 border border-amber-500/20 mr-3",children:s.type}),e.jsxs("span",{className:"text-gray-400 text-xs mr-3 tabular-nums",children:["×",s.count]}),e.jsxs("button",{onClick:()=>Ge(`In my test project, the test data "${s.value}" is duplicated in ${s.count} places (${s.type}). Analyze where it's used and suggest how to consolidate it into a single shared dataset or constant. Plan only.`),className:"inline-flex items-center gap-1 text-[11px] text-cyan-400 hover:text-cyan-300",children:[e.jsx(ne,{size:12})," consolidate"]})]},s.fingerprint)),i.duplicates.length>30&&e.jsxs("div",{className:"px-4 py-2 text-[11px] text-gray-500 border-t border-white/5",children:["Showing first 30 of ",i.duplicates.length," duplicate clusters."]})]})]})]}),K&&Xe.createPortal(e.jsx("div",{className:"fixed inset-0 bg-black/70 z-50 flex items-center justify-center p-4",onClick:()=>v(!1),children:e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/10 max-w-lg w-full max-h-[80vh] flex flex-col",onClick:s=>s.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-white/5",children:[e.jsxs("h3",{className:"text-base font-semibold text-gray-100 flex items-center gap-2",children:[e.jsx(Ae,{size:16})," Add test data file"]}),e.jsx("button",{onClick:()=>v(!1),className:"text-gray-500 hover:text-gray-300",children:e.jsx(xe,{size:18})})]}),e.jsxs("div",{className:"p-4 overflow-y-auto",children:[e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:"Data-ish files the scan didn't capture:"}),V?e.jsxs("div",{className:"flex items-center gap-2 text-gray-500 text-sm py-4",children:[e.jsx(I,{size:14,className:"animate-spin"})," Finding files…"]}):g.length===0?e.jsx("div",{className:"text-sm text-gray-600 py-2 mb-2",children:"No uncaptured candidate files found."}):e.jsx("div",{className:"border border-white/5 rounded-lg overflow-hidden max-h-[40vh] overflow-y-auto mb-4",children:g.map(s=>e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-sm border-b border-white/5 last:border-0 hover:bg-surface-2/40",children:[e.jsx(we,{size:13,className:"text-gray-500 flex-shrink-0"}),e.jsx("span",{className:"flex-1 font-mono text-xs text-gray-300 truncate",title:s.file,children:s.file}),e.jsx("span",{className:"text-[10px] text-gray-600 uppercase",children:s.format}),e.jsxs("button",{onClick:()=>Le(s.file),className:"text-[11px] text-cyan-400 hover:text-cyan-300 inline-flex items-center gap-1",children:[e.jsx(Ae,{size:12})," add"]})]},s.file))}),e.jsx("p",{className:"text-xs text-gray-500 mb-1.5",children:"Or add by path (relative to project):"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{value:se,onChange:s=>ze(s.target.value),placeholder:"e.g. src/test/resources/data.csv",className:"flex-1 bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 font-mono placeholder-gray-600 focus:outline-none focus:border-cyan-500/50",onKeyDown:s=>{s.key==="Enter"&&se.trim()&&Le(se.trim())}}),e.jsx("button",{onClick:()=>se.trim()&&Le(se.trim()),disabled:!se.trim(),className:"px-3 py-2 text-sm rounded-lg border border-cyan-500/30 text-cyan-300 hover:bg-cyan-500/10 disabled:opacity-40",children:"Add"})]}),Ke&&e.jsx("p",{className:"text-xs text-rose-400 mt-2",children:Ke})]})]})}),document.body),A&&Xe.createPortal(e.jsx("div",{className:"fixed inset-0 bg-black/70 z-50 flex items-center justify-center p-4",onClick:()=>U(!1),children:e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/10 max-w-lg w-full max-h-[80vh] flex flex-col",onClick:s=>s.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-white/5",children:[e.jsxs("h3",{className:"text-base font-semibold text-gray-100 flex items-center gap-2",children:[e.jsx(de,{size:16})," Ignored files (",d.ignored.length,")"]}),e.jsx("button",{onClick:()=>U(!1),className:"text-gray-500 hover:text-gray-300",children:e.jsx(xe,{size:18})})]}),e.jsx("div",{className:"p-4 overflow-y-auto",children:d.ignored.length===0?e.jsx("div",{className:"text-sm text-gray-600",children:"No ignored files."}):e.jsx("div",{className:"border border-white/5 rounded-lg overflow-hidden",children:d.ignored.map(s=>e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-sm border-b border-white/5 last:border-0",children:[e.jsx("span",{className:"flex-1 font-mono text-xs text-gray-300 truncate",title:s,children:s}),Me&&e.jsxs("button",{onClick:()=>vt(s),className:"text-[11px] text-cyan-400 hover:text-cyan-300 inline-flex items-center gap-1",children:[e.jsx(ms,{size:12})," restore"]})]},s))})})]})}),document.body)]})}const Ie={page:"Page Object",helper:"Helper",support:"Support",step:"Step Def",fixture:"Fixture",test:"Test",source:"Source"};function J(t,r){const n=`/explorer?file=${encodeURIComponent(t)}${r?`&line=${r}`:""}`;window.open(n,"_blank","noopener")}function Se(t,r){const n=`/tests?file=${encodeURIComponent(t)}&test=${encodeURIComponent(r)}`;window.open(n,"_blank","noopener")}const ys=new RegExp("\\b(?:async|await|function|return|const|let|var|if|else|elif|for|while|do|switch|case|break|continue|class|extends|implements|interface|type|enum|namespace|struct|new|delete|import|from|export|default|public|private|protected|internal|static|readonly|abstract|override|virtual|final|void|def|end|self|begin|rescue|ensure|module|require|lambda|yield|with|as|in|of|is|not|and|or|pass|raise|try|catch|except|finally|throw|throws|super|this|using|package|func|fn|val|when|then|true|false|null|nil|None|True|False|undefined|NaN|string|number|boolean|bool|int|float|double|char|str)\\b");function js(t,r){const n=r==="python"||r==="ruby",l=n?"#[^\\n]*":"\\/\\/[^\\n]*",i=n?"":"|\\/\\*[\\s\\S]*?\\*\\/",m=new RegExp(`(${l}${i})|(\`(?:\\\\.|[^\`\\\\])*\`|"(?:\\\\.|[^"\\\\])*"|'(?:\\\\.|[^'\\\\])*')|(\\b\\d[\\d_.]*(?:e[+-]?\\d+)?\\b)|(${ys.source})|([A-Za-z_$][\\w$]*)(?=\\s*\\()|(\\b[A-Z][A-Za-z0-9_]*\\b)`,"g"),b=[];let p=0,a,c=0;for(;(a=m.exec(t))!==null;){a.index>p&&b.push(t.slice(p,a.index));const y=a[1]?"cm-tok-comment":a[2]?"cm-tok-string":a[3]?"cm-tok-number":a[4]?"cm-tok-keyword":a[5]?"cm-tok-function":"cm-tok-type";b.push(e.jsx("span",{className:y,children:a[0]},c++)),p=a.index+a[0].length}return p<t.length&&b.push(t.slice(p)),b}function Ns({view:t,setView:r}){const n=(l,i,m)=>e.jsxs("button",{onClick:()=>r(l),className:`flex items-center gap-1.5 px-4 py-2 text-sm font-medium border-b-2 transition-colors ${t===l?"border-brand-400 text-brand-300":"border-transparent text-gray-400 hover:text-gray-200 hover:border-white/10"}`,children:[m,i]});return e.jsxs("div",{className:"flex items-center gap-1 px-5 border-b border-white/5 bg-surface-1 flex-shrink-0",children:[n("methods","Methods and Steps",e.jsx(Pe,{size:15})),n("data","Test Data",e.jsx(Fe,{size:15}))]})}function Js(){const[t,r]=Dt("view",["methods","data"],"methods");return e.jsxs("div",{className:"h-full flex flex-col animate-fade-in",children:[e.jsx(Ns,{view:t,setView:r}),e.jsx("div",{className:"flex-1 min-h-0",children:t==="methods"?e.jsx(vs,{}):e.jsx(gs,{})})]})}const je=500;function vs(){const{toast:t}=_(),[r,n]=o.useState(null),[l,i]=o.useState(!0),[m,b]=o.useState(!1),[p,a]=o.useState(""),[c,y]=o.useState("all"),[h,u]=o.useState(!1),[$,z]=o.useState("usage"),[q,M]=o.useState(null),[T,x]=o.useState("inventory"),[N,O]=o.useState(null),[w,E]=o.useState(!1),[W,Q]=o.useState(je);o.useEffect(()=>{Q(je)},[p,c,h,w,$]);const ee=(d=!1)=>{i(!0),Kt(d).then(L=>{n(L),Ht().then(O).catch(()=>O(null))}).catch(L=>t("error",`Failed to load code map: ${L}`)).finally(()=>i(!1))};o.useEffect(()=>{ee()},[]);const[f,j]=ot();o.useEffect(()=>{const d=f.get("symbol");if(!d)return;x("inventory"),M(d);const L=f.get("name");L&&a(L),j(K=>{const v=new URLSearchParams(K);return v.delete("symbol"),v.delete("name"),v},{replace:!0})},[]);const S=()=>{var A;const d=((r==null?void 0:r.symbols)||[]).filter(U=>U.unused);if(d.length===0){t("info","No unused methods to clean up.");return}const L=new Map;d.forEach(U=>{(L.get(U.file)||L.set(U.file,[]).get(U.file)).push(U)});const K=["# Code cleanup — unused methods (Testver Code Map)",""];for(const[U,g]of L){K.push(`## ${U}`);for(const R of g){const V=N!=null&&N.available&&N.executed[R.id]===!1?" — confirmed dead (not covered at runtime)":"";K.push(`- [ ] \`${R.className?R.className+".":""}${R.name}\` (line ${R.startLine})${V}`)}K.push("")}K.push("> Candidates only — verify before deleting (static analysis can miss reflection / dynamic dispatch).");const v=K.join(`
|
|
2
|
+
`);(A=navigator.clipboard)==null||A.writeText(v).then(()=>t("success",`Copied cleanup checklist (${d.length} methods) to clipboard`),()=>t("error","Could not copy to clipboard"))},C=o.useMemo(()=>{const d=new Set;return((r==null?void 0:r.symbols)||[]).forEach(L=>d.add(L.role)),[...d]},[r]),F=o.useMemo(()=>((r==null?void 0:r.symbols)||[]).filter(d=>!d.isEntryPoint||d.role!=="test").length,[r]),P=o.useMemo(()=>{let d=((r==null?void 0:r.symbols)||[]).filter(v=>!v.isEntryPoint||v.role!=="test");const L=p.trim().toLowerCase();L&&(d=d.filter(v=>v.name.toLowerCase().includes(L)||v.file.toLowerCase().includes(L)||(v.className||"").toLowerCase().includes(L))),c!=="all"&&(d=d.filter(v=>v.role===c)),h&&(d=d.filter(v=>v.unused)),w&&(d=d.filter(v=>v.unused&&(N==null?void 0:N.executed[v.id])===!1));const K={usage:(v,A)=>A.usedByTestCount-v.usedByTestCount||v.name.localeCompare(A.name),callers:(v,A)=>A.callerCount-v.callerCount||v.name.localeCompare(A.name),name:(v,A)=>v.name.localeCompare(A.name),file:(v,A)=>v.file.localeCompare(A.file)||v.startLine-A.startLine};return[...d].sort(K[$])},[r,p,c,h,w,N,$]),Z=()=>{b(!0),Vt().then(()=>ee(!1)).catch(d=>t("error",String(d))).finally(()=>b(!1))},B=r==null?void 0:r.stats;return e.jsxs("div",{className:"h-full flex flex-col animate-fade-in",children:[e.jsxs("div",{className:"flex items-center gap-3 px-5 py-3 border-b border-white/5 bg-surface-1 flex-shrink-0",children:[e.jsx(Pe,{size:18,className:"text-brand-400 flex-shrink-0"}),e.jsx("span",{className:"text-sm text-gray-500 hidden md:inline flex-shrink-0",children:"Methods & steps inventory, test usage and quality"}),e.jsx("div",{className:"flex items-center gap-1 p-0.5 rounded-xl bg-surface-2 border border-white/5",children:["inventory","quality","graph","steps"].filter(d=>d!=="steps"||(B==null?void 0:B.gherkin)).map(d=>e.jsx("button",{onClick:()=>x(d),className:`px-3 py-1.5 text-xs font-medium capitalize rounded-lg transition-colors ${T===d?"bg-brand-600 text-white shadow-sm":"text-gray-400 hover:text-gray-200 hover:bg-white/5"}`,children:d},d))}),e.jsxs("button",{onClick:Z,disabled:m,className:"ml-auto flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium rounded-xl bg-surface-2 hover:bg-surface-3 text-gray-400 hover:text-gray-200 border border-white/5 transition-colors disabled:opacity-50",children:[m?e.jsx(I,{size:14,className:"animate-spin"}):e.jsx(ct,{size:14})," Rebuild"]}),T==="inventory"&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:S,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium rounded-xl bg-surface-2 hover:bg-surface-3 text-gray-400 hover:text-gray-200 border border-white/5 transition-colors",children:[e.jsx(ps,{size:14})," Copy cleanup task"]}),e.jsxs("button",{onClick:()=>qt().catch(d=>t("error",`Export failed: ${d}`)),className:"flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium rounded-xl bg-surface-2 hover:bg-surface-3 text-gray-400 hover:text-gray-200 border border-white/5 transition-colors",children:[e.jsx(ut,{size:14})," Export CSV"]})]})]}),B&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2.5 px-5 py-3 border-b border-white/5 bg-surface-1/50 flex-shrink-0",children:[e.jsx(Ne,{icon:e.jsx(Pe,{size:15}),label:"Methods",value:F}),e.jsx(Ne,{icon:e.jsx(me,{size:15}),label:"Unused",value:B.unused,tone:"amber"}),e.jsx(Ne,{icon:e.jsx(Ue,{size:15}),label:"Tests",value:B.tests}),e.jsx(Ne,{icon:e.jsx(ge,{size:15}),label:"Files",value:B.files}),(N==null?void 0:N.available)&&e.jsxs("div",{className:"flex items-center gap-2 px-3.5 py-2 rounded-xl bg-emerald-500/10 border border-emerald-500/20",title:`Coverage from ${N.source}`,children:[e.jsx(et,{size:15,className:"text-emerald-400"}),e.jsx("span",{className:"text-[15px] font-bold text-emerald-300 tabular-nums",children:N.confirmedDead}),e.jsxs("span",{className:"text-xs text-emerald-400/70",children:["Confirmed dead · ",N.format]})]}),e.jsxs("span",{className:"ml-auto text-xs text-gray-500",children:["indexed in ",B.durationMs,"ms"]})]}),T==="inventory"&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2 px-5 py-3 border-b border-white/5 bg-surface-1/50 flex-shrink-0",children:[e.jsxs("div",{className:"relative flex-1 min-w-[200px] max-w-md",children:[e.jsx(oe,{size:15,className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-500"}),e.jsx("input",{value:p,onChange:d=>a(d.target.value),placeholder:"Search methods, files, classes…",className:"w-full pl-9 pr-3 py-1.5 rounded-xl text-sm bg-surface-2 border border-white/10 text-gray-200 outline-none placeholder-gray-600 focus:border-brand-500/50 transition-colors"})]}),e.jsxs("select",{value:c,onChange:d=>y(d.target.value),className:"bg-surface-2 border border-white/10 rounded-xl px-3 py-1.5 text-sm text-gray-300 outline-none cursor-pointer",children:[e.jsx("option",{value:"all",children:"All roles"}),C.map(d=>e.jsx("option",{value:d,children:Ie[d]||d},d))]}),e.jsxs("select",{value:$,onChange:d=>z(d.target.value),className:"bg-surface-2 border border-white/10 rounded-xl px-3 py-1.5 text-sm text-gray-300 outline-none cursor-pointer",children:[e.jsx("option",{value:"usage",children:"Sort: most used"}),e.jsx("option",{value:"callers",children:"Sort: most callers"}),e.jsx("option",{value:"name",children:"Sort: name"}),e.jsx("option",{value:"file",children:"Sort: file"})]}),e.jsxs("button",{onClick:()=>u(d=>!d),className:`flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium rounded-xl border transition-colors ${h?"bg-amber-500/15 text-amber-300 border-amber-500/30":"bg-surface-2 text-gray-400 border-white/5 hover:bg-surface-3 hover:text-gray-200"}`,children:[e.jsx(me,{size:14})," Unused only"]}),(N==null?void 0:N.available)&&e.jsxs("button",{onClick:()=>E(d=>!d),className:`flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium rounded-xl border transition-colors ${w?"bg-red-500/15 text-red-300 border-red-500/30":"bg-surface-2 text-gray-400 border-white/5 hover:bg-surface-3 hover:text-gray-200"}`,title:"Statically unused AND never executed at runtime",children:[e.jsx(et,{size:14})," Confirmed dead"]}),e.jsxs("span",{className:"text-xs text-gray-600",children:[P.length," shown"]})]}),T==="quality"?e.jsx($s,{onOpenSymbol:d=>{x("inventory"),M(d)}}):T==="steps"?e.jsx(Ls,{onOpenSymbol:d=>{x("inventory"),M(d)}}):T==="graph"?e.jsx(Us,{symbols:(r==null?void 0:r.symbols)||[],onOpenSymbol:d=>{x("inventory"),M(d)}}):e.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[e.jsxs("div",{className:"flex-1 overflow-auto bg-surface-1",children:[l?e.jsxs("div",{className:"flex items-center gap-2 p-6 text-sm text-gray-500",children:[e.jsx(I,{size:16,className:"animate-spin"})," Indexing project…"]}):P.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 py-20 text-gray-500",children:[e.jsx("div",{className:"w-12 h-12 rounded-2xl bg-surface-2 border border-white/5 flex items-center justify-center",children:e.jsx(oe,{size:22})}),e.jsx("div",{className:"text-sm",children:"No methods match your filters."})]}):e.jsxs("table",{className:"w-full text-sm border-separate border-spacing-0",children:[e.jsx("thead",{className:"sticky top-0 bg-surface-1 z-10",children:e.jsxs("tr",{className:"text-[11px] uppercase tracking-wide text-gray-500",children:[e.jsx("th",{className:"text-left font-semibold px-5 py-2.5 border-b border-white/5",children:"Method"}),e.jsx("th",{className:"text-left font-semibold px-3 py-2.5 border-b border-white/5",children:"File"}),e.jsx("th",{className:"text-left font-semibold px-3 py-2.5 border-b border-white/5",children:"Role"}),e.jsx("th",{className:"text-right font-semibold px-3 py-2.5 border-b border-white/5",children:"Tests"}),e.jsx("th",{className:"text-right font-semibold px-3 py-2.5 border-b border-white/5",children:"Callers"}),e.jsx("th",{className:"text-right font-semibold px-3 py-2.5 border-b border-white/5",title:"Cyclomatic complexity",children:"Cx"}),e.jsx("th",{className:"text-left font-semibold px-3 py-2.5 border-b border-white/5",children:"Status"})]})}),e.jsx("tbody",{children:P.slice(0,W).map(d=>e.jsxs("tr",{onClick:()=>M(d.id),className:`cursor-pointer transition-colors ${q===d.id?"bg-brand-500/10":"hover:bg-white/[0.03]"}`,children:[e.jsxs("td",{className:"px-5 py-2.5 border-b border-white/5",children:[e.jsx("span",{className:"font-mono text-gray-200",children:d.name}),d.className&&e.jsxs("span",{className:"text-gray-500 text-xs",children:[" · ",d.className]})]}),e.jsxs("td",{className:"px-3 py-2.5 border-b border-white/5 text-gray-500 text-xs font-mono truncate max-w-[260px]",title:d.file,children:[d.file,":",d.startLine]}),e.jsx("td",{className:"px-3 py-2.5 border-b border-white/5 text-gray-400 text-xs",children:Ie[d.role]||d.role}),e.jsx("td",{className:"px-3 py-2.5 border-b border-white/5 text-right tabular-nums text-gray-300",children:d.usedByTestCount}),e.jsx("td",{className:"px-3 py-2.5 border-b border-white/5 text-right tabular-nums text-gray-500",children:d.callerCount}),e.jsx("td",{className:`px-3 py-2.5 border-b border-white/5 text-right tabular-nums ${d.complexity>=10?"text-red-400":d.complexity>=6?"text-amber-400":"text-gray-500"}`,children:d.complexity}),e.jsx("td",{className:"px-3 py-2.5 border-b border-white/5",children:d.unused?e.jsx("span",{className:"text-[10px] font-medium px-2 py-0.5 rounded-md bg-amber-500/10 text-amber-400 border border-amber-500/20",children:"Unused"}):d.usedByTestCount>0?e.jsx("span",{className:"text-[10px] font-medium px-2 py-0.5 rounded-md bg-emerald-500/10 text-emerald-400 border border-emerald-500/20",children:"Used"}):e.jsx("span",{className:"text-[10px] font-medium px-2 py-0.5 rounded-md bg-gray-500/10 text-gray-400 border border-gray-500/20",children:"Indirect"})})]},d.id))})]}),!l&&P.length>W&&e.jsxs("div",{className:"flex items-center justify-center gap-3 py-4 text-xs text-gray-500",children:["Showing ",W.toLocaleString()," of ",P.length.toLocaleString()," methods",e.jsxs("button",{onClick:()=>Q(d=>d+je),className:"px-3 py-1 rounded-lg text-xs text-brand-200 bg-brand-500/10 border border-brand-500/25 hover:bg-brand-500/20 transition-colors",children:["Show ",Math.min(je,P.length-W).toLocaleString()," more"]})]})]}),q&&e.jsx(ws,{id:q,executed:N!=null&&N.available?N.executed[q]:void 0,onClose:()=>M(null)})]})]})}function Ne({icon:t,label:r,value:n,tone:l}){return e.jsxs("div",{className:`flex items-center gap-2 px-3.5 py-2 rounded-xl border ${l==="amber"?"bg-amber-500/10 border-amber-500/20":"bg-surface-2/50 border-white/5"}`,children:[e.jsx("span",{className:l==="amber"?"text-amber-400":"text-brand-400",children:t}),e.jsx("span",{className:`text-[15px] font-bold tabular-nums ${l==="amber"?"text-amber-300":"text-gray-100"}`,children:n}),e.jsx("span",{className:"text-xs text-gray-500",children:r})]})}function ws({id:t,executed:r,onClose:n}){const{toast:l}=_(),[i,m]=o.useState(null),[b,p]=o.useState(!0);o.useEffect(()=>{p(!0),m(null),Xt(t).then(m).catch(c=>l("error",String(c))).finally(()=>p(!1))},[t]);const a=i==null?void 0:i.symbol;return e.jsxs("div",{className:"w-[540px] max-w-[48vw] shrink-0 border-l border-white/5 bg-surface-1 flex flex-col overflow-hidden animate-fade-in",children:[e.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-b border-white/5 bg-surface-1 flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(be,{size:18,className:"text-brand-400 shrink-0"}),e.jsx("span",{className:"font-mono text-sm font-semibold text-gray-100 truncate",children:(a==null?void 0:a.name)||"…"})]}),e.jsx("button",{onClick:n,className:"p-1.5 rounded-lg text-gray-500 hover:text-gray-200 hover:bg-white/5 transition-colors",children:e.jsx(xe,{size:16})})]}),b||!i?e.jsxs("div",{className:"p-4 text-sm text-gray-500 flex items-center gap-2",children:[e.jsx(I,{size:14,className:"animate-spin"})," Loading…"]}):e.jsxs("div",{className:"flex-1 overflow-auto p-4 space-y-4",children:[e.jsxs("button",{onClick:()=>J(a.file,a.startLine),title:"Open in Project Explorer (new tab)",className:"group flex items-center gap-1.5 text-[13px] text-brand-400 hover:text-brand-300 font-mono transition-colors",children:[e.jsx(ge,{size:13,className:"shrink-0 text-brand-400"}),e.jsxs("span",{className:"truncate underline decoration-dotted decoration-gray-400/50 underline-offset-2",children:[a.file,":",a.startLine]}),e.jsx(H,{size:12,className:"shrink-0 text-brand-400"})]}),e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[e.jsx(ie,{children:Ie[a.role]||a.role}),e.jsx(ie,{children:a.language}),a.visibility&&e.jsx(ie,{children:a.visibility}),e.jsxs(ie,{children:[a.loc," LOC"]}),e.jsxs(ie,{children:["cx ",a.complexity]}),i.usage.unused&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-amber-500/10 text-amber-400 border border-amber-500/20",children:"Unused candidate"}),r===!0&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-emerald-500/10 text-emerald-400 border border-emerald-500/20",children:"ran at runtime"}),r===!1&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-red-500/10 text-red-400 border border-red-500/20",children:"not covered at runtime"})]}),e.jsx(Es,{id:t,unused:i.usage.unused}),i.usedByTests.length>0&&e.jsx(Ss,{tests:i.usedByTests}),i.usedByTests.length>0&&e.jsx(ve,{title:"Used by tests",icon:e.jsx(Ue,{size:14,className:"text-emerald-400"}),items:i.usedByTests,listClass:"space-y-2",getText:c=>`${c.name} ${c.file}`,placeholder:"Filter tests by name or file…",render:c=>e.jsx(zs,{t:c},c.id)}),i.calledBy.length>0&&e.jsx(ve,{title:"Called by methods",icon:e.jsx(be,{size:13,className:"text-brand-400"}),items:i.calledBy,getText:c=>`${c.className?c.className+".":""}${c.name} ${c.file}`,placeholder:"Filter methods by name or file…",render:c=>e.jsx(nt,{c},c.id)}),i.calls.length>0&&e.jsx(ve,{title:"Calls",icon:e.jsx(_e,{size:13,className:"text-brand-400"}),items:i.calls,getText:c=>`${c.className?c.className+".":""}${c.name} ${c.file}`,placeholder:"Filter calls by name or file…",render:c=>e.jsx(nt,{c},c.id)}),e.jsx(ke,{title:"Source",icon:e.jsx(pt,{size:13,className:"text-brand-400"}),children:e.jsx(qe,{code:i.source||"(source unavailable)",lang:a.language})})]})]})}const ks=new Set(["playwright","jest","vitest","mocha","pytest","robot","puppeteer"]),Cs=3;function Ss({tests:t}){const{toast:r}=_(),n=ce().hasRole("tester"),[l,i]=o.useState(!1),m=o.useMemo(()=>{const c=new Map;for(const h of t)(c.get(h.framework)||c.set(h.framework,new Set).get(h.framework)).add(h.file);const y=[];for(const[h,u]of c)if(ks.has(h))y.push({files:[...u],framework:h});else for(const $ of u)y.push({files:[$],framework:h});return y},[t]);if(!n)return null;const b=m.reduce((c,y)=>c+y.files.length,0),p=m.length>Cs,a=async()=>{i(!0);try{for(const c of m)await ss(c);r("success",`Started ${m.length===1?"a run":`${m.length} runs`} for ${b} test file${b!==1?"s":""} — follow ${m.length===1?"it":"them"} in the Runner.`)}catch(c){r("error",String(c))}finally{i(!1)}};return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:a,disabled:l||p,title:p?`${b} test files need ${m.length} separate runs — select the tests in Test Explorer to run them together`:"Run every test file that exercises this method",className:"flex items-center gap-1.5 px-2.5 py-1 rounded-lg text-xs font-medium text-emerald-300 bg-emerald-500/10 border border-emerald-500/25 hover:bg-emerald-500/20 disabled:opacity-50 transition-colors",children:[l?e.jsx(I,{size:12,className:"animate-spin"}):e.jsx(bs,{size:12})," Run affected tests"]}),e.jsxs("span",{className:"text-[11px] text-gray-500",children:[t.length," test",t.length!==1?"s":""," in ",b," file",b!==1?"s":"",p?" — too many separate runs; use Test Explorer":""]})]})}function rt({onClick:t,title:r,children:n,copied:l}){return e.jsx("button",{onClick:i=>{i.stopPropagation(),t()},title:r,className:`p-1.5 rounded-lg border transition-colors ${l?"text-emerald-400 border-emerald-500/30 bg-emerald-500/10":"text-gray-500 hover:text-gray-100 border-white/5 bg-surface-2/60 hover:bg-surface-3"}`,children:n})}function zs({t}){const{toast:r}=_(),[n,l]=o.useState(!1),i=()=>{var m;return(m=navigator.clipboard)==null?void 0:m.writeText(t.name).then(()=>{l(!0),setTimeout(()=>l(!1),1500)},()=>r("error","Could not copy to clipboard"))};return e.jsx("div",{className:"rounded-lg border border-white/5 bg-surface-2/40 px-3 py-2.5 hover:bg-surface-2/70 transition-colors",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-sm text-gray-200 leading-snug",title:t.name,children:fe(t.name)}),e.jsxs("button",{onClick:()=>J(t.file,t.startLine),title:"Open file in Project Explorer (new tab)",className:"group flex items-center gap-1.5 mt-1 text-xs text-gray-500 hover:text-brand-300 font-mono transition-colors",children:[e.jsx(ge,{size:12,className:"shrink-0 text-gray-600 group-hover:text-brand-400"}),e.jsx("span",{className:"truncate",children:t.file}),e.jsxs("span",{className:"text-gray-600",children:[":",t.startLine]})]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx(rt,{onClick:i,title:"Copy test name",copied:n,children:n?e.jsx(Ce,{size:13}):e.jsx(ue,{size:13})}),e.jsx(rt,{onClick:()=>Se(t.file,t.name),title:"Open in Test Explorer (new tab)",children:e.jsx(Be,{size:13})})]})]})})}function nt({c:t}){return e.jsxs("button",{onClick:()=>J(t.file,t.startLine),title:"Open in Project Explorer (new tab)",className:"group w-full flex items-center gap-2 rounded-lg border border-white/5 bg-surface-2/40 px-3 py-2 hover:bg-surface-2/70 transition-colors text-left",children:[e.jsxs("span",{className:"font-mono text-[13px] text-gray-200 truncate",title:`${t.className?t.className+".":""}${t.name}`,children:[t.className&&e.jsxs("span",{className:"text-gray-500",children:[t.className,"."]}),t.name]}),e.jsxs("span",{className:"ml-auto flex items-center gap-1.5 min-w-0",children:[e.jsx("span",{className:"text-[11px] text-gray-500 font-mono truncate max-w-[180px]",title:`${t.file}:${t.startLine}`,children:t.file}),e.jsx(H,{size:12,className:"shrink-0 text-gray-600 opacity-0 group-hover:opacity-100 transition-opacity"})]})]})}function qe({code:t,lang:r}){const{toast:n}=_(),[l,i]=o.useState(!1),m=o.useMemo(()=>js(t,r),[t,r]),b=()=>{var p;(p=navigator.clipboard)==null||p.writeText(t).then(()=>{i(!0),setTimeout(()=>i(!1),1500)},()=>n("error","Could not copy to clipboard"))};return e.jsxs("div",{className:"cm-code rounded-xl border cm-code-surface overflow-hidden",children:[e.jsxs("div",{className:"cm-code-bar flex items-center justify-between px-3 py-1.5 border-b",children:[e.jsxs("span",{className:"flex items-center gap-2 text-[10px] uppercase tracking-wide text-gray-500 font-medium",children:[e.jsxs("span",{className:"flex gap-1",children:[e.jsx("span",{className:"w-2.5 h-2.5 rounded-full bg-red-400/70"}),e.jsx("span",{className:"w-2.5 h-2.5 rounded-full bg-amber-400/70"}),e.jsx("span",{className:"w-2.5 h-2.5 rounded-full bg-emerald-400/70"})]}),r||"source"]}),e.jsx("button",{onClick:b,className:"flex items-center gap-1 px-2 py-0.5 rounded-md text-[11px] text-gray-500 hover:bg-gray-500/20 transition-colors",children:l?e.jsxs(e.Fragment,{children:[e.jsx(Ce,{size:12,className:"text-emerald-400"})," Copied"]}):e.jsxs(e.Fragment,{children:[e.jsx(ue,{size:12})," Copy"]})})]}),e.jsx("pre",{className:"cm-code-pre text-[12.5px] leading-relaxed font-mono whitespace-pre overflow-auto p-3 max-h-80",children:m})]})}function ke({title:t,count:r,icon:n,children:l}){return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[n,e.jsx("span",{className:"text-xs font-semibold text-gray-300",children:t}),r!=null&&e.jsx("span",{className:"text-[10px] font-medium text-gray-500 bg-surface-2 border border-white/5 rounded-full px-1.5 py-0.5 tabular-nums",children:r})]}),l]})}function ve({title:t,icon:r,items:n,getText:l,render:i,placeholder:m,listClass:b="space-y-1.5"}){const[p,a]=o.useState(""),c=p.trim().toLowerCase(),y=c?n.filter(h=>l(h).toLowerCase().includes(c)):n;return e.jsxs(ke,{title:t,count:n.length,icon:r,children:[n.length>4&&e.jsxs("div",{className:"relative mb-2",children:[e.jsx(oe,{size:13,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-gray-500"}),e.jsx("input",{value:p,onChange:h=>a(h.target.value),placeholder:m,className:"w-full pl-8 pr-3 py-1.5 rounded-lg text-xs bg-surface-2 border border-white/10 text-gray-200 outline-none placeholder-gray-600 focus:border-brand-500/50 transition-colors"})]}),y.length===0?e.jsxs("div",{className:"text-xs text-gray-500 py-1",children:["No matches for “",p,"”."]}):e.jsx("div",{className:b,children:y.map(i)})]})}function ie({children:t}){return e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-surface-2 text-gray-400 border border-white/10",children:t})}function $s({onOpenSymbol:t}){const{toast:r}=_(),[n,l]=o.useState(null),[i,m]=o.useState(!0);if(o.useEffect(()=>{m(!0),Gt().then(a=>l(a.quality)).catch(a=>r("error",String(a))).finally(()=>m(!1))},[]),i)return e.jsxs("div",{className:"flex-1 p-6 text-sm text-gray-500 flex items-center gap-2",children:[e.jsx(I,{size:16,className:"animate-spin"})," Analyzing quality…"]});if(!n)return e.jsx("div",{className:"flex-1 p-6 text-sm text-gray-500",children:"No quality data."});const b=({r:a})=>e.jsxs("button",{onClick:()=>t(a.id),title:"Open method details",className:"group inline-flex items-baseline gap-1 rounded-md px-2 py-1 -mx-2 text-left cursor-pointer hover:bg-brand-500/10 transition-colors",children:[e.jsxs("span",{className:"font-mono text-sm text-gray-200 group-hover:underline decoration-dotted underline-offset-2",children:[a.className?`${a.className}.`:"",a.name]}),e.jsxs("span",{className:"text-gray-600 text-xs font-mono",children:[" · ",a.file,":",a.startLine]})]}),p=a=>a==="A"?"text-emerald-400":a==="B"?"text-emerald-300":a==="C"?"text-amber-400":a==="D"?"text-orange-400":"text-red-400";return e.jsxs("div",{className:"flex-1 overflow-auto p-5 space-y-5",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(X,{label:"duplicate clusters",value:n.summary.duplicateClusters,tone:"amber"}),e.jsx(X,{label:"complex methods",value:n.summary.complexMethods,tone:"amber"}),e.jsx(X,{label:"orphan files",value:n.summary.orphanFiles,tone:"amber"}),e.jsx(X,{label:"orphan locators",value:n.summary.orphanLocators,tone:"amber"}),e.jsx(X,{label:"tests w/o assertions",value:n.summary.noAssertionTests,tone:"red"})]}),e.jsx(_s,{files:n.fileMaintainability}),e.jsx(G,{title:"Duplicate & near-duplicate methods",hint:"Refactor candidates. ‘identical’ = same body; ‘similar’ = same structure, renamed.",children:n.duplicates.length===0?e.jsx(re,{children:"No duplicates detected."}):n.duplicates.map((a,c)=>e.jsx(Ts,{c:a,RefEl:b},c))}),e.jsx(G,{title:"Most complex methods",hint:"High cyclomatic complexity / deep nesting / long bodies.",children:n.complexMethods.length===0?e.jsx(re,{children:"Nothing notably complex."}):e.jsx("table",{className:"w-full text-sm",children:e.jsx("tbody",{children:n.complexMethods.map(a=>e.jsxs("tr",{className:"border-b border-white/5",children:[e.jsx("td",{className:"py-2",children:e.jsx(b,{r:a})}),e.jsxs("td",{className:"py-2 text-right text-sm text-amber-400 tabular-nums w-20",children:["cx ",a.complexity]}),e.jsxs("td",{className:"py-2 text-right text-sm text-gray-500 tabular-nums w-24",children:["nest ",a.maxNesting]}),e.jsxs("td",{className:"py-2 text-right text-sm text-gray-500 tabular-nums w-20",children:[a.loc," loc"]})]},a.id))})})}),e.jsx(G,{title:"Orphan files",hint:"Every automation method in the file is unused — whole-file dead-code candidates.",children:n.orphanFiles.length===0?e.jsx(re,{children:"No orphan files."}):n.orphanFiles.map(a=>e.jsxs("button",{onClick:()=>J(a.file),title:"Open in Project Explorer (new tab)",className:"group w-full text-left text-sm py-1.5 px-1 flex items-center gap-2 border-b border-white/5 hover:bg-brand-500/10 transition-colors",children:[e.jsx(ge,{size:14,className:"text-amber-400 shrink-0"}),e.jsx("span",{className:"font-mono text-gray-300 group-hover:underline decoration-dotted underline-offset-2 truncate",children:a.file}),e.jsxs("span",{className:"text-gray-600 text-xs shrink-0",children:["· ",a.methods," unused method(s)"]}),e.jsx(H,{size:12,className:"text-brand-400 opacity-0 group-hover:opacity-100 transition-opacity ml-auto shrink-0"})]},a.file))}),e.jsx(G,{title:"Tests without assertions",hint:"Tests with no detected expect/assert — possible gaps.",children:n.noAssertionTests.length===0?e.jsx(re,{children:"All tests have assertions."}):n.noAssertionTests.map(a=>e.jsxs("button",{onClick:()=>Se(a.file,a.name),title:"Open in Test Explorer (new tab)",className:"group w-full text-left py-1.5 px-1 border-b border-white/5 last:border-0 hover:bg-brand-500/10 transition-colors flex items-center gap-2",children:[e.jsxs("span",{className:"flex-1 min-w-0",children:[e.jsx("span",{className:"block text-sm text-gray-200 group-hover:underline decoration-dotted underline-offset-2 truncate",title:a.name,children:fe(a.name)}),e.jsxs("span",{className:"block text-xs text-gray-600 font-mono truncate",children:[a.file,":",a.startLine]})]}),e.jsx(H,{size:12,className:"text-brand-400 opacity-0 group-hover:opacity-100 transition-opacity shrink-0"})]},a.id))}),e.jsx(G,{title:"Orphan locators",hint:"Element/selector definitions referenced nowhere else (best-effort — verify before removing).",children:n.orphanLocators.length===0?e.jsx(re,{children:"No orphan locators detected."}):n.orphanLocators.map((a,c)=>e.jsxs("button",{onClick:()=>J(a.file,a.line),title:"Open in Project Explorer (new tab)",className:"group w-full text-left text-sm py-1.5 px-1 flex items-center gap-1 border-b border-white/5 last:border-0 hover:bg-brand-500/10 transition-colors",children:[e.jsx("span",{className:"font-mono text-gray-300 group-hover:underline decoration-dotted underline-offset-2",children:a.name}),e.jsxs("span",{className:"text-gray-600 text-xs",children:[" · ",a.file,":",a.line]}),e.jsx(H,{size:12,className:"text-brand-400 opacity-0 group-hover:opacity-100 transition-opacity ml-auto shrink-0"})]},c))}),e.jsx(G,{title:"File maintainability",hint:"Heuristic score (complexity, size, unused, duplication). Lowest first.",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"sticky top-0 bg-surface-1 z-10",children:e.jsxs("tr",{className:"text-xs uppercase text-gray-500 border-b border-white/5",children:[e.jsx("th",{className:"text-left font-medium py-2",children:"File"}),e.jsx("th",{className:"text-right font-medium py-2",children:"Methods"}),e.jsx("th",{className:"text-right font-medium py-2",children:"Avg cx"}),e.jsx("th",{className:"text-right font-medium py-2",children:"Unused"}),e.jsx("th",{className:"text-right font-medium py-2",children:"Score"})]})}),e.jsx("tbody",{children:n.fileMaintainability.slice(0,40).map(a=>e.jsxs("tr",{className:"border-b border-white/5",children:[e.jsx("td",{className:"py-2 max-w-[320px]",children:e.jsxs("button",{onClick:()=>J(a.file),title:"Open in Project Explorer (new tab)",className:"group flex items-center gap-1 max-w-full font-mono text-sm text-gray-300 hover:text-brand-300 transition-colors",children:[e.jsx("span",{className:"truncate group-hover:underline decoration-dotted underline-offset-2",children:a.file}),e.jsx(H,{size:11,className:"text-brand-400 opacity-0 group-hover:opacity-100 transition-opacity shrink-0"})]})}),e.jsx("td",{className:"py-1.5 text-right tabular-nums text-gray-400",children:a.methods}),e.jsx("td",{className:"py-1.5 text-right tabular-nums text-gray-400",children:a.avgComplexity}),e.jsx("td",{className:"py-1.5 text-right tabular-nums text-gray-400",children:a.unused}),e.jsx("td",{className:"py-1.5 text-right tabular-nums",children:e.jsxs("span",{className:p(a.grade),children:[a.score," · ",a.grade]})})]},a.file))})]})})]})}function X({label:t,value:r,tone:n}){const l=n==="red"?"bg-red-500/10 border-red-500/20":n==="amber"?"bg-amber-500/10 border-amber-500/20":"bg-surface-2/50 border-white/5",i=n==="red"?"text-red-300":n==="amber"?"text-amber-300":"text-gray-100";return e.jsxs("div",{className:`flex items-center gap-1.5 px-2.5 py-1 rounded-lg border ${l}`,children:[e.jsx("span",{className:`text-sm font-bold tabular-nums ${i}`,children:r}),e.jsx("span",{className:"text-xs text-gray-500",children:t})]})}function G({title:t,hint:r,children:n}){return e.jsxs("div",{className:"rounded-xl border border-white/5 bg-surface-1 p-4",children:[e.jsxs("div",{className:"mb-3",children:[e.jsx("div",{className:"text-base font-semibold text-gray-200",children:t}),r&&e.jsx("div",{className:"text-xs text-gray-500 mt-0.5",children:r})]}),e.jsx("div",{className:"max-h-[340px] overflow-y-auto overflow-x-hidden pr-1",children:n})]})}function re({children:t}){return e.jsxs("div",{className:"text-sm text-gray-500 flex items-center gap-1.5",children:[e.jsx(Ue,{size:14,className:"text-emerald-400"})," ",t]})}function Es({id:t,unused:r}){const{toast:n}=_(),[l,i]=o.useState(null),[m,b]=o.useState(null),[p,a]=o.useState(!1);if(!ce().hasRole("tester"))return e.jsx(gt,{});const y=(u,$)=>{i(u),b(null),a(!1),$().then(z=>b({label:u,text:z&&z.trim()||"(no response from the AI model — check that an AI provider is configured in Settings)"})).catch(z=>n("error",String(z))).finally(()=>i(null))},h=()=>{var u;m&&((u=navigator.clipboard)==null||u.writeText(m.text).then(()=>{a(!0),setTimeout(()=>a(!1),1500)},()=>n("error","Could not copy to clipboard")))};return e.jsxs("div",{className:"rounded-xl border border-brand-500/20 bg-brand-500/[0.04] p-3",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-sm font-semibold text-brand-200 mb-2",children:[e.jsx(ne,{size:14,className:"text-brand-400"})," AI assists"]}),e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[e.jsx(he,{onClick:()=>y("Explanation",()=>as(t).then(u=>u.explanation)),busy:l==="Explanation",children:"Explain"}),e.jsx(he,{onClick:()=>y("Doc comment",()=>rs(t).then(u=>u.doc)),busy:l==="Doc comment",children:"Document"}),r&&e.jsx(he,{onClick:()=>y("Safe to delete?",()=>ns(t).then(u=>`${u.verdict}${u.confidence!=null?` (${Math.round(u.confidence*100)}% confident)`:""}
|
|
3
|
+
${u.reasoning}`)),busy:l==="Safe to delete?",children:"Safe to delete?"}),r&&e.jsx(he,{onClick:()=>y("Suggested test",()=>ls(t).then(u=>u.code)),busy:l==="Suggested test",children:"Generate test"})]}),l&&e.jsxs("div",{className:"text-xs text-gray-500 mt-2 flex items-center gap-1.5",children:[e.jsx(I,{size:12,className:"animate-spin"})," ",l,"…"]}),m&&e.jsxs("div",{className:"mt-2",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-wide text-gray-500",children:m.label}),e.jsx("button",{onClick:h,title:"Copy to clipboard",className:"flex items-center gap-1 px-2 py-0.5 rounded-md text-[11px] text-gray-400 hover:text-gray-100 hover:bg-white/10 transition-colors",children:p?e.jsxs(e.Fragment,{children:[e.jsx(Ce,{size:12,className:"text-emerald-400"})," Copied"]}):e.jsxs(e.Fragment,{children:[e.jsx(ue,{size:12})," Copy"]})})]}),e.jsx("pre",{className:"text-[11px] text-gray-200 whitespace-pre-wrap break-words bg-black/30 rounded-lg p-2 max-h-60 overflow-auto",children:m.text})]}),e.jsx("p",{className:"text-[10px] text-gray-600 mt-2",children:"AI suggestions are read-only — nothing is changed in your project."})]})}function gt(){return e.jsxs("div",{className:"rounded-xl border border-white/5 bg-surface-2/40 p-3 text-xs text-gray-500 flex items-center gap-1.5",children:[e.jsx(ne,{size:13,className:"text-gray-600"})," AI assists are available to testers and admins."]})}function he({onClick:t,busy:r,children:n}){return e.jsx("button",{onClick:t,disabled:r,className:"px-2.5 py-1 rounded-lg text-xs text-brand-200 bg-brand-500/10 border border-brand-500/25 hover:bg-brand-500/20 disabled:opacity-50 transition-colors",children:n})}function Ts({c:t,RefEl:r}){const{toast:n}=_(),l=ce().hasRole("tester"),[i,m]=o.useState(!1),[b,p]=o.useState(null),a=()=>{m(!0),Yt(t.members.map(c=>c.id)).then(c=>p(c.suggestion)).catch(c=>n("error",String(c))).finally(()=>m(!1))};return e.jsxs("div",{className:"rounded-xl border border-white/5 bg-surface-2/40 p-3 mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[e.jsx("span",{className:`text-xs font-medium px-2 py-0.5 rounded-md border ${t.kind==="identical"?"bg-red-500/10 text-red-400 border-red-500/20":"bg-amber-500/10 text-amber-400 border-amber-500/20"}`,children:t.kind}),e.jsxs("span",{className:"text-sm text-gray-500",children:[t.members.length," copies · ~",t.loc," lines each"]}),l&&e.jsxs("button",{onClick:a,disabled:i,className:"ml-auto flex items-center gap-1 px-2.5 py-1 rounded-lg text-xs font-medium text-brand-200 bg-brand-500/10 border border-brand-500/25 hover:bg-brand-500/20 disabled:opacity-50 transition-colors",children:[i?e.jsx(I,{size:11,className:"animate-spin"}):e.jsx(ne,{size:11})," Suggest consolidation"]})]}),e.jsx("div",{className:"space-y-1",children:t.members.map(c=>e.jsx("div",{className:"text-sm",children:e.jsx(r,{r:c})},c.id))}),b&&e.jsx("div",{className:"mt-2 rounded-lg border border-white/5 bg-surface-2/40 p-3 max-h-96 overflow-auto text-sm text-gray-200",children:e.jsx(ht,{text:b})})]})}const lt={Given:"bg-sky-500/15 text-sky-500 border-sky-500/30",When:"bg-amber-500/15 text-amber-500 border-amber-500/40",Then:"bg-emerald-500/15 text-emerald-500 border-emerald-500/30",And:"bg-violet-500/15 text-violet-500 border-violet-500/30",But:"bg-violet-500/15 text-violet-500 border-violet-500/30",Step:"bg-gray-500/15 text-gray-500 border-gray-500/25"};function yt({kw:t}){return e.jsx("span",{className:`text-[10px] font-semibold px-1.5 py-0.5 rounded-md border ${lt[t]||lt.And}`,children:t})}function Ls({onOpenSymbol:t}){const{toast:r}=_(),[n,l]=o.useState(null),[i,m]=o.useState(!0),[b,p]=o.useState(""),[a,c]=o.useState("usage"),[y,h]=o.useState(!1),[u,$]=o.useState(!1),[z,q]=o.useState(null);o.useEffect(()=>{m(!0),Wt().then(l).catch(x=>r("error",String(x))).finally(()=>m(!1))},[]);const M=o.useMemo(()=>{let x=(n==null?void 0:n.stepDefs)||[];const N=b.trim().toLowerCase();N&&(x=x.filter(w=>w.pattern.toLowerCase().includes(N)||w.file.toLowerCase().includes(N)||w.keyword.toLowerCase().includes(N))),y&&(x=x.filter(w=>w.unused));const O={usage:(w,E)=>E.usageCount-w.usageCount||w.pattern.localeCompare(E.pattern),scenarios:(w,E)=>E.scenarioCount-w.scenarioCount||w.pattern.localeCompare(E.pattern),keyword:(w,E)=>w.keyword.localeCompare(E.keyword)||w.pattern.localeCompare(E.pattern),pattern:(w,E)=>w.pattern.localeCompare(E.pattern),file:(w,E)=>w.file.localeCompare(E.file)||w.line-E.line};return[...x].sort(O[a])},[n,b,y,a]);if(i)return e.jsxs("div",{className:"flex-1 p-6 text-sm text-gray-500 flex items-center gap-2",children:[e.jsx(I,{size:16,className:"animate-spin"})," Analyzing steps…"]});if(!n||!n.available)return e.jsx("div",{className:"flex-1 p-6 text-sm text-gray-500",children:"No Gherkin scenarios detected in this project."});const T=n.totals;return e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2.5 px-5 py-3 border-b border-white/5 bg-surface-1/50 flex-shrink-0",children:[e.jsx(X,{label:"step defs",value:T.stepDefs}),e.jsx(X,{label:"used",value:T.usedDefs}),e.jsx(X,{label:"unused",value:T.unusedDefs,tone:"amber"}),e.jsx(X,{label:"undefined",value:T.undefinedSteps,tone:"red"}),e.jsx(X,{label:"ambiguous",value:T.ambiguousSteps,tone:"amber"}),e.jsxs("span",{className:"ml-auto text-xs text-gray-500",children:[T.features," features · ",T.scenarios," scenarios · ",T.steps," steps"]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 px-5 py-3 border-b border-white/5 bg-surface-1/50 flex-shrink-0",children:[e.jsxs("div",{className:"relative flex-1 min-w-[200px] max-w-md",children:[e.jsx(oe,{size:15,className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-500"}),e.jsx("input",{value:b,onChange:x=>p(x.target.value),placeholder:"Search steps by pattern, keyword, or file…",disabled:u,className:"w-full pl-9 pr-3 py-1.5 rounded-xl text-sm bg-surface-2 border border-white/10 text-gray-200 outline-none placeholder-gray-600 focus:border-brand-500/50 transition-colors disabled:opacity-40"})]}),e.jsxs("select",{value:a,onChange:x=>c(x.target.value),disabled:u,className:"bg-surface-2 border border-white/10 rounded-xl px-3 py-1.5 text-sm text-gray-300 outline-none cursor-pointer disabled:opacity-40",children:[e.jsx("option",{value:"usage",children:"Sort: most used"}),e.jsx("option",{value:"scenarios",children:"Sort: most scenarios"}),e.jsx("option",{value:"keyword",children:"Sort: keyword"}),e.jsx("option",{value:"pattern",children:"Sort: pattern"}),e.jsx("option",{value:"file",children:"Sort: file"})]}),e.jsxs("button",{onClick:()=>h(x=>!x),disabled:u,className:`flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium rounded-xl border transition-colors disabled:opacity-40 ${y?"bg-amber-500/15 text-amber-300 border-amber-500/30":"bg-surface-2 text-gray-400 border-white/5 hover:bg-surface-3 hover:text-gray-200"}`,children:[e.jsx(me,{size:14})," Unused only"]}),e.jsxs("button",{onClick:()=>{$(x=>!x),q(null)},title:u?"Close Quality — back to step list":"Show step quality (undefined, ambiguous, duplicates, tags)",className:`flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium rounded-xl border transition-colors ${u?"bg-brand-600 text-white border-brand-500":"bg-surface-2 text-gray-400 border-white/5 hover:bg-surface-3 hover:text-gray-200"}`,children:[e.jsx(tt,{size:14})," Quality",u&&e.jsx(xe,{size:14,className:"ml-0.5 opacity-90"})]}),e.jsxs("button",{onClick:()=>Qt().catch(x=>r("error",`Export failed: ${x}`)),className:"flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium rounded-xl bg-surface-2 hover:bg-surface-3 text-gray-400 hover:text-gray-200 border border-white/5 transition-colors",children:[e.jsx(ut,{size:14})," Export CSV"]}),e.jsx("span",{className:"text-xs text-gray-600",children:u?"quality view":`${M.length} shown`})]}),e.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[e.jsx("div",{className:"flex-1 overflow-auto bg-surface-1",children:u?e.jsxs("div",{className:"p-5 space-y-5",children:[e.jsx(G,{title:"Undefined steps",hint:"Gherkin steps with no matching step definition — these fail at runtime ('step undefined').",children:n.undefinedSteps.length===0?e.jsx(re,{children:"Every Gherkin step has a definition."}):n.undefinedSteps.map((x,N)=>e.jsx(Ms,{u:x},N))}),e.jsx(G,{title:"Ambiguous steps",hint:"Gherkin steps matching more than one definition — Cucumber raises an 'ambiguous' error.",children:n.ambiguousSteps.length===0?e.jsx(re,{children:"No ambiguous steps."}):n.ambiguousSteps.map((x,N)=>e.jsxs("div",{className:"rounded-lg border border-white/5 bg-surface-2/40 p-3 mb-2",children:[e.jsxs("div",{className:"text-sm text-gray-200",children:[x.text," ",e.jsxs("span",{className:"text-gray-600 text-xs",children:["· ",x.occurrences,"×"]})]}),e.jsx("div",{className:"mt-1.5 space-y-1",children:x.defs.map(O=>e.jsxs("button",{onClick:()=>J(O.file,O.line),title:"Open in Project Explorer (new tab)",className:"block text-left text-xs font-mono text-gray-400 hover:text-brand-300 transition-colors",children:[O.pattern," ",e.jsxs("span",{className:"text-gray-600",children:["· ",O.file,":",O.line]})]},O.id))})]},N))}),e.jsx(G,{title:"Duplicate step definitions",hint:"The same step pattern is defined more than once — consolidate to avoid ambiguity.",children:n.duplicateDefs.length===0?e.jsx(re,{children:"No duplicate definitions."}):n.duplicateDefs.map((x,N)=>e.jsx(Rs,{d:x},N))}),n.tags.length>0&&e.jsx(G,{title:"Tags",hint:"Scenario tags and how many scenarios carry each.",children:e.jsx("div",{className:"flex flex-wrap gap-2",children:n.tags.map(x=>e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-lg text-xs bg-surface-2/60 border border-white/5 text-gray-300",children:[e.jsx(hs,{size:12,className:"text-brand-400"})," ",x.tag," ",e.jsx("span",{className:"text-gray-500 tabular-nums",children:x.scenarios})]},x.tag))})})]}):M.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 py-16 text-gray-500",children:[e.jsx("div",{className:"w-12 h-12 rounded-2xl bg-surface-2 border border-white/5 flex items-center justify-center",children:e.jsx(tt,{size:22})}),e.jsx("div",{className:"text-sm",children:"No step definitions match your filters."})]}):e.jsxs("table",{className:"w-full text-sm border-separate border-spacing-0",children:[e.jsx("thead",{className:"sticky top-0 bg-surface-1 z-10",children:e.jsxs("tr",{className:"text-[11px] uppercase tracking-wide text-gray-500",children:[e.jsx("th",{className:"text-left font-semibold px-5 py-2.5 border-b border-white/5",children:"Step"}),e.jsx("th",{className:"text-left font-semibold px-3 py-2.5 border-b border-white/5",children:"File"}),e.jsx("th",{className:"text-right font-semibold px-3 py-2.5 border-b border-white/5",children:"Scenarios"}),e.jsx("th",{className:"text-right font-semibold px-3 py-2.5 border-b border-white/5",children:"Uses"}),e.jsx("th",{className:"text-left font-semibold px-3 py-2.5 border-b border-white/5",children:"Status"})]})}),e.jsx("tbody",{children:M.map(x=>e.jsxs("tr",{onClick:()=>q(x),className:`cursor-pointer transition-colors ${(z==null?void 0:z.id)===x.id?"bg-brand-500/10":"hover:bg-white/[0.03]"}`,children:[e.jsxs("td",{className:"px-5 py-2.5 border-b border-white/5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(yt,{kw:x.keyword}),e.jsx("span",{className:"font-mono text-gray-200",children:x.pattern})]}),x.reaches.length>0&&e.jsxs("div",{className:"text-[11px] text-gray-600 mt-0.5 truncate",children:["→ ",x.reaches.map(N=>N.name).join(", ")]})]}),e.jsxs("td",{className:"px-3 py-2.5 border-b border-white/5 text-gray-500 text-xs font-mono truncate max-w-[220px]",title:`${x.file}:${x.line}`,children:[x.file,":",x.line]}),e.jsx("td",{className:"px-3 py-2.5 border-b border-white/5 text-right tabular-nums text-gray-300",children:x.scenarioCount}),e.jsx("td",{className:"px-3 py-2.5 border-b border-white/5 text-right tabular-nums text-gray-500",children:x.usageCount}),e.jsx("td",{className:"px-3 py-2.5 border-b border-white/5",children:x.unused?e.jsx("span",{className:"text-[10px] font-medium px-2 py-0.5 rounded-md bg-amber-500/10 text-amber-400 border border-amber-500/20",children:"Unused"}):e.jsx("span",{className:"text-[10px] font-medium px-2 py-0.5 rounded-md bg-emerald-500/10 text-emerald-400 border border-emerald-500/20",children:"Used"})})]},x.id))})]})}),!u&&z&&e.jsx(As,{step:z,onClose:()=>q(null),onOpenSymbol:t})]})]})}function Ms({u:t}){const{toast:r}=_(),n=ce().hasRole("tester"),[l,i]=o.useState(!1),[m,b]=o.useState(null),p=()=>{i(!0),b(null),Jt(t.text).then(a=>b(a.code&&a.code.trim()||"(no response — check that an AI provider is configured in Settings)")).catch(a=>r("error",String(a))).finally(()=>i(!1))};return e.jsxs("div",{className:"rounded-lg border border-red-500/15 bg-red-500/[0.04] p-3 mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(me,{size:13,className:"text-red-400 shrink-0"}),e.jsx("span",{className:"text-sm text-gray-200",children:t.text}),e.jsxs("span",{className:"text-gray-600 text-xs",children:["· ",t.occurrences,"×"]}),n&&e.jsxs("button",{onClick:p,disabled:l,className:"ml-auto flex items-center gap-1 px-2.5 py-1 rounded-lg text-[11px] font-medium text-brand-200 bg-brand-500/10 border border-brand-500/25 hover:bg-brand-500/20 disabled:opacity-50 transition-colors",children:[l?e.jsx(I,{size:11,className:"animate-spin"}):e.jsx(ne,{size:11})," Suggest definition"]})]}),e.jsx("div",{className:"mt-1.5 flex flex-wrap gap-1.5",children:t.scenarios.slice(0,6).map(a=>e.jsx("button",{onClick:()=>Se(a.file,a.name),title:"Open scenario in Test Explorer (new tab)",className:"text-[10px] px-1.5 py-0.5 rounded bg-surface-2 text-gray-400 border border-white/10 hover:text-brand-300 transition-colors",children:a.name},a.id))}),m&&e.jsx("div",{className:"mt-3",children:e.jsx(qe,{code:m,lang:"step definition"})})]})}function Rs({d:t}){const{toast:r}=_(),n=ce().hasRole("tester"),[l,i]=o.useState(!1),[m,b]=o.useState(null),p=()=>{i(!0),es(t.members.map(a=>a.id)).then(a=>b(a.suggestion)).catch(a=>r("error",String(a))).finally(()=>i(!1))};return e.jsxs("div",{className:"rounded-lg border border-white/5 bg-surface-2/40 p-3 mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[e.jsx("span",{className:"font-mono text-sm text-gray-200",children:t.pattern}),e.jsxs("span",{className:"text-xs text-gray-500",children:[t.members.length," definitions"]}),n&&e.jsxs("button",{onClick:p,disabled:l,className:"ml-auto flex items-center gap-1 px-2.5 py-1 rounded-lg text-[11px] font-medium text-brand-200 bg-brand-500/10 border border-brand-500/25 hover:bg-brand-500/20 disabled:opacity-50 transition-colors",children:[l?e.jsx(I,{size:11,className:"animate-spin"}):e.jsx(ne,{size:11})," Consolidate"]})]}),e.jsx("div",{className:"space-y-1",children:t.members.map(a=>e.jsxs("button",{onClick:()=>J(a.file,a.line),title:"Open in Project Explorer (new tab)",className:"block text-left text-xs font-mono text-gray-400 hover:text-brand-300 transition-colors",children:[a.file,":",a.line]},a.id))}),m&&e.jsx("div",{className:"mt-2 rounded-lg border border-white/5 bg-surface-2/40 p-3 max-h-96 overflow-auto text-sm text-gray-200",children:e.jsx(ht,{text:m})})]})}function As({step:t,onClose:r,onOpenSymbol:n}){const{toast:l}=_(),i=ce().hasRole("tester"),[m,b]=o.useState(!1),[p,a]=o.useState(null),[c,y]=o.useState(!1),h=()=>{b(!0),a(null),ts(t.id).then(u=>a(u.explanation&&u.explanation.trim()||"(no response — check that an AI provider is configured in Settings)")).catch(u=>l("error",String(u))).finally(()=>b(!1))};return e.jsxs("div",{className:"w-[540px] max-w-[48vw] shrink-0 border-l border-white/5 bg-surface-1 flex flex-col overflow-hidden animate-fade-in",children:[e.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-b border-white/5 bg-surface-1 flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(yt,{kw:t.keyword}),e.jsx("span",{className:"font-mono text-sm font-semibold text-gray-100 truncate",children:t.pattern})]}),e.jsx("button",{onClick:r,className:"p-1.5 rounded-lg text-gray-500 hover:text-gray-200 hover:bg-white/5 transition-colors",children:e.jsx(xe,{size:16})})]}),e.jsxs("div",{className:"flex-1 overflow-auto p-4 space-y-4",children:[e.jsxs("button",{onClick:()=>J(t.file,t.line),title:"Open in Project Explorer (new tab)",className:"group flex items-center gap-1.5 text-[13px] text-brand-400 hover:text-brand-300 font-mono transition-colors",children:[e.jsx(ge,{size:13,className:"shrink-0 text-brand-400"}),e.jsxs("span",{className:"truncate underline decoration-dotted decoration-gray-400/50 underline-offset-2",children:[t.file,":",t.line]}),e.jsx(H,{size:12,className:"shrink-0 text-brand-400"})]}),e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[e.jsxs(ie,{children:[t.scenarioCount," scenario(s)"]}),e.jsxs(ie,{children:[t.usageCount," use(s)"]}),t.unused&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-amber-500/10 text-amber-400 border border-amber-500/20",children:"Unused — no scenario uses this"})]}),i?e.jsxs("div",{className:"rounded-xl border border-brand-500/20 bg-brand-500/[0.04] p-3",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-sm font-semibold text-brand-200 mb-2",children:[e.jsx(ne,{size:14,className:"text-brand-400"})," AI assist"]}),e.jsx(he,{onClick:h,busy:m,children:"Explain this step"}),m&&e.jsxs("div",{className:"text-xs text-gray-500 mt-2 flex items-center gap-1.5",children:[e.jsx(I,{size:12,className:"animate-spin"})," Explaining…"]}),p&&e.jsxs("div",{className:"mt-2",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-wide text-gray-500",children:"Explanation"}),e.jsx("button",{onClick:()=>{var u;return(u=navigator.clipboard)==null?void 0:u.writeText(p).then(()=>{y(!0),setTimeout(()=>y(!1),1500)})},className:"flex items-center gap-1 px-2 py-0.5 rounded-md text-[11px] text-gray-500 hover:bg-gray-500/20 transition-colors",children:c?e.jsxs(e.Fragment,{children:[e.jsx(Ce,{size:12,className:"text-emerald-400"})," Copied"]}):e.jsxs(e.Fragment,{children:[e.jsx(ue,{size:12})," Copy"]})})]}),e.jsx("pre",{className:"text-[11px] text-gray-200 whitespace-pre-wrap break-words bg-black/30 rounded-lg p-2 max-h-60 overflow-auto",children:p})]})]}):e.jsx(gt,{}),t.scenarios.length>0&&e.jsx(ve,{title:"Used by scenarios",icon:e.jsx(Be,{size:13,className:"text-emerald-400"}),items:t.scenarios,listClass:"space-y-1.5",getText:u=>`${u.name} ${u.feature} ${(u.tags||[]).join(" ")}`,placeholder:"Filter scenarios…",render:u=>e.jsxs("button",{onClick:()=>Se(u.file,u.name),title:"Open in Test Explorer (new tab)",className:"group w-full text-left rounded-lg border border-white/5 bg-surface-2/40 px-3 py-2.5 hover:bg-surface-2/70 transition-colors",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("div",{className:"text-sm text-gray-200 leading-snug flex-1",children:u.name}),e.jsx(H,{size:12,className:"shrink-0 mt-0.5 text-gray-600 opacity-0 group-hover:opacity-100 transition-opacity"})]}),e.jsxs("div",{className:"flex items-center flex-wrap gap-1.5 mt-1",children:[e.jsx("span",{className:"text-xs text-gray-500 truncate",children:u.feature||u.file}),(u.tags||[]).slice(0,4).map($=>e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-brand-500/10 text-brand-300 border border-brand-500/20",children:$},$))]})]},u.id)}),t.reaches.length>0&&e.jsx(ke,{title:"Reaches methods",count:t.reaches.length,icon:e.jsx(be,{size:13,className:"text-brand-400"}),children:e.jsx("div",{className:"space-y-1.5",children:t.reaches.map(u=>e.jsxs("button",{onClick:()=>n(u.id),title:"Open in Code Map · Inventory",className:"group w-full flex items-center gap-2 rounded-lg border border-white/5 bg-surface-2/40 px-3 py-2 hover:bg-surface-2/70 transition-colors text-left",children:[e.jsxs("span",{className:"font-mono text-sm text-gray-200 truncate",children:[u.className&&e.jsxs("span",{className:"text-gray-500",children:[u.className,"."]}),u.name]}),e.jsxs("span",{className:"ml-auto flex items-center gap-1.5 min-w-0",children:[e.jsx("span",{className:"text-xs text-gray-500 font-mono truncate max-w-[180px]",title:`${u.file}:${u.startLine}`,children:u.file}),e.jsx(_e,{size:12,className:"shrink-0 text-gray-600 opacity-0 group-hover:opacity-100 transition-opacity"})]})]},u.id))})}),e.jsx(ke,{title:"Step definition",icon:e.jsx(pt,{size:13,className:"text-brand-400"}),children:e.jsx(qe,{code:t.source||"(source unavailable)",lang:t.language})})]})]})}function Ds(){const[t,r]=o.useState(()=>typeof document<"u"&&document.documentElement.classList.contains("light"));return o.useEffect(()=>{const n=document.documentElement,l=new MutationObserver(()=>r(n.classList.contains("light")));return l.observe(n,{attributes:!0,attributeFilter:["class"]}),()=>l.disconnect()},[]),t}function Os(t,r){return(r?{focus:["#6d28d9","#7c3aed","#ffffff"],test:["#d1fae5","#34d399","#065f46"],caller:["#dbeafe","#60a5fa","#1e40af"],callee:["#f1f5f9","#cbd5e1","#334155"],unused:["#fef3c7","#f59e0b","#92400e"]}:{focus:["#6d28d9","#a78bfa","#ffffff"],test:["rgba(16,185,129,0.16)","rgba(16,185,129,0.55)","#6ee7b7"],caller:["rgba(59,130,246,0.16)","rgba(59,130,246,0.55)","#93c5fd"],callee:["rgba(148,163,184,0.14)","rgba(148,163,184,0.45)","#cbd5e1"],unused:["rgba(245,158,11,0.16)","rgba(245,158,11,0.55)","#fcd34d"]})[t]}function Fs(t,r){return(r?{focus:"#7c3aed",test:"#10b981",caller:"#3b82f6",callee:"#94a3b8",unused:"#f59e0b"}:{focus:"#a78bfa",test:"#34d399",caller:"#60a5fa",callee:"#94a3b8",unused:"#fbbf24"})[t]}const Ps=240,jt=4;function it(t,r){const[n,l,i]=Os(t,r);return{background:n,color:i,border:`1.5px solid ${l}`,borderRadius:10,width:Ps,padding:"8px 12px",fontSize:12,fontWeight:t==="focus"?600:500,lineHeight:"16px",textAlign:"center",whiteSpace:"normal",wordBreak:"break-word",display:"-webkit-box",WebkitLineClamp:jt,WebkitBoxOrient:"vertical",overflow:"hidden",transition:"opacity 0.15s ease",boxShadow:t==="focus"?"0 0 0 4px rgba(109,40,217,0.18)":"0 1px 2px rgba(0,0,0,0.12)"}}function Is(t){return Math.min(jt,Math.max(1,Math.ceil(t.length/30)))}const Bs=[{kind:"test",label:"Test"},{kind:"caller",label:"Caller"},{kind:"focus",label:"Focus"},{kind:"callee",label:"Callee"},{kind:"unused",label:"Unused"}];function Us({symbols:t,onOpenSymbol:r}){const{toast:n}=_(),l=Ds(),i=o.useMemo(()=>{var j;return((j=[...t.filter(S=>!S.isEntryPoint&&S.role!=="test")].sort((S,C)=>C.usedByTestCount+C.callerCount-(S.usedByTestCount+S.callerCount))[0])==null?void 0:j.id)||null},[t]),[m,b]=o.useState(null),[p,a]=o.useState(""),[c,y]=o.useState(!1),[h,u]=o.useState(null),[$,z,q]=$t([]),[M,T,x]=Et([]),[N,O]=o.useState(!1),[w,E]=o.useState(null),W=o.useRef(null);o.useEffect(()=>{!m&&i&&b(i)},[i,m]),o.useEffect(()=>{m&&(O(!0),Zt(m,2).then(f=>{const j=new Map,S=new Map;f.edges.forEach(g=>{(j.get(g.source)||j.set(g.source,[]).get(g.source)).push(g.target),(S.get(g.target)||S.set(g.target,[]).get(g.target)).push(g.source)});const C=new Map;C.set(f.focus,2),f.edges.forEach(g=>{var R;g.target===f.focus&&!C.has(g.source)&&C.set(g.source,((R=f.nodes.find(V=>V.id===g.source))==null?void 0:R.type)==="test"?0:1),g.source===f.focus&&!C.has(g.target)&&C.set(g.target,3)}),f.nodes.forEach(g=>{C.has(g.id)||C.set(g.id,g.type==="test"?0:4)});const F={};f.nodes.forEach(g=>{const R=C.get(g.id);(F[R]=F[R]||[]).push(g.id)});const P=new Map(f.nodes.map(g=>[g.id,g.label])),Z=new Map,B=22,d=16,L=18;Object.entries(F).forEach(([g,R])=>{let V=0;R.forEach(te=>{Z.set(te,{x:Number(g)*340,y:V});const se=Is(P.get(te)||"")*d+L;V+=se+B})});const K=g=>g.id===f.focus?"focus":g.type==="test"?"test":g.unused?"unused":(C.get(g.id)??4)<2?"caller":"callee",v={};f.nodes.forEach(g=>{v[g.id]=K(g)});const A=f.nodes.map(g=>({id:g.id,position:Z.get(g.id)||{x:0,y:0},data:{label:g.type==="test"?fe(g.label):g.label},sourcePosition:"right",targetPosition:"left",style:it(v[g.id],l)})),U=f.edges.map((g,R)=>{const V=v[g.source]??"callee",te=Fs(V,l);return{id:`e${R}`,source:g.source,target:g.target,type:"bezier",data:{srcKind:V},interactionWidth:0,style:{stroke:te,strokeWidth:1.5,strokeOpacity:.55},markerEnd:{type:Tt.ArrowClosed,color:te,width:16,height:16}}});u({nodes:A,edges:U,truncated:f.truncated,kinds:v})}).catch(f=>n("error",String(f))).finally(()=>O(!1)))},[m,l]);const Q=o.useMemo(()=>{const f=t.filter(C=>!C.isEntryPoint),j=p.trim().toLowerCase();return(j?f.filter(C=>C.name.toLowerCase().includes(j)||(C.className||"").toLowerCase().includes(j)).sort((C,F)=>C.name.localeCompare(F.name)):[...f].sort((C,F)=>F.usedByTestCount+F.callerCount-(C.usedByTestCount+C.callerCount))).slice(0,60)},[p,t]),ee=o.useMemo(()=>{const f=new Map;return h==null||h.edges.forEach(j=>{(f.get(j.source)||f.set(j.source,new Set).get(j.source)).add(j.target),(f.get(j.target)||f.set(j.target,new Set).get(j.target)).add(j.source)}),f},[h]);return o.useEffect(()=>{if(!h){z([]),T([]);return}E(null),z(h.nodes),T(h.edges)},[h]),o.useEffect(()=>{const f=w?ee.get(w):null;z(j=>j.map(S=>{var P;const F=!w||S.id===w||(f==null?void 0:f.has(S.id))?1:.18;return(((P=S.style)==null?void 0:P.opacity)??1)===F?S:{...S,style:{...S.style,opacity:F}}})),T(j=>j.map(S=>{var B,d;const C=!!w&&(S.source===w||S.target===w),P=!!w&&!C?.06:C?1:.55,Z=C?2.5:1.5;return!!S.animated===C&&(((B=S.style)==null?void 0:B.strokeOpacity)??.55)===P&&(((d=S.style)==null?void 0:d.strokeWidth)??1.5)===Z?S:{...S,animated:C,zIndex:C?1:0,style:{...S.style,strokeOpacity:P,strokeWidth:Z}}}))},[w,ee]),o.useEffect(()=>{if(!h)return;const f=setTimeout(()=>{var j;return(j=W.current)==null?void 0:j.fitView({padding:.25,duration:350})},80);return()=>clearTimeout(f)},[h]),e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-5 py-3 border-b border-white/5 bg-surface-1/50 flex items-center gap-2 flex-shrink-0",children:[e.jsx("span",{className:"text-xs font-medium text-gray-400",children:"Focus:"}),e.jsxs("div",{className:"relative",children:[e.jsx(oe,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-500"}),e.jsx("input",{value:p,onChange:f=>a(f.target.value),onFocus:()=>y(!0),onBlur:()=>setTimeout(()=>y(!1),150),placeholder:"click to browse, or type to filter methods…",className:"w-80 pl-9 pr-3 py-1.5 rounded-xl text-sm bg-surface-2 border border-white/10 text-gray-200 outline-none placeholder-gray-600 focus:border-brand-500/50 transition-colors"}),c&&Q.length>0&&e.jsxs("div",{className:"absolute z-20 mt-1 w-80 max-h-72 overflow-auto rounded-xl border border-white/10 bg-surface-1 shadow-xl py-1",children:[e.jsx("div",{className:"px-3 py-1 text-[10px] uppercase tracking-wide text-gray-500 border-b border-white/5 sticky top-0 bg-surface-1",children:p.trim()?`${Q.length} match${Q.length===1?"":"es"}`:"All methods · most connected first"}),Q.map(f=>e.jsxs("button",{onMouseDown:j=>j.preventDefault(),onClick:()=>{b(f.id),a(""),y(!1)},className:`block w-full text-left px-3 py-1.5 text-xs hover:bg-white/5 transition-colors ${f.id===m?"bg-brand-500/10":""}`,children:[e.jsxs("span",{className:"font-mono text-gray-200",children:[f.className?`${f.className}.`:"",f.name]}),e.jsxs("span",{className:"text-gray-600",children:[" · ",f.file]})]},f.id))]})]}),e.jsxs("span",{className:"hidden lg:flex items-center gap-1.5 text-[11px] text-gray-500",children:[e.jsx("span",{className:"font-medium text-gray-400",children:"tests"}),e.jsx("span",{className:"text-gray-600",children:"→"}),e.jsx("span",{className:"font-medium text-gray-400",children:"callers"}),e.jsx("span",{className:"text-gray-600",children:"→"}),e.jsx("span",{className:"font-medium text-brand-400",children:"focus"}),e.jsx("span",{className:"text-gray-600",children:"→"}),e.jsx("span",{className:"font-medium text-gray-400",children:"callees"}),e.jsx("span",{className:"text-gray-600 ml-1",children:"· hover to trace · click to re-center · double-click to inspect"})]}),(h==null?void 0:h.truncated)&&e.jsxs("span",{className:"ml-auto flex items-center gap-1 text-[11px] text-amber-400",children:[e.jsx(me,{size:12})," graph truncated (large neighborhood)"]})]}),e.jsxs("div",{className:"flex-1 relative bg-surface-0",children:[N&&e.jsxs("div",{className:"absolute inset-0 z-10 flex items-center justify-center text-sm text-gray-500 bg-surface-0/60 backdrop-blur-sm",children:[e.jsx(I,{size:16,className:"animate-spin mr-2"})," Building graph…"]}),m?h&&e.jsxs(Lt,{nodes:$,edges:M,onNodesChange:q,onEdgesChange:x,onInit:f=>{W.current=f},fitView:!0,minZoom:.2,fitViewOptions:{padding:.25},nodesConnectable:!1,nodesDraggable:!0,onNodeClick:(f,j)=>{(h==null?void 0:h.kinds[j.id])!=="test"&&b(j.id)},onNodeDoubleClick:(f,j)=>{(h==null?void 0:h.kinds[j.id])!=="test"&&r(j.id)},onNodeMouseEnter:(f,j)=>E(j.id),onNodeMouseLeave:()=>E(null),proOptions:{hideAttribution:!0},children:[e.jsx(Mt,{color:l?"#cbd5e1":"#2c2d36",gap:22,size:1}),e.jsx(Rt,{showInteractive:!1,className:"cm-graph-controls"}),e.jsx(At,{position:"top-right",children:e.jsxs("div",{className:"flex flex-col gap-1.5 rounded-xl border border-white/10 bg-surface-1/95 backdrop-blur px-3 py-2.5 shadow-lg",children:[e.jsx("div",{className:"text-[10px] uppercase tracking-wide font-semibold text-gray-500 mb-0.5",children:"Legend"}),Bs.map(f=>{const j=it(f.kind,l);return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-3.5 h-3.5 rounded-md shrink-0",style:{background:j.background,border:j.border}}),e.jsx("span",{className:"text-[11px] text-gray-400",children:f.label})]},f.kind)})]})})]}):e.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-3 text-gray-500",children:[e.jsx("div",{className:"w-12 h-12 rounded-2xl bg-surface-2 border border-white/5 flex items-center justify-center",children:e.jsx(_e,{size:22})}),e.jsx("div",{className:"text-sm",children:"Search for a method above to view its call graph."})]})]})]})}function _s({files:t}){const r=o.useMemo(()=>{const l=new Map;for(const i of t){const m=i.file.replace(/\\/g,"/").split("/")[0]||"(root)",b=l.get(m)||{files:0,methods:0,unused:0,dup:0,cxSum:0,scoreSum:0};b.files+=1,b.methods+=i.methods,b.unused+=i.unused,b.dup+=i.duplicated,b.cxSum+=i.avgComplexity*i.methods,b.scoreSum+=i.score,l.set(m,b)}return[...l.entries()].map(([i,m])=>({name:i,files:m.files,methods:m.methods,unused:m.unused,dup:m.dup,avgCx:m.methods?Math.round(m.cxSum/m.methods*10)/10:0,score:m.files?Math.round(m.scoreSum/m.files):0})).sort((i,m)=>i.score-m.score)},[t]);if(r.length===0)return null;const n=l=>l>=80?"text-emerald-400":l>=70?"text-amber-400":l>=60?"text-orange-400":"text-red-400";return e.jsx(G,{title:"Module overview",hint:"Aggregated by top-level folder. Lowest health first.",children:e.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-3 gap-2",children:r.map(l=>e.jsxs("div",{className:"rounded-xl border border-white/5 bg-surface-2/40 p-3 hover:bg-surface-2/60 transition-colors",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"font-mono text-base text-gray-200 truncate",title:l.name,children:[l.name,"/"]}),e.jsx("span",{className:`text-base font-semibold tabular-nums ${n(l.score)}`,children:l.score})]}),e.jsxs("div",{className:"text-xs text-gray-500 mt-1.5 flex flex-wrap gap-x-3 gap-y-0.5",children:[e.jsxs("span",{children:[l.files," files"]}),e.jsxs("span",{children:[l.methods," methods"]}),e.jsxs("span",{children:["avg cx ",l.avgCx]}),l.unused>0&&e.jsxs("span",{className:"text-amber-400",children:[l.unused," unused"]}),l.dup>0&&e.jsxs("span",{className:"text-amber-400",children:[l.dup," dup"]})]})]},l.name))})})}export{Js as CodeMapPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as u,j as e}from"./vendor-react-CTbHBddL.js";import{o as h}from"./vendor-icons-B0wLOBoh.js";function v({open:a,title:i,description:n,confirmLabel:l="Delete",cancelLabel:o="Cancel",onConfirm:c,onCancel:r,variant:d="danger",icon:x,size:t="md",children:m,confirmDisabled:b=!1}){if(!a)return null;const g=t==="xl"?"w-[760px]":t==="lg"?"w-[640px]":"w-[480px]",s=d==="primary"?{iconBg:"bg-brand-500/15",iconColor:"text-brand-400",confirmBg:"bg-brand-600 hover:bg-brand-500"}:{iconBg:"bg-red-500/15",iconColor:"text-red-400",confirmBg:"bg-red-600 hover:bg-red-500"},f=x??h;return u.createPortal(e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[e.jsx("div",{className:"absolute inset-0 bg-black/60",onClick:r}),e.jsxs("div",{className:`relative bg-surface-1 rounded-xl border border-white/10 p-6 ${g} max-w-[90vw] animate-fade-in`,children:[e.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[e.jsx("div",{className:`w-10 h-10 rounded-full ${s.iconBg} flex items-center justify-center flex-shrink-0`,children:e.jsx(f,{size:20,className:s.iconColor})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-semibold text-gray-100",children:i}),e.jsx("p",{className:"text-sm text-gray-400 mt-1",children:n}),m]})]}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx("button",{onClick:r,className:"px-4 py-2 text-sm rounded-lg bg-surface-2 hover:bg-surface-3 text-gray-300",children:o}),e.jsx("button",{onClick:c,disabled:b,className:`px-4 py-2 text-sm rounded-lg ${s.confirmBg} text-white font-medium disabled:opacity-50 disabled:cursor-not-allowed`,children:l})]})]})]}),document.body)}export{v as C};
|