@divami-artefacts/ai-design-system 1.0.3 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai-design-system.css +2 -0
- package/dist/canvas/canvasUtils.d.ts +41 -14
- package/dist/components/trend/Trend.d.ts +2 -0
- package/dist/components/trend/index.d.ts +2 -0
- package/dist/components/trend/styles.d.ts +1 -0
- package/dist/components/trend/types.d.ts +5 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +967 -886
- package/dist/types/index.d.ts +9 -6
- package/package.json +1 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
.trend-scroll{scrollbar-width:thin;scrollbar-color:#22262f #0c0e12}.trend-scroll::-webkit-scrollbar{height:6px}.trend-scroll::-webkit-scrollbar-track{background:#0c0e12;border-radius:3px}.trend-scroll::-webkit-scrollbar-thumb{background-color:#22262f;border-radius:3px}.trend-scroll::-webkit-scrollbar-thumb:hover{background-color:#334155}
|
|
2
|
+
/*$vite$:1*/
|
|
@@ -3,23 +3,50 @@
|
|
|
3
3
|
* Ported from enterprise-brain/src/canvas/utils.js + theme/tokens.js
|
|
4
4
|
*/
|
|
5
5
|
export declare const CC: {
|
|
6
|
-
readonly bg: "#
|
|
6
|
+
readonly bg: "#0C0E12";
|
|
7
7
|
readonly bgL: "#0C1420";
|
|
8
|
-
readonly sf: "#
|
|
9
|
-
readonly bd: "#
|
|
10
|
-
readonly blue: "#
|
|
11
|
-
readonly cyan: "#
|
|
12
|
-
readonly orange: "#
|
|
13
|
-
readonly red: "#
|
|
14
|
-
readonly green: "#
|
|
15
|
-
readonly purple: "#
|
|
16
|
-
readonly amber: "#
|
|
17
|
-
readonly t1: "#
|
|
18
|
-
readonly t2: "#
|
|
19
|
-
readonly t3: "#
|
|
8
|
+
readonly sf: "#13161B";
|
|
9
|
+
readonly bd: "#22262F";
|
|
10
|
+
readonly blue: "#2970FF";
|
|
11
|
+
readonly cyan: "#36BFFA";
|
|
12
|
+
readonly orange: "#EF6820";
|
|
13
|
+
readonly red: "#D92D20";
|
|
14
|
+
readonly green: "#16B364";
|
|
15
|
+
readonly purple: "#7A5AF8";
|
|
16
|
+
readonly amber: "#FAC515";
|
|
17
|
+
readonly t1: "#F7F7F7";
|
|
18
|
+
readonly t2: "#94979C";
|
|
19
|
+
readonly t3: "#94979C";
|
|
20
20
|
readonly t4: "#334155";
|
|
21
21
|
};
|
|
22
|
-
export declare const PALETTE: ("#
|
|
22
|
+
export declare const PALETTE: ("#2970FF" | "#36BFFA" | "#D92D20" | "#16B364" | "#7A5AF8" | "#FAC515")[];
|
|
23
|
+
/**
|
|
24
|
+
* Axis label style — applied to all x-axis and y-axis tick labels, titles, and legends.
|
|
25
|
+
* Change once here to update every chart.
|
|
26
|
+
* color: #94979C (CC.t2)
|
|
27
|
+
* font-family: Satoshi Variable, DM Sans (SANS fallback)
|
|
28
|
+
* font-size: 12px
|
|
29
|
+
* font-weight: 400
|
|
30
|
+
* line-height: 18px (informational — not applicable in canvas ctx.font)
|
|
31
|
+
*/
|
|
32
|
+
export declare const AXIS_LABEL: {
|
|
33
|
+
readonly font: "400 12px 'Satoshi Variable', 'DM Sans', sans-serif";
|
|
34
|
+
readonly color: "#94979C";
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Legend label style — applied to all chart legend items (swatches, keys, footers).
|
|
38
|
+
* Change once here to update every chart legend.
|
|
39
|
+
* color: #94979C (CC.t2)
|
|
40
|
+
* font-family: Satoshi Variable, DM Sans (SANS fallback)
|
|
41
|
+
* font-size: 12px
|
|
42
|
+
* font-weight: 400
|
|
43
|
+
* line-height: 18px (informational — not applicable in canvas ctx.font)
|
|
44
|
+
* text-align: center (set ctx.textAlign = 'center' at the draw call site)
|
|
45
|
+
*/
|
|
46
|
+
export declare const LEGEND_LABEL: {
|
|
47
|
+
readonly font: "400 12px 'Satoshi Variable', 'DM Sans', sans-serif";
|
|
48
|
+
readonly color: "#94979C";
|
|
49
|
+
};
|
|
23
50
|
/** Convert hex + alpha to rgba string */
|
|
24
51
|
export declare function rgb(hex: string, alpha?: number): string;
|
|
25
52
|
/** Linear interpolation between two values */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const containerStyle: React.CSSProperties;
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require(`react-dom/client`),t=require(`react`),n=require(`react/jsx-runtime`);function r({children:e,className:t=``}){return(0,n.jsx)(`div`,{className:`d3-chart ${t}`.trim(),children:e})}var i={bg:`#070B12`,bgL:`#0C1420`,sf:`#111B28`,bd:`#1C2D42`,blue:`#3B8BF6`,cyan:`#22D3EE`,orange:`#F0813A`,red:`#F06060`,green:`#34D399`,purple:`#A78BFA`,amber:`#FBBF24`,t1:`#F1F5F9`,t2:`#94A3B8`,t3:`#64748B`,t4:`#334155`},a=[i.blue,i.cyan,i.amber,i.purple,i.green,i.red];function o(e,t=1){let n=e.replace(`#`,``);return`rgba(${parseInt(n.substring(0,2),16)},${parseInt(n.substring(2,4),16)},${parseInt(n.substring(4,6),16)},${t})`}function s(e,t,n){return e+(t-e)*n}function c(e,t,n){let r=e=>{let t=e.replace(`#`,``);return[parseInt(t.substring(0,2),16),parseInt(t.substring(2,4),16),parseInt(t.substring(4,6),16)]},[i,a,o]=r(e),[c,l,u]=r(t),d=e=>Math.max(0,Math.min(255,Math.round(e)));return[d(s(i,c,n)),d(s(a,l,n)),d(s(o,u,n))].map(e=>e.toString(16).padStart(2,`0`)).join(``).replace(/^/,`#`)}function l(e,t,n,r=2){e.width=t*r,e.height=n*r;let i=e.getContext(`2d`);return i.scale(r,r),i}function u(e,t,n,r,i,a=.3){let s=e.createRadialGradient(t,n,0,t,n,r);s.addColorStop(0,o(i,a)),s.addColorStop(1,o(i,0)),e.fillStyle=s,e.beginPath(),e.arc(t,n,r,0,Math.PI*2),e.fill()}function d(e,t,n,r,a=50,s=o(i.blue,.05)){for(let i=0;i<a;i++)e.beginPath(),e.arc((Math.sin(r*.001+i*23)*.5+.5)*t,(Math.cos(r*8e-4+i*37)*.5+.5)*n,.6,0,Math.PI*2),e.fillStyle=s,e.fill()}function f(e,t,n,r,i=.015){e.fillStyle=`rgba(0,0,0,${i})`;let a=r*.5%6;for(let r=a;r<n;r+=3)e.fillRect(0,r,t,1)}function p(e,t,n,r,a=o(i.t1,.08)){e.strokeStyle=a,e.lineWidth=1,e.setLineDash([3,3]),e.beginPath(),e.moveTo(t,n),e.lineTo(t,r),e.stroke(),e.setLineDash([])}function m({visible:e,x:r,y:a,content:o,parentW:s}){let c=(0,t.useRef)(null);if((0,t.useLayoutEffect)(()=>{let t=c.current;if(!t)return;let n=t.offsetWidth,l=r-n/2,u=a-58;l<4&&(l=4),l+n>(s??400)-4&&(l=(s??400)-n-4),u<4&&(u=a+16),t.style.transform=`translate(${l}px, ${u}px)`,t.style.opacity=e?`1`:`0`;let d=o&&typeof o==`object`&&o.color?o.color:i.blue;t.style.setProperty(`--tooltip-accent`,d??i.blue)},[e,r,a,s,o]),!o)return null;let l=typeof o==`object`,u=l?o.label:null,d=l?o.value:o,f=l?o.sublabel:null;return(0,n.jsxs)(`div`,{ref:c,style:{position:`absolute`,top:0,left:0,minWidth:80,pointerEvents:`none`,background:i.sf,border:`1px solid ${i.bd}`,borderLeft:`2px solid var(--tooltip-accent)`,borderRadius:6,padding:`6px 10px`,opacity:0,transition:`opacity 0.15s ease`,zIndex:20,fontFamily:`'JetBrains Mono', monospace`},children:[u&&(0,n.jsx)(`div`,{style:{fontFamily:`'DM Sans', sans-serif`,fontSize:10,color:i.t3,marginBottom:2,whiteSpace:`nowrap`},children:u}),(0,n.jsx)(`div`,{style:{fontSize:11,color:i.t1,fontWeight:600,whiteSpace:`nowrap`},children:d}),f&&(0,n.jsx)(`div`,{style:{fontSize:9,color:`var(--tooltip-accent)`,marginTop:2,whiteSpace:`nowrap`},children:f})]})}function h(e,{width:n,height:r,onClick:i,enabled:a=!0}){let o=(0,t.useRef)({x:-1,y:-1,over:!1}),s=(0,t.useRef)(null),c=(0,t.useRef)([]),l=(0,t.useRef)(null),[u,d]=(0,t.useState)({visible:!1,x:0,y:0,content:null}),f=(0,t.useCallback)((e,t,n)=>{l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{d({visible:!0,x:e,y:t,content:n})},30)},[]),p=(0,t.useCallback)(()=>{l.current&&clearTimeout(l.current),d(e=>e.visible?{visible:!1,x:e.x,y:e.y,content:e.content}:e)},[]);return(0,t.useEffect)(()=>{let t=e.current;if(!t||!a)return;let u=e=>{let i=t.getBoundingClientRect(),a=n/i.width,l=r/i.height;o.current.x=(e.clientX-i.left)*a,o.current.y=(e.clientY-i.top)*l,o.current.over=!0;let u=null,d=c.current;for(let e=d.length-1;e>=0;e--)if(d[e].test(o.current.x,o.current.y)){u=d[e];break}let m=s.current;s.current=u?u.id:null,t.style.cursor=u?`pointer`:`default`,u?f((e.clientX-i.left)*a,(e.clientY-i.top)*l,u.data):m&&p()},d=()=>{o.current={x:-1,y:-1,over:!1},s.current&&(s.current=null,t.style.cursor=`default`,p())},m=()=>{if(s.current&&i){let e=c.current.find(e=>e.id===s.current);e&&i(e.id,e.data)}};return t.addEventListener(`mousemove`,u),t.addEventListener(`mouseleave`,d),t.addEventListener(`click`,m),()=>{t.removeEventListener(`mousemove`,u),t.removeEventListener(`mouseleave`,d),t.removeEventListener(`click`,m),l.current&&clearTimeout(l.current)}},[e,n,r,a,i,f,p]),{mouseRef:o,hoveredRef:s,tooltip:u,showTooltip:f,hideTooltip:p,hitZonesRef:c}}function g(e,t,n,r,i,a){e.push({id:t,data:a,test:(e,t)=>(e-n)**2+(t-r)**2<=i*i})}function _(e,t,n,r,i,a,o){e.push({id:t,data:o,test:(e,t)=>e>=n&&e<=n+i&&t>=r&&t<=r+a})}var v=e=>1-(1-e)**3,y=e=>1-(1-e)**4,b=e=>e===1?1:1-2**(-10*e),x=e=>{let t=1.70158;return 1+(t+1)*(e-1)**3+t*(e-1)**2},S=(e,t=.04,n=.001)=>Math.sin(e*t)*Math.exp(-Math.min(e*n,4)),C=(e,t,n,r=v)=>{let i=Math.min(.06,.5/n),a=t*i,o=1-(n-1)*i;return r(Math.max(0,Math.min((e-a)/o,1)))};function w(e,t,n=.12){e.forEach((r,i)=>{let a=i===t?1:0,o=r+(a-r)*n;Math.abs(o-a)<.005?a===0?e.delete(i):e.set(i,1):e.set(i,o)}),t&&!e.has(t)&&e.set(t,0)}var T=760,E=250;function D({rows:e=[],variant:a,className:s,colors:c}){let d=(0,t.useRef)(null),f=(0,t.useRef)(new Map),_=(0,t.useRef)(0),{mouseRef:v,hoveredRef:y,tooltip:x,hitZonesRef:C}=h(d,{width:T,height:E});return(0,t.useEffect)(()=>{let t=d.current;if(!t)return;let n=l(t,T,E);_.current=0;let r=c?.line??i.blue,s=c?.point??i.blue,m=c?.axisLine??i.bd,h=c?.areaFill??i.blue,x={top:24,right:24,bottom:44,left:24},D=T-x.left-x.right,O=E-x.top-x.bottom,k,A=()=>{_.current++;let t=_.current;if(n.clearRect(0,0,T,E),e.length<2){k=requestAnimationFrame(A);return}let c=e.map(e=>e.pricing??0),l=Math.max(100,...c),d=t=>x.left+t/(e.length-1)*D,j=e=>x.top+(1-e/l)*O,M=b(Math.min(t/48,1)),N=Math.max(2,Math.floor(M*e.length));w(f.current,y.current),C.current=[],n.strokeStyle=o(i.bd,.2),n.lineWidth=.5;for(let e=0;e<=4;e++){let t=x.top+e/4*O;n.beginPath(),n.moveTo(x.left,t),n.lineTo(x.left+D,t),n.stroke()}if(n.strokeStyle=o(m,.4),n.lineWidth=1,n.setLineDash([]),n.beginPath(),n.moveTo(x.left,j(0)),n.lineTo(x.left+D,j(0)),n.stroke(),v.current.over&&y.current){let e=parseInt(y.current.split(`-`)[1]);isNaN(e)||p(n,d(e),x.top,x.top+O)}if(a===`area`&&N>1){let t=n.createLinearGradient(0,x.top,0,x.top+O);t.addColorStop(0,o(h,.12)),t.addColorStop(1,o(h,0)),n.fillStyle=t,n.beginPath(),n.moveTo(d(0),x.top+O);for(let t=0;t<N;t++)n.lineTo(d(t),j(e[t].pricing??0));n.lineTo(d(N-1),x.top+O),n.closePath(),n.fill()}if(N>1){n.strokeStyle=o(r,.85),n.lineWidth=2,n.setLineDash([]),n.beginPath();for(let t=0;t<N;t++){let r=d(t),i=j(e[t].pricing??0);t===0?n.moveTo(r,i):n.lineTo(r,i)}n.stroke()}for(let r=0;r<N;r++){let c=d(r),l=j(e[r].pricing??0),p=`sc-${r}`,m=f.current.get(p)??0,h=r===e.length-1;g(C.current,p,c,l,12,{label:e[r].vendor,value:String(e[r].pricing??0),color:h?i.red:s}),m>0&&u(n,c,l,16*m,s,.2*m);let _=h?S(t,.05,5e-4):0,v=a===`area`?5:6;h?(n.shadowColor=o(i.red,.5),n.shadowBlur=(8+_*4)*(1+m*.5),n.fillStyle=i.red,n.beginPath(),n.arc(c,l,(v+_*1.5)*(1+m*.3),0,Math.PI*2),n.fill(),n.shadowBlur=0):(n.fillStyle=o(s,.7+m*.3),n.beginPath(),n.arc(c,l,v+m*2,0,Math.PI*2),n.fill()),n.font=`10px 'JetBrains Mono', monospace`,n.fillStyle=o(i.t3,.6+m*.3),n.textAlign=`center`,n.fillText(e[r].vendor,c,E-14)}k=requestAnimationFrame(A)};return A(),()=>cancelAnimationFrame(k)},[e,a,c]),(0,n.jsx)(r,{className:s,children:(0,n.jsxs)(`div`,{style:{position:`relative`,width:T,height:E},children:[(0,n.jsx)(`canvas`,{ref:d,role:`img`,"aria-label":`${a} chart`,style:{width:T,height:E,display:`block`,borderRadius:8}}),(0,n.jsx)(m,{...x,parentW:T,parentH:E})]})})}function O({rows:e=[],className:t,colors:r}){return(0,n.jsx)(D,{rows:e,variant:`area`,className:t,colors:r})}var k=760,A=280;function j({rows:e=[],className:s,colors:c}){let d=(0,t.useRef)(null),f=(0,t.useRef)(new Map),p=(0,t.useRef)(0),{hoveredRef:g,tooltip:v,hitZonesRef:b}=h(d,{width:k,height:A});return(0,t.useEffect)(()=>{let t=d.current;if(!t)return;let n=l(t,k,A);p.current=0;let r=c?.bars??a,s=c?.axisLine??i.bd,m=c?.valueLabel??i.t2,h={top:24,right:24,bottom:56,left:24},v=A-h.top-h.bottom,x=(k-h.left-h.right)/Math.max(e.length,1),S=Math.max(100,...e.map(e=>e.pricing??0)),T=h.top+v,E,D=()=>{p.current++;let t=p.current;n.clearRect(0,0,k,A);let a=y(Math.min(t/48,1));w(f.current,g.current),b.current=[],n.strokeStyle=o(s,.4),n.lineWidth=1,n.setLineDash([]),n.beginPath(),n.moveTo(h.left,T),n.lineTo(k-h.right,T),n.stroke(),e.forEach((t,s)=>{let c=h.left+s*x,l=C(a,s,e.length,y),d=S>0?(t.pricing??0)/S*v:0,p=Math.max(d>0?4:0,d*l),g=r[s%r.length],w=f.current.get(t.id??`bar-${s}`)??0;_(b.current,t.id??`bar-${s}`,c+4,T-p,x-8,p,{label:t.vendor,value:String(t.pricing??0),color:g}),p>0&&(w>0&&u(n,c+x/2,T-p/2,x*.8,g,.12*w),n.shadowColor=o(g,.2*(w>0?w:0)),n.shadowBlur=w>0?6:0,n.fillStyle=o(g,.5+w*.25),n.beginPath(),n.roundRect(c+4,T-p,x-8,p,[4,4,0,0]),n.fill(),n.shadowBlur=0,w>0&&(n.strokeStyle=o(g,.4*w),n.lineWidth=1,n.beginPath(),n.roundRect(c+4,T-p,x-8,p,[4,4,0,0]),n.stroke())),l>.5&&p>0&&(n.globalAlpha=Math.min(1,(l-.5)*2),n.font=`bold 10px 'JetBrains Mono', monospace`,n.fillStyle=w>0?g:o(m,.7),n.textAlign=`center`,n.fillText(String(t.pricing??``),c+x/2,T-p-6),n.globalAlpha=1),n.font=`${w>0?`bold `:``}9px 'JetBrains Mono', monospace`,n.fillStyle=w>0?g:o(i.t3,.6),n.textAlign=`center`,n.fillText(t.vendor,c+x/2,A-14)}),E=requestAnimationFrame(D)};return D(),()=>cancelAnimationFrame(E)},[e,c]),(0,n.jsx)(r,{className:s,children:(0,n.jsxs)(`div`,{style:{position:`relative`,width:k,height:A},children:[(0,n.jsx)(`canvas`,{ref:d,role:`img`,"aria-label":`bar chart`,style:{width:k,height:A,display:`block`,borderRadius:8}}),(0,n.jsx)(m,{...v,parentW:k,parentH:A})]})})}var M=680,N=300,ee=[i.green,i.blue,i.cyan,i.amber,i.red];function te({contractors:e=[],"data-testid":r}){let a=(0,t.useRef)(null),s=(0,t.useRef)(0),c=(0,t.useRef)(new Map),p=[...e].sort((e,t)=>(t.percentage??0)-(e.percentage??0)),{hoveredRef:_,tooltip:y,hitZonesRef:b}=h(a,{width:M,height:N});return(0,t.useEffect)(()=>{let e=a.current;if(!e)return;let t=l(e,M,N);s.current=0;let n=M*.13,r=M*.08,m=N*.08,h=N*.14,y=M-n-r,x,S=()=>{s.current++;let e=s.current;t.clearRect(0,0,M,N),b.current=[],c.current.forEach((e,t)=>{let n=t===_.current?1:0,r=e+(n-e)*.12;Math.abs(r-n)<.005?n===0?c.current.delete(t):c.current.set(t,1):c.current.set(t,r)}),_.current&&!c.current.has(_.current)&&c.current.set(_.current,0),d(t,M,N,e,40,o(i.blue,.04)),p.forEach((r,a)=>{let s=ee[a%ee.length],l=c.current.get(r.id)??0,d=m+a*(h+10);t.fillStyle=o(s,.04+l*.04),t.beginPath(),t.roundRect(n,d,y,h,3),t.fill(),t.strokeStyle=o(s,.08),t.lineWidth=1,t.setLineDash([4,4]),t.beginPath(),t.moveTo(n,d+h/2),t.lineTo(n+y,d+h/2),t.stroke(),t.setLineDash([]);let f=(r.percentage??0)/100,p=n+y*Math.min(f,f*v(Math.min(1,e*.005)));if(p>n+4){let e=t.createLinearGradient(n,0,p,0);e.addColorStop(0,o(s,.02)),e.addColorStop(1,o(s,.25+l*.15)),t.fillStyle=e,t.beginPath(),t.roundRect(n,d+2,p-n,h-4,2),t.fill()}u(t,p,d+h/2,18+l*8,s,.3+l*.2),t.beginPath(),t.arc(p,d+h/2,5+l*2,0,Math.PI*2),t.fillStyle=o(s,.9),t.fill(),g(b.current,r.id,p,d+h/2,14,{label:r.name,value:`${r.percentage??0}% commitment`,sublabel:`Base: £${r.base??0}M · Variations: £${r.variation??0}M`,color:s}),t.font=`bold 10px 'JetBrains Mono', monospace`,t.fillStyle=o(s,.9+l*.1),t.textAlign=`left`,t.textBaseline=`middle`,t.fillText(`${r.percentage??0}%`,p+10,d+h/2),t.font=`${l>0?`bold `:``}10px 'JetBrains Mono', monospace`,t.fillStyle=l>0?s:o(i.t2,.8),t.textAlign=`right`,t.fillText(r.abbreviation??r.name.slice(0,6),n-8,d+h/2)}),t.strokeStyle=o(i.t3,.3),t.lineWidth=1,t.setLineDash([]),t.beginPath(),t.moveTo(n+y,m),t.lineTo(n+y,m+(p.length-1)*(h+10)+h),t.stroke(),f(t,M,N,e,.015),x=requestAnimationFrame(S)};return S(),()=>cancelAnimationFrame(x)},[p]),(0,n.jsxs)(`div`,{"data-testid":r,style:{position:`relative`,width:M,height:N},children:[(0,n.jsx)(`canvas`,{ref:a,role:`img`,"aria-label":`Commitment race — contractors ranked by commitment percentage`,style:{width:M,height:N,display:`block`,borderRadius:8}}),(0,n.jsx)(m,{...y,parentW:M,parentH:N})]})}var ne=480,re=340;function ie({pct:e,confirmed:r,total:a,"data-testid":s}){let c=(0,t.useRef)(null),d=(0,t.useRef)(0);return(0,t.useEffect)(()=>{let t=c.current;if(!t)return;let n=l(t,ne,re);d.current=0;let s=ne/2,f=Math.PI,p=2*Math.PI,m=Math.PI,h,g=()=>{d.current++;let t=d.current;n.clearRect(0,0,ne,re);let c=v(Math.min(t/80,1)),l=x(Math.min(t/72,1));n.beginPath(),n.arc(s,220,120,f,p),n.strokeStyle=o(i.bd,.35),n.lineWidth=46,n.stroke(),[{start:0,end:.33,color:i.red},{start:.33,end:.66,color:i.amber},{start:.66,end:1,color:i.green}].forEach(e=>{let t=f+e.start*m,r=f+e.end*m;n.beginPath(),n.arc(s,220,194/2,t,r),n.strokeStyle=o(e.color,.12),n.lineWidth=42,n.stroke()}),[{label:`Low`,angle:f+.16*m},{label:`Mid`,angle:f+.5*m},{label:`High`,angle:f+.84*m}].forEach(({label:e,angle:t})=>{let r=s+Math.cos(t)*166,a=220+Math.sin(t)*166;n.font=`13px 'JetBrains Mono', monospace`,n.fillStyle=o(i.t3,.55),n.textAlign=`center`,n.fillText(e,r,a+3)});let _=f+e/100*m*c,y=e>=66?i.green:e>=33?i.amber:i.red;u(n,s+Math.cos(_)*194/2,220+Math.sin(_)*194/2,18,y,.35*c),n.beginPath(),n.arc(s,220,194/2,f,_),n.strokeStyle=o(y,.7*c),n.lineWidth=38,n.lineCap=`round`,n.stroke(),n.lineCap=`butt`;let b=f+e/100*m*l,S=s+Math.cos(b)*82,C=220+Math.sin(b)*82,w=s-Math.cos(b)*14,T=220-Math.sin(b)*14;n.strokeStyle=o(y,.18*l),n.lineWidth=6,n.lineCap=`round`,n.beginPath(),n.moveTo(w,T),n.lineTo(S,C),n.stroke(),n.strokeStyle=o(i.t1,.92*l),n.lineWidth=2,n.lineCap=`round`,n.beginPath(),n.moveTo(w,T),n.lineTo(S,C),n.stroke(),n.beginPath(),n.arc(S,C,3,0,Math.PI*2),n.fillStyle=o(y,.9*l),n.fill(),u(n,s,220,20,y,.25*l),n.beginPath(),n.arc(s,220,9,0,Math.PI*2),n.strokeStyle=o(y,.5*l),n.lineWidth=1.5,n.stroke(),n.beginPath(),n.arc(s,220,5,0,Math.PI*2),n.fillStyle=i.t1,n.fill(),c>.5&&(n.globalAlpha=Math.min(1,(c-.5)/.5),n.font=`bold 22px 'JetBrains Mono', monospace`,n.fillStyle=y,n.textAlign=`center`,n.fillText(`${Math.round(e*l)}%`,s,182),n.globalAlpha=1),c>.7&&(n.globalAlpha=Math.min(1,(c-.7)/.3),n.font=`13px 'JetBrains Mono', monospace`,n.fillStyle=i.t2,n.textAlign=`center`,n.fillText(`NCEs confirmed`,s,252),n.font=`bold 11px 'JetBrains Mono', monospace`,n.fillStyle=i.t2,n.fillText(`${r} of ${a} NCEs are confirmed compensation events`,s,272),n.globalAlpha=1);for(let e=0;e<=10;e++){let t=f+e/10*m;if(n.strokeStyle=o(i.bd,.5),n.lineWidth=e%5==0?1.5:.8,n.beginPath(),n.moveTo(s+Math.cos(t)*122,220+Math.sin(t)*122),n.lineTo(s+Math.cos(t)*128,220+Math.sin(t)*128),n.stroke(),e%5==0){let r=s+Math.cos(t)*138,a=220+Math.sin(t)*138;n.font=`11px 'JetBrains Mono', monospace`,n.fillStyle=o(i.t3,.45),n.textAlign=`center`,n.fillText(`${e*10}%`,r,a+3)}}h=requestAnimationFrame(g)};return g(),()=>cancelAnimationFrame(h)},[e,r,a]),(0,n.jsx)(`div`,{"data-testid":s,style:{position:`relative`,width:ne,height:re},children:(0,n.jsx)(`canvas`,{ref:c,role:`img`,"aria-label":`Compensation event gauge — ${e}% of NCEs confirmed as compensation events`,style:{width:ne,height:re,display:`block`}})})}function ae(e,n,r,i,a=!0,o={}){let s=(0,t.useRef)(0),{easing:c=v,durationFrames:l=48}=o;(0,t.useEffect)(()=>{let t=e.current;if(!t||!n||!r)return;let o=t.getContext(`2d`);if(!o)return;t.width=n*2,t.height=r*2,o.scale(2,2);let u;s.current=0;let d=()=>{s.current++;let e=s.current;o.clearRect(0,0,n,r);let t=a?Math.min(e/l,1):1;if(i(o,c(t),e),t<1)u=requestAnimationFrame(d);else{let e=()=>{s.current++,o.clearRect(0,0,n,r),i(o,1,s.current),u=requestAnimationFrame(e)};u=requestAnimationFrame(e)}};return d(),()=>cancelAnimationFrame(u)},[n,r,a])}var P=780,oe=234,se=130,ce=52,le=[i.blue,i.cyan,i.amber,i.purple,i.green],ue=[`Base Value`,`Variations`,`Commitment`],de=[`Base`,`Var`,`Commit`];function fe({contractors:e,"data-testid":r}){let a=(0,t.useRef)(null),s=(0,t.useRef)(new Map),{hoveredRef:c,tooltip:l,hitZonesRef:p}=h(a,{width:P,height:oe}),_=(0,t.useMemo)(()=>{let t=Math.max(...e.map(e=>e.base??0)),n=Math.max(...e.map(e=>e.variation??0));return e.map((e,r)=>{let i=P*(.12+r*.19),a=se,o=Math.min(P*.075,ce),s=le[r%le.length],c=[(e.base??0)/(t||1)*100,(e.variation??0)/(n||1)*100,e.percentage??0],l=[`£${e.base??0}M`,`£${e.variation??0}M`,`${e.percentage??0}%`],u=c.map((e,t)=>{let n=-Math.PI/2+t/ue.length*Math.PI*2,r=e/100,s=o*Math.max(.08,r);return{name:ue[t],short:de[t],label:l[t],val:Math.round(e),x:i+Math.cos(n)*s,y:a+Math.sin(n)*s,angle:n,norm:r}}),d=u.reduce((e,t)=>e+t.x,0)/u.length,f=u.reduce((e,t)=>e+t.y,0)/u.length,p=Math.sqrt(u.reduce((e,t)=>e+(t.x-d)**2+(t.y-f)**2,0)/u.length);return{...e,cx:i,cy:a,baseR:o,stars:u,scatter:p,color:s}})},[e]);return ae(a,P,oe,(e,t,n)=>{w(s.current,c.current),p.current=[],d(e,P,oe,n,30),_.forEach((t,r)=>{let a=t.color,c=`constellation-${r}`,l=s.current.get(c)??0;e.beginPath(),e.arc(t.cx,t.cy,t.baseR+5,0,Math.PI*2),e.strokeStyle=o(i.bd,.08+.08*l),e.lineWidth=.5,e.stroke(),e.beginPath(),t.stars.forEach((t,n)=>{n===0?e.moveTo(t.x,t.y):e.lineTo(t.x,t.y)}),e.closePath(),e.fillStyle=o(a,.04+.03*l),e.fill(),e.strokeStyle=o(a,.15+.1*l),e.lineWidth=.8,e.stroke(),t.stars.forEach((i,c)=>{let l=S(n,.05,5e-4)*.3+.7,u=3.5*l,d=`star-${r}-${c}`,f=s.current.get(d)??0,m=e.createRadialGradient(i.x,i.y,0,i.x,i.y,u*4);m.addColorStop(0,o(a,(.2+.1*f)*l)),m.addColorStop(1,o(a,0)),e.fillStyle=m,e.beginPath(),e.arc(i.x,i.y,u*4,0,Math.PI*2),e.fill(),e.beginPath(),e.arc(i.x,i.y,u+f*2,0,Math.PI*2),e.fillStyle=o(a,(.8+.2*f)*l),e.fill();let h=Math.sin(i.angle)<-.3;e.textAlign=`center`,e.textBaseline=`middle`,h?(e.font=`8px 'DM Sans', sans-serif`,e.fillStyle=o(a,.5+.15*f),e.fillText(i.short,i.x,i.y-24),e.font=`bold 11px 'JetBrains Mono', monospace`,e.fillStyle=o(a,.8+.15*f),e.fillText(i.label,i.x,i.y-11)):(e.font=`8px 'DM Sans', sans-serif`,e.fillStyle=o(a,.5+.15*f),e.fillText(i.short,i.x,i.y+11),e.font=`bold 11px 'JetBrains Mono', monospace`,e.fillStyle=o(a,.8+.15*f),e.fillText(i.label,i.x,i.y+24)),g(p.current,d,i.x,i.y,u*4+2,{label:i.name,value:i.label,sublabel:t.abbreviation??t.name.slice(0,6),color:a})}),l>0&&u(e,t.cx,t.cy,16*l,a,.15*l),e.beginPath(),e.arc(t.cx,t.cy,t.baseR+12,0,Math.PI*2),e.strokeStyle=o(a,.1+S(n,.03,5e-4)*.05),e.lineWidth=1,e.stroke(),e.font=`bold 11px 'DM Sans', sans-serif`,e.textAlign=`center`,e.textBaseline=`alphabetic`,e.fillStyle=o(i.t2,.65+l*.25),e.fillText(t.abbreviation??t.name.slice(0,6),t.cx,t.cy+t.baseR+26),g(p.current,c,t.cx,t.cy,t.baseR+5,{label:t.name,value:`£${t.total??0}M total`,sublabel:`${t.percentage??0}% committed · scatter ${t.scatter.toFixed(1)}`,color:a})}),e.font=`11px 'DM Sans', sans-serif`,e.textAlign=`center`,e.textBaseline=`middle`,e.fillStyle=o(i.t4,.55),e.fillText(`▲ top = Base value · ▼▸ lower-right = Variations · ◂▼ lower-left = Commitment % · hover stars for details`,P/2,oe-14),f(e,P,oe,n,.012)},!0),(0,n.jsxs)(`div`,{"data-testid":r,style:{position:`relative`,width:P,height:oe},children:[(0,n.jsx)(`canvas`,{ref:a,role:`img`,"aria-label":`Contract value breakdown per contractor — multi-KPI constellation chart`,style:{width:P,height:oe,display:`block`}}),(0,n.jsx)(m,{...l,parentW:P,parentH:oe})]})}var pe=680,me=220,he=[i.blue,i.cyan,i.amber,i.purple,i.green],F={left:8,right:64,top:16,bottom:38},I=88,L=18;function ge({data:e,"data-testid":r}){let a=(0,t.useRef)(null),s=(0,t.useRef)(new Map),{hoveredRef:c,tooltip:l,hitZonesRef:d}=h(a,{width:pe,height:me}),{contractors:f=[],totals:p}=e,g=f.length,v=Math.max(...f.map(e=>e.total??0),1),b=pe-F.left-I-F.right,x=g>1?(me-F.top-F.bottom-g*L)/(g-1):0;return ae(a,pe,me,(e,t)=>{w(s.current,c.current),d.current=[],f.forEach((n,r)=>{let a=he[r%he.length],c=C(t,r,g,y),l=F.top+r*(L+x),f=F.left+I,p=s.current.get(n.id)??0,m=(n.base??0)/v*b*c,h=(n.total??0)/v*b*c,S=h-m;e.font=`${p>0?`bold `:``}10px 'DM Sans', sans-serif`,e.fillStyle=p>0?a:o(i.t2,.8),e.textAlign=`right`,e.textBaseline=`middle`,e.fillText(n.abbreviation??n.name.slice(0,6),f-8,l+L/2),e.fillStyle=o(i.bd,.25),e.beginPath(),e.roundRect(f,l,b,L,4),e.fill(),m>0&&(p>0&&u(e,f+m/2,l+L/2,m*.3,a,.1*p),e.fillStyle=o(a,.5+p*.15),e.beginPath(),e.roundRect(f,l,m,L,4),e.fill()),S>2&&(e.fillStyle=o(a,.22+p*.08),e.beginPath(),e.roundRect(f+m,l,S,L,[0,4,4,0]),e.fill(),e.setLineDash([2,3]),e.strokeStyle=o(a,.55),e.lineWidth=1,e.beginPath(),e.moveTo(f+m,l+3),e.lineTo(f+m,l+L-3),e.stroke(),e.setLineDash([])),p>0&&h>0&&(e.strokeStyle=o(a,.5*p),e.lineWidth=1,e.setLineDash([]),e.beginPath(),e.roundRect(f,l,h,L,4),e.stroke()),c>.35&&(e.globalAlpha=Math.min(1,(c-.35)/.4),e.font=`bold 9px 'JetBrains Mono', monospace`,e.fillStyle=p>0?a:i.t2,e.textAlign=`left`,e.textBaseline=`middle`,e.fillText(`£${n.total??0}M`,f+h+6,l+L/2),e.globalAlpha=1),_(d.current,n.id,f,l,Math.max(h,1),L,{label:n.name,value:`£${n.total??0}M total`,sublabel:`Base £${n.base??0}M + Var £${n.variation??0}M · ${n.percentage??0}% committed`,color:a})});let n=me-14;e.textBaseline=`middle`,e.font=`7px 'DM Sans', sans-serif`,e.textAlign=`left`,e.fillStyle=o(i.cyan,.5),e.beginPath(),e.roundRect(F.left+I,n-3,14,6,2),e.fill(),e.fillStyle=o(i.t3,.45),e.fillText(`base value`,F.left+I+18,n),e.fillStyle=o(i.cyan,.22),e.beginPath(),e.roundRect(F.left+I+94,n-3,14,6,2),e.fill(),e.setLineDash([2,3]),e.strokeStyle=o(i.cyan,.5),e.lineWidth=.5,e.beginPath(),e.moveTo(F.left+I+101,n-3),e.lineTo(F.left+I+101,n+3),e.stroke(),e.setLineDash([]),e.fillStyle=o(i.t3,.45),e.fillText(`approved variations`,F.left+I+112,n),e.font=`bold 8px 'JetBrains Mono', monospace`,e.textAlign=`right`,e.fillStyle=o(i.t2,.6),e.fillText(`Portfolio: £${p?.total??0}M`,pe-8,n)},!0,{easing:y}),(0,n.jsxs)(`div`,{"data-testid":r,style:{position:`relative`,width:pe,height:me},children:[(0,n.jsx)(`canvas`,{ref:a,role:`img`,"aria-label":`Total contract value per contractor — horizontal bar chart`,style:{width:pe,height:me,display:`block`,borderRadius:8}}),(0,n.jsx)(m,{...l,parentW:pe,parentH:me})]})}var R=780,z=240,_e=12,ve=10,ye=[`Highest exposure`,`Elevated risk`,`Moderate exposure`,`Moderate exposure`,`Low exposure`];function be({contractors:e,"data-testid":r}){let a=(0,t.useRef)(null),s=(0,t.useRef)(0),c=(0,t.useRef)(new Map),{hoveredRef:d,tooltip:p,hitZonesRef:g}=h(a,{width:R,height:z}),v=[...e].sort((e,t)=>(t.count??0)-(e.count??0)).slice(0,5),y=v.reduce((e,t)=>e+(t.count??0),0);return(0,t.useEffect)(()=>{let e=a.current;if(!e)return;let t=l(e,R,z);s.current=0;let n=Math.min(5,v.length),r=(R-2*_e-(n-1)*ve)/n,p=z*.84,m=z*.08,h,b=()=>{s.current++;let e=s.current;t.clearRect(0,0,R,z),g.current=[],c.current.forEach((e,t)=>{let n=t===d.current?1:0,r=e+(n-e)*.12;Math.abs(r-n)<.005?n===0?c.current.delete(t):c.current.set(t,1):c.current.set(t,r)}),d.current&&!c.current.has(d.current)&&c.current.set(d.current,0),v.forEach((n,a)=>{let s=a===0,l=s?i.red:a===1?i.amber:i.blue,d=_e+a*(r+ve),f=c.current.get(n.id)??0,h=f*8,v=d-h/2,b=r+h,x=s?S(e,.04,3e-4)*.06+.06:0;t.fillStyle=o(l,.08+f*.07),t.beginPath(),t.roundRect(v,m,b,p,6),t.fill(),t.strokeStyle=o(l,.2+f*.4+x),t.lineWidth=s?1.5:1,t.stroke(),(f>.01||s)&&u(t,v+b/2,m+p/2,b*.55,l,x+f*.14),t.font=`bold 8px 'JetBrains Mono', monospace`,t.textAlign=`left`,t.textBaseline=`top`,t.fillStyle=o(l,.5+f*.35),t.fillText(`#${a+1}`,v+7,m+6);let C=r*.28,w=v+b/2,T=m+p*.38,E=t.createRadialGradient(w,T-C*.2,0,w,T,C);E.addColorStop(0,o(l,.5+f*.2)),E.addColorStop(1,o(l,.2+f*.1)),t.beginPath(),t.arc(w,T,C,0,Math.PI*2),t.fillStyle=E,t.fill(),t.strokeStyle=o(l,.4+f*.3),t.lineWidth=1,t.stroke(),t.font=`bold ${Math.min(10,r*.11)}px 'JetBrains Mono', monospace`,t.textAlign=`center`,t.textBaseline=`middle`,t.fillStyle=o(i.t1,.9),t.fillText(n.abbreviation??n.name.slice(0,6),w,T),t.font=`bold ${Math.min(18,r*.18)}px 'JetBrains Mono', monospace`,t.textBaseline=`alphabetic`,t.fillStyle=o(l,.9+f*.1),t.fillText(String(n.count??0),w,m+p*.76),t.font=`8px 'JetBrains Mono', monospace`,t.fillStyle=o(i.t2,.6),t.fillText(`open EWs`,w,m+p*.88);let D=Math.round((n.count??0)/(y||1)*100),O=ye[a]??`Low exposure`;_(g.current,n.id,d,m,r,p,{label:n.name,value:`${n.count??0} open · ${D}% of total`,sublabel:`Rank #${a+1} · ${O}`,color:l})}),f(t,R,z,e,.015),h=requestAnimationFrame(b)};return b(),()=>cancelAnimationFrame(h)},[v,y]),(0,n.jsxs)(`div`,{"data-testid":r,style:{position:`relative`,width:R,height:z},children:[(0,n.jsx)(`canvas`,{ref:a,role:`img`,"aria-label":`Contractor rank — open EW count per contractor`,style:{width:R,height:z,display:`block`,borderRadius:8}}),(0,n.jsx)(m,{...p,parentW:R,parentH:z})]})}var B=680,V=260;function xe({categories:e,"data-testid":r}){let a=(0,t.useRef)(null),s=(0,t.useRef)(0),c=(0,t.useRef)(new Map),{hoveredRef:p,tooltip:_,hitZonesRef:v}=h(a,{width:B,height:V});return(0,t.useEffect)(()=>{let t=a.current;if(!t)return;let n=l(t,B,V);s.current=0;let r=e.length,m=Math.max(...e.map(e=>e.count),1),h=m,_=B*.05,y=V*.1,b=B*.9/r,x=V*.7/h,C=e.reduce((e,t)=>e+t.count,0),w,T=()=>{s.current++;let t=s.current;n.clearRect(0,0,B,V),v.current=[],c.current.forEach((e,t)=>{let n=t===p.current?1:0,r=e+(n-e)*.12;Math.abs(r-n)<.005?n===0?c.current.delete(t):c.current.set(t,1):c.current.set(t,r)}),p.current&&!c.current.has(p.current)&&c.current.set(p.current,0),d(n,B,V,t,40,o(i.blue,.04)),e.forEach((e,r)=>{let a=e.count===m,s=a?i.cyan:i.blue,l=c.current.get(`${e.category}-col`)??0;for(let i=0;i<h;i++){let d=_+r*b+b/2,f=y+i*x+x/2,p=Math.min(b,x)*.38;if(i>=m-e.count){let m=p*(1+(S(t,.04,5e-4)+Math.sin(r*.6+i*1.2)*.3)*.12);(a||l>.01)&&u(n,d,f,m*3,s,(a?.2:.1)+l*.1),n.beginPath(),n.arc(d,f,m,0,Math.PI*2),n.fillStyle=o(s,a?.8:.5+l*.2),n.fill();let h=`${e.category}-${i}`;g(v.current,h,d,f,p+4,{label:e.fullName,value:`${e.count} Early Warnings`,sublabel:`${Math.round(e.count/C*100)}% of total`,color:s}),c.current.get(`${e.category}-col`)}else n.beginPath(),n.arc(d,f,1,0,Math.PI*2),n.fillStyle=o(s,.08),n.fill()}let d=y+h*x+16;n.font=`${a?`bold `:``}9px 'JetBrains Mono', monospace`,n.textAlign=`center`,n.textBaseline=`alphabetic`,n.fillStyle=a?i.cyan:o(i.t2,.65),n.fillText(e.category,_+r*b+b/2,d)}),f(n,B,V,t,.015),w=requestAnimationFrame(T)};return T(),()=>cancelAnimationFrame(w)},[e]),(0,n.jsxs)(`div`,{"data-testid":r,style:{position:`relative`,width:B,height:V},children:[(0,n.jsx)(`canvas`,{ref:a,role:`img`,"aria-label":`Early Warning count by category — breathing dot grid`,style:{width:B,height:V,display:`block`,borderRadius:8}}),(0,n.jsx)(m,{..._,parentW:B,parentH:V})]})}function Se({rows:e=[],className:t,colors:r}){return(0,n.jsx)(D,{rows:e,variant:`line`,className:t,colors:r})}var Ce=[`#6bbcff`,`#5fe6dd`,`#d7bc6d`,`#95a9ff`,`#7fb58a`,`#ee8a8a`],we={nodes:[{id:`supplier-x`,name:`Supplier X`,valueLabel:`Si +0.12%`},{id:`bf3-superheat`,name:`BF-3 Superheat`,valueLabel:`22°C (target 34)`},{id:`ccm3-solidification`,name:`CCM-3 Solidification`,valueLabel:`Rate deviation`},{id:`grade-risk`,name:`Grade Risk`,valueLabel:`Automotive 74%`}],links:[{source:`supplier-x`,target:`bf3-superheat`,value:92},{source:`bf3-superheat`,target:`ccm3-solidification`,value:87},{source:`ccm3-solidification`,target:`grade-risk`,value:74}]};function Te({rows:e=[],className:t,colors:r}){let i=r?.slices??Ce;return(0,n.jsx)(`div`,{className:[`d3-mini-bars`,t].filter(Boolean).join(` `),children:e.map(([e,t,r],a)=>(0,n.jsxs)(`div`,{className:`d3-mini-row`,children:[(0,n.jsx)(`span`,{children:e}),(0,n.jsx)(`div`,{className:`d3-mini-track`,children:(0,n.jsxs)(`svg`,{viewBox:`0 0 100 12`,className:`d3-mini-svg`,"aria-hidden":`true`,children:[(0,n.jsx)(`rect`,{x:`0`,y:`0`,width:`100`,height:`12`,rx:`6`,className:`d3-mini-track-fill`}),(0,n.jsx)(`rect`,{x:`0`,y:`0`,width:Math.max(0,Math.min(100,t)),height:`12`,rx:`6`,className:`d3-mini-fill tone-${a%Ce.length}`,fill:i[a%i.length]})]})}),(0,n.jsx)(`span`,{children:r})]},`${e}-${a}`))})}var Ee=680,H=320;function De({total:e=0,byContractor:r=[],"data-testid":s}){let c=(0,t.useRef)(null),d=(0,t.useRef)(new Map),f=(0,t.useRef)(0),{hoveredRef:p,tooltip:_,hitZonesRef:y}=h(c,{width:Ee,height:H});return(0,t.useEffect)(()=>{let t=c.current;if(!t)return;let n=l(t,Ee,H);f.current=0;let s=H/2,m=Ee-80,h=Math.max(...r.map(e=>e.count??0)),_=(H-60)/(r.length-1),b=r.map((e,t)=>({x:m,y:30+t*_})),x,S=()=>{f.current++;let t=f.current;n.clearRect(0,0,Ee,H);let c=v(Math.min(t/72,1));w(d.current,p.current),y.current=[],u(n,88,s,48*c,i.blue,.15*c),r.forEach((t,l)=>{let f=a[l%a.length],p=C(c,l,r.length,v),_=b[l],x=d.current.get(t.id)??0,S=Math.max(1.5,(t.count??0)/h*6);if(p<.01)return;let w=88+(m-88)*.4,T=s,E=88+(m-88)*.6,D=_.y,O=p;n.beginPath();for(let e=0;e<=40;e++){let t=e/40*O,r=(1-t)**3*88+3*(1-t)**2*t*w+3*(1-t)*t**2*E+t**3*_.x,i=(1-t)**3*s+3*(1-t)**2*t*T+3*(1-t)*t**2*D+t**3*_.y;e===0?n.moveTo(r,i):n.lineTo(r,i)}if(n.strokeStyle=o(f,x>0?.8:.45),n.lineWidth=S*(x>0?1.3:1),n.stroke(),p>.85){let r=Math.min(1,(p-.85)/.15),a=4+(t.count??0)/h*12;u(n,_.x,_.y,a*2.5,f,(.25+x*.2)*r),n.beginPath(),n.arc(_.x,_.y,a*r,0,Math.PI*2),n.fillStyle=o(f,(.7+x*.2)*r),n.fill(),g(y.current,t.id,_.x,_.y,a+8,{label:t.name,value:`${t.count??0} NCEs raised`,sublabel:`${Math.round((t.count??0)/e*100)}% of all NCEs`,color:f}),n.globalAlpha=r,n.font=`bold 9px 'JetBrains Mono', monospace`,n.fillStyle=x>0?f:o(i.t2,.85),n.textAlign=`left`,n.fillText(t.abbreviation??t.name.slice(0,6),_.x+a+6,_.y-3),n.font=`bold 11px 'JetBrains Mono', monospace`,n.fillStyle=x>0?f:i.t1,n.fillText(String(t.count??0),_.x+a+6,_.y+10),n.globalAlpha=1}}),n.beginPath(),n.arc(88,s,32*c,0,Math.PI*2),n.fillStyle=i.bgL,n.fill(),n.strokeStyle=o(i.blue,.6*c),n.lineWidth=2,n.stroke(),c>.4&&(n.globalAlpha=Math.min(1,(c-.4)/.4),n.font=`bold 18px 'JetBrains Mono', monospace`,n.fillStyle=i.t1,n.textAlign=`center`,n.fillText(String(e),88,s+5),n.font=`8px 'JetBrains Mono', monospace`,n.fillStyle=i.t3,n.fillText(`NCEs`,88,s+18),n.globalAlpha=1),x=requestAnimationFrame(S)};return S(),()=>cancelAnimationFrame(x)},[e,r]),(0,n.jsxs)(`div`,{"data-testid":s,style:{position:`relative`,width:Ee,height:H},children:[(0,n.jsx)(`canvas`,{ref:c,role:`img`,"aria-label":`NCE fault tree — NCEs per contractor as branching tree`,style:{width:Ee,height:H,display:`block`}}),(0,n.jsx)(m,{..._,parentW:Ee,parentH:H})]})}var Oe=192,U=Oe,ke=Oe+80;function Ae({rows:e=[],variant:s,className:d,colors:f}){let p=(0,t.useRef)(null),_=(0,t.useRef)(new Map),v=(0,t.useRef)(0),y=f?.slices??a,{hoveredRef:b,tooltip:x,hitZonesRef:C}=h(p,{width:U,height:ke});return(0,t.useEffect)(()=>{let t=p.current;if(!t)return;let n=l(t,U,ke);v.current=0;let r=U/2,a=Oe/2,d=Oe*.4,f=s===`donut`?Oe*.21:0,m=e.reduce((e,t)=>e+(t.pricing??0),0)||1,h,x=()=>{v.current++;let t=v.current;n.clearRect(0,0,U,ke);let l=1-(1-Math.min(t/48,1))**3;w(_.current,b.current),C.current=[];let p=-Math.PI/2;e.forEach((e,s)=>{let c=(e.pricing??0)/m,h=c*Math.PI*2*l,v=p+h,b=y[s%y.length],x=_.current.get(e.id??`sl-${s}`)??0,w=p+h/2,T=(d+f)/2,E=r+Math.cos(w)*T,D=a+Math.sin(w)*T,O=(d-f)/2+8;g(C.current,e.id??`sl-${s}`,E,D,O,{label:e.vendor,value:`${e.pricing??0} (${Math.round(c*100)}%)`,color:b}),x>0&&u(n,E,D,O*2*x,b,.2*x);let k=S(t,.03,3e-4),A=d+x*6+(x>0?k*2:0);n.beginPath(),n.moveTo(r+Math.cos(p)*f,a+Math.sin(p)*f),n.arc(r,a,A,p,v),f>0?n.arc(r,a,f,v,p,!0):n.lineTo(r,a),n.closePath(),n.fillStyle=o(b,.7+x*.2),n.fill(),n.strokeStyle=o(i.bg,.8),n.lineWidth=1.5,n.stroke(),p=v}),s===`donut`&&e.length>0&&u(n,r,a,f*.8,i.blue,.06);let T=Oe+12;e.forEach((e,t)=>{let r=y[t%y.length],a=(e.pricing??0)/m,s=_.current.get(e.id??`sl-${t}`)??0,l=T+t*18;n.beginPath(),n.arc(8,l,4,0,Math.PI*2),n.fillStyle=o(r,.8+s*.2),n.fill(),n.font=`9px 'JetBrains Mono', monospace`,n.fillStyle=o(i.t2,.7+s*.2),n.textAlign=`left`,n.fillText(e.vendor,18,l+3.5),n.font=`bold 9px 'JetBrains Mono', monospace`,n.fillStyle=c(i.t3,r,s),n.textAlign=`right`,n.fillText(`${e.pricing??0} (${Math.round(a*100)}%)`,U-4,l+3.5)}),h=requestAnimationFrame(x)};return x(),()=>cancelAnimationFrame(h)},[e,s,f,y]),(0,n.jsx)(r,{className:[`canvas-pie-frame`,d].filter(Boolean).join(` `),children:(0,n.jsxs)(`div`,{style:{position:`relative`,width:U,height:ke},children:[(0,n.jsx)(`canvas`,{ref:p,role:`img`,"aria-label":`${s} chart`,style:{width:U,height:ke,display:`block`,borderRadius:8}}),(0,n.jsx)(m,{...x,parentW:U,parentH:ke})]})})}function je(e,t,n,r){let i=new Set(t.map(e=>e.source)),a=new Set(t.map(e=>e.target)),o=new Map,s=[];for(e.forEach(e=>{i.has(e.id)&&!a.has(e.id)&&s.push({id:e.id,depth:0})});s.length>0;){let e=s.shift();if(!e)break;let{id:n,depth:r}=e;o.has(n)||(o.set(n,r),t.filter(e=>e.source===n).forEach(e=>{o.has(e.target)||s.push({id:e.target,depth:r+1})}))}let c=o.size>0?Math.max(...Array.from(o.values())):0;e.forEach(e=>{o.has(e.id)||o.set(e.id,c+1)});let l=new Map;e.forEach(e=>{let t=o.get(e.id)??0;l.has(t)||l.set(t,[]),l.get(t).push(e.id)});let u=Math.max(...Array.from(l.keys()))+1,d={left:100,right:80,top:40,bottom:40},f=new Map;return l.forEach((e,t)=>{let i=d.left+t/Math.max(u-1,1)*(n-d.left-d.right),a=r-d.top-d.bottom,o=Math.max(24,(a-(e.length-1)*12)/e.length),s=e.length*o+(e.length-1)*12,c=d.top+(a-s)/2;e.forEach((e,t)=>{f.set(e,{x:i-20/2,y:c+t*(o+12),w:20,h:o})})}),f}function Me({nodes:e,links:s,width:c=960,height:d=280,ariaLabel:p,selectedEntity:v,className:y,colors:b}){let x=(0,t.useRef)(null),C=(0,t.useRef)(new Map),T=(0,t.useRef)(0),E=(0,t.useRef)([]),D=b?.nodes??a,O=b?.links??i.bd,k=b?.activeLinks??i.blue,A=b?.activeNodes??i.blue,j=(0,t.useMemo)(()=>je(e,s,c,d),[e,s,c,d]),{hoveredRef:M,tooltip:N,hitZonesRef:ee}=h(x,{width:c,height:d});return(0,t.useEffect)(()=>{let t=x.current;if(!t)return;let n=l(t,c,d);T.current=0,E.current=[];let r=s.length>0?Math.max(...s.map(e=>e.value)):1,a,p=()=>{T.current++;let t=T.current;n.clearRect(0,0,c,d);let l=1-(1-Math.min(t/56,1))**3;w(C.current,M.current),ee.current=[],s.forEach((e,a)=>{let s=j.get(e.source),c=j.get(e.target);if(!s||!c)return;let u=!!v&&(e.source===v||e.target===v),d=u?k:O,f=u?.5:.2,p=Math.max(3,e.value/r*36*l),m=p/2,h=s.x+s.w,_=s.y+s.h/2,y=c.x,b=c.y+c.h/2,x=(h+y)/2;for(let e=0;e<30;e++){let r=e/30,i=(e+1)/30,s=1-r,c=1-i,l=s*s*h+2*s*r*x+r*r*y,u=s*s*_+2*s*r*_+r*r*b,p=c*c*h+2*c*i*x+i*i*y,g=c*c*_+2*c*i*_+i*i*b,v=S(t+r*120+a*40,.025,3e-4)*1.2;n.beginPath(),n.moveTo(l,u-m+v),n.lineTo(p,g-m+v),n.lineTo(p,g+m+v),n.lineTo(l,u+m+v),n.closePath(),n.fillStyle=o(d,f*(.5+r*.5)),n.fill()}g(ee.current,`link-${a}`,x,(_+b)/2,p+6,{label:`${e.source} → ${e.target}`,value:String(e.value),color:u?k:i.blue}),Math.random()<.08&&E.current.push({linkIdx:a,prog:0,speed:.006+Math.random()*.006,off:(Math.random()-.5)*p*.5,sz:1+Math.random()})}),e.forEach((e,r)=>{let a=j.get(e.id);if(!a)return;let s=v===e.id,c=M.current===`node-${r}`,l=C.current.get(`node-${r}`)??0,d=s?A:D[r%D.length];_(ee.current,`node-${r}`,a.x,a.y,a.w,a.h,{label:e.name,value:e.valueLabel??e.id,color:d}),(l>0||s)&&u(n,a.x+a.w/2,a.y+a.h/2,a.w*2,d,.2*Math.max(l,s?.6:0));let f=s?S(t,.03,3e-4)*.15:0;n.fillStyle=o(d,.6+l*.25+f),n.beginPath(),n.roundRect(a.x,a.y,a.w,a.h,4),n.fill(),(s||l>0)&&(n.strokeStyle=o(d,.5*Math.max(l,s?1:0)),n.lineWidth=1,n.beginPath(),n.roundRect(a.x,a.y,a.w,a.h,4),n.stroke());let p=a.x+a.w+8;n.font=`${s||c?`bold `:``}10px 'JetBrains Mono', monospace`,n.fillStyle=o(s?d:i.t2,.7+l*.2),n.textAlign=`left`,n.fillText(e.name,p,a.y+a.h/2+4),e.valueLabel&&(n.font=`9px 'JetBrains Mono', monospace`,n.fillStyle=o(d,.5+l*.2),n.fillText(e.valueLabel,p,a.y+a.h/2+17))}),E.current=E.current.filter(e=>{if(e.prog+=e.speed,e.prog>1)return!1;let t=s[e.linkIdx];if(!t)return!1;let r=j.get(t.source),a=j.get(t.target);if(!r||!a)return!1;let c=r.x+r.w,l=r.y+r.h/2,u=a.x,d=a.y+a.h/2,f=(c+u)/2,p=1-e.prog,m=p*p*c+2*p*e.prog*f+e.prog*e.prog*u,h=p*p*l+2*p*e.prog*l+e.prog*e.prog*d+e.off,g=Math.sin(e.prog*Math.PI)*.5,_=b?.links??i.cyan;return n.beginPath(),n.arc(m,h,e.sz,0,Math.PI*2),n.fillStyle=o(_,g),n.fill(),!0}),E.current.length>150&&(E.current=E.current.slice(-150)),f(n,c,d,t,.01),a=requestAnimationFrame(p)};return p(),()=>{cancelAnimationFrame(a),E.current=[]}},[e,s,c,d,v,b,j]),(0,n.jsx)(r,{className:[`canvas-sankey-frame`,y].filter(Boolean).join(` `),children:(0,n.jsxs)(`div`,{role:`img`,"aria-label":p,style:{position:`relative`,width:c,height:d},children:[(0,n.jsx)(`canvas`,{ref:x,style:{width:c,height:d,display:`block`,borderRadius:8}}),(0,n.jsx)(m,{...N,parentW:c,parentH:d})]})})}var Ne=[{x:.13,y:.48},{x:.37,y:.28},{x:.63,y:.62},{x:.87,y:.38},{x:.25,y:.72},{x:.5,y:.18},{x:.75,y:.7},{x:.92,y:.22}],Pe=[i.blue,i.cyan,i.orange,i.red,i.purple,i.green,i.amber,i.t2],Fe=[26,24,24,26,22,22,22,22];function Ie(e,t){let n=1-t;return{x:n*n*n*e.p0.x+3*n*n*t*e.p1.x+3*n*t*t*e.p2.x+t*t*t*e.p3.x,y:n*n*n*e.p0.y+3*n*n*t*e.p1.y+3*n*t*t*e.p2.y+t*t*t*e.p3.y}}function Le(e,t){let n=1-t,r=3*n*n*(e.p1.x-e.p0.x)+6*n*t*(e.p2.x-e.p1.x)+3*t*t*(e.p3.x-e.p2.x),i=3*n*n*(e.p1.y-e.p0.y)+6*n*t*(e.p2.y-e.p1.y)+3*t*t*(e.p3.y-e.p2.y),a=Math.sqrt(r*r+i*i)||1;return{x:-i/a,y:r/a}}function Re(e,t){let n=t.x-e.x,r=t.y-e.y;return{p0:{x:e.x,y:e.y},p1:{x:e.x+n*.3+r*.15,y:e.y+r*.3-n*.15},p2:{x:t.x-n*.3+r*.08,y:t.y-r*.3-n*.08},p3:{x:t.x,y:t.y}}}function ze({nodes:e,links:r,width:a=960,height:s=280,selectedEntity:p}){let _=(0,t.useRef)(null),y=(0,t.useRef)(0),b=(0,t.useRef)([]),{hoveredRef:x,tooltip:C,hitZonesRef:w}=h(_,{width:a,height:s}),T=(0,t.useMemo)(()=>{let t=new Map;return e.forEach((e,n)=>t.set(e.id,n)),t},[e]),E=(0,t.useMemo)(()=>r.length>0?Math.max(...r.map(e=>e.value)):100,[r]),D=e=>E>1?e/100:e,O=(0,t.useMemo)(()=>e.map((e,t)=>{let n=Ne[t%Ne.length];return{id:e.id,label:e.name,sub:e.valueLabel??``,x:n.x*a,y:n.y*s,r:Fe[t%Fe.length],color:Pe[t%Pe.length]}}),[e,a,s]),k=(0,t.useMemo)(()=>r.map(e=>({fromIdx:T.get(e.source)??-1,toIdx:T.get(e.target)??-1,conf:D(e.value)})).filter(e=>e.fromIdx>=0&&e.toIdx>=0),[r,T]);return(0,t.useEffect)(()=>{let e=_.current;if(!e)return;let t=l(e,a,s);y.current=0,b.current=[];let n,r=()=>{y.current++;let e=y.current;if(t.clearRect(0,0,a,s),w.current=[],d(t,a,s,e,50,o(i.blue,.05)),k.forEach((e,n)=>{let r=O[e.fromIdx],a=O[e.toIdx];if(!r||!a)return;let s=!!p&&(r.id===p||a.id===p),l=c(r.color,a.color,.5),u=s?.18:.05,d=s?.25:.1,f=Re(r,a);t.beginPath(),t.moveTo(f.p0.x,f.p0.y),t.bezierCurveTo(f.p1.x,f.p1.y,f.p2.x,f.p2.y,f.p3.x,f.p3.y),t.strokeStyle=o(l,u),t.lineWidth=16,t.lineCap=`round`,t.stroke(),t.strokeStyle=o(l,d),t.lineWidth=1.5,t.stroke();for(let t=0;t<e.conf*2.5;t++)Math.random()<.45&&b.current.push({edgeIdx:n,t:0,speed:.003+Math.random()*.004,off:(Math.random()-.5)*13,sz:.7+Math.random()*2});let m=Ie(f,.5),h=`${Math.round(e.conf*100)}%`;t.font=`bold 12px 'JetBrains Mono', monospace`,t.textBaseline=`middle`;let g=t.measureText(h).width+14;t.fillStyle=`rgba(10,16,24,0.88)`,t.beginPath(),t.roundRect(m.x-g/2,m.y-11,g,22,6),t.fill(),t.strokeStyle=o(i.cyan,.25),t.lineWidth=1,t.stroke(),t.fillStyle=o(i.cyan,.9),t.textAlign=`center`,t.fillText(h,m.x,m.y)}),b.current=b.current.filter(e=>{if(e.t+=e.speed,e.t>1)return!1;let n=k[e.edgeIdx];if(!n)return!1;let r=O[n.fromIdx],i=O[n.toIdx];if(!r||!i)return!1;let a=Re(r,i),s=Ie(a,e.t),l=Le(a,e.t),d=s.x+l.x*e.off,f=s.y+l.y*e.off,p=Math.sin(e.t*Math.PI)*.7,m=c(r.color,i.color,e.t);return u(t,d,f,e.sz*3,m,p*.1),t.beginPath(),t.arc(d,f,e.sz,0,Math.PI*2),t.fillStyle=o(m,p),t.fill(),!0}),b.current.length>350&&(b.current=b.current.slice(-350)),O.forEach((n,r)=>{let a=p===n.id,s=x.current===`node-${r}`,c=S(e,.03,3e-4)*.1+1,l=n.r*c*(a?1.15:1);t.beginPath(),t.arc(n.x,n.y,l+6,0,Math.PI*2),t.strokeStyle=o(n.color,a?.3:.1),t.lineWidth=a?1.5:.7,t.stroke(),u(t,n.x,n.y,l*3,n.color,a?.22:.12);let d=t.createRadialGradient(n.x,n.y-l*.2,0,n.x,n.y,l);if(d.addColorStop(0,o(n.color,a?1:.85)),d.addColorStop(1,o(n.color,a?.65:.45)),t.fillStyle=d,t.beginPath(),t.arc(n.x,n.y,l,0,Math.PI*2),t.fill(),a||r===O.length-1){let r=l+16,i=e*.04,a=n.x+Math.cos(i)*r,s=n.y+Math.sin(i)*r;u(t,a,s,6,n.color,.3),t.beginPath(),t.arc(a,s,2,0,Math.PI*2),t.fillStyle=o(n.color,.75),t.fill()}g(w.current,`node-${r}`,n.x,n.y,l+8,{label:n.label,value:n.sub||n.id,color:n.color}),t.font=`${a||s?`bold `:``}12px 'DM Sans', sans-serif`,t.textAlign=`center`,t.textBaseline=`alphabetic`,t.fillStyle=o(n.color,a?1:.9),t.fillText(n.label,n.x,n.y+l+18),n.sub&&(t.font=`10px 'JetBrains Mono', monospace`,t.fillStyle=o(i.t3,.65),t.fillText(n.sub,n.x,n.y+l+32))}),k.length>=2){let n=k.reduce((e,t)=>e*t.conf,1),r=s*.92,c=a*.12,l=a*.76,u=v(Math.min(e*.008,1));t.fillStyle=o(i.bd,.35),t.beginPath(),t.roundRect(c,r,l,5,3),t.fill(),t.fillStyle=o(i.orange,.6),t.beginPath(),t.roundRect(c,r,l*n*u,5,3),t.fill(),t.font=`bold 12px 'JetBrains Mono', monospace`,t.textAlign=`left`,t.textBaseline=`middle`,t.fillStyle=o(i.orange,.85),t.fillText(`${Math.round(n*100)}% compound confidence`,c+l*n*u+10,r+2);let d=k.map(e=>e.conf.toFixed(2)).join(` × `);t.textAlign=`right`,t.font=`9px 'JetBrains Mono', monospace`,t.fillStyle=o(i.t4,.6),t.fillText(d,c-6,r+2)}f(t,a,s,e,.012),n=requestAnimationFrame(r)};return r(),()=>{cancelAnimationFrame(n),b.current=[]}},[O,k,a,s,p]),(0,n.jsxs)(`div`,{style:{position:`relative`,width:a,height:s},children:[(0,n.jsx)(`canvas`,{ref:_,style:{width:a,height:s,display:`block`,borderRadius:8},role:`img`,"aria-label":`causal flow diagram`}),(0,n.jsx)(m,{...C,parentW:a,parentH:s})]})}function Be({selectedEntity:e,colors:t}){return(0,n.jsx)(ze,{nodes:we.nodes,links:we.links,width:960,height:280,selectedEntity:e})}function Ve({rows:e=[],className:r,colors:i}){let{nodes:a,links:o}=(0,t.useMemo)(()=>{let t=e.slice(0,5);return{nodes:[{id:`score`,name:`Portfolio Score`},...t.map(e=>({id:e.id??e.vendor,name:e.vendor}))],links:t.map(e=>({source:e.id??e.vendor,target:`score`,value:Math.max(8,e.pricing??0)}))}},[e]);return(0,n.jsx)(Me,{nodes:a,links:o,width:760,height:280,ariaLabel:`sankey chart`,className:r,colors:i})}var He=500,Ue=320;function We({accepted:e,submitted:r,"data-testid":a}){let s=(0,t.useRef)(null),c=(0,t.useRef)(0);return(0,t.useEffect)(()=>{let t=s.current;if(!t)return;let n=l(t,He,Ue);c.current=0;let a=He/2,d=Math.max(e.value,r.value),f=(e.value-r.value)/d*14,p,m=()=>{c.current++;let t=c.current;n.clearRect(0,0,He,Ue);let s=v(Math.min(t/80,1)),l=f*x(Math.min(t/80,1))*Math.PI/180;n.strokeStyle=o(i.bd,.5*s),n.lineWidth=2,n.beginPath(),n.moveTo(a,100),n.lineTo(a,Ue-80),n.stroke(),n.beginPath(),n.arc(a,100,5*s,0,Math.PI*2),n.fillStyle=i.t2,n.fill();let h={x:a-Math.cos(l)*160,y:100+Math.sin(-l)*160},g={x:a+Math.cos(l)*160,y:100+Math.sin(l)*160};n.strokeStyle=o(i.t2,.5*s),n.lineWidth=2,n.beginPath(),n.moveTo(h.x,h.y),n.lineTo(g.x,g.y),n.stroke();let _=Math.max(20,e.value/d*100*s),y=h.y+18;u(n,h.x,y+_/2,90*.5,i.green,.18*s),n.fillStyle=o(i.green,.5*s),n.beginPath(),n.roundRect(h.x-90/2,y,90,_,[0,0,6,6]),n.fill(),n.strokeStyle=o(i.green,.7*s),n.lineWidth=1.5,n.stroke(),n.strokeStyle=o(i.t3,.35*s),n.lineWidth=1,[-90/3,90/3].forEach(e=>{n.beginPath(),n.moveTo(h.x+e,h.y+4),n.lineTo(h.x+e,y),n.stroke()}),s>.5&&(n.globalAlpha=Math.min(1,(s-.5)/.5),n.font=`bold 14px 'JetBrains Mono', monospace`,n.fillStyle=i.green,n.textAlign=`center`,n.fillText(e.label,h.x,y+_+18),n.font=`9px 'JetBrains Mono', monospace`,n.fillStyle=i.t2,n.fillText(`Accepted`,h.x,y+_+32),n.fillText(`${e.count} quotations`,h.x,y+_+44),n.globalAlpha=1);let b=Math.max(20,r.value/d*100*s),S=g.y+18;n.fillStyle=o(i.amber,.3*s),n.strokeStyle=o(i.amber,.5*s),n.lineWidth=1.5,n.beginPath(),n.roundRect(g.x-90/2,S,90,b,[0,0,6,6]),n.fill(),n.stroke(),n.strokeStyle=o(i.t3,.35*s),n.lineWidth=1,[-90/3,90/3].forEach(e=>{n.beginPath(),n.moveTo(g.x+e,g.y+4),n.lineTo(g.x+e,S),n.stroke()}),s>.5&&(n.globalAlpha=Math.min(1,(s-.5)/.5),n.font=`bold 14px 'JetBrains Mono', monospace`,n.fillStyle=i.amber,n.textAlign=`center`,n.fillText(r.label,g.x,S+b+18),n.font=`9px 'JetBrains Mono', monospace`,n.fillStyle=i.t2,n.fillText(`Submitted`,g.x,S+b+32),n.fillText(`${r.count} quotations`,g.x,S+b+44),n.globalAlpha=1),s>.85&&Math.abs(f)>1&&(n.globalAlpha=Math.min(1,(s-.85)/.15)*.6,n.font=`8px 'JetBrains Mono', monospace`,n.fillStyle=i.t3,n.textAlign=`center`,n.fillText(`${Math.abs(f).toFixed(1)}° tilt toward accepted`,a,Ue-12),n.globalAlpha=1),p=requestAnimationFrame(m)};return m(),()=>cancelAnimationFrame(p)},[e,r]),(0,n.jsx)(`div`,{"data-testid":a,style:{position:`relative`,width:He,height:Ue},children:(0,n.jsx)(`canvas`,{ref:s,role:`img`,"aria-label":`Quotation balance — accepted vs submitted quotation value`,style:{width:He,height:Ue,display:`block`}})})}var Ge=680,W=280;function Ke({trend:e=[],"data-testid":r}){let a=(0,t.useRef)(null),s=(0,t.useRef)(new Map),c=(0,t.useRef)(0),{hoveredRef:d,tooltip:f,hitZonesRef:_}=h(a,{width:Ge,height:W});return(0,t.useEffect)(()=>{let t=a.current;if(!t)return;let n=l(t,Ge,W);c.current=0;let r=Ge-54-28,f=W-30-54,m=Math.max(...e.map(e=>e.count)),h=e.length,y=h>1?r/(h-1):r,b=e.map((e,t)=>({x:54+t*y,y:30+f-e.count/m*f,point:e})),x,S=()=>{c.current++;let e=c.current;n.clearRect(0,0,Ge,W);let t=v(Math.min(e/72,1));w(s.current,d.current),_.current=[],[.25,.5,.75,1].forEach(e=>{let t=30+f-e*f;n.strokeStyle=o(i.bd,.18),n.lineWidth=1,n.setLineDash([3,5]),n.beginPath(),n.moveTo(54,t),n.lineTo(54+r,t),n.stroke(),n.setLineDash([]),n.font=`10px 'JetBrains Mono', monospace`,n.fillStyle=o(i.t4,.6),n.textAlign=`right`,n.fillText(String(Math.round(m*e)),48,t+3)}),n.save(),n.translate(12,30+f/2),n.rotate(-Math.PI/2),n.font=`11px 'JetBrains Mono', monospace`,n.fillStyle=o(i.t3,.5),n.textAlign=`center`,n.fillText(`Submissions`,0,0),n.restore(),n.font=`11px 'JetBrains Mono', monospace`,n.fillStyle=o(i.t3,.5),n.textAlign=`center`,n.fillText(`Week`,54+r/2,W-6),n.strokeStyle=o(i.bd,.3),n.lineWidth=1,n.setLineDash([]),n.beginPath(),n.moveTo(54,30+f),n.lineTo(54+r,30+f),n.stroke();let a=t*(h-1),l=Math.floor(a)+1;if(l>=2){n.beginPath(),n.moveTo(b[0].x,30+f),n.lineTo(b[0].x,b[0].y);for(let e=1;e<l;e++){let t=a-Math.floor(a),r=e<l-1?b[e].x:b[e-1].x+(b[e].x-b[e-1].x)*(e===Math.ceil(a)?t:1),i=e<l-1?b[e].y:b[e-1].y+(b[e].y-b[e-1].y)*(e===Math.ceil(a)?t:1);n.lineTo(r,i)}let e=b[Math.min(l-1,h-1)];n.lineTo(e.x,30+f),n.closePath();let t=n.createLinearGradient(0,30,0,30+f);t.addColorStop(0,o(i.cyan,.22)),t.addColorStop(1,o(i.cyan,.02)),n.fillStyle=t,n.fill()}n.beginPath();for(let e=0;e<l;e++){let t=a-Math.floor(a),r=e===l-1&&e>0&&e===Math.ceil(a),i=e===0||e<l-1?b[e].x:b[e-1].x+(b[e].x-b[e-1].x)*(r?t:1),o=e===0||e<l-1?b[e].y:b[e-1].y+(b[e].y-b[e-1].y)*(r?t:1);e===0?n.moveTo(i,o):n.lineTo(i,o)}n.strokeStyle=o(i.cyan,.85),n.lineWidth=2,n.stroke(),b.forEach((e,t)=>{if(t>=l)return;let r=`pt-${t}`,a=s.current.get(r)??0;g(_.current,r,e.x,e.y,10,{label:e.point.week,value:`${e.point.count} quotations submitted`,sublabel:`£${e.point.value}M value`,color:i.cyan}),a>0&&p(n,e.x,30,30+f,o(i.cyan,.15*a));let c=e.point.count===m;(a>0||c)&&u(n,e.x,e.y,14,i.cyan,(c?.3:0)+a*.25),n.beginPath(),n.arc(e.x,e.y,a>0?5:3.5,0,Math.PI*2),n.fillStyle=o(i.cyan,a>0?1:.8),n.fill(),(a>0||c)&&(n.font=`bold 10px 'JetBrains Mono', monospace`,n.fillStyle=i.cyan,n.textAlign=`center`,n.fillText(String(e.point.count),e.x,e.y-10)),n.font=`10px 'JetBrains Mono', monospace`,n.fillStyle=a>0?i.cyan:o(i.t3,.6),n.textAlign=`center`,n.fillText(e.point.week,e.x,W-54+14)}),x=requestAnimationFrame(S)};return S(),()=>cancelAnimationFrame(x)},[e]),(0,n.jsxs)(`div`,{"data-testid":r,style:{position:`relative`,width:Ge,height:W},children:[(0,n.jsx)(`canvas`,{ref:a,role:`img`,"aria-label":`Quotation submission trend — weekly count over 12 weeks`,style:{width:Ge,height:W,display:`block`}}),(0,n.jsx)(m,{...f,parentW:Ge,parentH:W})]})}var G=680,qe=240,Je={Critical:i.red,High:i.orange,Medium:i.amber,Low:i.green};function Ye({severities:e,"data-testid":r}){let a=(0,t.useRef)(null),s=(0,t.useRef)(new Map),c=(0,t.useRef)(0),{hoveredRef:d,tooltip:f,hitZonesRef:p}=h(a,{width:G,height:qe});return(0,t.useEffect)(()=>{let t=a.current;if(!t)return;let n=l(t,G,qe);c.current=0;let r=e.reduce((e,t)=>e+t.count,0),f=G-28-28,m=qe-50-52,h=e.map(e=>e.count/r*f),g,v=()=>{c.current++;let t=c.current;n.clearRect(0,0,G,qe);let a=y(Math.min(t/60,1));w(s.current,d.current),p.current=[],n.strokeStyle=o(i.bd,.2),n.lineWidth=1,n.beginPath(),n.rect(28,50,f,m),n.stroke(),n.strokeStyle=o(i.t4,.15),n.lineWidth=1,n.setLineDash([4,4]),n.beginPath(),n.moveTo(G/2,50),n.lineTo(G/2,50+m),n.stroke(),n.setLineDash([]);let l=28;e.forEach((e,t)=>{let c=Je[e.severity]??i.blue,d=h[t];d*a;let f=s.current.get(e.severity)??0,g=l+d/2,v=d*.85;g-v/2;let y=d*a,b=v*a,x=g-b/2;if(y>0&&(f>0&&u(n,l+y/2,50+m/2,y*.4,c,.15*f),n.beginPath(),n.moveTo(x,50),n.lineTo(x+b,50),n.lineTo(l+y,50+m),n.lineTo(l,50+m),n.closePath(),n.fillStyle=o(c,.45+f*.25),n.fill(),n.strokeStyle=o(c,(.5+f*.3)*a),n.lineWidth=f>0?2:1,n.beginPath(),n.moveTo(x,50),n.lineTo(x+b,50),n.stroke(),n.strokeStyle=o(c,(.3+f*.3)*a),n.lineWidth=f>0?2:1,n.beginPath(),n.moveTo(l,50+m),n.lineTo(l+y,50+m),n.stroke()),_(p.current,e.severity,l,50,d,m,{label:e.severity,value:`${e.count} Early Warnings`,sublabel:`${Math.round(e.count/r*100)}% of all EWs`,color:c}),a>.5){let t=Math.min(1,(a-.5)/.5),s=l+d/2;n.globalAlpha=t,n.font=`bold 10px 'JetBrains Mono', monospace`,n.fillStyle=f>0?c:o(c,.9),n.textAlign=`center`,n.fillText(e.severity,s,38),n.font=`bold ${d>80?`18`:`13`}px 'JetBrains Mono', monospace`,n.fillStyle=f>0?i.t1:o(i.t1,.85),n.fillText(String(e.count),s,50+m/2+6),n.font=`9px 'JetBrains Mono', monospace`,n.fillStyle=f>0?c:o(i.t3,.7),n.fillText(`${Math.round(e.count/r*100)}%`,s,50+m+18),n.globalAlpha=1}l+=d});let b=n.createLinearGradient(28,0,28+f,0);b.addColorStop(0,o(i.red,.03)),b.addColorStop(.33,o(i.orange,.03)),b.addColorStop(.66,o(i.amber,.03)),b.addColorStop(1,o(i.green,.03)),n.fillStyle=b,n.fillRect(28,50,f*a,m),g=requestAnimationFrame(v)};return v(),()=>cancelAnimationFrame(g)},[e]),(0,n.jsxs)(`div`,{"data-testid":r,style:{position:`relative`,width:G,height:qe},children:[(0,n.jsx)(`canvas`,{ref:a,role:`img`,"aria-label":`Early Warning severity distribution — prism spectrum bands`,style:{width:G,height:qe,display:`block`}}),(0,n.jsx)(m,{...f,parentW:G,parentH:qe})]})}var K=460,q=300,Xe={Open:i.red,Submitted:i.amber,Closed:i.green};function Ze({segments:e,title:r,"data-testid":a}){let s=(0,t.useRef)(null),c=(0,t.useRef)(0),p=(0,t.useRef)(new Map),{hoveredRef:_,tooltip:v,hitZonesRef:y}=h(s,{width:K,height:q});return(0,t.useEffect)(()=>{let t=s.current;if(!t)return;let n=l(t,K,q);c.current=0;let r=K*.5,a=q*.54,m=K*.22,h=e.reduce((e,t)=>e+t.count,0),v=Math.max(...e.map(e=>e.count),1),b,x=()=>{c.current++;let t=c.current;n.clearRect(0,0,K,q),y.current=[],p.current.forEach((e,t)=>{let n=t===_.current?1:0,r=e+(n-e)*.12;Math.abs(r-n)<.005?n===0?p.current.delete(t):p.current.set(t,1):p.current.set(t,r)}),_.current&&!p.current.has(_.current)&&p.current.set(_.current,0),d(n,K,q,t,40,o(i.blue,.04)),e.forEach((e,s)=>{let c=s/3*Math.PI*2-Math.PI/2,l=r+Math.cos(c)*m,d=a+Math.sin(c)*m,f=Xe[e.status]??i.blue,p=2+e.count/v*8;n.beginPath(),n.moveTo(r,a),n.lineTo(l,d),n.strokeStyle=o(f,.08),n.lineWidth=p*2,n.stroke(),n.beginPath(),n.moveTo(r,a),n.lineTo(l,d),n.strokeStyle=o(f,.25),n.lineWidth=1,n.stroke();let h=(t*.005+s*.33)%1,g=r+(l-r)*h,_=a+(d-a)*h;u(n,g,_,6,f,.4),n.beginPath(),n.arc(g,_,2,0,Math.PI*2),n.fillStyle=o(f,.8),n.fill();let y=(r+l)/2,b=(a+d)/2;n.font=`bold 9px 'JetBrains Mono', monospace`,n.textAlign=`center`,n.textBaseline=`middle`,n.fillStyle=o(f,.85),n.fillText(String(e.count),y,b)}),e.forEach((e,t)=>{let s=t/3*Math.PI*2-Math.PI/2,c=r+Math.cos(s)*m,l=a+Math.sin(s)*m,d=Xe[e.status]??i.blue,f=10+e.count/v*18,_=p.current.get(e.status)??0;u(n,c,l,f*2.5,d,.2+_*.15);let b=n.createRadialGradient(c,l-f*.2,0,c,l,f);b.addColorStop(0,o(d,.8+_*.2)),b.addColorStop(1,o(d,.4+_*.1)),n.beginPath(),n.arc(c,l,f,0,Math.PI*2),n.fillStyle=b,n.fill(),n.font=`bold 9px 'JetBrains Mono', monospace`,n.textAlign=`center`,n.textBaseline=`middle`,n.fillStyle=o(i.t1,.9),n.fillText(e.status,c,l),g(y.current,e.status,c,l,f+6,{label:e.status,value:`${e.count} Early Warnings`,sublabel:`${Math.round(e.count/h*100)}%`,color:d})});let s=p.current.get(`center`)??0;u(n,r,a,36,i.t3,.2+s*.15);let l=n.createRadialGradient(r,a-4,0,r,a,22);l.addColorStop(0,o(i.t2,.9)),l.addColorStop(1,o(i.t3,.5)),n.beginPath(),n.arc(r,a,22,0,Math.PI*2),n.fillStyle=l,n.fill(),n.font=`bold 8px 'JetBrains Mono', monospace`,n.textAlign=`center`,n.textBaseline=`middle`,n.fillStyle=o(i.t1,.9),n.fillText(`EW Status`,r,a-4),n.font=`bold 10px 'JetBrains Mono', monospace`,n.fillStyle=i.t1,n.fillText(String(h),r,a+8),g(y.current,`center`,r,a,28,{label:`Total EW Status`,value:`${h} Early Warnings`,color:i.t3}),f(n,K,q,t,.015),b=requestAnimationFrame(x)};return x(),()=>cancelAnimationFrame(b)},[e,r]),(0,n.jsxs)(`div`,{"data-testid":a,style:{position:`relative`,width:K,height:q},children:[(0,n.jsx)(`canvas`,{ref:s,role:`img`,"aria-label":r??`EW status arc visualization`,style:{width:K,height:q,display:`block`,borderRadius:8}}),(0,n.jsx)(m,{...v,parentW:K,parentH:q})]})}var J=280,Y=96;function Qe({points:e=[],className:a,colors:s}){let c=(0,t.useRef)(null),d=(0,t.useRef)(new Map),f=(0,t.useRef)(0),_=(0,t.useMemo)(()=>e.map(([e,t])=>{let n=String(t).match(/-?\d+(\.\d+)?/);return{label:e,value:n?Number(n[0]):0}}),[e]),{mouseRef:v,hoveredRef:y,tooltip:b,hitZonesRef:x}=h(c,{width:J,height:Y});return(0,t.useEffect)(()=>{let e=c.current;if(!e)return;let t=l(e,J,Y);f.current=0;let n=s?.line??i.blue,r=s?.point??i.blue,a=s?.axisLine??i.bd,m,h=()=>{f.current++;let e=f.current;if(t.clearRect(0,0,J,Y),_.length<2){m=requestAnimationFrame(h);return}let s={left:12,right:12,top:16,bottom:20},c=J-s.left-s.right,l=Y-s.top-s.bottom,b=_.map(e=>e.value),C=Math.min(...b),T=Math.max(...b)-C||1,E=e=>s.left+e/(_.length-1)*c,D=e=>s.top+(1-(e-C)/T)*l,O=1-(1-Math.min(e/48,1))**3,k=Math.max(2,Math.floor(O*_.length));if(w(d.current,y.current),x.current=[],t.strokeStyle=o(a,.3),t.lineWidth=.5,t.setLineDash([]),t.beginPath(),t.moveTo(s.left,Y-s.bottom),t.lineTo(J-s.right,Y-s.bottom),t.stroke(),t.font=`9px 'JetBrains Mono', monospace`,t.fillStyle=o(i.t4,.9),t.textAlign=`center`,_.forEach((e,n)=>{t.fillText(e.label.replace(`Day `,`D`),E(n),Y-4)}),v.current.over&&y.current){let e=parseInt(y.current.split(`-`)[1]);isNaN(e)||p(t,E(e),s.top,s.top+l)}if(k>1){let e=t.createLinearGradient(0,s.top,0,s.top+l);e.addColorStop(0,o(n,.15)),e.addColorStop(1,o(n,0)),t.fillStyle=e,t.beginPath(),t.moveTo(E(0),s.top+l);for(let e=0;e<k;e++)t.lineTo(E(e),D(_[e].value));t.lineTo(E(k-1),s.top+l),t.closePath(),t.fill(),t.strokeStyle=o(n,.8),t.lineWidth=1.5,t.setLineDash([]),t.beginPath();for(let e=0;e<k;e++){let n=E(e),r=D(_[e].value);e===0?t.moveTo(n,r):t.lineTo(n,r)}t.stroke()}for(let e=0;e<k;e++){let n=E(e),a=D(_[e].value),s=`tp-${e}`,c=d.current.get(s)??0,l=e===_.length-1;g(x.current,s,n,a,10,{label:_[e].label,value:String(_[e].value),color:l?i.red:r}),c>0&&!l&&(u(t,n,a,12*c,r,.2*c),t.fillStyle=o(r,.8),t.beginPath(),t.arc(n,a,3+c*2,0,Math.PI*2),t.fill())}if(k>=_.length){let n=_.length-1,r=E(n),a=D(_[n].value),s=d.current.get(`tp-${n}`)??0,c=S(e,.05,5e-4),l=1+s*.5;t.shadowColor=o(i.red,.5),t.shadowBlur=(8+c*4)*l,t.fillStyle=i.red,t.beginPath(),t.arc(r,a,(3.5+c*1.5)*l,0,Math.PI*2),t.fill(),t.shadowBlur=0}m=requestAnimationFrame(h)};return h(),()=>cancelAnimationFrame(m)},[_,s]),(0,n.jsx)(r,{className:[`canvas-trend-frame`,a].filter(Boolean).join(` `),children:(0,n.jsxs)(`div`,{style:{position:`relative`,width:J,height:Y},children:[(0,n.jsx)(`canvas`,{ref:c,role:`img`,"aria-label":`trend chart`,style:{width:J,height:Y,display:`block`,borderRadius:8}}),(0,n.jsx)(m,{...b,parentW:J,parentH:Y})]})})}var $e=680,et=320;function tt({contractors:e=[],"data-testid":r}){let s=(0,t.useRef)(null),c=(0,t.useRef)(new Map),d=(0,t.useRef)(0),{hoveredRef:f,tooltip:p,hitZonesRef:g}=h(s,{width:$e,height:et});return(0,t.useEffect)(()=>{let t=s.current;if(!t)return;let n=l(t,$e,et);d.current=0;let r=$e-60-28,p=Math.max(...e.map(e=>(e.implemented??0)+(e.unimplemented??0))),m=e.length*40-14,h=16+(et-16-32-m)/2,v,b=()=>{d.current++;let t=d.current;n.clearRect(0,0,$e,et);let s=y(Math.min(t/60,1));w(c.current,f.current),g.current=[],e.forEach((t,l)=>{let d=a[l%a.length],f=C(s,l,e.length,y),m=h+l*40,v=(t.implemented??0)+(t.unimplemented??0),b=(t.implemented??0)/p*r*f,x=(t.unimplemented??0)/p*r*f,S=`${t.id}-impl`,w=`${t.id}-un`,T=c.current.get(S)??0,E=c.current.get(w)??0;_(g.current,S,60,m,b||1,26,{label:`${t.name} — Implemented`,value:`${t.implemented??0} variations`,sublabel:`${Math.round((t.implemented??0)/(v||1)*100)}% complete`,color:i.green}),_(g.current,w,60+b,m,x||1,26,{label:`${t.name} — Unimplemented`,value:`${t.unimplemented??0} variations`,sublabel:`${Math.round((t.unimplemented??0)/(v||1)*100)}% pending`,color:i.amber}),n.font=`9px 'JetBrains Mono', monospace`,n.fillStyle=o(d,.85),n.textAlign=`right`,n.fillText(t.abbreviation??t.name.slice(0,6),52,m+26/2+4),n.fillStyle=o(i.bd,.15),n.beginPath(),n.roundRect(60,m,v/p*r,26,4),n.fill(),b>0&&(T>0&&u(n,60+b/2,m+26/2,b*.3,i.green,.12*T),n.fillStyle=o(i.green,.6+T*.2),n.beginPath(),n.roundRect(60,m,b,26,[4,0,0,4]),n.fill(),b>28&&f>.5&&(n.font=`bold 10px 'JetBrains Mono', monospace`,n.fillStyle=T>0?i.green:o(i.t1,.8),n.textAlign=`center`,n.fillText(String(t.implemented??0),60+b/2,m+26/2+4))),x>0&&(E>0&&u(n,60+b+x/2,m+26/2,x*.3,i.amber,.12*E),n.fillStyle=o(i.amber,.18+E*.18),n.strokeStyle=o(i.amber,.3+E*.3),n.lineWidth=1,n.beginPath(),n.roundRect(60+b,m,x,26,[0,4,4,0]),n.fill(),n.stroke(),x>28&&f>.5&&(n.font=`${E>0?`bold `:``}10px 'JetBrains Mono', monospace`,n.fillStyle=E>0?i.amber:o(i.t3,.8),n.textAlign=`center`,n.fillText(String(t.unimplemented??0),60+b+x/2,m+26/2+4))),b>0&&x>0&&(n.strokeStyle=o(i.bg,.7),n.lineWidth=2,n.beginPath(),n.moveTo(60+b,m),n.lineTo(60+b,m+26),n.stroke())});let l=h+m+24,x=60+r/2;n.font=`9px 'JetBrains Mono', monospace`,n.textAlign=`right`,n.fillStyle=i.green,n.fillText(`■ Implemented`,x-10,l),n.textAlign=`left`,n.fillStyle=o(i.t3,.7),n.fillText(`■ Unimplemented`,x+10,l),v=requestAnimationFrame(b)};return b(),()=>cancelAnimationFrame(v)},[e]),(0,n.jsxs)(`div`,{"data-testid":r,style:{position:`relative`,width:$e,height:et},children:[(0,n.jsx)(`canvas`,{ref:s,role:`img`,"aria-label":`Implemented vs unimplemented variations per contractor — split bar`,style:{width:$e,height:et,display:`block`}}),(0,n.jsx)(m,{...p,parentW:$e,parentH:et})]})}var nt=800,X=360;function rt({contractors:e=[],"data-testid":r}){let s=(0,t.useRef)(null),c=(0,t.useRef)(new Map),d=(0,t.useRef)(0),{hoveredRef:f,tooltip:p,hitZonesRef:g}=h(s,{width:nt,height:X});return(0,t.useEffect)(()=>{let t=s.current;if(!t)return;let n=l(t,nt,X);d.current=0;let r=e.reduce((e,t)=>e+(t.base??0),0),p=e.reduce((e,t)=>e+(t.variation??0),0),m=e.reduce((e,t)=>e+(t.total??0),0),h=X-20-26,y=h-6*(e.length-1),b=20,x=e.map((e,t)=>{let n=Math.max(24,(e.total??0)/(m||1)*y),r={x:100-110/2,y:b,h:n,cy:b+n/2,c:e,color:a[t%a.length]};return b+=n+6,r}),S=y-14,T=Math.max(28,r/m*S),E=Math.max(18,p/m*S),D=20+(h-(T+E+14))/2,O={x:420-110/2,y:D,h:T,cy:D+T/2},k={x:420-110/2,y:D+T+14,h:E,cy:D+T+14+E/2},A={x:720-110/2,y:20,h,cy:20+h/2},j,M=()=>{d.current++;let t=d.current;n.clearRect(0,0,nt,X);let a=v(Math.min(t/80,1));if(w(c.current,f.current),g.current=[],e.forEach((t,i)=>{let o=x[i],s=C(a,i,e.length,v),l=c.current.get(t.id)??0;if(s<.01)return;let u=(t.base??0)/(t.total||1),d=(t.variation??0)/(t.total||1),f=o.h*u,m=o.h*d,h=o.y+f/2,g=o.y+f+m/2,_=Math.max(2,(t.base??0)/r*T),y=Math.max(2,(t.variation??0)/p*E),b=O.y+e.slice(0,i).reduce((e,t)=>e+(t.base??0)/r*T,0)+_/2,S=k.y+e.slice(0,i).reduce((e,t)=>e+(t.variation??0)/p*E,0)+y/2,w=l*.2+.18;it(n,o.x+110,h,420-110/2,b,_*s,o.color,w),it(n,o.x+110,g,420-110/2,S,y*s,o.color,w*.75)}),a>.3){let e=Math.min(1,(a-.3)/.7),t=A.y+r/m*h/2,o=A.y+h-p/m*h/2;it(n,475,O.cy,720-110/2,t,T*e,i.blue,.25*e),it(n,475,k.cy,720-110/2,o,E*e,i.amber,.22*e)}if([`Contractors`,`Components`,`Total`].forEach((e,t)=>{let r=[100,420,720][t];n.font=`9px 'JetBrains Mono', monospace`,n.fillStyle=o(i.t3,.5),n.textAlign=`center`,n.fillText(e,r,X-8)}),e.forEach((t,r)=>{let s=x[r],l=C(a,r,e.length,v),d=c.current.get(t.id)??0;_(g.current,t.id,s.x,s.y,110,s.h,{label:t.name,value:`£${t.total??0}M total commitment`,sublabel:`Base £${t.base??0}M + Variations £${t.variation??0}M`,color:s.color}),d>0&&u(n,s.x+110/2,s.cy,110*.6,s.color,.12*d),n.fillStyle=o(s.color,(.3+d*.15)*l),n.strokeStyle=o(s.color,(.55+d*.25)*l),n.lineWidth=1,n.beginPath(),n.roundRect(s.x,s.y,110*l,s.h,4),n.fill(),n.stroke(),l>.6&&s.h>=24&&(n.globalAlpha=Math.min(1,(l-.6)/.4),n.font=`${d>0?`bold `:``}9px 'JetBrains Mono', monospace`,n.fillStyle=d>0?s.color:o(i.t2,.9),n.textAlign=`center`,n.textBaseline=`middle`,n.fillText(t.abbreviation??t.name.slice(0,6),s.x+110/2,s.h>=36?s.cy-5:s.cy),s.h>=36&&(n.font=`8px 'JetBrains Mono', monospace`,n.fillStyle=o(i.t3,.8),n.fillText(`£${t.total??0}M`,s.x+110/2,s.cy+7)),n.globalAlpha=1,n.textBaseline=`alphabetic`)}),a>.2){let e=Math.min(1,(a-.2)/.4);u(n,420,O.cy,30,i.blue,.1*e),n.fillStyle=o(i.blue,.3*e),n.strokeStyle=o(i.blue,.5*e),n.lineWidth=1,n.beginPath(),n.roundRect(O.x,O.y,110,O.h*e,4),n.fill(),n.stroke(),n.globalAlpha=e,n.textBaseline=`middle`,n.font=`bold 9px 'JetBrains Mono', monospace`,n.fillStyle=i.blue,n.textAlign=`center`,n.fillText(`Base Value`,420,O.cy-6),n.font=`10px 'JetBrains Mono', monospace`,n.fillStyle=i.t1,n.fillText(`£${r}M`,420,O.cy+8),n.globalAlpha=1,n.textBaseline=`alphabetic`,u(n,420,k.cy,24,i.amber,.1*e),n.fillStyle=o(i.amber,.22*e),n.strokeStyle=o(i.amber,.4*e),n.beginPath(),n.roundRect(k.x,k.y,110,k.h*e,4),n.fill(),n.stroke(),n.globalAlpha=e,n.textBaseline=`middle`,n.font=`bold 9px 'JetBrains Mono', monospace`,n.fillStyle=i.amber,n.textAlign=`center`,n.fillText(`Variations`,420,k.cy-4),n.font=`10px 'JetBrains Mono', monospace`,n.fillStyle=i.t1,n.fillText(`£${p}M`,420,k.cy+8),n.globalAlpha=1,n.textBaseline=`alphabetic`}if(a>.5){let e=Math.min(1,(a-.5)/.5);u(n,720,A.cy,44,i.cyan,.2*e),n.fillStyle=o(i.cyan,.25*e),n.strokeStyle=o(i.cyan,.6*e),n.lineWidth=1.5,n.beginPath(),n.roundRect(A.x,A.y,110,A.h*e,6),n.fill(),n.stroke(),n.globalAlpha=e,n.textBaseline=`middle`,n.font=`9px 'JetBrains Mono', monospace`,n.fillStyle=i.t2,n.textAlign=`center`,n.fillText(`Total Commitment`,720,A.cy-12),n.font=`bold 16px 'JetBrains Mono', monospace`,n.fillStyle=i.cyan,n.fillText(`£${m}M`,720,A.cy+6),n.globalAlpha=1,n.textBaseline=`alphabetic`}j=requestAnimationFrame(M)};return M(),()=>cancelAnimationFrame(j)},[e]),(0,n.jsxs)(`div`,{"data-testid":r,style:{position:`relative`,width:nt,height:X},children:[(0,n.jsx)(`canvas`,{ref:s,role:`img`,"aria-label":`Weekly report flow — base value and variations per contractor flowing to total commitment`,style:{width:nt,height:X,display:`block`}}),(0,n.jsx)(m,{...p,parentW:nt,parentH:X})]})}function it(e,t,n,r,i,a,s,c){let l=(t+r)/2;e.beginPath(),e.moveTo(t,n-a/2),e.bezierCurveTo(l,n-a/2,l,i-a/2,r,i-a/2),e.lineTo(r,i+a/2),e.bezierCurveTo(l,i+a/2,l,n+a/2,t,n+a/2),e.closePath(),e.fillStyle=o(s,c),e.fill()}function at({config:e,className:t}){return e.type===`line`?(0,n.jsx)(Se,{rows:e.rows,className:t}):e.type===`area`?(0,n.jsx)(O,{rows:e.rows,className:t}):e.type===`bar`?(0,n.jsx)(j,{rows:e.rows,className:t}):e.type===`pie`?(0,n.jsx)(Ae,{rows:e.rows,variant:`pie`,className:t}):e.type===`donut`?(0,n.jsx)(Ae,{rows:e.rows,variant:`donut`,className:t}):e.type===`sankey`?(0,n.jsx)(Ve,{rows:e.rows,className:t}):e.type===`flow`?(0,n.jsx)(Be,{selectedEntity:e.selectedEntity,className:t}):e.type===`trend`?(0,n.jsx)(Qe,{points:e.points,className:t}):e.type===`mini-bars`?(0,n.jsx)(Te,{rows:e.rows,className:t}):e.type===`contract-value-orb`?(0,n.jsx)(ge,{data:e.data}):e.type===`contract-bars`?(0,n.jsx)(fe,{contractors:e.contractors}):e.type===`commitment-race`?(0,n.jsx)(te,{contractors:e.contractors}):e.type===`status-arc`?(0,n.jsx)(Ze,{segments:e.segments,title:e.title}):e.type===`ew-category`?(0,n.jsx)(xe,{categories:e.categories}):e.type===`contractor-rank`?(0,n.jsx)(be,{contractors:e.contractors}):e.type===`severity-bands`?(0,n.jsx)(Ye,{severities:e.severities}):e.type===`nce-tree`?(0,n.jsx)(De,{total:e.total,byContractor:e.byContractor}):e.type===`compensation-gauge`?(0,n.jsx)(ie,{pct:e.pct,confirmed:e.confirmed,total:e.total}):e.type===`variation-split`?(0,n.jsx)(tt,{contractors:e.contractors}):e.type===`quotation-balance`?(0,n.jsx)(We,{accepted:e.accepted,submitted:e.submitted}):e.type===`quotation-trend`?(0,n.jsx)(Ke,{trend:e.trend}):e.type===`weekly-flow`?(0,n.jsx)(rt,{contractors:e.contractors}):(0,n.jsx)(`div`,{className:`viz-empty`,children:`Visualization unavailable`})}var ot=[];function st(e){try{return JSON.parse(decodeURIComponent(e))}catch{return null}}function ct(){for(;ot.length;){let e=ot.pop();e&&e.unmount()}}function lt(){ct(),document.querySelectorAll(`[data-d3-viz]`).forEach(t=>{let r=t.dataset.d3Viz;if(!r)return;let i=st(r);if(!i)return;let a=(0,e.createRoot)(t);ot.push(a),a.render((0,n.jsx)(at,{config:i}))})}function ut(e){return encodeURIComponent(JSON.stringify(e))}function dt({rows:e=[],className:t,colors:r}){return(0,n.jsx)(Ae,{rows:e,variant:`donut`,className:t,colors:r})}var Z={bg:`rgba(255,255,255,0.025)`,border:`rgba(28,45,66,0.9)`,t1:`#F1F5F9`,t2:`#CBD5E1`,t3:`#94A3B8`,t4:`#64748B`,red:`#F06060`,amber:`#FBBF24`,green:`#34D399`},Q=`'JetBrains Mono', monospace`,$=`'DM Sans', sans-serif`;function ft({chips:e}){return(0,n.jsx)(`div`,{style:{display:`flex`,gap:6,marginTop:10},children:e.map((e,t)=>(0,n.jsxs)(`div`,{style:{flex:1,display:`flex`,alignItems:`baseline`,gap:8,padding:`8px 12px`,background:Z.bg,border:`1px solid ${Z.border}`,borderRadius:5},children:[(0,n.jsx)(`span`,{style:{fontSize:13,fontWeight:700,color:e.color??Z.t1,fontFamily:Q},children:e.value}),(0,n.jsx)(`span`,{style:{fontSize:11,color:Z.t4,fontFamily:$,lineHeight:1.4},children:e.label})]},t))})}function pt({items:e}){return(0,n.jsx)(`div`,{style:{display:`flex`,gap:8},children:e.map((e,t)=>(0,n.jsxs)(`div`,{style:{flex:1,padding:`12px 16px`,background:Z.bg,border:`1px solid ${Z.border}`,borderTop:`2px solid ${e.color??Z.t4}`,borderRadius:7,textAlign:`center`},children:[(0,n.jsx)(`div`,{style:{fontSize:22,fontWeight:700,color:e.color??Z.t1,fontFamily:Q,lineHeight:1.15},children:e.value}),(0,n.jsx)(`div`,{style:{fontSize:11,color:Z.t4,fontFamily:$,marginTop:5,lineHeight:1.45},children:e.label})]},t))})}function mt({items:e}){return(0,n.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:5},children:e.map((e,t)=>(0,n.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:12,padding:`9px 14px`,background:Z.bg,border:`1px solid ${Z.border}`,borderLeft:`3px solid ${e.color}`,borderRadius:6},children:[(0,n.jsx)(`span`,{style:{fontSize:11,fontWeight:600,color:e.color,background:e.color+`22`,padding:`2px 8px`,borderRadius:4,fontFamily:$,flexShrink:0},children:e.name}),(0,n.jsx)(`span`,{style:{fontSize:18,fontWeight:700,color:e.color,fontFamily:Q,minWidth:70,flexShrink:0},children:e.value}),(0,n.jsx)(`span`,{style:{fontSize:11,color:Z.t4,fontFamily:$,flex:1,lineHeight:1.45},children:e.kpiLabel})]},t))})}function ht({items:e}){return(0,n.jsx)(`div`,{style:{display:`flex`,gap:8},children:e.map((e,t)=>(0,n.jsxs)(`div`,{style:{flex:1,padding:`14px 16px`,background:Z.bg,border:`1px solid ${e.color?e.color+`30`:Z.border}`,borderRadius:7},children:[(0,n.jsx)(`div`,{style:{fontSize:26,fontWeight:700,color:e.color??Z.t1,fontFamily:Q,lineHeight:1.1},children:e.value}),(0,n.jsx)(`div`,{style:{fontSize:14,color:Z.t4,fontFamily:$,marginTop:6,lineHeight:1.5},children:e.label})]},t))})}var gt={red:Z.red,amber:Z.amber,green:Z.green};function _t({items:e}){return(0,n.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:5},children:e.map((e,t)=>{let r=gt[e.severity];return(0,n.jsxs)(`div`,{style:{display:`flex`,alignItems:`flex-start`,gap:10,padding:`10px 14px`,background:r+`0C`,border:`1px solid ${r}28`,borderLeft:`3px solid ${r}`,borderRadius:6},children:[(0,n.jsx)(`span`,{style:{width:7,height:7,borderRadius:`50%`,background:r,flexShrink:0,marginTop:5}}),(0,n.jsx)(`span`,{style:{fontSize:12,color:Z.t2,fontFamily:$,lineHeight:1.6},children:e.text})]},t)})})}function vt({min:e,max:t,unit:r,dots:i,chips:a}){let o=t-e;return(0,n.jsxs)(`div`,{children:[(0,n.jsxs)(`div`,{style:{position:`relative`,height:90,marginTop:4},children:[(0,n.jsx)(`div`,{style:{position:`absolute`,top:38,left:8,right:8,height:2,background:`rgba(255,255,255,0.08)`,borderRadius:1}}),(0,n.jsxs)(`div`,{style:{position:`absolute`,top:43,left:0,fontSize:9,color:Z.t4,fontFamily:Q},children:[e,r]}),(0,n.jsxs)(`div`,{style:{position:`absolute`,top:43,right:0,fontSize:9,color:Z.t4,fontFamily:Q},children:[t,r]}),i.map((t,i)=>{let a=(t.val-e)/o*100,s=i%2==0;return(0,n.jsxs)(`div`,{style:{position:`absolute`,left:`${a}%`,top:0,transform:`translateX(-50%)`},children:[s&&(0,n.jsxs)(`div`,{style:{textAlign:`center`,marginBottom:2},children:[(0,n.jsx)(`div`,{style:{fontSize:9,color:t.color,fontFamily:$,whiteSpace:`nowrap`},children:t.name}),(0,n.jsxs)(`div`,{style:{fontSize:9,fontWeight:700,color:t.color,fontFamily:Q,whiteSpace:`nowrap`},children:[t.val,r]})]}),(0,n.jsx)(`div`,{style:{width:10,height:10,borderRadius:`50%`,background:t.color,boxShadow:`0 0 8px ${t.color}70`,margin:s?`0 auto`:`26px auto 0`}}),!s&&(0,n.jsxs)(`div`,{style:{textAlign:`center`,marginTop:4},children:[(0,n.jsx)(`div`,{style:{fontSize:9,color:t.color,fontFamily:$,whiteSpace:`nowrap`},children:t.name}),(0,n.jsxs)(`div`,{style:{fontSize:9,fontWeight:700,color:t.color,fontFamily:Q,whiteSpace:`nowrap`},children:[t.val,r]})]})]},i)})]}),a&&a.length>0&&(0,n.jsx)(ft,{chips:a})]})}function yt({leftPct:e,leftLabel:t,leftValue:r,leftColor:i,rightPct:a,rightLabel:o,rightValue:s,rightColor:c,chips:l}){return(0,n.jsxs)(`div`,{children:[(0,n.jsxs)(`div`,{style:{display:`flex`,borderRadius:6,overflow:`hidden`,height:36,marginBottom:8},children:[(0,n.jsx)(`div`,{style:{width:`${e}%`,background:i+`38`,display:`flex`,alignItems:`center`,justifyContent:`flex-end`,paddingRight:12},children:(0,n.jsx)(`span`,{style:{fontSize:12,fontWeight:700,color:i,fontFamily:Q},children:r})}),(0,n.jsx)(`div`,{style:{width:1,background:`rgba(255,255,255,0.12)`,flexShrink:0}}),(0,n.jsx)(`div`,{style:{width:`${a}%`,background:c+`2A`,display:`flex`,alignItems:`center`,paddingLeft:12},children:(0,n.jsx)(`span`,{style:{fontSize:12,fontWeight:700,color:c,fontFamily:Q},children:s})})]}),(0,n.jsxs)(`div`,{style:{display:`flex`,marginBottom:l?4:0},children:[(0,n.jsx)(`div`,{style:{width:`${e}%`},children:(0,n.jsxs)(`span`,{style:{fontSize:10,color:i,fontFamily:$},children:[e,`% `,t]})}),(0,n.jsx)(`div`,{style:{width:`${a}%`,paddingLeft:10},children:(0,n.jsxs)(`span`,{style:{fontSize:10,color:c,fontFamily:$},children:[a,`% `,o]})})]}),l&&l.length>0&&(0,n.jsx)(ft,{chips:l})]})}function bt({pct:e,label:t,color:r,chips:i}){let a=2*Math.PI*30,o=a*(1-e/100);return(0,n.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:20},children:[(0,n.jsxs)(`div`,{style:{position:`relative`,flexShrink:0,width:80,height:80},children:[(0,n.jsxs)(`svg`,{width:80,height:80,style:{transform:`rotate(-90deg)`},children:[(0,n.jsx)(`circle`,{cx:40,cy:40,r:30,fill:`none`,stroke:`rgba(255,255,255,0.07)`,strokeWidth:8}),(0,n.jsx)(`circle`,{cx:40,cy:40,r:30,fill:`none`,stroke:r,strokeWidth:8,strokeDasharray:a,strokeDashoffset:o,strokeLinecap:`round`})]}),(0,n.jsx)(`div`,{style:{position:`absolute`,top:`50%`,left:`50%`,transform:`translate(-50%, -50%)`,textAlign:`center`},children:(0,n.jsxs)(`div`,{style:{fontSize:15,fontWeight:700,color:r,fontFamily:Q},children:[e,`%`]})})]}),(0,n.jsxs)(`div`,{style:{flex:1},children:[(0,n.jsx)(`div`,{style:{fontSize:12,color:Z.t3,fontFamily:$,marginBottom:10,lineHeight:1.5},children:t}),i&&(0,n.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:5},children:i.map((e,t)=>(0,n.jsxs)(`div`,{style:{display:`flex`,alignItems:`baseline`,gap:8,padding:`7px 10px`,background:Z.bg,border:`1px solid ${Z.border}`,borderRadius:5},children:[(0,n.jsx)(`span`,{style:{fontSize:13,fontWeight:700,color:e.color??Z.t1,fontFamily:Q},children:e.value}),(0,n.jsx)(`span`,{style:{fontSize:11,color:Z.t4,fontFamily:$,lineHeight:1.4},children:e.label})]},t))})]})]})}var xt={green:`#34D39918`,amber:`#FBBF2418`,red:`#F0606018`},St={green:`#34D399`,amber:`#FBBF24`,red:`#F06060`};function Ct({items:e}){return(0,n.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:5},children:e.map((e,t)=>(0,n.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:10,padding:`8px 12px`,background:Z.bg,border:`1px solid ${Z.border}`,borderLeft:`3px solid ${e.color}`,borderRadius:6},children:[(0,n.jsx)(`span`,{style:{fontSize:11,fontWeight:600,color:e.color,background:e.color+`1A`,padding:`2px 7px`,borderRadius:4,fontFamily:$,flexShrink:0,minWidth:62,textAlign:`center`},children:e.name}),(0,n.jsx)(`div`,{style:{flex:1,height:4,background:`rgba(255,255,255,0.07)`,borderRadius:2,overflow:`hidden`},children:(0,n.jsx)(`div`,{style:{height:`100%`,width:`${e.pct}%`,background:e.color,borderRadius:2,opacity:.75}})}),(0,n.jsx)(`span`,{style:{fontSize:13,fontWeight:700,color:e.color,fontFamily:Q,flexShrink:0,minWidth:52,textAlign:`right`},children:e.value}),e.badge&&e.badgeSeverity&&(0,n.jsx)(`span`,{style:{fontSize:10,fontWeight:600,color:St[e.badgeSeverity],background:xt[e.badgeSeverity],padding:`2px 7px`,borderRadius:4,fontFamily:$,flexShrink:0,minWidth:72,textAlign:`center`},children:e.badge}),e.sublabel&&(0,n.jsx)(`span`,{style:{fontSize:10,color:Z.t4,fontFamily:$,flexShrink:0,minWidth:80,textAlign:`right`},children:e.sublabel})]},t))})}var wt={red:Z.red,amber:Z.amber,green:Z.green};function Tt({items:e}){return(0,n.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:5},children:e.map((e,t)=>{let r=wt[e.severity];return(0,n.jsxs)(`div`,{style:{display:`flex`,alignItems:`flex-start`,gap:10,padding:`9px 12px`,background:r+`0A`,border:`1px solid ${r}25`,borderLeft:`3px solid ${r}`,borderRadius:6},children:[(0,n.jsx)(`span`,{style:{width:7,height:7,borderRadius:`50%`,background:r,flexShrink:0,marginTop:5}}),(0,n.jsx)(`span`,{style:{flex:1,fontSize:12,color:Z.t2,fontFamily:$,lineHeight:1.5},children:e.text}),(0,n.jsx)(`span`,{style:{fontSize:10,fontWeight:600,color:r,background:r+`20`,padding:`2px 7px`,borderRadius:4,fontFamily:$,flexShrink:0},children:e.tag}),(0,n.jsx)(`span`,{style:{fontSize:10,color:Z.t4,fontFamily:Q,flexShrink:0,marginTop:1},children:e.date})]},t)})})}function Et({columns:e,rows:t}){return(0,n.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:5},children:[(0,n.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:10,padding:`0 12px 6px`,borderBottom:`1px solid ${Z.border}`},children:[(0,n.jsx)(`div`,{style:{minWidth:64}}),e.map((e,t)=>(0,n.jsx)(`div`,{style:{flex:1,fontSize:9,fontWeight:600,color:Z.t4,fontFamily:$,textTransform:`uppercase`,letterSpacing:.6},children:e},t))]}),t.map((e,t)=>(0,n.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:10,padding:`8px 12px`,background:Z.bg,border:`1px solid ${Z.border}`,borderLeft:`3px solid ${e.color??Z.t4}`,borderRadius:6},children:[(0,n.jsx)(`span`,{style:{fontSize:11,fontWeight:600,color:e.color??Z.t2,background:(e.color??Z.t4)+`1A`,padding:`2px 8px`,borderRadius:4,fontFamily:$,flexShrink:0,minWidth:64,textAlign:`center`},children:e.label}),e.cells.map((t,r)=>(0,n.jsx)(`span`,{style:{flex:1,fontSize:13,fontWeight:700,color:e.color??Z.t1,fontFamily:Q},children:t},r))]},t))]})}function Dt({text:e}){return(0,n.jsxs)(`div`,{style:{marginTop:10,padding:`8px 12px`,background:`rgba(255,255,255,0.015)`,border:`1px solid ${Z.border}`,borderLeft:`2px solid rgba(100,116,139,0.35)`,borderRadius:5},children:[(0,n.jsx)(`span`,{style:{fontSize:10,fontWeight:700,color:Z.t4,fontFamily:$,letterSpacing:.5,textTransform:`uppercase`,marginRight:8},children:`Takeaway`}),(0,n.jsx)(`span`,{style:{fontSize:11,color:Z.t3,fontFamily:$,lineHeight:1.6},children:e})]})}function Ot({block:e}){if(!e)return null;let t=(()=>{switch(e.type){case`stats`:return(0,n.jsx)(pt,{items:e.items});case`ranked`:return(0,n.jsx)(mt,{items:e.items});case`chips`:return(0,n.jsx)(ht,{items:e.items});case`badges`:return(0,n.jsx)(_t,{items:e.items});case`dot-strip`:return(0,n.jsx)(vt,{min:e.min,max:e.max,unit:e.unit,dots:e.dots,chips:e.chips});case`proportion`:return(0,n.jsx)(yt,{leftPct:e.leftPct,leftLabel:e.leftLabel,leftValue:e.leftValue,leftColor:e.leftColor,rightPct:e.rightPct,rightLabel:e.rightLabel,rightValue:e.rightValue,rightColor:e.rightColor,chips:e.chips});case`ring`:return(0,n.jsx)(bt,{pct:e.pct,label:e.label,color:e.color,chips:e.chips});case`scorecard-rows`:return(0,n.jsx)(Ct,{items:e.items});case`flags-list`:return(0,n.jsx)(Tt,{items:e.items});case`comparison-rows`:return(0,n.jsx)(Et,{columns:e.columns,rows:e.rows});default:return null}})();return e.takeaway?(0,n.jsxs)(`div`,{children:[t,(0,n.jsx)(Dt,{text:e.takeaway})]}):t}exports.AreaChart=O,exports.BarChart=j,exports.ChartFrame=r,exports.DonutChart=dt,exports.KeyHighlights=Ot,exports.LineChart=Se,exports.MiniBars=Te,exports.PieChart=Ae,exports.ProcessSankey=Be,exports.RankingSankey=Ve,exports.SankeySvg=Me,exports.SeriesChart=D,exports.TrendChart=Qe,exports.VisualizationRenderer=at,exports.cleanupVisualizationMounts=ct,exports.hydrateVisualizationMounts=lt,exports.serializeVisualizationConfig=ut;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require(`react-dom/client`),t=require(`react`),n=require(`react/jsx-runtime`);function r({children:e,className:t=``}){return(0,n.jsx)(`div`,{className:`d3-chart ${t}`.trim(),children:e})}var i={bg:`#0C0E12`,bgL:`#0C1420`,sf:`#13161B`,bd:`#22262F`,blue:`#2970FF`,cyan:`#36BFFA`,orange:`#EF6820`,red:`#D92D20`,green:`#16B364`,purple:`#7A5AF8`,amber:`#FAC515`,t1:`#F7F7F7`,t2:`#94979C`,t3:`#94979C`,t4:`#334155`},a=[i.blue,i.cyan,i.amber,i.purple,i.green,i.red],o={font:`400 12px 'Satoshi Variable', 'DM Sans', sans-serif`,color:i.t2},s={font:`400 12px 'Satoshi Variable', 'DM Sans', sans-serif`,color:i.t2};function c(e,t=1){let n=e.replace(`#`,``);return`rgba(${parseInt(n.substring(0,2),16)},${parseInt(n.substring(2,4),16)},${parseInt(n.substring(4,6),16)},${t})`}function l(e,t,n){return e+(t-e)*n}function u(e,t,n){let r=e=>{let t=e.replace(`#`,``);return[parseInt(t.substring(0,2),16),parseInt(t.substring(2,4),16),parseInt(t.substring(4,6),16)]},[i,a,o]=r(e),[s,c,u]=r(t),d=e=>Math.max(0,Math.min(255,Math.round(e)));return[d(l(i,s,n)),d(l(a,c,n)),d(l(o,u,n))].map(e=>e.toString(16).padStart(2,`0`)).join(``).replace(/^/,`#`)}function d(e,t,n,r=2){e.width=t*r,e.height=n*r;let i=e.getContext(`2d`);return i.scale(r,r),i}function f(e,t,n,r,i,a=.3){let o=e.createRadialGradient(t,n,0,t,n,r);o.addColorStop(0,c(i,a)),o.addColorStop(1,c(i,0)),e.fillStyle=o,e.beginPath(),e.arc(t,n,r,0,Math.PI*2),e.fill()}function p(e,t,n,r,a=50,o=c(i.blue,.05)){for(let i=0;i<a;i++)e.beginPath(),e.arc((Math.sin(r*.001+i*23)*.5+.5)*t,(Math.cos(r*8e-4+i*37)*.5+.5)*n,.6,0,Math.PI*2),e.fillStyle=o,e.fill()}function m(e,t,n,r,i=.015){e.fillStyle=`rgba(0,0,0,${i})`;let a=r*.5%6;for(let r=a;r<n;r+=3)e.fillRect(0,r,t,1)}function h(e,t,n,r,a=c(i.t1,.08)){e.strokeStyle=a,e.lineWidth=1,e.setLineDash([3,3]),e.beginPath(),e.moveTo(t,n),e.lineTo(t,r),e.stroke(),e.setLineDash([])}function g({visible:e,x:r,y:a,content:o,parentW:s}){let c=(0,t.useRef)(null);if((0,t.useLayoutEffect)(()=>{let t=c.current;if(!t)return;let n=t.offsetWidth,l=r-n/2,u=a-58;l<4&&(l=4),l+n>(s??400)-4&&(l=(s??400)-n-4),u<4&&(u=a+16),t.style.transform=`translate(${l}px, ${u}px)`,t.style.opacity=e?`1`:`0`;let d=o&&typeof o==`object`&&o.color?o.color:i.blue;t.style.setProperty(`--tooltip-accent`,d??i.blue)},[e,r,a,s,o]),!o)return null;let l=typeof o==`object`,u=l?o.label:null,d=l?o.value:o,f=l?o.sublabel:null;return(0,n.jsxs)(`div`,{ref:c,style:{position:`absolute`,top:0,left:0,minWidth:80,pointerEvents:`none`,background:i.sf,border:`1px solid ${i.bd}`,borderLeft:`2px solid var(--tooltip-accent)`,borderRadius:6,padding:`8px 12px`,opacity:0,transition:`opacity 0.15s ease`,zIndex:20,fontFamily:`'Satoshi Variable', 'DM Sans', sans-serif`},children:[u&&(0,n.jsx)(`div`,{style:{fontSize:12,fontWeight:400,color:i.t2,marginBottom:3,whiteSpace:`nowrap`,lineHeight:`18px`},children:u}),(0,n.jsx)(`div`,{style:{fontSize:14,fontWeight:500,color:i.t1,whiteSpace:`nowrap`,lineHeight:`20px`},children:d}),f&&(0,n.jsx)(`div`,{style:{fontSize:12,fontWeight:400,color:`var(--tooltip-accent)`,marginTop:3,whiteSpace:`nowrap`,lineHeight:`18px`},children:f})]})}function _(e,{width:n,height:r,onClick:i,enabled:a=!0}){let o=(0,t.useRef)({x:-1,y:-1,over:!1}),s=(0,t.useRef)(null),c=(0,t.useRef)([]),l=(0,t.useRef)(null),[u,d]=(0,t.useState)({visible:!1,x:0,y:0,content:null}),f=(0,t.useCallback)((e,t,n)=>{l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{d({visible:!0,x:e,y:t,content:n})},30)},[]),p=(0,t.useCallback)(()=>{l.current&&clearTimeout(l.current),d(e=>e.visible?{visible:!1,x:e.x,y:e.y,content:e.content}:e)},[]);return(0,t.useEffect)(()=>{let t=e.current;if(!t||!a)return;let u=e=>{let i=t.getBoundingClientRect(),a=n/i.width,l=r/i.height;o.current.x=(e.clientX-i.left)*a,o.current.y=(e.clientY-i.top)*l,o.current.over=!0;let u=null,d=c.current;for(let e=d.length-1;e>=0;e--)if(d[e].test(o.current.x,o.current.y)){u=d[e];break}let m=s.current;s.current=u?u.id:null,t.style.cursor=u?`pointer`:`default`,u?f((e.clientX-i.left)*a,(e.clientY-i.top)*l,u.data):m&&p()},d=()=>{o.current={x:-1,y:-1,over:!1},s.current&&(s.current=null,t.style.cursor=`default`,p())},m=()=>{if(s.current&&i){let e=c.current.find(e=>e.id===s.current);e&&i(e.id,e.data)}};return t.addEventListener(`mousemove`,u),t.addEventListener(`mouseleave`,d),t.addEventListener(`click`,m),()=>{t.removeEventListener(`mousemove`,u),t.removeEventListener(`mouseleave`,d),t.removeEventListener(`click`,m),l.current&&clearTimeout(l.current)}},[e,n,r,a,i,f,p]),{mouseRef:o,hoveredRef:s,tooltip:u,showTooltip:f,hideTooltip:p,hitZonesRef:c}}function v(e,t,n,r,i,a){e.push({id:t,data:a,test:(e,t)=>(e-n)**2+(t-r)**2<=i*i})}function y(e,t,n,r,i,a,o){e.push({id:t,data:o,test:(e,t)=>e>=n&&e<=n+i&&t>=r&&t<=r+a})}var b=e=>1-(1-e)**3,x=e=>1-(1-e)**4,S=e=>e===1?1:1-2**(-10*e),C=e=>{let t=1.70158;return 1+(t+1)*(e-1)**3+t*(e-1)**2},w=(e,t=.04,n=.001)=>Math.sin(e*t)*Math.exp(-Math.min(e*n,4)),T=(e,t,n,r=b)=>{let i=Math.min(.06,.5/n),a=t*i,o=1-(n-1)*i;return r(Math.max(0,Math.min((e-a)/o,1)))};function E(e,t,n=.12){e.forEach((r,i)=>{let a=i===t?1:0,o=r+(a-r)*n;Math.abs(o-a)<.005?a===0?e.delete(i):e.set(i,1):e.set(i,o)}),t&&!e.has(t)&&e.set(t,0)}var D=760,O=250;function k({rows:e=[],variant:a,className:o,colors:s}){let l=(0,t.useRef)(null),u=(0,t.useRef)(new Map),p=(0,t.useRef)(0),{mouseRef:m,hoveredRef:y,tooltip:b,hitZonesRef:x}=_(l,{width:D,height:O});return(0,t.useEffect)(()=>{let t=l.current;if(!t)return;let n=d(t,D,O);p.current=0;let r=s?.line??i.blue,o=s?.point??i.blue,g=s?.axisLine??i.bd,_=s?.areaFill??i.blue,b={top:24,right:24,bottom:44,left:24},C=D-b.left-b.right,T=O-b.top-b.bottom,k,A=()=>{p.current++;let t=p.current;if(n.clearRect(0,0,D,O),e.length<2){k=requestAnimationFrame(A);return}let s=e.map(e=>e.pricing??0),l=Math.max(100,...s),d=t=>b.left+t/(e.length-1)*C,j=e=>b.top+(1-e/l)*T,M=S(Math.min(t/48,1)),N=Math.max(2,Math.floor(M*e.length));E(u.current,y.current),x.current=[],n.strokeStyle=c(i.bd,.2),n.lineWidth=.5;for(let e=0;e<=4;e++){let t=b.top+e/4*T;n.beginPath(),n.moveTo(b.left,t),n.lineTo(b.left+C,t),n.stroke()}if(n.strokeStyle=c(g,.4),n.lineWidth=1,n.setLineDash([]),n.beginPath(),n.moveTo(b.left,j(0)),n.lineTo(b.left+C,j(0)),n.stroke(),m.current.over&&y.current){let e=parseInt(y.current.split(`-`)[1]);isNaN(e)||h(n,d(e),b.top,b.top+T)}if(a===`area`&&N>1){let t=n.createLinearGradient(0,b.top,0,b.top+T);t.addColorStop(0,c(_,.12)),t.addColorStop(1,c(_,0)),n.fillStyle=t,n.beginPath(),n.moveTo(d(0),b.top+T);for(let t=0;t<N;t++)n.lineTo(d(t),j(e[t].pricing??0));n.lineTo(d(N-1),b.top+T),n.closePath(),n.fill()}if(N>1){n.strokeStyle=c(r,.85),n.lineWidth=2,n.setLineDash([]),n.beginPath();for(let t=0;t<N;t++){let r=d(t),i=j(e[t].pricing??0);t===0?n.moveTo(r,i):n.lineTo(r,i)}n.stroke()}for(let r=0;r<N;r++){let s=d(r),l=j(e[r].pricing??0),p=`sc-${r}`,m=u.current.get(p)??0,h=r===e.length-1;v(x.current,p,s,l,12,{label:e[r].vendor,value:String(e[r].pricing??0),color:h?i.red:o}),m>0&&f(n,s,l,16*m,o,.2*m);let g=h?w(t,.05,5e-4):0,_=a===`area`?5:6;h?(n.shadowColor=c(i.red,.5),n.shadowBlur=(8+g*4)*(1+m*.5),n.fillStyle=i.red,n.beginPath(),n.arc(s,l,(_+g*1.5)*(1+m*.3),0,Math.PI*2),n.fill(),n.shadowBlur=0):(n.fillStyle=c(o,.7+m*.3),n.beginPath(),n.arc(s,l,_+m*2,0,Math.PI*2),n.fill()),n.font=`10px 'JetBrains Mono', monospace`,n.fillStyle=c(i.t3,.6+m*.3),n.textAlign=`center`,n.fillText(e[r].vendor,s,O-14)}k=requestAnimationFrame(A)};return A(),()=>cancelAnimationFrame(k)},[e,a,s]),(0,n.jsx)(r,{className:o,children:(0,n.jsxs)(`div`,{style:{position:`relative`,width:D,height:O},children:[(0,n.jsx)(`canvas`,{ref:l,role:`img`,"aria-label":`${a} chart`,style:{width:D,height:O,display:`block`,borderRadius:8}}),(0,n.jsx)(g,{...b,parentW:D,parentH:O})]})})}function A({rows:e=[],className:t,colors:r}){return(0,n.jsx)(k,{rows:e,variant:`area`,className:t,colors:r})}var j=760,M=280;function N({rows:e=[],className:o,colors:s}){let l=(0,t.useRef)(null),u=(0,t.useRef)(new Map),p=(0,t.useRef)(0),{hoveredRef:m,tooltip:h,hitZonesRef:v}=_(l,{width:j,height:M});return(0,t.useEffect)(()=>{let t=l.current;if(!t)return;let n=d(t,j,M);p.current=0;let r=s?.bars??a,o=s?.axisLine??i.bd,h=s?.valueLabel??i.t2,g={top:24,right:24,bottom:56,left:24},_=M-g.top-g.bottom,b=(j-g.left-g.right)/Math.max(e.length,1),S=Math.max(100,...e.map(e=>e.pricing??0)),C=g.top+_,w,D=()=>{p.current++;let t=p.current;n.clearRect(0,0,j,M);let a=x(Math.min(t/48,1));E(u.current,m.current),v.current=[],n.strokeStyle=c(o,.4),n.lineWidth=1,n.setLineDash([]),n.beginPath(),n.moveTo(g.left,C),n.lineTo(j-g.right,C),n.stroke(),e.forEach((t,o)=>{let s=g.left+o*b,l=T(a,o,e.length,x),d=S>0?(t.pricing??0)/S*_:0,p=Math.max(d>0?4:0,d*l),m=r[o%r.length],w=u.current.get(t.id??`bar-${o}`)??0;y(v.current,t.id??`bar-${o}`,s+4,C-p,b-8,p,{label:t.vendor,value:String(t.pricing??0),color:m}),p>0&&(w>0&&f(n,s+b/2,C-p/2,b*.8,m,.12*w),n.shadowColor=c(m,.2*(w>0?w:0)),n.shadowBlur=w>0?6:0,n.fillStyle=c(m,.5+w*.25),n.beginPath(),n.roundRect(s+4,C-p,b-8,p,[4,4,0,0]),n.fill(),n.shadowBlur=0,w>0&&(n.strokeStyle=c(m,.4*w),n.lineWidth=1,n.beginPath(),n.roundRect(s+4,C-p,b-8,p,[4,4,0,0]),n.stroke())),l>.5&&p>0&&(n.globalAlpha=Math.min(1,(l-.5)*2),n.font=`bold 10px 'JetBrains Mono', monospace`,n.fillStyle=w>0?m:c(h,.7),n.textAlign=`center`,n.fillText(String(t.pricing??``),s+b/2,C-p-6),n.globalAlpha=1),n.font=`${w>0?`bold `:``}9px 'JetBrains Mono', monospace`,n.fillStyle=w>0?m:c(i.t3,.6),n.textAlign=`center`,n.fillText(t.vendor,s+b/2,M-14)}),w=requestAnimationFrame(D)};return D(),()=>cancelAnimationFrame(w)},[e,s]),(0,n.jsx)(r,{className:o,children:(0,n.jsxs)(`div`,{style:{position:`relative`,width:j,height:M},children:[(0,n.jsx)(`canvas`,{ref:l,role:`img`,"aria-label":`bar chart`,style:{width:j,height:M,display:`block`,borderRadius:8}}),(0,n.jsx)(g,{...h,parentW:j,parentH:M})]})})}var P=680,F=300,ee=[i.green,i.blue,i.cyan,i.amber,i.red];function te({contractors:e=[],"data-testid":r}){let a=(0,t.useRef)(null),s=(0,t.useRef)(0),l=(0,t.useRef)(new Map),u=[...e].sort((e,t)=>(t.percentage??0)-(e.percentage??0)),{hoveredRef:h,tooltip:y,hitZonesRef:x}=_(a,{width:P,height:F});return(0,t.useEffect)(()=>{let e=a.current;if(!e)return;let t=d(e,P,F);s.current=0;let n=P*.13,r=P*.08,g=F*.08,_=F*.14,y=P-n-r,S,C=()=>{s.current++;let e=s.current;t.clearRect(0,0,P,F),x.current=[],l.current.forEach((e,t)=>{let n=t===h.current?1:0,r=e+(n-e)*.12;Math.abs(r-n)<.005?n===0?l.current.delete(t):l.current.set(t,1):l.current.set(t,r)}),h.current&&!l.current.has(h.current)&&l.current.set(h.current,0),p(t,P,F,e,40,c(i.blue,.04)),u.forEach((r,i)=>{let a=ee[i%ee.length],s=l.current.get(r.id)??0,u=g+i*(_+10);t.fillStyle=c(a,.04+s*.04),t.beginPath(),t.roundRect(n,u,y,_,3),t.fill(),t.strokeStyle=c(a,.08),t.lineWidth=1,t.setLineDash([4,4]),t.beginPath(),t.moveTo(n,u+_/2),t.lineTo(n+y,u+_/2),t.stroke(),t.setLineDash([]);let d=(r.percentage??0)/100,p=n+y*Math.min(d,d*b(Math.min(1,e*.005)));if(p>n+4){let e=t.createLinearGradient(n,0,p,0);e.addColorStop(0,c(a,.02)),e.addColorStop(1,c(a,.25+s*.15)),t.fillStyle=e,t.beginPath(),t.roundRect(n,u+2,p-n,_-4,2),t.fill()}f(t,p,u+_/2,18+s*8,a,.3+s*.2),t.beginPath(),t.arc(p,u+_/2,5+s*2,0,Math.PI*2),t.fillStyle=c(a,.9),t.fill(),v(x.current,r.id,p,u+_/2,14,{label:r.name,value:`${r.percentage??0}% commitment`,sublabel:`Base: £${r.base??0}M · Variations: £${r.variation??0}M`,color:a}),t.font=`bold `+o.font,t.fillStyle=c(a,.9+s*.1),t.textAlign=`left`,t.textBaseline=`middle`,t.fillText(`${r.percentage??0}%`,p+10,u+_/2),t.font=`${s>0?`bold `:``}`+o.font,t.fillStyle=s>0?a:o.color,t.textAlign=`right`,t.fillText(r.abbreviation??r.name.slice(0,6),n-8,u+_/2)}),t.strokeStyle=c(i.t3,.3),t.lineWidth=1,t.setLineDash([]),t.beginPath(),t.moveTo(n+y,g),t.lineTo(n+y,g+(u.length-1)*(_+10)+_),t.stroke(),m(t,P,F,e,.015),S=requestAnimationFrame(C)};return C(),()=>cancelAnimationFrame(S)},[u]),(0,n.jsxs)(`div`,{"data-testid":r,style:{position:`relative`,width:P,height:F},children:[(0,n.jsx)(`canvas`,{ref:a,role:`img`,"aria-label":`Commitment race — contractors ranked by commitment percentage`,style:{width:P,height:F,display:`block`,borderRadius:8}}),(0,n.jsx)(g,{...y,parentW:P,parentH:F})]})}var ne=480,re=340;function ie({pct:e,confirmed:r,total:a,"data-testid":s}){let l=(0,t.useRef)(null),u=(0,t.useRef)(0);return(0,t.useEffect)(()=>{let t=l.current;if(!t)return;let n=d(t,ne,re);u.current=0;let s=ne/2,p=Math.PI,m=2*Math.PI,h=Math.PI,g,_=()=>{u.current++;let t=u.current;n.clearRect(0,0,ne,re);let l=b(Math.min(t/80,1)),d=C(Math.min(t/72,1));n.beginPath(),n.arc(s,220,120,p,m),n.strokeStyle=c(i.bd,.35),n.lineWidth=46,n.stroke(),[{start:0,end:.33,color:i.red},{start:.33,end:.66,color:i.amber},{start:.66,end:1,color:i.green}].forEach(e=>{let t=p+e.start*h,r=p+e.end*h;n.beginPath(),n.arc(s,220,194/2,t,r),n.strokeStyle=c(e.color,.12),n.lineWidth=42,n.stroke()}),[{label:`Low`,angle:p+.16*h},{label:`Mid`,angle:p+.5*h},{label:`High`,angle:p+.84*h}].forEach(({label:e,angle:t})=>{let r=s+Math.cos(t)*166,a=220+Math.sin(t)*166;n.font=`400 14px 'Satoshi Variable', 'DM Sans', sans-serif`,n.fillStyle=c(i.t3,.55),n.textAlign=`center`,n.fillText(e,r,a+3)});let v=p+e/100*h*l,y=e>=66?i.green:e>=33?i.amber:i.red;f(n,s+Math.cos(v)*194/2,220+Math.sin(v)*194/2,18,y,.35*l),n.beginPath(),n.arc(s,220,194/2,p,v),n.strokeStyle=c(y,.7*l),n.lineWidth=38,n.lineCap=`round`,n.stroke(),n.lineCap=`butt`;let x=p+e/100*h*d,S=s+Math.cos(x)*82,w=220+Math.sin(x)*82,T=s-Math.cos(x)*14,E=220-Math.sin(x)*14;n.strokeStyle=c(y,.18*d),n.lineWidth=6,n.lineCap=`round`,n.beginPath(),n.moveTo(T,E),n.lineTo(S,w),n.stroke(),n.strokeStyle=c(i.t1,.92*d),n.lineWidth=2,n.lineCap=`round`,n.beginPath(),n.moveTo(T,E),n.lineTo(S,w),n.stroke(),n.beginPath(),n.arc(S,w,3,0,Math.PI*2),n.fillStyle=c(y,.9*d),n.fill(),f(n,s,220,20,y,.25*d),n.beginPath(),n.arc(s,220,9,0,Math.PI*2),n.strokeStyle=c(y,.5*d),n.lineWidth=1.5,n.stroke(),n.beginPath(),n.arc(s,220,5,0,Math.PI*2),n.fillStyle=i.t1,n.fill(),l>.5&&(n.globalAlpha=Math.min(1,(l-.5)/.5),n.font=`500 24px 'Satoshi Variable', 'DM Sans', sans-serif`,n.fillStyle=y,n.textAlign=`center`,n.fillText(`${Math.round(e*d)}%`,s,182),n.globalAlpha=1),l>.7&&(n.globalAlpha=Math.min(1,(l-.7)/.3),n.font=`400 14px 'Satoshi Variable', 'DM Sans', sans-serif`,n.fillStyle=o.color,n.textAlign=`center`,n.fillText(`NCEs confirmed`,s,252),n.font=`400 14px 'Satoshi Variable', 'DM Sans', sans-serif`,n.fillStyle=o.color,n.fillText(`${r} of ${a} NCEs are confirmed compensation events`,s,272),n.globalAlpha=1);for(let e=0;e<=10;e++){let t=p+e/10*h;if(n.strokeStyle=c(i.bd,.5),n.lineWidth=e%5==0?1.5:.8,n.beginPath(),n.moveTo(s+Math.cos(t)*122,220+Math.sin(t)*122),n.lineTo(s+Math.cos(t)*128,220+Math.sin(t)*128),n.stroke(),e%5==0){let r=s+Math.cos(t)*138,a=220+Math.sin(t)*138;n.font=`400 14px 'Satoshi Variable', 'DM Sans', sans-serif`,n.fillStyle=c(i.t3,.45),n.textAlign=`center`,n.fillText(`${e*10}%`,r,a+3)}}g=requestAnimationFrame(_)};return _(),()=>cancelAnimationFrame(g)},[e,r,a]),(0,n.jsx)(`div`,{"data-testid":s,style:{position:`relative`,width:ne,height:re},children:(0,n.jsx)(`canvas`,{ref:l,role:`img`,"aria-label":`Compensation event gauge — ${e}% of NCEs confirmed as compensation events`,style:{width:ne,height:re,display:`block`}})})}function ae(e,n,r,i,a=!0,o={}){let s=(0,t.useRef)(0),{easing:c=b,durationFrames:l=48}=o;(0,t.useEffect)(()=>{let t=e.current;if(!t||!n||!r)return;let o=t.getContext(`2d`);if(!o)return;t.width=n*2,t.height=r*2,o.scale(2,2);let u;s.current=0;let d=()=>{s.current++;let e=s.current;o.clearRect(0,0,n,r);let t=a?Math.min(e/l,1):1;if(i(o,c(t),e),t<1)u=requestAnimationFrame(d);else{let e=()=>{s.current++,o.clearRect(0,0,n,r),i(o,1,s.current),u=requestAnimationFrame(e)};u=requestAnimationFrame(e)}};return d(),()=>cancelAnimationFrame(u)},[n,r,a])}var I=780,oe=234,se=130,ce=52,le=[i.blue,i.cyan,i.amber,i.purple,i.green],ue=[`Base Value`,`Variations`,`Commitment`],de=[`Base`,`Var`,`Commit`];function fe({contractors:e=[],"data-testid":r}){let a=(0,t.useRef)(null),o=(0,t.useRef)(new Map),{hoveredRef:s,tooltip:l,hitZonesRef:u}=_(a,{width:I,height:oe}),d=(0,t.useMemo)(()=>{let t=Math.max(...e.map(e=>e.base??0)),n=Math.max(...e.map(e=>e.variation??0));return e.map((e,r)=>{let i=I*(.12+r*.19),a=se,o=Math.min(I*.075,ce),s=le[r%le.length],c=[(e.base??0)/(t||1)*100,(e.variation??0)/(n||1)*100,e.percentage??0],l=[`£${e.base??0}M`,`£${e.variation??0}M`,`${e.percentage??0}%`],u=c.map((e,t)=>{let n=-Math.PI/2+t/ue.length*Math.PI*2,r=e/100,s=o*Math.max(.08,r);return{name:ue[t],short:de[t],label:l[t],val:Math.round(e),x:i+Math.cos(n)*s,y:a+Math.sin(n)*s,angle:n,norm:r}}),d=u.reduce((e,t)=>e+t.x,0)/u.length,f=u.reduce((e,t)=>e+t.y,0)/u.length,p=Math.sqrt(u.reduce((e,t)=>e+(t.x-d)**2+(t.y-f)**2,0)/u.length);return{...e,cx:i,cy:a,baseR:o,stars:u,scatter:p,color:s}})},[e]);return ae(a,I,oe,(e,t,n)=>{E(o.current,s.current),u.current=[],p(e,I,oe,n,30),d.forEach((t,r)=>{let a=t.color,s=`constellation-${r}`,l=o.current.get(s)??0;e.beginPath(),e.arc(t.cx,t.cy,t.baseR+5,0,Math.PI*2),e.strokeStyle=c(i.bd,.08+.08*l),e.lineWidth=.5,e.stroke(),e.beginPath(),t.stars.forEach((t,n)=>{n===0?e.moveTo(t.x,t.y):e.lineTo(t.x,t.y)}),e.closePath(),e.fillStyle=c(a,.04+.03*l),e.fill(),e.strokeStyle=c(a,.15+.1*l),e.lineWidth=.8,e.stroke(),t.stars.forEach((i,s)=>{let l=w(n,.05,5e-4)*.3+.7,d=3.5*l,f=`star-${r}-${s}`,p=o.current.get(f)??0,m=e.createRadialGradient(i.x,i.y,0,i.x,i.y,d*4);m.addColorStop(0,c(a,(.2+.1*p)*l)),m.addColorStop(1,c(a,0)),e.fillStyle=m,e.beginPath(),e.arc(i.x,i.y,d*4,0,Math.PI*2),e.fill(),e.beginPath(),e.arc(i.x,i.y,d+p*2,0,Math.PI*2),e.fillStyle=c(a,(.8+.2*p)*l),e.fill();let h=Math.sin(i.angle)<-.3;e.textAlign=`center`,e.textBaseline=`middle`,h?(e.font=`8px 'DM Sans', sans-serif`,e.fillStyle=c(a,.5+.15*p),e.fillText(i.short,i.x,i.y-24),e.font=`bold 11px 'JetBrains Mono', monospace`,e.fillStyle=c(a,.8+.15*p),e.fillText(i.label,i.x,i.y-11)):(e.font=`8px 'DM Sans', sans-serif`,e.fillStyle=c(a,.5+.15*p),e.fillText(i.short,i.x,i.y+11),e.font=`bold 11px 'JetBrains Mono', monospace`,e.fillStyle=c(a,.8+.15*p),e.fillText(i.label,i.x,i.y+24)),v(u.current,f,i.x,i.y,d*4+2,{label:i.name,value:i.label,sublabel:t.abbreviation??t.name.slice(0,6),color:a})}),l>0&&f(e,t.cx,t.cy,16*l,a,.15*l),e.beginPath(),e.arc(t.cx,t.cy,t.baseR+12,0,Math.PI*2),e.strokeStyle=c(a,.1+w(n,.03,5e-4)*.05),e.lineWidth=1,e.stroke(),e.font=`bold 11px 'DM Sans', sans-serif`,e.textAlign=`center`,e.textBaseline=`alphabetic`,e.fillStyle=c(i.t2,.65+l*.25),e.fillText(t.abbreviation??t.name.slice(0,6),t.cx,t.cy+t.baseR+26),v(u.current,s,t.cx,t.cy,t.baseR+5,{label:t.name,value:`£${t.total??0}M total`,sublabel:`${t.percentage??0}% committed · scatter ${t.scatter.toFixed(1)}`,color:a})}),e.font=`11px 'DM Sans', sans-serif`,e.textAlign=`center`,e.textBaseline=`middle`,e.fillStyle=c(i.t4,.55),e.fillText(`▲ top = Base value · ▼▸ lower-right = Variations · ◂▼ lower-left = Commitment % · hover stars for details`,I/2,oe-14),m(e,I,oe,n,.012)},!0),(0,n.jsxs)(`div`,{"data-testid":r,style:{position:`relative`,width:I,height:oe},children:[(0,n.jsx)(`canvas`,{ref:a,role:`img`,"aria-label":`Contract value breakdown per contractor — multi-KPI constellation chart`,style:{width:I,height:oe,display:`block`}}),(0,n.jsx)(g,{...l,parentW:I,parentH:oe})]})}var pe=680,me=220,he=[i.blue,i.cyan,i.amber,i.purple,i.green],L={left:8,right:64,top:16,bottom:38},R=88,z=18;function ge({data:e,"data-testid":r}){let a=(0,t.useRef)(null),l=(0,t.useRef)(new Map),{hoveredRef:u,tooltip:d,hitZonesRef:p}=_(a,{width:pe,height:me}),{contractors:m=[],totals:h}=e,v=m.length,b=Math.max(...m.map(e=>e.total??0),1),S=pe-L.left-R-L.right,C=v>1?(me-L.top-L.bottom-v*z)/(v-1):0;return ae(a,pe,me,(e,t)=>{E(l.current,u.current),p.current=[],m.forEach((n,r)=>{let a=he[r%he.length],s=T(t,r,v,x),u=L.top+r*(z+C),d=L.left+R,m=l.current.get(n.id)??0,h=(n.base??0)/b*S*s,g=(n.total??0)/b*S*s,_=g-h;e.font=`500 14px 'Satoshi Variable', 'DM Sans', sans-serif`,e.fillStyle=m>0?a:o.color,e.textAlign=`right`,e.textBaseline=`middle`,e.fillText(n.abbreviation??n.name.slice(0,6),d-8,u+z/2),e.fillStyle=c(i.bd,.25),e.beginPath(),e.roundRect(d,u,S,z,4),e.fill(),h>0&&(m>0&&f(e,d+h/2,u+z/2,h*.3,a,.1*m),e.fillStyle=c(a,.5+m*.15),e.beginPath(),e.roundRect(d,u,h,z,4),e.fill()),_>2&&(e.fillStyle=c(a,.22+m*.08),e.beginPath(),e.roundRect(d+h,u,_,z,[0,4,4,0]),e.fill(),e.setLineDash([2,3]),e.strokeStyle=c(a,.55),e.lineWidth=1,e.beginPath(),e.moveTo(d+h,u+3),e.lineTo(d+h,u+z-3),e.stroke(),e.setLineDash([])),m>0&&g>0&&(e.strokeStyle=c(a,.5*m),e.lineWidth=1,e.setLineDash([]),e.beginPath(),e.roundRect(d,u,g,z,4),e.stroke()),s>.35&&(e.globalAlpha=Math.min(1,(s-.35)/.4),e.font=`500 14px 'Satoshi Variable', 'DM Sans', sans-serif`,e.fillStyle=m>0?a:i.t2,e.textAlign=`left`,e.textBaseline=`middle`,e.fillText(`£${n.total??0}M`,d+g+6,u+z/2),e.globalAlpha=1),y(p.current,n.id,d,u,Math.max(g,1),z,{label:n.name,value:`£${n.total??0}M total`,sublabel:`Base £${n.base??0}M + Var £${n.variation??0}M · ${n.percentage??0}% committed`,color:a})});let n=me-14;e.textBaseline=`middle`,e.font=`400 12px 'Satoshi Variable', 'DM Sans', sans-serif`,e.textAlign=`left`,e.fillStyle=c(i.cyan,.5),e.beginPath(),e.roundRect(L.left+R,n-3,14,6,2),e.fill(),e.fillStyle=s.color,e.fillText(`base value`,L.left+R+18,n),e.fillStyle=c(i.cyan,.22),e.beginPath(),e.roundRect(L.left+R+94,n-3,14,6,2),e.fill(),e.setLineDash([2,3]),e.strokeStyle=c(i.cyan,.5),e.lineWidth=.5,e.beginPath(),e.moveTo(L.left+R+101,n-3),e.lineTo(L.left+R+101,n+3),e.stroke(),e.setLineDash([]),e.fillStyle=s.color,e.fillText(`approved variations`,L.left+R+112,n),e.font=`400 12px 'Satoshi Variable', 'DM Sans', sans-serif`,e.textAlign=`right`,e.fillStyle=s.color,e.fillText(`Portfolio: £${h?.total??0}M`,pe-8,n)},!0,{easing:x}),(0,n.jsxs)(`div`,{"data-testid":r,style:{position:`relative`,width:pe,height:me},children:[(0,n.jsx)(`canvas`,{ref:a,role:`img`,"aria-label":`Total contract value per contractor — horizontal bar chart`,style:{width:pe,height:me,display:`block`,borderRadius:8}}),(0,n.jsx)(g,{...d,parentW:pe,parentH:me})]})}var _e=780,B=240,ve=12,ye=10,be=[`Highest exposure`,`Elevated risk`,`Moderate exposure`,`Moderate exposure`,`Low exposure`];function xe({contractors:e=[],"data-testid":r}){let s=(0,t.useRef)(null),l=(0,t.useRef)(0),u=(0,t.useRef)(new Map),{hoveredRef:p,tooltip:h,hitZonesRef:v}=_(s,{width:_e,height:B}),b=[...e].sort((e,t)=>(t.count??0)-(e.count??0)).slice(0,5),x=b.reduce((e,t)=>e+(t.count??0),0);return(0,t.useEffect)(()=>{let e=s.current;if(!e)return;let t=d(e,_e,B);l.current=0;let n=Math.min(5,b.length),r=(_e-2*ve-(n-1)*ye)/n,h=B*.84,g=B*.08,_,S=()=>{l.current++;let e=l.current;t.clearRect(0,0,_e,B),v.current=[],u.current.forEach((e,t)=>{let n=t===p.current?1:0,r=e+(n-e)*.12;Math.abs(r-n)<.005?n===0?u.current.delete(t):u.current.set(t,1):u.current.set(t,r)}),p.current&&!u.current.has(p.current)&&u.current.set(p.current,0),b.forEach((n,s)=>{let l=s===0,d=s===0?i.red:s===1?i.amber:a[s%a.length],p=ve+s*(r+ye),m=u.current.get(n.id)??0,_=m*8,b=p-_/2,S=r+_,C=l?w(e,.04,3e-4)*.06+.06:0;t.fillStyle=c(d,.08+m*.07),t.beginPath(),t.roundRect(b,g,S,h,6),t.fill(),t.strokeStyle=c(d,.2+m*.4+C),t.lineWidth=l?1.5:1,t.stroke(),(m>.01||l)&&f(t,b+S/2,g+h/2,S*.55,d,C+m*.14),t.font=`bold `+o.font,t.textAlign=`left`,t.textBaseline=`top`,t.fillStyle=c(d,.5+m*.35),t.fillText(`#${s+1}`,b+7,g+6);let T=Math.min(r*.28,h*.32,72),E=b+S/2,D=g+h*.38,O=t.createRadialGradient(E,D-T*.2,0,E,D,T);O.addColorStop(0,c(d,.5+m*.2)),O.addColorStop(1,c(d,.2+m*.1)),t.beginPath(),t.arc(E,D,T,0,Math.PI*2),t.fillStyle=O,t.fill(),t.strokeStyle=c(d,.4+m*.3),t.lineWidth=1,t.stroke(),t.font=`bold `+o.font,t.textAlign=`center`,t.textBaseline=`middle`,t.fillStyle=c(i.t1,.9),t.fillText(n.abbreviation??n.name.slice(0,6),E,D),t.font=`bold 14px 'Satoshi Variable', 'DM Sans', sans-serif`,t.textBaseline=`alphabetic`,t.fillStyle=c(d,.9+m*.1),t.fillText(String(n.count??0),E,g+h*.76),t.font=o.font,t.fillStyle=o.color,t.fillText(`open EWs`,E,g+h*.88);let k=Math.round((n.count??0)/(x||1)*100),A=be[s]??`Low exposure`;y(v.current,n.id,p,g,r,h,{label:n.name,value:`${n.count??0} open · ${k}% of total`,sublabel:`Rank #${s+1} · ${A}`,color:d})}),m(t,_e,B,e,.015),_=requestAnimationFrame(S)};return S(),()=>cancelAnimationFrame(_)},[b,x]),(0,n.jsxs)(`div`,{"data-testid":r,style:{position:`relative`,width:_e,height:B},children:[(0,n.jsx)(`canvas`,{ref:s,role:`img`,"aria-label":`Contractor rank — open EW count per contractor`,style:{width:_e,height:B,display:`block`,borderRadius:8}}),(0,n.jsx)(g,{...h,parentW:_e,parentH:B})]})}var V=680,H=260;function Se({categories:e=[],"data-testid":r}){let a=(0,t.useRef)(null),o=(0,t.useRef)(0),s=(0,t.useRef)(new Map),{hoveredRef:l,tooltip:u,hitZonesRef:h}=_(a,{width:V,height:H});return(0,t.useEffect)(()=>{let t=a.current;if(!t)return;let n=d(t,V,H);o.current=0;let r=e.length,u=Math.max(...e.map(e=>e.count),1),g=u,_=V*.05,y=H*.1,b=V*.9/r,x=H*.7/g,S=e.reduce((e,t)=>e+t.count,0),C,T=()=>{o.current++;let t=o.current;n.clearRect(0,0,V,H),h.current=[],s.current.forEach((e,t)=>{let n=t===l.current?1:0,r=e+(n-e)*.12;Math.abs(r-n)<.005?n===0?s.current.delete(t):s.current.set(t,1):s.current.set(t,r)}),l.current&&!s.current.has(l.current)&&s.current.set(l.current,0),p(n,V,H,t,40,c(i.blue,.04)),e.forEach((e,r)=>{let a=e.count===u,o=a?i.cyan:i.blue,l=s.current.get(`${e.category}-col`)??0;for(let i=0;i<g;i++){let d=_+r*b+b/2,p=y+i*x+x/2,m=Math.min(b,x)*.38;if(i>=u-e.count){let u=m*(1+(w(t,.04,5e-4)+Math.sin(r*.6+i*1.2)*.3)*.12);(a||l>.01)&&f(n,d,p,u*3,o,(a?.2:.1)+l*.1),n.beginPath(),n.arc(d,p,u,0,Math.PI*2),n.fillStyle=c(o,a?.8:.5+l*.2),n.fill();let g=`${e.category}-${i}`;v(h.current,g,d,p,m+4,{label:e.fullName,value:`${e.count} Early Warnings`,sublabel:`${Math.round(e.count/S*100)}% of total`,color:o}),s.current.get(`${e.category}-col`)}else n.beginPath(),n.arc(d,p,1,0,Math.PI*2),n.fillStyle=c(o,.08),n.fill()}let d=y+g*x+16;n.font=`${a?`bold `:``}9px 'JetBrains Mono', monospace`,n.textAlign=`center`,n.textBaseline=`alphabetic`,n.fillStyle=a?i.cyan:c(i.t2,.65),n.fillText(e.category,_+r*b+b/2,d)}),m(n,V,H,t,.015),C=requestAnimationFrame(T)};return T(),()=>cancelAnimationFrame(C)},[e]),(0,n.jsxs)(`div`,{"data-testid":r,style:{position:`relative`,width:V,height:H},children:[(0,n.jsx)(`canvas`,{ref:a,role:`img`,"aria-label":`Early Warning count by category — breathing dot grid`,style:{width:V,height:H,display:`block`,borderRadius:8}}),(0,n.jsx)(g,{...u,parentW:V,parentH:H})]})}function Ce({rows:e=[],className:t,colors:r}){return(0,n.jsx)(k,{rows:e,variant:`line`,className:t,colors:r})}var we=[`#36BFFA`,`#16B364`,`#D444F1`,`#FAC515`,`#2970FF`,`#7A5AF8`,`#EF6820`,`#D92D20`],Te={nodes:[{id:`supplier-x`,name:`Supplier X`,valueLabel:`Si +0.12%`},{id:`bf3-superheat`,name:`BF-3 Superheat`,valueLabel:`22°C (target 34)`},{id:`ccm3-solidification`,name:`CCM-3 Solidification`,valueLabel:`Rate deviation`},{id:`grade-risk`,name:`Grade Risk`,valueLabel:`Automotive 74%`}],links:[{source:`supplier-x`,target:`bf3-superheat`,value:92},{source:`bf3-superheat`,target:`ccm3-solidification`,value:87},{source:`ccm3-solidification`,target:`grade-risk`,value:74}]};function Ee({rows:e=[],className:t,colors:r}){let i=r?.slices??we;return(0,n.jsx)(`div`,{className:[`d3-mini-bars`,t].filter(Boolean).join(` `),children:e.map(([e,t,r],a)=>(0,n.jsxs)(`div`,{className:`d3-mini-row`,children:[(0,n.jsx)(`span`,{children:e}),(0,n.jsx)(`div`,{className:`d3-mini-track`,children:(0,n.jsxs)(`svg`,{viewBox:`0 0 100 12`,className:`d3-mini-svg`,"aria-hidden":`true`,children:[(0,n.jsx)(`rect`,{x:`0`,y:`0`,width:`100`,height:`12`,rx:`6`,className:`d3-mini-track-fill`}),(0,n.jsx)(`rect`,{x:`0`,y:`0`,width:Math.max(0,Math.min(100,t)),height:`12`,rx:`6`,className:`d3-mini-fill tone-${a%we.length}`,fill:i[a%i.length]})]})}),(0,n.jsx)(`span`,{children:r})]},`${e}-${a}`))})}var De=680,Oe=320;function ke({total:e=0,byContractor:r=[],"data-testid":s}){let l=(0,t.useRef)(null),u=(0,t.useRef)(new Map),p=(0,t.useRef)(0),{hoveredRef:m,tooltip:h,hitZonesRef:y}=_(l,{width:De,height:Oe});return(0,t.useEffect)(()=>{let t=l.current;if(!t)return;let n=d(t,De,Oe);p.current=0;let s=Oe/2,h=De-80,g=Math.max(...r.map(e=>e.count??0)),_=(Oe-60)/(r.length-1),x=r.map((e,t)=>({x:h,y:30+t*_})),S,C=()=>{p.current++;let t=p.current;n.clearRect(0,0,De,Oe);let l=b(Math.min(t/72,1));E(u.current,m.current),y.current=[],f(n,88,s,48*l,i.blue,.15*l),r.forEach((t,d)=>{let p=a[d%a.length],m=T(l,d,r.length,b),_=x[d],S=u.current.get(t.id)??0,C=Math.max(1.5,(t.count??0)/g*6);if(m<.01)return;let w=88+(h-88)*.4,E=s,D=88+(h-88)*.6,O=_.y,k=m;n.beginPath();for(let e=0;e<=40;e++){let t=e/40*k,r=(1-t)**3*88+3*(1-t)**2*t*w+3*(1-t)*t**2*D+t**3*_.x,i=(1-t)**3*s+3*(1-t)**2*t*E+3*(1-t)*t**2*O+t**3*_.y;e===0?n.moveTo(r,i):n.lineTo(r,i)}if(n.strokeStyle=c(p,S>0?.8:.45),n.lineWidth=C*(S>0?1.3:1),n.stroke(),m>.85){let r=Math.min(1,(m-.85)/.15),a=4+(t.count??0)/g*12;f(n,_.x,_.y,a*2.5,p,(.25+S*.2)*r),n.beginPath(),n.arc(_.x,_.y,a*r,0,Math.PI*2),n.fillStyle=c(p,(.7+S*.2)*r),n.fill(),v(y.current,t.id,_.x,_.y,a+8,{label:t.name,value:`${t.count??0} NCEs raised`,sublabel:`${Math.round((t.count??0)/e*100)}% of all NCEs`,color:p}),n.globalAlpha=r,n.font=o.font,n.fillStyle=S>0?p:c(i.t2,.85),n.textAlign=`left`,n.fillText(t.abbreviation??t.name.slice(0,6),_.x+a+6,_.y-3),n.font=o.font,n.fillStyle=S>0?p:i.t1,n.fillText(String(t.count??0),_.x+a+6,_.y+10),n.globalAlpha=1}}),n.beginPath(),n.arc(88,s,32*l,0,Math.PI*2),n.fillStyle=i.bgL,n.fill(),n.strokeStyle=c(i.blue,.6*l),n.lineWidth=2,n.stroke(),l>.4&&(n.globalAlpha=Math.min(1,(l-.4)/.4),n.font=`500 24px 'Satoshi Variable', 'DM Sans', sans-serif`,n.fillStyle=i.t1,n.textAlign=`center`,n.fillText(String(e),88,s+5),n.font=o.font,n.fillStyle=o.color,n.fillText(`NCEs`,88,s+18),n.globalAlpha=1),S=requestAnimationFrame(C)};return C(),()=>cancelAnimationFrame(S)},[e,r]),(0,n.jsxs)(`div`,{"data-testid":s,style:{position:`relative`,width:De,height:Oe},children:[(0,n.jsx)(`canvas`,{ref:l,role:`img`,"aria-label":`NCE fault tree — NCEs per contractor as branching tree`,style:{width:De,height:Oe,display:`block`}}),(0,n.jsx)(g,{...h,parentW:De,parentH:Oe})]})}var Ae=192,je=Ae,Me=Ae+80;function Ne({rows:e=[],variant:o,className:s,colors:l}){let p=(0,t.useRef)(null),m=(0,t.useRef)(new Map),h=(0,t.useRef)(0),y=l?.slices??a,{hoveredRef:b,tooltip:x,hitZonesRef:S}=_(p,{width:je,height:Me});return(0,t.useEffect)(()=>{let t=p.current;if(!t)return;let n=d(t,je,Me);h.current=0;let r=je/2,a=Ae/2,s=Ae*.4,l=o===`donut`?Ae*.21:0,g=e.reduce((e,t)=>e+(t.pricing??0),0)||1,_,x=()=>{h.current++;let t=h.current;n.clearRect(0,0,je,Me);let d=1-(1-Math.min(t/48,1))**3;E(m.current,b.current),S.current=[];let p=-Math.PI/2;e.forEach((e,o)=>{let u=(e.pricing??0)/g,h=u*Math.PI*2*d,_=p+h,b=y[o%y.length],x=m.current.get(e.id??`sl-${o}`)??0,C=p+h/2,T=(s+l)/2,E=r+Math.cos(C)*T,D=a+Math.sin(C)*T,O=(s-l)/2+8;v(S.current,e.id??`sl-${o}`,E,D,O,{label:e.vendor,value:`${e.pricing??0} (${Math.round(u*100)}%)`,color:b}),x>0&&f(n,E,D,O*2*x,b,.2*x);let k=w(t,.03,3e-4),A=s+x*6+(x>0?k*2:0);n.beginPath(),n.moveTo(r+Math.cos(p)*l,a+Math.sin(p)*l),n.arc(r,a,A,p,_),l>0?n.arc(r,a,l,_,p,!0):n.lineTo(r,a),n.closePath(),n.fillStyle=c(b,.7+x*.2),n.fill(),n.strokeStyle=c(i.bg,.8),n.lineWidth=1.5,n.stroke(),p=_}),o===`donut`&&e.length>0&&f(n,r,a,l*.8,i.blue,.06);let C=Ae+12;e.forEach((e,t)=>{let r=y[t%y.length],a=(e.pricing??0)/g,o=m.current.get(e.id??`sl-${t}`)??0,s=C+t*18;n.beginPath(),n.arc(8,s,4,0,Math.PI*2),n.fillStyle=c(r,.8+o*.2),n.fill(),n.font=`9px 'JetBrains Mono', monospace`,n.fillStyle=c(i.t2,.7+o*.2),n.textAlign=`left`,n.fillText(e.vendor,18,s+3.5),n.font=`bold 9px 'JetBrains Mono', monospace`,n.fillStyle=u(i.t3,r,o),n.textAlign=`right`,n.fillText(`${e.pricing??0} (${Math.round(a*100)}%)`,je-4,s+3.5)}),_=requestAnimationFrame(x)};return x(),()=>cancelAnimationFrame(_)},[e,o,l,y]),(0,n.jsx)(r,{className:[`canvas-pie-frame`,s].filter(Boolean).join(` `),children:(0,n.jsxs)(`div`,{style:{position:`relative`,width:je,height:Me},children:[(0,n.jsx)(`canvas`,{ref:p,role:`img`,"aria-label":`${o} chart`,style:{width:je,height:Me,display:`block`,borderRadius:8}}),(0,n.jsx)(g,{...x,parentW:je,parentH:Me})]})})}function Pe(e,t,n,r){let i=new Set(t.map(e=>e.source)),a=new Set(t.map(e=>e.target)),o=new Map,s=[];for(e.forEach(e=>{i.has(e.id)&&!a.has(e.id)&&s.push({id:e.id,depth:0})});s.length>0;){let e=s.shift();if(!e)break;let{id:n,depth:r}=e;o.has(n)||(o.set(n,r),t.filter(e=>e.source===n).forEach(e=>{o.has(e.target)||s.push({id:e.target,depth:r+1})}))}let c=o.size>0?Math.max(...Array.from(o.values())):0;e.forEach(e=>{o.has(e.id)||o.set(e.id,c+1)});let l=new Map;e.forEach(e=>{let t=o.get(e.id)??0;l.has(t)||l.set(t,[]),l.get(t).push(e.id)});let u=Math.max(...Array.from(l.keys()))+1,d={left:100,right:80,top:40,bottom:40},f=new Map;return l.forEach((e,t)=>{let i=d.left+t/Math.max(u-1,1)*(n-d.left-d.right),a=r-d.top-d.bottom,o=Math.max(24,(a-(e.length-1)*12)/e.length),s=e.length*o+(e.length-1)*12,c=d.top+(a-s)/2;e.forEach((e,t)=>{f.set(e,{x:i-20/2,y:c+t*(o+12),w:20,h:o})})}),f}function Fe({nodes:e,links:o,width:s=960,height:l=280,ariaLabel:u,selectedEntity:p,className:h,colors:b}){let x=(0,t.useRef)(null),S=(0,t.useRef)(new Map),C=(0,t.useRef)(0),T=(0,t.useRef)([]),D=b?.nodes??a,O=b?.links??i.bd,k=b?.activeLinks??i.blue,A=b?.activeNodes??i.blue,j=(0,t.useMemo)(()=>Pe(e,o,s,l),[e,o,s,l]),{hoveredRef:M,tooltip:N,hitZonesRef:P}=_(x,{width:s,height:l});return(0,t.useEffect)(()=>{let t=x.current;if(!t)return;let n=d(t,s,l);C.current=0,T.current=[];let r=o.length>0?Math.max(...o.map(e=>e.value)):1,a,u=()=>{C.current++;let t=C.current;n.clearRect(0,0,s,l);let d=1-(1-Math.min(t/56,1))**3;E(S.current,M.current),P.current=[],o.forEach((e,a)=>{let o=j.get(e.source),s=j.get(e.target);if(!o||!s)return;let l=!!p&&(e.source===p||e.target===p),u=l?k:O,f=l?.5:.2,m=Math.max(3,e.value/r*36*d),h=m/2,g=o.x+o.w,_=o.y+o.h/2,y=s.x,b=s.y+s.h/2,x=(g+y)/2;for(let e=0;e<30;e++){let r=e/30,i=(e+1)/30,o=1-r,s=1-i,l=o*o*g+2*o*r*x+r*r*y,d=o*o*_+2*o*r*_+r*r*b,p=s*s*g+2*s*i*x+i*i*y,m=s*s*_+2*s*i*_+i*i*b,v=w(t+r*120+a*40,.025,3e-4)*1.2;n.beginPath(),n.moveTo(l,d-h+v),n.lineTo(p,m-h+v),n.lineTo(p,m+h+v),n.lineTo(l,d+h+v),n.closePath(),n.fillStyle=c(u,f*(.5+r*.5)),n.fill()}v(P.current,`link-${a}`,x,(_+b)/2,m+6,{label:`${e.source} → ${e.target}`,value:String(e.value),color:l?k:i.blue}),Math.random()<.08&&T.current.push({linkIdx:a,prog:0,speed:.006+Math.random()*.006,off:(Math.random()-.5)*m*.5,sz:1+Math.random()})}),e.forEach((e,r)=>{let a=j.get(e.id);if(!a)return;let o=p===e.id,s=M.current===`node-${r}`,l=S.current.get(`node-${r}`)??0,u=o?A:D[r%D.length];y(P.current,`node-${r}`,a.x,a.y,a.w,a.h,{label:e.name,value:e.valueLabel??e.id,color:u}),(l>0||o)&&f(n,a.x+a.w/2,a.y+a.h/2,a.w*2,u,.2*Math.max(l,o?.6:0));let d=o?w(t,.03,3e-4)*.15:0;n.fillStyle=c(u,.6+l*.25+d),n.beginPath(),n.roundRect(a.x,a.y,a.w,a.h,4),n.fill(),(o||l>0)&&(n.strokeStyle=c(u,.5*Math.max(l,o?1:0)),n.lineWidth=1,n.beginPath(),n.roundRect(a.x,a.y,a.w,a.h,4),n.stroke());let m=a.x+a.w+8;n.font=`${o||s?`bold `:``}10px 'JetBrains Mono', monospace`,n.fillStyle=c(o?u:i.t2,.7+l*.2),n.textAlign=`left`,n.fillText(e.name,m,a.y+a.h/2+4),e.valueLabel&&(n.font=`9px 'JetBrains Mono', monospace`,n.fillStyle=c(u,.5+l*.2),n.fillText(e.valueLabel,m,a.y+a.h/2+17))}),T.current=T.current.filter(e=>{if(e.prog+=e.speed,e.prog>1)return!1;let t=o[e.linkIdx];if(!t)return!1;let r=j.get(t.source),a=j.get(t.target);if(!r||!a)return!1;let s=r.x+r.w,l=r.y+r.h/2,u=a.x,d=a.y+a.h/2,f=(s+u)/2,p=1-e.prog,m=p*p*s+2*p*e.prog*f+e.prog*e.prog*u,h=p*p*l+2*p*e.prog*l+e.prog*e.prog*d+e.off,g=Math.sin(e.prog*Math.PI)*.5,_=b?.links??i.cyan;return n.beginPath(),n.arc(m,h,e.sz,0,Math.PI*2),n.fillStyle=c(_,g),n.fill(),!0}),T.current.length>150&&(T.current=T.current.slice(-150)),m(n,s,l,t,.01),a=requestAnimationFrame(u)};return u(),()=>{cancelAnimationFrame(a),T.current=[]}},[e,o,s,l,p,b,j]),(0,n.jsx)(r,{className:[`canvas-sankey-frame`,h].filter(Boolean).join(` `),children:(0,n.jsxs)(`div`,{role:`img`,"aria-label":u,style:{position:`relative`,width:s,height:l},children:[(0,n.jsx)(`canvas`,{ref:x,style:{width:s,height:l,display:`block`,borderRadius:8}}),(0,n.jsx)(g,{...N,parentW:s,parentH:l})]})})}var Ie=[{x:.13,y:.48},{x:.37,y:.28},{x:.63,y:.62},{x:.87,y:.38},{x:.25,y:.72},{x:.5,y:.18},{x:.75,y:.7},{x:.92,y:.22}],Le=[i.blue,i.cyan,i.orange,i.red,i.purple,i.green,i.amber,i.t2],Re=[26,24,24,26,22,22,22,22];function ze(e,t){let n=1-t;return{x:n*n*n*e.p0.x+3*n*n*t*e.p1.x+3*n*t*t*e.p2.x+t*t*t*e.p3.x,y:n*n*n*e.p0.y+3*n*n*t*e.p1.y+3*n*t*t*e.p2.y+t*t*t*e.p3.y}}function Be(e,t){let n=1-t,r=3*n*n*(e.p1.x-e.p0.x)+6*n*t*(e.p2.x-e.p1.x)+3*t*t*(e.p3.x-e.p2.x),i=3*n*n*(e.p1.y-e.p0.y)+6*n*t*(e.p2.y-e.p1.y)+3*t*t*(e.p3.y-e.p2.y),a=Math.sqrt(r*r+i*i)||1;return{x:-i/a,y:r/a}}function Ve(e,t){let n=t.x-e.x,r=t.y-e.y;return{p0:{x:e.x,y:e.y},p1:{x:e.x+n*.3+r*.15,y:e.y+r*.3-n*.15},p2:{x:t.x-n*.3+r*.08,y:t.y-r*.3-n*.08},p3:{x:t.x,y:t.y}}}function He({nodes:e,links:r,width:a=960,height:o=280,selectedEntity:s}){let l=(0,t.useRef)(null),h=(0,t.useRef)(0),y=(0,t.useRef)([]),{hoveredRef:x,tooltip:S,hitZonesRef:C}=_(l,{width:a,height:o}),T=(0,t.useMemo)(()=>{let t=new Map;return e.forEach((e,n)=>t.set(e.id,n)),t},[e]),E=(0,t.useMemo)(()=>r.length>0?Math.max(...r.map(e=>e.value)):100,[r]),D=e=>E>1?e/100:e,O=(0,t.useMemo)(()=>e.map((e,t)=>{let n=Ie[t%Ie.length];return{id:e.id,label:e.name,sub:e.valueLabel??``,x:n.x*a,y:n.y*o,r:Re[t%Re.length],color:Le[t%Le.length]}}),[e,a,o]),k=(0,t.useMemo)(()=>r.map(e=>({fromIdx:T.get(e.source)??-1,toIdx:T.get(e.target)??-1,conf:D(e.value)})).filter(e=>e.fromIdx>=0&&e.toIdx>=0),[r,T]);return(0,t.useEffect)(()=>{let e=l.current;if(!e)return;let t=d(e,a,o);h.current=0,y.current=[];let n,r=()=>{h.current++;let e=h.current;if(t.clearRect(0,0,a,o),C.current=[],p(t,a,o,e,50,c(i.blue,.05)),k.forEach((e,n)=>{let r=O[e.fromIdx],a=O[e.toIdx];if(!r||!a)return;let o=!!s&&(r.id===s||a.id===s),l=u(r.color,a.color,.5),d=o?.18:.05,f=o?.25:.1,p=Ve(r,a);t.beginPath(),t.moveTo(p.p0.x,p.p0.y),t.bezierCurveTo(p.p1.x,p.p1.y,p.p2.x,p.p2.y,p.p3.x,p.p3.y),t.strokeStyle=c(l,d),t.lineWidth=16,t.lineCap=`round`,t.stroke(),t.strokeStyle=c(l,f),t.lineWidth=1.5,t.stroke();for(let t=0;t<e.conf*2.5;t++)Math.random()<.45&&y.current.push({edgeIdx:n,t:0,speed:.003+Math.random()*.004,off:(Math.random()-.5)*13,sz:.7+Math.random()*2});let m=ze(p,.5),h=`${Math.round(e.conf*100)}%`;t.font=`bold 12px 'JetBrains Mono', monospace`,t.textBaseline=`middle`;let g=t.measureText(h).width+14;t.fillStyle=`rgba(10,16,24,0.88)`,t.beginPath(),t.roundRect(m.x-g/2,m.y-11,g,22,6),t.fill(),t.strokeStyle=c(i.cyan,.25),t.lineWidth=1,t.stroke(),t.fillStyle=c(i.cyan,.9),t.textAlign=`center`,t.fillText(h,m.x,m.y)}),y.current=y.current.filter(e=>{if(e.t+=e.speed,e.t>1)return!1;let n=k[e.edgeIdx];if(!n)return!1;let r=O[n.fromIdx],i=O[n.toIdx];if(!r||!i)return!1;let a=Ve(r,i),o=ze(a,e.t),s=Be(a,e.t),l=o.x+s.x*e.off,d=o.y+s.y*e.off,p=Math.sin(e.t*Math.PI)*.7,m=u(r.color,i.color,e.t);return f(t,l,d,e.sz*3,m,p*.1),t.beginPath(),t.arc(l,d,e.sz,0,Math.PI*2),t.fillStyle=c(m,p),t.fill(),!0}),y.current.length>350&&(y.current=y.current.slice(-350)),O.forEach((n,r)=>{let a=s===n.id,o=x.current===`node-${r}`,l=w(e,.03,3e-4)*.1+1,u=n.r*l*(a?1.15:1);t.beginPath(),t.arc(n.x,n.y,u+6,0,Math.PI*2),t.strokeStyle=c(n.color,a?.3:.1),t.lineWidth=a?1.5:.7,t.stroke(),f(t,n.x,n.y,u*3,n.color,a?.22:.12);let d=t.createRadialGradient(n.x,n.y-u*.2,0,n.x,n.y,u);if(d.addColorStop(0,c(n.color,a?1:.85)),d.addColorStop(1,c(n.color,a?.65:.45)),t.fillStyle=d,t.beginPath(),t.arc(n.x,n.y,u,0,Math.PI*2),t.fill(),a||r===O.length-1){let r=u+16,i=e*.04,a=n.x+Math.cos(i)*r,o=n.y+Math.sin(i)*r;f(t,a,o,6,n.color,.3),t.beginPath(),t.arc(a,o,2,0,Math.PI*2),t.fillStyle=c(n.color,.75),t.fill()}v(C.current,`node-${r}`,n.x,n.y,u+8,{label:n.label,value:n.sub||n.id,color:n.color}),t.font=`${a||o?`bold `:``}12px 'DM Sans', sans-serif`,t.textAlign=`center`,t.textBaseline=`alphabetic`,t.fillStyle=c(n.color,a?1:.9),t.fillText(n.label,n.x,n.y+u+18),n.sub&&(t.font=`10px 'JetBrains Mono', monospace`,t.fillStyle=c(i.t3,.65),t.fillText(n.sub,n.x,n.y+u+32))}),k.length>=2){let n=k.reduce((e,t)=>e*t.conf,1),r=o*.92,s=a*.12,l=a*.76,u=b(Math.min(e*.008,1));t.fillStyle=c(i.bd,.35),t.beginPath(),t.roundRect(s,r,l,5,3),t.fill(),t.fillStyle=c(i.orange,.6),t.beginPath(),t.roundRect(s,r,l*n*u,5,3),t.fill(),t.font=`bold 12px 'JetBrains Mono', monospace`,t.textAlign=`left`,t.textBaseline=`middle`,t.fillStyle=c(i.orange,.85),t.fillText(`${Math.round(n*100)}% compound confidence`,s+l*n*u+10,r+2);let d=k.map(e=>e.conf.toFixed(2)).join(` × `);t.textAlign=`right`,t.font=`9px 'JetBrains Mono', monospace`,t.fillStyle=c(i.t4,.6),t.fillText(d,s-6,r+2)}m(t,a,o,e,.012),n=requestAnimationFrame(r)};return r(),()=>{cancelAnimationFrame(n),y.current=[]}},[O,k,a,o,s]),(0,n.jsxs)(`div`,{style:{position:`relative`,width:a,height:o},children:[(0,n.jsx)(`canvas`,{ref:l,style:{width:a,height:o,display:`block`,borderRadius:8},role:`img`,"aria-label":`causal flow diagram`}),(0,n.jsx)(g,{...S,parentW:a,parentH:o})]})}function Ue({selectedEntity:e,colors:t}){return(0,n.jsx)(He,{nodes:Te.nodes,links:Te.links,width:960,height:280,selectedEntity:e})}function We({rows:e=[],className:r,colors:i}){let{nodes:a,links:o}=(0,t.useMemo)(()=>{let t=e.slice(0,5);return{nodes:[{id:`score`,name:`Portfolio Score`},...t.map(e=>({id:e.id??e.vendor,name:e.vendor}))],links:t.map(e=>({source:e.id??e.vendor,target:`score`,value:Math.max(8,e.pricing??0)}))}},[e]);return(0,n.jsx)(Fe,{nodes:a,links:o,width:760,height:280,ariaLabel:`sankey chart`,className:r,colors:i})}var Ge=500,Ke=320;function qe({accepted:e,submitted:r,"data-testid":a}){let s=(0,t.useRef)(null),l=(0,t.useRef)(0);return(0,t.useEffect)(()=>{let t=s.current;if(!t)return;let n=d(t,Ge,Ke);l.current=0;let a=Ge/2,u=Math.max(e.value,r.value),p=(e.value-r.value)/u*14,m,h=()=>{l.current++;let t=l.current;n.clearRect(0,0,Ge,Ke);let s=b(Math.min(t/80,1)),d=p*C(Math.min(t/80,1))*Math.PI/180;n.strokeStyle=c(i.bd,.5*s),n.lineWidth=2,n.beginPath(),n.moveTo(a,100),n.lineTo(a,Ke-80),n.stroke(),n.beginPath(),n.arc(a,100,5*s,0,Math.PI*2),n.fillStyle=i.t2,n.fill();let g={x:a-Math.cos(d)*160,y:100+Math.sin(-d)*160},_={x:a+Math.cos(d)*160,y:100+Math.sin(d)*160};n.strokeStyle=c(i.t2,.5*s),n.lineWidth=2,n.beginPath(),n.moveTo(g.x,g.y),n.lineTo(_.x,_.y),n.stroke();let v=Math.max(20,e.value/u*100*s),y=g.y+18;f(n,g.x,y+v/2,90*.5,i.green,.18*s),n.fillStyle=c(i.green,.5*s),n.beginPath(),n.roundRect(g.x-90/2,y,90,v,[0,0,6,6]),n.fill(),n.strokeStyle=c(i.green,.7*s),n.lineWidth=1.5,n.stroke(),n.strokeStyle=c(i.t3,.35*s),n.lineWidth=1,[-90/3,90/3].forEach(e=>{n.beginPath(),n.moveTo(g.x+e,g.y+4),n.lineTo(g.x+e,y),n.stroke()}),s>.5&&(n.globalAlpha=Math.min(1,(s-.5)/.5),n.font=`bold 14px 'JetBrains Mono', monospace`,n.fillStyle=i.green,n.textAlign=`center`,n.fillText(e.label,g.x,y+v+18),n.font=o.font,n.fillStyle=o.color,n.fillText(`Accepted`,g.x,y+v+32),n.fillText(`${e.count} quotations`,g.x,y+v+44),n.globalAlpha=1);let x=Math.max(20,r.value/u*100*s),S=_.y+18;n.fillStyle=c(i.amber,.3*s),n.strokeStyle=c(i.amber,.5*s),n.lineWidth=1.5,n.beginPath(),n.roundRect(_.x-90/2,S,90,x,[0,0,6,6]),n.fill(),n.stroke(),n.strokeStyle=c(i.t3,.35*s),n.lineWidth=1,[-90/3,90/3].forEach(e=>{n.beginPath(),n.moveTo(_.x+e,_.y+4),n.lineTo(_.x+e,S),n.stroke()}),s>.5&&(n.globalAlpha=Math.min(1,(s-.5)/.5),n.font=`bold 14px 'JetBrains Mono', monospace`,n.fillStyle=i.amber,n.textAlign=`center`,n.fillText(r.label,_.x,S+x+18),n.font=o.font,n.fillStyle=o.color,n.fillText(`Submitted`,_.x,S+x+32),n.fillText(`${r.count} quotations`,_.x,S+x+44),n.globalAlpha=1),s>.85&&Math.abs(p)>1&&(n.globalAlpha=Math.min(1,(s-.85)/.15)*.6,n.font=o.font,n.fillStyle=o.color,n.textAlign=`center`,n.fillText(`${Math.abs(p).toFixed(1)}° tilt toward accepted`,a,Ke-12),n.globalAlpha=1),m=requestAnimationFrame(h)};return h(),()=>cancelAnimationFrame(m)},[e,r]),(0,n.jsx)(`div`,{"data-testid":a,style:{position:`relative`,width:Ge,height:Ke},children:(0,n.jsx)(`canvas`,{ref:s,role:`img`,"aria-label":`Quotation balance — accepted vs submitted quotation value`,style:{width:Ge,height:Ke,display:`block`}})})}var Je=680,U=280;function Ye({trend:e=[],"data-testid":r}){let a=(0,t.useRef)(null),s=(0,t.useRef)(new Map),l=(0,t.useRef)(0),{hoveredRef:u,tooltip:p,hitZonesRef:m}=_(a,{width:Je,height:U});return(0,t.useEffect)(()=>{let t=a.current;if(!t)return;let n=d(t,Je,U);l.current=0;let r=Je-54-28,p=U-30-54,g=Math.max(...e.map(e=>e.count),1),_=e.length,y=_>1?r/(_-1):r,x=e.map((e,t)=>({x:54+t*y,y:30+p-e.count/g*p,point:e})),S,C=()=>{l.current++;let e=l.current;n.clearRect(0,0,Je,U);let t=b(Math.min(e/72,1));E(s.current,u.current),m.current=[],[.25,.5,.75,1].forEach(e=>{let t=30+p-e*p;n.strokeStyle=c(i.bd,.18),n.lineWidth=1,n.setLineDash([3,5]),n.beginPath(),n.moveTo(54,t),n.lineTo(54+r,t),n.stroke(),n.setLineDash([]),n.font=o.font,n.fillStyle=o.color,n.textAlign=`right`,n.fillText(String(Math.round(g*e)),48,t+3)}),n.save(),n.translate(12,30+p/2),n.rotate(-Math.PI/2),n.font=o.font,n.fillStyle=o.color,n.textAlign=`center`,n.fillText(`Submissions`,0,0),n.restore(),n.font=o.font,n.fillStyle=o.color,n.textAlign=`center`,n.fillText(`Week`,54+r/2,U-6),n.strokeStyle=c(i.bd,.3),n.lineWidth=1,n.setLineDash([]),n.beginPath(),n.moveTo(54,30+p),n.lineTo(54+r,30+p),n.stroke();let a=t*(_-1),d=Math.floor(a)+1;if(d>=2){n.beginPath(),n.moveTo(x[0].x,30+p),n.lineTo(x[0].x,x[0].y);for(let e=1;e<d;e++){let t=a-Math.floor(a),r=e<d-1?x[e].x:x[e-1].x+(x[e].x-x[e-1].x)*(e===Math.ceil(a)?t:1),i=e<d-1?x[e].y:x[e-1].y+(x[e].y-x[e-1].y)*(e===Math.ceil(a)?t:1);n.lineTo(r,i)}let e=x[Math.min(d-1,_-1)];n.lineTo(e.x,30+p),n.closePath();let t=n.createLinearGradient(0,30,0,30+p);t.addColorStop(0,c(i.cyan,.22)),t.addColorStop(1,c(i.cyan,.02)),n.fillStyle=t,n.fill()}n.beginPath();for(let e=0;e<d;e++){let t=a-Math.floor(a),r=e===d-1&&e>0&&e===Math.ceil(a),i=e===0||e<d-1?x[e].x:x[e-1].x+(x[e].x-x[e-1].x)*(r?t:1),o=e===0||e<d-1?x[e].y:x[e-1].y+(x[e].y-x[e-1].y)*(r?t:1);e===0?n.moveTo(i,o):n.lineTo(i,o)}n.strokeStyle=c(i.cyan,.85),n.lineWidth=2,n.stroke(),x.forEach((e,t)=>{if(t>=d)return;let r=`pt-${t}`,a=s.current.get(r)??0;v(m.current,r,e.x,e.y,10,{label:e.point.week,value:`${e.point.count} quotations submitted`,sublabel:`£${e.point.value}M value`,color:i.cyan}),a>0&&h(n,e.x,30,30+p,c(i.cyan,.15*a));let l=e.point.count===g;(a>0||l)&&f(n,e.x,e.y,14,i.cyan,(l?.3:0)+a*.25),n.beginPath(),n.arc(e.x,e.y,a>0?5:3.5,0,Math.PI*2),n.fillStyle=c(i.cyan,a>0?1:.8),n.fill(),(a>0||l)&&(n.font=`500 14px 'Satoshi Variable', 'DM Sans', sans-serif`,n.fillStyle=i.cyan,n.textAlign=`center`,n.fillText(String(e.point.count),e.x,e.y-10)),n.font=`500 14px 'Satoshi Variable', 'DM Sans', sans-serif`,n.fillStyle=a>0?i.cyan:o.color,n.textAlign=`center`,n.fillText(e.point.week,e.x,U-54+14)}),S=requestAnimationFrame(C)};return C(),()=>cancelAnimationFrame(S)},[e]),(0,n.jsx)(`div`,{"data-testid":r,className:`trend-scroll`,style:{width:`100%`,overflowX:`auto`},children:(0,n.jsxs)(`div`,{style:{position:`relative`,width:Je,height:U},children:[(0,n.jsx)(`canvas`,{ref:a,role:`img`,"aria-label":`Trend chart — count over time`,style:{width:Je,height:U,display:`block`}}),(0,n.jsx)(g,{...p,parentW:Je,parentH:U})]})})}var Xe=680,W=280,Ze=54,Qe=28,$e=64,et=`500 14px 'Satoshi Variable', 'DM Sans', sans-serif`,tt=12;function nt({trend:e=[],"data-testid":r}){let a=(0,t.useRef)(null),s=(0,t.useRef)(new Map),l=(0,t.useRef)(0),u=(0,t.useMemo)(()=>{if(e.length<=1)return $e;let t=document.createElement(`canvas`).getContext(`2d`);if(!t)return $e;t.font=et;let n=Math.max(...e.map(e=>t.measureText(e.week).width));return Math.max($e,n+tt)},[e]),p=Math.max(Xe,Ze+Qe+Math.max(0,e.length-1)*u),{hoveredRef:m,tooltip:y,hitZonesRef:x}=_(a,{width:p,height:W});return(0,t.useEffect)(()=>{let t=a.current;if(!t)return;let n=d(t,p,W);l.current=0;let r=Ze,g=Qe,_=p-r-g,y=W-30-54,S=Math.max(...e.map(e=>e.count),1),C=e.length,w=C>1?Math.max(_/(C-1),u):_,T=e.map((e,t)=>({x:r+t*w,y:30+y-e.count/S*y,point:e})),D,O=()=>{l.current++;let e=l.current;n.clearRect(0,0,p,W);let t=b(Math.min(e/72,1));E(s.current,m.current),x.current=[],[.25,.5,.75,1].forEach(e=>{let t=30+y-e*y;n.strokeStyle=c(i.bd,.18),n.lineWidth=1,n.setLineDash([3,5]),n.beginPath(),n.moveTo(r,t),n.lineTo(r+_,t),n.stroke(),n.setLineDash([]),n.font=o.font,n.fillStyle=o.color,n.textAlign=`right`,n.fillText(String(Math.round(S*e)),r-6,t+3)}),n.save(),n.translate(12,30+y/2),n.rotate(-Math.PI/2),n.font=o.font,n.fillStyle=o.color,n.textAlign=`center`,n.fillText(`Count`,0,0),n.restore(),n.font=o.font,n.fillStyle=o.color,n.textAlign=`center`,n.fillText(`Period`,r+_/2,W-6),n.strokeStyle=c(i.bd,.3),n.lineWidth=1,n.setLineDash([]),n.beginPath(),n.moveTo(r,30+y),n.lineTo(r+_,30+y),n.stroke();let a=t*(C-1),u=Math.floor(a)+1;if(u>=2){n.beginPath(),n.moveTo(T[0].x,30+y),n.lineTo(T[0].x,T[0].y);for(let e=1;e<u;e++){let t=a-Math.floor(a),r=e<u-1?T[e].x:T[e-1].x+(T[e].x-T[e-1].x)*(e===Math.ceil(a)?t:1),i=e<u-1?T[e].y:T[e-1].y+(T[e].y-T[e-1].y)*(e===Math.ceil(a)?t:1);n.lineTo(r,i)}let e=T[Math.min(u-1,C-1)];n.lineTo(e.x,30+y),n.closePath();let t=n.createLinearGradient(0,30,0,30+y);t.addColorStop(0,c(i.cyan,.22)),t.addColorStop(1,c(i.cyan,.02)),n.fillStyle=t,n.fill()}n.beginPath();for(let e=0;e<u;e++){let t=a-Math.floor(a),r=e===u-1&&e>0&&e===Math.ceil(a),i=e===0||e<u-1?T[e].x:T[e-1].x+(T[e].x-T[e-1].x)*(r?t:1),o=e===0||e<u-1?T[e].y:T[e-1].y+(T[e].y-T[e-1].y)*(r?t:1);e===0?n.moveTo(i,o):n.lineTo(i,o)}n.strokeStyle=c(i.cyan,.85),n.lineWidth=2,n.stroke(),T.forEach((e,t)=>{if(t>=u)return;let r=`pt-${t}`,a=s.current.get(r)??0;v(x.current,r,e.x,e.y,10,{label:e.point.week,value:`${e.point.count} submissions`,sublabel:`£${e.point.value}M value`,color:i.cyan}),a>0&&h(n,e.x,30,30+y,c(i.cyan,.15*a));let l=e.point.count===S;(a>0||l)&&f(n,e.x,e.y,14,i.cyan,(l?.3:0)+a*.25),n.beginPath(),n.arc(e.x,e.y,a>0?5:3.5,0,Math.PI*2),n.fillStyle=c(i.cyan,a>0?1:.8),n.fill(),(a>0||l)&&(n.font=et,n.fillStyle=i.cyan,n.textAlign=`center`,n.fillText(String(e.point.count),e.x,e.y-10)),n.font=et,n.fillStyle=a>0?i.cyan:o.color,n.textAlign=`center`,n.fillText(e.point.week,e.x,W-54+14)}),D=requestAnimationFrame(O)};return O(),()=>cancelAnimationFrame(D)},[e,p,u]),(0,n.jsx)(`div`,{"data-testid":r,className:`trend-scroll`,style:{width:`100%`,overflowX:`auto`},children:(0,n.jsxs)(`div`,{style:{position:`relative`,width:p,height:W},children:[(0,n.jsx)(`canvas`,{ref:a,role:`img`,"aria-label":`Trend chart — count over time`,style:{width:p,height:W,display:`block`}}),(0,n.jsx)(g,{...y,parentW:p,parentH:W})]})})}var G=680,rt=240,it={Critical:i.red,High:i.orange,Medium:i.amber,Low:i.green};function at({severities:e=[],"data-testid":r}){let a=(0,t.useRef)(null),s=(0,t.useRef)(new Map),l=(0,t.useRef)(0),{hoveredRef:u,tooltip:p,hitZonesRef:m}=_(a,{width:G,height:rt});return(0,t.useEffect)(()=>{let t=a.current;if(!t)return;let n=d(t,G,rt);l.current=0;let r=e.reduce((e,t)=>e+t.count,0),p=G-28-28,h=rt-50-52,g=e.map(e=>e.count/r*p),_,v=()=>{l.current++;let t=l.current;n.clearRect(0,0,G,rt);let a=x(Math.min(t/60,1));E(s.current,u.current),m.current=[],n.strokeStyle=c(i.bd,.2),n.lineWidth=1,n.beginPath(),n.rect(28,50,p,h),n.stroke(),n.strokeStyle=c(i.t4,.15),n.lineWidth=1,n.setLineDash([4,4]),n.beginPath(),n.moveTo(G/2,50),n.lineTo(G/2,50+h),n.stroke(),n.setLineDash([]);let d=28;e.forEach((e,t)=>{let l=it[e.severity]??i.blue,u=g[t];u*a;let p=s.current.get(e.severity)??0,_=d+u/2,v=u*.85;_-v/2;let b=u*a,x=v*a,S=_-x/2;if(b>0&&(p>0&&f(n,d+b/2,50+h/2,b*.4,l,.15*p),n.beginPath(),n.moveTo(S,50),n.lineTo(S+x,50),n.lineTo(d+b,50+h),n.lineTo(d,50+h),n.closePath(),n.fillStyle=c(l,.45+p*.25),n.fill(),n.strokeStyle=c(l,(.5+p*.3)*a),n.lineWidth=p>0?2:1,n.beginPath(),n.moveTo(S,50),n.lineTo(S+x,50),n.stroke(),n.strokeStyle=c(l,(.3+p*.3)*a),n.lineWidth=p>0?2:1,n.beginPath(),n.moveTo(d,50+h),n.lineTo(d+b,50+h),n.stroke()),y(m.current,e.severity,d,50,u,h,{label:e.severity,value:`${e.count} Early Warnings`,sublabel:`${Math.round(e.count/r*100)}% of all EWs`,color:l}),a>.5){let t=Math.min(1,(a-.5)/.5),s=d+u/2;n.globalAlpha=t,n.font=`bold `+o.font,n.fillStyle=p>0?l:c(l,.9),n.textAlign=`center`,n.fillText(e.severity,s,38),n.font=`bold `+o.font,n.fillStyle=p>0?i.t1:c(i.t1,.85),n.fillText(String(e.count),s,50+h/2+6),n.font=o.font,n.fillStyle=p>0?l:o.color,n.fillText(`${Math.round(e.count/r*100)}%`,s,50+h+18),n.globalAlpha=1}d+=u});let b=n.createLinearGradient(28,0,28+p,0);b.addColorStop(0,c(i.red,.03)),b.addColorStop(.33,c(i.orange,.03)),b.addColorStop(.66,c(i.amber,.03)),b.addColorStop(1,c(i.green,.03)),n.fillStyle=b,n.fillRect(28,50,p*a,h),_=requestAnimationFrame(v)};return v(),()=>cancelAnimationFrame(_)},[e]),(0,n.jsxs)(`div`,{"data-testid":r,style:{position:`relative`,width:G,height:rt},children:[(0,n.jsx)(`canvas`,{ref:a,role:`img`,"aria-label":`Early Warning severity distribution — prism spectrum bands`,style:{width:G,height:rt,display:`block`}}),(0,n.jsx)(g,{...p,parentW:G,parentH:rt})]})}var K=460,q=300,ot={Open:i.red,Submitted:i.amber,Closed:i.green};function st({segments:e=[],title:r,"data-testid":a}){let s=(0,t.useRef)(null),l=(0,t.useRef)(0),u=(0,t.useRef)(new Map),{hoveredRef:h,tooltip:y,hitZonesRef:b}=_(s,{width:K,height:q});return(0,t.useEffect)(()=>{let t=s.current;if(!t)return;let n=d(t,K,q);l.current=0;let r=K*.5,a=q*.54,g=K*.22,_=e.reduce((e,t)=>e+t.count,0),y=Math.max(...e.map(e=>e.count),1),x,S=()=>{l.current++;let t=l.current;n.clearRect(0,0,K,q),b.current=[],u.current.forEach((e,t)=>{let n=t===h.current?1:0,r=e+(n-e)*.12;Math.abs(r-n)<.005?n===0?u.current.delete(t):u.current.set(t,1):u.current.set(t,r)}),h.current&&!u.current.has(h.current)&&u.current.set(h.current,0),p(n,K,q,t,40,c(i.blue,.04)),e.forEach((e,s)=>{let l=s/3*Math.PI*2-Math.PI/2,u=r+Math.cos(l)*g,d=a+Math.sin(l)*g,p=ot[e.status]??i.blue,m=2+e.count/y*8;n.beginPath(),n.moveTo(r,a),n.lineTo(u,d),n.strokeStyle=c(p,.08),n.lineWidth=m*2,n.stroke(),n.beginPath(),n.moveTo(r,a),n.lineTo(u,d),n.strokeStyle=c(p,.25),n.lineWidth=1,n.stroke();let h=(t*.005+s*.33)%1,_=r+(u-r)*h,v=a+(d-a)*h;f(n,_,v,6,p,.4),n.beginPath(),n.arc(_,v,2,0,Math.PI*2),n.fillStyle=c(p,.8),n.fill();let b=(r+u)/2,x=(a+d)/2;n.font=`bold `+o.font,n.textAlign=`center`,n.textBaseline=`middle`,n.fillStyle=c(p,.85),n.fillText(String(e.count),b,x)}),e.forEach((e,t)=>{let s=t/3*Math.PI*2-Math.PI/2,l=r+Math.cos(s)*g,d=a+Math.sin(s)*g,p=ot[e.status]??i.blue,m=10+e.count/y*18,h=u.current.get(e.status)??0;f(n,l,d,m*2.5,p,.2+h*.15);let x=n.createRadialGradient(l,d-m*.2,0,l,d,m);x.addColorStop(0,c(p,.8+h*.2)),x.addColorStop(1,c(p,.4+h*.1)),n.beginPath(),n.arc(l,d,m,0,Math.PI*2),n.fillStyle=x,n.fill(),n.font=`bold `+o.font,n.textAlign=`center`,n.textBaseline=`middle`,n.fillStyle=c(i.t1,.9),n.fillText(e.status,l,d),v(b.current,e.status,l,d,m+6,{label:e.status,value:`${e.count} Early Warnings`,sublabel:`${Math.round(e.count/_*100)}%`,color:p})});let s=u.current.get(`center`)??0;f(n,r,a,36,i.t3,.2+s*.15);let d=n.createRadialGradient(r,a-4,0,r,a,22);d.addColorStop(0,c(i.t2,.9)),d.addColorStop(1,c(i.t3,.5)),n.beginPath(),n.arc(r,a,22,0,Math.PI*2),n.fillStyle=d,n.fill(),n.font=o.font,n.textAlign=`center`,n.textBaseline=`middle`,n.fillStyle=c(i.t1,.9),n.fillText(`EW Status`,r,a-4),n.font=`bold `+o.font,n.fillStyle=i.t1,n.fillText(String(_),r,a+8),v(b.current,`center`,r,a,28,{label:`Total EW Status`,value:`${_} Early Warnings`,color:i.t3}),m(n,K,q,t,.015),x=requestAnimationFrame(S)};return S(),()=>cancelAnimationFrame(x)},[e,r]),(0,n.jsxs)(`div`,{"data-testid":a,style:{position:`relative`,width:K,height:q},children:[(0,n.jsx)(`canvas`,{ref:s,role:`img`,"aria-label":r??`EW status arc visualization`,style:{width:K,height:q,display:`block`,borderRadius:8}}),(0,n.jsx)(g,{...y,parentW:K,parentH:q})]})}var J=280,Y=96;function ct({points:e=[],className:a,colors:o}){let s=(0,t.useRef)(null),l=(0,t.useRef)(new Map),u=(0,t.useRef)(0),p=(0,t.useMemo)(()=>e.map(([e,t])=>{let n=String(t).match(/-?\d+(\.\d+)?/);return{label:e,value:n?Number(n[0]):0}}),[e]),{mouseRef:m,hoveredRef:y,tooltip:b,hitZonesRef:x}=_(s,{width:J,height:Y});return(0,t.useEffect)(()=>{let e=s.current;if(!e)return;let t=d(e,J,Y);u.current=0;let n=o?.line??i.blue,r=o?.point??i.blue,a=o?.axisLine??i.bd,g,_=()=>{u.current++;let e=u.current;if(t.clearRect(0,0,J,Y),p.length<2){g=requestAnimationFrame(_);return}let o={left:12,right:12,top:16,bottom:20},s=J-o.left-o.right,d=Y-o.top-o.bottom,b=p.map(e=>e.value),S=Math.min(...b),C=Math.max(...b)-S||1,T=e=>o.left+e/(p.length-1)*s,D=e=>o.top+(1-(e-S)/C)*d,O=1-(1-Math.min(e/48,1))**3,k=Math.max(2,Math.floor(O*p.length));if(E(l.current,y.current),x.current=[],t.strokeStyle=c(a,.3),t.lineWidth=.5,t.setLineDash([]),t.beginPath(),t.moveTo(o.left,Y-o.bottom),t.lineTo(J-o.right,Y-o.bottom),t.stroke(),t.font=`9px 'JetBrains Mono', monospace`,t.fillStyle=c(i.t4,.9),t.textAlign=`center`,p.forEach((e,n)=>{t.fillText(e.label.replace(`Day `,`D`),T(n),Y-4)}),m.current.over&&y.current){let e=parseInt(y.current.split(`-`)[1]);isNaN(e)||h(t,T(e),o.top,o.top+d)}if(k>1){let e=t.createLinearGradient(0,o.top,0,o.top+d);e.addColorStop(0,c(n,.15)),e.addColorStop(1,c(n,0)),t.fillStyle=e,t.beginPath(),t.moveTo(T(0),o.top+d);for(let e=0;e<k;e++)t.lineTo(T(e),D(p[e].value));t.lineTo(T(k-1),o.top+d),t.closePath(),t.fill(),t.strokeStyle=c(n,.8),t.lineWidth=1.5,t.setLineDash([]),t.beginPath();for(let e=0;e<k;e++){let n=T(e),r=D(p[e].value);e===0?t.moveTo(n,r):t.lineTo(n,r)}t.stroke()}for(let e=0;e<k;e++){let n=T(e),a=D(p[e].value),o=`tp-${e}`,s=l.current.get(o)??0,u=e===p.length-1;v(x.current,o,n,a,10,{label:p[e].label,value:String(p[e].value),color:u?i.red:r}),s>0&&!u&&(f(t,n,a,12*s,r,.2*s),t.fillStyle=c(r,.8),t.beginPath(),t.arc(n,a,3+s*2,0,Math.PI*2),t.fill())}if(k>=p.length){let n=p.length-1,r=T(n),a=D(p[n].value),o=l.current.get(`tp-${n}`)??0,s=w(e,.05,5e-4),u=1+o*.5;t.shadowColor=c(i.red,.5),t.shadowBlur=(8+s*4)*u,t.fillStyle=i.red,t.beginPath(),t.arc(r,a,(3.5+s*1.5)*u,0,Math.PI*2),t.fill(),t.shadowBlur=0}g=requestAnimationFrame(_)};return _(),()=>cancelAnimationFrame(g)},[p,o]),(0,n.jsx)(r,{className:[`canvas-trend-frame`,a].filter(Boolean).join(` `),children:(0,n.jsxs)(`div`,{style:{position:`relative`,width:J,height:Y},children:[(0,n.jsx)(`canvas`,{ref:s,role:`img`,"aria-label":`trend chart`,style:{width:J,height:Y,display:`block`,borderRadius:8}}),(0,n.jsx)(g,{...b,parentW:J,parentH:Y})]})})}var lt=680,ut=320;function dt({contractors:e=[],"data-testid":r}){let o=(0,t.useRef)(null),l=(0,t.useRef)(new Map),u=(0,t.useRef)(0),{hoveredRef:p,tooltip:m,hitZonesRef:h}=_(o,{width:lt,height:ut});return(0,t.useEffect)(()=>{let t=o.current;if(!t)return;let n=d(t,lt,ut);u.current=0;let r=lt-60-28,m=Math.max(...e.map(e=>(e.implemented??0)+(e.unimplemented??0))),g=e.length*40-14,_=16+(ut-16-32-g)/2,v,b=()=>{u.current++;let t=u.current;n.clearRect(0,0,lt,ut);let o=x(Math.min(t/60,1));E(l.current,p.current),h.current=[],e.forEach((t,s)=>{let u=a[s%a.length],d=T(o,s,e.length,x),p=_+s*40,g=(t.implemented??0)+(t.unimplemented??0),v=(t.implemented??0)/m*r*d,b=(t.unimplemented??0)/m*r*d,S=`${t.id}-impl`,C=`${t.id}-un`,w=l.current.get(S)??0,E=l.current.get(C)??0;y(h.current,S,60,p,v||1,26,{label:`${t.name} — Implemented`,value:`${t.implemented??0} variations`,sublabel:`${Math.round((t.implemented??0)/(g||1)*100)}% complete`,color:i.green}),y(h.current,C,60+v,p,b||1,26,{label:`${t.name} — Unimplemented`,value:`${t.unimplemented??0} variations`,sublabel:`${Math.round((t.unimplemented??0)/(g||1)*100)}% pending`,color:i.amber}),n.font=`500 14px 'Satoshi Variable', 'DM Sans', sans-serif`,n.fillStyle=c(u,.85),n.textAlign=`right`,n.fillText(t.abbreviation??t.name.slice(0,6),52,p+26/2+4),n.fillStyle=c(i.bd,.15),n.beginPath(),n.roundRect(60,p,g/m*r,26,4),n.fill(),v>0&&(w>0&&f(n,60+v/2,p+26/2,v*.3,i.green,.12*w),n.fillStyle=c(i.green,.6+w*.2),n.beginPath(),n.roundRect(60,p,v,26,[4,0,0,4]),n.fill(),v>28&&d>.5&&(n.font=`500 14px 'Satoshi Variable', 'DM Sans', sans-serif`,n.fillStyle=w>0?i.green:c(i.t1,.8),n.textAlign=`center`,n.fillText(String(t.implemented??0),60+v/2,p+26/2+4))),b>0&&(E>0&&f(n,60+v+b/2,p+26/2,b*.3,i.amber,.12*E),n.fillStyle=c(i.amber,.18+E*.18),n.strokeStyle=c(i.amber,.3+E*.3),n.lineWidth=1,n.beginPath(),n.roundRect(60+v,p,b,26,[0,4,4,0]),n.fill(),n.stroke(),b>28&&d>.5&&(n.font=`500 14px 'Satoshi Variable', 'DM Sans', sans-serif`,n.fillStyle=E>0?i.amber:c(i.t3,.8),n.textAlign=`center`,n.fillText(String(t.unimplemented??0),60+v+b/2,p+26/2+4))),v>0&&b>0&&(n.strokeStyle=c(i.bg,.7),n.lineWidth=2,n.beginPath(),n.moveTo(60+v,p),n.lineTo(60+v,p+26),n.stroke())});let d=_+g+24,S=60+r/2;n.font=`400 12px 'Satoshi Variable', 'DM Sans', sans-serif`,n.textAlign=`right`,n.fillStyle=i.green,n.fillText(`■ Implemented`,S-10,d),n.textAlign=`left`,n.fillStyle=s.color,n.fillText(`■ Unimplemented`,S+10,d),v=requestAnimationFrame(b)};return b(),()=>cancelAnimationFrame(v)},[e]),(0,n.jsxs)(`div`,{"data-testid":r,style:{position:`relative`,width:lt,height:ut},children:[(0,n.jsx)(`canvas`,{ref:o,role:`img`,"aria-label":`Implemented vs unimplemented variations per contractor — split bar`,style:{width:lt,height:ut,display:`block`}}),(0,n.jsx)(g,{...m,parentW:lt,parentH:ut})]})}var ft=800,pt=360;function mt({contractors:e=[],"data-testid":r}){let o=(0,t.useRef)(null),s=(0,t.useRef)(new Map),l=(0,t.useRef)(0),{hoveredRef:u,tooltip:p,hitZonesRef:m}=_(o,{width:ft,height:pt});return(0,t.useEffect)(()=>{let t=o.current;if(!t)return;let n=d(t,ft,pt);l.current=0;let r=e.reduce((e,t)=>e+(t.base??0),0),p=e.reduce((e,t)=>e+(t.variation??0),0),h=e.reduce((e,t)=>e+(t.total??0),0),g=pt-20-26,_=g-6*(e.length-1),v=20,x=e.map((e,t)=>{let n=Math.max(24,(e.total??0)/(h||1)*_),r={x:100-110/2,y:v,h:n,cy:v+n/2,c:e,color:a[t%a.length]};return v+=n+6,r}),S=_-14,C=Math.max(28,r/h*S),w=Math.max(18,p/h*S),D=20+(g-(C+w+14))/2,O={x:420-110/2,y:D,h:C,cy:D+C/2},k={x:420-110/2,y:D+C+14,h:w,cy:D+C+14+w/2},A={x:720-110/2,y:20,h:g,cy:20+g/2},j,M=()=>{l.current++;let t=l.current;n.clearRect(0,0,ft,pt);let a=b(Math.min(t/80,1));if(E(s.current,u.current),m.current=[],e.forEach((t,i)=>{let o=x[i],c=T(a,i,e.length,b),l=s.current.get(t.id)??0;if(c<.01)return;let u=(t.base??0)/(t.total||1),d=(t.variation??0)/(t.total||1),f=o.h*u,m=o.h*d,h=o.y+f/2,g=o.y+f+m/2,_=Math.max(2,(t.base??0)/r*C),v=Math.max(2,(t.variation??0)/p*w),y=O.y+e.slice(0,i).reduce((e,t)=>e+(t.base??0)/r*C,0)+_/2,S=k.y+e.slice(0,i).reduce((e,t)=>e+(t.variation??0)/p*w,0)+v/2,E=l*.2+.18;ht(n,o.x+110,h,420-110/2,y,_*c,o.color,E),ht(n,o.x+110,g,420-110/2,S,v*c,o.color,E*.75)}),a>.3){let e=Math.min(1,(a-.3)/.7),t=A.y+r/h*g/2,o=A.y+g-p/h*g/2;ht(n,475,O.cy,720-110/2,t,C*e,i.blue,.25*e),ht(n,475,k.cy,720-110/2,o,w*e,i.amber,.22*e)}if([`Contractors`,`Components`,`Total`].forEach((e,t)=>{let r=[100,420,720][t];n.font=`400 12px 'Satoshi Variable', 'DM Sans', sans-serif`,n.fillStyle=c(i.t3,.5),n.textAlign=`center`,n.fillText(e,r,pt-8)}),e.forEach((t,r)=>{let o=x[r],l=T(a,r,e.length,b),u=s.current.get(t.id)??0;y(m.current,t.id,o.x,o.y,110,o.h,{label:t.name,value:`£${t.total??0}M total commitment`,sublabel:`Base £${t.base??0}M + Variations £${t.variation??0}M`,color:o.color}),u>0&&f(n,o.x+110/2,o.cy,110*.6,o.color,.12*u),n.fillStyle=c(o.color,(.3+u*.15)*l),n.strokeStyle=c(o.color,(.55+u*.25)*l),n.lineWidth=1,n.beginPath(),n.roundRect(o.x,o.y,110*l,o.h,4),n.fill(),n.stroke(),l>.6&&o.h>=24&&(n.globalAlpha=Math.min(1,(l-.6)/.4),n.font=`500 14px 'Satoshi Variable', 'DM Sans', sans-serif`,n.fillStyle=u>0?o.color:c(i.t2,.9),n.textAlign=`center`,n.textBaseline=`middle`,n.fillText(t.abbreviation??t.name.slice(0,6),o.x+110/2,o.h>=36?o.cy-5:o.cy),o.h>=36&&(n.font=`400 12px 'Satoshi Variable', 'DM Sans', sans-serif`,n.fillStyle=c(i.t3,.8),n.fillText(`£${t.total??0}M`,o.x+110/2,o.cy+7)),n.globalAlpha=1,n.textBaseline=`alphabetic`)}),a>.2){let e=Math.min(1,(a-.2)/.4);f(n,420,O.cy,30,i.blue,.1*e),n.fillStyle=c(i.blue,.3*e),n.strokeStyle=c(i.blue,.5*e),n.lineWidth=1,n.beginPath(),n.roundRect(O.x,O.y,110,O.h*e,4),n.fill(),n.stroke(),n.globalAlpha=e,n.textBaseline=`middle`,n.font=`500 14px 'Satoshi Variable', 'DM Sans', sans-serif`,n.fillStyle=i.blue,n.textAlign=`center`,n.fillText(`Base Value`,420,O.cy-6),n.font=`500 14px 'Satoshi Variable', 'DM Sans', sans-serif`,n.fillStyle=i.t1,n.fillText(`£${r}M`,420,O.cy+8),n.globalAlpha=1,n.textBaseline=`alphabetic`,f(n,420,k.cy,24,i.amber,.1*e),n.fillStyle=c(i.amber,.22*e),n.strokeStyle=c(i.amber,.4*e),n.beginPath(),n.roundRect(k.x,k.y,110,k.h*e,4),n.fill(),n.stroke(),n.globalAlpha=e,n.textBaseline=`middle`,n.font=`500 14px 'Satoshi Variable', 'DM Sans', sans-serif`,n.fillStyle=i.amber,n.textAlign=`center`,n.fillText(`Variations`,420,k.cy-4),n.font=`500 14px 'Satoshi Variable', 'DM Sans', sans-serif`,n.fillStyle=i.t1,n.fillText(`£${p}M`,420,k.cy+8),n.globalAlpha=1,n.textBaseline=`alphabetic`}if(a>.5){let e=Math.min(1,(a-.5)/.5);f(n,720,A.cy,44,i.cyan,.2*e),n.fillStyle=c(i.cyan,.25*e),n.strokeStyle=c(i.cyan,.6*e),n.lineWidth=1.5,n.beginPath(),n.roundRect(A.x,A.y,110,A.h*e,6),n.fill(),n.stroke(),n.globalAlpha=e,n.textBaseline=`middle`,n.font=`400 12px 'Satoshi Variable', 'DM Sans', sans-serif`,n.fillStyle=i.t2,n.textAlign=`center`,n.fillText(`Total Commitment`,720,A.cy-12),n.font=`500 14px 'Satoshi Variable', 'DM Sans', sans-serif`,n.fillStyle=i.cyan,n.fillText(`£${h}M`,720,A.cy+6),n.globalAlpha=1,n.textBaseline=`alphabetic`}j=requestAnimationFrame(M)};return M(),()=>cancelAnimationFrame(j)},[e]),(0,n.jsxs)(`div`,{"data-testid":r,style:{position:`relative`,width:ft,height:pt},children:[(0,n.jsx)(`canvas`,{ref:o,role:`img`,"aria-label":`Weekly report flow — base value and variations per contractor flowing to total commitment`,style:{width:ft,height:pt,display:`block`}}),(0,n.jsx)(g,{...p,parentW:ft,parentH:pt})]})}function ht(e,t,n,r,i,a,o,s){let l=(t+r)/2;e.beginPath(),e.moveTo(t,n-a/2),e.bezierCurveTo(l,n-a/2,l,i-a/2,r,i-a/2),e.lineTo(r,i+a/2),e.bezierCurveTo(l,i+a/2,l,n+a/2,t,n+a/2),e.closePath(),e.fillStyle=c(o,s),e.fill()}function gt({config:e,className:t}){return e.type===`line`?(0,n.jsx)(Ce,{rows:e.rows,className:t}):e.type===`area`?(0,n.jsx)(A,{rows:e.rows,className:t}):e.type===`bar`?(0,n.jsx)(N,{rows:e.rows,className:t}):e.type===`pie`?(0,n.jsx)(Ne,{rows:e.rows,variant:`pie`,className:t}):e.type===`donut`?(0,n.jsx)(Ne,{rows:e.rows,variant:`donut`,className:t}):e.type===`sankey`?(0,n.jsx)(We,{rows:e.rows,className:t}):e.type===`flow`?(0,n.jsx)(Ue,{selectedEntity:e.selectedEntity,className:t}):e.type===`trend`?(0,n.jsx)(ct,{points:e.points,className:t}):e.type===`mini-bars`?(0,n.jsx)(Ee,{rows:e.rows,className:t}):e.type===`contract-value-orb`?(0,n.jsx)(ge,{data:e.data}):e.type===`contract-bars`?(0,n.jsx)(fe,{contractors:e.contractors}):e.type===`commitment-race`?(0,n.jsx)(te,{contractors:e.contractors}):e.type===`status-arc`?(0,n.jsx)(st,{segments:e.segments,title:e.title}):e.type===`ew-category`?(0,n.jsx)(Se,{categories:e.categories}):e.type===`contractor-rank`?(0,n.jsx)(xe,{contractors:e.contractors}):e.type===`severity-bands`?(0,n.jsx)(at,{severities:e.severities}):e.type===`nce-tree`?(0,n.jsx)(ke,{total:e.total,byContractor:e.byContractor}):e.type===`compensation-gauge`?(0,n.jsx)(ie,{pct:e.pct,confirmed:e.confirmed,total:e.total}):e.type===`variation-split`?(0,n.jsx)(dt,{contractors:e.contractors}):e.type===`quotation-balance`?(0,n.jsx)(qe,{accepted:e.accepted,submitted:e.submitted}):e.type===`quotation-trend`?(0,n.jsx)(Ye,{trend:e.trend}):e.type===`trend-view`?(0,n.jsx)(nt,{trend:e.trend}):e.type===`weekly-flow`?(0,n.jsx)(mt,{contractors:e.contractors}):(0,n.jsx)(`div`,{className:`viz-empty`,children:`Visualization unavailable`})}var _t=[];function vt(e){try{return JSON.parse(decodeURIComponent(e))}catch{return null}}function yt(){for(;_t.length;){let e=_t.pop();e&&e.unmount()}}function bt(){yt(),document.querySelectorAll(`[data-d3-viz]`).forEach(t=>{let r=t.dataset.d3Viz;if(!r)return;let i=vt(r);if(!i)return;let a=(0,e.createRoot)(t);_t.push(a),a.render((0,n.jsx)(gt,{config:i}))})}function xt(e){return encodeURIComponent(JSON.stringify(e))}function St({rows:e=[],className:t,colors:r}){return(0,n.jsx)(Ne,{rows:e,variant:`donut`,className:t,colors:r})}var X={bg:i.sf,border:i.bd,t1:i.t1,t2:i.t2,t3:i.t3,t4:i.t4,red:i.red,amber:i.amber,green:i.green},Z=`'JetBrains Mono', monospace`,Q=`'Satoshi Variable', 'DM Sans', sans-serif`,Ct={color:`#F7F7F7`,fontFamily:Q,fontSize:24,fontWeight:500,lineHeight:`32px`},$={color:`#CECFD2`,fontFamily:Q,fontSize:14,fontWeight:400,lineHeight:`20px`};function wt({chips:e=[]}){return(0,n.jsx)(`div`,{style:{display:`flex`,gap:6,marginTop:10},children:e.map((e,t)=>(0,n.jsxs)(`div`,{style:{flex:1,display:`flex`,alignItems:`baseline`,gap:8,padding:`8px 12px`,background:X.bg,border:`1px solid ${X.border}`,borderRadius:5},children:[(0,n.jsx)(`span`,{style:{...Ct,color:e.color??X.t1},children:e.value}),(0,n.jsx)(`span`,{style:{...$,flex:1},children:e.label})]},t))})}function Tt({items:e=[]}){return(0,n.jsx)(`div`,{style:{display:`flex`,gap:8},children:e.map((e,t)=>(0,n.jsxs)(`div`,{style:{flex:1,padding:`12px 16px`,border:`1px solid ${X.border}`,background:X.bg,textAlign:`left`},children:[(0,n.jsx)(`div`,{style:{...Ct,color:e.color??X.t1},children:e.value}),(0,n.jsx)(`div`,{style:{...$,marginTop:5},children:e.label})]},t))})}function Et({items:e=[]}){return(0,n.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:5},children:e.map((e,t)=>(0,n.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:12,padding:`9px 14px`,background:X.bg,border:`1px solid ${X.border}`,borderLeft:`3px solid ${e.color??X.t2}`,borderRadius:6},children:[(0,n.jsx)(`span`,{style:{fontSize:11,fontWeight:600,color:e.color??X.t2,background:(e.color??X.t2)+`22`,padding:`2px 8px`,borderRadius:4,fontFamily:Q,flexShrink:0},children:e.name}),(0,n.jsx)(`span`,{style:{...Ct,color:e.color??X.t1,minWidth:70,flexShrink:0},children:e.value}),(0,n.jsx)(`span`,{style:{...$,flex:1},children:e.kpiLabel})]},t))})}function Dt({items:e=[]}){return(0,n.jsx)(`div`,{style:{display:`flex`,gap:8},children:e.map((e,t)=>(0,n.jsxs)(`div`,{style:{flex:1,padding:`14px 16px`,background:X.bg,border:`1px solid ${e.color?e.color+`30`:X.border}`},children:[(0,n.jsx)(`div`,{style:{...Ct,color:e.color??X.t1},children:e.value}),(0,n.jsx)(`div`,{style:{...$,marginTop:6},children:e.label})]},t))})}var Ot={red:X.red,amber:X.amber,green:X.green};function kt({items:e=[]}){return(0,n.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:5},children:e.map((e,t)=>{let r=Ot[e.severity];return(0,n.jsxs)(`div`,{style:{display:`flex`,alignItems:`flex-start`,gap:10,padding:`10px 14px`,background:i.sf,border:`1px solid ${X.border}`},children:[(0,n.jsx)(`span`,{style:{width:7,height:7,borderRadius:`50%`,background:r,flexShrink:0,marginTop:5}}),(0,n.jsx)(`span`,{style:{...$},children:e.text})]},t)})})}function At({min:e,max:t,unit:r,dots:a=[],chips:o=[]}){let s=t-e;return(0,n.jsxs)(`div`,{children:[(0,n.jsxs)(`div`,{style:{position:`relative`,height:90,marginTop:4},children:[(0,n.jsx)(`div`,{style:{position:`absolute`,top:38,left:8,right:8,height:2,background:`rgba(255,255,255,0.08)`,borderRadius:1}}),(0,n.jsxs)(`div`,{style:{position:`absolute`,top:43,left:0,fontSize:9,color:X.t4,fontFamily:Z},children:[e,r]}),(0,n.jsxs)(`div`,{style:{position:`absolute`,top:43,right:0,fontSize:9,color:X.t4,fontFamily:Z},children:[t,r]}),a.map((t,a)=>{let o=(t.val-e)/s*100,c=t.color??i.blue,l=a%2==0;return(0,n.jsxs)(`div`,{style:{position:`absolute`,left:`${o}%`,top:0,transform:`translateX(-50%)`},children:[l&&(0,n.jsxs)(`div`,{style:{textAlign:`center`,marginBottom:2},children:[(0,n.jsx)(`div`,{style:{fontSize:9,color:c,fontFamily:Q,whiteSpace:`nowrap`},children:t.name}),(0,n.jsxs)(`div`,{style:{fontSize:9,fontWeight:700,color:c,fontFamily:Z,whiteSpace:`nowrap`},children:[t.val,r]})]}),(0,n.jsx)(`div`,{style:{width:10,height:10,borderRadius:`50%`,background:c,boxShadow:`0 0 8px ${c}70`,margin:l?`0 auto`:`26px auto 0`}}),!l&&(0,n.jsxs)(`div`,{style:{textAlign:`center`,marginTop:4},children:[(0,n.jsx)(`div`,{style:{fontSize:9,color:c,fontFamily:Q,whiteSpace:`nowrap`},children:t.name}),(0,n.jsxs)(`div`,{style:{fontSize:9,fontWeight:700,color:c,fontFamily:Z,whiteSpace:`nowrap`},children:[t.val,r]})]})]},a)})]}),o&&o.length>0&&(0,n.jsx)(wt,{chips:o})]})}function jt({leftPct:e,leftLabel:t,leftValue:r,leftColor:a,rightPct:o,rightLabel:s,rightValue:c,rightColor:l,chips:u}){let d=a??i.blue,f=l??i.cyan;return(0,n.jsxs)(`div`,{children:[(0,n.jsxs)(`div`,{style:{display:`flex`,borderRadius:6,overflow:`hidden`,height:36,marginBottom:8},children:[(0,n.jsx)(`div`,{style:{width:`${e}%`,background:d+`38`,display:`flex`,alignItems:`center`,justifyContent:`flex-end`,paddingRight:12},children:(0,n.jsx)(`span`,{style:{fontSize:12,fontWeight:700,color:d,fontFamily:Z},children:r})}),(0,n.jsx)(`div`,{style:{width:1,background:`rgba(255,255,255,0.12)`,flexShrink:0}}),(0,n.jsx)(`div`,{style:{width:`${o}%`,background:f+`2A`,display:`flex`,alignItems:`center`,paddingLeft:12},children:(0,n.jsx)(`span`,{style:{fontSize:12,fontWeight:700,color:f,fontFamily:Z},children:c})})]}),(0,n.jsxs)(`div`,{style:{display:`flex`,marginBottom:u?4:0},children:[(0,n.jsx)(`div`,{style:{width:`${e}%`},children:(0,n.jsxs)(`span`,{style:{fontSize:10,color:d,fontFamily:Q},children:[e,`% `,t]})}),(0,n.jsx)(`div`,{style:{width:`${o}%`,paddingLeft:10},children:(0,n.jsxs)(`span`,{style:{fontSize:10,color:f,fontFamily:Q},children:[o,`% `,s]})})]}),u&&u.length>0&&(0,n.jsx)(wt,{chips:u})]})}function Mt({pct:e,label:t,color:r,chips:a}){let o=r??i.blue,s=2*Math.PI*30,c=s*(1-e/100);return(0,n.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:20},children:[(0,n.jsxs)(`div`,{style:{position:`relative`,flexShrink:0,width:80,height:80},children:[(0,n.jsxs)(`svg`,{width:80,height:80,style:{transform:`rotate(-90deg)`},children:[(0,n.jsx)(`circle`,{cx:40,cy:40,r:30,fill:`none`,stroke:`rgba(255,255,255,0.07)`,strokeWidth:8}),(0,n.jsx)(`circle`,{cx:40,cy:40,r:30,fill:`none`,stroke:o,strokeWidth:8,strokeDasharray:s,strokeDashoffset:c,strokeLinecap:`round`})]}),(0,n.jsx)(`div`,{style:{position:`absolute`,top:`50%`,left:`50%`,transform:`translate(-50%, -50%)`,textAlign:`center`},children:(0,n.jsxs)(`div`,{style:{fontSize:15,fontWeight:700,color:o,fontFamily:Z},children:[e,`%`]})})]}),(0,n.jsxs)(`div`,{style:{flex:1},children:[(0,n.jsx)(`div`,{style:{...$,marginBottom:10},children:t}),a&&(0,n.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:5},children:a.map((e,t)=>(0,n.jsxs)(`div`,{style:{display:`flex`,alignItems:`baseline`,gap:8,padding:`7px 10px`,background:X.bg,border:`1px solid ${X.border}`,borderRadius:5},children:[(0,n.jsx)(`span`,{style:{...Ct,color:e.color??X.t1},children:e.value}),(0,n.jsx)(`span`,{style:{...$},children:e.label})]},t))})]})]})}var Nt={green:`#34D39918`,amber:`#FBBF2418`,red:`#F0606018`},Pt={green:`#34D399`,amber:`#FBBF24`,red:`#F06060`};function Ft({items:e=[]}){return(0,n.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:5},children:e.map((e,t)=>(0,n.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:10,padding:`8px 12px`,background:X.bg,border:`1px solid ${X.border}`,borderLeft:`3px solid ${e.color??X.t2}`,borderRadius:6},children:[(0,n.jsx)(`span`,{style:{fontSize:11,fontWeight:600,color:e.color??X.t2,background:(e.color??X.t2)+`1A`,padding:`2px 7px`,borderRadius:4,fontFamily:Q,flexShrink:0,minWidth:62,textAlign:`center`},children:e.name}),(0,n.jsx)(`div`,{style:{flex:1,height:4,background:`rgba(255,255,255,0.07)`,borderRadius:2,overflow:`hidden`},children:(0,n.jsx)(`div`,{style:{height:`100%`,width:`${e.pct}%`,background:e.color??X.t2,borderRadius:2,opacity:.75}})}),(0,n.jsx)(`span`,{style:{fontSize:13,fontWeight:700,color:e.color??X.t1,fontFamily:Z,flexShrink:0,minWidth:52,textAlign:`right`},children:e.value}),e.badge&&e.badgeSeverity&&(0,n.jsx)(`span`,{style:{fontSize:10,fontWeight:600,color:Pt[e.badgeSeverity],background:Nt[e.badgeSeverity],padding:`2px 7px`,borderRadius:4,fontFamily:Q,flexShrink:0,minWidth:72,textAlign:`center`},children:e.badge}),e.sublabel&&(0,n.jsx)(`span`,{style:{...$,flexShrink:0,minWidth:80,textAlign:`right`},children:e.sublabel})]},t))})}var It={red:X.red,amber:X.amber,green:X.green};function Lt({items:e=[]}){return(0,n.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:5},children:e.map((e,t)=>{let r=It[e.severity];return(0,n.jsxs)(`div`,{style:{display:`flex`,alignItems:`flex-start`,gap:10,padding:`9px 12px`,background:r+`0A`,border:`1px solid ${r}25`,borderLeft:`3px solid ${r}`,borderRadius:6},children:[(0,n.jsx)(`span`,{style:{width:7,height:7,borderRadius:`50%`,background:r,flexShrink:0,marginTop:5}}),(0,n.jsx)(`span`,{style:{flex:1,...$},children:e.text}),(0,n.jsx)(`span`,{style:{fontSize:10,fontWeight:600,color:r,background:r+`20`,padding:`2px 7px`,borderRadius:4,fontFamily:Q,flexShrink:0},children:e.tag}),(0,n.jsx)(`span`,{style:{...$,flexShrink:0,marginTop:1},children:e.date})]},t)})})}function Rt({columns:e=[],rows:t=[]}){return(0,n.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:5},children:[(0,n.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:10,padding:`0 12px 6px`,borderBottom:`1px solid ${X.border}`},children:[(0,n.jsx)(`div`,{style:{minWidth:64}}),e.map((e,t)=>(0,n.jsx)(`div`,{style:{flex:1,fontSize:9,fontWeight:600,color:X.t4,fontFamily:Q,textTransform:`uppercase`,letterSpacing:.6},children:e},t))]}),t.map((e,t)=>(0,n.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:10,padding:`8px 12px`,background:X.bg,border:`1px solid ${X.border}`,borderLeft:`3px solid ${e.color??X.t4}`,borderRadius:6},children:[(0,n.jsx)(`span`,{style:{fontSize:11,fontWeight:600,color:e.color??X.t2,background:(e.color??X.t4)+`1A`,padding:`2px 8px`,borderRadius:4,fontFamily:Q,flexShrink:0,minWidth:64,textAlign:`center`},children:e.label}),e.cells.map((t,r)=>(0,n.jsx)(`span`,{style:{flex:1,fontSize:13,fontWeight:700,color:e.color??X.t1,fontFamily:Z},children:t},r))]},t))]})}function zt({text:e}){return(0,n.jsxs)(`div`,{style:{marginTop:10,padding:`8px 12px`,border:`1px solid ${i.bd}`,borderLeft:`4px solid #FFAE43`,borderRadius:5,background:`linear-gradient(90deg, rgba(255, 174, 67, 0.10) -48.4%, rgba(19, 22, 27, 0.10) 83.98%), ${i.sf}`},children:[(0,n.jsx)(`span`,{style:{fontSize:14,fontWeight:500,color:i.t1,fontFamily:Q,lineHeight:`20px`,marginRight:8},children:`Takeaway`}),(0,n.jsx)(`span`,{style:{...$},children:e})]})}function Bt({block:e}){if(!e)return null;let t=(()=>{switch(e.type){case`stats`:return(0,n.jsx)(Tt,{items:e.items});case`ranked`:return(0,n.jsx)(Et,{items:e.items});case`chips`:return(0,n.jsx)(Dt,{items:e.items});case`badges`:return(0,n.jsx)(kt,{items:e.items});case`dot-strip`:return(0,n.jsx)(At,{min:e.min,max:e.max,unit:e.unit,dots:e.dots,chips:e.chips});case`proportion`:return(0,n.jsx)(jt,{leftPct:e.leftPct,leftLabel:e.leftLabel,leftValue:e.leftValue,leftColor:e.leftColor,rightPct:e.rightPct,rightLabel:e.rightLabel,rightValue:e.rightValue,rightColor:e.rightColor,chips:e.chips});case`ring`:return(0,n.jsx)(Mt,{pct:e.pct,label:e.label,color:e.color,chips:e.chips});case`scorecard-rows`:return(0,n.jsx)(Ft,{items:e.items});case`flags-list`:return(0,n.jsx)(Lt,{items:e.items});case`comparison-rows`:return(0,n.jsx)(Rt,{columns:e.columns,rows:e.rows});default:return null}})();return e.takeaway?(0,n.jsxs)(`div`,{children:[t,(0,n.jsx)(zt,{text:e.takeaway})]}):t}exports.AreaChart=A,exports.BarChart=N,exports.ChartFrame=r,exports.DonutChart=St,exports.KeyHighlights=Bt,exports.LineChart=Ce,exports.MiniBars=Ee,exports.PieChart=Ne,exports.ProcessSankey=Ue,exports.RankingSankey=We,exports.SankeySvg=Fe,exports.SeriesChart=k,exports.Trend=nt,exports.TrendChart=ct,exports.VisualizationRenderer=gt,exports.cleanupVisualizationMounts=yt,exports.hydrateVisualizationMounts=bt,exports.serializeVisualizationConfig=xt;
|
package/dist/index.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export { PieChart } from './components/pieChart/PieChart';
|
|
|
9
9
|
export { ProcessSankey, RankingSankey, SankeySvg } from './components/sankey';
|
|
10
10
|
export { SeriesChart } from './components/common/SeriesChart';
|
|
11
11
|
export { TrendChart } from './components/trendChart/TrendChart';
|
|
12
|
+
export { Trend } from './components/trend/Trend';
|
|
12
13
|
export { KeyHighlights } from './components/keyHighlights/KeyHighlights';
|
|
13
14
|
export { VisualizationRenderer } from './components/visualizationRenderer/VisualizationRenderer';
|
|
14
15
|
export type { BaseVisualizationConfig, KeyHighlightBlock, MiniBarRow, PointPair, SankeyLinkData, SankeyNodeData, VizRow } from './types';
|