PageSourceSearch

https://namag.app/_next/static/chunks/2354-c4110157cfacf9bb.js

js namag.app collected 2026-10-02 01:15:24 UTC 114,492 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2354],{60245:function(e,t,n){n.d(t,{W:function(){return a}});var r=n(85893);function a(e){let{size:t=14,className:n=""}=e;return(0,r.jsx)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"currentColor",className:n,"aria-hidden":!0,children:(0,r.jsx)("path",{d:"M12 1.9C12.98 8.1 15.9 11.02 22.1 12C15.9 12.98 12.98 15.9 12 22.1C11.02 15.9 8.1 12.98 1.9 12C8.1 11.02 11.02 8.1 12 1.9Z"})})}},91005:function(e,t,n){n.d(t,{d:function(){return i}});var r=n(85893),a=n(67294),l=n(5152);let o=n.n(l)()(()=>n.e(2394).then(n.bind(n,72394)).then(e=>e.Prism),{loadableGenerated:{webpack:()=>[72394]},ssr:!1,loading:()=>(0,r.jsx)("div",{className:"bg-slate-800 p-4 rounded-lg mb-3",children:"Loading..."})});function i(e){let{language:t="",inline:n=!1,className:l="",children:i,...s}=e,d=String(i);return n?(0,r.jsx)("code",{className:"bg-slate-800/50 text-purple-300 px-2 py-1 rounded text-sm",...s,children:d}):t?(0,r.jsx)(a.Suspense,{fallback:(0,r.jsx)("div",{className:"bg-slate-800 p-4 rounded-lg mb-3",children:"Loading code..."}),children:(0,r.jsx)(o,{language:t,style:{hljs:{display:"block",overflowX:"auto",padding:"0.5em",background:"#1c1c21",color:"#abb2bf"}},className:"rounded-lg mb-3 text-sm",customStyle:{backgroundColor:"#1c1c21",padding:"1rem",margin:"0.75rem 0"},...s,children:d.replace(/\n$/,"")})}):(0,r.jsx)("code",{className:"block bg-slate-800 text-purple-300 p-4 rounded-lg mb-3 overflow-x-auto text-sm whitespace-pre-wrap break-words",...s,children:d})}},38237:function(e,t,n){n.d(t,{LT:function(){return c},Qj:function(){return d},m7:function(){return s}});var r=n(85893),a=n(19176),l=n(4958),o=n(27739);let i={p:e=>{let{node:t,...n}=e;return(0,r.jsx)("p",{className:"mb-2 last:mb-0",...n})},strong:e=>{let{node:t,...n}=e;return(0,r.jsx)("strong",{className:"font-semibold text-slate-900 dark:text-white",...n})},ul:e=>{let{node:t,...n}=e;return(0,r.jsx)("ul",{className:"list-disc pl-5 mb-2 space-y-1 marker:text-purple-500 dark:marker:text-purple-400",...n})},ol:e=>{let{node:t,...n}=e;return(0,r.jsx)("ol",{className:"list-decimal pl-5 mb-2 space-y-1 marker:text-purple-500 dark:marker:text-purple-400",...n})},li:e=>{let{node:t,...n}=e;return(0,r.jsx)("li",{className:"pl-0.5",...n})},code:e=>{let{node:t,...n}=e;return(0,r.jsx)("code",{className:"px-1 py-0.5 rounded bg-slate-200/70 dark:bg-white/10 text-[0.9em]",...n})},pre:e=>{let{node:t,...n}=e;return(0,r.jsx)("pre",{className:"p-3 rounded-lg bg-slate-100 dark:bg-white/5 overflow-x-auto text-[13px] mb-2",...n})},a:e=>{let{node:t,...n}=e;return(0,r.jsx)("a",{target:"_blank",rel:"noopener noreferrer",className:"text-purple-600 dark:text-purple-300 underline underline-offset-2",...n})},h1:e=>{let{node:t,...n}=e;return(0,r.jsx)("h3",{className:"text-[15px] font-semibold mt-2 first:mt-0 mb-1 text-slate-900 dark:text-white",...n})},h2:e=>{let{node:t,...n}=e;return(0,r.jsx)("h3",{className:"text-[15px] font-semibold mt-2 first:mt-0 mb-1 text-slate-900 dark:text-white",...n})},h3:e=>{let{node:t,...n}=e;return(0,r.jsx)("h4",{className:"text-[14px] font-semibold mt-2 first:mt-0 mb-1 text-slate-900 dark:text-white",...n})},blockquote:e=>{let{node:t,...n}=e;return(0,r.jsx)("blockquote",{className:"border-l-2 border-purple-500/40 pl-3 my-2 text-slate-600 dark:text-white/70",...n})}};function s(e){let{text:t,className:n}=e;return(0,r.jsx)("div",{dir:"auto",className:n,children:(0,r.jsx)(a.UG,{remarkPlugins:[l.Z],components:i,children:t})})}function d(e){return(0,o.V)(e.output)||e.streamedText}function c(e,t){return"key_points"!==e||/^\s*[-*+]\s/m.test(t)?t:t.split("\n").map(e=>e.trim()).filter(Boolean).map(e=>"- ".concat(e)).join("\n")}},31907:function(e,t,n){n.d(t,{z$:function(){return O},ic:function(){return R},dI:function(){return u}});var r=n(85893),a=n(73935),l=n(67294),o=n(63478),i=n(12158);let s={define:"Define",explain:"Explain",translate:"Translate",ask:"Ask…"},d={define:"Define",explain:"Explain",translate:"Translate",ask:"Ask"},c={define:"What this term means, in this context",explain:"Unpack this passage in plain language",translate:"Translate this into your language",ask:"Ask your own question about this"};function u(e){var t,n,u,p,m;let{controller:f}=e,[g,b]=(0,l.useState)(!1),[v,k]=(0,l.useState)(null),w=(0,l.useRef)(null),j=(0,o.z)();(0,l.useEffect)(()=>b(!0),[]);let{actionBar:y}=f;if((0,l.useLayoutEffect)(()=>
1{if(!y.visible){k(null);return}let e=w.current;if(!e)return;let t=e.offsetWidth,n=e.offsetHeight;k({left:Math.max(8,Math.min(y.x-t/2,window.innerWidth-t-8)),top:Math.max(8,y.y-n-8)})},[y.visible,y.x,y.y,y.operations.length,y.context,y.threadCount,null===(t=y.link)||void 0===t?void 0:t.href]),!g||!y.visible)return null;let N="span"===y.context,C=N?d:s,S=y.link;return(0,a.createPortal)((0,r.jsxs)("div",{ref:w,role:"toolbar","aria-label":"Annotation actions",className:"nx-floating fixed z-[60] flex gap-0.5 p-1.5 rounded-xl border",style:{left:"".concat(null!==(n=null==v?void 0:v.left)&&void 0!==n?n:0,"px"),top:"".concat(null!==(u=null==v?void 0:v.top)&&void 0!==u?u:0,"px"),visibility:v?"visible":"hidden"},children:[y.operations.map(e=>(0,r.jsxs)("button",{onMouseDown:e=>e.preventDefault(),onClick:()=>f.runActionBarOp(e),title:c[e],className:"inline-flex items-center gap-1.5 px-2.5 py-2 rounded-lg text-[13px] font-semibold text-slate-700 dark:text-white/90 hover:bg-[var(--interactive-primary)]/[0.1] hover:text-[var(--interactive-primary)] dark:hover:text-white transition-colors",children:[(0,r.jsx)(i.Eg,{op:e,size:15,className:"ask"===e?"text-[var(--interactive-primary)]":"opacity-60"}),C[e]]},e)),N&&(null!==(p=y.threadCount)&&void 0!==p?p:0)>0&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"w-px bg-[var(--border-color)] my-1.5 mx-0.5"}),(0,r.jsxs)("button",{onMouseDown:e=>e.preventDefault(),onClick:()=>f.openSpanHistory(),title:(null!==(m=y.threadCount)&&void 0!==m?m:0)>1?"See all conversations on this selection":"Open this conversation",className:"inline-flex items-center gap-1.5 px-2.5 py-2 rounded-lg text-[13px] font-semibold text-slate-700 dark:text-white/90 hover:bg-[var(--interactive-primary)]/[0.1] hover:text-[var(--interactive-primary)] dark:hover:text-white transition-colors",children:[(0,r.jsx)(h,{}),y.threadCount]})]}),S&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"w-px bg-[var(--border-color)] my-1.5 mx-0.5"}),(0,r.jsxs)("button",{onMouseDown:e=>e.preventDefault(),onClick:()=>{S&&(f.hideActionBar(),j?j.confirmExternalNav(S.href,S.target):window.open(S.href,S.target||"_blank","noopener,noreferrer"))},title:"Open this link",className:"inline-flex items-center gap-1.5 px-2.5 py-2 rounded-lg text-[13px] font-semibold text-slate-700 dark:text-white/90 hover:bg-[var(--interactive-primary)]/[0.1] hover:text-[var(--interactive-primary)] dark:hover:text-white transition-colors",children:[(0,r.jsx)(x,{}),"Open link"]})]})]}),document.body)}function x(){return(0,r.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,className:"opacity-80",children:[(0,r.jsx)("path",{d:"M7 17 17 7"}),(0,r.jsx)("path",{d:"M8 7h9v9"})]})}function h(){return(0,r.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,className:"opacity-80",children:(0,r.jsx)("path",{d:"M21 11.5a8.38 8.38 0 01-.9 3.8 8.5 8.5 0 01-7.6 4.7 8.38 8.38 0 01-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 01-.9-3.8 8.5 8.5 0 014.7-7.6 8.38 8.38 0 013.8-.9h.5a8.48 8.48 0 018 8v.5z"})})}var p=n(32185),m=n(38237);function f(e){let{scope:t,className:n}=e;return(0,r.jsxs)("span",{className:"inline-flex items-center gap-1.5 max-w-full text-[12px] font-medium text-slate-500 dark:text-white/55 bg-slate-100 dark:bg-white/[0.06] border border-slate-200 dark:border-white/10 rounded-full px-2.5 py-1 ".concat(null!=n?n:""),title:t.label,children:["attachment"===t.kind?(0,r.jsx)(g,{}):(0,r.jsx)(b,{}),(0,r.jsx)("span",{className:"truncate",children:t.label})]})}function g(){return(0,r.jsxs)("svg",{className:"flex-none",width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[(0,r.jsx)("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),(0,r.jsx)("polyline",{points:"14 2 14 8 20 8"})]})}function b(){return(0,r.jsxs)("svg",{className:"flex-none",width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,
1children:[(0,r.jsx)("polygon",{points:"12 2 2 7 12 12 22 7 12 2"}),(0,r.jsx)("polyline",{points:"2 17 12 22 22 17"}),(0,r.jsx)("polyline",{points:"2 12 12 17 22 12"})]})}var v=n(44265),k=n(99140);function w(){return(0,r.jsx)("span",{className:"inline-block w-0.5 h-4 bg-purple-500 dark:bg-purple-400 animate-blink ml-0.5 rounded-full align-middle"})}let j={define:"Define",explain:"Explain",ask:"Ask",summarize:"Summary",key_points:"Takeaways",translate:"Translate"},y={grounded:"Answered from this entry",insufficient_context:"Not enough in this content",out_of_scope:"Off-topic for this entry"},N={grounded:"text-green-600 dark:text-green-300",insufficient_context:"text-amber-600 dark:text-amber-300",out_of_scope:"text-blue-600 dark:text-blue-300"},C=new Set,S=()=>!!window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;function L(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]&&arguments[3],a=r||C.has(t)||S(),[o,i]=(0,l.useState)(a?e.length:0);return(0,l.useEffect)(()=>{if(a){i(e.length);return}if(o>=e.length){n||C.add(t);return}let r=setInterval(()=>i(t=>Math.min(e.length,t+2)),12);return()=>clearInterval(r)},[e,o,n,a,t]),{text:e.slice(0,Math.min(o,e.length)),typing:!a&&o<e.length}}function T(e){var t,n,a,o,s,d;let{record:c,controller:u,hideHeader:x}=e,h=null!==(o=u.scopes.find(e=>e.key===c.scopeKey))&&void 0!==o?o:u.documentScope,[g,b]=(0,l.useState)(""),{isFreeUser:C}=(0,v.a)(),[S,T]=(0,l.useState)(!1),_="span"===c.scope&&"ask"===c.operation&&!c.question&&!c.output&&!c.streamedText&&!c.pending&&!c.loading,A=!!c.loading&&!(0,m.Qj)(c).trim(),D=!c.pending&&!A&&!(0,m.Qj)(c).trim()&&!!(E(c.status)||c.suggestedPrompt),{text:B,typing:O}=L((0,m.Qj)(c),c.localId,c.pending,c.hydrated),F=O||c.pending,z=(0,l.useRef)(null),W=(0,l.useRef)(null),P=(0,l.useRef)(c.thread.length),H=(0,l.useRef)(c.oldestTurn),U=(0,l.useRef)(null);(0,l.useEffect)(()=>{if(!_)return;let e=window.setTimeout(()=>{var e;return null===(e=W.current)||void 0===e?void 0:e.focus()},60);return()=>window.clearTimeout(e)},[_,c.localId]);let K=()=>{var e;return null===(e=z.current)||void 0===e?void 0:e.closest("[data-answer-scroll]")};(0,l.useEffect)(()=>{let e=K();e&&(e.scrollTop=e.scrollHeight)},[c.localId]),(0,l.useEffect)(()=>{let e=c.thread.length>P.current,t=null!=c.oldestTurn&&null!=H.current&&c.oldestTurn<H.current;if(e&&!t){var n;null===(n=K())||void 0===n||n.scrollTo({top:1e9,behavior:"smooth"})}P.current=c.thread.length,H.current=c.oldestTurn},[c.thread.length,c.oldestTurn]),(0,l.useEffect)(()=>{if(c.error&&!c.pending){var e;null===(e=K())||void 0===e||e.scrollTo({top:"translate"===c.operation?1e9:0,behavior:"smooth"})}},[c.error,c.pending,c.operation]),(0,l.useLayoutEffect)(()=>{let e=U.current,t=K();e&&t&&(t.scrollTop=e.top+(t.scrollHeight-e.height),U.current=null)},[c.thread.length]);let $=null===(t=c.thread[c.thread.length-1])||void 0===t?void 0:t.answer;(0,l.useEffect)(()=>{let e=K();e&&e.scrollHeight-e.scrollTop-e.clientHeight<120&&(e.scrollTop=e.scrollHeight)},[B,$]);let G=(0,r.jsxs)(r.Fragment,{children:[!_&&!A&&!D&&!(c.error&&!c.pending&&!(0,m.Qj)(c).trim())&&!("grounded"===c.status&&!c.pending)&&(0,r.jsxs)("div",{className:"flex items-center gap-2 pt-3 pb-1 text-xs font-semibold ".concat(c.pending?"text-purple-600 dark:text-purple-300":N[c.status]),children:[(0,r.jsx)("span",{className:"w-[7px] h-[7px] rounded-full ".concat(c.pending?"bg-purple-500 animate-pulse":"grounded"===(d=c.status)?"bg-green-500":"insufficient_context"===d?"bg-amber-500":"bg-blue-500")}),c.pending?"Thinking…":y[c.status]]}),!_&&!A&&c.error&&!c.pending&&(0,r.jsxs)("div",{className:"mt-3 rounded-xl border border-amber-300/60 dark:border-amber-400/25 bg-amber-50 dark:bg-amber-400/10 px-3.5 py-3",children:[(0,r.jsxs)("div",{className:"flex items-start gap-2 text-[13.5px] leading-[1.5] text-amber-800 dark:text-amber-200",children:[(0,r.jsx)("span",{"aria-hidden":!0,className:"mt-[1px]",children:"⚠"}),(0,r.jsx)("span",{children:c.error})]}),c.quotaError&&C&&(0,r.jsxs)("button",{onClick:()=>T(!0),className:"mt-2.5 inline-flex items-center gap-1.5 px-3.5 py-1.5 rounded-full bg-primary text-on-accent text-[12.5px] font-semibold shadow-sm transition-all",children:[(0,r.jsx)(i.T$,{size:13})," Upgrade for more"]})]}),"translate"===c.operation&&c.translateLang&&!_&&!A&&!D&&!c.error&&(0,r.jsxs)("span",{className:"self-start inl
1ine-flex items-center gap-1 mt-2 text-[11px] font-semibold px-2 py-0.5 rounded-full bg-pink-500/10 text-pink-600 dark:text-pink-300 border border-pink-500/20",children:["→ ",c.translateLang]}),_?(0,r.jsxs)("p",{className:"text-sm text-slate-500 dark:text-white/50 mt-3",children:["Ask anything about “",null===(n=c.quote)||void 0===n?void 0:n.exact,"” — the agent answers using this entry as context."]}):A?(0,r.jsxs)("div",{className:"flex items-center gap-2.5 py-6 text-[13px] text-slate-400 dark:text-white/45",children:[(0,r.jsx)("span",{className:"w-4 h-4 rounded-full border-2 border-purple-500/30 border-t-purple-500 animate-spin"}),"Loading conversation…"]}):D?(0,r.jsx)(R,{status:c.status,suggestedPrompt:c.suggestedPrompt}):(0,r.jsxs)("div",{className:"mt-2.5",children:[(0,r.jsx)(m.m7,{text:(0,m.LT)(c.operation,B),className:"text-[15px] leading-[1.62] text-slate-700 dark:text-white/85"}),F&&(0,r.jsx)(w,{})]})]});return(0,r.jsxs)("div",{ref:z,className:"flex flex-col gap-0",children:[!x&&(0,r.jsxs)("div",{className:"flex items-center gap-2.5 pb-3 border-b border-slate-200 dark:border-white/10",children:[(0,r.jsx)("span",{className:"text-[11px] font-bold uppercase tracking-[0.06em] px-2 py-1 rounded-md border ".concat(i.mq[c.operation]),children:j[c.operation]}),"span"===c.scope?(0,r.jsxs)("span",{className:"flex-1 min-w-0 truncate text-[13px] italic text-slate-500 dark:text-white/50",children:["“",null!==(s=null===(a=c.quote)||void 0===a?void 0:a.exact)&&void 0!==s?s:"","”"]}):(0,r.jsx)("span",{className:"flex-1 min-w-0",children:(0,r.jsx)(f,{scope:h})}),(0,r.jsx)("button",{onClick:u.close,"aria-label":"Close",className:"ml-auto text-slate-400 dark:text-white/40 hover:text-slate-700 dark:hover:text-white text-xl leading-none px-1.5 rounded-md hover:bg-slate-100 dark:hover:bg-white/10",children:"\xd7"})]}),"ask"===c.operation&&c.question&&(0,r.jsx)("div",{className:"mt-3 self-end max-w-[88%] bg-primary text-on-accent text-[13.5px] px-3 py-2 rounded-[14px_14px_4px_14px]",children:c.question}),"translate"===c.operation&&!_&&(0,r.jsx)(I,{controller:u,record:c}),"translate"!==c.operation&&G,(c.thread.length>0||c.hasMore)&&(0,r.jsxs)("div",{className:"flex flex-col gap-3.5 mt-4",children:[c.hasMore&&(0,r.jsx)("button",{onClick:()=>{let e=K();e&&(U.current={top:e.scrollTop,height:e.scrollHeight}),u.loadEarlierTurns(c)},disabled:c.loadingEarlier,className:"self-center inline-flex items-center gap-1.5 text-[12px] font-semibold text-purple-600 dark:text-purple-300 hover:underline underline-offset-2 disabled:opacity-60 disabled:no-underline",children:c.loadingEarlier?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"w-3 h-3 rounded-full border-2 border-purple-500/30 border-t-purple-500 animate-spin"}),"Loading…"]}):"↑ Load earlier"}),c.thread.map((e,t)=>(0,r.jsxs)("div",{className:"flex flex-col gap-1.5",children:[e.question&&(0,r.jsx)("div",{className:"self-end max-w-[85%] bg-primary text-on-accent text-[13.5px] px-3 py-2 rounded-[14px_14px_4px_14px]",children:e.question}),(0,r.jsx)(q,{id:"".concat(c.localId,"-t").concat(t),text:e.answer,pending:!!e.pending,instant:!!e.hydrated,status:e.status})]},t))]}),"translate"===c.operation&&G,c.quote&&!c.pending&&!_&&(()=>{let e=(0,p.l)(c),t=e?u.records.filter(t=>(0,p.l)(t)===e):[],n=new Set(t.map(e=>e.operation)),a=t.length;return(0,r.jsxs)("div",{className:"flex items-center gap-2 mt-4 flex-wrap",children:[(0,r.jsx)("span",{className:"text-[10.5px] uppercase tracking-[0.1em] text-slate-400 dark:text-white/40 font-semibold",children:"On this selection"}),["define","explain"].filter(e=>!n.has(e)).map(e=>(0,r.jsx)("button",{onClick:()=>u.startSpanOp(c,e),className:"text-[12px] font-semibold px-2.5 py-1 rounded-full border border-slate-200 dark:border-white/10 text-slate-600 dark:text-white/70 hover:border-purple-500/40 hover:text-purple-600 dark:hover:text-purple-300 transition-colors",children:"define"===e?"Define":"Explain"},e)),(0,r.jsxs)("button",{onClick:()=>u.startSpanOp(c,"ask"),className:"inline-flex items-center gap-1.5 text-[12px] font-semibold px-2.5 py-1 rounded-full border border-purple-500/30 bg-purple-500/10 text-purple-600 dar
1k:text-purple-300 hover:bg-purple-500/20 transition-colors",children:[(0,r.jsx)(i.T$,{size:12})," New question"]}),a>1&&(0,r.jsxs)("button",{onClick:()=>u.openSpanHistory(e),className:"inline-flex items-center gap-1.5 text-[12px] font-semibold px-2.5 py-1 rounded-full border border-slate-200 dark:border-white/10 text-slate-600 dark:text-white/70 hover:border-purple-500/40 hover:text-purple-600 dark:hover:text-purple-300 transition-colors",children:[(0,r.jsx)(M,{})," ",a," conversations"]})]})})(),(0,r.jsxs)("form",{onSubmit:e=>{e.preventDefault();let t=g.trim();t&&(b(""),u.askFollowup(c,t))},className:"flex items-center gap-1.5 mt-4 rounded-xl border border-slate-300 dark:border-white/15 bg-white dark:bg-white/[0.04] pl-3 pr-1.5 py-1.5 transition-colors focus-within:border-purple-500/60 focus-within:ring-2 focus-within:ring-purple-500/15",children:[(0,r.jsx)("input",{ref:W,value:g,onChange:e=>b(e.target.value),placeholder:_?"Ask about this selection…":"Ask a follow-up…",className:"flex-1 min-w-0 bg-transparent outline-none text-[13.5px] text-slate-800 dark:text-white placeholder:text-slate-400 dark:placeholder:text-white/35"}),(0,r.jsx)("button",{type:"submit",disabled:!g.trim(),"aria-label":"Send",className:"flex-none w-8 h-8 rounded-lg bg-primary text-on-accent grid place-items-center disabled:opacity-40 disabled:cursor-not-allowed transition-opacity",children:(0,r.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[(0,r.jsx)("line",{x1:"5",y1:"12",x2:"19",y2:"12"}),(0,r.jsx)("polyline",{points:"12 5 19 12 12 19"})]})})]}),!_&&(0,r.jsxs)("div",{className:"flex items-center gap-2.5 mt-4 pt-3 border-t border-slate-200 dark:border-white/10 text-xs text-slate-400 dark:text-white/40 flex-wrap",children:[c.error?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"inline-flex items-center gap-1 text-amber-600 dark:text-amber-300 font-semibold",children:"Not saved"}),(0,r.jsx)("span",{className:"opacity-50",children:"\xb7"})]}):c.degraded?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"inline-flex items-center gap-1 text-amber-600 dark:text-amber-300 font-semibold",children:"⚠ Couldn’t place this"}),(0,r.jsx)("span",{className:"opacity-50",children:"\xb7"})]}):null,(0,r.jsx)("button",{onClick:()=>u.regenerate(c),className:"underline underline-offset-2 hover:text-purple-500 font-semibold",children:c.error?"Try again":"Regenerate"}),(0,r.jsx)("span",{className:"opacity-50",children:"\xb7"}),(0,r.jsx)("button",{onClick:()=>u.remove(c),className:"underline underline-offset-2 hover:text-red-500 font-semibold",children:"Delete"}),!c.error&&(0,r.jsx)("span",{className:"ml-auto italic",children:"AI-generated \xb7 double-check important details"})]}),(0,r.jsx)(k.x,{isOpen:S,onClose:()=>T(!1),source:"annotation_quota",context:{operation:c.operation}})]})}let _=["English","Spanish","French","German","Chinese","Arabic","Persian"];function I(e){var t;let{controller:n,record:a}=e,[o,i]=(0,l.useState)(!1),[s,d]=(0,l.useState)(""),c=null!==(t=a.translateLang)&&void 0!==t?t:n.targetLanguage,u=_.includes(c)?_:[c,..._],x=(e,t)=>{var r;n.retranslate(a,t),null===(r=e.closest("[data-answer-scroll]"))||void 0===r||r.scrollTo({top:1e9,behavior:"smooth"})};return(0,r.jsxs)("div",{className:"sticky top-0 z-10 -mx-5 -mt-5 px-5 pt-5 pb-3 mb-1 bg-white/95 dark:bg-[#0b0b0d]/95 backdrop-blur-sm border-b border-slate-200/60 dark:border-white/10 flex items-center gap-1.5 flex-wrap",children:[(0,r.jsx)("span",{className:"text-[10.5px] uppercase tracking-[0.1em] text-slate-400 dark:text-white/40 font-semibold mr-0.5",children:"Translate to"}),u.map(e=>(0,r.jsx)("button",{disabled:a.pending,onClick:t=>{e!==c&&x(t.currentTarget,e)},className:"text-[12px] font-semibold px-2.5 py-1 rounded-full border transition-colors disabled:opacity-50 ".concat(e===c?"border-pink-500/40 bg-pink-500/10 text-pink-600 dark:text-pink-300":"border-slate-200 dark:border-white/10 text-slate-600 dark:text-white/70 hover:border-pink-500/40 hover:text-pink-600 dark:hover:text-pink-300"),children:e},e)),o?(0,r.jsx)("form",{onSubmit:e=>{e.preventDefault();let t=s.trim();t&&(d(""),i(!1),x(e.currentTarget,t))},children:(0,r.jsx)("input",{autoFocus:!0,value:s,onChange:e=>d(e.target.value),onBlur:()=>!s.trim()&&i(!1),placeholder:"Language…",className:"w-28 bg-transparent border border-slate-300 dark:border-white/15 rounded-full px-2.5 py-1 text-[12px] text-slate-800 dark:text-white outline-none focus:border-pink-500/60"})}):(0,r.jsx)("button",{onClick:()=>i(!0),className:"text-[12px] font-semibold px-2.5 py-1 rounded-full border border-dashed border-slate-300 dark:border-white/15 text-slate-500 dark:text-white/50 hover:border-pink-500/40 hover:text-pink-600 dark:hover:text-pink-300 transition-colors",children:"Other…"})]})}function M(){return(0,r.jsx)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,
1children:(0,r.jsx)("path",{d:"M21 11.5a8.38 8.38 0 01-.9 3.8 8.5 8.5 0 01-7.6 4.7 8.38 8.38 0 01-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 01-.9-3.8 8.5 8.5 0 014.7-7.6 8.38 8.38 0 013.8-.9h.5a8.48 8.48 0 018 8v.5z"})})}function E(e){return"out_of_scope"===e?"That's outside what this entry covers — I can only answer from what's in it.":"insufficient_context"===e?"There isn't enough in this content to answer that.":""}let A=[{label:"Ask ChatGPT",url:e=>"https://chatgpt.com/?q=".concat(encodeURIComponent(e))},{label:"Ask Claude",url:e=>"https://claude.ai/new?q=".concat(encodeURIComponent(e))}];function R(e){let{status:t,suggestedPrompt:n}=e,a=E(t)||"I couldn't answer that from this entry.";return(0,r.jsxs)("div",{className:"mt-3 rounded-xl border border-slate-200 dark:border-white/10 bg-slate-50 dark:bg-white/[0.03] px-3.5 py-3",children:[(0,r.jsxs)("div",{className:"flex items-start gap-2 text-[14px] leading-[1.5] text-slate-600 dark:text-white/75",children:[(0,r.jsxs)("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,className:"mt-[2px] flex-none text-slate-400 dark:text-white/40",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,r.jsx)("path",{d:"M12 8h.01M11 12h1v4h1"})]}),(0,r.jsx)("span",{children:a})]}),n&&(0,r.jsxs)("div",{className:"mt-3",children:[(0,r.jsx)("p",{className:"text-[12px] text-slate-400 dark:text-white/45 mb-2",children:"Ask another AI with your question:"}),(0,r.jsx)("div",{className:"flex flex-wrap gap-2",children:A.map(e=>(0,r.jsxs)("a",{href:e.url(n),target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 text-[12.5px] font-semibold px-3 py-1.5 rounded-full border border-slate-200 dark:border-white/12 text-slate-700 dark:text-white/80 hover:border-purple-500/40 hover:text-purple-600 dark:hover:text-purple-300 transition-colors",children:[e.label,(0,r.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[(0,r.jsx)("path",{d:"M7 17 17 7"}),(0,r.jsx)("path",{d:"M8 7h9v9"})]})]},e.label))})]})]})}function q(e){let{id:t,text:n,pending:a,instant:l,status:o}=e,{text:i,typing:s}=L(n,t,a,l);return!a&&!n.trim()&&E(o)?(0,r.jsx)("p",{className:"text-[14px] leading-[1.55] text-slate-500 dark:text-white/55 italic",children:E(o)}):(0,r.jsxs)("div",{children:[(0,r.jsx)(m.m7,{text:(0,m.LT)("ask",i),className:"text-[14.5px] leading-[1.6] text-slate-700 dark:text-white/85"}),(s||a&&!n)&&(0,r.jsx)(w,{})]})}let D={define:"Define",explain:"Explain",ask:"Ask",summarize:"Summary",key_points:"Takeaways",translate:"Translate"};function B(e){let t=(0,l.useRef)(null);return(0,l.useEffect)(()=>{if(!e)return;let n=window.setTimeout(()=>{var e;return null===(e=t.current)||void 0===e?void 0:e.focus({preventScroll:!0})},80);return()=>window.clearTimeout(n)},[e]),t}function O(e){let{controller:t,variant:n="overlay"}=e,[o,i]=(0,l.useState)(!1);(0,l.useEffect)(()=>i(!0),[]);let s=(0,l.useRef)(null),d=t.sidebarOpen,c=t.close;if((0,l.useEffect)(()=>{if("overlay"!==n||!d)return;let e=e=>{var t,n;let r=e.target;!(!r||(null===(t=s.current)||void 0===t?void 0:t.contains(r)))&&(null!==(n=r.closest)&&void 0!==n&&n.call(r,'[role="toolbar"]')||c())};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[n,d,c]),!o)return null;let u=t.sidebarView,x=t.active;return(0,a.createPortal)((0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{onClick:c,"aria-hidden":!0,className:"fixed inset-0 z-[55] bg-black/40 sm:hidden transition-opacity duration-300 ".concat(d?"opacity-100":"opacity-0 pointer-events-none")}),(0,r.jsxs)("aside",{ref:s,role:"dialog","aria-label":"AI annotations","aria-hidden":!d,className:["fixed z-[56] flex flex-col bg-white dark:bg-[#0b0b0d] shadow-2xl","transition-transform duration-300 ease-out","inset-x-0 bottom-0 w-full h-[82vh] rounded-t-2xl border-t border-slate-200 dark:border-white/10","sm:inset-x-auto sm:inset-y-0 sm:right-0 sm:left-auto sm:w-[380px] sm:max-w-[92vw] sm:h-auto sm:rounded-t-none sm:border-t-0 sm:border-l",d?"translate-y-0 sm:translate-x-0":"translate-y-full sm:translate-y-0 sm:translate-x-full"].join(" "),children:[(0,r.jsx)("div",{className:"sm:hidden w-10 h-1 rounded-full bg-slate-300 dark:bg-white/20 mx-auto mt-2.5 mb-0.5 flex-none"}),"conv"===u&&x?(0,r.jsx)(W,{controller:t,record:x}):(0,r.jsx)(F,{controller:t}),(0,r.jsx)("div",{"data-answer-scroll":!0,className:"overflow-y-auto grow",children:"conv"===u&&x?(0,r.jsx)("div",{className:"p-5",children:(0,r.jsx)(T,{record:x,controller:t,hideHeader:!0})}):"list"===u?(0,r.jsx)(K,{controller:t}):(0,r.jsx)(P,{controller:t})})]})]}),document.body)}
1function F(e){let{controller:t}=e,n=t.sidebarView,a=t.spanFilter?t.records.filter(e=>(0,p.l)(e)===t.spanFilter).length:null,l=null!=a?a:"loaded"===t.loadState?t.totalCount:t.threadCount||void 0;return(0,r.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2.5 border-b border-slate-200 dark:border-white/10 flex-none",children:[(0,r.jsxs)("div",{className:"inline-flex bg-slate-100 dark:bg-white/[0.04] border border-slate-200 dark:border-white/10 rounded-[10px] p-0.5",children:[(0,r.jsx)(z,{label:"Ask",glyph:(0,r.jsx)(i.T$,{size:13}),on:"ask"===n,onClick:()=>t.goToView("ask")}),(0,r.jsx)(z,{label:"History",glyph:(0,r.jsx)(J,{}),count:l,on:"list"===n,onClick:()=>t.goToView("list")})]}),(0,r.jsx)("button",{onClick:t.close,"aria-label":"Close",className:"ml-auto w-7 h-7 rounded-lg text-slate-400 dark:text-white/40 hover:text-slate-800 dark:hover:text-white hover:bg-slate-100 dark:hover:bg-white/10 text-lg leading-none",children:"\xd7"})]})}function z(e){let{label:t,glyph:n,count:a,on:l,onClick:o}=e;return(0,r.jsxs)("button",{onClick:o,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[12.5px] font-semibold transition-colors ".concat(l?"bg-white dark:bg-white/[0.10] text-purple-700 dark:text-white shadow-sm":"text-slate-500 dark:text-white/55 hover:text-slate-800 dark:hover:text-white"),children:[(0,r.jsx)("span",{"aria-hidden":!0,className:"inline-flex ".concat(l?"text-purple-500 dark:text-purple-300":""),children:n})," ",t,"number"==typeof a&&a>0&&(0,r.jsx)("span",{className:"text-[10px] font-semibold leading-none px-1.5 py-[3px] rounded-full ".concat(l?"bg-purple-500/15 text-purple-700 dark:bg-purple-400/25 dark:text-purple-100":"bg-slate-200 text-slate-500 dark:bg-white/10 dark:text-white/55"),children:a})]})}function W(e){var t,n,a;let{controller:l,record:o}=e,s=null!==(a=l.scopes.find(e=>e.key===o.scopeKey))&&void 0!==a?a:l.ownScope;return(0,r.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2.5 border-b border-slate-200 dark:border-white/10 flex-none",children:[(0,r.jsx)("button",{onClick:()=>l.goToView("list"),"aria-label":"Back",className:"w-7 h-7 rounded-lg text-slate-500 dark:text-white/60 hover:text-slate-900 dark:hover:text-white hover:bg-slate-100 dark:hover:bg-white/10 text-base",children:"‹"}),(0,r.jsx)("span",{className:"text-[11px] font-bold uppercase tracking-[0.06em] px-2 py-1 rounded-md border ".concat(i.mq[o.operation]),children:D[o.operation]}),"span"===o.scope?(0,r.jsxs)("span",{className:"flex-1 min-w-0 truncate text-[12.5px] italic text-slate-500 dark:text-white/50",children:["“",null!==(n=null===(t=o.quote)||void 0===t?void 0:t.exact)&&void 0!==n?n:"","”"]}):(0,r.jsx)("span",{className:"flex-1 min-w-0",children:(0,r.jsx)(f,{scope:s})}),(0,r.jsx)("button",{onClick:l.close,"aria-label":"Close",className:"w-7 h-7 rounded-lg text-slate-400 dark:text-white/40 hover:text-slate-800 dark:hover:text-white hover:bg-slate-100 dark:hover:bg-white/10 text-lg leading-none",children:"\xd7"})]})}function P(e){var t;let{controller:n}=e,a=n.spanFilter&&null!==(t=n.records.find(e=>(0,p.l)(e)===n.spanFilter))&&void 0!==t?t:null;return(null==a?void 0:a.quote)?(0,r.jsx)(H,{controller:n,source:a}):(0,r.jsx)(U,{controller:n})}function H(e){let{controller:t,source:n}=e,[a,o]=(0,l.useState)(""),s=B(t.sidebarOpen),d=n.quote.exact,c=(0,p.l)(n),u=new Set(t.records.filter(e=>(0,p.l)(e)===c).map(e=>e.operation)),x=[{op:"define",icon:(0,r.jsx)(i.PS,{size:16}),title:"Define",subtitle:"What this means, in context"},{op:"explain",icon:(0,r.jsx)(i.B,{size:16}),title:"Explain",subtitle:"Unpack it in plain language"}].filter(e=>!u.has(e.op));return(0,r.jsxs)("div",{className:"p-5 flex flex-col gap-4",children:[(0,r.jsxs)("button",{onClick:t.clearSpanFilter,className:"flex items-center gap-1.5 text-[12px] font-semibold text-slate-500 dark:text-white/55 hover:text-purple-600 dark:hover:text-purple-300 self-start",children:["‹ Ask about the whole ",t.ownScope.noun]}),(0,r.jsxs)("div",{className:"flex items-start gap-2",children:[(0,r.jsx)("span",{className:"uppercase tracking-[0.1em] text-[10.5px] font-semibold text-slate-400 dark:text-white/35 mt-1 flex-none",children:"On"}),(0,r.jsxs)("span",{className:"text-[13px] italic text-slate-700 dark:text-white/75 leading-snug",children:["“",d,"”"]}
1)]}),x.length>0&&(0,r.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,r.jsx)("span",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-400 dark:text-white/40",children:"Suggested"}),x.map(e=>(0,r.jsx)(G,{icon:e.icon,title:e.title,subtitle:e.subtitle,onClick:()=>t.startSpanOp(n,e.op)},e.op))]}),(0,r.jsxs)("form",{onSubmit:e=>{e.preventDefault();let r=a.trim();r&&(o(""),t.startSpanOp(n,"ask",r))},className:"flex items-center gap-1.5 rounded-xl border border-slate-300 dark:border-white/15 bg-white dark:bg-white/[0.04] pl-3 pr-1.5 py-1.5 transition-colors focus-within:border-purple-500/60 focus-within:ring-2 focus-within:ring-purple-500/15",children:[(0,r.jsx)(Z,{className:"flex-none text-slate-400 dark:text-white/35"}),(0,r.jsx)("input",{ref:s,value:a,onChange:e=>o(e.target.value),placeholder:"Ask about this selection…",className:"flex-1 min-w-0 bg-transparent outline-none text-[14px] text-slate-800 dark:text-white placeholder:text-slate-400 dark:placeholder:text-white/35"}),(0,r.jsx)("button",{type:"submit",disabled:!a.trim(),"aria-label":"Ask",className:"flex-none w-8 h-8 rounded-lg bg-primary text-on-accent grid place-items-center disabled:opacity-40 disabled:cursor-not-allowed",children:(0,r.jsx)(ee,{})})]})]})}function U(e){let{controller:t}=e,[n,a]=(0,l.useState)(""),o=t.askScope,i=B(t.sidebarOpen),s=(e,n)=>t.startEntryAction(e,n);return(0,r.jsxs)("div",{className:"p-5 flex flex-col gap-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 text-[12px] text-slate-500 dark:text-white/45",children:[(0,r.jsx)("span",{className:"uppercase tracking-[0.1em] text-[10.5px] font-semibold text-slate-400 dark:text-white/35",children:"Grounded in"}),(0,r.jsx)(f,{scope:o})]}),(0,r.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,r.jsx)("span",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-400 dark:text-white/40",children:"Suggested"}),(0,r.jsx)(G,{icon:(0,r.jsx)(X,{}),title:"Summarize this ".concat(o.noun),subtitle:"A short recap of the whole thing",onClick:()=>s("summarize")}),(0,r.jsx)(G,{icon:(0,r.jsx)(Q,{}),title:"Key takeaways",subtitle:"The main points, as a list",onClick:()=>s("key_points")})]}),(0,r.jsxs)("form",{onSubmit:e=>{e.preventDefault();let t=n.trim();t&&(a(""),s("ask",t))},className:"flex items-center gap-1.5 rounded-xl border border-slate-300 dark:border-white/15 bg-white dark:bg-white/[0.04] pl-3 pr-1.5 py-1.5 transition-colors focus-within:border-purple-500/60 focus-within:ring-2 focus-within:ring-purple-500/15",children:[(0,r.jsx)(Z,{className:"flex-none text-slate-400 dark:text-white/35"}),(0,r.jsx)("input",{ref:i,value:n,onChange:e=>a(e.target.value),placeholder:"Ask about this ".concat(o.noun,"…"),className:"flex-1 min-w-0 bg-transparent outline-none text-[14px] text-slate-800 dark:text-white placeholder:text-slate-400 dark:placeholder:text-white/35"}),(0,r.jsx)("button",{type:"submit",disabled:!n.trim(),"aria-label":"Ask",className:"flex-none w-8 h-8 rounded-lg bg-primary text-on-accent grid place-items-center disabled:opacity-40 disabled:cursor-not-allowed",children:(0,r.jsx)(ee,{})})]}),(()=>{let e="loaded"===t.loadState?t.totalCount:t.threadCount;return e>0?(0,r.jsxs)("button",{onClick:()=>t.goToView("list"),className:"text-[12.5px] text-purple-600 dark:text-purple-300 font-semibold text-left hover:underline underline-offset-2",children:["≡ View history (",e,") →"]}):null})()]})}function K(e){let{controller:t}=e;if("loading"===t.loadState)return(0,r.jsxs)("div",{className:"flex flex-col items-center gap-3 py-10 text-slate-400 dark:text-white/40 text-[13px]",children:[(0,r.jsx)("span",{className:"w-4 h-4 rounded-full border-2 border-purple-500/30 border-t-purple-500 animate-spin"}),"Loading conversations…"]});if(t.spanFilter){var n,a,l;let e=t.records.filter(e=>(0,p.l)(e)===t.spanFilter),o=null!==(l=null===(a=e.find(e=>{var t;return null===(t=e.quote)||void 0===t?void 0:t.exact}))||void 0===a?void 0:null===(n=a.quote)||void 0===n?void 0:n.exact)&&void 0!==l?l:"this selection";return(0,r.jsxs)("div",{className:"p-4",children:[(0,r.jsx)("button",{onClick:t.clearSpanFilter,className:"flex items-center gap-1.5 text-[12px] font-semibold text-slate-500 dark:text-white/55 hover:text-purple-600 dar
1k:hover:text-purple-300 mb-1",children:"‹ All history"}),(0,r.jsxs)("div",{className:"text-[11px] uppercase tracking-[0.12em] text-slate-400 dark:text-white/40 font-semibold mb-2",children:[e.length," ",1===e.length?"conversation":"conversations"," on “",o,"”"]}),(0,r.jsx)("div",{className:"flex flex-col gap-2",children:e.map(e=>(0,r.jsx)($,{record:e,onClick:()=>t.openRecord(e.localId)},e.localId))})]})}return t.groups.length?(0,r.jsx)("div",{className:"p-4",children:t.groups.map(e=>(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 text-[10px] uppercase tracking-[0.12em] text-slate-400 dark:text-white/35 font-semibold sticky top-0 bg-white/95 dark:bg-[#0b0b0d]/95 py-1.5 mt-2 first:mt-0",children:[e.scope.label," \xb7 ",e.records.length]}),(0,r.jsx)("div",{className:"flex flex-col gap-2 pb-2",children:e.records.map(e=>(0,r.jsx)($,{record:e,onClick:()=>t.openRecord(e.localId)},e.localId))})]},e.scope.key))}):(0,r.jsxs)("div",{className:"px-5 py-10 text-center text-[13px] text-slate-400 dark:text-white/40",children:["No history yet.",(0,r.jsx)("br",{}),"Switch to ",(0,r.jsx)("b",{children:"Ask"})," to start a conversation."]})}function $(e){var t,n;let{record:a,onClick:l}=e;return(0,r.jsxs)("button",{onClick:l,className:"group flex items-center gap-2.5 w-full text-left px-3 py-2.5 rounded-xl border border-slate-200 dark:border-white/10 bg-slate-50 dark:bg-white/[0.02] hover:border-purple-500/40 hover:bg-purple-500/5 transition-colors",children:[(0,r.jsx)("span",{className:"flex-none text-[10px] font-bold uppercase tracking-[0.05em] px-1.5 py-0.5 rounded border ".concat(i.mq[a.operation]),children:D[a.operation]}),(0,r.jsx)("span",{className:"flex-1 min-w-0 truncate text-[13px] text-slate-700 dark:text-white/80",children:(null===(n=(t=a).question)||void 0===n?void 0:n.trim())||(0,m.Qj)(t).replace(/\s+/g," ").trim()||"Tap to open"}),"translate"===a.operation&&a.translateLang&&(0,r.jsx)("span",{className:"flex-none text-[10.5px] font-medium px-1.5 py-0.5 rounded-full bg-pink-500/10 text-pink-600 dark:text-pink-300 border border-pink-500/20",children:a.translateLang}),a.stale&&(0,r.jsx)("span",{className:"flex-none text-[10px] font-semibold text-amber-600 dark:text-amber-300",children:"outdated"}),V(a)>0&&(0,r.jsxs)("span",{className:"flex-none text-[10.5px] text-slate-400 dark:text-white/35",children:["+",V(a)]})]})}function G(e){let{icon:t,title:n,subtitle:a,onClick:l}=e;return(0,r.jsxs)("button",{onClick:l,className:"group flex items-center gap-3 w-full text-left px-3 py-2.5 rounded-xl border border-slate-200 dark:border-white/10 bg-slate-50 dark:bg-white/[0.03] hover:border-purple-500/40 hover:bg-purple-500/5 transition-colors",children:[(0,r.jsx)("span",{className:"flex-none w-8 h-8 rounded-lg bg-purple-500/15 text-purple-600 dark:text-purple-300 inline-flex items-center justify-center",children:t}),(0,r.jsxs)("span",{className:"flex-1 min-w-0",children:[(0,r.jsx)("span",{className:"block text-[14px] font-semibold text-slate-800 dark:text-white leading-tight",children:n}),(0,r.jsx)("span",{className:"block text-[12px] text-slate-500 dark:text-white/45 leading-tight mt-0.5",children:a})]}),(0,r.jsx)(Y,{className:"flex-none text-slate-300 dark:text-white/25 group-hover:text-purple-500 dark:group-hover:text-purple-300 transition-colors"})]})}function V(e){var t;return e.thread.length?e.thread.length:Math.max(0,(null!==(t=e.turnCount)&&void 0!==t?t:1)-1)}function J(){return(0,r.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[(0,r.jsx)("path",{d:"M3 3v5h5"}),(0,r.jsx)("path",{d:"M3.05 13A9 9 0 1 0 6 5.3L3 8"}),(0,r.jsx)("path",{d:"M12 7v5l3 2"})]})}function X(){return(0,r.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round","aria-hidden":!0,children:[(0,r.jsx)("line",{x1:"4",y1:"7",x2:"20",y2:"7"}),(0,r.jsx)("line",{x1:"4",y1:"12",x2:"20",y2:"12"}),(0,r.jsx)("line",{x1:"4",y1:"17",x2:"14",y2:"17"})]})}function Q(){return(0,r.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round","aria-hidden":!0,
1children:[(0,r.jsx)("line",{x1:"9",y1:"7",x2:"20",y2:"7"}),(0,r.jsx)("line",{x1:"9",y1:"12",x2:"20",y2:"12"}),(0,r.jsx)("line",{x1:"9",y1:"17",x2:"20",y2:"17"}),(0,r.jsx)("circle",{cx:"4.5",cy:"7",r:"1.3",fill:"currentColor",stroke:"none"}),(0,r.jsx)("circle",{cx:"4.5",cy:"12",r:"1.3",fill:"currentColor",stroke:"none"}),(0,r.jsx)("circle",{cx:"4.5",cy:"17",r:"1.3",fill:"currentColor",stroke:"none"})]})}function Y(e){let{className:t}=e;return(0,r.jsx)("svg",{className:t,width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:(0,r.jsx)("polyline",{points:"9 6 15 12 9 18"})})}function Z(e){let{className:t}=e;return(0,r.jsx)("svg",{className:t,width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:(0,r.jsx)("path",{d:"M21 11.5a8.38 8.38 0 01-.9 3.8 8.5 8.5 0 01-7.6 4.7 8.38 8.38 0 01-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 01-.9-3.8 8.5 8.5 0 014.7-7.6 8.38 8.38 0 013.8-.9h.5a8.48 8.48 0 018 8v.5z"})})}function ee(){return(0,r.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[(0,r.jsx)("line",{x1:"5",y1:"12",x2:"19",y2:"12"}),(0,r.jsx)("polyline",{points:"12 5 19 12 12 19"})]})}},12158:function(e,t,n){n.d(t,{B:function(){return i},Eg:function(){return u},PS:function(){return o},T$:function(){return d},mq:function(){return a}});var r=n(85893);let a={define:"bg-sky-500/15 text-sky-600 dark:text-sky-300 border-sky-500/30",explain:"bg-amber-500/15 text-amber-600 dark:text-amber-300 border-amber-500/30",ask:"bg-purple-500/15 text-purple-600 dark:text-purple-300 border-purple-500/30",summarize:"bg-emerald-500/15 text-emerald-600 dark:text-emerald-300 border-emerald-500/30",key_points:"bg-teal-500/15 text-teal-600 dark:text-teal-300 border-teal-500/30",translate:"bg-pink-500/15 text-pink-600 dark:text-pink-300 border-pink-500/30"},l=(e,t,n)=>(0,r.jsx)("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,className:"block flex-none".concat(t?" ".concat(t):""),children:n});function o(e){let{size:t=16,className:n}=e;return l(t,n,(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("path",{d:"M4 5a2 2 0 0 1 2-2h11a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1H6a2 2 0 0 0-2 2z"}),(0,r.jsx)("path",{d:"M8 7h6M8 11h6"})]}))}function i(e){let{size:t=16,className:n}=e;return l(t,n,(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("path",{d:"M9 18h6M10 21h4"}),(0,r.jsx)("path",{d:"M12 3a6 6 0 0 0-4 10.5c.6.6 1 1.2 1 2.5h6c0-1.3.4-1.9 1-2.5A6 6 0 0 0 12 3z"})]}))}function s(e){let{size:t=16,className:n}=e;return(0,r.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":!0,className:n,children:[(0,r.jsx)("path",{d:"M11 3.4a.62.62 0 0 1 1.18 0l1.1 3.3a3 3 0 0 0 1.9 1.9l3.3 1.1a.62.62 0 0 1 0 1.18l-3.3 1.1a3 3 0 0 0-1.9 1.9l-1.1 3.3a.62.62 0 0 1-1.18 0l-1.1-3.3a3 3 0 0 0-1.9-1.9l-3.3-1.1a.62.62 0 0 1 0-1.18l3.3-1.1a3 3 0 0 0 1.9-1.9z"}),(0,r.jsx)("path",{d:"M18.3 2.6a.4.4 0 0 1 .76 0l.52 1.55a1.6 1.6 0 0 0 1.01 1.01l1.55.52a.4.4 0 0 1 0 .76l-1.55.52a1.6 1.6 0 0 0-1.01 1.01l-.52 1.55a.4.4 0 0 1-.76 0l-.52-1.55a1.6 1.6 0 0 0-1.01-1.01l-1.55-.52a.4.4 0 0 1 0-.76l1.55-.52a1.6 1.6 0 0 0 1.01-1.01z"})]})}let d=s;function c(e){let{size:t=16,className:n}=e;return l(t,n,(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("path",{d:"M5 8l6 6"}),(0,r.jsx)("path",{d:"M4 14l6-6 2-3"}),(0,r.jsx)("path",{d:"M2 5h12"}),(0,r.jsx)("path",{d:"M7 2h1"}),(0,r.jsx)("path",{d:"M22 22l-5-10-5 10"}),(0,r.jsx)("path",{d:"M14 18h6"})]}))}function u(e){let{op:t,size:n,className:a}=e;return"define"===t?(0,r.jsx)(o,{size:n,className:a}):"explain"===t?(0,r.jsx)(i,{size:n,className:a}):"translate"===t?(0,r.jsx)(c,{size:n,className:a}):(0,r.jsx)(s,{size:n,className:a})}},62661:function(e,t,n){n.d(t,{W:function(){return c},w:function(){return d}});var r=n(85893),a=n(67421),l=n(36286),o=n(67294),i=n(95567);function s(e){let{memo:t}=e,{t:n}=(0,a.$G)(),s=(0,i.J)(),d=(0,o.useRef)(null),c=(0,o.useId)(),u=(0,o.useId)(),x=(0,o.useId)(),[h,p]=(0,o.useState)(0),[m,f]=(0,o.useState)(null),[g,b]=(0,o.useState)(!1),{bars:v,duration:k,currentTime:w,failed:j,opened:y,seekable:N,waveformSettled:C,reportBarCount:S}=t;(0,o.useEffect)(()=>
1{if(s){b(!0);return}let e=0,t=requestAnimationFrame(()=>{e=requestAnimationFrame(()=>b(!0))});return()=>{cancelAnimationFrame(t),cancelAnimationFrame(e)}},[s]),(0,o.useEffect)(()=>{let e=d.current;if(!e)return;let t=()=>p(e.clientWidth);t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);let L=h>0?(0,l.lJ)(h):l.qc;(0,o.useEffect)(()=>{S(L)},[L,S]);let T=N&&!j,_=(0,o.useCallback)(e=>{let t=d.current;if(!t)return 0;let n=t.getBoundingClientRect();return n.width<=0?0:Math.min(1,Math.max(0,(e-n.left)/n.width))},[]),I=(0,o.useCallback)(e=>{if(!T)return;e.preventDefault(),e.currentTarget.setPointerCapture(e.pointerId);let n=_(e.clientX);f(n),t.seekToRatio(n)},[T,_,t]),M=(0,o.useCallback)(e=>{if(null===m)return;let n=_(e.clientX);f(n),t.seekToRatio(n)},[m,_,t]),E=(0,o.useCallback)(e=>{null!==m&&(t.seekToRatio(_(e.clientX)),f(null))},[m,_,t]),A=(0,o.useCallback)(e=>{if(T){if("ArrowRight"===e.key)t.seekBy(5);else if("ArrowLeft"===e.key)t.seekBy(-5);else if("Home"===e.key)t.seekToRatio(0);else{if("End"!==e.key)return;t.seekToRatio(1)}e.preventDefault()}},[T,t]),R=(0,o.useMemo)(()=>v?(0,l.OQ)(v,L):Array(L).fill(.18),[v,L]),q=null!==v,D=Math.max(L*l.$j,1),B=null!=m?m:k>0?Math.min(1,w/k):0,O=(0,o.useMemo)(()=>R.map((e,t)=>{let n=Math.max(l.kj/26,e),a=Math.min(4*t,320),o={transform:"scaleY(".concat(g?n:0,")"),opacity:g?1:0,transformBox:"fill-box",transformOrigin:"center",transition:s?void 0:"transform 460ms cubic-bezier(0.16, 1, 0.3, 1) ".concat(a,"ms, opacity 260ms ease-out ").concat(a,"ms")};return(0,r.jsx)("rect",{x:t*l.$j,y:0,width:l.zV,height:26,rx:l.zV/2,style:o},t)}),[R,g,s]),F=!s&&!j&&y&&!C;return(0,r.jsxs)("div",{ref:d,role:T?"slider":void 0,tabIndex:T?0:void 0,"aria-label":T?n("audioPlayer.seek"):void 0,"aria-valuemin":T?0:void 0,"aria-valuemax":T?Math.round(k):void 0,"aria-valuenow":T?Math.round(w):void 0,"aria-valuetext":T?(0,l.D4)(w):void 0,onPointerDown:I,onPointerMove:M,onPointerUp:E,onPointerCancel:E,onKeyDown:A,onClick:e=>e.stopPropagation(),className:"relative block w-full py-[7px] touch-none select-none rounded focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-violet-500/40 ".concat(T?"cursor-pointer":""),style:{"--vm-sweep-from":"".concat(-96,"px"),"--vm-sweep-to":"".concat(D,"px")},children:[(0,r.jsxs)("svg",{width:"100%",height:26,viewBox:"0 0 ".concat(D," ").concat(26),preserveAspectRatio:"none",className:"block","aria-hidden":!0,children:[(0,r.jsxs)("defs",{children:[(0,r.jsx)("clipPath",{id:x,children:(0,r.jsx)("rect",{x:0,y:0,width:B*D,height:26})}),F&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("mask",{id:u,children:(0,r.jsx)("g",{fill:"#fff",children:O})}),(0,r.jsxs)("linearGradient",{id:c,gradientUnits:"userSpaceOnUse",x1:0,x2:96,children:[(0,r.jsx)("stop",{offset:"0",stopColor:"currentColor",stopOpacity:0}),(0,r.jsx)("stop",{offset:"0.5",stopColor:"currentColor",stopOpacity:.5}),(0,r.jsx)("stop",{offset:"1",stopColor:"currentColor",stopOpacity:0})]})]})]}),(0,r.jsx)("g",{className:q?"text-slate-900/25 dark:text-white/[0.22]":"text-slate-900/15 dark:text-white/[0.13]",fill:"currentColor",children:O}),!j&&(0,r.jsx)("g",{className:"text-violet-600 dark:text-violet-400",fill:"currentColor",clipPath:"url(#".concat(x,")"),children:O}),F&&(0,r.jsx)("g",{mask:"url(#".concat(u,")"),className:"text-violet-500",children:(0,r.jsx)("rect",{className:"vm-waveform-sweep",x:0,y:0,width:96,height:26,fill:"url(#".concat(c,")")})})]}),null!==m&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"absolute top-[7px] w-px bg-violet-600 dark:bg-violet-300",style:{height:26,left:"".concat(100*B,"%")},"aria-hidden":!0}),(0,r.jsx)("span",{className:"absolute -top-3 -translate-x-1/2 px-1.5 py-0.5 rounded bg-slate-900 dark:bg-white text-white dark:text-slate-900 text-[10px] font-mono font-semibold tabular-nums pointer-events-none z-10",style:{left:"".concat(100*B,"%")},"aria-hidden":!0,children:(0,l.D4)(B*k)})]})]})}function d(e){let{memo:t}=e;return(0,r.jsx)(s,{memo:t})}function c(e){let{memo:t}=e,{t:n}=(0,a.$G)();return t.failed?(0,r.jsx)("span",{className:"truncate",children:n("audioPlayer.loadFailed")}):(0,r.jsx)("span",{className:"tabular-nums flex-shrink-0",children:t.opened?"".concat((0,l.D4)(t.currentTime)," / ").concat((0,l.D4)(t.duration)):(0,l.D4)(t.duration)})}},59634:function(e,t,n){n.d(t,{C:function(){return c},e:function(){return d}});var r=n(67294),a=n(30146),l=n(79931),o=n(36286);let i=[1,1.5,2],s=new Set;function d(e,t,n){let[d,c]=(0,r.useState)(!1),[u,x]=(0,r.useState)(!1),[h,p]=(0,r.useState)(!1),[m,f]=(0,r.useState)(!1),[g,b]=(0,r.useState)(null),[v,k]=(0,r.useState)(!1),[w,j]=(0,r.useState)(0),[y,N]=(0,r.useState)(0),[C,S]=(0,r.useState)(1),L=(0,r.useRef)(null),T=(0,r.useRef)(null),_=(0,r.useRef)(null),I=(0,r.useRef)(!1),M=(0,r.useRef)(!0),E=(0,r.useRef)(o.qc),A=(0,r.useRef)(1),R=(0,r.useRef)({stop:()=>{}}
1),q=t.size_bytes,D=!q||q<=o.eC,B=(0,a.Xg)(t.signals);(0,r.useEffect)(()=>(M.current=!0,()=>{M.current=!1;let e=L.current;e&&(e.pause(),e.removeAttribute("src"),e.load()),T.current&&(URL.revokeObjectURL(T.current),T.current=null),L.current=null,_.current=null,I.current=!1}),[]),(0,r.useEffect)(()=>{if(!u)return;let e=0,t=()=>{let n=L.current;n&&j(n.currentTime),e=requestAnimationFrame(t)};return e=requestAnimationFrame(t),()=>cancelAnimationFrame(e)},[u]);let O=(0,r.useCallback)(()=>{var e;I.current=!1,p(!1),null===(e=L.current)||void 0===e||e.pause()},[]);(0,r.useEffect)(()=>{let e=R.current;return e.stop=O,s.add(e),()=>{s.delete(e)}},[O]);let F=(0,r.useCallback)(()=>{if(L.current)return L.current;let e=new Audio;return e.preload="metadata",e.playbackRate=A.current,e.addEventListener("play",()=>M.current&&x(!0)),e.addEventListener("pause",()=>M.current&&x(!1)),e.addEventListener("ended",()=>{M.current&&(x(!1),j(0))}),e.addEventListener("loadedmetadata",()=>{M.current&&(Number.isFinite(e.duration)&&N(e.duration),e.playbackRate=A.current)}),e.addEventListener("timeupdate",()=>{M.current&&e.paused&&j(e.currentTime)}),e.addEventListener("error",()=>{M.current&&e.getAttribute("src")&&f(!0)}),L.current=e,e},[]),z=(0,r.useCallback)(()=>{if(_.current)return _.current;let n=F();p(!0);let r=(async()=>{try{let{url:r}=await (0,a.X1)("",e,t.id,"original","inline");if(!M.current)return null;if(!D)return n.src=r,k(!0),p(!1),n;let l=await fetch(r);if(!l.ok)throw Error("audio fetch failed: ".concat(l.status));let i=await l.arrayBuffer();if(!M.current)return null;let s=URL.createObjectURL(new Blob([i],{type:t.content_type||"audio/mp4"}));if(T.current=s,n.src=s,p(!1),i.byteLength>o.eC)return k(!0),n;try{let e=await (0,o.xu)(i,E.current);M.current&&b(e)}catch(e){}finally{M.current&&k(!0)}return n}catch(e){if(_.current=null,!M.current)return null;return k(!0),p(!1),f(!0),console.error("Voice memo load failed",e),null}})();return _.current=r,r},[F,D,e,t.id,t.content_type]),W=(0,r.useCallback)(()=>{c(!0);let e=L.current;if(m)f(!1),_.current=null;else if(I.current){I.current=!1,p(!1);return}else if(e&&!e.paused){e.pause();return}s.forEach(e=>{e!==R.current&&e.stop()}),(0,l.j)("attachment_action",{action:"play",kind:"audio",from:n}),I.current=!0,z().then(e=>{e&&M.current&&I.current&&(I.current=!1,e.play().catch(()=>M.current&&f(!0)))})},[m,z,n]),P=(0,r.useCallback)(()=>{S(e=>{let t=i[(i.indexOf(e)+1)%i.length];return A.current=t,L.current&&(L.current.playbackRate=t),(0,l.j)("attachment_action",{action:"speed",kind:"audio",speed:t,from:n}),t})},[n]);return{opened:d,playing:u,loading:h,failed:m,seekable:y>0,bars:g,waveformSettled:v,duration:y>0?y:null!=B?B:0,currentTime:w,speed:C,toggle:W,cycleSpeed:P,seekToRatio:(0,r.useCallback)(e=>{let t=L.current;t&&Number.isFinite(t.duration)&&!(t.duration<=0)&&(t.currentTime=Math.min(1,Math.max(0,e))*t.duration,j(t.currentTime))},[]),seekBy:(0,r.useCallback)(e=>{let t=L.current;t&&Number.isFinite(t.duration)&&!(t.duration<=0)&&(t.currentTime=Math.min(t.duration,Math.max(0,t.currentTime+e)),j(t.currentTime))},[]),reportBarCount:(0,r.useCallback)(e=>{E.current=e},[])}}function c(e){return"".concat(e%1==0?e:e.toFixed(1),"\xd7")}},38649:function(e,t,n){n.d(t,{k:function(){return b}});var r=n(85893),a=n(67294),l=n(67421),o=n(19176),i=n(87414),s=n(4958),d=n(52491),c=n(32185),u=n(31907),x=n(30146),h=n(44265),p=n(99140),m=n(60245),f=n(82772),g=n(91005);function b(e){let{content:t,onClose:n}=e,l=(0,a.useRef)(null);if((0,a.useEffect)(()=>{if(!t)return;let e=e=>{"Escape"===e.key&&(e.preventDefault(),n())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[t,n]),(0,a.useEffect)(()=>{var e;t&&(null===(e=l.current)||void 0===e||e.focus())},[t]),!t)return null;let o="iframe"===t.kind;return(0,r.jsx)("div",{role:"dialog","aria-modal":"true","aria-labelledby":"reader-title",className:"fixed inset-0 z-50 bg-black/70 backdrop-blur-sm flex items-stretch justify-center p-4 sm:p-6 animate-textFadeIn",onClick:e=>{e.target===e.currentTarget&&n()},children:(0,r.jsx)("div",{className:"w-full ".concat(o?"max-w-[1240px]":"max-w-[820px]"," bg-white dark:bg-gray-900 rounded-2xl border border-slate-200 dark:border-white/15 shadow-2xl overflow-hidden flex flex-col transition-all duration-300 animate-fadeInDown"),onClick:e=>
1e.stopPropagation(),children:"prose"===t.kind?(0,r.jsx)(v,{content:t,onClose:n,closeButtonRef:l}):(t.kind,(0,r.jsx)(B,{content:t,onClose:n,closeButtonRef:l}))})})}function v(e){let{content:t,onClose:n,closeButtonRef:o}=e,{t:i}=(0,l.$G)(),s="transcript"===t.proseKind,{isProUser:m}=(0,h.a)(),{status:f,retry:g}=function(e,t,n){let[r,l]=(0,a.useState)(0),[o,i]=(0,a.useState)({kind:"loading"}),s=(0,a.useRef)(null),d=(0,a.useCallback)(()=>{let e=s.current;e&&(s.current=null,(0,x.XX)(e))},[]);return(0,a.useEffect)(()=>{let e=()=>d(),t=()=>{"hidden"===document.visibilityState&&d()};return window.addEventListener("beforeunload",e),document.addEventListener("visibilitychange",t),()=>{window.removeEventListener("beforeunload",e),document.removeEventListener("visibilitychange",t)}},[d]),(0,a.useEffect)(()=>{d();let r=!1,a=!1,l=null,o=null,c=Date.now(),u=0,h=()=>{a=!0,l&&clearTimeout(l),o&&clearTimeout(o)},p=async()=>{if(!r&&!a)try{let n=await (0,x.AW)("",e,t,{track:!0});if(r||a)return;h(),n.interaction_id&&!s.current&&(s.current=n.interaction_id),i({kind:"available",data:n})}catch(e){if(r||a)return;if(e instanceof x.MS){if(409===e.status){let t=function(e){if("object"!=typeof e||null===e)return null;let t=e.code;return"0413"===t||"0414"===t?t:null}(e.data);if("0414"===t){h();let t=e.data;i({kind:"needs-reprocess",access:(0,x.Lt)(t,n)});return}if("0413"===t){i({kind:"processing",slow:Date.now()-c>=15e3});let e=D[Math.min(u,D.length-1)];u+=1,l=setTimeout(p,e);return}h(),i({kind:"server-error"});return}if(404===e.status){h(),i({kind:"not-found"});return}if(415===e.status){h(),i({kind:"wrong-type"});return}}h(),i({kind:"server-error"})}};return i({kind:"loading"}),o=setTimeout(()=>{r||a||i(e=>"processing"===e.kind?{kind:"processing",slow:!0}:e)},15e3),p(),()=>{r=!0,h(),d()}},[e,t,r,d]),{status:o,retry:(0,a.useCallback)(()=>{l(e=>e+1)},[])}}(t.entryId,t.attachmentId,m),[b,v]=(0,a.useState)(!1),[k,j]=(0,a.useState)(!1),y=(0,a.useCallback)(async()=>{v(!0);try{await (0,x.ol)("",t.entryId),g()}catch(e){console.error("Reprocess failed",e)}finally{v(!1)}},[t.entryId,g]),T=(0,a.useMemo)(()=>{var e;return s?{url:void 0,domain:""}:"available"===f.kind&&f.data.source?{url:f.data.source.url,domain:f.data.source.domain||O(f.data.source.url)||""}:{url:t.initialSourceUrl,domain:null!==(e=t.initialSourceDomain)&&void 0!==e?e:O(t.initialSourceUrl)}},[s,f,t.initialSourceUrl,t.initialSourceDomain]),_="available"===f.kind?{savedAt:f.data.saved_at,crawledAt:f.data.crawled_at}:null,R=(0,a.useRef)(null),[q,B]=(0,a.useState)(0),F=(0,c.E)({entryId:t.entryId,rootRef:R,enabled:d.WD,autoLoad:d.WD,scopes:[{key:t.attachmentId,kind:"attachment",contentType:"attachment",attachmentId:t.attachmentId,label:"This article",noun:"article"}]}),z=(0,a.useCallback)(()=>{let e=R.current;if(!e){B(0);return}let t=e.scrollHeight-e.clientHeight;if(t<=0){B(0);return}B(Math.min(1,Math.max(0,e.scrollTop/t)))},[]);return(0,a.useLayoutEffect)(()=>{R.current&&(R.current.scrollTop=0),z()},[f.kind,z]),(0,a.useEffect)(()=>{let e=()=>z();return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[z]),(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("header",{className:"flex-shrink-0 flex items-center gap-3 px-4 py-3 bg-slate-100 dark:bg-white/[0.02]",children:[(0,r.jsx)("button",{ref:o,type:"button",onClick:n,"aria-label":i("reader.close"),className:"w-8 h-8 rounded-full inline-flex items-center justify-center bg-slate-200/80 dark:bg-white/[0.06] text-slate-500 dark:text-white/60 hover:text-slate-900 dark:hover:text-white transition-colors flex-shrink-0",children:(0,r.jsx)(P,{})}),(0,r.jsxs)("span",{className:"flex-1 min-w-0 flex items-center gap-2 text-xs",title:T.url||t.headerLabel||void 0,children:[(0,r.jsx)(J,{kind:s?"audio":"link"}),s?(0,r.jsx)("span",{className:"truncate text-slate-700 dark:text-white/80",children:t.headerLabel||i("reader.transcriptLabel")}):(0,r.jsx)(N,{url:T.url,fallbackDomain:T.domain})]}),_&&(0,r.jsx)(C,{..._}),F.enabled&&"available"===f.kind&&(0,r.jsxs)("button",{type:"button",onClick:F.openEntryAsk,className:"inline-flex items-center gap-1.5 flex-shrink-0 border border-purple-500/35 bg-purple-500/15 text-purple-600 dar
1k:text-purple-300 font-semibold text-xs px-3 py-1.5 rounded-full hover:bg-purple-500/25 transition-colors",children:[(0,r.jsx)("span",{"aria-hidden":!0,children:"✦"})," ",i("annotations.ask","Ask")]}),T.url?(0,r.jsx)(A,{url:T.url,signals:t.mediaSignals}):null]}),(0,r.jsx)("div",{className:"flex-shrink-0 relative h-[2px] bg-slate-200 dark:bg-white/[0.06]","aria-hidden":"true",children:(0,r.jsx)("div",{className:"absolute inset-0 bg-violet-500 dark:bg-violet-400/80 origin-left transition-transform duration-[80ms] linear",style:{transform:"scaleX(".concat("available"===f.kind?q:0,")"),willChange:"transform"}})}),(0,r.jsx)("div",{ref:R,onScroll:z,className:"flex-1 min-h-0 overflow-y-auto overscroll-contain",style:{overflowAnchor:"none"},children:"available"===f.kind?(0,r.jsx)(w,{data:f.data,aiSummary:t.aiSummary,hideAttribution:s,readSeconds:t.readSeconds}):"loading"===f.kind?(0,r.jsx)(S,{}):"processing"===f.kind?(0,r.jsx)(L,{tone:"processing",title:i(f.slow?"reader.states.slowTitle":"reader.states.preparingTitle"),body:i(f.slow?"reader.states.slowBody":"reader.states.preparingBody"),actions:f.slow&&T.url?(0,r.jsxs)(E,{href:T.url,children:[i("reader.openOriginal"),(0,r.jsx)(H,{})]}):null}):"needs-reprocess"===f.kind?(0,r.jsx)(L,{tone:"warn",title:i("unavailable"!==f.access?"reader.states.needsReprocessTitle":"reader.states.cantReadTitle"),body:i("unavailable"!==f.access?"reader.states.needsReprocessBody":"reader.states.cantReadBody"),actions:(0,r.jsxs)(r.Fragment,{children:["available"===f.access&&(0,r.jsxs)(I,{onClick:y,disabled:b,children:[(0,r.jsx)($,{}),i(b?"reader.states.reprocessing":"reader.states.reprocess")]}),"upgrade_required"===f.access&&(0,r.jsxs)(I,{onClick:()=>j(!0),children:[(0,r.jsx)($,{}),i("reader.states.reprocess")]}),T.url&&(0,r.jsxs)(E,{href:T.url,children:[i("reader.openOriginal"),(0,r.jsx)(H,{})]}),(0,r.jsx)(p.x,{isOpen:k,onClose:()=>j(!1),source:"reprocess",context:{entryId:t.entryId}})]})}):"not-found"===f.kind?(0,r.jsx)(L,{tone:"muted",title:i("reader.states.notFoundTitle"),body:i("reader.states.notFoundBody"),actions:(0,r.jsx)(M,{onClick:n,children:i("reader.close")})}):"wrong-type"===f.kind?(0,r.jsx)(L,{tone:"muted",title:i("reader.states.notFoundTitle"),body:i("reader.states.notFoundBody"),actions:T.url?(0,r.jsxs)(E,{href:T.url,children:[i("reader.openOriginal"),(0,r.jsx)(H,{})]}):(0,r.jsx)(M,{onClick:n,children:i("reader.close")})}):(0,r.jsx)(L,{tone:"warn",title:i("reader.states.errorTitle"),body:i("reader.states.errorBody"),actions:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(I,{onClick:g,children:[(0,r.jsx)($,{}),i("reader.states.tryAgain")]}),T.url&&(0,r.jsxs)(E,{href:T.url,children:[i("reader.openOriginal"),(0,r.jsx)(H,{})]})]})})}),(0,r.jsx)("footer",{className:"flex-shrink-0 px-4 py-2.5 border-t border-slate-200 dark:border-white/10 bg-slate-50/80 dark:bg-white/[0.02] text-center text-[11px] text-slate-400 dark:text-white/35 font-mono",children:i("reader.escToClose")}),F.enabled&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(u.dI,{controller:F}),(0,r.jsx)(u.z$,{controller:F})]})]})}let k={maskImage:"linear-gradient(to bottom, #000 calc(100% - 4.5rem), transparent 100%)",WebkitMaskImage:"linear-gradient(to bottom, #000 calc(100% - 4.5rem), transparent 100%)"},w=(0,a.memo)(function(e){var t,n,o;let{data:i,aiSummary:s,hideAttribution:d,readSeconds:c}=e,{t:u,i18n:h}=(0,l.$G)(),p=(0,a.useMemo)(()=>c&&c>0?Math.max(1,Math.round(c/60)):function(e){if(!e)return null;let t=e.replace(/```[\s\S]*?```/g," ").replace(/`[^`]+`/g," ").replace(/!\[[^\]]*\]\([^)]*\)/g," ").replace(/\[([^\]]*)\]\([^)]*\)/g,"$1").split(/\s+/).filter(Boolean).length;return 0===t?null:Math.max(1,Math.round(t/250))}(i.content_md),[c,i.content_md]),m=(0,a.useMemo)(()=>(function(e){let{authors:t,publishedAt:n,readMinutes:a,t:l}=e,o=[];return t&&t.length>0&&o.push((0,r.jsxs)("span",{children:[l("reader.byline.by")," ",function(e,t){let n=(e,t)=>e.url?(0,r.jsx)("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"text-slate-700 dark:text-white/85 underline decoration-white/15 hover:decoration-violet-400 underline-offset-[3px] transition-colors",children:e.name},t):(0,r.jsx)("span",{className:"text-slate-700 dark:text-white/85",children:e.name},t);if(1===e.length)return n(e[0],0);if(2===e.length)return(0,r.jsxs)(r.Fragment,{children:[n(e[0],0)," ",t("reader.byline.and")," ",n(e[1],1)]});let a=e.length-1;return(0,r.jsxs)(r.Fragment,{children:[n(e[0],0)," ",t("reader.byline.andOthers",{count:a})]})}(t,l)]},"authors")),n&&o.push((0,r.jsx)("span",{children:l("reader.byline.publishedOn",{date:(0,x.e)(n)})},"published")),a&&a>0&&o.push((0,r.jsx)("span",{children:l("reader.byline.readTime",{minutes:a})},"readtime")),o})({authors:i.authors,publishedAt:i.published_at,readMinutes:p,t:u}),[i.authors,i.published_at,p,u]),f=(null===(t=i.source)||void 0===t?void 0:t.domain)||O(null===(n=i.source)||void 0===n?void 0:n.url)||"",g=d?"":i.notice||(f?"\xa9 ".concat(f):"");return(0,r.jsx)("article",{className:"px-6 sm:px-12 py-8 sm:py-12",children:(0,r.jsxs)("div",{className:"max-w-[680px] mx-auto",children:[i.cover_image&&(0,r.jsx)(j,{cover:i.cover_image,fallbackAlt:i.title}),g&&(0,r.jsx)("p",{className:"text-[13px] leading-relaxed text-slate-500 dark:text-white/55 italic mb-6",children:(0,r.jsx)(W,{notice:g})}),(0,r.jsx)("h1",{id:"reader-title",dir:"auto",className:"font-display text-2xl sm:text-3xl font-bold tracking-tight text-slate-900 dark:text-white mb-2 leading-tight",children:i.title}),m.length>0&&(0,r.jsx)("p",{className:"text-sm text-slate-500 dark:text-white/55 mb-7 leading-relaxed",children:m.map((e,t)=>(0,r.jsxs)("span",{children:[t>0&&(0,r.jsx)("span",{className:"opacity-50 mx-2",children:"\xb7"}),e]},t))}),s&&(0,r.jsx)(y,{summary:s}),(0,r.jsx)("div",{style:i.content_truncated?k:void 0,children:(0,r.jsx)(z,{markdown:i.content_md})}),i.content_truncated&&(null===(o=i.source)||void 0===o?void 0:o.url)&&(0,r.jsxs)("div",{className:"mt-10 pt-6 border-t border-slate-200 dark:border-white/10 flex flex-col items-center gap-3 text-center",children:[(0,r.jsx)("p",{className:"text-[13px] leading-relaxed text-slate-500 dark:text-white/55 max-w-[440px]",children:u("reader.truncatedNote")}),(0,r.jsxs)("a",{href:i.source.url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 px-4 py-2 rounded-lg bg-primary hover:bg-primary-hover text-on-accent text-[13px] font-semibold transition-colors shadow-sm",children:[u("reader.readTheRest"),(0,r.jsx)(H,{})]})]})]})})});
1function j(e){let{cover:t,fallbackAlt:n}=e,a=t.width&&t.height?{aspectRatio:"".concat(t.width," / ").concat(t.height)}:{aspectRatio:"16 / 9"};return(0,r.jsx)("figure",{className:"w-full overflow-hidden rounded-xl mb-7 bg-slate-100 dark:bg-white/[0.04]",style:a,children:(0,r.jsx)("img",{src:t.url,alt:t.alt||n,loading:"lazy",decoding:"async",className:"w-full h-full object-cover"})})}function y(e){let{summary:t}=e,{t:n}=(0,l.$G)(),[o,i]=(0,a.useState)(!1),s=(0,a.useRef)(null),[d,c]=(0,a.useState)(0);return(0,a.useLayoutEffect)(()=>{s.current&&c(s.current.scrollHeight)},[t]),(0,r.jsxs)("section",{className:"mb-8 rounded-xl bg-violet-500/[0.06] border border-violet-500/15 hover:border-violet-500/25 transition-colors overflow-hidden",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>i(e=>!e),"aria-expanded":o,"aria-controls":"reader-ai-summary-content",className:"w-full flex items-center gap-2 px-4 py-3 text-left",children:[(0,r.jsx)("span",{className:"text-violet-500 dark:text-violet-400 flex-shrink-0",children:(0,r.jsx)(m.W,{size:10})}),(0,r.jsx)("span",{className:"flex-1 text-[11px] font-semibold uppercase tracking-[0.06em] text-slate-500 dark:text-white/55",children:n("reader.summary.label")}),(0,r.jsx)("span",{"aria-label":n(o?"reader.summary.collapse":"reader.summary.expand"),className:"text-slate-400 dark:text-white/40 transition-transform duration-[250ms] ease-out ".concat(o?"rotate-180":""),children:(0,r.jsx)(K,{})})]}),(0,r.jsx)("div",{id:"reader-ai-summary-content",style:{maxHeight:o?d:0},className:"overflow-hidden transition-[max-height] duration-[250ms] ease-out",children:(0,r.jsx)("div",{ref:s,dir:"auto",className:"px-4 pb-4 text-[15px] leading-relaxed text-slate-700 dark:text-white/85",children:t})})]})}function N(e){let{url:t,fallbackDomain:n}=e,l=(0,a.useMemo)(()=>{var e;return null!==(e=function(e){if(!e)return null;try{let t=new URL(e),n=t.host.replace(/^www\./,""),r="".concat(t.pathname).concat(t.search).concat(t.hash);return{domain:n,rest:"/"===r?"":r}}catch(e){return null}}(t))&&void 0!==e?e:{domain:null!=n?n:"",rest:""}},[t,n]),o=(0,a.useRef)(null),i=(0,a.useRef)(null);return(0,a.useLayoutEffect)(()=>{let e=o.current,t=i.current;if(!e||!t)return;if(!l.rest){t.textContent="";return}let n=()=>e.scrollWidth<=e.clientWidth,r=()=>{if(t.textContent=l.rest,n())return;let e=0,r=l.rest.length;for(;e<r;){let a=e+r+1>>1;t.textContent="".concat(l.rest.slice(0,a)," …"),n()?e=a:r=a-1}t.textContent="".concat(l.rest.slice(0,e)," …")};r();let a=new ResizeObserver(r);return a.observe(e),()=>a.disconnect()},[l.rest]),(0,r.jsxs)("span",{ref:o,className:"font-mono whitespace-nowrap overflow-hidden flex-1 min-w-0 text-slate-400 dark:text-white/35",children:[(0,r.jsx)("span",{className:"text-slate-700 dark:text-white/80",children:l.domain}),(0,r.jsx)("span",{ref:i,children:l.rest})]})}function C(e){let{savedAt:t,crawledAt:n}=e,{t:a}=(0,l.$G)(),o=(0,f.dB)(t),i=n?(0,f.dB)(n):"";return o||i?(0,r.jsxs)("span",{className:"hidden md:inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full bg-slate-200/60 dark:bg-white/[0.06] text-[11px] text-slate-500 dark:text-white/55 font-medium flex-shrink-0",children:[o&&(0,r.jsx)("span",{children:a("reader.savedAgo",{value:o})}),o&&i&&(0,r.jsx)("span",{className:"opacity-50",children:"\xb7"}),i&&(0,r.jsx)("span",{children:a("reader.updatedAgo",{value:i})})]}):null}function S(){return(0,r.jsx)("div",{className:"px-6 sm:px-12 py-8 sm:py-12","aria-busy":"true",children:(0,r.jsxs)("div",{className:"max-w-[680px] mx-auto animate-pulse",children:[(0,r.jsx)("div",{className:"w-full aspect-[16/9] rounded-xl bg-white/[0.06] mb-7"}),(0,r.jsx)("div",{className:"h-[18px] w-32 rounded bg-white/[0.06] mb-4"}),(0,r.jsx)("div",{className:"h-8 w-[88%] rounded bg-white/[0.06] mb-2.5"}),(0,r.jsx)("div",{className:"h-8 w-[62%] rounded bg-white/[0.06] mb-5"}),(0,r.jsx)("div",{className:"h-[14px] w-[340px] max-w-full rounded bg-white/[0.06] mb-8"}),(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsx)("div",{className:"h-4 w-full rounded bg-white/[0.06]"}),(0,r.jsx)("div",{className:"h-4 w-[95%] rounded bg-white/[0.06]"}),(0,r.jsx)("div",{className:"h-4 w-[92%] rounded bg-white/[0.06]"}),(0,r.jsx)("div",{className:"h-4 w-[88%] rounded bg-white/[0.06]"}),(0,r.jsx)("div",{className:"h-4 w-[78%] rounded bg-white/[0.06]"}),(0,r.jsx)("div",{className:"h-4 w-[65%] rounded bg-white/[0.06]"})]})]})})}function L(e){let{tone:t,title:n,body:a,actions:l}=e;return(0,r.jsx)("div",{className:"px-6 py-12 flex items-start justify-center",children:(0,r.jsxs)("div",{className:"max-w-[460px] text-center pt-8",children:["processing"===t?(0,r.jsx)(_,{}):"warn"===t?(0,r.jsx)(T,{variant:"warn",children:(0,r.jsx)(G,{})}):(0,r.jsx)(T,{variant:"muted",children:(0,r.jsx)(V,{})}),(0,r.jsx)("h2",{className:"font-display text-xl font-semibold text-slate-900 dark:text-white mb-2.5",children:n}),(0,r.jsx)("p",{className:"text-sm leading-relaxed text-slate-500 dark:text-white/55 mb-6",children:a}),l&&(0,r.jsx)("div",{className:"flex gap-2.5 justify-center flex-wrap",children:l})]})})}function T(e){let{variant:t,children:n}=e;return(0,r.jsx)("div",{className:"w-9 h-9 mx-auto mb-5 rounded-full inline-flex items-center justify-center ".concat("warn"===t?"text-amber-500 bg-amber-500/10":"text-slate-500 dark:text-white/55 bg-slate-200/60 dark:bg-white/[0.06]"),"aria-hidden":"true",children:n})}function _(){return(0,r.jsxs)("div",{className:"relative w-3 h-3 mx-auto mb-7","aria-hidden":"true",children:[(0,r.jsx)("span",{className:"absolute inset-0 rounded-full bg-violet-400 animate-ping"}),(0,r.jsx)("span",{className:"relative block w-3 h-3 rounded-full bg-violet-600"})]})}function I(e){let{children:t,onClick:n,disabled:a}=e;return(0,r.jsx)("button",{type:"button",onClick:n,disabled:a,className:"inline-flex items-center gap-1.5 px-4 py-2 rounded-lg bg-primary hover:bg-primary-hover text-on-accent disabled:opacity-60 disabled:cursor-not-allowed text-[13px] font-medium transition-colors",children:t})}function M(e){let{children:t,onClick:n}=e;return(0,r.jsx)("button",{type:"button",onClick:n,className:"inline-flex items-center gap-1.5 px-4 py-2 rounded-lg bg-slate-200/60 dark:bg-white/[0.06] hover:bg-slate-200 dark:hover:bg-white/10 text-slate-700 dark:text-white/85 text-[13px] font-medium transition-colors border border-slate-200 dark:border-white/10",children:t})}function E(e){let{children:t,href:n}=e;return(0,r.jsx)("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 px-4 py-2 rounded-lg bg-slate-200/60 dark:bg-white/[0.06] hover:bg-slate-200 dark:hover:bg-white/10 text-slate-700 dark:text-white/85 text-[13px] font-medium transition-colors border border-slate-200 dark:border-white/10",children:t})}function A(e){var t,n,a;let o,{url:i,signals:s}=e,{t:d}=(0,l.$G)(),c=null!==(t=null==s?void 0:s.hasVideo)&&void 0!==t&&t,u=null!==(n=null==s?void 0:s.hasAudio)&&void 0!==n&&n,x=null!==(a=null==s?void 0:s.hasLiveMedia)&&void 0!==a&&a,h=(null==s?void 0:s.isPrimary)!==!1;return c||u?h?(o=d(c&&u?x?"reader.openLive":"reader.openOriginal":c?x?"reader.watchLive":"reader.watchOriginal":x?"reader.listenLive":"reader.listenOriginal"),(0,r.jsxs)("a",{href:i,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md bg-primary hover:bg-primary-hover text-on-accent text-xs font-semibold transition-colors flex-shrink-0 shadow-sm",children:[c&&(0,r.jsx)(R,{}),u&&(0,r.jsx)(q,{}),o,(0,r.jsx)(H,{})]})):(0,r.jsxs)("a",{href:i,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md bg-slate-200/60 dark:bg-white/[0.06] hover:bg-slate-200 dark:hover:bg-white/10 text-slate-700 dark:text-white/80 text-xs font-medium transition-colors flex-shrink-0",children:[c&&(0,r.jsx)(R,{}),u&&(0,r.jsx)(q,{}),d("reader.openOriginal"),(0,r.jsx)(H,{})]}):(0,r.jsxs)("a",{href:i,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md bg-slate-200/60 dark:bg-white/[0.06] hover:bg-slate-200 dark:hover:bg-white/10 text-slate-700 dark:text-white/80 text-xs font-medium transition-colors flex-shrink-0",children:[d("reader.openOriginal"),(0,r.jsx)(H,{})]})}function R(){return(0,r.jsx)("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"
1currentColor","aria-hidden":!0,children:(0,r.jsx)("path",{d:"M8 5v14l11-7z"})})}function q(){return(0,r.jsxs)("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[(0,r.jsx)("path",{d:"M3 18v-6a9 9 0 0 1 18 0v6"}),(0,r.jsx)("path",{d:"M21 19a2 2 0 0 1-2 2h-1v-7h3v5zM3 19a2 2 0 0 0 2 2h1v-7H3v5z"})]})}let D=[2e3,4e3,8e3,15e3];function B(e){var t,n,o;let{content:i,onClose:s,closeButtonRef:x}=e,{t:h}=(0,l.$G)(),p="iframe"===i.kind,m="text"===i.kind?i:null,f=(0,a.useRef)(null),g=(0,c.E)({entryId:null!==(t=null==m?void 0:m.entryId)&&void 0!==t?t:"",rootRef:f,enabled:d.WD&&!!(null==m?void 0:m.entryId)&&!!(null==m?void 0:m.attachmentId),autoLoad:d.WD&&!!(null==m?void 0:m.entryId)&&!!(null==m?void 0:m.attachmentId),scopes:[{key:null!==(n=null==m?void 0:m.attachmentId)&&void 0!==n?n:"attachment",kind:"attachment",contentType:"attachment",attachmentId:null!==(o=null==m?void 0:m.attachmentId)&&void 0!==o?o:null,label:(null==m?void 0:m.sourceLabel)||"This file",noun:"file"}]});return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("header",{className:"flex-shrink-0 flex items-center gap-3 px-4 py-3 border-b border-slate-200 dark:border-white/10 bg-slate-50/80 dark:bg-white/[0.02]",children:[(0,r.jsx)("button",{ref:x,type:"button",onClick:s,"aria-label":h("reader.close"),className:"w-8 h-8 rounded-full inline-flex items-center justify-center bg-slate-200/60 dark:bg-white/[0.06] text-slate-500 dark:text-white/60 hover:text-slate-900 dark:hover:text-white transition-colors flex-shrink-0",children:(0,r.jsx)(P,{})}),(0,r.jsxs)("span",{className:"flex-1 min-w-0 flex items-center gap-2 text-xs text-slate-500 dark:text-white/55",children:[(0,r.jsx)(J,{kind:p?"pdf":"text"}),(0,r.jsx)("span",{className:"font-mono truncate",children:i.sourceLabel})]}),g.enabled&&(0,r.jsxs)("button",{type:"button",onClick:g.openEntryAsk,className:"inline-flex items-center gap-1.5 flex-shrink-0 border border-purple-500/35 bg-purple-500/15 text-purple-600 dark:text-purple-300 font-semibold text-xs px-3 py-1.5 rounded-full hover:bg-purple-500/25 transition-colors",children:[(0,r.jsx)("span",{"aria-hidden":!0,children:"✦"})," ",h("annotations.ask","Ask")]}),(0,r.jsxs)("a",{href:i.downloadUrl,download:i.downloadFilename,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md bg-slate-200/60 dark:bg-white/[0.06] hover:bg-slate-200 dark:hover:bg-white/10 text-slate-700 dark:text-white/80 text-xs font-medium transition-colors flex-shrink-0",children:[h("reader.download"),(0,r.jsx)(U,{})]})]}),"iframe"===i.kind?(0,r.jsx)("div",{className:"flex-1 min-h-0 bg-[#525659]",children:(0,r.jsx)("iframe",{src:function(e){let[t,n=""]=e.split("#"),r=["navpanes=0","view=FitH"];return n&&r.unshift(n),"".concat(t,"#").concat(r.join("&"))}(i.iframeSrc),title:i.sourceLabel,className:"w-full h-full border-0 block"},i.iframeSrc)}):(0,r.jsxs)("div",{ref:f,className:"flex-1 min-h-0 overflow-y-auto px-6 sm:px-12 py-8 sm:py-12",children:[(0,r.jsx)("h1",{id:"reader-title",className:"font-display font-mono text-base sm:text-lg font-semibold text-slate-900 dark:text-white mb-6 break-all",children:i.sourceLabel}),(0,r.jsx)(z,{markdown:i.markdown})]}),(0,r.jsx)("footer",{className:"flex-shrink-0 px-4 py-2.5 border-t border-slate-200 dark:border-white/10 bg-slate-50/80 dark:bg-white/[0.02] text-center text-[11px] text-slate-400 dark:text-white/35 font-mono",children:h("reader.escToClose")}),g.enabled&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(u.dI,{controller:g}),(0,r.jsx)(u.z$,{controller:g})]})]})}function O(e){if(e)try{return new URL(e).host.replace(/^www\./,"")}catch(e){return}}let F={h1:e=>{let{node:t,...n}=e;return(0,r.jsx)("h1",{dir:"auto",className:"font-display text-2xl sm:text-[28px] font-semibold text-slate-900 dark:text-white mt-9 mb-4 leading-tight",...n})},h2:e=>{let{node:t,...n}=e;return(0,r.jsx)("h2",{dir:"auto",className:"font-display text-xl sm:text-2xl font-semibold text-slate-900 dark:text-white mt-9 mb-3 leading-tight",...n})},h3:e=>{let{node:t,...n}=e;return(0,r.jsx)("h3",{dir:"auto",className:"font-display text-lg font-semibold text-slate-900 dark:text-white mt-6 mb-2.5 leading-snug",...n})},p:e=>{let{node:t,...n}=e;return(0,r.jsx)("p",{dir:"auto",className:"text-[18px] leading-[1.65] text-slate-700 dark:text-white/85 my-5",...n})},a:e=>{let{node:t,...n}=e;
1return(0,r.jsx)(i.mi,{className:"text-violet-600 dark:text-violet-300 underline decoration-violet-500/40 hover:decoration-violet-500",target:"_blank",rel:"noopener noreferrer",...n})},code:e=>{let{node:t,...n}=e;return(0,r.jsx)("code",{className:"font-mono text-[0.92em] px-1.5 py-0.5 rounded bg-slate-100 dark:bg-white/10 text-slate-700 dark:text-white/80",...n})},pre:e=>{var t,n,a;let{node:l}=e,o=null==l?void 0:null===(t=l.children)||void 0===t?void 0:t.find(e=>"code"===e.tagName),i=(null==o?void 0:null===(a=o.properties)||void 0===a?void 0:null===(n=a.className)||void 0===n?void 0:n[0])||"",s=/language-(\w+)/.exec(i),d=s?s[1]:"",c=e=>"text"===e.type?e.value||"":(e.children||[]).map(c).join(""),u=o?c(o):"";return(0,r.jsx)("div",{className:"my-6",children:(0,r.jsx)(g.d,{language:d,inline:!1,children:u})})},ul:e=>{let{node:t,...n}=e;return(0,r.jsx)("ul",{dir:"auto",className:"list-disc ps-6 my-5 space-y-2 text-[18px] leading-[1.65] text-slate-700 dark:text-white/85",...n})},ol:e=>{let{node:t,...n}=e;return(0,r.jsx)("ol",{dir:"auto",className:"list-decimal ps-6 my-5 space-y-2 text-[18px] leading-[1.65] text-slate-700 dark:text-white/85",...n})},li:e=>{let{node:t,...n}=e;return(0,r.jsx)("li",{dir:"auto",...n})},blockquote:e=>{let{node:t,...n}=e;return(0,r.jsx)("blockquote",{dir:"auto",className:"border-s-2 border-violet-500/40 ps-4 italic text-slate-600 dark:text-white/70 my-6",...n})},table:e=>{let{node:t,...n}=e;return(0,r.jsx)("div",{className:"my-5 overflow-x-auto",children:(0,r.jsx)("table",{dir:"auto",className:"w-full border-collapse text-sm text-slate-700 dark:text-white/80",...n})})},thead:e=>{let{node:t,...n}=e;return(0,r.jsx)("thead",{className:"bg-slate-100 dark:bg-white/[0.04]",...n})},tbody:e=>{let{node:t,...n}=e;return(0,r.jsx)("tbody",{...n})},tr:e=>{let{node:t,...n}=e;return(0,r.jsx)("tr",{className:"border-b border-slate-200 dark:border-white/10",...n})},th:e=>{let{node:t,...n}=e;return(0,r.jsx)("th",{className:"text-left px-3 py-2 text-slate-900 dark:text-white/90 font-semibold",...n})},td:e=>{let{node:t,...n}=e;return(0,r.jsx)("td",{className:"px-3 py-2 align-top",...n})},hr:e=>{let{node:t,...n}=e;return(0,r.jsx)("hr",{className:"border-slate-200 dark:border-white/10 my-8",...n})},strong:e=>{let{node:t,...n}=e;return(0,r.jsx)("strong",{...n})},em:e=>{let{node:t,...n}=e;return(0,r.jsx)("em",{...n})},img:e=>{let{node:t,src:n,alt:a,...l}=e,o="string"==typeof n?n:"";return o&&(/abs\.twimg\.com\/emoji\//i.test(o)||/\/twemoji[/.@-]/i.test(o)||/s\.w\.org\/images\/core\/emoji\//i.test(o)||/github(usercontent)?\.com\/.*\/emoji\//i.test(o)||/\/images\/emoji\//i.test(o))?(0,r.jsx)("img",{src:o,alt:a||"",style:{display:"inline-block",width:"1.1em",height:"1.1em",margin:"0 0.05em",verticalAlign:"-0.15em"},...l}):(0,r.jsx)("img",{src:o,alt:a||"",loading:"eager",decoding:"async",className:"max-w-full h-auto rounded-lg my-6 mx-auto",...l})}};function z(e){let{markdown:t}=e;return(0,r.jsx)("div",{className:"prose prose-slate dark:prose-invert max-w-none",children:(0,r.jsx)(o.UG,{remarkPlugins:[s.Z],components:F,children:t})})}function W(e){let{notice:t}=e,n=(0,a.useMemo)(()=>t.replace(/([\w.-]+\.[a-z]{2,})\s+\((https?:\/\/[^\s)]+)\)/gi,(e,t,n)=>"[".concat(t,"](<").concat(n,">)")),[t]);return(0,r.jsx)(o.UG,{remarkPlugins:[s.Z],components:{p:e=>{let{...t}=e;return(0,r.jsx)("span",{...t})},a:e=>{let{...t}=e;return(0,r.jsx)(i.mi,{className:"text-violet-600 dark:text-violet-400 underline decoration-violet-500/40 hover:decoration-violet-500",target:"_blank",rel:"noopener noreferrer",...t})}},children:n})}function P(){return(0,r.jsx)("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:(0,r.jsx)("path",{d:"M18 6L6 18M6 6l12 12"})})}function H(){return(0,r.jsxs)("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[(0,r.jsx)("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),(0,r.jsx)("polyline",{points:"15 3 21 3 21 9"}),(0,r.jsx)("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]})}function U(){return(0,r.jsxs)("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,
1children:[(0,r.jsx)("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),(0,r.jsx)("polyline",{points:"7 10 12 15 17 10"}),(0,r.jsx)("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]})}function K(){return(0,r.jsx)("svg",{viewBox:"0 0 24 24",width:"14",height:"14",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:(0,r.jsx)("polyline",{points:"6 9 12 15 18 9"})})}function $(){return(0,r.jsxs)("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[(0,r.jsx)("polyline",{points:"23 4 23 10 17 10"}),(0,r.jsx)("path",{d:"M20.49 15a9 9 0 1 1-2.12-9.36L23 10"})]})}function G(){return(0,r.jsxs)("svg",{className:"w-[18px] h-[18px]",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[(0,r.jsx)("path",{d:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),(0,r.jsx)("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),(0,r.jsx)("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]})}function V(){return(0,r.jsxs)("svg",{className:"w-[18px] h-[18px]",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[(0,r.jsx)("polyline",{points:"21 8 21 21 3 21 3 8"}),(0,r.jsx)("rect",{x:"1",y:"3",width:"22",height:"5"}),(0,r.jsx)("line",{x1:"10",y1:"12",x2:"14",y2:"12"})]})}function J(e){let{kind:t}=e,n="w-3.5 h-3.5 ".concat("text-slate-500 dark:text-white/55"," flex-shrink-0");return"audio"===t?(0,r.jsxs)("svg",{className:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round","aria-hidden":!0,children:[(0,r.jsx)("line",{x1:"4",y1:"10",x2:"4",y2:"14"}),(0,r.jsx)("line",{x1:"8",y1:"6",x2:"8",y2:"18"}),(0,r.jsx)("line",{x1:"12",y1:"9",x2:"12",y2:"15"}),(0,r.jsx)("line",{x1:"16",y1:"4",x2:"16",y2:"20"}),(0,r.jsx)("line",{x1:"20",y1:"10",x2:"20",y2:"14"})]}):"link"===t?(0,r.jsxs)("svg",{className:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,r.jsx)("path",{d:"M2 12h20"}),(0,r.jsx)("path",{d:"M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"})]}):"text"===t?(0,r.jsxs)("svg",{className:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[(0,r.jsx)("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),(0,r.jsx)("polyline",{points:"14 2 14 8 20 8"}),(0,r.jsx)("line",{x1:"8",y1:"13",x2:"16",y2:"13"}),(0,r.jsx)("line",{x1:"8",y1:"17",x2:"14",y2:"17"})]}):(0,r.jsxs)("svg",{className:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[(0,r.jsx)("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),(0,r.jsx)("polyline",{points:"14 2 14 8 20 8"})]})}},82772:function(e,t,n){n.d(t,{QG:function(){return s},Uz:function(){return d},dB:function(){return c}});let r=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=new Date(e);return r.setHours(t,n,0,0),r},a=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Date,t=r(e,18);if(t.getTime()-e.getTime()>36e5)return t;let n=r(e,21);return n.getTime()-e.getTime()>18e5?n:null},l=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Date,t=r(e,8);return t.setDate(t.getDate()+1),t},o=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Date,t=(6-e.getDay()+7)%7;0===t&&(t=7);let n=r(e,8);return n.setDate(n.getDate()+t),n},i=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Date,t=(1-e.getDay()+7)%7;0===t&&(t=7);let n=r(e,8);return n.setDate(n.getDate()+t),n},s=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Date,t=[],n=a(e);
1n&&t.push({kind:"laterToday",date:n,iso:n.toISOString()});let r=l(e);t.push({kind:"tomorrow",date:r,iso:r.toISOString()});let s=o(e);t.push({kind:"weekend",date:s,iso:s.toISOString()});let d=i(e);return t.push({kind:"nextWeek",date:d,iso:d.toISOString()}),t},d=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new Date,r=e.toDateString()===n.toDateString(),a=new Intl.DateTimeFormat(t,{hour:"numeric",minute:"2-digit"}).format(e);if(r)return a;let l=new Intl.DateTimeFormat(t,{weekday:"short"}).format(e);return"".concat(l," ").concat(a)},c=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new Date;if(!e)return"";let r=new Date(e);if(Number.isNaN(r.getTime()))return"";let a=Math.max(0,Math.floor((n.getTime()-r.getTime())/1e3));if(a<60)return"just now";let l=Math.floor(a/60);if(l<60)return"".concat(l,"m ago");let o=Math.floor(l/60);if(o<24)return"".concat(o,"h ago");let i=Math.floor(o/24);return i<7?"".concat(i,"d ago"):new Intl.DateTimeFormat(t,{month:"short",day:"numeric",year:r.getFullYear()!==n.getFullYear()?"numeric":void 0}).format(r)}},52491:function(e,t,n){n.d(t,{Cq:function(){return a},Es:function(){return l},WD:function(){return r},e:function(){return o}});
1let r="false"!==n(83454).env.NEXT_PUBLIC_CONTENT_ANNOTATIONS_ENABLED,a={document:e=>"entry/".concat(e,"/document"),annotations:e=>"entry/".concat(e,"/annotations"),threads:e=>"entry/".concat(e,"/threads")},l=2e3,o=32},32185:function(e,t,n){n.d(t,{l:function(){return u},E:function(){return v}});var r=n(67294),a=n(91292),l=n(1094),o=n(52491);function i(e,t){var n,r;let{exact:a}=t;if(!a)return null;let l=[],o=0;for(;l.length<500;){let t=e.indexOf(a,o);if(-1===t)break;l.push(t),o=t+1}if(0===l.length)return null;if(1===l.length)return{start:l[0],end:l[0]+a.length};let i=null!==(n=t.prefix)&&void 0!==n?n:"",s=null!==(r=t.suffix)&&void 0!==r?r:"",d=l[0],c=-1;for(let t of l){let n=e.slice(Math.max(0,t-i.length),t),r=e.slice(t+a.length,t+a.length+s.length),l=function(e,t){let n=Math.min(e.length,t.length),r=0;for(;r<n&&e[e.length-1-r]===t[t.length-1-r];)r++;return r}(n,i)+function(e,t){let n=Math.min(e.length,t.length),r=0;for(;r<n&&e[r]===t[r];)r++;return r}(r,s);l>c&&(c=l,d=t)}return{start:d,end:d+a.length}}function s(e,t){let n=document.createElement("span");n.className=t;try{e.surroundContents(n)}
1catch(t){try{n.appendChild(e.extractContents()),e.insertNode(n)}catch(e){return null}}return n}function d(e){let t=e.parentNode;if(t){for(;e.firstChild;)t.insertBefore(e.firstChild,e);t.removeChild(e),t.normalize()}}var c=n(46575);function u(e){var t,n;return e.anchorHash?e.anchorHash:e.quote?"".concat(e.scopeKey,"|").concat(e.quote.exact,"|").concat(null!==(t=e.quote.prefix)&&void 0!==t?t:"","|").concat(null!==(n=e.quote.suffix)&&void 0!==n?n:""):null}let x="noax-annot",h="You're going a bit fast. Please wait a moment, then try again.",p=new Set(["summarize","key_points"]),m="noax:annotations:targetLanguage";function f(){return window.localStorage.getItem(m)||"English"}let g=0,b=()=>"annot-".concat(Date.now().toString(36),"-").concat((g++).toString(36));function v(e){var t;let{entryId:n,entryVersion:c,scopes:p,rootRef:g,enabled:v,autoLoad:y,threadCount:N,onToast:C}=e,S=p[0],L=S.contentType,T=S.attachmentId,[_,I]=(0,r.useState)({visible:!1,x:0,y:0,operations:[],context:"selection"}),[M,E]=(0,r.useState)([]),A=(0,r.useRef)(M);A.current=M;let[R,q]=(0,r.useState)(null),[D,B]=(0,r.useState)(!1),[O,F]=(0,r.useState)("ask"),[z,W]=(0,r.useState)("idle"),[P,H]=(0,r.useState)(null),[U,K]=(0,r.useState)(null),$=(0,r.useRef)(null),G=(0,r.useRef)(""),V=(0,r.useRef)(null),[J,X]=(0,r.useState)(f),Q=(0,r.useRef)(J);Q.current=J;let Y=(0,r.useCallback)(e=>{let t=e.trim();t&&(X(t),function(e){try{window.localStorage.setItem(m,e)}catch(e){}}(t))},[]),Z=(0,r.useRef)(!1),ee=(0,r.useRef)(!1),et=(0,r.useRef)(new Set),en=(0,r.useMemo)(()=>{var e;return null!==(e=M.find(e=>e.localId===R))&&void 0!==e?e:null},[M,R]),er=(0,r.useMemo)(()=>{let e=new Set(p.map(e=>e.key)),t=p.map(e=>({scope:e,records:M.filter(t=>t.scopeKey===e.key)})).filter(e=>e.records.length>0),n=[];for(let t of M)e.has(t.scopeKey)||n.includes(t.scopeKey)||n.push(t.scopeKey);return[...t,...n.map(e=>({scope:{key:e,kind:"attachment",contentType:"attachment",attachmentId:e,label:"Attachment",noun:"attachment"},records:M.filter(t=>t.scopeKey===e)}))]},[p,M]),ea=M.length,el=(0,r.useMemo)(()=>{var e;let t={};for(let n of M)t[n.scopeKey]=(null!==(e=t[n.scopeKey])&&void 0!==e?e:0)+1;return t},[M]),eo=(0,r.useCallback)((e,t)=>{E(n=>n.map(n=>n.localId===e?{...n,...t}:n))},[]),ei=(0,r.useCallback)(()=>{I(e=>e.visible?{...e,visible:!1}:e)},[]);(0,r.useEffect)(()=>{if(!v)return;let e=(e,t,n,r,a)=>I({visible:!0,x:e.left+e.width/2,y:e.top,operations:t,context:n,threadCount:r,link:null!=a?a:void 0}),t=(t,n)=>{V.current=t;let r=A.current.find(e=>e.spanEl===t),a=r?u(r):null,l=a?A.current.filter(e=>u(e)===a).length:0;e(t.getBoundingClientRect(),["define","explain","translate","ask"],"span",l,j(t,n))},n=n=>{let r=g.current;if(!r)return;let a=window.getSelection();if(a&&a.rangeCount>0&&!a.isCollapsed){let n=a.getRangeAt(0),l=a.toString().trim();if(l.length<2||l.length>o.Es||!r.contains(n.commonAncestorContainer))return ei();let i=w(n.commonAncestorContainer,r);if(i)return t(i,r);$.current=n.cloneRange(),G.current=l;let s=l.split(/\s+/).length,d=j(n.commonAncestorContainer,r);return void e(n.getBoundingClientRect(),s<=3?["define","translate","ask"]:["explain","translate","ask"],"selection",void 0,d)}let l=n instanceof Node?w(n,r):null;if(l)return t(l,r);ei()},r=e=>window.setTimeout(()=>n(e.target),0),a=()=>{let e=window.getSelection();(!e||e.isCollapsed)&&I(e=>e.visible&&"selection"===e.context?{...e,visible:!1}:e)};return document.addEventListener("mouseup",r),document.addEventListener("selectionchange",a),()=>{document.removeEventListener("mouseup",r),document.removeEventListener("selectionchange",a)}},[v,g,ei]);let es=null!==(t=p.find(e=>e.key===U))&&void 0!==t?t:S,ed=(0,r.useCallback)(()=>({entry_id:n,entry_version:c,content_type:L,attachment_id:"attachment"===L&&null!=T?T:null}),[n,c,L,T]),ec=(0,r.useCallback)(e=>{var t;return{entry_id:n,entry_version:c,content_type:e.contentType,attachment_id:"attachment"===e.contentType&&null!==(t=e.attachmentId)&&void 0!==t?t:null}},[n,c]),eu=(0,r.useCallback)(async e=>{try{let t=await (0,a.pN)(n,{contentType:L,attachmentId:T}),r=i(t.text,e);return r?{start:r.start,end:r.end,hash:t.document_hash}:{hash:t.document_hash}}catch(e){return{}}},[n,L,T]),ex=(0,r.useCallback)(e=>{E(t=>t.map(t=>(t.localId===e&&t.spanEl&&(t.spanEl.className=x),t)))},[]),eh=(0,r.useCallback)(function(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];E(r=>r.map(r=>r.localId!==e?r:(r.spanEl&&d(r.spanEl),{...r,spanEl:null,streamedText:"",output:null,pending:!1,error:t,quotaError:n})))},[]),ep=(0,r.useCallback)((e,t)=>{var n,r,a;let o=t instanceof l.MS?t:null,i=null==o?void 0:null===(n=o.data)||void 0===n?void 0:n.code;if("anchor_unresolved"===i){eh(e,"We couldn't find that selection in the saved content — it may have changed since. Try selecting the text again."),null==C||C("Couldn't find that selection in the content","error");return}if("document_mismatch"===i){eh(e,"This content changed since it was saved. Try again to re-sync with the latest version."),null==C||C("Content changed — try again","error");return}if("rate_limited"===i){eh(e,h,!0),null==C||C("Rate limit reached — try again shortly","error");return}eo(e,{error:null!==(r=null==o?void 0:o.message)&&void 0!==r?r:"Something went wrong",pending:!1}),null==C||C(null!==(a=null==o?void 0:o.message)&&void 0!==a?a:"Something went wrong","error")},[eo,C,eh]),em=(0,r.useCallback)(async(e,t)=>{let r,l;eo(e,{pending:!0,streamedText:"",output:null,error:void 0});let o="",i=!1,s=0,c="",u=!1;
1try{for await(let n of(0,a.dy)(t))if(n.thread_id&&(r=n.thread_id),"number"==typeof n.turn_index&&(s=n.turn_index),n.annotation_id&&(c=n.annotation_id,eo(e,{annotationId:n.annotation_id,threadId:n.thread_id})),n.token&&(o+=n.token,E(t=>t.map(t=>t.localId===e?{...t,streamedText:t.streamedText+n.token}:t))),n.annotation&&(i=n.annotation.cached,r=n.annotation.thread_id,s=n.annotation.turn_index,c=n.annotation.annotation_id,eo(e,{annotationId:n.annotation.annotation_id,threadId:n.annotation.thread_id,status:n.annotation.status,suggestedPrompt:n.annotation.suggested_prompt,detailLoaded:!0})),n.error&&(l=n.error),n.done){n.quota&&(u=!0);break}if(u){eh(e,o.trim()||h,!0),null==C||C("Rate limit reached — try again shortly","error");return}if(l){eh(e,l),null==C||C(l,"error");return}if(!c&&!o&&!i){E(t=>t.map(t=>t.localId!==e?t:(t.spanEl&&d(t.spanEl),{...t,spanEl:null})));return}if(i&&!o&&r)try{let t=(await (0,a.bJ)(n,r)).annotations.find(e=>e.turn_index===s);(null==t?void 0:t.output)&&eo(e,{output:t.output,status:t.status})}catch(e){}ex(e),null==C||C("Saved","success")}catch(t){ep(e,t)}finally{eo(e,{pending:!1})}},[eo,C,ex,ep,eh,n]),ef=(0,r.useCallback)(async e=>{if(e.threadId){eo(e.localId,{loading:!0,error:void 0});try{var t,r,l,o,i,s,d,c,u;let x=await (0,a.bJ)(n,e.threadId),h=[...x.annotations].sort((e,t)=>e.turn_index-t.turn_index),p=h.find(e=>0===e.turn_index),m=h.filter(e=>e.turn_index>0).map(e=>{var t,n,r,a;return{question:null!==(r=null===(t=e.params)||void 0===t?void 0:t.question)&&void 0!==r?r:"",answer:null!==(a=null===(n=e.output)||void 0===n?void 0:n.text)&&void 0!==a?a:"",pending:!1,hydrated:!0,status:e.status}}),f=h.length?Math.min(...h.map(e=>e.turn_index)):void 0;eo(e.localId,{annotationId:null!==(i=null==p?void 0:p.annotation_id)&&void 0!==i?i:e.annotationId,status:null!==(s=null==p?void 0:p.status)&&void 0!==s?s:e.status,output:null!==(d=null==p?void 0:p.output)&&void 0!==d?d:e.output,question:(null==p?void 0:null===(r=p.params)||void 0===r?void 0:null===(t=r.question)||void 0===t?void 0:t.trim())||e.question,suggestedPrompt:null!==(c=null==p?void 0:p.suggested_prompt)&&void 0!==c?c:e.suggestedPrompt,translateLang:(null==p?void 0:null===(o=p.params)||void 0===o?void 0:null===(l=o.target_language)||void 0===l?void 0:l.trim())||e.translateLang,thread:m,stale:null!==(u=null==p?void 0:p.stale)&&void 0!==u?u:e.stale,detailLoa
1ded:!0,loading:!1,hasMore:!!x.has_more,oldestTurn:f})}catch(t){eo(e.localId,{loading:!1,error:"Couldn't load this conversation"})}}},[eo,n]),eg=(0,r.useCallback)(async e=>{if(e.threadId)try{var t,r,l,o,i;let s=(await (0,a.bJ)(n,e.threadId,{before:1,limit:1})).annotations.find(e=>0===e.turn_index);if(!s)return;eo(e.localId,{question:(null===(r=s.params)||void 0===r?void 0:null===(t=r.question)||void 0===t?void 0:t.trim())||e.question,translateLang:(null===(o=s.params)||void 0===o?void 0:null===(l=o.target_language)||void 0===l?void 0:l.trim())||e.translateLang,suggestedPrompt:null!==(i=s.suggested_prompt)&&void 0!==i?i:e.suggestedPrompt})}catch(e){}},[n,eo]),eb=(0,r.useCallback)(async e=>{if(e.threadId&&null!=e.oldestTurn&&e.hasMore&&!e.loadingEarlier){eo(e.localId,{loadingEarlier:!0});try{let t=await (0,a.bJ)(n,e.threadId,{before:e.oldestTurn}),r=[...t.annotations].sort((e,t)=>e.turn_index-t.turn_index);if(!r.length){eo(e.localId,{loadingEarlier:!1});return}let l=r.find(e=>0===e.turn_index),o=r.filter(e=>e.turn_index>0).map(e=>{var t,n,r,a;return{question:null!==(r=null===(t=e.params)||void 0===t?void 0:t.question)&&void 0!==r?r:"",answer:null!==(a=null===(n=e.output)||void 0===n?void 0:n.text)&&void 0!==a?a:"",pending:!1,hydrated:!0,status:e.status}}),i=Math.min(...r.map(e=>e.turn_index));E(n=>n.map(n=>{var r,a,s;return n.localId===e.localId?{...n,thread:[...o,...n.thread],output:null!==(s=null==l?void 0:l.output)&&void 0!==s?s:n.output,question:(null==l?void 0:null===(a=l.params)||void 0===a?void 0:null===(r=a.question)||void 0===r?void 0:r.trim())||n.question,hasMore:!!t.has_more,oldestTurn:i,loadingEarlier:!1}:n}))}catch(t){eo(e.localId,{loadingEarlier:!1})}}},[eo,n]),ev=(0,r.useCallback)(e=>{q(e),F("conv"),B(!0);let t=A.current.find(t=>t.localId===e);!t||!t.threadId||t.detailLoaded||t.pending||t.loading||t.streamedText||t.output||ef(t)},[ef]),ek=(0,r.useCallback)((e,t)=>{var n;ei();let r=$.current,a=g.current;if(!r||!a)return;let l=function(e,t){var n;let r=e.toString();if(!r.trim())return null;let a=document.createRange();a.selectNodeContents(t);try{a.setEnd(e.startContainer,e.startOffset)}catch(e){return{exact:r}}let l=a.toString().length,i=null!==(n=t.textContent)&&void 0!==n?n:"";return{exact:r,prefix:i.slice(Math.max(0,l-o.e),l),suffix:i.slice(l+r.length,l+r.length+o.e)}}(r,a);if(!l)return;let i=s(r.cloneRange(),"noax-annot noax-annot--pending"),d=b();i&&(i.dataset.annotId=d),null===(n=window.getSelection())||void 0===n||n.removeAllRanges();let c={localId:d,scope:"span",scopeKey:S.key,operation:e,quote:l,spanEl:i,translateLang:"translate"===e?Q.current:void 0,status:"grounded",output:null,streamedText:"",citations:[],thread:[],pending:!0};if(E(e=>[...e,c]),ev(d),"ask"===e&&!t){eo(d,{pending:!1});return}(async()=>{var n;let r=await eu(l);await em(d,{operation:e,document:ed(),selector:{...l,start:r.start,end:r.end},document_hash:null!==(n=r.hash)&&void 0!==n?n:null,params:"ask"===e?{question:t}:"translate"===e?{target_language:Q.current}:{},regenerate:!1})})()},[ei,g,S,eo,eu,ed,em,ev]),ew=(0,r.useCallback)((e,t,n)=>{var r;let a=e.quote;if(!a)return;if("ask"!==t){let n=M.find(n=>{var r;return n.scopeKey===e.scopeKey&&n.operation===t&&(null===(r=n.quote)||void 0===r?void 0:r.exact)===a.exact});if(n){ev(n.localId);return}}let l="ask"===t&&!n,o=b(),i={localId:o,scope:"span",scopeKey:e.scopeKey,operation:t,quote:a,spanEl:null!==(r=e.spanEl)&&void 0!==r?r:null,translateLang:"translate"===t?Q.current:void 0,status:"grounded",output:null,streamedText:"",citations:[],thread:[],pending:!l};E(e=>[...e,i]),ev(o),l||(async()=>{var e;let r=await eu(a);await em(o,{operation:t,document:ed(),selector:{...a,start:r.start,end:r.end},document_hash:null!==(e=r.hash)&&void 0!==e?e:null,params:"ask"===t?{question:n}:"translate"===t?{target_language:Q.current}:{},regenerate:!1})})()},[M,eu,ed,em,ev]),ej=(0,r.useCallback)(e=>{if("span"===_.context){var t;let n=V.current;if(ei(),null===(t=window.getSelection())||void 0===t||t.removeAllRanges(),!n)return;let r=M.find(e=>e.spanEl===n);r&&ew(r,e);return}ek(e)},[_.context,M,ew,ek,ei]),ey=(0,r.useCallback)((e,t)=>{if("span"===e.scope&&"ask"===e.operation&&!e.output&&!e.streamedText){eo(e.localId,{question:t}),(async()=>{var n;let r=e.quote,a=await eu(r);await em(e.localId,{operation:"ask",document:ed(),selector:{...r,start:a.start,end:a.end},document_hash:null!==(n=a.hash)&&void 0!==n?n:null,params:{question:t}})})();return}if(!e.threadId){null==C||C("Answer still loading — try again in a moment","error");return}let n=e.thread.length;eo(e.localId,{thread:[...e.thread,{question:t,answer:"",pending:!0}]});let r=t=>E(r=>r.map(r=>{if(r.localId!==e.localId)return r;let a=[...r.thread];return a[n]&&(a[n]={...a[n],...t}),{...r,thread:a}}));(async()=>{try{let n,l="",o=!1;for await(let i of(0,a.dy)({operation:"ask",thread_id:e.threadId,params:{question:t}}))if(i.token&&(l+=i.token,r({answer:l})),i.annotation&&r({status:i.annotation.status}),i.error&&(n=i.error),i.done){i.quota&&(o=!0);break}o?null==C||C("Rate limit reached — try again shortly","error"):n&&(r({answer:n}),null==C||C(n,"error"))}catch(t){var n,o;let e=t instanceof l.MS?t:null;(null==e?void 0:null===(n=e.data)||void 0===n?void 0:n.code)==="thread_full"?null==C||C("This thread is full — start a new one","error"):null==C||C(null!==(o=null==e?void 0:e.message)&&void 0!==o?o:"Follow-up failed","error")}finally{r({pending:!1})}})()},[eo,eu,ed,em,C]),eN=(0,r.useCallback)((e,t)=>{if("ask"!==e){let t=M.find(t=>t.scopeKey===es.key&&t.operation===e);if(t){ev(t.localId),null==C||C("Cached — no re-inference","success");return}}let n=b(),r={localId:n,scope:"entry",scopeKey:es.key,operation:e,question:t,status:"grounded",output:null,streamedText:"",citations:[],thread:[],pending:!0};E(e=>[...e,r]),ev(n),em(n,{operation:e,document:ec(es),params:"ask"===e?{question:t}:{},regenerate:!1})},[M,es,ec,em,C,ev]),eC=(0,r.useCallback)(e=>{if("span"===e.scope)return ed();let t=p.find(t=>t.key===e.scopeKey);return t?ec(t):ed()},[p,ed,ec]),eS=(0,r.useCallback)(e=>{em(e.localId,{operation:e.operation,document:eC(e),selector:"span"===e.scope?e.quote:void 0,params:"ask"===e.operation?{question:e.question}:"translate"===e.operation?{target_language:Q.current}:{},regenerate:!0})},[eC,em]),eL=(0,r.useCallback)((e,t)=>{let n=t.trim();n&&(Y(n),eo(e.localId,{translateLang:n}),(async()=>{var t;let r=e.quote,a=r?await eu(r):{};await em(e.localId,{operation:"translate",document:eC(e),selector:"span"===e.scope&&r?{...r,start:a.start,end:a.end}:void 0,document_hash:null!==(t=a.hash)&&void 0!==t?t:null,params:{target_language:n},regenerate:!0})})())},[Y,eu,eC,em,eo]),eT=(0,r.useCallback)(e=>{e.spanEl&&d(e.spanEl),E(t=>t.filter(t=>
1t.localId!==e.localId)),R===e.localId&&(q(null),F("list")),e.annotationId&&v&&(0,a.Dl)(n,e.annotationId).then(e=>{let t=new Set(e.deleted_ids);E(e=>e.filter(e=>!(e.annotationId&&t.has(e.annotationId))))}).catch(()=>void 0),null==C||C("Deleted","success")},[R,v,C,n]),e_=(0,r.useCallback)(async e=>{var t,n,r,a;let l=e.filter(e=>"span"===e.scope&&e.quote&&e.scopeKey===S.key);if(!l.length)return;for(let e=0;e<20;e++){let e=g.current;if(e&&(null!==(t=e.textContent)&&void 0!==t?t:"").trim().length>0)break;await new Promise(e=>window.setTimeout(e,150))}let o=g.current,d=new Map;for(let e of l){let t=e.quote,l=null!==(a=e.anchorHash)&&void 0!==a?a:"".concat(t.exact,"|").concat(null!==(n=t.prefix)&&void 0!==n?n:"","|").concat(null!==(r=t.suffix)&&void 0!==r?r:""),o=d.get(l);o?o.push(e):d.set(l,[e])}let c=new Map;for(let e of d.values()){let t=o?function(e,t){var n;let r=i(null!==(n=e.textContent)&&void 0!==n?n:"",t);return r?function(e,t,n){let r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),a=0,l=null,o=0,i=null,s=0,d=r.nextNode();for(;d;){let e=d.data.length;if(!l&&a+e>t&&(l=d,o=t-a),l&&a+e>=n){i=d,s=n-a;break}a+=e,d=r.nextNode()}if(!l||!i)return null;let c=document.createRange();try{c.setStart(l,o),c.setEnd(i,s)}catch(e){return null}return c}(e,r.start,r.end):null}(o,e[0].quote):null,n=t?s(t,x):null;for(let t of(n&&(n.dataset.annotId=e[0].localId),e))c.set(t.localId,n)}E(e=>e.map(e=>{var t,n;if(!c.has(e.localId))return e;let r=null!==(n=c.get(e.localId))&&void 0!==n?n:null;return r?{...e,spanEl:r}:{...e,scope:"entry",degraded:!0,question:null===(t=e.quote)||void 0===t?void 0:t.exact}}))},[S,g]),eI=(0,r.useCallback)(async()=>{if(!v||!n||Z.current)return;Z.current=!0;let e=[];try{e=(await (0,a.OB)(n,{contentType:S.contentType,attachmentId:S.attachmentId})).markers.map(e=>k(e,S))}catch(e){Z.current=!1;return}E(t=>{let n=new Set(t.map(e=>e.localId));return[...t,...e.filter(e=>!n.has(e.localId))]}),1===p.length&&(ee.current=!0,W("loaded")),await e_(e)},[v,n,S,p.length,e_]),eM=(0,r.useCallback)(async()=>{if(!v||!n||ee.current)return;ee.current=!0,W("loading");let e=(e,t)=>p.find(n=>{var r;return n.contentType===e&&(null!==(r=n.attachmentId)&&void 0!==r?r:null)===t}),t=[];try{for(let o of(await (0,a.OB)(n)).markers){var r,l;let n=null!==(l=e(o.content_type,null!==(r=o.attachment_id)&&void 0!==r?r:null))&&void 0!==l?l:function(e){var t;let n=null!==(t=e.attachment_id)&&void 0!==t?t:null;return{key:null!=n?n:"entry",kind:n?"attachment":"entry",contentType:e.content_type,attachmentId:n,label:n?"Attachment":"Entire entry",noun:n?"attachment":"entry"}}(o);t.push(k(o,n))}}catch(e){ee.current=!1,W("loaded");return}E(e=>{let n=new Map(e.map(e=>[e.localId,e])),r=t.map(e=>{var t;return null!==(t=n.get(e.localId))&&void 0!==t?t:e}),a=new Set(t.map(e=>e.localId));for(let t of e)a.has(t.localId)||r.push(t);return r}),W("loaded"),Z.current||(Z.current=!0,await e_(t.filter(e=>e.scopeKey===S.key)))},[v,n,p,S,e_]),eE=(0,r.useCallback)(async()=>{ee.current=!1,await eM()},[eM]);(0,r.useEffect)(()=>{y&&eI()},[y,eI]),(0,r.useEffect)(()=>{var e;let t=D?null!==(e=en&&"span"===en.scope?u(en):null)&&void 0!==e?e:P:null;for(let e of A.current)e.spanEl&&e.spanEl.classList.toggle("noax-annot--active",null!=t&&u(e)===t)},[en,P,D,M]),(0,r.useEffect)(()=>{if(D&&"list"===O)for(let t of A.current){var e;if(!t.threadId||t.detailLoaded||et.current.has(t.localId))continue;let n="ask"===t.operation&&(!t.question||t.question===(null===(e=t.quote)||void 0===e?void 0:e.exact)),r="translate"===t.operation&&!t.translateLang;(n||r)&&(et.current.add(t.localId),eg(t))}},[D,O,M,eg]);let eA=(0,r.useCallback)(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"ask";B(!0),F(e),"list"===e&&eM()},[eM]),eR=(0,r.useCallback)(()=>{H(null),K(null),eA("ask"),eM()},[eA,eM]),eq=(0,r.useCallback)(e=>{H(null),K(p.some(t=>t.key===e)?e:null),eA("ask"),eM()},[p,eA,eM]),eD=(0,r.useCallback)(()=>{H(null),eA("list")},[eA]),eB=(0,r.useCallback)(e=>ev(e),[ev]),eO=(0,r.useCallback)((e,t,n)=>{H(null);let r=A.current.find(t=>t.threadId===e);if(r){ev(r.localId);return}let a=b(),l={localId:a,scope:"entry",scopeKey:null!=n?n:S.key,operation:"ask",question:t,threadId:e,status:"grounded",output:null,streamedText:"",citations:[],thread:[],pending:!1};E(e=>[...e,l]),q(a),F("conv"),B(!0),ef(l)},[S,ev,ef]),eF=(0,r.useCallback)(()=>{B(!1),H(null)},[]),ez=(0,r.useCallback)(e=>{F(e),"conv"!==e&&q(null),"list"===e&&eM()},[eM]),eW=(0,r.useCallback)(()=>H(null),[]),eP=(0,r.useCallback)(e=>{var t;ei(),null===(t=window.getSelection())||void 0===t||t.removeAllRanges();let n=null!=e?e:null;if(!n){let e=V.current,t=e?A.current.find(t=>t.spanEl===e):null;n=t?u(t):null}if(!n)return;let r=A.current.filter(e=>u(e)===n);if(1===r.length){ev(r[0].localId);return}H(n),q(null),F("list"),B(!0),eM()},[ei,eM,ev]);return(0,r.useEffect)(()=>{E([]),q(null),B(!1),F("ask"),W("idle"),H(null),Z.current=!1,ee.current=!1,et.current.clear()},[n,T]),{enabled:v,actionBar:_,hideActionBar:ei,startSpanAction:ek,startSpanOp:ew,runActionBarOp:ej,startEntryAction:eN,askFollowup:ey,loadEarlierTurns:eb,active:en,records:M,groups:er,totalCount:ea,countByScope:el,scopes:p,ownScope:S,documentScope:S,askScope:es,sidebarOpen:D,sidebarView:O,loadState:z,spanFilter:P,threadCount:null!=N?N:0,load:eM,reloadHistory:eE,openSidebar:eA,openEntryAsk:eR,openScopeAsk:eq,openSaved:eD,openRecord:eB,openThread:eO,openSpanHistory:eP,clearSpanFilter:eW,goToView:ez,close:eF,regenerate:eS,remove:eT,targetLanguage:J,setTargetLanguage:Y,retranslate:eL,selectionText:G}}function k(e,t){var n,r,a,l;let o=null===(n=e.selector)||void 0===n?void 0:n.exact,i=!p.has(e.operation)&&!!o;return{localId:e.thread_id,threadId:e.thread_id,scope:i?"span":"entry",scopeKey:t.key,operation:e.operation,anchorHash:e.anchor_hash,quote:o?{exact:o,prefix:e.selector.prefix,suffix:e.selector.suffix}:void 0,question:i?"ask"===e.operation&&(null===(r=e.preview)||void 0===r?void 0:r.trim())||o:(null===(a=e.preview)||void 0===a?void 0:a.trim())||void 0,translateLang:(null===(l=e.target_language)||void 0===l?void 0:l.trim())||void 0,status:"grounded",output:null,streamedText:"",citations:[],thread:[],pending:!1,spanEl:null,degraded:"orphaned"===e.state||e.stale,hydrated:!0,detailLoa
1ded:!1,turnCount:e.turn_count,stale:e.stale}}function w(e,t){let n=3===e.nodeType?e.parentNode:e;for(;n&&n!==t;){if(n instanceof HTMLElement&&n.classList.contains("noax-annot"))return n;n=n.parentNode}return null}function j(e,t){let n=null,r=3===e.nodeType?e.parentNode:e;for(;r&&r!==t;){if(r instanceof HTMLAnchorElement){n=r;break}r=r.parentNode}!n&&e instanceof HTMLElement&&(n=e.querySelector("a[href]"));let a=null==n?void 0:n.getAttribute("href");return a&&(0,c.bE)(a)?{href:a,target:n.target||void 0}:null}},95567:function(e,t,n){n.d(t,{J:function(){return a}});var r=n(67294);function a(){let[e,t]=(0,r.useState)(!1);return(0,r.useEffect)(()=>{let e=window.matchMedia("(prefers-reduced-motion: reduce)"),n=()=>t(e.matches);return n(),e.addEventListener("change",n),()=>e.removeEventListener("change",n)},[]),e}},91292:function(e,t,n){n.d(t,{Dl:function(){return d},OB:function(){return i},bJ:function(){return s},dy:function(){return l},pN:function(){return o}});var r=n(1094),a=n(52491);async function*l(e){let t=(0,r.gO)(r.$W.endpoints.annotationsStream),n=await fetch(t,{method:"POST",credentials:"same-origin",headers:(0,r.NU)(),body:JSON.stringify(e)});if(!n.ok){let e=await n.json().catch(()=>({}));!function(e,t,n){var a;let l=(0,r.mi)(e),o=(0,r.fw)(e),i=null==t?void 0:t.detail,s=o||("string"==typeof i?i:null==i?void 0:i.message)||(null==t?void 0:t.message)||"".concat(n," (status ").concat(e.status,")");throw new r.MS(e.status,s,{...t,code:null!==(a=null==i?void 0:i.code)&&void 0!==a?a:null==t?void 0:t.code,quotaHeaders:l})}(n,e,"Annotation stream failed")}if(!n.body)throw new r.MS(500,"No response body for annotation stream");let a=n.body.getReader(),l=new TextDecoder,o="";try{for(;;){let{done:e,value:t}=await a.read();if(e)break;let n=(o+=l.decode(t,{stream:!0})).split("\n");for(let e of(o=n.pop()||"",n)){if(!e.startsWith("data: "))continue;let t=e.slice(6).trim();if(t)try{let e=JSON.parse(t);if(yield e,e.done)return}catch(e){console.error("Failed to parse annotation SSE event:",t)}}}}finally{a.releaseLock()}}let o=async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{contentType:"entry_content"},n=new URLSearchParams({content_type:t.contentType});t.attachmentId&&n.set("attachment_id",t.attachmentId);let l=(0,r.f8)("".concat(a.Cq.document(e),"?").concat(n.toString()));return(0,r.P7)(l,{method:"GET"})},i=async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=new URLSearchParams;t.contentType&&n.set("content_type",t.contentType),t.attachmentId&&n.set("attachment_id",t.attachmentId),t.anchorHash&&n.set("anchor_hash",t.anchorHash);let l=n.toString(),o=(0,r.f8)("".concat(a.Cq.annotations(e)).concat(l?"?".concat(l):""));return(0,r.P7)(o,{method:"GET"})},s=async function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},l=new URLSearchParams;null!=n.limit&&l.set("limit",String(n.limit)),null!=n.before&&l.set("before",String(n.before));let o=l.toString(),i=(0,r.f8)("".concat(a.Cq.threads(e),"/").concat(t).concat(o?"?".concat(o):""));return(0,r.P7)(i,{method:"GET"})},d=async(e,t)=>{let n=(0,r.f8)("".concat(a.Cq.annotations(e),"/").concat(t));return(0,r.P7)(n,{method:"DELETE"})}},27739:function(e,t,n){n.d(t,{V:function(){return l}});let r=["text","answer","summary","explanation","definition","translated_text"],a=new Set(["status","source_language","target_language","term","sense_in_context","citations"]);function l(e){let t=function(e){if(!e)return null;if("string"==typeof e)try{let t=JSON.parse(e);return t&&"object"==typeof t?t:null}catch(e){return null}return"object"==typeof e?e:null}(e);if(!t)return"";for(let e of r){let n=t[e];if("string"==typeof n&&n.trim())return n}if(Array.isArray(t.points))return t.points.filter(e=>"string"==typeof e).join("\n");for(let[e,n]of Object.entries(t))if(!a.has(e)&&"string"==typeof n&&n.trim())return n;return""}},36286:function(e,t,n){n.d(t,{$j:function(){return a},D4:function(){return u},OQ:function(){return s},eC:function(){return i},kj:function(){return l},lJ:function(){return c},qc:function(){return o},xu:function(){return d},zV:function(){return r}});let r=2,a=4,l=2,o=82,i=26214400;function s(e,t){if(t<=0)return[];if(0===e.length)return Array(t).fill(0);if(e.length===t)return e;let n=e.length/t,r=Array(t).fill(0);for(let a=0;a<t;a+=1){let t=Math.floor(a*n),l=Math.min(e.length,Math.max(t+1,Math.floor((a+1)*n))),o=0;for(let n=t;n<l;n+=1)o+=e[n];r[a]=o/(l-t)}return r}async function d(e,t){var n;let r=null!==(n=window.OfflineAudioContext)&&void 0!==n?n:window.webkitOfflineAudioContext;if(!r)throw Error("Web Audio decoding unavailable");let a=new r(1,1,44100);return function(e){let t=function(e,t){if(0===e.length)return 0;let n=[...e].sort((e,t)=>
1e-t),r=Math.ceil(.95*n.length),a=Math.min(n.length-1,Math.max(0,r-1));return n[a]}(e.filter(e=>e>.001),0);return t<=0?e.map(()=>0):e.map(e=>e<=.001?0:Math.pow(Math.min(1,e/t),.7))}(function(e,t){let n=Array(t).fill(0);if(t<=0||0===e.length)return n;let r=e.length/t;for(let a=0;a<t;a+=1){let t=Math.floor(a*r),l=Math.min(e.length,Math.max(t+1,Math.floor((a+1)*r))),o=0;for(let n=t;n<l;n+=1){let t=e[n];o+=t*t}n[a]=Math.sqrt(o/(l-t))}return n}(function(e){let t=e.numberOfChannels;if(t<=1)return e.getChannelData(0);let n=e.length,r=new Float32Array(n);for(let a=0;a<t;a+=1){let t=e.getChannelData(a);for(let e=0;e<n;e+=1)r[e]+=t[e]}for(let e=0;e<n;e+=1)r[e]/=t;return r}(await new Promise((t,n)=>{let r=a.decodeAudioData(e,t,n);r&&"function"==typeof r.then&&r.then(t,n)})),t))}function c(e){return!e||e<=0?o:Math.max(8,Math.floor(e/a))}function u(e){if(!Number.isFinite(e)||e<0)return"0:00";let t=Math.floor(e),n=Math.floor(t/3600),r=Math.floor(t%3600/60),a=n>0?String(r).padStart(2,"0"):String(r);return"".concat(n>0?"".concat(n,":"):"").concat(a,":").concat(String(t%60).padStart(2,"0"))}}}]);

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.