module.exports=[38783,(a,b,c)=>{"use strict";b.exports=a.r(42602).vendored["react-ssr"].ReactServerDOMTurbopackClient},9014,a=>{"use strict";var b=a.i(87924),c=a.i(72131),d=a.i(81631),e=a.i(34914);function f(){let[a,f]=(0,c.useState)([]),[g,h]=(0,c.useState)(null),[i,j]=(0,c.useState)([]),[k,l]=(0,c.useState)(!0),[m,n]=(0,c.useState)(!1),[o,p]=(0,c.useState)("");(0,c.useEffect)(()=>{!async function(){try{let a=await fetch("/api/admin/chats"),b=await a.json();if(b.error)throw Error(b.error);b.sessions&&(f(b.sessions),b.sessions.length>0&&!g&&h(b.sessions[0].id))}catch(a){console.error("Error fetching sessions:",a)}finally{l(!1)}}()},[]),(0,c.useEffect)(()=>{if(!g)return;async function a(){n(!0);try{let a=await fetch("/api/admin/chats",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:g})}),b=await a.json();b.messages&&j(b.messages)}catch(a){console.error("Error fetching messages:",a)}finally{n(!1)}}a();let b=setInterval(a,5e3);return()=>clearInterval(b)},[g]);let q=a.find(a=>a.id===g),r=(0,b.jsxs)("div",{className:"Admin_dashboard__Jc4xS Admin_desktopProfile__dxwTd",children:[(0,b.jsx)("header",{className:"Admin_dashboardHeader",children:(0,b.jsx)("div",{className:"Admin_headerContent",children:(0,b.jsx)("h1",{children:"Chat Monitoring"})})}),(0,b.jsxs)("div",{className:"Admin_chatSplitView",children:[(0,b.jsxs)("div",{className:"Admin_chatListPane",children:[(0,b.jsx)("div",{className:"Admin_chatListHeader",children:(0,b.jsx)("input",{type:"text",className:"Admin_chatListSearch",placeholder:"Search user or character...",value:o,onChange:a=>p(a.target.value)})}),(0,b.jsx)("div",{className:"Admin_chatListScroll",children:k?(0,b.jsx)("div",{className:"Admin_loaderText",children:"Loading sessions..."}):a.filter(a=>a.userName.toLowerCase().includes(o.toLowerCase())||a.charName.toLowerCase().includes(o.toLowerCase())).map(a=>(0,b.jsxs)("div",{className:`Admin_chatListItem ${g===a.id?"active":""}`,onClick:()=>h(a.id),children:[(0,b.jsx)("img",{src:a.charAvatar,alt:"char",className:"Admin_chatListItemAvatar"}),(0,b.jsxs)("div",{className:"Admin_chatListItemInfo",children:[(0,b.jsxs)("div",{className:"Admin_chatListItemTitle",children:[a.charName," + ",a.userName]}),(0,b.jsx)("div",{className:"Admin_chatListItemLastMsg",children:a.lastMsg}),(0,b.jsxs)("div",{className:"Admin_chatListItemMeta",children:[(0,b.jsx)("span",{children:a.timestamp}),a.isFlagged&&(0,b.jsx)("span",{className:"Admin_flaggedText",children:"⚠️ Flagged"})]})]})]},a.id))})]}),(0,b.jsx)("div",{className:"Admin_chatViewPane",children:m&&0===i.length?(0,b.jsx)("div",{className:"Admin_chatEmptyState",children:"Loading messages..."}):q?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)("div",{className:"Admin_chatViewHeader",children:[(0,b.jsxs)("h3",{children:[q.charName," ",(0,b.jsx)("span",{className:"Admin_textDimmed",children:"&"})," ",q.userName]}),(0,b.jsxs)("div",{className:"Admin_chatViewActions",children:[(0,b.jsx)("button",{className:"Button_primaryButton__wTR1R Button_outline__kf5T2 Admin_footerBtn Admin_textXs",children:"Flag Chat"}),(0,b.jsx)("button",{className:"Button_primaryButton__wTR1R Button_outline__kf5T2 Admin_btnDanger Admin_textXs",children:"Term Session"})]})]}),(0,b.jsxs)("div",{className:"Admin_chatViewScroll",children:[i.map(a=>(0,b.jsx)("div",{className:`Admin_msgRow Admin_msgRow--${a.role}`,children:"narration"===a.role?(0,b.jsx)("div",{className:"Admin_msgNarration",children:a.content}):(0,b.jsxs)("div",{className:`Admin_msgBubble Admin_msgBubble--${a.role} ${a.isFlagged?"Admin_msgBubble--flagged":""}`,children:[a.content,(0,b.jsx)("span",{className:"Admin_msgTimestamp",children:a.time})]})},a.id)),0===i.length&&(0,b.jsx)("div",{className:"Admin_chatEmptyState",children:"No messages in this session yet."})]})]}):(0,b.jsxs)("div",{className:"Admin_chatEmptyState",children:[(0,b.jsx)("div",{className:"Admin_chatEmptyIcon",children:(0,b.jsx)("img",{src:"/media/chat.4a7a4aa4.png",alt:"chat",width:64,height:64})}),(0,b.jsx)("p",{children:"Select a chat session to monitor"})]})})]})]});return(0,b.jsx)("div",{style:{height:"100%"},children:(0,b.jsxs)("section",{className:"userLogin_desktopLayout__T3_3F",children:[(0,b.jsx)("div",{children:(0,b.jsx)(d.default,{})}),(0,b.jsxs)("div",{className:"userLogin_desktopContent___cssm userLogin_contentSection__UUi1l",children:[(0,b.jsx)(e.default,{}),r,(0,b.jsx)("div",{className:"FloatingNotifications_floatingNotificationSection__LHC_h"})]})]})})}a.s(["default",()=>f])},62358,a=>{a.v(b=>Promise.all(["server/chunks/ssr/lib_storage_imageDB_ts_31e09dce._.js"].map(b=>a.l(b))).then(()=>b(66232)))},96384,a=>{a.v(a=>Promise.resolve().then(()=>a(69240)))}];

//# sourceMappingURL=_5dc2ad24._.js.map