sparkforensics-server 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +147 -0
- package/lib/static-files.js +50 -0
- package/package.json +28 -0
- package/public/assets/AutoscalingChurn-CP5OjN6v.js +1 -0
- package/public/assets/CacheUtilization-BjyawXL6.js +1 -0
- package/public/assets/CachingOpportunity-DV2ABG2G.js +1 -0
- package/public/assets/ConfigAudit-DMiBhAoG.js +1 -0
- package/public/assets/CoreUsageArea-CGYIgPnt.js +1 -0
- package/public/assets/Dashboard-D1_IrWRs.js +12 -0
- package/public/assets/ExecutorTimeline-DkaAGqQT.js +1 -0
- package/public/assets/Failures-Crngoicu.js +1 -0
- package/public/assets/GcPressure-CFXm4BnA.js +1 -0
- package/public/assets/IncompleteRun-BWEJTb13.js +1 -0
- package/public/assets/JobFailures-BmjxCA-h.js +1 -0
- package/public/assets/MemoryUtilization-Bu2uQJbd.js +1 -0
- package/public/assets/PlanExplorer-DKUwF0uz.js +1 -0
- package/public/assets/PlanGraphRoute-BjPSugIG.js +1 -0
- package/public/assets/ShuffleIO--Rur3neu.js +1 -0
- package/public/assets/Spill-DIMpt8c2.js +1 -0
- package/public/assets/TaskSkew-BDr1DbeI.js +1 -0
- package/public/assets/charts-vendor-NMqKV0H4.js +59 -0
- package/public/assets/index-4id52G-A.js +9 -0
- package/public/assets/index-D9kwVYIO.css +1 -0
- package/public/assets/parser-worker-00O9WEQC.js +65 -0
- package/public/assets/plan-graph-vendor-BnuhLJ6X.css +1 -0
- package/public/assets/plan-graph-vendor-vZQHG2EJ.js +7 -0
- package/public/assets/react-vendor-u4pyvC5Y.js +9 -0
- package/public/assets/useRecentFiles-46iBU9zJ.js +5 -0
- package/public/docs/404.html +26 -0
- package/public/docs/assets/app.Bxy4_HVA.js +1 -0
- package/public/docs/assets/chunks/@localSearchIndexroot.DclgKtlT.js +1 -0
- package/public/docs/assets/chunks/VPLocalSearchBox.L5jNOIR3.js +9 -0
- package/public/docs/assets/chunks/framework.CNDaxUod.js +20 -0
- package/public/docs/assets/chunks/theme.CoT6y5bf.js +2 -0
- package/public/docs/assets/contributor-guide_architecture_board-widgets.md.BtjoE_1k.js +1 -0
- package/public/docs/assets/contributor-guide_architecture_board-widgets.md.BtjoE_1k.lean.js +1 -0
- package/public/docs/assets/contributor-guide_architecture_detector-contract.md.DQyCHQNM.js +1 -0
- package/public/docs/assets/contributor-guide_architecture_detector-contract.md.DQyCHQNM.lean.js +1 -0
- package/public/docs/assets/contributor-guide_architecture_drill-down.md.BKfyDQck.js +1 -0
- package/public/docs/assets/contributor-guide_architecture_drill-down.md.BKfyDQck.lean.js +1 -0
- package/public/docs/assets/contributor-guide_architecture_impact-estimation.md.CzlXOnCq.js +1 -0
- package/public/docs/assets/contributor-guide_architecture_impact-estimation.md.CzlXOnCq.lean.js +1 -0
- package/public/docs/assets/contributor-guide_architecture_index.md.94lNbF-4.js +1 -0
- package/public/docs/assets/contributor-guide_architecture_index.md.94lNbF-4.lean.js +1 -0
- package/public/docs/assets/contributor-guide_architecture_overview.md.mQFlN66o.js +1 -0
- package/public/docs/assets/contributor-guide_architecture_overview.md.mQFlN66o.lean.js +1 -0
- package/public/docs/assets/contributor-guide_architecture_state-and-history.md.DaqttKgQ.js +1 -0
- package/public/docs/assets/contributor-guide_architecture_state-and-history.md.DaqttKgQ.lean.js +1 -0
- package/public/docs/assets/contributor-guide_architecture_widget-rendering.md.Bk6Iyj9S.js +1 -0
- package/public/docs/assets/contributor-guide_architecture_widget-rendering.md.Bk6Iyj9S.lean.js +1 -0
- package/public/docs/assets/contributor-guide_architecture_worker-protocol.md.BaS_L10g.js +6 -0
- package/public/docs/assets/contributor-guide_architecture_worker-protocol.md.BaS_L10g.lean.js +1 -0
- package/public/docs/assets/contributor-guide_contributing.md.C-lKs70I.js +1 -0
- package/public/docs/assets/contributor-guide_contributing.md.C-lKs70I.lean.js +1 -0
- package/public/docs/assets/contributor-guide_development-setup.md.CpUMVtIK.js +12 -0
- package/public/docs/assets/contributor-guide_development-setup.md.CpUMVtIK.lean.js +1 -0
- package/public/docs/assets/contributor-guide_testing.md.C0q-BJfl.js +1 -0
- package/public/docs/assets/contributor-guide_testing.md.C0q-BJfl.lean.js +1 -0
- package/public/docs/assets/index.md.CETnDZzR.js +1 -0
- package/public/docs/assets/index.md.CETnDZzR.lean.js +1 -0
- package/public/docs/assets/inter-italic-cyrillic-ext.r48I6akx.woff2 +0 -0
- package/public/docs/assets/inter-italic-cyrillic.By2_1cv3.woff2 +0 -0
- package/public/docs/assets/inter-italic-greek-ext.1u6EdAuj.woff2 +0 -0
- package/public/docs/assets/inter-italic-greek.DJ8dCoTZ.woff2 +0 -0
- package/public/docs/assets/inter-italic-latin-ext.CN1xVJS-.woff2 +0 -0
- package/public/docs/assets/inter-italic-latin.C2AdPX0b.woff2 +0 -0
- package/public/docs/assets/inter-italic-vietnamese.BSbpV94h.woff2 +0 -0
- package/public/docs/assets/inter-roman-cyrillic-ext.BBPuwvHQ.woff2 +0 -0
- package/public/docs/assets/inter-roman-cyrillic.C5lxZ8CY.woff2 +0 -0
- package/public/docs/assets/inter-roman-greek-ext.CqjqNYQ-.woff2 +0 -0
- package/public/docs/assets/inter-roman-greek.BBVDIX6e.woff2 +0 -0
- package/public/docs/assets/inter-roman-latin-ext.4ZJIpNVo.woff2 +0 -0
- package/public/docs/assets/inter-roman-latin.Di8DUHzh.woff2 +0 -0
- package/public/docs/assets/inter-roman-vietnamese.BjW4sHH5.woff2 +0 -0
- package/public/docs/assets/style.D2mY0HUs.css +1 -0
- package/public/docs/assets/user-guide_getting-started.md.BJdD7a7_.js +3 -0
- package/public/docs/assets/user-guide_getting-started.md.BJdD7a7_.lean.js +1 -0
- package/public/docs/assets/user-guide_mcp-tools.md.DwYI1d6C.js +95 -0
- package/public/docs/assets/user-guide_mcp-tools.md.DwYI1d6C.lean.js +1 -0
- package/public/docs/assets/user-guide_run-comparison.md.5-oaOfTu.js +1 -0
- package/public/docs/assets/user-guide_run-comparison.md.5-oaOfTu.lean.js +1 -0
- package/public/docs/assets/user-guide_understanding-findings.md.CK2WZ0Tf.js +1 -0
- package/public/docs/assets/user-guide_understanding-findings.md.CK2WZ0Tf.lean.js +1 -0
- package/public/docs/contributor-guide/architecture/board-widgets.html +29 -0
- package/public/docs/contributor-guide/architecture/detector-contract.html +29 -0
- package/public/docs/contributor-guide/architecture/drill-down.html +29 -0
- package/public/docs/contributor-guide/architecture/impact-estimation.html +29 -0
- package/public/docs/contributor-guide/architecture/index.html +29 -0
- package/public/docs/contributor-guide/architecture/overview.html +29 -0
- package/public/docs/contributor-guide/architecture/state-and-history.html +29 -0
- package/public/docs/contributor-guide/architecture/widget-rendering.html +29 -0
- package/public/docs/contributor-guide/architecture/worker-protocol.html +34 -0
- package/public/docs/contributor-guide/contributing.html +29 -0
- package/public/docs/contributor-guide/development-setup.html +40 -0
- package/public/docs/contributor-guide/testing.html +29 -0
- package/public/docs/favicon.svg +4 -0
- package/public/docs/hashmap.json +1 -0
- package/public/docs/index.html +29 -0
- package/public/docs/user-guide/getting-started.html +31 -0
- package/public/docs/user-guide/mcp-tools.html +123 -0
- package/public/docs/user-guide/run-comparison.html +29 -0
- package/public/docs/user-guide/understanding-findings.html +29 -0
- package/public/docs/vp-icons.css +0 -0
- package/public/favicon.svg +4 -0
- package/public/index.html +36 -0
- package/public/vendor/spark-doc/anchors.json +205 -0
- package/public/vendor/spark-doc/index.html +4202 -0
- package/public/vendor/spark-doc/landing.html +418 -0
- package/public/vendor/spark-doc/meta.html +970 -0
- package/vendor-core/analyzer.js +167 -0
- package/vendor-core/assert-never.js +3 -0
- package/vendor-core/cli/budgets.js +203 -0
- package/vendor-core/cli/collect-run.js +107 -0
- package/vendor-core/core-count.js +68 -0
- package/vendor-core/core-locality-ratio.js +54 -0
- package/vendor-core/core-time-series.js +92 -0
- package/vendor-core/core-usage-locality.js +70 -0
- package/vendor-core/detectors.js +1989 -0
- package/vendor-core/docs-config.js +72 -0
- package/vendor-core/docs-site-config.js +23 -0
- package/vendor-core/efficiency-model.js +62 -0
- package/vendor-core/etl-phases.js +28 -0
- package/vendor-core/event-handlers.js +906 -0
- package/vendor-core/event-schemas.js +405 -0
- package/vendor-core/evidence-availability.js +121 -0
- package/vendor-core/evidence-report.js +459 -0
- package/vendor-core/finding-action-label.js +97 -0
- package/vendor-core/finding-filter-predicate.js +38 -0
- package/vendor-core/format-utils.js +167 -0
- package/vendor-core/impact-band.js +50 -0
- package/vendor-core/impact-estimator.js +428 -0
- package/vendor-core/ingest.js +139 -0
- package/vendor-core/job-groups.js +30 -0
- package/vendor-core/load-vendored.js +24 -0
- package/vendor-core/lz4-block.js +135 -0
- package/vendor-core/mcp-error.js +3 -0
- package/vendor-core/mcp-server-factory.js +115 -0
- package/vendor-core/mcp-tools.js +331 -0
- package/vendor-core/model-assembler.js +76 -0
- package/vendor-core/occupancy.js +202 -0
- package/vendor-core/parser-worker.js +249 -0
- package/vendor-core/plan-dot.js +25 -0
- package/vendor-core/plan-duration-attribution.js +185 -0
- package/vendor-core/plan-graph-model.js +171 -0
- package/vendor-core/plan-node-detail.js +159 -0
- package/vendor-core/plan-summary.js +233 -0
- package/vendor-core/plan-tree-walk.js +29 -0
- package/vendor-core/proxy.js +157 -0
- package/vendor-core/recommendation-rollup.js +197 -0
- package/vendor-core/redact.js +175 -0
- package/vendor-core/rolling-log-reassembly.js +52 -0
- package/vendor-core/run-aggregates.js +44 -0
- package/vendor-core/run-comparison.js +458 -0
- package/vendor-core/scaling-sim.js +73 -0
- package/vendor-core/session-snapshot.js +79 -0
- package/vendor-core/shs-fetch.js +196 -0
- package/vendor-core/shs-load.js +121 -0
- package/vendor-core/shs-request.js +101 -0
- package/vendor-core/shs-schemas.js +13 -0
- package/vendor-core/snappy-block.js +140 -0
- package/vendor-core/stage-quantiles.js +199 -0
- package/vendor-core/threshold-summary.js +35 -0
- package/vendor-core/types.js +286 -0
- package/vendor-core/vendor/fflate.js +2695 -0
- package/vendor-core/vendor/fzstd.js +768 -0
- package/vendor-core/wall-clock.js +36 -0
- package/vendor-core/wasted-core-hours.js +68 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./TaskSkew-BDr1DbeI.js","./react-vendor-u4pyvC5Y.js","./index-4id52G-A.js","./charts-vendor-NMqKV0H4.js","./plan-graph-vendor-vZQHG2EJ.js","./plan-graph-vendor-BnuhLJ6X.css","./index-D9kwVYIO.css","./PlanExplorer-DKUwF0uz.js","./useRecentFiles-46iBU9zJ.js","./ShuffleIO--Rur3neu.js","./Spill-DIMpt8c2.js","./GcPressure-CFXm4BnA.js","./Failures-Crngoicu.js","./ExecutorTimeline-DkaAGqQT.js","./MemoryUtilization-Bu2uQJbd.js","./CachingOpportunity-DV2ABG2G.js","./JobFailures-BmjxCA-h.js","./ConfigAudit-DMiBhAoG.js","./CacheUtilization-BjyawXL6.js","./CoreUsageArea-CGYIgPnt.js","./AutoscalingChurn-CP5OjN6v.js","./IncompleteRun-BWEJTb13.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as x,j as o,S as Zn,T as ei,t as ti,A as ni,v as ii,x as si,y as oi,z as ri}from"./react-vendor-u4pyvC5Y.js";import{c as ai,d as N,e as li,I as ue,t as tn,X as ui,g as mt,h as ci,i as di,j as Ne,k as gi,l as nn,m as U,n as sn,o as Me,p as B,W as X,f as F,q as ie,D as pt,r as ht,v as we,x as Ee,y as fi,E as on,z as mi,A as pi,F as rn,_ as z,G as hi,H as xi,J as wi,K as ee,L as xt,M as Z,N as an,O as ln,P as vi,S as Si,Q as Ci,T as pe,R as yi,U as Ri,V as ji,Y as wt,B as ke,Z as Y,$ as un,a0 as bi,a1 as _i,C as he,a2 as Ii,a3 as cn,a4 as Fi,a5 as ki,a6 as $i,u as Ti,a as Ei,a7 as Re,b as kt,a8 as Pi}from"./index-4id52G-A.js";import{i as Ni,j as $t,I as dn,k as Mi,l as Ai,n as Li,o as Di,q as zi,s as Vi,t as gn,v as Bi,D as Oi,d as Hi,e as Gi,f as qi,S as oe,r as Wi,P as Ui,u as Ki,T as Xi,w as Yi,x as Ji,y as Tt,z as Et}from"./useRecentFiles-46iBU9zJ.js";import{R as Qi,A as Zi,B as ce,L as fn,P as es,a as ts,b as ns,S as is,d as Ae,C as ve,X as Se,Y as Ce,e as ss,T as Le,f as Pt,g as mn}from"./charts-vendor-NMqKV0H4.js";const os=[["path",{d:"M2 5h20",key:"1fs1ex"}],["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M9 19h6",key:"456am0"}]],rs=ai("list-filter",os),vt=["critical","warning","info"];function st(){return{impactBands:new Set,types:new Set,stages:new Set}}function as(e){return e.impactBands.size===0&&e.types.size===0&&e.stages.size===0}function ls(e,n){return Ni(e,{impactBand:n.impactBands,type:n.types,stageId:n.stages})}function Nt(e,n){return e.filter(t=>ls(t,n))}function us(e,n){const t=new Set,i=new Set,s=new Set;for(const r of[...e,...n])t.add(r.impactBand),i.add(r.type),r.stageId!=null&&s.add(r.stageId);return{impactBands:vt.filter(r=>t.has(r)),types:[...i].sort(),stages:[...s].sort((r,a)=>r-a)}}function Ge(e){return e?e.split(",").map(n=>n.trim()).filter(Boolean):[]}function Mt(e,n){const t=new URLSearchParams(e),i=st();for(const r of Ge(t.get("impact")))vt.includes(r)&&i.impactBands.add(r);const s=new Set(n.types);for(const r of Ge(t.get("type")))s.has(r)&&i.types.add(r);for(const r of Ge(t.get("stage"))){const a=Number(r);Number.isInteger(a)&&i.stages.add(a)}return i}function cs(e){const n=[];return e.impactBands.size&&n.push(`impact=${vt.filter(t=>e.impactBands.has(t)).join(",")}`),e.types.size&&n.push(`type=${[...e.types].sort().join(",")}`),e.stages.size&&n.push(`stage=${[...e.stages].sort((t,i)=>t-i).join(",")}`),n.length?`?${n.join("&")}`:""}const pn=x.createContext(null);function qe(e,n){const t=new Set(e);return t.has(n)?t.delete(n):t.add(n),t}function ds({options:e,fileId:n,children:t}){const[i,s]=x.useState(()=>Mt(typeof window>"u"?"":window.location.search,e));x.useEffect(()=>{if(typeof window>"u")return;const p=cs(i),d=`${window.location.pathname}${p}${window.location.hash}`;window.history.replaceState(window.history.state,"",d)},[i]);const r=x.useRef(n);x.useEffect(()=>{r.current!==n&&(r.current=n,s(st()))},[n]),x.useEffect(()=>()=>{if(typeof window>"u")return;const p=`${window.location.pathname}${window.location.hash}`;window.history.replaceState(window.history.state,"",p)},[]),x.useEffect(()=>{if(typeof window>"u")return;const p=()=>s(Mt(window.location.search,e));return window.addEventListener("popstate",p),()=>window.removeEventListener("popstate",p)},[e]);const a=x.useCallback(p=>s(d=>({...d,impactBands:qe(d.impactBands,p)})),[]),l=x.useCallback(p=>s(d=>({...d,types:qe(d.types,p)})),[]),u=x.useCallback(p=>s(d=>({...d,stages:qe(d.stages,p)})),[]),c=x.useCallback(()=>s(st()),[]),g=x.useMemo(()=>({selection:i,toggleImpactBand:a,toggleType:l,toggleStage:u,clearAll:c}),[i,a,l,u,c]);return o.jsx(pn.Provider,{value:g,children:t})}function St(){const e=x.useContext(pn);if(!e)throw new Error("useFindingFilter outside FindingFilterProvider");return e}function gs(){const{clearAll:e}=St();return o.jsxs("div",{className:"flex items-center gap-3 rounded-xl border border-border/60 bg-muted/40 p-4",children:[o.jsxs("div",{className:"flex-1",children:[o.jsx("p",{className:"font-medium",children:"No findings match the active filters"}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Adjust or clear the filters to see findings."})]}),o.jsx("button",{type:"button",onClick:e,className:"text-sm underline",children:"Clear all filters"})]})}function je({className:e,orientation:n="horizontal",...t}){return o.jsx(Zn,{"data-slot":"separator",orientation:n,className:N("shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch",e),...t})}const fs=li("group/toggle inline-flex items-center justify-center gap-1 rounded-lg text-sm font-medium whitespace-nowrap transition-all outline-none hover:bg-muted hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 aria-pressed:bg-muted data-[state=on]:bg-muted dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"bg-transparent",outline:"border border-input bg-transparent hover:bg-muted"},size:{default:"h-8 min-w-8 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",sm:"h-7 min-w-7 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",lg:"h-9 min-w-9 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2"}},defaultVariants:{variant:"default",size:"default"}}),hn=x.createContext({size:"default",variant:"default",spacing:2,orientation:"horizontal"});function ms({className:e,variant:n,size:t,spacing:i=2,orientation:s="horizontal",children:r,...a}){return o.jsx(ei,{"data-slot":"toggle-group","data-variant":n,"data-size":t,"data-spacing":i,"data-orientation":s,style:{"--gap":i},className:N("group/toggle-group flex w-fit flex-row items-center gap-[--spacing(var(--gap))] rounded-lg data-[size=sm]:rounded-[min(var(--radius-md),10px)] data-vertical:flex-col data-vertical:items-stretch",e),...a,children:o.jsx(hn.Provider,{value:{variant:n,size:t,spacing:i,orientation:s},children:r})})}function ps({className:e,children:n,variant:t="default",size:i="default",...s}){const r=x.useContext(hn);return o.jsx(ti,{"data-slot":"toggle-group-item","data-variant":r.variant||t,"data-size":r.size||i,"data-spacing":r.spacing,className:N("shrink-0 group-data-[spacing=0]/toggle-group:rounded-none group-data-[spacing=0]/toggle-group:px-2 focus:z-10 focus-visible:z-10 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-end]:pr-1.5 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-start]:pl-1.5 group-data-horizontal/toggle-group:data-[spacing=0]:first:rounded-l-lg group-data-vertical/toggle-group:data-[spacing=0]:first:rounded-t-lg group-data-horizontal/toggle-group:data-[spacing=0]:last:rounded-r-lg group-data-vertical/toggle-group:data-[spacing=0]:last:rounded-b-lg group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:border-l-0 group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:border-t-0 group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-l group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-t",fs({variant:r.variant||t,size:r.size||i}),e),...s,children:n})}const hs={critical:"aria-pressed:bg-critical/10 aria-pressed:text-critical",warning:"aria-pressed:bg-warning/10 aria-pressed:text-warning",info:"aria-pressed:bg-info/10 aria-pressed:text-info"};function xs(e,n,t){const i=new Set(e);for(const s of i)n.has(s)||t(s);for(const s of n)i.has(s)||t(s)}function At({label:e,count:n,children:t}){return o.jsxs(Mi,{children:[o.jsxs(Ai,{className:N(ci({variant:"outline",size:"sm"}),"gap-1.5"),"aria-label":`Filter by ${e.toLowerCase()}`,children:[e,n>0&&o.jsx("span",{className:"rounded-full bg-primary px-1.5 text-xs font-medium text-primary-foreground",children:n}),o.jsx(mt,{"aria-hidden":"true",className:"opacity-60"})]}),o.jsx(Li,{align:"start",className:"max-h-72 w-56 overflow-y-auto",children:t})]})}function ws({options:e,resultCount:n}){const{selection:t,toggleImpactBand:i,toggleType:s,toggleStage:r,clearAll:a}=St(),[l,u]=x.useState(""),c=x.useMemo(()=>{const d=l.trim();return d?e.stages.filter(f=>String(f).includes(d)):e.stages},[e.stages,l]);if(e.impactBands.length===0&&e.types.length===0&&e.stages.length===0)return null;const g=!as(t),p=[...[...t.impactBands].map(d=>({key:`impact-${d}`,label:`impact ${d}`,onRemove:()=>i(d)})),...[...t.types].map(d=>({key:`type-${d}`,label:`type ${d}`,onRemove:()=>s(d)})),...[...t.stages].map(d=>({key:`stage-${d}`,label:`stage ${d}`,onRemove:()=>r(d)}))];return o.jsxs("section",{"aria-label":"Filter findings",className:"flex flex-wrap items-center gap-x-3 gap-y-2 rounded-xl border border-border/60 p-2",children:[o.jsxs("span",{title:"Narrow the whole dashboard to findings matching the chosen impact bands, types, or stages",className:"flex items-center gap-1.5 text-xs font-medium text-muted-foreground",children:[o.jsx(rs,{"aria-hidden":"true",className:"size-3.5"}),"Filter findings"]}),o.jsx("span",{role:"status","aria-live":"polite",className:"text-xs text-muted-foreground",children:g?`${n} finding${n===1?"":"s"} match${n===1?"es":""} the active filters`:`Showing all ${n} finding${n===1?"":"s"}`}),o.jsx(je,{orientation:"vertical",className:"h-6"}),e.impactBands.length>0&&o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Impact"}),o.jsx(ms,{multiple:!0,"aria-label":"Filter by impact",value:[...t.impactBands],onValueChange:d=>xs(d,t.impactBands,i),children:e.impactBands.map(d=>o.jsxs(ps,{value:d,variant:"outline",size:"sm","aria-label":`Filter by impact: ${d}`,className:N("tap-target-comfortable gap-1.5",hs[d]),children:[o.jsx(ue,{impactBand:d}),d]},d))})]}),e.types.length>0&&o.jsxs(o.Fragment,{children:[o.jsx(je,{orientation:"vertical",className:"h-6"}),o.jsx(At,{label:"Type",count:t.types.size,children:e.types.map(d=>o.jsxs($t,{checked:t.types.has(d),onCheckedChange:()=>s(d),"aria-label":`Filter by type: ${d}`,children:[o.jsx("span",{className:"rounded bg-muted px-1 text-xs font-medium text-foreground!",children:tn(d)})," ",d]},d))})]}),e.stages.length>0&&o.jsxs(o.Fragment,{children:[o.jsx(je,{orientation:"vertical",className:"h-6"}),o.jsxs(At,{label:"Stage",count:t.stages.size,children:[o.jsx("div",{className:"p-1",children:o.jsx(dn,{type:"text",value:l,onChange:d=>u(d.target.value),onKeyDown:d=>d.stopPropagation(),placeholder:"Search stage id…","aria-label":"Search stages",autoComplete:"off",className:"h-8"})}),c.map(d=>o.jsxs($t,{checked:t.stages.has(d),onCheckedChange:()=>r(d),"aria-label":`Filter by stage: ${d}`,children:["Stage ",d]},d)),c.length===0&&o.jsx("p",{className:"px-2 py-1.5 text-xs text-muted-foreground",children:"No matching stage"})]})]}),g&&o.jsxs(o.Fragment,{children:[o.jsx(je,{orientation:"vertical",className:"h-6"}),o.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[p.map(d=>o.jsxs("button",{type:"button",onClick:d.onRemove,"aria-label":`Remove filter: ${d.label}`,className:"tap-target-comfortable inline-flex items-center gap-1 rounded-full border border-border bg-muted px-2 py-0.5 text-xs hover:bg-muted/70",children:[d.label," ",o.jsx(ui,{"aria-hidden":"true",className:"size-3"})]},d.key)),o.jsx("button",{type:"button",onClick:a,className:"tap-target-comfortable text-xs underline",children:"Clear all filters"})]})]})]})}function vs(e,n){const t=[];for(const{launch:r,finish:a}of e)a>r&&(t.push({t:r,delta:1}),t.push({t:a,delta:-1}));t.sort((r,a)=>r.t-a.t||r.delta-a.delta);const i=[];let s=0;for(let r=0;r<t.length;r++){const a=t[r];s+=a.delta;const l=t[r+1];if(!l||l.t===a.t)continue;const u=n!=null?Math.min(s,n):s;i.push({tStart:a.t,tEnd:l.t,busy:u})}return i}function Ss(e,{bucketBy:n="time",bucketWidthMs:t=1e3,hypotheticalCores:i=null}={}){const s=vs(e,i);if(n==="coreCount"){const u=[];for(const c of s)u[c.busy]=(u[c.busy]??0)+(c.tEnd-c.tStart);for(let c=0;c<u.length;c++)u[c]===void 0&&(u[c]=0);return{mode:"coreCount",histogram:u}}if(s.length===0)return{mode:"time",bucketWidthMs:t,startTime:null,endTime:null,buckets:[]};const r=s[0].tStart,a=s[s.length-1].tEnd,l=[];for(let u=r;u<a;u+=t){const c=u+t;let g=0;for(const p of s){const d=Math.max(p.tStart,u),f=Math.min(p.tEnd,c);f>d&&(g+=p.busy*(f-d))}l.push({tStart:u,tEnd:c,busyCoreMs:g,avgBusyCores:g/t})}return{mode:"time",bucketWidthMs:t,startTime:r,endTime:a,buckets:l}}const Cs={light:"",dark:".dark"},ys={width:320,height:200},Rs=x.createContext(null);function js({id:e,className:n,children:t,config:i,initialDimension:s=ys,...r}){const a=x.useId(),l=`chart-${e??a.replace(/:/g,"")}`;return o.jsx(Rs.Provider,{value:{config:i},children:o.jsxs("div",{"data-slot":"chart","data-chart":l,className:N("flex aspect-video justify-center text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-hidden [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border [&_.recharts-sector]:outline-hidden [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-surface]:outline-hidden",n),...r,children:[o.jsx(bs,{id:l,config:i}),o.jsx(Qi,{initialDimension:s,children:t})]})})}const bs=({id:e,config:n})=>{const t=Object.entries(n).filter(([,i])=>i.theme??i.color);return t.length?o.jsx("style",{dangerouslySetInnerHTML:{__html:Object.entries(Cs).map(([i,s])=>`
|
|
3
|
+
${s} [data-chart=${e}] {
|
|
4
|
+
${t.map(([r,a])=>{const l=a.theme?.[i]??a.color;return l?` --color-${r}: ${l};`:null}).join(`
|
|
5
|
+
`)}
|
|
6
|
+
}
|
|
7
|
+
`).join(`
|
|
8
|
+
`)}}):null},xn="(prefers-reduced-motion: reduce)";function _s(e){if(typeof window>"u"||!window.matchMedia)return()=>{};const n=window.matchMedia(xn);return n.addEventListener("change",e),()=>n.removeEventListener("change",e)}function Is(){return typeof window>"u"||!window.matchMedia?!1:window.matchMedia(xn).matches}function Fs(){return x.useSyncExternalStore(_s,Is,()=>!1)}const M={accent:"var(--color-accent)",warning:"var(--color-warning)",critical:"var(--color-critical)",info:"var(--color-info)",clean:"var(--color-clean)",muted:"var(--color-muted-foreground)"};function ks(e,n){return[e,...n].map(t=>t.join(" ")).join(`
|
|
9
|
+
`)}async function $s(e){if(navigator.clipboard?.writeText)try{await navigator.clipboard.writeText(e);return}catch{}const n=document.createElement("textarea");n.value=e,n.style.position="fixed",n.style.opacity="0",document.body.appendChild(n);try{if(n.select(),!document.execCommand("copy"))throw new Error("copy unavailable")}finally{n.remove()}}function Ts({caption:e,columns:n,rows:t,align:i}){const[s,r]=x.useState(!1),[a,l]=x.useState(!1);async function u(){try{await $s(ks(n,t)),l(!0),setTimeout(()=>l(!1),1500)}catch{}}return o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("button",{type:"button",className:"text-muted-foreground text-xs underline","aria-expanded":s,onClick:()=>r(c=>!c),children:"▤ Table"}),o.jsx("button",{type:"button",className:"text-muted-foreground text-xs underline",onClick:u,children:"⧉ Copy"}),o.jsx("span",{"aria-live":"polite",className:"text-xs text-muted-foreground",children:a?"Copied":""})]}),o.jsxs(Ne,{className:s?void 0:"sr-only",children:[o.jsx(gi,{className:"sr-only",children:e}),o.jsx(nn,{children:o.jsx(U,{children:n.map((c,g)=>o.jsx(sn,{className:i?.[g]==="right"?"text-right":void 0,children:c},c))})}),o.jsx(Me,{children:t.map((c,g)=>o.jsx(U,{children:c.map((p,d)=>o.jsx(B,{className:i?.[d]==="right"?"text-right":void 0,children:p},d))},g))})]})]})}const Es=new Set([Zi,ce,fn,es,ts,ns,is]);function wn(e){if(!x.isValidElement(e))return e;const{children:n,isAnimationActive:t}=e.props,i=n==null?n:x.Children.map(n,wn),s=Es.has(e.type)&&t===void 0;return!s&&i===n?e:x.cloneElement(e,s?{isAnimationActive:!1}:{},...n==null?[]:[i])}function ye({title:e,ariaLabel:n,height:t,children:i,table:s}){const a=Fs()?wn(i):i,l=di();return o.jsxs("div",{className:"flex flex-col gap-1",children:[e?o.jsx("p",{className:"text-muted-foreground text-xs font-medium",children:e}):null,l?o.jsx(js,{role:"img","aria-label":n,config:{},className:"aspect-auto w-full",style:{height:t},initialDimension:{width:320,height:t},children:a}):o.jsx("div",{style:{height:t},"aria-hidden":!0}),s?o.jsx(Ts,{...s}):null]})}function Ct(e,n=2e3){if(e.length<=n)return e;if(n<=1)return e.length?[e[0]]:[];const t=e.length-1,i=t/(n-1),s=new Array(n);for(let r=0;r<n;r++)s[r]=e[Math.min(t,Math.round(r*i))];return s}const Ps=220;async function Ns(e,n){const t=[...e.stages.keys()],i=await Promise.all(t.map(a=>n(a).catch(()=>null))),s=[];let r=!1;for(const a of i){if(!a){r=!0;continue}const{metrics:l,fieldNames:u}=a,c=u.length,g=u.indexOf("launchTime"),p=u.indexOf("finishTime");if(!(g===-1||p===-1))for(let d=0;d<l.length;d+=c)s.push({launch:l[d+g],finish:l[d+p]})}return{intervals:s,incomplete:r}}function Ms({appModel:e,getTaskData:n}){const[t,i]=x.useState(null),[s,r]=x.useState(!1),[a,l]=x.useState(!1),u=e.stages.size>0;if(x.useEffect(()=>{if(!u||!a||t!==null)return;let d=!1;return Ns(e,n).then(({intervals:f,incomplete:h})=>{if(d)return;const{histogram:m}=Ss(f,{bucketBy:"coreCount"});i(m??[]),r(h)}),()=>{d=!0}},[e,n,u,a,t]),!u)return null;const c=(t??[]).map((d,f)=>({cores:String(f),coreCount:f,ms:d})),g=Ct(c),p=c.reduce((d,f)=>f.ms>d.ms?f:d,c[0]);return o.jsx(X,{title:"Core-Usage Distribution",id:"core-usage-histogram",badges:o.jsx(pt,{anchor:"#bottleneck-utilization",children:"Learn more →"}),open:a,onOpenChange:l,summary:t!==null&&p?o.jsx(ie,{value:F(p.ms),context:`at ${p.coreCount} concurrent core${p.coreCount===1?"":"s"}`}):void 0,children:t===null?o.jsx("p",{className:"text-muted-foreground text-xs",children:"Loading core usage…"}):o.jsxs(o.Fragment,{children:[o.jsx(ye,{ariaLabel:"Wall-clock time spent at each concurrent-core count across the run. See the table below for exact values.",height:Ps,table:{caption:"Wall-clock time by concurrent-core count",columns:["Concurrent cores","Time"],rows:t.map((d,f)=>[f,F(d)]),align:["right","right"]},children:o.jsxs(Ae,{data:g,children:[o.jsx(ve,{vertical:!1,stroke:M.muted,strokeOpacity:.2}),o.jsx(Se,{dataKey:"cores",tick:{fontSize:10},label:{value:"Concurrent busy cores",position:"insideBottom",offset:-5,fontSize:10}}),o.jsx(Ce,{tick:{fontSize:10},width:48,tickFormatter:d=>F(d)}),o.jsx(ce,{dataKey:"ms",name:"Time",fill:M.accent})]})}),s?o.jsx("p",{className:"text-muted-foreground text-xs",children:"Reopen this file to compute full core usage because some task data was released."}):null]})})}function vn({app:e,stages:n,executorsAdded:t,runAggregates:i}){const s=ht(e??{},t),r=(e?.endTime??0)-(e?.startTime??0),a=we(e,n),l=s*(r/36e5),u=a.startup+a.gaps+a.idle,c=s*(u/36e5),g=s*a.stagesActive,p=i?.busyCoreMs??0,d=Math.max(0,g-p)/36e5,f=c+d,h=l>0?Math.round(f/l*100):null;let m=0;const v=i?.perStage??{};for(const C of Object.keys(v))m+=v[C].totalTaskDurationSum;const S=s>0?m/s:0;let j=null;return(c>0||d>0)&&(j=c>=d?"driver":"executor"),{availableComputeHours:l,driverWasteHours:c,executorWasteHours:d,wastagePct:h,floorZeroSkewMs:S,dominantWaste:j}}function Sn(e){const n=e?[...e.values()]:[],t=new Map;let i=0;for(const a of n){if(a.submissionTime==null||a.completionTime==null)continue;const l=a.sqlExecutionId!=null?`sql:${a.sqlExecutionId}`:`job:${a.id??i++}`,u=t.get(l);u?(u.start=Math.min(u.start,a.submissionTime),u.end=Math.max(u.end,a.completionTime)):t.set(l,{start:a.submissionTime,end:a.completionTime})}const s=[...t.entries()].sort((a,l)=>a[1].start-l[1].start),r=[];for(let a=1;a<s.length;a++)for(let l=0;l<a;l++){const[u,c]=s[l],[g,p]=s[a];p.start<c.end&&c.start<p.end&&r.push([u,g])}return{wallClockReliable:r.length===0,overlappingGroupIds:r}}const ge=e=>`${Math.round(e*100)/100} core-h`;function As({appModel:e}){if(!e.runAggregates)return null;const n=vn({app:e.app,stages:e.stages,executorsAdded:e.executors.added,runAggregates:e.runAggregates});if(n.availableComputeHours<=0)return null;const t=Sn(e.jobs);let i=null;return n.dominantWaste==="driver"?i=o.jsxs("p",{children:[o.jsx("strong",{children:"Driver-bound waste dominates."})," Review driver sizing (spark.driver.memory / spark.driver.cores) before scaling executors."]}):n.dominantWaste==="executor"&&(i=o.jsxs("p",{children:[o.jsx("strong",{children:"Executor-bound waste dominates."})," Review executor count / cores by reducing cluster size or enabling dynamic allocation."]})),o.jsx(X,{title:"Compute Efficiency",badges:o.jsx(Ee,{variant:"outline",className:"text-muted-foreground text-xs",title:"This is a design-spike estimate, so verify against wall-clock data before acting on it.",children:"low confidence: verify"}),defaultCollapsed:!0,summary:o.jsx(ie,{value:n.wastagePct!=null?`${n.wastagePct}% wasted`:ge(n.availableComputeHours),context:`of ${ge(n.availableComputeHours)} available`}),children:o.jsxs("div",{className:"space-y-2 text-sm",children:[!t.wallClockReliable&&o.jsx("p",{className:"text-muted-foreground",children:"This run used concurrent job groups: the driver/executor split below is approximate, not precise."}),o.jsxs("p",{children:["Available: ",o.jsx("strong",{children:ge(n.availableComputeHours)}),n.wastagePct!=null&&o.jsxs(o.Fragment,{children:[" ","· wasted ",o.jsxs("strong",{children:[n.wastagePct,"%"]})]})]}),o.jsxs("p",{children:[o.jsx(ue,{impactBand:"info"})," Driver-bound waste: ",o.jsx("strong",{children:ge(n.driverWasteHours)})]}),o.jsxs("p",{children:[o.jsx(ue,{impactBand:"info"})," Executor-bound waste: ",o.jsx("strong",{children:ge(n.executorWasteHours)})]}),o.jsxs("p",{className:"text-muted-foreground",children:["Floor (same executors, zero skew): ",F(n.floorZeroSkewMs)]}),i]})})}function Ls(e){const n={extract:0,transform:0,load:0};for(const t of e.values()){const i=Math.max(0,(t.completedAt??0)-(t.submittedAt??0));if(i===0)continue;const s=(t.shuffleReadBytes??0)>0||(t.shuffleWriteBytes??0)>0;(t.inputBytes??0)>0&&(t.shuffleReadBytes??0)===0&&(n.extract+=i),s&&(n.transform+=i),(t.outputBytes??0)>0&&(n.load+=i)}return n}const Lt=[{label:"Extract",key:"extract"},{label:"Transform",key:"transform"},{label:"Load",key:"load"}];function Ds({appModel:e}){const n=Ls(e.stages);if(n.extract+n.transform+n.load===0)return null;const i=Lt.reduce((s,r)=>n[r.key]>n[s.key]?r:s);return o.jsx(X,{title:"ETL Phase Attribution",defaultCollapsed:!0,summary:o.jsx(ie,{value:`${i.label} ${F(n[i.key])}`,context:"dominant phase"}),children:o.jsxs("div",{className:"space-y-1",children:[Lt.map(({label:s,key:r})=>o.jsxs("div",{children:[o.jsx("strong",{children:s}),": ",F(n[r])]},r)),o.jsx("div",{className:"text-xs text-muted-foreground",children:"Heuristic: a stage that both shuffles and writes counts in Transform and Load, so phases can overlap and need not sum to wall-clock."})]})})}const Dt=[10,20,50,80,100,110,120,150,200,300,400,500];function zs(e,n,t){return n<=0||t<=0?0:e/Math.min(t,n)}function zt(e,n){let t=0;for(const i of Object.keys(e)){const{totalTaskDurationSum:s,taskCount:r}=e[i];t+=zs(s,r,n)}return t}function Vs({app:e,stages:n,runAggregates:t,executorsAdded:i}){const s=t?.perStage??{},r=ht(e??{},i),l=we(e,n).stagesActive,u=r>0?zt(s,r):0,c=l>0?Math.round(Math.abs(u-l)/l*100):null,g=u>0?l/u:1,p=Dt.map(d=>{const f=Math.max(1,Math.round(r*d/100)),h=Math.round(zt(s,f)*g);return{pct:d,cores:f,estMakespanMs:h}});return{baselineCores:r,testPercentages:Dt,predictions:p,modelErrorPct:c}}const Cn="What-If Executor Scaling",Bs=220,Os=20;function Hs([e,n]){const t=(n-e)*.1;return[Math.max(0,e-t),n+t]}function Gs(e){return[...e.stages.values()].some(n=>{const t=n.submittedAt,i=n.completedAt;return typeof t=="number"&&Number.isFinite(t)&&typeof i=="number"&&Number.isFinite(i)&&i>t})}function qs(e){return e.evidenceAvailability?.entries.find(n=>n.key==="taskCoreTime")}function We({reason:e,evidence:n}){return o.jsx(X,{title:Cn,summary:o.jsxs("span",{className:"text-muted-foreground text-xs",children:["Not available: ",e]}),children:o.jsxs("p",{className:"text-muted-foreground text-xs",children:["Not available: ",e,n?o.jsxs(o.Fragment,{children:[" ",o.jsx(on,{evidenceKey:n})]}):null]})})}function Ws({appModel:e}){const n=qs(e);if(!(fi(e.runAggregates)&&(n==null||n.state==="present")))return o.jsx(We,{reason:n?.summary??"No usable task and core-time evidence in this log.",evidence:"taskCoreTime"});const i=Vs({app:e.app,stages:e.stages,runAggregates:e.runAggregates,executorsAdded:e.executors.added});if(i.baselineCores<=0)return o.jsx(We,{reason:"Baseline executor/core capacity is unavailable in this log."});if(!Gs(e))return o.jsx(We,{reason:"Usable stage timing is unavailable in this log."});const s=Sn(e.jobs),r=i.modelErrorPct!=null&&i.modelErrorPct>=Os,a=Ct(i.predictions),l=i.predictions.reduce((u,c)=>c.estMakespanMs<u.estMakespanMs?c:u,i.predictions[0]);return o.jsx(X,{title:Cn,badges:o.jsx(pt,{anchor:"#config-autoscale-bounds",children:"Learn more →"}),defaultCollapsed:!0,summary:o.jsx(ie,{value:F(l.estMakespanMs),context:`best case at ${l.pct}% executors`}),children:o.jsxs("div",{className:"space-y-3",children:[o.jsxs("p",{className:"text-muted-foreground text-xs",children:["Model Error:"," ",o.jsx("strong",{className:r?"text-warning":void 0,children:i.modelErrorPct==null?"—":`${i.modelErrorPct}%`})," ","(idealized makespan vs. observed); higher means all estimates below are less trustworthy. Predictions are unvalidated (a single log observes only one scale)."]}),s.wallClockReliable?null:o.jsx("p",{className:"text-muted-foreground text-xs",children:"This run used concurrent job groups, so the wall-clock-based estimates below may be unreliable."}),o.jsx("p",{className:"text-xs",children:o.jsx(on,{evidenceKey:"taskCoreTime"})}),o.jsx(ye,{ariaLabel:"Estimated makespan by executor percentage: diminishing-returns curve.",height:Bs,table:{caption:"Estimated makespan by executor percentage",columns:["% Executors","Cores","Est. makespan"],rows:i.predictions.map(u=>[`${u.pct}%`,u.cores,F(u.estMakespanMs)]),align:["right","right","right"]},children:o.jsxs(ss,{data:a,children:[o.jsx(ve,{stroke:M.muted,strokeOpacity:.2}),o.jsx(Se,{dataKey:"pct",tickFormatter:u=>`${u}%`,tick:{fontSize:10}}),o.jsx(Ce,{domain:Hs,tickFormatter:u=>F(u),tick:{fontSize:10},width:56}),o.jsx(Le,{formatter:u=>[F(Number(u)),"Est. makespan"],labelFormatter:u=>`${u}% executors`}),o.jsx(fn,{type:"monotone",dataKey:"estMakespanMs",name:"Est. makespan",stroke:M.accent,dot:{r:3}})]})})]})})}function yn(e){return typeof e?.startTime=="number"&&Number.isFinite(e.startTime)&&typeof e?.endTime=="number"&&Number.isFinite(e.endTime)&&e.endTime>e.startTime}function Us(e){if(!yn(e.app))return{efficiency:{value:null,unavailableReason:"application-timing"},wastage:{value:null,unavailableReason:"application-timing"}};const n=we(e.app,e.stages),t=Math.min(100,Math.round(n.stagesActive/n.total*100));if(!e.runAggregates)return{efficiency:{value:t,unavailableReason:null},wastage:{value:null,unavailableReason:"core-usage-summary"}};const i=vn({app:e.app,stages:e.stages,executorsAdded:e.executors.added,runAggregates:e.runAggregates});return!Number.isFinite(i.availableComputeHours)||i.availableComputeHours<=0?{efficiency:{value:t,unavailableReason:null},wastage:{value:null,unavailableReason:"executor-capacity"}}:{efficiency:{value:t,unavailableReason:null},wastage:{value:i.wastagePct,unavailableReason:null}}}const Vt={critical:"text-critical",warning:"text-warning"};function Ue({eyebrow:e,value:n,meta:t,flag:i=null,dataTestid:s}){return o.jsx(mi,{size:"sm","data-testid":s,children:o.jsxs(pi,{className:"flex flex-col gap-1",children:[o.jsxs("span",{className:N("flex items-center gap-1.5 text-xs font-medium text-muted-foreground",i&&Vt[i]),children:[i&&o.jsx(ue,{impactBand:i}),e]}),o.jsx("div",{className:N("font-heading text-2xl font-semibold",i&&Vt[i]),children:n}),o.jsx("p",{className:"text-xs text-muted-foreground",children:t})]})})}function Ks({appModel:e,catalog:n}){const{app:t,stages:i}=e,s=we(t,i),r=Us(e),a=yn(t),l=s.total,u=r.efficiency.value,c=u==null?null:u<75?"critical":u<90?"warning":null,g=n.find(f=>f.type==="coldStart"),p=r.wastage.value,d=p==null?null:p>=70?"critical":p>=40?"warning":null;return o.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-3",children:[o.jsx(Ue,{eyebrow:"Wall-clock",dataTestid:"kpi-wall-clock",value:a?l>0?F(l):"—":"Unavailable",meta:a?o.jsxs(o.Fragment,{children:["Ran ",F(s.stagesActive),g?` · ${g.value}s cold start`:""]}):"This run has no complete application timing interval."}),o.jsx(Ue,{eyebrow:"Efficiency",dataTestid:"kpi-efficiency",value:u==null?"Unavailable":o.jsxs(o.Fragment,{children:[u,o.jsx("small",{children:"%"})]}),flag:c,meta:u==null?"This run has no complete application timing interval.":l>s.stagesActive?`Ran ${F(s.stagesActive)} · ${F(l-s.stagesActive)} idle/gap time`:"executors active the whole run"}),o.jsx(Ue,{eyebrow:"Wastage",dataTestid:"kpi-wastage",value:p==null?"Unavailable":o.jsxs(o.Fragment,{children:[p,o.jsx("small",{children:"%"})]}),flag:d,meta:r.wastage.unavailableReason==="application-timing"?"Wastage needs complete application timing.":r.wastage.unavailableReason==="core-usage-summary"?"Wastage needs the core-usage summary.":r.wastage.unavailableReason==="executor-capacity"?"Wastage needs usable executor-capacity data.":"Directional estimate of unused executor capacity; it is not a cost or billing figure."})]})}function Xs({className:e,...n}){return o.jsx(ni,{"data-slot":"accordion",className:N("flex w-full flex-col",e),...n})}function Ys({className:e,...n}){return o.jsx(ii,{"data-slot":"accordion-item",className:N("not-last:border-b",e),...n})}function Js({className:e,children:n,headingLevel:t=3,...i}){const s=`h${t}`;return o.jsx(si,{className:"flex",render:o.jsx(s,{}),children:o.jsxs(oi,{"data-slot":"accordion-trigger",className:N("group/accordion-trigger relative flex flex-1 items-start justify-between rounded-lg border border-transparent py-2.5 text-left text-sm font-medium transition-all outline-none hover:underline focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:after:border-ring aria-disabled:pointer-events-none aria-disabled:opacity-50 **:data-[slot=accordion-trigger-icon]:ml-auto **:data-[slot=accordion-trigger-icon]:size-4 **:data-[slot=accordion-trigger-icon]:text-muted-foreground",e),...i,children:[n,o.jsx(mt,{"data-slot":"accordion-trigger-icon",className:"pointer-events-none shrink-0 group-aria-expanded/accordion-trigger:hidden"}),o.jsx(rn,{"data-slot":"accordion-trigger-icon",className:"pointer-events-none hidden shrink-0 group-aria-expanded/accordion-trigger:inline"})]})})}function Qs({className:e,children:n,...t}){return o.jsx(ri,{"data-slot":"accordion-content",className:"h-(--accordion-panel-height) overflow-hidden text-sm transition-[height] duration-150 ease-out data-ending-style:h-0 data-starting-style:h-0 motion-reduce:transition-none",...t,children:o.jsx("div",{className:N("pt-0 pb-2.5 [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground [&_p:not(:last-child)]:mb-4",e),children:n})})}const $e=x.lazy(()=>z(()=>import("./TaskSkew-BDr1DbeI.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8]),import.meta.url).then(e=>({default:e.TaskSkew}))),ot=x.lazy(()=>z(()=>import("./ShuffleIO--Rur3neu.js"),__vite__mapDeps([9,1,2,3,4,5,6,8,7]),import.meta.url).then(e=>({default:e.ShuffleIO}))),Rn=x.lazy(()=>z(()=>import("./Spill-DIMpt8c2.js"),__vite__mapDeps([10,1,2,3,4,5,6,8,7]),import.meta.url).then(e=>({default:e.Spill}))),jn=x.lazy(()=>z(()=>import("./GcPressure-CFXm4BnA.js"),__vite__mapDeps([11,1,2,3,4,5,6]),import.meta.url).then(e=>({default:e.GcPressure}))),Te=x.lazy(()=>z(()=>import("./Failures-Crngoicu.js"),__vite__mapDeps([12,1,2,3,4,5,6]),import.meta.url).then(e=>({default:e.Failures}))),ae=x.lazy(()=>z(()=>import("./ExecutorTimeline-DkaAGqQT.js"),__vite__mapDeps([13,1,2,3,4,5,6,8]),import.meta.url).then(e=>({default:e.ExecutorTimeline}))),rt=x.lazy(()=>z(()=>import("./MemoryUtilization-Bu2uQJbd.js"),__vite__mapDeps([14,1,2,3,4,5,6]),import.meta.url).then(e=>({default:e.MemoryUtilization}))),bn=x.lazy(()=>z(()=>import("./CachingOpportunity-DV2ABG2G.js"),__vite__mapDeps([15,1,2,3,4,5,6]),import.meta.url).then(e=>({default:e.CachingOpportunity}))),_n=x.lazy(()=>z(()=>import("./JobFailures-BmjxCA-h.js"),__vite__mapDeps([16,1,2,3,4,5,6]),import.meta.url).then(e=>({default:e.JobFailures}))),In=x.lazy(()=>z(()=>import("./ConfigAudit-DMiBhAoG.js"),__vite__mapDeps([17,1,2,3,4,5,6]),import.meta.url).then(e=>({default:e.ConfigAudit}))),le=x.lazy(()=>z(()=>import("./index-4id52G-A.js").then(e=>e.aI),__vite__mapDeps([2,1,3,4,5,6]),import.meta.url).then(e=>({default:e.PlanFindings}))),Fn=x.lazy(()=>z(()=>import("./CacheUtilization-BjyawXL6.js"),__vite__mapDeps([18,1,2,3,4,5,6]),import.meta.url).then(e=>({default:e.CacheUtilization}))),kn=x.lazy(()=>z(()=>import("./CoreUsageArea-CGYIgPnt.js"),__vite__mapDeps([19,1,2,3,4,5,6,8]),import.meta.url).then(e=>({default:e.CoreUsageArea}))),$n=x.lazy(()=>z(()=>import("./AutoscalingChurn-CP5OjN6v.js"),__vite__mapDeps([20,1,2,3,4,5,6,8]),import.meta.url).then(e=>({default:e.AutoscalingChurn}))),Tn=x.lazy(()=>z(()=>import("./IncompleteRun-BWEJTb13.js"),__vite__mapDeps([21,1,2,3,4,5,6]),import.meta.url).then(e=>({default:e.IncompleteRun})));function V(e,n){e.displayName=n}V($e,"TaskSkew");V(ot,"ShuffleIO");V(Rn,"Spill");V(jn,"GcPressure");V(Te,"Failures");V(ae,"ExecutorTimeline");V(rt,"MemoryUtilization");V(bn,"CachingOpportunity");V(_n,"JobFailures");V(In,"ConfigAudit");V(le,"PlanFindings");V(Fn,"CacheUtilization");V(kn,"CoreUsageArea");V($n,"AutoscalingChurn");V(Tn,"IncompleteRun");const K={incompleteRun:{component:Tn,region:"action",widgetId:"incomplete-run",widgetTitle:"Incomplete Run",findingLabel:"incomplete run",routeable:!0},skew:{component:$e,region:"action",widgetId:"task-skew",widgetTitle:"Task Skew & Shape",findingLabel:"task skew",routeable:!0},stageShape:{component:$e,region:"action",widgetId:"task-skew",widgetTitle:"Task Skew & Shape",findingLabel:"stage shape",routeable:!0},tinyTask:{component:$e,region:"action",widgetId:"task-skew",widgetTitle:"Task Skew & Shape",findingLabel:"tiny tasks",routeable:!0},shuffle:{component:ot,region:"action",widgetId:"shuffle-io",widgetTitle:"Shuffle I/O",findingLabel:"shuffle I/O",routeable:!0},partitionSizing:{component:ot,region:"action",widgetId:"shuffle-io",widgetTitle:"Shuffle I/O",findingLabel:"partition sizing",routeable:!0},spill:{component:Rn,region:"action",widgetId:"spill",widgetTitle:"Spill",findingLabel:"spill",routeable:!0},gc:{component:jn,region:"action",widgetId:"gc-pressure",widgetTitle:"GC Pressure",findingLabel:"GC pressure",routeable:!0},stageFailed:{component:Te,region:"action",widgetId:"failures",widgetTitle:"Failures",findingLabel:"failed stage",routeable:!0},failures:{component:Te,region:"action",widgetId:"failures",widgetTitle:"Failures",findingLabel:"failed tasks",routeable:!0},retryWaste:{component:Te,region:"action",widgetId:"failures",widgetTitle:"Failures",findingLabel:"retry waste",routeable:!0},slowHost:{component:ae,region:"action",widgetId:"executor-timeline",widgetTitle:"Executor Timeline",findingLabel:"slow executor host",routeable:!0},stageSlowness:{component:ae,region:"action",widgetId:"executor-timeline",widgetTitle:"Executor Timeline",findingLabel:"slow stage",routeable:!0},straggler:{component:ae,region:"action",widgetId:"executor-timeline",widgetTitle:"Executor Timeline",findingLabel:"straggling task",routeable:!0},speculationWaste:{component:ae,region:"action",widgetId:"executor-timeline",widgetTitle:"Executor Timeline",findingLabel:"speculation waste",routeable:!0},coldStart:{component:ae,region:"action",widgetId:"executor-timeline",widgetTitle:"Executor Timeline",findingLabel:"cold start",routeable:!0},memoryUtilization:{component:rt,region:"reference",widgetId:"memory-utilization",widgetTitle:"Memory Utilization",findingLabel:"memory utilization",routeable:!0},utilization:{component:rt,region:"reference",widgetId:"memory-utilization",widgetTitle:"Memory Utilization",findingLabel:"executor utilization",routeable:!0},coreLocality:{component:kn,region:"reference",widgetId:"core-usage-area",widgetTitle:"Core Usage by Locality",findingLabel:"core locality",routeable:!0},cachingOpportunity:{component:bn,region:"action",widgetId:"caching-opportunity",widgetTitle:"Caching Opportunities",findingLabel:"caching opportunity",routeable:!0},cacheUtilization:{component:Fn,region:"reference",widgetId:"cache-utilization",widgetTitle:"Cache Utilization",findingLabel:"cache utilization",routeable:!0},jobFailureRate:{component:_n,region:"action",widgetId:"job-failures",widgetTitle:"Job Failures",findingLabel:"job failure rate",routeable:!0},autoscalingChurn:{component:$n,region:"action",widgetId:"autoscaling-churn",widgetTitle:"Autoscaling Churn",findingLabel:"autoscaling churn",routeable:!0},configAudit:{component:In,region:"action",widgetId:"config-audit",widgetTitle:"Config Sanity",findingLabel:"config audit",routeable:!0},duplicatePlanSubtree:{component:le,region:"action",widgetId:"plan-findings",widgetTitle:"Plan Advisor",findingLabel:"duplicate plan subtree",routeable:!0},smallFiles:{component:le,region:"action",widgetId:"plan-findings",widgetTitle:"Plan Advisor",findingLabel:"small files",routeable:!0},broadcastSizing:{component:le,region:"reference",widgetId:"plan-findings",widgetTitle:"Plan Advisor",findingLabel:"broadcast sizing",routeable:!1},underBroadcast:{component:le,region:"action",widgetId:"plan-findings",widgetTitle:"Plan Advisor",findingLabel:"missed broadcast join",routeable:!0},overBroadcast:{component:le,region:"action",widgetId:"plan-findings",widgetTitle:"Plan Advisor",findingLabel:"oversized broadcast join",routeable:!0}},Bt={action:0,reference:1};function En(){const e=new Map;for(const n of hi){const t=K[n.type];if(!t)continue;const i=e.get(t.component);(!i||n.order<i.order)&&e.set(t.component,{region:t.region,order:n.order,widgetId:t.widgetId,widgetTitle:t.widgetTitle,findingLabel:t.findingLabel,type:n.type})}return[...e.entries()].sort(([,n],[,t])=>Bt[n.region]-Bt[t.region]||n.order-t.order).map(([n,{region:t,widgetId:i,widgetTitle:s,findingLabel:r,type:a}])=>({component:n,region:t,widgetId:i,widgetTitle:s,findingLabel:r,type:a}))}const Zs=new Set(["broadcastSizing","cacheUtilization"]);function yt(e){const n=K[e];return n!==void 0&&n.region==="reference"&&!Zs.has(e)}function eo(){const e=new Map;for(const[n,t]of Object.entries(K))yt(n)&&(e.has(t.component)||e.set(t.component,{component:t.component,widgetId:t.widgetId}));return[...e.values()]}function Ot(e){return e.length===0?e:e[0].toUpperCase()+e.slice(1)}function to({type:e,label:n,thresholdSummary:t}){return o.jsxs(U,{"data-testid":"clean-check-row","data-clean-check-type":e,children:[o.jsx(B,{className:"w-px",children:o.jsxs("span",{className:"inline-flex h-6 items-center gap-1 rounded-full bg-clean/10 px-2 font-mono text-xs font-medium whitespace-nowrap text-clean",children:[o.jsx(xi,{"aria-hidden":"true",className:"size-3.5 shrink-0"}),tn(e)]})}),o.jsxs(B,{className:"whitespace-normal",children:[o.jsx("span",{className:"block text-sm font-medium text-foreground",children:Ot(n)}),o.jsx("span",{className:"block text-xs text-muted-foreground",children:Ot(`measured against: ${t}.`)})]})]})}const no="suggested-improvements",io={skew:"per-stage",stageShape:"per-stage",tinyTask:"per-stage",shuffle:"per-stage",partitionSizing:"per-stage",spill:"per-stage",gc:"per-stage",stageFailed:"per-stage",failures:"per-stage",retryWaste:"per-stage",slowHost:"per-stage",stageSlowness:"per-stage",straggler:"per-stage",speculationWaste:"per-stage",incompleteRun:"app-level",coldStart:"app-level",memoryUtilization:"app-level",utilization:"app-level",coreLocality:"app-level",cachingOpportunity:"app-level",cacheUtilization:"app-level",jobFailureRate:"app-level",autoscalingChurn:"app-level",duplicatePlanSubtree:"sql-scope",smallFiles:"sql-scope",broadcastSizing:"sql-scope",underBroadcast:"sql-scope",overBroadcast:"sql-scope",configAudit:"config-scope"},so=["per-stage","app-level","sql-scope","config-scope"],oo={"per-stage":"Per-stage checks","app-level":"App-level checks","sql-scope":"SQL plan checks","config-scope":"Config checks"};function ro(e,n){const t=[...e,...n],i=new Map;for(const[r,a]of Object.entries(K))i.has(a.component)||i.set(a.component,new Set),i.get(a.component).add(r);return En().filter(({type:r})=>!yt(r)).map(({component:r,widgetId:a},l)=>{const u=i.get(r)??new Set,c=t.filter(g=>u.has(g.type));return{component:r,widgetId:a,index:l,findings:c,impactBand:wi(c)}}).filter(r=>r.impactBand!==void 0).sort((r,a)=>ee[r.impactBand]-ee[a.impactBand]||r.index-a.index)}function ao({appModel:e,catalog:n,configFindings:t=[],getTaskData:i,activeFileId:s}){const r=[...n,...t],a=Object.keys(K).filter(c=>!yt(c)).filter(c=>!r.some(g=>g.type===c)).map(c=>({type:c,findingLabel:K[c].findingLabel})),l=new Map;for(const c of a){const g=io[c.type]??"app-level";l.has(g)||l.set(g,[]),l.get(g).push(c)}const u=eo();return o.jsxs(o.Fragment,{children:[o.jsx(xt,{children:u.map(({component:c,widgetId:g})=>o.jsx(Z,{cardId:`reference-${g}`,widgetId:g,children:o.jsx(x.Suspense,{fallback:o.jsx(an,{}),children:o.jsx(c,{appModel:e,catalog:n,configFindings:t,getTaskData:i,activeFileId:s,defaultCollapsed:!0})})},g))}),o.jsx(Xs,{children:o.jsxs(Ys,{value:"clean-checks",children:[o.jsx(Js,{children:"Clean checks"}),o.jsxs(Qs,{children:[o.jsx("p",{className:"pb-2 text-xs text-muted-foreground",children:"Every check below passed. No fix needed."}),so.map(c=>{const g=l.get(c);return!g||g.length===0?null:o.jsxs("div",{className:"pt-3 first:pt-0",children:[o.jsx("p",{className:"pb-1 text-xs font-medium text-muted-foreground",children:oo[c]}),o.jsx(Ne,{children:o.jsx(Me,{children:g.map(({type:p,findingLabel:d})=>o.jsx(to,{type:p,label:d,thresholdSummary:Di(p)},p))})})]},c)})]})]})})]})}function De(e){return zi(e)??K[e.type]?.findingLabel??e.type}function Pn(e){const n=K[e.type],t=typeof e.recommendation=="string"?e.recommendation.trim():"";return!n?.routeable||!t?null:{finding:e,widgetId:n.widgetId,region:n.region,findingLabel:n.findingLabel,stageId:typeof e.stageId=="number"?e.stageId:null,recommendation:t}}function xe(e,n){return n.includes(e)?Pn(e):null}function Ht(e){return e.impactEstimate?.wallClock?.high??null}function lo(e){const n=new Map(En().map((i,s)=>[i.widgetId,s])),t=e.map((i,s)=>({target:Pn(i),catalogIndex:s})).filter(i=>i.target!==null);return t.sort((i,s)=>{const r=Ht(i.target.finding),a=Ht(s.target.finding);return r!==null&&a!==null&&r!==a?a-r:r!==null!=(a!==null)?r!==null?-1:1:(n.get(i.target.widgetId)??Number.MAX_SAFE_INTEGER)-(n.get(s.target.widgetId)??Number.MAX_SAFE_INTEGER)||i.catalogIndex-s.catalogIndex}),t[0]?.target??null}const be=10;function uo(e){return Bi(e)&&K[e.type]!=null}function co(e){return gn(e.findings)[0].impactBand}function Rt(e){const n=e.impactEstimate;return n?n.wallClock?ln(n.wallClock.low,n.wallClock.high):n.rawWaste?vi(n.rawWaste):null:null}const Ke=8;function go(e){return e.length<=Ke?e.join(", "):`${e.slice(0,Ke).join(", ")}, +${e.length-Ke} more`}function ze(e){const n=e.stageId!=null?`St.${e.stageId}`:e.stageIds&&e.stageIds.length>0?`St.${go(e.stageIds)}`:null;if(e.type==="duplicatePlanSubtree"&&e.rootName!=null){const t=Nn(e);return n&&t?`${n} · ${t}`:t??n}return n||(e.property?String(e.property):null)}function Nn(e){if(e.type!=="duplicatePlanSubtree"||e.rootName==null)return null;const n=Ri(e.rootName),t=e.groupIndex!=null?`${n} #${Number(e.groupIndex)+1}`:n;return e.executionId!=null?`${t} (SQL ${e.executionId})`:t}function Pe({finding:e,textClassName:n}){const{stageId:t,stageIds:i}=e;if(t!=null)return o.jsx(Si,{stageId:t});if(i&&i.length>0){const r=Nn(e);return o.jsxs("span",{className:"inline-flex min-w-0 flex-wrap items-center gap-1.5",children:[o.jsx(Ci,{pills:i.map(a=>({id:a}))}),r?o.jsx("span",{className:N("truncate",n),title:r,children:r}):null]})}const s=ze(e);return s?o.jsx("span",{className:N("min-w-0 truncate",n),title:s,children:s}):null}function Ve(e){const n=typeof e.recommendation=="string"?e.recommendation.trim():"";return n||(K[e.type]?.findingLabel??e.type)}function fo({finding:e,allFindings:n,onRoute:t}){const i=xe(e,n),s=ze(e),r=Rt(e),a=Ve(e),l=De(e);return o.jsxs(U,{"data-testid":"fix-these-first-row","data-finding-type":e.type,children:[o.jsx(B,{className:"w-px",children:o.jsx(pe,{type:e.type,impactBand:e.impactBand})}),o.jsx(B,{className:"whitespace-normal",children:o.jsxs("button",{type:"button",className:"text-left focus-visible:outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 rounded-sm",onClick:()=>i&&t(i),children:[o.jsx("span",{className:"block text-sm font-medium",children:l}),o.jsx("span",{className:"block text-xs text-muted-foreground",children:a})]})}),o.jsx(B,{className:"w-px text-right font-mono text-xs text-muted-foreground",title:[s,r].filter(Boolean).join(" · "),children:o.jsxs("span",{className:"flex items-center justify-end gap-1.5",children:[o.jsx(Pe,{finding:e}),r?o.jsx("span",{className:"shrink-0",children:r}):null]})})]})}function mo({finding:e,allFindings:n,onRoute:t,id:i}){const s=xe(e,n),r=ze(e),a=Rt(e),l=Ve(e),u=De(e),c=e.stageId!=null||r!=null;return o.jsxs(U,{id:i,"data-testid":"fix-these-first-row","data-finding-type":e.type,className:"bg-muted/50",children:[o.jsxs(B,{colSpan:2,className:"whitespace-normal",children:[c?o.jsx("div",{className:"mb-1",children:o.jsx(Pe,{finding:e,textClassName:"line-clamp-1 break-words text-xs font-medium font-mono"})}):null,o.jsxs("button",{type:"button",className:"block w-full text-left focus-visible:outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 rounded-sm",onClick:()=>s&&t(s),children:[c?null:o.jsx("span",{className:"line-clamp-1 break-words text-xs font-medium",children:u}),o.jsx("span",{className:"line-clamp-1 break-words text-xs text-muted-foreground",children:l})]})]}),o.jsx(B,{className:"w-px text-right font-mono text-xs text-muted-foreground",children:a})]})}function po(e){return e.kind==="time"?`×${e.findingCount} · ${ln(e.recoverableMsHigh,e.recoverableMsHigh)} recoverable`:e.kind==="resource"?`×${e.findingCount} · resource-cost projection`:Object.entries(e.byImpactBand).map(([n,t])=>`${t} ${n}`).join(", ")}function ho({group:e,allFindings:n,expanded:t,onToggle:i,onRoute:s}){const[r,a]=x.useState(0),l=gn(e.findings),u=l[0],c=Ve(u),g=De(u),p=Math.ceil(l.length/be),d=Math.min(r,Math.max(0,p-1)),f=l.slice(d*be,d*be+be),h=`fix-these-first-group-content-${e.kind}-${e.type}${"unit"in e?`-${e.unit}`:""}`;return o.jsxs(o.Fragment,{children:[o.jsxs(U,{"data-testid":"fix-these-first-group-row","data-finding-type":e.type,children:[o.jsx(B,{className:"w-px",children:o.jsx(pe,{type:e.type,impactBand:u.impactBand})}),o.jsx(B,{className:"whitespace-normal",children:o.jsxs("button",{type:"button","aria-expanded":t,"aria-controls":h,className:"text-left focus-visible:outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 rounded-sm",onClick:i,children:[o.jsx("span",{className:"block text-sm font-medium",children:g}),o.jsx("span",{className:"block text-xs text-muted-foreground",children:c})]})}),o.jsx(B,{className:"w-px text-right font-mono text-xs text-muted-foreground",children:o.jsxs("span",{className:"inline-flex items-center justify-end gap-1.5",children:[po(e),t?o.jsx(rn,{"aria-hidden":"true",className:"size-4 shrink-0 text-muted-foreground"}):o.jsx(mt,{"aria-hidden":"true",className:"size-4 shrink-0 text-muted-foreground"})]})})]}),t&&f.map((m,v)=>o.jsx(mo,{finding:m,allFindings:n,onRoute:s,id:v===0?h:void 0},m.id)),t&&p>1&&o.jsx(U,{className:"bg-muted/50",children:o.jsx(B,{colSpan:3,children:o.jsx(yi,{page:d,totalPages:p,onPrev:()=>a(m=>m-1),onNext:()=>a(m=>m+1)})})})]})}function xo({target:e,onRoute:n}){const t=ze(e.finding),i=Rt(e.finding),s=e.finding.stageId!=null||t!=null;return o.jsxs("div",{className:"rounded-lg border border-primary/40 bg-primary/5 px-4 py-3",children:[o.jsx("p",{className:"text-xs font-medium text-primary",children:"This is the highest-impact actionable finding."}),o.jsxs("div",{className:"mt-1 flex items-start justify-between gap-4",children:[o.jsxs("button",{type:"button",className:"min-w-0 flex-1 text-left focus-visible:outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 rounded-sm",onClick:()=>n(e),children:[o.jsx("span",{className:"text-sm font-semibold underline-offset-4 hover:underline",children:De(e.finding)}),o.jsxs("span",{className:"text-sm text-muted-foreground",children:[" — ",Ve(e.finding)]})]}),i?o.jsxs("div",{className:"shrink-0 text-right",children:[o.jsx("p",{className:"text-[11px] uppercase tracking-wide text-muted-foreground",children:"Potential savings"}),o.jsx("p",{className:"whitespace-nowrap font-mono text-lg font-semibold leading-tight tabular-nums text-primary",children:i}),s?o.jsx("div",{className:"mt-1 flex justify-end",children:o.jsx(Pe,{finding:e.finding,textClassName:"line-clamp-2 max-w-[140px] break-words text-[11px] text-muted-foreground"})}):null]}):s?o.jsx(Pe,{finding:e.finding,textClassName:"line-clamp-2 max-w-[140px] shrink-0 break-words text-[11px] text-muted-foreground"}):null]})]})}function wo(e,n,t){const s=[...e,...n].filter(uo),r=Vi(s,t),a=lo(s);return{eligible:s,groups:r,triageTarget:a}}const Mn={critical:"Critical",warning:"Warning",info:"Info"},Gt=["critical","warning","info"];function vo(e){return`${e.kind}-${e.type}-${"unit"in e?e.unit:""}`}const So=96;function Co(e){const n=e.join("|"),[t,i]=x.useState(e[0]??null);return x.useEffect(()=>{if(e.length===0)return;let s=0;function r(){s=0;let l=e[0];for(const c of e){const g=document.getElementById(c);g&&g.getBoundingClientRect().top<=So&&(l=c)}window.innerHeight+window.scrollY>=document.documentElement.scrollHeight-1&&(l=e[e.length-1]),i(l)}function a(){s||(s=requestAnimationFrame(r))}return r(),window.addEventListener("scroll",a,{passive:!0}),window.addEventListener("resize",a),()=>{s&&cancelAnimationFrame(s),window.removeEventListener("scroll",a),window.removeEventListener("resize",a)}},[n]),t}function yo(e){const n=document.getElementById(e);if(!n)return;const t=window.matchMedia("(prefers-reduced-motion: reduce)").matches;n.scrollIntoView({behavior:t?"auto":"smooth",block:"start",inline:"nearest"})}function Ro({items:e}){const n=e.map(i=>`impact-band-${i.impactBand}-heading`),t=Co(n);return e.length<2?null:o.jsx("nav",{"aria-label":"Jump to impact band",className:"sticky top-0 z-10 flex items-center gap-1 rounded-lg border border-border bg-background/95 px-2 py-1.5 backdrop-blur",children:e.map((i,s)=>{const r=n[s],a=t===r;return o.jsxs("a",{href:`#${r}`,"aria-current":a?"location":void 0,onClick:l=>{l.metaKey||l.ctrlKey||l.shiftKey||l.altKey||l.button!==0||(l.preventDefault(),yo(r))},className:N("inline-flex items-center gap-1.5 rounded-md px-2 py-1 text-xs font-medium transition-colors",a?"text-primary":"text-muted-foreground hover:text-foreground"),children:[o.jsx(ue,{impactBand:i.impactBand}),Mn[i.impactBand]," (",i.count,")"]},i.impactBand)})})}function jo({impactBand:e,groups:n,widgets:t,allFindings:i,expandedGroupKey:s,onToggleGroup:r,onRoute:a,appModel:l,catalog:u,configFindings:c,getTaskData:g,activeFileId:p}){if(n.length===0&&t.length===0)return null;const d=`impact-band-${e}-heading`;return o.jsxs("section",{"aria-labelledby":d,className:"space-y-3",children:[o.jsx("h2",{id:d,className:"scroll-mt-16 font-heading text-base font-semibold",children:Mn[e]}),n.length>0&&o.jsx(Ne,{children:o.jsx(Me,{children:n.map(f=>{if(f.findingCount===1)return o.jsx(fo,{finding:f.findings[0],allFindings:i,onRoute:a},f.findings[0].id);const h=vo(f);return o.jsx(ho,{group:f,allFindings:i,expanded:s===h,onToggle:()=>r(h),onRoute:a},h)})})}),t.length>0&&o.jsx(xt,{children:t.map(({component:f,widgetId:h,index:m})=>o.jsx(Z,{cardId:`alert-${m}`,widgetId:h,children:o.jsx(x.Suspense,{fallback:o.jsx(an,{}),children:o.jsx(f,{appModel:l,catalog:u,configFindings:c,getTaskData:g,activeFileId:p,defaultCollapsed:!0})})},h))})]})}function bo({appModel:e,catalog:n,configFindings:t=[],stages:i,getTaskData:s,activeFileId:r,onRoute:a}){const{eligible:l,groups:u,triageTarget:c}=x.useMemo(()=>wo(n,t,i),[n,t,i]),g=[...n,...t],p=x.useMemo(()=>ro(n,t),[n,t]),[d,f]=x.useState(null),{groupsByImpactBand:h,widgetsByImpactBand:m}=x.useMemo(()=>{const S=new Map;for(const C of u){const k=co(C);S.has(k)||S.set(k,[]),S.get(k).push(C)}const j=new Map;for(const C of p)j.has(C.impactBand)||j.set(C.impactBand,[]),j.get(C.impactBand).push(C);return{groupsByImpactBand:S,widgetsByImpactBand:j}},[u,p]),v=Gt.flatMap(S=>{const j=h.get(S)??[],C=m.get(S)??[];if(j.length===0&&C.length===0)return[];const k=new Set;for(const T of j)for(const P of T.findings)k.add(P);for(const T of C)for(const P of T.findings)k.add(P);return[{impactBand:S,count:k.size}]});return o.jsxs("div",{id:no,className:"space-y-6 scroll-mt-20",children:[o.jsx(Ro,{items:v}),c?o.jsx(xo,{target:c,onRoute:a}):null,l.length===0?o.jsx("p",{className:"text-sm text-muted-foreground",children:"No findings to fix right now."}):null,Gt.map(S=>o.jsx(jo,{impactBand:S,groups:h.get(S)??[],widgets:m.get(S)??[],allFindings:g,expandedGroupKey:d,onToggleGroup:j=>f(C=>C===j?null:j),onRoute:a,appModel:e,catalog:n,configFindings:t,getTaskData:s,activeFileId:r},S)),o.jsx(ao,{appModel:e,catalog:n,configFindings:t,getTaskData:s,activeFileId:r})]})}const _o=5,Io=30,Fo=220;function qt(e,n){if(e.length<2)return e[0]??null;const t=e[1]-e[0],i=Math.round((n-e[0])/t);return e[Math.min(e.length-1,Math.max(0,i))]}function ko({metrics:e,fieldNames:n,markers:t={}}){const i=n.indexOf("duration");if(i===-1)return null;const s=n.length,r=e.length/s,a=[];for(let m=0;m<r;m++)a.push(e[m*s+i]);if(a.length<_o)return o.jsxs("p",{className:"text-muted-foreground text-xs",children:["Too few tasks (",a.length,") for a distribution."]});const{labels:l,data:u}=ji(a,Io),c=l[1]-l[0],g=l.map((m,v)=>({bin:`${(m/1e3).toFixed(1)}s`,range:`${(m/1e3).toFixed(1)}s – ${((m+c)/1e3).toFixed(1)}s`,ms:m,count:u[v]})),p=t.p50!=null?qt(l,t.p50):null,d=t.p95!=null?qt(l,t.p95):null,f=p!=null?g.find(m=>m.ms===p)?.bin:void 0,h=d!=null?g.find(m=>m.ms===d)?.bin:void 0;return o.jsx(ye,{title:"Task duration",ariaLabel:"Task duration histogram",height:Fo,table:{caption:"Task duration histogram",columns:["Duration bin","Task count"],rows:g.map(m=>[m.range,m.count]),align:["right","right"]},children:o.jsxs(Ae,{data:g,children:[o.jsx(ve,{vertical:!1,stroke:M.muted,strokeOpacity:.2}),o.jsx(Se,{dataKey:"bin",tick:{fontSize:10}}),o.jsx(Ce,{allowDecimals:!1,tick:{fontSize:10},width:32}),o.jsx(Le,{formatter:m=>[`${Number(m)} task${Number(m)===1?"":"s"}`,"Count"],labelFormatter:(m,v)=>v?.[0]?.payload?.range??m}),o.jsx(ce,{dataKey:"count",name:"Tasks",fill:M.accent}),f?o.jsx(Pt,{x:f,stroke:M.accent,label:"P50"}):null,h?o.jsx(Pt,{x:h,stroke:M.warning,label:"P95"}):null]})})}const Wt=["PROCESS_LOCAL","NODE_LOCAL","RACK_LOCAL","NO_PREF","ANY"],Ut=[M.clean,M.accent,M.warning,M.muted,M.critical];function Kt(e){return e?new Date(e).toLocaleString():"—"}function $o({stats:e}){const n=new Map(e.map(s=>[s.locality,s.count])),t=Wt.filter(s=>n.has(s));for(const s of e)Wt.includes(s.locality)||t.push(s.locality);const i=t.map((s,r)=>({locality:s,count:n.get(s)??0,color:Ut[Math.min(r,Ut.length-1)]}));return o.jsx(ye,{ariaLabel:"Task locality distribution",height:140,table:{caption:"Task locality distribution",columns:["Locality tier","Task count"],rows:i.map(s=>[s.locality,s.count]),align:["left","right"]},children:o.jsxs(Ae,{data:i,children:[o.jsx(ve,{vertical:!1,stroke:M.muted,strokeOpacity:.2}),o.jsx(Se,{dataKey:"locality",tick:{fontSize:10}}),o.jsx(Ce,{allowDecimals:!1,tick:{fontSize:10},width:32}),o.jsx(Le,{formatter:s=>[`${Number(s)} task${Number(s)===1?"":"s"}`,"Tasks"]}),o.jsx(ce,{dataKey:"count",name:"Tasks",children:i.map(s=>o.jsx(mn,{fill:s.color},s.locality))})]})})}function To(e){const n=new Map;for(const t of e){n.has(t.type)||n.set(t.type,{impactBand:t.impactBand,finding:t,recs:new Map});const i=n.get(t.type);ee[t.impactBand]<ee[i.impactBand]&&(i.impactBand=t.impactBand,i.finding=t),t.recommendation&&!i.recs.has(t.recommendation)&&i.recs.set(t.recommendation,{extended:t.extended??null,docAnchor:t.docAnchor??null})}return[...n.entries()].sort(([,t],[,i])=>ee[t.impactBand]-ee[i.impactBand])}function Eo({rec:e,docAnchor:n,extended:t,finding:i,showImpactEstimate:s}){const[r,a]=x.useState(!1);return o.jsxs("div",{className:"space-y-1 text-sm",children:[o.jsxs("p",{className:"max-w-full leading-normal break-words",children:[e,n?o.jsxs(o.Fragment,{children:[" ",o.jsx(pt,{anchor:n,children:"Learn more →"})]}):null]}),t||s?o.jsxs("details",{open:r,onToggle:l=>a(l.target.open),children:[o.jsx("summary",{className:"cursor-pointer text-xs text-muted-foreground",children:"more"}),t?o.jsx("p",{className:"text-xs text-muted-foreground",children:t}):null,s&&r?o.jsx(bi,{finding:i}):null]}):null]})}function Po({findings:e}){if(e.length===0)return null;const n=To(e);return o.jsx("section",{className:"space-y-3 rounded-md border p-3",children:n.map(([t,{impactBand:i,finding:s,recs:r}])=>{const a=un(s.impactEstimate);return o.jsxs("div",{className:"space-y-1",children:[o.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[o.jsx(pe,{type:t,impactBand:i}),a?o.jsx("span",{className:"text-xs text-muted-foreground",children:a}):null]}),[...r.entries()].map(([l,{extended:u,docAnchor:c}],g)=>o.jsx(Eo,{rec:l,docAnchor:c,extended:u,finding:s,showImpactEstimate:g===0&&a!==null},g))]},t)})})}function No({stage:e,appModel:n}){return Wi(e.id,n)?o.jsxs("section",{className:"space-y-2",children:[o.jsx("h3",{className:"font-heading text-sm font-medium",children:"Query Plan"}),o.jsx(Ui,{stageId:e.id,appModel:n})]}):null}function Mo({stage:e,appModel:n,catalog:t,getTaskData:i}){const[s,r]=x.useState(null),[a,l]=x.useState(!1),[u,c]=x.useState(0),g=(e.taskCount??0)>0,p=t.filter(C=>C.stageId===e.id);x.useEffect(()=>{if(!g)return;let C=!1;return l(!1),i(e.id).catch(()=>null).then(k=>{C||(k?r(k):l(!0))}),()=>{C=!0}},[u]);const d=(e.completedAt??0)-(e.submittedAt??0),f=(e.memoryBytesSpilled??0)>0||(e.diskBytesSpilled??0)>0,h=(e.jvmGCTime??0)>0||(e.gcPct??0)>0,m=e.fetchWaitTime??0,v=m>0&&d>0?Math.round(m/d*100):null,S=(e.inputBytes??0)>0?((e.outputBytes??0)/(e.inputBytes??0)).toFixed(2):null,j=e.localityStats??[];return o.jsxs("div",{className:"space-y-4",children:[o.jsx(Po,{findings:p}),o.jsx(oe,{title:"Timing",rows:[["Duration",F(d)],["Submitted",Kt(e.submittedAt)],["Completed",Kt(e.completedAt)],e.sqlExecutionId!=null&&["SQL Execution",`#${e.sqlExecutionId}`],e.stageType?["Stage type",e.stageType]:!1]}),o.jsx(oe,{title:"Tasks",rows:[["Total",String(e.taskCount)],["Failed",String(e.failedTasks)],["P50 duration",(e.taskDurationP50??0)>0?F(e.taskDurationP50):"—"],["P95 duration",(e.taskDurationP95??0)>0?F(e.taskDurationP95):"—"],["Max duration",(e.taskDurationMax??0)>0?F(e.taskDurationMax):"—"],(e.peakExecutionMemoryMax??0)>0&&["Peak execution memory",Y(e.peakExecutionMemoryMax)]],children:g?s?o.jsx(ko,{metrics:s.metrics,fieldNames:s.fieldNames,markers:{p50:e.taskDurationP50,p95:e.taskDurationP95}}):a?o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("p",{className:"text-xs text-muted-foreground",children:"Couldn’t load task data for this stage."}),o.jsx(ke,{type:"button",variant:"ghost",size:"sm",onClick:()=>c(C=>C+1),children:"Retry"})]}):o.jsx("p",{className:"text-xs text-muted-foreground",children:"Loading task data…"}):null}),o.jsx(oe,{title:"Locality",rows:j.map(C=>[C.locality,String(C.count)]),children:j.length>0?o.jsx($o,{stats:j}):null}),o.jsx(oe,{title:"I/O",rows:[["Input",Y(e.inputBytes)],["Output",Y(e.outputBytes)],["Shuffle read",Y(e.shuffleReadBytes)],["Shuffle write",Y(e.shuffleWriteBytes)],m>0&&["Fetch wait",`${F(m)}${v!=null?` (${v}%)`:""}`],S!=null&&["I/O ratio",S]]}),f?o.jsx(oe,{title:"Spill",rows:[["Memory spilled",Y(e.memoryBytesSpilled)],["Disk spilled",Y(e.diskBytesSpilled)],(e.memoryBytesSpilled??0)>0&&["Classification",e.spillClassification??"unclassified"]]}):null,h?o.jsx(oe,{title:"GC",rows:[["JVM GC time",F(e.jvmGCTime)],["Executor run time",F(e.executorRunTime)],["GC %",`${(e.gcPct??0).toFixed(1)}%`]]}):null,e.details?o.jsxs("details",{className:"space-y-2",children:[o.jsx("summary",{className:"cursor-pointer font-heading text-sm font-medium",children:"Call Stack"}),o.jsx("pre",{className:"overflow-x-auto rounded-md bg-muted p-2 text-xs whitespace-pre-wrap",children:e.details})]}):null,o.jsx(No,{stage:e,appModel:n})]})}function Ao({appModel:e,catalog:n,getTaskData:t}){const{stageId:i,close:s}=wt(),r=i!=null?e.stages.get(i):void 0,a=r!=null;return o.jsx(Oi,{open:a,onOpenChange:l=>{l||s()},children:o.jsx(Hi,{className:"max-h-[85vh] overflow-y-auto sm:max-w-2xl",children:r?o.jsxs(o.Fragment,{children:[o.jsx(Gi,{children:o.jsxs(qi,{children:["Stage ",r.id," ",o.jsxs("span",{className:"text-muted-foreground",children:["— ",r.name??""]})]})}),o.jsx(Mo,{stage:r,appModel:e,catalog:n,getTaskData:t},r.id)]}):null})})}function te(e,n){return typeof e=="function"?e(n):e}function H(e,n){return t=>{n.setState(i=>({...i,[e]:te(t,i[e])}))}}function Be(e){return e instanceof Function}function Lo(e){return Array.isArray(e)&&e.every(n=>typeof n=="number")}function Do(e,n){const t=[],i=s=>{s.forEach(r=>{t.push(r);const a=n(r);a!=null&&a.length&&i(a)})};return i(e),t}function y(e,n,t){let i=[],s;return r=>{let a;t.key&&t.debug&&(a=Date.now());const l=e(r);if(!(l.length!==i.length||l.some((g,p)=>i[p]!==g)))return s;i=l;let c;if(t.key&&t.debug&&(c=Date.now()),s=n(...l),t==null||t.onChange==null||t.onChange(s),t.key&&t.debug&&t!=null&&t.debug()){const g=Math.round((Date.now()-a)*100)/100,p=Math.round((Date.now()-c)*100)/100,d=p/16,f=(h,m)=>{for(h=String(h);h.length<m;)h=" "+h;return h};console.info(`%c⏱ ${f(p,5)} /${f(g,5)} ms`,`
|
|
10
|
+
font-size: .6rem;
|
|
11
|
+
font-weight: bold;
|
|
12
|
+
color: hsl(${Math.max(0,Math.min(120-120*d,120))}deg 100% 31%);`,t?.key)}return s}}function R(e,n,t,i){return{debug:()=>{var s;return(s=e?.debugAll)!=null?s:e[n]},key:!1,onChange:i}}function zo(e,n,t,i){const s=()=>{var a;return(a=r.getValue())!=null?a:e.options.renderFallbackValue},r={id:`${n.id}_${t.id}`,row:n,column:t,getValue:()=>n.getValue(i),renderValue:s,getContext:y(()=>[e,t,n,r],(a,l,u,c)=>({table:a,column:l,row:u,cell:c,getValue:c.getValue,renderValue:c.renderValue}),R(e.options,"debugCells"))};return e._features.forEach(a=>{a.createCell==null||a.createCell(r,t,n,e)},{}),r}function Vo(e,n,t,i){var s,r;const l={...e._getDefaultColumnDef(),...n},u=l.accessorKey;let c=(s=(r=l.id)!=null?r:u?typeof String.prototype.replaceAll=="function"?u.replaceAll(".","_"):u.replace(/\./g,"_"):void 0)!=null?s:typeof l.header=="string"?l.header:void 0,g;if(l.accessorFn?g=l.accessorFn:u&&(u.includes(".")?g=d=>{let f=d;for(const m of u.split(".")){var h;f=(h=f)==null?void 0:h[m]}return f}:g=d=>d[l.accessorKey]),!c)throw new Error;let p={id:`${String(c)}`,accessorFn:g,parent:i,depth:t,columnDef:l,columns:[],getFlatColumns:y(()=>[!0],()=>{var d;return[p,...(d=p.columns)==null?void 0:d.flatMap(f=>f.getFlatColumns())]},R(e.options,"debugColumns")),getLeafColumns:y(()=>[e._getOrderColumnsFn()],d=>{var f;if((f=p.columns)!=null&&f.length){let h=p.columns.flatMap(m=>m.getLeafColumns());return d(h)}return[p]},R(e.options,"debugColumns"))};for(const d of e._features)d.createColumn==null||d.createColumn(p,e);return p}const L="debugHeaders";function Xt(e,n,t){var i;let r={id:(i=t.id)!=null?i:n.id,column:n,index:t.index,isPlaceholder:!!t.isPlaceholder,placeholderId:t.placeholderId,depth:t.depth,subHeaders:[],colSpan:0,rowSpan:0,headerGroup:null,getLeafHeaders:()=>{const a=[],l=u=>{u.subHeaders&&u.subHeaders.length&&u.subHeaders.map(l),a.push(u)};return l(r),a},getContext:()=>({table:e,header:r,column:n})};return e._features.forEach(a=>{a.createHeader==null||a.createHeader(r,e)}),r}const Bo={createTable:e=>{e.getHeaderGroups=y(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(n,t,i,s)=>{var r,a;const l=(r=i?.map(p=>t.find(d=>d.id===p)).filter(Boolean))!=null?r:[],u=(a=s?.map(p=>t.find(d=>d.id===p)).filter(Boolean))!=null?a:[],c=t.filter(p=>!(i!=null&&i.includes(p.id))&&!(s!=null&&s.includes(p.id)));return _e(n,[...l,...c,...u],e)},R(e.options,L)),e.getCenterHeaderGroups=y(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(n,t,i,s)=>(t=t.filter(r=>!(i!=null&&i.includes(r.id))&&!(s!=null&&s.includes(r.id))),_e(n,t,e,"center")),R(e.options,L)),e.getLeftHeaderGroups=y(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left],(n,t,i)=>{var s;const r=(s=i?.map(a=>t.find(l=>l.id===a)).filter(Boolean))!=null?s:[];return _e(n,r,e,"left")},R(e.options,L)),e.getRightHeaderGroups=y(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.right],(n,t,i)=>{var s;const r=(s=i?.map(a=>t.find(l=>l.id===a)).filter(Boolean))!=null?s:[];return _e(n,r,e,"right")},R(e.options,L)),e.getFooterGroups=y(()=>[e.getHeaderGroups()],n=>[...n].reverse(),R(e.options,L)),e.getLeftFooterGroups=y(()=>[e.getLeftHeaderGroups()],n=>[...n].reverse(),R(e.options,L)),e.getCenterFooterGroups=y(()=>[e.getCenterHeaderGroups()],n=>[...n].reverse(),R(e.options,L)),e.getRightFooterGroups=y(()=>[e.getRightHeaderGroups()],n=>[...n].reverse(),R(e.options,L)),e.getFlatHeaders=y(()=>[e.getHeaderGroups()],n=>n.map(t=>t.headers).flat(),R(e.options,L)),e.getLeftFlatHeaders=y(()=>[e.getLeftHeaderGroups()],n=>n.map(t=>t.headers).flat(),R(e.options,L)),e.getCenterFlatHeaders=y(()=>[e.getCenterHeaderGroups()],n=>n.map(t=>t.headers).flat(),R(e.options,L)),e.getRightFlatHeaders=y(()=>[e.getRightHeaderGroups()],n=>n.map(t=>t.headers).flat(),R(e.options,L)),e.getCenterLeafHeaders=y(()=>[e.getCenterFlatHeaders()],n=>n.filter(t=>{var i;return!((i=t.subHeaders)!=null&&i.length)}),R(e.options,L)),e.getLeftLeafHeaders=y(()=>[e.getLeftFlatHeaders()],n=>n.filter(t=>{var i;return!((i=t.subHeaders)!=null&&i.length)}),R(e.options,L)),e.getRightLeafHeaders=y(()=>[e.getRightFlatHeaders()],n=>n.filter(t=>{var i;return!((i=t.subHeaders)!=null&&i.length)}),R(e.options,L)),e.getLeafHeaders=y(()=>[e.getLeftHeaderGroups(),e.getCenterHeaderGroups(),e.getRightHeaderGroups()],(n,t,i)=>{var s,r,a,l,u,c;return[...(s=(r=n[0])==null?void 0:r.headers)!=null?s:[],...(a=(l=t[0])==null?void 0:l.headers)!=null?a:[],...(u=(c=i[0])==null?void 0:c.headers)!=null?u:[]].map(g=>g.getLeafHeaders()).flat()},R(e.options,L))}};function _e(e,n,t,i){var s,r;let a=0;const l=function(d,f){f===void 0&&(f=1),a=Math.max(a,f),d.filter(h=>h.getIsVisible()).forEach(h=>{var m;(m=h.columns)!=null&&m.length&&l(h.columns,f+1)},0)};l(e);let u=[];const c=(d,f)=>{const h={depth:f,id:[i,`${f}`].filter(Boolean).join("_"),headers:[]},m=[];d.forEach(v=>{const S=[...m].reverse()[0],j=v.column.depth===h.depth;let C,k=!1;if(j&&v.column.parent?C=v.column.parent:(C=v.column,k=!0),S&&S?.column===C)S.subHeaders.push(v);else{const T=Xt(t,C,{id:[i,f,C.id,v?.id].filter(Boolean).join("_"),isPlaceholder:k,placeholderId:k?`${m.filter(P=>P.column===C).length}`:void 0,depth:f,index:m.length});T.subHeaders.push(v),m.push(T)}h.headers.push(v),v.headerGroup=h}),u.push(h),f>0&&c(m,f-1)},g=n.map((d,f)=>Xt(t,d,{depth:a,index:f}));c(g,a-1),u.reverse();const p=d=>d.filter(h=>h.column.getIsVisible()).map(h=>{let m=0,v=0,S=[0];h.subHeaders&&h.subHeaders.length?(S=[],p(h.subHeaders).forEach(C=>{let{colSpan:k,rowSpan:T}=C;m+=k,S.push(T)})):m=1;const j=Math.min(...S);return v=v+j,h.colSpan=m,h.rowSpan=v,{colSpan:m,rowSpan:v}});return p((s=(r=u[0])==null?void 0:r.headers)!=null?s:[]),u}const Oo=(e,n,t,i,s,r,a)=>{let l={id:n,index:i,original:t,depth:s,parentId:a,_valuesCache:{},_uniqueValuesCache:{},getValue:u=>{if(l._valuesCache.hasOwnProperty(u))return l._valuesCache[u];const c=e.getColumn(u);if(c!=null&&c.accessorFn)return l._valuesCache[u]=c.accessorFn(l.original,i),l._valuesCache[u]},getUniqueValues:u=>{if(l._uniqueValuesCache.hasOwnProperty(u))return l._uniqueValuesCache[u];const c=e.getColumn(u);if(c!=null&&c.accessorFn)return c.columnDef.getUniqueValues?(l._uniqueValuesCache[u]=c.columnDef.getUniqueValues(l.original,i),l._uniqueValuesCache[u]):(l._uniqueValuesCache[u]=[l.getValue(u)],l._uniqueValuesCache[u])},renderValue:u=>{var c;return(c=l.getValue(u))!=null?c:e.options.renderFallbackValue},subRows:[],getLeafRows:()=>Do(l.subRows,u=>u.subRows),getParentRow:()=>l.parentId?e.getRow(l.parentId,!0):void 0,getParentRows:()=>{let u=[],c=l;for(;;){const g=c.getParentRow();if(!g)break;u.push(g),c=g}return u.reverse()},getAllCells:y(()=>[e.getAllLeafColumns()],u=>u.map(c=>zo(e,l,c,c.id)),R(e.options,"debugRows")),_getAllCellsByColumnId:y(()=>[l.getAllCells()],u=>u.reduce((c,g)=>(c[g.column.id]=g,c),{}),R(e.options,"debugRows"))};for(let u=0;u<e._features.length;u++){const c=e._features[u];c==null||c.createRow==null||c.createRow(l,e)}return l},Ho={createColumn:(e,n)=>{e._getFacetedRowModel=n.options.getFacetedRowModel&&n.options.getFacetedRowModel(n,e.id),e.getFacetedRowModel=()=>e._getFacetedRowModel?e._getFacetedRowModel():n.getPreFilteredRowModel(),e._getFacetedUniqueValues=n.options.getFacetedUniqueValues&&n.options.getFacetedUniqueValues(n,e.id),e.getFacetedUniqueValues=()=>e._getFacetedUniqueValues?e._getFacetedUniqueValues():new Map,e._getFacetedMinMaxValues=n.options.getFacetedMinMaxValues&&n.options.getFacetedMinMaxValues(n,e.id),e.getFacetedMinMaxValues=()=>{if(e._getFacetedMinMaxValues)return e._getFacetedMinMaxValues()}}},An=(e,n,t)=>{var i,s;const r=t==null||(i=t.toString())==null?void 0:i.toLowerCase();return!!(!((s=e.getValue(n))==null||(s=s.toString())==null||(s=s.toLowerCase())==null)&&s.includes(r))};An.autoRemove=e=>q(e);const Ln=(e,n,t)=>{var i;return!!(!((i=e.getValue(n))==null||(i=i.toString())==null)&&i.includes(t))};Ln.autoRemove=e=>q(e);const Dn=(e,n,t)=>{var i;return((i=e.getValue(n))==null||(i=i.toString())==null?void 0:i.toLowerCase())===t?.toLowerCase()};Dn.autoRemove=e=>q(e);const zn=(e,n,t)=>{var i;return(i=e.getValue(n))==null?void 0:i.includes(t)};zn.autoRemove=e=>q(e);const Vn=(e,n,t)=>!t.some(i=>{var s;return!((s=e.getValue(n))!=null&&s.includes(i))});Vn.autoRemove=e=>q(e)||!(e!=null&&e.length);const Bn=(e,n,t)=>t.some(i=>{var s;return(s=e.getValue(n))==null?void 0:s.includes(i)});Bn.autoRemove=e=>q(e)||!(e!=null&&e.length);const On=(e,n,t)=>e.getValue(n)===t;On.autoRemove=e=>q(e);const Hn=(e,n,t)=>e.getValue(n)==t;Hn.autoRemove=e=>q(e);const jt=(e,n,t)=>{let[i,s]=t;const r=e.getValue(n);return r>=i&&r<=s};jt.resolveFilterValue=e=>{let[n,t]=e,i=typeof n!="number"?parseFloat(n):n,s=typeof t!="number"?parseFloat(t):t,r=n===null||Number.isNaN(i)?-1/0:i,a=t===null||Number.isNaN(s)?1/0:s;if(r>a){const l=r;r=a,a=l}return[r,a]};jt.autoRemove=e=>q(e)||q(e[0])&&q(e[1]);const J={includesString:An,includesStringSensitive:Ln,equalsString:Dn,arrIncludes:zn,arrIncludesAll:Vn,arrIncludesSome:Bn,equals:On,weakEquals:Hn,inNumberRange:jt};function q(e){return e==null||e===""}const Go={getDefaultColumnDef:()=>({filterFn:"auto"}),getInitialState:e=>({columnFilters:[],...e}),getDefaultOptions:e=>({onColumnFiltersChange:H("columnFilters",e),filterFromLeafRows:!1,maxLeafRowFilterDepth:100}),createColumn:(e,n)=>{e.getAutoFilterFn=()=>{const t=n.getCoreRowModel().flatRows[0],i=t?.getValue(e.id);return typeof i=="string"?J.includesString:typeof i=="number"?J.inNumberRange:typeof i=="boolean"||i!==null&&typeof i=="object"?J.equals:Array.isArray(i)?J.arrIncludes:J.weakEquals},e.getFilterFn=()=>{var t,i;return Be(e.columnDef.filterFn)?e.columnDef.filterFn:e.columnDef.filterFn==="auto"?e.getAutoFilterFn():(t=(i=n.options.filterFns)==null?void 0:i[e.columnDef.filterFn])!=null?t:J[e.columnDef.filterFn]},e.getCanFilter=()=>{var t,i,s;return((t=e.columnDef.enableColumnFilter)!=null?t:!0)&&((i=n.options.enableColumnFilters)!=null?i:!0)&&((s=n.options.enableFilters)!=null?s:!0)&&!!e.accessorFn},e.getIsFiltered=()=>e.getFilterIndex()>-1,e.getFilterValue=()=>{var t;return(t=n.getState().columnFilters)==null||(t=t.find(i=>i.id===e.id))==null?void 0:t.value},e.getFilterIndex=()=>{var t,i;return(t=(i=n.getState().columnFilters)==null?void 0:i.findIndex(s=>s.id===e.id))!=null?t:-1},e.setFilterValue=t=>{n.setColumnFilters(i=>{const s=e.getFilterFn(),r=i?.find(g=>g.id===e.id),a=te(t,r?r.value:void 0);if(Yt(s,a,e)){var l;return(l=i?.filter(g=>g.id!==e.id))!=null?l:[]}const u={id:e.id,value:a};if(r){var c;return(c=i?.map(g=>g.id===e.id?u:g))!=null?c:[]}return i!=null&&i.length?[...i,u]:[u]})}},createRow:(e,n)=>{e.columnFilters={},e.columnFiltersMeta={}},createTable:e=>{e.setColumnFilters=n=>{const t=e.getAllLeafColumns(),i=s=>{var r;return(r=te(n,s))==null?void 0:r.filter(a=>{const l=t.find(u=>u.id===a.id);if(l){const u=l.getFilterFn();if(Yt(u,a.value,l))return!1}return!0})};e.options.onColumnFiltersChange==null||e.options.onColumnFiltersChange(i)},e.resetColumnFilters=n=>{var t,i;e.setColumnFilters(n?[]:(t=(i=e.initialState)==null?void 0:i.columnFilters)!=null?t:[])},e.getPreFilteredRowModel=()=>e.getCoreRowModel(),e.getFilteredRowModel=()=>(!e._getFilteredRowModel&&e.options.getFilteredRowModel&&(e._getFilteredRowModel=e.options.getFilteredRowModel(e)),e.options.manualFiltering||!e._getFilteredRowModel?e.getPreFilteredRowModel():e._getFilteredRowModel())}};function Yt(e,n,t){return(e&&e.autoRemove?e.autoRemove(n,t):!1)||typeof n>"u"||typeof n=="string"&&!n}const qo=(e,n,t)=>t.reduce((i,s)=>{const r=s.getValue(e);return i+(typeof r=="number"?r:0)},0),Wo=(e,n,t)=>{let i;return t.forEach(s=>{const r=s.getValue(e);r!=null&&(i>r||i===void 0&&r>=r)&&(i=r)}),i},Uo=(e,n,t)=>{let i;return t.forEach(s=>{const r=s.getValue(e);r!=null&&(i<r||i===void 0&&r>=r)&&(i=r)}),i},Ko=(e,n,t)=>{let i,s;return t.forEach(r=>{const a=r.getValue(e);a!=null&&(i===void 0?a>=a&&(i=s=a):(i>a&&(i=a),s<a&&(s=a)))}),[i,s]},Xo=(e,n)=>{let t=0,i=0;if(n.forEach(s=>{let r=s.getValue(e);r!=null&&(r=+r)>=r&&(++t,i+=r)}),t)return i/t},Yo=(e,n)=>{if(!n.length)return;const t=n.map(r=>r.getValue(e));if(!Lo(t))return;if(t.length===1)return t[0];const i=Math.floor(t.length/2),s=t.sort((r,a)=>r-a);return t.length%2!==0?s[i]:(s[i-1]+s[i])/2},Jo=(e,n)=>Array.from(new Set(n.map(t=>t.getValue(e))).values()),Qo=(e,n)=>new Set(n.map(t=>t.getValue(e))).size,Zo=(e,n)=>n.length,Xe={sum:qo,min:Wo,max:Uo,extent:Ko,mean:Xo,median:Yo,unique:Jo,uniqueCount:Qo,count:Zo},er={getDefaultColumnDef:()=>({aggregatedCell:e=>{var n,t;return(n=(t=e.getValue())==null||t.toString==null?void 0:t.toString())!=null?n:null},aggregationFn:"auto"}),getInitialState:e=>({grouping:[],...e}),getDefaultOptions:e=>({onGroupingChange:H("grouping",e),groupedColumnMode:"reorder"}),createColumn:(e,n)=>{e.toggleGrouping=()=>{n.setGrouping(t=>t!=null&&t.includes(e.id)?t.filter(i=>i!==e.id):[...t??[],e.id])},e.getCanGroup=()=>{var t,i;return((t=e.columnDef.enableGrouping)!=null?t:!0)&&((i=n.options.enableGrouping)!=null?i:!0)&&(!!e.accessorFn||!!e.columnDef.getGroupingValue)},e.getIsGrouped=()=>{var t;return(t=n.getState().grouping)==null?void 0:t.includes(e.id)},e.getGroupedIndex=()=>{var t;return(t=n.getState().grouping)==null?void 0:t.indexOf(e.id)},e.getToggleGroupingHandler=()=>{const t=e.getCanGroup();return()=>{t&&e.toggleGrouping()}},e.getAutoAggregationFn=()=>{const t=n.getCoreRowModel().flatRows[0],i=t?.getValue(e.id);if(typeof i=="number")return Xe.sum;if(Object.prototype.toString.call(i)==="[object Date]")return Xe.extent},e.getAggregationFn=()=>{var t,i;if(!e)throw new Error;return Be(e.columnDef.aggregationFn)?e.columnDef.aggregationFn:e.columnDef.aggregationFn==="auto"?e.getAutoAggregationFn():(t=(i=n.options.aggregationFns)==null?void 0:i[e.columnDef.aggregationFn])!=null?t:Xe[e.columnDef.aggregationFn]}},createTable:e=>{e.setGrouping=n=>e.options.onGroupingChange==null?void 0:e.options.onGroupingChange(n),e.resetGrouping=n=>{var t,i;e.setGrouping(n?[]:(t=(i=e.initialState)==null?void 0:i.grouping)!=null?t:[])},e.getPreGroupedRowModel=()=>e.getFilteredRowModel(),e.getGroupedRowModel=()=>(!e._getGroupedRowModel&&e.options.getGroupedRowModel&&(e._getGroupedRowModel=e.options.getGroupedRowModel(e)),e.options.manualGrouping||!e._getGroupedRowModel?e.getPreGroupedRowModel():e._getGroupedRowModel())},createRow:(e,n)=>{e.getIsGrouped=()=>!!e.groupingColumnId,e.getGroupingValue=t=>{if(e._groupingValuesCache.hasOwnProperty(t))return e._groupingValuesCache[t];const i=n.getColumn(t);return i!=null&&i.columnDef.getGroupingValue?(e._groupingValuesCache[t]=i.columnDef.getGroupingValue(e.original),e._groupingValuesCache[t]):e.getValue(t)},e._groupingValuesCache={}},createCell:(e,n,t,i)=>{e.getIsGrouped=()=>n.getIsGrouped()&&n.id===t.groupingColumnId,e.getIsPlaceholder=()=>!e.getIsGrouped()&&n.getIsGrouped(),e.getIsAggregated=()=>{var s;return!e.getIsGrouped()&&!e.getIsPlaceholder()&&!!((s=t.subRows)!=null&&s.length)}}};function tr(e,n,t){if(!(n!=null&&n.length)||!t)return e;const i=e.filter(r=>!n.includes(r.id));return t==="remove"?i:[...n.map(r=>e.find(a=>a.id===r)).filter(Boolean),...i]}const nr={getInitialState:e=>({columnOrder:[],...e}),getDefaultOptions:e=>({onColumnOrderChange:H("columnOrder",e)}),createColumn:(e,n)=>{e.getIndex=y(t=>[me(n,t)],t=>t.findIndex(i=>i.id===e.id),R(n.options,"debugColumns")),e.getIsFirstColumn=t=>{var i;return((i=me(n,t)[0])==null?void 0:i.id)===e.id},e.getIsLastColumn=t=>{var i;const s=me(n,t);return((i=s[s.length-1])==null?void 0:i.id)===e.id}},createTable:e=>{e.setColumnOrder=n=>e.options.onColumnOrderChange==null?void 0:e.options.onColumnOrderChange(n),e.resetColumnOrder=n=>{var t;e.setColumnOrder(n?[]:(t=e.initialState.columnOrder)!=null?t:[])},e._getOrderColumnsFn=y(()=>[e.getState().columnOrder,e.getState().grouping,e.options.groupedColumnMode],(n,t,i)=>s=>{let r=[];if(!(n!=null&&n.length))r=s;else{const a=[...n],l=[...s];for(;l.length&&a.length;){const u=a.shift(),c=l.findIndex(g=>g.id===u);c>-1&&r.push(l.splice(c,1)[0])}r=[...r,...l]}return tr(r,t,i)},R(e.options,"debugTable"))}},Ye=()=>({left:[],right:[]}),ir={getInitialState:e=>({columnPinning:Ye(),...e}),getDefaultOptions:e=>({onColumnPinningChange:H("columnPinning",e)}),createColumn:(e,n)=>{e.pin=t=>{const i=e.getLeafColumns().map(s=>s.id).filter(Boolean);n.setColumnPinning(s=>{var r,a;if(t==="right"){var l,u;return{left:((l=s?.left)!=null?l:[]).filter(p=>!(i!=null&&i.includes(p))),right:[...((u=s?.right)!=null?u:[]).filter(p=>!(i!=null&&i.includes(p))),...i]}}if(t==="left"){var c,g;return{left:[...((c=s?.left)!=null?c:[]).filter(p=>!(i!=null&&i.includes(p))),...i],right:((g=s?.right)!=null?g:[]).filter(p=>!(i!=null&&i.includes(p)))}}return{left:((r=s?.left)!=null?r:[]).filter(p=>!(i!=null&&i.includes(p))),right:((a=s?.right)!=null?a:[]).filter(p=>!(i!=null&&i.includes(p)))}})},e.getCanPin=()=>e.getLeafColumns().some(i=>{var s,r,a;return((s=i.columnDef.enablePinning)!=null?s:!0)&&((r=(a=n.options.enableColumnPinning)!=null?a:n.options.enablePinning)!=null?r:!0)}),e.getIsPinned=()=>{const t=e.getLeafColumns().map(l=>l.id),{left:i,right:s}=n.getState().columnPinning,r=t.some(l=>i?.includes(l)),a=t.some(l=>s?.includes(l));return r?"left":a?"right":!1},e.getPinnedIndex=()=>{var t,i;const s=e.getIsPinned();return s?(t=(i=n.getState().columnPinning)==null||(i=i[s])==null?void 0:i.indexOf(e.id))!=null?t:-1:0}},createRow:(e,n)=>{e.getCenterVisibleCells=y(()=>[e._getAllVisibleCells(),n.getState().columnPinning.left,n.getState().columnPinning.right],(t,i,s)=>{const r=[...i??[],...s??[]];return t.filter(a=>!r.includes(a.column.id))},R(n.options,"debugRows")),e.getLeftVisibleCells=y(()=>[e._getAllVisibleCells(),n.getState().columnPinning.left],(t,i)=>(i??[]).map(r=>t.find(a=>a.column.id===r)).filter(Boolean).map(r=>({...r,position:"left"})),R(n.options,"debugRows")),e.getRightVisibleCells=y(()=>[e._getAllVisibleCells(),n.getState().columnPinning.right],(t,i)=>(i??[]).map(r=>t.find(a=>a.column.id===r)).filter(Boolean).map(r=>({...r,position:"right"})),R(n.options,"debugRows"))},createTable:e=>{e.setColumnPinning=n=>e.options.onColumnPinningChange==null?void 0:e.options.onColumnPinningChange(n),e.resetColumnPinning=n=>{var t,i;return e.setColumnPinning(n?Ye():(t=(i=e.initialState)==null?void 0:i.columnPinning)!=null?t:Ye())},e.getIsSomeColumnsPinned=n=>{var t;const i=e.getState().columnPinning;if(!n){var s,r;return!!((s=i.left)!=null&&s.length||(r=i.right)!=null&&r.length)}return!!((t=i[n])!=null&&t.length)},e.getLeftLeafColumns=y(()=>[e.getAllLeafColumns(),e.getState().columnPinning.left],(n,t)=>(t??[]).map(i=>n.find(s=>s.id===i)).filter(Boolean),R(e.options,"debugColumns")),e.getRightLeafColumns=y(()=>[e.getAllLeafColumns(),e.getState().columnPinning.right],(n,t)=>(t??[]).map(i=>n.find(s=>s.id===i)).filter(Boolean),R(e.options,"debugColumns")),e.getCenterLeafColumns=y(()=>[e.getAllLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(n,t,i)=>{const s=[...t??[],...i??[]];return n.filter(r=>!s.includes(r.id))},R(e.options,"debugColumns"))}};function sr(e){return e||(typeof document<"u"?document:null)}const Ie={size:150,minSize:20,maxSize:Number.MAX_SAFE_INTEGER},Je=()=>({startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,isResizingColumn:!1,columnSizingStart:[]}),or={getDefaultColumnDef:()=>Ie,getInitialState:e=>({columnSizing:{},columnSizingInfo:Je(),...e}),getDefaultOptions:e=>({columnResizeMode:"onEnd",columnResizeDirection:"ltr",onColumnSizingChange:H("columnSizing",e),onColumnSizingInfoChange:H("columnSizingInfo",e)}),createColumn:(e,n)=>{e.getSize=()=>{var t,i,s;const r=n.getState().columnSizing[e.id];return Math.min(Math.max((t=e.columnDef.minSize)!=null?t:Ie.minSize,(i=r??e.columnDef.size)!=null?i:Ie.size),(s=e.columnDef.maxSize)!=null?s:Ie.maxSize)},e.getStart=y(t=>[t,me(n,t),n.getState().columnSizing],(t,i)=>i.slice(0,e.getIndex(t)).reduce((s,r)=>s+r.getSize(),0),R(n.options,"debugColumns")),e.getAfter=y(t=>[t,me(n,t),n.getState().columnSizing],(t,i)=>i.slice(e.getIndex(t)+1).reduce((s,r)=>s+r.getSize(),0),R(n.options,"debugColumns")),e.resetSize=()=>{n.setColumnSizing(t=>{let{[e.id]:i,...s}=t;return s})},e.getCanResize=()=>{var t,i;return((t=e.columnDef.enableResizing)!=null?t:!0)&&((i=n.options.enableColumnResizing)!=null?i:!0)},e.getIsResizing=()=>n.getState().columnSizingInfo.isResizingColumn===e.id},createHeader:(e,n)=>{e.getSize=()=>{let t=0;const i=s=>{if(s.subHeaders.length)s.subHeaders.forEach(i);else{var r;t+=(r=s.column.getSize())!=null?r:0}};return i(e),t},e.getStart=()=>{if(e.index>0){const t=e.headerGroup.headers[e.index-1];return t.getStart()+t.getSize()}return 0},e.getResizeHandler=t=>{const i=n.getColumn(e.column.id),s=i?.getCanResize();return r=>{if(!i||!s||(r.persist==null||r.persist(),Qe(r)&&r.touches&&r.touches.length>1))return;const a=e.getSize(),l=e?e.getLeafHeaders().map(S=>[S.column.id,S.column.getSize()]):[[i.id,i.getSize()]],u=Qe(r)?Math.round(r.touches[0].clientX):r.clientX,c={},g=(S,j)=>{typeof j=="number"&&(n.setColumnSizingInfo(C=>{var k,T;const P=n.options.columnResizeDirection==="rtl"?-1:1,w=(j-((k=C?.startOffset)!=null?k:0))*P,b=Math.max(w/((T=C?.startSize)!=null?T:0),-.999999);return C.columnSizingStart.forEach(I=>{let[D,$]=I;c[D]=Math.round(Math.max($+$*b,0)*100)/100}),{...C,deltaOffset:w,deltaPercentage:b}}),(n.options.columnResizeMode==="onChange"||S==="end")&&n.setColumnSizing(C=>({...C,...c})))},p=S=>g("move",S),d=S=>{g("end",S),n.setColumnSizingInfo(j=>({...j,isResizingColumn:!1,startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,columnSizingStart:[]}))},f=sr(t),h={moveHandler:S=>p(S.clientX),upHandler:S=>{f?.removeEventListener("mousemove",h.moveHandler),f?.removeEventListener("mouseup",h.upHandler),d(S.clientX)}},m={moveHandler:S=>(S.cancelable&&(S.preventDefault(),S.stopPropagation()),p(S.touches[0].clientX),!1),upHandler:S=>{var j;f?.removeEventListener("touchmove",m.moveHandler),f?.removeEventListener("touchend",m.upHandler),S.cancelable&&(S.preventDefault(),S.stopPropagation()),d((j=S.touches[0])==null?void 0:j.clientX)}},v=rr()?{passive:!1}:!1;Qe(r)?(f?.addEventListener("touchmove",m.moveHandler,v),f?.addEventListener("touchend",m.upHandler,v)):(f?.addEventListener("mousemove",h.moveHandler,v),f?.addEventListener("mouseup",h.upHandler,v)),n.setColumnSizingInfo(S=>({...S,startOffset:u,startSize:a,deltaOffset:0,deltaPercentage:0,columnSizingStart:l,isResizingColumn:i.id}))}}},createTable:e=>{e.setColumnSizing=n=>e.options.onColumnSizingChange==null?void 0:e.options.onColumnSizingChange(n),e.setColumnSizingInfo=n=>e.options.onColumnSizingInfoChange==null?void 0:e.options.onColumnSizingInfoChange(n),e.resetColumnSizing=n=>{var t;e.setColumnSizing(n?{}:(t=e.initialState.columnSizing)!=null?t:{})},e.resetHeaderSizeInfo=n=>{var t;e.setColumnSizingInfo(n?Je():(t=e.initialState.columnSizingInfo)!=null?t:Je())},e.getTotalSize=()=>{var n,t;return(n=(t=e.getHeaderGroups()[0])==null?void 0:t.headers.reduce((i,s)=>i+s.getSize(),0))!=null?n:0},e.getLeftTotalSize=()=>{var n,t;return(n=(t=e.getLeftHeaderGroups()[0])==null?void 0:t.headers.reduce((i,s)=>i+s.getSize(),0))!=null?n:0},e.getCenterTotalSize=()=>{var n,t;return(n=(t=e.getCenterHeaderGroups()[0])==null?void 0:t.headers.reduce((i,s)=>i+s.getSize(),0))!=null?n:0},e.getRightTotalSize=()=>{var n,t;return(n=(t=e.getRightHeaderGroups()[0])==null?void 0:t.headers.reduce((i,s)=>i+s.getSize(),0))!=null?n:0}}};let Fe=null;function rr(){if(typeof Fe=="boolean")return Fe;let e=!1;try{const n={get passive(){return e=!0,!1}},t=()=>{};window.addEventListener("test",t,n),window.removeEventListener("test",t)}catch{e=!1}return Fe=e,Fe}function Qe(e){return e.type==="touchstart"}const ar={getInitialState:e=>({columnVisibility:{},...e}),getDefaultOptions:e=>({onColumnVisibilityChange:H("columnVisibility",e)}),createColumn:(e,n)=>{e.toggleVisibility=t=>{e.getCanHide()&&n.setColumnVisibility(i=>({...i,[e.id]:t??!e.getIsVisible()}))},e.getIsVisible=()=>{var t,i;const s=e.columns;return(t=s.length?s.some(r=>r.getIsVisible()):(i=n.getState().columnVisibility)==null?void 0:i[e.id])!=null?t:!0},e.getCanHide=()=>{var t,i;return((t=e.columnDef.enableHiding)!=null?t:!0)&&((i=n.options.enableHiding)!=null?i:!0)},e.getToggleVisibilityHandler=()=>t=>{e.toggleVisibility==null||e.toggleVisibility(t.target.checked)}},createRow:(e,n)=>{e._getAllVisibleCells=y(()=>[e.getAllCells(),n.getState().columnVisibility],t=>t.filter(i=>i.column.getIsVisible()),R(n.options,"debugRows")),e.getVisibleCells=y(()=>[e.getLeftVisibleCells(),e.getCenterVisibleCells(),e.getRightVisibleCells()],(t,i,s)=>[...t,...i,...s],R(n.options,"debugRows"))},createTable:e=>{const n=(t,i)=>y(()=>[i(),i().filter(s=>s.getIsVisible()).map(s=>s.id).join("_")],s=>s.filter(r=>r.getIsVisible==null?void 0:r.getIsVisible()),R(e.options,"debugColumns"));e.getVisibleFlatColumns=n("getVisibleFlatColumns",()=>e.getAllFlatColumns()),e.getVisibleLeafColumns=n("getVisibleLeafColumns",()=>e.getAllLeafColumns()),e.getLeftVisibleLeafColumns=n("getLeftVisibleLeafColumns",()=>e.getLeftLeafColumns()),e.getRightVisibleLeafColumns=n("getRightVisibleLeafColumns",()=>e.getRightLeafColumns()),e.getCenterVisibleLeafColumns=n("getCenterVisibleLeafColumns",()=>e.getCenterLeafColumns()),e.setColumnVisibility=t=>e.options.onColumnVisibilityChange==null?void 0:e.options.onColumnVisibilityChange(t),e.resetColumnVisibility=t=>{var i;e.setColumnVisibility(t?{}:(i=e.initialState.columnVisibility)!=null?i:{})},e.toggleAllColumnsVisible=t=>{var i;t=(i=t)!=null?i:!e.getIsAllColumnsVisible(),e.setColumnVisibility(e.getAllLeafColumns().reduce((s,r)=>({...s,[r.id]:t||!(r.getCanHide!=null&&r.getCanHide())}),{}))},e.getIsAllColumnsVisible=()=>!e.getAllLeafColumns().some(t=>!(t.getIsVisible!=null&&t.getIsVisible())),e.getIsSomeColumnsVisible=()=>e.getAllLeafColumns().some(t=>t.getIsVisible==null?void 0:t.getIsVisible()),e.getToggleAllColumnsVisibilityHandler=()=>t=>{var i;e.toggleAllColumnsVisible((i=t.target)==null?void 0:i.checked)}}};function me(e,n){return n?n==="center"?e.getCenterVisibleLeafColumns():n==="left"?e.getLeftVisibleLeafColumns():e.getRightVisibleLeafColumns():e.getVisibleLeafColumns()}const lr={createTable:e=>{e._getGlobalFacetedRowModel=e.options.getFacetedRowModel&&e.options.getFacetedRowModel(e,"__global__"),e.getGlobalFacetedRowModel=()=>e.options.manualFiltering||!e._getGlobalFacetedRowModel?e.getPreFilteredRowModel():e._getGlobalFacetedRowModel(),e._getGlobalFacetedUniqueValues=e.options.getFacetedUniqueValues&&e.options.getFacetedUniqueValues(e,"__global__"),e.getGlobalFacetedUniqueValues=()=>e._getGlobalFacetedUniqueValues?e._getGlobalFacetedUniqueValues():new Map,e._getGlobalFacetedMinMaxValues=e.options.getFacetedMinMaxValues&&e.options.getFacetedMinMaxValues(e,"__global__"),e.getGlobalFacetedMinMaxValues=()=>{if(e._getGlobalFacetedMinMaxValues)return e._getGlobalFacetedMinMaxValues()}}},ur={getInitialState:e=>({globalFilter:void 0,...e}),getDefaultOptions:e=>({onGlobalFilterChange:H("globalFilter",e),globalFilterFn:"auto",getColumnCanGlobalFilter:n=>{var t;const i=(t=e.getCoreRowModel().flatRows[0])==null||(t=t._getAllCellsByColumnId()[n.id])==null?void 0:t.getValue();return typeof i=="string"||typeof i=="number"}}),createColumn:(e,n)=>{e.getCanGlobalFilter=()=>{var t,i,s,r;return((t=e.columnDef.enableGlobalFilter)!=null?t:!0)&&((i=n.options.enableGlobalFilter)!=null?i:!0)&&((s=n.options.enableFilters)!=null?s:!0)&&((r=n.options.getColumnCanGlobalFilter==null?void 0:n.options.getColumnCanGlobalFilter(e))!=null?r:!0)&&!!e.accessorFn}},createTable:e=>{e.getGlobalAutoFilterFn=()=>J.includesString,e.getGlobalFilterFn=()=>{var n,t;const{globalFilterFn:i}=e.options;return Be(i)?i:i==="auto"?e.getGlobalAutoFilterFn():(n=(t=e.options.filterFns)==null?void 0:t[i])!=null?n:J[i]},e.setGlobalFilter=n=>{e.options.onGlobalFilterChange==null||e.options.onGlobalFilterChange(n)},e.resetGlobalFilter=n=>{e.setGlobalFilter(n?void 0:e.initialState.globalFilter)}}},cr={getInitialState:e=>({expanded:{},...e}),getDefaultOptions:e=>({onExpandedChange:H("expanded",e),paginateExpandedRows:!0}),createTable:e=>{let n=!1,t=!1;e._autoResetExpanded=()=>{var i,s;if(!n){e._queue(()=>{n=!0});return}if((i=(s=e.options.autoResetAll)!=null?s:e.options.autoResetExpanded)!=null?i:!e.options.manualExpanding){if(t)return;t=!0,e._queue(()=>{e.resetExpanded(),t=!1})}},e.setExpanded=i=>e.options.onExpandedChange==null?void 0:e.options.onExpandedChange(i),e.toggleAllRowsExpanded=i=>{i??!e.getIsAllRowsExpanded()?e.setExpanded(!0):e.setExpanded({})},e.resetExpanded=i=>{var s,r;e.setExpanded(i?{}:(s=(r=e.initialState)==null?void 0:r.expanded)!=null?s:{})},e.getCanSomeRowsExpand=()=>e.getPrePaginationRowModel().flatRows.some(i=>i.getCanExpand()),e.getToggleAllRowsExpandedHandler=()=>i=>{i.persist==null||i.persist(),e.toggleAllRowsExpanded()},e.getIsSomeRowsExpanded=()=>{const i=e.getState().expanded;return i===!0||Object.values(i).some(Boolean)},e.getIsAllRowsExpanded=()=>{const i=e.getState().expanded;return typeof i=="boolean"?i===!0:!(!Object.keys(i).length||e.getRowModel().flatRows.some(s=>!s.getIsExpanded()))},e.getExpandedDepth=()=>{let i=0;return(e.getState().expanded===!0?Object.keys(e.getRowModel().rowsById):Object.keys(e.getState().expanded)).forEach(r=>{const a=r.split(".");i=Math.max(i,a.length)}),i},e.getPreExpandedRowModel=()=>e.getSortedRowModel(),e.getExpandedRowModel=()=>(!e._getExpandedRowModel&&e.options.getExpandedRowModel&&(e._getExpandedRowModel=e.options.getExpandedRowModel(e)),e.options.manualExpanding||!e._getExpandedRowModel?e.getPreExpandedRowModel():e._getExpandedRowModel())},createRow:(e,n)=>{e.toggleExpanded=t=>{n.setExpanded(i=>{var s;const r=i===!0?!0:!!(i!=null&&i[e.id]);let a={};if(i===!0?Object.keys(n.getRowModel().rowsById).forEach(l=>{a[l]=!0}):a=i,t=(s=t)!=null?s:!r,!r&&t)return{...a,[e.id]:!0};if(r&&!t){const{[e.id]:l,...u}=a;return u}return i})},e.getIsExpanded=()=>{var t;const i=n.getState().expanded;return!!((t=n.options.getIsRowExpanded==null?void 0:n.options.getIsRowExpanded(e))!=null?t:i===!0||i?.[e.id])},e.getCanExpand=()=>{var t,i,s;return(t=n.options.getRowCanExpand==null?void 0:n.options.getRowCanExpand(e))!=null?t:((i=n.options.enableExpanding)!=null?i:!0)&&!!((s=e.subRows)!=null&&s.length)},e.getIsAllParentsExpanded=()=>{let t=!0,i=e;for(;t&&i.parentId;)i=n.getRow(i.parentId,!0),t=i.getIsExpanded();return t},e.getToggleExpandedHandler=()=>{const t=e.getCanExpand();return()=>{t&&e.toggleExpanded()}}}},at=0,lt=10,Ze=()=>({pageIndex:at,pageSize:lt}),dr={getInitialState:e=>({...e,pagination:{...Ze(),...e?.pagination}}),getDefaultOptions:e=>({onPaginationChange:H("pagination",e)}),createTable:e=>{let n=!1,t=!1;e._autoResetPageIndex=()=>{var i,s;if(!n){e._queue(()=>{n=!0});return}if((i=(s=e.options.autoResetAll)!=null?s:e.options.autoResetPageIndex)!=null?i:!e.options.manualPagination){if(t)return;t=!0,e._queue(()=>{e.resetPageIndex(),t=!1})}},e.setPagination=i=>{const s=r=>te(i,r);return e.options.onPaginationChange==null?void 0:e.options.onPaginationChange(s)},e.resetPagination=i=>{var s;e.setPagination(i?Ze():(s=e.initialState.pagination)!=null?s:Ze())},e.setPageIndex=i=>{e.setPagination(s=>{let r=te(i,s.pageIndex);const a=typeof e.options.pageCount>"u"||e.options.pageCount===-1?Number.MAX_SAFE_INTEGER:e.options.pageCount-1;return r=Math.max(0,Math.min(r,a)),{...s,pageIndex:r}})},e.resetPageIndex=i=>{var s,r;e.setPageIndex(i?at:(s=(r=e.initialState)==null||(r=r.pagination)==null?void 0:r.pageIndex)!=null?s:at)},e.resetPageSize=i=>{var s,r;e.setPageSize(i?lt:(s=(r=e.initialState)==null||(r=r.pagination)==null?void 0:r.pageSize)!=null?s:lt)},e.setPageSize=i=>{e.setPagination(s=>{const r=Math.max(1,te(i,s.pageSize)),a=s.pageSize*s.pageIndex,l=Math.floor(a/r);return{...s,pageIndex:l,pageSize:r}})},e.setPageCount=i=>e.setPagination(s=>{var r;let a=te(i,(r=e.options.pageCount)!=null?r:-1);return typeof a=="number"&&(a=Math.max(-1,a)),{...s,pageCount:a}}),e.getPageOptions=y(()=>[e.getPageCount()],i=>{let s=[];return i&&i>0&&(s=[...new Array(i)].fill(null).map((r,a)=>a)),s},R(e.options,"debugTable")),e.getCanPreviousPage=()=>e.getState().pagination.pageIndex>0,e.getCanNextPage=()=>{const{pageIndex:i}=e.getState().pagination,s=e.getPageCount();return s===-1?!0:s===0?!1:i<s-1},e.previousPage=()=>e.setPageIndex(i=>i-1),e.nextPage=()=>e.setPageIndex(i=>i+1),e.firstPage=()=>e.setPageIndex(0),e.lastPage=()=>e.setPageIndex(e.getPageCount()-1),e.getPrePaginationRowModel=()=>e.getExpandedRowModel(),e.getPaginationRowModel=()=>(!e._getPaginationRowModel&&e.options.getPaginationRowModel&&(e._getPaginationRowModel=e.options.getPaginationRowModel(e)),e.options.manualPagination||!e._getPaginationRowModel?e.getPrePaginationRowModel():e._getPaginationRowModel()),e.getPageCount=()=>{var i;return(i=e.options.pageCount)!=null?i:Math.ceil(e.getRowCount()/e.getState().pagination.pageSize)},e.getRowCount=()=>{var i;return(i=e.options.rowCount)!=null?i:e.getPrePaginationRowModel().rows.length}}},et=()=>({top:[],bottom:[]}),gr={getInitialState:e=>({rowPinning:et(),...e}),getDefaultOptions:e=>({onRowPinningChange:H("rowPinning",e)}),createRow:(e,n)=>{e.pin=(t,i,s)=>{const r=i?e.getLeafRows().map(u=>{let{id:c}=u;return c}):[],a=s?e.getParentRows().map(u=>{let{id:c}=u;return c}):[],l=new Set([...a,e.id,...r]);n.setRowPinning(u=>{var c,g;if(t==="bottom"){var p,d;return{top:((p=u?.top)!=null?p:[]).filter(m=>!(l!=null&&l.has(m))),bottom:[...((d=u?.bottom)!=null?d:[]).filter(m=>!(l!=null&&l.has(m))),...Array.from(l)]}}if(t==="top"){var f,h;return{top:[...((f=u?.top)!=null?f:[]).filter(m=>!(l!=null&&l.has(m))),...Array.from(l)],bottom:((h=u?.bottom)!=null?h:[]).filter(m=>!(l!=null&&l.has(m)))}}return{top:((c=u?.top)!=null?c:[]).filter(m=>!(l!=null&&l.has(m))),bottom:((g=u?.bottom)!=null?g:[]).filter(m=>!(l!=null&&l.has(m)))}})},e.getCanPin=()=>{var t;const{enableRowPinning:i,enablePinning:s}=n.options;return typeof i=="function"?i(e):(t=i??s)!=null?t:!0},e.getIsPinned=()=>{const t=[e.id],{top:i,bottom:s}=n.getState().rowPinning,r=t.some(l=>i?.includes(l)),a=t.some(l=>s?.includes(l));return r?"top":a?"bottom":!1},e.getPinnedIndex=()=>{var t,i;const s=e.getIsPinned();if(!s)return-1;const r=(t=s==="top"?n.getTopRows():n.getBottomRows())==null?void 0:t.map(a=>{let{id:l}=a;return l});return(i=r?.indexOf(e.id))!=null?i:-1}},createTable:e=>{e.setRowPinning=n=>e.options.onRowPinningChange==null?void 0:e.options.onRowPinningChange(n),e.resetRowPinning=n=>{var t,i;return e.setRowPinning(n?et():(t=(i=e.initialState)==null?void 0:i.rowPinning)!=null?t:et())},e.getIsSomeRowsPinned=n=>{var t;const i=e.getState().rowPinning;if(!n){var s,r;return!!((s=i.top)!=null&&s.length||(r=i.bottom)!=null&&r.length)}return!!((t=i[n])!=null&&t.length)},e._getPinnedRows=(n,t,i)=>{var s;return((s=e.options.keepPinnedRows)==null||s?(t??[]).map(a=>{const l=e.getRow(a,!0);return l.getIsAllParentsExpanded()?l:null}):(t??[]).map(a=>n.find(l=>l.id===a))).filter(Boolean).map(a=>({...a,position:i}))},e.getTopRows=y(()=>[e.getRowModel().rows,e.getState().rowPinning.top],(n,t)=>e._getPinnedRows(n,t,"top"),R(e.options,"debugRows")),e.getBottomRows=y(()=>[e.getRowModel().rows,e.getState().rowPinning.bottom],(n,t)=>e._getPinnedRows(n,t,"bottom"),R(e.options,"debugRows")),e.getCenterRows=y(()=>[e.getRowModel().rows,e.getState().rowPinning.top,e.getState().rowPinning.bottom],(n,t,i)=>{const s=new Set([...t??[],...i??[]]);return n.filter(r=>!s.has(r.id))},R(e.options,"debugRows"))}},fr={getInitialState:e=>({rowSelection:{},...e}),getDefaultOptions:e=>({onRowSelectionChange:H("rowSelection",e),enableRowSelection:!0,enableMultiRowSelection:!0,enableSubRowSelection:!0}),createTable:e=>{e.setRowSelection=n=>e.options.onRowSelectionChange==null?void 0:e.options.onRowSelectionChange(n),e.resetRowSelection=n=>{var t;return e.setRowSelection(n?{}:(t=e.initialState.rowSelection)!=null?t:{})},e.toggleAllRowsSelected=n=>{e.setRowSelection(t=>{n=typeof n<"u"?n:!e.getIsAllRowsSelected();const i={...t},s=e.getPreGroupedRowModel().flatRows;return n?s.forEach(r=>{r.getCanSelect()&&(i[r.id]=!0)}):s.forEach(r=>{delete i[r.id]}),i})},e.toggleAllPageRowsSelected=n=>e.setRowSelection(t=>{const i=typeof n<"u"?n:!e.getIsAllPageRowsSelected(),s={...t};return e.getRowModel().rows.forEach(r=>{ut(s,r.id,i,!0,e)}),s}),e.getPreSelectedRowModel=()=>e.getCoreRowModel(),e.getSelectedRowModel=y(()=>[e.getState().rowSelection,e.getCoreRowModel()],(n,t)=>Object.keys(n).length?tt(e,t):{rows:[],flatRows:[],rowsById:{}},R(e.options,"debugTable")),e.getFilteredSelectedRowModel=y(()=>[e.getState().rowSelection,e.getFilteredRowModel()],(n,t)=>Object.keys(n).length?tt(e,t):{rows:[],flatRows:[],rowsById:{}},R(e.options,"debugTable")),e.getGroupedSelectedRowModel=y(()=>[e.getState().rowSelection,e.getSortedRowModel()],(n,t)=>Object.keys(n).length?tt(e,t):{rows:[],flatRows:[],rowsById:{}},R(e.options,"debugTable")),e.getIsAllRowsSelected=()=>{const n=e.getFilteredRowModel().flatRows,{rowSelection:t}=e.getState();let i=!!(n.length&&Object.keys(t).length);return i&&n.some(s=>s.getCanSelect()&&!t[s.id])&&(i=!1),i},e.getIsAllPageRowsSelected=()=>{const n=e.getPaginationRowModel().flatRows.filter(s=>s.getCanSelect()),{rowSelection:t}=e.getState();let i=!!n.length;return i&&n.some(s=>!t[s.id])&&(i=!1),i},e.getIsSomeRowsSelected=()=>{var n;const t=Object.keys((n=e.getState().rowSelection)!=null?n:{}).length;return t>0&&t<e.getFilteredRowModel().flatRows.length},e.getIsSomePageRowsSelected=()=>{const n=e.getPaginationRowModel().flatRows;return e.getIsAllPageRowsSelected()?!1:n.filter(t=>t.getCanSelect()).some(t=>t.getIsSelected()||t.getIsSomeSelected())},e.getToggleAllRowsSelectedHandler=()=>n=>{e.toggleAllRowsSelected(n.target.checked)},e.getToggleAllPageRowsSelectedHandler=()=>n=>{e.toggleAllPageRowsSelected(n.target.checked)}},createRow:(e,n)=>{e.toggleSelected=(t,i)=>{const s=e.getIsSelected();n.setRowSelection(r=>{var a;if(t=typeof t<"u"?t:!s,e.getCanSelect()&&s===t)return r;const l={...r};return ut(l,e.id,t,(a=i?.selectChildren)!=null?a:!0,n),l})},e.getIsSelected=()=>{const{rowSelection:t}=n.getState();return bt(e,t)},e.getIsSomeSelected=()=>{const{rowSelection:t}=n.getState();return ct(e,t)==="some"},e.getIsAllSubRowsSelected=()=>{const{rowSelection:t}=n.getState();return ct(e,t)==="all"},e.getCanSelect=()=>{var t;return typeof n.options.enableRowSelection=="function"?n.options.enableRowSelection(e):(t=n.options.enableRowSelection)!=null?t:!0},e.getCanSelectSubRows=()=>{var t;return typeof n.options.enableSubRowSelection=="function"?n.options.enableSubRowSelection(e):(t=n.options.enableSubRowSelection)!=null?t:!0},e.getCanMultiSelect=()=>{var t;return typeof n.options.enableMultiRowSelection=="function"?n.options.enableMultiRowSelection(e):(t=n.options.enableMultiRowSelection)!=null?t:!0},e.getToggleSelectedHandler=()=>{const t=e.getCanSelect();return i=>{var s;t&&e.toggleSelected((s=i.target)==null?void 0:s.checked)}}}},ut=(e,n,t,i,s)=>{var r;const a=s.getRow(n,!0);t?(a.getCanMultiSelect()||Object.keys(e).forEach(l=>delete e[l]),a.getCanSelect()&&(e[n]=!0)):delete e[n],i&&(r=a.subRows)!=null&&r.length&&a.getCanSelectSubRows()&&a.subRows.forEach(l=>ut(e,l.id,t,i,s))};function tt(e,n){const t=e.getState().rowSelection,i=[],s={},r=function(a,l){return a.map(u=>{var c;const g=bt(u,t);if(g&&(i.push(u),s[u.id]=u),(c=u.subRows)!=null&&c.length&&(u={...u,subRows:r(u.subRows)}),g)return u}).filter(Boolean)};return{rows:r(n.rows),flatRows:i,rowsById:s}}function bt(e,n){var t;return(t=n[e.id])!=null?t:!1}function ct(e,n,t){var i;if(!((i=e.subRows)!=null&&i.length))return!1;let s=!0,r=!1;return e.subRows.forEach(a=>{if(!(r&&!s)&&(a.getCanSelect()&&(bt(a,n)?r=!0:s=!1),a.subRows&&a.subRows.length)){const l=ct(a,n);l==="all"?r=!0:(l==="some"&&(r=!0),s=!1)}}),s?"all":r?"some":!1}const dt=/([0-9]+)/gm,mr=(e,n,t)=>Gn(ne(e.getValue(t)).toLowerCase(),ne(n.getValue(t)).toLowerCase()),pr=(e,n,t)=>Gn(ne(e.getValue(t)),ne(n.getValue(t))),hr=(e,n,t)=>_t(ne(e.getValue(t)).toLowerCase(),ne(n.getValue(t)).toLowerCase()),xr=(e,n,t)=>_t(ne(e.getValue(t)),ne(n.getValue(t))),wr=(e,n,t)=>{const i=e.getValue(t),s=n.getValue(t);return i>s?1:i<s?-1:0},vr=(e,n,t)=>_t(e.getValue(t),n.getValue(t));function _t(e,n){return e===n?0:e>n?1:-1}function ne(e){return typeof e=="number"?isNaN(e)||e===1/0||e===-1/0?"":String(e):typeof e=="string"?e:""}function Gn(e,n){const t=e.split(dt).filter(Boolean),i=n.split(dt).filter(Boolean);for(;t.length&&i.length;){const s=t.shift(),r=i.shift(),a=parseInt(s,10),l=parseInt(r,10),u=[a,l].sort();if(isNaN(u[0])){if(s>r)return 1;if(r>s)return-1;continue}if(isNaN(u[1]))return isNaN(a)?-1:1;if(a>l)return 1;if(l>a)return-1}return t.length-i.length}const fe={alphanumeric:mr,alphanumericCaseSensitive:pr,text:hr,textCaseSensitive:xr,datetime:wr,basic:vr},Sr={getInitialState:e=>({sorting:[],...e}),getDefaultColumnDef:()=>({sortingFn:"auto",sortUndefined:1}),getDefaultOptions:e=>({onSortingChange:H("sorting",e),isMultiSortEvent:n=>n.shiftKey}),createColumn:(e,n)=>{e.getAutoSortingFn=()=>{const t=n.getFilteredRowModel().flatRows.slice(10);let i=!1;for(const s of t){const r=s?.getValue(e.id);if(Object.prototype.toString.call(r)==="[object Date]")return fe.datetime;if(typeof r=="string"&&(i=!0,r.split(dt).length>1))return fe.alphanumeric}return i?fe.text:fe.basic},e.getAutoSortDir=()=>{const t=n.getFilteredRowModel().flatRows[0];return typeof t?.getValue(e.id)=="string"?"asc":"desc"},e.getSortingFn=()=>{var t,i;if(!e)throw new Error;return Be(e.columnDef.sortingFn)?e.columnDef.sortingFn:e.columnDef.sortingFn==="auto"?e.getAutoSortingFn():(t=(i=n.options.sortingFns)==null?void 0:i[e.columnDef.sortingFn])!=null?t:fe[e.columnDef.sortingFn]},e.toggleSorting=(t,i)=>{const s=e.getNextSortingOrder(),r=typeof t<"u"&&t!==null;n.setSorting(a=>{const l=a?.find(f=>f.id===e.id),u=a?.findIndex(f=>f.id===e.id);let c=[],g,p=r?t:s==="desc";if(a!=null&&a.length&&e.getCanMultiSort()&&i?l?g="toggle":g="add":a!=null&&a.length&&u!==a.length-1?g="replace":l?g="toggle":g="replace",g==="toggle"&&(r||s||(g="remove")),g==="add"){var d;c=[...a,{id:e.id,desc:p}],c.splice(0,c.length-((d=n.options.maxMultiSortColCount)!=null?d:Number.MAX_SAFE_INTEGER))}else g==="toggle"?c=a.map(f=>f.id===e.id?{...f,desc:p}:f):g==="remove"?c=a.filter(f=>f.id!==e.id):c=[{id:e.id,desc:p}];return c})},e.getFirstSortDir=()=>{var t,i;return((t=(i=e.columnDef.sortDescFirst)!=null?i:n.options.sortDescFirst)!=null?t:e.getAutoSortDir()==="desc")?"desc":"asc"},e.getNextSortingOrder=t=>{var i,s;const r=e.getFirstSortDir(),a=e.getIsSorted();return a?a!==r&&((i=n.options.enableSortingRemoval)==null||i)&&(!(t&&(s=n.options.enableMultiRemove)!=null)||s)?!1:a==="desc"?"asc":"desc":r},e.getCanSort=()=>{var t,i;return((t=e.columnDef.enableSorting)!=null?t:!0)&&((i=n.options.enableSorting)!=null?i:!0)&&!!e.accessorFn},e.getCanMultiSort=()=>{var t,i;return(t=(i=e.columnDef.enableMultiSort)!=null?i:n.options.enableMultiSort)!=null?t:!!e.accessorFn},e.getIsSorted=()=>{var t;const i=(t=n.getState().sorting)==null?void 0:t.find(s=>s.id===e.id);return i?i.desc?"desc":"asc":!1},e.getSortIndex=()=>{var t,i;return(t=(i=n.getState().sorting)==null?void 0:i.findIndex(s=>s.id===e.id))!=null?t:-1},e.clearSorting=()=>{n.setSorting(t=>t!=null&&t.length?t.filter(i=>i.id!==e.id):[])},e.getToggleSortingHandler=()=>{const t=e.getCanSort();return i=>{t&&(i.persist==null||i.persist(),e.toggleSorting==null||e.toggleSorting(void 0,e.getCanMultiSort()?n.options.isMultiSortEvent==null?void 0:n.options.isMultiSortEvent(i):!1))}}},createTable:e=>{e.setSorting=n=>e.options.onSortingChange==null?void 0:e.options.onSortingChange(n),e.resetSorting=n=>{var t,i;e.setSorting(n?[]:(t=(i=e.initialState)==null?void 0:i.sorting)!=null?t:[])},e.getPreSortedRowModel=()=>e.getGroupedRowModel(),e.getSortedRowModel=()=>(!e._getSortedRowModel&&e.options.getSortedRowModel&&(e._getSortedRowModel=e.options.getSortedRowModel(e)),e.options.manualSorting||!e._getSortedRowModel?e.getPreSortedRowModel():e._getSortedRowModel())}},Cr=[Bo,ar,nr,ir,Ho,Go,lr,ur,Sr,er,cr,dr,gr,fr,or];function yr(e){var n,t;const i=[...Cr,...(n=e._features)!=null?n:[]];let s={_features:i};const r=s._features.reduce((d,f)=>Object.assign(d,f.getDefaultOptions==null?void 0:f.getDefaultOptions(s)),{}),a=d=>s.options.mergeOptions?s.options.mergeOptions(r,d):{...r,...d};let u={...{},...(t=e.initialState)!=null?t:{}};s._features.forEach(d=>{var f;u=(f=d.getInitialState==null?void 0:d.getInitialState(u))!=null?f:u});const c=[];let g=!1;const p={_features:i,options:{...r,...e},initialState:u,_queue:d=>{c.push(d),g||(g=!0,Promise.resolve().then(()=>{for(;c.length;)c.shift()();g=!1}).catch(f=>setTimeout(()=>{throw f})))},reset:()=>{s.setState(s.initialState)},setOptions:d=>{const f=te(d,s.options);s.options=a(f)},getState:()=>s.options.state,setState:d=>{s.options.onStateChange==null||s.options.onStateChange(d)},_getRowId:(d,f,h)=>{var m;return(m=s.options.getRowId==null?void 0:s.options.getRowId(d,f,h))!=null?m:`${h?[h.id,f].join("."):f}`},getCoreRowModel:()=>(s._getCoreRowModel||(s._getCoreRowModel=s.options.getCoreRowModel(s)),s._getCoreRowModel()),getRowModel:()=>s.getPaginationRowModel(),getRow:(d,f)=>{let h=(f?s.getPrePaginationRowModel():s.getRowModel()).rowsById[d];if(!h&&(h=s.getCoreRowModel().rowsById[d],!h))throw new Error;return h},_getDefaultColumnDef:y(()=>[s.options.defaultColumn],d=>{var f;return d=(f=d)!=null?f:{},{header:h=>{const m=h.header.column.columnDef;return m.accessorKey?m.accessorKey:m.accessorFn?m.id:null},cell:h=>{var m,v;return(m=(v=h.renderValue())==null||v.toString==null?void 0:v.toString())!=null?m:null},...s._features.reduce((h,m)=>Object.assign(h,m.getDefaultColumnDef==null?void 0:m.getDefaultColumnDef()),{}),...d}},R(e,"debugColumns")),_getColumnDefs:()=>s.options.columns,getAllColumns:y(()=>[s._getColumnDefs()],d=>{const f=function(h,m,v){return v===void 0&&(v=0),h.map(S=>{const j=Vo(s,S,v,m),C=S;return j.columns=C.columns?f(C.columns,j,v+1):[],j})};return f(d)},R(e,"debugColumns")),getAllFlatColumns:y(()=>[s.getAllColumns()],d=>d.flatMap(f=>f.getFlatColumns()),R(e,"debugColumns")),_getAllFlatColumnsById:y(()=>[s.getAllFlatColumns()],d=>d.reduce((f,h)=>(f[h.id]=h,f),{}),R(e,"debugColumns")),getAllLeafColumns:y(()=>[s.getAllColumns(),s._getOrderColumnsFn()],(d,f)=>{let h=d.flatMap(m=>m.getLeafColumns());return f(h)},R(e,"debugColumns")),getColumn:d=>s._getAllFlatColumnsById()[d]};Object.assign(s,p);for(let d=0;d<s._features.length;d++){const f=s._features[d];f==null||f.createTable==null||f.createTable(s)}return s}function Rr(){return e=>y(()=>[e.options.data],n=>{const t={rows:[],flatRows:[],rowsById:{}},i=function(s,r,a){r===void 0&&(r=0);const l=[];for(let c=0;c<s.length;c++){const g=Oo(e,e._getRowId(s[c],c,a),s[c],c,r,void 0,a?.id);if(t.flatRows.push(g),t.rowsById[g.id]=g,l.push(g),e.options.getSubRows){var u;g.originalSubRows=e.options.getSubRows(s[c],c),(u=g.originalSubRows)!=null&&u.length&&(g.subRows=i(g.originalSubRows,r+1,g))}}return l};return t.rows=i(n),t},R(e.options,"debugTable","getRowModel",()=>e._autoResetPageIndex()))}function jr(e){const n=[],t=i=>{var s;n.push(i),(s=i.subRows)!=null&&s.length&&i.getIsExpanded()&&i.subRows.forEach(t)};return e.rows.forEach(t),{rows:n,flatRows:e.flatRows,rowsById:e.rowsById}}function br(e){return n=>y(()=>[n.getState().pagination,n.getPrePaginationRowModel(),n.options.paginateExpandedRows?void 0:n.getState().expanded],(t,i)=>{if(!i.rows.length)return i;const{pageSize:s,pageIndex:r}=t;let{rows:a,flatRows:l,rowsById:u}=i;const c=s*r,g=c+s;a=a.slice(c,g);let p;n.options.paginateExpandedRows?p={rows:a,flatRows:l,rowsById:u}:p=jr({rows:a,flatRows:l,rowsById:u}),p.flatRows=[];const d=f=>{p.flatRows.push(f),f.subRows.length&&f.subRows.forEach(d)};return p.rows.forEach(d),p},R(n.options,"debugTable"))}function _r(){return e=>y(()=>[e.getState().sorting,e.getPreSortedRowModel()],(n,t)=>{if(!t.rows.length||!(n!=null&&n.length))return t;const i=e.getState().sorting,s=[],r=i.filter(u=>{var c;return(c=e.getColumn(u.id))==null?void 0:c.getCanSort()}),a={};r.forEach(u=>{const c=e.getColumn(u.id);c&&(a[u.id]={sortUndefined:c.columnDef.sortUndefined,invertSorting:c.columnDef.invertSorting,sortingFn:c.getSortingFn()})});const l=u=>{const c=u.map(g=>({...g}));return c.sort((g,p)=>{for(let f=0;f<r.length;f+=1){var d;const h=r[f],m=a[h.id],v=m.sortUndefined,S=(d=h?.desc)!=null?d:!1;let j=0;if(v){const C=g.getValue(h.id),k=p.getValue(h.id),T=C===void 0,P=k===void 0;if(T||P){if(v==="first")return T?-1:1;if(v==="last")return T?1:-1;j=T&&P?0:T?v:-v}}if(j===0&&(j=m.sortingFn(g,p,h.id)),j!==0)return S&&(j*=-1),m.invertSorting&&(j*=-1),j}return g.index-p.index}),c.forEach(g=>{var p;s.push(g),(p=g.subRows)!=null&&p.length&&(g.subRows=l(g.subRows))}),c};return{rows:l(t.rows),flatRows:s,rowsById:t.rowsById}},R(e.options,"debugTable","getSortedRowModel",()=>e._autoResetPageIndex()))}function Jt(e,n){return e?Ir(e)?x.createElement(e,n):e:null}function Ir(e){return Fr(e)||typeof e=="function"||kr(e)}function Fr(e){return typeof e=="function"&&(()=>{const n=Object.getPrototypeOf(e);return n.prototype&&n.prototype.isReactComponent})()}function kr(e){return typeof e=="object"&&typeof e.$$typeof=="symbol"&&["react.memo","react.forward_ref"].includes(e.$$typeof.description)}function $r(e){const n={state:{},onStateChange:()=>{},renderFallbackValue:null,...e},[t]=x.useState(()=>({current:yr(n)})),[i,s]=x.useState(()=>t.current.initialState);return t.current.setOptions(r=>({...r,...e,state:{...i,...e.state},onStateChange:a=>{s(a),e.onStateChange==null||e.onStateChange(a)}})),t.current}const Qt=10,nt=10,Zt=new Set(["duration","taskCount","shuffleRead","fetchWait","gcPct","skew","spill"]);function Tr(e,n){return e.length>n?`${e.slice(0,n)}…`:e}function Er(e){return e<=0?o.jsx(o.Fragment,{children:"0"}):o.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e," ",o.jsx(he,{label:"RETRY",impactBand:"critical"})]})}function Pr(e,n){if(e<=0)return o.jsx(o.Fragment,{children:"—"});const t=F(e);if(n<=0)return o.jsx(o.Fragment,{children:t});const i=e/n;return i>.3?o.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t," ",o.jsx(he,{label:`${Math.round(i*100)}%`,impactBand:"critical"})]}):i>.15?o.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t," ",o.jsx(he,{label:`${Math.round(i*100)}%`,impactBand:"info"})]}):o.jsx(o.Fragment,{children:t})}function Nr(e,n){if(!e||e<=0)return o.jsx(o.Fragment,{children:"—"});if(!n||n<=0)return o.jsx(o.Fragment,{children:"—"});const t=n/e,i=t<.01?`${t.toExponential(1)}×`:`${t.toFixed(2)}×`;return t>2||t<.1?o.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[i," ",o.jsx(he,{label:"extreme",impactBand:"info"})]}):o.jsx(o.Fragment,{children:i})}function Mr(e,n){if(e<=0)return o.jsx(o.Fragment,{children:"—"});const t=n==="skew"?"skew":n==="volume"?"vol":"?";return o.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[Y(e)," ",o.jsx(he,{label:t,impactBand:"warning",title:Ii[n??"unclassified"]})]})}function Ar(e,n){return!e||e<=0?0:(n??0)/e}function Lr(e){const n=new Map;for(const t of e){const i=n.get(t.type);(!i||ee[t.impactBand]<ee[i.impactBand])&&n.set(t.type,t)}return[...n.values()]}function Dr({appModel:e,catalog:n,getTaskData:t,onRoute:i}){const{openStage:s}=wt(),[r,a]=x.useState(!0),[l,u]=x.useState(""),[c,g]=x.useState([]),[p,d]=x.useState({pageIndex:0,pageSize:Qt}),{catalogByStage:f,flaggedStageIds:h,frequency:m}=x.useMemo(()=>{const w=new Map,b=new Set;for(const I of n)I.stageId!=null&&(b.add(I.stageId),w.has(I.stageId)||w.set(I.stageId,[]),w.get(I.stageId).push(I));return{catalogByStage:w,flaggedStageIds:b,frequency:_i(n)}},[n]),v=x.useMemo(()=>{const w=[...e.stages.values()],b=r?w.filter($=>h.has($.id)):[...w].sort(($,A)=>(A.completedAt??0)-(A.submittedAt??0)-(($.completedAt??0)-($.submittedAt??0))).slice(0,nt),I=l.trim().toLowerCase();return(I?b.filter($=>($.name??"").toLowerCase().includes(I)||String($.id).includes(I)):b).map($=>({stage:$,tags:Lr(f.get($.id)??[]),frequency:m.get($.id)??0}))},[e.stages,r,h,f,m,l]),S=x.useMemo(()=>{if(!i)return null;const w=new Map;for(const b of n){const I=xe(b,n);I&&w.set(b,I)}return w},[n,i]),j=x.useMemo(()=>[{id:"id",header:"Stage",accessorFn:w=>w.stage.id,cell:({getValue:w})=>{const b=w();return o.jsx("button",{type:"button","aria-label":`Open Stage ${b} details`,className:"inline-flex items-center rounded-sm hover:underline underline-offset-2 focus-visible:outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50",onClick:I=>{I.stopPropagation(),s(b)},children:o.jsx("strong",{children:b})})}},{id:"name",header:"Operation",accessorFn:w=>w.stage.name??"",cell:({row:w})=>{const b=w.original.stage.id;return o.jsxs("span",{className:"inline-flex flex-wrap items-center gap-1.5",children:[Tr(w.original.stage.name??"",40),w.original.tags.map((I,D)=>{const $=S?S.get(I)??null:null,A=$&&i?{target:$,onRoute:i}:null,G=un(I.impactEstimate);return o.jsxs("span",{className:"inline-flex items-center gap-1",children:[A?o.jsx("button",{type:"button","aria-label":`Investigate ${A.target.findingLabel} in Stage ${b}`,title:`Investigate ${A.target.findingLabel} in Stage ${b}`,className:"inline-flex items-center rounded-full hover:underline underline-offset-2 focus-visible:outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50",onClick:se=>{se.stopPropagation(),A.onRoute(A.target)},onKeyDown:se=>{(se.key==="Enter"||se.key===" ")&&se.stopPropagation()},children:o.jsx(pe,{type:I.type,impactBand:I.impactBand,plainBadge:!0})}):o.jsx(pe,{type:I.type,impactBand:I.impactBand}),G?o.jsx("span",{className:"text-xs text-muted-foreground",children:G}):null]},D)})]})}},{id:"type",header:"Type",accessorFn:w=>w.stage.stageType??"",cell:({row:w})=>o.jsx(Ee,{variant:"outline",children:w.original.stage.stageType??"—"})},{id:"duration",header:"Duration",accessorFn:w=>(w.stage.completedAt??0)-(w.stage.submittedAt??0),cell:({getValue:w})=>o.jsx(o.Fragment,{children:F(w())})},{id:"taskCount",header:"Tasks",accessorFn:w=>w.stage.taskCount},{id:"retried",header:"Retried",accessorFn:w=>w.stage.failedTasks??0,cell:({getValue:w})=>Er(w())},{id:"shuffleRead",header:"Shuffle Read",accessorFn:w=>w.stage.shuffleReadBytes??0,cell:({getValue:w})=>o.jsx(o.Fragment,{children:Y(w())})},{id:"fetchWait",header:"Fetch Wait",accessorFn:w=>w.stage.fetchWaitTime??0,cell:({row:w})=>Pr(w.original.stage.fetchWaitTime??0,w.original.stage.executorRunTime??0)},{id:"ioRatio",header:"I/O Ratio",accessorFn:w=>w.stage.inputBytes?(w.stage.outputBytes??0)/w.stage.inputBytes:0,cell:({row:w})=>Nr(w.original.stage.inputBytes??0,w.original.stage.outputBytes??0)},{id:"spill",header:"Spill (mem)",accessorFn:w=>w.stage.memoryBytesSpilled??0,cell:({row:w})=>Mr(w.original.stage.memoryBytesSpilled??0,w.original.stage.spillClassification)},{id:"gcPct",header:"GC%",accessorFn:w=>w.stage.gcPct??0,cell:({getValue:w})=>o.jsxs(o.Fragment,{children:[w().toFixed(1),"%"]})},{id:"skew",header:"Skew P95/median",accessorFn:w=>Ar(w.stage.taskDurationP50,w.stage.taskDurationP95),cell:({getValue:w})=>{const b=w();return o.jsx(o.Fragment,{children:b>0?`${b.toFixed(1)}×`:"—"})}},{id:"frequency",header:"Flagged",accessorFn:w=>w.frequency,cell:({getValue:w})=>{const b=w();return b<=1?o.jsx(o.Fragment,{children:"—"}):o.jsx(Ee,{variant:"outline",children:`Flagged by ${b}`})}}],[n,i,S,s]),C=$r({data:v,columns:j,state:{sorting:c,pagination:p},sortDescFirst:!1,onSortingChange:g,onPaginationChange:d,getCoreRowModel:Rr(),getSortedRowModel:_r(),getPaginationRowModel:br()});function k(){a(w=>!w),g([]),d({pageIndex:0,pageSize:Qt})}const T=w=>w==="asc"?" ▲":w==="desc"?" ▼":"",P=w=>w==="asc"?"ascending":w==="desc"?"descending":"none";return o.jsx(X,{title:"Stage Summary",collapsible:!1,summary:o.jsx(ie,{value:`${h.size} / ${e.stages.size}`,context:"stages flagged"}),children:o.jsxs("div",{className:"space-y-3",children:[o.jsx(dn,{type:"text",value:l,onChange:w=>{u(w.target.value),d(b=>({...b,pageIndex:0}))},placeholder:"Filter by stage name or ID…","aria-label":"Filter by stage name or ID",className:"max-w-xs"}),o.jsxs("div",{className:"flex items-center justify-between gap-2",children:[o.jsx("p",{className:"text-muted-foreground text-xs",children:"Scroll sideways to see all columns →"}),o.jsx(ke,{type:"button",variant:"outline",size:"sm",onClick:k,children:r?`Top ${nt} by duration`:"Problems only"})]}),o.jsxs("p",{className:"sr-only",role:"status","aria-live":"polite",children:["Showing ",v.length," stage",v.length===1?"":"s",": "," ",r?"problems only":`top ${nt} by duration`,"."]}),o.jsxs(Ne,{children:[o.jsx(nn,{children:C.getHeaderGroups().map(w=>o.jsx(U,{children:w.headers.map(b=>{const I=b.column.getIsSorted(),D=b.column.getToggleSortingHandler();return o.jsxs(sn,{scope:"col",tabIndex:b.column.getCanSort()?0:void 0,"aria-sort":P(I),className:N(b.column.getCanSort()&&"tap-target-comfortable cursor-pointer select-none",Zt.has(b.column.id)&&"text-right"),onClick:D,onKeyDown:$=>{D&&($.key==="Enter"||$.key===" ")&&($.preventDefault(),D($))},children:[Jt(b.column.columnDef.header,b.getContext()),T(I)]},b.id)})},w.id))}),o.jsx(Me,{children:C.getRowModel().rows.length===0?o.jsx(U,{children:o.jsx(B,{colSpan:j.length,className:"text-muted-foreground",children:"No stages to show."})}):C.getRowModel().rows.map(w=>o.jsx(U,{className:"cursor-pointer",onClick:()=>s(w.original.stage.id),children:w.getVisibleCells().map(b=>o.jsx(B,{className:Zt.has(b.column.id)?"text-right":void 0,children:Jt(b.column.columnDef.cell,b.getContext())},b.id))},w.id))})]}),C.getPageCount()>1?o.jsxs("div",{className:"flex items-center justify-end gap-2 text-xs",children:[o.jsx(ke,{type:"button",variant:"ghost",size:"sm",className:"tap-target-comfortable",onClick:()=>C.previousPage(),disabled:!C.getCanPreviousPage(),children:"Previous"}),o.jsxs("span",{className:"text-muted-foreground",children:["Page ",p.pageIndex+1," of ",C.getPageCount()]}),o.jsx(ke,{type:"button",variant:"ghost",size:"sm",className:"tap-target-comfortable",onClick:()=>C.nextPage(),disabled:!C.getCanNextPage(),children:"Next"})]}):null]})})}const qn=20,zr=100,en=320,Vr=16;function Br(e,n=qn){const t=[...e].filter(r=>r.submittedAt&&r.completedAt),i=t.length;return i<=n?{stages:t.sort((r,a)=>r.submittedAt-a.submittedAt),total:i,capped:!1}:{stages:[...t].sort((r,a)=>a.completedAt-a.submittedAt-(r.completedAt-r.submittedAt)).slice(0,n).sort((r,a)=>r.submittedAt-a.submittedAt),total:i,capped:!0}}function Or({appModel:e,catalog:n}){const{openStage:t}=wt(),i=[...e.stages.values()].filter(m=>m.submittedAt&&m.completedAt),s=i.length,r=i.reduce((m,v)=>Math.min(m,v.submittedAt),1/0),a=e.app?.startTime??(Number.isFinite(r)?r:0),l=new Set(n.filter(m=>m.stageId!=null).map(m=>m.stageId)),[u,c]=x.useState(()=>s<=zr?s:qn),{stages:g}=Br(i,u),d=Ct(g).map(m=>({stageId:m.id,label:`Stage ${m.id}`,wait:m.submittedAt-a,duration:m.completedAt-m.submittedAt,flagged:l.has(m.id)})),f=Math.max(1,Math.floor(en/Vr)),h=Math.max(1,Math.ceil(d.length/f));return o.jsx(X,{title:"Job Timeline",summary:s>0?o.jsx(ie,{value:`${s} stage${s===1?"":"s"}`,context:`${l.size} flagged`}):void 0,children:s===0?o.jsx("p",{className:"text-muted-foreground text-xs",children:"No stages"}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"mb-2 flex items-center gap-2 text-xs text-muted-foreground",children:[o.jsx("label",{htmlFor:"timeline-topn",children:"showing top"}),o.jsx("input",{id:"timeline-topn",type:"number",min:1,max:s,value:Math.min(u,s),onChange:m=>{let v=parseInt(m.target.value,10);Number.isFinite(v)||(v=u),c(Math.max(1,Math.min(s,v)))},className:"w-16 rounded border border-input bg-transparent px-1 py-0.5","aria-label":"Number of stages to show"}),o.jsxs("span",{children:["of ",s," by duration · flagged in red"]})]}),o.jsx(ye,{ariaLabel:"Job timeline: stage durations by time from app start.",height:en,table:{caption:"Job timeline: stage durations by time from app start",columns:["Stage","Start","Duration"],rows:d.map(m=>[m.label,F(m.wait),F(m.duration)]),align:["left","right","right"]},children:o.jsxs(Ae,{data:d,layout:"vertical",children:[o.jsx(ve,{stroke:M.muted,strokeOpacity:.2,horizontal:!1}),o.jsx(Se,{type:"number",tickFormatter:m=>`${Math.round(m/1e3)}s`,tick:{fontSize:10},tickCount:10}),o.jsx(Ce,{type:"category",dataKey:"label",tick:{fontSize:10},width:64,interval:0,tickFormatter:(m,v)=>v%h===0?m:""}),o.jsx(Le,{formatter:(m,v)=>v==="Duration"?F(Number(m)):[null,null]}),o.jsx(ce,{dataKey:"wait",stackId:"timeline",fill:"transparent",name:"Wait"}),o.jsx(ce,{dataKey:"duration",stackId:"timeline",name:"Duration",cursor:"pointer",onClick:m=>t(m.payload.stageId),children:d.map(m=>o.jsx(mn,{fill:m.flagged?M.critical:M.accent,stroke:m.flagged?M.critical:"none",strokeWidth:m.flagged?2:0},m.stageId))})]})})]})})}const gt={present:"present",disabled:"disabled",notEmitted:"not emitted",notApplicable:"not applicable",outsideEventLog:"outside event log",unknown:"unknown"},Hr={present:"bg-info",disabled:"bg-warning",notEmitted:"bg-warning",notApplicable:"bg-muted-foreground",outsideEventLog:"bg-muted-foreground",unknown:"bg-muted-foreground"};function Gr(e){return Object.keys(gt).map(n=>[n,e.filter(t=>t.state===n).length]).filter(([,n])=>n>0).map(([n,t])=>`${t} ${gt[n]}`).join(" · ")}function qr({entry:e}){const n=e.evidence?.count,t=Fi(),i=`${e.summary}${n!=null?` · ${n} observed`:""}`;return o.jsxs("li",{id:`evidence-availability-${e.key}`,tabIndex:-1,title:i,ref:s=>t(e.key,s),className:"flex items-center justify-between gap-2 rounded-md px-2 py-1 outline-none focus:ring-2 focus:ring-ring",children:[o.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[o.jsx("span",{"aria-hidden":"true",className:N("inline-block size-2 shrink-0 rounded-full",Hr[e.state])}),o.jsx("span",{className:"truncate text-sm font-medium",children:ki(e.key)})]}),o.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:gt[e.state]})]})}function Wr({ledger:e}){const{evidenceCardOpen:n,setEvidenceCardOpen:t}=cn();return o.jsx(X,{title:"Evidence availability",open:n,onOpenChange:t,summary:o.jsx("span",{className:"text-xs text-muted-foreground",children:e?Gr(e.entries):"Unavailable for this restored run"}),children:e?o.jsx("ul",{className:"grid grid-cols-1 gap-x-4 gap-y-0.5 sm:grid-cols-2","aria-label":"Evidence availability ledger",children:e.entries.map(i=>o.jsx(qr,{entry:i},i.key))}):o.jsx("p",{className:"text-xs text-muted-foreground",children:"Evidence availability is unavailable for this restored run."})})}function Ur(e){return[{key:"startup",label:"Startup",value:e.startup,barClassName:"bg-info",swatchClassName:"bg-info"},{key:"stagesActive",label:"Stages active",value:e.stagesActive,barClassName:"bg-clean",swatchClassName:"bg-clean"},{key:"gaps",label:"Scheduler gaps",value:e.gaps,barClassName:"bg-warning",swatchClassName:"bg-warning"},{key:"idle",label:"Idle",value:e.idle,barClassName:"bg-muted-foreground/60",swatchClassName:"bg-muted-foreground/60"}].filter(n=>n.value>0)}const Kr=x.memo(function({appModel:n}){const{app:t,stages:i}=n,s=we(t,i);if(s.total<=0)return null;const r=Ur(s),a=u=>s.total>0?u/s.total*100:0,l=r.reduce((u,c)=>c.value>u.value?c:u,r[0]);return o.jsxs(X,{title:"Wall-Clock Breakdown",badges:o.jsxs("span",{className:"text-xs text-muted-foreground",children:[F(s.total)," total"]}),summary:o.jsx(ie,{value:`${l.label} ${Math.round(a(l.value))}%`,context:`of ${F(s.total)} total`}),children:[o.jsx("div",{role:"img","aria-label":`Wall-clock breakdown: ${F(s.total)} total`,className:"flex h-8 w-full gap-0.5 overflow-hidden rounded-md",children:r.map(u=>o.jsx("div",{title:`${u.label}: ${F(u.value)}`,style:{width:`${a(u.value).toFixed(2)}%`},className:N("flex items-center justify-center truncate text-xs font-medium text-white",u.barClassName),children:a(u.value)>8?u.label:""},u.key))}),o.jsx("div",{className:"mt-3 flex flex-wrap gap-3 text-xs text-muted-foreground",children:r.map(u=>o.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[o.jsx("span",{className:N("inline-block size-2.5 rounded-sm",u.swatchClassName)}),u.label," (",F(u.value),")"]},u.key))})]})}),ft=36e5,Xr=5,it={totalCoreHours:null,usefulCoreHours:null,wastedCoreHours:null,totalCores:null,topStages:[]};function Yr(e,n=[],t){if(!t||e?.startTime==null||e?.endTime==null)return it;const i=e.endTime-e.startTime;if(i<=0)return it;const s=ht(e,n);if(s<=0)return it;const r=s*i/ft,a=(t.busyCoreMs??0)/ft,l=Math.max(0,r-a),u=Object.entries(t.perStage??{}).map(([c,g])=>({stageId:Number(c),coreMs:g?.totalTaskDurationSum??0})).sort((c,g)=>g.coreMs-c.coreMs).slice(0,Xr);return{totalCoreHours:r,usefulCoreHours:a,wastedCoreHours:l,totalCores:s,topStages:u}}const re=e=>`${Math.round(e*100)/100} core-h`;function Jr({appModel:e}){const n=Yr(e.app,e.executors.added,e.runAggregates);if(n.totalCoreHours==null)return null;const t=n.totalCoreHours>0?Math.round(n.wastedCoreHours/n.totalCoreHours*100):0;return o.jsx(X,{title:"Wasted Core-Hours",badges:o.jsx(Ee,{variant:"outline",className:"text-muted-foreground text-xs",title:"This is a design-spike estimate; verify against wall-clock data before acting on it.",children:"low confidence: verify"}),defaultCollapsed:!0,summary:o.jsx(ie,{value:o.jsx("span",{className:"whitespace-nowrap",children:re(n.wastedCoreHours)}),context:`wasted of ${re(n.totalCoreHours)} allocated`}),children:o.jsxs("div",{className:"space-y-2 text-sm",children:[o.jsxs("p",{children:["Allocated: ",o.jsx("strong",{children:re(n.totalCoreHours)})," · Used: ",o.jsx("strong",{children:re(n.usefulCoreHours)})]}),o.jsxs("p",{children:[o.jsx(ue,{impactBand:"info"})," Wasted: ",o.jsx("strong",{children:re(n.wastedCoreHours)})," (",t,"% of allocated)"]}),o.jsxs("p",{className:"text-muted-foreground text-xs",children:["Allocated = ",n.totalCores," cores over the run; used = core-time that actually ran tasks."]}),n.topStages.length>0&&o.jsxs("div",{className:"space-y-1",children:[o.jsx("p",{className:"text-muted-foreground text-xs",children:"Top stages by task core-time"}),o.jsx("ul",{className:"space-y-0.5",children:n.topStages.map(i=>o.jsxs("li",{className:"flex justify-between gap-2",children:[o.jsxs("span",{children:["Stage ",i.stageId]}),o.jsx("span",{className:"text-muted-foreground tabular-nums",children:re(i.coreMs/ft)})]},i.stageId))})]})]})})}function Qr({appModel:e,catalog:n,getTaskData:t,onRoute:i}){return o.jsxs("div",{className:"space-y-6",children:[o.jsx("h2",{className:"sr-only",children:"Full app report"}),o.jsx(Kr,{appModel:e}),o.jsx(Or,{appModel:e,catalog:n}),o.jsx(Dr,{appModel:e,catalog:n,getTaskData:t,onRoute:i}),o.jsxs(xt,{children:[o.jsx(Z,{cardId:"reference-evidence-availability",collapsedTile:!0,children:o.jsx(Wr,{ledger:e.evidenceAvailability})}),o.jsx(Z,{cardId:"reference-etl-phases",collapsedTile:!0,children:o.jsx(Ds,{appModel:e})}),o.jsx(Z,{cardId:"reference-scaling-sim",collapsedTile:!0,children:o.jsx(Ws,{appModel:e})}),o.jsx(Z,{cardId:"reference-efficiency-model",collapsedTile:!0,children:o.jsx(As,{appModel:e})}),o.jsx(Z,{cardId:"reference-wasted-core-hours",collapsedTile:!0,children:o.jsx(Jr,{appModel:e})}),o.jsx(Z,{cardId:"reference-core-usage-histogram",collapsedTile:!0,children:o.jsx(Ms,{appModel:e,getTaskData:t})})]})]})}function Zr({appModel:e,catalog:n,configFindings:t,getTaskData:i,activeFileId:s,options:r,onRoute:a,activeTab:l,onActiveTabChange:u}){const{selection:c}=St(),g=x.useMemo(()=>Nt(n,c),[n,c]),p=x.useMemo(()=>Nt(t??[],c),[t,c]),d=g.length+p.length,f=n.length+(t??[]).length>0&&d===0;return o.jsxs("main",{className:"flex-1 space-y-6 p-4",children:[o.jsx(ws,{options:r,resultCount:d}),f&&o.jsx(gs,{}),o.jsx(Ks,{appModel:e,catalog:g}),!f&&o.jsxs(Yi,{value:l,onValueChange:h=>u(h),children:[o.jsxs(Ji,{variant:"chrome","aria-label":"Report view",children:[o.jsx(Tt,{value:"findings",className:"tap-target-comfortable",children:"Findings"}),o.jsx(Tt,{value:"full-report",className:"tap-target-comfortable",children:"Full app report"})]}),o.jsxs(Et,{value:"findings",keepMounted:!0,children:[o.jsx("h2",{className:"sr-only",children:"Findings"}),o.jsx(bo,{appModel:e,catalog:g,configFindings:p,stages:e.stages,getTaskData:i,activeFileId:s,onRoute:a})]}),o.jsx(Et,{value:"full-report",keepMounted:!0,children:o.jsx(Qr,{appModel:e,catalog:g,getTaskData:i,configFindings:p,activeFileId:s,onRoute:a})})]})]})}function ea(){const{open:e}=Ti(),{resetToDropZone:n,startLoad:t,getTaskData:i}=Ei(),s=Re(_=>_.appModel),r=Re(_=>_.catalog),a=Re(_=>_.activeFileId),{recentEntries:l,onPickRecent:u,onRemoveRecent:c}=Ki(a),[g,p]=x.useState(!1),[d,f]=x.useState("findings"),{referenceOpen:h}=cn(),[m,v]=x.useState(null),[S,j]=x.useState(null),[C,k]=x.useState(null),T=x.useRef(0),P=x.useRef(null),w=x.useRef(null),b=x.useRef(new Map),I=x.useRef(new Map),D=x.useRef(null),$=m?.target??null;x.useEffect(()=>()=>{D.current&&clearTimeout(D.current)},[]),x.useEffect(()=>{h&&f("full-report")},[h]);const A=x.useCallback(_=>{P.current?.token===_&&(P.current=null,w.current=null,v(E=>E?.token===_?null:E))},[]),G=x.useCallback(_=>{if(P.current?.token!==_.token)return null;const{catalog:E,activeFileId:O}=kt.getState();if(w.current!==O)return null;const W=xe(_.target.finding,E);return!W||W.widgetId!==_.target.widgetId||W.region!==_.target.region?null:W},[]),se=x.useCallback(_=>{f("findings");const E=T.current+1;T.current=E;const{catalog:O,activeFileId:W}=kt.getState(),Q=xe(_.finding,O);if(!Q||Q.widgetId!==_.widgetId||Q.region!==_.region){P.current=null,w.current=null,v(null);return}const de={target:Q,token:E};P.current=de,w.current=W,v(de)},[]),Wn=x.useCallback((_,E)=>{b.current.set(_,E);const O=P.current;return O?.target.widgetId===_&&G(O)&&E.open(),()=>{b.current.get(_)===E&&b.current.delete(_)}},[G]),Un=x.useCallback((_,E)=>(I.current.set(_,E),()=>{I.current.get(_)===E&&I.current.delete(_)}),[]),Kn=x.useCallback((_,E)=>{if(!E)return;const O=P.current;if(!O||O.target.widgetId!==_)return;const W=G(O);if(!W){A(O.token);return}const Q=b.current.get(_);if(!Q)return;const de=Q.getDisclosureButton();if(!de){A(O.token);return}const Ft=window.matchMedia("(prefers-reduced-motion: reduce)").matches,He=I.current.get(W.finding);He?(He.scrollIntoView({behavior:Ft?"auto":"smooth",block:"center",inline:"nearest"}),He.focus({preventScroll:!0}),D.current&&clearTimeout(D.current),k(W.finding),D.current=setTimeout(()=>{D.current=null,k(null)},2e3)):(Q.wrapperElement.scrollIntoView({behavior:Ft?"auto":"smooth",block:"start",inline:"nearest"}),de.focus({preventScroll:!0}),j(_)),A(O.token)},[A,G]),Xn=x.useCallback(_=>{j(E=>E===_?null:E)},[]);x.useLayoutEffect(()=>{if(!m)return;const _=G(m);if(!_){A(m.token);return}b.current.get(_.widgetId)?.open()},[A,G,m]),x.useLayoutEffect(()=>{const _=P.current;_&&!G(_)&&A(_.token)},[a,r,A,G]);const Oe=Re(_=>_.configFindings),It=x.useMemo(()=>us(r,Oe),[r,Oe]),Yn=_=>{_.preventDefault(),p(!0)},Jn=()=>p(!1),Qn=_=>{_.preventDefault(),p(!1);const E=_.dataTransfer.files[0];E&&t(E)};return o.jsxs("div",{"data-testid":"dashboard",className:"relative flex min-h-screen flex-col",style:{paddingRight:"var(--docs-inset, 0px)"},onDragOver:Yn,onDragLeave:Jn,onDrop:Qn,children:[o.jsx(Xi,{onOpenDocs:()=>e(),onLoadNew:n,recentEntries:l,activeFileId:a,onPickRecent:u,onRemoveRecent:c}),o.jsx(ds,{options:It,fileId:a,children:o.jsx(Pi,{registerWidget:Wn,registerFindingAnchor:Un,reportWidgetOpen:Kn,clearRouteFocus:Xn,focusedWidgetId:S,activeRouteTarget:$,flashedFinding:C,children:o.jsx(Zr,{appModel:s,catalog:r,configFindings:Oe,getTaskData:i,activeFileId:a,options:It,onRoute:se,activeTab:d,onActiveTabChange:f})})}),o.jsx(Ao,{appModel:s,catalog:r,getTaskData:i}),g&&o.jsx("div",{"aria-hidden":"true",className:"pointer-events-none fixed inset-0 z-50 flex items-center justify-center bg-background/80",children:o.jsx("p",{className:"rounded-lg border-2 border-dashed border-primary px-6 py-4 text-lg font-medium",children:"Drop to load a new event log"})})]})}function ta(){return o.jsx($i,{children:o.jsx(ea,{})})}const ra=Object.freeze(Object.defineProperty({__proto__:null,Dashboard:ta},Symbol.toStringTag,{value:"Module"}));export{ye as C,ko as D,M as a,ra as b,Ct as d};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as h,j as t}from"./react-vendor-u4pyvC5Y.js";import{ar as W,K as S,as as G,at as H,T as b,au as z,av as K,W as Y,R as _,q as X,ax as q,ay as Q,aw as V,Q as J,a0 as U,az as Z,D as ee,aA as te,f as ae}from"./index-4id52G-A.js";import{d as se,C as oe,a as j}from"./Dashboard-D1_IrWRs.js";import{j as ne,C as re,X as ce,Y as le,T as ie,A as me}from"./charts-vendor-NMqKV0H4.js";import"./plan-graph-vendor-vZQHG2EJ.js";import"./useRecentFiles-46iBU9zJ.js";const ue=220,w=["slowHost","stageSlowness","straggler","speculationWaste","coldStart"];function de(a){const s=a.app,c=a.executors.added,l=a.executors.removed;if(s?.startTime==null)return{times:[],counts:[]};const i=(s.endTime??Date.now())-s.startTime,m=Math.max(5e3,Math.floor(i/100)),u=[],p=[],x=new Map(l.map(n=>[n.executorId,n.timestamp]));for(let n=s.startTime;n<=(s.endTime??s.startTime+i);n+=m){const g=c.filter(d=>{const o=x.get(d.executorId)??1/0;return d.timestamp<=n&&n<o}).length;u.push(((n-s.startTime)/1e3).toFixed(0)+"s"),p.push(g)}return{times:u,counts:p}}function pe(a){return w.includes(a)}function xe({finding:a}){const s=q([a]),c=Q([a]),{expanded:l,toggle:i}=V(),m=he(a),u=a.stageId!=null?`Stage ${a.stageId}`:"this issue";return t.jsxs("li",{ref:s,tabIndex:-1,"data-flashed":c?"true":"false",className:`space-y-1 text-sm transition-colors ${te(c)}`,children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx(b,{type:a.type,impactBand:a.impactBand}),a.stageId!=null?t.jsx(J,{pills:[{id:a.stageId}]}):null,m!=null?t.jsx("strong",{children:m}):null]}),t.jsx(U,{finding:a}),t.jsx(Z,{expanded:l,onClick:i,label:u}),l?t.jsxs("p",{className:"text-muted-foreground pt-1",children:[a.recommendation,a.docAnchor?t.jsxs(t.Fragment,{children:[" ",t.jsx(ee,{anchor:a.docAnchor,children:"Learn more →"})]}):null]}):null]})}function he(a){return a.type==="coldStart"?`${a.value}s`:a.type==="speculationWaste"?ae(typeof a.value=="number"?a.value:0):null}const Ie=h.memo(function({appModel:s,catalog:c,activeFileId:l,defaultCollapsed:i=!0}){const{sortMode:m,setSortMode:u,orderBy:p}=W(),[x,n]=h.useState(!i),[g,d]=h.useState(0),o=c.filter(e=>pe(e.type)).slice().sort((e,r)=>S[e.impactBand]-S[r.impactBand]),A=o[0]?.impactBand,f=p(o,e=>[e],e=>e.stageId??null),T=G(),R=T?f.findIndex(e=>e===T.finding):null,{totalPages:B,effectivePage:C,visible:E}=H(f,g,d,R),v=w.filter(e=>o.some(r=>r.type===e)),k=v.length?t.jsxs(t.Fragment,{children:[v.map(e=>t.jsx(b,{type:e,impactBand:o.find(r=>r.type===e).impactBand},e)),z(o)&&o.length>1&&x?t.jsx(K,{mode:m,onChange:u,alternateOrderLabel:"By stage"}):null]}):void 0,{chartData:D,sampled:F,hasSeries:O,peak:P}=h.useMemo(()=>{const{times:e,counts:r}=de(s),y=e.map((N,$)=>({label:N,count:r[$]})),L=se(y),I=r.length>0,M=I?Math.max(...r):0;return{chartData:y,sampled:L,hasSeries:I,peak:M}},[s,l]);return t.jsx(Y,{title:"Executor Timeline",impactBand:A,badges:k,open:x,onOpenChange:n,summary:O?t.jsx(X,{value:`${P} peak`,context:o.length>0?`${o.length} issue${o.length===1?"":"s"} flagged`:"no issues flagged",pills:o.filter(e=>e.stageId!=null).map(e=>({id:e.stageId}))}):void 0,children:t.jsxs("div",{className:"space-y-4",children:[t.jsx(oe,{ariaLabel:"Executor count over time. See the table below for exact values.",height:ue,table:{caption:"Executor timeline: active executor count over time",columns:["Time","Active executors"],rows:D.map(e=>[e.label,e.count]),align:["left","right"]},children:t.jsxs(ne,{data:F,children:[t.jsx(re,{vertical:!1,stroke:j.muted,strokeOpacity:.2}),t.jsx(ce,{dataKey:"label",tick:{fontSize:10},minTickGap:24}),t.jsx(le,{allowDecimals:!1,tick:{fontSize:10},width:32}),t.jsx(ie,{formatter:e=>[`${e} executor${e===1?"":"s"} active`,""],labelFormatter:()=>""}),t.jsx(me,{type:"monotone",dataKey:"count",name:"Active executors",stroke:j.clean,fill:j.clean,fillOpacity:.15})]})}),f.length>0?t.jsxs(t.Fragment,{children:[t.jsx("ul",{className:"space-y-2",children:E.map(e=>t.jsx(xe,{finding:e},e.id))}),t.jsx(_,{page:C,totalPages:B,onPrev:()=>d(e=>e-1),onNext:()=>d(e=>e+1)})]}):null]})})});export{Ie as ExecutorTimeline};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as m,j as e}from"./react-vendor-u4pyvC5Y.js";import{ar as G,as as H,K as u,T as g,J as h,au as Q,av as U,W as P,q as W,at as V,R as X,ax as A,ay as E,aw as O,S as D,a0 as M,az as L,aA as z,f as _}from"./index-4id52G-A.js";import"./charts-vendor-NMqKV0H4.js";import"./plan-graph-vendor-vZQHG2EJ.js";function v(t){return t.stageId!=null}function Y(t){return t.type==="retryWaste"?_(typeof t.value=="number"?t.value:0):t.type==="stageFailed"?"Failed":`${t.value}%`}function Z({finding:t}){const n=A([t]),o=E([t]),{expanded:r,toggle:l}=O();return e.jsxs("li",{ref:n,tabIndex:-1,"data-flashed":o?"true":"false",className:`flex flex-col gap-1 transition-colors ${z(o)}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(D,{stageId:t.stageId}),e.jsx(g,{type:t.type,impactBand:t.impactBand})]}),t.type==="stageFailed"?e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Stage attempt failed outright. Reason: ",e.jsx("strong",{children:String(t.value)})]}):e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Failure rate: ",e.jsxs("strong",{children:[t.value,"%"]})," (",String(t.failedTasks)," tasks) · Dominant reason: ",e.jsx("strong",{children:t.dominantReason??"—"})]}),e.jsx(M,{finding:t}),t.recommendation?e.jsxs(e.Fragment,{children:[e.jsx(L,{expanded:r,onClick:l,label:`stage ${t.stageId} failure`}),r?e.jsx("p",{className:"text-xs text-muted-foreground",children:t.recommendation}):null]}):null]})}function ee({finding:t}){const n=A([t]),o=E([t]),{expanded:r,toggle:l}=O(),i=!!t.extended||!!t.recommendation;return e.jsxs("li",{ref:n,tabIndex:-1,"data-flashed":o?"true":"false",className:`flex flex-col gap-1 transition-colors ${z(o)}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(D,{stageId:t.stageId}),e.jsx(g,{type:"retryWaste",impactBand:t.impactBand})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Wasted ",e.jsx("strong",{children:_(typeof t.value=="number"?t.value:0)})," of executor time."]}),e.jsx(M,{finding:t}),i?e.jsxs(e.Fragment,{children:[e.jsx(L,{expanded:r,onClick:l,label:`stage ${t.stageId} retry waste`}),r?e.jsxs(e.Fragment,{children:[t.extended?e.jsx("p",{className:"text-xs text-muted-foreground",children:String(t.extended)}):null,t.recommendation?e.jsx("p",{className:"text-xs text-muted-foreground",children:t.recommendation}):null]}):null]}):null]})}function $({title:t,findings:n,page:o,setPage:r,routeTarget:l,renderRow:i}){const x=l?n.findIndex(d=>d===l.finding):null,{totalPages:j,effectivePage:f,visible:p}=V(n,o,r,x);return e.jsxs("section",{className:"space-y-2",children:[e.jsx("h3",{className:"font-heading text-sm font-medium",children:t}),e.jsx("ul",{className:"space-y-3",children:p.map(i)}),e.jsx(X,{page:f,totalPages:j,onPrev:()=>r(d=>d-1),onNext:()=>r(d=>d+1)})]})}function ne({appModel:t,catalog:n,defaultCollapsed:o=!0}){const[r,l]=m.useState(0),[i,x]=m.useState(0),{sortMode:j,setSortMode:f,orderBy:p}=G(),[d,B]=m.useState(!o),I=H(),N=m.useRef(!1);m.useEffect(()=>{if(!N.current){N.current=!0;return}l(0),x(0)},[t]);const y=n.filter(v).filter(a=>a.type==="stageFailed"),R=n.filter(v).filter(a=>a.type==="failures"),F=n.filter(v).filter(a=>a.type==="retryWaste"),S=[...y,...R].sort((a,s)=>u[a.impactBand]-u[s.impactBand]||a.stageId-s.stageId),k=[...F].sort((a,s)=>u[a.impactBand]-u[s.impactBand]||(typeof s.value=="number"?s.value:0)-(typeof a.value=="number"?a.value:0)),c=[...S,...k],T=p(S,a=>[a],a=>a.stageId),w=p(k,a=>[a],a=>a.stageId),q=e.jsxs(e.Fragment,{children:[y.length>0&&e.jsx(g,{type:"stageFailed",impactBand:h(y)}),R.length>0&&e.jsx(g,{type:"failures",impactBand:h(R)}),F.length>0&&e.jsx(g,{type:"retryWaste",impactBand:h(F)}),Q(c)&&c.length>1&&d?e.jsx(U,{mode:j,onChange:a=>{f(a),l(0),x(0)},alternateOrderLabel:"By stage"}):null]});if(c.length===0){const a=t.stages.size;let s=0,b=0;for(const C of t.stages.values())s+=C.taskCount??0,b+=C.failedTasks??0;const K=s>0?Math.round(b/s*1e3)/10:0;return e.jsx(P,{title:"Failures",open:d,onOpenChange:B,summary:e.jsx(W,{value:`${K}%`,context:`no issue detected: task failure rate across ${a} stage${a===1?"":"s"}`}),children:e.jsx("p",{className:"text-xs text-muted-foreground",children:"No task failures, stage failures, or retry waste detected."})})}const J=[...c].sort((a,s)=>u[a.impactBand]-u[s.impactBand])[0];return e.jsx(P,{title:"Failures",impactBand:h(c),badges:q,open:d,onOpenChange:B,summary:e.jsx(W,{value:Y(J),context:`${c.length} item${c.length===1?"":"s"} flagged`,pills:c.map(a=>({id:a.stageId}))}),children:e.jsxs("div",{className:"space-y-4",children:[T.length>0&&e.jsx($,{title:"Task & stage failures",findings:T,page:r,setPage:l,routeTarget:I,renderRow:a=>e.jsx(Z,{finding:a},a.id)}),w.length>0&&e.jsx($,{title:"Retry waste",findings:w,page:i,setPage:x,routeTarget:I,renderRow:a=>e.jsx(ee,{finding:a},a.id)})]})})}export{ne as Failures};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as g,j as e}from"./react-vendor-u4pyvC5Y.js";import{ar as R,as as P,J as N,W as S,q as G,T,au as b,av as B,at as E,R as F,ax as $,ay as O,aw as L,S as A,f as M,a0 as W,az as k,aA as J}from"./index-4id52G-A.js";import"./charts-vendor-NMqKV0H4.js";import"./plan-graph-vendor-vZQHG2EJ.js";const V="GC % = total JVM GC time ÷ total executor run time; it can exceed 100% when GC pauses overlap many concurrent task threads.";function j(t){return[...t].sort((s,r)=>(typeof r.value=="number"?r.value:0)-(typeof s.value=="number"?s.value:0))}function q(t){return j(t).map(s=>({id:s.stageId,label:`${s.value}%`}))}function z({finding:t,appModel:s}){const r=$([t]),c=O([t]),{expanded:n,toggle:u}=L(),d=(t.stageId!=null?s.stages.get(t.stageId):void 0)?.executorRunTime;return e.jsxs("li",{ref:r,tabIndex:-1,"data-flashed":c?"true":"false",className:`flex flex-col gap-1 transition-colors ${J(c)}`,children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(A,{stageId:t.stageId})}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["GC: ",e.jsxs("strong",{children:[t.value,"%"]})," · Executor run time:"," ",e.jsx("strong",{children:M(d??0)})]}),e.jsx(W,{finding:t}),e.jsx(k,{expanded:n,onClick:u,label:`stage ${t.stageId}`}),n?e.jsx("p",{className:"text-xs text-muted-foreground",children:t.recommendation}):null]})}function y({title:t,findings:s,appModel:r,page:c,setPage:n,routeTarget:u,orderBy:i}){const d=j(s),x=i(d,a=>[a],a=>a.stageId),m=u?x.findIndex(a=>a===u.finding):null,{totalPages:h,effectivePage:f,visible:p}=E(x,c,n,m);return e.jsxs("section",{className:"space-y-2",children:[e.jsxs("h3",{className:"font-heading text-sm font-medium",children:[t," · ",s.length," stage",s.length===1?"":"s"]}),e.jsx("ul",{className:"space-y-3",children:p.map(a=>e.jsx(z,{finding:a,appModel:r},a.stageId))}),e.jsx(F,{page:f,totalPages:h,onPrev:()=>n(a=>a-1),onNext:()=>n(a=>a+1)})]})}function Q({catalog:t,appModel:s,defaultCollapsed:r=!0}){const[c,n]=g.useState(0),[u,i]=g.useState(0),{sortMode:d,setSortMode:x,orderBy:m}=R(),[h,f]=g.useState(!r),p=P(),a=g.useRef(!1);g.useEffect(()=>{if(!a.current){a.current=!0;return}n(0),i(0)},[s]);const o=t.filter(l=>l.type==="gc");if(o.length===0)return null;const v=o.filter(l=>l.direction!=="low"),w=o.filter(l=>l.direction==="low"),I=N(o),C=j(o)[0];return e.jsx(S,{title:"GC Pressure",impactBand:I,badges:e.jsxs(e.Fragment,{children:[e.jsx(T,{type:"gc",impactBand:I??"info"}),b(o)&&o.length>1&&h?e.jsx(B,{mode:d,onChange:l=>{x(l),n(0),i(0)},alternateOrderLabel:"By stage"}):null]}),open:h,onOpenChange:f,summary:e.jsx(G,{value:`${C.value}%`,context:`${o.length} stage${o.length===1?"":"s"} flagged`,pills:q(o)}),children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:V}),v.length>0&&e.jsx(y,{title:"GC overhead",findings:v,appModel:s,page:c,setPage:n,routeTarget:p,orderBy:m}),w.length>0&&e.jsx(y,{title:"Low GC (cost)",findings:w,appModel:s,page:u,setPage:i,routeTarget:p,orderBy:m})]})})}export{Q as GcPressure};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e}from"./react-vendor-u4pyvC5Y.js";import{W as r,T as a,aw as c,a0 as i,az as d,D as p}from"./index-4id52G-A.js";import"./charts-vendor-NMqKV0H4.js";import"./plan-graph-vendor-vZQHG2EJ.js";function m({finding:s}){const{expanded:o,toggle:n}=c(),{recommendation:t,docAnchor:l}=s;return e.jsxs("div",{className:"flex flex-col gap-1 transition-colors",children:[e.jsxs("p",{className:"text-xs text-muted-foreground",children:["ApplicationEnd event: ",e.jsx("strong",{children:"missing"})]}),e.jsx(i,{finding:s}),e.jsx(d,{expanded:o,onClick:n,label:"Incomplete Run"}),o?e.jsxs("div",{className:"space-y-1 pt-1",children:[e.jsx("p",{children:"This run’s event log never recorded an ApplicationEnd event."}),t?e.jsxs("p",{children:[t,l?e.jsxs(e.Fragment,{children:[" ",e.jsx(p,{anchor:l,children:"Learn more →"})]}):null]}):null]}):null]})}function h({catalog:s,defaultCollapsed:o=!0}){const n=s.find(l=>l.type==="incompleteRun");if(!n)return null;const{impactBand:t}=n;return e.jsx(r,{title:"Incomplete Run",impactBand:t,badges:e.jsx(a,{type:"incompleteRun",impactBand:t}),defaultCollapsed:o,children:e.jsx(m,{finding:n})})}export{h as IncompleteRun};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e}from"./react-vendor-u4pyvC5Y.js";import{W as x,q as m,T as j,aw as b,a0 as f,az as p,D as h}from"./index-4id52G-A.js";import"./charts-vendor-NMqKV0H4.js";import"./plan-graph-vendor-vZQHG2EJ.js";function g({finding:s}){const{expanded:l,toggle:r}=b(),o=s.failedJobs,n=s.totalJobs,i=s.failedTasks,u=s.totalTasks,d=s.taskFailureRate,{value:t,recommendation:c,docAnchor:a}=s;return e.jsxs("div",{className:"flex flex-col gap-1 transition-colors",children:[e.jsxs("p",{children:["Failure rate: ",e.jsxs("strong",{children:[t,"%"]})," (",o," of ",n," completed jobs)"]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Task-failure context: ",i," of ",u," tasks failed (",d,"%)."]}),e.jsx(f,{finding:s}),c?e.jsxs(e.Fragment,{children:[e.jsx(p,{expanded:l,onClick:r,label:"Job Failures"}),l?e.jsxs("p",{children:[c,a?e.jsxs(e.Fragment,{children:[" ",e.jsx(h,{anchor:a,children:"Learn more →"})]}):null]}):null]}):null]})}function v({appModel:s,catalog:l,defaultCollapsed:r=!0}){const o=l.find(t=>t.type==="jobFailureRate");if(!o){const t=[...s.jobs.values()].filter(a=>a.result!=null),c=t.length>0?Math.round(t.filter(a=>a.succeeded===!1).length/t.length*1e3)/10:0;return e.jsx(x,{title:"Job Failures",defaultCollapsed:r,summary:e.jsx(m,{value:`${c}%`,context:"no issue detected: job-failure rate"}),children:e.jsx("p",{className:"text-xs text-muted-foreground",children:"No jobs failed to recover after retries."})})}const{impactBand:n,value:i,failedJobs:u,totalJobs:d}=o;return e.jsx(x,{title:"Job Failures",impactBand:n,badges:e.jsx(j,{type:"jobFailureRate",impactBand:n}),defaultCollapsed:r,summary:e.jsx(m,{value:`${i}%`,context:`${u} of ${d} completed jobs failed`}),children:e.jsx(g,{finding:o})})}export{v as JobFailures};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as u,j as e}from"./react-vendor-u4pyvC5Y.js";import{K as x,as as D,at as L,W as I,J as j,D as k,R as q,q as K,T as N,ax as B,ay as R,aw as w,I as E,a0 as M,az as U,aA as g,E as b}from"./index-4id52G-A.js";import"./charts-vendor-NMqKV0H4.js";import"./plan-graph-vendor-vZQHG2EJ.js";function y(t){return t.type==="utilization"?"Executor utilization":"executorId"in t&&t.executorId!=null?`Executor ${t.executorId}`:t.variant==="idleCores"?"Idle cores":"Memory waste"}function W({finding:t,confidenceId:i}){const o=B([t]),s=R([t]),{expanded:c,toggle:d}=w(),n=t.confidence&&t.confidence!=="high";return t.dataUnavailable?e.jsxs("div",{ref:o,tabIndex:-1,"data-flashed":s?"true":"false",className:`space-y-1 transition-colors ${g(s)}`,children:[e.jsx("p",{className:"text-muted-foreground",children:t.recommendation}),e.jsx(b,{evidenceKey:"executorMetrics"})]}):e.jsxs("div",{ref:o,tabIndex:-1,"data-flashed":s?"true":"false",className:`transition-colors ${g(s)}`,children:[e.jsxs("p",{className:"flex flex-wrap items-start gap-2",children:[e.jsx(E,{impactBand:t.impactBand,className:"mt-1.5"}),e.jsx("strong",{children:y(t)})]}),e.jsx(M,{finding:t}),e.jsx(U,{expanded:c,onClick:d,label:y(t)}),c?e.jsxs("div",{className:"space-y-1",children:[e.jsxs("p",{children:[t.recommendation," ",e.jsx(b,{evidenceKey:"executorMetrics"})]}),n?e.jsxs("p",{className:"text-xs text-muted-foreground",title:t.validationRequired,tabIndex:0,"aria-describedby":i,children:[t.confidence," confidence: verify",e.jsx("span",{id:i,className:"sr-only",children:t.validationRequired})]}):null]}):null]})}function S({finding:t}){const i=B([t]),o=R([t]),{expanded:s,toggle:c}=w();return e.jsxs("div",{ref:i,tabIndex:-1,"data-flashed":o?"true":"false",className:`transition-colors ${g(o)}`,children:[e.jsxs("p",{className:"flex flex-wrap items-start gap-2",children:[e.jsx(E,{impactBand:t.impactBand,className:"mt-1.5"}),e.jsxs("strong",{children:[t.value,"%"]})," average executor utilization"]}),e.jsx(M,{finding:t}),e.jsx(U,{expanded:s,onClick:c,label:"executor utilization"}),s?e.jsx("p",{children:t.recommendation}):null]})}const H=u.memo(function({catalog:i,defaultCollapsed:o=!0}){const s=u.useId(),[c,d]=u.useState(0),{findings:n,utilizationFindings:l,combined:f}=u.useMemo(()=>{const a=i.filter(r=>r.type==="memoryUtilization").sort((r,h)=>x[r.impactBand]-x[h.impactBand]),m=i.filter(r=>r.type==="utilization").sort((r,h)=>x[r.impactBand]-x[h.impactBand]),T=[...a,...m];return{findings:a,utilizationFindings:m,combined:T}},[i]),v=D(),C=v?f.findIndex(a=>a===v.finding):null,{totalPages:F,effectivePage:$,visible:A}=L(f,c,d,C);if(n.length===0&&l.length===0)return e.jsx(I,{title:"Memory Utilization",summary:e.jsx("span",{className:"text-xs text-muted-foreground",children:"No memory utilization issues in this run."}),children:e.jsx("p",{className:"text-xs text-muted-foreground",children:"No memory utilization issues in this run."})});const p=n.find(a=>!a.dataUnavailable)??n[0]??l[0],P=j([...n,...l]),z=n.length+l.length;return e.jsxs(I,{title:"Memory Utilization",impactBand:P,badges:e.jsxs(e.Fragment,{children:[n.length>0&&e.jsx(N,{type:"memoryUtilization",impactBand:j(n)??"info"}),l.length>0&&e.jsx(N,{type:"utilization",impactBand:j(l)??"info"})]}),defaultCollapsed:o,summary:e.jsx(K,{value:y(p),context:`${z} item${z===1?"":"s"} flagged`}),children:[e.jsxs("div",{className:"space-y-2 text-sm",children:[A.map((a,m)=>a.type==="utilization"?e.jsx(S,{finding:a},a.id):e.jsx(W,{finding:a,confidenceId:`${s}-${m}`},a.id)),p.docAnchor?e.jsx("p",{children:e.jsx(k,{anchor:p.docAnchor,children:"Learn more →"})}):null]}),e.jsx(q,{page:$,totalPages:F,onPrev:()=>d(a=>a-1),onNext:()=>d(a=>a+1)})]})});export{H as MemoryUtilization};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as t,j as e}from"./react-vendor-u4pyvC5Y.js";import{aD as i,aE as l,F as o,g as x,aF as d}from"./index-4id52G-A.js";import{r as m,P as c}from"./useRecentFiles-46iBU9zJ.js";function f({stageId:a,appModel:r}){const[s,n]=t.useState(!1);return m(a,r)?e.jsx("div",{className:"space-y-3",children:e.jsxs(i,{open:s,onOpenChange:n,children:[e.jsxs(l,{"aria-expanded":String(s),className:"flex items-center gap-2 bg-transparent text-left",children:[e.jsx("h3",{className:"font-heading text-sm font-medium",children:"Plan context"}),s?e.jsx(o,{"aria-hidden":"true",className:"size-4 shrink-0 text-muted-foreground"}):e.jsx(x,{"aria-hidden":"true",className:"size-4 shrink-0 text-muted-foreground"})]}),e.jsx(d,{keepMounted:!0,children:e.jsx("div",{className:"pt-3",children:e.jsx(c,{stageId:a,appModel:r})})})]})}):null}export{f as P};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as t,r as y}from"./react-vendor-u4pyvC5Y.js";import{s as xe,w as we,C as ae,T as oe,f as be,B as O,u as ye,a as je,b as le}from"./index-4id52G-A.js";import{c as Ne,b as Ie,m as Se,a as re,g as ve,p as Ee,D as Ge,d as De,e as Re,f as ke,h as Ce,u as Pe,r as Oe,T as Me}from"./useRecentFiles-46iBU9zJ.js";import{$ as Z,H as J,P as Q,R as Te,c as $e,B as Be,C as Fe,M as Ae,u as ie,d as ze}from"./plan-graph-vendor-vZQHG2EJ.js";import"./charts-vendor-NMqKV0H4.js";function _e(n){return re(n.name)==="exchange"}function _({id:n,sourceNodeId:l,planNode:o,category:s,segmentIndex:i,splitRole:r,durationShare:a}){return{id:n,sourceNodeId:l,label:o.name,category:s,operatorDetail:Ee(o.name,o.detail??""),primaryMetric:ve(o.metrics),segmentIndex:i,splitRole:r,durationShare:a??null}}function He(n,l){const{scope:o,stageId:s,appModel:i}=l;if(!n)return{nodes:[],edges:[],segmentIndex:null,segmentCount:0,scope:"full",segmentStageIds:new Map};const a=i.stages.get(s)?.sqlExecutionId??null,d=a!=null?i.sql.get(a):null,{segments:c,segOf:w,segmentTopology:h}=Ne(n),j=c.filter(Boolean).length,b=d&&a!=null?Ie(n,i,d,a):null,g=new Map,x=d&&a!=null?xe(a,i.stages):[];if(x.length){const e=new Map;for(const u of x){const p=i.stages.get(u);p&&e.set(u,{submittedAt:p.submittedAt,completedAt:p.completedAt})}for(const[u,p]of Se(c,e,x,h))g.set(u,p)}const v=new WeakMap;let C=0;const D=[],E=[];if(we(n,(e,u)=>{const p=`n${C++}`,m=re(e.name),N=w.get(e),I=u?v.get(u):null;if(_e(e)){const G=`${p}-read`,f=`${p}-write`,T=e.children?.length?w.get(e.children[0]):N;D.push(_({id:G,sourceNodeId:p,planNode:e,category:m,segmentIndex:N,splitRole:"read",durationShare:b?.get(e)})),D.push(_({id:f,sourceNodeId:p,planNode:e,category:m,segmentIndex:T,splitRole:"write"})),E.push({id:`${G}=>${f}`,source:G,target:f}),I&&E.push({id:`${I}->${G}`,source:I,target:G}),v.set(e,f)}else D.push(_({id:p,sourceNodeId:p,planNode:e,category:m,segmentIndex:N,splitRole:null,durationShare:b?.get(e)})),I&&E.push({id:`${I}->${p}`,source:I,target:p}),v.set(e,p)},{dedupe:!0}),o==="full")return{nodes:D,edges:E,segmentIndex:null,segmentCount:j,scope:"full",segmentStageIds:g};let P=null;for(const[e,u]of g)if(u===s){P=e;break}if(P===null)return{nodes:D,edges:E,segmentIndex:null,segmentCount:j,scope:"full",segmentStageIds:g};const k=new Set,R=D.filter(e=>e.segmentIndex!==P?!1:(k.add(e.id),!0)),M=E.filter(e=>k.has(e.source)&&k.has(e.target));return{nodes:R,edges:M,segmentIndex:P,segmentCount:j,scope:"segment",segmentStageIds:g}}const $=220,B=90,ee=24,Le=32,Ye=32,Xe=64,qe=0;function te(n,l,o={}){const s=new Z.graphlib.Graph({compound:!!o.groupOf});s.setGraph({rankdir:"RL",nodesep:40,ranksep:60}),s.setDefaultEdgeLabel(()=>({}));const i=new Set;if(o.groupOf){for(const r of n){const a=o.groupOf(r);a&&i.add(a)}for(const r of i)s.setNode(r,{})}for(const r of n){s.setNode(r.id,{width:$,height:B});const a=o.groupOf?.(r);a&&s.setParent(r.id,a)}for(const r of l)s.setEdge(r.source,r.target);return Z.layout(s),n.map(r=>{const a=s.node(r.id);return{...r,position:{x:a.x-$/2,y:a.y-B/2}}})}function Ue(n,l,o={}){const s=o.paddingX??ee,i=o.paddingY??ee,r=o.headerHeight??Le,a=new Map;for(const d of n){const c=l(d);if(!c)continue;const w=d.position.x,h=d.position.y,j=w+$,b=h+B,g=a.get(c);g?(g.minX=Math.min(g.minX,w),g.minY=Math.min(g.minY,h),g.maxX=Math.max(g.maxX,j),g.maxY=Math.max(g.maxY,b)):a.set(c,{minX:w,minY:h,maxX:j,maxY:b})}return[...a.entries()].map(([d,c])=>({id:d,position:{x:c.minX-s,y:c.minY-i-r},width:c.maxX-c.minX+s*2,height:c.maxY-c.minY+i*2+r}))}function H(n,l,o={}){const s=new Set,i=[];for(const r of l){const a=d=>{const c=n(d);return c&&!s.has(c)?c:null};for(const d of Ue(r,a,o))s.add(d.id),i.push(d)}return i}const ne={scan:"⇩",exchange:"⇄",join:"⋈",aggregate:"Σ",sort:"↕",filter:"∇",aqe:"⚙",boilerplate:"·",transform:"→"};function We({data:n}){const{label:l,operatorDetail:o,primaryMetric:s,category:i,splitRole:r,durationSharePct:a}=n,d=ne[i]??ne.transform;return t.jsxs("div",{className:"relative flex flex-col overflow-hidden rounded-md border border-border bg-card px-3 py-2 text-xs shadow-sm",style:{width:$,height:B},"data-category":i,children:[t.jsx(J,{type:"target",position:Q.Right}),t.jsx(J,{type:"source",position:Q.Left}),r==="read"?t.jsx("p",{className:"truncate text-xs text-muted-foreground",children:"paired: see write half"}):a!=null?t.jsxs("div",{className:"mb-1 h-1.5 shrink-0 overflow-hidden rounded-full bg-plan-aggregate/20",title:"Approximate share of this stage's wall time",children:[t.jsx("div",{"data-testid":"duration-heat-bar-fill",className:"h-full rounded-full bg-plan-aggregate",style:{width:`${a}%`}}),t.jsxs("span",{className:"sr-only",children:[a,"%"]})]}):null,t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{"aria-hidden":"true",className:"shrink-0",children:d}),t.jsx("span",{className:"min-w-0 truncate font-medium",title:l,children:l})]}),o?t.jsx("p",{className:"truncate text-muted-foreground",title:o,children:o}):null,s?t.jsx("p",{className:"truncate text-muted-foreground",title:s,children:s}):null,r!=="read"&&a!=null?t.jsxs("p",{className:"truncate text-muted-foreground",children:[a,"%"]}):null]})}function Ve({data:n}){const{width:l,height:o,stageId:s,durationLabel:i,findings:r}=n;return t.jsx("div",{className:"rounded-lg border border-dashed border-border/70 bg-muted/10 nopan nodrag",style:{width:l,height:o,pointerEvents:"all"},children:t.jsxs("div",{className:"flex flex-wrap items-center gap-2 px-2 py-1 text-xs text-muted-foreground",children:[t.jsx("span",{title:s==null?"This plan segment couldn't be matched to a specific Spark stage":void 0,children:s!=null?`Stage ${s}`:"Stage —"}),t.jsx(ae,{label:i??"—",impactBand:"info",title:"Approximate share of this stage's wall time"}),r.length>0?t.jsx("div",{className:"ml-auto flex flex-wrap items-center justify-end gap-1",children:r.map((a,d)=>t.jsx(oe,{type:a.type,impactBand:a.impactBand,className:"h-4 gap-1 px-1.5 text-xs"},a.id??`${a.type}-${d}`))}):null]})})}function Ke({data:n}){const{width:l,height:o,stageId:s,findings:i,showOwnFindings:r=!0,onSelect:a}=n;return t.jsxs("div",{className:"relative rounded-xl border border-primary/25 bg-primary/5 nopan nodrag",style:{width:l,height:o,pointerEvents:"all"},children:[t.jsx("button",{type:"button","aria-label":`Focus stage ${s}`,onClick:a,style:{pointerEvents:"auto"},className:"absolute inset-0 size-full cursor-pointer rounded-xl transition-colors hover:border-primary/50 hover:bg-primary/10"}),r&&i.length>0?t.jsx("div",{className:"absolute left-2 top-1 flex flex-wrap gap-1",children:i.map((d,c)=>t.jsx(oe,{type:d.type,impactBand:d.impactBand,className:"h-4 gap-1 px-1.5 text-xs"},d.id??`${d.type}-${c}`))}):null,t.jsxs("span",{className:"absolute right-2 bottom-1 text-xs font-medium text-primary/70",children:["Stage ",s]})]})}const Ze={planNode:We,segmentGroup:Ve,stageGroup:Ke},L=n=>n.data;function Je({nodes:n,problemNodes:l}){const{setCenter:o}=ie(),[s,i]=y.useState(null),[r,a]=y.useState(null),d=[...n].filter(h=>L(h).durationSharePct!=null).sort((h,j)=>(L(j).durationSharePct??0)-(L(h).durationSharePct??0)),c=h=>{h&&o(h.position.x,h.position.y,{zoom:1,duration:300})},w=(h,j,b)=>{if(h.length===0)return;const g=j?h.findIndex(v=>v.id===j):-1,x=h[(g+1)%h.length];c(x),b(x.id)};return t.jsxs(ze,{position:"top-left",className:"flex gap-2",children:[t.jsx(O,{type:"button",variant:"outline",size:"sm",disabled:d.length===0,onClick:()=>w(d,s,i),children:"Next worst duration"}),l.length>0?t.jsx(O,{type:"button",variant:"outline",size:"sm",onClick:()=>w(l,r,a),children:"Next problem"}):null]})}function Qe({resizeTick:n}){const{fitView:l}=ie();return y.useEffect(()=>{const o=()=>l({duration:200});return window.addEventListener("resize",o),()=>window.removeEventListener("resize",o)},[l]),y.useEffect(()=>{n!==0&&l({duration:200})},[n,l]),null}function et(){const n=y.useRef(null),[l,o]=y.useState(0);return y.useEffect(()=>{const s=n.current;if(!s)return;let i=!0;const r=new ResizeObserver(()=>{if(i){i=!1;return}o(a=>a+1)});return r.observe(s),()=>r.disconnect()},[]),{ref:n,tick:l}}function Y(n,l){return n.filter(o=>o.stageId===l||o.stageIds?.includes(l))}function tt({model:n,showMiniMap:l,findings:o=[],stageId:s,segmentStageIds:i,visibleNodeIds:r,visibleEdges:a,onSelectStage:d}){const{flowNodes:c,flowEdges:w}=y.useMemo(()=>{const b=n.nodes.reduce((e,u)=>e+(u.durationShare??0),0),g=e=>`segment-${e.segmentIndex}`,x=te(n.nodes,n.edges,{groupOf:g}),v=r?te(n.nodes.filter(e=>r.has(e.id)),a??n.edges,{groupOf:g}):x,C=v.map(e=>{const u=e.durationShare!=null&&b>0?Math.round(e.durationShare/b*100):null,p=e.splitRole==="read"?`${e.label}, paired: see write half`:[e.label,e.operatorDetail,e.primaryMetric,u!=null?`${u}% of stage duration`:null].filter(Boolean).join(", ");return{id:e.id,type:"planNode",position:e.position,measured:{width:$,height:B},ariaLabel:p,data:{...e,durationSharePct:u}}}),D=n.scope==="full",E=H(g,[v,x]).map(e=>{const u=Number(e.id.replace("segment-","")),p=x.filter(f=>g(f)===e.id),m=p.reduce((f,T)=>f+(T.durationShare??0),0),N=p.some(f=>f.durationShare!=null),I=i?.get(u)??null,G=I!=null?Y(o,I):[];return{id:e.id,type:"segmentGroup",position:e.position,draggable:!1,selectable:!1,zIndex:-1,style:{width:e.width,height:e.height},measured:{width:e.width,height:e.height},data:{width:e.width,height:e.height,stageId:I,durationLabel:N?be(m):null,findings:G}}}),P=new Set(E.map(e=>e.data.stageId).filter(e=>e!=null)),k=e=>{const u=i?.get(e.segmentIndex);return u!=null?`stage-${u}`:null},R=D?(()=>{const e={paddingX:Ye,paddingY:Xe,headerHeight:qe},u=H(k,[v,x],e),p=`stage-${s}`;if(Y(o,s).length>0&&!u.some(m=>m.id===p)){const[m]=H(()=>p,[v,x],e);m&&u.push(m)}return u.map(m=>{const N=Number(m.id.replace("stage-",""));return{id:m.id,type:"stageGroup",position:m.position,draggable:!1,selectable:!1,zIndex:-2,style:{width:m.width,height:m.height},measured:{width:m.width,height:m.height},data:{width:m.width,height:m.height,stageId:N,findings:Y(o,N),showOwnFindings:!P.has(N),onSelect:()=>d?.(N)}}})})():[],M=(a??n.edges).map(e=>({id:e.id,source:e.source,target:e.target}));return{flowNodes:[...R,...E,...C],flowEdges:M}},[n,o,s,i,r,a,d]),{ref:h,tick:j}=et();return t.jsx("div",{className:"flex-1",ref:h,children:t.jsx(Te,{children:t.jsxs($e,{nodes:c,edges:w,nodeTypes:Ze,fitView:!0,edgesFocusable:!1,children:[t.jsx(Be,{}),t.jsx(Fe,{}),t.jsx(Je,{nodes:c.filter(b=>b.type==="planNode"),problemNodes:c.filter(b=>b.type==="stageGroup"&&(b.data.findings?.length??0)>0)}),t.jsx(Qe,{resizeTick:j}),l?t.jsx(Ae,{nodeColor:"var(--plan-aggregate)",pannable:!0,zoomable:!0,ariaLabel:"Plan overview. Drag to pan and scroll to zoom the graph."}):null]})})})}const nt=[{value:"io",label:"I/O only"},{value:"basic",label:"Basic"},{value:"advanced",label:"Advanced"}];function st({mode:n,onChange:l,hiddenCount:o}){return t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1.5",role:"radiogroup","aria-label":"Node filter",children:[nt.map(s=>t.jsxs("label",{className:"tap-target-comfortable flex min-h-8 items-center gap-1.5 px-1 text-sm",children:[t.jsx("input",{type:"radio",name:"plan-graph-filter",value:s.value,checked:n===s.value,onChange:()=>l(s.value)}),s.label]},s.value)),o>0?t.jsx(ae,{label:`${o} nodes hidden`,impactBand:"info"}):null]})}function at({open:n,nodeCount:l,onConfirm:o,onCancel:s}){return t.jsx(Ge,{open:n,onOpenChange:i=>{i||s()},children:t.jsxs(De,{children:[t.jsx(Re,{children:t.jsx(ke,{children:"Expand to full plan?"})}),t.jsxs("p",{className:"text-sm text-muted-foreground",children:["This plan has ",l," nodes. Rendering the full graph may take several seconds."]}),t.jsxs(Ce,{children:[t.jsx(O,{type:"button",variant:"outline",size:"sm",onClick:s,children:"Cancel"}),t.jsx(O,{type:"button",size:"sm",onClick:o,children:"Expand anyway"})]})]})})}const ot={io:["scan","exchange"],basic:["scan","exchange","join","aggregate","sort","filter"],advanced:null},X=300;function lt(n,l){const o=new Map;for(const a of n){const d=o.get(a.source);d?d.push(a.target):o.set(a.source,[a.target])}const s=new Map;function i(a){const d=s.get(a);if(d)return d;const c=new Set;s.set(a,c);for(const w of o.get(a)??[])if(l.has(w))c.add(w);else for(const h of i(w))c.add(h);return c}const r=[];for(const a of l)for(const d of i(a))r.push({id:`${a}=>${d}`,source:a,target:d});return r}function rt(n,l){try{return He(n,l)}catch{return null}}const U=new Map;function it(n,l,o){return`${n??"none"}::${l}::${o}`}function dt(){U.clear()}let se=le.getState().modelResetCount;le.subscribe(n=>{n.modelResetCount!==se&&(se=n.modelResetCount,dt())});function q(n,l,o){const s=it(o,l.stageId,l.scope),i=U.get(s);if(i)return i;const r=rt(n,l);return r&&U.set(s,r),r}function ht({stageId:n,appModel:l,findings:o,activeFileId:s,onClose:i,initialScope:r}){const{open:a}=ye(),{resetToDropZone:d}=je(),{recentEntries:c,onPickRecent:w,onRemoveRecent:h}=Pe(s),[j,b]=y.useState("basic"),[g,x]=y.useState(r??"segment"),[v,C]=y.useState(!1),[D,E]=y.useState(r!=="full"),[P,k]=y.useState(!1),[R,M]=y.useState(n),e=Oe(R,l),u=e?q(e,{scope:"segment",stageId:R,appModel:l},s):null,p=u!=null&&u.scope==="full"&&g==="segment"&&u.nodes.length>X,m=p&&!P;y.useEffect(()=>{m&&C(!0)},[m]);const N=e&&(g==="full"||v)?q(e,{scope:"full",stageId:R,appModel:l},s):null,I=!D&&g==="full"&&N!=null&&N.nodes.length>X,G=v||I;y.useEffect(()=>{const S=K=>{K.key==="Escape"&&!G&&i()};return window.addEventListener("keydown",S),()=>window.removeEventListener("keydown",S)},[i,G]);const f=p||I?null:g==="full"?N:u;function T(){const S=e?q(e,{scope:"full",stageId:R,appModel:l},s):null;S&&S.nodes.length>X?C(!0):x("full")}function de(){x("segment")}function ce(S){M(S),x("segment"),E(!0),k(!1)}function ue(){E(!0),x("full"),C(!1)}function ge(){C(!1),I&&(E(!0),x("segment"),u?.scope==="full"&&k(!0)),m&&k(!0)}function pe(S){return i(),w(S)}const W=ot[j],F=new Set;if(f)for(const S of f.nodes)(!W||W.includes(S.category))&&F.add(S.id);const fe=f?lt(f.edges,F):[],he=f?f.nodes.filter(S=>!F.has(S.id)):[],A=f?.scope==="full",me=g==="full",V=y.useId(),z=A&&!me;return t.jsxs("div",{className:"flex h-screen flex-col",style:{paddingRight:"var(--docs-inset, 0px)"},children:[t.jsx(Me,{onOpenDocs:a,onLoadNew:d,recentEntries:c,activeFileId:s,onPickRecent:pe,onRemoveRecent:h,sectionControls:t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("h1",{className:"truncate font-heading text-sm font-semibold",children:["Plan graph — Stage ",R]}),f&&f.scope==="segment"?t.jsxs("p",{className:"truncate text-xs text-muted-foreground",children:["Segment ",f.segmentIndex+1," of ",f.segmentCount]}):null]}),f?t.jsx(st,{mode:j,onChange:b,hiddenCount:he.length}):null,t.jsxs("div",{className:"flex flex-col items-end gap-0.5",children:[t.jsx(O,{type:"button",variant:"outline",size:"sm",disabled:z,"aria-describedby":z?V:void 0,onClick:A?de:T,children:A?"Back to segment view":"Expand to full plan"}),z?t.jsx("p",{id:V,className:"text-xs text-muted-foreground",children:"This stage's plan couldn't be scoped to a single segment"}):null]}),t.jsx(O,{variant:"ghost",size:"sm",onClick:i,children:"Close"})]})}),t.jsx("div",{className:"flex flex-1 flex-col gap-4 overflow-hidden p-6",children:I?null:!e||!f?t.jsx("p",{role:"alert",className:"text-sm text-destructive",children:p?'This plan has more nodes than the graph view can safely render without expanding. Click "Expand to full plan" to confirm.':"Couldn't build the plan graph for this stage."}):t.jsx(tt,{model:f,visibleNodeIds:F,visibleEdges:fe,showMiniMap:f.scope==="full",findings:o,stageId:R,segmentStageIds:f.segmentStageIds,onSelectStage:ce})}),t.jsx(at,{open:G,nodeCount:N?.nodes.length??0,onConfirm:ue,onCancel:ge})]})}export{ht as PlanGraphRoute,dt as clearPlanGraphModelCache,lt as collapseHiddenEdges};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{X as J,j as e,Y as V,Z as W,_ as U,$ as q,a0 as Z,a1 as G,a2 as H,a3 as K,a4 as Q,a5 as X,a6 as Y,a7 as ee,r as w}from"./react-vendor-u4pyvC5Y.js";import{g as T,d as x,F as te,ar as se,as as ae,K as B,at as ne,W as y,q as F,Z as m,J as N,au as ie,Q as re,R as oe,aB as _,T as E,av as le,ax as de,ay as ce,aw as ue,aC as fe,S as ge,a0 as k,az as pe,aA as me}from"./index-4id52G-A.js";import{C as xe}from"./useRecentFiles-46iBU9zJ.js";import{P as he}from"./PlanExplorer-DKUwF0uz.js";import"./charts-vendor-NMqKV0H4.js";import"./plan-graph-vendor-vZQHG2EJ.js";const ve=J;function je({className:s,...n}){return e.jsx(U,{"data-slot":"select-value",className:x("flex flex-1 text-left",s),...n})}function Se({className:s,size:n="default",children:i,...u}){return e.jsxs(V,{"data-slot":"select-trigger","data-size":n,className:x("flex w-fit items-center justify-between gap-1.5 rounded-lg border border-input bg-transparent py-2 pr-2 pl-2.5 text-sm whitespace-nowrap transition-colors outline-none select-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-[3px] aria-invalid:ring-destructive/20 data-placeholder:text-muted-foreground data-[size=default]:h-8 data-[size=sm]:h-7 data-[size=sm]:rounded-[min(var(--radius-md),10px)] *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",s),...u,children:[i,e.jsx(W,{render:e.jsx(T,{className:"pointer-events-none size-4 text-muted-foreground"})})]})}function be({className:s,children:n,side:i="bottom",sideOffset:u=4,align:g="center",alignOffset:r=0,alignItemWithTrigger:f=!0,...d}){return e.jsx(q,{children:e.jsx(Z,{side:i,sideOffset:u,align:g,alignOffset:r,alignItemWithTrigger:f,className:"isolate z-50",children:e.jsxs(G,{"data-slot":"select-content","data-align-trigger":f,className:x("relative isolate z-50 max-h-(--available-height) w-(--anchor-width) min-w-36 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[align-trigger=true]:animate-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",s),...d,children:[e.jsx(we,{}),e.jsx(H,{children:n}),e.jsx(Be,{})]})})})}function Ie({className:s,children:n,...i}){return e.jsxs(K,{"data-slot":"select-item",className:x("relative flex w-full cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",s),...i,children:[e.jsx(Q,{className:"flex flex-1 shrink-0 gap-2 whitespace-nowrap",children:n}),e.jsx(X,{render:e.jsx("span",{className:"pointer-events-none absolute right-2 flex size-4 items-center justify-center"}),children:e.jsx(xe,{className:"pointer-events-none"})})]})}function we({className:s,...n}){return e.jsx(Y,{"data-slot":"select-scroll-up-button",className:x("top-0 z-10 flex w-full cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4",s),...n,children:e.jsx(te,{})})}function Be({className:s,...n}){return e.jsx(ee,{"data-slot":"select-scroll-down-button",className:x("bottom-0 z-10 flex w-full cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4",s),...n,children:e.jsx(T,{})})}function ze({entry:s,appModel:n}){const i=[s.shuffle,...s.partitions].filter(c=>c!==null),u=de(i),g=ce(i),{expanded:r,toggle:f}=ue(),d=n.stages.get(s.stageId),h=d?fe(d):null;return e.jsxs("div",{ref:u,tabIndex:-1,"data-flashed":g?"true":"false",className:`space-y-2 border-t border-border pt-3 first:border-t-0 first:pt-0 transition-colors ${me(g)}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ge,{stageId:s.stageId}),e.jsx("span",{className:"text-sm text-muted-foreground",children:d?.name??""})]}),s.shuffle?e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"text-sm",children:["Shuffle read: ",e.jsx("strong",{children:m(typeof s.shuffle.value=="number"?s.shuffle.value:0)})," · ","Write: ",m(d?.shuffleWriteBytes??0)]}),e.jsx(k,{finding:s.shuffle})]}):s.partitions.length>0?e.jsx(k,{finding:s.partitions[0]}):null,e.jsx(pe,{expanded:r,onClick:f,label:`Stage ${s.stageId}`}),r?e.jsxs("div",{className:"space-y-2 pt-1",children:[h?e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Try ",e.jsxs("code",{children:["spark.sql.shuffle.partitions = ",h.recommended]}),": current"," ",h.current," tasks, target 128 MB per partition"]}):null,s.partitions.length>0?e.jsx("ul",{className:"list-disc space-y-1 pl-5 text-xs text-muted-foreground",children:s.partitions.map((c,S)=>e.jsxs("li",{children:[c.recommendation," ",e.jsx(k,{finding:c})]},S))}):null,e.jsx(he,{stageId:s.stageId,appModel:n})]}):null]})}const Fe=w.memo(function({appModel:n,catalog:i,defaultCollapsed:u=!0}){const[g,r]=w.useState(0),{sortMode:f,setSortMode:d,orderBy:h}=se(),[c,S]=w.useState(!u),z=ae(),{shuffleFindings:v,partitionFindings:j,sorted:o,orderedEntries:b}=w.useMemo(()=>{const a=i.filter(t=>t.type==="shuffle"),p=i.filter(t=>t.type==="partitionSizing"),I=new Map;for(const t of a)t.stageId!=null&&I.set(t.stageId,{stageId:t.stageId,shuffle:t,partitions:[],impactBand:t.impactBand,peak:typeof t.value=="number"?t.value:0});for(const t of p){if(t.stageId==null)continue;const l=I.get(t.stageId);l?(l.partitions.push(t),B[t.impactBand]<B[l.impactBand]&&(l.impactBand=t.impactBand)):I.set(t.stageId,{stageId:t.stageId,shuffle:null,partitions:[t],impactBand:t.impactBand,peak:0})}const R=[...I.values()].sort((t,l)=>B[t.impactBand]-B[l.impactBand]||l.peak-t.peak),L=h(R,t=>[t.shuffle,...t.partitions].filter(l=>l!==null),t=>t.stageId);return{shuffleFindings:a,partitionFindings:p,sorted:R,orderedEntries:L}},[i,f]),$=z?b.findIndex(a=>a.shuffle===z.finding||a.partitions.includes(z.finding)):null,{totalPages:O,effectivePage:P,visible:M}=ne(b,g,r,$);if(v.length===0&&j.length===0){let a=0;for(const p of n.stages.values())a=Math.max(a,p.shuffleReadBytes??0);return e.jsx(y,{title:"Shuffle I/O",open:c,onOpenChange:S,summary:e.jsx(F,{value:m(a),context:"no issue detected: peak shuffle read"}),children:e.jsx("p",{className:"text-xs text-muted-foreground",children:"No shuffle read/write or partition-sizing issues detected."})})}const A=N([...v,...j]),C=b.map(a=>({id:a.stageId,label:m(a.peak)})),D=ie([...v,...j])&&o.length>1;return e.jsx(y,{title:"Shuffle I/O",impactBand:A,badges:e.jsxs(e.Fragment,{children:[v.length>0&&e.jsx(E,{type:"shuffle",impactBand:N(v)??"info"}),j.length>0&&e.jsx(E,{type:"partitionSizing",impactBand:N(j)??"info"}),D&&c?e.jsx(le,{mode:f,onChange:a=>{d(a),r(0)},alternateOrderLabel:"By stage"}):null]}),open:c,onOpenChange:S,summary:e.jsx(F,{value:o[0].shuffle?m(o[0].peak):`Partition sizing · Stage ${o[0].stageId}`,context:o[0].shuffle?`Peak shuffle read · ${o.length} stage${o.length===1?"":"s"} flagged`:`${o.length} stage${o.length===1?"":"s"} flagged`,pills:C}),children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(re,{pills:C}),M.map(a=>e.jsx(ze,{entry:a,appModel:n},a.stageId)),e.jsx(oe,{page:P,totalPages:O,onPrev:()=>r(a=>a-1),onNext:()=>r(a=>a+1),renderJumpControl:()=>e.jsxs(ve,{value:String(P*_),onValueChange:a=>r(Math.floor(Number(a)/_)),children:[e.jsx(Se,{size:"sm","aria-label":"Jump to stage",children:e.jsx(je,{placeholder:"Jump to stage"})}),e.jsx(be,{children:b.map((a,p)=>e.jsxs(Ie,{value:String(p),children:["Stage ",a.stageId," (",m(a.peak),")"]},a.stageId))})]})})]})})});export{Fe as ShuffleIO};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e,r as h}from"./react-vendor-u4pyvC5Y.js";import{D as z,I as f,Z as d,ar as K,K as w,as as H,at as W,W as P,R as q,q as Y,T as F,au as X,av as U,ax as V,ay as Z,aw as J,aC as Q,C as ee,a2 as se,S as te,a0 as ae,az as re,aA as ie}from"./index-4id52G-A.js";import{w as ne,x as le,y as N,z as T}from"./useRecentFiles-46iBU9zJ.js";import{d as oe,C as A,a as u}from"./Dashboard-D1_IrWRs.js";import{h as ce,C as k,X as L,Y as C,T as R,S as de,g as me,i as pe,B as xe,L as ue}from"./charts-vendor-NMqKV0H4.js";import{P as ge}from"./PlanExplorer-DKUwF0uz.js";import"./plan-graph-vendor-vZQHG2EJ.js";const M=240,he=500*1024*1024,fe=10;function G(s){const a=s.spillBytes>he,r=s.gcPct>fe;return a&&r?"critical":a||r?"warning":"info"}function je(s){return u[G(s)]}function ye({active:s,payload:a}){if(!s||!a?.length)return null;const r=a[0]?.payload;if(!r)return null;const n=G(r);return e.jsxs("div",{className:"rounded-md border border-border bg-popover px-2 py-1.5 text-xs text-popover-foreground shadow-md",children:[e.jsxs("p",{children:[d(r.spillBytes)," spilled"]}),e.jsxs("p",{children:[r.gcPct.toFixed(1),"% GC"]}),e.jsxs("p",{className:"mt-1 flex items-center gap-1.5 font-medium",children:[e.jsx(f,{impactBand:n}),n.toUpperCase()]})]})}function Se({appModel:s}){const a=[];for(const t of s.stages.values()){const o=t.memoryBytesSpilled??0;o<=0||a.push({stageId:t.id,spillBytes:o,gcPct:t.gcPct??0,submittedAt:t.submittedAt??0})}if(a.length===0)return e.jsx("p",{className:"text-muted-foreground text-xs",children:"No stages spilled memory in this run."});const r=oe(a),n=[...r].sort((t,o)=>t.submittedAt-o.submittedAt).map(t=>({stage:`S${t.stageId}`,spillMB:t.spillBytes/(1024*1024),gcPct:t.gcPct}));return e.jsxs(ne,{defaultValue:"scatter",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs(le,{"aria-label":"Memory pressure view",children:[e.jsx(N,{value:"scatter",children:"Scatter"}),e.jsx(N,{value:"twin",children:"Twin bars"})]}),e.jsx(z,{anchor:"#memory-model",children:"Learn more →"})]}),e.jsxs(T,{value:"scatter",children:[e.jsxs("div",{className:"mb-1 flex items-center gap-3 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(f,{impactBand:"critical"}),"CRITICAL"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(f,{impactBand:"warning"}),"WARNING"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(f,{impactBand:"info"}),"INFO"]})]}),e.jsx(A,{ariaLabel:"Memory pressure scatter: spilled memory versus GC percent, one point per stage that spilled.",height:M,table:{caption:"Memory spilled and GC percent by stage",columns:["Stage","Memory spilled","GC %"],rows:r.map(t=>[`S${t.stageId}`,d(t.spillBytes),`${t.gcPct.toFixed(1)}%`]),align:["left","right","right"]},children:e.jsxs(ce,{children:[e.jsx(k,{stroke:u.muted,strokeOpacity:.2}),e.jsx(L,{type:"number",dataKey:"spillBytes",name:"Memory spilled",tickFormatter:t=>d(t),tick:{fontSize:10}}),e.jsx(C,{type:"number",dataKey:"gcPct",name:"GC %",tick:{fontSize:10},width:32}),e.jsx(R,{cursor:{strokeDasharray:"3 3"},content:ye}),e.jsx(de,{data:r,name:"Spill vs. GC",children:r.map(t=>e.jsx(me,{fill:je(t)},t.stageId))})]})})]}),e.jsx(T,{value:"twin",children:e.jsx(A,{ariaLabel:"Memory pressure by stage: spilled memory and GC percent across stages in submission order.",height:M,table:{caption:"Spilled memory and GC percent by stage, submission order",columns:["Stage","Spill (MB)","GC %"],rows:n.map(t=>[t.stage,t.spillMB.toFixed(1),`${t.gcPct.toFixed(1)}%`]),align:["left","right","right"]},children:e.jsxs(pe,{data:n,children:[e.jsx(k,{stroke:u.muted,strokeOpacity:.2}),e.jsx(L,{dataKey:"stage",tick:{fontSize:10}}),e.jsx(C,{yAxisId:"left",tick:{fontSize:10},width:36}),e.jsx(C,{yAxisId:"right",orientation:"right",tick:{fontSize:10},width:36}),e.jsx(R,{}),e.jsx(xe,{yAxisId:"left",dataKey:"spillMB",name:"Spill (MB)",fill:u.critical}),e.jsx(ue,{yAxisId:"right",dataKey:"gcPct",name:"GC %",stroke:u.info,dot:!1})]})})})]})}const Ce={skew:"skew",volume:"vol",unclassified:"?"};function be(s,a){return s.stages.get(a)?.spillClassification??"unclassified"}function Be({finding:s,appModel:a}){const r=V([s]),n=Z([s]),{expanded:t,toggle:o}=J(),p=a.stages.get(s.stageId),m=be(a,s.stageId),x=m==="volume"&&p?Q(p):null,j=s.confidence&&s.confidence!=="high";return e.jsxs("div",{ref:r,tabIndex:-1,"data-flashed":n?"true":"false",className:`space-y-2 border-t border-border pt-3 first:border-t-0 first:pt-0 transition-colors ${ie(n)}`,children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(F,{type:"spill",impactBand:s.impactBand}),e.jsx(ee,{label:Ce[m],impactBand:s.impactBand,title:se[m]}),e.jsx(te,{stageId:s.stageId})]}),e.jsxs("p",{className:"text-sm",children:["Memory spilled: ",e.jsx("strong",{children:d(typeof s.value=="number"?s.value:0)})," · ","Disk: ",d(p?.diskBytesSpilled??0)]}),e.jsx(ae,{finding:s}),e.jsx(re,{expanded:t,onClick:o,label:`Stage ${s.stageId}`}),t?e.jsxs("div",{className:"space-y-2 pt-1",children:[x?e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Try: ",e.jsxs("code",{children:["spark.sql.shuffle.partitions = ",x.recommended]}),` (current ${x.current} tasks, target 128 MB per partition)`]}):null,s.recommendation?e.jsx("p",{className:"text-xs text-muted-foreground",children:s.recommendation}):null,j?e.jsxs("p",{className:"text-xs text-muted-foreground",children:[s.confidence," confidence: verify: ",s.validationRequired]}):null,e.jsx(ge,{stageId:s.stageId,appModel:a})]}):null]})}const ke=h.memo(function({appModel:a,catalog:r,defaultCollapsed:n=!0}){const{sortMode:t,setSortMode:o,orderBy:p}=K(),[m,x]=h.useState(!n),[j,y]=h.useState(0),{findings:b,sorted:c,orderedFindings:B}=h.useMemo(()=>{const i=r.filter(l=>l.type==="spill"&&l.stageId!=null),g=[...i].sort((l,S)=>(w[l.impactBand]??9)-(w[S.impactBand]??9)||(typeof S.value=="number"?S.value:0)-(typeof l.value=="number"?l.value:0)),$=p(g,l=>[l],l=>l.stageId);return{findings:i,sorted:g,orderedFindings:$}},[r,t]),v=H(),O=v?B.findIndex(i=>i===v.finding):null,{totalPages:_,effectivePage:D,visible:E}=W(B,j,y,O);if(b.length===0){let i=0;for(const g of a.stages.values())i=Math.max(i,g.memoryBytesSpilled??0);return e.jsx(P,{title:`Spill: no issue detected (max ${d(i)} spilled)`,children:e.jsx("p",{className:"text-xs text-muted-foreground",children:"No stage spilled memory in this run."})})}const I=c[0].impactBand;return e.jsx(P,{title:"Spill",impactBand:I,badges:e.jsxs(e.Fragment,{children:[e.jsx(F,{type:"spill",impactBand:I}),X(b)&&c.length>1&&m?e.jsx(U,{mode:t,onChange:o,alternateOrderLabel:"By stage"}):null]}),open:m,onOpenChange:x,summary:e.jsx(Y,{value:d(typeof c[0].value=="number"?c[0].value:0),context:`peak · ${c.length} stage${c.length===1?"":"s"}`,pills:c.map(i=>({id:i.stageId}))}),children:e.jsxs("div",{className:"space-y-4",children:[E.map(i=>e.jsx(Be,{finding:i,appModel:a},i.stageId)),e.jsx(q,{page:D,totalPages:_,onPrev:()=>y(i=>i-1),onNext:()=>y(i=>i+1)}),e.jsx(Se,{appModel:a})]})})});export{ke as Spill};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as k,j as e}from"./react-vendor-u4pyvC5Y.js";import{ar as A,J as P,K as T,as as H,at as L,W as M,R as C,q as G,au as _,av as O,aw as F,ax as W,ay as q,S as z,T as J,a0 as K,f as I,I as B,az as U,aA as Y}from"./index-4id52G-A.js";import{D as Q}from"./Dashboard-D1_IrWRs.js";import{P as V}from"./PlanExplorer-DKUwF0uz.js";import"./charts-vendor-NMqKV0H4.js";import"./plan-graph-vendor-vZQHG2EJ.js";import"./useRecentFiles-46iBU9zJ.js";const X=new Set(["skew","stageShape","tinyTask"]),Z={lowParallelism:"Low parallelism",dataExplosion:"Data explosion",taskStageSkew:"Task/stage skew"};function ss(s){if(s.type==="skew")return`${s.metric}: ${s.value}×`;if(s.type==="stageShape"){const r=typeof s.rule=="string"?s.rule:void 0;return`${(r&&Z[r])??s.metric??"stage shape"}: ${s.value}`}return s.type==="tinyTask"?`P50 ${s.value}ms across many small tasks`:`${s.metric??s.type}: ${s.value??""}`}function es({group:s,appModel:r,getTaskData:l}){const{expanded:p,data:d,error:j,toggle:c}=F(()=>l(s.stageId)),u=W(s.findings),h=q(s.findings),n=r.stages.get(s.stageId);return e.jsxs("div",{ref:u,tabIndex:-1,"data-flashed":h?"true":"false",className:`space-y-2 border-b border-border pb-3 last:border-b-0 last:pb-0 transition-colors ${Y(h)}`,children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(z,{stageId:s.stageId}),e.jsx("span",{className:"text-sm font-medium",children:n?.name??`Stage ${s.stageId}`})]}),e.jsx("ul",{className:"flex flex-col gap-1.5",children:s.findings.map((o,w)=>e.jsxs("li",{className:"flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(J,{type:o.type,impactBand:o.impactBand}),e.jsx("span",{children:ss(o)}),e.jsx(K,{finding:o})]},w))}),n?.taskDurationP50!=null?e.jsxs("p",{className:"text-xs text-muted-foreground",children:["P50 ",I(n.taskDurationP50)," · P95 ",I(n.taskDurationP95)," · Max"," ",I(n.taskDurationMax)]}):null,s.slowHost?e.jsxs("p",{className:"flex items-start gap-2 text-xs",children:[e.jsx(B,{impactBand:s.slowHost.impactBand,className:"mt-1"}),e.jsxs("span",{children:[e.jsx("strong",{children:"Slow host:"})," ",s.slowHost.host," (",s.slowHost.value,"× median,"," ",Math.round((s.slowHost.hostTaskShare??0)*100),"% of tasks)"]})]}):null,s.straggler?e.jsxs("p",{className:"flex items-start gap-2 text-xs",children:[e.jsx(B,{impactBand:s.straggler.impactBand,className:"mt-1"}),e.jsxs("span",{children:[e.jsx("strong",{children:"Stragglers:"})," ",(s.straggler.speculativeTasks??0)>0?`${s.straggler.speculativeTasks} speculative task${s.straggler.speculativeTasks===1?"":"s"}`:`${s.straggler.value}% of tasks > 4× P50`]})]}):null,e.jsx(U,{expanded:p,onClick:c,label:`Stage ${s.stageId}`}),p?e.jsxs("div",{className:"space-y-3 pt-1",children:[d?e.jsx(Q,{metrics:d.metrics,fieldNames:d.fieldNames,markers:{p50:n?.taskDurationP50,p95:n?.taskDurationP95}}):j?e.jsx("p",{className:"text-xs text-muted-foreground",children:"Task data unavailable for this stage."}):e.jsx("p",{className:"text-xs text-muted-foreground",children:"Loading task data…"}),e.jsx(V,{stageId:s.stageId,appModel:r})]}):null]})}const ds=k.memo(function({appModel:r,catalog:l,getTaskData:p,defaultCollapsed:d=!0}){const[j,c]=k.useState(0),{sortMode:u,setSortMode:h,orderBy:n}=A(),[o,w]=k.useState(!d),{relevant:g,stageGroups:f,orderedGroups:S}=k.useMemo(()=>{const t=l.filter(a=>X.has(a.type)),i=new Map;for(const a of t)a.stageId!=null&&(i.has(a.stageId)||i.set(a.stageId,[]),i.get(a.stageId).push(a));const y=[...i.entries()].map(([a,m])=>({stageId:a,findings:m,impactBand:P(m)??"info",slowHost:l.find(x=>x.type==="slowHost"&&x.stageId===a),straggler:l.find(x=>x.type==="straggler"&&x.stageId===a)})).sort((a,m)=>T[a.impactBand]-T[m.impactBand]||a.stageId-m.stageId),R=n(y,a=>a.findings,a=>a.stageId);return{relevant:t,stageGroups:y,orderedGroups:R}},[l,u]),v=H(),N=v?S.findIndex(t=>t.findings.some(i=>i===v.finding)):null,{totalPages:b,effectivePage:$,visible:D}=L(S,j,c,N);if(g.length===0)return null;const E=P(g);return e.jsxs(M,{title:"Task Skew & Shape",impactBand:E,badges:_(g)&&f.length>1&&o?e.jsx(O,{mode:u,onChange:h,alternateOrderLabel:"By stage"}):void 0,open:o,onOpenChange:w,summary:e.jsx(G,{value:`${f.length} stage${f.length===1?"":"s"}`,context:`${g.length} finding${g.length===1?"":"s"} flagged`,pills:f.map(t=>({id:t.stageId}))}),children:[e.jsx("div",{className:"space-y-3",children:D.map(t=>e.jsx(es,{group:t,appModel:r,getTaskData:p},t.stageId))}),e.jsx(C,{page:$,totalPages:b,onPrev:()=>c(t=>t-1),onNext:()=>c(t=>t+1)})]})});export{ds as TaskSkew};
|