import{d as e,f as t,m as n,t as r}from"./hooks.module-5xe-uC6c.js";import{s as i}from"./options-CDt8ZGCW.js";import{t as a}from"./jsxRuntime.module--xb8gfv5.js";import{s as o}from"./hooks-CSTgmcXO.js";import{t as s}from"./NoItems-CjX4hzvd.js";import{n as c,r as l,t as u}from"./useLlmChat-DMeVmtzC.js";e();function d({note:e,ntxId:d,noteContext:f}){let p=r(null),m=u(()=>p.current?.scheduleUpdate(),{defaultEnableNoteTools:!1,supportsExtendedThinking:!0,chatNoteId:e?.noteId});n(()=>{m.setChatNoteId(e?.noteId)},[e?.noteId,m.setChatNoteId]),p.current=o({note:e,noteType:`llmChat`,noteContext:f,getData:()=>{let e=m.getContent();return{content:JSON.stringify(e)}},onContentChange:e=>{if(!e){m.clearMessages();return}try{let t=JSON.parse(e);m.loadFromContent(t)}catch(e){console.error(`Failed to parse LLM chat content:`,e),m.clearMessages()}}});let h=t(()=>{p.current?.scheduleUpdate()},[]);return a(`div`,{className:`llm-chat-container`,children:[a(`div`,{className:`llm-chat-messages`,ref:m.scrollContainerRef,children:[m.messages.length===0&&!m.isStreaming&&a(s,{icon:`bx bx-conversation`,text:i(`llm_chat.empty_state`)}),m.messages.map(e=>a(c,{message:e},e.id)),m.isStreaming&&m.streamingThinking&&a(c,{message:{id:`streaming-thinking`,role:`assistant`,content:m.streamingThinking,createdAt:new Date().toISOString(),type:`thinking`},isStreaming:!0}),m.isStreaming&&m.streamingBlocks.length>0&&a(c,{message:{id:`streaming`,role:`assistant`,content:m.streamingBlocks,createdAt:new Date().toISOString(),citations:m.pendingCitations.length>0?m.pendingCitations:void 0},isStreaming:!0}),a(`div`,{ref:m.messagesEndRef})]}),a(l,{chat:m,onWebSearchChange:h,onNoteToolsChange:h,onExtendedThinkingChange:h,onModelChange:h})]})}export{d as default};