@testver/testver 1.4.2 → 1.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/dist/index.js +1174 -800
  2. package/package.json +1 -1
  3. package/src/ui/static/assets/AIPanel-KQFq4c0Q.js +32 -0
  4. package/src/ui/static/assets/AIRecordPanel-CAs8fXyS.js +40 -0
  5. package/src/ui/static/assets/AIStreamUI-p_sMTEDQ.js +9 -0
  6. package/src/ui/static/assets/{AITestGenPage-D3t2gPAA.js → AITestGenPage-CHaHfmu4.js} +1 -1
  7. package/src/ui/static/assets/APITestingPage-BSGJY_hd.js +19 -0
  8. package/src/ui/static/assets/{AboutPage-CjEqKB-q.js → AboutPage-CDa24SCJ.js} +1 -1
  9. package/src/ui/static/assets/{AdvancedPage-4kAcpE8Y.js → AdvancedPage-BqXP0FLg.js} +1 -1
  10. package/src/ui/static/assets/{AnalyticsPage-64mYNK2v.js → AnalyticsPage-Lm8noJqC.js} +1 -1
  11. package/src/ui/static/assets/{AuditLogPage-BQjOzQje.js → AuditLogPage-BvldSIik.js} +1 -1
  12. package/src/ui/static/assets/ChangesSummary-Cu0_4Ucf.js +3 -0
  13. package/src/ui/static/assets/{CodeMapPage-B1ezmnlE.js → CodeMapPage-uEjuo3fk.js} +3 -3
  14. package/src/ui/static/assets/{ConfirmDialog-t7mpeeSN.js → ConfirmDialog-DtotgVmI.js} +1 -1
  15. package/src/ui/static/assets/{CoveragePage-YMmCbiBk.js → CoveragePage-jNkQJA1P.js} +1 -1
  16. package/src/ui/static/assets/{CronBuilder-Nk-K-_8I.js → CronBuilder-D2fERHt9.js} +1 -1
  17. package/src/ui/static/assets/{Dashboard-BDVxO2V4.js → Dashboard-BaIj_IdQ.js} +1 -1
  18. package/src/ui/static/assets/{DefectsPage-l8yGeCyR.js → DefectsPage-DH0njYFG.js} +3 -3
  19. package/src/ui/static/assets/{EmptyState-D1T3JWUr.js → EmptyState-utxlJ0fu.js} +1 -1
  20. package/src/ui/static/assets/{ExportButton-Dt5RhL-h.js → ExportButton-ouKqn9CU.js} +1 -1
  21. package/src/ui/static/assets/{FileViewer-CrKgh_cB.js → FileViewer-mU3JloJ6.js} +1 -1
  22. package/src/ui/static/assets/{GitPage-_4nCEzkJ.js → GitPage-TrX-RqNC.js} +5 -5
  23. package/src/ui/static/assets/{ImportExportPage-BcR7IQi9.js → ImportExportPage-CIhK_raX.js} +1 -1
  24. package/src/ui/static/assets/{JiraPushDialog-C2sP4_4h.js → JiraPushDialog-DgEZS-0u.js} +1 -1
  25. package/src/ui/static/assets/{KpiTile-inmeEsy3.js → KpiTile-BHLE3HVj.js} +1 -1
  26. package/src/ui/static/assets/{LiveExecutionView-D5BRe9jq.js → LiveExecutionView-CaIf7Jux.js} +1 -1
  27. package/src/ui/static/assets/{ManagePage-B8iG6Q0B.js → ManagePage-SvRQ6L19.js} +1 -1
  28. package/src/ui/static/assets/{MediaModal-C5n6sHYi.js → MediaModal-DNM45Uz2.js} +1 -1
  29. package/src/ui/static/assets/{MobileRunPicker-0h-N2c6d.js → MobileRunPicker-DFKm6_nU.js} +1 -1
  30. package/src/ui/static/assets/{MobileRunTarget-Bo_xekig.js → MobileRunTarget-DHDoDZ_F.js} +3 -3
  31. package/src/ui/static/assets/{ModuleExplorer-VGcmK167.js → ModuleExplorer-rni7JbsL.js} +1 -1
  32. package/src/ui/static/assets/{OutputPage-B_1nPPxE.js → OutputPage-Cn2WCpJ6.js} +1 -1
  33. package/src/ui/static/assets/{PipelinesPanel-PmmPu8pj.js → PipelinesPanel-D6zWcLtD.js} +1 -1
  34. package/src/ui/static/assets/{ProfilePage-y7tJNNFd.js → ProfilePage-BKNdkSnx.js} +1 -1
  35. package/src/ui/static/assets/{ProjectExplorer-DbfGhRq0.js → ProjectExplorer-5e7J8t-o.js} +1 -1
  36. package/src/ui/static/assets/{RemoteFileStrip-WuRKtx_h.js → RemoteFileStrip-C1S2aclP.js} +1 -1
  37. package/src/ui/static/assets/{ReportCard-G52Q6-2i.js → ReportCard-D4EElEe9.js} +2 -2
  38. package/src/ui/static/assets/{ReportFullView-Bt8UFP2J.js → ReportFullView-2w2ysKRg.js} +1 -1
  39. package/src/ui/static/assets/{ReportsPage-DMtDi73Q.js → ReportsPage-9Fx-IEwV.js} +2 -2
  40. package/src/ui/static/assets/{ResultsPage-BI9jpK2N.js → ResultsPage-DPkfGh-K.js} +1 -1
  41. package/src/ui/static/assets/{RunState-ifC4zi6M.js → RunState-CRuS_bC2.js} +1 -1
  42. package/src/ui/static/assets/{RunTargets-C7vpCbck.js → RunTargets-CPKBrefj.js} +1 -1
  43. package/src/ui/static/assets/{ScriptMappingPage-7vHuvhQw.js → ScriptMappingPage-C3K_uyf0.js} +1 -1
  44. package/src/ui/static/assets/{SearchableDevicePicker-BYxYJNWl.js → SearchableDevicePicker-DubIldKj.js} +1 -1
  45. package/src/ui/static/assets/{SettingsPage-DSISg7r7.js → SettingsPage-BuZrrlW2.js} +1 -1
  46. package/src/ui/static/assets/{SharedReportView-BOqKGJmR.js → SharedReportView-ig5hECRk.js} +1 -1
  47. package/src/ui/static/assets/{SourcesPage-CgqtYGBi.js → SourcesPage-BPkqRqkC.js} +1 -1
  48. package/src/ui/static/assets/{TestExplorerPage-gYLhCD4d.js → TestExplorerPage-C_jl93GR.js} +3 -3
  49. package/src/ui/static/assets/{TestManagementPage-wqYTKP7W.js → TestManagementPage-DJiWpCne.js} +2 -2
  50. package/src/ui/static/assets/{TestPlansPage-DOKX9p6z.js → TestPlansPage-G1lvK1C0.js} +3 -3
  51. package/src/ui/static/assets/{TestverCreditsDetail-cSW0SpNx.js → TestverCreditsDetail-BKpt4oLW.js} +1 -1
  52. package/src/ui/static/assets/{TestverCreditsRing-DpMzl3h7.js → TestverCreditsRing-CEBSy3w3.js} +1 -1
  53. package/src/ui/static/assets/{UncommittedDiffViewer-BxS0zi-p.js → UncommittedDiffViewer-FKvUZcRi.js} +2 -2
  54. package/src/ui/static/assets/{UserManagementPage-B5d0uDU_.js → UserManagementPage-gDGhaHE4.js} +3 -3
  55. package/src/ui/static/assets/{WorkflowsPage-Bk0DFnFS.js → WorkflowsPage-BACdnU-1.js} +1 -1
  56. package/src/ui/static/assets/{hiddenLlmProviders-CdhhNa5G.js → hiddenLlmProviders-DzwaR-b9.js} +1 -1
  57. package/src/ui/static/assets/index-D6sQYc_0.js +47 -0
  58. package/src/ui/static/assets/{index-DpQhqcHv.js → index-DLmlY2Ol.js} +1 -1
  59. package/src/ui/static/assets/index-aInN0yoR.css +1 -0
  60. package/src/ui/static/assets/{reportMeta-AKcU_qwq.js → reportMeta-3kxT7BIT.js} +1 -1
  61. package/src/ui/static/assets/{useChartTheme-BFz2QcND.js → useChartTheme-CTIe6M63.js} +1 -1
  62. package/src/ui/static/assets/{useDebouncedValue-BsHptIvX.js → useDebouncedValue-C9odz7b2.js} +1 -1
  63. package/src/ui/static/assets/{useFeatureFlags-DNkIctil.js → useFeatureFlags-DrhvBp0C.js} +1 -1
  64. package/src/ui/static/assets/{useJiraConnector-D5ysBBvz.js → useJiraConnector-Dwj69Rfh.js} +1 -1
  65. package/src/ui/static/assets/useOwnership-C1CmzcvJ.js +1 -0
  66. package/src/ui/static/assets/useSuites-V0AxZYex.js +1 -0
  67. package/src/ui/static/assets/{useTabParam-ChbOedP1.js → useTabParam-CyYAP90W.js} +1 -1
  68. package/src/ui/static/assets/{useTestExplorer-DT8frjCK.js → useTestExplorer-CUqC18DV.js} +1 -1
  69. package/src/ui/static/assets/{useTestLifecycle-OcwQaB1s.js → useTestLifecycle-C2S_vaX2.js} +1 -1
  70. package/src/ui/static/assets/{useTestManagement-Xm4Bcx3u.js → useTestManagement-DW6AW2mt.js} +2 -2
  71. package/src/ui/static/assets/{useTestResults-D5EwGIX9.js → useTestResults-yjH1aUy-.js} +1 -1
  72. package/src/ui/static/assets/{vendor-charts-DWFQlmCz.js → vendor-charts-By5uZ93z.js} +1 -1
  73. package/src/ui/static/assets/{vendor-flow-YGpC9U9I.js → vendor-flow-B61ZV-pm.js} +1 -1
  74. package/src/ui/static/assets/{vendor-icons-BKPiFyYV.js → vendor-icons-D_Dmmj8d.js} +277 -282
  75. package/src/ui/static/assets/vendor-query-DkZSMtfn.js +1 -0
  76. package/src/ui/static/assets/{vendor-quill-W-RoQfb6.js → vendor-quill-xJF2Jvjc.js} +1 -1
  77. package/src/ui/static/assets/{vendor-react-CTbHBddL.js → vendor-react-DOVfxdUy.js} +1 -1
  78. package/src/ui/static/index.html +5 -5
  79. package/src/ui/static/assets/AIPanel-B_R-CbrF.js +0 -32
  80. package/src/ui/static/assets/AIRecordPanel-BRQWIU5h.js +0 -40
  81. package/src/ui/static/assets/AIStreamUI-C3D989_6.js +0 -9
  82. package/src/ui/static/assets/APITestingPage-Cmwkiiys.js +0 -19
  83. package/src/ui/static/assets/ChangesSummary-CY_Vb27i.js +0 -2
  84. package/src/ui/static/assets/DiffViewer-BIU09a_i.js +0 -2
  85. package/src/ui/static/assets/index-BYVxKLrT.js +0 -47
  86. package/src/ui/static/assets/index-C2KJt7SI.css +0 -1
  87. package/src/ui/static/assets/useOwnership-U0AfKBRo.js +0 -1
  88. package/src/ui/static/assets/useSuites-DyfN9HVv.js +0 -1
  89. package/src/ui/static/assets/vendor-query-BrzmPFT3.js +0 -1
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-BYVxKLrT.js","assets/vendor-react-CTbHBddL.js","assets/vendor-query-BrzmPFT3.js","assets/vendor-icons-BKPiFyYV.js","assets/index-C2KJt7SI.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-BYVxKLrT.js";import{u as ss}from"./useTabParam-ChbOedP1.js";import{N as ut,a as st,A as rs,b7 as ns,bO as as,X as je,e as is,I as os,o as ls,ap as jt,K as kt,a2 as rt,ba as Fe,aa as ot,bP as cs,q as ds,bQ as us,bR as xs,aj as hs,al as fs,bS as ps,b9 as We,y as Be,J as lt,bT as ms,bU as gs,bV as bs,bW as ys,W as ws,w as vs,bX as js,bY as ks,aT as Ns,aU as Cs,a0 as ve,b8 as Ss,a6 as Nt,l as Rs,r as nt,aI as xt,bZ as Es,ac as Ts,ag as Ct,t as Ue,a9 as Ms,bt as $s,aJ as Ps,bw as As,S as zs,c as _s,f as Is,_ as Ds,aC as St,bx as Ls,Q as Fs,C as Ws,by as Os,b_ as Bs,b$ as Rt,ab as Et,c0 as Tt,v as Us,F as Hs,g as Xs,c1 as Vs,c2 as Mt,G as $t}from"./vendor-icons-BKPiFyYV.js";import{f as Ys}from"./formatDate-T65-Y6Mi.js";import{C as Gs}from"./ConfirmDialog-t7mpeeSN.js";import{a as Pt}from"./DiffViewer-BIU09a_i.js";import{M as Ks}from"./MediaModal-C5n6sHYi.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,D;Se.current++;const o=G.current;o&&((S=o.getContext("2d"))==null||S.clearRect(0,0,o.width,o.height));const $=ce.current;$&&((D=$.getContext("2d"))==null||D.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 D=he.current;if(!D)return;const re=Se.current;D.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(D,0,0,V.width,V.height),ee.current++)},D.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 D=F;S.fillStyle="rgba(59, 130, 246, 0.1)",S.fillRect(D.x,D.y,D.width,D.height),S.strokeStyle="rgba(59, 130, 246, 0.7)",S.lineWidth=2,S.setLineDash([]),S.strokeRect(D.x,D.y,D.width,D.height);const re=`${D.tagName}${D.id?"#"+D.id:""}${D.className?"."+D.className.split(" ")[0]:""}`;S.font="11px monospace";const V=S.measureText(re).width,oe=D.x,be=D.y>18?D.y-4:D.y+D.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 D=S.getBoundingClientRect(),re=o-D.left,V=$-D.top,oe=m.width/D.width,be=m.height/D.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 D;if(b!=="user")return;o.preventDefault(),(D=de.current)==null||D.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:D}=q(o.clientX,o.clientY);z&&r({type:"screencast-hover",x:S,y:D}),r({type:"screencast-mouse",mouseType:"mouseMoved",x:S,y:D,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||[],I=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:`${I}`},children:[e.jsx("canvas",{ref:G,className:"max-w-full max-h-full block",style:{aspectRatio:`${I}`,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:`${I}`}}),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,Ie=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=>`${De(h.tag)}${we(h,a)===De(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+Ie+le>w&&(b=Math.max(le,Math.min(w-Ie-le,x-Ie/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:Ie},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!==De(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:De(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 De(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 I=P.length>1?(P[P.length-1]-P[0])/1e3:0,B=P.length>1&&I>0?(P.length-1)/I: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 I=typeof document<"u"&&document.visibilityState==="hidden"||X.current||!j&&(k.current||window.__testver_mobile_action_in_flight===!0);I||await ne(),!g&&(N=setTimeout(P,I?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),I=Math.round(g.naturalHeight*j),B=document.createElement("canvas");B.width=P,B.height=I;const K=B.getContext("2d");return K?(K.drawImage(g,0,0,P,I),{dataUrl:B.toDataURL("image/jpeg",.55),width:P,height:I,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,I=(g.clientY-j.top)/j.height;return{deviceX:Math.round(P*N.naturalWidth),deviceY:Math.round(I*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-BYVxKLrT.js").then(o=>o.iF);return{getStoredToken:B,getClientId:K}},__vite__mapDeps([0,1,2,3,4])),j=g(),P=N(),I={"Content-Type":"application/json"};return j&&(I.Authorization=`Bearer ${j}`),P&&(I["X-Client-Id"]=P),I},[]),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}),I=window.__testver_mobile_record_paused===!0,B=T&&!I,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,I=g.clientY-N.clientY;Math.hypot(P,I)>=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 I=await q(),B=await fetch("/api/mobile/session/tap",{method:"POST",headers:I,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(I){c(`Tap failed: ${I.message}`)}finally{y(!1),k.current=!1,ne()}return}if(O||U){const I=Y.length>0?ft(Y,N.deviceX,N.deviceY):null;if(!I){c("No accessibility element at that point. Refreshing tree…"),await ee();return}O&&ce({el:I,x:g.clientX,y:g.clientY}),U&&he({el:I,x:g.clientX,y:g.clientY});return}const j=M.current,P=ae(j);k.current=!0,y(!0);try{const{getStoredToken:I,getClientId:B}=await dt(async()=>{const{getStoredToken:V,getClientId:oe}=await import("./index-BYVxKLrT.js").then(be=>be.iF);return{getStoredToken:V,getClientId:oe}},__vite__mapDeps([0,1,2,3,4])),K=I(),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})}),D=await S.json();if(!S.ok)throw new Error((D==null?void 0:D.error)||`HTTP ${S.status}`);const re=D.action;A||h(V=>[...V,re]),window.dispatchEvent(new CustomEvent("testver-mobile-action",{detail:{action:re}})),(O||U)&&ee()}catch(I){c(`Tap recording failed: ${I.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,I=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*I),width:Math.round((g.bounds.x2-g.bounds.x1)*P),height:Math.round((g.bounds.y2-g.bounds.y1)*I)}}},[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(I=>[...I,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 I=ge(Z.el),{action:B}=await Jt({text:g,locator:P[0],ranked:P,elementAttrs:Z.el.attrs,elementLabel:j,elementHierarchy:N,...I});A||h(K=>[...K,B]),window.dispatchEvent(new CustomEvent("testver-mobile-action",{detail:{action:B}}))}catch(I){c(`Annotation failed: ${I.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(Is,{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(Ds,{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 It({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 Dt({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(Dt,{path:l.filePath}),e.jsx(It,{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(Dt,{path:v.filePath,strong:!1}),e.jsx(It,{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};
@@ -1,2 +0,0 @@
1
- import{r as m,j as e}from"./vendor-react-CTbHBddL.js";import{dW as u}from"./index-BYVxKLrT.js";import{y as b,t as N,c0 as w,b$ as j,ab as y}from"./vendor-icons-BKPiFyYV.js";function g(){const[d,n]=m.useState(()=>u());return m.useEffect(()=>{const a=new MutationObserver(()=>n(u()));return a.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>a.disconnect()},[]),d}function k(d){const n=[];let a=0,x=0,i=!1;for(const s of d.split(`
2
- `)){if(!i&&(s.startsWith("--- ")||s.startsWith("+++ ")||s.startsWith("diff ")||s.startsWith("index ")||s==="---"||s==="+++"))continue;if(s.startsWith("diff --git ")){i=!1;continue}const l=s.match(/^@@\s+-(\d+)(?:,\d+)?\s+\+(\d+)(?:,\d+)?\s+@@/);if(l){i=!0,a=parseInt(l[1],10),x=parseInt(l[2],10),n.push({kind:"hunk",oldNo:null,newNo:null,text:s});continue}s.startsWith("+")?n.push({kind:"add",oldNo:null,newNo:x++,text:s.slice(1)}):s.startsWith("-")?n.push({kind:"del",oldNo:a++,newNo:null,text:s.slice(1)}):n.push({kind:"ctx",oldNo:a++,newNo:x++,text:s.startsWith(" ")?s.slice(1):s})}const r=n[n.length-1];return r&&r.kind==="ctx"&&r.text===""&&n.pop(),n}function v({diff:d,className:n=""}){const a=g()==="light",x=k(d),i=r=>r==="hunk"?a?{row:"bg-indigo-50/70",gutter:"bg-indigo-50/70 text-indigo-400",text:"text-indigo-600"}:{row:"bg-indigo-500/[0.07]",gutter:"bg-indigo-500/[0.07] text-indigo-500/70",text:"text-indigo-300/80"}:r==="add"?a?{row:"bg-emerald-50",gutter:"bg-emerald-100/70 text-emerald-600/70",text:"text-emerald-800"}:{row:"bg-emerald-500/[0.09]",gutter:"bg-emerald-500/[0.14] text-emerald-400/60",text:"text-emerald-200"}:r==="del"?a?{row:"bg-red-50",gutter:"bg-red-100/70 text-red-600/70",text:"text-red-800"}:{row:"bg-red-500/[0.09]",gutter:"bg-red-500/[0.14] text-red-400/60",text:"text-red-200"}:a?{row:"",gutter:"bg-gray-50 text-gray-400",text:"text-gray-600"}:{row:"",gutter:"bg-white/[0.02] text-gray-600",text:"text-gray-400"};return e.jsx("div",{className:`min-w-max font-mono text-[11px] leading-[1.55] ${n}`,children:x.map((r,s)=>{const l=i(r.kind);if(r.kind==="hunk")return e.jsxs("div",{className:`flex ${l.row}`,children:[e.jsx("span",{className:`sticky left-0 w-[84px] flex-shrink-0 px-2 select-none ${l.gutter}`}),e.jsx("span",{className:`px-2 whitespace-pre ${l.text}`,children:r.text})]},s);const t=r.kind==="add"?"+":r.kind==="del"?"−":" ";return e.jsxs("div",{className:`flex ${l.row}`,children:[e.jsxs("span",{className:`sticky left-0 flex-shrink-0 flex select-none ${l.gutter}`,children:[e.jsx("span",{className:"w-10 text-right pr-2 tabular-nums",children:r.oldNo??""}),e.jsx("span",{className:"w-10 text-right pr-2 tabular-nums",children:r.newNo??""}),e.jsx("span",{className:"w-4 text-center",children:t})]}),e.jsx("span",{className:`pl-2 pr-4 whitespace-pre ${l.text}`,children:r.text||" "})]},s)})})}function P({diffs:d}){const[n,a]=m.useState({}),i=g()==="light";if(d.length===0)return null;const r=t=>{a(o=>({...o,[t]:!o[t]}))},s=i?"hover:bg-gray-100/70":"hover:bg-white/[0.04]",l=i?"bg-gray-50 border border-gray-200":"bg-black/30 border border-white/5";return e.jsx("div",{className:"mt-2",children:e.jsx("div",{className:"space-y-0.5",children:d.map((t,o)=>{const f=n[o]??!1,c=t.filePath.lastIndexOf("/"),h=c>=0?t.filePath.slice(0,c+1):"",p=c>=0?t.filePath.slice(c+1):t.filePath;return e.jsxs("div",{children:[e.jsxs("button",{onClick:()=>r(o),className:`inline-flex max-w-full items-center gap-2 px-4 py-1.5 rounded-lg transition-colors text-left ${s}`,title:t.filePath,children:[f?e.jsx(b,{size:12,className:"text-gray-500 flex-shrink-0"}):e.jsx(N,{size:12,className:"text-gray-500 flex-shrink-0"}),t.diffType==="new"?e.jsx(w,{size:13,className:"text-emerald-500 flex-shrink-0"}):t.diffType==="deleted"?e.jsx(j,{size:13,className:"text-red-500 flex-shrink-0"}):e.jsx(y,{size:13,className:"text-amber-500 flex-shrink-0"}),e.jsxs("span",{className:"text-xs font-mono truncate min-w-0",children:[h&&e.jsx("span",{className:i?"text-gray-400":"text-gray-600",children:h}),e.jsx("span",{className:i?"text-gray-900 font-medium":"text-gray-100 font-medium",children:p})]}),e.jsxs("span",{className:"flex items-center gap-1.5 text-[10px] font-mono tabular-nums flex-shrink-0",children:[t.linesAdded>0&&e.jsxs("span",{className:i?"text-emerald-600":"text-emerald-400",children:["+",t.linesAdded]}),t.linesRemoved>0&&e.jsxs("span",{className:i?"text-red-600":"text-red-400",children:["−",t.linesRemoved]})]}),e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded-full border flex-shrink-0 ${t.diffType==="new"?"bg-emerald-500/10 text-emerald-500 border-emerald-500/20":t.diffType==="deleted"?"bg-red-500/10 text-red-500 border-red-500/20":"bg-amber-500/10 text-amber-500 border-amber-500/20"}`,children:t.diffType==="new"?"New":t.diffType==="deleted"?"Deleted":"Modified"})]}),f&&e.jsx("div",{className:`mx-4 mt-1 mb-1 rounded-lg max-h-[420px] overflow-auto ${l}`,children:e.jsx(v,{diff:t.diff})})]},`${t.filePath}-${t.timestamp}`)})})})}export{P as D,v as a};