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