){console.warn("[API] 401 处理失败，刷新页面:",n),window.location.reload()}finally{Hs=null}})(),Hs)}function Zr(e){return{message_id:e.id||e.message_id||"",conversation_id:e.conversation_id||"",message_type:e.sender_type||e.message_type||"text",msg_type:e.msg_type,content:typeof e.content=="string"?e.content:e.content?JSON.stringify(e.content):"",sender_name:e.sender_name||"",created_at:e.created_at||"",media_url:e.media_url,file_name:e.file_name,file_size:e.file_size,extra_data:e.extra_data,reply_to_id:e.reply_to_id}}function Gf(e){return(e||[]).map(Zr)}async function Hw(){return await Oe.get("/h5/user")}function qw(e){return e?{conversation_id:e.id||e.conversation_id||"",employee_id:e.employee_id||"",employee_name:e.employee_name||"",status:e.status||"waiting",agent_id:e.assigned_agent_id||e.agent_id||"",agent_name:e.agent_name||"",created_at:e.created_at||"",updated_at:e.updated_at||"",ai_substantive_reply_count:e.ai_substantive_reply_count??0,can_call_agent:e.can_call_agent??!1,participants:e.participants||[]}:null}async function Ww(){const e=await Oe.get("/h5/conversations/current");return qw(e)}async function Oc(e){const t=await Oe.post("/h5/conversations/current/messages",e,{timeout:3e4});return{user_message:Zr(t.user_message),ai_reply:t.ai_reply?Zr(t.ai_reply):t.ai_reply,is_guidance:t.is_guidance,ai_reply_count:t.ai_reply_count,can_call_agent:t.can_call_agent}}async function Kw(e){const n=await Oe.get("/h5/conversations/current/messages/poll",{params:e}),s=(n==null?void 0:n.items)||n||[];return Gf(s)}async function Pc(e){const n=await Oe.get("/h5/conversations/current/messages",{params:e}),s=(n==null?void 0:n.items)||[];return{items:Gf(s),has_more:(n==null?void 0:n.has_mor