"use strict";var e=require("@babel/runtime/helpers/toConsumableArray"),t=require("react"),i=require("prop-types"),r=require("react/jsx-runtime");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=l(e),h=l(i),c="#239FE6",n="#085EDF",s="#C208DF",u="yellow",o="#8398A5",f="#dd375e",d="#44ff44";function p(e){var i=e.schematic,l=e.containerWidth,h=e.containerHeight,p=t.useRef(),y=t.useRef();t.useEffect((function(){var e=p.current,t=e.getContext("2d"),r=y.current,l=r.clientWidth,h=r.clientHeight;e.width=l-8,e.height=h,e.style.width="".concat(l-8,"px"),e.style.height="".concat(h,"px");var g=i.filter((function(e){return["bit","stabilizer","ags","ur"].includes(e.family)})).length,b=i.filter((function(e){return["pdm","rss"].includes(e.family)})).length,x=(l-6*g)/(i.filter((function(e){return"other"===e.family})).length+2*b),m=[],w=0;a.default(i).reverse().forEach((function(e){var t=0;switch(t=["bit","stabilizer","ags","ur"].includes(e.family)?6:["pdm","rss"].includes(e.family)?2*x:x,e.family){case"bit":m.push({type:"rect",x:w,y:h/2-6,width:t,height:12,fillColor:"pdc"===e.bitType?c:n});break;case"ur":m.push({type:"rect",x:w,y:h/2-6,width:t,height:12,fillColor:d});break;case"pdm":e.hasStabilizer?m.push({type:"rect",x:w+(t/2-3),y:h/2-6,width:6,height:12,fillColor:u},{type:"rect",x:w,y:h/2-2,width:t,height:4,fillColor:s}):m.push({type:"rect",x:w,y:h/2-2,width:t,height:4,fillColor:s});break;case"rss":m.push({type:"rect",x:w,y:h/2-2,width:t,height:4,fillColor:f});break;case"stabilizer":case"ags":m.push({type:"rect",x:w,y:h/2-6,width:t,height:12,fillColor:u});break;case"other":m.push({type:"rect",x:w,y:h/2-2,width:t,height:4,fillColor:o})}w+=t})),m.forEach((function(e){t.fillStyle=e.fillColor,t.fillRect(e.x,e.y,e.width,e.height)}))}));var g={width:l?"".concat(l,"px"):"100%",height:h?"".concat(h,"px"):"100%"};return r.jsx("div",{ref:y,style:g,children:r.jsx("canvas",{ref:p})})}p.propTypes={containerWidth:h.default.number,containerHeight:h.default.number,schematic:h.default.arrayOf(h.default.shape({})).isRequired},p.defaultProps={containerWidth:null,containerHeight:null},module.exports=p;
//# sourceMappingURL=BHASchematic.js.map
