@testver/testver 1.4.2 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +88 -69
- package/README.md +6 -2
- package/bin/testver.js +9 -1
- package/dist/index.js +52650 -35771
- package/package.json +179 -178
- package/src/ui/static/agents/antigravity.svg +76 -0
- package/src/ui/static/agents/codex.svg +3 -0
- package/src/ui/static/agents/gemini.svg +1 -0
- package/src/ui/static/agents/opencode.svg +4 -0
- package/src/ui/static/agents/vscode.svg +17 -0
- package/src/ui/static/assets/AIPanel-RWO8Cd9w.js +32 -0
- package/src/ui/static/assets/AIRecordPanel-DnreS585.js +40 -0
- package/src/ui/static/assets/AIStreamUI-C1gHJtlF.js +9 -0
- package/src/ui/static/assets/{AITestGenPage-D3t2gPAA.js → AITestGenPage-C8bWUelu.js} +5 -5
- package/src/ui/static/assets/APITestingPage-DwL67hqL.js +19 -0
- package/src/ui/static/assets/AboutPage-CynLB95E.js +1 -0
- package/src/ui/static/assets/AccessTokensTab-BdevOmpE.js +1 -0
- package/src/ui/static/assets/AdvancedPage-BeM7aB8b.js +3 -0
- package/src/ui/static/assets/{AnalyticsPage-64mYNK2v.js → AnalyticsPage-C5ddYfRk.js} +1 -1
- package/src/ui/static/assets/AuditLogPage-DYcUdJoj.js +1 -0
- package/src/ui/static/assets/ChangesSummary-BjNMwGIZ.js +3 -0
- package/src/ui/static/assets/{CodeMapPage-B1ezmnlE.js → CodeMapPage-BQOEtv-R.js} +3 -3
- package/src/ui/static/assets/{ConfirmDialog-t7mpeeSN.js → ConfirmDialog-D_N9188T.js} +1 -1
- package/src/ui/static/assets/{CoveragePage-YMmCbiBk.js → CoveragePage-8bDSphY1.js} +2 -2
- package/src/ui/static/assets/{CronBuilder-Nk-K-_8I.js → CronBuilder-C7_JADb7.js} +1 -1
- package/src/ui/static/assets/{Dashboard-BDVxO2V4.js → Dashboard-B22yRPyV.js} +1 -1
- package/src/ui/static/assets/{DefectsPage-l8yGeCyR.js → DefectsPage-Arv4Ac-b.js} +72 -72
- package/src/ui/static/assets/{EmptyState-D1T3JWUr.js → EmptyState-BShNSbLf.js} +1 -1
- package/src/ui/static/assets/{ExportButton-Dt5RhL-h.js → ExportButton-xrS_AnfS.js} +1 -1
- package/src/ui/static/assets/{FileViewer-CrKgh_cB.js → FileViewer-Bcr9T1jW.js} +18 -18
- package/src/ui/static/assets/{GitPage-_4nCEzkJ.js → GitPage-DXL2Sv40.js} +12 -12
- package/src/ui/static/assets/{ImportExportPage-BcR7IQi9.js → ImportExportPage-BcjzRd7T.js} +36 -36
- package/src/ui/static/assets/{JiraPushDialog-C2sP4_4h.js → JiraPushDialog-DNYU9Ce0.js} +1 -1
- package/src/ui/static/assets/{KpiTile-inmeEsy3.js → KpiTile-BKlWqjgN.js} +1 -1
- package/src/ui/static/assets/{LiveExecutionView-D5BRe9jq.js → LiveExecutionView-1LlyEDEe.js} +1 -1
- package/src/ui/static/assets/{ManagePage-B8iG6Q0B.js → ManagePage-SvRQ6L19.js} +1 -1
- package/src/ui/static/assets/{MediaModal-C5n6sHYi.js → MediaModal-Dyy_iHl9.js} +1 -1
- package/src/ui/static/assets/MobileRunPicker-Cf5rm469.js +1 -0
- package/src/ui/static/assets/MobileRunTarget-C4M4YJJh.js +6 -0
- package/src/ui/static/assets/{ModuleExplorer-VGcmK167.js → ModuleExplorer-BKVbxFZK.js} +1 -1
- package/src/ui/static/assets/{OutputPage-B_1nPPxE.js → OutputPage-Bi-28tJi.js} +1 -1
- package/src/ui/static/assets/PipelinesPanel-BtO3iSJ4.js +1 -0
- package/src/ui/static/assets/{ProfilePage-y7tJNNFd.js → ProfilePage-BgZ4VDC-.js} +1 -1
- package/src/ui/static/assets/{ProjectExplorer-DbfGhRq0.js → ProjectExplorer-BVGbmVP7.js} +1 -1
- package/src/ui/static/assets/{RemoteFileStrip-WuRKtx_h.js → RemoteFileStrip-dzPInzgb.js} +1 -1
- package/src/ui/static/assets/{ReportCard-G52Q6-2i.js → ReportCard-LOf1PXlb.js} +2 -2
- package/src/ui/static/assets/{ReportFullView-Bt8UFP2J.js → ReportFullView-Ce4OI8lf.js} +1 -1
- package/src/ui/static/assets/{ReportsPage-DMtDi73Q.js → ReportsPage-DFxCQ8cY.js} +48 -48
- package/src/ui/static/assets/{ResultsPage-BI9jpK2N.js → ResultsPage-DD-uj8gk.js} +115 -115
- package/src/ui/static/assets/{RunState-ifC4zi6M.js → RunState-DDwFB4tA.js} +1 -1
- package/src/ui/static/assets/{RunTargets-C7vpCbck.js → RunTargets-CkIpY3v3.js} +1 -1
- package/src/ui/static/assets/ScriptMappingPage-DQQoR6sR.js +1 -0
- package/src/ui/static/assets/{SearchableDevicePicker-BYxYJNWl.js → SearchableDevicePicker-CenIxD7b.js} +1 -1
- package/src/ui/static/assets/{SettingsPage-DSISg7r7.js → SettingsPage-DAV_0y0m.js} +83 -83
- package/src/ui/static/assets/{SharedReportView-BOqKGJmR.js → SharedReportView-CqSLFKT1.js} +1 -1
- package/src/ui/static/assets/{SourcesPage-CgqtYGBi.js → SourcesPage-BvqC9oKw.js} +14 -14
- package/src/ui/static/assets/TestExplorerPage-Bdnll77k.js +7 -0
- package/src/ui/static/assets/{TestManagementPage-wqYTKP7W.js → TestManagementPage-CCNE688A.js} +10 -10
- package/src/ui/static/assets/{TestPlansPage-DOKX9p6z.js → TestPlansPage-T6D25i6-.js} +5 -5
- package/src/ui/static/assets/{TestverCreditsDetail-cSW0SpNx.js → TestverCreditsDetail-BKpt4oLW.js} +1 -1
- package/src/ui/static/assets/{TestverCreditsRing-DpMzl3h7.js → TestverCreditsRing-CoDk5eAS.js} +1 -1
- package/src/ui/static/assets/TestverMcpPage-Dte0qSXp.js +34 -0
- package/src/ui/static/assets/{UncommittedDiffViewer-BxS0zi-p.js → UncommittedDiffViewer-BNroxCoo.js} +2 -2
- package/src/ui/static/assets/{UserManagementPage-B5d0uDU_.js → UserManagementPage-BU4MuDJZ.js} +10 -10
- package/src/ui/static/assets/{WorkflowsPage-Bk0DFnFS.js → WorkflowsPage-BP5k7AqE.js} +83 -83
- package/src/ui/static/assets/clipboard-BIEd7Ccc.js +1 -0
- package/src/ui/static/assets/{hiddenLlmProviders-CdhhNa5G.js → hiddenLlmProviders-BPORgy-e.js} +1 -1
- package/src/ui/static/assets/index-BlA8ntjb.js +47 -0
- package/src/ui/static/assets/index-Co4_SlGD.css +1 -0
- package/src/ui/static/assets/{index-DpQhqcHv.js → index-DLmlY2Ol.js} +1 -1
- package/src/ui/static/assets/{reportMeta-AKcU_qwq.js → reportMeta-B9ZRW6ts.js} +1 -1
- package/src/ui/static/assets/runSelected-BoPm1sz-.js +1 -0
- package/src/ui/static/assets/{useChartTheme-BFz2QcND.js → useChartTheme-CTIe6M63.js} +1 -1
- package/src/ui/static/assets/{useDebouncedValue-BsHptIvX.js → useDebouncedValue-C9odz7b2.js} +1 -1
- package/src/ui/static/assets/{useFeatureFlags-DNkIctil.js → useFeatureFlags-B4Otsv-N.js} +1 -1
- package/src/ui/static/assets/{useJiraConnector-D5ysBBvz.js → useJiraConnector--JZhbYrT.js} +1 -1
- package/src/ui/static/assets/{useOwnership-U0AfKBRo.js → useOwnership-BhPOiYzy.js} +1 -1
- package/src/ui/static/assets/useSuites-GN_K2mHc.js +1 -0
- package/src/ui/static/assets/{useTabParam-ChbOedP1.js → useTabParam-CyYAP90W.js} +1 -1
- package/src/ui/static/assets/{useTestExplorer-DT8frjCK.js → useTestExplorer-BGhkGHKy.js} +1 -1
- package/src/ui/static/assets/{useTestLifecycle-OcwQaB1s.js → useTestLifecycle-DX5ES6x8.js} +1 -1
- package/src/ui/static/assets/{useTestManagement-Xm4Bcx3u.js → useTestManagement-ommXjx0q.js} +2 -2
- package/src/ui/static/assets/useTestResults-DWjvm8gm.js +1 -0
- package/src/ui/static/assets/{vendor-charts-DWFQlmCz.js → vendor-charts-By5uZ93z.js} +1 -1
- package/src/ui/static/assets/{vendor-flow-YGpC9U9I.js → vendor-flow-B61ZV-pm.js} +1 -1
- package/src/ui/static/assets/{vendor-icons-BKPiFyYV.js → vendor-icons-Cm92aSc5.js} +1426 -1421
- package/src/ui/static/assets/vendor-query-DkZSMtfn.js +1 -0
- package/src/ui/static/assets/{vendor-quill-W-RoQfb6.js → vendor-quill-xJF2Jvjc.js} +1 -1
- package/src/ui/static/assets/{vendor-react-CTbHBddL.js → vendor-react-DOVfxdUy.js} +1 -1
- package/src/ui/static/index.html +479 -479
- package/src/ui/static/assets/AIPanel-B_R-CbrF.js +0 -32
- package/src/ui/static/assets/AIRecordPanel-BRQWIU5h.js +0 -40
- package/src/ui/static/assets/AIStreamUI-C3D989_6.js +0 -9
- package/src/ui/static/assets/APITestingPage-Cmwkiiys.js +0 -19
- package/src/ui/static/assets/AboutPage-CjEqKB-q.js +0 -1
- package/src/ui/static/assets/AdvancedPage-4kAcpE8Y.js +0 -3
- package/src/ui/static/assets/AuditLogPage-BQjOzQje.js +0 -1
- package/src/ui/static/assets/ChangesSummary-CY_Vb27i.js +0 -2
- package/src/ui/static/assets/DiffViewer-BIU09a_i.js +0 -2
- package/src/ui/static/assets/MobileRunPicker-0h-N2c6d.js +0 -1
- package/src/ui/static/assets/MobileRunTarget-Bo_xekig.js +0 -6
- package/src/ui/static/assets/PipelinesPanel-PmmPu8pj.js +0 -1
- package/src/ui/static/assets/ScriptMappingPage-7vHuvhQw.js +0 -1
- package/src/ui/static/assets/TestExplorerPage-gYLhCD4d.js +0 -7
- package/src/ui/static/assets/index-BYVxKLrT.js +0 -47
- package/src/ui/static/assets/index-C2KJt7SI.css +0 -1
- package/src/ui/static/assets/runSelected-WlgnZcSF.js +0 -1
- package/src/ui/static/assets/useSuites-DyfN9HVv.js +0 -1
- package/src/ui/static/assets/useTestResults-D5EwGIX9.js +0 -1
- package/src/ui/static/assets/vendor-query-BrzmPFT3.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as Te,r as l,j as e}from"./vendor-react-CTbHBddL.js";import{a as Re,u as te}from"./vendor-query-BrzmPFT3.js";import{a8 as Be,bE as qe,bF as He,bG as Ue,bH as ge,bI as Ge,bJ as We,bK as Ke,bL as fe}from"./index-BYVxKLrT.js";import{F as Je}from"./index-DpQhqcHv.js";import{u as Qe}from"./useChartTheme-BFz2QcND.js";import{w as Xe}from"./sandboxStorage-BrzaG3ny.js";import{c3 as M,b4 as xe,b6 as _e,b7 as ue,aj as Ve,al as Ye,c4 as Ze,ao as et,t as tt,v as st,X as be,c5 as rt,c6 as at,c7 as lt,c8 as nt,R as it,a0 as I,l as ot,aM as se,S as ye,aL as je,g as me,aI as re,bg as ct,c9 as dt,ca as xt,cb as ut,_ as mt,a5 as he}from"./vendor-icons-BKPiFyYV.js";const pe={js:"javascript",jsx:"javascript",ts:"typescript",tsx:"typescript",json:"json",xml:"xml",html:"html",htm:"html",css:"css",py:"python",java:"java",rb:"ruby",go:"go",md:"markdown",yaml:"yaml",yml:"yaml",sql:"sql",txt:"plaintext",log:"plaintext",csv:"plaintext",feature:"plaintext"};function q(r,i=14){switch(r){case"png":case"jpg":case"jpeg":case"gif":case"webp":case"svg":case"bmp":return e.jsx(ut,{size:i,className:"text-purple-400"});case"mp4":case"webm":case"ogg":return e.jsx(xt,{size:i,className:"text-pink-400"});case"html":case"htm":return e.jsx(re,{size:i,className:"text-orange-400"});case"json":return e.jsx(dt,{size:i,className:"text-yellow-400"});case"xml":return e.jsx(re,{size:i,className:"text-cyan-400"});case"pdf":return e.jsx(me,{size:i,className:"text-red-400"});case"csv":case"xlsx":case"xls":return e.jsx(ct,{size:i,className:"text-emerald-400"});case"js":case"ts":case"jsx":case"tsx":case"py":case"java":case"rb":case"go":return e.jsx(re,{size:i,className:"text-blue-400"});case"log":case"txt":case"md":return e.jsx(me,{size:i,className:"text-gray-400"});default:return e.jsx(je,{size:i,className:"text-gray-500"})}}function H(r){return r===0?"0 B":r<1024?`${r} B`:r<1024*1024?`${(r/1024).toFixed(1)} KB`:r<1024*1024*1024?`${(r/(1024*1024)).toFixed(1)} MB`:`${(r/(1024*1024*1024)).toFixed(1)} GB`}function ht(r){return new Date(r).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}function pt(r){return["png","jpg","jpeg","gif","webp","svg","bmp","mp4","webm","ogg","html","htm","json","xml","txt","log","csv","md","pdf","js","ts","jsx","tsx","py","java","rb","go","css","yaml","yml","feature"].includes(r)}function gt(r,i){if(!i)return r;const h=i.split("/");let x=r;for(const a of h){const c=x.find(o=>o.name===a&&o.type==="directory");if(!c||!c.children)return[];x=c.children}return x}function St(){const{subscribe:r}=Te(),i=Re(),{hasRole:h}=Be(),x=h("tester"),[a,c]=l.useState(null),[o,p]=l.useState(""),[b,w]=l.useState([""]),[N,F]=l.useState(0),[d,y]=l.useState(null),[n,O]=l.useState(""),[U,ve]=l.useState("name"),[G,we]=l.useState("asc"),[W,Ne]=l.useState(""),[D,ae]=l.useState("grid"),[K,ke]=l.useState(60),[le,L]=l.useState(!1),[$,J]=l.useState(null),[A,T]=l.useState(null),Q=l.useRef(!1),X=l.useRef(null),{data:_,isLoading:Ce,refetch:V}=te({queryKey:["output-folders"],queryFn:()=>qe(),staleTime:3e4}),S=(_==null?void 0:_.folders)||[];l.useEffect(()=>{!a&&S.length>0&&c(S[0].id)},[S,a]);const{data:u,isLoading:Fe,refetch:Se}=te({queryKey:["output-files",a,U,G,W],queryFn:()=>He(a,{sortBy:U,sortDir:G,filterExt:W||void 0}),enabled:!!a,staleTime:1e4}),{data:E}=te({queryKey:["output-search",n],queryFn:()=>Ue(n),enabled:n.length>=2,staleTime:5e3});l.useEffect(()=>r(t=>{if(t.type==="output-file-change"){const s=t.folderId;i.invalidateQueries({queryKey:["output-files",s]})}}),[r,i]);const g=l.useMemo(()=>u!=null&&u.files?gt(u.files,o):[],[u,o]),[j,z]=l.useState(-1);l.useEffect(()=>{z(-1)},[o,a]),l.useEffect(()=>{const t=s=>{var f,k,C,P,B;if(!g.length||((f=s.target)==null?void 0:f.tagName)==="INPUT"||((k=s.target)==null?void 0:k.tagName)==="TEXTAREA"||((C=s.target)==null?void 0:C.tagName)==="SELECT")return;const m=D==="grid"?Math.max(1,Math.floor((((B=(P=X.current)==null?void 0:P.querySelector("[data-grid]"))==null?void 0:B.clientWidth)||800)/100)):1;if(s.key==="ArrowRight")s.preventDefault(),z(v=>Math.min(v+1,g.length-1));else if(s.key==="ArrowLeft")s.preventDefault(),z(v=>Math.max(v-1,0));else if(s.key==="ArrowDown")s.preventDefault(),z(v=>Math.min(v+m,g.length-1));else if(s.key==="ArrowUp")s.preventDefault(),z(v=>Math.max(v-m,0));else if(s.key==="Enter"&&j>=0){s.preventDefault();const v=g[j];v&&ee(v)}else s.key==="Backspace"&&(s.preventDefault(),ce())};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[g,j,D,o]);const ne=l.useRef(-1);l.useEffect(()=>{if(j>=0&&j!==ne.current&&j<g.length){const t=g[j];t&&t.type==="file"&&y(t)}ne.current=j},[j]);const Y=g.filter(t=>t.type==="file").length,Z=g.filter(t=>t.type==="directory").length,R=l.useCallback(t=>{p(t),y(null);const s=b.slice(0,N+1);s.push(t),w(s),F(s.length-1)},[b,N]),ie=N>0,oe=N<b.length-1,ze=()=>{if(!ie)return;const t=N-1;F(t),p(b[t]),y(null)},Ae=()=>{if(!oe)return;const t=N+1;F(t),p(b[t]),y(null)},ce=()=>{if(!o)return;const t=o.split("/");t.pop(),R(t.join("/"))},De=()=>R("");l.useEffect(()=>{p(""),w([""]),F(0),y(null)},[a]);const Le=l.useCallback(t=>{var P;t.preventDefault(),Q.current=!0;const s=t.clientX,m=K,f=((P=X.current)==null?void 0:P.offsetWidth)||window.innerWidth,k=B=>{if(!Q.current)return;const $e=(s-B.clientX)/f*100;ke(Math.max(30,Math.min(70,m+$e)))},C=()=>{Q.current=!1,document.removeEventListener("mousemove",k),document.removeEventListener("mouseup",C)};document.addEventListener("mousemove",k),document.addEventListener("mouseup",C)},[K]),Ee=async(t,s,m,f)=>{await We({label:t,path:s,isAbsolute:m,framework:f}),V(),L(!1)},Pe=async t=>{const s=S.find(m=>m.id===t);if(s){T(s);return}},Me=async()=>{A&&(await Ke(A.id),a===A.id&&c(null),T(null),V())},Ie=async(t,s)=>{await Ge(t,s),V(),J(null)},Oe=t=>{a&&window.open(ge(a,t.path,!0),"_blank")},ee=t=>{t.type==="directory"?R(t.path):y(t)},de=l.useMemo(()=>{const t=S.find(f=>f.id===a),m=[{label:(t==null?void 0:t.label)||"Root",path:""}];if(o){const f=o.split("/");let k="";for(const C of f)k=k?`${k}/${C}`:C,m.push({label:C,path:k})}return m},[o,a,S]);return!Ce&&S.length===0&&!le?e.jsx("div",{className:"flex-1 flex items-center justify-center h-full",children:e.jsxs("div",{className:"text-center max-w-md",children:[e.jsx("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-2xl bg-gradient-to-br from-brand-500/20 to-cyan-500/20 border border-brand-500/20 mb-5",children:e.jsx(M,{size:30,className:"text-brand-400"})}),e.jsx("h2",{className:"text-xl font-semibold text-gray-200 mb-2",children:"Output Browser"}),e.jsx("p",{className:"text-sm text-gray-500 mb-6 leading-relaxed",children:"Map your test output folders to browse reports, screenshots, videos, logs, and other artifacts right here."}),x?e.jsxs("div",{className:"flex items-center justify-center gap-3",children:[e.jsxs("button",{onClick:()=>L(!0),className:"flex items-center gap-2 px-5 py-2.5 rounded-xl text-sm font-medium text-white bg-brand-600 hover:bg-brand-500 transition-colors",children:[e.jsx(xe,{size:16})," Add Folder"]}),e.jsx(yt,{onDetect:t=>{t.length>0&&L(!0)}})]}):e.jsx("p",{className:"text-sm text-gray-500",children:"A tester or admin can map output folders."})]})}):e.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[e.jsx("div",{className:"flex-shrink-0 border-b border-white/5 bg-surface-1",children:e.jsxs("div",{className:"flex items-center gap-1 px-4 pt-2 overflow-x-auto",children:[S.map(t=>e.jsxs("button",{onClick:()=>c(t.id),className:`group flex items-center gap-1.5 px-3.5 py-2.5 rounded-t-lg text-sm font-medium transition-all whitespace-nowrap ${a===t.id?"bg-surface-0 text-cyan-300 border border-white/5 border-b-transparent -mb-px":"text-gray-500 hover:text-gray-300 hover:bg-white/[0.03]"}`,children:[e.jsx(M,{size:14}),t.label,t.framework&&e.jsx("span",{className:"text-xs px-1 py-0.5 rounded bg-brand-500/10 text-brand-400",children:t.framework}),a===t.id&&x&&e.jsxs("div",{className:"flex items-center gap-0.5 ml-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsx("button",{onClick:s=>{s.stopPropagation(),J(t)},className:"p-0.5 rounded text-gray-600 hover:text-sky-400",children:e.jsx(_e,{size:10})}),e.jsx("button",{onClick:s=>{s.stopPropagation(),Pe(t.id)},className:"p-0.5 rounded text-gray-600 hover:text-red-400",children:e.jsx(ue,{size:10})})]})]},t.id)),x&&e.jsxs("button",{onClick:()=>L(!0),className:"flex items-center gap-1 px-2.5 py-2 rounded-t-lg text-sm text-gray-600 hover:text-brand-400 hover:bg-brand-500/5 transition-colors",children:[e.jsx(xe,{size:13})," Add"]})]})}),e.jsxs("div",{className:"flex-shrink-0 flex items-center gap-2 px-4 py-2 border-b border-white/5 bg-surface-1/50",children:[e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx("button",{onClick:ze,disabled:!ie,className:"p-1.5 rounded-lg text-gray-500 hover:text-gray-200 hover:bg-white/5 transition-colors disabled:opacity-30 disabled:hover:bg-transparent disabled:hover:text-gray-500",children:e.jsx(Ve,{size:16})}),e.jsx("button",{onClick:Ae,disabled:!oe,className:"p-1.5 rounded-lg text-gray-500 hover:text-gray-200 hover:bg-white/5 transition-colors disabled:opacity-30 disabled:hover:bg-transparent disabled:hover:text-gray-500",children:e.jsx(Ye,{size:16})}),e.jsx("button",{onClick:ce,disabled:!o,className:"p-1.5 rounded-lg text-gray-500 hover:text-gray-200 hover:bg-white/5 transition-colors disabled:opacity-30 disabled:hover:bg-transparent disabled:hover:text-gray-500",title:"Up one level",children:e.jsx(Ze,{size:16})}),e.jsx("button",{onClick:De,className:"p-1.5 rounded-lg text-gray-500 hover:text-gray-200 hover:bg-white/5 transition-colors",title:"Go to root",children:e.jsx(et,{size:15})})]}),e.jsx("div",{className:"flex-1 flex items-center gap-0.5 min-w-0 bg-surface-2 border border-white/5 rounded-lg px-3 py-1.5 overflow-x-auto",children:de.map((t,s)=>e.jsxs("span",{className:"flex items-center gap-0.5 flex-shrink-0",children:[s>0&&e.jsx(tt,{size:12,className:"text-gray-600"}),e.jsxs("button",{onClick:()=>R(t.path),className:`text-sm px-1 py-0.5 rounded hover:bg-white/5 transition-colors truncate max-w-[160px] ${s===de.length-1?"text-gray-200 font-medium":"text-gray-500 hover:text-gray-300"}`,children:[s===0&&e.jsx(M,{size:13,className:"inline mr-1 -mt-0.5 text-brand-400"}),t.label]})]},t.path))}),e.jsxs("div",{className:"relative w-48",children:[e.jsx(st,{size:14,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-gray-600"}),e.jsx("input",{value:n,onChange:t=>O(t.target.value),placeholder:"Search...",className:"w-full bg-surface-2 border border-white/5 rounded-lg pl-8 pr-3 py-1.5 text-sm text-gray-200 outline-none placeholder-gray-600 focus:border-brand-500/40 transition-colors"}),n&&e.jsx("button",{onClick:()=>O(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-gray-600 hover:text-gray-300",children:e.jsx(be,{size:12})})]}),e.jsxs("select",{value:U,onChange:t=>ve(t.target.value),className:"bg-surface-2 border border-white/5 rounded-lg px-2.5 py-1.5 text-sm text-gray-400 outline-none cursor-pointer",children:[e.jsx("option",{value:"name",children:"Name"}),e.jsx("option",{value:"date",children:"Date"}),e.jsx("option",{value:"size",children:"Size"}),e.jsx("option",{value:"type",children:"Type"})]}),e.jsx("button",{onClick:()=>we(t=>t==="asc"?"desc":"asc"),className:"p-1.5 rounded-lg text-gray-500 hover:text-gray-300 hover:bg-white/5 transition-colors",children:G==="asc"?e.jsx(rt,{size:15}):e.jsx(at,{size:15})}),e.jsxs("select",{value:W,onChange:t=>Ne(t.target.value),className:"bg-surface-2 border border-white/5 rounded-lg px-2.5 py-1.5 text-sm text-gray-400 outline-none cursor-pointer",children:[e.jsx("option",{value:"",children:"All"}),e.jsx("option",{value:"png,jpg,jpeg,gif,webp,svg",children:"Images"}),e.jsx("option",{value:"mp4,webm",children:"Videos"}),e.jsx("option",{value:"html,htm",children:"HTML"}),e.jsx("option",{value:"json",children:"JSON"}),e.jsx("option",{value:"txt,log",children:"Logs"}),e.jsx("option",{value:"pdf",children:"PDF"})]}),e.jsxs("div",{className:"flex items-center rounded-lg border border-white/5 overflow-hidden",children:[e.jsx("button",{onClick:()=>ae("grid"),className:`p-1.5 transition-colors ${D==="grid"?"bg-brand-500/10 text-brand-400":"text-gray-600 hover:text-gray-300"}`,children:e.jsx(lt,{size:15})}),e.jsx("button",{onClick:()=>ae("list"),className:`p-1.5 transition-colors ${D==="list"?"bg-brand-500/10 text-brand-400":"text-gray-600 hover:text-gray-300"}`,children:e.jsx(nt,{size:15})})]}),e.jsx("button",{onClick:()=>Se(),className:"p-1.5 rounded-lg text-gray-500 hover:text-cyan-400 hover:bg-cyan-500/10 transition-colors",children:e.jsx(it,{size:15})})]}),e.jsxs("div",{ref:X,className:"flex-1 flex overflow-hidden",children:[e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden ",children:[n.length>=2&&(E!=null&&E.results)?e.jsxs("div",{className:"flex-1 overflow-y-auto p-4",children:[e.jsxs("p",{className:"text-xs text-gray-500 mb-3",children:[E.results.length,' results for "',n,'"']}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 md:grid-cols-6 lg:grid-cols-8 gap-2",children:E.results.map(t=>e.jsxs("button",{onClick:()=>{c(t.folderId),y(t)},className:"flex flex-col items-center gap-1.5 p-3 rounded-xl border border-transparent hover:border-white/10 hover:bg-white/[0.02] transition-all text-center group",children:[q(t.extension||"",28),e.jsx("span",{className:"text-xs text-gray-300 truncate w-full",children:t.name}),e.jsx("span",{className:"text-[11px] text-gray-600 truncate w-full",children:t.folderLabel})]},`${t.folderId}-${t.path}`))})]}):Fe?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsx(I,{size:24,className:"text-gray-600 animate-spin"})}):u!=null&&u.exists?g.length===0?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx(se,{size:28,className:"text-gray-700 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-gray-500",children:"This folder is empty"})]})}):D==="grid"?e.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:e.jsx("div",{"data-grid":!0,className:"grid grid-cols-3 sm:grid-cols-5 md:grid-cols-7 lg:grid-cols-9 xl:grid-cols-10 gap-1",children:g.map((t,s)=>e.jsxs("button",{onClick:()=>{t.type==="file"&&z(s),ee(t)},onDoubleClick:()=>{t.type==="file"&&y(t)},className:`flex flex-col items-center gap-1 p-2.5 rounded-xl border transition-all text-center group ${j===s?"border-cyan-500/50 bg-cyan-500/10 ring-1 ring-cyan-500/30":(d==null?void 0:d.path)===t.path?"border-brand-500/40 bg-brand-500/10":"border-transparent hover:border-white/10 hover:bg-white/[0.02]"}`,children:[t.type==="directory"?e.jsx(se,{size:32,className:"text-blue-400"}):q(t.extension||"",32),e.jsx("span",{className:"text-xs text-gray-300 w-full leading-tight mt-0.5 line-clamp-2 break-all",title:t.name,children:t.name}),t.type==="file"&&t.size!==void 0&&e.jsx("span",{className:"text-[11px] text-gray-600 opacity-0 group-hover:opacity-100 transition-opacity",children:H(t.size)}),t.type==="directory"&&t.children&&e.jsxs("span",{className:"text-[11px] text-gray-600 opacity-0 group-hover:opacity-100 transition-opacity",children:[t.children.length," items"]})]},t.path))})}):e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[e.jsxs("div",{className:"sticky top-0 flex items-center gap-3 px-4 py-2 bg-surface-1 border-b border-white/5 text-xs text-gray-500 font-medium",children:[e.jsx("span",{className:"flex-1 min-w-0",children:"Name"}),e.jsx("span",{className:"w-28 text-right",children:"Date Modified"}),e.jsx("span",{className:"w-20 text-right",children:"Type"}),e.jsx("span",{className:"w-20 text-right",children:"Size"})]}),e.jsx("div",{className:"divide-y divide-white/[0.02]",children:g.map((t,s)=>e.jsxs("button",{onClick:()=>{t.type==="file"&&z(s),ee(t)},className:`w-full flex items-center gap-3 px-4 py-2 text-left transition-colors group ${j===s?"bg-cyan-500/10 border-l-2 border-l-cyan-500/50":(d==null?void 0:d.path)===t.path?"bg-brand-500/10":"hover:bg-white/[0.02]"}`,children:[e.jsxs("div",{className:"flex items-center gap-2.5 flex-1 min-w-0",children:[t.type==="directory"?e.jsx(se,{size:18,className:"text-blue-400 flex-shrink-0"}):q(t.extension||"",18),e.jsx("span",{className:"text-sm text-gray-200 truncate",children:t.name})]}),e.jsx("span",{className:"w-28 text-right text-xs text-gray-500",children:t.modified?ht(t.modified):""}),e.jsx("span",{className:"w-20 text-right text-xs text-gray-600 uppercase",children:t.type==="directory"?"Folder":t.extension||"—"}),e.jsx("span",{className:"w-20 text-right text-xs text-gray-500",children:t.type==="file"&&t.size!==void 0?H(t.size):""})]},t.path))})]}):e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx(ot,{size:24,className:"text-amber-400 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-gray-500",children:"Folder does not exist on disk"}),e.jsx("p",{className:"text-xs text-gray-600 mt-1 break-all",children:u==null?void 0:u.folderPath})]})}),e.jsx("div",{className:"flex-shrink-0 flex items-center justify-between px-4 py-1.5 border-t border-white/5 bg-surface-1 text-xs text-gray-500",children:e.jsxs("span",{children:[Z>0&&`${Z} folders`,Z>0&&Y>0&&", ",Y>0&&`${Y} files`,u?` — ${H(u.totalSize)}`:""]})})]}),d&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-1 flex-shrink-0 bg-white/[0.02] hover:bg-brand-500/30 cursor-col-resize transition-colors",onMouseDown:Le}),e.jsx("div",{style:{width:`${K}%`},className:"flex-shrink-0 flex flex-col overflow-hidden border-l border-white/5",children:e.jsx(ft,{file:d,folderId:a,onDownload:()=>Oe(d),onClose:()=>y(null)})})]})]}),(le||$)&&e.jsx(bt,{folder:$,onSave:(t,s,m,f)=>{$?Ie($.id,{label:t,path:s}):Ee(t,s,m,f)},onClose:()=>{L(!1),J(null)}}),A&&e.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50",onClick:()=>T(null),children:e.jsxs("div",{className:"bg-surface-1 border border-white/10 rounded-2xl shadow-xl w-full max-w-md p-6",onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-red-500/10 flex items-center justify-center flex-shrink-0",children:e.jsx(ue,{size:20,className:"text-red-400"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-semibold text-gray-200",children:"Delete Folder Mapping"}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"This action cannot be undone"})]})]}),e.jsx("p",{className:"text-sm text-gray-400 mb-1",children:"Are you sure you want to remove the folder mapping?"}),e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-surface-2 border border-white/5 mb-5",children:[e.jsx(M,{size:15,className:"text-brand-400 flex-shrink-0"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("span",{className:"text-sm font-medium text-gray-200 block truncate",children:A.label}),e.jsx("span",{className:"text-xs text-gray-500 block truncate font-mono",children:A.path})]})]}),e.jsx("p",{className:"text-xs text-gray-600 mb-5",children:"This will only remove the mapping from the dashboard. Your actual files on disk will not be deleted."}),e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx("button",{onClick:()=>T(null),className:"px-4 py-2 rounded-lg text-sm text-gray-400 hover:text-gray-200 hover:bg-white/5 transition-colors",children:"Cancel"}),e.jsx("button",{onClick:Me,className:"px-4 py-2 rounded-lg text-sm font-medium text-white bg-red-600 hover:bg-red-500 transition-colors",children:"Delete"})]})]})})]})}function ft({file:r,folderId:i,onDownload:h,onClose:x}){const a=r.extension||"",c=ge(i,r.path),[o,p]=l.useState(null),[b,w]=l.useState(!1),{monacoTheme:N}=Qe();return l.useEffect(()=>{["json","xml","txt","log","csv","md","js","ts","jsx","tsx","py","java","rb","go","css","yaml","yml","feature","html","htm"].includes(a)?(w(!0),p(null),fetch(c).then(d=>d.text()).then(d=>{p(d),w(!1)}).catch(()=>{p(null),w(!1)})):p(null)},[r.path,a,c]),e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between px-4 py-2.5 border-b border-white/5 bg-surface-1",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[q(a,16),e.jsx("span",{className:"text-sm font-medium text-gray-200 truncate",children:r.name}),r.size!==void 0&&e.jsx("span",{className:"text-xs text-gray-500",children:H(r.size)})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[a==="html"&&e.jsxs("button",{onClick:()=>window.open(c,"_blank"),className:"flex items-center gap-1 px-2.5 py-1 rounded-lg text-xs text-gray-500 hover:text-gray-300 hover:bg-white/5 transition-colors",children:[e.jsx(mt,{size:12})," Open"]}),e.jsxs("button",{onClick:h,className:"flex items-center gap-1 px-2.5 py-1 rounded-lg text-xs text-gray-500 hover:text-cyan-400 hover:bg-cyan-500/10 transition-colors",children:[e.jsx(he,{size:12})," Download"]}),e.jsx("button",{onClick:x,className:"p-1 rounded-lg text-gray-600 hover:text-gray-300 hover:bg-white/5 transition-colors",children:e.jsx(be,{size:14})})]})]}),e.jsxs("div",{className:"flex-1 overflow-auto bg-black/20",children:[["png","jpg","jpeg","gif","webp","svg","bmp"].includes(a)&&e.jsx("div",{className:"flex items-center justify-center h-full p-6",children:e.jsx("img",{src:c,alt:r.name,className:"max-w-full max-h-full object-contain rounded-lg shadow-lg"})}),["mp4","webm","ogg"].includes(a)&&e.jsx("div",{className:"flex items-center justify-center h-full p-6",children:e.jsx("video",{src:c,controls:!0,className:"max-w-full max-h-full rounded-lg shadow-lg"})}),a==="pdf"&&e.jsx("embed",{src:c,type:"application/pdf",className:"w-full h-full"}),["html","htm"].includes(a)&&o!==null&&e.jsx("iframe",{srcDoc:Xe(o),sandbox:"allow-scripts",className:"w-full h-full bg-white",title:r.name}),pe[a]&&o!==null&&!["html","htm"].includes(a)&&e.jsx(Je,{value:a==="json"?(()=>{try{return JSON.stringify(JSON.parse(o),null,2)}catch{return o}})():o,language:pe[a]||"plaintext",theme:N,options:{readOnly:!0,minimap:{enabled:!1},fontSize:13,lineHeight:20,scrollBeyondLastLine:!1,wordWrap:"on",renderLineHighlight:"line",padding:{top:8,bottom:8},scrollbar:{verticalScrollbarSize:8,horizontalScrollbarSize:8},lineNumbers:"on",folding:!0,bracketPairColorization:{enabled:!0},guides:{bracketPairs:!0,indentation:!0}},loading:e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx(I,{size:20,className:"text-gray-600 animate-spin"})})}),b&&e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx(I,{size:20,className:"text-gray-600 animate-spin"})}),!pt(a)&&!b&&e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"text-center",children:[e.jsx(je,{size:36,className:"text-gray-700 mx-auto mb-3"}),e.jsxs("p",{className:"text-sm text-gray-500 mb-3",children:["Preview not available for .",a," files"]}),e.jsxs("button",{onClick:h,className:"flex items-center gap-2 px-4 py-2 rounded-lg text-sm text-white bg-brand-600 hover:bg-brand-500 transition-colors mx-auto",children:[e.jsx(he,{size:14})," Download File"]})]})})]})]})}function bt({folder:r,onSave:i,onClose:h}){const[x,a]=l.useState((r==null?void 0:r.label)||""),[c,o]=l.useState((r==null?void 0:r.path)||""),[p,b]=l.useState((r==null?void 0:r.isAbsolute)||!1),[w,N]=l.useState([]),[F,d]=l.useState(!1),y=async()=>{d(!0);try{const n=await fe();N(n.detected)}catch{}d(!1)};return e.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50",onClick:h,children:e.jsxs("div",{className:"bg-surface-1 border border-white/10 rounded-2xl shadow-xl w-full max-w-lg p-6",onClick:n=>n.stopPropagation(),children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-200 mb-4",children:r?"Edit Folder Mapping":"Add Output Folder"}),!r&&e.jsxs("div",{className:"mb-4",children:[e.jsxs("button",{onClick:y,disabled:F,className:"flex items-center gap-2 px-4 py-2.5 rounded-lg text-sm font-medium text-brand-300 bg-brand-500/10 border border-brand-500/20 hover:bg-brand-500/20 transition-colors disabled:opacity-50 w-full justify-center",children:[F?e.jsx(I,{size:14,className:"animate-spin"}):e.jsx(ye,{size:14}),"Auto-Detect Output Folders"]}),w.length>0&&e.jsx("div",{className:"mt-2 space-y-1 max-h-40 overflow-y-auto",children:w.map(n=>e.jsxs("button",{onClick:()=>{a(n.label),o(n.path),b(!1)},className:`w-full flex items-center gap-2 px-3 py-2 rounded-lg text-left transition-colors ${c===n.path?"bg-brand-500/10 border border-brand-500/30":"hover:bg-white/[0.03] border border-transparent"}`,children:[e.jsx(M,{size:15,className:n.exists?"text-emerald-400":"text-gray-600"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm text-gray-200 font-medium",children:n.label}),e.jsx("div",{className:"text-xs text-gray-500 truncate",children:n.path})]}),n.framework&&e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-brand-500/10 text-brand-400",children:n.framework}),e.jsx("span",{className:`text-xs ${n.exists?"text-emerald-400":"text-gray-600"}`,children:n.exists?"exists":"not found"})]},n.path))})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm text-gray-400 mb-1 block",children:"Label"}),e.jsx("input",{value:x,onChange:n=>a(n.target.value),placeholder:"e.g., Playwright Reports",className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 outline-none focus:border-brand-500/40 placeholder-gray-600"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm text-gray-400 mb-1 block",children:"Path"}),e.jsx("input",{value:c,onChange:n=>o(n.target.value),placeholder:"e.g., playwright-report",className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 outline-none focus:border-brand-500/40 placeholder-gray-600 font-mono"})]}),e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:p,onChange:n=>b(n.target.checked),className:"w-3.5 h-3.5 rounded border-white/10 bg-surface-2 text-brand-500"}),e.jsx("span",{className:"text-sm text-gray-400",children:"Absolute path (outside project directory)"})]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 mt-5",children:[e.jsx("button",{onClick:h,className:"px-4 py-2 rounded-lg text-sm text-gray-400 hover:text-gray-200 hover:bg-white/5 transition-colors",children:"Cancel"}),e.jsx("button",{onClick:()=>{var n;return i(x,c,p,(n=w.find(O=>O.path===c))==null?void 0:n.framework)},disabled:!x.trim()||!c.trim(),className:"px-4 py-2 rounded-lg text-sm font-medium text-white bg-brand-600 hover:bg-brand-500 transition-colors disabled:opacity-30",children:r?"Save Changes":"Add Folder"})]})]})})}function yt({onDetect:r}){const[i,h]=l.useState(!1),x=async()=>{h(!0);try{const a=await fe();r(a.detected)}catch{}h(!1)};return e.jsxs("button",{onClick:x,disabled:i,className:"flex items-center gap-2 px-5 py-2.5 rounded-xl text-sm font-medium text-gray-400 bg-surface-1 border border-white/10 hover:border-brand-500/30 hover:text-gray-200 transition-colors disabled:opacity-50",children:[i?e.jsx(I,{size:16,className:"animate-spin"}):e.jsx(ye,{size:16}),"Auto-Detect"]})}export{St as OutputPage};
|
|
1
|
+
import{n as Ie,r as l,j as e}from"./vendor-react-DOVfxdUy.js";import{a as Re,u as te}from"./vendor-query-DkZSMtfn.js";import{ae as Be,bS as qe,bT as Ue,bU as He,bV as ge,bW as We,bX as Ge,bY as Xe,bZ as fe}from"./index-BlA8ntjb.js";import{F as Je}from"./index-DLmlY2Ol.js";import{u as Ke}from"./useChartTheme-CTIe6M63.js";import{w as Qe}from"./sandboxStorage-BrzaG3ny.js";import{c6 as M,b5 as xe,b7 as Ve,b8 as ue,ak as _e,am as Ye,c7 as Ze,ap as et,u as tt,w as st,X as be,c8 as rt,c9 as at,ca as lt,cb as nt,R as it,a1 as $,a as ot,aN as se,S as ye,aM as je,j as me,aJ as re,bh as ct,cc as dt,cd as xt,ce as ut,$ as mt,a6 as he}from"./vendor-icons-Cm92aSc5.js";const pe={js:"javascript",jsx:"javascript",ts:"typescript",tsx:"typescript",json:"json",xml:"xml",html:"html",htm:"html",css:"css",py:"python",java:"java",rb:"ruby",go:"go",md:"markdown",yaml:"yaml",yml:"yaml",sql:"sql",txt:"plaintext",log:"plaintext",csv:"plaintext",feature:"plaintext"};function q(r,i=14){switch(r){case"png":case"jpg":case"jpeg":case"gif":case"webp":case"svg":case"bmp":return e.jsx(ut,{size:i,className:"text-purple-400"});case"mp4":case"webm":case"ogg":return e.jsx(xt,{size:i,className:"text-pink-400"});case"html":case"htm":return e.jsx(re,{size:i,className:"text-orange-400"});case"json":return e.jsx(dt,{size:i,className:"text-yellow-400"});case"xml":return e.jsx(re,{size:i,className:"text-cyan-400"});case"pdf":return e.jsx(me,{size:i,className:"text-red-400"});case"csv":case"xlsx":case"xls":return e.jsx(ct,{size:i,className:"text-emerald-400"});case"js":case"ts":case"jsx":case"tsx":case"py":case"java":case"rb":case"go":return e.jsx(re,{size:i,className:"text-blue-400"});case"log":case"txt":case"md":return e.jsx(me,{size:i,className:"text-gray-400"});default:return e.jsx(je,{size:i,className:"text-gray-500"})}}function U(r){return r===0?"0 B":r<1024?`${r} B`:r<1024*1024?`${(r/1024).toFixed(1)} KB`:r<1024*1024*1024?`${(r/(1024*1024)).toFixed(1)} MB`:`${(r/(1024*1024*1024)).toFixed(1)} GB`}function ht(r){return new Date(r).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}function pt(r){return["png","jpg","jpeg","gif","webp","svg","bmp","mp4","webm","ogg","html","htm","json","xml","txt","log","csv","md","pdf","js","ts","jsx","tsx","py","java","rb","go","css","yaml","yml","feature"].includes(r)}function gt(r,i){if(!i)return r;const h=i.split("/");let x=r;for(const a of h){const c=x.find(o=>o.name===a&&o.type==="directory");if(!c||!c.children)return[];x=c.children}return x}function St(){const{subscribe:r}=Ie(),i=Re(),{hasRole:h}=Be(),x=h("tester"),[a,c]=l.useState(null),[o,p]=l.useState(""),[b,w]=l.useState([""]),[N,F]=l.useState(0),[d,y]=l.useState(null),[n,O]=l.useState(""),[H,ve]=l.useState("name"),[W,we]=l.useState("asc"),[G,Ne]=l.useState(""),[D,ae]=l.useState("grid"),[X,ke]=l.useState(60),[le,L]=l.useState(!1),[T,J]=l.useState(null),[A,I]=l.useState(null),K=l.useRef(!1),Q=l.useRef(null),{data:V,isLoading:Ce,refetch:_}=te({queryKey:["output-folders"],queryFn:()=>qe(),staleTime:3e4}),S=(V==null?void 0:V.folders)||[];l.useEffect(()=>{!a&&S.length>0&&c(S[0].id)},[S,a]);const{data:u,isLoading:Fe,refetch:Se}=te({queryKey:["output-files",a,H,W,G],queryFn:()=>Ue(a,{sortBy:H,sortDir:W,filterExt:G||void 0}),enabled:!!a,staleTime:1e4}),{data:E}=te({queryKey:["output-search",n],queryFn:()=>He(n),enabled:n.length>=2,staleTime:5e3});l.useEffect(()=>r(t=>{if(t.type==="output-file-change"){const s=t.folderId;i.invalidateQueries({queryKey:["output-files",s]})}}),[r,i]);const g=l.useMemo(()=>u!=null&&u.files?gt(u.files,o):[],[u,o]),[j,z]=l.useState(-1);l.useEffect(()=>{z(-1)},[o,a]),l.useEffect(()=>{const t=s=>{var f,k,C,P,B;if(!g.length||((f=s.target)==null?void 0:f.tagName)==="INPUT"||((k=s.target)==null?void 0:k.tagName)==="TEXTAREA"||((C=s.target)==null?void 0:C.tagName)==="SELECT")return;const m=D==="grid"?Math.max(1,Math.floor((((B=(P=Q.current)==null?void 0:P.querySelector("[data-grid]"))==null?void 0:B.clientWidth)||800)/100)):1;if(s.key==="ArrowRight")s.preventDefault(),z(v=>Math.min(v+1,g.length-1));else if(s.key==="ArrowLeft")s.preventDefault(),z(v=>Math.max(v-1,0));else if(s.key==="ArrowDown")s.preventDefault(),z(v=>Math.min(v+m,g.length-1));else if(s.key==="ArrowUp")s.preventDefault(),z(v=>Math.max(v-m,0));else if(s.key==="Enter"&&j>=0){s.preventDefault();const v=g[j];v&&ee(v)}else s.key==="Backspace"&&(s.preventDefault(),ce())};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[g,j,D,o]);const ne=l.useRef(-1);l.useEffect(()=>{if(j>=0&&j!==ne.current&&j<g.length){const t=g[j];t&&t.type==="file"&&y(t)}ne.current=j},[j]);const Y=g.filter(t=>t.type==="file").length,Z=g.filter(t=>t.type==="directory").length,R=l.useCallback(t=>{p(t),y(null);const s=b.slice(0,N+1);s.push(t),w(s),F(s.length-1)},[b,N]),ie=N>0,oe=N<b.length-1,ze=()=>{if(!ie)return;const t=N-1;F(t),p(b[t]),y(null)},Ae=()=>{if(!oe)return;const t=N+1;F(t),p(b[t]),y(null)},ce=()=>{if(!o)return;const t=o.split("/");t.pop(),R(t.join("/"))},De=()=>R("");l.useEffect(()=>{p(""),w([""]),F(0),y(null)},[a]);const Le=l.useCallback(t=>{var P;t.preventDefault(),K.current=!0;const s=t.clientX,m=X,f=((P=Q.current)==null?void 0:P.offsetWidth)||window.innerWidth,k=B=>{if(!K.current)return;const Te=(s-B.clientX)/f*100;ke(Math.max(30,Math.min(70,m+Te)))},C=()=>{K.current=!1,document.removeEventListener("mousemove",k),document.removeEventListener("mouseup",C)};document.addEventListener("mousemove",k),document.addEventListener("mouseup",C)},[X]),Ee=async(t,s,m,f)=>{await Ge({label:t,path:s,isAbsolute:m,framework:f}),_(),L(!1)},Pe=async t=>{const s=S.find(m=>m.id===t);if(s){I(s);return}},Me=async()=>{A&&(await Xe(A.id),a===A.id&&c(null),I(null),_())},$e=async(t,s)=>{await We(t,s),_(),J(null)},Oe=t=>{a&&window.open(ge(a,t.path,!0),"_blank")},ee=t=>{t.type==="directory"?R(t.path):y(t)},de=l.useMemo(()=>{const t=S.find(f=>f.id===a),m=[{label:(t==null?void 0:t.label)||"Root",path:""}];if(o){const f=o.split("/");let k="";for(const C of f)k=k?`${k}/${C}`:C,m.push({label:C,path:k})}return m},[o,a,S]);return!Ce&&S.length===0&&!le?e.jsx("div",{className:"flex-1 flex items-center justify-center h-full",children:e.jsxs("div",{className:"text-center max-w-md",children:[e.jsx("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-2xl bg-gradient-to-br from-brand-500/20 to-cyan-500/20 border border-brand-500/20 mb-5",children:e.jsx(M,{size:30,className:"text-brand-400"})}),e.jsx("h2",{className:"text-xl font-semibold text-gray-200 mb-2",children:"Output Browser"}),e.jsx("p",{className:"text-sm text-gray-500 mb-6 leading-relaxed",children:"Map your test output folders to browse reports, screenshots, videos, logs, and other artifacts right here."}),x?e.jsxs("div",{className:"flex items-center justify-center gap-3",children:[e.jsxs("button",{onClick:()=>L(!0),className:"flex items-center gap-2 px-5 py-2.5 rounded-xl text-sm font-medium text-white bg-brand-600 hover:bg-brand-500 transition-colors",children:[e.jsx(xe,{size:16})," Add Folder"]}),e.jsx(yt,{onDetect:t=>{t.length>0&&L(!0)}})]}):e.jsx("p",{className:"text-sm text-gray-500",children:"A tester or admin can map output folders."})]})}):e.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[e.jsx("div",{className:"flex-shrink-0 border-b border-white/5 bg-surface-1",children:e.jsxs("div",{className:"flex items-center gap-1 px-4 pt-2 overflow-x-auto",children:[S.map(t=>e.jsxs("button",{onClick:()=>c(t.id),className:`group flex items-center gap-1.5 px-3.5 py-2.5 rounded-t-lg text-sm font-medium transition-all whitespace-nowrap ${a===t.id?"bg-surface-0 text-cyan-300 border border-white/5 border-b-transparent -mb-px":"text-gray-500 hover:text-gray-300 hover:bg-white/[0.03]"}`,children:[e.jsx(M,{size:14}),t.label,t.framework&&e.jsx("span",{className:"text-xs px-1 py-0.5 rounded bg-brand-500/10 text-brand-400",children:t.framework}),a===t.id&&x&&e.jsxs("div",{className:"flex items-center gap-0.5 ml-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsx("button",{onClick:s=>{s.stopPropagation(),J(t)},className:"p-0.5 rounded text-gray-600 hover:text-sky-400",children:e.jsx(Ve,{size:10})}),e.jsx("button",{onClick:s=>{s.stopPropagation(),Pe(t.id)},className:"p-0.5 rounded text-gray-600 hover:text-red-400",children:e.jsx(ue,{size:10})})]})]},t.id)),x&&e.jsxs("button",{onClick:()=>L(!0),className:"flex items-center gap-1 px-2.5 py-2 rounded-t-lg text-sm text-gray-600 hover:text-brand-400 hover:bg-brand-500/5 transition-colors",children:[e.jsx(xe,{size:13})," Add"]})]})}),e.jsxs("div",{className:"flex-shrink-0 flex items-center gap-2 px-4 py-2 border-b border-white/5 bg-surface-1/50",children:[e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx("button",{onClick:ze,disabled:!ie,className:"p-1.5 rounded-lg text-gray-500 hover:text-gray-200 hover:bg-white/5 transition-colors disabled:opacity-30 disabled:hover:bg-transparent disabled:hover:text-gray-500",children:e.jsx(_e,{size:16})}),e.jsx("button",{onClick:Ae,disabled:!oe,className:"p-1.5 rounded-lg text-gray-500 hover:text-gray-200 hover:bg-white/5 transition-colors disabled:opacity-30 disabled:hover:bg-transparent disabled:hover:text-gray-500",children:e.jsx(Ye,{size:16})}),e.jsx("button",{onClick:ce,disabled:!o,className:"p-1.5 rounded-lg text-gray-500 hover:text-gray-200 hover:bg-white/5 transition-colors disabled:opacity-30 disabled:hover:bg-transparent disabled:hover:text-gray-500",title:"Up one level",children:e.jsx(Ze,{size:16})}),e.jsx("button",{onClick:De,className:"p-1.5 rounded-lg text-gray-500 hover:text-gray-200 hover:bg-white/5 transition-colors",title:"Go to root",children:e.jsx(et,{size:15})})]}),e.jsx("div",{className:"flex-1 flex items-center gap-0.5 min-w-0 bg-surface-2 border border-white/5 rounded-lg px-3 py-1.5 overflow-x-auto",children:de.map((t,s)=>e.jsxs("span",{className:"flex items-center gap-0.5 flex-shrink-0",children:[s>0&&e.jsx(tt,{size:12,className:"text-gray-600"}),e.jsxs("button",{onClick:()=>R(t.path),className:`text-sm px-1 py-0.5 rounded hover:bg-white/5 transition-colors truncate max-w-[160px] ${s===de.length-1?"text-gray-200 font-medium":"text-gray-500 hover:text-gray-300"}`,children:[s===0&&e.jsx(M,{size:13,className:"inline mr-1 -mt-0.5 text-brand-400"}),t.label]})]},t.path))}),e.jsxs("div",{className:"relative w-48",children:[e.jsx(st,{size:14,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-gray-600"}),e.jsx("input",{value:n,onChange:t=>O(t.target.value),placeholder:"Search...",className:"w-full bg-surface-2 border border-white/5 rounded-lg pl-8 pr-3 py-1.5 text-sm text-gray-200 outline-none placeholder-gray-600 focus:border-brand-500/40 transition-colors"}),n&&e.jsx("button",{onClick:()=>O(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-gray-600 hover:text-gray-300",children:e.jsx(be,{size:12})})]}),e.jsxs("select",{value:H,onChange:t=>ve(t.target.value),className:"bg-surface-2 border border-white/5 rounded-lg px-2.5 py-1.5 text-sm text-gray-400 outline-none cursor-pointer",children:[e.jsx("option",{value:"name",children:"Name"}),e.jsx("option",{value:"date",children:"Date"}),e.jsx("option",{value:"size",children:"Size"}),e.jsx("option",{value:"type",children:"Type"})]}),e.jsx("button",{onClick:()=>we(t=>t==="asc"?"desc":"asc"),className:"p-1.5 rounded-lg text-gray-500 hover:text-gray-300 hover:bg-white/5 transition-colors",children:W==="asc"?e.jsx(rt,{size:15}):e.jsx(at,{size:15})}),e.jsxs("select",{value:G,onChange:t=>Ne(t.target.value),className:"bg-surface-2 border border-white/5 rounded-lg px-2.5 py-1.5 text-sm text-gray-400 outline-none cursor-pointer",children:[e.jsx("option",{value:"",children:"All"}),e.jsx("option",{value:"png,jpg,jpeg,gif,webp,svg",children:"Images"}),e.jsx("option",{value:"mp4,webm",children:"Videos"}),e.jsx("option",{value:"html,htm",children:"HTML"}),e.jsx("option",{value:"json",children:"JSON"}),e.jsx("option",{value:"txt,log",children:"Logs"}),e.jsx("option",{value:"pdf",children:"PDF"})]}),e.jsxs("div",{className:"flex items-center rounded-lg border border-white/5 overflow-hidden",children:[e.jsx("button",{onClick:()=>ae("grid"),className:`p-1.5 transition-colors ${D==="grid"?"bg-brand-500/10 text-brand-400":"text-gray-600 hover:text-gray-300"}`,children:e.jsx(lt,{size:15})}),e.jsx("button",{onClick:()=>ae("list"),className:`p-1.5 transition-colors ${D==="list"?"bg-brand-500/10 text-brand-400":"text-gray-600 hover:text-gray-300"}`,children:e.jsx(nt,{size:15})})]}),e.jsx("button",{onClick:()=>Se(),className:"p-1.5 rounded-lg text-gray-500 hover:text-cyan-400 hover:bg-cyan-500/10 transition-colors",children:e.jsx(it,{size:15})})]}),e.jsxs("div",{ref:Q,className:"flex-1 flex overflow-hidden",children:[e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden ",children:[n.length>=2&&(E!=null&&E.results)?e.jsxs("div",{className:"flex-1 overflow-y-auto p-4",children:[e.jsxs("p",{className:"text-xs text-gray-500 mb-3",children:[E.results.length,' results for "',n,'"']}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 md:grid-cols-6 lg:grid-cols-8 gap-2",children:E.results.map(t=>e.jsxs("button",{onClick:()=>{c(t.folderId),y(t)},className:"flex flex-col items-center gap-1.5 p-3 rounded-xl border border-transparent hover:border-white/10 hover:bg-white/[0.02] transition-all text-center group",children:[q(t.extension||"",28),e.jsx("span",{className:"text-xs text-gray-300 truncate w-full",children:t.name}),e.jsx("span",{className:"text-[11px] text-gray-600 truncate w-full",children:t.folderLabel})]},`${t.folderId}-${t.path}`))})]}):Fe?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsx($,{size:24,className:"text-gray-600 animate-spin"})}):u!=null&&u.exists?g.length===0?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx(se,{size:28,className:"text-gray-700 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-gray-500",children:"This folder is empty"})]})}):D==="grid"?e.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:e.jsx("div",{"data-grid":!0,className:"grid grid-cols-3 sm:grid-cols-5 md:grid-cols-7 lg:grid-cols-9 xl:grid-cols-10 gap-1",children:g.map((t,s)=>e.jsxs("button",{onClick:()=>{t.type==="file"&&z(s),ee(t)},onDoubleClick:()=>{t.type==="file"&&y(t)},className:`flex flex-col items-center gap-1 p-2.5 rounded-xl border transition-all text-center group ${j===s?"border-cyan-500/50 bg-cyan-500/10 ring-1 ring-cyan-500/30":(d==null?void 0:d.path)===t.path?"border-brand-500/40 bg-brand-500/10":"border-transparent hover:border-white/10 hover:bg-white/[0.02]"}`,children:[t.type==="directory"?e.jsx(se,{size:32,className:"text-blue-400"}):q(t.extension||"",32),e.jsx("span",{className:"text-xs text-gray-300 w-full leading-tight mt-0.5 line-clamp-2 break-all",title:t.name,children:t.name}),t.type==="file"&&t.size!==void 0&&e.jsx("span",{className:"text-[11px] text-gray-600 opacity-0 group-hover:opacity-100 transition-opacity",children:U(t.size)}),t.type==="directory"&&t.children&&e.jsxs("span",{className:"text-[11px] text-gray-600 opacity-0 group-hover:opacity-100 transition-opacity",children:[t.children.length," items"]})]},t.path))})}):e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[e.jsxs("div",{className:"sticky top-0 flex items-center gap-3 px-4 py-2 bg-surface-1 border-b border-white/5 text-xs text-gray-500 font-medium",children:[e.jsx("span",{className:"flex-1 min-w-0",children:"Name"}),e.jsx("span",{className:"w-28 text-right",children:"Date Modified"}),e.jsx("span",{className:"w-20 text-right",children:"Type"}),e.jsx("span",{className:"w-20 text-right",children:"Size"})]}),e.jsx("div",{className:"divide-y divide-white/[0.02]",children:g.map((t,s)=>e.jsxs("button",{onClick:()=>{t.type==="file"&&z(s),ee(t)},className:`w-full flex items-center gap-3 px-4 py-2 text-left transition-colors group ${j===s?"bg-cyan-500/10 border-l-2 border-l-cyan-500/50":(d==null?void 0:d.path)===t.path?"bg-brand-500/10":"hover:bg-white/[0.02]"}`,children:[e.jsxs("div",{className:"flex items-center gap-2.5 flex-1 min-w-0",children:[t.type==="directory"?e.jsx(se,{size:18,className:"text-blue-400 flex-shrink-0"}):q(t.extension||"",18),e.jsx("span",{className:"text-sm text-gray-200 truncate",children:t.name})]}),e.jsx("span",{className:"w-28 text-right text-xs text-gray-500",children:t.modified?ht(t.modified):""}),e.jsx("span",{className:"w-20 text-right text-xs text-gray-600 uppercase",children:t.type==="directory"?"Folder":t.extension||"—"}),e.jsx("span",{className:"w-20 text-right text-xs text-gray-500",children:t.type==="file"&&t.size!==void 0?U(t.size):""})]},t.path))})]}):e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx(ot,{size:24,className:"text-amber-400 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-gray-500",children:"Folder does not exist on disk"}),e.jsx("p",{className:"text-xs text-gray-600 mt-1 break-all",children:u==null?void 0:u.folderPath})]})}),e.jsx("div",{className:"flex-shrink-0 flex items-center justify-between px-4 py-1.5 border-t border-white/5 bg-surface-1 text-xs text-gray-500",children:e.jsxs("span",{children:[Z>0&&`${Z} folders`,Z>0&&Y>0&&", ",Y>0&&`${Y} files`,u?` — ${U(u.totalSize)}`:""]})})]}),d&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-1 flex-shrink-0 bg-white/[0.02] hover:bg-brand-500/30 cursor-col-resize transition-colors",onMouseDown:Le}),e.jsx("div",{style:{width:`${X}%`},className:"flex-shrink-0 flex flex-col overflow-hidden border-l border-white/5",children:e.jsx(ft,{file:d,folderId:a,onDownload:()=>Oe(d),onClose:()=>y(null)})})]})]}),(le||T)&&e.jsx(bt,{folder:T,onSave:(t,s,m,f)=>{T?$e(T.id,{label:t,path:s}):Ee(t,s,m,f)},onClose:()=>{L(!1),J(null)}}),A&&e.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50",onClick:()=>I(null),children:e.jsxs("div",{className:"bg-surface-1 border border-white/10 rounded-2xl shadow-xl w-full max-w-md p-6",onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-red-500/10 flex items-center justify-center flex-shrink-0",children:e.jsx(ue,{size:20,className:"text-red-400"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-semibold text-gray-200",children:"Delete Folder Mapping"}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"This action cannot be undone"})]})]}),e.jsx("p",{className:"text-sm text-gray-400 mb-1",children:"Are you sure you want to remove the folder mapping?"}),e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-surface-2 border border-white/5 mb-5",children:[e.jsx(M,{size:15,className:"text-brand-400 flex-shrink-0"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("span",{className:"text-sm font-medium text-gray-200 block truncate",children:A.label}),e.jsx("span",{className:"text-xs text-gray-500 block truncate font-mono",children:A.path})]})]}),e.jsx("p",{className:"text-xs text-gray-600 mb-5",children:"This will only remove the mapping from the dashboard. Your actual files on disk will not be deleted."}),e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx("button",{onClick:()=>I(null),className:"px-4 py-2 rounded-lg text-sm text-gray-400 hover:text-gray-200 hover:bg-white/5 transition-colors",children:"Cancel"}),e.jsx("button",{onClick:Me,className:"px-4 py-2 rounded-lg text-sm font-medium text-white bg-red-600 hover:bg-red-500 transition-colors",children:"Delete"})]})]})})]})}function ft({file:r,folderId:i,onDownload:h,onClose:x}){const a=r.extension||"",c=ge(i,r.path),[o,p]=l.useState(null),[b,w]=l.useState(!1),{monacoTheme:N}=Ke();return l.useEffect(()=>{["json","xml","txt","log","csv","md","js","ts","jsx","tsx","py","java","rb","go","css","yaml","yml","feature","html","htm"].includes(a)?(w(!0),p(null),fetch(c).then(d=>d.text()).then(d=>{p(d),w(!1)}).catch(()=>{p(null),w(!1)})):p(null)},[r.path,a,c]),e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between px-4 py-2.5 border-b border-white/5 bg-surface-1",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[q(a,16),e.jsx("span",{className:"text-sm font-medium text-gray-200 truncate",children:r.name}),r.size!==void 0&&e.jsx("span",{className:"text-xs text-gray-500",children:U(r.size)})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[a==="html"&&e.jsxs("button",{onClick:()=>window.open(c,"_blank"),className:"flex items-center gap-1 px-2.5 py-1 rounded-lg text-xs text-gray-500 hover:text-gray-300 hover:bg-white/5 transition-colors",children:[e.jsx(mt,{size:12})," Open"]}),e.jsxs("button",{onClick:h,className:"flex items-center gap-1 px-2.5 py-1 rounded-lg text-xs text-gray-500 hover:text-cyan-400 hover:bg-cyan-500/10 transition-colors",children:[e.jsx(he,{size:12})," Download"]}),e.jsx("button",{onClick:x,className:"p-1 rounded-lg text-gray-600 hover:text-gray-300 hover:bg-white/5 transition-colors",children:e.jsx(be,{size:14})})]})]}),e.jsxs("div",{className:"flex-1 overflow-auto bg-black/20",children:[["png","jpg","jpeg","gif","webp","svg","bmp"].includes(a)&&e.jsx("div",{className:"flex items-center justify-center h-full p-6",children:e.jsx("img",{src:c,alt:r.name,className:"max-w-full max-h-full object-contain rounded-lg shadow-lg"})}),["mp4","webm","ogg"].includes(a)&&e.jsx("div",{className:"flex items-center justify-center h-full p-6",children:e.jsx("video",{src:c,controls:!0,className:"max-w-full max-h-full rounded-lg shadow-lg"})}),a==="pdf"&&e.jsx("embed",{src:c,type:"application/pdf",className:"w-full h-full"}),["html","htm"].includes(a)&&o!==null&&e.jsx("iframe",{srcDoc:Qe(o),sandbox:"allow-scripts",className:"w-full h-full bg-white",title:r.name}),pe[a]&&o!==null&&!["html","htm"].includes(a)&&e.jsx(Je,{value:a==="json"?(()=>{try{return JSON.stringify(JSON.parse(o),null,2)}catch{return o}})():o,language:pe[a]||"plaintext",theme:N,options:{readOnly:!0,minimap:{enabled:!1},fontSize:13,lineHeight:20,scrollBeyondLastLine:!1,wordWrap:"on",renderLineHighlight:"line",padding:{top:8,bottom:8},scrollbar:{verticalScrollbarSize:8,horizontalScrollbarSize:8},lineNumbers:"on",folding:!0,bracketPairColorization:{enabled:!0},guides:{bracketPairs:!0,indentation:!0}},loading:e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx($,{size:20,className:"text-gray-600 animate-spin"})})}),b&&e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx($,{size:20,className:"text-gray-600 animate-spin"})}),!pt(a)&&!b&&e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"text-center",children:[e.jsx(je,{size:36,className:"text-gray-700 mx-auto mb-3"}),e.jsxs("p",{className:"text-sm text-gray-500 mb-3",children:["Preview not available for .",a," files"]}),e.jsxs("button",{onClick:h,className:"flex items-center gap-2 px-4 py-2 rounded-lg text-sm text-white bg-brand-600 hover:bg-brand-500 transition-colors mx-auto",children:[e.jsx(he,{size:14})," Download File"]})]})})]})]})}function bt({folder:r,onSave:i,onClose:h}){const[x,a]=l.useState((r==null?void 0:r.label)||""),[c,o]=l.useState((r==null?void 0:r.path)||""),[p,b]=l.useState((r==null?void 0:r.isAbsolute)||!1),[w,N]=l.useState([]),[F,d]=l.useState(!1),y=async()=>{d(!0);try{const n=await fe();N(n.detected)}catch{}d(!1)};return e.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50",onClick:h,children:e.jsxs("div",{className:"bg-surface-1 border border-white/10 rounded-2xl shadow-xl w-full max-w-lg p-6",onClick:n=>n.stopPropagation(),children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-200 mb-4",children:r?"Edit Folder Mapping":"Add Output Folder"}),!r&&e.jsxs("div",{className:"mb-4",children:[e.jsxs("button",{onClick:y,disabled:F,className:"flex items-center gap-2 px-4 py-2.5 rounded-lg text-sm font-medium text-brand-300 bg-brand-500/10 border border-brand-500/20 hover:bg-brand-500/20 transition-colors disabled:opacity-50 w-full justify-center",children:[F?e.jsx($,{size:14,className:"animate-spin"}):e.jsx(ye,{size:14}),"Auto-Detect Output Folders"]}),w.length>0&&e.jsx("div",{className:"mt-2 space-y-1 max-h-40 overflow-y-auto",children:w.map(n=>e.jsxs("button",{onClick:()=>{a(n.label),o(n.path),b(!1)},className:`w-full flex items-center gap-2 px-3 py-2 rounded-lg text-left transition-colors ${c===n.path?"bg-brand-500/10 border border-brand-500/30":"hover:bg-white/[0.03] border border-transparent"}`,children:[e.jsx(M,{size:15,className:n.exists?"text-emerald-400":"text-gray-600"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm text-gray-200 font-medium",children:n.label}),e.jsx("div",{className:"text-xs text-gray-500 truncate",children:n.path})]}),n.framework&&e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-brand-500/10 text-brand-400",children:n.framework}),e.jsx("span",{className:`text-xs ${n.exists?"text-emerald-400":"text-gray-600"}`,children:n.exists?"exists":"not found"})]},n.path))})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm text-gray-400 mb-1 block",children:"Label"}),e.jsx("input",{value:x,onChange:n=>a(n.target.value),placeholder:"e.g., Playwright Reports",className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 outline-none focus:border-brand-500/40 placeholder-gray-600"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm text-gray-400 mb-1 block",children:"Path"}),e.jsx("input",{value:c,onChange:n=>o(n.target.value),placeholder:"e.g., playwright-report",className:"w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 outline-none focus:border-brand-500/40 placeholder-gray-600 font-mono"})]}),e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:p,onChange:n=>b(n.target.checked),className:"w-3.5 h-3.5 rounded border-white/10 bg-surface-2 text-brand-500"}),e.jsx("span",{className:"text-sm text-gray-400",children:"Absolute path (outside project directory)"})]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 mt-5",children:[e.jsx("button",{onClick:h,className:"px-4 py-2 rounded-lg text-sm text-gray-400 hover:text-gray-200 hover:bg-white/5 transition-colors",children:"Cancel"}),e.jsx("button",{onClick:()=>{var n;return i(x,c,p,(n=w.find(O=>O.path===c))==null?void 0:n.framework)},disabled:!x.trim()||!c.trim(),className:"px-4 py-2 rounded-lg text-sm font-medium text-white bg-brand-600 hover:bg-brand-500 transition-colors disabled:opacity-30",children:r?"Save Changes":"Add Folder"})]})]})})}function yt({onDetect:r}){const[i,h]=l.useState(!1),x=async()=>{h(!0);try{const a=await fe();r(a.detected)}catch{}h(!1)};return e.jsxs("button",{onClick:x,disabled:i,className:"flex items-center gap-2 px-5 py-2.5 rounded-xl text-sm font-medium text-gray-400 bg-surface-1 border border-white/10 hover:border-brand-500/30 hover:text-gray-200 transition-colors disabled:opacity-50",children:[i?e.jsx($,{size:16,className:"animate-spin"}):e.jsx(ye,{size:16}),"Auto-Detect"]})}export{St as OutputPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e,r as n}from"./vendor-react-DOVfxdUy.js";import{a as it,u as K}from"./vendor-query-DkZSMtfn.js";import{R as ot,Q as ct}from"./RunState-DDwFB4tA.js";import{ae as dt,cZ as xt,c_ as mt,c$ as ht,cy as ut,d0 as pt,d1 as Qe,d2 as gt,d3 as bt,d4 as yt,d5 as ft,d6 as Ze,d7 as jt,d8 as vt,d9 as Nt,da as wt,db as kt,dc as Ct,dd as St}from"./index-BlA8ntjb.js";import{C as Te}from"./ConfirmDialog-D_N9188T.js";import{u as It,T as Ue}from"./RunTargets-CkIpY3v3.js";import{u as Tt,b as zt,a as Se}from"./useTabParam-CyYAP90W.js";import{c as Je}from"./clipboard-BIEd7Ccc.js";import{G as Le,X as $e,a1 as J,cp as He,at as Rt,b5 as Ye,p as Ae,aJ as Ee,b7 as Et,b8 as Pt,a9 as Ge,a_ as $t,cH as ue,w as Fe,R as At,cI as Mt,$ as Xe,b9 as Lt,c5 as Ht,ah as Ie,ai as Oe}from"./vendor-icons-Cm92aSc5.js";const qt="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20128%20128'%3e%3cpath%20fill='%232088ff'%20d='M26.666%200C11.97%200%200%2011.97%200%2026.666c0%2012.87%209.181%2023.651%2021.334%2026.13v37.87c0%2011.77%209.68%2021.334%2021.332%2021.334h.195c1.302%209.023%209.1%2016%2018.473%2016C71.612%20128%2080%20119.612%2080%20109.334s-8.388-18.668-18.666-18.668c-9.372%200-17.17%206.977-18.473%2016h-.195c-8.737%200-16-7.152-16-16V63.779a18.514%2018.514%200%200%200%2013.24%205.555h2.955c1.303%209.023%209.1%2016%2018.473%2016%209.372%200%2017.169-6.977%2018.47-16h11.057c1.303%209.023%209.1%2016%2018.473%2016%2010.278%200%2018.666-8.39%2018.666-18.668C128%2056.388%20119.612%2048%20109.334%2048c-9.373%200-17.171%206.977-18.473%2016H79.805c-1.301-9.023-9.098-16-18.471-16s-17.171%206.977-18.473%2016h-2.955c-6.433%200-11.793-4.589-12.988-10.672%2014.58-.136%2026.416-12.05%2026.416-26.662C53.334%2011.97%2041.362%200%2026.666%200zm0%205.334A21.292%2021.292%200%200%201%2048%2026.666%2021.294%2021.294%200%200%201%2026.666%2048%2021.292%2021.292%200%200%201%205.334%2026.666%2021.29%2021.29%200%200%201%2026.666%205.334zm-5.215%207.541C18.67%2012.889%2016%2015.123%2016%2018.166v17.043c0%204.043%204.709%206.663%208.145%204.533l13.634-8.455c3.257-2.02%203.274-7.002.032-9.045l-13.635-8.59a5.024%205.024%200%200%200-2.725-.777zm-.117%205.291%2013.635%208.588-13.635%208.455V18.166zm40%2035.168a13.29%2013.29%200%200%201%2013.332%2013.332A13.293%2013.293%200%200%201%2061.334%2080%2013.294%2013.294%200%200%201%2048%2066.666a13.293%2013.293%200%200%201%2013.334-13.332zm48%200a13.29%2013.29%200%200%201%2013.332%2013.332A13.293%2013.293%200%200%201%20109.334%2080%2013.294%2013.294%200%200%201%2096%2066.666a13.293%2013.293%200%200%201%2013.334-13.332zm-42.568%206.951a2.667%202.667%200%200%200-1.887.78l-6.3%206.294-2.093-2.084a2.667%202.667%200%200%200-3.771.006%202.667%202.667%200%200%200%20.008%203.772l3.974%203.96a2.667%202.667%200%200%200%203.766-.001l8.185-8.174a2.667%202.667%200%200%200%20.002-3.772%202.667%202.667%200%200%200-1.884-.78zm48%200a2.667%202.667%200%200%200-1.887.78l-6.3%206.294-2.093-2.084a2.667%202.667%200%200%200-3.771.006%202.667%202.667%200%200%200%20.008%203.772l3.974%203.96a2.667%202.667%200%200%200%203.766-.001l8.185-8.174a2.667%202.667%200%200%200%20.002-3.772%202.667%202.667%200%200%200-1.884-.78zM61.334%2096a13.293%2013.293%200%200%201%2013.332%2013.334%2013.29%2013.29%200%200%201-13.332%2013.332A13.293%2013.293%200%200%201%2048%20109.334%2013.294%2013.294%200%200%201%2061.334%2096zM56%20105.334c-2.193%200-4%201.807-4%204%200%202.195%201.808%204%204%204s4-1.805%204-4c0-2.193-1.807-4-4-4zm10.666%200c-2.193%200-4%201.807-4%204%200%202.195%201.808%204%204%204s4-1.805%204-4c0-2.193-1.807-4-4-4zM56%20108c.75%200%201.334.585%201.334%201.334%200%20.753-.583%201.332-1.334%201.332-.75%200-1.334-.58-1.334-1.332%200-.75.585-1.334%201.334-1.334zm10.666%200c.75%200%201.334.585%201.334%201.334%200%20.753-.583%201.332-1.334%201.332-.75%200-1.332-.58-1.332-1.332%200-.75.583-1.334%201.332-1.334z'/%3e%3cpath%20fill='%2379b8ff'%20d='M109.334%2090.666c-9.383%200-17.188%206.993-18.477%2016.031a2.667%202.667%200%200%200-.265-.011l-2.7.09a2.667%202.667%200%200%200-2.578%202.751%202.667%202.667%200%200%200%202.752%202.578l2.7-.087a2.667%202.667%200%200%200%20.097-.006C92.17%20121.029%2099.965%20128%20109.334%20128c10.278%200%2018.666-8.388%2018.666-18.666s-8.388-18.668-18.666-18.668zm0%205.334a13.293%2013.293%200%200%201%2013.332%2013.334%2013.29%2013.29%200%200%201-13.332%2013.332A13.293%2013.293%200%200%201%2096%20109.334%2013.294%2013.294%200%200%201%20109.334%2096z'/%3e%3c/svg%3e",Ft="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20128%20128'%20xml:space='preserve'%3e%3cpath%20fill='%23E24329'%20d='m124.755%2051.382-.177-.452L107.47%206.282a4.459%204.459%200%200%200-1.761-2.121%204.581%204.581%200%200%200-5.236.281%204.578%204.578%200%200%200-1.518%202.304L87.404%2042.088H40.629L29.077%206.746a4.492%204.492%200%200%200-1.518-2.31%204.581%204.581%200%200%200-5.236-.281%204.502%204.502%200%200%200-1.761%202.121L3.422%2050.904l-.17.452c-5.059%2013.219-.763%2028.192%2010.537%2036.716l.059.046.157.111%2026.061%2019.516%2012.893%209.758%207.854%205.93a5.283%205.283%200%200%200%206.388%200l7.854-5.93%2012.893-9.758%2026.218-19.634.065-.052c11.273-8.526%2015.562-23.472%2010.524-36.677z'/%3e%3cpath%20fill='%23FC6D26'%20d='m124.755%2051.382-.177-.452a57.79%2057.79%200%200%200-23.005%2010.341L64%2089.682c12.795%209.68%2023.934%2018.09%2023.934%2018.09l26.218-19.634.065-.052c11.291-8.527%2015.586-23.488%2010.538-36.704z'/%3e%3cpath%20fill='%23FCA326'%20d='m40.066%20107.771%2012.893%209.758%207.854%205.93a5.283%205.283%200%200%200%206.388%200l7.854-5.93%2012.893-9.758s-11.152-8.436-23.947-18.09a18379.202%2018379.202%200%200%200-23.935%2018.09z'/%3e%3cpath%20fill='%23FC6D26'%20d='M26.42%2061.271A57.73%2057.73%200%200%200%203.422%2050.904l-.17.452c-5.059%2013.219-.763%2028.192%2010.537%2036.716l.059.046.157.111%2026.061%2019.516L64%2089.655%2026.42%2061.271z'/%3e%3c/svg%3e",Ot="/assets/jenkins-CWiA3Rta.svg",Bt="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='utf-8'?%3e%3c!--%20Uploaded%20to:%20SVG%20Repo,%20www.svgrepo.com,%20Generator:%20SVG%20Repo%20Mixer%20Tools%20--%3e%3csvg%20width='800px'%20height='800px'%20viewBox='0%200%2032%2032'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%3e%3cdefs%3e%3cmask%20id='a'%20x='1.455'%20y='1.455'%20width='29.091'%20height='29.091'%20maskUnits='userSpaceOnUse'%3e%3cpath%20d='M5.7,20.974l1.464-1.565,1.819,1.819L7.5,22.707,9.293,24.5l1.479-1.479L12.6,24.852,11.151,26.3l4.242,4.242h6.667a1.212,1.212,0,0,0,1.212-1.212v-9.7l6.195-4.129a2.425,2.425,0,0,0,1.078-2.016V2.667a1.212,1.212,0,0,0-1.212-1.212H18.509a2.425,2.425,0,0,0-2.016,1.078L12.364,8.727h-9.7A1.212,1.212,0,0,0,1.455,9.94v6.666Z'%20style='fill:%23fff'/%3e%3cpath%20d='M3.636,23.273H1.455v7.273H8.727V28.364H3.636Z'%20style='fill:%23fff'/%3e%3c/mask%3e%3clinearGradient%20id='b'%20x1='0.069'%20y1='31.569'%20x2='1.069'%20y2='31.569'%20gradientTransform='matrix(0,%2029.091,%2029.091,%200,%20-902.364,%20-0.545)'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20offset='0'%20stop-color='%23ffffff'/%3e%3cstop%20offset='1'%20stop-color='%23ffffff'%20stop-opacity='0'/%3e%3c/linearGradient%3e%3clinearGradient%20id='c'%20x1='0.069'%20y1='31.194'%20x2='1.069'%20y2='31.194'%20xlink:href='%23b'/%3e%3c/defs%3e%3ctitle%3efile_type_azurepipelines%3c/title%3e%3cg%20style='mask:url(%23a)'%3e%3cpath%20d='M1.455,23.273H3.636v5.091H8.727v2.182H1.455Z'%20style='fill:%2391b0f2'/%3e%3cpath%20d='M1.455,9.939v6.667L5.7,20.974,7.515,19.03l5.455,5.455L11.151,26.3l4.242,4.242h6.667a1.212,1.212,0,0,0,1.212-1.212v-9.7L12.364,8.727h-9.7A1.212,1.212,0,0,0,1.455,9.939Z'%20style='fill:%230f46bd'/%3e%3cpath%20d='M6,18.249,17.212,1.455H30.545V14.788L13.751,26Z'%20style='fill:%23062aa9'/%3e%3cpath%20d='M6.7,18.952a1.212,1.212,0,0,1-.151-1.53l9.94-14.889a2.424,2.424,0,0,1,2.016-1.078H29.333a1.212,1.212,0,0,1,1.212,1.212V13.492a2.424,2.424,0,0,1-1.078,2.016l-14.889,9.94a1.212,1.212,0,0,1-1.53-.151Z'%20style='fill:%232560e0'/%3e%3cpath%20d='M7.5,22.707l9.255-9.255,1.792,1.792L9.293,24.5Z'%20style='fill:%230a44c2'/%3e%3cpath%20d='M7.5,22.707l9.255-9.255,1.792,1.792L9.293,24.5Z'%20style='fill:%23729af2'/%3e%3cpath%20d='M10.772,23.02,8.98,21.228l7.776-7.775,1.792,1.792Z'%20style='fill:%234c80f0'/%3e%3cpath%20d='M23.273,12.364a3.636,3.636,0,1,0-3.636-3.636A3.636,3.636,0,0,0,23.273,12.364Z'%20style='fill:%230a44c2'/%3e%3cpath%20d='M23.273,12.364a3.636,3.636,0,1,0-3.636-3.636A3.636,3.636,0,0,0,23.273,12.364Z'%20style='fill:%2391b0f2'/%3e%3cg%20style='opacity:0.20000000298023224'%3e%3cpath%20d='M5.7,20.974l1.464-1.565,1.819,1.819L7.5,22.707,9.293,24.5l1.479-1.479L12.6,24.852,11.151,26.3l4.242,4.242h6.667a1.212,1.212,0,0,0,1.212-1.212v-9.7l6.195-4.129a2.425,2.425,0,0,0,1.078-2.016V2.667a1.212,1.212,0,0,0-1.212-1.212H18.509a2.425,2.425,0,0,0-2.016,1.078L12.364,8.727h-9.7A1.212,1.212,0,0,0,1.455,9.94v6.666Z'%20style='fill:url(%23b)'/%3e%3cpath%20d='M3.636,23.273H1.455v7.273H8.727V28.364H3.636Z'%20style='fill:url(%23c)'/%3e%3c/g%3e%3c/g%3e%3c/svg%3e",_t="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20128%20128'%3e%3cdefs%3e%3clinearGradient%20id='bitbucket-original-a'%20gradientUnits='userSpaceOnUse'%20x1='28.593'%20y1='14.226'%20x2='16.672'%20y2='23.532'%20gradientTransform='scale(4)'%3e%3cstop%20offset='.176'%20stop-color='%230052cc'/%3e%3cstop%20offset='1'%20stop-color='%232684ff'/%3e%3c/linearGradient%3e%3c/defs%3e%3cpath%20d='M19.082%2020c-1.918%200-3.355%201.758-3.039%203.516l12.95%2079.289c.32%202.078%202.077%203.515%204.155%203.515h62.66c1.442%200%202.72-1.12%203.04-2.558l13.109-80.086c.316-1.918-1.121-3.516-3.039-3.516zM74.07%2077.227H54.09l-5.278-28.293h30.215zm0%200'%20fill='%232684ff'/%3e%3cpath%20d='M107.64%2048.934H78.868L74.07%2077.227H54.09l-23.5%2027.972s1.12.961%202.719.961h62.66c1.441%200%202.719-1.12%203.039-2.558zm0%200'%20fill='url(%23bitbucket-original-a)'/%3e%3c/svg%3e",Dt="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20128%20128'%3e%3cpath%20fill='%23343434'%20d='M47.809%2064c0-8.45%206.847-15.23%2015.23-15.23%208.387%200%2015.234%206.847%2015.234%2015.23S71.426%2079.23%2063.04%2079.23c-8.383%200-15.23-6.847-15.23-15.23zm15.23-64C33.152%200%208.13%2020.48%201.023%2048.129c-.062.191-.062.383-.062.64a3.07%203.07%200%20003.07%203.07h25.793c1.215%200%202.305-.702%202.75-1.792%205.313-11.52%2016.961-19.582%2030.465-19.582%2018.496%200%2033.535%2015.039%2033.535%2033.535%200%2018.496-15.039%2033.535-33.535%2033.535-13.504%200-25.152-8-30.465-19.582-.511-1.023-1.535-1.793-2.75-1.793H4.031a3.07%203.07%200%2000-3.07%203.07c0%20.196.062.387.062.641C8.063%20107.52%2033.153%20128%2063.04%20128c35.328%200%2064-28.672%2064-64s-28.672-64-64-64zm0%200'/%3e%3c/svg%3e",Ut={"github-actions":qt,"gitlab-ci":Ft,jenkins:Ot,"azure-pipelines":Bt,bitbucket:_t,circleci:Dt},Gt={circleci:!0};function Kt({platform:s,size:o=16,className:l=""}){const a=Ut[s];return a?e.jsx("img",{src:a,alt:"","aria-hidden":"true",width:o,height:o,style:{width:o,height:o},className:`flex-shrink-0 object-contain ${Gt[s]?"dark:invert":""} ${l}`}):null}const Pe={queued:"bg-amber-500/10 border-amber-500/30 text-amber-300",running:"bg-blue-500/10 border-blue-500/30 text-blue-300",passed:"bg-emerald-500/10 border-emerald-500/30 text-emerald-300",failed:"bg-red-500/10 border-red-500/30 text-red-300",cancelled:"bg-white/5 border-white/10 text-gray-400",error:"bg-red-500/10 border-red-500/30 text-red-300"},et={command:"Command",suite:"Suite",cycle:"Cycle"};function V(s){if(!s)return"—";const o=Date.now()-new Date(s).getTime(),l=Math.floor(o/6e4);if(l<1)return"just now";if(l<60)return`${l}m ago`;const a=Math.floor(l/60);return a<24?`${a}h ago`:`${Math.floor(a/24)}d ago`}function tt(s){if(!s)return"";const o=new Date(s).getTime()-Date.now();if(o<=0)return"expired";const l=o/864e5;return l>=1?`expires in ${Math.round(l)}d`:`expires in ${Math.max(1,Math.floor(o/36e5))}h`}function pe(s){if(!s||s<=0)return"—";const o=Math.round(s/1e3);if(o<60)return`${o}s`;const l=Math.floor(o/60);return l<60?`${l}m ${o%60}s`:`${Math.floor(l/60)}h ${l%60}m`}function st(s){return s>=90?"text-emerald-400":s>=70?"text-amber-400":"text-red-400"}function at(s){let o;try{o=new URL(s)}catch{return"Enter a full address, e.g. https://testver.example.com"}return/^https?:$/.test(o.protocol)?/^(localhost|127\.|0\.0\.0\.0|\[?::1\]?)/i.test(o.hostname)?"This is a local address — CI runners in the cloud cannot reach it. Use the address your CI runners reach this server at.":o.protocol==="http:"?"Plain http — the CI token travels unencrypted. Use https when CI reaches this server over the internet.":null:"Use an http(s) address"}function Be(s){const o=n.useRef(s);o.current=s,n.useEffect(()=>{const l=a=>{a.key==="Escape"&&o.current()};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[])}function Re({what:s,error:o,onRetry:l}){return e.jsxs("div",{role:"alert",className:"px-4 py-3 rounded-xl bg-red-500/10 border border-red-500/30 text-sm text-red-300 flex items-center gap-3",children:[e.jsx(Ae,{size:15,className:"flex-shrink-0"}),e.jsxs("span",{className:"flex-1",children:["Could not load ",s,": ",(o==null?void 0:o.message)||String(o)]}),e.jsxs("button",{onClick:l,className:"flex items-center gap-1 px-2.5 py-1 rounded-lg border border-red-500/30 hover:bg-red-500/10 text-xs font-medium",children:[e.jsx(At,{size:12})," Retry"]})]})}function rt({message:s,onDismiss:o}){return s?e.jsxs("div",{role:"alert",className:"mb-4 px-3 py-2.5 rounded-xl bg-red-500/10 border border-red-500/30 text-sm text-red-300 flex items-start gap-2",children:[e.jsx(Ae,{size:15,className:"flex-shrink-0 mt-0.5"}),e.jsx("span",{className:"flex-1",children:s}),e.jsx("button",{onClick:o,"aria-label":"Dismiss error",className:"text-red-300 hover:text-red-200",children:e.jsx($e,{size:14})})]}):null}function is(){var ve,ie,Ne,we;const s=it(),{hasRole:o}=dt(),l=o("tester"),a=o("admin"),[i,w]=Tt("tab",["dashboard","pipelines","ci-runs","tokens","trace"],"dashboard"),x=zt(),N=K({queryKey:["ci-pipelines"],queryFn:xt}),g=K({queryKey:["ci-tokens"],queryFn:mt}),j=K({queryKey:["ci-runs"],queryFn:()=>ht(200),refetchInterval:t=>{var u;return(((u=t.state.data)==null?void 0:u.runs)||[]).some(f=>f.state==="running"||f.state==="queued")?1e4:3e4}}),{data:b}=K({queryKey:["suites"],queryFn:ut}),c=K({queryKey:["ci-analytics"],queryFn:pt,refetchInterval:3e4}),d=c.data,v=((ve=N.data)==null?void 0:ve.pipelines)||[],P=((ie=g.data)==null?void 0:ie.tokens)||[],F=P.filter(t=>!t.revoked),$=P.filter(t=>t.revoked),S=((Ne=j.data)==null?void 0:Ne.runs)||[],O=(b==null?void 0:b.suites)||[],h=[...new Set(v.filter(t=>t.target.type==="cycle"&&t.target.cycleId).map(t=>t.target.cycleId))],{data:R}=K({queryKey:["ci-cycle-names",h.join(",")],enabled:h.length>0,queryFn:async()=>{const t=await Promise.all(h.map(async u=>{try{const f=await Qe(u);return[u,{name:f==null?void 0:f.name,planId:f==null?void 0:f.planId}]}catch{return[u,null]}}));return Object.fromEntries(t)}}),[A]=Se("state"),[k]=Se("pipeline"),[B]=Se("branch"),[M]=Se("env"),L=S.filter(t=>(!A||t.state===A)&&(!k||t.mappingName===k)&&(!B||(t.branch||"").toLowerCase().includes(B.toLowerCase()))&&(!M||(t.environment||"").toLowerCase()===M.toLowerCase())),_=!!(A||k||B||M),ce=()=>x({state:null,pipeline:null,branch:null,env:null}),[se,I]=n.useState(0),[z,ae]=n.useState(20);n.useEffect(()=>{I(0)},[A,k,B,M]);const E=Math.max(1,Math.ceil(L.length/z)),T=Math.min(se,E-1),re=L.slice(T*z,(T+1)*z),[ne,G]=n.useState(null),[W,m]=n.useState(null),[y,Y]=n.useState(null),[ge,le]=n.useState(null),[Q,de]=n.useState(null),[X,p]=n.useState(null),[be,ye]=n.useState(!1),[fe,D]=n.useState(null),[Me,ee]=n.useState(null),je=t=>{var u;return(u=O.find(f=>f.id===t))==null?void 0:u.name},Z=()=>{s.invalidateQueries({queryKey:["ci-pipelines"]}),s.invalidateQueries({queryKey:["ci-tokens"]}),s.invalidateQueries({queryKey:["ci-runs"]}),s.invalidateQueries({queryKey:["ci-analytics"]})},ze=async t=>{try{await Ze({...t,enabled:!t.enabled}),Z()}catch(u){D((u==null?void 0:u.message)||String(u))}},q=[{id:"dashboard",label:"Dashboard",icon:e.jsx(He,{size:15})},{id:"pipelines",label:"Pipelines",icon:e.jsx(Le,{size:15})},{id:"tokens",label:"CI Tokens",icon:e.jsx(Ge,{size:15})},{id:"ci-runs",label:"CI Runs",icon:e.jsx(ue,{size:15})},{id:"trace",label:"Trace",icon:e.jsx(Fe,{size:15})}];return e.jsxs("div",{className:"h-full flex flex-col bg-surface-0 text-gray-200 animate-fade-in",children:[e.jsx("div",{className:"border-b border-white/5 bg-surface-1",children:e.jsxs("div",{className:"max-w-[1400px] mx-auto w-full px-6 py-6",children:[e.jsxs("h1",{className:"text-2xl font-bold text-gray-100 flex items-center gap-3",children:[e.jsx(Le,{size:24,className:"text-brand-300"}),"CI/CD Pipelines"]}),e.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"Your CI/CD pipelines trigger test runs that execute on this Testver server and gate the build on the verdict"})]})}),e.jsx("div",{className:"border-b border-white/5 bg-surface-1",children:e.jsx("div",{role:"tablist","aria-label":"CI/CD Pipelines sections",className:"max-w-[1400px] mx-auto w-full px-6 flex gap-1",children:q.map(t=>e.jsxs("button",{role:"tab","aria-selected":i===t.id,onClick:()=>w(t.id),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium border-b-2 transition-colors ${i===t.id?"border-brand-400 text-brand-300":"border-transparent text-gray-400 hover:text-gray-200 hover:border-white/10"}`,children:[t.icon,t.label]},t.id))})}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:e.jsxs("div",{className:"max-w-[1400px] mx-auto w-full px-6 py-6 space-y-8",children:[fe&&e.jsxs("div",{role:"alert",className:"px-4 py-3 rounded-xl bg-red-500/10 border border-red-500/30 text-sm text-red-300 flex items-center justify-between",children:[e.jsx("span",{children:fe}),e.jsx("button",{onClick:()=>D(null),"aria-label":"Dismiss error",className:"text-red-300 hover:text-red-200",children:e.jsx($e,{size:14})})]}),i==="pipelines"&&e.jsxs("div",{className:"px-4 py-3 rounded-xl bg-brand-500/10 border border-brand-500/25 text-sm text-gray-300",children:[e.jsx("b",{className:"text-brand-300",children:"Delegated execution:"})," CI pipelines trigger runs that execute ",e.jsx("b",{children:"on this Testver server"}),", then gate the build on the verdict. Map a pipeline to a suite, cycle, or command, create a CI token, and wire your workflow — from CI or any terminal via"," ",e.jsx("code",{className:"text-brand-300",children:"testver trigger"}),"."]}),i==="dashboard"&&c.isLoading&&e.jsxs("div",{className:"py-12 text-center text-gray-500 text-sm",children:[e.jsx(J,{size:16,className:"animate-spin inline mr-2"}),"Loading the dashboard…"]}),i==="dashboard"&&c.isError&&e.jsx(Re,{what:"the CI dashboard",error:c.error,onRetry:()=>c.refetch()}),i==="dashboard"&&d&&d.totals.runs===0&&e.jsxs("div",{className:"py-16 text-center rounded-xl border border-dashed border-white/10",children:[e.jsx(He,{size:32,className:"mx-auto text-gray-600 mb-3"}),e.jsx("p",{className:"text-base font-medium text-gray-300 mb-1",children:"No CI runs yet"}),e.jsx("p",{className:"text-sm text-gray-500 max-w-md mx-auto mb-4",children:"Create a pipeline mapping and a CI token, then trigger a run from your pipeline or any terminal. The dashboard lights up with pass rates, trends, and insights from the first run."}),e.jsx("button",{onClick:()=>w("pipelines"),className:"px-4 py-2 rounded-xl text-sm font-medium bg-brand-600 hover:bg-brand-500 text-white transition-colors",children:"Set up a Pipeline →"})]}),i==="dashboard"&&d&&d.totals.runs>0&&e.jsxs("section",{children:[e.jsxs("h2",{className:"text-base font-semibold text-gray-100 flex items-center gap-2 mb-3",children:[e.jsx(He,{size:17,className:"text-emerald-300"})," Overview"]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3 mb-3",children:[e.jsxs("div",{className:"px-4 py-3 rounded-xl bg-surface-1 border border-white/5",children:[e.jsx("div",{className:"text-xs text-gray-500 uppercase tracking-wide",children:"CI Runs"}),e.jsx("div",{className:"text-xl font-semibold text-gray-100 mt-0.5",children:d.totals.runs})]}),e.jsxs("div",{className:"px-4 py-3 rounded-xl bg-surface-1 border border-white/5",title:"Passed ÷ (passed + failed + errored). A run that errored — lost, timed out or ran no tests — counts against it; cancelled runs don't count.",children:[e.jsx("div",{className:"text-xs text-gray-500 uppercase tracking-wide",children:"Pass Rate"}),e.jsxs("div",{className:`text-xl font-semibold mt-0.5 ${st(d.totals.passRate)}`,children:[d.totals.passRate,"%"]}),(d.totals.errored||0)>0&&e.jsxs("div",{className:"text-xs text-gray-500 mt-0.5",children:[d.totals.errored," errored"]})]}),e.jsxs("div",{className:"px-4 py-3 rounded-xl bg-surface-1 border border-white/5",children:[e.jsxs("div",{className:"text-xs text-gray-500 uppercase tracking-wide flex items-center gap-1",children:[e.jsx(Rt,{size:11})," Avg Duration"]}),e.jsx("div",{className:"text-xl font-semibold text-gray-100 mt-0.5",children:pe(d.totals.avgDurationMs)})]}),e.jsxs("div",{className:"px-4 py-3 rounded-xl bg-surface-1 border border-white/5",children:[e.jsx("div",{className:"text-xs text-gray-500 uppercase tracking-wide",children:"Active / Queued"}),e.jsx("div",{className:`text-xl font-semibold mt-0.5 ${d.totals.active>0?"text-blue-300":"text-gray-100"}`,children:d.totals.active})]})]}),d.trend.length>1&&e.jsxs("div",{className:"px-4 py-3 rounded-xl bg-surface-1 border border-white/5",children:[e.jsx("div",{className:"text-xs text-gray-500 uppercase tracking-wide mb-2",children:"Recent verdicts (oldest → newest)"}),e.jsx("div",{className:"flex items-end gap-1 h-14",role:"list","aria-label":"Recent CI verdicts",children:d.trend.map((t,u)=>{const f=d.trend.length,xe=Math.max(...d.trend.map(H=>H.durationMs||0),1),te=30+Math.round((t.durationMs||0)/xe*70),oe=t.state==="passed"?"bg-emerald-400/70":t.state==="error"?"bg-amber-400/80":"bg-red-400/80",U=u<f/4?"left-0":u>3*f/4?"right-0":"left-1/2 -translate-x-1/2",ke=`${t.mapping||"CI run"}: ${t.state}${t.summary?`, ${t.summary.passed} of ${t.summary.total} passed`:""}, ${V(t.at)}`,Ce=`block w-full rounded-sm transition-opacity hover:opacity-80 focus:outline-none focus-visible:ring-2 focus-visible:ring-brand-400 ${oe}`;return e.jsxs("div",{role:"listitem",className:"relative flex-1 max-w-[14px] h-full flex items-end",onMouseEnter:()=>ee(u),onMouseLeave:()=>ee(H=>H===u?null:H),children:[t.runId?e.jsx("a",{href:`/results?runId=${encodeURIComponent(t.runId)}`,target:"_blank",rel:"noopener noreferrer","aria-label":`${ke} — open the report`,onFocus:()=>ee(u),onBlur:()=>ee(H=>H===u?null:H),className:Ce,style:{height:`${te}%`}}):e.jsx("span",{tabIndex:0,"aria-label":ke,onFocus:()=>ee(u),onBlur:()=>ee(H=>H===u?null:H),className:Ce,style:{height:`${te}%`}}),Me===u&&e.jsxs("div",{className:`absolute bottom-full mb-2 ${U} z-50 pointer-events-none w-64 rounded-xl bg-surface-1 border border-white/10 shadow-xl shadow-black/30 p-3.5 text-left`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 mb-2.5",children:[e.jsx("span",{className:"text-sm font-semibold text-gray-100 truncate",children:t.mapping||"CI run"}),e.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full border flex-shrink-0 ${Pe[t.state]||Pe.failed}`,children:t.state})]}),e.jsxs("div",{className:"space-y-1.5 text-xs",children:[t.branch&&e.jsxs("div",{className:"flex justify-between gap-3",children:[e.jsx("span",{className:"text-gray-500",children:"Branch"}),e.jsx("span",{className:"text-gray-200 truncate",children:t.branch})]}),t.summary&&e.jsxs("div",{className:"flex justify-between gap-3",children:[e.jsx("span",{className:"text-gray-500",children:"Result"}),e.jsxs("span",{className:"text-gray-200",children:[e.jsx("span",{className:"text-emerald-400",children:t.summary.passed})," / ",t.summary.total," passed",t.summary.failed>0&&e.jsxs("span",{className:"text-red-400",children:[" · ",t.summary.failed," failed"]})]})]}),t.error&&e.jsx("div",{className:"text-amber-300 line-clamp-2",children:t.error}),e.jsxs("div",{className:"flex justify-between gap-3",children:[e.jsx("span",{className:"text-gray-500",children:"Duration"}),e.jsx("span",{className:"text-gray-200",children:pe(t.durationMs)})]}),e.jsxs("div",{className:"flex justify-between gap-3",children:[e.jsx("span",{className:"text-gray-500",children:"When"}),e.jsxs("span",{className:"text-gray-200",children:[V(t.at)," · ",new Date(t.at).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})]})]})]}),t.runId&&e.jsx("div",{className:"mt-2.5 pt-2 border-t border-white/10 text-xs text-brand-300",children:"Click the bar to open the full report →"})]})]},t.ciRunId)})})]})]}),i==="pipelines"&&e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("h2",{className:"text-base font-semibold text-gray-100 flex items-center gap-2",children:[e.jsx(Le,{size:17,className:"text-brand-300"})," Pipeline Mappings"]}),l&&e.jsxs("button",{onClick:()=>G({enabled:!0,target:{type:"suite"}}),className:"flex items-center gap-1.5 px-3.5 py-2 rounded-xl text-sm font-medium bg-brand-600 hover:bg-brand-500 text-white transition-colors",children:[e.jsx(Ye,{size:14})," New Mapping"]})]}),N.isError?e.jsx(Re,{what:"pipeline mappings",error:N.error,onRetry:()=>N.refetch()}):N.isLoading?e.jsxs("div",{className:"py-8 text-center text-gray-500 text-sm",children:[e.jsx(J,{size:16,className:"animate-spin inline mr-2"}),"Loading…"]}):v.length===0?e.jsxs("div",{className:"py-10 text-center rounded-xl border border-dashed border-white/10 text-sm text-gray-500",children:["No pipeline mappings yet — ",l?"create one to let CI (or the CLI) trigger runs on this server.":"a tester or admin can create one."]}):e.jsx("div",{className:"space-y-2",children:v.map(t=>{var te,me,oe;const u=t.target.type==="suite"?je(t.target.suiteId):void 0,f=t.target.type==="cycle"&&t.target.cycleId?R==null?void 0:R[t.target.cycleId]:void 0,xe=t.target.type==="suite"&&O.length>0&&!u||t.target.type==="cycle"&&f===null;return e.jsxs("div",{className:`flex items-center gap-3 px-4 py-3 rounded-xl bg-surface-1 border border-white/5 ${t.enabled?"":"opacity-60"}`,children:[e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-brand-500/15 text-brand-300 border border-brand-500/25 flex-shrink-0",children:et[t.target.type]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-sm font-medium text-gray-200",children:t.name}),!t.enabled&&e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-white/5 text-gray-500",children:"disabled"}),t.previousNames&&t.previousNames.length>0&&e.jsxs("span",{className:"text-xs text-gray-500",title:"CI files that still use an old name keep triggering this mapping",children:["also answers to ",t.previousNames.map(U=>`"${U}"`).join(", "),l&&e.jsx("button",{onClick:async()=>{try{await gt(t.id),Z()}catch(U){D((U==null?void 0:U.message)||String(U))}},className:"ml-1.5 text-brand-300 hover:text-brand-200 underline-offset-2 hover:underline",children:"Forget old names"})]})]}),e.jsxs("div",{className:"text-sm text-gray-400 truncate",children:[t.target.type==="command"&&e.jsx("code",{children:t.target.command}),t.target.type==="suite"&&e.jsxs(e.Fragment,{children:["→ ",u||e.jsx("code",{children:t.target.suiteId})]}),t.target.type==="cycle"&&e.jsxs(e.Fragment,{children:["→ ",f!=null&&f.name?`Cycle "${f.name}"`:e.jsxs(e.Fragment,{children:["Cycle ",e.jsx("code",{children:t.target.cycleId})]})]}),xe&&e.jsxs("span",{className:"ml-2 text-amber-400",children:[e.jsx(Ae,{size:12,className:"inline -mt-0.5"})," no longer exists — triggers will fail"]}),((te=t.overrides)==null?void 0:te.environment)&&e.jsxs("span",{className:"ml-2",children:["env: ",t.overrides.environment]}),((me=t.overrides)==null?void 0:me.browser)&&e.jsxs("span",{className:"ml-2",children:["browser: ",t.overrides.browser]}),((oe=t.statusPush)==null?void 0:oe.enabled)&&e.jsxs("span",{className:"ml-2 text-brand-400/80",children:["PR status → ",t.statusPush.provider]}),e.jsxs("span",{className:"ml-2",children:["· last triggered ",V(t.lastTriggeredAt)]})]})]}),l&&e.jsx("button",{onClick:()=>void ze(t),role:"switch","aria-checked":t.enabled,"aria-label":`${t.enabled?"Disable":"Enable"} ${t.name}`,title:t.enabled?"Enabled — click to disable":"Disabled — click to enable",className:`relative w-9 h-5 rounded-full transition-colors flex-shrink-0 ${t.enabled?"bg-brand-500":"bg-surface-3 border border-white/10"}`,children:e.jsx("span",{className:`absolute top-0.5 left-0.5 w-4 h-4 rounded-full bg-white shadow transition-transform ${t.enabled?"translate-x-4":""}`})}),l&&e.jsx("button",{onClick:()=>Y(t),title:"Get pipeline config + CLI snippet","aria-label":`Wire ${t.name} into CI`,className:"p-2 rounded-lg text-gray-400 hover:text-brand-300 hover:bg-white/5 transition-colors",children:e.jsx(Ee,{size:15})}),l&&e.jsx("button",{onClick:()=>G(t),title:"Edit","aria-label":`Edit ${t.name}`,className:"p-2 rounded-lg text-gray-400 hover:text-gray-200 hover:bg-white/5 transition-colors",children:e.jsx(Et,{size:15})}),l&&e.jsx("button",{onClick:()=>m(t),title:"Delete","aria-label":`Delete ${t.name}`,className:"p-2 rounded-lg text-gray-400 hover:text-red-300 hover:bg-white/5 transition-colors",children:e.jsx(Pt,{size:15})})]},t.id)})})]}),i==="tokens"&&e.jsxs("section",{children:[e.jsxs("h2",{className:"text-base font-semibold text-gray-100 flex items-center gap-2 mb-1",children:[e.jsx(Ge,{size:17,className:"text-amber-300"})," CI Tokens"]}),e.jsxs("p",{className:"text-sm text-gray-400 mb-3",children:["Machine tokens for the Gate API. Store one as ",e.jsx("code",{children:"TESTVER_CI_TOKEN"})," in your CI platform's secrets. The value is shown ",e.jsx("b",{children:"once"})," at creation. A token triggers only the pipeline mappings it is scoped to — ad-hoc suites, cycles and commands need a token that allows them."]}),a?e.jsx(Vt,{pipelines:v,onCreated:t=>{le(t),Z()}}):e.jsx("p",{className:"text-sm text-gray-500 mb-3 px-3 py-2 rounded-lg bg-surface-2 border border-white/5",children:"Only admins can create or revoke CI tokens."}),g.isError?e.jsx(Re,{what:"CI tokens",error:g.error,onRetry:()=>g.refetch()}):g.isLoading?e.jsxs("div",{className:"py-6 text-center text-gray-500 text-sm",children:[e.jsx(J,{size:16,className:"animate-spin inline mr-2"}),"Loading…"]}):F.length===0?e.jsxs("div",{className:"py-8 text-center rounded-xl border border-dashed border-white/10 text-sm text-gray-500",children:["No active CI tokens.",a?" Create one above, then add it to your CI platform's secrets.":""]}):e.jsx("div",{className:"space-y-1.5",children:F.map(t=>e.jsx(Ke,{token:t,pipelines:v,onRevoke:a?()=>de({id:t.id,name:t.name}):void 0},t.id))}),$.length>0&&e.jsxs("div",{className:"mt-4",children:[e.jsxs("button",{onClick:()=>ye(t=>!t),"aria-expanded":be,className:"text-sm text-gray-500 hover:text-gray-300",children:[be?"▾":"▸"," Revoked tokens (",$.length,")"]}),be&&e.jsx("div",{className:"space-y-1.5 mt-2",children:$.map(t=>e.jsx(Ke,{token:t,pipelines:v},t.id))})]})]}),i==="dashboard"&&d&&(d.perPipeline.length>0||d.perBranch.length>0)&&e.jsxs("section",{children:[e.jsxs("h2",{className:"text-base font-semibold text-gray-100 flex items-center gap-2 mb-3",children:[e.jsx($t,{size:17,className:"text-purple-300"})," Insights"]}),e.jsx("p",{className:"text-sm text-gray-500 -mt-2 mb-3",children:"Click a row to see its runs."}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-3",children:[e.jsx(qe,{title:"By Pipeline",rows:d.perPipeline,onSelect:t=>x({tab:"ci-runs",pipeline:t,branch:null,env:null,state:null})}),e.jsx(qe,{title:"By Branch",rows:d.perBranch,onSelect:t=>x({tab:"ci-runs",branch:t,pipeline:null,env:null,state:null})}),e.jsx(qe,{title:"By Environment",rows:d.perEnvironment,onSelect:t=>x({tab:"ci-runs",env:t,pipeline:null,branch:null,state:null})})]})]}),i==="trace"&&e.jsx(Jt,{}),i==="dashboard"&&d&&d.totals.runs>0&&e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("h2",{className:"text-base font-semibold text-gray-100 flex items-center gap-2",children:[e.jsx(ue,{size:17,className:"text-blue-300"})," Recent CI Runs",e.jsx("span",{className:"text-sm text-gray-500 font-normal",children:"(last 5)"})]}),e.jsx("button",{onClick:()=>w("ci-runs"),className:"text-sm text-brand-300 hover:text-brand-200 font-medium",children:"View all runs →"})]}),e.jsx(We,{runs:S.slice(0,5),onCancel:l?p:void 0})]}),i==="ci-runs"&&e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3 flex-wrap gap-2",children:[e.jsxs("h2",{className:"text-base font-semibold text-gray-100 flex items-center gap-2",children:[e.jsx(ue,{size:17,className:"text-blue-300"})," CI Runs",e.jsxs("span",{className:"text-sm text-gray-500 font-normal",children:[_?`${L.length} of ${S.length}`:`${S.length} total`,(((we=j.data)==null?void 0:we.total)||0)>S.length&&` (latest ${S.length} of ${j.data.total})`]})]}),S.length>0&&e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.jsxs("select",{value:A||"",onChange:t=>x({state:t.target.value||null}),"aria-label":"Filter by state",className:"px-2.5 py-1.5 rounded-lg bg-surface-2 border border-white/10 text-sm text-gray-900 dark:text-gray-200 focus:outline-none",children:[e.jsx("option",{value:"",children:"All states"}),["running","queued","passed","failed","cancelled","error"].map(t=>e.jsx("option",{value:t,children:t},t))]}),e.jsxs("select",{value:k||"",onChange:t=>x({pipeline:t.target.value||null}),"aria-label":"Filter by pipeline",className:"px-2.5 py-1.5 rounded-lg bg-surface-2 border border-white/10 text-sm text-gray-900 dark:text-gray-200 focus:outline-none",children:[e.jsx("option",{value:"",children:"All pipelines"}),[...new Set(S.map(t=>t.mappingName).filter(Boolean))].map(t=>e.jsx("option",{value:t,children:t},t))]}),e.jsxs("select",{value:M||"",onChange:t=>x({env:t.target.value||null}),"aria-label":"Filter by environment",className:"px-2.5 py-1.5 rounded-lg bg-surface-2 border border-white/10 text-sm text-gray-900 dark:text-gray-200 focus:outline-none",children:[e.jsx("option",{value:"",children:"All environments"}),[...new Set(S.map(t=>t.environment).filter(Boolean))].map(t=>e.jsx("option",{value:t,children:t},t))]}),e.jsx("input",{value:B||"",onChange:t=>x({branch:t.target.value||null}),placeholder:"Branch…","aria-label":"Filter by branch",className:"px-2.5 py-1.5 rounded-lg bg-surface-2 border border-white/10 text-sm text-gray-200 placeholder-gray-600 focus:outline-none w-32"}),_&&e.jsx("button",{onClick:ce,className:"text-sm text-gray-500 hover:text-gray-300 px-1.5",title:"Clear all filters",children:"✕ Clear"})]})]}),j.isError?e.jsx(Re,{what:"CI runs",error:j.error,onRetry:()=>j.refetch()}):j.isLoading?e.jsxs("div",{className:"py-8 text-center text-gray-500 text-sm",children:[e.jsx(J,{size:16,className:"animate-spin inline mr-2"}),"Loading…"]}):S.length===0?e.jsxs("div",{className:"py-10 text-center rounded-xl border border-dashed border-white/10 text-sm text-gray-500",children:["No CI-triggered runs yet. Trigger one with ",e.jsx("code",{children:'testver trigger --mapping "…"'})," or from your pipeline."]}):e.jsxs(e.Fragment,{children:[e.jsx(We,{runs:re,emptyNote:"No runs match the filters.",onCancel:l?p:void 0}),E>1&&e.jsxs("div",{className:"flex items-center justify-between gap-3 px-4 py-2.5 mt-2 rounded-xl border border-white/5 bg-surface-1 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 text-gray-500",children:[e.jsx("span",{children:"Rows per page:"}),e.jsx("select",{value:z,onChange:t=>{ae(Number(t.target.value)),I(0)},"aria-label":"Rows per page",className:"bg-surface-2 border border-white/10 rounded px-2 py-1 text-gray-900 dark:text-gray-200 focus:outline-none focus:border-brand-500/40",children:[10,20,50,100].map(t=>e.jsx("option",{value:t,children:t},t))})]}),e.jsxs("div",{className:"flex items-center gap-2 text-gray-500",children:[e.jsxs("span",{children:["Showing ",T*z+1,"–",Math.min((T+1)*z,L.length)," of ",L.length," run",L.length===1?"":"s"]}),e.jsxs("div",{className:"flex items-center gap-1 ml-2",children:[e.jsx("button",{onClick:()=>I(0),disabled:T===0,title:"First page","aria-label":"First page",className:"px-2 py-1 rounded hover:bg-white/5 disabled:opacity-30 disabled:cursor-not-allowed text-gray-400",children:"«"}),e.jsx("button",{onClick:()=>I(t=>Math.max(0,t-1)),disabled:T===0,title:"Previous page",className:"px-2 py-1 rounded hover:bg-white/5 disabled:opacity-30 disabled:cursor-not-allowed text-gray-400",children:"‹ Prev"}),e.jsxs("span",{className:"px-2 text-gray-400",children:["Page ",e.jsx("span",{className:"text-gray-900 dark:text-gray-200 font-medium",children:T+1})," of ",E]}),e.jsx("button",{onClick:()=>I(t=>Math.min(E-1,t+1)),disabled:T>=E-1,title:"Next page",className:"px-2 py-1 rounded hover:bg-white/5 disabled:opacity-30 disabled:cursor-not-allowed text-gray-400",children:"Next ›"}),e.jsx("button",{onClick:()=>I(E-1),disabled:T>=E-1,title:"Last page","aria-label":"Last page",className:"px-2 py-1 rounded hover:bg-white/5 disabled:opacity-30 disabled:cursor-not-allowed text-gray-400",children:"»"})]})]})]})]})]})]})}),ne&&e.jsx(Qt,{mapping:ne,suites:O,onClose:()=>G(null),onSaved:()=>{G(null),Z()}}),y&&e.jsx(Zt,{mapping:y,hasToken:F.length>0,onOpenTokens:()=>{Y(null),w("tokens")},onClose:()=>Y(null)}),ge&&e.jsx(Wt,{raw:ge.raw,token:ge.token,pipelines:v,onClose:()=>le(null)}),W&&e.jsx(Te,{open:!0,title:`Delete mapping "${W.name}"?`,description:"CI jobs and scripts triggering this mapping name will start failing with 404. This does not affect past runs.",confirmLabel:"Delete",variant:"danger",onCancel:()=>m(null),onConfirm:async()=>{try{await bt(W.id),Z()}catch(t){D((t==null?void 0:t.message)||String(t))}m(null)}}),Q&&e.jsx(Te,{open:!0,title:`Revoke token "${Q.name}"?`,description:"Every CI job or script using this token immediately loses access. This cannot be undone.",confirmLabel:"Revoke",variant:"danger",onCancel:()=>de(null),onConfirm:async()=>{try{await yt(Q.id),Z()}catch(t){D((t==null?void 0:t.message)||String(t))}de(null)}}),X&&e.jsx(Te,{open:!0,title:`Cancel this ${X.mappingName||"CI"} run?`,description:X.state==="queued"?'It leaves the queue and its CI job fails with "cancelled".':'The tests stop on the Testver server and the CI job fails with "cancelled".',confirmLabel:"Cancel run",variant:"danger",onCancel:()=>p(null),onConfirm:async()=>{try{await ft(X.id),Z()}catch(t){D((t==null?void 0:t.message)||String(t))}p(null)}})]})}function nt(s,o){const l=s==null?void 0:s.mappingIds,a=l?l.length===0?"no pipeline mappings":l.map(w=>{var x;return((x=o.find(N=>N.id===w))==null?void 0:x.name)||"a deleted mapping"}).join(", "):"all pipeline mappings",i=(s==null?void 0:s.adHoc)??"none";return i==="commands"?`${a} + ad-hoc suites, cycles and shell commands`:i==="suites"?`${a} + ad-hoc suites and cycles`:a}function Ke({token:s,pipelines:o,onRevoke:l}){var i;const a=!!s.expiresAt&&new Date(s.expiresAt).getTime()<=Date.now();return e.jsxs("div",{className:`flex items-center gap-3 px-4 py-2.5 rounded-xl bg-surface-1 border border-white/5 text-sm ${s.revoked||a?"opacity-70":""}`,children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"font-medium text-gray-200",children:s.name}),e.jsxs("code",{className:"text-xs text-gray-500",children:[s.prefix,"…"]}),s.revoked&&e.jsxs("span",{className:"text-xs px-1.5 py-0.5 rounded bg-white/5 text-gray-500",children:["revoked ",V(s.revokedAt),s.revokedBy?` by ${s.revokedBy}`:""]}),!s.revoked&&s.expiresAt&&e.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded ${a?"bg-red-500/10 text-red-300":"bg-white/5 text-gray-400"}`,children:tt(s.expiresAt)}),(((i=s.scope)==null?void 0:i.adHoc)??"none")==="commands"&&!s.revoked&&e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-amber-500/10 text-amber-300",title:"Can run any shell command on this server",children:"runs commands"})]}),e.jsxs("div",{className:"text-xs text-gray-500 mt-0.5 truncate",children:["Triggers ",nt(s.scope,o)]})]}),e.jsxs("span",{className:"text-sm text-gray-500 whitespace-nowrap",children:["created ",V(s.createdAt),s.createdBy?` by ${s.createdBy}`:""," · last used ",V(s.lastUsedAt)]}),l&&e.jsx("button",{onClick:l,title:"Revoke","aria-label":`Revoke ${s.name}`,className:"p-1.5 rounded-lg text-red-400 hover:text-red-600 dark:hover:text-red-500 hover:bg-red-500/10 transition-colors",children:e.jsx(Mt,{size:15})})]})}function Vt({pipelines:s,onCreated:o}){const[l,a]=n.useState(""),[i,w]=n.useState(!0),[x,N]=n.useState([]),[g,j]=n.useState("none"),[b,c]=n.useState("365"),[d,v]=n.useState(!1),[P,F]=n.useState(null),$=!!l.trim()&&!d&&(i||x.length>0||g!=="none"),S=async()=>{if($){v(!0),F(null);try{const h=await kt({name:l.trim(),scope:{mappingIds:i?void 0:x,adHoc:g},expiresInDays:b?Number(b):void 0});a(""),N([]),w(!0),j("none"),o(h)}catch(h){F((h==null?void 0:h.message)||String(h))}finally{v(!1)}}};return e.jsxs("div",{className:"mb-4 p-4 rounded-xl bg-surface-1 border border-white/5 space-y-3",children:[e.jsxs("div",{className:"flex items-end gap-2 flex-wrap",children:[e.jsxs("label",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-xs text-gray-500",children:"Name"}),e.jsx("input",{value:l,onChange:h=>a(h.target.value),maxLength:60,onKeyDown:h=>{h.key==="Enter"&&S()},placeholder:"e.g. github-pr-gate",className:"px-3 py-2 rounded-xl bg-surface-2 border border-white/10 text-sm text-gray-200 placeholder-gray-600 focus:outline-none focus:border-brand-500/50 w-64"})]}),e.jsxs("label",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-xs text-gray-500",children:"Expires"}),e.jsxs("select",{value:b,onChange:h=>c(h.target.value),className:"px-3 py-2 rounded-xl bg-surface-2 border border-white/10 text-sm text-gray-900 dark:text-gray-200 focus:outline-none focus:border-brand-500/50",children:[e.jsx("option",{value:"30",children:"in 30 days"}),e.jsx("option",{value:"90",children:"in 90 days"}),e.jsx("option",{value:"365",children:"in 1 year"}),e.jsx("option",{value:"",children:"never"})]})]}),e.jsxs("button",{disabled:!$,onClick:()=>void S(),className:"flex items-center gap-1.5 px-3.5 py-2 rounded-xl text-sm font-medium bg-brand-600 hover:bg-brand-500 text-white transition-colors disabled:opacity-50",children:[d?e.jsx(J,{size:14,className:"animate-spin"}):e.jsx(Ye,{size:14})," Create Token"]})]}),e.jsxs("fieldset",{children:[e.jsx("legend",{className:"text-xs text-gray-500 mb-1",children:"May trigger"}),e.jsxs("div",{className:"flex flex-col gap-1.5 text-sm text-gray-300",children:[e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"radio",name:"tok-scope",checked:i,onChange:()=>w(!0),className:"accent-brand-500"}),"Every pipeline mapping"]}),e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"radio",name:"tok-scope",checked:!i,onChange:()=>w(!1),className:"accent-brand-500"}),"Only these mappings:"]}),!i&&e.jsxs("div",{className:"ml-6 flex flex-wrap gap-x-4 gap-y-1",children:[s.length===0&&e.jsx("span",{className:"text-xs text-gray-500",children:"No mappings yet."}),s.map(h=>e.jsxs("label",{className:"flex items-center gap-1.5 text-sm",children:[e.jsx("input",{type:"checkbox",checked:x.includes(h.id),className:"accent-brand-500",onChange:R=>N(A=>R.target.checked?[...A,h.id]:A.filter(k=>k!==h.id))}),h.name]},h.id))]})]})]}),e.jsxs("fieldset",{children:[e.jsxs("legend",{className:"text-xs text-gray-500 mb-1",children:["Ad-hoc targets (CLI ",e.jsx("code",{children:"--suite"})," / ",e.jsx("code",{children:"--cycle"})," / ",e.jsx("code",{children:"--command"}),")"]}),e.jsx("div",{className:"flex flex-wrap gap-x-4 gap-y-1.5 text-sm text-gray-300",children:[["none","Not allowed"],["suites","Any suite or cycle"],["commands","Suites, cycles and shell commands"]].map(([h,R])=>e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"radio",name:"tok-adhoc",checked:g===h,onChange:()=>j(h),className:"accent-brand-500"}),R]},h))}),g==="commands"&&e.jsx("p",{className:"mt-1.5 text-xs px-3 py-2 rounded-lg bg-amber-500/10 border border-amber-500/25 text-amber-300",children:"⚠ Anyone holding this token can run any shell command on this Testver server. Prefer a pipeline mapping with a fixed command, and only allow this for a trusted, private pipeline."})]}),P&&e.jsx("p",{role:"alert",className:"text-sm text-red-300",children:P})]})}function Wt({raw:s,token:o,pipelines:l,onClose:a}){const[i,w]=n.useState(null),[x,N]=n.useState(!1),g=()=>{i==="ok"?a():N(!0)};Be(g);const j=window.location.origin,b=at(j);return e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4",children:[e.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"new-token-title",className:"w-full max-w-xl rounded-2xl bg-surface-1 border border-white/10 p-6",children:[e.jsxs("h3",{id:"new-token-title",className:"text-base font-semibold text-gray-100 mb-2",children:['CI token "',o.name,'" created']}),e.jsx("p",{className:"text-xs text-amber-300 mb-3",children:"Copy it now — this is the only time it will be shown."}),e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2.5 rounded-xl bg-surface-2 border border-white/10",children:[e.jsx("code",{className:"text-xs text-gray-200 break-all flex-1 select-all",children:s}),e.jsx("button",{onClick:async()=>{w(await Je(s)?"ok":"fail")},"aria-label":"Copy the token",className:"p-1.5 rounded-lg text-gray-400 hover:text-gray-200",children:i==="ok"?e.jsx(Ie,{size:14,className:"text-emerald-400"}):e.jsx(Oe,{size:14})})]}),i==="fail"&&e.jsx("p",{role:"alert",className:"text-xs text-red-300 mt-1.5",children:"Copying isn't available here — select the token above and copy it by hand."}),e.jsxs("div",{className:"mt-4 text-sm text-gray-400 space-y-1.5",children:[e.jsx("p",{className:"font-medium text-gray-300",children:"Next:"}),e.jsxs("ol",{className:"list-decimal ml-5 space-y-1",children:[e.jsxs("li",{children:["Add it to your CI platform's secrets as ",e.jsx("code",{children:"TESTVER_CI_TOKEN"}),"."]}),e.jsxs("li",{children:["Open a pipeline mapping's ",e.jsx(Ee,{size:12,className:"inline -mt-0.5"})," ",e.jsx("b",{children:"Wire into CI"})," to generate the pipeline file."]}),e.jsxs("li",{children:["CI reaches this server at ",b?e.jsxs("span",{className:"text-amber-300",children:["the address your CI runners can reach (this page's address, ",e.jsx("code",{children:j}),", is local)"]}):e.jsx("code",{children:j}),"."]})]}),e.jsxs("p",{className:"text-xs text-gray-500",children:["It may trigger ",nt(o.scope,l),o.expiresAt?` · ${tt(o.expiresAt)}`:" · never expires","."]})]}),e.jsx("div",{className:"mt-4 text-right",children:e.jsx("button",{onClick:g,className:"px-4 py-2 rounded-xl text-sm font-medium bg-brand-600 hover:bg-brand-500 text-white",children:"Done"})})]}),x&&e.jsx(Te,{open:!0,title:"Close without copying the token?",description:"It cannot be shown again — you would have to create a new token.",confirmLabel:"Close",variant:"danger",onCancel:()=>N(!1),onConfirm:a})]})}function Qt({mapping:s,suites:o,onClose:l,onSaved:a}){var Ne,we,t,u,f,xe,te,me,oe,U,ke,Ce,H,_e,De;Be(l);const[i,w]=n.useState(s.name||""),[x,N]=n.useState(((Ne=s.target)==null?void 0:Ne.type)||"suite"),[g,j]=n.useState(((we=s.target)==null?void 0:we.command)||""),[b,c]=n.useState(((t=s.target)==null?void 0:t.suiteId)||""),[d,v]=n.useState(""),[P,F]=n.useState(((u=s.target)==null?void 0:u.cycleId)||""),[$,S]=n.useState(((f=s.overrides)==null?void 0:f.environment)||""),[O,h]=n.useState(((xe=s.overrides)==null?void 0:xe.browser)||""),[R,A]=n.useState(s.autoHeal||"inherit"),[k,B]=n.useState(s.timeoutMinutes?String(s.timeoutMinutes):""),[M,L]=n.useState(!!((te=s.statusPush)!=null&&te.enabled)),[_,ce]=n.useState(((me=s.statusPush)==null?void 0:me.provider)||"github"),[se,I]=n.useState(((oe=s.statusPush)==null?void 0:oe.repo)||""),[z,ae]=n.useState(s.statusPush?"••••••••":""),[E,T]=n.useState(((U=s.statusPush)==null?void 0:U.baseUrl)||""),[re,ne]=n.useState(s.enabled!==!1),[G,W]=n.useState(!1),[m,y]=n.useState(null),Y={github:"owner/repo",gitlab:"group/project (or numeric id)","azure-devops":"org/project/repo",bitbucket:"workspace/repo"},ge={github:"PAT with repo:status (classic) or Commit statuses read/write (fine-grained)",gitlab:"Access token with api scope","azure-devops":"PAT with Code (Status) scope",bitbucket:"username:app_password with Repositories:Write (or a workspace access token)"},le=s.statusPush,Q=!!le&&(le.provider!==_||(le.baseUrl||"")!==E.trim()),de=z==="••••••••";n.useEffect(()=>{Q&&de&&ae("")},[Q,de]);const{data:X}=K({queryKey:["tm-plans"],queryFn:()=>jt(),enabled:x==="cycle"});K({queryKey:["ci-cycle-plan",(ke=s.target)==null?void 0:ke.cycleId],enabled:x==="cycle"&&!!((Ce=s.target)!=null&&Ce.cycleId)&&!d,queryFn:async()=>{const r=await Qe(s.target.cycleId).catch(()=>null);return r!=null&&r.planId&&v(r.planId),(r==null?void 0:r.planId)||null}});const{data:p}=K({queryKey:["tm-cycles",d],queryFn:()=>vt(d),enabled:x==="cycle"&&!!d}),be=((p==null?void 0:p.cycles)||[]).map(r=>r.id).join(","),{data:ye}=K({queryKey:["cycle-automation-counts",d,be],enabled:x==="cycle"&&!!d&&(((H=p==null?void 0:p.cycles)==null?void 0:H.length)||0)>0,queryFn:async()=>{const r=await Promise.all(p.cycles.map(async C=>{try{const he=await Nt(C.id);return[C.id,(he.executions||[]).filter(lt=>lt.hasMappedScript).length]}catch{return[C.id,-1]}}));return Object.fromEntries(r)}}),fe=r=>ye==null?void 0:ye[r],D=((p==null?void 0:p.cycles)||[]).filter(r=>(fe(r.id)??1)!==0).length,{browserOpts:Me,envOpts:ee}=It(),je=!!i.trim()&&!/^[A-Za-z0-9][A-Za-z0-9 ._-]*$/.test(i.trim()),Z=!!s.id&&!!s.name&&i.trim()!==s.name,ze=k.trim()!==""&&!(Number.isInteger(Number(k))&&Number(k)>=1&&Number(k)<=1440),q=[];i.trim()?je&&q.push("a valid name"):q.push("a name"),x==="command"&&!g.trim()&&q.push("the command"),x==="suite"&&!b&&q.push("a suite"),x==="cycle"&&!P&&q.push("a cycle"),ze&&q.push("a timeout between 1 and 1440 minutes"),M&&!se.trim()&&q.push("the repository for status push"),M&&!z.trim()&&q.push(Q?"the access token for the new git host":"the status push access token");const ve=q.length===0,ie="w-full px-3 py-2 rounded-xl bg-surface-2 border border-white/10 text-sm text-gray-900 dark:text-gray-200 focus:outline-none focus:border-brand-500/50";return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4",children:e.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"mapping-modal-title",className:"w-full max-w-2xl rounded-2xl bg-surface-1 border border-white/10 p-6 max-h-[90vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h3",{id:"mapping-modal-title",className:"text-base font-semibold text-gray-100",children:[s.id?"Edit":"New"," Pipeline Mapping"]}),e.jsx("button",{onClick:l,"aria-label":"Close",className:"text-gray-500 hover:text-gray-300",children:e.jsx($e,{size:16})})]}),e.jsx(rt,{message:m,onDismiss:()=>y(null)}),e.jsx("label",{htmlFor:"mapping-name",className:"block text-sm font-medium text-gray-300 mb-1",children:"Mapping name (the trigger key)"}),e.jsx("input",{id:"mapping-name",value:i,onChange:r=>w(r.target.value),placeholder:'e.g. "pr-gate-main"',maxLength:60,className:`w-full px-3 py-2 rounded-xl bg-surface-2 border text-sm text-gray-200 placeholder-gray-600 focus:outline-none mb-1 ${je?"border-red-500/50 focus:border-red-500/70":"border-white/10 focus:border-brand-500/50"}`}),je?e.jsx("p",{className:"text-xs text-red-400 mb-3",children:"This name can only contain letters, numbers, spaces, dots, dashes, and underscores — and must start with a letter or number. Special characters would break the generated CI config files."}):Z?e.jsxs("p",{className:"text-xs text-amber-300 mb-3",children:['CI files that use "',s.name,'" keep working — Testver remembers the old name. Update them to "',i.trim(),'" when you can, then forget the old name from the mapping list.']}):e.jsxs("p",{className:"text-xs text-gray-500 mb-3",children:["Your CI pipeline uses this exact name to trigger the run — e.g. ",e.jsxs("code",{children:['testver trigger --mapping "',i.trim()||"pr-gate-main",'"']}),". Allowed: letters, numbers, spaces, dots, dashes, underscores."]}),e.jsx("span",{className:"block text-sm font-medium text-gray-300 mb-1.5",children:"Execution target"}),e.jsx("div",{className:"flex gap-1.5 mb-3",role:"group","aria-label":"Execution target",children:["suite","cycle","command"].map(r=>e.jsx("button",{onClick:()=>N(r),"aria-pressed":x===r,className:`px-3.5 py-1.5 rounded-lg text-sm font-medium transition-colors ${x===r?"bg-brand-600 text-white":"bg-surface-2 text-gray-400 hover:text-gray-200"}`,children:et[r]},r))}),x==="suite"&&e.jsxs("select",{value:b,onChange:r=>c(r.target.value),className:`${ie} mb-4`,"aria-label":"Suite",children:[e.jsx("option",{value:"",children:"Select a suite…"}),o.map(r=>{var C;return e.jsxs("option",{value:r.id,children:[r.name," (",((C=r.tests)==null?void 0:C.length)||0," tests)"]},r.id)}),b&&!o.some(r=>r.id===b)&&e.jsxs("option",{value:b,children:["(deleted suite ",b,")"]})]}),x==="cycle"&&e.jsxs("div",{className:"grid grid-cols-2 gap-2 mb-4",children:[e.jsxs("select",{value:d,onChange:r=>{v(r.target.value),F("")},className:ie,"aria-label":"Test plan",children:[e.jsx("option",{value:"",children:"Select a plan…"}),((X==null?void 0:X.plans)||[]).map(r=>e.jsx("option",{value:r.id,children:r.name},r.id))]}),e.jsxs("select",{value:P,onChange:r=>F(r.target.value),className:ie,disabled:!d,"aria-label":"Test cycle",children:[e.jsx("option",{value:"",children:d?"Select a cycle…":"Pick a plan first"}),((p==null?void 0:p.cycles)||[]).map(r=>{const C=fe(r.id),he=C===0;return e.jsxs("option",{value:r.id,disabled:he,children:[r.name,C===void 0||C===-1?"":he?" — no automated scripts":` (${C} automated)`]},r.id)})]}),d&&(((_e=p==null?void 0:p.cycles)==null?void 0:_e.length)||0)>0&&D>0&&e.jsxs("p",{className:"col-span-2 text-xs text-gray-500",children:["CI triggers run a cycle's ",e.jsx("b",{className:"text-gray-400",children:"mapped automation scripts"})," — cycles without any are disabled here (",D," of ",p.cycles.length," cycle",p.cycles.length!==1?"s":""," in this plan ",D===1?"has":"have"," automated scripts). Map scripts under Script Mapping to enable a cycle."]}),d&&(((De=p==null?void 0:p.cycles)==null?void 0:De.length)||0)>0&&D===0&&e.jsx("p",{className:"col-span-2 text-xs px-3 py-2 rounded-lg bg-amber-500/10 border border-amber-500/25 text-amber-300",children:"⚠ None of this plan's cycles have mapped automation scripts — a CI trigger would fail. Pick a different plan or map automation scripts first (Script Mapping screen)."})]}),x==="command"&&e.jsx("textarea",{value:g,onChange:r=>j(r.target.value),rows:2,"aria-label":"Command",placeholder:"npx playwright test --grep @smoke",className:"w-full px-3 py-2 rounded-xl bg-surface-2 border border-white/10 text-sm text-gray-200 font-mono placeholder-gray-600 focus:outline-none focus:border-brand-500/50 mb-4"}),e.jsxs("span",{className:"block text-sm font-medium text-gray-300 mb-1.5",children:["Overrides ",e.jsxs("span",{className:"text-gray-600",children:["(optional — ",x==="command"?"the browser / environment entries from Settings → Run Commands":`defaults come from the ${x}'s saved settings`,")"]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2 mb-4",children:[e.jsxs("div",{children:[e.jsx("span",{className:"block text-xs text-gray-500 mb-1",children:"Environment"}),e.jsx(Ue,{isEnv:!0,value:$,onChange:S,options:ee})]}),e.jsxs("div",{children:[e.jsx("span",{className:"block text-xs text-gray-500 mb-1",children:"Browser"}),e.jsx(Ue,{isEnv:!1,value:O,onChange:h,options:Me})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-xs text-gray-500 mb-1",children:"Time limit (minutes)"}),e.jsx("input",{value:k,onChange:r=>B(r.target.value.replace(/[^0-9]/g,"")),inputMode:"numeric",placeholder:"240",className:`w-full px-3 py-2 rounded-xl bg-surface-2 border text-sm text-gray-200 placeholder-gray-600 focus:outline-none ${ze?"border-red-500/50":"border-white/10 focus:border-brand-500/50"}`})]})]}),e.jsxs("div",{className:"mb-3",children:[e.jsx("p",{className:"text-sm text-gray-300 mb-1",children:"Auto-Heal on this pipeline"}),e.jsx("div",{className:"inline-flex rounded-lg border border-white/10 bg-surface-2 overflow-hidden",role:"group","aria-label":"Auto-Heal on this pipeline",children:[["inherit","Inherit"],["off","Off"],["heal","Heal only"],["heal-regate","Heal + re-gate"]].map(([r,C],he)=>e.jsx("button",{type:"button",onClick:()=>A(r),className:`px-3 py-1.5 text-xs font-medium transition-colors ${he>0?"border-l border-white/10":""} ${R===r?"bg-purple-500/15 text-purple-600 dark:text-purple-300":"text-gray-500 hover:text-gray-300 hover:bg-white/5"}`,"aria-pressed":R===r,children:C},r))}),e.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:[e.jsx("b",{children:"Heal only"})," keeps the build result and heals in the workspace's mode (Suggest when the workspace is Off). ",e.jsx("b",{children:"Heal + re-gate"})," always keeps verified fixes (Auto) and holds the gate until healing finishes, so a fully-healed run turns the build green, labeled as auto-healed."," ",e.jsx("b",{children:"Inherit"})," follows Settings → General."]})]}),e.jsxs("label",{className:"flex items-start gap-2 text-sm text-gray-300 mb-2",children:[e.jsx("input",{type:"checkbox",checked:M,onChange:r=>L(r.target.checked),className:"accent-brand-500 mt-0.5"}),e.jsxs("span",{children:["Push commit statuses to the git host (PR decoration)",e.jsx("span",{className:"block text-xs text-gray-500",children:"Testver posts queued → running → success/failure statuses on the triggering commit, so PRs show the verdict — this is what enables the fire-and-forget CI job mode."})]})]}),M&&e.jsxs("div",{className:"ml-6 mb-3 space-y-2",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("select",{value:_,onChange:r=>ce(r.target.value),className:ie,"aria-label":"Git host",children:[e.jsx("option",{value:"github",children:"GitHub"}),e.jsx("option",{value:"gitlab",children:"GitLab"}),e.jsx("option",{value:"azure-devops",children:"Azure DevOps"}),e.jsx("option",{value:"bitbucket",children:"Bitbucket"})]}),e.jsx("input",{value:se,onChange:r=>I(r.target.value),placeholder:Y[_],"aria-label":"Repository",className:"px-3 py-2 rounded-xl bg-surface-2 border border-white/10 text-sm text-gray-200 font-mono placeholder-gray-600 focus:outline-none"})]}),e.jsx("input",{value:z,onChange:r=>ae(r.target.value),type:"password",autoComplete:"new-password","aria-label":"Access token",placeholder:le&&!Q?"Token saved — type to replace":"Access token",className:"w-full px-3 py-2 rounded-xl bg-surface-2 border border-white/10 text-sm text-gray-200 placeholder-gray-600 focus:outline-none"}),Q&&e.jsx("p",{className:"text-xs text-amber-300",children:"The git host changed — enter the access token for it. The saved token is not sent to a different host."}),e.jsxs("p",{className:"text-xs text-gray-600 -mt-1",children:[ge[_],". Stored encrypted on this server, never returned to the browser."]}),e.jsx("input",{value:E,onChange:r=>T(r.target.value),"aria-label":"Self-hosted base URL",placeholder:"Self-hosted base URL (optional — GHE / self-managed GitLab / Azure Server)",className:"w-full px-3 py-2 rounded-xl bg-surface-2 border border-white/10 text-sm text-gray-200 placeholder-gray-600 focus:outline-none"})]}),e.jsxs("label",{className:"flex items-center gap-2 text-sm text-gray-300 mb-5",children:[e.jsx("input",{type:"checkbox",checked:re,onChange:r=>ne(r.target.checked),className:"accent-brand-500"}),"Enabled (triggers are rejected while disabled)"]}),e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[!ve&&e.jsxs("span",{className:"text-xs text-gray-500 mr-auto",children:["Still needed: ",q.join(", ")]}),e.jsx("button",{onClick:l,className:"px-4 py-2 rounded-xl text-sm text-gray-400 hover:text-gray-200",children:"Cancel"}),e.jsxs("button",{disabled:!ve||G,onClick:async()=>{var r;W(!0),y(null);try{await Ze({id:s.id,name:i.trim(),target:{type:x,command:x==="command"?g.trim():void 0,suiteId:x==="suite"?b:void 0,cycleId:x==="cycle"?P||((r=s.target)==null?void 0:r.cycleId):void 0},overrides:$||O?{environment:$||void 0,browser:O||void 0}:void 0,autoHeal:R,timeoutMinutes:k.trim()?Number(k):void 0,statusPush:M?{enabled:!0,provider:_,repo:se.trim(),token:z.trim(),baseUrl:E.trim()||void 0}:void 0,enabled:re}),a()}catch(C){y((C==null?void 0:C.message)||String(C)),W(!1)}},className:"flex items-center gap-1.5 px-4 py-2 rounded-xl text-sm font-medium bg-brand-600 hover:bg-brand-500 text-white disabled:opacity-50",children:[G&&e.jsx(J,{size:13,className:"animate-spin"}),s.id?"Save Changes":"Create Mapping"]})]})]})})}const Ve=[{id:"github-actions",label:"GitHub Actions",note:"Add TESTVER_CI_TOKEN as a repository secret (Settings → Secrets and variables → Actions). Pull requests report on their own commit."},{id:"gitlab-ci",label:"GitLab CI",note:"Add TESTVER_CI_TOKEN as a masked CI/CD variable. This file is the repo's .gitlab-ci.yml — saving replaces any existing pipeline. Merge requests are gated once (no duplicate branch pipeline)."},{id:"jenkins",label:"Jenkins",note:`Add a Secret Text credential with id "testver-ci-token", then set the job's Script Path to Jenkinsfile.testver-gate. The agent needs curl + jq.`,branchNote:"Jenkins decides which branches build in the job settings — the branch list is not used."},{id:"azure-pipelines",label:"Azure Pipelines",note:`Create a pipeline from azure-testver-gate.yml (Pipelines → New → Existing Azure Pipelines YAML file), then add TESTVER_CI_TOKEN as a secret variable ("Keep this value secret"). PR builds report on the PR's own commit.`},{id:"bitbucket",label:"Bitbucket",note:"Add TESTVER_CI_TOKEN as a SECURED repository variable (Repository settings → Repository variables). This is the repo's bitbucket-pipelines.yml — saving replaces any existing pipeline."},{id:"circleci",label:"CircleCI",note:"Add TESTVER_CI_TOKEN as a project environment variable (Project Settings → Environment Variables). This is the repo's .circleci/config.yml — saving replaces any existing config.",branchNote:'CircleCI filters by the pushed branch: listing branches means only those are gated — pull request branches too need "*" to be gated.'}];function Zt({mapping:s,hasToken:o,onOpenTokens:l,onClose:a}){var W;Be(a);const[i,w]=n.useState(window.location.origin),[x,N]=n.useState("github-actions"),[g,j]=n.useState(!1),[b,c]=n.useState("main"),[d,v]=n.useState(null),[P,F]=n.useState(".github/workflows/testver-gate.yml"),[$,S]=n.useState(!1),[O,h]=n.useState(!1),[R,A]=n.useState(!1),[k,B]=n.useState(!1),[M,L]=n.useState(!1),[_,ce]=n.useState(null),[se,I]=n.useState(null),z=n.useMemo(()=>at(i),[i]),ae=b.split(",").map(m=>m.trim()).filter(Boolean),E=Ve.find(m=>m.id===x),T=()=>{v(null),B(!1),I(null)},re=`npx -y testver trigger --server ${i} --mapping "${s.name}"`,ne=async(m,y)=>{await Je(y)?(ce(m),setTimeout(()=>ce(Y=>Y===m?null:Y),1500)):I("Copying isn't available here — select the text and copy it by hand.")},G=async m=>{if(d){A(!0),I(null);try{await St({filePath:P,content:d,overwrite:m}),B(!0)}catch(y){(y==null?void 0:y.status)===409?L(!0):I((y==null?void 0:y.message)||String(y))}finally{A(!1)}}};return e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4",children:[e.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"wire-modal-title",className:"w-full max-w-5xl rounded-2xl bg-surface-1 border border-white/10 p-6 max-h-[90vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h3",{id:"wire-modal-title",className:"text-base font-semibold text-gray-100",children:['Wire "',s.name,'" into CI']}),e.jsx("button",{onClick:a,"aria-label":"Close",className:"text-gray-500 hover:text-gray-300",children:e.jsx($e,{size:16})})]}),e.jsx(rt,{message:se,onDismiss:()=>I(null)}),!o&&e.jsxs("div",{className:"mb-4 px-3 py-2.5 rounded-xl bg-amber-500/10 border border-amber-500/25 text-sm text-amber-300 flex items-center gap-3",children:[e.jsx(Ae,{size:15,className:"flex-shrink-0"}),e.jsxs("span",{className:"flex-1",children:["There is no active CI token yet — the pipeline needs one in its secrets as ",e.jsx("code",{children:"TESTVER_CI_TOKEN"}),"."]}),e.jsx("button",{onClick:l,className:"px-2.5 py-1 rounded-lg border border-amber-500/30 hover:bg-amber-500/10 text-xs font-medium whitespace-nowrap",children:"Go to CI Tokens"})]}),e.jsxs("label",{htmlFor:"wire-server-url",className:"block text-sm font-medium text-gray-300 mb-1",children:["Testver server URL ",e.jsx("span",{className:"text-gray-600",children:"(must be reachable from CI runners)"})]}),e.jsx("input",{id:"wire-server-url",value:i,onChange:m=>{w(m.target.value.trim()),T()},className:`w-full px-3 py-2 rounded-xl bg-surface-2 border text-sm text-gray-200 focus:outline-none mb-1 ${z?"border-amber-500/40":"border-white/10 focus:border-brand-500/50"}`}),z?e.jsxs("p",{className:"text-xs text-amber-300 mb-4",children:["⚠ ",z]}):e.jsx("div",{className:"mb-4"}),e.jsxs("span",{className:"block text-sm font-medium text-gray-300 mb-1 flex items-center gap-1.5",children:[e.jsx(Ht,{size:13})," From any terminal / script (exit 0 passed · 1 failed · 2 no verdict)"]}),e.jsxs("div",{className:"flex items-start gap-2 px-3 py-2.5 rounded-xl bg-surface-2 border border-white/10 mb-1",children:[e.jsx("pre",{className:"text-xs text-gray-300 whitespace-pre-wrap break-all flex-1 m-0",children:re}),e.jsx("button",{onClick:()=>void ne("cli",re),"aria-label":"Copy the CLI command",className:"p-1.5 rounded-lg text-gray-400 hover:text-gray-200",children:_==="cli"?e.jsx(Ie,{size:14,className:"text-emerald-400"}):e.jsx(Oe,{size:14})})]}),e.jsxs("p",{className:"text-xs text-gray-600 mb-4",children:["Needs Node.js (npx fetches the ",e.jsx("code",{children:"testver"})," CLI). Auth: set ",e.jsx("code",{children:"TESTVER_CI_TOKEN"})," (or pass ",e.jsx("code",{children:"--token"}),")."," ","Add ",e.jsx("code",{children:"--sha <commit> --branch <name>"})," to record the commit on the run (Trace, PR status)."," ","Add ",e.jsx("code",{children:"--no-wait"})," to return right away and let the commit status carry the verdict."]}),e.jsxs("span",{className:"block text-sm font-medium text-gray-300 mb-1.5 flex items-center gap-1.5",children:[e.jsx(Ee,{size:14})," Pipeline config",e.jsx("span",{className:"font-normal text-gray-500",children:"— the CI job triggers Testver and gates on the verdict; nothing is installed on the runner"})]}),e.jsx("span",{className:"block text-xs font-medium text-gray-500 uppercase tracking-wide mb-1.5",children:"Platform"}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-2 mb-4",children:Ve.map(m=>{const y=x===m.id;return e.jsxs("button",{onClick:()=>{N(m.id),T()},"aria-pressed":y,className:`relative flex items-center gap-2.5 px-3 py-2.5 rounded-xl border text-sm font-medium transition-colors text-left ${y?"bg-brand-500/10 border-brand-500 text-gray-900 dark:text-gray-100":"bg-surface-1 border-white/10 text-gray-600 dark:text-gray-300 hover:border-white/25 hover:bg-surface-2"}`,children:[e.jsx(Kt,{platform:m.id,size:18}),e.jsx("span",{className:"truncate",children:m.label}),y&&e.jsx(Ie,{size:14,className:"ml-auto text-brand-500 flex-shrink-0"})]},m.id)})}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mb-3",children:[e.jsxs("div",{children:[e.jsx("span",{className:"block text-xs font-medium text-gray-500 uppercase tracking-wide mb-1.5",children:"Gate mode"}),e.jsx("div",{className:"inline-flex p-1 rounded-xl bg-surface-2 border border-white/10",children:[{id:!1,label:"Wait & gate",hint:"exit code"},{id:!0,label:"Fire-and-forget",hint:"status push-back"}].map(m=>{const y=g===m.id;return e.jsxs("button",{onClick:()=>{j(m.id),T()},"aria-pressed":y,className:`px-3.5 py-2 rounded-lg text-sm font-medium transition-colors ${y?"bg-brand-600 text-white shadow-sm":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-200"}`,children:[m.label,e.jsxs("span",{className:`ml-1.5 text-xs ${y?"text-white/70":"text-gray-500"}`,children:["(",m.hint,")"]})]},String(m.id))})})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-xs font-medium text-gray-500 uppercase tracking-wide mb-1.5",children:"Branches"}),e.jsx("input",{value:b,onChange:m=>{c(m.target.value),T()},placeholder:"main, release/* ( * = every branch)",className:"w-full px-3 py-2 rounded-xl bg-surface-2 border border-white/10 text-sm text-gray-200 font-mono placeholder-gray-600 focus:outline-none focus:border-brand-500/50"}),e.jsx("span",{className:"block text-xs text-gray-500 mt-1",children:E.branchNote||"Pushes to these branches, and pull requests targeting them, run the gate. Comma-separated; * = every branch."})]})]}),g&&e.jsxs("p",{className:"text-xs mb-2 px-3 py-2 rounded-lg border bg-amber-500/10 border-amber-500/25 text-amber-300",children:["The job triggers and exits immediately — the PR verdict comes from the commit status Testver pushes.",(W=s.statusPush)!=null&&W.enabled?" Status push-back is configured on this mapping. ✓":' ⚠ Enable "Push commit statuses" on this mapping first, or the PR will never get a verdict.']}),e.jsxs("div",{className:"flex items-start justify-between gap-4 mb-3",children:[e.jsxs("p",{className:"flex-1 text-sm text-gray-500 dark:text-gray-400 leading-relaxed px-3 py-2 rounded-lg bg-surface-2 border border-white/5",children:[e.jsx("span",{className:"font-medium text-gray-700 dark:text-gray-300",children:"Setup: "}),E.note]}),e.jsxs("button",{disabled:O||ae.length===0,onClick:async()=>{h(!0),B(!1),I(null);try{const m=await wt({platform:x,options:{branches:ae,delegate:{mapping:s.name,serverUrl:i,noWait:g}}});v(m.content),F(m.filePath),S(!!m.exists)}catch(m){I((m==null?void 0:m.message)||String(m))}finally{h(!1)}},className:"flex items-center gap-1.5 px-4 py-2.5 rounded-xl text-sm font-medium bg-brand-600 hover:bg-brand-500 text-white disabled:opacity-50 flex-shrink-0 transition-colors",children:[O?e.jsx(J,{size:14,className:"animate-spin"}):e.jsx(Ee,{size:14}),d?"Regenerate":"Generate Config"]})]}),d&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative",children:[e.jsx("pre",{className:"px-3 py-2.5 rounded-xl bg-surface-2 border border-white/10 text-xs text-gray-300 overflow-auto max-h-80 whitespace-pre",children:d}),e.jsx("button",{onClick:()=>void ne("yaml",d),"aria-label":"Copy the pipeline config",className:"absolute top-2 right-2 p-1.5 rounded-lg bg-surface-1 text-gray-400 hover:text-gray-200",children:_==="yaml"?e.jsx(Ie,{size:14,className:"text-emerald-400"}):e.jsx(Oe,{size:14})})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 mt-3",children:[e.jsxs("span",{className:"text-xs text-gray-600",children:["Saves to ",e.jsx("code",{children:P})," in this project — commit & push it (token setup: see the note above).",$&&e.jsx("span",{className:"text-amber-300",children:" That file already exists — saving replaces it."})]}),e.jsxs("button",{disabled:R||k,onClick:()=>$?L(!0):void G(!1),className:"flex items-center gap-1.5 px-3.5 py-2 rounded-xl text-sm font-medium bg-emerald-600 hover:bg-emerald-500 text-white disabled:opacity-60 flex-shrink-0",children:[R?e.jsx(J,{size:13,className:"animate-spin"}):k?e.jsx(Ie,{size:13}):null,k?"Saved to project":"Save to project"]})]})]})]}),M&&e.jsx(Te,{open:!0,title:`Replace ${P}?`,description:"This file already exists in the project. Saving replaces its whole content with the Testver gate — anything else in it is lost (git still has the previous version).",confirmLabel:"Replace file",variant:"danger",onCancel:()=>L(!1),onConfirm:()=>{L(!1),G(!0)}})]})}function qe({title:s,rows:o,onSelect:l}){return e.jsxs("div",{className:"rounded-xl bg-surface-1 border border-white/5 overflow-hidden",children:[e.jsx("div",{className:"px-4 py-2.5 text-xs font-semibold text-gray-400 uppercase tracking-wide border-b border-white/5",children:s}),o.length===0?e.jsx("div",{className:"px-4 py-5 text-center text-xs text-gray-600",children:"No data yet"}):e.jsx("table",{className:"w-full text-sm",children:e.jsx("tbody",{children:o.slice(0,6).map(a=>e.jsxs("tr",{onClick:l?()=>l(a.key):void 0,className:`border-t border-white/5 first:border-t-0 ${l?"cursor-pointer hover:bg-white/[0.04] transition-colors":""}`,children:[e.jsx("td",{className:"px-4 py-2 text-gray-200 truncate max-w-[120px]",title:a.key,children:l?e.jsx("button",{onClick:i=>{i.stopPropagation(),l(a.key)},"aria-label":`Show runs for ${a.key}`,className:"text-left truncate max-w-full hover:text-brand-300 focus:outline-none focus-visible:underline",children:a.key}):a.key}),e.jsxs("td",{className:"px-2 py-2 text-gray-500 whitespace-nowrap",children:[a.runs," run",a.runs!==1?"s":""]}),e.jsxs("td",{className:`px-2 py-2 font-medium whitespace-nowrap ${st(a.passRate)}`,title:(a.errored||0)>0?`${a.errored} errored run(s) count against the pass rate`:void 0,children:[a.passRate,"%"]}),e.jsx("td",{className:"px-2 py-2 text-gray-500 whitespace-nowrap",children:pe(a.avgDurationMs)}),e.jsx("td",{className:"px-3 py-2 text-right",children:e.jsx("span",{className:`inline-block w-2 h-2 rounded-full ${a.lastState==="passed"?"bg-emerald-400":a.lastState==="failed"||a.lastState==="error"?"bg-red-400":a.lastState==="running"?"bg-sky-400 animate-pulse":a.lastState==="queued"?"border border-dashed border-gray-400 bg-transparent":"bg-gray-500"}`,title:`last: ${a.lastState} · ${V(a.lastAt)}`,"aria-label":`last run ${a.lastState}`})})]},a.key))})})]})}function Jt(){const[s,o]=Se("q"),[l,a]=n.useState(s||""),[i,w]=n.useState(null),[x,N]=n.useState(!1),[g,j]=n.useState(null),b=async(c=l)=>{const d=c.trim();if(d.length<2){j("Enter at least 2 characters — a commit sha (6 or more) or a branch name");return}N(!0),j(null),d!==s&&o(d);try{w(await Ct(d))}catch(v){j((v==null?void 0:v.message)||String(v)),w(null)}finally{N(!1)}};return n.useEffect(()=>{s&&!i&&b(s)},[]),e.jsxs("section",{children:[e.jsxs("h2",{className:"text-base font-semibold text-gray-100 flex items-center gap-2 mb-1",children:[e.jsx(Fe,{size:17,className:"text-amber-300"})," Trace a Deploy"]}),e.jsx("p",{className:"text-sm text-gray-400 mb-3",children:"Paste a commit sha (6 or more characters) or a branch name from a deploy to see every run that gated it — the CI verdicts plus any manual verification runs on the same commit."}),e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("input",{value:l,onChange:c=>a(c.target.value),onKeyDown:c=>{c.key==="Enter"&&b()},placeholder:"e.g. 2f812c2 or release/2.4","aria-label":"Commit sha or branch",className:"px-3 py-2 rounded-xl bg-surface-2 border border-white/10 text-sm text-gray-200 font-mono placeholder-gray-600 focus:outline-none focus:border-brand-500/50 w-80"}),e.jsxs("button",{onClick:()=>void b(),disabled:x,className:"flex items-center gap-1.5 px-3.5 py-2 rounded-xl text-sm font-medium bg-brand-600 hover:bg-brand-500 text-white transition-colors disabled:opacity-50",children:[x?e.jsx(J,{size:14,className:"animate-spin"}):e.jsx(Fe,{size:14})," Trace"]})]}),g&&e.jsx("div",{role:"alert",className:"px-3 py-2 rounded-lg bg-red-500/10 border border-red-500/30 text-xs text-red-300 mb-3",children:g}),i&&e.jsxs("div",{className:"space-y-1.5",children:[i.ciRuns.length===0&&i.otherRuns.length===0&&e.jsxs("div",{className:"px-4 py-4 rounded-xl border border-dashed border-white/10 text-sm text-gray-500 text-center",children:["No runs found for ",e.jsx("code",{children:i.query}),".",i.hint?` ${i.hint}.`:""]}),i.ciRuns.map(c=>e.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5 rounded-xl bg-surface-1 border border-white/5 text-sm",children:[e.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full border flex-shrink-0 ${Pe[c.state]}`,children:c.state}),e.jsx("span",{className:"text-gray-200 font-medium",children:c.mappingName}),c.buildNumber&&e.jsxs("span",{className:"text-gray-500 text-xs",children:["#",c.buildNumber]}),e.jsxs("span",{className:"text-sm text-gray-400",children:[c.branch,c.sha?` · ${c.sha.slice(0,7)}`:""]}),c.summary&&e.jsxs("span",{className:"text-sm text-gray-300",children:[e.jsx("span",{className:"text-emerald-400",children:c.summary.passed}),"/",c.summary.total," passed"]}),c.error&&e.jsx("span",{className:"text-xs text-red-300 truncate max-w-[280px]",title:c.error,children:c.error}),e.jsxs("span",{className:"text-sm text-gray-500 ml-auto",children:[V(c.createdAt)," · ",pe(c.durationMs)]}),c.buildUrl&&e.jsx("a",{href:c.buildUrl,target:"_blank",rel:"noopener noreferrer",title:"CI build","aria-label":"Open the CI build",className:"p-1.5 rounded-lg text-gray-500 hover:text-gray-200 hover:bg-white/5",children:e.jsx(Xe,{size:13})}),c.runId&&e.jsx("a",{href:`/results?runId=${encodeURIComponent(c.runId)}`,target:"_blank",rel:"noopener noreferrer",title:"Testver report","aria-label":"Open the Testver report",className:"p-1.5 rounded-lg text-brand-400 hover:text-brand-300 hover:bg-white/5",children:e.jsx(ue,{size:13})})]},c.id)),i.otherRuns.map(c=>e.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5 rounded-xl bg-surface-1 border border-white/5 text-sm opacity-90",children:[e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full border bg-white/5 border-white/10 text-gray-400 flex-shrink-0",children:c.origin||"run"}),e.jsx("span",{className:"text-xs text-gray-400 flex-shrink-0",children:c.status}),e.jsx("span",{className:"text-gray-200",children:c.label||c.runId}),e.jsxs("span",{className:"text-sm text-gray-400",children:[c.gitBranch,c.gitCommitSha?` · ${c.gitCommitSha.slice(0,7)}`:""]}),c.summary&&e.jsxs("span",{className:"text-sm text-gray-300",children:[e.jsx("span",{className:"text-emerald-400",children:c.summary.passed}),"/",c.summary.total," passed"]}),e.jsxs("span",{className:"text-sm text-gray-500 ml-auto",children:[V(c.startTime)," · ",pe(c.duration)]}),e.jsx("a",{href:`/results?runId=${encodeURIComponent(c.runId)}`,target:"_blank",rel:"noopener noreferrer",title:"Testver report","aria-label":"Open the Testver report",className:"p-1.5 rounded-lg text-brand-400 hover:text-brand-300 hover:bg-white/5",children:e.jsx(ue,{size:13})})]},c.runId)),i.searched&&e.jsxs("p",{className:"text-xs text-gray-600 pt-1",children:["Searched the latest ",i.searched.ciRuns," CI runs and ",i.searched.otherRuns," other runs."]})]})]})}function We({runs:s,emptyNote:o,onCancel:l}){return e.jsx("div",{className:"rounded-xl border border-white/5 overflow-hidden bg-surface-1",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-left text-xs text-gray-500 uppercase tracking-wide border-b border-white/5",children:[e.jsx("th",{className:"px-4 py-2.5",children:"State"}),e.jsx("th",{className:"px-4 py-2.5",children:"Pipeline"}),e.jsx("th",{className:"px-4 py-2.5",children:"Branch / Commit"}),e.jsx("th",{className:"px-4 py-2.5",children:"Result"}),e.jsx("th",{className:"px-4 py-2.5",children:"Duration"}),e.jsx("th",{className:"px-4 py-2.5",children:"Triggered"}),e.jsx("th",{className:"px-4 py-2.5 text-right",children:"Links"})]})}),e.jsxs("tbody",{children:[s.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:7,className:"px-4 py-6 text-center text-sm text-gray-500",children:o||"No runs."})}),s.map(a=>e.jsxs("tr",{className:"border-t border-white/5 align-top",children:[e.jsx("td",{className:"px-4 py-2.5",children:a.state==="running"?e.jsx(ot,{size:"sm"}):a.state==="queued"?e.jsx(ct,{size:"sm",position:a.queuePosition||void 0}):e.jsx("span",{className:`inline-flex items-center gap-1.5 text-xs px-2 py-0.5 rounded-full border capitalize ${Pe[a.state]}`,children:a.state})}),e.jsxs("td",{className:"px-4 py-2.5 text-gray-200",children:[a.mappingName||"—",a.buildNumber&&e.jsxs("span",{className:"text-gray-500 ml-1.5",children:["#",a.buildNumber]})]}),e.jsxs("td",{className:"px-4 py-2.5 text-gray-300 text-sm",children:[a.branch||"—",a.sha&&e.jsx("code",{className:"ml-1.5 text-gray-500",children:a.sha.slice(0,7)})]}),e.jsxs("td",{className:"px-4 py-2.5 text-sm text-gray-300 max-w-[320px]",children:[a.summary&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-emerald-400",children:a.summary.passed})," / ",a.summary.total," passed",a.summary.failed>0&&e.jsxs("span",{className:"text-red-400 ml-1",children:["(",a.summary.failed," failed)"]})]}),a.error&&e.jsx("span",{className:"block text-xs text-red-300 mt-0.5 line-clamp-2",title:a.error,children:a.error}),!a.summary&&!a.error&&"—",a.pushWarning&&e.jsxs("span",{className:"block text-xs text-amber-400/80 mt-0.5 line-clamp-2",title:a.pushWarning,children:["PR status not posted: ",a.pushWarning]}),a.autoHeal&&e.jsxs("span",{className:"block text-[11px] mt-0.5 space-x-2",children:[a.autoHeal.healed>0&&e.jsxs("span",{className:"text-emerald-600 dark:text-emerald-300",title:"Locator repaired, verified by re-run, and kept — the summary above counts the original failure",children:["✦ ",a.autoHeal.healed," healed & verified"]}),a.autoHeal.suggested>0&&e.jsxs("span",{className:"text-purple-600 dark:text-purple-300",title:"A verified fix is waiting — open the run in Results and click Apply fix",children:[a.autoHeal.suggested," fix",a.autoHeal.suggested>1?"es":""," ready"]}),a.autoHeal.reverted>0&&e.jsxs("span",{className:"text-amber-600 dark:text-amber-300",title:"A repair was tried but failed verification — files were restored",children:[a.autoHeal.reverted," reverted"]})]})]}),e.jsx("td",{className:"px-4 py-2.5 text-sm text-gray-400",title:"Time on the Testver server (queue wait not included)",children:pe(a.durationMs)}),e.jsxs("td",{className:"px-4 py-2.5 text-sm text-gray-400",children:[V(a.createdAt)," by ",a.triggeredBy]}),e.jsxs("td",{className:"px-4 py-2.5 text-right whitespace-nowrap",children:[l&&(a.state==="queued"||a.state==="running")&&e.jsx("button",{onClick:()=>l(a),title:"Cancel this run","aria-label":`Cancel the ${a.mappingName||"CI"} run`,className:"inline-flex p-1.5 rounded-lg text-red-400 hover:text-red-500 hover:bg-red-500/10",children:e.jsx(Lt,{size:13})}),a.buildUrl&&e.jsx("a",{href:a.buildUrl,target:"_blank",rel:"noopener noreferrer",title:"Open CI build","aria-label":"Open the CI build",className:"inline-flex p-1.5 rounded-lg text-gray-500 hover:text-gray-200 hover:bg-white/5",children:e.jsx(Xe,{size:13})}),a.runId&&e.jsx("a",{href:`/results?runId=${encodeURIComponent(a.runId)}`,target:"_blank",rel:"noopener noreferrer",title:"Open Testver report","aria-label":"Open the Testver report",className:"inline-flex p-1.5 rounded-lg text-brand-400 hover:text-brand-300 hover:bg-white/5",children:e.jsx(ue,{size:13})})]})]},a.id))]})]})})}export{is as PipelinesPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as d,j as e}from"./vendor-react-CTbHBddL.js";import{a as E,u as P,c as N}from"./vendor-query-BrzmPFT3.js";import{e7 as W,fI as Y,fJ as G,eD as U,fK as J,fL as V,fM as X,fN as Z,fO as H,fP as ee,fQ as se,a8 as te,b as re,fR as ae,fS as ne,fT as ie,L as oe,fU as ce,B as $,fV as de,fW as le,fX as xe,dW as L,fY as ue}from"./index-BYVxKLrT.js";import{ac as me,a0 as C,J as F,o as he,R as ge,am as pe,b9 as R,b7 as K,X as D,a8 as fe,q as be,ag as ye,b6 as je,a3 as we,u as B,cU as ve,a9 as A,aa as T,aC as Ne,z as Ce,d9 as ke,cm as q,ce as Se,t as Pe,K as ze,M as Ae,x as Te}from"./vendor-icons-BKPiFyYV.js";const S=s=>s?new Date(s).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}):"Never",M="w-full bg-surface-2 border border-white/10 rounded-xl px-3.5 py-2.5 text-[15px] text-gray-100 focus:outline-none focus:ring-1 focus:ring-brand-500";function Fe({toast:s,describeBrowser:i}){const r=E(),{data:t,isLoading:u}=P({queryKey:["two-factor"],queryFn:W}),[o,n]=d.useState("idle"),[c,l]=d.useState(""),[x,y]=d.useState(""),[m,j]=d.useState(!0),[h,p]=d.useState(null),f=()=>{r.invalidateQueries({queryKey:["two-factor"]}),r.invalidateQueries({queryKey:["profile"]}),r.invalidateQueries({queryKey:["my-sessions"]}),r.invalidateQueries({queryKey:["my-activity"]})},b=()=>{n("idle"),l(""),y(""),p(null)},g=N({mutationFn:Y,onSuccess:()=>{s("success","This browser will ask for the code again"),f()},onError:a=>s("error",a.message)}),k=N({mutationFn:G,onSuccess:a=>{s("success",`${a.removed} browser${a.removed===1?"":"s"} will ask for the code again`),f()},onError:a=>s("error",a.message)});return e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-5 space-y-4","data-testid":"two-factor-section",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("h2",{className:"text-base font-semibold text-gray-200 flex items-center gap-2",children:[e.jsx(me,{size:16}),"Two-factor authentication"]}),t&&e.jsx("span",{className:`text-xs font-medium px-2 py-0.5 rounded-full border ${t.enabled?"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border-emerald-500/20":"bg-gray-500/10 text-gray-500 dark:text-gray-400 border-white/10"}`,children:t.enabled?"On":"Off"})]}),u||!t?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-500",children:[e.jsx(C,{size:14,className:"animate-spin"})," Loading…"]}):t.enabled?e.jsxs("div",{className:"space-y-4",children:[!t.keyReadable&&e.jsxs("div",{className:"flex items-start gap-2 p-3 rounded-lg bg-red-500/10 border border-red-500/20 text-sm text-red-500 dark:text-red-300",children:[e.jsx(he,{size:14,className:"mt-0.5 flex-shrink-0"}),e.jsx("span",{children:"This server can no longer read your authenticator setup (its two-factor key is missing or was replaced). Sign in with a recovery code until you set it up again — turn it off below with a recovery code, then set it up once more."})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"p-3 rounded-lg bg-surface-2 border border-white/5",children:[e.jsx("p",{className:"text-xs text-gray-500",children:"Turned on"}),e.jsx("p",{className:"text-sm text-gray-200 mt-0.5",children:S(t.enabledAt)})]}),e.jsxs("div",{className:`p-3 rounded-lg border ${t.recoveryCodesLeft<=2?"bg-amber-500/10 border-amber-500/20":"bg-surface-2 border-white/5"}`,children:[e.jsx("p",{className:"text-xs text-gray-500",children:"Recovery codes left"}),e.jsxs("p",{className:`text-sm mt-0.5 ${t.recoveryCodesLeft<=2?"text-amber-600 dark:text-amber-400 font-medium":"text-gray-200"}`,children:[t.recoveryCodesLeft," of 10",t.recoveryCodesLeft<=2?" — make new ones":""]})]})]}),h?e.jsx("div",{className:"max-w-lg",children:e.jsx(Z,{codes:h,onDone:()=>{b(),f()}})}):o==="codes"||o==="disable"?e.jsx(Re,{title:o==="codes"?"New recovery codes — your old ones stop working":"Turn off two-factor authentication",submitLabel:o==="codes"?"Make new codes":"Turn off",danger:o==="disable",onCancel:b,onSubmit:async(a,w)=>{o==="codes"?p((await H(a,w)).recoveryCodes):(await ee(a,w),s("success","Two-factor authentication is off"),b(),f())}}):e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>n("codes"),className:"flex items-center gap-1.5 px-3.5 py-2 rounded-xl border border-white/10 text-sm text-gray-300 hover:bg-white/5",children:[e.jsx(ge,{size:14})," New recovery codes"]}),e.jsxs("button",{type:"button",onClick:()=>n("disable"),disabled:t.required,title:t.required?"Your administrator requires two-factor authentication":void 0,className:"flex items-center gap-1.5 px-3.5 py-2 rounded-xl border border-red-500/20 text-sm text-red-500 dark:text-red-400 hover:bg-red-500/10 disabled:opacity-40 disabled:cursor-not-allowed",children:[e.jsx(pe,{size:14})," Turn off"]}),t.required&&e.jsx("span",{className:"self-center text-xs text-gray-500",children:"Required by your administrator"})]}),e.jsxs("div",{className:"pt-2 border-t border-white/5 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("p",{className:"text-sm font-medium text-gray-300",children:["Trusted browsers ",e.jsx("span",{className:"font-normal text-gray-500",children:"— skip the code at sign-in"})]}),t.trustedBrowsers.length>1&&e.jsx("button",{type:"button",onClick:()=>k.mutate(),disabled:k.isPending,className:"text-xs text-red-500 dark:text-red-400 hover:underline",children:"Remove all"})]}),t.trustedBrowsers.length===0?e.jsx("p",{className:"text-xs text-gray-500",children:t.policy.allowTrustedBrowsers?`None. Tick “Trust this browser” when you enter a code to skip it on that browser for ${t.policy.trustedBrowserDays} days.`:"Your administrator has turned trusted browsers off — every sign-in asks for a code."}):t.trustedBrowsers.map(a=>{const{label:w,isMobile:_}=i(a.userAgent);return e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-surface-2 rounded-lg border border-white/5",children:[_?e.jsx(F,{size:16,className:"text-gray-400 shrink-0"}):e.jsx(R,{size:16,className:"text-gray-400 shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm text-gray-200",children:w}),e.jsxs("p",{className:"text-xs text-gray-500",children:[a.ipAddress?`${a.ipAddress} · `:"","Trusted ",S(a.createdAt)," · until ",S(a.expiresAt),a.lastUsedAt?` · last used ${S(a.lastUsedAt)}`:""]})]}),e.jsx("button",{type:"button",onClick:()=>g.mutate(a.id),disabled:g.isPending,title:"Stop trusting this browser",className:"p-1.5 text-gray-500 hover:text-red-400",children:e.jsx(K,{size:14})})]},a.id)})]})]}):o==="idle"?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{className:"text-sm text-gray-400 leading-relaxed max-w-xl",children:["Sign-in asks for a 6-digit code from an authenticator app on your phone as well as your password, so a stolen password alone is not enough.",t.required&&e.jsx("span",{className:"block mt-1 text-amber-600 dark:text-amber-400",children:"Your administrator requires it for your account."})]}),e.jsxs("button",{type:"button",onClick:()=>n("password"),className:"flex items-center gap-2 px-5 py-2.5 bg-brand-600 hover:bg-brand-500 text-white text-[15px] font-medium rounded-xl transition-colors",children:[e.jsx(F,{size:14})," Set up"]})]}):o==="password"?e.jsxs("form",{onSubmit:a=>{a.preventDefault(),c&&(y(c),n("setup"))},className:"space-y-3 max-w-md",children:[e.jsx("label",{htmlFor:"two-factor-setup-password",className:"block text-sm font-medium text-gray-400",children:"Confirm your password"}),e.jsx(U,{id:"two-factor-setup-password",value:c,onChange:a=>l(a.target.value),autoFocus:!0,autoComplete:"current-password",className:M}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"submit",disabled:!c,className:"px-5 py-2.5 bg-brand-600 hover:bg-brand-500 text-white text-[15px] font-medium rounded-xl disabled:opacity-50",children:"Continue"}),e.jsx("button",{type:"button",onClick:b,className:"px-4 py-2.5 text-[15px] text-gray-400 hover:text-gray-200",children:"Cancel"})]})]}):e.jsxs("div",{className:"max-w-lg space-y-3",children:[e.jsx(J,{start:()=>X(x).catch(a=>{throw s("error",a.message),b(),a}),confirm:async a=>{const w=await V(a,m);return w.sessionsRevoked&&s("info",`Signed out of ${w.sessionsRevoked} other session${w.sessionsRevoked===1?"":"s"}`),w.recoveryCodes},beforeCode:e.jsxs("label",{className:"flex items-center gap-2 text-[13px] text-gray-300 cursor-pointer select-none",children:[e.jsx("input",{type:"checkbox",checked:m,onChange:a=>j(a.target.checked),className:"accent-brand-500"}),"Sign out my other sessions when it is on"]}),onFinished:()=>{s("success","Two-factor authentication is on"),b(),f()}}),e.jsx("button",{type:"button",onClick:b,className:"text-xs text-gray-500 hover:text-gray-300",children:"Cancel"})]})]})}function Re({title:s,submitLabel:i,danger:r,onSubmit:t,onCancel:u}){const[o,n]=d.useState(""),[c,l]=d.useState(""),[x,y]=d.useState(""),[m,j]=d.useState(!1),[h,p]=d.useState(""),[f,b]=d.useState(!1),g=!!o&&(m?!!x.trim():c.length===6),k=async()=>{if(!(!g||f)){b(!0),p("");try{await t(o,m?{recoveryCode:x.trim()}:{code:c})}catch(a){p(a.message||"That did not work."),l("")}finally{b(!1)}}};return e.jsxs("form",{onSubmit:a=>{a.preventDefault(),k()},className:"space-y-3 max-w-md p-4 rounded-xl border border-white/10 bg-surface-2/40",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-sm font-medium text-gray-200",children:s}),e.jsx("button",{type:"button",onClick:u,className:"p-1 text-gray-500 hover:text-gray-300",title:"Cancel",children:e.jsx(D,{size:14})})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"two-factor-stepup-password",className:"block text-xs text-gray-400 mb-1",children:"Password"}),e.jsx(U,{id:"two-factor-stepup-password",value:o,onChange:a=>n(a.target.value),autoFocus:!0,autoComplete:"current-password",className:M})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("label",{className:"block text-xs text-gray-400",children:m?"Recovery code":"Code from your authenticator app"}),e.jsxs("button",{type:"button",onClick:()=>j(a=>!a),className:"flex items-center gap-1 text-xs text-brand-400 hover:text-brand-300",children:[e.jsx(fe,{size:11})," ",m?"Use the app code":"Use a recovery code"]})]}),m?e.jsx("input",{value:x,onChange:a=>y(a.target.value),placeholder:"xxxxx-xxxxx",spellCheck:!1,className:`${M} font-mono`}):e.jsx(se,{value:c,onChange:l,autoFocus:!1})]}),h&&e.jsx("p",{className:"text-xs text-red-400",children:h}),e.jsxs("button",{type:"submit",disabled:!g||f,className:`flex items-center gap-2 px-5 py-2.5 text-white text-[15px] font-medium rounded-xl transition-colors disabled:opacity-50 ${r?"bg-red-600 hover:bg-red-500":"bg-brand-600 hover:bg-brand-500"}`,children:[f&&e.jsx(C,{size:14,className:"animate-spin"})," ",i]})]})}function I(s){if(!s)return{browser:"Unknown",os:"Unknown",isMobile:!1};let i="Unknown";s.includes("Edg")?i="Edge":s.includes("Chrome")?i="Chrome":s.includes("Firefox")?i="Firefox":s.includes("Safari")&&(i="Safari");let r="Unknown";s.includes("Windows")?r="Windows":s.includes("Mac")?r="macOS":s.includes("Linux")?r="Linux":s.includes("Android")?r="Android":(s.includes("iPhone")||s.includes("iPad"))&&(r="iOS");const t=/Mobile|Android|iPhone|iPad/i.test(s);return{browser:i,os:r,isMobile:t}}function z(s){return s?new Date(s).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}):"Never"}function Q(s){const i=Date.now()-new Date(s).getTime(),r=Math.floor(i/6e4);if(r<1)return"just now";if(r<60)return`${r}m ago`;const t=Math.floor(r/60);if(t<24)return`${t}h ago`;const u=Math.floor(t/24);return u<30?`${u}d ago`:z(s)}const Me={superadmin:"yellow",admin:"brand",tester:"green",viewer:"gray"},O={admin:"bg-brand-500/20 text-brand-300 ring-brand-500/30",tester:"bg-emerald-500/20 text-emerald-300 ring-emerald-500/30",viewer:"bg-gray-500/20 text-gray-300 ring-gray-500/30"},Le={"auth.":"text-amber-400","user.":"text-brand-400","run.":"text-emerald-400","file.":"text-sky-400","git.":"text-orange-400","ai.":"text-purple-400","settings.":"text-gray-400","recorder.":"text-pink-400","cicd.":"text-teal-400"};function qe(s){for(const[i,r]of Object.entries(Le))if(s.startsWith(i))return r;return"text-gray-400"}function Oe(s){return s.replace(/[._]/g," ").replace(/\b\w/g,i=>i.toUpperCase()).replace(/\b2fa\b/gi,"2FA")}function We(){const{user:s,refreshStatus:i}=te(),{toast:r}=re(),t=E(),{data:u,isLoading:o}=P({queryKey:["profile"],queryFn:ae}),{data:n}=P({queryKey:["my-sessions"],queryFn:ne}),[c,l]=d.useState(0),{data:x,isFetching:y}=P({queryKey:["my-activity",c],queryFn:()=>ie(v,c*v),placeholderData:m=>m});return o?e.jsx(oe,{text:"Loading profile..."}):e.jsxs("div",{className:"min-h-screen bg-surface-0 text-gray-200",children:[e.jsx("div",{className:"border-b border-white/5 bg-surface-1",children:e.jsxs("div",{className:"max-w-3xl mx-auto px-6 py-6",children:[e.jsxs("h1",{className:"text-2xl font-bold text-gray-100 flex items-center gap-3",children:[e.jsx(be,{size:24,className:"text-brand-300"}),"Profile"]}),e.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"Manage your account settings and preferences"})]})}),e.jsx("div",{className:"max-w-3xl mx-auto px-6 py-8",children:e.jsxs("div",{className:"space-y-6 animate-fade-in",children:[e.jsx(Ee,{profile:u,userRole:(s==null?void 0:s.role)||"viewer",onUpdate:async m=>{await ce({displayName:m}),t.invalidateQueries({queryKey:["profile"]}),i()},toast:r}),e.jsx(Ue,{toast:r}),e.jsx(Fe,{toast:r,describeBrowser:m=>{const{browser:j,os:h,isMobile:p}=I(m);return{label:`${j} on ${h}`,isMobile:p}}}),e.jsx($e,{sessions:(n==null?void 0:n.sessions)||[],queryClient:t,toast:r}),e.jsx(Ke,{entries:(x==null?void 0:x.entries)||[],total:(x==null?void 0:x.total)??0,page:c,loading:y,onPage:l}),e.jsx(De,{})]})})]})}function Ee({profile:s,userRole:i,onUpdate:r,toast:t}){const[u,o]=d.useState(!1),[n,c]=d.useState(s.displayName),[l,x]=d.useState(!1),y=async()=>{if(n.trim()){x(!0);try{await r(n.trim()),t("success","Display name updated"),o(!1)}catch(h){t("error",h.message||"Failed to update")}finally{x(!1)}}},m=(s.displayName||s.username).charAt(0).toUpperCase(),j=O[i]||O.viewer;return e.jsx("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-5",children:e.jsxs("div",{className:"flex items-start gap-5",children:[e.jsx("div",{className:`w-16 h-16 rounded-full flex items-center justify-center text-2xl font-bold ring-2 shrink-0 ${j}`,children:m}),e.jsxs("div",{className:"flex-1 min-w-0 space-y-2",children:[e.jsx("div",{className:"flex items-center gap-2",children:u?e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"text",value:n,onChange:h=>c(h.target.value),className:"bg-surface-2 border border-white/10 rounded px-2 py-1 text-lg font-semibold text-gray-100 focus:outline-none focus:ring-1 focus:ring-brand-500",autoFocus:!0,onKeyDown:h=>{h.key==="Enter"&&y(),h.key==="Escape"&&o(!1)}}),e.jsx("button",{onClick:y,disabled:l,className:"p-1 text-emerald-400 hover:text-emerald-300",children:l?e.jsx(C,{size:16,className:"animate-spin"}):e.jsx(ye,{size:16})}),e.jsx("button",{onClick:()=>{o(!1),c(s.displayName)},className:"p-1 text-gray-400 hover:text-gray-300",children:e.jsx(D,{size:16})})]}):e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-100 truncate",children:s.displayName}),e.jsx("button",{onClick:()=>{c(s.displayName),o(!0)},className:"p-1 text-gray-500 hover:text-gray-300",children:e.jsx(je,{size:14})})]})}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"text-sm text-gray-400",children:["@",s.username]}),e.jsx($,{label:s.role==="superadmin"?"super admin":s.role,color:Me[s.role]||"gray"})]}),e.jsx("div",{className:"mt-1 text-sm text-gray-400",children:s.email?s.email:e.jsx("span",{className:"text-gray-600",children:"No email on file — ask an administrator to add one (needed for password reset)"})}),e.jsxs("div",{className:"flex items-center gap-4 text-xs text-gray-500",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(we,{size:12})," Joined ",z(s.createdAt)]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(B,{size:12})," Last login ",z(s.lastLoginAt)]})]})]})]})})}function Ue({toast:s}){const[i,r]=d.useState(""),[t,u]=d.useState(""),[o,n]=d.useState(""),[c,l]=d.useState(!1),[x,y]=d.useState(!1),[m,j]=d.useState(!1),[h,p]=d.useState(""),f=N({mutationFn:()=>de(i,t),onSuccess:()=>{s("success","Password changed successfully"),r(""),u(""),n(""),p("")},onError:g=>{p(g.message||"Failed to change password")}}),b=g=>{if(g.preventDefault(),p(""),!i||!t||!o){p("All fields are required");return}if(t.length<6){p("New password must be at least 6 characters");return}if(t!==o){p("New passwords do not match");return}f.mutate()};return e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-5 space-y-4",children:[e.jsxs("h2",{className:"text-base font-semibold text-gray-200 flex items-center gap-2",children:[e.jsx(ve,{size:16}),"Change Password"]}),e.jsxs("form",{onSubmit:b,className:"space-y-3 max-w-md",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-1",children:"Current Password"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:c?"text":"password",value:i,onChange:g=>r(g.target.value),className:"w-full bg-surface-2 border border-white/10 rounded-xl px-3.5 py-2.5 text-[15px] text-gray-100 pr-10 focus:outline-none focus:ring-1 focus:ring-brand-500",placeholder:"Enter current password"}),e.jsx("button",{type:"button",onClick:()=>l(!c),className:"absolute right-2 top-1/2 -translate-y-1/2 text-gray-500 hover:text-gray-300",children:c?e.jsx(A,{size:16}):e.jsx(T,{size:16})})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-1",children:"New Password"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:x?"text":"password",value:t,onChange:g=>u(g.target.value),className:"w-full bg-surface-2 border border-white/10 rounded-xl px-3.5 py-2.5 text-[15px] text-gray-100 pr-10 focus:outline-none focus:ring-1 focus:ring-brand-500",placeholder:"At least 6 characters"}),e.jsx("button",{type:"button",onClick:()=>y(!x),className:"absolute right-2 top-1/2 -translate-y-1/2 text-gray-500 hover:text-gray-300",children:x?e.jsx(A,{size:16}):e.jsx(T,{size:16})})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-1",children:"Confirm New Password"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:m?"text":"password",value:o,onChange:g=>n(g.target.value),className:"w-full bg-surface-2 border border-white/10 rounded-xl px-3.5 py-2.5 text-[15px] text-gray-100 pr-10 focus:outline-none focus:ring-1 focus:ring-brand-500",placeholder:"Re-enter new password"}),e.jsx("button",{type:"button",onClick:()=>j(!m),className:"absolute right-2 top-1/2 -translate-y-1/2 text-gray-500 hover:text-gray-300",children:m?e.jsx(A,{size:16}):e.jsx(T,{size:16})})]})]}),h&&e.jsx("p",{className:"text-xs text-red-400",children:h}),e.jsxs("button",{type:"submit",disabled:f.isPending,className:"flex items-center gap-2 px-5 py-2.5 bg-brand-600 hover:bg-brand-500 text-white text-[15px] font-medium rounded-xl transition-colors disabled:opacity-50",children:[f.isPending?e.jsx(C,{size:14,className:"animate-spin"}):e.jsx(Ne,{size:14}),"Update Password"]})]})]})}function $e({sessions:s,queryClient:i,toast:r}){const t=N({mutationFn:le,onSuccess:()=>{i.invalidateQueries({queryKey:["my-sessions"]}),r("success","Session revoked")},onError:n=>r("error",n.message)}),u=N({mutationFn:xe,onSuccess:n=>{i.invalidateQueries({queryKey:["my-sessions"]}),r("success",`${n.sessionsRevoked} session(s) revoked`)},onError:n=>r("error",n.message)}),o=s.filter(n=>!n.isCurrent);return e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-5 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h2",{className:"text-base font-semibold text-gray-200 flex items-center gap-2",children:[e.jsx(R,{size:16}),"Active Sessions",e.jsxs("span",{className:"text-xs text-gray-500 font-normal",children:["(",s.length,")"]})]}),o.length>0&&e.jsxs("button",{onClick:()=>u.mutate(),disabled:u.isPending,className:"flex items-center gap-1.5 px-3 py-1.5 text-xs text-red-400 hover:text-red-300 bg-red-500/10 hover:bg-red-500/20 rounded transition-colors",children:[u.isPending?e.jsx(C,{size:12,className:"animate-spin"}):e.jsx(Ce,{size:12}),"Revoke All Others"]})]}),s.length===0?e.jsx("p",{className:"text-sm text-gray-500 py-4 text-center",children:"No active sessions"}):e.jsx("div",{className:"space-y-2",children:s.map(n=>{const{browser:c,os:l,isMobile:x}=I(n.userAgent);return e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-surface-2 rounded-lg border border-white/5",children:[x?e.jsx(F,{size:18,className:"text-gray-400 shrink-0"}):e.jsx(R,{size:18,className:"text-gray-400 shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-sm text-gray-200 font-medium",children:[c," on ",l]}),n.isCurrent&&e.jsx($,{label:"Current",color:"green"})]}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-gray-500 mt-0.5",children:[n.ipAddress&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ke,{size:10})," ",n.ipAddress]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(B,{size:10})," ",Q(n.createdAt)]}),e.jsxs("span",{children:["Expires ",z(n.expiresAt)]})]})]}),!n.isCurrent&&e.jsx("button",{onClick:()=>t.mutate(n.id),disabled:t.isPending,className:"p-1.5 text-gray-500 hover:text-red-400 transition-colors",title:"Revoke session",children:e.jsx(K,{size:14})})]},n.id)})})]})}const v=20;function Ke({entries:s,total:i,page:r,loading:t,onPage:u}){const o=Math.max(1,Math.ceil(i/v)),n=i===0?0:r*v+1,c=Math.min(i,(r+1)*v);return e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-5 space-y-4",children:[e.jsxs("h2",{className:"text-base font-semibold text-gray-200 flex items-center gap-2",children:[e.jsx(q,{size:16}),"Recent Activity",i>0&&e.jsxs("span",{className:"text-xs font-normal text-gray-500",children:["(",i,")"]})]}),s.length===0?e.jsx("p",{className:"text-sm text-gray-500 py-4 text-center",children:"No recent activity"}):e.jsx("div",{className:"space-y-1",children:s.map(l=>e.jsxs("div",{className:"flex items-center gap-3 py-2 px-3 rounded hover:bg-surface-2 transition-colors",children:[e.jsx(q,{size:14,className:`shrink-0 ${qe(l.action)}`}),e.jsx("span",{className:"text-sm text-gray-300 flex-1 truncate",children:Oe(l.action)}),l.resourceId&&e.jsx("span",{className:"text-xs text-gray-500 truncate max-w-[200px]",children:l.resourceId}),e.jsx("span",{className:"text-xs text-gray-500 shrink-0",children:Q(l.timestamp)})]},l.id))}),i>v&&e.jsxs("div",{className:"flex items-center justify-between gap-3 pt-3 border-t border-white/5",children:[e.jsxs("span",{className:"text-xs text-gray-500",children:["Showing ",n,"–",c," of ",i]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>u(r-1),disabled:r===0||t,className:"flex items-center gap-1 h-8 px-3 rounded-lg border border-white/10 text-xs text-gray-300 hover:bg-white/5 disabled:opacity-40 disabled:cursor-not-allowed",children:[e.jsx(Se,{size:14})," Previous"]}),e.jsxs("span",{className:"text-xs text-gray-400 tabular-nums min-w-[84px] text-center",children:["Page ",r+1," of ",o]}),e.jsxs("button",{onClick:()=>u(r+1),disabled:r>=o-1||t,className:"flex items-center gap-1 h-8 px-3 rounded-lg border border-white/10 text-xs text-gray-300 hover:bg-white/5 disabled:opacity-40 disabled:cursor-not-allowed",children:["Next ",e.jsx(Pe,{size:14})]})]})]})]})}function De(){const[s,i]=d.useState(L()),r=()=>{ue(),i(L())};return e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-5 space-y-4",children:[e.jsxs("h2",{className:"text-base font-semibold text-gray-200 flex items-center gap-2",children:[e.jsx(ze,{size:16}),"Preferences"]}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-gray-200",children:"Theme"}),e.jsx("p",{className:"text-xs text-gray-500",children:"Switch between dark and light mode"})]}),e.jsxs("button",{onClick:r,className:"flex items-center gap-2 px-3 py-1.5 bg-surface-2 border border-white/10 rounded text-sm text-gray-300 hover:text-gray-100 transition-colors",children:[s==="dark"?e.jsx(Ae,{size:14}):e.jsx(Te,{size:14}),s==="dark"?"Dark":"Light"]})]})]})}export{We as ProfilePage};
|
|
1
|
+
import{r as d,j as e}from"./vendor-react-DOVfxdUy.js";import{a as E,u as P,c as N}from"./vendor-query-DkZSMtfn.js";import{ek as W,fV as Y,fW as G,eS as $,fX as V,fY as X,fZ as Z,f_ as J,f$ as H,g0 as ee,g1 as se,ae as te,b as re,g2 as ae,g3 as ne,g4 as ie,L as oe,g5 as ce,B as U,g6 as de,g7 as le,g8 as xe,bO as L,g9 as ue}from"./index-BlA8ntjb.js";import{ad as me,a1 as C,K as F,p as he,R as ge,an as pe,ba as R,b8 as D,X as K,a9 as fe,r as be,ah as ye,b7 as je,a4 as we,v as B,cW as ve,aa as z,ab as T,aD as Ne,D as Ce,db as ke,cp as O,ch as Se,u as Pe,O as Ae,M as ze,y as Te}from"./vendor-icons-Cm92aSc5.js";const S=s=>s?new Date(s).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}):"Never",M="w-full bg-surface-2 border border-white/10 rounded-xl px-3.5 py-2.5 text-[15px] text-gray-100 focus:outline-none focus:ring-1 focus:ring-brand-500";function Fe({toast:s,describeBrowser:i}){const r=E(),{data:t,isLoading:u}=P({queryKey:["two-factor"],queryFn:W}),[o,n]=d.useState("idle"),[c,l]=d.useState(""),[x,y]=d.useState(""),[m,j]=d.useState(!0),[h,p]=d.useState(null),f=()=>{r.invalidateQueries({queryKey:["two-factor"]}),r.invalidateQueries({queryKey:["profile"]}),r.invalidateQueries({queryKey:["my-sessions"]}),r.invalidateQueries({queryKey:["my-activity"]})},b=()=>{n("idle"),l(""),y(""),p(null)},g=N({mutationFn:Y,onSuccess:()=>{s("success","This browser will ask for the code again"),f()},onError:a=>s("error",a.message)}),k=N({mutationFn:G,onSuccess:a=>{s("success",`${a.removed} browser${a.removed===1?"":"s"} will ask for the code again`),f()},onError:a=>s("error",a.message)});return e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-5 space-y-4","data-testid":"two-factor-section",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("h2",{className:"text-base font-semibold text-gray-200 flex items-center gap-2",children:[e.jsx(me,{size:16}),"Two-factor authentication"]}),t&&e.jsx("span",{className:`text-xs font-medium px-2 py-0.5 rounded-full border ${t.enabled?"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border-emerald-500/20":"bg-gray-500/10 text-gray-500 dark:text-gray-400 border-white/10"}`,children:t.enabled?"On":"Off"})]}),u||!t?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-500",children:[e.jsx(C,{size:14,className:"animate-spin"})," Loading…"]}):t.enabled?e.jsxs("div",{className:"space-y-4",children:[!t.keyReadable&&e.jsxs("div",{className:"flex items-start gap-2 p-3 rounded-lg bg-red-500/10 border border-red-500/20 text-sm text-red-500 dark:text-red-300",children:[e.jsx(he,{size:14,className:"mt-0.5 flex-shrink-0"}),e.jsx("span",{children:"This server can no longer read your authenticator setup (its two-factor key is missing or was replaced). Sign in with a recovery code until you set it up again — turn it off below with a recovery code, then set it up once more."})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"p-3 rounded-lg bg-surface-2 border border-white/5",children:[e.jsx("p",{className:"text-xs text-gray-500",children:"Turned on"}),e.jsx("p",{className:"text-sm text-gray-200 mt-0.5",children:S(t.enabledAt)})]}),e.jsxs("div",{className:`p-3 rounded-lg border ${t.recoveryCodesLeft<=2?"bg-amber-500/10 border-amber-500/20":"bg-surface-2 border-white/5"}`,children:[e.jsx("p",{className:"text-xs text-gray-500",children:"Recovery codes left"}),e.jsxs("p",{className:`text-sm mt-0.5 ${t.recoveryCodesLeft<=2?"text-amber-600 dark:text-amber-400 font-medium":"text-gray-200"}`,children:[t.recoveryCodesLeft," of 10",t.recoveryCodesLeft<=2?" — make new ones":""]})]})]}),h?e.jsx("div",{className:"max-w-lg",children:e.jsx(J,{codes:h,onDone:()=>{b(),f()}})}):o==="codes"||o==="disable"?e.jsx(Re,{title:o==="codes"?"New recovery codes — your old ones stop working":"Turn off two-factor authentication",submitLabel:o==="codes"?"Make new codes":"Turn off",danger:o==="disable",onCancel:b,onSubmit:async(a,w)=>{o==="codes"?p((await H(a,w)).recoveryCodes):(await ee(a,w),s("success","Two-factor authentication is off"),b(),f())}}):e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>n("codes"),className:"flex items-center gap-1.5 px-3.5 py-2 rounded-xl border border-white/10 text-sm text-gray-300 hover:bg-white/5",children:[e.jsx(ge,{size:14})," New recovery codes"]}),e.jsxs("button",{type:"button",onClick:()=>n("disable"),disabled:t.required,title:t.required?"Your administrator requires two-factor authentication":void 0,className:"flex items-center gap-1.5 px-3.5 py-2 rounded-xl border border-red-500/20 text-sm text-red-500 dark:text-red-400 hover:bg-red-500/10 disabled:opacity-40 disabled:cursor-not-allowed",children:[e.jsx(pe,{size:14})," Turn off"]}),t.required&&e.jsx("span",{className:"self-center text-xs text-gray-500",children:"Required by your administrator"})]}),e.jsxs("div",{className:"pt-2 border-t border-white/5 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("p",{className:"text-sm font-medium text-gray-300",children:["Trusted browsers ",e.jsx("span",{className:"font-normal text-gray-500",children:"— skip the code at sign-in"})]}),t.trustedBrowsers.length>1&&e.jsx("button",{type:"button",onClick:()=>k.mutate(),disabled:k.isPending,className:"text-xs text-red-500 dark:text-red-400 hover:underline",children:"Remove all"})]}),t.trustedBrowsers.length===0?e.jsx("p",{className:"text-xs text-gray-500",children:t.policy.allowTrustedBrowsers?`None. Tick “Trust this browser” when you enter a code to skip it on that browser for ${t.policy.trustedBrowserDays} days.`:"Your administrator has turned trusted browsers off — every sign-in asks for a code."}):t.trustedBrowsers.map(a=>{const{label:w,isMobile:_}=i(a.userAgent);return e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-surface-2 rounded-lg border border-white/5",children:[_?e.jsx(F,{size:16,className:"text-gray-400 shrink-0"}):e.jsx(R,{size:16,className:"text-gray-400 shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm text-gray-200",children:w}),e.jsxs("p",{className:"text-xs text-gray-500",children:[a.ipAddress?`${a.ipAddress} · `:"","Trusted ",S(a.createdAt)," · until ",S(a.expiresAt),a.lastUsedAt?` · last used ${S(a.lastUsedAt)}`:""]})]}),e.jsx("button",{type:"button",onClick:()=>g.mutate(a.id),disabled:g.isPending,title:"Stop trusting this browser",className:"p-1.5 text-gray-500 hover:text-red-400",children:e.jsx(D,{size:14})})]},a.id)})]})]}):o==="idle"?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{className:"text-sm text-gray-400 leading-relaxed max-w-xl",children:["Sign-in asks for a 6-digit code from an authenticator app on your phone as well as your password, so a stolen password alone is not enough.",t.required&&e.jsx("span",{className:"block mt-1 text-amber-600 dark:text-amber-400",children:"Your administrator requires it for your account."})]}),e.jsxs("button",{type:"button",onClick:()=>n("password"),className:"flex items-center gap-2 px-5 py-2.5 bg-brand-600 hover:bg-brand-500 text-white text-[15px] font-medium rounded-xl transition-colors",children:[e.jsx(F,{size:14})," Set up"]})]}):o==="password"?e.jsxs("form",{onSubmit:a=>{a.preventDefault(),c&&(y(c),n("setup"))},className:"space-y-3 max-w-md",children:[e.jsx("label",{htmlFor:"two-factor-setup-password",className:"block text-sm font-medium text-gray-400",children:"Confirm your password"}),e.jsx($,{id:"two-factor-setup-password",value:c,onChange:a=>l(a.target.value),autoFocus:!0,autoComplete:"current-password",className:M}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"submit",disabled:!c,className:"px-5 py-2.5 bg-brand-600 hover:bg-brand-500 text-white text-[15px] font-medium rounded-xl disabled:opacity-50",children:"Continue"}),e.jsx("button",{type:"button",onClick:b,className:"px-4 py-2.5 text-[15px] text-gray-400 hover:text-gray-200",children:"Cancel"})]})]}):e.jsxs("div",{className:"max-w-lg space-y-3",children:[e.jsx(V,{start:()=>Z(x).catch(a=>{throw s("error",a.message),b(),a}),confirm:async a=>{const w=await X(a,m);return w.sessionsRevoked&&s("info",`Signed out of ${w.sessionsRevoked} other session${w.sessionsRevoked===1?"":"s"}`),w.recoveryCodes},beforeCode:e.jsxs("label",{className:"flex items-center gap-2 text-[13px] text-gray-300 cursor-pointer select-none",children:[e.jsx("input",{type:"checkbox",checked:m,onChange:a=>j(a.target.checked),className:"accent-brand-500"}),"Sign out my other sessions when it is on"]}),onFinished:()=>{s("success","Two-factor authentication is on"),b(),f()}}),e.jsx("button",{type:"button",onClick:b,className:"text-xs text-gray-500 hover:text-gray-300",children:"Cancel"})]})]})}function Re({title:s,submitLabel:i,danger:r,onSubmit:t,onCancel:u}){const[o,n]=d.useState(""),[c,l]=d.useState(""),[x,y]=d.useState(""),[m,j]=d.useState(!1),[h,p]=d.useState(""),[f,b]=d.useState(!1),g=!!o&&(m?!!x.trim():c.length===6),k=async()=>{if(!(!g||f)){b(!0),p("");try{await t(o,m?{recoveryCode:x.trim()}:{code:c})}catch(a){p(a.message||"That did not work."),l("")}finally{b(!1)}}};return e.jsxs("form",{onSubmit:a=>{a.preventDefault(),k()},className:"space-y-3 max-w-md p-4 rounded-xl border border-white/10 bg-surface-2/40",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-sm font-medium text-gray-200",children:s}),e.jsx("button",{type:"button",onClick:u,className:"p-1 text-gray-500 hover:text-gray-300",title:"Cancel",children:e.jsx(K,{size:14})})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"two-factor-stepup-password",className:"block text-xs text-gray-400 mb-1",children:"Password"}),e.jsx($,{id:"two-factor-stepup-password",value:o,onChange:a=>n(a.target.value),autoFocus:!0,autoComplete:"current-password",className:M})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("label",{className:"block text-xs text-gray-400",children:m?"Recovery code":"Code from your authenticator app"}),e.jsxs("button",{type:"button",onClick:()=>j(a=>!a),className:"flex items-center gap-1 text-xs text-brand-400 hover:text-brand-300",children:[e.jsx(fe,{size:11})," ",m?"Use the app code":"Use a recovery code"]})]}),m?e.jsx("input",{value:x,onChange:a=>y(a.target.value),placeholder:"xxxxx-xxxxx",spellCheck:!1,className:`${M} font-mono`}):e.jsx(se,{value:c,onChange:l,autoFocus:!1})]}),h&&e.jsx("p",{className:"text-xs text-red-400",children:h}),e.jsxs("button",{type:"submit",disabled:!g||f,className:`flex items-center gap-2 px-5 py-2.5 text-white text-[15px] font-medium rounded-xl transition-colors disabled:opacity-50 ${r?"bg-red-600 hover:bg-red-500":"bg-brand-600 hover:bg-brand-500"}`,children:[f&&e.jsx(C,{size:14,className:"animate-spin"})," ",i]})]})}function I(s){if(!s)return{browser:"Unknown",os:"Unknown",isMobile:!1};let i="Unknown";s.includes("Edg")?i="Edge":s.includes("Chrome")?i="Chrome":s.includes("Firefox")?i="Firefox":s.includes("Safari")&&(i="Safari");let r="Unknown";s.includes("Windows")?r="Windows":s.includes("Mac")?r="macOS":s.includes("Linux")?r="Linux":s.includes("Android")?r="Android":(s.includes("iPhone")||s.includes("iPad"))&&(r="iOS");const t=/Mobile|Android|iPhone|iPad/i.test(s);return{browser:i,os:r,isMobile:t}}function A(s){return s?new Date(s).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}):"Never"}function Q(s){const i=Date.now()-new Date(s).getTime(),r=Math.floor(i/6e4);if(r<1)return"just now";if(r<60)return`${r}m ago`;const t=Math.floor(r/60);if(t<24)return`${t}h ago`;const u=Math.floor(t/24);return u<30?`${u}d ago`:A(s)}const Me={superadmin:"yellow",admin:"brand",tester:"green",viewer:"gray"},q={admin:"bg-brand-500/20 text-brand-300 ring-brand-500/30",tester:"bg-emerald-500/20 text-emerald-300 ring-emerald-500/30",viewer:"bg-gray-500/20 text-gray-300 ring-gray-500/30"},Le={"auth.":"text-amber-400","user.":"text-brand-400","run.":"text-emerald-400","file.":"text-sky-400","git.":"text-orange-400","ai.":"text-purple-400","settings.":"text-gray-400","recorder.":"text-pink-400","cicd.":"text-teal-400"};function Oe(s){for(const[i,r]of Object.entries(Le))if(s.startsWith(i))return r;return"text-gray-400"}function qe(s){return s.replace(/[._]/g," ").replace(/\b\w/g,i=>i.toUpperCase()).replace(/\b2fa\b/gi,"2FA")}function We(){const{user:s,refreshStatus:i}=te(),{toast:r}=re(),t=E(),{data:u,isLoading:o}=P({queryKey:["profile"],queryFn:ae}),{data:n}=P({queryKey:["my-sessions"],queryFn:ne}),[c,l]=d.useState(0),{data:x,isFetching:y}=P({queryKey:["my-activity",c],queryFn:()=>ie(v,c*v),placeholderData:m=>m});return o?e.jsx(oe,{text:"Loading profile..."}):e.jsxs("div",{className:"min-h-screen bg-surface-0 text-gray-200",children:[e.jsx("div",{className:"border-b border-white/5 bg-surface-1",children:e.jsxs("div",{className:"max-w-3xl mx-auto px-6 py-6",children:[e.jsxs("h1",{className:"text-2xl font-bold text-gray-100 flex items-center gap-3",children:[e.jsx(be,{size:24,className:"text-brand-300"}),"Profile"]}),e.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"Manage your account settings and preferences"})]})}),e.jsx("div",{className:"max-w-3xl mx-auto px-6 py-8",children:e.jsxs("div",{className:"space-y-6 animate-fade-in",children:[e.jsx(Ee,{profile:u,userRole:(s==null?void 0:s.role)||"viewer",onUpdate:async m=>{await ce({displayName:m}),t.invalidateQueries({queryKey:["profile"]}),i()},toast:r}),e.jsx($e,{toast:r}),e.jsx(Fe,{toast:r,describeBrowser:m=>{const{browser:j,os:h,isMobile:p}=I(m);return{label:`${j} on ${h}`,isMobile:p}}}),e.jsx(Ue,{sessions:(n==null?void 0:n.sessions)||[],queryClient:t,toast:r}),e.jsx(De,{entries:(x==null?void 0:x.entries)||[],total:(x==null?void 0:x.total)??0,page:c,loading:y,onPage:l}),e.jsx(Ke,{})]})})]})}function Ee({profile:s,userRole:i,onUpdate:r,toast:t}){const[u,o]=d.useState(!1),[n,c]=d.useState(s.displayName),[l,x]=d.useState(!1),y=async()=>{if(n.trim()){x(!0);try{await r(n.trim()),t("success","Display name updated"),o(!1)}catch(h){t("error",h.message||"Failed to update")}finally{x(!1)}}},m=(s.displayName||s.username).charAt(0).toUpperCase(),j=q[i]||q.viewer;return e.jsx("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-5",children:e.jsxs("div",{className:"flex items-start gap-5",children:[e.jsx("div",{className:`w-16 h-16 rounded-full flex items-center justify-center text-2xl font-bold ring-2 shrink-0 ${j}`,children:m}),e.jsxs("div",{className:"flex-1 min-w-0 space-y-2",children:[e.jsx("div",{className:"flex items-center gap-2",children:u?e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"text",value:n,onChange:h=>c(h.target.value),className:"bg-surface-2 border border-white/10 rounded px-2 py-1 text-lg font-semibold text-gray-100 focus:outline-none focus:ring-1 focus:ring-brand-500",autoFocus:!0,onKeyDown:h=>{h.key==="Enter"&&y(),h.key==="Escape"&&o(!1)}}),e.jsx("button",{onClick:y,disabled:l,className:"p-1 text-emerald-400 hover:text-emerald-300",children:l?e.jsx(C,{size:16,className:"animate-spin"}):e.jsx(ye,{size:16})}),e.jsx("button",{onClick:()=>{o(!1),c(s.displayName)},className:"p-1 text-gray-400 hover:text-gray-300",children:e.jsx(K,{size:16})})]}):e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-100 truncate",children:s.displayName}),e.jsx("button",{onClick:()=>{c(s.displayName),o(!0)},className:"p-1 text-gray-500 hover:text-gray-300",children:e.jsx(je,{size:14})})]})}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"text-sm text-gray-400",children:["@",s.username]}),e.jsx(U,{label:s.role==="superadmin"?"super admin":s.role,color:Me[s.role]||"gray"})]}),e.jsx("div",{className:"mt-1 text-sm text-gray-400",children:s.email?s.email:e.jsx("span",{className:"text-gray-600",children:"No email on file — ask an administrator to add one (needed for password reset)"})}),e.jsxs("div",{className:"flex items-center gap-4 text-xs text-gray-500",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(we,{size:12})," Joined ",A(s.createdAt)]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(B,{size:12})," Last login ",A(s.lastLoginAt)]})]})]})]})})}function $e({toast:s}){const[i,r]=d.useState(""),[t,u]=d.useState(""),[o,n]=d.useState(""),[c,l]=d.useState(!1),[x,y]=d.useState(!1),[m,j]=d.useState(!1),[h,p]=d.useState(""),f=N({mutationFn:()=>de(i,t),onSuccess:()=>{s("success","Password changed successfully"),r(""),u(""),n(""),p("")},onError:g=>{p(g.message||"Failed to change password")}}),b=g=>{if(g.preventDefault(),p(""),!i||!t||!o){p("All fields are required");return}if(t.length<6){p("New password must be at least 6 characters");return}if(t!==o){p("New passwords do not match");return}f.mutate()};return e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-5 space-y-4",children:[e.jsxs("h2",{className:"text-base font-semibold text-gray-200 flex items-center gap-2",children:[e.jsx(ve,{size:16}),"Change Password"]}),e.jsxs("form",{onSubmit:b,className:"space-y-3 max-w-md",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-1",children:"Current Password"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:c?"text":"password",value:i,onChange:g=>r(g.target.value),className:"w-full bg-surface-2 border border-white/10 rounded-xl px-3.5 py-2.5 text-[15px] text-gray-100 pr-10 focus:outline-none focus:ring-1 focus:ring-brand-500",placeholder:"Enter current password"}),e.jsx("button",{type:"button",onClick:()=>l(!c),className:"absolute right-2 top-1/2 -translate-y-1/2 text-gray-500 hover:text-gray-300",children:c?e.jsx(z,{size:16}):e.jsx(T,{size:16})})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-1",children:"New Password"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:x?"text":"password",value:t,onChange:g=>u(g.target.value),className:"w-full bg-surface-2 border border-white/10 rounded-xl px-3.5 py-2.5 text-[15px] text-gray-100 pr-10 focus:outline-none focus:ring-1 focus:ring-brand-500",placeholder:"At least 6 characters"}),e.jsx("button",{type:"button",onClick:()=>y(!x),className:"absolute right-2 top-1/2 -translate-y-1/2 text-gray-500 hover:text-gray-300",children:x?e.jsx(z,{size:16}):e.jsx(T,{size:16})})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-1",children:"Confirm New Password"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:m?"text":"password",value:o,onChange:g=>n(g.target.value),className:"w-full bg-surface-2 border border-white/10 rounded-xl px-3.5 py-2.5 text-[15px] text-gray-100 pr-10 focus:outline-none focus:ring-1 focus:ring-brand-500",placeholder:"Re-enter new password"}),e.jsx("button",{type:"button",onClick:()=>j(!m),className:"absolute right-2 top-1/2 -translate-y-1/2 text-gray-500 hover:text-gray-300",children:m?e.jsx(z,{size:16}):e.jsx(T,{size:16})})]})]}),h&&e.jsx("p",{className:"text-xs text-red-400",children:h}),e.jsxs("button",{type:"submit",disabled:f.isPending,className:"flex items-center gap-2 px-5 py-2.5 bg-brand-600 hover:bg-brand-500 text-white text-[15px] font-medium rounded-xl transition-colors disabled:opacity-50",children:[f.isPending?e.jsx(C,{size:14,className:"animate-spin"}):e.jsx(Ne,{size:14}),"Update Password"]})]})]})}function Ue({sessions:s,queryClient:i,toast:r}){const t=N({mutationFn:le,onSuccess:()=>{i.invalidateQueries({queryKey:["my-sessions"]}),r("success","Session revoked")},onError:n=>r("error",n.message)}),u=N({mutationFn:xe,onSuccess:n=>{i.invalidateQueries({queryKey:["my-sessions"]}),r("success",`${n.sessionsRevoked} session(s) revoked`)},onError:n=>r("error",n.message)}),o=s.filter(n=>!n.isCurrent);return e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-5 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h2",{className:"text-base font-semibold text-gray-200 flex items-center gap-2",children:[e.jsx(R,{size:16}),"Active Sessions",e.jsxs("span",{className:"text-xs text-gray-500 font-normal",children:["(",s.length,")"]})]}),o.length>0&&e.jsxs("button",{onClick:()=>u.mutate(),disabled:u.isPending,className:"flex items-center gap-1.5 px-3 py-1.5 text-xs text-red-400 hover:text-red-300 bg-red-500/10 hover:bg-red-500/20 rounded transition-colors",children:[u.isPending?e.jsx(C,{size:12,className:"animate-spin"}):e.jsx(Ce,{size:12}),"Revoke All Others"]})]}),s.length===0?e.jsx("p",{className:"text-sm text-gray-500 py-4 text-center",children:"No active sessions"}):e.jsx("div",{className:"space-y-2",children:s.map(n=>{const{browser:c,os:l,isMobile:x}=I(n.userAgent);return e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-surface-2 rounded-lg border border-white/5",children:[x?e.jsx(F,{size:18,className:"text-gray-400 shrink-0"}):e.jsx(R,{size:18,className:"text-gray-400 shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-sm text-gray-200 font-medium",children:[c," on ",l]}),n.isCurrent&&e.jsx(U,{label:"Current",color:"green"})]}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-gray-500 mt-0.5",children:[n.ipAddress&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ke,{size:10})," ",n.ipAddress]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(B,{size:10})," ",Q(n.createdAt)]}),e.jsxs("span",{children:["Expires ",A(n.expiresAt)]})]})]}),!n.isCurrent&&e.jsx("button",{onClick:()=>t.mutate(n.id),disabled:t.isPending,className:"p-1.5 text-gray-500 hover:text-red-400 transition-colors",title:"Revoke session",children:e.jsx(D,{size:14})})]},n.id)})})]})}const v=20;function De({entries:s,total:i,page:r,loading:t,onPage:u}){const o=Math.max(1,Math.ceil(i/v)),n=i===0?0:r*v+1,c=Math.min(i,(r+1)*v);return e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-5 space-y-4",children:[e.jsxs("h2",{className:"text-base font-semibold text-gray-200 flex items-center gap-2",children:[e.jsx(O,{size:16}),"Recent Activity",i>0&&e.jsxs("span",{className:"text-xs font-normal text-gray-500",children:["(",i,")"]})]}),s.length===0?e.jsx("p",{className:"text-sm text-gray-500 py-4 text-center",children:"No recent activity"}):e.jsx("div",{className:"space-y-1",children:s.map(l=>e.jsxs("div",{className:"flex items-center gap-3 py-2 px-3 rounded hover:bg-surface-2 transition-colors",children:[e.jsx(O,{size:14,className:`shrink-0 ${Oe(l.action)}`}),e.jsx("span",{className:"text-sm text-gray-300 flex-1 truncate",children:qe(l.action)}),l.resourceId&&e.jsx("span",{className:"text-xs text-gray-500 truncate max-w-[200px]",children:l.resourceId}),e.jsx("span",{className:"text-xs text-gray-500 shrink-0",children:Q(l.timestamp)})]},l.id))}),i>v&&e.jsxs("div",{className:"flex items-center justify-between gap-3 pt-3 border-t border-white/5",children:[e.jsxs("span",{className:"text-xs text-gray-500",children:["Showing ",n,"–",c," of ",i]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>u(r-1),disabled:r===0||t,className:"flex items-center gap-1 h-8 px-3 rounded-lg border border-white/10 text-xs text-gray-300 hover:bg-white/5 disabled:opacity-40 disabled:cursor-not-allowed",children:[e.jsx(Se,{size:14})," Previous"]}),e.jsxs("span",{className:"text-xs text-gray-400 tabular-nums min-w-[84px] text-center",children:["Page ",r+1," of ",o]}),e.jsxs("button",{onClick:()=>u(r+1),disabled:r>=o-1||t,className:"flex items-center gap-1 h-8 px-3 rounded-lg border border-white/10 text-xs text-gray-300 hover:bg-white/5 disabled:opacity-40 disabled:cursor-not-allowed",children:["Next ",e.jsx(Pe,{size:14})]})]})]})]})}function Ke(){const[s,i]=d.useState(L()),r=()=>{ue(),i(L())};return e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-5 space-y-4",children:[e.jsxs("h2",{className:"text-base font-semibold text-gray-200 flex items-center gap-2",children:[e.jsx(Ae,{size:16}),"Preferences"]}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-gray-200",children:"Theme"}),e.jsx("p",{className:"text-xs text-gray-500",children:"Switch between dark and light mode"})]}),e.jsxs("button",{onClick:r,className:"flex items-center gap-2 px-3 py-1.5 bg-surface-2 border border-white/10 rounded text-sm text-gray-300 hover:text-gray-100 transition-colors",children:[s==="dark"?e.jsx(ze,{size:14}):e.jsx(Te,{size:14}),s==="dark"?"Dark":"Light"]})]})]})}export{We as ProfilePage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as I,r as t,
|
|
1
|
+
import{e as I,r as t,b as K,j as e}from"./vendor-react-DOVfxdUy.js";import{u as U}from"./vendor-query-DkZSMtfn.js";import{a as q,L as _}from"./index-BlA8ntjb.js";import{u as $,F as B,a as O}from"./FileViewer-Bcr9T1jW.js";import{E as Q}from"./EmptyState-BShNSbLf.js";import{F as V,ay as G,az as J,w as Y,X as Z,j as ee}from"./vendor-icons-Cm92aSc5.js";import"./RemoteFileStrip-dzPInzgb.js";import"./index-DLmlY2Ol.js";import"./useChartTheme-CTIe6M63.js";import"./sandboxStorage-BrzaG3ny.js";import"./simpleMarkdown-kWs-10D8.js";import"./formatDate-T65-Y6Mi.js";import"./UncommittedDiffViewer-BNroxCoo.js";function F(o){const r=[];for(const s of o)s.type==="directory"&&(r.push(s.path),s.children&&r.push(...F(s.children)));return r}function L(o){let r=0;for(const s of o)s.type==="file"?r++:s.children&&(r+=L(s.children));return r}function te(o,r){const s=[];function u(d,h){for(const i of d){if(i.path===o)return s.push(...h),!0;if(i.type==="directory"&&i.children&&u(i.children,[...h,i.path]))return!0}return!1}return u(r,[]),s}function me(){const[o,r]=I(),{expanded:s,toggle:u,expandAll:d,collapseAll:h}=$("testver_explorer_expanded"),[i,j]=t.useState(null),[S,z]=t.useState(null),[m,w]=t.useState(""),[p,P]=t.useState(280),[C,b]=t.useState(!1),M=t.useRef(null),g=t.useRef(null),[R,N]=t.useState(null),{data:f,isLoading:D}=U({queryKey:["fileTree"],queryFn:q,staleTime:3e4}),l=t.useMemo(()=>f?f.children??[f]:[],[f]),T=t.useMemo(()=>L(l),[l]),A=t.useMemo(()=>F(l),[l]),v=K(),k=t.useRef(null),y=t.useRef(s);y.current=s,t.useEffect(()=>{if(!l.length||k.current===v.key)return;k.current=v.key;const n=o.get("file");if(!n)return;j(n);const a=Number.parseInt(o.get("line")??"",10);N(a>0?a:null);const c=te(n,l).filter(x=>!y.current.has(x));c.length>0&&d([...y.current,...c]),r({},{replace:!0})},[l,v.key,o,r,d]),t.useEffect(()=>{const n=a=>{if((a.ctrlKey||a.metaKey)&&a.key==="f"&&g.current){const c=document.activeElement;(!c||!c.closest(".monaco-editor"))&&(a.preventDefault(),g.current.focus())}};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[]);const W=t.useCallback(n=>{n.preventDefault(),b(!0);const a=n.clientX,c=p,x=X=>{const H=Math.max(200,Math.min(500,c+X.clientX-a));P(H)},E=()=>{b(!1),document.removeEventListener("mousemove",x),document.removeEventListener("mouseup",E)};document.addEventListener("mousemove",x),document.addEventListener("mouseup",E)},[p]);return D?e.jsx(_,{text:"Loading project tree..."}):l.length?e.jsx("div",{className:"h-full flex flex-col animate-fade-in",children:e.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[e.jsxs("div",{className:"flex flex-col border-r border-white/5 bg-surface-1 flex-shrink-0 overflow-hidden",style:{width:`${p}px`},children:[e.jsxs("div",{className:"flex items-center gap-1 px-2 py-1.5 border-b border-white/5 flex-shrink-0",children:[e.jsxs("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-gray-500 mr-auto",children:["Explorer",e.jsxs("span",{className:"ml-1.5 font-normal text-gray-600",children:[T," files"]})]}),e.jsx("button",{onClick:()=>d(A),className:"p-1 rounded hover:bg-white/5 text-gray-500 hover:text-gray-300 transition-colors",title:"Expand all",children:e.jsx(G,{size:14})}),e.jsx("button",{onClick:h,className:"p-1 rounded hover:bg-white/5 text-gray-500 hover:text-gray-300 transition-colors",title:"Collapse all",children:e.jsx(J,{size:14})})]}),e.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1.5 border-b border-white/5 flex-shrink-0",children:[e.jsx(Y,{size:13,className:"text-gray-500 flex-shrink-0"}),e.jsx("input",{ref:g,type:"text",value:m,onChange:n=>w(n.target.value),placeholder:"Filter files...",className:"flex-1 bg-transparent border-none outline-none text-xs text-gray-300 placeholder-gray-600 min-w-0"}),m&&e.jsx("button",{onClick:()=>w(""),className:"p-0.5 rounded hover:bg-white/5 text-gray-500 hover:text-gray-300",children:e.jsx(Z,{size:12})})]}),e.jsx("div",{className:"flex-1 overflow-y-auto overflow-x-hidden py-1 scrollbar-thin",children:e.jsx(B,{nodes:l,expanded:s,selectedPath:S??i,onToggle:u,onSelect:j,filter:m||void 0})})]}),e.jsx("div",{ref:M,className:`w-1 cursor-col-resize hover:bg-brand-500/30 transition-colors flex-shrink-0 ${C?"bg-brand-500/40":""}`,onMouseDown:W}),e.jsx("div",{className:"flex-1 overflow-hidden",children:i?e.jsx(O,{filePath:i,onActiveFileChange:z,initialHighlightLine:R,onHighlightConsumed:()=>N(null)}):e.jsx("div",{className:"h-full flex items-center justify-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-3 text-gray-500",children:[e.jsx(ee,{size:40,strokeWidth:1,className:"text-gray-600"}),e.jsx("p",{className:"text-sm",children:"Select a file to view its contents"}),e.jsx("p",{className:"text-xs text-gray-600",children:"Browse the project tree on the left"})]})})})]})}):e.jsx(Q,{title:"No project files",description:"No files found in this project",icon:e.jsx(V,{size:28})})}export{me as ProjectExplorer};
|