chordia-ui 3.6.9 → 3.7.1

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.
@@ -0,0 +1,15 @@
1
+ "use strict";const e=require("react/jsx-runtime"),T=require("react"),o=require("recharts"),Y=require("lucide-react"),w=["#5E88B0","#9B7AA8","#C98A5A","#7BA89D","#D17B6B","#6B7C93","#9B8E6F","#8A9BAF","#B8976A","#A8C76B"],Q={fill:"var(--text-muted, #666)",fontSize:12},$={stroke:"var(--border, #e0e0e0)"},K="var(--border, #e0e0e0)",O={wrapperStyle:{zIndex:9999,pointerEvents:"none",outline:"none",transition:"none"}},oe={color:"var(--text-ink, #1e2125)",fontSize:"12px"},_=({active:h,payload:d,label:x})=>!h||!d||!d.length?null:e.jsxs("div",{className:"chordia-chart-tooltip",style:{background:"#ffffff",border:"1px solid rgba(52, 58, 64, 0.12)",borderRadius:8,boxShadow:"0 8px 24px rgba(15, 23, 42, 0.12), 0 2px 6px rgba(15, 23, 42, 0.06)",padding:"10px 12px",minWidth:140,maxWidth:280,maxHeight:280,overflowY:"auto",fontSize:12,lineHeight:1.5,color:"#1E2125",pointerEvents:"auto"},children:[e.jsx("style",{children:`
2
+ .chordia-chart-tooltip::-webkit-scrollbar { width: 8px; }
3
+ .chordia-chart-tooltip::-webkit-scrollbar-track { background: transparent; }
4
+ .chordia-chart-tooltip::-webkit-scrollbar-thumb {
5
+ background: rgba(52, 58, 64, 0.25);
6
+ border-radius: 4px;
7
+ }
8
+ .chordia-chart-tooltip::-webkit-scrollbar-thumb:hover {
9
+ background: rgba(52, 58, 64, 0.4);
10
+ }
11
+ `}),x!==void 0&&x!==""&&e.jsx("div",{style:{fontSize:11,fontWeight:600,letterSpacing:"0.02em",color:"#6B7280",textTransform:"uppercase",marginBottom:6,paddingBottom:6,borderBottom:"1px solid rgba(52, 58, 64, 0.08)"},children:x}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:d.map((a,s)=>{var p;const u=a.color||((p=a.payload)==null?void 0:p.fill)||"#9CA3AF";return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,justifyContent:"space-between"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,minWidth:0},children:[e.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:u,flexShrink:0}}),e.jsx("span",{style:{color:"#374151",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:a.name})]}),e.jsx("span",{style:{color:"#111827",fontWeight:600,marginLeft:8},children:a.value})]},s)})})]}),ie=(h,d)=>{if(!h)return!1;const x=h.toLowerCase();return d.filter(s=>String(s).toLowerCase().includes(x)).length<d.length*.5},se=h=>{const d=Array.from(h.querySelectorAll(".recharts-wrapper")),x=d.length?d.reduce((p,S)=>{const b=p.getBoundingClientRect(),i=S.getBoundingClientRect();return i.width*i.height>b.width*b.height?S:p}):null;if(x){const p=x.querySelector("svg.recharts-surface");if(p){const S=p.getBoundingClientRect();if(S.width>=100&&S.height>=100)return p}}const a=Array.from(h.querySelectorAll("svg"));if(!a.length)return null;const s=a.reduce((p,S)=>{const b=p.getBoundingClientRect(),i=S.getBoundingClientRect();return i.width*i.height>b.width*b.height?S:p}),u=s.getBoundingClientRect();return u.width<100||u.height<100?null:s},ae=h=>String(h).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;"),le=({chartSvg:h,width:d,height:x,legendItems:a=[]})=>{const s=h.cloneNode(!0),u=20,p=16,b=d-16,i=[];let c=[],n=0;a.forEach(({label:m,color:l})=>{const f=Math.max(40,String(m).length*7+34);c.length&&p+n+f>b&&(i.push(c),c=[],n=0),c.push({label:m,color:l,itemWidth:f}),n+=f}),c.length&&i.push(c);const t=i.length?i.length*u+20:0,r=x+t;s.setAttribute("width",d),s.setAttribute("height",x),s.setAttribute("x",0),s.setAttribute("y",0);const v=i.map((m,l)=>{let f=p;const j=x+20+l*u;return m.map(({label:A,color:B,itemWidth:W})=>{const I=`<line x1="${f}" y1="${j}" x2="${f+10}" y2="${j}" stroke="${B}" stroke-width="2" />`,R=`<circle cx="${f+5}" cy="${j}" r="2.5" fill="#fff" stroke="${B}" stroke-width="1.5" />`,L=`<text x="${f+14}" y="${j+4}" fill="#666" font-size="12">${ae(A)}</text>`;return f+=W,`${I}${R}${L}`}).join("")}).join("");return[`<svg xmlns="http://www.w3.org/2000/svg" width="${d}" height="${r}" viewBox="0 0 ${d} ${r}">`,'<style>text { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }</style>','<rect x="0" y="0" width="100%" height="100%" fill="#ffffff" />',new XMLSerializer().serializeToString(s),v,"</svg>"].join("")},ce=async(h,d,x=[])=>{const a=se(h);if(!a)return;const s=a.getBoundingClientRect(),u=s.width||a.clientWidth||Number(a.getAttribute("width"))||600,p=s.height||a.clientHeight||Number(a.getAttribute("height"))||300,S=le({chartSvg:a,width:u,height:p,legendItems:x}),b=new Blob([S],{type:"image/svg+xml;charset=utf-8"}),i=URL.createObjectURL(b),c=new Image;c.onload=()=>{const n=document.createElement("canvas"),t=2;n.width=u*t,n.height=p*t;const r=n.getContext("2d");r.fillStyle="#ffffff",r.fillRect(0,0,n.width,n.height),r.scale(t,t),r.drawImage(c,0,0,u,p),URL.revokeObjectURL(i);const v=document.createElement("a");v.download=`${(d||"chart").replace(/[^a-z0-9]+/gi,"_")}.png`,v.href=n.toDataURL("image/png"),v.click()},c.src=i},de=(h,d)=>{const x=["",...h.map(u=>u.name)].join(","),a=d.map(u=>{const p=h.map(S=>{const b=S.data.find(i=>i.x===u);return b?b.y:""});return[u,...p].join(",")}),s=[x,...a].join(`
12
+ `);navigator.clipboard.writeText(s)},he=({onDownloadPng:h,onCopy:d,copied:x})=>e.jsxs("div",{style:{display:"flex",gap:6,justifyContent:"flex-end",marginBottom:8,opacity:.7,transition:"opacity 0.15s"},children:[e.jsx("button",{onClick:d,title:"Copy data as CSV",style:{background:"none",border:"1px solid var(--border, #e0e0e0)",borderRadius:"var(--radius-sm, 4px)",padding:"3px 8px",fontSize:11,color:"var(--text-muted, #666)",cursor:"pointer",display:"flex",alignItems:"center",gap:4},children:x?"✓ Copied":"📋 CSV"}),e.jsx("button",{onClick:h,title:"Download as PNG",style:{background:"none",border:"1px solid var(--border, #e0e0e0)",borderRadius:"var(--radius-sm, 4px)",padding:"3px 8px",fontSize:11,color:"var(--text-muted, #666)",cursor:"pointer",display:"flex",alignItems:"center",gap:4},children:"📥 PNG"})]}),pe=({chartType:h,title:d,xLabel:x,yLabel:a,series:s,compact:u=!1})=>{const p=T.useRef(null),[S,b]=T.useState(!1);if(!s||s.length===0)return null;const i=[...new Set(s.flatMap(g=>g.data.map(y=>y.x)))],c=i.map(g=>{const y={x:g};return s.forEach(z=>{const k=z.data.find(D=>D.x===g);y[z.name]=k?k.y:null}),y}),n=s.map(g=>g.name),t=n.length===1,r=ie(x,i),m=Math.max(...i.map(g=>String(g).length))>12||i.length>8,j=(m?40:5)+(r?25:0),C=t?0:Math.max(1,Math.ceil(n.length/4)),A=C>0?C*24+(r?24:12):0,W=(u?240:300)+Math.max(0,(C-1)*28),R={...oe,paddingTop:r?24:12,zIndex:0},L={background:"var(--paper-elevated, #fff)",border:"1px solid var(--border, #e0e0e0)",borderRadius:"var(--radius-md, 8px)",padding:"16px",marginBottom:"16px"},G={color:"var(--text-strong, #1e2125)",fontSize:"14px",fontWeight:"600",marginBottom:"12px"},H={dataKey:"x",tick:m?{fill:"var(--text-muted, #666)",fontSize:11,angle:-35,textAnchor:"end"}:Q,axisLine:$,tickLine:$,...r?{label:{value:x,position:"insideBottom",offset:m?-45:-10,style:{textAnchor:"middle",fill:"var(--text-muted, #666)"}}}:{}},V={tick:Q,axisLine:$,tickLine:$,...a?{width:72,label:{value:a,angle:-90,position:"insideLeft",offset:10,style:{textAnchor:"middle",fill:"var(--text-muted, #666)"}}}:{}},ee=()=>{switch(h){case"bar":return e.jsx(o.ResponsiveContainer,{width:"100%",height:W,children:e.jsxs(o.BarChart,{data:c,margin:{top:5,right:30,left:a?10:20,bottom:j},children:[e.jsx(o.CartesianGrid,{strokeDasharray:"3 3",stroke:K}),e.jsx(o.XAxis,{...H}),e.jsx(o.YAxis,{...V}),!t&&e.jsx(o.Legend,{wrapperStyle:R,height:A}),n.map((g,y)=>e.jsx(o.Bar,{dataKey:g,fill:w[y%w.length],radius:[2,2,0,0],isAnimationActive:!1,children:t&&c.map((z,k)=>e.jsx(o.Cell,{fill:w[k%w.length]},k))},g)),e.jsx(o.Tooltip,{wrapperStyle:O.wrapperStyle,content:e.jsx(_,{}),cursor:{fill:"rgba(94, 136, 176, 0.06)",stroke:"rgba(52, 58, 64, 0.18)",strokeDasharray:"3 3"},isAnimationActive:!1,animationDuration:0})]})});case"horizontal_bar":return e.jsx(o.ResponsiveContainer,{width:"100%",height:Math.max(u?240:300,c.length*(u?32:40)),children:e.jsxs(o.BarChart,{data:c,layout:"vertical",margin:{top:5,right:30,left:100,bottom:5},children:[e.jsx(o.CartesianGrid,{strokeDasharray:"3 3",stroke:K}),e.jsx(o.XAxis,{type:"number",tick:Q,axisLine:$,tickLine:$,...a?{label:{value:a,position:"insideBottom",offset:-5,style:{textAnchor:"middle",fill:"var(--text-muted, #666)"}}}:{}}),e.jsx(o.YAxis,{type:"category",dataKey:"x",tick:{fill:"var(--text-muted, #666)",fontSize:11},width:90,axisLine:$,tickLine:$}),!t&&e.jsx(o.Legend,{wrapperStyle:R,height:A}),n.map((g,y)=>e.jsx(o.Bar,{dataKey:g,fill:w[y%w.length],radius:[0,2,2,0],isAnimationActive:!1,children:t&&c.map((z,k)=>e.jsx(o.Cell,{fill:w[k%w.length]},k))},g)),e.jsx(o.Tooltip,{wrapperStyle:O.wrapperStyle,content:e.jsx(_,{}),cursor:{fill:"rgba(94, 136, 176, 0.06)",stroke:"rgba(52, 58, 64, 0.18)",strokeDasharray:"3 3"},isAnimationActive:!1,animationDuration:0})]})});case"line":return e.jsx(o.ResponsiveContainer,{width:"100%",height:W,children:e.jsxs(o.LineChart,{data:c,margin:{top:5,right:30,left:a?10:20,bottom:j},children:[e.jsx(o.CartesianGrid,{strokeDasharray:"3 3",stroke:K}),e.jsx(o.XAxis,{...H}),e.jsx(o.YAxis,{...V}),e.jsx(o.Legend,{wrapperStyle:R,height:A}),n.map((g,y)=>e.jsx(o.Line,{type:"monotone",dataKey:g,stroke:w[y%w.length],strokeWidth:2,dot:{r:4,fill:w[y%w.length]},activeDot:{r:6,fill:w[y%w.length]},isAnimationActive:!1},g)),e.jsx(o.Tooltip,{wrapperStyle:O.wrapperStyle,content:e.jsx(_,{}),cursor:{fill:"rgba(94, 136, 176, 0.06)",stroke:"rgba(52, 58, 64, 0.18)",strokeDasharray:"3 3"},isAnimationActive:!1,animationDuration:0})]})});case"area":return e.jsx(o.ResponsiveContainer,{width:"100%",height:W,children:e.jsxs(o.AreaChart,{data:c,margin:{top:5,right:30,left:a?10:20,bottom:j},children:[e.jsx(o.CartesianGrid,{strokeDasharray:"3 3",stroke:K}),e.jsx(o.XAxis,{...H}),e.jsx(o.YAxis,{...V}),e.jsx(o.Legend,{wrapperStyle:R,height:A}),n.map((g,y)=>e.jsx(o.Area,{type:"monotone",dataKey:g,stroke:w[y%w.length],strokeWidth:2,fill:w[y%w.length],fillOpacity:.15,isAnimationActive:!1},g)),e.jsx(o.Tooltip,{wrapperStyle:O.wrapperStyle,content:e.jsx(_,{}),cursor:{fill:"rgba(94, 136, 176, 0.06)",stroke:"rgba(52, 58, 64, 0.18)",strokeDasharray:"3 3"},isAnimationActive:!1,animationDuration:0})]})});case"pie":{const g=s[0].data.map((k,D)=>({name:k.x,value:k.y,fill:w[D%w.length]})),y=Math.PI/180,z=({cx:k,cy:D,midAngle:E,innerRadius:X,outerRadius:J,percent:P,name:N})=>{const F=J+20,U=k+F*Math.cos(-E*y),q=D+F*Math.sin(-E*y);return P<.04?null:e.jsxs("text",{x:U,y:q,fill:"var(--text-ink, #1e2125)",fontSize:11,textAnchor:U>k?"start":"end",dominantBaseline:"central",children:[N," (",(P*100).toFixed(0),"%)"]})};return e.jsx(o.ResponsiveContainer,{width:"100%",height:u?260:320,children:e.jsxs(o.PieChart,{margin:{top:16,right:16,bottom:16,left:16},children:[e.jsx(o.Pie,{data:g,cx:u?"42%":"38%",cy:"50%",outerRadius:u?88:110,dataKey:"value",label:z,labelLine:{stroke:"var(--text-muted, #666)"},isAnimationActive:!1,children:g.map((k,D)=>e.jsx(o.Cell,{fill:k.fill},D))}),e.jsx(o.Tooltip,{wrapperStyle:O.wrapperStyle,content:e.jsx(_,{}),cursor:{fill:"rgba(94, 136, 176, 0.06)",stroke:"rgba(52, 58, 64, 0.18)",strokeDasharray:"3 3"},isAnimationActive:!1,animationDuration:0})]})})}case"metric":{const g=s[0],y=g.data[0],z=g.data.length>1?g.data[1]:null,k=y.y,D=y.x||"",E=z!==null,X=E?k-z.y:0,J=E&&z.y!==0?X/Math.abs(z.y)*100:0,P=X>0,N=X<0,F=P?"#7BA89D":N?"#D17B6B":"var(--text-muted, #666)",U=P?"↑":N?"↓":"→",q=M=>Number.isInteger(M)&&Math.abs(M)>=1e3?M.toLocaleString():typeof M=="number"?M%1===0?M.toString():M.toFixed(M<10?2:1):String(M);return e.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:12,padding:"8px 0"},children:[e.jsx("div",{style:{fontSize:"36px",fontWeight:700,lineHeight:1,color:"var(--text-strong, #1e2125)",fontVariantNumeric:"tabular-nums"},children:q(k)}),D&&e.jsx("div",{style:{fontSize:"14px",color:"var(--text-muted, #666)",fontWeight:500},children:D}),E&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4,fontSize:"13px",fontWeight:600,color:F,background:P?"rgba(123,168,157,0.12)":N?"rgba(209,123,107,0.12)":"rgba(128,128,128,0.08)",padding:"3px 8px",borderRadius:"var(--radius-sm, 4px)"},children:[e.jsx("span",{children:U}),e.jsxs("span",{children:[q(Math.abs(X))," (",Math.abs(J).toFixed(1),"%)"]})]}),E&&e.jsxs("div",{style:{fontSize:"11px",color:"var(--text-faint, #999)"},children:["vs ",z.x||"previous"]})]})}default:return e.jsxs("div",{style:{color:"var(--text-muted)",fontSize:12,padding:8},children:["Unsupported chart type: ",h]})}},Z=h==="line"||h==="area"||(h==="bar"||h==="horizontal_bar")&&!t?n.map((g,y)=>({label:g,color:w[y%w.length]})):[],te=T.useCallback(()=>{p.current&&ce(p.current,d,Z)},[d,Z]),re=T.useCallback(()=>{de(s,i),b(!0),setTimeout(()=>b(!1),2e3)},[s,i]),ne=h!=="metric";return e.jsxs("div",{style:L,children:[d&&e.jsx("div",{style:G,children:d}),ne&&e.jsx(he,{onDownloadPng:te,onCopy:re,copied:S}),e.jsx("div",{ref:p,children:ee()})]})},ge=({content:h,onCodeBlockClick:d,onFilePathClick:x})=>{const[a,s]=T.useState(new Set),u=async(c,n)=>{try{await navigator.clipboard.writeText(c),s(t=>new Set([...t,n])),setTimeout(()=>{s(t=>{const r=new Set(t);return r.delete(n),r})},2e3)}catch(t){console.error("Failed to copy text:",t)}},p=(c,n,t)=>{const r=a.has(t);return e.jsxs("div",{style:{position:"relative",marginBottom:"16px",borderRadius:"8px",background:"var(--ink, #1E2125)",border:"1px solid var(--border-subtle, rgba(52,58,64,0.08))",overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"8px 12px",background:"rgba(255,255,255,0.05)",borderBottom:"1px solid rgba(255,255,255,0.1)"},children:[e.jsx("span",{style:{fontSize:"11px",color:"rgba(255,255,255,0.7)",fontFamily:"var(--font-mono, monospace)",textTransform:"uppercase",letterSpacing:"0.05em"},children:n||"code"}),e.jsxs("button",{onClick:()=>u(c,t),style:{background:"none",border:"none",color:"rgba(255,255,255,0.7)",cursor:"pointer",padding:"4px",borderRadius:"4px",display:"flex",alignItems:"center",gap:"4px",fontSize:"11px",transition:"all 0.15s ease"},onMouseEnter:v=>{v.target.style.background="rgba(255,255,255,0.1)",v.target.style.color="rgba(255,255,255,0.9)"},onMouseLeave:v=>{v.target.style.background="none",v.target.style.color="rgba(255,255,255,0.7)"},children:[r?e.jsx(Y.Check,{size:12}):e.jsx(Y.Copy,{size:12}),r?"Copied!":"Copy"]}),d&&e.jsxs("button",{onClick:()=>d({code:c,language:n}),style:{background:"none",border:"none",color:"rgba(255,255,255,0.7)",cursor:"pointer",padding:"4px",borderRadius:"4px",display:"flex",alignItems:"center",gap:"4px",fontSize:"11px",transition:"all 0.15s ease"},onMouseEnter:v=>{v.currentTarget.style.background="rgba(255,255,255,0.1)",v.currentTarget.style.color="rgba(255,255,255,0.9)"},onMouseLeave:v=>{v.currentTarget.style.background="none",v.currentTarget.style.color="rgba(255,255,255,0.7)"},children:[e.jsx(Y.PanelRightOpen,{size:12}),"Canvas"]})]}),e.jsx("pre",{style:{margin:0,padding:"12px",fontFamily:"var(--font-mono, monospace)",fontSize:"13px",lineHeight:1.4,color:"rgba(255,255,255,0.95)",overflow:"auto",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:c})]},t)},S=c=>{const n=[],t=c.split(`
13
+ `);let r=0,v=0;for(;r<t.length;){const m=t[r];if(m.trim().startsWith("```")){const l=m.trim().slice(3);let f=[];for(r++;r<t.length&&!t[r].trim().startsWith("```");)f.push(t[r]),r++;r<t.length&&r++,n.push(p(f.join(`
14
+ `),l,`code-${v++}`));continue}if(m.startsWith("#")){const l=m.match(/^#+/)[0].length,f=m.slice(l).trim(),j=l===1?"h2":l===2?"h3":l===3?"h4":"h5";n.push(T.createElement(j,{key:`header-${r}`,style:{fontSize:l===1?"18px":l===2?"16px":"14px",fontWeight:720,color:"var(--text-strong, rgba(30,33,37,0.92))",marginTop:n.length>0?"20px":"0",marginBottom:"8px",lineHeight:1.3}},f)),r++;continue}if(m.trim()==="---"||m.trim()==="***"){n.push(e.jsx("hr",{style:{border:"none",borderTop:"1px solid var(--border-subtle, rgba(52,58,64,0.08))",margin:"16px 0"}},`hr-${r}`)),r++;continue}if(m.match(/^(\s*)([-*+]|\d+\.)\s/)){const l=[],f=/^\s*\d+\./.test(m);for(;r<t.length&&(t[r].match(/^(\s*)([-*+]|\d+\.)\s/)||t[r].trim()==="");){if(t[r].trim()!==""){const C=t[r].match(/^(\s*)([-*+]|\d+\.)\s(.*)$/);C&&l.push(C[3])}r++}const j=f?"ol":"ul";n.push(T.createElement(j,{key:`list-${r}`,style:{margin:"8px 0",paddingLeft:"20px",color:"var(--text-strong, rgba(30,33,37,0.92))"}},l.map((C,A)=>T.createElement("li",{key:`item-${A}`,style:{marginBottom:"4px"}},i(C)))));continue}if(m.trim().startsWith("|")&&m.trim().endsWith("|")){const l=[];for(;r<t.length&&t[r].trim().startsWith("|")&&t[r].trim().endsWith("|");)l.push(t[r]),r++;if(l.length>=2){const f=R=>R.trim().slice(1,-1).split("|").map(L=>L.trim()),j=f(l[0]),C=R=>f(R).every(L=>/^[-:]+$/.test(L)),A=l.length>=2&&C(l[1]),B=A?2:1,W=A?f(l[1]).map(R=>R.startsWith(":")&&R.endsWith(":")?"center":R.endsWith(":")?"right":"left"):j.map(()=>"left"),I={padding:"6px 12px",borderBottom:"1px solid var(--border-subtle, rgba(52,58,64,0.08))",fontSize:"13px",lineHeight:1.5,color:"var(--text-strong, rgba(30,33,37,0.92))",wordBreak:"normal",overflowWrap:"normal"};n.push(e.jsx("div",{style:{overflowX:"auto",margin:"8px 0"},children:e.jsxs("table",{style:{borderCollapse:"collapse",width:"100%",border:"1px solid var(--border-subtle, rgba(52,58,64,0.08))",borderRadius:"6px",overflow:"hidden"},children:[A&&e.jsx("thead",{children:e.jsx("tr",{style:{background:"var(--hover-warm-subtle, rgba(231,212,162,0.08))"},children:j.map((R,L)=>e.jsx("th",{style:{...I,fontWeight:660,textAlign:W[L]||"left",whiteSpace:"nowrap"},children:i(R)},L))})}),e.jsx("tbody",{children:(A?l.slice(B):l).map((R,L)=>e.jsx("tr",{style:{background:L%2===1?"var(--hover-warm-subtle, rgba(231,212,162,0.04))":"transparent"},children:f(R).map((G,H)=>e.jsx("td",{style:{...I,textAlign:W[H]||"left"},children:i(G)},H))},L))})]})},`table-${r}`))}continue}if(m.trim()){const l=[];for(;r<t.length&&t[r].trim()&&!t[r].match(/^(#|```|---|\*\*\*|(\s*)([-*+]|\d+\.)\s)/)&&!(t[r].trim().startsWith("|")&&t[r].trim().endsWith("|"));)l.push(t[r]),r++;l.length>0&&n.push(e.jsx("p",{style:{margin:"8px 0",lineHeight:1.6,color:"var(--text-strong, rgba(30,33,37,0.92))"},children:i(l.join(" "))},`p-${r}`))}else r++}return n},b=c=>{const n=[];let t=c,r=0;for(;t.length>0;){if(x){const C=t.match(/^([^\s`*\[]+(?:\/src\/|\/components\/|\/packages\/)[^\s`*\[]*|[^\s`*\[]*\.(ts|tsx|js|jsx|py|css|scss|sass|json|md|yaml|yml|html|xml|sh|sql|go|rs|php|java|c|cpp|h|hpp)(?:\b|$))/);if(C){const A=C[1];n.push(e.jsx("span",{onClick:()=>x(A),style:{color:"var(--rail-discovery, #5E88B0)",textDecoration:"underline",textDecorationStyle:"dotted",textUnderlineOffset:"2px",cursor:"pointer",fontFamily:"var(--font-mono, monospace)",fontSize:"13px",transition:"all 0.15s ease",":hover":{background:"var(--hover-warm-subtle, rgba(231,212,162,0.08))",textDecoration:"underline",textDecorationStyle:"solid"}},onMouseEnter:B=>{B.target.style.background="var(--hover-warm-subtle, rgba(231,212,162,0.08))",B.target.style.textDecorationStyle="solid"},onMouseLeave:B=>{B.target.style.background="none",B.target.style.textDecorationStyle="dotted"},children:A},`file-path-${r++}`)),t=t.slice(C[0].length);continue}}const v=t.match(/^`([^`]+)`/);if(v){n.push(e.jsx("code",{style:{background:"var(--hover-warm-subtle, rgba(231,212,162,0.08))",border:"1px solid var(--border-subtle, rgba(52,58,64,0.08))",borderRadius:"3px",padding:"2px 4px",fontFamily:"var(--font-mono, monospace)",fontSize:"12px",color:"var(--text-strong, rgba(30,33,37,0.92))"},children:v[1]},`inline-code-${r++}`)),t=t.slice(v[0].length);continue}const m=t.match(/^\*\*([^*]+)\*\*/);if(m){n.push(e.jsx("strong",{style:{fontWeight:720,color:"var(--text-strong, rgba(30,33,37,0.92))"},children:m[1]},`bold-${r++}`)),t=t.slice(m[0].length);continue}const l=t.match(/^\*([^*]+)\*/);if(l){n.push(e.jsx("em",{style:{fontStyle:"italic",color:"var(--text-strong, rgba(30,33,37,0.92))"},children:l[1]},`italic-${r++}`)),t=t.slice(l[0].length);continue}const f=t.match(/^\[([^\]]+)\]\(([^)]+)\)/);if(f){const C=f[1],A=f[2],B=C==="View",W={display:"inline-flex",alignItems:"center",padding:"3px 10px",background:"var(--rail-discovery, #5E88B0)",color:"#fff",textDecoration:"none",borderRadius:"4px",fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",cursor:"pointer"},I={color:"var(--rail-discovery, #5E88B0)",textDecoration:"underline",textUnderlineOffset:"2px"};n.push(e.jsx("a",{href:A,target:"_blank",rel:"noopener noreferrer",style:B?W:I,children:C},`link-${r++}`)),t=t.slice(f[0].length);continue}const j=t.search(/[`*\[]/);if(j===-1){n.push(t);break}else j===0?(n.push(t[0]),t=t.slice(1)):(n.push(t.slice(0,j)),t=t.slice(j))}return n.length===1&&typeof n[0]=="string"?n[0]:n},i=c=>b(c);return e.jsx("div",{children:S(h)})};function xe({role:h,content:d,html:x,timestamp:a,toolBadges:s,isStreaming:u,onCodeBlockClick:p,onFilePathClick:S}){const b=h==="user";return e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:b?"flex-end":"flex-start",marginBottom:"16px",maxWidth:"100%"},children:[e.jsxs("div",{style:{fontSize:"var(--text-sm, 11px)",color:"var(--text-faint, rgba(30,33,37,0.36))",marginBottom:"6px",fontWeight:650,letterSpacing:"0.02em"},children:[b?"You":"Chordia",u&&!b&&e.jsx("span",{style:{marginLeft:"6px",color:"var(--rail-purple, #9B7AA8)"},children:"●"})]}),s&&s.length>0&&e.jsx("div",{style:{marginBottom:"8px",display:"flex",flexWrap:"wrap",gap:"4px",maxWidth:"75%"},children:s.map((i,c)=>e.jsxs("span",{style:{display:"inline-block",fontSize:"11px",padding:"2px 8px",borderRadius:"6px",background:"var(--paper-elevated, rgba(255,255,255,0.82))",border:`1px solid ${i.pending?"var(--rail-discovery, #5A8CC0)":i.success!==!1?"var(--state-present, #5CB85C)":"var(--rail-signal-churn, #C98A5A)"}`,color:i.pending?"var(--rail-discovery, #5A8CC0)":i.success!==!1?"var(--state-present, #5CB85C)":"var(--rail-signal-churn, #C98A5A)"},children:[e.jsx(Y.Wrench,{size:10,style:{marginRight:3,verticalAlign:"middle"}}),i.name,i.pending?"...":i.success!==!1?" ✓":" ✗"]},i.id||c))}),e.jsx("div",{style:{maxWidth:"75%",padding:"12px 16px",borderRadius:"var(--radius-lg, 12px)",background:b?"var(--card-customer, rgba(94,136,176,0.08))":"var(--paper-elevated, rgba(255,255,255,0.82))",border:b?"1px solid var(--border-subtle, rgba(52,58,64,0.08))":"1px solid var(--border, rgba(52,58,64,0.12))",fontSize:"var(--text-base, 14px)",lineHeight:1.6,color:"var(--text-strong, rgba(30,33,37,0.92))",wordBreak:"break-word"},children:x?e.jsx("div",{dangerouslySetInnerHTML:{__html:x}}):b?e.jsx("div",{style:{whiteSpace:"pre-wrap"},children:d}):e.jsx(ge,{content:d||"",onCodeBlockClick:p,onFilePathClick:S})}),a&&e.jsx("div",{style:{fontSize:"var(--text-xs-plus, 10.5px)",color:"var(--text-faint, rgba(30,33,37,0.36))",marginTop:"4px",fontFamily:"var(--font-mono, monospace)"},children:a})]})}exports.ChartRenderer=pe;exports.ChatMessage=xe;
15
+ //# sourceMappingURL=ChatMessage.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChatMessage.cjs.js","sources":["../src/components/chat/ChartRenderer.jsx","../src/components/chat/ChatMessage.jsx"],"sourcesContent":["\"use client\";\nimport React, { useRef, useCallback } from 'react';\nimport {\n ResponsiveContainer, BarChart, Bar, Cell, LineChart, Line,\n XAxis, YAxis, CartesianGrid, Tooltip, Legend,\n PieChart, Pie, AreaChart, Area,\n} from 'recharts';\n\n// Chordia design system rail colors — ordered for max visual distinction\nconst COLORS = [\n '#5E88B0', // rail-discovery / rail-blue\n '#9B7AA8', // rail-purple / rail-tone\n '#C98A5A', // rail-compliance / rail-orange\n '#7BA89D', // rail-signal-upsell (teal-green)\n '#D17B6B', // rail-coral / rail-signal-churn\n '#6B7C93', // rail-slate / rail-outcome\n '#9B8E6F', // rail-olive / rail-signal-satisfaction\n '#8A9BAF', // rail-quality\n '#B8976A', // rail-teal (warm gold)\n '#A8C76B', // green accent (complementary)\n];\n\n// Shared axis/tooltip/legend styling\nconst AXIS_TICK = { fill: 'var(--text-muted, #666)', fontSize: 12 };\nconst AXIS_LINE = { stroke: 'var(--border, #e0e0e0)' };\nconst GRID_STROKE = 'var(--border, #e0e0e0)';\nconst TOOLTIP_STYLE = {\n // pointerEvents: 'none' is critical — without it, the tooltip steals hover from chart elements\n // and flickers (especially noticeable on pie slices).\n // transition: 'none' disables Recharts' default position-slide animation, so the tooltip\n // snaps to the active point instead of flying in from its previous location.\n wrapperStyle: {\n zIndex: 9999,\n pointerEvents: 'none',\n outline: 'none',\n transition: 'none',\n },\n};\nconst LEGEND_STYLE = { color: 'var(--text-ink, #1e2125)', fontSize: '12px' };\n\n// Custom tooltip with a clean light-bg card layout.\n// Each row has a colored dot (the series color) + dark text — always readable, no contrast tricks.\nconst ChartTooltip = ({ active, payload, label }) => {\n if (!active || !payload || !payload.length) return null;\n return (\n <div\n className=\"chordia-chart-tooltip\"\n style={{\n background: '#ffffff',\n border: '1px solid rgba(52, 58, 64, 0.12)',\n borderRadius: 8,\n boxShadow: '0 8px 24px rgba(15, 23, 42, 0.12), 0 2px 6px rgba(15, 23, 42, 0.06)',\n padding: '10px 12px',\n minWidth: 140,\n maxWidth: 280,\n maxHeight: 280,\n overflowY: 'auto',\n fontSize: 12,\n lineHeight: 1.5,\n color: '#1E2125',\n // Re-enable pointer events on the inner content so the user can scroll with the wheel\n // even though the wrapper above has pointerEvents: 'none' (which prevents hover flicker).\n pointerEvents: 'auto',\n }}\n >\n <style>{`\n .chordia-chart-tooltip::-webkit-scrollbar { width: 8px; }\n .chordia-chart-tooltip::-webkit-scrollbar-track { background: transparent; }\n .chordia-chart-tooltip::-webkit-scrollbar-thumb {\n background: rgba(52, 58, 64, 0.25);\n border-radius: 4px;\n }\n .chordia-chart-tooltip::-webkit-scrollbar-thumb:hover {\n background: rgba(52, 58, 64, 0.4);\n }\n `}</style>\n {label !== undefined && label !== '' && (\n <div\n style={{\n fontSize: 11,\n fontWeight: 600,\n letterSpacing: '0.02em',\n color: '#6B7280',\n textTransform: 'uppercase',\n marginBottom: 6,\n paddingBottom: 6,\n borderBottom: '1px solid rgba(52, 58, 64, 0.08)',\n }}\n >\n {label}\n </div>\n )}\n <div style={{ display: 'flex', flexDirection: 'column', gap: 4 }}>\n {payload.map((entry, i) => {\n const seriesColor = entry.color || entry.payload?.fill || '#9CA3AF';\n return (\n <div\n key={i}\n style={{\n display: 'flex',\n alignItems: 'center',\n gap: 8,\n justifyContent: 'space-between',\n }}\n >\n <div style={{ display: 'flex', alignItems: 'center', gap: 8, minWidth: 0 }}>\n <span\n style={{\n width: 8,\n height: 8,\n borderRadius: '50%',\n background: seriesColor,\n flexShrink: 0,\n }}\n />\n <span\n style={{\n color: '#374151',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n }}\n >\n {entry.name}\n </span>\n </div>\n <span style={{ color: '#111827', fontWeight: 600, marginLeft: 8 }}>\n {entry.value}\n </span>\n </div>\n );\n })}\n </div>\n </div>\n );\n};\n\n// Smart label: skip x_label if tick values already contain the label text\nconst shouldShowAxisLabel = (label, tickValues) => {\n if (!label) return false;\n const lower = label.toLowerCase();\n // If most ticks contain the label word, it's redundant\n const matches = tickValues.filter(v => String(v).toLowerCase().includes(lower));\n return matches.length < tickValues.length * 0.5;\n};\n\n// --- Export utilities ---\nconst getChartSvg = (containerEl) => {\n const wrappers = Array.from(containerEl.querySelectorAll('.recharts-wrapper'));\n const largestWrapper = wrappers.length\n ? wrappers.reduce((largest, current) => {\n const largestRect = largest.getBoundingClientRect();\n const currentRect = current.getBoundingClientRect();\n return (currentRect.width * currentRect.height) > (largestRect.width * largestRect.height)\n ? current\n : largest;\n })\n : null;\n\n if (largestWrapper) {\n const surface = largestWrapper.querySelector('svg.recharts-surface');\n if (surface) {\n const rect = surface.getBoundingClientRect();\n if (rect.width >= 100 && rect.height >= 100) return surface;\n }\n }\n\n // Fallback: pick the largest SVG so we don't accidentally export icon SVGs.\n const candidates = Array.from(containerEl.querySelectorAll('svg'));\n if (!candidates.length) return null;\n\n const largestSvg = candidates.reduce((largest, current) => {\n const largestRect = largest.getBoundingClientRect();\n const currentRect = current.getBoundingClientRect();\n return (currentRect.width * currentRect.height) > (largestRect.width * largestRect.height)\n ? current\n : largest;\n });\n\n const largestRect = largestSvg.getBoundingClientRect();\n if (largestRect.width < 100 || largestRect.height < 100) return null;\n\n return largestSvg;\n};\n\nconst escapeXml = (value) => String(value)\n .replace(/&/g, '&amp;')\n .replace(/</g, '&lt;')\n .replace(/>/g, '&gt;')\n .replace(/\"/g, '&quot;')\n .replace(/'/g, '&apos;');\n\nconst buildExportSvg = ({ chartSvg, width, height, legendItems = [] }) => {\n const baseSvg = chartSvg.cloneNode(true);\n const legendLineHeight = 20;\n const legendStartX = 16;\n const legendRightPadding = 16;\n const maxLegendX = width - legendRightPadding;\n const legendRows = [];\n let currentRow = [];\n let currentRowWidth = 0;\n\n legendItems.forEach(({ label, color }) => {\n const itemWidth = Math.max(40, (String(label).length * 7) + 34);\n if (currentRow.length && (legendStartX + currentRowWidth + itemWidth > maxLegendX)) {\n legendRows.push(currentRow);\n currentRow = [];\n currentRowWidth = 0;\n }\n currentRow.push({ label, color, itemWidth });\n currentRowWidth += itemWidth;\n });\n if (currentRow.length) legendRows.push(currentRow);\n\n const exportLegendHeight = legendRows.length ? (legendRows.length * legendLineHeight) + 20 : 0;\n const exportHeight = height + exportLegendHeight;\n\n baseSvg.setAttribute('width', width);\n baseSvg.setAttribute('height', height);\n baseSvg.setAttribute('x', 0);\n baseSvg.setAttribute('y', 0);\n\n const legendMarkup = legendRows.map((row, rowIndex) => {\n let cursorX = legendStartX;\n const legendLineY = height + 20 + (rowIndex * legendLineHeight);\n const rowMarkup = row.map(({ label, color, itemWidth }) => {\n const line = `<line x1=\"${cursorX}\" y1=\"${legendLineY}\" x2=\"${cursorX + 10}\" y2=\"${legendLineY}\" stroke=\"${color}\" stroke-width=\"2\" />`;\n const dot = `<circle cx=\"${cursorX + 5}\" cy=\"${legendLineY}\" r=\"2.5\" fill=\"#fff\" stroke=\"${color}\" stroke-width=\"1.5\" />`;\n const text = `<text x=\"${cursorX + 14}\" y=\"${legendLineY + 4}\" fill=\"#666\" font-size=\"12\">${escapeXml(label)}</text>`;\n cursorX += itemWidth;\n return `${line}${dot}${text}`;\n }).join('');\n return rowMarkup;\n }).join('');\n\n return [\n `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"${width}\" height=\"${exportHeight}\" viewBox=\"0 0 ${width} ${exportHeight}\">`,\n '<style>text { font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif; }</style>',\n '<rect x=\"0\" y=\"0\" width=\"100%\" height=\"100%\" fill=\"#ffffff\" />',\n new XMLSerializer().serializeToString(baseSvg),\n legendMarkup,\n '</svg>',\n ].join('');\n};\n\nconst downloadPng = async (containerEl, title, legendItems = []) => {\n const svg = getChartSvg(containerEl);\n if (!svg) return;\n // Ensure dimensions\n const svgRect = svg.getBoundingClientRect();\n const w = svgRect.width || svg.clientWidth || Number(svg.getAttribute('width')) || 600;\n const h = svgRect.height || svg.clientHeight || Number(svg.getAttribute('height')) || 300;\n const xml = buildExportSvg({ chartSvg: svg, width: w, height: h, legendItems });\n const blob = new Blob([xml], { type: 'image/svg+xml;charset=utf-8' });\n const url = URL.createObjectURL(blob);\n const img = new Image();\n img.onload = () => {\n const canvas = document.createElement('canvas');\n const scale = 2; // retina\n canvas.width = w * scale;\n canvas.height = h * scale;\n const ctx = canvas.getContext('2d');\n ctx.fillStyle = '#ffffff';\n ctx.fillRect(0, 0, canvas.width, canvas.height);\n ctx.scale(scale, scale);\n ctx.drawImage(img, 0, 0, w, h);\n URL.revokeObjectURL(url);\n const link = document.createElement('a');\n link.download = `${(title || 'chart').replace(/[^a-z0-9]+/gi, '_')}.png`;\n link.href = canvas.toDataURL('image/png');\n link.click();\n };\n img.src = url;\n};\n\nconst downloadSvg = (containerEl, title, legendItems = []) => {\n const svg = getChartSvg(containerEl);\n if (!svg) return;\n const svgRect = svg.getBoundingClientRect();\n const w = svgRect.width || svg.clientWidth || Number(svg.getAttribute('width')) || 600;\n const h = svgRect.height || svg.clientHeight || Number(svg.getAttribute('height')) || 300;\n\n const xml = buildExportSvg({ chartSvg: svg, width: w, height: h, legendItems });\n const blob = new Blob([xml], { type: 'image/svg+xml;charset=utf-8' });\n const url = URL.createObjectURL(blob);\n const link = document.createElement('a');\n link.download = `${(title || 'chart').replace(/[^a-z0-9]+/gi, '_')}.svg`;\n link.href = url;\n link.click();\n setTimeout(() => URL.revokeObjectURL(url), 1000);\n};\n\nconst copyAsCsv = (series, allXValues) => {\n const header = ['', ...series.map(s => s.name)].join(',');\n const rows = allXValues.map(x => {\n const vals = series.map(s => {\n const match = s.data.find(d => d.x === x);\n return match ? match.y : '';\n });\n return [x, ...vals].join(',');\n });\n const csv = [header, ...rows].join('\\n');\n navigator.clipboard.writeText(csv);\n};\n\nconst ActionBar = ({ onDownloadPng, onCopy, copied }) => (\n <div style={{\n display: 'flex', gap: 6, justifyContent: 'flex-end',\n marginBottom: 8, opacity: 0.7, transition: 'opacity 0.15s',\n }}>\n <button onClick={onCopy} title=\"Copy data as CSV\" style={{\n background: 'none', border: '1px solid var(--border, #e0e0e0)',\n borderRadius: 'var(--radius-sm, 4px)', padding: '3px 8px',\n fontSize: 11, color: 'var(--text-muted, #666)', cursor: 'pointer',\n display: 'flex', alignItems: 'center', gap: 4,\n }}>\n {copied ? '✓ Copied' : '📋 CSV'}\n </button>\n <button onClick={onDownloadPng} title=\"Download as PNG\" style={{\n background: 'none', border: '1px solid var(--border, #e0e0e0)',\n borderRadius: 'var(--radius-sm, 4px)', padding: '3px 8px',\n fontSize: 11, color: 'var(--text-muted, #666)', cursor: 'pointer',\n display: 'flex', alignItems: 'center', gap: 4,\n }}>\n 📥 PNG\n </button>\n </div>\n);\n\nconst ChartRenderer = ({ chartType, title, xLabel, yLabel, series, compact = false }) => {\n const chartRef = useRef(null);\n const [copied, setCopied] = React.useState(false);\n\n if (!series || series.length === 0) return null;\n\n // Transform: merge all series into [{x, series1: val, series2: val}, ...]\n const allXValues = [...new Set(series.flatMap(s => s.data.map(d => d.x)))];\n const chartData = allXValues.map(x => {\n const point = { x };\n series.forEach(s => {\n const match = s.data.find(d => d.x === x);\n point[s.name] = match ? match.y : null;\n });\n return point;\n });\n\n const seriesNames = series.map(s => s.name);\n const isSingleSeries = seriesNames.length === 1;\n\n // Determine if axis labels are redundant\n const showXLabel = shouldShowAxisLabel(xLabel, allXValues);\n\n // Check if x-axis labels are long (rotate them)\n const maxTickLen = Math.max(...allXValues.map(v => String(v).length));\n const rotateXTicks = maxTickLen > 12 || allXValues.length > 8;\n\n // Bottom margin: stack space for tick labels + the axis label so they don't overlap\n const xTickSpace = rotateXTicks ? 40 : 5;\n const xLabelSpace = showXLabel ? 25 : 0;\n const bottomMargin = xTickSpace + xLabelSpace;\n\n // Estimate legend rows so we can reserve enough vertical space for it. Recharts\n // doesn't auto-detect wrapping, so a multi-row legend collides with the x-axis label.\n // Conservative estimate: ~4 items per row.\n const legendRows = isSingleSeries ? 0 : Math.max(1, Math.ceil(seriesNames.length / 4));\n const legendHeight = legendRows > 0 ? legendRows * 24 + (showXLabel ? 24 : 12) : 0;\n\n // Bump chart container height so the wrapped legend gets its own space below the chart\n // SVG instead of overlapping the x-axis label.\n // In compact mode (e.g. AskCompass panel), shrink the base height so charts feel proportional\n // to the smaller surface they're rendered in.\n const baseChartHeight = compact ? 240 : 300;\n const chartHeight = baseChartHeight + Math.max(0, (legendRows - 1) * 28);\n\n // Always keep a gap between the x-axis (or its label) and the legend.\n // Extra padding when an x-label is also present so all three layers (ticks → label → legend) breathe.\n // zIndex: 0 ensures the legend never paints over the tooltip (which is zIndex: 1000).\n const legendPaddingTop = showXLabel ? 24 : 12;\n const legendWrapperStyle = { ...LEGEND_STYLE, paddingTop: legendPaddingTop, zIndex: 0 };\n\n const containerStyle = {\n background: 'var(--paper-elevated, #fff)',\n border: '1px solid var(--border, #e0e0e0)',\n borderRadius: 'var(--radius-md, 8px)',\n padding: '16px',\n marginBottom: '16px',\n };\n\n const titleStyle = {\n color: 'var(--text-strong, #1e2125)',\n fontSize: '14px',\n fontWeight: '600',\n marginBottom: '12px',\n };\n\n const xAxisProps = {\n dataKey: 'x',\n tick: rotateXTicks\n ? { fill: 'var(--text-muted, #666)', fontSize: 11, angle: -35, textAnchor: 'end' }\n : AXIS_TICK,\n axisLine: AXIS_LINE,\n tickLine: AXIS_LINE,\n ...(showXLabel ? {\n label: {\n value: xLabel,\n position: 'insideBottom',\n // Push label below rotated ticks (which take ~40px) when present\n offset: rotateXTicks ? -45 : -10,\n style: { textAnchor: 'middle', fill: 'var(--text-muted, #666)' },\n },\n } : {}),\n };\n\n const yAxisProps = {\n tick: AXIS_TICK,\n axisLine: AXIS_LINE,\n tickLine: AXIS_LINE,\n ...(yLabel ? {\n width: 72,\n label: {\n value: yLabel,\n angle: -90,\n position: 'insideLeft',\n offset: 10,\n style: { textAnchor: 'middle', fill: 'var(--text-muted, #666)' },\n },\n } : {}),\n };\n\n const renderChart = () => {\n switch (chartType) {\n case 'bar':\n return (\n <ResponsiveContainer width=\"100%\" height={chartHeight}>\n <BarChart data={chartData} margin={{ top: 5, right: 30, left: yLabel ? 10 : 20, bottom: bottomMargin }}>\n <CartesianGrid strokeDasharray=\"3 3\" stroke={GRID_STROKE} />\n <XAxis {...xAxisProps} />\n <YAxis {...yAxisProps} />\n {!isSingleSeries && <Legend wrapperStyle={legendWrapperStyle} height={legendHeight} />}\n {seriesNames.map((name, i) => (\n <Bar key={name} dataKey={name} fill={COLORS[i % COLORS.length]} radius={[2, 2, 0, 0]} isAnimationActive={false}>\n {isSingleSeries && chartData.map((_, idx) => (\n <Cell key={idx} fill={COLORS[idx % COLORS.length]} />\n ))}\n </Bar>\n ))}\n <Tooltip wrapperStyle={TOOLTIP_STYLE.wrapperStyle} content={<ChartTooltip />} cursor={{ fill: 'rgba(94, 136, 176, 0.06)', stroke: 'rgba(52, 58, 64, 0.18)', strokeDasharray: '3 3' }} isAnimationActive={false} animationDuration={0} />\n </BarChart>\n </ResponsiveContainer>\n );\n\n case 'horizontal_bar': {\n // Horizontal bar: swap X/Y, use YAxis for categories\n return (\n <ResponsiveContainer width=\"100%\" height={Math.max(compact ? 240 : 300, chartData.length * (compact ? 32 : 40))}>\n <BarChart data={chartData} layout=\"vertical\" margin={{ top: 5, right: 30, left: 100, bottom: 5 }}>\n <CartesianGrid strokeDasharray=\"3 3\" stroke={GRID_STROKE} />\n <XAxis type=\"number\" tick={AXIS_TICK} axisLine={AXIS_LINE} tickLine={AXIS_LINE}\n {...(yLabel ? { label: { value: yLabel, position: 'insideBottom', offset: -5, style: { textAnchor: 'middle', fill: 'var(--text-muted, #666)' } } } : {})}\n />\n <YAxis type=\"category\" dataKey=\"x\" tick={{ fill: 'var(--text-muted, #666)', fontSize: 11 }} width={90} axisLine={AXIS_LINE} tickLine={AXIS_LINE} />\n {!isSingleSeries && <Legend wrapperStyle={legendWrapperStyle} height={legendHeight} />}\n {seriesNames.map((name, i) => (\n <Bar key={name} dataKey={name} fill={COLORS[i % COLORS.length]} radius={[0, 2, 2, 0]} isAnimationActive={false}>\n {isSingleSeries && chartData.map((_, idx) => (\n <Cell key={idx} fill={COLORS[idx % COLORS.length]} />\n ))}\n </Bar>\n ))}\n <Tooltip wrapperStyle={TOOLTIP_STYLE.wrapperStyle} content={<ChartTooltip />} cursor={{ fill: 'rgba(94, 136, 176, 0.06)', stroke: 'rgba(52, 58, 64, 0.18)', strokeDasharray: '3 3' }} isAnimationActive={false} animationDuration={0} />\n </BarChart>\n </ResponsiveContainer>\n );\n }\n\n case 'line':\n return (\n <ResponsiveContainer width=\"100%\" height={chartHeight}>\n <LineChart data={chartData} margin={{ top: 5, right: 30, left: yLabel ? 10 : 20, bottom: bottomMargin }}>\n <CartesianGrid strokeDasharray=\"3 3\" stroke={GRID_STROKE} />\n <XAxis {...xAxisProps} />\n <YAxis {...yAxisProps} />\n <Legend wrapperStyle={legendWrapperStyle} height={legendHeight} />\n {seriesNames.map((name, i) => (\n <Line key={name} type=\"monotone\" dataKey={name}\n stroke={COLORS[i % COLORS.length]} strokeWidth={2}\n dot={{ r: 4, fill: COLORS[i % COLORS.length] }}\n activeDot={{ r: 6, fill: COLORS[i % COLORS.length] }}\n isAnimationActive={false}\n />\n ))}\n <Tooltip wrapperStyle={TOOLTIP_STYLE.wrapperStyle} content={<ChartTooltip />} cursor={{ fill: 'rgba(94, 136, 176, 0.06)', stroke: 'rgba(52, 58, 64, 0.18)', strokeDasharray: '3 3' }} isAnimationActive={false} animationDuration={0} />\n </LineChart>\n </ResponsiveContainer>\n );\n\n case 'area':\n return (\n <ResponsiveContainer width=\"100%\" height={chartHeight}>\n <AreaChart data={chartData} margin={{ top: 5, right: 30, left: yLabel ? 10 : 20, bottom: bottomMargin }}>\n <CartesianGrid strokeDasharray=\"3 3\" stroke={GRID_STROKE} />\n <XAxis {...xAxisProps} />\n <YAxis {...yAxisProps} />\n <Legend wrapperStyle={legendWrapperStyle} height={legendHeight} />\n {seriesNames.map((name, i) => (\n <Area key={name} type=\"monotone\" dataKey={name}\n stroke={COLORS[i % COLORS.length]} strokeWidth={2}\n fill={COLORS[i % COLORS.length]} fillOpacity={0.15}\n isAnimationActive={false}\n />\n ))}\n <Tooltip wrapperStyle={TOOLTIP_STYLE.wrapperStyle} content={<ChartTooltip />} cursor={{ fill: 'rgba(94, 136, 176, 0.06)', stroke: 'rgba(52, 58, 64, 0.18)', strokeDasharray: '3 3' }} isAnimationActive={false} animationDuration={0} />\n </AreaChart>\n </ResponsiveContainer>\n );\n\n case 'pie': {\n // Pie uses first series only\n const pieData = series[0].data.map((d, i) => ({\n name: d.x,\n value: d.y,\n fill: COLORS[i % COLORS.length],\n }));\n const RADIAN = Math.PI / 180;\n const renderLabel = ({ cx, cy, midAngle, innerRadius, outerRadius, percent, name }) => {\n const radius = outerRadius + 20;\n const x = cx + radius * Math.cos(-midAngle * RADIAN);\n const y = cy + radius * Math.sin(-midAngle * RADIAN);\n if (percent < 0.04) return null;\n return (\n <text x={x} y={y} fill=\"var(--text-ink, #1e2125)\" fontSize={11}\n textAnchor={x > cx ? 'start' : 'end'} dominantBaseline=\"central\">\n {name} ({(percent * 100).toFixed(0)}%)\n </text>\n );\n };\n return (\n <ResponsiveContainer width=\"100%\" height={compact ? 260 : 320}>\n <PieChart margin={{ top: 16, right: 16, bottom: 16, left: 16 }}>\n <Pie data={pieData} cx={compact ? \"42%\" : \"38%\"} cy=\"50%\" outerRadius={compact ? 88 : 110}\n dataKey=\"value\" label={renderLabel} labelLine={{ stroke: 'var(--text-muted, #666)' }}\n isAnimationActive={false}>\n {pieData.map((entry, i) => (\n <Cell key={i} fill={entry.fill} />\n ))}\n </Pie>\n <Tooltip wrapperStyle={TOOLTIP_STYLE.wrapperStyle} content={<ChartTooltip />} cursor={{ fill: 'rgba(94, 136, 176, 0.06)', stroke: 'rgba(52, 58, 64, 0.18)', strokeDasharray: '3 3' }} isAnimationActive={false} animationDuration={0} />\n </PieChart>\n </ResponsiveContainer>\n );\n }\n\n case 'metric': {\n const s = series[0];\n const current = s.data[0];\n const previous = s.data.length > 1 ? s.data[1] : null;\n const value = current.y;\n const unit = current.x || '';\n const hasTrend = previous !== null;\n const change = hasTrend ? value - previous.y : 0;\n const pctChange = hasTrend && previous.y !== 0 ? ((change / Math.abs(previous.y)) * 100) : 0;\n const isPositive = change > 0;\n const isNegative = change < 0;\n const trendColor = isPositive ? '#7BA89D' : isNegative ? '#D17B6B' : 'var(--text-muted, #666)';\n const trendArrow = isPositive ? '↑' : isNegative ? '↓' : '→';\n\n // Format large numbers nicely\n const fmt = (n) => {\n if (Number.isInteger(n) && Math.abs(n) >= 1000) return n.toLocaleString();\n if (typeof n === 'number') return n % 1 === 0 ? n.toString() : n.toFixed(n < 10 ? 2 : 1);\n return String(n);\n };\n\n return (\n <div style={{ display: 'flex', alignItems: 'baseline', gap: 12, padding: '8px 0' }}>\n <div style={{\n fontSize: '36px', fontWeight: 700, lineHeight: 1,\n color: 'var(--text-strong, #1e2125)',\n fontVariantNumeric: 'tabular-nums',\n }}>\n {fmt(value)}\n </div>\n {unit && (\n <div style={{ fontSize: '14px', color: 'var(--text-muted, #666)', fontWeight: 500 }}>\n {unit}\n </div>\n )}\n {hasTrend && (\n <div style={{\n display: 'flex', alignItems: 'center', gap: 4,\n fontSize: '13px', fontWeight: 600, color: trendColor,\n background: isPositive ? 'rgba(123,168,157,0.12)' : isNegative ? 'rgba(209,123,107,0.12)' : 'rgba(128,128,128,0.08)',\n padding: '3px 8px', borderRadius: 'var(--radius-sm, 4px)',\n }}>\n <span>{trendArrow}</span>\n <span>{fmt(Math.abs(change))} ({Math.abs(pctChange).toFixed(1)}%)</span>\n </div>\n )}\n {hasTrend && (\n <div style={{ fontSize: '11px', color: 'var(--text-faint, #999)' }}>\n vs {previous.x || 'previous'}\n </div>\n )}\n </div>\n );\n }\n\n default:\n return <div style={{ color: 'var(--text-muted)', fontSize: 12, padding: 8 }}>Unsupported chart type: {chartType}</div>;\n }\n };\n\n const showLegendInExport = chartType === 'line'\n || chartType === 'area'\n || ((chartType === 'bar' || chartType === 'horizontal_bar') && !isSingleSeries);\n\n const exportLegendItems = showLegendInExport\n ? seriesNames.map((name, i) => ({ label: name, color: COLORS[i % COLORS.length] }))\n : [];\n\n const handleDownloadPng = useCallback(() => {\n if (chartRef.current) downloadPng(chartRef.current, title, exportLegendItems);\n }, [title, exportLegendItems]);\n\n const handleCopy = useCallback(() => {\n copyAsCsv(series, allXValues);\n setCopied(true);\n setTimeout(() => setCopied(false), 2000);\n }, [series, allXValues]);\n\n const showActions = chartType !== 'metric';\n\n return (\n <div style={containerStyle}>\n {title && <div style={titleStyle}>{title}</div>}\n {showActions && <ActionBar onDownloadPng={handleDownloadPng} onCopy={handleCopy} copied={copied} />}\n <div ref={chartRef}>\n {renderChart()}\n </div>\n </div>\n );\n};\n\nexport default ChartRenderer;\n","\"use client\";\n\nimport React, { useState } from \"react\";\nimport { Wrench, Copy, Check, PanelRightOpen } from \"lucide-react\";\n\n/**\n * Lightweight Markdown Renderer\n * Handles: code blocks, inline code, bold, italic, links, lists, headers, horizontal rules, file paths\n */\nconst MarkdownRenderer = ({ content, onCodeBlockClick, onFilePathClick }) => {\n const [copiedBlocks, setCopiedBlocks] = useState(new Set());\n\n const copyToClipboard = async (text, blockId) => {\n try {\n await navigator.clipboard.writeText(text);\n setCopiedBlocks(prev => new Set([...prev, blockId]));\n setTimeout(() => {\n setCopiedBlocks(prev => {\n const newSet = new Set(prev);\n newSet.delete(blockId);\n return newSet;\n });\n }, 2000);\n } catch (err) {\n console.error('Failed to copy text:', err);\n }\n };\n\n const renderCodeBlock = (code, language, blockId) => {\n const isCopied = copiedBlocks.has(blockId);\n \n return (\n <div \n key={blockId}\n style={{\n position: 'relative',\n marginBottom: '16px',\n borderRadius: '8px',\n background: 'var(--ink, #1E2125)',\n border: '1px solid var(--border-subtle, rgba(52,58,64,0.08))',\n overflow: 'hidden',\n }}\n >\n {/* Header with language and copy button */}\n <div style={{\n display: 'flex',\n justifyContent: 'space-between',\n alignItems: 'center',\n padding: '8px 12px',\n background: 'rgba(255,255,255,0.05)',\n borderBottom: '1px solid rgba(255,255,255,0.1)',\n }}>\n <span style={{\n fontSize: '11px',\n color: 'rgba(255,255,255,0.7)',\n fontFamily: 'var(--font-mono, monospace)',\n textTransform: 'uppercase',\n letterSpacing: '0.05em',\n }}>\n {language || 'code'}\n </span>\n <button\n onClick={() => copyToClipboard(code, blockId)}\n style={{\n background: 'none',\n border: 'none',\n color: 'rgba(255,255,255,0.7)',\n cursor: 'pointer',\n padding: '4px',\n borderRadius: '4px',\n display: 'flex',\n alignItems: 'center',\n gap: '4px',\n fontSize: '11px',\n transition: 'all 0.15s ease',\n }}\n onMouseEnter={(e) => {\n e.target.style.background = 'rgba(255,255,255,0.1)';\n e.target.style.color = 'rgba(255,255,255,0.9)';\n }}\n onMouseLeave={(e) => {\n e.target.style.background = 'none';\n e.target.style.color = 'rgba(255,255,255,0.7)';\n }}\n >\n {isCopied ? <Check size={12} /> : <Copy size={12} />}\n {isCopied ? 'Copied!' : 'Copy'}\n </button>\n {onCodeBlockClick && (\n <button\n onClick={() => onCodeBlockClick({ code, language })}\n style={{\n background: 'none',\n border: 'none',\n color: 'rgba(255,255,255,0.7)',\n cursor: 'pointer',\n padding: '4px',\n borderRadius: '4px',\n display: 'flex',\n alignItems: 'center',\n gap: '4px',\n fontSize: '11px',\n transition: 'all 0.15s ease',\n }}\n onMouseEnter={(e) => {\n e.currentTarget.style.background = 'rgba(255,255,255,0.1)';\n e.currentTarget.style.color = 'rgba(255,255,255,0.9)';\n }}\n onMouseLeave={(e) => {\n e.currentTarget.style.background = 'none';\n e.currentTarget.style.color = 'rgba(255,255,255,0.7)';\n }}\n >\n <PanelRightOpen size={12} />\n Canvas\n </button>\n )}\n </div>\n {/* Code content */}\n <pre style={{\n margin: 0,\n padding: '12px',\n fontFamily: 'var(--font-mono, monospace)',\n fontSize: '13px',\n lineHeight: 1.4,\n color: 'rgba(255,255,255,0.95)',\n overflow: 'auto',\n whiteSpace: 'pre-wrap',\n wordBreak: 'break-word',\n }}>\n {code}\n </pre>\n </div>\n );\n };\n\n const parseMarkdown = (text) => {\n const elements = [];\n const lines = text.split('\\n');\n let i = 0;\n let blockId = 0;\n\n while (i < lines.length) {\n const line = lines[i];\n \n // Code blocks (```language)\n if (line.trim().startsWith('```')) {\n const language = line.trim().slice(3);\n let codeLines = [];\n i++;\n \n while (i < lines.length && !lines[i].trim().startsWith('```')) {\n codeLines.push(lines[i]);\n i++;\n }\n \n if (i < lines.length) i++; // Skip closing ```\n \n elements.push(renderCodeBlock(codeLines.join('\\n'), language, `code-${blockId++}`));\n continue;\n }\n \n // Headers\n if (line.startsWith('#')) {\n const level = line.match(/^#+/)[0].length;\n const text = line.slice(level).trim();\n const HeaderTag = level === 1 ? 'h2' : level === 2 ? 'h3' : level === 3 ? 'h4' : 'h5';\n \n elements.push(\n React.createElement(HeaderTag, {\n key: `header-${i}`,\n style: {\n fontSize: level === 1 ? '18px' : level === 2 ? '16px' : '14px',\n fontWeight: 720,\n color: 'var(--text-strong, rgba(30,33,37,0.92))',\n marginTop: elements.length > 0 ? '20px' : '0',\n marginBottom: '8px',\n lineHeight: 1.3,\n }\n }, text)\n );\n i++;\n continue;\n }\n \n // Horizontal rule\n if (line.trim() === '---' || line.trim() === '***') {\n elements.push(\n <hr key={`hr-${i}`} style={{\n border: 'none',\n borderTop: '1px solid var(--border-subtle, rgba(52,58,64,0.08))',\n margin: '16px 0',\n }} />\n );\n i++;\n continue;\n }\n \n // Lists\n if (line.match(/^(\\s*)([-*+]|\\d+\\.)\\s/)) {\n const listItems = [];\n const isOrdered = /^\\s*\\d+\\./.test(line);\n \n while (i < lines.length && (lines[i].match(/^(\\s*)([-*+]|\\d+\\.)\\s/) || lines[i].trim() === '')) {\n if (lines[i].trim() !== '') {\n const match = lines[i].match(/^(\\s*)([-*+]|\\d+\\.)\\s(.*)$/);\n if (match) {\n listItems.push(match[3]);\n }\n }\n i++;\n }\n \n const ListTag = isOrdered ? 'ol' : 'ul';\n elements.push(\n React.createElement(ListTag, {\n key: `list-${i}`,\n style: {\n margin: '8px 0',\n paddingLeft: '20px',\n color: 'var(--text-strong, rgba(30,33,37,0.92))',\n }\n }, listItems.map((item, idx) => \n React.createElement('li', {\n key: `item-${idx}`,\n style: { marginBottom: '4px' }\n }, parseInlineMarkdownWithContext(item))\n ))\n );\n continue;\n }\n \n // Tables (lines starting with |)\n if (line.trim().startsWith('|') && line.trim().endsWith('|')) {\n const tableRows = [];\n while (i < lines.length && lines[i].trim().startsWith('|') && lines[i].trim().endsWith('|')) {\n tableRows.push(lines[i]);\n i++;\n }\n \n if (tableRows.length >= 2) {\n // Parse cells from each row\n const parseCells = (row) => row.trim().slice(1, -1).split('|').map(c => c.trim());\n const headerCells = parseCells(tableRows[0]);\n \n // Check if row 1 is a separator (---|---|---)\n const isSeparator = (row) => parseCells(row).every(c => /^[-:]+$/.test(c));\n const hasSeparator = tableRows.length >= 2 && isSeparator(tableRows[1]);\n const bodyStart = hasSeparator ? 2 : 1;\n \n // Parse alignment from separator\n const alignments = hasSeparator ? parseCells(tableRows[1]).map(c => {\n if (c.startsWith(':') && c.endsWith(':')) return 'center';\n if (c.endsWith(':')) return 'right';\n return 'left';\n }) : headerCells.map(() => 'left');\n \n const cellStyle = {\n padding: '6px 12px',\n borderBottom: '1px solid var(--border-subtle, rgba(52,58,64,0.08))',\n fontSize: '13px',\n lineHeight: 1.5,\n color: 'var(--text-strong, rgba(30,33,37,0.92))',\n // Override the chat bubble's inherited `word-break: break-word`\n // so cells size to natural min-content; the wrapper's\n // overflow-x: auto handles wide tables via horizontal scroll\n // instead of collapsing columns char-by-char on long URLs.\n wordBreak: 'normal',\n overflowWrap: 'normal',\n };\n \n elements.push(\n <div key={`table-${i}`} style={{ overflowX: 'auto', margin: '8px 0' }}>\n <table style={{\n borderCollapse: 'collapse',\n width: '100%',\n border: '1px solid var(--border-subtle, rgba(52,58,64,0.08))',\n borderRadius: '6px',\n overflow: 'hidden',\n }}>\n {hasSeparator && (\n <thead>\n <tr style={{ background: 'var(--hover-warm-subtle, rgba(231,212,162,0.08))' }}>\n {headerCells.map((cell, ci) => (\n <th key={ci} style={{ ...cellStyle, fontWeight: 660, textAlign: alignments[ci] || 'left', whiteSpace: 'nowrap' }}>\n {parseInlineMarkdownWithContext(cell)}\n </th>\n ))}\n </tr>\n </thead>\n )}\n <tbody>\n {(hasSeparator ? tableRows.slice(bodyStart) : tableRows).map((row, ri) => (\n <tr key={ri} style={{ background: ri % 2 === 1 ? 'var(--hover-warm-subtle, rgba(231,212,162,0.04))' : 'transparent' }}>\n {parseCells(row).map((cell, ci) => (\n <td key={ci} style={{ ...cellStyle, textAlign: alignments[ci] || 'left' }}>\n {parseInlineMarkdownWithContext(cell)}\n </td>\n ))}\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n );\n }\n continue;\n }\n \n // Regular paragraphs\n if (line.trim()) {\n const paragraph = [];\n while (i < lines.length && lines[i].trim() && !lines[i].match(/^(#|```|---|\\*\\*\\*|(\\s*)([-*+]|\\d+\\.)\\s)/) && !(lines[i].trim().startsWith('|') && lines[i].trim().endsWith('|'))) {\n paragraph.push(lines[i]);\n i++;\n }\n \n if (paragraph.length > 0) {\n elements.push(\n <p key={`p-${i}`} style={{ \n margin: '8px 0',\n lineHeight: 1.6,\n color: 'var(--text-strong, rgba(30,33,37,0.92))',\n }}>\n {parseInlineMarkdownWithContext(paragraph.join(' '))}\n </p>\n );\n }\n } else {\n i++;\n }\n }\n \n return elements;\n };\n\n const parseInlineMarkdown = (text) => {\n const elements = [];\n let remaining = text;\n let key = 0;\n\n while (remaining.length > 0) {\n // File paths (before other patterns to catch them first)\n if (onFilePathClick) {\n // Match file paths: containing /src/, /components/, /packages/ or ending in common extensions\n const filePathMatch = remaining.match(/^([^\\s`*\\[]+(?:\\/src\\/|\\/components\\/|\\/packages\\/)[^\\s`*\\[]*|[^\\s`*\\[]*\\.(ts|tsx|js|jsx|py|css|scss|sass|json|md|yaml|yml|html|xml|sh|sql|go|rs|php|java|c|cpp|h|hpp)(?:\\b|$))/);\n if (filePathMatch) {\n const filePath = filePathMatch[1];\n elements.push(\n <span\n key={`file-path-${key++}`}\n onClick={() => onFilePathClick(filePath)}\n style={{\n color: 'var(--rail-discovery, #5E88B0)',\n textDecoration: 'underline',\n textDecorationStyle: 'dotted',\n textUnderlineOffset: '2px',\n cursor: 'pointer',\n fontFamily: 'var(--font-mono, monospace)',\n fontSize: '13px',\n transition: 'all 0.15s ease',\n ':hover': {\n background: 'var(--hover-warm-subtle, rgba(231,212,162,0.08))',\n textDecoration: 'underline',\n textDecorationStyle: 'solid'\n }\n }}\n onMouseEnter={(e) => {\n e.target.style.background = 'var(--hover-warm-subtle, rgba(231,212,162,0.08))';\n e.target.style.textDecorationStyle = 'solid';\n }}\n onMouseLeave={(e) => {\n e.target.style.background = 'none';\n e.target.style.textDecorationStyle = 'dotted';\n }}\n >\n {filePath}\n </span>\n );\n remaining = remaining.slice(filePathMatch[0].length);\n continue;\n }\n }\n\n // Inline code\n const inlineCodeMatch = remaining.match(/^`([^`]+)`/);\n if (inlineCodeMatch) {\n elements.push(\n <code key={`inline-code-${key++}`} style={{\n background: 'var(--hover-warm-subtle, rgba(231,212,162,0.08))',\n border: '1px solid var(--border-subtle, rgba(52,58,64,0.08))',\n borderRadius: '3px',\n padding: '2px 4px',\n fontFamily: 'var(--font-mono, monospace)',\n fontSize: '12px',\n color: 'var(--text-strong, rgba(30,33,37,0.92))',\n }}>\n {inlineCodeMatch[1]}\n </code>\n );\n remaining = remaining.slice(inlineCodeMatch[0].length);\n continue;\n }\n\n // Bold\n const boldMatch = remaining.match(/^\\*\\*([^*]+)\\*\\*/);\n if (boldMatch) {\n elements.push(\n <strong key={`bold-${key++}`} style={{\n fontWeight: 720,\n color: 'var(--text-strong, rgba(30,33,37,0.92))',\n }}>\n {boldMatch[1]}\n </strong>\n );\n remaining = remaining.slice(boldMatch[0].length);\n continue;\n }\n\n // Italic\n const italicMatch = remaining.match(/^\\*([^*]+)\\*/);\n if (italicMatch) {\n elements.push(\n <em key={`italic-${key++}`} style={{\n fontStyle: 'italic',\n color: 'var(--text-strong, rgba(30,33,37,0.92))',\n }}>\n {italicMatch[1]}\n </em>\n );\n remaining = remaining.slice(italicMatch[0].length);\n continue;\n }\n\n // Links\n const linkMatch = remaining.match(/^\\[([^\\]]+)\\]\\(([^)]+)\\)/);\n if (linkMatch) {\n const linkText = linkMatch[1];\n const linkHref = linkMatch[2];\n const isViewButton = linkText === 'View';\n const viewButtonStyle = {\n display: 'inline-flex',\n alignItems: 'center',\n padding: '3px 10px',\n background: 'var(--rail-discovery, #5E88B0)',\n color: '#fff',\n textDecoration: 'none',\n borderRadius: '4px',\n fontSize: '12px',\n fontWeight: 600,\n whiteSpace: 'nowrap',\n cursor: 'pointer',\n };\n const defaultLinkStyle = {\n color: 'var(--rail-discovery, #5E88B0)',\n textDecoration: 'underline',\n textUnderlineOffset: '2px',\n };\n elements.push(\n <a key={`link-${key++}`}\n href={linkHref}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n style={isViewButton ? viewButtonStyle : defaultLinkStyle}>\n {linkText}\n </a>\n );\n remaining = remaining.slice(linkMatch[0].length);\n continue;\n }\n\n // Regular text — consume up to the next special char, or consume the special char itself if no pattern matched\n const nextSpecialChar = remaining.search(/[`*\\[]/);\n if (nextSpecialChar === -1) {\n // No more special chars — add rest and break\n elements.push(remaining);\n break;\n } else if (nextSpecialChar === 0) {\n // Special char at position 0 but no pattern matched — consume it as text\n elements.push(remaining[0]);\n remaining = remaining.slice(1);\n } else {\n elements.push(remaining.slice(0, nextSpecialChar));\n remaining = remaining.slice(nextSpecialChar);\n }\n }\n\n return elements.length === 1 && typeof elements[0] === 'string' ? elements[0] : elements;\n };\n\n // Helper to pass context to parseInlineMarkdown calls within parseMarkdown\n const parseInlineMarkdownWithContext = (text) => parseInlineMarkdown(text);\n \n return <div>{parseMarkdown(content)}</div>;\n};\n\n/**\n * ChatMessage Component\n * Individual message in chat interface with markdown support for assistant messages\n */\nexport default function ChatMessage({ \n role, \n content, \n html, \n timestamp, \n toolBadges, \n isStreaming,\n onCodeBlockClick,\n onFilePathClick,\n}) {\n const isUser = role === \"user\";\n\n return (\n <div\n style={{\n display: \"flex\",\n flexDirection: \"column\",\n alignItems: isUser ? \"flex-end\" : \"flex-start\",\n marginBottom: \"16px\",\n maxWidth: \"100%\",\n }}\n >\n {/* Role label */}\n <div\n style={{\n fontSize: \"var(--text-sm, 11px)\",\n color: \"var(--text-faint, rgba(30,33,37,0.36))\",\n marginBottom: \"6px\",\n fontWeight: 650,\n letterSpacing: \"0.02em\",\n }}\n >\n {isUser ? \"You\" : \"Chordia\"}\n {isStreaming && !isUser && (\n <span style={{ marginLeft: \"6px\", color: \"var(--rail-purple, #9B7AA8)\" }}>\n ●\n </span>\n )}\n </div>\n\n {/* Tool badges */}\n {toolBadges && toolBadges.length > 0 && (\n <div style={{ \n marginBottom: \"8px\", \n display: \"flex\", \n flexWrap: \"wrap\", \n gap: \"4px\",\n maxWidth: \"75%\" \n }}>\n {toolBadges.map((badge, index) => (\n <span \n key={badge.id || index}\n style={{\n display: \"inline-block\",\n fontSize: \"11px\",\n padding: \"2px 8px\",\n borderRadius: \"6px\",\n background: \"var(--paper-elevated, rgba(255,255,255,0.82))\",\n border: `1px solid ${\n badge.pending \n ? \"var(--rail-discovery, #5A8CC0)\" \n : badge.success !== false \n ? \"var(--state-present, #5CB85C)\" \n : \"var(--rail-signal-churn, #C98A5A)\"\n }`,\n color: badge.pending \n ? \"var(--rail-discovery, #5A8CC0)\" \n : badge.success !== false \n ? \"var(--state-present, #5CB85C)\" \n : \"var(--rail-signal-churn, #C98A5A)\",\n }}\n >\n <Wrench size={10} style={{ marginRight: 3, verticalAlign: \"middle\" }} />\n {badge.name}\n {badge.pending ? \"...\" : badge.success !== false ? \" ✓\" : \" ✗\"}\n </span>\n ))}\n </div>\n )}\n\n {/* Message bubble */}\n <div\n style={{\n maxWidth: \"75%\",\n padding: \"12px 16px\",\n borderRadius: \"var(--radius-lg, 12px)\",\n background: isUser\n ? \"var(--card-customer, rgba(94,136,176,0.08))\"\n : \"var(--paper-elevated, rgba(255,255,255,0.82))\",\n border: isUser\n ? \"1px solid var(--border-subtle, rgba(52,58,64,0.08))\"\n : \"1px solid var(--border, rgba(52,58,64,0.12))\",\n fontSize: \"var(--text-base, 14px)\",\n lineHeight: 1.6,\n color: \"var(--text-strong, rgba(30,33,37,0.92))\",\n wordBreak: \"break-word\",\n }}\n >\n {html ? (\n <div dangerouslySetInnerHTML={{ __html: html }} />\n ) : isUser ? (\n // User messages stay plain text\n <div style={{ whiteSpace: \"pre-wrap\" }}>{content}</div>\n ) : (\n // Assistant messages get markdown rendering\n <MarkdownRenderer content={content || \"\"} onCodeBlockClick={onCodeBlockClick} onFilePathClick={onFilePathClick} />\n )}\n </div>\n\n {/* Timestamp */}\n {timestamp && (\n <div\n style={{\n fontSize: \"var(--text-xs-plus, 10.5px)\",\n color: \"var(--text-faint, rgba(30,33,37,0.36))\",\n marginTop: \"4px\",\n fontFamily: \"var(--font-mono, monospace)\",\n }}\n >\n {timestamp}\n </div>\n )}\n </div>\n );\n}"],"names":["COLORS","AXIS_TICK","AXIS_LINE","GRID_STROKE","TOOLTIP_STYLE","LEGEND_STYLE","ChartTooltip","active","payload","label","jsxs","jsx","entry","i","seriesColor","_a","shouldShowAxisLabel","tickValues","lower","v","getChartSvg","containerEl","wrappers","largestWrapper","largest","current","largestRect","currentRect","surface","rect","candidates","largestSvg","escapeXml","value","buildExportSvg","chartSvg","width","height","legendItems","baseSvg","legendLineHeight","legendStartX","maxLegendX","legendRows","currentRow","currentRowWidth","color","itemWidth","exportLegendHeight","exportHeight","legendMarkup","row","rowIndex","cursorX","legendLineY","line","dot","text","downloadPng","title","svg","svgRect","w","h","xml","blob","url","img","canvas","scale","ctx","link","copyAsCsv","series","allXValues","header","s","rows","x","vals","match","d","csv","ActionBar","onDownloadPng","onCopy","copied","ChartRenderer","chartType","xLabel","yLabel","compact","chartRef","useRef","setCopied","React","chartData","point","seriesNames","isSingleSeries","showXLabel","rotateXTicks","bottomMargin","legendHeight","chartHeight","legendWrapperStyle","containerStyle","titleStyle","xAxisProps","yAxisProps","renderChart","ResponsiveContainer","BarChart","CartesianGrid","XAxis","YAxis","Legend","name","Bar","_","idx","Cell","Tooltip","LineChart","Line","AreaChart","Area","pieData","RADIAN","renderLabel","cx","cy","midAngle","innerRadius","outerRadius","percent","radius","y","PieChart","Pie","previous","unit","hasTrend","change","pctChange","isPositive","isNegative","trendColor","trendArrow","fmt","n","exportLegendItems","handleDownloadPng","useCallback","handleCopy","showActions","MarkdownRenderer","content","onCodeBlockClick","onFilePathClick","copiedBlocks","setCopiedBlocks","useState","copyToClipboard","blockId","prev","newSet","err","renderCodeBlock","code","language","isCopied","e","Check","Copy","PanelRightOpen","parseMarkdown","elements","lines","codeLines","level","HeaderTag","listItems","isOrdered","ListTag","item","parseInlineMarkdownWithContext","tableRows","parseCells","c","headerCells","isSeparator","hasSeparator","bodyStart","alignments","cellStyle","cell","ci","ri","paragraph","parseInlineMarkdown","remaining","key","filePathMatch","filePath","inlineCodeMatch","boldMatch","italicMatch","linkMatch","linkText","linkHref","isViewButton","viewButtonStyle","defaultLinkStyle","nextSpecialChar","ChatMessage","role","html","timestamp","toolBadges","isStreaming","isUser","badge","index","Wrench"],"mappings":"qHASMA,EAAS,CACb,UACA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,SACF,EAGMC,EAAY,CAAE,KAAM,0BAA2B,SAAU,EAAG,EAC5DC,EAAY,CAAE,OAAQ,0BACtBC,EAAc,yBACdC,EAAgB,CAKpB,aAAc,CACZ,OAAQ,KACR,cAAe,OACf,QAAS,OACT,WAAY,MACd,CACF,EACMC,GAAe,CAAE,MAAO,2BAA4B,SAAU,MAAO,EAIrEC,EAAe,CAAC,CAAE,OAAAC,EAAQ,QAAAC,EAAS,MAAAC,KACnC,CAACF,GAAU,CAACC,GAAW,CAACA,EAAQ,OAAe,KAEjDE,EAAA,KAAC,MAAA,CACC,UAAU,wBACV,MAAO,CACL,WAAY,UACZ,OAAQ,mCACR,aAAc,EACd,UAAW,sEACX,QAAS,YACT,SAAU,IACV,SAAU,IACV,UAAW,IAC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