1import{r as b,j as r}from"./react-vendor-CHQL15iE.js";import{L as tt}from"./index.esm-DEYnJgQB.js";import rt from"./BlackboardMarkdown-Cizre-1w.js";import{a8 as at,a9 as se,aa as st,ab as Fe,ac as nt,ad as it,l as ot,ae as Ue,E as re,m as lt,u as ct,af as dt}from"./main-Dck1T9BT.js";import{r as ut}from"./renderLatex-D6ZnkI2b.js";import{ae as pt,o as ht,V as ft,ad as Te,v as mt,_ as Me,B as De,A as Oe,X as pe,a7 as bt,J as te,b9 as xt,aM as gt,aT as wt}from"./lucide-BFLOpGdB.js";import"./katex-math-BxKHCrdI.js";import"./markdown-W-rE_H7s.js";import"./pdfjs-ji3DqnKJ.js";const J=t=>t?`${t.ownerId}\0${t.sessionId}\0${t.epoch}`:"",W={status:"empty",identity:null,revision:0,presentation:null,metadataMissing:!1,latestTurn:null,material:null,selectedSectionId:"",messages:[],boardContent:"",images:[],turn:null,error:null,offline:!1,positionSaveError:null,metadataStatus:"idle",metadataError:null,emptyReason:"no_identity"},qe=/^p2g-document-image:\/\/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\/\d+$/iu,Be=2e4,X=(t,n)=>t instanceof Error&&t.message.trim()?t.message:n,Le=(t,n)=>J(t)===J(n),Ve=(t,n)=>{if(!t||typeof t!="object")return!1;const i=t;return typeof i.materialId=="string"&&i.materialId===n.materialId&&typeof i.runId=="string"&&typeof i.index=="number"&&Number.isSafeInteger(i.index)&&i.index>0&&typeof i.fileOrdinal=="number"&&Number.isSafeInteger(i.fileOrdinal)&&n.files.some(e=>e.fileOrdinal===i.fileOrdinal)&&typeof i.reference=="string"&&qe.test(i.reference)&&typeof i.type=="string"&&(i.type==="actual_image"||i.type==="data_chart"||i.type==="architecture_diagram")&&typeof i.description=="string"&&typeof i.url=="string"&&i.url.trim().length>0},me=(t,n,i)=>{if(!t||typeof t!="object")throw new Error("ç ç©¶å岿¶æ¯æ ¼å¼æ æ");const e=t;if(e.role!=="user"&&e.role!=="assistant"||typeof e.id!="string"||!e.id.trim()||i.has(e.id)||typeof e.text!="string"||!e.text.trim())throw new Error("ç ç©¶å岿¶æ¯æ ¼å¼æ æ");i.add(e.id);const d=e.role==="assistant"&&Array.isArray(e.citations)?e.citations.map(c=>nt(c,n)).filter(c=>c!==null):[],l=e.role==="assistant"?it(e.text,d,n):[];return{id:e.id,role:e.role,text:e.text,...l.length>0?{citations:l}:{},...typeof e.createdAt=="string"?{createdAt:e.createdAt}:{}}},ze=(t,n)=>{if(t.ownerId!==n.ownerId||t.sessionId!==n.sessionId||!Number.isSafeInteger(t.revision)||t.revision<0)throw new Error("ç ç©¶ä¼è¯èº«ä»½æ ¡éªå¤±è´¥");const i=st(t.material);if(!i)throw new Error("ç ç©¶æææ ¡éªå¤±è´¥");if(!Array.isArray(t.messages))throw new Error("ç ç©¶å岿 ¡éªå¤±è´¥");const e=new Set,d=t.messages.map(C=>me(C,i,e)),l=Array.isArray(t.images)?t.images.filter(C=>Ve(C,i)):[];if(t.images&&l.length!==t.images.length)throw new Error("ç ç©¶å¾çæææ ¡éªå¤±è´¥");if(typeof t.boardContent=="string"&&t.boardContent.length>Be)throw new Error("ç ç©¶é»æ¿å
容è¿é¿");let c;const y=t.metadataMissing===!0||t.presentation==null;try{c=t.presentation==null?se(i):Fe(t.presentation,{material:i})}catch{throw new Error("ç ç©¶å
æ°æ®æ ¡éªå¤±è´¥")}const R=t.latestTurn===void 0?void 0:t.latestTurn===null?null:{operationId:t.latestTurn.operationId,boardContent:t.latestTurn.boardContent,imageReferences:[...new Set(t.latestTurn.imageReferences)]};return{...t,latestTurn:R,metadataMissing:y,presentation:c,material:i,messages:d,images:l,boardContent:typeof t.boardContent=="string"?t.boardContent:""}},he=(t,n,i)=>{if(!t||t.operationId!==i)throw new Error("ç ç©¶æä½èº«ä»½æ ¡éªå¤±è´¥");const e=new Set,d=me(t.userMessage,n,e),l=me(t.assistantMessage,n,e);if(d.role!=="user"||l.role!=="assistant")throw new Error("ç ç©¶åçè§è²æ ¡éªå¤±è´¥");let c=t.session;if((c==null?void 0:c.presentation)!==void 0)try{c={...c,presentation:c.presentation==null?se(n):Fe(c.presentation,{material:n})}}catch{throw new Error("ç ç©¶å
æ°æ®æ ¡éªå¤±è´¥")}return{operationId:i,userMessage:d,assistantMessage:l,...typeof t.boardContent=="string"?{boardContent:t.boardContent}:{},...Number.isSafeInteger(t.revision)?{revision:t.revision}:{},...Array.isArray(t.imageReferences)?{imageReferences:[...new Set(t.imageReferences)]}:{},...c?{session:c}:{}}},vt=()=>{var t,n;return((n=(t=globalThis.crypto)==null?void 0:t.randomUUID)==null?void 0:n.call(t))??`research-turn-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`};function yt({gateway:t,createOperationId:n=vt,characterConfiguration:i}){let e=W,d=null,l=0,c=null,y=!1,R=i,C=null,S=null;const _=new Set,O=()=>_.forEach(s=>s()),E=s=>{y||(e=s,O())},A=(s,m)=>!y&&m===l&&Le(d,s),z=(s,m)=>({...s,signal:m}),f=()=>(c==null||c.abort(),c=new AbortController,c),j=s=>{if(Le(d,s)&&e.status!=="empty")return;if(l+=1,c==null||c.abort(),C==null||C.abort(),S==null||S.abort(),c=null,C=null,S=null,d=s,!s){E({...W});return}const m=l,x=f();E({...W,status:"loading",identity:s,emptyReason:null}),t.loadSession(z(s,x.signal)).then(g=>{var N;if(!A(s,m))return;if(!g){E({...W,identity:s,emptyReason:"no_session",error:"å½å没æå¯æ¢å¤çç ç©¶ä¼è¯ã"});return}const h=ze(g,s),p=h.selectedSectionId&&h.material.outline.some(w=>w.id===h.selectedSectionId)?h.selectedSectionId:((N=h.material.outline[0])==null?void 0:N.id)??"";E({status:"ready",identity:s,revision:h.revision,presentation:h.presentation??se(h.material),metadataMissing:h.metadataMissing===!0,latestTurn:h.latestTurn??null,material:h.material,selectedSectionId:p,messages:h.messages,boardContent:h.boardContent??"",images:h.images??[],turn:null,error:null,offline:h.offline===!0,positionSaveError:null,metadataStatus:"idle",metadataError:null,emptyReason:null})}).catch(g=>{!A(s,m)||x.signal.aborted||E({...W,status:"error",identity:s,error:X(g,"ç ç©¶ä¼è¯å 载失败ã"),emptyReason:null})})},T=async()=>{var g;if(!d)return!1;const s=d,m=l,x=new AbortController;S==null||S.abort(),S=x;try{const h=await t.loadSession(z(s,x.signal));if(!h||!A(s,m))return!1;const p=ze(h,s);if(p.revision<e.revision)return!1;const N=p.selectedSectionId&&p.material.outline.some(w=>w.id===p.selectedSectionId)?p.selectedSectionId:((g=p.material.outline[0])==null?void 0:g.id)??"";return E({...e,status:"ready",revision:p.revision,presentation:p.presentation??se(p.material),metadataMissing:p.metadataMissing===!0,latestTurn:p.latestTurn??null,material:p.material,selectedSectionId:N,messages:p.messages,boardContent:p.boardContent??"",images:p.images??[],offline:p.offline===!0,metadataStatus:"idle",metadataError:null,error:null,emptyReason:null}),!0}catch{return!1}finally{S===x&&(S=null)}},M=async s=>{if(e.status!=="ready"||e.offline||!d||!e.presentation||e.metadataMissing&&(!s.character||!s.background)||typeof t.updateMetadata!="function")return!1;const m=d,x=l,g=e.revision;S==null||S.abort();const h=new AbortController;S=h,E({...e,metadataStatus:"saving",metadataError:null});try{const p=await t.updateMetadata({...z(m,h.signal),expectedRevision:g,patch:s}
1);return!A(m,x)||h.signal.aborted?!1:p.revision<e.revision||p.revision!==g+1?(E({...e,metadataStatus:"conflict",metadataError:"ç ç©¶ä¼è¯çæ¬å·²ååã"}),!1):(E({...e,revision:p.revision,presentation:p.presentation,metadataMissing:!1,metadataStatus:"idle",metadataError:null}),!0)}catch(p){return!A(m,x)||h.signal.aborted?!1:(p==null?void 0:p.code)==="RESEARCH_SESSION_STALE_REVISION"?(E({...e,metadataStatus:"conflict",metadataError:X(p,"ç ç©¶ä¼è¯çæ¬å·²ååã")}),await T(),!1):(E({...e,metadataStatus:"error",metadataError:X(p,"ç ç©¶å
æ°æ®ä¿å失败ã")}),!1)}finally{S===h&&(S=null)}},I=s=>{if(e.status!=="ready"||e.offline||!e.material||!d)return;const m=e.material.outline.find(N=>N.id===s);if(!m)return;const x=d,g=l,h=e.revision;C==null||C.abort(),C=new AbortController;const p=C;E({...e,selectedSectionId:m.id,positionSaveError:null}),t.updatePosition({...z(x,p.signal),expectedRevision:h,selectedSectionId:m.id}).then(N=>{!A(x,g)||p.signal.aborted||C!==p||N.revision<e.revision||E({...e,revision:N.revision,selectedSectionId:m.id,positionSaveError:null})}).catch(N=>{!A(x,g)||p.signal.aborted||C!==p||E({...e,selectedSectionId:m.id,positionSaveError:X(N,"ç« èä½ç½®æªä¿åï¼å¯ç»§ç»é
读ã")})})},H=async(s,m,x,g)=>{var w;if(!((w=s.imageReferences)!=null&&w.length))return{images:[]};const h=s.imageReferences.filter(k=>typeof k=="string"&&qe.test(k));if(h.length!==s.imageReferences.length)return{images:[],error:"åçå
嫿 æå¾çå¼ç¨ï¼å·²ç§»é¤ã"};const p=await Promise.all(h.map(async k=>{try{const P=await t.resolveImage({...z(m,g.signal),reference:k});return!P||!e.material||P.reference!==k||!Ve(P,e.material)?null:P}catch{return null}}));if(!A(m,x))return{images:[]};const N=p.filter(k=>k!==null);return N.length===h.length?{images:N}:{images:N,error:"é¨åææå¾çå½åä¸å¯ç¨ï¼æ£æåçä»å·²ä¿çã"}},a=(s,m,x,g,h)=>{if(!A(g,h)||!e.material)return!1;if(typeof s.boardContent=="string"&&s.boardContent.length>Be)throw new Error("ç ç©¶é»æ¿å
容è¿é¿");const p=new Set(e.messages.map(k=>k.id)),N=[...e.messages];for(const k of[s.userMessage,s.assistantMessage])p.has(k.id)||(p.add(k.id),N.push(k));const w=new Map(e.images.map(k=>[k.reference,k]));for(const k of m)w.set(k.reference,k);return E({...e,status:"ready",revision:Number.isSafeInteger(s.revision)?s.revision:e.revision+1,messages:N,boardContent:s.boardContent??e.boardContent,latestTurn:{operationId:s.operationId,boardContent:s.boardContent??"",imageReferences:[...new Set(s.imageReferences??[])]},images:[...w.values()],turn:null,error:x??null,positionSaveError:null}),!0},v=async s=>{if(!d||!e.material||e.offline)return!1;const m=d,x=l,g=f();E({...e,turn:{...s,phase:"saving",error:void 0}});try{const h=await t.saveTurn({...z(m,g.signal),operationId:s.operationId});if(!A(m,x)||!e.material)return!1;if(h.status==="pending")return E({...e,turn:{...s,phase:"unsaved",error:"åçå·²çæï¼ä¿åä»å¨æå¡ç«¯å¤çä¸ã"}}),!1;if(h.status!==void 0&&h.status!=="completed"||!("userMessage"in h)||!("assistantMessage"in h))return E({...e,turn:{...s,phase:"failed",error:"åçä¿å失败ï¼è¯·ä½¿ç¨ç¸åæä½éè¯ã"}}),!1;const p=he(h,e.material,s.operationId),N=await H(p,m,x,g);return a(p,N.images,N.error,m,x)}catch(h){return A(m,x)&&E({...e,turn:{...s,phase:"unsaved",error:X(h,"åçä¿å失败ï¼è¯·ä½¿ç¨ç¸åæä½éè¯ã")}}),!1}},$=async(s,m)=>{var N;if(e.status!=="ready"||e.metadataMissing||e.offline||e.turn&&(e.turn.operationId!==m||e.turn.phase!=="failed")||!d||!e.material)return!1;const x=d,g=l,h=f(),p=((N=e.turn)==null?void 0:N.characterConfiguration)??(e.presentation?{characterReference:e.presentation.character.reference,outputLanguage:e.presentation.outputLanguage,narrativeStyle:e.presentation.narrativeStyle,...e.presentation.playerAddress?{playerAddressOverride:e.presentation.playerAddress}:{}}:R);E({...e,turn:{operationId:m,question:s,phase:"pending",images:[],characterConfiguration:p},error:null});try{const w=await t.ask({...z(x,h.signal),operationId:m,question:s,...e.selectedSectionId?{selectedSection:e.selectedSectionId}:{},...p?{characterConfiguration:p}:{}});if(!A(x,g)||!e.material)return!1;
1if(w.status==="pending"&&w.pendingReason!=="save")return E({...e,turn:{...e.turn,phase:"failed",images:[],error:"åçä»å¨æå¡ç«¯å¤çä¸ï¼å¯ä½¿ç¨ç¸åæä½éè¯ã"}}),!1;if(w.status==="pending"&&w.pendingReason==="save"){const F=await t.saveTurn({...z(x,h.signal),operationId:m});if(!A(x,g)||!e.material)return!1;if(F.status==="pending")return E({...e,turn:{...e.turn,phase:"unsaved",images:[],error:"åçå·²çæï¼ä¿åä»å¨æå¡ç«¯å¤çä¸ã"}}),!1;if(F.status!==void 0&&F.status!=="completed"||!("userMessage"in F)||!("assistantMessage"in F))return E({...e,turn:{...e.turn,phase:"failed",images:[],error:"åçä¿å失败ï¼è¯·ä½¿ç¨ç¸åæä½éè¯ã"}}),!1;const Y=he(F,e.material,m),U=await H(Y,x,g,h);return a(Y,U.images,U.error,x,g)}if(w.status==="quota"||w.status==="capacity"){const F=w.status==="quota"?{kind:"quota",code:w.code,count:w.count,limit:w.limit}:{kind:"capacity",code:w.code,reason:w.reason};return E({...e,turn:{...e.turn,phase:"failed",images:[],error:w.status==="quota"?"ç ç©¶é®ç次æ°å·²è¾¾ä¸éã":"ç ç©¶ä¼è¯å®¹é已达ä¸éã",failure:F}}),!1}if(w.status!==void 0&&w.status!=="completed"||!("userMessage"in w)||!("assistantMessage"in w))return!1;const k=he(w,e.material,m),P=await H(k,x,g,h);return A(x,g)?a(k,P.images,P.error,x,g):!1}catch(w){return A(x,g)&&E({...e,turn:{...e.turn,phase:"failed",images:[],error:X(w,"æé®å¤±è´¥ï¼å¯ä½¿ç¨ç¸åæä½éè¯ã")}}),!1}};return{getState:()=>e,subscribe:s=>(_.add(s),()=>_.delete(s)),setIdentity:j,setCharacterConfiguration:s=>{R=s},selectSection:I,updateMetadata:M,refresh:T,submit:async s=>{const m=s.trim();return!m||e.status!=="ready"||e.metadataMissing||e.offline||e.turn||!d?!1:$(m,n())},retry:async()=>{const s=e.turn;return!s||!d?!1:s.phase==="unsaved"?v(s):s.phase!=="failed"?!1:$(s.question,s.operationId)},dispose:()=>{y=!0,l+=1,c==null||c.abort(),C==null||C.abort(),S==null||S.abort(),_.clear()}}}function Rt({identity:t,gateway:n,createOperationId:i,characterConfiguration:e}){const d=b.useRef(null);d.current||(d.current=yt({gateway:n,createOperationId:i,characterConfiguration:e}));const l=d.current,[,c]=b.useState(0);return b.useEffect(()=>l.subscribe(()=>c(y=>y+1)),[l]),b.useEffect(()=>{l.setCharacterConfiguration(e)},[l,e]),b.useEffect(()=>{l.setIdentity(t)},[l,t?J(t):""]),b.useEffect(()=>()=>l.setIdentity(null),[l]),{...l.getState(),selectSection:l.selectSection,updateMetadata:l.updateMetadata,refresh:l.refresh,submit:l.submit,retry:l.retry}}const Et=t=>t.material?at(t.material,t.selectedSectionId):null,$e={zh:{roomTitle:"èªç±ç 究室",waitingForSession:"çå¾
å·²ææçç ç©¶ä¼è¯ã",loading:"æ£å¨æ¢å¤ç ç©¶ä¼è¯â¦",noSession:"å½å没æå¯æ¢å¤çç ç©¶ä¼è¯ã请å
宿ææåå¤ã",loadFailed:"ç ç©¶ä¼è¯å 载失败ã",exit:"éåºç 究室",chapters:"ç« è",source:"åæ",fullText:"å
¨æ",board:"ç¬ç«é»æ¿",questionPlaceholder:"å´ç»æææé®ï¼æ Enter åéâ¦",send:"åé",thinking:"æ£å¨æ´çææåçâ¦",saving:"æ£å¨ä¿ååçâ¦",unsaved:"åçå·²æ¾ç¤ºï¼ä½å°æªä¿åã离å¼å请éè¯ä¿åã",failed:"æé®å¤±è´¥ã",retry:"éè¯",leaveRisk:"å½ååçå°æªä¿åï¼ç¦»å¼ä¼ä¸¢å¤±å®ã",leave:"ä»ç¶ç¦»å¼",stay:"çä¸",noChapters:"没æå¯å¯¼èªçç« èã",noSource:"è¯¥ç« èææ 坿¾ç¤ºåæã",unavailableImage:"ææå¾çå½åä¸å¯ç¨ã",user:"ä½ ",assistant:"ç ç©¶å©æ",positionNotSaved:"ç« èä½ç½®å°æªä¿åã",offlineReadOnly:"å½å为离线åªè¯»æ¨¡å¼ï¼æ æ³æé®æä¿åæ°ä½ç½®ã",citation:"åæå¼ç¨",quotaDetail:(t,n)=>Number.isFinite(t)&&Number.isFinite(n)?`仿¥é¢åº¦å·²ç¨ ${t}/${n}ã`:"仿¥ç ç©¶é®çé¢åº¦å·²è¾¾ä¸éã",capacityDetail:t=>t?`ä¼è¯å®¹é已达ä¸éï¼${t}ï¼ã`:"ç ç©¶ä¼è¯å®¹é已达ä¸éã",paperResearchOutline:"论æç®å½",paperResearchSource:"论æåæ",paperResearchPlaceholder:"ç»§ç»è¿½é®è®ºæå
å®¹ï¼æ Enter åéâ¦",paperResearchThinking:"æ£å¨æ¥æ¾åæå¹¶æ´çåçâ¦",paperResearchAskFailed:"æé®å¤±è´¥ï¼è¯·ç¨åéè¯ã",paperResearchExit:"è¿å主页é¢",paperResearchYou:"ä½ ",paperResearchPartner:"ææ¡£",paperResearchSourceEmpty:"è¯¥ç« èæ²¡æå¯æ¾ç¤ºçåæã
1",paperResearchSourceTruncated:"[ç« èè¾é¿ï¼å·²æªæé¢è§]",paperResearchContinuousHint:"è¿ç»é®çä¼èªå¨ä¿åï¼ç¨é以个人ä¸å¿æ¾ç¤ºçé¢åº¦ä¸è®°å½ä¸ºåã",paperResearchMetadataMissing:"æ¤åå²ä¼è¯æ²¡æä¿åè§è²è®¾ç½®ï¼è¯·æ¾å¼ç¡®è®¤è§è²ä¸èæ¯ååå¼å§æé®ã",paperResearchMetadataResolve:"确认å½åéæ©",paperResearchHistory:"对è¯åå²",paperResearchVoiceUnavailable:"å½å设å¤ä¸æ¯æè¯é³è¾å
¥ã",paperResearchImageExpand:"ç¹å»å
¨å±æ¥ç",paperResearchImageCollapse:"ç¹å»æ¢å¤"},en:{roomTitle:"Research Room",waitingForSession:"Waiting for an authorized research session.",loading:"Restoring research sessionâ¦",noSession:"No resumable research session is available. Prepare the material first.",loadFailed:"The research session could not be loaded.",exit:"Exit research room",chapters:"Chapters",source:"Source",fullText:"Full text",board:"Separate board",questionPlaceholder:"Ask about the material. Press Enter to sendâ¦",send:"Send",thinking:"Preparing a grounded answerâ¦",saving:"Saving answerâ¦",unsaved:"The answer is shown but not saved. Retry before leaving.",failed:"The question failed.",retry:"Retry",leaveRisk:"The current answer is not saved and will be lost if you leave.",leave:"Leave anyway",stay:"Stay",noChapters:"No navigable chapters.",noSource:"No source text is available for this chapter.",unavailableImage:"This material image is unavailable.",user:"You",assistant:"Research assistant",positionNotSaved:"The chapter position was not saved.",offlineReadOnly:"Offline read-only mode: asking and saving a new position are disabled.",citation:"Source citation",quotaDetail:(t,n)=>Number.isFinite(t)&&Number.isFinite(n)?`Daily research quota reached (${t}/${n}).`:"Daily research question quota reached.",capacityDetail:t=>t?`Session capacity reached (${t}).`:"Research session capacity reached.",paperResearchOutline:"Paper Outline",paperResearchSource:"Source Text",paperResearchPlaceholder:"Ask a follow-up about the paper. Press Enter to sendâ¦",paperResearchThinking:"Finding the source and preparing an answerâ¦",paperResearchAskFailed:"Could not answer. Please try again.",paperResearchExit:"Return to Home",paperResearchYou:"You",paperResearchPartner:"Partner",paperResearchSourceEmpty:"No source text is available for this section.",paperResearchSourceTruncated:"[This section is long; the preview has been truncated.]",paperResearchContinuousHint:"Follow-up questions are saved automatically. Check your profile for available allowance and usage records.",paperResearchMetadataMissing:"This legacy session has no saved persona settings. Explicitly confirm a character and background before asking.",paperResearchMetadataResolve:"Confirm selection",paperResearchHistory:"Dialogue History",paperResearchVoiceUnavailable:"Voice input is not supported on this device.",paperResearchImageExpand:"Click to view fullscreen",paperResearchImageCollapse:"Click to restore"},ja:{roomTitle:"ãªãµã¼ãã«ã¼ã ",waitingForSession:"èªè¨¼æ¸ã¿ã®ç ç©¶ã»ãã·ã§ã³ãå¾
ã£ã¦ãã¾ãã",loading:"ç ç©¶ã»ãã·ã§ã³ã復å
ä¸â¦",noSession:"復å
ã§ããç ç©¶ã»ãã·ã§ã³ãããã¾ãããå
ã«è³æãæºåãã¦ãã ããã",loadFailed:"ç ç©¶ã»ãã·ã§ã³ãèªã¿è¾¼ãã¾ããã§ããã",exit:"ç 究室ãéåº",chapters:"ç« ",source:"åæ",fullText:"å
¨æ",board:"ç¬ç«ãã¼ã",questionPlaceholder:"è³æã«ã¤ãã¦è³ªåãEnter ã§éä¿¡â¦",send:"éä¿¡",thinking:"è³æã«åºã¥ãåçãæ´çä¸â¦",saving:"åçãä¿åä¸â¦",unsaved:"åçã¯è¡¨ç¤ºããã¦ãã¾ããæªä¿åã§ããéåºåã«å試è¡ãã¦ãã ããã",failed:"質åã«å¤±æãã¾ããã",retry:"å試è¡",leaveRisk:"æªä¿åã®åçã¯éåºããã¨å¤±ããã¾ãã",leave:"éåºãã",stay:"ã¨ã©ã¾ã",noChapters:"ç§»åã§ããç« ãããã¾ããã",noSource:"ãã®ç« ã®åæã¯ããã¾ããã",unavailableImage:"ãã®è³æç»åã¯å©ç¨ã§ãã¾ããã",user:"ããªã",assistant:"ç ç©¶ã¢ã·ã¹ã¿ã³ã",positionNotSaved:"ç« ã®ä½ç½®ãä¿åã§ãã¾ããã§ããã",offlineReadOnly:"ãªãã©ã¤ã³ã®èªã¿åãå°ç¨ã¢ã¼ãã§ãã質åã¨æ°ããä½ç½®ã®ä¿åã¯ç¡å¹ã§ãã",citation:"åæå¼ç¨",quotaDetail:(t,n)=>Number.isFinite(t)&&Number.isFinite(n)?`æ¬æ¥ã®è³ªåä¸éã§ãï¼${t}/${n}ï¼ã`:"æ¬æ¥ã®ç 究質åä¸éã§ãã",capacityDetail:t=>t?`ã»ãã·ã§ã³å®¹éã®ä¸éã§ãï¼${t}ï¼ã`:"ç ç©¶ã»ãã·ã§ã³å®¹éã®ä¸éã§ãã",paperResearchOutline:"è«æç®æ¬¡",paperResearchSource:"åæ",paperResearchPlaceholder:"è«æã«ã¤ãã¦ç¶ãã¦è³ªåãã¾ããEnter ã§éä¿¡â¦",paperResearchThinking:"åæãæ¢ãã¦åçãæ´çãã¦ãã¾ãâ¦",paperResearchAskFailed:"åçã§ã
1ã¾ããã§ãããããä¸åº¦ã試ããã ããã",paperResearchExit:"ãã¼ã ã¸æ»ã",paperResearchYou:"ããªã",paperResearchPartner:"ãã¼ããã¼",paperResearchSourceEmpty:"ãã®ç¯ã«ã¯è¡¨ç¤ºã§ããåæãããã¾ããã",paperResearchSourceTruncated:"[ç¯ãé·ãããããã¬ãã¥ã¼ãçç¥ãã¾ãã]",paperResearchContinuousHint:"質åã¯èªåä¿åããã¾ããå©ç¨æ ã¨å±¥æ´ã¯ãããã£ã¼ã«ã§ç¢ºèªã§ãã¾ãã",paperResearchMetadataMissing:"ãã®æ§ã»ãã·ã§ã³ã«ã¯ãã£ã©ã¯ã¿ã¼è¨å®ãããã¾ããã質ååã«ãã£ã©ã¯ã¿ã¼ã¨èæ¯ãæç¤ºçã«ç¢ºèªãã¦ãã ããã",paperResearchMetadataResolve:"鏿ã確èª",paperResearchHistory:"ä¼è©±å±¥æ´",paperResearchVoiceUnavailable:"ãã®ç«¯æ«ã¯é³å£°å
¥åã«å¯¾å¿ãã¦ãã¾ããã",paperResearchImageExpand:"ã¯ãªãã¯ã§å
¨ç»é¢è¡¨ç¤º",paperResearchImageCollapse:"ã¯ãªãã¯ã§æ»ã"},ru:{roomTitle:"ÐÑÑледоваÑелÑÑÐºÐ°Ñ ÐºÐ¾Ð¼Ð½Ð°Ñа",waitingForSession:"Ðжидание авÑоÑизованной иÑÑледоваÑелÑÑкой ÑеÑÑии.",loading:"ÐоÑÑÑановление иÑÑледоваÑелÑÑкой ÑеÑÑииâ¦",noSession:"ÐÐµÑ Ð´Ð¾ÑÑÑпной ÑеÑÑии Ð´Ð»Ñ Ð²Ð¾ÑÑÑановлениÑ. СнаÑала подгоÑовÑÑе маÑеÑиалÑ.",loadFailed:"Ðе ÑдалоÑÑ Ð·Ð°Ð³ÑÑзиÑÑ Ð¸ÑÑледоваÑелÑÑкÑÑ ÑеÑÑиÑ.",exit:"ÐÑйÑи из комнаÑÑ",chapters:"ÐлавÑ",source:"ÐÑÑоÑник",fullText:"ÐолнÑй ÑекÑÑ",board:"ÐÑделÑÐ½Ð°Ñ Ð´Ð¾Ñка",questionPlaceholder:"ÐадайÑе вопÑÐ¾Ñ Ð¾ маÑеÑиале. Enter â оÑпÑавиÑÑâ¦",send:"ÐÑпÑавиÑÑ",thinking:"ÐодгоÑовка оÑвеÑа по иÑÑоÑникÑâ¦",saving:"СоÑ
Ñанение оÑвеÑаâ¦",unsaved:"ÐÑÐ²ÐµÑ Ð¿Ð¾ÐºÐ°Ð·Ð°Ð½, но не ÑоÑ
ÑанÑн. ÐовÑоÑиÑе попÑÑÐºÑ Ð¿ÐµÑед вÑÑ
одом.",failed:"Ðе ÑдалоÑÑ Ð²ÑполниÑÑ Ð²Ð¾Ð¿ÑоÑ.",retry:"ÐовÑоÑиÑÑ",leaveRisk:"ÐеÑоÑ
ÑанÑннÑй оÑÐ²ÐµÑ Ð±ÑÐ´ÐµÑ Ð¿Ð¾ÑеÑÑн пÑи вÑÑ
оде.",leave:"ÐÑйÑи",stay:"ÐÑÑаÑÑÑÑ",noChapters:"ÐÐµÑ Ð´Ð¾ÑÑÑпнÑÑ
глав.",noSource:"ÐÐ»Ñ ÑÑой Ð³Ð»Ð°Ð²Ñ Ð½ÐµÑ Ð¸ÑÑ
одного ÑекÑÑа.",unavailableImage:"ÐзобÑажение маÑеÑиала недоÑÑÑпно.",user:"ÐÑ",assistant:"ÐÑÑледоваÑелÑÑкий помоÑник",positionNotSaved:"ÐозиÑÐ¸Ñ Ð³Ð»Ð°Ð²Ñ Ð½Ðµ ÑоÑ
Ñанена.",offlineReadOnly:"ÐвÑономнÑй Ñежим ÑолÑко Ð´Ð»Ñ ÑÑениÑ: вопÑоÑÑ Ð¸ ÑоÑ
Ñанение новой позиÑии оÑклÑÑенÑ.",citation:"ЦиÑаÑа иÑÑоÑника",quotaDetail:(t,n)=>Number.isFinite(t)&&Number.isFinite(n)?`ÐоÑÑигнÑÑ Ð´Ð½ÐµÐ²Ð½Ð¾Ð¹ Ð»Ð¸Ð¼Ð¸Ñ Ð²Ð¾Ð¿ÑоÑов (${t}/${n}).`:"ÐоÑÑигнÑÑ Ð´Ð½ÐµÐ²Ð½Ð¾Ð¹ Ð»Ð¸Ð¼Ð¸Ñ Ð¸ÑÑледоваÑелÑÑкиÑ
вопÑоÑов.",capacityDetail:t=>t?`ÐоÑÑигнÑÑ Ð»Ð¸Ð¼Ð¸Ñ ÑеÑÑии (${t}).`:"ÐоÑÑигнÑÑ Ð»Ð¸Ð¼Ð¸Ñ Ð¸ÑÑледоваÑелÑÑкой ÑеÑÑии.",paperResearchOutline:"СÑÑÑкÑÑÑа ÑÑаÑÑи",paperResearchSource:"ÐÑÑ
однÑй ÑекÑÑ",paperResearchPlaceholder:"ÐадайÑе ÑледÑÑÑий вопÑоÑ. Enter â оÑпÑавиÑÑâ¦",paperResearchThinking:"ÐÑем иÑÑ
однÑй Ñ
1ÑÐ°Ð³Ð¼ÐµÐ½Ñ Ð¸ гоÑовим оÑвеÑâ¦",paperResearchAskFailed:"Ðе ÑдалоÑÑ Ð¾ÑвеÑиÑÑ. ÐопÑобÑйÑе еÑÑ Ñаз.",paperResearchExit:"Ðа главнÑÑ",paperResearchYou:"ÐÑ",paperResearchPartner:"ÐаÑÑнÑÑ",paperResearchSourceEmpty:"ÐÐ»Ñ ÑÑого Ñаздела Ð½ÐµÑ Ð´Ð¾ÑÑÑпного ÑекÑÑа.",paperResearchSourceTruncated:"[Раздел длиннÑй; пÑедпÑоÑмоÑÑ ÑокÑаÑÑн]",paperResearchContinuousHint:"ÐопÑоÑÑ ÑоÑ
ÑанÑÑÑÑÑ Ð°Ð²ÑомаÑиÑеÑки. ÐоÑÑÑпнÑй Ð»Ð¸Ð¼Ð¸Ñ Ð¸ иÑÑоÑÐ¸Ñ Ð¸ÑполÑÐ·Ð¾Ð²Ð°Ð½Ð¸Ñ Ð¼Ð¾Ð¶Ð½Ð¾ поÑмоÑÑеÑÑ Ð² пÑоÑиле.",paperResearchMetadataMissing:"Ð ÑÑой ÑÑаÑой ÑеÑÑии Ð½ÐµÑ Ð½Ð°ÑÑÑоек пеÑÑонажа. ÐеÑед вопÑоÑом Ñвно подÑвеÑдиÑе пеÑÑонажа и Ñон.",paperResearchMetadataResolve:"ÐодÑвеÑдиÑÑ Ð²ÑбоÑ",paperResearchHistory:"ÐÑÑоÑÐ¸Ñ Ð´Ð¸Ð°Ð»Ð¾Ð³Ð°",paperResearchVoiceUnavailable:"ÐолоÑовой ввод не поддеÑживаеÑÑÑ Ð½Ð° ÑÑом ÑÑÑÑойÑÑве.",paperResearchImageExpand:"ÐажмиÑе, ÑÑÐ¾Ð±Ñ Ð¾ÑкÑÑÑÑ Ð½Ð° веÑÑ ÑкÑан",paperResearchImageCollapse:"ÐажмиÑе, ÑÑÐ¾Ð±Ñ Ð²Ð¾ÑÑÑановиÑÑ"}},St=(t="zh")=>$e[t]??$e.zh;async function ae(t,n,i={}){const e=localStorage.getItem("p2g_token");if(!e)throw new Error("RESEARCH_AUDIO_LOGIN");const d=new Headers(i.headers);d.set("Authorization",`Bearer ${e}`);const l=await ot(t,{...i,headers:d,signal:n,cache:"no-store"});if(!l.ok){const c=await l.json().catch(()=>null),y=["DAILY_POINTS_EXCEEDED","RESEARCH_RECORDING_INVALID"].includes(c==null?void 0:c.code)?c.code:l.status===403?"RESEARCH_VOICE_QUOTA":l.status===429?"RESEARCH_AUDIO_BUSY":"RESEARCH_AUDIO_FAILED";throw new Error(y)}return l}const kt=t=>new Promise((n,i)=>{const e=()=>{clearTimeout(d),i(new DOMException("Aborted","AbortError"))},d=setTimeout(()=>{t.removeEventListener("abort",e),n()},1500);t.aborted?e():t.addEventListener("abort",e,{once:!0})});async function jt(t,n,i,e){const d=`/api/research/sessions/${encodeURIComponent(t)}/voice`,l=await ae(d,e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({messageId:n,chunkIndex:i})}),{jobId:c}=await l.json();if(typeof c!="string"||!/^[0-9a-f-]{36}$/iu.test(c))throw new Error("RESEARCH_AUDIO_FAILED");const y=Date.now()+600*1e3;for(;Date.now()<y;){const R=await(await ae(`/api/tts/jobs/${c}`,e)).json();if(R.state==="done")return(await ae(`${d}/${c}/audio`,e)).blob();if(R.state==="failed")throw new Error("RESEARCH_AUDIO_FAILED");await kt(e)}throw new Error("RESEARCH_AUDIO_FAILED")}async function It(t,n,i){if(!n.size||n.size>2*1024*1024)throw new Error("RESEARCH_RECORDING_INVALID");const e=new FormData;e.append("audio",n,"question.audio");const d=await ae(`/api/research/sessions/${encodeURIComponent(t)}/transcribe`,i,{method:"POST",headers:{"Idempotency-Key":crypto.randomUUID()},body:e}),{text:l}=await d.json();if(typeof l!="string"||!l.trim())throw new Error("RESEARCH_AUDIO_FAILED");return l.slice(0,2e3)}function Nt(t){const n=Ue(String(t||"")).replace(/!\[[^\]]*\]\([^)]*\)|<img\b[^>]*>/giu,"").replace(/\[([^\]]+)\]\([^)]*\)/gu,"$1").replace(/https?:\/\/\S+|\[(?:å¼ç¨|æ¥æº|citation|source)\s*\d+\]/giu,"").replace(/[`#*_]/gu,"").replace(/\s+/gu," ").trim(),i=[];for(let e=0;e<n.length;){let d=Math.min(n.length,e+70);if(d<n.length){let c=1/0;const y=d;for(let R=e+34;R<y;R++)/[ãï¼ï¼!?ï¼;ï¼,ãï¼:\s]/u.test(n[R])&&Math.abs(R+1-e-50)<c&&(c=Math.abs(R+1-e-50),d=R+1);c===1/0&&(d=e+50),/[\uD800-\uDBFF]/u.test(n[d-1])&&d--}const l=n.slice(e,d).trim();l&&i.push(l),e=d}return i}function Ct(t={},n="",i=null,e=Math.random()){const d=new Set,l=Object.values(re).filter(y=>{const R=t[y]||t[y.toLowerCase()]||(y===re.NEUTRAL?n:"");return!R||d.has(R)?!1:(d.add(R),!0)}),c=l.length>1?l.filter(y=>y!==i):l;return c[Math.floor(Math.max(0,Math.min(.999999,e))*c.length)]||re.NEUTRAL}function _t({scope:t,sessionId:n,message:i,locked:e,expressions:d,avatarUrl:l,volume:c,muted:y,onStateChange:R}){const[C,S]=b.useState(!1),[_,O]=b.useState(!1),[E,A]=b.useState(""),[z,f]=b.useState(""),j=b.useRef(null),T=b.useRef({expressions:d,avatarUrl:l,volume:c,muted:y,onStateChange:R});T.current={expressions:d,avatarUrl:l,volume:c,muted:y,onStateChange:R};const M=b.useRef(void 0),I=b.useCallback(()=>{var v,$,o;const a=j.current;j.current=null,a==null||a.controller.abort(),(v=a==null?void 0:a.audio)==null||v.pause(),a!=null&&a.url&&URL.revokeObjectURL(a.url),(o=($=T.current).onStateChange)==null||o.call($,{audio:null,emotion:re.NEUTRAL}),O(!1),A("")},[]),H=b.useCallback(async a=>{var o,V;if(I(),!n||e)return;const v={controller:new AbortController,audio:void 0,url:void 0};j.current=v,O(!0),f("");let $=null;try{const s=Nt(a.text),m=g=>
1jt(n,a.id,g,v.controller.signal).then(h=>({blob:h,error:null}),h=>({blob:null,error:h}));let x=s.length?m(0):null;for(let g=0;g<s.length;g++){const h=await x;if(h.error)throw h.error;if(j.current!==v)return;x=g+1<s.length?m(g+1):null,v.url=URL.createObjectURL(h.blob);const p=new Audio(v.url);v.audio=p,p.volume=Math.max(0,Math.min(1,T.current.volume)),p.muted=T.current.muted,$=Ct(T.current.expressions,T.current.avatarUrl,$),A(s[g]),(V=(o=T.current).onStateChange)==null||V.call(o,{audio:p,emotion:$}),await new Promise((N,w)=>{const k=()=>{p.onended=null,p.onerror=null,v.controller.signal.removeEventListener("abort",P)},P=()=>{k(),w(new DOMException("Aborted","AbortError"))};p.onended=()=>{k(),N()},p.onerror=()=>{k(),w(new Error("RESEARCH_AUDIO_FAILED"))},v.controller.signal.addEventListener("abort",P,{once:!0}),p.play().catch(()=>{k(),w(new Error("RESEARCH_AUDIO_PLAYBACK"))})}),URL.revokeObjectURL(v.url),v.url=void 0,v.audio=void 0}}catch(s){!v.controller.signal.aborted&&j.current===v&&f(s instanceof Error?s.message:"RESEARCH_AUDIO_FAILED")}finally{j.current===v&&I()}},[n,e,I]);return b.useEffect(()=>(S(!1),f(""),M.current=void 0,I),[t,I]),b.useEffect(()=>{if(e)return;const a=M.current;M.current=(i==null?void 0:i.id)||"",a!==void 0&&i&&a!==i.id&&C&&H(i)},[i,C,e,H]),b.useEffect(()=>{e&&I()},[e,I]),b.useEffect(()=>{var a;(a=j.current)!=null&&a.audio&&(j.current.audio.volume=Math.max(0,Math.min(1,c)),j.current.audio.muted=y)},[c,y]),{enabled:C,busy:_,subtitle:E,error:z,stop:I,replay:()=>i&&H(i),toggle:()=>{I(),f(""),S(a=>!a)}}}function At({scope:t,sessionId:n,disabled:i,onTranscript:e,onStart:d}){var z;const[l,c]=b.useState("idle"),[y,R]=b.useState(""),C=typeof navigator<"u"&&!!((z=navigator.mediaDevices)!=null&&z.getUserMedia)&&typeof MediaRecorder<"u",S=b.useRef({disabled:i,onTranscript:e,onStart:d});S.current={disabled:i,onTranscript:e,onStart:d};const _=b.useRef(null),O=b.useCallback(()=>{var j;const f=_.current;_.current=null,f==null||f.controller.abort(),clearTimeout(f==null?void 0:f.timer),f!=null&&f.recorder&&(f.recorder.ondataavailable=null,f.recorder.onstop=null,f.recorder.onerror=null,f.recorder.state!=="inactive"&&f.recorder.stop()),(j=f==null?void 0:f.stream)==null||j.getTracks().forEach(T=>T.stop()),c("idle")},[]),E=b.useCallback(()=>{var j;const f=_.current;((j=f==null?void 0:f.recorder)==null?void 0:j.state)==="recording"?f.recorder.stop():f&&!f.recorder&&O()},[O]),A=b.useCallback(async()=>{if(!C||!n||S.current.disabled||_.current)return;const f={controller:new AbortController,recorder:void 0,stream:void 0,timer:void 0};_.current=f,R(""),c("starting"),S.current.onStart();try{const j=await navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!0,noiseSuppression:!0,channelCount:1}});if(_.current!==f){j.getTracks().forEach(a=>a.stop());return}f.stream=j;const T=["audio/webm;codecs=opus","audio/mp4","audio/ogg;codecs=opus"].find(a=>MediaRecorder.isTypeSupported(a)),M=new MediaRecorder(j,{...T?{mimeType:T}:{},audioBitsPerSecond:64e3});f.recorder=M;const I=[];let H=0;M.ondataavailable=a=>{if(H+=a.data.size,H>2*1024*1024){R("RESEARCH_RECORDING_INVALID"),O();return}a.data.size&&I.push(a.data)},M.onerror=()=>{R("RESEARCH_RECORDING_FAILED"),O()},M.onstop=async()=>{if(clearTimeout(f.timer),j.getTracks().forEach(a=>a.stop()),_.current===f){c("transcribing");try{const a=await It(n,new Blob(I,{type:M.mimeType}),f.controller.signal);_.current===f&&!S.current.disabled&&await S.current.onTranscript(a)}catch(a){!f.controller.signal.aborted&&_.current===f&&R(a instanceof Error?a.message:"RESEARCH_RECORDING_FAILED")}finally{_.current===f&&O()}}},M.start(250),c("recording"),f.timer=setTimeout(E,6e4)}catch(j){_.current===f&&(R(j instanceof Error&&["NotAllowedError","SecurityError"].includes(j.name)?"RESEARCH_RECORDING_PERMISSION":"RESEARCH_RECORDING_FAILED"),O())}},[C,n,O,E]);return b.useEffect(()=>(R(""),O),[t,O]),b.useEffect(()=>{let f=!1;const j=I=>{I.code!=="Space"||I.repeat||I.ctrlKey||I.altKey||I.metaKey||I.target instanceof Element&&I.target.closest('input,textarea,button,select,[contenteditable="true"],[role="dialog"]')||S.current.disabled||_.current||(I.preventDefault(),f=!0,A())},T=()=>{f&&(f=!1,E())},M=I=>{I.code==="Space"&&T()};return window.addEventListener("keydown",j),window.addEventListener("keyup",M),window.addEventListener("blur",T),()=>{window.removeEventListener("keydown",j),window.removeEventListener("keyup",M),window.removeEventListener("blur",T)}},[A,E]),{supported:C,phase:l,error:y,cancel:O,toggle:()=>_.current?E():void A()}}const Pe={zh:{voice:"åå¤é
é³",replay:"éæåå¤",record:"å½é³æ
1é®",stop:"ç»æå½é³",starting:"æ£å¨å¼å¯éº¦å
é£â¦",recording:"æ£å¨å½é³",transcribing:"æ£å¨è¯å«è¯é³â¦",unavailable:"该è§è²æªé
ç½®è¯é³",unsupported:"å½å设å¤ä¸æ¯æå½é³",failed:"è¯é³å¤ç失败ï¼è¯·ç¨åéè¯ã",quota:"è¯é³é¢åº¦å·²ç¨å®æææ è¯é³æéã",busy:"è¯é³æå¡ç¹å¿ï¼è¯·ç¨åéè¯ã",permission:"æ æ³è®¿é®éº¦å
é£ï¼è¯·æ£æ¥æµè§å¨æéã",invalid:"å½é³ä¸è½è¶
è¿ 60 ç§æ 2 MBã",playback:"æ æ³ææ¾è¯é³ï¼è¯·ç¹å»éæã"},en:{voice:"Reply audio",replay:"Replay reply",record:"Voice question",stop:"Stop recording",starting:"Opening microphoneâ¦",recording:"Recording",transcribing:"Transcribingâ¦",unavailable:"This character has no voice",unsupported:"Recording is unavailable on this device",failed:"Audio processing failed. Please try again.",quota:"Voice quota or access is unavailable.",busy:"Audio service is busy. Please try again.",permission:"Microphone access failed. Check browser permissions.",invalid:"Recordings must be within 60 seconds and 2 MB.",playback:"Audio could not play. Select replay."},ja:{voice:"è¿çã®é³å£°",replay:"è¿çãåç",record:"é³å£°ã§è³ªå",stop:"é²é³ãçµäº",starting:"ãã¤ã¯ãèµ·åä¸â¦",recording:"é²é³ä¸",transcribing:"é³å£°ãèªèä¸â¦",unavailable:"ãã®ãã£ã©ã¯ã¿ã¼ã«é³å£°ãããã¾ãã",unsupported:"ãã®ç«¯æ«ã¯é²é³ã«å¯¾å¿ãã¦ãã¾ãã",failed:"é³å£°ã®å¦çã«å¤±æãã¾ãããå試è¡ãã¦ãã ããã",quota:"é³å£°ã®å©ç¨æ ã¾ãã¯æ¨©éãããã¾ããã",busy:"é³å£°ãµã¼ãã¹ãæ··éãã¦ãã¾ãã",permission:"ãã¤ã¯ã®æ¨©éã確èªãã¦ãã ããã",invalid:"é²é³ã¯60ç§ã2 MB以å
ã«ãã¦ãã ããã",playback:"é³å£°ãåçã§ãã¾ãããåçãã¿ã³ãæ¼ãã¦ãã ããã"},ru:{voice:"ÐзвÑÑка оÑвеÑа",replay:"ÐовÑоÑиÑÑ Ð¾ÑвеÑ",record:"ÐолоÑовой вопÑоÑ",stop:"ÐавеÑÑиÑÑ Ð·Ð°Ð¿Ð¸ÑÑ",starting:"ÐклÑÑение микÑоÑонаâ¦",recording:"ÐапиÑÑ",transcribing:"РаÑпознаваниеâ¦",unavailable:"У пеÑÑонажа Ð½ÐµÑ Ð³Ð¾Ð»Ð¾Ñа",unsupported:"ÐапиÑÑ Ð½ÐµÐ´Ð¾ÑÑÑпна на ÑÑом ÑÑÑÑойÑÑве",failed:"Ðе ÑдалоÑÑ Ð¾Ð±ÑабоÑаÑÑ Ð·Ð²Ñк. ÐовÑоÑиÑе попÑÑкÑ.",quota:"ÐзвÑÑка недоÑÑÑпна или Ð»Ð¸Ð¼Ð¸Ñ Ð¸ÑÑеÑпан.",busy:"СеÑÐ²Ð¸Ñ Ð·Ð°Ð½ÑÑ. ÐовÑоÑиÑе попÑÑÐºÑ Ð¿Ð¾Ð·Ð¶Ðµ.",permission:"ÐÑовеÑÑÑе ÑазÑеÑение на доÑÑÑп к микÑоÑонÑ.",invalid:"ÐапиÑÑ Ð´Ð¾Ð»Ð¶Ð½Ð° бÑÑÑ Ð½Ðµ длиннее 60 ÑекÑнд и не болÑÑе 2 ÐÐ.",playback:"Ðе ÑдалоÑÑ Ð²Ð¾ÑпÑоизвеÑÑи звÑк. ÐажмиÑе повÑоÑ."}};function Tt(t){const n=Pe[t]||Pe.en;return{...n,error:i=>i==="DAILY_POINTS_EXCEEDED"?lt(i,t):i==="RESEARCH_VOICE_QUOTA"?n.quota:i==="RESEARCH_AUDIO_BUSY"?n.busy:i==="RESEARCH_RECORDING_PERMISSION"?n.permission:i==="RESEARCH_RECORDING_INVALID"?n.invalid:i==="RESEARCH_AUDIO_PLAYBACK"?n.playback:n.failed}}const He=3e4,Mt={position:"absolute",top:"50%",left:"50%",width:"calc(100% + 20px)",height:"calc(100% + 20px)",pointerEvents:"none"},fe=({mouseContainer:t})=>r.jsx(tt,{displacementScale:78,blurAmount:.05,saturation:155,aberrationIntensity:4,elasticity:.12,cornerRadius:24,padding:"0",mode:"prominent",mouseContainer:t,className:"paper-research-liquid-layer",style:Mt,children:r.jsx("span",{"aria-hidden":"true",className:"block h-full w-full"})}),Dt=(t,n)=>{const i=new Map(n.map(l=>[l.reference,l])),e=dt(t);let d=t;for(const l of[...e].sort((c,y)=>y.startOffset-c.startOffset)){const c=i.get(l.url);if(!c){d=`${d.slice(0,l.startOffset)}${d.slice(l.endOffset)}`;continue}const y=l.alt.replace(/[\\\]]/gu,"\\\\$&");d=`${d.slice(0,l.startOffset)}${d.slice(l.endOffset)}`}return d};function Bt({identity:t,gateway:n,characterConfiguration:i,language:e="zh",preparation:d=null,preparationActive:l=!1,preparationTerminal:c=!1,preparationUncertain:y=!1,preparationError:R=null,preparationCancelling:C=!1,characterAvailable:S=!0,voiceAvailable:_=!1,characterExpressions:O,characterAvatarUrl:E,voiceVolume:A=1,muted:z=!1,onVoiceStateChange:f,metadataMissing:j=!1,onResolveMissingMetadata:T,onMetadataResolved:M,onPresentationResolved:I,onExit:H}){var ye,Re,Ee,Se,ke,je,Ie,Ne,Ce,_e,Ae;const a=St(e),v=Tt(e),$=ct(),o=Rt({identity:t,gateway:n,characterConfiguration:i}),V=Et(o);b.useEffect(()=>{o.presentation&&(I==null||I(o.presentation))},[I,o.presentation]);const s=b.useRef(null),m=b.useRef(null),[x,g]=b.useState(null),[h,p]=b.useState(!1),[N,w]=b.useState(!1),[k,P]=b.useState(!1),[F,Y]=b.useState(""),[U,Z]=b.useState(null),[be,xe]=b.useState(!1),ne=((ye=o.turn)==null?void 0:ye.phase)==="pending"||((Re=o.turn)==null?void 0:Re.phase)==="saving",q=b.useMemo(()=>[...o.messages].reverse().find(u=>u.role==="assistant"),[o.messages]),ie=b.useMemo(()=>
1{if(!o.latestTurn)return[];const u=new Set(o.latestTurn.imageReferences);return o.images.filter(B=>u.has(B.reference)).slice(0,4)},[o.images,o.latestTurn]),ge=((Se=(Ee=o.presentation)==null?void 0:Ee.character.name)==null?void 0:Se.trim())||a.paperResearchPartner,ee=V==null?void 0:V.section,oe=ee?V.text:o.material&&o.material.outline.length===0?o.material.fullText:"",Ge=oe.length>He?`${oe.slice(0,He)} 2 3${a.paperResearchSourceTruncated}`:oe,Ye=(ee==null?void 0:ee.title)??(o.material&&o.material.outline.length===0?a.fullText:a.paperResearchSourceEmpty),le=((ke=o.turn)==null?void 0:ke.phase)==="unsaved",Q=l&&!c,ce=y?e==="zh"?"ç ç©¶åå¤ç¶æææ¶ä¸ç¡®å®ï¼ä»å¯å®å ¨åæ¶ã":e==="ja"?"ç ç©¶æºåã®ç¶æ ã確èªã§ãã¾ãããå®å ¨ã«ãã£ã³ã»ã«ã§ãã¾ãã":e==="ru"?"СоÑÑоÑние подгоÑовки неизвеÑÑно. ÐÑÐ¼ÐµÐ½Ñ Ð²ÑÑ ÐµÑÑ Ð¼Ð¾Ð¶Ð½Ð¾ вÑполниÑÑ Ð±ÐµÐ·Ð¾Ð¿Ð°Ñно.":"Preparation status is uncertain. You can still cancel safely.":R||(Q?e==="zh"?"æ£å¨åå¤ç ç©¶ææâ¦":e==="ja"?"ç ç©¶è³æãæºåä¸â¦":e==="ru"?"ÐодгоÑовка иÑÑледоваÑелÑÑÐºÐ¸Ñ Ð¼Ð°ÑеÑиаловâ¦":"Preparing research materialâ¦":o.status==="loading"?a.loading:o.status==="error"?o.error||a.loadFailed:o.status==="empty"&&t?o.error||a.noSession:t?null:a.waitingForSession),Ke=R?"research-preparation-error":Q||y||d?"research-preparation-status":t?o.status==="error"?"research-error":o.status==="empty"?"research-no-session":"research-loading":"research-empty",Xe=Q||y||o.status==="loading",Qe=!!R||o.status==="error",de=j||o.metadataMissing,We=de?a.paperResearchMetadataMissing:S?R||(Q||y?ce:a.paperResearchContinuousHint):e==="zh"?"å½åè§è²ä¸å¯ç¨ï¼æ æ³æé®ã":"The saved character is unavailable; questions are disabled.",G=o.offline||de||!t||Q||o.status!=="ready"||!S,D=_t({scope:J(t)||"",sessionId:t==null?void 0:t.sessionId,message:q,locked:G||!_,expressions:O,avatarUrl:E,volume:A,muted:z,onStateChange:f}),L=At({scope:J(t)||"",sessionId:t==null?void 0:t.sessionId,disabled:!!o.turn||G||k||N||h||be,onStart:D.stop,onTranscript:async u=>{Y(u),await o.submit(u)&&Y("")}}),K=L.phase!=="idle",ue=!!o.turn||G||K;b.useEffect(()=>{G&&L.cancel()},[G,L.cancel]);const we=o.turn&&(o.turn.phase==="failed"||o.turn.phase==="unsaved")?o.turn.phase==="unsaved"?a.unsaved:((je=o.turn.failure)==null?void 0:je.kind)==="quota"?o.turn.failure.code==="DAILY_POINTS_EXCEEDED"?v.error("DAILY_POINTS_EXCEEDED"):a.quotaDetail(o.turn.failure.count,o.turn.failure.limit):((Ie=o.turn.failure)==null?void 0:Ie.kind)==="capacity"?a.capacityDetail(o.turn.failure.reason):`${a.failed} ${o.turn.error??""}`:null;b.useEffect(()=>{if(!le)return;const u=B=>{B.preventDefault(),B.returnValue=a.leaveRisk};return window.addEventListener("beforeunload",u),()=>window.removeEventListener("beforeunload",u)},[le,a.leaveRisk]),b.useEffect(()=>Z(null),[q==null?void 0:q.id]),b.useEffect(()=>{if(!U)return;const u=B=>{B.key==="Escape"&&Z(null)};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[U]),b.useEffect(()=>{if(!k)return;const u=setTimeout(()=>{m.current&&(m.current.scrollTop=m.current.scrollHeight)},50);return()=>clearTimeout(u)},[k]);const Je=()=>{if(le){xe(!0);return}D.stop(),L.cancel(),H()},Ze=u=>{g(null),w(!0),o.selectSection(u)},et=u=>{g(u),w(!0),o.selectSection(u.sectionId)},ve=async()=>{const u=F.trim();if(!u||ue)return;D.stop(),await o.submit(u)&&Y("")};return r.jsxs("div",{ref:s,"data-testid":"paper-research-scene",className:"pointer-events-none absolute inset-0 z-40 overflow-hidden text-slate-700",children:[r.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-black/25 via-transparent to-black/35"}),r.jsxs("header",{className:"pointer-events-auto absolute inset-x-0 top-0 z-30 flex items-center justify-between gap-3 p-3 md:p-5",children:[r.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[r.jsx("button",{type:"button",onClick:Je,disabled:C,"aria-busy":C||void 0,className:"rounded-full border border-white/30 bg-black/25 p-2.5 text-white shadow-lg backdrop-blur-md transition hover:bg-white hover:text-pink-600",title:a.paperResearchExit,children:r.jsx(pt,{size:20})}),r.jsxs("div",{className:"min-w-0 rounded-2xl border border-white/25 bg-black/25 px-3 py-2 text-white shadow-lg backdrop-blur-md",children:[r.jsx("div",{className:"max-w-[45vw] truncate text-xs font-black md:max-w-[55vw] md:text-sm",children:((Ne=o.presentation)==null?void 0:Ne.title)||a.roomTitle}),r.jsx("div",{className:"hidden truncate text-[10px] text-white/70 sm:block",children:We})]})]}),r.jsxs("div",{className:"flex shrink-0 gap-2",children:[r.jsxs("button",{"data-testid":"paper-research-voice-toggle",type:"button",disabled:G||!_,onClick:D.toggle,"aria-pressed":D.enabled,title:_?v.voice:v.unavailable,"aria-label":_?v.voice:v.unavailable,className:`flex items-center gap-2 rounded-full border px-3 py-2 text-xs font-black shadow-lg backdrop-blur-md transition disabled:opacity-50 ${D.enabled?"border-pink-300 bg-pink-500 text-white":"border-white/30 bg-black/25 text-white hover:bg-white hover:text-pink-600"}`,children:[D.enabled?r.jsx(ht,{size:16}):r.jsx(ft,{size:16}),r.jsx("span",{className:"hidden sm:inline",children:v.voice})]}),D.enabled&&q&&r.jsx("button",{type:"button","data-testid":"paper-research-voice-replay",onClick:()=>D.busy?D.stop():void D.replay(),disabled:G||K,title:D.busy?v.stop:v.replay,"aria-label":D.busy?v.stop:v.replay,className:"rounded-full border border-white/30 bg-black/25 p-2.5 text-white shadow-lg backdrop-blur-md disabled:opacity-50",children:D.busy?r.jsx(Te,{size:16}):r.jsx(mt,{size:16})}),r.jsxs("button",{"data-testid":"paper-research-history",type:"button",onClick:()=>P(!0),className:"flex items-center gap-2 rounded-full border border-white/30 bg-black/25 px-3 py-2 text-xs font-black text-white shadow-lg backdrop-blur-md transition hover:bg-white hover:text-pink-600",children:[r.jsx(Me,{size:16}),r.jsx("span",{className:"hidden sm:inline",children:a.paperResearchHistory})]}),r.jsxs("button",{"data-testid":"paper-research-outline-toggle",type:"button",onClick:()=>p(u=>!u),className:`flex items-center gap-2 rounded-full border px-3 py-2 text-xs font-black shadow-lg backdrop-blur-md transition ${h?"border-pink-300 bg-pink-500 text-white":"border-white/30 bg-black/25 text-white hover:bg-white hover:text-pink-600"}`,children:[r.jsx(De,{size:16}),r.jsx("span",{className:"hidden sm:inline",children:a.paperResearchOutline})]}),r.jsxs("button",{type:"button",onClick:()=>w(u=>!u),className:`flex items-center gap-2 rounded-full border px-3 py-2 text-xs font-black shadow-lg backdrop-blur-md transition ${N?"border-pink-300 bg-pink-500 text-white":"border-white/30 bg-black/25 text-white hover:bg-white hover:text-pink-600"}`,children:[r.jsx(Oe,{size:16}),r.jsx("span",{className:"hidden sm:inline",children:a.paperResearchSource})]})]})]}),h&&r.jsxs("aside",{"data-testid":"paper-research-outline",className:"paper-research-liquid-host pointer-events-auto absolute bottom-[25vh] left-3 top-16 z-30 flex w-[min(82vw,280px)] flex-col p-3 text-white md:bottom-[24vh] md:left-5 md:top-20",children:[r.jsx(fe,{mouseContainer:s}),r.jsxs("div",{className:"relative z-10 mb-2 flex items-center justify-between gap-2",children:[r.jsxs("div",{className:"flex items-center gap-2 text-xs font-black",children:[r.jsx(De,{size:15}),a.paperResearchOutline]}),r.jsx("button",{type:"button",onClick:()=>p(!1),className:"rounded-full p-1 text-white/70 transition hover:bg-white/15 hover:text-white",children:r.jsx(pe,{size:15})})]}),r.jsx("nav",{className:"relative z-10 min-h-0 flex-1 space-y-1 overflow-y-auto pr-1 custom-scrollbar",children:(((Ce=o.material)==null?void 0:Ce.outline)??[]).map(u=>r.jsx("button",{type:"button",onClick:()=>Ze(u.id),"aria-current":o.selectedSectionId===u.id?"true":void 0,className:`w-full rounded-xl px-3 py-2 text-left text-xs font-bold transition ${o.selectedSectionId===u.id?"bg-pink-500 text-white":"text-white/80 hover:bg-white/15 hover:text-white"}`,style:{paddingLeft:`${12+Math.max(0,u.level-1)*9}px`},children:u.title},u.id))})]}),N&&r.jsxs("aside",{"data-testid":"paper-research-source-panel",className:"paper-research-liquid-host pointer-events-auto absolute bottom-[25vh] right-3 top-16 z-30 flex w-[min(88vw,390px)] flex-col p-3 text-white md:bottom-[24vh] md:right-5 md:top-20",children:[r.jsx(fe,{mouseContainer:s}),r.jsxs("div",{className:"relative z-10 mb-2 flex items-center justify-between gap-2",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2 text-xs font-black text-pink-300",children:[r.jsx(Oe,{size:15}),a.paperResearchSource]}),r.jsx("div",{className:"mt-1 truncate text-[11px] font-bold text-white/65",children:Ye})]}),r.jsx("button",{type:"button",onClick:()=>w(!1),className:"rounded-full p-1 text-white/60 transition hover:bg-white/15 hover:text-white",children:r.jsx(pe,{size:16})})]}),r.jsxs("div",{className:"relative z-10 min-h-0 flex-1 overflow-y-auto rounded-xl border border-white/10 bg-black/20 p-3 text-xs leading-6 text-white/75 custom-scrollbar",children:[x&&r.jsxs("blockquote",{className:"mb-3 rounded-xl border-l-4 border-pink-400 bg-pink-500/15 p-3 text-[11px] leading-5 text-white/80",children:[r.jsxs("div",{className:"mb-1 font-black text-pink-300",children:["[",x.id,"] ",x.sectionTitle]}),r.jsx("div",{className:"whitespace-pre-wrap",children:x.quote})]}),r.jsx("div",{className:"whitespace-pre-wrap",children:Ge||a.paperResearchSourceEmpty})]})]}),ie.length>0&&r.jsx("section",{"data-testid":"paper-research-image-stage",className:"pointer-events-auto absolute bottom-[51vh] right-4 top-[12vh] z-10 flex w-[min(44vw,760px)] items-center justify-end md:right-8",children:r.jsx("div",{className:`grid max-h-full w-full gap-3 overflow-y-auto pr-1 custom-scrollbar ${ie.length>1?"grid-cols-2":"grid-cols-1"}`,children:ie.map(u=>r.jsxs("figure",{className:"min-h-0 overflow-hidden rounded-2xl border border-white/30 bg-black/45 p-2 shadow-2xl backdrop-blur-sm",children:[r.jsxs("button",{type:"button",onClick:()=>Z(u),className:"group relative block w-full cursor-zoom-in overflow-hidden rounded-xl",title:a.paperResearchImageExpand,"aria-label":a.paperResearchImageExpand,children:[r.jsx("img",{src:u.url,alt:u.description||u.reference,className:"max-h-[30vh] w-full object-contain transition duration-200 group-hover:scale-[1.03] group-hover:brightness-110",draggable:!1}),r.jsx("span",{className:"pointer-events-none absolute inset-0 flex items-center justify-center bg-black/0 opacity-0 transition group-hover:bg-black/20 group-hover:opacity-100",children:r.jsxs("span",{className:"flex items-center gap-2 rounded-full bg-black/65 px-3 py-1.5 text-xs font-black text-white backdrop-blur-sm",children:[r.jsx(bt,{size:15}),a.paperResearchImageExpand]})})]}),u.description&&r.jsx("figcaption",{className:"mt-1 line-clamp-2 text-center text-[11px] font-bold text-white/85",children:u.description})]},u.reference))})}),U&&r.jsxs("button",{"data-testid":"paper-research-image-fullscreen",type:"button",onClick:()=>Z(null),className:"pointer-events-auto absolute inset-0 z-[70] flex cursor-zoom-out flex-col items-center justify-center gap-3 bg-black/85 p-4 backdrop-blur-md",title:a.paperResearchImageCollapse,"aria-label":a.paperResearchImageCollapse,children:[r.jsx("div",{className:"flex min-h-0 w-full flex-1 items-center justify-center",children:r.jsx("img",{src:U.url,alt:U.description||U.reference,className:"h-full w-full object-contain drop-shadow-2xl",draggable:!1})}),U.description&&r.jsx("span",{className:"max-w-5xl text-center text-sm font-bold text-white/90 [text-shadow:0_2px_8px_rgba(0,0,0,1)]",children:U.description})]}),r.jsxs("main",{className:"absolute inset-x-0 bottom-0 z-20 flex max-h-[50vh] flex-col items-center px-2 pb-2 sm:px-5 sm:pb-3 md:px-10 md:pb-5",children:[r.jsx("div",{"data-testid":"paper-research-current-response","data-phase":(_e=o.turn)==null?void 0:_e.phase,className:"pointer-events-auto mb-3 min-h-0 w-[92%] max-w-5xl text-white sm:w-[82%]",children:r.jsxs("div",{className:"max-h-[24vh] overflow-y-auto px-4 py-2 custom-scrollbar md:px-6",children:[ce&&r.jsxs("div",{"data-testid":Ke,className:`flex items-center justify-center gap-2 text-center text-sm font-bold [text-shadow:0_2px_8px_rgba(0,0,0,0.9)] md:text-base ${Qe?"text-red-300":""}`,children:[Xe&&r.jsx(te,{size:16,className:"animate-spin text-pink-300"}),r.jsx("span",{children:ce})]}),de&&r.jsxs("p",{"data-testid":"research-metadata-missing",role:"status",className:"mt-1 text-center text-[11px] font-bold text-amber-200 [text-shadow:0_2px_8px_rgba(0,0,0,0.9)]",children:[a.paperResearchMetadataMissing,T&&!o.offline&&r.jsx("button",{type:"button","data-testid":"research-metadata-resolve",onClick:async()=>{const u=await T();u&&await o.updateMetadata(u)&&o.presentation&&(M==null||M({...o.presentation,...u}))},className:"ml-2 underline underline-offset-2",children:a.paperResearchMetadataResolve})]}),o.offline&&r.jsx("p",{"data-testid":"research-offline",className:"mt-1 text-center text-[11px] font-bold text-amber-200 [text-shadow:0_2px_8px_rgba(0,0,0,0.9)]",children:a.offlineReadOnly}),o.positionSaveError&&r.jsx("p",{className:"mt-1 text-center text-[11px] font-bold text-amber-200 [text-shadow:0_2px_8px_rgba(0,0,0,0.9)]",children:a.positionNotSaved}),ne&&r.jsxs("div",{className:"flex items-center justify-center gap-2 text-sm font-bold [text-shadow:0_2px_8px_rgba(0,0,0,0.9)] md:text-base",children:[r.jsx(te,{size:16,className:"animate-spin text-pink-300"}),a.paperResearchThinking]}),!ne&&q&&r.jsxs("article",{className:"min-w-0",children:[r.jsx("div",{className:"mb-1.5 text-center text-sm font-black text-pink-200 [text-shadow:0_2px_8px_rgba(0,0,0,0.9)] md:text-base",children:ge}),r.jsx(rt,{content:Ue(Dt(q.text,o.images)),className:"h-auto text-sm !leading-relaxed [text-shadow:0_2px_8px_rgba(0,0,0,0.95)] md:text-base [&_h1]:!text-white [&_h2]:!text-white [&_h3]:!text-white [&_p]:!text-white [&_li]:!text-white [&_.katex]:!text-white [&_.katex-display]:!text-white"}),!!((Ae=q.citations)!=null&&Ae.length)&&r.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:q.citations.map(u=>r.jsxs("button",{type:"button",onClick:()=>et(u),className:"flex items-center gap-1 rounded-full border border-white/25 bg-white/10 px-2 py-1 text-[10px] font-black text-white transition hover:border-pink-300 hover:bg-pink-500/80",children:[r.jsx(xt,{size:10}),"[",u.id,"] ",a.paperResearchSource]},`${q.id}-${u.id}`))})]})]})}),r.jsxs("div",{"data-testid":"paper-research-dialogue",className:"paper-research-liquid-host pointer-events-auto relative flex w-[92%] max-w-5xl sm:w-[82%]",children:[r.jsx(fe,{mouseContainer:s}),r.jsxs("div",{"data-testid":"paper-research-input",className:"relative z-10 flex min-w-0 flex-1 flex-col justify-center px-3 py-2 md:px-5",children:[r.jsx("textarea",{value:F,onChange:u=>Y(u.target.value),onKeyDown:u=>{u.key==="Enter"&&!u.shiftKey&&!u.nativeEvent.isComposing&&(u.preventDefault(),ve())},rows:1,maxLength:2e3,disabled:ue,placeholder:a.paperResearchPlaceholder,className:"max-h-24 min-h-[30px] w-full resize-none bg-transparent py-1 text-sm font-medium leading-6 text-white outline-none placeholder:text-white/60 disabled:opacity-60 md:text-base"}),(D.subtitle||K||D.error||L.error)&&r.jsxs("div",{"data-testid":"paper-research-audio-status",role:"status",className:"max-h-16 overflow-y-auto text-xs leading-5 text-white/90",children:[K?v[L.phase]:D.subtitle,(L.error||D.error)&&r.jsx("span",{className:"block text-red-200",children:v.error(L.error||D.error)})]}),we&&r.jsxs("div",{className:"flex items-center gap-2 text-xs font-bold text-red-300",children:[r.jsx("span",{children:we}),r.jsx("button",{type:"button",onClick:()=>void o.retry(),className:"flex items-center gap-1 rounded-full border border-white/25 bg-white/10 px-2 py-1 text-[10px] font-black text-white transition hover:border-pink-300 hover:bg-pink-500/80",children:a.retry})]})]}),r.jsx("button",{"data-testid":"paper-research-record",type:"button",disabled:!L.supported||G||!!o.turn||L.phase==="transcribing",onClick:L.toggle,"aria-pressed":L.phase==="recording",title:L.supported?K?v.stop:v.record:v.unsupported,"aria-label":L.supported?K?v.stop:v.record:v.unsupported,className:"relative z-10 flex w-12 shrink-0 items-center justify-center border-l borde
3r-white/35 text-white transition disabled:cursor-not-allowed disabled:bg-white/20 disabled:text-white/45 bg-white/10 hover:bg-white/25",children:L.phase==="transcribing"||L.phase==="starting"?r.jsx(te,{size:18,className:"animate-spin"}):L.phase==="recording"?r.jsx(Te,{size:18,className:"text-red-300"}):r.jsx(gt,{size:18})}),r.jsxs("button",{"data-testid":"paper-research-send",type:"button",onClick:()=>void ve(),disabled:!F.trim()||ue,className:"relative z-10 flex min-w-[88px] shrink-0 items-center justify-center gap-2 border-l border-white/50 bg-pink-500/75 px-4 text-xs font-black text-white shadow-[0_0_18px_rgba(236,72,153,0.25)] transition hover:bg-pink-400/85 disabled:cursor-not-allowed disabled:bg-white/70 disabled:text-slate-500 disabled:shadow-none md:min-w-[128px] md:px-6 md:text-sm",children:[ne?r.jsx(te,{size:16,className:"animate-spin"}):r.jsx(wt,{size:16}),r.jsx("span",{children:a.send})]})]})]}),k&&r.jsx("div",{"data-testid":"paper-research-history-drawer",className:"pointer-events-auto absolute inset-0 z-[100] bg-black/40 flex items-center justify-center animate-fade-in font-sans",onClick:()=>P(!1),children:r.jsxs("div",{className:"bg-white/95 backdrop-blur-xl border-white ring-blue-100 rounded-2xl w-full shadow-[0_20px_60px_rgba(0,0,0,0.3)] flex flex-col overflow-hidden border-solid max-w-4xl h-[80vh]",onClick:u=>u.stopPropagation(),children:[r.jsxs("div",{className:`${$?"p-3":"p-5 md:p-6"} border-gray-100 bg-blue-50/50 border-b flex justify-between items-center`,children:[r.jsxs("h3",{className:`${$?"text-base":"text-xl md:text-2xl"} text-brand-darkBlue font-black flex items-center gap-2 min-w-0`,children:[r.jsx(Me,{className:"w-6 h-6"}),r.jsx("span",{children:a.paperResearchHistory})]}),r.jsx("button",{type:"button",onClick:()=>P(!1),className:"text-slate-400 hover:bg-red-50 hover:text-red-500 rounded-full shrink-0 flex items-center justify-center transition-colors w-11 h-11",children:r.jsx(pe,{size:24})})]}),r.jsx("div",{ref:m,className:`flex-1 overflow-y-auto space-y-4 md:space-y-5 custom-scrollbar ${$?"p-3":"p-6 md:p-8"}`,children:o.messages.map((u,B)=>r.jsxs("div",{className:`flex flex-col ${B===o.messages.length-1?"opacity-100":"opacity-80 hover:opacity-100"} transition-opacity`,children:[r.jsx("div",{className:"flex items-center gap-3 mb-2",children:r.jsx("span",{className:`font-bold inline-flex items-center justify-center shadow-sm tracking-wide ${$?"text-xs":"text-xs md:text-sm"} px-3 py-1 rounded-full ${u.role==="user"?"bg-slate-700 text-white":"bg-gray-200 text-gray-600"}`,children:u.role==="user"?a.paperResearchYou:ge})}),r.jsx("div",{className:`${$?"text-sm":"text-base md:text-lg"} text-slate-700 border-gray-200 bg-white/50 leading-relaxed border-l-4 pl-4 pr-3 py-2 rounded-r-lg`,children:ut(u.text)})]},u.id))})]})}),be&&r.jsx("div",{role:"dialog","aria-modal":"true",className:"pointer-events-auto absolute inset-0 z-[110] flex items-center justify-center bg-black/70 p-4",children:r.jsxs("div",{className:"max-w-md rounded-2xl border border-white/10 bg-slate-950/90 p-5 shadow-xl backdrop-blur",children:[r.jsx("p",{className:"mb-4 text-sm text-white",children:a.leaveRisk}),r.jsxs("div",{className:"flex justify-end gap-2",children:[r.jsx("button",{type:"button",className:"rounded-lg border border-white/15 bg-white/10 px-3 py-2 text-sm font-semibold text-white transition hover:bg-white/20 focus:outline-none focus:ring-2 focus:ring-cyan-300",onClick:()=>xe(!1),children:a.stay}),r.jsx("button",{type:"button",className:"rounded-lg border border-rose-300/40 bg-rose-400/20 px-3 py-2 text-sm font-semibold text-white transition hover:bg-rose-400/30 focus:outline-none focus:ring-2 focus:ring-rose-300",onClick:H,children:a.leave})]})]})})]})}export{Bt 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.