@testver/testver 1.4.2 → 1.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1174 -800
- package/package.json +1 -1
- package/src/ui/static/assets/AIPanel-KQFq4c0Q.js +32 -0
- package/src/ui/static/assets/AIRecordPanel-CAs8fXyS.js +40 -0
- package/src/ui/static/assets/AIStreamUI-p_sMTEDQ.js +9 -0
- package/src/ui/static/assets/{AITestGenPage-D3t2gPAA.js → AITestGenPage-CHaHfmu4.js} +1 -1
- package/src/ui/static/assets/APITestingPage-BSGJY_hd.js +19 -0
- package/src/ui/static/assets/{AboutPage-CjEqKB-q.js → AboutPage-CDa24SCJ.js} +1 -1
- package/src/ui/static/assets/{AdvancedPage-4kAcpE8Y.js → AdvancedPage-BqXP0FLg.js} +1 -1
- package/src/ui/static/assets/{AnalyticsPage-64mYNK2v.js → AnalyticsPage-Lm8noJqC.js} +1 -1
- package/src/ui/static/assets/{AuditLogPage-BQjOzQje.js → AuditLogPage-BvldSIik.js} +1 -1
- package/src/ui/static/assets/ChangesSummary-Cu0_4Ucf.js +3 -0
- package/src/ui/static/assets/{CodeMapPage-B1ezmnlE.js → CodeMapPage-uEjuo3fk.js} +3 -3
- package/src/ui/static/assets/{ConfirmDialog-t7mpeeSN.js → ConfirmDialog-DtotgVmI.js} +1 -1
- package/src/ui/static/assets/{CoveragePage-YMmCbiBk.js → CoveragePage-jNkQJA1P.js} +1 -1
- package/src/ui/static/assets/{CronBuilder-Nk-K-_8I.js → CronBuilder-D2fERHt9.js} +1 -1
- package/src/ui/static/assets/{Dashboard-BDVxO2V4.js → Dashboard-BaIj_IdQ.js} +1 -1
- package/src/ui/static/assets/{DefectsPage-l8yGeCyR.js → DefectsPage-DH0njYFG.js} +3 -3
- package/src/ui/static/assets/{EmptyState-D1T3JWUr.js → EmptyState-utxlJ0fu.js} +1 -1
- package/src/ui/static/assets/{ExportButton-Dt5RhL-h.js → ExportButton-ouKqn9CU.js} +1 -1
- package/src/ui/static/assets/{FileViewer-CrKgh_cB.js → FileViewer-mU3JloJ6.js} +1 -1
- package/src/ui/static/assets/{GitPage-_4nCEzkJ.js → GitPage-TrX-RqNC.js} +5 -5
- package/src/ui/static/assets/{ImportExportPage-BcR7IQi9.js → ImportExportPage-CIhK_raX.js} +1 -1
- package/src/ui/static/assets/{JiraPushDialog-C2sP4_4h.js → JiraPushDialog-DgEZS-0u.js} +1 -1
- package/src/ui/static/assets/{KpiTile-inmeEsy3.js → KpiTile-BHLE3HVj.js} +1 -1
- package/src/ui/static/assets/{LiveExecutionView-D5BRe9jq.js → LiveExecutionView-CaIf7Jux.js} +1 -1
- package/src/ui/static/assets/{ManagePage-B8iG6Q0B.js → ManagePage-SvRQ6L19.js} +1 -1
- package/src/ui/static/assets/{MediaModal-C5n6sHYi.js → MediaModal-DNM45Uz2.js} +1 -1
- package/src/ui/static/assets/{MobileRunPicker-0h-N2c6d.js → MobileRunPicker-DFKm6_nU.js} +1 -1
- package/src/ui/static/assets/{MobileRunTarget-Bo_xekig.js → MobileRunTarget-DHDoDZ_F.js} +3 -3
- package/src/ui/static/assets/{ModuleExplorer-VGcmK167.js → ModuleExplorer-rni7JbsL.js} +1 -1
- package/src/ui/static/assets/{OutputPage-B_1nPPxE.js → OutputPage-Cn2WCpJ6.js} +1 -1
- package/src/ui/static/assets/{PipelinesPanel-PmmPu8pj.js → PipelinesPanel-D6zWcLtD.js} +1 -1
- package/src/ui/static/assets/{ProfilePage-y7tJNNFd.js → ProfilePage-BKNdkSnx.js} +1 -1
- package/src/ui/static/assets/{ProjectExplorer-DbfGhRq0.js → ProjectExplorer-5e7J8t-o.js} +1 -1
- package/src/ui/static/assets/{RemoteFileStrip-WuRKtx_h.js → RemoteFileStrip-C1S2aclP.js} +1 -1
- package/src/ui/static/assets/{ReportCard-G52Q6-2i.js → ReportCard-D4EElEe9.js} +2 -2
- package/src/ui/static/assets/{ReportFullView-Bt8UFP2J.js → ReportFullView-2w2ysKRg.js} +1 -1
- package/src/ui/static/assets/{ReportsPage-DMtDi73Q.js → ReportsPage-9Fx-IEwV.js} +2 -2
- package/src/ui/static/assets/{ResultsPage-BI9jpK2N.js → ResultsPage-DPkfGh-K.js} +1 -1
- package/src/ui/static/assets/{RunState-ifC4zi6M.js → RunState-CRuS_bC2.js} +1 -1
- package/src/ui/static/assets/{RunTargets-C7vpCbck.js → RunTargets-CPKBrefj.js} +1 -1
- package/src/ui/static/assets/{ScriptMappingPage-7vHuvhQw.js → ScriptMappingPage-C3K_uyf0.js} +1 -1
- package/src/ui/static/assets/{SearchableDevicePicker-BYxYJNWl.js → SearchableDevicePicker-DubIldKj.js} +1 -1
- package/src/ui/static/assets/{SettingsPage-DSISg7r7.js → SettingsPage-BuZrrlW2.js} +1 -1
- package/src/ui/static/assets/{SharedReportView-BOqKGJmR.js → SharedReportView-ig5hECRk.js} +1 -1
- package/src/ui/static/assets/{SourcesPage-CgqtYGBi.js → SourcesPage-BPkqRqkC.js} +1 -1
- package/src/ui/static/assets/{TestExplorerPage-gYLhCD4d.js → TestExplorerPage-C_jl93GR.js} +3 -3
- package/src/ui/static/assets/{TestManagementPage-wqYTKP7W.js → TestManagementPage-DJiWpCne.js} +2 -2
- package/src/ui/static/assets/{TestPlansPage-DOKX9p6z.js → TestPlansPage-G1lvK1C0.js} +3 -3
- package/src/ui/static/assets/{TestverCreditsDetail-cSW0SpNx.js → TestverCreditsDetail-BKpt4oLW.js} +1 -1
- package/src/ui/static/assets/{TestverCreditsRing-DpMzl3h7.js → TestverCreditsRing-CEBSy3w3.js} +1 -1
- package/src/ui/static/assets/{UncommittedDiffViewer-BxS0zi-p.js → UncommittedDiffViewer-FKvUZcRi.js} +2 -2
- package/src/ui/static/assets/{UserManagementPage-B5d0uDU_.js → UserManagementPage-gDGhaHE4.js} +3 -3
- package/src/ui/static/assets/{WorkflowsPage-Bk0DFnFS.js → WorkflowsPage-BACdnU-1.js} +1 -1
- package/src/ui/static/assets/{hiddenLlmProviders-CdhhNa5G.js → hiddenLlmProviders-DzwaR-b9.js} +1 -1
- package/src/ui/static/assets/index-D6sQYc_0.js +47 -0
- package/src/ui/static/assets/{index-DpQhqcHv.js → index-DLmlY2Ol.js} +1 -1
- package/src/ui/static/assets/index-aInN0yoR.css +1 -0
- package/src/ui/static/assets/{reportMeta-AKcU_qwq.js → reportMeta-3kxT7BIT.js} +1 -1
- package/src/ui/static/assets/{useChartTheme-BFz2QcND.js → useChartTheme-CTIe6M63.js} +1 -1
- package/src/ui/static/assets/{useDebouncedValue-BsHptIvX.js → useDebouncedValue-C9odz7b2.js} +1 -1
- package/src/ui/static/assets/{useFeatureFlags-DNkIctil.js → useFeatureFlags-DrhvBp0C.js} +1 -1
- package/src/ui/static/assets/{useJiraConnector-D5ysBBvz.js → useJiraConnector-Dwj69Rfh.js} +1 -1
- package/src/ui/static/assets/useOwnership-C1CmzcvJ.js +1 -0
- package/src/ui/static/assets/useSuites-V0AxZYex.js +1 -0
- package/src/ui/static/assets/{useTabParam-ChbOedP1.js → useTabParam-CyYAP90W.js} +1 -1
- package/src/ui/static/assets/{useTestExplorer-DT8frjCK.js → useTestExplorer-CUqC18DV.js} +1 -1
- package/src/ui/static/assets/{useTestLifecycle-OcwQaB1s.js → useTestLifecycle-C2S_vaX2.js} +1 -1
- package/src/ui/static/assets/{useTestManagement-Xm4Bcx3u.js → useTestManagement-DW6AW2mt.js} +2 -2
- package/src/ui/static/assets/{useTestResults-D5EwGIX9.js → useTestResults-yjH1aUy-.js} +1 -1
- package/src/ui/static/assets/{vendor-charts-DWFQlmCz.js → vendor-charts-By5uZ93z.js} +1 -1
- package/src/ui/static/assets/{vendor-flow-YGpC9U9I.js → vendor-flow-B61ZV-pm.js} +1 -1
- package/src/ui/static/assets/{vendor-icons-BKPiFyYV.js → vendor-icons-D_Dmmj8d.js} +277 -282
- package/src/ui/static/assets/vendor-query-DkZSMtfn.js +1 -0
- package/src/ui/static/assets/{vendor-quill-W-RoQfb6.js → vendor-quill-xJF2Jvjc.js} +1 -1
- package/src/ui/static/assets/{vendor-react-CTbHBddL.js → vendor-react-DOVfxdUy.js} +1 -1
- package/src/ui/static/index.html +5 -5
- package/src/ui/static/assets/AIPanel-B_R-CbrF.js +0 -32
- package/src/ui/static/assets/AIRecordPanel-BRQWIU5h.js +0 -40
- package/src/ui/static/assets/AIStreamUI-C3D989_6.js +0 -9
- package/src/ui/static/assets/APITestingPage-Cmwkiiys.js +0 -19
- package/src/ui/static/assets/ChangesSummary-CY_Vb27i.js +0 -2
- package/src/ui/static/assets/DiffViewer-BIU09a_i.js +0 -2
- package/src/ui/static/assets/index-BYVxKLrT.js +0 -47
- package/src/ui/static/assets/index-C2KJt7SI.css +0 -1
- package/src/ui/static/assets/useOwnership-U0AfKBRo.js +0 -1
- package/src/ui/static/assets/useSuites-DyfN9HVv.js +0 -1
- package/src/ui/static/assets/vendor-query-BrzmPFT3.js +0 -1
|
@@ -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{eh as Y,fN as W,fO as G,eK as U,fP as V,fQ as J,fR as X,fS as Z,fT as H,fU as ee,fV as se,ae as te,b as re,fW as ae,fX as ne,fY as ie,L as oe,fZ as ce,B as $,f_ as de,f$ as le,g0 as xe,bO as L,g1 as ue}from"./index-D6sQYc_0.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 O,ce as Se,t as Pe,K as ze,M as Ae,x as Te}from"./vendor-icons-D_Dmmj8d.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:Y}),[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:W,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(V,{start:()=>X(x).catch(a=>{throw s("error",a.message),b(),a}),confirm:async a=>{const w=await J(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 Q(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 I(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"},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 Ye(){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}=Q(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=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(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}=Q(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})," ",I(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(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:I(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{Ye 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-D6sQYc_0.js";import{u as $,F as B,a as O}from"./FileViewer-mU3JloJ6.js";import{E as Q}from"./EmptyState-utxlJ0fu.js";import{F as V,ax as G,ay as J,v as Y,X as Z,i as ee}from"./vendor-icons-D_Dmmj8d.js";import"./RemoteFileStrip-C1S2aclP.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-FKvUZcRi.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,P]=t.useState(null),[m,w]=t.useState(""),[p,z]=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));z(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:P,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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,u}from"./vendor-react-
|
|
1
|
+
import{j as e,u}from"./vendor-react-DOVfxdUy.js";import{aa as d,a9 as g,ax as f,ay as h,h as x,P as b}from"./index-D6sQYc_0.js";import{A as k,s as m,aa as y,br as j}from"./vendor-icons-D_Dmmj8d.js";function p(){const n=d(),{data:t}=g(n),s=(t==null?void 0:t.check)??null,i=new Map;if(s&&f(s)){for(const a of s.incoming)for(const r of a.files){const o=h(s,r.path);o&&!i.has(o)&&i.set(o,a)}for(const a of s.incomingFiles){const r=h(s,a);r&&!i.has(r)&&i.set(r,{sha:s.upstreamSha??"",shortSha:"",author:"",email:"",message:"",timestamp:"",files:[]})}}return{check:s,byPath:i}}const c=n=>n.replace(/\\/g,"/").replace(/^\.\//,"");function v({path:n,byPath:t,label:s}){return t.has(c(n))?e.jsx("span",{className:"text-[10px] font-semibold px-1 rounded bg-sky-500/15 text-sky-700 dark:text-sky-300 flex items-center flex-shrink-0",title:`Newer on ${s}`,children:e.jsx(k,{size:10})}):null}function P({filePath:n}){const t=u(),{check:s,byPath:i}=p(),a=i.get(c(n));if(!s||!a)return null;const r=x(s),o=s.projectPrefix+c(n),l=s.dirtyFiles.includes(o);return e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-sky-500/30 bg-sky-500/10 text-xs text-gray-700 dark:text-gray-300 flex-shrink-0",children:[e.jsx(m,{size:13,className:"text-sky-600 shrink-0"}),e.jsxs("span",{className:"flex-1 min-w-0",children:[a.author?e.jsxs(e.Fragment,{children:[a.author," changed this file on ",r," ",b(a.timestamp)," — “",a.message,"”."]}):e.jsxs(e.Fragment,{children:["This file has newer changes on ",r,"."]}),l&&" You also have uncommitted edits here."]}),e.jsxs("button",{onClick:()=>t("/git?incoming=1"),className:"px-2 py-1 text-xs rounded bg-surface-2 hover:bg-surface-3 text-gray-300 border border-white/5 flex items-center gap-1 shrink-0",children:[e.jsx(y,{size:12})," View change"]}),e.jsx("button",{onClick:()=>t("/git"),className:`px-2 py-1 text-xs rounded text-white flex items-center gap-1 shrink-0 ${l?"bg-amber-600 hover:bg-amber-500":"bg-emerald-600 hover:bg-emerald-500"}`,children:l?e.jsxs(e.Fragment,{children:[e.jsx(j,{size:12})," Stash, pull & re-apply"]}):e.jsxs(e.Fragment,{children:[e.jsx(m,{size:12})," Pull"]})})]})}function R({filePath:n}){const{check:t,byPath:s}=p();return!t||!s.has(c(n))?null:e.jsxs("span",{className:"text-[9px] font-medium text-sky-700 dark:text-sky-300 bg-sky-500/15 px-1.5 py-0.5 rounded uppercase",children:["Newer on ",x(t)]})}export{v as I,R,P as a,p as u};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as p,j as e,u as Fe,L as Te}from"./vendor-react-CTbHBddL.js";import{f as X}from"./formatDate-T65-Y6Mi.js";import{T as he,a as Re,K as Me}from"./KpiTile-inmeEsy3.js";import{R as O,P as De,m as Be,n as ze,T as K,o as H,B as ge,h as G,X as J,Y as Q,l as me,j as Ie,L as _e}from"./vendor-charts-DWFQlmCz.js";import{y as V,S as Ue,v as Oe,cy as Ke,a0 as B,a5 as He,dl as z,am as Pe,dm as pe,L as We,dn as qe,_ as Ye,ag as Xe,dd as Ge}from"./vendor-icons-BKPiFyYV.js";import{a8 as Je,bN as Qe,a1 as ue,gI as Ze,gJ as Ve,gK as et,gL as tt}from"./index-BYVxKLrT.js";function be({active:t,payload:s,label:a,clickHint:n}){return!t||!s||s.length===0?null:e.jsxs("div",{className:"rounded-lg border border-gray-200 dark:border-white/10 bg-white dark:bg-gray-900 shadow-lg px-2.5 py-2 text-xs min-w-[120px]",children:[a!=null&&a!==""&&e.jsx("div",{className:"text-[10px] uppercase tracking-wider font-semibold text-gray-500 dark:text-gray-400 mb-1.5",children:String(a)}),e.jsx("div",{className:"space-y-1",children:s.map((r,g)=>{var N;const l=r.value,x=String(r.name??r.dataKey??""),S=r.color||((N=r.payload)==null?void 0:N.fill)||"#3B82F6";return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{"aria-hidden":!0,className:"inline-block w-2.5 h-2.5 rounded-sm flex-shrink-0",style:{background:S}}),x&&x!=="value"&&e.jsx("span",{className:"text-gray-600 dark:text-gray-300 flex-1 truncate",children:x}),e.jsx("span",{className:"tabular-nums font-semibold text-gray-900 dark:text-gray-100 ml-auto",children:typeof l=="number"?Number.isInteger(l)?l.toLocaleString():l.toFixed(2):String(l??"")})]},g)})}),n&&e.jsx("div",{className:"mt-1.5 pt-1.5 border-t border-gray-100 dark:border-white/10 text-[11px] text-blue-700 dark:text-blue-300",children:n})]})}const ye={vibrant:["#8AB4F8","#F4A0A0","#7DD3AE","#F6C66E","#B3A1EE","#F2A5C7","#7CCFC6","#F7B489","#A2ACF2","#8BCFE6"],pastel:["#93C5FD","#FCA5A5","#6EE7B7","#FCD34D","#C4B5FD","#F9A8D4","#5EEAD4","#FDBA74","#A5B4FC","#67E8F9"]},rt={status:{passed:"#7DD3AE",failed:"#F4A0A0",skipped:"#F6C66E",blocked:"#F7B489",not_run:"#C3C9D2",in_progress:"#8AB4F8"},priority:{critical:"#F4A0A0",high:"#F7B489",medium:"#F6C66E",low:"#8AB4F8"},severity:{blocker:"#EE8F8F",critical:"#F4A0A0",major:"#F6C66E",minor:"#8AB4F8",trivial:"#C3C9D2"}};function fe(t,s,a){if(Array.isArray(a)&&a.length>=t.length&&a.every(g=>typeof g=="string"))return a;const n=ye.vibrant;if(s==="status"||s==="priority"||s==="severity"){const g=rt[s];return t.map((l,x)=>g[String(l).toLowerCase().replace(/\s+/g,"_")]||n[x%n.length])}const r=s==="pastel"?ye.pastel:n;return t.map((g,l)=>r[l%r.length])}const P=t=>s=>{const a=String(s??"");return a.length>t?`${a.slice(0,t-1)}…`:a},ke=t=>(Array.isArray(t)?t:[]).map(s=>typeof s=="number"&&Number.isFinite(s)?s:Number(s)||0);function at({cell:t,height:s=260,onPick:a,clickHint:n}){var v;const r=p.useMemo(()=>{var j;const i=(Array.isArray(t.labels)?t.labels:[]).map(w=>String(w??"")),h=(Array.isArray(t.datasets)?t.datasets:[]).filter(w=>w&&typeof w=="object").map((w,$)=>({label:String(w.label??`Series ${$+1}`),data:ke(w.data)})),y=t.chartType==="pie"||t.chartType==="doughnut",k=Array.isArray(t.data)&&t.data.length>0?ke(t.data):y?(j=h[0])==null?void 0:j.data:void 0;return{...t,labels:i,data:k,datasets:y?void 0:h.length>0?h:void 0}},[t]),g=p.useMemo(()=>fe(r.labels,r.colorScheme,r.colors),[r.labels,r.colorScheme,r.colors]),l=p.useMemo(()=>fe((r.datasets||[]).map(i=>i.label),r.colorScheme,r.colors),[r.datasets,r.colorScheme,r.colors]),x=r.datasets&&r.datasets.length>0?l:g,S=p.useMemo(()=>r.datasets&&r.datasets.length>0?r.labels.map((i,h)=>{const y={label:i};for(const k of r.datasets)y[k.label]=k.data[h]??0;return y}):r.labels.map((i,h)=>{var y;return{label:i,value:((y=r.data)==null?void 0:y[h])??0}}),[r.labels,r.data,r.datasets]),N=((v=r.datasets)==null?void 0:v.map(i=>i.label))??["value"],R=r.labels.reduce((i,h)=>Math.max(i,h.length),0),C={fill:"rgb(107 114 128)",fontSize:11},L="rgba(107,114,128,0.2)",A={stroke:"rgba(107,114,128,0.4)"},M={fill:"rgba(107,114,128,0.08)"},m=p.useMemo(()=>{var w;const i=(((w=r.datasets)==null?void 0:w.flatMap($=>$.data))??r.data??[]).filter($=>Number.isFinite($));if(i.length<2)return;const h=Math.min(...i),y=Math.max(...i),k=Math.max((y-h)*.15,Math.abs(y)*.01,1);return[h>=0?Math.max(0,Math.floor(h-k)):Math.floor(h-k),Math.ceil(y+k)]},[r.data,r.datasets]),o=a?i=>{const h=i==null?void 0:i.activeTooltipIndex;typeof h=="number"&&h>=0&&a(h)}:void 0,u=a?{cursor:"pointer"}:void 0,b=e.jsx(be,{clickHint:a?n:void 0}),f=i=>e.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:String(i??"")}),d={fontSize:11,color:"rgb(107 114 128)",maxHeight:56,overflowY:"auto"};if(r.labels.length===0||!r.datasets&&!(r.data&&r.data.length>0))return e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 p-4 text-center",children:"No data to chart."});switch(r.chartType){case"line":return e.jsx(O,{width:"100%",height:s,children:e.jsxs(Ie,{data:S,margin:{top:8,right:16,bottom:8,left:0},onClick:o,style:u,children:[e.jsx(G,{strokeDasharray:"3 3",stroke:L}),e.jsx(J,{dataKey:"label",tick:C,axisLine:!1,tickLine:!1,interval:0,angle:-28,textAnchor:"end",height:60,tickFormatter:P(16)}),e.jsx(Q,{tick:C,axisLine:!1,tickLine:!1,domain:m,allowDecimals:!0}),e.jsx(K,{content:b,cursor:A}),N.length>1&&e.jsx(H,{wrapperStyle:d,formatter:f}),N.map((i,h)=>e.jsx(_e,{type:"monotone",dataKey:i,stroke:x[h%x.length],strokeWidth:2,dot:{r:3,fill:x[h%x.length]},activeDot:{r:5}},i))]})});case"bar":case"stacked_bar":return e.jsx(O,{width:"100%",height:s,children:e.jsxs(ge,{data:S,margin:{top:8,right:16,bottom:8,left:0},onClick:o,style:u,children:[e.jsx(G,{strokeDasharray:"3 3",stroke:L}),e.jsx(J,{dataKey:"label",tick:C,axisLine:!1,tickLine:!1,interval:0,angle:-28,textAnchor:"end",height:60,tickFormatter:P(16)}),e.jsx(Q,{tick:C,axisLine:!1,tickLine:!1}),e.jsx(K,{content:b,cursor:M}),N.length>1&&e.jsx(H,{wrapperStyle:d,formatter:f}),N.map((i,h)=>e.jsx(me,{dataKey:i,fill:x[h%x.length],radius:[4,4,0,0],stackId:r.chartType==="stacked_bar"?"s1":void 0},i))]})});case"horizontal_bar":return e.jsx(O,{width:"100%",height:Math.max(s,r.labels.length*28+40),children:e.jsxs(ge,{data:S,layout:"vertical",margin:{top:8,right:24,bottom:8,left:0},onClick:o,style:u,children:[e.jsx(G,{strokeDasharray:"3 3",stroke:L,horizontal:!1}),e.jsx(J,{type:"number",tick:C,axisLine:!1,tickLine:!1}),e.jsx(Q,{type:"category",dataKey:"label",tick:C,axisLine:!1,tickLine:!1,width:Math.min(180,Math.max(60,R*6.5)),tickFormatter:P(28)}),e.jsx(K,{content:b,cursor:M}),N.length>1&&e.jsx(H,{wrapperStyle:d,formatter:f}),N.map((i,h)=>e.jsx(me,{dataKey:i,fill:x[h%x.length],radius:[0,4,4,0]},i))]})});case"pie":case"doughnut":{const i=r.labels.map((k,j)=>{var w;return{name:k,value:((w=r.data)==null?void 0:w[j])??0}}),h=i.reduce((k,j)=>k+(Number(j.value)||0),0),y=(k,j)=>{var I;const w=Number((I=j==null?void 0:j.payload)==null?void 0:I.value)||0,$=h>0?Math.round(w/h*1e3)/10:0;return e.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:`${P(28)(k)} · ${$}%`})};return e.jsx(O,{width:"100%",height:s,children:e.jsxs(De,{children:[e.jsx(Be,{data:i,dataKey:"value",nameKey:"name",innerRadius:r.chartType==="doughnut"?"55%":0,outerRadius:"85%",paddingAngle:2,children:i.map((k,j)=>e.jsx(ze,{fill:x[j%x.length],stroke:"transparent"},j))}),e.jsx(K,{content:e.jsx(be,{})}),e.jsx(H,{wrapperStyle:d,formatter:y})]})})}default:return e.jsxs("div",{className:"text-xs text-gray-500 p-4",children:["Unsupported chart type: ",r.chartType]})}}function st(){const t=p.useRef(null),[s,a]=p.useState(0);return p.useEffect(()=>{const n=t.current;if(!n||typeof ResizeObserver>"u")return;const r=new ResizeObserver(g=>{var l;return a(((l=g[0])==null?void 0:l.contentRect.width)??0)});return r.observe(n),a(n.getBoundingClientRect().width),()=>r.disconnect()},[]),[t,s]}function je({spec:t,links:s=!0}){const[a,n]=st(),r=n>0&&n<640,g=Array.isArray(t.cells)?t.cells:[],l=typeof t.method=="string"?t.method.trim():"";return e.jsxs("div",{ref:a,className:"flex flex-col gap-4",children:[t.summary&&e.jsx(nt,{summary:t.summary,narrow:r}),e.jsx("div",{className:"grid grid-cols-12 gap-4",children:g.map((x,S)=>e.jsx(it,{cell:x,narrow:r,links:s},S))}),l&&e.jsxs("details",{className:"rounded-xl border border-gray-200 dark:border-white/10 bg-white dark:bg-white/[0.03] px-5 py-3.5 group","data-testid":"report-method",children:[e.jsxs("summary",{className:"cursor-pointer text-sm font-semibold text-gray-800 dark:text-gray-200 list-none flex items-center gap-1.5",children:[e.jsx(V,{size:14,className:"transition-transform group-open:rotate-180","aria-hidden":!0}),"How this was calculated"]}),e.jsx("p",{className:"mt-2 text-sm leading-relaxed text-gray-700 dark:text-gray-300 whitespace-pre-line",children:l})]})]})}const we={good:{sym:"✓",cls:"bg-emerald-50 text-emerald-700 dark:bg-emerald-500/15 dark:text-emerald-300"},warn:{sym:"~",cls:"bg-amber-50 text-amber-700 dark:bg-amber-500/15 dark:text-amber-300"},bad:{sym:"!",cls:"bg-rose-50 text-rose-700 dark:bg-rose-500/15 dark:text-rose-300"},info:{sym:"i",cls:"bg-gray-100 text-gray-700 dark:bg-white/10 dark:text-gray-300"}};function nt({summary:t,narrow:s}){const a=Array.isArray(t.findings)?t.findings:[],n=t.status&&he[t.status]?t.status:void 0;return e.jsxs("section",{className:`rounded-xl border border-gray-200 dark:border-white/10 bg-white dark:bg-white/[0.03] px-5 py-4 grid gap-5 ${s||a.length===0?"grid-cols-1":"grid-cols-[minmax(220px,1fr)_minmax(0,2fr)]"}`,"aria-label":"Summary","data-testid":"report-summary",children:[e.jsxs("div",{className:"flex flex-col items-start gap-2",children:[n&&e.jsxs("span",{className:`inline-flex items-center gap-1.5 rounded-full px-2.5 py-0.5 text-xs font-semibold ${Re[n]}`,children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-current opacity-80","aria-hidden":!0}),he[n]]}),t.verdict&&e.jsx("p",{className:"text-lg leading-snug font-bold text-gray-900 dark:text-gray-100",children:t.verdict}),e.jsxs("p",{className:"flex items-center gap-1.5 text-xs text-gray-500 dark:text-gray-400",children:[e.jsx(Ue,{size:13,"aria-hidden":!0})," Summary written by the AI Assistant"]})]}),a.length>0&&e.jsx("ul",{className:"flex flex-col gap-2.5",children:a.map((r,g)=>{const l=we[r.tone]??we.info;return e.jsxs("li",{className:"flex items-start gap-2.5 text-sm leading-relaxed text-gray-700 dark:text-gray-300",children:[e.jsx("span",{className:`mt-0.5 flex h-[18px] w-[18px] flex-shrink-0 items-center justify-center rounded-full text-[11px] font-bold ${l.cls}`,"aria-hidden":!0,children:l.sym}),e.jsxs("span",{children:[e.jsx("strong",{className:"font-semibold text-gray-900 dark:text-gray-100",children:r.title}),r.detail?` ${r.detail}`:""]})]},g)})})]})}function it({cell:t,narrow:s,links:a}){const n=t.type==="kpi"?3:t.type==="chart"?6:12,r=Math.max(1,Math.min(12,Math.round(Number(t.span)||n))),g=s?t.type==="kpi"?6:12:r,l={gridColumn:`span ${g} / span ${g}`};return t.type==="kpi"?e.jsx("div",{style:l,children:e.jsx(Me,{cell:t})}):t.type==="chart"?e.jsx("div",{style:l,children:e.jsx(ot,{cell:t,links:a})}):t.type==="table"?e.jsx("div",{style:l,children:e.jsx(ht,{cell:t,links:a})}):t.type==="markdown"?e.jsx("div",{style:l,children:e.jsx("div",{className:"rounded-xl border border-gray-200 dark:border-white/10 bg-white dark:bg-white/[0.03] px-5 py-4","data-testid":"report-note",children:e.jsx(gt,{content:String(t.content??"")})})}):null}function ot({cell:t,links:s}){const a=Fe(),n=s&&Array.isArray(t.runIds)&&t.runIds.some(Boolean)?t.runIds:null,r=n?g=>{const l=n[g];l&&a(`/results?runId=${encodeURIComponent(l)}`)}:void 0;return e.jsxs("div",{className:"rounded-xl border border-gray-200 dark:border-white/10 bg-white dark:bg-white/[0.03] px-5 py-4 h-full","data-testid":"report-chart",children:[e.jsx("h3",{className:"text-base font-semibold text-gray-900 dark:text-gray-100",children:t.title}),(t.hint||n)&&e.jsxs("p",{className:"mt-0.5 text-[13px] text-gray-500 dark:text-gray-400",children:[t.hint,t.hint&&n?" ":"",n?"Click a bar or point to open the run.":""]}),e.jsx("div",{className:"mt-3",children:e.jsx(at,{cell:t,onPick:r,clickHint:"Click to open this run in Results"})})]})}const lt=/^(passed|pass|failed|fail|error|skipped|blocked|flaky|open|in progress|resolved|closed|fixed|rejected|never run|not run)(\s*\((?:error|fixed)\))?(?:\s*[—–-]\s+([\s\S]+))?$/i,dt={ok:"bg-emerald-50 text-emerald-700 dark:bg-emerald-500/15 dark:text-emerald-300",bad:"bg-rose-50 text-rose-700 dark:bg-rose-500/15 dark:text-rose-300",warn:"bg-amber-50 text-amber-700 dark:bg-amber-500/15 dark:text-amber-300",neutral:"bg-gray-100 text-gray-700 dark:bg-white/10 dark:text-gray-300"},ct={passed:"ok",pass:"ok",resolved:"ok",closed:"ok",fixed:"ok",failed:"bad",fail:"bad",error:"bad",blocked:"bad",open:"bad",skipped:"warn",flaky:"warn","in progress":"warn"},Ne=/^[-+]?[\d,]+(\.\d+)?\s*(%|ms|s)?$/,xt=/^[A-Za-z0-9._-]{1,120}$/,Z=10;function ve(t){const s=t.trim();return Ne.test(s)?Number(s.replace(/[,%\s]|ms|s$/g,"")):null}function ht({cell:t,links:s=!0}){const a=(Array.isArray(t.headers)?t.headers:[]).map(m=>String(m??"")),n=p.useMemo(()=>(Array.isArray(t.rows)?t.rows:[]).map(m=>(Array.isArray(m)?m:[m]).map(o=>String(o??""))),[t.rows]),[r,g]=p.useState(null),[l,x]=p.useState(""),[S,N]=p.useState(!1),R=p.useMemo(()=>a.map((m,o)=>{const u=n.map(b=>(b[o]??"").trim()).filter(Boolean);return u.length>0&&u.every(b=>Ne.test(b))}),[a,n]),C=p.useMemo(()=>{const m=s&&t.columnLinks&&typeof t.columnLinks=="object"?t.columnLinks:{},o=a.findIndex(u=>m[u]==="file");return(u,b)=>{const f=m[a[b]??""],d=(u[b]??"").trim();if(!f||!d)return null;if(f==="run"){const v=d.split(/\s+/)[0]??"";return xt.test(v)?`/results?runId=${encodeURIComponent(v)}`:null}return f==="file"?`/tests?file=${encodeURIComponent(d)}`:f==="test"&&o>=0&&u[o]?`/tests?file=${encodeURIComponent(u[o].trim())}&test=${encodeURIComponent(d)}`:null}},[s,t.columnLinks,a]),L=p.useMemo(()=>{const m=l.trim().toLowerCase();let o=m?n.filter(u=>u.some(b=>b.toLowerCase().includes(m))):n;return r&&(o=[...o].sort((u,b)=>{const f=u[r.col]??"",d=b[r.col]??"",v=ve(f),i=ve(d);return(v!=null&&i!=null?v-i:f.localeCompare(d,void 0,{numeric:!0,sensitivity:"base"}))*r.dir})),o},[n,l,r]),A=S?L:L.slice(0,Z),M=m=>g(o=>{const u=R[m]?-1:1;return!o||o.col!==m?{col:m,dir:u}:o.dir===u?{col:m,dir:u===1?-1:1}:null});return e.jsxs("div",{className:"rounded-xl border border-gray-200 dark:border-white/10 bg-white dark:bg-white/[0.03] px-5 py-4 h-full","data-testid":"report-table",children:[e.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{className:"text-base font-semibold text-gray-900 dark:text-gray-100",children:t.title}),t.hint&&e.jsx("p",{className:"mt-0.5 text-[13px] text-gray-500 dark:text-gray-400",children:t.hint})]}),n.length>Z&&e.jsxs("label",{className:"flex h-8 items-center gap-2 rounded-lg border border-gray-300 dark:border-white/15 px-2.5 text-[13px] text-gray-500 dark:text-gray-400",children:[e.jsx(Oe,{size:13,"aria-hidden":!0}),e.jsx("span",{className:"sr-only",children:"Filter rows"}),e.jsx("input",{value:l,onChange:m=>{x(m.target.value),N(!1)},placeholder:"Filter rows",className:"w-36 bg-transparent text-[13px] text-gray-900 dark:text-gray-100 outline-none placeholder:text-gray-400"})]})]}),e.jsx("div",{className:"mt-3 overflow-x-auto rounded-lg border border-gray-200 dark:border-white/10",children:e.jsxs("table",{className:"w-full border-collapse text-sm",children:[e.jsx("thead",{children:e.jsx("tr",{className:"bg-gray-50 dark:bg-white/[0.04]",children:a.map((m,o)=>{const u=(r==null?void 0:r.col)===o;return e.jsx("th",{scope:"col","aria-sort":u?r.dir===1?"ascending":"descending":"none",className:`border-b border-gray-200 dark:border-white/10 px-3.5 py-2.5 text-xs font-semibold uppercase tracking-wide text-gray-600 dark:text-gray-400 whitespace-nowrap ${R[o]?"text-right":"text-left"}`,children:e.jsxs("button",{type:"button",onClick:()=>M(o),className:"inline-flex items-center gap-1 uppercase hover:text-gray-900 dark:hover:text-gray-200",title:`Sort by ${m}`,children:[m,u&&(r.dir===1?e.jsx(Ke,{size:12,"aria-hidden":!0}):e.jsx(V,{size:12,"aria-hidden":!0}))]})},o)})})}),e.jsxs("tbody",{children:[A.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:a.length||1,className:"px-3.5 py-6 text-center text-[13px] text-gray-500 dark:text-gray-400",children:n.length===0?"No rows":"No rows match the filter"})}),A.map((m,o)=>e.jsx("tr",{className:"hover:bg-gray-50/70 dark:hover:bg-white/[0.03]",children:a.map((u,b)=>{const f=m[b]??"",d=lt.exec(f.trim()),v=C(m,b);let i=f;if(d){const h=ct[d[1].toLowerCase()]??"neutral";i=e.jsxs(e.Fragment,{children:[e.jsx("span",{className:`inline-block rounded-full px-2 py-0.5 text-xs font-semibold ${dt[h]}`,children:`${d[1]}${d[2]??""}`.trim()}),d[3]&&e.jsx("span",{className:"ml-1.5 text-gray-500 dark:text-gray-400",children:d[3].trim()})]})}else v&&(i=e.jsx(Te,{to:v,className:"font-medium text-blue-700 dark:text-blue-300 hover:underline",children:f}));return e.jsx("td",{title:f.length>60?f:void 0,className:`border-b border-gray-100 dark:border-white/[0.06] px-3.5 py-2.5 align-top text-gray-800 dark:text-gray-200 ${R[b]?"text-right tabular-nums whitespace-nowrap":""} ${b===0&&!v?"font-medium text-gray-900 dark:text-gray-100":""} max-w-[28rem] break-words`,children:i},b)})},o))]})]})}),L.length>Z&&e.jsx("button",{type:"button",onClick:()=>N(m=>!m),className:"mt-2.5 text-[13px] font-medium text-blue-700 dark:text-blue-300 hover:underline",children:S?"Show fewer rows":`Show all ${L.length} rows`})]})}function gt({content:t}){const s=t.split(`
|
|
2
|
-
`),a=[];let n=[];const r=()=>{n.length!==0&&(a.push(e.jsx("ul",{className:"list-disc pl-5 text-sm text-gray-700 dark:text-gray-300 space-y-1.5 my-2 leading-relaxed",children:n.map((l,x)=>e.jsx("li",{dangerouslySetInnerHTML:{__html:g(l)}},x))},a.length)),n=[])},g=l=>l.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/\*\*(.+?)\*\*/g,'<strong class="font-semibold text-gray-900 dark:text-gray-100">$1</strong>').replace(/`([^`]+)`/g,'<code class="px-1 py-0.5 rounded bg-gray-100 dark:bg-white/10 font-mono text-[12px]">$1</code>');for(const l of s){const x=l.trim();if(!x){r();continue}x.startsWith("## ")||x.startsWith("### ")?(r(),a.push(e.jsx("h3",{className:"text-base font-semibold text-gray-900 dark:text-gray-100 mt-2 mb-1.5",dangerouslySetInnerHTML:{__html:g(x.replace(/^#+\s/,""))}},a.length))):x.startsWith("# ")?(r(),a.push(e.jsx("h2",{className:"text-lg font-bold text-gray-900 dark:text-gray-100 mt-2 mb-1.5",dangerouslySetInnerHTML:{__html:g(x.slice(2))}},a.length))):x.startsWith("- ")||x.startsWith("* ")?n.push(x.slice(2)):(r(),a.push(e.jsx("p",{className:"text-sm text-gray-700 dark:text-gray-300 my-1.5 leading-relaxed",dangerouslySetInnerHTML:{__html:g(x)}},a.length)))}return r(),e.jsx(e.Fragment,{children:a})}const mt=[{days:void 0,label:"Never"},{days:7,label:"7 days"},{days:30,label:"30 days"},{days:90,label:"90 days"}];function jt({spec:t,urls:s,savedId:a,initialShareToken:n,initialShareExpiresAt:r,readonly:g=!1,variant:l="card",chips:x,metaLine:S,leadActions:N,trailActions:R,links:C}){const{hasRole:L}=Je(),A=!g&&L("tester"),[M,m]=p.useState(!1),[o,u]=p.useState(a),[b,f]=p.useState(!1),[d,v]=p.useState(n),[i,h]=p.useState(r),[y,k]=p.useState(!1),[j,w]=p.useState("closed"),[$,I]=p.useState(void 0),[_,U]=p.useState(!1),[ee,te]=p.useState(null),[re,ae]=p.useState(null);p.useEffect(()=>{a&&u(a)},[a]),p.useEffect(()=>{n&&v(n)},[n]),p.useEffect(()=>{r&&h(r)},[r]);const F=c=>{ae(c),setTimeout(()=>ae(null),2600)},D=d?`/reports/share/${d}`:o?`/reports/view/${o}`:(s==null?void 0:s.html)||"",Se=async()=>{if(!D)return;const c=`${window.location.origin}${D}`;try{await navigator.clipboard.writeText(c),m(!0),setTimeout(()=>m(!1),1500)}catch{}},se=async()=>{const c=await tt({title:t.title,spec:t,outputFiles:s?{html:s.html,json:s.json}:void 0});return u(c.id),c.id},ne=async()=>{if(!(o||b)){f(!0);try{await se(),F("Saved to your reports")}catch(c){F(`Save failed: ${c instanceof Error?c.message:String(c)}`)}finally{f(!1)}}},Ce=async()=>{if(!y){k(!0);try{const c=o??await se(),{token:E,shareExpiresAt:Ee}=await Ve(c,$);v(E),h(Ee),w("link"),F("Share link created")}catch(c){F(`Share failed: ${c instanceof Error?c.message:String(c)}`)}finally{k(!1)}}},Ae=async()=>{if(!(!d||!o)){k(!0);try{await et(o),v(void 0),h(void 0),w("closed"),F("Share link revoked")}catch(c){F(`Revoke failed: ${c instanceof Error?c.message:String(c)}`)}finally{k(!1)}}},W=d?`${window.location.origin}/reports/share/${d}`:"",Le=async()=>{if(W)try{await navigator.clipboard.writeText(W),F("Share URL copied")}catch{}},ie=g&&d?`/api/reports/share/${encodeURIComponent(d)}/render.html`:o?Qe(`/api/reports/${encodeURIComponent(o)}/render.html`):d?`/api/reports/share/${encodeURIComponent(d)}/render.html`:s!=null&&s.html?ue(s.html):null,$e=async c=>{U(!1),te(c);try{await Ze(c,g&&d?{shareToken:d}:o?{reportId:o}:{spec:t,title:t.title})}catch(E){F(`Download failed: ${E instanceof Error?E.message:String(E)}`)}finally{te(null)}},q=p.useRef(null);p.useEffect(()=>{if(!_)return;const c=E=>{q.current&&!q.current.contains(E.target)&&U(!1)};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[_]);const oe="inline-flex h-9 items-center gap-1.5 rounded-lg border border-gray-300 dark:border-white/15 bg-white dark:bg-white/[0.04] px-3.5 text-sm font-medium text-gray-900 dark:text-gray-100 hover:bg-gray-50 dark:hover:bg-white/[0.08] transition-colors disabled:opacity-60",Y="inline-flex h-8 items-center gap-1.5 rounded-lg border border-gray-300 dark:border-white/15 bg-white dark:bg-white/[0.04] px-2.5 text-[13px] font-medium text-gray-800 dark:text-gray-100 hover:bg-gray-50 dark:hover:bg-white/[0.08] transition-colors disabled:opacity-60",le="inline-flex h-8 w-8 items-center justify-center rounded-lg border border-gray-300 dark:border-white/15 bg-white dark:bg-white/[0.04] text-gray-600 dark:text-gray-300 hover:bg-gray-50 hover:text-gray-900 dark:hover:bg-white/[0.08] dark:hover:text-gray-100 transition-colors",T=l==="page",de=()=>w(c=>c==="closed"?d?"link":"create":"closed"),ce=e.jsxs("div",{className:"relative",ref:q,children:[e.jsxs("button",{onClick:()=>U(c=>!c),disabled:!!ee,title:"Download","aria-haspopup":"menu","aria-expanded":_,className:T?"inline-flex h-9 items-center gap-1.5 rounded-lg bg-brand-600 px-3.5 text-sm font-medium text-white hover:bg-brand-700 transition-colors disabled:opacity-60":Y,children:[ee?e.jsx(B,{size:T?15:14,className:"animate-spin"}):e.jsx(He,{size:T?15:14}),"Download",e.jsx(V,{size:T?14:13,"aria-hidden":!0})]}),_&&e.jsxs("div",{role:"menu",className:"absolute right-0 top-full mt-1 z-20 w-44 rounded-lg border border-gray-200 dark:border-white/10 bg-white dark:bg-surface-1 shadow-lg py-1 text-sm",children:[ie&&e.jsx("a",{role:"menuitem",href:ie,download:`${t.title||t.id}.html`,onClick:()=>U(!1),className:"block px-3 py-1.5 text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-white/5",children:"HTML page"}),[["pdf","PDF"],["docx","Word (.docx)"],["xlsx","Excel (.xlsx)"]].map(([c,E])=>e.jsx("button",{role:"menuitem",onClick:()=>$e(c),className:"w-full text-left px-3 py-1.5 text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-white/5",children:E},c))]})]}),xe=e.jsxs(e.Fragment,{children:[A&&j==="create"&&!d&&e.jsxs("div",{className:`${T?"rounded-xl border mb-4":"border-b"} px-5 py-2.5 border-gray-200 dark:border-white/10 bg-blue-50/60 dark:bg-blue-500/10 flex items-center gap-2 text-[13px] flex-wrap`,children:[e.jsx(z,{size:13,className:"text-blue-700 dark:text-blue-300 flex-shrink-0"}),e.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:"Anyone with the link can view this report."}),e.jsxs("label",{className:"flex items-center gap-1 text-gray-700 dark:text-gray-300 ml-auto",children:["Expires",e.jsx("select",{value:$??"",onChange:c=>I(c.target.value?Number(c.target.value):void 0),className:"px-1.5 py-0.5 rounded border border-gray-300 dark:border-white/15 bg-white dark:bg-white/[0.05] text-[12px]",children:mt.map(c=>e.jsx("option",{value:c.days??"",children:c.label},c.label))})]}),e.jsx("button",{onClick:Ce,disabled:y,className:"px-2.5 py-1 rounded-md text-[12px] font-semibold bg-brand-600 text-white hover:bg-brand-700 transition-colors",children:"Create link"})]}),A&&d&&j==="link"&&e.jsxs("div",{className:`${T?"rounded-xl border mb-4":"border-b"} px-5 py-2.5 border-gray-200 dark:border-white/10 bg-blue-50/60 dark:bg-blue-500/10 flex items-center gap-2 text-[13px] flex-wrap`,children:[e.jsx(z,{size:13,className:"text-blue-700 dark:text-blue-300 flex-shrink-0"}),e.jsx("span",{className:"text-gray-700 dark:text-gray-300 flex-shrink-0",children:"Public link:"}),e.jsx("code",{className:"flex-1 min-w-[12rem] truncate font-mono text-[12px] text-blue-800 dark:text-blue-200 bg-white dark:bg-white/[0.05] border border-blue-200 dark:border-blue-400/20 rounded px-2 py-1",children:W}),e.jsx("span",{className:"text-[12px] text-gray-600 dark:text-gray-400",children:i?`Expires ${X(i)}`:"No expiry"}),e.jsx("button",{onClick:Le,className:"px-2.5 py-1 rounded-md text-[12px] font-semibold bg-brand-600 text-white hover:bg-brand-700 transition-colors",children:"Copy"}),e.jsxs("button",{onClick:Ae,disabled:y,title:"Revoke this share link",className:"px-2 py-1 rounded-md text-[12px] font-semibold text-rose-700 dark:text-rose-400 hover:bg-rose-500/10 transition-colors flex items-center gap-1",children:[e.jsx(Pe,{size:12})," Revoke"]})]}),re&&e.jsx("div",{role:"status",className:`${T?"rounded-lg mb-4 border border-gray-200 dark:border-white/10":"border-b border-gray-200 dark:border-white/10"} px-5 py-1.5 text-[12px] text-gray-700 dark:text-gray-300 bg-gray-50 dark:bg-white/[0.02]`,children:re})]});return T?e.jsxs("div",{children:[e.jsxs("header",{className:"flex flex-wrap items-start justify-between gap-4 mb-5","data-testid":"report-header",children:[e.jsxs("div",{className:"min-w-0 flex flex-col gap-2",children:[x&&e.jsx("div",{className:"flex flex-wrap gap-2",children:x}),e.jsx("h1",{className:"text-[28px] leading-tight font-bold tracking-tight text-gray-900 dark:text-gray-100",children:t.title}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:[S,t.subtitle,`Data as of ${X(t.generatedAt)}`].filter(Boolean).join(" · ")})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2","data-testid":"report-actions",children:[N,A&&e.jsxs("button",{onClick:de,disabled:y,className:oe,"aria-expanded":j!=="closed",children:[y?e.jsx(B,{size:15,className:"animate-spin"}):e.jsx(z,{size:15}),d?"Shared":"Share"]}),A&&!o&&e.jsxs("button",{onClick:ne,disabled:b,className:oe,children:[b?e.jsx(B,{size:15,className:"animate-spin"}):e.jsx(pe,{size:15})," Save"]}),ce,R]})]}),xe,e.jsx(je,{spec:t,links:C??!g})]}):e.jsxs("div",{className:"rounded-2xl border border-gray-200 dark:border-white/10 bg-gray-50 dark:bg-white/[0.02] overflow-hidden",children:[e.jsxs("div",{className:"px-5 py-4 border-b border-gray-200 dark:border-white/10 bg-white dark:bg-white/[0.03] flex flex-wrap items-start justify-between gap-x-4 gap-y-3","data-testid":"report-card-header",children:[e.jsxs("div",{className:"flex min-w-[16rem] flex-1 items-start gap-3",children:[e.jsx("span",{className:"mt-0.5 flex h-9 w-9 flex-shrink-0 items-center justify-center rounded-lg bg-gray-100 text-gray-700 dark:bg-white/10 dark:text-gray-300","aria-hidden":!0,children:e.jsx(We,{size:18})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[e.jsx("h3",{className:"text-base font-semibold leading-snug text-gray-900 dark:text-gray-100",children:t.title}),o&&e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md bg-emerald-50 px-1.5 py-0.5 text-[11px] font-semibold text-emerald-700 dark:bg-emerald-500/15 dark:text-emerald-300",children:[e.jsx(qe,{size:11,"aria-hidden":!0})," Saved"]}),d&&e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md bg-blue-50 px-1.5 py-0.5 text-[11px] font-semibold text-blue-700 dark:bg-blue-500/15 dark:text-blue-300",children:[e.jsx(z,{size:11,"aria-hidden":!0})," Shared"]})]}),e.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-gray-600 dark:text-gray-400",children:[t.subtitle,`Data as of ${X(t.generatedAt)}`].filter(Boolean).join(" · ")})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[A&&!o&&e.jsxs("button",{onClick:ne,disabled:b,className:Y,title:"Save to your reports",children:[b?e.jsx(B,{size:14,className:"animate-spin"}):e.jsx(pe,{size:14})," Save"]}),A&&e.jsxs("button",{onClick:de,disabled:y,"aria-expanded":j!=="closed",title:d?"Public link active — view or revoke":"Create a public share link",className:Y,children:[y?e.jsx(B,{size:14,className:"animate-spin"}):e.jsx(z,{size:14}),d?"Shared":"Share"]}),ce,D&&e.jsx("a",{href:D.startsWith("/api/")?ue(D):D,target:"_blank",rel:"noopener noreferrer",title:d?"Open shareable full view (new tab)":o?"Open full view (new tab)":"Open HTML snapshot (new tab)","aria-label":"Open full view",className:le,children:e.jsx(Ye,{size:14})}),D&&e.jsx("button",{onClick:Se,title:M?"Copied!":d?"Copy share link":o?"Copy link to full view":"Copy HTML snapshot link (signed-in users only)","aria-label":"Copy link",className:le,children:M?e.jsx(Xe,{size:14,className:"text-emerald-600"}):e.jsx(Ge,{size:14})})]})]}),xe,e.jsx("div",{className:"p-4",children:e.jsx(je,{spec:t,links:C??!g})})]})}export{jt as R};
|
|
1
|
+
import{r as p,j as e,u as Fe,L as Te}from"./vendor-react-DOVfxdUy.js";import{f as X}from"./formatDate-T65-Y6Mi.js";import{T as he,a as Re,K as Me}from"./KpiTile-BHLE3HVj.js";import{R as O,P as De,m as Be,n as ze,T as H,o as K,B as ge,h as G,X as Q,Y as Z,l as me,j as Ie,L as _e}from"./vendor-charts-By5uZ93z.js";import{y as V,S as Ue,v as Oe,cy as He,a0 as B,a5 as Ke,dk as z,am as Pe,dl as pe,L as We,dm as Ye,_ as qe,ag as Xe,dd as Ge}from"./vendor-icons-D_Dmmj8d.js";import{ae as Qe,bY as Ze,a6 as ue,gN as Je,gO as Ve,gP as et,gQ as tt}from"./index-D6sQYc_0.js";function be({active:t,payload:s,label:a,clickHint:n}){return!t||!s||s.length===0?null:e.jsxs("div",{className:"rounded-lg border border-gray-200 dark:border-white/10 bg-white dark:bg-gray-900 shadow-lg px-2.5 py-2 text-xs min-w-[120px]",children:[a!=null&&a!==""&&e.jsx("div",{className:"text-[10px] uppercase tracking-wider font-semibold text-gray-500 dark:text-gray-400 mb-1.5",children:String(a)}),e.jsx("div",{className:"space-y-1",children:s.map((r,g)=>{var N;const l=r.value,x=String(r.name??r.dataKey??""),S=r.color||((N=r.payload)==null?void 0:N.fill)||"#3B82F6";return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{"aria-hidden":!0,className:"inline-block w-2.5 h-2.5 rounded-sm flex-shrink-0",style:{background:S}}),x&&x!=="value"&&e.jsx("span",{className:"text-gray-600 dark:text-gray-300 flex-1 truncate",children:x}),e.jsx("span",{className:"tabular-nums font-semibold text-gray-900 dark:text-gray-100 ml-auto",children:typeof l=="number"?Number.isInteger(l)?l.toLocaleString():l.toFixed(2):String(l??"")})]},g)})}),n&&e.jsx("div",{className:"mt-1.5 pt-1.5 border-t border-gray-100 dark:border-white/10 text-[11px] text-blue-700 dark:text-blue-300",children:n})]})}const ye={vibrant:["#8AB4F8","#F4A0A0","#7DD3AE","#F6C66E","#B3A1EE","#F2A5C7","#7CCFC6","#F7B489","#A2ACF2","#8BCFE6"],pastel:["#93C5FD","#FCA5A5","#6EE7B7","#FCD34D","#C4B5FD","#F9A8D4","#5EEAD4","#FDBA74","#A5B4FC","#67E8F9"]},rt={status:{passed:"#7DD3AE",failed:"#F4A0A0",skipped:"#F6C66E",blocked:"#F7B489",not_run:"#C3C9D2",in_progress:"#8AB4F8"},priority:{critical:"#F4A0A0",high:"#F7B489",medium:"#F6C66E",low:"#8AB4F8"},severity:{blocker:"#EE8F8F",critical:"#F4A0A0",major:"#F6C66E",minor:"#8AB4F8",trivial:"#C3C9D2"}};function fe(t,s,a){if(Array.isArray(a)&&a.length>=t.length&&a.every(g=>typeof g=="string"))return a;const n=ye.vibrant;if(s==="status"||s==="priority"||s==="severity"){const g=rt[s];return t.map((l,x)=>g[String(l).toLowerCase().replace(/\s+/g,"_")]||n[x%n.length])}const r=s==="pastel"?ye.pastel:n;return t.map((g,l)=>r[l%r.length])}const P=t=>s=>{const a=String(s??"");return a.length>t?`${a.slice(0,t-1)}…`:a},ke=t=>(Array.isArray(t)?t:[]).map(s=>typeof s=="number"&&Number.isFinite(s)?s:Number(s)||0);function at({cell:t,height:s=260,onPick:a,clickHint:n}){var v;const r=p.useMemo(()=>{var j;const i=(Array.isArray(t.labels)?t.labels:[]).map(w=>String(w??"")),h=(Array.isArray(t.datasets)?t.datasets:[]).filter(w=>w&&typeof w=="object").map((w,$)=>({label:String(w.label??`Series ${$+1}`),data:ke(w.data)})),y=t.chartType==="pie"||t.chartType==="doughnut",k=Array.isArray(t.data)&&t.data.length>0?ke(t.data):y?(j=h[0])==null?void 0:j.data:void 0;return{...t,labels:i,data:k,datasets:y?void 0:h.length>0?h:void 0}},[t]),g=p.useMemo(()=>fe(r.labels,r.colorScheme,r.colors),[r.labels,r.colorScheme,r.colors]),l=p.useMemo(()=>fe((r.datasets||[]).map(i=>i.label),r.colorScheme,r.colors),[r.datasets,r.colorScheme,r.colors]),x=r.datasets&&r.datasets.length>0?l:g,S=p.useMemo(()=>r.datasets&&r.datasets.length>0?r.labels.map((i,h)=>{const y={label:i};for(const k of r.datasets)y[k.label]=k.data[h]??0;return y}):r.labels.map((i,h)=>{var y;return{label:i,value:((y=r.data)==null?void 0:y[h])??0}}),[r.labels,r.data,r.datasets]),N=((v=r.datasets)==null?void 0:v.map(i=>i.label))??["value"],R=r.labels.reduce((i,h)=>Math.max(i,h.length),0),C={fill:"rgb(107 114 128)",fontSize:11},L="rgba(107,114,128,0.2)",A={stroke:"rgba(107,114,128,0.4)"},M={fill:"rgba(107,114,128,0.08)"},m=p.useMemo(()=>{var w;const i=(((w=r.datasets)==null?void 0:w.flatMap($=>$.data))??r.data??[]).filter($=>Number.isFinite($));if(i.length<2)return;const h=Math.min(...i),y=Math.max(...i),k=Math.max((y-h)*.15,Math.abs(y)*.01,1);return[h>=0?Math.max(0,Math.floor(h-k)):Math.floor(h-k),Math.ceil(y+k)]},[r.data,r.datasets]),o=a?i=>{const h=i==null?void 0:i.activeTooltipIndex;typeof h=="number"&&h>=0&&a(h)}:void 0,u=a?{cursor:"pointer"}:void 0,b=e.jsx(be,{clickHint:a?n:void 0}),f=i=>e.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:String(i??"")}),d={fontSize:11,color:"rgb(107 114 128)",maxHeight:56,overflowY:"auto"};if(r.labels.length===0||!r.datasets&&!(r.data&&r.data.length>0))return e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 p-4 text-center",children:"No data to chart."});switch(r.chartType){case"line":return e.jsx(O,{width:"100%",height:s,children:e.jsxs(Ie,{data:S,margin:{top:8,right:16,bottom:8,left:0},onClick:o,style:u,children:[e.jsx(G,{strokeDasharray:"3 3",stroke:L}),e.jsx(Q,{dataKey:"label",tick:C,axisLine:!1,tickLine:!1,interval:0,angle:-28,textAnchor:"end",height:60,tickFormatter:P(16)}),e.jsx(Z,{tick:C,axisLine:!1,tickLine:!1,domain:m,allowDecimals:!0}),e.jsx(H,{content:b,cursor:A}),N.length>1&&e.jsx(K,{wrapperStyle:d,formatter:f}),N.map((i,h)=>e.jsx(_e,{type:"monotone",dataKey:i,stroke:x[h%x.length],strokeWidth:2,dot:{r:3,fill:x[h%x.length]},activeDot:{r:5}},i))]})});case"bar":case"stacked_bar":return e.jsx(O,{width:"100%",height:s,children:e.jsxs(ge,{data:S,margin:{top:8,right:16,bottom:8,left:0},onClick:o,style:u,children:[e.jsx(G,{strokeDasharray:"3 3",stroke:L}),e.jsx(Q,{dataKey:"label",tick:C,axisLine:!1,tickLine:!1,interval:0,angle:-28,textAnchor:"end",height:60,tickFormatter:P(16)}),e.jsx(Z,{tick:C,axisLine:!1,tickLine:!1}),e.jsx(H,{content:b,cursor:M}),N.length>1&&e.jsx(K,{wrapperStyle:d,formatter:f}),N.map((i,h)=>e.jsx(me,{dataKey:i,fill:x[h%x.length],radius:[4,4,0,0],stackId:r.chartType==="stacked_bar"?"s1":void 0},i))]})});case"horizontal_bar":return e.jsx(O,{width:"100%",height:Math.max(s,r.labels.length*28+40),children:e.jsxs(ge,{data:S,layout:"vertical",margin:{top:8,right:24,bottom:8,left:0},onClick:o,style:u,children:[e.jsx(G,{strokeDasharray:"3 3",stroke:L,horizontal:!1}),e.jsx(Q,{type:"number",tick:C,axisLine:!1,tickLine:!1}),e.jsx(Z,{type:"category",dataKey:"label",tick:C,axisLine:!1,tickLine:!1,width:Math.min(180,Math.max(60,R*6.5)),tickFormatter:P(28)}),e.jsx(H,{content:b,cursor:M}),N.length>1&&e.jsx(K,{wrapperStyle:d,formatter:f}),N.map((i,h)=>e.jsx(me,{dataKey:i,fill:x[h%x.length],radius:[0,4,4,0]},i))]})});case"pie":case"doughnut":{const i=r.labels.map((k,j)=>{var w;return{name:k,value:((w=r.data)==null?void 0:w[j])??0}}),h=i.reduce((k,j)=>k+(Number(j.value)||0),0),y=(k,j)=>{var I;const w=Number((I=j==null?void 0:j.payload)==null?void 0:I.value)||0,$=h>0?Math.round(w/h*1e3)/10:0;return e.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:`${P(28)(k)} · ${$}%`})};return e.jsx(O,{width:"100%",height:s,children:e.jsxs(De,{children:[e.jsx(Be,{data:i,dataKey:"value",nameKey:"name",innerRadius:r.chartType==="doughnut"?"55%":0,outerRadius:"85%",paddingAngle:2,children:i.map((k,j)=>e.jsx(ze,{fill:x[j%x.length],stroke:"transparent"},j))}),e.jsx(H,{content:e.jsx(be,{})}),e.jsx(K,{wrapperStyle:d,formatter:y})]})})}default:return e.jsxs("div",{className:"text-xs text-gray-500 p-4",children:["Unsupported chart type: ",r.chartType]})}}function st(){const t=p.useRef(null),[s,a]=p.useState(0);return p.useEffect(()=>{const n=t.current;if(!n||typeof ResizeObserver>"u")return;const r=new ResizeObserver(g=>{var l;return a(((l=g[0])==null?void 0:l.contentRect.width)??0)});return r.observe(n),a(n.getBoundingClientRect().width),()=>r.disconnect()},[]),[t,s]}function je({spec:t,links:s=!0}){const[a,n]=st(),r=n>0&&n<640,g=Array.isArray(t.cells)?t.cells:[],l=typeof t.method=="string"?t.method.trim():"";return e.jsxs("div",{ref:a,className:"flex flex-col gap-4",children:[t.summary&&e.jsx(nt,{summary:t.summary,narrow:r}),e.jsx("div",{className:"grid grid-cols-12 gap-4",children:g.map((x,S)=>e.jsx(it,{cell:x,narrow:r,links:s},S))}),l&&e.jsxs("details",{className:"rounded-xl border border-gray-200 dark:border-white/10 bg-white dark:bg-white/[0.03] px-5 py-3.5 group","data-testid":"report-method",children:[e.jsxs("summary",{className:"cursor-pointer text-sm font-semibold text-gray-800 dark:text-gray-200 list-none flex items-center gap-1.5",children:[e.jsx(V,{size:14,className:"transition-transform group-open:rotate-180","aria-hidden":!0}),"How this was calculated"]}),e.jsx("p",{className:"mt-2 text-sm leading-relaxed text-gray-700 dark:text-gray-300 whitespace-pre-line",children:l})]})]})}const we={good:{sym:"✓",cls:"bg-emerald-50 text-emerald-700 dark:bg-emerald-500/15 dark:text-emerald-300"},warn:{sym:"~",cls:"bg-amber-50 text-amber-700 dark:bg-amber-500/15 dark:text-amber-300"},bad:{sym:"!",cls:"bg-rose-50 text-rose-700 dark:bg-rose-500/15 dark:text-rose-300"},info:{sym:"i",cls:"bg-gray-100 text-gray-700 dark:bg-white/10 dark:text-gray-300"}};function nt({summary:t,narrow:s}){const a=Array.isArray(t.findings)?t.findings:[],n=t.status&&he[t.status]?t.status:void 0;return e.jsxs("section",{className:`rounded-xl border border-gray-200 dark:border-white/10 bg-white dark:bg-white/[0.03] px-5 py-4 grid gap-5 ${s||a.length===0?"grid-cols-1":"grid-cols-[minmax(220px,1fr)_minmax(0,2fr)]"}`,"aria-label":"Summary","data-testid":"report-summary",children:[e.jsxs("div",{className:"flex flex-col items-start gap-2",children:[n&&e.jsxs("span",{className:`inline-flex items-center gap-1.5 rounded-full px-2.5 py-0.5 text-xs font-semibold ${Re[n]}`,children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-current opacity-80","aria-hidden":!0}),he[n]]}),t.verdict&&e.jsx("p",{className:"text-lg leading-snug font-bold text-gray-900 dark:text-gray-100",children:t.verdict}),e.jsxs("p",{className:"flex items-center gap-1.5 text-xs text-gray-500 dark:text-gray-400",children:[e.jsx(Ue,{size:13,"aria-hidden":!0})," Summary written by the AI Assistant"]})]}),a.length>0&&e.jsx("ul",{className:"flex flex-col gap-2.5",children:a.map((r,g)=>{const l=we[r.tone]??we.info;return e.jsxs("li",{className:"flex items-start gap-2.5 text-sm leading-relaxed text-gray-700 dark:text-gray-300",children:[e.jsx("span",{className:`mt-0.5 flex h-[18px] w-[18px] flex-shrink-0 items-center justify-center rounded-full text-[11px] font-bold ${l.cls}`,"aria-hidden":!0,children:l.sym}),e.jsxs("span",{children:[e.jsx("strong",{className:"font-semibold text-gray-900 dark:text-gray-100",children:r.title}),r.detail?` ${r.detail}`:""]})]},g)})})]})}function it({cell:t,narrow:s,links:a}){const n=t.type==="kpi"?3:t.type==="chart"?6:12,r=Math.max(1,Math.min(12,Math.round(Number(t.span)||n))),g=s?t.type==="kpi"?6:12:r,l={gridColumn:`span ${g} / span ${g}`};return t.type==="kpi"?e.jsx("div",{style:l,children:e.jsx(Me,{cell:t})}):t.type==="chart"?e.jsx("div",{style:l,children:e.jsx(ot,{cell:t,links:a})}):t.type==="table"?e.jsx("div",{style:l,children:e.jsx(ht,{cell:t,links:a})}):t.type==="markdown"?e.jsx("div",{style:l,children:e.jsx("div",{className:"rounded-xl border border-gray-200 dark:border-white/10 bg-white dark:bg-white/[0.03] px-5 py-4","data-testid":"report-note",children:e.jsx(gt,{content:String(t.content??"")})})}):null}function ot({cell:t,links:s}){const a=Fe(),n=s&&Array.isArray(t.runIds)&&t.runIds.some(Boolean)?t.runIds:null,r=n?g=>{const l=n[g];l&&a(`/results?runId=${encodeURIComponent(l)}`)}:void 0;return e.jsxs("div",{className:"rounded-xl border border-gray-200 dark:border-white/10 bg-white dark:bg-white/[0.03] px-5 py-4 h-full","data-testid":"report-chart",children:[e.jsx("h3",{className:"text-base font-semibold text-gray-900 dark:text-gray-100",children:t.title}),(t.hint||n)&&e.jsxs("p",{className:"mt-0.5 text-[13px] text-gray-500 dark:text-gray-400",children:[t.hint,t.hint&&n?" ":"",n?"Click a bar or point to open the run.":""]}),e.jsx("div",{className:"mt-3",children:e.jsx(at,{cell:t,onPick:r,clickHint:"Click to open this run in Results"})})]})}const lt=/^(passed|pass|failed|fail|error|skipped|blocked|flaky|open|in progress|resolved|closed|fixed|rejected|never run|not run)(\s*\((?:error|fixed)\))?(?:\s*[—–-]\s+([\s\S]+))?$/i,dt={ok:"bg-emerald-50 text-emerald-700 dark:bg-emerald-500/15 dark:text-emerald-300",bad:"bg-rose-50 text-rose-700 dark:bg-rose-500/15 dark:text-rose-300",warn:"bg-amber-50 text-amber-700 dark:bg-amber-500/15 dark:text-amber-300",neutral:"bg-gray-100 text-gray-700 dark:bg-white/10 dark:text-gray-300"},ct={passed:"ok",pass:"ok",resolved:"ok",closed:"ok",fixed:"ok",failed:"bad",fail:"bad",error:"bad",blocked:"bad",open:"bad",skipped:"warn",flaky:"warn","in progress":"warn"},Ne=/^[-+]?[\d,]+(\.\d+)?\s*(%|ms|s)?$/,xt=/^[A-Za-z0-9._-]{1,120}$/,J=10;function ve(t){const s=t.trim();return Ne.test(s)?Number(s.replace(/[,%\s]|ms|s$/g,"")):null}function ht({cell:t,links:s=!0}){const a=(Array.isArray(t.headers)?t.headers:[]).map(m=>String(m??"")),n=p.useMemo(()=>(Array.isArray(t.rows)?t.rows:[]).map(m=>(Array.isArray(m)?m:[m]).map(o=>String(o??""))),[t.rows]),[r,g]=p.useState(null),[l,x]=p.useState(""),[S,N]=p.useState(!1),R=p.useMemo(()=>a.map((m,o)=>{const u=n.map(b=>(b[o]??"").trim()).filter(Boolean);return u.length>0&&u.every(b=>Ne.test(b))}),[a,n]),C=p.useMemo(()=>{const m=s&&t.columnLinks&&typeof t.columnLinks=="object"?t.columnLinks:{},o=a.findIndex(u=>m[u]==="file");return(u,b)=>{const f=m[a[b]??""],d=(u[b]??"").trim();if(!f||!d)return null;if(f==="run"){const v=d.split(/\s+/)[0]??"";return xt.test(v)?`/results?runId=${encodeURIComponent(v)}`:null}return f==="file"?`/tests?file=${encodeURIComponent(d)}`:f==="test"&&o>=0&&u[o]?`/tests?file=${encodeURIComponent(u[o].trim())}&test=${encodeURIComponent(d)}`:null}},[s,t.columnLinks,a]),L=p.useMemo(()=>{const m=l.trim().toLowerCase();let o=m?n.filter(u=>u.some(b=>b.toLowerCase().includes(m))):n;return r&&(o=[...o].sort((u,b)=>{const f=u[r.col]??"",d=b[r.col]??"",v=ve(f),i=ve(d);return(v!=null&&i!=null?v-i:f.localeCompare(d,void 0,{numeric:!0,sensitivity:"base"}))*r.dir})),o},[n,l,r]),A=S?L:L.slice(0,J),M=m=>g(o=>{const u=R[m]?-1:1;return!o||o.col!==m?{col:m,dir:u}:o.dir===u?{col:m,dir:u===1?-1:1}:null});return e.jsxs("div",{className:"rounded-xl border border-gray-200 dark:border-white/10 bg-white dark:bg-white/[0.03] px-5 py-4 h-full","data-testid":"report-table",children:[e.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{className:"text-base font-semibold text-gray-900 dark:text-gray-100",children:t.title}),t.hint&&e.jsx("p",{className:"mt-0.5 text-[13px] text-gray-500 dark:text-gray-400",children:t.hint})]}),n.length>J&&e.jsxs("label",{className:"flex h-8 items-center gap-2 rounded-lg border border-gray-300 dark:border-white/15 px-2.5 text-[13px] text-gray-500 dark:text-gray-400",children:[e.jsx(Oe,{size:13,"aria-hidden":!0}),e.jsx("span",{className:"sr-only",children:"Filter rows"}),e.jsx("input",{value:l,onChange:m=>{x(m.target.value),N(!1)},placeholder:"Filter rows",className:"w-36 bg-transparent text-[13px] text-gray-900 dark:text-gray-100 outline-none placeholder:text-gray-400"})]})]}),e.jsx("div",{className:"mt-3 overflow-x-auto rounded-lg border border-gray-200 dark:border-white/10",children:e.jsxs("table",{className:"w-full border-collapse text-sm",children:[e.jsx("thead",{children:e.jsx("tr",{className:"bg-gray-50 dark:bg-white/[0.04]",children:a.map((m,o)=>{const u=(r==null?void 0:r.col)===o;return e.jsx("th",{scope:"col","aria-sort":u?r.dir===1?"ascending":"descending":"none",className:`border-b border-gray-200 dark:border-white/10 px-3.5 py-2.5 text-xs font-semibold uppercase tracking-wide text-gray-600 dark:text-gray-400 whitespace-nowrap ${R[o]?"text-right":"text-left"}`,children:e.jsxs("button",{type:"button",onClick:()=>M(o),className:"inline-flex items-center gap-1 uppercase hover:text-gray-900 dark:hover:text-gray-200",title:`Sort by ${m}`,children:[m,u&&(r.dir===1?e.jsx(He,{size:12,"aria-hidden":!0}):e.jsx(V,{size:12,"aria-hidden":!0}))]})},o)})})}),e.jsxs("tbody",{children:[A.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:a.length||1,className:"px-3.5 py-6 text-center text-[13px] text-gray-500 dark:text-gray-400",children:n.length===0?"No rows":"No rows match the filter"})}),A.map((m,o)=>e.jsx("tr",{className:"hover:bg-gray-50/70 dark:hover:bg-white/[0.03]",children:a.map((u,b)=>{const f=m[b]??"",d=lt.exec(f.trim()),v=C(m,b);let i=f;if(d){const h=ct[d[1].toLowerCase()]??"neutral";i=e.jsxs(e.Fragment,{children:[e.jsx("span",{className:`inline-block rounded-full px-2 py-0.5 text-xs font-semibold ${dt[h]}`,children:`${d[1]}${d[2]??""}`.trim()}),d[3]&&e.jsx("span",{className:"ml-1.5 text-gray-500 dark:text-gray-400",children:d[3].trim()})]})}else v&&(i=e.jsx(Te,{to:v,className:"font-medium text-blue-700 dark:text-blue-300 hover:underline",children:f}));return e.jsx("td",{title:f.length>60?f:void 0,className:`border-b border-gray-100 dark:border-white/[0.06] px-3.5 py-2.5 align-top text-gray-800 dark:text-gray-200 ${R[b]?"text-right tabular-nums whitespace-nowrap":""} ${b===0&&!v?"font-medium text-gray-900 dark:text-gray-100":""} max-w-[28rem] break-words`,children:i},b)})},o))]})]})}),L.length>J&&e.jsx("button",{type:"button",onClick:()=>N(m=>!m),className:"mt-2.5 text-[13px] font-medium text-blue-700 dark:text-blue-300 hover:underline",children:S?"Show fewer rows":`Show all ${L.length} rows`})]})}function gt({content:t}){const s=t.split(`
|
|
2
|
+
`),a=[];let n=[];const r=()=>{n.length!==0&&(a.push(e.jsx("ul",{className:"list-disc pl-5 text-sm text-gray-700 dark:text-gray-300 space-y-1.5 my-2 leading-relaxed",children:n.map((l,x)=>e.jsx("li",{dangerouslySetInnerHTML:{__html:g(l)}},x))},a.length)),n=[])},g=l=>l.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/\*\*(.+?)\*\*/g,'<strong class="font-semibold text-gray-900 dark:text-gray-100">$1</strong>').replace(/`([^`]+)`/g,'<code class="px-1 py-0.5 rounded bg-gray-100 dark:bg-white/10 font-mono text-[12px]">$1</code>');for(const l of s){const x=l.trim();if(!x){r();continue}x.startsWith("## ")||x.startsWith("### ")?(r(),a.push(e.jsx("h3",{className:"text-base font-semibold text-gray-900 dark:text-gray-100 mt-2 mb-1.5",dangerouslySetInnerHTML:{__html:g(x.replace(/^#+\s/,""))}},a.length))):x.startsWith("# ")?(r(),a.push(e.jsx("h2",{className:"text-lg font-bold text-gray-900 dark:text-gray-100 mt-2 mb-1.5",dangerouslySetInnerHTML:{__html:g(x.slice(2))}},a.length))):x.startsWith("- ")||x.startsWith("* ")?n.push(x.slice(2)):(r(),a.push(e.jsx("p",{className:"text-sm text-gray-700 dark:text-gray-300 my-1.5 leading-relaxed",dangerouslySetInnerHTML:{__html:g(x)}},a.length)))}return r(),e.jsx(e.Fragment,{children:a})}const mt=[{days:void 0,label:"Never"},{days:7,label:"7 days"},{days:30,label:"30 days"},{days:90,label:"90 days"}];function jt({spec:t,urls:s,savedId:a,initialShareToken:n,initialShareExpiresAt:r,readonly:g=!1,variant:l="card",chips:x,metaLine:S,leadActions:N,trailActions:R,links:C}){const{hasRole:L}=Qe(),A=!g&&L("tester"),[M,m]=p.useState(!1),[o,u]=p.useState(a),[b,f]=p.useState(!1),[d,v]=p.useState(n),[i,h]=p.useState(r),[y,k]=p.useState(!1),[j,w]=p.useState("closed"),[$,I]=p.useState(void 0),[_,U]=p.useState(!1),[ee,te]=p.useState(null),[re,ae]=p.useState(null);p.useEffect(()=>{a&&u(a)},[a]),p.useEffect(()=>{n&&v(n)},[n]),p.useEffect(()=>{r&&h(r)},[r]);const F=c=>{ae(c),setTimeout(()=>ae(null),2600)},D=d?`/reports/share/${d}`:o?`/reports/view/${o}`:(s==null?void 0:s.html)||"",Se=async()=>{if(!D)return;const c=`${window.location.origin}${D}`;try{await navigator.clipboard.writeText(c),m(!0),setTimeout(()=>m(!1),1500)}catch{}},se=async()=>{const c=await tt({title:t.title,spec:t,outputFiles:s?{html:s.html,json:s.json}:void 0});return u(c.id),c.id},ne=async()=>{if(!(o||b)){f(!0);try{await se(),F("Saved to your reports")}catch(c){F(`Save failed: ${c instanceof Error?c.message:String(c)}`)}finally{f(!1)}}},Ce=async()=>{if(!y){k(!0);try{const c=o??await se(),{token:E,shareExpiresAt:Ee}=await Ve(c,$);v(E),h(Ee),w("link"),F("Share link created")}catch(c){F(`Share failed: ${c instanceof Error?c.message:String(c)}`)}finally{k(!1)}}},Ae=async()=>{if(!(!d||!o)){k(!0);try{await et(o),v(void 0),h(void 0),w("closed"),F("Share link revoked")}catch(c){F(`Revoke failed: ${c instanceof Error?c.message:String(c)}`)}finally{k(!1)}}},W=d?`${window.location.origin}/reports/share/${d}`:"",Le=async()=>{if(W)try{await navigator.clipboard.writeText(W),F("Share URL copied")}catch{}},ie=g&&d?`/api/reports/share/${encodeURIComponent(d)}/render.html`:o?Ze(`/api/reports/${encodeURIComponent(o)}/render.html`):d?`/api/reports/share/${encodeURIComponent(d)}/render.html`:s!=null&&s.html?ue(s.html):null,$e=async c=>{U(!1),te(c);try{await Je(c,g&&d?{shareToken:d}:o?{reportId:o}:{spec:t,title:t.title})}catch(E){F(`Download failed: ${E instanceof Error?E.message:String(E)}`)}finally{te(null)}},Y=p.useRef(null);p.useEffect(()=>{if(!_)return;const c=E=>{Y.current&&!Y.current.contains(E.target)&&U(!1)};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[_]);const oe="inline-flex h-9 items-center gap-1.5 rounded-lg border border-gray-300 dark:border-white/15 bg-white dark:bg-white/[0.04] px-3.5 text-sm font-medium text-gray-900 dark:text-gray-100 hover:bg-gray-50 dark:hover:bg-white/[0.08] transition-colors disabled:opacity-60",q="inline-flex h-8 items-center gap-1.5 rounded-lg border border-gray-300 dark:border-white/15 bg-white dark:bg-white/[0.04] px-2.5 text-[13px] font-medium text-gray-800 dark:text-gray-100 hover:bg-gray-50 dark:hover:bg-white/[0.08] transition-colors disabled:opacity-60",le="inline-flex h-8 w-8 items-center justify-center rounded-lg border border-gray-300 dark:border-white/15 bg-white dark:bg-white/[0.04] text-gray-600 dark:text-gray-300 hover:bg-gray-50 hover:text-gray-900 dark:hover:bg-white/[0.08] dark:hover:text-gray-100 transition-colors",T=l==="page",de=()=>w(c=>c==="closed"?d?"link":"create":"closed"),ce=e.jsxs("div",{className:"relative",ref:Y,children:[e.jsxs("button",{onClick:()=>U(c=>!c),disabled:!!ee,title:"Download","aria-haspopup":"menu","aria-expanded":_,className:T?"inline-flex h-9 items-center gap-1.5 rounded-lg bg-brand-600 px-3.5 text-sm font-medium text-white hover:bg-brand-700 transition-colors disabled:opacity-60":q,children:[ee?e.jsx(B,{size:T?15:14,className:"animate-spin"}):e.jsx(Ke,{size:T?15:14}),"Download",e.jsx(V,{size:T?14:13,"aria-hidden":!0})]}),_&&e.jsxs("div",{role:"menu",className:"absolute right-0 top-full mt-1 z-20 w-44 rounded-lg border border-gray-200 dark:border-white/10 bg-white dark:bg-surface-1 shadow-lg py-1 text-sm",children:[ie&&e.jsx("a",{role:"menuitem",href:ie,download:`${t.title||t.id}.html`,onClick:()=>U(!1),className:"block px-3 py-1.5 text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-white/5",children:"HTML page"}),[["pdf","PDF"],["docx","Word (.docx)"],["xlsx","Excel (.xlsx)"]].map(([c,E])=>e.jsx("button",{role:"menuitem",onClick:()=>$e(c),className:"w-full text-left px-3 py-1.5 text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-white/5",children:E},c))]})]}),xe=e.jsxs(e.Fragment,{children:[A&&j==="create"&&!d&&e.jsxs("div",{className:`${T?"rounded-xl border mb-4":"border-b"} px-5 py-2.5 border-gray-200 dark:border-white/10 bg-blue-50/60 dark:bg-blue-500/10 flex items-center gap-2 text-[13px] flex-wrap`,children:[e.jsx(z,{size:13,className:"text-blue-700 dark:text-blue-300 flex-shrink-0"}),e.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:"Anyone with the link can view this report."}),e.jsxs("label",{className:"flex items-center gap-1 text-gray-700 dark:text-gray-300 ml-auto",children:["Expires",e.jsx("select",{value:$??"",onChange:c=>I(c.target.value?Number(c.target.value):void 0),className:"px-1.5 py-0.5 rounded border border-gray-300 dark:border-white/15 bg-white dark:bg-white/[0.05] text-[12px]",children:mt.map(c=>e.jsx("option",{value:c.days??"",children:c.label},c.label))})]}),e.jsx("button",{onClick:Ce,disabled:y,className:"px-2.5 py-1 rounded-md text-[12px] font-semibold bg-brand-600 text-white hover:bg-brand-700 transition-colors",children:"Create link"})]}),A&&d&&j==="link"&&e.jsxs("div",{className:`${T?"rounded-xl border mb-4":"border-b"} px-5 py-2.5 border-gray-200 dark:border-white/10 bg-blue-50/60 dark:bg-blue-500/10 flex items-center gap-2 text-[13px] flex-wrap`,children:[e.jsx(z,{size:13,className:"text-blue-700 dark:text-blue-300 flex-shrink-0"}),e.jsx("span",{className:"text-gray-700 dark:text-gray-300 flex-shrink-0",children:"Public link:"}),e.jsx("code",{className:"flex-1 min-w-[12rem] truncate font-mono text-[12px] text-blue-800 dark:text-blue-200 bg-white dark:bg-white/[0.05] border border-blue-200 dark:border-blue-400/20 rounded px-2 py-1",children:W}),e.jsx("span",{className:"text-[12px] text-gray-600 dark:text-gray-400",children:i?`Expires ${X(i)}`:"No expiry"}),e.jsx("button",{onClick:Le,className:"px-2.5 py-1 rounded-md text-[12px] font-semibold bg-brand-600 text-white hover:bg-brand-700 transition-colors",children:"Copy"}),e.jsxs("button",{onClick:Ae,disabled:y,title:"Revoke this share link",className:"px-2 py-1 rounded-md text-[12px] font-semibold text-rose-700 dark:text-rose-400 hover:bg-rose-500/10 transition-colors flex items-center gap-1",children:[e.jsx(Pe,{size:12})," Revoke"]})]}),re&&e.jsx("div",{role:"status",className:`${T?"rounded-lg mb-4 border border-gray-200 dark:border-white/10":"border-b border-gray-200 dark:border-white/10"} px-5 py-1.5 text-[12px] text-gray-700 dark:text-gray-300 bg-gray-50 dark:bg-white/[0.02]`,children:re})]});return T?e.jsxs("div",{children:[e.jsxs("header",{className:"flex flex-wrap items-start justify-between gap-4 mb-5","data-testid":"report-header",children:[e.jsxs("div",{className:"min-w-0 flex flex-col gap-2",children:[x&&e.jsx("div",{className:"flex flex-wrap gap-2",children:x}),e.jsx("h1",{className:"text-[28px] leading-tight font-bold tracking-tight text-gray-900 dark:text-gray-100",children:t.title}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:[S,t.subtitle,`Data as of ${X(t.generatedAt)}`].filter(Boolean).join(" · ")})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2","data-testid":"report-actions",children:[N,A&&e.jsxs("button",{onClick:de,disabled:y,className:oe,"aria-expanded":j!=="closed",children:[y?e.jsx(B,{size:15,className:"animate-spin"}):e.jsx(z,{size:15}),d?"Shared":"Share"]}),A&&!o&&e.jsxs("button",{onClick:ne,disabled:b,className:oe,children:[b?e.jsx(B,{size:15,className:"animate-spin"}):e.jsx(pe,{size:15})," Save"]}),ce,R]})]}),xe,e.jsx(je,{spec:t,links:C??!g})]}):e.jsxs("div",{className:"rounded-2xl border border-gray-200 dark:border-white/10 bg-gray-50 dark:bg-white/[0.02] overflow-hidden",children:[e.jsxs("div",{className:"px-5 py-4 border-b border-gray-200 dark:border-white/10 bg-white dark:bg-white/[0.03] flex flex-wrap items-start justify-between gap-x-4 gap-y-3","data-testid":"report-card-header",children:[e.jsxs("div",{className:"flex min-w-[16rem] flex-1 items-start gap-3",children:[e.jsx("span",{className:"mt-0.5 flex h-9 w-9 flex-shrink-0 items-center justify-center rounded-lg bg-gray-100 text-gray-700 dark:bg-white/10 dark:text-gray-300","aria-hidden":!0,children:e.jsx(We,{size:18})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[e.jsx("h3",{className:"text-base font-semibold leading-snug text-gray-900 dark:text-gray-100",children:t.title}),o&&e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md bg-emerald-50 px-1.5 py-0.5 text-[11px] font-semibold text-emerald-700 dark:bg-emerald-500/15 dark:text-emerald-300",children:[e.jsx(Ye,{size:11,"aria-hidden":!0})," Saved"]}),d&&e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md bg-blue-50 px-1.5 py-0.5 text-[11px] font-semibold text-blue-700 dark:bg-blue-500/15 dark:text-blue-300",children:[e.jsx(z,{size:11,"aria-hidden":!0})," Shared"]})]}),e.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-gray-600 dark:text-gray-400",children:[t.subtitle,`Data as of ${X(t.generatedAt)}`].filter(Boolean).join(" · ")})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[A&&!o&&e.jsxs("button",{onClick:ne,disabled:b,className:q,title:"Save to your reports",children:[b?e.jsx(B,{size:14,className:"animate-spin"}):e.jsx(pe,{size:14})," Save"]}),A&&e.jsxs("button",{onClick:de,disabled:y,"aria-expanded":j!=="closed",title:d?"Public link active — view or revoke":"Create a public share link",className:q,children:[y?e.jsx(B,{size:14,className:"animate-spin"}):e.jsx(z,{size:14}),d?"Shared":"Share"]}),ce,D&&e.jsx("a",{href:D.startsWith("/api/")?ue(D):D,target:"_blank",rel:"noopener noreferrer",title:d?"Open shareable full view (new tab)":o?"Open full view (new tab)":"Open HTML snapshot (new tab)","aria-label":"Open full view",className:le,children:e.jsx(qe,{size:14})}),D&&e.jsx("button",{onClick:Se,title:M?"Copied!":d?"Copy share link":o?"Copy link to full view":"Copy HTML snapshot link (signed-in users only)","aria-label":"Copy link",className:le,children:M?e.jsx(Xe,{size:14,className:"text-emerald-600"}):e.jsx(Ge,{size:14})})]})]}),xe,e.jsx("div",{className:"p-4",children:e.jsx(je,{spec:t,links:C??!g})})]})}export{jt as R};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as J,u as K,r as s,j as e,L as C}from"./vendor-react-
|
|
1
|
+
import{o as J,u as K,r as s,j as e,L as C}from"./vendor-react-DOVfxdUy.js";import{b as Q,ae as W,a5 as X,iv as Y,iz as Z,iu as _,iw as ee}from"./index-D6sQYc_0.js";import{C as te}from"./ConfirmDialog-DtotgVmI.js";import{R as re}from"./ReportCard-D4EElEe9.js";import{i as se,t as ae,a as ne,s as ie,S as oe}from"./reportMeta-3kxT7BIT.js";import{a0 as z,aj as E,a as le,a3 as A,bp as L,cu as de,bo as ce,b7 as me,S as ue,R as xe}from"./vendor-icons-D_Dmmj8d.js";import"./vendor-query-DkZSMtfn.js";import"./formatDate-T65-Y6Mi.js";import"./KpiTile-BHLE3HVj.js";import"./vendor-charts-By5uZ93z.js";import"./CronBuilder-D2fERHt9.js";const i="inline-flex items-center gap-1.5 rounded-md px-2 py-0.5 text-xs font-semibold",$="inline-flex h-9 items-center gap-1.5 rounded-lg border border-gray-300 dark:border-white/15 bg-white dark:bg-white/[0.04] px-3.5 text-sm font-medium text-gray-900 dark:text-gray-100 hover:bg-gray-50 dark:hover:bg-white/[0.08] transition-colors disabled:opacity-60";function Se(){var N;const{id:c}=J(),D=K(),a=Q(),I=W().hasRole("tester"),[r,m]=s.useState(null),[o,k]=s.useState([]),[T,u]=s.useState(!0),[n,j]=s.useState(!1),[w,x]=s.useState(null),[P,v]=s.useState(!1),[F,p]=s.useState(!1),[l,d]=s.useState(!1),g=s.useRef(null),R=async t=>{try{const{schedules:y}=await Z();k(y.filter(H=>H.sourceReportId===t))}catch{k([])}},U=async()=>{if(!c){x("No report ID in URL"),u(!1);return}x(null);try{const t=await X(c);m(t),t.mine!==!1&&R(t.id)}catch(t){x(t instanceof Error?t.message:String(t))}finally{u(!1)}};s.useEffect(()=>{u(!0),U()},[c]),s.useEffect(()=>{if(!l)return;const t=y=>{g.current&&!g.current.contains(y.target)&&d(!1)};return document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[l]);const B=async()=>{if(r)try{await _(r.id),a.toast("success","Report deleted"),D("/reports")}catch(t){a.toast("error",`Delete failed: ${t instanceof Error?t.message:String(t)}`)}},M=async()=>{if(!(!r||n)){j(!0);try{const t=await ee(r.id);m(t),a.toast("success","Report refreshed with current data")}catch(t){a.toast("error",`Refresh failed: ${t instanceof Error?t.message:String(t)}`)}finally{j(!1)}}},O=async()=>{if(r){d(!1);try{const t=await Y(r.id,{pinned:!r.pinned});m({...r,pinned:t.pinned}),a.toast("success",t.pinned?"Pinned to the top of Reports":"Unpinned")}catch(t){a.toast("error",`Pin failed: ${t instanceof Error?t.message:String(t)}`)}}};if(T)return e.jsxs("div",{className:"p-6 flex items-center justify-center text-sm text-gray-600 dark:text-gray-400 gap-2",children:[e.jsx(z,{size:14,className:"animate-spin"})," Loading report…"]});if(w||!r)return e.jsxs("div",{className:"p-6 max-w-2xl mx-auto",children:[e.jsxs(C,{to:"/reports",className:"inline-flex items-center gap-1.5 text-sm text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-200 mb-4",children:[e.jsx(E,{size:15})," Reports"]}),e.jsxs("div",{className:"rounded-xl border border-rose-500/30 bg-rose-500/5 p-6 text-center",children:[e.jsx(le,{size:24,className:"text-rose-500 mx-auto mb-3"}),e.jsx("div",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100 mb-1",children:"Could not load report"}),e.jsx("div",{className:"text-[13px] text-gray-600 dark:text-gray-400",children:w||"Report not found"})]})]});const h=r.mine!==!1,S=I&&h,b=(N=r.spec)==null?void 0:N.generatedAt,f=se(b,r.templateId),V=e.jsxs(e.Fragment,{children:[e.jsx("span",{className:`${i} bg-gray-100 text-gray-700 dark:bg-white/10 dark:text-gray-300`,children:ae(r.templateId)}),b&&e.jsxs("span",{className:`${i} ${f?"bg-amber-50 text-amber-700 dark:bg-amber-500/15 dark:text-amber-300":"bg-emerald-50 text-emerald-700 dark:bg-emerald-500/15 dark:text-emerald-300"}`,title:f?"The data is out of date — Refresh data rebuilds it from current results":void 0,children:["Updated ",ne(b),f?" · out of date":""]}),o.map(t=>e.jsxs("span",{className:`${i} bg-gray-100 text-gray-700 dark:bg-white/10 dark:text-gray-300`,children:[e.jsx(A,{size:12,"aria-hidden":!0})," ",ie(t)]},t.id)),r.pinned&&e.jsxs("span",{className:`${i} bg-amber-50 text-amber-700 dark:bg-amber-500/15 dark:text-amber-300`,children:[e.jsx(L,{size:12,"aria-hidden":!0})," Pinned"]}),!h&&r.sharedByName&&e.jsxs("span",{className:`${i} bg-blue-50 text-blue-700 dark:bg-blue-500/15 dark:text-blue-300`,"data-testid":"report-shared-by",children:["Shared by ",r.sharedByName]})]}),q=S?e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:M,disabled:n,className:$,title:"The AI rebuilds this report from current data — same layout, new numbers. Takes 30 seconds to 2 minutes and uses AI credits.",children:[n?e.jsx(z,{size:15,className:"animate-spin"}):e.jsx(xe,{size:15}),n?"Refreshing…":"Refresh data"]}),e.jsxs("button",{onClick:()=>p(!0),className:$,title:"Email this report on a schedule",children:[e.jsx(A,{size:15})," Schedule"]})]}):null,G=S?e.jsxs("div",{className:"relative",ref:g,children:[e.jsx("button",{onClick:()=>d(t=>!t),className:"inline-flex h-9 w-9 items-center justify-center rounded-lg border border-gray-300 dark:border-white/15 bg-white dark:bg-white/[0.04] text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-white/[0.08]","aria-label":"More actions","aria-haspopup":"menu","aria-expanded":l,children:e.jsx(de,{size:16})}),l&&e.jsxs("div",{role:"menu",className:"absolute right-0 top-full mt-1 z-20 w-44 rounded-lg border border-gray-200 dark:border-white/10 bg-white dark:bg-surface-1 shadow-lg py-1 text-sm",children:[e.jsxs("button",{role:"menuitem",onClick:O,className:"w-full flex items-center gap-2 px-3 py-1.5 text-left text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-white/5",children:[r.pinned?e.jsx(ce,{size:14}):e.jsx(L,{size:14})," ",r.pinned?"Unpin":"Pin to top"]}),e.jsxs("button",{role:"menuitem",onClick:()=>{d(!1),v(!0)},className:"w-full flex items-center gap-2 px-3 py-1.5 text-left text-rose-700 dark:text-rose-400 hover:bg-rose-500/10",children:[e.jsx(me,{size:14})," Delete"]})]})]}):null;return e.jsxs("div",{className:"p-6 max-w-[1360px] mx-auto",children:[e.jsxs(C,{to:"/reports",className:"inline-flex items-center gap-1.5 text-sm text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-200 mb-4",children:[e.jsx(E,{size:15})," Reports"]}),n&&e.jsxs("div",{role:"status",className:"mb-4 flex items-center gap-2 rounded-xl border border-blue-200 dark:border-blue-400/20 bg-blue-50/70 dark:bg-blue-500/10 px-4 py-2.5 text-[13px] text-blue-900 dark:text-blue-200",children:[e.jsx(ue,{size:14,"aria-hidden":!0})," The AI is rebuilding this report from current data — same layout, new numbers. This takes 30 seconds to 2 minutes."]}),e.jsx(re,{variant:"page",spec:r.spec,urls:r.outputFiles,savedId:r.id,initialShareToken:r.shareToken,initialShareExpiresAt:r.shareExpiresAt,readonly:!h,links:!0,chips:V,leadActions:q,trailActions:G}),F&&e.jsx(oe,{reports:[r],editing:null,initialReportId:r.id,onClose:()=>p(!1),onSaved:async()=>{p(!1),await R(r.id)}}),e.jsx(te,{open:P,title:"Delete report?",description:`"${r.title}" will be permanently deleted. Any active share link will stop working.`+(o.length>0?` ${o.length} scheduled email${o.length===1?"":"s"} for this report will also be removed.`:""),confirmLabel:"Delete",onConfirm:B,onCancel:()=>v(!1)})]})}export{Se as ReportFullView};
|