1import{r as n,C as z,y as A,bp as D,p as r,w as x,a6 as k,T as E,v as G,B as v,L as N,ak as Q}from"./index-C9IH3k-2.js";import{aa as W,aM as Z,T as J,g as P}from"./TemplateUtil-D1DzmWLm.js";import{g as X,a as Y}from"./AuditConstant-C6syQHOu.js";import{P as tt}from"./PageDescription-BrOUsEZE.js";import{F as et}from"./Table-isZ0WXp4.js";import"./Wrapper-ChjuDa3w.js";import"./HelperMethods-C-ewwU_x.js";import"./index-CmSVNJzc.js";import"./index-Bv3SRNsl.js";import"./CalendarOutlined-DyzsKNdO.js";import"./ClockCircleOutlined-Cym7vptW.js";import"./index-BOwvFOZJ.js";import"./Pagination-D1z-xPUv.js";import"./HolderOutlined-YOHjCGKZ.js";const ft=()=>{const[c,l]=n.useState([]),[F,L]=n.useState({}),[f,T]=n.useState(!1),[B,d]=n.useState(!0),[u,O]=n.useState({}),[b,V]=n.useState([{fieldName:"id",dir:"desc"}]),$=n.useRef(null),j=z(),_=(e=u)=>{const t=new URLSearchParams;return Object.entries(e).forEach(([o,a])=>{a&&a.length>0&&(o==="status"?t.set("status",a.join(",")):o==="customerId"?t.set("phoneNumber",a.join(",")):o==="creationTime"&&(t.set("dateFrom",a[0]),t.set("dateTo",a[1])))}),t.toString()},S=n.useCallback((e=u)=>{const t=[];return Object.entries(e).forEach(([o,a])=>{a&&a.length>0&&t.push({fieldName:o,value:o==="creationTime"?a.map(W):a})}),t},[u]),I=n.useCallback(async e=>{try{if(!e||e.length===0)return{};const o={ids:[...new Set(e)]},a=await A("/api/v1/chatbot/list/byIds",o);if(a&&a.data){const i={};return a.data.forEach(s=>{i[s.id]=s.name||s.catalogName||s.id}),i}return{}}catch(t){return console.error("Error fetching chatbot names:",t),{}}},[]),g=n.useCallback(async(e=!1,t=null,o=null,a=null)=>{T(!0);try{const s=S(t||u),h=o||b,q={search:a?[...s,{fieldName:"id",value:[a],operator:"lt"}]:s,pagination:{current:1,pageSize:D},order:h},C=await A("/api/v1/chatbot/execution/list",q);if(C&&C.data){const p=C.data.results||[],H=[...new Set(p.map(m=>m.chatbotId).filter(Boolean))],K=await I(H);L(m=>({...m,...K})),p.length<D?d(!1):d(!0),l(e||!a?p:m=>[...m,...p])}else(e||!a)&&l([]),d(!1)}catch(i){console.error("Error fetching chatbot list:",i),(e||!a)&&l([]),d(!1)}finally{T(!1)}},[u,S,I]),M=(e,t,o)=>{const a={};t&&Object.entries(t).forEach(([s,h])=>{Array.isArray(h)&&h.some(y=>y!==""&&y!=null)&&(a[s]=h)});let i=b;o&&o.order&&(i=[{fieldName:o.columnKey||o.field,dir:o.order==="descend"?"desc":"asc"}
1],V(i)),O(a),l([]),d(!0),g(!0,a,i)},w=(e,t)=>{t()},R=e=>{if(f||!B||c.length===0)return;const{scrollTop:t,clientHeight:o,scrollHeight:a}=e.target;if(a-t-o>200)return;const i=c[c.length-1]?.id;i&&g(!1,null,b,i)};n.useEffect(()=>{g(!0)},[]);const U=[{title:"Execution ID",dataIndex:"id",key:"id",render:(e,t)=>r.jsx(x,{title:"View Execution Details",arrow:!0,children:r.jsx(k,{to:`/Chatbot/AdvanceChatBot/${t.chatbotId}/Executions/${e}`,children:e})})},{title:"Chatbot",dataIndex:"chatbotId",key:"chatbotId",render:(e,t)=>{const o=F[t.chatbotId]||t.chatbotName||e;return r.jsx(x,{title:"View Chatbot Details",arrow:!0,children:r.jsx(k,{to:`/Chatbot/AdvanceChatBot/${t.chatbotId}/Executions`,children:o})})}},{title:"Phone Number",dataIndex:"customerId",key:"customerId",...X("customerId","Customer ID",$,w)},{title:"Status",dataIndex:"status",key:"status",filters:Z.map(e=>({text:e.label,value:e.value})),render:e=>r.jsx(J,{color:e==="ERROR"?"red":e==="COMPLETED"?"cyan":e==="ACTIVE"?"processing":void 0,children:e})},{title:"Created At",dataIndex:"creationTime",key:"creationTime",render:(e,t)=>r.jsx(E.Text,{children:P(t.creationTime)}),...Y("creationTime","Creation Time",()=>{},()=>{},w)},{title:"Updated At",dataIndex:"lastUpdateTime",key:"lastUpdateTime",render:(e,t)=>r.jsx(E.Text,{children:P(t.lastUpdateTime)})},{title:"Actions",key:"actions",render:(e,t)=>{const o=_(),a=`/Chatbot/AdvanceChatBot/${t.chatbotId}/Executions${o?`?${o}`:""}`;return r.jsxs(G,{children:[r.jsx(x,{title:"Executions",children:r.jsx(v,{onClick:()=>j(a),children:"Executions"})}),r.jsx(x,{title:"View Execution Details",children:r.jsx(v,{onClick:()=>j(`/Chatbot/AdvanceChatBot/${t.chatbotId}/Executions/${t.id}`),children:"View Details"})})]})}}];return r.jsxs(N,{vertical:!0,gap:"large",children:[r.jsx(N,{justify:"space-between",wrap:!0,children:r.jsx(E.Title,{level:4,style:{margin:0},children:"Advance Chatbots Executions"})}),r.jsx(tt,{description:"What are Advanced Chatbots Executions?",children:"View all chatbot executions from all your chatbots in one place. Filter executions by phone number, status, or date. Click 'Executions' to see all execution logs for a chatbot, or 'View Details' to see specific execution information."}),r.jsxs("div",{style:{position:"relative",height:"calc(100vh - 200px)",overflow:"hidden",flex:1},children:[r.jsx(et,{columns:U,dataSource:c,rowKey:"id",pagination:!1,loading:f&&c.length===0,onChange:M,onScroll:R,scroll:{y:"calc(100vh - 250px)",x:"max-content"},style:{tableLayout:"fixed"}}),f&&c.length>0&&r.jsx("div",{style:{textAlign:"center",padding:"16px 0",position:"absolute",bottom:0,width:"100%",background:"rgba(255, 255, 255, 0.9)"},children:r.jsx(Q,{tip:"Loading more..."})})]})]})};export{ft as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.