@nice2dev/ui 1.4.14 → 1.4.16

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 (51) hide show
  1. package/CHANGELOG.md +80 -0
  2. package/dist/{NiceColorPicker-BLwYNSXJ.cjs → NiceColorPicker-79rkvaSk.cjs} +1 -1
  3. package/dist/NiceDataGrid-B1AOjgjm.cjs +10 -0
  4. package/dist/NiceForm-fmePSeA9.cjs +1 -0
  5. package/dist/{NiceHtmlEditor-BzECmDO3.cjs → NiceHtmlEditor-By7R1wRo.cjs} +1 -1
  6. package/dist/{NiceMention-CYRqPKGU.cjs → NiceMention-i7n2BoMw.cjs} +1 -1
  7. package/dist/{NiceModuleLifecyclePanel-CiYbPcHV.cjs → NiceModuleLifecyclePanel-DVHQuhc-.cjs} +1 -1
  8. package/dist/{NicePagination-BAxwqeEd.cjs → NicePagination-D9JguOl0.cjs} +1 -1
  9. package/dist/NicePivotGrid-B_7iQJys.cjs +2 -0
  10. package/dist/NiceSavedQueryPanel-ChY4HwpM.cjs +587 -0
  11. package/dist/{NiceScheduler-BqYiHPvz.cjs → NiceScheduler-B2DamQ_L.cjs} +1 -1
  12. package/dist/backup/NiceBackupScheduler.mjs +171 -119
  13. package/dist/charts/NiceOrganizationChart.mjs +159 -59
  14. package/dist/charts/orgChartExport.mjs +71 -0
  15. package/dist/charts/tidyTree.mjs +43 -0
  16. package/dist/charts-C3Q3r8Yz.cjs +918 -0
  17. package/dist/charts.cjs +1 -1
  18. package/dist/charts.d.ts +9 -0
  19. package/dist/{core-lazy-BQexApr7.cjs → core-lazy-ChKRuEPb.cjs} +1 -1
  20. package/dist/data/NiceDataGrid.mjs +301 -320
  21. package/dist/data/NiceRowEditDialog.mjs +57 -0
  22. package/dist/data/NiceTreeGrid.mjs +478 -433
  23. package/dist/data.cjs +1 -1
  24. package/dist/data.d.ts +43 -2
  25. package/dist/{devops-cgRBnZVX.cjs → devops-o6Zm0VKB.cjs} +3 -3
  26. package/dist/devops.cjs +1 -1
  27. package/dist/editors/forms/NiceForm.mjs +216 -167
  28. package/dist/editors/inputs/NiceUpload.mjs +238 -238
  29. package/dist/editors.cjs +1 -1
  30. package/dist/editors.d.ts +13 -1
  31. package/dist/feedback.cjs +1 -1
  32. package/dist/index.cjs +254 -254
  33. package/dist/index.d.ts +198 -5
  34. package/dist/index.mjs +928 -920
  35. package/dist/lazy.cjs +1 -1
  36. package/dist/lazy.d.ts +11 -1
  37. package/dist/navigation.cjs +1 -1
  38. package/dist/no-code/NiceDataMapper.mjs +398 -361
  39. package/dist/no-code-CN_q6TcB.cjs +331 -0
  40. package/dist/no-code.cjs +1 -1
  41. package/dist/no-code.d.ts +11 -1
  42. package/dist/style.css +1 -1
  43. package/dist/tools/NicePermissionMatrix.mjs +171 -138
  44. package/dist/tools/NiceRoleEditor.mjs +334 -297
  45. package/package.json +4 -4
  46. package/dist/NiceDataGrid-D3qRQSjy.cjs +0 -10
  47. package/dist/NiceForm-BWb4LTQJ.cjs +0 -1
  48. package/dist/NicePivotGrid-Cxu5PECg.cjs +0 -152
  49. package/dist/NiceSavedQueryPanel-C1nxEmMu.cjs +0 -587
  50. package/dist/charts-BzlvCCg9.cjs +0 -768
  51. package/dist/no-code-B1jzfUF5.cjs +0 -331
@@ -1,768 +0,0 @@
1
- "use strict";const e=require("react/jsx-runtime"),de=require("@nice2dev/ui-core"),c=require("react"),Ye=require("@nice2dev/i18n"),Fe=[],$e=["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)"],Ae=({series:t=Fe,categories:s,width:d=600,height:r=400,title:i,showLegend:b=!0,showGrid:g=!0,axisLabels:S=!0,yAxisLabel:D,xAxisLabel:E,stacked:R,animated:_,zoomable:O,crosshair:N,annotations:z,legendInteractive:T,onDataPointClick:w,exportable:l,className:x,style:A,testId:L,"data-testid":C})=>{const{t:y}=de.useNiceTranslation(),m=c.useRef(null),[I,a]=c.useState(new Set),[p,o]=c.useState(null),[k,f]=c.useState(null),[P,$]=c.useState(!1),H=c.useRef(null),ee=c.useMemo(()=>t.filter(j=>!I.has(j.name)),[t,I]),Y=c.useCallback(j=>{T&&a(Q=>{const n=new Set(Q);return n.has(j)?n.delete(j):n.add(j),n})},[T]),q={top:i?40:20,right:20,bottom:E?60:40,left:D?60:50},Z=d-q.left-q.right,U=r-q.top-q.bottom,v=ee[0]?.data.length??t[0]?.data.length??0,V=k?.start??0,te=k?.end??v,ce=te-V,ae=c.useMemo(()=>ee.map(j=>({...j,data:j.data.slice(V,te)})),[ee,V,te]),he=c.useMemo(()=>s?.slice(V,te),[s,V,te]),{minY:F,maxY:h,yTicks:B}=c.useMemo(()=>{let j;if(R){j=[];for(let ie=0;ie<ce;ie++)j.push(ae.reduce((le,me)=>le+(me.data[ie]||0),0))}else j=ae.flatMap(ie=>ie.data);j.length===0&&(j=[0]);const Q=Math.min(0,...j),n=Math.max(0,...j),W=n-Q||1,K=Math.pow(10,Math.floor(Math.log10(W)))||1,M=Math.floor(Q/K)*K;let J=Math.ceil(n/K)*K;const re=[];for(let ie=M;ie<=J;ie+=K)re.push(Math.round(ie*1e6)/1e6);return re.length<2&&(J=M+K,re.push(Math.round(J*1e6)/1e6)),{minY:M,maxY:J,yTicks:re}},[ae,ce,R]),u=j=>U-(j-F)/(h-F||1)*U,X=j=>(j+.5)/ce*Z,fe=j=>(j.type||"bar")==="bar",G=new Map(ae.filter(fe).map((j,Q)=>[j,Q])),se=ce>0?Z/ce/(R?1.5:Math.max(G.size,1)*1.5):20,ue=se*.9,ve=c.useCallback(j=>{if(!O)return;j.preventDefault();const Q=k??{start:0,end:v},n=Q.end-Q.start,W=(Q.start+Q.end)/2,K=j.deltaY>0?1.2:.8,M=Math.max(2,Math.min(v,Math.round(n*K))),J=Math.max(0,Math.round(W-M/2)),re=Math.min(v,J+M);f({start:J,end:re})},[O,k,v]),Ne=c.useCallback(j=>{O&&($(!0),H.current={x:j.clientX,range:k??{start:0,end:v}})},[O,k,v]),ye=c.useCallback(j=>{const Q=m.current?.getBoundingClientRect();if(Q&&o({x:j.clientX-Q.left-q.left,y:j.clientY-Q.top-q.top}),P&&H.current&&O){const n=j.clientX-H.current.x,W=Z/ce,K=-Math.round(n/W),M=H.current.range,J=M.end-M.start;let re=M.start+K;re<0&&(re=0),re+J>v&&(re=v-J),f({start:re,end:re+J})}},[P,O,Z,ce,v,q.left,q.top]),Me=c.useCallback(()=>{$(!1),H.current=null},[]),we=c.useCallback(()=>{o(null),$(!1),H.current=null},[]),ne=c.useCallback(()=>{const j=m.current;if(!j)return;const Q=new XMLSerializer().serializeToString(j),n=document.createElement("canvas");n.width=d,n.height=r+(b?30:0);const W=n.getContext("2d");if(!W)return;const K=new Image;K.onload=()=>{W.fillStyle=de.resolveCssColor("var(--nice-bg-primary, #fff)",W.canvas),W.fillRect(0,0,n.width,n.height),W.drawImage(K,0,0);const M=document.createElement("a");M.download="chart.png",M.href=n.toDataURL("image/png"),M.click()},K.src="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(Q)},[d,r,b]),oe=r+(b?30:0),xe=ae.length>0&&ae.every(j=>j.type==="radar"),je=c.useMemo(()=>{if(!xe)return 1;const j=ae.flatMap(Q=>Q.data);return Math.max(1,...j)},[xe,ae]);if(xe){const j=d/2,Q=(r-q.top-q.bottom)/2+q.top,n=Math.min(Z,r-q.top-q.bottom)/2-10,W=he?.length??ae[0]?.data.length??0,K=re=>re/W*Math.PI*2-Math.PI/2,M=(re,ie)=>{const le=ie/je*n;return[j+Math.cos(K(re))*le,Q+Math.sin(K(re))*le]},J=4;return e.jsx("div",{className:`nice-chart nice-chart--radar ${x||""}`,style:A,"data-testid":C??L,children:e.jsxs("svg",{ref:m,viewBox:`0 0 ${d} ${oe}`,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}),g&&Array.from({length:J},(re,ie)=>{const le=(ie+1)/J*n,me=[];for(let ge=0;ge<W;ge++)me.push(`${j+Math.cos(K(ge))*le},${Q+Math.sin(K(ge))*le}`);return e.jsx("polygon",{points:me.join(" "),fill:"none",className:"nice-chart__grid-line"},ie)}),Array.from({length:W},(re,ie)=>{const[le,me]=M(ie,je);return e.jsx("line",{x1:j,y1:Q,x2:le,y2:me,className:"nice-chart__grid-line"},ie)}),S&&he?.map((re,ie)=>{const[le,me]=M(ie,je*1.12);return e.jsx("text",{x:le,y:me,textAnchor:"middle",dominantBaseline:"middle",className:"nice-chart__axis-label",children:re},ie)}),ae.map((re,ie)=>{const le=re.color||$e[ie%$e.length],me=re.data.map((ge,ke)=>M(ke,ge).join(",")).join(" ");return e.jsxs("g",{className:_?"nice-chart__series nice-chart__series--radar nice-chart__series--anim":"nice-chart__series nice-chart__series--radar",children:[e.jsx("polygon",{points:me,fill:le,fillOpacity:.2,stroke:le,strokeWidth:2}),re.data.map((ge,ke)=>{const[Se,Ie]=M(ke,ge);return e.jsx("circle",{cx:Se,cy:Ie,r:3,fill:le,children:e.jsx("title",{children:`${re.name}: ${ge}`})},ke)})]},re.name)}),b&&e.jsx("g",{transform:`translate(${q.left}, ${r})`,children:t.map((re,ie)=>{const le=ie*120,me=I.has(re.name);return e.jsxs("g",{transform:`translate(${le}, 10)`,style:T?{cursor:"pointer"}:void 0,onClick:()=>Y(re.name),opacity:me?.35:1,children:[e.jsx("rect",{width:12,height:12,rx:2,fill:re.color||$e[ie%$e.length]}),e.jsx("text",{x:16,y:10,className:"nice-chart__legend-text",children:re.name})]},re.name)})})]})})}return e.jsxs("div",{className:`nice-chart ${x||""}`,style:A,"data-testid":C??L,children:[l&&e.jsx("button",{type:"button",className:"nice-chart__export-btn",onClick:ne,title:y("chart.exportPng","Export PNG"),"aria-label":y("chart.exportPng","Export PNG"),children:e.jsx(de.NiceIcon,{name:"camera",size:16})}),e.jsxs("svg",{ref:m,viewBox:`0 0 ${d} ${oe}`,preserveAspectRatio:"xMidYMid meet",width:"100%",height:"100%",style:{display:"block",maxWidth:"100%",maxHeight:"100%"},className:"nice-chart__svg",onWheel:ve,onMouseDown:Ne,onMouseMove:ye,onMouseUp:Me,onMouseLeave:we,children:[e.jsxs("g",{transform:`translate(${q.left},${q.top})`,children:[i&&e.jsx("text",{x:Z/2,y:-10,textAnchor:"middle",className:"nice-chart__title",children:i}),g&&B.map(j=>e.jsx("line",{x1:0,y1:u(j),x2:Z,y2:u(j),className:"nice-chart__grid-line"},`grid-${j}`)),S&&B.map(j=>e.jsx("text",{x:-8,y:u(j)+4,textAnchor:"end",className:"nice-chart__axis-label",children:j},`ylabel-${j}`)),S&&he&&he.map((j,Q)=>e.jsx("text",{x:X(Q),y:U+20,textAnchor:"middle",className:"nice-chart__axis-label",children:j},Q)),D&&e.jsx("text",{x:-q.left+14,y:U/2,textAnchor:"middle",transform:`rotate(-90, -${q.left-14}, ${U/2})`,className:"nice-chart__axis-title",children:D}),E&&e.jsx("text",{x:Z/2,y:U+45,textAnchor:"middle",className:"nice-chart__axis-title",children:E}),e.jsx("line",{x1:0,y1:0,x2:0,y2:U,className:"nice-chart__axis"}),e.jsx("line",{x1:0,y1:U,x2:Z,y2:U,className:"nice-chart__axis"}),z?.map((j,Q)=>{if(j.type==="line"){const n=u(j.value);return e.jsxs("g",{children:[e.jsx("line",{x1:0,y1:n,x2:Z,y2:n,stroke:j.color||"var(--nice-color-error, #ef4444)",strokeWidth:1.5,strokeDasharray:j.dash||"6,3"}),j.label&&e.jsx("text",{x:Z+4,y:n+4,className:"nice-chart__annotation-label",fill:j.color||"var(--nice-color-error, #ef4444)",children:j.label})]},Q)}return e.jsx("text",{x:X(j.value),y:-4,textAnchor:"middle",className:"nice-chart__annotation-label",fill:j.color||"var(--nice-text-muted, #6b7280)",children:j.label},Q)}),N&&p&&p.x>=0&&p.x<=Z&&p.y>=0&&p.y<=U&&e.jsxs(e.Fragment,{children:[e.jsx("line",{x1:p.x,y1:0,x2:p.x,y2:U,stroke:"var(--nice-text-muted, #9ca3af)",strokeWidth:1,strokeDasharray:"4,2"}),e.jsx("line",{x1:0,y1:p.y,x2:Z,y2:p.y,stroke:"var(--nice-text-muted, #9ca3af)",strokeWidth:1,strokeDasharray:"4,2"})]}),ae.map((j,Q)=>{const n=j.color||$e[Q%$e.length],W=j.type||"bar";if(W==="bar")return e.jsx("g",{className:_?"nice-chart__series nice-chart__series--bar nice-chart__series--anim":"nice-chart__series nice-chart__series--bar",children:j.data.map((M,J)=>{let re,ie;if(R){const ge=ae.slice(0,Q).filter(fe).reduce((ke,Se)=>ke+(Se.data[J]||0),0);re=u(ge+M),ie=u(ge)-re}else re=u(Math.max(0,M)),ie=Math.abs(u(M)-u(0));const le=G.get(j)??0,me=R?X(J)-ue/2:X(J)-G.size*se/2+le*se+(se-ue)/2;return e.jsx("rect",{x:me,y:re,width:ue,height:Math.max(0,ie),fill:n,rx:2,style:{transformOrigin:`${me+ue/2}px ${u(0)}px`,...w?{cursor:"pointer"}:{}},onClick:w?()=>w(j.name,V+J,M):void 0,children:e.jsx("title",{children:`${j.name}: ${M}`})},J)})},j.name);if(W==="scatter")return e.jsx("g",{className:_?"nice-chart__series nice-chart__series--scatter nice-chart__series--anim":"nice-chart__series nice-chart__series--scatter",children:j.data.map((M,J)=>e.jsx("circle",{cx:X(J),cy:u(M),r:5,fill:n,fillOpacity:.7,stroke:n,strokeWidth:1.5,style:w?{cursor:"pointer"}:void 0,onClick:w?()=>w(j.name,V+J,M):void 0,children:e.jsx("title",{children:`${j.name}: ${M}`})},J))},j.name);const K=j.data.map((M,J)=>`${X(J)},${u(M)}`);return e.jsxs("g",{className:_?`nice-chart__series nice-chart__series--${W} nice-chart__series--anim`:`nice-chart__series nice-chart__series--${W}`,children:[W==="area"&&ce>0&&e.jsx("polygon",{points:`${X(0)},${u(0)} ${K.join(" ")} ${X(ce-1)},${u(0)}`,fill:n,opacity:.15}),e.jsx("polyline",{points:K.join(" "),fill:"none",stroke:n,strokeWidth:2,className:_?"nice-chart__line":void 0}),j.data.map((M,J)=>e.jsx("circle",{cx:X(J),cy:u(M),r:3,fill:n,style:w?{cursor:"pointer"}:void 0,onClick:w?()=>w(j.name,V+J,M):void 0,children:e.jsx("title",{children:`${j.name}: ${M}`})},J))]},j.name)})]}),b&&e.jsx("g",{transform:`translate(${q.left}, ${r})`,children:t.map((j,Q)=>{const n=Q*120,W=I.has(j.name);return e.jsxs("g",{transform:`translate(${n}, 10)`,style:T?{cursor:"pointer"}:void 0,onClick:()=>Y(j.name),opacity:W?.35:1,children:[e.jsx("rect",{width:12,height:12,rx:2,fill:j.color||$e[Q%$e.length]}),e.jsx("text",{x:16,y:10,className:"nice-chart__legend-text",style:W?{textDecoration:"line-through"}:void 0,children:j.name})]},j.name)})})]})]})},He=Object.freeze(Object.defineProperty({__proto__:null,NiceChart:Ae},Symbol.toStringTag,{value:"Module"})),Ve=({value:t,min:s=0,max:d=100,width:r=200,height:i=200,startAngle:b=225,endAngle:g=-45,color:S="var(--nice-color-primary, #3b82f6)",trackColor:D,label:E,formatValue:R,ranges:_,className:O,style:N,testId:z,"data-testid":T})=>{const w=r/2,l=i/2,x=Math.min(w,l)-20,A=Math.max(0,Math.min(1,(t-s)/(d-s||1))),L=o=>o*Math.PI/180,C=(b-g+360)%360||360,y=o=>({x:w+x*Math.cos(L(o)),y:l-x*Math.sin(L(o))}),m=(o,k)=>{const f=y(o),P=y(k),H=(o-k+360)%360>180?1:0;return`M${f.x},${f.y} A${x},${x} 0 ${H},1 ${P.x},${P.y}`},I=b-A*C,a=y(I);let p=S;if(_){for(const o of _)if(t>=o.start&&t<=o.end){p=o.color;break}}return e.jsx("div",{className:`nice-gauge nice-gauge--circular ${O||""}`,style:N,"data-testid":T??z,children:e.jsxs("svg",{width:r,height:i,children:[e.jsx("path",{d:m(b,g),fill:"none",stroke:D||"var(--nice-border-color, #e2e8f0)",strokeWidth:12,strokeLinecap:"round"}),A>0&&e.jsx("path",{d:m(b,I),fill:"none",stroke:p,strokeWidth:12,strokeLinecap:"round"}),e.jsx("line",{x1:w,y1:l,x2:a.x,y2:a.y,stroke:"var(--nice-text-primary, #333)",strokeWidth:2,strokeLinecap:"round"}),e.jsx("circle",{cx:w,cy:l,r:4,fill:"var(--nice-text-primary, #333)"}),e.jsx("text",{x:w,y:l+x*.6,textAnchor:"middle",className:"nice-gauge__value",children:R?R(t):t}),E&&e.jsx("text",{x:w,y:l+x*.95,textAnchor:"middle",className:"nice-gauge__label",children:E})]})})},Xe=({value:t,min:s=0,max:d=100,width:r=300,height:i=60,orientation:b="horizontal",color:g="var(--nice-color-primary, #3b82f6)",label:S,formatValue:D,ranges:E,showTicks:R=!0,tickCount:_=5,className:O,style:N,testId:z,"data-testid":T})=>{const w=b==="horizontal",l=w?r-40:i-40,x=Math.max(0,Math.min(1,(t-s)/(d-s||1))),A=10;let L=g;if(E){for(const y of E)if(t>=y.start&&t<=y.end){L=y.color;break}}const C=Array.from({length:_},(y,m)=>s+(d-s)*(m/(_-1)));if(w){const y=S?14:0;return e.jsx("div",{className:`nice-gauge nice-gauge--linear ${O||""}`,style:N,"data-testid":T??z,children:e.jsxs("svg",{width:r,height:i+y,children:[e.jsx("text",{x:20+l*x,y:14,textAnchor:"middle",className:"nice-gauge__value",style:{fontSize:12},children:D?D(t):t}),e.jsx("rect",{x:20,y:i/2-A/2,width:l,height:A,rx:5,fill:"var(--nice-border-color, #e2e8f0)"}),e.jsx("rect",{x:20,y:i/2-A/2,width:l*x,height:A,rx:5,fill:L}),e.jsx("polygon",{points:`${20+l*x},${i/2-A/2-2} ${20+l*x-5},${i/2-A/2-8} ${20+l*x+5},${i/2-A/2-8}`,fill:"var(--nice-text-primary, #333)"}),R&&C.map((m,I)=>{const a=20+(m-s)/(d-s)*l;return e.jsx("text",{x:a,y:i/2+A/2+12,textAnchor:"middle",className:"nice-gauge__tick",children:m},I)}),S&&e.jsx("text",{x:r/2,y:i+y-2,textAnchor:"middle",className:"nice-gauge__label",children:S})]})})}return e.jsx("div",{className:`nice-gauge nice-gauge--linear nice-gauge--vertical ${O||""}`,style:N,"data-testid":T??z,children:e.jsxs("svg",{width:r,height:i,children:[e.jsx("rect",{x:r/2-A/2,y:20,width:A,height:l,rx:5,fill:"var(--nice-border-color, #e2e8f0)"}),e.jsx("rect",{x:r/2-A/2,y:20+l*(1-x),width:A,height:l*x,rx:5,fill:L}),e.jsx("text",{x:r/2,y:14,textAnchor:"middle",className:"nice-gauge__value",children:D?D(t):t}),S&&e.jsx("text",{x:r/2,y:i-4,textAnchor:"middle",className:"nice-gauge__label",children:S})]})})},_e=["#3b82f6","#ef4444","#22c55e","#f59e0b","#8b5cf6","#ec4899","#06b6d4","#84cc16"],Ge=[],ze=20,Ze=10,Ue=32,Ke=({items:t=Ge,min:s=0,max:d=100,width:r=300,height:i=300,startAngle:b=225,endAngle:g=-45,formatValue:S,title:D,className:E,style:R,testId:_,"data-testid":O})=>{const N=$=>$*Math.PI/180,z=(b-g+360)%360||360,T=[N(b),N(g)],w=$=>(b-$+720)%360<=z,l=w(90)?1:Math.max(0,...T.map($=>Math.sin($))),x=w(270)?1:Math.max(0,...T.map($=>-Math.sin($))),A=w(180)?1:Math.max(0,...T.map($=>-Math.cos($))),L=w(0)?1:Math.max(0,...T.map($=>Math.cos($))),C=D?Ue:0,y=Ze+ze/2,m=r-2*y,I=i-C-2*y,a=Math.max(0,Math.min(m/(A+L||1),I/(l+x||1))),p=y+A*a+(m-(A+L)*a)/2,o=C+y+l*a+(I-(l+x)*a)/2,k=Math.min(ze,a/(t.length+1)),f=4,P=($,H,ee)=>{const Y=p+$*Math.cos(N(H)),q=o-$*Math.sin(N(H)),Z=p+$*Math.cos(N(ee)),U=o-$*Math.sin(N(ee)),v=(H-ee+360)%360;return`M${Y},${q} A${$},${$} 0 ${v>180?1:0},1 ${Z},${U}`};return e.jsx("div",{className:`nice-bargauge ${E||""}`,style:R,"data-testid":O??_,children:e.jsxs("svg",{width:r,height:i,children:[D&&e.jsx("text",{x:r/2,y:20,textAnchor:"middle",className:"nice-chart__title",children:D}),t.map(($,H)=>{const ee=a-H*(k+f),Y=Math.max(0,Math.min(1,($.value-s)/(d-s||1))),q=b-Y*z,Z=$.color||_e[H%_e.length];return e.jsxs("g",{children:[e.jsx("path",{d:P(ee,b,g),fill:"none",stroke:"var(--nice-border-color, #e2e8f0)",strokeWidth:k,strokeLinecap:"round"}),Y>0&&e.jsx("path",{d:P(ee,b,q),fill:"none",stroke:Z,strokeWidth:k,strokeLinecap:"round"})]},H)}),e.jsx("g",{children:t.map(($,H)=>e.jsxs("text",{x:p,y:o-((t.length-1)/2-H)*16,textAnchor:"middle",dominantBaseline:"middle",className:"nice-gauge__value",style:{fontSize:12},children:[$.label?`${$.label}: `:"",S?S($.value):$.value]},H))})]})})},qe={sm:{width:160,height:22,fontSize:11},md:{width:220,height:32,fontSize:12},lg:{width:320,height:44,fontSize:14}},Je=({value:t,target:s,min:d=0,max:r=100,width:i,height:b,color:g="var(--nice-color-primary, #3b82f6)",targetColor:S="var(--nice-color-error, #ef4444)",size:D="md",label:E,labelPlacement:R="top",showValue:_=!1,showTarget:O=!1,formatValue:N=L=>String(L),state:z="normal",errorMessage:T,className:w,style:l,testId:x,"data-testid":A})=>{const{t:L}=de.useNiceTranslation(),C=qe[D],y=i??C.width,m=b??C.height,I=C.fontSize,a=4,p=y-a*2,o=O&&s!=null?I+4:a,k=O&&s!=null?m+(o-a):m,f=k-o-a,P=Math.max(0,Math.min(1,(t-d)/(r-d||1))),$=s!=null?Math.max(0,Math.min(1,(s-d)/(r-d||1))):null,H=()=>z==="error"?e.jsx("div",{role:"alert",style:{width:y,height:k,display:"flex",alignItems:"center",justifyContent:"center",border:"1px dashed var(--nice-color-error, #ef4444)",borderRadius:4,color:"var(--nice-color-error, #ef4444)",fontSize:I,padding:"0 8px",boxSizing:"border-box"},children:T??L("bullet.error","Error")}):z==="loading"?e.jsx("div",{role:"status","aria-label":L("bullet.loading","Loading"),className:"nice-bullet__skeleton",style:{width:y,height:k,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:y,height:k,role:"img","aria-label":typeof E=="string"?E:void 0,children:[e.jsx("rect",{x:a,y:o,width:p,height:f,rx:3,fill:"var(--nice-border-color, #e2e8f0)"}),e.jsx("rect",{x:a,y:o+f*.2,width:p*P,height:f*.6,rx:2,fill:g}),$!=null&&e.jsx("line",{x1:a+p*$,y1:o+2,x2:a+p*$,y2:o+f-2,stroke:S,strokeWidth:2}),_&&e.jsx("text",{x:a+Math.max(p*P,4),y:o+f/2,dx:p*P>24?-4:4,textAnchor:p*P>24?"end":"start",dominantBaseline:"middle",fontSize:I,fill:p*P>24?"var(--nice-color-white, #ffffff)":"var(--nice-text-primary)",fontWeight:600,children:N(t)}),O&&$!=null&&e.jsx("text",{x:a+p*$,y:o-2,textAnchor:"middle",fontSize:I-1,fill:S,fontWeight:600,children:N(s)})]});if(R==="none"||!E)return e.jsxs("div",{className:`nice-bullet ${w||""}`,style:l,"data-testid":A??x,children:[H(),e.jsx("style",{children:Le})]});const ee=R==="top"||R==="bottom",Y=e.jsx("span",{className:"nice-bullet__label",style:{fontSize:I,fontWeight:600,color:"var(--nice-text-primary)",...ee?{marginBottom:R==="top"?4:0,marginTop:R==="bottom"?4:0}:{},...R==="left"?{marginRight:8}:{},...R==="right"?{marginLeft:8}:{}},children:E});return e.jsxs("div",{className:`nice-bullet nice-bullet--${R} ${w||""}`,style:{display:"inline-flex",flexDirection:ee?"column":"row",alignItems:ee?"flex-start":"center",...l},"data-testid":A??x,children:[(R==="top"||R==="left")&&Y,H(),(R==="bottom"||R==="right")&&Y,e.jsx("style",{children:Le})]})},Le=`
2
- @keyframes nice-bullet-shimmer {
3
- 0% { background-position: 200% 0; }
4
- 100% { background-position: -200% 0; }
5
- }
6
- `,Qe=[],et=({data:t=Qe,width:s=400,height:d=400,innerRadius:r=0,title:i,showLegend:b=!0,showLabels:g=!0,className:S,style:D,testId:E,"data-testid":R})=>{const _=s/2,O=(d-(b?30:0))/2+(i?10:0),N=Math.min(_,O)-40,z=t.reduce((l,x)=>l+x.value,0);let T=-Math.PI/2;const w=t.map((l,x)=>{const A=l.value/(z||1)*Math.PI*2,L=T;T+=A;const C=T,y=(L+C)/2,m=_+N*Math.cos(L),I=O+N*Math.sin(L),a=_+N*Math.cos(C),p=O+N*Math.sin(C),o=A>Math.PI?1:0,k=l.color||_e[x%_e.length],f=A>=Math.PI*2-1e-9;let P;if(f){const Z=(U,v)=>`M${_-U},${O} A${U},${U} 0 1,${v} ${_+U},${O} A${U},${U} 0 1,${v} ${_-U},${O} Z`;P=r>0?`${Z(N,1)} ${Z(r,0)}`:Z(N,1)}else if(r>0){const Z=_+r*Math.cos(L),U=O+r*Math.sin(L),v=_+r*Math.cos(C),V=O+r*Math.sin(C);P=`M${m},${I} A${N},${N} 0 ${o},1 ${a},${p} L${v},${V} A${r},${r} 0 ${o},0 ${Z},${U} Z`}else P=`M${_},${O} L${m},${I} A${N},${N} 0 ${o},1 ${a},${p} Z`;const $=Math.min(Math.max(r,0),N),H=$>0?($+N)/2:N*.65,ee=f?_:_+H*Math.cos(y),Y=f?O:O+H*Math.sin(y),q=z>0?Math.round(l.value/z*100):0;return{...l,path:P,labelX:ee,labelY:Y,pct:q,color:k}});return e.jsx("div",{className:`nice-piechart ${S||""}`,style:D,"data-testid":R??E,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:_,y:20,textAnchor:"middle",className:"nice-chart__title",children:i}),w.map((l,x)=>e.jsxs("g",{children:[e.jsx("path",{d:l.path,fill:l.color,stroke:"var(--nice-bg-primary, #fff)",strokeWidth:2,children:e.jsx("title",{children:`${l.label}: ${l.value} (${l.pct}%)`})}),g&&l.pct>=5&&e.jsxs("text",{x:l.labelX,y:l.labelY,textAnchor:"middle",dominantBaseline:"middle",className:"nice-piechart__label",children:[l.pct,"%"]})]},x)),b&&e.jsx("g",{transform:`translate(10, ${d-25})`,children:t.map((l,x)=>e.jsxs("g",{transform:`translate(${x*100}, 0)`,children:[e.jsx("rect",{width:10,height:10,rx:2,fill:l.color||_e[x%_e.length]}),e.jsx("text",{x:14,y:9,className:"nice-chart__legend-text",children:l.label})]},x))})]})})},tt=[],nt=({data:t=tt,width:s=400,height:d=300,inverted:r,showLabels:i=!0,showValues:b=!0,title:g,className:S,style:D,testId:E,"data-testid":R})=>{const _={top:g?30:10,bottom:10,x:40},O=s-_.x*2,N=d-_.top-_.bottom,z=r?[...t].reverse():t,T=Math.max(...z.map(l=>l.value),1),w=N/z.length;return e.jsx("div",{className:`nice-funnel ${S||""}`,style:D,"data-testid":R??E,children:e.jsxs("svg",{width:s,height:d,children:[g&&e.jsx("text",{x:s/2,y:20,textAnchor:"middle",className:"nice-chart__title",children:g}),z.map((l,x)=>{const A=l.value/T*O,L=x<z.length-1?z[x+1].value/T*O:A*.3,C=_.top+x*w,y=C+w,m=s/2,I=`${m-A/2},${C} ${m+A/2},${C} ${m+L/2},${y} ${m-L/2},${y}`,a=l.color||_e[x%_e.length];return e.jsxs("g",{children:[e.jsx("polygon",{points:I,fill:a,stroke:"var(--nice-bg-primary, #fff)",strokeWidth:1,children:e.jsx("title",{children:`${l.label}: ${l.value}`})}),i&&e.jsx("text",{x:m,y:C+w/2-(b?4:0),textAnchor:"middle",dominantBaseline:"middle",className:"nice-funnel__label",children:l.label}),b&&e.jsx("text",{x:m,y:C+w/2+10,textAnchor:"middle",dominantBaseline:"middle",className:"nice-funnel__value",children:l.value})]},x)})]})})},rt=[];function at(t,s,d){const r=N=>{const z=N.replace("#","");return[parseInt(z.slice(0,2),16),parseInt(z.slice(2,4),16),parseInt(z.slice(4,6),16)]},[i,b,g]=r(t),[S,D,E]=r(s),R=Math.round(i+(S-i)*d),_=Math.round(b+(D-b)*d),O=Math.round(g+(E-g)*d);return`rgb(${R},${_},${O})`}const ct=Object.assign(c.forwardRef(({data:t=rt,xLabels:s,yLabels:d,colors:r=["var(--nice-primary-bg, #e0f2fe)","var(--nice-color-primary-active, #1d4ed8)"],onCellClick:i,cellSize:b=40,showValues:g=!0,className:S,style:D,id:E,testId:R,"data-testid":_},O)=>{const N=de.useControlId(E),{minVal:z,maxVal:T}=c.useMemo(()=>{let l=1/0,x=-1/0;for(const A of t)for(const L of A)L<l&&(l=L),L>x&&(x=L);return{minVal:l,maxVal:x}},[t]),w=c.useCallback(l=>T===z?.5:(l-z)/(T-z),[z,T]);return e.jsx("div",{ref:O,id:N,className:`nice-heatmap ${S||""}`,style:D,"data-testid":_??R,children:e.jsxs("table",{className:"nice-heatmap__table",children:[s&&e.jsx("thead",{children:e.jsxs("tr",{children:[d&&e.jsx("th",{}),s.map((l,x)=>e.jsx("th",{className:"nice-heatmap__header",children:l},x))]})}),e.jsx("tbody",{children:t.map((l,x)=>e.jsxs("tr",{children:[d&&e.jsx("th",{className:"nice-heatmap__row-label",children:d[x]}),l.map((A,L)=>e.jsx("td",{className:"nice-heatmap__cell",style:{background:at(r[0],r[1],w(A)),width:b,height:b,textAlign:"center",color:w(A)>.6?"var(--nice-color-white, #fff)":"var(--nice-text-primary, #333)",cursor:i?"pointer":void 0},onClick:()=>i?.(x,L,A),title:String(A),children:g?A:""},L))]},x))})]})})}),{displayName:"NiceHeatMap"}),st=[],it=[],Pe=({nodes:t=st,links:s=it,width:d=600,height:r=400,nodeWidth:i=20,nodePadding:b=10,title:g,className:S,style:D,testId:E,"data-testid":R})=>{const _={top:g?40:20,bottom:20,left:20,right:20},O=d-_.left-_.right,N=r-_.top-_.bottom,z=new Set(s.map(o=>o.source)),T=new Set(s.map(o=>o.target)),w=t.filter(o=>z.has(o.id)&&!T.has(o.id)),l=t.filter(o=>T.has(o.id)),x=t.filter(o=>z.has(o.id)&&T.has(o.id)),A=[w,...x.length?[x]:[],l].filter(o=>o.length>0),L=A.length,C=new Map;t.forEach(o=>{const k=s.filter(P=>P.source===o.id).reduce((P,$)=>P+$.value,0),f=s.filter(P=>P.target===o.id).reduce((P,$)=>P+$.value,0);C.set(o.id,Math.max(k,f))});const y=A.map(o=>o.reduce((k,f)=>k+(C.get(f.id)||0),0)+(o.length-1)*b),m=Math.max(...y,1),I=new Map;A.forEach((o,k)=>{const f=_.left+k/(L-1||1)*(O-i);let P=0;o.forEach($=>{const H=(C.get($.id)||0)/m*N;I.set($.id,{x:f,y:_.top+P,h:H}),P+=H+b})});const a=new Map,p=new Map;return t.forEach(o=>{a.set(o.id,0),p.set(o.id,0)}),e.jsx("div",{className:`nice-sankey ${S||""}`,style:D,"data-testid":R??E,children:e.jsxs("svg",{width:d,height:r,children:[g&&e.jsx("text",{x:d/2,y:20,textAnchor:"middle",className:"nice-chart__title",children:g}),s.map((o,k)=>{const f=I.get(o.source),P=I.get(o.target);if(!f||!P)return null;const $=a.get(o.source)||0,H=p.get(o.target)||0,ee=o.value/m*N;a.set(o.source,$+ee),p.set(o.target,H+ee);const Y=f.x+i,q=f.y+$,Z=P.x,U=P.y+H,v=(Y+Z)/2,te=t.find(ce=>ce.id===o.source)?.color||_e[k%_e.length];return e.jsx("path",{d:`M${Y},${q} C${v},${q} ${v},${U} ${Z},${U} L${Z},${U+ee} C${v},${U+ee} ${v},${q+ee} ${Y},${q+ee} Z`,fill:te,fillOpacity:.3,stroke:te,strokeOpacity:.5,strokeWidth:.5,children:e.jsx("title",{children:`${o.source} → ${o.target}: ${o.value}`})},k)}),t.map((o,k)=>{const f=I.get(o.id);if(!f)return null;const P=o.color||_e[k%_e.length];return e.jsxs("g",{children:[e.jsx("rect",{x:f.x,y:f.y,width:i,height:Math.max(f.h,2),fill:P,rx:2}),e.jsx("text",{x:f.x<O/2?f.x+i+4:f.x-4,y:f.y+f.h/2,textAnchor:f.x<O/2?"start":"end",dominantBaseline:"middle",className:"nice-chart__legend-text",children:o.label})]},o.id)})]})})},ot=Object.freeze(Object.defineProperty({__proto__:null,NiceSankey:Pe},Symbol.toStringTag,{value:"Module"}));function lt(t,s){const d=t.reduce((E,R)=>E+R.value,0);if(d===0||t.length===0)return[];const r=[];let{x:i,y:b,w:g,h:S}=s;const D=[...t].sort((E,R)=>R.value-E.value);for(const E of D){const R=E.value/d;if(g>=S){const _=g*R;r.push({x:i,y:b,w:_,h:S,node:E}),i+=_,g-=_}else{const _=S*R;r.push({x:i,y:b,w:g,h:_,node:E}),b+=_,S-=_}}return r}const dt=["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)"],Oe=Object.assign(c.forwardRef(({data:t,width:s=600,height:d=400,onNodeClick:r,colors:i=dt,className:b,style:g,id:S,testId:D,"data-testid":E},R)=>{const _=de.useControlId(S),O=c.useMemo(()=>{const N=t.children??[t];return lt(N,{x:0,y:0,w:s,h:d})},[t,s,d]);return e.jsx("div",{ref:R,id:_,className:`nice-treemap ${b||""}`,style:g,"data-testid":E??D,children:e.jsx("svg",{width:s,height:d,className:"nice-treemap__svg",children:O.map((N,z)=>e.jsxs("g",{onClick:()=>r?.(N.node),style:{cursor:r?"pointer":void 0},children:[e.jsx("rect",{x:N.x,y:N.y,width:Math.max(N.w-1,0),height:Math.max(N.h-1,0),fill:N.node.color??i[z%i.length],rx:2}),N.w>40&&N.h>20&&e.jsx("text",{x:N.x+N.w/2,y:N.y+N.h/2,textAnchor:"middle",dominantBaseline:"central",fill:"var(--nice-color-white, #fff)",fontSize:Math.min(12,N.w/6),className:"nice-treemap__label",children:N.node.label})]},N.node.key))})})}),{displayName:"NiceTreeMap"}),ht=Object.freeze(Object.defineProperty({__proto__:null,NiceTreeMap:Oe},Symbol.toStringTag,{value:"Module"})),ut=[],Be=({regions:t=ut,width:s=600,height:d=400,viewBox:r="0 0 1000 600",colorRange:i=["#dbeafe","#1d4ed8"],maxValue:b,onRegionClick:g,selectedRegionId:S,title:D,showTooltip:E=!0,className:R,style:_,testId:O,"data-testid":N})=>{const z=b??Math.max(...t.map(w=>w.value??0),1),T=w=>{const l=o=>[parseInt(o.slice(1,3),16),parseInt(o.slice(3,5),16),parseInt(o.slice(5,7),16)],[x,A,L]=l(i[0]),[C,y,m]=l(i[1]),I=Math.round(x+(C-x)*w),a=Math.round(A+(y-A)*w),p=Math.round(L+(m-L)*w);return`rgb(${I},${a},${p})`};return e.jsxs("div",{className:`nice-vectormap ${R||""}`,style:_,"data-testid":N??O,children:[D&&e.jsx("div",{className:"nice-vectormap__title",children:D}),e.jsx("svg",{width:s,height:d,viewBox:r,children:t.map(w=>{const l=w.value!=null?Math.max(0,Math.min(1,w.value/z)):0,x=w.value!=null?T(l):"var(--nice-bg-tertiary, #e5e7eb)",A=w.id===S;return e.jsx("path",{d:w.path,fill:x,stroke:A?"var(--nice-color-primary, #3b82f6)":"var(--nice-border-color, #d1d5db)",strokeWidth:A?2:.5,cursor:g?"pointer":void 0,onClick:()=>g?.(w),children:E&&e.jsx("title",{children:`${w.name}${w.value!=null?`: ${w.value}`:""}`})},w.id)})})]})},ft=Object.freeze(Object.defineProperty({__proto__:null,NiceVectorMap:Be},Symbol.toStringTag,{value:"Module"})),xt=Object.assign(c.forwardRef(({data:t,renderNode:s,selectable:d,selectedKey:r,onSelect:i,direction:b="top-down",collapsible:g=!0,className:S,style:D,id:E,testId:R,"data-testid":_},O)=>{const{t:N}=de.useNiceTranslation(),z=de.useControlId(E),[T,w]=c.useState(new Set),l=c.useCallback(L=>{w(C=>{const y=new Set(C);return y.has(L)?y.delete(L):y.add(L),y})},[]),x=c.useCallback(L=>{d&&i?.(L)},[d,i]),A=c.useCallback(L=>{const C=T.has(L.key),y=L.children&&L.children.length>0;return e.jsxs("li",{className:"nice-org-chart__item",children:[e.jsxs("div",{tabIndex:d?0:void 0,onKeyDown:d?de.clickOnActivationKey:void 0,className:`nice-org-chart__node${r===L.key?" nice-org-chart__node--selected":""}`,onClick:()=>x(L.key),role:d?"button":void 0,children:[s?s(L):e.jsx("span",{children:L.label}),g&&y&&e.jsx("button",{type:"button",className:"nice-org-chart__toggle",onClick:m=>{m.stopPropagation(),l(L.key)},"aria-label":C?N("organizationChart.expand","Expand"):N("organizationChart.collapse","Collapse"),children:e.jsx(de.NiceIcon,{name:C?"plus":"minus",size:14})})]}),y&&!C&&e.jsx("ul",{className:"nice-org-chart__children",children:L.children.map(m=>A(m))})]},L.key)},[T,r,s,d,g,x,l,N]);return e.jsx("div",{ref:O,id:z,className:`nice-org-chart nice-org-chart--${b} ${S||""}`,style:D,"data-testid":_??R,children:e.jsx("ul",{className:"nice-org-chart__root",children:A(t)})})}),{displayName:"NiceOrganizationChart"}),mt=[],pt=Object.assign(c.forwardRef(({data:t=mt,type:s="candlestick",showVolume:d=!0,width:r=800,height:i=400,bullColor:b="var(--nice-color-success, #22c55e)",bearColor:g="var(--nice-color-error, #ef4444)",className:S,style:D,id:E,testId:R,"data-testid":_},O)=>{const N=de.useControlId(E),z={top:20,right:20,bottom:d?80:30,left:60},T=r-z.left-z.right,w=d?50:0,l=i-z.top-z.bottom-w,{minP:x,maxP:A,maxVol:L}=c.useMemo(()=>{if(t.length===0)return{minP:0,maxP:1,maxVol:0};let a=1/0,p=-1/0,o=0;for(const k of t)k.low<a&&(a=k.low),k.high>p&&(p=k.high),k.volume&&k.volume>o&&(o=k.volume);return{minP:a,maxP:p,maxVol:o}},[t]),C=Math.max(1,T/t.length*.7),y=a=>z.left+(a+.5)*(T/t.length),m=a=>z.top+l-(a-x)/(A-x||1)*l,I=a=>i-z.bottom-w+w*(1-a/(L||1));return e.jsx("div",{ref:O,id:N,className:`nice-stock-chart ${S||""}`,style:D,"data-testid":_??R,children:e.jsxs("svg",{width:r,height:i,className:"nice-stock-chart__svg",children:[[0,.25,.5,.75,1].map(a=>{const p=x+a*(A-x);return e.jsxs("g",{children:[e.jsx("line",{x1:z.left,x2:r-z.right,y1:m(p),y2:m(p),stroke:"var(--nice-border, #e5e7eb)",strokeDasharray:"2,2"}),t.length>0&&e.jsx("text",{x:z.left-4,y:m(p)+4,textAnchor:"end",fontSize:10,fill:"var(--nice-text-secondary, #888)",children:p.toFixed(2)})]},a)}),s==="line"?e.jsx("polyline",{points:t.map((a,p)=>`${y(p)},${m(a.close)}`).join(" "),fill:"none",stroke:b,strokeWidth:1.5}):t.map((a,p)=>{const o=a.close>=a.open,k=o?b:g,f=y(p);if(s==="ohlc")return e.jsxs("g",{children:[e.jsx("line",{x1:f,x2:f,y1:m(a.high),y2:m(a.low),stroke:k,strokeWidth:1}),e.jsx("line",{x1:f-C/2,x2:f,y1:m(a.open),y2:m(a.open),stroke:k,strokeWidth:1.5}),e.jsx("line",{x1:f,x2:f+C/2,y1:m(a.close),y2:m(a.close),stroke:k,strokeWidth:1.5})]},p);const P=m(Math.max(a.open,a.close)),$=m(Math.min(a.open,a.close));return e.jsxs("g",{children:[e.jsx("line",{x1:f,x2:f,y1:m(a.high),y2:m(a.low),stroke:k,strokeWidth:1}),e.jsx("rect",{x:f-C/2,y:P,width:C,height:Math.max($-P,1),fill:o?"transparent":k,stroke:k,strokeWidth:1})]},p)}),d&&t.map((a,p)=>{if(!a.volume)return null;const o=a.close>=a.open;return e.jsx("rect",{x:y(p)-C/2,y:I(a.volume),width:C,height:i-z.bottom-I(a.volume),fill:o?b:g,opacity:.3},`v${p}`)}),t.map((a,p)=>p%Math.max(1,Math.floor(t.length/8))!==0?null:e.jsx("text",{x:y(p),y:i-z.bottom+w+14,textAnchor:"middle",fontSize:9,fill:"var(--nice-text-secondary, #888)",children:a.date},`l${p}`))]})})}),{displayName:"NiceStockChart"}),gt=[],vt=({data:t=gt,width:s=120,height:d=30,type:r="line",color:i="var(--nice-color-primary, #3b82f6)",showMinMax:b,showLastPoint:g=!0,className:S,style:D,testId:E,"data-testid":R})=>{if(t.length===0)return null;const _=2,O=Math.min(...t),N=Math.max(...t),z=N-O||1,T=s-_*2,w=d-_*2,l=m=>_+m/(t.length-1||1)*T,x=m=>_+w-(m-O)/z*w;if(r==="bar"){const m=Math.max(1,T/t.length-1);return e.jsx("svg",{width:s,height:d,className:`nice-sparkline ${S||""}`,style:D,"data-testid":R??E,children:t.map((I,a)=>e.jsx("rect",{x:_+a/t.length*T,y:x(I),width:m,height:w-(x(I)-_),fill:i,rx:1},a))})}const A=t.map((m,I)=>`${l(I)},${x(m)}`).join(" "),L=t.indexOf(O),C=t.indexOf(N),y=t.length-1;return e.jsxs("svg",{width:s,height:d,className:`nice-sparkline ${S||""}`,style:D,"data-testid":R??E,children:[r==="area"&&e.jsx("polygon",{points:`${l(0)},${_+w} ${A} ${l(y)},${_+w}`,fill:i,opacity:.15}),e.jsx("polyline",{points:A,fill:"none",stroke:i,strokeWidth:1.5}),b&&e.jsx("circle",{cx:l(L),cy:x(O),r:2,fill:"var(--nice-danger, #ef4444)"}),b&&e.jsx("circle",{cx:l(C),cy:x(N),r:2,fill:"var(--nice-success, #22c55e)"}),g&&e.jsx("circle",{cx:l(y),cy:x(t[y]),r:2,fill:i})]})},yt=[],bt=[],_t=({series:t=yt,categories:s=bt,width:d=400,height:r=400,maxValue:i,title:b,showLegend:g=!0,className:S,style:D,testId:E,"data-testid":R})=>{const _=b?44:0,O=r-(g?30:0)-_,N=d/2,z=_+O/2,T=Math.min(N,O/2)-60,w=s.length,l=i??Math.max(...t.flatMap(C=>C.data),1),x=Math.PI*2/w,A=5,L=(C,y)=>{const m=C*x-Math.PI/2,I=y/l*T;return{x:N+I*Math.cos(m),y:z+I*Math.sin(m)}};return e.jsx("div",{className:`nice-polarchart ${S||""}`,style:D,"data-testid":R??E,children:e.jsxs("svg",{width:d,height:r,className:"nice-polarchart__svg",children:[b&&e.jsx("text",{x:N,y:20,textAnchor:"middle",className:"nice-chart__title",children:b}),Array.from({length:A},(C,y)=>{const m=T*((y+1)/A);return e.jsx("circle",{cx:N,cy:z,r:m,fill:"none",stroke:"var(--nice-border-color, #ddd)",strokeWidth:.5},y)}),s.map((C,y)=>{const m=L(y,l),I=L(y,l*1.22),a=y*x-Math.PI/2,p=Math.cos(a),o=Math.sin(a),k=p>.2?"start":p<-.2?"end":"middle",f=o>.2?"hanging":o<-.2?"auto":"middle";return e.jsxs("g",{children:[e.jsx("line",{x1:N,y1:z,x2:m.x,y2:m.y,stroke:"var(--nice-border-color, #ddd)",strokeWidth:.5}),e.jsx("text",{x:I.x,y:I.y,textAnchor:k,dominantBaseline:f,className:"nice-chart__axis-label nice-chart__axis-label--polar",children:C})]},y)}),t.map((C,y)=>{const m=C.color||_e[y%_e.length],I=C.data.map((a,p)=>{const o=L(p,a);return`${o.x},${o.y}`}).join(" ");return e.jsxs("g",{children:[e.jsx("polygon",{points:I,fill:C.fill!==!1?m:"none",fillOpacity:.15,stroke:m,strokeWidth:2}),C.data.map((a,p)=>{const o=L(p,a);return e.jsx("circle",{cx:o.x,cy:o.y,r:3,fill:m,children:e.jsx("title",{children:`${C.name} - ${s[p]}: ${a}`})},p)})]},C.name)}),g&&e.jsx("g",{transform:`translate(10, ${r-25})`,children:t.map((C,y)=>e.jsxs("g",{transform:`translate(${y*100}, 0)`,children:[e.jsx("rect",{width:10,height:10,rx:2,fill:C.color||_e[y%_e.length]}),e.jsx("text",{x:14,y:9,className:"nice-chart__legend-text",children:C.name})]},y))})]})})},jt=({data:t,min:s,max:d,start:r,end:i,onChange:b,width:g=500,height:S=100,step:D=1,formatValue:E,chartColor:R="var(--nice-color-primary, #3b82f6)",className:_,style:O,testId:N,"data-testid":z})=>{const T={top:10,bottom:30,left:10,right:10},w=g-T.left-T.right,l=S-T.top-T.bottom,x=I=>T.left+(I-s)/(d-s||1)*w,A=I=>{const a=Math.max(0,Math.min(1,(I-T.left)/w)),p=s+a*(d-s);return Math.round(p/D)*D},L=(I,a)=>{a.preventDefault();const p=a.target.closest("svg");if(!p)return;const o=f=>{const P=p.getBoundingClientRect(),$=A(f.clientX-P.left);I==="start"?b(Math.min($,i),i):b(r,Math.max($,r))},k=()=>{document.removeEventListener("pointermove",o),document.removeEventListener("pointerup",k)};document.addEventListener("pointermove",o),document.addEventListener("pointerup",k)},C=t?Math.min(...t):0,m=(t?Math.max(...t):1)-C||1;return e.jsx("div",{className:`nice-rangeselector ${_||""}`,style:O,"data-testid":z??N,children:e.jsxs("svg",{width:g,height:S,children:[t&&t.length>1&&e.jsx("polygon",{points:`${T.left},${T.top+l} ${t.map((I,a)=>`${T.left+a/(t.length-1)*w},${T.top+l-(I-C)/m*l}`).join(" ")} ${T.left+w},${T.top+l}`,fill:R,opacity:.15}),e.jsx("rect",{x:x(r),y:T.top,width:x(i)-x(r),height:l,fill:R,opacity:.1}),e.jsx("rect",{x:T.left,y:T.top,width:x(r)-T.left,height:l,fill:"var(--nice-bg-secondary, #f5f5f5)",opacity:.6}),e.jsx("rect",{x:x(i),y:T.top,width:T.left+w-x(i),height:l,fill:"var(--nice-bg-secondary, #f5f5f5)",opacity:.6}),e.jsx("rect",{x:x(r)-4,y:T.top,width:8,height:l,fill:R,rx:2,cursor:"ew-resize",onPointerDown:I=>L("start",I)}),e.jsx("rect",{x:x(i)-4,y:T.top,width:8,height:l,fill:R,rx:2,cursor:"ew-resize",onPointerDown:I=>L("end",I)}),e.jsx("text",{x:x(r),y:T.top+l+18,textAnchor:"middle",className:"nice-chart__axis-label",children:E?E(r):r}),e.jsx("text",{x:x(i),y:T.top+l+18,textAnchor:"middle",className:"nice-chart__axis-label",children:E?E(i):i})]})})},Mt=`
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
- `,De=["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 be(t){return t instanceof Date?t:new Date(t)}function Te(t,s="pl-PL"){return t.toLocaleDateString(s,{year:"numeric",month:"short",day:"numeric"})}function Ce(t,s="pl-PL"){return new Intl.NumberFormat(s,{minimumFractionDigits:0,maximumFractionDigits:2}).format(t)}const Nt={top:20,right:30,bottom:40,left:60},wt=c.forwardRef(function(s,d){const{t:r}=de.useNiceTranslation(),{scenarios:i,data:b,annotations:g=[],referenceLines:S=[],forecastStartDate:D,cashRunway:E,xAxis:R,yAxis:_,confidenceBands:O=[{level:95,color:"var(--nice-color-primary, #3b82f6)",opacity:.15}],tooltip:N,legend:z={enabled:!0,position:"bottom",interactive:!0},height:T=350,showForecastRegion:w=!0,lineWidth:l=2,showPoints:x=!1,pointRadius:A=4,enableZoom:L=!1,zoomEnabled:C,animationDuration:y=300,showLegend:m,responsive:I=!0,onPointClick:a,onAnnotationClick:p,onScenarioToggle:o,onViewportChange:k,size:f="medium",disabled:P=!1,labels:$={},locale:H="pl-PL",className:ee,style:Y,testId:q,"data-testid":Z}=s,U=i&&i.length>0?i:b?[{id:"default",name:"Series",data:b}]:[],v={...z,enabled:m??z.enabled},[V,te]=c.useState(()=>U.map((n,W)=>({...n,color:n.color??De[W%De.length],visible:n.visible!==!1}))),[ce,ae]=c.useState(null),[he,F]=c.useState({x:0,y:0}),h=c.useRef(null),B=c.useRef(null),u=Nt,[X,fe]=c.useState({width:600,height:typeof T=="number"?T:350});c.useEffect(()=>{if(!I||!h.current)return;const n=new ResizeObserver(W=>{for(const K of W)fe(M=>({width:K.contentRect.width,height:M.height}))});return n.observe(h.current),()=>n.disconnect()},[I]),c.useEffect(()=>{const n="nice-forecast-chart-styles";if(!document.getElementById(n)){const W=document.createElement("style");W.id=n,W.textContent=Mt,document.head.appendChild(W)}},[]);const{xScale:G,yScale:se,allDates:ue,minY:ve,maxY:Ne}=c.useMemo(()=>{const W=V.filter(pe=>pe.visible!==!1).flatMap(pe=>pe.data);if(W.length===0)return{xScale:()=>0,yScale:()=>0,allDates:[],minY:0,maxY:100};const K=W.map(pe=>be(pe.date).getTime()),M=Math.min(...K),J=Math.max(...K),re=W.flatMap(pe=>[pe.value,pe.forecast,pe.lowerBound,pe.upperBound]).filter(pe=>pe!=null),ie=_?.min??Math.min(...re)*.95,le=_?.max??Math.max(...re)*1.05,me=X.width-u.left-u.right,ge=X.height-u.top-u.bottom,ke=pe=>{const Re=typeof pe=="number"?pe:pe.getTime();return u.left+(Re-M)/(J-M)*me},Se=pe=>u.top+ge-(pe-ie)/(le-ie)*ge,Ie=[...new Set(K)].sort((pe,Re)=>pe-Re).map(pe=>new Date(pe));return{xScale:ke,yScale:Se,allDates:Ie,minY:ie,maxY:le}},[V,X,u,_]),ye=D?be(D):null,Me=c.useMemo(()=>{if(!E?.enabled)return null;const n=E.threshold??0,W=E.scenarioId?V.find(M=>M.id===E.scenarioId&&M.visible!==!1):V.find(M=>M.visible!==!1);if(!W)return null;const K=W.data.sort((M,J)=>be(M.date).getTime()-be(J.date).getTime());for(let M=1;M<K.length;M++){const J=K[M-1],re=K[M],ie=J.forecast??J.value,le=re.forecast??re.value;if(ie!=null&&le!=null&&ie>n&&le<=n){const me=(ie-n)/(ie-le),ge=be(J.date).getTime(),ke=be(re.date).getTime(),Se=ge+me*(ke-ge);return new Date(Se)}}return null},[E,V]),we=c.useCallback((n,W)=>{const K=n.filter(M=>M[W]!=null).map(M=>({x:G(be(M.date)),y:se(M[W])}));return K.length===0?"":`M ${K.map(M=>`${M.x},${M.y}`).join(" L ")}`},[G,se]),ne=c.useCallback(n=>{const W=n.filter(J=>J.lowerBound!=null&&J.upperBound!=null);if(W.length===0)return"";const K=W.map(J=>({x:G(be(J.date)),y:se(J.upperBound)})),M=W.map(J=>({x:G(be(J.date)),y:se(J.lowerBound)})).reverse();return`M ${K.map(J=>`${J.x},${J.y}`).join(" L ")} L ${M.map(J=>`${J.x},${J.y}`).join(" L ")} Z`},[G,se]),oe=c.useCallback(n=>{if(!B.current||N?.enabled===!1)return;const W=B.current.getBoundingClientRect(),K=n.clientX-W.left;n.clientY-W.top;let M=null,J=1/0;for(const re of ue){const ie=G(re),le=Math.abs(ie-K);le<J&&(J=le,M=re)}if(M&&J<50){const re=V.filter(le=>le.visible!==!1).map(le=>{const me=le.data.find(ge=>be(ge.date).getTime()===M.getTime());return{scenario:le,value:me?.value,forecast:me?.forecast,lowerBound:me?.lowerBound,upperBound:me?.upperBound}}),ie=g.filter(le=>Math.abs(be(le.date).getTime()-M.getTime())<864e5);ae({date:M,values:re,annotations:ie}),F({x:n.clientX-W.left+10,y:n.clientY-W.top-10})}else ae(null)},[G,ue,V,g,N]),xe=c.useCallback(n=>{if(!v.interactive)return;te(K=>K.map(M=>M.id===n?{...M,visible:!M.visible}:M));const W=V.find(K=>K.id===n);W&&o?.(n,!W.visible)},[v.interactive,V,o]);c.useImperativeHandle(d,()=>({getScenarios:()=>V,updateScenario:(n,W)=>{te(K=>K.map(M=>M.id===n?{...M,data:W}:M))},toggleScenario:xe,setZoomRange:()=>{},resetZoom:()=>{},exportImage:n=>{if(!B.current)return null;const W=B.current,M=new XMLSerializer().serializeToString(W);return`data:image/svg+xml;base64,${btoa(M)}`},getDataAtDate:n=>{const W=V.filter(K=>K.visible!==!1).map(K=>{const M=K.data.find(J=>be(J.date).getTime()===n.getTime());return{scenario:K,value:M?.value,forecast:M?.forecast,lowerBound:M?.lowerBound,upperBound:M?.upperBound}});return{date:n,values:W,annotations:g.filter(K=>be(K.date).getTime()===n.getTime())}}}),[V,g,xe]),X.width-u.left-u.right;const je=X.height-u.top-u.bottom,j=c.useMemo(()=>{const n=_?.tickCount??5,W=[],K=(Ne-ve)/(n-1);for(let M=0;M<n;M++)W.push(ve+K*M);return W},[ve,Ne,_?.tickCount]),Q=c.useMemo(()=>{const n=R?.tickCount??6;if(ue.length===0)return[];const W=Math.max(1,Math.floor(ue.length/(n-1)));return ue.filter((K,M)=>M%W===0||M===ue.length-1)},[ue,R?.tickCount]);return V.length===0||V.every(n=>n.data.length===0)?e.jsx("div",{className:`nice-forecast-chart ${ee??""}`,style:Y,"data-testid":Z??q,children:e.jsx("div",{className:"nice-forecast-chart__empty",children:$.noData??r("forecastChart.noDataAvailable","No data available")})}):e.jsxs("div",{className:`nice-forecast-chart ${ee??""}`,style:{...Y,height:T},"data-testid":Z??q,children:[e.jsxs("div",{ref:h,className:"nice-forecast-chart__container",children:[e.jsxs("svg",{ref:B,className:"nice-forecast-chart__svg",width:X.width,height:X.height,onMouseMove:oe,onMouseLeave:()=>ae(null),children:[_?.showGrid!==!1&&j.map(n=>e.jsx("line",{className:"nice-forecast-chart__grid-line",x1:u.left,x2:X.width-u.right,y1:se(n),y2:se(n)},n)),w&&ye&&e.jsx("rect",{className:"nice-forecast-chart__forecast-region",x:G(ye),y:u.top,width:X.width-u.right-G(ye),height:je}),S.map(n=>e.jsxs("g",{children:[e.jsx("line",{className:"nice-forecast-chart__reference-line",x1:u.left,x2:X.width-u.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:X.width-u.right-4,y:se(n.value)-4,textAnchor:"end",children:n.label})]},n.id)),Me&&E?.enabled&&e.jsxs("g",{className:"nice-forecast-chart__cash-runway",children:[e.jsx("line",{className:"nice-forecast-chart__cash-runway-line",x1:G(Me),x2:G(Me),y1:u.top,y2:X.height-u.bottom,stroke:E.color??"var(--nice-color-error, #ef4444)"}),E.showLabel!==!1&&e.jsxs(e.Fragment,{children:[e.jsx("rect",{className:"nice-forecast-chart__cash-runway-label-bg",x:G(Me)-60,y:u.top-2,width:120,height:E.showDate!==!1?32:20,fill:E.color??"var(--nice-color-error, #ef4444)",rx:4}),e.jsx("text",{className:"nice-forecast-chart__cash-runway-label",x:G(Me),y:u.top+12,textAnchor:"middle",fill:"var(--nice-color-white, #fff)",children:E.label??$.cashRunsOut??r("forecastChart.cashRunsOut","Cash runs out")}),E.showDate!==!1&&e.jsx("text",{className:"nice-forecast-chart__cash-runway-label",x:G(Me),y:u.top+26,textAnchor:"middle",fill:"var(--nice-color-white, #fff)",style:{fontSize:"0.625rem",opacity:.9},children:Te(Me,H)})]})]}),V.filter(n=>n.visible!==!1&&n.showConfidenceBand).map(n=>e.jsx("path",{className:"nice-forecast-chart__confidence-band",d:ne(n.data),fill:n.color},`band-${n.id}`)),V.filter(n=>n.visible!==!1).map(n=>{const W=ye?n.data.filter(M=>be(M.date)<ye):n.data.filter(M=>M.value!=null),K=ye?n.data.filter(M=>be(M.date)>=ye):n.data.filter(M=>M.forecast!=null);return e.jsxs("g",{children:[e.jsx("path",{className:"nice-forecast-chart__historical-line",d:we(W,"value"),stroke:n.color,strokeWidth:l}),e.jsx("path",{className:"nice-forecast-chart__forecast-line",d:we(K,ye?"value":"forecast"),stroke:n.color,strokeWidth:l}),K.length>0&&n.data.some(M=>M.forecast!=null)&&e.jsx("path",{className:"nice-forecast-chart__forecast-line",d:we(n.data,"forecast"),stroke:n.color,strokeWidth:l}),x&&n.data.map((M,J)=>{const re=M.value??M.forecast;return re==null?null:e.jsx("circle",{className:"nice-forecast-chart__point",cx:G(be(M.date)),cy:se(re),r:A,fill:n.color,onClick:()=>a?.(M,n)},J)})]},n.id)}),g.map(n=>{const W=G(be(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:W,x2:W,y1:u.top,y2:X.height-u.bottom,stroke:n.color??"var(--nice-text-muted, #9ca3af)"}),e.jsx("circle",{cx:W,cy:u.top+10,r:8,fill:n.color??"var(--nice-text-muted, #9ca3af)"}),e.jsx("text",{x:W,y:u.top+14,textAnchor:"middle",fill:"white",fontSize:"10",children:n.icon??"!"})]},n.id)}),e.jsx("line",{className:"nice-forecast-chart__axis-line",x1:u.left,x2:u.left,y1:u.top,y2:X.height-u.bottom}),e.jsx("line",{className:"nice-forecast-chart__axis-line",x1:u.left,x2:X.width-u.right,y1:X.height-u.bottom,y2:X.height-u.bottom}),j.map(n=>e.jsx("text",{className:"nice-forecast-chart__axis-label",x:u.left-8,y:se(n)+4,textAnchor:"end",children:_?.format?_.format(n):Ce(n,H)},n)),Q.map(n=>e.jsx("text",{className:"nice-forecast-chart__axis-label",x:G(n),y:X.height-u.bottom+16,textAnchor:"middle",children:R?.format?R.format(n):Te(n,H)},n.getTime())),_?.title&&e.jsx("text",{className:"nice-forecast-chart__axis-title",x:15,y:X.height/2,textAnchor:"middle",transform:`rotate(-90, 15, ${X.height/2})`,children:_.title})]}),ce&&e.jsxs("div",{className:"nice-forecast-chart__tooltip",style:{left:he.x,top:he.y},children:[e.jsx("div",{className:"nice-forecast-chart__tooltip-date",children:Te(ce.date,H)}),ce.values.map(n=>{const W=n.value??n.forecast;return W==null?null:e.jsxs("div",{className:"nice-forecast-chart__tooltip-item",children:[e.jsx("span",{className:"nice-forecast-chart__tooltip-color",style:{background:n.scenario.color}}),e.jsx("span",{className:"nice-forecast-chart__tooltip-label",children:n.scenario.name}),e.jsx("span",{className:"nice-forecast-chart__tooltip-value",children:Ce(W,H)})]},n.scenario.id)}),ce.values.some(n=>n.lowerBound!=null)&&e.jsxs("div",{className:"nice-forecast-chart__tooltip-confidence",children:[$.confidence??r("forecastChart.ci","CI"),":"," ",Ce(ce.values[0]?.lowerBound??0,H)," –"," ",Ce(ce.values[0]?.upperBound??0,H)]})]})]}),v.enabled&&e.jsx("div",{className:"nice-forecast-chart__legend",children:V.map(n=>e.jsxs("div",{role:"button",tabIndex:0,"aria-pressed":n.visible!==!1,onKeyDown:de.clickOnActivationKey,className:`nice-forecast-chart__legend-item ${n.visible===!1?"nice-forecast-chart__legend-item--hidden":""}`,onClick:()=>xe(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))})]})}),kt=[];function $t(t,s){const d=t?typeof t=="number"?new Date(t):new Date(t):new Date,r=D=>D.toString().padStart(2,"0"),i=r(d.getHours()),b=r(d.getMinutes()),g=r(d.getSeconds()),S=d.getMilliseconds().toString().padStart(3,"0");switch(s){case"HH:mm:ss":return`${i}:${b}:${g}`;case"HH:mm":return`${i}:${b}`;case"mm:ss":return`${b}:${g}`;case"ss.SSS":return`${g}.${S}`;case"ISO":return d.toISOString();default:return`${i}:${b}:${g}`}}function Ee(t){if(t.length===0)return null;const s=Math.min(...t),d=Math.max(...t),r=t.reduce((b,g)=>b+g,0)/t.length,i=t[t.length-1];return{min:s,max:d,avg:r,current:i,count:t.length}}const St=Object.assign(c.forwardRef(({series:t=kt,maxPoints:s=100,slidingWindow:d=!0,refreshRate:r=16,dataSource:i,width:b=600,height:g=400,title:S,showLegend:D=!0,showGrid:E=!0,yAxisLabel:R,xAxisLabel:_,stacked:O,zoomable:N,crosshair:z,annotations:T=[],legendInteractive:w,onDataPointClick:l,exportable:x,showControls:A=!0,showStatus:L=!0,initialPaused:C=!1,onDataReceived:y,onDataDropped:m,timeFormat:I="HH:mm:ss",showStats:a,thresholds:p=[],className:o,style:k,testId:f,"data-testid":P},$)=>{const[H,ee]=c.useState(()=>{const ne=new Map;for(const oe of t)ne.set(oe.name,oe.initialData?.slice()??[]);return ne}),[Y,q]=c.useState([]),{t:Z}=de.useNiceTranslation(),[U,v]=c.useState(C),[V,te]=c.useState(!1),ce=c.useRef([]),ae=c.useRef(Date.now()),he=c.useRef(null),F=c.useRef(new Map),h=c.useRef(0),B=JSON.stringify(t.map(ne=>ne.name)),u=c.useMemo(()=>new Set(JSON.parse(B)),[B]),X=c.useRef(U),fe=c.useRef(y),G=c.useRef(m);c.useEffect(()=>{X.current=U,fe.current=y,G.current=m});const se=c.useRef(null);se.current===null&&(se.current=new Map(t.map(ne=>[ne.name,ne.initialData?.length??0])));const ue=c.useCallback(()=>{const ne=ce.current;if(ne.length===0)return;ce.current=[];const oe=se.current??new Map,xe=[];for(const j of ne){const Q=oe.get(j.series);Q!==void 0&&(d&&Q+1>s?(xe.push([j.series,Q+1-s]),oe.set(j.series,s)):oe.set(j.series,Q+1))}ee(j=>{const Q=new Map(j);for(const n of ne){const W=Q.get(n.series);if(!W)continue;const K=[...W,n.value];d&&K.length>s&&K.splice(0,K.length-s),Q.set(n.series,K)}return Q});for(const[j,Q]of xe)G.current?.(Q,j);const je=[];for(const j of ne){if(!u.has(j.series))continue;const Q=(F.current.get(j.series)??0)+1;F.current.set(j.series,Q),Q>h.current&&(h.current=Q,je.push(j.category??$t(j.timestamp,I)))}je.length>0&&q(j=>{const Q=[...j,...je];return d&&Q.length>s&&Q.splice(0,Q.length-s),Q})},[d,s,I,u]),ve=c.useCallback(()=>{const ne=Date.now();ne-ae.current>=r&&(ue(),ae.current=ne),he.current=requestAnimationFrame(ve)},[r,ue]);c.useEffect(()=>(U||(he.current=requestAnimationFrame(ve)),()=>{he.current!==null&&(cancelAnimationFrame(he.current),he.current=null)}),[U,ve]);const Ne=c.useCallback(ne=>{if(X.current)return;const oe="points"in ne?ne.points:[ne];for(const xe of oe)u.has(xe.series)&&(ce.current.push(xe),fe.current?.(xe))},[u]);c.useEffect(()=>{if(!i)return;const ne=i.subscribe(Ne);let oe;return i.onStatusChange?oe=i.onStatusChange(te):te(!0),i.fetchHistory&&i.fetchHistory(s).then(xe=>{for(const je of xe)ce.current.push(je);ue()}),()=>{ne(),oe?.()}},[i,Ne,s,ue]);const ye=c.useMemo(()=>t.map(ne=>({name:ne.name,color:ne.color,type:ne.type,data:H.get(ne.name)??[]})),[t,H]),Me=c.useMemo(()=>{const ne=[...T];for(const oe of p)ne.push({type:"line",value:oe.value,color:oe.color,label:oe.label,dash:oe.style==="dashed"?"5,5":oe.style==="dotted"?"2,2":void 0});return ne},[T,p]);c.useImperativeHandle($,()=>({pause(){v(!0)},resume(){v(!1)},isPaused(){return U},clear(){ee(oe=>{const xe=new Map(oe);for(const je of xe.keys())xe.set(je,[]);return xe}),q([]),F.current=new Map,h.current=0,ce.current=[];const ne=se.current;if(ne)for(const oe of ne.keys())ne.set(oe,0)},addPoint(ne){Ne(ne)},addPoints(ne){Ne({points:ne})},getData(ne){return H.get(ne)??[]},getCategories(){return Y},exportData(){return{series:ye,categories:Y}},getStats(ne){const oe=H.get(ne);return oe?Ee(oe):null}}),[U,H,Y,ye,Ne]);const we=c.useMemo(()=>{if(!a)return null;const ne={};for(const[oe,xe]of H)ne[oe]=Ee(xe);return ne},[a,H]);return e.jsxs("div",{className:o,style:{position:"relative",...k},"data-testid":P??f,children:[L&&e.jsxs("div",{style:{position:"absolute",top:8,right:8,display:"flex",alignItems:"center",gap:4,fontSize:12,color:V?"var(--nice-color-success, #22c55e)":"var(--nice-color-error, #ef4444)",zIndex:10},children:[e.jsx("span",{style:{width:8,height:8,borderRadius:"50%",backgroundColor:V?"var(--nice-color-success, #22c55e)":"var(--nice-color-error, #ef4444)"}}),V?Z("charts.live","Live"):Z("charts.disconnected","Disconnected")]}),A&&e.jsx("div",{style:{position:"absolute",top:8,left:8,display:"flex",gap:4,zIndex:10},children:e.jsx("button",{onClick:()=>v(ne=>!ne),style:{padding:"4px 8px",fontSize:12,border:"1px solid var(--nice-border-color, #ddd)",borderRadius:4,background:U?"var(--nice-warning-bg, #fef3c7)":"var(--nice-bg-primary, #fff)",color:"var(--nice-text-primary, #0f172a)",cursor:"pointer"},title:U?Z("charts.resume","Resume"):Z("charts.pause","Pause"),"aria-label":U?Z("charts.resume","Resume"):Z("charts.pause","Pause"),children:e.jsx(de.NiceIcon,{name:U?"play":"pause",size:14})})}),a&&we&&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(we).map(([ne,oe])=>oe?e.jsxs("div",{style:{marginBottom:4},children:[e.jsx("strong",{children:ne}),e.jsxs("div",{children:[Z("charts.stats.min","Min"),": ",oe.min.toFixed(2)," |"," ",Z("charts.stats.max","Max"),": ",oe.max.toFixed(2)]}),e.jsxs("div",{children:[Z("charts.stats.avg","Avg"),": ",oe.avg.toFixed(2)," |"," ",Z("charts.stats.now","Now"),": ",oe.current.toFixed(2)]})]},ne):null)}),e.jsx(Ae,{series:ye,categories:Y,width:b,height:g,title:S,showLegend:D,showGrid:E,yAxisLabel:R,xAxisLabel:_,stacked:O,zoomable:N,crosshair:z,annotations:Me,legendInteractive:w,onDataPointClick:l,exportable:x})]})}),{displayName:"NiceLiveChart"});function Ct(t){const{hubConnection:s,eventName:d="DataPoint",subscribeMethod:r="SubscribeToMetrics",historyMethod:i="GetMetricHistory",metricName:b}=t;return{subscribe(g){const S=D=>{g(D)};return s.on(d,S),s.state==="Connected"&&s.invoke(r,b).catch(()=>{}),()=>{s.off(d,S)}},async fetchHistory(g){try{return await s.invoke(i,b,g)}catch{return[]}},onStatusChange(g){const S=()=>g(s.state==="Connected");return s.onclose(()=>g(!1)),s.onreconnected(()=>g(!0)),S(),()=>{}}}}function At(t){const{url:s,autoReconnect:d=!0,reconnectDelay:r=3e3,parseMessage:i=R=>JSON.parse(R)}=t;let b=null,g=null,S=null,D=null;const E=()=>{b=new WebSocket(s),b.onopen=()=>{g?.(!0)},b.onclose=()=>{g?.(!1),d&&(D=setTimeout(E,r))},b.onerror=()=>{b?.close()},b.onmessage=R=>{try{const _=i(R.data);_&&S&&S(_)}catch{}}};return{subscribe(R){return S=R,E(),()=>{S=null,D&&clearTimeout(D),b?.close(),b=null}},onStatusChange(R){return g=R,()=>{g=null}}}}function It(t){const{seriesNames:s,interval:d=1e3,generateValue:r=()=>Math.random()*100}=t;let i=null,b=0;return{subscribe(g){return i=setInterval(()=>{for(const S of s)g({series:S,value:r(S,b),timestamp:Date.now()});b++},d),()=>{i&&clearInterval(i)}},onStatusChange(g){return g(!0),()=>{}}}}const Rt=[];function Tt(t){if(!t.length)return{categories:[],numericFields:[],sampleValues:{}};const s=t[0],d=[],r={};let i=null;for(const[g,S]of Object.entries(s))typeof S=="number"?(d.push(g),r[g]=t.map(D=>Number(D[g])||0)):!i&&(typeof S=="string"||S instanceof Date)&&(i=g);return{categories:i?t.map(g=>String(g[i]||"")):t.map((g,S)=>`Item ${S+1}`),numericFields:d,sampleValues:r}}function zt(t,s){const{categories:d,numericFields:r,sampleValues:i}=Tt(t);return{series:r.map((g,S)=>({name:g.replace(/([A-Z])/g," $1").replace(/^./,D=>D.toUpperCase()).trim(),data:i[g],type:s==="area"?"area":s==="line"?"line":"bar"})),categories:d}}const Lt=c.forwardRef(function(s,d){const{rawData:r,enableAI:i=!0,aiModel:b,enableAutoType:g=!0,enableInsights:S=!0,dataDescription:D,onChartSuggestion:E,onInsights:R,showAIToolbar:_=!0,showInsightsOnLoad:O=!1,series:N=Rt,categories:z,...T}=s,[w,l]=c.useState("bar"),[x,A]=c.useState(null),[L,C]=c.useState([]),[y,m]=c.useState(O),[I,a]=c.useState(null),{t:p}=Ye.useNiceTranslation(),o=de.useNiceAI(),{suggestChartType:k,generateInsights:f,isLoading:P}=de.useChartSuggestion(),$=i&&o.isConfigured,{series:H,categories:ee}=r?zt(r,I||w):{series:N||[],categories:z},Y=c.useCallback(async()=>{if(!$||!g)return{type:"bar",reason:"Default",config:{}};const V=r||(N?.length?N.flatMap(te=>te.data.map((ce,ae)=>({[te.name]:ce,index:ae}))):[]);try{const te=await k(V,D),ce={type:te.type,reason:te.reason,config:te.config};return A(ce),l(ce.type),E?.(ce),ce}catch{return{type:"bar",reason:"Default fallback",config:{}}}},[$,g,r,N,D,k,E]),q=c.useCallback(async()=>{if(!$||!S)return[];const V=r||(N?.length?N.flatMap(te=>te.data.map((ce,ae)=>({[te.name]:ce,category:z?.[ae]||ae}))):[]);try{const te=await f(V,I||w);return C(te),R?.(te),te}catch{return[]}},[$,S,r,N,z,w,I,f,R]),Z=c.useCallback(()=>I||w,[I,w]);c.useEffect(()=>{$&&g&&(r?.length||N?.length)&&Y()},[$,g,r,N]),c.useImperativeHandle(d,()=>({getSuggestion:Y,generateInsights:q,getCurrentType:Z}));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")}],v=I||w;return e.jsxs("div",{className:"nice-chart-ai","data-testid":s["data-testid"],children:[_&&$&&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")}),x&&e.jsxs("div",{className:"nice-chart-ai__suggestion",children:[e.jsx("span",{className:"nice-chart-ai__suggestion-icon",children:e.jsx(de.NiceIcon,{name:"lightbulb",size:14})}),e.jsxs("span",{className:"nice-chart-ai__suggestion-text",children:[p("chartAI.suggestedType","Suggested:")," ",x.type]}),e.jsxs("span",{className:"nice-chart-ai__suggestion-reason",title:x.reason,children:["(",x.reason,")"]})]}),P&&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(V=>["bar","line","area"].includes(V.type)).map(({type:V,icon:te,label:ce})=>e.jsx("button",{type:"button",className:`nice-chart-ai__type-btn ${v===V?"nice-chart-ai__type-btn--active":""}`,onClick:()=>a(V),title:ce,children:e.jsx(de.NiceIcon,{name:te,size:16})},V))})}),e.jsxs("div",{className:"nice-chart-ai__toolbar-right",children:[e.jsxs("button",{type:"button",className:"nice-chart-ai__auto-btn",onClick:()=>Y(),disabled:P,title:p("chartAI.autoDetect","Auto-detect best chart type"),children:[e.jsx(de.NiceIcon,{name:"zap",size:14})," ",p("chartAI.auto","Auto")]}),S&&e.jsxs("button",{type:"button",className:"nice-chart-ai__insights-btn",onClick:()=>{L.length||q(),m(!y)},disabled:P,title:p("chartAI.showInsights","Show data insights"),children:[e.jsx(de.NiceIcon,{name:"lightbulb",size:14})," ",p("chartAI.insights","Insights")]})]})]}),e.jsx("div",{className:"nice-chart-ai__chart-wrapper",children:e.jsx(Ae,{series:H,categories:ee,...T})}),y&&L.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(de.NiceIcon,{name:"lightbulb",size:14})," ",p("chartAI.dataInsights","Data Insights")]}),e.jsx("button",{type:"button",className:"nice-chart-ai__insights-close",onClick:()=>m(!1),"aria-label":p("chartAI.close","Close"),children:e.jsx(de.NiceIcon,{name:"close",size:14})})]}),e.jsx("ul",{className:"nice-chart-ai__insights-list",children:L.map((V,te)=>e.jsxs("li",{className:"nice-chart-ai__insight",children:[e.jsx("span",{className:"nice-chart-ai__insight-icon",children:"•"}),V]},te))}),e.jsx("div",{className:"nice-chart-ai__insights-footer",children:e.jsxs("button",{type:"button",className:"nice-chart-ai__refresh",onClick:()=>q(),disabled:P,children:[e.jsx(de.NiceIcon,{name:"refresh",size:14})," ",p("chartAI.refresh","Refresh")]})})]}),y&&P&&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...")]})})]})}),Dt=[],Et=[],Pt=[],We=["var(--nice-color-primary, #3b82f6)","var(--nice-color-error, #ef4444)","var(--nice-color-success, #22c55e)","var(--nice-color-warning, #f59e0b)","var(--nice-color-accent, #8b5cf6)","var(--nice-color-accent-pink, #ec4899)","var(--nice-color-info, #06b6d4)","var(--nice-color-success, #10b981)","var(--nice-color-warning, #f59e0b)","var(--nice-color-accent, #6366f1)"],Ot=Object.assign(c.forwardRef((t,s)=>{const{t:d}=de.useNiceTranslation(),{levels:r=Pt,initialLevelId:i,levelId:b,chartType:g="bar",width:S=600,height:D=400,showBreadcrumbs:E=!0,showBackButton:R=!0,animationDuration:_=300,onLevelChange:O,onItemClick:N,colors:z=We,showValues:T=!0,showLegend:w=!0,className:l,style:x,testId:A,"data-testid":L,...C}=t,y=b!==void 0,[m,I]=c.useState(i||r[0]?.id),[a,p]=c.useState([i||r[0]?.id]),o=c.useCallback(F=>{const h=[];let B=r.find(u=>u.id===F);for(;B&&!h.includes(B.id);){h.unshift(B.id);const u=B.parentId;B=u?r.find(X=>X.id===u):void 0}return h.length>0?h:[F]},[r]),k=b??m,f=c.useMemo(()=>b!==void 0?o(b):a,[b,a,o]),[P,$]=c.useState(!1),[H,ee]=c.useState("in"),Y=c.useMemo(()=>r.find(F=>F.id===k),[r,k]),q=c.useCallback(F=>{r.find(B=>B.id===F)&&(ee("in"),$(!0),setTimeout(()=>{y||(I(F),p(B=>[...B,F])),O?.(F,y?o(F):[...f,F]),$(!1)},_/2))},[r,f,_,O,y,o]),Z=c.useCallback(()=>{if(f.length<=1)return;ee("out"),$(!0);const F=f.slice(0,-1),h=F[F.length-1];setTimeout(()=>{y||(I(h),p(F)),O?.(h,F),$(!1)},_/2)},[f,_,O,y]),U=c.useCallback(()=>{const F=r[0]?.id;F&&(ee("out"),$(!0),setTimeout(()=>{y||(I(F),p([F])),O?.(F,[F]),$(!1)},_/2))},[r,_,O,y]);c.useImperativeHandle(s,()=>({drillDown:q,drillUp:Z,resetToRoot:U,getCurrentLevel:()=>k,getPath:()=>f}),[q,Z,U,k,f]);const v=c.useCallback((F,h)=>{N?.(F,k);const B=r.find(u=>u.parentId===k&&u.id===F.metadata?.childLevelId);B&&q(B.id)},[k,r,q,N]),V=c.useMemo(()=>Y?.data.reduce((F,h)=>F+h.value,0)||0,[Y]),te=c.useMemo(()=>f.map(F=>r.find(h=>h.id===F)?.label||F),[f,r]),ce=()=>{if(!Y)return null;const F=Y.data,h=Math.max(...F.map(u=>u.value)),B=Math.min(40,(D-100)/F.length-8);return e.jsx("div",{className:"nice-drilldown-bars",children:F.map((u,X)=>{const fe=u.value/h*100;return e.jsxs("div",{role:"button",tabIndex:0,onKeyDown:de.clickOnActivationKey,className:"nice-drilldown-bar-row",onClick:()=>v(u,X),children:[e.jsx("span",{className:"nice-drilldown-bar-label",children:u.label||d("charts.item","Item {i}").replace("{i}",String(X+1))}),e.jsx("div",{className:"nice-drilldown-bar-track",children:e.jsx("div",{className:"nice-drilldown-bar-fill",style:{width:`${fe}%`,backgroundColor:u.color||z[X%z.length],height:B}})}),T&&e.jsx("span",{className:"nice-drilldown-bar-value",children:u.value.toLocaleString()})]},X)})})},ae=()=>{if(!Y)return null;const F=Y.data,h=S/2,B=(D-60)/2+30,u=Math.min(h,B)-40;let X=-90;const fe=F.map((G,se)=>{const ue=G.value/V*360,ve=X+ue,Ne=ue>180?1:0,ye=X*Math.PI/180,Me=ve*Math.PI/180,we=h+u*Math.cos(ye),ne=B+u*Math.sin(ye),oe=h+u*Math.cos(Me),xe=B+u*Math.sin(Me),je=(X+ue/2)*Math.PI/180,j=h+u*.7*Math.cos(je),Q=B+u*.7*Math.sin(je),n=`M ${h} ${B} L ${we} ${ne} A ${u} ${u} 0 ${Ne} 1 ${oe} ${xe} Z`;return X=ve,{path:n,color:G.color||z[se%z.length],label:G.label||d("charts.item","Item {i}").replace("{i}",String(se+1)),value:G.value,percentage:(G.value/V*100).toFixed(1),labelX:j,labelY:Q,item:G,index:se}});return e.jsx("svg",{width:S,height:D-40,className:"nice-drilldown-pie",children:e.jsx("g",{children:fe.map((G,se)=>e.jsxs("g",{onClick:()=>v(G.item,G.index),children:[e.jsx("path",{d:G.path,fill:G.color,stroke:"white",strokeWidth:2,className:"nice-drilldown-pie-slice"}),T&&parseFloat(G.percentage)>5&&e.jsxs("text",{x:G.labelX,y:G.labelY,textAnchor:"middle",dominantBaseline:"middle",fill:"white",fontSize:"12",fontWeight:"600",children:[G.percentage,"%"]})]},se))})})},he=()=>{if(!Y)return null;const F=Y.data,h=Math.max(...F.map(X=>X.value)),B=Math.min(60,(S-100)/F.length-8),u=D-100;return e.jsx("svg",{width:S,height:D-40,className:"nice-drilldown-columns",children:e.jsxs("g",{transform:"translate(50, 20)",children:[[0,.25,.5,.75,1].map((X,fe)=>e.jsxs("g",{children:[e.jsx("line",{x1:0,y1:u*(1-X),x2:S-80,y2:u*(1-X),stroke:"var(--nice-border-color, #e5e7eb)",strokeDasharray:X===0?void 0:"4"}),e.jsx("text",{x:-8,y:u*(1-X),textAnchor:"end",dominantBaseline:"middle",fontSize:"11",fill:"var(--nice-text-secondary, #6b7280)",children:Math.round(h*X).toLocaleString()})]},fe)),F.map((X,fe)=>{const G=X.value/h*u,se=fe*((S-100)/F.length)+((S-100)/F.length-B)/2;return e.jsxs("g",{onClick:()=>v(X,fe),children:[e.jsx("rect",{x:se,y:u-G,width:B,height:G,fill:X.color||z[fe%z.length],rx:4,className:"nice-drilldown-column-bar"}),e.jsx("text",{x:se+B/2,y:u+16,textAnchor:"middle",fontSize:"11",fill:"var(--nice-text-primary, #374151)",children:(X.label||`${fe+1}`).slice(0,10)}),T&&e.jsx("text",{x:se+B/2,y:u-G-8,textAnchor:"middle",fontSize:"11",fill:"var(--nice-text-primary, #374151)",fontWeight:"500",children:X.value.toLocaleString()})]},fe)})]})})};return e.jsxs("div",{className:`nice-drilldown-chart ${P?`animating ${H}`:""} ${l||""}`,style:{width:S,...x},"data-testid":L??A,...C,children:[e.jsxs("div",{className:"nice-drilldown-header",children:[R&&f.length>1&&e.jsxs("button",{className:"nice-drilldown-back",onClick:Z,children:[e.jsx(de.NiceIcon,{name:"arrow-left",size:14})," ",d("charts.back","Back")]}),E&&e.jsx("div",{className:"nice-drilldown-breadcrumbs",children:te.map((F,h)=>e.jsxs(c.Fragment,{children:[h>0&&e.jsx("span",{className:"nice-drilldown-separator",children:"/"}),e.jsx("span",{role:h<te.length-1?"button":void 0,tabIndex:h<te.length-1?0:void 0,"aria-current":h===te.length-1?"location":void 0,onKeyDown:h<te.length-1?de.clickOnActivationKey:void 0,className:`nice-drilldown-crumb ${h===te.length-1?"active":""}`,onClick:()=>{if(h<te.length-1){const B=f.slice(0,h+1),u=B[B.length-1];y||(p(B),I(u)),O?.(u,B)}},children:F})]},h))})]}),e.jsxs("div",{className:"nice-drilldown-content",style:{height:D-40},children:[g==="bar"&&ce(),g==="pie"&&ae(),g==="column"&&he()]}),w&&Y&&e.jsx("div",{className:"nice-drilldown-legend",children:Y.data.map((F,h)=>e.jsxs("div",{className:"nice-drilldown-legend-item",children:[e.jsx("span",{className:"nice-drilldown-legend-color",style:{backgroundColor:F.color||z[h%z.length]}}),e.jsx("span",{className:"nice-drilldown-legend-label",children:F.label||d("charts.item","Item {i}").replace("{i}",String(h+1))})]},h))}),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"}),Bt=["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)"],Wt=({type:t="choropleth",regions:s=[],bubbles:d=[],width:r=800,height:i=500,viewBox:b="0 0 800 500",colorScale:g,colorRange:S,minValue:D,maxValue:E,showTooltip:R=!0,showLegend:_=!0,onRegionClick:O,onBubbleClick:N,onRegionHover:z,title:T,mapSvg:w,zoomable:l=!1,className:x,style:A,testId:L,"data-testid":C,...y})=>{const m=g??S??Bt,{t:I}=de.useNiceTranslation(),[a,p]=c.useState(null),[o,k]=c.useState(1),[f,P]=c.useState({x:0,y:0}),$=c.useRef(null),H=c.useRef(!1),ee=c.useRef({x:0,y:0}),Y=D??Math.min(...s.map(h=>h.value),...d.map(h=>h.value)),q=E??Math.max(...s.map(h=>h.value),...d.map(h=>h.value)),Z=c.useCallback(h=>{const B=(h-Y)/(q-Y),u=Math.min(Math.floor(B*m.length),m.length-1);return m[Math.max(0,u)]},[Y,q,m]),U=c.useCallback(h=>{if(!R||!a)return;const B=$.current?.getBoundingClientRect();B&&p(u=>u?{...u,x:h.clientX-B.left,y:h.clientY-B.top}:null)},[R,a]),v=c.useCallback((h,B)=>{const u=$.current?.getBoundingClientRect();u&&R&&p({x:B.clientX-u.left,y:B.clientY-u.top,content:`${h.name}: ${h.value.toLocaleString()}`}),z?.(h)},[R,z]),V=c.useCallback(()=>{p(null),z?.(null)},[z]),te=c.useCallback(h=>{if(!l)return;h.preventDefault();const B=h.deltaY>0?.9:1.1;k(u=>Math.min(Math.max(u*B,.5),4))},[l]),ce=c.useCallback(h=>{l&&(H.current=!0,ee.current={x:h.clientX-f.x,y:h.clientY-f.y})},[l,f]),ae=c.useCallback(()=>{H.current=!1},[]),he=c.useCallback(h=>{H.current&&P({x:h.clientX-ee.current.x,y:h.clientY-ee.current.y})},[]),F=c.useMemo(()=>s.length>0?s:[{id:"mazowieckie",name:"Mazowieckie",value:100,path:"M400,200 L450,200 L460,250 L420,280 L380,250 Z"},{id:"slaskie",name:"Śląskie",value:80,path:"M350,280 L400,280 L390,330 L340,320 Z"},{id:"wielkopolskie",name:"Wielkopolskie",value:70,path:"M300,200 L350,200 L360,260 L310,270 L280,230 Z"}],[s]);return e.jsxs("div",{className:`nice-map-chart ${x||""}`,style:{width:r,...A},"data-testid":C??L,...y,children:[T&&e.jsx("div",{className:"nice-map-title",children:T}),e.jsx("svg",{ref:$,width:r,height:i,viewBox:b,className:"nice-map-svg",onWheel:te,onMouseDown:ce,onMouseUp:ae,onMouseLeave:ae,onMouseMove:h=>{U(h),he(h)},children:e.jsxs("g",{transform:`translate(${f.x}, ${f.y}) scale(${o})`,children:[w&&e.jsx("g",{dangerouslySetInnerHTML:{__html:w}}),t==="choropleth"&&F.map(h=>e.jsx("path",{d:h.path,fill:h.color||Z(h.value),stroke:"var(--nice-bg-primary, #ffffff)",strokeWidth:1,className:"nice-map-region",onClick:()=>O?.(h),onMouseEnter:B=>v(h,B),onMouseLeave:V},h.id)),(t==="bubble"||d.length>0)&&d.map(h=>{const B=Math.sqrt((h.value-Y)/(q-Y))*30+5;return e.jsx("circle",{cx:h.lng,cy:h.lat,r:B,fill:h.color||"var(--nice-color-primary, #3b82f6)",fillOpacity:.7,stroke:"var(--nice-bg-primary, #ffffff)",strokeWidth:1,className:"nice-map-bubble",onClick:()=>N?.(h),onMouseEnter:u=>{const X=$.current?.getBoundingClientRect();X&&R&&p({x:u.clientX-X.left,y:u.clientY-X.top,content:`${h.label||h.id}: ${h.value.toLocaleString()}`})},onMouseLeave:V,children:h.label&&e.jsxs("title",{children:[h.label,": ",h.value]})},h.id)})]})}),a&&e.jsx("div",{className:"nice-map-tooltip",style:{left:a.x+10,top:a.y-30},children:a.content}),_&&e.jsxs("div",{className:"nice-map-legend",children:[e.jsx("span",{className:"nice-map-legend-title",children:I("charts.value","Value")}),e.jsx("div",{className:"nice-map-legend-scale",children:m.map((h,B)=>e.jsx("div",{className:"nice-map-legend-item",style:{backgroundColor:h}},B))}),e.jsxs("div",{className:"nice-map-legend-labels",children:[e.jsx("span",{children:Y.toLocaleString()}),e.jsx("span",{children:q.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
- `})]})},Yt=({nodes:t=Dt,links:s=Et,width:d=800,height:r=500,nodeWidth:i=20,nodePadding:b=10,showValues:g=!0,showTooltip:S=!0,onNodeClick:D,onLinkClick:E,title:R,className:_,style:O,testId:N,"data-testid":z,...T})=>{const[w,l]=c.useState(null),x=c.useRef(null),A=c.useMemo(()=>{const C=new Map;t.forEach(v=>C.set(v.id,v));const y=new Set(s.map(v=>v.target)),m=new Set(s.map(v=>v.source)),I=[],a=new Map,p=t.filter(v=>m.has(v.id)&&!y.has(v.id));p.length>0&&(I.push(p.map(v=>v.id)),p.forEach(v=>a.set(v.id,0)));const o=t.filter(v=>m.has(v.id)&&y.has(v.id));o.length>0&&(I.push(o.map(v=>v.id)),o.forEach(v=>a.set(v.id,1)));const k=t.filter(v=>!m.has(v.id)&&y.has(v.id));k.length>0&&(I.push(k.map(v=>v.id)),k.forEach(v=>a.set(v.id,2))),I.length===0&&(I.push(t.map(v=>v.id)),t.forEach(v=>a.set(v.id,0)));const f=new Map;s.forEach(v=>{f.set(v.source,(f.get(v.source)||0)+v.value),f.set(v.target,(f.get(v.target)||0)+v.value)});const P=40,$=d-P*2,H=r-P*2,ee=I.length>1?$/(I.length-1):$,Y=new Map;Math.max(...Array.from(f.values())),I.forEach((v,V)=>{const te=v.reduce((he,F)=>he+(f.get(F)||0),0),ce=(H-(v.length-1)*b)/te;let ae=P;v.forEach(he=>{const h=(f.get(he)||0)*ce,B=P+V*ee;Y.set(he,{x:B,y:ae,height:h}),ae+=h+b})});const q=[],Z=new Map,U=new Map;return s.forEach(v=>{const V=Y.get(v.source),te=Y.get(v.target);if(!V||!te)return;const ce=f.get(v.source)||1;f.get(v.target);const ae=v.value/ce*V.height,he=V.y+(Z.get(v.source)||0),F=te.y+(U.get(v.target)||0);Z.set(v.source,(Z.get(v.source)||0)+ae),U.set(v.target,(U.get(v.target)||0)+ae);const h=V.x+i,B=te.x,u=(B-h)*.5,X=`
564
- M ${h} ${he}
565
- C ${h+u} ${he},
566
- ${B-u} ${F},
567
- ${B} ${F}
568
- L ${B} ${F+ae}
569
- C ${B-u} ${F+ae},
570
- ${h+u} ${he+ae},
571
- ${h} ${he+ae}
572
- Z
573
- `;q.push({path:X,link:v,sourcePos:V,targetPos:te})}),{nodePositions:Y,linkPaths:q,nodeMap:C,nodeValues:f}},[t,s,d,r,i,b]),L=c.useCallback((C,y)=>{const m=x.current?.getBoundingClientRect();m&&S&&l({x:y.clientX-m.left,y:y.clientY-m.top,content:C})},[S]);return e.jsxs("div",{className:`nice-sankey-chart ${_||""}`,style:{width:d,...O},"data-testid":z??N,...T,children:[R&&e.jsx("div",{className:"nice-sankey-title",children:R}),e.jsxs("svg",{ref:x,width:d,height:r,className:"nice-sankey-svg",children:[e.jsx("defs",{children:A.linkPaths.map((C,y)=>e.jsxs("linearGradient",{id:`sankey-gradient-${y}`,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:[e.jsx("stop",{offset:"0%",stopColor:A.nodeMap.get(C.link.source)?.color||"var(--nice-color-primary, #3b82f6)"}),e.jsx("stop",{offset:"100%",stopColor:A.nodeMap.get(C.link.target)?.color||"var(--nice-color-error, #ef4444)"})]},y))}),e.jsx("g",{className:"nice-sankey-links",children:A.linkPaths.map((C,y)=>e.jsx("path",{d:C.path,fill:C.link.color||`url(#sankey-gradient-${y})`,fillOpacity:.4,className:"nice-sankey-link",onClick:()=>E?.(C.link),onMouseEnter:m=>L(`${A.nodeMap.get(C.link.source)?.name} → ${A.nodeMap.get(C.link.target)?.name}: ${C.link.value.toLocaleString()}`,m),onMouseLeave:()=>l(null)},y))}),e.jsx("g",{className:"nice-sankey-nodes",children:Array.from(A.nodePositions.entries()).map(([C,y])=>{const m=A.nodeMap.get(C);return m?e.jsxs("g",{children:[e.jsx("rect",{x:y.x,y:y.y,width:i,height:y.height,fill:m.color||"var(--nice-color-primary, #3b82f6)",rx:2,className:"nice-sankey-node",onClick:()=>D?.(m),onMouseEnter:I=>L(`${m.label??m.name??m.id}: ${A.nodeValues.get(C)?.toLocaleString()||0}`,I),onMouseLeave:()=>l(null)}),e.jsxs("text",{x:y.x+i+6,y:y.y+y.height/2,dominantBaseline:"middle",fontSize:"12",fill:"var(--nice-text-primary, #0f172a)",children:[m.label??m.name??m.id,g&&` (${A.nodeValues.get(C)?.toLocaleString()||0})`]})]},C):null})})]}),w&&e.jsx("div",{className:"nice-sankey-tooltip",style:{left:w.x+10,top:w.y-30},children:w.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
- `})]})},Ft=Object.assign(c.forwardRef((t,s)=>{const{t:d}=de.useNiceTranslation(),{initialData:r,data:i,maxPoints:b=60,updateInterval:g=1e3,fetchData:S,width:D=600,height:E=200,chartType:R="line",color:_="var(--nice-color-primary, #3b82f6)",showGrid:O=!0,showTimeAxis:N=!0,showCurrentValue:z=!0,title:T,valueFormatter:w=G=>G.toFixed(2),timeFormatter:l=G=>new Date(G).toLocaleTimeString(),onDataUpdate:x,paused:A,className:L,style:C,testId:y,"data-testid":m,...I}=t,[a,p]=c.useState(r??i??[]),[o,k]=c.useState(A||!1),f=c.useRef(void 0);c.useEffect(()=>{A!==void 0&&k(A)},[A]),c.useEffect(()=>{if(o||!S)return;const G=async()=>{try{const se=await S();p(ue=>{const ve=[...ue,se].slice(-b);return x?.(ve),ve})}catch(se){console.error("Failed to fetch realtime data:",se)}};return f.current=setInterval(G,g),()=>{f.current&&clearInterval(f.current)}},[o,S,g,b,x]);const P=c.useCallback(G=>{p(se=>{const ue=[...se,G].slice(-b);return x?.(ue),ue})},[b,x]),$=c.useCallback(()=>{p([]),x?.([])},[x]),H=c.useCallback(()=>k(!0),[]),ee=c.useCallback(()=>k(!1),[]);c.useImperativeHandle(s,()=>({addDataPoint:P,clearData:$,pause:H,resume:ee,getData:()=>a}),[P,$,H,ee,a]);const Y={top:20,right:60,bottom:N?40:20,left:50},q=D-Y.left-Y.right,Z=E-Y.top-Y.bottom,U=a.map(G=>G.value),v=U.length?Math.min(...U):0,V=U.length?Math.max(...U):100,ce=(V-v||1)*.1,ae=v-ce,F=V+ce-ae,h=G=>{const se=S?b-1:Math.max(1,a.length-1);return Y.left+G/se*q},B=G=>Y.top+Z-(G-ae)/F*Z,u=a.map((G,se)=>`${h(se)},${B(G.value)}`).join(" "),X=a.length>0?`M ${h(0)},${Y.top+Z} L ${u} L ${h(a.length-1)},${Y.top+Z} Z`:"",fe=a.length>0?a[a.length-1].value:null;return e.jsxs("div",{className:`nice-realtime-chart ${L||""}`,style:{width:D,...C},"data-testid":m??y,...I,children:[e.jsxs("div",{className:"nice-realtime-header",children:[e.jsx("span",{className:"nice-realtime-title",children:T}),e.jsxs("div",{className:"nice-realtime-controls",children:[e.jsxs("span",{className:`nice-realtime-status ${o?"paused":"live"}`,children:[e.jsx("span",{className:"nice-realtime-status-dot"}),e.jsx("span",{children:o?d("charts.paused","Paused"):d("charts.live","Live")})]}),e.jsx("button",{className:`nice-realtime-btn ${o?"paused":""}`,onClick:()=>k(!o),"aria-label":o?d("charts.resume","Resume"):d("charts.pause","Pause"),children:e.jsx(de.NiceIcon,{name:o?"play":"pause",size:14})}),z&&fe!==null&&e.jsx("span",{className:"nice-realtime-value",children:w(fe)})]})]}),e.jsxs("svg",{width:D,height:E,className:"nice-realtime-svg",children:[O&&e.jsx("g",{className:"nice-realtime-grid",children:[0,.25,.5,.75,1].map((G,se)=>{const ue=Y.top+Z*(1-G),ve=ae+F*G;return e.jsxs("g",{children:[e.jsx("line",{x1:Y.left,y1:ue,x2:D-Y.right,y2:ue,stroke:"var(--nice-border-color, #e5e7eb)",strokeDasharray:G===0?void 0:"3"}),e.jsx("text",{x:Y.left-8,y:ue,textAnchor:"end",dominantBaseline:"middle",fontSize:"10",fill:"var(--nice-text-secondary, #6b7280)",children:Math.round(ve).toLocaleString()})]},se)})}),R==="area"&&a.length>0&&e.jsx("path",{d:X,fill:_,fillOpacity:.2}),a.length>1&&e.jsx("polyline",{points:u,fill:"none",stroke:_,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),a.length>0&&e.jsx("circle",{cx:h(a.length-1),cy:B(a[a.length-1].value),r:3,fill:_,className:"nice-realtime-point"}),N&&a.length>0&&e.jsx("g",{className:"nice-realtime-time-axis",children:Array.from(new Set([0,Math.floor(a.length/2),a.length-1].filter(G=>a[G]))).map(G=>e.jsx("text",{x:h(G),y:E-8,textAnchor:"middle",fontSize:"10",fill:"var(--nice-text-secondary, #6b7280)",children:l(a[G].timestamp)},`tx-${G}`))})]}),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: ${_};
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"}),Ht=({data:t,width:s=600,height:d=400,showLabels:r=!0,showValues:i=!0,onNodeClick:b,drilldownEnabled:g=!0,colors:S=We,tilePadding:D=2,className:E,style:R,testId:_,"data-testid":O,...N})=>{const{t:z}=de.useNiceTranslation(),T=c.useMemo(()=>Array.isArray(t)?{id:"root",name:"Root",value:t.reduce((k,f)=>k+(f.value||0),0),children:t.map((k,f)=>({id:`${f}`,name:k.label??k.name??`Item ${f+1}`,value:k.value,color:k.color}))}:t,[t]),[w,l]=c.useState(T),[x,A]=c.useState([T.name]),[L,C]=c.useState(null),y=c.useRef(null),m=c.useMemo(()=>{const f=w.children||[];if(f.length===0)return[];const P=f.reduce((v,V)=>v+V.value,0),$=f.map(v=>({node:v,area:v.value/P*s*d}));$.sort((v,V)=>V.area-v.area);const H=[];let ee=0,Y=0,q=s,Z=d,U=0;for(;U<$.length;){const v=q<Z;let V=0,te=[];const ce=v?Z:q;for(let F=U;F<$.length;F++){const h=[...te,$[F]],B=h.reduce((X,fe)=>X+fe.area,0),u=I(h,B,ce);if(te.length===0)te=h,V=B;else{const X=I(te,V,ce);if(u<=X)te=h,V=B;else break}}const ae=V/ce;let he=0;te.forEach((F,h)=>{const B=F.area/ae;H.push({node:F.node,x:v?ee:ee+he,y:v?Y+he:Y,w:v?ae:B,h:v?B:ae,color:F.node.color||S[(U+h)%S.length]}),he+=B}),v?(ee+=ae,q-=ae):(Y+=ae,Z-=ae),U+=te.length}return H},[w,s,d,S]);function I(k,f,P){const $=f/P;let H=0;for(const ee of k){const Y=ee.area/$,q=Math.max($/Y,Y/$);H=Math.max(H,q)}return H}const a=k=>{b?.(k,[...x,k.name]),g&&k.children&&k.children.length>0&&(l(k),A(f=>[...f,k.name]))},p=()=>{if(x.length<=1)return;let k=T;const f=x.slice(0,-1);for(let P=1;P<f.length;P++){const $=k.children?.find(H=>H.name===f[P]);$&&(k=$)}l(k),A(f)},o=(k,f)=>{const P=y.current?.getBoundingClientRect();P&&C({x:f.clientX-P.left,y:f.clientY-P.top,content:k})};return e.jsxs("div",{className:`nice-treemap-chart ${E||""}`,style:{width:s,...R},"data-testid":O??_,...N,children:[e.jsxs("div",{className:"nice-treemap-nav",children:[x.length>1&&e.jsxs("button",{className:"nice-treemap-back",onClick:p,children:[e.jsx(de.NiceIcon,{name:"arrow-left",size:14})," ",z("charts.back","Back")]}),e.jsx("div",{className:"nice-treemap-breadcrumbs",children:x.map((k,f)=>e.jsxs(c.Fragment,{children:[f>0&&e.jsx("span",{className:"nice-treemap-sep",children:"/"}),e.jsx("span",{className:f===x.length-1?"current":"",children:k})]},f))})]}),e.jsx("svg",{ref:y,width:s,height:d,className:"nice-treemap-svg",children:m.map((k,f)=>{const{node:P,x:$,y:H,w:ee,h:Y,color:q}=k,Z=Math.min(14,Math.max(10,Math.min(ee,Y)/6)),U=ee>40&&Y>30;return e.jsxs("g",{onClick:()=>a(P),onMouseEnter:v=>o(`${P.name}: ${P.value.toLocaleString()}`,v),onMouseLeave:()=>C(null),children:[e.jsx("rect",{x:$+D/2,y:H+D/2,width:Math.max(0,ee-D),height:Math.max(0,Y-D),fill:q,rx:4,className:"nice-treemap-tile"}),r&&U&&e.jsx("text",{x:$+ee/2,y:H+Y/2-(i?6:0),textAnchor:"middle",dominantBaseline:"middle",fontSize:Z,fill:"white",fontWeight:"500",style:{pointerEvents:"none"},children:P.name.length>ee/Z+2?P.name.slice(0,Math.floor(ee/Z))+"...":P.name}),i&&U&&e.jsx("text",{x:$+ee/2,y:H+Y/2+10,textAnchor:"middle",dominantBaseline:"middle",fontSize:Z-2,fill:"var(--nice-overlay-light-80, rgba(255, 255, 255, 0.8))",style:{pointerEvents:"none"},children:P.value.toLocaleString()})]},f)})}),L&&e.jsx("div",{className:"nice-treemap-tooltip",style:{left:L.x+10,top:L.y-30},children:L.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=_e;exports.NiceBarGauge=Ke;exports.NiceBullet=Je;exports.NiceChart=Ae;exports.NiceChart$1=He;exports.NiceChartAI=Lt;exports.NiceCircularGauge=Ve;exports.NiceDrillDownChart=Ot;exports.NiceForecastChart=wt;exports.NiceFunnel=nt;exports.NiceHeatMap=ct;exports.NiceLinearGauge=Xe;exports.NiceLiveChart=St;exports.NiceMapChart=Wt;exports.NiceOrganizationChart=xt;exports.NicePieChart=et;exports.NicePolarChart=_t;exports.NiceRangeSelector=jt;exports.NiceRealtimeChart=Ft;exports.NiceSankey=Pe;exports.NiceSankey$1=ot;exports.NiceSankeyChart=Yt;exports.NiceSparkline=vt;exports.NiceStockChart=pt;exports.NiceTreeMap=Oe;exports.NiceTreeMap$1=ht;exports.NiceTreeMapChart=Ht;exports.NiceVectorMap=Be;exports.NiceVectorMap$1=ft;exports.createMockLiveChartSource=It;exports.createSignalRLiveChartSource=Ct;exports.createWebSocketLiveChartSource=At;