import{d as N,r as I,k as f,ai as g,o as m,M as h,O as S,a as v,J as z,U,T as b,P as F,V as O,I as x,E as X,w as D,c as E,F as j,a8 as J}from"./vue.adf17aba.js";import{T as L}from"./index.05a2d588.js";import{_ as $}from"./_plugin-vue_export-helper.c27b6911.js";import{X as P}from"./index.ad3efb29.js";const q={class:"metric-value"},A={class:"metric-pre"},G=N({name:"MCard",__name:"mCard",props:{modelValue:{},metricItems:{},color:{}},emits:["update:modelValue","change-metric"],setup(V,{emit:C}){const c=V,n=C,i=I(c.modelValue),l=(a,u)=>{n("update:modelValue",a),n("change-metric",a,u)},s=f(()=>{const a=c.metricItems.find(u=>u.value===i.value);return a||null}),d=f(()=>{const a={"border-top-color":"rgb(232, 244, 255)"};return c.color&&(a["border-top-color"]=c.color),a}),_=f(()=>{var a;return(((a=s.value)==null?void 0:a.gapVal)??-1)>0}),p=f(()=>_.value?"green":"red");return(a,u)=>{const e=g("Top"),o=g("Bottom"),t=g("el-icon"),r=g("el-card");return m(),h(r,{class:"metric-card"},{default:S(()=>{var y,M,k,B,T;return[v("div",{class:"metric-card__color",style:z(d.value)},null,4),U(L,{modelValue:i.value,"onUpdate:modelValue":u[0]||(u[0]=w=>i.value=w),options:c.metricItems,onChange:l},null,8,["modelValue","options"]),v("div",q,b((y=s.value)==null?void 0:y.metricVal),1),v("div",A,[v("span",null,b((M=s.value)==null?void 0:M.preVal)+"  ",1),F(U(t,{style:{display:"inline-block","padding-top":"2px"}},{default:S(()=>[_.value?(m(),h(e,{key:0,class:x(p.value)},null,8,["class"])):(m(),h(o,{key:1,class:x(p.value)},null,8,["class"]))]),_:1},512),[[O,(k=s.value)==null?void 0:k.gapVal]]),v("span",{class:x(p.value)},b((B=s.value)!=null&&B.gapVal?((T=s.value)==null?void 0:T.gapVal)+"%":""),3)])]}),_:1})}}});const H=$(G,[["__scopeId","data-v-08c63995"]]),K={class:"metrics-cards"},Q=N({__name:"index",props:{modelValue:{},metricItems:{}},emits:["change","update:modelValue"],setup(V,{emit:C}){const c={},n=V,i=C,l=I(n.modelValue),s=I([]),d=f(()=>{const e={};for(const o of n.metricItems)e[o.value]=o.label;return e});X(()=>{const e={};for(const o of l.value)s.value.push({metric:o.metric,color:o.color}),e[o.metric]=!0,o.color&&(c[o.color]=!0)});const _=()=>{for(const[e,o]of Object.entries(c))if(!o)return c[e]=!0,e;return""},p=e=>{P.has(c,e)&&(c[e]=!1)},a=(e,o)=>{for(const r of n.metricItems)r.value===e?r.disabled=!0:r.value===o&&(r.disabled=!1);const t=l.value.findIndex(r=>r.metric===o);t>-1&&(l.value[t].metric=e,l.value[t].label=d.value[e],i("update:modelValue",l.value),i("change",l.value))},u=e=>{const o=l.value.findIndex(t=>t.metric===e);if(o>-1){if(l.value.length<=1)return;const t=l.value[o];l.value.splice(o,1),p(t.color),i("update:modelValue",l.value),i("change",l.value)}else{if(l.value.length===3)l.value[2].metric=e,l.value[2].label=d.value[e];else{const t=_();l.value.push({metric:e,color:t,label:d.value[e]})}i("update:modelValue",l.value),i("change",l.value)}};return D(l.value,()=>{const e={};for(const o of l.value)e[o.metric]=o.color;for(const o of s.value){const t=e[o.metric];t?o.color=t:o.color=void 0}}),D(n.metricItems,()=>{const e={};for(const t of s.value)e[t.metric]=!0;let o=6-s.value.length;if(o>0){for(const t of n.metricItems)if(!e[t.value]&&(s.value.push({metric:t.value}),e[t.value]=!0,o--,o===0))break}for(const t of n.metricItems)e[t.value]?t.disabled=!0:t.disabled=!1}),(e,o)=>(m(),E("div",K,[(m(!0),E(j,null,J(s.value,t=>(m(),h(H,{modelValue:t.metric,"onUpdate:modelValue":r=>t.metric=r,"metric-items":n.metricItems,color:t.color,onChangeMetric:a,onClick:r=>u(t.metric)},null,8,["modelValue","onUpdate:modelValue","metric-items","color","onClick"]))),256))]))}});const ee=$(Q,[["__scopeId","data-v-3a3260d4"]]);export{ee as M};
