@oliasoft-open-source/charts-library 5.0.8 → 5.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/dist/assets/{Color-YHDXOIA2-B_-Et0_1.js → Color-YHDXOIA2-Cf20dAz7.js} +1 -1
  2. package/dist/assets/{DocsRenderer-CFRXHY34-CBX5RMGQ.js → DocsRenderer-CFRXHY34-BLg8W1W2.js} +3 -3
  3. package/dist/assets/{bar-chart.stories-BtoqoUxl.js → bar-chart.stories-BYQyquXm.js} +1 -1
  4. package/dist/assets/{entry-preview-DWlzoP88.js → entry-preview-BZo_8q_9.js} +1 -1
  5. package/dist/assets/{get-draggableData-DpL-PCw1.js → get-draggableData-dkvBi0Bl.js} +1 -1
  6. package/dist/assets/{iframe-CwbFIHzR.js → iframe-DQBiGpMD.js} +2 -2
  7. package/dist/assets/{legend-DU0eJsZy.js → legend-Dsh-gS4D.js} +1 -1
  8. package/dist/assets/{legend-context-BD2-S1C1.js → legend-context-9xqNf4cB.js} +18 -18
  9. package/dist/assets/line-chart-r9Mg5Qcy.js +1 -0
  10. package/dist/assets/{line-chart.stories-DI9XRm8n.js → line-chart.stories-B40-dAYL.js} +1 -1
  11. package/dist/assets/{line-chart.test-case.stories-DNfY92DJ.js → line-chart.test-case.stories-DtULjl6w.js} +1 -1
  12. package/dist/assets/{pie-chart.stories-DkA8tvR7.js → pie-chart.stories-Birt17VG.js} +1 -1
  13. package/dist/assets/{preview-Dn7dWRX3.js → preview-BxIF5cTA.js} +2 -2
  14. package/dist/assets/{preview-tfNj4tfS.js → preview-C_VJ39RO.js} +1 -1
  15. package/dist/assets/{scatter-chart.stories-H8K5l3_j.js → scatter-chart.stories-BoOuwmMg.js} +1 -1
  16. package/dist/bar-chart/utils/use-bar-chart-options.d.ts +1 -1
  17. package/dist/common/helpers/chart-utils.d.ts +1 -1
  18. package/dist/iframe.html +1 -1
  19. package/dist/index.js.js +134 -104
  20. package/dist/index.js.js.map +1 -1
  21. package/dist/line-chart/hooks/use-chart-options.d.ts +2 -2
  22. package/dist/line-chart/utils/datalabels-alignment/get-alignment-data.d.ts +1 -1
  23. package/dist/line-chart/utils/get-line-chart-data-labels.d.ts +0 -3
  24. package/dist/line-chart/utils/get-line-chart-tooltips.d.ts +14 -0
  25. package/dist/project.json +1 -1
  26. package/dist/scatter-chart/hooks/use-scatter-chart-config.d.ts +1 -1
  27. package/dist/src/components/bar-chart/utils/use-bar-chart-options.d.ts +1 -1
  28. package/dist/src/components/common/helpers/chart-utils.d.ts +1 -1
  29. package/dist/src/components/line-chart/hooks/use-chart-options.d.ts +2 -2
  30. package/dist/src/components/line-chart/utils/datalabels-alignment/get-alignment-data.d.ts +1 -1
  31. package/dist/src/components/line-chart/utils/get-line-chart-tooltips.d.ts +14 -0
  32. package/dist/src/components/scatter-chart/hooks/use-scatter-chart-config.d.ts +1 -1
  33. package/package.json +1 -1
  34. package/dist/assets/line-chart-BzkMGnyJ.js +0 -1
@@ -0,0 +1 @@
1
+ import{j as x}from"./jsx-runtime-Y5Ju2SGo.js";import{r as C}from"./index-eCxJ45ll.js";import{$ as qn,a0 as Ze,a1 as J,x as V,a2 as Wn,v as N,A as F,P as ie,C as Q,a3 as Be,a4 as $n,g as Ae,N as Zn,S as Kn,y as Jn,O as Qn,a5 as oe,a6 as ae,Q as ee,a7 as ge,E as Me,R as et,T as nt,L as Ke,a as tt,U as be,V as st,W as Z,d as rt,r as lt,B as Je,a8 as it,f as ot,a9 as at,I as ut,aa as k,ab as Ue,ac as le,D as ct,ad as K,b as dt,s as ft,F as gt,ae as mt,h as bt,i as yt,J as ht,Y as pt,j as _t,k as xt,p as Tt,m as Et,n as Lt,o as Ot,q as Ct,t as St}from"./legend-context-9xqNf4cB.js";import{r as Pe,M as Ve,p as ye,B as X,s as Pt,v as Nt,w as Qe,x as Dt,y as wt,z as At,A as Mt,E as vt,N as en,G as It,S as jt,g as Ft,e as kt,F as Gt,T as pn,J as zt,K as Rt,D as Bt,O as Ut,Q as Vt,k as Xt,q as Yt,U as Ht,u as qt,j as Wt,Z as $t,t as Zt,R as Kt,m as Jt,H as Qt,L as es,n as ns,o as ts}from"./legend-Dsh-gS4D.js";import{c as ss,C as rs,f as nn,a as ls,b as is}from"./get-draggableData-dkvBi0Bl.js";import{e as _n}from"./index-B-BONL6g.js";const os="_chart_e3qdd_1",as="_canvas_e3qdd_11",us="_fixedHeight_e3qdd_20",cs="_stretchHeight_e3qdd_26",ds="_squareAspectRatio_e3qdd_32",fs="_table_e3qdd_62",Ne={chart:os,canvas:as,fixedHeight:us,stretchHeight:cs,squareAspectRatio:ds,table:fs};var xn=Symbol.for("immer-nothing"),tn=Symbol.for("immer-draftable"),M=Symbol.for("immer-state");function I(e,...n){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var ne=Object.getPrototypeOf;function te(e){return!!e&&!!e[M]}function q(e){var n;return e?Tn(e)||Array.isArray(e)||!!e[tn]||!!((n=e.constructor)!=null&&n[tn])||Oe(e)||Ce(e):!1}var gs=Object.prototype.constructor.toString();function Tn(e){if(!e||typeof e!="object")return!1;const n=ne(e);if(n===null)return!0;const t=Object.hasOwnProperty.call(n,"constructor")&&n.constructor;return t===Object?!0:typeof t=="function"&&Function.toString.call(t)===gs}function he(e,n){Le(e)===0?Reflect.ownKeys(e).forEach(t=>{n(t,e[t],e)}):e.forEach((t,r)=>n(r,t,e))}function Le(e){const n=e[M];return n?n.type_:Array.isArray(e)?1:Oe(e)?2:Ce(e)?3:0}function ve(e,n){return Le(e)===2?e.has(n):Object.prototype.hasOwnProperty.call(e,n)}function En(e,n,t){const r=Le(e);r===2?e.set(n,t):r===3?e.add(t):e[n]=t}function ms(e,n){return e===n?e!==0||1/e===1/n:e!==e&&n!==n}function Oe(e){return e instanceof Map}function Ce(e){return e instanceof Set}function H(e){return e.copy_||e.base_}function Ie(e,n){if(Oe(e))return new Map(e);if(Ce(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);const t=Tn(e);if(n===!0||n==="class_only"&&!t){const r=Object.getOwnPropertyDescriptors(e);delete r[M];let s=Reflect.ownKeys(r);for(let i=0;i<s.length;i++){const l=s[i],o=r[l];o.writable===!1&&(o.writable=!0,o.configurable=!0),(o.get||o.set)&&(r[l]={configurable:!0,writable:!0,enumerable:o.enumerable,value:e[l]})}return Object.create(ne(e),r)}else{const r=ne(e);if(r!==null&&t)return{...e};const s=Object.create(r);return Object.assign(s,e)}}function Xe(e,n=!1){return Se(e)||te(e)||!q(e)||(Le(e)>1&&(e.set=e.add=e.clear=e.delete=bs),Object.freeze(e),n&&Object.entries(e).forEach(([t,r])=>Xe(r,!0))),e}function bs(){I(2)}function Se(e){return Object.isFrozen(e)}var ys={};function W(e){const n=ys[e];return n||I(0,e),n}var ue;function Ln(){return ue}function hs(e,n){return{drafts_:[],parent_:e,immer_:n,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function sn(e,n){n&&(W("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=n)}function je(e){Fe(e),e.drafts_.forEach(ps),e.drafts_=null}function Fe(e){e===ue&&(ue=e.parent_)}function rn(e){return ue=hs(ue,e)}function ps(e){const n=e[M];n.type_===0||n.type_===1?n.revoke_():n.revoked_=!0}function ln(e,n){n.unfinalizedDrafts_=n.drafts_.length;const t=n.drafts_[0];return e!==void 0&&e!==t?(t[M].modified_&&(je(n),I(4)),q(e)&&(e=pe(n,e),n.parent_||_e(n,e)),n.patches_&&W("Patches").generateReplacementPatches_(t[M].base_,e,n.patches_,n.inversePatches_)):e=pe(n,t,[]),je(n),n.patches_&&n.patchListener_(n.patches_,n.inversePatches_),e!==xn?e:void 0}function pe(e,n,t){if(Se(n))return n;const r=n[M];if(!r)return he(n,(s,i)=>on(e,r,n,s,i,t)),n;if(r.scope_!==e)return n;if(!r.modified_)return _e(e,r.base_,!0),r.base_;if(!r.finalized_){r.finalized_=!0,r.scope_.unfinalizedDrafts_--;const s=r.copy_;let i=s,l=!1;r.type_===3&&(i=new Set(s),s.clear(),l=!0),he(i,(o,a)=>on(e,r,s,o,a,t,l)),_e(e,s,!1),t&&e.patches_&&W("Patches").generatePatches_(r,t,e.patches_,e.inversePatches_)}return r.copy_}function on(e,n,t,r,s,i,l){if(te(s)){const o=i&&n&&n.type_!==3&&!ve(n.assigned_,r)?i.concat(r):void 0,a=pe(e,s,o);if(En(t,r,a),te(a))e.canAutoFreeze_=!1;else return}else l&&t.add(s);if(q(s)&&!Se(s)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;pe(e,s),(!n||!n.scope_.parent_)&&typeof r!="symbol"&&Object.prototype.propertyIsEnumerable.call(t,r)&&_e(e,s)}}function _e(e,n,t=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Xe(n,t)}function _s(e,n){const t=Array.isArray(e),r={type_:t?1:0,scope_:n?n.scope_:Ln(),modified_:!1,finalized_:!1,assigned_:{},parent_:n,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let s=r,i=Ye;t&&(s=[r],i=ce);const{revoke:l,proxy:o}=Proxy.revocable(s,i);return r.draft_=o,r.revoke_=l,o}var Ye={get(e,n){if(n===M)return e;const t=H(e);if(!ve(t,n))return xs(e,t,n);const r=t[n];return e.finalized_||!q(r)?r:r===De(e.base_,n)?(we(e),e.copy_[n]=Ge(r,e)):r},has(e,n){return n in H(e)},ownKeys(e){return Reflect.ownKeys(H(e))},set(e,n,t){const r=On(H(e),n);if(r!=null&&r.set)return r.set.call(e.draft_,t),!0;if(!e.modified_){const s=De(H(e),n),i=s==null?void 0:s[M];if(i&&i.base_===t)return e.copy_[n]=t,e.assigned_[n]=!1,!0;if(ms(t,s)&&(t!==void 0||ve(e.base_,n)))return!0;we(e),ke(e)}return e.copy_[n]===t&&(t!==void 0||n in e.copy_)||Number.isNaN(t)&&Number.isNaN(e.copy_[n])||(e.copy_[n]=t,e.assigned_[n]=!0),!0},deleteProperty(e,n){return De(e.base_,n)!==void 0||n in e.base_?(e.assigned_[n]=!1,we(e),ke(e)):delete e.assigned_[n],e.copy_&&delete e.copy_[n],!0},getOwnPropertyDescriptor(e,n){const t=H(e),r=Reflect.getOwnPropertyDescriptor(t,n);return r&&{writable:!0,configurable:e.type_!==1||n!=="length",enumerable:r.enumerable,value:t[n]}},defineProperty(){I(11)},getPrototypeOf(e){return ne(e.base_)},setPrototypeOf(){I(12)}},ce={};he(Ye,(e,n)=>{ce[e]=function(){return arguments[0]=arguments[0][0],n.apply(this,arguments)}});ce.deleteProperty=function(e,n){return ce.set.call(this,e,n,void 0)};ce.set=function(e,n,t){return Ye.set.call(this,e[0],n,t,e[0])};function De(e,n){const t=e[M];return(t?H(t):e)[n]}function xs(e,n,t){var s;const r=On(n,t);return r?"value"in r?r.value:(s=r.get)==null?void 0:s.call(e.draft_):void 0}function On(e,n){if(!(n in e))return;let t=ne(e);for(;t;){const r=Object.getOwnPropertyDescriptor(t,n);if(r)return r;t=ne(t)}}function ke(e){e.modified_||(e.modified_=!0,e.parent_&&ke(e.parent_))}function we(e){e.copy_||(e.copy_=Ie(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var Ts=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(n,t,r)=>{if(typeof n=="function"&&typeof t!="function"){const i=t;t=n;const l=this;return function(a=i,...c){return l.produce(a,u=>t.call(this,u,...c))}}typeof t!="function"&&I(6),r!==void 0&&typeof r!="function"&&I(7);let s;if(q(n)){const i=rn(this),l=Ge(n,void 0);let o=!0;try{s=t(l),o=!1}finally{o?je(i):Fe(i)}return sn(i,r),ln(s,i)}else if(!n||typeof n!="object"){if(s=t(n),s===void 0&&(s=n),s===xn&&(s=void 0),this.autoFreeze_&&Xe(s,!0),r){const i=[],l=[];W("Patches").generateReplacementPatches_(n,s,i,l),r(i,l)}return s}else I(1,n)},this.produceWithPatches=(n,t)=>{if(typeof n=="function")return(l,...o)=>this.produceWithPatches(l,a=>n(a,...o));let r,s;return[this.produce(n,t,(l,o)=>{r=l,s=o}),r,s]},typeof(e==null?void 0:e.autoFreeze)=="boolean"&&this.setAutoFreeze(e.autoFreeze),typeof(e==null?void 0:e.useStrictShallowCopy)=="boolean"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){q(e)||I(8),te(e)&&(e=Es(e));const n=rn(this),t=Ge(e,void 0);return t[M].isManual_=!0,Fe(n),t}finishDraft(e,n){const t=e&&e[M];(!t||!t.isManual_)&&I(9);const{scope_:r}=t;return sn(r,n),ln(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,n){let t;for(t=n.length-1;t>=0;t--){const s=n[t];if(s.path.length===0&&s.op==="replace"){e=s.value;break}}t>-1&&(n=n.slice(t+1));const r=W("Patches").applyPatches_;return te(e)?r(e,n):this.produce(e,s=>r(s,n))}};function Ge(e,n){const t=Oe(e)?W("MapSet").proxyMap_(e,n):Ce(e)?W("MapSet").proxySet_(e,n):_s(e,n);return(n?n.scope_:Ln()).drafts_.push(t),t}function Es(e){return te(e)||I(10,e),Cn(e)}function Cn(e){if(!q(e)||Se(e))return e;const n=e[M];let t;if(n){if(!n.modified_)return n.base_;n.finalized_=!0,t=Ie(e,n.scope_.immer_.useStrictShallowCopy_)}else t=Ie(e,!0);return he(t,(r,s)=>{En(t,r,Cn(s))}),n&&(n.finalized_=!1),t}var v=new Ts,Ls=v.produce;v.produceWithPatches.bind(v);v.setAutoFreeze.bind(v);v.setUseStrictShallowCopy.bind(v);v.applyPatches.bind(v);v.createDraft.bind(v);v.finishDraft.bind(v);const Sn="TOGGLE_ZOOM",Pn="TOGGLE_PAN",Nn="TOGGLE_POINTS",Dn="TOGGLE_LINE",wn="TOGGLE_LEGEND",An="TOGGLE_TABLE",ze="RESET_AXES_RANGES",xe="UPDATE_AXES_RANGES",Mn="TOGGLE_DRAG_POINTS",vn="TOGGLE_DRAG_ANNOTATION",In="DISABLE_DRAG_OPTIONS",me="UPDATE_EDITED",Os=(e,n)=>Ls(e,t=>{switch(n.type){case Sn:{t.zoomEnabled=!t.zoomEnabled,t.panEnabled&&(t.panEnabled=!1),t.enableDragPoints&&(t.enableDragPoints=!1),t.enableDragAnnotation&&(t.enableDragAnnotation=!1);break}case Pn:{t.panEnabled=!t.panEnabled,t.zoomEnabled&&(t.zoomEnabled=!1),t.enableDragPoints&&(t.enableDragPoints=!1),t.enableDragAnnotation&&(t.enableDragAnnotation=!1);break}case Nn:{t.pointsEnabled=!t.pointsEnabled;break}case Dn:{t.lineEnabled=!t.lineEnabled;break}case wn:{t.legendEnabled=!t.legendEnabled;break}case An:{t.showTable=!t.showTable;break}case xe:{const{axes:r}=n.payload;t.axes=r;break}case ze:{const{axes:r}=n.payload;t.axes=r;break}case Mn:{t.enableDragPoints=!t.enableDragPoints,t.panEnabled&&(t.panEnabled=!1),t.zoomEnabled&&(t.zoomEnabled=!1),t.enableDragAnnotation&&(t.enableDragAnnotation=!1);break}case vn:{t.enableDragAnnotation=!t.enableDragAnnotation,t.panEnabled&&(t.panEnabled=!1),t.zoomEnabled&&(t.zoomEnabled=!1);break}case In:{(t.enableDragAnnotation||t.enableDragPoints||t.panEnabled||t.zoomEnabled)&&(t.enableDragAnnotation=!1,t.enableDragPoints=!1,t.panEnabled=!1,t.zoomEnabled=!1);break}case me:{t.edited=n.payload;break}}}),Cs=e=>{if(!e)return null;const n=`line-chart-state-${e}`,t=localStorage.getItem(n);return t?JSON.parse(t).state:null},Ss=(e=72)=>{const n=new Date().getTime(),t=e*60*60*1e3;for(let r=0;r<localStorage.length;r++){const s=localStorage.key(r);if(s!=null&&s.includes("line-chart-state-")){const i=localStorage.getItem(s);if(i){const o=JSON.parse(i).timestamp;o&&n-o>t&&localStorage.removeItem(s)}}}},Ps=(e,n)=>{if(!n)return;const t=new Date().getTime(),r=`line-chart-state-${n}`,s={state:e,timestamp:t};localStorage.setItem(r,JSON.stringify(s)),Ss()},Ns=({options:e,persistenceId:n})=>{const{chartOptions:{enableZoom:t,enablePan:r,showPoints:s,showLine:i,enableDragAnnotation:l},legend:{display:o},dragData:a}=e,{zoomEnabled:c,panEnabled:u,pointsEnabled:d,lineEnabled:y,legendEnabled:m,enableDragPoints:h,enableDragAnnotation:b}=Cs(n)||{};return{zoomEnabled:l??b?!1:c??t,panEnabled:u??r,pointsEnabled:d??s,lineEnabled:y??i,legendEnabled:m??o,axes:[],showTable:!1,enableDragPoints:(a==null?void 0:a.enableDragData)&&h,enableDragAnnotation:l??b,edited:!1}},Ds=e=>C.createElement("svg",{fill:"currentColor",height:"1em",viewBox:"0 0 12 12",width:"1em",xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",...e},C.createElement("clipPath",{id:"a"},C.createElement("path",{d:"m0 0h12v12h-12z"})),C.createElement("g",{clipPath:"url(#a)"},C.createElement("path",{d:"m.5 6.5v-1h11v1c-4.16104 0-6.63549 0-11 0z"}))),ws=e=>C.createElement("svg",{fill:"currentColor",height:"1em",viewBox:"0 0 12 12",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e},C.createElement("circle",{cx:6,cy:6,r:2})),As=e=>C.createElement("svg",{fill:"currentColor",height:"1em",viewBox:"0 0 12 12",width:"1em",xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",...e},C.createElement("clipPath",{id:"a"},C.createElement("path",{d:"m0 0h12v12h-12z"})),C.createElement("g",{clipPath:"url(#a)"},C.createElement("path",{d:"m7.937 6.5c-.11122.42912-.36179.80916-.71237 1.08047-.35058.2713-.78133.4185-1.22463.4185s-.87405-.1472-1.22463-.4185c-.35058-.27131-.60115-.65135-.71237-1.08047h-3.563v-1h3.563c.11122-.42912.36179-.80916.71237-1.08046s.78133-.41851 1.22463-.41851.87405.14721 1.22463.41851.60115.65134.71237 1.08046h3.563v1z"})));function Ms({lineEnabled:e,onToggleLine:n,onTogglePoints:t,pointsEnabled:r,translations:s}){return[{type:"Option",label:s.pointsLines,icon:x.jsx(Pe,{icon:x.jsx(As,{})}),selected:r&&e,onClick:()=>{r||t(),e||n()}},{type:"Option",label:s.linesOnly,icon:x.jsx(Pe,{icon:x.jsx(Ds,{})}),selected:!r&&e,onClick:()=>{r&&t(),e||n()}},{type:"Option",label:s.pointsOnly,icon:x.jsx(Pe,{icon:x.jsx(ws,{})}),selected:r&&!e,onClick:()=>{r||t(),e&&n()}}]}const jn=({options:e})=>{const[n,t]=C.useState(!1),r=e.find(s=>s.selected);return x.jsx(Ve,{open:n,setOpen:t,menu:{sections:e,trigger:"Component",component:x.jsx(ye,{display:"inline-flex",text:r==null?void 0:r.label,placement:"bottom-start",enabled:!n,children:x.jsx(X,{colored:"muted",basic:!0,small:!0,round:!0,icon:r==null?void 0:r.icon})})}})};jn.__docgenInfo={description:"",methods:[],displayName:"LineOptions",props:{options:{required:!0,tsType:{name:"Array",elements:[{name:"IMenuSection"}],raw:"IMenuSection[]"},description:""}}};function vs({onTogglePan:e,onToggleZoom:n,panEnabled:t,zoomEnabled:r,enableDragPoints:s,enableDragAnnotation:i,isDragDataAllowed:l,isDragAnnotationAllowed:o,onToggleDragAnnotation:a,onToggleDragPoints:c,onDisableDragOptions:u,translations:{dragToZoom:d,doubleClickToReset:y,dragToPan:m,dragToMovePoints:h,dragDisabled:b,dragToMoveAnnotation:_}}){return[{label:d,description:y,icon:x.jsx(Pt,{}),selected:r,type:"Option",onClick:()=>{r||n()}},{label:m,description:y,icon:x.jsx(Nt,{}),selected:t,type:"Option",onClick:()=>{t||e()}},...l?[{label:h,icon:x.jsx(Qe,{}),selected:s,type:"Option",onClick:()=>{s||c()}}]:[],...o?[{label:_,icon:x.jsx(Qe,{}),selected:i,type:"Option",onClick:()=>{i||a()}}]:[],{label:b,icon:x.jsx(Dt,{}),selected:!r&&!t&&!s&&!i,type:"Option",onClick:u}]}const Fn=({options:e})=>{const n=e.find(t=>t.selected);return x.jsx(Ve,{menu:{sections:e,trigger:"Component",component:x.jsx(X,{colored:"muted",basic:!0,small:!0,label:n==null?void 0:n.label,icon:n==null?void 0:n.icon})}})};Fn.__docgenInfo={description:"@param {import('./drag-options-interfaces').IDragOptions} obj",methods:[],displayName:"DragOptions",props:{options:{required:!0,tsType:{name:"Array",elements:[{name:"IMenuSection"}],raw:"IMenuSection[]"},description:""}}};const Is="_controls_1edjs_1",js="_buttons_1edjs_6",an={controls:Is,buttons:js},Fs=e=>{const n=C.useCallback(t=>()=>{e({type:t})},[e]);return{onToggleLegend:n(wn),onToggleLine:n(Dn),onTogglePan:n(Pn),onTogglePoints:n(Nn),onToggleTable:n(An),onToggleZoom:n(Sn),onToggleDragPoints:n(Mn),onToggleDragAnnotation:n(vn),onDisableDragOptions:n(In)}},ks=(e,n)=>e===void 0||n===void 0||Number(e)<Number(n),Gs=(e,n)=>e===void 0||n===void 0||Number(e)>Number(n),kn=(e,n=0,t=!1)=>{const r=t&&n!==0?n+1:"";return`${e}${r}`},zs=e=>{var n;return((n=e==null?void 0:e.match(/[^0-9/]+/gi))==null?void 0:n[0])??""},Rs=e=>e.join(""),Hr=e=>typeof e=="string"||typeof e=="number"||typeof e=="boolean"||e===null,Bs=e=>e?Object.values(e).some(n=>!qn(n)):!1,He=({chartRef:e,state:n,options:t,dispatch:r,generatedDatasets:s})=>{const{interactions:{onHover:i,onUnhover:l},axes:o}=t,a=C.useCallback(()=>{var T,g;const f=e==null?void 0:e.current;f&&(n!=null&&n.edited)&&((T=f==null?void 0:f.resetZoom)==null||T.call(f),(g=f==null?void 0:f.reset)==null||g.call(f),r({type:ze,payload:{axes:[]}}),r({type:me,payload:!1}))},[e==null?void 0:e.current,r,n]),c=C.useCallback((f,T,g)=>(p,L)=>{var O,S;if(!(L!=null&&L.length)&&l&&f&&(T(null),l(p),(O=e==null?void 0:e.current)==null||O.update()),L!=null&&L.length&&i){const{index:P,datasetIndex:D}=L[0],A=g[D],w=A==null?void 0:A.data[P];w&&!_n(f,w)&&(T(w),i(p,D,P,g),(S=e==null?void 0:e.current)==null||S.update())}},[i,l,s]),u=C.useCallback(()=>ss(e),[e==null?void 0:e.current]),d=C.useCallback(f=>{var T,g,p,L,O;if(f.key===Ze.Shift){const S=e.current,P=(p=(g=(T=S==null?void 0:S.config)==null?void 0:T.options)==null?void 0:g.plugins)==null?void 0:p.zoom;(L=P==null?void 0:P.zoom)!=null&&L.mode&&((O=P==null?void 0:P.pan)!=null&&O.mode)&&(P.zoom.mode=J.Y,P.pan.mode=J.Y,S==null||S.update())}},[e==null?void 0:e.current]),y=C.useCallback(f=>{var T,g,p,L,O;if(f.key===Ze.Shift){const S=e.current,P=(p=(g=(T=S==null?void 0:S.config)==null?void 0:T.options)==null?void 0:g.plugins)==null?void 0:p.zoom;(L=P==null?void 0:P.zoom)!=null&&L.mode&&((O=P==null?void 0:P.pan)!=null&&O.mode)&&(P.zoom.mode=J.XY,P.pan.mode=J.XY,S==null||S.update())}},[e==null?void 0:e.current]),m=C.useCallback(f=>{var g;if(!((g=Object.keys(f))!=null&&g.length))return[];const T=(p,L)=>{var O;return!p[L]||!((O=p[L])!=null&&O.length)?[]:p[L].map((S,P)=>({id:kn(L,P,p[L].length>1),label:(S==null?void 0:S.label)||""}))};return[...T(f,V.X),...T(f,V.Y)]},[o]),h=C.useCallback(()=>{var g;const{scales:f={}}=(e==null?void 0:e.current)||{},T=(g=Object.entries(f))==null?void 0:g.map(([p,{min:L,max:O}])=>({id:p,min:L??0,max:O??0}));r({type:xe,payload:{axes:T}})},[o]),b=C.useCallback(()=>{var T,g;const f=e==null?void 0:e.current;f&&n.edited&&((T=f==null?void 0:f.resetZoom)==null||T.call(f),(g=f==null?void 0:f.reset)==null||g.call(f),r({type:ze,payload:{axes:[]}}),r({type:me,payload:!1}))},[e==null?void 0:e.current]),_=C.useCallback(({axes:f})=>{r({type:xe,payload:{axes:f}})},[]),E=C.useCallback(f=>{r({type:me,payload:f})},[n]);return{resetZoom:a,onHover:c,handleDownload:u,handleKeyDown:d,handleKeyUp:y,controlsAxesLabels:m(o),updateAxesRangesFromChart:h,onResetAxes:b,onUpdateAxes:_,onUpdateEdited:E}},un=(e,n,t)=>{const r=[];return Wn(e)&&r.push("mustHaveAValue"),t==="min"&&!ks(e,n)?r.push("mustBeLessThanMax"):t==="max"&&!Gs(e,n)&&r.push("mustBeGreaterThanMin"),r},Us=e=>{const n=e.map(({id:r,min:s,max:i})=>({id:r,min:un(String(s),String(i),"min"),max:un(String(i),String(s),"max")})),t=n.every(r=>r.min.length===0&&r.max.length===0);return{errors:n,valid:t}},cn=1,dn=({chartRef:e,state:n})=>{const t=e==null?void 0:e.current;if(!t)return[];const r=(t==null?void 0:t.getInitialScaleBounds())??{};return Object.entries(r).map(([s,{min:i="",max:l=""}])=>{var u;let o=Number(i),a=Number(l);isNaN(o)&&(o=0),isNaN(a)&&(a=o+cn),o===a&&(a+=cn);const{unit:c}=((u=n==null?void 0:n.axes)==null?void 0:u.find(d=>d.id===s))??{};return{id:s,min:o,max:a,unit:c}})},Vs=e=>{var T;const{state:n,controlsAxesLabels:t,onUpdateAxes:r,onResetAxes:s,onUpdateEdited:i,depthType:l,translations:o,close:a,chartRef:c}=e??{},[u,d]=C.useState({localAxes:dn({chartRef:c,state:n}),depthType:l==null?void 0:l.selectedDepthType,edited:n.edited}),{errors:y,valid:m}=Us(u.localAxes),h=({name:g,value:p,id:L})=>{d(O=>({...O,localAxes:O.localAxes.map(S=>S.id===L?{...S,[g]:p}:S),edited:!0}))},b=({name:g,value:p,id:L})=>{d(O=>({...O,localAxes:O.localAxes.map(S=>S.id===L&&typeof S.unit=="object"?{...S,unit:{...S.unit,[g]:p}}:S),edited:!0}))},_=g=>{g.preventDefault(),m&&(r({axes:u.localAxes}),a==null||a()),l&&(l!=null&&l.setSelectedDepthType)&&(l==null||l.setSelectedDepthType(u.depthType)),i(u.edited)},E=()=>{d({localAxes:dn({chartRef:c,state:n}),depthType:l==null?void 0:l.selectedDepthType,edited:!1}),s(),i(!1),a==null||a()},f=g=>g.target.select();return x.jsxs("form",{onSubmit:_,children:[u.localAxes.map(g=>{var S,P;const p=t.find(D=>D.id===g.id),L=(p==null?void 0:p.label)||N.startCase(g.id),O=y.find(D=>D.id===g.id);return x.jsx(Mt,{label:L,children:x.jsxs(vt,{small:!0,width:"300px",children:[x.jsx(en,{name:"min",value:g.min,error:(S=O==null?void 0:O.min)!=null&&S[0]?o[O.min[0]]:null,width:"100%",onChange:D=>h({name:D.target.name,value:D.target.value,id:g.id}),onFocus:f}),x.jsx(It,{children:"to"}),x.jsx(en,{name:"max",value:g.max,error:(P=O==null?void 0:O.max)!=null&&P[0]?o[O.max[0]]:null,width:"100%",onChange:D=>h({name:D.target.name,value:D.target.value,id:g.id}),onFocus:f}),g.unit?x.jsx(jt,{name:"selectedUnit",options:typeof g.unit!="string"?g.unit.options:[],value:typeof g.unit!="string"?g.unit.selectedUnit:void 0,onChange:D=>b({name:D.target.name,value:D.target.value,id:g.id}),autoLayerWidth:!0,width:"15%"}):null]})},g.id)}),((T=l==null?void 0:l.options)==null?void 0:T.length)>0&&x.jsxs(x.Fragment,{children:[x.jsx(Ft,{items:l.options.map((g,p)=>({key:p,label:g})),onSelected:g=>{d(p=>({...p,depthType:l.options[g],edited:!0}))},small:!0,value:l.options.indexOf(u.depthType)}),x.jsx(kt,{})]}),x.jsxs(Gt,{gap:"8px",alignItems:"center",children:[x.jsx(X,{type:"submit",small:!0,colored:!0,label:o.done,disabled:!m||!u.edited}),x.jsx(X,{small:!0,name:"resetAxes",label:o.resetAxes,onClick:E}),x.jsx(pn,{small:!0,muted:!0,children:o.orDoubleClickToCanvas})]})]})},Gn=e=>x.jsx(wt,{placement:"bottom-start",overflowContainer:!0,content:x.jsx(Vs,{...e}),children:x.jsx(ye,{text:e.translations.axesOptions,placement:"bottom-start",display:"inline-flex",children:x.jsx(X,{small:!0,basic:!0,colored:"muted",round:!0,icon:x.jsx(At,{})})})});Gn.__docgenInfo={description:"",methods:[],displayName:"AxesOptions",props:{chartRef:{required:!0,tsType:{name:"RefObject",elements:[{name:"Chart"}],raw:"RefObject<Chart>"},description:""},state:{required:!0,tsType:{name:"IState"},description:""},controlsAxesLabels:{required:!0,tsType:{name:"Array",elements:[{name:"IAxisControlLabel"}],raw:"IAxisControlLabel[]"},description:""},onUpdateAxes:{required:!0,tsType:{name:"signature",type:"function",raw:"({ axes }: { axes: IAxisState }) => void",signature:{arguments:[{type:{name:"signature",type:"object",raw:"{ axes: IAxisState }",signature:{properties:[{key:"axes",value:{name:"IAxisState",required:!0}}]}},name:""}],return:{name:"void"}}},description:""},onResetAxes:{required:!0,tsType:{name:"signature",type:"function",raw:"() => void",signature:{arguments:[],return:{name:"void"}}},description:""},onUpdateEdited:{required:!0,tsType:{name:"signature",type:"function",raw:"(edited: boolean) => void",signature:{arguments:[{type:{name:"boolean"},name:"edited"}],return:{name:"void"}}},description:""},depthType:{required:!1,tsType:{name:"union",raw:"IDepthType | object",elements:[{name:"IDepthType"},{name:"object"}]},description:""},close:{required:!1,tsType:{name:"signature",type:"function",raw:"() => void",signature:{arguments:[],return:{name:"void"}}},description:""},translations:{required:!0,tsType:{name:"Record",elements:[{name:"string"},{name:"string"}],raw:"Record<string, string>"},description:""}}};const zn=({table:e,headerComponent:n,subheaderComponent:t,chartRef:r,state:s,options:i,dispatch:l,generatedDatasets:o,translations:a,controlsPortalId:c})=>{const{enableDragPoints:u,lineEnabled:d,panEnabled:y,pointsEnabled:m,showTable:h,zoomEnabled:b,enableDragAnnotation:_}=s,{dragData:E,depthType:f,annotations:T}=i,{onToggleLine:g,onTogglePan:p,onTogglePoints:L,onToggleTable:O,onToggleZoom:S,onToggleDragPoints:P,onToggleDragAnnotation:D,onDisableDragOptions:A}=Fs(l),{handleDownload:w,controlsAxesLabels:$,onResetAxes:G,onUpdateAxes:se,onUpdateEdited:z}=He({chartRef:r,state:s,options:i,dispatch:l,generatedDatasets:o}),[R,{width:re}]=zt(),Y=re<200,B=C.useMemo(()=>Ms({lineEnabled:d,onToggleLine:g,onTogglePoints:L,pointsEnabled:m,translations:a}),[d,m]),U=C.useMemo(()=>vs({onTogglePan:p,onToggleZoom:S,panEnabled:y,zoomEnabled:b,enableDragPoints:u,enableDragAnnotation:_,isDragDataAllowed:E==null?void 0:E.enableDragData,isDragAnnotationAllowed:T==null?void 0:T.enableDragAnnotation,onToggleDragAnnotation:D,onToggleDragPoints:P,onDisableDragOptions:A,translations:a}),[b,y,u,E==null?void 0:E.enableDragData,T==null?void 0:T.enableDragAnnotation]);return x.jsxs(x.Fragment,{children:[x.jsxs("div",{className:an.controls,children:[!!i.title&&x.jsx(pn,{bold:!0,children:i.title}),n,x.jsx(rs,{controlsPortalId:c??"",children:x.jsxs("div",{className:an.buttons,ref:R,children:[!h&&x.jsxs(x.Fragment,{children:[x.jsx(Gn,{chartRef:r,state:s,controlsAxesLabels:$,onUpdateAxes:se,onResetAxes:G,onUpdateEdited:z,depthType:f,translations:a}),Y?x.jsx(Ve,{menu:{placement:"bottom-end",sections:[...B,{type:"Divider"},...U,{type:"Divider"},{icon:"download",label:a.downloadAsPNG,type:"Option",onClick:w}],trigger:"Component",component:x.jsx(X,{colored:"muted",basic:!0,small:!0,round:!0,icon:"menu"})}}):x.jsxs(x.Fragment,{children:[x.jsx(jn,{options:B}),x.jsx(ye,{display:"inline-flex",text:a.downloadAsPNG,placement:"bottom-end",children:x.jsx(X,{small:!0,basic:!0,colored:"muted",round:!0,icon:"download",onClick:w})}),x.jsx(Fn,{options:U})]})]}),e?x.jsx(ye,{display:"inline-flex",text:h?a.showChart:a.showTable,placement:"bottom-end",children:x.jsx(X,{small:!0,basic:!0,colored:"muted",round:!0,icon:h?"chart":"table",onClick:O})}):null]})})]}),t]})};zn.__docgenInfo={description:"",methods:[],displayName:"Controls",props:{headerComponent:{required:!1,tsType:{name:"ReactNode"},description:""},subheaderComponent:{required:!1,tsType:{name:"ReactNode"},description:""},table:{required:!1,tsType:{name:"ReactNode"},description:""},chartRef:{required:!0,tsType:{name:"RefObject",elements:[{name:"Chart"}],raw:"RefObject<Chart>"},description:""},state:{required:!0,tsType:{name:"IState"},description:""},options:{required:!0,tsType:{name:"ILineChartOptions"},description:""},dispatch:{required:!0,tsType:{name:"Dispatch",elements:[{name:"any"}],raw:"Dispatch<any>"},description:""},generatedDatasets:{required:!0,tsType:{name:"Array",elements:[{name:"IGeneratedLineChartDataset"}],raw:"IGeneratedLineChartDataset[]"},description:""},translations:{required:!0,tsType:{name:"Record",elements:[{name:"string"},{name:"string"}],raw:"Record<string, string>"},description:""},controlsPortalId:{required:!1,tsType:{name:"string"},description:""}}};const j={TOP_LEFT:"top-left",TOP_CENTER:"top-center",TOP_RIGHT:"top-right",MIDDLE_LEFT:"middle-left",MIDDLE_CENTER:"middle-center",MIDDLE_RIGHT:"middle-right",BOTTOM_LEFT:"bottom-left",BOTTOM_CENTER:"bottom-center",BOTTOM_RIGHT:"bottom-right"},fn=e=>({label:"",position:e,color:"",unit:{options:[],selectedUnit:"",setSelectedUnit:()=>{}}}),Xs=e=>({x:(e==null?void 0:e.x)||[fn("bottom")],y:(e==null?void 0:e.y)||[fn("left")]}),Ys=e=>({chartScaleType:(e==null?void 0:e.chartScaleType)||"linear",reverse:(e==null?void 0:e.reverse)||!1,beginAtZero:(e==null?void 0:e.beginAtZero)??!1,stepSize:e==null?void 0:e.stepSize,suggestedMin:e==null?void 0:e.suggestedMin,suggestedMax:e==null?void 0:e.suggestedMax,range:e==null?void 0:e.range,autoAxisPadding:(e==null?void 0:e.autoAxisPadding)??!1}),Hs=e=>({width:e==null?void 0:e.width,height:e==null?void 0:e.height,maintainAspectRatio:(e==null?void 0:e.maintainAspectRatio)??!1,staticChartHeight:(e==null?void 0:e.staticChartHeight)??!1,performanceMode:(e==null?void 0:e.performanceMode)??!0,squareAspectRatio:(e==null?void 0:e.squareAspectRatio)??!1,layoutPadding:(e==null?void 0:e.layoutPadding)||{top:0,bottom:20,left:0,right:0}}),qs=e=>({tooltips:(e==null?void 0:e.tooltips)??!0,showLabelsInTooltips:(e==null?void 0:e.showLabelsInTooltips)??!1,hideSimulationName:(e==null?void 0:e.hideSimulationName)??!1,scientificNotation:(e==null?void 0:e.scientificNotation)??!0}),Ws=e=>({lineTension:(e==null?void 0:e.lineTension)??.01,spanGaps:(e==null?void 0:e.spanGaps)??!1,showDataLabels:(e==null?void 0:e.showDataLabels)??!1,showMinorGridlines:(e==null?void 0:e.showMinorGridlines)??!1}),$s=e=>e?e.map(n=>({...n,display:(n==null?void 0:n.display)??!0})):[],Zs=e=>{var n,t,r,s,i,l,o,a;return{labelAnnotation:{showLabel:((n=e==null?void 0:e.labelAnnotation)==null?void 0:n.showLabel)??!1,text:((t=e==null?void 0:e.labelAnnotation)==null?void 0:t.text)??"",position:((r=e==null?void 0:e.labelAnnotation)==null?void 0:r.position)??j.BOTTOM_RIGHT,fontSize:((s=e==null?void 0:e.labelAnnotation)==null?void 0:s.fontSize)??12,xOffset:((i=e==null?void 0:e.labelAnnotation)==null?void 0:i.xOffset)??5,yOffset:((l=e==null?void 0:e.labelAnnotation)==null?void 0:l.yOffset)??5,maxWidth:((o=e==null?void 0:e.labelAnnotation)==null?void 0:o.maxWidth)??300,lineHeight:((a=e==null?void 0:e.labelAnnotation)==null?void 0:a.lineHeight)??12},showAnnotations:(e==null?void 0:e.showAnnotations)??!1,controlAnnotation:(e==null?void 0:e.controlAnnotation)??!1,enableDragAnnotation:(e==null?void 0:e.enableDragAnnotation)??!1,annotationsData:$s(e==null?void 0:e.annotationsData)}},Ks=e=>({display:(e==null?void 0:e.display)??!0,position:(e==null?void 0:e.position)??ie.BottomLeft,align:(e==null?void 0:e.align)??F.Center,customLegend:(e==null?void 0:e.customLegend)??{customLegendPlugin:null,customLegendContainerID:""},usePointStyle:(e==null?void 0:e.usePointStyle)??!0}),Js=e=>({showPoints:(e==null?void 0:e.showPoints)??!0,showLine:(e==null?void 0:e.showLine)??!0,enableZoom:(e==null?void 0:e.enableZoom)??!0,enablePan:(e==null?void 0:e.enablePan)??!1,enableDragAnnotation:(e==null?void 0:e.enableDragAnnotation)??!1,closeOnOutsideClick:(e==null?void 0:e.closeOnOutsideClick)??!1}),Qs=e=>({onLegendClick:e==null?void 0:e.onLegendClick,onHover:e==null?void 0:e.onHover,onUnhover:e==null?void 0:e.onUnhover,onAnimationComplete:e==null?void 0:e.onAnimationComplete}),er=e=>({enableDragData:(e==null?void 0:e.enableDragData)??!1,showTooltip:(e==null?void 0:e.showTooltip)??!0,roundPoints:(e==null?void 0:e.roundPoints)??!0,dragX:(e==null?void 0:e.dragX)??!0,dragY:(e==null?void 0:e.dragY)??!0,onDragStart:e==null?void 0:e.onDragStart,onDrag:e==null?void 0:e.onDrag,onDragEnd:e==null?void 0:e.onDragEnd}),Rn=e=>{const n=(e==null?void 0:e.chart)||{},t=(n==null?void 0:n.options)||{};return{persistenceId:(n==null?void 0:n.persistenceId)??"",controlsPortalId:(n==null?void 0:n.controlsPortalId)??"",testId:(n==null?void 0:n.testId)??void 0,data:(n==null?void 0:n.data)??{datasets:[]},options:{title:(t==null?void 0:t.title)??"",scales:(t==null?void 0:t.scales)??{},axes:Xs(t==null?void 0:t.axes),additionalAxesOptions:Ys(t==null?void 0:t.additionalAxesOptions),chartStyling:Hs(t==null?void 0:t.chartStyling),tooltip:qs(t==null?void 0:t.tooltip),graph:Ws(t==null?void 0:t.graph),annotations:Zs(t==null?void 0:t.annotations),legend:Ks(t==null?void 0:t.legend),chartOptions:Js(t==null?void 0:t.chartOptions),interactions:Qs(t==null?void 0:t.interactions),dragData:er(t==null?void 0:t.dragData),depthType:(t==null?void 0:t.depthType)??{}}}},nr=(e,n)=>{if(N.isEmpty(e)||N.isEmpty(n))return!1;const t=r=>typeof n=="string"?r&&N.has(r,n):N.isArray(n)?r&&N.some(n,s=>r&&N.has(r,s)):r&&N.some(Object.values(n),s=>r&&N.has(r,s));return N.isArray(e)?N.some(e,t):t(e)};var Bn=(e=>(e.showLine="showLine",e.showPoints="showPoints",e))(Bn||{});const tr=(e,n,t,{label:r})=>{const s=[...e??[]],{annotations:i,graph:l}=t??{},{controlAnnotation:o,showAnnotations:a,annotationsData:c=[]}=i??{};if(o&&a){const u=c.map((d,y)=>{const{type:m,...h}=d,b=h.color??Q[y],_=$n,E=Be.INITIAL;return{...h,isAnnotation:!0,annotationType:m,label:h.label,annotationIndex:y,backgroundColor:b,pointBackgroundColor:b,borderColor:b,borderDash:_,borderWidth:E,data:[{}]}});s.push(...u)}return s==null?void 0:s.map((u,d)=>{var U,qe;const{formation:y,data:m=[],pointRadius:h,pointHoverRadius:b,borderWidth:_,borderColor:E,backgroundColor:f,pointBackgroundColor:T,borderDash:g,showPoints:p,showLine:L}=u??{},{lineEnabled:O,pointsEnabled:S,axes:P=[]}=n??{},{lineTension:D,spanGaps:A}=l??{},w=Array.isArray(m)?m:[];if(y&&(w!=null&&w.length)){const We=Number((U=P[0])==null?void 0:U.min),$e=Number((qe=P[0])==null?void 0:qe.max),[de,fe]=w;We&&(de!=null&&de.x)&&(w[0].x=Math.max(We,de.x)),$e&&(fe!=null&&fe.x)&&(w[2].x=Math.min($e,fe.x))}const $=nr(u,Bn),G=(w==null?void 0:w.filter(Boolean))||[],se=(G==null?void 0:G.length)===1;let z,R;p!==void 0?z=p:L===!1?z=!0:z=S||se,L!==void 0?R=L:p===!1?R=!0:R=O;const re=parseFloat(h)||Bt,Y=parseFloat(b)||Rt,B=Q[d];return{...u,label:(u==null?void 0:u.label)??`${r} ${d+1}`,data:G,showLine:R,lineTension:(u==null?void 0:u.lineTension)??D,spanGaps:A,borderWidth:parseFloat(_)||Xt,borderDash:g||[],borderJoinStyle:Vt,borderColor:E??B??Ae(Q),backgroundColor:f??Ut,pointBackgroundColor:T??B??Ae(Q),pointRadius:z?re:0,pointHoverRadius:Y,pointHitRadius:(u==null?void 0:u.pointHitRadius)??Y,...$?{hasCustomOpt:$}:{}}})},Un=e=>e==null?void 0:e.reduce((n,t)=>({...n,[t.annotationAxis]:[...n[t.annotationAxis]||[],+t.value]}),{}),Vn=(e,n,t)=>{if(!e||!e.current)return null;const r=e.current.getSortedVisibleDatasetMetas(),s=Un(t)[n]??[];let i=[];if(r.forEach(a=>{const c=a._parsed.map(u=>u[n]).filter(u=>u!=null&&!isNaN(u));i=i.concat(c)}),i=i.concat(s),i.length===0)return null;const l=Math.min(...i),o=Math.max(...i);return{min:l,max:o}},Re=(e,n,t,r,s=0)=>{var u,d,y,m,h,b,_;const i=r||e.axes[n][0]||{},l=t==null?void 0:t.axes.filter(E=>{var f;return(f=E==null?void 0:E.id)==null?void 0:f.startsWith(n)})[s],o=(d=(u=e==null?void 0:e.scales)==null?void 0:u[`${s===0?n:n+s}`])==null?void 0:d.ticks,{additionalAxesOptions:a}=e,c=()=>{const E=(a==null?void 0:a.chartScaleType)===Kn.Logarithmic,f=(p,L,O)=>E?Qn.includes(p)?nn(p,O):"":nn(p,O);return{...E?{}:{stepSize:i.stepSize??(n===V.Y?a.stepSize:null)},callback:f,includeBounds:!1,...o,font:{size:Jn}}};return{display:!0,type:a.chartScaleType,position:i.position,beginAtZero:a.beginAtZero,reverse:n===V.Y?a.reverse:!1,suggestedMax:a.suggestedMax,suggestedMin:a.suggestedMin,min:(l==null?void 0:l.min)??((m=(y=a==null?void 0:a.range)==null?void 0:y[n])==null?void 0:m.min),max:(l==null?void 0:l.max)??((b=(h=a==null?void 0:a.range)==null?void 0:h[n])==null?void 0:b.max),title:{display:(_=i.label)==null?void 0:_.length,text:i.label,padding:0},ticks:c(),grid:{...i.gridLines}}},gn=(e,n,t)=>e.axes[n].reduce((i,l,o)=>{const a=l;a.color=l.color||Q[o]||Ae(Q),a.position=l.position||Zn(n,o);const c=Re(e,n,t,a,o),u=kn(n,o,!0);return{...i,[u]:c}},{}),sr=(e,n)=>{var l,o;const t=((l=e.axes.x)==null?void 0:l.length)>1,r=((o=e.axes.y)==null?void 0:o.length)>1,s=t?gn(e,V.X,n):{x:Re(e,V.X,n)},i=r?gn(e,V.Y,n):{y:Re(e,V.Y,n)};return{...s,...i}},rr=e=>{var t;if(!Array.isArray(e)||!(e!=null&&e.length))return!1;const n=e==null?void 0:e.reduce((r,s)=>{var a,c,u,d;const i=(s==null?void 0:s.xAxisID)??"x",l=(s==null?void 0:s.yAxisID)??"y",o=(s==null?void 0:s.data)??[];if(o&&(o!=null&&o.length)){const{x:y,y:m}=(o==null?void 0:o[0])??{},{x:h=0,y:b=0}=(o==null?void 0:o.at(-1))??{},_=((a=r==null?void 0:r[i])==null?void 0:a.xFirst)??y,E=((c=r==null?void 0:r[i])==null?void 0:c.xLast)??h,f=((u=r==null?void 0:r[l])==null?void 0:u.yFirst)??m,T=((d=r==null?void 0:r[l])==null?void 0:d.yLast)??b,g=Math.min(y,_),p=Math.max(h,E),L=Math.min(m,f),O=Math.max(b,T);r={...r,[i]:{...r[i],xFirst:g,xLast:p},[l]:{yFirst:L,yLast:O}}}return r},{});return(t=Object.values(n))==null?void 0:t.some(({xFirst:r,xLast:s,yFirst:i,yLast:l})=>oe(r,s,{absoluteDiff:ae})||oe(i,l,{absoluteDiff:ae}))},mn=.05,lr={min:-1,max:1},ir=({data:e,beginAtZero:n=!1,autoAxisPadding:t=!1})=>{const r=Math.min(...e.filter(m=>m!=null&&!isNaN(m))),s=Math.max(...e.filter(m=>m!=null&&!isNaN(m))),i=Math.sign(r)===-1||Math.sign(s)===-1,l=oe(r,0,{absoluteDiff:ae})&&oe(s,0,{absoluteDiff:ae});if(!(e!=null&&e.length)||l)return lr;if(oe(r,s,{absoluteDiff:ae})){const m=s,h=m*mn,b=n&&!i?0:m-h,_=n&&i?0:m+h,E=ee(_,ge),f=ee(b,ge);return{min:E<0?E:f,max:f<0?f:E}}if(!t)return{min:void 0,max:void 0};const o=r===0||s===0||n,a=Math.sign(r)===-1&&Math.sign(s)===1,c=Math.abs(s-r),u=t?c*mn:0,d=!a&&o&&n&&!i?0:r-u,y=!a&&o&&n&&i?0:s+u;return{min:ee(d,ge),max:ee(y,ge)}},or=(e,n,t)=>{if(!Array.isArray(e)||!Array.isArray(n))return{};const r=Un(t);return n.reduce((s,i)=>{const l=zs(i),o=e.filter(c=>(c[`${l}AxisID`]??l)===i).flatMap(c=>((c==null?void 0:c.data)??[]).map(d=>d[l])),a=(r==null?void 0:r[i])??[];return s[i]=[...new Set([...o,...a])],s},{})},bn=(e,n)=>!N.isNil(e)||!N.isNil(n),ar=(e,n,t,r)=>{const{additionalAxesOptions:s,annotations:{annotationsData:i=[],controlAnnotation:l=!1}={}}=e||{},o=sr(e,n)||{},a=l?t.filter(({isAnnotation:y})=>!y):t;if(!(s!=null&&s.autoAxisPadding)&&!rr(a))return o;const c=Object.keys(o)??[],u=or(t,c,i);return(u&&(c==null?void 0:c.reduce((y,m)=>{const h=o[m],{min:b=void 0,max:_=void 0}=h,{min:E,max:f}=Vn(r,m,i)??{},{min:T,max:g}=ir({data:u[m],beginAtZero:s==null?void 0:s.beginAtZero,autoAxisPadding:s==null?void 0:s.autoAxisPadding}),p={[m]:{...h,min:b??(bn(b,_)?E:T),max:_??(bn(b,_)?f:g)}};return{...y,...p}},{})))??o},ur=(e,n,t,r,s)=>{const l=e??0,o=n??0,a=t??0,c=r??0,u=s??0,d=l-100<=a,y=l+100>=c,m=l+100>=a&&l+100<c&&o+100>=u;return{overLeftSide:d,overRightSide:y,overBottomSide:m}},cr=e=>{var y,m;const n=e==null?void 0:e.chart,t=(e==null?void 0:e.dataIndex)??0,r=(e==null?void 0:e.datasetIndex)??0,s=(n==null?void 0:n.chartArea)??{},{left:i=null,right:l=null,bottom:o=null}=s,a=(y=n==null?void 0:n.getDatasetMeta)==null?void 0:y.call(n,r),c=(m=a==null?void 0:a.data)==null?void 0:m[t],u=(c==null?void 0:c.x)??null,d=(c==null?void 0:c.y)??null;return{x:u,y:d,left:i,right:l,bottom:o}},dr=()=>e=>{const{x:n,y:t,left:r,right:s,bottom:i}=cr(e),{overLeftSide:l=!1,overRightSide:o=!1,overBottomSide:a=!1}=ur(n,t,r,s,i);return l&&F.Right||o&&F.Left||a&&F.End||F.Start},fr=e=>{var n;return(n=e==null?void 0:e.graph)!=null&&n.showDataLabels?{display:Me,align:dr(),formatter:(t,r)=>{var i,l;const s=(l=(i=r==null?void 0:r.dataset)==null?void 0:i.data)==null?void 0:l[r.dataIndex];return!s||s.label==null?"":typeof s.label=="string"?s.label:Array.isArray(s.label)?s.label.map(String):String(s.label)}}:{display:!1}},gr=e=>{const n=e==null?void 0:e.match(/\[(.*)\]/g);return n&&(n==null?void 0:n.length)>0?n==null?void 0:n[0]:""},yn=(e,n)=>{let t={};return n?(Math.abs(e)<Yt||Math.abs(e)>Ht)&&(t={roundScientificCoefficient:3}):t={scientific:!1},rt(lt(e),t)},mr=e=>{var i,l,o,a,c;if(!((l=(i=e==null?void 0:e.axes)==null?void 0:i.x)!=null&&l.length)||!((a=(o=e==null?void 0:e.axes)==null?void 0:o.y)!=null&&a.length))return console.warn("Tooltip config fallback: missing axes",e),{enabled:!1,callbacks:{}};const{scientificNotation:n}=(e==null?void 0:e.tooltip)??{},t=({xAxisID:u="",yAxisID:d=""})=>{var _,E,f,T,g,p,L;const y=(u==null?void 0:u.length)>1?Number(u==null?void 0:u[1])-1:0,m=(d==null?void 0:d.length)>1?Number(d==null?void 0:d[1])-1:0,h=(E=(_=e==null?void 0:e.axes)==null?void 0:_.x)==null?void 0:E[y],b=(T=(f=e==null?void 0:e.axes)==null?void 0:f.y)==null?void 0:T[m];return((L=(p=(g=e==null?void 0:e.axes)==null?void 0:g.x)==null?void 0:p[0])==null?void 0:L.position)===ie.Top?{titleAxisLabel:(b==null?void 0:b.label)||"",valueAxisLabel:(h==null?void 0:h.label)||"",titleLabel:Z.Y,valueLabel:Z.X}:{titleAxisLabel:(h==null?void 0:h.label)||"",valueAxisLabel:(b==null?void 0:b.label)||"",titleLabel:Z.X,valueLabel:Z.Y}},r=u=>{var _,E,f,T;if(!(u!=null&&u[0]))return"";const d=t(u[0].dataset),{titleLabel:y="",titleAxisLabel:m=""}=d??{},h=y===Z.Y?(E=(_=u==null?void 0:u[0])==null?void 0:_.parsed)==null?void 0:E.y:(T=(f=u==null?void 0:u[0])==null?void 0:f.parsed)==null?void 0:T.x;return`${yn(h,n)} ${m}`},s=u=>{var g;const{showLabelsInTooltips:d}=(e==null?void 0:e.tooltip)??{};let y=((g=u==null?void 0:u.dataset)==null?void 0:g.label)||"";const m=t(u==null?void 0:u.dataset),{valueLabel:h="",valueAxisLabel:b=""}=m??{},E=(()=>{var L,O;const p=h===Z.X?(L=u==null?void 0:u.parsed)==null?void 0:L.x:(O=u==null?void 0:u.parsed)==null?void 0:O.y;return yn(p,n)})(),f=gr(b),T=st(u,d);return`${y}: ${E} ${f} ${T}`};return{enabled:(c=e==null?void 0:e.tooltip)==null?void 0:c.tooltips,mode:be.Nearest,intersect:!0,padding:tt,usePointStyle:!0,boxWidth:Ke,boxHeight:Ke,boxPadding:nt,callbacks:{title:r,label:s,afterLabel:et}}},br=({chartRef:e,state:n,options:t,dispatch:r,generatedDatasets:s})=>{const{interactions:{onAnimationComplete:i},annotations:{labelAnnotation:{showLabel:l,text:o,position:a,fontSize:c,xOffset:u,yOffset:d,maxWidth:y,lineHeight:m}={}},chartStyling:{layoutPadding:h}}=t,{enableDragPoints:b,zoomEnabled:_,panEnabled:E,lineEnabled:f}=n,[T,g]=C.useState(null),{updateAxesRangesFromChart:p,onHover:L,onUpdateEdited:O}=He({chartRef:e,state:n,options:t,dispatch:r,generatedDatasets:s}),{legend:S,customLegendPlugin:P}=qt({chartRef:e,options:t})??{},{state:D}=Wt()??{},{annotation:A}=D??{},w=fr(t)??{},$=mr(t)??{},G=C.useMemo(()=>ar(t,n,s,e),[t,n,s,e]),se=C.useMemo(()=>b&&ls(t),[b,t]),z=C.useMemo(()=>({enabled:E,mode:J.XY,onPanComplete(){p(),O(!0)}}),[E]),R=C.useMemo(()=>({mode:J.XY,drag:{enabled:_,threshold:3,backgroundColor:$t,borderColor:Je,borderWidth:1},onZoomComplete(){p(),O(!0)}}),[_]),re={datalabels:w,annotationDraggerPlugin:{enabled:n==null?void 0:n.enableDragAnnotation},annotation:Zt(A),zoom:{pan:z,zoom:R},tooltip:$,legend:{...S,display:!1,events:[]},customLegendPlugin:P,chartAreaBorder:{borderColor:Je},chartAreaText:{showLabel:l,text:o,position:a,fontSize:c,xOffset:u,yOffset:d,maxWidth:y,lineHeight:m},...se};return C.useMemo(()=>{var Y,B,U;return{layout:{padding:h},onHover:L(T,g,s),maintainAspectRatio:(Y=t==null?void 0:t.chartStyling)==null?void 0:Y.maintainAspectRatio,aspectRatio:(B=t==null?void 0:t.chartStyling)!=null&&B.squareAspectRatio?1:0,animation:(U=t==null?void 0:t.chartStyling)!=null&&U.performanceMode?!1:{duration:ot.FAST,onComplete:i},hover:{mode:be.Nearest,intersect:!0},elements:{line:{pointStyle:it.Circle,showLine:f,tension:0}},scales:G,plugins:re,events:Object.values(at)}},[n,t,e,s])},yr=({options:e,resetZoom:n})=>{const{graph:t,legend:r}=e,s=C.useCallback((i,l)=>{const{event:o}=l;return o.type===Kt?(n(),!1):!0},[n]);return C.useMemo(()=>[...ut(t,r),{id:"customEventCatcher",beforeEvent:s}],[s])},hr=1,pr=(e,n)=>{var t,r;C.useEffect(()=>{var s,i;if((i=(s=n==null?void 0:n.legend)==null?void 0:s.customLegend)!=null&&i.customLegendPlugin){const l=document.getElementById(n.legend.customLegend.customLegendContainerID);l!==null&&(l.style.visibility=e.legendEnabled?"visible":"hidden")}},[(r=(t=n==null?void 0:n.legend)==null?void 0:t.customLegend)==null?void 0:r.customLegendPlugin,e.legendEnabled])},_r=(e,n)=>{C.useEffect(()=>{Ps(e,n)},[e.panEnabled,e.lineEnabled,e.pointsEnabled,e.legendEnabled,e.enableDragPoints,e.zoomEnabled])},xr=({chartRef:e,range:n,state:t,dispatch:r,annotationsData:s})=>{const i=C.useRef(t.axes);C.useEffect(()=>{if(n&&Bs(n)){const l=Object.entries(n).map(([a,{min:c,max:u}])=>{const{min:d=void 0,max:y=void 0}=Vn(e,a,s)??{};let m=c??d,h=u??y;return m===h&&(h+=hr),{id:a,min:m,max:h}}),o=[...i.current??[]].map(a=>{const c=l.find(u=>u.id===a.id);return c?{...a,...c}:a});_n(o,i.current)||(r({type:xe,payload:{axes:o}}),i.current=o)}},[n])},Tr=({chartRef:e,options:n,state:t,dispatch:r,persistenceId:s})=>{const i=C.useMemo(()=>t,[t]),l=C.useMemo(()=>n,[n]),{additionalAxesOptions:{range:o=void 0},annotations:{annotationsData:a=[]}={}}=l;_r(i,s),pr(i,l),xr({range:o,state:i,dispatch:r,chartRef:e,annotationsData:a})},Te=" ",Er="rgba(0, 0, 0, 0.5)",Lr=e=>{var n;return(n=Array.isArray(e)?e.join(Te):e)==null?void 0:n.split(Te)},Or=({ctx:e,lines:n,lineHeight:t,x:r,y:s,position:i})=>{n==null||n.forEach((l,o)=>{const a=i!=null&&i.includes("top")?s+t*(o+1)-5:s-(n.length-1-o)*t;e==null||e.fillText(l,r,a)})},Cr=(e,n)=>{const s=n<500?.5:n<700?.7:1;return e*s},Sr=e=>{var s,i,l,o,a,c,u;const{legend:n}=e??{},t=n&&(n!=null&&n.display)&&((s=n==null?void 0:n.options)==null?void 0:s.position)==="left"?(n==null?void 0:n.width)+((l=(i=n==null?void 0:n.options)==null?void 0:i.labels)==null?void 0:l.padding)*2:0,r=n&&n.display&&(((o=n==null?void 0:n.options)==null?void 0:o.position)==="top"||((a=n==null?void 0:n.options)==null?void 0:a.position)==="bottom")?(n==null?void 0:n.height)+((u=(c=n==null?void 0:n.options)==null?void 0:c.labels)==null?void 0:u.padding)*2:0;return{legendWidth:t,legendHeight:r}},Pr=(e,n,t,r)=>{const{chartArea:s,width:i}=n??{},l=i-8,{legendWidth:o,legendHeight:a}=Sr(n)??{};switch(e){case j.TOP_LEFT:return[(s==null?void 0:s.left)+t+o,(s==null?void 0:s.top)+r+a];case j.TOP_CENTER:return[(s==null?void 0:s.left)+(s==null?void 0:s.width)/2,(s==null?void 0:s.top)+r+a];case j.TOP_RIGHT:return[l-t,(s==null?void 0:s.top)+r+a];case j.MIDDLE_LEFT:return[(s==null?void 0:s.left)+t+o,(s==null?void 0:s.top)+(s==null?void 0:s.height)/2];case j.MIDDLE_CENTER:return[(s==null?void 0:s.left)+(s==null?void 0:s.width)/2,(s==null?void 0:s.top)+(s==null?void 0:s.height)/2];case j.MIDDLE_RIGHT:return[l-t-o,(s==null?void 0:s.top)+(s==null?void 0:s.height)/2];case j.BOTTOM_LEFT:return[(s==null?void 0:s.left)+t+o,(s==null?void 0:s.bottom)-r-a];case j.BOTTOM_CENTER:return[(s==null?void 0:s.left)+(s==null?void 0:s.width)/2,(s==null?void 0:s.bottom)-r-a];case j.BOTTOM_RIGHT:default:return[l-t-o,(s==null?void 0:s.bottom)-r-a]}},Nr=e=>e!=null&&e.includes(F.Center)?F.Center:e!=null&&e.includes(F.Left)?F.Left:F.Right,Dr=(e,n,t)=>{let r="",s=[];for(let i=0;i<e.length;i++){const l=`${r}${e==null?void 0:e[i]}${Te}`,{width:o}=(t==null?void 0:t.measureText(l))??{};o>n?(s.push(r==null?void 0:r.trim()),r=`${e==null?void 0:e[i]}${Te}`):r=l}return s.push(r.trim()),s},wr=(e,n)=>{var d,y;if(!e)return;const{text:t,maxWidth:r,fontSize:s,lineHeight:i,x:l,y:o,position:a}=n??{},c=Lr(t),u=Dr(c,r,e);(d=e==null?void 0:e.save)==null||d.call(e),e.font=`${s}px Arial`,e.fillStyle=Er,e.textAlign=Nr(a),Or({ctx:e,lines:u,lineHeight:i,x:l,y:o,position:a}),(y=e==null?void 0:e.restore)==null||y.call(e)},Ar={id:"chartAreaText",beforeDraw:(e,n,t)=>{const{showLabel:r,text:s,fontSize:i,xOffset:l,yOffset:o,lineHeight:a,maxWidth:c,position:u}=t??{};if(!r||!s)return;const{ctx:d,chartArea:y}=e??{};if(!d||!y)return;const m=Cr(c,y.width),[h,b]=Pr(u,e,l,o);wr(d,{text:s,maxWidth:m,fontSize:i,lineHeight:a,x:h,y:b,position:u})}},Xn=(e,n,t,r,s)=>{const i=n.getBoundingClientRect(),l=e.clientX-i.left,o=e.clientY-i.top,a=t==null?void 0:t[r],c=t==null?void 0:t[s],u=(a==null?void 0:a.getValueForPixel(l))??-1,d=(c==null?void 0:c.getValueForPixel(o))??-1;return{x:u,y:d}},Ee=e=>{const{xMin:n,xMax:t,yMin:r,yMax:s,xValue:i,yValue:l,type:o}=e??{};let a,c,u,d;return!N.isNil(n)&&!N.isNil(t)&&!N.isNil(r)&&!N.isNil(s)&&o===k.BOX?(a=(n+t)/2,c=(r+s)/2,u=t-n,d=s-r):!N.isNil(i)&&!N.isNil(l)&&o===k.POINT&&(a=i,c=l,u=0,d=0),{centerX:a,centerY:c,width:u,height:d}},Yn=(e,n,t,r)=>{const{xMin:s,xMax:i,yMin:l,yMax:o,xValue:a,yValue:c,type:u}=e??{};let d,y,m,h;const b=n==null?void 0:n[t],_=n==null?void 0:n[r];if(!b||!_)return{centerX:-1,centerY:-1,width:0,height:0};if(!N.isNil(s)&&!N.isNil(i)&&!N.isNil(l)&&!N.isNil(o)&&u===k.BOX){const E=(s+i)/2,f=(l+o)/2,T=(b==null?void 0:b.getPixelForValue(s))??0,g=(b==null?void 0:b.getPixelForValue(i))??0,p=(_==null?void 0:_.getPixelForValue(l))??0,L=(_==null?void 0:_.getPixelForValue(o))??0;m=T-g,h=p-L,d=(b==null?void 0:b.getPixelForValue(E))??-1,y=(_==null?void 0:_.getPixelForValue(f))??-1}else!N.isNil(a)&&!N.isNil(c)&&u===k.POINT&&(m=0,h=0,d=(b==null?void 0:b.getPixelForValue(a))??-1,y=(_==null?void 0:_.getPixelForValue(c))??-1);return{centerX:d,centerY:y,width:m,height:h}},Mr=({x:e,y:n,chartArea:t,scales:r,metrics:s,resizable:i=!1,dragRange:l,annotationType:o,xScaleID:a,yScaleID:c})=>{if(i&&!l)return!0;if(l){const _=e!==void 0&&l.x?e>=l.x[0]&&e<=l.x[1]:!0,E=n!==void 0&&l.y?n>=l.y[0]&&n<=l.y[1]:!0;return _&&E}const u=r==null?void 0:r[a],d=r==null?void 0:r[c];if(!(r!=null&&r[a])||!(r!=null&&r[c]))return!1;const y=(u==null?void 0:u.getValueForPixel(t.left))??Number.NEGATIVE_INFINITY,m=(u==null?void 0:u.getValueForPixel(t.right))??Number.POSITIVE_INFINITY,h=(d==null?void 0:d.getValueForPixel(t.bottom))??Number.NEGATIVE_INFINITY,b=(d==null?void 0:d.getValueForPixel(t.top))??Number.POSITIVE_INFINITY;if(o===k.POINT){const _=e!==void 0?e>=y&&e<=m:!0,E=n!==void 0?n>=h&&n<=b:!0;return _&&E}if(o===k.BOX&&s.width!==void 0&&s.height!==void 0){const _=e!==void 0?e-s.width/2:void 0,E=e!==void 0?e+s.width/2:void 0,f=n!==void 0?n-s.height/2:void 0,T=n!==void 0?n+s.height/2:void 0,g=_!==void 0&&E!==void 0?_>=y&&E<=m:!0,p=f!==void 0&&T!==void 0?f>=h&&T<=b:!0;return g&&p}return!0},hn=(e,n,t,r,s,i,l,o)=>{if(!(r!=null&&r.chartArea))return;const{resizable:a,dragRange:c=null}=t??{};Mr({[e]:n,chartArea:r.chartArea,scales:s,resizable:a,dragRange:c,metrics:o||{},annotationType:t.type,xScaleID:i,yScaleID:l})&&(t.type===k.POINT?e==="x"?t.xValue=n:e==="y"&&(t.yValue=n):t.type===k.BOX&&o&&(e==="x"&&o.width&&(t.xMin=n-o.width/2,t.xMax=n+o.width/2),e==="y"&&o.height&&(t.yMin=n-o.height/2,t.yMax=n+o.height/2)))},Hn=(e,n,t)=>{var s,i,l;if(!n)return;const r=(l=(i=(s=e==null?void 0:e.options)==null?void 0:s.plugins)==null?void 0:i.annotation)==null?void 0:l.annotations;r&&n&&r[n]&&(r[n].borderWidth=t)},vr=(e,n,t,r,s,i)=>{const l=i?r==null?void 0:r[i]:null;if(!l)return;const{xScaleID:o="x",yScaleID:a="y"}=l,{x:c,y:u}=Xn(e,n,t,o,a),d=Ee(l);if(l&&l.enableDrag&&!N.isNil(d.centerY)&&!N.isNil(d.centerX)){!N.isNil(n)&&!N.isNil(n.style)&&(n.style.cursor=Ue.Move);const y=c-d.centerX,m=u-d.centerY;s(!0,l,y,m),l!=null&&l.onDragStart&&l.onDragStart({x:c,y:u},l)}},Ir=(e,n,t,r,s,i,l,o)=>{if(r&&s){!N.isNil(n)&&!N.isNil(n.style)&&(n.style.cursor=Ue.Move);const a=s==null?void 0:s.id;Hn(o,a,Be.HOVERED);const c=(s==null?void 0:s.dragAxis)??le.Both,{xScaleID:u="x",yScaleID:d="y"}=s,{x:y,y:m}=Xn(e,n,t,u,d),h=Ee(s);let b=y-i,_=m-l;c!==le.Y&&hn(le.X,b,s,o,t,u,d,h),c!==le.X&&hn(le.Y,_,s,o,t,u,d,h),o.update(),s!=null&&s.onDrag&&s.onDrag({x:y,y:m},s);const{ctx:E,width:f,height:T}=o,{centerX:g,centerY:p}=Ee(s)??{},{centerX:L,centerY:O}=Yn(s,t,u,d);if(!N.isNil(g)&&!N.isNil(p)&&!N.isNil(L)&&!N.isNil(O)&&(E.save(),E.clearRect(0,0,f,T),o.draw(),E.font=ct,E.fillStyle="black",s!=null&&s.displayDragCoordinates)){let S=L-45,P=O-20;const D=`X: ${ee(g,2)}, Y: ${ee(p,2)}`,A=14;P-A<0&&(P=O+A+15),P>T&&(P=T-7),E.fillText(D,S,P),E.restore()}}},jr=(e,n,t,r,s)=>{if(e&&n){const i=n==null?void 0:n.id;Hn(t,i,Be.ZERO);const{centerX:l=-1,centerY:o=-1}=Ee(n)??{};N.isNil(n==null?void 0:n.onDragEnd)||n==null||n.onDragEnd({x:l,y:o},n),!N.isNil(r)&&!N.isNil(r.style)&&(r.style.cursor=Ue.Pointer),s(!1,null)}},Fr=(e,n,t)=>{Object.values(n).forEach(r=>{var s;if(r.type===k.POINT&&!N.isNil(r==null?void 0:r.label)&&((s=r==null?void 0:r.label)!=null&&s.display)){const{content:i,font:l,color:o,position:a,padding:c}=(r==null?void 0:r.label)??{},{xScaleID:u="x",yScaleID:d="y"}=r;e.save(),e.font=l,e.fillStyle=o;const{centerX:y=-1,centerY:m=-1}=Yn(r,t,u,d),h=e.measureText(i).width;let b=y-h/2,_=m+20;switch(a){case ie.Top:_=m-20;break;case ie.Left:b=y-h-c,_=m;break;case ie.Right:b=y+c,_=m;break}e.fillText(i,b,_),e.restore()}})},kr={id:"annotationDraggerPlugin",beforeDraw(e){var s,i,l,o,a,c,u,d;const n=e==null?void 0:e.ctx;let t=((i=(s=e.options.plugins)==null?void 0:s.annotation)==null?void 0:i.annotations)??{};if(!t||!n||!t)return;Fr(e.ctx,t,e.scales),(((o=(l=e==null?void 0:e.options)==null?void 0:l.plugins)==null?void 0:o.annotationDraggerPlugin)||{enabled:!1}).enabled?((c=(a=e==null?void 0:e.options)==null?void 0:a.plugins)!=null&&c.tooltip&&(e.options.plugins.tooltip.enabled=!1),e.options.hover={mode:void 0,intersect:!1}):((d=(u=e==null?void 0:e.options)==null?void 0:u.plugins)!=null&&d.tooltip&&(e.options.plugins.tooltip.enabled=!0),e.options.hover={mode:be.Nearest,intersect:!0})},afterUpdate(e){var y,m,h,b,_,E,f,T;const{canvas:n,scales:t,hoveredAnnotationId:r}=e??{},s=((m=(y=e==null?void 0:e.options)==null?void 0:y.plugins)==null?void 0:m.annotationDraggerPlugin)||{enabled:!1};if(!n||!t||!s)return;const i={...t,x:t.x,y:t.y};let l=((b=(h=e.options.plugins)==null?void 0:h.annotation)==null?void 0:b.annotations)??{};if(!e&&!l)return;s.enabled?((E=(_=e==null?void 0:e.options)==null?void 0:_.plugins)!=null&&E.tooltip&&(e.options.plugins.tooltip.enabled=!1),e.options.hover={mode:void 0,intersect:!1}):((T=(f=e==null?void 0:e.options)==null?void 0:f.plugins)!=null&&T.tooltip&&(e.options.plugins.tooltip.enabled=!0),e.options.hover={mode:be.Nearest,intersect:!0});let o=!1,a,c,u=null;const d=(g,p,L,O)=>{o=g,u=p,L!==void 0&&O!==void 0&&(a=L,c=O)};!n.dataset.annotationDraggerInitialized&&s.enabled&&r&&(n.addEventListener(K.MOUSEDOWN,g=>{var p,L,O;vr(g,n,i,(O=(L=(p=e==null?void 0:e.options)==null?void 0:p.plugins)==null?void 0:L.annotation)==null?void 0:O.annotations,d,e.hoveredAnnotationId)}),n.addEventListener(K.MOUSEMOVE,g=>{N.debounce(()=>Ir(g,n,i,o,u,a,c,e),5)()}),n.addEventListener(K.MOUSEUP,g=>{const p=g.currentTarget;jr(o,u,e,p,d)}),n.dataset.annotationDraggerInitialized="true"),s.enabled||(n.removeEventListener(K.MOUSEDOWN,()=>{}),n.removeEventListener(K.MOUSEMOVE,()=>{}),n.removeEventListener(K.MOUSEUP,()=>{}),n.dataset.annotationDraggerInitialized="")}};bt.register(yt,ht,pt,_t,xt,Tt,Et,Lt,Ot,Ct,St,ts,Ar,kr);const Gr=e=>{var D,A;ft();const n=C.useRef(null),{table:t,headerComponent:r,subheaderComponent:s}=e??{},{translations:i,languageKey:l}=is(),o=Rn(e),{data:{datasets:a}={datasets:[]},options:c,testId:u,persistenceId:d,controlsPortalId:y}=o,{annotations:m,axes:h,chartStyling:b,graph:_}=c??{},E=!((A=(D=c==null?void 0:c.legend)==null?void 0:D.customLegend)!=null&&A.customLegendContainerID),[f,T]=C.useReducer(Os,{options:c,persistenceId:d,chartRef:n},Ns),g=C.useMemo(()=>tr(a,f,c,i),[f.lineEnabled,f.pointsEnabled,a,h,m,_]);Tr({chartRef:n,options:c,state:f,dispatch:T,persistenceId:d});const{resetZoom:p,handleKeyDown:L,handleKeyUp:O}=He({chartRef:n,state:f,options:c,dispatch:T,generatedDatasets:g}),S=br({chartRef:n,state:f,options:c,dispatch:T,generatedDatasets:g}),P=yr({options:c,resetZoom:p});return x.jsxs("div",{className:gt(b,Ne),style:{width:b.width||Me,height:b.height||Me},tabIndex:0,onKeyDown:L,onKeyUp:O,"data-testid":u,children:[x.jsx(zn,{table:t,headerComponent:r,subheaderComponent:s,chartRef:n,state:f,options:c,dispatch:T,generatedDatasets:g,translations:i,controlsPortalId:y}),t&&f.showTable?x.jsx("div",{className:Ne.table,children:t}):x.jsx(Jt,{backend:Qt,context:window,children:x.jsxs("div",{className:Ne.canvas,id:"canvas",children:[x.jsx(mt,{ref:n,data:{datasets:g},options:S,plugins:P}),E&&!!g.length&&x.jsx(es,{chartRef:n,legendConfig:{options:c,generatedDatasets:g,chartType:ns.LINE}})]})})]},Rs([...Object.values(f),l]))},zr=e=>{const{options:n}=Rn(e);return x.jsx(dt,{options:n,children:x.jsx(Gr,{...e})})};zr.__docgenInfo={description:"",methods:[],displayName:"LineChartWithLegend",props:{chart:{required:!0,tsType:{name:"ILineChartData"},description:""},table:{required:!1,tsType:{name:"ReactNode"},description:""},headerComponent:{required:!1,tsType:{name:"ReactNode"},description:""},subheaderComponent:{required:!1,tsType:{name:"ReactNode"},description:""}}};export{zr as L,Hr as i};