@nice2dev/ui 1.2.1 → 1.3.0
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/CHANGELOG.md +476 -0
- package/dist/NiceButton-CnAIqCbd.js +101 -0
- package/dist/NiceButton-DzCqkG5a.cjs +1 -0
- package/dist/NiceCodeEditor-C43xFG8v.cjs +260 -0
- package/dist/NiceCodeEditor-CK6B54mu.js +1215 -0
- package/dist/NiceCodeEditor-CspuYLh6.js +1174 -0
- package/dist/NiceCodeEditor-bJReZPDO.cjs +268 -0
- package/dist/NiceColorPicker-BV3olE3M.cjs +1 -0
- package/dist/NiceColorPicker-CyY-4q89.js +552 -0
- package/dist/NiceDataGrid-BQIqitMM.cjs +10 -0
- package/dist/NiceDataGrid-C1eI6Pso.js +2267 -0
- package/dist/NiceDataGrid-CrD4HPlO.cjs +10 -0
- package/dist/NiceDataGrid-Dfg1DVbU.js +2224 -0
- package/dist/NiceForm-CISJyzoW.cjs +1 -0
- package/dist/NiceForm-CfAPcXdX.cjs +1 -0
- package/dist/NiceForm-DfKYNQti.js +5017 -0
- package/dist/NiceForm-DmH6k1b_.js +4775 -0
- package/dist/NiceGantt-CHnq-n8f.cjs +1 -0
- package/dist/NiceGantt-CX3jVNaF.js +330 -0
- package/dist/NiceGantt-TEXbAELi.js +333 -0
- package/dist/NiceGantt-s2cgt5zD.cjs +1 -0
- package/dist/NiceHtmlEditor-CDZeF_zG.cjs +10 -0
- package/dist/NiceHtmlEditor-CdWgddg3.js +901 -0
- package/dist/NiceHtmlEditor-DeK0Of98.js +883 -0
- package/dist/NiceHtmlEditor-DvVxl4Fu.cjs +10 -0
- package/dist/NiceLoginForm-CHXbz0eu.js +747 -0
- package/dist/NiceLoginForm-DRPldHXa.js +808 -0
- package/dist/NiceLoginForm-IGLUCQUE.cjs +1 -0
- package/dist/NiceLoginForm-ix6J1adA.cjs +1 -0
- package/dist/NiceMention-CgDp0sl9.cjs +430 -0
- package/dist/NiceMention-DBvFvx71.js +11653 -0
- package/dist/NiceMention-DKhk3xdM.js +11321 -0
- package/dist/NiceMention-wp1AJ5oh.cjs +430 -0
- package/dist/NiceMention.css +1 -1
- package/dist/NiceModal-BbQwiEOp.cjs +1 -0
- package/dist/NiceModal-BlYhFDhP.js +80 -0
- package/dist/NiceModal-DQEfTcnZ.js +85 -0
- package/dist/NiceModal-DmWz2PDM.cjs +1 -0
- package/dist/NiceModuleLifecyclePanel-22CEEVbA.cjs +1 -0
- package/dist/NiceModuleLifecyclePanel-BCd9Wv5Y.js +6825 -0
- package/dist/NiceModuleLifecyclePanel-D8EoXqBy.cjs +1 -0
- package/dist/NiceModuleLifecyclePanel-SN6G7t64.js +7189 -0
- package/dist/NiceModuleLifecyclePanel.css +1 -1
- package/dist/NicePagination-BFGt1v0a.js +165 -0
- package/dist/NicePagination-BJS65foT.js +200 -0
- package/dist/NicePagination-D_3GfWp5.cjs +1 -0
- package/dist/NicePagination-DltL3-Sz.cjs +1 -0
- package/dist/NicePivotGrid-BD87Na7P.js +1163 -0
- package/dist/NicePivotGrid-BPmnvbPQ.cjs +152 -0
- package/dist/NicePivotGrid-D_kRF1Dt.js +1180 -0
- package/dist/NicePivotGrid-DqluEkCI.cjs +152 -0
- package/dist/NiceSavedQueryPanel-BSTiZvFg.js +5130 -0
- package/dist/NiceSavedQueryPanel-C2Tn1cMW.js +5311 -0
- package/dist/NiceSavedQueryPanel-DDKtL1AA.cjs +586 -0
- package/dist/NiceSavedQueryPanel-DrR3sw4T.cjs +586 -0
- package/dist/NiceScheduler-DvxJ8N0I.js +1698 -0
- package/dist/NiceScheduler-GJLvkXJ3.cjs +5 -0
- package/dist/NiceScheduler-TIksdF0k.cjs +5 -0
- package/dist/NiceScheduler-UT49u2Vq.js +1710 -0
- package/dist/NiceSelect-CdUHd8rj.cjs +1 -0
- package/dist/NiceSelect-fOelG_QB.js +495 -0
- package/dist/NiceWindow-CqSsTjrS.cjs +1 -0
- package/dist/NiceWindow-DZLPhXbR.js +2223 -0
- package/dist/charts-BYQwl_GS.js +4789 -0
- package/dist/charts-BpELGDXh.cjs +768 -0
- package/dist/charts-C6iOu0H6.cjs +768 -0
- package/dist/charts-M6LuVI7F.js +4776 -0
- package/dist/charts.cjs +1 -1
- package/dist/charts.d.ts +1 -29
- package/dist/charts.mjs +1 -1
- package/dist/core-lazy-B_laOXNf.cjs +1 -0
- package/dist/core-lazy-Ctin_LwS.cjs +1 -0
- package/dist/core-lazy-VQEjdz0L.js +351 -0
- package/dist/core-lazy-iDiropM6.js +351 -0
- package/dist/data-branching-7rpktFJ-.cjs +1 -0
- package/dist/data-branching-BS0aFUMu.js +6428 -0
- package/dist/data-branching-BgIAw01q.cjs +1 -0
- package/dist/data-branching-bvB9K6KS.js +6386 -0
- package/dist/data-branching.cjs +1 -1
- package/dist/data-branching.mjs +1 -1
- package/dist/data.cjs +1 -1
- package/dist/data.mjs +3 -3
- package/dist/devops-Bp-_aA-9.js +8682 -0
- package/dist/devops-CFytAJQr.cjs +18 -0
- package/dist/devops-CW8YY_zA.js +9122 -0
- package/dist/devops-CXBSjnyX.cjs +17 -0
- package/dist/devops.cjs +1 -1
- package/dist/devops.css +1 -0
- package/dist/devops.mjs +5 -5
- package/dist/editors.cjs +1 -1
- package/dist/editors.mjs +8 -8
- package/dist/feedback.cjs +1 -1
- package/dist/feedback.d.ts +21 -16
- package/dist/feedback.mjs +3 -3
- package/dist/index.cjs +199 -194
- package/dist/index.css +1 -1
- package/dist/index.d.ts +378 -48
- package/dist/index.mjs +23248 -21783
- package/dist/lazy.cjs +1 -1
- package/dist/lazy.mjs +24 -24
- package/dist/navigation.cjs +1 -1
- package/dist/navigation.d.ts +31 -0
- package/dist/navigation.mjs +404 -354
- package/dist/no-code-BNFk_BDO.js +8275 -0
- package/dist/no-code-BaAI_sJR.js +8318 -0
- package/dist/no-code-CFdTp543.cjs +331 -0
- package/dist/no-code-oQTeAtnW.cjs +331 -0
- package/dist/no-code.cjs +1 -1
- package/dist/no-code.mjs +1 -1
- package/dist/overlays.cjs +1 -1
- package/dist/overlays.d.ts +5 -0
- package/dist/overlays.mjs +1 -1
- package/dist/pickerCommons-BQi6IEAt.js +661 -0
- package/dist/pickerCommons-CMxFt9SW.js +548 -0
- package/dist/pickerCommons-Dc_hlz-e.cjs +1 -0
- package/dist/pickerCommons-DvQptSPX.cjs +1 -0
- package/dist/style.css +7 -4
- package/package.json +4 -3
|
@@ -0,0 +1,768 @@
|
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),le=require("@nice2dev/ui-core"),c=require("react"),Be=require("@nice2dev/i18n"),We=[],we=["var(--nice-color-primary, #3b82f6)","var(--nice-color-error, #ef4444)","var(--nice-color-success, #22c55e)","var(--nice-color-warning, #f59e0b)","var(--nice-color-accent, #8b5cf6)","var(--nice-color-accent-pink, #ec4899)","var(--nice-color-info, #06b6d4)","var(--nice-success, #84cc16)"],Se=({series:t=We,categories:s,width:l=600,height:r=400,title:i,showLegend:_=!0,showGrid:v=!0,axisLabels:C=!0,yAxisLabel:L,xAxisLabel:g,stacked:b,animated:h,zoomable:D,crosshair:I,annotations:N,legendInteractive:o,onDataPointClick:d,exportable:M,className:w,style:A})=>{const{t:S}=le.useNiceTranslation(),k=c.useRef(null),[z,a]=c.useState(new Set),[R,u]=c.useState(null),[x,p]=c.useState(null),[O,T]=c.useState(!1),F=c.useRef(null),G=c.useMemo(()=>t.filter(j=>!z.has(j.name)),[t,z]),P=c.useCallback(j=>{o&&a(Q=>{const n=new Set(Q);return n.has(j)?n.delete(j):n.add(j),n})},[o]),K={top:i?40:20,right:20,bottom:g?60:40,left:L?60:50},H=l-K.left-K.right,X=r-K.top-K.bottom,y=G[0]?.data.length??t[0]?.data.length??0,q=x?.start??0,ce=x?.end??y,ne=ce-q,Z=c.useMemo(()=>G.map(j=>({...j,data:j.data.slice(q,ce)})),[G,q,ce]),ae=c.useMemo(()=>s?.slice(q,ce),[s,q,ce]),{minY:E,maxY:f,yTicks:B}=c.useMemo(()=>{let j;if(b){j=[];for(let se=0;se<ne;se++)j.push(Z.reduce((oe,fe)=>oe+(fe.data[se]||0),0))}else j=Z.flatMap(se=>se.data);j.length===0&&(j=[0]);const Q=Math.min(0,...j),n=Math.max(0,...j),W=n-Q||1,U=Math.pow(10,Math.floor(Math.log10(W)))||1,$=Math.floor(Q/U)*U;let J=Math.ceil(n/U)*U;const te=[];for(let se=$;se<=J;se+=U)te.push(Math.round(se*1e6)/1e6);return te.length<2&&(J=$+U,te.push(Math.round(J*1e6)/1e6)),{minY:$,maxY:J,yTicks:te}},[Z,ne,b]),m=j=>X-(j-E)/(f-E||1)*X,Y=j=>(j+.5)/ne*H,he=j=>(j.type||"bar")==="bar",V=new Map(Z.filter(he).map((j,Q)=>[j,Q])),re=ne>0?H/ne/(b?1.5:Math.max(V.size,1)*1.5):20,de=re*.9,pe=c.useCallback(j=>{if(!D)return;j.preventDefault();const Q=x??{start:0,end:y},n=Q.end-Q.start,W=(Q.start+Q.end)/2,U=j.deltaY>0?1.2:.8,$=Math.max(2,Math.min(y,Math.round(n*U))),J=Math.max(0,Math.round(W-$/2)),te=Math.min(y,J+$);p({start:J,end:te})},[D,x,y]),je=c.useCallback(j=>{D&&(T(!0),F.current={x:j.clientX,range:x??{start:0,end:y}})},[D,x,y]),ge=c.useCallback(j=>{const Q=k.current?.getBoundingClientRect();if(Q&&u({x:j.clientX-Q.left-K.left,y:j.clientY-Q.top-K.top}),O&&F.current&&D){const n=j.clientX-F.current.x,W=H/ne,U=-Math.round(n/W),$=F.current.range,J=$.end-$.start;let te=$.start+U;te<0&&(te=0),te+J>y&&(te=y-J),p({start:te,end:te+J})}},[O,D,H,ne,y,K.left,K.top]),_e=c.useCallback(()=>{T(!1),F.current=null},[]),Me=c.useCallback(()=>{u(null),T(!1),F.current=null},[]),ee=c.useCallback(()=>{const j=k.current;if(!j)return;const Q=new XMLSerializer().serializeToString(j),n=document.createElement("canvas");n.width=l,n.height=r+(_?30:0);const W=n.getContext("2d");if(!W)return;const U=new Image;U.onload=()=>{W.fillStyle=le.resolveCssColor("var(--nice-bg-primary, #fff)",W.canvas),W.fillRect(0,0,n.width,n.height),W.drawImage(U,0,0);const $=document.createElement("a");$.download="chart.png",$.href=n.toDataURL("image/png"),$.click()},U.src="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(Q)},[l,r,_]),ie=r+(_?30:0),ue=Z.length>0&&Z.every(j=>j.type==="radar"),be=c.useMemo(()=>{if(!ue)return 1;const j=Z.flatMap(Q=>Q.data);return Math.max(1,...j)},[ue,Z]);if(ue){const j=l/2,Q=(r-K.top-K.bottom)/2+K.top,n=Math.min(H,r-K.top-K.bottom)/2-10,W=ae?.length??Z[0]?.data.length??0,U=te=>te/W*Math.PI*2-Math.PI/2,$=(te,se)=>{const oe=se/be*n;return[j+Math.cos(U(te))*oe,Q+Math.sin(U(te))*oe]},J=4;return e.jsx("div",{className:`nice-chart nice-chart--radar ${w||""}`,style:A,children:e.jsxs("svg",{ref:k,viewBox:`0 0 ${l} ${ie}`,preserveAspectRatio:"xMidYMid meet",width:"100%",height:"100%",className:"nice-chart__svg",style:{display:"block",maxWidth:"100%",maxHeight:"100%"},children:[i&&e.jsx("text",{x:l/2,y:20,textAnchor:"middle",className:"nice-chart__title",children:i}),v&&Array.from({length:J},(te,se)=>{const oe=(se+1)/J*n,fe=[];for(let me=0;me<W;me++)fe.push(`${j+Math.cos(U(me))*oe},${Q+Math.sin(U(me))*oe}`);return e.jsx("polygon",{points:fe.join(" "),fill:"none",className:"nice-chart__grid-line"},se)}),Array.from({length:W},(te,se)=>{const[oe,fe]=$(se,be);return e.jsx("line",{x1:j,y1:Q,x2:oe,y2:fe,className:"nice-chart__grid-line"},se)}),C&&ae?.map((te,se)=>{const[oe,fe]=$(se,be*1.12);return e.jsx("text",{x:oe,y:fe,textAnchor:"middle",dominantBaseline:"middle",className:"nice-chart__axis-label",children:te},se)}),Z.map((te,se)=>{const oe=te.color||we[se%we.length],fe=te.data.map((me,Ne)=>$(Ne,me).join(",")).join(" ");return e.jsxs("g",{className:h?"nice-chart__series nice-chart__series--radar nice-chart__series--anim":"nice-chart__series nice-chart__series--radar",children:[e.jsx("polygon",{points:fe,fill:oe,fillOpacity:.2,stroke:oe,strokeWidth:2}),te.data.map((me,Ne)=>{const[ke,Ce]=$(Ne,me);return e.jsx("circle",{cx:ke,cy:Ce,r:3,fill:oe,children:e.jsx("title",{children:`${te.name}: ${me}`})},Ne)})]},te.name)}),_&&e.jsx("g",{transform:`translate(${K.left}, ${r})`,children:t.map((te,se)=>{const oe=se*120,fe=z.has(te.name);return e.jsxs("g",{transform:`translate(${oe}, 10)`,style:o?{cursor:"pointer"}:void 0,onClick:()=>P(te.name),opacity:fe?.35:1,children:[e.jsx("rect",{width:12,height:12,rx:2,fill:te.color||we[se%we.length]}),e.jsx("text",{x:16,y:10,className:"nice-chart__legend-text",children:te.name})]},te.name)})})]})})}return e.jsxs("div",{className:`nice-chart ${w||""}`,style:A,children:[M&&e.jsx("button",{type:"button",className:"nice-chart__export-btn",onClick:ee,title:S("chart.exportPng","Export PNG"),"aria-label":S("chart.exportPng","Export PNG"),children:e.jsx(le.NiceIcon,{name:"camera",size:16})}),e.jsxs("svg",{ref:k,viewBox:`0 0 ${l} ${ie}`,preserveAspectRatio:"xMidYMid meet",width:"100%",height:"100%",style:{display:"block",maxWidth:"100%",maxHeight:"100%"},className:"nice-chart__svg",onWheel:pe,onMouseDown:je,onMouseMove:ge,onMouseUp:_e,onMouseLeave:Me,children:[e.jsxs("g",{transform:`translate(${K.left},${K.top})`,children:[i&&e.jsx("text",{x:H/2,y:-10,textAnchor:"middle",className:"nice-chart__title",children:i}),v&&B.map(j=>e.jsx("line",{x1:0,y1:m(j),x2:H,y2:m(j),className:"nice-chart__grid-line"},`grid-${j}`)),C&&B.map(j=>e.jsx("text",{x:-8,y:m(j)+4,textAnchor:"end",className:"nice-chart__axis-label",children:j},`ylabel-${j}`)),C&&ae&&ae.map((j,Q)=>e.jsx("text",{x:Y(Q),y:X+20,textAnchor:"middle",className:"nice-chart__axis-label",children:j},Q)),L&&e.jsx("text",{x:-K.left+14,y:X/2,textAnchor:"middle",transform:`rotate(-90, -${K.left-14}, ${X/2})`,className:"nice-chart__axis-title",children:L}),g&&e.jsx("text",{x:H/2,y:X+45,textAnchor:"middle",className:"nice-chart__axis-title",children:g}),e.jsx("line",{x1:0,y1:0,x2:0,y2:X,className:"nice-chart__axis"}),e.jsx("line",{x1:0,y1:X,x2:H,y2:X,className:"nice-chart__axis"}),N?.map((j,Q)=>{if(j.type==="line"){const n=m(j.value);return e.jsxs("g",{children:[e.jsx("line",{x1:0,y1:n,x2:H,y2:n,stroke:j.color||"var(--nice-color-error, #ef4444)",strokeWidth:1.5,strokeDasharray:j.dash||"6,3"}),j.label&&e.jsx("text",{x:H+4,y:n+4,className:"nice-chart__annotation-label",fill:j.color||"var(--nice-color-error, #ef4444)",children:j.label})]},Q)}return e.jsx("text",{x:Y(j.value),y:-4,textAnchor:"middle",className:"nice-chart__annotation-label",fill:j.color||"var(--nice-text-muted, #6b7280)",children:j.label},Q)}),I&&R&&R.x>=0&&R.x<=H&&R.y>=0&&R.y<=X&&e.jsxs(e.Fragment,{children:[e.jsx("line",{x1:R.x,y1:0,x2:R.x,y2:X,stroke:"var(--nice-text-muted, #9ca3af)",strokeWidth:1,strokeDasharray:"4,2"}),e.jsx("line",{x1:0,y1:R.y,x2:H,y2:R.y,stroke:"var(--nice-text-muted, #9ca3af)",strokeWidth:1,strokeDasharray:"4,2"})]}),Z.map((j,Q)=>{const n=j.color||we[Q%we.length],W=j.type||"bar";if(W==="bar")return e.jsx("g",{className:h?"nice-chart__series nice-chart__series--bar nice-chart__series--anim":"nice-chart__series nice-chart__series--bar",children:j.data.map(($,J)=>{let te,se;if(b){const me=Z.slice(0,Q).filter(he).reduce((Ne,ke)=>Ne+(ke.data[J]||0),0);te=m(me+$),se=m(me)-te}else te=m(Math.max(0,$)),se=Math.abs(m($)-m(0));const oe=V.get(j)??0,fe=b?Y(J)-de/2:Y(J)-V.size*re/2+oe*re+(re-de)/2;return e.jsx("rect",{x:fe,y:te,width:de,height:Math.max(0,se),fill:n,rx:2,style:{transformOrigin:`${fe+de/2}px ${m(0)}px`,...d?{cursor:"pointer"}:{}},onClick:d?()=>d(j.name,q+J,$):void 0,children:e.jsx("title",{children:`${j.name}: ${$}`})},J)})},j.name);if(W==="scatter")return e.jsx("g",{className:h?"nice-chart__series nice-chart__series--scatter nice-chart__series--anim":"nice-chart__series nice-chart__series--scatter",children:j.data.map(($,J)=>e.jsx("circle",{cx:Y(J),cy:m($),r:5,fill:n,fillOpacity:.7,stroke:n,strokeWidth:1.5,style:d?{cursor:"pointer"}:void 0,onClick:d?()=>d(j.name,q+J,$):void 0,children:e.jsx("title",{children:`${j.name}: ${$}`})},J))},j.name);const U=j.data.map(($,J)=>`${Y(J)},${m($)}`);return e.jsxs("g",{className:h?`nice-chart__series nice-chart__series--${W} nice-chart__series--anim`:`nice-chart__series nice-chart__series--${W}`,children:[W==="area"&&ne>0&&e.jsx("polygon",{points:`${Y(0)},${m(0)} ${U.join(" ")} ${Y(ne-1)},${m(0)}`,fill:n,opacity:.15}),e.jsx("polyline",{points:U.join(" "),fill:"none",stroke:n,strokeWidth:2,className:h?"nice-chart__line":void 0}),j.data.map(($,J)=>e.jsx("circle",{cx:Y(J),cy:m($),r:3,fill:n,style:d?{cursor:"pointer"}:void 0,onClick:d?()=>d(j.name,q+J,$):void 0,children:e.jsx("title",{children:`${j.name}: ${$}`})},J))]},j.name)})]}),_&&e.jsx("g",{transform:`translate(${K.left}, ${r})`,children:t.map((j,Q)=>{const n=Q*120,W=z.has(j.name);return e.jsxs("g",{transform:`translate(${n}, 10)`,style:o?{cursor:"pointer"}:void 0,onClick:()=>P(j.name),opacity:W?.35:1,children:[e.jsx("rect",{width:12,height:12,rx:2,fill:j.color||we[Q%we.length]}),e.jsx("text",{x:16,y:10,className:"nice-chart__legend-text",style:W?{textDecoration:"line-through"}:void 0,children:j.name})]},j.name)})})]})]})},Ye=Object.freeze(Object.defineProperty({__proto__:null,NiceChart:Se},Symbol.toStringTag,{value:"Module"})),Fe=({value:t,min:s=0,max:l=100,width:r=200,height:i=200,startAngle:_=225,endAngle:v=-45,color:C="var(--nice-color-primary, #3b82f6)",trackColor:L,label:g,formatValue:b,ranges:h,className:D,style:I})=>{const N=r/2,o=i/2,d=Math.min(N,o)-20,M=Math.max(0,Math.min(1,(t-s)/(l-s||1))),w=u=>u*Math.PI/180,A=(_-v+360)%360||360,S=u=>({x:N+d*Math.cos(w(u)),y:o-d*Math.sin(w(u))}),k=(u,x)=>{const p=S(u),O=S(x),F=(u-x+360)%360>180?1:0;return`M${p.x},${p.y} A${d},${d} 0 ${F},1 ${O.x},${O.y}`},z=_-M*A,a=S(z);let R=C;if(h){for(const u of h)if(t>=u.start&&t<=u.end){R=u.color;break}}return e.jsx("div",{className:`nice-gauge nice-gauge--circular ${D||""}`,style:I,children:e.jsxs("svg",{width:r,height:i,children:[e.jsx("path",{d:k(_,v),fill:"none",stroke:L||"var(--nice-border-color, #e2e8f0)",strokeWidth:12,strokeLinecap:"round"}),M>0&&e.jsx("path",{d:k(_,z),fill:"none",stroke:R,strokeWidth:12,strokeLinecap:"round"}),e.jsx("line",{x1:N,y1:o,x2:a.x,y2:a.y,stroke:"var(--nice-text-primary, #333)",strokeWidth:2,strokeLinecap:"round"}),e.jsx("circle",{cx:N,cy:o,r:4,fill:"var(--nice-text-primary, #333)"}),e.jsx("text",{x:N,y:o+d*.6,textAnchor:"middle",className:"nice-gauge__value",children:b?b(t):t}),g&&e.jsx("text",{x:N,y:o+d*.95,textAnchor:"middle",className:"nice-gauge__label",children:g})]})})},He=({value:t,min:s=0,max:l=100,width:r=300,height:i=60,orientation:_="horizontal",color:v="var(--nice-color-primary, #3b82f6)",label:C,formatValue:L,ranges:g,showTicks:b=!0,tickCount:h=5,className:D,style:I})=>{const N=_==="horizontal",o=N?r-40:i-40,d=Math.max(0,Math.min(1,(t-s)/(l-s||1))),M=10;let w=v;if(g){for(const S of g)if(t>=S.start&&t<=S.end){w=S.color;break}}const A=Array.from({length:h},(S,k)=>s+(l-s)*(k/(h-1)));return N?e.jsx("div",{className:`nice-gauge nice-gauge--linear ${D||""}`,style:I,children:e.jsxs("svg",{width:r,height:i,children:[e.jsx("text",{x:20+o*d,y:14,textAnchor:"middle",className:"nice-gauge__value",style:{fontSize:12},children:L?L(t):t}),e.jsx("rect",{x:20,y:i/2-M/2,width:o,height:M,rx:5,fill:"var(--nice-border-color, #e2e8f0)"}),e.jsx("rect",{x:20,y:i/2-M/2,width:o*d,height:M,rx:5,fill:w}),e.jsx("polygon",{points:`${20+o*d},${i/2-M/2-2} ${20+o*d-5},${i/2-M/2-8} ${20+o*d+5},${i/2-M/2-8}`,fill:"var(--nice-text-primary, #333)"}),b&&A.map((S,k)=>{const z=20+(S-s)/(l-s)*o;return e.jsx("text",{x:z,y:i/2+M/2+12,textAnchor:"middle",className:"nice-gauge__tick",children:S},k)}),C&&e.jsx("text",{x:r/2,y:i-2,textAnchor:"middle",className:"nice-gauge__label",children:C})]})}):e.jsx("div",{className:`nice-gauge nice-gauge--linear nice-gauge--vertical ${D||""}`,style:I,children:e.jsxs("svg",{width:r,height:i,children:[e.jsx("rect",{x:r/2-M/2,y:20,width:M,height:o,rx:5,fill:"var(--nice-border-color, #e2e8f0)"}),e.jsx("rect",{x:r/2-M/2,y:20+o*(1-d),width:M,height:o*d,rx:5,fill:w}),e.jsx("text",{x:r/2,y:14,textAnchor:"middle",className:"nice-gauge__value",children:L?L(t):t}),C&&e.jsx("text",{x:r/2,y:i-4,textAnchor:"middle",className:"nice-gauge__label",children:C})]})})},ye=["#3b82f6","#ef4444","#22c55e","#f59e0b","#8b5cf6","#ec4899","#06b6d4","#84cc16"],Ve=[],Re=20,Xe=10,Ge=32,Ze=({items:t=Ve,min:s=0,max:l=100,width:r=300,height:i=300,startAngle:_=225,endAngle:v=-45,formatValue:C,title:L,className:g,style:b})=>{const h=T=>T*Math.PI/180,D=(_-v+360)%360||360,I=[h(_),h(v)],N=T=>(_-T+720)%360<=D,o=N(90)?1:Math.max(0,...I.map(T=>Math.sin(T))),d=N(270)?1:Math.max(0,...I.map(T=>-Math.sin(T))),M=N(180)?1:Math.max(0,...I.map(T=>-Math.cos(T))),w=N(0)?1:Math.max(0,...I.map(T=>Math.cos(T))),A=L?Ge:0,S=Xe+Re/2,k=r-2*S,z=i-A-2*S,a=Math.max(0,Math.min(k/(M+w||1),z/(o+d||1))),R=S+M*a+(k-(M+w)*a)/2,u=A+S+o*a+(z-(o+d)*a)/2,x=Math.min(Re,a/(t.length+1)),p=4,O=(T,F,G)=>{const P=R+T*Math.cos(h(F)),K=u-T*Math.sin(h(F)),H=R+T*Math.cos(h(G)),X=u-T*Math.sin(h(G)),y=(F-G+360)%360;return`M${P},${K} A${T},${T} 0 ${y>180?1:0},1 ${H},${X}`};return e.jsx("div",{className:`nice-bargauge ${g||""}`,style:b,children:e.jsxs("svg",{width:r,height:i,children:[L&&e.jsx("text",{x:r/2,y:20,textAnchor:"middle",className:"nice-chart__title",children:L}),t.map((T,F)=>{const G=a-F*(x+p),P=Math.max(0,Math.min(1,(T.value-s)/(l-s||1))),K=_-P*D,H=T.color||ye[F%ye.length];return e.jsxs("g",{children:[e.jsx("path",{d:O(G,_,v),fill:"none",stroke:"var(--nice-border-color, #e2e8f0)",strokeWidth:x,strokeLinecap:"round"}),P>0&&e.jsx("path",{d:O(G,_,K),fill:"none",stroke:H,strokeWidth:x,strokeLinecap:"round"})]},F)}),e.jsx("g",{children:t.map((T,F)=>e.jsxs("text",{x:R,y:u-((t.length-1)/2-F)*16,textAnchor:"middle",dominantBaseline:"middle",className:"nice-gauge__value",style:{fontSize:12},children:[T.label?`${T.label}: `:"",C?C(T.value):T.value]},F))})]})})},Ue={sm:{width:160,height:22,fontSize:11},md:{width:220,height:32,fontSize:12},lg:{width:320,height:44,fontSize:14}},Ke=({value:t,target:s,min:l=0,max:r=100,width:i,height:_,color:v="var(--nice-color-primary, #3b82f6)",targetColor:C="var(--nice-color-error, #ef4444)",size:L="md",label:g,labelPlacement:b="top",showValue:h=!1,showTarget:D=!1,formatValue:I=w=>String(w),state:N="normal",errorMessage:o,className:d,style:M})=>{const{t:w}=le.useNiceTranslation(),A=Ue[L],S=i??A.width,k=_??A.height,z=A.fontSize,a=4,R=S-a*2,u=D&&s!=null?z+4:a,x=D&&s!=null?k+(u-a):k,p=x-u-a,O=Math.max(0,Math.min(1,(t-l)/(r-l||1))),T=s!=null?Math.max(0,Math.min(1,(s-l)/(r-l||1))):null,F=()=>N==="error"?e.jsx("div",{role:"alert",style:{width:S,height:x,display:"flex",alignItems:"center",justifyContent:"center",border:"1px dashed var(--nice-color-error, #ef4444)",borderRadius:4,color:"var(--nice-color-error, #ef4444)",fontSize:z,padding:"0 8px",boxSizing:"border-box"},children:o??w("bullet.error","Error")}):N==="loading"?e.jsx("div",{role:"status","aria-label":w("bullet.loading","Loading"),className:"nice-bullet__skeleton",style:{width:S,height:x,borderRadius:4,background:"linear-gradient(90deg, var(--nice-bg-tertiary, #e5e7eb) 25%, var(--nice-bg-secondary, #f3f4f6) 50%, var(--nice-bg-tertiary, #e5e7eb) 75%)",backgroundSize:"200% 100%",animation:"nice-bullet-shimmer 1.4s linear infinite"}}):e.jsxs("svg",{width:S,height:x,role:"img","aria-label":typeof g=="string"?g:void 0,children:[e.jsx("rect",{x:a,y:u,width:R,height:p,rx:3,fill:"var(--nice-border-color, #e2e8f0)"}),e.jsx("rect",{x:a,y:u+p*.2,width:R*O,height:p*.6,rx:2,fill:v}),T!=null&&e.jsx("line",{x1:a+R*T,y1:u+2,x2:a+R*T,y2:u+p-2,stroke:C,strokeWidth:2}),h&&e.jsx("text",{x:a+Math.max(R*O,4),y:u+p/2,dx:R*O>24?-4:4,textAnchor:R*O>24?"end":"start",dominantBaseline:"middle",fontSize:z,fill:R*O>24?"var(--nice-color-white, #ffffff)":"var(--nice-text-primary)",fontWeight:600,children:I(t)}),D&&T!=null&&e.jsx("text",{x:a+R*T,y:u-2,textAnchor:"middle",fontSize:z-1,fill:C,fontWeight:600,children:I(s)})]});if(b==="none"||!g)return e.jsxs("div",{className:`nice-bullet ${d||""}`,style:M,children:[F(),e.jsx("style",{children:Te})]});const G=b==="top"||b==="bottom",P=e.jsx("span",{className:"nice-bullet__label",style:{fontSize:z,fontWeight:600,color:"var(--nice-text-primary)",...G?{marginBottom:b==="top"?4:0,marginTop:b==="bottom"?4:0}:{},...b==="left"?{marginRight:8}:{},...b==="right"?{marginLeft:8}:{}},children:g});return e.jsxs("div",{className:`nice-bullet nice-bullet--${b} ${d||""}`,style:{display:"inline-flex",flexDirection:G?"column":"row",alignItems:G?"flex-start":"center",...M},children:[(b==="top"||b==="left")&&P,F(),(b==="bottom"||b==="right")&&P,e.jsx("style",{children:Te})]})},Te=`
|
|
2
|
+
@keyframes nice-bullet-shimmer {
|
|
3
|
+
0% { background-position: 200% 0; }
|
|
4
|
+
100% { background-position: -200% 0; }
|
|
5
|
+
}
|
|
6
|
+
`,qe=[],Je=({data:t=qe,width:s=400,height:l=400,innerRadius:r=0,title:i,showLegend:_=!0,showLabels:v=!0,className:C,style:L})=>{const g=s/2,b=(l-(_?30:0))/2+(i?10:0),h=Math.min(g,b)-40,D=t.reduce((o,d)=>o+d.value,0);let I=-Math.PI/2;const N=t.map((o,d)=>{const M=o.value/(D||1)*Math.PI*2,w=I;I+=M;const A=I,S=(w+A)/2,k=g+h*Math.cos(w),z=b+h*Math.sin(w),a=g+h*Math.cos(A),R=b+h*Math.sin(A),u=M>Math.PI?1:0,x=o.color||ye[d%ye.length],p=M>=Math.PI*2-1e-9;let O;if(p){const H=(X,y)=>`M${g-X},${b} A${X},${X} 0 1,${y} ${g+X},${b} A${X},${X} 0 1,${y} ${g-X},${b} Z`;O=r>0?`${H(h,1)} ${H(r,0)}`:H(h,1)}else if(r>0){const H=g+r*Math.cos(w),X=b+r*Math.sin(w),y=g+r*Math.cos(A),q=b+r*Math.sin(A);O=`M${k},${z} A${h},${h} 0 ${u},1 ${a},${R} L${y},${q} A${r},${r} 0 ${u},0 ${H},${X} Z`}else O=`M${g},${b} L${k},${z} A${h},${h} 0 ${u},1 ${a},${R} Z`;const T=Math.min(Math.max(r,0),h),F=T>0?(T+h)/2:h*.65,G=p?g:g+F*Math.cos(S),P=p?b:b+F*Math.sin(S),K=D>0?Math.round(o.value/D*100):0;return{...o,path:O,labelX:G,labelY:P,pct:K,color:x}});return e.jsx("div",{className:`nice-piechart ${C||""}`,style:L,children:e.jsxs("svg",{viewBox:`0 0 ${s} ${l}`,preserveAspectRatio:"xMidYMid meet",width:"100%",height:"100%",style:{display:"block",maxWidth:"100%",maxHeight:"100%"},className:"nice-piechart__svg",children:[i&&e.jsx("text",{x:g,y:20,textAnchor:"middle",className:"nice-chart__title",children:i}),N.map((o,d)=>e.jsxs("g",{children:[e.jsx("path",{d:o.path,fill:o.color,stroke:"var(--nice-bg-primary, #fff)",strokeWidth:2,children:e.jsx("title",{children:`${o.label}: ${o.value} (${o.pct}%)`})}),v&&o.pct>=5&&e.jsxs("text",{x:o.labelX,y:o.labelY,textAnchor:"middle",dominantBaseline:"middle",className:"nice-piechart__label",children:[o.pct,"%"]})]},d)),_&&e.jsx("g",{transform:`translate(10, ${l-25})`,children:t.map((o,d)=>e.jsxs("g",{transform:`translate(${d*100}, 0)`,children:[e.jsx("rect",{width:10,height:10,rx:2,fill:o.color||ye[d%ye.length]}),e.jsx("text",{x:14,y:9,className:"nice-chart__legend-text",children:o.label})]},d))})]})})},Qe=[],et=({data:t=Qe,width:s=400,height:l=300,inverted:r,showLabels:i=!0,showValues:_=!0,title:v,className:C,style:L})=>{const g={top:v?30:10,bottom:10,x:40},b=s-g.x*2,h=l-g.top-g.bottom,D=r?[...t].reverse():t,I=Math.max(...D.map(o=>o.value),1),N=h/D.length;return e.jsx("div",{className:`nice-funnel ${C||""}`,style:L,children:e.jsxs("svg",{width:s,height:l,children:[v&&e.jsx("text",{x:s/2,y:20,textAnchor:"middle",className:"nice-chart__title",children:v}),D.map((o,d)=>{const M=o.value/I*b,w=d<D.length-1?D[d+1].value/I*b:M*.3,A=g.top+d*N,S=A+N,k=s/2,z=`${k-M/2},${A} ${k+M/2},${A} ${k+w/2},${S} ${k-w/2},${S}`,a=o.color||ye[d%ye.length];return e.jsxs("g",{children:[e.jsx("polygon",{points:z,fill:a,stroke:"var(--nice-bg-primary, #fff)",strokeWidth:1,children:e.jsx("title",{children:`${o.label}: ${o.value}`})}),i&&e.jsx("text",{x:k,y:A+N/2-(_?4:0),textAnchor:"middle",dominantBaseline:"middle",className:"nice-funnel__label",children:o.label}),_&&e.jsx("text",{x:k,y:A+N/2+10,textAnchor:"middle",dominantBaseline:"middle",className:"nice-funnel__value",children:o.value})]},d)})]})})},tt=[];function nt(t,s,l){const r=I=>{const N=I.replace("#","");return[parseInt(N.slice(0,2),16),parseInt(N.slice(2,4),16),parseInt(N.slice(4,6),16)]},[i,_,v]=r(t),[C,L,g]=r(s),b=Math.round(i+(C-i)*l),h=Math.round(_+(L-_)*l),D=Math.round(v+(g-v)*l);return`rgb(${b},${h},${D})`}const rt=Object.assign(c.forwardRef(({data:t=tt,xLabels:s,yLabels:l,colors:r=["var(--nice-primary-bg, #e0f2fe)","var(--nice-color-primary-active, #1d4ed8)"],onCellClick:i,cellSize:_=40,showValues:v=!0,className:C,style:L,id:g},b)=>{const h=le.useControlId(g),{minVal:D,maxVal:I}=c.useMemo(()=>{let o=1/0,d=-1/0;for(const M of t)for(const w of M)w<o&&(o=w),w>d&&(d=w);return{minVal:o,maxVal:d}},[t]),N=c.useCallback(o=>I===D?.5:(o-D)/(I-D),[D,I]);return e.jsx("div",{ref:b,id:h,className:`nice-heatmap ${C||""}`,style:L,children:e.jsxs("table",{className:"nice-heatmap__table",children:[s&&e.jsx("thead",{children:e.jsxs("tr",{children:[l&&e.jsx("th",{}),s.map((o,d)=>e.jsx("th",{className:"nice-heatmap__header",children:o},d))]})}),e.jsx("tbody",{children:t.map((o,d)=>e.jsxs("tr",{children:[l&&e.jsx("th",{className:"nice-heatmap__row-label",children:l[d]}),o.map((M,w)=>e.jsx("td",{className:"nice-heatmap__cell",style:{background:nt(r[0],r[1],N(M)),width:_,height:_,textAlign:"center",color:N(M)>.6?"var(--nice-color-white, #fff)":"var(--nice-text-primary, #333)",cursor:i?"pointer":void 0},onClick:()=>i?.(d,w,M),title:String(M),children:v?M:""},w))]},d))})]})})}),{displayName:"NiceHeatMap"}),at=[],ct=[],De=({nodes:t=at,links:s=ct,width:l=600,height:r=400,nodeWidth:i=20,nodePadding:_=10,title:v,className:C,style:L})=>{const g={top:v?40:20,bottom:20,left:20,right:20},b=l-g.left-g.right,h=r-g.top-g.bottom,D=new Set(s.map(u=>u.source)),I=new Set(s.map(u=>u.target)),N=t.filter(u=>D.has(u.id)&&!I.has(u.id)),o=t.filter(u=>I.has(u.id)),d=t.filter(u=>D.has(u.id)&&I.has(u.id)),M=[N,...d.length?[d]:[],o].filter(u=>u.length>0),w=M.length,A=new Map;t.forEach(u=>{const x=s.filter(O=>O.source===u.id).reduce((O,T)=>O+T.value,0),p=s.filter(O=>O.target===u.id).reduce((O,T)=>O+T.value,0);A.set(u.id,Math.max(x,p))});const S=M.map(u=>u.reduce((x,p)=>x+(A.get(p.id)||0),0)+(u.length-1)*_),k=Math.max(...S,1),z=new Map;M.forEach((u,x)=>{const p=g.left+x/(w-1||1)*(b-i);let O=0;u.forEach(T=>{const F=(A.get(T.id)||0)/k*h;z.set(T.id,{x:p,y:g.top+O,h:F}),O+=F+_})});const a=new Map,R=new Map;return t.forEach(u=>{a.set(u.id,0),R.set(u.id,0)}),e.jsx("div",{className:`nice-sankey ${C||""}`,style:L,children:e.jsxs("svg",{width:l,height:r,children:[v&&e.jsx("text",{x:l/2,y:20,textAnchor:"middle",className:"nice-chart__title",children:v}),s.map((u,x)=>{const p=z.get(u.source),O=z.get(u.target);if(!p||!O)return null;const T=a.get(u.source)||0,F=R.get(u.target)||0,G=u.value/k*h;a.set(u.source,T+G),R.set(u.target,F+G);const P=p.x+i,K=p.y+T,H=O.x,X=O.y+F,y=(P+H)/2,ce=t.find(ne=>ne.id===u.source)?.color||ye[x%ye.length];return e.jsx("path",{d:`M${P},${K} C${y},${K} ${y},${X} ${H},${X} L${H},${X+G} C${y},${X+G} ${y},${K+G} ${P},${K+G} Z`,fill:ce,fillOpacity:.3,stroke:ce,strokeOpacity:.5,strokeWidth:.5,children:e.jsx("title",{children:`${u.source} → ${u.target}: ${u.value}`})},x)}),t.map((u,x)=>{const p=z.get(u.id);if(!p)return null;const O=u.color||ye[x%ye.length];return e.jsxs("g",{children:[e.jsx("rect",{x:p.x,y:p.y,width:i,height:Math.max(p.h,2),fill:O,rx:2}),e.jsx("text",{x:p.x<b/2?p.x+i+4:p.x-4,y:p.y+p.h/2,textAnchor:p.x<b/2?"start":"end",dominantBaseline:"middle",className:"nice-chart__legend-text",children:u.label})]},u.id)})]})})},st=Object.freeze(Object.defineProperty({__proto__:null,NiceSankey:De},Symbol.toStringTag,{value:"Module"}));function it(t,s){const l=t.reduce((g,b)=>g+b.value,0);if(l===0||t.length===0)return[];const r=[];let{x:i,y:_,w:v,h:C}=s;const L=[...t].sort((g,b)=>b.value-g.value);for(const g of L){const b=g.value/l;if(v>=C){const h=v*b;r.push({x:i,y:_,w:h,h:C,node:g}),i+=h,v-=h}else{const h=C*b;r.push({x:i,y:_,w:v,h,node:g}),_+=h,C-=h}}return r}const ot=["var(--nice-color-primary, #3b82f6)","var(--nice-color-success, #10b981)","var(--nice-color-warning, #f59e0b)","var(--nice-color-error, #ef4444)","var(--nice-color-accent, #8b5cf6)","var(--nice-color-info, #06b6d4)","var(--nice-color-accent-pink, #ec4899)","var(--nice-success, #84cc16)"],Ee=Object.assign(c.forwardRef(({data:t,width:s=600,height:l=400,onNodeClick:r,colors:i=ot,className:_,style:v,id:C},L)=>{const g=le.useControlId(C),b=c.useMemo(()=>{const h=t.children??[t];return it(h,{x:0,y:0,w:s,h:l})},[t,s,l]);return e.jsx("div",{ref:L,id:g,className:`nice-treemap ${_||""}`,style:v,children:e.jsx("svg",{width:s,height:l,className:"nice-treemap__svg",children:b.map((h,D)=>e.jsxs("g",{onClick:()=>r?.(h.node),style:{cursor:r?"pointer":void 0},children:[e.jsx("rect",{x:h.x,y:h.y,width:Math.max(h.w-1,0),height:Math.max(h.h-1,0),fill:h.node.color??i[D%i.length],rx:2}),h.w>40&&h.h>20&&e.jsx("text",{x:h.x+h.w/2,y:h.y+h.h/2,textAnchor:"middle",dominantBaseline:"central",fill:"var(--nice-color-white, #fff)",fontSize:Math.min(12,h.w/6),className:"nice-treemap__label",children:h.node.label})]},h.node.key))})})}),{displayName:"NiceTreeMap"}),lt=Object.freeze(Object.defineProperty({__proto__:null,NiceTreeMap:Ee},Symbol.toStringTag,{value:"Module"})),dt=[],Pe=({regions:t=dt,width:s=600,height:l=400,viewBox:r="0 0 1000 600",colorRange:i=["#dbeafe","#1d4ed8"],maxValue:_,onRegionClick:v,selectedRegionId:C,title:L,showTooltip:g=!0,className:b,style:h})=>{const D=_??Math.max(...t.map(N=>N.value??0),1),I=N=>{const o=u=>[parseInt(u.slice(1,3),16),parseInt(u.slice(3,5),16),parseInt(u.slice(5,7),16)],[d,M,w]=o(i[0]),[A,S,k]=o(i[1]),z=Math.round(d+(A-d)*N),a=Math.round(M+(S-M)*N),R=Math.round(w+(k-w)*N);return`rgb(${z},${a},${R})`};return e.jsxs("div",{className:`nice-vectormap ${b||""}`,style:h,children:[L&&e.jsx("div",{className:"nice-vectormap__title",children:L}),e.jsx("svg",{width:s,height:l,viewBox:r,children:t.map(N=>{const o=N.value!=null?Math.max(0,Math.min(1,N.value/D)):0,d=N.value!=null?I(o):"var(--nice-bg-tertiary, #e5e7eb)",M=N.id===C;return e.jsx("path",{d:N.path,fill:d,stroke:M?"var(--nice-color-primary, #3b82f6)":"var(--nice-border-color, #d1d5db)",strokeWidth:M?2:.5,cursor:v?"pointer":void 0,onClick:()=>v?.(N),children:g&&e.jsx("title",{children:`${N.name}${N.value!=null?`: ${N.value}`:""}`})},N.id)})})]})},ht=Object.freeze(Object.defineProperty({__proto__:null,NiceVectorMap:Pe},Symbol.toStringTag,{value:"Module"})),ut=Object.assign(c.forwardRef(({data:t,renderNode:s,selectable:l,selectedKey:r,onSelect:i,direction:_="top-down",collapsible:v=!0,className:C,style:L,id:g},b)=>{const{t:h}=le.useNiceTranslation(),D=le.useControlId(g),[I,N]=c.useState(new Set),o=c.useCallback(w=>{N(A=>{const S=new Set(A);return S.has(w)?S.delete(w):S.add(w),S})},[]),d=c.useCallback(w=>{l&&i?.(w)},[l,i]),M=c.useCallback(w=>{const A=I.has(w.key),S=w.children&&w.children.length>0;return e.jsxs("li",{className:"nice-org-chart__item",children:[e.jsxs("div",{tabIndex:l?0:void 0,onKeyDown:l?le.clickOnActivationKey:void 0,className:`nice-org-chart__node${r===w.key?" nice-org-chart__node--selected":""}`,onClick:()=>d(w.key),role:l?"button":void 0,children:[s?s(w):e.jsx("span",{children:w.label}),v&&S&&e.jsx("button",{type:"button",className:"nice-org-chart__toggle",onClick:k=>{k.stopPropagation(),o(w.key)},"aria-label":A?h("organizationChart.expand","Expand"):h("organizationChart.collapse","Collapse"),children:e.jsx(le.NiceIcon,{name:A?"plus":"minus",size:14})})]}),S&&!A&&e.jsx("ul",{className:"nice-org-chart__children",children:w.children.map(k=>M(k))})]},w.key)},[I,r,s,l,v,d,o,h]);return e.jsx("div",{ref:b,id:D,className:`nice-org-chart nice-org-chart--${_} ${C||""}`,style:L,children:e.jsx("ul",{className:"nice-org-chart__root",children:M(t)})})}),{displayName:"NiceOrganizationChart"}),ft=[],xt=Object.assign(c.forwardRef(({data:t=ft,type:s="candlestick",showVolume:l=!0,width:r=800,height:i=400,bullColor:_="var(--nice-color-success, #22c55e)",bearColor:v="var(--nice-color-error, #ef4444)",className:C,style:L,id:g},b)=>{const h=le.useControlId(g),D={top:20,right:20,bottom:l?80:30,left:60},I=r-D.left-D.right,N=l?50:0,o=i-D.top-D.bottom-N,{minP:d,maxP:M,maxVol:w}=c.useMemo(()=>{if(t.length===0)return{minP:0,maxP:1,maxVol:0};let a=1/0,R=-1/0,u=0;for(const x of t)x.low<a&&(a=x.low),x.high>R&&(R=x.high),x.volume&&x.volume>u&&(u=x.volume);return{minP:a,maxP:R,maxVol:u}},[t]),A=Math.max(1,I/t.length*.7),S=a=>D.left+(a+.5)*(I/t.length),k=a=>D.top+o-(a-d)/(M-d||1)*o,z=a=>i-D.bottom-N+N*(1-a/(w||1));return e.jsx("div",{ref:b,id:h,className:`nice-stock-chart ${C||""}`,style:L,children:e.jsxs("svg",{width:r,height:i,className:"nice-stock-chart__svg",children:[[0,.25,.5,.75,1].map(a=>{const R=d+a*(M-d);return e.jsxs("g",{children:[e.jsx("line",{x1:D.left,x2:r-D.right,y1:k(R),y2:k(R),stroke:"var(--nice-border, #e5e7eb)",strokeDasharray:"2,2"}),t.length>0&&e.jsx("text",{x:D.left-4,y:k(R)+4,textAnchor:"end",fontSize:10,fill:"var(--nice-text-secondary, #888)",children:R.toFixed(2)})]},a)}),s==="line"?e.jsx("polyline",{points:t.map((a,R)=>`${S(R)},${k(a.close)}`).join(" "),fill:"none",stroke:_,strokeWidth:1.5}):t.map((a,R)=>{const u=a.close>=a.open,x=u?_:v,p=S(R);if(s==="ohlc")return e.jsxs("g",{children:[e.jsx("line",{x1:p,x2:p,y1:k(a.high),y2:k(a.low),stroke:x,strokeWidth:1}),e.jsx("line",{x1:p-A/2,x2:p,y1:k(a.open),y2:k(a.open),stroke:x,strokeWidth:1.5}),e.jsx("line",{x1:p,x2:p+A/2,y1:k(a.close),y2:k(a.close),stroke:x,strokeWidth:1.5})]},R);const O=k(Math.max(a.open,a.close)),T=k(Math.min(a.open,a.close));return e.jsxs("g",{children:[e.jsx("line",{x1:p,x2:p,y1:k(a.high),y2:k(a.low),stroke:x,strokeWidth:1}),e.jsx("rect",{x:p-A/2,y:O,width:A,height:Math.max(T-O,1),fill:u?"transparent":x,stroke:x,strokeWidth:1})]},R)}),l&&t.map((a,R)=>{if(!a.volume)return null;const u=a.close>=a.open;return e.jsx("rect",{x:S(R)-A/2,y:z(a.volume),width:A,height:i-D.bottom-z(a.volume),fill:u?_:v,opacity:.3},`v${R}`)}),t.map((a,R)=>R%Math.max(1,Math.floor(t.length/8))!==0?null:e.jsx("text",{x:S(R),y:i-D.bottom+N+14,textAnchor:"middle",fontSize:9,fill:"var(--nice-text-secondary, #888)",children:a.date},`l${R}`))]})})}),{displayName:"NiceStockChart"}),mt=[],pt=({data:t=mt,width:s=120,height:l=30,type:r="line",color:i="var(--nice-color-primary, #3b82f6)",showMinMax:_,showLastPoint:v=!0,className:C,style:L})=>{if(t.length===0)return null;const g=2,b=Math.min(...t),h=Math.max(...t),D=h-b||1,I=s-g*2,N=l-g*2,o=k=>g+k/(t.length-1||1)*I,d=k=>g+N-(k-b)/D*N;if(r==="bar"){const k=Math.max(1,I/t.length-1);return e.jsx("svg",{width:s,height:l,className:`nice-sparkline ${C||""}`,style:L,children:t.map((z,a)=>e.jsx("rect",{x:g+a/t.length*I,y:d(z),width:k,height:N-(d(z)-g),fill:i,rx:1},a))})}const M=t.map((k,z)=>`${o(z)},${d(k)}`).join(" "),w=t.indexOf(b),A=t.indexOf(h),S=t.length-1;return e.jsxs("svg",{width:s,height:l,className:`nice-sparkline ${C||""}`,style:L,children:[r==="area"&&e.jsx("polygon",{points:`${o(0)},${g+N} ${M} ${o(S)},${g+N}`,fill:i,opacity:.15}),e.jsx("polyline",{points:M,fill:"none",stroke:i,strokeWidth:1.5}),_&&e.jsx("circle",{cx:o(w),cy:d(b),r:2,fill:"var(--nice-danger, #ef4444)"}),_&&e.jsx("circle",{cx:o(A),cy:d(h),r:2,fill:"var(--nice-success, #22c55e)"}),v&&e.jsx("circle",{cx:o(S),cy:d(t[S]),r:2,fill:i})]})},gt=[],vt=[],yt=({series:t=gt,categories:s=vt,width:l=400,height:r=400,maxValue:i,title:_,showLegend:v=!0,className:C,style:L})=>{const g=l/2,b=(r-(v?30:0))/2+(_?10:0),h=Math.min(g,b)-60,D=s.length,I=i??Math.max(...t.flatMap(M=>M.data),1),N=Math.PI*2/D,o=5,d=(M,w)=>{const A=M*N-Math.PI/2,S=w/I*h;return{x:g+S*Math.cos(A),y:b+S*Math.sin(A)}};return e.jsx("div",{className:`nice-polarchart ${C||""}`,style:L,children:e.jsxs("svg",{width:l,height:r,className:"nice-polarchart__svg",children:[_&&e.jsx("text",{x:g,y:20,textAnchor:"middle",className:"nice-chart__title",children:_}),Array.from({length:o},(M,w)=>{const A=h*((w+1)/o);return e.jsx("circle",{cx:g,cy:b,r:A,fill:"none",stroke:"var(--nice-border-color, #ddd)",strokeWidth:.5},w)}),s.map((M,w)=>{const A=d(w,I),S=d(w,I*1.22),k=w*N-Math.PI/2,z=Math.cos(k),a=Math.sin(k),R=z>.2?"start":z<-.2?"end":"middle",u=a>.2?"hanging":a<-.2?"auto":"middle";return e.jsxs("g",{children:[e.jsx("line",{x1:g,y1:b,x2:A.x,y2:A.y,stroke:"var(--nice-border-color, #ddd)",strokeWidth:.5}),e.jsx("text",{x:S.x,y:S.y,textAnchor:R,dominantBaseline:u,className:"nice-chart__axis-label nice-chart__axis-label--polar",children:M})]},w)}),t.map((M,w)=>{const A=M.color||ye[w%ye.length],S=M.data.map((k,z)=>{const a=d(z,k);return`${a.x},${a.y}`}).join(" ");return e.jsxs("g",{children:[e.jsx("polygon",{points:S,fill:M.fill!==!1?A:"none",fillOpacity:.15,stroke:A,strokeWidth:2}),M.data.map((k,z)=>{const a=d(z,k);return e.jsx("circle",{cx:a.x,cy:a.y,r:3,fill:A,children:e.jsx("title",{children:`${M.name} - ${s[z]}: ${k}`})},z)})]},M.name)}),v&&e.jsx("g",{transform:`translate(10, ${r-25})`,children:t.map((M,w)=>e.jsxs("g",{transform:`translate(${w*100}, 0)`,children:[e.jsx("rect",{width:10,height:10,rx:2,fill:M.color||ye[w%ye.length]}),e.jsx("text",{x:14,y:9,className:"nice-chart__legend-text",children:M.name})]},w))})]})})},bt=({data:t,min:s,max:l,start:r,end:i,onChange:_,width:v=500,height:C=100,step:L=1,formatValue:g,chartColor:b="var(--nice-color-primary, #3b82f6)",className:h,style:D})=>{const I={top:10,bottom:30,left:10,right:10},N=v-I.left-I.right,o=C-I.top-I.bottom,d=z=>I.left+(z-s)/(l-s||1)*N,M=z=>{const a=Math.max(0,Math.min(1,(z-I.left)/N)),R=s+a*(l-s);return Math.round(R/L)*L},w=(z,a)=>{a.preventDefault();const R=a.target.closest("svg");if(!R)return;const u=p=>{const O=R.getBoundingClientRect(),T=M(p.clientX-O.left);z==="start"?_(Math.min(T,i),i):_(r,Math.max(T,r))},x=()=>{document.removeEventListener("pointermove",u),document.removeEventListener("pointerup",x)};document.addEventListener("pointermove",u),document.addEventListener("pointerup",x)},A=t?Math.min(...t):0,k=(t?Math.max(...t):1)-A||1;return e.jsx("div",{className:`nice-rangeselector ${h||""}`,style:D,children:e.jsxs("svg",{width:v,height:C,children:[t&&t.length>1&&e.jsx("polygon",{points:`${I.left},${I.top+o} ${t.map((z,a)=>`${I.left+a/(t.length-1)*N},${I.top+o-(z-A)/k*o}`).join(" ")} ${I.left+N},${I.top+o}`,fill:b,opacity:.15}),e.jsx("rect",{x:d(r),y:I.top,width:d(i)-d(r),height:o,fill:b,opacity:.1}),e.jsx("rect",{x:I.left,y:I.top,width:d(r)-I.left,height:o,fill:"var(--nice-bg-secondary, #f5f5f5)",opacity:.6}),e.jsx("rect",{x:d(i),y:I.top,width:I.left+N-d(i),height:o,fill:"var(--nice-bg-secondary, #f5f5f5)",opacity:.6}),e.jsx("rect",{x:d(r)-4,y:I.top,width:8,height:o,fill:b,rx:2,cursor:"ew-resize",onPointerDown:z=>w("start",z)}),e.jsx("rect",{x:d(i)-4,y:I.top,width:8,height:o,fill:b,rx:2,cursor:"ew-resize",onPointerDown:z=>w("end",z)}),e.jsx("text",{x:d(r),y:I.top+o+18,textAnchor:"middle",className:"nice-chart__axis-label",children:g?g(r):r}),e.jsx("text",{x:d(i),y:I.top+o+18,textAnchor:"middle",className:"nice-chart__axis-label",children:g?g(i):i})]})})},_t=`
|
|
7
|
+
.nice-forecast-chart {
|
|
8
|
+
display: flex;
|
|
9
|
+
flex-direction: column;
|
|
10
|
+
background: var(--nice-bg-primary, #ffffff);
|
|
11
|
+
border: 1px solid var(--nice-border-color, #e5e7eb);
|
|
12
|
+
border-radius: var(--nice-radius-lg, 0.5rem);
|
|
13
|
+
overflow: hidden;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.nice-forecast-chart__header {
|
|
17
|
+
display: flex;
|
|
18
|
+
align-items: center;
|
|
19
|
+
justify-content: space-between;
|
|
20
|
+
padding: 0.75rem 1rem;
|
|
21
|
+
border-bottom: 1px solid var(--nice-border-color, #e5e7eb);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.nice-forecast-chart__title {
|
|
25
|
+
font-size: 1rem;
|
|
26
|
+
font-weight: 600;
|
|
27
|
+
color: var(--nice-text-primary);
|
|
28
|
+
margin: 0;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.nice-forecast-chart__actions {
|
|
32
|
+
display: flex;
|
|
33
|
+
gap: 0.5rem;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.nice-forecast-chart__btn {
|
|
37
|
+
display: inline-flex;
|
|
38
|
+
align-items: center;
|
|
39
|
+
justify-content: center;
|
|
40
|
+
width: 2rem;
|
|
41
|
+
height: 2rem;
|
|
42
|
+
font-size: 1rem;
|
|
43
|
+
border-radius: var(--nice-radius-md, 0.375rem);
|
|
44
|
+
cursor: pointer;
|
|
45
|
+
transition: all 0.15s ease;
|
|
46
|
+
border: 1px solid var(--nice-border-color, #d1d5db);
|
|
47
|
+
background: var(--nice-bg-primary, #ffffff);
|
|
48
|
+
color: var(--nice-text-secondary);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.nice-forecast-chart__btn:hover {
|
|
52
|
+
background: var(--nice-bg-hover, #f3f4f6);
|
|
53
|
+
color: var(--nice-text-primary);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.nice-forecast-chart__btn:disabled {
|
|
57
|
+
opacity: 0.5;
|
|
58
|
+
cursor: not-allowed;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.nice-forecast-chart__container {
|
|
62
|
+
position: relative;
|
|
63
|
+
width: 100%;
|
|
64
|
+
padding: 1rem;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.nice-forecast-chart__svg {
|
|
68
|
+
width: 100%;
|
|
69
|
+
overflow: visible;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.nice-forecast-chart__grid-line {
|
|
73
|
+
stroke: var(--nice-border-divider, #f3f4f6);
|
|
74
|
+
stroke-width: 1;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.nice-forecast-chart__axis-line {
|
|
78
|
+
stroke: var(--nice-border-color, #e5e7eb);
|
|
79
|
+
stroke-width: 1;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.nice-forecast-chart__axis-label {
|
|
83
|
+
font-size: 0.6875rem;
|
|
84
|
+
fill: var(--nice-text-secondary);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.nice-forecast-chart__axis-title {
|
|
88
|
+
font-size: 0.75rem;
|
|
89
|
+
font-weight: 500;
|
|
90
|
+
fill: var(--nice-text-primary);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.nice-forecast-chart__historical-line {
|
|
94
|
+
fill: none;
|
|
95
|
+
stroke-width: 2;
|
|
96
|
+
stroke-linecap: round;
|
|
97
|
+
stroke-linejoin: round;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.nice-forecast-chart__forecast-line {
|
|
101
|
+
fill: none;
|
|
102
|
+
stroke-width: 2;
|
|
103
|
+
stroke-linecap: round;
|
|
104
|
+
stroke-linejoin: round;
|
|
105
|
+
stroke-dasharray: 6, 4;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.nice-forecast-chart__confidence-band {
|
|
109
|
+
opacity: 0.2;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.nice-forecast-chart__forecast-region {
|
|
113
|
+
fill: var(--nice-bg-secondary, #f9fafb);
|
|
114
|
+
opacity: 0.5;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.nice-forecast-chart__point {
|
|
118
|
+
cursor: pointer;
|
|
119
|
+
transition: r 0.15s ease;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.nice-forecast-chart__point:hover {
|
|
123
|
+
r: 6;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.nice-forecast-chart__annotation-line {
|
|
127
|
+
stroke-dasharray: 4, 2;
|
|
128
|
+
stroke-width: 1;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.nice-forecast-chart__annotation-marker {
|
|
132
|
+
cursor: pointer;
|
|
133
|
+
transition: transform 0.15s ease;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.nice-forecast-chart__annotation-marker:hover {
|
|
137
|
+
transform: scale(1.2);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.nice-forecast-chart__reference-line {
|
|
141
|
+
stroke-width: 1;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.nice-forecast-chart__reference-label {
|
|
145
|
+
font-size: 0.625rem;
|
|
146
|
+
fill: var(--nice-text-secondary);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
.nice-forecast-chart__cash-runway {
|
|
150
|
+
pointer-events: none;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
.nice-forecast-chart__cash-runway-line {
|
|
154
|
+
stroke: var(--nice-danger, #ef4444);
|
|
155
|
+
stroke-width: 2;
|
|
156
|
+
stroke-dasharray: 8, 4;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.nice-forecast-chart__cash-runway-label-bg {
|
|
160
|
+
fill: var(--nice-danger, #ef4444);
|
|
161
|
+
rx: 4;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.nice-forecast-chart__cash-runway-label {
|
|
165
|
+
font-size: 0.6875rem;
|
|
166
|
+
font-weight: 600;
|
|
167
|
+
fill: var(--nice-bg, #FFFFFF);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
.nice-forecast-chart__cash-runway-date {
|
|
171
|
+
font-size: 0.625rem;
|
|
172
|
+
fill: var(--nice-danger, #ef4444);
|
|
173
|
+
font-weight: 500;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.nice-forecast-chart__tooltip {
|
|
177
|
+
position: absolute;
|
|
178
|
+
pointer-events: none;
|
|
179
|
+
z-index: 100;
|
|
180
|
+
padding: 0.75rem;
|
|
181
|
+
background: var(--nice-bg-primary, #ffffff);
|
|
182
|
+
border: 1px solid var(--nice-border-color, #e5e7eb);
|
|
183
|
+
border-radius: var(--nice-radius-lg, 0.5rem);
|
|
184
|
+
box-shadow: 0 4px 12px var(--nice-overlay-10, rgba(0, 0, 0, 0.1));
|
|
185
|
+
font-size: 0.8125rem;
|
|
186
|
+
max-width: 250px;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
.nice-forecast-chart__tooltip-date {
|
|
190
|
+
font-weight: 600;
|
|
191
|
+
color: var(--nice-text-primary);
|
|
192
|
+
margin-bottom: 0.5rem;
|
|
193
|
+
padding-bottom: 0.5rem;
|
|
194
|
+
border-bottom: 1px solid var(--nice-border-divider, #f3f4f6);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
.nice-forecast-chart__tooltip-item {
|
|
198
|
+
display: flex;
|
|
199
|
+
align-items: center;
|
|
200
|
+
gap: 0.5rem;
|
|
201
|
+
margin-bottom: 0.25rem;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
.nice-forecast-chart__tooltip-color {
|
|
205
|
+
width: 10px;
|
|
206
|
+
height: 10px;
|
|
207
|
+
border-radius: var(--nice-radius-sm, 2px);
|
|
208
|
+
flex-shrink: 0;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
.nice-forecast-chart__tooltip-label {
|
|
212
|
+
color: var(--nice-text-secondary);
|
|
213
|
+
flex: 1;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
.nice-forecast-chart__tooltip-value {
|
|
217
|
+
font-weight: 600;
|
|
218
|
+
color: var(--nice-text-primary);
|
|
219
|
+
font-variant-numeric: tabular-nums;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
.nice-forecast-chart__tooltip-confidence {
|
|
223
|
+
font-size: 0.75rem;
|
|
224
|
+
color: var(--nice-text-tertiary);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
.nice-forecast-chart__legend {
|
|
228
|
+
display: flex;
|
|
229
|
+
flex-wrap: wrap;
|
|
230
|
+
gap: 1rem;
|
|
231
|
+
padding: 0.75rem 1rem;
|
|
232
|
+
border-top: 1px solid var(--nice-border-color, #e5e7eb);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
.nice-forecast-chart__legend-item {
|
|
236
|
+
display: flex;
|
|
237
|
+
align-items: center;
|
|
238
|
+
gap: 0.375rem;
|
|
239
|
+
font-size: 0.8125rem;
|
|
240
|
+
color: var(--nice-text-secondary);
|
|
241
|
+
cursor: pointer;
|
|
242
|
+
user-select: none;
|
|
243
|
+
transition: opacity 0.15s ease;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
.nice-forecast-chart__legend-item:hover {
|
|
247
|
+
color: var(--nice-text-primary);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
.nice-forecast-chart__legend-item--hidden {
|
|
251
|
+
opacity: 0.4;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
.nice-forecast-chart__legend-color {
|
|
255
|
+
width: 16px;
|
|
256
|
+
height: 3px;
|
|
257
|
+
border-radius: var(--nice-radius-xs, 1px);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
.nice-forecast-chart__legend-color--dashed {
|
|
261
|
+
background: repeating-linear-gradient(
|
|
262
|
+
90deg,
|
|
263
|
+
currentColor,
|
|
264
|
+
currentColor 4px,
|
|
265
|
+
transparent 4px,
|
|
266
|
+
transparent 6px
|
|
267
|
+
);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
.nice-forecast-chart__empty {
|
|
271
|
+
display: flex;
|
|
272
|
+
align-items: center;
|
|
273
|
+
justify-content: center;
|
|
274
|
+
height: 300px;
|
|
275
|
+
color: var(--nice-text-secondary);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/* Dark mode */
|
|
279
|
+
.dark .nice-forecast-chart {
|
|
280
|
+
background: var(--nice-bg-primary-dark, #111827);
|
|
281
|
+
border-color: var(--nice-border-color-dark, #374151);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
.dark .nice-forecast-chart__tooltip {
|
|
285
|
+
background: var(--nice-bg-secondary-dark, #1f2937);
|
|
286
|
+
border-color: var(--nice-border-color-dark, #374151);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
.dark .nice-forecast-chart__forecast-region {
|
|
290
|
+
fill: var(--nice-bg-secondary-dark, #1f2937);
|
|
291
|
+
}
|
|
292
|
+
`,ze=["var(--nice-color-primary, #3b82f6)","var(--nice-color-success, #10b981)","var(--nice-color-warning, #f59e0b)","var(--nice-color-error, #ef4444)","var(--nice-color-accent, #8b5cf6)","var(--nice-color-accent-pink, #ec4899)","var(--nice-color-info, #06b6d4)","var(--nice-warning, #f97316)"];function ve(t){return t instanceof Date?t:new Date(t)}function Ae(t,s="pl-PL"){return t.toLocaleDateString(s,{year:"numeric",month:"short",day:"numeric"})}function $e(t,s="pl-PL"){return new Intl.NumberFormat(s,{minimumFractionDigits:0,maximumFractionDigits:2}).format(t)}const jt={top:20,right:30,bottom:40,left:60},Mt=c.forwardRef(function(s,l){const{t:r}=le.useNiceTranslation(),{scenarios:i,data:_,annotations:v=[],referenceLines:C=[],forecastStartDate:L,cashRunway:g,xAxis:b,yAxis:h,confidenceBands:D=[{level:95,color:"var(--nice-color-primary, #3b82f6)",opacity:.15}],tooltip:I,legend:N={enabled:!0,position:"bottom",interactive:!0},height:o=350,showForecastRegion:d=!0,lineWidth:M=2,showPoints:w=!1,pointRadius:A=4,enableZoom:S=!1,zoomEnabled:k,animationDuration:z=300,showLegend:a,responsive:R=!0,onPointClick:u,onAnnotationClick:x,onScenarioToggle:p,onViewportChange:O,size:T="medium",disabled:F=!1,labels:G={},locale:P="pl-PL",className:K,style:H}=s,X=i&&i.length>0?i:_?[{id:"default",name:"Series",data:_}]:[],y={...N,enabled:a??N.enabled},[q,ce]=c.useState(()=>X.map((n,W)=>({...n,color:n.color??ze[W%ze.length],visible:n.visible!==!1}))),[ne,Z]=c.useState(null),[ae,E]=c.useState({x:0,y:0}),f=c.useRef(null),B=c.useRef(null),m=jt,[Y,he]=c.useState({width:600,height:typeof o=="number"?o:350});c.useEffect(()=>{if(!R||!f.current)return;const n=new ResizeObserver(W=>{for(const U of W)he($=>({width:U.contentRect.width,height:$.height}))});return n.observe(f.current),()=>n.disconnect()},[R]),c.useEffect(()=>{const n="nice-forecast-chart-styles";if(!document.getElementById(n)){const W=document.createElement("style");W.id=n,W.textContent=_t,document.head.appendChild(W)}},[]);const{xScale:V,yScale:re,allDates:de,minY:pe,maxY:je}=c.useMemo(()=>{const W=q.filter(xe=>xe.visible!==!1).flatMap(xe=>xe.data);if(W.length===0)return{xScale:()=>0,yScale:()=>0,allDates:[],minY:0,maxY:100};const U=W.map(xe=>ve(xe.date).getTime()),$=Math.min(...U),J=Math.max(...U),te=W.flatMap(xe=>[xe.value,xe.forecast,xe.lowerBound,xe.upperBound]).filter(xe=>xe!=null),se=h?.min??Math.min(...te)*.95,oe=h?.max??Math.max(...te)*1.05,fe=Y.width-m.left-m.right,me=Y.height-m.top-m.bottom,Ne=xe=>{const Ie=typeof xe=="number"?xe:xe.getTime();return m.left+(Ie-$)/(J-$)*fe},ke=xe=>m.top+me-(xe-se)/(oe-se)*me,Ce=[...new Set(U)].sort((xe,Ie)=>xe-Ie).map(xe=>new Date(xe));return{xScale:Ne,yScale:ke,allDates:Ce,minY:se,maxY:oe}},[q,Y,m,h]),ge=L?ve(L):null,_e=c.useMemo(()=>{if(!g?.enabled)return null;const n=g.threshold??0,W=g.scenarioId?q.find($=>$.id===g.scenarioId&&$.visible!==!1):q.find($=>$.visible!==!1);if(!W)return null;const U=W.data.sort(($,J)=>ve($.date).getTime()-ve(J.date).getTime());for(let $=1;$<U.length;$++){const J=U[$-1],te=U[$],se=J.forecast??J.value,oe=te.forecast??te.value;if(se!=null&&oe!=null&&se>n&&oe<=n){const fe=(se-n)/(se-oe),me=ve(J.date).getTime(),Ne=ve(te.date).getTime(),ke=me+fe*(Ne-me);return new Date(ke)}}return null},[g,q]),Me=c.useCallback((n,W)=>{const U=n.filter($=>$[W]!=null).map($=>({x:V(ve($.date)),y:re($[W])}));return U.length===0?"":`M ${U.map($=>`${$.x},${$.y}`).join(" L ")}`},[V,re]),ee=c.useCallback(n=>{const W=n.filter(J=>J.lowerBound!=null&&J.upperBound!=null);if(W.length===0)return"";const U=W.map(J=>({x:V(ve(J.date)),y:re(J.upperBound)})),$=W.map(J=>({x:V(ve(J.date)),y:re(J.lowerBound)})).reverse();return`M ${U.map(J=>`${J.x},${J.y}`).join(" L ")} L ${$.map(J=>`${J.x},${J.y}`).join(" L ")} Z`},[V,re]),ie=c.useCallback(n=>{if(!B.current||I?.enabled===!1)return;const W=B.current.getBoundingClientRect(),U=n.clientX-W.left;n.clientY-W.top;let $=null,J=1/0;for(const te of de){const se=V(te),oe=Math.abs(se-U);oe<J&&(J=oe,$=te)}if($&&J<50){const te=q.filter(oe=>oe.visible!==!1).map(oe=>{const fe=oe.data.find(me=>ve(me.date).getTime()===$.getTime());return{scenario:oe,value:fe?.value,forecast:fe?.forecast,lowerBound:fe?.lowerBound,upperBound:fe?.upperBound}}),se=v.filter(oe=>Math.abs(ve(oe.date).getTime()-$.getTime())<864e5);Z({date:$,values:te,annotations:se}),E({x:n.clientX-W.left+10,y:n.clientY-W.top-10})}else Z(null)},[V,de,q,v,I]),ue=c.useCallback(n=>{if(!y.interactive)return;ce(U=>U.map($=>$.id===n?{...$,visible:!$.visible}:$));const W=q.find(U=>U.id===n);W&&p?.(n,!W.visible)},[y.interactive,q,p]);c.useImperativeHandle(l,()=>({getScenarios:()=>q,updateScenario:(n,W)=>{ce(U=>U.map($=>$.id===n?{...$,data:W}:$))},toggleScenario:ue,setZoomRange:()=>{},resetZoom:()=>{},exportImage:n=>{if(!B.current)return null;const W=B.current,$=new XMLSerializer().serializeToString(W);return`data:image/svg+xml;base64,${btoa($)}`},getDataAtDate:n=>{const W=q.filter(U=>U.visible!==!1).map(U=>{const $=U.data.find(J=>ve(J.date).getTime()===n.getTime());return{scenario:U,value:$?.value,forecast:$?.forecast,lowerBound:$?.lowerBound,upperBound:$?.upperBound}});return{date:n,values:W,annotations:v.filter(U=>ve(U.date).getTime()===n.getTime())}}}),[q,v,ue]),Y.width-m.left-m.right;const be=Y.height-m.top-m.bottom,j=c.useMemo(()=>{const n=h?.tickCount??5,W=[],U=(je-pe)/(n-1);for(let $=0;$<n;$++)W.push(pe+U*$);return W},[pe,je,h?.tickCount]),Q=c.useMemo(()=>{const n=b?.tickCount??6;if(de.length===0)return[];const W=Math.max(1,Math.floor(de.length/(n-1)));return de.filter((U,$)=>$%W===0||$===de.length-1)},[de,b?.tickCount]);return q.length===0||q.every(n=>n.data.length===0)?e.jsx("div",{className:`nice-forecast-chart ${K??""}`,style:H,children:e.jsx("div",{className:"nice-forecast-chart__empty",children:G.noData??r("forecastChart.noDataAvailable","No data available")})}):e.jsxs("div",{className:`nice-forecast-chart ${K??""}`,style:{...H,height:o},children:[e.jsxs("div",{ref:f,className:"nice-forecast-chart__container",children:[e.jsxs("svg",{ref:B,className:"nice-forecast-chart__svg",width:Y.width,height:Y.height,onMouseMove:ie,onMouseLeave:()=>Z(null),children:[h?.showGrid!==!1&&j.map(n=>e.jsx("line",{className:"nice-forecast-chart__grid-line",x1:m.left,x2:Y.width-m.right,y1:re(n),y2:re(n)},n)),d&&ge&&e.jsx("rect",{className:"nice-forecast-chart__forecast-region",x:V(ge),y:m.top,width:Y.width-m.right-V(ge),height:be}),C.map(n=>e.jsxs("g",{children:[e.jsx("line",{className:"nice-forecast-chart__reference-line",x1:m.left,x2:Y.width-m.right,y1:re(n.value),y2:re(n.value),stroke:n.color??"var(--nice-text-muted, #9ca3af)",strokeDasharray:n.dashArray??"4,2"}),n.label&&e.jsx("text",{className:"nice-forecast-chart__reference-label",x:Y.width-m.right-4,y:re(n.value)-4,textAnchor:"end",children:n.label})]},n.id)),_e&&g?.enabled&&e.jsxs("g",{className:"nice-forecast-chart__cash-runway",children:[e.jsx("line",{className:"nice-forecast-chart__cash-runway-line",x1:V(_e),x2:V(_e),y1:m.top,y2:Y.height-m.bottom,stroke:g.color??"var(--nice-color-error, #ef4444)"}),g.showLabel!==!1&&e.jsxs(e.Fragment,{children:[e.jsx("rect",{className:"nice-forecast-chart__cash-runway-label-bg",x:V(_e)-60,y:m.top-2,width:120,height:g.showDate!==!1?32:20,fill:g.color??"var(--nice-color-error, #ef4444)",rx:4}),e.jsx("text",{className:"nice-forecast-chart__cash-runway-label",x:V(_e),y:m.top+12,textAnchor:"middle",fill:"var(--nice-color-white, #fff)",children:g.label??G.cashRunsOut??r("forecastChart.cashRunsOut","Cash runs out")}),g.showDate!==!1&&e.jsx("text",{className:"nice-forecast-chart__cash-runway-label",x:V(_e),y:m.top+26,textAnchor:"middle",fill:"var(--nice-color-white, #fff)",style:{fontSize:"0.625rem",opacity:.9},children:Ae(_e,P)})]})]}),q.filter(n=>n.visible!==!1&&n.showConfidenceBand).map(n=>e.jsx("path",{className:"nice-forecast-chart__confidence-band",d:ee(n.data),fill:n.color},`band-${n.id}`)),q.filter(n=>n.visible!==!1).map(n=>{const W=ge?n.data.filter($=>ve($.date)<ge):n.data.filter($=>$.value!=null),U=ge?n.data.filter($=>ve($.date)>=ge):n.data.filter($=>$.forecast!=null);return e.jsxs("g",{children:[e.jsx("path",{className:"nice-forecast-chart__historical-line",d:Me(W,"value"),stroke:n.color,strokeWidth:M}),e.jsx("path",{className:"nice-forecast-chart__forecast-line",d:Me(U,ge?"value":"forecast"),stroke:n.color,strokeWidth:M}),U.length>0&&n.data.some($=>$.forecast!=null)&&e.jsx("path",{className:"nice-forecast-chart__forecast-line",d:Me(n.data,"forecast"),stroke:n.color,strokeWidth:M}),w&&n.data.map(($,J)=>{const te=$.value??$.forecast;return te==null?null:e.jsx("circle",{className:"nice-forecast-chart__point",cx:V(ve($.date)),cy:re(te),r:A,fill:n.color,onClick:()=>u?.($,n)},J)})]},n.id)}),v.map(n=>{const W=V(ve(n.date));return e.jsxs("g",{className:"nice-forecast-chart__annotation-marker",onClick:()=>x?.(n),children:[n.showLine!==!1&&e.jsx("line",{className:"nice-forecast-chart__annotation-line",x1:W,x2:W,y1:m.top,y2:Y.height-m.bottom,stroke:n.color??"var(--nice-text-muted, #9ca3af)"}),e.jsx("circle",{cx:W,cy:m.top+10,r:8,fill:n.color??"var(--nice-text-muted, #9ca3af)"}),e.jsx("text",{x:W,y:m.top+14,textAnchor:"middle",fill:"white",fontSize:"10",children:n.icon??"!"})]},n.id)}),e.jsx("line",{className:"nice-forecast-chart__axis-line",x1:m.left,x2:m.left,y1:m.top,y2:Y.height-m.bottom}),e.jsx("line",{className:"nice-forecast-chart__axis-line",x1:m.left,x2:Y.width-m.right,y1:Y.height-m.bottom,y2:Y.height-m.bottom}),j.map(n=>e.jsx("text",{className:"nice-forecast-chart__axis-label",x:m.left-8,y:re(n)+4,textAnchor:"end",children:h?.format?h.format(n):$e(n,P)},n)),Q.map(n=>e.jsx("text",{className:"nice-forecast-chart__axis-label",x:V(n),y:Y.height-m.bottom+16,textAnchor:"middle",children:b?.format?b.format(n):Ae(n,P)},n.getTime())),h?.title&&e.jsx("text",{className:"nice-forecast-chart__axis-title",x:15,y:Y.height/2,textAnchor:"middle",transform:`rotate(-90, 15, ${Y.height/2})`,children:h.title})]}),ne&&e.jsxs("div",{className:"nice-forecast-chart__tooltip",style:{left:ae.x,top:ae.y},children:[e.jsx("div",{className:"nice-forecast-chart__tooltip-date",children:Ae(ne.date,P)}),ne.values.map(n=>{const W=n.value??n.forecast;return W==null?null:e.jsxs("div",{className:"nice-forecast-chart__tooltip-item",children:[e.jsx("span",{className:"nice-forecast-chart__tooltip-color",style:{background:n.scenario.color}}),e.jsx("span",{className:"nice-forecast-chart__tooltip-label",children:n.scenario.name}),e.jsx("span",{className:"nice-forecast-chart__tooltip-value",children:$e(W,P)})]},n.scenario.id)}),ne.values.some(n=>n.lowerBound!=null)&&e.jsxs("div",{className:"nice-forecast-chart__tooltip-confidence",children:[G.confidence??r("forecastChart.ci","CI"),":"," ",$e(ne.values[0]?.lowerBound??0,P)," –"," ",$e(ne.values[0]?.upperBound??0,P)]})]})]}),y.enabled&&e.jsx("div",{className:"nice-forecast-chart__legend",children:q.map(n=>e.jsxs("div",{role:"button",tabIndex:0,"aria-pressed":n.visible!==!1,onKeyDown:le.clickOnActivationKey,className:`nice-forecast-chart__legend-item ${n.visible===!1?"nice-forecast-chart__legend-item--hidden":""}`,onClick:()=>ue(n.id),children:[e.jsx("span",{className:`nice-forecast-chart__legend-color ${n.isBase?"":"nice-forecast-chart__legend-color--dashed"}`,style:{background:n.color}}),n.name]},n.id))})]})}),Nt=[];function wt(t,s){const l=t?typeof t=="number"?new Date(t):new Date(t):new Date,r=L=>L.toString().padStart(2,"0"),i=r(l.getHours()),_=r(l.getMinutes()),v=r(l.getSeconds()),C=l.getMilliseconds().toString().padStart(3,"0");switch(s){case"HH:mm:ss":return`${i}:${_}:${v}`;case"HH:mm":return`${i}:${_}`;case"mm:ss":return`${_}:${v}`;case"ss.SSS":return`${v}.${C}`;case"ISO":return l.toISOString();default:return`${i}:${_}:${v}`}}function Le(t){if(t.length===0)return null;const s=Math.min(...t),l=Math.max(...t),r=t.reduce((_,v)=>_+v,0)/t.length,i=t[t.length-1];return{min:s,max:l,avg:r,current:i,count:t.length}}const kt=Object.assign(c.forwardRef(({series:t=Nt,maxPoints:s=100,slidingWindow:l=!0,refreshRate:r=16,dataSource:i,width:_=600,height:v=400,title:C,showLegend:L=!0,showGrid:g=!0,yAxisLabel:b,xAxisLabel:h,stacked:D,zoomable:I,crosshair:N,annotations:o=[],legendInteractive:d,onDataPointClick:M,exportable:w,showControls:A=!0,showStatus:S=!0,initialPaused:k=!1,onDataReceived:z,onDataDropped:a,timeFormat:R="HH:mm:ss",showStats:u,thresholds:x=[],className:p,style:O},T)=>{const[F,G]=c.useState(()=>{const ee=new Map;for(const ie of t)ee.set(ie.name,ie.initialData?.slice()??[]);return ee}),[P,K]=c.useState([]),{t:H}=le.useNiceTranslation(),[X,y]=c.useState(k),[q,ce]=c.useState(!1),ne=c.useRef([]),Z=c.useRef(Date.now()),ae=c.useRef(null),E=c.useRef(new Map),f=c.useRef(0),B=JSON.stringify(t.map(ee=>ee.name)),m=c.useMemo(()=>new Set(JSON.parse(B)),[B]),Y=c.useRef(X),he=c.useRef(z),V=c.useRef(a);c.useEffect(()=>{Y.current=X,he.current=z,V.current=a});const re=c.useRef(null);re.current===null&&(re.current=new Map(t.map(ee=>[ee.name,ee.initialData?.length??0])));const de=c.useCallback(()=>{const ee=ne.current;if(ee.length===0)return;ne.current=[];const ie=re.current??new Map,ue=[];for(const j of ee){const Q=ie.get(j.series);Q!==void 0&&(l&&Q+1>s?(ue.push([j.series,Q+1-s]),ie.set(j.series,s)):ie.set(j.series,Q+1))}G(j=>{const Q=new Map(j);for(const n of ee){const W=Q.get(n.series);if(!W)continue;const U=[...W,n.value];l&&U.length>s&&U.splice(0,U.length-s),Q.set(n.series,U)}return Q});for(const[j,Q]of ue)V.current?.(Q,j);const be=[];for(const j of ee){if(!m.has(j.series))continue;const Q=(E.current.get(j.series)??0)+1;E.current.set(j.series,Q),Q>f.current&&(f.current=Q,be.push(j.category??wt(j.timestamp,R)))}be.length>0&&K(j=>{const Q=[...j,...be];return l&&Q.length>s&&Q.splice(0,Q.length-s),Q})},[l,s,R,m]),pe=c.useCallback(()=>{const ee=Date.now();ee-Z.current>=r&&(de(),Z.current=ee),ae.current=requestAnimationFrame(pe)},[r,de]);c.useEffect(()=>(X||(ae.current=requestAnimationFrame(pe)),()=>{ae.current!==null&&(cancelAnimationFrame(ae.current),ae.current=null)}),[X,pe]);const je=c.useCallback(ee=>{if(Y.current)return;const ie="points"in ee?ee.points:[ee];for(const ue of ie)m.has(ue.series)&&(ne.current.push(ue),he.current?.(ue))},[m]);c.useEffect(()=>{if(!i)return;const ee=i.subscribe(je);let ie;return i.onStatusChange?ie=i.onStatusChange(ce):ce(!0),i.fetchHistory&&i.fetchHistory(s).then(ue=>{for(const be of ue)ne.current.push(be);de()}),()=>{ee(),ie?.()}},[i,je,s,de]);const ge=c.useMemo(()=>t.map(ee=>({name:ee.name,color:ee.color,type:ee.type,data:F.get(ee.name)??[]})),[t,F]),_e=c.useMemo(()=>{const ee=[...o];for(const ie of x)ee.push({type:"line",value:ie.value,color:ie.color,label:ie.label,dash:ie.style==="dashed"?"5,5":ie.style==="dotted"?"2,2":void 0});return ee},[o,x]);c.useImperativeHandle(T,()=>({pause(){y(!0)},resume(){y(!1)},isPaused(){return X},clear(){G(ie=>{const ue=new Map(ie);for(const be of ue.keys())ue.set(be,[]);return ue}),K([]),E.current=new Map,f.current=0,ne.current=[];const ee=re.current;if(ee)for(const ie of ee.keys())ee.set(ie,0)},addPoint(ee){je(ee)},addPoints(ee){je({points:ee})},getData(ee){return F.get(ee)??[]},getCategories(){return P},exportData(){return{series:ge,categories:P}},getStats(ee){const ie=F.get(ee);return ie?Le(ie):null}}),[X,F,P,ge,je]);const Me=c.useMemo(()=>{if(!u)return null;const ee={};for(const[ie,ue]of F)ee[ie]=Le(ue);return ee},[u,F]);return e.jsxs("div",{className:p,style:{position:"relative",...O},children:[S&&e.jsxs("div",{style:{position:"absolute",top:8,right:8,display:"flex",alignItems:"center",gap:4,fontSize:12,color:q?"var(--nice-color-success, #22c55e)":"var(--nice-color-error, #ef4444)",zIndex:10},children:[e.jsx("span",{style:{width:8,height:8,borderRadius:"50%",backgroundColor:q?"var(--nice-color-success, #22c55e)":"var(--nice-color-error, #ef4444)"}}),q?H("charts.live","Live"):H("charts.disconnected","Disconnected")]}),A&&e.jsx("div",{style:{position:"absolute",top:8,left:8,display:"flex",gap:4,zIndex:10},children:e.jsx("button",{onClick:()=>y(ee=>!ee),style:{padding:"4px 8px",fontSize:12,border:"1px solid var(--nice-border-color, #ddd)",borderRadius:4,background:X?"var(--nice-warning-bg, #fef3c7)":"var(--nice-bg-primary, #fff)",color:"var(--nice-text-primary, #0f172a)",cursor:"pointer"},title:X?H("charts.resume","Resume"):H("charts.pause","Pause"),"aria-label":X?H("charts.resume","Resume"):H("charts.pause","Pause"),children:e.jsx(le.NiceIcon,{name:X?"play":"pause",size:14})})}),u&&Me&&e.jsx("div",{style:{position:"absolute",bottom:50,right:8,background:"color-mix(in srgb, var(--nice-bg-elevated, #fff) 92%, transparent)",color:"var(--nice-text-primary, #0f172a)",border:"1px solid var(--nice-border-color, #ddd)",borderRadius:4,padding:8,fontSize:11,zIndex:10},children:Object.entries(Me).map(([ee,ie])=>ie?e.jsxs("div",{style:{marginBottom:4},children:[e.jsx("strong",{children:ee}),e.jsxs("div",{children:[H("charts.stats.min","Min"),": ",ie.min.toFixed(2)," |"," ",H("charts.stats.max","Max"),": ",ie.max.toFixed(2)]}),e.jsxs("div",{children:[H("charts.stats.avg","Avg"),": ",ie.avg.toFixed(2)," |"," ",H("charts.stats.now","Now"),": ",ie.current.toFixed(2)]})]},ee):null)}),e.jsx(Se,{series:ge,categories:P,width:_,height:v,title:C,showLegend:L,showGrid:g,yAxisLabel:b,xAxisLabel:h,stacked:D,zoomable:I,crosshair:N,annotations:_e,legendInteractive:d,onDataPointClick:M,exportable:w})]})}),{displayName:"NiceLiveChart"});function $t(t){const{hubConnection:s,eventName:l="DataPoint",subscribeMethod:r="SubscribeToMetrics",historyMethod:i="GetMetricHistory",metricName:_}=t;return{subscribe(v){const C=L=>{v(L)};return s.on(l,C),s.state==="Connected"&&s.invoke(r,_).catch(()=>{}),()=>{s.off(l,C)}},async fetchHistory(v){try{return await s.invoke(i,_,v)}catch{return[]}},onStatusChange(v){const C=()=>v(s.state==="Connected");return s.onclose(()=>v(!1)),s.onreconnected(()=>v(!0)),C(),()=>{}}}}function St(t){const{url:s,autoReconnect:l=!0,reconnectDelay:r=3e3,parseMessage:i=b=>JSON.parse(b)}=t;let _=null,v=null,C=null,L=null;const g=()=>{_=new WebSocket(s),_.onopen=()=>{v?.(!0)},_.onclose=()=>{v?.(!1),l&&(L=setTimeout(g,r))},_.onerror=()=>{_?.close()},_.onmessage=b=>{try{const h=i(b.data);h&&C&&C(h)}catch{}}};return{subscribe(b){return C=b,g(),()=>{C=null,L&&clearTimeout(L),_?.close(),_=null}},onStatusChange(b){return v=b,()=>{v=null}}}}function Ct(t){const{seriesNames:s,interval:l=1e3,generateValue:r=()=>Math.random()*100}=t;let i=null,_=0;return{subscribe(v){return i=setInterval(()=>{for(const C of s)v({series:C,value:r(C,_),timestamp:Date.now()});_++},l),()=>{i&&clearInterval(i)}},onStatusChange(v){return v(!0),()=>{}}}}const It=[];function At(t){if(!t.length)return{categories:[],numericFields:[],sampleValues:{}};const s=t[0],l=[],r={};let i=null;for(const[v,C]of Object.entries(s))typeof C=="number"?(l.push(v),r[v]=t.map(L=>Number(L[v])||0)):!i&&(typeof C=="string"||C instanceof Date)&&(i=v);return{categories:i?t.map(v=>String(v[i]||"")):t.map((v,C)=>`Item ${C+1}`),numericFields:l,sampleValues:r}}function Rt(t,s){const{categories:l,numericFields:r,sampleValues:i}=At(t);return{series:r.map((v,C)=>({name:v.replace(/([A-Z])/g," $1").replace(/^./,L=>L.toUpperCase()).trim(),data:i[v],type:s==="area"?"area":s==="line"?"line":"bar"})),categories:l}}const Tt=c.forwardRef(function(s,l){const{rawData:r,enableAI:i=!0,aiModel:_,enableAutoType:v=!0,enableInsights:C=!0,dataDescription:L,onChartSuggestion:g,onInsights:b,showAIToolbar:h=!0,showInsightsOnLoad:D=!1,series:I=It,categories:N,...o}=s,[d,M]=c.useState("bar"),[w,A]=c.useState(null),[S,k]=c.useState([]),[z,a]=c.useState(D),[R,u]=c.useState(null),{t:x}=Be.useNiceTranslation(),p=le.useNiceAI(),{suggestChartType:O,generateInsights:T,isLoading:F}=le.useChartSuggestion(),G=i&&p.isConfigured,{series:P,categories:K}=r?Rt(r,R||d):{series:I||[],categories:N},H=c.useCallback(async()=>{if(!G||!v)return{type:"bar",reason:"Default",config:{}};const ne=r||(I?.length?I.flatMap(Z=>Z.data.map((ae,E)=>({[Z.name]:ae,index:E}))):[]);try{const Z=await O(ne,L),ae={type:Z.type,reason:Z.reason,config:Z.config};return A(ae),M(ae.type),g?.(ae),ae}catch{return{type:"bar",reason:"Default fallback",config:{}}}},[G,v,r,I,L,O,g]),X=c.useCallback(async()=>{if(!G||!C)return[];const ne=r||(I?.length?I.flatMap(Z=>Z.data.map((ae,E)=>({[Z.name]:ae,category:N?.[E]||E}))):[]);try{const Z=await T(ne,R||d);return k(Z),b?.(Z),Z}catch{return[]}},[G,C,r,I,N,d,R,T,b]),y=c.useCallback(()=>R||d,[R,d]);c.useEffect(()=>{G&&v&&(r?.length||I?.length)&&H()},[G,v,r,I]),c.useImperativeHandle(l,()=>({getSuggestion:H,generateInsights:X,getCurrentType:y}));const q=[{type:"bar",icon:"bar-chart",label:x("chartAI.bar","Bar")},{type:"line",icon:"line-chart",label:x("chartAI.line","Line")},{type:"area",icon:"area-chart",label:x("chartAI.area","Area")},{type:"pie",icon:"pie-chart",label:x("chartAI.pie","Pie")},{type:"donut",icon:"donut-chart",label:x("chartAI.donut","Donut")},{type:"scatter",icon:"scatter-chart",label:x("chartAI.scatter","Scatter")}],ce=R||d;return e.jsxs("div",{className:"nice-chart-ai","data-testid":s["data-testid"],children:[h&&G&&e.jsxs("div",{className:"nice-chart-ai__toolbar",children:[e.jsxs("div",{className:"nice-chart-ai__toolbar-left",children:[e.jsx("span",{className:"nice-chart-ai__badge",children:x("chartAI.ai","AI")}),w&&e.jsxs("div",{className:"nice-chart-ai__suggestion",children:[e.jsx("span",{className:"nice-chart-ai__suggestion-icon",children:e.jsx(le.NiceIcon,{name:"lightbulb",size:14})}),e.jsxs("span",{className:"nice-chart-ai__suggestion-text",children:[x("chartAI.suggestedType","Suggested:")," ",w.type]}),e.jsxs("span",{className:"nice-chart-ai__suggestion-reason",title:w.reason,children:["(",w.reason,")"]})]}),F&&e.jsx("span",{className:"nice-chart-ai__loading",children:x("chartAI.analyzing","Analyzing...")})]}),e.jsx("div",{className:"nice-chart-ai__toolbar-center",children:e.jsx("div",{className:"nice-chart-ai__type-selector",children:q.filter(ne=>["bar","line","area"].includes(ne.type)).map(({type:ne,icon:Z,label:ae})=>e.jsx("button",{type:"button",className:`nice-chart-ai__type-btn ${ce===ne?"nice-chart-ai__type-btn--active":""}`,onClick:()=>u(ne),title:ae,children:e.jsx(le.NiceIcon,{name:Z,size:16})},ne))})}),e.jsxs("div",{className:"nice-chart-ai__toolbar-right",children:[e.jsxs("button",{type:"button",className:"nice-chart-ai__auto-btn",onClick:()=>H(),disabled:F,title:x("chartAI.autoDetect","Auto-detect best chart type"),children:[e.jsx(le.NiceIcon,{name:"zap",size:14})," ",x("chartAI.auto","Auto")]}),C&&e.jsxs("button",{type:"button",className:"nice-chart-ai__insights-btn",onClick:()=>{S.length||X(),a(!z)},disabled:F,title:x("chartAI.showInsights","Show data insights"),children:[e.jsx(le.NiceIcon,{name:"lightbulb",size:14})," ",x("chartAI.insights","Insights")]})]})]}),e.jsx("div",{className:"nice-chart-ai__chart-wrapper",children:e.jsx(Se,{series:P,categories:K,...o})}),z&&S.length>0&&e.jsxs("div",{className:"nice-chart-ai__insights",children:[e.jsxs("div",{className:"nice-chart-ai__insights-header",children:[e.jsxs("h4",{children:[e.jsx(le.NiceIcon,{name:"lightbulb",size:14})," ",x("chartAI.dataInsights","Data Insights")]}),e.jsx("button",{type:"button",className:"nice-chart-ai__insights-close",onClick:()=>a(!1),"aria-label":x("chartAI.close","Close"),children:e.jsx(le.NiceIcon,{name:"close",size:14})})]}),e.jsx("ul",{className:"nice-chart-ai__insights-list",children:S.map((ne,Z)=>e.jsxs("li",{className:"nice-chart-ai__insight",children:[e.jsx("span",{className:"nice-chart-ai__insight-icon",children:"•"}),ne]},Z))}),e.jsx("div",{className:"nice-chart-ai__insights-footer",children:e.jsxs("button",{type:"button",className:"nice-chart-ai__refresh",onClick:()=>X(),disabled:F,children:[e.jsx(le.NiceIcon,{name:"refresh",size:14})," ",x("chartAI.refresh","Refresh")]})})]}),z&&F&&e.jsx("div",{className:"nice-chart-ai__insights nice-chart-ai__insights--loading",children:e.jsxs("div",{className:"nice-chart-ai__loading-content",children:[e.jsx("span",{className:"nice-chart-ai__spinner"}),x("chartAI.generatingInsights","Generating insights...")]})})]})}),zt=[],Lt=[],Dt=[],Oe=["var(--nice-color-primary, #3b82f6)","var(--nice-color-error, #ef4444)","var(--nice-color-success, #22c55e)","var(--nice-color-warning, #f59e0b)","var(--nice-color-accent, #8b5cf6)","var(--nice-color-accent-pink, #ec4899)","var(--nice-color-info, #06b6d4)","var(--nice-color-success, #10b981)","var(--nice-color-warning, #f59e0b)","var(--nice-color-accent, #6366f1)"],Et=Object.assign(c.forwardRef((t,s)=>{const{t:l}=le.useNiceTranslation(),{levels:r=Dt,initialLevelId:i,levelId:_,chartType:v="bar",width:C=600,height:L=400,showBreadcrumbs:g=!0,showBackButton:b=!0,animationDuration:h=300,onLevelChange:D,onItemClick:I,colors:N=Oe,showValues:o=!0,showLegend:d=!0,className:M,style:w,...A}=t,S=_!==void 0,[k,z]=c.useState(i||r[0]?.id),[a,R]=c.useState([i||r[0]?.id]),u=c.useCallback(E=>{const f=[];let B=r.find(m=>m.id===E);for(;B&&!f.includes(B.id);){f.unshift(B.id);const m=B.parentId;B=m?r.find(Y=>Y.id===m):void 0}return f.length>0?f:[E]},[r]),x=_??k,p=c.useMemo(()=>_!==void 0?u(_):a,[_,a,u]),[O,T]=c.useState(!1),[F,G]=c.useState("in"),P=c.useMemo(()=>r.find(E=>E.id===x),[r,x]),K=c.useCallback(E=>{r.find(B=>B.id===E)&&(G("in"),T(!0),setTimeout(()=>{S||(z(E),R(B=>[...B,E])),D?.(E,S?u(E):[...p,E]),T(!1)},h/2))},[r,p,h,D,S,u]),H=c.useCallback(()=>{if(p.length<=1)return;G("out"),T(!0);const E=p.slice(0,-1),f=E[E.length-1];setTimeout(()=>{S||(z(f),R(E)),D?.(f,E),T(!1)},h/2)},[p,h,D,S]),X=c.useCallback(()=>{const E=r[0]?.id;E&&(G("out"),T(!0),setTimeout(()=>{S||(z(E),R([E])),D?.(E,[E]),T(!1)},h/2))},[r,h,D,S]);c.useImperativeHandle(s,()=>({drillDown:K,drillUp:H,resetToRoot:X,getCurrentLevel:()=>x,getPath:()=>p}),[K,H,X,x,p]);const y=c.useCallback((E,f)=>{I?.(E,x);const B=r.find(m=>m.parentId===x&&m.id===E.metadata?.childLevelId);B&&K(B.id)},[x,r,K,I]),q=c.useMemo(()=>P?.data.reduce((E,f)=>E+f.value,0)||0,[P]),ce=c.useMemo(()=>p.map(E=>r.find(f=>f.id===E)?.label||E),[p,r]),ne=()=>{if(!P)return null;const E=P.data,f=Math.max(...E.map(m=>m.value)),B=Math.min(40,(L-100)/E.length-8);return e.jsx("div",{className:"nice-drilldown-bars",children:E.map((m,Y)=>{const he=m.value/f*100;return e.jsxs("div",{role:"button",tabIndex:0,onKeyDown:le.clickOnActivationKey,className:"nice-drilldown-bar-row",onClick:()=>y(m,Y),children:[e.jsx("span",{className:"nice-drilldown-bar-label",children:m.label||l("charts.item","Item {i}").replace("{i}",String(Y+1))}),e.jsx("div",{className:"nice-drilldown-bar-track",children:e.jsx("div",{className:"nice-drilldown-bar-fill",style:{width:`${he}%`,backgroundColor:m.color||N[Y%N.length],height:B}})}),o&&e.jsx("span",{className:"nice-drilldown-bar-value",children:m.value.toLocaleString()})]},Y)})})},Z=()=>{if(!P)return null;const E=P.data,f=C/2,B=(L-60)/2+30,m=Math.min(f,B)-40;let Y=-90;const he=E.map((V,re)=>{const de=V.value/q*360,pe=Y+de,je=de>180?1:0,ge=Y*Math.PI/180,_e=pe*Math.PI/180,Me=f+m*Math.cos(ge),ee=B+m*Math.sin(ge),ie=f+m*Math.cos(_e),ue=B+m*Math.sin(_e),be=(Y+de/2)*Math.PI/180,j=f+m*.7*Math.cos(be),Q=B+m*.7*Math.sin(be),n=`M ${f} ${B} L ${Me} ${ee} A ${m} ${m} 0 ${je} 1 ${ie} ${ue} Z`;return Y=pe,{path:n,color:V.color||N[re%N.length],label:V.label||l("charts.item","Item {i}").replace("{i}",String(re+1)),value:V.value,percentage:(V.value/q*100).toFixed(1),labelX:j,labelY:Q,item:V,index:re}});return e.jsx("svg",{width:C,height:L-40,className:"nice-drilldown-pie",children:e.jsx("g",{children:he.map((V,re)=>e.jsxs("g",{onClick:()=>y(V.item,V.index),children:[e.jsx("path",{d:V.path,fill:V.color,stroke:"white",strokeWidth:2,className:"nice-drilldown-pie-slice"}),o&&parseFloat(V.percentage)>5&&e.jsxs("text",{x:V.labelX,y:V.labelY,textAnchor:"middle",dominantBaseline:"middle",fill:"white",fontSize:"12",fontWeight:"600",children:[V.percentage,"%"]})]},re))})})},ae=()=>{if(!P)return null;const E=P.data,f=Math.max(...E.map(Y=>Y.value)),B=Math.min(60,(C-100)/E.length-8),m=L-100;return e.jsx("svg",{width:C,height:L-40,className:"nice-drilldown-columns",children:e.jsxs("g",{transform:"translate(50, 20)",children:[[0,.25,.5,.75,1].map((Y,he)=>e.jsxs("g",{children:[e.jsx("line",{x1:0,y1:m*(1-Y),x2:C-80,y2:m*(1-Y),stroke:"var(--nice-border-color, #e5e7eb)",strokeDasharray:Y===0?void 0:"4"}),e.jsx("text",{x:-8,y:m*(1-Y),textAnchor:"end",dominantBaseline:"middle",fontSize:"11",fill:"var(--nice-text-secondary, #6b7280)",children:Math.round(f*Y).toLocaleString()})]},he)),E.map((Y,he)=>{const V=Y.value/f*m,re=he*((C-100)/E.length)+((C-100)/E.length-B)/2;return e.jsxs("g",{onClick:()=>y(Y,he),children:[e.jsx("rect",{x:re,y:m-V,width:B,height:V,fill:Y.color||N[he%N.length],rx:4,className:"nice-drilldown-column-bar"}),e.jsx("text",{x:re+B/2,y:m+16,textAnchor:"middle",fontSize:"11",fill:"var(--nice-text-primary, #374151)",children:(Y.label||`${he+1}`).slice(0,10)}),o&&e.jsx("text",{x:re+B/2,y:m-V-8,textAnchor:"middle",fontSize:"11",fill:"var(--nice-text-primary, #374151)",fontWeight:"500",children:Y.value.toLocaleString()})]},he)})]})})};return e.jsxs("div",{className:`nice-drilldown-chart ${O?`animating ${F}`:""} ${M||""}`,style:{width:C,...w},...A,children:[e.jsxs("div",{className:"nice-drilldown-header",children:[b&&p.length>1&&e.jsxs("button",{className:"nice-drilldown-back",onClick:H,children:[e.jsx(le.NiceIcon,{name:"arrow-left",size:14})," ",l("charts.back","Back")]}),g&&e.jsx("div",{className:"nice-drilldown-breadcrumbs",children:ce.map((E,f)=>e.jsxs(c.Fragment,{children:[f>0&&e.jsx("span",{className:"nice-drilldown-separator",children:"/"}),e.jsx("span",{role:f<ce.length-1?"button":void 0,tabIndex:f<ce.length-1?0:void 0,"aria-current":f===ce.length-1?"location":void 0,onKeyDown:f<ce.length-1?le.clickOnActivationKey:void 0,className:`nice-drilldown-crumb ${f===ce.length-1?"active":""}`,onClick:()=>{if(f<ce.length-1){const B=p.slice(0,f+1),m=B[B.length-1];S||(R(B),z(m)),D?.(m,B)}},children:E})]},f))})]}),e.jsxs("div",{className:"nice-drilldown-content",style:{height:L-40},children:[v==="bar"&&ne(),v==="pie"&&Z(),v==="column"&&ae()]}),d&&P&&e.jsx("div",{className:"nice-drilldown-legend",children:P.data.map((E,f)=>e.jsxs("div",{className:"nice-drilldown-legend-item",children:[e.jsx("span",{className:"nice-drilldown-legend-color",style:{backgroundColor:E.color||N[f%N.length]}}),e.jsx("span",{className:"nice-drilldown-legend-label",children:E.label||l("charts.item","Item {i}").replace("{i}",String(f+1))})]},f))}),e.jsx("style",{children:`
|
|
293
|
+
.nice-drilldown-chart {
|
|
294
|
+
font-family: inherit;
|
|
295
|
+
color: var(--nice-text-primary, #111827);
|
|
296
|
+
background: var(--nice-bg-elevated, #ffffff);
|
|
297
|
+
border-radius: 8px;
|
|
298
|
+
overflow: hidden;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
.nice-drilldown-header {
|
|
302
|
+
display: flex;
|
|
303
|
+
align-items: center;
|
|
304
|
+
gap: 12px;
|
|
305
|
+
padding: 12px 16px;
|
|
306
|
+
border-bottom: 1px solid var(--nice-border-color, #e5e7eb);
|
|
307
|
+
min-height: 40px;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
.nice-drilldown-back {
|
|
311
|
+
background: var(--nice-bg-secondary, #f3f4f6);
|
|
312
|
+
border: none;
|
|
313
|
+
padding: 6px 12px;
|
|
314
|
+
border-radius: 6px;
|
|
315
|
+
cursor: pointer;
|
|
316
|
+
font-size: 13px;
|
|
317
|
+
font-family: inherit;
|
|
318
|
+
color: var(--nice-text-primary, #374151);
|
|
319
|
+
transition: background 0.2s;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
.nice-drilldown-back:hover {
|
|
323
|
+
background: var(--nice-hover-bg, #e5e7eb);
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
.nice-drilldown-breadcrumbs {
|
|
327
|
+
display: flex;
|
|
328
|
+
align-items: center;
|
|
329
|
+
gap: 4px;
|
|
330
|
+
font-size: 13px;
|
|
331
|
+
font-family: inherit;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
.nice-drilldown-separator {
|
|
335
|
+
color: var(--nice-text-muted, #9ca3af);
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
.nice-drilldown-crumb {
|
|
339
|
+
color: var(--nice-text-secondary, #6b7280);
|
|
340
|
+
cursor: pointer;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
.nice-drilldown-crumb:hover:not(.active) {
|
|
344
|
+
color: var(--nice-color-primary, #3b82f6);
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
.nice-drilldown-crumb.active {
|
|
348
|
+
color: var(--nice-text-primary, #111827);
|
|
349
|
+
font-weight: 500;
|
|
350
|
+
cursor: default;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
.nice-drilldown-content {
|
|
354
|
+
padding: 16px;
|
|
355
|
+
transition: opacity 0.15s, transform 0.15s;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
.nice-drilldown-chart.animating .nice-drilldown-content {
|
|
359
|
+
opacity: 0;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
.nice-drilldown-chart.animating.in .nice-drilldown-content {
|
|
363
|
+
transform: translateX(20px);
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
.nice-drilldown-chart.animating.out .nice-drilldown-content {
|
|
367
|
+
transform: translateX(-20px);
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
.nice-drilldown-bars {
|
|
371
|
+
display: flex;
|
|
372
|
+
flex-direction: column;
|
|
373
|
+
gap: 8px;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
.nice-drilldown-bar-row {
|
|
377
|
+
display: flex;
|
|
378
|
+
align-items: center;
|
|
379
|
+
gap: 12px;
|
|
380
|
+
cursor: pointer;
|
|
381
|
+
padding: 4px 8px;
|
|
382
|
+
margin: -4px -8px;
|
|
383
|
+
border-radius: 6px;
|
|
384
|
+
transition: background 0.2s;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
.nice-drilldown-bar-row:hover {
|
|
388
|
+
background: var(--nice-hover-bg, #f9fafb);
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
.nice-drilldown-bar-label {
|
|
392
|
+
width: 120px;
|
|
393
|
+
font-size: 13px;
|
|
394
|
+
font-family: inherit;
|
|
395
|
+
color: var(--nice-text-primary, #374151);
|
|
396
|
+
overflow: hidden;
|
|
397
|
+
text-overflow: ellipsis;
|
|
398
|
+
white-space: nowrap;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
.nice-drilldown-bar-track {
|
|
402
|
+
flex: 1;
|
|
403
|
+
background: var(--nice-bg-tertiary, #f3f4f6);
|
|
404
|
+
border-radius: 6px;
|
|
405
|
+
overflow: hidden;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
.nice-drilldown-bar-fill {
|
|
409
|
+
transition: width 0.3s ease;
|
|
410
|
+
border-radius: 6px;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
.nice-drilldown-bar-value {
|
|
414
|
+
width: 80px;
|
|
415
|
+
text-align: right;
|
|
416
|
+
font-size: 13px;
|
|
417
|
+
font-family: inherit;
|
|
418
|
+
font-weight: 500;
|
|
419
|
+
color: var(--nice-text-primary, #111827);
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
.nice-drilldown-pie-slice {
|
|
423
|
+
cursor: pointer;
|
|
424
|
+
transition: transform 0.2s, opacity 0.2s;
|
|
425
|
+
transform-origin: center;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
.nice-drilldown-pie-slice:hover {
|
|
429
|
+
opacity: 0.85;
|
|
430
|
+
transform: scale(1.02);
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
.nice-drilldown-column-bar {
|
|
434
|
+
cursor: pointer;
|
|
435
|
+
transition: opacity 0.2s;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
.nice-drilldown-column-bar:hover {
|
|
439
|
+
opacity: 0.8;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
.nice-drilldown-legend {
|
|
443
|
+
display: flex;
|
|
444
|
+
flex-wrap: wrap;
|
|
445
|
+
gap: 16px;
|
|
446
|
+
padding: 12px 16px;
|
|
447
|
+
border-top: 1px solid var(--nice-border-color, #e5e7eb);
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
.nice-drilldown-legend-item {
|
|
451
|
+
display: flex;
|
|
452
|
+
align-items: center;
|
|
453
|
+
gap: 6px;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
.nice-drilldown-legend-color {
|
|
457
|
+
width: 12px;
|
|
458
|
+
height: 12px;
|
|
459
|
+
border-radius: 3px;
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
.nice-drilldown-legend-label {
|
|
463
|
+
font-size: 12px;
|
|
464
|
+
font-family: inherit;
|
|
465
|
+
color: var(--nice-text-secondary, #6b7280);
|
|
466
|
+
}
|
|
467
|
+
`})]})}),{displayName:"NiceDrillDownChart"}),Pt=["var(--nice-info-bg, #dbeafe)","var(--nice-color-primary-light, #93c5fd)","var(--nice-color-primary, #3b82f6)","var(--nice-color-primary-active, #1d4ed8)","var(--nice-color-primary, #6366f1)"],Ot=({type:t="choropleth",regions:s=[],bubbles:l=[],width:r=800,height:i=500,viewBox:_="0 0 800 500",colorScale:v,colorRange:C,minValue:L,maxValue:g,showTooltip:b=!0,showLegend:h=!0,onRegionClick:D,onBubbleClick:I,onRegionHover:N,title:o,mapSvg:d,zoomable:M=!1,className:w,style:A,...S})=>{const k=v??C??Pt,{t:z}=le.useNiceTranslation(),[a,R]=c.useState(null),[u,x]=c.useState(1),[p,O]=c.useState({x:0,y:0}),T=c.useRef(null),F=c.useRef(!1),G=c.useRef({x:0,y:0}),P=L??Math.min(...s.map(f=>f.value),...l.map(f=>f.value)),K=g??Math.max(...s.map(f=>f.value),...l.map(f=>f.value)),H=c.useCallback(f=>{const B=(f-P)/(K-P),m=Math.min(Math.floor(B*k.length),k.length-1);return k[Math.max(0,m)]},[P,K,k]),X=c.useCallback(f=>{if(!b||!a)return;const B=T.current?.getBoundingClientRect();B&&R(m=>m?{...m,x:f.clientX-B.left,y:f.clientY-B.top}:null)},[b,a]),y=c.useCallback((f,B)=>{const m=T.current?.getBoundingClientRect();m&&b&&R({x:B.clientX-m.left,y:B.clientY-m.top,content:`${f.name}: ${f.value.toLocaleString()}`}),N?.(f)},[b,N]),q=c.useCallback(()=>{R(null),N?.(null)},[N]),ce=c.useCallback(f=>{if(!M)return;f.preventDefault();const B=f.deltaY>0?.9:1.1;x(m=>Math.min(Math.max(m*B,.5),4))},[M]),ne=c.useCallback(f=>{M&&(F.current=!0,G.current={x:f.clientX-p.x,y:f.clientY-p.y})},[M,p]),Z=c.useCallback(()=>{F.current=!1},[]),ae=c.useCallback(f=>{F.current&&O({x:f.clientX-G.current.x,y:f.clientY-G.current.y})},[]),E=c.useMemo(()=>s.length>0?s:[{id:"mazowieckie",name:"Mazowieckie",value:100,path:"M400,200 L450,200 L460,250 L420,280 L380,250 Z"},{id:"slaskie",name:"Śląskie",value:80,path:"M350,280 L400,280 L390,330 L340,320 Z"},{id:"wielkopolskie",name:"Wielkopolskie",value:70,path:"M300,200 L350,200 L360,260 L310,270 L280,230 Z"}],[s]);return e.jsxs("div",{className:`nice-map-chart ${w||""}`,style:{width:r,...A},...S,children:[o&&e.jsx("div",{className:"nice-map-title",children:o}),e.jsx("svg",{ref:T,width:r,height:i,viewBox:_,className:"nice-map-svg",onWheel:ce,onMouseDown:ne,onMouseUp:Z,onMouseLeave:Z,onMouseMove:f=>{X(f),ae(f)},children:e.jsxs("g",{transform:`translate(${p.x}, ${p.y}) scale(${u})`,children:[d&&e.jsx("g",{dangerouslySetInnerHTML:{__html:d}}),t==="choropleth"&&E.map(f=>e.jsx("path",{d:f.path,fill:f.color||H(f.value),stroke:"var(--nice-bg-primary, #ffffff)",strokeWidth:1,className:"nice-map-region",onClick:()=>D?.(f),onMouseEnter:B=>y(f,B),onMouseLeave:q},f.id)),(t==="bubble"||l.length>0)&&l.map(f=>{const B=Math.sqrt((f.value-P)/(K-P))*30+5;return e.jsx("circle",{cx:f.lng,cy:f.lat,r:B,fill:f.color||"var(--nice-color-primary, #3b82f6)",fillOpacity:.7,stroke:"var(--nice-bg-primary, #ffffff)",strokeWidth:1,className:"nice-map-bubble",onClick:()=>I?.(f),onMouseEnter:m=>{const Y=T.current?.getBoundingClientRect();Y&&b&&R({x:m.clientX-Y.left,y:m.clientY-Y.top,content:`${f.label||f.id}: ${f.value.toLocaleString()}`})},onMouseLeave:q,children:f.label&&e.jsxs("title",{children:[f.label,": ",f.value]})},f.id)})]})}),a&&e.jsx("div",{className:"nice-map-tooltip",style:{left:a.x+10,top:a.y-30},children:a.content}),h&&e.jsxs("div",{className:"nice-map-legend",children:[e.jsx("span",{className:"nice-map-legend-title",children:z("charts.value","Value")}),e.jsx("div",{className:"nice-map-legend-scale",children:k.map((f,B)=>e.jsx("div",{className:"nice-map-legend-item",style:{backgroundColor:f}},B))}),e.jsxs("div",{className:"nice-map-legend-labels",children:[e.jsx("span",{children:P.toLocaleString()}),e.jsx("span",{children:K.toLocaleString()})]})]}),e.jsx("style",{children:`
|
|
468
|
+
.nice-map-chart {
|
|
469
|
+
font-family: system-ui, -apple-system, sans-serif;
|
|
470
|
+
background: var(--nice-bg-primary, #ffffff);
|
|
471
|
+
border-radius: var(--nice-radius-lg, 8px);
|
|
472
|
+
overflow: hidden;
|
|
473
|
+
position: relative;
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
.nice-map-title {
|
|
477
|
+
padding: var(--nice-space-3, 12px) var(--nice-space-4, 16px);
|
|
478
|
+
font-size: 16px;
|
|
479
|
+
font-weight: 600;
|
|
480
|
+
color: var(--nice-text-primary, #0f172a);
|
|
481
|
+
border-bottom: 1px solid var(--nice-border-color, #e5e7eb);
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
.nice-map-svg {
|
|
485
|
+
display: block;
|
|
486
|
+
cursor: grab;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
.nice-map-svg:active {
|
|
490
|
+
cursor: grabbing;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
.nice-map-region {
|
|
494
|
+
cursor: pointer;
|
|
495
|
+
transition: opacity 0.2s, stroke-width 0.2s;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
.nice-map-region:hover {
|
|
499
|
+
opacity: 0.8;
|
|
500
|
+
stroke-width: 2;
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
.nice-map-bubble {
|
|
504
|
+
cursor: pointer;
|
|
505
|
+
transition: transform 0.2s, opacity 0.2s;
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
.nice-map-bubble:hover {
|
|
509
|
+
opacity: 1;
|
|
510
|
+
transform: scale(1.1);
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
.nice-map-tooltip {
|
|
514
|
+
position: absolute;
|
|
515
|
+
/* audit-allow: token-role — inverted chip like .nice-tooltip: the text colour is the
|
|
516
|
+
fill and the label uses --nice-text-inverse, so the pair flips together. */
|
|
517
|
+
background: var(--nice-text-primary, #0f172a);
|
|
518
|
+
color: var(--nice-text-inverse, #ffffff);
|
|
519
|
+
padding: var(--nice-space-1-5, 6px) var(--nice-space-2-5, 10px);
|
|
520
|
+
border-radius: var(--nice-radius-sm, 4px);
|
|
521
|
+
font-size: 12px;
|
|
522
|
+
pointer-events: none;
|
|
523
|
+
z-index: 10;
|
|
524
|
+
white-space: nowrap;
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
.nice-map-legend {
|
|
528
|
+
position: absolute;
|
|
529
|
+
right: 16px;
|
|
530
|
+
bottom: 16px;
|
|
531
|
+
background: var(--nice-bg-elevated, #ffffff);
|
|
532
|
+
padding: var(--nice-space-3, 12px);
|
|
533
|
+
border-radius: var(--nice-radius-md, 6px);
|
|
534
|
+
box-shadow: 0 2px 8px var(--nice-overlay-10, color-mix(in srgb, var(--nice-text-primary, #000) 10%, transparent));
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
.nice-map-legend-title {
|
|
538
|
+
display: block;
|
|
539
|
+
font-size: 11px;
|
|
540
|
+
color: var(--nice-text-secondary, #475569);
|
|
541
|
+
margin-bottom: var(--nice-space-1-5, 6px);
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
.nice-map-legend-scale {
|
|
545
|
+
display: flex;
|
|
546
|
+
height: 12px;
|
|
547
|
+
border-radius: var(--nice-radius-sm, 2px);
|
|
548
|
+
overflow: hidden;
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
.nice-map-legend-item {
|
|
552
|
+
flex: 1;
|
|
553
|
+
min-width: 24px;
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
.nice-map-legend-labels {
|
|
557
|
+
display: flex;
|
|
558
|
+
justify-content: space-between;
|
|
559
|
+
font-size: 10px;
|
|
560
|
+
color: var(--nice-text-secondary, #475569);
|
|
561
|
+
margin-top: var(--nice-space-1, 4px);
|
|
562
|
+
}
|
|
563
|
+
`})]})},Bt=({nodes:t=zt,links:s=Lt,width:l=800,height:r=500,nodeWidth:i=20,nodePadding:_=10,showValues:v=!0,showTooltip:C=!0,onNodeClick:L,onLinkClick:g,title:b,className:h,style:D,...I})=>{const[N,o]=c.useState(null),d=c.useRef(null),M=c.useMemo(()=>{const A=new Map;t.forEach(y=>A.set(y.id,y));const S=new Set(s.map(y=>y.target)),k=new Set(s.map(y=>y.source)),z=[],a=new Map,R=t.filter(y=>k.has(y.id)&&!S.has(y.id));R.length>0&&(z.push(R.map(y=>y.id)),R.forEach(y=>a.set(y.id,0)));const u=t.filter(y=>k.has(y.id)&&S.has(y.id));u.length>0&&(z.push(u.map(y=>y.id)),u.forEach(y=>a.set(y.id,1)));const x=t.filter(y=>!k.has(y.id)&&S.has(y.id));x.length>0&&(z.push(x.map(y=>y.id)),x.forEach(y=>a.set(y.id,2))),z.length===0&&(z.push(t.map(y=>y.id)),t.forEach(y=>a.set(y.id,0)));const p=new Map;s.forEach(y=>{p.set(y.source,(p.get(y.source)||0)+y.value),p.set(y.target,(p.get(y.target)||0)+y.value)});const O=40,T=l-O*2,F=r-O*2,G=z.length>1?T/(z.length-1):T,P=new Map;Math.max(...Array.from(p.values())),z.forEach((y,q)=>{const ce=y.reduce((ae,E)=>ae+(p.get(E)||0),0),ne=(F-(y.length-1)*_)/ce;let Z=O;y.forEach(ae=>{const f=(p.get(ae)||0)*ne,B=O+q*G;P.set(ae,{x:B,y:Z,height:f}),Z+=f+_})});const K=[],H=new Map,X=new Map;return s.forEach(y=>{const q=P.get(y.source),ce=P.get(y.target);if(!q||!ce)return;const ne=p.get(y.source)||1;p.get(y.target);const Z=y.value/ne*q.height,ae=q.y+(H.get(y.source)||0),E=ce.y+(X.get(y.target)||0);H.set(y.source,(H.get(y.source)||0)+Z),X.set(y.target,(X.get(y.target)||0)+Z);const f=q.x+i,B=ce.x,m=(B-f)*.5,Y=`
|
|
564
|
+
M ${f} ${ae}
|
|
565
|
+
C ${f+m} ${ae},
|
|
566
|
+
${B-m} ${E},
|
|
567
|
+
${B} ${E}
|
|
568
|
+
L ${B} ${E+Z}
|
|
569
|
+
C ${B-m} ${E+Z},
|
|
570
|
+
${f+m} ${ae+Z},
|
|
571
|
+
${f} ${ae+Z}
|
|
572
|
+
Z
|
|
573
|
+
`;K.push({path:Y,link:y,sourcePos:q,targetPos:ce})}),{nodePositions:P,linkPaths:K,nodeMap:A,nodeValues:p}},[t,s,l,r,i,_]),w=c.useCallback((A,S)=>{const k=d.current?.getBoundingClientRect();k&&C&&o({x:S.clientX-k.left,y:S.clientY-k.top,content:A})},[C]);return e.jsxs("div",{className:`nice-sankey-chart ${h||""}`,style:{width:l,...D},...I,children:[b&&e.jsx("div",{className:"nice-sankey-title",children:b}),e.jsxs("svg",{ref:d,width:l,height:r,className:"nice-sankey-svg",children:[e.jsx("defs",{children:M.linkPaths.map((A,S)=>e.jsxs("linearGradient",{id:`sankey-gradient-${S}`,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:[e.jsx("stop",{offset:"0%",stopColor:M.nodeMap.get(A.link.source)?.color||"var(--nice-color-primary, #3b82f6)"}),e.jsx("stop",{offset:"100%",stopColor:M.nodeMap.get(A.link.target)?.color||"var(--nice-color-error, #ef4444)"})]},S))}),e.jsx("g",{className:"nice-sankey-links",children:M.linkPaths.map((A,S)=>e.jsx("path",{d:A.path,fill:A.link.color||`url(#sankey-gradient-${S})`,fillOpacity:.4,className:"nice-sankey-link",onClick:()=>g?.(A.link),onMouseEnter:k=>w(`${M.nodeMap.get(A.link.source)?.name} → ${M.nodeMap.get(A.link.target)?.name}: ${A.link.value.toLocaleString()}`,k),onMouseLeave:()=>o(null)},S))}),e.jsx("g",{className:"nice-sankey-nodes",children:Array.from(M.nodePositions.entries()).map(([A,S])=>{const k=M.nodeMap.get(A);return k?e.jsxs("g",{children:[e.jsx("rect",{x:S.x,y:S.y,width:i,height:S.height,fill:k.color||"var(--nice-color-primary, #3b82f6)",rx:2,className:"nice-sankey-node",onClick:()=>L?.(k),onMouseEnter:z=>w(`${k.label??k.name??k.id}: ${M.nodeValues.get(A)?.toLocaleString()||0}`,z),onMouseLeave:()=>o(null)}),e.jsxs("text",{x:S.x+i+6,y:S.y+S.height/2,dominantBaseline:"middle",fontSize:"12",fill:"var(--nice-text-primary, #0f172a)",children:[k.label??k.name??k.id,v&&` (${M.nodeValues.get(A)?.toLocaleString()||0})`]})]},A):null})})]}),N&&e.jsx("div",{className:"nice-sankey-tooltip",style:{left:N.x+10,top:N.y-30},children:N.content}),e.jsx("style",{children:`
|
|
574
|
+
.nice-sankey-chart {
|
|
575
|
+
font-family: system-ui, -apple-system, sans-serif;
|
|
576
|
+
background: var(--nice-bg-primary, #ffffff);
|
|
577
|
+
border-radius: var(--nice-radius-lg, 8px);
|
|
578
|
+
position: relative;
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
.nice-sankey-title {
|
|
582
|
+
padding: var(--nice-space-3, 12px) var(--nice-space-4, 16px);
|
|
583
|
+
font-size: 16px;
|
|
584
|
+
font-weight: 600;
|
|
585
|
+
color: var(--nice-text-primary, #0f172a);
|
|
586
|
+
border-bottom: 1px solid var(--nice-border-color, #e5e7eb);
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
.nice-sankey-link {
|
|
590
|
+
cursor: pointer;
|
|
591
|
+
transition: fill-opacity 0.2s;
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
.nice-sankey-link:hover {
|
|
595
|
+
fill-opacity: 0.7;
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
.nice-sankey-node {
|
|
599
|
+
cursor: pointer;
|
|
600
|
+
transition: opacity 0.2s;
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
.nice-sankey-node:hover {
|
|
604
|
+
opacity: 0.8;
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
.nice-sankey-tooltip {
|
|
608
|
+
position: absolute;
|
|
609
|
+
/* audit-allow: token-role — inverted chip like .nice-tooltip: the text colour is the
|
|
610
|
+
fill and the label uses --nice-text-inverse, so the pair flips together. */
|
|
611
|
+
background: var(--nice-text-primary, #0f172a);
|
|
612
|
+
color: var(--nice-text-inverse, #ffffff);
|
|
613
|
+
padding: var(--nice-space-1-5, 6px) var(--nice-space-2-5, 10px);
|
|
614
|
+
border-radius: var(--nice-radius-sm, 4px);
|
|
615
|
+
font-size: 12px;
|
|
616
|
+
pointer-events: none;
|
|
617
|
+
z-index: 10;
|
|
618
|
+
white-space: nowrap;
|
|
619
|
+
}
|
|
620
|
+
`})]})},Wt=Object.assign(c.forwardRef((t,s)=>{const{t:l}=le.useNiceTranslation(),{initialData:r,data:i,maxPoints:_=60,updateInterval:v=1e3,fetchData:C,width:L=600,height:g=200,chartType:b="line",color:h="var(--nice-color-primary, #3b82f6)",showGrid:D=!0,showTimeAxis:I=!0,showCurrentValue:N=!0,title:o,valueFormatter:d=V=>V.toFixed(2),timeFormatter:M=V=>new Date(V).toLocaleTimeString(),onDataUpdate:w,paused:A,className:S,style:k,...z}=t,[a,R]=c.useState(r??i??[]),[u,x]=c.useState(A||!1),p=c.useRef(void 0);c.useEffect(()=>{A!==void 0&&x(A)},[A]),c.useEffect(()=>{if(u||!C)return;const V=async()=>{try{const re=await C();R(de=>{const pe=[...de,re].slice(-_);return w?.(pe),pe})}catch(re){console.error("Failed to fetch realtime data:",re)}};return p.current=setInterval(V,v),()=>{p.current&&clearInterval(p.current)}},[u,C,v,_,w]);const O=c.useCallback(V=>{R(re=>{const de=[...re,V].slice(-_);return w?.(de),de})},[_,w]),T=c.useCallback(()=>{R([]),w?.([])},[w]),F=c.useCallback(()=>x(!0),[]),G=c.useCallback(()=>x(!1),[]);c.useImperativeHandle(s,()=>({addDataPoint:O,clearData:T,pause:F,resume:G,getData:()=>a}),[O,T,F,G,a]);const P={top:20,right:60,bottom:I?40:20,left:50},K=L-P.left-P.right,H=g-P.top-P.bottom,X=a.map(V=>V.value),y=X.length?Math.min(...X):0,q=X.length?Math.max(...X):100,ne=(q-y||1)*.1,Z=y-ne,E=q+ne-Z,f=V=>{const re=C?_-1:Math.max(1,a.length-1);return P.left+V/re*K},B=V=>P.top+H-(V-Z)/E*H,m=a.map((V,re)=>`${f(re)},${B(V.value)}`).join(" "),Y=a.length>0?`M ${f(0)},${P.top+H} L ${m} L ${f(a.length-1)},${P.top+H} Z`:"",he=a.length>0?a[a.length-1].value:null;return e.jsxs("div",{className:`nice-realtime-chart ${S||""}`,style:{width:L,...k},...z,children:[e.jsxs("div",{className:"nice-realtime-header",children:[e.jsx("span",{className:"nice-realtime-title",children:o}),e.jsxs("div",{className:"nice-realtime-controls",children:[e.jsxs("span",{className:`nice-realtime-status ${u?"paused":"live"}`,children:[e.jsx("span",{className:"nice-realtime-status-dot"}),e.jsx("span",{children:u?l("charts.paused","Paused"):l("charts.live","Live")})]}),e.jsx("button",{className:`nice-realtime-btn ${u?"paused":""}`,onClick:()=>x(!u),"aria-label":u?l("charts.resume","Resume"):l("charts.pause","Pause"),children:e.jsx(le.NiceIcon,{name:u?"play":"pause",size:14})}),N&&he!==null&&e.jsx("span",{className:"nice-realtime-value",children:d(he)})]})]}),e.jsxs("svg",{width:L,height:g,className:"nice-realtime-svg",children:[D&&e.jsx("g",{className:"nice-realtime-grid",children:[0,.25,.5,.75,1].map((V,re)=>{const de=P.top+H*(1-V),pe=Z+E*V;return e.jsxs("g",{children:[e.jsx("line",{x1:P.left,y1:de,x2:L-P.right,y2:de,stroke:"var(--nice-border-color, #e5e7eb)",strokeDasharray:V===0?void 0:"3"}),e.jsx("text",{x:P.left-8,y:de,textAnchor:"end",dominantBaseline:"middle",fontSize:"10",fill:"var(--nice-text-secondary, #6b7280)",children:Math.round(pe).toLocaleString()})]},re)})}),b==="area"&&a.length>0&&e.jsx("path",{d:Y,fill:h,fillOpacity:.2}),a.length>1&&e.jsx("polyline",{points:m,fill:"none",stroke:h,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),a.length>0&&e.jsx("circle",{cx:f(a.length-1),cy:B(a[a.length-1].value),r:3,fill:h,className:"nice-realtime-point"}),I&&a.length>0&&e.jsx("g",{className:"nice-realtime-time-axis",children:Array.from(new Set([0,Math.floor(a.length/2),a.length-1].filter(V=>a[V]))).map(V=>e.jsx("text",{x:f(V),y:g-8,textAnchor:"middle",fontSize:"10",fill:"var(--nice-text-secondary, #6b7280)",children:M(a[V].timestamp)},`tx-${V}`))})]}),e.jsx("style",{children:`
|
|
621
|
+
.nice-realtime-chart {
|
|
622
|
+
font-family: inherit;
|
|
623
|
+
color: var(--nice-text-primary, #111827);
|
|
624
|
+
background: var(--nice-bg-elevated, #ffffff);
|
|
625
|
+
border-radius: 8px;
|
|
626
|
+
position: relative;
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
.nice-realtime-header {
|
|
630
|
+
display: flex;
|
|
631
|
+
justify-content: space-between;
|
|
632
|
+
align-items: center;
|
|
633
|
+
padding: 12px 16px;
|
|
634
|
+
border-bottom: 1px solid var(--nice-border-color, #e5e7eb);
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
.nice-realtime-title {
|
|
638
|
+
font-size: 14px;
|
|
639
|
+
font-weight: 600;
|
|
640
|
+
color: var(--nice-text-primary, #111827);
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
.nice-realtime-controls {
|
|
644
|
+
display: flex;
|
|
645
|
+
align-items: center;
|
|
646
|
+
gap: 12px;
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
.nice-realtime-btn {
|
|
650
|
+
background: none;
|
|
651
|
+
border: none;
|
|
652
|
+
cursor: pointer;
|
|
653
|
+
font-size: 16px;
|
|
654
|
+
padding: 4px;
|
|
655
|
+
font-family: inherit;
|
|
656
|
+
color: inherit;
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
.nice-realtime-value {
|
|
660
|
+
font-size: 18px;
|
|
661
|
+
font-weight: 600;
|
|
662
|
+
color: ${h};
|
|
663
|
+
font-variant-numeric: tabular-nums;
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
/* Static current-value dot — no pulsing animation (was distracting) */
|
|
667
|
+
|
|
668
|
+
.nice-realtime-status {
|
|
669
|
+
display: inline-flex;
|
|
670
|
+
align-items: center;
|
|
671
|
+
gap: 6px;
|
|
672
|
+
font-size: 11px;
|
|
673
|
+
font-family: inherit;
|
|
674
|
+
color: var(--nice-text-secondary, #6b7280);
|
|
675
|
+
background: var(--nice-bg-secondary, #f3f4f6);
|
|
676
|
+
padding: 2px 10px;
|
|
677
|
+
border-radius: 999px;
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
.nice-realtime-status-dot {
|
|
681
|
+
width: 8px;
|
|
682
|
+
height: 8px;
|
|
683
|
+
border-radius: 50%;
|
|
684
|
+
background: var(--nice-color-success, #22c55e);
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
.nice-realtime-status.paused .nice-realtime-status-dot {
|
|
688
|
+
background: var(--nice-color-warning, #f59e0b);
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
.nice-realtime-status.live .nice-realtime-status-dot {
|
|
692
|
+
animation: live-pulse 2s ease-in-out infinite;
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
@keyframes live-pulse {
|
|
696
|
+
0%, 100% { opacity: 1; }
|
|
697
|
+
50% { opacity: 0.4; }
|
|
698
|
+
}
|
|
699
|
+
`})]})}),{displayName:"NiceRealtimeChart"}),Yt=({data:t,width:s=600,height:l=400,showLabels:r=!0,showValues:i=!0,onNodeClick:_,drilldownEnabled:v=!0,colors:C=Oe,tilePadding:L=2,className:g,style:b,...h})=>{const{t:D}=le.useNiceTranslation(),I=c.useMemo(()=>Array.isArray(t)?{id:"root",name:"Root",value:t.reduce((x,p)=>x+(p.value||0),0),children:t.map((x,p)=>({id:`${p}`,name:x.label??x.name??`Item ${p+1}`,value:x.value,color:x.color}))}:t,[t]),[N,o]=c.useState(I),[d,M]=c.useState([I.name]),[w,A]=c.useState(null),S=c.useRef(null),k=c.useMemo(()=>{const p=N.children||[];if(p.length===0)return[];const O=p.reduce((y,q)=>y+q.value,0),T=p.map(y=>({node:y,area:y.value/O*s*l}));T.sort((y,q)=>q.area-y.area);const F=[];let G=0,P=0,K=s,H=l,X=0;for(;X<T.length;){const y=K<H;let q=0,ce=[];const ne=y?H:K;for(let E=X;E<T.length;E++){const f=[...ce,T[E]],B=f.reduce((Y,he)=>Y+he.area,0),m=z(f,B,ne);if(ce.length===0)ce=f,q=B;else{const Y=z(ce,q,ne);if(m<=Y)ce=f,q=B;else break}}const Z=q/ne;let ae=0;ce.forEach((E,f)=>{const B=E.area/Z;F.push({node:E.node,x:y?G:G+ae,y:y?P+ae:P,w:y?Z:B,h:y?B:Z,color:E.node.color||C[(X+f)%C.length]}),ae+=B}),y?(G+=Z,K-=Z):(P+=Z,H-=Z),X+=ce.length}return F},[N,s,l,C]);function z(x,p,O){const T=p/O;let F=0;for(const G of x){const P=G.area/T,K=Math.max(T/P,P/T);F=Math.max(F,K)}return F}const a=x=>{_?.(x,[...d,x.name]),v&&x.children&&x.children.length>0&&(o(x),M(p=>[...p,x.name]))},R=()=>{if(d.length<=1)return;let x=I;const p=d.slice(0,-1);for(let O=1;O<p.length;O++){const T=x.children?.find(F=>F.name===p[O]);T&&(x=T)}o(x),M(p)},u=(x,p)=>{const O=S.current?.getBoundingClientRect();O&&A({x:p.clientX-O.left,y:p.clientY-O.top,content:x})};return e.jsxs("div",{className:`nice-treemap-chart ${g||""}`,style:{width:s,...b},...h,children:[e.jsxs("div",{className:"nice-treemap-nav",children:[d.length>1&&e.jsxs("button",{className:"nice-treemap-back",onClick:R,children:[e.jsx(le.NiceIcon,{name:"arrow-left",size:14})," ",D("charts.back","Back")]}),e.jsx("div",{className:"nice-treemap-breadcrumbs",children:d.map((x,p)=>e.jsxs(c.Fragment,{children:[p>0&&e.jsx("span",{className:"nice-treemap-sep",children:"/"}),e.jsx("span",{className:p===d.length-1?"current":"",children:x})]},p))})]}),e.jsx("svg",{ref:S,width:s,height:l,className:"nice-treemap-svg",children:k.map((x,p)=>{const{node:O,x:T,y:F,w:G,h:P,color:K}=x,H=Math.min(14,Math.max(10,Math.min(G,P)/6)),X=G>40&&P>30;return e.jsxs("g",{onClick:()=>a(O),onMouseEnter:y=>u(`${O.name}: ${O.value.toLocaleString()}`,y),onMouseLeave:()=>A(null),children:[e.jsx("rect",{x:T+L/2,y:F+L/2,width:Math.max(0,G-L),height:Math.max(0,P-L),fill:K,rx:4,className:"nice-treemap-tile"}),r&&X&&e.jsx("text",{x:T+G/2,y:F+P/2-(i?6:0),textAnchor:"middle",dominantBaseline:"middle",fontSize:H,fill:"white",fontWeight:"500",style:{pointerEvents:"none"},children:O.name.length>G/H+2?O.name.slice(0,Math.floor(G/H))+"...":O.name}),i&&X&&e.jsx("text",{x:T+G/2,y:F+P/2+10,textAnchor:"middle",dominantBaseline:"middle",fontSize:H-2,fill:"var(--nice-overlay-light-80, rgba(255, 255, 255, 0.8))",style:{pointerEvents:"none"},children:O.value.toLocaleString()})]},p)})}),w&&e.jsx("div",{className:"nice-treemap-tooltip",style:{left:w.x+10,top:w.y-30},children:w.content}),e.jsx("style",{children:`
|
|
700
|
+
.nice-treemap-chart {
|
|
701
|
+
font-family: system-ui, -apple-system, sans-serif;
|
|
702
|
+
background: var(--nice-bg-primary, #ffffff);
|
|
703
|
+
border-radius: var(--nice-radius-lg, 8px);
|
|
704
|
+
position: relative;
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
.nice-treemap-nav {
|
|
708
|
+
display: flex;
|
|
709
|
+
align-items: center;
|
|
710
|
+
gap: var(--nice-space-3, 12px);
|
|
711
|
+
padding: var(--nice-space-3, 12px) var(--nice-space-4, 16px);
|
|
712
|
+
border-bottom: 1px solid var(--nice-border-color, #e5e7eb);
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
.nice-treemap-back {
|
|
716
|
+
background: var(--nice-bg-secondary, #f8fafc);
|
|
717
|
+
color: var(--nice-text-primary, #0f172a);
|
|
718
|
+
border: none;
|
|
719
|
+
padding: var(--nice-space-1-5, 6px) var(--nice-space-3, 12px);
|
|
720
|
+
border-radius: var(--nice-radius-md, 6px);
|
|
721
|
+
cursor: pointer;
|
|
722
|
+
font-size: 13px;
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
.nice-treemap-back:hover {
|
|
726
|
+
background: var(--nice-border-color, #e5e7eb);
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
.nice-treemap-breadcrumbs {
|
|
730
|
+
display: flex;
|
|
731
|
+
align-items: center;
|
|
732
|
+
gap: var(--nice-space-1, 4px);
|
|
733
|
+
font-size: 13px;
|
|
734
|
+
color: var(--nice-text-secondary, #475569);
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
.nice-treemap-breadcrumbs .current {
|
|
738
|
+
color: var(--nice-text-primary, #0f172a);
|
|
739
|
+
font-weight: 500;
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
.nice-treemap-sep {
|
|
743
|
+
color: var(--nice-text-muted, #94a3b8);
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
.nice-treemap-tile {
|
|
747
|
+
cursor: pointer;
|
|
748
|
+
transition: opacity 0.2s, transform 0.1s;
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
.nice-treemap-tile:hover {
|
|
752
|
+
opacity: 0.85;
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
.nice-treemap-tooltip {
|
|
756
|
+
position: absolute;
|
|
757
|
+
/* audit-allow: token-role — inverted chip like .nice-tooltip: the text colour is the
|
|
758
|
+
fill and the label uses --nice-text-inverse, so the pair flips together. */
|
|
759
|
+
background: var(--nice-text-primary, #0f172a);
|
|
760
|
+
color: var(--nice-text-inverse, #ffffff);
|
|
761
|
+
padding: var(--nice-space-1-5, 6px) var(--nice-space-2-5, 10px);
|
|
762
|
+
border-radius: var(--nice-radius-sm, 4px);
|
|
763
|
+
font-size: 12px;
|
|
764
|
+
pointer-events: none;
|
|
765
|
+
z-index: 10;
|
|
766
|
+
white-space: nowrap;
|
|
767
|
+
}
|
|
768
|
+
`})]})};exports.CHART_COLORS=ye;exports.NiceBarGauge=Ze;exports.NiceBullet=Ke;exports.NiceChart=Se;exports.NiceChart$1=Ye;exports.NiceChartAI=Tt;exports.NiceCircularGauge=Fe;exports.NiceDrillDownChart=Et;exports.NiceForecastChart=Mt;exports.NiceFunnel=et;exports.NiceHeatMap=rt;exports.NiceLinearGauge=He;exports.NiceLiveChart=kt;exports.NiceMapChart=Ot;exports.NiceOrganizationChart=ut;exports.NicePieChart=Je;exports.NicePolarChart=yt;exports.NiceRangeSelector=bt;exports.NiceRealtimeChart=Wt;exports.NiceSankey=De;exports.NiceSankey$1=st;exports.NiceSankeyChart=Bt;exports.NiceSparkline=pt;exports.NiceStockChart=xt;exports.NiceTreeMap=Ee;exports.NiceTreeMap$1=lt;exports.NiceTreeMapChart=Yt;exports.NiceVectorMap=Pe;exports.NiceVectorMap$1=ht;exports.createMockLiveChartSource=Ct;exports.createSignalRLiveChartSource=$t;exports.createWebSocketLiveChartSource=St;
|