define(["@grafana/data","react","jquery","@grafana/ui"],(e,t,r,a)=>(()=>{"use strict";var o={2007:e=>{e.exports=a},4846:e=>{e.exports=r},5959:e=>{e.exports=t},7781:t=>{t.exports=e}},n={};function l(e){var t=n[e];if(void 0!==t)return t.exports;var r=n[e]={exports:{}};return o[e](r,r.exports,l),r.exports}l.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return l.d(t,{a:t}),t},l.d=(e,t)=>{for(var r in t)l.o(t,r)&&!l.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},l.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),l.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};l.r(i),l.d(i,{plugin:()=>K});var u=l(7781),c=l(5959),d=l.n(c),s=l(4846),f=l.n(s),v=l(2007);const p={label:"Vertical",value:1},b={label:"Horizontal",value:2},g={label:"Acknowledged",value:1},m={label:"Severity",value:2},y={index:0,label:"Outstanding",value:void 0},O={index:1,label:"Acknowledged",value:!0},h=0,E="Cleared",P="CLEARED",x=1,C="Normal",j="NORMAL",w=2,S="Indeterm.",A="INDETERMINATE",D=3,M="Warning",R="WARNING",k=4,I="Minor",N="MINOR",G=5,B="Major",T="MAJOR",W=6,L="Critical",_="CRITICAL";function z(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function F(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},a=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(a=a.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),a.forEach(function(t){z(e,t,r[t])})}return e}const q=({value:e,onChange:t})=>d().createElement("div",null,d().createElement(v.Select,{options:[F({},g),F({},m)],value:e,onChange:e=>t(e.value)}));function H(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function J(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},a=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(a=a.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),a.forEach(function(t){H(e,t,r[t])})}return e}const V=({value:e,onChange:t})=>d().createElement("div",null,d().createElement(v.Select,{options:[J({},p),J({},b)],value:e,onChange:e=>t(e.value)})),K=new u.PanelPlugin(({options:e,data:t,width:r,height:a})=>{const{getPlotConfig:o,getPlotData:n,ref:l}=(()=>{const e=(0,c.useRef)(),t=(e,t,r)=>e===b.value?[t,r]:[r,t],r=(e,t,r,a=!1)=>{const o=((e,t)=>t.series.map(t=>{var r;return null===(r=t.fields.find(t=>t.name===e))||void 0===r?void 0:r.values.toArray()}))(e,r);let n=0;for(let e of o)if(e)for(let r of e)(r===t||a&&r)&&(n+=1);return n},a=e=>e===g.value?[[O.index,O.label],[y.index,y.label]]:[[h,E],[x,C],[w,S],[D,M],[k,I],[G,B],[W,L]];return{getPlotData:(e,a,o)=>e===g.value?((e,a)=>{const o="Acked By",n=[r(o,y.value,a),r(o,O.value,a,!0)];return[{data:[t(e,n[0],y.index)],color:v.colors[0]},{data:[t(e,n[1],O.index)],color:v.colors[4]}]})(a,o):((e,a)=>{const o="Severity",n=[r(o,P,a),r(o,j,a),r(o,A,a),r(o,R,a),r(o,N,a),r(o,T,a),r(o,_,a)];return[{data:[t(e,n[0],h)],color:"#EEE000"},{data:[t(e,n[1],x)],color:"#86B15B"},{data:[t(e,n[2],w)],color:"#990000"},{data:[t(e,n[3],D)],color:"#FCCC3B"},{data:[t(e,n[4],k)],color:"#EE901C"},{data:[t(e,n[5],G)],color:"#E3692F"},{data:[t(e,n[6],W)],color:"#DB4345"}]})(a,o),getPlotConfig:(e,t)=>{const r=b.value===t?"yaxis":"xaxis";return{series:{bars:{show:!0,barWidth:t===b.value?.5:.6,align:"center",fill:.8,lineWidth:1,horizontal:t===b.value}},[r]:{mode:"categories",tickLength:0,autoscaleMargin:.02,ticks:a(e)},grid:{borderWidth:0}}},ref:e}})();return(0,c.useEffect)(()=>{const r=n(e.alarmGroup,e.alarmDirection,t),a=o(e.alarmGroup,e.alarmDirection);f().plot(l.current,r,a)},[t,e.alarmGroup,r,a,e.alarmDirection,o,n,l]),d().createElement("div",{ref:l,style:{width:r,height:a}})}).setPanelOptions(e=>{e.addCustomEditor({id:"alarm-group",path:"alarmGroup",name:"Alarm Group",editor:q}),e.addCustomEditor({id:"alarm-direction",path:"alarmDirection",name:"Alarm Direction",editor:V})});return i})());
//# sourceMappingURL=module.js.map