import{r as a,j as C}from"./chunk-WWGJGFF6-CIhJDzEq.js";import{C as m,B as L,e as x}from"./chart-Q31GZOj-.js";const g="label";function b(t,e){typeof t=="function"?t(e):t&&(t.current=e)}function T(t,e){const s=t.options;s&&e&&Object.assign(s,e)}function E(t,e){t.labels=e}function R(t,e,s=g){const u=[];t.datasets=e.map(n=>{const c=t.datasets.find(i=>i[s]===n[s]);return!c||!n.data||u.includes(c)?{...n}:(u.push(c),Object.assign(c,n),c)})}function v(t,e=g){const s={labels:[],datasets:[]};return E(s,t.labels),R(s,t.datasets,e),s}function D(t,e){const{height:s=150,width:u=300,redraw:n=!1,datasetIdKey:c,type:i,data:o,options:f,plugins:y=[],fallbackContent:j,updateMode:h,...B}=t,l=a.useRef(null),r=a.useRef(null),d=()=>{l.current&&(r.current=new m(l.current,{type:i,data:v(o,c),options:f&&{...f},plugins:y}),b(e,r.current))},p=()=>{b(e,null),r.current&&(r.current.destroy(),r.current=null)};return a.useEffect(()=>{!n&&r.current&&f&&T(r.current,f)},[n,f]),a.useEffect(()=>{!n&&r.current&&E(r.current.config.data,o.labels)},[n,o.labels]),a.useEffect(()=>{!n&&r.current&&o.datasets&&R(r.current.config.data,o.datasets,c)},[n,o.datasets]),a.useEffect(()=>{r.current&&(n?(p(),setTimeout(d)):r.current.update(h))},[n,f,o.labels,o.datasets,h]),a.useEffect(()=>{r.current&&(p(),setTimeout(d))},[i]),a.useEffect(()=>(d(),()=>p()),[]),C.jsx("canvas",{ref:l,role:"img",height:s,width:u,...B,children:j})}const O=a.forwardRef(D);function w(t,e){return m.register(e),a.forwardRef((s,u)=>C.jsx(O,{...s,ref:u,type:t}))}const K=w("line",x),M=w("bar",L);export{M as B,K as L};