import{u as A,w,b as L,a as M,x as h,y as a,j as n}from"./index-BICubz86.js";import{r as i}from"./vendor-antd-DoyqoZ7x.js";import{S as H}from"./logo-DuzqZi6-.js";import{c as U}from"./account-CsOayCF-.js";import{u as N,m as q,R as b,f as P}from"./RenderHistoryList-BlLM7gLb.js";import"./vendor-firebase-D-efta1e.js";const W="_shareWrapper_5kgns_1",$="_header_5kgns_11",z="_logo_5kgns_20",G="_content_5kgns_24",O="_normalContent_5kgns_32",Q="_hidden_5kgns_43",X="_fullpageContent_5kgns_47",Y="_errorContainer_5kgns_76",B="_errorText_5kgns_82",D="_loadingContainer_5kgns_88",J="_spinner_5kgns_95",K="_loadingText_5kgns_103",V="_content_list_5kgns_128",t={shareWrapper:W,header:$,logo:z,content:G,normalContent:O,hidden:Q,fullpageContent:X,errorContainer:Y,errorText:B,loadingContainer:D,spinner:J,loadingText:K,content_list:V};function re(){const{t:f}=A(),{shareSessionId:u}=w(),[p,S]=i.useState(!0),[x,j]=i.useState([]),[m,y]=i.useState(""),[d,_]=i.useState(!1),[o,g]=i.useState(null),I=N(e=>e.getModelShowName),v=N(e=>e.init);i.useEffect(()=>{v()},[]),i.useEffect(()=>{u&&F()},[u]);const F=async()=>{S(!0),y("");try{const{history:e}=await L.getShareContent({share_session_id:u}),l=R(e||[]);j(l)}catch(e){M.error("Fetch share content error:",e),y(f("share_not_found")||"Share link not found or expired")}finally{S(!1)}},R=e=>{const l=[];return e.forEach(s=>{var C,k;if(s.role===h.USER){const r={role:h.USER,questionId:s.questionId||"",messages:[],id:s.id};switch(s.messageType){case a.FILE:case a.IMAGE:case a.PDF:r.messages=[{...s,type:a.USER_FILE_LIST,content:((k=(C=s.content_dict)==null?void 0:C.files)==null?void 0:k.map(c=>({file_key:c.file_key,original_file_type:c.type,file_type:U(c.type),file_name:c.file_name,file_url:c.url_full,file_size:c.file_size})))||[]}];break;case a.TEXT:r.messages=[{...s,type:a.USER_QUESTION}];break;default:r.messages=[{...s,type:s.messageType||a.USER_QUESTION}];break}l.push(r);return}const T={...s,messages:q(s.content_dict||[])},E=l.find(r=>r.question_id===s.questionId&&r.role===h.ASSISTANT);if(!E){l.push({role:h.ASSISTANT,question_id:s.questionId,datasource:[T],id:s.id});return}E.datasource.push(T)}),l};return n.jsxs("div",{className:t.shareWrapper,children:[n.jsx("div",{className:t.header,children:n.jsx(H,{className:t.logo})}),n.jsxs("div",{className:t.content,children:[n.jsxs("div",{className:"".concat(t.normalContent," ").concat(d?t.hidden:""),children:[p&&n.jsxs("div",{className:t.loadingContainer,children:[n.jsx("div",{className:t.spinner}),n.jsx("div",{className:t.loadingText,children:f("loading")})]}),!p&&m&&n.jsx("div",{className:t.errorContainer,children:n.jsx("div",{className:t.errorText,children:m})}),!p&&!m&&x.length>0&&n.jsx("div",{className:t.content_list,children:n.jsx(b,{history_list:x,assistantDialogProps:{isShowFullpage:d,fullpageDatasource:o,onToggleFullpage:e=>{e?(g(e),_(!0)):(g(null),_(!1))}}})})]}),n.jsx("div",{className:"".concat(t.fullpageContent," ").concat(d?"":t.hidden),children:d&&o&&n.jsx(P,{datasource:o,isShowFullpage:d,fullpageDatasource:o,onToggleFullpage:e=>{e?(g(e),_(!0)):(g(null),_(!1))},modelShowName:I(o==null?void 0:o.provider,o==null?void 0:o.agent)})})]})]})}export{re as default};
