@oliasoft-open-source/charts-library 5.2.1-beta-8 → 5.2.1-beta-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.
- package/dist/assets/Color-AVL7NMMY-CqDJ8ZOT.js +1 -0
- package/dist/assets/DocsRenderer-PQXLIZUC-D_u5u9z2.js +2 -0
- package/dist/assets/bar-chart-const-D_44J3Hs.js +1 -0
- package/dist/assets/bar-chart.stories-xE70f9TR.js +145 -0
- package/dist/assets/client-Ciqut_YX.js +1 -0
- package/dist/assets/components-9epRxl4J.js +1 -0
- package/dist/assets/get-custom-legend-plugin-example-CGyRL0oI.js +1 -0
- package/dist/assets/get-draggableData-BVJ5iVjR.js +2 -0
- package/dist/assets/iframe-DwZM_ZTV.js +2349 -0
- package/dist/assets/legend-DX1GE7eL.js +1266 -0
- package/dist/assets/legend-context-EFDEFPqT.js +47 -0
- package/dist/assets/line-chart-DA2zDhY7.js +1 -0
- package/dist/assets/line-chart.stories-2jpvKnZZ.js +1162 -0
- package/dist/assets/{line-chart.test-case.stories-BherIy2k.js → line-chart.test-case.stories-BtymlJdg.js} +4 -4
- package/dist/assets/pie-chart.stories-BitiqvNU.js +45 -0
- package/dist/assets/preload-helper-Dr7BywEQ.js +1 -0
- package/dist/assets/react-18-DuDr_33m.js +1 -0
- package/dist/assets/react-6r188Yvx.js +1 -0
- package/dist/assets/scatter-chart.stories-Dx00FKXF.js +41 -0
- package/dist/iframe.html +2 -2
- package/dist/index.js +39708 -4959
- package/dist/project.json +1 -1
- package/dist/vite-inject-mocker-entry.js +8 -18
- package/package.json +2 -2
- package/dist/assets/Color-AVL7NMMY-CS12GsAp.js +0 -1
- package/dist/assets/DocsRenderer-PQXLIZUC-GzKWCIKM.js +0 -2
- package/dist/assets/bar-chart-const-Cgj9sgUU.js +0 -1
- package/dist/assets/bar-chart.stories-DiVXSfzm.js +0 -136
- package/dist/assets/client-YjsYyvlT.js +0 -1
- package/dist/assets/get-custom-legend-plugin-example-DoKp_ti3.js +0 -1
- package/dist/assets/get-draggableData-C4lfrQc8.js +0 -2
- package/dist/assets/iframe-DCxgzTof.js +0 -2359
- package/dist/assets/index-C0sntNAo.js +0 -1
- package/dist/assets/legend-CkDoV6Ma.js +0 -1372
- package/dist/assets/legend-context-Byc4ADTV.js +0 -68
- package/dist/assets/line-chart-B8LdJRW7.js +0 -1
- package/dist/assets/line-chart.stories-DMNBRfTA.js +0 -1162
- package/dist/assets/pie-chart.stories-CqXDaxxI.js +0 -45
- package/dist/assets/preload-helper-PPVm8Dsz.js +0 -1
- package/dist/assets/react-18-2D2yOiaU.js +0 -1
- package/dist/assets/scatter-chart.stories-CzHmKRFZ.js +0 -41
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as A,j as p}from"./iframe-DCxgzTof.js";import{V as Vt,W as Bt,X as qe,Y as $,d as z,Z as Ut,R as D,e as R,P as ae,b as Z,_ as ke,$ as Xt,g as Se,c as Yt,S as Ht,D as Wt,L as qt,a0 as ie,a1 as re,r as K,a2 as de,f as Le,h as $t,T as Zt,j as $e,k as Kt,l as Ge,m as Jt,n as W,o as Qt,p as en,B as Ze,a3 as tn,s as nn,a4 as on,x as sn,a5 as F,a6 as ze,a7 as se,U as an,a8 as q,t as rn,u as ln,v as cn,a9 as un,C as dn,y as gn,z as fn,E as pn,F as hn,G as mn,I as bn,J as xn,K as yn,M as An,N as _n,O as Tn}from"./legend-context-Byc4ADTV.js";import{o as De,M as Ve,T as fe,B as V,p as Dn,q as En,r as Ke,s as On,v as Pn,P as Sn,w as Ln,x as Cn,y as wn,N as Je,z as In,S as Nn,j as Mn,h as vn,F as Rn,c as ht,A as Fn,E as jn,l as kn,G as Gn,J as zn,K as Vn,O as Bn,U as Un,a as Xn,u as Yn,Z as Hn,t as Wn,Q as qn,D as $n,H as Zn,L as Kn,C as Jn,b as Qn}from"./legend-CkDoV6Ma.js";import{d as eo,C as to,f as Qe,g as no,a as oo}from"./get-draggableData-C4lfrQc8.js";const so=(e,t,n)=>{const[o,s]=e.major,[a,i]=e.minor,r=(o.x+s.x+a.x+i.x)/4,l=(o.y+s.y+a.y+i.y)/4,u=s.x-o.x,c=s.y-o.y,d=Math.atan2(n.getPixelForValue(l+c/2)-n.getPixelForValue(l-c/2),t.getPixelForValue(r+u/2)-t.getPixelForValue(r-u/2)),f=Math.hypot(t.getPixelForValue(o.x)-t.getPixelForValue(s.x),n.getPixelForValue(o.y)-n.getPixelForValue(s.y))/2,g=Math.hypot(t.getPixelForValue(a.x)-t.getPixelForValue(i.x),n.getPixelForValue(a.y)-n.getPixelForValue(i.y))/2,m=t.getPixelForValue(r),b=n.getPixelForValue(l);return{cx:m,cy:b,radiusX:f,radiusY:g,angle:d}},ao=e=>e.data.datasets.some(t=>t.data.some(n=>!!n.ellipsePoints)),io={id:"ellipsisAnnotationPlugin",afterDatasetsDraw(e){if(!ao(e))return;const t=e?.ctx,n=e?.scales?.x,o=e?.scales?.y,s=e?.chartArea;!n||!o||!s||(t?.save?.(),t?.beginPath?.(),t?.rect?.(s.left,s.top,s.right-s.left,s.bottom-s.top),t?.clip?.(),e?.data?.datasets?.forEach(a=>{const i=a;i?.data?.forEach(r=>{const{ellipsePoints:l}=r??{};if(!l)return;const{cx:u,cy:c,radiusX:d,radiusY:f,angle:g}=so(l,n,o);t?.save?.(),t?.beginPath?.(),t?.ellipse?.(u,c,d,f,g,0,2*Math.PI),t.strokeStyle=i.borderColor||Vt,t.lineWidth=i.borderWidth||1,t?.stroke?.(),t?.restore?.()})}),t?.restore?.())}},ro="_chart_e3qdd_1",lo="_canvas_e3qdd_11",co="_fixedHeight_e3qdd_20",uo="_stretchHeight_e3qdd_26",go="_squareAspectRatio_e3qdd_32",fo="_table_e3qdd_62",Ee={chart:ro,canvas:lo,fixedHeight:co,stretchHeight:uo,squareAspectRatio:go,table:fo};var mt=Symbol.for("immer-nothing"),et=Symbol.for("immer-draftable"),L=Symbol.for("immer-state");function N(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var J=Object.getPrototypeOf;function Q(e){return!!e&&!!e[L]}function U(e){return e?bt(e)||Array.isArray(e)||!!e[et]||!!e.constructor?.[et]||Ae(e)||_e(e):!1}var po=Object.prototype.constructor.toString();function bt(e){if(!e||typeof e!="object")return!1;const t=J(e);if(t===null)return!0;const n=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return n===Object?!0:typeof n=="function"&&Function.toString.call(n)===po}function pe(e,t){ye(e)===0?Reflect.ownKeys(e).forEach(n=>{t(n,e[n],e)}):e.forEach((n,o)=>t(o,n,e))}function ye(e){const t=e[L];return t?t.type_:Array.isArray(e)?1:Ae(e)?2:_e(e)?3:0}function Ce(e,t){return ye(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function xt(e,t,n){const o=ye(e);o===2?e.set(t,n):o===3?e.add(n):e[t]=n}function ho(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function Ae(e){return e instanceof Map}function _e(e){return e instanceof Set}function B(e){return e.copy_||e.base_}function we(e,t){if(Ae(e))return new Map(e);if(_e(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);const n=bt(e);if(t===!0||t==="class_only"&&!n){const o=Object.getOwnPropertyDescriptors(e);delete o[L];let s=Reflect.ownKeys(o);for(let a=0;a<s.length;a++){const i=s[a],r=o[i];r.writable===!1&&(r.writable=!0,r.configurable=!0),(r.get||r.set)&&(o[i]={configurable:!0,writable:!0,enumerable:r.enumerable,value:e[i]})}return Object.create(J(e),o)}else{const o=J(e);if(o!==null&&n)return{...e};const s=Object.create(o);return Object.assign(s,e)}}function Be(e,t=!1){return Te(e)||Q(e)||!U(e)||(ye(e)>1&&(e.set=e.add=e.clear=e.delete=mo),Object.freeze(e),t&&Object.entries(e).forEach(([n,o])=>Be(o,!0))),e}function mo(){N(2)}function Te(e){return Object.isFrozen(e)}var bo={};function X(e){const t=bo[e];return t||N(0,e),t}var le;function yt(){return le}function xo(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function tt(e,t){t&&(X("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Ie(e){Ne(e),e.drafts_.forEach(yo),e.drafts_=null}function Ne(e){e===le&&(le=e.parent_)}function nt(e){return le=xo(le,e)}function yo(e){const t=e[L];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function ot(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return e!==void 0&&e!==n?(n[L].modified_&&(Ie(t),N(4)),U(e)&&(e=he(t,e),t.parent_||me(t,e)),t.patches_&&X("Patches").generateReplacementPatches_(n[L].base_,e,t.patches_,t.inversePatches_)):e=he(t,n,[]),Ie(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==mt?e:void 0}function he(e,t,n){if(Te(t))return t;const o=t[L];if(!o)return pe(t,(s,a)=>st(e,o,t,s,a,n)),t;if(o.scope_!==e)return t;if(!o.modified_)return me(e,o.base_,!0),o.base_;if(!o.finalized_){o.finalized_=!0,o.scope_.unfinalizedDrafts_--;const s=o.copy_;let a=s,i=!1;o.type_===3&&(a=new Set(s),s.clear(),i=!0),pe(a,(r,l)=>st(e,o,s,r,l,n,i)),me(e,s,!1),n&&e.patches_&&X("Patches").generatePatches_(o,n,e.patches_,e.inversePatches_)}return o.copy_}function st(e,t,n,o,s,a,i){if(Q(s)){const r=a&&t&&t.type_!==3&&!Ce(t.assigned_,o)?a.concat(o):void 0,l=he(e,s,r);if(xt(n,o,l),Q(l))e.canAutoFreeze_=!1;else return}else i&&n.add(s);if(U(s)&&!Te(s)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;he(e,s),(!t||!t.scope_.parent_)&&typeof o!="symbol"&&Object.prototype.propertyIsEnumerable.call(n,o)&&me(e,s)}}function me(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Be(t,n)}function Ao(e,t){const n=Array.isArray(e),o={type_:n?1:0,scope_:t?t.scope_:yt(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let s=o,a=Ue;n&&(s=[o],a=ce);const{revoke:i,proxy:r}=Proxy.revocable(s,a);return o.draft_=r,o.revoke_=i,r}var Ue={get(e,t){if(t===L)return e;const n=B(e);if(!Ce(n,t))return _o(e,n,t);const o=n[t];return e.finalized_||!U(o)?o:o===Oe(e.base_,t)?(Pe(e),e.copy_[t]=ve(o,e)):o},has(e,t){return t in B(e)},ownKeys(e){return Reflect.ownKeys(B(e))},set(e,t,n){const o=At(B(e),t);if(o?.set)return o.set.call(e.draft_,n),!0;if(!e.modified_){const s=Oe(B(e),t),a=s?.[L];if(a&&a.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(ho(n,s)&&(n!==void 0||Ce(e.base_,t)))return!0;Pe(e),Me(e)}return e.copy_[t]===n&&(n!==void 0||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_[t]=!0),!0},deleteProperty(e,t){return Oe(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,Pe(e),Me(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const n=B(e),o=Reflect.getOwnPropertyDescriptor(n,t);return o&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:o.enumerable,value:n[t]}},defineProperty(){N(11)},getPrototypeOf(e){return J(e.base_)},setPrototypeOf(){N(12)}},ce={};pe(Ue,(e,t)=>{ce[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});ce.deleteProperty=function(e,t){return ce.set.call(this,e,t,void 0)};ce.set=function(e,t,n){return Ue.set.call(this,e[0],t,n,e[0])};function Oe(e,t){const n=e[L];return(n?B(n):e)[t]}function _o(e,t,n){const o=At(t,n);return o?"value"in o?o.value:o.get?.call(e.draft_):void 0}function At(e,t){if(!(t in e))return;let n=J(e);for(;n;){const o=Object.getOwnPropertyDescriptor(n,t);if(o)return o;n=J(n)}}function Me(e){e.modified_||(e.modified_=!0,e.parent_&&Me(e.parent_))}function Pe(e){e.copy_||(e.copy_=we(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var To=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(t,n,o)=>{if(typeof t=="function"&&typeof n!="function"){const a=n;n=t;const i=this;return function(l=a,...u){return i.produce(l,c=>n.call(this,c,...u))}}typeof n!="function"&&N(6),o!==void 0&&typeof o!="function"&&N(7);let s;if(U(t)){const a=nt(this),i=ve(t,void 0);let r=!0;try{s=n(i),r=!1}finally{r?Ie(a):Ne(a)}return tt(a,o),ot(s,a)}else if(!t||typeof t!="object"){if(s=n(t),s===void 0&&(s=t),s===mt&&(s=void 0),this.autoFreeze_&&Be(s,!0),o){const a=[],i=[];X("Patches").generateReplacementPatches_(t,s,a,i),o(a,i)}return s}else N(1,t)},this.produceWithPatches=(t,n)=>{if(typeof t=="function")return(i,...r)=>this.produceWithPatches(i,l=>t(l,...r));let o,s;return[this.produce(t,n,(i,r)=>{o=i,s=r}),o,s]},typeof e?.autoFreeze=="boolean"&&this.setAutoFreeze(e.autoFreeze),typeof e?.useStrictShallowCopy=="boolean"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){U(e)||N(8),Q(e)&&(e=Do(e));const t=nt(this),n=ve(e,void 0);return n[L].isManual_=!0,Ne(t),n}finishDraft(e,t){const n=e&&e[L];(!n||!n.isManual_)&&N(9);const{scope_:o}=n;return tt(o,t),ot(void 0,o)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const s=t[n];if(s.path.length===0&&s.op==="replace"){e=s.value;break}}n>-1&&(t=t.slice(n+1));const o=X("Patches").applyPatches_;return Q(e)?o(e,t):this.produce(e,s=>o(s,t))}};function ve(e,t){const n=Ae(e)?X("MapSet").proxyMap_(e,t):_e(e)?X("MapSet").proxySet_(e,t):Ao(e,t);return(t?t.scope_:yt()).drafts_.push(n),n}function Do(e){return Q(e)||N(10,e),_t(e)}function _t(e){if(!U(e)||Te(e))return e;const t=e[L];let n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=we(e,t.scope_.immer_.useStrictShallowCopy_)}else n=we(e,!0);return pe(n,(o,s)=>{xt(n,o,_t(s))}),t&&(t.finalized_=!1),n}var C=new To,Eo=C.produce;C.produceWithPatches.bind(C);C.setAutoFreeze.bind(C);C.setUseStrictShallowCopy.bind(C);C.applyPatches.bind(C);C.createDraft.bind(C);C.finishDraft.bind(C);const Tt="TOGGLE_ZOOM",Dt="TOGGLE_PAN",Et="TOGGLE_POINTS",Ot="TOGGLE_LINE",Pt="TOGGLE_LEGEND",St="TOGGLE_TABLE",Re="RESET_AXES_RANGES",Fe="UPDATE_AXES_RANGES",Lt="TOGGLE_DRAG_POINTS",Ct="TOGGLE_DRAG_ANNOTATION",wt="DISABLE_DRAG_OPTIONS",ge="UPDATE_EDITED",Oo=(e,t)=>Eo(e,n=>{switch(t.type){case Tt:{n.zoomEnabled=!n.zoomEnabled,n.panEnabled&&(n.panEnabled=!1),n.enableDragPoints&&(n.enableDragPoints=!1),n.enableDragAnnotation&&(n.enableDragAnnotation=!1);break}case Dt:{n.panEnabled=!n.panEnabled,n.zoomEnabled&&(n.zoomEnabled=!1),n.enableDragPoints&&(n.enableDragPoints=!1),n.enableDragAnnotation&&(n.enableDragAnnotation=!1);break}case Et:{n.pointsEnabled=!n.pointsEnabled;break}case Ot:{n.lineEnabled=!n.lineEnabled;break}case Pt:{n.legendEnabled=!n.legendEnabled;break}case St:{n.showTable=!n.showTable;break}case Fe:{const{axes:o}=t.payload;n.axes=o;break}case Re:{const{axes:o}=t.payload;n.axes=o;break}case Lt:{n.enableDragPoints=!n.enableDragPoints,n.panEnabled&&(n.panEnabled=!1),n.zoomEnabled&&(n.zoomEnabled=!1),n.enableDragAnnotation&&(n.enableDragAnnotation=!1);break}case Ct:{n.enableDragAnnotation=!n.enableDragAnnotation,n.panEnabled&&(n.panEnabled=!1),n.zoomEnabled&&(n.zoomEnabled=!1);break}case wt:{(n.enableDragAnnotation||n.enableDragPoints||n.panEnabled||n.zoomEnabled)&&(n.enableDragAnnotation=!1,n.enableDragPoints=!1,n.panEnabled=!1,n.zoomEnabled=!1);break}case ge:{n.edited=t.payload;break}}}),Po=e=>{if(!e)return null;const t=`line-chart-state-${e}`,n=localStorage.getItem(t);return n?JSON.parse(n).state:null},So=(e=72)=>{const t=new Date().getTime(),n=e*60*60*1e3;for(let o=0;o<localStorage.length;o++){const s=localStorage.key(o);if(s?.includes("line-chart-state-")){const a=localStorage.getItem(s);if(a){const r=JSON.parse(a).timestamp;r&&t-r>n&&localStorage.removeItem(s)}}}},Lo=(e,t)=>{if(!t)return;const n=new Date().getTime(),o=`line-chart-state-${t}`,s={state:e,timestamp:n};localStorage.setItem(o,JSON.stringify(s)),So()},Co=({options:e,persistenceId:t})=>{const{chartOptions:{enableZoom:n,enablePan:o,showPoints:s,showLine:a,enableDragAnnotation:i},legend:{display:r},dragData:l}=e,{zoomEnabled:u,panEnabled:c,pointsEnabled:d,lineEnabled:f,legendEnabled:g,enableDragPoints:m,enableDragAnnotation:b}=Po(t)||{};return{zoomEnabled:i??b?!1:u??n,panEnabled:c??o,pointsEnabled:d??s,lineEnabled:f??a,legendEnabled:g??r,axes:[],showTable:!1,enableDragPoints:l?.enableDragData&&m,enableDragAnnotation:i??b,edited:!1}},wo=e=>A.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},A.createElement("clipPath",{id:"a"},A.createElement("path",{d:"m0 0h12v12h-12z"})),A.createElement("g",{clipPath:"url(#a)"},A.createElement("path",{d:"m.5 6.5v-1h11v1c-4.16104 0-6.63549 0-11 0z"}))),Io=e=>A.createElement("svg",{fill:"currentColor",height:"1em",viewBox:"0 0 12 12",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e},A.createElement("circle",{cx:6,cy:6,r:2})),No=e=>A.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},A.createElement("clipPath",{id:"a"},A.createElement("path",{d:"m0 0h12v12h-12z"})),A.createElement("g",{clipPath:"url(#a)"},A.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 Mo({lineEnabled:e,onToggleLine:t,onTogglePoints:n,pointsEnabled:o,translations:s}){return[{type:"Option",label:s.pointsLines,icon:p.jsx(De,{icon:p.jsx(No,{})}),selected:o&&e,onClick:()=>{o||n(),e||t()}},{type:"Option",label:s.linesOnly,icon:p.jsx(De,{icon:p.jsx(wo,{})}),selected:!o&&e,onClick:()=>{o&&n(),e||t()}},{type:"Option",label:s.pointsOnly,icon:p.jsx(De,{icon:p.jsx(Io,{})}),selected:o&&!e,onClick:()=>{o||n(),e&&t()}}]}const It=({options:e})=>{const[t,n]=A.useState(!1),o=e.find(s=>s.selected);return p.jsx(Ve,{open:t,setOpen:n,menu:{sections:e,trigger:"Component",component:p.jsx(fe,{display:"inline-flex",text:o?.label,placement:"bottom-start",enabled:!t,children:p.jsx(V,{colored:"muted",basic:!0,small:!0,round:!0,icon:o?.icon})})}})};It.__docgenInfo={description:"",methods:[],displayName:"LineOptions",props:{options:{required:!0,tsType:{name:"Array",elements:[{name:"IMenuSection"}],raw:"IMenuSection[]"},description:""}}};function vo({onTogglePan:e,onToggleZoom:t,panEnabled:n,zoomEnabled:o,enableDragPoints:s,enableDragAnnotation:a,isDragDataAllowed:i,isDragAnnotationAllowed:r,onToggleDragAnnotation:l,onToggleDragPoints:u,onDisableDragOptions:c,translations:{dragToZoom:d,doubleClickToReset:f,dragToPan:g,dragToMovePoints:m,dragDisabled:b,dragToMoveAnnotation:_}}){return[{label:d,description:f,icon:p.jsx(Dn,{}),selected:o,type:"Option",onClick:()=>{o||t()}},{label:g,description:f,icon:p.jsx(En,{}),selected:n,type:"Option",onClick:()=>{n||e()}},...i?[{label:m,icon:p.jsx(Ke,{}),selected:s,type:"Option",onClick:()=>{s||u()}}]:[],...r?[{label:_,icon:p.jsx(Ke,{}),selected:a,type:"Option",onClick:()=>{a||l()}}]:[],{label:b,icon:p.jsx(On,{}),selected:!o&&!n&&!s&&!a,type:"Option",onClick:c}]}const Nt=({options:e})=>{const t=e.find(n=>n.selected);return p.jsx(Ve,{menu:{sections:e,trigger:"Component",component:p.jsx(V,{colored:"muted",basic:!0,small:!0,label:t?.label,icon:t?.icon})}})};Nt.__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 Ro="_controls_1edjs_1",Fo="_buttons_1edjs_6",at={controls:Ro,buttons:Fo},jo=e=>{const t=A.useCallback(n=>()=>{e({type:n})},[e]);return{onToggleLegend:t(Pt),onToggleLine:t(Ot),onTogglePan:t(Dt),onTogglePoints:t(Et),onToggleTable:t(St),onToggleZoom:t(Tt),onToggleDragPoints:t(Lt),onToggleDragAnnotation:t(Ct),onDisableDragOptions:t(wt)}},ko=(e,t)=>e===void 0||t===void 0||Number(e)<Number(t),Go=(e,t)=>e===void 0||t===void 0||Number(e)>Number(t),Mt=(e,t=0,n=!1)=>{const o=n&&t!==0?t+1:"";return`${e}${o}`},zo=e=>e?.match(/[^0-9/]+/gi)?.[0]??"",Us=e=>typeof e=="string"||typeof e=="number"||typeof e=="boolean"||e===null,Vo=(e,t)=>Pn({state:e,languageKey:t},{unorderedObjects:!0}),Xe=({chartRef:e,state:t,options:n,dispatch:o,generatedDatasets:s})=>{const{interactions:{onHover:a,onUnhover:i},axes:r}=n,l=A.useCallback(()=>{const x=e?.current;x&&t?.edited&&(x?.resetZoom?.(),x?.reset?.(),o({type:Re,payload:{axes:[]}}),o({type:ge,payload:!1}))},[e?.current,o,t]),u=A.useCallback((x,h,y)=>(O,P)=>{if(!P?.length&&i&&x&&(h(null),i(O)),P?.length&&a){const{index:T,datasetIndex:w}=P[0],I=y[w]?.data[T];I&&!Bt(x,I)&&(h(I),a(O,w,T,y))}},[a,i,s]),c=A.useCallback(()=>eo(e),[e?.current]),d=A.useCallback(x=>{if(x.key===qe.Shift){const h=e.current,y=h?.config?.options?.plugins?.zoom;y?.zoom?.mode&&y?.pan?.mode&&(y.zoom.mode=$.Y,y.pan.mode=$.Y,h?.update())}},[e?.current]),f=A.useCallback(x=>{if(x.key===qe.Shift){const h=e.current,y=h?.config?.options?.plugins?.zoom;y?.zoom?.mode&&y?.pan?.mode&&(y.zoom.mode=$.XY,y.pan.mode=$.XY,h?.update())}},[e?.current]),g=A.useCallback(x=>{if(!Object.keys(x)?.length)return[];const h=(y,O)=>!y[O]||!y[O]?.length?[]:y[O].map((P,T)=>({id:Mt(O,T,y[O].length>1),label:P?.label||""}));return[...h(x,z.X),...h(x,z.Y)]},[r]),m=A.useCallback(()=>{const{scales:x={}}=e?.current||{},h=Object.entries(x)?.map(([y,{min:O,max:P}])=>({id:y,min:O??0,max:P??0}));o({type:Fe,payload:{axes:h}})},[r]),b=A.useCallback(()=>{const x=e?.current;x&&t.edited&&(x?.resetZoom?.(),x?.reset?.(),o({type:Re,payload:{axes:[]}}),o({type:ge,payload:!1}))},[e?.current]),_=A.useCallback(({axes:x})=>{o({type:Fe,payload:{axes:x}})},[]),E=A.useCallback(x=>{o({type:ge,payload:x})},[t]);return{resetZoom:l,onHover:u,handleDownload:c,handleKeyDown:d,handleKeyUp:f,controlsAxesLabels:g(r),updateAxesRangesFromChart:m,onResetAxes:b,onUpdateAxes:_,onUpdateEdited:E}},it=(e,t,n)=>{const o=[];return Ut(e)&&o.push("mustHaveAValue"),n==="min"&&!ko(e,t)?o.push("mustBeLessThanMax"):n==="max"&&!Go(e,t)&&o.push("mustBeGreaterThanMin"),o},Bo=e=>{const t=e.map(({id:o,min:s,max:a})=>({id:o,min:it(String(s),String(a),"min"),max:it(String(a),String(s),"max")})),n=t.every(o=>o.min.length===0&&o.max.length===0);return{errors:t,valid:n}},rt=1,lt=({chartRef:e,state:t})=>{const n=e?.current;if(!n)return[];const o=n?.getInitialScaleBounds()??{};return Object.entries(o).map(([s,{min:a="",max:i=""}])=>{let r=Number(a),l=Number(i);isNaN(r)&&(r=0),isNaN(l)&&(l=r+rt),r===l&&(l+=rt);const{unit:u}=t?.axes?.find(c=>c.id===s)??{};return{id:s,min:r,max:l,unit:u}})},Uo=e=>{const{state:t,controlsAxesLabels:n,onUpdateAxes:o,onResetAxes:s,onUpdateEdited:a,depthType:i,translations:r,close:l,chartRef:u}=e??{},[c,d]=A.useState({localAxes:lt({chartRef:u,state:t}),depthType:i?.selectedDepthType,edited:t.edited}),{errors:f,valid:g}=Bo(c.localAxes),m=({name:h,value:y,id:O})=>{d(P=>({...P,localAxes:P.localAxes.map(T=>T.id===O?{...T,[h]:y}:T),edited:!0}))},b=({name:h,value:y,id:O})=>{d(P=>({...P,localAxes:P.localAxes.map(T=>T.id===O&&typeof T.unit=="object"?{...T,unit:{...T.unit,[h]:y}}:T),edited:!0}))},_=h=>{h.preventDefault(),g&&(o({axes:c.localAxes}),l?.()),i&&i?.setSelectedDepthType&&i?.setSelectedDepthType(c.depthType),a(c.edited)},E=()=>{d({localAxes:lt({chartRef:u,state:t}),depthType:i?.selectedDepthType,edited:!1}),s(),a(!1),l?.()},x=h=>h.target.select();return p.jsxs("form",{onSubmit:_,children:[c.localAxes.map(h=>{const O=n.find(T=>T.id===h.id)?.label||D.startCase(h.id),P=f.find(T=>T.id===h.id);return p.jsx(Cn,{label:O,children:p.jsxs(wn,{small:!0,width:"300px",children:[p.jsx(Je,{name:"min",value:h.min,error:P?.min?.[0]?r[P.min[0]]:null,width:"100%",onChange:T=>m({name:T.target.name,value:T.target.value,id:h.id}),onFocus:x}),p.jsx(In,{children:"to"}),p.jsx(Je,{name:"max",value:h.max,error:P?.max?.[0]?r[P.max[0]]:null,width:"100%",onChange:T=>m({name:T.target.name,value:T.target.value,id:h.id}),onFocus:x}),h.unit?p.jsx(Nn,{name:"selectedUnit",options:typeof h.unit!="string"?h.unit.options:[],value:typeof h.unit!="string"?h.unit.selectedUnit:void 0,onChange:T=>b({name:T.target.name,value:T.target.value,id:h.id}),autoLayerWidth:!0,width:"15%"}):null]})},h.id)}),i?.options?.length>0&&p.jsxs(p.Fragment,{children:[p.jsx(Mn,{items:i.options.map((h,y)=>({key:y,label:h})),onSelected:h=>{d(y=>({...y,depthType:i.options[h],edited:!0}))},small:!0,value:i.options.indexOf(c.depthType)}),p.jsx(vn,{})]}),p.jsxs(Rn,{gap:"8px",alignItems:"center",children:[p.jsx(V,{type:"submit",small:!0,colored:!0,label:r.done,disabled:!g||!c.edited}),p.jsx(V,{small:!0,name:"resetAxes",label:r.resetAxes,onClick:E}),p.jsx(ht,{small:!0,muted:!0,children:r.orDoubleClickToCanvas})]})]})},vt=e=>p.jsx(Sn,{placement:"bottom-start",overflowContainer:!0,content:p.jsx(Uo,{...e}),children:p.jsx(fe,{text:e.translations.axesOptions,placement:"bottom-start",display:"inline-flex",children:p.jsx(V,{small:!0,basic:!0,colored:"muted",round:!0,icon:p.jsx(Ln,{})})})});vt.__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 Rt=({table:e,headerComponent:t,subheaderComponent:n,chartRef:o,state:s,options:a,dispatch:i,generatedDatasets:r,translations:l,controlsPortalId:u})=>{const{enableDragPoints:c,lineEnabled:d,panEnabled:f,pointsEnabled:g,showTable:m,zoomEnabled:b,enableDragAnnotation:_}=s,{dragData:E,depthType:x,annotations:h}=a,{onToggleLine:y,onTogglePan:O,onTogglePoints:P,onToggleTable:T,onToggleZoom:w,onToggleDragPoints:S,onToggleDragAnnotation:I,onDisableDragOptions:j}=jo(i),{handleDownload:M,controlsAxesLabels:Y,onResetAxes:H,onUpdateAxes:ee,onUpdateEdited:k}=Xe({chartRef:o,state:s,options:a,dispatch:i,generatedDatasets:r}),[G,{width:te}]=Fn(),ue=te<200,ne=A.useMemo(()=>Mo({lineEnabled:d,onToggleLine:y,onTogglePoints:P,pointsEnabled:g,translations:l}),[d,g]),oe=A.useMemo(()=>vo({onTogglePan:O,onToggleZoom:w,panEnabled:f,zoomEnabled:b,enableDragPoints:c,enableDragAnnotation:_,isDragDataAllowed:E?.enableDragData,isDragAnnotationAllowed:h?.enableDragAnnotation,onToggleDragAnnotation:I,onToggleDragPoints:S,onDisableDragOptions:j,translations:l}),[b,f,c,E?.enableDragData,h?.enableDragAnnotation]);return p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:at.controls,children:[!!a.title&&p.jsx(ht,{bold:!0,children:a.title}),t,p.jsx(to,{controlsPortalId:u??"",children:p.jsxs("div",{className:at.buttons,ref:G,children:[!m&&p.jsxs(p.Fragment,{children:[p.jsx(vt,{chartRef:o,state:s,controlsAxesLabels:Y,onUpdateAxes:ee,onResetAxes:H,onUpdateEdited:k,depthType:x,translations:l}),ue?p.jsx(Ve,{menu:{placement:"bottom-end",sections:[...ne,{type:"Divider"},...oe,{type:"Divider"},{icon:"download",label:l.downloadAsPNG,type:"Option",onClick:M}],trigger:"Component",component:p.jsx(V,{colored:"muted",basic:!0,small:!0,round:!0,icon:"menu"})}}):p.jsxs(p.Fragment,{children:[p.jsx(It,{options:ne}),p.jsx(fe,{display:"inline-flex",text:l.downloadAsPNG,placement:"bottom-end",children:p.jsx(V,{small:!0,basic:!0,colored:"muted",round:!0,icon:"download",onClick:M})}),p.jsx(Nt,{options:oe})]})]}),e?p.jsx(fe,{display:"inline-flex",text:m?l.showChart:l.showTable,placement:"bottom-end",children:p.jsx(V,{small:!0,basic:!0,colored:"muted",round:!0,icon:m?"chart":"table",onClick:T})}):null]})})]}),n]})};Rt.__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 v={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"},ct=e=>({label:"",position:e,color:"",unit:{options:[],selectedUnit:"",setSelectedUnit:()=>{}}}),Xo=e=>({x:e?.x||[ct("bottom")],y:e?.y||[ct("left")]}),Yo=e=>({chartScaleType:e?.chartScaleType||"linear",reverse:e?.reverse||!1,beginAtZero:e?.beginAtZero??!1,stepSize:e?.stepSize,suggestedMin:e?.suggestedMin,suggestedMax:e?.suggestedMax,range:e?.range,autoAxisPadding:e?.autoAxisPadding??!1}),Ho=e=>({width:e?.width,height:e?.height,maintainAspectRatio:e?.maintainAspectRatio??!1,staticChartHeight:e?.staticChartHeight??!1,performanceMode:e?.performanceMode??!0,squareAspectRatio:e?.squareAspectRatio??!1,layoutPadding:e?.layoutPadding||{top:0,bottom:20,left:0,right:0}}),Wo=e=>({tooltips:e?.tooltips??!0,showLabelsInTooltips:e?.showLabelsInTooltips??!1,hideSimulationName:e?.hideSimulationName??!1,scientificNotation:e?.scientificNotation??!0}),qo=e=>({lineTension:e?.lineTension??.01,spanGaps:e?.spanGaps??!1,showDataLabels:e?.showDataLabels??!1,showMinorGridlines:e?.showMinorGridlines??!1}),$o=e=>e?e.map(t=>({...t,display:t?.display??!0})):[],Zo=e=>({labelAnnotation:{showLabel:e?.labelAnnotation?.showLabel??!1,text:e?.labelAnnotation?.text??"",position:e?.labelAnnotation?.position??v.BOTTOM_RIGHT,fontSize:e?.labelAnnotation?.fontSize??12,xOffset:e?.labelAnnotation?.xOffset??5,yOffset:e?.labelAnnotation?.yOffset??5,maxWidth:e?.labelAnnotation?.maxWidth??300,lineHeight:e?.labelAnnotation?.lineHeight??12},showAnnotations:e?.showAnnotations??!1,controlAnnotation:e?.controlAnnotation??!1,enableDragAnnotation:e?.enableDragAnnotation??!1,annotationsData:$o(e?.annotationsData)}),Ko=e=>({display:e?.display??!0,position:e?.position??ae.BottomLeft,align:e?.align??R.Center,customLegend:e?.customLegend??{customLegendPlugin:null,customLegendContainerID:""},usePointStyle:e?.usePointStyle??!0}),Jo=e=>({showPoints:e?.showPoints??!0,showLine:e?.showLine??!0,enableZoom:e?.enableZoom??!0,enablePan:e?.enablePan??!1,enableDragAnnotation:e?.enableDragAnnotation??!1,closeOnOutsideClick:e?.closeOnOutsideClick??!1}),Qo=e=>({onLegendClick:e?.onLegendClick,onHover:e?.onHover,onUnhover:e?.onUnhover,onAnimationComplete:e?.onAnimationComplete}),es=e=>({enableDragData:e?.enableDragData??!1,showTooltip:e?.showTooltip??!0,roundPoints:e?.roundPoints??!0,dragX:e?.dragX??!0,dragY:e?.dragY??!0,onDragStart:e?.onDragStart,onDrag:e?.onDrag,onDragEnd:e?.onDragEnd}),Ft=e=>{const t=e?.chart||{},n=t?.options||{};return{persistenceId:t?.persistenceId??"",controlsPortalId:t?.controlsPortalId??"",testId:t?.testId??void 0,data:t?.data??{datasets:[]},options:{title:n?.title??"",scales:n?.scales??{},axes:Xo(n?.axes),additionalAxesOptions:Yo(n?.additionalAxesOptions),chartStyling:Ho(n?.chartStyling),tooltip:Wo(n?.tooltip),graph:qo(n?.graph),annotations:Zo(n?.annotations),legend:Ko(n?.legend),chartOptions:Jo(n?.chartOptions),interactions:Qo(n?.interactions),dragData:es(n?.dragData),depthType:n?.depthType??{}}}},ts=(e,t)=>{if(D.isEmpty(e)||D.isEmpty(t))return!1;const n=o=>typeof t=="string"?o&&D.has(o,t):D.isArray(t)?o&&D.some(t,s=>o&&D.has(o,s)):o&&D.some(Object.values(t),s=>o&&D.has(o,s));return D.isArray(e)?D.some(e,n):n(e)};var jt=(e=>(e.showLine="showLine",e.showPoints="showPoints",e))(jt||{});const ns=(e,t,n,{label:o})=>{const s=[...e??[]],{annotations:a,graph:i}=n??{},{controlAnnotation:r,showAnnotations:l,annotationsData:u=[]}=a??{};if(r&&l){const c=u.map((d,f)=>{const{type:g,...m}=d,b=m.color??Z[f],_=Xt,E=ke.INITIAL;return{...m,isAnnotation:!0,annotationType:g,label:m.label,annotationIndex:f,backgroundColor:b,pointBackgroundColor:b,borderColor:b,borderDash:_,borderWidth:E,data:[{}]}});s.push(...c)}return s?.map((c,d)=>{const{formation:f,data:g=[],pointRadius:m,pointHoverRadius:b,borderWidth:_,borderColor:E,backgroundColor:x,pointBackgroundColor:h,borderDash:y,showPoints:O,showLine:P}=c??{},{lineEnabled:T,pointsEnabled:w,axes:S=[]}=t??{},{lineTension:I,spanGaps:j}=i??{},M=Array.isArray(g)?g:[];if(f&&M?.length){const oe=Number(S[0]?.min),Ye=Number(S[0]?.max),[He,We]=M;oe&&He?.x&&(M[0].x=Math.max(oe,He.x)),Ye&&We?.x&&(M[2].x=Math.min(Ye,We.x))}const Y=ts(c,jt),H=M?.filter(Boolean)||[],ee=H?.length===1;let k,G;O!==void 0?k=O:P===!1?k=!0:k=w||ee,P!==void 0?G=P:O===!1?G=!0:G=T;const te=parseFloat(m)||kn,ue=parseFloat(b)||jn,ne=Z[d];return{...c,label:c?.label??`${o} ${d+1}`,data:H,showLine:G,lineTension:c?.lineTension??I,spanGaps:j,borderWidth:parseFloat(_)||Vn,borderDash:y||[],borderJoinStyle:zn,borderColor:E??ne??Se(Z),backgroundColor:x??Gn,pointBackgroundColor:h??ne??Se(Z),pointRadius:k?te:0,pointHoverRadius:ue,pointHitRadius:c?.pointHitRadius??ue,...Y?{hasCustomOpt:Y}:{}}})},je=(e,t,n,o,s=0)=>{const a=o||e.axes[t][0]||{},i=n?.axes.filter(c=>c?.id?.startsWith(t))[s],r=e?.scales?.[`${s===0?t:t+s}`]?.ticks,{additionalAxesOptions:l}=e,u=()=>{const c=l?.chartScaleType===Ht.Logarithmic,d=(m,b,_)=>c?qt.includes(m)?Qe(m,_):"":Qe(m,_);return{...c?{}:{stepSize:a.stepSize??(t===z.Y?l.stepSize:null)},callback:d,includeBounds:!1,...r,font:{size:Wt}}};return{display:!0,type:l.chartScaleType,position:a.position,beginAtZero:l.beginAtZero,reverse:t===z.Y?l.reverse:!1,suggestedMax:l.suggestedMax,suggestedMin:l.suggestedMin,min:i?.min??l?.range?.[t]?.min,max:i?.max??l?.range?.[t]?.max,title:{display:a.label?.length,text:a.label,padding:0},ticks:u(),grid:{...a.gridLines}}},ut=(e,t,n)=>e.axes[t].reduce((a,i,r)=>{const l=i;l.color=i.color||Z[r]||Se(Z),l.position=i.position||Yt(t,r);const u=je(e,t,n,l,r),c=Mt(t,r,!0);return{...a,[c]:u}},{}),os=(e,t)=>{const n=e.axes.x?.length>1,o=e.axes.y?.length>1,s=n?ut(e,z.X,t):{x:je(e,z.X,t)},a=o?ut(e,z.Y,t):{y:je(e,z.Y,t)};return{...s,...a}},ss=e=>{if(!Array.isArray(e)||!e?.length)return!1;const t=e?.reduce((n,o)=>{const s=o?.xAxisID??"x",a=o?.yAxisID??"y",i=o?.data??[];if(i&&i?.length){const{x:r,y:l}=i?.[0]??{},{x:u=0,y:c=0}=i?.at(-1)??{},d=n?.[s]?.xFirst??r,f=n?.[s]?.xLast??u,g=n?.[a]?.yFirst??l,m=n?.[a]?.yLast??c,b=Math.min(r,d),_=Math.max(u,f),E=Math.min(l,g),x=Math.max(c,m);n={...n,[s]:{...n[s],xFirst:b,xLast:_},[a]:{yFirst:E,yLast:x}}}return n},{});return Object.values(t)?.some(({xFirst:n,xLast:o,yFirst:s,yLast:a})=>ie(n,o,{absoluteDiff:re})||ie(s,a,{absoluteDiff:re}))},dt=.05,as={min:-1,max:1},is=({data:e,beginAtZero:t=!1,autoAxisPadding:n=!1})=>{const o=Math.min(...e.filter(g=>g!=null&&!isNaN(g))),s=Math.max(...e.filter(g=>g!=null&&!isNaN(g))),a=Math.sign(o)===-1||Math.sign(s)===-1,i=ie(o,0,{absoluteDiff:re})&&ie(s,0,{absoluteDiff:re});if(!e?.length||i)return as;if(ie(o,s,{absoluteDiff:re})){const g=s,m=g*dt,b=t&&!a?0:g-m,_=t&&a?0:g+m,E=K(_,de),x=K(b,de);return{min:E<0?E:x,max:x<0?x:E}}if(!n)return{min:void 0,max:void 0};const r=o===0||s===0||t,l=Math.sign(o)===-1&&Math.sign(s)===1,u=Math.abs(s-o),c=n?u*dt:0,d=!l&&r&&t&&!a?0:o-c,f=!l&&r&&t&&a?0:s+c;return{min:K(d,de),max:K(f,de)}},rs=e=>e?.reduce((t,n)=>({...t,[n.annotationAxis]:[...t[n.annotationAxis]||[],+n.value]}),{}),ls=(e,t,n)=>{if(!Array.isArray(e)||!Array.isArray(t))return{};const o=rs(n);return t.reduce((s,a)=>{const i=zo(a),r=e.filter(u=>(u[`${i}AxisID`]??i)===a).flatMap(u=>(u?.data??[]).map(d=>d[i])),l=o?.[a]??[];return s[a]=[...new Set([...r,...l])],s},{})},gt=(e,t)=>!D.isNil(e)||!D.isNil(t),cs=(e,t,n)=>{const{additionalAxesOptions:o,annotations:{annotationsData:s=[],controlAnnotation:a=!1}={}}=e||{},i=os(e,t)||{},r=a?n.filter(({isAnnotation:d})=>!d):n;if(!o?.autoAxisPadding&&!ss(r))return i;const l=Object.keys(i)??[],u=ls(n,l,s);return(u&&l?.reduce((d,f)=>{const g=i[f],{min:m=void 0,max:b=void 0}=g,{min:_,max:E}=is({data:u[f],beginAtZero:o?.beginAtZero,autoAxisPadding:o?.autoAxisPadding}),x={[f]:{...g,min:m??(gt(m,b)?void 0:_),max:b??(gt(m,b)?void 0:E)}};return{...d,...x}},{}))??i},us=(e,t,n,o,s)=>{const i=e??0,r=t??0,l=n??0,u=o??0,c=s??0,d=i-100<=l,f=i+100>=u,g=i+100>=l&&i+100<u&&r+100>=c;return{overLeftSide:d,overRightSide:f,overBottomSide:g}},ds=e=>{const t=e?.chart,n=e?.dataIndex??0,o=e?.datasetIndex??0,s=t?.chartArea??{},{left:a=null,right:i=null,bottom:r=null}=s,u=t?.getDatasetMeta?.(o)?.data?.[n],c=u?.x??null,d=u?.y??null;return{x:c,y:d,left:a,right:i,bottom:r}},gs=()=>e=>{const{x:t,y:n,left:o,right:s,bottom:a}=ds(e),{overLeftSide:i=!1,overRightSide:r=!1,overBottomSide:l=!1}=us(t,n,o,s,a);return i&&R.Right||r&&R.Left||l&&R.End||R.Start},fs=e=>e?.graph?.showDataLabels?{display:Le,align:gs(),formatter:(t,n)=>{const o=n?.dataset?.data?.[n.dataIndex];return!o||o.label==null?"":typeof o.label=="string"?o.label:Array.isArray(o.label)?o.label.map(String):String(o.label)}}:{display:!1},ps=e=>{const t=e?.match(/\[(.*)\]/g);return t&&t?.length>0?t?.[0]:""},ft=(e,t)=>{let n={};return t?(Math.abs(e)<Bn||Math.abs(e)>Un)&&(n={roundScientificCoefficient:3}):n={scientific:!1},Qt(en(e),n)},hs=e=>{if(!e?.axes?.x?.length||!e?.axes?.y?.length)return console.warn("Tooltip config fallback: missing axes",e),{enabled:!1,callbacks:{}};const{scientificNotation:t}=e?.tooltip??{},n=({xAxisID:a="",yAxisID:i=""})=>{const r=a?.length>1?Number(a?.[1])-1:0,l=i?.length>1?Number(i?.[1])-1:0,u=e?.axes?.x?.[r],c=e?.axes?.y?.[l];return e?.axes?.x?.[0]?.position===ae.Top?{titleAxisLabel:c?.label||"",valueAxisLabel:u?.label||"",titleLabel:W.Y,valueLabel:W.X}:{titleAxisLabel:u?.label||"",valueAxisLabel:c?.label||"",titleLabel:W.X,valueLabel:W.Y}},o=a=>{if(!a?.[0])return"";const i=n(a[0].dataset),{titleLabel:r="",titleAxisLabel:l=""}=i??{},u=r===W.Y?a?.[0]?.parsed?.y:a?.[0]?.parsed?.x;return`${ft(u,t)} ${l}`},s=a=>{const{showLabelsInTooltips:i}=e?.tooltip??{};let r=a?.dataset?.label||"";const l=n(a?.dataset),{valueLabel:u="",valueAxisLabel:c=""}=l??{},f=(()=>{const b=u===W.X?a?.parsed?.x:a?.parsed?.y;return ft(b,t)})(),g=ps(c),m=Jt(a,i);return`${r}: ${f} ${g} ${m}`};return{enabled:e?.tooltip?.tooltips,mode:Ge.Nearest,intersect:!0,padding:Kt,usePointStyle:!0,boxWidth:$e,boxHeight:$e,boxPadding:Zt,callbacks:{title:o,label:s,afterLabel:$t}}},ms=({chartRef:e,state:t,options:n,dispatch:o,generatedDatasets:s})=>{const{interactions:{onAnimationComplete:a},annotations:{labelAnnotation:{showLabel:i,text:r,position:l,fontSize:u,xOffset:c,yOffset:d,maxWidth:f,lineHeight:g}={}},chartStyling:{layoutPadding:m}}=n,{enableDragPoints:b,zoomEnabled:_,panEnabled:E,lineEnabled:x}=t,[h,y]=A.useState(null),{updateAxesRangesFromChart:O,onHover:P,onUpdateEdited:T}=Xe({chartRef:e,state:t,options:n,dispatch:o,generatedDatasets:s}),{legend:w,customLegendPlugin:S}=Xn({chartRef:e,options:n})??{},{state:I}=Yn()??{},{annotation:j}=I??{},M=fs(n)??{},Y=hs(n)??{},H=A.useMemo(()=>cs(n,t,s),[n,t,s,e]),ee=A.useMemo(()=>b&&no(n),[b,n]),k=A.useMemo(()=>({enabled:E,mode:$.XY,onPanComplete(){O(),T(!0)}}),[E]),G=A.useMemo(()=>({mode:$.XY,drag:{enabled:_,threshold:3,backgroundColor:Hn,borderColor:Ze,borderWidth:1},onZoomComplete(){O(),T(!0)}}),[_]),te={datalabels:M,annotationDraggerPlugin:{enabled:t?.enableDragAnnotation},annotation:Wn(j),zoom:{pan:k,zoom:G},tooltip:Y,legend:{...w,display:!1,events:[]},customLegendPlugin:S,chartAreaBorder:{borderColor:Ze},chartAreaText:{showLabel:i,text:r,position:l,fontSize:u,xOffset:c,yOffset:d,maxWidth:f,lineHeight:g},...ee};return A.useMemo(()=>({layout:{padding:m},onHover:P(h,y,s),maintainAspectRatio:n?.chartStyling?.maintainAspectRatio,aspectRatio:n?.chartStyling?.squareAspectRatio?1:0,animation:n?.chartStyling?.performanceMode?!1:{duration:nn.FAST,onComplete:a},hover:{mode:Ge.Nearest,intersect:!0},elements:{line:{pointStyle:tn.Circle,showLine:x,tension:0}},scales:H,plugins:te,events:Object.values(on)}),[t,n,e,s])},bs=({options:e,resetZoom:t})=>{const{graph:n,legend:o}=e,s=A.useCallback((a,i)=>{const{event:r}=i;return r.type===qn?(t(),!1):!0},[t]);return A.useMemo(()=>[...sn(n,o),{id:"customEventCatcher",beforeEvent:s}],[s])},xs=(e,t)=>{A.useEffect(()=>{if(t?.legend?.customLegend?.customLegendPlugin){const n=document.getElementById(t.legend.customLegend.customLegendContainerID);n!==null&&(n.style.visibility=e.legendEnabled?"visible":"hidden")}},[t?.legend?.customLegend?.customLegendPlugin,e.legendEnabled])},ys=(e,t)=>{A.useEffect(()=>{Lo(e,t)},[e.panEnabled,e.lineEnabled,e.pointsEnabled,e.legendEnabled,e.enableDragPoints,e.zoomEnabled])},As=({options:e,state:t,persistenceId:n})=>{const o=A.useMemo(()=>t,[t]),s=A.useMemo(()=>e,[e]);ys(o,n),xs(o,s)},be=" ",_s="rgba(0, 0, 0, 0.5)",Ts=e=>(Array.isArray(e)?e.join(be):e)?.split(be),Ds=({ctx:e,lines:t,lineHeight:n,x:o,y:s,position:a})=>{t?.forEach((i,r)=>{const l=a?.includes("top")?s+n*(r+1)-5:s-(t.length-1-r)*n;e?.fillText(i,o,l)})},Es=(e,t)=>{const s=t<500?.5:t<700?.7:1;return e*s},Os=e=>{const{legend:t}=e??{},n=t&&t?.display&&t?.options?.position==="left"?t?.width+t?.options?.labels?.padding*2:0,o=t&&t.display&&(t?.options?.position==="top"||t?.options?.position==="bottom")?t?.height+t?.options?.labels?.padding*2:0;return{legendWidth:n,legendHeight:o}},Ps=(e,t,n,o)=>{const{chartArea:s,width:a}=t??{},i=a-8,{legendWidth:r,legendHeight:l}=Os(t)??{};switch(e){case v.TOP_LEFT:return[s?.left+n+r,s?.top+o+l];case v.TOP_CENTER:return[s?.left+s?.width/2,s?.top+o+l];case v.TOP_RIGHT:return[i-n,s?.top+o+l];case v.MIDDLE_LEFT:return[s?.left+n+r,s?.top+s?.height/2];case v.MIDDLE_CENTER:return[s?.left+s?.width/2,s?.top+s?.height/2];case v.MIDDLE_RIGHT:return[i-n-r,s?.top+s?.height/2];case v.BOTTOM_LEFT:return[s?.left+n+r,s?.bottom-o-l];case v.BOTTOM_CENTER:return[s?.left+s?.width/2,s?.bottom-o-l];case v.BOTTOM_RIGHT:default:return[i-n-r,s?.bottom-o-l]}},Ss=e=>e?.includes(R.Center)?R.Center:e?.includes(R.Left)?R.Left:R.Right,Ls=(e,t,n)=>{let o="",s=[];for(let a=0;a<e.length;a++){const i=`${o}${e?.[a]}${be}`,{width:r}=n?.measureText(i)??{};r>t?(s.push(o?.trim()),o=`${e?.[a]}${be}`):o=i}return s.push(o.trim()),s},Cs=(e,t)=>{if(!e)return;const{text:n,maxWidth:o,fontSize:s,lineHeight:a,x:i,y:r,position:l}=t??{},u=Ts(n),c=Ls(u,o,e);e?.save?.(),e.font=`${s}px Arial`,e.fillStyle=_s,e.textAlign=Ss(l),Ds({ctx:e,lines:c,lineHeight:a,x:i,y:r,position:l}),e?.restore?.()},ws={id:"chartAreaText",beforeDraw:(e,t,n)=>{const{showLabel:o,text:s,fontSize:a,xOffset:i,yOffset:r,lineHeight:l,maxWidth:u,position:c}=n??{};if(!o||!s)return;const{ctx:d,chartArea:f}=e??{};if(!d||!f)return;const g=Es(u,f.width),[m,b]=Ps(c,e,i,r);Cs(d,{text:s,maxWidth:g,fontSize:a,lineHeight:l,x:m,y:b,position:c})}},kt=(e,t,n,o,s)=>{const a=t.getBoundingClientRect(),i=e.clientX-a.left,r=e.clientY-a.top,l=n?.[o],u=n?.[s],c=l?.getValueForPixel(i)??-1,d=u?.getValueForPixel(r)??-1;return{x:c,y:d}},xe=e=>{const{xMin:t,xMax:n,yMin:o,yMax:s,xValue:a,yValue:i,type:r}=e??{};let l,u,c,d;return!D.isNil(t)&&!D.isNil(n)&&!D.isNil(o)&&!D.isNil(s)&&r===F.BOX?(l=(t+n)/2,u=(o+s)/2,c=n-t,d=s-o):!D.isNil(a)&&!D.isNil(i)&&r===F.POINT&&(l=a,u=i,c=0,d=0),{centerX:l,centerY:u,width:c,height:d}},Gt=(e,t,n,o)=>{const{xMin:s,xMax:a,yMin:i,yMax:r,xValue:l,yValue:u,type:c}=e??{};let d,f,g,m;const b=t?.[n],_=t?.[o];if(!b||!_)return{centerX:-1,centerY:-1,width:0,height:0};if(!D.isNil(s)&&!D.isNil(a)&&!D.isNil(i)&&!D.isNil(r)&&c===F.BOX){const E=(s+a)/2,x=(i+r)/2,h=b?.getPixelForValue(s)??0,y=b?.getPixelForValue(a)??0,O=_?.getPixelForValue(i)??0,P=_?.getPixelForValue(r)??0;g=h-y,m=O-P,d=b?.getPixelForValue(E)??-1,f=_?.getPixelForValue(x)??-1}else!D.isNil(l)&&!D.isNil(u)&&c===F.POINT&&(g=0,m=0,d=b?.getPixelForValue(l)??-1,f=_?.getPixelForValue(u)??-1);return{centerX:d,centerY:f,width:g,height:m}},Is=({x:e,y:t,chartArea:n,scales:o,metrics:s,resizable:a=!1,dragRange:i,annotationType:r,xScaleID:l,yScaleID:u})=>{if(a&&!i)return!0;if(i){const _=e!==void 0&&i.x?e>=i.x[0]&&e<=i.x[1]:!0,E=t!==void 0&&i.y?t>=i.y[0]&&t<=i.y[1]:!0;return _&&E}const c=o?.[l],d=o?.[u];if(!o?.[l]||!o?.[u])return!1;const f=c?.getValueForPixel(n.left)??Number.NEGATIVE_INFINITY,g=c?.getValueForPixel(n.right)??Number.POSITIVE_INFINITY,m=d?.getValueForPixel(n.bottom)??Number.NEGATIVE_INFINITY,b=d?.getValueForPixel(n.top)??Number.POSITIVE_INFINITY;if(r===F.POINT){const _=e!==void 0?e>=f&&e<=g:!0,E=t!==void 0?t>=m&&t<=b:!0;return _&&E}if(r===F.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,x=t!==void 0?t-s.height/2:void 0,h=t!==void 0?t+s.height/2:void 0,y=_!==void 0&&E!==void 0?_>=f&&E<=g:!0,O=x!==void 0&&h!==void 0?x>=m&&h<=b:!0;return y&&O}return!0},pt=(e,t,n,o,s,a,i,r)=>{if(!o?.chartArea)return;const{resizable:l,dragRange:u=null}=n??{};Is({[e]:t,chartArea:o?.chartArea,scales:s,resizable:l,dragRange:u,metrics:r||{},annotationType:n?.type,xScaleID:a,yScaleID:i})&&(n.type===F.POINT?e==="x"?n.xValue=t:e==="y"&&(n.yValue=t):n.type===F.BOX&&r&&(e==="x"&&r.width&&(n.xMin=t-r.width/2,n.xMax=t+r.width/2),e==="y"&&r.height&&(n.yMin=t-r.height/2,n.yMax=t+r.height/2)))},zt=(e,t,n)=>{if(!t)return;const o=e?.options?.plugins?.annotation?.annotations;o&&t&&o[t]&&(o[t].borderWidth=n)},Ns=(e,t,n,o,s,a)=>{const i=a?o?.[a]:null;if(!i)return;const{xScaleID:r="x",yScaleID:l="y"}=i,{x:u,y:c}=kt(e,t,n,r,l),d=xe(i);if(i&&i.enableDrag&&!D.isNil(d.centerY)&&!D.isNil(d.centerX)){!D.isNil(t)&&!D.isNil(t.style)&&(t.style.cursor=ze.Move);const f=u-d.centerX,g=c-d.centerY;s(!0,i,f,g),i?.onDragStart&&i.onDragStart({x:u,y:c},i)}},Ms=(e,t,n,o,s,a,i,r)=>{if(o&&s){!D.isNil(t)&&!D.isNil(t.style)&&(t.style.cursor=ze.Move);const l=s?.id;zt(r,l,ke.HOVERED);const u=s?.dragAxis??se.Both,{xScaleID:c="x",yScaleID:d="y"}=s,{x:f,y:g}=kt(e,t,n,c,d),m=xe(s);let b=f-a,_=g-i;u!==se.Y&&pt(se.X,b,s,r,n,c,d,m),u!==se.X&&pt(se.Y,_,s,r,n,c,d,m),r?.update?.(),s?.onDrag&&s.onDrag({x:f,y:g},s);const{ctx:E,width:x,height:h}=r,{centerX:y,centerY:O}=xe(s)??{},{centerX:P,centerY:T}=Gt(s,n,c,d);if(!D.isNil(y)&&!D.isNil(O)&&!D.isNil(P)&&!D.isNil(T)&&(E?.save?.(),E?.clearRect?.(0,0,x,h),r?.draw?.(),E.font=an,E.fillStyle="black",s?.displayDragCoordinates)){let w=P-45,S=T-20;const I=`X: ${K(y,2)}, Y: ${K(O,2)}`,j=14;S-j<0&&(S=T+j+15),S>h&&(S=h-7),E?.fillText?.(I,w,S),E?.restore?.()}}},vs=(e,t,n,o,s)=>{if(e&&t){const a=t?.id;zt(n,a,ke.ZERO);const{centerX:i=-1,centerY:r=-1}=xe(t)??{};D.isNil(t?.onDragEnd)||t?.onDragEnd({x:i,y:r},t),!D.isNil(o)&&!D.isNil(o.style)&&(o.style.cursor=ze.Pointer),s(!1,null)}},Rs=(e,t,n)=>{!e||!t||Object.values(t).forEach(o=>{if(o.type===F.POINT&&!D.isNil(o?.label)&&o?.label?.display){const{content:s,font:a,color:i,position:r,padding:l}=o?.label??{},{xScaleID:u="x",yScaleID:c="y"}=o;e?.save?.(),e.font=a,e.fillStyle=i;const{centerX:d=-1,centerY:f=-1}=Gt(o,n,u,c),g=e.measureText(s).width;let m=d-g/2,b=f+20;switch(r){case ae.Top:b=f-20;break;case ae.Left:m=d-g-l,b=f;break;case ae.Right:m=d+l,b=f;break}e?.fillText?.(s,m,b),e?.restore?.()}})},Fs={id:"annotationDraggerPlugin",beforeDraw(e){const t=e?.ctx,n=e?.options?.plugins?.annotationDraggerPlugin||{enabled:!1};let o=e?.options?.plugins?.annotation?.annotations??{};o&&(!t||!o||(Rs(e?.ctx,o,e?.scales),n.enabled&&(e?.options?.plugins?.tooltip&&(e.options.plugins.tooltip.enabled=!1),e?.options?.hover&&(e.options.hover={mode:void 0,intersect:!1}))))},afterUpdate(e){const{canvas:t,scales:n,hoveredAnnotationId:o}=e??{},s=e?.options?.plugins?.annotationDraggerPlugin||{enabled:!1};if(!t||!n||!s||!s?.enabled)return;const a={...n,x:n.x,y:n.y};let i=e?.options?.plugins?.annotation?.annotations??{};if(!e&&!i)return;s.enabled?(e?.options?.plugins?.tooltip&&(e.options.plugins.tooltip.enabled=!1),e?.options?.hover&&(e.options.hover={mode:void 0,intersect:!1})):(e?.options?.plugins?.tooltip&&(e.options.plugins.tooltip.enabled=!0),e?.options?.hover&&(e.options.hover={mode:Ge.Nearest,intersect:!0}));let r=!1,l,u,c=null;const d=(f,g,m,b)=>{r=f,c=g,m!==void 0&&b!==void 0&&(l=m,u=b)};!t.dataset.annotationDraggerInitialized&&s.enabled&&o&&(t.addEventListener(q.MOUSEDOWN,f=>{Ns(f,t,a,e?.options?.plugins?.annotation?.annotations,d,e?.hoveredAnnotationId)}),t.addEventListener(q.MOUSEMOVE,f=>{D.debounce(()=>Ms(f,t,a,r,c,l,u,e),5)()}),t.addEventListener(q.MOUSEUP,f=>{const g=f.currentTarget;vs(r,c,e,g,d)}),t.dataset.annotationDraggerInitialized="true"),s.enabled||(t.removeEventListener(q.MOUSEDOWN,()=>{}),t.removeEventListener(q.MOUSEMOVE,()=>{}),t.removeEventListener(q.MOUSEUP,()=>{}),t.dataset.annotationDraggerInitialized="")}};dn.register(gn,fn,pn,hn,mn,bn,xn,yn,An,_n,Tn,Qn,ws,Fs,io);const js=e=>{ln();const t=A.useRef(null),{table:n,headerComponent:o,subheaderComponent:s}=e??{},{translations:a,languageKey:i}=oo(),r=Ft(e),{data:{datasets:l}={datasets:[]},options:u,testId:c,persistenceId:d,controlsPortalId:f}=r,{annotations:g,axes:m,chartStyling:b,graph:_}=u??{},E=!u?.legend?.customLegend?.customLegendContainerID,[x,h]=A.useReducer(Oo,{options:u,persistenceId:d},Co),y=A.useMemo(()=>ns(l,x,u,a),[x.lineEnabled,x.pointsEnabled,l,m,g,_]);As({options:u,state:x,persistenceId:d});const{resetZoom:O,handleKeyDown:P,handleKeyUp:T}=Xe({chartRef:t,state:x,options:u,dispatch:h,generatedDatasets:y}),w=ms({chartRef:t,state:x,options:u,dispatch:h,generatedDatasets:y}),S=bs({options:u,resetZoom:O});return p.jsxs("div",{className:cn(b,Ee),style:{width:b.width||Le,height:b.height||Le},tabIndex:0,onKeyDown:P,onKeyUp:T,"data-testid":c,children:[p.jsx(Rt,{table:n,headerComponent:o,subheaderComponent:s,chartRef:t,state:x,options:u,dispatch:h,generatedDatasets:y,translations:a,controlsPortalId:f}),n&&x.showTable?p.jsx("div",{className:Ee.table,children:n}):p.jsx($n,{backend:Zn,context:window,children:p.jsxs("div",{className:Ee.canvas,id:"canvas",children:[p.jsx(un,{ref:t,data:{datasets:y},options:w,plugins:S}),E&&!!y.length&&p.jsx(Kn,{chartRef:t,legendConfig:{options:u,generatedDatasets:y,chartType:Jn.LINE}})]})})]},Vo(x,i))},ks=e=>{const{options:t,data:{datasets:n=[]}={}}=Ft(e);return p.jsx(rn,{options:t,datasets:n,children:p.jsx(js,{...e})})};ks.__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{ks as L,Us as i};
|