@nice2dev/ui 1.2.1 → 1.3.0

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