@nice2dev/ui 1.4.23 → 1.4.25

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 (45) hide show
  1. package/CHANGELOG.md +100 -0
  2. package/README.md +2 -4
  3. package/dist/NiceModuleLifecyclePanel-bsHwj1pO.cjs +1 -0
  4. package/dist/{NicePivotGrid-B5Fgi5E_.cjs → NicePivotGrid-D53CQ2cY.cjs} +1 -1
  5. package/dist/{NiceStreamDashboard.doc-74KUXya1.cjs → NiceStreamDashboard.doc-CdkHFf4Y.cjs} +2 -2
  6. package/dist/charts/NiceAdvancedCharts.mjs +586 -773
  7. package/dist/charts/NiceChartRangeSelector.mjs +159 -0
  8. package/dist/charts/NiceHeatMap.mjs +140 -70
  9. package/dist/charts/NiceOrganizationChart.mjs +183 -90
  10. package/dist/charts/NiceSankey.mjs +166 -93
  11. package/dist/charts/NiceStockChart.mjs +258 -157
  12. package/dist/charts-CSgOgfES.cjs +867 -0
  13. package/dist/charts.cjs +1 -1
  14. package/dist/charts.d.ts +126 -102
  15. package/dist/charts.mjs +22 -24
  16. package/dist/core/lazy.mjs +50 -63
  17. package/dist/core-lazy-sO0xvg64.cjs +1 -0
  18. package/dist/data.cjs +1 -1
  19. package/dist/demo/docs/docPreviews.mjs +504 -546
  20. package/dist/demo/docs/docRegistry.mjs +9 -94
  21. package/dist/docs/NiceStreamDashboard.doc.json.mjs +1 -1
  22. package/dist/documentation/utils.mjs +1 -1
  23. package/dist/index.cjs +95 -121
  24. package/dist/index.d.ts +126 -217
  25. package/dist/index.mjs +829 -836
  26. package/dist/lazy.cjs +1 -1
  27. package/dist/lazy.d.ts +41 -23
  28. package/dist/lazy.mjs +1 -1
  29. package/dist/navigation/NiceDock.mjs +55 -48
  30. package/dist/navigation/NiceMenuTypes.mjs +197 -251
  31. package/dist/navigation.cjs +1 -1
  32. package/dist/navigation.d.ts +5 -16
  33. package/dist/navigation.mjs +53 -54
  34. package/dist/style.css +2 -2
  35. package/dist/tools/NiceShowcase.mjs +2 -4
  36. package/package.json +4 -4
  37. package/dist/NiceDiagram.doc-CASS0Tnj.cjs +0 -8
  38. package/dist/NiceModuleLifecyclePanel-jckyVqqt.cjs +0 -1
  39. package/dist/charts/NiceRangeSelector.mjs +0 -135
  40. package/dist/charts/NiceTreeMap.mjs +0 -100
  41. package/dist/charts/NiceVectorMap.mjs +0 -59
  42. package/dist/charts-C9B548D2.cjs +0 -924
  43. package/dist/core-lazy-B54FdghB.cjs +0 -1
  44. package/dist/docs/NiceDiagram.doc.json.mjs +0 -32
  45. package/dist/tools/NiceChat.mjs +0 -98
@@ -0,0 +1,867 @@
1
+ "use strict";const e=require("react/jsx-runtime"),pe=require("@nice2dev/ui-core"),u=require("react"),St=require("@nice2dev/i18n"),Ct=[],Le=["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)"],Ye=({series:t=Ct,categories:n,width:r=600,height:a=400,title:c,showLegend:f=!0,legendPlacement:s="bottom",showGrid:h=!0,axisLabels:v=!0,yAxisLabel:b,xAxisLabel:_,stacked:S,animated:O,zoomable:I,crosshair:B,annotations:g,legendInteractive:M,onDataPointClick:k,exportable:T,className:E,style:N,testId:l,"data-testid":o})=>{const{t:y}=pe.useNiceTranslation(),j=u.useRef(null),[d,C]=u.useState(new Set),[F,Z]=u.useState(null),[z,J]=u.useState(null),[V,K]=u.useState(!1),A=u.useRef(null),i=u.useMemo(()=>t.filter(L=>!d.has(L.name)),[t,d]),m=u.useCallback(L=>{M&&C(he=>{const fe=new Set(he);return fe.has(L)?fe.delete(L):fe.add(L),fe})},[M]),x={top:c?40:20,right:20,bottom:_?60:40,left:b?60:50},U=t.length,$=t.reduce((L,he)=>Math.max(L,he.name.length),0),w=f&&(s==="left"||s==="right"),Y=Math.min(r*.3,24+$*7),X=w?1:Math.max(1,Math.floor((r-x.left)/120)),oe=f?Math.ceil(U/X):0;f&&s==="right"?x.right+=Y+12:f&&s==="left"?x.left+=Y+12:f&&s==="top"&&(x.top+=oe*20+6);const ie=f&&s==="bottom",ue=s==="right"?{x:r-Y-8,y:x.top}:s==="left"?{x:8,y:x.top}:s==="top"?{x:x.left,y:(c?40:20)-6}:{x:x.left,y:a},P=L=>w?`translate(0, ${10+L*20})`:`translate(${L%X*120}, ${10+Math.floor(L/X)*20})`,G=r-x.left-x.right,p=a-x.top-x.bottom,D=i[0]?.data.length??t[0]?.data.length??0,H=z?.start??0,W=z?.end??D,te=W-H,ne=u.useMemo(()=>i.map(L=>({...L,data:L.data.slice(H,W)})),[i,H,W]),re=u.useMemo(()=>n?.slice(H,W),[n,H,W]),{minY:be,maxY:ke,yTicks:Q}=u.useMemo(()=>{let L;if(S){L=[];for(let ve=0;ve<te;ve++)L.push(ne.reduce((Ce,Ie)=>Ce+(Ie.data[ve]||0),0))}else L=ne.flatMap(ve=>ve.data);L.length===0&&(L=[0]);const he=Math.min(0,...L),fe=Math.max(0,...L),je=fe-he||1,$e=Math.pow(10,Math.floor(Math.log10(je)))||1,ae=Math.floor(he/$e)*$e;let xe=Math.ceil(fe/$e)*$e;const me=[];for(let ve=ae;ve<=xe;ve+=$e)me.push(Math.round(ve*1e6)/1e6);return me.length<2&&(xe=ae+$e,me.push(Math.round(xe*1e6)/1e6)),{minY:ae,maxY:xe,yTicks:me}},[ne,te,S]),ce=L=>p-(L-be)/(ke-be||1)*p,q=L=>(L+.5)/te*G,le=L=>(L.type||"bar")==="bar",ye=new Map(ne.filter(le).map((L,he)=>[L,he])),Me=te>0?G/te/(S?1.5:Math.max(ye.size,1)*1.5):20,_e=Me*.9,we=u.useCallback(L=>{if(!I)return;L.preventDefault();const he=z??{start:0,end:D},fe=he.end-he.start,je=(he.start+he.end)/2,$e=L.deltaY>0?1.2:.8,ae=Math.max(2,Math.min(D,Math.round(fe*$e))),xe=Math.max(0,Math.round(je-ae/2)),me=Math.min(D,xe+ae);J({start:xe,end:me})},[I,z,D]),R=u.useCallback(L=>{I&&(K(!0),A.current={x:L.clientX,range:z??{start:0,end:D}})},[I,z,D]),se=u.useCallback(L=>{const he=j.current?.getBoundingClientRect();if(he&&Z({x:L.clientX-he.left-x.left,y:L.clientY-he.top-x.top}),V&&A.current&&I){const fe=L.clientX-A.current.x,je=G/te,$e=-Math.round(fe/je),ae=A.current.range,xe=ae.end-ae.start;let me=ae.start+$e;me<0&&(me=0),me+xe>D&&(me=D-xe),J({start:me,end:me+xe})}},[V,I,G,te,D,x.left,x.top]),de=u.useCallback(()=>{K(!1),A.current=null},[]),ee=u.useCallback(()=>{Z(null),K(!1),A.current=null},[]),ge=u.useCallback(()=>{const L=j.current;if(!L)return;const he=new XMLSerializer().serializeToString(L),fe=document.createElement("canvas");fe.width=r,fe.height=a+(ie?30:0);const je=fe.getContext("2d");if(!je)return;const $e=new Image;$e.onload=()=>{je.fillStyle=pe.resolveCssColor("var(--nice-bg-primary, #fff)",je.canvas),je.fillRect(0,0,fe.width,fe.height),je.drawImage($e,0,0);const ae=document.createElement("a");ae.download="chart.png",ae.href=fe.toDataURL("image/png"),ae.click()},$e.src="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(he)},[r,a,ie]),Re=a+(ie?30:0),Te=ne.length>0&&ne.every(L=>L.type==="radar"),Ne=u.useMemo(()=>{if(!Te)return 1;const L=ne.flatMap(he=>he.data);return Math.max(1,...L)},[Te,ne]);if(Te){const L=r/2,he=(a-x.top-x.bottom)/2+x.top,fe=Math.min(G,a-x.top-x.bottom)/2-10,je=re?.length??ne[0]?.data.length??0,$e=me=>me/je*Math.PI*2-Math.PI/2,ae=(me,ve)=>{const Ce=ve/Ne*fe;return[L+Math.cos($e(me))*Ce,he+Math.sin($e(me))*Ce]},xe=4;return e.jsx("div",{className:`nice-chart nice-chart--radar ${E||""}`,style:N,"data-testid":o??l,children:e.jsxs("svg",{ref:j,viewBox:`0 0 ${r} ${Re}`,preserveAspectRatio:"xMidYMid meet",width:"100%",height:"100%",className:"nice-chart__svg",style:{display:"block",maxWidth:"100%",maxHeight:"100%"},children:[c&&e.jsx("text",{x:r/2,y:20,textAnchor:"middle",className:"nice-chart__title",children:c}),h&&Array.from({length:xe},(me,ve)=>{const Ce=(ve+1)/xe*fe,Ie=[];for(let ze=0;ze<je;ze++)Ie.push(`${L+Math.cos($e(ze))*Ce},${he+Math.sin($e(ze))*Ce}`);return e.jsx("polygon",{points:Ie.join(" "),fill:"none",className:"nice-chart__grid-line"},ve)}),Array.from({length:je},(me,ve)=>{const[Ce,Ie]=ae(ve,Ne);return e.jsx("line",{x1:L,y1:he,x2:Ce,y2:Ie,className:"nice-chart__grid-line"},ve)}),v&&re?.map((me,ve)=>{const[Ce,Ie]=ae(ve,Ne*1.12);return e.jsx("text",{x:Ce,y:Ie,textAnchor:"middle",dominantBaseline:"middle",className:"nice-chart__axis-label",children:me},ve)}),ne.map((me,ve)=>{const Ce=me.color||Le[ve%Le.length],Ie=me.data.map((ze,Fe)=>ae(Fe,ze).join(",")).join(" ");return e.jsxs("g",{className:O?"nice-chart__series nice-chart__series--radar nice-chart__series--anim":"nice-chart__series nice-chart__series--radar",children:[e.jsx("polygon",{points:Ie,fill:Ce,fillOpacity:.2,stroke:Ce,strokeWidth:2}),me.data.map((ze,Fe)=>{const[Ve,Nt]=ae(Fe,ze);return e.jsx("circle",{cx:Ve,cy:Nt,r:3,fill:Ce,children:e.jsx("title",{children:`${me.name}: ${ze}`})},Fe)})]},me.name)}),f&&e.jsx("g",{transform:`translate(${ue.x}, ${ue.y})`,children:t.map((me,ve)=>{const Ce=d.has(me.name);return e.jsxs("g",{transform:P(ve),style:M?{cursor:"pointer"}:void 0,onClick:()=>m(me.name),opacity:Ce?.35:1,children:[e.jsx("rect",{width:12,height:12,rx:2,fill:me.color||Le[ve%Le.length]}),e.jsx("text",{x:16,y:10,className:"nice-chart__legend-text",children:me.name})]},me.name)})})]})})}return e.jsxs("div",{className:`nice-chart ${E||""}`,style:N,"data-testid":o??l,children:[T&&e.jsx("button",{type:"button",className:"nice-chart__export-btn",onClick:ge,title:y("chart.exportPng","Export PNG"),"aria-label":y("chart.exportPng","Export PNG"),children:e.jsx(pe.NiceIcon,{name:"camera",size:16})}),e.jsxs("svg",{ref:j,viewBox:`0 0 ${r} ${Re}`,preserveAspectRatio:"xMidYMid meet",width:"100%",height:"100%",style:{display:"block",maxWidth:"100%",maxHeight:"100%"},className:"nice-chart__svg",onWheel:we,onMouseDown:R,onMouseMove:se,onMouseUp:de,onMouseLeave:ee,children:[e.jsxs("g",{transform:`translate(${x.left},${x.top})`,children:[c&&e.jsx("text",{x:G/2,y:-10,textAnchor:"middle",className:"nice-chart__title",children:c}),h&&Q.map(L=>e.jsx("line",{x1:0,y1:ce(L),x2:G,y2:ce(L),className:"nice-chart__grid-line"},`grid-${L}`)),v&&Q.map(L=>e.jsx("text",{x:-8,y:ce(L)+4,textAnchor:"end",className:"nice-chart__axis-label",children:L},`ylabel-${L}`)),v&&re&&re.map((L,he)=>e.jsx("text",{x:q(he),y:p+20,textAnchor:"middle",className:"nice-chart__axis-label",children:L},he)),b&&e.jsx("text",{x:-x.left+14,y:p/2,textAnchor:"middle",transform:`rotate(-90, -${x.left-14}, ${p/2})`,className:"nice-chart__axis-title",children:b}),_&&e.jsx("text",{x:G/2,y:p+45,textAnchor:"middle",className:"nice-chart__axis-title",children:_}),e.jsx("line",{x1:0,y1:0,x2:0,y2:p,className:"nice-chart__axis"}),e.jsx("line",{x1:0,y1:p,x2:G,y2:p,className:"nice-chart__axis"}),g?.map((L,he)=>{if(L.type==="line"){const fe=ce(L.value);return e.jsxs("g",{children:[e.jsx("line",{x1:0,y1:fe,x2:G,y2:fe,stroke:L.color||"var(--nice-color-error, #ef4444)",strokeWidth:1.5,strokeDasharray:L.dash||"6,3"}),L.label&&e.jsx("text",{x:G+4,y:fe+4,className:"nice-chart__annotation-label",fill:L.color||"var(--nice-color-error, #ef4444)",children:L.label})]},he)}return e.jsx("text",{x:q(L.value),y:-4,textAnchor:"middle",className:"nice-chart__annotation-label",fill:L.color||"var(--nice-text-muted, #6b7280)",children:L.label},he)}),B&&F&&F.x>=0&&F.x<=G&&F.y>=0&&F.y<=p&&e.jsxs(e.Fragment,{children:[e.jsx("line",{x1:F.x,y1:0,x2:F.x,y2:p,stroke:"var(--nice-text-muted, #9ca3af)",strokeWidth:1,strokeDasharray:"4,2"}),e.jsx("line",{x1:0,y1:F.y,x2:G,y2:F.y,stroke:"var(--nice-text-muted, #9ca3af)",strokeWidth:1,strokeDasharray:"4,2"})]}),ne.map((L,he)=>{const fe=L.color||Le[he%Le.length],je=L.type||"bar";if(je==="bar")return e.jsx("g",{className:O?"nice-chart__series nice-chart__series--bar nice-chart__series--anim":"nice-chart__series nice-chart__series--bar",children:L.data.map((ae,xe)=>{let me,ve;if(S){const ze=ne.slice(0,he).filter(le).reduce((Fe,Ve)=>Fe+(Ve.data[xe]||0),0);me=ce(ze+ae),ve=ce(ze)-me}else me=ce(Math.max(0,ae)),ve=Math.abs(ce(ae)-ce(0));const Ce=ye.get(L)??0,Ie=S?q(xe)-_e/2:q(xe)-ye.size*Me/2+Ce*Me+(Me-_e)/2;return e.jsx("rect",{x:Ie,y:me,width:_e,height:Math.max(0,ve),fill:fe,rx:2,style:{transformOrigin:`${Ie+_e/2}px ${ce(0)}px`,...k?{cursor:"pointer"}:{}},onClick:k?()=>k(L.name,H+xe,ae):void 0,children:e.jsx("title",{children:`${L.name}: ${ae}`})},xe)})},L.name);if(je==="scatter")return e.jsx("g",{className:O?"nice-chart__series nice-chart__series--scatter nice-chart__series--anim":"nice-chart__series nice-chart__series--scatter",children:L.data.map((ae,xe)=>e.jsx("circle",{cx:q(xe),cy:ce(ae),r:5,fill:fe,fillOpacity:.7,stroke:fe,strokeWidth:1.5,style:k?{cursor:"pointer"}:void 0,onClick:k?()=>k(L.name,H+xe,ae):void 0,children:e.jsx("title",{children:`${L.name}: ${ae}`})},xe))},L.name);const $e=L.data.map((ae,xe)=>`${q(xe)},${ce(ae)}`);return e.jsxs("g",{className:O?`nice-chart__series nice-chart__series--${je} nice-chart__series--anim`:`nice-chart__series nice-chart__series--${je}`,children:[je==="area"&&te>0&&e.jsx("polygon",{points:`${q(0)},${ce(0)} ${$e.join(" ")} ${q(te-1)},${ce(0)}`,fill:fe,opacity:.15}),e.jsx("polyline",{points:$e.join(" "),fill:"none",stroke:fe,strokeWidth:2,className:O?"nice-chart__line":void 0}),L.data.map((ae,xe)=>e.jsx("circle",{cx:q(xe),cy:ce(ae),r:3,fill:fe,style:k?{cursor:"pointer"}:void 0,onClick:k?()=>k(L.name,H+xe,ae):void 0,children:e.jsx("title",{children:`${L.name}: ${ae}`})},xe))]},L.name)})]}),f&&e.jsx("g",{transform:`translate(${ue.x}, ${ue.y})`,children:t.map((L,he)=>{const fe=d.has(L.name);return e.jsxs("g",{transform:P(he),style:M?{cursor:"pointer"}:void 0,onClick:()=>m(L.name),opacity:fe?.35:1,children:[e.jsx("rect",{width:12,height:12,rx:2,fill:L.color||Le[he%Le.length]}),e.jsx("text",{x:16,y:10,className:"nice-chart__legend-text",style:fe?{textDecoration:"line-through"}:void 0,children:L.name})]},L.name)})})]})]})},Rt=Object.freeze(Object.defineProperty({__proto__:null,NiceChart:Ye},Symbol.toStringTag,{value:"Module"})),At=({value:t,min:n=0,max:r=100,width:a=200,height:c=200,startAngle:f=225,endAngle:s=-45,color:h,trackColor:v,label:b,formatValue:_,ranges:S,className:O,style:I,testId:B,"data-testid":g})=>{const M=h||"var(--nice-color-primary, #3b82f6)",k=a/2,T=c/2,E=Math.min(k,T),N=Math.max(4,E*.12),l=Math.max(8,E-N/2-4),o=Math.max(2.5,l*.05),y=Math.max(3,l*.08),j=Math.min(40,Math.max(10,l*.34)),d=Math.min(18,Math.max(8,l*.17)),C=Math.max(0,Math.min(1,(t-n)/(r-n||1))),F=i=>i*Math.PI/180,Z=(f-s+360)%360||360,z=i=>({x:k+l*Math.cos(F(i)),y:T-l*Math.sin(F(i))}),J=(i,m)=>{const x=z(i),U=z(m),w=(i-m+360)%360>180?1:0;return`M${x.x},${x.y} A${l},${l} 0 ${w},1 ${U.x},${U.y}`},V=f-C*Z,K=z(V);let A=M;if(S){for(const i of S)if(t>=i.start&&t<=i.end){A=i.color;break}}return e.jsx("div",{className:`nice-gauge nice-gauge--circular ${O||""}`,style:I,"data-testid":g??B,children:e.jsxs("svg",{width:a,height:c,viewBox:`0 0 ${a} ${c}`,style:{maxWidth:"100%",height:"auto"},children:[e.jsx("path",{d:J(f,s),fill:"none",stroke:v||"var(--nice-border-color, #e2e8f0)",strokeWidth:N,strokeLinecap:"round"}),C>0&&e.jsx("path",{d:J(f,V),fill:"none",stroke:A,strokeWidth:N,strokeLinecap:"round"}),e.jsx("line",{x1:k,y1:T,x2:K.x,y2:K.y,stroke:"var(--nice-text-primary, #333)",strokeWidth:o,strokeLinecap:"round"}),e.jsx("circle",{cx:k,cy:T,r:y,fill:"var(--nice-text-primary, #333)"}),e.jsx("text",{x:k,y:T+l*.58,textAnchor:"middle",className:"nice-gauge__value",style:{fontSize:j},children:_?_(t):t}),b&&e.jsx("text",{x:k,y:T+l*.58+j*.5+d*1.1,textAnchor:"middle",className:"nice-gauge__label",style:{fontSize:d},children:b})]})})},We=16,Tt=7,It=({value:t,min:n=0,max:r=100,width:a=300,height:c=60,orientation:f="horizontal",color:s,label:h,labelPlacement:v="bottom",showValueLabel:b=!1,formatValue:_,ranges:S,showTicks:O=!0,tickCount:I=5,className:B,style:g,testId:M,"data-testid":k})=>{const T=f==="horizontal",E=Math.max(0,Math.min(1,(t-n)/(r-n||1))),N=10,l=_?_(t):String(t);let o=s||"var(--nice-color-primary, #3b82f6)";if(S){for(const i of S)if(t>=i.start&&t<=i.end){o=i.color;break}}const y=Math.max(2,I),j=Array.from({length:y},(i,m)=>n+(r-n)*(m/(y-1)));if(T){const i=h&&v==="left",m=h&&v==="top",x=h&&v==="bottom",U=i?Math.min(a*.35,h.length*Tt+12):0,$=(m?We:0)+(b?16:6),w=20+U,Y=Math.max(20,a-40-U),X=$+8,oe=X+N+12,ie=Math.max(c,oe+(O?4:-8)+(x?We+4:4)),ue=w+Y*E;return e.jsx("div",{className:`nice-gauge nice-gauge--linear ${B||""}`,style:g,"data-testid":k??M,children:e.jsxs("svg",{width:a,height:ie,viewBox:`0 0 ${a} ${ie}`,style:{maxWidth:"100%"},children:[m&&e.jsx("text",{x:w,y:12,className:"nice-gauge__label",children:h}),i&&e.jsx("text",{x:U+8,y:X+N/2,textAnchor:"end",dominantBaseline:"middle",className:"nice-gauge__label",children:h}),b&&e.jsx("text",{x:ue,y:X-10,textAnchor:"middle",className:"nice-gauge__value",style:{fontSize:12},children:l}),e.jsx("rect",{x:w,y:X,width:Y,height:N,rx:5,fill:"var(--nice-border-color, #e2e8f0)"}),e.jsx("rect",{x:w,y:X,width:Y*E,height:N,rx:5,fill:o}),e.jsx("polygon",{points:`${ue},${X-2} ${ue-5},${X-8} ${ue+5},${X-8}`,fill:"var(--nice-text-primary, #333)",children:e.jsx("title",{children:l})}),O&&j.map((P,G)=>e.jsx("text",{x:w+(P-n)/(r-n||1)*Y,y:oe,textAnchor:"middle",className:"nice-gauge__tick",children:Math.round(P*100)/100},G)),x&&e.jsx("text",{x:w+Y/2,y:ie-4,textAnchor:"middle",className:"nice-gauge__label",children:h})]})})}const d=Math.max(a,c),C=Math.max(72,Math.min(a,c,140)),F=h&&v!=="bottom",Z=h&&v==="bottom",z=(F?We+4:0)+(b?18:8),J=Z?We+8:8,V=Math.max(20,d-z-J),K=C/2-N/2-(O?10:0),A=z+V*(1-E);return e.jsx("div",{className:`nice-gauge nice-gauge--linear nice-gauge--vertical ${B||""}`,style:g,"data-testid":k??M,children:e.jsxs("svg",{width:C,height:d,viewBox:`0 0 ${C} ${d}`,style:{maxWidth:"100%"},children:[F&&e.jsx("text",{x:C/2,y:12,textAnchor:"middle",className:"nice-gauge__label",children:h}),b&&e.jsx("text",{x:K+N/2,y:z-6,textAnchor:"middle",className:"nice-gauge__value",style:{fontSize:12},children:l}),e.jsx("rect",{x:K,y:z,width:N,height:V,rx:5,fill:"var(--nice-border-color, #e2e8f0)"}),e.jsx("rect",{x:K,y:A,width:N,height:V*E,rx:5,fill:o}),e.jsx("polygon",{points:`${K-2},${A} ${K-8},${A-5} ${K-8},${A+5}`,fill:"var(--nice-text-primary, #333)",children:e.jsx("title",{children:l})}),O&&j.map((i,m)=>e.jsx("text",{x:K+N+6,y:z+V*(1-(i-n)/(r-n||1)),dominantBaseline:"middle",className:"nice-gauge__tick",children:Math.round(i*100)/100},m)),Z&&e.jsx("text",{x:C/2,y:d-6,textAnchor:"middle",className:"nice-gauge__label",children:h})]})})},Se=["#3b82f6","#ef4444","#22c55e","#f59e0b","#8b5cf6","#ec4899","#06b6d4","#84cc16"],zt=[],Qe=20,Dt=10,Et=32,Lt=({items:t=zt,min:n=0,max:r=100,width:a=300,height:c=300,startAngle:f=225,endAngle:s=-45,formatValue:h,title:v,className:b,style:_,testId:S,"data-testid":O})=>{const I=i=>i*Math.PI/180,B=(f-s+360)%360||360,g=[I(f),I(s)],M=i=>(f-i+720)%360<=B,k=M(90)?1:Math.max(0,...g.map(i=>Math.sin(i))),T=M(270)?1:Math.max(0,...g.map(i=>-Math.sin(i))),E=M(180)?1:Math.max(0,...g.map(i=>-Math.cos(i))),N=M(0)?1:Math.max(0,...g.map(i=>Math.cos(i))),l=v?Et:0,o=Dt+Qe/2,y=a-2*o,j=c-l-2*o,d=Math.max(0,Math.min(y/(E+N||1),j/(k+T||1))),C=o+E*d+(y-(E+N)*d)/2,F=l+o+k*d+(j-(k+T)*d)/2,Z=Math.min(Qe,d/(t.length+1)),z=4,J=Math.max(0,d-(t.length-1)*(Z+z)-Z/2-2),V=Math.min(20,Math.max(9,J*1.5/Math.max(1,t.length))),K=V/1.3,A=(i,m,x)=>{const U=C+i*Math.cos(I(m)),$=F-i*Math.sin(I(m)),w=C+i*Math.cos(I(x)),Y=F-i*Math.sin(I(x)),X=(m-x+360)%360;return`M${U},${$} A${i},${i} 0 ${X>180?1:0},1 ${w},${Y}`};return e.jsx("div",{className:`nice-bargauge ${b||""}`,style:_,"data-testid":O??S,children:e.jsxs("svg",{width:a,height:c,viewBox:`0 0 ${a} ${c}`,style:{maxWidth:"100%",height:"auto"},children:[v&&e.jsx("text",{x:a/2,y:20,textAnchor:"middle",className:"nice-chart__title",children:v}),t.map((i,m)=>{const x=d-m*(Z+z),U=Math.max(0,Math.min(1,(i.value-n)/(r-n||1))),$=f-U*B,w=i.color||Se[m%Se.length];return e.jsxs("g",{children:[e.jsx("path",{d:A(x,f,s),fill:"none",stroke:"var(--nice-border-color, #e2e8f0)",strokeWidth:Z,strokeLinecap:"round"}),U>0&&e.jsx("path",{d:A(x,f,$),fill:"none",stroke:w,strokeWidth:Z,strokeLinecap:"round"})]},m)}),e.jsx("g",{children:t.map((i,m)=>{const x=F-((t.length-1)/2-m)*V,U=h?h(i.value):i.value;return e.jsx("g",{style:{fontSize:K},children:i.label?e.jsxs(e.Fragment,{children:[e.jsx("text",{x:C-3,y:x,textAnchor:"end",dominantBaseline:"middle",className:"nice-bargauge__label",children:i.label}),e.jsx("text",{x:C+3,y:x,textAnchor:"start",dominantBaseline:"middle",className:"nice-gauge__value nice-bargauge__value",style:{fill:i.color||Se[m%Se.length]},children:U})]}):e.jsx("text",{x:C,y:x,textAnchor:"middle",dominantBaseline:"middle",className:"nice-gauge__value nice-bargauge__value",style:{fill:i.color||Se[m%Se.length]},children:U})},m)})})]})})},Bt={sm:{width:160,height:22,fontSize:11},md:{width:220,height:32,fontSize:12},lg:{width:320,height:44,fontSize:14}},Ft=({value:t,target:n,min:r=0,max:a=100,width:c,height:f,color:s="var(--nice-color-primary, #3b82f6)",targetColor:h="var(--nice-color-error, #ef4444)",size:v="md",label:b,labelPlacement:_="top",showValue:S=!1,showTarget:O=!1,formatValue:I=N=>String(N),state:B="normal",errorMessage:g,className:M,style:k,testId:T,"data-testid":E})=>{const{t:N}=pe.useNiceTranslation(),l=Bt[v],o=c??l.width,y=f??l.height,j=l.fontSize,d=4,C=o-d*2,F=O&&n!=null?j+4:d,Z=O&&n!=null?y+(F-d):y,z=Z-F-d,J=Math.max(0,Math.min(1,(t-r)/(a-r||1))),V=n!=null?Math.max(0,Math.min(1,(n-r)/(a-r||1))):null,K=()=>B==="error"?e.jsx("div",{role:"alert",style:{width:o,height:Z,display:"flex",alignItems:"center",justifyContent:"center",border:"1px dashed var(--nice-color-error, #ef4444)",borderRadius:4,color:"var(--nice-color-error, #ef4444)",fontSize:j,padding:"0 8px",boxSizing:"border-box"},children:g??N("bullet.error","Error")}):B==="loading"?e.jsx("div",{role:"status","aria-label":N("bullet.loading","Loading"),className:"nice-bullet__skeleton",style:{width:o,height:Z,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:o,height:Z,viewBox:`0 0 ${o} ${Z}`,style:{maxWidth:"100%",height:"auto"},role:"img","aria-label":typeof b=="string"?b:void 0,children:[e.jsx("rect",{x:d,y:F,width:C,height:z,rx:3,fill:"var(--nice-border-color, #e2e8f0)"}),e.jsx("rect",{x:d,y:F+z*.2,width:C*J,height:z*.6,rx:2,fill:s}),V!=null&&e.jsx("line",{x1:d+C*V,y1:F+2,x2:d+C*V,y2:F+z-2,stroke:h,strokeWidth:2}),S&&e.jsx("text",{x:d+Math.max(C*J,4),y:F+z/2+j*.08,dx:C*J>24?-4:4,textAnchor:C*J>24?"end":"start",dominantBaseline:"middle",fontSize:j,fill:C*J>24?"var(--nice-color-white, #ffffff)":"var(--nice-text-primary)",fontWeight:600,children:I(t)}),O&&V!=null&&e.jsx("text",{x:d+C*V,y:F-2,textAnchor:"middle",fontSize:j-1,fill:h,fontWeight:600,children:I(n)})]});if(_==="none"||!b)return e.jsxs("div",{className:`nice-bullet ${M||""}`,style:k,"data-testid":E??T,children:[K(),e.jsx("style",{children:et})]});const A=_==="top"||_==="bottom",i=e.jsx("span",{className:"nice-bullet__label",style:{fontSize:j,fontWeight:600,color:"var(--nice-text-primary)",...A?{marginBottom:_==="top"?4:0,marginTop:_==="bottom"?4:0}:{},..._==="left"?{marginRight:8}:{},..._==="right"?{marginLeft:8}:{}},children:b});return e.jsxs("div",{className:`nice-bullet nice-bullet--${_} ${M||""}`,style:{display:"inline-flex",flexDirection:A?"column":"row",alignItems:A?"flex-start":"center",...k},"data-testid":E??T,children:[(_==="top"||_==="left")&&i,K(),(_==="bottom"||_==="right")&&i,e.jsx("style",{children:et})]})},et=`
2
+ @keyframes nice-bullet-shimmer {
3
+ 0% { background-position: 200% 0; }
4
+ 100% { background-position: -200% 0; }
5
+ }
6
+ `,Ot=[],De=12,tt=20,nt=7,rt=22,Ut=({data:t=Ot,width:n=400,height:r=400,innerRadius:a=0,title:c,showLegend:f=!0,legendPlacement:s="right",showLabels:h=!0,splitSize:v=2,className:b,style:_,testId:S,"data-testid":O})=>{const I=`nice-pie-gaps-${u.useId().replace(/[^a-zA-Z0-9_-]/g,"")}`,B=t.reduce((A,i)=>A+i.value,0),g=c?32:0,M=t.reduce((A,i)=>Math.max(A,i.label.length),0),k=s==="left"||s==="right",T=Math.min(n*(k?.42:.9),rt+M*nt),E=k?1:Math.max(1,Math.floor((n-2*De)/(T+12))),l=(f?Math.ceil(t.length/E):0)*tt,o={x:De,y:g+De/2,w:n-2*De,h:r-g-De};f&&t.length>0&&(s==="right"?o.w-=T+De:s==="left"?(o.x+=T+De,o.w-=T+De):(s==="top"&&(o.y+=l+8),o.h-=l+8));const y=o.x+o.w/2,j=o.y+o.h/2,d=Math.max(10,Math.min(o.w,o.h)/2-4),C=s==="right"?n-De-T:De,F=s==="top"?g+4:s==="bottom"?r-De/2-l:j-l/2,Z=A=>{const i=Math.max(3,Math.floor((T-rt)/nt));return A.length>i?`${A.slice(0,i-1)}…`:A};let z=-Math.PI/2;const J=[],V=t.map((A,i)=>{const m=A.value/(B||1)*Math.PI*2,x=z;z+=m;const U=z,$=(x+U)/2;m>0&&J.push(x);const w=y+d*Math.cos(x),Y=j+d*Math.sin(x),X=y+d*Math.cos(U),oe=j+d*Math.sin(U),ie=m>Math.PI?1:0,ue=A.color||Se[i%Se.length],P=m>=Math.PI*2-1e-9;let G;if(P){const ne=(re,be)=>`M${y-re},${j} A${re},${re} 0 1,${be} ${y+re},${j} A${re},${re} 0 1,${be} ${y-re},${j} Z`;G=a>0?`${ne(d,1)} ${ne(a,0)}`:ne(d,1)}else if(a>0){const ne=y+a*Math.cos(x),re=j+a*Math.sin(x),be=y+a*Math.cos(U),ke=j+a*Math.sin(U);G=`M${w},${Y} A${d},${d} 0 ${ie},1 ${X},${oe} L${be},${ke} A${a},${a} 0 ${ie},0 ${ne},${re} Z`}else G=`M${y},${j} L${w},${Y} A${d},${d} 0 ${ie},1 ${X},${oe} Z`;const p=Math.min(Math.max(a,0),d),D=p>0?(p+d)/2:d*.65,H=P?y:y+D*Math.cos($),W=P?j:j+D*Math.sin($),te=B>0?Math.round(A.value/B*100):0;return{...A,path:G,labelX:H,labelY:W,pct:te,color:ue}}),K=v>0&&J.length>1;return e.jsx("div",{className:`nice-piechart ${b||""}`,style:_,"data-testid":O??S,children:e.jsxs("svg",{viewBox:`0 0 ${n} ${r}`,preserveAspectRatio:"xMidYMid meet",width:"100%",height:"100%",style:{display:"block",maxWidth:"100%",maxHeight:"100%"},className:"nice-piechart__svg",children:[K&&e.jsx("defs",{children:e.jsxs("mask",{id:I,maskUnits:"userSpaceOnUse",x:0,y:0,width:n,height:r,children:[e.jsx("rect",{x:0,y:0,width:n,height:r,fill:"white"}),J.map((A,i)=>e.jsx("line",{x1:y,y1:j,x2:y+(d+v)*Math.cos(A),y2:j+(d+v)*Math.sin(A),stroke:"black",strokeWidth:v},i))]})}),c&&e.jsx("text",{x:n/2,y:20,textAnchor:"middle",className:"nice-chart__title",children:c}),e.jsx("g",{mask:K?`url(#${I})`:void 0,children:V.map((A,i)=>e.jsx("path",{d:A.path,fill:A.color,children:e.jsx("title",{children:`${A.label}: ${A.value} (${A.pct}%)`})},i))}),h&&V.map((A,i)=>A.pct>=5?e.jsxs("text",{x:A.labelX,y:A.labelY,textAnchor:"middle",dominantBaseline:"middle",className:"nice-piechart__label",children:[A.pct,"%"]},i):null),f&&e.jsx("g",{transform:`translate(${C}, ${F})`,children:t.map((A,i)=>e.jsxs("g",{transform:`translate(${i%E*(T+12)}, ${Math.floor(i/E)*tt})`,children:[e.jsx("rect",{y:3,width:10,height:10,rx:2,fill:A.color||Se[i%Se.length]}),e.jsxs("text",{x:16,y:12,className:"nice-chart__legend-text",children:[Z(A.label)!==A.label&&e.jsx("title",{children:A.label}),Z(A.label)]})]},i))})]})})},Ht=[],Wt=({data:t=Ht,width:n=400,height:r=300,inverted:a,showLabels:c=!0,showValues:f=!0,title:s,className:h,style:v,testId:b,"data-testid":_})=>{const S={top:s?30:10,bottom:10,x:40},O=n-S.x*2,I=r-S.top-S.bottom,B=a?[...t].reverse():t,g=Math.max(...B.map(k=>k.value),1),M=I/B.length;return e.jsx("div",{className:`nice-funnel ${h||""}`,style:v,"data-testid":_??b,children:e.jsxs("svg",{width:n,height:r,children:[s&&e.jsx("text",{x:n/2,y:20,textAnchor:"middle",className:"nice-chart__title",children:s}),B.map((k,T)=>{const E=k.value/g*O,N=T<B.length-1?B[T+1].value/g*O:E*.3,l=S.top+T*M,o=l+M,y=n/2,j=`${y-E/2},${l} ${y+E/2},${l} ${y+N/2},${o} ${y-N/2},${o}`,d=k.color||Se[T%Se.length];return e.jsxs("g",{children:[e.jsx("polygon",{points:j,fill:d,stroke:"var(--nice-bg-primary, #fff)",strokeWidth:1,children:e.jsx("title",{children:`${k.label}: ${k.value}`})}),c&&e.jsx("text",{x:y,y:l+M/2-(f?4:0),textAnchor:"middle",dominantBaseline:"middle",className:"nice-funnel__label",children:k.label}),f&&e.jsx("text",{x:y,y:l+M/2+10,textAnchor:"middle",dominantBaseline:"middle",className:"nice-funnel__value",children:k.value})]},T)})]})})},Pt=[],Yt=["var(--nice-primary-bg, #e0f2fe)","var(--nice-color-primary-active, #1d4ed8)"];function Xt(t,n){const r=Math.max(0,Math.min(1,n));return t.length===3?r<.5?`color-mix(in srgb, ${t[1]} ${Math.round(r*200)}%, ${t[0]})`:`color-mix(in srgb, ${t[2]} ${Math.round((r-.5)*200)}%, ${t[1]})`:`color-mix(in srgb, ${t[1]} ${Math.round(r*100)}%, ${t[0]})`}const Vt=Object.assign(u.forwardRef(({data:t=Pt,xLabels:n,yLabels:r,colors:a=Yt,onCellClick:c,cellSize:f=32,showValues:s=!1,showLegend:h=!0,showTooltip:v=!0,responsive:b=!0,min:_,max:S,cellGap:O=2,cellRadius:I=3,emptyColor:B="var(--nice-bg-tertiary, #f1f5f9)",formatValue:g,xAxisLabel:M,yAxisLabel:k,className:T,style:E,id:N,testId:l,"data-testid":o},y)=>{const j=pe.useControlId(N),[d,C]=u.useState(null),F=u.useRef(null);u.useEffect(()=>{const m=F.current;if(!m)return;const x=$=>{const w=$.target.closest("[data-cell]");w&&C({r:Number(w.dataset.r),c:Number(w.dataset.c)})},U=()=>C(null);return m.addEventListener("mouseover",x),m.addEventListener("focusin",x),m.addEventListener("mouseleave",U),()=>{m.removeEventListener("mouseover",x),m.removeEventListener("focusin",x),m.removeEventListener("mouseleave",U)}},[]);const Z=m=>g?g(m):String(m),{lo:z,hi:J}=u.useMemo(()=>{let m=1/0,x=-1/0;for(const U of t)for(const $ of U)$==null||!Number.isFinite($)||(m=Math.min(m,$),x=Math.max(x,$));return{lo:_??(Number.isFinite(m)?m:0),hi:S??(Number.isFinite(x)?x:1)}},[t,_,S]),V=m=>J===z?.5:(m-z)/(J-z),K=t.reduce((m,x)=>Math.max(m,x.length),0),A=b?`minmax(${f}px, 1fr)`:`${f}px`,i=d?t[d.r]?.[d.c]??null:null;return e.jsxs("div",{ref:y,id:j,className:`nice-heatmap ${T||""}`,style:E,"data-testid":o??l,children:[M&&e.jsx("div",{className:"nice-heatmap__axis nice-heatmap__axis--x",children:M}),e.jsxs("div",{className:"nice-heatmap__body",children:[k&&e.jsx("div",{className:"nice-heatmap__axis nice-heatmap__axis--y",children:k}),e.jsxs("div",{ref:F,className:"nice-heatmap__grid",role:"table",style:{gridTemplateColumns:`${r?"auto ":""}repeat(${K}, ${A})`,gap:O},children:[n&&e.jsxs("div",{role:"row",className:"nice-heatmap__row nice-heatmap__row--header",children:[r&&e.jsx("span",{}),Array.from({length:K},(m,x)=>e.jsx("span",{role:"columnheader",className:"nice-heatmap__header",children:n[x]??""},x))]}),t.map((m,x)=>e.jsxs("div",{role:"row",className:"nice-heatmap__row",children:[r&&e.jsx("span",{role:"rowheader",className:"nice-heatmap__row-label",children:r[x]??""}),Array.from({length:K},(U,$)=>{const w=m[$]??null,Y=w==null?0:V(w),X=`${r?.[x]??`#${x+1}`} × ${n?.[$]??`#${$+1}`}: ${w==null?"—":Z(w)}`;return e.jsx("span",{role:"cell","data-cell":"","data-r":x,"data-c":$,"aria-label":c?void 0:X,className:`nice-heatmap__cell${d?.r===x&&d?.c===$?" nice-heatmap__cell--hover":""}`,style:{minHeight:f,borderRadius:I,background:w==null?B:Xt(a,Y),color:Y>.6?"var(--nice-color-white, #fff)":"var(--nice-text-primary, #333)"},children:c?e.jsx("button",{type:"button",className:"nice-heatmap__cell-btn","aria-label":X,onClick:()=>c(x,$,w),children:s&&w!=null?Z(w):""}):s&&w!=null?Z(w):""},$)})]},x))]})]}),v&&d&&e.jsxs("div",{className:"nice-heatmap__tooltip",role:"status",children:[e.jsxs("strong",{children:[r?.[d.r]??`#${d.r+1}`," ×"," ",n?.[d.c]??`#${d.c+1}`]}),e.jsx("span",{children:i==null?"—":Z(i)})]}),h&&e.jsxs("div",{className:"nice-heatmap__legend","aria-hidden":"true",children:[e.jsx("span",{children:Z(z)}),e.jsx("span",{className:"nice-heatmap__legend-bar",style:{background:`linear-gradient(90deg, ${a.join(", ")})`}}),e.jsx("span",{children:Z(J)})]})]})}),{displayName:"NiceHeatMap"}),Gt=[],Zt=[];function qt(t,n){const r=new Map(t.map(s=>[s.id,0]));for(let s=0;s<t.length;s++){let h=!1;for(const v of n){const b=(r.get(v.source)??0)+1;r.has(v.target)&&b>(r.get(v.target)??0)&&b<t.length&&(r.set(v.target,b),h=!0)}if(!h)break}const a=Math.max(0,...r.values()),c=new Set(n.map(s=>s.source)),f=new Set(n.map(s=>s.target));for(const s of t)f.has(s.id)&&!c.has(s.id)&&r.set(s.id,a);return r}const lt=({nodes:t=Gt,links:n=Zt,width:r=600,height:a=400,nodeWidth:c=20,nodePadding:f=10,title:s,showValues:h=!1,showTooltip:v=!0,gradientLinks:b=!0,onNodeClick:_,onLinkClick:S,className:O,style:I,testId:B,"data-testid":g})=>{const M=u.useId().replace(/[^a-zA-Z0-9_-]/g,""),k={top:s?40:16,bottom:16,left:12,right:12},T=r-k.left-k.right,E=a-k.top-k.bottom,N=o=>o.label??o.name??o.id,l=u.useMemo(()=>{const o=qt(t,n),y=Math.max(1,...[...o.values()].map(m=>m+1)),j=new Map;for(const m of t){const x=n.filter($=>$.source===m.id).reduce(($,w)=>$+w.value,0),U=n.filter($=>$.target===m.id).reduce(($,w)=>$+w.value,0);j.set(m.id,Math.max(x,U))}const d=Array.from({length:y},()=>[]);t.forEach(m=>d[o.get(m.id)??0].push(m));const C=Math.min(...d.filter(m=>m.length>0).map(m=>{const x=m.reduce((U,$)=>U+(j.get($.id)||0),0);return x>0?(E-(m.length-1)*f)/x:1/0})),F=Number.isFinite(C)?Math.max(0,C):0,Z=new Map;d.forEach((m,x)=>{const U=k.left+(y>1?x/(y-1)*(T-c):(T-c)/2),$=m.reduce((Y,X)=>Y+(j.get(X.id)||0)*F,0)+(m.length-1)*f;let w=k.top+Math.max(0,(E-$)/2);m.forEach(Y=>{const X=(j.get(Y.id)||0)*F;Z.set(Y.id,{node:Y,color:Y.color||Se[t.indexOf(Y)%Se.length],depth:x,value:j.get(Y.id)||0,x:U,y:w,h:X}),w+=X+f})});const z=new Map,J=new Map,i=[...[...n].sort((m,x)=>(Z.get(m.target)?.y??0)-(Z.get(x.target)?.y??0)).map(m=>{const x=Z.get(m.source),U=z.get(m.source)??0,$=m.value*F;return z.set(m.source,U+$),{link:m,y0:(x?.y??0)+U,w:$}})].sort((m,x)=>(Z.get(m.link.source)?.y??0)-(Z.get(x.link.source)?.y??0)).map(m=>{const x=Z.get(m.link.target),U=J.get(m.link.target)??0;return J.set(m.link.target,U+m.w),{...m,y1:(x?.y??0)+U}});return{placed:Z,flows:i}},[t,n,E,T,f,c,k.left,k.top]);return e.jsx("div",{className:`nice-sankey ${O||""}`,style:I,"data-testid":g??B,children:e.jsxs("svg",{width:r,height:a,viewBox:`0 0 ${r} ${a}`,style:{maxWidth:"100%",height:"auto"},children:[s&&e.jsx("text",{x:r/2,y:22,textAnchor:"middle",className:"nice-chart__title",children:s}),b&&e.jsx("defs",{children:l.flows.map((o,y)=>{const j=l.placed.get(o.link.source),d=l.placed.get(o.link.target);return!j||!d||o.link.color?null:e.jsxs("linearGradient",{id:`${M}-g${y}`,gradientUnits:"userSpaceOnUse",x1:j.x+c,x2:d.x,y1:0,y2:0,children:[e.jsx("stop",{offset:"0%",stopColor:j.color}),e.jsx("stop",{offset:"100%",stopColor:d.color})]},y)})}),l.flows.map((o,y)=>{const j=l.placed.get(o.link.source),d=l.placed.get(o.link.target);if(!j||!d)return null;const C=j.x+c,F=d.x,Z=(C+F)/2,z=o.link.color??(b?`url(#${M}-g${y})`:j.color);return e.jsx("path",{className:"nice-sankey__link",d:`M${C},${o.y0} C${Z},${o.y0} ${Z},${o.y1} ${F},${o.y1} L${F},${o.y1+o.w} C${Z},${o.y1+o.w} ${Z},${o.y0+o.w} ${C},${o.y0+o.w} Z`,fill:z,fillOpacity:.45,onClick:S?()=>S(o.link):void 0,style:S?{cursor:"pointer"}:void 0,children:v&&e.jsx("title",{children:`${N(j.node)} → ${N(d.node)}: ${o.link.value}`})},y)}),[...l.placed.values()].map(o=>{const y=o.x+c/2>r/2;return e.jsxs("g",{children:[e.jsx("rect",{x:o.x,y:o.y,width:c,height:Math.max(o.h,2),fill:o.color,onClick:_?()=>_(o.node):void 0,style:_?{cursor:"pointer"}:void 0,children:v&&e.jsx("title",{children:`${N(o.node)}: ${o.value}`})}),e.jsxs("text",{x:y?o.x-6:o.x+c+6,y:o.y+o.h/2,textAnchor:y?"end":"start",dominantBaseline:"middle",className:"nice-sankey__label",children:[N(o.node),h?` (${o.value})`:""]})]},o.node.id)})]})})},Kt=Object.freeze(Object.defineProperty({__proto__:null,NiceSankey:lt},Symbol.toStringTag,{value:"Module"})),Jt=[],Qt=Se,en=["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)"],dt=Object.assign(u.forwardRef((t,n)=>{const{t:r}=pe.useNiceTranslation(),{levels:a=Jt,initialLevelId:c,levelId:f,chartType:s="bar",width:h=600,height:v=400,showBreadcrumbs:b=!0,showBackButton:_=!0,animationDuration:S=300,onLevelChange:O,onItemClick:I,colors:B=en,showValues:g=!0,showLegend:M=!0,className:k,style:T,testId:E,"data-testid":N,...l}=t,o=f!==void 0,[y,j]=u.useState(c||a[0]?.id),[d,C]=u.useState([c||a[0]?.id]),F=u.useCallback(P=>{const G=[];let p=a.find(D=>D.id===P);for(;p&&!G.includes(p.id);){G.unshift(p.id);const D=p.parentId;p=D?a.find(H=>H.id===D):void 0}return G.length>0?G:[P]},[a]),Z=f??y,z=u.useMemo(()=>f!==void 0?F(f):d,[f,d,F]),[J,V]=u.useState(!1),[K,A]=u.useState("in"),i=u.useMemo(()=>a.find(P=>P.id===Z),[a,Z]),m=u.useCallback(P=>{a.find(p=>p.id===P)&&(A("in"),V(!0),setTimeout(()=>{o||(j(P),C(p=>[...p,P])),O?.(P,o?F(P):[...z,P]),V(!1)},S/2))},[a,z,S,O,o,F]),x=u.useCallback(()=>{if(z.length<=1)return;A("out"),V(!0);const P=z.slice(0,-1),G=P[P.length-1];setTimeout(()=>{o||(j(G),C(P)),O?.(G,P),V(!1)},S/2)},[z,S,O,o]),U=u.useCallback(()=>{const P=a[0]?.id;P&&(A("out"),V(!0),setTimeout(()=>{o||(j(P),C([P])),O?.(P,[P]),V(!1)},S/2))},[a,S,O,o]);u.useImperativeHandle(n,()=>({drillDown:m,drillUp:x,resetToRoot:U,getCurrentLevel:()=>Z,getPath:()=>z}),[m,x,U,Z,z]);const $=u.useCallback((P,G)=>{I?.(P,Z);const p=P.drillDownId??P.metadata?.childLevelId,D=p?a.find(H=>H.id===p):void 0;D&&m(D.id)},[Z,a,m,I]),w=u.useMemo(()=>i?.data.reduce((P,G)=>P+G.value,0)||0,[i]),Y=u.useMemo(()=>z.map(P=>a.find(G=>G.id===P)?.label||P),[z,a]),X=()=>{if(!i)return null;const P=i.data,G=Math.max(...P.map(D=>D.value)),p=Math.min(40,(v-100)/P.length-8);return e.jsx("div",{className:"nice-drilldown-bars",children:P.map((D,H)=>{const W=D.value/G*100;return e.jsxs("div",{role:"button",tabIndex:0,onKeyDown:pe.clickOnActivationKey,className:"nice-drilldown-bar-row",onClick:()=>$(D,H),children:[e.jsx("span",{className:"nice-drilldown-bar-label",children:D.label||r("charts.item","Item {i}").replace("{i}",String(H+1))}),e.jsx("div",{className:"nice-drilldown-bar-track",children:e.jsx("div",{className:"nice-drilldown-bar-fill",style:{width:`${W}%`,backgroundColor:D.color||B[H%B.length],height:p}})}),g&&e.jsx("span",{className:"nice-drilldown-bar-value",children:D.value.toLocaleString()})]},H)})})},oe=`nice-drill-gaps-${u.useId().replace(/[^a-zA-Z0-9_-]/g,"")}`,ie=()=>{if(!i)return null;const P=i.data,G=v-40,p=h/2,D=G/2,H=Math.max(10,Math.min(h,G)/2-16);let W=-90;const te=P.map((re,be)=>{const ke=re.value/w*360,Q=W+ke,ce=ke>180?1:0,q=W*Math.PI/180,le=Q*Math.PI/180,ye=p+H*Math.cos(q),Me=D+H*Math.sin(q),_e=p+H*Math.cos(le),we=D+H*Math.sin(le),R=(W+ke/2)*Math.PI/180,se=p+H*.7*Math.cos(R),de=D+H*.7*Math.sin(R),ee=`M ${p} ${D} L ${ye} ${Me} A ${H} ${H} 0 ${ce} 1 ${_e} ${we} Z`;return W=Q,{path:ee,startRad:q,drillable:!!(re.drillDownId??re.metadata?.childLevelId),color:re.color||B[be%B.length],label:re.label||r("charts.item","Item {i}").replace("{i}",String(be+1)),value:re.value,percentage:(re.value/w*100).toFixed(1),labelX:se,labelY:de,item:re,index:be}}),ne=te.length>1?te.map(re=>re.startRad):[];return e.jsxs("svg",{width:h,height:G,className:"nice-drilldown-pie",children:[ne.length>0&&e.jsx("defs",{children:e.jsxs("mask",{id:oe,maskUnits:"userSpaceOnUse",x:0,y:0,width:h,height:G,children:[e.jsx("rect",{x:0,y:0,width:h,height:G,fill:"white"}),ne.map((re,be)=>e.jsx("line",{x1:p,y1:D,x2:p+(H+2)*Math.cos(re),y2:D+(H+2)*Math.sin(re),stroke:"black",strokeWidth:2},be))]})}),e.jsx("g",{mask:ne.length>0?`url(#${oe})`:void 0,children:te.map((re,be)=>e.jsx("path",{d:re.path,fill:re.color,className:`nice-drilldown-pie-slice${re.drillable?" nice-drilldown-pie-slice--drillable":""}`,onClick:()=>$(re.item,re.index),children:e.jsx("title",{children:`${re.label}: ${re.value} (${re.percentage}%)`})},be))}),g&&te.map((re,be)=>parseFloat(re.percentage)>5?e.jsxs("text",{x:re.labelX,y:re.labelY,textAnchor:"middle",dominantBaseline:"middle",className:"nice-piechart__label",style:{fontSize:13,pointerEvents:"none"},children:[re.percentage,"%"]},be):null)]})},ue=()=>{if(!i)return null;const P=i.data,G=Math.max(...P.map(H=>H.value)),p=Math.min(60,(h-100)/P.length-8),D=v-100;return e.jsx("svg",{width:h,height:v-40,className:"nice-drilldown-columns",children:e.jsxs("g",{transform:"translate(50, 20)",children:[[0,.25,.5,.75,1].map((H,W)=>e.jsxs("g",{children:[e.jsx("line",{x1:0,y1:D*(1-H),x2:h-80,y2:D*(1-H),stroke:"var(--nice-border-color, #e5e7eb)",strokeDasharray:H===0?void 0:"4"}),e.jsx("text",{x:-8,y:D*(1-H),textAnchor:"end",dominantBaseline:"middle",fontSize:"11",fill:"var(--nice-text-secondary, #6b7280)",children:Math.round(G*H).toLocaleString()})]},W)),P.map((H,W)=>{const te=H.value/G*D,ne=W*((h-100)/P.length)+((h-100)/P.length-p)/2;return e.jsxs("g",{onClick:()=>$(H,W),children:[e.jsx("rect",{x:ne,y:D-te,width:p,height:te,fill:H.color||B[W%B.length],rx:4,className:"nice-drilldown-column-bar"}),e.jsx("text",{x:ne+p/2,y:D+16,textAnchor:"middle",fontSize:"11",fill:"var(--nice-text-primary, #374151)",children:(H.label||`${W+1}`).slice(0,10)}),g&&e.jsx("text",{x:ne+p/2,y:D-te-8,textAnchor:"middle",fontSize:"11",fill:"var(--nice-text-primary, #374151)",fontWeight:"500",children:H.value.toLocaleString()})]},W)})]})})};return e.jsxs("div",{className:`nice-drilldown-chart ${J?`animating ${K}`:""} ${k||""}`,style:{width:h,...T},"data-testid":N??E,...l,children:[e.jsxs("div",{className:"nice-drilldown-header",children:[_&&e.jsxs("button",{type:"button",className:"nice-drilldown-back",onClick:x,disabled:z.length<=1,children:[e.jsx(pe.NiceIcon,{name:"arrow-left",size:14})," ",r("charts.back","Back")]}),b&&e.jsx("div",{className:"nice-drilldown-breadcrumbs",children:Y.map((P,G)=>e.jsxs(u.Fragment,{children:[G>0&&e.jsx("span",{className:"nice-drilldown-separator",children:"/"}),e.jsx("span",{role:G<Y.length-1?"button":void 0,tabIndex:G<Y.length-1?0:void 0,"aria-current":G===Y.length-1?"location":void 0,onKeyDown:G<Y.length-1?pe.clickOnActivationKey:void 0,className:`nice-drilldown-crumb ${G===Y.length-1?"active":""}`,onClick:()=>{if(G<Y.length-1){const p=z.slice(0,G+1),D=p[p.length-1];o||(C(p),j(D)),O?.(D,p)}},children:P})]},G))})]}),e.jsxs("div",{className:"nice-drilldown-content",style:{height:v-40},children:[s==="bar"&&X(),s==="pie"&&ie(),s==="column"&&ue()]}),M&&i&&e.jsx("div",{className:"nice-drilldown-legend",children:i.data.map((P,G)=>e.jsxs("div",{className:"nice-drilldown-legend-item",children:[e.jsx("span",{className:"nice-drilldown-legend-color",style:{backgroundColor:P.color||B[G%B.length]}}),e.jsx("span",{className:"nice-drilldown-legend-label",children:P.label||r("charts.item","Item {i}").replace("{i}",String(G+1))})]},G))}),e.jsx("style",{children:`
7
+ .nice-drilldown-chart {
8
+ font-family: inherit;
9
+ color: var(--nice-text-primary, #111827);
10
+ background: var(--nice-bg-elevated, #ffffff);
11
+ border-radius: 8px;
12
+ overflow: hidden;
13
+ }
14
+
15
+ .nice-drilldown-header {
16
+ display: flex;
17
+ align-items: center;
18
+ gap: 12px;
19
+ padding: 12px 16px;
20
+ border-bottom: 1px solid var(--nice-border-color, #e5e7eb);
21
+ min-height: 40px;
22
+ }
23
+
24
+ .nice-drilldown-back {
25
+ background: var(--nice-bg-secondary, #f3f4f6);
26
+ border: none;
27
+ padding: 6px 12px;
28
+ border-radius: 6px;
29
+ cursor: pointer;
30
+ font-size: 13px;
31
+ font-family: inherit;
32
+ color: var(--nice-text-primary, #374151);
33
+ transition: background 0.2s;
34
+ }
35
+
36
+ .nice-drilldown-back:hover {
37
+ background: var(--nice-hover-bg, #e5e7eb);
38
+ }
39
+
40
+ .nice-drilldown-breadcrumbs {
41
+ display: flex;
42
+ align-items: center;
43
+ gap: 4px;
44
+ font-size: 13px;
45
+ font-family: inherit;
46
+ }
47
+
48
+ .nice-drilldown-separator {
49
+ color: var(--nice-text-muted, #9ca3af);
50
+ }
51
+
52
+ .nice-drilldown-crumb {
53
+ color: var(--nice-text-secondary, #6b7280);
54
+ cursor: pointer;
55
+ }
56
+
57
+ .nice-drilldown-crumb:hover:not(.active) {
58
+ color: var(--nice-color-primary, #3b82f6);
59
+ }
60
+
61
+ .nice-drilldown-crumb.active {
62
+ color: var(--nice-text-primary, #111827);
63
+ font-weight: 500;
64
+ cursor: default;
65
+ }
66
+
67
+ .nice-drilldown-content {
68
+ padding: 16px;
69
+ transition: opacity 0.15s, transform 0.15s;
70
+ }
71
+
72
+ .nice-drilldown-chart.animating .nice-drilldown-content {
73
+ opacity: 0;
74
+ }
75
+
76
+ .nice-drilldown-chart.animating.in .nice-drilldown-content {
77
+ transform: translateX(20px);
78
+ }
79
+
80
+ .nice-drilldown-chart.animating.out .nice-drilldown-content {
81
+ transform: translateX(-20px);
82
+ }
83
+
84
+ .nice-drilldown-bars {
85
+ display: flex;
86
+ flex-direction: column;
87
+ gap: 8px;
88
+ }
89
+
90
+ .nice-drilldown-bar-row {
91
+ display: flex;
92
+ align-items: center;
93
+ gap: 12px;
94
+ cursor: pointer;
95
+ padding: 4px 8px;
96
+ margin: -4px -8px;
97
+ border-radius: 6px;
98
+ transition: background 0.2s;
99
+ }
100
+
101
+ .nice-drilldown-bar-row:hover {
102
+ background: var(--nice-hover-bg, #f9fafb);
103
+ }
104
+
105
+ .nice-drilldown-bar-label {
106
+ width: 120px;
107
+ font-size: 13px;
108
+ font-family: inherit;
109
+ color: var(--nice-text-primary, #374151);
110
+ overflow: hidden;
111
+ text-overflow: ellipsis;
112
+ white-space: nowrap;
113
+ }
114
+
115
+ .nice-drilldown-bar-track {
116
+ flex: 1;
117
+ background: var(--nice-bg-tertiary, #f3f4f6);
118
+ border-radius: 6px;
119
+ overflow: hidden;
120
+ }
121
+
122
+ .nice-drilldown-bar-fill {
123
+ transition: width 0.3s ease;
124
+ border-radius: 6px;
125
+ }
126
+
127
+ .nice-drilldown-bar-value {
128
+ width: 80px;
129
+ text-align: right;
130
+ font-size: 13px;
131
+ font-family: inherit;
132
+ font-weight: 500;
133
+ color: var(--nice-text-primary, #111827);
134
+ }
135
+
136
+ .nice-drilldown-pie-slice {
137
+ cursor: pointer;
138
+ transition: transform 0.2s, opacity 0.2s;
139
+ transform-origin: center;
140
+ }
141
+
142
+ .nice-drilldown-pie-slice:hover {
143
+ opacity: 0.85;
144
+ }
145
+ .nice-drilldown-pie-slice--drillable {
146
+ cursor: zoom-in;
147
+ }
148
+ .nice-drilldown-back:disabled {
149
+ opacity: 0.45;
150
+ cursor: default;
151
+ }
152
+
153
+ .nice-drilldown-column-bar {
154
+ cursor: pointer;
155
+ transition: opacity 0.2s;
156
+ }
157
+
158
+ .nice-drilldown-column-bar:hover {
159
+ opacity: 0.8;
160
+ }
161
+
162
+ .nice-drilldown-legend {
163
+ display: flex;
164
+ flex-wrap: wrap;
165
+ gap: 16px;
166
+ padding: 12px 16px;
167
+ border-top: 1px solid var(--nice-border-color, #e5e7eb);
168
+ }
169
+
170
+ .nice-drilldown-legend-item {
171
+ display: flex;
172
+ align-items: center;
173
+ gap: 6px;
174
+ }
175
+
176
+ .nice-drilldown-legend-color {
177
+ width: 12px;
178
+ height: 12px;
179
+ border-radius: 3px;
180
+ }
181
+
182
+ .nice-drilldown-legend-label {
183
+ font-size: 12px;
184
+ font-family: inherit;
185
+ color: var(--nice-text-secondary, #6b7280);
186
+ }
187
+ `})]})}),{displayName:"NiceDrillDownChart"}),tn=[18,36,56,78,100].map(t=>`color-mix(in srgb, var(--nice-color-primary, #3b82f6) ${t}%, var(--nice-bg-primary, #ffffff))`),ht=({type:t="choropleth",regions:n=[],bubbles:r=[],width:a=800,height:c=500,viewBox:f="0 0 800 500",colorScale:s,colorRange:h,minValue:v,maxValue:b,showTooltip:_=!0,showLegend:S=!0,onRegionClick:O,onBubbleClick:I,onRegionHover:B,title:g,mapSvg:M,zoomable:k=!1,selectedRegionId:T,bounds:E,className:N,style:l,testId:o,"data-testid":y,...j})=>{const d=s??h??tn,{t:C}=pe.useNiceTranslation(),[F,Z]=u.useState(null),[z,J]=u.useState(1),[V,K]=u.useState({x:0,y:0}),A=u.useRef(null),i=u.useRef(!1),m=u.useRef({x:0,y:0}),x=u.useRef({x:0,y:0}),U=v??Math.min(...n.map(Q=>Q.value),...r.map(Q=>Q.value)),$=b??Math.max(...n.map(Q=>Q.value),...r.map(Q=>Q.value)),w=$-U,Y=u.useCallback(Q=>Number.isFinite(w)&&w>0?(Q-U)/w:.5,[U,w]),X=u.useCallback(Q=>{const ce=Y(Q);if(t==="heat"){const le=Math.round(Math.max(0,Math.min(1,ce))*100);return`color-mix(in srgb, ${d[d.length-1]} ${le}%, ${d[0]})`}const q=Math.min(Math.floor(ce*d.length),d.length-1);return d[Math.max(0,q)]},[Y,d,t]),oe=f.split(/[\s,]+/).map(Number),[ie,ue,P,G]=oe.length===4&&oe.every(Number.isFinite)?oe:[0,0,a,c],p=(Q,ce)=>{if(!E)return[Q,ce];const[q,le,ye,Me]=E;return[ie+(Q-q)/(ye-q||1)*P,ue+(Me-ce)/(Me-le||1)*G]},D=u.useCallback(Q=>{if(!_||!F)return;const ce=A.current?.getBoundingClientRect();ce&&Z(q=>q?{...q,x:Q.clientX-ce.left,y:Q.clientY-ce.top}:null)},[_,F]),H=u.useCallback((Q,ce)=>{const q=A.current?.getBoundingClientRect();q&&_&&Z({x:ce.clientX-q.left,y:ce.clientY-q.top,content:`${Q.name}: ${Q.value.toLocaleString()}`}),B?.(Q)},[_,B]),W=u.useCallback(()=>{Z(null),B?.(null)},[B]),te=u.useCallback(Q=>{if(!k)return;Q.preventDefault();const ce=Q.deltaY>0?.9:1.1;J(q=>Math.min(Math.max(q*ce,.5),4))},[k]),ne=u.useCallback(Q=>{k&&(i.current=!0,m.current={x:Q.clientX,y:Q.clientY},x.current=V)},[k,V]),re=u.useCallback(()=>{i.current=!1},[]),be=u.useCallback(Q=>{if(!i.current)return;const ce=A.current?.getBoundingClientRect(),q=ce&&ce.width>0?P/ce.width:1;K({x:x.current.x+(Q.clientX-m.current.x)*q,y:x.current.y+(Q.clientY-m.current.y)*q})},[P]),ke=n;return e.jsxs("div",{className:`nice-map-chart ${N||""}`,style:{width:a,...l},"data-testid":y??o,...j,children:[g&&e.jsx("div",{className:"nice-map-title",children:g}),e.jsx("svg",{ref:A,width:a,height:c,viewBox:f,className:"nice-map-svg",onWheel:te,onMouseDown:ne,onMouseUp:re,onMouseLeave:re,onMouseMove:Q=>{D(Q),be(Q)},children:e.jsxs("g",{transform:`translate(${V.x}, ${V.y}) scale(${z})`,children:[M&&e.jsx("image",{href:`data:image/svg+xml;charset=utf-8,${encodeURIComponent(M)}`,x:ie,y:ue,width:P,height:G,preserveAspectRatio:"xMidYMid meet"}),(t==="choropleth"||t==="heat")&&ke.map(Q=>e.jsx("path",{d:Q.path,fill:Q.color||X(Q.value),stroke:Q.id===T?"var(--nice-text-primary, #111827)":"var(--nice-bg-primary, #ffffff)",strokeWidth:Q.id===T?2.5:1,"aria-selected":Q.id===T||void 0,className:"nice-map-region",onClick:()=>O?.(Q),onMouseEnter:ce=>H(Q,ce),onMouseLeave:W},Q.id)),(t==="bubble"||r.length>0)&&r.map(Q=>{const ce=Math.sqrt(Math.max(0,Y(Q.value)))*30+5,[q,le]=p(Q.lng,Q.lat);return e.jsx("circle",{cx:q,cy:le,r:ce,fill:Q.color||"var(--nice-color-primary, #3b82f6)",fillOpacity:.7,stroke:"var(--nice-bg-primary, #ffffff)",strokeWidth:1,className:"nice-map-bubble",onClick:()=>I?.(Q),onMouseEnter:ye=>{const Me=A.current?.getBoundingClientRect();Me&&_&&Z({x:ye.clientX-Me.left,y:ye.clientY-Me.top,content:`${Q.label||Q.id}: ${Q.value.toLocaleString()}`})},onMouseLeave:W,children:Q.label&&e.jsxs("title",{children:[Q.label,": ",Q.value]})},Q.id)})]})}),F&&e.jsx("div",{className:"nice-map-tooltip",style:{left:F.x+10,top:F.y-30},children:F.content}),S&&Number.isFinite(U)&&Number.isFinite($)&&e.jsxs("div",{className:"nice-map-legend",children:[e.jsx("span",{className:"nice-map-legend-title",children:C("charts.value","Value")}),e.jsx("div",{className:"nice-map-legend-scale",children:d.map((Q,ce)=>e.jsx("div",{className:"nice-map-legend-item",style:{backgroundColor:Q}},ce))}),e.jsxs("div",{className:"nice-map-legend-labels",children:[e.jsx("span",{children:U.toLocaleString()}),e.jsx("span",{children:$.toLocaleString()})]})]}),e.jsx("style",{children:`
188
+ .nice-map-chart {
189
+ font-family: system-ui, -apple-system, sans-serif;
190
+ background: var(--nice-bg-primary, #ffffff);
191
+ border-radius: var(--nice-radius-lg, 8px);
192
+ overflow: hidden;
193
+ position: relative;
194
+ }
195
+
196
+ .nice-map-title {
197
+ padding: var(--nice-space-3, 12px) var(--nice-space-4, 16px);
198
+ font-size: 16px;
199
+ font-weight: 600;
200
+ color: var(--nice-text-primary, #0f172a);
201
+ border-bottom: 1px solid var(--nice-border-color, #e5e7eb);
202
+ }
203
+
204
+ .nice-map-svg {
205
+ display: block;
206
+ cursor: grab;
207
+ }
208
+
209
+ .nice-map-svg:active {
210
+ cursor: grabbing;
211
+ }
212
+
213
+ .nice-map-region {
214
+ cursor: pointer;
215
+ transition: opacity 0.2s, stroke-width 0.2s;
216
+ }
217
+
218
+ .nice-map-region:hover {
219
+ opacity: 0.8;
220
+ stroke-width: 2;
221
+ }
222
+
223
+ .nice-map-bubble {
224
+ cursor: pointer;
225
+ transition: transform 0.2s, opacity 0.2s;
226
+ }
227
+
228
+ .nice-map-bubble:hover {
229
+ opacity: 1;
230
+ transform: scale(1.1);
231
+ }
232
+
233
+ .nice-map-tooltip {
234
+ position: absolute;
235
+ /* audit-allow: token-role — inverted chip like .nice-tooltip: the text colour is the
236
+ fill and the label uses --nice-text-inverse, so the pair flips together. */
237
+ background: var(--nice-text-primary, #0f172a);
238
+ color: var(--nice-text-inverse, #ffffff);
239
+ padding: var(--nice-space-1-5, 6px) var(--nice-space-2-5, 10px);
240
+ border-radius: var(--nice-radius-sm, 4px);
241
+ font-size: 12px;
242
+ pointer-events: none;
243
+ z-index: 10;
244
+ white-space: nowrap;
245
+ }
246
+
247
+ .nice-map-legend {
248
+ position: absolute;
249
+ right: 16px;
250
+ bottom: 16px;
251
+ background: var(--nice-bg-elevated, #ffffff);
252
+ padding: var(--nice-space-3, 12px);
253
+ border-radius: var(--nice-radius-md, 6px);
254
+ box-shadow: 0 2px 8px var(--nice-overlay-10, color-mix(in srgb, var(--nice-text-primary, #000) 10%, transparent));
255
+ }
256
+
257
+ .nice-map-legend-title {
258
+ display: block;
259
+ font-size: 11px;
260
+ color: var(--nice-text-secondary, #475569);
261
+ margin-bottom: var(--nice-space-1-5, 6px);
262
+ }
263
+
264
+ .nice-map-legend-scale {
265
+ display: flex;
266
+ height: 12px;
267
+ border-radius: var(--nice-radius-sm, 2px);
268
+ overflow: hidden;
269
+ }
270
+
271
+ .nice-map-legend-item {
272
+ flex: 1;
273
+ min-width: 24px;
274
+ }
275
+
276
+ .nice-map-legend-labels {
277
+ display: flex;
278
+ justify-content: space-between;
279
+ font-size: 10px;
280
+ color: var(--nice-text-secondary, #475569);
281
+ margin-top: var(--nice-space-1, 4px);
282
+ }
283
+ `})]})},ut=Object.assign(u.forwardRef((t,n)=>{const{t:r}=pe.useNiceTranslation(),{initialData:a,data:c,maxPoints:f=60,updateInterval:s=1e3,fetchData:h,width:v=600,height:b=200,chartType:_="line",color:S="var(--nice-color-primary, #3b82f6)",showGrid:O=!0,showTimeAxis:I=!0,showCurrentValue:B=!0,title:g,valueFormatter:M=W=>W.toFixed(2),timeFormatter:k=W=>new Date(W).toLocaleTimeString(),onDataUpdate:T,paused:E,className:N,style:l,testId:o,"data-testid":y,...j}=t,[d,C]=u.useState(a??c??[]),[F,Z]=u.useState(E||!1),z=u.useRef(void 0);u.useEffect(()=>{E!==void 0&&Z(E)},[E]),u.useEffect(()=>{if(F||!h)return;const W=async()=>{try{const te=await h();C(ne=>{const re=[...ne,te].slice(-f);return T?.(re),re})}catch(te){console.error("Failed to fetch realtime data:",te)}};return z.current=setInterval(W,s),()=>{z.current&&clearInterval(z.current)}},[F,h,s,f,T]);const J=u.useCallback(W=>{C(te=>{const ne=[...te,W].slice(-f);return T?.(ne),ne})},[f,T]),V=u.useCallback(()=>{C([]),T?.([])},[T]),K=u.useCallback(()=>Z(!0),[]),A=u.useCallback(()=>Z(!1),[]);u.useImperativeHandle(n,()=>({addDataPoint:J,clearData:V,pause:K,resume:A,getData:()=>d}),[J,V,K,A,d]);const i={top:20,right:60,bottom:I?40:20,left:50},m=v-i.left-i.right,x=b-i.top-i.bottom,U=d.map(W=>W.value),$=U.length?Math.min(...U):0,w=U.length?Math.max(...U):100,X=(w-$||1)*.1,oe=$-X,ue=w+X-oe,P=W=>{const te=h?f-1:Math.max(1,d.length-1);return i.left+W/te*m},G=W=>i.top+x-(W-oe)/ue*x,p=d.map((W,te)=>`${P(te)},${G(W.value)}`).join(" "),D=d.length>0?`M ${P(0)},${i.top+x} L ${p} L ${P(d.length-1)},${i.top+x} Z`:"",H=d.length>0?d[d.length-1].value:null;return e.jsxs("div",{className:`nice-realtime-chart ${N||""}`,style:{width:v,...l},"data-testid":y??o,...j,children:[e.jsxs("div",{className:"nice-realtime-header",children:[e.jsx("span",{className:"nice-realtime-title",children:g}),e.jsxs("div",{className:"nice-realtime-controls",children:[e.jsxs("span",{className:`nice-realtime-status ${F?"paused":"live"}`,children:[e.jsx("span",{className:"nice-realtime-status-dot"}),e.jsx("span",{children:F?r("charts.paused","Paused"):r("charts.live","Live")})]}),e.jsx("button",{className:`nice-realtime-btn ${F?"paused":""}`,onClick:()=>Z(!F),"aria-label":F?r("charts.resume","Resume"):r("charts.pause","Pause"),children:e.jsx(pe.NiceIcon,{name:F?"play":"pause",size:14})}),B&&H!==null&&e.jsx("span",{className:"nice-realtime-value",children:M(H)})]})]}),e.jsxs("svg",{width:v,height:b,className:"nice-realtime-svg",children:[O&&e.jsx("g",{className:"nice-realtime-grid",children:[0,.25,.5,.75,1].map((W,te)=>{const ne=i.top+x*(1-W),re=oe+ue*W;return e.jsxs("g",{children:[e.jsx("line",{x1:i.left,y1:ne,x2:v-i.right,y2:ne,stroke:"var(--nice-border-color, #e5e7eb)",strokeDasharray:W===0?void 0:"3"}),e.jsx("text",{x:i.left-8,y:ne,textAnchor:"end",dominantBaseline:"middle",fontSize:"10",fill:"var(--nice-text-secondary, #6b7280)",children:Math.round(re).toLocaleString()})]},te)})}),_==="area"&&d.length>0&&e.jsx("path",{d:D,fill:S,fillOpacity:.2}),d.length>1&&e.jsx("polyline",{points:p,fill:"none",stroke:S,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),d.length>0&&e.jsx("circle",{cx:P(d.length-1),cy:G(d[d.length-1].value),r:3,fill:S,className:"nice-realtime-point"}),I&&d.length>0&&e.jsx("g",{className:"nice-realtime-time-axis",children:Array.from(new Set([0,Math.floor(d.length/2),d.length-1].filter(W=>d[W]))).map(W=>e.jsx("text",{x:P(W),y:b-8,textAnchor:"middle",fontSize:"10",fill:"var(--nice-text-secondary, #6b7280)",children:k(d[W].timestamp)},`tx-${W}`))})]}),e.jsx("style",{children:`
284
+ .nice-realtime-chart {
285
+ font-family: inherit;
286
+ color: var(--nice-text-primary, #111827);
287
+ background: var(--nice-bg-elevated, #ffffff);
288
+ border-radius: 8px;
289
+ position: relative;
290
+ }
291
+
292
+ .nice-realtime-header {
293
+ display: flex;
294
+ justify-content: space-between;
295
+ align-items: center;
296
+ padding: 12px 16px;
297
+ border-bottom: 1px solid var(--nice-border-color, #e5e7eb);
298
+ }
299
+
300
+ .nice-realtime-title {
301
+ font-size: 14px;
302
+ font-weight: 600;
303
+ color: var(--nice-text-primary, #111827);
304
+ }
305
+
306
+ .nice-realtime-controls {
307
+ display: flex;
308
+ align-items: center;
309
+ gap: 12px;
310
+ }
311
+
312
+ .nice-realtime-btn {
313
+ background: none;
314
+ border: none;
315
+ cursor: pointer;
316
+ font-size: 16px;
317
+ padding: 4px;
318
+ font-family: inherit;
319
+ color: inherit;
320
+ }
321
+
322
+ .nice-realtime-value {
323
+ font-size: 18px;
324
+ font-weight: 600;
325
+ color: ${S};
326
+ font-variant-numeric: tabular-nums;
327
+ }
328
+
329
+ /* Static current-value dot — no pulsing animation (was distracting) */
330
+
331
+ .nice-realtime-status {
332
+ display: inline-flex;
333
+ align-items: center;
334
+ gap: 6px;
335
+ font-size: 11px;
336
+ font-family: inherit;
337
+ color: var(--nice-text-secondary, #6b7280);
338
+ background: var(--nice-bg-secondary, #f3f4f6);
339
+ padding: 2px 10px;
340
+ border-radius: 999px;
341
+ }
342
+
343
+ .nice-realtime-status-dot {
344
+ width: 8px;
345
+ height: 8px;
346
+ border-radius: 50%;
347
+ background: var(--nice-color-success, #22c55e);
348
+ }
349
+
350
+ .nice-realtime-status.paused .nice-realtime-status-dot {
351
+ background: var(--nice-color-warning, #f59e0b);
352
+ }
353
+
354
+ .nice-realtime-status.live .nice-realtime-status-dot {
355
+ animation: live-pulse 2s ease-in-out infinite;
356
+ }
357
+
358
+ @keyframes live-pulse {
359
+ 0%, 100% { opacity: 1; }
360
+ 50% { opacity: 0.4; }
361
+ }
362
+ `})]})}),{displayName:"NiceRealtimeChart"}),ft=({data:t,width:n=600,height:r=400,showLabels:a=!0,showValues:c=!0,onNodeClick:f,drilldownEnabled:s=!0,colors:h=Qt,tilePadding:v=2,className:b,style:_,testId:S,"data-testid":O,...I})=>{const{t:B}=pe.useNiceTranslation(),g=u.useMemo(()=>Array.isArray(t)?{id:"root",name:"Root",value:t.reduce((z,J)=>z+(J.value||0),0),children:t.map((z,J)=>({id:`${J}`,name:z.label??z.name??`Item ${J+1}`,value:z.value,color:z.color}))}:t,[t]),[M,k]=u.useState([g.id]);u.useEffect(()=>k([g.id]),[g]);const T=u.useMemo(()=>{const z=[g];for(const J of M.slice(1)){const V=z[z.length-1].children?.find(K=>K.id===J);if(!V)break;z.push(V)}return z},[g,M]),E=T[T.length-1],N=T.map(z=>z.name),[l,o]=u.useState(null),y=u.useRef(null),j=u.useMemo(()=>{const J=E.children||[];if(J.length===0)return[];const V=J.reduce((w,Y)=>w+Y.value,0),K=J.map(w=>({node:w,area:w.value/V*n*r}));K.sort((w,Y)=>Y.area-w.area);const A=[];let i=0,m=0,x=n,U=r,$=0;for(;$<K.length;){const w=x<U;let Y=0,X=[];const oe=w?U:x;for(let P=$;P<K.length;P++){const G=[...X,K[P]],p=G.reduce((H,W)=>H+W.area,0),D=d(G,p,oe);if(X.length===0)X=G,Y=p;else{const H=d(X,Y,oe);if(D<=H)X=G,Y=p;else break}}const ie=Y/oe;let ue=0;X.forEach(P=>{const G=P.area/ie;A.push({node:P.node,x:w?i:i+ue,y:w?m+ue:m,w:w?ie:G,h:w?G:ie,color:P.node.color||h[J.indexOf(P.node)%h.length]}),ue+=G}),w?(i+=ie,x-=ie):(m+=ie,U-=ie),$+=X.length}return A},[E,n,r,h]);function d(z,J,V){const K=J/V;let A=0;for(const i of z){const m=i.area/K,x=Math.max(K/m,m/K);A=Math.max(A,x)}return A}const C=z=>{f?.(z,[...N,z.name]),s&&z.children&&z.children.length>0&&k(J=>[...J,z.id])},F=()=>{k(z=>z.length>1?z.slice(0,-1):z)},Z=(z,J)=>{const V=y.current?.getBoundingClientRect();V&&o({x:J.clientX-V.left,y:J.clientY-V.top,content:z})};return e.jsxs("div",{className:`nice-treemap-chart ${b||""}`,style:{width:n,..._},"data-testid":O??S,...I,children:[e.jsxs("div",{className:"nice-treemap-nav",children:[N.length>1&&e.jsxs("button",{className:"nice-treemap-back",onClick:F,children:[e.jsx(pe.NiceIcon,{name:"arrow-left",size:14})," ",B("charts.back","Back")]}),e.jsx("div",{className:"nice-treemap-breadcrumbs",children:N.map((z,J)=>e.jsxs(u.Fragment,{children:[J>0&&e.jsx("span",{className:"nice-treemap-sep",children:"/"}),e.jsx("span",{className:J===N.length-1?"current":"",children:z})]},J))})]}),e.jsx("svg",{ref:y,width:n,height:r,className:"nice-treemap-svg",children:j.map((z,J)=>{const{node:V,x:K,y:A,w:i,h:m,color:x}=z,U=Math.min(18,Math.max(11,Math.min(i,m)/5)),$=i>40&&m>30;return e.jsxs("g",{onClick:()=>C(V),onMouseEnter:w=>Z(`${V.name}: ${V.value.toLocaleString()}`,w),onMouseLeave:()=>o(null),children:[e.jsx("rect",{x:K+v/2,y:A+v/2,width:Math.max(0,i-v),height:Math.max(0,m-v),fill:x,className:"nice-treemap-tile"}),a&&$&&e.jsx("text",{x:K+i/2,y:A+m/2-(c?U*.5:0),textAnchor:"middle",dominantBaseline:"middle",fontSize:U,className:"nice-piechart__label",style:{pointerEvents:"none",fontSize:U,fontWeight:600},children:V.name.length>i/U+2?V.name.slice(0,Math.floor(i/U))+"...":V.name}),c&&$&&e.jsx("text",{x:K+i/2,y:A+m/2+U*.75,textAnchor:"middle",dominantBaseline:"middle",fontSize:U-2,className:"nice-piechart__label",style:{pointerEvents:"none",fontSize:U-2,fontWeight:500,opacity:.9},children:V.value.toLocaleString()})]},J)})}),l&&e.jsx("div",{className:"nice-treemap-tooltip",style:{left:l.x+10,top:l.y-30},children:l.content}),e.jsx("style",{children:`
363
+ .nice-treemap-chart {
364
+ font-family: system-ui, -apple-system, sans-serif;
365
+ background: var(--nice-bg-primary, #ffffff);
366
+ border-radius: var(--nice-radius-lg, 8px);
367
+ position: relative;
368
+ }
369
+
370
+ .nice-treemap-nav {
371
+ display: flex;
372
+ align-items: center;
373
+ gap: var(--nice-space-3, 12px);
374
+ padding: var(--nice-space-3, 12px) var(--nice-space-4, 16px);
375
+ border-bottom: 1px solid var(--nice-border-color, #e5e7eb);
376
+ }
377
+
378
+ .nice-treemap-back {
379
+ background: var(--nice-bg-secondary, #f8fafc);
380
+ color: var(--nice-text-primary, #0f172a);
381
+ border: none;
382
+ padding: var(--nice-space-1-5, 6px) var(--nice-space-3, 12px);
383
+ border-radius: var(--nice-radius-md, 6px);
384
+ cursor: pointer;
385
+ font-size: 13px;
386
+ }
387
+
388
+ .nice-treemap-back:hover {
389
+ background: var(--nice-border-color, #e5e7eb);
390
+ }
391
+
392
+ .nice-treemap-breadcrumbs {
393
+ display: flex;
394
+ align-items: center;
395
+ gap: var(--nice-space-1, 4px);
396
+ font-size: 13px;
397
+ color: var(--nice-text-secondary, #475569);
398
+ }
399
+
400
+ .nice-treemap-breadcrumbs .current {
401
+ color: var(--nice-text-primary, #0f172a);
402
+ font-weight: 500;
403
+ }
404
+
405
+ .nice-treemap-sep {
406
+ color: var(--nice-text-muted, #94a3b8);
407
+ }
408
+
409
+ .nice-treemap-tile {
410
+ cursor: pointer;
411
+ transition: opacity 0.2s, transform 0.1s;
412
+ }
413
+
414
+ .nice-treemap-tile:hover {
415
+ opacity: 0.85;
416
+ }
417
+
418
+ .nice-treemap-tooltip {
419
+ position: absolute;
420
+ /* audit-allow: token-role — inverted chip like .nice-tooltip: the text colour is the
421
+ fill and the label uses --nice-text-inverse, so the pair flips together. */
422
+ background: var(--nice-text-primary, #0f172a);
423
+ color: var(--nice-text-inverse, #ffffff);
424
+ padding: var(--nice-space-1-5, 6px) var(--nice-space-2-5, 10px);
425
+ border-radius: var(--nice-radius-sm, 4px);
426
+ font-size: 12px;
427
+ pointer-events: none;
428
+ z-index: 10;
429
+ white-space: nowrap;
430
+ }
431
+ `})]})},nn=Object.freeze(Object.defineProperty({__proto__:null,NiceDrillDownChart:dt,NiceMapChart:ht,NiceRealtimeChart:ut,NiceTreeMap:ft},Symbol.toStringTag,{value:"Module"}));function mt(t,n,r={}){const{delimiter:a=",",lineEnding:c=`
432
+ `,quoteChar:f='"',alwaysQuote:s=!1,includeHeaders:h=!0,includeRowNumbers:v=!1,locale:b="en-US",dateTimeFormat:_="yyyy-MM-dd HH:mm:ss"}=r,S=n.filter(g=>g.visible!==!1),O=[],I=g=>{if(s||g.includes(a)||g.includes(f)||g.includes(`
433
+ `)||g.includes("\r")){const k=g.replace(new RegExp(f,"g"),f+f);return`${f}${k}${f}`}return g},B=(g,M,k)=>{if(g==null)return"";if(M.format)return M.format(g,k);switch(M.dataType){case"date":return Ze(g,M.dateFormat??_);case"number":return qe(g,M.numberFormat,b);case"currency":return Ke(g,M.currencyCode??"USD",b);case"boolean":return g?"Yes":"No";default:return String(g)}};if(h){const g=[];v&&g.push(I("#"));for(const M of S)g.push(I(M.header));O.push(g.join(a))}return t.forEach((g,M)=>{const k=[];v&&k.push(String(M+1));for(const T of S){const E=g[T.field],N=B(E,T,g);k.push(I(N))}O.push(k.join(a))}),O.join(c)}function pt(t,n,r={}){const{fileName:a="export",includeTimestamp:c=!1,includeBOM:f=!0,encoding:s="utf-8"}=r,h=mt(t,n,r),v=c?`_${Xe()}`:"",b=`${a}${v}.csv`;let _=h;f&&s==="utf-8"&&(_="\uFEFF"+h);const S=new Blob([_],{type:`text/csv;charset=${s}`});Be(S,b)}function rn(){return{sheets:new Map,activeSheet:""}}function an(t,n){const r={name:n,cells:new Map,columns:[],merges:[]};return t.sheets.set(n,r),t.activeSheet||(t.activeSheet=n),r}function Oe(t,n,r,a){const c=He(n,r);t.cells.set(c,a)}function He(t,n){let r="",a=n;for(;a>=0;)r=String.fromCharCode(65+a%26)+r,a=Math.floor(a/26)-1;return`${r}${t+1}`}function sn(t){const n=new TextEncoder,r=Array.from(t.sheets.entries()),a=r.map(([v,b],_)=>{const S=[];let O=0,I=0;b.cells.forEach((g,M)=>{const k=M.match(/([A-Z]+)(\d+)/);if(k){const T=on(k[1]),E=parseInt(k[2],10);O=Math.max(O,E),I=Math.max(I,T)}});for(let g=1;g<=O;g++){const M=[];for(let k=0;k<=I;k++){const T=He(g-1,k),E=b.cells.get(T);if(E){const N=E.type==="s"?' t="inlineStr"':E.type==="b"?' t="b"':"";let l;E.type==="s"?l=`<is><t>${at(String(E.value))}</t></is>`:E.type==="b"?l=`<v>${E.value?1:0}</v>`:l=`<v>${E.value}</v>`,M.push(`<c r="${T}"${N}>${l}</c>`)}}M.length>0&&S.push(`<row r="${g}">${M.join("")}</row>`)}return`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
434
+ <worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
435
+ <dimension ref="${O>0?`A1:${He(O-1,I)}`:"A1"}"/>
436
+ <sheetData>${S.join("")}</sheetData>
437
+ </worksheet>`}),c=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
438
+ <workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">
439
+ <sheets>${r.map(([v],b)=>`<sheet name="${at(v)}" sheetId="${b+1}" r:id="rId${b+1}"/>`).join("")}</sheets>
440
+ </workbook>`,f=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
441
+ <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
442
+ ${r.map((v,b)=>`<Relationship Id="rId${b+1}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet${b+1}.xml"/>`).join(`
443
+ `)}
444
+ </Relationships>`,s=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
445
+ <Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">
446
+ <Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/>
447
+ <Default Extension="xml" ContentType="application/xml"/>
448
+ <Override PartName="/xl/workbook.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"/>
449
+ ${r.map((v,b)=>`<Override PartName="/xl/worksheets/sheet${b+1}.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"/>`).join(`
450
+ `)}
451
+ </Types>`;return cn([{path:"[Content_Types].xml",content:n.encode(s)},{path:"_rels/.rels",content:n.encode(`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
452
+ <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
453
+ <Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="xl/workbook.xml"/>
454
+ </Relationships>`)},{path:"xl/workbook.xml",content:n.encode(c)},{path:"xl/_rels/workbook.xml.rels",content:n.encode(f)},...a.map((v,b)=>({path:`xl/worksheets/sheet${b+1}.xml`,content:n.encode(v)}))])}function on(t){let n=0;for(let r=0;r<t.length;r++)n=n*26+(t.charCodeAt(r)-64);return n-1}function at(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}function cn(t){const n=[],r=[];let a=0;for(const _ of t){const S=new TextEncoder().encode(_.path),O=new Uint8Array(30+S.length),I=new DataView(O.buffer);I.setUint32(0,67324752,!0),I.setUint16(4,20,!0),I.setUint16(6,0,!0),I.setUint16(8,0,!0),I.setUint16(10,0,!0),I.setUint16(12,0,!0),I.setUint32(14,st(_.content),!0),I.setUint32(18,_.content.length,!0),I.setUint32(22,_.content.length,!0),I.setUint16(26,S.length,!0),I.setUint16(28,0,!0),O.set(S,30),n.push(O),n.push(_.content);const B=new Uint8Array(46+S.length),g=new DataView(B.buffer);g.setUint32(0,33639248,!0),g.setUint16(4,20,!0),g.setUint16(6,20,!0),g.setUint16(8,0,!0),g.setUint16(10,0,!0),g.setUint16(12,0,!0),g.setUint16(14,0,!0),g.setUint32(16,st(_.content),!0),g.setUint32(20,_.content.length,!0),g.setUint32(24,_.content.length,!0),g.setUint16(28,S.length,!0),g.setUint16(30,0,!0),g.setUint16(32,0,!0),g.setUint16(34,0,!0),g.setUint16(36,0,!0),g.setUint32(38,0,!0),g.setUint32(42,a,!0),B.set(S,46),r.push(B),a+=O.length+_.content.length}const c=r.reduce((_,S)=>_+S.length,0),f=new Uint8Array(22),s=new DataView(f.buffer);s.setUint32(0,101010256,!0),s.setUint16(4,0,!0),s.setUint16(6,0,!0),s.setUint16(8,t.length,!0),s.setUint16(10,t.length,!0),s.setUint32(12,c,!0),s.setUint32(16,a,!0),s.setUint16(20,0,!0);const h=a+c+f.length,v=new Uint8Array(h);let b=0;for(const _ of n)v.set(_,b),b+=_.length;for(const _ of r)v.set(_,b),b+=_.length;return v.set(f,b),v.buffer}function st(t){let n=4294967295;const r=ln();for(let a=0;a<t.length;a++)n=n>>>8^r[(n^t[a])&255];return(n^4294967295)>>>0}let Ue=null;function ln(){if(Ue)return Ue;Ue=new Uint32Array(256);for(let t=0;t<256;t++){let n=t;for(let r=0;r<8;r++)n=n&1?3988292384^n>>>1:n>>>1;Ue[t]=n}return Ue}function xt(t,n,r={}){const{sheetName:a="Sheet1",title:c,subtitle:f,includeHeaders:s=!0,includeRowNumbers:h=!1,freezeHeader:v=!0,autoFilter:b=!0,styles:_={},locale:S="en-US",dateTimeFormat:O="yyyy-MM-dd HH:mm:ss"}=r,I=n.filter(N=>N.visible!==!1),B=rn(),g=an(B,a);let M=0;const k=h?1:0;c&&(Oe(g,M,0,{value:c,type:"s",style:{font:{bold:!0,size:16}}}),M++),f&&(Oe(g,M,0,{value:f,type:"s",style:{font:{italic:!0,size:12}}}),M++);const T=M;s&&(h&&Oe(g,M,0,{value:"#",type:"s",style:{font:{bold:_.headerFontWeight==="bold",color:_.headerColor},fill:{color:_.headerBackground},alignment:{horizontal:"center"}}}),I.forEach((N,l)=>{Oe(g,M,l+k,{value:N.header,type:"s",style:{font:{bold:_.headerFontWeight==="bold",color:_.headerColor},fill:{color:_.headerBackground},alignment:{horizontal:N.align??"left"}}})}),M++),t.forEach((N,l)=>{h&&Oe(g,M,0,{value:l+1,type:"n"}),I.forEach((o,y)=>{const j=N[o.field];let d;if(j==null)d={value:"",type:"s"};else if(o.format)d={value:o.format(j,N),type:"s"};else switch(o.dataType){case"number":case"currency":d={value:Number(j),type:"n",numberFormat:o.numberFormat};break;case"date":{d={value:dn(j),type:"n",numberFormat:o.dateFormat??"yyyy-mm-dd"};break}case"boolean":d={value:j,type:"b"};break;default:d={value:String(j),type:"s"}}_.alternateRows&&l%2===1&&(d.style={...d.style,fill:{color:_.alternateBackground??"var(--nice-text-primary, #f5f5f5)"}}),Oe(g,M,y+k,d)}),M++});const E=I.map(N=>N.width??100);if(h&&E.unshift(40),g.columns=E.map(N=>({width:N/7})),v&&s&&(g.freezePane={row:T+1,col:0}),b&&s&&t.length>0){const N=He(T,0),l=He(M-1,I.length-1+k);g.autoFilter={start:N,end:l}}return sn(B)}function gt(t,n,r={}){const{fileName:a="export",includeTimestamp:c=!1}=r,f=xt(t,n,r),s=c?`_${Xe()}`:"",h=`${a}${s}.xlsx`,v=new Blob([f],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"});Be(v,h)}function yt(t,n,r={}){const{title:a,subtitle:c,orientation:f="portrait",pageSize:s="A4",margins:h={top:20,right:20,bottom:20,left:20},header:v,footer:b,logo:_,logoWidth:S=100,logoHeight:O,watermark:I,includeHeaders:B=!0,includeRowNumbers:g=!1,styles:M={},locale:k="en-US",dateTimeFormat:T="yyyy-MM-dd HH:mm:ss"}=r,E=n.filter(y=>y.visible!==!1),N=(y,j,d)=>{if(y==null)return"";if(j.format)return j.format(y,d);switch(j.dataType){case"date":return Ze(y,j.dateFormat??T);case"number":return qe(y,j.numberFormat,k);case"currency":return Ke(y,j.currencyCode??"USD",k);case"boolean":return y?"✓":"✗";default:return String(y)}};let l=`
455
+ <!DOCTYPE html>
456
+ <html>
457
+ <head>
458
+ <meta charset="utf-8">
459
+ <title>${Ee(a??"Export")}</title>
460
+ <style>
461
+ @page {
462
+ size: ${s} ${f};
463
+ margin: ${h.top}mm ${h.right}mm ${h.bottom}mm ${h.left}mm;
464
+ }
465
+
466
+ body {
467
+ font-family: ${M.fontFamily??"Arial, sans-serif"};
468
+ font-size: ${M.fontSize??10}pt;
469
+ margin: 0;
470
+ padding: 0;
471
+ }
472
+
473
+ .header {
474
+ text-align: center;
475
+ margin-bottom: var(--nice-space-5, 20px);
476
+ }
477
+
478
+ .title {
479
+ font-size: 18pt;
480
+ font-weight: bold;
481
+ margin: 0 0 var(--nice-space-1-25, 5px) 0;
482
+ }
483
+
484
+ .subtitle {
485
+ font-size: 12pt;
486
+ color: var(--nice-text-secondary, #666);
487
+ margin: 0;
488
+ }
489
+
490
+ .logo {
491
+ max-width: ${S}px;
492
+ ${O?`max-height: ${O}px;`:""}
493
+ margin-bottom: var(--nice-space-2-5, 10px);
494
+ }
495
+
496
+ table {
497
+ width: 100%;
498
+ border-collapse: collapse;
499
+ page-break-inside: auto;
500
+ }
501
+
502
+ tr {
503
+ page-break-inside: avoid;
504
+ page-break-after: auto;
505
+ }
506
+
507
+ th, td {
508
+ border: 1px solid ${M.borderColor??"var(--nice-border, #ddd)"};
509
+ padding: var(--nice-space-1-5, 6px) var(--nice-space-2, 8px);
510
+ text-align: left;
511
+ }
512
+
513
+ th {
514
+ background-color: ${M.headerBackground??"var(--nice-bg-secondary, #f5f5f5)"};
515
+ color: ${M.headerColor??"var(--nice-text, #333)"};
516
+ font-weight: ${M.headerFontWeight??"bold"};
517
+ }
518
+
519
+ tr:nth-child(even) {
520
+ background-color: ${M.alternateRows!==!1?M.alternateBackground??"var(--nice-bg-secondary, #fafafa)":"transparent"};
521
+ }
522
+
523
+ .text-left { text-align: left; }
524
+ .text-center { text-align: center; }
525
+ .text-right { text-align: right; }
526
+
527
+ .watermark {
528
+ position: fixed;
529
+ top: 50%;
530
+ left: 50%;
531
+ transform: translate(-50%, -50%) rotate(-45deg);
532
+ font-size: 72pt;
533
+ color: var(--nice-overlay-10, rgba(0, 0, 0, 0.1));
534
+ pointer-events: none;
535
+ z-index: -1;
536
+ }
537
+
538
+ .page-footer {
539
+ position: fixed;
540
+ bottom: 0;
541
+ width: 100%;
542
+ text-align: center;
543
+ font-size: 9pt;
544
+ color: var(--nice-text-secondary, #666);
545
+ }
546
+
547
+ @media print {
548
+ .no-print { display: none; }
549
+ }
550
+ </style>
551
+ </head>
552
+ <body>
553
+ `;if(I&&(l+=`<div class="watermark">${Ee(I)}</div>`),l+='<div class="header">',_&&(l+=`<img src="${_}" class="logo" alt="Logo">`),a&&(l+=`<h1 class="title">${Ee(a)}</h1>`),c&&(l+=`<p class="subtitle">${Ee(c)}</p>`),l+="</div>",l+="<table>",B){l+="<thead><tr>",g&&(l+='<th class="text-center">#</th>');for(const y of E){const j=y.align??"left";l+=`<th class="text-${j}" style="width: ${y.width??"auto"}px">${Ee(y.header)}</th>`}l+="</tr></thead>"}l+="<tbody>",t.forEach((y,j)=>{l+="<tr>",g&&(l+=`<td class="text-center">${j+1}</td>`);for(const d of E){const C=N(y[d.field],d,y),F=d.align??"left";l+=`<td class="text-${F}">${Ee(C)}</td>`}l+="</tr>"}),l+="</tbody>",l+="</table>",l+="</body></html>";const o=window.open("","_blank");o&&(o.document.write(l),o.document.close(),o.onload=()=>{o.print()})}function vt(t,n,r={}){yt(t,n,r)}function bt(t,n={}){const{pretty:r=!0,indent:a=2,fields:c,transform:f}=n;let s=t;return f&&(s=t.map((h,v)=>f(h,v))),c?.length&&(s=s.map(h=>{const v={};for(const b of c)b in h&&(v[b]=h[b]);return v})),JSON.stringify(s,null,r?a:void 0)}function _t(t,n={}){const{fileName:r="export",includeTimestamp:a=!1}=n,c=bt(t,n),f=a?`_${Xe()}`:"",s=`${r}${f}.json`,h=new Blob([c],{type:"application/json;charset=utf-8"});Be(h,s)}function wt(t,n,r={}){const{title:a,includeHeaders:c=!0,includeRowNumbers:f=!1,inlineStyles:s=!0,tableClass:h="nice-export-table",standalone:v=!0,styles:b={},locale:_="en-US",dateTimeFormat:S="yyyy-MM-dd HH:mm:ss"}=r,O=n.filter(g=>g.visible!==!1),I=(g,M,k)=>{if(g==null)return"";if(M.format)return M.format(g,k);switch(M.dataType){case"date":return Ze(g,M.dateFormat??S);case"number":return qe(g,M.numberFormat,_);case"currency":return Ke(g,M.currencyCode??"USD",_);case"boolean":return g?"Yes":"No";default:return String(g)}};let B="";if(v&&(B+=`<!DOCTYPE html>
554
+ <html>
555
+ <head>
556
+ <meta charset="utf-8">
557
+ <title>${Ee(a??"Export")}</title>
558
+ <style>
559
+ .${h} {
560
+ border-collapse: collapse;
561
+ width: 100%;
562
+ font-family: ${b.fontFamily??"Arial, sans-serif"};
563
+ font-size: ${b.fontSize??12}px;
564
+ }
565
+ .${h} th, .${h} td {
566
+ border: 1px solid ${b.borderColor??"var(--nice-border, #ddd)"};
567
+ padding: var(--nice-space-2, 8px);
568
+ text-align: left;
569
+ }
570
+ .${h} th {
571
+ background-color: ${b.headerBackground??"var(--nice-bg-secondary, #f5f5f5)"};
572
+ color: ${b.headerColor??"var(--nice-text, #333)"};
573
+ font-weight: ${b.headerFontWeight??"bold"};
574
+ }
575
+ .${h} tr:nth-child(even) {
576
+ background-color: ${b.alternateRows!==!1?b.alternateBackground??"var(--nice-bg-secondary, #fafafa)":"transparent"};
577
+ }
578
+ </style>
579
+ </head>
580
+ <body>
581
+ `,a&&(B+=`<h1>${Ee(a)}</h1>`)),B+=`<table class="${h}"${!v&&s?' style="border-collapse:collapse;width:100%"':""}>`,c){B+="<thead><tr>",f&&(B+="<th>#</th>");for(const g of O)B+=`<th>${Ee(g.header)}</th>`;B+="</tr></thead>"}return B+="<tbody>",t.forEach((g,M)=>{B+="<tr>",f&&(B+=`<td>${M+1}</td>`);for(const k of O){const T=I(g[k.field],k,g);B+=`<td>${Ee(T)}</td>`}B+="</tr>"}),B+="</tbody></table>",v&&(B+="</body></html>"),B}function jt(t,n,r={}){const{fileName:a="export",includeTimestamp:c=!1}=r,f=wt(t,n,{...r,standalone:!0}),s=c?`_${Xe()}`:"",h=`${a}${s}.html`,v=new Blob([f],{type:"text/html;charset=utf-8"});Be(v,h)}function Be(t,n){const r=URL.createObjectURL(t),a=document.createElement("a");a.href=r,a.download=n,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(r)}function Xe(){return new Date().toISOString().slice(0,19).replace(/[T:]/g,"-")}function Ze(t,n,r){const a=t instanceof Date?t:new Date(t);if(isNaN(a.getTime()))return String(t);const c=f=>String(f).padStart(2,"0");return n.replace("yyyy",String(a.getFullYear())).replace("MM",c(a.getMonth()+1)).replace("dd",c(a.getDate())).replace("HH",c(a.getHours())).replace("mm",c(a.getMinutes())).replace("ss",c(a.getSeconds()))}function qe(t,n,r){if(n){const a=n.match(/0+$/)?.[0]?.length??0;return t.toLocaleString(r,{minimumFractionDigits:a,maximumFractionDigits:a})}return t.toLocaleString(r)}function Ke(t,n,r){return t.toLocaleString(r,{style:"currency",currency:n})}function dn(t){const n=t instanceof Date?t:new Date(t),r=new Date(1899,11,30),a=1440*60*1e3;return(n.getTime()-r.getTime())/a}function Ee(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function hn(t){const{data:n,columns:r,format:a,options:c={}}=t;switch(a){case"csv":pt(n,r,c);break;case"xlsx":gt(n,r,c);break;case"pdf":vt(n,r,c);break;case"json":_t(n,c);break;case"html":jt(n,r,c);break;default:throw new Error(`Unsupported export format: ${a}`)}}function un(t,n={}){const{maxSample:r=100,exclude:a=[]}=n;if(t.length===0)return[];const c=t.slice(0,r),f=t[0],s=[];for(const h of Object.keys(f)){if(a.includes(h))continue;let v="string";for(const b of c){const _=b[h];if(_!=null){if(typeof _=="number"){v="number";break}if(typeof _=="boolean"){v="boolean";break}if(_ instanceof Date){v="date";break}if(typeof _=="string"&&/^\d{4}-\d{2}-\d{2}/.test(_)&&!isNaN(Date.parse(_))){v="date";break}}}s.push({field:h,header:fn(h),dataType:v})}return s}function fn(t){return t.replace(/([A-Z])/g," $1").replace(/_/g," ").replace(/^\s+/,"").split(" ").map(n=>n.charAt(0).toUpperCase()+n.slice(1).toLowerCase()).join(" ")}function $t(t,n={}){const r=n.nodeWidth??160,a=n.nodeHeight??56,c=n.siblingGap??24,f=n.levelGap??48,s=n.direction==="LR",h=N=>s?N.height??a:N.width??r,v=N=>s?N.width??r:N.height??a,b=new Set,_=new Map,S=new Map,O=[],I=(N,l)=>{b.add(N.id),O[l]=Math.max(O[l]??0,v(N));const o=(N.children??[]).filter(d=>!b.has(d.id));o.forEach(d=>b.add(d.id)),_.set(N.id,o);const y=o.reduce((d,C,F)=>d+I(C,l+1)+(F>0?c:0),0),j=Math.max(h(N),y);return S.set(N.id,j),j},B=[],g=[];for(const N of t)b.has(N.id)||(B.push(N),g.push(I(N,0)));const M=[];O.forEach((N,l)=>{M[l]=l===0?0:M[l-1]+O[l-1]+f});const k=new Map,T=(N,l,o)=>{const y=S.get(N.id)??h(N),j=_.get(N.id)??[],d=j.reduce((V,K,A)=>V+(S.get(K.id)??h(K))+(A>0?c:0),0);let C=l+(y-d)/2;const F=[];for(const V of j)F.push(T(V,C,o+1)),C+=(S.get(V.id)??h(V))+c;const Z=F.length?(F[0]+F[F.length-1])/2:l+y/2,z=Math.min(Math.max(Z-h(N)/2,l),l+y-h(N)),J=M[o];return k.set(N.id,{x:s?J:z,y:s?z:J,width:N.width??r,height:N.height??a,depth:o}),z+h(N)/2};let E=0;return B.forEach((N,l)=>{T(N,E,0),E+=g[l]+c}),k}const ot=t=>t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;");function Je(t,n={}){const r=n.fontSize??13,a=n.nodeHeight??40,c=n.minNodeWidth??120,f=n.direction==="left-right",s=16,h=T=>({id:T.key,width:Math.max(c,Math.round(T.label.length*r*.6)+32),height:a,children:(T.children??[]).map(h)}),v=$t([h(t)],{direction:f?"LR":"TB",siblingGap:16,levelGap:32});let b=0,_=0;for(const T of v.values())b=Math.max(b,T.x+T.width),_=Math.max(_,T.y+T.height);const S=n.lineColor??"#9ca3af",O=[],I=T=>{const E=v.get(T.key);if(E)for(const N of T.children??[]){const l=v.get(N.key);if(l){if(f){const o=E.x+E.width+s,y=E.y+E.height/2+s,j=l.x+s,d=l.y+l.height/2+s,C=(o+j)/2;O.push(`<path d="M${o} ${y}H${C}V${d}H${j}" fill="none" stroke="${S}" stroke-width="1.5"/>`)}else{const o=E.x+E.width/2+s,y=E.y+E.height+s,j=l.x+l.width/2+s,d=l.y+s,C=(y+d)/2;O.push(`<path d="M${o} ${y}V${C}H${j}V${d}" fill="none" stroke="${S}" stroke-width="1.5"/>`)}I(N)}}};I(t);const B=[],g=T=>{const E=v.get(T.key);E&&B.push(`<g><rect x="${E.x+s}" y="${E.y+s}" width="${E.width}" height="${E.height}" rx="6" fill="${n.boxFill??"#ffffff"}" stroke="${n.boxStroke??"#d1d5db"}"/><text x="${E.x+s+E.width/2}" y="${E.y+s+E.height/2}" text-anchor="middle" dominant-baseline="central" font-size="${r}" fill="${n.textColor??"#111827"}">${ot(T.label)}</text></g>`),(T.children??[]).forEach(g)};g(t);const M=b+s*2,k=_+s*2;return`<svg xmlns="http://www.w3.org/2000/svg" width="${M}" height="${k}" viewBox="0 0 ${M} ${k}" font-family="${ot(n.fontFamily??"system-ui, sans-serif")}"><rect width="100%" height="100%" fill="${n.background??"#ffffff"}"/>`+O.join("")+B.join("")+"</svg>"}async function Mt(t,n={}){const r=Je(t,n),a=n.scale??2,c=/width="([\d.]+)" height="([\d.]+)"/.exec(r),f=Number(c?.[1]??0),s=Number(c?.[2]??0),h=URL.createObjectURL(new Blob([r],{type:"image/svg+xml"}));try{const v=new Image;await new Promise((S,O)=>{v.onload=()=>S(),v.onerror=()=>O(new Error("The chart image could not be drawn.")),v.src=h});const b=document.createElement("canvas");b.width=Math.ceil(f*a),b.height=Math.ceil(s*a);const _=b.getContext("2d");if(!_)throw new Error("No 2D canvas.");return _.scale(a,a),_.drawImage(v,0,0),await new Promise((S,O)=>b.toBlob(I=>I?S(I):O(new Error("No PNG.")),"image/png"))}finally{URL.revokeObjectURL(h)}}function kt(t,n,r=0,a=new Set){return t.children?.length&&(r>=n&&a.add(t.key),t.children.forEach(c=>kt(c,n,r+1,a))),a}function mn(t,n){const r=new Set,a=new Set,c=(f,s)=>{String(f.label??"").toLowerCase().includes(n)&&(r.add(f.key),s.forEach(h=>a.add(h))),f.children?.forEach(h=>c(h,[...s,f.key]))};return n&&c(t,[]),{matches:r,ancestors:a}}const pn=Object.assign(u.forwardRef(({data:t,renderNode:n,selectable:r,selectedKey:a,onSelect:c,direction:f="top-down",collapsible:s=!0,zoomable:h=!1,exportable:v=!1,onExport:b,pannable:_=!0,wheelZoom:S="ctrl",searchable:O=!1,collapsedDepth:I,highlightKeys:B,onNodeClick:g,className:M,style:k,id:T,testId:E,"data-testid":N},l)=>{const{t:o}=pe.useNiceTranslation(),y=pe.useControlId(T),[j,d]=u.useState(()=>I!=null?kt(t,I):new Set),[C,F]=u.useState(1),[Z,z]=u.useState({x:0,y:0}),[J,V]=u.useState(""),K=u.useRef(null),A=u.useMemo(()=>mn(t,J.trim().toLowerCase()),[t,J]),i=u.useMemo(()=>new Set(B??[]),[B]),m=u.useRef(null),x=u.useRef(null),U=u.useRef(null);pe.useRovingFocus(U,{orientation:"horizontal"});const $=p=>F(D=>Math.min(2,Math.max(.2,Math.round(D*p*100)/100))),w=()=>{const p=m.current,D=x.current;if(!p||!D)return;const H=D.scrollWidth/C,W=D.scrollHeight/C;H>0&&W>0&&F(Math.max(.2,Math.min(1,p.clientWidth/H,p.clientHeight/W)))},Y=v===!0?["svg","png"]:v===!1?[]:v,X=async p=>{const D={direction:f};if(p==="svg"){const W=Je(t,D);b?b("svg",W):Be(new Blob([W],{type:"image/svg+xml"}),"organization-chart.svg");return}const H=await Mt(t,D);b?b("png",H):Be(H,"organization-chart.png")},oe=()=>x.current?.querySelector(":scope > .nice-org-chart__item > .nice-org-chart__node")??null;u.useLayoutEffect(()=>{const p=K.current,D=oe();if(K.current=null,!p||!D)return;const H=D.getBoundingClientRect(),W=(p.left-H.left)/C,te=(p.top-H.top)/C;(W||te)&&z(ne=>({x:ne.x+W,y:ne.y+te}))},[j,C]),u.useEffect(()=>{if(A.ancestors.size===0)return;d(D=>{const H=new Set(D);return A.ancestors.forEach(W=>H.delete(W)),H.size===D.size?D:H});const p=window.requestAnimationFrame(()=>{const D=m.current,H=D?.querySelector(".nice-org-chart__node--match");if(!D||!H)return;const W=D.getBoundingClientRect(),te=H.getBoundingClientRect();z(ne=>({x:ne.x+(W.left+W.width/2-(te.left+te.width/2))/C,y:ne.y+(W.top+W.height/2-(te.top+te.height/2))/C}))});return()=>window.cancelAnimationFrame(p)},[A]),u.useEffect(()=>{const p=m.current;if(!p||!h||!S)return;const D=H=>{S==="ctrl"&&!(H.ctrlKey||H.metaKey)||(H.preventDefault(),$(H.deltaY>0?1/1.1:1.1))};return p.addEventListener("wheel",D,{passive:!1}),()=>p.removeEventListener("wheel",D)},[h,S]);const ie=p=>{if(!_||p.button!==0||p.target.closest(".nice-org-chart__node, button, input"))return;const D={x:p.clientX,y:p.clientY,pan:Z},H=p.currentTarget;H.setPointerCapture(p.pointerId),H.classList.add("nice-org-chart__view--panning");const W=ne=>z({x:D.pan.x+(ne.clientX-D.x)/C,y:D.pan.y+(ne.clientY-D.y)/C}),te=()=>{H.classList.remove("nice-org-chart__view--panning"),H.removeEventListener("pointermove",W),H.removeEventListener("pointerup",te),H.removeEventListener("pointercancel",te)};H.addEventListener("pointermove",W),H.addEventListener("pointerup",te),H.addEventListener("pointercancel",te)},ue=u.useCallback(p=>{K.current=oe()?.getBoundingClientRect()??null,d(D=>{const H=new Set(D);return H.has(p)?H.delete(p):H.add(p),H})},[]),P=u.useCallback(p=>{g?.(p),r&&c?.(p.key)},[r,c,g]),G=u.useCallback(p=>{const D=j.has(p.key),H=p.children&&p.children.length>0;return e.jsxs("li",{className:"nice-org-chart__item",children:[e.jsxs("div",{tabIndex:r?0:void 0,onKeyDown:r?pe.clickOnActivationKey:void 0,className:`nice-org-chart__node${a===p.key?" nice-org-chart__node--selected":""}${A.matches.has(p.key)?" nice-org-chart__node--match":""}${i.has(p.key)?" nice-org-chart__node--highlight":""}`,onClick:()=>P(p),role:r?"button":void 0,children:[n?n(p):e.jsx("span",{children:p.label}),s&&H&&e.jsx("button",{type:"button",className:"nice-org-chart__toggle",onClick:W=>{W.stopPropagation(),ue(p.key)},"aria-label":D?o("organizationChart.expand","Expand"):o("organizationChart.collapse","Collapse"),children:e.jsx(pe.NiceIcon,{name:D?"plus":"minus",size:14})})]}),H&&!D&&e.jsx("ul",{className:"nice-org-chart__children",children:p.children.map(W=>G(W))})]},p.key)},[j,a,A,i,n,r,s,P,ue,o]);return e.jsxs("div",{ref:l,id:y,className:`nice-org-chart nice-org-chart--${f}${h||Y.length||O?" nice-org-chart--tools":""} ${M||""}`,style:k,"data-testid":N??E,children:[(h||Y.length>0||O)&&e.jsxs("div",{ref:U,className:"nice-org-chart__tools",role:"toolbar","aria-label":o("organizationChart.tools","Chart tools"),children:[h&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"nice-org-chart__tool",onClick:()=>$(1/1.2),"aria-label":o("organizationChart.zoomOut","Zoom out"),title:o("organizationChart.zoomOut","Zoom out"),children:e.jsx(pe.NiceIcon,{name:"zoom-out",size:14})}),e.jsxs("span",{className:"nice-org-chart__zoom","aria-live":"polite",children:[Math.round(C*100),"%"]}),e.jsx("button",{type:"button",className:"nice-org-chart__tool",onClick:()=>$(1.2),"aria-label":o("organizationChart.zoomIn","Zoom in"),title:o("organizationChart.zoomIn","Zoom in"),children:e.jsx(pe.NiceIcon,{name:"zoom-in",size:14})}),e.jsx("button",{type:"button",className:"nice-org-chart__tool",onClick:w,"aria-label":o("organizationChart.fit","Fit to view"),title:o("organizationChart.fit","Fit to view"),children:e.jsx(pe.NiceIcon,{name:"expand",size:14})})]}),O&&e.jsx("input",{type:"search",className:"nice-org-chart__search",value:J,onChange:p=>V(p.target.value),placeholder:o("organizationChart.search","Search people…"),"aria-label":o("organizationChart.search","Search people…")}),O&&J.trim()&&e.jsx("span",{className:"nice-org-chart__zoom","aria-live":"polite",children:o("organizationChart.found","{count} found").replace("{count}",String(A.matches.size))}),Y.map(p=>e.jsxs("button",{type:"button",className:"nice-org-chart__tool",onClick:()=>void X(p),title:o("organizationChart.export","Export as {format}").replace("{format}",p.toUpperCase()),children:[e.jsx(pe.NiceIcon,{name:"download",size:14})," ",p.toUpperCase()]},p))]}),e.jsx("div",{ref:m,className:`nice-org-chart__view${_?" nice-org-chart__view--pannable":""}`,onPointerDown:ie,children:e.jsx("ul",{ref:x,className:"nice-org-chart__root",style:{...C!==1?{zoom:C}:{},...Z.x||Z.y?{transform:`translate(${Z.x}px, ${Z.y}px)`}:{}},children:G(t)})})]})}),{displayName:"NiceOrganizationChart"}),xn=[],gn=Object.assign(u.forwardRef(({data:t=xn,type:n="candlestick",showVolume:r=!0,width:a=800,height:c=400,bullColor:f="var(--nice-color-success, #22c55e)",bearColor:s="var(--nice-color-error, #ef4444)",showCrosshair:h=!0,responsive:v=!0,formatPrice:b=M=>M.toFixed(2),className:_,style:S,id:O,testId:I,"data-testid":B},g)=>{const M=pe.useControlId(O),k=u.useRef(null),[T,E]=u.useState(null);u.useEffect(()=>{const $=k.current;if(!v||!$||typeof ResizeObserver>"u")return;const w=new ResizeObserver(([Y])=>{const X=Math.round(Y.contentRect.width);X>0&&E(X)});return w.observe($),()=>w.disconnect()},[v]);const N=v&&T?T:a,[l,o]=u.useState(null),y={top:20,right:20,bottom:30,left:60},j=Math.max(10,N-y.left-y.right),d=r?50:0,C=r?8:0,F=c-y.top-y.bottom-d-C,{minP:Z,maxP:z,maxVol:J}=u.useMemo(()=>{if(t.length===0)return{minP:0,maxP:1,maxVol:0};let $=1/0,w=-1/0,Y=0;for(const X of t)X.low<$&&($=X.low),X.high>w&&(w=X.high),X.volume&&X.volume>Y&&(Y=X.volume);return{minP:$,maxP:w,maxVol:Y}},[t]),V=Math.max(1,j/t.length*.7),K=$=>y.left+($+.5)*(j/t.length),A=$=>y.top+F-($-Z)/(z-Z||1)*F,i=c-y.bottom,m=$=>i-d*($/(J||1)),x=l!=null?t[l]:void 0,U=$=>{if(!h||t.length===0)return;const w=$.currentTarget.getBoundingClientRect(),Y=$.clientX-w.left-y.left,X=Math.floor(Y/j*t.length);o(X>=0&&X<t.length?X:null)};return e.jsxs("div",{ref:$=>{k.current=$,typeof g=="function"?g($):g&&(g.current=$)},id:M,className:`nice-stock-chart ${_||""}`,style:v?{width:"100%",position:"relative",...S}:{position:"relative",...S},"data-testid":B??I,children:[e.jsxs("svg",{width:N,height:c,className:"nice-stock-chart__svg",onMouseMove:U,onMouseLeave:()=>o(null),children:[[0,.25,.5,.75,1].map($=>{const w=Z+$*(z-Z);return e.jsxs("g",{children:[e.jsx("line",{x1:y.left,x2:N-y.right,y1:A(w),y2:A(w),stroke:"var(--nice-border, #e5e7eb)",strokeDasharray:"2,2"}),t.length>0&&e.jsx("text",{x:y.left-4,y:A(w)+4,textAnchor:"end",fontSize:10,fill:"var(--nice-text-secondary, #888)",children:b(w)})]},$)}),n==="line"?e.jsx("polyline",{points:t.map(($,w)=>`${K(w)},${A($.close)}`).join(" "),fill:"none",stroke:f,strokeWidth:1.5}):t.map(($,w)=>{const Y=$.close>=$.open,X=Y?f:s,oe=K(w);if(n==="ohlc")return e.jsxs("g",{children:[e.jsx("line",{x1:oe,x2:oe,y1:A($.high),y2:A($.low),stroke:X,strokeWidth:1}),e.jsx("line",{x1:oe-V/2,x2:oe,y1:A($.open),y2:A($.open),stroke:X,strokeWidth:1.5}),e.jsx("line",{x1:oe,x2:oe+V/2,y1:A($.close),y2:A($.close),stroke:X,strokeWidth:1.5})]},w);const ie=A(Math.max($.open,$.close)),ue=A(Math.min($.open,$.close)),P=Math.abs(ue-ie)<1;return e.jsxs("g",{className:"nice-stock-chart__candle",children:[e.jsx("line",{x1:oe,x2:oe,y1:A($.high),y2:ie,stroke:X,strokeWidth:1}),e.jsx("line",{x1:oe,x2:oe,y1:ue,y2:A($.low),stroke:X,strokeWidth:1}),P?e.jsx("line",{x1:oe-V/2,x2:oe+V/2,y1:ie,y2:ie,stroke:X,strokeWidth:1.5}):e.jsx("rect",{x:oe-V/2,y:ie,width:V,height:ue-ie,fill:Y?"var(--nice-bg-primary, #ffffff)":X,stroke:X,strokeWidth:1})]},w)}),r&&t.map(($,w)=>{if(!$.volume)return null;const Y=$.close>=$.open;return e.jsx("rect",{x:K(w)-V/2,y:m($.volume),width:V,height:i-m($.volume),fill:Y?f:s,opacity:.3},`v${w}`)}),t.map(($,w)=>w%Math.max(1,Math.floor(t.length/8))!==0?null:e.jsx("text",{x:K(w),y:c-y.bottom+16,textAnchor:"middle",fontSize:9,fill:"var(--nice-text-secondary, #888)",children:$.date},`l${w}`)),h&&x&&l!=null&&e.jsxs("g",{pointerEvents:"none",className:"nice-stock-chart__crosshair",children:[e.jsx("line",{x1:K(l),x2:K(l),y1:y.top,y2:c-y.bottom,stroke:"var(--nice-text-secondary, #888)",strokeDasharray:"3,3"}),e.jsx("line",{x1:y.left,x2:N-y.right,y1:A(x.close),y2:A(x.close),stroke:"var(--nice-text-secondary, #888)",strokeDasharray:"3,3"})]})]}),h&&x&&e.jsxs("div",{className:"nice-stock-chart__tooltip",role:"status",children:[e.jsx("strong",{children:x.date}),e.jsxs("span",{children:["O ",b(x.open)]}),e.jsxs("span",{children:["H ",b(x.high)]}),e.jsxs("span",{children:["L ",b(x.low)]}),e.jsxs("span",{children:["C ",b(x.close)]}),x.volume!=null&&e.jsxs("span",{children:["V ",x.volume.toLocaleString()]})]})]})}),{displayName:"NiceStockChart"}),yn=[],vn=({data:t=yn,width:n=120,height:r=30,type:a="line",color:c="var(--nice-color-primary, #3b82f6)",showMinMax:f,showLastPoint:s=!0,className:h,style:v,testId:b,"data-testid":_})=>{if(t.length===0)return null;const S=2,O=Math.min(...t),I=Math.max(...t),B=I-O||1,g=n-S*2,M=r-S*2,k=y=>S+y/(t.length-1||1)*g,T=y=>S+M-(y-O)/B*M;if(a==="bar"){const y=Math.max(1,g/t.length-1);return e.jsx("svg",{width:n,height:r,className:`nice-sparkline ${h||""}`,style:v,"data-testid":_??b,children:t.map((j,d)=>e.jsx("rect",{x:S+d/t.length*g,y:T(j),width:y,height:M-(T(j)-S),fill:c,rx:1},d))})}const E=t.map((y,j)=>`${k(j)},${T(y)}`).join(" "),N=t.indexOf(O),l=t.indexOf(I),o=t.length-1;return e.jsxs("svg",{width:n,height:r,className:`nice-sparkline ${h||""}`,style:v,"data-testid":_??b,children:[a==="area"&&e.jsx("polygon",{points:`${k(0)},${S+M} ${E} ${k(o)},${S+M}`,fill:c,opacity:.15}),e.jsx("polyline",{points:E,fill:"none",stroke:c,strokeWidth:1.5}),f&&e.jsx("circle",{cx:k(N),cy:T(O),r:2,fill:"var(--nice-danger, #ef4444)"}),f&&e.jsx("circle",{cx:k(l),cy:T(I),r:2,fill:"var(--nice-success, #22c55e)"}),s&&e.jsx("circle",{cx:k(o),cy:T(t[o]),r:2,fill:c})]})},bn=[],_n=[],wn=({series:t=bn,categories:n=_n,width:r=400,height:a=400,maxValue:c,title:f,showLegend:s=!0,className:h,style:v,testId:b,"data-testid":_})=>{const S=f?54:0,O=a-(s?30:0)-S,I=r/2,B=S+O/2,g=Math.min(I,O/2)-60,M=n.length,k=c??Math.max(...t.flatMap(l=>l.data),1),T=Math.PI*2/M,E=5,N=(l,o)=>{const y=l*T-Math.PI/2,j=o/k*g;return{x:I+j*Math.cos(y),y:B+j*Math.sin(y)}};return e.jsx("div",{className:`nice-polarchart ${h||""}`,style:v,"data-testid":_??b,children:e.jsxs("svg",{width:r,height:a,className:"nice-polarchart__svg",children:[f&&e.jsx("text",{x:I,y:30,textAnchor:"middle",className:"nice-chart__title",children:f}),Array.from({length:E},(l,o)=>{const y=g*((o+1)/E);return e.jsx("circle",{cx:I,cy:B,r:y,fill:"none",stroke:"var(--nice-border-color, #ddd)",strokeWidth:.5},o)}),n.map((l,o)=>{const y=N(o,k),j=N(o,k*1.22),d=o*T-Math.PI/2,C=Math.cos(d),F=Math.sin(d),Z=C>.2?"start":C<-.2?"end":"middle",z=F>.2?"hanging":F<-.2?"auto":"middle";return e.jsxs("g",{children:[e.jsx("line",{x1:I,y1:B,x2:y.x,y2:y.y,stroke:"var(--nice-border-color, #ddd)",strokeWidth:.5}),e.jsx("text",{x:j.x,y:j.y,textAnchor:Z,dominantBaseline:z,className:"nice-chart__axis-label nice-chart__axis-label--polar",children:l})]},o)}),t.map((l,o)=>{const y=l.color||Se[o%Se.length],j=l.data.map((d,C)=>{const F=N(C,d);return`${F.x},${F.y}`}).join(" ");return e.jsxs("g",{children:[e.jsx("polygon",{points:j,fill:l.fill!==!1?y:"none",fillOpacity:.15,stroke:y,strokeWidth:2}),l.data.map((d,C)=>{const F=N(C,d);return e.jsx("circle",{cx:F.x,cy:F.y,r:3,fill:y,children:e.jsx("title",{children:`${l.name} - ${n[C]}: ${d}`})},C)})]},l.name)}),s&&e.jsx("g",{transform:`translate(10, ${a-25})`,children:t.map((l,o)=>e.jsxs("g",{transform:`translate(${o*100}, 0)`,children:[e.jsx("rect",{width:10,height:10,rx:2,fill:l.color||Se[o%Se.length]}),e.jsx("text",{x:14,y:9,className:"nice-chart__legend-text",children:l.name})]},o))})]})})},jn=({data:t,min:n,max:r,start:a,end:c,onChange:f,width:s=500,height:h=100,step:v=1,formatValue:b,chartColor:_="var(--nice-color-primary, #3b82f6)",responsive:S=!0,className:O,style:I,testId:B,"data-testid":g})=>{const{t:M}=pe.useNiceTranslation(),k=u.useRef(null),[T,E]=u.useState(null);u.useEffect(()=>{const i=k.current;if(!S||!i||typeof ResizeObserver>"u")return;const m=new ResizeObserver(([x])=>{const U=Math.round(x.contentRect.width);U>0&&E(U)});return m.observe(i),()=>m.disconnect()},[S]);const N=S&&T?T:s,l={top:10,bottom:30,left:10,right:10},o=Math.max(10,N-l.left-l.right),y=h-l.top-l.bottom,j=r-n||1,d=i=>Math.min(r,Math.max(n,Math.round((i-n)/v)*v+n)),C=i=>l.left+(i-n)/j*o,F=i=>b?b(i):String(i),Z=(i,m)=>{m.preventDefault();const U=(m.currentTarget.ownerSVGElement??m.currentTarget).getBoundingClientRect(),$=ue=>n+Math.max(0,Math.min(1,(ue-U.left-l.left)/o))*j,w=$(m.clientX),Y=a,X=c,oe=ue=>{const P=$(ue.clientX);if(i==="start")f(Math.min(d(P),c),c);else if(i==="end")f(a,Math.max(d(P),a));else{const G=X-Y,p=Math.min(r-G,Math.max(n,d(Y+(P-w))));f(p,p+G)}},ie=()=>{document.removeEventListener("pointermove",oe),document.removeEventListener("pointerup",ie)};document.addEventListener("pointermove",oe),document.addEventListener("pointerup",ie)},z=i=>m=>{const x=v*10,U=i==="start"?a:c,$=m.key==="ArrowLeft"||m.key==="ArrowDown"?U-v:m.key==="ArrowRight"||m.key==="ArrowUp"?U+v:m.key==="PageDown"?U-x:m.key==="PageUp"?U+x:m.key==="Home"?i==="start"?n:a:m.key==="End"?i==="start"?c:r:null;$!==null&&(m.preventDefault(),i==="start"?f(Math.min(d($),c),c):f(a,Math.max(d($),a)))},J=t&&t.length?Math.min(...t):0,K=(t&&t.length?Math.max(...t):1)-J||1,A=i=>{const m=i==="start"?a:c;return e.jsx("rect",{x:C(m)-5,y:l.top,width:10,height:y,fill:_,rx:2,cursor:"ew-resize",className:"nice-rangeselector__handle",role:"slider",tabIndex:0,"aria-label":i==="start"?M("chartRangeSelector.start","Range start"):M("chartRangeSelector.end","Range end"),"aria-valuemin":i==="start"?n:a,"aria-valuemax":i==="start"?c:r,"aria-valuenow":m,"aria-valuetext":F(m),onPointerDown:x=>Z(i,x),onKeyDown:z(i)})};return e.jsx("div",{ref:k,className:`nice-rangeselector ${O||""}`,style:S?{width:"100%",...I}:I,"data-testid":g??B,children:e.jsxs("svg",{width:N,height:h,children:[t&&t.length>1&&e.jsx("polygon",{points:`${l.left},${l.top+y} ${t.map((i,m)=>`${l.left+m/(t.length-1)*o},${l.top+y-(i-J)/K*y}`).join(" ")} ${l.left+o},${l.top+y}`,fill:_,opacity:.15}),e.jsx("rect",{x:C(a),y:l.top,width:Math.max(0,C(c)-C(a)),height:y,fill:_,opacity:.12,cursor:"grab",className:"nice-rangeselector__window",onPointerDown:i=>Z("window",i)}),e.jsx("rect",{x:l.left,y:l.top,width:Math.max(0,C(a)-l.left),height:y,fill:"var(--nice-bg-secondary, #f5f5f5)",opacity:.6,pointerEvents:"none"}),e.jsx("rect",{x:C(c),y:l.top,width:Math.max(0,l.left+o-C(c)),height:y,fill:"var(--nice-bg-secondary, #f5f5f5)",opacity:.6,pointerEvents:"none"}),A("start"),A("end"),e.jsx("text",{x:C(a),y:l.top+y+18,textAnchor:"middle",className:"nice-chart__axis-label",children:F(a)}),e.jsx("text",{x:C(c),y:l.top+y+18,textAnchor:"middle",className:"nice-chart__axis-label",children:F(c)})]})})},$n=`
582
+ .nice-forecast-chart {
583
+ display: flex;
584
+ flex-direction: column;
585
+ background: var(--nice-bg-primary, #ffffff);
586
+ border: 1px solid var(--nice-border-color, #e5e7eb);
587
+ border-radius: var(--nice-radius-lg, 0.5rem);
588
+ overflow: hidden;
589
+ }
590
+
591
+ .nice-forecast-chart__header {
592
+ display: flex;
593
+ align-items: center;
594
+ justify-content: space-between;
595
+ padding: 0.75rem 1rem;
596
+ border-bottom: 1px solid var(--nice-border-color, #e5e7eb);
597
+ }
598
+
599
+ .nice-forecast-chart__title {
600
+ font-size: 1rem;
601
+ font-weight: 600;
602
+ color: var(--nice-text-primary);
603
+ margin: 0;
604
+ }
605
+
606
+ .nice-forecast-chart__actions {
607
+ display: flex;
608
+ gap: 0.5rem;
609
+ }
610
+
611
+ .nice-forecast-chart__btn {
612
+ display: inline-flex;
613
+ align-items: center;
614
+ justify-content: center;
615
+ width: 2rem;
616
+ height: 2rem;
617
+ font-size: 1rem;
618
+ border-radius: var(--nice-radius-md, 0.375rem);
619
+ cursor: pointer;
620
+ transition: all 0.15s ease;
621
+ border: 1px solid var(--nice-border-color, #d1d5db);
622
+ background: var(--nice-bg-primary, #ffffff);
623
+ color: var(--nice-text-secondary);
624
+ }
625
+
626
+ .nice-forecast-chart__btn:hover {
627
+ background: var(--nice-bg-hover, #f3f4f6);
628
+ color: var(--nice-text-primary);
629
+ }
630
+
631
+ .nice-forecast-chart__btn:disabled {
632
+ opacity: 0.5;
633
+ cursor: not-allowed;
634
+ }
635
+
636
+ .nice-forecast-chart__container {
637
+ position: relative;
638
+ width: 100%;
639
+ padding: 1rem;
640
+ }
641
+
642
+ .nice-forecast-chart__svg {
643
+ width: 100%;
644
+ overflow: visible;
645
+ }
646
+
647
+ .nice-forecast-chart__grid-line {
648
+ stroke: var(--nice-border-divider, #f3f4f6);
649
+ stroke-width: 1;
650
+ }
651
+
652
+ .nice-forecast-chart__axis-line {
653
+ stroke: var(--nice-border-color, #e5e7eb);
654
+ stroke-width: 1;
655
+ }
656
+
657
+ .nice-forecast-chart__axis-label {
658
+ font-size: 0.6875rem;
659
+ fill: var(--nice-text-secondary);
660
+ }
661
+
662
+ .nice-forecast-chart__axis-title {
663
+ font-size: 0.75rem;
664
+ font-weight: 500;
665
+ fill: var(--nice-text-primary);
666
+ }
667
+
668
+ .nice-forecast-chart__historical-line {
669
+ fill: none;
670
+ stroke-width: 2;
671
+ stroke-linecap: round;
672
+ stroke-linejoin: round;
673
+ }
674
+
675
+ .nice-forecast-chart__forecast-line {
676
+ fill: none;
677
+ stroke-width: 2;
678
+ stroke-linecap: round;
679
+ stroke-linejoin: round;
680
+ stroke-dasharray: 6, 4;
681
+ }
682
+
683
+ .nice-forecast-chart__confidence-band {
684
+ opacity: 0.2;
685
+ }
686
+
687
+ .nice-forecast-chart__forecast-region {
688
+ fill: var(--nice-bg-secondary, #f9fafb);
689
+ opacity: 0.5;
690
+ }
691
+
692
+ .nice-forecast-chart__point {
693
+ cursor: pointer;
694
+ transition: r 0.15s ease;
695
+ }
696
+
697
+ .nice-forecast-chart__point:hover {
698
+ r: 6;
699
+ }
700
+
701
+ .nice-forecast-chart__annotation-line {
702
+ stroke-dasharray: 4, 2;
703
+ stroke-width: 1;
704
+ }
705
+
706
+ .nice-forecast-chart__annotation-marker {
707
+ cursor: pointer;
708
+ transition: transform 0.15s ease;
709
+ }
710
+
711
+ .nice-forecast-chart__annotation-marker:hover {
712
+ transform: scale(1.2);
713
+ }
714
+
715
+ .nice-forecast-chart__reference-line {
716
+ stroke-width: 1;
717
+ }
718
+
719
+ .nice-forecast-chart__reference-label {
720
+ font-size: 0.625rem;
721
+ fill: var(--nice-text-secondary);
722
+ }
723
+
724
+ .nice-forecast-chart__cash-runway {
725
+ pointer-events: none;
726
+ }
727
+
728
+ .nice-forecast-chart__cash-runway-line {
729
+ stroke: var(--nice-danger, #ef4444);
730
+ stroke-width: 2;
731
+ stroke-dasharray: 8, 4;
732
+ }
733
+
734
+ .nice-forecast-chart__cash-runway-label-bg {
735
+ fill: var(--nice-danger, #ef4444);
736
+ rx: 4;
737
+ }
738
+
739
+ .nice-forecast-chart__cash-runway-label {
740
+ font-size: 0.6875rem;
741
+ font-weight: 600;
742
+ fill: var(--nice-bg, #FFFFFF);
743
+ }
744
+
745
+ .nice-forecast-chart__cash-runway-date {
746
+ font-size: 0.625rem;
747
+ fill: var(--nice-danger, #ef4444);
748
+ font-weight: 500;
749
+ }
750
+
751
+ .nice-forecast-chart__tooltip {
752
+ position: absolute;
753
+ pointer-events: none;
754
+ z-index: 100;
755
+ padding: 0.75rem;
756
+ background: var(--nice-bg-primary, #ffffff);
757
+ border: 1px solid var(--nice-border-color, #e5e7eb);
758
+ border-radius: var(--nice-radius-lg, 0.5rem);
759
+ box-shadow: 0 4px 12px var(--nice-overlay-10, rgba(0, 0, 0, 0.1));
760
+ font-size: 0.8125rem;
761
+ max-width: 250px;
762
+ }
763
+
764
+ .nice-forecast-chart__tooltip-date {
765
+ font-weight: 600;
766
+ color: var(--nice-text-primary);
767
+ margin-bottom: 0.5rem;
768
+ padding-bottom: 0.5rem;
769
+ border-bottom: 1px solid var(--nice-border-divider, #f3f4f6);
770
+ }
771
+
772
+ .nice-forecast-chart__tooltip-item {
773
+ display: flex;
774
+ align-items: center;
775
+ gap: 0.5rem;
776
+ margin-bottom: 0.25rem;
777
+ }
778
+
779
+ .nice-forecast-chart__tooltip-color {
780
+ width: 10px;
781
+ height: 10px;
782
+ border-radius: var(--nice-radius-sm, 2px);
783
+ flex-shrink: 0;
784
+ }
785
+
786
+ .nice-forecast-chart__tooltip-label {
787
+ color: var(--nice-text-secondary);
788
+ flex: 1;
789
+ }
790
+
791
+ .nice-forecast-chart__tooltip-value {
792
+ font-weight: 600;
793
+ color: var(--nice-text-primary);
794
+ font-variant-numeric: tabular-nums;
795
+ }
796
+
797
+ .nice-forecast-chart__tooltip-confidence {
798
+ font-size: 0.75rem;
799
+ color: var(--nice-text-tertiary);
800
+ }
801
+
802
+ .nice-forecast-chart__legend {
803
+ display: flex;
804
+ flex-wrap: wrap;
805
+ gap: 1rem;
806
+ padding: 0.75rem 1rem;
807
+ border-top: 1px solid var(--nice-border-color, #e5e7eb);
808
+ }
809
+
810
+ .nice-forecast-chart__legend-item {
811
+ display: flex;
812
+ align-items: center;
813
+ gap: 0.375rem;
814
+ font-size: 0.8125rem;
815
+ color: var(--nice-text-secondary);
816
+ cursor: pointer;
817
+ user-select: none;
818
+ transition: opacity 0.15s ease;
819
+ }
820
+
821
+ .nice-forecast-chart__legend-item:hover {
822
+ color: var(--nice-text-primary);
823
+ }
824
+
825
+ .nice-forecast-chart__legend-item--hidden {
826
+ opacity: 0.4;
827
+ }
828
+
829
+ .nice-forecast-chart__legend-color {
830
+ width: 16px;
831
+ height: 3px;
832
+ border-radius: var(--nice-radius-xs, 1px);
833
+ }
834
+
835
+ .nice-forecast-chart__legend-color--dashed {
836
+ background: repeating-linear-gradient(
837
+ 90deg,
838
+ currentColor,
839
+ currentColor 4px,
840
+ transparent 4px,
841
+ transparent 6px
842
+ );
843
+ }
844
+
845
+ .nice-forecast-chart__empty {
846
+ display: flex;
847
+ align-items: center;
848
+ justify-content: center;
849
+ height: 300px;
850
+ color: var(--nice-text-secondary);
851
+ }
852
+
853
+ /* Dark mode */
854
+ .dark .nice-forecast-chart {
855
+ background: var(--nice-bg-primary-dark, #111827);
856
+ border-color: var(--nice-border-color-dark, #374151);
857
+ }
858
+
859
+ .dark .nice-forecast-chart__tooltip {
860
+ background: var(--nice-bg-secondary-dark, #1f2937);
861
+ border-color: var(--nice-border-color-dark, #374151);
862
+ }
863
+
864
+ .dark .nice-forecast-chart__forecast-region {
865
+ fill: var(--nice-bg-secondary-dark, #1f2937);
866
+ }
867
+ `,ct=["var(--nice-color-primary, #3b82f6)","var(--nice-color-success, #10b981)","var(--nice-color-warning, #f59e0b)","var(--nice-color-error, #ef4444)","var(--nice-color-accent, #8b5cf6)","var(--nice-color-accent-pink, #ec4899)","var(--nice-color-info, #06b6d4)","var(--nice-warning, #f97316)"];function Ae(t){return t instanceof Date?t:new Date(t)}function Ge(t,n="pl-PL"){return t.toLocaleDateString(n,{year:"numeric",month:"short",day:"numeric"})}function Pe(t,n="pl-PL"){return new Intl.NumberFormat(n,{minimumFractionDigits:0,maximumFractionDigits:2}).format(t)}const Mn={top:20,right:30,bottom:40,left:60},kn=u.forwardRef(function(n,r){const{t:a}=pe.useNiceTranslation(),{scenarios:c,data:f,annotations:s=[],referenceLines:h=[],forecastStartDate:v,cashRunway:b,xAxis:_,yAxis:S,confidenceBands:O=[{level:95,color:"var(--nice-color-primary, #3b82f6)",opacity:.15}],tooltip:I,legend:B={enabled:!0,position:"bottom",interactive:!0},height:g=350,showForecastRegion:M=!0,lineWidth:k=2,showPoints:T=!1,pointRadius:E=4,enableZoom:N=!1,zoomEnabled:l,animationDuration:o=300,showLegend:y,responsive:j=!0,onPointClick:d,onAnnotationClick:C,onScenarioToggle:F,onViewportChange:Z,size:z="medium",disabled:J=!1,labels:V={},locale:K="pl-PL",className:A,style:i,testId:m,"data-testid":x}=n,U=c&&c.length>0?c:f?[{id:"default",name:"Series",data:f}]:[],$={...B,enabled:y??B.enabled},[w,Y]=u.useState(()=>U.map((R,se)=>({...R,color:R.color??ct[se%ct.length],visible:R.visible!==!1}))),[X,oe]=u.useState(null),[ie,ue]=u.useState({x:0,y:0}),P=u.useRef(null),G=u.useRef(null),p=Mn,[D,H]=u.useState({width:600,height:typeof g=="number"?g:350});u.useEffect(()=>{if(!j||!P.current)return;const R=new ResizeObserver(se=>{for(const de of se)H(ee=>({width:de.contentRect.width,height:ee.height}))});return R.observe(P.current),()=>R.disconnect()},[j]),u.useEffect(()=>{const R="nice-forecast-chart-styles";if(!document.getElementById(R)){const se=document.createElement("style");se.id=R,se.textContent=$n,document.head.appendChild(se)}},[]);const{xScale:W,yScale:te,allDates:ne,minY:re,maxY:be}=u.useMemo(()=>{const se=w.filter(ae=>ae.visible!==!1).flatMap(ae=>ae.data);if(se.length===0)return{xScale:()=>0,yScale:()=>0,allDates:[],minY:0,maxY:100};const de=se.map(ae=>Ae(ae.date).getTime()),ee=Math.min(...de),ge=Math.max(...de),Re=se.flatMap(ae=>[ae.value,ae.forecast,ae.lowerBound,ae.upperBound]).filter(ae=>ae!=null),Te=S?.min??Math.min(...Re)*.95,Ne=S?.max??Math.max(...Re)*1.05,L=D.width-p.left-p.right,he=D.height-p.top-p.bottom,fe=ae=>{const xe=typeof ae=="number"?ae:ae.getTime();return p.left+(xe-ee)/(ge-ee)*L},je=ae=>p.top+he-(ae-Te)/(Ne-Te)*he,$e=[...new Set(de)].sort((ae,xe)=>ae-xe).map(ae=>new Date(ae));return{xScale:fe,yScale:je,allDates:$e,minY:Te,maxY:Ne}},[w,D,p,S]),ke=v?Ae(v):null,Q=u.useMemo(()=>{if(!b?.enabled)return null;const R=b.threshold??0,se=b.scenarioId?w.find(ee=>ee.id===b.scenarioId&&ee.visible!==!1):w.find(ee=>ee.visible!==!1);if(!se)return null;const de=se.data.sort((ee,ge)=>Ae(ee.date).getTime()-Ae(ge.date).getTime());for(let ee=1;ee<de.length;ee++){const ge=de[ee-1],Re=de[ee],Te=ge.forecast??ge.value,Ne=Re.forecast??Re.value;if(Te!=null&&Ne!=null&&Te>R&&Ne<=R){const L=(Te-R)/(Te-Ne),he=Ae(ge.date).getTime(),fe=Ae(Re.date).getTime(),je=he+L*(fe-he);return new Date(je)}}return null},[b,w]),ce=u.useCallback((R,se)=>{const de=R.filter(ee=>ee[se]!=null).map(ee=>({x:W(Ae(ee.date)),y:te(ee[se])}));return de.length===0?"":`M ${de.map(ee=>`${ee.x},${ee.y}`).join(" L ")}`},[W,te]),q=u.useCallback(R=>{const se=R.filter(ge=>ge.lowerBound!=null&&ge.upperBound!=null);if(se.length===0)return"";const de=se.map(ge=>({x:W(Ae(ge.date)),y:te(ge.upperBound)})),ee=se.map(ge=>({x:W(Ae(ge.date)),y:te(ge.lowerBound)})).reverse();return`M ${de.map(ge=>`${ge.x},${ge.y}`).join(" L ")} L ${ee.map(ge=>`${ge.x},${ge.y}`).join(" L ")} Z`},[W,te]),le=u.useCallback(R=>{if(!G.current||I?.enabled===!1)return;const se=G.current.getBoundingClientRect(),de=R.clientX-se.left;R.clientY-se.top;let ee=null,ge=1/0;for(const Re of ne){const Te=W(Re),Ne=Math.abs(Te-de);Ne<ge&&(ge=Ne,ee=Re)}if(ee&&ge<50){const Re=w.filter(Ne=>Ne.visible!==!1).map(Ne=>{const L=Ne.data.find(he=>Ae(he.date).getTime()===ee.getTime());return{scenario:Ne,value:L?.value,forecast:L?.forecast,lowerBound:L?.lowerBound,upperBound:L?.upperBound}}),Te=s.filter(Ne=>Math.abs(Ae(Ne.date).getTime()-ee.getTime())<864e5);oe({date:ee,values:Re,annotations:Te}),ue({x:R.clientX-se.left+10,y:R.clientY-se.top-10})}else oe(null)},[W,ne,w,s,I]),ye=u.useCallback(R=>{if(!$.interactive)return;Y(de=>de.map(ee=>ee.id===R?{...ee,visible:!ee.visible}:ee));const se=w.find(de=>de.id===R);se&&F?.(R,!se.visible)},[$.interactive,w,F]);u.useImperativeHandle(r,()=>({getScenarios:()=>w,updateScenario:(R,se)=>{Y(de=>de.map(ee=>ee.id===R?{...ee,data:se}:ee))},toggleScenario:ye,setZoomRange:()=>{},resetZoom:()=>{},exportImage:R=>{if(!G.current)return null;const se=G.current,ee=new XMLSerializer().serializeToString(se);return`data:image/svg+xml;base64,${btoa(ee)}`},getDataAtDate:R=>{const se=w.filter(de=>de.visible!==!1).map(de=>{const ee=de.data.find(ge=>Ae(ge.date).getTime()===R.getTime());return{scenario:de,value:ee?.value,forecast:ee?.forecast,lowerBound:ee?.lowerBound,upperBound:ee?.upperBound}});return{date:R,values:se,annotations:s.filter(de=>Ae(de.date).getTime()===R.getTime())}}}),[w,s,ye]),D.width-p.left-p.right;const Me=D.height-p.top-p.bottom,_e=u.useMemo(()=>{const R=S?.tickCount??5,se=[],de=(be-re)/(R-1);for(let ee=0;ee<R;ee++)se.push(re+de*ee);return se},[re,be,S?.tickCount]),we=u.useMemo(()=>{const R=_?.tickCount??6;if(ne.length===0)return[];const se=Math.max(1,Math.floor(ne.length/(R-1)));return ne.filter((de,ee)=>ee%se===0||ee===ne.length-1)},[ne,_?.tickCount]);return w.length===0||w.every(R=>R.data.length===0)?e.jsx("div",{className:`nice-forecast-chart ${A??""}`,style:i,"data-testid":x??m,children:e.jsx("div",{className:"nice-forecast-chart__empty",children:V.noData??a("forecastChart.noDataAvailable","No data available")})}):e.jsxs("div",{className:`nice-forecast-chart ${A??""}`,style:{...i,height:g},"data-testid":x??m,children:[e.jsxs("div",{ref:P,className:"nice-forecast-chart__container",children:[e.jsxs("svg",{ref:G,className:"nice-forecast-chart__svg",width:D.width,height:D.height,onMouseMove:le,onMouseLeave:()=>oe(null),children:[S?.showGrid!==!1&&_e.map(R=>e.jsx("line",{className:"nice-forecast-chart__grid-line",x1:p.left,x2:D.width-p.right,y1:te(R),y2:te(R)},R)),M&&ke&&e.jsx("rect",{className:"nice-forecast-chart__forecast-region",x:W(ke),y:p.top,width:D.width-p.right-W(ke),height:Me}),h.map(R=>e.jsxs("g",{children:[e.jsx("line",{className:"nice-forecast-chart__reference-line",x1:p.left,x2:D.width-p.right,y1:te(R.value),y2:te(R.value),stroke:R.color??"var(--nice-text-muted, #9ca3af)",strokeDasharray:R.dashArray??"4,2"}),R.label&&e.jsx("text",{className:"nice-forecast-chart__reference-label",x:D.width-p.right-4,y:te(R.value)-4,textAnchor:"end",children:R.label})]},R.id)),Q&&b?.enabled&&e.jsxs("g",{className:"nice-forecast-chart__cash-runway",children:[e.jsx("line",{className:"nice-forecast-chart__cash-runway-line",x1:W(Q),x2:W(Q),y1:p.top,y2:D.height-p.bottom,stroke:b.color??"var(--nice-color-error, #ef4444)"}),b.showLabel!==!1&&e.jsxs(e.Fragment,{children:[e.jsx("rect",{className:"nice-forecast-chart__cash-runway-label-bg",x:W(Q)-60,y:p.top-2,width:120,height:b.showDate!==!1?32:20,fill:b.color??"var(--nice-color-error, #ef4444)",rx:4}),e.jsx("text",{className:"nice-forecast-chart__cash-runway-label",x:W(Q),y:p.top+12,textAnchor:"middle",fill:"var(--nice-color-white, #fff)",children:b.label??V.cashRunsOut??a("forecastChart.cashRunsOut","Cash runs out")}),b.showDate!==!1&&e.jsx("text",{className:"nice-forecast-chart__cash-runway-label",x:W(Q),y:p.top+26,textAnchor:"middle",fill:"var(--nice-color-white, #fff)",style:{fontSize:"0.625rem",opacity:.9},children:Ge(Q,K)})]})]}),w.filter(R=>R.visible!==!1&&R.showConfidenceBand).map(R=>e.jsx("path",{className:"nice-forecast-chart__confidence-band",d:q(R.data),fill:R.color},`band-${R.id}`)),w.filter(R=>R.visible!==!1).map(R=>{const se=ke?R.data.filter(ee=>Ae(ee.date)<ke):R.data.filter(ee=>ee.value!=null),de=ke?R.data.filter(ee=>Ae(ee.date)>=ke):R.data.filter(ee=>ee.forecast!=null);return e.jsxs("g",{children:[e.jsx("path",{className:"nice-forecast-chart__historical-line",d:ce(se,"value"),stroke:R.color,strokeWidth:k}),e.jsx("path",{className:"nice-forecast-chart__forecast-line",d:ce(de,ke?"value":"forecast"),stroke:R.color,strokeWidth:k}),de.length>0&&R.data.some(ee=>ee.forecast!=null)&&e.jsx("path",{className:"nice-forecast-chart__forecast-line",d:ce(R.data,"forecast"),stroke:R.color,strokeWidth:k}),T&&R.data.map((ee,ge)=>{const Re=ee.value??ee.forecast;return Re==null?null:e.jsx("circle",{className:"nice-forecast-chart__point",cx:W(Ae(ee.date)),cy:te(Re),r:E,fill:R.color,onClick:()=>d?.(ee,R)},ge)})]},R.id)}),s.map(R=>{const se=W(Ae(R.date));return e.jsxs("g",{className:"nice-forecast-chart__annotation-marker",onClick:()=>C?.(R),children:[R.showLine!==!1&&e.jsx("line",{className:"nice-forecast-chart__annotation-line",x1:se,x2:se,y1:p.top,y2:D.height-p.bottom,stroke:R.color??"var(--nice-text-muted, #9ca3af)"}),e.jsx("circle",{cx:se,cy:p.top+10,r:8,fill:R.color??"var(--nice-text-muted, #9ca3af)"}),e.jsx("text",{x:se,y:p.top+14,textAnchor:"middle",fill:"white",fontSize:"10",children:R.icon??"!"})]},R.id)}),e.jsx("line",{className:"nice-forecast-chart__axis-line",x1:p.left,x2:p.left,y1:p.top,y2:D.height-p.bottom}),e.jsx("line",{className:"nice-forecast-chart__axis-line",x1:p.left,x2:D.width-p.right,y1:D.height-p.bottom,y2:D.height-p.bottom}),_e.map(R=>e.jsx("text",{className:"nice-forecast-chart__axis-label",x:p.left-8,y:te(R)+4,textAnchor:"end",children:S?.format?S.format(R):Pe(R,K)},R)),we.map(R=>e.jsx("text",{className:"nice-forecast-chart__axis-label",x:W(R),y:D.height-p.bottom+16,textAnchor:"middle",children:_?.format?_.format(R):Ge(R,K)},R.getTime())),S?.title&&e.jsx("text",{className:"nice-forecast-chart__axis-title",x:15,y:D.height/2,textAnchor:"middle",transform:`rotate(-90, 15, ${D.height/2})`,children:S.title})]}),X&&e.jsxs("div",{className:"nice-forecast-chart__tooltip",style:{left:ie.x,top:ie.y},children:[e.jsx("div",{className:"nice-forecast-chart__tooltip-date",children:Ge(X.date,K)}),X.values.map(R=>{const se=R.value??R.forecast;return se==null?null:e.jsxs("div",{className:"nice-forecast-chart__tooltip-item",children:[e.jsx("span",{className:"nice-forecast-chart__tooltip-color",style:{background:R.scenario.color}}),e.jsx("span",{className:"nice-forecast-chart__tooltip-label",children:R.scenario.name}),e.jsx("span",{className:"nice-forecast-chart__tooltip-value",children:Pe(se,K)})]},R.scenario.id)}),X.values.some(R=>R.lowerBound!=null)&&e.jsxs("div",{className:"nice-forecast-chart__tooltip-confidence",children:[V.confidence??a("forecastChart.ci","CI"),":"," ",Pe(X.values[0]?.lowerBound??0,K)," –"," ",Pe(X.values[0]?.upperBound??0,K)]})]})]}),$.enabled&&e.jsx("div",{className:"nice-forecast-chart__legend",children:w.map(R=>e.jsxs("div",{role:"button",tabIndex:0,"aria-pressed":R.visible!==!1,onKeyDown:pe.clickOnActivationKey,className:`nice-forecast-chart__legend-item ${R.visible===!1?"nice-forecast-chart__legend-item--hidden":""}`,onClick:()=>ye(R.id),children:[e.jsx("span",{className:`nice-forecast-chart__legend-color ${R.isBase?"":"nice-forecast-chart__legend-color--dashed"}`,style:{background:R.color}}),R.name]},R.id))})]})}),Nn=[];function Sn(t,n){const r=t?typeof t=="number"?new Date(t):new Date(t):new Date,a=v=>v.toString().padStart(2,"0"),c=a(r.getHours()),f=a(r.getMinutes()),s=a(r.getSeconds()),h=r.getMilliseconds().toString().padStart(3,"0");switch(n){case"HH:mm:ss":return`${c}:${f}:${s}`;case"HH:mm":return`${c}:${f}`;case"mm:ss":return`${f}:${s}`;case"ss.SSS":return`${s}.${h}`;case"ISO":return r.toISOString();default:return`${c}:${f}:${s}`}}function it(t){if(t.length===0)return null;const n=Math.min(...t),r=Math.max(...t),a=t.reduce((f,s)=>f+s,0)/t.length,c=t[t.length-1];return{min:n,max:r,avg:a,current:c,count:t.length}}const Cn=Object.assign(u.forwardRef(({series:t=Nn,maxPoints:n=100,slidingWindow:r=!0,refreshRate:a=16,dataSource:c,width:f=600,height:s=400,title:h,showLegend:v=!0,showGrid:b=!0,yAxisLabel:_,xAxisLabel:S,stacked:O,zoomable:I,crosshair:B,annotations:g=[],legendInteractive:M,onDataPointClick:k,exportable:T,showControls:E=!0,showStatus:N=!0,initialPaused:l=!1,onDataReceived:o,onDataDropped:y,timeFormat:j="HH:mm:ss",showStats:d,thresholds:C=[],className:F,style:Z,testId:z,"data-testid":J},V)=>{const[K,A]=u.useState(()=>{const q=new Map;for(const le of t)q.set(le.name,le.initialData?.slice()??[]);return q}),[i,m]=u.useState([]),{t:x}=pe.useNiceTranslation(),[U,$]=u.useState(l),[w,Y]=u.useState(!1),X=u.useRef([]),oe=u.useRef(Date.now()),ie=u.useRef(null),ue=u.useRef(new Map),P=u.useRef(0),G=JSON.stringify(t.map(q=>q.name)),p=u.useMemo(()=>new Set(JSON.parse(G)),[G]),D=u.useRef(U),H=u.useRef(o),W=u.useRef(y);u.useEffect(()=>{D.current=U,H.current=o,W.current=y});const te=u.useRef(null);te.current===null&&(te.current=new Map(t.map(q=>[q.name,q.initialData?.length??0])));const ne=u.useCallback(()=>{const q=X.current;if(q.length===0)return;X.current=[];const le=te.current??new Map,ye=[];for(const _e of q){const we=le.get(_e.series);we!==void 0&&(r&&we+1>n?(ye.push([_e.series,we+1-n]),le.set(_e.series,n)):le.set(_e.series,we+1))}A(_e=>{const we=new Map(_e);for(const R of q){const se=we.get(R.series);if(!se)continue;const de=[...se,R.value];r&&de.length>n&&de.splice(0,de.length-n),we.set(R.series,de)}return we});for(const[_e,we]of ye)W.current?.(we,_e);const Me=[];for(const _e of q){if(!p.has(_e.series))continue;const we=(ue.current.get(_e.series)??0)+1;ue.current.set(_e.series,we),we>P.current&&(P.current=we,Me.push(_e.category??Sn(_e.timestamp,j)))}Me.length>0&&m(_e=>{const we=[..._e,...Me];return r&&we.length>n&&we.splice(0,we.length-n),we})},[r,n,j,p]),re=u.useCallback(()=>{const q=Date.now();q-oe.current>=a&&(ne(),oe.current=q),ie.current=requestAnimationFrame(re)},[a,ne]);u.useEffect(()=>(U||(ie.current=requestAnimationFrame(re)),()=>{ie.current!==null&&(cancelAnimationFrame(ie.current),ie.current=null)}),[U,re]);const be=u.useCallback(q=>{if(D.current)return;const le="points"in q?q.points:[q];for(const ye of le)p.has(ye.series)&&(X.current.push(ye),H.current?.(ye))},[p]);u.useEffect(()=>{if(!c)return;const q=c.subscribe(be);let le;return c.onStatusChange?le=c.onStatusChange(Y):Y(!0),c.fetchHistory&&c.fetchHistory(n).then(ye=>{for(const Me of ye)X.current.push(Me);ne()}),()=>{q(),le?.()}},[c,be,n,ne]);const ke=u.useMemo(()=>t.map(q=>({name:q.name,color:q.color,type:q.type,data:K.get(q.name)??[]})),[t,K]),Q=u.useMemo(()=>{const q=[...g];for(const le of C)q.push({type:"line",value:le.value,color:le.color,label:le.label,dash:le.style==="dashed"?"5,5":le.style==="dotted"?"2,2":void 0});return q},[g,C]);u.useImperativeHandle(V,()=>({pause(){$(!0)},resume(){$(!1)},isPaused(){return U},clear(){A(le=>{const ye=new Map(le);for(const Me of ye.keys())ye.set(Me,[]);return ye}),m([]),ue.current=new Map,P.current=0,X.current=[];const q=te.current;if(q)for(const le of q.keys())q.set(le,0)},addPoint(q){be(q)},addPoints(q){be({points:q})},getData(q){return K.get(q)??[]},getCategories(){return i},exportData(){return{series:ke,categories:i}},getStats(q){const le=K.get(q);return le?it(le):null}}),[U,K,i,ke,be]);const ce=u.useMemo(()=>{if(!d)return null;const q={};for(const[le,ye]of K)q[le]=it(ye);return q},[d,K]);return e.jsxs("div",{className:F,style:{position:"relative",...Z},"data-testid":J??z,children:[N&&e.jsxs("div",{style:{position:"absolute",top:8,right:8,display:"flex",alignItems:"center",gap:4,fontSize:12,color:w?"var(--nice-color-success, #22c55e)":"var(--nice-color-error, #ef4444)",zIndex:10},children:[e.jsx("span",{style:{width:8,height:8,borderRadius:"50%",backgroundColor:w?"var(--nice-color-success, #22c55e)":"var(--nice-color-error, #ef4444)"}}),w?x("charts.live","Live"):x("charts.disconnected","Disconnected")]}),E&&e.jsx("div",{style:{position:"absolute",top:8,left:8,display:"flex",gap:4,zIndex:10},children:e.jsx("button",{onClick:()=>$(q=>!q),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?x("charts.resume","Resume"):x("charts.pause","Pause"),"aria-label":U?x("charts.resume","Resume"):x("charts.pause","Pause"),children:e.jsx(pe.NiceIcon,{name:U?"play":"pause",size:14})})}),d&&ce&&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(ce).map(([q,le])=>le?e.jsxs("div",{style:{marginBottom:4},children:[e.jsx("strong",{children:q}),e.jsxs("div",{children:[x("charts.stats.min","Min"),": ",le.min.toFixed(2)," |"," ",x("charts.stats.max","Max"),": ",le.max.toFixed(2)]}),e.jsxs("div",{children:[x("charts.stats.avg","Avg"),": ",le.avg.toFixed(2)," |"," ",x("charts.stats.now","Now"),": ",le.current.toFixed(2)]})]},q):null)}),e.jsx(Ye,{series:ke,categories:i,width:f,height:s,title:h,showLegend:v,showGrid:b,yAxisLabel:_,xAxisLabel:S,stacked:O,zoomable:I,crosshair:B,annotations:Q,legendInteractive:M,onDataPointClick:k,exportable:T})]})}),{displayName:"NiceLiveChart"});function Rn(t){const{hubConnection:n,eventName:r="DataPoint",subscribeMethod:a="SubscribeToMetrics",historyMethod:c="GetMetricHistory",metricName:f}=t;return{subscribe(s){const h=v=>{s(v)};return n.on(r,h),n.state==="Connected"&&n.invoke(a,f).catch(()=>{}),()=>{n.off(r,h)}},async fetchHistory(s){try{return await n.invoke(c,f,s)}catch{return[]}},onStatusChange(s){const h=()=>s(n.state==="Connected");return n.onclose(()=>s(!1)),n.onreconnected(()=>s(!0)),h(),()=>{}}}}function An(t){const{url:n,autoReconnect:r=!0,reconnectDelay:a=3e3,parseMessage:c=_=>JSON.parse(_)}=t;let f=null,s=null,h=null,v=null;const b=()=>{f=new WebSocket(n),f.onopen=()=>{s?.(!0)},f.onclose=()=>{s?.(!1),r&&(v=setTimeout(b,a))},f.onerror=()=>{f?.close()},f.onmessage=_=>{try{const S=c(_.data);S&&h&&h(S)}catch{}}};return{subscribe(_){return h=_,b(),()=>{h=null,v&&clearTimeout(v),f?.close(),f=null}},onStatusChange(_){return s=_,()=>{s=null}}}}function Tn(t){const{seriesNames:n,interval:r=1e3,generateValue:a=()=>Math.random()*100}=t;let c=null,f=0;return{subscribe(s){return c=setInterval(()=>{for(const h of n)s({series:h,value:a(h,f),timestamp:Date.now()});f++},r),()=>{c&&clearInterval(c)}},onStatusChange(s){return s(!0),()=>{}}}}const In=[];function zn(t){if(!t.length)return{categories:[],numericFields:[],sampleValues:{}};const n=t[0],r=[],a={};let c=null;for(const[s,h]of Object.entries(n))typeof h=="number"?(r.push(s),a[s]=t.map(v=>Number(v[s])||0)):!c&&(typeof h=="string"||h instanceof Date)&&(c=s);return{categories:c?t.map(s=>String(s[c]||"")):t.map((s,h)=>`Item ${h+1}`),numericFields:r,sampleValues:a}}function Dn(t,n){const{categories:r,numericFields:a,sampleValues:c}=zn(t);return{series:a.map((s,h)=>({name:s.replace(/([A-Z])/g," $1").replace(/^./,v=>v.toUpperCase()).trim(),data:c[s],type:n==="area"?"area":n==="line"?"line":"bar"})),categories:r}}const En=u.forwardRef(function(n,r){const{rawData:a,enableAI:c=!0,aiModel:f,enableAutoType:s=!0,enableInsights:h=!0,dataDescription:v,onChartSuggestion:b,onInsights:_,showAIToolbar:S=!0,showInsightsOnLoad:O=!1,series:I=In,categories:B,...g}=n,[M,k]=u.useState("bar"),[T,E]=u.useState(null),[N,l]=u.useState([]),[o,y]=u.useState(O),[j,d]=u.useState(null),{t:C}=St.useNiceTranslation(),F=pe.useNiceAI(),{suggestChartType:Z,generateInsights:z,isLoading:J}=pe.useChartSuggestion(),V=c&&F.isConfigured,{series:K,categories:A}=a?Dn(a,j||M):{series:I||[],categories:B},i=u.useCallback(async()=>{if(!V||!s)return{type:"bar",reason:"Default",config:{}};const w=a||(I?.length?I.flatMap(Y=>Y.data.map((X,oe)=>({[Y.name]:X,index:oe}))):[]);try{const Y=await Z(w,v),X={type:Y.type,reason:Y.reason,config:Y.config};return E(X),k(X.type),b?.(X),X}catch{return{type:"bar",reason:"Default fallback",config:{}}}},[V,s,a,I,v,Z,b]),m=u.useCallback(async()=>{if(!V||!h)return[];const w=a||(I?.length?I.flatMap(Y=>Y.data.map((X,oe)=>({[Y.name]:X,category:B?.[oe]||oe}))):[]);try{const Y=await z(w,j||M);return l(Y),_?.(Y),Y}catch{return[]}},[V,h,a,I,B,M,j,z,_]),x=u.useCallback(()=>j||M,[j,M]);u.useEffect(()=>{V&&s&&(a?.length||I?.length)&&i()},[V,s,a,I]),u.useImperativeHandle(r,()=>({getSuggestion:i,generateInsights:m,getCurrentType:x}));const U=[{type:"bar",icon:"bar-chart",label:C("chartAI.bar","Bar")},{type:"line",icon:"line-chart",label:C("chartAI.line","Line")},{type:"area",icon:"area-chart",label:C("chartAI.area","Area")},{type:"pie",icon:"pie-chart",label:C("chartAI.pie","Pie")},{type:"donut",icon:"donut-chart",label:C("chartAI.donut","Donut")},{type:"scatter",icon:"scatter-chart",label:C("chartAI.scatter","Scatter")}],$=j||M;return e.jsxs("div",{className:"nice-chart-ai","data-testid":n["data-testid"],children:[S&&V&&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:C("chartAI.ai","AI")}),T&&e.jsxs("div",{className:"nice-chart-ai__suggestion",children:[e.jsx("span",{className:"nice-chart-ai__suggestion-icon",children:e.jsx(pe.NiceIcon,{name:"lightbulb",size:14})}),e.jsxs("span",{className:"nice-chart-ai__suggestion-text",children:[C("chartAI.suggestedType","Suggested:")," ",T.type]}),e.jsxs("span",{className:"nice-chart-ai__suggestion-reason",title:T.reason,children:["(",T.reason,")"]})]}),J&&e.jsx("span",{className:"nice-chart-ai__loading",children:C("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(w=>["bar","line","area"].includes(w.type)).map(({type:w,icon:Y,label:X})=>e.jsx("button",{type:"button",className:`nice-chart-ai__type-btn ${$===w?"nice-chart-ai__type-btn--active":""}`,onClick:()=>d(w),title:X,children:e.jsx(pe.NiceIcon,{name:Y,size:16})},w))})}),e.jsxs("div",{className:"nice-chart-ai__toolbar-right",children:[e.jsxs("button",{type:"button",className:"nice-chart-ai__auto-btn",onClick:()=>i(),disabled:J,title:C("chartAI.autoDetect","Auto-detect best chart type"),children:[e.jsx(pe.NiceIcon,{name:"zap",size:14})," ",C("chartAI.auto","Auto")]}),h&&e.jsxs("button",{type:"button",className:"nice-chart-ai__insights-btn",onClick:()=>{N.length||m(),y(!o)},disabled:J,title:C("chartAI.showInsights","Show data insights"),children:[e.jsx(pe.NiceIcon,{name:"lightbulb",size:14})," ",C("chartAI.insights","Insights")]})]})]}),e.jsx("div",{className:"nice-chart-ai__chart-wrapper",children:e.jsx(Ye,{series:K,categories:A,...g})}),o&&N.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(pe.NiceIcon,{name:"lightbulb",size:14})," ",C("chartAI.dataInsights","Data Insights")]}),e.jsx("button",{type:"button",className:"nice-chart-ai__insights-close",onClick:()=>y(!1),"aria-label":C("chartAI.close","Close"),children:e.jsx(pe.NiceIcon,{name:"close",size:14})})]}),e.jsx("ul",{className:"nice-chart-ai__insights-list",children:N.map((w,Y)=>e.jsxs("li",{className:"nice-chart-ai__insight",children:[e.jsx("span",{className:"nice-chart-ai__insight-icon",children:"•"}),w]},Y))}),e.jsx("div",{className:"nice-chart-ai__insights-footer",children:e.jsxs("button",{type:"button",className:"nice-chart-ai__refresh",onClick:()=>m(),disabled:J,children:[e.jsx(pe.NiceIcon,{name:"refresh",size:14})," ",C("chartAI.refresh","Refresh")]})})]}),o&&J&&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"}),C("chartAI.generatingInsights","Generating insights...")]})})]})});exports.CHART_COLORS=Se;exports.NiceAdvancedCharts=nn;exports.NiceBarGauge=Lt;exports.NiceBullet=Ft;exports.NiceChart=Ye;exports.NiceChart$1=Rt;exports.NiceChartAI=En;exports.NiceChartRangeSelector=jn;exports.NiceCircularGauge=At;exports.NiceDrillDownChart=dt;exports.NiceForecastChart=kn;exports.NiceFunnel=Wt;exports.NiceHeatMap=Vt;exports.NiceLinearGauge=It;exports.NiceLiveChart=Cn;exports.NiceMapChart=ht;exports.NiceOrganizationChart=pn;exports.NicePieChart=Ut;exports.NicePolarChart=wn;exports.NiceRealtimeChart=ut;exports.NiceSankey=lt;exports.NiceSankey$1=Kt;exports.NiceSparkline=vn;exports.NiceStockChart=gn;exports.NiceTreeMap=ft;exports.autoDetectColumns=un;exports.createMockLiveChartSource=Tn;exports.createSignalRLiveChartSource=Rn;exports.createWebSocketLiveChartSource=An;exports.downloadBlob=Be;exports.downloadCSV=pt;exports.downloadHTML=jt;exports.downloadJSON=_t;exports.downloadPDF=vt;exports.downloadXLSX=gt;exports.exportToCSV=mt;exports.exportToHTML=wt;exports.exportToJSON=bt;exports.exportToPDF=yt;exports.exportToXLSX=xt;exports.niceExport=hn;exports.orgChartToPng=Mt;exports.orgChartToSvg=Je;exports.tidyTreeLayout=$t;