@nice2dev/ui 1.0.28 → 1.0.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/dist/NiceAssessment.doc-BB1rXcVx.cjs +1 -0
  3. package/dist/NiceAssessment.doc-C3QQawiZ.js +23 -0
  4. package/dist/NiceBackupStatusBadge.doc-Bx2bFmBQ.cjs +1 -0
  5. package/dist/NiceBackupStatusBadge.doc-CdDxIQ-M.js +25 -0
  6. package/dist/NiceConfirmDialog-BiTJVR4-.js +81 -0
  7. package/dist/NiceConfirmDialog-Bjw_rN4o.cjs +1 -0
  8. package/dist/NiceConfirmDialog-DPfYwO2B.js +81 -0
  9. package/dist/NiceConfirmDialog-Dyh42OiK.cjs +1 -0
  10. package/dist/NiceErrorBoundary-1H751jK7.cjs +1 -0
  11. package/dist/NiceErrorBoundary-B-txoU3Y.js +709 -0
  12. package/dist/NiceErrorBoundary-BHCKA1h8.cjs +1 -0
  13. package/dist/NiceErrorBoundary-CBxXcleR.js +695 -0
  14. package/dist/NiceExam.doc-BpTJpwGb.js +23 -0
  15. package/dist/NiceExam.doc-Br8pEbQb.cjs +1 -0
  16. package/dist/NiceForm-C8yEx3VV.cjs +382 -0
  17. package/dist/NiceForm-Ci3XG7s7.js +5000 -0
  18. package/dist/NiceForm-DGUTmaZT.js +5014 -0
  19. package/dist/NiceForm-DmU-gmyv.cjs +382 -0
  20. package/dist/NiceModal-BClAtR5T.js +95 -0
  21. package/dist/NiceModal-Crbhc7GB.cjs +1 -0
  22. package/dist/NiceModal-XvEKVVLa.js +95 -0
  23. package/dist/NiceModal-iKwtagFB.cjs +1 -0
  24. package/dist/NiceModuleLifecyclePanel-BO8Hw_W9.js +7619 -0
  25. package/dist/NiceModuleLifecyclePanel-Ch7HRRoy.cjs +1 -0
  26. package/dist/NiceModuleLifecyclePanel-D3k8kAey.js +7582 -0
  27. package/dist/NiceModuleLifecyclePanel-MAyTh_s5.cjs +1 -0
  28. package/dist/NicePagination-BVo-4KAD.js +172 -0
  29. package/dist/NicePagination-CaohvQsY.cjs +1 -0
  30. package/dist/NicePagination-DUnMbROj.cjs +1 -0
  31. package/dist/NicePagination-DyC6dQ7_.js +171 -0
  32. package/dist/NicePinCodeInput-C43eB9h4.js +13102 -0
  33. package/dist/NicePinCodeInput-DsyLuc0b.cjs +696 -0
  34. package/dist/NicePinCodeInput-nuRCN-9R.js +13223 -0
  35. package/dist/NicePinCodeInput-p5IFVwfY.cjs +696 -0
  36. package/dist/NicePoll.doc-DCiXvOb0.js +23 -0
  37. package/dist/NicePoll.doc-IOgqVPhc.cjs +1 -0
  38. package/dist/NicePollLive.doc-CdUyiCyf.js +23 -0
  39. package/dist/NicePollLive.doc-xBMqHeyt.cjs +1 -0
  40. package/dist/NiceQuiz.doc-BhAeGrcP.cjs +1 -0
  41. package/dist/NiceQuiz.doc-BiZq8X1P.js +23 -0
  42. package/dist/NiceSavedQueryPanel-BBFV4qiF.js +6969 -0
  43. package/dist/NiceSavedQueryPanel-CsiVNkCT.cjs +596 -0
  44. package/dist/NiceSavedQueryPanel-DV4a4axz.cjs +596 -0
  45. package/dist/NiceSavedQueryPanel-Dgbn1ExK.js +6893 -0
  46. package/dist/NiceSurvey.doc-9UorYdXy.cjs +1 -0
  47. package/dist/NiceSurvey.doc-CPF1ZEHo.js +23 -0
  48. package/dist/NiceWindow-BehN3PKk.js +1592 -0
  49. package/dist/NiceWindow-Cm9E6EAi.cjs +1 -0
  50. package/dist/NiceWindow-Dqu9ik8A.cjs +1 -0
  51. package/dist/NiceWindow-FMrVS7zo.js +1603 -0
  52. package/dist/charts-B90sSFeJ.cjs +761 -0
  53. package/dist/charts-CJruxLRY.js +4657 -0
  54. package/dist/charts-D8oj6Nf5.cjs +761 -0
  55. package/dist/charts-DaLf19vS.js +4671 -0
  56. package/dist/charts.cjs +1 -1
  57. package/dist/charts.mjs +1 -1
  58. package/dist/core-BIdbG6p3.js +27212 -0
  59. package/dist/core-BUTtIHg0.js +27766 -0
  60. package/dist/core-CESNSRyS.cjs +122 -0
  61. package/dist/core-bzK0ZnUp.cjs +122 -0
  62. package/dist/data-branching-ByQdcjKO.cjs +1 -0
  63. package/dist/data-branching-BzRFsCJu.js +6133 -0
  64. package/dist/data-branching-DahoQa4M.cjs +1 -0
  65. package/dist/data-branching-psTzlcrT.js +6255 -0
  66. package/dist/data-branching.cjs +1 -1
  67. package/dist/data-branching.mjs +1 -1
  68. package/dist/data.cjs +1 -1
  69. package/dist/data.mjs +1 -1
  70. package/dist/devops-C9gdQxuU.cjs +17 -0
  71. package/dist/devops-CaO_4qGz.js +7684 -0
  72. package/dist/devops-D7bQ3rE4.cjs +17 -0
  73. package/dist/devops-jCmpD6O-.js +8165 -0
  74. package/dist/devops.cjs +1 -1
  75. package/dist/devops.mjs +3 -3
  76. package/dist/editors.cjs +1 -1
  77. package/dist/editors.d.ts +4 -0
  78. package/dist/editors.mjs +3 -3
  79. package/dist/feedback.cjs +1 -1
  80. package/dist/feedback.mjs +3 -3
  81. package/dist/index-BK_Uwmz0.js +67774 -0
  82. package/dist/index-BpixglWg.js +69337 -0
  83. package/dist/index-CTbp81RF.cjs +5517 -0
  84. package/dist/index-DLR-aWZR.cjs +5506 -0
  85. package/dist/index.cjs +1 -1
  86. package/dist/index.css +1 -1
  87. package/dist/index.d.ts +796 -545
  88. package/dist/index.mjs +992 -979
  89. package/dist/lazy.cjs +1 -1
  90. package/dist/lazy.mjs +24 -24
  91. package/dist/navigation.cjs +1 -1
  92. package/dist/navigation.mjs +146 -146
  93. package/dist/no-code-B0mG7OQc.cjs +332 -0
  94. package/dist/no-code-BHo5WrXr.js +7425 -0
  95. package/dist/no-code-CikRvKeJ.js +7133 -0
  96. package/dist/no-code-DyA_1_Th.cjs +332 -0
  97. package/dist/no-code.cjs +1 -1
  98. package/dist/no-code.mjs +1 -1
  99. package/dist/overlays.cjs +1 -1
  100. package/dist/overlays.d.ts +4 -0
  101. package/dist/overlays.mjs +66 -66
  102. package/dist/pickerCommons-BEc3pZ_s.js +2044 -0
  103. package/dist/pickerCommons-CqhXp4QL.js +2043 -0
  104. package/dist/pickerCommons-CrITwM88.cjs +1 -0
  105. package/dist/pickerCommons-OsYJhnFE.cjs +1 -0
  106. package/dist/style.css +1 -1
  107. package/package.json +3 -3
@@ -0,0 +1,761 @@
1
+ "use strict";const e=require("react/jsx-runtime"),ue=require("./core-CESNSRyS.cjs"),o=require("react"),_e=["var(--color-primary, #3b82f6)","var(--color-error, #ef4444)","var(--color-success, #22c55e)","var(--color-warning, #f59e0b)","var(--color-accent, #8b5cf6)","var(--color-accent-pink, #ec4899)","var(--color-info, #06b6d4)","var(--nice-success, #84cc16)"],ke=({series:t,categories:c,width:i=600,height:l=400,title:s,showLegend:b=!0,showGrid:f=!0,axisLabels:A=!0,yAxisLabel:R,xAxisLabel:w,stacked:p,animated:k,zoomable:z,crosshair:S,annotations:N,legendInteractive:d,onDataPointClick:h,exportable:x,className:$,style:g})=>{const y=o.useRef(null),[v,j]=o.useState(new Set),[u,I]=o.useState(null),[a,_]=o.useState(null),[C,E]=o.useState(!1),U=o.useRef(null),V=o.useMemo(()=>t.filter(D=>!v.has(D.name)),[t,v]),H=o.useCallback(D=>{d&&j(ne=>{const ae=new Set(ne);return ae.has(D)?ae.delete(D):ae.add(D),ae})},[d]),G={top:s?40:20,right:20,bottom:w?60:40,left:R?60:50},Q=i-G.left-G.right,q=l-G.top-G.bottom,J=V[0]?.data.length??t[0]?.data.length??0,r=a?.start??0,X=a?.end??J,Y=X-r,B=o.useMemo(()=>V.map(D=>({...D,data:D.data.slice(r,X)})),[V,r,X]),m=o.useMemo(()=>c?.slice(r,X),[c,r,X]),{minY:P,maxY:F,yTicks:ee}=o.useMemo(()=>{let D;if(p){D=[];for(let M=0;M<Y;M++)D.push(B.reduce((K,se)=>K+(se.data[M]||0),0))}else D=B.flatMap(M=>M.data);D.length===0&&(D=[0]);const ne=Math.min(0,...D),ae=Math.max(0,...D),ce=ae-ne||1,ie=Math.pow(10,Math.floor(Math.log10(ce)))||1,n=Math.floor(ne/ie)*ie,T=Math.ceil(ae/ie)*ie,W=[];for(let M=n;M<=T;M+=ie)W.push(Math.round(M*1e6)/1e6);return W.length<2&&W.push(T),{minY:n,maxY:T,yTicks:W}},[B,Y,p]),O=D=>q-(D-P)/(F-P||1)*q,te=D=>(D+.5)/Y*Q,xe=Y>0?Q/Y/(p?1.5:Math.max(V.length,1)*1.5):20,L=o.useCallback(D=>{if(!z)return;D.preventDefault();const ne=a??{start:0,end:J},ae=ne.end-ne.start,ce=(ne.start+ne.end)/2,ie=D.deltaY>0?1.2:.8,n=Math.max(2,Math.min(J,Math.round(ae*ie))),T=Math.max(0,Math.round(ce-n/2)),W=Math.min(J,T+n);_({start:T,end:W})},[z,a,J]),Z=o.useCallback(D=>{z&&(E(!0),U.current={x:D.clientX,range:a??{start:0,end:J}})},[z,a,J]),re=o.useCallback(D=>{const ne=y.current?.getBoundingClientRect();if(ne&&I({x:D.clientX-ne.left-G.left,y:D.clientY-ne.top-G.top}),C&&U.current&&z){const ae=D.clientX-U.current.x,ce=Q/Y,ie=-Math.round(ae/ce),n=U.current.range,T=n.end-n.start;let W=n.start+ie;W<0&&(W=0),W+T>J&&(W=J-T),_({start:W,end:W+T})}},[C,z,Q,Y,J,G.left,G.top]),de=o.useCallback(()=>{E(!1),U.current=null},[]),ye=o.useCallback(()=>{I(null),E(!1),U.current=null},[]),me=o.useCallback(()=>{const D=y.current;if(!D)return;const ne=new XMLSerializer().serializeToString(D),ae=document.createElement("canvas");ae.width=i,ae.height=l+(b?30:0);const ce=ae.getContext("2d");if(!ce)return;const ie=new Image;ie.onload=()=>{ce.fillStyle="var(--bg-primary, #fff)",ce.fillRect(0,0,ae.width,ae.height),ce.drawImage(ie,0,0);const n=document.createElement("a");n.download="chart.png",n.href=ae.toDataURL("image/png"),n.click()},ie.src="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(ne)},[i,l,b]),ge=l+(b?30:0),be=B.length>0&&B.every(D=>D.type==="radar"),we=o.useMemo(()=>{if(!be)return 1;const D=B.flatMap(ne=>ne.data);return Math.max(1,...D)},[be,B]);if(be){const D=i/2,ne=(l-G.top-G.bottom)/2+G.top,ae=Math.min(Q,l-G.top-G.bottom)/2-10,ce=m?.length??B[0]?.data.length??0,ie=W=>W/ce*Math.PI*2-Math.PI/2,n=(W,M)=>{const K=M/we*ae;return[D+Math.cos(ie(W))*K,ne+Math.sin(ie(W))*K]},T=4;return e.jsx("div",{className:`nice-chart nice-chart--radar ${$||""}`,style:g,children:e.jsxs("svg",{ref:y,viewBox:`0 0 ${i} ${ge}`,preserveAspectRatio:"xMidYMid meet",width:"100%",height:"100%",className:"nice-chart__svg",style:{display:"block",maxWidth:"100%",maxHeight:"100%"},children:[s&&e.jsx("text",{x:i/2,y:20,textAnchor:"middle",className:"nice-chart__title",children:s}),f&&Array.from({length:T},(W,M)=>{const K=(M+1)/T*ae,se=[];for(let oe=0;oe<ce;oe++)se.push(`${D+Math.cos(ie(oe))*K},${ne+Math.sin(ie(oe))*K}`);return e.jsx("polygon",{points:se.join(" "),fill:"none",className:"nice-chart__grid-line"},M)}),Array.from({length:ce},(W,M)=>{const[K,se]=n(M,we);return e.jsx("line",{x1:D,y1:ne,x2:K,y2:se,className:"nice-chart__grid-line"},M)}),A&&m?.map((W,M)=>{const[K,se]=n(M,we*1.12);return e.jsx("text",{x:K,y:se,textAnchor:"middle",dominantBaseline:"middle",className:"nice-chart__axis-label",children:W},M)}),B.map((W,M)=>{const K=W.color||_e[M%_e.length],se=W.data.map((oe,le)=>n(le,oe).join(",")).join(" ");return e.jsxs("g",{className:k?"nice-chart__series nice-chart__series--radar nice-chart__series--anim":"nice-chart__series nice-chart__series--radar",children:[e.jsx("polygon",{points:se,fill:K,fillOpacity:.2,stroke:K,strokeWidth:2}),W.data.map((oe,le)=>{const[ve,je]=n(le,oe);return e.jsx("circle",{cx:ve,cy:je,r:3,fill:K,children:e.jsx("title",{children:`${W.name}: ${oe}`})},le)})]},W.name)}),b&&e.jsx("g",{transform:`translate(${G.left}, ${l})`,children:t.map((W,M)=>{const K=M*120,se=v.has(W.name);return e.jsxs("g",{transform:`translate(${K}, 10)`,style:d?{cursor:"pointer"}:void 0,onClick:()=>H(W.name),opacity:se?.35:1,children:[e.jsx("rect",{width:12,height:12,rx:2,fill:W.color||_e[M%_e.length]}),e.jsx("text",{x:16,y:10,className:"nice-chart__legend-text",children:W.name})]},W.name)})})]})})}return e.jsxs("div",{className:`nice-chart ${$||""}`,style:g,children:[x&&e.jsx("button",{type:"button",className:"nice-chart__export-btn",onClick:me,title:"Export PNG","aria-label":"Export PNG",children:e.jsx(ue.oa,{name:"camera",size:16})}),e.jsxs("svg",{ref:y,viewBox:`0 0 ${i} ${ge}`,preserveAspectRatio:"xMidYMid meet",width:"100%",height:"100%",style:{display:"block",maxWidth:"100%",maxHeight:"100%"},className:"nice-chart__svg",onWheel:L,onMouseDown:Z,onMouseMove:re,onMouseUp:de,onMouseLeave:ye,children:[e.jsxs("g",{transform:`translate(${G.left},${G.top})`,children:[s&&e.jsx("text",{x:Q/2,y:-10,textAnchor:"middle",className:"nice-chart__title",children:s}),f&&ee.map(D=>e.jsx("line",{x1:0,y1:O(D),x2:Q,y2:O(D),className:"nice-chart__grid-line"},`grid-${D}`)),A&&ee.map(D=>e.jsx("text",{x:-8,y:O(D)+4,textAnchor:"end",className:"nice-chart__axis-label",children:D},`ylabel-${D}`)),A&&m&&m.map((D,ne)=>e.jsx("text",{x:te(ne),y:q+20,textAnchor:"middle",className:"nice-chart__axis-label",children:D},ne)),R&&e.jsx("text",{x:-G.left+14,y:q/2,textAnchor:"middle",transform:`rotate(-90, -${G.left-14}, ${q/2})`,className:"nice-chart__axis-title",children:R}),w&&e.jsx("text",{x:Q/2,y:q+45,textAnchor:"middle",className:"nice-chart__axis-title",children:w}),e.jsx("line",{x1:0,y1:0,x2:0,y2:q,className:"nice-chart__axis"}),e.jsx("line",{x1:0,y1:q,x2:Q,y2:q,className:"nice-chart__axis"}),N?.map((D,ne)=>{if(D.type==="line"){const ae=O(D.value);return e.jsxs("g",{children:[e.jsx("line",{x1:0,y1:ae,x2:Q,y2:ae,stroke:D.color||"var(--color-error, #ef4444)",strokeWidth:1.5,strokeDasharray:D.dash||"6,3"}),D.label&&e.jsx("text",{x:Q+4,y:ae+4,className:"nice-chart__annotation-label",fill:D.color||"var(--color-error, #ef4444)",children:D.label})]},ne)}return e.jsx("text",{x:te(D.value),y:-4,textAnchor:"middle",className:"nice-chart__annotation-label",fill:D.color||"var(--text-muted, #6b7280)",children:D.label},ne)}),S&&u&&u.x>=0&&u.x<=Q&&u.y>=0&&u.y<=q&&e.jsxs(e.Fragment,{children:[e.jsx("line",{x1:u.x,y1:0,x2:u.x,y2:q,stroke:"var(--nice-text-muted, #9ca3af)",strokeWidth:1,strokeDasharray:"4,2"}),e.jsx("line",{x1:0,y1:u.y,x2:Q,y2:u.y,stroke:"var(--nice-text-muted, #9ca3af)",strokeWidth:1,strokeDasharray:"4,2"})]}),B.map((D,ne)=>{const ae=D.color||_e[ne%_e.length],ce=D.type||"bar";if(ce==="bar")return e.jsx("g",{className:k?"nice-chart__series nice-chart__series--bar nice-chart__series--anim":"nice-chart__series nice-chart__series--bar",children:D.data.map((n,T)=>{let W,M;if(p){const se=B.slice(0,ne).reduce((oe,le)=>oe+(le.data[T]||0),0);W=O(se+n),M=O(se)-W}else W=O(Math.max(0,n)),M=Math.abs(O(n)-O(0));const K=p?te(T)-xe/2:te(T)-B.length*xe/2+ne*xe;return e.jsx("rect",{x:K,y:W,width:xe*.9,height:Math.max(0,M),fill:ae,rx:2,style:{transformOrigin:`${K+xe*.9/2}px ${O(0)}px`,...h?{cursor:"pointer"}:{}},onClick:h?()=>h(D.name,r+T,n):void 0,children:e.jsx("title",{children:`${D.name}: ${n}`})},T)})},D.name);if(ce==="scatter")return e.jsx("g",{className:k?"nice-chart__series nice-chart__series--scatter nice-chart__series--anim":"nice-chart__series nice-chart__series--scatter",children:D.data.map((n,T)=>e.jsx("circle",{cx:te(T),cy:O(n),r:5,fill:ae,fillOpacity:.7,stroke:ae,strokeWidth:1.5,style:h?{cursor:"pointer"}:void 0,onClick:h?()=>h(D.name,r+T,n):void 0,children:e.jsx("title",{children:`${D.name}: ${n}`})},T))},D.name);const ie=D.data.map((n,T)=>`${te(T)},${O(n)}`);return e.jsxs("g",{className:k?`nice-chart__series nice-chart__series--${ce} nice-chart__series--anim`:`nice-chart__series nice-chart__series--${ce}`,children:[ce==="area"&&e.jsx("polygon",{points:`${te(0)},${O(0)} ${ie.join(" ")} ${te(Y-1)},${O(0)}`,fill:ae,opacity:.15}),e.jsx("polyline",{points:ie.join(" "),fill:"none",stroke:ae,strokeWidth:2,className:k?"nice-chart__line":void 0}),D.data.map((n,T)=>e.jsx("circle",{cx:te(T),cy:O(n),r:3,fill:ae,style:h?{cursor:"pointer"}:void 0,onClick:h?()=>h(D.name,r+T,n):void 0,children:e.jsx("title",{children:`${D.name}: ${n}`})},T))]},D.name)})]}),b&&e.jsx("g",{transform:`translate(${G.left}, ${l})`,children:t.map((D,ne)=>{const ae=ne*120,ce=v.has(D.name);return e.jsxs("g",{transform:`translate(${ae}, 10)`,style:d?{cursor:"pointer"}:void 0,onClick:()=>H(D.name),opacity:ce?.35:1,children:[e.jsx("rect",{width:12,height:12,rx:2,fill:D.color||_e[ne%_e.length]}),e.jsx("text",{x:16,y:10,className:"nice-chart__legend-text",style:ce?{textDecoration:"line-through"}:void 0,children:D.name})]},D.name)})})]})]})},Ye=Object.freeze(Object.defineProperty({__proto__:null,NiceChart:ke},Symbol.toStringTag,{value:"Module"}));function Ve(t){if(!t.length)return{categories:[],numericFields:[],sampleValues:{}};const c=t[0],i=[],l={};let s=null;for(const[f,A]of Object.entries(c))typeof A=="number"?(i.push(f),l[f]=t.map(R=>Number(R[f])||0)):!s&&(typeof A=="string"||A instanceof Date)&&(s=f);return{categories:s?t.map(f=>String(f[s]||"")):t.map((f,A)=>`Item ${A+1}`),numericFields:i,sampleValues:l}}function Xe(t,c){const{categories:i,numericFields:l,sampleValues:s}=Ve(t);return{series:l.map((f,A)=>({name:f.replace(/([A-Z])/g," $1").replace(/^./,R=>R.toUpperCase()).trim(),data:s[f],type:c==="area"?"area":c==="line"?"line":"bar"})),categories:i}}const Ze=o.forwardRef(function(c,i){const{rawData:l,enableAI:s=!0,aiModel:b,enableAutoType:f=!0,enableInsights:A=!0,dataDescription:R,onChartSuggestion:w,onInsights:p,showAIToolbar:k=!0,showInsightsOnLoad:z=!1,series:S,categories:N,...d}=c,[h,x]=o.useState("bar"),[$,g]=o.useState(null),[y,v]=o.useState([]),[j,u]=o.useState(z),[I,a]=o.useState(null),{t:_}=ue.Gt(),C=ue.he(),{suggestChartType:E,generateInsights:U,isLoading:V}=ue.kd(),H=s&&C.isConfigured,{series:G,categories:Q}=l?Xe(l,I||h):{series:S||[],categories:N},q=o.useCallback(async()=>{if(!H||!f)return{type:"bar",reason:"Default",config:{}};const B=l||(S?.length?S.flatMap(m=>m.data.map((P,F)=>({[m.name]:P,index:F}))):[]);try{const m=await E(B,R),P={type:m.type,reason:m.reason,config:m.config};return g(P),x(P.type),w?.(P),P}catch{return{type:"bar",reason:"Default fallback",config:{}}}},[H,f,l,S,R,E,w]),J=o.useCallback(async()=>{if(!H||!A)return[];const B=l||(S?.length?S.flatMap(m=>m.data.map((P,F)=>({[m.name]:P,category:N?.[F]||F}))):[]);try{const m=await U(B,I||h);return v(m),p?.(m),m}catch{return[]}},[H,A,l,S,N,h,I,U,p]),r=o.useCallback(()=>I||h,[I,h]);o.useEffect(()=>{H&&f&&(l?.length||S?.length)&&q()},[H,f,l,S]),o.useImperativeHandle(i,()=>({getSuggestion:q,generateInsights:J,getCurrentType:r}));const X=[{type:"bar",icon:"bar-chart",label:"Bar"},{type:"line",icon:"bar-chart",label:"Line"},{type:"area",icon:"bar-chart",label:"Area"},{type:"pie",icon:"circle",label:"Pie"},{type:"donut",icon:"circle",label:"Donut"},{type:"scatter",icon:"star",label:"Scatter"}],Y=I||h;return e.jsxs("div",{className:"nice-chart-ai","data-testid":c["data-testid"],children:[k&&H&&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:"AI"}),$&&e.jsxs("div",{className:"nice-chart-ai__suggestion",children:[e.jsx("span",{className:"nice-chart-ai__suggestion-icon",children:e.jsx(ue.oa,{name:"lightbulb",size:14})}),e.jsxs("span",{className:"nice-chart-ai__suggestion-text",children:[_("chartAI.suggestedType","Suggested:")," ",$.type]}),e.jsxs("span",{className:"nice-chart-ai__suggestion-reason",title:$.reason,children:["(",$.reason,")"]})]}),V&&e.jsx("span",{className:"nice-chart-ai__loading",children:_("chartAI.analyzing","Analyzing...")})]}),e.jsx("div",{className:"nice-chart-ai__toolbar-center",children:e.jsx("div",{className:"nice-chart-ai__type-selector",children:X.filter(B=>["bar","line","area"].includes(B.type)).map(({type:B,icon:m,label:P})=>e.jsx("button",{type:"button",className:`nice-chart-ai__type-btn ${Y===B?"nice-chart-ai__type-btn--active":""}`,onClick:()=>a(B),title:P,children:e.jsx(ue.oa,{name:m,size:16})},B))})}),e.jsxs("div",{className:"nice-chart-ai__toolbar-right",children:[e.jsxs("button",{type:"button",className:"nice-chart-ai__auto-btn",onClick:()=>q(),disabled:V,title:_("chartAI.autoDetect","Auto-detect best chart type"),children:[e.jsx(ue.oa,{name:"zap",size:14})," ",_("chartAI.auto","Auto")]}),A&&e.jsxs("button",{type:"button",className:"nice-chart-ai__insights-btn",onClick:()=>{y.length||J(),u(!j)},disabled:V,title:_("chartAI.showInsights","Show data insights"),children:[e.jsx(ue.oa,{name:"lightbulb",size:14})," ",_("chartAI.insights","Insights")]})]})]}),e.jsx("div",{className:"nice-chart-ai__chart-wrapper",children:e.jsx(ke,{series:G,categories:Q,...d})}),j&&y.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(ue.oa,{name:"lightbulb",size:14})," ",_("chartAI.dataInsights","Data Insights")]}),e.jsx("button",{type:"button",className:"nice-chart-ai__insights-close",onClick:()=>u(!1),"aria-label":_("chartAI.close","Close"),children:e.jsx(ue.oa,{name:"close",size:14})})]}),e.jsx("ul",{className:"nice-chart-ai__insights-list",children:y.map((B,m)=>e.jsxs("li",{className:"nice-chart-ai__insight",children:[e.jsx("span",{className:"nice-chart-ai__insight-icon",children:"•"}),B]},m))}),e.jsx("div",{className:"nice-chart-ai__insights-footer",children:e.jsxs("button",{type:"button",className:"nice-chart-ai__refresh",onClick:()=>J(),disabled:V,children:[e.jsx(ue.oa,{name:"refresh",size:14})," ",_("chartAI.refresh","Refresh")]})})]}),j&&V&&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"}),_("chartAI.generatingInsights","Generating insights...")]})})]})});function Ue(t,c){const i=t?typeof t=="number"?new Date(t):new Date(t):new Date,l=R=>R.toString().padStart(2,"0"),s=l(i.getHours()),b=l(i.getMinutes()),f=l(i.getSeconds()),A=i.getMilliseconds().toString().padStart(3,"0");switch(c){case"HH:mm:ss":return`${s}:${b}:${f}`;case"HH:mm":return`${s}:${b}`;case"mm:ss":return`${b}:${f}`;case"ss.SSS":return`${f}.${A}`;case"ISO":return i.toISOString();default:return`${s}:${b}:${f}`}}function ze(t){if(t.length===0)return null;const c=Math.min(...t),i=Math.max(...t),l=t.reduce((b,f)=>b+f,0)/t.length,s=t[t.length-1];return{min:c,max:i,avg:l,current:s,count:t.length}}const Re=o.forwardRef(({series:t,maxPoints:c=100,slidingWindow:i=!0,refreshRate:l=16,dataSource:s,width:b=600,height:f=400,title:A,showLegend:R=!0,showGrid:w=!0,yAxisLabel:p,xAxisLabel:k,stacked:z,zoomable:S,crosshair:N,annotations:d=[],legendInteractive:h,onDataPointClick:x,exportable:$,showControls:g=!0,showStatus:y=!0,initialPaused:v=!1,onDataReceived:j,onDataDropped:u,timeFormat:I="HH:mm:ss",showStats:a,thresholds:_=[],className:C,style:E},U)=>{const[V,H]=o.useState(()=>{const L=new Map;for(const Z of t)L.set(Z.name,Z.initialData?.slice()??[]);return L}),[G,Q]=o.useState([]),[q,J]=o.useState(v),[r,X]=o.useState(!1),Y=o.useRef([]),B=o.useRef(Date.now()),m=o.useRef(null),P=o.useCallback(()=>{const L=Y.current;L.length!==0&&(Y.current=[],H(Z=>{const re=new Map(Z);for(const de of L){const ye=re.get(de.series);if(!ye)continue;const me=[...ye,de.value];if(i&&me.length>c){const ge=me.length-c;u?.(ge,de.series),me.splice(0,ge)}re.set(de.series,me)}return re}),L.length>0&&Q(Z=>{const re=[...Z];for(const de of L){const ye=de.category??Ue(de.timestamp,I);re.push(ye)}return i&&re.length>c&&re.splice(0,re.length-c),re}))},[i,c,I,u]),F=o.useCallback(()=>{const L=Date.now();L-B.current>=l&&(P(),B.current=L),m.current=requestAnimationFrame(F)},[l,P]);o.useEffect(()=>(q||(m.current=requestAnimationFrame(F)),()=>{m.current!==null&&(cancelAnimationFrame(m.current),m.current=null)}),[q,F]);const ee=o.useCallback(L=>{if(q)return;const Z="points"in L?L.points:[L];for(const re of Z)V.has(re.series)&&(Y.current.push(re),j?.(re))},[q,V,j]);o.useEffect(()=>{if(!s)return;const L=s.subscribe(ee);let Z;return s.onStatusChange?Z=s.onStatusChange(X):X(!0),s.fetchHistory&&s.fetchHistory(c).then(re=>{for(const de of re)Y.current.push(de);P()}),()=>{L(),Z?.()}},[s,ee,c,P]);const O=o.useMemo(()=>t.map(L=>({name:L.name,color:L.color,type:L.type,data:V.get(L.name)??[]})),[t,V]),te=o.useMemo(()=>{const L=[...d];for(const Z of _)L.push({type:"line",value:Z.value,color:Z.color,label:Z.label,dash:Z.style==="dashed"?"5,5":Z.style==="dotted"?"2,2":void 0});return L},[d,_]);o.useImperativeHandle(U,()=>({pause(){J(!0)},resume(){J(!1)},isPaused(){return q},clear(){H(L=>{const Z=new Map(L);for(const re of Z.keys())Z.set(re,[]);return Z}),Q([]),Y.current=[]},addPoint(L){ee(L)},addPoints(L){ee({points:L})},getData(L){return V.get(L)??[]},getCategories(){return G},exportData(){return{series:O,categories:G}},getStats(L){const Z=V.get(L);return Z?ze(Z):null}}),[q,V,G,O,ee]);const xe=o.useMemo(()=>{if(!a)return null;const L={};for(const[Z,re]of V)L[Z]=ze(re);return L},[a,V]);return e.jsxs("div",{className:C,style:{position:"relative",...E},children:[y&&e.jsxs("div",{style:{position:"absolute",top:8,right:8,display:"flex",alignItems:"center",gap:4,fontSize:12,color:r?"var(--color-success, #22c55e)":"var(--color-error, #ef4444)",zIndex:10},children:[e.jsx("span",{style:{width:8,height:8,borderRadius:"50%",backgroundColor:r?"var(--color-success, #22c55e)":"var(--color-error, #ef4444)"}}),r?"Live":"Disconnected"]}),g&&e.jsx("div",{style:{position:"absolute",top:8,left:8,display:"flex",gap:4,zIndex:10},children:e.jsx("button",{onClick:()=>J(L=>!L),style:{padding:"4px 8px",fontSize:12,border:"1px solid var(--border-color, #ddd)",borderRadius:4,background:q?"var(--warning-bg, #fef3c7)":"var(--bg-primary, #fff)",cursor:"pointer"},title:q?"Resume":"Pause","aria-label":q?"Resume":"Pause",children:e.jsx(ue.oa,{name:q?"play":"pause",size:14})})}),a&&xe&&e.jsx("div",{style:{position:"absolute",bottom:50,right:8,background:"var(--nice-overlay-light-90, rgba(255, 255, 255, 0.9))",border:"1px solid var(--border-color, #ddd)",borderRadius:4,padding:8,fontSize:11,zIndex:10},children:Object.entries(xe).map(([L,Z])=>Z?e.jsxs("div",{style:{marginBottom:4},children:[e.jsx("strong",{children:L}),e.jsxs("div",{children:["Min: ",Z.min.toFixed(2)," | Max: ",Z.max.toFixed(2)]}),e.jsxs("div",{children:["Avg: ",Z.avg.toFixed(2)," | Now: ",Z.current.toFixed(2)]})]},L):null)}),e.jsx(ke,{series:O,categories:G,width:b,height:f,title:A,showLegend:R,showGrid:w,yAxisLabel:p,xAxisLabel:k,stacked:z,zoomable:S,crosshair:N,annotations:te,legendInteractive:h,onDataPointClick:x,exportable:$})]})});Re.displayName="NiceLiveChart";function Ge(t){const{hubConnection:c,eventName:i="DataPoint",subscribeMethod:l="SubscribeToMetrics",historyMethod:s="GetMetricHistory",metricName:b}=t;return{subscribe(f){const A=R=>{f(R)};return c.on(i,A),c.state==="Connected"&&c.invoke(l,b).catch(()=>{}),()=>{c.off(i,A)}},async fetchHistory(f){try{return await c.invoke(s,b,f)}catch{return[]}},onStatusChange(f){const A=()=>f(c.state==="Connected");return c.onclose(()=>f(!1)),c.onreconnected(()=>f(!0)),A(),()=>{}}}}function qe(t){const{url:c,autoReconnect:i=!0,reconnectDelay:l=3e3,parseMessage:s=p=>JSON.parse(p)}=t;let b=null,f=null,A=null,R=null;const w=()=>{b=new WebSocket(c),b.onopen=()=>{f?.(!0)},b.onclose=()=>{f?.(!1),i&&(R=setTimeout(w,l))},b.onerror=()=>{b?.close()},b.onmessage=p=>{try{const k=s(p.data);k&&A&&A(k)}catch{}}};return{subscribe(p){return A=p,w(),()=>{A=null,R&&clearTimeout(R),b?.close(),b=null}},onStatusChange(p){return f=p,()=>{f=null}}}}function Je(t){const{seriesNames:c,interval:i=1e3,generateValue:l=()=>Math.random()*100}=t;let s=null,b=0;return{subscribe(f){return s=setInterval(()=>{for(const A of c)f({series:A,value:l(A,b),timestamp:Date.now()});b++},i),()=>{s&&clearInterval(s)}},onStatusChange(f){return f(!0),()=>{}}}}const pe=["#3b82f6","#ef4444","#22c55e","#f59e0b","#8b5cf6","#ec4899","#06b6d4","#84cc16"],Ke=({data:t,width:c=400,height:i=400,innerRadius:l=0,title:s,showLegend:b=!0,showLabels:f=!0,className:A,style:R})=>{const w=c/2,p=(i-(b?30:0))/2+(s?10:0),k=Math.min(w,p)-40,z=t.reduce((d,h)=>d+h.value,0);let S=-Math.PI/2;const N=t.map((d,h)=>{const x=d.value/(z||1)*Math.PI*2,$=S;S+=x;const g=S,y=($+g)/2,v=w+k*Math.cos($),j=p+k*Math.sin($),u=w+k*Math.cos(g),I=p+k*Math.sin(g),a=x>Math.PI?1:0,_=d.color||pe[h%pe.length];let C;if(l>0){const H=w+l*Math.cos($),G=p+l*Math.sin($),Q=w+l*Math.cos(g),q=p+l*Math.sin(g);C=`M${v},${j} A${k},${k} 0 ${a},1 ${u},${I} L${Q},${q} A${l},${l} 0 ${a},0 ${H},${G} Z`}else C=`M${w},${p} L${v},${j} A${k},${k} 0 ${a},1 ${u},${I} Z`;const E=w+k*.7*Math.cos(y),U=p+k*.7*Math.sin(y),V=z>0?Math.round(d.value/z*100):0;return{...d,path:C,labelX:E,labelY:U,pct:V,color:_}});return e.jsx("div",{className:`nice-piechart ${A||""}`,style:R,children:e.jsxs("svg",{viewBox:`0 0 ${c} ${i}`,preserveAspectRatio:"xMidYMid meet",width:"100%",height:"100%",style:{display:"block",maxWidth:"100%",maxHeight:"100%"},className:"nice-piechart__svg",children:[s&&e.jsx("text",{x:w,y:20,textAnchor:"middle",className:"nice-chart__title",children:s}),N.map((d,h)=>e.jsxs("g",{children:[e.jsx("path",{d:d.path,fill:d.color,stroke:"var(--bg-primary, #fff)",strokeWidth:2,children:e.jsx("title",{children:`${d.label}: ${d.value} (${d.pct}%)`})}),f&&d.pct>=5&&e.jsxs("text",{x:d.labelX,y:d.labelY,textAnchor:"middle",dominantBaseline:"middle",className:"nice-piechart__label",children:[d.pct,"%"]})]},h)),b&&e.jsx("g",{transform:`translate(10, ${i-25})`,children:t.map((d,h)=>e.jsxs("g",{transform:`translate(${h*100}, 0)`,children:[e.jsx("rect",{width:10,height:10,rx:2,fill:d.color||pe[h%pe.length]}),e.jsx("text",{x:14,y:9,className:"nice-chart__legend-text",children:d.label})]},h))})]})})},Qe=({series:t,categories:c,width:i=400,height:l=400,maxValue:s,title:b,showLegend:f=!0,className:A,style:R})=>{const w=i/2,p=(l-(f?30:0))/2+(b?10:0),k=Math.min(w,p)-60,z=c.length,S=s??Math.max(...t.flatMap(x=>x.data),1),N=Math.PI*2/z,d=5,h=(x,$)=>{const g=x*N-Math.PI/2,y=$/S*k;return{x:w+y*Math.cos(g),y:p+y*Math.sin(g)}};return e.jsx("div",{className:`nice-polarchart ${A||""}`,style:R,children:e.jsxs("svg",{width:i,height:l,className:"nice-polarchart__svg",children:[b&&e.jsx("text",{x:w,y:20,textAnchor:"middle",className:"nice-chart__title",children:b}),Array.from({length:d},(x,$)=>{const g=k*(($+1)/d);return e.jsx("circle",{cx:w,cy:p,r:g,fill:"none",stroke:"var(--border-color, #ddd)",strokeWidth:.5},$)}),c.map((x,$)=>{const g=h($,S),y=h($,S*1.22),v=$*N-Math.PI/2,j=Math.cos(v),u=Math.sin(v),I=j>.2?"start":j<-.2?"end":"middle",a=u>.2?"hanging":u<-.2?"auto":"middle";return e.jsxs("g",{children:[e.jsx("line",{x1:w,y1:p,x2:g.x,y2:g.y,stroke:"var(--border-color, #ddd)",strokeWidth:.5}),e.jsx("text",{x:y.x,y:y.y,textAnchor:I,dominantBaseline:a,className:"nice-chart__axis-label nice-chart__axis-label--polar",children:x})]},$)}),t.map((x,$)=>{const g=x.color||pe[$%pe.length],y=x.data.map((v,j)=>{const u=h(j,v);return`${u.x},${u.y}`}).join(" ");return e.jsxs("g",{children:[e.jsx("polygon",{points:y,fill:x.fill!==!1?g:"none",fillOpacity:.15,stroke:g,strokeWidth:2}),x.data.map((v,j)=>{const u=h(j,v);return e.jsx("circle",{cx:u.x,cy:u.y,r:3,fill:g,children:e.jsx("title",{children:`${x.name} - ${c[j]}: ${v}`})},j)})]},x.name)}),f&&e.jsx("g",{transform:`translate(10, ${l-25})`,children:t.map((x,$)=>e.jsxs("g",{transform:`translate(${$*100}, 0)`,children:[e.jsx("rect",{width:10,height:10,rx:2,fill:x.color||pe[$%pe.length]}),e.jsx("text",{x:14,y:9,className:"nice-chart__legend-text",children:x.name})]},$))})]})})},et=({value:t,min:c=0,max:i=100,width:l=200,height:s=200,startAngle:b=225,endAngle:f=-45,color:A="var(--color-primary, #3b82f6)",trackColor:R,label:w,formatValue:p,ranges:k,className:z,style:S})=>{const N=l/2,d=s/2,h=Math.min(N,d)-20,x=Math.max(0,Math.min(1,(t-c)/(i-c||1))),$=a=>a*Math.PI/180,g=(b-f+360)%360||360,y=a=>({x:N+h*Math.cos($(a)),y:d-h*Math.sin($(a))}),v=(a,_)=>{const C=y(a),E=y(_),V=(a-_+360)%360>180?1:0;return`M${C.x},${C.y} A${h},${h} 0 ${V},1 ${E.x},${E.y}`},j=b-x*g,u=y(j);let I=A;if(k){for(const a of k)if(t>=a.start&&t<=a.end){I=a.color;break}}return e.jsx("div",{className:`nice-gauge nice-gauge--circular ${z||""}`,style:S,children:e.jsxs("svg",{width:l,height:s,children:[e.jsx("path",{d:v(b,f),fill:"none",stroke:R||"var(--border-color, #e2e8f0)",strokeWidth:12,strokeLinecap:"round"}),x>0&&e.jsx("path",{d:v(b,j),fill:"none",stroke:I,strokeWidth:12,strokeLinecap:"round"}),e.jsx("line",{x1:N,y1:d,x2:u.x,y2:u.y,stroke:"var(--text-primary, #333)",strokeWidth:2,strokeLinecap:"round"}),e.jsx("circle",{cx:N,cy:d,r:4,fill:"var(--text-primary, #333)"}),e.jsx("text",{x:N,y:d+h*.6,textAnchor:"middle",className:"nice-gauge__value",children:p?p(t):t}),w&&e.jsx("text",{x:N,y:d+h*.95,textAnchor:"middle",className:"nice-gauge__label",children:w})]})})},tt=({value:t,min:c=0,max:i=100,width:l=300,height:s=60,orientation:b="horizontal",color:f="var(--color-primary, #3b82f6)",label:A,formatValue:R,ranges:w,showTicks:p=!0,tickCount:k=5,className:z,style:S})=>{const N=b==="horizontal",d=N?l-40:s-40,h=Math.max(0,Math.min(1,(t-c)/(i-c||1))),x=10;let $=f;if(w){for(const y of w)if(t>=y.start&&t<=y.end){$=y.color;break}}const g=Array.from({length:k},(y,v)=>c+(i-c)*(v/(k-1)));return N?e.jsx("div",{className:`nice-gauge nice-gauge--linear ${z||""}`,style:S,children:e.jsxs("svg",{width:l,height:s,children:[e.jsx("text",{x:20+d*h,y:14,textAnchor:"middle",className:"nice-gauge__value",style:{fontSize:12},children:R?R(t):t}),e.jsx("rect",{x:20,y:s/2-x/2,width:d,height:x,rx:5,fill:"var(--border-color, #e2e8f0)"}),e.jsx("rect",{x:20,y:s/2-x/2,width:d*h,height:x,rx:5,fill:$}),e.jsx("polygon",{points:`${20+d*h},${s/2-x/2-2} ${20+d*h-5},${s/2-x/2-8} ${20+d*h+5},${s/2-x/2-8}`,fill:"var(--text-primary, #333)"}),p&&g.map((y,v)=>{const j=20+(y-c)/(i-c)*d;return e.jsx("text",{x:j,y:s/2+x/2+12,textAnchor:"middle",className:"nice-gauge__tick",children:y},v)}),A&&e.jsx("text",{x:l/2,y:s-2,textAnchor:"middle",className:"nice-gauge__label",children:A})]})}):e.jsx("div",{className:`nice-gauge nice-gauge--linear nice-gauge--vertical ${z||""}`,style:S,children:e.jsxs("svg",{width:l,height:s,children:[e.jsx("rect",{x:l/2-x/2,y:20,width:x,height:d,rx:5,fill:"var(--border-color, #e2e8f0)"}),e.jsx("rect",{x:l/2-x/2,y:20+d*(1-h),width:x,height:d*h,rx:5,fill:$}),e.jsx("text",{x:l/2,y:14,textAnchor:"middle",className:"nice-gauge__value",children:R?R(t):t}),A&&e.jsx("text",{x:l/2,y:s-4,textAnchor:"middle",className:"nice-gauge__label",children:A})]})})},rt=({items:t,min:c=0,max:i=100,width:l=300,height:s=300,startAngle:b=225,endAngle:f=-45,formatValue:A,title:R,className:w,style:p})=>{const k=l/2,z=s/2,S=Math.min(k,z)-30,N=Math.min(20,S/(t.length+1)),d=4,h=g=>g*Math.PI/180,x=(b-f+360)%360||360,$=(g,y,v)=>{const j=k+g*Math.cos(h(y)),u=z-g*Math.sin(h(y)),I=k+g*Math.cos(h(v)),a=z-g*Math.sin(h(v)),_=(y-v+360)%360;return`M${j},${u} A${g},${g} 0 ${_>180?1:0},1 ${I},${a}`};return e.jsx("div",{className:`nice-bargauge ${w||""}`,style:p,children:e.jsxs("svg",{width:l,height:s,children:[R&&e.jsx("text",{x:k,y:20,textAnchor:"middle",className:"nice-chart__title",children:R}),t.map((g,y)=>{const v=S-y*(N+d),j=Math.max(0,Math.min(1,(g.value-c)/(i-c||1))),u=b-j*x,I=g.color||pe[y%pe.length];return e.jsxs("g",{children:[e.jsx("path",{d:$(v,b,f),fill:"none",stroke:"var(--border-color, #e2e8f0)",strokeWidth:N,strokeLinecap:"round"}),j>0&&e.jsx("path",{d:$(v,b,u),fill:"none",stroke:I,strokeWidth:N,strokeLinecap:"round"})]},y)}),e.jsx("g",{children:t.map((g,y)=>e.jsxs("text",{x:k,y:z-((t.length-1)/2-y)*16,textAnchor:"middle",dominantBaseline:"middle",className:"nice-gauge__value",style:{fontSize:12},children:[g.label?`${g.label}: `:"",A?A(g.value):g.value]},y))})]})})},nt=({data:t,width:c=120,height:i=30,type:l="line",color:s="var(--color-primary, #3b82f6)",showMinMax:b,showLastPoint:f=!0,className:A,style:R})=>{if(t.length===0)return null;const w=2,p=Math.min(...t),k=Math.max(...t),z=k-p||1,S=c-w*2,N=i-w*2,d=v=>w+v/(t.length-1||1)*S,h=v=>w+N-(v-p)/z*N;if(l==="bar"){const v=Math.max(1,S/t.length-1);return e.jsx("svg",{width:c,height:i,className:`nice-sparkline ${A||""}`,style:R,children:t.map((j,u)=>e.jsx("rect",{x:w+u/t.length*S,y:h(j),width:v,height:N-(h(j)-w),fill:s,rx:1},u))})}const x=t.map((v,j)=>`${d(j)},${h(v)}`).join(" "),$=t.indexOf(p),g=t.indexOf(k),y=t.length-1;return e.jsxs("svg",{width:c,height:i,className:`nice-sparkline ${A||""}`,style:R,children:[l==="area"&&e.jsx("polygon",{points:`${d(0)},${w+N} ${x} ${d(y)},${w+N}`,fill:s,opacity:.15}),e.jsx("polyline",{points:x,fill:"none",stroke:s,strokeWidth:1.5}),b&&e.jsx("circle",{cx:d($),cy:h(p),r:2,fill:"var(--nice-danger, #ef4444)"}),b&&e.jsx("circle",{cx:d(g),cy:h(k),r:2,fill:"var(--nice-success, #22c55e)"}),f&&e.jsx("circle",{cx:d(y),cy:h(t[y]),r:2,fill:s})]})},at={sm:{width:160,height:22,fontSize:11},md:{width:220,height:32,fontSize:12},lg:{width:320,height:44,fontSize:14}},st=({value:t,target:c,min:i=0,max:l=100,width:s,height:b,color:f="var(--color-primary, #3b82f6)",targetColor:A="var(--color-error, #ef4444)",size:R="md",label:w,labelPlacement:p="top",showValue:k=!1,showTarget:z=!1,formatValue:S=$=>String($),state:N="normal",errorMessage:d,className:h,style:x})=>{const $=at[R],g=s??$.width,y=b??$.height,v=$.fontSize,j=4,u=g-j*2,I=z&&c!=null?v+4:j,a=z&&c!=null?y+(I-j):y,_=a-I-j,C=Math.max(0,Math.min(1,(t-i)/(l-i||1))),E=c!=null?Math.max(0,Math.min(1,(c-i)/(l-i||1))):null,U=()=>N==="error"?e.jsx("div",{role:"alert",style:{width:g,height:a,display:"flex",alignItems:"center",justifyContent:"center",border:"1px dashed var(--color-error, #ef4444)",borderRadius:4,color:"var(--color-error, #ef4444)",fontSize:v,padding:"0 8px",boxSizing:"border-box"},children:d??"Error"}):N==="loading"?e.jsx("div",{role:"status","aria-label":"Loading",className:"nice-bullet__skeleton",style:{width:g,height:a,borderRadius:4,background:"linear-gradient(90deg, var(--bg-tertiary, #e5e7eb) 25%, var(--bg-secondary, #f3f4f6) 50%, var(--bg-tertiary, #e5e7eb) 75%)",backgroundSize:"200% 100%",animation:"nice-bullet-shimmer 1.4s linear infinite"}}):e.jsxs("svg",{width:g,height:a,role:"img","aria-label":typeof w=="string"?w:void 0,children:[e.jsx("rect",{x:j,y:I,width:u,height:_,rx:3,fill:"var(--border-color, #e2e8f0)"}),e.jsx("rect",{x:j,y:I+_*.2,width:u*C,height:_*.6,rx:2,fill:f}),E!=null&&e.jsx("line",{x1:j+u*E,y1:I+2,x2:j+u*E,y2:I+_-2,stroke:A,strokeWidth:2}),k&&e.jsx("text",{x:j+Math.max(u*C,4),y:I+_/2,dx:u*C>24?-4:4,textAnchor:u*C>24?"end":"start",dominantBaseline:"middle",fontSize:v,fill:u*C>24?"var(--text-on-primary, #ffffff)":"var(--text-primary)",fontWeight:600,children:S(t)}),z&&E!=null&&e.jsxs("text",{x:j+u*E,y:I-2,textAnchor:"middle",fontSize:v-1,fill:A,fontWeight:600,children:["▼",S(c)]})]});if(p==="none"||!w)return e.jsxs("div",{className:`nice-bullet ${h||""}`,style:x,children:[U(),e.jsx("style",{children:Ie})]});const V=p==="top"||p==="bottom",H=e.jsx("span",{className:"nice-bullet__label",style:{fontSize:v,fontWeight:600,color:"var(--text-primary)",...V?{marginBottom:p==="top"?4:0,marginTop:p==="bottom"?4:0}:{},...p==="left"?{marginRight:8}:{},...p==="right"?{marginLeft:8}:{}},children:w});return e.jsxs("div",{className:`nice-bullet nice-bullet--${p} ${h||""}`,style:{display:"inline-flex",flexDirection:V?"column":"row",alignItems:V?"flex-start":"center",...x},children:[(p==="top"||p==="left")&&H,U(),(p==="bottom"||p==="right")&&H,e.jsx("style",{children:Ie})]})},Ie=`
2
+ @keyframes nice-bullet-shimmer {
3
+ 0% { background-position: 200% 0; }
4
+ 100% { background-position: -200% 0; }
5
+ }
6
+ `,ct=({data:t,width:c=400,height:i=300,inverted:l,showLabels:s=!0,showValues:b=!0,title:f,className:A,style:R})=>{const w={top:f?30:10,bottom:10,x:40},p=c-w.x*2,k=i-w.top-w.bottom,z=l?[...t].reverse():t,S=Math.max(...z.map(d=>d.value),1),N=k/z.length;return e.jsx("div",{className:`nice-funnel ${A||""}`,style:R,children:e.jsxs("svg",{width:c,height:i,children:[f&&e.jsx("text",{x:c/2,y:20,textAnchor:"middle",className:"nice-chart__title",children:f}),z.map((d,h)=>{const x=d.value/S*p,$=h<z.length-1?z[h+1].value/S*p:x*.3,g=w.top+h*N,y=g+N,v=c/2,j=`${v-x/2},${g} ${v+x/2},${g} ${v+$/2},${y} ${v-$/2},${y}`,u=d.color||pe[h%pe.length];return e.jsxs("g",{children:[e.jsx("polygon",{points:j,fill:u,stroke:"var(--bg-primary, #fff)",strokeWidth:1,children:e.jsx("title",{children:`${d.label}: ${d.value}`})}),s&&e.jsx("text",{x:v,y:g+N/2-(b?4:0),textAnchor:"middle",dominantBaseline:"middle",className:"nice-funnel__label",children:d.label}),b&&e.jsx("text",{x:v,y:g+N/2+10,textAnchor:"middle",dominantBaseline:"middle",className:"nice-funnel__value",children:d.value})]},h)})]})})},De=({nodes:t,links:c,width:i=600,height:l=400,nodeWidth:s=20,nodePadding:b=10,title:f,className:A,style:R})=>{const w={top:f?40:20,bottom:20,left:20,right:20},p=i-w.left-w.right,k=l-w.top-w.bottom,z=new Set(c.map(a=>a.source)),S=new Set(c.map(a=>a.target)),N=t.filter(a=>z.has(a.id)&&!S.has(a.id)),d=t.filter(a=>S.has(a.id)),h=t.filter(a=>z.has(a.id)&&S.has(a.id)),x=[N,...h.length?[h]:[],d].filter(a=>a.length>0),$=x.length,g=new Map;t.forEach(a=>{const _=c.filter(E=>E.source===a.id).reduce((E,U)=>E+U.value,0),C=c.filter(E=>E.target===a.id).reduce((E,U)=>E+U.value,0);g.set(a.id,Math.max(_,C))});const y=x.map(a=>a.reduce((_,C)=>_+(g.get(C.id)||0),0)+(a.length-1)*b),v=Math.max(...y,1),j=new Map;x.forEach((a,_)=>{const C=w.left+_/($-1||1)*(p-s);let E=0;a.forEach(U=>{const V=(g.get(U.id)||0)/v*k;j.set(U.id,{x:C,y:w.top+E,h:V}),E+=V+b})});const u=new Map,I=new Map;return t.forEach(a=>{u.set(a.id,0),I.set(a.id,0)}),e.jsx("div",{className:`nice-sankey ${A||""}`,style:R,children:e.jsxs("svg",{width:i,height:l,children:[f&&e.jsx("text",{x:i/2,y:20,textAnchor:"middle",className:"nice-chart__title",children:f}),c.map((a,_)=>{const C=j.get(a.source),E=j.get(a.target);if(!C||!E)return null;const U=u.get(a.source)||0,V=I.get(a.target)||0,H=a.value/v*k;u.set(a.source,U+H),I.set(a.target,V+H);const G=C.x+s,Q=C.y+U,q=E.x,J=E.y+V,r=(G+q)/2,Y=t.find(B=>B.id===a.source)?.color||pe[_%pe.length];return e.jsx("path",{d:`M${G},${Q} C${r},${Q} ${r},${J} ${q},${J} L${q},${J+H} C${r},${J+H} ${r},${Q+H} ${G},${Q+H} Z`,fill:Y,fillOpacity:.3,stroke:Y,strokeOpacity:.5,strokeWidth:.5,children:e.jsx("title",{children:`${a.source} → ${a.target}: ${a.value}`})},_)}),t.map((a,_)=>{const C=j.get(a.id);if(!C)return null;const E=a.color||pe[_%pe.length];return e.jsxs("g",{children:[e.jsx("rect",{x:C.x,y:C.y,width:s,height:Math.max(C.h,2),fill:E,rx:2}),e.jsx("text",{x:C.x<p/2?C.x+s+4:C.x-4,y:C.y+C.h/2,textAnchor:C.x<p/2?"start":"end",dominantBaseline:"middle",className:"nice-chart__legend-text",children:a.label})]},a.id)})]})})},ot=Object.freeze(Object.defineProperty({__proto__:null,NiceSankey:De},Symbol.toStringTag,{value:"Module"})),it=({data:t,min:c,max:i,start:l,end:s,onChange:b,width:f=500,height:A=100,step:R=1,formatValue:w,chartColor:p="var(--color-primary, #3b82f6)",className:k,style:z})=>{const S={top:10,bottom:30,left:10,right:10},N=f-S.left-S.right,d=A-S.top-S.bottom,h=j=>S.left+(j-c)/(i-c||1)*N,x=j=>{const u=Math.max(0,Math.min(1,(j-S.left)/N)),I=c+u*(i-c);return Math.round(I/R)*R},$=(j,u)=>{u.preventDefault();const I=u.target.closest("svg");if(!I)return;const a=C=>{const E=I.getBoundingClientRect(),U=x(C.clientX-E.left);j==="start"?b(Math.min(U,s),s):b(l,Math.max(U,l))},_=()=>{document.removeEventListener("pointermove",a),document.removeEventListener("pointerup",_)};document.addEventListener("pointermove",a),document.addEventListener("pointerup",_)},g=t?Math.min(...t):0,v=(t?Math.max(...t):1)-g||1;return e.jsx("div",{className:`nice-rangeselector ${k||""}`,style:z,children:e.jsxs("svg",{width:f,height:A,children:[t&&t.length>1&&e.jsx("polygon",{points:`${S.left},${S.top+d} ${t.map((j,u)=>`${S.left+u/(t.length-1)*N},${S.top+d-(j-g)/v*d}`).join(" ")} ${S.left+N},${S.top+d}`,fill:p,opacity:.15}),e.jsx("rect",{x:h(l),y:S.top,width:h(s)-h(l),height:d,fill:p,opacity:.1}),e.jsx("rect",{x:S.left,y:S.top,width:h(l)-S.left,height:d,fill:"var(--bg-secondary, #f5f5f5)",opacity:.6}),e.jsx("rect",{x:h(s),y:S.top,width:S.left+N-h(s),height:d,fill:"var(--bg-secondary, #f5f5f5)",opacity:.6}),e.jsx("rect",{x:h(l)-4,y:S.top,width:8,height:d,fill:p,rx:2,cursor:"ew-resize",onPointerDown:j=>$("start",j)}),e.jsx("rect",{x:h(s)-4,y:S.top,width:8,height:d,fill:p,rx:2,cursor:"ew-resize",onPointerDown:j=>$("end",j)}),e.jsx("text",{x:h(l),y:S.top+d+18,textAnchor:"middle",className:"nice-chart__axis-label",children:w?w(l):l}),e.jsx("text",{x:h(s),y:S.top+d+18,textAnchor:"middle",className:"nice-chart__axis-label",children:w?w(s):s})]})})},Te=({regions:t,width:c=600,height:i=400,viewBox:l="0 0 1000 600",colorRange:s=["var(--info-bg, #dbeafe)","var(--color-primary-active, #1d4ed8)"],maxValue:b,onRegionClick:f,selectedRegionId:A,title:R,showTooltip:w=!0,className:p,style:k})=>{const z=b??Math.max(...t.map(N=>N.value??0),1),S=N=>{const d=a=>[parseInt(a.slice(1,3),16),parseInt(a.slice(3,5),16),parseInt(a.slice(5,7),16)],[h,x,$]=d(s[0]),[g,y,v]=d(s[1]),j=Math.round(h+(g-h)*N),u=Math.round(x+(y-x)*N),I=Math.round($+(v-$)*N);return`rgb(${j},${u},${I})`};return e.jsxs("div",{className:`nice-vectormap ${p||""}`,style:k,children:[R&&e.jsx("div",{className:"nice-vectormap__title",children:R}),e.jsx("svg",{width:c,height:i,viewBox:l,children:t.map(N=>{const d=N.value!=null?Math.max(0,Math.min(1,N.value/z)):0,h=N.value!=null?S(d):"var(--bg-tertiary, #e5e7eb)",x=N.id===A;return e.jsx("path",{d:N.path,fill:h,stroke:x?"var(--color-primary, #3b82f6)":"var(--border-color, #d1d5db)",strokeWidth:x?2:.5,cursor:f?"pointer":void 0,onClick:()=>f?.(N),children:w&&e.jsx("title",{children:`${N.name}${N.value!=null?`: ${N.value}`:""}`})},N.id)})})]})},lt=Object.freeze(Object.defineProperty({__proto__:null,NiceVectorMap:Te},Symbol.toStringTag,{value:"Module"})),dt=`
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
+ `,Le=["var(--color-primary, #3b82f6)","var(--color-success, #10b981)","var(--color-warning, #f59e0b)","var(--color-error, #ef4444)","var(--color-accent, #8b5cf6)","var(--color-accent-pink, #ec4899)","var(--color-info, #06b6d4)","var(--nice-warning, #f97316)"];function fe(t){return t instanceof Date?t:new Date(t)}function Ce(t,c="pl-PL"){return t.toLocaleDateString(c,{year:"numeric",month:"short",day:"numeric"})}function Me(t,c="pl-PL"){return new Intl.NumberFormat(c,{minimumFractionDigits:0,maximumFractionDigits:2}).format(t)}const ht=o.forwardRef(function(c,i){const{scenarios:l,data:s,annotations:b=[],referenceLines:f=[],forecastStartDate:A,cashRunway:R,xAxis:w,yAxis:p,confidenceBands:k=[{level:95,color:"var(--color-primary, #3b82f6)",opacity:.15}],tooltip:z,legend:S={enabled:!0,position:"bottom",interactive:!0},height:N=350,showForecastRegion:d=!0,lineWidth:h=2,showPoints:x=!1,pointRadius:$=4,enableZoom:g=!1,zoomEnabled:y,animationDuration:v=300,showLegend:j,responsive:u=!0,onPointClick:I,onAnnotationClick:a,onScenarioToggle:_,onViewportChange:C,size:E="medium",disabled:U=!1,labels:V={},locale:H="pl-PL",className:G,style:Q}=c,q=l&&l.length>0?l:s?[{id:"default",name:"Series",data:s}]:[],J={...S,enabled:j??S.enabled},[r,X]=o.useState(()=>q.map((n,T)=>({...n,color:n.color??Le[T%Le.length],visible:n.visible!==!1}))),[Y,B]=o.useState(null),[m,P]=o.useState({x:0,y:0}),F=o.useRef(null),ee=o.useRef(null),O={top:20,right:30,bottom:40,left:60},[te,xe]=o.useState({width:600,height:typeof N=="number"?N:350});o.useEffect(()=>{if(!u||!F.current)return;const n=new ResizeObserver(T=>{for(const W of T)xe(M=>({width:W.contentRect.width,height:M.height}))});return n.observe(F.current),()=>n.disconnect()},[u]),o.useEffect(()=>{const n="nice-forecast-chart-styles";if(!document.getElementById(n)){const T=document.createElement("style");T.id=n,T.textContent=dt,document.head.appendChild(T)}},[]);const{xScale:L,yScale:Z,allDates:re,minY:de,maxY:ye}=o.useMemo(()=>{const T=r.filter(he=>he.visible!==!1).flatMap(he=>he.data);if(T.length===0)return{xScale:()=>0,yScale:()=>0,allDates:[],minY:0,maxY:100};const W=T.map(he=>fe(he.date).getTime()),M=Math.min(...W),K=Math.max(...W),se=T.flatMap(he=>[he.value,he.forecast,he.lowerBound,he.upperBound]).filter(he=>he!=null),oe=p?.min??Math.min(...se)*.95,le=p?.max??Math.max(...se)*1.05,ve=te.width-O.left-O.right,je=te.height-O.top-O.bottom,Ne=he=>{const Se=typeof he=="number"?he:he.getTime();return O.left+(Se-M)/(K-M)*ve},$e=he=>O.top+je-(he-oe)/(le-oe)*je,He=[...new Set(W)].sort((he,Se)=>he-Se).map(he=>new Date(he));return{xScale:Ne,yScale:$e,allDates:He,minY:oe,maxY:le}},[r,te,O,p]),me=A?fe(A):null,ge=o.useMemo(()=>{if(!R?.enabled)return null;const n=R.threshold??0,T=R.scenarioId?r.find(M=>M.id===R.scenarioId&&M.visible!==!1):r.find(M=>M.visible!==!1);if(!T)return null;const W=T.data.sort((M,K)=>fe(M.date).getTime()-fe(K.date).getTime());for(let M=1;M<W.length;M++){const K=W[M-1],se=W[M],oe=K.forecast??K.value,le=se.forecast??se.value;if(oe!=null&&le!=null&&oe>n&&le<=n){const ve=(oe-n)/(oe-le),je=fe(K.date).getTime(),Ne=fe(se.date).getTime(),$e=je+ve*(Ne-je);return new Date($e)}}return null},[R,r]),be=o.useCallback((n,T)=>{const W=n.filter(M=>M[T]!=null).map(M=>({x:L(fe(M.date)),y:Z(M[T])}));return W.length===0?"":`M ${W.map(M=>`${M.x},${M.y}`).join(" L ")}`},[L,Z]),we=o.useCallback(n=>{const T=n.filter(K=>K.lowerBound!=null&&K.upperBound!=null);if(T.length===0)return"";const W=T.map(K=>({x:L(fe(K.date)),y:Z(K.upperBound)})),M=T.map(K=>({x:L(fe(K.date)),y:Z(K.lowerBound)})).reverse();return`M ${W.map(K=>`${K.x},${K.y}`).join(" L ")} L ${M.map(K=>`${K.x},${K.y}`).join(" L ")} Z`},[L,Z]),D=o.useCallback(n=>{if(!ee.current||z?.enabled===!1)return;const T=ee.current.getBoundingClientRect(),W=n.clientX-T.left;n.clientY-T.top;let M=null,K=1/0;for(const se of re){const oe=L(se),le=Math.abs(oe-W);le<K&&(K=le,M=se)}if(M&&K<50){const se=r.filter(le=>le.visible!==!1).map(le=>{const ve=le.data.find(je=>fe(je.date).getTime()===M.getTime());return{scenario:le,value:ve?.value,forecast:ve?.forecast,lowerBound:ve?.lowerBound,upperBound:ve?.upperBound}}),oe=b.filter(le=>Math.abs(fe(le.date).getTime()-M.getTime())<864e5);B({date:M,values:se,annotations:oe}),P({x:n.clientX-T.left+10,y:n.clientY-T.top-10})}else B(null)},[L,re,r,b,z]),ne=o.useCallback(n=>{if(!J.interactive)return;X(W=>W.map(M=>M.id===n?{...M,visible:!M.visible}:M));const T=r.find(W=>W.id===n);T&&_?.(n,!T.visible)},[J.interactive,r,_]);o.useImperativeHandle(i,()=>({getScenarios:()=>r,updateScenario:(n,T)=>{X(W=>W.map(M=>M.id===n?{...M,data:T}:M))},toggleScenario:ne,setZoomRange:()=>{},resetZoom:()=>{},exportImage:n=>{if(!ee.current)return null;const T=ee.current,M=new XMLSerializer().serializeToString(T);return`data:image/svg+xml;base64,${btoa(M)}`},getDataAtDate:n=>{const T=r.filter(W=>W.visible!==!1).map(W=>{const M=W.data.find(K=>fe(K.date).getTime()===n.getTime());return{scenario:W,value:M?.value,forecast:M?.forecast,lowerBound:M?.lowerBound,upperBound:M?.upperBound}});return{date:n,values:T,annotations:b.filter(W=>fe(W.date).getTime()===n.getTime())}}}),[r,b,ne]),te.width-O.left-O.right;const ae=te.height-O.top-O.bottom,ce=o.useMemo(()=>{const n=p?.tickCount??5,T=[],W=(ye-de)/(n-1);for(let M=0;M<n;M++)T.push(de+W*M);return T},[de,ye,p?.tickCount]),ie=o.useMemo(()=>{const n=w?.tickCount??6;if(re.length===0)return[];const T=Math.max(1,Math.floor(re.length/(n-1)));return re.filter((W,M)=>M%T===0||M===re.length-1)},[re,w?.tickCount]);return r.length===0||r.every(n=>n.data.length===0)?e.jsx("div",{className:`nice-forecast-chart ${G??""}`,style:Q,children:e.jsx("div",{className:"nice-forecast-chart__empty",children:V.noData??"No data available"})}):e.jsxs("div",{className:`nice-forecast-chart ${G??""}`,style:{...Q,height:N},children:[e.jsxs("div",{ref:F,className:"nice-forecast-chart__container",children:[e.jsxs("svg",{ref:ee,className:"nice-forecast-chart__svg",width:te.width,height:te.height,onMouseMove:D,onMouseLeave:()=>B(null),children:[p?.showGrid!==!1&&ce.map(n=>e.jsx("line",{className:"nice-forecast-chart__grid-line",x1:O.left,x2:te.width-O.right,y1:Z(n),y2:Z(n)},n)),d&&me&&e.jsx("rect",{className:"nice-forecast-chart__forecast-region",x:L(me),y:O.top,width:te.width-O.right-L(me),height:ae}),f.map(n=>e.jsxs("g",{children:[e.jsx("line",{className:"nice-forecast-chart__reference-line",x1:O.left,x2:te.width-O.right,y1:Z(n.value),y2:Z(n.value),stroke:n.color??"var(--text-muted, #9ca3af)",strokeDasharray:n.dashArray??"4,2"}),n.label&&e.jsx("text",{className:"nice-forecast-chart__reference-label",x:te.width-O.right-4,y:Z(n.value)-4,textAnchor:"end",children:n.label})]},n.id)),ge&&R?.enabled&&e.jsxs("g",{className:"nice-forecast-chart__cash-runway",children:[e.jsx("line",{className:"nice-forecast-chart__cash-runway-line",x1:L(ge),x2:L(ge),y1:O.top,y2:te.height-O.bottom,stroke:R.color??"var(--color-error, #ef4444)"}),R.showLabel!==!1&&e.jsxs(e.Fragment,{children:[e.jsx("rect",{className:"nice-forecast-chart__cash-runway-label-bg",x:L(ge)-60,y:O.top-2,width:120,height:R.showDate!==!1?32:20,fill:R.color??"var(--color-error, #ef4444)",rx:4}),e.jsx("text",{className:"nice-forecast-chart__cash-runway-label",x:L(ge),y:O.top+12,textAnchor:"middle",fill:"var(--nice-bg, #fff)",children:R.label??V.cashRunsOut??"Cash runs out"}),R.showDate!==!1&&e.jsx("text",{className:"nice-forecast-chart__cash-runway-label",x:L(ge),y:O.top+26,textAnchor:"middle",fill:"var(--nice-bg, #fff)",style:{fontSize:"0.625rem",opacity:.9},children:Ce(ge,H)})]})]}),r.filter(n=>n.visible!==!1&&n.showConfidenceBand).map(n=>e.jsx("path",{className:"nice-forecast-chart__confidence-band",d:we(n.data),fill:n.color},`band-${n.id}`)),r.filter(n=>n.visible!==!1).map(n=>{const T=me?n.data.filter(M=>fe(M.date)<me):n.data.filter(M=>M.value!=null),W=me?n.data.filter(M=>fe(M.date)>=me):n.data.filter(M=>M.forecast!=null);return e.jsxs("g",{children:[e.jsx("path",{className:"nice-forecast-chart__historical-line",d:be(T,"value"),stroke:n.color,strokeWidth:h}),e.jsx("path",{className:"nice-forecast-chart__forecast-line",d:be(W,me?"value":"forecast"),stroke:n.color,strokeWidth:h}),W.length>0&&n.data.some(M=>M.forecast!=null)&&e.jsx("path",{className:"nice-forecast-chart__forecast-line",d:be(n.data,"forecast"),stroke:n.color,strokeWidth:h}),x&&n.data.map((M,K)=>{const se=M.value??M.forecast;return se==null?null:e.jsx("circle",{className:"nice-forecast-chart__point",cx:L(fe(M.date)),cy:Z(se),r:$,fill:n.color,onClick:()=>I?.(M,n)},K)})]},n.id)}),b.map(n=>{const T=L(fe(n.date));return e.jsxs("g",{className:"nice-forecast-chart__annotation-marker",onClick:()=>a?.(n),children:[n.showLine!==!1&&e.jsx("line",{className:"nice-forecast-chart__annotation-line",x1:T,x2:T,y1:O.top,y2:te.height-O.bottom,stroke:n.color??"var(--text-muted, #9ca3af)"}),e.jsx("circle",{cx:T,cy:O.top+10,r:8,fill:n.color??"var(--text-muted, #9ca3af)"}),e.jsx("text",{x:T,y:O.top+14,textAnchor:"middle",fill:"white",fontSize:"10",children:n.icon??"!"})]},n.id)}),e.jsx("line",{className:"nice-forecast-chart__axis-line",x1:O.left,x2:O.left,y1:O.top,y2:te.height-O.bottom}),e.jsx("line",{className:"nice-forecast-chart__axis-line",x1:O.left,x2:te.width-O.right,y1:te.height-O.bottom,y2:te.height-O.bottom}),ce.map(n=>e.jsx("text",{className:"nice-forecast-chart__axis-label",x:O.left-8,y:Z(n)+4,textAnchor:"end",children:p?.format?p.format(n):Me(n,H)},n)),ie.map(n=>e.jsx("text",{className:"nice-forecast-chart__axis-label",x:L(n),y:te.height-O.bottom+16,textAnchor:"middle",children:w?.format?w.format(n):Ce(n,H)},n.getTime())),p?.title&&e.jsx("text",{className:"nice-forecast-chart__axis-title",x:15,y:te.height/2,textAnchor:"middle",transform:`rotate(-90, 15, ${te.height/2})`,children:p.title})]}),Y&&e.jsxs("div",{className:"nice-forecast-chart__tooltip",style:{left:m.x,top:m.y},children:[e.jsx("div",{className:"nice-forecast-chart__tooltip-date",children:Ce(Y.date,H)}),Y.values.map(n=>{const T=n.value??n.forecast;return T==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:Me(T,H)})]},n.scenario.id)}),Y.values.some(n=>n.lowerBound!=null)&&e.jsxs("div",{className:"nice-forecast-chart__tooltip-confidence",children:[V.confidence??"CI",":"," ",Me(Y.values[0]?.lowerBound??0,H)," –"," ",Me(Y.values[0]?.upperBound??0,H)]})]})]}),J.enabled&&e.jsx("div",{className:"nice-forecast-chart__legend",children:r.map(n=>e.jsxs("div",{className:`nice-forecast-chart__legend-item ${n.visible===!1?"nice-forecast-chart__legend-item--hidden":""}`,onClick:()=>ne(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))})]})}),Be=["var(--color-primary, #3b82f6)","var(--color-error, #ef4444)","var(--color-success, #22c55e)","var(--color-warning, #f59e0b)","var(--color-accent, #8b5cf6)","var(--color-accent-pink, #ec4899)","var(--color-info, #06b6d4)","var(--color-success, #10b981)","var(--color-warning, #f59e0b)","var(--color-accent, #6366f1)"],We=o.forwardRef((t,c)=>{const{levels:i,initialLevelId:l,chartType:s="bar",width:b=600,height:f=400,showBreadcrumbs:A=!0,showBackButton:R=!0,animationDuration:w=300,onLevelChange:p,onItemClick:k,colors:z=Be,showValues:S=!0,showLegend:N=!0,className:d,style:h,...x}=t,[$,g]=o.useState(l||i[0]?.id),[y,v]=o.useState([l||i[0]?.id]),[j,u]=o.useState(!1),[I,a]=o.useState("in"),_=o.useMemo(()=>i.find(r=>r.id===$),[i,$]),C=o.useCallback(r=>{i.find(Y=>Y.id===r)&&(a("in"),u(!0),setTimeout(()=>{g(r),v(Y=>[...Y,r]),p?.(r,[...y,r]),u(!1)},w/2))},[i,y,w,p]),E=o.useCallback(()=>{if(y.length<=1)return;a("out"),u(!0);const r=y.slice(0,-1),X=r[r.length-1];setTimeout(()=>{g(X),v(r),p?.(X,r),u(!1)},w/2)},[y,w,p]),U=o.useCallback(()=>{const r=i[0]?.id;r&&(a("out"),u(!0),setTimeout(()=>{g(r),v([r]),p?.(r,[r]),u(!1)},w/2))},[i,w,p]);o.useImperativeHandle(c,()=>({drillDown:C,drillUp:E,resetToRoot:U,getCurrentLevel:()=>$,getPath:()=>y}),[C,E,U,$,y]);const V=o.useCallback((r,X)=>{k?.(r,$);const Y=i.find(B=>B.parentId===$&&B.id===r.metadata?.childLevelId);Y&&C(Y.id)},[$,i,C,k]),H=o.useMemo(()=>_?.data.reduce((r,X)=>r+X.value,0)||0,[_]),G=o.useMemo(()=>y.map(r=>i.find(X=>X.id===r)?.label||r),[y,i]),Q=()=>{if(!_)return null;const r=_.data,X=Math.max(...r.map(B=>B.value)),Y=Math.min(40,(f-100)/r.length-8);return e.jsx("div",{className:"nice-drilldown-bars",children:r.map((B,m)=>{const P=B.value/X*100;return e.jsxs("div",{className:"nice-drilldown-bar-row",onClick:()=>V(B,m),children:[e.jsx("span",{className:"nice-drilldown-bar-label",children:B.label||`Item ${m+1}`}),e.jsx("div",{className:"nice-drilldown-bar-track",children:e.jsx("div",{className:"nice-drilldown-bar-fill",style:{width:`${P}%`,backgroundColor:B.color||z[m%z.length],height:Y}})}),S&&e.jsx("span",{className:"nice-drilldown-bar-value",children:B.value.toLocaleString()})]},m)})})},q=()=>{if(!_)return null;const r=_.data,X=b/2,Y=(f-60)/2+30,B=Math.min(X,Y)-40;let m=-90;const P=r.map((F,ee)=>{const O=F.value/H*360,te=m+O,xe=O>180?1:0,L=m*Math.PI/180,Z=te*Math.PI/180,re=X+B*Math.cos(L),de=Y+B*Math.sin(L),ye=X+B*Math.cos(Z),me=Y+B*Math.sin(Z),ge=(m+O/2)*Math.PI/180,be=X+B*.7*Math.cos(ge),we=Y+B*.7*Math.sin(ge),D=`M ${X} ${Y} L ${re} ${de} A ${B} ${B} 0 ${xe} 1 ${ye} ${me} Z`;return m=te,{path:D,color:F.color||z[ee%z.length],label:F.label||`Item ${ee+1}`,value:F.value,percentage:(F.value/H*100).toFixed(1),labelX:be,labelY:we,item:F,index:ee}});return e.jsx("svg",{width:b,height:f-40,className:"nice-drilldown-pie",children:e.jsx("g",{children:P.map((F,ee)=>e.jsxs("g",{onClick:()=>V(F.item,F.index),children:[e.jsx("path",{d:F.path,fill:F.color,stroke:"white",strokeWidth:2,className:"nice-drilldown-pie-slice"}),S&&parseFloat(F.percentage)>5&&e.jsxs("text",{x:F.labelX,y:F.labelY,textAnchor:"middle",dominantBaseline:"middle",fill:"white",fontSize:"12",fontWeight:"600",children:[F.percentage,"%"]})]},ee))})})},J=()=>{if(!_)return null;const r=_.data,X=Math.max(...r.map(m=>m.value)),Y=Math.min(60,(b-100)/r.length-8),B=f-100;return e.jsx("svg",{width:b,height:f-40,className:"nice-drilldown-columns",children:e.jsxs("g",{transform:"translate(50, 20)",children:[[0,.25,.5,.75,1].map((m,P)=>e.jsxs("g",{children:[e.jsx("line",{x1:0,y1:B*(1-m),x2:b-80,y2:B*(1-m),stroke:"var(--border-color, #e5e7eb)",strokeDasharray:m===0?void 0:"4"}),e.jsx("text",{x:-8,y:B*(1-m),textAnchor:"end",dominantBaseline:"middle",fontSize:"11",fill:"var(--text-secondary, #6b7280)",children:Math.round(X*m).toLocaleString()})]},P)),r.map((m,P)=>{const F=m.value/X*B,ee=P*((b-100)/r.length)+((b-100)/r.length-Y)/2;return e.jsxs("g",{onClick:()=>V(m,P),children:[e.jsx("rect",{x:ee,y:B-F,width:Y,height:F,fill:m.color||z[P%z.length],rx:4,className:"nice-drilldown-column-bar"}),e.jsx("text",{x:ee+Y/2,y:B+16,textAnchor:"middle",fontSize:"11",fill:"var(--text-primary, #374151)",children:(m.label||`${P+1}`).slice(0,10)}),S&&e.jsx("text",{x:ee+Y/2,y:B-F-8,textAnchor:"middle",fontSize:"11",fill:"var(--text-primary, #374151)",fontWeight:"500",children:m.value.toLocaleString()})]},P)})]})})};return e.jsxs("div",{className:`nice-drilldown-chart ${j?`animating ${I}`:""} ${d||""}`,style:{width:b,...h},...x,children:[e.jsxs("div",{className:"nice-drilldown-header",children:[R&&y.length>1&&e.jsxs("button",{className:"nice-drilldown-back",onClick:E,children:[e.jsx(ue.oa,{name:"arrow-left",size:14})," Wstecz"]}),A&&e.jsx("div",{className:"nice-drilldown-breadcrumbs",children:G.map((r,X)=>e.jsxs(o.Fragment,{children:[X>0&&e.jsx("span",{className:"nice-drilldown-separator",children:"/"}),e.jsx("span",{className:`nice-drilldown-crumb ${X===G.length-1?"active":""}`,onClick:()=>{if(X<G.length-1){const Y=y.slice(0,X+1);v(Y),g(Y[Y.length-1])}},children:r})]},X))})]}),e.jsxs("div",{className:"nice-drilldown-content",style:{height:f-40},children:[s==="bar"&&Q(),s==="pie"&&q(),s==="column"&&J()]}),N&&_&&e.jsx("div",{className:"nice-drilldown-legend",children:_.data.map((r,X)=>e.jsxs("div",{className:"nice-drilldown-legend-item",children:[e.jsx("span",{className:"nice-drilldown-legend-color",style:{backgroundColor:r.color||z[X%z.length]}}),e.jsx("span",{className:"nice-drilldown-legend-label",children:r.label||`Item ${X+1}`})]},X))}),e.jsx("style",{children:`
293
+ .nice-drilldown-chart {
294
+ font-family: inherit;
295
+ color: var(--text-primary, #111827);
296
+ background: var(--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(--border-color, #e5e7eb);
307
+ min-height: 40px;
308
+ }
309
+
310
+ .nice-drilldown-back {
311
+ background: var(--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(--text-primary, #374151);
319
+ transition: background 0.2s;
320
+ }
321
+
322
+ .nice-drilldown-back:hover {
323
+ background: var(--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(--text-muted, #9ca3af);
336
+ }
337
+
338
+ .nice-drilldown-crumb {
339
+ color: var(--text-secondary, #6b7280);
340
+ cursor: pointer;
341
+ }
342
+
343
+ .nice-drilldown-crumb:hover:not(.active) {
344
+ color: var(--color-primary, #3b82f6);
345
+ }
346
+
347
+ .nice-drilldown-crumb.active {
348
+ color: var(--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(--hover-bg, #f9fafb);
389
+ }
390
+
391
+ .nice-drilldown-bar-label {
392
+ width: 120px;
393
+ font-size: 13px;
394
+ font-family: inherit;
395
+ color: var(--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(--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(--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(--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(--text-secondary, #6b7280);
466
+ }
467
+ `})]})});We.displayName="NiceDrillDownChart";const ut=({type:t="choropleth",regions:c=[],bubbles:i=[],width:l=800,height:s=500,viewBox:b="0 0 800 500",colorScale:f=["var(--info-bg, #dbeafe)","var(--color-primary-light, #93c5fd)","var(--color-primary, #3b82f6)","var(--color-primary-active, #1d4ed8)","var(--color-primary, #6366f1)"],minValue:A,maxValue:R,showTooltip:w=!0,showLegend:p=!0,onRegionClick:k,onBubbleClick:z,onRegionHover:S,title:N,mapSvg:d,zoomable:h=!1,className:x,style:$,...g})=>{const[y,v]=o.useState(null),[j,u]=o.useState(1),[I,a]=o.useState({x:0,y:0}),_=o.useRef(null),C=o.useRef(!1),E=o.useRef({x:0,y:0}),U=A??Math.min(...c.map(m=>m.value),...i.map(m=>m.value)),V=R??Math.max(...c.map(m=>m.value),...i.map(m=>m.value)),H=o.useCallback(m=>{const P=(m-U)/(V-U),F=Math.min(Math.floor(P*f.length),f.length-1);return f[Math.max(0,F)]},[U,V,f]),G=o.useCallback(m=>{if(!w||!y)return;const P=_.current?.getBoundingClientRect();P&&v(F=>F?{...F,x:m.clientX-P.left,y:m.clientY-P.top}:null)},[w,y]),Q=o.useCallback((m,P)=>{const F=_.current?.getBoundingClientRect();F&&w&&v({x:P.clientX-F.left,y:P.clientY-F.top,content:`${m.name}: ${m.value.toLocaleString()}`}),S?.(m)},[w,S]),q=o.useCallback(()=>{v(null),S?.(null)},[S]),J=o.useCallback(m=>{if(!h)return;m.preventDefault();const P=m.deltaY>0?.9:1.1;u(F=>Math.min(Math.max(F*P,.5),4))},[h]),r=o.useCallback(m=>{h&&(C.current=!0,E.current={x:m.clientX-I.x,y:m.clientY-I.y})},[h,I]),X=o.useCallback(()=>{C.current=!1},[]),Y=o.useCallback(m=>{C.current&&a({x:m.clientX-E.current.x,y:m.clientY-E.current.y})},[]),B=o.useMemo(()=>c.length>0?c:[{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"}],[c]);return e.jsxs("div",{className:`nice-map-chart ${x||""}`,style:{width:l,...$},...g,children:[N&&e.jsx("div",{className:"nice-map-title",children:N}),e.jsx("svg",{ref:_,width:l,height:s,viewBox:b,className:"nice-map-svg",onWheel:J,onMouseDown:r,onMouseUp:X,onMouseLeave:X,onMouseMove:m=>{G(m),Y(m)},children:e.jsxs("g",{transform:`translate(${I.x}, ${I.y}) scale(${j})`,children:[d&&e.jsx("g",{dangerouslySetInnerHTML:{__html:d}}),t==="choropleth"&&B.map(m=>e.jsx("path",{d:m.path,fill:m.color||H(m.value),stroke:"var(--bg-primary, #ffffff)",strokeWidth:1,className:"nice-map-region",onClick:()=>k?.(m),onMouseEnter:P=>Q(m,P),onMouseLeave:q},m.id)),(t==="bubble"||i.length>0)&&i.map(m=>{const P=Math.sqrt((m.value-U)/(V-U))*30+5;return e.jsx("circle",{cx:m.lng,cy:m.lat,r:P,fill:m.color||"var(--color-primary, #3b82f6)",fillOpacity:.7,stroke:"var(--bg-primary, #ffffff)",strokeWidth:1,className:"nice-map-bubble",onClick:()=>z?.(m),onMouseEnter:F=>{const ee=_.current?.getBoundingClientRect();ee&&w&&v({x:F.clientX-ee.left,y:F.clientY-ee.top,content:`${m.label||m.id}: ${m.value.toLocaleString()}`})},onMouseLeave:q,children:m.label&&e.jsxs("title",{children:[m.label,": ",m.value]})},m.id)})]})}),y&&e.jsx("div",{className:"nice-map-tooltip",style:{left:y.x+10,top:y.y-30},children:y.content}),p&&e.jsxs("div",{className:"nice-map-legend",children:[e.jsx("span",{className:"nice-map-legend-title",children:"Wartość"}),e.jsx("div",{className:"nice-map-legend-scale",children:f.map((m,P)=>e.jsx("div",{className:"nice-map-legend-item",style:{backgroundColor:m}},P))}),e.jsxs("div",{className:"nice-map-legend-labels",children:[e.jsx("span",{children:U.toLocaleString()}),e.jsx("span",{children:V.toLocaleString()})]})]}),e.jsx("style",{children:`
468
+ .nice-map-chart {
469
+ font-family: system-ui, -apple-system, sans-serif;
470
+ background: white;
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(--text-primary, #0f172a);
481
+ border-bottom: 1px solid var(--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
+ background: var(--text-primary, #0f172a);
516
+ color: white;
517
+ padding: var(--nice-space-1-5, 6px) var(--nice-space-2-5, 10px);
518
+ border-radius: var(--nice-radius-sm, 4px);
519
+ font-size: 12px;
520
+ pointer-events: none;
521
+ z-index: 10;
522
+ white-space: nowrap;
523
+ }
524
+
525
+ .nice-map-legend {
526
+ position: absolute;
527
+ right: 16px;
528
+ bottom: 16px;
529
+ background: white;
530
+ padding: var(--nice-space-3, 12px);
531
+ border-radius: var(--nice-radius-md, 6px);
532
+ box-shadow: 0 2px 8px var(--nice-overlay-10, color-mix(in srgb, var(--text-primary, #000) 10%, transparent));
533
+ }
534
+
535
+ .nice-map-legend-title {
536
+ display: block;
537
+ font-size: 11px;
538
+ color: var(--text-secondary, #475569);
539
+ margin-bottom: var(--nice-space-1-5, 6px);
540
+ }
541
+
542
+ .nice-map-legend-scale {
543
+ display: flex;
544
+ height: 12px;
545
+ border-radius: var(--nice-radius-sm, 2px);
546
+ overflow: hidden;
547
+ }
548
+
549
+ .nice-map-legend-item {
550
+ flex: 1;
551
+ min-width: 24px;
552
+ }
553
+
554
+ .nice-map-legend-labels {
555
+ display: flex;
556
+ justify-content: space-between;
557
+ font-size: 10px;
558
+ color: var(--text-secondary, #475569);
559
+ margin-top: var(--nice-space-1, 4px);
560
+ }
561
+ `})]})},xt=({nodes:t,links:c,width:i=800,height:l=500,nodeWidth:s=20,nodePadding:b=10,showValues:f=!0,showTooltip:A=!0,onNodeClick:R,onLinkClick:w,title:p,className:k,style:z,...S})=>{const[N,d]=o.useState(null),h=o.useRef(null),x=o.useMemo(()=>{const g=new Map;t.forEach(r=>g.set(r.id,r));const y=new Set(c.map(r=>r.target)),v=new Set(c.map(r=>r.source)),j=[],u=new Map,I=t.filter(r=>v.has(r.id)&&!y.has(r.id));I.length>0&&(j.push(I.map(r=>r.id)),I.forEach(r=>u.set(r.id,0)));const a=t.filter(r=>v.has(r.id)&&y.has(r.id));a.length>0&&(j.push(a.map(r=>r.id)),a.forEach(r=>u.set(r.id,1)));const _=t.filter(r=>!v.has(r.id)&&y.has(r.id));_.length>0&&(j.push(_.map(r=>r.id)),_.forEach(r=>u.set(r.id,2))),j.length===0&&(j.push(t.map(r=>r.id)),t.forEach(r=>u.set(r.id,0)));const C=new Map;c.forEach(r=>{C.set(r.source,(C.get(r.source)||0)+r.value),C.set(r.target,(C.get(r.target)||0)+r.value)});const E=40,U=i-E*2,V=l-E*2,H=j.length>1?U/(j.length-1):U,G=new Map;Math.max(...Array.from(C.values())),j.forEach((r,X)=>{const Y=r.reduce((P,F)=>P+(C.get(F)||0),0),B=(V-(r.length-1)*b)/Y;let m=E;r.forEach(P=>{const ee=(C.get(P)||0)*B,O=E+X*H;G.set(P,{x:O,y:m,height:ee}),m+=ee+b})});const Q=[],q=new Map,J=new Map;return c.forEach(r=>{const X=G.get(r.source),Y=G.get(r.target);if(!X||!Y)return;const B=C.get(r.source)||1;C.get(r.target);const m=r.value/B*X.height,P=X.y+(q.get(r.source)||0),F=Y.y+(J.get(r.target)||0);q.set(r.source,(q.get(r.source)||0)+m),J.set(r.target,(J.get(r.target)||0)+m);const ee=X.x+s,O=Y.x,te=(O-ee)*.5,xe=`
562
+ M ${ee} ${P}
563
+ C ${ee+te} ${P},
564
+ ${O-te} ${F},
565
+ ${O} ${F}
566
+ L ${O} ${F+m}
567
+ C ${O-te} ${F+m},
568
+ ${ee+te} ${P+m},
569
+ ${ee} ${P+m}
570
+ Z
571
+ `;Q.push({path:xe,link:r,sourcePos:X,targetPos:Y})}),{nodePositions:G,linkPaths:Q,nodeMap:g,nodeValues:C}},[t,c,i,l,s,b]),$=o.useCallback((g,y)=>{const v=h.current?.getBoundingClientRect();v&&A&&d({x:y.clientX-v.left,y:y.clientY-v.top,content:g})},[A]);return e.jsxs("div",{className:`nice-sankey-chart ${k||""}`,style:{width:i,...z},...S,children:[p&&e.jsx("div",{className:"nice-sankey-title",children:p}),e.jsxs("svg",{ref:h,width:i,height:l,className:"nice-sankey-svg",children:[e.jsx("defs",{children:x.linkPaths.map((g,y)=>e.jsxs("linearGradient",{id:`sankey-gradient-${y}`,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:[e.jsx("stop",{offset:"0%",stopColor:x.nodeMap.get(g.link.source)?.color||"var(--color-primary, #3b82f6)"}),e.jsx("stop",{offset:"100%",stopColor:x.nodeMap.get(g.link.target)?.color||"var(--color-error, #ef4444)"})]},y))}),e.jsx("g",{className:"nice-sankey-links",children:x.linkPaths.map((g,y)=>e.jsx("path",{d:g.path,fill:g.link.color||`url(#sankey-gradient-${y})`,fillOpacity:.4,className:"nice-sankey-link",onClick:()=>w?.(g.link),onMouseEnter:v=>$(`${x.nodeMap.get(g.link.source)?.name} → ${x.nodeMap.get(g.link.target)?.name}: ${g.link.value.toLocaleString()}`,v),onMouseLeave:()=>d(null)},y))}),e.jsx("g",{className:"nice-sankey-nodes",children:Array.from(x.nodePositions.entries()).map(([g,y])=>{const v=x.nodeMap.get(g);return v?e.jsxs("g",{children:[e.jsx("rect",{x:y.x,y:y.y,width:s,height:y.height,fill:v.color||"var(--color-primary, #3b82f6)",rx:2,className:"nice-sankey-node",onClick:()=>R?.(v),onMouseEnter:j=>$(`${v.label??v.name??v.id}: ${x.nodeValues.get(g)?.toLocaleString()||0}`,j),onMouseLeave:()=>d(null)}),e.jsxs("text",{x:y.x+s+6,y:y.y+y.height/2,dominantBaseline:"middle",fontSize:"12",fill:"var(--text-primary, #0f172a)",children:[v.label??v.name??v.id,f&&` (${x.nodeValues.get(g)?.toLocaleString()||0})`]})]},g):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:`
572
+ .nice-sankey-chart {
573
+ font-family: system-ui, -apple-system, sans-serif;
574
+ background: white;
575
+ border-radius: var(--nice-radius-lg, 8px);
576
+ position: relative;
577
+ }
578
+
579
+ .nice-sankey-title {
580
+ padding: var(--nice-space-3, 12px) var(--nice-space-4, 16px);
581
+ font-size: 16px;
582
+ font-weight: 600;
583
+ color: var(--text-primary, #0f172a);
584
+ border-bottom: 1px solid var(--border-color, #e5e7eb);
585
+ }
586
+
587
+ .nice-sankey-link {
588
+ cursor: pointer;
589
+ transition: fill-opacity 0.2s;
590
+ }
591
+
592
+ .nice-sankey-link:hover {
593
+ fill-opacity: 0.7;
594
+ }
595
+
596
+ .nice-sankey-node {
597
+ cursor: pointer;
598
+ transition: opacity 0.2s;
599
+ }
600
+
601
+ .nice-sankey-node:hover {
602
+ opacity: 0.8;
603
+ }
604
+
605
+ .nice-sankey-tooltip {
606
+ position: absolute;
607
+ background: var(--text-primary, #0f172a);
608
+ color: white;
609
+ padding: var(--nice-space-1-5, 6px) var(--nice-space-2-5, 10px);
610
+ border-radius: var(--nice-radius-sm, 4px);
611
+ font-size: 12px;
612
+ pointer-events: none;
613
+ z-index: 10;
614
+ white-space: nowrap;
615
+ }
616
+ `})]})},Ee=o.forwardRef((t,c)=>{const{initialData:i,data:l,maxPoints:s=60,updateInterval:b=1e3,fetchData:f,width:A=600,height:R=200,chartType:w="line",color:p="var(--color-primary, #3b82f6)",showGrid:k=!0,showTimeAxis:z=!0,showCurrentValue:S=!0,title:N,valueFormatter:d=L=>L.toFixed(2),timeFormatter:h=L=>new Date(L).toLocaleTimeString(),onDataUpdate:x,paused:$,className:g,style:y,...v}=t,[j,u]=o.useState(i??l??[]),[I,a]=o.useState($||!1),_=o.useRef();o.useEffect(()=>{$!==void 0&&a($)},[$]),o.useEffect(()=>{if(I||!f)return;const L=async()=>{try{const Z=await f();u(re=>{const de=[...re,Z].slice(-s);return x?.(de),de})}catch(Z){console.error("Failed to fetch realtime data:",Z)}};return _.current=setInterval(L,b),()=>{_.current&&clearInterval(_.current)}},[I,f,b,s,x]);const C=o.useCallback(L=>{u(Z=>{const re=[...Z,L].slice(-s);return x?.(re),re})},[s,x]),E=o.useCallback(()=>{u([]),x?.([])},[x]),U=o.useCallback(()=>a(!0),[]),V=o.useCallback(()=>a(!1),[]);o.useImperativeHandle(c,()=>({addDataPoint:C,clearData:E,pause:U,resume:V,getData:()=>j}),[C,E,j]);const H={top:20,right:60,bottom:z?40:20,left:50},G=A-H.left-H.right,Q=R-H.top-H.bottom,q=j.map(L=>L.value),J=q.length?Math.min(...q):0,r=q.length?Math.max(...q):100,Y=(r-J||1)*.1,B=J-Y,P=r+Y-B,F=L=>{const Z=f?s-1:Math.max(1,j.length-1);return H.left+L/Z*G},ee=L=>H.top+Q-(L-B)/P*Q,O=j.map((L,Z)=>`${F(Z)},${ee(L.value)}`).join(" "),te=j.length>0?`M ${F(0)},${H.top+Q} L ${O} L ${F(j.length-1)},${H.top+Q} Z`:"",xe=j.length>0?j[j.length-1].value:null;return e.jsxs("div",{className:`nice-realtime-chart ${g||""}`,style:{width:A,...y},...v,children:[e.jsxs("div",{className:"nice-realtime-header",children:[e.jsx("span",{className:"nice-realtime-title",children:N}),e.jsxs("div",{className:"nice-realtime-controls",children:[e.jsxs("span",{className:`nice-realtime-status ${I?"paused":"live"}`,children:[e.jsx("span",{className:"nice-realtime-status-dot"}),e.jsx("span",{children:I?"Wstrzymano":"Na żywo"})]}),e.jsx("button",{className:`nice-realtime-btn ${I?"paused":""}`,onClick:()=>a(!I),"aria-label":I?"Wznów":"Wstrzymaj",children:e.jsx(ue.oa,{name:I?"play":"pause",size:14})}),S&&xe!==null&&e.jsx("span",{className:"nice-realtime-value",children:d(xe)})]})]}),e.jsxs("svg",{width:A,height:R,className:"nice-realtime-svg",children:[k&&e.jsx("g",{className:"nice-realtime-grid",children:[0,.25,.5,.75,1].map((L,Z)=>{const re=H.top+Q*(1-L),de=B+P*L;return e.jsxs("g",{children:[e.jsx("line",{x1:H.left,y1:re,x2:A-H.right,y2:re,stroke:"var(--border-color, #e5e7eb)",strokeDasharray:L===0?void 0:"3"}),e.jsx("text",{x:H.left-8,y:re,textAnchor:"end",dominantBaseline:"middle",fontSize:"10",fill:"var(--text-secondary, #6b7280)",children:Math.round(de).toLocaleString()})]},Z)})}),w==="area"&&j.length>0&&e.jsx("path",{d:te,fill:p,fillOpacity:.2}),j.length>1&&e.jsx("polyline",{points:O,fill:"none",stroke:p,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),j.length>0&&e.jsx("circle",{cx:F(j.length-1),cy:ee(j[j.length-1].value),r:3,fill:p,className:"nice-realtime-point"}),z&&j.length>0&&e.jsx("g",{className:"nice-realtime-time-axis",children:Array.from(new Set([0,Math.floor(j.length/2),j.length-1].filter(L=>j[L]))).map(L=>e.jsx("text",{x:F(L),y:R-8,textAnchor:"middle",fontSize:"10",fill:"var(--text-secondary, #6b7280)",children:h(j[L].timestamp)},`tx-${L}`))})]}),e.jsx("style",{children:`
617
+ .nice-realtime-chart {
618
+ font-family: inherit;
619
+ color: var(--text-primary, #111827);
620
+ background: var(--bg-elevated, #ffffff);
621
+ border-radius: 8px;
622
+ position: relative;
623
+ }
624
+
625
+ .nice-realtime-header {
626
+ display: flex;
627
+ justify-content: space-between;
628
+ align-items: center;
629
+ padding: 12px 16px;
630
+ border-bottom: 1px solid var(--border-color, #e5e7eb);
631
+ }
632
+
633
+ .nice-realtime-title {
634
+ font-size: 14px;
635
+ font-weight: 600;
636
+ color: var(--text-primary, #111827);
637
+ }
638
+
639
+ .nice-realtime-controls {
640
+ display: flex;
641
+ align-items: center;
642
+ gap: 12px;
643
+ }
644
+
645
+ .nice-realtime-btn {
646
+ background: none;
647
+ border: none;
648
+ cursor: pointer;
649
+ font-size: 16px;
650
+ padding: 4px;
651
+ font-family: inherit;
652
+ color: inherit;
653
+ }
654
+
655
+ .nice-realtime-value {
656
+ font-size: 18px;
657
+ font-weight: 600;
658
+ color: ${p};
659
+ font-variant-numeric: tabular-nums;
660
+ }
661
+
662
+ /* Static current-value dot — no pulsing animation (was distracting) */
663
+
664
+ .nice-realtime-status {
665
+ display: inline-flex;
666
+ align-items: center;
667
+ gap: 6px;
668
+ font-size: 11px;
669
+ font-family: inherit;
670
+ color: var(--text-secondary, #6b7280);
671
+ background: var(--bg-secondary, #f3f4f6);
672
+ padding: 2px 10px;
673
+ border-radius: 999px;
674
+ }
675
+
676
+ .nice-realtime-status-dot {
677
+ width: 8px;
678
+ height: 8px;
679
+ border-radius: 50%;
680
+ background: var(--color-success, #22c55e);
681
+ }
682
+
683
+ .nice-realtime-status.paused .nice-realtime-status-dot {
684
+ background: var(--color-warning, #f59e0b);
685
+ }
686
+
687
+ .nice-realtime-status.live .nice-realtime-status-dot {
688
+ animation: live-pulse 2s ease-in-out infinite;
689
+ }
690
+
691
+ @keyframes live-pulse {
692
+ 0%, 100% { opacity: 1; }
693
+ 50% { opacity: 0.4; }
694
+ }
695
+ `})]})});Ee.displayName="NiceRealtimeChart";const mt=({data:t,width:c=600,height:i=400,showLabels:l=!0,showValues:s=!0,onNodeClick:b,drilldownEnabled:f=!0,colors:A=Be,tilePadding:R=2,className:w,style:p,...k})=>{const z=o.useMemo(()=>Array.isArray(t)?{id:"root",name:"Root",value:t.reduce((a,_)=>a+(_.value||0),0),children:t.map((a,_)=>({id:`${_}`,name:a.label??a.name??`Item ${_+1}`,value:a.value,color:a.color}))}:t,[t]),[S,N]=o.useState(z),[d,h]=o.useState([z.name]),[x,$]=o.useState(null),g=o.useRef(null),y=o.useMemo(()=>{const _=S.children||[];if(_.length===0)return[];const C=_.reduce((J,r)=>J+r.value,0),E=_.map(J=>({node:J,area:J.value/C*c*i}));E.sort((J,r)=>r.area-J.area);const U=[];let V=0,H=0,G=c,Q=i,q=0;for(;q<E.length;){const J=G<Q;let r=0,X=[];const Y=J?Q:G;for(let P=q;P<E.length;P++){const F=[...X,E[P]],ee=F.reduce((te,xe)=>te+xe.area,0),O=v(F,ee,Y);if(X.length===0)X=F,r=ee;else{const te=v(X,r,Y);if(O<=te)X=F,r=ee;else break}}const B=r/Y;let m=0;X.forEach((P,F)=>{const ee=P.area/B;U.push({node:P.node,x:J?V:V+m,y:J?H+m:H,w:J?B:ee,h:J?ee:B,color:P.node.color||A[(q+F)%A.length]}),m+=ee}),J?(V+=B,G-=B):(H+=B,Q-=B),q+=X.length}return U},[S,c,i,A]);function v(a,_,C){const E=_/C;let U=0;for(const V of a){const H=V.area/E,G=Math.max(E/H,H/E);U=Math.max(U,G)}return U}const j=a=>{b?.(a,[...d,a.name]),f&&a.children&&a.children.length>0&&(N(a),h(_=>[..._,a.name]))},u=()=>{if(d.length<=1)return;let a=z;const _=d.slice(0,-1);for(let C=1;C<_.length;C++){const E=a.children?.find(U=>U.name===_[C]);E&&(a=E)}N(a),h(_)},I=(a,_)=>{const C=g.current?.getBoundingClientRect();C&&$({x:_.clientX-C.left,y:_.clientY-C.top,content:a})};return e.jsxs("div",{className:`nice-treemap-chart ${w||""}`,style:{width:c,...p},...k,children:[e.jsxs("div",{className:"nice-treemap-nav",children:[d.length>1&&e.jsxs("button",{className:"nice-treemap-back",onClick:u,children:[e.jsx(ue.oa,{name:"arrow-left",size:14})," Wstecz"]}),e.jsx("div",{className:"nice-treemap-breadcrumbs",children:d.map((a,_)=>e.jsxs(o.Fragment,{children:[_>0&&e.jsx("span",{className:"nice-treemap-sep",children:"/"}),e.jsx("span",{className:_===d.length-1?"current":"",children:a})]},_))})]}),e.jsx("svg",{ref:g,width:c,height:i,className:"nice-treemap-svg",children:y.map((a,_)=>{const{node:C,x:E,y:U,w:V,h:H,color:G}=a,Q=Math.min(14,Math.max(10,Math.min(V,H)/6)),q=V>40&&H>30;return e.jsxs("g",{onClick:()=>j(C),onMouseEnter:J=>I(`${C.name}: ${C.value.toLocaleString()}`,J),onMouseLeave:()=>$(null),children:[e.jsx("rect",{x:E+R/2,y:U+R/2,width:Math.max(0,V-R),height:Math.max(0,H-R),fill:G,rx:4,className:"nice-treemap-tile"}),l&&q&&e.jsx("text",{x:E+V/2,y:U+H/2-(s?6:0),textAnchor:"middle",dominantBaseline:"middle",fontSize:Q,fill:"white",fontWeight:"500",style:{pointerEvents:"none"},children:C.name.length>V/Q+2?C.name.slice(0,Math.floor(V/Q))+"...":C.name}),s&&q&&e.jsx("text",{x:E+V/2,y:U+H/2+10,textAnchor:"middle",dominantBaseline:"middle",fontSize:Q-2,fill:"var(--nice-overlay-light-80, rgba(255, 255, 255, 0.8))",style:{pointerEvents:"none"},children:C.value.toLocaleString()})]},_)})}),x&&e.jsx("div",{className:"nice-treemap-tooltip",style:{left:x.x+10,top:x.y-30},children:x.content}),e.jsx("style",{children:`
696
+ .nice-treemap-chart {
697
+ font-family: system-ui, -apple-system, sans-serif;
698
+ background: white;
699
+ border-radius: var(--nice-radius-lg, 8px);
700
+ position: relative;
701
+ }
702
+
703
+ .nice-treemap-nav {
704
+ display: flex;
705
+ align-items: center;
706
+ gap: var(--nice-space-3, 12px);
707
+ padding: var(--nice-space-3, 12px) var(--nice-space-4, 16px);
708
+ border-bottom: 1px solid var(--border-color, #e5e7eb);
709
+ }
710
+
711
+ .nice-treemap-back {
712
+ background: var(--bg-secondary, #f8fafc);
713
+ border: none;
714
+ padding: var(--nice-space-1-5, 6px) var(--nice-space-3, 12px);
715
+ border-radius: var(--nice-radius-md, 6px);
716
+ cursor: pointer;
717
+ font-size: 13px;
718
+ }
719
+
720
+ .nice-treemap-back:hover {
721
+ background: var(--border-color, #e5e7eb);
722
+ }
723
+
724
+ .nice-treemap-breadcrumbs {
725
+ display: flex;
726
+ align-items: center;
727
+ gap: var(--nice-space-1, 4px);
728
+ font-size: 13px;
729
+ color: var(--text-secondary, #475569);
730
+ }
731
+
732
+ .nice-treemap-breadcrumbs .current {
733
+ color: var(--text-primary, #0f172a);
734
+ font-weight: 500;
735
+ }
736
+
737
+ .nice-treemap-sep {
738
+ color: var(--text-muted, #94a3b8);
739
+ }
740
+
741
+ .nice-treemap-tile {
742
+ cursor: pointer;
743
+ transition: opacity 0.2s, transform 0.1s;
744
+ }
745
+
746
+ .nice-treemap-tile:hover {
747
+ opacity: 0.85;
748
+ }
749
+
750
+ .nice-treemap-tooltip {
751
+ position: absolute;
752
+ background: var(--text-primary, #0f172a);
753
+ color: white;
754
+ padding: var(--nice-space-1-5, 6px) var(--nice-space-2-5, 10px);
755
+ border-radius: var(--nice-radius-sm, 4px);
756
+ font-size: 12px;
757
+ pointer-events: none;
758
+ z-index: 10;
759
+ white-space: nowrap;
760
+ }
761
+ `})]})},Oe=o.forwardRef(({data:t,renderNode:c,selectable:i,selectedKey:l,onSelect:s,direction:b="top-down",collapsible:f=!0,className:A,style:R,id:w},p)=>{const k=ue.hc(w),[z,S]=o.useState(new Set),N=o.useCallback(x=>{S($=>{const g=new Set($);return g.has(x)?g.delete(x):g.add(x),g})},[]),d=o.useCallback(x=>{i&&s?.(x)},[i,s]),h=o.useCallback(x=>{const $=z.has(x.key),g=x.children&&x.children.length>0;return e.jsxs("li",{className:"nice-org-chart__item",children:[e.jsxs("div",{className:`nice-org-chart__node${l===x.key?" nice-org-chart__node--selected":""}`,onClick:()=>d(x.key),role:i?"button":void 0,children:[c?c(x):e.jsx("span",{children:x.label}),f&&g&&e.jsx("button",{type:"button",className:"nice-org-chart__toggle",onClick:y=>{y.stopPropagation(),N(x.key)},"aria-label":$?"Expand":"Collapse",children:e.jsx(ue.oa,{name:$?"plus":"minus",size:14})})]}),g&&!$&&e.jsx("ul",{className:"nice-org-chart__children",children:x.children.map(y=>h(y))})]},x.key)},[z,l,c,i,f,d,N]);return e.jsx("div",{ref:p,id:k,className:`nice-org-chart nice-org-chart--${b} ${A||""}`,style:R,children:e.jsx("ul",{className:"nice-org-chart__root",children:h(t)})})});Oe.displayName="NiceOrganizationChart";function ft(t,c,i){const l=S=>{const N=S.replace("#","");return[parseInt(N.slice(0,2),16),parseInt(N.slice(2,4),16),parseInt(N.slice(4,6),16)]},[s,b,f]=l(t),[A,R,w]=l(c),p=Math.round(s+(A-s)*i),k=Math.round(b+(R-b)*i),z=Math.round(f+(w-f)*i);return`rgb(${p},${k},${z})`}const Pe=o.forwardRef(({data:t,xLabels:c,yLabels:i,colors:l=["var(--nice-primary-bg, #e0f2fe)","var(--color-primary-active, #1d4ed8)"],onCellClick:s,cellSize:b=40,showValues:f=!0,className:A,style:R,id:w},p)=>{const k=ue.hc(w),{minVal:z,maxVal:S}=o.useMemo(()=>{let d=1/0,h=-1/0;for(const x of t)for(const $ of x)$<d&&(d=$),$>h&&(h=$);return{minVal:d,maxVal:h}},[t]),N=o.useCallback(d=>S===z?.5:(d-z)/(S-z),[z,S]);return e.jsx("div",{ref:p,id:k,className:`nice-heatmap ${A||""}`,style:R,children:e.jsxs("table",{className:"nice-heatmap__table",children:[c&&e.jsx("thead",{children:e.jsxs("tr",{children:[i&&e.jsx("th",{}),c.map((d,h)=>e.jsx("th",{className:"nice-heatmap__header",children:d},h))]})}),e.jsx("tbody",{children:t.map((d,h)=>e.jsxs("tr",{children:[i&&e.jsx("th",{className:"nice-heatmap__row-label",children:i[h]}),d.map((x,$)=>e.jsx("td",{className:"nice-heatmap__cell",style:{background:ft(l[0],l[1],N(x)),width:b,height:b,textAlign:"center",color:N(x)>.6?"var(--bg-primary, #fff)":"var(--bg-tertiary, #333)",cursor:s?"pointer":void 0},onClick:()=>s?.(h,$,x),title:String(x),children:f?x:""},$))]},h))})]})})});Pe.displayName="NiceHeatMap";function pt(t,c){const i=t.reduce((w,p)=>w+p.value,0);if(i===0||t.length===0)return[];const l=[];let{x:s,y:b,w:f,h:A}=c;const R=[...t].sort((w,p)=>p.value-w.value);for(const w of R){const p=w.value/i;if(f>=A){const k=f*p;l.push({x:s,y:b,w:k,h:A,node:w}),s+=k,f-=k}else{const k=A*p;l.push({x:s,y:b,w:f,h:k,node:w}),b+=k,A-=k}}return l}const gt=["var(--color-primary, #3b82f6)","var(--color-success, #10b981)","var(--color-warning, #f59e0b)","var(--color-error, #ef4444)","var(--color-accent, #8b5cf6)","var(--color-info, #06b6d4)","var(--color-accent-pink, #ec4899)","var(--nice-success, #84cc16)"],Ae=o.forwardRef(({data:t,width:c=600,height:i=400,onNodeClick:l,colors:s=gt,className:b,style:f,id:A},R)=>{const w=ue.hc(A),p=o.useMemo(()=>{const k=t.children??[t];return pt(k,{x:0,y:0,w:c,h:i})},[t,c,i]);return e.jsx("div",{ref:R,id:w,className:`nice-treemap ${b||""}`,style:f,children:e.jsx("svg",{width:c,height:i,className:"nice-treemap__svg",children:p.map((k,z)=>e.jsxs("g",{onClick:()=>l?.(k.node),style:{cursor:l?"pointer":void 0},children:[e.jsx("rect",{x:k.x,y:k.y,width:Math.max(k.w-1,0),height:Math.max(k.h-1,0),fill:k.node.color??s[z%s.length],rx:2}),k.w>40&&k.h>20&&e.jsx("text",{x:k.x+k.w/2,y:k.y+k.h/2,textAnchor:"middle",dominantBaseline:"central",fill:"var(--nice-bg, #fff)",fontSize:Math.min(12,k.w/6),className:"nice-treemap__label",children:k.node.label})]},k.node.key))})})});Ae.displayName="NiceTreeMap";const yt=Object.freeze(Object.defineProperty({__proto__:null,NiceTreeMap:Ae},Symbol.toStringTag,{value:"Module"})),Fe=o.forwardRef(({data:t,type:c="candlestick",showVolume:i=!0,width:l=800,height:s=400,bullColor:b="var(--color-success, #22c55e)",bearColor:f="var(--color-error, #ef4444)",className:A,style:R,id:w},p)=>{const k=ue.hc(w),z={top:20,right:20,bottom:i?80:30,left:60},S=l-z.left-z.right,N=i?50:0,d=s-z.top-z.bottom-N,{minP:h,maxP:x,maxVol:$}=o.useMemo(()=>{let u=1/0,I=-1/0,a=0;for(const _ of t)_.low<u&&(u=_.low),_.high>I&&(I=_.high),_.volume&&_.volume>a&&(a=_.volume);return{minP:u,maxP:I,maxVol:a}},[t]),g=Math.max(1,S/t.length*.7),y=u=>z.left+(u+.5)*(S/t.length),v=u=>z.top+d-(u-h)/(x-h||1)*d,j=u=>s-z.bottom-N+N*(1-u/($||1));return e.jsx("div",{ref:p,id:k,className:`nice-stock-chart ${A||""}`,style:R,children:e.jsxs("svg",{width:l,height:s,className:"nice-stock-chart__svg",children:[[0,.25,.5,.75,1].map(u=>{const I=h+u*(x-h);return e.jsxs("g",{children:[e.jsx("line",{x1:z.left,x2:l-z.right,y1:v(I),y2:v(I),stroke:"var(--nice-border, #e5e7eb)",strokeDasharray:"2,2"}),e.jsx("text",{x:z.left-4,y:v(I)+4,textAnchor:"end",fontSize:10,fill:"var(--nice-text-secondary, #888)",children:I.toFixed(2)})]},u)}),c==="line"?e.jsx("polyline",{points:t.map((u,I)=>`${y(I)},${v(u.close)}`).join(" "),fill:"none",stroke:b,strokeWidth:1.5}):t.map((u,I)=>{const a=u.close>=u.open,_=a?b:f,C=y(I);if(c==="ohlc")return e.jsxs("g",{children:[e.jsx("line",{x1:C,x2:C,y1:v(u.high),y2:v(u.low),stroke:_,strokeWidth:1}),e.jsx("line",{x1:C-g/2,x2:C,y1:v(u.open),y2:v(u.open),stroke:_,strokeWidth:1.5}),e.jsx("line",{x1:C,x2:C+g/2,y1:v(u.close),y2:v(u.close),stroke:_,strokeWidth:1.5})]},I);const E=v(Math.max(u.open,u.close)),U=v(Math.min(u.open,u.close));return e.jsxs("g",{children:[e.jsx("line",{x1:C,x2:C,y1:v(u.high),y2:v(u.low),stroke:_,strokeWidth:1}),e.jsx("rect",{x:C-g/2,y:E,width:g,height:Math.max(U-E,1),fill:a?"transparent":_,stroke:_,strokeWidth:1})]},I)}),i&&t.map((u,I)=>{if(!u.volume)return null;const a=u.close>=u.open;return e.jsx("rect",{x:y(I)-g/2,y:j(u.volume),width:g,height:s-z.bottom-j(u.volume),fill:a?b:f,opacity:.3},`v${I}`)}),t.map((u,I)=>I%Math.max(1,Math.floor(t.length/8))!==0?null:e.jsx("text",{x:y(I),y:s-z.bottom+N+14,textAnchor:"middle",fontSize:9,fill:"var(--nice-text-secondary, #888)",children:u.date},`l${I}`))]})})});Fe.displayName="NiceStockChart";exports.CHART_COLORS=pe;exports.NiceBarGauge=rt;exports.NiceBullet=st;exports.NiceChart=ke;exports.NiceChart$1=Ye;exports.NiceChartAI=Ze;exports.NiceCircularGauge=et;exports.NiceDrillDownChart=We;exports.NiceForecastChart=ht;exports.NiceFunnel=ct;exports.NiceHeatMap=Pe;exports.NiceLinearGauge=tt;exports.NiceLiveChart=Re;exports.NiceMapChart=ut;exports.NiceOrganizationChart=Oe;exports.NicePieChart=Ke;exports.NicePolarChart=Qe;exports.NiceRangeSelector=it;exports.NiceRealtimeChart=Ee;exports.NiceSankey=De;exports.NiceSankey$1=ot;exports.NiceSankeyChart=xt;exports.NiceSparkline=nt;exports.NiceStockChart=Fe;exports.NiceTreeMap=Ae;exports.NiceTreeMap$1=yt;exports.NiceTreeMapChart=mt;exports.NiceVectorMap=Te;exports.NiceVectorMap$1=lt;exports.createMockLiveChartSource=Je;exports.createSignalRLiveChartSource=Ge;exports.createWebSocketLiveChartSource=qe;