"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[7317],{7333:(B,h,t)=>{t.r(h),t.d(h,{plugin:()=>$});var y=t(68256),p=t(62321),r=t(74848),F=t(41811),P=t(96540),C=t(97414),N=t(63141),S=t(3241);const U=({width:s,height:n,data:e,options:o})=>{const d=(0,C.JQ)(e.timeRange),c=(0,P.useId)();if(!e||!e.series.length)return(0,r.jsx)("div",{className:"panel-empty",children:(0,r.jsx)("p",{children:"No data found in response"})});const l=(0,F.default)(S.BR);return(0,r.jsx)("div",{style:{width:s,height:n},children:(0,r.jsx)(N.F,{dataFrames:l(e.series,o),getLinks:d,panelId:c,zoomMode:o.zoomMode})})};var j=t(22803),x=t(29675),G=t(57836),f=t(54594),z=t(59748);const O=({value:s,onChange:n,context:e})=>{const o=(0,x.of)(A),d=()=>{const i={field:"",color:""};n(s?[...s,i]:[i])},c=i=>{const a=s?.slice();a.splice(i,1),n(a)},l=(i,a,m)=>{let v=s?.slice()??[];v[i][a]=m,n(v)};return(0,r.jsxs)(r.Fragment,{children:[s?.map((i,a)=>(0,r.jsxs)("div",{className:o.section,children:[(0,r.jsx)(z.O,{context:e,value:i.field??"",onChange:m=>{l(a,"field",m)},item:{settings:{filter:m=>m.name.includes("arc__")},id:`arc-field-${a}`,name:`arc-field-${a}`}}),(0,r.jsx)(G.sk,{color:i.color||"#808080",onChange:m=>{l(a,"color",m)}}),(0,r.jsx)(f.$n,{size:"sm",icon:"minus",variant:"secondary",onClick:()=>c(a),title:"Remove arc"})]},a)),(0,r.jsx)(f.$n,{size:"sm",icon:"plus",onClick:d,variant:"secondary",children:"Add arc"})]})},A=s=>({section:(0,j.css)({display:"flex",alignItems:"center",justifyContent:"space-between",gap:`0 ${s.spacing(1)}`,marginBottom:s.spacing(1)})});var g=t(63739),L=t(21288),u=t(18550);class M{getListWithDefaults(n){return n.getListAppender({name:u.m.NodeGraph,pluginId:"nodeGraph"})}hasCorrectFields(n){let e=!1,o=!1;const d=[["id",g.PU.string],["title",g.PU.string],["mainstat",g.PU.number]],c=[["id",g.PU.string],["source",g.PU.string],["target",g.PU.string]];for(const l of n)this.checkFields(d,l)&&(e=!0),this.checkFields(c,l)&&(o=!0);return e&&o}checkFields(n,e){let o=!0;for(const d of n){const[c,l]=d,i=e.fields.find(a=>a.name===c);if(!i||l!==i.type){o=!1;break}}return o}getSuggestionsForData(n){if(!n.data)return;const e=this.hasCorrectFields(n.data.series),o=n.data.series.filter(d=>d.meta&&d.meta.preferredVisualisationType==="nodeGraph");(e||o.length===2)&&this.getListWithDefaults(n).append({name:u.m.NodeGraph,score:L.nQ.Best})}}const $=new y.m(U).useFieldConfig({disableStandardOptions:Object.values(p.uo).filter(s=>s!==p.uo.Links)}).setPanelOptions((s,n)=>{s.addSelect({name:"Zoom mode",path:"zoomMode",defaultValue:"cooperative",settings:{options:[{value:"cooperative",label:"Cooperative",description:"Lets you scroll the page normally"},{value:"greedy",label:"Greedy",description:"Reacts to all zoom gestures"}]}}),s.addNestedOptions({category:["Nodes"],path:"nodes",build:e=>{e.addUnitPicker({name:"Main stat unit",path:"mainStatUnit"}),e.addUnitPicker({name:"Secondary stat unit",path:"secondaryStatUnit"}),e.addCustomEditor({name:"Arc sections",path:"arcs",id:"arcs",editor:O})}}),s.addNestedOptions({category:["Edges"],path:"edges",build:e=>{e.addUnitPicker({name:"Main stat unit",path:"mainStatUnit"}),e.addUnitPicker({name:"Secondary stat unit",path:"secondaryStatUnit"})}})}).setSuggestionsSupplier(new M)}}]);

//# sourceMappingURL=nodeGraphPanel.20cc067c44dc5255168e.js.map