chordia-ui 3.9.3 → 3.9.4
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.
- package/dist/ChatMessage.cjs.js +5 -5
- package/dist/ChatMessage.cjs.js.map +1 -1
- package/dist/ChatMessage.es.js +583 -353
- package/dist/ChatMessage.es.js.map +1 -1
- package/dist/MessageThread.cjs.js +15 -0
- package/dist/MessageThread.cjs.js.map +1 -0
- package/dist/MessageThread.es.js +1868 -0
- package/dist/MessageThread.es.js.map +1 -0
- package/dist/components/chat.cjs.js +1 -27
- package/dist/components/chat.cjs.js.map +1 -1
- package/dist/components/chat.es.js +276 -1617
- package/dist/components/chat.es.js.map +1 -1
- package/dist/components/layout.cjs.js +2 -2
- package/dist/components/layout.cjs.js.map +1 -1
- package/dist/components/layout.es.js +289 -272
- package/dist/components/layout.es.js.map +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.es.js +8 -8
- package/package.json +1 -1
- package/src/components/chat/ChatHistoryPanel.jsx +740 -388
- package/src/components/chat/ChatMessage.jsx +338 -48
- package/src/components/chat/ChatWelcome.jsx +386 -0
- package/src/components/chat/ThinkingIndicator.jsx +121 -275
- package/src/components/chat/index.js +1 -0
- package/src/components/layout/SplitPane.jsx +21 -13
package/dist/ChatMessage.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const e=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),L=require("react"),l=require("recharts"),F=require("lucide-react"),k=["#5E88B0","#9B7AA8","#C98A5A","#7BA89D","#D17B6B","#6B7C93","#9B8E6F","#8A9BAF","#B8976A","#A8C76B"],ee={fill:"var(--text-muted, #666)",fontSize:12},I={stroke:"var(--border, #e0e0e0)"},V="var(--border, #e0e0e0)",U={wrapperStyle:{zIndex:9999,pointerEvents:"none",outline:"none",transition:"none"}},ie={color:"var(--text-ink, #1e2125)",fontSize:"12px"},G=({active:c,payload:p,label:d})=>!c||!p||!p.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
2
|
.chordia-chart-tooltip::-webkit-scrollbar { width: 8px; }
|
|
3
3
|
.chordia-chart-tooltip::-webkit-scrollbar-track { background: transparent; }
|
|
4
4
|
.chordia-chart-tooltip::-webkit-scrollbar-thumb {
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
.chordia-chart-tooltip::-webkit-scrollbar-thumb:hover {
|
|
9
9
|
background: rgba(52, 58, 64, 0.4);
|
|
10
10
|
}
|
|
11
|
-
`}),
|
|
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,
|
|
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",width:"100%",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":"Compass",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:{width:"100%",maxWidth:"100%",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;
|
|
11
|
+
`}),d!==void 0&&d!==""&&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:d}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:p.map((o,i)=>{var h;const f=o.color||((h=o.payload)==null?void 0:h.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:f,flexShrink:0}}),e.jsx("span",{style:{color:"#374151",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:o.name})]}),e.jsx("span",{style:{color:"#111827",fontWeight:600,marginLeft:8},children:o.value})]},i)})})]}),ae=(c,p)=>{if(!c)return!1;const d=c.toLowerCase();return p.filter(i=>String(i).toLowerCase().includes(d)).length<p.length*.5},le=c=>{const p=Array.from(c.querySelectorAll(".recharts-wrapper")),d=p.length?p.reduce((h,S)=>{const v=h.getBoundingClientRect(),x=S.getBoundingClientRect();return x.width*x.height>v.width*v.height?S:h}):null;if(d){const h=d.querySelector("svg.recharts-surface");if(h){const S=h.getBoundingClientRect();if(S.width>=100&&S.height>=100)return h}}const o=Array.from(c.querySelectorAll("svg"));if(!o.length)return null;const i=o.reduce((h,S)=>{const v=h.getBoundingClientRect(),x=S.getBoundingClientRect();return x.width*x.height>v.width*v.height?S:h}),f=i.getBoundingClientRect();return f.width<100||f.height<100?null:i},ce=c=>String(c).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"),de=({chartSvg:c,width:p,height:d,legendItems:o=[]})=>{const i=c.cloneNode(!0),f=20,h=16,v=p-16,x=[];let a=[],n=0;o.forEach(({label:b,color:g})=>{const u=Math.max(40,String(b).length*7+34);a.length&&h+n+u>v&&(x.push(a),a=[],n=0),a.push({label:b,color:g,itemWidth:u}),n+=u}),a.length&&x.push(a);const t=x.length?x.length*f+20:0,r=d+t;i.setAttribute("width",p),i.setAttribute("height",d),i.setAttribute("x",0),i.setAttribute("y",0);const y=x.map((b,g)=>{let u=h;const w=d+20+g*f;return b.map(({label:s,color:z,itemWidth:C})=>{const H=`<line x1="${u}" y1="${w}" x2="${u+10}" y2="${w}" stroke="${z}" stroke-width="2" />`,A=`<circle cx="${u+5}" cy="${w}" r="2.5" fill="#fff" stroke="${z}" stroke-width="1.5" />`,T=`<text x="${u+14}" y="${w+4}" fill="#666" font-size="12">${ce(s)}</text>`;return u+=C,`${H}${A}${T}`}).join("")}).join("");return[`<svg xmlns="http://www.w3.org/2000/svg" width="${p}" height="${r}" viewBox="0 0 ${p} ${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(i),y,"</svg>"].join("")},pe=async(c,p,d=[])=>{const o=le(c);if(!o)return;const i=o.getBoundingClientRect(),f=i.width||o.clientWidth||Number(o.getAttribute("width"))||600,h=i.height||o.clientHeight||Number(o.getAttribute("height"))||300,S=de({chartSvg:o,width:f,height:h,legendItems:d}),v=new Blob([S],{type:"image/svg+xml;charset=utf-8"}),x=URL.createObjectURL(v),a=new Image;a.onload=()=>{const n=document.createElement("canvas"),t=2;n.width=f*t,n.height=h*t;const r=n.getContext("2d");r.fillStyle="#ffffff",r.fillRect(0,0,n.width,n.height),r.scale(t,t),r.drawImage(a,0,0,f,h),URL.revokeObjectURL(x);const y=document.createElement("a");y.download=`${(p||"chart").replace(/[^a-z0-9]+/gi,"_")}.png`,y.href=n.toDataURL("image/png"),y.click()},a.src=x},he=(c,p)=>{const d=["",...c.map(f=>f.name)].join(","),o=p.map(f=>{const h=c.map(S=>{const v=S.data.find(x=>x.x===f);return v?v.y:""});return[f,...h].join(",")}),i=[d,...o].join(`
|
|
12
|
+
`);navigator.clipboard.writeText(i)},ge=({onDownloadPng:c,onCopy:p,copied:d})=>e.jsxs("div",{style:{display:"flex",gap:6,justifyContent:"flex-end",marginBottom:8,opacity:.7,transition:"opacity 0.15s"},children:[e.jsx("button",{onClick:p,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:d?"✓ Copied":"📋 CSV"}),e.jsx("button",{onClick:c,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"})]}),xe=({chartType:c,title:p,xLabel:d,yLabel:o,series:i,compact:f=!1})=>{const h=L.useRef(null),[S,v]=L.useState(!1);if(!i||i.length===0)return null;const x=[...new Set(i.flatMap(m=>m.data.map(j=>j.x)))],a=x.map(m=>{const j={x:m};return i.forEach(M=>{const B=M.data.find($=>$.x===m);j[M.name]=B?B.y:null}),j}),n=i.map(m=>m.name),t=n.length===1,r=ae(d,x),b=Math.max(...x.map(m=>String(m).length))>12||x.length>8,w=(b?40:5)+(r?25:0),R=t?0:Math.max(1,Math.ceil(n.length/4)),s=R>0?R*24+(r?24:12):0,C=(f?240:300)+Math.max(0,(R-1)*28),A={...ie,paddingTop:r?24:12,zIndex:0},T={background:"var(--paper-elevated, #fff)",border:"1px solid var(--border, #e0e0e0)",borderRadius:"var(--radius-md, 8px)",padding:"16px",marginBottom:"16px"},Z={color:"var(--text-strong, #1e2125)",fontSize:"14px",fontWeight:"600",marginBottom:"12px"},P={dataKey:"x",tick:b?{fill:"var(--text-muted, #666)",fontSize:11,angle:-35,textAnchor:"end"}:ee,axisLine:I,tickLine:I,...r?{label:{value:d,position:"insideBottom",offset:b?-45:-10,style:{textAnchor:"middle",fill:"var(--text-muted, #666)"}}}:{}},J={tick:ee,axisLine:I,tickLine:I,...o?{width:72,label:{value:o,angle:-90,position:"insideLeft",offset:10,style:{textAnchor:"middle",fill:"var(--text-muted, #666)"}}}:{}},re=()=>{switch(c){case"bar":return e.jsx(l.ResponsiveContainer,{width:"100%",height:C,children:e.jsxs(l.BarChart,{data:a,margin:{top:5,right:30,left:o?10:20,bottom:w},children:[e.jsx(l.CartesianGrid,{strokeDasharray:"3 3",stroke:V}),e.jsx(l.XAxis,{...P}),e.jsx(l.YAxis,{...J}),!t&&e.jsx(l.Legend,{wrapperStyle:A,height:s}),n.map((m,j)=>e.jsx(l.Bar,{dataKey:m,fill:k[j%k.length],radius:[2,2,0,0],isAnimationActive:!1,children:t&&a.map((M,B)=>e.jsx(l.Cell,{fill:k[B%k.length]},B))},m)),e.jsx(l.Tooltip,{wrapperStyle:U.wrapperStyle,content:e.jsx(G,{}),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(l.ResponsiveContainer,{width:"100%",height:Math.max(f?240:300,a.length*(f?32:40)),children:e.jsxs(l.BarChart,{data:a,layout:"vertical",margin:{top:5,right:30,left:100,bottom:5},children:[e.jsx(l.CartesianGrid,{strokeDasharray:"3 3",stroke:V}),e.jsx(l.XAxis,{type:"number",tick:ee,axisLine:I,tickLine:I,...o?{label:{value:o,position:"insideBottom",offset:-5,style:{textAnchor:"middle",fill:"var(--text-muted, #666)"}}}:{}}),e.jsx(l.YAxis,{type:"category",dataKey:"x",tick:{fill:"var(--text-muted, #666)",fontSize:11},width:90,axisLine:I,tickLine:I}),!t&&e.jsx(l.Legend,{wrapperStyle:A,height:s}),n.map((m,j)=>e.jsx(l.Bar,{dataKey:m,fill:k[j%k.length],radius:[0,2,2,0],isAnimationActive:!1,children:t&&a.map((M,B)=>e.jsx(l.Cell,{fill:k[B%k.length]},B))},m)),e.jsx(l.Tooltip,{wrapperStyle:U.wrapperStyle,content:e.jsx(G,{}),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(l.ResponsiveContainer,{width:"100%",height:C,children:e.jsxs(l.LineChart,{data:a,margin:{top:5,right:30,left:o?10:20,bottom:w},children:[e.jsx(l.CartesianGrid,{strokeDasharray:"3 3",stroke:V}),e.jsx(l.XAxis,{...P}),e.jsx(l.YAxis,{...J}),e.jsx(l.Legend,{wrapperStyle:A,height:s}),n.map((m,j)=>e.jsx(l.Line,{type:"monotone",dataKey:m,stroke:k[j%k.length],strokeWidth:2,dot:{r:4,fill:k[j%k.length]},activeDot:{r:6,fill:k[j%k.length]},isAnimationActive:!1},m)),e.jsx(l.Tooltip,{wrapperStyle:U.wrapperStyle,content:e.jsx(G,{}),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(l.ResponsiveContainer,{width:"100%",height:C,children:e.jsxs(l.AreaChart,{data:a,margin:{top:5,right:30,left:o?10:20,bottom:w},children:[e.jsx(l.CartesianGrid,{strokeDasharray:"3 3",stroke:V}),e.jsx(l.XAxis,{...P}),e.jsx(l.YAxis,{...J}),e.jsx(l.Legend,{wrapperStyle:A,height:s}),n.map((m,j)=>e.jsx(l.Area,{type:"monotone",dataKey:m,stroke:k[j%k.length],strokeWidth:2,fill:k[j%k.length],fillOpacity:.15,isAnimationActive:!1},m)),e.jsx(l.Tooltip,{wrapperStyle:U.wrapperStyle,content:e.jsx(G,{}),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 m=i[0].data.map((B,$)=>({name:B.x,value:B.y,fill:k[$%k.length]})),j=Math.PI/180,M=({cx:B,cy:$,midAngle:_,innerRadius:N,outerRadius:Q,percent:O,name:X})=>{const K=Q+20,q=B+K*Math.cos(-_*j),Y=$+K*Math.sin(-_*j);return O<.04?null:e.jsxs("text",{x:q,y:Y,fill:"var(--text-ink, #1e2125)",fontSize:11,textAnchor:q>B?"start":"end",dominantBaseline:"central",children:[X," (",(O*100).toFixed(0),"%)"]})};return e.jsx(l.ResponsiveContainer,{width:"100%",height:f?260:320,children:e.jsxs(l.PieChart,{margin:{top:16,right:16,bottom:16,left:16},children:[e.jsx(l.Pie,{data:m,cx:f?"42%":"38%",cy:"50%",outerRadius:f?88:110,dataKey:"value",label:M,labelLine:{stroke:"var(--text-muted, #666)"},isAnimationActive:!1,children:m.map((B,$)=>e.jsx(l.Cell,{fill:B.fill},$))}),e.jsx(l.Tooltip,{wrapperStyle:U.wrapperStyle,content:e.jsx(G,{}),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 m=i[0],j=m.data[0],M=m.data.length>1?m.data[1]:null,B=j.y,$=j.x||"",_=M!==null,N=_?B-M.y:0,Q=_&&M.y!==0?N/Math.abs(M.y)*100:0,O=N>0,X=N<0,K=O?"#7BA89D":X?"#D17B6B":"var(--text-muted, #666)",q=O?"↑":X?"↓":"→",Y=E=>Number.isInteger(E)&&Math.abs(E)>=1e3?E.toLocaleString():typeof E=="number"?E%1===0?E.toString():E.toFixed(E<10?2:1):String(E);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:Y(B)}),$&&e.jsx("div",{style:{fontSize:"14px",color:"var(--text-muted, #666)",fontWeight:500},children:$}),_&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4,fontSize:"13px",fontWeight:600,color:K,background:O?"rgba(123,168,157,0.12)":X?"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:q}),e.jsxs("span",{children:[Y(Math.abs(N))," (",Math.abs(Q).toFixed(1),"%)"]})]}),_&&e.jsxs("div",{style:{fontSize:"11px",color:"var(--text-faint, #999)"},children:["vs ",M.x||"previous"]})]})}default:return e.jsxs("div",{style:{color:"var(--text-muted)",fontSize:12,padding:8},children:["Unsupported chart type: ",c]})}},te=c==="line"||c==="area"||(c==="bar"||c==="horizontal_bar")&&!t?n.map((m,j)=>({label:m,color:k[j%k.length]})):[],ne=L.useCallback(()=>{h.current&&pe(h.current,p,te)},[p,te]),oe=L.useCallback(()=>{he(i,x),v(!0),setTimeout(()=>v(!1),2e3)},[i,x]),se=c!=="metric";return e.jsxs("div",{style:T,children:[p&&e.jsx("div",{style:Z,children:p}),se&&e.jsx(ge,{onDownloadPng:ne,onCopy:oe,copied:S}),e.jsx("div",{ref:h,children:re()})]})},ue=({content:c,onCodeBlockClick:p,onFilePathClick:d})=>{const[o,i]=L.useState(new Set),f=async(a,n)=>{try{await navigator.clipboard.writeText(a),i(t=>new Set([...t,n])),setTimeout(()=>{i(t=>{const r=new Set(t);return r.delete(n),r})},2e3)}catch(t){console.error("Failed to copy text:",t)}},h=(a,n,t)=>{const r=o.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:()=>f(a,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:y=>{y.target.style.background="rgba(255,255,255,0.1)",y.target.style.color="rgba(255,255,255,0.9)"},onMouseLeave:y=>{y.target.style.background="none",y.target.style.color="rgba(255,255,255,0.7)"},children:[r?e.jsx(F.Check,{size:12}):e.jsx(F.Copy,{size:12}),r?"Copied!":"Copy"]}),p&&e.jsxs("button",{onClick:()=>p({code:a,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:y=>{y.currentTarget.style.background="rgba(255,255,255,0.1)",y.currentTarget.style.color="rgba(255,255,255,0.9)"},onMouseLeave:y=>{y.currentTarget.style.background="none",y.currentTarget.style.color="rgba(255,255,255,0.7)"},children:[e.jsx(F.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:a})]},t)},S=a=>{const n=[],t=a.split(`
|
|
13
|
+
`);let r=0,y=0;for(;r<t.length;){const b=t[r];if(b.trim().startsWith("```")){const g=b.trim().slice(3);let u=[];for(r++;r<t.length&&!t[r].trim().startsWith("```");)u.push(t[r]),r++;r<t.length&&r++,n.push(h(u.join(`
|
|
14
|
+
`),g,`code-${y++}`));continue}if(b.startsWith("#")){const g=b.match(/^#+/)[0].length,u=b.slice(g).trim(),w=g===1?"h2":g===2?"h3":g===3?"h4":"h5";n.push(L.createElement(w,{key:`header-${r}`,style:{fontSize:g===1?"18px":g===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}},u)),r++;continue}if(b.trim()==="---"||b.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(b.match(/^(\s*)([-*+]|\d+\.)\s/)){const g=[],u=/^\s*\d+\./.test(b);for(;r<t.length&&(t[r].match(/^(\s*)([-*+]|\d+\.)\s/)||t[r].trim()==="");){if(t[r].trim()!==""){const R=t[r].match(/^(\s*)([-*+]|\d+\.)\s(.*)$/);R&&g.push(R[3])}r++}const w=u?"ol":"ul";n.push(L.createElement(w,{key:`list-${r}`,style:{margin:"8px 0",paddingLeft:"20px",color:"var(--text-strong, rgba(30,33,37,0.92))"}},g.map((R,s)=>L.createElement("li",{key:`item-${s}`,style:{marginBottom:"4px"}},x(R)))));continue}if(b.trim().startsWith("|")&&b.trim().endsWith("|")){const g=[];for(;r<t.length&&t[r].trim().startsWith("|")&&t[r].trim().endsWith("|");)g.push(t[r]),r++;if(g.length>=2){const u=A=>A.trim().slice(1,-1).split("|").map(T=>T.trim()),w=u(g[0]),R=A=>u(A).every(T=>/^[-:]+$/.test(T)),s=g.length>=2&&R(g[1]),z=s?2:1,C=s?u(g[1]).map(A=>A.startsWith(":")&&A.endsWith(":")?"center":A.endsWith(":")?"right":"left"):w.map(()=>"left"),H={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:[s&&e.jsx("thead",{children:e.jsx("tr",{style:{background:"var(--hover-warm-subtle, rgba(231,212,162,0.08))"},children:w.map((A,T)=>e.jsx("th",{style:{...H,fontWeight:660,textAlign:C[T]||"left",whiteSpace:"nowrap"},children:x(A)},T))})}),e.jsx("tbody",{children:(s?g.slice(z):g).map((A,T)=>e.jsx("tr",{style:{background:T%2===1?"var(--hover-warm-subtle, rgba(231,212,162,0.04))":"transparent"},children:u(A).map((Z,P)=>e.jsx("td",{style:{...H,textAlign:C[P]||"left"},children:x(Z)},P))},T))})]})},`table-${r}`))}continue}if(b.trim()){const g=[];for(;r<t.length&&t[r].trim()&&!t[r].match(/^(#|```|---|\*\*\*|(\s*)([-*+]|\d+\.)\s)/)&&!(t[r].trim().startsWith("|")&&t[r].trim().endsWith("|"));)g.push(t[r]),r++;g.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:x(g.join(" "))},`p-${r}`))}else r++}return n},v=a=>{const n=[];let t=a,r=0;for(;t.length>0;){if(d){const s=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(s){const z=s[1];n.push(e.jsx("span",{onClick:()=>d(z),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:C=>{C.target.style.background="var(--hover-warm-subtle, rgba(231,212,162,0.08))",C.target.style.textDecorationStyle="solid"},onMouseLeave:C=>{C.target.style.background="none",C.target.style.textDecorationStyle="dotted"},children:z},`file-path-${r++}`)),t=t.slice(s[0].length);continue}}const y=t.match(/^`([^`]+)`/);if(y){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:y[1]},`inline-code-${r++}`)),t=t.slice(y[0].length);continue}const b=t.match(/^\*\*([^*]+)\*\*/);if(b){n.push(e.jsx("strong",{style:{fontWeight:720,color:"var(--text-strong, rgba(30,33,37,0.92))"},children:b[1]},`bold-${r++}`)),t=t.slice(b[0].length);continue}const g=t.match(/^\*([^*]+)\*/);if(g){n.push(e.jsx("em",{style:{fontStyle:"italic",color:"var(--text-strong, rgba(30,33,37,0.92))"},children:g[1]},`italic-${r++}`)),t=t.slice(g[0].length);continue}const u=t.match(/^!\[([^\]]*)\]\(([^)]+)\)/);if(u){const s=u[1]||u[2],z=u[2];n.push(e.jsx("a",{href:z,target:"_blank",rel:"noopener noreferrer",style:{color:"var(--rail-discovery, #5E88B0)",textDecoration:"underline",textUnderlineOffset:"2px"},children:s},`img-link-${r++}`)),t=t.slice(u[0].length);continue}const w=t.match(/^\[([^\]]+)\]\(([^)]+)\)/);if(w){const s=w[1],z=w[2],C=s==="View",H={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"},A={color:"var(--rail-discovery, #5E88B0)",textDecoration:"underline",textUnderlineOffset:"2px"};n.push(e.jsx("a",{href:z,target:"_blank",rel:"noopener noreferrer",style:C?H:A,children:s},`link-${r++}`)),t=t.slice(w[0].length);continue}const R=t.search(/[`*\[!]/);if(R===-1){n.push(t);break}else R===0?(n.push(t[0]),t=t.slice(1)):(n.push(t.slice(0,R)),t=t.slice(R))}return n.length===1&&typeof n[0]=="string"?n[0]:n},x=a=>v(a);return e.jsx("div",{children:S(c)})},D="#808183",W="#2e3236";function fe(c){return c?c.replace(/```[a-zA-Z0-9]*\n?([\s\S]*?)```/g,"$1").replace(/`([^`]+)`/g,"$1").replace(/!\[([^\]]*)\]\(([^)]*)\)/g,(p,d,o)=>d.trim()&&d.trim()!==o.trim()?`${d} (${o})`:o).replace(/\[([^\]]+)\]\(([^)]*)\)/g,(p,d,o)=>d.trim()&&d.trim()!==o.trim()?`${d} (${o})`:o).replace(/(\*\*|__)(.*?)\1/g,"$2").replace(/(\*|_)(.*?)\1/g,"$2").replace(/~~(.*?)~~/g,"$1").replace(/^\s{0,3}#{1,6}\s+/gm,"").replace(/^\s{0,3}>\s?/gm,"").replace(/^\s*[-*+]\s+/gm,"• ").replace(/^\s*([-*_])\1{2,}\s*$/gm,"").trim():""}function me({timestamp:c,content:p,showFeedback:d,align:o="start",onFeedback:i,initialRating:f=null}){const[h,S]=L.useState(!1),[v,x]=L.useState(f),[a,n]=L.useState(!1),[t,r]=L.useState(""),y=L.useRef(null);L.useEffect(()=>{if(!a)return;const s=C=>{y.current&&!y.current.contains(C.target)&&n(!1)},z=C=>{C.key==="Escape"&&n(!1)};return document.addEventListener("mousedown",s),document.addEventListener("keydown",z),()=>{document.removeEventListener("mousedown",s),document.removeEventListener("keydown",z)}},[a]);const b=async()=>{try{await navigator.clipboard.writeText(fe(p||"")),S(!0),setTimeout(()=>S(!1),1500)}catch(s){console.error("Failed to copy message:",s)}},g=()=>{n(!1),x("up"),i==null||i({rating:"up"})},u=()=>{x("down"),n(!1),i==null||i({rating:"down",...t.trim()?{reason:t.trim()}:{}})},w={display:"inline-flex",alignItems:"center",justifyContent:"center",padding:0,background:"transparent",border:"none",cursor:"pointer",color:D,transition:"color 0.12s ease"},R=e.jsx("span",{style:{fontSize:"13px",color:D,lineHeight:"normal"},children:"•"});return e.jsxs("div",{style:{position:"relative",display:"flex",alignItems:"center",gap:"8px",marginTop:"8px",justifyContent:o==="end"?"flex-end":"flex-start"},children:[c&&e.jsx("span",{style:{fontSize:"13px",color:D,whiteSpace:"nowrap"},children:c}),c&&R,e.jsx("button",{type:"button",title:h?"Copied":"Copy",onClick:b,style:{...w,color:h?"#1f9d57":D},onMouseEnter:s=>{h||(s.currentTarget.style.color=W)},onMouseLeave:s=>{h||(s.currentTarget.style.color=D)},children:h?e.jsx(F.Check,{size:16}):e.jsx(F.Copy,{size:16})}),d&&e.jsxs(e.Fragment,{children:[R,e.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:"16px"},children:[e.jsx("button",{type:"button",title:"Good response",onClick:g,style:{...w,color:v==="up"?W:D},onMouseEnter:s=>s.currentTarget.style.color=W,onMouseLeave:s=>s.currentTarget.style.color=v==="up"?W:D,children:e.jsx(F.ThumbsUp,{size:16,fill:v==="up"?"currentColor":"none"})}),e.jsx("button",{type:"button",title:"Bad response",onClick:()=>n(s=>!s),style:{...w,color:v==="down"||a?W:D},onMouseEnter:s=>s.currentTarget.style.color=W,onMouseLeave:s=>s.currentTarget.style.color=v==="down"||a?W:D,children:e.jsx(F.ThumbsDown,{size:16,fill:v==="down"?"currentColor":"none"})})]})]}),a&&e.jsxs("div",{ref:y,style:{position:"absolute",top:"calc(100% + 6px)",[o==="end"?"right":"left"]:0,zIndex:30,width:"300px",background:"#FFFFFF",border:"1px solid #d9d9d9",borderRadius:"10px",boxShadow:"0 4px 16px rgba(0,0,0,0.12)",padding:"12px",display:"flex",flexDirection:"column",gap:"10px",textAlign:"left"},children:[e.jsx("div",{style:{fontSize:"13px",fontWeight:600,color:W},children:"What was wrong with this response?"}),e.jsx("textarea",{value:t,onChange:s=>r(s.target.value),placeholder:"Add details (optional)",rows:3,style:{width:"100%",boxSizing:"border-box",resize:"none",border:"1px solid #d9d9d9",borderRadius:"8px",padding:"8px",fontSize:"13px",color:W,fontFamily:"inherit",outline:"none"}}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"8px"},children:[e.jsx("button",{type:"button",onClick:()=>n(!1),style:{padding:"6px 12px",fontSize:"12px",fontWeight:600,color:W,background:"#FFFFFF",border:"1px solid #d9d9d9",borderRadius:"6px",cursor:"pointer"},children:"Cancel"}),e.jsx("button",{type:"button",onClick:u,style:{padding:"6px 12px",fontSize:"12px",fontWeight:600,color:"#f2f2f0",background:"#0B0B0B",border:"1px solid #0B0B0B",borderRadius:"6px",cursor:"pointer"},children:"Submit"})]})]})]})}function ye({role:c,content:p,html:d,timestamp:o,toolBadges:i,isStreaming:f,onCodeBlockClick:h,onFilePathClick:S,onFeedback:v,feedbackRating:x,afterContent:a}){const n=c==="user";return e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:n?"flex-end":"flex-start",marginBottom:"16px",width:"100%",maxWidth:"100%"},children:[e.jsx("div",{style:{fontSize:"13px",fontWeight:400,color:D,marginBottom:"6px"},children:n?"You":"Compass"}),i&&i.length>0&&e.jsx("div",{style:{marginBottom:"8px",display:"flex",flexWrap:"wrap",gap:"4px",maxWidth:"75%"},children:i.map((t,r)=>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 ${t.pending?"var(--rail-discovery, #5A8CC0)":t.success!==!1?"var(--state-present, #5CB85C)":"var(--rail-signal-churn, #C98A5A)"}`,color:t.pending?"var(--rail-discovery, #5A8CC0)":t.success!==!1?"var(--state-present, #5CB85C)":"var(--rail-signal-churn, #C98A5A)"},children:[e.jsx(F.Wrench,{size:10,style:{marginRight:3,verticalAlign:"middle"}}),t.name,t.pending?"...":t.success!==!1?" ✓":" ✗"]},t.id||r))}),e.jsx("div",{style:n?{maxWidth:"85%",width:"fit-content",padding:"12px 16px",borderRadius:"8px",background:"#f3f7f7",fontSize:"14px",lineHeight:1.6,color:"#2e3236",wordBreak:"break-word"}:{width:"100%",maxWidth:"100%",padding:"20px 24px",border:"1px solid #e6e6e6",borderRadius:"14px",background:"#FFFFFF",fontSize:"14px",lineHeight:1.6,color:"#2e3236",wordBreak:"break-word"},children:d?e.jsx("div",{dangerouslySetInnerHTML:{__html:d}}):n?e.jsx("div",{style:{whiteSpace:"pre-wrap"},children:p}):e.jsx(ue,{content:p||"",onCodeBlockClick:h,onFilePathClick:S})}),a&&e.jsx("div",{style:{width:"100%",marginTop:"10px"},children:a}),!(f&&!n)&&e.jsx(me,{timestamp:o,content:p,showFeedback:!n,align:n?"end":"start",onFeedback:v,initialRating:x})]})}exports.ChartRenderer=xe;exports.ChatMessage=ye;
|
|
15
15
|
//# sourceMappingURL=ChatMessage.cjs.js.map
|