@oliasoft-open-source/charts-library 5.1.1 → 5.1.2-beta-2
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.
- package/dist/assets/{Color-YHDXOIA2-BMZgyHAN.js → Color-YHDXOIA2-D1T4LLq8.js} +1 -1
- package/dist/assets/{DocsRenderer-CFRXHY34-CbvfojdO.js → DocsRenderer-CFRXHY34-D6Q7Fl4L.js} +4 -4
- package/dist/assets/bar-chart.stories-5CuN6VFG.js +136 -0
- package/dist/assets/chunk-XP5HYGXS-D5tuasO7.js +1 -0
- package/dist/assets/{client-9BU5HM4U.js → client-DnE3718B.js} +1 -1
- package/dist/assets/entry-preview-D2nZ6Uy3.js +2 -0
- package/dist/assets/{entry-preview-docs-z3mMcuG4.js → entry-preview-docs-Cet2djRm.js} +1 -1
- package/dist/assets/{get-draggableData-6sYCK0Sg.js → get-draggableData-eD2Xdq-6.js} +2 -2
- package/dist/assets/{iframe-BMP-xuj2.js → iframe-BRmCfBZj.js} +15 -15
- package/dist/assets/{index-D3-0uUTW.js → index-BhTLYoCu.js} +1 -1
- package/dist/assets/{index-B-BONL6g.js → index-CgYGpm1H.js} +1 -1
- package/dist/assets/index-DHw5ixvP.js +1 -0
- package/dist/assets/index-YTOF1_EJ.js +9 -0
- package/dist/assets/{index-CVdx34fM.js → index-uDG1oqxT.js} +1 -1
- package/dist/assets/jsx-runtime-W3oueGCa.js +9 -0
- package/dist/assets/legend-Cgq98xea.js +1367 -0
- package/dist/assets/{legend-context-CuYQJx0k.js → legend-context-PSa8HhGj.js} +22 -22
- package/dist/assets/line-chart-DQPiqg-c.js +1 -0
- package/dist/assets/{line-chart.stories-CCmSDSVh.js → line-chart.stories-yZbOjEZw.js} +16 -13
- package/dist/assets/{line-chart.test-case.stories-tBreUWeJ.js → line-chart.test-case.stories-KRbhVyto.js} +1 -1
- package/dist/assets/{pie-chart.stories-cGmfyrjX.js → pie-chart.stories-C3l9VGYJ.js} +1 -1
- package/dist/assets/{preview-DjxCxm3j.js → preview-OTEdgn42.js} +2 -2
- package/dist/assets/{preview-cjTsgsnd.js → preview-THptAU8l.js} +1 -1
- package/dist/assets/{react-18-DZY5LW1V.js → react-18-BdgjDjvZ.js} +1 -1
- package/dist/assets/{scatter-chart.stories-BK0zwTCK.js → scatter-chart.stories-U-tLziOZ.js} +6 -6
- package/dist/assets/test-utils-BBHUGUfi.js +9 -0
- package/dist/iframe.html +1 -1
- package/dist/index.js +34 -110
- package/dist/line-chart/hooks/use-chart-state.d.ts +1 -5
- package/dist/line-chart/state/initial-state.d.ts +0 -3
- package/dist/line-chart/utils/axis-scales/axis-scales.d.ts +1 -3
- package/dist/line-chart/utils/line-chart-utils.d.ts +6 -1
- package/dist/project.json +1 -1
- package/dist/sb-manager/globals-runtime.js +1 -1
- package/dist/src/components/line-chart/hooks/use-chart-state.d.ts +1 -5
- package/dist/src/components/line-chart/utils/axis-scales/axis-scales.d.ts +1 -3
- package/dist/src/components/line-chart/utils/line-chart-utils.d.ts +6 -1
- package/package.json +1 -1
- package/dist/assets/bar-chart.stories-BxoeoHbp.js +0 -153
- package/dist/assets/entry-preview-BsyjCx5f.js +0 -10
- package/dist/assets/index-BGqSdrBK.js +0 -1
- package/dist/assets/index-eCxJ45ll.js +0 -9
- package/dist/assets/jsx-runtime-Y5Ju2SGo.js +0 -9
- package/dist/assets/legend-DOpGXAxK.js +0 -1346
- package/dist/assets/line-chart-BWgI7lqL.js +0 -1
- package/dist/assets/react-CxVRKATl.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as E}from"./jsx-runtime-W3oueGCa.js";import{r as O}from"./index-YTOF1_EJ.js";import{$ as Xn,a0 as Ze,a1 as Q,B as Y,a2 as Yn,v as S,A as V,P as oe,C as ee,a3 as Ve,a4 as Hn,g as De,y as qn,S as Wn,E as $n,F as Zn,a5 as ie,a6 as ue,H as ne,a7 as ge,G as Ae,I as Kn,T as Jn,L as Ke,a as Qn,J as be,K as et,M as K,d as nt,r as tt,N as Je,a8 as st,f as rt,a9 as lt,U as ot,aa as B,ab as Be,ac as le,D as it,ad as J,b as ut,s as at,Q as dt,ae as ct,h as ft,i as gt,V as mt,W as bt,j as yt,k as pt,p as ht,m as _t,n as Tt,o as Et,q as xt,t as Pt}from"./legend-context-PSa8HhGj.js";import{r as Oe,M as Ue,k as ye,B as H,s as Lt,v as Ct,w as Qe,x as Ot,y as St,z as Nt,A as wt,E as Dt,N as en,G as At,S as Mt,g as Ft,e as vt,F as It,T as hn,J as kt,K as jt,D as Gt,O as Rt,Q as zt,o as Vt,q as Bt,U as Ut,j as Xt,u as Yt,Z as Ht,t as qt,R as Wt,l as $t,H as Zt,L as Kt,m as Jt,n as Qt}from"./legend-Cgq98xea.js";import{c as es,C as ns,f as nn,a as ts,b as ss}from"./get-draggableData-eD2Xdq-6.js";import{e as rs}from"./index-CgYGpm1H.js";const ls=(e,n,t)=>{const[r,s]=e.major,[i,l]=e.minor,o=(r.x+s.x+i.x+l.x)/4,u=(r.y+s.y+i.y+l.y)/4,d=s.x-r.x,a=s.y-r.y,c=Math.atan2(t.getPixelForValue(u+a/2)-t.getPixelForValue(u-a/2),n.getPixelForValue(o+d/2)-n.getPixelForValue(o-d/2)),p=Math.hypot(n.getPixelForValue(r.x)-n.getPixelForValue(s.x),t.getPixelForValue(r.y)-t.getPixelForValue(s.y))/2,b=Math.hypot(n.getPixelForValue(i.x)-n.getPixelForValue(l.x),t.getPixelForValue(i.y)-t.getPixelForValue(l.y))/2,h=n.getPixelForValue(o),m=t.getPixelForValue(u);return{cx:h,cy:m,radiusX:p,radiusY:b,angle:c}},os={id:"ellipsisAnnotationPlugin",afterDatasetsDraw(e){var i,l;const n=e==null?void 0:e.ctx,t=(i=e==null?void 0:e.scales)==null?void 0:i.x,r=(l=e==null?void 0:e.scales)==null?void 0:l.y;n.save();const s=e==null?void 0:e.chartArea;s&&(n.beginPath(),n.rect(s.left,s.top,s.right-s.left,s.bottom-s.top),n.clip()),e.data.datasets.forEach(o=>{const u=o;u.data.forEach(d=>{const{ellipsePoints:a}=d;if(!a)return;const{cx:c,cy:p,radiusX:b,radiusY:h,angle:m}=ls(a,t,r);n.save(),n.beginPath(),n.ellipse(c,p,b,h,m,0,2*Math.PI),n.strokeStyle=u.borderColor||Xn,n.lineWidth=u.borderWidth||1,n.stroke(),n.restore()})})}},is="_chart_e3qdd_1",us="_canvas_e3qdd_11",as="_fixedHeight_e3qdd_20",ds="_stretchHeight_e3qdd_26",cs="_squareAspectRatio_e3qdd_32",fs="_table_e3qdd_62",Se={chart:is,canvas:us,fixedHeight:as,stretchHeight:ds,squareAspectRatio:cs,table:fs};var _n=Symbol.for("immer-nothing"),tn=Symbol.for("immer-draftable"),A=Symbol.for("immer-state");function k(e,...n){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var te=Object.getPrototypeOf;function se(e){return!!e&&!!e[A]}function $(e){var n;return e?Tn(e)||Array.isArray(e)||!!e[tn]||!!((n=e.constructor)!=null&&n[tn])||Pe(e)||Le(e):!1}var gs=Object.prototype.constructor.toString();function Tn(e){if(!e||typeof e!="object")return!1;const n=te(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 pe(e,n){xe(e)===0?Reflect.ownKeys(e).forEach(t=>{n(t,e[t],e)}):e.forEach((t,r)=>n(r,t,e))}function xe(e){const n=e[A];return n?n.type_:Array.isArray(e)?1:Pe(e)?2:Le(e)?3:0}function Me(e,n){return xe(e)===2?e.has(n):Object.prototype.hasOwnProperty.call(e,n)}function En(e,n,t){const r=xe(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 Pe(e){return e instanceof Map}function Le(e){return e instanceof Set}function W(e){return e.copy_||e.base_}function Fe(e,n){if(Pe(e))return new Map(e);if(Le(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[A];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(te(e),r)}else{const r=te(e);if(r!==null&&t)return{...e};const s=Object.create(r);return Object.assign(s,e)}}function Xe(e,n=!1){return Ce(e)||se(e)||!$(e)||(xe(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(){k(2)}function Ce(e){return Object.isFrozen(e)}var ys={};function Z(e){const n=ys[e];return n||k(0,e),n}var ae;function xn(){return ae}function ps(e,n){return{drafts_:[],parent_:e,immer_:n,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function sn(e,n){n&&(Z("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=n)}function ve(e){Ie(e),e.drafts_.forEach(hs),e.drafts_=null}function Ie(e){e===ae&&(ae=e.parent_)}function rn(e){return ae=ps(ae,e)}function hs(e){const n=e[A];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[A].modified_&&(ve(n),k(4)),$(e)&&(e=he(n,e),n.parent_||_e(n,e)),n.patches_&&Z("Patches").generateReplacementPatches_(t[A].base_,e,n.patches_,n.inversePatches_)):e=he(n,t,[]),ve(n),n.patches_&&n.patchListener_(n.patches_,n.inversePatches_),e!==_n?e:void 0}function he(e,n,t){if(Ce(n))return n;const r=n[A];if(!r)return pe(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),pe(i,(o,u)=>on(e,r,s,o,u,t,l)),_e(e,s,!1),t&&e.patches_&&Z("Patches").generatePatches_(r,t,e.patches_,e.inversePatches_)}return r.copy_}function on(e,n,t,r,s,i,l){if(se(s)){const o=i&&n&&n.type_!==3&&!Me(n.assigned_,r)?i.concat(r):void 0,u=he(e,s,o);if(En(t,r,u),se(u))e.canAutoFreeze_=!1;else return}else l&&t.add(s);if($(s)&&!Ce(s)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;he(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_:xn(),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=de);const{revoke:l,proxy:o}=Proxy.revocable(s,i);return r.draft_=o,r.revoke_=l,o}var Ye={get(e,n){if(n===A)return e;const t=W(e);if(!Me(t,n))return Ts(e,t,n);const r=t[n];return e.finalized_||!$(r)?r:r===Ne(e.base_,n)?(we(e),e.copy_[n]=je(r,e)):r},has(e,n){return n in W(e)},ownKeys(e){return Reflect.ownKeys(W(e))},set(e,n,t){const r=Pn(W(e),n);if(r!=null&&r.set)return r.set.call(e.draft_,t),!0;if(!e.modified_){const s=Ne(W(e),n),i=s==null?void 0:s[A];if(i&&i.base_===t)return e.copy_[n]=t,e.assigned_[n]=!1,!0;if(ms(t,s)&&(t!==void 0||Me(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 Ne(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=W(e),r=Reflect.getOwnPropertyDescriptor(t,n);return r&&{writable:!0,configurable:e.type_!==1||n!=="length",enumerable:r.enumerable,value:t[n]}},defineProperty(){k(11)},getPrototypeOf(e){return te(e.base_)},setPrototypeOf(){k(12)}},de={};pe(Ye,(e,n)=>{de[e]=function(){return arguments[0]=arguments[0][0],n.apply(this,arguments)}});de.deleteProperty=function(e,n){return de.set.call(this,e,n,void 0)};de.set=function(e,n,t){return Ye.set.call(this,e[0],n,t,e[0])};function Ne(e,n){const t=e[A];return(t?W(t):e)[n]}function Ts(e,n,t){var s;const r=Pn(n,t);return r?"value"in r?r.value:(s=r.get)==null?void 0:s.call(e.draft_):void 0}function Pn(e,n){if(!(n in e))return;let t=te(e);for(;t;){const r=Object.getOwnPropertyDescriptor(t,n);if(r)return r;t=te(t)}}function ke(e){e.modified_||(e.modified_=!0,e.parent_&&ke(e.parent_))}function we(e){e.copy_||(e.copy_=Fe(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var Es=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(u=i,...d){return l.produce(u,a=>t.call(this,a,...d))}}typeof t!="function"&&k(6),r!==void 0&&typeof r!="function"&&k(7);let s;if($(n)){const i=rn(this),l=je(n,void 0);let o=!0;try{s=t(l),o=!1}finally{o?ve(i):Ie(i)}return sn(i,r),ln(s,i)}else if(!n||typeof n!="object"){if(s=t(n),s===void 0&&(s=n),s===_n&&(s=void 0),this.autoFreeze_&&Xe(s,!0),r){const i=[],l=[];Z("Patches").generateReplacementPatches_(n,s,i,l),r(i,l)}return s}else k(1,n)},this.produceWithPatches=(n,t)=>{if(typeof n=="function")return(l,...o)=>this.produceWithPatches(l,u=>n(u,...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){$(e)||k(8),se(e)&&(e=xs(e));const n=rn(this),t=je(e,void 0);return t[A].isManual_=!0,Ie(n),t}finishDraft(e,n){const t=e&&e[A];(!t||!t.isManual_)&&k(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=Z("Patches").applyPatches_;return se(e)?r(e,n):this.produce(e,s=>r(s,n))}};function je(e,n){const t=Pe(e)?Z("MapSet").proxyMap_(e,n):Le(e)?Z("MapSet").proxySet_(e,n):_s(e,n);return(n?n.scope_:xn()).drafts_.push(t),t}function xs(e){return se(e)||k(10,e),Ln(e)}function Ln(e){if(!$(e)||Ce(e))return e;const n=e[A];let t;if(n){if(!n.modified_)return n.base_;n.finalized_=!0,t=Fe(e,n.scope_.immer_.useStrictShallowCopy_)}else t=Fe(e,!0);return pe(t,(r,s)=>{En(t,r,Ln(s))}),n&&(n.finalized_=!1),t}var M=new Es,Ps=M.produce;M.produceWithPatches.bind(M);M.setAutoFreeze.bind(M);M.setUseStrictShallowCopy.bind(M);M.applyPatches.bind(M);M.createDraft.bind(M);M.finishDraft.bind(M);const Cn="TOGGLE_ZOOM",On="TOGGLE_PAN",Sn="TOGGLE_POINTS",Nn="TOGGLE_LINE",wn="TOGGLE_LEGEND",Dn="TOGGLE_TABLE",Ge="RESET_AXES_RANGES",Re="UPDATE_AXES_RANGES",An="TOGGLE_DRAG_POINTS",Mn="TOGGLE_DRAG_ANNOTATION",Fn="DISABLE_DRAG_OPTIONS",me="UPDATE_EDITED",Ls=(e,n)=>Ps(e,t=>{switch(n.type){case Cn:{t.zoomEnabled=!t.zoomEnabled,t.panEnabled&&(t.panEnabled=!1),t.enableDragPoints&&(t.enableDragPoints=!1),t.enableDragAnnotation&&(t.enableDragAnnotation=!1);break}case On:{t.panEnabled=!t.panEnabled,t.zoomEnabled&&(t.zoomEnabled=!1),t.enableDragPoints&&(t.enableDragPoints=!1),t.enableDragAnnotation&&(t.enableDragAnnotation=!1);break}case Sn:{t.pointsEnabled=!t.pointsEnabled;break}case Nn:{t.lineEnabled=!t.lineEnabled;break}case wn:{t.legendEnabled=!t.legendEnabled;break}case Dn:{t.showTable=!t.showTable;break}case Re:{const{axes:r}=n.payload;t.axes=r;break}case Ge:{const{axes:r}=n.payload;t.axes=r;break}case An:{t.enableDragPoints=!t.enableDragPoints,t.panEnabled&&(t.panEnabled=!1),t.zoomEnabled&&(t.zoomEnabled=!1),t.enableDragAnnotation&&(t.enableDragAnnotation=!1);break}case Mn:{t.enableDragAnnotation=!t.enableDragAnnotation,t.panEnabled&&(t.panEnabled=!1),t.zoomEnabled&&(t.zoomEnabled=!1);break}case Fn:{(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},Os=(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)}}}},Ss=(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)),Os()},Ns=({options:e,persistenceId:n})=>{const{chartOptions:{enableZoom:t,enablePan:r,showPoints:s,showLine:i,enableDragAnnotation:l},legend:{display:o},dragData:u}=e,{zoomEnabled:d,panEnabled:a,pointsEnabled:c,lineEnabled:p,legendEnabled:b,enableDragPoints:h,enableDragAnnotation:m}=Cs(n)||{};return{zoomEnabled:l??m?!1:d??t,panEnabled:a??r,pointsEnabled:c??s,lineEnabled:p??i,legendEnabled:b??o,axes:[],showTable:!1,enableDragPoints:(u==null?void 0:u.enableDragData)&&h,enableDragAnnotation:l??m,edited:!1}},ws=e=>O.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},O.createElement("clipPath",{id:"a"},O.createElement("path",{d:"m0 0h12v12h-12z"})),O.createElement("g",{clipPath:"url(#a)"},O.createElement("path",{d:"m.5 6.5v-1h11v1c-4.16104 0-6.63549 0-11 0z"}))),Ds=e=>O.createElement("svg",{fill:"currentColor",height:"1em",viewBox:"0 0 12 12",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e},O.createElement("circle",{cx:6,cy:6,r:2})),As=e=>O.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},O.createElement("clipPath",{id:"a"},O.createElement("path",{d:"m0 0h12v12h-12z"})),O.createElement("g",{clipPath:"url(#a)"},O.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:E.jsx(Oe,{icon:E.jsx(As,{})}),selected:r&&e,onClick:()=>{r||t(),e||n()}},{type:"Option",label:s.linesOnly,icon:E.jsx(Oe,{icon:E.jsx(ws,{})}),selected:!r&&e,onClick:()=>{r&&t(),e||n()}},{type:"Option",label:s.pointsOnly,icon:E.jsx(Oe,{icon:E.jsx(Ds,{})}),selected:r&&!e,onClick:()=>{r||t(),e&&n()}}]}const vn=({options:e})=>{const[n,t]=O.useState(!1),r=e.find(s=>s.selected);return E.jsx(Ue,{open:n,setOpen:t,menu:{sections:e,trigger:"Component",component:E.jsx(ye,{display:"inline-flex",text:r==null?void 0:r.label,placement:"bottom-start",enabled:!n,children:E.jsx(H,{colored:"muted",basic:!0,small:!0,round:!0,icon:r==null?void 0:r.icon})})}})};vn.__docgenInfo={description:"",methods:[],displayName:"LineOptions",props:{options:{required:!0,tsType:{name:"Array",elements:[{name:"IMenuSection"}],raw:"IMenuSection[]"},description:""}}};function Fs({onTogglePan:e,onToggleZoom:n,panEnabled:t,zoomEnabled:r,enableDragPoints:s,enableDragAnnotation:i,isDragDataAllowed:l,isDragAnnotationAllowed:o,onToggleDragAnnotation:u,onToggleDragPoints:d,onDisableDragOptions:a,translations:{dragToZoom:c,doubleClickToReset:p,dragToPan:b,dragToMovePoints:h,dragDisabled:m,dragToMoveAnnotation:_}}){return[{label:c,description:p,icon:E.jsx(Lt,{}),selected:r,type:"Option",onClick:()=>{r||n()}},{label:b,description:p,icon:E.jsx(Ct,{}),selected:t,type:"Option",onClick:()=>{t||e()}},...l?[{label:h,icon:E.jsx(Qe,{}),selected:s,type:"Option",onClick:()=>{s||d()}}]:[],...o?[{label:_,icon:E.jsx(Qe,{}),selected:i,type:"Option",onClick:()=>{i||u()}}]:[],{label:m,icon:E.jsx(Ot,{}),selected:!r&&!t&&!s&&!i,type:"Option",onClick:a}]}const In=({options:e})=>{const n=e.find(t=>t.selected);return E.jsx(Ue,{menu:{sections:e,trigger:"Component",component:E.jsx(H,{colored:"muted",basic:!0,small:!0,label:n==null?void 0:n.label,icon:n==null?void 0:n.icon})}})};In.__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 vs="_controls_1edjs_1",Is="_buttons_1edjs_6",un={controls:vs,buttons:Is},ks=e=>{const n=O.useCallback(t=>()=>{e({type:t})},[e]);return{onToggleLegend:n(wn),onToggleLine:n(Nn),onTogglePan:n(On),onTogglePoints:n(Sn),onToggleTable:n(Dn),onToggleZoom:n(Cn),onToggleDragPoints:n(An),onToggleDragAnnotation:n(Mn),onDisableDragOptions:n(Fn)}},js=(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}`},Rs=e=>{var n;return((n=e==null?void 0:e.match(/[^0-9/]+/gi))==null?void 0:n[0])??""},zs=e=>e.join(""),Yr=e=>typeof e=="string"||typeof e=="number"||typeof e=="boolean"||e===null,Vs=(e,n,t)=>zs([JSON.stringify(e),JSON.stringify(n),t]),He=({chartRef:e,state:n,options:t,dispatch:r,generatedDatasets:s})=>{const{interactions:{onHover:i,onUnhover:l},axes:o}=t,u=O.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:Ge,payload:{axes:[]}}),r({type:me,payload:!1}))},[e==null?void 0:e.current,r,n]),d=O.useCallback((f,T,g)=>(x,L)=>{if(!(L!=null&&L.length)&&l&&f&&(T(null),l(x)),L!=null&&L.length&&i){const{index:y,datasetIndex:C}=L[0],N=g[C],w=N==null?void 0:N.data[y];w&&!rs(f,w)&&(T(w),i(x,C,y,g))}},[i,l,s]),a=O.useCallback(()=>es(e),[e==null?void 0:e.current]),c=O.useCallback(f=>{var T,g,x,L,y;if(f.key===Ze.Shift){const C=e.current,N=(x=(g=(T=C==null?void 0:C.config)==null?void 0:T.options)==null?void 0:g.plugins)==null?void 0:x.zoom;(L=N==null?void 0:N.zoom)!=null&&L.mode&&((y=N==null?void 0:N.pan)!=null&&y.mode)&&(N.zoom.mode=Q.Y,N.pan.mode=Q.Y,C==null||C.update())}},[e==null?void 0:e.current]),p=O.useCallback(f=>{var T,g,x,L,y;if(f.key===Ze.Shift){const C=e.current,N=(x=(g=(T=C==null?void 0:C.config)==null?void 0:T.options)==null?void 0:g.plugins)==null?void 0:x.zoom;(L=N==null?void 0:N.zoom)!=null&&L.mode&&((y=N==null?void 0:N.pan)!=null&&y.mode)&&(N.zoom.mode=Q.XY,N.pan.mode=Q.XY,C==null||C.update())}},[e==null?void 0:e.current]),b=O.useCallback(f=>{var g;if(!((g=Object.keys(f))!=null&&g.length))return[];const T=(x,L)=>{var y;return!x[L]||!((y=x[L])!=null&&y.length)?[]:x[L].map((C,N)=>({id:kn(L,N,x[L].length>1),label:(C==null?void 0:C.label)||""}))};return[...T(f,Y.X),...T(f,Y.Y)]},[o]),h=O.useCallback(()=>{var g;const{scales:f={}}=(e==null?void 0:e.current)||{},T=(g=Object.entries(f))==null?void 0:g.map(([x,{min:L,max:y}])=>({id:x,min:L??0,max:y??0}));r({type:Re,payload:{axes:T}})},[o]),m=O.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:Ge,payload:{axes:[]}}),r({type:me,payload:!1}))},[e==null?void 0:e.current]),_=O.useCallback(({axes:f})=>{r({type:Re,payload:{axes:f}})},[]),P=O.useCallback(f=>{r({type:me,payload:f})},[n]);return{resetZoom:u,onHover:d,handleDownload:a,handleKeyDown:c,handleKeyUp:p,controlsAxesLabels:b(o),updateAxesRangesFromChart:h,onResetAxes:m,onUpdateAxes:_,onUpdateEdited:P}},an=(e,n,t)=>{const r=[];return Yn(e)&&r.push("mustHaveAValue"),t==="min"&&!js(e,n)?r.push("mustBeLessThanMax"):t==="max"&&!Gs(e,n)&&r.push("mustBeGreaterThanMin"),r},Bs=e=>{const n=e.map(({id:r,min:s,max:i})=>({id:r,min:an(String(s),String(i),"min"),max:an(String(i),String(s),"max")})),t=n.every(r=>r.min.length===0&&r.max.length===0);return{errors:n,valid:t}},dn=1,cn=({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 a;let o=Number(i),u=Number(l);isNaN(o)&&(o=0),isNaN(u)&&(u=o+dn),o===u&&(u+=dn);const{unit:d}=((a=n==null?void 0:n.axes)==null?void 0:a.find(c=>c.id===s))??{};return{id:s,min:o,max:u,unit:d}})},Us=e=>{var T;const{state:n,controlsAxesLabels:t,onUpdateAxes:r,onResetAxes:s,onUpdateEdited:i,depthType:l,translations:o,close:u,chartRef:d}=e??{},[a,c]=O.useState({localAxes:cn({chartRef:d,state:n}),depthType:l==null?void 0:l.selectedDepthType,edited:n.edited}),{errors:p,valid:b}=Bs(a.localAxes),h=({name:g,value:x,id:L})=>{c(y=>({...y,localAxes:y.localAxes.map(C=>C.id===L?{...C,[g]:x}:C),edited:!0}))},m=({name:g,value:x,id:L})=>{c(y=>({...y,localAxes:y.localAxes.map(C=>C.id===L&&typeof C.unit=="object"?{...C,unit:{...C.unit,[g]:x}}:C),edited:!0}))},_=g=>{g.preventDefault(),b&&(r({axes:a.localAxes}),u==null||u()),l&&(l!=null&&l.setSelectedDepthType)&&(l==null||l.setSelectedDepthType(a.depthType)),i(a.edited)},P=()=>{c({localAxes:cn({chartRef:d,state:n}),depthType:l==null?void 0:l.selectedDepthType,edited:!1}),s(),i(!1),u==null||u()},f=g=>g.target.select();return E.jsxs("form",{onSubmit:_,children:[a.localAxes.map(g=>{var C,N;const x=t.find(w=>w.id===g.id),L=(x==null?void 0:x.label)||S.startCase(g.id),y=p.find(w=>w.id===g.id);return E.jsx(wt,{label:L,children:E.jsxs(Dt,{small:!0,width:"300px",children:[E.jsx(en,{name:"min",value:g.min,error:(C=y==null?void 0:y.min)!=null&&C[0]?o[y.min[0]]:null,width:"100%",onChange:w=>h({name:w.target.name,value:w.target.value,id:g.id}),onFocus:f}),E.jsx(At,{children:"to"}),E.jsx(en,{name:"max",value:g.max,error:(N=y==null?void 0:y.max)!=null&&N[0]?o[y.max[0]]:null,width:"100%",onChange:w=>h({name:w.target.name,value:w.target.value,id:g.id}),onFocus:f}),g.unit?E.jsx(Mt,{name:"selectedUnit",options:typeof g.unit!="string"?g.unit.options:[],value:typeof g.unit!="string"?g.unit.selectedUnit:void 0,onChange:w=>m({name:w.target.name,value:w.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&&E.jsxs(E.Fragment,{children:[E.jsx(Ft,{items:l.options.map((g,x)=>({key:x,label:g})),onSelected:g=>{c(x=>({...x,depthType:l.options[g],edited:!0}))},small:!0,value:l.options.indexOf(a.depthType)}),E.jsx(vt,{})]}),E.jsxs(It,{gap:"8px",alignItems:"center",children:[E.jsx(H,{type:"submit",small:!0,colored:!0,label:o.done,disabled:!b||!a.edited}),E.jsx(H,{small:!0,name:"resetAxes",label:o.resetAxes,onClick:P}),E.jsx(hn,{small:!0,muted:!0,children:o.orDoubleClickToCanvas})]})]})},jn=e=>E.jsx(St,{placement:"bottom-start",overflowContainer:!0,content:E.jsx(Us,{...e}),children:E.jsx(ye,{text:e.translations.axesOptions,placement:"bottom-start",display:"inline-flex",children:E.jsx(H,{small:!0,basic:!0,colored:"muted",round:!0,icon:E.jsx(Nt,{})})})});jn.__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 Gn=({table:e,headerComponent:n,subheaderComponent:t,chartRef:r,state:s,options:i,dispatch:l,generatedDatasets:o,translations:u,controlsPortalId:d})=>{const{enableDragPoints:a,lineEnabled:c,panEnabled:p,pointsEnabled:b,showTable:h,zoomEnabled:m,enableDragAnnotation:_}=s,{dragData:P,depthType:f,annotations:T}=i,{onToggleLine:g,onTogglePan:x,onTogglePoints:L,onToggleTable:y,onToggleZoom:C,onToggleDragPoints:N,onToggleDragAnnotation:w,onDisableDragOptions:F}=ks(l),{handleDownload:D,controlsAxesLabels:j,onResetAxes:G,onUpdateAxes:v,onUpdateEdited:R}=He({chartRef:r,state:s,options:i,dispatch:l,generatedDatasets:o}),[I,{width:re}]=kt(),q=re<200,U=O.useMemo(()=>Ms({lineEnabled:c,onToggleLine:g,onTogglePoints:L,pointsEnabled:b,translations:u}),[c,b]),X=O.useMemo(()=>Fs({onTogglePan:x,onToggleZoom:C,panEnabled:p,zoomEnabled:m,enableDragPoints:a,enableDragAnnotation:_,isDragDataAllowed:P==null?void 0:P.enableDragData,isDragAnnotationAllowed:T==null?void 0:T.enableDragAnnotation,onToggleDragAnnotation:w,onToggleDragPoints:N,onDisableDragOptions:F,translations:u}),[m,p,a,P==null?void 0:P.enableDragData,T==null?void 0:T.enableDragAnnotation]);return E.jsxs(E.Fragment,{children:[E.jsxs("div",{className:un.controls,children:[!!i.title&&E.jsx(hn,{bold:!0,children:i.title}),n,E.jsx(ns,{controlsPortalId:d??"",children:E.jsxs("div",{className:un.buttons,ref:I,children:[!h&&E.jsxs(E.Fragment,{children:[E.jsx(jn,{chartRef:r,state:s,controlsAxesLabels:j,onUpdateAxes:v,onResetAxes:G,onUpdateEdited:R,depthType:f,translations:u}),q?E.jsx(Ue,{menu:{placement:"bottom-end",sections:[...U,{type:"Divider"},...X,{type:"Divider"},{icon:"download",label:u.downloadAsPNG,type:"Option",onClick:D}],trigger:"Component",component:E.jsx(H,{colored:"muted",basic:!0,small:!0,round:!0,icon:"menu"})}}):E.jsxs(E.Fragment,{children:[E.jsx(vn,{options:U}),E.jsx(ye,{display:"inline-flex",text:u.downloadAsPNG,placement:"bottom-end",children:E.jsx(H,{small:!0,basic:!0,colored:"muted",round:!0,icon:"download",onClick:D})}),E.jsx(In,{options:X})]})]}),e?E.jsx(ye,{display:"inline-flex",text:h?u.showChart:u.showTable,placement:"bottom-end",children:E.jsx(H,{small:!0,basic:!0,colored:"muted",round:!0,icon:h?"chart":"table",onClick:y})}):null]})})]}),t]})};Gn.__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 z={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,u;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)??z.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:((u=e==null?void 0:e.labelAnnotation)==null?void 0:u.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)??oe.BottomLeft,align:(e==null?void 0:e.align)??V.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(S.isEmpty(e)||S.isEmpty(n))return!1;const t=r=>typeof n=="string"?r&&S.has(r,n):S.isArray(n)?r&&S.some(n,s=>r&&S.has(r,s)):r&&S.some(Object.values(n),s=>r&&S.has(r,s));return S.isArray(e)?S.some(e,t):t(e)};var zn=(e=>(e.showLine="showLine",e.showPoints="showPoints",e))(zn||{});const tr=(e,n,t,{label:r})=>{const s=[...e??[]],{annotations:i,graph:l}=t??{},{controlAnnotation:o,showAnnotations:u,annotationsData:d=[]}=i??{};if(o&&u){const a=d.map((c,p)=>{const{type:b,...h}=c,m=h.color??ee[p],_=Hn,P=Ve.INITIAL;return{...h,isAnnotation:!0,annotationType:b,label:h.label,annotationIndex:p,backgroundColor:m,pointBackgroundColor:m,borderColor:m,borderDash:_,borderWidth:P,data:[{}]}});s.push(...a)}return s==null?void 0:s.map((a,c)=>{var X,qe;const{formation:p,data:b=[],pointRadius:h,pointHoverRadius:m,borderWidth:_,borderColor:P,backgroundColor:f,pointBackgroundColor:T,borderDash:g,showPoints:x,showLine:L}=a??{},{lineEnabled:y,pointsEnabled:C,axes:N=[]}=n??{},{lineTension:w,spanGaps:F}=l??{},D=Array.isArray(b)?b:[];if(p&&(D!=null&&D.length)){const We=Number((X=N[0])==null?void 0:X.min),$e=Number((qe=N[0])==null?void 0:qe.max),[ce,fe]=D;We&&(ce!=null&&ce.x)&&(D[0].x=Math.max(We,ce.x)),$e&&(fe!=null&&fe.x)&&(D[2].x=Math.min($e,fe.x))}const j=nr(a,zn),G=(D==null?void 0:D.filter(Boolean))||[],v=(G==null?void 0:G.length)===1;let R,I;x!==void 0?R=x:L===!1?R=!0:R=C||v,L!==void 0?I=L:x===!1?I=!0:I=y;const re=parseFloat(h)||Gt,q=parseFloat(m)||jt,U=ee[c];return{...a,label:(a==null?void 0:a.label)??`${r} ${c+1}`,data:G,showLine:I,lineTension:(a==null?void 0:a.lineTension)??w,spanGaps:F,borderWidth:parseFloat(_)||Vt,borderDash:g||[],borderJoinStyle:zt,borderColor:P??U??De(ee),backgroundColor:f??Rt,pointBackgroundColor:T??U??De(ee),pointRadius:R?re:0,pointHoverRadius:q,pointHitRadius:(a==null?void 0:a.pointHitRadius)??q,...j?{hasCustomOpt:j}:{}}})},ze=(e,n,t,r,s=0)=>{var a,c,p,b,h,m,_;const i=r||e.axes[n][0]||{},l=t==null?void 0:t.axes.filter(P=>{var f;return(f=P==null?void 0:P.id)==null?void 0:f.startsWith(n)})[s],o=(c=(a=e==null?void 0:e.scales)==null?void 0:a[`${s===0?n:n+s}`])==null?void 0:c.ticks,{additionalAxesOptions:u}=e,d=()=>{const P=(u==null?void 0:u.chartScaleType)===Wn.Logarithmic,f=(x,L,y)=>P?Zn.includes(x)?nn(x,y):"":nn(x,y);return{...P?{}:{stepSize:i.stepSize??(n===Y.Y?u.stepSize:null)},callback:f,includeBounds:!1,...o,font:{size:$n}}};return{display:!0,type:u.chartScaleType,position:i.position,beginAtZero:u.beginAtZero,reverse:n===Y.Y?u.reverse:!1,suggestedMax:u.suggestedMax,suggestedMin:u.suggestedMin,min:(l==null?void 0:l.min)??((b=(p=u==null?void 0:u.range)==null?void 0:p[n])==null?void 0:b.min),max:(l==null?void 0:l.max)??((m=(h=u==null?void 0:u.range)==null?void 0:h[n])==null?void 0:m.max),title:{display:(_=i.label)==null?void 0:_.length,text:i.label,padding:0},ticks:d(),grid:{...i.gridLines}}},gn=(e,n,t)=>e.axes[n].reduce((i,l,o)=>{const u=l;u.color=l.color||ee[o]||De(ee),u.position=l.position||qn(n,o);const d=ze(e,n,t,u,o),a=kn(n,o,!0);return{...i,[a]:d}},{}),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,Y.X,n):{x:ze(e,Y.X,n)},i=r?gn(e,Y.Y,n):{y:ze(e,Y.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 u,d,a,c;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:p,y:b}=(o==null?void 0:o[0])??{},{x:h=0,y:m=0}=(o==null?void 0:o.at(-1))??{},_=((u=r==null?void 0:r[i])==null?void 0:u.xFirst)??p,P=((d=r==null?void 0:r[i])==null?void 0:d.xLast)??h,f=((a=r==null?void 0:r[l])==null?void 0:a.yFirst)??b,T=((c=r==null?void 0:r[l])==null?void 0:c.yLast)??m,g=Math.min(p,_),x=Math.max(h,P),L=Math.min(b,f),y=Math.max(m,T);r={...r,[i]:{...r[i],xFirst:g,xLast:x},[l]:{yFirst:L,yLast:y}}}return r},{});return(t=Object.values(n))==null?void 0:t.some(({xFirst:r,xLast:s,yFirst:i,yLast:l})=>ie(r,s,{absoluteDiff:ue})||ie(i,l,{absoluteDiff:ue}))},mn=.05,lr={min:-1,max:1},or=({data:e,beginAtZero:n=!1,autoAxisPadding:t=!1})=>{const r=Math.min(...e.filter(b=>b!=null&&!isNaN(b))),s=Math.max(...e.filter(b=>b!=null&&!isNaN(b))),i=Math.sign(r)===-1||Math.sign(s)===-1,l=ie(r,0,{absoluteDiff:ue})&&ie(s,0,{absoluteDiff:ue});if(!(e!=null&&e.length)||l)return lr;if(ie(r,s,{absoluteDiff:ue})){const b=s,h=b*mn,m=n&&!i?0:b-h,_=n&&i?0:b+h,P=ne(_,ge),f=ne(m,ge);return{min:P<0?P:f,max:f<0?f:P}}if(!t)return{min:void 0,max:void 0};const o=r===0||s===0||n,u=Math.sign(r)===-1&&Math.sign(s)===1,d=Math.abs(s-r),a=t?d*mn:0,c=!u&&o&&n&&!i?0:r-a,p=!u&&o&&n&&i?0:s+a;return{min:ne(c,ge),max:ne(p,ge)}},ir=e=>e==null?void 0:e.reduce((n,t)=>({...n,[t.annotationAxis]:[...n[t.annotationAxis]||[],+t.value]}),{}),ur=(e,n,t)=>{if(!Array.isArray(e)||!Array.isArray(n))return{};const r=ir(t);return n.reduce((s,i)=>{const l=Rs(i),o=e.filter(d=>(d[`${l}AxisID`]??l)===i).flatMap(d=>((d==null?void 0:d.data)??[]).map(c=>c[l])),u=(r==null?void 0:r[i])??[];return s[i]=[...new Set([...o,...u])],s},{})},bn=(e,n)=>!S.isNil(e)||!S.isNil(n),ar=(e,n,t)=>{const{additionalAxesOptions:r,annotations:{annotationsData:s=[],controlAnnotation:i=!1}={}}=e||{},l=sr(e,n)||{},o=i?t.filter(({isAnnotation:c})=>!c):t;if(!(r!=null&&r.autoAxisPadding)&&!rr(o))return l;const u=Object.keys(l)??[],d=ur(t,u,s);return(d&&(u==null?void 0:u.reduce((c,p)=>{const b=l[p],{min:h=void 0,max:m=void 0}=b,{min:_,max:P}=or({data:d[p],beginAtZero:r==null?void 0:r.beginAtZero,autoAxisPadding:r==null?void 0:r.autoAxisPadding}),f={[p]:{...b,min:h??(bn(h,m)?void 0:_),max:m??(bn(h,m)?void 0:P)}};return{...c,...f}},{})))??l},dr=(e,n,t,r,s)=>{const l=e??0,o=n??0,u=t??0,d=r??0,a=s??0,c=l-100<=u,p=l+100>=d,b=l+100>=u&&l+100<d&&o+100>=a;return{overLeftSide:c,overRightSide:p,overBottomSide:b}},cr=e=>{var p,b;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,u=(p=n==null?void 0:n.getDatasetMeta)==null?void 0:p.call(n,r),d=(b=u==null?void 0:u.data)==null?void 0:b[t],a=(d==null?void 0:d.x)??null,c=(d==null?void 0:d.y)??null;return{x:a,y:c,left:i,right:l,bottom:o}},fr=()=>e=>{const{x:n,y:t,left:r,right:s,bottom:i}=cr(e),{overLeftSide:l=!1,overRightSide:o=!1,overBottomSide:u=!1}=dr(n,t,r,s,i);return l&&V.Right||o&&V.Left||u&&V.End||V.Start},gr=e=>{var n;return(n=e==null?void 0:e.graph)!=null&&n.showDataLabels?{display:Ae,align:fr(),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}},mr=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)<Bt||Math.abs(e)>Ut)&&(t={roundScientificCoefficient:3}):t={scientific:!1},nt(tt(e),t)},br=e=>{var i,l,o,u,d;if(!((l=(i=e==null?void 0:e.axes)==null?void 0:i.x)!=null&&l.length)||!((u=(o=e==null?void 0:e.axes)==null?void 0:o.y)!=null&&u.length))return console.warn("Tooltip config fallback: missing axes",e),{enabled:!1,callbacks:{}};const{scientificNotation:n}=(e==null?void 0:e.tooltip)??{},t=({xAxisID:a="",yAxisID:c=""})=>{var _,P,f,T,g,x,L;const p=(a==null?void 0:a.length)>1?Number(a==null?void 0:a[1])-1:0,b=(c==null?void 0:c.length)>1?Number(c==null?void 0:c[1])-1:0,h=(P=(_=e==null?void 0:e.axes)==null?void 0:_.x)==null?void 0:P[p],m=(T=(f=e==null?void 0:e.axes)==null?void 0:f.y)==null?void 0:T[b];return((L=(x=(g=e==null?void 0:e.axes)==null?void 0:g.x)==null?void 0:x[0])==null?void 0:L.position)===oe.Top?{titleAxisLabel:(m==null?void 0:m.label)||"",valueAxisLabel:(h==null?void 0:h.label)||"",titleLabel:K.Y,valueLabel:K.X}:{titleAxisLabel:(h==null?void 0:h.label)||"",valueAxisLabel:(m==null?void 0:m.label)||"",titleLabel:K.X,valueLabel:K.Y}},r=a=>{var _,P,f,T;if(!(a!=null&&a[0]))return"";const c=t(a[0].dataset),{titleLabel:p="",titleAxisLabel:b=""}=c??{},h=p===K.Y?(P=(_=a==null?void 0:a[0])==null?void 0:_.parsed)==null?void 0:P.y:(T=(f=a==null?void 0:a[0])==null?void 0:f.parsed)==null?void 0:T.x;return`${yn(h,n)} ${b}`},s=a=>{var g;const{showLabelsInTooltips:c}=(e==null?void 0:e.tooltip)??{};let p=((g=a==null?void 0:a.dataset)==null?void 0:g.label)||"";const b=t(a==null?void 0:a.dataset),{valueLabel:h="",valueAxisLabel:m=""}=b??{},P=(()=>{var L,y;const x=h===K.X?(L=a==null?void 0:a.parsed)==null?void 0:L.x:(y=a==null?void 0:a.parsed)==null?void 0:y.y;return yn(x,n)})(),f=mr(m),T=et(a,c);return`${p}: ${P} ${f} ${T}`};return{enabled:(d=e==null?void 0:e.tooltip)==null?void 0:d.tooltips,mode:be.Nearest,intersect:!0,padding:Qn,usePointStyle:!0,boxWidth:Ke,boxHeight:Ke,boxPadding:Jn,callbacks:{title:r,label:s,afterLabel:Kn}}},yr=({chartRef:e,state:n,options:t,dispatch:r,generatedDatasets:s})=>{const{interactions:{onAnimationComplete:i},annotations:{labelAnnotation:{showLabel:l,text:o,position:u,fontSize:d,xOffset:a,yOffset:c,maxWidth:p,lineHeight:b}={}},chartStyling:{layoutPadding:h}}=t,{enableDragPoints:m,zoomEnabled:_,panEnabled:P,lineEnabled:f}=n,[T,g]=O.useState(null),{updateAxesRangesFromChart:x,onHover:L,onUpdateEdited:y}=He({chartRef:e,state:n,options:t,dispatch:r,generatedDatasets:s}),{legend:C,customLegendPlugin:N}=Xt({chartRef:e,options:t})??{},{state:w}=Yt()??{},{annotation:F}=w??{},D=gr(t)??{},j=br(t)??{},G=O.useMemo(()=>ar(t,n,s),[t,n,s,e]),v=O.useMemo(()=>m&&ts(t),[m,t]),R=O.useMemo(()=>({enabled:P,mode:Q.XY,onPanComplete(){x(),y(!0)}}),[P]),I=O.useMemo(()=>({mode:Q.XY,drag:{enabled:_,threshold:3,backgroundColor:Ht,borderColor:Je,borderWidth:1},onZoomComplete(){x(),y(!0)}}),[_]),re={datalabels:D,annotationDraggerPlugin:{enabled:n==null?void 0:n.enableDragAnnotation},annotation:qt(F),zoom:{pan:R,zoom:I},tooltip:j,legend:{...C,display:!1,events:[]},customLegendPlugin:N,chartAreaBorder:{borderColor:Je},chartAreaText:{showLabel:l,text:o,position:u,fontSize:d,xOffset:a,yOffset:c,maxWidth:p,lineHeight:b},...v};return O.useMemo(()=>{var q,U,X;return{layout:{padding:h},onHover:L(T,g,s),maintainAspectRatio:(q=t==null?void 0:t.chartStyling)==null?void 0:q.maintainAspectRatio,aspectRatio:(U=t==null?void 0:t.chartStyling)!=null&&U.squareAspectRatio?1:0,animation:(X=t==null?void 0:t.chartStyling)!=null&&X.performanceMode?!1:{duration:rt.FAST,onComplete:i},hover:{mode:be.Nearest,intersect:!0},elements:{line:{pointStyle:st.Circle,showLine:f,tension:0}},scales:G,plugins:re,events:Object.values(lt)}},[n,t,e,s])},pr=({options:e,resetZoom:n})=>{const{graph:t,legend:r}=e,s=O.useCallback((i,l)=>{const{event:o}=l;return o.type===Wt?(n(),!1):!0},[n]);return O.useMemo(()=>[...ot(t,r),{id:"customEventCatcher",beforeEvent:s}],[s])},hr=(e,n)=>{var t,r;O.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)=>{O.useEffect(()=>{Ss(e,n)},[e.panEnabled,e.lineEnabled,e.pointsEnabled,e.legendEnabled,e.enableDragPoints,e.zoomEnabled])},Tr=({options:e,state:n,persistenceId:t})=>{const r=O.useMemo(()=>n,[n]),s=O.useMemo(()=>e,[e]);_r(r,t),hr(r,s)},Te=" ",Er="rgba(0, 0, 0, 0.5)",xr=e=>{var n;return(n=Array.isArray(e)?e.join(Te):e)==null?void 0:n.split(Te)},Pr=({ctx:e,lines:n,lineHeight:t,x:r,y:s,position:i})=>{n==null||n.forEach((l,o)=>{const u=i!=null&&i.includes("top")?s+t*(o+1)-5:s-(n.length-1-o)*t;e==null||e.fillText(l,r,u)})},Lr=(e,n)=>{const s=n<500?.5:n<700?.7:1;return e*s},Cr=e=>{var s,i,l,o,u,d,a;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"||((u=n==null?void 0:n.options)==null?void 0:u.position)==="bottom")?(n==null?void 0:n.height)+((a=(d=n==null?void 0:n.options)==null?void 0:d.labels)==null?void 0:a.padding)*2:0;return{legendWidth:t,legendHeight:r}},Or=(e,n,t,r)=>{const{chartArea:s,width:i}=n??{},l=i-8,{legendWidth:o,legendHeight:u}=Cr(n)??{};switch(e){case z.TOP_LEFT:return[(s==null?void 0:s.left)+t+o,(s==null?void 0:s.top)+r+u];case z.TOP_CENTER:return[(s==null?void 0:s.left)+(s==null?void 0:s.width)/2,(s==null?void 0:s.top)+r+u];case z.TOP_RIGHT:return[l-t,(s==null?void 0:s.top)+r+u];case z.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 z.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 z.MIDDLE_RIGHT:return[l-t-o,(s==null?void 0:s.top)+(s==null?void 0:s.height)/2];case z.BOTTOM_LEFT:return[(s==null?void 0:s.left)+t+o,(s==null?void 0:s.bottom)-r-u];case z.BOTTOM_CENTER:return[(s==null?void 0:s.left)+(s==null?void 0:s.width)/2,(s==null?void 0:s.bottom)-r-u];case z.BOTTOM_RIGHT:default:return[l-t-o,(s==null?void 0:s.bottom)-r-u]}},Sr=e=>e!=null&&e.includes(V.Center)?V.Center:e!=null&&e.includes(V.Left)?V.Left:V.Right,Nr=(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 c,p;if(!e)return;const{text:t,maxWidth:r,fontSize:s,lineHeight:i,x:l,y:o,position:u}=n??{},d=xr(t),a=Nr(d,r,e);(c=e==null?void 0:e.save)==null||c.call(e),e.font=`${s}px Arial`,e.fillStyle=Er,e.textAlign=Sr(u),Pr({ctx:e,lines:a,lineHeight:i,x:l,y:o,position:u}),(p=e==null?void 0:e.restore)==null||p.call(e)},Dr={id:"chartAreaText",beforeDraw:(e,n,t)=>{const{showLabel:r,text:s,fontSize:i,xOffset:l,yOffset:o,lineHeight:u,maxWidth:d,position:a}=t??{};if(!r||!s)return;const{ctx:c,chartArea:p}=e??{};if(!c||!p)return;const b=Lr(d,p.width),[h,m]=Or(a,e,l,o);wr(c,{text:s,maxWidth:b,fontSize:i,lineHeight:u,x:h,y:m,position:a})}},Vn=(e,n,t,r,s)=>{const i=n.getBoundingClientRect(),l=e.clientX-i.left,o=e.clientY-i.top,u=t==null?void 0:t[r],d=t==null?void 0:t[s],a=(u==null?void 0:u.getValueForPixel(l))??-1,c=(d==null?void 0:d.getValueForPixel(o))??-1;return{x:a,y:c}},Ee=e=>{const{xMin:n,xMax:t,yMin:r,yMax:s,xValue:i,yValue:l,type:o}=e??{};let u,d,a,c;return!S.isNil(n)&&!S.isNil(t)&&!S.isNil(r)&&!S.isNil(s)&&o===B.BOX?(u=(n+t)/2,d=(r+s)/2,a=t-n,c=s-r):!S.isNil(i)&&!S.isNil(l)&&o===B.POINT&&(u=i,d=l,a=0,c=0),{centerX:u,centerY:d,width:a,height:c}},Bn=(e,n,t,r)=>{const{xMin:s,xMax:i,yMin:l,yMax:o,xValue:u,yValue:d,type:a}=e??{};let c,p,b,h;const m=n==null?void 0:n[t],_=n==null?void 0:n[r];if(!m||!_)return{centerX:-1,centerY:-1,width:0,height:0};if(!S.isNil(s)&&!S.isNil(i)&&!S.isNil(l)&&!S.isNil(o)&&a===B.BOX){const P=(s+i)/2,f=(l+o)/2,T=(m==null?void 0:m.getPixelForValue(s))??0,g=(m==null?void 0:m.getPixelForValue(i))??0,x=(_==null?void 0:_.getPixelForValue(l))??0,L=(_==null?void 0:_.getPixelForValue(o))??0;b=T-g,h=x-L,c=(m==null?void 0:m.getPixelForValue(P))??-1,p=(_==null?void 0:_.getPixelForValue(f))??-1}else!S.isNil(u)&&!S.isNil(d)&&a===B.POINT&&(b=0,h=0,c=(m==null?void 0:m.getPixelForValue(u))??-1,p=(_==null?void 0:_.getPixelForValue(d))??-1);return{centerX:c,centerY:p,width:b,height:h}},Ar=({x:e,y:n,chartArea:t,scales:r,metrics:s,resizable:i=!1,dragRange:l,annotationType:o,xScaleID:u,yScaleID:d})=>{if(i&&!l)return!0;if(l){const _=e!==void 0&&l.x?e>=l.x[0]&&e<=l.x[1]:!0,P=n!==void 0&&l.y?n>=l.y[0]&&n<=l.y[1]:!0;return _&&P}const a=r==null?void 0:r[u],c=r==null?void 0:r[d];if(!(r!=null&&r[u])||!(r!=null&&r[d]))return!1;const p=(a==null?void 0:a.getValueForPixel(t.left))??Number.NEGATIVE_INFINITY,b=(a==null?void 0:a.getValueForPixel(t.right))??Number.POSITIVE_INFINITY,h=(c==null?void 0:c.getValueForPixel(t.bottom))??Number.NEGATIVE_INFINITY,m=(c==null?void 0:c.getValueForPixel(t.top))??Number.POSITIVE_INFINITY;if(o===B.POINT){const _=e!==void 0?e>=p&&e<=b:!0,P=n!==void 0?n>=h&&n<=m:!0;return _&&P}if(o===B.BOX&&s.width!==void 0&&s.height!==void 0){const _=e!==void 0?e-s.width/2:void 0,P=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&&P!==void 0?_>=p&&P<=b:!0,x=f!==void 0&&T!==void 0?f>=h&&T<=m:!0;return g&&x}return!0},pn=(e,n,t,r,s,i,l,o)=>{if(!(r!=null&&r.chartArea))return;const{resizable:u,dragRange:d=null}=t??{};Ar({[e]:n,chartArea:r.chartArea,scales:s,resizable:u,dragRange:d,metrics:o||{},annotationType:t.type,xScaleID:i,yScaleID:l})&&(t.type===B.POINT?e==="x"?t.xValue=n:e==="y"&&(t.yValue=n):t.type===B.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)))},Un=(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)},Mr=(e,n,t,r,s,i)=>{const l=i?r==null?void 0:r[i]:null;if(!l)return;const{xScaleID:o="x",yScaleID:u="y"}=l,{x:d,y:a}=Vn(e,n,t,o,u),c=Ee(l);if(l&&l.enableDrag&&!S.isNil(c.centerY)&&!S.isNil(c.centerX)){!S.isNil(n)&&!S.isNil(n.style)&&(n.style.cursor=Be.Move);const p=d-c.centerX,b=a-c.centerY;s(!0,l,p,b),l!=null&&l.onDragStart&&l.onDragStart({x:d,y:a},l)}},Fr=(e,n,t,r,s,i,l,o)=>{var u,d,a,c,p,b;if(r&&s){!S.isNil(n)&&!S.isNil(n.style)&&(n.style.cursor=Be.Move);const h=s==null?void 0:s.id;Un(o,h,Ve.HOVERED);const m=(s==null?void 0:s.dragAxis)??le.Both,{xScaleID:_="x",yScaleID:P="y"}=s,{x:f,y:T}=Vn(e,n,t,_,P),g=Ee(s);let x=f-i,L=T-l;m!==le.Y&&pn(le.X,x,s,o,t,_,P,g),m!==le.X&&pn(le.Y,L,s,o,t,_,P,g),(u=o==null?void 0:o.update)==null||u.call(o),s!=null&&s.onDrag&&s.onDrag({x:f,y:T},s);const{ctx:y,width:C,height:N}=o,{centerX:w,centerY:F}=Ee(s)??{},{centerX:D,centerY:j}=Bn(s,t,_,P);if(!S.isNil(w)&&!S.isNil(F)&&!S.isNil(D)&&!S.isNil(j)&&((d=y==null?void 0:y.save)==null||d.call(y),(a=y==null?void 0:y.clearRect)==null||a.call(y,0,0,C,N),(c=o==null?void 0:o.draw)==null||c.call(o),y.font=it,y.fillStyle="black",s!=null&&s.displayDragCoordinates)){let G=D-45,v=j-20;const R=`X: ${ne(w,2)}, Y: ${ne(F,2)}`,I=14;v-I<0&&(v=j+I+15),v>N&&(v=N-7),(p=y==null?void 0:y.fillText)==null||p.call(y,R,G,v),(b=y==null?void 0:y.restore)==null||b.call(y)}}},vr=(e,n,t,r,s)=>{if(e&&n){const i=n==null?void 0:n.id;Un(t,i,Ve.ZERO);const{centerX:l=-1,centerY:o=-1}=Ee(n)??{};S.isNil(n==null?void 0:n.onDragEnd)||n==null||n.onDragEnd({x:l,y:o},n),!S.isNil(r)&&!S.isNil(r.style)&&(r.style.cursor=Be.Pointer),s(!1,null)}},Ir=(e,n,t)=>{!e||!n||Object.values(n).forEach(r=>{var s,i,l,o;if(r.type===B.POINT&&!S.isNil(r==null?void 0:r.label)&&((s=r==null?void 0:r.label)!=null&&s.display)){const{content:u,font:d,color:a,position:c,padding:p}=(r==null?void 0:r.label)??{},{xScaleID:b="x",yScaleID:h="y"}=r;(i=e==null?void 0:e.save)==null||i.call(e),e.font=d,e.fillStyle=a;const{centerX:m=-1,centerY:_=-1}=Bn(r,t,b,h),P=e.measureText(u).width;let f=m-P/2,T=_+20;switch(c){case oe.Top:T=_-20;break;case oe.Left:f=m-P-p,T=_;break;case oe.Right:f=m+p,T=_;break}(l=e==null?void 0:e.fillText)==null||l.call(e,u,f,T),(o=e==null?void 0:e.restore)==null||o.call(e)}})},kr={id:"annotationDraggerPlugin",beforeDraw(e){var s,i,l,o,u,d,a,c;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;Ir(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?((d=(u=e==null?void 0:e.options)==null?void 0:u.plugins)!=null&&d.tooltip&&(e.options.plugins.tooltip.enabled=!1),e.options.hover={mode:void 0,intersect:!1}):((c=(a=e==null?void 0:e.options)==null?void 0:a.plugins)!=null&&c.tooltip&&(e.options.plugins.tooltip.enabled=!0),e.options.hover={mode:be.Nearest,intersect:!0})},afterUpdate(e){var p,b,h,m,_,P,f,T;const{canvas:n,scales:t,hoveredAnnotationId:r}=e??{},s=((b=(p=e==null?void 0:e.options)==null?void 0:p.plugins)==null?void 0:b.annotationDraggerPlugin)||{enabled:!1};if(!n||!t||!s)return;const i={...t,x:t.x,y:t.y};let l=((m=(h=e.options.plugins)==null?void 0:h.annotation)==null?void 0:m.annotations)??{};if(!e&&!l)return;s.enabled?((P=(_=e==null?void 0:e.options)==null?void 0:_.plugins)!=null&&P.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,u,d,a=null;const c=(g,x,L,y)=>{o=g,a=x,L!==void 0&&y!==void 0&&(u=L,d=y)};!n.dataset.annotationDraggerInitialized&&s.enabled&&r&&(n.addEventListener(J.MOUSEDOWN,g=>{var x,L,y;Mr(g,n,i,(y=(L=(x=e==null?void 0:e.options)==null?void 0:x.plugins)==null?void 0:L.annotation)==null?void 0:y.annotations,c,e.hoveredAnnotationId)}),n.addEventListener(J.MOUSEMOVE,g=>{S.debounce(()=>Fr(g,n,i,o,a,u,d,e),5)()}),n.addEventListener(J.MOUSEUP,g=>{const x=g.currentTarget;vr(o,a,e,x,c)}),n.dataset.annotationDraggerInitialized="true"),s.enabled||(n.removeEventListener(J.MOUSEDOWN,()=>{}),n.removeEventListener(J.MOUSEMOVE,()=>{}),n.removeEventListener(J.MOUSEUP,()=>{}),n.dataset.annotationDraggerInitialized="")}};ft.register(gt,mt,bt,yt,pt,ht,_t,Tt,Et,xt,Pt,Qt,Dr,kr,os);const jr=e=>{var w,F;at();const n=O.useRef(null),{table:t,headerComponent:r,subheaderComponent:s}=e??{},{translations:i,languageKey:l}=ss(),o=Rn(e),{data:{datasets:u}={datasets:[]},options:d,testId:a,persistenceId:c,controlsPortalId:p}=o,{annotations:b,axes:h,chartStyling:m,graph:_}=d??{},P=!((F=(w=d==null?void 0:d.legend)==null?void 0:w.customLegend)!=null&&F.customLegendContainerID),[f,T]=O.useReducer(Ls,{options:d,persistenceId:c},Ns),g=O.useMemo(()=>tr(u,f,d,i),[f.lineEnabled,f.pointsEnabled,u,h,b,_]);Tr({options:d,state:f,persistenceId:c});const{resetZoom:x,handleKeyDown:L,handleKeyUp:y}=He({chartRef:n,state:f,options:d,dispatch:T,generatedDatasets:g}),C=yr({chartRef:n,state:f,options:d,dispatch:T,generatedDatasets:g}),N=pr({options:d,resetZoom:x});return E.jsxs("div",{className:dt(m,Se),style:{width:m.width||Ae,height:m.height||Ae},tabIndex:0,onKeyDown:L,onKeyUp:y,"data-testid":a,children:[E.jsx(Gn,{table:t,headerComponent:r,subheaderComponent:s,chartRef:n,state:f,options:d,dispatch:T,generatedDatasets:g,translations:i,controlsPortalId:p}),t&&f.showTable?E.jsx("div",{className:Se.table,children:t}):E.jsx($t,{backend:Zt,context:window,children:E.jsxs("div",{className:Se.canvas,id:"canvas",children:[E.jsx(ct,{ref:n,data:{datasets:g},options:C,plugins:N}),P&&!!g.length&&E.jsx(Kt,{chartRef:n,legendConfig:{options:d,generatedDatasets:g,chartType:Jt.LINE}})]})})]},Vs(f,d,l))},Gr=e=>{const{options:n}=Rn(e);return E.jsx(ut,{options:n,children:E.jsx(jr,{...e})})};Gr.__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{Gr as L,Yr as i};
|