PageSourceSearch

https://reader.easeverse.ink/assets/DeepReadingPanel-CPUHjgGC.js

js easeverse.ink collected 2026-09-24 15:03:36 UTC 23,559 bytes, 3 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/collectionsApi-CPzdA3vw.js","assets/index-_Z6lRafW.js","assets/react-pc37tQby.js","assets/epub-CZIC69-u.js","assets/index-BPp4UNtk.css","assets/lookupsApi-DQKkek9k.js"])))=>i.map(i=>d[i]);
2import{i as H,_ as z,j as e,o as Q,q as Z}from"./index-_Z6lRafW.js";import{r as n}from"./react-pc37tQby.js";import{getLookups as U,getLookupDetail as ee}from"./lookupsApi-DQKkek9k.js";import{p as te}from"./Reader-zUH_inpi.js";import"./epub-CZIC69-u.js";import"./contentProcessor-Bm3htu2Y.js";import"./imageLoader-BQe3-qlZ.js";import"./pdfjs-DeWlx49F.js";import"./pdf.worker.min-DVp0HCY1.js";function Y(){return e.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5",fill:"currentColor",stroke:"none"}),e.jsx("path",{d:"M15.54 8.46a5 5 0 0 1 0 7.07"}),e.jsx("path",{d:"M19.07 4.93a10 10 0 0 1 0 14.14"})]})}function re({filled:t}){return e.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:t?"currentColor":"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"M19 21l-7-5-7 5V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z"})})}function ne(){return e.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function K({word:t,weight:u,hint:h,lang:i,member:v,onSelectWord:x,onSpeak:b,playingKey:p,onCollect:w,collectStatus:a,onDelete:l,t:m}){const y=a==="done",d=m(y?"reader.deepReading.inLoom":a==="error"?"reader.deepReading.loomError":"reader.deepReading.collectToLoom");return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`dr-word-line${v?" dr-word-line--member":""}`,children:[e.jsxs("button",{type:"button",className:`dr-word-row${v?" dr-word-row--member":""}`,onClick:()=>x==null?void 0:x(t),title:t,children:[e.jsx("span",{className:"dr-word-text",children:t}),e.jsx("span",{className:"dr-word-weight",children:u})]}),e.jsxs("span",{className:"dr-word-actions",children:[e.jsx("button",{type:"button",className:`dr-play-btn${p===`${t}@1`?" is-playing":""}`,onClick:()=>b(t,i,1),title:m("reader.deepReading.playNormal"),"aria-label":m("reader.deepReading.playNormal"),children:e.jsx(Y,{})}),e.jsxs("button",{type:"button",className:`dr-play-btn dr-play-btn--slow${p===`${t}@0.7`?" is-playing":""}`,onClick:()=>b(t,i,.7),title:m("reader.deepReading.playSlow"),"aria-label":m("reader.deepReading.playSlow"),children:[e.jsx(Y,{}),e.jsx("span",{className:"dr-play-rate",children:"0.7×"})]}),e.jsx("button",{type:"button",className:`dr-collect-btn dr-collect-${a||"idle"}`,onClick:()=>w==null?void 0:w(t),disabled:a==="saving"||y,title:d,"aria-label":d,children:e.jsx(re,{filled:y})}),e.jsx("button",{type:"button",className:"dr-delete-btn",onClick:()=>l==null?void 0:l(t),title:m("reader.deepReading.deleteEntry"),"aria-label":m("reader.deepReading.deleteEntry"),children:e.jsx(ne,{})})]})]}),h?e.jsx("p",{className:"dr-word-hint",children:h}):null]})}const se=800,ae=20;function ie({canonicalBookId:t,bookId:u,getToken:h,onSelectWord:i,collectState:v,markCollect:x}){const{t:b}=H(),[p,w]=n.useState([]),[a,l]=n.useState("idle"),[m,y]=n.useState("history"),[d,N]=n.useState(null),[C,R]=n.useState({}),I=typeof x=="function",T=I?v||{}:C,f=n.useCallback((r,s)=>{if(I){x(r,s);return}R(o=>{if(s==null){if(!(r in o))return o;const c={...o};return delete c[r],c}return{...o,[r]:s}})},[I,x]),g=n.useRef(h);g.current=h;const k=n.useRef(p);k.current=p;const A=n.useRef(T);A.current=T;const _=n.useCallback((r,s,o)=>{var q;const c=(q=g.current)==null?void 0:q.call(g);if(!c||!r)return;const M=`${r}@${o}`;N(M);const P=()=>N(V=>V===M?null:V);te(r,c,s||"auto",null,o).then(V=>{if(!V){P();return}V.addEventListener("ended",P,{once:!0}),V.addEventListener("error",P,{once:!0})}).catch(P)},[]),L=n.useCallback(r=>{var P;const s=(P=g.current)==null?void 0:P.call(g);if(!s||!r)return;const o=A.current[r];if(o==="saving"||o==="done")return;const c=k.current.find(q=>q.word===r);if(!c)return;f(r,"saving");let M="zh";try{M=localStorage.getItem("ev_lens_lang")||"zh"}catch{}z(async()=>{const{saveChunkToCollections:q}=await import("./collectionsApi-CPzdA3vw.js");return{saveChunkToCollections:q}},__vite__mapDeps([0,1,2,3,4])).then(({saveChunkToCollections:q})=>q(s,{word:r,context:"",explanation:c.hint||"",category:c.category||"",source_type:"reader",source_canonical_book_id:t||"",source_book_id:u||"",chunk_category:c.category||"",chunk_level:c.cefr||"",target_lang:M})).then(()=>f(r,"done")).catch(()=>f(r,"error"))},[t,u,f]),S=n.useCallback(r=>{var o;const s=(o=g.current)==null?void 0:o.call(g);!s||!r||(w(c=>c.filter(M=>M.word!==r)),f(r,null),z(async()=>{const{deleteLookup:c}=await import("./lookupsApi-DQKkek9k.js");return{deleteLookup:c}},__vite__mapDeps([5,1,2,3,4])).then(({deleteLookup:c})=>c(s,t,r)).catch(()=>{}).finally(()=>{var c;return(c=j.current)==null?void 0:c.call(j,{silent:!0})}
2))},[t,f]),j=n.useRef(null),D=n.useRef(0),O=n.useCallback(({silent:r})=>{var c;if(!t){l("idle");return}const s=(c=g.current)==null?void 0:c.call(g);if(!s){l("unauth");return}const o=++D.current;r||l("loading"),U(s,t).then(({lookups:M})=>{if(o!==D.current)return;const P=Array.isArray(M)?M.filter(q=>q&&q.category!=="grammar"):[];w(P),l(P.length===0?"empty":"ready")}).catch(()=>{o===D.current&&(r||l("error"))})},[t]);j.current=O,n.useEffect(()=>{a==="ready"&&p.length===0&&l("empty")},[a,p]),n.useEffect(()=>(O({silent:!1}),()=>{D.current++}),[t,O]),n.useEffect(()=>{if(!t)return;let r=null;const s=o=>{const c=o==null?void 0:o.detail;c!=null&&c.canonicalBookId&&c.canonicalBookId!==t||(r&&clearTimeout(r),r=setTimeout(()=>{r=null,O({silent:!0})},se))};return window.addEventListener("easeverse:lookup-recorded",s),()=>{window.removeEventListener("easeverse:lookup-recorded",s),r&&clearTimeout(r)}},[t,O]);const E=n.useMemo(()=>[...p].sort((r,s)=>{const o=r.last_at||"",c=s.last_at||"";return o!==c?o<c?1:-1:(s.weight||0)-(r.weight||0)}).slice(0,ae),[p]),$=n.useMemo(()=>{const r=new Map;for(const o of p){if(!o.word)continue;const c=o.family||o.lemma||o.word,M=r.get(c);M?(M.members.push(o),M.total+=o.weight||0):r.set(c,{label:c,total:o.weight||0,members:[o]})}const s=[...r.values()];for(const o of s)o.members.sort((c,M)=>(M.weight||0)-(c.weight||0));return s.sort((o,c)=>c.total-o.total),s},[p]),F={unauth:"reader.deepReading.signInToSee",idle:"reader.deepReading.noLookups",loading:"reader.deepReading.loading",error:"reader.deepReading.loadError",empty:"reader.deepReading.noLookups"}[a];return e.jsxs("div",{className:"dr-lookup-list","data-testid":"dr-lookup-list",children:[e.jsxs("div",{className:"dr-view-tabs",role:"tablist","aria-label":b("reader.deepReading.bubbles"),children:[e.jsx("button",{type:"button",role:"tab","aria-selected":m==="history",className:`dr-view-tab ${m==="history"?"active":""}`,onClick:()=>y("history"),children:b("reader.deepReading.viewHistory")}),e.jsx("button",{type:"button",role:"tab","aria-selected":m==="frequency",className:`dr-view-tab ${m==="frequency"?"active":""}`,onClick:()=>y("frequency"),children:b("reader.deepReading.viewFrequency")})]}),F&&e.jsx("div",{className:"dr-placeholder",children:b(F)}),a==="ready"&&m==="history"&&e.jsx("ul",{className:"dr-word-list","data-testid":"dr-history-list",children:E.map(r=>e.jsx("li",{className:"dr-word-entry",children:e.jsx(K,{word:r.word,weight:r.weight,hint:r.hint,lang:r.lang,onSelectWord:i,onSpeak:_,playingKey:d,onCollect:L,collectStatus:T[r.word],onDelete:S,t:b})},r.word))}),a==="ready"&&m==="frequency"&&e.jsx("ul",{className:"dr-lemma-list","data-testid":"dr-frequency-list",children:$.map(r=>e.jsx("li",{className:"dr-lemma-group",children:r.members.length>1?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"dr-lemma-head",children:[e.jsx("span",{className:"dr-lemma-text",children:r.label}),e.jsx("span",{className:"dr-lemma-total",children:r.total})]}),e.jsx("ul",{className:"dr-lemma-members",children:r.members.map(s=>e.jsx("li",{className:"dr-word-entry",children:e.jsx(K,{word:s.word,weight:s.weight,hint:s.hint,lang:s.lang,member:!0,onSelectWord:i,onSpeak:_,playingKey:d,onCollect:L,collectStatus:T[s.word],onDelete:S,t:b})},s.word))})]}):e.jsx(K,{word:r.members[0].word,weight:r.total,hint:r.members[0].hint,lang:r.members[0].lang,onSelectWord:i,onSpeak:_,playingKey:d,onCollect:L,collectStatus:T[r.members[0].word],onDelete:S,t:b})},r.label))})]})}function le({word:t,canonicalBookId:u,bookId:h,getToken:i,onBack:v,collectState:x,markCollect:b}){const{t:p}=H(),[w,a]=n.useState([]),[l,m]=n.useState("loading"),y=typeof b=="function",[d,N]=n.useState("idle"),C=y?(x==null?void 0:x[t])||"idle":d,R=f=>{y?b(t,f):N(f)};n.useEffect(()=>{const f=i==null?void 0:i();if(!t||!u||!f){m("error");return}let g=!1;return m("loading"),y||N("idle"),ee(f,u,t).then(({contexts:k})=>{g||(a(Array.isArray(k)?k:[]),m((k||[]).length===0?"empty":"ready"))}).catch(()=>{g||m("error")}),()=>{g=!0}},[t,u,i]);const I=async()=>{const f=i==null?void 0:i();if(!f||C==="saving"||C==="done")return;R("saving");const g=w[0]||{};let k="zh";try{k=localStorage.getItem("ev_lens_lang")||"zh"}catch{}try{const{saveChunkToCollections:A}=await z(async()=>{const{saveChunkToCollections:_}=await import("./collectionsApi-CPzdA3vw.js");return{saveChunkToCollections:_}},__vite__mapDeps([0,1,2,3,4]));await A(f,{word:t,context:g.sentence||"",explanation:g.hint||"",category:g.category||"",source_type:"reader",source_canonical_book_id:u||"",source_book_id:h||"",chunk_category:g.category||"",chunk_level:g.cefr||"",target_lang:k}),R("done")}catch{R("error")}},T=p(C==="done"?"reader.deepReading.inLoom":C==="error"?"reader.deepReading.loomError":C==="saving"?"reader.deepReading.loading":"reader.deepReading.toLoom");return e.jsxs("div",{className:"dr-word-detail","data-testid":"dr-word-detail",children:[e.jsxs("div",{className:"dr-word-detail-head",children:[e.jsx("button",{type:"button",className:"dr-back",onClick:v,children:p("reader.deepReading.back")}),e.jsx("span",{className:"dr-word-detail-word",children:t}),l==="ready"&&e.jsx("button",{type:"button",className:`dr-loom-btn dr-loom-${C}`,onClick:I,disabled:C==="saving"||C==="done",children:T})]}),l==="loading"&&e.jsx("div",{className:"dr-placeholder",children:p("reader.deepReading.loading")}),l==="error"&&e.jsx("div",{className:"dr-placeholder",children:p("reader.deepReading.loadError")}),l==="empty"&&e.jsx("div",{className:"dr-placeholder",children:p("reader.deepReading.noLookups")}),l==="ready"&&e.jsxs(e.Fragment,{children:[e.jsx("h4",{className:"dr-section-title",children:p("reader.deepReading.contexts")}
2),e.jsx("ul",{className:"dr-context-list",children:w.map((f,g)=>e.jsxs("li",{className:"dr-context",children:[f.chapter_index!=null&&e.jsx("span",{className:"dr-context-chapter",children:f.chapter_index+1}),e.jsxs("span",{className:"dr-context-sentence",children:[f.context_before?e.jsxs("span",{className:"dr-ctx-dim",children:[f.context_before," "]}):null,e.jsx("strong",{children:f.sentence||f.original_text||t}),f.context_after?e.jsxs("span",{className:"dr-ctx-dim",children:[" ",f.context_after]}):null]}),f.hint&&e.jsx("span",{className:"dr-context-hint",children:f.hint})]},g))})]})]})}const G=" unknown",de=800,ce=16,oe=4;function ue(){const{t}=H();return n.useCallback(u=>{if(!u)return"";const h=new Date(u);if(isNaN(h.getTime()))return"";const i=Math.floor((Date.now()-h.getTime())/1e3);return i<60?t("reader.deepReading.timeJustNow"):i<3600?t("reader.deepReading.timeMinAgo",{n:Math.floor(i/60)}):i<86400?t("reader.deepReading.timeHourAgo",{n:Math.floor(i/3600)}):i<86400*3?t("reader.deepReading.timeDayAgo",{n:Math.floor(i/86400)}):h.toLocaleString(void 0,{year:"numeric",month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"})},[t])}function X({initialValue:t="",placeholder:u,onSave:h,onClose:i}){const{t:v}=H(),[x,b]=n.useState(t),p=n.useRef(null),w=n.useRef(null),a=n.useRef(h),l=n.useRef(x);n.useEffect(()=>{a.current=h},[h]),n.useEffect(()=>{l.current=x},[x]),n.useEffect(()=>(w.current&&clearTimeout(w.current),w.current=setTimeout(()=>{var d;w.current=null,(d=a.current)==null||d.call(a,l.current)},de),()=>{w.current&&clearTimeout(w.current)}),[x]),n.useEffect(()=>()=>{var d;w.current&&(clearTimeout(w.current),w.current=null,(d=a.current)==null||d.call(a,l.current))},[]);const m=n.useCallback(()=>{const d=()=>{typeof window>"u"||(window.scrollTo(0,0),document.scrollingElement&&(document.scrollingElement.scrollTop=0))};d(),setTimeout(d,350)},[]),y=n.useCallback(()=>{var d;(d=p.current)==null||d.blur(),i==null||i()},[i]);return e.jsxs("div",{className:"dr-wf-edit",children:[e.jsx("textarea",{ref:p,className:"dr-wf-textarea",value:x,autoFocus:!0,placeholder:u||v("reader.deepReading.notePlaceholder"),onChange:d=>b(d.target.value),onBlur:m,onKeyDown:d=>{d.key==="Escape"&&(d.preventDefault(),y()),d.key==="Enter"&&(d.metaKey||d.ctrlKey)&&(d.preventDefault(),y())}}),e.jsx("div",{className:"dr-wf-edit-actions",children:e.jsx("button",{type:"button",className:"dr-wf-done",onClick:y,children:v("reader.deepReading.done")})})]})}function he({note:t,userId:u,onClose:h}){const{t:i}=H(),[v,x]=n.useState(null),[b,p]=n.useState(null);n.useEffect(()=>{let a=!1;return(async()=>{try{const l=await Z(t.id,u);a||x(l)}catch(l){a||p((l==null?void 0:l.message)||"load failed")}})(),()=>{a=!0}},[t.id,u]),n.useEffect(()=>{const a=l=>{l.key==="Escape"&&(h==null||h())};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[h]);const w=n.useMemo(()=>v?[...v].sort((a,l)=>new Date(l.created_at)-new Date(a.created_at)):[],[v]);return e.jsx("div",{className:"dr-wf-history-backdrop",role:"dialog","aria-modal":"true","aria-label":i("reader.deepReading.editHistoryTitle"),onClick:a=>{a.target===a.currentTarget&&(h==null||h())},children:e.jsxs("div",{className:"dr-wf-history-modal",children:[e.jsxs("div",{className:"dr-wf-history-header",children:[e.jsx("span",{className:"dr-wf-history-title",children:i("reader.deepReading.editHistoryTitle")}),e.jsx("button",{type:"button",className:"dr-wf-history-close",onClick:h,"aria-label":i("reader.deepReading.close"),children:"×"})]}),e.jsxs("ul",{className:"dr-wf-history-list",children:[e.jsxs("li",{className:"dr-wf-history-row dr-wf-history-row--current",children:[e.jsx("div",{className:"dr-wf-history-meta",children:i("reader.deepReading.editHistoryCurrent")}),e.jsx("div",{className:"dr-wf-history-content",children:t.content})]}),b&&e.jsx("li",{className:"dr-wf-history-empty",children:i("reader.deepReading.editHistoryError")}),!b&&v===null&&e.jsx("li",{className:"dr-wf-history-empty",children:"…"}),!b&&v&&w.length===0&&e.jsx("li",{className:"dr-wf-history-empty",children:i("reader.deepReading.editHistoryNone")}),w.map(a=>e.jsxs("li",{className:"dr-wf-history-row",children:[e.jsx("div",{className:"dr-wf-history-meta",children:new Date(a.created_at).toLocaleStr
2ing()}),e.jsx("div",{className:"dr-wf-history-content",children:a.content})]},a.id))]})]})})}function me({parentNote:t,onCreateReply:u,onUpdateNote:h,onClose:i}){const{t:v}=H(),x=n.useRef(null),b=n.useRef(null),p=n.useCallback(async w=>{const a=(w||"").trim();if(!a)return;const l=b.current||Promise.resolve(),m=(async()=>{await l;try{if(x.current)await(h==null?void 0:h(x.current,a));else{const y=await(u==null?void 0:u({content:a,parent_note_id:t.id,chapter:t.chapter||null}));y!=null&&y.id&&(x.current=y.id)}}catch{}})();b.current=m,await m},[t.id,t.chapter,u,h]);return e.jsx("div",{className:"dr-wf-reply",children:e.jsx(X,{initialValue:"",placeholder:v("reader.deepReading.replyPlaceholder"),onSave:p,onClose:i})})}function B({it:t,depth:u,editingId:h,replyingId:i,historyId:v,openEditor:x,closeEditor:b,openReply:p,closeReply:w,openHistory:a,closeHistory:l,onNavigate:m,onUpdateNote:y,onCreateReply:d,onDeleteNote:N,userId:C,t:R,chapterLabel:I,formatTime:T,shown:f,toggleChildren:g}){const k=h===t.id,A=i===t.id,_=v===t.id,L=!!t.cfi&&!k,S=Math.min(u,oe)*ce,j=t.children.length>0,D=f.has(t.id)?f.get(t.id):u===0,O=()=>m==null?void 0:m(t.cfi,t.highlightId?{highlightId:t.highlightId}:void 0);return e.jsxs("li",{className:`dr-wf-item ${k?"editing":""} ${u>0?"dr-wf-reply-item":""}`,style:u>0?{marginLeft:`${S}px`}:void 0,"data-depth":u,children:[u===0&&t.quote&&(L?e.jsxs("button",{type:"button",className:"dr-wf-quote","data-color":t.color||void 0,title:R("reader.deepReading.jumpToPassage"),"aria-label":R("reader.deepReading.jumpToPassage"),onClick:O,children:['"',t.quote,'"']}):e.jsxs("div",{className:"dr-wf-quote dr-wf-quote--static","data-color":t.color||void 0,children:['"',t.quote,'"']})),k?e.jsx(X,{initialValue:t.note.content||"",onSave:E=>{const $=(E||"").trim();if(!(!$||$===(t.note.content||"").trim()))try{y==null||y(t.note.id,$)}catch{}},onClose:b}):e.jsx("div",{className:"dr-wf-content",role:"button",tabIndex:0,onClick:()=>x(t.id),onKeyDown:E=>{(E.key==="Enter"||E.key===" ")&&(E.preventDefault(),x(t.id))},children:t.note.content}),e.jsxs("div",{className:"dr-wf-meta",children:[u===0&&e.jsx("span",{className:"dr-wf-meta-chapter",children:I(t.chapter)}),t.created_at&&e.jsx("span",{className:"dr-wf-meta-time",title:new Date(t.created_at).toLocaleString(),children:T(t.created_at)}),t.note.edit_count>0&&e.jsx("button",{type:"button",className:"dr-wf-meta-action dr-wf-meta-edits",onClick:()=>a(t.id),title:R("reader.deepReading.editHistoryOpen"),children:R("reader.deepReading.editHistoryTitle")}),N&&e.jsx("button",{type:"button",className:"dr-wf-meta-action dr-wf-meta-delete",onClick:()=>N(t.id),title:R("reader.deepReading.deleteNote"),children:R("reader.deepReading.deleteNote")}),j&&e.jsx("button",{type:"button",className:"dr-wf-meta-action dr-wf-meta-replies",onClick:()=>g(t.id,u),"aria-expanded":D,children:D?R("reader.deepReading.repliesHide",{n:t.children.length}):R("reader.deepReading.repliesShow",{n:t.children.length})}),e.jsx("button",{type:"button",className:"dr-wf-meta-action dr-wf-meta-reply",onClick:()=>p(t.id),title:R("reader.deepReading.replyOpen"),children:R("reader.deepReading.reply")})]}),A&&e.jsx(me,{parentNote:t.note,onCreateReply:d,onUpdateNote:y,onClose:w}),_&&e.jsx(he,{note:t.note,userId:C,onClose:l}),j&&D&&e.jsx("ul",{className:"dr-wf-children",children:t.children.map(E=>e.jsx(B,{it:E,depth:u+1,editingId:h,replyingId:i,historyId:v,openEditor:x,closeEditor:b,openReply:p,closeReply:w,openHistory:a,closeHistory:l,onNavigate:m,onUpdateNote:y,onCreateReply:d,onDeleteNote:N,userId:C,t:R,chapterLabel:I,formatTime:T,shown:f,toggleChildren:g},E.id))})]})}function pe({notes:t=[],highlights:u=[],onNavigate:h,onUpdateNote:i,onAddNote:v,onDeleteNote:x}){const{t:b}=H(),p=ue(),[w,a]=n.useState(null),[l,m]=n.useState(null),[y,d]=n.useState(null),[N,C]=n.useState(()=>new Map),R=n.useMemo(()=>{try{const j=typeof localStorage<"u"?localStorage.getItem("easeverse_token"):null;return j?Q(j):null}catch{return null}},[]),I=n.useMemo(()=>{const j=new Map(u.map(r=>[r.id,r])),D=r=>{const s=r.highlight_id?j.get(r.highlight_id):null;return{id:r.id,chapter:(s==null?void 0:s.chapter)||r.chapter||G,cfi:(s==null?void 0:s.cfi_range)||r.cfi_range,created_at:r.created_at,color:(s==null?void 0:s.color)||null,quote:(s==null?void 0:s.text)||r.selected_text||null,highlightId:s==null?void 0:s.id,note:r,children:[]}},O=new Map,E=[];
2for(const r of t)O.set(r.id,D(r));for(const r of O.values()){const s=r.note.parent_note_id;s&&O.has(s)?O.get(s).children.push(r):E.push(r)}const $=r=>r.created_at?new Date(r.created_at).getTime():0;E.sort((r,s)=>$(s)-$(r));const F=r=>{r.children.sort((s,o)=>$(s)-$(o)),r.children.forEach(F)};return E.forEach(F),E},[t,u]),T=n.useCallback(j=>{a(j),m(null)},[]),f=n.useCallback(()=>a(null),[]),g=n.useCallback(j=>{m(j),a(null)},[]),k=n.useCallback(()=>m(null),[]),A=n.useCallback(j=>d(j),[]),_=n.useCallback(()=>d(null),[]),L=n.useCallback((j,D)=>{C(O=>{const E=new Map(O),$=E.has(j)?E.get(j):D===0;return E.set(j,!$),E})},[]);if(I.length===0)return e.jsx("div",{className:"dr-placeholder",children:b("reader.deepReading.noNotes")});const S=j=>j===G?b("sidebar.unknownChapter"):j;return e.jsx("div",{className:"dr-waterfall","data-testid":"dr-waterfall",children:e.jsx("ul",{className:"dr-wf-items",children:I.map(j=>e.jsx(B,{it:j,depth:0,editingId:w,replyingId:l,historyId:y,openEditor:T,closeEditor:f,openReply:g,closeReply:k,openHistory:A,closeHistory:_,onNavigate:h,onUpdateNote:i,onCreateReply:v,onDeleteNote:x,userId:R,t:b,chapterLabel:S,formatTime:p,shown:N,toggleChildren:L},j.id))})})}const W=["bubbles","notes","chat"],fe={bubbles:"reader.deepReading.tabLookups",notes:"reader.deepReading.tabNotes",chat:"reader.deepReading.chat"},J=new Set(["chat"]),ge=W.filter(t=>!J.has(t));function ke({widthFraction:t=.3,onClose:u,canonicalBookId:h,bookId:i,currentChapter:v,getToken:x,notes:b=[],highlights:p=[],onNavigate:w,onAddNote:a,onUpdateNote:l,onDeleteNote:m,sections:y=ge,onSectionsChange:d}){const{t:N}=H(),C=Math.round(t*1e3)/10,[R,I]=n.useState(null),[T,f]=n.useState({}),g=n.useCallback((_,L)=>{f(S=>{if(L==null){if(!(_ in S))return S;const j={...S};return delete j[_],j}return{...S,[_]:L}})},[]),k=n.useMemo(()=>new Set(y),[y]),A=n.useCallback(_=>{if(J.has(_)||!d)return;const L=new Set(y);if(L.has(_)){if(L.size===1)return;L.delete(_)}else L.add(_);d(W.filter(S=>L.has(S)))},[y,d]);return e.jsxs("aside",{className:"deep-reading-panel",style:{flex:`0 0 ${C}%`},"data-testid":"deep-reading-panel","aria-label":N("reader.deepReading.title"),children:[e.jsxs("header",{className:"dr-header",children:[e.jsx("span",{className:"dr-title",children:N("reader.deepReading.title")}),e.jsx("div",{className:"dr-section-chips",role:"group","aria-label":N("reader.deepReading.title"),children:W.map(_=>{const L=k.has(_),S=J.has(_);return e.jsx("button",{type:"button",className:`dr-section-chip ${L?"active":""} ${S?"coming-soon":""}`,onClick:()=>A(_),"aria-pressed":L,"aria-disabled":S||void 0,disabled:S,title:S?N("reader.deepReading.comingSoon"):void 0,children:N(fe[_])},_)})}),e.jsx("button",{type:"button",className:"dr-close",onClick:u,"aria-label":N("reader.deepReading.close"),title:N("reader.deepReading.close"),children:"×"})]}),e.jsxs("div",{className:"dr-body","data-visible-count":k.size,children:[k.has("bubbles")&&e.jsxs("section",{className:"dr-section dr-bubbles","aria-label":N("reader.deepReading.bubbles"),children:[e.jsx("h3",{className:"dr-section-title",children:N("reader.deepReading.bubbles")}),R?e.jsx(le,{word:R,canonicalBookId:h,bookId:i,getToken:x,onBack:()=>I(null),collectState:T,markCollect:g}):e.jsx(ie,{canonicalBookId:h,bookId:i,getToken:x,onSelectWord:I,collectState:T,markCollect:g})]}),k.has("notes")&&e.jsxs("section",{className:"dr-section dr-notes","aria-label":N("reader.deepReading.notes"),children:[e.jsx("h3",{className:"dr-section-title",children:N("reader.deepReading.notes")}),e.jsx(pe,{notes:b,highlights:p,currentChapter:v,onNavigate:w,onAddNote:a,onUpdateNote:l,onDeleteNote:m})]}),k.has("chat")&&e.jsxs("section",{className:"dr-section dr-chat","aria-label":N("reader.deepReading.chat"),children:[e.jsx("h3",{className:"dr-section-title",children:N("reader.deepReading.chat")}),e.jsx("div",{className:"dr-placeholder",children:N("reader.deepReading.comingSoon")})]})]})]})}export{ke as default};
3//# sourceMappingURL=DeepReadingPanel-CPUHjgGC.js.map

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.