1import{j as e,b as Vt,u as Ht,c as Ce}from"./query-vendor-Ds0DV8-_.js";import{c as Ke,a as n,i as It,h as Ot,R as wt,L as Ut}from"./react-vendor-C3oeC08Q.js";import{a as S,b as Yt,u as Jt,L as Xt,c as Zt,T as es,H as ts}from"./index-C3MLWdW5.js";import{L as Se,g as _e,p as kt}from"./Layout-MY2HVUV8.js";import{S as Ct}from"./SEOHead-zcHCK6E5.js";import{B as v}from"./Button-ByJlO_or.js";import{M as St}from"./Modal-DdY0J7v5.js";import{M as ss}from"./MindmapVisualization-9wLRE5_J.js";import{C as Mt}from"./ChatMarkdown-B1WOWSGZ.js";import{m as rs}from"./activation-ZRsFV9T0.js";import{M as Me,r as Le}from"./markdown-BCk2mJ1c.js";import"./analytics-DecdBF38.js";import"./AppShell-CZSowtzF.js";import"./supabaseNotesService-D3Re8H6O.js";import"./supabase-B4SStAWe.js";import"./supabase-CpRTRdvQ.js";import"./demoContent-Drn604Il.js";import"./useAuroraAnimation-BbATYk__.js";import"./flow-vendor-BvgtTytz.js";const Lt=({tags:a,onSave:d,isSaving:m=!1})=>{const c=Ke(),[h,g]=n.useState(!1),[f,u]=n.useState(""),x=n.useRef(null);n.useEffect(()=>{h&&setTimeout(()=>x.current?.focus(),50)},[h]);const p=b=>b.trim().toLowerCase().replace(/[^a-z0-9-_]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,""),o=async b=>{const w=p(b);!w||a.includes(w)||a.length>=20||(u(""),g(!1),await d([...a,w]))},N=async b=>{await d(a.filter(w=>w!==b))},C=b=>{(b.key==="Enter"||b.key===",")&&f.trim()&&(b.preventDefault(),o(f)),b.key==="Escape"&&(g(!1),u("")),b.key==="Backspace"&&!f&&a.length>0&&N(a[a.length-1])},M=(b,w)=>{w.stopPropagation(),c(`/notes?tags=${encodeURIComponent(b)}`)};return e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[a.length===0&&!h&&e.jsx("span",{className:"text-xs italic ntb-placeholder",children:"No tags"}),a.map(b=>e.jsxs("span",{className:"ntb-tag-pill inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium group",children:[e.jsxs("button",{onClick:w=>M(b,w),className:"hover:underline",title:"Filter notes by this tag",children:["#",b]}),e.jsx("button",{onClick:w=>{w.stopPropagation(),N(b)},disabled:m,className:"ml-0.5 leading-none opacity-50 hover:opacity-100 transition-opacity disabled:cursor-not-allowed",title:`Remove #${b}`,"aria-label":`Remove tag ${b}`,children:e.jsx("svg",{className:"w-2.5 h-2.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2.5,d:"M6 18L18 6M6 6l12 12"})})})]},b)),h?e.jsx("input",{ref:x,type:"text",value:f,onChange:b=>u(b.target.value),onKeyDown:C,onBlur:()=>{f.trim()?o(f):(g(!1),u(""))},placeholder:"tag nameâ¦",className:"ntb-input px-2 py-0.5 rounded-full text-xs outline-none w-28"}):e.jsxs("button",{onClick:()=>g(!0),disabled:m,className:"ntb-add-btn inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs transition-all disabled:opacity-50",title:"Add a tag",children:[e.jsx("svg",{className:"w-2.5 h-2.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2.5,d:"M12 4v16m8-8H4"})}),m?"Savingâ¦":"Edit tags"]})]})},zt=({noteId:a})=>{const d=Ke(),[m,c]=n.useState(null),[h,g]=n.useState(null),[f,u]=n.useState(null);n.useEffect(()=>{let p=!1;return S.getNoteConnections(a).then(({connections:o})=>{p||c(o)}).catch(o=>{p||g(o?.response?.data?.message||"Could not load connections")}),()=>{p=!0}},[a]);const x=async p=>{try{await S.unlinkNoteConnection(a,p),c(o=>(o??[]).filter(N=>N.entity.id!==p))}catch(o){console.error("Failed to unlink connection",o)}};return h?null:m===null?e.jsx("p",{className:"text-xs text-text-secondary py-2",children:"Loading connectionsâ¦"}):m.length===0?e.jsxs("p",{className:"text-xs text-text-secondary py-2",children:["No connections yet. Connections appear after knowledge-graph extraction runs on your notes (see the ",e.jsx("button",{onClick:()=>d("/knowledge-graph"),className:"text-primary hover:underline",children:"Knowledge Graph"})," page)."]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs text-text-secondary mb-2",children:"Concepts in this note and where else they appear in your knowledge base. Click a concept to see related notes; unlink ones that aren't relevant."}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:m.map(p=>e.jsx("div",{className:"inline-flex items-center",children:e.jsxs("button",{onClick:()=>u(f===p.entity.id?null:p.entity.id),className:`inline-flex items-center gap-1.5 pl-2.5 pr-1.5 py-1 text-xs rounded-full border transition-colors ${f===p.entity.id?"border-primary/50 bg-primary/15 text-primary":"border-border bg-surface-hover text-text-secondary hover:border-primary/40 hover:text-text-primary"}`,title:p.entity.entityType?`Type: ${p.entity.entityType}`:void 0,children:[e.jsx("span",{className:"font-medium",children:p.entity.name}),e.jsx("span",{className:"inline-flex items-center justify-center min-w-[18px] h-[18px] px-1 text-[10px] font-bold rounded-full bg-primary/20 text-primary",children:p.mentionCount}),e.jsx("span",{role:"button",tabIndex:0,onClick:o=>{o.stopPropagation(),x(p.entity.id)},onKeyDown:o=>{o.key==="Enter"&&(o.stopPropagation(),x(p.entity.id))},className:"text-text-muted hover:text-red-400 px-0.5",title:"Unlink this connection",children:"Ã"})]})},p.entity.id))}),f&&(()=>{const p=m.find(o=>o.entity.id===f);return p?e.jsxs("div",{className:"mt-2 p-3 rounded-xl border border-border bg-surface-hover",children:[e.jsxs("p",{className:"text-[11px] uppercase tracking-wide text-text-muted mb-1.5",children:['Also mentions "',p.entity.name,'"']}),p.relatedNotes.length===0?e.jsx("p",{className:"text-xs text-text-secondary",children:"No other notes mention this yet."}):e.jsx("div",{className:"space-y-1",children:p.relatedNotes.map(o=>e.jsxs("button",{onClick:()=>d(`/notes/${o.id}`),className:"block w-full text-left text-sm text-primary hover:underline truncate",children:[o.source_type==="video"?"ð¬":o.source_type==="pdf"?"ð":"ð°"," ",o.title]},o.id))})]}):null})()]})};function as(a){const d=a.content?.nodes??[],m=a.content?.edges??[],c=new Map;d.forEach(x=>c.set(x.id,new Set)),m.forEach(x=>{c.get(x.from)?.add(x.to)}),d.forEach(x=>{x.parentId&&c.get(x.parentId)?.add(x.id)});const h=new Set;
1c.forEach(x=>x.forEach(p=>h.add(p)));const g=d.filter(x=>!h.has(x.id)),f=new Map(d.map(x=>[x.id,x]));function u(x,p=new Set){if(p.has(x))return null;p.add(x);const o=f.get(x);if(!o)return null;const C=Array.from(c.get(x)??[]).map(M=>u(M,new Set(p))).filter(M=>M!==null);return{id:o.id,label:o.label,level:o.level??1,children:C}}return g.map(x=>u(x.id)).filter(x=>x!==null)}function Et({node:a,depth:d=0}){const[m,c]=n.useState(!1),h=a.children.length>0,g=d===0?"border-primary":d===1?"border-indigo-400/50":"border-border",f=d===0?"text-base font-bold text-text-primary":d===1?"text-sm font-medium text-text-primary":"text-sm text-text-secondary";return e.jsxs("div",{children:[e.jsxs("div",{className:`flex items-start gap-2 py-2.5 border-l-2 ${g} ${h?"cursor-pointer active:bg-surface/60":""}`,style:{paddingLeft:`${d*20+12}px`,paddingRight:12},onClick:()=>h&&c(u=>!u),children:[h?e.jsx("span",{className:"shrink-0 text-text-secondary text-[10px] mt-1 w-3",children:m?"â¶":"â¼"}):e.jsx("span",{className:"shrink-0 text-text-secondary/50 text-xs mt-1 w-3",children:"â¢"}),e.jsx("span",{className:f,children:a.label})]}),!m&&a.children.map(u=>e.jsx(Et,{node:u,depth:d+1},u.id))]})}const ns=({mindmap:a})=>{const d=n.useMemo(()=>as(a),[a]);return d.length===0?e.jsx("p",{className:"text-sm text-text-secondary p-4 text-center",children:"No mindmap data available."}):e.jsx("div",{className:"divide-y divide-border rounded-xl overflow-hidden border border-border bg-surface",children:d.map(m=>e.jsx(Et,{node:m,depth:0},m.id))})};function ls(a){const d=a.split(` 2`).map(h=>h.trim()).filter(Boolean),m=[],c=[];for(const h of d){const g=h.match(/^([A-D])[.)]\s*(.+)$/);g?m.push({letter:g[1],text:g[2]}):m.length===0&&c.push(h)}return m.length>=2?{question:c.join(" "),options:m}:null}function os(a){const d=a.match(/^([A-D])[.)]/);return d?d[1]:null}const Tt=({noteId:a,noteTitle:d,excerpt:m,onClose:c})=>{const[h,g]=n.useState("idle"),[f,u]=n.useState([]),[x,p]=n.useState(0),[o,N]=n.useState(!1),[C,M]=n.useState([]),[b,w]=n.useState(null),[me,Te]=n.useState([]),[z,se]=n.useState(null),F=n.useCallback(async()=>{g("generating"),w(null);try{const y=await S.generateRecallBundle(a);if(y.flashcards.length===0){w("No recall questions could be generated for this note."),g("error");return}u(y.flashcards),p(0),N(!1),M([]),g("reviewing")}catch(y){w(y?.response?.data?.message??"Failed to generate recall cards"),g("error")}},[a]),X=()=>N(!0),R=y=>{const W=[...C,y];M(W),x+1>=f.length?g("done"):(p(A=>A+1),N(!1),se(null))},Z=y=>{z||(se(y),N(!0))};n.useEffect(()=>{h==="done"&&S.completeRecallSession(a).then(y=>{y.trophies_unlocked?.length>0&&Te(y.trophies_unlocked)}).catch(()=>{})},[h,a]);const $=C.filter(y=>y==="correct").length;return e.jsxs("div",{className:"recall-card rounded-2xl overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-border",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"recall-icon-badge w-8 h-8 rounded-lg flex items-center justify-center",children:e.jsx("svg",{className:"w-4 h-4 text-violet-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9.663 17h4.673M12 3v1m6.364 1.636l-.707.707M21 12h-1M4 12H3m3.343-5.657l-.707-.707m2.828 9.9a5 5 0 117.072 0l-.548.547A3.374 3.374 0 0014 18.469V19a2 2 0 11-4 0v-.531c0-.895-.356-1.754-.988-2.386l-.548-.547z"})})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold text-white",children:"Read & Recall"}),d&&e.jsx("p",{className:"text-[11px] text-text-muted line-clamp-1",children:d})]})]}),e.jsx("button",{onClick:c,className:"recall-close-btn w-8 h-8 flex items-center justify-center rounded-lg text-text-muted hover:text-white transition-colors",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsxs("div",{className:"p-6",children:[(h==="idle"||h==="error")&&e.jsxs("div",{className:"space-y-4",children:[m&&e.jsxs("div",{className:"recall-excerpt p-4 rounded-xl text-sm text-text-secondary leading-relaxed",children:[e.jsx("p",{className:"text-[11px] text-text-muted uppercase tracking-wider mb-2",children:"Note excerpt"}),e.jsx("p",{className:"line-clamp-4",children:m})]}),b&&e.jsx("p",{className:"error-icon-box text-xs text-red-400 px-3 py-2 rounded-lg",children:b}),e.jsx("p",{className:"text-sm text-text-muted",children:"Generate 3 AI recall questions based on this note â test your understanding without flashcards."}),e.jsx("button",{onClick:F,className:"btn-cyan w-full !py-3 !text-sm",children:"Generate Recall Questions"})]}),h==="generating"&&e.jsxs("div",{className:"flex flex-col items-center gap-4 py-8 text-text-muted",children:[e.jsx("svg",{className:"w-8 h-8 animate-spin text-violet-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),e.jsx("p",{className:"text-sm",children:"Generating recall questions with AIâ¦"})]}),h==="reviewing"&&f[x]&&(()=>{const y=f[x],W=y.metadata?.card_type==="mcq",A=W?ls(y.front):null,V=W?os(y.back):null,P=z!==null&&z===V;return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between text-[11px] text-text-muted font-mono uppercase tracking-widest",children:[e.jsxs("span",{children:["Question ",x+1," / ",f.length]}),e.jsxs("span",{children:[Math.round(x/f.length*100),"%"]})]}),e.jsx("div",{className:"recall-progress-track h-1 w-full rounded-full overflow-hidden",children:e.jsx("div",{className:"recall-progress-fill h-full rounded-full transition-all duration-500",style:{width:`${x/f.length*100}%`}})}),W&&A?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`recall-mcq-card rounded-xl p-5 ${z?P?"recall-mcq-card--correct":"recall-mcq-card--wrong":""}`,children:[e.jsx("div",{className:"flex items-center gap-2 mb-3",children:e.jsx("span",{className:"recall-mcq-tag text-[10px] px-2 py-0.5 rounded-full font-medium text-amber-400",children:"Multiple Choice"})}),e.jsx("p",{className:"text-base font-medium text-white leading-relaxed",children:A.question}),o&&e.jsxs("div",{className:"mt-3 pt-3 border-t border-border",children:[e.jsx("p",{className:`text-xs font-medium mb-1 ${P?"text-emerald-400":"text-red-400"}`,children:P?"â Correct!":"â Incorrect"}),e.jsx("p",{className:"text-xs text-text-muted leading-relaxed",children:y.back})]})]}),e.jsx("div",{className:"space-y-2",children:A.options.map(_=>{const L=z===_.letter,ae=_.letter===V,ee=z?ae?"mcq-opt-correct":L?"mcq-opt-wrong":"mcq-opt-disabled":"mcq-opt-idle";return e.jsxs("button",{onClick:()=>Z(_.letter),disabled:!!z,className:`w-full flex items-center gap-3 px-4 py-2.5 rounded-lg text-sm font-medium text-left transition-all ${ee}`,children:[e.jsx("span",{className:"recall-opt-letter w-5 h-5 rounded-full flex items-center justify-center text-[10px] font-bold shrink-0",children:_.letter}),e.jsx("span",{className:"flex-1",children:_.text}),z&&ae&&e.jsx("span",{className:"text-emerald-400 text-xs shrink-0",children:"â"}),z&&L&&!ae&&e.jsx("span",{className:"text-red-400 text-xs shrink-0",children:"â"})]},_.letter)})}),z&&e.jsx("div",{className:"flex gap-3 pt-1",children:e.jsx("button",{onClick:()=>R(P?"correct":"incorrect"),className:"btn-cyan w-full !py-2.5 !text-sm",children:"Next â"})})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"recall-flip-card p-5 rounded-xl min-h-[100px] flex items-center justify-center",children:e.jsx("p",{className:"text-base font-medium text-white text-center leading-relaxed",children:y.front})}),o?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"recall-answer-box p-4 rounded-xl",children:[e.jsx("p",{className:"text-[11px] text-cyan-500 uppercase tracking-wider mb-1",children:"Answer"}),e.jsx("p",{className:"text-sm text-white leading-relaxed",children:y.back})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("button",{onClick:()=>R("incorrect"),className:"recall-score-hard flex-1 py-2.5 rounded-xl text-sm font-semibold transition-all",children:"Didn't know â"}),e.jsx("button",{onClick:()=>R("correct"),className:"recall-score-easy flex-1 py-2.5 rounded-xl text-sm font-semibold transition-all",children:"Got it â"})]})]}):e.jsx("button",{onClick:X,className:"btn-cyan w-full !py-2.5 !text-sm",children:"Show Answer"})]})]})})(),h==="done"&&e.jsxs("div",{className:"text-center space-y-4 py-4",children:[e.jsx("div",{className:"text-4xl",children:$===f.length?"ð":$>=f.length/2?"ð":"ð"}),e.jsxs("p",{className:"text-lg font-bold text-white",children:[$," / ",f.length," correct"]}),me.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2 justify-center",children:me.map(y=>e.jsx("span",{className:"recall-trophy-badge text-xs px-3 py-1 rounded-full font-medium text-yellow-400",children:"ð Trophy unlocked!"},y))}),e.jsx("p",{className:"text-sm text-text-muted",children:$===f.length?"Perfect score! You know this note well.":$>=f.length/2?"Good effort â review the ones you missed.":"Keep reviewing â try again after studying the note."}),e.jsxs("div",{className:"flex gap-3 pt-2",children:[e.jsx("button",{onClick:()=>{g("idle"),u([])},className:"recall-done-btn flex-1 py-2.5 rounded-xl text-sm font-medium text-text-secondary transition-colors hover:text-white",children:"Try Again"}),e.jsx("button",{onClick:c,className:"btn-cyan flex-1 !py-2.5 !text-sm",children:"Done"})]})]})]})]})};function is(a=768){const[d,m]=n.useState(()=>typeof window<"u"&&window.innerWidth<a);return n.useEffect(()=>{const c=window.matchMedia(`(max-width: ${a-1}px)`);m(c.matches);const h=g=>m(g.matches);return c.addEventListener("change",h),()=>c.removeEventListener("change",h)},[a]),d}function $t(a){if(!a)return"";const d=a.trim();let m="";if(d.startsWith("{"))try{const c=JSON.parse(d);typeof c.full_report=="string"&&c.full_report.trim()?m=c.full_report:typeof c.overview=="string"&&c.overview.trim()&&(m=c.overview)}catch{}
2return m||(m=a),m.replace(/\\n/g,` 3`).replace(/\\t/g," ").replace(/\\r/g,"\r").replace(/\\"/g,'"')}function At(a){if(!a)return"";const d=a.trim();let m="";if(d.startsWith("{"))try{const c=JSON.parse(d);typeof c.overview=="string"&&c.overview.trim()?m=c.overview.substring(0,600):typeof c.full_report=="string"&&(m=c.full_report.substring(0,600))}catch{}return m||(m=a),m.replace(/\\n/g,` 4`).replace(/\\t/g," ").replace(/\\r/g,"\r").replace(/\\"/g,'"')}function Y(a){const d=Math.floor(a/60),m=Math.floor(a%60);return`${d}:${m.toString().padStart(2,"0")}`}function ze(a){if(!a)return null;const d=[/[?&]v=([^&#]+)/,/youtu\.be\/([^?&#/]+)/,/\/embed\/([^?&#/]+)/,/\/shorts\/([^?&#/]+)/];for(const m of d){const c=a.match(m);if(c?.[1])return`https://www.youtube-nocookie.com/embed/${c[1]}?rel=0&playsinline=1`}return null}const J=({children:a})=>e.jsx("h3",{className:"text-xs font-bold tracking-widest uppercase mb-3 border-b border-border pb-2 text-text-secondary",children:a}),qt=({active:a,onSelect:d,hasQuiz:m,flashcardsReady:c,flashcardCount:h,className:g=""})=>{const f=p=>a===p,u=p=>d(f(p)?"summary":p),x=(p,o,N,C,M=!1)=>e.jsxs("button",{onClick:()=>!M&&u(p),disabled:M,className:`flex-1 flex flex-col items-center gap-0.5 py-3 px-1 rounded-xl border transition-all min-h-[72px] ${f(p)?"bg-primary/10 border-primary/30 text-primary":M?"border-transparent text-text-secondary/25 cursor-not-allowed":"border-border/50 hover:bg-surface hover:border-border text-text-secondary hover:text-text-primary"}`,style:{touchAction:"manipulation"},children:[e.jsx("div",{className:"w-5 h-5 flex items-center justify-center",children:o}),e.jsx("span",{className:"text-xs font-semibold leading-tight mt-0.5",children:N}),e.jsx("span",{className:"text-[10px] leading-tight opacity-60 text-center",children:C})]},p);return e.jsxs("div",{className:`flex items-stretch gap-2 px-4 py-3 ${g}`,children:[x("mindmap",e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 20l-5.447-2.724A1 1 0 013 16.382V5.618a1 1 0 011.447-.894L9 7m0 13l6-3m-6 3V7m6 10l4.553 2.276A1 1 0 0021 18.382V7.618a1 1 0 00-1.447-.894L15 9m0 8V9m0 0L9 7"})}),"Mindmap","Visualize"),x("flashcards",e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})}),"Flashcards",c?`${h} cards`:"Memorize"),x("chat",e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 10h.01M12 10h.01M16 10h.01M9 16H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-5l-5 5v-5z"})}),"AI Chat","Ask Anything"),x("quiz",e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})}),"Quiz",m?"Test Yourself":"Not ready",!m)]})},Ls=()=>{const{id:a}=It(),d=Ke(),[m]=Ot(),c=Vt(),h=Yt(),{isPremium:g,token:f}=Jt(),[u,x]=n.useState(m.get("edit")==="true"),p=m.get("tab"),[o,N]=n.useState(p&&["summary","mindmap","chat","quiz"].includes(p)?p:"summary"),[C,M]=n.useState(""),[b,w]=n.useState(!1),[me,Te]=n.useState(""),[z,se]=n.useState(""),[F,X]=n.useState([]),[R,Z]=n.useState([]),[$,y]=n.useState([]),[W,A]=n.useState(!1),[V,P]=n.useState(""),[_,L]=n.useState(!1),[ae,ee]=n.useState(!1),[Rt,ne]=n.useState(!1),xe=n.useRef(null),Qt=n.useRef(null),Bt=n.useRef(null),[q,le]=n.useState(null),[ue,Ge]=n.useState(!1),[$e,H]=n.useState(!1),Ae=n.useRef(null),[Q,qe]=n.useState([]),[oe,Ee]=n.useState(""),[I,Ve]=n.useState(!1),Re=n.useRef(null),[He,Ie]=n.useState(null),ie=n.useRef(null),[ce,Oe]=n.useState(null),[Ue,Ye]=n.useState(!1),[pe,Je]=n.useState(null),[O,Xe]=n.useState({}),[B,Ze]=n.useState(!1),[Qe,et]=n.useState(!1),[Be,Dt]=n.useState(null),[K,De]=n.useState(null),[tt,de]=n.useState(!1),[st,he]=n.useState(!1),[E,rt]=n.useState(null),[at,nt]=n.useState(!1),[fe,lt]=n.useState(null),Fe=is(),{data:s,isLoading:Ft}=Ht({queryKey:["note",a],queryFn:()=>S.getNote(a),enabled:!!a}),be=Ce({mutationFn:t=>S.updateNote(a,t),onSuccess:()=>{c.invalidateQueries({queryKey:["note",a]}),c.invalidateQueries({queryKey:["notes"]}),x(!1),d(`/notes/${a}`,{replace:!0})}}),ye=Ce({mutationFn:t=>S.updateNote(a,{customNotes:t}),onSuccess:()=>{c.invalidateQueries({queryKey:["note",a]}),c.invalidateQueries({queryKey:["notes"]}),we("â Saved to Custom Notes")},onError:t=>{c.invalidateQueries({queryKey:["note",a]}),we(t?.response?.data?.message||t?.message||"Could not save to Custom Notes")}}),ot=Ce({mutationFn:t=>S.updateNote(a,{starred:t}),onSuccess:()=>{c.invalidateQueries({queryKey:["note",a]}),c.invalidateQueries({queryKey:["notes"]})}}),We=Ce({mutationFn:()=>S.deleteNote(a),onSuccess:()=>{c.invalidateQueries({queryKey:["notes"]}),d("/notes")}});wt.useEffect(()=>()=>{ie.current&&clearTimeout(ie.current)},[]),wt.useEffect(()=>{s&&(M(s.customNotes||""),P(s.title||""),u&&(Te(s.title||""),se(s.summary?.tldr||""),X(s.summary?.keyConcepts||[]),Z(s.summary?.definitions||[]),y(s.summary?.takeaways||[])))},[s,u]),n.useEffect(()=>{s?.id&&o==="mindmap"&&!ce&&Wt()},[s?.id,o]),n.useEffect(()=>{if(!s?.id)return;let t=!1;return S.getFlashcards(void 0,s.id).then(({flashcards:r})=>{!t&&Array.isArray(r)&&r.length>0&&rt({count:r.length,deckName:r[0]?.deck_name??"Recall"})}).catch(()=>{}),()=>{t=!0}},[s?.id]),n.useEffect(()=>{const t=r=>{xe.current&&!xe.current.contains(r.target)&&(L(!1),ee(!1),ne(!1),H(!1))};return document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[]),n.useEffect(()=>{Re.current?.scrollIntoView({behavior:"smooth"})},[Q,I]),n.useEffect(()=>{Fe&&o!=="summary"&&Ae.current&&Ae.current.scrollIntoView({behavior:"smooth",block:"start"})},[o,Fe]);const Wt=async()=>
4{if(s?.id)try{const i=((await S.getMindmaps()).mindmaps||[]).find(l=>l.note_id===s.id);i&&Oe(i)}catch(t){console.error("Failed to load mindmap:",t)}},ge=()=>{V.trim()&&s&&(be.mutate({title:V.trim()}),A(!1))},je=()=>{P(s?.title||""),A(!1)},it=()=>{u||(x(!0),A(!0))},D=async t=>{const r=t||oe.trim();if(!r||I||!s?.summary)return;const i={role:"user",content:r,ts:Date.now()};qe(l=>[...l,i]),Ee(""),Ve(!0);try{const l=Q.map(T=>({role:T.role,content:T.content})),j=await S.chat(i.content,s.summary,l,s.transcript??null);qe(T=>[...T,{role:"assistant",content:j.response,ts:Date.now()}])}catch(l){qe(j=>[...j,{role:"assistant",content:`Error: ${l?.response?.data?.message||l.message}`,ts:Date.now()}])}finally{Ve(!1)}},ct=async()=>{if(s?.id){nt(!0),lt(null);try{const t=await S.generateRecallBundle(s.id);rt({count:t.flashcards.length,deckName:t.flashcards[0]?.deck_name??"Recall"}),rs("has_flashcard")}catch(t){lt(t?.response?.data?.message??t?.message??"Failed to generate flashcards")}finally{nt(!1)}}},dt=async()=>{if(s?.summary){Ye(!0),Je(null);try{const t=[];s.summary.tldr&&t.push(`TL;DR: ${s.summary.tldr}`),s.summary.keyConcepts?.length&&t.push(`Key Concepts: ${s.summary.keyConcepts.join(", ")}`),s.summary.definitions?.length&&t.push(`Definitions: ${s.summary.definitions.join("; ")}`),s.summary.takeaways?.length&&t.push(`Takeaways: ${s.summary.takeaways.join("; ")}`);const r=t.join(` 5 6`),i=await S.generateMindmap(r,s.title,s.id);Oe(i.mindmap)}catch(t){Je(t?.response?.data?.message||t.message||"Failed to generate mindmap")}finally{Ye(!1)}}},ve=async t=>{if(!s?.summary)return;const r=q??s.summary;let i=`# ${s.title} 7 8`;r.tldr&&(i+=`## TL;DR 9${r.tldr} 10 11`),r.keyConcepts?.length>0&&(i+=`## Key Concepts 12${r.keyConcepts.join(", ")} 13 14`),r.takeaways?.length>0&&(i+=`## Takeaways 15${r.takeaways.map((l,j)=>`${j+1}. ${l}`).join(` 16`)} 17 18`),t&&r.keyMoments&&r.keyMoments.length>0&&(i+=`## Key Moments 19`,r.keyMoments.forEach(l=>{i+=`[${Y(l.time)}] ${l.title} 20${l.summary} 21 22`})),await navigator.clipboard.writeText(i),L(!1),ee(!1),alert("â Summary copied to clipboard!")},mt=(t,r)=>{const i=URL.createObjectURL(t),l=document.createElement("a");l.href=i,l.download=r,document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(i)},Ne=async t=>{if(!s?.transcript||s.transcript.length===0){alert("No transcript available");return}const r=s.transcript.map(l=>`[${Y(l.start)}] ${l.text}`).join(` 23 24`),i=`${s.title.replace(/[^a-z0-9]/gi,"_").toLowerCase()}_transcript`;if(t==="json"){const l=new Blob([JSON.stringify(s.transcript,null,2)],{type:"application/json"});mt(l,`${i}.json`)}else if(t==="markdown"){const l=new Blob([r],{type:"text/markdown"});mt(l,`${i}.md`)}else if(t==="pdf"){const l=`<!DOCTYPE html><html><head><title>${s.title} - Transcript</title> 25 <style>body{font-family:Arial,sans-serif;padding:20px;line-height:1.6;max-width:800px;margin:0 auto}h1{color:#333}.ts{color:#666;font-weight:bold}@media print{button{display:none}}</style> 26 </head><body><h1>${s.title}</h1><h2>Transcript</h2> 27 ${s.transcript.map(T=>`<p><span class="ts">[${Y(T.start)}]</span> ${T.text}</p>`).join("")} 28 <script>window.onload=()=>window.print()<\/script></body></html>`,j=window.open("","_blank");j&&(j.document.write(l),j.document.close())}L(!1),ne(!1)},xt=()=>{if(!s?.summary){alert("Summary is required to generate quiz"),L(!1);return}s.summary.quizQuestions&&s.summary.quizQuestions.length>0?(N("quiz"),L(!1)):(alert("Quiz questions are automatically generated when creating a summary. This summary was created before quiz generation was available. Please regenerate the summary to get quiz questions."),L(!1))},ut=(t,r)=>{B||Xe(i=>({...i,[t]:r}))},pt=()=>{Ze(!0)},ht=()=>{Xe({}),Ze(!1)},ft=["Hindi","Urdu","Tamil","Telugu","Kannada","Bengali","Spanish","French","German","Portuguese","Italian","Arabic","Japanese","Korean","Chinese (Simplified)","Russian"],bt=async t=>{if(s?.summary){Ge(!0),L(!1),H(!1);try{const r=await S.translateSummary(s.summary,t);le({...r.summary,_language:t})}catch(r){alert(r?.response?.data?.message||"Translation failed. Please try again.")}finally{Ge(!1)}}},Pt=async()=>
28{if(!(!s||Qe)){et(!0);try{const{challenge:t}=await S.createChallenge({noteId:s.id}),r=`${window.location.origin}/challenge/${t.token}`;Dt(r),await navigator.clipboard.writeText(r).catch(()=>{})}catch(t){alert(t?.response?.data?.message||"Failed to create challenge link")}finally{et(!1)}}},yt=e.jsxs("div",{className:"glass-card p-3 flex flex-col sm:flex-row sm:items-center gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-semibold text-text-primary",children:"âï¸ Challenge a friend"}),e.jsx("p",{className:"text-xs text-text-secondary",children:"Share this quiz as a public link â no account needed to play."})]}),Be?e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("input",{readOnly:!0,value:Be,onFocus:t=>t.target.select(),className:"flex-1 min-w-0 px-2 py-1.5 text-xs border rounded-lg input-base"}),e.jsx("button",{onClick:()=>navigator.clipboard.writeText(Be),className:"text-xs px-3 py-1.5 rounded-lg border border-primary/40 text-primary hover:bg-primary/10 shrink-0",children:"Copy"})]}):e.jsx("button",{onClick:Pt,disabled:Qe,className:"text-xs px-3 py-1.5 rounded-lg border border-primary/40 text-primary hover:bg-primary/10 shrink-0 self-start sm:self-auto",children:Qe?"Creatingâ¦":"Create challenge link"})]}),gt=()=>{const t=new Date().toLocaleString(),r=[`## AI Chat â ${s?.title??"Note"}`,"",`_Exported ${t}_`,""];return Q.forEach(i=>{r.push(i.role==="user"?"**You:**":"**Sorusly:**",""),r.push(i.content.trim(),"")}),`${r.join(` 29`).trimEnd()} 30`},we=t=>{Ie(t),ie.current&&clearTimeout(ie.current),ie.current=setTimeout(()=>Ie(null),3e3)},_t=async()=>{if(Q.length!==0)try{await navigator.clipboard.writeText(gt()),we("â Copied as Markdown")}catch{we("Could not access the clipboard")}},Kt=()=>{if(Q.length===0||ye.isPending)return;const t=gt(),r=C.trim()?`${C.trimEnd()} 31 32--- 33 34${t}`:t;M(r),ye.mutate(r)},Pe=Q.length>0?e.jsxs("div",{className:"flex-shrink-0 flex flex-wrap items-center gap-2 pb-2",children:[e.jsx("button",{type:"button",onClick:_t,className:"text-xs px-2.5 py-1.5 rounded-lg border border-border text-text-secondary hover:border-primary/50 hover:text-text-primary transition-colors",title:"Copy the whole conversation as Markdown, formatting intact",children:"Copy as Markdown"}),e.jsx("button",{type:"button",onClick:Kt,disabled:ye.isPending,className:"text-xs px-2.5 py-1.5 rounded-lg border border-primary/40 text-primary hover:bg-primary/10 transition-colors disabled:opacity-50",title:"Append this conversation to the Custom Notes section of this note",children:ye.isPending?"Savingâ¦":"Save to Custom Notes"}),He&&e.jsx("span",{className:"text-xs text-text-secondary",children:He})]}):null,jt=()=>{if(!s?.summary?.quizQuestions)return{correct:0,total:0,percentage:0};const t=s.summary.quizQuestions;let r=0;t.forEach((l,j)=>{O[j]===l.correctAnswer&&r++});const i=Math.round(r/t.length*100);return{correct:r,total:t.length,percentage:i}},vt=()=>{const t={customNotes:C,title:W?V:me,summary:{...s?.summary,tldr:z,keyConcepts:F,definitions:R,takeaways:$}};be.mutate(t),A(!1)},Nt=()=>{We.mutate()};if(Ft)return e.jsx(Se,{children:e.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:e.jsx(Xt,{size:"lg"})})});if(!s)return e.jsx(Se,{children:e.jsx("div",{className:"p-4 sm:p-6 md:p-8",children:e.jsx("div",{className:"bg-yellow-50 border border-yellow-200 text-yellow-700 px-4 py-3 rounded-lg",children:"Note not found"})})});const ke=s.platform==="youtube",k=q??s.summary;return Fe?e.jsxs(Se,{children:[e.jsx(Ct,{title:s.title||"Note",description:s.summary?.tldr||"View and study your saved note.",noindex:!0}),e.jsxs("div",{className:"flex flex-col bg-background text-text-primary",children:[e.jsxs("div",{className:"sticky top-0 z-40 flex items-center gap-2 px-3 py-3 border-b border-border bg-surface backdrop-blur-md min-h-[56px]",children:[e.jsx(v,{variant:"outline",size:"sm",onClick:()=>d("/notes"),children:"â Back"}),e.jsx("div",{className:"flex-1 min-w-0 flex items-center gap-2",children:W?e.jsxs("div",{className:"flex items-center gap-1.5 flex-1 min-w-0",children:[e.jsx("input",{type:"text",value:V,onChange:t=>P(t.target.value),onKeyDown:t=>{t.key==="Enter"&&ge(),t.key==="Escape"&&je()},className:"flex-1 px-2 py-1 text-sm border border-primary/50 rounded-lg focus:outline-none focus:ring-2 focus:ring-primary input-base",autoFocus:!0}),e.jsx("button",{onClick:ge,className:"p-1 text-green-400 hover:bg-green-400/10 rounded",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}),e.jsx("button",{onClick:je,className:"p-1 text-red-400 hover:bg-red-400/10 rounded",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}):e.jsxs("div",{className:"flex items-center gap-1.5 flex-1 min-w-0",children:[e.jsx("h1",{className:"text-base font-display font-bold truncate text-text-primary",children:s.title}),e.jsx("button",{onClick:it,className:"p-1 text-text-secondary hover:text-primary hover:bg-primary/10 rounded shrink-0",children:e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})})]})}),e.jsx("div",{className:"flex items-center gap-1 shrink-0",children:u?e.jsxs(e.Fragment,{children:[e.jsx(v,{variant:"secondary",size:"sm",onClick:()=>{x(!1),A(!1)},children:"Cancel"}),e.jsx(v,{variant:"secondary",size:"sm",onClick:vt,isLoading:be.isPending,children:"Save"})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>ot.mutate(!s.starred),className:`p-2 rounded-lg transition-colors ${s.starred?"text-amber-400":"text-text-secondary"}`,children:e.jsx("svg",{className:"w-5 h-5",fill:s.starred?"currentColor":"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11.049 2.927c.3-.921 1.603-.921 1.902 0l1.519 4.674a1 1 0 00.95.69h4.915c.969 0 1.371 1.24.588 1.81l-3.976 2.888a1 1 0 00-.363 1.118l1.518 4.674c.3.922-.755 1.688-1.538 1.118l-3.976-2.888a1 1 0 00-1.176 0l-3.976 2.888c-.783.57-1.838-.197-1.538-1.118l1.518-4.674a1 1 0 00-.363-1.118l-3.976-2.888c-.784-.57-.38-1.81.588-1.81h4.914a1 1 0 00.951-.69l1.519-4.674z"})})}),e.jsx("button",{onClick:()=>w(!0),className:"p-2 text-text-secondary hover:text-red-400 rounded-lg transition-colors",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})}),e.jsxs("div",{className:"relative",ref:xe,children:[e.jsx("button",{onClick:t=>{t.stopPropagation(),L(r=>!r)},className:"p-2 text-text-secondary hover:text-text-primary rounded-lg transition-colors",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 12h.01M12 12h.01M19 12h.01M6 12a1 1 0 11-2 0 1 1 0 012 0zm7 0a1 1 0 11-2 0 1 1 0 012 0zm7 0a1 1 0 11-2 0 1 1 0 012 0z"})})}),_&&e.jsx("div",{className:"absolute top-full right-0 mt-1 w-52 backdrop-blur-md border border-border rounded-lg shadow-xl z-[60] bg-background",children:e.jsxs("div",{className:"py-1",children:[e.jsx("button",{onClick:()=>ve(!1),className:"w-full px-4 py-3 text-left text-sm text-text-primary hover:bg-surface",children:"Copy Summary"}),e.jsx("button",{onClick:()=>ve(!0),className:"w-full px-4 py-3 text-left text-sm text-text-primary hover:bg-surface",children:"Copy with Timestamps"}),e.jsx("div",{className:"border-t border-border my-1"}),e.jsx("button",{onClick:()=>Ne("markdown"),className:"w-full px-4 py-3 text-left text-sm text-text-primary hover:bg-surface",children:"Download Transcript"}),e.jsx("div",{className:"border-t border-border my-1"}),e.jsxs("button",{onClick:()=>H(t=>
34!t),className:"w-full px-4 py-3 text-left text-sm text-text-primary hover:bg-surface flex items-center justify-between",children:[q?`Translated (${q._language})`:"Translate",e.jsx("svg",{className:`w-3.5 h-3.5 transition-transform ${$e?"rotate-90":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})]}),$e&&e.jsxs("div",{className:"bg-surface border-t border-b border-border",children:[q&&e.jsx("button",{onClick:()=>{le(null),H(!1),L(!1)},className:"w-full px-6 py-2 text-left text-xs text-primary hover:bg-background",children:"â© Back to original"}),ft.map(t=>e.jsx("button",{onClick:()=>bt(t),className:"w-full px-6 py-2 text-left text-xs text-text-primary hover:bg-background",children:t},t))]}),e.jsx("div",{className:"border-t border-border my-1"}),e.jsx("button",{onClick:()=>{de(!0),L(!1)},className:"w-full px-4 py-3 text-left text-sm text-text-primary hover:bg-surface",children:"Read & Recall"})]})})]})]})})]}),e.jsxs("div",{className:"flex flex-col pb-28",children:[K&&e.jsxs("div",{className:`mx-4 mt-4 px-4 py-3 rounded-xl text-xs flex items-start gap-2 ${K.type==="success"?"bg-emerald-500/10 border border-emerald-500/25 text-emerald-400":"bg-red-500/10 border border-red-500/25 text-red-400"}`,children:[e.jsx("span",{children:K.type==="success"?"â
":"â ï¸"}),e.jsx("span",{children:K.text}),e.jsx("button",{onClick:()=>De(null),className:"ml-auto opacity-60",children:"â"})]}),tt&&e.jsx("div",{className:"mx-4 mt-4",children:e.jsx(Tt,{noteId:s.id,noteTitle:s.title,excerpt:s.summary?.tldr?.slice(0,300),onClose:()=>de(!1)})}),ke&&e.jsx("div",{className:"px-4 pt-4",children:e.jsx("div",{className:"aspect-video rounded-xl overflow-hidden bg-black border border-border shadow-lg",children:ze(s.url)?e.jsx("iframe",{className:"w-full h-full",src:ze(s.url),title:"YouTube player",frameBorder:"0",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",referrerPolicy:"no-referrer-when-downgrade",allowFullScreen:!0}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-text-secondary/50 text-sm",children:"Video unavailable"})})}),e.jsx("div",{className:"mt-4 border-y border-border bg-surface/40 backdrop-blur-sm",children:e.jsx(qt,{active:o,onSelect:N,hasQuiz:!!(s.summary.quizQuestions&&s.summary.quizQuestions.length>0),flashcardsReady:!!E,flashcardCount:E?.count})}),o!=="summary"&&e.jsxs("div",{ref:Ae,className:"mx-4 mt-3 mb-2",children:[o==="mindmap"&&e.jsx("div",{className:"glass-card p-4",children:ce?e.jsx(ns,{mindmap:ce}):e.jsxs("div",{className:"text-center py-6 space-y-3",children:[e.jsx("p",{className:"text-text-secondary text-sm",children:"No mindmap generated yet"}),pe&&e.jsx("p",{className:"text-red-400 text-xs",children:pe}),e.jsx(v,{onClick:dt,isLoading:Ue,variant:"secondary",size:"sm",children:"Generate Mindmap"})]})}),o==="flashcards"&&e.jsx("div",{className:"glass-card p-6 flex flex-col items-center text-center space-y-4",children:E?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-14 h-14 rounded-full bg-emerald-500/10 border border-emerald-500/25 flex items-center justify-center",children:e.jsx("svg",{className:"w-7 h-7 text-emerald-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}),e.jsxs("div",{children:[e.jsxs("h3",{className:"text-lg font-display font-semibold text-text-primary",children:[E.count," Flashcards Ready"]}),e.jsxs("p",{className:"text-sm text-text-secondary mt-1",children:['Deck: "',E.deckName,'"']})]}),e.jsx(v,{onClick:()=>d("/flashcards"),variant:"secondary",children:"Go to Flashcards â"})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-14 h-14 rounded-full bg-primary/10 border border-primary/20 flex items-center justify-center",children:e.jsx("svg",{className:"w-7 h-7 text-primary",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-display font-semibold text-text-primary",children:"Create Flashcards"}),e.jsx("p",{className:"text-sm text-text-secondary mt-1",children:"Generate spaced-repetition cards from this note"})]}),fe&&e.jsx("p",{className:"text-red-400 text-xs",children:fe}),e.jsx(v,{onClick:ct,isLoading:at,variant:"secondary",children:"Generate Flashcards"})]})}),o==="chat"&&e.jsxs("div",{className:"glass-card flex flex-col",style:{height:"60vh"},children:[e.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto p-4 space-y-3 custom-scrollbar",children:[Q.length===0&&e.jsxs("div",{className:"text-center py-4",children:[e.jsx("p",{className:"text-sm text-text-secondary mb-3",children:"Ask anything about this note"}),e.jsx("div",{className:"flex flex-col gap-1.5",children:["List all key conclusions.","Get comprehensive notes.","Extract 5 key points."].map(t=>e.jsx("button",{onClick:()=>D(t),className:"px-3 py-2 text-left rounded-lg text-xs bg-surface border border-border hover:border-primary/50 text-text-primary",style:{touchAction:"manipulation"},children:t},t))})]}),Q.map((t,r)=>e.jsx("div",{className:`flex ${t.role==="user"?"justify-end":"justify-start"}`,children:e.jsx("div",{className:`max-w-[85%] px-3 py-2.5 rounded-lg text-sm ${t.role==="user"?"bg-primary text-white rounded-br-sm":"bg-surface text-text-primary rounded-bl-sm border border-border"}`,children:e.jsx(Mt,{content:t.content})})},r)),I&&e.jsx("div",{className:"flex justify-start",children:e.jsx("div",{className:"px-3 py-2.5 rounded-lg rounded-bl-sm bg-surface border border-border",children:e.jsx("div",{className:"flex gap-1",children:[0,150,300].map(t=>e.jsx("span",{className:"w-2 h-2 rounded-full animate-bounce bg-text-secondary",style:{animationDelay:`${t}ms`}},t))})})}),e.jsx("div",{ref:Re})]}),Pe&&e.jsx("div",{className:"shrink-0 px-3",children:Pe}),e.jsxs("div",{className:"shrink-0 flex gap-2 p-3 border-t border-border",children:[e.jsx("input",{type:"text",value:oe,onChange:t=>Ee(t.target.value),onKeyDown:t=>{t.key==="Enter"&&!t.shiftKey&&(t.preventDefault(),D())},placeholder:"Ask a questionâ¦",className:"flex-1 px-3 py-2 text-sm rounded-lg focus:outline-none focus:ring-2 focus:ring-primary input-base border",disabled:I}),e.jsx(v,{onClick:()=>D(),disabled:I||!oe.trim(),variant:"secondary",size:"sm",children:"Send"})]})]}),o==="quiz"&&s.summary.quizQuestions&&e.jsxs("div",{className:"space-y-3",children:[yt,B&&e.jsx("div",{className:"glass-card p-4 text-center",children:(()=>{const t=jt();return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"text-4xl font-bold mb-1",style:{color:t.percentage>=80?"#10b981":t.percentage>=60?"#f59e0b":"#ef4444"},children:[t.percentage,"%"]}),e.jsxs("p",{className:"text-sm text-text-secondary",children:[t.correct," / ",t.total," correct"]}),e.jsx("button",{onClick:ht,className:"mt-3 text-primary text-sm underline",children:"Retake"})]})})()}),s.summary.quizQuestions.map((t,r)=>{const i=O[r],l=i===t.correctAnswer;return e.jsxs("div",{className:"glass-card p-4",children:[e.jsxs("p",{className:"font-semibold text-sm text-text-primary mb-3",children:[r+1,". ",t.question]}),e.jsx("div",{className:"space-y-2",children:t.options.map((j,T)=>{const te=i===T,U=T===t.correctAnswer;let G="w-full px-3 py-2.5 text-left rounded-lg border text-sm transition-colors ";return B?G+=U?"bg-green-500/20 border-green-500/50 text-green-300":te?"bg-red-500/20 border-red-500/50 text-red-300":"bg-surface border-border text-text-secondary":G+=te?"bg-primary/20 border-primary/50 text-text-primary":"bg-surface border-border text-text-secondary",e.jsx("button",{onClick:()=>ut(r,T),disabled:B,className:G,style:{touchAction:"manipulation"},children:j},T)})}),B&&t.explanation&&e.jsxs("div",{className:`mt-3 p-3 rounded-lg text-xs ${l?"bg-green-500/10 border border-green-500/20":"bg-blue-500/10 border border-blue-500/20"} text-text-primary`,children:[e.jsx("strong",{children:"Explanation:"})," ",t.explanation]})]},r)}),!B&&e.jsx(v,{onClick:pt,variant:"secondary",disabled:Object.keys(O).length<s.summary.quizQuestions.length,className:"w-full",children:Object.keys(O).length<s.summary.quizQuestions.length?`Answer all ${s.summary.quizQuestions.length} questions`:"Show Results"})]})]}),ue&&e.jsxs("div",{className:"mx-4 mt-4 px-4 py-3 rounded-xl text-xs flex items-center gap-2 bg-primary/10 border border-primary/25 text-primary",children:[e.jsxs("svg",{className:"w-4 h-4 animate-spin shrink-0",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),"Translatingâ¦"]}),q&&!ue&&e.jsxs("div",{className:"mx-4 mt-4 px-4 py-3 rounded-xl text-xs flex items-center justify-between bg-primary/10 border border-primary/25 text-primary",children:[e.jsxs("span",{children:["Viewing in ",q._language]}),e.jsx("button",{onClick:()=>le(null),className:"underline opacity-70 hover:opacity-100",children:"Back to original"})]}),(k.tldr||u)&&e.jsxs("section",{className:"mx-4 mt-4 glass-card p-4 bg-gradient-to-br from-purple-500/5 to-transparent border-purple-500/20",children:[e.jsx(J,{children:e.jsx("span",{className:"text-purple-400",children:"TL;DR"})}),u?e.jsx("textarea",{value:z,onChange:t=>se(t.target.value),className:"w-full min-h-[80px] p-3 border border-purple-500/30 rounded-xl focus:ring-2 focus:ring-purple-500 text-sm resize-y input-base"}):e.jsx("p",{className:"text-base leading-relaxed font-medium text-text-primary",children:At(k.tldr)})]}),!g&&!u&&e.jsxs("section",{className:"mx-4 mt-4 rounded-2xl p-4 flex flex-col sm:flex-row items-start sm:items-center gap-4",style:{background:"linear-gradient(135deg, rgba(167,139,250,0.08), rgba(34,211,238,0.05))",border:"1px solid rgba(167,139,250,0.25)"},children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-semibold text-text-primary mb-0.5",children:"Save summaries & unlock AI chat"}),e.jsx("p",{className:"text-xs text-text-muted",children:"Get Pro to chat with this note, build knowledge graphs, and more."})]}),e.jsx(Ut,{to:"/pricing",className:"shrink-0 w-full sm:w-auto text-center px-5 py-2.5 rounded-xl text-sm font-bold transition-all duration-150 hover:opacity-90 active:scale-95",style:{background:"linear-gradient(135deg, #7c3aed, #0ea5e9)",color:"#fff",boxShadow:"0 0 16px rgba(124,58,237,0.3)"},children:"Upgrade to Pro â 25% OFF"})]}),k.keyMoments&&k.keyMoments.length>0&&e.jsxs("section",{className:"mx-4 mt-4 glass-card p-4",children:[e.jsx(J,{children:"Key Moments"}),e.jsx("div",{className:"space-y-3",children:k.keyMoments.map((t,r)=>e.jsxs("div",{className:"flex items-start gap-3 p-3 rounded-lg bg-background border border-border",children:[e.jsx("button",{onClick:()=>{const i=_e(s.platform,s.url,t.time);window.open(i,"_blank","noopener,noreferrer")},className:"shrink-0 px-2 py-1 bg-primary/10 text-primary font-mono text-xs font-bold rounded border border-primary/20 hover:bg-primary/20 transition-colors",style:{touchAction:"manipulation"},children:Y(t.time)}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-semibold text-sm text-text-primary leading-tight",children:t.title}),e.jsx("p",{className:"text-xs text-text-secondary mt-1 leading-relaxed",children:t.summary})]})]},r))})]}),(k.keyConcepts?.length>0||u)&&e.jsxs("section",{className:"mx-4 mt-4 glass-card p-4",children:[e.jsx(J,{children:"Key Concepts"}),u?e.jsxs("div",{className:"space-y-2",children:[F.map((t,r)=>e.jsx("input",{type:"text",value:t,onChange:i=>{const l=[...F];l[r]=i.target.value,X(l)},className:"w-full px-3 py-2 border rounded-xl text-sm input-base"},r)),e.jsx("button",{onClick:()=>X([...F,""]),className:"text-primary text-sm font-medium",children:"+ Add"})]}):e.jsx("div",{className:"flex flex-wrap gap-2",children:k.keyConcepts.map((t,r)=>e.jsx("span",{className:"px-3 py-1.5 border border-border rounded-lg text-sm font-medium bg-surface text-text-primary",children:t},r))})]}),(k.takeaways?.length>0||u)&&e.jsxs("section",{className:"mx-4 mt-4 glass-card p-4",children:[e.jsx(J,{children:"Actionable Takeaways"}),u?e.jsxs("div",{className:"space-y-2",children:[$.map((t,r)=>e.jsx("textarea",{value:t,onChange:i=>{const l=[...$];l[r]=i.target.value,y(l)},className:"w-full min-h-[50px] p-3 border rounded-xl text-sm input-base"},r)),e.jsx("button",{onClick:()=>y([...$,""]),className:"text-primary text-sm font-medium",children:"+ Add"})]}):e.jsx("ul",{className:"space-y-2.5",children:k.takeaways.map((t,r)=>e.jsxs("li",{className:"flex items-start gap-3 text-text-secondary",children:[e.jsx("div",{className:"mt-0.5 w-
345 h-5 rounded-full bg-primary/20 text-primary flex items-center justify-center text-xs font-bold border border-primary/30 shrink-0",children:r+1}),e.jsx("span",{className:"leading-relaxed text-sm",children:t})]},r))})]}),(k.definitions?.length>0||u)&&e.jsxs("section",{className:"mx-4 mt-4 glass-card p-4",children:[e.jsx(J,{children:"Definitions"}),u?e.jsxs("div",{className:"space-y-2",children:[R.map((t,r)=>e.jsx("textarea",{value:t,onChange:i=>{const l=[...R];l[r]=i.target.value,Z(l)},className:"w-full min-h-[50px] p-3 border rounded-xl text-sm input-base"},r)),e.jsx("button",{onClick:()=>Z([...R,""]),className:"text-primary text-sm font-medium",children:"+ Add"})]}):e.jsx("div",{className:"space-y-3",children:k.definitions.map((t,r)=>{const[i,...l]=t.split(":");return e.jsxs("div",{className:"p-3 rounded-xl border border-border bg-background",children:[e.jsx("strong",{className:"font-semibold text-sm block mb-1 text-text-primary",children:i}),e.jsx("span",{className:"text-xs text-text-secondary leading-relaxed",children:l.join(":")})]},r)})})]}),s.rawContent&&s.rawContent.trim().length>0&&!u&&(()=>{const t=$t(s.rawContent);return t?e.jsxs("section",{className:"mx-4 mt-4 glass-card p-4",children:[e.jsx(J,{children:"Full Report"}),e.jsx("div",{className:`prose prose-sm max-w-none prose-headings:text-text-primary prose-p:text-text-secondary prose-li:text-text-secondary prose-strong:text-text-primary prose-code:text-primary prose-code:bg-surface prose-code:px-1 prose-code:rounded prose-code:text-xs ${h?"prose-invert":""}`,children:e.jsx(Me,{remarkPlugins:[Le],children:t})})]}):null})(),e.jsxs("section",{className:"mx-4 mt-4 glass-card p-4",children:[e.jsx(J,{children:"Custom Notes"}),u?e.jsx("textarea",{value:C,onChange:t=>M(t.target.value),className:"w-full min-h-[120px] p-3 border rounded-xl font-mono text-sm placeholder-text-secondary/50 resize-y input-base",placeholder:"Add your markdown notes here..."}):e.jsx("div",{className:`prose prose-sm max-w-none prose-p:text-text-secondary prose-headings:text-text-primary ${h?"prose-invert":""}`,children:C?e.jsx(Me,{remarkPlugins:[Le],children:C}):e.jsx("p",{className:"text-text-secondary/50 italic text-sm",children:"No custom notes added yet. Save an AI Chat conversation here from the Chat tab, or edit this note to write your own."})})]}),e.jsxs("section",{className:"mx-4 mt-4 glass-card p-4",children:[e.jsx(J,{children:"Connections"}),e.jsx(zt,{noteId:s.id})]}),e.jsx("div",{className:"mx-4 mt-4",children:e.jsx(Lt,{tags:s.tags??[],isSaving:st,onSave:async t=>{he(!0);try{await S.updateNoteTags(s.id,t),c.invalidateQueries({queryKey:["note",a]}),c.invalidateQueries({queryKey:["notes"]})}finally{he(!1)}}})})]})]}),e.jsx(St,{isOpen:b,onClose:()=>w(!1),title:"Delete Note",size:"sm",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx("p",{className:"text-text-secondary",children:"Are you sure you want to delete this note? This action cannot be undone."}),e.jsxs("div",{className:"flex items-center justify-end space-x-3 border-t border-border pt-4",children:[e.jsx(v,{variant:"outline",onClick:()=>w(!1),children:"Cancel"}),e.jsx(v,{variant:"danger",onClick:Nt,isLoading:We.isPending,children:"Delete Permanently"})]})]})})]}):e.jsxs(Se,{children:[e.jsx(Ct,{title:s.title||"Note",description:s.summary?.tldr||"View and study your saved note.",noindex:!0}),e.jsxs("div",{className:"flex flex-col md:h-[calc(100vh-80px)] md:overflow-hidden bg-background text-text-primary",children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 md:px-4 py-3 border-b backdrop-blur-md sticky top-0 z-40 min-h-[56px] md:h-[73px] border-border bg-surface",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[e.jsx(v,{variant:"outline",size:"sm",onClick:()=>d("/notes"),children:"â Back"}),W?e.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[e.jsx("input",{type:"text",value:V,onChange:t=>P(t.target.value),onKeyDown:t=>{t.key==="Enter"&&ge(),t.key==="Escape"&&je()},className:"flex-1 px-3 py-1.5 border border-primary/50 rounded-lg focus:outline-none focus:ring-2 focus:ring-primary input-base",autoFocus:!0}),e.jsx("button",{onClick:ge,className:"p-1.5 text-green-400 hover:bg-green-400/10 rounded transition-colors",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}),e.jsx("button",{onClick:je,className:"p-1.5 text-red-400 hover:bg-red-400/10 rounded transition-colors",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}):e.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[e.jsx("h1",{className:"text-base md:text-xl font-display font-bold tracking-wide truncate text-text-primary",children:s.title}),e.jsx("button",{onClick:it,className:"p-1 text-text-secondary hover:text-primary hover:bg-primary/10 rounded transition-colors flex-shrink-0",title:"Edit title and content",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})})]})]}),e.jsxs("div",{className:"flex items-center gap-1 md:gap-3 flex-shrink-0",children:[u?e.jsxs(e.Fragment,{children:[e.jsx(v,{variant:"secondary",size:"sm",onClick:()=>{x(!1),A(!1)},children:"Cancel"}),e.jsx(v,{variant:"secondary",size:"sm",onClick:vt,isLoading:be.isPending,children:"Save Changes"})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>ot.mutate(!s.starred),title:s.starred?"Remove from Starred":"Add to Starred",className:`p-2 rounded-lg transition-colors ${s.starred?"text-amber-400 hover:text-amber-300 hover:bg-amber-400/10":"text-text-secondary hover:text-amber-400 hover:bg-amber-400/10"}`,children:e.jsx("svg",{className:"w-5 h-5",fill:s.starred?"currentColor":"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11.049 2.927c.3-.921 1.603-.921 1.902 0l1.519 4.674a1 1 0 00.95.69h4.915c.969 0 1.371 1.24.588 1.81l-3.976 2.888a1 1 0 00-.363 1.118l1.518 4.674c.3.922-.755 1.688-1.538 1.118l-3.976-2.888a1 1 0 00-1.176 0l-3.976 2.888c-.783.57-1.838-.197-1.538-1.118l1.518-4.674a1 1 0 00-.363-1.118l-3.976-2.888c-.784-.57-.38-1.81.588-1.81h4.914a1 1 0 00.951-.69l1.519-4.674z"})})}),e.jsx("button",{onClick:async()=>{try{const r=await(await fetch(`${Zt()}
34/share/${s.id}`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${f}`}})).json();if(r.shareToken){const i=`${window.location.origin}/share/${r.shareToken}`;await navigator.clipboard.writeText(i),alert("Share link copied to clipboard!")}}catch{alert("Failed to generate share link")}},className:"p-2 text-text-secondary hover:text-primary hover:bg-primary/10 rounded-lg transition-colors",title:"Copy share link",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8.684 13.342C8.886 12.938 9 12.482 9 12c0-.482-.114-.938-.316-1.342m0 2.684a3 3 0 110-2.684m0 2.684l6.632 3.316m-6.632-6l6.632-3.316m0 0a3 3 0 105.367-2.684 3 3 0 00-5.367 2.684zm0 9.316a3 3 0 105.368 2.684 3 3 0 00-5.368-2.684z"})})}),e.jsx("button",{onClick:()=>w(!0),className:"p-2 text-text-secondary hover:text-red-400 hover:bg-red-400/10 rounded-lg transition-colors",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})})]}),e.jsxs("div",{className:"flex items-center gap-1 md:gap-2 pl-1 md:pl-2 ml-1 border-l border-border",children:[e.jsx(es,{}),e.jsx(ts,{})]})]})]}),e.jsxs("div",{className:"flex flex-col md:flex-row flex-1 md:min-h-0 md:overflow-hidden",children:[ke&&e.jsx("div",{className:"w-full md:w-1/2 min-h-0 flex flex-col border-b md:border-b-0 md:border-r border-border md:overflow-hidden bg-surface",children:e.jsxs("div",{className:"flex-1 md:overflow-y-auto custom-scrollbar p-4 md:p-6",children:[e.jsx("div",{className:"aspect-video bg-black rounded-2xl border border-border mb-8 overflow-hidden shadow-2xl relative group",children:ze(s.url)?e.jsx("iframe",{className:"w-full h-full",src:ze(s.url),title:"YouTube player",frameBorder:"0",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",referrerPolicy:"no-referrer-when-downgrade",allowFullScreen:!0}):e.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center text-text-secondary/50",children:[e.jsx("svg",{className:"w-16 h-16 mb-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1,d:"M15 10l4.553-2.276A1 1 0 0121 8.618v6.764a1 1 0 01-1.447.894L15 14M5 18h8a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v8a2 2 0 002 2z"})}),e.jsx("p",{children:"Video source unavailable"})]})}),e.jsx("div",{className:"mb-6 -mx-0 border border-border rounded-2xl overflow-hidden bg-background/40",children:e.jsx(qt,{active:o,onSelect:N,hasQuiz:!!(s.summary.quizQuestions&&s.summary.quizQuestions.length>0),flashcardsReady:!!E,flashcardCount:E?.count})}),s.summary.keyMoments&&s.summary.keyMoments.length>0&&e.jsxs("div",{className:"mb-8",children:[e.jsxs("h3",{className:"text-lg font-display font-semibold mb-6 flex items-center text-text-primary",children:[e.jsx("svg",{className:"w-5 h-5 mr-2 text-primary",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})}),"Key Moments Timeline"]}),e.jsx("div",{className:"space-y-4 relative before:absolute before:inset-y-0 before:left-[11px] before:w-[2px] ml-2 before:bg-border",children:s.summary.keyMoments.map((t,r)=>e.jsxs("div",{className:"relative pl-8 group",children:[e.jsx("div",{className:"absolute left-0 top-1.5 w-6 h-6 rounded-full group-hover:bg-primary transition-colors flex items-center justify-center shadow-[0_0_10px_rgba(99,102,241,0.5)] bg-surface border-2 border-primary",children:e.jsx("div",{className:"w-2 h-2 rounded-full bg-primary"})}),e.jsxs("div",{className:"glass-card p-5 hover:border-primary/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("button",{onClick:i=>{i.stopPropagation();const l=_e(s.platform,s.url,t.time);window.open(l,"_blank","noopener,noreferrer")},className:"px-2.5 py-1 bg-primary/10 text-primary font-mono text-xs font-bold tracking-wider rounded border border-primary/20 hover:bg-primary/20 hover:border-primary/40 transition-colors cursor-pointer",title:kt(s.platform)?`Jump to ${Y(t.time)} in video`:`Open video (timestamp navigation not supported for ${s.platform})`,children:Y(t.time)}),e.jsx("h4",{className:"font-semibold text-text-primary",children:t.title})]}),e.jsx("p",{className:"text-sm text-text-secondary leading-relaxed",children:t.summary}),t.image&&e.jsx("img",{src:t.image,alt:t.title,className:"mt-4 rounded-xl max-w-sm border border-white/10 cursor-pointer hover:opacity-90 transition-opacity",onClick:()=>window.open(t.image,"_blank")})]})]},r))})]})]})}),e.jsxs("div",{className:`${ke?"w-full md:w-1/2":"w-full"} min-h-0 flex flex-col relative overflow-visible bg-surface`,children:[e.jsxs("div",{className:"flex items-stretch border-b border-border flex-shrink-0 relative z-30 min-h-0 overflow-visible bg-surface backdrop-blur-md",children:[e.jsxs("div",{className:"flex flex-1 min-w-0 items-center gap-1 overflow-x-auto overflow-y-visible",children:[e.jsx("button",{type:"button",onClick:()=>N("summary"),className:`shrink-0 px-3 md:px-4 py-2.5 text-sm font-medium transition-colors min-h-[44px] ${o==="summary"?"text-primary border-b-2 border-primary":"text-text-secondary hover:text-text-primary"}`,style:{touchAction:"manipulation"},children:"Summary"}),e.jsx("button",{type:"button",onClick:()=>N("mindmap"),className:`shrink-0 px-3 md:px-4 py-2.5 text-sm font-medium transition-colors min-h-[44px] ${o==="mindmap"?"text-primary border-b-2 border-primary":"text-text-secondary hover:text-text-primary"}`,style:{touchAction:"manipulation"},children:"Mind Map"}),e.jsx("button",{type:"button",onClick:()=>N("chat"),className:`shrink-0 px-3 md:px-4 py-2.5 text-sm font-medium transition-colors min-h-[44px] ${o==="chat"?"text-primary border-b-2 border-primary":"text-text-secondary hover:text-text-primary"}`,style:{touchAction:"manipulation"},children:"AI Chat"}),e.jsxs("button",{type:"button",onClick:()=>N("quiz"),className:`shrink-0 px-3 md:px-4 py-2.5 text-sm font-medium transition-colors min-h-[44px] ${o==="quiz"?"text-primary border-b-2 border-primary":"text-text-secondary hover:text-text-primary"}`,style:{touchAction:"manipulation"},disabled:!s?.summary?.quizQuestions||s.summary.quizQuestions.length===0,children:["Quiz",s?.summary?.quizQuestions&&s.summary.quizQuestions.length>0&&e.jsxs("span",{className:"ml-1 text-xs",children:["(",s.summary.quizQuestions.length,")"]})]}),e.jsxs("button",{type:"button",onClick:()=>N("flashcards"),className:`shrink-0 px-3 md:px-4 py-2.5 text-sm font-medium transition-colors min-h-[44px] ${o==="flashcards"?"text-primary border-b-2 border-primary":"text-text-secondary hover:text-text-primary"}`,style:{touchAction:"manipulation"},children:["Flashcards",E&&e.jsxs("span",{className:"ml-1 text-xs",children:["(",E.count,")"]})]})]}),e.jsxs("div",{className:"relative shrink-0",ref:xe,children:[e.jsxs("button",{type:"button",onClick:t=>{t.stopPropagation(),L(r=>!r)},className:`px-3 md:px-4 py-2.5 text-sm font-medium transition-colors flex items-center gap-1 min-h-[44px] ${o==="more"?"text-primary border-b-2 border-primary":"text-text-secondary hover:text-text-primary"}`,style:{touchAction:"manipulation"},children:["More",e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),_&&e.jsx("div",{className:"absolute top-full right-0 mt-1 w-56 backdrop-blur-md border border-border rounded-lg shadow-xl z-[60] bg-background overflow-visible",children:e.jsxs("div",{className:"py-1",children:[e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:()=>{ne(!1),H(!1),ee(t=>!t)},className:"w-full px-4 py-2 text-left text-sm flex items-center justify-between text-text-primary hover:bg-surface",children:["Copy Summary",e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})]}),ae&&e.jsxs("div",{ref:Qt,className:"absolute right-full top-0 mr-1 w-48 backdrop-blur-md border border-border rounded-lg shadow-xl z-50 overflow-hidden bg-background",children:[e.jsx("button",{onClick:()=>ve(!0),className:"w-full px-4 py-2 text-left text-sm text-text-primary hover:bg-surface",children:"Copy with timestamp"}),e.jsx("button",{onClick:()=>ve(!1),className:"w-full px-4 py-2 text-left text-sm text-text-primary hover:bg-surface",children:"Copy without timestamp"})]})]}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:()=>{ee(!1),H(!1),ne(t=>!t)},className:"w-full px-4 py-2 text-left text-sm flex items-center justify-between text-text-primary hover:bg-surface",children:["Download Transcript",e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})]}),Rt&&e.jsxs("div",{ref:Bt,className:"absolute right-full top-0 mr-1 w-48 backdrop-blur-md border border-border rounded-lg shadow-xl z-50 overflow-hidden bg-background",children:[e.jsx("button",{onClick:()=>Ne("json"),className:"w-full px-4 py-2 text-left text-sm text-text-primary hover:bg-surface",children:"Download as JSON"}),e.jsx("button",{onClick:()=>Ne("pdf"),className:"w-full px-4 py-2 text-left text-sm text-text-primary hover:bg-surface",children:"Download as PDF"}),e.jsx("button",{onClick:()=>Ne("markdown"),className:"w-full px-4 py-2 text-left text-sm text-text-primary hover:bg-surface",children:"Download as Markdown"})]})]}),e.jsx("button",{onClick:xt,className:"w-full px-4 py-2 text-left text-sm text-text-primary hover:bg-surface",children:"Generate Quiz"}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:()=>{ee(!1),ne(!1),H(t=>!t)},className:"w-full px-4 py-2 text-left text-sm flex items-center justify-between text-text-primary hover:bg-surface",children:[q?`Translated (${q._language})`:"Translate",e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})]}),$e&&e.jsxs("div",{className:"absolute right-full top-0 mr-1 w-
3452 max-h-[60vh] overflow-y-auto custom-scrollbar backdrop-blur-md border border-border rounded-lg shadow-xl z-50 bg-background",children:[q&&e.jsx("button",{onClick:()=>{le(null),H(!1),L(!1)},className:"w-full px-4 py-2 text-left text-sm text-primary hover:bg-surface",children:"â© Back to original"}),ft.map(t=>e.jsx("button",{onClick:()=>bt(t),className:"w-full px-4 py-2 text-left text-sm text-text-primary hover:bg-surface",children:t},t))]})]}),e.jsx("button",{onClick:()=>{de(!0),L(!1)},className:"w-full px-4 py-2 text-left text-sm text-text-primary hover:bg-surface",children:"Read & Recall"})]})})]})]}),K&&e.jsxs("div",{className:`mx-6 mt-3 px-4 py-3 rounded-xl text-xs flex items-start gap-2 ${K.type==="success"?"bg-emerald-500/10 border border-emerald-500/25 text-emerald-400":"bg-red-500/10 border border-red-500/25 text-red-400"}`,children:[e.jsx("span",{children:K.type==="success"?"â
":"â ï¸"}),e.jsx("span",{children:K.text}),K.type==="success"&&e.jsx("button",{onClick:()=>{De(null),de(!0)},className:"ml-2 underline font-medium hover:no-underline",children:"Start session â"}),e.jsx("button",{onClick:()=>De(null),className:"ml-auto opacity-60 hover:opacity-100",children:"â"})]}),tt&&s&&e.jsx("div",{className:"mx-6 mt-4",children:e.jsx(Tt,{noteId:s.id,noteTitle:s.title,excerpt:s.summary?.tldr?.slice(0,300),onClose:()=>de(!1)})}),s&&e.jsx("div",{className:"mx-6 mt-3",children:e.jsx(Lt,{tags:s.tags??[],isSaving:st,onSave:async t=>{he(!0);try{await S.updateNoteTags(s.id,t),c.invalidateQueries({queryKey:["note",a]}),c.invalidateQueries({queryKey:["notes"]})}finally{he(!1)}}})}),e.jsxs("div",{className:o==="chat"?"flex flex-col p-4 md:p-6 h-[65vh] md:h-auto md:flex-1 md:min-h-0 overflow-hidden":o==="mindmap"?"flex flex-col md:flex-1 md:min-h-0 md:overflow-hidden":"flex flex-col p-4 pb-24 md:p-6 md:flex-1 md:min-h-0 md:overflow-y-auto custom-scrollbar",children:[o==="summary"&&e.jsxs("div",{className:"space-y-6",children:[ue&&e.jsxs("div",{className:"px-4 py-3 rounded-xl text-sm flex items-center gap-2 bg-primary/10 border border-primary/25 text-primary",children:[e.jsxs("svg",{className:"w-4 h-4 animate-spin shrink-0",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),"Translatingâ¦"]}),q&&!ue&&e.jsxs("div",{className:"px-4 py-3 rounded-xl text-sm flex items-center justify-between bg-primary/10 border border-primary/25 text-primary",children:[e.jsxs("span",{children:["Viewing in ",q._language]}),e.jsx("button",{onClick:()=>le(null),className:"underline opacity-70 hover:opacity-100",children:"Back to original"})]}),(k.tldr||u)&&e.jsxs("section",{className:"glass-card p-4 md:p-6 bg-gradient-to-br from-purple-500/5 to-transparent border-purple-500/20",children:[e.jsx("h3",{className:"text-sm font-bold tracking-widest text-purple-400 uppercase mb-4 border-b border-purple-500/10 pb-2",children:"TL;DR"}),u?e.jsx("textarea",{value:z,onChange:t=>se(t.target.value),className:"w-full min-h-[100px] p-4 border border-purple-500/30 rounded-xl focus:ring-2 focus:ring-purple-500 focus:border-transparent text-sm resize-y transition-all input-base"}):e.jsx("p",{className:"text-lg leading-relaxed font-medium text-text-primary",children:At(k.tldr)})]}),s.summary.quizQuestions&&s.summary.quizQuestions.length>0&&e.jsx("section",{className:"glass-card p-4 bg-gradient-to-r from-primary/10 to-purple-500/10 border border-primary/20",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-primary/20 flex items-center justify-center",children:e.jsx("svg",{className:"w-5 h-5 text-primary",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4M7.835 4.697a3.42 3.42 0 001.946-.806 3.42 3.42 0 014.438 0 3.42 3.42 0 001.946.806 3.42 3.42 0 013.138 3.138 3.42 3.42 0 00.806 1.946 3.42 3.42 0 010 4.438 3.42 3.42 0 00-.806 1.946 3.42 3.42 0 01-3.138 3.138 3.42 3.42 0 00-1.946.806 3.42 3.42 0 01-4.438 0 3.42 3.42 0 00-1.946-.806 3.42 3.42 0 01-3.138-3.138 3.42 3.42 0 00-.806-1.946 3.42 3.42 0 010-4.438 3.42 3.42 0 00.806-1.946 3.42 3.42 0 013.138-3.138z"})})}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold text-text-primary",children:"Qu
34iz Available"}),e.jsxs("p",{className:"text-sm text-text-secondary",children:[s.summary.quizQuestions.length," quiz ",s.summary.quizQuestions.length===1?"question":"questions"," ready to test your knowledge"]})]})]}),e.jsx(v,{onClick:()=>N("quiz"),variant:"secondary",size:"sm",children:"Take Quiz"})]})}),!ke&&k.keyMoments&&k.keyMoments.length>0&&e.jsxs("section",{className:"glass-card p-4 md:p-6",children:[e.jsxs("h3",{className:"text-lg font-display font-semibold mb-6 flex items-center text-text-primary",children:[e.jsx("svg",{className:"w-5 h-5 mr-2 text-primary",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})}),"Key Moments Timeline"]}),e.jsx("div",{className:"space-y-4 relative before:absolute before:inset-y-0 before:left-[11px] before:w-[2px] ml-2 before:bg-border",children:k.keyMoments.map((t,r)=>e.jsxs("div",{className:"relative pl-8 group",children:[e.jsx("div",{className:"absolute left-0 top-1.5 w-6 h-6 rounded-full group-hover:bg-primary transition-colors flex items-center justify-center shadow-[0_0_10px_rgba(99,102,241,0.5)] bg-surface border-2 border-primary",children:e.jsx("div",{className:"w-2 h-2 rounded-full bg-primary"})}),e.jsxs("div",{className:"glass-card p-5 hover:border-primary/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("button",{onClick:i=>{i.stopPropagation();const l=_e(s.platform,s.url,t.time);window.open(l,"_blank","noopener,noreferrer")},className:"px-2.5 py-1 bg-primary/10 text-primary font-mono text-xs font-bold tracking-wider rounded border border-primary/20 hover:bg-primary/20 hover:border-primary/40 transition-colors cursor-pointer",title:kt(s.platform)?`Jump to ${Y(t.time)} in video`:`Open video (timestamp navigation not supported for ${s.platform})`,children:Y(t.time)}),e.jsx("h4",{className:"font-semibold text-text-primary",children:t.title})]}),e.jsx("p",{className:"text-sm text-text-secondary leading-relaxed",children:t.summary}),t.image&&e.jsx("img",{src:t.image,alt:t.title,className:"mt-4 rounded-xl max-w-sm border border-white/10 cursor-pointer hover:opacity-90 transition-opacity",onClick:()=>window.open(t.image,"_blank")})]})]},r))})]}),(k.keyConcepts?.length>0||u)&&e.jsxs("section",{className:"glass-card p-4 md:p-6",children:[e.jsx("h3",{className:"text-sm font-bold tracking-widest uppercase mb-4 border-b border-border pb-2 text-text-secondary",children:"Key Concepts"}),u?e.jsxs("div",{className:"space-y-3",children:[F.map((t,r)=>e.jsx("input",{type:"text",value:t,onChange:i=>{const l=[...F];l[r]=i.target.value,X(l)},className:"w-full px-4 py-3 border rounded-xl focus:ring-2 focus:ring-primary focus:border-transparent text-sm transition-all input-base"},r)),e.jsx("button",{onClick:()=>X([...F,""]),className:"text-primary text-sm font-medium hover:text-text-primary transition-colors",children:"+ Add Concept"})]}):e.jsx("div",{className:"flex flex-wrap gap-2",children:k.keyConcepts.map((t,r)=>e.jsx("span",{className:"px-3 py-1.5 border border-border rounded-lg text-sm shadow-sm font-medium bg-surface text-text-primary",children:t},r))})]}),(k.takeaways?.length>0||u)&&e.jsxs("section",{className:"glass-card p-4 md:p-6",children:[e.jsx("h3",{className:"text-sm font-bold tracking-widest uppercase mb-4 border-b border-border pb-2 text-text-secondary",children:"Actionable Takeaways"}),u?e.jsxs("div",{className:"space-y-3",children:[$.map((t,r)=>e.jsx("textarea",{value:t,onChange:i=>{const l=[...$];l[r]=i.target.value,y(l)},className:"w-full min-h-[60px] p-4 border rounded-xl focus:ring-2 focus:ring-primary focus:border-transparent text-sm transition-all input-base"},r)),e.jsx("button",{onClick:()=>y([...$,""]),className:"text-primary text-sm font-medium hover:text-text-primary transition-colors",children:"+ Add Takeaway"})]}):e.jsx("ul",{className:"space-y-3",children:k.takeaways.map((t,r)=>e.jsxs("li",{className:"flex items-start gap-3 text-text-secondary",children:[e.jsx("div",{className:"mt-1 w-5 h-5 rounded-full bg-primary/20 text-primary flex items-center justify-center text-xs font-bold border border-primary/30 shrink-0",children:r+1}),e.jsx("span",{className:"leading-relaxed",children:t})]},r))})]}),(k.definitions?.length>0||u)&&e.jsxs("section",{className:"glass-card p-4 md:p-6",children:[e.jsx("h3",{className:"text-sm font-bold tracking-widest uppercase mb-4 border-b border-border pb-2 text-text-secondary",children:"Definitions"}),u?e.jsxs("div",{className:"space-y-3",children:[R.map((t,r)=>e.jsx("textarea",{value:t,onChange:i=>{const l=[...R];l[r]=i.target.value,Z(l)}
34,className:"w-full min-h-[60px] p-4 border rounded-xl focus:ring-2 focus:ring-primary focus:border-transparent text-sm transition-all input-base"},r)),e.jsx("button",{onClick:()=>Z([...R,""]),className:"text-primary text-sm font-medium hover:text-text-primary transition-colors",children:"+ Add Definition"})]}):e.jsx("div",{className:"space-y-4",children:k.definitions.map((t,r)=>{const[i,...l]=t.split(":"),j=l.join(":");return e.jsxs("div",{className:"p-4 rounded-xl border border-border bg-surface",children:[e.jsx("strong",{className:"font-semibold block mb-1 text-text-primary",children:i}),e.jsx("span",{className:"text-sm text-text-secondary",children:j})]},r)})})]}),s.rawContent&&s.rawContent.trim().length>0&&!u&&(()=>{const t=$t(s.rawContent);return t?e.jsxs("section",{className:"glass-card p-4 md:p-6",children:[e.jsx("h3",{className:"text-sm font-bold tracking-widest uppercase mb-4 border-b border-border pb-2 text-text-secondary",children:"Full Report"}),e.jsx("div",{className:`prose prose-sm max-w-none 35 prose-headings:text-text-primary prose-headings:font-semibold 36 prose-h2:text-base prose-h2:mt-6 prose-h2:mb-3 prose-h2:pb-1.5 prose-h2:border-b prose-h2:border-border 37 prose-h3:text-sm prose-h3:mt-4 prose-h3:mb-2 38 prose-p:text-text-secondary prose-p:leading-relaxed prose-p:my-3 39 prose-li:text-text-secondary prose-ul:my-3 prose-ol:my-3 prose-li:my-1 40 prose-strong:text-text-primary 41 prose-code:text-primary prose-code:bg-surface prose-code:px-1 prose-code:rounded prose-code:text-xs 42 prose-hr:border-border prose-hr:my-6 43 ${h?"prose-invert":""}`,children:e.jsx(Me,{remarkPlugins:[Le],children:t})})]}):null})(),e.jsxs("section",{className:"glass-card p-4 md:p-6",children:[e.jsx("h3",{className:"text-sm font-bold tracking-widest uppercase mb-4 border-b border-border pb-2 text-text-secondary",children:"Custom Notes"}),u?e.jsx("textarea",{value:C,onChange:t=>M(t.target.value),className:"w-full min-h-[150px] p-4 border rounded-xl focus:ring-2 focus:ring-primary focus:border-transparent font-mono text-sm placeholder-text-secondary/50 resize-y transition-all input-base",placeholder:"Add your markdown notes here..."}):e.jsx("div",{className:`prose max-w-none prose-p:text-text-secondary prose-headings:text-text-primary ${h?"prose-invert":""}`,children:C?e.jsx(Me,{remarkPlugins:[Le],children:C}):e.jsx("p",{className:"text-text-secondary/50 italic text-sm",children:"No custom notes added yet. Edit this note to write your own, or save an AI Chat conversation here from the Chat tab."})})]}),e.jsxs("section",{className:"glass-card p-4 md:p-6",children:[e.jsx("h3",{className:"text-sm font-bold tracking-widest uppercase mb-4 border-b border-border pb-2 text-text-secondary",children:"Connections"}),e.jsx(zt,{noteId:s.id})]})]}),o==="mindmap"&&e.jsx("div",{className:"h-[60vh] md:h-full",children:ce?e.jsx(ss,{mindmap:ce}):e.jsx("div",{className:"flex flex-col items-center justify-center h-full space-y-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h3",{className:"text-xl font-display font-semibold text-text-primary mb-2",children:"No Mindmap Generated"}),e.jsx("p",{className:"text-text-secondary mb-6",children:"Generate a mindmap from this note's summary"}),pe&&e.jsx("div",{className:"mb-4 p-3 bg-red-500/10 border border-red-500/20 rounded-lg text-red-400 text-sm",children:pe}),e.jsx(v,{onClick:dt,isLoading:Ue,variant:"secondary",children:"Generate Mindmap"})]})})}),o==="chat"&&e.jsxs("div",{className:"flex flex-col flex-1 min-h-0",children:[e.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto space-y-3 pb-2 pr-1 custom-scrollbar",children:[Q.length===0&&e.jsxs("div",{className:"text-center py-6",children:[e.jsx("div",{className:"text-3xl mb-2",children:"ð"}),e.jsx("h3",{className:"text-lg font-display font-semibold mb-1 text-text-primary",children:"Hi~ Feel free to ask me anything!"}),e.jsx("p",{className:"text-sm mb-4 text-text-secondary",children:"Ask questions about this note"}),e.jsxs("div",{className:"flex flex-col gap-1.5 max-w-md mx-auto",children:[e.jsxs("button",{type:"button",onClick:()=>D("List all key conclusions or recommendations from this content."),className:"px-2.5 py-1.5 text-left rounded-md transition-all flex items-center gap-2 text-xs leading-snug bg-surface border border-border hover:border-primary/50 text-text-primary",children:[e.jsx("span",{className:"shrink-0",children:"â¨"}),e.jsx("span",{children:"List all key conclusions or recommendations."})]}),e.jsxs("button",{type:"button",onClick:()=>D("Get comprehensive notes from this content."),className:"px-2.5 py-1.5 text-left rounded-md transition-all flex items-center gap-2 text-xs leading-snug bg-surface border border-border hover:border-primary/50 text-text-primary",children:[e.jsx("span",{className:"shrink-0",children:"ð"}),e.jsx("span",{children:"Get Notes."})]}),e.jsxs("button",{type:"button",onClick:()=>D("Rewrite the key points from this content into 3 short social media posts that are engaging and shareable."),className:"px-2.5 py-1.5 text-left rounded-md transition-all flex items-center gap-2 text-xs leading-snug bg-surface border border-border hover:border-primary/50 text-text-primary",children:[e.jsx("span",{className:"shrink-0",children:"ð¿"}),e.jsx("span",{children:"Rewrite into 3 short social media posts."})]}),e.jsxs("button",{type:"button",onClick:()=>D("Summarize 5 frequently asked questions (FAQs) based on this content with clear answers."),className:"px-2.5 py-1.5 text-left rounded-md transition-all flex items-center gap-2 text-xs leading-snug bg-surface border border-border hover:border-primary/50 text-text-primary",children:[e.jsx("span",{className:"shrink-0",children:"ð"}),e.jsx("span",{children:"Summarize 5 FAQs."})]}),e.jsxs("button",{type:"button",onClick:()=>D("Extract 5 key points from this content and explain each one clearly."),className:"px-2.5 py-1.5 text-left rounded-md transition-all flex items-center gap-2 text-xs leading-snug bg-surface border border-border hover:border-primary/50 text-text-primary",children:[e.jsx("span",{className:"shrink-0",children:"ð"}),e.jsx("span",{children:"Extract 5 key points."})]})]})]}),Q.map((t,r)=>e.jsx("div",{className:`flex ${t.role==="user"?"justify-end":"justify-start"}`,children:e.jsx("div",{className:`max-w-[80%] px-4 py-3 rounded-lg ${t.role==="user"?"bg-primary text-white rounded-br-sm":"bg-surface text-text-primary rounded-bl-sm border border-border"}`,children:e.jsx(Mt,{content:t.content,className:"text-sm"})})},r)),I&&e.jsx("div",{className:"flex justify-start",children:e.jsx("div",{className:"px-4 py-3 rounded-lg rounded-bl-sm bg-surface border border-border text-text-primary",children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx("span",{className:"w-2 h-2 rounded-full animate-bounce bg-text-secondary",style:{animationDelay:"0ms"}}),e.jsx("span",{className:"w-2 h-2 rounded-full animate-bounce bg-text-secondary",style:{animationDelay:"150ms"}}),e.jsx("span",{className:"w-2 h-2 rounded-full animate-bounce bg-text-secondary",style:{animationDelay:"300ms"}})]})})}),e.jsx("div",{ref:Re})]}),Pe,e.jsxs("div",{className:"flex-shrink-0 flex gap-2 pt-3 border-t border-border",children:[e.jsx("input",{type:"text",value:oe,onChange:t=>Ee(t.target.value),onKeyDown:t=>{t.key==="Enter"&&!t.shiftKey&&(t.preventDefault(),D())},placeholder:"Ask a question about this contentâ¦",className:"flex-1 px-3 py-2 text-sm rounded-lg transition-all focus:outline-none focus:ring-2 focus:ring-primary input-base border",disabled:I}),e.jsx(v,{onClick:()=>D(),disabled:I||!oe.trim(),variant:"secondary",size:"sm",children:"Send"})]})]}),o==="quiz"&&e.jsx("div",{className:"flex flex-col h-full",children:!s?.summary?.quizQuestions||s.summary.quizQuestions.length===0?e.jsx("div",{className:"flex flex-col items-center justify-center h-full space-y-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-4xl mb-4",children:"ð"}),e.jsx("h3",{className:"text-xl font-display font-semibold mb-2 text-text-primary",children:"No Quiz Available"}),e.jsxs("p",{className:"text-text-secondary mb-6",children:["Quiz questions are generated automatically when a summary is created.",s?.summary&&" This summary was created before quiz generation was available."]}),e.jsx(v,{onClick:xt,variant:"secondary",children:"Check for Quiz"})]})}):e.jsxs("div",{className:"flex-1 overflow-y-auto custom-scrollbar space-y-6",children:[yt,!B&&e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h3",{className:"text-lg font-display font-semibold text-text-primary",children:["Quiz: ",s.title]}),e.jsxs("div",{className:"text-sm text-text-secondary",children:[Object.keys(O).length," / ",s.summary.quizQuestions.length," answered"]})]}),B&&e.jsxs("div",{className:"mb-6 glass-card p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-xl font-display font-semibold text-text-primary",children:"Qu
43iz Results"}),e.jsx(v,{variant:"outline",size:"sm",onClick:ht,children:"Retake Quiz"})]}),(()=>{const t=jt();return e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"text-5xl font-bold mb-2",style:{color:t.percentage>=80?"#10b981":t.percentage>=60?"#f59e0b":"#ef4444"},children:[t.percentage,"%"]}),e.jsxs("p",{className:"text-text-secondary",children:["You got ",t.correct," out of ",t.total," questions correct"]})]})})()]}),s.summary.quizQuestions.map((t,r)=>{const i=O[r],l=i===t.correctAnswer,j=B;return e.jsx("div",{className:"glass-card p-6",children:e.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[e.jsx("div",{className:"flex-shrink-0 w-8 h-8 rounded-full bg-primary/20 text-primary flex items-center justify-center text-sm font-bold border border-primary/30",children:r+1}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"font-semibold mb-4 leading-relaxed text-text-primary",children:t.question}),e.jsx("div",{className:"space-y-2",children:t.options.map((T,te)=>{const U=i===te,G=te===t.correctAnswer;let re="w-full px-4 py-3 text-left rounded-lg border-2 transition-colors text-sm ";j?G?re+="bg-green-500/20 border-green-500/50 text-green-300":U&&!G?re+="bg-red-500/20 border-red-500/50 text-red-300":re+="bg-surface border-border text-text-secondary":U?re+="bg-primary/20 border-primary/50 text-text-primary":re+="bg-surface border-border text-text-secondary hover:bg-surface/80 hover:border-primary/50";const Gt=j?G?"bg-green-500 border-green-500":U?"bg-red-500 border-red-500":"border-border bg-transparent":U?"bg-primary border-primary":"border-border bg-transparent";return e.jsx("button",{onClick:()=>ut(r,te),disabled:j,className:re,children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:`flex-shrink-0 w-5 h-5 rounded-full border-2 flex items-center justify-center ${Gt}`,children:[j&&G&&e.jsx("svg",{className:"w-3 h-3 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:3,d:"M5 13l4 4L19 7"})}),j&&U&&!G&&e.jsx("svg",{className:"w-3 h-3 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:3,d:"M6 18L18 6M6 6l12 12"})}),!j&&U&&e.jsx("div",{className:"w-2 h-2 bg-white rounded-full"})]}),e.jsx("span",{className:"flex-1",children:T})]})},te)})}),j&&t.explanation&&e.jsx("div",{className:`mt-4 p-4 rounded-lg border ${l?"bg-green-500/10 border-green-500/20":"bg-blue-500/10 border-blue-500/20"}`,children:e.jsxs("p",{className:"text-sm text-text-primary",children:[e.jsx("strong",{className:"text-text-primary font-semibold",children:"Explanation:"})," ",t.explanation]})})]})]})},r)}),!B&&e.jsx("div",{className:"sticky bottom-0 backdrop-blur-md border-t border-border p-4 mt-2 rounded-t-xl bg-background/95",children:e.jsx(v,{onClick:pt,variant:"secondary",disabled:Object.keys(O).length<s.summary.quizQuestions.length,className:"w-full",children:Object.keys(O).length<s.summary.quizQuestions.length?`Answer all ${s.summary.quizQuestions.length} questions to see results`:"Show Results"})})]})}),o==="flashcards"&&e.jsx("div",{className:"flex flex-col items-center justify-center h-full p-8 space-y-6",children:E?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-20 h-20 rounded-full bg-emerald-500/10 border border-emerald-500/25 flex items-center justify-center",children:e.jsx("svg",{className:"w-10 h-10 text-emerald-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}),e.jsxs("div",{className:"text-center",children:[e.jsxs("h3",{className:"text-2xl font-display font-semibold text-text-primary mb-2",children:[E.count," Flashcards Ready"]}),e.jsxs("p",{className:"text-text-secondary",children:['Deck: "',E.deckName,'"']})]}),e.jsx(v,{onClick:()=>d("/flashcards"),variant:"secondary",children:"Go to Flashcards â"})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-20 h-20 rounded-full bg-primary/10 border border-primary/20 flex items-center justify-center",children:e.jsx("svg",{className:"w-10 h-10 text-primary",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})})}),e.jsxs("div",{className:"text-center",children:[e.jsx("h3",{className:"text-2xl font-display font-semibold text-text-primary mb-2",children:"Create Flashcards"}),e.jsx("p",{className:"text-text-secondary",children:"Generate spaced-repetition cards from this note for active recall practice"})]}),fe&&e.jsx("p",{className:"text-red-400 text-sm",children:fe}),e.jsx(v,{onClick:ct,isLoading:at,variant:"secondary",children:"Generate Flashcards"})]})})]})]})]})]}),e.jsx(St,{isOpen:b,onClose:()=>w(!1),title:"Delete Note",size:"sm",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx("p",{className:"text-text-secondary h-12",children:"Are you sure you want to delete this note? This action cannot be undone."}),e.jsxs("div",{className:"flex items-center justify-end space-x-3 border-t border-border pt-4",children:[e.jsx(v,{variant:"outline",onClick:()=>w(!1),children:"Cancel"}),e.jsx(v,{variant:"danger",onClick:Nt,isLoading:We.isPending,children:"Delete Permanently"})]})]})})]})};export{Ls as NoteDetailPage};
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.