"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[1698],{67004:(A,B,g)=>{g.d(B,{Hj:()=>T,bP:()=>b,h:()=>M});var h=g(32196),d=g(46942),I=g.n(d),c=g(96540),w=g(84140),O=g(8066),x=g(40845),D=g(14578),_=g(48543);const M=40,L="#a00",C=(i,l)=>({mainGroup:(0,h.css)`
    cursor: pointer;
    font-size: 10px;
    transition: opacity 300ms;
    opacity: ${l==="inactive"?.5:1};
  `,mainCircle:(0,h.css)`
    fill: ${i.components.panel.background};
  `,filledCircle:(0,h.css)`
    fill: ${L};
  `,hoverCircle:(0,h.css)`
    opacity: 0.5;
    fill: transparent;
    stroke: ${i.colors.primary.text};
  `,text:(0,h.css)`
    fill: ${i.colors.text.primary};
    pointer-events: none;
  `,titleText:(0,h.css)`
    text-align: center;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
    background-color: ${(0,w.A)(i.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,w.A)(i.colors.background.primary).setAlpha(.8).toHex8String()};
    }
  `,clickTarget:(0,h.css)`
    fill: none;
    stroke: none;
    pointer-events: fill;
  `}),T=i=>Math.ceil(i*.075),b=(0,c.memo)(function(l){const{node:s,onMouseEnter:p,onMouseLeave:y,onClick:E,hovering:N}=l,S=(0,x.$j)(),m=C(S,N),F=N==="active",a=s.nodeRadius?.values[s.dataFrameRowIndex]||M,e=T(a);return s.x!==void 0&&s.y!==void 0?c.createElement("g",{"data-node-id":s.id,className:m.mainGroup,"aria-label":`Node: ${s.title}`},c.createElement("circle",{"data-testid":`node-circle-${s.id}`,className:s.highlighted?m.filledCircle:m.mainCircle,r:a,cx:s.x,cy:s.y}),F&&c.createElement("circle",{className:m.hoverCircle,r:a-3,cx:s.x,cy:s.y,strokeWidth:e}),c.createElement(k,{node:s}),c.createElement("g",{className:m.text,style:{pointerEvents:"none"}},c.createElement(P,{node:s,hovering:N}),c.createElement("foreignObject",{x:s.x-(F?100:70),y:s.y+a+5,width:F?"200":"140",height:"40"},c.createElement("div",{className:I()(m.titleText,F&&m.textHovering)},c.createElement("span",null,s.title),c.createElement("br",null),c.createElement("span",null,s.subTitle)))),c.createElement("rect",{"data-testid":`node-click-rect-${s.id}`,onMouseEnter:()=>{p(s.id)},onMouseLeave:()=>{y(s.id)},onClick:t=>{E(t,s)},className:m.clickTarget,x:s.x-a-5,y:s.y-a-5,width:a*2+10,height:a*2+50})):null});function P({node:i,hovering:l}){const s=(0,x.$j)(),p=C(s,l),y=l==="active";return i.x!==void 0&&i.y!==void 0?i.icon?c.createElement("foreignObject",{x:i.x-35,y:i.y-20,width:"70",height:"40"},c.createElement("div",{style:{width:70,overflow:"hidden",display:"flex",justifyContent:"center",marginTop:-4}},c.createElement(D.I,{"data-testid":`node-icon-${i.icon}`,name:i.icon,size:"xxxl"}))):c.createElement("foreignObject",{x:i.x-(y?100:35),y:i.y-15,width:y?"200":"70",height:"40"},c.createElement("div",{className:I()(p.statsText,y&&p.textHovering)},c.createElement("span",null,i.mainStat&&(0,_.Xq)(i.mainStat.config,i.mainStat.values[i.dataFrameRowIndex])),c.createElement("br",null),c.createElement("span",null,i.secondaryStat&&(0,_.Xq)(i.secondaryStat.config,i.secondaryStat.values[i.dataFrameRowIndex])))):null}function k(i){const{node:l}=i,s=l.arcSections.find(m=>m.values[l.dataFrameRowIndex]>=1),p=(0,x.$j)(),y=l.nodeRadius?.values[l.dataFrameRowIndex]||M,E=T(y);if(s)return c.createElement("circle",{fill:"none",stroke:p.visualization.getColorByName(s.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 c.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:S}=N.reduce((m,F,a)=>{const e=F.config.color?.fixedColor||"",t=F.values[l.dataFrameRowIndex],o=c.createElement(R,{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 c.createElement(c.Fragment,null,S)}function R({r:i,x:l,y:s,startPercent:p,percent:y,color:E,strokeWidth:N=2}){const S=p+y,m=l+Math.sin(2*Math.PI*p)*i,F=s-Math.cos(2*Math.PI*p)*i,a=l+Math.sin(2*Math.PI*S)*i,e=s-Math.cos(2*Math.PI*S)*i,t=y>.5?"1":"0";return c.createElement("path",{fill:"none",d:`M ${m} ${F} A ${i} ${i} 0 ${t} 1 ${a} ${e}`,stroke:E,strokeWidth:N})}function G(i,l,s){return i.config.color?(0,O.Qi)(i).getCalculator(i,s)(0,i.values[l]):i.values[l]}},48543:(A,B,g)=>{g.d(B,{AG:()=>x,BJ:()=>M,BR:()=>E,CP:()=>F,K0:()=>S,Tl:()=>m,Xq:()=>R,_d:()=>y,a0:()=>O,tF:()=>D});var h=g(85404),d=g(25352),I=g(11261),c=g(24293),w=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(d.u.id.toLowerCase()),title:t.getFieldByName(d.u.title.toLowerCase()),subTitle:t.getFieldByName(d.u.subTitle.toLowerCase()),mainStat:t.getFieldByName(d.u.mainStat.toLowerCase()),secondaryStat:t.getFieldByName(d.u.secondaryStat.toLowerCase()),arc:_(a,d.u.arc),details:_(a,d.u.detail),color:t.getFieldByName(d.u.color),icon:t.getFieldByName(d.u.icon),nodeRadius:t.getFieldByName(d.u.nodeRadius.toLowerCase()),highlighted:t.getFieldByName(d.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(d.u.id.toLowerCase()),source:t.getFieldByName(d.u.source.toLowerCase()),target:t.getFieldByName(d.u.target.toLowerCase()),mainStat:t.getFieldByName(d.u.mainStat.toLowerCase()),secondaryStat:t.getFieldByName(d.u.secondaryStat.toLowerCase()),details:_(a,d.u.detail.toLowerCase()),highlighted:t.getFieldByName(d.u.highlighted.toLowerCase()),thickness:t.getFieldByName(d.u.thickness.toLowerCase())}}function _(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?L(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,C(o.mainStat)&&(t[f.id].mainStatNumeric=(t[f.id].mainStatNumeric??0)+o.mainStat.values[u]),C(o.secondaryStat)&&(t[f.id].secondaryStatNumeric=(t[f.id].secondaryStatNumeric??0)+o.secondaryStat.values[u]),t[f.id].incoming++}let n=L(e,o,t);return{nodes:T(t,o),edges:n}}}function L(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]:w.h,targetNodeRadius:f.nodeRadius?f.nodeRadius.values[f.dataFrameRowIndex]:w.h,mainStat:e.mainStat?R(e.mainStat.config,e.mainStat.values[n]):"",secondaryStat:e.secondaryStat?R(e.secondaryStat.config,e.secondaryStat.values[n]):"",highlighted:e.highlighted?.values[n]||!1,thickness:e.thickness?.values[n]||1}})}function C(a){return a&&a.type===I.PU.number}function T(a,e){const t=[],o=[],n=C(e.secondaryStat)?{...e.secondaryStat,values:t}:void 0,r=C(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:P(t,e),source:P(o,e)}}function P(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 R(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(i(t));return e}function i(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 s(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(d.u.id)));return e&&(t=N(t,e)),t}const N=(a,e)=>a.map(t=>{if(new h.L(t).getFieldByName(d.u.source.toLowerCase())){if(e?.edges?.mainStatUnit){const n=t.fields.find(r=>r.name.toLowerCase()===d.u.mainStat);n&&(n.config={...n.config,unit:e.edges.mainStatUnit})}if(e?.edges?.secondaryStatUnit){const n=t.fields.find(r=>r.name.toLowerCase()===d.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()===d.u.mainStat);n&&(n.config={...n.config,unit:e.nodes.mainStatUnit})}if(e?.nodes?.secondaryStatUnit){const n=t.fields.find(r=>r.name.toLowerCase()===d.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:c.Y.Fixed}})}}return t}),S=(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.68ff1ef08e94a87836b3.js.map