@object-ui/plugin-charts 17.7.0 → 18.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
- (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@object-ui/core"),require("react"),require("@object-ui/components"),require("@object-ui/i18n"),require("react/jsx-runtime"),require("recharts"),require("@object-ui/react"),require("lucide-react")):typeof define==`function`&&define.amd?define([`exports`,`@object-ui/core`,`react`,`@object-ui/components`,`@object-ui/i18n`,`react/jsx-runtime`,`recharts`,`@object-ui/react`,`lucide-react`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.ObjectUIPluginCharts={},e.ObjectUICore,e.React,e.ObjectUIComponents,e._object_ui_i18n,e.react_jsx_runtime,e.recharts,e.ObjectUIReact,e.lucide_react))})(this,function(e,t,n,r,i,a,o,s,c){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var l=Object.create,u=Object.defineProperty,d=Object.getOwnPropertyDescriptor,f=Object.getOwnPropertyNames,p=Object.getPrototypeOf,m=Object.prototype.hasOwnProperty,h=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(e){throw n=[e],e}},g=(e,t)=>{let n={};for(var r in e)u(n,r,{get:e[r],enumerable:!0});return t||u(n,Symbol.toStringTag,{value:`Module`}),n},_=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=f(t),a=0,o=i.length,s;a<o;a++)s=i[a],!m.call(e,s)&&s!==n&&u(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=d(t,s))||r.enumerable});return e};n=((e,t,n)=>(n=e==null?{}:l(p(e)),_(t||!e||!e.__esModule||!m.call(e,`default`)?u(n,`default`,{value:e,enumerable:!0}):n,e)))(n,1);function ee(e){if(!e)return;let t=e.startsWith(w)?e.slice(14):e;return C.get(t)}function v(e,t){if(typeof e==`string`||T(e))return(0,i.pickLocalized)(e,t)||void 0}function te(e,t){if(!T(e))return;let n={},r=E(e.field);r&&(n.field=r);let i=E(e.format);i&&(n.format=i);let a=D(e.min);a!==void 0&&(n.min=a);let o=D(e.max);o!==void 0&&(n.max=o);let s=D(e.stepSize);s!==void 0&&s>0&&(n.stepSize=s),typeof e.showGridLines==`boolean`&&(n.showGridLines=e.showGridLines),typeof e.logarithmic==`boolean`&&(n.logarithmic=e.logarithmic);let c=E(e.position);(c===`left`||c===`right`||c===`top`||c===`bottom`)&&(n.position=c);let l=v(e.title,t);return l&&(n.title=l),n}function ne(e,t){if(!T(e)){let t=E(e);return t?{dataKey:t}:void 0}let n=E(e.dataKey)??E(e.name);if(!n)return;let r={dataKey:n},i=v(e.label,t);i&&(r.label=i);let a=E(e.chartType)??E(e.type);(a===`bar`||a===`line`||a===`area`)&&(r.chartType=a);let o=E(e.variant);(o===`comparison`||o===`current`||o===`primary`)&&(r.variant=o);let s=D(e.opacity);s!==void 0&&(r.opacity=s);let c=E(e.dashArray);c&&(r.dashArray=c);let l=E(e.stack);l&&(r.stack=l);let u=E(e.yAxis);(u===`left`||u===`right`)&&(r.yAxis=u);let d=E(e.color);return d&&(r.color=d),r}function re(e,t){let n=t===`horizontal-bar`,r=t===`scatter`?1:2,i=(e??[]).slice(0,r),a=[],o=e=>n?e===`bottom`?`left`:e===`top`?`right`:void 0:e===`left`||e===`right`?e:void 0,s=e=>e===`left`?`right`:`left`,c=i.map(e=>o(e.position)),l=[];if(i.length===1)l.push(c[0]??`left`);else if(i.length===2){let[e,t]=c;e&&t?l.push(e,e===t?s(e):t):e?l.push(e,s(e)):t?l.push(s(t),t):l.push(`left`,`right`)}i.forEach((e,t)=>{e.position&&(c[t]?c[t]!==l[t]&&a.push({index:t,position:e.position,reason:`taken`,drawn:l[t]}):a.push({index:t,position:e.position,reason:`side`,drawn:l[t]}))});let u=r===1?l[0]:`right`,d={slotOf:l,notes:a,undrawn:(e??[]).slice(i.length).map((e,t)=>({index:i.length+t,boundTo:u}))};return l.forEach((e,t)=>{d[e]=t}),d}function ie(e,t){if(!T(e))return{};let n={},r=E(e.type),i=E(e.chartType)??E(e.specType)??(r&&le.has(r)?r:void 0)??ee(r);i&&(n.chartType=i);let a=e.xAxis,o=te(a,t);o&&Object.keys(o).some(e=>e!==`field`)&&(n.xAxis=o);let s=E(e.xAxisKey)??o?.field??E(a);s&&(n.xAxisKey=s);let c=(Array.isArray(e.yAxis)?e.yAxis:e.yAxis===void 0?[]:[e.yAxis]).map(e=>te(e,t)??(E(e)?{field:E(e)}:void 0)).filter(e=>!!e);c.length&&(n.yAxes=c);let l=(Array.isArray(e.series)?e.series:Array.isArray(e.categories)?e.categories:void 0)?.map(e=>ne(e,t)).filter(e=>!!e);if(!l?.length){let e=re(c,i),t=[...e.slotOf,...e.undrawn.map(e=>e.boundTo)],n=c.map((e,n)=>({a:e,slot:t[n],i:n})).filter(({a:e})=>e.field).map(({a:e,slot:t,i:n})=>({dataKey:e.field,...e.title?{label:e.title}:{},...t===`right`||n>0?{yAxis:t}:{}}));n.length&&(l=n)}l?.length&&(n.series=l),typeof e.showLegend==`boolean`&&(n.showLegend=e.showLegend),typeof e.showDataLabels==`boolean`&&(n.showDataLabels=e.showDataLabels);let u=v(e.title,t);u&&(n.title=u);let d=v(e.subtitle,t);d&&(n.subtitle=d);let f=v(e.description,t);f&&(n.description=f);let p=D(e.height);return p!==void 0&&p>0&&(n.height=p),Array.isArray(e.annotations)&&e.annotations.length&&(n.annotations=e.annotations.filter(T)),T(e.interaction)&&(n.interaction=e.interaction),n}function ae(e){if(e===`bar`||e===`column`)return`bar`;if(e===`line`)return`line`;if(e===`area`)return`area`}function oe(e,t){if(e===`combo`)return`combo`;let n=ae(e);if(!n||!t||t.length<2)return e;let r=t.map(e=>e.chartType??n);return new Set(r).size>1?`combo`:e}function y(e,t){if(!e)return;let n=e.includes(`%`),r=/^([$£€¥₹])/.exec(e),i=e.includes(`,`),a=/\.(0+)/.exec(e)?.[1].length??0,o={$:`USD`,"£":`GBP`,"€":`EUR`,"¥":`CNY`,"₹":`INR`};if(!n&&!r&&!i&&a===0)return;let s={minimumFractionDigits:a,maximumFractionDigits:a,useGrouping:i};return n?s.style=`percent`:r&&(s.style=`currency`,s.currency=o[r[1]]??`USD`),e=>{let n=typeof e==`number`?e:Number(e);if(!Number.isFinite(n))return e==null?``:String(e);try{return new Intl.NumberFormat(t,s).format(n)}catch{return String(n)}}}function b(e,t){let n=e?.stepSize;if(!n||n<=0)return;let r=t.filter(e=>Number.isFinite(e)),i=r.length?Math.min(...r):void 0,a=r.length?Math.max(...r):void 0,o=e.min??Math.min(0,i??0),s=e.max??a;if(s===void 0||!Number.isFinite(o)||!Number.isFinite(s)||s<o)return;let c=Math.floor(o/n)*n,l=e.max===void 0?Math.ceil(s/n)*n:e.max,u=Math.floor((l-c)/n+1e-9)+1;if(u<1||u>O)return;let d=[];for(let e=0;e<u;e++)d.push(Number((c+e*n).toPrecision(12)));return e.max!==void 0&&d[d.length-1]<e.max&&d.push(e.max),d}function x(e){if(!e)return;let{min:t,max:n}=e;if(t!==void 0||n!==void 0)return[t??`auto`,n??`auto`]}var se,ce,S,le,C,w,T,E,D,O,k=h((()=>{se=new Set([`bar`,`column`,`horizontal-bar`,`line`,`area`,`pie`,`donut`,`funnel`,`radar`,`scatter`,`treemap`,`sankey`,`combo`]),ce=new Set([`gauge`,`solid-gauge`,`metric`,`kpi`,`bullet`]),S=new Set([`table`,`pivot`]),le=new Set([...se,...ce,...S]),C=new Map([[`chart:bar`,`bar`]]),w=`plugin-charts:`,T=e=>!!e&&typeof e==`object`&&!Array.isArray(e),E=e=>typeof e==`string`&&e?e:void 0,D=e=>typeof e==`number`&&Number.isFinite(e)?e:void 0,O=200})),A=g({default:()=>de});function ue(e,t=14){return e.length>t?`${e.slice(0,t-1)}…`:e}function j({x:e,y:t,payload:n}){let r=String(n?.value??``),i=ue(r);return(0,a.jsx)(`g`,{transform:`translate(${e},${t})`,children:(0,a.jsxs)(`text`,{dy:10,textAnchor:`end`,transform:`rotate(-32)`,fill:`hsl(var(--muted-foreground))`,fontSize:11,fontFamily:`monospace`,children:[r!==i&&(0,a.jsx)(`title`,{children:r}),i]})})}function de({data:e=[],dataKey:t=`value`,xAxisKey:n=`name`,height:r=400,className:i=``,color:s=`hsl(var(--primary))`}){let c=e.map(e=>String(e?.[n]??``)),l=c.length>4||c.some(e=>e.length>8);return(0,a.jsx)(`div`,{className:`p-2 sm:p-3 md:p-4 rounded-xl border border-border bg-card/40 backdrop-blur-sm shadow-lg shadow-background/5 ${i}`,children:(0,a.jsx)(o.ResponsiveContainer,{width:`100%`,height:r,children:(0,a.jsxs)(o.BarChart,{data:e,margin:{top:10,right:10,left:10,bottom:l?24:5},children:[(0,a.jsxs)(`defs`,{children:[(0,a.jsxs)(`linearGradient`,{id:`barGradient`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,a.jsx)(`stop`,{offset:`0%`,stopColor:s,stopOpacity:1}),(0,a.jsx)(`stop`,{offset:`90%`,stopColor:s,stopOpacity:.6}),(0,a.jsx)(`stop`,{offset:`100%`,stopColor:s,stopOpacity:.3})]}),(0,a.jsxs)(`filter`,{id:`glow`,height:`130%`,children:[(0,a.jsx)(`feGaussianBlur`,{in:`SourceAlpha`,stdDeviation:`3`,result:`blur`}),(0,a.jsx)(`feOffset`,{in:`blur`,dx:`0`,dy:`0`,result:`offsetBlur`}),(0,a.jsx)(`feFlood`,{floodColor:s,floodOpacity:`0.5`,result:`offsetColor`}),(0,a.jsx)(`feComposite`,{in:`offsetColor`,in2:`offsetBlur`,operator:`in`,result:`offsetBlur`}),(0,a.jsxs)(`feMerge`,{children:[(0,a.jsx)(`feMergeNode`,{in:`offsetBlur`}),(0,a.jsx)(`feMergeNode`,{in:`SourceGraphic`})]})]})]}),(0,a.jsx)(o.CartesianGrid,{strokeDasharray:`3 3`,stroke:`hsl(var(--border))`,vertical:!1}),(0,a.jsx)(o.XAxis,{dataKey:n,tick:l?(0,a.jsx)(j,{}):{fill:`hsl(var(--muted-foreground))`,fontSize:12,fontFamily:`monospace`},tickLine:!1,axisLine:{stroke:`hsl(var(--border))`},interval:0,height:l?56:void 0,dy:l?void 0:10}),(0,a.jsx)(o.YAxis,{tick:{fill:`hsl(var(--muted-foreground))`,fontSize:12,fontFamily:`monospace`},tickLine:!1,axisLine:!1}),(0,a.jsx)(o.Tooltip,{cursor:{fill:`hsl(var(--muted))`,opacity:.2},contentStyle:{backgroundColor:`hsl(var(--popover))`,borderColor:`hsl(var(--border))`,color:`hsl(var(--popover-foreground))`,borderRadius:`8px`,fontFamily:`monospace`,boxShadow:`0 4px 6px -1px rgb(0 0 0 / 0.1)`},itemStyle:{color:`hsl(var(--primary))`}}),(0,a.jsx)(o.Legend,{wrapperStyle:{paddingTop:`20px`,fontFamily:`monospace`}}),(0,a.jsx)(o.Bar,{dataKey:t,fill:`url(#barGradient)`,radius:[4,4,0,0],filter:`url(#glow)`,animationDuration:1500})]})})})}var fe=h((()=>{}));function pe(){let e=n.useContext(me);if(!e)throw Error(`useChart must be used within a <ChartContainer />`);return e}function M({id:e,className:t,children:r,config:i,disableSettleRemount:s,style:c,...l}){let u=n.useId(),d=`chart-${e||u.replace(/:/g,``)}`,f=n.useRef(null),[p,m]=n.useState(0);n.useEffect(()=>{if(s)return;let e=f.current;if(e==null||typeof ResizeObserver>`u`)return;let t=!1,n,r=new ResizeObserver(e=>{if(t)return;let i=e[0]?.contentRect;i==null||i.width<=0||i.height<=0||(n!=null&&clearTimeout(n),n=setTimeout(()=>{t=!0,r.disconnect(),m(e=>e+1)},80))});return r.observe(e),()=>{t=!0,n!=null&&clearTimeout(n),r.disconnect()}},[s]);let h=c?.height!=null||c?.minHeight!=null,g=c?.width!=null||c?.minWidth!=null,_={...h?{}:{minHeight:he},...g?{}:{minWidth:0},...c};return(0,a.jsx)(me.Provider,{value:{config:i},children:(0,a.jsxs)(`div`,{ref:f,"data-slot":`chart`,"data-chart":d,className:I(`block w-full h-[350px] text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground`,t),style:_,...l,children:[(0,a.jsx)(R,{id:d,config:i}),(0,a.jsx)(o.ResponsiveContainer,{width:`100%`,height:`100%`,...h?{}:{minHeight:he},children:r},p)]})})}function N({active:e,payload:t,className:r,indicator:o=`dot`,hideLabel:s=!1,hideIndicator:c=!1,label:l,labelFormatter:u,labelClassName:d,formatter:f,color:p,nameKey:m,labelKey:h}){let{config:g}=pe(),_=(0,i.useDisplayLocale)(),ee=n.useMemo(()=>{if(s||!t?.length)return null;let[e]=t,n=`${h||e?.dataKey||e?.name||`value`}`,r=F(g,e,n),i=!h&&typeof l==`string`?g[l]?.label||l:r?.label;return u?(0,a.jsx)(`div`,{className:I(`font-medium`,d),children:u(i,t)}):i?(0,a.jsx)(`div`,{className:I(`font-medium`,d),children:i}):null},[l,u,t,s,d,g,h]);if(!e||!t?.length)return null;let v=t.length===1&&o!==`dot`;return(0,a.jsxs)(`div`,{className:I(`border-border/50 bg-background grid min-w-[8rem] items-start gap-1.5 rounded-lg border px-2.5 py-1.5 text-xs shadow-xl`,r),children:[v?null:ee,(0,a.jsx)(`div`,{className:`grid gap-1.5`,children:t.filter(e=>e.type!==`none`).map((e,t)=>{let n=`${m||e.name||e.dataKey||`value`}`,r=F(g,e,n),i=p||e.payload.fill||e.color;return(0,a.jsx)(`div`,{className:I(`[&>svg]:text-muted-foreground flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5`,o===`dot`?`items-center`:``),children:f&&e?.value!==void 0&&e.name?f(e.value,e.name,e,t,e.payload):(0,a.jsxs)(a.Fragment,{children:[r?.icon?(0,a.jsx)(r.icon,{}):!c&&(0,a.jsx)(`div`,{className:I(`shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)`,o===`dot`?`h-2.5 w-2.5`:``,o===`line`?`w-1`:``,o===`dashed`?`w-0 border-[1.5px] border-dashed bg-transparent`:``,v&&o===`dashed`?`my-0.5`:``),style:{"--color-bg":i,"--color-border":i}}),(0,a.jsxs)(`div`,{className:I(`flex flex-1 justify-between leading-none`,v?`items-end`:`items-center`),children:[(0,a.jsxs)(`div`,{className:`grid gap-1.5`,children:[v?ee:null,(0,a.jsx)(`span`,{className:`text-muted-foreground`,children:r?.label||e.name})]}),e.value&&(0,a.jsx)(`span`,{className:`text-foreground font-mono font-medium tabular-nums`,children:e.value.toLocaleString(_)})]})]})},e.dataKey)})})]})}function P({className:e,hideIcon:t=!1,payload:n,verticalAlign:r=`bottom`,nameKey:i}){let{config:o}=pe();return n?.length?(0,a.jsx)(`div`,{className:I(`flex items-center justify-center gap-4`,r===`top`?`pb-3`:`pt-3`,e),children:n.filter(e=>e.type!==`none`).map(e=>{let n=`${i||e.dataKey||`value`}`,r=F(o,e,n);return(0,a.jsxs)(`div`,{className:I(`[&>svg]:text-muted-foreground flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3`),children:[r?.icon&&!t?(0,a.jsx)(r.icon,{}):(0,a.jsx)(`div`,{className:`h-2 w-2 shrink-0 rounded-[2px] bg-(--color-bg)`,style:{"--color-bg":e.color}}),r?.label??e.value]},e.value)})}):null}function F(e,t,n){if(typeof t!=`object`||!t)return;let r=`payload`in t&&typeof t.payload==`object`&&t.payload!==null?t.payload:void 0,i=n;return r&&n in r&&typeof r[n]==`string`?i=r[n]:n in t&&typeof t[n]==`string`&&(i=t[n]),i in e?e[i]:e[n]}var I,L,me,he,R,z,B,ge=h((()=>{I=(...e)=>e.filter(Boolean).join(` `),L={light:``,dark:`.dark`},me=n.createContext(null),he=280,R=({id:e,config:t})=>{let n=Object.entries(t).filter(([,e])=>e.theme||e.color);return n.length?(0,a.jsx)(`style`,{dangerouslySetInnerHTML:{__html:Object.entries(L).map(([t,r])=>`
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@object-ui/core"),require("react"),require("@object-ui/components"),require("@object-ui/i18n"),require("react/jsx-runtime"),require("recharts"),require("@object-ui/react"),require("lucide-react")):typeof define==`function`&&define.amd?define([`exports`,`@object-ui/core`,`react`,`@object-ui/components`,`@object-ui/i18n`,`react/jsx-runtime`,`recharts`,`@object-ui/react`,`lucide-react`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.ObjectUIPluginCharts={},e.ObjectUICore,e.React,e.ObjectUIComponents,e._object_ui_i18n,e.react_jsx_runtime,e.recharts,e.ObjectUIReact,e.lucide_react))})(this,function(e,t,n,r,i,a,o,s,c){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var l=Object.create,u=Object.defineProperty,d=Object.getOwnPropertyDescriptor,f=Object.getOwnPropertyNames,p=Object.getPrototypeOf,m=Object.prototype.hasOwnProperty,h=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(e){throw n=[e],e}},g=(e,t)=>{let n={};for(var r in e)u(n,r,{get:e[r],enumerable:!0});return t||u(n,Symbol.toStringTag,{value:`Module`}),n},_=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=f(t),a=0,o=i.length,s;a<o;a++)s=i[a],!m.call(e,s)&&s!==n&&u(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=d(t,s))||r.enumerable});return e};n=((e,t,n)=>(n=e==null?{}:l(p(e)),_(t||!e||!e.__esModule||!m.call(e,`default`)?u(n,`default`,{value:e,enumerable:!0}):n,e)))(n,1);function ee(e){if(!e)return;let t=e.startsWith(C)?e.slice(14):e;return de.get(t)}function te(e){return e.length>0&&e.every(e=>(0,t.isIntegerAggregate)(e.aggregate))}function ne(e,t){if(typeof e==`string`||w(e))return(0,i.pickLocalized)(e,t)||void 0}function re(e,t){if(!w(e))return;let n={},r=T(e.field);r&&(n.field=r);let i=T(e.format);i&&(n.format=i);let a=E(e.min);a!==void 0&&(n.min=a);let o=E(e.max);o!==void 0&&(n.max=o);let s=E(e.stepSize);s!==void 0&&s>0&&(n.stepSize=s),typeof e.showGridLines==`boolean`&&(n.showGridLines=e.showGridLines),typeof e.logarithmic==`boolean`&&(n.logarithmic=e.logarithmic);let c=T(e.position);(c===`left`||c===`right`||c===`top`||c===`bottom`)&&(n.position=c);let l=ne(e.title,t);return l&&(n.title=l),n}function ie(e,t){if(!w(e)){let t=T(e);return t?{dataKey:t}:void 0}let n=T(e.dataKey)??T(e.name);if(!n)return;let r={dataKey:n},i=ne(e.label,t);i&&(r.label=i);let a=T(e.chartType)??T(e.type);(a===`bar`||a===`line`||a===`area`)&&(r.chartType=a);let o=T(e.variant);(o===`comparison`||o===`current`||o===`primary`)&&(r.variant=o);let s=E(e.opacity);s!==void 0&&(r.opacity=s);let c=T(e.dashArray);c&&(r.dashArray=c);let l=T(e.stack);l&&(r.stack=l);let u=T(e.yAxis);(u===`left`||u===`right`)&&(r.yAxis=u);let d=T(e.color);d&&(r.color=d);let f=T(e.aggregate);return f&&(r.aggregate=f),r}function ae(e,t){let n=t===`horizontal-bar`,r=t===`scatter`?1:2,i=(e??[]).slice(0,r),a=[],o=e=>n?e===`bottom`?`left`:e===`top`?`right`:void 0:e===`left`||e===`right`?e:void 0,s=e=>e===`left`?`right`:`left`,c=i.map(e=>o(e.position)),l=[];if(i.length===1)l.push(c[0]??`left`);else if(i.length===2){let[e,t]=c;e&&t?l.push(e,e===t?s(e):t):e?l.push(e,s(e)):t?l.push(s(t),t):l.push(`left`,`right`)}i.forEach((e,t)=>{e.position&&(c[t]?c[t]!==l[t]&&a.push({index:t,position:e.position,reason:`taken`,drawn:l[t]}):a.push({index:t,position:e.position,reason:`side`,drawn:l[t]}))});let u=r===1?l[0]:`right`,d={slotOf:l,notes:a,undrawn:(e??[]).slice(i.length).map((e,t)=>({index:i.length+t,boundTo:u}))};return l.forEach((e,t)=>{d[e]=t}),d}function oe(e,t){if(!w(e))return{};let n={},r=T(e.type),i=T(e.chartType)??T(e.specType)??(r&&S.has(r)?r:void 0)??ee(r);i&&(n.chartType=i);let a=e.xAxis,o=re(a,t);o&&Object.keys(o).some(e=>e!==`field`)&&(n.xAxis=o);let s=T(e.xAxisKey)??o?.field??T(a);s&&(n.xAxisKey=s);let c=(Array.isArray(e.yAxis)?e.yAxis:e.yAxis===void 0?[]:[e.yAxis]).map(e=>re(e,t)??(T(e)?{field:T(e)}:void 0)).filter(e=>!!e);c.length&&(n.yAxes=c);let l=(Array.isArray(e.series)?e.series:Array.isArray(e.categories)?e.categories:void 0)?.map(e=>ie(e,t)).filter(e=>!!e);if(!l?.length){let e=ae(c,i),t=[...e.slotOf,...e.undrawn.map(e=>e.boundTo)],n=c.map((e,n)=>({a:e,slot:t[n],i:n})).filter(({a:e})=>e.field).map(({a:e,slot:t,i:n})=>({dataKey:e.field,...e.title?{label:e.title}:{},...t===`right`||n>0?{yAxis:t}:{}}));n.length&&(l=n)}l?.length&&(n.series=l),typeof e.showLegend==`boolean`&&(n.showLegend=e.showLegend),typeof e.showDataLabels==`boolean`&&(n.showDataLabels=e.showDataLabels);let u=ne(e.title,t);u&&(n.title=u);let d=ne(e.subtitle,t);d&&(n.subtitle=d);let f=ne(e.description,t);f&&(n.description=f);let p=E(e.height);return p!==void 0&&p>0&&(n.height=p),Array.isArray(e.annotations)&&e.annotations.length&&(n.annotations=e.annotations.filter(w)),w(e.interaction)&&(n.interaction=e.interaction),n}function se(e){if(e===`bar`||e===`column`)return`bar`;if(e===`line`)return`line`;if(e===`area`)return`area`}function v(e,t){if(e===`combo`)return`combo`;let n=se(e);if(!n||!t||t.length<2)return e;let r=t.map(e=>e.chartType??n);return new Set(r).size>1?`combo`:e}function y(e,t){if(!e)return;let n=e.includes(`%`),r=/^([$£€¥₹])/.exec(e),i=e.includes(`,`),a=/\.(0+)/.exec(e)?.[1].length??0,o={$:`USD`,"£":`GBP`,"€":`EUR`,"¥":`CNY`,"₹":`INR`};if(!n&&!r&&!i&&a===0)return;let s={minimumFractionDigits:a,maximumFractionDigits:a,useGrouping:i};return n?s.style=`percent`:r&&(s.style=`currency`,s.currency=o[r[1]]??`USD`),e=>{let n=typeof e==`number`?e:Number(e);if(!Number.isFinite(n))return e==null?``:String(e);try{return new Intl.NumberFormat(t,s).format(n)}catch{return String(n)}}}function ce(e,t){let n=e?.stepSize;if(!n||n<=0)return;let r=t.filter(e=>Number.isFinite(e)),i=r.length?Math.min(...r):void 0,a=r.length?Math.max(...r):void 0,o=e.min??Math.min(0,i??0),s=e.max??a;if(s===void 0||!Number.isFinite(o)||!Number.isFinite(s)||s<o)return;let c=Math.floor(o/n)*n,l=e.max===void 0?Math.ceil(s/n)*n:e.max,u=Math.floor((l-c)/n+1e-9)+1;if(u<1||u>D)return;let d=[];for(let e=0;e<u;e++)d.push(Number((c+e*n).toPrecision(12)));return e.max!==void 0&&d[d.length-1]<e.max&&d.push(e.max),d}function b(e){if(!e)return;let{min:t,max:n}=e;if(t!==void 0||n!==void 0)return[t??`auto`,n??`auto`]}var le,x,ue,S,de,C,w,T,E,D,O=h((()=>{le=new Set([`bar`,`column`,`horizontal-bar`,`line`,`area`,`pie`,`donut`,`funnel`,`radar`,`scatter`,`treemap`,`sankey`,`combo`]),x=new Set([`gauge`,`solid-gauge`,`metric`,`kpi`,`bullet`]),ue=new Set([`table`,`pivot`]),S=new Set([...le,...x,...ue]),de=new Map([[`chart:bar`,`bar`]]),C=`plugin-charts:`,w=e=>!!e&&typeof e==`object`&&!Array.isArray(e),T=e=>typeof e==`string`&&e?e:void 0,E=e=>typeof e==`number`&&Number.isFinite(e)?e:void 0,D=200})),k=g({default:()=>me});function fe(e,t=14){return e.length>t?`${e.slice(0,t-1)}…`:e}function pe({x:e,y:t,payload:n}){let r=String(n?.value??``),i=fe(r);return(0,a.jsx)(`g`,{transform:`translate(${e},${t})`,children:(0,a.jsxs)(`text`,{dy:10,textAnchor:`end`,transform:`rotate(-32)`,fill:`hsl(var(--muted-foreground))`,fontSize:11,fontFamily:`monospace`,children:[r!==i&&(0,a.jsx)(`title`,{children:r}),i]})})}function me({data:e=[],dataKey:t=`value`,xAxisKey:n=`name`,height:r=400,className:i=``,color:s=`hsl(var(--primary))`}){let c=e.map(e=>String(e?.[n]??``)),l=c.length>4||c.some(e=>e.length>8);return(0,a.jsx)(`div`,{className:`p-2 sm:p-3 md:p-4 rounded-xl border border-border bg-card/40 backdrop-blur-sm shadow-lg shadow-background/5 ${i}`,children:(0,a.jsx)(o.ResponsiveContainer,{width:`100%`,height:r,children:(0,a.jsxs)(o.BarChart,{data:e,margin:{top:10,right:10,left:10,bottom:l?24:5},children:[(0,a.jsxs)(`defs`,{children:[(0,a.jsxs)(`linearGradient`,{id:`barGradient`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,a.jsx)(`stop`,{offset:`0%`,stopColor:s,stopOpacity:1}),(0,a.jsx)(`stop`,{offset:`90%`,stopColor:s,stopOpacity:.6}),(0,a.jsx)(`stop`,{offset:`100%`,stopColor:s,stopOpacity:.3})]}),(0,a.jsxs)(`filter`,{id:`glow`,height:`130%`,children:[(0,a.jsx)(`feGaussianBlur`,{in:`SourceAlpha`,stdDeviation:`3`,result:`blur`}),(0,a.jsx)(`feOffset`,{in:`blur`,dx:`0`,dy:`0`,result:`offsetBlur`}),(0,a.jsx)(`feFlood`,{floodColor:s,floodOpacity:`0.5`,result:`offsetColor`}),(0,a.jsx)(`feComposite`,{in:`offsetColor`,in2:`offsetBlur`,operator:`in`,result:`offsetBlur`}),(0,a.jsxs)(`feMerge`,{children:[(0,a.jsx)(`feMergeNode`,{in:`offsetBlur`}),(0,a.jsx)(`feMergeNode`,{in:`SourceGraphic`})]})]})]}),(0,a.jsx)(o.CartesianGrid,{strokeDasharray:`3 3`,stroke:`hsl(var(--border))`,vertical:!1}),(0,a.jsx)(o.XAxis,{dataKey:n,tick:l?(0,a.jsx)(pe,{}):{fill:`hsl(var(--muted-foreground))`,fontSize:12,fontFamily:`monospace`},tickLine:!1,axisLine:{stroke:`hsl(var(--border))`},interval:0,height:l?56:void 0,dy:l?void 0:10}),(0,a.jsx)(o.YAxis,{tick:{fill:`hsl(var(--muted-foreground))`,fontSize:12,fontFamily:`monospace`},tickLine:!1,axisLine:!1}),(0,a.jsx)(o.Tooltip,{cursor:{fill:`hsl(var(--muted))`,opacity:.2},contentStyle:{backgroundColor:`hsl(var(--popover))`,borderColor:`hsl(var(--border))`,color:`hsl(var(--popover-foreground))`,borderRadius:`8px`,fontFamily:`monospace`,boxShadow:`0 4px 6px -1px rgb(0 0 0 / 0.1)`},itemStyle:{color:`hsl(var(--primary))`}}),(0,a.jsx)(o.Legend,{wrapperStyle:{paddingTop:`20px`,fontFamily:`monospace`}}),(0,a.jsx)(o.Bar,{dataKey:t,fill:`url(#barGradient)`,radius:[4,4,0,0],filter:`url(#glow)`,animationDuration:1500})]})})})}var he=h((()=>{}));function ge(){let e=n.useContext(F);if(!e)throw Error(`useChart must be used within a <ChartContainer />`);return e}function A({id:e,className:t,children:r,config:i,disableSettleRemount:s,style:c,...l}){let u=n.useId(),d=`chart-${e||u.replace(/:/g,``)}`,f=n.useRef(null),[p,m]=n.useState(0);n.useEffect(()=>{if(s)return;let e=f.current;if(e==null||typeof ResizeObserver>`u`)return;let t=!1,n,r=new ResizeObserver(e=>{if(t)return;let i=e[0]?.contentRect;i==null||i.width<=0||i.height<=0||(n!=null&&clearTimeout(n),n=setTimeout(()=>{t=!0,r.disconnect(),m(e=>e+1)},80))});return r.observe(e),()=>{t=!0,n!=null&&clearTimeout(n),r.disconnect()}},[s]);let h=c?.height!=null||c?.minHeight!=null,g=c?.width!=null||c?.minWidth!=null,_={...h?{}:{minHeight:I},...g?{}:{minWidth:0},...c};return(0,a.jsx)(F.Provider,{value:{config:i},children:(0,a.jsxs)(`div`,{ref:f,"data-slot":`chart`,"data-chart":d,className:N(`block w-full h-[350px] text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground`,t),style:_,...l,children:[(0,a.jsx)(ve,{id:d,config:i}),(0,a.jsx)(o.ResponsiveContainer,{width:`100%`,height:`100%`,...h?{}:{minHeight:I},children:r},p)]})})}function j({active:e,payload:t,className:r,indicator:o=`dot`,hideLabel:s=!1,hideIndicator:c=!1,label:l,labelFormatter:u,labelClassName:d,formatter:f,color:p,nameKey:m,labelKey:h}){let{config:g}=ge(),_=(0,i.useDisplayLocale)(),ee=n.useMemo(()=>{if(s||!t?.length)return null;let[e]=t,n=`${h||e?.dataKey||e?.name||`value`}`,r=M(g,e,n),i=!h&&typeof l==`string`?g[l]?.label||l:r?.label;return u?(0,a.jsx)(`div`,{className:N(`font-medium`,d),children:u(i,t)}):i?(0,a.jsx)(`div`,{className:N(`font-medium`,d),children:i}):null},[l,u,t,s,d,g,h]);if(!e||!t?.length)return null;let te=t.length===1&&o!==`dot`;return(0,a.jsxs)(`div`,{className:N(`border-border/50 bg-background grid min-w-[8rem] items-start gap-1.5 rounded-lg border px-2.5 py-1.5 text-xs shadow-xl`,r),children:[te?null:ee,(0,a.jsx)(`div`,{className:`grid gap-1.5`,children:t.filter(e=>e.type!==`none`).map((e,t)=>{let n=`${m||e.name||e.dataKey||`value`}`,r=M(g,e,n),i=p||e.payload.fill||e.color;return(0,a.jsx)(`div`,{className:N(`[&>svg]:text-muted-foreground flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5`,o===`dot`?`items-center`:``),children:f&&e?.value!==void 0&&e.name?f(e.value,e.name,e,t,e.payload):(0,a.jsxs)(a.Fragment,{children:[r?.icon?(0,a.jsx)(r.icon,{}):!c&&(0,a.jsx)(`div`,{className:N(`shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)`,o===`dot`?`h-2.5 w-2.5`:``,o===`line`?`w-1`:``,o===`dashed`?`w-0 border-[1.5px] border-dashed bg-transparent`:``,te&&o===`dashed`?`my-0.5`:``),style:{"--color-bg":i,"--color-border":i}}),(0,a.jsxs)(`div`,{className:N(`flex flex-1 justify-between leading-none`,te?`items-end`:`items-center`),children:[(0,a.jsxs)(`div`,{className:`grid gap-1.5`,children:[te?ee:null,(0,a.jsx)(`span`,{className:`text-muted-foreground`,children:r?.label||e.name})]}),e.value&&(0,a.jsx)(`span`,{className:`text-foreground font-mono font-medium tabular-nums`,children:e.value.toLocaleString(_)})]})]})},e.dataKey)})})]})}function _e({className:e,hideIcon:t=!1,payload:n,verticalAlign:r=`bottom`,nameKey:i}){let{config:o}=ge();return n?.length?(0,a.jsx)(`div`,{className:N(`flex items-center justify-center gap-4`,r===`top`?`pb-3`:`pt-3`,e),children:n.filter(e=>e.type!==`none`).map(e=>{let n=`${i||e.dataKey||`value`}`,r=M(o,e,n);return(0,a.jsxs)(`div`,{className:N(`[&>svg]:text-muted-foreground flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3`),children:[r?.icon&&!t?(0,a.jsx)(r.icon,{}):(0,a.jsx)(`div`,{className:`h-2 w-2 shrink-0 rounded-[2px] bg-(--color-bg)`,style:{"--color-bg":e.color}}),r?.label??e.value]},e.value)})}):null}function M(e,t,n){if(typeof t!=`object`||!t)return;let r=`payload`in t&&typeof t.payload==`object`&&t.payload!==null?t.payload:void 0,i=n;return r&&n in r&&typeof r[n]==`string`?i=r[n]:n in t&&typeof t[n]==`string`&&(i=t[n]),i in e?e[i]:e[n]}var N,P,F,I,ve,L,R,ye=h((()=>{N=(...e)=>e.filter(Boolean).join(` `),P={light:``,dark:`.dark`},F=n.createContext(null),I=280,ve=({id:e,config:t})=>{let n=Object.entries(t).filter(([,e])=>e.theme||e.color);return n.length?(0,a.jsx)(`style`,{dangerouslySetInnerHTML:{__html:Object.entries(P).map(([t,r])=>`
2
2
  ${r} [data-chart=${e}] {
3
3
  ${n.map(([e,n])=>{let r=n.theme?.[t]||n.color;return r?` --color-${e}: ${r};`:null}).join(`
4
4
  `)}
5
5
  }
6
6
  `).join(`
7
- `)}}):null},z=o.Tooltip,B=o.Legend}));function V(e){return e?.[0]?.dataKey||`value`}function _e(e,t,n){if(!e)return null;let r=e.payload??e,i=r?.[t];if(i==null)return null;let a=V(n);return{category:String(i),series:a,value:typeof r?.[a]==`number`?r[a]:void 0}}function ve(e,t){if(!e)return null;let n=e.name??e.payload?.name??e.root?.name;if(n==null)return null;let r=e.value??e.size??e.payload?.size;return{category:String(n),series:V(t),value:typeof r==`number`?r:void 0}}function ye(e,t){if(!e)return null;let n=e.payload??e,r=n?.name;return r==null||n?.depth===0?null:{category:String(r),series:V(t),value:typeof n?.value==`number`?n.value:void 0}}var be=h((()=>{})),xe=g({default:()=>G});function Se(e){return e===`top`?ft:dt}function Ce(e){return e===`right`?pt:X}function we(e,t){return e?t?e===`left`||e===`right`?{down:e}:{refused:e}:e===`top`||e===`bottom`?{across:e}:{refused:e}:{}}function Te(e,t){return e?(0,a.jsxs)(`p`,{role:`note`,"data-chart-note":`x-axis-position`,className:`px-1 text-xs text-muted-foreground`,children:[(0,a.jsx)(`code`,{className:`font-mono`,children:`xAxis.position`}),` is`,` `,(0,a.jsx)(`code`,{className:`font-mono`,children:e}),` —`,` `,t?(0,a.jsx)(a.Fragment,{children:`this chart's categories run down its side, so its x axis sits on the left or the right. It is drawn on the left.`}):(0,a.jsx)(a.Fragment,{children:`this chart's x axis runs across it, so it sits at the top or the bottom. It is drawn at the bottom.`})]}):null}function Ee(e,t){return t?e===`left`?`bottom`:`top`:e}function De(e){return e===`left`||e===`right`?`on the ${e}`:`at the ${e}`}function Oe(e,t){return e?t?gt:ht:mt}function ke(e,t){if(e.notes.length===0)return null;let n=t?`this chart's value axes run across it, so each sits at the bottom or the top.`:`this chart's value axes run up its side, so each sits on the left or the right.`;return je(...e.notes.map(e=>{let r=De(Ee(e.drawn,t));return(0,a.jsxs)(`p`,{role:`note`,"data-chart-note":`y-axis-position`,className:`px-1 text-xs text-muted-foreground`,children:[(0,a.jsx)(`code`,{className:`font-mono`,children:`yAxis[${e.index}].position`}),` is`,` `,(0,a.jsx)(`code`,{className:`font-mono`,children:e.position}),` —`,` `,e.reason===`side`?(0,a.jsxs)(a.Fragment,{children:[n,` It is drawn `,r,`.`]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(`code`,{className:`font-mono`,children:`yAxis[0]`}),` already sits `,De(e.position),`, so this axis is drawn `,r,`.`]})]},e.index)}))}function Ae(e,t,n){if(e.undrawn.length===0)return null;let r=e.slotOf.length===1,i=n?`one at the bottom and one at the top`:`one on each side`;return je(...e.undrawn.map(o=>{let s=e[o.boundTo];if(r)return(0,a.jsxs)(`p`,{role:`note`,"data-chart-note":`y-axis-undrawn`,className:`px-1 text-xs text-muted-foreground`,children:[(0,a.jsx)(`code`,{className:`font-mono`,children:`yAxis[${o.index}]`}),` is not drawn — this chart draws one value axis`,s===void 0?null:(0,a.jsxs)(a.Fragment,{children:[`, `,(0,a.jsx)(`code`,{className:`font-mono`,children:`yAxis[${s}]`})]}),`.`]},o.index);let c=t?.[o.index]?.field;return(0,a.jsxs)(`p`,{role:`note`,"data-chart-note":`y-axis-undrawn`,className:`px-1 text-xs text-muted-foreground`,children:[(0,a.jsx)(`code`,{className:`font-mono`,children:`yAxis[${o.index}]`}),` is not drawn — this chart draws at most two value axes, `,i,`.`,c?(0,a.jsxs)(a.Fragment,{children:[` `,`When the chart declares neither `,(0,a.jsx)(`code`,{className:`font-mono`,children:`series`}),` nor`,` `,(0,a.jsx)(`code`,{className:`font-mono`,children:`categories`}),`, its field `,(0,a.jsx)(`code`,{className:`font-mono`,children:c}),` is plotted against the axis `,De(Ee(o.boundTo,n)),s===void 0?null:(0,a.jsxs)(a.Fragment,{children:[`, `,(0,a.jsx)(`code`,{className:`font-mono`,children:`yAxis[${s}]`})]}),`.`]}):null]},o.index)}))}function je(...e){let t=e.filter(e=>e!=null&&e!==!1);return t.length<=1?t[0]??null:(0,a.jsx)(a.Fragment,{children:t.map((e,t)=>(0,a.jsx)(n.Fragment,{children:e},t))})}function Me(e,t,n){if(!e)return{};let r=x(e),i=b(e,t);return{...i?{ticks:i}:{},...r?{domain:r}:{},...r?{allowDataOverflow:!0}:{},...e.logarithmic?{scale:`log`,domain:r??[1,`auto`]}:{},...e.title?{label:{value:e.title,...n}}:{}}}function Ne(e){let{x:t,y:n,width:r,height:i,name:o,fill:s}=e;return r<=0||i<=0?null:(0,a.jsxs)(`g`,{children:[(0,a.jsx)(`rect`,{x:t,y:n,width:r,height:i,fill:s,stroke:`hsl(var(--background))`,strokeWidth:2}),r>48&&i>18?(0,a.jsx)(`text`,{x:t+6,y:n+18,fill:`#fff`,fontSize:12,className:`pointer-events-none`,children:o}):null]})}function Pe({title:e,subtitle:t,children:n}){return!e&&!t?(0,a.jsx)(a.Fragment,{children:n}):(0,a.jsxs)(`div`,{className:`flex h-full w-full flex-col`,children:[(0,a.jsxs)(`div`,{className:`mb-2 shrink-0`,children:[e?(0,a.jsx)(`div`,{className:`text-sm font-medium leading-tight text-foreground`,children:e}):null,t?(0,a.jsx)(`div`,{className:`text-xs leading-tight text-muted-foreground`,children:t}):null]}),(0,a.jsx)(`div`,{className:`min-h-0 flex-1`,children:n})]})}function Fe({note:e,children:t}){return e?(0,a.jsxs)(`div`,{className:`flex h-full w-full flex-col`,children:[(0,a.jsx)(`div`,{className:`min-h-0 flex-1`,children:t}),(0,a.jsx)(`div`,{className:`mt-1 shrink-0`,children:e})]}):(0,a.jsx)(a.Fragment,{children:t})}function Ie(e,t){let n=0;for(let r of e){let e=Number(r?.[t]);Number.isFinite(e)&&e>0&&(n+=1)}return{sizable:n,total:e.length}}function Le({dataKey:e,className:t}){return(0,a.jsxs)(W,{code:`no-positive-magnitude`,className:t,children:[`This chart has nothing to size: no row's`,` `,(0,a.jsx)(`code`,{className:`font-mono`,children:e}),` is above zero.`]})}function Re(e,t,n){let r=t-e;return r<=0?null:(0,a.jsxs)(`p`,{role:`note`,"data-chart-note":`unsized-rows`,className:`px-1 text-xs text-muted-foreground`,children:[r,` of `,t,` rows `,r===1?`has`:`have`,` no`,` `,(0,a.jsx)(`code`,{className:`font-mono`,children:n}),` above zero — this chart sizes by value, so`,` `,r===1?`that row is`:`those rows are`,` not drawn to scale.`]})}function ze(e){return e!=null&&Number.isFinite(Number(e))}function Be(e,t,n){let r=0;for(let i of e){let e=i;ze(e?.[t])&&ze(e?.[n])&&(r+=1)}return{plottable:r,total:e.length}}function Ve({xKey:e,yKey:t,className:n}){return(0,a.jsxs)(W,{code:`no-plottable-points`,className:n,children:[`This chart has nothing to place: no row carries a number for both`,` `,(0,a.jsx)(`code`,{className:`font-mono`,children:e}),` and`,` `,(0,a.jsx)(`code`,{className:`font-mono`,children:t}),`.`]})}function He(e){return typeof e==`boolean`?!1:Array.isArray(e)?Ue(e[0])&&Ue(e[1]):Ue(e)}function Ue(e){return typeof e==`number`||e instanceof Number||typeof e==`string`||e instanceof Date?Number.isFinite(Number(e)):!1}function We(e){let t=e=>typeof e==`number`&&Number.isFinite(e);return t(e?.min)&&t(e?.max)||t(e?.stepSize)}function Ge(e,t){return e.some(e=>He(e?.[t]))}function Ke(e,t,n){let r=t[n];if(!r?.stack)return`none`;let i=oe(e,t),a=i===`combo`?r.chartType||ae(e)||(n===0?`bar`:`line`):i;return a===`line`?`none`:a===`area`?`area`:`bar`}function qe({keys:e,total:t,className:r}){return(0,a.jsxs)(W,{code:`no-numeric-value`,className:r,children:[`This chart has no scale to draw on:`,` `,t===1?`its only row has no`:`none of the ${t} rows has a`,` numeric value for`,` `,e.map((e,t)=>(0,a.jsxs)(n.Fragment,{children:[t>0?` or `:``,(0,a.jsx)(`code`,{className:`font-mono`,children:e})]},`${t}-${e}`)),`.`]})}function Je({seriesKeys:e,className:t}){let r=(0,i.useSafeTranslate)();return(0,a.jsxs)(W,{code:`scatter-multi-series`,className:t,children:[r(`chart.scatterOneMeasure`,`A scatter plots one measure. Keep exactly one series:`),` `,e.map((e,t)=>(0,a.jsxs)(n.Fragment,{children:[t>0?`, `:``,(0,a.jsx)(`code`,{className:`font-mono`,children:e})]},`${t}-${e}`))]})}function Ye(e,t,n,r){let i=t-e;return i<=0?null:(0,a.jsxs)(`p`,{role:`note`,"data-chart-note":`unplotted-points`,className:`px-1 text-xs text-muted-foreground`,children:[i,` of `,t,` rows `,i===1?`has`:`have`,` no number for both`,` `,(0,a.jsx)(`code`,{className:`font-mono`,children:n}),` and`,` `,(0,a.jsx)(`code`,{className:`font-mono`,children:r}),` — this chart plots by position, so`,` `,i===1?`that point is`:`those points are`,` not drawn.`]})}function Xe({chartType:e,data:r=[],config:s={},xAxisKey:c=`name`,series:l=[],className:u=``,colors:d,categoryColors:f,categoryOrder:p,onChartClick:m,isAnimationActive:h,xAxis:g,yAxes:_,showLegend:ee,showDataLabels:v,title:te,subtitle:ne,description:ie,height:b,annotations:x,interaction:le}){let C=e===`column`?`bar`:e,w=oe(C,l),T=ae(C),E=Array.isArray(r)?r:[],D=(0,i.useDisplayLocale)(),O=h===!1?{isAnimationActive:!1}:{},k={...h===!1?{disableSettleRemount:!0}:{},...b?{style:{height:b}}:{},...ie?{role:`img`,"aria-label":ie}:{}},[A,ue]=n.useState(!1),j=n.useRef(null),de=n.useCallback(e=>(...t)=>{let n=at(t);n!==void 0&&(j.current={gesture:n,dataKey:String(e.dataKey)})},[]),fe=m?e=>({onClick:de(e)}):()=>({}),pe=n.useCallback((e,n,r)=>{if(!m||!e)return;let i=e.activeTooltipIndex??e.activeIndex,a=i==null?NaN:Number(i),o=Number.isInteger(a)&&a>=0?E[a]:void 0,s=j.current;j.current=null;let c=it(n),u=s!=null&&c!==void 0&&s.gesture===c;if(r&&!u)return;let d=u?s.dataKey:rt(e.activeDataKey,l),f=d!=null&&o?o[d]:void 0;m({category:e.activeLabel==null?void 0:String(e.activeLabel),categoryId:(0,t.chartRowBucketId)(o),series:d,seriesLabel:ot(d,l),value:typeof f==`number`?f:void 0})},[m,E,l]),F=n.useCallback((e,t)=>{pe(e,t,!1)},[pe]),I=n.useCallback((e,t)=>{pe(e,t,!0)},[pe]),L=n.useCallback(e=>{if(!m||!e)return;let n=e.payload?.[c],r=l[0]?.dataKey||`value`;m({category:n==null?void 0:String(n),categoryId:(0,t.chartRowBucketId)(e.payload),series:r,seriesLabel:ot(r,l),value:typeof e.payload?.[r]==`number`?e.payload[r]:void 0})},[m,c,l]),me=m?{onClick:F,style:{cursor:`pointer`}}:{},he=m?{onClick:I}:{},R=m?e=>({...fe(e),cursor:`pointer`}):()=>({}),ge=m?{onClick:L,style:{cursor:`pointer`}}:{},V=n.useCallback((e,t,n)=>f&&f[e==null?``:String(e)]||n[t%n.length],[f]),be=n.useCallback(e=>{if(!m)return;let t=_e(e,c,l);t&&m(t)},[m,c,l]),xe=n.useCallback(e=>{if(!m)return;let t=ve(e,l);t&&m(t)},[m,l]),Ee=n.useCallback(e=>{if(!m)return;let t=ye(e,l);t&&m(t)},[m,l]),De=m?{onClick:be,cursor:`pointer`}:{},ze=m?{onClick:xe,style:{cursor:`pointer`}}:{},He=m?{onClick:Ee,style:{cursor:`pointer`}}:{};n.useEffect(()=>{let e=()=>ue(window.innerWidth<640);return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let Ue=n.useCallback(e=>{if(e==null||e===``)return``;let n=s?.[String(e)]?.label;if(n!=null)return String(n);let r=typeof e==`string`?e:String(e);if(/^\d{4}-\d{2}-\d{2}/.test(r)){let e=(0,t.toDisplayDate)(r);if(!Number.isNaN(e.getTime())){let n=(E.length>1?Math.abs(new Date(String(E[E.length-1][c]??``)).getTime()-new Date(String(E[0][c]??``)).getTime()):0)/864e5;try{return n<=62?e.toLocaleDateString(D,{month:`short`,day:`numeric`}):e.toLocaleDateString(D,{month:`short`,year:`numeric`})}catch{return(0,t.isRealCalendarDate)(r)?(0,t.toDateInputValue)(e):e.toISOString().slice(0,10)}}}return A&&r.length>8?r.slice(0,8)+`…`:r},[E,c,A,s,D]),Ke=n.useMemo(()=>E.some(e=>String(e[c]||``).length>5),[E,c]),Xe=E.length>0&&E.length<=st,H=(Xe||!A)&&Ke,Ze=()=>Array.isArray(d)&&d.length>0?d:[`hsl(var(--chart-1))`,`hsl(var(--chart-2))`,`hsl(var(--chart-3))`,`hsl(var(--chart-4))`,`hsl(var(--chart-5))`],Qe=n.useCallback(e=>{if(e==null||e===``)return``;let t=typeof e==`number`?e:Number(e);if(!Number.isFinite(t))return String(e);try{return new Intl.NumberFormat(D,{notation:`compact`,maximumFractionDigits:1}).format(t)}catch{return String(t)}},[D]),$e=_?.[0],U=w===`horizontal-bar`,et=re(_,w),G=et.left===void 0?void 0:_?.[et.left],K=et.right===void 0?void 0:_?.[et.right],J=!!G&&!!K,Y=w===`combo`||J,X=et.slotOf[0]??`left`,pt=je(ke(et,U),Ae(et,_,U)),mt=e=>J?e.yAxis===`right`?K:G:$e,ht=n.useMemo(()=>y(g?.format,D)??Ue,[g?.format,D,Ue]),gt=n.useMemo(()=>!Xe||!H?ht:e=>{let t=String(ht(e)??``);return t.length>ct?`${t.slice(0,11)}…`:t},[Xe,H,ht]),_t=n.useMemo(()=>y($e?.format,D)??Qe,[$e?.format,D,Qe]),vt=n.useMemo(()=>y(G?.format,D)??Qe,[G?.format,D,Qe]),yt=n.useMemo(()=>y(K?.format,D)??Qe,[K?.format,D,Qe]),bt=n.useCallback(e=>{let t=l.filter(t=>!J||(t.yAxis===`right`?`right`:`left`)===e).map(e=>e.dataKey),n=[];for(let e of E)for(let r of t){let t=Number(e?.[r]);Number.isFinite(t)&&n.push(t)}return n},[E,l,J]),Z=n.useCallback((e,t=`left`,n)=>Me(e,bt(t),n??Ce(t)),[bt]),xt=$e?.showGridLines!==!1,St={vertical:g?.showGridLines===!0,horizontal:xt},{across:Q,down:Ct,refused:wt}=we(g?.position,U),Tt=Te(wt,U),Et=ee!==!1,Dt=n.useMemo(()=>{if(!Array.isArray(x)||x.length===0)return null;let e={solid:void 0,dashed:`4 4`,dotted:`1 4`},t=Oe(Y,U);return x.map((n,r)=>{let i=n?.axis===`x`,s=q(String(n?.color||`hsl(var(--muted-foreground))`)),c=e[String(n?.style??`dashed`)],l=typeof n?.label==`string`?n.label:void 0,u=l?{label:{value:l,position:`insideTopRight`,fill:s,fontSize:11}}:{};if(n?.type===`region`){let e=i?{x1:n.value,x2:n.endValue}:{y1:n.value,y2:n.endValue};return(0,a.jsx)(o.ReferenceArea,{...e,...t,fill:s,fillOpacity:.12,stroke:s,strokeOpacity:.35,...u},`ann-${r}`)}return(0,a.jsx)(o.ReferenceLine,{...i?{x:n?.value}:{y:n?.value},...t,stroke:s,strokeDasharray:c,...u},`ann-${r}`)})},[x,Y,U]),Ot=le?.tooltips!==!1,kt=le?.brush===!0?(0,a.jsx)(o.Brush,{dataKey:c,height:24,travellerWidth:8,stroke:`hsl(var(--muted-foreground))`}):null,$=e=>v?(0,a.jsx)(o.LabelList,{position:`top`,className:`fill-foreground`,fontSize:11,...e?{formatter:e}:{}}):null,At=n.useMemo(()=>({tickLine:!1,tickMargin:10,axisLine:!1,...Xe?{interval:0}:{interval:`preserveStartEnd`,minTickGap:0},tickFormatter:gt,...Q?{orientation:Q}:{},...g?.title?{label:{value:g.title,...Se(Q)}}:{},...H&&{angle:Q===`top`?35:-35,textAnchor:`end`,height:60}}),[Xe,H,gt,g?.title,Q]);if(w&&ce.has(w)){let e=l[0]?.dataKey||`value`,t=E[0]?.[e],n=typeof t==`number`?t:Number(t),r=l[0]?.label??s?.[e]?.label??e;return(0,a.jsx)(`div`,{className:u,"data-testid":`advanced-chart-single-value`,children:(0,a.jsxs)(`div`,{className:`flex flex-col gap-1 py-4`,children:[(0,a.jsx)(`span`,{className:`text-3xl font-semibold tabular-nums`,children:Number.isFinite(n)?new Intl.NumberFormat(D).format(n):String(t??`—`)}),(0,a.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:String(r)})]})})}if(w&&S.has(w))return(0,a.jsxs)(`div`,{className:`rounded-md border border-dashed bg-muted/20 px-3 py-2 text-xs text-muted-foreground ${u??``}`,"data-testid":`advanced-chart-tabular-notice`,role:`note`,children:[`Chart type “`,w,`” is tabular — render it with the data-table / pivot components; a chart block draws series charts.`]});if(!w||!se.has(w))return(0,a.jsx)(`div`,{className:`rounded-md border border-dashed bg-muted/20 px-3 py-2 text-xs text-muted-foreground ${u??``}`,"data-testid":`advanced-chart-unknown-type`,role:`note`,children:w?(0,a.jsxs)(a.Fragment,{children:[`Chart type “`,w,`” is not a spec chart type — nothing was drawn.`]}):(0,a.jsx)(a.Fragment,{children:`This chart names no chart type — nothing was drawn.`})});let jt={bar:o.BarChart,"horizontal-bar":o.BarChart,line:o.LineChart,area:o.AreaChart,pie:o.PieChart,donut:o.PieChart,radar:o.RadarChart,scatter:o.ScatterChart,funnel:o.FunnelChart,combo:o.ComposedChart,treemap:o.BarChart,sankey:o.BarChart}[w]||o.BarChart;if(w===`pie`||w===`donut`){let e=w===`donut`?`52%`:0,t=Ze(),n=l[0]?.dataKey||`value`,r=Ie(E,n);if(r.total>0&&r.sizable===0)return(0,a.jsx)(Le,{dataKey:n,className:u});let i={...s};E.forEach((e,n)=>{let r=e?.[c];if(r==null||r===``)return;let a=String(r);i[a]||(i[a]={label:a,color:V(r,n,t)})});let d=(0,a.jsx)(M,{config:i,className:u,...k,children:(0,a.jsxs)(o.PieChart,{children:[(0,a.jsx)(z,{cursor:!1,content:(0,a.jsx)(N,{hideLabel:!0})}),(0,a.jsx)(o.Pie,{data:E,dataKey:n,nameKey:c||`name`,innerRadius:e,strokeWidth:5,paddingAngle:2,outerRadius:`85%`,...O,...ge,children:E.map((e,n)=>{let r=V(e?.[c],n,t);return(0,a.jsx)(o.Cell,{fill:q(r)},`cell-${n}`)})}),Et?(0,a.jsx)(B,{verticalAlign:`bottom`,wrapperStyle:{fontSize:A?`11px`:`12px`,paddingTop:`8px`},content:(0,a.jsx)(P,{nameKey:c,className:`flex-wrap`})}):null]})});return(0,a.jsx)(Fe,{note:Re(r.sizable,r.total,n),children:d})}if(w===`funnel`){let e=l[0]?.dataKey||`value`,n=Ze(),r=Ie(E,e);if(r.total>0&&r.sizable===0)return(0,a.jsx)(Le,{dataKey:e,className:u});let i=m?n=>{n&&m({category:n?.payload?.[c]??n?.[c],categoryId:(0,t.chartRowBucketId)(n?.payload)??(0,t.chartRowBucketId)(n),value:n?.payload?.[e]??n?.[e]})}:void 0,d=i?{onClick:i,style:{cursor:`pointer`}}:{},f=(0,t.buildCategoryRank)(p),h=f?[...E].sort((e,t)=>(f.get(String(e?.[c]??``))??2**53-1)-(f.get(String(t?.[c]??``))??2**53-1)):[...E].sort((t,n)=>{let r=Number(t?.[e]??0);return Number(n?.[e]??0)-r}),g=(0,a.jsx)(M,{config:s,className:u,...k,children:(0,a.jsxs)(o.FunnelChart,{children:[(0,a.jsx)(z,{content:(0,a.jsx)(N,{})}),(0,a.jsxs)(o.Funnel,{dataKey:e,data:h,nameKey:c,...O,...d,children:[(0,a.jsx)(o.LabelList,{position:`right`,fill:`hsl(var(--foreground))`,stroke:`none`,dataKey:c}),h.map((e,t)=>(0,a.jsx)(o.Cell,{fill:q(n[t%n.length])},`funnel-cell-${t}`))]})]})});return(0,a.jsx)(Fe,{note:Re(r.sizable,r.total,e),children:g})}if(w===`treemap`){let e=l[0]?.dataKey||`value`,t=Ze(),n=Ie(E,e);if(n.total>0&&n.sizable===0)return(0,a.jsx)(Le,{dataKey:e,className:u});let r=E.map((n,r)=>({name:String(n?.[c]??``),size:Number(n?.[e])||0,fill:q(t[r%t.length])})),i=(0,a.jsx)(M,{config:s,className:u,...k,children:(0,a.jsx)(o.Treemap,{data:r,dataKey:`size`,nameKey:`name`,...O,content:(0,a.jsx)(Ne,{}),...ze,children:(0,a.jsx)(o.Tooltip,{})})});return(0,a.jsx)(Fe,{note:Re(n.sizable,n.total,e),children:i})}if(w===`sankey`){let e=l[0]?.dataKey||`value`,t=l[0]?.label||e,n=E.filter(t=>(Number(t?.[e])||0)>0),r=[{name:t},...n.map(e=>({name:String(e?.[c]??``)}))],i=n.map((t,n)=>({source:0,target:n+1,value:Number(t?.[e])||0}));if(i.length===0)return E.length===0?(0,a.jsx)(`div`,{className:u}):(0,a.jsxs)(W,{code:`no-positive-flow`,className:u,children:[`This chart has no flow to draw: no row's`,` `,(0,a.jsx)(`code`,{className:`font-mono`,children:e}),` is above zero.`]});let d=E.length-n.length;return(0,a.jsx)(Fe,{note:d>0?(0,a.jsxs)(`p`,{role:`note`,"data-chart-note":`omitted-rows`,className:`px-1 text-xs text-muted-foreground`,children:[`Showing `,n.length,` of `,E.length,` rows — `,d,` `,d===1?`row has`:`rows have`,` no`,` `,(0,a.jsx)(`code`,{className:`font-mono`,children:e}),` above zero, which a flow cannot draw.`]}):null,children:(0,a.jsx)(M,{config:s,className:u,...k,children:(0,a.jsx)(o.Sankey,{data:{nodes:r,links:i},nodePadding:24,link:{stroke:`hsl(var(--muted-foreground))`,strokeOpacity:.25},node:{fill:`hsl(var(--chart-1))`},...He,children:(0,a.jsx)(o.Tooltip,{})})})})}if(w===`radar`)return(0,a.jsx)(M,{config:s,className:u,...k,children:(0,a.jsxs)(o.RadarChart,{data:E,children:[(0,a.jsx)(o.PolarGrid,{}),(0,a.jsx)(o.PolarAngleAxis,{dataKey:c}),(0,a.jsx)(o.PolarRadiusAxis,{}),(0,a.jsx)(z,{content:(0,a.jsx)(N,{})}),(0,a.jsx)(B,{content:(0,a.jsx)(P,{}),...A&&{verticalAlign:`bottom`,wrapperStyle:{fontSize:`11px`,paddingTop:`8px`}}}),l.map(e=>{let t=q(s[e.dataKey]?.color||tt),n=nt(e,`radar`);return(0,a.jsx)(o.Radar,{dataKey:e.dataKey,stroke:t,fill:t,fillOpacity:n.fillOpacity??.6,strokeOpacity:n.strokeOpacity,strokeDasharray:n.strokeDasharray,...O},e.dataKey)})]})});if(w===`scatter`){if(l.length>1)return(0,a.jsx)(Je,{seriesKeys:l.map(e=>String(e.dataKey)),className:u});let e=l[0]?.dataKey||`value`,t=Be(E,c,e),n=E.map(e=>Number(e?.[c])).filter(e=>Number.isFinite(e)),r=y(g?.format,D);if(t.total>0&&t.plottable===0)return(0,a.jsx)(Ve,{xKey:c,yKey:e,className:u});if(t.total>0){let n=[[c,g],[e,_?.[0]]].filter(([e,t])=>!We(t)&&!Ge(E,e)).map(([e])=>e).filter((e,t,n)=>n.indexOf(e)===t);if(n.length>0)return(0,a.jsx)(qe,{keys:n,total:t.total,className:u})}return(0,a.jsx)(Fe,{note:je(Ye(t.plottable,t.total,c,e),Tt,pt),children:(0,a.jsx)(M,{config:s,className:u,...k,children:(0,a.jsxs)(o.ScatterChart,{children:[(0,a.jsx)(o.CartesianGrid,{...St}),(0,a.jsx)(o.XAxis,{type:`number`,dataKey:c,name:String(s[c]?.label||c),tickLine:!1,axisLine:!1,minTickGap:A?32:48,padding:lt,...r?{tickFormatter:r}:{},...Q?{orientation:Q}:{},...Me(g,n,Se(Q))}),(0,a.jsx)(o.YAxis,{type:`number`,dataKey:e,name:String(s[l[0]?.dataKey]?.label||l[0]?.dataKey),tickLine:!1,axisLine:!1,tickFormatter:_t,width:48,padding:ut,...X===`right`?{orientation:`right`}:{},...Z($e,X)}),(0,a.jsx)(z,{content:(0,a.jsx)(N,{})}),(0,a.jsx)(B,{content:(0,a.jsx)(P,{nameKey:e}),...A&&{verticalAlign:`bottom`,wrapperStyle:{fontSize:`11px`,paddingTop:`8px`}}}),l.map((e,t)=>{let n=Ze(),r=q(s[e.dataKey]?.color||n[t%n.length]),i=nt(e,`scatter`);return(0,a.jsx)(o.Scatter,{name:s[e.dataKey]?.label||e.dataKey,data:E,fill:r,fillOpacity:i.fillOpacity,strokeOpacity:i.strokeOpacity,strokeDasharray:i.strokeDasharray,...O,...De},e.dataKey)})]})})})}if(w===`combo`)return(0,a.jsx)(Pe,{title:te,subtitle:ne,children:(0,a.jsx)(Fe,{note:je(Tt,pt),children:(0,a.jsx)(M,{config:s,className:u,...k,children:(0,a.jsxs)(o.ComposedChart,{data:E,...he,children:[(0,a.jsx)(o.CartesianGrid,{...St,...Oe(Y,U)}),(0,a.jsx)(o.XAxis,{dataKey:c,...At}),(0,a.jsx)(o.YAxis,{yAxisId:`left`,tickLine:!1,axisLine:!1,tickFormatter:vt,width:48,...Z(G,`left`)}),(0,a.jsx)(o.YAxis,{yAxisId:`right`,orientation:`right`,tickLine:!1,axisLine:!1,tickFormatter:yt,width:48,...Z(K,`right`)}),Ot?(0,a.jsx)(z,{content:(0,a.jsx)(N,{})}):null,Et?(0,a.jsx)(B,{content:(0,a.jsx)(P,{}),...A&&{verticalAlign:`bottom`,wrapperStyle:{fontSize:`11px`,paddingTop:`8px`}}}):null,Dt,kt,l.map((e,t)=>{let n=q(s[e.dataKey]?.color||tt),r=e.chartType||T||(t===0?`bar`:`line`),i=e.yAxis===`right`||e.yAxis===`left`?e.yAxis:T||r===`bar`?`left`:`right`,c=nt(e,r),l=e.stack?{stackId:String(e.stack)}:{},u=y((i===`right`?K:G)?.format,D);return r===`line`?(0,a.jsx)(o.Line,{yAxisId:i,type:`monotone`,dataKey:e.dataKey,stroke:n,strokeWidth:2,dot:!1,strokeOpacity:c.strokeOpacity,strokeDasharray:c.strokeDasharray,...O,...R(e),children:$(u)},e.dataKey):r===`area`?(0,a.jsx)(o.Area,{yAxisId:i,type:`monotone`,dataKey:e.dataKey,fill:n,stroke:n,fillOpacity:c.fillOpacity??.4,strokeOpacity:c.strokeOpacity,strokeDasharray:c.strokeDasharray,...l,...O,...R(e),children:$(u)},e.dataKey):(0,a.jsx)(o.Bar,{yAxisId:i,dataKey:e.dataKey,fill:n,radius:4,fillOpacity:c.fillOpacity,strokeOpacity:c.strokeOpacity,strokeDasharray:c.strokeDasharray,...l,...O,...R(e),children:$(u)},e.dataKey)})]})})})});let Mt=w===`horizontal-bar`,Nt=Ze(),Pt=f?Object.values(f).map(e=>q(String(e))):[],Ft=Array.from(new Set([...Nt,...Pt,...l.map((e,t)=>q(s[e.dataKey]?.color||Nt[t%Nt.length]||tt))])),It=e=>`g`+e.replace(/[^a-zA-Z0-9]/g,``);return(0,a.jsx)(Pe,{title:te,subtitle:ne,children:(0,a.jsx)(Fe,{note:je(Tt,pt),children:(0,a.jsx)(M,{config:s,className:u,...k,children:(0,a.jsxs)(jt,{data:E,layout:Mt?`vertical`:`horizontal`,...me,children:[(0,a.jsx)(`defs`,{children:Ft.map(e=>(0,a.jsxs)(n.Fragment,{children:[(0,a.jsxs)(`linearGradient`,{id:`bg-${It(e)}`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,a.jsx)(`stop`,{offset:`0%`,style:{stopColor:e},stopOpacity:.95}),(0,a.jsx)(`stop`,{offset:`100%`,style:{stopColor:e},stopOpacity:.5})]}),(0,a.jsxs)(`linearGradient`,{id:`ag-${It(e)}`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,a.jsx)(`stop`,{offset:`0%`,style:{stopColor:e},stopOpacity:.5}),(0,a.jsx)(`stop`,{offset:`95%`,style:{stopColor:e},stopOpacity:.05})]})]},It(e)))}),(0,a.jsx)(o.CartesianGrid,{...St,...Oe(Y,U)}),Mt?(0,a.jsxs)(a.Fragment,{children:[J?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(o.XAxis,{xAxisId:`left`,type:`number`,tickLine:!1,axisLine:!1,tickFormatter:vt,...Z(G,`left`,dt)}),(0,a.jsx)(o.XAxis,{xAxisId:`right`,orientation:`top`,type:`number`,tickLine:!1,axisLine:!1,tickFormatter:yt,...Z(K,`right`,ft)})]}):(0,a.jsx)(o.XAxis,{type:`number`,tickLine:!1,axisLine:!1,tickFormatter:_t,...X===`right`?{orientation:`top`}:{},...Z($e,X,Se(X===`right`?`top`:`bottom`))}),(0,a.jsx)(o.YAxis,{type:`category`,dataKey:c,tickLine:!1,axisLine:!1,width:Math.min(140,Math.max(60,Math.max(...E.map(e=>String(e[c]??``).length))*7)),tickFormatter:ht,...Ct?{orientation:Ct}:{},...g?.title?{label:{value:g.title,...Ce(Ct)}}:{}})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(o.XAxis,{dataKey:c,...At}),J?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(o.YAxis,{yAxisId:`left`,tickLine:!1,axisLine:!1,tickFormatter:vt,width:48,...Z(G,`left`)}),(0,a.jsx)(o.YAxis,{yAxisId:`right`,orientation:`right`,tickLine:!1,axisLine:!1,tickFormatter:yt,width:48,...Z(K,`right`)})]}):(0,a.jsx)(o.YAxis,{tickLine:!1,axisLine:!1,tickFormatter:_t,width:48,...X===`right`?{orientation:`right`}:{},...Z($e,X)})]}),Ot?(0,a.jsx)(z,{content:(0,a.jsx)(N,{})}):null,Et?(0,a.jsx)(B,{content:(0,a.jsx)(P,{}),...A&&{verticalAlign:`bottom`,wrapperStyle:{fontSize:`11px`,paddingTop:`8px`}}}):null,Dt,kt,l.map((e,t)=>{let n=Ze(),r=e.variant===`comparison`,i=r?l.slice(0,t).find(e=>e.variant!==`comparison`)||l[0]:e,u=r?l.indexOf(i):t,d=q(s[i.dataKey]?.color||n[u%n.length]||tt),f=e.yAxis===`right`?`right`:`left`,p=J?Mt?{xAxisId:f}:{yAxisId:f}:{},m=e.stack?{stackId:String(e.stack)}:{},h=y(mt(e)?.format,D);if(w===`bar`||w===`horizontal-bar`){let t=l.filter(e=>e.variant!==`comparison`).length===1&&!r&&l.length===1&&E.length>1,i=nt(e,`bar`);return(0,a.jsxs)(o.Bar,{dataKey:e.dataKey,fill:`url(#bg-${It(d)})`,radius:4,fillOpacity:i.fillOpacity,strokeOpacity:i.strokeOpacity,strokeDasharray:i.strokeDasharray,...m,...p,...O,...fe(e),children:[t&&E.map((e,t)=>(0,a.jsx)(o.Cell,{fill:`url(#bg-${It(q(V(e?.[c],t,n)))})`},`cell-${t}`)),$(h)]},e.dataKey)}if(w===`line`){let t=nt(e,`line`);return(0,a.jsx)(o.Line,{type:`monotone`,dataKey:e.dataKey,stroke:d,strokeWidth:2,dot:!1,strokeOpacity:t.strokeOpacity,strokeDasharray:t.strokeDasharray,...p,...O,...fe(e),children:$(h)},e.dataKey)}if(w===`area`){let t=nt(e,`area`);return(0,a.jsx)(o.Area,{type:`monotone`,dataKey:e.dataKey,fill:`url(#ag-${It(d)})`,stroke:d,strokeWidth:2,fillOpacity:t.fillOpacity??1,strokeOpacity:t.strokeOpacity,strokeDasharray:t.strokeDasharray,...m,...p,...O,...fe(e),children:$(h)},e.dataKey)}return null})]})})})})}function H(e){return e.chartType===`column`?`bar`:e.chartType}function Ze(e){let t=H(e),n=Array.isArray(e.data)?e.data:[],r=e.xAxisKey??`name`;return t!==void 0&&J.has(t)&&n.length>0&&!n.some(e=>typeof e==`object`&&!!e&&r in e)}function Qe(e){let t=H(e),n=Array.isArray(e.data)?e.data:[];return t===void 0||!_t.has(t)||n.length===0?null:e.series===void 0?`undeclared`:Array.isArray(e.series)&&e.series.length===0?`empty`:null}function $e(e){let t=H(e),n=Array.isArray(e.data)?e.data:[],r=Array.isArray(e.series)?e.series:[];if(t===void 0||!_t.has(t)||n.length===0||r.length===0)return null;let i=Array.from(new Set(r.map(e=>String(e.dataKey))));if(!i.every(e=>n.some(t=>typeof t==`object`&&!!t&&Object.prototype.hasOwnProperty.call(t,e))))return null;let a=Array.isArray(e.yAxes)?e.yAxes:[],o=re(a,t),s=o.left===void 0?void 0:a[o.left],c=o.right===void 0?void 0:a[o.right],l=!!s&&!!c,u=e=>We(s)||(!l||e.yAxis!==`left`)&&We(c);return r.some((e,i)=>Ke(t,r,i)!==`none`||u(e)||Ge(n,String(e.dataKey)))?null:i}function U(e){let t=H(e),n=Array.isArray(e.data)?e.data:[],r=Array.isArray(e.series)?e.series:[];if(t===void 0||!_t.has(t)||n.length===0||r.length===0)return null;let i=Array.from(new Set(r.map(e=>e.dataKey)));return i.every(e=>typeof e==`string`&&/^[^.[]+$/.test(e)&&!n.some(t=>typeof t==`object`&&!!t&&e in t))?i:null}function et({keys:e,className:t}){return(0,a.jsxs)(W,{code:`missing-series-key`,className:t,children:[`This chart cannot plot its series: no row has a`,` `,e.map((e,t)=>(0,a.jsxs)(n.Fragment,{children:[t>0?` or `:``,(0,a.jsx)(`code`,{className:`font-mono`,children:e})]},`${t}-${e}`)),` `,`field.`]})}function W({code:e,className:t,children:n}){return(0,a.jsx)(`div`,{className:`flex h-full min-h-[120px] w-full items-center justify-center p-4 text-center text-sm text-muted-foreground ${t??``}`,role:`status`,"data-chart-error":e,children:(0,a.jsx)(`span`,{children:n})})}function G(e){let t=Ze(e),r=t?null:Qe(e),i=t||r?null:U(e),o=t||r||i?null:$e(e),s=e.xAxisKey??`name`,c=n.useMemo(()=>Object.keys((Array.isArray(e.data)?e.data[0]:void 0)??{}),[e.data]),l=i?JSON.stringify(i):null,u=JSON.stringify(c);return n.useEffect(()=>{t&&console.warn(`[chart] no row has the category key "${s}" — rendering an explanatory placeholder instead of an empty axis. Row keys: ${JSON.stringify(c)}. A dataset query must PROJECT the dimension it groups by (framework#4033).`)},[t,s,c]),n.useEffect(()=>{if(r){if(r===`undeclared`){console.warn(`[chart] no series binding was declared for the category axis "${s}" — rendering an explanatory placeholder instead of an empty frame. Row keys: ${JSON.stringify(c)}. A bar / line / area / combo chart draws only the columns its \`series\` (or \`categories\`, or a y-axis \`field\`) names (objectui#4695).`);return}console.warn(`[chart] no series to plot against the category axis "${s}" — rendering an explanatory placeholder instead of an empty frame. Row keys: ${JSON.stringify(c)}. A grouped chart's SECOND dimension must be PROJECTED by the dataset query, and a chart with no measure selected has nothing to draw either (objectui#4683, framework#4033).`)}},[r,s,c]),n.useEffect(()=>{l&&console.warn(`[chart] no row has the series key(s) ${l} — rendering an explanatory placeholder instead of an empty frame. Row keys: ${u}. A series \`dataKey\` must name a column the rows carry (objectui#10396).`)},[l,u]),t?(0,a.jsxs)(W,{code:`missing-category-key`,className:e.className,children:[`This chart cannot plot its category axis: no row has a`,` `,(0,a.jsx)(`code`,{className:`font-mono`,children:s}),` field.`]}):r===`undeclared`?(0,a.jsxs)(W,{code:`no-plottable-series`,className:e.className,children:[`This chart cannot plot any series: none was declared to draw against its`,` `,(0,a.jsx)(`code`,{className:`font-mono`,children:s}),` axis.`]}):r===`empty`?(0,a.jsxs)(W,{code:`no-plottable-series`,className:e.className,children:[`This chart cannot plot any series: no measure or group reached its`,` `,(0,a.jsx)(`code`,{className:`font-mono`,children:s}),` axis.`]}):i?(0,a.jsx)(et,{keys:i,className:e.className}):o?(0,a.jsx)(qe,{keys:o,total:Array.isArray(e.data)?e.data.length:0,className:e.className}):(0,a.jsx)(Xe,{...e})}var tt,K,q,nt,rt,it,at,ot,J,st,ct,Y,lt,ut,X,dt,ft,pt,mt,ht,gt,_t,vt=h((()=>{ge(),be(),k(),tt=`hsl(var(--primary))`,K={slate:`#64748b`,gray:`#6b7280`,zinc:`#71717a`,neutral:`#737373`,stone:`#78716c`,red:`#ef4444`,orange:`#f97316`,amber:`#f59e0b`,yellow:`#eab308`,lime:`#84cc16`,green:`#22c55e`,emerald:`#10b981`,teal:`#14b8a6`,cyan:`#06b6d4`,sky:`#0ea5e9`,blue:`#3b82f6`,indigo:`#6366f1`,violet:`#8b5cf6`,purple:`#a855f7`,fuchsia:`#d946ef`,pink:`#ec4899`,rose:`#f43f5e`},q=e=>K[e]||e,nt=(e,t)=>{let n=e?.variant===`comparison`,r=t===`area`||t===`radar`,i=typeof e?.opacity==`number`?e.opacity:void 0;return{strokeOpacity:i??(n?t===`line`?.5:r?.6:void 0:void 0),fillOpacity:i??(n?t===`bar`?.4:r?.2:.5:void 0),strokeDasharray:e?.dashArray??(n&&(t===`line`||r)?`4 4`:void 0)}},rt=(e,t)=>{if(typeof e==`string`||typeof e==`number`){let t=String(e);if(t!==``)return t}if(t.length===1){let e=t[0]?.dataKey;if(e!=null&&String(e)!==``)return String(e)}},it=e=>{if(e&&typeof e==`object`&&`nativeEvent`in e)return e.nativeEvent},at=e=>{for(let t=e.length-1;t>=0;--t){let n=it(e[t]);if(n!==void 0)return n}},ot=(e,t)=>{if(e==null)return;let n=t.find(t=>String(t.dataKey)===e);return typeof n?.label==`string`?n.label:void 0},J=new Set([`bar`,`horizontal-bar`,`line`,`area`,`pie`,`donut`,`radar`,`funnel`,`combo`]),st=5,ct=12,Y=Math.ceil(Math.sqrt(400/Math.PI)),lt={left:Y,right:Y},ut={top:Y,bottom:Y},X={angle:-90,position:`insideLeft`},dt={position:`insideBottom`,offset:-4},ft={position:`insideTop`,offset:-4},pt={angle:90,position:`insideRight`},mt={},ht={yAxisId:`left`},gt={xAxisId:`left`},_t=new Set([`bar`,`horizontal-bar`,`line`,`area`,`combo`])}));k();var yt=n.default.lazy(()=>Promise.resolve().then(()=>(fe(),A))),bt=n.default.lazy(()=>Promise.resolve().then(()=>(vt(),xe))),Z=({schema:e})=>(0,a.jsx)(n.Suspense,{fallback:(0,a.jsx)(r.Skeleton,{className:`w-full h-48 sm:h-64 md:h-80 lg:h-[400px]`}),children:(0,a.jsx)(yt,{data:e.data,dataKey:e.dataKey,xAxisKey:e.xAxisKey,height:e.height,className:e.className,color:e.color})}),xt=({schema:e,onChartClick:t})=>{let{language:o}=(0,i.useObjectTranslation)(),s=n.default.useMemo(()=>{let t=ie(e,o),n=Array.isArray(e.series)?e.series:void 0,r=t.series??n,i=e.xAxisKey??t.xAxisKey,a=e.config;if(!a&&r){let t=e.colors||[`hsl(var(--chart-1))`,`hsl(var(--chart-2))`,`hsl(var(--chart-3))`],n={};r.forEach((e,r)=>{n[e.dataKey]={label:e.label||e.dataKey,color:e.color||t[r%t.length]}}),a=n}return{chartType:e.chartType??t.chartType,data:Array.isArray(e.data)?e.data:[],config:a,xAxisKey:i,series:r,className:e.className,spec:t}},[e,o]);return(0,a.jsx)(n.Suspense,{fallback:(0,a.jsx)(r.Skeleton,{className:`w-full h-48 sm:h-64 md:h-80 lg:h-[400px]`}),children:(0,a.jsx)(bt,{chartType:s.chartType,data:s.data,config:s.config,xAxisKey:s.xAxisKey,series:s.series,className:s.className,colors:Array.isArray(e.colors)?e.colors:void 0,categoryColors:e.categoryColors,categoryOrder:e.categoryOrder,isAnimationActive:e.isAnimationActive,onChartClick:t,xAxis:s.spec.xAxis,yAxes:s.spec.yAxes,showLegend:s.spec.showLegend,showDataLabels:s.spec.showDataLabels,title:s.spec.title,subtitle:s.spec.subtitle,description:s.spec.description,height:s.spec.height??e.height,annotations:s.spec.annotations,interaction:s.spec.interaction})})};k();function St(e){return(0,t.chartMeasureKey)(e,e.function||`count`)}var Q=[`aggregate.groupBy`,`xAxisKey`,`xAxis.field`];function Ct(e){let t=e?.aggregate?.groupBy;if(t&&typeof t==`object`&&!Array.isArray(t)){let e=t.field;return typeof e==`string`&&e?e:void 0}return typeof t==`string`&&t?t:ie(e).xAxisKey}var wt=`__comparison`;function Tt(e){let t=e?.groupBy;return t&&typeof t==`object`&&!Array.isArray(t)?t.alias||t.field:typeof t==`string`?t:void 0}function Et(e,t){let{field:n,function:r,groupBy:i}=t,a=St(t),o={};for(let t of e){let e=String(t[i]??`Unknown`);o[e]||(o[e]=[]),o[e].push(t)}return Object.entries(o).map(([e,t])=>{let o=n?t.map(e=>Number(e[n])||0):[],s;switch(r){case`count`:s=t.length;break;case`avg`:s=o.length>0?o.reduce((e,t)=>e+t,0)/o.length:0;break;case`min`:s=o.length>0?Math.min(...o):0;break;case`max`:s=o.length>0?Math.max(...o):0;break;default:s=o.reduce((e,t)=>e+t,0)}return{[i]:e,[a]:s}})}async function Dt(e,n,r,i,a){if(!e.length||!n)return e;let o=a||((e,t)=>t),s=`__raw_${n}`,c=r?.fields?.[n];if(!c){let r=/^\d{4}-\d{2}-\d{2}/;return e.map(e=>{let i=e[n],a=String(i??``),c=r.test(a)?a:(0,t.humanizeLabel)(a);return{...e,[n]:o(a,c),[s]:i}})}let l=c.type;if(l===`select`||l===`picklist`||l===`dropdown`){let r=c.options||[];if(r.length===0)return e.map(e=>{let r=e[n],i=String(r??``),a=(0,t.humanizeLabel)(i);return{...e,[n]:o(i,a),[s]:r}});let i={};for(let e of r)typeof e==`string`?i[e]=e:e&&typeof e==`object`&&(i[String(e.value)]=e.label||String(e.value));return e.map(e=>{let r=e[n],a=String(r??``),c=i[a]||(0,t.humanizeLabel)(a);return{...e,[n]:o(a,c),[s]:r}})}if(l===`lookup`||l===`master_detail`){let r=c.reference;if(!r||!i||typeof i.find!=`function`)return e.map(e=>({...e,[s]:e[n]}));let a=[...new Set(e.map(e=>e[n]).filter(e=>e!=null))];if(a.length===0)return e.map(e=>({...e,[s]:e[n]}));let o=c.id_field||`id`;try{let l=await i.find(r,{$filter:{[o]:{$in:a}},$top:a.length}),u=(0,t.extractRecords)(l),d=c.displayField||c.reference_field||`name`,f={};for(let e of u){let t=String(e[o]??e.id??e._id??``),n=e[d]||e.name||e.label||e.title||t;t&&(f[t]=String(n))}return e.map(e=>{let t=e[n],r=String(t??``);return{...e,[n]:f[r]||r,[s]:t}})}catch(t){return console.warn(`[ObjectChart] Failed to resolve lookup labels:`,t),e.map(e=>({...e,[s]:e[n]}))}}if(l===`date`||l===`datetime`||l===`date_time`||l===`timestamp`||l===`time`)return e.map(e=>({...e,[s]:e[n]}));let u=/^\d{4}-\d{2}-\d{2}/;return e.map(e=>{let r=e[n],i=String(r??``);return{...e,[n]:u.test(i)?i:(0,t.humanizeLabel)(i),[s]:r}})}var Ot=e=>{let{schema:o}=e,l=e.onSegmentClick,u=(0,n.useContext)(s.SchemaRendererContext),d=e.dataSource||u?.dataSource,f=u?.apiFetch,p=(0,s.useDataScope)(o.bind),{fieldOptionLabel:m}=(0,i.useSafeFieldLabel)(),[h,g]=(0,n.useState)([]),[_,ee]=(0,n.useState)(null),[v,te]=(0,n.useState)(void 0),[ne,re]=(0,n.useState)(()=>!(Array.isArray(o.data)&&o.data.length>0)&&(!!o.objectName||!!o.dataset)),[ae,oe]=(0,n.useState)(null),[y,b]=(0,n.useState)(null),[x,se]=(0,n.useState)(null),{openRecordList:ce}=(0,s.useDrillNavigation)(),S=(0,i.useSafeTranslate)(),{t:le,language:C}=(0,i.useObjectTranslation)(),w=(0,n.useMemo)(()=>ie(o,C).chartType,[o,C]),T=(0,n.useMemo)(()=>o.aggregate?JSON.stringify(o.aggregate):``,[o.aggregate]),E=(0,n.useMemo)(()=>o.filter?JSON.stringify(o.filter):``,[o.filter]),D=(0,n.useMemo)(()=>o.compareTo?JSON.stringify(o.compareTo):``,[o.compareTo]),O=(0,n.useMemo)(()=>o.dataset?JSON.stringify({d:o.dataset,dim:o.dimensions??[],val:o.values??[]}):``,[o.dataset,o.dimensions,o.values]);(0,n.useEffect)(()=>{let e=!1;return(async()=>{try{let n=f??fetch,r={headers:{accept:`application/json`},credentials:`include`},i=o.objectName,a,s=null;if(i)a=Ct(o);else if(o.dataset){let e=Array.isArray(o.dimensions)&&o.dimensions.length?o.dimensions[0]:void 0,t=await(await n(`/api/v1/meta/dataset/${encodeURIComponent(o.dataset)}`,r)).json().catch(()=>null);s=t?.item??t?.data??t,i=s?.object,a=((s?.dimensions||[]).find(t=>t?.name===e)??(s?.dimensions||[])[0])?.field??e}if(!i||!a){e||se(null);return}let c=async e=>{let t=await(await n(`/api/v1/meta/object/${encodeURIComponent(e)}`,r)).json().catch(()=>null);return t?.item??t?.data??t},l={};if(o.dataset&&Array.isArray(o.dimensions))for(let e of o.dimensions)l[e]=(s?.dimensions||[]).find(t=>t?.name===e)?.field??e;let u=await(0,t.loadDimensionFieldMeta)(c,i,[a,...Object.values(l)]);e||se({metaByPath:u,colorPath:a,fieldByDim:o.dataset&&Array.isArray(o.dimensions)?l:null})}catch{e||se(null)}})(),()=>{e=!0}},[o.objectName,o.dataset,O,T,o.xAxisKey,f]);let{fieldOptionColors:k,dimensionLabels:A}=(0,n.useMemo)(()=>{if(!x)return{fieldOptionColors:null,dimensionLabels:null};let{metaByPath:e,colorPath:n,fieldByDim:r}=x,i=(0,t.localizeFieldOptions)(e[n]?.options,(0,t.dimensionOptionTranslator)(e[n],m)),a=(0,t.deriveDimensionLabelMaps)(e,r?Object.entries(r).map(([e,t])=>({dim:e,path:t})):null,m);return{fieldOptionColors:(0,t.buildOptionColorMap)(i),dimensionLabels:a}},[x,m]),ue=(0,n.useCallback)(async(e,n)=>{if(o.aggregate&&typeof e.aggregate==`function`){let r=o.aggregate.groupBy;if((0,t.isStructuredGroupBy)(r)){let i=await e.aggregate(o.objectName,(0,t.objectAggregateSpecQuery)(o.aggregate,r,n));return Array.isArray(i)?i:[]}let i=await e.aggregate(o.objectName,{field:o.aggregate.field,function:o.aggregate.function,groupBy:r,filter:n});return Array.isArray(i)?i:[]}if(typeof e.find==`function`){let r=await e.find(o.objectName,{$filter:n}),i=(0,t.extractRecords)(r),a=Tt(o.aggregate);return o.aggregate&&a&&i.length>0&&(i=Et(i,{...o.aggregate,groupBy:a})),i}return[]},[o.objectName,T]),j=(0,s.useFilterScope)(),de=(0,n.useCallback)(async(e,n)=>{if(!e||!o.objectName&&!o.dataset){n.current&&re(!1);return}n.current&&(re(!0),oe(null));try{if(o.dataset&&typeof e.queryDataset==`function`){let r=(0,t.resolveFilterPlaceholders)(o.filter,j),i=await e.queryDataset(o.dataset,{dimensions:Array.isArray(o.dimensions)?o.dimensions:[],measures:Array.isArray(o.values)?o.values:[],...r?{runtimeFilter:r}:{}});n.current&&(g(Array.isArray(i?.rows)?i.rows:[]),ee(Array.isArray(i?.fields)?i.fields:null),te(typeof i?.object==`string`&&i.object?i.object:void 0));return}let r=(0,t.resolveFilterPlaceholders)(o.filter,j),i=o.compareTo,a=!!i&&!(0,t.chartTypeIgnoresCompareTo)(w),s=a?(0,t.resolveContextTokens)((0,t.shiftFilterByCompareTo)(o.filter,i),j):null,[c,l]=await Promise.all([ue(e,r),s?ue(e,s):Promise.resolve([])]),u=c,d=Tt(o.aggregate)||o.xAxisKey;if(a&&l.length>0&&o.aggregate){let e=o.aggregate.field,t=o.aggregate.function,n=St(o.aggregate),r=r=>{if(r==null)return null;if(e){let n=`${e}_${t}`;if(n in r)return Number(r[n]);if(t===`count`&&`${e}_count`in r)return Number(r[`${e}_count`])}return n in r?Number(r[n]):`value`in r?Number(r.value):`count`in r?Number(r.count):null},i=`${n}${wt}`,a=d;if(a&&u.some(e=>e[a]!=null)&&l.some(e=>e[a]!=null)){let e=new Map;for(let t of l){let n=String(t[a]??``);e.set(n,r(t))}u=u.map(t=>{let n=String(t[a]??``),r=e.get(n);return r==null?t:{...t,[i]:r}});let t=new Set(u.map(e=>String(e[a]??``)));for(let e of l){let n=String(e[a]??``);t.has(n)||u.push({[a]:n,[i]:r(e)})}}else{let e=Math.max(u.length,l.length),t=[];for(let n=0;n<e;n++){let e=u[n]||{},a=l[n];t.push(a?{...e,[i]:r(a)}:e)}u=t}}if(d&&o.objectName&&typeof e.getObjectSchema==`function`){let t=o.objectName;try{let n=await e.getObjectSchema(t);u=await Dt(u,d,n,e,(e,n)=>m(t,d,e,n))}catch{}}n.current&&g(u)}catch(e){console.error(`[ObjectChart] Fetch error:`,e),n.current&&oe(e instanceof Error?e.message:`Failed to load chart data`)}finally{n.current&&re(!1)}},[o.objectName,O,T,E,D,o.xAxisKey,w,ue,j,m]),fe=!!(o.objectName||o.dataset)&&!p&&!o.data,pe=(0,s.useDataInvalidation)(fe?o.dataset?v:o.objectName:void 0);(0,n.useEffect)(()=>{let e={current:!0};return fe?de(d,e):e.current&&re(!1),()=>{e.current=!1}},[o.objectName,O,d,p,o.data,E,T,D,de,pe]);let M=p||o.data||h,N=Array.isArray(M)?M:[],P=o.drillDown,F=Tt(o.aggregate)||o.xAxisKey,I=(0,n.useMemo)(()=>{if(!F)return new Map;let e=new Map,t=`__raw_${F}`;for(let n of N){let r=n?.[F];if(r==null)continue;let i=t in(n||{})?n[t]:r;e.set(String(r),i)}return e},[N,F]),L=(0,n.useMemo)(()=>{if(y)try{return{ok:!0,filter:(0,t.composeDrillFilter)(o.filter,(0,t.computeDrillFilter)(P,y,{groupByField:F}))}}catch(e){if(!(e instanceof t.FilterOperatorError))throw e;return{ok:!1,refusal:e}}},[y,P,F,E]),me=L?.ok?L.filter:void 0,he=L?.ok===!1,R=L?.ok===!1?L.refusal.message:void 0;(0,n.useEffect)(()=>{R&&console.warn(`[ObjectChart] drill-down refused — the drilled list cannot be scoped: ${R}`)},[R]);let z=!l&&!!y&&!he&&!!o.objectName&&P?.target===`navigate`&&!!ce;(0,n.useEffect)(()=>{z&&(ce(o.objectName,me),b(null))},[z]);let B=o.compareTo,ge=o.aggregate?St(o.aggregate):void 0,V=ge?`${ge}${wt}`:void 0,_e=!!B&&!(0,t.chartTypeIgnoresCompareTo)(w)&&!!V&&N.some(e=>e[V]!=null),ve=(0,n.useMemo)(()=>{let e=Array.isArray(o.series)?o.series:null;if(!_e)return e;let n=e||[{dataKey:ge}],r={vsLastWeek:`Previous week`,vsLastMonth:`Previous month`,vsLastQuarter:`Previous quarter`,vsLastYear:`Previous year`,vsYesterday:`Yesterday`,vsPreviousPeriod:`Previous period`}[(0,t.compareToTrendLabelKey)(B,o.filter)]||`Previous period`;return[...n.map(e=>({...e,variant:e.variant||`current`})),{dataKey:V,label:r,variant:`comparison`}]},[_e,o.series,ge,V,o.filter,B]),ye=o.dataset?(0,t.buildChartSeries)((0,t.relabelDimensions)(N,A),o.dimensions,o.values,_,{nullCategoryLabel:S(`chart.nullCategory`,`(None)`),builtinAggregateLabels:(0,i.builtinAggregateLabels)(S)}):null,be=!!p||Array.isArray(o.data),xe=!!o.objectName&&!o.dataset&&!be,Se=xe&&!ie(o,C).xAxisKey?Tt(o.aggregate):void 0,Ce=ye?{...o,data:ye.data,xAxisKey:ye.xAxisKey,series:ye.series}:{...o,data:N,...Se?{xAxisKey:Se}:{},...ve?{series:ve}:{}},we=o.colors&&!Array.isArray(o.colors)&&typeof o.colors==`object`?o.colors:null,Te=Array.isArray(o.colors)?o.colors:void 0,Ee=k||we?{...k||{},...we||{}}:void 0,De={...Ce,colors:Te,...Ee?{categoryColors:Ee}:{}};if(xe&&!Ct(o))return(0,a.jsxs)(`div`,{className:`p-4 text-destructive `+(o.className||``),"data-testid":`chart-missing-category-axis`,role:`alert`,children:[S(`chart.unconfigured.noCategoryAxis`,`Chart category axis required — an object-bound chart will not invent one. Declare one of:`),` `,Q.map((e,t)=>(0,a.jsxs)(n.default.Fragment,{children:[t>0?`, `:``,(0,a.jsx)(`code`,{className:`font-mono`,children:e})]},e))]});if(ne&&N.length===0)return(0,a.jsxs)(`div`,{className:`p-2 `+(o.className||``),"data-testid":`chart-loading`,role:`status`,"aria-busy":`true`,"aria-live":`polite`,children:[(0,a.jsx)(`span`,{className:`sr-only`,children:`Loading chart data…`}),(0,a.jsx)(r.ChartSkeleton,{className:`h-full`})]});if(ae)return(0,a.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-2 p-4 `+(o.className||``),"data-testid":`chart-error`,role:`alert`,children:[(0,a.jsx)(c.AlertCircle,{className:`h-6 w-6 text-destructive opacity-60`}),(0,a.jsx)(`p`,{className:`text-xs text-destructive font-medium`,children:`Failed to load chart data`}),(0,a.jsx)(`p`,{className:`text-xs text-muted-foreground max-w-xs text-center`,children:ae})]});if(!d&&o.objectName&&N.length===0)return(0,a.jsxs)(`div`,{className:`flex items-center justify-center text-muted-foreground text-sm p-4 `+(o.className||``),"data-testid":`chart-no-datasource`,children:[`No data source available for “`,o.objectName,`”`]});if((o.objectName||o.dataset)&&!p&&!o.data&&N.length===0)return(0,a.jsx)(r.DataEmptyState,{role:`status`,"data-testid":`chart-empty-state`,className:`h-full w-full gap-2 p-4 [&>h3]:text-sm [&>h3]:font-medium [&>p]:text-xs `+(o.className||``),icon:(0,a.jsx)(c.Inbox,{className:`h-5 w-5 text-muted-foreground/70`}),iconWrapperClassName:`flex size-9 items-center justify-center rounded-lg bg-muted`,title:S(`dashboard.empty.title`,`No data yet`),description:S(`dashboard.empty.message`,`This widget loaded successfully and its query returned no records yet.`),children:(0,a.jsxs)(`p`,{className:`text-xs text-muted-foreground/80`,"data-testid":`chart-empty-source`,children:[(0,a.jsx)(`span`,{children:S(`dashboard.empty.sourceLabel`,`Source:`)}),` `,(0,a.jsx)(`span`,{className:`font-mono`,children:o.dataset||o.objectName})]})});let Oe=(0,t.isDrillEnabled)(P)?e=>{let t=e.category,n=t!=null&&I.has(String(t))?I.get(String(t)):t;b({...e,category:n,categoryLabel:t,scope:`cell`})}:void 0,ke=l??Oe,Ae=!l&&y&&!he&&o.objectName&&!z?(()=>{let e=me??{},n=(0,t.resolveDrillTitle)(P,y,(0,i.pickLocalized)(o.title,C)||`Details`),l=P?.target??`drawer`,u={type:`object-data-table`,objectName:o.objectName,filter:e,pagination:!0,pageSize:P?.maxRows,columns:P?.columns?.map(e=>({accessorKey:e,header:e})),drillDown:{enabled:!0,mode:`record`,target:`dialog`}},f=(0,a.jsx)(`div`,{className:`overflow-auto`,"data-testid":`chart-drill-body`,children:(0,a.jsx)(s.SchemaRenderer,{schema:u,dataSource:d})}),p=ce&&o.objectName?(0,a.jsxs)(r.Button,{type:`button`,variant:`ghost`,size:`sm`,"data-testid":`drill-open-in-list`,onClick:()=>{ce(o.objectName,e),b(null)},children:[S(`dashboard.openInList`,`Open in list`),(0,a.jsx)(c.ArrowUpRight,{className:`ml-1 h-3.5 w-3.5`})]}):null;return l===`dialog`?(0,a.jsx)(r.Dialog,{open:!0,onOpenChange:e=>!e&&b(null),children:(0,a.jsxs)(r.DialogContent,{className:`max-w-4xl`,children:[(0,a.jsxs)(r.DialogHeader,{className:`flex-row items-center justify-between gap-4 pr-8`,children:[(0,a.jsx)(r.DialogTitle,{children:n}),p]}),f]})}):(0,a.jsx)(r.Sheet,{open:!0,onOpenChange:e=>!e&&b(null),children:(0,a.jsxs)(r.SheetContent,{side:`right`,className:`w-full sm:max-w-2xl md:max-w-3xl lg:max-w-4xl flex flex-col`,children:[(0,a.jsxs)(r.SheetHeader,{className:`flex-row items-center justify-between gap-4 pr-8`,children:[(0,a.jsx)(r.SheetTitle,{children:n}),p]}),(0,a.jsx)(`div`,{className:`flex-1 overflow-hidden mt-2`,children:f})]})})})():null;return(0,a.jsxs)(`div`,{className:`relative h-full`,children:[(0,a.jsx)(r.RefreshIndicator,{active:ne&&N.length>0,ariaLabel:le(`chart.refreshing`)}),(0,a.jsx)(xt,{...e,schema:De,onChartClick:ke}),Ae]})},kt={filter:!0},$=(0,t.elementDataSourceBlock)(e=>(0,a.jsx)(s.ElementDataSourceGate,{schema:e.schema,mapping:kt,dataSource:e.dataSource,testId:`object-chart`,errorTitle:`This chart’s data source could not be resolved`,children:t=>(0,a.jsx)(Ot,{...e,schema:t})}));t.ComponentRegistry.register(`object-chart`,$,{namespace:`plugin-charts`,label:`Object Chart`,category:`view`,inputs:[{name:`objectName`,type:`string`,required:!0},{name:`data`,type:`array`,description:`Optional static data`},{name:`filter`,type:`array`},{name:`aggregate`,type:`object`,description:`Aggregation config: { field, function, groupBy }`},{name:`drillDown`,type:`object`,description:`Segment drill config: { enabled?, filter?, title?, target?: 'drawer' | 'dialog', columns?, maxRows? }. Present = on; {} is enough. Clicking a segment opens the underlying records filtered by the clicked category.`}]}),k();var At={"bar-chart":Z,chart:xt};t.ComponentRegistry.register(`bar-chart`,Z,{namespace:`plugin-charts`,label:`Bar Chart`,category:`plugin`,inputs:[{name:`data`,type:`array`,required:!0},{name:`dataKey`,type:`string`},{name:`xAxisKey`,type:`string`},{name:`height`,type:`number`},{name:`color`,type:`color`}],defaultProps:{data:[{name:`Jan`,value:400},{name:`Feb`,value:300},{name:`Mar`,value:600},{name:`Apr`,value:800},{name:`May`,value:500}],dataKey:`value`,xAxisKey:`name`,height:400,color:`#8884d8`}}),t.ComponentRegistry.register(`chart`,$,{namespace:`view`,category:`view`,label:`Chart`,skipFallback:!0,inputs:[{name:`objectName`,type:`string`,required:!0},{name:`type`,type:`string`},{name:`categoryField`,type:`string`},{name:`valueField`,type:`string`}]}),t.ComponentRegistry.register(`chart`,xt,{namespace:`plugin-charts`,label:`Chart`,category:`plugin`,inputs:[{name:`chartType`,type:`enum`,enum:[{label:`Bar`,value:`bar`},{label:`Line`,value:`line`},{label:`Area`,value:`area`},{label:`Pie`,value:`pie`},{label:`Donut`,value:`donut`},{label:`Radar`,value:`radar`},{label:`Scatter`,value:`scatter`}]},{name:`data`,type:`code`,required:!0},{name:`config`,type:`code`},{name:`xAxisKey`,type:`string`},{name:`series`,type:`code`,required:!0},{name:`className`,type:`string`}],defaultProps:{chartType:`bar`,data:[{name:`Jan`,sales:400,revenue:240},{name:`Feb`,sales:300,revenue:139},{name:`Mar`,sales:600,revenue:380},{name:`Apr`,sales:800,revenue:430},{name:`May`,sales:500,revenue:220}],config:{sales:{label:`Sales`,color:`#8884d8`},revenue:{label:`Revenue`,color:`#82ca9d`}},xAxisKey:`name`,series:[{dataKey:`sales`},{dataKey:`revenue`}]}}),t.ComponentRegistry.register(`chart:bar`,xt,{namespace:`plugin-charts`,label:`Bar Chart (Alias)`,category:`plugin`}),e.ChartBarRenderer=Z,e.ChartRenderer=xt,e.ObjectChart=Ot,e.ObjectChartBlock=$,e.chartComponents=At,e.normalizeChartSchema=ie});
7
+ `)}}):null},L=o.Tooltip,R=o.Legend}));function be(e){return e?.[0]?.dataKey||`value`}function xe(e,t,n){if(!e)return null;let r=e.payload??e,i=r?.[t];if(i==null)return null;let a=be(n);return{category:String(i),series:a,value:typeof r?.[a]==`number`?r[a]:void 0}}function Se(e,t){if(!e)return null;let n=e.name??e.payload?.name??e.root?.name;if(n==null)return null;let r=e.value??e.size??e.payload?.size;return{category:String(n),series:be(t),value:typeof r==`number`?r:void 0}}function Ce(e,t){if(!e)return null;let n=e.payload??e,r=n?.name;return r==null||n?.depth===0?null:{category:String(r),series:be(t),value:typeof n?.value==`number`?n.value:void 0}}var we=h((()=>{})),z=g({default:()=>H});function Te(e){let t=0;for(let n of e)t+=vt.test(n)?1:J;return t*q}function Ee(e,t){if(e.length===0||t<=0)return!1;let n=t/e.length;return e.reduce((e,t)=>Math.max(e,Te(t)),0)+Y<=n}function De(e){let t=gt*Math.PI/180,n=e.reduce((e,t)=>Math.max(e,Te(t)),0);return Math.ceil(16+q*Math.cos(t)+n*Math.sin(t))}function Oe(e){return e===`top`?Tt:wt}function ke(e){return e===`right`?Et:Ct}function Ae(e,t){return e?t?e===`left`||e===`right`?{down:e}:{refused:e}:e===`top`||e===`bottom`?{across:e}:{refused:e}:{}}function je(e,t){return e?(0,a.jsxs)(`p`,{role:`note`,"data-chart-note":`x-axis-position`,className:`px-1 text-xs text-muted-foreground`,children:[(0,a.jsx)(`code`,{className:`font-mono`,children:`xAxis.position`}),` is`,` `,(0,a.jsx)(`code`,{className:`font-mono`,children:e}),` —`,` `,t?(0,a.jsx)(a.Fragment,{children:`this chart's categories run down its side, so its x axis sits on the left or the right. It is drawn on the left.`}):(0,a.jsx)(a.Fragment,{children:`this chart's x axis runs across it, so it sits at the top or the bottom. It is drawn at the bottom.`})]}):null}function Me(e,t){return t?e===`left`?`bottom`:`top`:e}function Ne(e){return e===`left`||e===`right`?`on the ${e}`:`at the ${e}`}function Pe(e,t){return e?t?kt:Ot:Dt}function Fe(e,t){if(e.notes.length===0)return null;let n=t?`this chart's value axes run across it, so each sits at the bottom or the top.`:`this chart's value axes run up its side, so each sits on the left or the right.`;return Le(...e.notes.map(e=>{let r=Ne(Me(e.drawn,t));return(0,a.jsxs)(`p`,{role:`note`,"data-chart-note":`y-axis-position`,className:`px-1 text-xs text-muted-foreground`,children:[(0,a.jsx)(`code`,{className:`font-mono`,children:`yAxis[${e.index}].position`}),` is`,` `,(0,a.jsx)(`code`,{className:`font-mono`,children:e.position}),` —`,` `,e.reason===`side`?(0,a.jsxs)(a.Fragment,{children:[n,` It is drawn `,r,`.`]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(`code`,{className:`font-mono`,children:`yAxis[0]`}),` already sits `,Ne(e.position),`, so this axis is drawn `,r,`.`]})]},e.index)}))}function Ie(e,t,n){if(e.undrawn.length===0)return null;let r=e.slotOf.length===1,i=n?`one at the bottom and one at the top`:`one on each side`;return Le(...e.undrawn.map(o=>{let s=e[o.boundTo];if(r)return(0,a.jsxs)(`p`,{role:`note`,"data-chart-note":`y-axis-undrawn`,className:`px-1 text-xs text-muted-foreground`,children:[(0,a.jsx)(`code`,{className:`font-mono`,children:`yAxis[${o.index}]`}),` is not drawn — this chart draws one value axis`,s===void 0?null:(0,a.jsxs)(a.Fragment,{children:[`, `,(0,a.jsx)(`code`,{className:`font-mono`,children:`yAxis[${s}]`})]}),`.`]},o.index);let c=t?.[o.index]?.field;return(0,a.jsxs)(`p`,{role:`note`,"data-chart-note":`y-axis-undrawn`,className:`px-1 text-xs text-muted-foreground`,children:[(0,a.jsx)(`code`,{className:`font-mono`,children:`yAxis[${o.index}]`}),` is not drawn — this chart draws at most two value axes, `,i,`.`,c?(0,a.jsxs)(a.Fragment,{children:[` `,`When the chart declares neither `,(0,a.jsx)(`code`,{className:`font-mono`,children:`series`}),` nor`,` `,(0,a.jsx)(`code`,{className:`font-mono`,children:`categories`}),`, its field `,(0,a.jsx)(`code`,{className:`font-mono`,children:c}),` is plotted against the axis `,Ne(Me(o.boundTo,n)),s===void 0?null:(0,a.jsxs)(a.Fragment,{children:[`, `,(0,a.jsx)(`code`,{className:`font-mono`,children:`yAxis[${s}]`})]}),`.`]}):null]},o.index)}))}function Le(...e){let t=e.filter(e=>e!=null&&e!==!1);return t.length<=1?t[0]??null:(0,a.jsx)(a.Fragment,{children:t.map((e,t)=>(0,a.jsx)(n.Fragment,{children:e},t))})}function Re(e,t,n){if(!e)return{};let r=b(e),i=ce(e,t);return{...i?{ticks:i}:{},...r?{domain:r}:{},...r?{allowDataOverflow:!0}:{},...e.logarithmic?{scale:`log`,domain:r??[1,`auto`]}:{},...e.title?{label:{value:e.title,...n}}:{}}}function ze(e){let{x:t,y:n,width:r,height:i,name:o,fill:s}=e;return r<=0||i<=0?null:(0,a.jsxs)(`g`,{children:[(0,a.jsx)(`rect`,{x:t,y:n,width:r,height:i,fill:s,stroke:`hsl(var(--background))`,strokeWidth:2}),r>48&&i>18?(0,a.jsx)(`text`,{x:t+6,y:n+18,fill:`#fff`,fontSize:12,className:`pointer-events-none`,children:o}):null]})}function Be({title:e,subtitle:t,children:n}){return!e&&!t?(0,a.jsx)(a.Fragment,{children:n}):(0,a.jsxs)(`div`,{className:`flex h-full w-full flex-col`,children:[(0,a.jsxs)(`div`,{className:`mb-2 shrink-0`,children:[e?(0,a.jsx)(`div`,{className:`text-sm font-medium leading-tight text-foreground`,children:e}):null,t?(0,a.jsx)(`div`,{className:`text-xs leading-tight text-muted-foreground`,children:t}):null]}),(0,a.jsx)(`div`,{className:`min-h-0 flex-1`,children:n})]})}function Ve({note:e,children:t}){return e?(0,a.jsxs)(`div`,{className:`flex h-full w-full flex-col`,children:[(0,a.jsx)(`div`,{className:`min-h-0 flex-1`,children:t}),(0,a.jsx)(`div`,{className:`mt-1 shrink-0`,children:e})]}):(0,a.jsx)(a.Fragment,{children:t})}function He(e,t){let n=0;for(let r of e){let e=Number(r?.[t]);Number.isFinite(e)&&e>0&&(n+=1)}return{sizable:n,total:e.length}}function Ue({dataKey:e,className:t}){return(0,a.jsxs)(V,{code:`no-positive-magnitude`,className:t,children:[`This chart has nothing to size: no row's`,` `,(0,a.jsx)(`code`,{className:`font-mono`,children:e}),` is above zero.`]})}function We(e,t,n){let r=t-e;return r<=0?null:(0,a.jsxs)(`p`,{role:`note`,"data-chart-note":`unsized-rows`,className:`px-1 text-xs text-muted-foreground`,children:[r,` of `,t,` rows `,r===1?`has`:`have`,` no`,` `,(0,a.jsx)(`code`,{className:`font-mono`,children:n}),` above zero — this chart sizes by value, so`,` `,r===1?`that row is`:`those rows are`,` not drawn to scale.`]})}function Ge(e){return e!=null&&Number.isFinite(Number(e))}function Ke(e,t,n){let r=0;for(let i of e){let e=i;Ge(e?.[t])&&Ge(e?.[n])&&(r+=1)}return{plottable:r,total:e.length}}function qe({xKey:e,yKey:t,className:n}){return(0,a.jsxs)(V,{code:`no-plottable-points`,className:n,children:[`This chart has nothing to place: no row carries a number for both`,` `,(0,a.jsx)(`code`,{className:`font-mono`,children:e}),` and`,` `,(0,a.jsx)(`code`,{className:`font-mono`,children:t}),`.`]})}function Je(e){return typeof e==`boolean`?!1:Array.isArray(e)?Ye(e[0])&&Ye(e[1]):Ye(e)}function Ye(e){return typeof e==`number`||e instanceof Number||typeof e==`string`||e instanceof Date?Number.isFinite(Number(e)):!1}function Xe(e){let t=e=>typeof e==`number`&&Number.isFinite(e);return t(e?.min)&&t(e?.max)||t(e?.stepSize)}function Ze(e,t){return e.some(e=>Je(e?.[t]))}function Qe(e,t,n){let r=t[n];if(!r?.stack)return`none`;let i=v(e,t),a=i===`combo`?r.chartType||se(e)||(n===0?`bar`:`line`):i;return a===`line`?`none`:a===`area`?`area`:`bar`}function $e({keys:e,total:t,className:r}){return(0,a.jsxs)(V,{code:`no-numeric-value`,className:r,children:[`This chart has no scale to draw on:`,` `,t===1?`its only row has no`:`none of the ${t} rows has a`,` numeric value for`,` `,e.map((e,t)=>(0,a.jsxs)(n.Fragment,{children:[t>0?` or `:``,(0,a.jsx)(`code`,{className:`font-mono`,children:e})]},`${t}-${e}`)),`.`]})}function et({seriesKeys:e,className:t}){let r=(0,i.useSafeTranslate)();return(0,a.jsxs)(V,{code:`scatter-multi-series`,className:t,children:[r(`chart.scatterOneMeasure`,`A scatter plots one measure. Keep exactly one series:`),` `,e.map((e,t)=>(0,a.jsxs)(n.Fragment,{children:[t>0?`, `:``,(0,a.jsx)(`code`,{className:`font-mono`,children:e})]},`${t}-${e}`))]})}function tt(e,t,n,r){let i=t-e;return i<=0?null:(0,a.jsxs)(`p`,{role:`note`,"data-chart-note":`unplotted-points`,className:`px-1 text-xs text-muted-foreground`,children:[i,` of `,t,` rows `,i===1?`has`:`have`,` no number for both`,` `,(0,a.jsx)(`code`,{className:`font-mono`,children:n}),` and`,` `,(0,a.jsx)(`code`,{className:`font-mono`,children:r}),` — this chart plots by position, so`,` `,i===1?`that point is`:`those points are`,` not drawn.`]})}function nt({chartType:e,data:r=[],config:s={},xAxisKey:c=`name`,series:l=[],className:u=``,colors:d,categoryColors:f,categoryOrder:p,onChartClick:m,isAnimationActive:h,xAxis:g,yAxes:_,showLegend:ee,showDataLabels:ne,title:re,subtitle:ie,description:oe,height:ce,annotations:b,interaction:S}){let de=e===`column`?`bar`:e,C=v(de,l),w=se(de),T=Array.isArray(r)?r:[],E=(0,i.useDisplayLocale)(),D=h===!1?{isAnimationActive:!1}:{},O={...h===!1?{disableSettleRemount:!0}:{},...ce?{style:{height:ce}}:{},...oe?{role:`img`,"aria-label":oe}:{}},[k,fe]=n.useState(!1),[pe,me]=n.useState(null),[he,ge]=n.useState(void 0);n.useEffect(()=>{if(pe==null||typeof ResizeObserver>`u`)return;let e=new ResizeObserver(e=>{let t=e[0]?.contentRect.width;t!=null&&t>0&&ge(Math.round(t))});return e.observe(pe),()=>e.disconnect()},[pe]);let M=n.useRef(null),N=n.useCallback(e=>(...t)=>{let n=ft(t);n!==void 0&&(M.current={gesture:n,dataKey:String(e.dataKey)})},[]),P=m?e=>({onClick:N(e)}):()=>({}),F=n.useCallback((e,n,r)=>{if(!m||!e)return;let i=e.activeTooltipIndex??e.activeIndex,a=i==null?NaN:Number(i),o=Number.isInteger(a)&&a>=0?T[a]:void 0,s=M.current;M.current=null;let c=dt(n),u=s!=null&&c!==void 0&&s.gesture===c;if(r&&!u)return;let d=u?s.dataKey:ut(e.activeDataKey,l),f=d!=null&&o?o[d]:void 0;m({category:e.activeLabel==null?void 0:String(e.activeLabel),categoryId:(0,t.chartRowBucketId)(o),series:d,seriesLabel:pt(d,l),value:typeof f==`number`?f:void 0})},[m,T,l]),I=n.useCallback((e,t)=>{F(e,t,!1)},[F]),ve=n.useCallback((e,t)=>{F(e,t,!0)},[F]),ye=n.useCallback(e=>{if(!m||!e)return;let n=e.payload?.[c],r=l[0]?.dataKey||`value`;m({category:n==null?void 0:String(n),categoryId:(0,t.chartRowBucketId)(e.payload),series:r,seriesLabel:pt(r,l),value:typeof e.payload?.[r]==`number`?e.payload[r]:void 0})},[m,c,l]),be=m?{onClick:I,style:{cursor:`pointer`}}:{},we=m?{onClick:ve}:{},z=m?e=>({...P(e),cursor:`pointer`}):()=>({}),Te=m?{onClick:ye,style:{cursor:`pointer`}}:{},Me=n.useCallback((e,t,n)=>f&&f[e==null?``:String(e)]||n[t%n.length],[f]),Ne=n.useCallback(e=>{if(!m)return;let t=xe(e,c,l);t&&m(t)},[m,c,l]),Ge=n.useCallback(e=>{if(!m)return;let t=Se(e,l);t&&m(t)},[m,l]),Je=n.useCallback(e=>{if(!m)return;let t=Ce(e,l);t&&m(t)},[m,l]),Ye=m?{onClick:Ne,cursor:`pointer`}:{},Qe=m?{onClick:Ge,style:{cursor:`pointer`}}:{},nt=m?{onClick:Je,style:{cursor:`pointer`}}:{};n.useEffect(()=>{let e=()=>fe(window.innerWidth<640);return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let rt=n.useCallback(e=>{if(e==null||e===``)return``;let n=s?.[String(e)]?.label;if(n!=null)return String(n);let r=typeof e==`string`?e:String(e);if(/^\d{4}-\d{2}-\d{2}/.test(r)){let e=(0,t.toDisplayDate)(r);if(!Number.isNaN(e.getTime())){let n=(T.length>1?Math.abs(new Date(String(T[T.length-1][c]??``)).getTime()-new Date(String(T[0][c]??``)).getTime()):0)/864e5;try{return n<=62?e.toLocaleDateString(E,{month:`short`,day:`numeric`}):e.toLocaleDateString(E,{month:`short`,year:`numeric`})}catch{return(0,t.isRealCalendarDate)(r)?(0,t.toDateInputValue)(e):e.toISOString().slice(0,10)}}}return k&&r.length>8?r.slice(0,8)+`…`:r},[T,c,k,s,E]),it=n.useMemo(()=>T.some(e=>String(e[c]||``).length>5),[T,c]),at=T.length>0&&T.length<=mt,ot=()=>Array.isArray(d)&&d.length>0?d:[`hsl(var(--chart-1))`,`hsl(var(--chart-2))`,`hsl(var(--chart-3))`,`hsl(var(--chart-4))`,`hsl(var(--chart-5))`],st=n.useCallback(e=>{if(e==null||e===``)return``;let t=typeof e==`number`?e:Number(e);if(!Number.isFinite(t))return String(e);try{return new Intl.NumberFormat(E,{notation:`compact`,maximumFractionDigits:1}).format(t)}catch{return String(t)}},[E]),B=_?.[0],H=C===`horizontal-bar`,U=ae(_,C),G=U.left===void 0?void 0:_?.[U.left],q=U.right===void 0?void 0:_?.[U.right],J=!!G&&!!q,vt=C===`combo`||J,Y=U.slotOf[0]??`left`,X=Le(Fe(U,H),Ie(U,_,H)),Ct=e=>J?e.yAxis===`right`?q:G:B,Et=n.useMemo(()=>y(g?.format,E)??rt,[g?.format,E,rt]),Dt=he===void 0?void 0:Ee(T.map(e=>String(Et(e?.[c])??``)),he-yt-(C===`combo`||J?2:1)*bt),Ot=(at||!k)&&it&&Dt!==!0,kt=n.useMemo(()=>Ot?e=>{let t=String(Et(e)??``);return t.length>ht?`${t.slice(0,11)}…`:t}:Et,[Ot,Et]),At=Ot?De(T.map(e=>String(kt(e?.[c])??``))):void 0,jt=n.useMemo(()=>y(B?.format,E)??st,[B?.format,E,st]),Mt=n.useMemo(()=>y(G?.format,E)??st,[G?.format,E,st]),Nt=n.useMemo(()=>y(q?.format,E)??st,[q?.format,E,st]),Pt=n.useCallback(e=>l.filter(t=>!J||(t.yAxis===`right`?`right`:`left`)===e),[l,J]),Z=n.useCallback(e=>{let t=Pt(e).map(e=>e.dataKey),n=[];for(let e of T)for(let r of t){let t=Number(e?.[r]);Number.isFinite(t)&&n.push(t)}return n},[T,Pt]),Q=n.useCallback((e,t=`left`,n)=>({...te(Pt(t))?{allowDecimals:!1}:{},...Re(e,Z(t),n??ke(t))}),[Z,Pt]),Ft=B?.showGridLines!==!1,It={vertical:g?.showGridLines===!0,horizontal:Ft},{across:$,down:Lt,refused:Rt}=Ae(g?.position,H),zt=je(Rt,H),Bt=ee!==!1,Vt=n.useMemo(()=>{if(!Array.isArray(b)||b.length===0)return null;let e={solid:void 0,dashed:`4 4`,dotted:`1 4`},t=Pe(vt,H);return b.map((n,r)=>{let i=n?.axis===`x`,s=W(String(n?.color||`hsl(var(--muted-foreground))`)),c=e[String(n?.style??`dashed`)],l=typeof n?.label==`string`?n.label:void 0,u=l?{label:{value:l,position:`insideTopRight`,fill:s,fontSize:11}}:{};if(n?.type===`region`){let e=i?{x1:n.value,x2:n.endValue}:{y1:n.value,y2:n.endValue};return(0,a.jsx)(o.ReferenceArea,{...e,...t,fill:s,fillOpacity:.12,stroke:s,strokeOpacity:.35,...u},`ann-${r}`)}return(0,a.jsx)(o.ReferenceLine,{...i?{x:n?.value}:{y:n?.value},...t,stroke:s,strokeDasharray:c,...u},`ann-${r}`)})},[b,vt,H]),Ht=S?.tooltips!==!1,Ut=S?.brush===!0?(0,a.jsx)(o.Brush,{dataKey:c,height:24,travellerWidth:8,stroke:`hsl(var(--muted-foreground))`}):null,Wt=e=>ne?(0,a.jsx)(o.LabelList,{position:`top`,className:`fill-foreground`,fontSize:11,...e?{formatter:e}:{}}):null,Gt=n.useMemo(()=>({tick:K,tickLine:!1,tickMargin:_t,axisLine:!1,...at?{interval:0}:{interval:`preserveStartEnd`,minTickGap:0},tickFormatter:kt,...$?{orientation:$}:{},...g?.title?{label:{value:g.title,...Oe($)}}:{},...Ot&&{angle:$===`top`?gt:-35,textAnchor:`end`,height:At}}),[at,Ot,kt,g?.title,$,At]);if(C&&x.has(C)){let e=l[0]?.dataKey||`value`,t=T[0]?.[e],n=typeof t==`number`?t:Number(t),r=l[0]?.label??s?.[e]?.label??e;return(0,a.jsx)(`div`,{className:u,"data-testid":`advanced-chart-single-value`,children:(0,a.jsxs)(`div`,{className:`flex flex-col gap-1 py-4`,children:[(0,a.jsx)(`span`,{className:`text-3xl font-semibold tabular-nums`,children:Number.isFinite(n)?new Intl.NumberFormat(E).format(n):String(t??`—`)}),(0,a.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:String(r)})]})})}if(C&&ue.has(C))return(0,a.jsxs)(`div`,{className:`rounded-md border border-dashed bg-muted/20 px-3 py-2 text-xs text-muted-foreground ${u??``}`,"data-testid":`advanced-chart-tabular-notice`,role:`note`,children:[`Chart type “`,C,`” is tabular — render it with the data-table / pivot components; a chart block draws series charts.`]});if(!C||!le.has(C))return(0,a.jsx)(`div`,{className:`rounded-md border border-dashed bg-muted/20 px-3 py-2 text-xs text-muted-foreground ${u??``}`,"data-testid":`advanced-chart-unknown-type`,role:`note`,children:C?(0,a.jsxs)(a.Fragment,{children:[`Chart type “`,C,`” is not a spec chart type — nothing was drawn.`]}):(0,a.jsx)(a.Fragment,{children:`This chart names no chart type — nothing was drawn.`})});let Kt={bar:o.BarChart,"horizontal-bar":o.BarChart,line:o.LineChart,area:o.AreaChart,pie:o.PieChart,donut:o.PieChart,radar:o.RadarChart,scatter:o.ScatterChart,funnel:o.FunnelChart,combo:o.ComposedChart,treemap:o.BarChart,sankey:o.BarChart}[C]||o.BarChart;if(C===`pie`||C===`donut`){let e=C===`donut`?`52%`:0,t=ot(),n=l[0]?.dataKey||`value`,r=He(T,n);if(r.total>0&&r.sizable===0)return(0,a.jsx)(Ue,{dataKey:n,className:u});let i={...s};T.forEach((e,n)=>{let r=e?.[c];if(r==null||r===``)return;let a=String(r);i[a]||(i[a]={label:a,color:Me(r,n,t)})});let d=(0,a.jsx)(A,{config:i,className:u,...O,children:(0,a.jsxs)(o.PieChart,{children:[(0,a.jsx)(L,{cursor:!1,content:(0,a.jsx)(j,{hideLabel:!0})}),(0,a.jsx)(o.Pie,{data:T,dataKey:n,nameKey:c||`name`,innerRadius:e,strokeWidth:5,paddingAngle:2,outerRadius:`85%`,...D,...Te,children:T.map((e,n)=>{let r=Me(e?.[c],n,t);return(0,a.jsx)(o.Cell,{fill:W(r)},`cell-${n}`)})}),Bt?(0,a.jsx)(R,{verticalAlign:`bottom`,wrapperStyle:{fontSize:k?`11px`:`12px`,paddingTop:`8px`},content:(0,a.jsx)(_e,{nameKey:c,className:`flex-wrap`})}):null]})});return(0,a.jsx)(Ve,{note:We(r.sizable,r.total,n),children:d})}if(C===`funnel`){let e=l[0]?.dataKey||`value`,n=ot(),r=He(T,e);if(r.total>0&&r.sizable===0)return(0,a.jsx)(Ue,{dataKey:e,className:u});let i=m?n=>{n&&m({category:n?.payload?.[c]??n?.[c],categoryId:(0,t.chartRowBucketId)(n?.payload)??(0,t.chartRowBucketId)(n),value:n?.payload?.[e]??n?.[e]})}:void 0,d=i?{onClick:i,style:{cursor:`pointer`}}:{},f=(0,t.buildCategoryRank)(p),h=f?[...T].sort((e,t)=>(f.get(String(e?.[c]??``))??2**53-1)-(f.get(String(t?.[c]??``))??2**53-1)):[...T].sort((t,n)=>{let r=Number(t?.[e]??0);return Number(n?.[e]??0)-r}),g=(0,a.jsx)(A,{config:s,className:u,...O,children:(0,a.jsxs)(o.FunnelChart,{children:[(0,a.jsx)(L,{content:(0,a.jsx)(j,{})}),(0,a.jsxs)(o.Funnel,{dataKey:e,data:h,nameKey:c,...D,...d,children:[(0,a.jsx)(o.LabelList,{position:`right`,fill:`hsl(var(--foreground))`,stroke:`none`,dataKey:c}),h.map((e,t)=>(0,a.jsx)(o.Cell,{fill:W(n[t%n.length])},`funnel-cell-${t}`))]})]})});return(0,a.jsx)(Ve,{note:We(r.sizable,r.total,e),children:g})}if(C===`treemap`){let e=l[0]?.dataKey||`value`,t=ot(),n=He(T,e);if(n.total>0&&n.sizable===0)return(0,a.jsx)(Ue,{dataKey:e,className:u});let r=T.map((n,r)=>({name:String(n?.[c]??``),size:Number(n?.[e])||0,fill:W(t[r%t.length])})),i=(0,a.jsx)(A,{config:s,className:u,...O,children:(0,a.jsx)(o.Treemap,{data:r,dataKey:`size`,nameKey:`name`,...D,content:(0,a.jsx)(ze,{}),...Qe,children:(0,a.jsx)(o.Tooltip,{})})});return(0,a.jsx)(Ve,{note:We(n.sizable,n.total,e),children:i})}if(C===`sankey`){let e=l[0]?.dataKey||`value`,t=l[0]?.label||e,n=T.filter(t=>(Number(t?.[e])||0)>0),r=[{name:t},...n.map(e=>({name:String(e?.[c]??``)}))],i=n.map((t,n)=>({source:0,target:n+1,value:Number(t?.[e])||0}));if(i.length===0)return T.length===0?(0,a.jsx)(`div`,{className:u}):(0,a.jsxs)(V,{code:`no-positive-flow`,className:u,children:[`This chart has no flow to draw: no row's`,` `,(0,a.jsx)(`code`,{className:`font-mono`,children:e}),` is above zero.`]});let d=T.length-n.length;return(0,a.jsx)(Ve,{note:d>0?(0,a.jsxs)(`p`,{role:`note`,"data-chart-note":`omitted-rows`,className:`px-1 text-xs text-muted-foreground`,children:[`Showing `,n.length,` of `,T.length,` rows — `,d,` `,d===1?`row has`:`rows have`,` no`,` `,(0,a.jsx)(`code`,{className:`font-mono`,children:e}),` above zero, which a flow cannot draw.`]}):null,children:(0,a.jsx)(A,{config:s,className:u,...O,children:(0,a.jsx)(o.Sankey,{data:{nodes:r,links:i},nodePadding:24,link:{stroke:`hsl(var(--muted-foreground))`,strokeOpacity:.25},node:{fill:`hsl(var(--chart-1))`},...nt,children:(0,a.jsx)(o.Tooltip,{})})})})}if(C===`radar`)return(0,a.jsx)(A,{config:s,className:u,...O,children:(0,a.jsxs)(o.RadarChart,{data:T,children:[(0,a.jsx)(o.PolarGrid,{}),(0,a.jsx)(o.PolarAngleAxis,{dataKey:c,tick:K}),(0,a.jsx)(o.PolarRadiusAxis,{tick:K}),(0,a.jsx)(L,{content:(0,a.jsx)(j,{})}),(0,a.jsx)(R,{content:(0,a.jsx)(_e,{}),...k&&{verticalAlign:`bottom`,wrapperStyle:{fontSize:`11px`,paddingTop:`8px`}}}),l.map(e=>{let t=W(s[e.dataKey]?.color||ct),n=lt(e,`radar`);return(0,a.jsx)(o.Radar,{dataKey:e.dataKey,stroke:t,fill:t,fillOpacity:n.fillOpacity??.6,strokeOpacity:n.strokeOpacity,strokeDasharray:n.strokeDasharray,...D},e.dataKey)})]})});if(C===`scatter`){if(l.length>1)return(0,a.jsx)(et,{seriesKeys:l.map(e=>String(e.dataKey)),className:u});let e=l[0]?.dataKey||`value`,t=Ke(T,c,e),n=T.map(e=>Number(e?.[c])).filter(e=>Number.isFinite(e)),r=y(g?.format,E);if(t.total>0&&t.plottable===0)return(0,a.jsx)(qe,{xKey:c,yKey:e,className:u});if(t.total>0){let n=[[c,g],[e,_?.[0]]].filter(([e,t])=>!Xe(t)&&!Ze(T,e)).map(([e])=>e).filter((e,t,n)=>n.indexOf(e)===t);if(n.length>0)return(0,a.jsx)($e,{keys:n,total:t.total,className:u})}return(0,a.jsx)(Ve,{note:Le(tt(t.plottable,t.total,c,e),zt,X),children:(0,a.jsx)(A,{config:s,className:u,...O,children:(0,a.jsxs)(o.ScatterChart,{children:[(0,a.jsx)(o.CartesianGrid,{...It}),(0,a.jsx)(o.XAxis,{type:`number`,dataKey:c,name:String(s[c]?.label||c),tick:K,tickLine:!1,axisLine:!1,minTickGap:k?32:48,padding:xt,...r?{tickFormatter:r}:{},...$?{orientation:$}:{},...Re(g,n,Oe($))}),(0,a.jsx)(o.YAxis,{type:`number`,dataKey:e,name:String(s[l[0]?.dataKey]?.label||l[0]?.dataKey),tick:K,tickLine:!1,axisLine:!1,tickFormatter:jt,width:48,padding:St,...Y===`right`?{orientation:`right`}:{},...Q(B,Y)}),(0,a.jsx)(L,{content:(0,a.jsx)(j,{})}),(0,a.jsx)(R,{content:(0,a.jsx)(_e,{nameKey:e}),...k&&{verticalAlign:`bottom`,wrapperStyle:{fontSize:`11px`,paddingTop:`8px`}}}),l.map((e,t)=>{let n=ot(),r=W(s[e.dataKey]?.color||n[t%n.length]),i=lt(e,`scatter`);return(0,a.jsx)(o.Scatter,{name:s[e.dataKey]?.label||e.dataKey,data:T,fill:r,fillOpacity:i.fillOpacity,strokeOpacity:i.strokeOpacity,strokeDasharray:i.strokeDasharray,...D,...Ye},e.dataKey)})]})})})}if(C===`combo`)return(0,a.jsx)(Be,{title:re,subtitle:ie,children:(0,a.jsx)(Ve,{note:Le(zt,X),children:(0,a.jsx)(A,{config:s,className:u,...O,children:(0,a.jsxs)(o.ComposedChart,{ref:me,data:T,...we,children:[(0,a.jsx)(o.CartesianGrid,{...It,...Pe(vt,H)}),(0,a.jsx)(o.XAxis,{dataKey:c,...Gt}),(0,a.jsx)(o.YAxis,{yAxisId:`left`,tick:K,tickLine:!1,axisLine:!1,tickFormatter:Mt,width:48,...Q(G,`left`)}),(0,a.jsx)(o.YAxis,{yAxisId:`right`,orientation:`right`,tick:K,tickLine:!1,axisLine:!1,tickFormatter:Nt,width:48,...Q(q,`right`)}),Ht?(0,a.jsx)(L,{content:(0,a.jsx)(j,{})}):null,Bt?(0,a.jsx)(R,{content:(0,a.jsx)(_e,{}),...k&&{verticalAlign:`bottom`,wrapperStyle:{fontSize:`11px`,paddingTop:`8px`}}}):null,Vt,Ut,l.map((e,t)=>{let n=W(s[e.dataKey]?.color||ct),r=e.chartType||w||(t===0?`bar`:`line`),i=e.yAxis===`right`||e.yAxis===`left`?e.yAxis:w||r===`bar`?`left`:`right`,c=lt(e,r),l=e.stack?{stackId:String(e.stack)}:{},u=y((i===`right`?q:G)?.format,E);return r===`line`?(0,a.jsx)(o.Line,{yAxisId:i,type:`monotone`,dataKey:e.dataKey,stroke:n,strokeWidth:2,dot:!1,strokeOpacity:c.strokeOpacity,strokeDasharray:c.strokeDasharray,...D,...z(e),children:Wt(u)},e.dataKey):r===`area`?(0,a.jsx)(o.Area,{yAxisId:i,type:`monotone`,dataKey:e.dataKey,fill:n,stroke:n,fillOpacity:c.fillOpacity??.4,strokeOpacity:c.strokeOpacity,strokeDasharray:c.strokeDasharray,...l,...D,...z(e),children:Wt(u)},e.dataKey):(0,a.jsx)(o.Bar,{yAxisId:i,dataKey:e.dataKey,fill:n,radius:4,fillOpacity:c.fillOpacity,strokeOpacity:c.strokeOpacity,strokeDasharray:c.strokeDasharray,...l,...D,...z(e),children:Wt(u)},e.dataKey)})]})})})});let qt=C===`horizontal-bar`,Jt=ot(),Yt=f?Object.values(f).map(e=>W(String(e))):[],Xt=Array.from(new Set([...Jt,...Yt,...l.map((e,t)=>W(s[e.dataKey]?.color||Jt[t%Jt.length]||ct))])),Zt=e=>`g`+e.replace(/[^a-zA-Z0-9]/g,``);return(0,a.jsx)(Be,{title:re,subtitle:ie,children:(0,a.jsx)(Ve,{note:Le(zt,X),children:(0,a.jsx)(A,{config:s,className:u,...O,children:(0,a.jsxs)(Kt,{ref:me,data:T,layout:qt?`vertical`:`horizontal`,...be,children:[(0,a.jsx)(`defs`,{children:Xt.map(e=>(0,a.jsxs)(n.Fragment,{children:[(0,a.jsxs)(`linearGradient`,{id:`bg-${Zt(e)}`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,a.jsx)(`stop`,{offset:`0%`,style:{stopColor:e},stopOpacity:.95}),(0,a.jsx)(`stop`,{offset:`100%`,style:{stopColor:e},stopOpacity:.5})]}),(0,a.jsxs)(`linearGradient`,{id:`ag-${Zt(e)}`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,a.jsx)(`stop`,{offset:`0%`,style:{stopColor:e},stopOpacity:.5}),(0,a.jsx)(`stop`,{offset:`95%`,style:{stopColor:e},stopOpacity:.05})]})]},Zt(e)))}),(0,a.jsx)(o.CartesianGrid,{...It,...Pe(vt,H)}),qt?(0,a.jsxs)(a.Fragment,{children:[J?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(o.XAxis,{xAxisId:`left`,type:`number`,tick:K,tickLine:!1,axisLine:!1,tickFormatter:Mt,...Q(G,`left`,wt)}),(0,a.jsx)(o.XAxis,{xAxisId:`right`,orientation:`top`,type:`number`,tick:K,tickLine:!1,axisLine:!1,tickFormatter:Nt,...Q(q,`right`,Tt)})]}):(0,a.jsx)(o.XAxis,{type:`number`,tick:K,tickLine:!1,axisLine:!1,tickFormatter:jt,...Y===`right`?{orientation:`top`}:{},...Q(B,Y,Oe(Y===`right`?`top`:`bottom`))}),(0,a.jsx)(o.YAxis,{type:`category`,dataKey:c,tick:K,tickLine:!1,axisLine:!1,width:Math.min(140,Math.max(60,Math.max(...T.map(e=>String(e[c]??``).length))*7)),tickFormatter:Et,...Lt?{orientation:Lt}:{},...g?.title?{label:{value:g.title,...ke(Lt)}}:{}})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(o.XAxis,{dataKey:c,...Gt}),J?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(o.YAxis,{yAxisId:`left`,tick:K,tickLine:!1,axisLine:!1,tickFormatter:Mt,width:48,...Q(G,`left`)}),(0,a.jsx)(o.YAxis,{yAxisId:`right`,orientation:`right`,tick:K,tickLine:!1,axisLine:!1,tickFormatter:Nt,width:48,...Q(q,`right`)})]}):(0,a.jsx)(o.YAxis,{tick:K,tickLine:!1,axisLine:!1,tickFormatter:jt,width:48,...Y===`right`?{orientation:`right`}:{},...Q(B,Y)})]}),Ht?(0,a.jsx)(L,{content:(0,a.jsx)(j,{})}):null,Bt?(0,a.jsx)(R,{content:(0,a.jsx)(_e,{}),...k&&{verticalAlign:`bottom`,wrapperStyle:{fontSize:`11px`,paddingTop:`8px`}}}):null,Vt,Ut,l.map((e,t)=>{let n=ot(),r=e.variant===`comparison`,i=r?l.slice(0,t).find(e=>e.variant!==`comparison`)||l[0]:e,u=r?l.indexOf(i):t,d=W(s[i.dataKey]?.color||n[u%n.length]||ct),f=e.yAxis===`right`?`right`:`left`,p=J?qt?{xAxisId:f}:{yAxisId:f}:{},m=e.stack?{stackId:String(e.stack)}:{},h=y(Ct(e)?.format,E);if(C===`bar`||C===`horizontal-bar`){let t=l.filter(e=>e.variant!==`comparison`).length===1&&!r&&l.length===1&&T.length>1,i=lt(e,`bar`);return(0,a.jsxs)(o.Bar,{dataKey:e.dataKey,fill:`url(#bg-${Zt(d)})`,radius:4,fillOpacity:i.fillOpacity,strokeOpacity:i.strokeOpacity,strokeDasharray:i.strokeDasharray,...m,...p,...D,...P(e),children:[t&&T.map((e,t)=>(0,a.jsx)(o.Cell,{fill:`url(#bg-${Zt(W(Me(e?.[c],t,n)))})`},`cell-${t}`)),Wt(h)]},e.dataKey)}if(C===`line`){let t=lt(e,`line`);return(0,a.jsx)(o.Line,{type:`monotone`,dataKey:e.dataKey,stroke:d,strokeWidth:2,dot:!1,strokeOpacity:t.strokeOpacity,strokeDasharray:t.strokeDasharray,...p,...D,...P(e),children:Wt(h)},e.dataKey)}if(C===`area`){let t=lt(e,`area`);return(0,a.jsx)(o.Area,{type:`monotone`,dataKey:e.dataKey,fill:`url(#ag-${Zt(d)})`,stroke:d,strokeWidth:2,fillOpacity:t.fillOpacity??1,strokeOpacity:t.strokeOpacity,strokeDasharray:t.strokeDasharray,...m,...p,...D,...P(e),children:Wt(h)},e.dataKey)}return null})]})})})})}function rt(e){return e.chartType===`column`?`bar`:e.chartType}function it(e){let t=rt(e),n=Array.isArray(e.data)?e.data:[],r=e.xAxisKey??`name`;return t!==void 0&&G.has(t)&&n.length>0&&!n.some(e=>typeof e==`object`&&!!e&&r in e)}function at(e){let t=rt(e),n=Array.isArray(e.data)?e.data:[];return t===void 0||!At.has(t)||n.length===0?null:e.series===void 0?`undeclared`:Array.isArray(e.series)&&e.series.length===0?`empty`:null}function ot(e){let t=rt(e),n=Array.isArray(e.data)?e.data:[],r=Array.isArray(e.series)?e.series:[];if(t===void 0||!At.has(t)||n.length===0||r.length===0)return null;let i=Array.from(new Set(r.map(e=>String(e.dataKey))));if(!i.every(e=>n.some(t=>typeof t==`object`&&!!t&&Object.prototype.hasOwnProperty.call(t,e))))return null;let a=Array.isArray(e.yAxes)?e.yAxes:[],o=ae(a,t),s=o.left===void 0?void 0:a[o.left],c=o.right===void 0?void 0:a[o.right],l=!!s&&!!c,u=e=>Xe(s)||(!l||e.yAxis!==`left`)&&Xe(c);return r.some((e,i)=>Qe(t,r,i)!==`none`||u(e)||Ze(n,String(e.dataKey)))?null:i}function st(e){let t=rt(e),n=Array.isArray(e.data)?e.data:[],r=Array.isArray(e.series)?e.series:[];if(t===void 0||!At.has(t)||n.length===0||r.length===0)return null;let i=Array.from(new Set(r.map(e=>e.dataKey)));return i.every(e=>typeof e==`string`&&/^[^.[]+$/.test(e)&&!n.some(t=>typeof t==`object`&&!!t&&e in t))?i:null}function B({keys:e,className:t}){return(0,a.jsxs)(V,{code:`missing-series-key`,className:t,children:[`This chart cannot plot its series: no row has a`,` `,e.map((e,t)=>(0,a.jsxs)(n.Fragment,{children:[t>0?` or `:``,(0,a.jsx)(`code`,{className:`font-mono`,children:e})]},`${t}-${e}`)),` `,`field.`]})}function V({code:e,className:t,children:n}){return(0,a.jsx)(`div`,{className:`flex h-full min-h-[120px] w-full items-center justify-center p-4 text-center text-sm text-muted-foreground ${t??``}`,role:`status`,"data-chart-error":e,children:(0,a.jsx)(`span`,{children:n})})}function H(e){let t=it(e),r=t?null:at(e),i=t||r?null:st(e),o=t||r||i?null:ot(e),s=e.xAxisKey??`name`,c=n.useMemo(()=>Object.keys((Array.isArray(e.data)?e.data[0]:void 0)??{}),[e.data]),l=i?JSON.stringify(i):null,u=JSON.stringify(c);return n.useEffect(()=>{t&&console.warn(`[chart] no row has the category key "${s}" — rendering an explanatory placeholder instead of an empty axis. Row keys: ${JSON.stringify(c)}. A dataset query must PROJECT the dimension it groups by (framework#4033).`)},[t,s,c]),n.useEffect(()=>{if(r){if(r===`undeclared`){console.warn(`[chart] no series binding was declared for the category axis "${s}" — rendering an explanatory placeholder instead of an empty frame. Row keys: ${JSON.stringify(c)}. A bar / line / area / combo chart draws only the columns its \`series\` (or \`categories\`, or a y-axis \`field\`) names (objectui#4695).`);return}console.warn(`[chart] no series to plot against the category axis "${s}" — rendering an explanatory placeholder instead of an empty frame. Row keys: ${JSON.stringify(c)}. A grouped chart's SECOND dimension must be PROJECTED by the dataset query, and a chart with no measure selected has nothing to draw either (objectui#4683, framework#4033).`)}},[r,s,c]),n.useEffect(()=>{l&&console.warn(`[chart] no row has the series key(s) ${l} — rendering an explanatory placeholder instead of an empty frame. Row keys: ${u}. A series \`dataKey\` must name a column the rows carry (objectui#10396).`)},[l,u]),t?(0,a.jsxs)(V,{code:`missing-category-key`,className:e.className,children:[`This chart cannot plot its category axis: no row has a`,` `,(0,a.jsx)(`code`,{className:`font-mono`,children:s}),` field.`]}):r===`undeclared`?(0,a.jsxs)(V,{code:`no-plottable-series`,className:e.className,children:[`This chart cannot plot any series: none was declared to draw against its`,` `,(0,a.jsx)(`code`,{className:`font-mono`,children:s}),` axis.`]}):r===`empty`?(0,a.jsxs)(V,{code:`no-plottable-series`,className:e.className,children:[`This chart cannot plot any series: no measure or group reached its`,` `,(0,a.jsx)(`code`,{className:`font-mono`,children:s}),` axis.`]}):i?(0,a.jsx)(B,{keys:i,className:e.className}):o?(0,a.jsx)($e,{keys:o,total:Array.isArray(e.data)?e.data.length:0,className:e.className}):(0,a.jsx)(nt,{...e})}var ct,U,W,lt,ut,dt,ft,pt,G,mt,ht,gt,_t,K,q,J,vt,yt,bt,Y,X,xt,St,Ct,wt,Tt,Et,Dt,Ot,kt,At,jt=h((()=>{ye(),we(),O(),ct=`hsl(var(--primary))`,U={slate:`#64748b`,gray:`#6b7280`,zinc:`#71717a`,neutral:`#737373`,stone:`#78716c`,red:`#ef4444`,orange:`#f97316`,amber:`#f59e0b`,yellow:`#eab308`,lime:`#84cc16`,green:`#22c55e`,emerald:`#10b981`,teal:`#14b8a6`,cyan:`#06b6d4`,sky:`#0ea5e9`,blue:`#3b82f6`,indigo:`#6366f1`,violet:`#8b5cf6`,purple:`#a855f7`,fuchsia:`#d946ef`,pink:`#ec4899`,rose:`#f43f5e`},W=e=>U[e]||e,lt=(e,t)=>{let n=e?.variant===`comparison`,r=t===`area`||t===`radar`,i=typeof e?.opacity==`number`?e.opacity:void 0;return{strokeOpacity:i??(n?t===`line`?.5:r?.6:void 0:void 0),fillOpacity:i??(n?t===`bar`?.4:r?.2:.5:void 0),strokeDasharray:e?.dashArray??(n&&(t===`line`||r)?`4 4`:void 0)}},ut=(e,t)=>{if(typeof e==`string`||typeof e==`number`){let t=String(e);if(t!==``)return t}if(t.length===1){let e=t[0]?.dataKey;if(e!=null&&String(e)!==``)return String(e)}},dt=e=>{if(e&&typeof e==`object`&&`nativeEvent`in e)return e.nativeEvent},ft=e=>{for(let t=e.length-1;t>=0;--t){let n=dt(e[t]);if(n!==void 0)return n}},pt=(e,t)=>{if(e==null)return;let n=t.find(t=>String(t.dataKey)===e);return typeof n?.label==`string`?n.label:void 0},G=new Set([`bar`,`horizontal-bar`,`line`,`area`,`pie`,`donut`,`radar`,`funnel`,`combo`]),mt=5,ht=12,gt=35,_t=10,K={fill:`hsl(var(--muted-foreground))`},q=12,J=.65,vt=/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\u3000-\u303f\uff00-\uffef]/u,yt=10,bt=48,Y=8,X=Math.ceil(Math.sqrt(400/Math.PI)),xt={left:X,right:X},St={top:X,bottom:X},Ct={angle:-90,position:`insideLeft`},wt={position:`insideBottom`,offset:-4},Tt={position:`insideTop`,offset:-4},Et={angle:90,position:`insideRight`},Dt={},Ot={yAxisId:`left`},kt={xAxisId:`left`},At=new Set([`bar`,`horizontal-bar`,`line`,`area`,`combo`])}));O();var Mt=n.default.lazy(()=>Promise.resolve().then(()=>(he(),k))),Nt=n.default.lazy(()=>Promise.resolve().then(()=>(jt(),z))),Pt=({schema:e})=>(0,a.jsx)(n.Suspense,{fallback:(0,a.jsx)(r.Skeleton,{className:`w-full h-48 sm:h-64 md:h-80 lg:h-[400px]`}),children:(0,a.jsx)(Mt,{data:e.data,dataKey:e.dataKey,xAxisKey:e.xAxisKey,height:e.height,className:e.className,color:e.color})}),Z=({schema:e,onChartClick:t})=>{let{language:o}=(0,i.useObjectTranslation)(),s=n.default.useMemo(()=>{let t=oe(e,o),n=Array.isArray(e.series)?e.series:void 0,r=t.series??n,i=e.xAxisKey??t.xAxisKey,a=e.config;if(!a&&r){let t=e.colors||[`hsl(var(--chart-1))`,`hsl(var(--chart-2))`,`hsl(var(--chart-3))`],n={};r.forEach((e,r)=>{n[e.dataKey]={label:e.label||e.dataKey,color:e.color||t[r%t.length]}}),a=n}return{chartType:e.chartType??t.chartType,data:Array.isArray(e.data)?e.data:[],config:a,xAxisKey:i,series:r,className:e.className,spec:t}},[e,o]);return(0,a.jsx)(n.Suspense,{fallback:(0,a.jsx)(r.Skeleton,{className:`w-full h-48 sm:h-64 md:h-80 lg:h-[400px]`}),children:(0,a.jsx)(Nt,{chartType:s.chartType,data:s.data,config:s.config,xAxisKey:s.xAxisKey,series:s.series,className:s.className,colors:Array.isArray(e.colors)?e.colors:void 0,categoryColors:e.categoryColors,categoryOrder:e.categoryOrder,isAnimationActive:e.isAnimationActive,onChartClick:t,xAxis:s.spec.xAxis,yAxes:s.spec.yAxes,showLegend:s.spec.showLegend,showDataLabels:s.spec.showDataLabels,title:s.spec.title,subtitle:s.spec.subtitle,description:s.spec.description,height:s.spec.height??e.height,annotations:s.spec.annotations,interaction:s.spec.interaction})})};O();function Q(e){return(0,t.chartMeasureKey)(e,e.function||`count`)}var Ft=[`aggregate.groupBy`,`xAxisKey`,`xAxis.field`];function It(e){let t=e?.aggregate?.groupBy;if(t&&typeof t==`object`&&!Array.isArray(t)){let e=t.field;return typeof e==`string`&&e?e:void 0}return typeof t==`string`&&t?t:oe(e).xAxisKey}var $=`__comparison`;function Lt(e){let t=e?.groupBy;return t&&typeof t==`object`&&!Array.isArray(t)?t.alias||t.field:typeof t==`string`?t:void 0}function Rt(e,t){let{field:n,function:r,groupBy:i}=t,a=Q(t),o={};for(let t of e){let e=String(t[i]??`Unknown`);o[e]||(o[e]=[]),o[e].push(t)}return Object.entries(o).map(([e,t])=>{let o=n?t.map(e=>Number(e[n])||0):[],s;switch(r){case`count`:s=t.length;break;case`avg`:s=o.length>0?o.reduce((e,t)=>e+t,0)/o.length:0;break;case`min`:s=o.length>0?Math.min(...o):0;break;case`max`:s=o.length>0?Math.max(...o):0;break;default:s=o.reduce((e,t)=>e+t,0)}return{[i]:e,[a]:s}})}async function zt(e,n,r,i,a){if(!e.length||!n)return e;let o=a||((e,t)=>t),s=`__raw_${n}`,c=r?.fields?.[n];if(!c){let r=/^\d{4}-\d{2}-\d{2}/;return e.map(e=>{let i=e[n],a=String(i??``),c=r.test(a)?a:(0,t.humanizeLabel)(a);return{...e,[n]:o(a,c),[s]:i}})}let l=c.type;if(l===`select`||l===`picklist`||l===`dropdown`){let r=c.options||[];if(r.length===0)return e.map(e=>{let r=e[n],i=String(r??``),a=(0,t.humanizeLabel)(i);return{...e,[n]:o(i,a),[s]:r}});let i={};for(let e of r)typeof e==`string`?i[e]=e:e&&typeof e==`object`&&(i[String(e.value)]=e.label||String(e.value));return e.map(e=>{let r=e[n],a=String(r??``),c=i[a]||(0,t.humanizeLabel)(a);return{...e,[n]:o(a,c),[s]:r}})}if(l===`lookup`||l===`master_detail`){let r=c.reference;if(!r||!i||typeof i.find!=`function`)return e.map(e=>({...e,[s]:e[n]}));let a=[...new Set(e.map(e=>e[n]).filter(e=>e!=null))];if(a.length===0)return e.map(e=>({...e,[s]:e[n]}));let o=c.id_field||`id`;try{let l=await i.find(r,{$filter:{[o]:{$in:a}},$top:a.length}),u=(0,t.extractRecords)(l),d=c.displayField||c.reference_field||`name`,f={};for(let e of u){let t=String(e[o]??e.id??e._id??``),n=e[d]||e.name||e.label||e.title||t;t&&(f[t]=String(n))}return e.map(e=>{let t=e[n],r=String(t??``);return{...e,[n]:f[r]||r,[s]:t}})}catch(t){return console.warn(`[ObjectChart] Failed to resolve lookup labels:`,t),e.map(e=>({...e,[s]:e[n]}))}}if(l===`date`||l===`datetime`||l===`date_time`||l===`timestamp`||l===`time`)return e.map(e=>({...e,[s]:e[n]}));let u=/^\d{4}-\d{2}-\d{2}/;return e.map(e=>{let r=e[n],i=String(r??``);return{...e,[n]:u.test(i)?i:(0,t.humanizeLabel)(i),[s]:r}})}var Bt=e=>{let{schema:o}=e,l=e.onSegmentClick,u=(0,n.useContext)(s.SchemaRendererContext),d=e.dataSource||u?.dataSource,f=u?.apiFetch,p=(0,s.useDataScope)(o.bind),{fieldOptionLabel:m}=(0,i.useSafeFieldLabel)(),[h,g]=(0,n.useState)([]),[_,ee]=(0,n.useState)(null),[te,ne]=(0,n.useState)(void 0),[re,ie]=(0,n.useState)(()=>!(Array.isArray(o.data)&&o.data.length>0)&&(!!o.objectName||!!o.dataset)),[ae,se]=(0,n.useState)(null),[v,y]=(0,n.useState)(null),[ce,b]=(0,n.useState)(null),{openRecordList:le}=(0,s.useDrillNavigation)(),x=(0,i.useSafeTranslate)(),{t:ue,language:S}=(0,i.useObjectTranslation)(),de=(0,n.useMemo)(()=>oe(o,S).chartType,[o,S]),C=(0,n.useMemo)(()=>o.aggregate?JSON.stringify(o.aggregate):``,[o.aggregate]),w=(0,n.useMemo)(()=>o.filter?JSON.stringify(o.filter):``,[o.filter]),T=(0,n.useMemo)(()=>o.compareTo?JSON.stringify(o.compareTo):``,[o.compareTo]),E=(0,n.useMemo)(()=>o.dataset?JSON.stringify({d:o.dataset,dim:o.dimensions??[],val:o.values??[]}):``,[o.dataset,o.dimensions,o.values]);(0,n.useEffect)(()=>{let e=!1;return(async()=>{try{let n=f??fetch,r={headers:{accept:`application/json`},credentials:`include`},i=o.objectName,a,s=null;if(i)a=It(o);else if(o.dataset){let e=Array.isArray(o.dimensions)&&o.dimensions.length?o.dimensions[0]:void 0,t=await(await n(`/api/v1/meta/dataset/${encodeURIComponent(o.dataset)}`,r)).json().catch(()=>null);s=t?.item??t?.data??t,i=s?.object,a=((s?.dimensions||[]).find(t=>t?.name===e)??(s?.dimensions||[])[0])?.field??e}if(!i||!a){e||b(null);return}let c=typeof d?.getObjectSchema==`function`?e=>d.getObjectSchema(e):async e=>{let t=await(await n(`/api/v1/meta/object/${encodeURIComponent(e)}`,r)).json().catch(()=>null);return t?.item??t?.data??t},l={};if(o.dataset&&Array.isArray(o.dimensions))for(let e of o.dimensions)l[e]=(s?.dimensions||[]).find(t=>t?.name===e)?.field??e;let u=await(0,t.loadDimensionFieldMeta)(c,i,[a,...Object.values(l)]);e||b({metaByPath:u,colorPath:a,fieldByDim:o.dataset&&Array.isArray(o.dimensions)?l:null})}catch{e||b(null)}})(),()=>{e=!0}},[o.objectName,o.dataset,E,C,o.xAxisKey,f,d]);let{fieldOptionColors:D,dimensionLabels:O}=(0,n.useMemo)(()=>{if(!ce)return{fieldOptionColors:null,dimensionLabels:null};let{metaByPath:e,colorPath:n,fieldByDim:r}=ce,i=(0,t.localizeFieldOptions)(e[n]?.options,(0,t.dimensionOptionTranslator)(e[n],m)),a=(0,t.deriveDimensionLabelMaps)(e,r?Object.entries(r).map(([e,t])=>({dim:e,path:t})):null,m);return{fieldOptionColors:(0,t.buildOptionColorMap)(i),dimensionLabels:a}},[ce,m]),k=(0,n.useCallback)(async(e,n)=>{if(o.aggregate&&typeof e.aggregate==`function`){let r=o.aggregate.groupBy;if((0,t.isStructuredGroupBy)(r)){let i=await e.aggregate(o.objectName,(0,t.objectAggregateSpecQuery)(o.aggregate,r,n));return Array.isArray(i)?i:[]}let i=await e.aggregate(o.objectName,{field:o.aggregate.field,function:o.aggregate.function,groupBy:r,filter:n});return Array.isArray(i)?i:[]}if(typeof e.find==`function`){let r=await e.find(o.objectName,{$filter:n}),i=(0,t.extractRecords)(r),a=Lt(o.aggregate);return o.aggregate&&a&&i.length>0&&(i=Rt(i,{...o.aggregate,groupBy:a})),i}return[]},[o.objectName,C]),fe=(0,s.useFilterScope)(),pe=(0,n.useCallback)(async(e,n)=>{if(!e||!o.objectName&&!o.dataset){n.current&&ie(!1);return}n.current&&(ie(!0),se(null));try{if(o.dataset&&typeof e.queryDataset==`function`){let r=(0,t.resolveFilterPlaceholders)(o.filter,fe),i=await e.queryDataset(o.dataset,{dimensions:Array.isArray(o.dimensions)?o.dimensions:[],measures:Array.isArray(o.values)?o.values:[],...r?{runtimeFilter:r}:{}});n.current&&(g(Array.isArray(i?.rows)?i.rows:[]),ee(Array.isArray(i?.fields)?i.fields:null),ne(typeof i?.object==`string`&&i.object?i.object:void 0));return}let r=(0,t.resolveFilterPlaceholders)(o.filter,fe),i=o.compareTo,a=!!i&&!(0,t.chartTypeIgnoresCompareTo)(de),s=a?(0,t.resolveContextTokens)((0,t.shiftFilterByCompareTo)(o.filter,i),fe):null,[c,l]=await Promise.all([k(e,r),s?k(e,s):Promise.resolve([])]),u=c,d=Lt(o.aggregate)||o.xAxisKey;if(a&&l.length>0&&o.aggregate){let e=o.aggregate.field,t=o.aggregate.function,n=Q(o.aggregate),r=r=>{if(r==null)return null;if(e){let n=`${e}_${t}`;if(n in r)return Number(r[n]);if(t===`count`&&`${e}_count`in r)return Number(r[`${e}_count`])}return n in r?Number(r[n]):`value`in r?Number(r.value):`count`in r?Number(r.count):null},i=`${n}${$}`,a=d;if(a&&u.some(e=>e[a]!=null)&&l.some(e=>e[a]!=null)){let e=new Map;for(let t of l){let n=String(t[a]??``);e.set(n,r(t))}u=u.map(t=>{let n=String(t[a]??``),r=e.get(n);return r==null?t:{...t,[i]:r}});let t=new Set(u.map(e=>String(e[a]??``)));for(let e of l){let n=String(e[a]??``);t.has(n)||u.push({[a]:n,[i]:r(e)})}}else{let e=Math.max(u.length,l.length),t=[];for(let n=0;n<e;n++){let e=u[n]||{},a=l[n];t.push(a?{...e,[i]:r(a)}:e)}u=t}}if(d&&o.objectName&&typeof e.getObjectSchema==`function`){let t=o.objectName;try{let n=await e.getObjectSchema(t);u=await zt(u,d,n,e,(e,n)=>m(t,d,e,n))}catch{}}n.current&&g(u)}catch(e){console.error(`[ObjectChart] Fetch error:`,e),n.current&&se(e instanceof Error?e.message:`Failed to load chart data`)}finally{n.current&&ie(!1)}},[o.objectName,E,C,w,T,o.xAxisKey,de,k,fe,m]),me=!!p||Array.isArray(o.data),he=!!o.objectName&&!o.dataset&&!me,ge=he&&!It(o),A=!!(o.objectName||o.dataset)&&!p&&!o.data&&!ge,j=(0,s.useDataInvalidation)(A?o.dataset?te:o.objectName:void 0);(0,n.useEffect)(()=>{let e={current:!0};return A?pe(d,e):e.current&&ie(!1),()=>{e.current=!1}},[o.objectName,E,d,p,o.data,w,C,T,pe,j,A]);let _e=p||o.data||h,M=Array.isArray(_e)?_e:[],N=o.drillDown,P=Lt(o.aggregate)||o.xAxisKey,F=(0,n.useMemo)(()=>{if(!P)return new Map;let e=new Map,t=`__raw_${P}`;for(let n of M){let r=n?.[P];if(r==null)continue;let i=t in(n||{})?n[t]:r;e.set(String(r),i)}return e},[M,P]),I=(0,n.useMemo)(()=>{if(v)try{return{ok:!0,filter:(0,t.composeDrillFilter)(o.filter,(0,t.computeDrillFilter)(N,v,{groupByField:P}))}}catch(e){if(!(e instanceof t.FilterOperatorError))throw e;return{ok:!1,refusal:e}}},[v,N,P,w]),ve=I?.ok?I.filter:void 0,L=I?.ok===!1,R=I?.ok===!1?I.refusal.message:void 0;(0,n.useEffect)(()=>{R&&console.warn(`[ObjectChart] drill-down refused — the drilled list cannot be scoped: ${R}`)},[R]);let ye=!l&&!!v&&!L&&!!o.objectName&&N?.target===`navigate`&&!!le;(0,n.useEffect)(()=>{ye&&(le(o.objectName,ve),y(null))},[ye]);let be=o.compareTo,xe=o.aggregate?Q(o.aggregate):void 0,Se=xe?`${xe}${$}`:void 0,Ce=!!be&&!(0,t.chartTypeIgnoresCompareTo)(de)&&!!Se&&M.some(e=>e[Se]!=null),we=(0,n.useMemo)(()=>{let e=Array.isArray(o.series)?o.series:null;if(!Ce)return e;let n=e||[{dataKey:xe}],r={vsLastWeek:`Previous week`,vsLastMonth:`Previous month`,vsLastQuarter:`Previous quarter`,vsLastYear:`Previous year`,vsYesterday:`Yesterday`,vsPreviousPeriod:`Previous period`}[(0,t.compareToTrendLabelKey)(be,o.filter)]||`Previous period`;return[...n.map(e=>({...e,variant:e.variant||`current`})),{dataKey:Se,label:r,variant:`comparison`}]},[Ce,o.series,xe,Se,o.filter,be]),z=o.dataset?(0,t.buildChartSeries)((0,t.relabelDimensions)(M,O),o.dimensions,o.values,_,{nullCategoryLabel:x(`chart.nullCategory`,`(None)`),builtinAggregateLabels:(0,i.builtinAggregateLabels)(x)}):null,Te=he&&!oe(o,S).xAxisKey?Lt(o.aggregate):void 0,Ee=z?{...o,data:z.data,xAxisKey:z.xAxisKey,series:z.series}:{...o,data:M,...Te?{xAxisKey:Te}:{},...we?{series:we}:{}},De=o.colors&&!Array.isArray(o.colors)&&typeof o.colors==`object`?o.colors:null,Oe=Array.isArray(o.colors)?o.colors:void 0,ke=D||De?{...D||{},...De||{}}:void 0,Ae={...Ee,colors:Oe,...ke?{categoryColors:ke}:{}};if(ge)return(0,a.jsxs)(`div`,{className:`p-4 text-destructive `+(o.className||``),"data-testid":`chart-missing-category-axis`,role:`alert`,children:[x(`chart.unconfigured.noCategoryAxis`,`Chart category axis required — an object-bound chart will not invent one. Declare one of:`),` `,Ft.map((e,t)=>(0,a.jsxs)(n.default.Fragment,{children:[t>0?`, `:``,(0,a.jsx)(`code`,{className:`font-mono`,children:e})]},e))]});if(re&&M.length===0)return(0,a.jsxs)(`div`,{className:`p-2 `+(o.className||``),"data-testid":`chart-loading`,role:`status`,"aria-busy":`true`,"aria-live":`polite`,children:[(0,a.jsx)(`span`,{className:`sr-only`,children:`Loading chart data…`}),(0,a.jsx)(r.ChartSkeleton,{className:`h-full`})]});if(ae)return(0,a.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-2 p-4 `+(o.className||``),"data-testid":`chart-error`,role:`alert`,children:[(0,a.jsx)(c.AlertCircle,{className:`h-6 w-6 text-destructive opacity-60`}),(0,a.jsx)(`p`,{className:`text-xs text-destructive font-medium`,children:`Failed to load chart data`}),(0,a.jsx)(`p`,{className:`text-xs text-muted-foreground max-w-xs text-center`,children:ae})]});if(!d&&o.objectName&&M.length===0)return(0,a.jsxs)(`div`,{className:`flex items-center justify-center text-muted-foreground text-sm p-4 `+(o.className||``),"data-testid":`chart-no-datasource`,children:[`No data source available for “`,o.objectName,`”`]});if((o.objectName||o.dataset)&&!p&&!o.data&&M.length===0)return(0,a.jsx)(r.DataEmptyState,{role:`status`,"data-testid":`chart-empty-state`,className:`h-full w-full gap-2 p-4 [&>h3]:text-sm [&>h3]:font-medium [&>p]:text-xs `+(o.className||``),icon:(0,a.jsx)(c.Inbox,{className:`h-5 w-5 text-muted-foreground/70`}),iconWrapperClassName:`flex size-9 items-center justify-center rounded-lg bg-muted`,title:x(`dashboard.empty.title`,`No data yet`),description:x(`dashboard.empty.message`,`This widget loaded successfully and its query returned no records yet.`),children:(0,a.jsxs)(`p`,{className:`text-xs text-muted-foreground/80`,"data-testid":`chart-empty-source`,children:[(0,a.jsx)(`span`,{children:x(`dashboard.empty.sourceLabel`,`Source:`)}),` `,(0,a.jsx)(`span`,{className:`font-mono`,children:o.dataset||o.objectName})]})});let je=(0,t.isDrillEnabled)(N)?e=>{let t=e.category,n=t!=null&&F.has(String(t))?F.get(String(t)):t;y({...e,category:n,categoryLabel:t,scope:`cell`})}:void 0,Me=l??je,Ne=!l&&v&&!L&&o.objectName&&!ye?(()=>{let e=ve??{},n=(0,t.resolveDrillTitle)(N,v,(0,i.pickLocalized)(o.title,S)||`Details`),l=N?.target??`drawer`,u={type:`object-data-table`,objectName:o.objectName,filter:e,pagination:!0,pageSize:N?.maxRows,columns:N?.columns?.map(e=>({accessorKey:e,header:e})),drillDown:{enabled:!0,mode:`record`,target:`dialog`}},f=(0,a.jsx)(`div`,{className:`overflow-auto`,"data-testid":`chart-drill-body`,children:(0,a.jsx)(s.SchemaRenderer,{schema:u,dataSource:d})}),p=le&&o.objectName?(0,a.jsxs)(r.Button,{type:`button`,variant:`ghost`,size:`sm`,"data-testid":`drill-open-in-list`,onClick:()=>{le(o.objectName,e),y(null)},children:[x(`dashboard.openInList`,`Open in list`),(0,a.jsx)(c.ArrowUpRight,{className:`ml-1 h-3.5 w-3.5`})]}):null;return l===`dialog`?(0,a.jsx)(r.Dialog,{open:!0,onOpenChange:e=>!e&&y(null),children:(0,a.jsxs)(r.DialogContent,{className:`max-w-4xl`,children:[(0,a.jsxs)(r.DialogHeader,{className:`flex-row items-center justify-between gap-4 pr-8`,children:[(0,a.jsx)(r.DialogTitle,{children:n}),p]}),f]})}):(0,a.jsx)(r.Sheet,{open:!0,onOpenChange:e=>!e&&y(null),children:(0,a.jsxs)(r.SheetContent,{side:`right`,className:`w-full sm:max-w-2xl md:max-w-3xl lg:max-w-4xl flex flex-col`,children:[(0,a.jsxs)(r.SheetHeader,{className:`flex-row items-center justify-between gap-4 pr-8`,children:[(0,a.jsx)(r.SheetTitle,{children:n}),p]}),(0,a.jsx)(`div`,{className:`flex-1 overflow-hidden mt-2`,children:f})]})})})():null;return(0,a.jsxs)(`div`,{className:`relative h-full`,children:[(0,a.jsx)(r.RefreshIndicator,{active:re&&M.length>0,ariaLabel:ue(`chart.refreshing`)}),(0,a.jsx)(Z,{...e,schema:Ae,onChartClick:Me}),Ne]})},Vt={filter:!0},Ht=e=>e.data==null&&e.bind==null&&Reflect.get(e,`dataset`)==null,Ut=(0,t.elementDataSourceBlock)(e=>{let{t}=(0,i.useObjectTranslation)();return(0,a.jsx)(s.ElementDataSourceGate,{schema:e.schema,mapping:Vt,dataSource:e.dataSource,testId:`object-chart`,errorTitle:t(`element.chart.sourceUnresolved`,{defaultValue:`This chart’s data source could not be resolved`}),requiresObject:Ht(e.schema),children:t=>(0,a.jsx)(Bt,{...e,schema:t})})});t.ComponentRegistry.register(`object-chart`,Ut,{namespace:`plugin-charts`,label:`Object Chart`,category:`view`,inputs:[{name:`objectName`,type:`string`,description:"Object this chart aggregates. Not required: the node's `dataSource` binding can name the object instead, and `dataSource.object` lands on this key, outranking an authored value. With neither, and no inline `data`, the chart shows a hint naming this key instead of an empty frame."},{name:`data`,type:`array`,description:`Optional static data`},{name:`filter`,type:`array`},{name:`aggregate`,type:`object`,description:`Aggregation config: { field, function, groupBy }`},{name:`drillDown`,type:`object`,description:`Segment drill config: { enabled?, filter?, title?, target?: 'drawer' | 'dialog', columns?, maxRows? }. Present = on; {} is enough. Clicking a segment opens the underlying records filtered by the clicked category.`}]}),O();var Wt={"bar-chart":Pt,chart:Z};t.ComponentRegistry.register(`bar-chart`,Pt,{namespace:`plugin-charts`,label:`Bar Chart`,category:`plugin`,inputs:[{name:`data`,type:`array`,required:!0},{name:`dataKey`,type:`string`},{name:`xAxisKey`,type:`string`},{name:`height`,type:`number`},{name:`color`,type:`color`}],defaultProps:{data:[{name:`Jan`,value:400},{name:`Feb`,value:300},{name:`Mar`,value:600},{name:`Apr`,value:800},{name:`May`,value:500}],dataKey:`value`,xAxisKey:`name`,height:400,color:`#8884d8`}}),t.ComponentRegistry.register(`chart`,Ut,{namespace:`view`,category:`view`,label:`Chart`,skipFallback:!0,inputs:[{name:`objectName`,type:`string`,description:"Object this chart aggregates. Not required: the node's `dataSource` binding can name the object instead, and `dataSource.object` lands on this key, outranking an authored value. With neither, and no inline `data`, the chart shows a hint naming this key instead of an empty frame."},{name:`type`,type:`string`},{name:`categoryField`,type:`string`},{name:`valueField`,type:`string`}]}),t.ComponentRegistry.register(`chart`,Z,{namespace:`plugin-charts`,label:`Chart`,category:`plugin`,inputs:[{name:`chartType`,type:`enum`,enum:[{label:`Bar`,value:`bar`},{label:`Line`,value:`line`},{label:`Area`,value:`area`},{label:`Pie`,value:`pie`},{label:`Donut`,value:`donut`},{label:`Radar`,value:`radar`},{label:`Scatter`,value:`scatter`}]},{name:`data`,type:`code`,required:!0},{name:`config`,type:`code`},{name:`xAxisKey`,type:`string`},{name:`series`,type:`code`,required:!0},{name:`className`,type:`string`}],defaultProps:{chartType:`bar`,data:[{name:`Jan`,sales:400,revenue:240},{name:`Feb`,sales:300,revenue:139},{name:`Mar`,sales:600,revenue:380},{name:`Apr`,sales:800,revenue:430},{name:`May`,sales:500,revenue:220}],config:{sales:{label:`Sales`,color:`#8884d8`},revenue:{label:`Revenue`,color:`#82ca9d`}},xAxisKey:`name`,series:[{dataKey:`sales`},{dataKey:`revenue`}]}}),t.ComponentRegistry.register(`chart:bar`,Z,{namespace:`plugin-charts`,label:`Bar Chart (Alias)`,category:`plugin`}),e.ChartBarRenderer=Pt,e.ChartRenderer=Z,e.ObjectChart=Bt,e.ObjectChartBlock=Ut,e.chartComponents=Wt,e.normalizeChartSchema=oe});
@@ -198,7 +198,24 @@ export interface NormalizedSeries {
198
198
  /** Which y-axis this series binds to (dual-axis charts). */
199
199
  yAxis?: 'left' | 'right';
200
200
  color?: string;
201
+ /**
202
+ * The aggregate of the measure this series plots — renderer-internal, the
203
+ * dataset answer's `fields[].aggregate` carried by `buildChartSeries`
204
+ * (objectui#11681). It decides one thing: a value axis whose series all plot
205
+ * a count draws whole-number ticks ({@link plotsWholeNumbers}). On the
206
+ * authoring face it is refused by name (`ChartDataSeriesSchema.aggregate`),
207
+ * so an author cannot claim integer ticks for a currency sum.
208
+ */
209
+ aggregate?: string;
201
210
  }
211
+ /**
212
+ * Whether a value axis plotting `series` should draw whole-number ticks only
213
+ * (objectui#11681): true exactly when at least one series is bound to it and
214
+ * EVERY one plots an integer aggregate (`count` / `count_distinct`). One sum,
215
+ * average or undeclared series on the axis keeps recharts' default ticks, so a
216
+ * sum over currency keeps its decimals.
217
+ */
218
+ export declare function plotsWholeNumbers(series: readonly NormalizedSeries[]): boolean;
202
219
  export interface NormalizedChartSchema {
203
220
  /**
204
221
  * The chart family the schema names, as named: `chartType`, else `specType`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@object-ui/plugin-charts",
3
- "version": "17.7.0",
3
+ "version": "18.0.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "description": "Chart components plugin for Object UI, powered by Recharts",
@@ -26,18 +26,18 @@
26
26
  "dependencies": {
27
27
  "lucide-react": "^1.43.0",
28
28
  "recharts": "^3.10.1",
29
- "@object-ui/components": "17.7.0",
30
- "@object-ui/core": "17.7.0",
31
- "@object-ui/i18n": "17.7.0",
32
- "@object-ui/react": "17.7.0",
33
- "@object-ui/types": "17.7.0"
29
+ "@object-ui/components": "18.0.0",
30
+ "@object-ui/core": "18.0.0",
31
+ "@object-ui/i18n": "18.0.0",
32
+ "@object-ui/react": "18.0.0",
33
+ "@object-ui/types": "18.0.0"
34
34
  },
35
35
  "peerDependencies": {
36
36
  "react": "^18.0.0 || ^19.0.0",
37
37
  "react-dom": "^18.0.0 || ^19.0.0"
38
38
  },
39
39
  "devDependencies": {
40
- "@objectstack/spec": "^17.0.0",
40
+ "@objectstack/spec": "^18.0.0",
41
41
  "@types/react": "19.2.18",
42
42
  "@types/react-dom": "19.2.4",
43
43
  "@vitejs/plugin-react": "^6.0.5",