"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[1698],{67004:(A,P,g)=>{g.d(P,{Hj:()=>T,bP:()=>b,h:()=>M});var h=g(32196),c=g(46942),R=g.n(c),d=g(96540),_=g(84140),O=g(8066),x=g(40845),D=g(14578),w=g(48543);const M=40,I="#a00",S=(s,l)=>({mainGroup:(0,h.css)`
    cursor: pointer;
    font-size: 10px;
    transition: opacity 300ms;
    opacity: ${l==="inactive"?.5:1};
  `,mainCircle:(0,h.css)`
    fill: ${s.components.panel.background};
  `,filledCircle:(0,h.css)`
    fill: ${I};
  `,hoverCircle:(0,h.css)`
    opacity: 0.5;
    fill: transparent;
    stroke: ${s.colors.primary.text};
  `,text:(0,h.css)`
    fill: ${s.colors.text.primary};
    pointer-events: none;
  `,titleText:(0,h.css)`
    text-align: center;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
    background-color: ${(0,_.A)(s.colors.background.primary).setAlpha(.6).toHex8String()};
    width: 140px;
  `,statsText:(0,h.css)`
    text-align: center;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
    width: 70px;
  `,textHovering:(0,h.css)`
    width: 200px;
    & span {
      background-color: ${(0,_.A)(s.colors.background.primary).setAlpha(.8).toHex8String()};
    }
  `,clickTarget:(0,h.css)`
    fill: none;
    stroke: none;
    pointer-events: fill;
  `}),T=s=>Math.ceil(s*.075),b=(0,d.memo)(function(l){const{node:i,onMouseEnter:p,onMouseLeave:y,onClick:E,hovering:N}=l,C=(0,x.$j)(),m=S(C,N),F=N==="active",a=i.nodeRadius?.values[i.dataFrameRowIndex]||M,e=T(a);return i.x!==void 0&&i.y!==void 0?d.createElement("g",{"data-node-id":i.id,className:m.mainGroup,"aria-label":`Node: ${i.title}`},d.createElement("circle",{"data-testid":`node-circle-${i.id}`,className:i.highlighted?m.filledCircle:m.mainCircle,r:a,cx:i.x,cy:i.y}),F&&d.createElement("circle",{className:m.hoverCircle,r:a-3,cx:i.x,cy:i.y,strokeWidth:e}),d.createElement(k,{node:i}),d.createElement("g",{className:m.text,style:{pointerEvents:"none"}},d.createElement(B,{node:i,hovering:N}),d.createElement("foreignObject",{x:i.x-(F?100:70),y:i.y+a+5,width:F?"200":"140",height:"40"},d.createElement("div",{className:R()(m.titleText,F&&m.textHovering)},d.createElement("span",null,i.title),d.createElement("br",null),d.createElement("span",null,i.subTitle)))),d.createElement("rect",{"data-testid":`node-click-rect-${i.id}`,onMouseEnter:()=>{p(i.id)},onMouseLeave:()=>{y(i.id)},onClick:t=>{E(t,i)},className:m.clickTarget,x:i.x-a-5,y:i.y-a-5,width:a*2+10,height:a*2+50})):null});function B({node:s,hovering:l}){const i=(0,x.$j)(),p=S(i,l),y=l==="active";return s.x!==void 0&&s.y!==void 0?s.icon?d.createElement("foreignObject",{x:s.x-35,y:s.y-20,width:"70",height:"40"},d.createElement("div",{style:{width:70,overflow:"hidden",display:"flex",justifyContent:"center",marginTop:-4}},d.createElement(D.I,{"data-testid":`node-icon-${s.icon}`,name:s.icon,size:"xxxl"}))):d.createElement("foreignObject",{x:s.x-(y?100:35),y:s.y-15,width:y?"200":"70",height:"40"},d.createElement("div",{className:R()(p.statsText,y&&p.textHovering)},d.createElement("span",null,s.mainStat&&(0,w.Xq)(s.mainStat.config,s.mainStat.values[s.dataFrameRowIndex])),d.createElement("br",null),d.createElement("span",null,s.secondaryStat&&(0,w.Xq)(s.secondaryStat.config,s.secondaryStat.values[s.dataFrameRowIndex])))):null}function k(s){const{node:l}=s,i=l.arcSections.find(m=>m.values[l.dataFrameRowIndex]>=1),p=(0,x.$j)(),y=l.nodeRadius?.values[l.dataFrameRowIndex]||M,E=T(y);if(i)return d.createElement("circle",{fill:"none",stroke:p.visualization.getColorByName(i.config.color?.fixedColor||""),strokeWidth:E,r:y,cx:l.x,cy:l.y});const N=l.arcSections.filter(m=>m.values[l.dataFrameRowIndex]!==0);if(N.length===0)return d.createElement("circle",{fill:"none",stroke:l.color?G(l.color,l.dataFrameRowIndex,p):"gray",strokeWidth:E,r:y,cx:l.x,cy:l.y});const{elements:C}=N.reduce((m,F,a)=>{const e=F.config.color?.fixedColor||"",t=F.values[l.dataFrameRowIndex],o=d.createElement(L,{key:a,r:y,x:l.x,y:l.y,startPercent:m.percent,percent:t+m.percent>1?1-m.percent:t,color:p.visualization.getColorByName(e),strokeWidth:E});return m.elements.push(o),m.percent=m.percent+t,m},{elements:[],percent:0});return d.createElement(d.Fragment,null,C)}function L({r:s,x:l,y:i,startPercent:p,percent:y,color:E,strokeWidth:N=2}){const C=p+y,m=l+Math.sin(2*Math.PI*p)*s,F=i-Math.cos(2*Math.PI*p)*s,a=l+Math.sin(2*Math.PI*C)*s,e=i-Math.cos(2*Math.PI*C)*s,t=y>.5?"1":"0";return d.createElement("path",{fill:"none",d:`M ${m} ${F} A ${s} ${s} 0 ${t} 1 ${a} ${e}`,stroke:E,strokeWidth:N})}function G(s,l,i){return s.config.color?(0,O.Qi)(s).getCalculator(s,i)(0,s.values[l]):s.values[l]}},48543:(A,P,g)=>{g.d(P,{AG:()=>x,BJ:()=>M,BR:()=>E,CP:()=>F,K0:()=>C,Tl:()=>m,Xq:()=>L,_d:()=>y,a0:()=>O,tF:()=>D});var h=g(85404),c=g(25352),R=g(11261),d=g(24293),_=g(67004);function O(a,e,t,o=1){const n=a.x2-a.x1,r=a.y2-a.y1,u=Math.sqrt(n*n+r*r),v=(a.x2-a.x1)/u,f=(a.y2-a.y1)/u,U=o-o/10;return{x1:a.x1+v*(e+5),y1:a.y1+f*(e+5),x2:a.x2-v*(t+3+U),y2:a.y2-f*(t+3+U)}}function x(a){const e={...a,fields:a.fields.map(o=>({...o,name:o.name.toLowerCase()}))},t=new h.L(e);return{id:t.getFieldByName(c.u.id.toLowerCase()),title:t.getFieldByName(c.u.title.toLowerCase()),subTitle:t.getFieldByName(c.u.subTitle.toLowerCase()),mainStat:t.getFieldByName(c.u.mainStat.toLowerCase()),secondaryStat:t.getFieldByName(c.u.secondaryStat.toLowerCase()),arc:w(a,c.u.arc),details:w(a,c.u.detail),color:t.getFieldByName(c.u.color),icon:t.getFieldByName(c.u.icon),nodeRadius:t.getFieldByName(c.u.nodeRadius.toLowerCase()),highlighted:t.getFieldByName(c.u.highlighted.toLowerCase())}}function D(a){const e={...a,fields:a.fields.map(o=>({...o,name:o.name.toLowerCase()}))},t=new h.L(e);return{id:t.getFieldByName(c.u.id.toLowerCase()),source:t.getFieldByName(c.u.source.toLowerCase()),target:t.getFieldByName(c.u.target.toLowerCase()),mainStat:t.getFieldByName(c.u.mainStat.toLowerCase()),secondaryStat:t.getFieldByName(c.u.secondaryStat.toLowerCase()),details:w(a,c.u.detail.toLowerCase()),highlighted:t.getFieldByName(c.u.highlighted.toLowerCase()),thickness:t.getFieldByName(c.u.thickness.toLowerCase()),color:t.getFieldByName(c.u.color.toLowerCase()),strokeDasharray:t.getFieldByName(c.u.strokeDasharray.toLowerCase())}}function w(a,e){return a.fields.filter(t=>t.name.match(new RegExp("^"+e)))}function M(a,e){if(!(e||a))return{nodes:[],edges:[]};if(a){const t=x(a);if(!t.id)throw new Error("id field is required for nodes data frame.");const o={};for(let r=0;r<t.id.values.length;r++){const u=t.id.values[r];o[u]=k(u,t,r)}let n=e?I(e,D(e),o):[];for(const r of n)o[r.target].incoming++;return{nodes:Object.values(o),edges:n,legend:t.arc.map(r=>({color:r.config.color?.fixedColor??"",name:r.config.displayName||r.name}))}}else{e=e;const t={},o=D(e);for(let u=0;u<e.length;u++){const{source:v,target:f}=b(o,u);t[f.id]=t[f.id]||f,t[v.id]=t[v.id]||v,S(o.mainStat)&&(t[f.id].mainStatNumeric=(t[f.id].mainStatNumeric??0)+o.mainStat.values[u]),S(o.secondaryStat)&&(t[f.id].secondaryStatNumeric=(t[f.id].secondaryStatNumeric??0)+o.secondaryStat.values[u]),t[f.id].incoming++}let n=I(e,o,t);return{nodes:T(t,o),edges:n}}}function I(a,e,t){if(!e.id)throw new Error("id field is required for edges data frame.");return e.id.values.map((o,n)=>{const r=e.target?.values[n],u=e.source?.values[n],v=t[u],f=t[r];return{id:o,dataFrameRowIndex:n,source:u,target:r,sourceNodeRadius:v.nodeRadius?v.nodeRadius.values[v.dataFrameRowIndex]:_.h,targetNodeRadius:f.nodeRadius?f.nodeRadius.values[f.dataFrameRowIndex]:_.h,mainStat:e.mainStat?L(e.mainStat.config,e.mainStat.values[n]):"",secondaryStat:e.secondaryStat?L(e.secondaryStat.config,e.secondaryStat.values[n]):"",highlighted:e.highlighted?.values[n]||!1,thickness:e.thickness?.values[n]||1,color:e.color?.values[n],strokeDasharray:e.strokeDasharray?.values[n]}})}function S(a){return a&&a.type===R.PU.number}function T(a,e){const t=[],o=[],n=S(e.secondaryStat)?{...e.secondaryStat,values:t}:void 0,r=S(e.mainStat)?{...e.mainStat,values:o}:void 0;return Object.values(a).map((u,v)=>{if(r||n){const f={...u};return r&&(f.mainStat=r,o.push(u.mainStatNumeric),f.dataFrameRowIndex=v),n&&(f.secondaryStat=n,t.push(u.secondaryStatNumeric),f.dataFrameRowIndex=v),f}return u})}function b(a,e){const t=a.target?.values[e],o=a.source?.values[e];return{target:B(t,e),source:B(o,e)}}function B(a,e){return{id:a,title:a,subTitle:"",dataFrameRowIndex:e,incoming:0,arcSections:[],highlighted:!1}}function k(a,e,t){return{id:a,title:e.title?.values[t]||"",subTitle:e.subTitle?.values[t]||"",dataFrameRowIndex:t,incoming:0,mainStat:e.mainStat,secondaryStat:e.secondaryStat,arcSections:e.arc,color:e.color,icon:e.icon?.values[t]||"",nodeRadius:e.nodeRadius,highlighted:e.highlighted?.values[t]||!1}}function L(a,e){if(typeof e=="string")return e;{const t=a.decimals||2;return Number.isFinite(e)?e.toFixed(t)+(a.unit?" "+a.unit:""):""}}function G(a){const e=l();for(let t=0;t<a;t++)e.add(s(t));return e}function s(a){return{id:a.toString(),title:`service:${a}`,subtitle:"service",arc__success:.5,arc__errors:.5,mainstat:.1,secondarystat:2,color:.5,icon:"database",noderadius:40}}function l(){const a={[NodeGraphDataFrameFieldNames.id]:{values:[],type:FieldType.string},[NodeGraphDataFrameFieldNames.title]:{values:[],type:FieldType.string},[NodeGraphDataFrameFieldNames.subTitle]:{values:[],type:FieldType.string},[NodeGraphDataFrameFieldNames.mainStat]:{values:[],type:FieldType.number},[NodeGraphDataFrameFieldNames.secondaryStat]:{values:[],type:FieldType.number},[NodeGraphDataFrameFieldNames.arc+"success"]:{values:[],type:FieldType.number,config:{color:{mode:FieldColorModeId.Fixed,fixedColor:"green"}}},[NodeGraphDataFrameFieldNames.arc+"errors"]:{values:[],type:FieldType.number,config:{color:{mode:FieldColorModeId.Fixed,fixedColor:"red"}}},[NodeGraphDataFrameFieldNames.color]:{values:[],type:FieldType.number,config:{color:{mode:FieldColorModeId.ContinuousGrYlRd}}},[NodeGraphDataFrameFieldNames.icon]:{values:[],type:FieldType.string},[NodeGraphDataFrameFieldNames.nodeRadius]:{values:[],type:FieldType.number}};return new MutableDataFrame({name:"nodes",fields:Object.entries(a).map(([e,t])=>({...t,name:e}))})}function i(a){const e=p();for(const t of a)e.add({id:t.source+"--"+t.target,...t});return e}function p(){const a={[NodeGraphDataFrameFieldNames.id]:{values:[],type:FieldType.string},[NodeGraphDataFrameFieldNames.source]:{values:[],type:FieldType.string},[NodeGraphDataFrameFieldNames.target]:{values:[],type:FieldType.string},[NodeGraphDataFrameFieldNames.mainStat]:{values:[],type:FieldType.number},[NodeGraphDataFrameFieldNames.secondaryStat]:{values:[],type:FieldType.number}};return new MutableDataFrame({name:"edges",fields:Object.entries(a).map(([e,t])=>({...t,name:e}))})}function y(a){if(a.length===0)return{top:0,right:0,bottom:0,left:0,center:{x:0,y:0}};const e=a.reduce((n,r)=>(r.x>n.right&&(n.right=r.x),r.x<n.left&&(n.left=r.x),r.y>n.bottom&&(n.bottom=r.y),r.y<n.top&&(n.top=r.y),n),{top:1/0,right:-1/0,bottom:-1/0,left:1/0}),t=e.top+(e.bottom-e.top)/2,o=e.left+(e.right-e.left)/2;return{...e,center:{x:o,y:t}}}function E(a,e){let t=a.filter(o=>!!(o.meta?.preferredVisualisationType==="nodeGraph"||o.name==="nodes"||o.name==="edges"||o.refId==="nodes"||o.refId==="edges"||new h.L(o).getFieldByName(c.u.id)));return e&&(t=N(t,e)),t}const N=(a,e)=>a.map(t=>{if(new h.L(t).getFieldByName(c.u.source.toLowerCase())){if(e?.edges?.mainStatUnit){const n=t.fields.find(r=>r.name.toLowerCase()===c.u.mainStat);n&&(n.config={...n.config,unit:e.edges.mainStatUnit})}if(e?.edges?.secondaryStatUnit){const n=t.fields.find(r=>r.name.toLowerCase()===c.u.secondaryStat);n&&(n.config={...n.config,unit:e.edges.secondaryStatUnit})}}else{if(e?.nodes?.mainStatUnit){const n=t.fields.find(r=>r.name.toLowerCase()===c.u.mainStat);n&&(n.config={...n.config,unit:e.nodes.mainStatUnit})}if(e?.nodes?.secondaryStatUnit){const n=t.fields.find(r=>r.name.toLowerCase()===c.u.secondaryStat);n&&(n.config={...n.config,unit:e.nodes.secondaryStatUnit})}if(e?.nodes?.arcs?.length)for(const n of e.nodes.arcs){const r=t.fields.find(u=>u.name.toLowerCase()===n.field);r&&n.color&&(r.config={...r.config,color:{fixedColor:n.color,mode:d.Y.Fixed}})}}return t}),C=(a,e,t)=>{const o=e.find(n=>n.id===t);return o?[...new Set(a.filter(n=>o.source===n.id||o.target===n.id).map(n=>n.id))]:[]},m=(a,e,t)=>{const o=a.find(n=>n.id===t);if(o){const n=e.filter(r=>r.source===o.id||r.target===o.id);return[...new Set(n.flatMap(r=>a.filter(u=>r.source===u.id||r.target===u.id).map(u=>u.id)))]}return[]},F=a=>a.reduce((e,t)=>{const o=t.fields.filter(n=>n.name==="source");return t.name==="edges"||o.length?e.edges.push(t):e.nodes.push(t),e},{edges:[],nodes:[]})}}]);

//# sourceMappingURL=1698.12fe1c8caac497bd5652.js.map