import{Or as e,Tr as t,t as n}from"./jsx-runtime-NwRKtVrk.js";import{t as r}from"./request-Blbag3Ot.js";import{r as i}from"./statusUtils-G17j4Ng-.js";import{t as a}from"./table-By97ouEx.js";import{t as o}from"./button-CM-rzMOH.js";import{jt as s}from"./es-Do50EHua.js";import{t as c}from"./tag-C0Yg14A-.js";import{D as l,E as u,h as d,s as f}from"./index-B7MUL4ct.js";import{t as p}from"./XinTable-Cyzgse09.js";async function m(e,t){return r({url:`/ai/conversation/${e}/messages`,method:`get`,params:t})}var h=e(l(),1),g=e(t(),1),_=n(),{Title:v,Text:y}=d;function b(){let{t:e}=f(),[t,n]=(0,g.useState)(!1),[r,l]=(0,g.useState)(``),[d,b]=(0,g.useState)([]),[x,S]=(0,g.useState)(!1),[C,w]=(0,g.useState)(0),[T,E]=(0,g.useState)(1),[D,O]=(0,g.useState)(``),k=async(e,t)=>{S(!0);try{let n=(await m(e,{page:t,pageSize:20})).data.data;b(n.data),w(n.total)}finally{S(!1)}},A=async e=>{O(e.id),l(e.title||``),E(1),n(!0),await k(e.id,1)},j=e=>{E(e),k(D,e)},M=[{title:e(`ai.conversation.id`),dataIndex:`id`,hideInForm:!0,width:260,ellipsis:!0,align:`center`},{title:e(`ai.conversation.username`),dataIndex:`username`,hideInForm:!0,align:`center`,width:120,render:t=>t||e(`ai.conversation.noUser`)},{title:e(`ai.conversation.title`),dataIndex:`title`,valueType:`text`,ellipsis:!0},{title:e(`ai.conversation.messageCount`),dataIndex:`message_count`,hideInForm:!0,hideInSearch:!0,align:`center`,width:100},{title:e(`ai.conversation.createdAt`),dataIndex:`created_at`,hideInForm:!0,hideInSearch:!0,align:`center`,width:180,render:e=>e?(0,h.default)(e).format(`YYYY-MM-DD HH:mm:ss`):`-`},{title:e(`ai.conversation.updatedAt`),dataIndex:`updated_at`,hideInForm:!0,hideInSearch:!0,align:`center`,width:180,render:e=>e?(0,h.default)(e).format(`YYYY-MM-DD HH:mm:ss`):`-`}],N=[{title:e(`ai.conversation.message.role`),dataIndex:`role`,width:100,render:t=>(0,_.jsx)(c,{color:{user:`blue`,assistant:`green`,system:`orange`}[t]||`default`,children:e(`ai.conversation.message.role.${t}`,t)})},{title:e(`ai.conversation.message.agent`),dataIndex:`agent`,width:150,ellipsis:!0},{title:e(`ai.conversation.message.content`),dataIndex:`content`,ellipsis:!0},{title:e(`ai.conversation.message.createdAt`),dataIndex:`created_at`,width:180,render:e=>e?(0,h.default)(e).format(`YYYY-MM-DD HH:mm:ss`):`-`}];return(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(`div`,{className:`mb-5`,children:[(0,_.jsx)(v,{level:3,children:e(`ai.conversation.page.title`)}),(0,_.jsx)(y,{type:`secondary`,children:e(`ai.conversation.page.description`)})]}),(0,_.jsx)(p,{api:`/ai/conversation`,columns:M,rowKey:`id`,accessName:`ai.conversation`,addShow:!1,editShow:!1,formProps:!1,operateProps:{fixed:`right`,width:120},operateRender:(t,n)=>[(0,_.jsx)(i,{title:e(`ai.conversation.viewMessages`),children:(0,_.jsx)(o,{type:`primary`,icon:(0,_.jsx)(s,{}),size:`small`,onClick:()=>A(t)})},`view`),n.del],scroll:{x:1100},cardProps:{variant:`borderless`}}),(0,_.jsx)(u,{title:`${e(`ai.conversation.messageTitle`)} - ${r}`,open:t,onClose:()=>n(!1),width:900,children:(0,_.jsx)(a,{dataSource:d,columns:N,rowKey:`id`,loading:x,pagination:{current:T,total:C,pageSize:20,onChange:j,showSizeChanger:!1},scroll:{x:700},size:`small`})})]})}export{b as default};