chordia-ui 4.0.6 → 4.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/dist/MessageThread.cjs.js +4 -6
  2. package/dist/MessageThread.cjs.js.map +1 -1
  3. package/dist/MessageThread.es.js +348 -475
  4. package/dist/MessageThread.es.js.map +1 -1
  5. package/dist/ThinkingIndicator.cjs.js +17 -0
  6. package/dist/ThinkingIndicator.cjs.js.map +1 -0
  7. package/dist/{ChatMessage.es.js → ThinkingIndicator.es.js} +415 -288
  8. package/dist/ThinkingIndicator.es.js.map +1 -0
  9. package/dist/Toast.cjs.js +2 -2
  10. package/dist/Toast.cjs.js.map +1 -1
  11. package/dist/Toast.es.js +103 -115
  12. package/dist/Toast.es.js.map +1 -1
  13. package/dist/components/chat.cjs.js +1 -1
  14. package/dist/components/chat.cjs.js.map +1 -1
  15. package/dist/components/chat.es.js +5 -5
  16. package/dist/components/common.cjs.js +1 -1
  17. package/dist/components/common.es.js +1 -1
  18. package/dist/components/policies.cjs.js +1 -1
  19. package/dist/components/policies.cjs.js.map +1 -1
  20. package/dist/components/policies.es.js +357 -283
  21. package/dist/components/policies.es.js.map +1 -1
  22. package/dist/components/reports.cjs.js +2 -2
  23. package/dist/components/reports.cjs.js.map +1 -1
  24. package/dist/components/reports.es.js +25 -20
  25. package/dist/components/reports.es.js.map +1 -1
  26. package/dist/index.cjs.js +1 -1
  27. package/dist/index.es.js +5 -5
  28. package/package.json +1 -1
  29. package/src/components/common/AskCompass.jsx +2 -15
  30. package/src/components/policies/PoliciesPage.jsx +15 -13
  31. package/src/components/policies/PolicyCard.jsx +35 -5
  32. package/src/components/policies/PolicyDetailsDrawer.jsx +101 -34
  33. package/src/components/reports/ReportsList.jsx +8 -2
  34. package/dist/ChatMessage.cjs.js +0 -15
  35. package/dist/ChatMessage.cjs.js.map +0 -1
  36. package/dist/ChatMessage.es.js.map +0 -1
@@ -1,15 +1,13 @@
1
- "use strict";const e=require("react/jsx-runtime"),s=require("react"),y=require("lucide-react"),ce=require("./ChatMessage.cjs.js"),pe="#2e3236",he="#e3e1d7",ye="#2e3236";function me({size:d=32}){const p=Math.round(d*.75);return e.jsx("div",{style:{width:d,height:d,borderRadius:"9999px",background:pe,display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",flexShrink:0},children:e.jsxs("svg",{width:p,height:p,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{display:"block"},"aria-hidden":"true",children:[e.jsx("path",{d:"M12 24C18.6274 24 24 18.6274 24 12C24 5.37258 18.6274 0 12 0C5.37258 0 0 5.37258 0 12C0 18.6274 5.37258 24 12 24Z",fill:pe}),e.jsx("path",{d:"M12.0281 1.54883C15.1413 1.54883 17.9364 2.90958 19.8514 5.06845C21.4881 6.9137 22.4824 9.34236 22.4824 12.0032C22.4824 15.0939 21.1413 17.8711 19.0094 19.7849C17.1586 21.4463 14.7113 22.4575 12.0281 22.4575C9.34478 22.4575 6.74638 21.3828 4.8764 19.6286C2.84343 17.7216 1.57373 15.0107 1.57373 12.0032C1.57373 9.28897 2.60792 6.81646 4.30366 4.95829C6.21523 2.86349 8.9682 1.54883 12.0281 1.54883Z",stroke:"#E8D4A3",strokeWidth:"1.6",strokeMiterlimit:"10"}),e.jsx("path",{d:"M12.0281 4.27832C14.237 4.27832 16.2239 5.21303 17.6307 6.69799C18.9409 8.08066 19.7525 9.94558 19.7525 12.0027C19.7525 14.2369 18.8032 16.2491 17.2862 17.6582C15.9086 18.9419 14.06 19.7271 12.0281 19.7271C9.99626 19.7271 8.46689 18.4265 7.08366 17.1225C5.58971 15.714 4.30371 14.2184 4.30371 12.0027C4.30371 10.0097 5.05856 8.19307 6.2979 6.82333C7.71148 5.26024 9.75514 4.27832 12.0281 4.27832Z",stroke:"#9BDB9C",strokeWidth:"1.2",strokeMiterlimit:"10"}),e.jsx("path",{d:"M12.0282 7.00837C13.3327 7.00837 14.5209 7.50861 15.4101 8.32753C16.4016 9.24032 17.0226 10.5488 17.0226 12.0028C17.0226 13.3805 16.4651 14.6282 15.563 15.5315C14.6592 16.4369 13.4091 16.9973 12.0282 16.9973C10.6472 16.9973 10.1869 15.4702 9.29093 14.6164C8.33599 13.7065 7.03369 13.426 7.03369 12.0023C7.03369 10.7303 7.50919 9.56969 8.29158 8.68781C9.20662 7.65699 10.5415 7.00781 12.0282 7.00781V7.00837Z",stroke:"#4DE294",strokeWidth:"0.8",strokeMiterlimit:"10"})]})})}function ue({phase:d="thinking",label:p,toolSteps:k=[],elapsedMs:j,compact:c=!1}){const C=p||(d==="responding"||d==="generating"?"Compass is generating response...":"Thinking..."),L=c?28:32;return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",animation:"cuiThinkingPulse 1.6s ease-in-out infinite"},children:[e.jsx("style",{children:`
2
- @keyframes cuiThinkingPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }
3
- `}),e.jsx(me,{size:L}),e.jsx("div",{style:{display:"inline-flex",alignItems:"center",background:he,padding:c?"8px 12px":"12px 16px",borderRadius:"20px",maxWidth:"100%",minWidth:0},children:e.jsx("p",{style:{margin:0,fontSize:"14px",fontWeight:400,lineHeight:"normal",color:ye,fontFamily:"inherit",overflowWrap:"anywhere",wordBreak:"break-word"},children:C})})]})}const ve={error:(...d)=>console.warn("toast.error:",...d)};function ke({initialMessages:d=[],onSendMessage:p,onStreamMessage:k,onMessagesChange:j,onCodeBlockClick:c,placeholder:C="Ask a question about this interaction...",title:L="Chat with Chordia"}){const[M,P]=s.useState(d||[]),[b,ee]=s.useState(""),[U,z]=s.useState(!1),[m,u]=s.useState(!1),[h,A]=s.useState(null),[F,q]=s.useState("thinking"),[O,n]=s.useState(null),[v,I]=s.useState(0),f=s.useRef(null),R=s.useRef(null),_=s.useRef(null),J=s.useRef(null),H=s.useRef(null),[N,$]=s.useState(!1),[te,K]=s.useState(0);s.useEffect(()=>{var a;(a=f.current)==null||a.scrollIntoView({behavior:"smooth"})},[M,U]),s.useEffect(()=>{R.current&&(R.current.style.height="auto",R.current.style.height=`${Math.min(R.current.scrollHeight,120)}px`)},[b]),s.useEffect(()=>{if(j){const a=[...M];h&&a.push(h),j(a)}},[M,h,j]),s.useEffect(()=>{let a;return U&&O&&(a=setInterval(()=>{if(I(Date.now()-O),H.current){const l=(Date.now()-H.current)/1e3;l>=3?($(!0),K(Math.floor(l))):$(!1)}},500)),()=>a&&clearInterval(a)},[U,O]);const Q=()=>{z(!1),u(!1),A(null),J.current=null,q("thinking"),$(!1),K(0),H.current=null,n(null),I(0),_.current&&(_.current.abort(),_.current=null)},re=a=>{if(a.startsWith("data: ")){const l=a.slice(6);if(l==="[DONE]")return{type:"done"};try{return{type:"data",data:JSON.parse(l)}}catch{return null}}return null},se=a=>{var T,x;if(!((x=(T=a.choices)==null?void 0:T[0])!=null&&x.delta))return;H.current=Date.now(),$(!1);const l=a.choices[0].delta;if(l.tool_calls||l.tool_results){q("tool");return}l.content!==void 0&&(q("responding"),A(S=>{const Y=S||{id:Date.now().toString(),role:"assistant",content:"",timestamp:new Date().toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}),isStreaming:!0},V={...Y,content:(Y.content||"")+(l.content||"")};return J.current=V,V}))},X=async a=>{const l=a.getReader(),T=new TextDecoder;let x="";try{for(;;){const{done:S,value:Y}=await l.read();if(S)break;x+=T.decode(Y,{stream:!0});const V=x.split(`
4
- `);x=V.pop()||"";for(const ae of V)if(ae.trim()){const ne=re(ae);if(ne){if(ne.type==="done")return;ne.type==="data"&&se(ne.data)}}}}finally{l.releaseLock()}},ie=async()=>{if(!b.trim()||m)return;const a=b.trim(),l={id:Date.now().toString(),role:"user",content:a,timestamp:new Date().toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"})},T=[...M,l];P(T),ee(""),z(!0),u(!0),q("thinking"),n(Date.now()),H.current=Date.now(),_.current=new AbortController;try{let x;if(k)x=await k(a,T);else if(p)x=await p(a,T);else{setTimeout(()=>{const S={id:(Date.now()+1).toString(),role:"assistant",content:"This is a demonstration response. In a real implementation, this would connect to your LLM backend.",timestamp:new Date().toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"})};P(Y=>[...Y,S]),Q()},1e3);return}if(x instanceof ReadableStream)await X(x);else if(x instanceof Response&&x.body)await X(x.body);else if(x&&typeof x.then=="function"){const S=await x;S instanceof ReadableStream?await X(S):S instanceof Response&&S.body&&await X(S.body)}J.current&&P(S=>[...S,{...J.current,isStreaming:!1}])}catch(x){x.name!=="AbortError"&&(ve.error("Failed to send message"),console.error("Stream error:",x))}finally{Q()}},D=a=>{a.key==="Enter"&&!a.shiftKey&&(a.preventDefault(),ie())};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",border:"1px solid var(--border, rgba(52,58,64,0.12))",borderRadius:"var(--radius-lg, 12px)",background:"var(--paper-elevated, rgba(255,255,255,0.82))",overflow:"hidden"},children:[L?e.jsxs("div",{style:{padding:"16px 20px",borderBottom:"1px solid var(--border-subtle, rgba(52,58,64,0.08))",background:"var(--paper-elevated, rgba(255,255,255,0.82))"},children:[e.jsx("div",{style:{fontSize:"var(--text-lg, 16px)",fontWeight:720,letterSpacing:"-0.01em",color:"var(--text-strong, rgba(30,33,37,0.92))"},children:L}),e.jsx("div",{style:{fontSize:"var(--text-sm, 11px)",color:"var(--text-muted, rgba(30,33,37,0.56))",marginTop:"2px"},children:"Ask questions, get insights from analyzed interactions"})]}):null,e.jsx("div",{style:{flex:1,minHeight:0,overflowY:"auto",padding:"20px",display:"flex",flexDirection:"column"},children:M.length===0?e.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",color:"var(--text-faint, rgba(30,33,37,0.36))",fontSize:"var(--text-md, 13px)",textAlign:"center",padding:"40px"},children:"No messages yet. Start a conversation by asking a question below."}):e.jsxs(e.Fragment,{children:[M.map(a=>e.jsx(ce.ChatMessage,{role:a.role,content:a.content,html:a.html,timestamp:a.timestamp,toolBadges:a.toolBadges,isStreaming:a.isStreaming,onCodeBlockClick:c},a.id)),h&&e.jsx(ce.ChatMessage,{role:h.role,content:h.content,timestamp:h.timestamp,isStreaming:!0,onCodeBlockClick:c},h.id),U&&(!h||N)&&e.jsx("div",{style:{marginBottom:"16px"},children:e.jsx(ue,{phase:N?"tool":F,elapsedMs:v,label:N&&te>=30?"Compacting conversation — trimming context to stay sharp...":N&&te>=10?"Running background tasks...":N?"Still working...":void 0})}),e.jsx("div",{ref:f})]})}),e.jsxs("div",{style:{borderTop:"1px solid var(--border-subtle, rgba(52,58,64,0.08))",padding:"16px 20px",background:"var(--paper-elevated, rgba(255,255,255,0.82))"},children:[e.jsxs("div",{style:{display:"flex",gap:"12px",alignItems:"flex-end"},children:[e.jsx("textarea",{ref:R,value:b,onChange:a=>ee(a.target.value),onKeyDown:D,placeholder:C,rows:1,disabled:m,style:{flex:1,padding:"10px 14px",fontSize:"var(--text-base, 14px)",lineHeight:1.5,color:"var(--text-strong, rgba(30,33,37,0.92))",background:"rgba(255, 255, 255, 0.95)",border:"1px solid rgba(52, 58, 64, 0.18)",borderRadius:"var(--radius-md, 8px)",resize:"none",outline:"none",transition:"border-color 0.15s ease",fontFamily:"inherit",minHeight:"42px",maxHeight:"120px",opacity:m?.6:1,cursor:m?"not-allowed":"text"},onFocus:a=>{m||(a.target.style.borderColor="rgba(94, 136, 176, 0.35)")},onBlur:a=>{a.target.style.borderColor="rgba(52, 58, 64, 0.18)"}}),e.jsx("button",{onClick:ie,disabled:!b.trim()||m,style:{padding:"10px 16px",background:b.trim()&&!m?"var(--Base-Strong, #0B0B0B)":"#ECEEF2",color:b.trim()&&!m?"white":"var(--text-base)",border:"none",borderRadius:"var(--radius-md, 8px)",cursor:b.trim()&&!m?"pointer":"not-allowed",display:"flex",alignItems:"center",gap:"6px",fontSize:"var(--text-md, 13px)",fontWeight:650,transition:"all 0.15s ease",height:"42px"},children:m?e.jsxs(e.Fragment,{children:[e.jsx("style",{children:`
1
+ "use strict";const e=require("react/jsx-runtime"),s=require("react"),y=require("lucide-react"),de=require("./ThinkingIndicator.cjs.js"),fe={error:(...h)=>console.warn("toast.error:",...h)};function be({initialMessages:h=[],onSendMessage:f,onStreamMessage:j,onMessagesChange:k,onCodeBlockClick:d,placeholder:L="Ask a question about this interaction...",title:H="Chat with Chordia"}){const[C,P]=s.useState(h||[]),[g,ee]=s.useState(""),[q,E]=s.useState(!1),[m,c]=s.useState(!1),[b,W]=s.useState(null),[z,K]=s.useState("thinking"),[O,n]=s.useState(null),[v,F]=s.useState(0),x=s.useRef(null),I=s.useRef(null),_=s.useRef(null),X=s.useRef(null),A=s.useRef(null),[N,$]=s.useState(!1),[te,U]=s.useState(0);s.useEffect(()=>{var a;(a=x.current)==null||a.scrollIntoView({behavior:"smooth"})},[C,q]),s.useEffect(()=>{I.current&&(I.current.style.height="auto",I.current.style.height=`${Math.min(I.current.scrollHeight,120)}px`)},[g]),s.useEffect(()=>{if(k){const a=[...C];b&&a.push(b),k(a)}},[C,b,k]),s.useEffect(()=>{let a;return q&&O&&(a=setInterval(()=>{if(F(Date.now()-O),A.current){const l=(Date.now()-A.current)/1e3;l>=3?($(!0),U(Math.floor(l))):$(!1)}},500)),()=>a&&clearInterval(a)},[q,O]);const G=()=>{E(!1),c(!1),W(null),X.current=null,K("thinking"),$(!1),U(0),A.current=null,n(null),F(0),_.current&&(_.current.abort(),_.current=null)},re=a=>{if(a.startsWith("data: ")){const l=a.slice(6);if(l==="[DONE]")return{type:"done"};try{return{type:"data",data:JSON.parse(l)}}catch{return null}}return null},se=a=>{var T,p;if(!((p=(T=a.choices)==null?void 0:T[0])!=null&&p.delta))return;A.current=Date.now(),$(!1);const l=a.choices[0].delta;if(l.tool_calls||l.tool_results){K("tool");return}l.content!==void 0&&(K("responding"),W(S=>{const Y=S||{id:Date.now().toString(),role:"assistant",content:"",timestamp:new Date().toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}),isStreaming:!0},V={...Y,content:(Y.content||"")+(l.content||"")};return X.current=V,V}))},Z=async a=>{const l=a.getReader(),T=new TextDecoder;let p="";try{for(;;){const{done:S,value:Y}=await l.read();if(S)break;p+=T.decode(Y,{stream:!0});const V=p.split(`
2
+ `);p=V.pop()||"";for(const ae of V)if(ae.trim()){const ne=re(ae);if(ne){if(ne.type==="done")return;ne.type==="data"&&se(ne.data)}}}}finally{l.releaseLock()}},oe=async()=>{if(!g.trim()||m)return;const a=g.trim(),l={id:Date.now().toString(),role:"user",content:a,timestamp:new Date().toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"})},T=[...C,l];P(T),ee(""),E(!0),c(!0),K("thinking"),n(Date.now()),A.current=Date.now(),_.current=new AbortController;try{let p;if(j)p=await j(a,T);else if(f)p=await f(a,T);else{setTimeout(()=>{const S={id:(Date.now()+1).toString(),role:"assistant",content:"This is a demonstration response. In a real implementation, this would connect to your LLM backend.",timestamp:new Date().toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"})};P(Y=>[...Y,S]),G()},1e3);return}if(p instanceof ReadableStream)await Z(p);else if(p instanceof Response&&p.body)await Z(p.body);else if(p&&typeof p.then=="function"){const S=await p;S instanceof ReadableStream?await Z(S):S instanceof Response&&S.body&&await Z(S.body)}X.current&&P(S=>[...S,{...X.current,isStreaming:!1}])}catch(p){p.name!=="AbortError"&&(fe.error("Failed to send message"),console.error("Stream error:",p))}finally{G()}},R=a=>{a.key==="Enter"&&!a.shiftKey&&(a.preventDefault(),oe())};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",border:"1px solid var(--border, rgba(52,58,64,0.12))",borderRadius:"var(--radius-lg, 12px)",background:"var(--paper-elevated, rgba(255,255,255,0.82))",overflow:"hidden"},children:[H?e.jsxs("div",{style:{padding:"16px 20px",borderBottom:"1px solid var(--border-subtle, rgba(52,58,64,0.08))",background:"var(--paper-elevated, rgba(255,255,255,0.82))"},children:[e.jsx("div",{style:{fontSize:"var(--text-lg, 16px)",fontWeight:720,letterSpacing:"-0.01em",color:"var(--text-strong, rgba(30,33,37,0.92))"},children:H}),e.jsx("div",{style:{fontSize:"var(--text-sm, 11px)",color:"var(--text-muted, rgba(30,33,37,0.56))",marginTop:"2px"},children:"Ask questions, get insights from analyzed interactions"})]}):null,e.jsx("div",{style:{flex:1,minHeight:0,overflowY:"auto",padding:"20px",display:"flex",flexDirection:"column"},children:C.length===0?e.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",color:"var(--text-faint, rgba(30,33,37,0.36))",fontSize:"var(--text-md, 13px)",textAlign:"center",padding:"40px"},children:"No messages yet. Start a conversation by asking a question below."}):e.jsxs(e.Fragment,{children:[C.map(a=>e.jsx(de.ChatMessage,{role:a.role,content:a.content,html:a.html,timestamp:a.timestamp,toolBadges:a.toolBadges,isStreaming:a.isStreaming,onCodeBlockClick:d},a.id)),b&&e.jsx(de.ChatMessage,{role:b.role,content:b.content,timestamp:b.timestamp,isStreaming:!0,onCodeBlockClick:d},b.id),q&&(!b||N)&&e.jsx("div",{style:{marginBottom:"16px"},children:e.jsx(de.ThinkingIndicator,{phase:N?"tool":z,elapsedMs:v,label:N&&te>=30?"Compacting conversation — trimming context to stay sharp...":N&&te>=10?"Running background tasks...":N?"Still working...":void 0})}),e.jsx("div",{ref:x})]})}),e.jsxs("div",{style:{borderTop:"1px solid var(--border-subtle, rgba(52,58,64,0.08))",padding:"16px 20px",background:"var(--paper-elevated, rgba(255,255,255,0.82))"},children:[e.jsxs("div",{style:{display:"flex",gap:"12px",alignItems:"flex-end"},children:[e.jsx("textarea",{ref:I,value:g,onChange:a=>ee(a.target.value),onKeyDown:R,placeholder:L,rows:1,disabled:m,style:{flex:1,padding:"10px 14px",fontSize:"var(--text-base, 14px)",lineHeight:1.5,color:"var(--text-strong, rgba(30,33,37,0.92))",background:"rgba(255, 255, 255, 0.95)",border:"1px solid rgba(52, 58, 64, 0.18)",borderRadius:"var(--radius-md, 8px)",resize:"none",outline:"none",transition:"border-color 0.15s ease",fontFamily:"inherit",minHeight:"42px",maxHeight:"120px",opacity:m?.6:1,cursor:m?"not-allowed":"text"},onFocus:a=>{m||(a.target.style.borderColor="rgba(94, 136, 176, 0.35)")},onBlur:a=>{a.target.style.borderColor="rgba(52, 58, 64, 0.18)"}}),e.jsx("button",{onClick:oe,disabled:!g.trim()||m,style:{padding:"10px 16px",background:g.trim()&&!m?"var(--Base-Strong, #0B0B0B)":"#ECEEF2",color:g.trim()&&!m?"white":"var(--text-base)",border:"none",borderRadius:"var(--radius-md, 8px)",cursor:g.trim()&&!m?"pointer":"not-allowed",display:"flex",alignItems:"center",gap:"6px",fontSize:"var(--text-md, 13px)",fontWeight:650,transition:"all 0.15s ease",height:"42px"},children:m?e.jsxs(e.Fragment,{children:[e.jsx("style",{children:`
5
3
  @keyframes buttonSpin {
6
4
  from { transform: rotate(0deg); }
7
5
  to { transform: rotate(360deg); }
8
6
  }
9
- `}),e.jsx("div",{style:{width:"14px",height:"14px",border:"2px solid rgba(255, 255, 255, 0.3)",borderTopColor:"white",borderRadius:"50%",animation:"buttonSpin 0.6s linear infinite"}}),"Sending..."]}):e.jsxs(e.Fragment,{children:[e.jsx(y.Send,{size:16}),"Send"]})})]}),e.jsx("div",{style:{fontSize:"var(--text-sm, 11px)",color:"var(--text-faint, rgba(30,33,37,0.36))",marginTop:"8px"},children:"Press Enter to send, Shift+Enter for new line"})]})]})}const i={title:"#2e3236",muted:"#808183",faint:"#989898",hoverBg:"#f3f7f7",selectedBg:"#FAF5E9",border:"#d9d9d9",borderSubtle:"#e6e6e6",pillDarkBg:"#272727",pillDarkText:"#f2f2f0",searchTrack:"#d8d8d8"};function je(d){const p=d?new Date(d):null;if(!p||Number.isNaN(p.getTime()))return"Older";const k=new Date,j=new Date(k.getFullYear(),k.getMonth(),k.getDate()),c=new Date(j);return c.setDate(j.getDate()-1),p>=j?"Today":p>=c?"Yesterday":"Older"}const Se=["Today","Yesterday","Older"];function we(d){const p=d?new Date(d):null;if(!p||Number.isNaN(p.getTime()))return"";const k=Date.now()-p.getTime(),j=Math.floor(k/6e4);if(j<1)return"just now";if(j<60)return`${j}m ago`;const c=Math.floor(j/60);if(c<24)return`${c}h ago`;const C=Math.floor(c/24);return C<7?`${C}d ago`:p.toLocaleDateString(void 0,{month:"short",day:"numeric"})}function Ce({threads:d=[],activeThreadId:p,onSelectThread:k,onNewChat:j,onCollapse:c,onRenameThread:C,onDeleteThread:L,onPinThread:M,loading:P=!1,pageSize:b=10,page:ee,pageCount:U,onPageChange:z,onFilterChange:m}){const u=typeof z=="function",[h,A]=s.useState(""),[F,q]=s.useState("all"),O=o=>{q(o),m==null||m(o)},[n,v]=s.useState(1),[I,f]=s.useState(null),[R,_]=s.useState(null),[J,H]=s.useState(""),[N,$]=s.useState(null),[te,K]=s.useState(null),Q=s.useRef(null);s.useEffect(()=>{R&&Q.current&&(Q.current.focus(),Q.current.select())},[R]),s.useEffect(()=>{if(!te)return;const o=()=>K(null),r=B=>{B.key==="Escape"&&K(null)};return document.addEventListener("click",o),document.addEventListener("keydown",r),()=>{document.removeEventListener("click",o),document.removeEventListener("keydown",r)}},[te]);const re=typeof C=="function",se=typeof L=="function",X=typeof M=="function",{groups:ie,totalPages:D}=s.useMemo(()=>{const o=h.trim().toLowerCase(),B=[...d.filter(g=>F==="pinned"&&!g.pinned?!1:o?(g.title||"").toLowerCase().includes(o)||(g.last_message_preview||"").toLowerCase().includes(o):!0)].sort((g,E)=>{if(g.pinned&&!E.pinned)return-1;if(!g.pinned&&E.pinned)return 1;const le=new Date(g.updated_at||g.created_at||0).getTime();return new Date(E.updated_at||E.created_at||0).getTime()-le}),Z=u?Math.max(1,U||1):Math.max(1,Math.ceil(B.length/b));let w;if(u)w=B;else{const E=(Math.min(n,Z)-1)*b;w=B.slice(E,E+b)}const W={};for(const g of w){const E=je(g.updated_at||g.created_at);(W[E]||(W[E]=[])).push(g)}return{groups:Se.map(g=>({label:g,items:W[g]||[]})).filter(g=>g.items.length>0),totalPages:Z}},[d,h,F,n,b,u,U]),a=ie.reduce((o,r)=>o+r.items.length,0),l=u?Math.max(1,ee||1):n,T=u?z:v;s.useEffect(()=>{u||v(1)},[h,F,u]),s.useEffect(()=>{u||v(o=>Math.min(o,D))},[D,u]);const x=s.useMemo(()=>{if(D<=5)return Array.from({length:D},(Z,w)=>w+1);let r=Math.max(1,l-2);const B=Math.min(D,r+5-1);return r=Math.max(1,B-5+1),Array.from({length:B-r+1},(Z,w)=>r+w)},[D,l]),S=(o,r)=>{o.stopPropagation(),K(null),$(null),_(r.id),H(r.title||r.name||"")},Y=o=>{o&&o.stopPropagation();const r=(J||"").trim();R&&r&&(C==null||C(R,r)),_(null),H("")},V=o=>{o&&o.stopPropagation(),_(null),H("")},ae=(o,r)=>{o.stopPropagation(),K(null),_(null),$(r.id)},ne=o=>{o&&o.stopPropagation(),N&&(L==null||L(N)),$(null)},xe=o=>{o&&o.stopPropagation(),$(null)},ge=(o,r)=>{o.stopPropagation(),M==null||M(r.id,!r.pinned)},oe={display:"inline-flex",alignItems:"center",justifyContent:"center",width:"24px",height:"24px",padding:0,background:"transparent",border:"none",borderRadius:"6px",cursor:"pointer",color:i.muted,transition:"all 0.12s ease",flexShrink:0};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",background:"#FFFFFF",overflow:"hidden"},children:[e.jsxs("div",{style:{padding:"16px 16px 0 16px",flexShrink:0},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",height:"32px"},children:[e.jsx("div",{style:{fontSize:"14px",fontWeight:400,color:i.title},children:"Threads"}),c&&e.jsx("button",{type:"button",title:"Collapse",onClick:c,style:{...oe,width:"20px",height:"20px",color:i.muted},onMouseEnter:o=>o.currentTarget.style.background=i.hoverBg,onMouseLeave:o=>o.currentTarget.style.background="transparent",children:e.jsx(y.PanelLeftClose,{size:20,strokeWidth:1.5})})]}),e.jsx("div",{style:{display:"flex",alignItems:"center",height:"32px",background:i.searchTrack,borderRadius:"11px",padding:"1px",marginTop:"12px"},children:e.jsxs("div",{style:{display:"flex",flex:1,alignItems:"center",gap:"8px",height:"30px",background:"#FFFFFF",borderRadius:"10px",padding:"4px 8px"},children:[e.jsx(y.Search,{size:18,style:{color:i.faint,flexShrink:0}}),e.jsx("input",{type:"text",value:h,onChange:o=>A(o.target.value),placeholder:"Search",style:{flex:1,minWidth:0,border:"none",outline:"none",background:"transparent",fontSize:"14px",fontWeight:500,color:i.title}})]})}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"16px",marginTop:"12px"},children:[e.jsx("button",{type:"button",onClick:()=>O("all"),style:{display:"inline-flex",alignItems:"center",justifyContent:"center",height:"28px",padding:"0 12px",borderRadius:"8px",border:"none",cursor:"pointer",fontSize:"14px",fontWeight:400,lineHeight:"24px",transition:"all 0.12s ease",background:F==="all"?i.pillDarkBg:i.hoverBg,color:F==="all"?i.pillDarkText:i.title},children:"All"}),e.jsxs("button",{type:"button",onClick:()=>O("pinned"),style:{display:"inline-flex",alignItems:"center",justifyContent:"center",gap:"8px",height:"28px",padding:"0 16px",borderRadius:"10px",border:"none",cursor:"pointer",fontSize:"14px",fontWeight:400,lineHeight:"24px",transition:"all 0.12s ease",background:F==="pinned"?i.pillDarkBg:i.hoverBg,color:F==="pinned"?i.pillDarkText:i.title},children:[e.jsx(y.Pin,{size:16,style:{flexShrink:0}}),"Pinned"]})]})]}),e.jsx("div",{style:{flex:1,overflowY:"auto",padding:"16px 16px 8px 16px"},children:P?e.jsx("div",{style:{padding:"30px 16px",textAlign:"center",color:i.faint,fontSize:"13px"},children:"Loading threads..."}):a===0?e.jsx("div",{style:{padding:"30px 16px",textAlign:"center",color:i.faint,fontSize:"13px"},children:h?"No threads found":F==="pinned"?"No pinned threads":"No threads yet"}):ie.map(o=>e.jsxs("div",{style:{marginBottom:"8px"},children:[e.jsx("div",{style:{fontSize:"13px",fontWeight:500,color:i.title,padding:"8px 0 4px 0"},children:o.label}),o.items.map(r=>{const B=r.id===p,Z=I===r.id,w=R===r.id,W=N===r.id,G=te===r.id,g=re||se,E=(X||g)&&(Z||B||G)&&!w&&!W,le=G||W||w,de=B?i.selectedBg:Z||le?i.hoverBg:"transparent",fe=B||Z||le?`1px solid ${i.border}`:"1px solid transparent";return e.jsxs("div",{onClick:()=>{w||W||k==null||k(r.id)},onMouseEnter:()=>f(r.id),onMouseLeave:()=>f(t=>t===r.id?null:t),style:{display:"flex",alignItems:"center",gap:"4px",padding:"8px 4px",marginBottom:"2px",borderRadius:"8px",background:de,border:fe,cursor:w||W?"default":"pointer",transition:"background 0.12s ease, border-color 0.12s ease",boxSizing:"border-box",position:"relative"},children:[e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",width:"40px",height:"40px",flexShrink:0,color:i.muted},children:e.jsx(y.MessageSquare,{size:20})}),w?e.jsx("input",{ref:Q,type:"text",value:J,onChange:t=>H(t.target.value),onClick:t=>t.stopPropagation(),onKeyDown:t=>{t.stopPropagation(),t.key==="Enter"?Y(t):t.key==="Escape"&&V(t)},style:{flex:1,minWidth:0,fontSize:"14px",fontWeight:600,color:i.title,background:"#fff",border:`1px solid ${i.border}`,borderRadius:"6px",padding:"4px 8px",outline:"none",boxSizing:"border-box"}}):e.jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:"4px",textAlign:"left"},children:[e.jsx("div",{title:r.title||r.name||"Untitled thread",style:{display:"block",minWidth:0,maxWidth:"100%",fontSize:"14px",fontWeight:B?550:500,color:i.title,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",lineHeight:1.2},children:r.title||r.name||"Untitled thread"}),W?e.jsxs("div",{style:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"12px",fontWeight:500,color:i.title},children:"Confirm: delete this thread?"}),e.jsx("button",{type:"button",onClick:ne,style:{padding:"3px 12px",fontSize:"12px",fontWeight:600,color:i.title,background:"#ECEEF2",border:`1px solid ${i.borderSubtle}`,borderRadius:"6px",cursor:"pointer"},onMouseEnter:t=>t.currentTarget.style.background="#E2E5EA",onMouseLeave:t=>t.currentTarget.style.background="#ECEEF2",children:"Yes"}),e.jsx("button",{type:"button",onClick:xe,style:{padding:"3px 6px",fontSize:"12px",fontWeight:500,color:i.muted,background:"transparent",border:"none",cursor:"pointer"},onMouseEnter:t=>t.currentTarget.style.color=i.title,onMouseLeave:t=>t.currentTarget.style.color=i.muted,children:"No"})]}):e.jsxs("div",{style:{fontSize:"12px",color:i.muted,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",lineHeight:1.5},children:[r.message_count!=null&&e.jsxs(e.Fragment,{children:[r.message_count," msg",r.message_count!==1?"s":""," · "]}),we(r.updated_at||r.created_at)]})]}),w&&e.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:"2px",flexShrink:0},children:[e.jsx("button",{type:"button",title:"Save",onClick:Y,style:{...oe,color:"#1f9d57"},onMouseEnter:t=>t.currentTarget.style.background="rgba(31,157,87,0.12)",onMouseLeave:t=>t.currentTarget.style.background="transparent",children:e.jsx(y.Check,{size:15})}),e.jsx("button",{type:"button",title:"Cancel",onClick:V,style:oe,onMouseEnter:t=>t.currentTarget.style.background="rgba(0,0,0,0.06)",onMouseLeave:t=>t.currentTarget.style.background="transparent",children:e.jsx(y.X,{size:15})})]}),!w&&!W&&!E&&r.pinned&&e.jsx(y.Pin,{size:14,style:{color:i.title,flexShrink:0},fill:"currentColor"}),E&&e.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:"2px",flexShrink:0},children:[X&&e.jsx("button",{type:"button",title:r.pinned?"Unpin":"Pin",onClick:t=>ge(t,r),style:{...oe,color:r.pinned?i.title:i.muted},onMouseEnter:t=>{t.currentTarget.style.background="rgba(0,0,0,0.06)",t.currentTarget.style.color=i.title},onMouseLeave:t=>{t.currentTarget.style.background="transparent",t.currentTarget.style.color=r.pinned?i.title:i.muted},children:e.jsx(y.Pin,{size:14,fill:r.pinned?"currentColor":"none"})}),g&&e.jsx("button",{type:"button",title:"More",onClick:t=>{t.stopPropagation(),K(be=>be===r.id?null:r.id)},style:{...oe,color:G?i.title:i.muted,background:G?"rgba(0,0,0,0.06)":"transparent"},onMouseEnter:t=>{t.currentTarget.style.background="rgba(0,0,0,0.06)",t.currentTarget.style.color=i.title},onMouseLeave:t=>{t.currentTarget.style.background=G?"rgba(0,0,0,0.06)":"transparent",t.currentTarget.style.color=G?i.title:i.muted},children:e.jsx(y.MoreVertical,{size:14})})]}),G&&g&&e.jsxs("div",{onClick:t=>t.stopPropagation(),style:{position:"absolute",top:"calc(100% - 2px)",right:"8px",zIndex:20,width:"144px",background:"#FFFFFF",border:`1px solid ${i.border}`,borderRadius:"4px",boxShadow:"-2px 2px 4px rgba(0,0,0,0.1)",overflow:"hidden"},children:[re&&e.jsx("button",{type:"button",onClick:t=>S(t,r),style:{display:"block",width:"100%",textAlign:"left",padding:"12px",fontSize:"13px",color:i.title,background:"transparent",border:"none",cursor:"pointer"},onMouseEnter:t=>t.currentTarget.style.background=i.hoverBg,onMouseLeave:t=>t.currentTarget.style.background="transparent",children:"Rename"}),se&&e.jsx("button",{type:"button",onClick:t=>ae(t,r),style:{display:"block",width:"100%",textAlign:"left",padding:"12px",fontSize:"13px",color:i.title,background:"transparent",border:"none",borderTop:re?`1px solid ${i.border}`:"none",cursor:"pointer"},onMouseEnter:t=>t.currentTarget.style.background=i.hoverBg,onMouseLeave:t=>t.currentTarget.style.background="transparent",children:"Delete"})]})]},r.id)})]},o.label))}),!P&&D>1&&e.jsxs("div",{style:{flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",gap:"6px",height:"64px",padding:"0 16px",boxSizing:"border-box",borderTop:`1px solid ${i.border}`},children:[e.jsxs("button",{type:"button",disabled:l<=1,onClick:()=>T(Math.max(1,l-1)),style:{display:"inline-flex",alignItems:"center",justifyContent:"center",gap:"4px",height:"24px",padding:"4px 8px",borderRadius:"10px",background:"#FFFFFF",border:`1px solid ${i.borderSubtle}`,fontSize:"12px",lineHeight:"16px",color:"#0b0b0b",cursor:l<=1?"default":"pointer",opacity:l<=1?.5:1},children:[e.jsx(y.ChevronLeft,{size:12}),"Back"]}),x.map(o=>{const r=o===l;return e.jsx("button",{type:"button",onClick:()=>T(o),style:{display:"inline-flex",alignItems:"center",justifyContent:"center",height:"24px",minWidth:"22px",padding:"4px 8px",borderRadius:"10px",fontSize:"12px",lineHeight:"16px",cursor:"pointer",background:r?"#0b0b0b":"#FFFFFF",color:r?"#FFFFFF":"#0b0b0b",border:r?"1px solid #0b0b0b":`1px solid ${i.borderSubtle}`,fontWeight:r?600:400},children:o},o)}),e.jsxs("button",{type:"button",disabled:l>=D,onClick:()=>T(Math.min(D,l+1)),style:{display:"inline-flex",alignItems:"center",justifyContent:"center",gap:"4px",height:"24px",padding:"4px 8px",borderRadius:"10px",background:"#FFFFFF",border:`1px solid ${i.borderSubtle}`,fontSize:"12px",lineHeight:"16px",color:"#0b0b0b",cursor:l>=D?"default":"pointer",opacity:l>=D?.5:1},children:["Next",e.jsx(y.ChevronRight,{size:12})]})]})]})}const Me={error:(...d)=>console.warn("toast.error:",...d)},Te=()=>({userData:{name:"User",email:""}});function Ee({sessionTitle:d,messages:p,onSendMessage:k,currentUser:j}){var O;const[c,C]=s.useState(""),[L,M]=s.useState(!1),[P,b]=s.useState(p||[]),[ee,U]=s.useState(!1),[z,m]=s.useState(!1),{userData:u}=Te(),h=s.useRef(null),A=j||{name:(u==null?void 0:u.name)||"You",initials:((O=u==null?void 0:u.name)==null?void 0:O.split(" ").map(n=>n[0]).join("").toUpperCase())||"YO",color:"#6B7C93"};s.useEffect(()=>{b(p||[])},[p]),s.useEffect(()=>{h.current&&h.current.scrollIntoView({behavior:"smooth"})},[P]);const F=async()=>{if(!c.trim())return;const n=c.trim();C(""),m(!0);const v={id:`temp-${Date.now()}`,author:{name:A.name,role:(u==null?void 0:u.role)||"",initials:A.initials,color:A.color},content:n,timestamp:"Just now",type:"comment",isOptimistic:!0};if(b(I=>[...I,v]),k){try{await k(n),b(I=>I.map(f=>f.id===v.id?{...f,isOptimistic:!1}:f))}catch{b(f=>f.filter(R=>R.id!==v.id)),Me.error("Failed to send message")}finally{m(!1)}return}setTimeout(()=>{b(I=>I.map(f=>f.id===v.id?{...f,isOptimistic:!1}:f)),m(!1)},500)},q=n=>{n.key==="Enter"&&!n.shiftKey&&(n.preventDefault(),F())};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",background:"var(--paper-elevated, rgba(255,255,255,0.82))",border:"1px solid var(--border, rgba(52,58,64,0.12))",borderRadius:"var(--radius-lg, 12px)",overflow:"hidden"},children:[d&&e.jsxs("div",{style:{padding:"14px 16px",borderBottom:"1px solid var(--border, rgba(52,58,64,0.12))",background:"var(--paper-elevated, rgba(255,255,255,0.82))"},children:[e.jsx("div",{style:{fontSize:"var(--text-md, 13px)",fontWeight:680,color:"var(--text-strong, rgba(30,33,37,0.92))",marginBottom:"3px"},children:"Session Discussion"}),d&&e.jsx("div",{style:{fontSize:"var(--text-sm, 11px)",color:"var(--text-muted, rgba(30,33,37,0.56))",display:"flex",alignItems:"center",gap:"8px"},children:e.jsx("span",{children:d})})]}),e.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"16px",display:"flex",flexDirection:"column",gap:"16px"},children:[ee?e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"40px",color:"var(--text-faint, rgba(30,33,37,0.36))"},children:"Loading messages..."}):P.length===0?e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"40px",color:"var(--text-faint, rgba(30,33,37,0.36))"},children:"No messages yet. Start the conversation!"}):P.map(n=>e.jsxs("div",{style:{display:"flex",gap:"12px",opacity:n.type==="system"?.75:1},children:[n.type!=="system"&&e.jsx("div",{style:{width:"32px",height:"32px",borderRadius:"8px",background:n.author.color,color:"white",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"11px",fontWeight:650,flexShrink:0,opacity:.9},children:n.author.initials}),n.type==="system"&&e.jsx("div",{style:{width:"32px",height:"32px",borderRadius:"8px",background:"rgba(30, 33, 37, 0.08)",color:"rgba(30, 33, 37, 0.52)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"11px",fontWeight:650,flexShrink:0},children:e.jsx(y.Clock,{size:14})}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",marginBottom:"4px"},children:[e.jsx("span",{style:{fontSize:"var(--text-sm, 11px)",fontWeight:650,color:"var(--text-base, rgba(30,33,37,0.78))"},children:n.author.name}),e.jsx("span",{style:{fontSize:"var(--text-sm, 11px)",color:"var(--text-faint, rgba(30,33,37,0.36))",fontFamily:"var(--font-mono, monospace)"},children:n.timestamp}),n.author.role&&e.jsx("span",{style:{fontSize:"var(--text-xs, 10px)",color:"var(--text-muted, rgba(30,33,37,0.56))",background:"rgba(30, 33, 37, 0.06)",padding:"2px 6px",borderRadius:"4px",textTransform:"uppercase",letterSpacing:"0.04em",fontWeight:600},children:n.author.role}),n.isEdited&&e.jsx("span",{style:{fontSize:"var(--text-xs, 10px)",color:"var(--text-faint, rgba(30,33,37,0.36))",fontStyle:"italic"},children:"(edited)"})]}),e.jsx("div",{style:{fontSize:"var(--text-md, 13px)",color:"var(--text-base, rgba(30,33,37,0.78))",lineHeight:1.5,marginBottom:n.references?"8px":0},children:n.content}),n.references&&n.references.length>0&&e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px",marginTop:"8px"},children:n.references.map((v,I)=>e.jsxs("button",{type:"button",style:{fontSize:"11px",padding:"4px 8px",borderRadius:"6px",border:"1px solid rgba(52, 58, 64, 0.16)",background:"rgba(255, 255, 255, 0.7)",color:v.type==="condition"?"rgba(94, 136, 176, 0.85)":v.type==="observation"?"rgba(107, 123, 147, 0.85)":v.type==="timestamp"?"rgba(184, 156, 106, 0.85)":"rgba(30, 33, 37, 0.65)",cursor:"pointer",display:"inline-flex",alignItems:"center",gap:"4px",transition:"all 0.15s ease",fontWeight:550},onMouseEnter:f=>{f.currentTarget.style.background="rgba(255, 255, 255, 0.95)",f.currentTarget.style.borderColor="rgba(52, 58, 64, 0.24)"},onMouseLeave:f=>{f.currentTarget.style.background="rgba(255, 255, 255, 0.7)",f.currentTarget.style.borderColor="rgba(52, 58, 64, 0.16)"},children:[v.type==="timestamp"&&e.jsx(y.Clock,{size:12}),(v.type==="condition"||v.type==="observation")&&e.jsx(y.Hash,{size:12}),v.label]},I))})]})]},n.id)),e.jsx("div",{ref:h})]}),e.jsxs("div",{style:{padding:"12px",borderTop:"1px solid var(--border, rgba(52,58,64,0.12))",background:"var(--paper-elevated, rgba(255,255,255,0.82))"},children:[e.jsxs("div",{style:{display:"flex",gap:"8px",alignItems:"flex-end"},children:[e.jsx("div",{style:{width:"32px",height:"32px",borderRadius:"var(--radius-md, 8px)",background:A.color,color:"white",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"var(--text-sm, 11px)",fontWeight:650,flexShrink:0,opacity:.9},children:A.initials}),e.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:"8px"},children:[e.jsx("textarea",{value:c,onChange:n=>C(n.target.value),onKeyDown:q,onFocus:()=>M(!0),onBlur:()=>M(!1),placeholder:"Add a comment...",style:{width:"100%",minHeight:"38px",maxHeight:"120px",padding:"8px 12px",fontSize:"var(--text-md, 13px)",color:"var(--text-base, rgba(30,33,37,0.78))",background:"white",border:`1px solid ${L?"rgba(94, 136, 176, 0.35)":"rgba(52, 58, 64, 0.16)"}`,borderRadius:"var(--radius-md, 8px)",resize:"vertical",outline:"none",transition:"border-color 0.15s ease",fontFamily:"inherit",lineHeight:1.5}}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{style:{display:"flex",gap:"4px"},children:[e.jsx("button",{type:"button",style:{padding:"6px",background:"transparent",border:"none",borderRadius:"6px",color:"rgba(30, 33, 37, 0.52)",cursor:"pointer",display:"flex",alignItems:"center",transition:"all 0.15s ease"},onMouseEnter:n=>{n.currentTarget.style.background="rgba(30, 33, 37, 0.06)",n.currentTarget.style.color="rgba(30, 33, 37, 0.75)"},onMouseLeave:n=>{n.currentTarget.style.background="transparent",n.currentTarget.style.color="rgba(30, 33, 37, 0.52)"},title:"Mention user",children:e.jsx(y.AtSign,{size:16})}),e.jsx("button",{type:"button",style:{padding:"6px",background:"transparent",border:"none",borderRadius:"6px",color:"rgba(30, 33, 37, 0.52)",cursor:"pointer",display:"flex",alignItems:"center",transition:"all 0.15s ease"},onMouseEnter:n=>{n.currentTarget.style.background="rgba(30, 33, 37, 0.06)",n.currentTarget.style.color="rgba(30, 33, 37, 0.75)"},onMouseLeave:n=>{n.currentTarget.style.background="transparent",n.currentTarget.style.color="rgba(30, 33, 37, 0.52)"},title:"Reference condition",children:e.jsx(y.Hash,{size:16})}),e.jsx("button",{type:"button",style:{padding:"6px",background:"transparent",border:"none",borderRadius:"6px",color:"rgba(30, 33, 37, 0.52)",cursor:"pointer",display:"flex",alignItems:"center",transition:"all 0.15s ease"},onMouseEnter:n=>{n.currentTarget.style.background="rgba(30, 33, 37, 0.06)",n.currentTarget.style.color="rgba(30, 33, 37, 0.75)"},onMouseLeave:n=>{n.currentTarget.style.background="transparent",n.currentTarget.style.color="rgba(30, 33, 37, 0.52)"},title:"Attach file",children:e.jsx(y.Paperclip,{size:16})})]}),e.jsx("button",{type:"button",onClick:F,disabled:!c.trim()||z,style:{padding:"6px 12px",background:c.trim()&&!z?"rgba(94, 136, 176, 0.85)":"var(--border-subtle, rgba(52,58,64,0.08))",border:"none",borderRadius:"6px",color:c.trim()&&!z?"white":"var(--text-faint, rgba(30,33,37,0.36))",fontSize:"var(--text-sm, 11px)",fontWeight:600,cursor:c.trim()&&!z?"pointer":"not-allowed",display:"flex",alignItems:"center",gap:"6px",transition:"all 0.15s ease"},onMouseEnter:n=>{c.trim()&&!z&&(n.currentTarget.style.background="rgba(94, 136, 176, 1)")},onMouseLeave:n=>{c.trim()&&!z&&(n.currentTarget.style.background="rgba(94, 136, 176, 0.85)")},children:z?e.jsxs(e.Fragment,{children:[e.jsx("style",{children:`
7
+ `}),e.jsx("div",{style:{width:"14px",height:"14px",border:"2px solid rgba(255, 255, 255, 0.3)",borderTopColor:"white",borderRadius:"50%",animation:"buttonSpin 0.6s linear infinite"}}),"Sending..."]}):e.jsxs(e.Fragment,{children:[e.jsx(y.Send,{size:16}),"Send"]})})]}),e.jsx("div",{style:{fontSize:"var(--text-sm, 11px)",color:"var(--text-faint, rgba(30,33,37,0.36))",marginTop:"8px"},children:"Press Enter to send, Shift+Enter for new line"})]})]})}const o={title:"#2e3236",muted:"#808183",faint:"#989898",hoverBg:"#f3f7f7",selectedBg:"#FAF5E9",border:"#d9d9d9",borderSubtle:"#e6e6e6",pillDarkBg:"#272727",pillDarkText:"#f2f2f0",searchTrack:"#d8d8d8"};function ye(h){const f=h?new Date(h):null;if(!f||Number.isNaN(f.getTime()))return"Older";const j=new Date,k=new Date(j.getFullYear(),j.getMonth(),j.getDate()),d=new Date(k);return d.setDate(k.getDate()-1),f>=k?"Today":f>=d?"Yesterday":"Older"}const he=["Today","Yesterday","Older"];function me(h){const f=h?new Date(h):null;if(!f||Number.isNaN(f.getTime()))return"";const j=Date.now()-f.getTime(),k=Math.floor(j/6e4);if(k<1)return"just now";if(k<60)return`${k}m ago`;const d=Math.floor(k/60);if(d<24)return`${d}h ago`;const L=Math.floor(d/24);return L<7?`${L}d ago`:f.toLocaleDateString(void 0,{month:"short",day:"numeric"})}function ve({threads:h=[],activeThreadId:f,onSelectThread:j,onNewChat:k,onCollapse:d,onRenameThread:L,onDeleteThread:H,onPinThread:C,loading:P=!1,pageSize:g=10,page:ee,pageCount:q,onPageChange:E,onFilterChange:m}){const c=typeof E=="function",[b,W]=s.useState(""),[z,K]=s.useState("all"),O=i=>{K(i),m==null||m(i)},[n,v]=s.useState(1),[F,x]=s.useState(null),[I,_]=s.useState(null),[X,A]=s.useState(""),[N,$]=s.useState(null),[te,U]=s.useState(null),G=s.useRef(null);s.useEffect(()=>{I&&G.current&&(G.current.focus(),G.current.select())},[I]),s.useEffect(()=>{if(!te)return;const i=()=>U(null),r=D=>{D.key==="Escape"&&U(null)};return document.addEventListener("click",i),document.addEventListener("keydown",r),()=>{document.removeEventListener("click",i),document.removeEventListener("keydown",r)}},[te]);const re=typeof L=="function",se=typeof H=="function",Z=typeof C=="function",{groups:oe,totalPages:R}=s.useMemo(()=>{const i=b.trim().toLowerCase(),D=[...h.filter(u=>z==="pinned"&&!u.pinned?!1:i?(u.title||"").toLowerCase().includes(i)||(u.last_message_preview||"").toLowerCase().includes(i):!0)].sort((u,M)=>{if(u.pinned&&!M.pinned)return-1;if(!u.pinned&&M.pinned)return 1;const le=new Date(u.updated_at||u.created_at||0).getTime();return new Date(M.updated_at||M.created_at||0).getTime()-le}),J=c?Math.max(1,q||1):Math.max(1,Math.ceil(D.length/g));let w;if(c)w=D;else{const M=(Math.min(n,J)-1)*g;w=D.slice(M,M+g)}const B={};for(const u of w){const M=ye(u.updated_at||u.created_at);(B[M]||(B[M]=[])).push(u)}return{groups:he.map(u=>({label:u,items:B[u]||[]})).filter(u=>u.items.length>0),totalPages:J}},[h,b,z,n,g,c,q]),a=oe.reduce((i,r)=>i+r.items.length,0),l=c?Math.max(1,ee||1):n,T=c?E:v;s.useEffect(()=>{c||v(1)},[b,z,c]),s.useEffect(()=>{c||v(i=>Math.min(i,R))},[R,c]);const p=s.useMemo(()=>{if(R<=5)return Array.from({length:R},(J,w)=>w+1);let r=Math.max(1,l-2);const D=Math.min(R,r+5-1);return r=Math.max(1,D-5+1),Array.from({length:D-r+1},(J,w)=>r+w)},[R,l]),S=(i,r)=>{i.stopPropagation(),U(null),$(null),_(r.id),A(r.title||r.name||"")},Y=i=>{i&&i.stopPropagation();const r=(X||"").trim();I&&r&&(L==null||L(I,r)),_(null),A("")},V=i=>{i&&i.stopPropagation(),_(null),A("")},ae=(i,r)=>{i.stopPropagation(),U(null),_(null),$(r.id)},ne=i=>{i&&i.stopPropagation(),N&&(H==null||H(N)),$(null)},pe=i=>{i&&i.stopPropagation(),$(null)},ue=(i,r)=>{i.stopPropagation(),C==null||C(r.id,!r.pinned)},ie={display:"inline-flex",alignItems:"center",justifyContent:"center",width:"24px",height:"24px",padding:0,background:"transparent",border:"none",borderRadius:"6px",cursor:"pointer",color:o.muted,transition:"all 0.12s ease",flexShrink:0};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",background:"#FFFFFF",overflow:"hidden"},children:[e.jsxs("div",{style:{padding:"16px 16px 0 16px",flexShrink:0},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",height:"32px"},children:[e.jsx("div",{style:{fontSize:"14px",fontWeight:400,color:o.title},children:"Threads"}),d&&e.jsx("button",{type:"button",title:"Collapse",onClick:d,style:{...ie,width:"20px",height:"20px",color:o.muted},onMouseEnter:i=>i.currentTarget.style.background=o.hoverBg,onMouseLeave:i=>i.currentTarget.style.background="transparent",children:e.jsx(y.PanelLeftClose,{size:20,strokeWidth:1.5})})]}),e.jsx("div",{style:{display:"flex",alignItems:"center",height:"32px",background:o.searchTrack,borderRadius:"11px",padding:"1px",marginTop:"12px"},children:e.jsxs("div",{style:{display:"flex",flex:1,alignItems:"center",gap:"8px",height:"30px",background:"#FFFFFF",borderRadius:"10px",padding:"4px 8px"},children:[e.jsx(y.Search,{size:18,style:{color:o.faint,flexShrink:0}}),e.jsx("input",{type:"text",value:b,onChange:i=>W(i.target.value),placeholder:"Search",style:{flex:1,minWidth:0,border:"none",outline:"none",background:"transparent",fontSize:"14px",fontWeight:500,color:o.title}})]})}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"16px",marginTop:"12px"},children:[e.jsx("button",{type:"button",onClick:()=>O("all"),style:{display:"inline-flex",alignItems:"center",justifyContent:"center",height:"28px",padding:"0 12px",borderRadius:"8px",border:"none",cursor:"pointer",fontSize:"14px",fontWeight:400,lineHeight:"24px",transition:"all 0.12s ease",background:z==="all"?o.pillDarkBg:o.hoverBg,color:z==="all"?o.pillDarkText:o.title},children:"All"}),e.jsxs("button",{type:"button",onClick:()=>O("pinned"),style:{display:"inline-flex",alignItems:"center",justifyContent:"center",gap:"8px",height:"28px",padding:"0 16px",borderRadius:"10px",border:"none",cursor:"pointer",fontSize:"14px",fontWeight:400,lineHeight:"24px",transition:"all 0.12s ease",background:z==="pinned"?o.pillDarkBg:o.hoverBg,color:z==="pinned"?o.pillDarkText:o.title},children:[e.jsx(y.Pin,{size:16,style:{flexShrink:0}}),"Pinned"]})]})]}),e.jsx("div",{style:{flex:1,overflowY:"auto",padding:"16px 16px 8px 16px"},children:P?e.jsx("div",{style:{padding:"30px 16px",textAlign:"center",color:o.faint,fontSize:"13px"},children:"Loading threads..."}):a===0?e.jsx("div",{style:{padding:"30px 16px",textAlign:"center",color:o.faint,fontSize:"13px"},children:b?"No threads found":z==="pinned"?"No pinned threads":"No threads yet"}):oe.map(i=>e.jsxs("div",{style:{marginBottom:"8px"},children:[e.jsx("div",{style:{fontSize:"13px",fontWeight:500,color:o.title,padding:"8px 0 4px 0"},children:i.label}),i.items.map(r=>{const D=r.id===f,J=F===r.id,w=I===r.id,B=N===r.id,Q=te===r.id,u=re||se,M=(Z||u)&&(J||D||Q)&&!w&&!B,le=Q||B||w,ce=D?o.selectedBg:J||le?o.hoverBg:"transparent",xe=D||J||le?`1px solid ${o.border}`:"1px solid transparent";return e.jsxs("div",{onClick:()=>{w||B||j==null||j(r.id)},onMouseEnter:()=>x(r.id),onMouseLeave:()=>x(t=>t===r.id?null:t),style:{display:"flex",alignItems:"center",gap:"4px",padding:"8px 4px",marginBottom:"2px",borderRadius:"8px",background:ce,border:xe,cursor:w||B?"default":"pointer",transition:"background 0.12s ease, border-color 0.12s ease",boxSizing:"border-box",position:"relative"},children:[e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",width:"40px",height:"40px",flexShrink:0,color:o.muted},children:e.jsx(y.MessageSquare,{size:20})}),w?e.jsx("input",{ref:G,type:"text",value:X,onChange:t=>A(t.target.value),onClick:t=>t.stopPropagation(),onKeyDown:t=>{t.stopPropagation(),t.key==="Enter"?Y(t):t.key==="Escape"&&V(t)},style:{flex:1,minWidth:0,fontSize:"14px",fontWeight:600,color:o.title,background:"#fff",border:`1px solid ${o.border}`,borderRadius:"6px",padding:"4px 8px",outline:"none",boxSizing:"border-box"}}):e.jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:"4px",textAlign:"left"},children:[e.jsx("div",{title:r.title||r.name||"Untitled thread",style:{display:"block",minWidth:0,maxWidth:"100%",fontSize:"14px",fontWeight:D?550:500,color:o.title,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",lineHeight:1.2},children:r.title||r.name||"Untitled thread"}),B?e.jsxs("div",{style:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"12px",fontWeight:500,color:o.title},children:"Confirm: delete this thread?"}),e.jsx("button",{type:"button",onClick:ne,style:{padding:"3px 12px",fontSize:"12px",fontWeight:600,color:o.title,background:"#ECEEF2",border:`1px solid ${o.borderSubtle}`,borderRadius:"6px",cursor:"pointer"},onMouseEnter:t=>t.currentTarget.style.background="#E2E5EA",onMouseLeave:t=>t.currentTarget.style.background="#ECEEF2",children:"Yes"}),e.jsx("button",{type:"button",onClick:pe,style:{padding:"3px 6px",fontSize:"12px",fontWeight:500,color:o.muted,background:"transparent",border:"none",cursor:"pointer"},onMouseEnter:t=>t.currentTarget.style.color=o.title,onMouseLeave:t=>t.currentTarget.style.color=o.muted,children:"No"})]}):e.jsxs("div",{style:{fontSize:"12px",color:o.muted,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",lineHeight:1.5},children:[r.message_count!=null&&e.jsxs(e.Fragment,{children:[r.message_count," msg",r.message_count!==1?"s":""," · "]}),me(r.updated_at||r.created_at)]})]}),w&&e.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:"2px",flexShrink:0},children:[e.jsx("button",{type:"button",title:"Save",onClick:Y,style:{...ie,color:"#1f9d57"},onMouseEnter:t=>t.currentTarget.style.background="rgba(31,157,87,0.12)",onMouseLeave:t=>t.currentTarget.style.background="transparent",children:e.jsx(y.Check,{size:15})}),e.jsx("button",{type:"button",title:"Cancel",onClick:V,style:ie,onMouseEnter:t=>t.currentTarget.style.background="rgba(0,0,0,0.06)",onMouseLeave:t=>t.currentTarget.style.background="transparent",children:e.jsx(y.X,{size:15})})]}),!w&&!B&&!M&&r.pinned&&e.jsx(y.Pin,{size:14,style:{color:o.title,flexShrink:0},fill:"currentColor"}),M&&e.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:"2px",flexShrink:0},children:[Z&&e.jsx("button",{type:"button",title:r.pinned?"Unpin":"Pin",onClick:t=>ue(t,r),style:{...ie,color:r.pinned?o.title:o.muted},onMouseEnter:t=>{t.currentTarget.style.background="rgba(0,0,0,0.06)",t.currentTarget.style.color=o.title},onMouseLeave:t=>{t.currentTarget.style.background="transparent",t.currentTarget.style.color=r.pinned?o.title:o.muted},children:e.jsx(y.Pin,{size:14,fill:r.pinned?"currentColor":"none"})}),u&&e.jsx("button",{type:"button",title:"More",onClick:t=>{t.stopPropagation(),U(ge=>ge===r.id?null:r.id)},style:{...ie,color:Q?o.title:o.muted,background:Q?"rgba(0,0,0,0.06)":"transparent"},onMouseEnter:t=>{t.currentTarget.style.background="rgba(0,0,0,0.06)",t.currentTarget.style.color=o.title},onMouseLeave:t=>{t.currentTarget.style.background=Q?"rgba(0,0,0,0.06)":"transparent",t.currentTarget.style.color=Q?o.title:o.muted},children:e.jsx(y.MoreVertical,{size:14})})]}),Q&&u&&e.jsxs("div",{onClick:t=>t.stopPropagation(),style:{position:"absolute",top:"calc(100% - 2px)",right:"8px",zIndex:20,width:"144px",background:"#FFFFFF",border:`1px solid ${o.border}`,borderRadius:"4px",boxShadow:"-2px 2px 4px rgba(0,0,0,0.1)",overflow:"hidden"},children:[re&&e.jsx("button",{type:"button",onClick:t=>S(t,r),style:{display:"block",width:"100%",textAlign:"left",padding:"12px",fontSize:"13px",color:o.title,background:"transparent",border:"none",cursor:"pointer"},onMouseEnter:t=>t.currentTarget.style.background=o.hoverBg,onMouseLeave:t=>t.currentTarget.style.background="transparent",children:"Rename"}),se&&e.jsx("button",{type:"button",onClick:t=>ae(t,r),style:{display:"block",width:"100%",textAlign:"left",padding:"12px",fontSize:"13px",color:o.title,background:"transparent",border:"none",borderTop:re?`1px solid ${o.border}`:"none",cursor:"pointer"},onMouseEnter:t=>t.currentTarget.style.background=o.hoverBg,onMouseLeave:t=>t.currentTarget.style.background="transparent",children:"Delete"})]})]},r.id)})]},i.label))}),!P&&R>1&&e.jsxs("div",{style:{flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",gap:"6px",height:"64px",padding:"0 16px",boxSizing:"border-box",borderTop:`1px solid ${o.border}`},children:[e.jsxs("button",{type:"button",disabled:l<=1,onClick:()=>T(Math.max(1,l-1)),style:{display:"inline-flex",alignItems:"center",justifyContent:"center",gap:"4px",height:"24px",padding:"4px 8px",borderRadius:"10px",background:"#FFFFFF",border:`1px solid ${o.borderSubtle}`,fontSize:"12px",lineHeight:"16px",color:"#0b0b0b",cursor:l<=1?"default":"pointer",opacity:l<=1?.5:1},children:[e.jsx(y.ChevronLeft,{size:12}),"Back"]}),p.map(i=>{const r=i===l;return e.jsx("button",{type:"button",onClick:()=>T(i),style:{display:"inline-flex",alignItems:"center",justifyContent:"center",height:"24px",minWidth:"22px",padding:"4px 8px",borderRadius:"10px",fontSize:"12px",lineHeight:"16px",cursor:"pointer",background:r?"#0b0b0b":"#FFFFFF",color:r?"#FFFFFF":"#0b0b0b",border:r?"1px solid #0b0b0b":`1px solid ${o.borderSubtle}`,fontWeight:r?600:400},children:i},i)}),e.jsxs("button",{type:"button",disabled:l>=R,onClick:()=>T(Math.min(R,l+1)),style:{display:"inline-flex",alignItems:"center",justifyContent:"center",gap:"4px",height:"24px",padding:"4px 8px",borderRadius:"10px",background:"#FFFFFF",border:`1px solid ${o.borderSubtle}`,fontSize:"12px",lineHeight:"16px",color:"#0b0b0b",cursor:l>=R?"default":"pointer",opacity:l>=R?.5:1},children:["Next",e.jsx(y.ChevronRight,{size:12})]})]})]})}const je={error:(...h)=>console.warn("toast.error:",...h)},ke=()=>({userData:{name:"User",email:""}});function Se({sessionTitle:h,messages:f,onSendMessage:j,currentUser:k}){var O;const[d,L]=s.useState(""),[H,C]=s.useState(!1),[P,g]=s.useState(f||[]),[ee,q]=s.useState(!1),[E,m]=s.useState(!1),{userData:c}=ke(),b=s.useRef(null),W=k||{name:(c==null?void 0:c.name)||"You",initials:((O=c==null?void 0:c.name)==null?void 0:O.split(" ").map(n=>n[0]).join("").toUpperCase())||"YO",color:"#6B7C93"};s.useEffect(()=>{g(f||[])},[f]),s.useEffect(()=>{b.current&&b.current.scrollIntoView({behavior:"smooth"})},[P]);const z=async()=>{if(!d.trim())return;const n=d.trim();L(""),m(!0);const v={id:`temp-${Date.now()}`,author:{name:W.name,role:(c==null?void 0:c.role)||"",initials:W.initials,color:W.color},content:n,timestamp:"Just now",type:"comment",isOptimistic:!0};if(g(F=>[...F,v]),j){try{await j(n),g(F=>F.map(x=>x.id===v.id?{...x,isOptimistic:!1}:x))}catch{g(x=>x.filter(I=>I.id!==v.id)),je.error("Failed to send message")}finally{m(!1)}return}setTimeout(()=>{g(F=>F.map(x=>x.id===v.id?{...x,isOptimistic:!1}:x)),m(!1)},500)},K=n=>{n.key==="Enter"&&!n.shiftKey&&(n.preventDefault(),z())};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",background:"var(--paper-elevated, rgba(255,255,255,0.82))",border:"1px solid var(--border, rgba(52,58,64,0.12))",borderRadius:"var(--radius-lg, 12px)",overflow:"hidden"},children:[h&&e.jsxs("div",{style:{padding:"14px 16px",borderBottom:"1px solid var(--border, rgba(52,58,64,0.12))",background:"var(--paper-elevated, rgba(255,255,255,0.82))"},children:[e.jsx("div",{style:{fontSize:"var(--text-md, 13px)",fontWeight:680,color:"var(--text-strong, rgba(30,33,37,0.92))",marginBottom:"3px"},children:"Session Discussion"}),h&&e.jsx("div",{style:{fontSize:"var(--text-sm, 11px)",color:"var(--text-muted, rgba(30,33,37,0.56))",display:"flex",alignItems:"center",gap:"8px"},children:e.jsx("span",{children:h})})]}),e.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"16px",display:"flex",flexDirection:"column",gap:"16px"},children:[ee?e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"40px",color:"var(--text-faint, rgba(30,33,37,0.36))"},children:"Loading messages..."}):P.length===0?e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"40px",color:"var(--text-faint, rgba(30,33,37,0.36))"},children:"No messages yet. Start the conversation!"}):P.map(n=>e.jsxs("div",{style:{display:"flex",gap:"12px",opacity:n.type==="system"?.75:1},children:[n.type!=="system"&&e.jsx("div",{style:{width:"32px",height:"32px",borderRadius:"8px",background:n.author.color,color:"white",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"11px",fontWeight:650,flexShrink:0,opacity:.9},children:n.author.initials}),n.type==="system"&&e.jsx("div",{style:{width:"32px",height:"32px",borderRadius:"8px",background:"rgba(30, 33, 37, 0.08)",color:"rgba(30, 33, 37, 0.52)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"11px",fontWeight:650,flexShrink:0},children:e.jsx(y.Clock,{size:14})}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",marginBottom:"4px"},children:[e.jsx("span",{style:{fontSize:"var(--text-sm, 11px)",fontWeight:650,color:"var(--text-base, rgba(30,33,37,0.78))"},children:n.author.name}),e.jsx("span",{style:{fontSize:"var(--text-sm, 11px)",color:"var(--text-faint, rgba(30,33,37,0.36))",fontFamily:"var(--font-mono, monospace)"},children:n.timestamp}),n.author.role&&e.jsx("span",{style:{fontSize:"var(--text-xs, 10px)",color:"var(--text-muted, rgba(30,33,37,0.56))",background:"rgba(30, 33, 37, 0.06)",padding:"2px 6px",borderRadius:"4px",textTransform:"uppercase",letterSpacing:"0.04em",fontWeight:600},children:n.author.role}),n.isEdited&&e.jsx("span",{style:{fontSize:"var(--text-xs, 10px)",color:"var(--text-faint, rgba(30,33,37,0.36))",fontStyle:"italic"},children:"(edited)"})]}),e.jsx("div",{style:{fontSize:"var(--text-md, 13px)",color:"var(--text-base, rgba(30,33,37,0.78))",lineHeight:1.5,marginBottom:n.references?"8px":0},children:n.content}),n.references&&n.references.length>0&&e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px",marginTop:"8px"},children:n.references.map((v,F)=>e.jsxs("button",{type:"button",style:{fontSize:"11px",padding:"4px 8px",borderRadius:"6px",border:"1px solid rgba(52, 58, 64, 0.16)",background:"rgba(255, 255, 255, 0.7)",color:v.type==="condition"?"rgba(94, 136, 176, 0.85)":v.type==="observation"?"rgba(107, 123, 147, 0.85)":v.type==="timestamp"?"rgba(184, 156, 106, 0.85)":"rgba(30, 33, 37, 0.65)",cursor:"pointer",display:"inline-flex",alignItems:"center",gap:"4px",transition:"all 0.15s ease",fontWeight:550},onMouseEnter:x=>{x.currentTarget.style.background="rgba(255, 255, 255, 0.95)",x.currentTarget.style.borderColor="rgba(52, 58, 64, 0.24)"},onMouseLeave:x=>{x.currentTarget.style.background="rgba(255, 255, 255, 0.7)",x.currentTarget.style.borderColor="rgba(52, 58, 64, 0.16)"},children:[v.type==="timestamp"&&e.jsx(y.Clock,{size:12}),(v.type==="condition"||v.type==="observation")&&e.jsx(y.Hash,{size:12}),v.label]},F))})]})]},n.id)),e.jsx("div",{ref:b})]}),e.jsxs("div",{style:{padding:"12px",borderTop:"1px solid var(--border, rgba(52,58,64,0.12))",background:"var(--paper-elevated, rgba(255,255,255,0.82))"},children:[e.jsxs("div",{style:{display:"flex",gap:"8px",alignItems:"flex-end"},children:[e.jsx("div",{style:{width:"32px",height:"32px",borderRadius:"var(--radius-md, 8px)",background:W.color,color:"white",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"var(--text-sm, 11px)",fontWeight:650,flexShrink:0,opacity:.9},children:W.initials}),e.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:"8px"},children:[e.jsx("textarea",{value:d,onChange:n=>L(n.target.value),onKeyDown:K,onFocus:()=>C(!0),onBlur:()=>C(!1),placeholder:"Add a comment...",style:{width:"100%",minHeight:"38px",maxHeight:"120px",padding:"8px 12px",fontSize:"var(--text-md, 13px)",color:"var(--text-base, rgba(30,33,37,0.78))",background:"white",border:`1px solid ${H?"rgba(94, 136, 176, 0.35)":"rgba(52, 58, 64, 0.16)"}`,borderRadius:"var(--radius-md, 8px)",resize:"vertical",outline:"none",transition:"border-color 0.15s ease",fontFamily:"inherit",lineHeight:1.5}}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{style:{display:"flex",gap:"4px"},children:[e.jsx("button",{type:"button",style:{padding:"6px",background:"transparent",border:"none",borderRadius:"6px",color:"rgba(30, 33, 37, 0.52)",cursor:"pointer",display:"flex",alignItems:"center",transition:"all 0.15s ease"},onMouseEnter:n=>{n.currentTarget.style.background="rgba(30, 33, 37, 0.06)",n.currentTarget.style.color="rgba(30, 33, 37, 0.75)"},onMouseLeave:n=>{n.currentTarget.style.background="transparent",n.currentTarget.style.color="rgba(30, 33, 37, 0.52)"},title:"Mention user",children:e.jsx(y.AtSign,{size:16})}),e.jsx("button",{type:"button",style:{padding:"6px",background:"transparent",border:"none",borderRadius:"6px",color:"rgba(30, 33, 37, 0.52)",cursor:"pointer",display:"flex",alignItems:"center",transition:"all 0.15s ease"},onMouseEnter:n=>{n.currentTarget.style.background="rgba(30, 33, 37, 0.06)",n.currentTarget.style.color="rgba(30, 33, 37, 0.75)"},onMouseLeave:n=>{n.currentTarget.style.background="transparent",n.currentTarget.style.color="rgba(30, 33, 37, 0.52)"},title:"Reference condition",children:e.jsx(y.Hash,{size:16})}),e.jsx("button",{type:"button",style:{padding:"6px",background:"transparent",border:"none",borderRadius:"6px",color:"rgba(30, 33, 37, 0.52)",cursor:"pointer",display:"flex",alignItems:"center",transition:"all 0.15s ease"},onMouseEnter:n=>{n.currentTarget.style.background="rgba(30, 33, 37, 0.06)",n.currentTarget.style.color="rgba(30, 33, 37, 0.75)"},onMouseLeave:n=>{n.currentTarget.style.background="transparent",n.currentTarget.style.color="rgba(30, 33, 37, 0.52)"},title:"Attach file",children:e.jsx(y.Paperclip,{size:16})})]}),e.jsx("button",{type:"button",onClick:z,disabled:!d.trim()||E,style:{padding:"6px 12px",background:d.trim()&&!E?"rgba(94, 136, 176, 0.85)":"var(--border-subtle, rgba(52,58,64,0.08))",border:"none",borderRadius:"6px",color:d.trim()&&!E?"white":"var(--text-faint, rgba(30,33,37,0.36))",fontSize:"var(--text-sm, 11px)",fontWeight:600,cursor:d.trim()&&!E?"pointer":"not-allowed",display:"flex",alignItems:"center",gap:"6px",transition:"all 0.15s ease"},onMouseEnter:n=>{d.trim()&&!E&&(n.currentTarget.style.background="rgba(94, 136, 176, 1)")},onMouseLeave:n=>{d.trim()&&!E&&(n.currentTarget.style.background="rgba(94, 136, 176, 0.85)")},children:E?e.jsxs(e.Fragment,{children:[e.jsx("style",{children:`
10
8
  @keyframes messageSpin {
11
9
  from { transform: rotate(0deg); }
12
10
  to { transform: rotate(360deg); }
13
11
  }
14
- `}),e.jsx("div",{style:{width:"14px",height:"14px",border:"2px solid rgba(255, 255, 255, 0.3)",borderTopColor:"white",borderRadius:"50%",animation:"messageSpin 0.6s linear infinite"}}),"Sending..."]}):e.jsxs(e.Fragment,{children:[e.jsx(y.Send,{size:14}),"Send"]})})]})]})]}),e.jsxs("div",{style:{marginTop:"8px",fontSize:"var(--text-sm, 11px)",color:"var(--text-faint, rgba(30,33,37,0.36))",lineHeight:1.4},children:[e.jsx("strong",{children:"Tip:"})," Use"," ",e.jsx("code",{style:{background:"rgba(30, 33, 37, 0.06)",padding:"2px 4px",borderRadius:"3px",fontFamily:"var(--font-mono, monospace)",fontSize:"var(--text-xs, 10px)"},children:"@"})," ","to mention teammates,"," ",e.jsx("code",{style:{background:"rgba(30, 33, 37, 0.06)",padding:"2px 4px",borderRadius:"3px",fontFamily:"var(--font-mono, monospace)",fontSize:"var(--text-xs, 10px)"},children:"#"})," ","to reference conditions"]})]})]})}exports.ChatHistoryPanel=Ce;exports.ChatInterface=ke;exports.MessageThread=Ee;exports.ThinkingIndicator=ue;
12
+ `}),e.jsx("div",{style:{width:"14px",height:"14px",border:"2px solid rgba(255, 255, 255, 0.3)",borderTopColor:"white",borderRadius:"50%",animation:"messageSpin 0.6s linear infinite"}}),"Sending..."]}):e.jsxs(e.Fragment,{children:[e.jsx(y.Send,{size:14}),"Send"]})})]})]})]}),e.jsxs("div",{style:{marginTop:"8px",fontSize:"var(--text-sm, 11px)",color:"var(--text-faint, rgba(30,33,37,0.36))",lineHeight:1.4},children:[e.jsx("strong",{children:"Tip:"})," Use"," ",e.jsx("code",{style:{background:"rgba(30, 33, 37, 0.06)",padding:"2px 4px",borderRadius:"3px",fontFamily:"var(--font-mono, monospace)",fontSize:"var(--text-xs, 10px)"},children:"@"})," ","to mention teammates,"," ",e.jsx("code",{style:{background:"rgba(30, 33, 37, 0.06)",padding:"2px 4px",borderRadius:"3px",fontFamily:"var(--font-mono, monospace)",fontSize:"var(--text-xs, 10px)"},children:"#"})," ","to reference conditions"]})]})]})}exports.ChatHistoryPanel=ve;exports.ChatInterface=be;exports.MessageThread=Se;
15
13
  //# sourceMappingURL=MessageThread.cjs.js.map