diff --git a/tools/server/public/bundle.js b/tools/server/public/bundle.js index 7258e6bea..f1eb1e68f 100644 --- a/tools/server/public/bundle.js +++ b/tools/server/public/bundle.js @@ -7006,210 +7006,209 @@ $$slots:{default:!0}}),reset(div_7),append($$anchor5,div_7)};if_block(node_11,$$ ()=>set_class(button,1,`group/expand w-full text-left ${!get$3(isExpanded)&&get$3(showExpandButton)?"cursor-pointer":"cursor-auto"}`)),delegated("click",button,function(...$$args){(get$3(showExpandButton)&&!get$3(isExpanded)?toggleExpand:void 0)?.apply(this,$$args)}),append($$anchor3,div_3)},d2=user_derived(()=>$$props.message.content.trim());if_block(node_5,$$render=>{get$3(d2)&&$$render(consequent_4)})}var node_13=sibling(node_5,2);{var consequent_5=$$anchor3=>{var div_8=root_13$8(),node_14=child( div_8);ChatMessageActionIcons(node_14,{actionsPosition:"right",get deletionInfo(){return $$props.deletionInfo},justify:"end",get onConfirmDelete(){return $$props.onConfirmDelete},get onCopy(){return $$props.onCopy},get onDelete(){return $$props.onDelete},get onEdit(){return $$props.onEdit},get onNavigateToSibling(){return $$props.onNavigateToSibling},get onShowDeleteDialogChange(){return $$props.onShowDeleteDialogChange},get siblingInfo(){return siblingInfo()},get showDeleteDialog(){return $$props. showDeleteDialog},get role(){return MessageRole.USER}}),reset(div_8),append($$anchor3,div_8)};if_block(node_13,$$render=>{$$props.message.timestamp&&$$render(consequent_5)})}append($$anchor2,fragment_2)};if_block(node2,$$render=>{editCtx.isEditing?$$render(consequent):$$render(alternate_1,-1)})}reset(div),template_effect(()=>set_class(div,1,`group flex flex-col items-end gap-3 md:gap-2 ${className()??""}`)),append($$anchor,div),pop()}delegate(["keydown","input","click"]);class AutoScrollController{#_autoScrollEnabled=state$1( -!0);get _autoScrollEnabled(){return get$3(this.#_autoScrollEnabled)}set _autoScrollEnabled(value){set$1(this.#_autoScrollEnabled,value,!0)}#_userScrolledUp=state$1(!1);get _userScrolledUp(){return get$3(this.#_userScrolledUp)}set _userScrolledUp(value){set$1(this.#_userScrolledUp,value,!0)}#_lastScrollTop=state$1(0);get _lastScrollTop(){return get$3(this.#_lastScrollTop)}set _lastScrollTop(value){set$1(this.#_lastScrollTop,value,!0)}_scrollInterval;_scrollTimeout;_container;_disabled;_mutationObserver=null;_rafPending=!1;_observerEnabled=!1;constructor(options={}){ -this._disabled=options.disabled??!1}get autoScrollEnabled(){return this._autoScrollEnabled}get userScrolledUp(){return this._userScrolledUp}setContainer(container2){this._doStopObserving(),this._container=container2,this._observerEnabled&&container2&&!this._disabled&&this._doStartObserving()}setDisabled(disabled){this._disabled=disabled,disabled?(this._autoScrollEnabled=!1,this.stopInterval(),this._doStopObserving()):this._observerEnabled&&this._container&&!this._mutationObserver&&this._doStartObserving()}handleScroll(){ -if(this._disabled||!this._container)return;const{scrollTop,scrollHeight,clientHeight}=this._container,distanceFromBottom=scrollHeight-clientHeight-scrollTop,isScrollingUp=scrollTop{isAtBottom&&(this._userScrolledUp=!1,this._autoScrollEnabled=!0)},AUTO_SCROLL_INTERVAL),this._lastScrollTop=scrollTop}scrollToBottom(behavior="smooth"){this._disabled||!this._container||this._container.scrollTo({top:this._container.scrollHeight,behavior})}enable(){this._disabled||(this._userScrolledUp=!1,this._autoScrollEnabled=!0)}startInterval(){this._disabled||this._scrollInterval||(this._scrollInterval=setInterval(()=>{this.scrollToBottom()},AUTO_SCROLL_INTERVAL))}stopInterval(){ -this._scrollInterval&&(clearInterval(this._scrollInterval),this._scrollInterval=void 0)}updateInterval(isStreaming){if(this._disabled){this.stopInterval();return}isStreaming&&this._autoScrollEnabled?this._scrollInterval||this.startInterval():this.stopInterval()}destroy(){this.stopInterval(),this._doStopObserving(),this._scrollTimeout&&(clearTimeout(this._scrollTimeout),this._scrollTimeout=void 0)}startObserving(){this._observerEnabled=!0,this._container&&!this._disabled&&!this._mutationObserver&& -this._doStartObserving()}stopObserving(){this._observerEnabled=!1,this._doStopObserving()}_doStartObserving(){!this._container||this._mutationObserver||(this._mutationObserver=new MutationObserver(()=>{!this._autoScrollEnabled||this._rafPending||(this._rafPending=!0,requestAnimationFrame(()=>{this._rafPending=!1,this._autoScrollEnabled&&this._container&&(this._container.scrollTop=this._container.scrollHeight)}))}),this._mutationObserver.observe(this._container,{childList:!0,subtree:!0,characterData:!0}))}_doStopObserving(){ -this._mutationObserver&&(this._mutationObserver.disconnect(),this._mutationObserver=null),this._rafPending=!1}}function createAutoScrollController(options={}){return new AutoScrollController(options)}function useKeyboardShortcuts(callbacks){function handleKeydown(event2){const isCmdOrCtrl=event2.metaKey||event2.ctrlKey;isCmdOrCtrl&&event2.key===KeyboardKey.K_LOWER&&(event2.preventDefault(),callbacks.activateSearchMode?.(),callbacks.onSearchActivated?.()),isCmdOrCtrl&&event2.shiftKey&&(event2.key=== -KeyboardKey.O_LOWER||event2.key===KeyboardKey.O_UPPER)&&(event2.preventDefault(),goto(ROUTES.NEW_CHAT)),event2.shiftKey&&isCmdOrCtrl&&event2.key===KeyboardKey.E_UPPER&&(event2.preventDefault(),callbacks.editActiveConversation?.()),isCmdOrCtrl&&event2.shiftKey&&(event2.key===KeyboardKey.D_LOWER||event2.key===KeyboardKey.D_UPPER)&&(event2.preventDefault(),callbacks.deleteActiveConversation?.()),isCmdOrCtrl&&event2.shiftKey&&event2.key===KeyboardKey.ARROW_UP&&(event2.preventDefault(),callbacks.navigateToPrevConversation?.()), -isCmdOrCtrl&&event2.shiftKey&&event2.key===KeyboardKey.ARROW_DOWN&&(event2.preventDefault(),callbacks.navigateToNextConversation?.())}return{handleKeydown}}var root_5$i=from_html('

Hello there

'),root_9$d=from_html('Server unavailable ',1),root_8$j=from_html(" ",1),root_7$h=from_html('
'),root_3$D=from_html('
'),root$$=from_html(" ",1);function ChatScreen($$anchor,$$props){push$1($$props,!0);let showCenteredEmpty=prop($$props,"showCenteredEmpty",3,!1);const autoScroll=createAutoScrollController();let disableAutoScroll=user_derived(()=>!!config$1().disableAutoScroll),chatScrollContainer=state$1(void 0),dragCounter=state$1(0),isDragOver=state$1(!1),showFileErrorDialog=state$1(!1),uploadedFiles=state$1(proxy([])),fileErrorData=state$1(proxy({generallyUnsupported:[],modalityUnsupported:[], -modalityReasons:{},supportedTypes:[]})),showDeleteDialog=state$1(!1),showEmptyFileDialog=state$1(!1),emptyFileNames=state$1(proxy([])),initialMessage=state$1(""),isEmpty=user_derived(()=>showCenteredEmpty()&&!activeConversation()&&activeMessages().length===0&&!isLoading()),activeErrorDialog=user_derived(errorDialog),isServerLoading=user_derived(serverLoading),hasPropsError=user_derived(()=>!!serverError()),isCurrentConversationLoading=user_derived(()=>isLoading()||isChatStreaming()),showProcessingInfo=user_derived( -()=>get$3(isCurrentConversationLoading)||config$1().keepStatsVisible&&!!page$1.params.id||activeProcessingState()!==null),isRouter=user_derived(isRouterMode),conversationModel=user_derived(()=>chatStore.getConversationModel(activeMessages())),activeModelId=user_derived(()=>{const options=modelOptions();if(!get$3(isRouter))return options.length>0?options[0].model:null;const selectedId=selectedModelId();if(selectedId){const model=options.find(m=>m.id===selectedId);if(model)return model.model}if(get$3( -conversationModel)){const model=options.find(m=>m.model===get$3(conversationModel));if(model)return model.model}return null}),modelPropsVersion=state$1(0);setProcessingInfoContext({get showProcessingInfo(){return get$3(showProcessingInfo)}}),user_effect(()=>{get$3(activeModelId)&&(modelsStore.getModelProps(get$3(activeModelId))||modelsStore.fetchModelProps(get$3(activeModelId)).then(()=>{update$1(modelPropsVersion)}))});let hasAudioModality=user_derived(()=>get$3(activeModelId)?(get$3(modelPropsVersion), -modelsStore.modelSupportsAudio(get$3(activeModelId))):!1),hasVisionModality=user_derived(()=>get$3(activeModelId)?(get$3(modelPropsVersion),modelsStore.modelSupportsVision(get$3(activeModelId))):!1);async function handleDeleteConfirm(){const conversation=activeConversation();conversation&&await conversationsStore.deleteConversation(conversation.id),set$1(showDeleteDialog,!1)}function handleDragEnter(event2){event2.preventDefault(),update$1(dragCounter),event2.dataTransfer?.types.includes("Files")&& -set$1(isDragOver,!0)}function handleDragLeave(event2){event2.preventDefault(),update$1(dragCounter,-1),get$3(dragCounter)===0&&set$1(isDragOver,!1)}function handleErrorDialogOpenChange(open2){open2||chatStore.dismissErrorDialog()}function handleDragOver(event2){event2.preventDefault()}function handleDrop(event2){if(event2.preventDefault(),set$1(isDragOver,!1),set$1(dragCounter,0),event2.dataTransfer?.files){const files=Array.from(event2.dataTransfer.files);if(isEditing()){const handler=getAddFilesHandler(); -if(handler){handler(files);return}}processFiles(files)}}function handleFileRemove(fileId){set$1(uploadedFiles,get$3(uploadedFiles).filter(f=>f.id!==fileId),!0)}function handleFileUpload(files){processFiles(files)}const{handleKeydown}=useKeyboardShortcuts({deleteActiveConversation:()=>{activeConversation()&&set$1(showDeleteDialog,!0)}});async function handleSystemPromptAdd(draft){(draft.message||draft.files.length>0)&&chatStore.savePendingDraft(draft.message,draft.files),await chatStore.addSystemPrompt()} -function handleScroll(){autoScroll.handleScroll()}async function handleSendMessage(message,files){const plainFiles=files?snapshot(files):void 0,result=plainFiles?await parseFilesToMessageExtras(plainFiles,get$3(activeModelId)??void 0):void 0;if(result?.emptyFiles&&result.emptyFiles.length>0){if(set$1(emptyFileNames,result.emptyFiles,!0),set$1(showEmptyFileDialog,!0),files){const emptyFileNamesSet=new Set(result.emptyFiles);set$1(uploadedFiles,get$3(uploadedFiles).filter(file=>!emptyFileNamesSet. -has(file.name)),!0)}return!1}const extras=result?.extras;return autoScroll.enable(),await chatStore.sendMessage(message,extras),autoScroll.scrollToBottom(),!0}async function processFiles(files){const generallySupported=[],generallyUnsupported=[];for(const file of files)isFileTypeSupported(file.name,file.type)?generallySupported.push(file):generallyUnsupported.push(file);const capabilities={hasVision:get$3(hasVisionModality),hasAudio:get$3(hasAudioModality)},{supportedFiles,unsupportedFiles,modalityReasons}=filterFilesByModalities( -generallySupported,capabilities);if([...generallyUnsupported,...unsupportedFiles].length>0){const supportedTypes=["text files","PDFs"];get$3(hasVisionModality)&&supportedTypes.push("images"),get$3(hasAudioModality)&&supportedTypes.push("audio files"),set$1(fileErrorData,{generallyUnsupported,modalityUnsupported:unsupportedFiles,modalityReasons,supportedTypes},!0),set$1(showFileErrorDialog,!0)}if(supportedFiles.length>0){const processed=await processFilesToChatUploaded(supportedFiles,get$3(activeModelId)?? -void 0);set$1(uploadedFiles,[...get$3(uploadedFiles),...processed],!0)}}afterNavigate(()=>{get$3(disableAutoScroll)||autoScroll.enable()});function handleMessagesReady(){get$3(disableAutoScroll)||requestAnimationFrame(()=>{autoScroll.scrollToBottom("instant")})}onMount$1(()=>{autoScroll.startObserving(),get$3(disableAutoScroll)||autoScroll.enable();const pendingDraft=chatStore.consumePendingDraft();pendingDraft&&(set$1(initialMessage,pendingDraft.message,!0),set$1(uploadedFiles,pendingDraft.files, -!0))}),user_effect(()=>{autoScroll.setContainer(get$3(chatScrollContainer))}),user_effect(()=>{autoScroll.setDisabled(get$3(disableAutoScroll))});var fragment=root$$();event("keydown",$window,handleKeydown);var node2=first_child(fragment);{var consequent=$$anchor2=>{ChatScreenDragOverlay($$anchor2)};if_block(node2,$$render=>{get$3(isDragOver)&&$$render(consequent)})}var node_1=sibling(node2,2);{var consequent_1=$$anchor2=>{ServerLoadingSplash($$anchor2,{})},alternate=$$anchor2=>{var div=root_3$D(), -div_1=child(div),node_2=child(div_1);{var consequent_2=$$anchor3=>{{let $0=user_derived(activeMessages);ChatMessages($$anchor3,{get messages(){return get$3($0)},onUserAction:()=>{autoScroll.enable(),autoScroll.scrollToBottom()},onMessagesReady:handleMessagesReady})}};if_block(node_2,$$render=>{get$3(isEmpty)||$$render(consequent_2)})}var div_2=sibling(node_2,2),node_3=child(div_2);{var consequent_3=$$anchor3=>{var div_3=root_5$i(),p2=sibling(child(div_3),2),text2=child(p2);reset(p2),reset(div_3), -action(div_3,($$node,$$action_arg)=>fadeInView?.($$node,$$action_arg),()=>({duration:300})),template_effect(()=>set_text(text2,`${serverStore.props?.modalities?.audio?"Record audio, type a message ":"Type a message"} or upload files to get started`)),append($$anchor3,div_3)};if_block(node_3,$$render=>{get$3(isEmpty)&&$$render(consequent_3)})}var node_4=sibling(node_3,2);{var consequent_4=$$anchor3=>{ChatScreenProcessingInfo($$anchor3,{})};if_block(node_4,$$render=>{page$1.params.id&&$$render(consequent_4)})} -var node_5=sibling(node_4,2);{var consequent_5=$$anchor3=>{var div_4=root_7$h(),node_6=child(div_4);component(node_6,()=>Alert,($$anchor4,Alert_Root)=>{Alert_Root($$anchor4,{variant:"destructive",children:($$anchor5,$$slotProps)=>{var fragment_5=root_8$j(),node_7=first_child(fragment_5);Triangle_alert(node_7,{class:"h-4 w-4"});var node_8=sibling(node_7,2);component(node_8,()=>Alert_title,($$anchor6,Alert_Title)=>{Alert_Title($$anchor6,{class:"flex items-center justify-between",children:($$anchor7,$$slotProps2)=>{ -var fragment_6=root_9$d(),button=sibling(first_child(fragment_6),2),node_9=child(button);{let $0=user_derived(()=>get$3(isServerLoading)?"animate-spin":"");Refresh_cw(node_9,{get class(){return`h-3 w-3 ${get$3($0)??""}`}})}var text_1=sibling(node_9);reset(button),template_effect(()=>{button.disabled=get$3(isServerLoading),set_text(text_1,` ${get$3(isServerLoading)?"Retrying...":"Retry"}`)}),delegated("click",button,()=>serverStore.fetch()),append($$anchor7,fragment_6)},$$slots:{default:!0}})});var node_10=sibling( -node_8,2);component(node_10,()=>Alert_description,($$anchor6,Alert_Description)=>{Alert_Description($$anchor6,{children:($$anchor7,$$slotProps2)=>{next$1();var text_2=text$8();template_effect($0=>set_text(text_2,$0),[()=>serverError()]),append($$anchor7,text_2)},$$slots:{default:!0}})}),append($$anchor5,fragment_5)},$$slots:{default:!0}})}),reset(div_4),action(div_4,($$node,$$action_arg)=>fadeInView?.($$node,$$action_arg),()=>({y:10,duration:250})),append($$anchor3,div_4)};if_block(node_5,$$render=>{ -get$3(hasPropsError)&&$$render(consequent_5)})}var div_5=sibling(node_5,2),node_11=child(div_5);{let $0=user_derived(()=>get$3(hasPropsError)||isEditing());ChatScreenForm(node_11,{get disabled(){return get$3($0)},get initialMessage(){return get$3(initialMessage)},get isLoading(){return get$3(isCurrentConversationLoading)},onFileRemove:handleFileRemove,onFileUpload:handleFileUpload,onSend:handleSendMessage,onStop:()=>chatStore.stopGeneration(),onSystemPromptAdd:handleSystemPromptAdd,get uploadedFiles(){ -return get$3(uploadedFiles)},set uploadedFiles($$value){set$1(uploadedFiles,$$value,!0)}})}reset(div_5),reset(div_2),reset(div_1),reset(div),bind_this(div,$$value=>set$1(chatScrollContainer,$$value),()=>get$3(chatScrollContainer)),template_effect(()=>set_class(div_2,1,`pointer-events-none ${get$3(isEmpty)?"absolute bottom-[calc(50dvh-7rem)]":"sticky bottom-4"} right-4 left-4 mt-auto pt-16 transition-all duration-200`)),event("dragenter",div,handleDragEnter),event("dragleave",div,handleDragLeave), -event("dragover",div,handleDragOver),event("drop",div,handleDrop),event("scroll",div,handleScroll),append($$anchor2,div)};if_block(node_1,$$render=>{get$3(isServerLoading)?$$render(consequent_1):$$render(alternate,-1)})}var node_12=sibling(node_1,2);DialogFileUploadError(node_12,{get fileErrorData(){return get$3(fileErrorData)},get open(){return get$3(showFileErrorDialog)},set open($$value){set$1(showFileErrorDialog,$$value,!0)}});var node_13=sibling(node_12,2);DialogConfirmation(node_13,{title:"\ -Delete Conversation",description:"Are you sure you want to delete this conversation? This action cannot be undone and will permanently remove all messages in this conversation.",confirmText:"Delete",cancelText:"Cancel",variant:"destructive",get icon(){return Trash_2},onConfirm:handleDeleteConfirm,onCancel:()=>set$1(showDeleteDialog,!1),get open(){return get$3(showDeleteDialog)},set open($$value){set$1(showDeleteDialog,$$value,!0)}});var node_14=sibling(node_13,2);DialogEmptyFileAlert(node_14,{get emptyFiles(){ -return get$3(emptyFileNames)},onOpenChange:open2=>{open2||set$1(emptyFileNames,[],!0)},get open(){return get$3(showEmptyFileDialog)},set open($$value){set$1(showEmptyFileDialog,$$value,!0)}});var node_15=sibling(node_14,2);{let $0=user_derived(()=>get$3(activeErrorDialog)?.message??""),$1=user_derived(()=>get$3(activeErrorDialog)?.contextInfo),$2=user_derived(()=>!!get$3(activeErrorDialog)),$3=user_derived(()=>get$3(activeErrorDialog)?.type??ErrorDialogType.SERVER);DialogChatError(node_15,{get message(){ -return get$3($0)},get contextInfo(){return get$3($1)},onOpenChange:handleErrorDialogOpenChange,get open(){return get$3($2)},get type(){return get$3($3)}})}append($$anchor,fragment),pop()}delegate(["click"]);var root$_=from_html('

Attach a file

Drop your files here to upload

');function ChatScreenDragOverlay($$anchor){var div=root$_(),div_1=child(div),node2=child(div_1);Upload(node2,{class:"mb-4 h-12 w-12 text-muted-foreground"}),next$1(4),reset(div_1),reset(div),append($$anchor,div)}class DraftMessagesStore{drafts=new Map;getDraftMessage(chatId){const key2=chatId??NEW_CHAT_DRAFT_KEY;return this.drafts.get(key2)??{message:"",files:[]}}saveDraftMessage(chatId,message,files){ -const key2=chatId??NEW_CHAT_DRAFT_KEY;message||files.length>0?this.drafts.set(key2,{message,files:[...files]}):this.drafts.delete(key2)}clearDraftMessage(chatId){const key2=chatId??NEW_CHAT_DRAFT_KEY;this.drafts.delete(key2)}}const draftMessagesStore=new DraftMessagesStore;function useDraftMessages(options){onMount$1(()=>{const chatId=options.getChatId(),draft=draftMessagesStore.getDraftMessage(chatId);(draft.message||draft.files.length>0)&&!options.getInitialMessage()&&(options.setMessage(draft. -message),options.setFiles(draft.files))}),beforeNavigate(()=>{const chatId=options.getChatId();draftMessagesStore.saveDraftMessage(chatId,options.getMessage(),options.getFiles())}),afterNavigate(navigation=>{if(navigation?.from!=null){const chatId=options.getChatId(),draft=draftMessagesStore.getDraftMessage(chatId);options.setMessage(draft.message),options.setFiles(draft.files)}});function clearDraft(){const chatId=options.getChatId();draftMessagesStore.clearDraftMessage(chatId)}return{clearDraft}} -var root$Z=from_html('
');function ChatScreenForm($$anchor,$$props){push$1($$props,!0);let disabled=prop($$props,"disabled",3,!1),initialMessage=prop($$props,"initialMessage",3,""),isLoading2=prop($$props,"isLoading",3,!1),uploadedFiles=prop($$props,"uploadedFiles",31,()=>proxy([])),chatFormRef=state$1(void 0),chatId=user_derived(()=>page$1.params.id),hasLoadingAttachments=user_derived(()=>uploadedFiles().some(f=>f.isLoading)),message=user_derived( -initialMessage),previousIsLoading=user_derived(isLoading2),previousInitialMessage=user_derived(initialMessage);const{clearDraft}=useDraftMessages({getChatId:()=>get$3(chatId),getMessage:()=>get$3(message),getFiles:()=>uploadedFiles(),setMessage:m=>set$1(message,m),setFiles:f=>uploadedFiles(f),getInitialMessage:()=>initialMessage()});function handleFilesAdd(files){$$props.onFileUpload?.(files)}async function handleSubmit(){if(!get$3(message).trim()&&uploadedFiles().length===0||disabled()||get$3(hasLoadingAttachments)|| -!get$3(chatFormRef)?.checkModelSelected())return;const messageToSend=get$3(message).trim(),filesToSend=[...uploadedFiles()];set$1(message,""),uploadedFiles([]),clearDraft(),get$3(chatFormRef)?.resetTextareaHeight(),await $$props.onSend?.(messageToSend,filesToSend)||(set$1(message,messageToSend),uploadedFiles(filesToSend))}function handleSystemPromptClick(){$$props.onSystemPromptAdd?.({message:get$3(message),files:uploadedFiles()})}function handleUploadedFileRemove(fileId){$$props.onFileRemove?.( -fileId)}onMount$1(()=>{setTimeout(()=>get$3(chatFormRef)?.focus(),10)}),afterNavigate(navigation=>{navigation?.from!=null&&setTimeout(()=>get$3(chatFormRef)?.focus(),10)}),user_effect(()=>{initialMessage()!==get$3(previousInitialMessage)&&(set$1(message,initialMessage()),set$1(previousInitialMessage,initialMessage()))}),user_effect(()=>{get$3(previousIsLoading)&&!isLoading2()&&setTimeout(()=>get$3(chatFormRef)?.focus(),10),set$1(previousIsLoading,isLoading2())});var div=root$Z(),node2=child(div); -bind_this(ChatForm(node2,{get class(){return $$props.class},get disabled(){return disabled()},get isLoading(){return isLoading2()},showMcpPromptButton:!0,onFilesAdd:handleFilesAdd,get onStop(){return $$props.onStop},onSubmit:handleSubmit,onSystemPromptClick:handleSystemPromptClick,onUploadedFileRemove:handleUploadedFileRemove,get value(){return get$3(message)},set value($$value){set$1(message,$$value)},get uploadedFiles(){return uploadedFiles()},set uploadedFiles($$value){uploadedFiles($$value)}}), -$$value=>set$1(chatFormRef,$$value,!0),()=>get$3(chatFormRef)),reset(div),append($$anchor,div),pop()}var root_1$u=from_html(' '),root$Y=from_html('
');function ChatScreenProcessingInfo($$anchor,$$props){push$1($$props,!0);const processingState=useProcessingState(),processingInfoCtx=getProcessingInfoContext();let showProcessingInfo=user_derived( -()=>processingInfoCtx.showProcessingInfo),isCurrentConversationLoading=user_derived(isLoading),isStreaming=user_derived(isChatStreaming),processingDetails=user_derived(()=>processingState.getTechnicalDetails());user_effect(()=>{const conversation=activeConversation();untrack$1(()=>chatStore.setActiveProcessingConversation(conversation?.id??null))}),user_effect(()=>{const keepStatsVisible=config$1().keepStatsVisible;if((keepStatsVisible||get$3(isCurrentConversationLoading)||get$3(isStreaming))&&processingState. -startMonitoring(),!get$3(isCurrentConversationLoading)&&!get$3(isStreaming)&&!keepStatsVisible){const timeout=setTimeout(()=>{!config$1().keepStatsVisible&&!isChatStreaming()&&processingState.stopMonitoring()},PROCESSING_INFO_TIMEOUT);return()=>clearTimeout(timeout)}}),user_effect(()=>{const conversation=activeConversation(),messages=activeMessages();if(config$1().keepStatsVisible&&conversation){if(messages.length===0){untrack$1(()=>chatStore.clearProcessingState(conversation.id));return}!get$3( -isCurrentConversationLoading)&&!get$3(isStreaming)&&untrack$1(()=>chatStore.restoreProcessingStateFromMessages(messages,conversation.id))}});var div=root$Y(),div_1=child(div);each(div_1,20,()=>get$3(processingDetails),detail=>detail,($$anchor2,detail)=>{var span=root_1$u(),text2=child(span,!0);reset(span),template_effect(()=>set_text(text2,detail)),append($$anchor2,span)}),reset(div_1),reset(div),template_effect(()=>set_class(div,1,clsx(["chat-processing-info-container pointer-events-none",get$3( -showProcessingInfo)&&"visible"]),"svelte-1ktvj8d")),append($$anchor,div),pop()}const emptyOptions$7={};function toString$1(value,options){const settings=emptyOptions$7,includeImageAlt=typeof settings.includeImageAlt=="boolean"?settings.includeImageAlt:!0,includeHtml=typeof settings.includeHtml=="boolean"?settings.includeHtml:!0;return one$2(value,includeImageAlt,includeHtml)}function one$2(value,includeImageAlt,includeHtml){if(node(value)){if("value"in value)return value.type==="html"&&!includeHtml? -"":value.value;if(includeImageAlt&&"alt"in value&&value.alt)return value.alt;if("children"in value)return all$2(value.children,includeImageAlt,includeHtml)}return Array.isArray(value)?all$2(value,includeImageAlt,includeHtml):""}function all$2(values,includeImageAlt,includeHtml){const result=[];let index2=-1;for(;++index2end?0:end+start2:start2=start2>end?end:start2,remove2=remove2>0?remove2:0,items2. -length<1e4)parameters=Array.from(items2),parameters.unshift(start2,remove2),list2.splice(...parameters);else for(remove2&&list2.splice(start2,remove2);chunkStart0?(splice(list2,list2.length,0,items2),list2):items2}const hasOwnProperty={}.hasOwnProperty;function combineExtensions(extensions){const all2={}; -let index2=-1;for(;++index213&&code2<32||code2>126&&code2<160||code2>55295&&code2<57344||code2>64975&&code2<65008||(code2&65535)===65535||(code2&65535)===65534||code2>1114111?"�":String.fromCodePoint(code2)}function normalizeIdentifier(value){return value.replace( -/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const asciiAlpha=regexCheck(/[A-Za-z]/),asciiAlphanumeric=regexCheck(/[\dA-Za-z]/),asciiAtext=regexCheck(/[#-'*+\--9=?A-Z^-~]/);function asciiControl(code2){return code2!==null&&(code2<32||code2===127)}const asciiDigit=regexCheck(/\d/),asciiHexDigit=regexCheck(/[\dA-Fa-f]/),asciiPunctuation=regexCheck(/[!-/:-@[-`{-~]/);function markdownLineEnding(code2){return code2!==null&&code2<-2}function markdownLineEndingOrSpace(code2){return code2!== -null&&(code2<0||code2===32)}function markdownSpace(code2){return code2===-2||code2===-1||code2===32}const unicodePunctuation=regexCheck(new RegExp("\\p{P}|\\p{S}","u")),unicodeWhitespace=regexCheck(/\s/);function regexCheck(regex){return check;function check(code2){return code2!==null&&code2>-1&®ex.test(String.fromCharCode(code2))}}function normalizeUri(value){const result=[];let index2=-1,start2=0,skip=0;for(;++index255295&&code2<57344){const next2=value.charCodeAt(index2+1);code2<56320&&next2>56319&&next2<57344?(replace2=String.fromCharCode(code2,next2),skip=1):replace2="�"}else replace2=String.fromCharCode(code2);replace2&&(result.push(value.slice(start2,index2),encodeURIComponent( -replace2)),start2=index2+skip+1,replace2=""),skip&&(index2+=skip,skip=0)}return result.join("")+value.slice(start2)}function factorySpace(effects,ok,type2,max2){const limit2=max2?max2-1:Number.POSITIVE_INFINITY;let size2=0;return start2;function start2(code2){return markdownSpace(code2)?(effects.enter(type2),prefix(code2)):ok(code2)}function prefix(code2){return markdownSpace(code2)&&size2++lineStartOffset))return;const indexBeforeExits=self2.events.length;let indexBeforeFlow=indexBeforeExits,seen2,point2;for(;indexBeforeFlow--;)if(self2.events[indexBeforeFlow][0]==="exit"&&self2.events[indexBeforeFlow][1].type==="chunkFlow"){if(seen2){point2=self2.events[indexBeforeFlow][1].end;break}seen2=!0}for(exitContainers(continued),index2=indexBeforeExits;index2size2;){const entry=stack[index2];self2.containerState=entry[1],entry[0].exit.call(self2,effects)}stack.length=size2}function closeFlow(){childFlow.write([null]),childToken=void 0,childFlow=void 0,self2.containerState._closeFlow=void 0}}function tokenizeContainer(effects,ok,nok){return factorySpace(effects,effects.attempt(this.parser.constructs.document,ok,nok),"linePrefix", -this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function classifyCharacter(code2){if(code2===null||markdownLineEndingOrSpace(code2)||unicodeWhitespace(code2))return 1;if(unicodePunctuation(code2))return 2}function resolveAll(constructs2,events,context){const called=[];let index2=-1;for(;++index21&&events[index2][1].end.offset-events[index2][1].start.offset>1?2:1;const start2={...events[open2][1].end},end={ -...events[index2][1].start};movePoint(start2,-use),movePoint(end,use),openingSequence={type:use>1?"strongSequence":"emphasisSequence",start:start2,end:{...events[open2][1].end}},closingSequence={type:use>1?"strongSequence":"emphasisSequence",start:{...events[index2][1].start},end},text2={type:use>1?"strongText":"emphasisText",start:{...events[open2][1].end},end:{...events[index2][1].start}},group={type:use>1?"strong":"emphasis",start:{...openingSequence.start},end:{...closingSequence.end}},events[open2][1]. -end={...openingSequence.start},events[index2][1].start={...closingSequence.end},nextEvents=[],events[open2][1].end.offset-events[open2][1].start.offset&&(nextEvents=push(nextEvents,[["enter",events[open2][1],context],["exit",events[open2][1],context]])),nextEvents=push(nextEvents,[["enter",group,context],["enter",openingSequence,context],["exit",openingSequence,context],["enter",text2,context]]),nextEvents=push(nextEvents,resolveAll(context.parser.constructs.insideSpan.null,events.slice(open2+1, -index2),context)),nextEvents=push(nextEvents,[["exit",text2,context],["enter",closingSequence,context],["exit",closingSequence,context],["exit",group,context]]),events[index2][1].end.offset-events[index2][1].start.offset?(offset2=2,nextEvents=push(nextEvents,[["enter",events[index2][1],context],["exit",events[index2][1],context]])):offset2=0,splice(events,open2-1,index2-open2+3,nextEvents),index2=open2+nextEvents.length-offset2-2;break}}for(index2=-1;++index20&&markdownSpace(code2)?factorySpace(effects,beforeContentChunk,"linePrefix",initialPrefix+1)(code2):beforeContentChunk( -code2)}function beforeContentChunk(code2){return code2===null||markdownLineEnding(code2)?effects.check(nonLazyContinuation$1,atNonLazyBreak,after)(code2):(effects.enter("codeFlowValue"),contentChunk(code2))}function contentChunk(code2){return code2===null||markdownLineEnding(code2)?(effects.exit("codeFlowValue"),beforeContentChunk(code2)):(effects.consume(code2),contentChunk)}function after(code2){return effects.exit("codeFenced"),ok(code2)}function tokenizeCloseStart(effects2,ok2,nok2){let size2=0; -return startBefore;function startBefore(code2){return effects2.enter("lineEnding"),effects2.consume(code2),effects2.exit("lineEnding"),start3}function start3(code2){return effects2.enter("codeFencedFence"),markdownSpace(code2)?factorySpace(effects2,beforeSequenceClose,"linePrefix",self2.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(code2):beforeSequenceClose(code2)}function beforeSequenceClose(code2){return code2===marker?(effects2.enter("codeFencedFenceSequence"),sequenceClose( -code2)):nok2(code2)}function sequenceClose(code2){return code2===marker?(size2++,effects2.consume(code2),sequenceClose):size2>=sizeOpen?(effects2.exit("codeFencedFenceSequence"),markdownSpace(code2)?factorySpace(effects2,sequenceCloseAfter,"whitespace")(code2):sequenceCloseAfter(code2)):nok2(code2)}function sequenceCloseAfter(code2){return code2===null||markdownLineEnding(code2)?(effects2.exit("codeFencedFence"),ok2(code2)):nok2(code2)}}}function tokenizeNonLazyContinuation$1(effects,ok,nok){const self2=this; -return start2;function start2(code2){return code2===null?nok(code2):(effects.enter("lineEnding"),effects.consume(code2),effects.exit("lineEnding"),lineStart)}function lineStart(code2){return self2.parser.lazy[self2.now().line]?nok(code2):ok(code2)}}const codeIndented={name:"codeIndented",tokenize:tokenizeCodeIndented},furtherStart={partial:!0,tokenize:tokenizeFurtherStart};function tokenizeCodeIndented(effects,ok,nok){const self2=this;return start2;function start2(code2){return effects.enter("co\ -deIndented"),factorySpace(effects,afterPrefix,"linePrefix",5)(code2)}function afterPrefix(code2){const tail=self2.events[self2.events.length-1];return tail&&tail[1].type==="linePrefix"&&tail[2].sliceSerialize(tail[1],!0).length>=4?atBreak(code2):nok(code2)}function atBreak(code2){return code2===null?after(code2):markdownLineEnding(code2)?effects.attempt(furtherStart,atBreak,after)(code2):(effects.enter("codeFlowValue"),inside(code2))}function inside(code2){return code2===null||markdownLineEnding( -code2)?(effects.exit("codeFlowValue"),atBreak(code2)):(effects.consume(code2),inside)}function after(code2){return effects.exit("codeIndented"),ok(code2)}}function tokenizeFurtherStart(effects,ok,nok){const self2=this;return furtherStart2;function furtherStart2(code2){return self2.parser.lazy[self2.now().line]?nok(code2):markdownLineEnding(code2)?(effects.enter("lineEnding"),effects.consume(code2),effects.exit("lineEnding"),furtherStart2):factorySpace(effects,afterPrefix,"linePrefix",5)(code2)}function afterPrefix(code2){ -const tail=self2.events[self2.events.length-1];return tail&&tail[1].type==="linePrefix"&&tail[2].sliceSerialize(tail[1],!0).length>=4?ok(code2):markdownLineEnding(code2)?furtherStart2(code2):nok(code2)}}const codeText={name:"codeText",previous:previous$2,resolve:resolveCodeText,tokenize:tokenizeCodeText};function resolveCodeText(events){let tailExitIndex=events.length-4,headEnterIndex=3,index2,enter;if((events[headEnterIndex][1].type==="lineEnding"||events[headEnterIndex][1].type==="space")&&(events[tailExitIndex][1]. -type==="lineEnding"||events[tailExitIndex][1].type==="space")){for(index2=headEnterIndex;++index2=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+index2+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return index2this.left.length?this.right.slice(this.right.length-stop+this.left.length,this.right.length-start2+this.left.length).reverse():this.left.slice(start2).concat(this.right.slice(this.right.length-stop+this.left.length).reverse())}splice(start2,deleteCount,items2){const count=deleteCount||0;this.setCursor(Math.trunc(start2));const removed=this.right.splice(this.right.length-count,Number.POSITIVE_INFINITY);return items2&&chunkedPush(this. -left,items2),removed.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(item){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(item)}pushMany(items2){this.setCursor(Number.POSITIVE_INFINITY),chunkedPush(this.left,items2)}unshift(item){this.setCursor(0),this.right.push(item)}unshiftMany(items2){this.setCursor(0),chunkedPush(this.right,items2.reverse())}setCursor(n){if(!(n===this.left.length||n>this.left.length&&this.right.length===0||n<0&&this.left.length=== -0))if(n=4?ok(code2):effects.interrupt(self2.parser.constructs.flow,nok,ok)(code2)}}function factoryDestination(effects,ok,nok,type2,literalType,literalMarkerType,rawType,stringType,max2){const limit2=max2||Number.POSITIVE_INFINITY; -let balance=0;return start2;function start2(code2){return code2===60?(effects.enter(type2),effects.enter(literalType),effects.enter(literalMarkerType),effects.consume(code2),effects.exit(literalMarkerType),enclosedBefore):code2===null||code2===32||code2===41||asciiControl(code2)?nok(code2):(effects.enter(type2),effects.enter(rawType),effects.enter(stringType),effects.enter("chunkString",{contentType:"string"}),raw2(code2))}function enclosedBefore(code2){return code2===62?(effects.enter(literalMarkerType), -effects.consume(code2),effects.exit(literalMarkerType),effects.exit(literalType),effects.exit(type2),ok):(effects.enter(stringType),effects.enter("chunkString",{contentType:"string"}),enclosed(code2))}function enclosed(code2){return code2===62?(effects.exit("chunkString"),effects.exit(stringType),enclosedBefore(code2)):code2===null||code2===60||markdownLineEnding(code2)?nok(code2):(effects.consume(code2),code2===92?enclosedEscape:enclosed)}function enclosedEscape(code2){return code2===60||code2=== -62||code2===92?(effects.consume(code2),enclosed):enclosed(code2)}function raw2(code2){return!balance&&(code2===null||code2===41||markdownLineEndingOrSpace(code2))?(effects.exit("chunkString"),effects.exit(stringType),effects.exit(rawType),effects.exit(type2),ok(code2)):balance999||code2===null||code2===91||code2===93&&!seen2||code2===94&&!size2&&"\ -_hiddenFootnoteSupport"in self2.parser.constructs?nok(code2):code2===93?(effects.exit(stringType),effects.enter(markerType),effects.consume(code2),effects.exit(markerType),effects.exit(type2),ok):markdownLineEnding(code2)?(effects.enter("lineEnding"),effects.consume(code2),effects.exit("lineEnding"),atBreak):(effects.enter("chunkString",{contentType:"string"}),labelInside(code2))}function labelInside(code2){return code2===null||code2===91||code2===93||markdownLineEnding(code2)||size2++>999?(effects. -exit("chunkString"),atBreak(code2)):(effects.consume(code2),seen2||(seen2=!markdownSpace(code2)),code2===92?labelEscape:labelInside)}function labelEscape(code2){return code2===91||code2===92||code2===93?(effects.consume(code2),size2++,labelInside):labelInside(code2)}}function factoryTitle(effects,ok,nok,type2,markerType,stringType){let marker;return start2;function start2(code2){return code2===34||code2===39||code2===40?(effects.enter(type2),effects.enter(markerType),effects.consume(code2),effects. -exit(markerType),marker=code2===40?41:code2,begin):nok(code2)}function begin(code2){return code2===marker?(effects.enter(markerType),effects.consume(code2),effects.exit(markerType),effects.exit(type2),ok):(effects.enter(stringType),atBreak(code2))}function atBreak(code2){return code2===marker?(effects.exit(stringType),begin(marker)):code2===null?nok(code2):markdownLineEnding(code2)?(effects.enter("lineEnding"),effects.consume(code2),effects.exit("lineEnding"),factorySpace(effects,atBreak,"linePr\ -efix")):(effects.enter("chunkString",{contentType:"string"}),inside(code2))}function inside(code2){return code2===marker||code2===null||markdownLineEnding(code2)?(effects.exit("chunkString"),atBreak(code2)):(effects.consume(code2),code2===92?escape2:inside)}function escape2(code2){return code2===marker||code2===92?(effects.consume(code2),inside):inside(code2)}}function factoryWhitespace(effects,ok){let seen2;return start2;function start2(code2){return markdownLineEnding(code2)?(effects.enter("li\ -neEnding"),effects.consume(code2),effects.exit("lineEnding"),seen2=!0,start2):markdownSpace(code2)?factorySpace(effects,start2,seen2?"linePrefix":"lineSuffix")(code2):ok(code2)}}const definition$1={name:"definition",tokenize:tokenizeDefinition},titleBefore={partial:!0,tokenize:tokenizeTitleBefore};function tokenizeDefinition(effects,ok,nok){const self2=this;let identifier2;return start2;function start2(code2){return effects.enter("definition"),before(code2)}function before(code2){return factoryLabel. -call(self2,effects,labelAfter,nok,"definitionLabel","definitionLabelMarker","definitionLabelString")(code2)}function labelAfter(code2){return identifier2=normalizeIdentifier(self2.sliceSerialize(self2.events[self2.events.length-1][1]).slice(1,-1)),code2===58?(effects.enter("definitionMarker"),effects.consume(code2),effects.exit("definitionMarker"),markerAfter):nok(code2)}function markerAfter(code2){return markdownLineEndingOrSpace(code2)?factoryWhitespace(effects,destinationBefore)(code2):destinationBefore( -code2)}function destinationBefore(code2){return factoryDestination(effects,destinationAfter,nok,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(code2)}function destinationAfter(code2){return effects.attempt(titleBefore,after,after)(code2)}function after(code2){return markdownSpace(code2)?factorySpace(effects,afterWhitespace,"whitespace")(code2):afterWhitespace(code2)}function afterWhitespace(code2){ -return code2===null||markdownLineEnding(code2)?(effects.exit("definition"),self2.parser.defined.push(identifier2),ok(code2)):nok(code2)}}function tokenizeTitleBefore(effects,ok,nok){return titleBefore2;function titleBefore2(code2){return markdownLineEndingOrSpace(code2)?factoryWhitespace(effects,beforeMarker)(code2):nok(code2)}function beforeMarker(code2){return factoryTitle(effects,titleAfter,nok,"definitionTitle","definitionTitleMarker","definitionTitleString")(code2)}function titleAfter(code2){ -return markdownSpace(code2)?factorySpace(effects,titleAfterOptionalWhitespace,"whitespace")(code2):titleAfterOptionalWhitespace(code2)}function titleAfterOptionalWhitespace(code2){return code2===null||markdownLineEnding(code2)?ok(code2):nok(code2)}}const hardBreakEscape={name:"hardBreakEscape",tokenize:tokenizeHardBreakEscape};function tokenizeHardBreakEscape(effects,ok,nok){return start2;function start2(code2){return effects.enter("hardBreakEscape"),effects.consume(code2),after}function after(code2){ -return markdownLineEnding(code2)?(effects.exit("hardBreakEscape"),ok(code2)):nok(code2)}}const headingAtx={name:"headingAtx",resolve:resolveHeadingAtx,tokenize:tokenizeHeadingAtx};function resolveHeadingAtx(events,context){let contentEnd=events.length-2,contentStart=3,content2,text2;return events[contentStart][1].type==="whitespace"&&(contentStart+=2),contentEnd-2>contentStart&&events[contentEnd][1].type==="whitespace"&&(contentEnd-=2),events[contentEnd][1].type==="atxHeadingSequence"&&(contentStart=== -contentEnd-1||contentEnd-4>contentStart&&events[contentEnd-2][1].type==="whitespace")&&(contentEnd-=contentStart+1===contentEnd?2:4),contentEnd>contentStart&&(content2={type:"atxHeadingText",start:events[contentStart][1].start,end:events[contentEnd][1].end},text2={type:"chunkText",start:events[contentStart][1].start,end:events[contentEnd][1].end,contentType:"text"},splice(events,contentStart,contentEnd-contentStart+1,[["enter",content2,context],["enter",text2,context],["exit",text2,context],["ex\ -it",content2,context]])),events}function tokenizeHeadingAtx(effects,ok,nok){let size2=0;return start2;function start2(code2){return effects.enter("atxHeading"),before(code2)}function before(code2){return effects.enter("atxHeadingSequence"),sequenceOpen(code2)}function sequenceOpen(code2){return code2===35&&size2++<6?(effects.consume(code2),sequenceOpen):code2===null||markdownLineEndingOrSpace(code2)?(effects.exit("atxHeadingSequence"),atBreak(code2)):nok(code2)}function atBreak(code2){return code2=== -35?(effects.enter("atxHeadingSequence"),sequenceFurther(code2)):code2===null||markdownLineEnding(code2)?(effects.exit("atxHeading"),ok(code2)):markdownSpace(code2)?factorySpace(effects,atBreak,"whitespace")(code2):(effects.enter("atxHeadingText"),data(code2))}function sequenceFurther(code2){return code2===35?(effects.consume(code2),sequenceFurther):(effects.exit("atxHeadingSequence"),atBreak(code2))}function data(code2){return code2===null||code2===35||markdownLineEndingOrSpace(code2)?(effects.exit( -"atxHeadingText"),atBreak(code2)):(effects.consume(code2),data)}}const htmlBlockNames=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","\ -table","tbody","td","tfoot","th","thead","title","tr","track","ul"],htmlRawNames=["pre","script","style","textarea"],htmlFlow={concrete:!0,name:"htmlFlow",resolveTo:resolveToHtmlFlow,tokenize:tokenizeHtmlFlow},blankLineBefore={partial:!0,tokenize:tokenizeBlankLineBefore},nonLazyContinuationStart={partial:!0,tokenize:tokenizeNonLazyContinuationStart};function resolveToHtmlFlow(events){let index2=events.length;for(;index2--&&!(events[index2][0]==="enter"&&events[index2][1].type==="htmlFlow"););return index2> -1&&events[index2-2][1].type==="linePrefix"&&(events[index2][1].start=events[index2-2][1].start,events[index2+1][1].start=events[index2-2][1].start,events.splice(index2-2,2)),events}function tokenizeHtmlFlow(effects,ok,nok){const self2=this;let marker,closingTag,buffer,index2,markerB;return start2;function start2(code2){return before(code2)}function before(code2){return effects.enter("htmlFlow"),effects.enter("htmlFlowData"),effects.consume(code2),open2}function open2(code2){return code2===33?(effects. -consume(code2),declarationOpen):code2===47?(effects.consume(code2),closingTag=!0,tagCloseStart):code2===63?(effects.consume(code2),marker=3,self2.interrupt?ok:continuationDeclarationInside):asciiAlpha(code2)?(effects.consume(code2),buffer=String.fromCharCode(code2),tagName):nok(code2)}function declarationOpen(code2){return code2===45?(effects.consume(code2),marker=2,commentOpenInside):code2===91?(effects.consume(code2),marker=5,index2=0,cdataOpenInside):asciiAlpha(code2)?(effects.consume(code2), -marker=4,self2.interrupt?ok:continuationDeclarationInside):nok(code2)}function commentOpenInside(code2){return code2===45?(effects.consume(code2),self2.interrupt?ok:continuationDeclarationInside):nok(code2)}function cdataOpenInside(code2){const value="CDATA[";return code2===value.charCodeAt(index2++)?(effects.consume(code2),index2===value.length?self2.interrupt?ok:continuation:cdataOpenInside):nok(code2)}function tagCloseStart(code2){return asciiAlpha(code2)?(effects.consume(code2),buffer=String. -fromCharCode(code2),tagName):nok(code2)}function tagName(code2){if(code2===null||code2===47||code2===62||markdownLineEndingOrSpace(code2)){const slash=code2===47,name=buffer.toLowerCase();return!slash&&!closingTag&&htmlRawNames.includes(name)?(marker=1,self2.interrupt?ok(code2):continuation(code2)):htmlBlockNames.includes(buffer.toLowerCase())?(marker=6,slash?(effects.consume(code2),basicSelfClosing):self2.interrupt?ok(code2):continuation(code2)):(marker=7,self2.interrupt&&!self2.parser.lazy[self2. -now().line]?nok(code2):closingTag?completeClosingTagAfter(code2):completeAttributeNameBefore(code2))}return code2===45||asciiAlphanumeric(code2)?(effects.consume(code2),buffer+=String.fromCharCode(code2),tagName):nok(code2)}function basicSelfClosing(code2){return code2===62?(effects.consume(code2),self2.interrupt?ok:continuation):nok(code2)}function completeClosingTagAfter(code2){return markdownSpace(code2)?(effects.consume(code2),completeClosingTagAfter):completeEnd(code2)}function completeAttributeNameBefore(code2){ -return code2===47?(effects.consume(code2),completeEnd):code2===58||code2===95||asciiAlpha(code2)?(effects.consume(code2),completeAttributeName):markdownSpace(code2)?(effects.consume(code2),completeAttributeNameBefore):completeEnd(code2)}function completeAttributeName(code2){return code2===45||code2===46||code2===58||code2===95||asciiAlphanumeric(code2)?(effects.consume(code2),completeAttributeName):completeAttributeNameAfter(code2)}function completeAttributeNameAfter(code2){return code2===61?(effects. -consume(code2),completeAttributeValueBefore):markdownSpace(code2)?(effects.consume(code2),completeAttributeNameAfter):completeAttributeNameBefore(code2)}function completeAttributeValueBefore(code2){return code2===null||code2===60||code2===61||code2===62||code2===96?nok(code2):code2===34||code2===39?(effects.consume(code2),markerB=code2,completeAttributeValueQuoted):markdownSpace(code2)?(effects.consume(code2),completeAttributeValueBefore):completeAttributeValueUnquoted(code2)}function completeAttributeValueQuoted(code2){ -return code2===markerB?(effects.consume(code2),markerB=null,completeAttributeValueQuotedAfter):code2===null||markdownLineEnding(code2)?nok(code2):(effects.consume(code2),completeAttributeValueQuoted)}function completeAttributeValueUnquoted(code2){return code2===null||code2===34||code2===39||code2===47||code2===60||code2===61||code2===62||code2===96||markdownLineEndingOrSpace(code2)?completeAttributeNameAfter(code2):(effects.consume(code2),completeAttributeValueUnquoted)}function completeAttributeValueQuotedAfter(code2){ -return code2===47||code2===62||markdownSpace(code2)?completeAttributeNameBefore(code2):nok(code2)}function completeEnd(code2){return code2===62?(effects.consume(code2),completeAfter):nok(code2)}function completeAfter(code2){return code2===null||markdownLineEnding(code2)?continuation(code2):markdownSpace(code2)?(effects.consume(code2),completeAfter):nok(code2)}function continuation(code2){return code2===45&&marker===2?(effects.consume(code2),continuationCommentInside):code2===60&&marker===1?(effects. -consume(code2),continuationRawTagOpen):code2===62&&marker===4?(effects.consume(code2),continuationClose):code2===63&&marker===3?(effects.consume(code2),continuationDeclarationInside):code2===93&&marker===5?(effects.consume(code2),continuationCdataInside):markdownLineEnding(code2)&&(marker===6||marker===7)?(effects.exit("htmlFlowData"),effects.check(blankLineBefore,continuationAfter,continuationStart)(code2)):code2===null||markdownLineEnding(code2)?(effects.exit("htmlFlowData"),continuationStart( -code2)):(effects.consume(code2),continuation)}function continuationStart(code2){return effects.check(nonLazyContinuationStart,continuationStartNonLazy,continuationAfter)(code2)}function continuationStartNonLazy(code2){return effects.enter("lineEnding"),effects.consume(code2),effects.exit("lineEnding"),continuationBefore}function continuationBefore(code2){return code2===null||markdownLineEnding(code2)?continuationStart(code2):(effects.enter("htmlFlowData"),continuation(code2))}function continuationCommentInside(code2){ -return code2===45?(effects.consume(code2),continuationDeclarationInside):continuation(code2)}function continuationRawTagOpen(code2){return code2===47?(effects.consume(code2),buffer="",continuationRawEndTag):continuation(code2)}function continuationRawEndTag(code2){if(code2===62){const name=buffer.toLowerCase();return htmlRawNames.includes(name)?(effects.consume(code2),continuationClose):continuation(code2)}return asciiAlpha(code2)&&buffer.length<8?(effects.consume(code2),buffer+=String.fromCharCode( -code2),continuationRawEndTag):continuation(code2)}function continuationCdataInside(code2){return code2===93?(effects.consume(code2),continuationDeclarationInside):continuation(code2)}function continuationDeclarationInside(code2){return code2===62?(effects.consume(code2),continuationClose):code2===45&&marker===2?(effects.consume(code2),continuationDeclarationInside):continuation(code2)}function continuationClose(code2){return code2===null||markdownLineEnding(code2)?(effects.exit("htmlFlowData"),continuationAfter( -code2)):(effects.consume(code2),continuationClose)}function continuationAfter(code2){return effects.exit("htmlFlow"),ok(code2)}}function tokenizeNonLazyContinuationStart(effects,ok,nok){const self2=this;return start2;function start2(code2){return markdownLineEnding(code2)?(effects.enter("lineEnding"),effects.consume(code2),effects.exit("lineEnding"),after):nok(code2)}function after(code2){return self2.parser.lazy[self2.now().line]?nok(code2):ok(code2)}}function tokenizeBlankLineBefore(effects,ok,nok){ -return start2;function start2(code2){return effects.enter("lineEnding"),effects.consume(code2),effects.exit("lineEnding"),effects.attempt(blankLine,ok,nok)}}const htmlText={name:"htmlText",tokenize:tokenizeHtmlText};function tokenizeHtmlText(effects,ok,nok){const self2=this;let marker,index2,returnState;return start2;function start2(code2){return effects.enter("htmlText"),effects.enter("htmlTextData"),effects.consume(code2),open2}function open2(code2){return code2===33?(effects.consume(code2),declarationOpen): -code2===47?(effects.consume(code2),tagCloseStart):code2===63?(effects.consume(code2),instruction):asciiAlpha(code2)?(effects.consume(code2),tagOpen):nok(code2)}function declarationOpen(code2){return code2===45?(effects.consume(code2),commentOpenInside):code2===91?(effects.consume(code2),index2=0,cdataOpenInside):asciiAlpha(code2)?(effects.consume(code2),declaration):nok(code2)}function commentOpenInside(code2){return code2===45?(effects.consume(code2),commentEnd):nok(code2)}function comment2(code2){ -return code2===null?nok(code2):code2===45?(effects.consume(code2),commentClose):markdownLineEnding(code2)?(returnState=comment2,lineEndingBefore(code2)):(effects.consume(code2),comment2)}function commentClose(code2){return code2===45?(effects.consume(code2),commentEnd):comment2(code2)}function commentEnd(code2){return code2===62?end(code2):code2===45?commentClose(code2):comment2(code2)}function cdataOpenInside(code2){const value="CDATA[";return code2===value.charCodeAt(index2++)?(effects.consume( -code2),index2===value.length?cdata:cdataOpenInside):nok(code2)}function cdata(code2){return code2===null?nok(code2):code2===93?(effects.consume(code2),cdataClose):markdownLineEnding(code2)?(returnState=cdata,lineEndingBefore(code2)):(effects.consume(code2),cdata)}function cdataClose(code2){return code2===93?(effects.consume(code2),cdataEnd):cdata(code2)}function cdataEnd(code2){return code2===62?end(code2):code2===93?(effects.consume(code2),cdataEnd):cdata(code2)}function declaration(code2){return code2=== -null||code2===62?end(code2):markdownLineEnding(code2)?(returnState=declaration,lineEndingBefore(code2)):(effects.consume(code2),declaration)}function instruction(code2){return code2===null?nok(code2):code2===63?(effects.consume(code2),instructionClose):markdownLineEnding(code2)?(returnState=instruction,lineEndingBefore(code2)):(effects.consume(code2),instruction)}function instructionClose(code2){return code2===62?end(code2):instruction(code2)}function tagCloseStart(code2){return asciiAlpha(code2)? -(effects.consume(code2),tagClose):nok(code2)}function tagClose(code2){return code2===45||asciiAlphanumeric(code2)?(effects.consume(code2),tagClose):tagCloseBetween(code2)}function tagCloseBetween(code2){return markdownLineEnding(code2)?(returnState=tagCloseBetween,lineEndingBefore(code2)):markdownSpace(code2)?(effects.consume(code2),tagCloseBetween):end(code2)}function tagOpen(code2){return code2===45||asciiAlphanumeric(code2)?(effects.consume(code2),tagOpen):code2===47||code2===62||markdownLineEndingOrSpace( -code2)?tagOpenBetween(code2):nok(code2)}function tagOpenBetween(code2){return code2===47?(effects.consume(code2),end):code2===58||code2===95||asciiAlpha(code2)?(effects.consume(code2),tagOpenAttributeName):markdownLineEnding(code2)?(returnState=tagOpenBetween,lineEndingBefore(code2)):markdownSpace(code2)?(effects.consume(code2),tagOpenBetween):end(code2)}function tagOpenAttributeName(code2){return code2===45||code2===46||code2===58||code2===95||asciiAlphanumeric(code2)?(effects.consume(code2),tagOpenAttributeName): -tagOpenAttributeNameAfter(code2)}function tagOpenAttributeNameAfter(code2){return code2===61?(effects.consume(code2),tagOpenAttributeValueBefore):markdownLineEnding(code2)?(returnState=tagOpenAttributeNameAfter,lineEndingBefore(code2)):markdownSpace(code2)?(effects.consume(code2),tagOpenAttributeNameAfter):tagOpenBetween(code2)}function tagOpenAttributeValueBefore(code2){return code2===null||code2===60||code2===61||code2===62||code2===96?nok(code2):code2===34||code2===39?(effects.consume(code2), -marker=code2,tagOpenAttributeValueQuoted):markdownLineEnding(code2)?(returnState=tagOpenAttributeValueBefore,lineEndingBefore(code2)):markdownSpace(code2)?(effects.consume(code2),tagOpenAttributeValueBefore):(effects.consume(code2),tagOpenAttributeValueUnquoted)}function tagOpenAttributeValueQuoted(code2){return code2===marker?(effects.consume(code2),marker=void 0,tagOpenAttributeValueQuotedAfter):code2===null?nok(code2):markdownLineEnding(code2)?(returnState=tagOpenAttributeValueQuoted,lineEndingBefore( -code2)):(effects.consume(code2),tagOpenAttributeValueQuoted)}function tagOpenAttributeValueUnquoted(code2){return code2===null||code2===34||code2===39||code2===60||code2===61||code2===96?nok(code2):code2===47||code2===62||markdownLineEndingOrSpace(code2)?tagOpenBetween(code2):(effects.consume(code2),tagOpenAttributeValueUnquoted)}function tagOpenAttributeValueQuotedAfter(code2){return code2===47||code2===62||markdownLineEndingOrSpace(code2)?tagOpenBetween(code2):nok(code2)}function end(code2){return code2=== -62?(effects.consume(code2),effects.exit("htmlTextData"),effects.exit("htmlText"),ok):nok(code2)}function lineEndingBefore(code2){return effects.exit("htmlTextData"),effects.enter("lineEnding"),effects.consume(code2),effects.exit("lineEnding"),lineEndingAfter}function lineEndingAfter(code2){return markdownSpace(code2)?factorySpace(effects,lineEndingAfterPrefix,"linePrefix",self2.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(code2):lineEndingAfterPrefix(code2)}function lineEndingAfterPrefix(code2){ -return effects.enter("htmlTextData"),returnState(code2)}}const labelEnd={name:"labelEnd",resolveAll:resolveAllLabelEnd,resolveTo:resolveToLabelEnd,tokenize:tokenizeLabelEnd},resourceConstruct={tokenize:tokenizeResource},referenceFullConstruct={tokenize:tokenizeReferenceFull},referenceCollapsedConstruct={tokenize:tokenizeReferenceCollapsed};function resolveAllLabelEnd(events){let index2=-1;const newEvents=[];for(;++index2=3&&(code2===null||markdownLineEnding(code2))?(effects.exit("thematicBreak"),ok(code2)):nok(code2)}function sequence(code2){return code2===marker?(effects.consume(code2),size2++, -sequence):(effects.exit("thematicBreakSequence"),markdownSpace(code2)?factorySpace(effects,atBreak,"whitespace")(code2):atBreak(code2))}}const list$3={continuation:{tokenize:tokenizeListContinuation},exit:tokenizeListEnd,name:"list",tokenize:tokenizeListStart},listItemPrefixWhitespaceConstruct={partial:!0,tokenize:tokenizeListItemPrefixWhitespace},indentConstruct={partial:!0,tokenize:tokenizeIndent$1};function tokenizeListStart(effects,ok,nok){const self2=this,tail=self2.events[self2.events.length- -1];let initialSize=tail&&tail[1].type==="linePrefix"?tail[2].sliceSerialize(tail[1],!0).length:0,size2=0;return start2;function start2(code2){const kind=self2.containerState.type||(code2===42||code2===43||code2===45?"listUnordered":"listOrdered");if(kind==="listUnordered"?!self2.containerState.marker||code2===self2.containerState.marker:asciiDigit(code2)){if(self2.containerState.type||(self2.containerState.type=kind,effects.enter(kind,{_container:!0})),kind==="listUnordered")return effects.enter( -"listItemPrefix"),code2===42||code2===45?effects.check(thematicBreak$2,nok,atMarker)(code2):atMarker(code2);if(!self2.interrupt||code2===49)return effects.enter("listItemPrefix"),effects.enter("listItemValue"),inside(code2)}return nok(code2)}function inside(code2){return asciiDigit(code2)&&++size2<10?(effects.consume(code2),inside):(!self2.interrupt||size2<2)&&(self2.containerState.marker?code2===self2.containerState.marker:code2===41||code2===46)?(effects.exit("listItemValue"),atMarker(code2)): -nok(code2)}function atMarker(code2){return effects.enter("listItemMarker"),effects.consume(code2),effects.exit("listItemMarker"),self2.containerState.marker=self2.containerState.marker||code2,effects.check(blankLine,self2.interrupt?nok:onBlank,effects.attempt(listItemPrefixWhitespaceConstruct,endOfPrefix,otherPrefix))}function onBlank(code2){return self2.containerState.initialBlankLine=!0,initialSize++,endOfPrefix(code2)}function otherPrefix(code2){return markdownSpace(code2)?(effects.enter("lis\ -tItemPrefixWhitespace"),effects.consume(code2),effects.exit("listItemPrefixWhitespace"),endOfPrefix):nok(code2)}function endOfPrefix(code2){return self2.containerState.size=initialSize+self2.sliceSerialize(effects.exit("listItemPrefix"),!0).length,ok(code2)}}function tokenizeListContinuation(effects,ok,nok){const self2=this;return self2.containerState._closeFlow=void 0,effects.check(blankLine,onBlank,notBlank);function onBlank(code2){return self2.containerState.furtherBlankLines=self2.containerState. -furtherBlankLines||self2.containerState.initialBlankLine,factorySpace(effects,ok,"listItemIndent",self2.containerState.size+1)(code2)}function notBlank(code2){return self2.containerState.furtherBlankLines||!markdownSpace(code2)?(self2.containerState.furtherBlankLines=void 0,self2.containerState.initialBlankLine=void 0,notInCurrentItem(code2)):(self2.containerState.furtherBlankLines=void 0,self2.containerState.initialBlankLine=void 0,effects.attempt(indentConstruct,ok,notInCurrentItem)(code2))}function notInCurrentItem(code2){ -return self2.containerState._closeFlow=!0,self2.interrupt=void 0,factorySpace(effects,effects.attempt(list$3,ok,nok),"linePrefix",self2.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(code2)}}function tokenizeIndent$1(effects,ok,nok){const self2=this;return factorySpace(effects,afterPrefix,"listItemIndent",self2.containerState.size+1);function afterPrefix(code2){const tail=self2.events[self2.events.length-1];return tail&&tail[1].type==="listItemIndent"&&tail[2].sliceSerialize(tail[1], -!0).length===self2.containerState.size?ok(code2):nok(code2)}}function tokenizeListEnd(effects){effects.exit(this.containerState.type)}function tokenizeListItemPrefixWhitespace(effects,ok,nok){const self2=this;return factorySpace(effects,afterPrefix,"listItemPrefixWhitespace",self2.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function afterPrefix(code2){const tail=self2.events[self2.events.length-1];return!markdownSpace(code2)&&tail&&tail[1].type==="listItemPrefixWhitespace"? -ok(code2):nok(code2)}}const setextUnderline={name:"setextUnderline",resolveTo:resolveToSetextUnderline,tokenize:tokenizeSetextUnderline};function resolveToSetextUnderline(events,context){let index2=events.length,content2,text2,definition2;for(;index2--;)if(events[index2][0]==="enter"){if(events[index2][1].type==="content"){content2=index2;break}events[index2][1].type==="paragraph"&&(text2=index2)}else events[index2][1].type==="content"&&events.splice(index2,1),!definition2&&events[index2][1].type=== -"definition"&&(definition2=index2);const heading2={type:"setextHeading",start:{...events[content2][1].start},end:{...events[events.length-1][1].end}};return events[text2][1].type="setextHeadingText",definition2?(events.splice(text2,0,["enter",heading2,context]),events.splice(definition2+1,0,["exit",events[content2][1],context]),events[content2][1].end={...events[definition2][1].end}):events[content2][1]=heading2,events.push(["exit",heading2,context]),events}function tokenizeSetextUnderline(effects,ok,nok){ -const self2=this;let marker;return start2;function start2(code2){let index2=self2.events.length,paragraph2;for(;index2--;)if(self2.events[index2][1].type!=="lineEnding"&&self2.events[index2][1].type!=="linePrefix"&&self2.events[index2][1].type!=="content"){paragraph2=self2.events[index2][1].type==="paragraph";break}return!self2.parser.lazy[self2.now().line]&&(self2.interrupt||paragraph2)?(effects.enter("setextHeadingLine"),marker=code2,before(code2)):nok(code2)}function before(code2){return effects. -enter("setextHeadingLineSequence"),inside(code2)}function inside(code2){return code2===marker?(effects.consume(code2),inside):(effects.exit("setextHeadingLineSequence"),markdownSpace(code2)?factorySpace(effects,after,"lineSuffix")(code2):after(code2))}function after(code2){return code2===null||markdownLineEnding(code2)?(effects.exit("setextHeadingLine"),ok(code2)):nok(code2)}}const flow$1={tokenize:initializeFlow};function initializeFlow(effects){const self2=this,initial=effects.attempt(blankLine, -atBlankEnding,effects.attempt(this.parser.constructs.flowInitial,afterConstruct,factorySpace(effects,effects.attempt(this.parser.constructs.flow,afterConstruct,effects.attempt(content,afterConstruct)),"linePrefix")));return initial;function atBlankEnding(code2){if(code2===null){effects.consume(code2);return}return effects.enter("lineEndingBlank"),effects.consume(code2),effects.exit("lineEndingBlank"),self2.currentConstruct=void 0,initial}function afterConstruct(code2){if(code2===null){effects.consume( -code2);return}return effects.enter("lineEnding"),effects.consume(code2),effects.exit("lineEnding"),self2.currentConstruct=void 0,initial}}const resolver={resolveAll:createResolver()},string$1=initializeFactory("string"),text$7=initializeFactory("text");function initializeFactory(field){return{resolveAll:createResolver(field==="text"?resolveAllLineSuffixes:void 0),tokenize:initializeText};function initializeText(effects){const self2=this,constructs2=this.parser.constructs[field],text2=effects.attempt( -constructs2,start2,notText);return start2;function start2(code2){return atBreak(code2)?text2(code2):notText(code2)}function notText(code2){if(code2===null){effects.consume(code2);return}return effects.enter("data"),effects.consume(code2),data}function data(code2){return atBreak(code2)?(effects.exit("data"),text2(code2)):(effects.consume(code2),data)}function atBreak(code2){if(code2===null)return!0;const list2=constructs2[code2];let index2=-1;if(list2)for(;++index2-1){const head2=view[0];typeof head2=="string"?view[0]=head2.slice(startBufferIndex):view.shift()}endBufferIndex>0&&view.push(chunks[endIndex].slice(0,endBufferIndex))}return view}function serializeChunks(chunks,expandTabs){let index2=-1;const result=[];let atTab;for(;++index2{this.scrollToBottom()},AUTO_SCROLL_INTERVAL))}stopInterval(){this._scrollInterval&&(clearInterval(this._scrollInterval),this._scrollInterval=void 0)}updateInterval(isStreaming){if(this._disabled){this.stopInterval(); +return}isStreaming&&this._autoScrollEnabled?this._scrollInterval||this.startInterval():this.stopInterval()}destroy(){this.stopInterval(),this._doStopObserving()}startObserving(){this._observerEnabled=!0,this._container&&!this._disabled&&!this._mutationObserver&&this._doStartObserving()}stopObserving(){this._observerEnabled=!1,this._doStopObserving()}_doStartObserving(){!this._container||this._mutationObserver||(this._mutationObserver=new MutationObserver(()=>{!this._autoScrollEnabled||this._rafPending|| +(this._rafPending=!0,requestAnimationFrame(()=>{this._rafPending=!1,this._autoScrollEnabled&&this._container&&(this._container.scrollTop=this._container.scrollHeight)}))}),this._mutationObserver.observe(this._container,{childList:!0,subtree:!0,characterData:!0}))}_doStopObserving(){this._mutationObserver&&(this._mutationObserver.disconnect(),this._mutationObserver=null),this._rafPending=!1}}function createAutoScrollController(options={}){return new AutoScrollController(options)}function useKeyboardShortcuts(callbacks){ +function handleKeydown(event2){const isCmdOrCtrl=event2.metaKey||event2.ctrlKey;isCmdOrCtrl&&event2.key===KeyboardKey.K_LOWER&&(event2.preventDefault(),callbacks.activateSearchMode?.(),callbacks.onSearchActivated?.()),isCmdOrCtrl&&event2.shiftKey&&(event2.key===KeyboardKey.O_LOWER||event2.key===KeyboardKey.O_UPPER)&&(event2.preventDefault(),goto(ROUTES.NEW_CHAT)),event2.shiftKey&&isCmdOrCtrl&&event2.key===KeyboardKey.E_UPPER&&(event2.preventDefault(),callbacks.editActiveConversation?.()),isCmdOrCtrl&& +event2.shiftKey&&(event2.key===KeyboardKey.D_LOWER||event2.key===KeyboardKey.D_UPPER)&&(event2.preventDefault(),callbacks.deleteActiveConversation?.()),isCmdOrCtrl&&event2.shiftKey&&event2.key===KeyboardKey.ARROW_UP&&(event2.preventDefault(),callbacks.navigateToPrevConversation?.()),isCmdOrCtrl&&event2.shiftKey&&event2.key===KeyboardKey.ARROW_DOWN&&(event2.preventDefault(),callbacks.navigateToNextConversation?.())}return{handleKeydown}}var root_5$i=from_html('
<\ +h1 class="mb-2 text-2xl font-semibold tracking-tight md:text-3xl">Hello there

'),root_9$d=from_html('Server unavailable ',1),root_8$j=from_html(" ",1),root_7$h=from_html('
'),root_3$D=from_html( +'
'),root$$=from_html(" ",1);function ChatScreen($$anchor,$$props){push$1($$props,!0);let showCenteredEmpty=prop($$props,"showCenteredEmpty",3,!1);const autoScroll=createAutoScrollController();let disableAutoScroll=user_derived( +()=>!!config$1().disableAutoScroll),chatScrollContainer=state$1(void 0),dragCounter=state$1(0),isDragOver=state$1(!1),showFileErrorDialog=state$1(!1),uploadedFiles=state$1(proxy([])),fileErrorData=state$1(proxy({generallyUnsupported:[],modalityUnsupported:[],modalityReasons:{},supportedTypes:[]})),showDeleteDialog=state$1(!1),showEmptyFileDialog=state$1(!1),emptyFileNames=state$1(proxy([])),initialMessage=state$1(""),isEmpty=user_derived(()=>showCenteredEmpty()&&!activeConversation()&&activeMessages(). +length===0&&!isLoading()),activeErrorDialog=user_derived(errorDialog),isServerLoading=user_derived(serverLoading),hasPropsError=user_derived(()=>!!serverError()),isCurrentConversationLoading=user_derived(()=>isLoading()||isChatStreaming()),showProcessingInfo=user_derived(()=>get$3(isCurrentConversationLoading)||config$1().keepStatsVisible&&!!page$1.params.id||activeProcessingState()!==null),isRouter=user_derived(isRouterMode),conversationModel=user_derived(()=>chatStore.getConversationModel(activeMessages())), +activeModelId=user_derived(()=>{const options=modelOptions();if(!get$3(isRouter))return options.length>0?options[0].model:null;const selectedId=selectedModelId();if(selectedId){const model=options.find(m=>m.id===selectedId);if(model)return model.model}if(get$3(conversationModel)){const model=options.find(m=>m.model===get$3(conversationModel));if(model)return model.model}return null}),modelPropsVersion=state$1(0);setProcessingInfoContext({get showProcessingInfo(){return get$3(showProcessingInfo)}}), +user_effect(()=>{get$3(activeModelId)&&(modelsStore.getModelProps(get$3(activeModelId))||modelsStore.fetchModelProps(get$3(activeModelId)).then(()=>{update$1(modelPropsVersion)}))});let hasAudioModality=user_derived(()=>get$3(activeModelId)?(get$3(modelPropsVersion),modelsStore.modelSupportsAudio(get$3(activeModelId))):!1),hasVisionModality=user_derived(()=>get$3(activeModelId)?(get$3(modelPropsVersion),modelsStore.modelSupportsVision(get$3(activeModelId))):!1);async function handleDeleteConfirm(){ +const conversation=activeConversation();conversation&&await conversationsStore.deleteConversation(conversation.id),set$1(showDeleteDialog,!1)}function handleDragEnter(event2){event2.preventDefault(),update$1(dragCounter),event2.dataTransfer?.types.includes("Files")&&set$1(isDragOver,!0)}function handleDragLeave(event2){event2.preventDefault(),update$1(dragCounter,-1),get$3(dragCounter)===0&&set$1(isDragOver,!1)}function handleErrorDialogOpenChange(open2){open2||chatStore.dismissErrorDialog()}function handleDragOver(event2){ +event2.preventDefault()}function handleDrop(event2){if(event2.preventDefault(),set$1(isDragOver,!1),set$1(dragCounter,0),event2.dataTransfer?.files){const files=Array.from(event2.dataTransfer.files);if(isEditing()){const handler=getAddFilesHandler();if(handler){handler(files);return}}processFiles(files)}}function handleFileRemove(fileId){set$1(uploadedFiles,get$3(uploadedFiles).filter(f=>f.id!==fileId),!0)}function handleFileUpload(files){processFiles(files)}const{handleKeydown}=useKeyboardShortcuts( +{deleteActiveConversation:()=>{activeConversation()&&set$1(showDeleteDialog,!0)}});async function handleSystemPromptAdd(draft){(draft.message||draft.files.length>0)&&chatStore.savePendingDraft(draft.message,draft.files),await chatStore.addSystemPrompt()}function handleScroll(){autoScroll.handleScroll()}async function handleSendMessage(message,files){const plainFiles=files?snapshot(files):void 0,result=plainFiles?await parseFilesToMessageExtras(plainFiles,get$3(activeModelId)??void 0):void 0;if(result?. +emptyFiles&&result.emptyFiles.length>0){if(set$1(emptyFileNames,result.emptyFiles,!0),set$1(showEmptyFileDialog,!0),files){const emptyFileNamesSet=new Set(result.emptyFiles);set$1(uploadedFiles,get$3(uploadedFiles).filter(file=>!emptyFileNamesSet.has(file.name)),!0)}return!1}const extras=result?.extras;return autoScroll.enable(),await chatStore.sendMessage(message,extras),autoScroll.scrollToBottom(),!0}async function processFiles(files){const generallySupported=[],generallyUnsupported=[];for(const file of files) +isFileTypeSupported(file.name,file.type)?generallySupported.push(file):generallyUnsupported.push(file);const capabilities={hasVision:get$3(hasVisionModality),hasAudio:get$3(hasAudioModality)},{supportedFiles,unsupportedFiles,modalityReasons}=filterFilesByModalities(generallySupported,capabilities);if([...generallyUnsupported,...unsupportedFiles].length>0){const supportedTypes=["text files","PDFs"];get$3(hasVisionModality)&&supportedTypes.push("images"),get$3(hasAudioModality)&&supportedTypes.push( +"audio files"),set$1(fileErrorData,{generallyUnsupported,modalityUnsupported:unsupportedFiles,modalityReasons,supportedTypes},!0),set$1(showFileErrorDialog,!0)}if(supportedFiles.length>0){const processed=await processFilesToChatUploaded(supportedFiles,get$3(activeModelId)??void 0);set$1(uploadedFiles,[...get$3(uploadedFiles),...processed],!0)}}afterNavigate(()=>{get$3(disableAutoScroll)||autoScroll.enable()});function handleMessagesReady(){!get$3(disableAutoScroll)&&!autoScroll.userScrolledUp&&requestAnimationFrame( +()=>{autoScroll.scrollToBottom("instant")})}onMount$1(()=>{autoScroll.startObserving(),get$3(disableAutoScroll)||autoScroll.enable();const pendingDraft=chatStore.consumePendingDraft();pendingDraft&&(set$1(initialMessage,pendingDraft.message,!0),set$1(uploadedFiles,pendingDraft.files,!0))}),user_effect(()=>{autoScroll.setContainer(get$3(chatScrollContainer))}),user_effect(()=>{autoScroll.setDisabled(get$3(disableAutoScroll))});var fragment=root$$();event("keydown",$window,handleKeydown);var node2=first_child( +fragment);{var consequent=$$anchor2=>{ChatScreenDragOverlay($$anchor2)};if_block(node2,$$render=>{get$3(isDragOver)&&$$render(consequent)})}var node_1=sibling(node2,2);{var consequent_1=$$anchor2=>{ServerLoadingSplash($$anchor2,{})},alternate=$$anchor2=>{var div=root_3$D(),div_1=child(div),node_2=child(div_1);{var consequent_2=$$anchor3=>{{let $0=user_derived(activeMessages);ChatMessages($$anchor3,{get messages(){return get$3($0)},onUserAction:()=>{autoScroll.enable(),autoScroll.userScrolledUp|| +autoScroll.scrollToBottom()},onMessagesReady:handleMessagesReady})}};if_block(node_2,$$render=>{get$3(isEmpty)||$$render(consequent_2)})}var div_2=sibling(node_2,2),node_3=child(div_2);{var consequent_3=$$anchor3=>{var div_3=root_5$i(),p2=sibling(child(div_3),2),text2=child(p2);reset(p2),reset(div_3),action(div_3,($$node,$$action_arg)=>fadeInView?.($$node,$$action_arg),()=>({duration:300})),template_effect(()=>set_text(text2,`${serverStore.props?.modalities?.audio?"Record audio, type a message ": +"Type a message"} or upload files to get started`)),append($$anchor3,div_3)};if_block(node_3,$$render=>{get$3(isEmpty)&&$$render(consequent_3)})}var node_4=sibling(node_3,2);{var consequent_4=$$anchor3=>{ChatScreenProcessingInfo($$anchor3,{})};if_block(node_4,$$render=>{page$1.params.id&&$$render(consequent_4)})}var node_5=sibling(node_4,2);{var consequent_5=$$anchor3=>{var div_4=root_7$h(),node_6=child(div_4);component(node_6,()=>Alert,($$anchor4,Alert_Root)=>{Alert_Root($$anchor4,{variant:"des\ +tructive",children:($$anchor5,$$slotProps)=>{var fragment_5=root_8$j(),node_7=first_child(fragment_5);Triangle_alert(node_7,{class:"h-4 w-4"});var node_8=sibling(node_7,2);component(node_8,()=>Alert_title,($$anchor6,Alert_Title)=>{Alert_Title($$anchor6,{class:"flex items-center justify-between",children:($$anchor7,$$slotProps2)=>{var fragment_6=root_9$d(),button=sibling(first_child(fragment_6),2),node_9=child(button);{let $0=user_derived(()=>get$3(isServerLoading)?"animate-spin":"");Refresh_cw(node_9, +{get class(){return`h-3 w-3 ${get$3($0)??""}`}})}var text_1=sibling(node_9);reset(button),template_effect(()=>{button.disabled=get$3(isServerLoading),set_text(text_1,` ${get$3(isServerLoading)?"Retrying...":"Retry"}`)}),delegated("click",button,()=>serverStore.fetch()),append($$anchor7,fragment_6)},$$slots:{default:!0}})});var node_10=sibling(node_8,2);component(node_10,()=>Alert_description,($$anchor6,Alert_Description)=>{Alert_Description($$anchor6,{children:($$anchor7,$$slotProps2)=>{next$1(); +var text_2=text$8();template_effect($0=>set_text(text_2,$0),[()=>serverError()]),append($$anchor7,text_2)},$$slots:{default:!0}})}),append($$anchor5,fragment_5)},$$slots:{default:!0}})}),reset(div_4),action(div_4,($$node,$$action_arg)=>fadeInView?.($$node,$$action_arg),()=>({y:10,duration:250})),append($$anchor3,div_4)};if_block(node_5,$$render=>{get$3(hasPropsError)&&$$render(consequent_5)})}var div_5=sibling(node_5,2),node_11=child(div_5);{let $0=user_derived(()=>get$3(hasPropsError)||isEditing()); +ChatScreenForm(node_11,{get disabled(){return get$3($0)},get initialMessage(){return get$3(initialMessage)},get isLoading(){return get$3(isCurrentConversationLoading)},onFileRemove:handleFileRemove,onFileUpload:handleFileUpload,onSend:handleSendMessage,onStop:()=>chatStore.stopGeneration(),onSystemPromptAdd:handleSystemPromptAdd,get uploadedFiles(){return get$3(uploadedFiles)},set uploadedFiles($$value){set$1(uploadedFiles,$$value,!0)}})}reset(div_5),reset(div_2),reset(div_1),reset(div),bind_this( +div,$$value=>set$1(chatScrollContainer,$$value),()=>get$3(chatScrollContainer)),template_effect(()=>set_class(div_2,1,`pointer-events-none ${get$3(isEmpty)?"absolute bottom-[calc(50dvh-7rem)]":"sticky bottom-4"} right-4 left-4 mt-auto pt-16 transition-all duration-200`)),event("dragenter",div,handleDragEnter),event("dragleave",div,handleDragLeave),event("dragover",div,handleDragOver),event("drop",div,handleDrop),event("scroll",div,handleScroll),append($$anchor2,div)};if_block(node_1,$$render=>{get$3( +isServerLoading)?$$render(consequent_1):$$render(alternate,-1)})}var node_12=sibling(node_1,2);DialogFileUploadError(node_12,{get fileErrorData(){return get$3(fileErrorData)},get open(){return get$3(showFileErrorDialog)},set open($$value){set$1(showFileErrorDialog,$$value,!0)}});var node_13=sibling(node_12,2);DialogConfirmation(node_13,{title:"Delete Conversation",description:"Are you sure you want to delete this conversation? This action cannot be undone and will permanently remove all messages\ + in this conversation.",confirmText:"Delete",cancelText:"Cancel",variant:"destructive",get icon(){return Trash_2},onConfirm:handleDeleteConfirm,onCancel:()=>set$1(showDeleteDialog,!1),get open(){return get$3(showDeleteDialog)},set open($$value){set$1(showDeleteDialog,$$value,!0)}});var node_14=sibling(node_13,2);DialogEmptyFileAlert(node_14,{get emptyFiles(){return get$3(emptyFileNames)},onOpenChange:open2=>{open2||set$1(emptyFileNames,[],!0)},get open(){return get$3(showEmptyFileDialog)},set open($$value){ +set$1(showEmptyFileDialog,$$value,!0)}});var node_15=sibling(node_14,2);{let $0=user_derived(()=>get$3(activeErrorDialog)?.message??""),$1=user_derived(()=>get$3(activeErrorDialog)?.contextInfo),$2=user_derived(()=>!!get$3(activeErrorDialog)),$3=user_derived(()=>get$3(activeErrorDialog)?.type??ErrorDialogType.SERVER);DialogChatError(node_15,{get message(){return get$3($0)},get contextInfo(){return get$3($1)},onOpenChange:handleErrorDialogOpenChange,get open(){return get$3($2)},get type(){return get$3( +$3)}})}append($$anchor,fragment),pop()}delegate(["click"]);var root$_=from_html('

Attach a file

Drop your files here to upload

');function ChatScreenDragOverlay($$anchor){ +var div=root$_(),div_1=child(div),node2=child(div_1);Upload(node2,{class:"mb-4 h-12 w-12 text-muted-foreground"}),next$1(4),reset(div_1),reset(div),append($$anchor,div)}class DraftMessagesStore{drafts=new Map;getDraftMessage(chatId){const key2=chatId??NEW_CHAT_DRAFT_KEY;return this.drafts.get(key2)??{message:"",files:[]}}saveDraftMessage(chatId,message,files){const key2=chatId??NEW_CHAT_DRAFT_KEY;message||files.length>0?this.drafts.set(key2,{message,files:[...files]}):this.drafts.delete(key2)}clearDraftMessage(chatId){ +const key2=chatId??NEW_CHAT_DRAFT_KEY;this.drafts.delete(key2)}}const draftMessagesStore=new DraftMessagesStore;function useDraftMessages(options){onMount$1(()=>{const chatId=options.getChatId(),draft=draftMessagesStore.getDraftMessage(chatId);(draft.message||draft.files.length>0)&&!options.getInitialMessage()&&(options.setMessage(draft.message),options.setFiles(draft.files))}),beforeNavigate(()=>{const chatId=options.getChatId();draftMessagesStore.saveDraftMessage(chatId,options.getMessage(),options. +getFiles())}),afterNavigate(navigation=>{if(navigation?.from!=null){const chatId=options.getChatId(),draft=draftMessagesStore.getDraftMessage(chatId);options.setMessage(draft.message),options.setFiles(draft.files)}});function clearDraft(){const chatId=options.getChatId();draftMessagesStore.clearDraftMessage(chatId)}return{clearDraft}}var root$Z=from_html('
');function ChatScreenForm($$anchor,$$props){push$1($$props,!0);let disabled=prop($$props, +"disabled",3,!1),initialMessage=prop($$props,"initialMessage",3,""),isLoading2=prop($$props,"isLoading",3,!1),uploadedFiles=prop($$props,"uploadedFiles",31,()=>proxy([])),chatFormRef=state$1(void 0),chatId=user_derived(()=>page$1.params.id),hasLoadingAttachments=user_derived(()=>uploadedFiles().some(f=>f.isLoading)),message=user_derived(initialMessage),previousIsLoading=user_derived(isLoading2),previousInitialMessage=user_derived(initialMessage);const{clearDraft}=useDraftMessages({getChatId:()=>get$3( +chatId),getMessage:()=>get$3(message),getFiles:()=>uploadedFiles(),setMessage:m=>set$1(message,m),setFiles:f=>uploadedFiles(f),getInitialMessage:()=>initialMessage()});function handleFilesAdd(files){$$props.onFileUpload?.(files)}async function handleSubmit(){if(!get$3(message).trim()&&uploadedFiles().length===0||disabled()||get$3(hasLoadingAttachments)||!get$3(chatFormRef)?.checkModelSelected())return;const messageToSend=get$3(message).trim(),filesToSend=[...uploadedFiles()];set$1(message,""),uploadedFiles( +[]),clearDraft(),get$3(chatFormRef)?.resetTextareaHeight(),await $$props.onSend?.(messageToSend,filesToSend)||(set$1(message,messageToSend),uploadedFiles(filesToSend))}function handleSystemPromptClick(){$$props.onSystemPromptAdd?.({message:get$3(message),files:uploadedFiles()})}function handleUploadedFileRemove(fileId){$$props.onFileRemove?.(fileId)}onMount$1(()=>{setTimeout(()=>get$3(chatFormRef)?.focus(),10)}),afterNavigate(navigation=>{navigation?.from!=null&&setTimeout(()=>get$3(chatFormRef)?. +focus(),10)}),user_effect(()=>{initialMessage()!==get$3(previousInitialMessage)&&(set$1(message,initialMessage()),set$1(previousInitialMessage,initialMessage()))}),user_effect(()=>{get$3(previousIsLoading)&&!isLoading2()&&setTimeout(()=>get$3(chatFormRef)?.focus(),10),set$1(previousIsLoading,isLoading2())});var div=root$Z(),node2=child(div);bind_this(ChatForm(node2,{get class(){return $$props.class},get disabled(){return disabled()},get isLoading(){return isLoading2()},showMcpPromptButton:!0,onFilesAdd:handleFilesAdd, +get onStop(){return $$props.onStop},onSubmit:handleSubmit,onSystemPromptClick:handleSystemPromptClick,onUploadedFileRemove:handleUploadedFileRemove,get value(){return get$3(message)},set value($$value){set$1(message,$$value)},get uploadedFiles(){return uploadedFiles()},set uploadedFiles($$value){uploadedFiles($$value)}}),$$value=>set$1(chatFormRef,$$value,!0),()=>get$3(chatFormRef)),reset(div),append($$anchor,div),pop()}var root_1$u=from_html(' '),root$Y=from_html('
');function ChatScreenProcessingInfo($$anchor,$$props){push$1($$props,!0);const processingState=useProcessingState(),processingInfoCtx=getProcessingInfoContext();let showProcessingInfo=user_derived(()=>processingInfoCtx.showProcessingInfo),isCurrentConversationLoading=user_derived(isLoading),isStreaming=user_derived(isChatStreaming),processingDetails=user_derived( +()=>processingState.getTechnicalDetails());user_effect(()=>{const conversation=activeConversation();untrack$1(()=>chatStore.setActiveProcessingConversation(conversation?.id??null))}),user_effect(()=>{const keepStatsVisible=config$1().keepStatsVisible;if((keepStatsVisible||get$3(isCurrentConversationLoading)||get$3(isStreaming))&&processingState.startMonitoring(),!get$3(isCurrentConversationLoading)&&!get$3(isStreaming)&&!keepStatsVisible){const timeout=setTimeout(()=>{!config$1().keepStatsVisible&& +!isChatStreaming()&&processingState.stopMonitoring()},PROCESSING_INFO_TIMEOUT);return()=>clearTimeout(timeout)}}),user_effect(()=>{const conversation=activeConversation(),messages=activeMessages();if(config$1().keepStatsVisible&&conversation){if(messages.length===0){untrack$1(()=>chatStore.clearProcessingState(conversation.id));return}!get$3(isCurrentConversationLoading)&&!get$3(isStreaming)&&untrack$1(()=>chatStore.restoreProcessingStateFromMessages(messages,conversation.id))}});var div=root$Y(), +div_1=child(div);each(div_1,20,()=>get$3(processingDetails),detail=>detail,($$anchor2,detail)=>{var span=root_1$u(),text2=child(span,!0);reset(span),template_effect(()=>set_text(text2,detail)),append($$anchor2,span)}),reset(div_1),reset(div),template_effect(()=>set_class(div,1,clsx(["chat-processing-info-container pointer-events-none",get$3(showProcessingInfo)&&"visible"]),"svelte-1ktvj8d")),append($$anchor,div),pop()}const emptyOptions$7={};function toString$1(value,options){const settings=emptyOptions$7, +includeImageAlt=typeof settings.includeImageAlt=="boolean"?settings.includeImageAlt:!0,includeHtml=typeof settings.includeHtml=="boolean"?settings.includeHtml:!0;return one$2(value,includeImageAlt,includeHtml)}function one$2(value,includeImageAlt,includeHtml){if(node(value)){if("value"in value)return value.type==="html"&&!includeHtml?"":value.value;if(includeImageAlt&&"alt"in value&&value.alt)return value.alt;if("children"in value)return all$2(value.children,includeImageAlt,includeHtml)}return Array. +isArray(value)?all$2(value,includeImageAlt,includeHtml):""}function all$2(values,includeImageAlt,includeHtml){const result=[];let index2=-1;for(;++index2end?0:end+start2:start2=start2>end?end:start2,remove2=remove2>0?remove2:0,items2.length<1e4)parameters=Array.from(items2),parameters.unshift(start2,remove2),list2.splice(...parameters);else for(remove2&&list2.splice(start2,remove2);chunkStart0?(splice(list2,list2.length,0,items2),list2):items2}const hasOwnProperty={}.hasOwnProperty;function combineExtensions(extensions){const all2={};let index2=-1;for(;++index213&&code2<32||code2>126&&code2<160||code2>55295&&code2<57344||code2>64975&&code2<65008||(code2&65535)===65535||(code2&65535)===65534||code2>1114111?"�":String.fromCodePoint(code2)}function normalizeIdentifier(value){return value.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const asciiAlpha=regexCheck(/[A-Za-z]/),asciiAlphanumeric=regexCheck(/[\dA-Za-z]/),asciiAtext=regexCheck(/[#-'*+\--9=?A-Z^-~]/); +function asciiControl(code2){return code2!==null&&(code2<32||code2===127)}const asciiDigit=regexCheck(/\d/),asciiHexDigit=regexCheck(/[\dA-Fa-f]/),asciiPunctuation=regexCheck(/[!-/:-@[-`{-~]/);function markdownLineEnding(code2){return code2!==null&&code2<-2}function markdownLineEndingOrSpace(code2){return code2!==null&&(code2<0||code2===32)}function markdownSpace(code2){return code2===-2||code2===-1||code2===32}const unicodePunctuation=regexCheck(new RegExp("\\p{P}|\\p{S}","u")),unicodeWhitespace=regexCheck( +/\s/);function regexCheck(regex){return check;function check(code2){return code2!==null&&code2>-1&®ex.test(String.fromCharCode(code2))}}function normalizeUri(value){const result=[];let index2=-1,start2=0,skip=0;for(;++index255295&&code2<57344){const next2=value.charCodeAt(index2+1);code2<56320&&next2>56319&&next2<57344?(replace2=String.fromCharCode(code2,next2),skip=1):replace2="�"}else replace2=String.fromCharCode(code2);replace2&&(result.push(value.slice(start2,index2),encodeURIComponent(replace2)),start2=index2+skip+1,replace2=""),skip&&(index2+=skip,skip=0)}return result.join("")+value.slice(start2)}function factorySpace(effects,ok,type2,max2){const limit2=max2?max2-1:Number. +POSITIVE_INFINITY;let size2=0;return start2;function start2(code2){return markdownSpace(code2)?(effects.enter(type2),prefix(code2)):ok(code2)}function prefix(code2){return markdownSpace(code2)&&size2++lineStartOffset))return;const indexBeforeExits=self2.events.length;let indexBeforeFlow=indexBeforeExits,seen2,point2;for(;indexBeforeFlow--;)if(self2.events[indexBeforeFlow][0]=== +"exit"&&self2.events[indexBeforeFlow][1].type==="chunkFlow"){if(seen2){point2=self2.events[indexBeforeFlow][1].end;break}seen2=!0}for(exitContainers(continued),index2=indexBeforeExits;index2size2;){const entry=stack[index2];self2.containerState=entry[1], +entry[0].exit.call(self2,effects)}stack.length=size2}function closeFlow(){childFlow.write([null]),childToken=void 0,childFlow=void 0,self2.containerState._closeFlow=void 0}}function tokenizeContainer(effects,ok,nok){return factorySpace(effects,effects.attempt(this.parser.constructs.document,ok,nok),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function classifyCharacter(code2){if(code2===null||markdownLineEndingOrSpace(code2)||unicodeWhitespace(code2))return 1; +if(unicodePunctuation(code2))return 2}function resolveAll(constructs2,events,context){const called=[];let index2=-1;for(;++index21&&events[index2][1].end.offset-events[index2][1].start.offset>1?2:1;const start2={...events[open2][1].end},end={...events[index2][1].start};movePoint(start2,-use),movePoint(end,use),openingSequence={type:use>1?"strongSequence":"emphasisSequence",start:start2,end:{...events[open2][1].end}},closingSequence= +{type:use>1?"strongSequence":"emphasisSequence",start:{...events[index2][1].start},end},text2={type:use>1?"strongText":"emphasisText",start:{...events[open2][1].end},end:{...events[index2][1].start}},group={type:use>1?"strong":"emphasis",start:{...openingSequence.start},end:{...closingSequence.end}},events[open2][1].end={...openingSequence.start},events[index2][1].start={...closingSequence.end},nextEvents=[],events[open2][1].end.offset-events[open2][1].start.offset&&(nextEvents=push(nextEvents,[ +["enter",events[open2][1],context],["exit",events[open2][1],context]])),nextEvents=push(nextEvents,[["enter",group,context],["enter",openingSequence,context],["exit",openingSequence,context],["enter",text2,context]]),nextEvents=push(nextEvents,resolveAll(context.parser.constructs.insideSpan.null,events.slice(open2+1,index2),context)),nextEvents=push(nextEvents,[["exit",text2,context],["enter",closingSequence,context],["exit",closingSequence,context],["exit",group,context]]),events[index2][1].end. +offset-events[index2][1].start.offset?(offset2=2,nextEvents=push(nextEvents,[["enter",events[index2][1],context],["exit",events[index2][1],context]])):offset2=0,splice(events,open2-1,index2-open2+3,nextEvents),index2=open2+nextEvents.length-offset2-2;break}}for(index2=-1;++index20&&markdownSpace(code2)?factorySpace(effects,beforeContentChunk,"linePrefix",initialPrefix+1)(code2):beforeContentChunk(code2)}function beforeContentChunk(code2){return code2===null||markdownLineEnding(code2)?effects.check(nonLazyContinuation$1,atNonLazyBreak,after)(code2):(effects.enter("codeFlowValue"),contentChunk(code2))}function contentChunk(code2){ +return code2===null||markdownLineEnding(code2)?(effects.exit("codeFlowValue"),beforeContentChunk(code2)):(effects.consume(code2),contentChunk)}function after(code2){return effects.exit("codeFenced"),ok(code2)}function tokenizeCloseStart(effects2,ok2,nok2){let size2=0;return startBefore;function startBefore(code2){return effects2.enter("lineEnding"),effects2.consume(code2),effects2.exit("lineEnding"),start3}function start3(code2){return effects2.enter("codeFencedFence"),markdownSpace(code2)?factorySpace( +effects2,beforeSequenceClose,"linePrefix",self2.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(code2):beforeSequenceClose(code2)}function beforeSequenceClose(code2){return code2===marker?(effects2.enter("codeFencedFenceSequence"),sequenceClose(code2)):nok2(code2)}function sequenceClose(code2){return code2===marker?(size2++,effects2.consume(code2),sequenceClose):size2>=sizeOpen?(effects2.exit("codeFencedFenceSequence"),markdownSpace(code2)?factorySpace(effects2,sequenceCloseAfter, +"whitespace")(code2):sequenceCloseAfter(code2)):nok2(code2)}function sequenceCloseAfter(code2){return code2===null||markdownLineEnding(code2)?(effects2.exit("codeFencedFence"),ok2(code2)):nok2(code2)}}}function tokenizeNonLazyContinuation$1(effects,ok,nok){const self2=this;return start2;function start2(code2){return code2===null?nok(code2):(effects.enter("lineEnding"),effects.consume(code2),effects.exit("lineEnding"),lineStart)}function lineStart(code2){return self2.parser.lazy[self2.now().line]? +nok(code2):ok(code2)}}const codeIndented={name:"codeIndented",tokenize:tokenizeCodeIndented},furtherStart={partial:!0,tokenize:tokenizeFurtherStart};function tokenizeCodeIndented(effects,ok,nok){const self2=this;return start2;function start2(code2){return effects.enter("codeIndented"),factorySpace(effects,afterPrefix,"linePrefix",5)(code2)}function afterPrefix(code2){const tail=self2.events[self2.events.length-1];return tail&&tail[1].type==="linePrefix"&&tail[2].sliceSerialize(tail[1],!0).length>= +4?atBreak(code2):nok(code2)}function atBreak(code2){return code2===null?after(code2):markdownLineEnding(code2)?effects.attempt(furtherStart,atBreak,after)(code2):(effects.enter("codeFlowValue"),inside(code2))}function inside(code2){return code2===null||markdownLineEnding(code2)?(effects.exit("codeFlowValue"),atBreak(code2)):(effects.consume(code2),inside)}function after(code2){return effects.exit("codeIndented"),ok(code2)}}function tokenizeFurtherStart(effects,ok,nok){const self2=this;return furtherStart2; +function furtherStart2(code2){return self2.parser.lazy[self2.now().line]?nok(code2):markdownLineEnding(code2)?(effects.enter("lineEnding"),effects.consume(code2),effects.exit("lineEnding"),furtherStart2):factorySpace(effects,afterPrefix,"linePrefix",5)(code2)}function afterPrefix(code2){const tail=self2.events[self2.events.length-1];return tail&&tail[1].type==="linePrefix"&&tail[2].sliceSerialize(tail[1],!0).length>=4?ok(code2):markdownLineEnding(code2)?furtherStart2(code2):nok(code2)}}const codeText={ +name:"codeText",previous:previous$2,resolve:resolveCodeText,tokenize:tokenizeCodeText};function resolveCodeText(events){let tailExitIndex=events.length-4,headEnterIndex=3,index2,enter;if((events[headEnterIndex][1].type==="lineEnding"||events[headEnterIndex][1].type==="space")&&(events[tailExitIndex][1].type==="lineEnding"||events[tailExitIndex][1].type==="space")){for(index2=headEnterIndex;++index2=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+index2+"` in a splice buffer of size `"+(this. +left.length+this.right.length)+"`");return index2this.left.length?this.right.slice(this.right.length-stop+this.left.length,this.right.length-start2+this.left.length).reverse():this. +left.slice(start2).concat(this.right.slice(this.right.length-stop+this.left.length).reverse())}splice(start2,deleteCount,items2){const count=deleteCount||0;this.setCursor(Math.trunc(start2));const removed=this.right.splice(this.right.length-count,Number.POSITIVE_INFINITY);return items2&&chunkedPush(this.left,items2),removed.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(item){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(item)}pushMany(items2){this. +setCursor(Number.POSITIVE_INFINITY),chunkedPush(this.left,items2)}unshift(item){this.setCursor(0),this.right.push(item)}unshiftMany(items2){this.setCursor(0),chunkedPush(this.right,items2.reverse())}setCursor(n){if(!(n===this.left.length||n>this.left.length&&this.right.length===0||n<0&&this.left.length===0))if(n=4?ok(code2):effects.interrupt(self2.parser.constructs.flow,nok,ok)(code2)}}function factoryDestination(effects,ok,nok,type2,literalType,literalMarkerType,rawType,stringType,max2){const limit2=max2||Number.POSITIVE_INFINITY;let balance=0;return start2;function start2(code2){return code2===60?(effects.enter(type2),effects.enter(literalType),effects.enter(literalMarkerType),effects.consume(code2),effects.exit(literalMarkerType),enclosedBefore):code2===null||code2===32||code2===41||asciiControl( +code2)?nok(code2):(effects.enter(type2),effects.enter(rawType),effects.enter(stringType),effects.enter("chunkString",{contentType:"string"}),raw2(code2))}function enclosedBefore(code2){return code2===62?(effects.enter(literalMarkerType),effects.consume(code2),effects.exit(literalMarkerType),effects.exit(literalType),effects.exit(type2),ok):(effects.enter(stringType),effects.enter("chunkString",{contentType:"string"}),enclosed(code2))}function enclosed(code2){return code2===62?(effects.exit("chun\ +kString"),effects.exit(stringType),enclosedBefore(code2)):code2===null||code2===60||markdownLineEnding(code2)?nok(code2):(effects.consume(code2),code2===92?enclosedEscape:enclosed)}function enclosedEscape(code2){return code2===60||code2===62||code2===92?(effects.consume(code2),enclosed):enclosed(code2)}function raw2(code2){return!balance&&(code2===null||code2===41||markdownLineEndingOrSpace(code2))?(effects.exit("chunkString"),effects.exit(stringType),effects.exit(rawType),effects.exit(type2),ok( +code2)):balance999||code2===null||code2===91||code2===93&&!seen2||code2===94&&!size2&&"_hiddenFootnoteSupport"in self2.parser.constructs?nok(code2):code2===93?(effects.exit(stringType),effects.enter(markerType),effects.consume(code2),effects.exit(markerType),effects.exit(type2),ok):markdownLineEnding(code2)?(effects.enter("lineEnding"),effects.consume(code2), +effects.exit("lineEnding"),atBreak):(effects.enter("chunkString",{contentType:"string"}),labelInside(code2))}function labelInside(code2){return code2===null||code2===91||code2===93||markdownLineEnding(code2)||size2++>999?(effects.exit("chunkString"),atBreak(code2)):(effects.consume(code2),seen2||(seen2=!markdownSpace(code2)),code2===92?labelEscape:labelInside)}function labelEscape(code2){return code2===91||code2===92||code2===93?(effects.consume(code2),size2++,labelInside):labelInside(code2)}}function factoryTitle(effects,ok,nok,type2,markerType,stringType){ +let marker;return start2;function start2(code2){return code2===34||code2===39||code2===40?(effects.enter(type2),effects.enter(markerType),effects.consume(code2),effects.exit(markerType),marker=code2===40?41:code2,begin):nok(code2)}function begin(code2){return code2===marker?(effects.enter(markerType),effects.consume(code2),effects.exit(markerType),effects.exit(type2),ok):(effects.enter(stringType),atBreak(code2))}function atBreak(code2){return code2===marker?(effects.exit(stringType),begin(marker)): +code2===null?nok(code2):markdownLineEnding(code2)?(effects.enter("lineEnding"),effects.consume(code2),effects.exit("lineEnding"),factorySpace(effects,atBreak,"linePrefix")):(effects.enter("chunkString",{contentType:"string"}),inside(code2))}function inside(code2){return code2===marker||code2===null||markdownLineEnding(code2)?(effects.exit("chunkString"),atBreak(code2)):(effects.consume(code2),code2===92?escape2:inside)}function escape2(code2){return code2===marker||code2===92?(effects.consume(code2), +inside):inside(code2)}}function factoryWhitespace(effects,ok){let seen2;return start2;function start2(code2){return markdownLineEnding(code2)?(effects.enter("lineEnding"),effects.consume(code2),effects.exit("lineEnding"),seen2=!0,start2):markdownSpace(code2)?factorySpace(effects,start2,seen2?"linePrefix":"lineSuffix")(code2):ok(code2)}}const definition$1={name:"definition",tokenize:tokenizeDefinition},titleBefore={partial:!0,tokenize:tokenizeTitleBefore};function tokenizeDefinition(effects,ok,nok){ +const self2=this;let identifier2;return start2;function start2(code2){return effects.enter("definition"),before(code2)}function before(code2){return factoryLabel.call(self2,effects,labelAfter,nok,"definitionLabel","definitionLabelMarker","definitionLabelString")(code2)}function labelAfter(code2){return identifier2=normalizeIdentifier(self2.sliceSerialize(self2.events[self2.events.length-1][1]).slice(1,-1)),code2===58?(effects.enter("definitionMarker"),effects.consume(code2),effects.exit("definit\ +ionMarker"),markerAfter):nok(code2)}function markerAfter(code2){return markdownLineEndingOrSpace(code2)?factoryWhitespace(effects,destinationBefore)(code2):destinationBefore(code2)}function destinationBefore(code2){return factoryDestination(effects,destinationAfter,nok,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(code2)}function destinationAfter(code2){return effects.attempt(titleBefore,after, +after)(code2)}function after(code2){return markdownSpace(code2)?factorySpace(effects,afterWhitespace,"whitespace")(code2):afterWhitespace(code2)}function afterWhitespace(code2){return code2===null||markdownLineEnding(code2)?(effects.exit("definition"),self2.parser.defined.push(identifier2),ok(code2)):nok(code2)}}function tokenizeTitleBefore(effects,ok,nok){return titleBefore2;function titleBefore2(code2){return markdownLineEndingOrSpace(code2)?factoryWhitespace(effects,beforeMarker)(code2):nok(code2)} +function beforeMarker(code2){return factoryTitle(effects,titleAfter,nok,"definitionTitle","definitionTitleMarker","definitionTitleString")(code2)}function titleAfter(code2){return markdownSpace(code2)?factorySpace(effects,titleAfterOptionalWhitespace,"whitespace")(code2):titleAfterOptionalWhitespace(code2)}function titleAfterOptionalWhitespace(code2){return code2===null||markdownLineEnding(code2)?ok(code2):nok(code2)}}const hardBreakEscape={name:"hardBreakEscape",tokenize:tokenizeHardBreakEscape}; +function tokenizeHardBreakEscape(effects,ok,nok){return start2;function start2(code2){return effects.enter("hardBreakEscape"),effects.consume(code2),after}function after(code2){return markdownLineEnding(code2)?(effects.exit("hardBreakEscape"),ok(code2)):nok(code2)}}const headingAtx={name:"headingAtx",resolve:resolveHeadingAtx,tokenize:tokenizeHeadingAtx};function resolveHeadingAtx(events,context){let contentEnd=events.length-2,contentStart=3,content2,text2;return events[contentStart][1].type==="\ +whitespace"&&(contentStart+=2),contentEnd-2>contentStart&&events[contentEnd][1].type==="whitespace"&&(contentEnd-=2),events[contentEnd][1].type==="atxHeadingSequence"&&(contentStart===contentEnd-1||contentEnd-4>contentStart&&events[contentEnd-2][1].type==="whitespace")&&(contentEnd-=contentStart+1===contentEnd?2:4),contentEnd>contentStart&&(content2={type:"atxHeadingText",start:events[contentStart][1].start,end:events[contentEnd][1].end},text2={type:"chunkText",start:events[contentStart][1].start, +end:events[contentEnd][1].end,contentType:"text"},splice(events,contentStart,contentEnd-contentStart+1,[["enter",content2,context],["enter",text2,context],["exit",text2,context],["exit",content2,context]])),events}function tokenizeHeadingAtx(effects,ok,nok){let size2=0;return start2;function start2(code2){return effects.enter("atxHeading"),before(code2)}function before(code2){return effects.enter("atxHeadingSequence"),sequenceOpen(code2)}function sequenceOpen(code2){return code2===35&&size2++<6? +(effects.consume(code2),sequenceOpen):code2===null||markdownLineEndingOrSpace(code2)?(effects.exit("atxHeadingSequence"),atBreak(code2)):nok(code2)}function atBreak(code2){return code2===35?(effects.enter("atxHeadingSequence"),sequenceFurther(code2)):code2===null||markdownLineEnding(code2)?(effects.exit("atxHeading"),ok(code2)):markdownSpace(code2)?factorySpace(effects,atBreak,"whitespace")(code2):(effects.enter("atxHeadingText"),data(code2))}function sequenceFurther(code2){return code2===35?(effects. +consume(code2),sequenceFurther):(effects.exit("atxHeadingSequence"),atBreak(code2))}function data(code2){return code2===null||code2===35||markdownLineEndingOrSpace(code2)?(effects.exit("atxHeadingText"),atBreak(code2)):(effects.consume(code2),data)}}const htmlBlockNames=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h\ +3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],htmlRawNames=["pre","script","style","textarea"],htmlFlow={concrete:!0,name:"htmlFlow",resolveTo:resolveToHtmlFlow,tokenize:tokenizeHtmlFlow},blankLineBefore={partial:!0,tokenize:tokenizeBlankLineBefore},nonLazyContinuationStart={partial:!0,tokenize:tokenizeNonLazyContinuationStart}; +function resolveToHtmlFlow(events){let index2=events.length;for(;index2--&&!(events[index2][0]==="enter"&&events[index2][1].type==="htmlFlow"););return index2>1&&events[index2-2][1].type==="linePrefix"&&(events[index2][1].start=events[index2-2][1].start,events[index2+1][1].start=events[index2-2][1].start,events.splice(index2-2,2)),events}function tokenizeHtmlFlow(effects,ok,nok){const self2=this;let marker,closingTag,buffer,index2,markerB;return start2;function start2(code2){return before(code2)} +function before(code2){return effects.enter("htmlFlow"),effects.enter("htmlFlowData"),effects.consume(code2),open2}function open2(code2){return code2===33?(effects.consume(code2),declarationOpen):code2===47?(effects.consume(code2),closingTag=!0,tagCloseStart):code2===63?(effects.consume(code2),marker=3,self2.interrupt?ok:continuationDeclarationInside):asciiAlpha(code2)?(effects.consume(code2),buffer=String.fromCharCode(code2),tagName):nok(code2)}function declarationOpen(code2){return code2===45? +(effects.consume(code2),marker=2,commentOpenInside):code2===91?(effects.consume(code2),marker=5,index2=0,cdataOpenInside):asciiAlpha(code2)?(effects.consume(code2),marker=4,self2.interrupt?ok:continuationDeclarationInside):nok(code2)}function commentOpenInside(code2){return code2===45?(effects.consume(code2),self2.interrupt?ok:continuationDeclarationInside):nok(code2)}function cdataOpenInside(code2){const value="CDATA[";return code2===value.charCodeAt(index2++)?(effects.consume(code2),index2===value. +length?self2.interrupt?ok:continuation:cdataOpenInside):nok(code2)}function tagCloseStart(code2){return asciiAlpha(code2)?(effects.consume(code2),buffer=String.fromCharCode(code2),tagName):nok(code2)}function tagName(code2){if(code2===null||code2===47||code2===62||markdownLineEndingOrSpace(code2)){const slash=code2===47,name=buffer.toLowerCase();return!slash&&!closingTag&&htmlRawNames.includes(name)?(marker=1,self2.interrupt?ok(code2):continuation(code2)):htmlBlockNames.includes(buffer.toLowerCase())? +(marker=6,slash?(effects.consume(code2),basicSelfClosing):self2.interrupt?ok(code2):continuation(code2)):(marker=7,self2.interrupt&&!self2.parser.lazy[self2.now().line]?nok(code2):closingTag?completeClosingTagAfter(code2):completeAttributeNameBefore(code2))}return code2===45||asciiAlphanumeric(code2)?(effects.consume(code2),buffer+=String.fromCharCode(code2),tagName):nok(code2)}function basicSelfClosing(code2){return code2===62?(effects.consume(code2),self2.interrupt?ok:continuation):nok(code2)} +function completeClosingTagAfter(code2){return markdownSpace(code2)?(effects.consume(code2),completeClosingTagAfter):completeEnd(code2)}function completeAttributeNameBefore(code2){return code2===47?(effects.consume(code2),completeEnd):code2===58||code2===95||asciiAlpha(code2)?(effects.consume(code2),completeAttributeName):markdownSpace(code2)?(effects.consume(code2),completeAttributeNameBefore):completeEnd(code2)}function completeAttributeName(code2){return code2===45||code2===46||code2===58||code2=== +95||asciiAlphanumeric(code2)?(effects.consume(code2),completeAttributeName):completeAttributeNameAfter(code2)}function completeAttributeNameAfter(code2){return code2===61?(effects.consume(code2),completeAttributeValueBefore):markdownSpace(code2)?(effects.consume(code2),completeAttributeNameAfter):completeAttributeNameBefore(code2)}function completeAttributeValueBefore(code2){return code2===null||code2===60||code2===61||code2===62||code2===96?nok(code2):code2===34||code2===39?(effects.consume(code2), +markerB=code2,completeAttributeValueQuoted):markdownSpace(code2)?(effects.consume(code2),completeAttributeValueBefore):completeAttributeValueUnquoted(code2)}function completeAttributeValueQuoted(code2){return code2===markerB?(effects.consume(code2),markerB=null,completeAttributeValueQuotedAfter):code2===null||markdownLineEnding(code2)?nok(code2):(effects.consume(code2),completeAttributeValueQuoted)}function completeAttributeValueUnquoted(code2){return code2===null||code2===34||code2===39||code2=== +47||code2===60||code2===61||code2===62||code2===96||markdownLineEndingOrSpace(code2)?completeAttributeNameAfter(code2):(effects.consume(code2),completeAttributeValueUnquoted)}function completeAttributeValueQuotedAfter(code2){return code2===47||code2===62||markdownSpace(code2)?completeAttributeNameBefore(code2):nok(code2)}function completeEnd(code2){return code2===62?(effects.consume(code2),completeAfter):nok(code2)}function completeAfter(code2){return code2===null||markdownLineEnding(code2)?continuation( +code2):markdownSpace(code2)?(effects.consume(code2),completeAfter):nok(code2)}function continuation(code2){return code2===45&&marker===2?(effects.consume(code2),continuationCommentInside):code2===60&&marker===1?(effects.consume(code2),continuationRawTagOpen):code2===62&&marker===4?(effects.consume(code2),continuationClose):code2===63&&marker===3?(effects.consume(code2),continuationDeclarationInside):code2===93&&marker===5?(effects.consume(code2),continuationCdataInside):markdownLineEnding(code2)&& +(marker===6||marker===7)?(effects.exit("htmlFlowData"),effects.check(blankLineBefore,continuationAfter,continuationStart)(code2)):code2===null||markdownLineEnding(code2)?(effects.exit("htmlFlowData"),continuationStart(code2)):(effects.consume(code2),continuation)}function continuationStart(code2){return effects.check(nonLazyContinuationStart,continuationStartNonLazy,continuationAfter)(code2)}function continuationStartNonLazy(code2){return effects.enter("lineEnding"),effects.consume(code2),effects. +exit("lineEnding"),continuationBefore}function continuationBefore(code2){return code2===null||markdownLineEnding(code2)?continuationStart(code2):(effects.enter("htmlFlowData"),continuation(code2))}function continuationCommentInside(code2){return code2===45?(effects.consume(code2),continuationDeclarationInside):continuation(code2)}function continuationRawTagOpen(code2){return code2===47?(effects.consume(code2),buffer="",continuationRawEndTag):continuation(code2)}function continuationRawEndTag(code2){ +if(code2===62){const name=buffer.toLowerCase();return htmlRawNames.includes(name)?(effects.consume(code2),continuationClose):continuation(code2)}return asciiAlpha(code2)&&buffer.length<8?(effects.consume(code2),buffer+=String.fromCharCode(code2),continuationRawEndTag):continuation(code2)}function continuationCdataInside(code2){return code2===93?(effects.consume(code2),continuationDeclarationInside):continuation(code2)}function continuationDeclarationInside(code2){return code2===62?(effects.consume( +code2),continuationClose):code2===45&&marker===2?(effects.consume(code2),continuationDeclarationInside):continuation(code2)}function continuationClose(code2){return code2===null||markdownLineEnding(code2)?(effects.exit("htmlFlowData"),continuationAfter(code2)):(effects.consume(code2),continuationClose)}function continuationAfter(code2){return effects.exit("htmlFlow"),ok(code2)}}function tokenizeNonLazyContinuationStart(effects,ok,nok){const self2=this;return start2;function start2(code2){return markdownLineEnding( +code2)?(effects.enter("lineEnding"),effects.consume(code2),effects.exit("lineEnding"),after):nok(code2)}function after(code2){return self2.parser.lazy[self2.now().line]?nok(code2):ok(code2)}}function tokenizeBlankLineBefore(effects,ok,nok){return start2;function start2(code2){return effects.enter("lineEnding"),effects.consume(code2),effects.exit("lineEnding"),effects.attempt(blankLine,ok,nok)}}const htmlText={name:"htmlText",tokenize:tokenizeHtmlText};function tokenizeHtmlText(effects,ok,nok){const self2=this; +let marker,index2,returnState;return start2;function start2(code2){return effects.enter("htmlText"),effects.enter("htmlTextData"),effects.consume(code2),open2}function open2(code2){return code2===33?(effects.consume(code2),declarationOpen):code2===47?(effects.consume(code2),tagCloseStart):code2===63?(effects.consume(code2),instruction):asciiAlpha(code2)?(effects.consume(code2),tagOpen):nok(code2)}function declarationOpen(code2){return code2===45?(effects.consume(code2),commentOpenInside):code2=== +91?(effects.consume(code2),index2=0,cdataOpenInside):asciiAlpha(code2)?(effects.consume(code2),declaration):nok(code2)}function commentOpenInside(code2){return code2===45?(effects.consume(code2),commentEnd):nok(code2)}function comment2(code2){return code2===null?nok(code2):code2===45?(effects.consume(code2),commentClose):markdownLineEnding(code2)?(returnState=comment2,lineEndingBefore(code2)):(effects.consume(code2),comment2)}function commentClose(code2){return code2===45?(effects.consume(code2), +commentEnd):comment2(code2)}function commentEnd(code2){return code2===62?end(code2):code2===45?commentClose(code2):comment2(code2)}function cdataOpenInside(code2){const value="CDATA[";return code2===value.charCodeAt(index2++)?(effects.consume(code2),index2===value.length?cdata:cdataOpenInside):nok(code2)}function cdata(code2){return code2===null?nok(code2):code2===93?(effects.consume(code2),cdataClose):markdownLineEnding(code2)?(returnState=cdata,lineEndingBefore(code2)):(effects.consume(code2), +cdata)}function cdataClose(code2){return code2===93?(effects.consume(code2),cdataEnd):cdata(code2)}function cdataEnd(code2){return code2===62?end(code2):code2===93?(effects.consume(code2),cdataEnd):cdata(code2)}function declaration(code2){return code2===null||code2===62?end(code2):markdownLineEnding(code2)?(returnState=declaration,lineEndingBefore(code2)):(effects.consume(code2),declaration)}function instruction(code2){return code2===null?nok(code2):code2===63?(effects.consume(code2),instructionClose): +markdownLineEnding(code2)?(returnState=instruction,lineEndingBefore(code2)):(effects.consume(code2),instruction)}function instructionClose(code2){return code2===62?end(code2):instruction(code2)}function tagCloseStart(code2){return asciiAlpha(code2)?(effects.consume(code2),tagClose):nok(code2)}function tagClose(code2){return code2===45||asciiAlphanumeric(code2)?(effects.consume(code2),tagClose):tagCloseBetween(code2)}function tagCloseBetween(code2){return markdownLineEnding(code2)?(returnState=tagCloseBetween, +lineEndingBefore(code2)):markdownSpace(code2)?(effects.consume(code2),tagCloseBetween):end(code2)}function tagOpen(code2){return code2===45||asciiAlphanumeric(code2)?(effects.consume(code2),tagOpen):code2===47||code2===62||markdownLineEndingOrSpace(code2)?tagOpenBetween(code2):nok(code2)}function tagOpenBetween(code2){return code2===47?(effects.consume(code2),end):code2===58||code2===95||asciiAlpha(code2)?(effects.consume(code2),tagOpenAttributeName):markdownLineEnding(code2)?(returnState=tagOpenBetween, +lineEndingBefore(code2)):markdownSpace(code2)?(effects.consume(code2),tagOpenBetween):end(code2)}function tagOpenAttributeName(code2){return code2===45||code2===46||code2===58||code2===95||asciiAlphanumeric(code2)?(effects.consume(code2),tagOpenAttributeName):tagOpenAttributeNameAfter(code2)}function tagOpenAttributeNameAfter(code2){return code2===61?(effects.consume(code2),tagOpenAttributeValueBefore):markdownLineEnding(code2)?(returnState=tagOpenAttributeNameAfter,lineEndingBefore(code2)):markdownSpace( +code2)?(effects.consume(code2),tagOpenAttributeNameAfter):tagOpenBetween(code2)}function tagOpenAttributeValueBefore(code2){return code2===null||code2===60||code2===61||code2===62||code2===96?nok(code2):code2===34||code2===39?(effects.consume(code2),marker=code2,tagOpenAttributeValueQuoted):markdownLineEnding(code2)?(returnState=tagOpenAttributeValueBefore,lineEndingBefore(code2)):markdownSpace(code2)?(effects.consume(code2),tagOpenAttributeValueBefore):(effects.consume(code2),tagOpenAttributeValueUnquoted)} +function tagOpenAttributeValueQuoted(code2){return code2===marker?(effects.consume(code2),marker=void 0,tagOpenAttributeValueQuotedAfter):code2===null?nok(code2):markdownLineEnding(code2)?(returnState=tagOpenAttributeValueQuoted,lineEndingBefore(code2)):(effects.consume(code2),tagOpenAttributeValueQuoted)}function tagOpenAttributeValueUnquoted(code2){return code2===null||code2===34||code2===39||code2===60||code2===61||code2===96?nok(code2):code2===47||code2===62||markdownLineEndingOrSpace(code2)? +tagOpenBetween(code2):(effects.consume(code2),tagOpenAttributeValueUnquoted)}function tagOpenAttributeValueQuotedAfter(code2){return code2===47||code2===62||markdownLineEndingOrSpace(code2)?tagOpenBetween(code2):nok(code2)}function end(code2){return code2===62?(effects.consume(code2),effects.exit("htmlTextData"),effects.exit("htmlText"),ok):nok(code2)}function lineEndingBefore(code2){return effects.exit("htmlTextData"),effects.enter("lineEnding"),effects.consume(code2),effects.exit("lineEnding"), +lineEndingAfter}function lineEndingAfter(code2){return markdownSpace(code2)?factorySpace(effects,lineEndingAfterPrefix,"linePrefix",self2.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(code2):lineEndingAfterPrefix(code2)}function lineEndingAfterPrefix(code2){return effects.enter("htmlTextData"),returnState(code2)}}const labelEnd={name:"labelEnd",resolveAll:resolveAllLabelEnd,resolveTo:resolveToLabelEnd,tokenize:tokenizeLabelEnd},resourceConstruct={tokenize:tokenizeResource},referenceFullConstruct={ +tokenize:tokenizeReferenceFull},referenceCollapsedConstruct={tokenize:tokenizeReferenceCollapsed};function resolveAllLabelEnd(events){let index2=-1;const newEvents=[];for(;++index2=3&&(code2===null||markdownLineEnding(code2))?(effects.exit("thematicBreak"),ok(code2)):nok(code2)}function sequence(code2){return code2===marker?(effects.consume(code2),size2++,sequence):(effects.exit("thematicBreakSequence"),markdownSpace(code2)?factorySpace(effects,atBreak,"whitespace")(code2):atBreak(code2))}}const list$3={continuation:{tokenize:tokenizeListContinuation},exit:tokenizeListEnd,name:"list",tokenize:tokenizeListStart},listItemPrefixWhitespaceConstruct={ +partial:!0,tokenize:tokenizeListItemPrefixWhitespace},indentConstruct={partial:!0,tokenize:tokenizeIndent$1};function tokenizeListStart(effects,ok,nok){const self2=this,tail=self2.events[self2.events.length-1];let initialSize=tail&&tail[1].type==="linePrefix"?tail[2].sliceSerialize(tail[1],!0).length:0,size2=0;return start2;function start2(code2){const kind=self2.containerState.type||(code2===42||code2===43||code2===45?"listUnordered":"listOrdered");if(kind==="listUnordered"?!self2.containerState. +marker||code2===self2.containerState.marker:asciiDigit(code2)){if(self2.containerState.type||(self2.containerState.type=kind,effects.enter(kind,{_container:!0})),kind==="listUnordered")return effects.enter("listItemPrefix"),code2===42||code2===45?effects.check(thematicBreak$2,nok,atMarker)(code2):atMarker(code2);if(!self2.interrupt||code2===49)return effects.enter("listItemPrefix"),effects.enter("listItemValue"),inside(code2)}return nok(code2)}function inside(code2){return asciiDigit(code2)&&++size2< +10?(effects.consume(code2),inside):(!self2.interrupt||size2<2)&&(self2.containerState.marker?code2===self2.containerState.marker:code2===41||code2===46)?(effects.exit("listItemValue"),atMarker(code2)):nok(code2)}function atMarker(code2){return effects.enter("listItemMarker"),effects.consume(code2),effects.exit("listItemMarker"),self2.containerState.marker=self2.containerState.marker||code2,effects.check(blankLine,self2.interrupt?nok:onBlank,effects.attempt(listItemPrefixWhitespaceConstruct,endOfPrefix, +otherPrefix))}function onBlank(code2){return self2.containerState.initialBlankLine=!0,initialSize++,endOfPrefix(code2)}function otherPrefix(code2){return markdownSpace(code2)?(effects.enter("listItemPrefixWhitespace"),effects.consume(code2),effects.exit("listItemPrefixWhitespace"),endOfPrefix):nok(code2)}function endOfPrefix(code2){return self2.containerState.size=initialSize+self2.sliceSerialize(effects.exit("listItemPrefix"),!0).length,ok(code2)}}function tokenizeListContinuation(effects,ok,nok){ +const self2=this;return self2.containerState._closeFlow=void 0,effects.check(blankLine,onBlank,notBlank);function onBlank(code2){return self2.containerState.furtherBlankLines=self2.containerState.furtherBlankLines||self2.containerState.initialBlankLine,factorySpace(effects,ok,"listItemIndent",self2.containerState.size+1)(code2)}function notBlank(code2){return self2.containerState.furtherBlankLines||!markdownSpace(code2)?(self2.containerState.furtherBlankLines=void 0,self2.containerState.initialBlankLine= +void 0,notInCurrentItem(code2)):(self2.containerState.furtherBlankLines=void 0,self2.containerState.initialBlankLine=void 0,effects.attempt(indentConstruct,ok,notInCurrentItem)(code2))}function notInCurrentItem(code2){return self2.containerState._closeFlow=!0,self2.interrupt=void 0,factorySpace(effects,effects.attempt(list$3,ok,nok),"linePrefix",self2.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(code2)}}function tokenizeIndent$1(effects,ok,nok){const self2=this;return factorySpace( +effects,afterPrefix,"listItemIndent",self2.containerState.size+1);function afterPrefix(code2){const tail=self2.events[self2.events.length-1];return tail&&tail[1].type==="listItemIndent"&&tail[2].sliceSerialize(tail[1],!0).length===self2.containerState.size?ok(code2):nok(code2)}}function tokenizeListEnd(effects){effects.exit(this.containerState.type)}function tokenizeListItemPrefixWhitespace(effects,ok,nok){const self2=this;return factorySpace(effects,afterPrefix,"listItemPrefixWhitespace",self2. +parser.constructs.disable.null.includes("codeIndented")?void 0:5);function afterPrefix(code2){const tail=self2.events[self2.events.length-1];return!markdownSpace(code2)&&tail&&tail[1].type==="listItemPrefixWhitespace"?ok(code2):nok(code2)}}const setextUnderline={name:"setextUnderline",resolveTo:resolveToSetextUnderline,tokenize:tokenizeSetextUnderline};function resolveToSetextUnderline(events,context){let index2=events.length,content2,text2,definition2;for(;index2--;)if(events[index2][0]==="ente\ +r"){if(events[index2][1].type==="content"){content2=index2;break}events[index2][1].type==="paragraph"&&(text2=index2)}else events[index2][1].type==="content"&&events.splice(index2,1),!definition2&&events[index2][1].type==="definition"&&(definition2=index2);const heading2={type:"setextHeading",start:{...events[content2][1].start},end:{...events[events.length-1][1].end}};return events[text2][1].type="setextHeadingText",definition2?(events.splice(text2,0,["enter",heading2,context]),events.splice(definition2+ +1,0,["exit",events[content2][1],context]),events[content2][1].end={...events[definition2][1].end}):events[content2][1]=heading2,events.push(["exit",heading2,context]),events}function tokenizeSetextUnderline(effects,ok,nok){const self2=this;let marker;return start2;function start2(code2){let index2=self2.events.length,paragraph2;for(;index2--;)if(self2.events[index2][1].type!=="lineEnding"&&self2.events[index2][1].type!=="linePrefix"&&self2.events[index2][1].type!=="content"){paragraph2=self2.events[index2][1]. +type==="paragraph";break}return!self2.parser.lazy[self2.now().line]&&(self2.interrupt||paragraph2)?(effects.enter("setextHeadingLine"),marker=code2,before(code2)):nok(code2)}function before(code2){return effects.enter("setextHeadingLineSequence"),inside(code2)}function inside(code2){return code2===marker?(effects.consume(code2),inside):(effects.exit("setextHeadingLineSequence"),markdownSpace(code2)?factorySpace(effects,after,"lineSuffix")(code2):after(code2))}function after(code2){return code2=== +null||markdownLineEnding(code2)?(effects.exit("setextHeadingLine"),ok(code2)):nok(code2)}}const flow$1={tokenize:initializeFlow};function initializeFlow(effects){const self2=this,initial=effects.attempt(blankLine,atBlankEnding,effects.attempt(this.parser.constructs.flowInitial,afterConstruct,factorySpace(effects,effects.attempt(this.parser.constructs.flow,afterConstruct,effects.attempt(content,afterConstruct)),"linePrefix")));return initial;function atBlankEnding(code2){if(code2===null){effects. +consume(code2);return}return effects.enter("lineEndingBlank"),effects.consume(code2),effects.exit("lineEndingBlank"),self2.currentConstruct=void 0,initial}function afterConstruct(code2){if(code2===null){effects.consume(code2);return}return effects.enter("lineEnding"),effects.consume(code2),effects.exit("lineEnding"),self2.currentConstruct=void 0,initial}}const resolver={resolveAll:createResolver()},string$1=initializeFactory("string"),text$7=initializeFactory("text");function initializeFactory(field){ +return{resolveAll:createResolver(field==="text"?resolveAllLineSuffixes:void 0),tokenize:initializeText};function initializeText(effects){const self2=this,constructs2=this.parser.constructs[field],text2=effects.attempt(constructs2,start2,notText);return start2;function start2(code2){return atBreak(code2)?text2(code2):notText(code2)}function notText(code2){if(code2===null){effects.consume(code2);return}return effects.enter("data"),effects.consume(code2),data}function data(code2){return atBreak(code2)? +(effects.exit("data"),text2(code2)):(effects.consume(code2),data)}function atBreak(code2){if(code2===null)return!0;const list2=constructs2[code2];let index2=-1;if(list2)for(;++index2-1){const head2=view[0];typeof head2=="string"?view[0]= +head2.slice(startBufferIndex):view.shift()}endBufferIndex>0&&view.push(chunks[endIndex].slice(0,endBufferIndex))}return view}function serializeChunks(chunks,expandTabs){let index2=-1;const result=[];let atTab;for(;++index2 { autoScroll.scrollToBottom('instant'); }); @@ -379,7 +379,9 @@ messages={activeMessages()} onUserAction={() => { autoScroll.enable(); - autoScroll.scrollToBottom(); + if (!autoScroll.userScrolledUp) { + autoScroll.scrollToBottom(); + } }} onMessagesReady={handleMessagesReady} /> diff --git a/tools/server/webui/src/lib/hooks/use-auto-scroll.svelte.ts b/tools/server/webui/src/lib/hooks/use-auto-scroll.svelte.ts index f4b9a0fb0..f59e3ed4b 100644 --- a/tools/server/webui/src/lib/hooks/use-auto-scroll.svelte.ts +++ b/tools/server/webui/src/lib/hooks/use-auto-scroll.svelte.ts @@ -17,7 +17,6 @@ export class AutoScrollController { private _userScrolledUp = $state(false); private _lastScrollTop = $state(0); private _scrollInterval: ReturnType | undefined; - private _scrollTimeout: ReturnType | undefined; private _container: HTMLElement | undefined; private _disabled: boolean; private _mutationObserver: MutationObserver | null = null; @@ -51,6 +50,7 @@ export class AutoScrollController { * Updates the disabled state. */ setDisabled(disabled: boolean): void { + if (this._disabled === disabled) return; this._disabled = disabled; if (disabled) { this._autoScrollEnabled = false; @@ -80,17 +80,6 @@ export class AutoScrollController { this._autoScrollEnabled = true; } - if (this._scrollTimeout) { - clearTimeout(this._scrollTimeout); - } - - this._scrollTimeout = setTimeout(() => { - if (isAtBottom) { - this._userScrolledUp = false; - this._autoScrollEnabled = true; - } - }, AUTO_SCROLL_INTERVAL); - this._lastScrollTop = scrollTop; } @@ -157,11 +146,6 @@ export class AutoScrollController { destroy(): void { this.stopInterval(); this._doStopObserving(); - - if (this._scrollTimeout) { - clearTimeout(this._scrollTimeout); - this._scrollTimeout = undefined; - } } /**