import e from"@babel/runtime/helpers/defineProperty";import{useRef as t,useEffect as r,useMemo as s}from"react";import{shape as i,arrayOf as n,string as o,number as a,func as p,bool as m}from"prop-types";import u from"classnames";import{get as c,maxBy as d}from"lodash";import l from"uuid";import f from"./components/Track.js";import g from"./components/Tooltip/CursorPositioner.js";import{DEFAULT_TRACK_SETTINGS as y,SETTINGS_KEY as h}from"./constants.js";import{convertData as j}from"./utils/dataParser.js";import O from"./SettingsContext.js";import b from"./DataContext.js";import C from"./ChartsContext.js";import P from"./ParameterCharts.css.js";import{jsx as v,jsxs as x}from"react/jsx-runtime";function R(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,s)}return r}function q(t){for(var r=1;r<arguments.length;r++){var s=null!=arguments[r]?arguments[r]:{};r%2?R(Object(s),!0).forEach((function(r){e(t,r,s[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):R(Object(s)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(s,e))}))}return t}var k=function(i){var n=i.settings,o=i.onSettingsChange,a=i.settingsKey,p=i.horizontal,m=i.mapping,h=i.data,R=i.indexes,k=i.isLoading,w=i.multipleAssets,S=i.assestColors,D=n[a],K=t(new Map);r((function(){D&&D.length||o(q(q({},n),{},e({},a,[q(q({},y),{},{id:l()})])))}),[]);var T=s((function(){return c(d(D,"traces.length"),"traces.length")||1}),[D]),z=s((function(){return w?Object.keys(h).reduce((function(t,r){return q(q({},t),{},e({},r,j({data:h[r],mapping:m,indexesKeys:R.keys})))}),{}):j({data:h,mapping:m,indexesKeys:R.keys})}),[h,m,R.keys,w]);return v(O.Provider,{value:{horizontal:p,settingsKey:a,settings:n,onSettingsChange:o,maxTracesCount:T,multipleAssets:w,assestColors:S},children:v(b.Provider,{value:{mapping:m,parsedData:z,indexes:R,isLoading:k},children:v(C.Provider,{value:{chartsRef:K,onChartChange:function(e,t){K.current.set(e,t)}},children:x("div",{className:u(P.container,e({},P.horizontal,p)),children:[v(g,{}),D&&D.map((function(e,t){return v(f,{settings:n,onSettingsChange:o,id:e.id,index:t},e.id)}))]})})})})};k.propTypes={data:i({}).isRequired,mapping:n(i({name:o.isRequired,key:o.isRequired,unit:o.isRequired,unitType:o.isRequired}).isRequired).isRequired,indexes:i({key:o,name:o,min:a,max:a,unit:o,unitType:o}).isRequired,settingsKey:o,settings:i({}),onSettingsChange:p.isRequired,horizontal:m,multipleAssets:m,isLoading:m.isRequired,assestColors:n(o)},k.defaultProps={settingsKey:h,horizontal:!1,multipleAssets:!1,settings:{},assestColors:[]};export{k as default};
//# sourceMappingURL=ParameterCharts.js.map
