import{n as e,o as t}from"./kpi-CR-RraS8.js";import{a as n}from"./button-CYVyx32W.js";var r=n(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),i=n(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]);function a(n,r,i){return n.map(n=>{let a=t(n),o=r[n.kpi_key]??null;return{target:a,actual:o,previous:i[n.kpi_key]??null,status:e(o,a)}})}function o(e){let t={green:0,yellow:0,red:0,none:0},n=0,r=0;for(let i of e)t[i.status]++,i.status!==`none`&&(r++,n+=i.status===`green`?100:i.status===`yellow`?60:20);return{score:r?Math.round(n/r):null,counts:t}}function s(e,t){return e==null||t==null||t===0?null:(e-t)/Math.abs(t)*100}function c(e){let t=s(e.actual,e.previous);return t==null?null:e.target.direction===`lower_is_better`?t<0:t>0}function l(e){let t=c(e);return e.status===`green`&&t?`On target and improving over last week.`:e.status===`green`?`On target — hold the line.`:e.status===`yellow`&&t?`Below target but trending in the right direction.`:e.status===`yellow`?`Watch — trending away from target.`:e.status===`red`&&t?`Critical, but improving. Sustain the corrective actions.`:e.status===`red`?`Immediate attention required.`:`No data reported for this week.`}function u(e){let t={red:0,yellow:1,green:2,none:3};return[...e].filter(e=>e.status!==`none`).sort((e,n)=>t[e.status]-t[n.status]).slice(0,3)}export{c as a,r as c,u as i,l as n,o,s as r,i as s,a as t};