"use strict";var e=require("@babel/runtime/helpers/defineProperty"),t=require("react"),r=require("prop-types"),i=require("highcharts"),s=require("highcharts-react-official"),n=require("lodash"),a=require("../../DataContext.js"),u=require("../../SettingsContext.js"),c=require("../../ChartsContext.js"),o=require("./EmptyChart.js"),l=require("./options.js"),f=require("./LineChart.css.js"),d=require("react/jsx-runtime");function p(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var h=p(e),m=p(r),x=p(i),y=p(s);function b(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,i)}return r}function g(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?b(Object(r),!0).forEach((function(t){h.default(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):b(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var j=function(e){var r=e.traceSettings,i=e.trackIndex,s=t.useContext(a),p=s.parsedData,h=s.indexes,m=t.useContext(c).onChartChange,b=t.useContext(u),j=b.maxTracesCount,q=b.multipleAssets,O=b.assestColors,v=t.useRef(),C=t.useMemo((function(){var e=l.getLineOptionsByTrack(i),t=e.yAxis;if(e.yAxis=[],q){var s=r[0];if(!s)return e;Object.keys(p).forEach((function(r){e.series.push(g(g(g({},s),{},{lineColor:O[r]},p[r]["".concat(s.collection,".").concat(s.key)]),{},{name:r})),e.yAxis.push(g(g({},t),{},{min:!s.autoScale&&s.scaleMin?n.toNumber(s.scaleMin):void 0,max:!s.autoScale&&s.scaleMax?n.toNumber(s.scaleMax):void 0}))}))}else r.forEach((function(r){e.series.push(g(g({},r),p["".concat(r.collection,".").concat(r.key)])),e.yAxis.push(g(g({},t),{},{min:!r.autoScale&&r.scaleMin?n.toNumber(r.scaleMin):void 0,max:!r.autoScale&&r.scaleMax?n.toNumber(r.scaleMax):void 0}))}));return e}),[r,p]);t.useEffect((function(){v.current&&v.current.chart.xAxis[0].setExtremes(h.min,h.max)}),[h.min,h.max]),t.useEffect((function(){v.current&&v.current.chart.setSize()}),[j]),t.useEffect((function(){m(i,v)}),[v]);var S=!C.series||!C.series.length||1===C.series.length&&!C.series[0].data;return t.useMemo((function(){return S?d.jsx(o,{}):C&&d.jsx(y.default,{highcharts:x.default,options:C,ref:v,containerProps:{className:f.container}})}),[C])};j.propTypes={traceSettings:m.default.arrayOf(m.default.shape({dashStyle:m.default.string.isRequired,id:m.default.string.isRequired,key:m.default.string,color:m.default.string,name:m.default.string,traceType:m.default.string.isRequired,unit:m.default.string,lineWidth:m.default.number.isRequired}).isRequired).isRequired,trackIndex:m.default.number.isRequired},module.exports=j;
