wherever-dev 0.8.4 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +80 -111
- package/dist/index.js.map +1 -1
- package/dist/protocol.d.ts +5 -7
- package/dist/protocol.d.ts.map +1 -1
- package/dist/session-pool.d.ts +3 -0
- package/dist/session-pool.d.ts.map +1 -1
- package/dist/session-pool.js +5 -0
- package/dist/session-pool.js.map +1 -1
- package/package.json +3 -3
- package/public/_app/immutable/assets/0.CwrVDlFK.css +1 -0
- package/public/_app/immutable/chunks/-xFihj9P.js +2 -0
- package/public/_app/immutable/chunks/{Dpm8IW62.js.map → -xFihj9P.js.map} +1 -1
- package/public/_app/immutable/chunks/{Bs6e_yNr.js → 88FtHtY_.js} +2 -2
- package/public/_app/immutable/chunks/{Bs6e_yNr.js.map → 88FtHtY_.js.map} +1 -1
- package/public/_app/immutable/chunks/{C3dty8_c.js → DwXE0xae.js} +2 -2
- package/public/_app/immutable/chunks/{C3dty8_c.js.map → DwXE0xae.js.map} +1 -1
- package/public/_app/immutable/entry/{app.CfEYnTXR.js → app.DvvZgm5h.js} +3 -3
- package/public/_app/immutable/entry/{app.CfEYnTXR.js.map → app.DvvZgm5h.js.map} +1 -1
- package/public/_app/immutable/entry/start.DgTAbv12.js +2 -0
- package/public/_app/immutable/entry/start.DgTAbv12.js.map +1 -0
- package/public/_app/immutable/nodes/{0.BvSvDXrg.js → 0.COFe6BkI.js} +2 -2
- package/public/_app/immutable/nodes/{0.BvSvDXrg.js.map → 0.COFe6BkI.js.map} +1 -1
- package/public/_app/immutable/nodes/{1.CWEPdQEw.js → 1.BLK2L9bz.js} +2 -2
- package/public/_app/immutable/nodes/{1.CWEPdQEw.js.map → 1.BLK2L9bz.js.map} +1 -1
- package/public/_app/immutable/nodes/2.anOtZjZq.js +87 -0
- package/public/_app/immutable/nodes/2.anOtZjZq.js.map +1 -0
- package/public/_app/version.json +1 -1
- package/public/index.html +11 -11
- package/public/service-worker.js +1 -1
- package/public/_app/immutable/assets/0.CKKlv2WN.css +0 -1
- package/public/_app/immutable/chunks/Dpm8IW62.js +0 -2
- package/public/_app/immutable/entry/start.DeP-d0TI.js +0 -2
- package/public/_app/immutable/entry/start.DeP-d0TI.js.map +0 -1
- package/public/_app/immutable/nodes/2.D-h8cHh0.js +0 -89
- package/public/_app/immutable/nodes/2.D-h8cHh0.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"mappings":"q3BAkDO,SAASA,GACfC,EACAC,EACAC,EAAgB,GAChBC,EAAM,GACNC,EAAS,GACTC,EAAe,GACd,CACD,IAAIC,EAASN,EAGTO,EAAQ,GAEZ,GAAIL,EAAe,CAClB,IAAIM,EAAsCR,EAEtCS,KACHH,EAASI,GAAiBC,GAAgBH,CAAW,CAAC,EAExD,CAEAI,EAAgB,IAAM,CACrB,IAAIC,EAAgCC,GAEpC,GAAIP,KAAWA,EAAQN,EAAS,GAAM,IAAK,CACtCQ,IAAWM,GAAY,EAC3B,MACD,CAEA,GAAIb,GAAiB,CAACO,GAAW,CAGhCI,EAAO,MAAQ,KACfL,EAAY,UAAmCD,EAE3CA,IAAU,IACbS,GAC8BL,GAAgBH,CAAW,EAC3BA,EAAY,SAC9C,EAGG,MACD,CAOA,GALIK,EAAO,QAAU,OACpBI,GAAkBJ,EAAO,MAAM,MAAoCA,EAAO,MAAM,GAAG,EACnFA,EAAO,MAAQ,MAGZN,IAAU,GAEd,IAAIE,GAAW,CAGqBS,GAAc,KAMjD,QAHIC,EAAOJ,GAAY,EACnBK,EAAOD,EAGVA,IAAS,OACRA,EAAK,WAAaE,IAAwCF,EAAM,OAAS,KAE1EC,EAAOD,EACPA,EAAOG,GAAiBH,CAAI,EAG7B,GAAIA,IAAS,KACZI,SAAoB,EACdC,GAOPR,GAAaE,GAAcE,CAAI,EAC/Bd,EAASI,GAAiBS,CAAI,EAC9B,MACD,CAMA,IAAIM,EAAKtB,EAAMuB,GAA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","set_hydrate_node","get_first_child","template_effect","effect","active_effect","hydrate_next","assign_nodes","remove_effect_dom","hydrate_node","next","last","COMMENT_NODE","get_next_sibling","w.hydration_mismatch","HYDRATION_ERROR","ns","NAMESPACE_SVG","NAMESPACE_MATHML","wrapper","create_element","head","hash","render_fn","previous_hydrate_node","was_hydrating","head_anchor","set_hydrating","start","create_text","block","e","branch","HEAD_EFFECT","r","t","f","n","clsx","_clsx","to_class","directives","classname","set_class","dom","is_html","prev_classes","next_classes","prev","CLASS_CACHE","next_class_name","select_option","select","mounting","is_array","w.select_multiple_invalid_value","option","get_option_value","option_value","is","init_select","observer","teardown","bind_select_value","get","set","batches","listen_to_event_and_reset_event","is_reset","query","selected_option","current_batch","batch","bind_value","input","is_numberlike_input","to_number","tick","end","length","new_length","untrack","render_effect","pending","bind_group","inputs","group_index","is_checkbox","binding_group","hydration_mismatch","index","get_binding_group_value","queue_micro_task","a","b","hydration_input","bind_checked","group","__value","checked","i","type","ssr","prerender","url","p","resolve","host","canonicalURL","previewImage","isHome","$.derived","$$props","metadata","name","description","page","$.head","$$anchor","meta","$.first_child","fragment","meta_1","$$render","consequent_1","meta_3","$.sibling","meta_4","meta_5","meta_6","meta_7","meta_8","meta_9","meta_10","meta_11","link","link_1","link_2","link_3","meta_12","meta_13","meta_14","meta_15","meta_16","$.get","$0","$1","$.set_attribute","$2","$3","themeColor","appleStatusBarStyle","version","audioCtx","getContext","Ctor","playNote","ctx","frequency","startTime","duration","peakGain","osc","gain","attack","customAudioCache","playCustomSound","el","playInvitingBeep","soundUrl","now","noop","safe_not_equal","subscribe","store","callbacks","unsub","get_store_value","_","subscriber_queue","writable","stop","subscribers","new_value","run_queue","subscriber","update","fn","subscribe2","run2","invalidate","defaultState","WhereverClient","config","newConfig","preserveState","s","protocol","tokenQuery","wsUrl","WebSocketImpl","wsOptions","err","currentWs","onOpen","cached","rejoinFile","rejoinCwd","rejoinModel","onMessage","event","rawData","msg","onClose","onError","data","resetState","dyingWs","swallow","st","sendBeat","checkLiveness","silentFor","streaming","threshold","deadWs","scheme","preserve","listener","lastThinking","m","newMsg","lastAssistant","newMessages","lastUserMessage","toolArgs","k","v","finalizedMessages","startedAt","toolMsg","result","aborted","effectiveIsError","toolImages","endedAt","errorPrefix","content","message","abortedAt","sessionIdForPending","inFlight","candidates","mapped","totalCount","offset","historyContents","seen","undelivered","c","older","lines","rawMessages","sessionId","applyStreamingTail","openCalls","openById","removeFromNameQueue","tName","idx","q","at","args","callIdx","id","isError","interrupted","call","tArgs","allOpen","idxs","lastOpenIdx","lastIndex","lastMsg","text","raw","arr","messageId","timer","x","confirmedId","target","sessionFile","cwd","model","gitInit","createRemote","repoVisibility","cloneRemote","action","password","prompt","updates","cb","filename","base64Data","reject","uploadId","sessionFolders","availableModels","readOnlySessionFolders","defaultPort","loc","getBaseUrl","defaultHost","parsed","port","fetchTimeout","resolveQueue","fetchInFlight","refetchRequested","firstQueuedAt","FETCH_DEBOUNCE_MS","FETCH_MAX_WAIT_MS","doFetchSessions","baseUrl","token","getToken","res","fetchSessions","promise","runQueuedFetch","resolves","fetchReadOnlySessions","fetchModels","gitInitDefaultStore","uploadMethodStore","searchFolderStore","searchCreateRemoteStore","searchDefaultModelStore","checkPath","pathStr","checkRemoteRepo","autocompletePath","fetchConfig","setCurrentSession","getStoredConfig","stored","saveConfig","getConfig","beepDefaultStore","BEEP_OVERRIDES_KEY","loadBeepOverrides","saveBeepOverrides","map","beepOverridesStore","beepSessionKeyStore","getBeepDefault","getBeepSoundUrl","setBeepSoundUrl","beepSessionOverride","derived","$key","$overrides","beepEnabled","$override","$default","setBeepDefault","setBeepSessionOverride","key","setBeepSessionKey","initialConfig","client","state","prevIsStreaming","prevSessionKey","sessionKey","pendingSearchQuery","connect","isSecure","disconnect","suspend","resume","hasSuspendedSession","hasActiveSession","filePickerActiveUntil","FILE_PICKER_GRACE_MS","beginFilePicker","endFilePicker","isFilePickerActive","sendMessage","resendMessage","discardMessage","abort","joinSession","switchSession","createSession","runSearch","trimmed","folder","leaveSession","loadMoreHistory","resolveConflict","ping","clearMessages","setConfig","hideThinking","hideTools","updateConfig","dismissSessionError","dismissNotice","sendSudoPassword","cancelSudoPrompt","changeModel","piState","$s","isConnected","isStreaming","messages","connectionError","currentSession","conflict","isInterrupted","sessionError","sessionNotice","sudoPrompt","isReadOnly","activeSessionInfo","contextUsage","isCreatingSession","isLoadingSession","isResyncing","isAgentPending","hasMoreHistory","isLoadingMoreHistory","uploadFileViaPost","file","fileData","errData","uploadFileViaWebSocket","reader","downloadFileUrl","path","uploadFile","deleteSession","localHost","$.state","localPort","localToken","localHideThinking","localBeepDefault","localBeepSoundUrl","saving","connected","$isConnected","onMount","$.set","handleTestBeep","handleConfigChange","handleConnect","handleDisconnect","handleReload","div","root","div_1","div_2","$.child","$.remove_input_defaults","div_3","input_1","div_4","input_2","div_5","input_3","div_6","input_4","div_7","div_8","input_5","button","div_9","button_1","root_1","$.delegated","$.append","button_2","root_2","consequent","alternate","button_3","$$value","_getDefaults","_defaults","changeDefaults","newDefaults","noopTest","edit","regex","opt","source","obj","val","valSource","other","bull","indent","newline","blockCode","fences","hr","heading","bullet","lheadingCore","lheading","lheadingGfm","_paragraph","blockText","_blockLabel","def","list","_tag","_comment","paragraph","blockquote","blockNormal","gfmTable","blockGfm","blockPedantic","escape","inlineCode","br","inlineText","_punctuation","_punctuationOrSpace","_notPunctuationOrSpace","punctuation","_punctuationGfmStrongEm","_punctuationOrSpaceGfmStrongEm","_notPunctuationOrSpaceGfmStrongEm","blockSkip","emStrongLDelimCore","emStrongLDelim","emStrongLDelimGfm","emStrongRDelimAstCore","emStrongRDelimAst","emStrongRDelimAstGfm","emStrongRDelimUnd","anyPunctuation","autolink","_inlineComment","tag","_inlineLabel","reflink","nolink","reflinkSearch","inlineNormal","inlinePedantic","inlineGfm","inlineBreaks","inline","escapeReplacements","getEscapeReplacement","ch","escape2","html2","encode","cleanUrl","href","splitCells","tableRow","count","row","match","str","escaped","curr","cells","rtrim","invert","l","suffLen","findClosingBracket","level","outputLink","cap","link2","lexer2","rules","title","indentCodeCompensation","matchIndentToCode","indentToCode","matchIndentInNode","indentInNode","_Tokenizer","options2","src","tokens","inBlockquote","currentLines","currentRaw","currentText","top","lastToken","oldToken","newText","newToken","isordered","list2","itemRegex","endsWithBlankLine","endEarly","itemContents","line","nextLine","blankLine","nextBulletRegex","hrRegex","fencesBeginRegex","headingBeginRegex","htmlBeginRegex","rawLine","nextLineWithoutTabs","istask","ischecked","lastItem","spacers","hasMultipleLineBreaks","tag2","headers","aligns","rows","item","align","cell","trimmedUrl","rtrimSlash","lastParenIndex","linkLen","links","linkString","maskedSrc","prevChar","lLength","rDelim","rLength","delimTotal","midDelimTotal","endReg","lastCharLength","text2","hasNonSpaceChars","hasSpaceCharsOnBothEnds","prevCapZero","_Lexer","__Lexer","lastParagraphClipped","extTokenizer","cutSrc","startIndex","tempSrc","tempStart","getStartIndex","errMsg","keepPrevChar","_Renderer","lang","langString","code","depth","ordered","body","j","startAttr","itemBody","checkbox","header","cleanHref","out","_TextRenderer","_Parser","__Parser","anyToken","genericToken","ret","textToken","renderer","_Hooks","markdown","Marked","callback","values","tableToken","listToken","childTokens","tokens2","extensions","pack","opts","ext","prevRenderer","args2","extLevel","prop","rendererProp","rendererFunc","tokenizer","tokenizerProp","tokenizerFunc","prevTokenizer","hooks","hooksProp","hooksFunc","prevHook","arg","ret2","walkTokens2","packWalktokens","blockType","origOpt","throwError","parser2","src2","silent","async","markedInstance","marked","_arrayLikeToArray","_arrayWithHoles","_iterableToArrayLimit","u","o","_nonIterableRest","_slicedToArray","_unsupportedIterableToArray","entries","setPrototypeOf","isFrozen","getPrototypeOf","getOwnPropertyDescriptor","freeze","seal","create","_ref","apply","construct","func","thisArg","_len","_key","Func","_len2","_key2","arrayForEach","unapply","arrayLastIndexOf","arrayPop","arrayPush","arraySplice","arrayIsArray","stringToLowerCase","stringToString","stringMatch","stringReplace","stringIndexOf","stringTrim","numberToString","booleanToString","bigintToString","symbolToString","objectHasOwnProperty","objectToString","regExpTest","typeErrorCreate","unconstruct","_len3","_key3","_len4","_key4","addToSet","array","transformCaseFunc","element","lcElement","cleanArray","clone","object","newObject","_ref2","_ref3","property","stringifyValue","valueAsRecord","valueToString","lookupGetter","stringified","desc","fallbackValue","isRegex","html$1","svg$1","svgFilters","svgDisallowed","mathMl$1","mathMlDisallowed","mathMl","xml","MUSTACHE_EXPR","ERB_EXPR","TMPLIT_EXPR","DATA_ATTR","ARIA_ATTR","IS_ALLOWED_URI","IS_SCRIPT_OR_DATA","ATTR_WHITESPACE","DOCTYPE_NAME","CUSTOM_ELEMENT","ELEMENT_MARKUP_PROBE","COMMENT_MARKUP_PROBE","FALLBACK_TAG_CLOSE","SELF_CLOSING_TAG","NODE_TYPE","getGlobal","_createTrustedTypesPolicy","trustedTypes","purifyHostElement","suffix","ATTR_NAME","policyName","scriptUrl","_createHooksMap","_resolveSetOption","cfg","fallback","options","createDOMPurify","window","DOMPurify","document","originalDocument","currentScript","HTMLTemplateElement","Node","Element","NodeFilter","_window$NamedNodeMap","DOMParser","ElementPrototype","cloneNode","remove","getNextSibling","getChildNodes","getParentNode","getShadowRoot","getAttributes","getNodeType","getNodeName","template","trustedTypesPolicy","emptyHTML","defaultTrustedTypesPolicy","defaultTrustedTypesPolicyResolved","IN_TRUSTED_TYPES_POLICY","_assertNotInTrustedTypesPolicy","_createTrustedHTML","_createTrustedScriptURL","_getDefaultTrustedTypesPolicy","_document","implementation","createNodeIterator","createDocumentFragment","getElementsByTagName","importNode","MUSTACHE_EXPR$1","ERB_EXPR$1","TMPLIT_EXPR$1","DATA_ATTR$1","ARIA_ATTR$1","IS_SCRIPT_OR_DATA$1","ATTR_WHITESPACE$1","CUSTOM_ELEMENT$1","IS_ALLOWED_URI$1","ALLOWED_TAGS","DEFAULT_ALLOWED_TAGS","ALLOWED_ATTR","DEFAULT_ALLOWED_ATTR","CUSTOM_ELEMENT_HANDLING","FORBID_TAGS","FORBID_ATTR","EXTRA_ELEMENT_HANDLING","ALLOW_ARIA_ATTR","ALLOW_DATA_ATTR","ALLOW_UNKNOWN_PROTOCOLS","ALLOW_SELF_CLOSE_IN_ATTR","SAFE_FOR_TEMPLATES","SAFE_FOR_XML","WHOLE_DOCUMENT","SET_CONFIG","SET_CONFIG_ALLOWED_TAGS","SET_CONFIG_ALLOWED_ATTR","FORCE_BODY","RETURN_DOM","RETURN_DOM_FRAGMENT","RETURN_TRUSTED_TYPE","SANITIZE_DOM","SANITIZE_NAMED_PROPS","SANITIZE_NAMED_PROPS_PREFIX","KEEP_CONTENT","IN_PLACE","USE_PROFILES","FORBID_CONTENTS","DEFAULT_FORBID_CONTENTS","DATA_URI_TAGS","DEFAULT_DATA_URI_TAGS","URI_SAFE_ATTRIBUTES","DEFAULT_URI_SAFE_ATTRIBUTES","MATHML_NAMESPACE","SVG_NAMESPACE","HTML_NAMESPACE","NAMESPACE","IS_EMPTY_INPUT","ALLOWED_NAMESPACES","DEFAULT_ALLOWED_NAMESPACES","DEFAULT_MATHML_TEXT_INTEGRATION_POINTS","MATHML_TEXT_INTEGRATION_POINTS","DEFAULT_HTML_INTEGRATION_POINTS","HTML_INTEGRATION_POINTS","COMMON_SVG_AND_HTML_ELEMENTS","PARSER_MEDIA_TYPE","SUPPORTED_PARSER_MEDIA_TYPES","DEFAULT_PARSER_MEDIA_TYPE","CONFIG","formElement","isRegexOrFunction","testValue","_parseConfig","customElementHandling","previousTrustedTypesPolicy","error","ALL_SVG_TAGS","ALL_MATHML_TAGS","_checkSvgNamespace","tagName","parent","parentTagName","_checkMathMlNamespace","_checkHtmlNamespace","_checkValidNamespace","_forceRemove","_neutralizeRoot","childNodes","snapshot","child","attributes","attribute","_removeAttribute","_stripDisallowedAttributes","_neutralizeSubtree","stack","_initDocument","dirty","doc","leadingWhitespace","matches","dirtyPayload","_createNodeIterator","_stripTemplateExpressions","_scrubTemplateExpressions2","_node$querySelectorAl","walker","currentNode","templates","tmpl","_isDocumentFragment","_isClobbered","realTagName","_isNode","_executeHooks","hook","_isUnsafeNode","_sanitizeDisallowedNode","_isBasicCustomElement","parentNode","childCount","hoisted","_sanitizeElements","_isValidAttribute","lcTag","lcName","nameIsPermitted","RESERVED_CUSTOM_ELEMENT_NAMES","_applyTrustedTypesToAttribute","namespaceURI","_setAttributeValue","_sanitizeAttributes","hookEvent","attr","attrValue","initValue","_sanitizeShadowDOM2","shadowNode","shadowIterator","innerSr","_sanitizeAttachedShadowRoots","isElement","rootName","sr","importedNode","returnNode","inPlace","nn","nodeIterator","entry","serializedHTML","entryPoint","hookFunction","purify","CODE_SUMMARY_MAX","escapeHtml","codeRenderer","langLabel","nonEmpty","multiline","codeHtml","summaryText","hookRegistered","ensureHook","renderMarkdown","URL_RE","linkifyText","urlText","trailing","trailMatch","markdownCache","renderAssistant","linkifyCache","renderUser","formatTokens","contextLabel","$piState","parseUserMessage","fileRegex","cleanLines","attachments","cleanContent","newFolderCwd","completions","$.proxy","inputFocused","inputEl","containerEl","lastCheckedPath","newFolderModel","newFolderGitInit","userManualGitInit","createRemoteRepo","showGitInitConfirmModal","showCloneConfirmModal","checkingRemote","cloneRemoteInfo","submitCreateSession","pathStatus","appState","modelsData","$availableModels","defaultGitInit","$gitInitDefaultStore","$.user_effect","isRemoteRepoCreation","pathCheckTimeout","triggerCheck","pathValue","immediate","fetchEmpty","fetchFn","defaultModel","handleFormCreateSession","probe","messageList","sessionInfo","$activeSessionInfo","loadingSession","$isLoadingSession","beepOverride","$beepSessionOverride","beepOn","$beepEnabled","cycleBeep","hasCachedSession","shouldAutoScroll","forceScroll","expandedMessages","toggleMessage","currentVal","parseArgsObject","argsStr","getSmartTitleArgs","toolName","argsObj","rawArgsStr","pathVal","cmd","cleanCmd","pattern","commonPath","getFullArgsFormatted","parseToolMessage","toolOutput","firstLineBreak","headerLine","firstSpace","smartTitleArgs","fullArgs","extractDownloadablePath","isScrolledToBottom","handleScroll","scrollToBottom","scrollToBottomIfShould","lastSessionFile","wasLoadingSession","scrollToBottomSettled","sFile","isLoading","msgList","filtered","$messages","isAssociatedWithForceCommand","activeStreamExists","isThinking","$isStreaming","anyToolRunning","toolDuration","$.user_pre_effect","formatTime","timestamp","shouldAutoExpand","forceScrollToBottom","moreHistory","$hasMoreHistory","loadingMore","$isLoadingMoreHistory","REVEAL_GAP_PX","pendingAnchorId","pendingAnchorFromBottom","handleLoadMore","anchorId","anchorFromBottom","anchorEl","delta","node_1","root_3","$.reset","$.template_effect","$.set_text","wherever","root_4","root_5","img_1","form","div_10","node_2","div_11","root_6","completion","root_7","text_1","consequent_4","span","root_8","span_1","root_9","consequent_5","span_2","root_10","consequent_6","div_12","root_11","$.each","$.index","root_12","root_13","consequent_7","alternate_1","div_13","root_14","div_14","label","text_3","div_15","root_15","label_1","label_2","consequent_8","consequent_9","div_16","root_16","consequent_10","node_8","text_4","$.event","div_17","root_17","div_18","root_18","node_9","div_19","root_19","node_10","consequent_13","alternate_2","consequent_14","node_11","div_20","root_22","div_21","node_12","div_22","root_24","div_23","root_25","div_24","root_26","div_25","root_27","div_26","root_28","consequent_18","div_27","node_14","text_7","consequent_15","consequent_16","consequent_17","alternate_3","div_28","root_30","span_3","span_4","text_8","node_16","span_5","root_31","text_9","d","isExpanded","dlPath","dlUrl","isAttachTool","fileName","div_29","root_33","div_30","root_34","div_31","root_35","span_6","span_7","root_36","text_10","consequent_23","root_37","span_8","span_9","span_10","text_12","div_32","root_38","span_11","span_12","consequent_22","consequent_25","alternate_4","div_33","root_39","div_34","button_4","div_35","node_20","span_13","root_40","span_14","root_41","span_15","root_42","span_16","root_43","consequent_27","consequent_28","consequent_29","alternate_5","span_17","text_14","node_21","span_18","root_44","text_15","consequent_30","span_19","root_45","text_16","$.set_class","d_2","div_36","node_23","consequent_32","alternate_6","node_24","a_1","root_49","span_20","root_50","consequent_33","alternate_7","consequent_34","div_37","root_51","div_38","img","a_2","root_52","img_2","consequent_35","div_39","root_53","node_28","div_40","root_54","pre","text_17","consequent_36","div_41","pre_1","root_55","text_18","div_42","root_56","div_43","root_57","div_44","root_58","consequent_37","consequent_38","consequent_39","alternate_8","consequent_40","consequent_26","alternate_9","pre_2","root_60","text_19","div_45","root_61","consequent_42","alternate_11","parsedUserMsg","div_46","fragment_7","node_31","userHtml","span_21","root_64","$.html","text_20","consequent_44","alternate_12","span_22","root_66","consequent_45","consequent_46","alternate_13","span_23","root_68","consequent_47","node_34","div_47","root_69","filePath","div_48","root_70","span_24","consequent_48","consequent_43","alternate_14","div_49","fragment_11","node_36","consequent_49","node_37","div_50","root_73","button_5","button_6","consequent_50","consequent_51","consequent_2","consequent_3","consequent_12","alternate_15","consequent_11","div_51","div_52","label_3","input_6","node_38","button_7","root_74","span_25","span_26","text_26","$isReadOnly","consequent_52","div_53","root_75","span_27","consequent_53","button_8","node_40","div_54","root_76","div_55","p_1","span_28","div_56","div_57","input_7","label_4","node_41","span_29","root_77","span_30","root_78","consequent_54","alternate_16","div_58","root_79","div_59","input_8","label_5","text_29","div_60","root_80","label_6","input_9","label_7","input_10","consequent_55","consequent_56","div_61","button_9","button_10","consequent_57","div_62","root_81","div_63","p_2","span_31","text_30","p_3","root_82","text_32","consequent_58","div_64","node_45","button_11","button_12","consequent_59","$$args","decideComposeSend","$.prop","SpeechRecognition","isBrowserSupported","isRecording","isProcessing","isHolding","showSettings","directSend","locale","engine","speechError","pressTimer","recognitionInstance","audioContext","micSource","scriptProcessor","audioStream","pcmChunks","baseText","textModified","locales","storedDirectSend","storedLocale","storedEngine","track","savePreferences","playBeep","AudioContextClass","downsampleBuffer","buffer","inputSampleRate","outputSampleRate","sampleRateRatio","newLength","offsetResult","offsetBuffer","nextOffsetBuffer","accum","startBrowserRecording","finalSessionText","interimSessionText","sessionText","stopBrowserRecording","startCloudRecording","stream","inputBuffer","stopCloudRecording","processCloudTranscription","totalLength","chunk","flatBuffer","originalSampleRate","targetSampleRate","downsampledBuffer","wavBuffer","createWav","wavBlob","startRecording","stopRecording","handlePointerDown","handlePointerUp","handlePointerCancel","samples","numOfChan","sampleRate","format","bitDepth","view","writeString","floatTo16BitPCM","output","string","text_2","showAttach","searchMode","searchConfigured","searchModels","searchModel","enterToSend","isCollapsed","fileInput","readOnly","effectivelyDisabled","isAnyUploading","canSend","textarea","DRAFT_PREFIX","draftKey","hydratedKey","saved","focusInput","toggleEnterToSend","handleFileChange","files","startIdx","currentIdx","targetUrl","removeAttachment","handleSend","messageToSend","validAttachments","fileLines","lower","decision","handleKeydown","fragment_1","attachment","node_5","$.bind_select_value","node_7","textarea_1","$.remove_textarea_child","fragment_5","SpeechButton","$.set_checked","folders","$readOnlySessionFolders","$sessionFolders","loading","refresh","resyncing","$isResyncing","models","expanded","searchExpanded","confirmingDelete","confirmingDeleteFolder","searchQuery","filteredFolders","matchesFilter","session","folderName","foldersArr","isFolderExpanded","folderPath","toggleFolder","handleDeleteSession","sessionPath","handleDeleteAllFolderSessions","sessionPaths","handleSessionClick","createFormOpen","sidebarCwd","sidebarCompletions","sidebarInputFocused","sidebarInputEl","sidebarContainerEl","lastCheckedSidebarPath","sidebarModel","sidebarGitInit","userManualSidebarGitInit","sidebarCreateRemote","sidebarRepoVisibility","showSidebarGitConfirmModal","sidebarPathStatus","isSidebarRemoteRepoCreation","sidebarPathCheckTimeout","triggerSidebarCheck","handleSidebarCreateSession","handleSidebarConfirmModalSubmit","newSessionPicker","openNewSessionPicker","closeNewSessionPicker","handleCreateSession","formatRelative","timeStr","diff","mins","hours","truncate","max","node_4","root_20","root_21","node_15","root_23","text_11","node_17","text_6","select_1","root_29","option_1","option_1_value","$.bind_value","button_13","consequent_19","root_32","button_14","$sessionError","consequent_20","consequent_21","input_11","button_15","button_16","consequent_24","$.set_value","$.clsx","$conflict","$sudoPrompt","lastPromptId","submit","cancel","onKeydown","isSessionPendingOpen","isSearchActive","sidebarOpen","sessionView","chatList","handleHashChange","hashId","currentSessionId","hiddenTimer","HIDE_DISCONNECT_DELAY","handleVisibility","handlePageShow","handleConnected","handleReconnect","handleRefresh","handleShowMainScreen","agentPending","$isAgentPending","$isInterrupted","sError","notice","$sessionNotice","wasSessionActive","hashJoinTimer","isCreating","$isCreatingSession","searchFolder","$searchFolderStore","chatInput","searchActive","searchDefaultModel","$searchDefaultModelStore","folderDefault","listDefault","hasFocusedSearch","startSearch","Head","fragment_2","ConnectionSettings","fragment_3","SessionBrowser","$.init_select","select_value","node_19","$.bind_this","ChatMessageList","ChatInput","node_26","SessionConflictDialog","node_27","SudoPasswordDialog"],"ignoreList":[0,1,2,3,4,5,6,11,16,17],"sources":["../../../../../../../node_modules/.pnpm/svelte@5.55.9/node_modules/svelte/src/internal/client/dom/blocks/html.js","../../../../../../../node_modules/.pnpm/svelte@5.55.9/node_modules/svelte/src/internal/client/dom/blocks/svelte-head.js","../../../../../../../node_modules/.pnpm/clsx@2.1.1/node_modules/clsx/dist/clsx.mjs","../../../../../../../node_modules/.pnpm/svelte@5.55.9/node_modules/svelte/src/internal/shared/attributes.js","../../../../../../../node_modules/.pnpm/svelte@5.55.9/node_modules/svelte/src/internal/client/dom/elements/class.js","../../../../../../../node_modules/.pnpm/svelte@5.55.9/node_modules/svelte/src/internal/client/dom/elements/bindings/select.js","../../../../../../../node_modules/.pnpm/svelte@5.55.9/node_modules/svelte/src/internal/client/dom/elements/bindings/input.js","../../../../../../src/routes/+page.ts","../../../../../../src/lib/core/utils/web/path.ts","../../../../../../src/lib/Head.svelte","../../../../../../src/lib/core/beep.ts","../../../../../../../node_modules/.pnpm/sveltore@0.0.2/node_modules/sveltore/dist/index.js","../../../../../../../client/dist/client.js","../../../../../../src/lib/session-store.ts","../../../../../../src/lib/wherever.ts","../../../../../../src/lib/components/ConnectionSettings.svelte","../../../../../../../node_modules/.pnpm/marked@15.0.12/node_modules/marked/lib/marked.esm.js","../../../../../../../node_modules/.pnpm/dompurify@3.4.11/node_modules/dompurify/dist/purify.es.mjs","../../../../../../src/lib/core/utils/markdown.ts","../../../../../../src/lib/components/ChatMessageList.svelte","../../../../../../src/lib/core/compose-send.ts","../../../../../../src/lib/components/speech/SpeechButton.svelte","../../../../../../src/lib/components/ChatInput.svelte","../../../../../../src/lib/components/SessionBrowser.svelte","../../../../../../src/lib/components/SessionConflictDialog.svelte","../../../../../../src/lib/components/SudoPasswordDialog.svelte","../../../../../../src/lib/core/view-mode.ts","../../../../../../src/routes/+page.svelte"],"sourcesContent":["/** @import { Effect, TemplateNode } from '#client' */\n/** @import {} from 'trusted-types' */\nimport {\n\tFILENAME,\n\tHYDRATION_ERROR,\n\tNAMESPACE_SVG,\n\tNAMESPACE_MATHML\n} from '../../../../constants.js';\nimport { remove_effect_dom, template_effect } from '../../reactivity/effects.js';\nimport { hydrate_next, hydrate_node, hydrating, set_hydrate_node } from '../hydration.js';\n\nimport { assign_nodes } from '../template.js';\nimport * as w from '../../warnings.js';\nimport { hash, sanitize_location } from '../../../../utils.js';\nimport { DEV } from 'esm-env';\nimport { dev_current_component_function } from '../../context.js';\nimport { create_element, get_first_child, get_next_sibling } from '../operations.js';\nimport { active_effect } from '../../runtime.js';\nimport { COMMENT_NODE } from '#client/constants';\n\n/**\n * @param {Element} element\n * @param {string | null} server_hash\n * @param {string | TrustedHTML} value\n */\nfunction check_hash(element, server_hash, value) {\n\tif (!server_hash || server_hash === hash(String(value ?? ''))) return;\n\n\tlet location;\n\n\t// @ts-expect-error\n\tconst loc = element.__svelte_meta?.loc;\n\tif (loc) {\n\t\tlocation = `near ${loc.file}:${loc.line}:${loc.column}`;\n\t} else if (dev_current_component_function?.[FILENAME]) {\n\t\tlocation = `in ${dev_current_component_function[FILENAME]}`;\n\t}\n\n\tw.hydration_html_changed(sanitize_location(location));\n}\n\n/**\n * @param {Element | Text | Comment} node\n * @param {() => string | TrustedHTML} get_value\n * @param {boolean} [is_controlled]\n * @param {boolean} [svg]\n * @param {boolean} [mathml]\n * @param {boolean} [skip_warning]\n * @returns {void}\n */\nexport function html(\n\tnode,\n\tget_value,\n\tis_controlled = false,\n\tsvg = false,\n\tmathml = false,\n\tskip_warning = false\n) {\n\tvar anchor = node;\n\n\t/** @type {string | TrustedHTML} */\n\tvar value = '';\n\n\tif (is_controlled) {\n\t\tvar parent_node = /** @type {Element} */ (node);\n\n\t\tif (hydrating) {\n\t\t\tanchor = set_hydrate_node(get_first_child(parent_node));\n\t\t}\n\t}\n\n\ttemplate_effect(() => {\n\t\tvar effect = /** @type {Effect} */ (active_effect);\n\n\t\tif (value === (value = get_value() ?? '')) {\n\t\t\tif (hydrating) hydrate_next();\n\t\t\treturn;\n\t\t}\n\n\t\tif (is_controlled && !hydrating) {\n\t\t\t// When @html is the only child, use innerHTML directly.\n\t\t\t// This also handles contenteditable, where the user may delete the anchor comment.\n\t\t\teffect.nodes = null;\n\t\t\tparent_node.innerHTML = /** @type {string} */ (value);\n\n\t\t\tif (value !== '') {\n\t\t\t\tassign_nodes(\n\t\t\t\t\t/** @type {TemplateNode} */ (get_first_child(parent_node)),\n\t\t\t\t\t/** @type {TemplateNode} */ (parent_node.lastChild)\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn;\n\t\t}\n\n\t\tif (effect.nodes !== null) {\n\t\t\tremove_effect_dom(effect.nodes.start, /** @type {TemplateNode} */ (effect.nodes.end));\n\t\t\teffect.nodes = null;\n\t\t}\n\n\t\tif (value === '') return;\n\n\t\tif (hydrating) {\n\t\t\t// We're deliberately not trying to repair mismatches between server and client,\n\t\t\t// as it's costly and error-prone (and it's an edge case to have a mismatch anyway)\n\t\t\tvar hash = /** @type {Comment} */ (hydrate_node).data;\n\n\t\t\t/** @type {TemplateNode | null} */\n\t\t\tvar next = hydrate_next();\n\t\t\tvar last = next;\n\n\t\t\twhile (\n\t\t\t\tnext !== null &&\n\t\t\t\t(next.nodeType !== COMMENT_NODE || /** @type {Comment} */ (next).data !== '')\n\t\t\t) {\n\t\t\t\tlast = next;\n\t\t\t\tnext = get_next_sibling(next);\n\t\t\t}\n\n\t\t\tif (next === null) {\n\t\t\t\tw.hydration_mismatch();\n\t\t\t\tthrow HYDRATION_ERROR;\n\t\t\t}\n\n\t\t\tif (DEV && !skip_warning) {\n\t\t\t\tcheck_hash(/** @type {Element} */ (next.parentNode), hash, value);\n\t\t\t}\n\n\t\t\tassign_nodes(hydrate_node, last);\n\t\t\tanchor = set_hydrate_node(next);\n\t\t\treturn;\n\t\t}\n\n\t\t// Don't use create_fragment_with_script_from_html here because that would mean script tags are executed.\n\t\t// @html is basically `.innerHTML = ...` and that doesn't execute scripts either due to security reasons.\n\t\t// Use a <template>, <svg>, or <math> wrapper depending on context. If value is a TrustedHTML object,\n\t\t// it will be assigned directly to innerHTML without coercion — this allows {@html policy.createHTML(...)} to work.\n\t\tvar ns = svg ? NAMESPACE_SVG : mathml ? NAMESPACE_MATHML : undefined;\n\t\tvar wrapper = /** @type {HTMLTemplateElement | SVGElement | MathMLElement} */ (\n\t\t\tcreate_element(svg ? 'svg' : mathml ? 'math' : 'template', ns)\n\t\t);\n\t\twrapper.innerHTML = /** @type {any} */ (value);\n\n\t\t/** @type {DocumentFragment | Element} */\n\t\tvar node = svg || mathml ? wrapper : /** @type {HTMLTemplateElement} */ (wrapper).content;\n\n\t\tassign_nodes(\n\t\t\t/** @type {TemplateNode} */ (get_first_child(node)),\n\t\t\t/** @type {TemplateNode} */ (node.lastChild)\n\t\t);\n\n\t\tif (svg || mathml) {\n\t\t\twhile (get_first_child(node)) {\n\t\t\t\tanchor.before(/** @type {TemplateNode} */ (get_first_child(node)));\n\t\t\t}\n\t\t} else {\n\t\t\tanchor.before(node);\n\t\t}\n\t});\n}\n","/** @import { TemplateNode } from '#client' */\nimport { hydrate_node, hydrating, set_hydrate_node, set_hydrating } from '../hydration.js';\nimport { create_text, get_first_child, get_next_sibling } from '../operations.js';\nimport { block, branch } from '../../reactivity/effects.js';\nimport { COMMENT_NODE, HEAD_EFFECT } from '#client/constants';\n\n/**\n * @param {string} hash\n * @param {(anchor: Node) => void} render_fn\n * @returns {void}\n */\nexport function head(hash, render_fn) {\n\t// The head function may be called after the first hydration pass and ssr comment nodes may still be present,\n\t// therefore we need to skip that when we detect that we're not in hydration mode.\n\tlet previous_hydrate_node = null;\n\tlet was_hydrating = hydrating;\n\n\t/** @type {Comment | Text} */\n\tvar anchor;\n\n\tif (hydrating) {\n\t\tprevious_hydrate_node = hydrate_node;\n\n\t\tvar head_anchor = get_first_child(document.head);\n\n\t\t// There might be multiple head blocks in our app, and they could have been\n\t\t// rendered in an arbitrary order — find one corresponding to this component\n\t\twhile (\n\t\t\thead_anchor !== null &&\n\t\t\t(head_anchor.nodeType !== COMMENT_NODE || /** @type {Comment} */ (head_anchor).data !== hash)\n\t\t) {\n\t\t\thead_anchor = get_next_sibling(head_anchor);\n\t\t}\n\n\t\t// If we can't find an opening hydration marker, skip hydration (this can happen\n\t\t// if a framework rendered body but not head content)\n\t\tif (head_anchor === null) {\n\t\t\tset_hydrating(false);\n\t\t} else {\n\t\t\tvar start = /** @type {TemplateNode} */ (get_next_sibling(head_anchor));\n\t\t\thead_anchor.remove(); // in case this component is repeated\n\n\t\t\tset_hydrate_node(start);\n\t\t}\n\t}\n\n\tif (!hydrating) {\n\t\tanchor = document.head.appendChild(create_text());\n\t}\n\n\ttry {\n\t\tblock(() => {\n\t\t\tvar e = branch(() => render_fn(anchor));\n\t\t\te.f |= HEAD_EFFECT;\n\t\t});\n\t} finally {\n\t\tif (was_hydrating) {\n\t\t\tset_hydrating(true);\n\t\t\tset_hydrate_node(/** @type {TemplateNode} */ (previous_hydrate_node));\n\t\t}\n\t}\n}\n","function r(e){var t,f,n=\"\";if(\"string\"==typeof e||\"number\"==typeof e)n+=e;else if(\"object\"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=\" \"),n+=f)}else for(f in e)e[f]&&(n&&(n+=\" \"),n+=f);return n}export function clsx(){for(var e,t,f=0,n=\"\",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=\" \"),n+=t);return n}export default clsx;","import { escape_html } from '../../escaping.js';\nimport { clsx as _clsx } from 'clsx';\nimport { has_own_property } from './utils.js';\n\n/**\n * `<div translate={false}>` should be rendered as `<div translate=\"no\">` and _not_\n * `<div translate=\"false\">`, which is equivalent to `<div translate=\"yes\">`. There\n * may be other odd cases that need to be added to this list in future\n * @type {Record<string, Map<any, string>>}\n */\nconst replacements = {\n\ttranslate: new Map([\n\t\t[true, 'yes'],\n\t\t[false, 'no']\n\t])\n};\n\n/**\n * @template V\n * @param {string} name\n * @param {V} value\n * @param {boolean} [is_boolean]\n * @returns {string}\n */\nexport function attr(name, value, is_boolean = false) {\n\t// attribute hidden for values other than \"until-found\" behaves like a boolean attribute\n\tif (name === 'hidden' && value !== 'until-found') {\n\t\tis_boolean = true;\n\t}\n\tif (value == null || (!value && is_boolean)) return '';\n\tconst normalized =\n\t\t(has_own_property.call(replacements, name) && replacements[name].get(value)) || value;\n\tconst assignment = is_boolean ? `=\"\"` : `=\"${escape_html(normalized, true)}\"`;\n\treturn ` ${name}${assignment}`;\n}\n\n/**\n * Small wrapper around clsx to preserve Svelte's (weird) handling of falsy values.\n * TODO Svelte 6 revisit this, and likely turn all falsy values into the empty string (what clsx also does)\n * @param {any} value\n */\nexport function clsx(value) {\n\tif (typeof value === 'object') {\n\t\treturn _clsx(value);\n\t} else {\n\t\treturn value ?? '';\n\t}\n}\n\nconst whitespace = [...' \\t\\n\\r\\f\\u00a0\\u000b\\ufeff'];\n\n/**\n * @param {any} value\n * @param {string | null} [hash]\n * @param {Record<string, boolean>} [directives]\n * @returns {string | null}\n */\nexport function to_class(value, hash, directives) {\n\tvar classname = value == null ? '' : '' + value;\n\n\tif (hash) {\n\t\tclassname = classname ? classname + ' ' + hash : hash;\n\t}\n\n\tif (directives) {\n\t\tfor (var key of Object.keys(directives)) {\n\t\t\tif (directives[key]) {\n\t\t\t\tclassname = classname ? classname + ' ' + key : key;\n\t\t\t} else if (classname.length) {\n\t\t\t\tvar len = key.length;\n\t\t\t\tvar a = 0;\n\n\t\t\t\twhile ((a = classname.indexOf(key, a)) >= 0) {\n\t\t\t\t\tvar b = a + len;\n\n\t\t\t\t\tif (\n\t\t\t\t\t\t(a === 0 || whitespace.includes(classname[a - 1])) &&\n\t\t\t\t\t\t(b === classname.length || whitespace.includes(classname[b]))\n\t\t\t\t\t) {\n\t\t\t\t\t\tclassname = (a === 0 ? '' : classname.substring(0, a)) + classname.substring(b + 1);\n\t\t\t\t\t} else {\n\t\t\t\t\t\ta = b;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn classname === '' ? null : classname;\n}\n\n/**\n *\n * @param {Record<string,any>} styles\n * @param {boolean} important\n */\nfunction append_styles(styles, important = false) {\n\tvar separator = important ? ' !important;' : ';';\n\tvar css = '';\n\n\tfor (var key of Object.keys(styles)) {\n\t\tvar value = styles[key];\n\t\tif (value != null && value !== '') {\n\t\t\tcss += ' ' + key + ': ' + value + separator;\n\t\t}\n\t}\n\n\treturn css;\n}\n\n/**\n * @param {string} name\n * @returns {string}\n */\nfunction to_css_name(name) {\n\tif (name[0] !== '-' || name[1] !== '-') {\n\t\treturn name.toLowerCase();\n\t}\n\treturn name;\n}\n\n/**\n * @param {any} value\n * @param {Record<string, any> | [Record<string, any>, Record<string, any>]} [styles]\n * @returns {string | null}\n */\nexport function to_style(value, styles) {\n\tif (styles) {\n\t\tvar new_style = '';\n\n\t\t/** @type {Record<string,any> | undefined} */\n\t\tvar normal_styles;\n\n\t\t/** @type {Record<string,any> | undefined} */\n\t\tvar important_styles;\n\n\t\tif (Array.isArray(styles)) {\n\t\t\tnormal_styles = styles[0];\n\t\t\timportant_styles = styles[1];\n\t\t} else {\n\t\t\tnormal_styles = styles;\n\t\t}\n\n\t\tif (value) {\n\t\t\tvalue = String(value)\n\t\t\t\t.replaceAll(/\\s*\\/\\*.*?\\*\\/\\s*/g, '')\n\t\t\t\t.trim();\n\n\t\t\t/** @type {boolean | '\"' | \"'\"} */\n\t\t\tvar in_str = false;\n\t\t\tvar in_apo = 0;\n\t\t\tvar in_comment = false;\n\n\t\t\tvar reserved_names = [];\n\n\t\t\tif (normal_styles) {\n\t\t\t\treserved_names.push(...Object.keys(normal_styles).map(to_css_name));\n\t\t\t}\n\t\t\tif (important_styles) {\n\t\t\t\treserved_names.push(...Object.keys(important_styles).map(to_css_name));\n\t\t\t}\n\n\t\t\tvar start_index = 0;\n\t\t\tvar name_index = -1;\n\n\t\t\tconst len = value.length;\n\t\t\tfor (var i = 0; i < len; i++) {\n\t\t\t\tvar c = value[i];\n\n\t\t\t\tif (in_comment) {\n\t\t\t\t\tif (c === '/' && value[i - 1] === '*') {\n\t\t\t\t\t\tin_comment = false;\n\t\t\t\t\t}\n\t\t\t\t} else if (in_str) {\n\t\t\t\t\tif (in_str === c) {\n\t\t\t\t\t\tin_str = false;\n\t\t\t\t\t}\n\t\t\t\t} else if (c === '/' && value[i + 1] === '*') {\n\t\t\t\t\tin_comment = true;\n\t\t\t\t} else if (c === '\"' || c === \"'\") {\n\t\t\t\t\tin_str = c;\n\t\t\t\t} else if (c === '(') {\n\t\t\t\t\tin_apo++;\n\t\t\t\t} else if (c === ')') {\n\t\t\t\t\tin_apo--;\n\t\t\t\t}\n\n\t\t\t\tif (!in_comment && in_str === false && in_apo === 0) {\n\t\t\t\t\tif (c === ':' && name_index === -1) {\n\t\t\t\t\t\tname_index = i;\n\t\t\t\t\t} else if (c === ';' || i === len - 1) {\n\t\t\t\t\t\tif (name_index !== -1) {\n\t\t\t\t\t\t\tvar name = to_css_name(value.substring(start_index, name_index).trim());\n\n\t\t\t\t\t\t\tif (!reserved_names.includes(name)) {\n\t\t\t\t\t\t\t\tif (c !== ';') {\n\t\t\t\t\t\t\t\t\ti++;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tvar property = value.substring(start_index, i).trim();\n\t\t\t\t\t\t\t\tnew_style += ' ' + property + ';';\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tstart_index = i + 1;\n\t\t\t\t\t\tname_index = -1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (normal_styles) {\n\t\t\tnew_style += append_styles(normal_styles);\n\t\t}\n\n\t\tif (important_styles) {\n\t\t\tnew_style += append_styles(important_styles, true);\n\t\t}\n\n\t\tnew_style = new_style.trim();\n\t\treturn new_style === '' ? null : new_style;\n\t}\n\n\treturn value == null ? null : String(value);\n}\n","import { to_class } from '../../../shared/attributes.js';\nimport { CLASS_CACHE } from '../../constants.js';\nimport { hydrating } from '../hydration.js';\n\n/**\n * @param {Element} dom\n * @param {boolean | number} is_html\n * @param {string | null} value\n * @param {string} [hash]\n * @param {Record<string, any>} [prev_classes]\n * @param {Record<string, any>} [next_classes]\n * @returns {Record<string, boolean> | undefined}\n */\nexport function set_class(dom, is_html, value, hash, prev_classes, next_classes) {\n\tvar prev = /** @type {any} */ (dom)[CLASS_CACHE];\n\n\tif (\n\t\thydrating ||\n\t\tprev !== value ||\n\t\tprev === undefined // for edge case of `class={undefined}`\n\t) {\n\t\tvar next_class_name = to_class(value, hash, next_classes);\n\n\t\tif (!hydrating || next_class_name !== dom.getAttribute('class')) {\n\t\t\t// Removing the attribute when the value is only an empty string causes\n\t\t\t// performance issues vs simply making the className an empty string. So\n\t\t\t// we should only remove the class if the value is nullish\n\t\t\t// and there no hash/directives :\n\t\t\tif (next_class_name == null) {\n\t\t\t\tdom.removeAttribute('class');\n\t\t\t} else if (is_html) {\n\t\t\t\tdom.className = next_class_name;\n\t\t\t} else {\n\t\t\t\tdom.setAttribute('class', next_class_name);\n\t\t\t}\n\t\t}\n\n\t\t/** @type {any} */ (dom)[CLASS_CACHE] = value;\n\t} else if (next_classes && prev_classes !== next_classes) {\n\t\tfor (var key in next_classes) {\n\t\t\tvar is_present = !!next_classes[key];\n\n\t\t\tif (prev_classes == null || is_present !== !!prev_classes[key]) {\n\t\t\t\tdom.classList.toggle(key, is_present);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn next_classes;\n}\n","import { effect, teardown } from '../../../reactivity/effects.js';\nimport { listen_to_event_and_reset_event } from './shared.js';\nimport { is } from '../../../proxy.js';\nimport { is_array } from '../../../../shared/utils.js';\nimport * as w from '../../../warnings.js';\nimport { Batch, current_batch, previous_batch } from '../../../reactivity/batch.js';\nimport { async_mode_flag } from '../../../../flags/index.js';\n\n/**\n * Selects the correct option(s) (depending on whether this is a multiple select)\n * @template V\n * @param {HTMLSelectElement} select\n * @param {V} value\n * @param {boolean} mounting\n */\nexport function select_option(select, value, mounting = false) {\n\tif (select.multiple) {\n\t\t// If value is null or undefined, keep the selection as is\n\t\tif (value == undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\t// If not an array, warn and keep the selection as is\n\t\tif (!is_array(value)) {\n\t\t\treturn w.select_multiple_invalid_value();\n\t\t}\n\n\t\t// Otherwise, update the selection\n\t\tfor (var option of select.options) {\n\t\t\toption.selected = value.includes(get_option_value(option));\n\t\t}\n\n\t\treturn;\n\t}\n\n\tfor (option of select.options) {\n\t\tvar option_value = get_option_value(option);\n\t\tif (is(option_value, value)) {\n\t\t\toption.selected = true;\n\t\t\treturn;\n\t\t}\n\t}\n\n\tif (!mounting || value !== undefined) {\n\t\tselect.selectedIndex = -1; // no option should be selected\n\t}\n}\n\n/**\n * Selects the correct option(s) if `value` is given,\n * and then sets up a mutation observer to sync the\n * current selection to the dom when it changes. Such\n * changes could for example occur when options are\n * inside an `#each` block.\n * @param {HTMLSelectElement} select\n */\nexport function init_select(select) {\n\tvar observer = new MutationObserver(() => {\n\t\t// @ts-ignore\n\t\tselect_option(select, select.__value);\n\t\t// Deliberately don't update the potential binding value,\n\t\t// the model should be preserved unless explicitly changed\n\t});\n\n\tobserver.observe(select, {\n\t\t// Listen to option element changes\n\t\tchildList: true,\n\t\tsubtree: true, // because of <optgroup>\n\t\t// Listen to option element value attribute changes\n\t\t// (doesn't get notified of select value changes,\n\t\t// because that property is not reflected as an attribute)\n\t\tattributes: true,\n\t\tattributeFilter: ['value']\n\t});\n\n\tteardown(() => {\n\t\tobserver.disconnect();\n\t});\n}\n\n/**\n * @param {HTMLSelectElement} select\n * @param {() => unknown} get\n * @param {(value: unknown) => void} set\n * @returns {void}\n */\nexport function bind_select_value(select, get, set = get) {\n\tvar batches = new WeakSet();\n\tvar mounting = true;\n\n\tlisten_to_event_and_reset_event(select, 'change', (is_reset) => {\n\t\tvar query = is_reset ? '[selected]' : ':checked';\n\t\t/** @type {unknown} */\n\t\tvar value;\n\n\t\tif (select.multiple) {\n\t\t\tvalue = [].map.call(select.querySelectorAll(query), get_option_value);\n\t\t} else {\n\t\t\t/** @type {HTMLOptionElement | null} */\n\t\t\tvar selected_option =\n\t\t\t\tselect.querySelector(query) ??\n\t\t\t\t// will fall back to first non-disabled option if no option is selected\n\t\t\t\tselect.querySelector('option:not([disabled])');\n\t\t\tvalue = selected_option && get_option_value(selected_option);\n\t\t}\n\n\t\tset(value);\n\n\t\t// @ts-ignore\n\t\tselect.__value = value;\n\n\t\tif (current_batch !== null) {\n\t\t\tbatches.add(current_batch);\n\t\t}\n\t});\n\n\t// Needs to be an effect, not a render_effect, so that in case of each loops the logic runs after the each block has updated\n\teffect(() => {\n\t\tvar value = get();\n\n\t\tif (select === document.activeElement) {\n\t\t\t// In sync mode render effects are executed during tree traversal -> needs current_batch\n\t\t\t// In async mode render effects are flushed once batch resolved, at which point current_batch is null -> needs previous_batch\n\t\t\tvar batch = /** @type {Batch} */ (async_mode_flag ? previous_batch : current_batch);\n\n\t\t\t// Don't update the <select> if it is focused. We can get here if, for example,\n\t\t\t// an update is deferred because of async work depending on the select:\n\t\t\t//\n\t\t\t// <select bind:value={selected}>...</select>\n\t\t\t// <p>{await find(selected)}</p>\n\t\t\tif (batches.has(batch)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\tselect_option(select, value, mounting);\n\n\t\t// Mounting and value undefined -> take selection from dom\n\t\tif (mounting && value === undefined) {\n\t\t\t/** @type {HTMLOptionElement | null} */\n\t\t\tvar selected_option = select.querySelector(':checked');\n\t\t\tif (selected_option !== null) {\n\t\t\t\tvalue = get_option_value(selected_option);\n\t\t\t\tset(value);\n\t\t\t}\n\t\t}\n\n\t\t// @ts-ignore\n\t\tselect.__value = value;\n\t\tmounting = false;\n\t});\n\n\tinit_select(select);\n}\n\n/** @param {HTMLOptionElement} option */\nfunction get_option_value(option) {\n\t// __value only exists if the <option> has a value attribute\n\tif ('__value' in option) {\n\t\treturn option.__value;\n\t} else {\n\t\treturn option.value;\n\t}\n}\n","/** @import { Batch } from '../../../reactivity/batch.js' */\nimport { DEV } from 'esm-env';\nimport { render_effect, teardown } from '../../../reactivity/effects.js';\nimport { listen_to_event_and_reset_event } from './shared.js';\nimport * as e from '../../../errors.js';\nimport { is } from '../../../proxy.js';\nimport { queue_micro_task } from '../../task.js';\nimport { hydrating } from '../../hydration.js';\nimport { tick, untrack } from '../../../runtime.js';\nimport { is_runes } from '../../../context.js';\nimport { current_batch, previous_batch } from '../../../reactivity/batch.js';\nimport { async_mode_flag } from '../../../../flags/index.js';\n\n/**\n * @param {HTMLInputElement} input\n * @param {() => unknown} get\n * @param {(value: unknown) => void} set\n * @returns {void}\n */\nexport function bind_value(input, get, set = get) {\n\tvar batches = new WeakSet();\n\n\tlisten_to_event_and_reset_event(input, 'input', async (is_reset) => {\n\t\tif (DEV && input.type === 'checkbox') {\n\t\t\t// TODO should this happen in prod too?\n\t\t\te.bind_invalid_checkbox_value();\n\t\t}\n\n\t\t/** @type {any} */\n\t\tvar value = is_reset ? input.defaultValue : input.value;\n\t\tvalue = is_numberlike_input(input) ? to_number(value) : value;\n\t\tset(value);\n\n\t\tif (current_batch !== null) {\n\t\t\tbatches.add(current_batch);\n\t\t}\n\n\t\t// Because `{#each ...}` blocks work by updating sources inside the flush,\n\t\t// we need to wait a tick before checking to see if we should forcibly\n\t\t// update the input and reset the selection state\n\t\tawait tick();\n\n\t\t// Respect any validation in accessors\n\t\tif (value !== (value = get())) {\n\t\t\tvar start = input.selectionStart;\n\t\t\tvar end = input.selectionEnd;\n\t\t\tvar length = input.value.length;\n\n\t\t\t// the value is coerced on assignment\n\t\t\tinput.value = value ?? '';\n\n\t\t\t// Restore selection\n\t\t\tif (end !== null) {\n\t\t\t\tvar new_length = input.value.length;\n\t\t\t\t// If cursor was at end and new input is longer, move cursor to new end\n\t\t\t\tif (start === end && end === length && new_length > length) {\n\t\t\t\t\tinput.selectionStart = new_length;\n\t\t\t\t\tinput.selectionEnd = new_length;\n\t\t\t\t} else {\n\t\t\t\t\tinput.selectionStart = start;\n\t\t\t\t\tinput.selectionEnd = Math.min(end, new_length);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t});\n\n\tif (\n\t\t// If we are hydrating and the value has since changed,\n\t\t// then use the updated value from the input instead.\n\t\t(hydrating && input.defaultValue !== input.value) ||\n\t\t// If defaultValue is set, then value == defaultValue\n\t\t// TODO Svelte 6: remove input.value check and set to empty string?\n\t\t(untrack(get) == null && input.value)\n\t) {\n\t\tset(is_numberlike_input(input) ? to_number(input.value) : input.value);\n\n\t\tif (current_batch !== null) {\n\t\t\tbatches.add(current_batch);\n\t\t}\n\t}\n\n\trender_effect(() => {\n\t\tif (DEV && input.type === 'checkbox') {\n\t\t\t// TODO should this happen in prod too?\n\t\t\te.bind_invalid_checkbox_value();\n\t\t}\n\n\t\tvar value = get();\n\n\t\tif (input === document.activeElement) {\n\t\t\t// In sync mode render effects are executed during tree traversal -> needs current_batch\n\t\t\t// In async mode render effects are flushed once batch resolved, at which point current_batch is null -> needs previous_batch\n\t\t\tvar batch = /** @type {Batch} */ (async_mode_flag ? previous_batch : current_batch);\n\n\t\t\t// Never rewrite the contents of a focused input. We can get here if, for example,\n\t\t\t// an update is deferred because of async work depending on the input:\n\t\t\t//\n\t\t\t// <input bind:value={query}>\n\t\t\t// <p>{await find(query)}</p>\n\t\t\tif (batches.has(batch)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\tif (is_numberlike_input(input) && value === to_number(input.value)) {\n\t\t\t// handles 0 vs 00 case (see https://github.com/sveltejs/svelte/issues/9959)\n\t\t\treturn;\n\t\t}\n\n\t\tif (input.type === 'date' && !value && !input.value) {\n\t\t\t// Handles the case where a temporarily invalid date is set (while typing, for example with a leading 0 for the day)\n\t\t\t// and prevents this state from clearing the other parts of the date input (see https://github.com/sveltejs/svelte/issues/7897)\n\t\t\treturn;\n\t\t}\n\n\t\t// don't set the value of the input if it's the same to allow\n\t\t// minlength to work properly\n\t\tif (value !== input.value) {\n\t\t\t// @ts-expect-error the value is coerced on assignment\n\t\t\tinput.value = value ?? '';\n\t\t}\n\t});\n}\n\n/** @type {Set<HTMLInputElement[]>} */\nconst pending = new Set();\n\n/**\n * @param {HTMLInputElement[]} inputs\n * @param {null | [number]} group_index\n * @param {HTMLInputElement} input\n * @param {() => unknown} get\n * @param {(value: unknown) => void} set\n * @returns {void}\n */\nexport function bind_group(inputs, group_index, input, get, set = get) {\n\tvar is_checkbox = input.getAttribute('type') === 'checkbox';\n\tvar binding_group = inputs;\n\n\t// needs to be let or related code isn't treeshaken out if it's always false\n\tlet hydration_mismatch = false;\n\n\tif (group_index !== null) {\n\t\tfor (var index of group_index) {\n\t\t\t// @ts-expect-error\n\t\t\tbinding_group = binding_group[index] ??= [];\n\t\t}\n\t}\n\n\tbinding_group.push(input);\n\n\tlisten_to_event_and_reset_event(\n\t\tinput,\n\t\t'change',\n\t\t() => {\n\t\t\t// @ts-ignore\n\t\t\tvar value = input.__value;\n\n\t\t\tif (is_checkbox) {\n\t\t\t\tvalue = get_binding_group_value(binding_group, value, input.checked);\n\t\t\t}\n\n\t\t\tset(value);\n\t\t},\n\t\t// TODO better default value handling\n\t\t() => set(is_checkbox ? [] : null)\n\t);\n\n\trender_effect(() => {\n\t\tvar value = get();\n\n\t\t// If we are hydrating and the value has since changed, then use the update value\n\t\t// from the input instead.\n\t\tif (hydrating && input.defaultChecked !== input.checked) {\n\t\t\thydration_mismatch = true;\n\t\t\treturn;\n\t\t}\n\n\t\tif (is_checkbox) {\n\t\t\tvalue = value || [];\n\t\t\t// @ts-ignore\n\t\t\tinput.checked = value.includes(input.__value);\n\t\t} else {\n\t\t\t// @ts-ignore\n\t\t\tinput.checked = is(input.__value, value);\n\t\t}\n\t});\n\n\tteardown(() => {\n\t\tvar index = binding_group.indexOf(input);\n\n\t\tif (index !== -1) {\n\t\t\tbinding_group.splice(index, 1);\n\t\t}\n\t});\n\n\tif (!pending.has(binding_group)) {\n\t\tpending.add(binding_group);\n\n\t\tqueue_micro_task(() => {\n\t\t\t// necessary to maintain binding group order in all insertion scenarios\n\t\t\tbinding_group.sort((a, b) => (a.compareDocumentPosition(b) === 4 ? -1 : 1));\n\t\t\tpending.delete(binding_group);\n\t\t});\n\t}\n\n\tqueue_micro_task(() => {\n\t\tif (hydration_mismatch) {\n\t\t\tvar value;\n\n\t\t\tif (is_checkbox) {\n\t\t\t\tvalue = get_binding_group_value(binding_group, value, input.checked);\n\t\t\t} else {\n\t\t\t\tvar hydration_input = binding_group.find((input) => input.checked);\n\t\t\t\t// @ts-ignore\n\t\t\t\tvalue = hydration_input?.__value;\n\t\t\t}\n\n\t\t\tset(value);\n\t\t}\n\t});\n}\n\n/**\n * @param {HTMLInputElement} input\n * @param {() => unknown} get\n * @param {(value: unknown) => void} set\n * @returns {void}\n */\nexport function bind_checked(input, get, set = get) {\n\tlisten_to_event_and_reset_event(input, 'change', (is_reset) => {\n\t\tvar value = is_reset ? input.defaultChecked : input.checked;\n\t\tset(value);\n\t});\n\n\tif (\n\t\t// If we are hydrating and the value has since changed,\n\t\t// then use the update value from the input instead.\n\t\t(hydrating && input.defaultChecked !== input.checked) ||\n\t\t// If defaultChecked is set, then checked == defaultChecked\n\t\tuntrack(get) == null\n\t) {\n\t\tset(input.checked);\n\t}\n\n\trender_effect(() => {\n\t\tvar value = get();\n\t\tinput.checked = Boolean(value);\n\t});\n}\n\n/**\n * @template V\n * @param {Array<HTMLInputElement>} group\n * @param {V} __value\n * @param {boolean} checked\n * @returns {V[]}\n */\nfunction get_binding_group_value(group, __value, checked) {\n\t/** @type {Set<V>} */\n\tvar value = new Set();\n\n\tfor (var i = 0; i < group.length; i += 1) {\n\t\tif (group[i].checked) {\n\t\t\t// @ts-ignore\n\t\t\tvalue.add(group[i].__value);\n\t\t}\n\t}\n\n\tif (!checked) {\n\t\tvalue.delete(__value);\n\t}\n\n\treturn Array.from(value);\n}\n\n/**\n * @param {HTMLInputElement} input\n */\nfunction is_numberlike_input(input) {\n\tvar type = input.type;\n\treturn type === 'number' || type === 'range';\n}\n\n/**\n * @param {string} value\n */\nfunction to_number(value) {\n\treturn value === '' ? null : +value;\n}\n\n/**\n * @param {HTMLInputElement} input\n * @param {() => FileList | null} get\n * @param {(value: FileList | null) => void} set\n */\nexport function bind_files(input, get, set = get) {\n\tlisten_to_event_and_reset_event(input, 'change', () => {\n\t\tset(input.files);\n\t});\n\n\tif (\n\t\t// If we are hydrating and the value has since changed,\n\t\t// then use the updated value from the input instead.\n\t\thydrating &&\n\t\tinput.files\n\t) {\n\t\tset(input.files);\n\t}\n\n\trender_effect(() => {\n\t\tinput.files = get();\n\t});\n}\n","export const ssr = false;\nexport const prerender = true;\n","import {params, globalQueryParams} from '$lib/core/config';\nimport {resolve} from '$app/paths';\nimport {getParamsFromURL, queryStringifyNoArray} from './url.js';\n\nexport function route(p: string, hash?: string) {\n\tif (!p.endsWith('/')) {\n\t\tp += '/';\n\t}\n\tconst pathToResolve = `${p}${getQueryStringToKeep(p)}${hash ? `#${hash}` : ''}`;\n\tlet path = resolve<any>(pathToResolve);\n\treturn path;\n}\n\nfunction getQueryStringToKeep(p: string): string {\n\tif (globalQueryParams && globalQueryParams.length > 0) {\n\t\tconst {params: paramFromPath} = getParamsFromURL(p);\n\t\tfor (const queryParam of globalQueryParams) {\n\t\t\tif (\n\t\t\t\ttypeof params[queryParam] != 'undefined' &&\n\t\t\t\ttypeof paramFromPath[queryParam] === 'undefined'\n\t\t\t) {\n\t\t\t\tparamFromPath[queryParam] = params[queryParam];\n\t\t\t}\n\t\t}\n\t\treturn queryStringifyNoArray(paramFromPath);\n\t} else {\n\t\treturn '';\n\t}\n}\n\nexport function url(p: string, hash?: string) {\n\treturn resolve<any>(\n\t\thash ? `${p}${hash.startsWith('#') ? hash : `#${hash}`}` : p,\n\t);\n}\n\nexport function isSameRoute(a: string, b: string): boolean {\n\treturn a === b || a === route(b);\n}\n\nexport function isParentRoute(a: string, b: string): boolean {\n\treturn a.startsWith(b) || a.startsWith(route(b));\n}\n","<script lang=\"ts\">\n\timport {dev, version} from '$app/environment';\n\timport {page} from '$app/state';\n\n\timport {\n\t\tname,\n\t\tdescription,\n\t\tthemeColor,\n\t\tcanonicalURL,\n\t\tappleStatusBarStyle,\n\t\tENSName,\n\t} from '../web-config.json';\n\timport {url} from '$lib/core/utils/web/path';\n\n\tconst host = canonicalURL.endsWith('/')\n\t\t? canonicalURL.slice(0, -1)\n\t\t: canonicalURL;\n\tconst previewImage = host + '/preview.png';\n\n\tinterface Props {\n\t\ttype?: 'website' | 'article';\n\t\ttitle?: string;\n\t\tdescription?: string;\n\t\timage?: string;\n\t\thome?: boolean;\n\t}\n\n\tlet overrides: Props = $props();\n\n\tlet isHome = $derived(overrides.home || false);\n\n\tlet metadata = $derived({\n\t\ttype: overrides.type || 'website',\n\t\ttitle: overrides.title || name,\n\t\tdescription: overrides.description || description,\n\t\timage: overrides.image || previewImage,\n\t\turl: `${host}${page.url.pathname}`,\n\t});\n</script>\n\n<svelte:head>\n\t<title>{metadata.title}</title>\n\t<meta name=\"title\" content={metadata.title} />\n\t<meta name=\"description\" content={metadata.description} />\n\t{#if isHome}\n\t\t{#if ENSName}\n\t\t\t<meta name=\"Dwebsite\" content={ENSName} />\n\t\t{/if}\n\n\t\t<!-- TODO get url -->\n\t{/if}\n\n\t<meta property=\"og:type\" content={metadata.type} />\n\t<meta property=\"og:url\" content={metadata.url} />\n\t<meta property=\"og:title\" content={metadata.title} />\n\t<meta property=\"og:description\" content={metadata.description} />\n\t<meta property=\"og:image\" content={metadata.image} />\n\t<meta property=\"twitter:card\" content=\"summary_large_image\" />\n\t<meta property=\"twitter:url\" content={metadata.url} />\n\t<meta property=\"twitter:title\" content={metadata.title} />\n\t<meta property=\"twitter:description\" content={metadata.description} />\n\t<meta property=\"twitter:image\" content={metadata.image} />\n\n\t<!-- minimal -->\n\t<!-- use SVG, if need PNG, adapt accordingly -->\n\t<!-- TODO automatise -->\n\t<link rel=\"icon\" href={url('/pwa/favicon.png')} type=\"image/png\" />\n\t<link rel=\"icon\" href={url('/pwa/favicon.ico')} sizes=\"any\" /><!-- 32×32 -->\n\t<link\n\t\trel=\"apple-touch-icon\"\n\t\thref={url('/pwa/apple-touch-icon.png')}\n\t/><!-- 180×180 -->\n\t<link rel=\"manifest\" href={url('/pwa/manifest.webmanifest')} />\n\n\t<!-- extra info -->\n\t<meta name=\"theme-color\" content={themeColor} />\n\t<meta name=\"mobile-web-app-capable\" content=\"yes\" />\n\t<meta name=\"application-name\" content={name} />\n\n\t<!-- apple -->\n\t<meta name=\"apple-mobile-web-app-capable\" content=\"yes\" />\n\t<meta\n\t\tname=\"apple-mobile-web-app-status-bar-style\"\n\t\tcontent={appleStatusBarStyle}\n\t/>\n\t<meta name=\"apple-mobile-web-app-title\" content={name} />\n\n\t<meta name=\"version\" content={version} />\n</svelte:head>\n","// Inviting \"agent is waiting for you\" chime, synthesised with the Web Audio API\n// so no audio asset needs to be bundled or fetched. The sound is deliberately\n// gentle: a soft two-note rising interval (a friendly \"ding-dong\" that invites\n// attention rather than an alarm), with a short attack and a smooth decay so it\n// never clips or sounds harsh.\n//\n// Browsers block audio until the user has interacted with the page, so the\n// AudioContext is created lazily on the first play and any failure is swallowed\n// (a beep is a nicety, never a hard requirement).\n\nlet audioCtx: AudioContext | null = null;\n\nfunction getContext(): AudioContext | null {\n\tif (typeof window === 'undefined') return null;\n\ttry {\n\t\tif (!audioCtx) {\n\t\t\tconst Ctor =\n\t\t\t\twindow.AudioContext ||\n\t\t\t\t(window as unknown as {webkitAudioContext?: typeof AudioContext})\n\t\t\t\t\t.webkitAudioContext;\n\t\t\tif (!Ctor) return null;\n\t\t\taudioCtx = new Ctor();\n\t\t}\n\t\t// A context can be left 'suspended' until a user gesture resumes it.\n\t\tif (audioCtx.state === 'suspended') {\n\t\t\t// Best-effort; if it stays suspended the play simply produces no sound.\n\t\t\taudioCtx.resume().catch(() => {});\n\t\t}\n\t\treturn audioCtx;\n\t} catch {\n\t\treturn null;\n\t}\n}\n\n// Play one note (a sine tone) with a soft attack/decay envelope.\nfunction playNote(\n\tctx: AudioContext,\n\tfrequency: number,\n\tstartTime: number,\n\tduration: number,\n\tpeakGain: number,\n): void {\n\tconst osc = ctx.createOscillator();\n\tconst gain = ctx.createGain();\n\tosc.type = 'sine';\n\tosc.frequency.value = frequency;\n\n\t// Envelope: quick-but-not-instant attack, then an exponential fade so the\n\t// tail is smooth (no click). exponentialRampToValueAtTime cannot target 0,\n\t// so we ramp to a tiny value and stop just after.\n\tconst attack = 0.015;\n\tgain.gain.setValueAtTime(0.0001, startTime);\n\tgain.gain.exponentialRampToValueAtTime(peakGain, startTime + attack);\n\tgain.gain.exponentialRampToValueAtTime(0.0001, startTime + duration);\n\n\tosc.connect(gain);\n\tgain.connect(ctx.destination);\n\tosc.start(startTime);\n\tosc.stop(startTime + duration + 0.02);\n}\n\n// Cache one Audio element per custom sound URL so we do not re-fetch/re-decode\n// on every play. Rewinding a reused element is cheaper and avoids a growing pile\n// of elements.\nconst customAudioCache = new Map<string, HTMLAudioElement>();\n\n// Play a user-supplied sound file (URL/path). Returns true if playback was\n// started (or at least attempted without throwing synchronously), false if it\n// could not be set up so the caller can fall back to the synthesized chime.\nfunction playCustomSound(url: string): boolean {\n\tif (typeof Audio === 'undefined') return false;\n\ttry {\n\t\tlet el = customAudioCache.get(url);\n\t\tif (!el) {\n\t\t\tel = new Audio(url);\n\t\t\tel.preload = 'auto';\n\t\t\tcustomAudioCache.set(url, el);\n\t\t}\n\t\ttry {\n\t\t\tel.currentTime = 0;\n\t\t} catch {\n\t\t\t// Some elements throw if not yet seekable; ignore and let play() handle it.\n\t\t}\n\t\t// play() returns a promise that rejects if blocked (autoplay policy) or the\n\t\t// source failed to load. Swallow both: a beep is a nicety.\n\t\tconst p = el.play();\n\t\tif (p && typeof p.catch === 'function') p.catch(() => {});\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\n/**\n * Play the inviting waiting-for-human chime. Safe to call from anywhere; a no-op\n * (rather than a throw) when audio is unavailable or blocked.\n *\n * When `soundUrl` is provided (a user-configured sound file), it is played\n * instead of the synthesized chime; if that cannot be set up, we fall back to\n * the built-in two-note chime (C6 then F6, a gentle rising interval that reads\n * as a friendly \"you're up\" prompt).\n */\nexport function playInvitingBeep(soundUrl?: string): void {\n\tif (soundUrl && soundUrl.trim()) {\n\t\tif (playCustomSound(soundUrl.trim())) return;\n\t\t// else fall through to the synthesized chime.\n\t}\n\tconst ctx = getContext();\n\tif (!ctx) return;\n\ttry {\n\t\tconst now = ctx.currentTime;\n\t\t// Two soft rising notes: C6 then F6 (a gentle, welcoming interval).\n\t\tplayNote(ctx, 1046.5, now, 0.16, 0.12);\n\t\tplayNote(ctx, 1396.9, now + 0.13, 0.22, 0.12);\n\t} catch {\n\t\t// Swallow: the beep is a nicety, never a hard requirement.\n\t}\n}\n","// src/svelte_internals_utils.ts\nfunction noop() {\n}\nvar identity = (x) => x;\nfunction run(fn) {\n return fn();\n}\nfunction run_all(fns) {\n fns.forEach(run);\n}\nfunction is_function(thing) {\n return typeof thing === \"function\";\n}\nfunction safe_not_equal(a, b) {\n return a != a ? b == b : a !== b || a && typeof a === \"object\" || typeof a === \"function\";\n}\nfunction subscribe(store, ...callbacks) {\n if (store == null) {\n return noop;\n }\n const unsub = store.subscribe(...callbacks);\n return unsub.unsubscribe ? () => unsub.unsubscribe() : unsub;\n}\nfunction get_store_value(store) {\n let value;\n subscribe(store, (_) => value = _)();\n return value;\n}\n\n// src/svelte_stores.ts\nvar subscriber_queue = [];\nfunction readable(value, start) {\n return {\n subscribe: writable(value, start).subscribe\n };\n}\nfunction writable(value, start = noop) {\n let stop;\n const subscribers = /* @__PURE__ */ new Set();\n function set(new_value) {\n if (safe_not_equal(value, new_value)) {\n value = new_value;\n if (stop) {\n const run_queue = !subscriber_queue.length;\n for (const subscriber of subscribers) {\n subscriber[1]();\n subscriber_queue.push(subscriber, value);\n }\n if (run_queue) {\n for (let i = 0; i < subscriber_queue.length; i += 2) {\n subscriber_queue[i][0](subscriber_queue[i + 1]);\n }\n subscriber_queue.length = 0;\n }\n }\n }\n }\n function update(fn) {\n set(fn(value));\n }\n function subscribe2(run2, invalidate = noop) {\n const subscriber = [run2, invalidate];\n subscribers.add(subscriber);\n if (subscribers.size === 1) {\n stop = start(set) || noop;\n }\n run2(value);\n return () => {\n subscribers.delete(subscriber);\n if (subscribers.size === 0) {\n stop();\n stop = null;\n }\n };\n }\n return { set, update, subscribe: subscribe2 };\n}\nfunction derived(stores, fn, initial_value) {\n const single = !Array.isArray(stores);\n const stores_array = single ? [stores] : stores;\n const auto = fn.length < 2;\n return readable(initial_value, (set) => {\n let inited = false;\n const values = [];\n let pending = 0;\n let cleanup = noop;\n const sync = () => {\n if (pending) {\n return;\n }\n cleanup();\n const result = fn(single ? values[0] : values, set);\n if (auto) {\n set(result);\n } else {\n cleanup = is_function(result) ? result : noop;\n }\n };\n const unsubscribers = stores_array.map(\n (store, i) => subscribe(\n store,\n (value) => {\n values[i] = value;\n pending &= ~(1 << i);\n if (inited) {\n sync();\n }\n },\n () => {\n pending |= 1 << i;\n }\n )\n );\n inited = true;\n sync();\n return function stop() {\n run_all(unsubscribers);\n cleanup();\n };\n });\n}\nexport {\n derived,\n get_store_value as get,\n identity,\n noop,\n readable,\n writable\n};\n","import { writable, get } from \"sveltore\";\nconst defaultState = {\n connected: false,\n connecting: false,\n creatingSession: false,\n loadingSession: false,\n resyncing: false,\n agentPending: false,\n error: null,\n session: null,\n sessionId: null,\n isStreaming: false,\n messages: [],\n clientId: null,\n conflict: null,\n isInterrupted: false,\n notice: null,\n sudoPrompt: null,\n sessionError: null,\n readOnly: false,\n activeSessionFile: null,\n activeCwd: null,\n activeModel: null,\n hideThinking: false,\n hideTools: false,\n historyTotalCount: 0,\n historyOffset: 0,\n loadingMoreHistory: false,\n contextUsage: null,\n};\nexport class WhereverClient {\n ws = null;\n config;\n stateStore;\n reconnectTimer = null;\n agentEndTimeout = null;\n // Watchdog for an in-flight session_load. We set loadingSession/resyncing the\n // moment a load is requested and clear them when message_history (or an\n // error/conflict/disconnect) arrives. If none of those ever comes back (a lost\n // reply, a server that answered for a different session, or any unforeseen\n // edge), the \"Loading session...\" / \"Reconnecting...\" affordance would hang\n // forever. This timer guarantees the load state always resolves: on expiry we\n // clear the flags and surface a recoverable error instead of an endless spin.\n loadWatchdog = null;\n static LOAD_WATCHDOG_MS = 12_000;\n // Watchdog for an in-flight session_new. Symmetrical to loadWatchdog: creating\n // a session sets creatingSession=true and shows a BLOCKING full-screen overlay,\n // and the only things that clear it are session_created/session_error/\n // session_conflict/session_interrupted (or a socket close). If none of those\n // ever arrives (a slow git init / remote-repo creation, an error thrown before\n // the reply is sent, or a half-open socket the liveness watchdog has not yet\n // reaped), the overlay spins forever and the only recovery is a reload. This\n // timer guarantees creatingSession always resolves. It is longer than the load\n // watchdog because creating can legitimately take a while (git init + creating\n // a remote GitHub repo over the network).\n createWatchdog = null;\n static CREATE_WATCHDOG_MS = 25_000;\n reconnectAttempts = 0;\n reconnectDelay = 2000;\n maxReconnectDelay = 15000;\n // Whether the socket has EVER opened successfully since construction. Repeated\n // closes with zero successful opens almost always mean a rejected handshake\n // (bad/missing token, wrong host/port, or wrong ws-vs-wss scheme) rather than\n // a transient network drop. A browser WebSocket cannot read the HTTP 401 body\n // (it just sees close code 1006), so we infer auth/config failure from this\n // pattern and surface an actionable error instead of looping silently.\n hasEverConnected = false;\n static HANDSHAKE_FAIL_HINT_AFTER = 2;\n // Liveness watchdog: a half-open TCP socket fires neither 'close' nor 'error',\n // so the existing reconnect machinery never triggers and the agent hangs\n // forever (see work/observations/ws-half-open-connection-hangs-agent-no-heartbeat.md).\n // We record the time of the last inbound frame and, if the socket goes silent\n // for longer than STALE_SOCKET_MS, proactively tear it down and reconnect.\n // A periodic app-level {type:'ping'} keeps a healthy connection refreshed even\n // during long, token-less model turns.\n livenessTimer = null;\n heartbeatTimer = null;\n lastInboundAt = 0;\n // > the server heartbeat (when present) and any normal token-less gap, so a\n // healthy connection is never falsely reaped; short enough to self-heal fast.\n static STALE_SOCKET_MS = 60_000;\n // While a turn is streaming, the keepalive pong should keep traffic flowing, so\n // a shorter deadline surfaces a stalled transport (vs a merely slow model)\n // faster. Still > one HEARTBEAT_MS so a single healthy pong keeps it fresh.\n static TURN_STALL_MS = 45_000;\n // Send a keepalive well under STALE_SOCKET_MS so the pong refreshes liveness.\n static HEARTBEAT_MS = 25_000;\n isInitialConnect = true;\n // When set, the next successful (re)connection should rejoin the previously\n // active session instead of starting blank. Used by resume() so a backgrounded\n // tab returns to its cached conversation and resyncs history in place.\n resumeSessionFile = null;\n resumeCwd;\n resumeModel;\n listeners = new Set();\n pendingUploads = new Map();\n // Per-message confirmation watchdogs. A user message committed optimistically\n // is only proven delivered when the server echoes it back; if no echo lands\n // within CONFIRM_MS the watchdog flips it to delivery:'failed' so the UI can\n // offer a retry instead of pretending it was sent (the half-open-socket loss).\n confirmTimers = new Map();\n static CONFIRM_MS = 12_000;\n static PENDING_PREFIX = 'wherever-pending:';\n constructor(config) {\n this.config = {\n secure: true,\n ...config\n };\n this.stateStore = writable({\n ...defaultState,\n hideThinking: !!this.config.hideThinking,\n hideTools: !!this.config.hideTools,\n });\n }\n connect(newConfig, preserveState = false) {\n if (newConfig) {\n this.config = {\n ...this.config,\n ...newConfig\n };\n }\n this.disconnect(false);\n // preserveState keeps the cached session/messages in the store across a\n // reconnect (resume path), so the previous conversation stays visible while\n // we reconnect and resync. The default (fresh connect) clears to a blank\n // store as before.\n this.stateStore.update(s => preserveState\n ? { ...s, connecting: true, error: null }\n : {\n ...defaultState,\n connecting: true,\n hideThinking: !!this.config.hideThinking,\n hideTools: !!this.config.hideTools,\n });\n const protocol = this.config.secure ? \"wss\" : \"ws\";\n const host = this.config.host.startsWith('http')\n ? this.config.host.replace(/^https?:\\/\\//, '')\n : this.config.host;\n const tokenQuery = this.config.token ? `?token=${encodeURIComponent(this.config.token)}` : \"\";\n const wsUrl = `${protocol}://${host}:${this.config.port}/ws${tokenQuery}`;\n const WebSocketImpl = this.config.WebSocketCtor || (typeof globalThis !== 'undefined' ? globalThis.WebSocket : null);\n if (!WebSocketImpl) {\n this.stateStore.update(s => ({\n ...s,\n connecting: false,\n error: \"No WebSocket implementation found. Please pass custom WebSocketCtor.\"\n }));\n return;\n }\n try {\n const wsOptions = this.config.secure && this.config.WebSocketCtor ? { rejectUnauthorized: false } : undefined;\n this.ws = wsOptions ? new WebSocketImpl(wsUrl, wsOptions) : new WebSocketImpl(wsUrl);\n }\n catch (err) {\n this.stateStore.update(s => ({\n ...s,\n connecting: false,\n error: `Failed to connect: ${err}`\n }));\n this.scheduleReconnect();\n return;\n }\n const currentWs = this.ws;\n const onOpen = () => {\n if (this.ws !== currentWs)\n return;\n if (!this.isInitialConnect) {\n console.info('[wherever] reconnected to relay');\n }\n this.hasEverConnected = true;\n this.reconnectAttempts = 0;\n this.reconnectDelay = 2000;\n this.isInitialConnect = false;\n this.startLivenessWatchdog();\n this.stateStore.update(s => ({\n ...s,\n connected: true,\n connecting: false,\n error: null\n }));\n // Resume path: rejoin the previously-active session so its history is\n // resynced in place. resyncing stays true until message_history (or an\n // error/conflict) arrives, keeping the \"reconnecting\" affordance up and\n // input blocked without dropping the cached messages.\n //\n // Re-attachment is REQUIRED on every reconnect that still holds a session,\n // not just the suspend/resume path. The server is stateless per socket:\n // each new connection starts attached to NO session (the old socket's\n // close removed this client from the pool). If we do not re-issue\n // session_load here, the relay is connected but the session stream is\n // dead, so the UI shows a frozen conversation (a stale tool call as the\n // last message, Abort disabled) while the agent keeps running headless.\n // Two sources for what to rejoin:\n // 1. resumeSessionFile -> explicit suspend()/resume() (tab background).\n // 2. the store's activeSessionFile -> an UNSOLICITED drop (network\n // blip, tab switch, laptop sleep, half-open reap) where suspend()\n // never ran. This is the case that used to silently freeze.\n const cached = get(this.stateStore);\n const rejoinFile = this.resumeSessionFile ?? cached.activeSessionFile;\n const rejoinCwd = this.resumeSessionFile != null\n ? this.resumeCwd\n : (cached.activeCwd ?? undefined);\n const rejoinModel = this.resumeSessionFile != null\n ? this.resumeModel\n : (cached.activeModel ?? undefined);\n this.resumeSessionFile = null;\n this.resumeCwd = undefined;\n this.resumeModel = undefined;\n if (rejoinFile) {\n // Keep the cached conversation on screen but mark it resyncing so the\n // \"Reconnecting and syncing session...\" banner shows and sending is\n // blocked until fresh history lands. resyncing is cleared by\n // message_history (or an error/conflict) via the reducer.\n this.stateStore.update(s => (s.resyncing ? s : { ...s, resyncing: true }));\n this.send({ type: 'session_load', sessionFile: rejoinFile, cwd: rejoinCwd, model: rejoinModel });\n this.armLoadWatchdog();\n }\n else {\n this.stateStore.update(s => (s.resyncing ? { ...s, resyncing: false } : s));\n }\n };\n const onMessage = (event) => {\n if (this.ws !== currentWs)\n return;\n // Any inbound frame (including the pong reply to our keepalive) proves the\n // socket is alive and resets the stale-socket watchdog.\n this.lastInboundAt = Date.now();\n try {\n const rawData = typeof event.data === 'string' ? event.data : event.data.toString();\n const msg = JSON.parse(rawData);\n this.handleMessage(msg);\n }\n catch (err) {\n console.error(\"Failed to parse WebSocket message:\", err);\n }\n };\n const onClose = () => {\n if (this.ws !== currentWs)\n return;\n this.stopLivenessWatchdog();\n this.clearLoadWatchdog();\n this.ws = null;\n this.stateStore.update(s => ({\n ...s,\n connected: false,\n connecting: false,\n // Never leave a session-load spinner stuck if the socket drops mid-load.\n loadingSession: false,\n creatingSession: false,\n // If we still hold an active session, the drop is an unsolicited one on a\n // live conversation: mark it resyncing NOW (during the reconnect backoff)\n // so the user immediately sees \"Reconnecting...\" instead of a frozen view\n // with a stale tool call and a disabled Abort. onOpen re-attaches and the\n // reducer clears resyncing when fresh history lands.\n resyncing: s.activeSessionFile ? true : s.resyncing,\n }));\n this.scheduleReconnect();\n };\n const onError = (err) => {\n if (this.ws !== currentWs)\n return;\n this.stateStore.update(s => ({\n ...s,\n error: s.error || 'Connection error occurred'\n }));\n };\n if (typeof currentWs.addEventListener === 'function') {\n currentWs.addEventListener('open', onOpen);\n currentWs.addEventListener('message', onMessage);\n currentWs.addEventListener('close', onClose);\n currentWs.addEventListener('error', onError);\n }\n else if (typeof currentWs.on === 'function') {\n currentWs.on('open', onOpen);\n currentWs.on('message', (data) => onMessage({ data }));\n currentWs.on('close', onClose);\n currentWs.on('error', onError);\n }\n }\n disconnect(resetState = true) {\n if (this.reconnectTimer) {\n clearTimeout(this.reconnectTimer);\n this.reconnectTimer = null;\n }\n // A pending agent_end clear timer belongs to the socket we are tearing down.\n // Leaving it armed lets it fire against a freshly (re)connected session's\n // state, so cancel it here.\n if (this.agentEndTimeout) {\n clearTimeout(this.agentEndTimeout);\n this.agentEndTimeout = null;\n }\n this.stopLivenessWatchdog();\n // The load/create affordances belong to the socket we are tearing down. If\n // left armed they would later fire against a fresh (re)connected session's\n // state, so cancel them here.\n this.clearLoadWatchdog();\n this.clearCreateWatchdog();\n if (this.ws) {\n const dyingWs = this.ws;\n try {\n if (typeof dyingWs.removeAllListeners === 'function') {\n dyingWs.removeAllListeners();\n }\n // Closing a socket that is still CONNECTING (e.g. the wherever server is\n // not running so the handshake never completed) makes `ws` abort the\n // handshake and emit an 'error' asynchronously on the next tick. With\n // every listener removed, that 'error' would be an unhandled\n // EventEmitter error and crash the whole process as an\n // uncaughtException. Keep a no-op error sink on the socket we are\n // tearing down so the late error is swallowed, in both the node (`ws`)\n // and browser (`WebSocket`) environments.\n const swallow = () => { };\n if (typeof dyingWs.on === 'function') {\n dyingWs.on('error', swallow);\n }\n else if (typeof dyingWs.addEventListener === 'function') {\n dyingWs.addEventListener('error', swallow);\n }\n else {\n dyingWs.onerror = swallow;\n }\n dyingWs.close();\n }\n catch (err) { }\n this.ws = null;\n }\n if (resetState) {\n // Full teardown wipes the store, so no unconfirmed message survives in it;\n // clear their watchdogs to avoid firing against a fresh store. The\n // persisted-pending localStorage entries intentionally REMAIN so a later\n // load can still recover them.\n for (const t of this.confirmTimers.values())\n clearTimeout(t);\n this.confirmTimers.clear();\n this.stateStore.set({\n ...defaultState,\n hideThinking: !!this.config.hideThinking,\n hideTools: !!this.config.hideTools,\n });\n }\n else {\n // Preserve-cache teardown (suspend / resume's pre-connect close). The\n // socket is gone, so the store MUST reflect disconnected: leaving a stale\n // connected:true made resume() early-return (its `if (connected) return`\n // guard), so the real reconnect fell through to a plain connect() that did\n // NOT preserve the session, which is what flashed the search / new-session\n // empty-state on tab return. Clearing connected here (without wiping the\n // cached session/messages) lets resume() actually rejoin in place, and\n // never leaves the blocking load/create overlays up on a dead socket.\n this.stateStore.update(s => ({\n ...s,\n connected: false,\n connecting: false,\n loadingSession: false,\n creatingSession: false,\n }));\n }\n }\n // Suspend the connection without tearing down the cached session state. Used\n // when the tab is backgrounded: closing the WebSocket improves bfcache\n // eligibility, but we keep messages/sessionId so returning is a cheap resync\n // rather than a full reload. Records the active session so resume() can rejoin\n // it. Does NOT schedule a reconnect (disconnect(false) clears that timer).\n suspend() {\n const s = get(this.stateStore);\n if (s.activeSessionFile) {\n this.resumeSessionFile = s.activeSessionFile;\n this.resumeCwd = s.activeCwd ?? undefined;\n this.resumeModel = s.activeModel ?? undefined;\n }\n // The socket producing the live stream is going away. If we carry a stale\n // isStreaming:true across the suspend/resume gap, the composer will wrongly\n // queue the next message as if the agent were still busy (and the queue\n // never drains because no agent_end ever arrives on the dead socket). The\n // authoritative value is re-established by session_created on rejoin.\n if (s.isStreaming) {\n this.stateStore.update(st => ({ ...st, isStreaming: false }));\n }\n this.disconnect(false);\n }\n // Resume after suspend(): reconnect while preserving the cached store, mark\n // the session as resyncing, and let onOpen rejoin the recorded session. If\n // there is no active session to rejoin, this is just a state-preserving\n // reconnect.\n resume() {\n const s = get(this.stateStore);\n if (s.connected || s.connecting)\n return;\n // Rejoin whatever session we still hold: an explicit suspend() record OR the\n // cached active session from an unsolicited drop. In BOTH cases onOpen\n // re-issues session_load, so mark resyncing here to show the affordance and\n // block sending until fresh history lands.\n if (this.resumeSessionFile || s.activeSessionFile) {\n this.stateStore.update(st => ({ ...st, resyncing: true }));\n // Arm here too: if the socket never opens, onOpen never runs and the\n // resync affordance would otherwise hang. onClose also clears it, but the\n // watchdog covers the half-open / never-opens case.\n this.armLoadWatchdog();\n }\n this.connect(undefined, true);\n }\n // True when suspend() recorded an active session to rejoin on the next resume.\n // Callers use this to take the resume (preserve-cache, rejoin-in-place) path\n // only when there is actually a suspended session; otherwise a plain connect()\n // is correct and avoids racing/latching the hash auto-join on a fresh load.\n hasSuspendedSession() {\n return this.resumeSessionFile !== null;\n }\n // True when the store still holds an active session to rejoin in place -- from\n // an explicit suspend() OR an unsolicited drop that left activeSessionFile set.\n // Callers use this to prefer the preserve-cache resume() path over a fresh,\n // session-wiping connect() when returning to a still-live conversation.\n hasActiveSession() {\n return this.resumeSessionFile !== null || get(this.stateStore).activeSessionFile !== null;\n }\n // Start (or restart) the stale-socket watchdog + keepalive for the current\n // socket. A half-open connection emits no 'close'/'error', so without this the\n // existing reconnect logic would never fire and the agent would hang forever.\n startLivenessWatchdog() {\n this.stopLivenessWatchdog();\n this.lastInboundAt = Date.now();\n const sendBeat = () => {\n // Keep a healthy connection warm so the pong refreshes lastInboundAt even\n // during long, token-less model turns.\n try {\n this.ping();\n }\n catch { }\n };\n if (typeof setInterval === 'function') {\n this.heartbeatTimer = setInterval(sendBeat, WhereverClient.HEARTBEAT_MS);\n if (this.heartbeatTimer && typeof this.heartbeatTimer.unref === 'function') {\n this.heartbeatTimer.unref();\n }\n }\n const checkLiveness = () => {\n if (!this.ws)\n return;\n const silentFor = Date.now() - this.lastInboundAt;\n const streaming = get(this.stateStore).isStreaming;\n // Per-turn stall timeout: while a turn is in flight the heartbeat pong (and,\n // normally, tokens) should keep traffic flowing, so a shorter deadline\n // distinguishes \"model is slow\" (heartbeat still arriving -> not stale) from\n // \"transport is dead\" (heartbeat stopped). When idle, fall back to the\n // generic stale-socket threshold.\n const threshold = streaming\n ? WhereverClient.TURN_STALL_MS\n : WhereverClient.STALE_SOCKET_MS;\n if (silentFor < threshold)\n return;\n // The socket has been silent past the threshold: treat it as dead. Tearing\n // it down forcibly is what makes a half-open connection recover, since the\n // OS never produced a FIN/RST to trigger the normal close path.\n console.warn(`[wherever] relay connection stale: no inbound frame for ${silentFor}ms ` +\n `(threshold ${threshold}ms, ${streaming ? 'mid-turn' : 'idle'}); ` +\n `tearing down dead socket and reconnecting`);\n this.stopLivenessWatchdog();\n const deadWs = this.ws;\n this.ws = null;\n try {\n if (typeof deadWs.terminate === 'function') {\n deadWs.terminate();\n }\n else if (typeof deadWs.close === 'function') {\n deadWs.close();\n }\n }\n catch { }\n this.stateStore.update(s => ({\n ...s,\n connected: false,\n connecting: false,\n loadingSession: false,\n creatingSession: false,\n // If a turn was in flight, surface it as a recoverable error so the UI\n // shows \"the transport stalled\" rather than silently parking mid-stream.\n sessionError: streaming\n ? 'Connection to relay stalled mid-turn; reconnecting...'\n : s.sessionError,\n isStreaming: false,\n }));\n this.scheduleReconnect();\n };\n if (typeof setInterval === 'function') {\n this.livenessTimer = setInterval(checkLiveness, WhereverClient.HEARTBEAT_MS);\n if (this.livenessTimer && typeof this.livenessTimer.unref === 'function') {\n this.livenessTimer.unref();\n }\n }\n }\n stopLivenessWatchdog() {\n if (this.heartbeatTimer) {\n clearInterval(this.heartbeatTimer);\n this.heartbeatTimer = null;\n }\n if (this.livenessTimer) {\n clearInterval(this.livenessTimer);\n this.livenessTimer = null;\n }\n }\n // Arm (or re-arm) the load watchdog. Called whenever a session_load is issued\n // so an unresolved load can never strand the loading UI. Idempotent: a fresh\n // load resets the deadline.\n armLoadWatchdog() {\n this.clearLoadWatchdog();\n this.loadWatchdog = setTimeout(() => {\n this.loadWatchdog = null;\n const s = get(this.stateStore);\n if (!s.loadingSession && !s.resyncing)\n return;\n console.warn('[wherever] session load timed out; clearing loading state');\n this.stateStore.update(st => ({\n ...st,\n loadingSession: false,\n resyncing: false,\n sessionError: st.sessionError ||\n 'Loading the session timed out. Please retry from the sidebar or reload.',\n }));\n }, WhereverClient.LOAD_WATCHDOG_MS);\n }\n // Clear the load watchdog. Called at every point the load resolves\n // (message_history, session_error, session_conflict, disconnect, leave).\n clearLoadWatchdog() {\n if (this.loadWatchdog) {\n clearTimeout(this.loadWatchdog);\n this.loadWatchdog = null;\n }\n }\n // Arm (or re-arm) the create watchdog. Called when session_new is issued so an\n // unanswered create can never strand the blocking \"Creating session...\"\n // overlay. On expiry we clear creatingSession and surface a recoverable error\n // instead of an endless spin that only a reload escapes.\n armCreateWatchdog() {\n this.clearCreateWatchdog();\n this.createWatchdog = setTimeout(() => {\n this.createWatchdog = null;\n const s = get(this.stateStore);\n if (!s.creatingSession)\n return;\n console.warn('[wherever] session create timed out; clearing creating state');\n this.stateStore.update(st => ({\n ...st,\n creatingSession: false,\n sessionError: st.sessionError ||\n 'Creating the session timed out. It may still be starting on the server; check the sidebar or reload.',\n }));\n }, WhereverClient.CREATE_WATCHDOG_MS);\n }\n // Clear the create watchdog. Called at every point a create resolves\n // (session_created, session_error, session_conflict, session_interrupted,\n // disconnect, leave).\n clearCreateWatchdog() {\n if (this.createWatchdog) {\n clearTimeout(this.createWatchdog);\n this.createWatchdog = null;\n }\n }\n scheduleReconnect() {\n if (this.reconnectTimer)\n return;\n this.reconnectTimer = setTimeout(() => {\n this.reconnectTimer = null;\n this.reconnectDelay = Math.min(this.reconnectDelay * 1.5, this.maxReconnectDelay);\n console.info(`[wherever] reconnecting to relay (attempt ${++this.reconnectAttempts})`);\n // If we have retried a few times and NEVER once opened the socket, this is\n // almost certainly a rejected handshake, not a flaky network. Surface a\n // concrete, actionable error (the server rejects a bad/missing token with\n // HTTP 401 during the WS upgrade, which the browser reports only as an\n // opaque 1006 close). Keep retrying, but stop looking like a mere network\n // hiccup.\n if (!this.hasEverConnected &&\n this.reconnectAttempts >= WhereverClient.HANDSHAKE_FAIL_HINT_AFTER) {\n const scheme = this.config.secure ? 'wss' : 'ws';\n this.stateStore.update(s => ({\n ...s,\n error: 'Cannot connect to the wherever server: the connection is being rejected. ' +\n 'This usually means a missing or wrong token, or a wrong host/port/scheme ' +\n `(currently ${scheme}://${this.config.host}:${this.config.port}). ` +\n 'Check the auth token and connection settings.',\n }));\n }\n // If we still hold an active session, PRESERVE the cached store across the\n // reconnect. A default connect() resets to a blank store, which wiped\n // activeSessionFile BEFORE onOpen could re-attach to it -- that is what\n // silently detached the frontend from a still-running session (frozen\n // conversation, no re-follow, not even a \"connecting\"/\"loading\" hint).\n // Preserving the store keeps the conversation on screen and lets onOpen\n // re-issue session_load from activeSessionFile.\n const preserve = !!get(this.stateStore).activeSessionFile;\n this.stateStore.update(s => ({\n ...s,\n connecting: true,\n error: 'Reconnecting...',\n }));\n this.connect(undefined, preserve);\n }, this.reconnectDelay);\n }\n handleMessage(msg) {\n for (const listener of this.listeners) {\n try {\n listener(msg);\n }\n catch (err) {\n console.error(\"Error in message listener:\", err);\n }\n }\n // Any message that resolves an in-flight session_load disarms the watchdog.\n // session_created arrives just before message_history; message_history is the\n // real completion, but an error/conflict/destroy/interrupt also resolves it.\n switch (msg.type) {\n case 'message_history':\n case 'session_error':\n case 'session_conflict':\n case 'session_destroyed':\n case 'session_interrupted':\n this.clearLoadWatchdog();\n break;\n }\n // Any message that resolves an in-flight session_new disarms the create\n // watchdog. session_created is the success path; error/conflict/interrupt end\n // it too.\n switch (msg.type) {\n case 'session_created':\n case 'session_error':\n case 'session_conflict':\n case 'session_interrupted':\n this.clearCreateWatchdog();\n break;\n }\n switch (msg.type) {\n case 'connected':\n this.stateStore.update((s) => ({\n ...s,\n connected: true,\n connecting: false,\n clientId: msg.clientId,\n error: null,\n }));\n break;\n case 'file_uploaded': {\n const pending = this.pendingUploads.get(msg.uploadId);\n if (pending) {\n pending.resolve({ savedPath: msg.savedPath, filename: msg.filename });\n this.pendingUploads.delete(msg.uploadId);\n }\n break;\n }\n case 'file_upload_error': {\n const pending = this.pendingUploads.get(msg.uploadId);\n if (pending) {\n pending.reject(new Error(msg.error));\n this.pendingUploads.delete(msg.uploadId);\n }\n break;\n }\n case 'agent_start':\n if (this.agentEndTimeout) {\n clearTimeout(this.agentEndTimeout);\n this.agentEndTimeout = null;\n }\n this.stateStore.update((s) => ({ ...s, isStreaming: true }));\n break;\n case 'thinking_update':\n this.stateStore.update((s) => {\n let lastThinking = [...s.messages]\n .reverse()\n .find((m) => m.role === 'thinking' && m.isStreaming);\n if (!lastThinking) {\n const newMsg = {\n id: this.generateId(),\n role: 'thinking',\n content: msg.delta,\n timestamp: Date.now(),\n isStreaming: true,\n };\n return { ...s, messages: [...s.messages, newMsg] };\n }\n return {\n ...s,\n messages: s.messages.map((m) => m.id === lastThinking.id\n ? { ...m, content: m.content + msg.delta, isStreaming: true }\n : m),\n };\n });\n break;\n case 'message_update':\n this.stateStore.update((s) => {\n let lastAssistant = [...s.messages]\n .reverse()\n .find((m) => m.role === 'assistant' && m.isStreaming);\n if (!lastAssistant) {\n const newMsg = {\n id: this.generateId(),\n role: 'assistant',\n content: msg.delta,\n timestamp: Date.now(),\n isStreaming: true,\n };\n return { ...s, messages: [...s.messages, newMsg] };\n }\n return {\n ...s,\n messages: s.messages.map((m) => m.id === lastAssistant.id\n ? { ...m, content: m.content + msg.delta, isStreaming: true }\n : m),\n };\n });\n break;\n case 'message_end':\n this.stateStore.update((s) => {\n let newMessages = s.messages;\n const lastThinking = [...newMessages]\n .reverse()\n .find((m) => m.role === 'thinking' && m.isStreaming);\n if (lastThinking) {\n newMessages = newMessages.map((m) => m.id === lastThinking.id ? { ...m, isStreaming: false } : m);\n }\n const lastAssistant = [...newMessages]\n .reverse()\n .find((m) => m.role === 'assistant' && m.isStreaming);\n if (lastAssistant) {\n newMessages = newMessages.map((m) => m.id === lastAssistant.id\n ? {\n ...m,\n content: msg.content || m.content,\n isStreaming: false,\n }\n : m);\n }\n else if (msg.content) {\n // The server echoes the user's own message back once pi has appended\n // it: that is the delivery CONFIRMATION for an optimistic (unconfirmed)\n // echo. Confirm the matching pending message (flip delivery off, clear\n // its watchdog, update the persisted-pending store) instead of adding\n // a duplicate. If there was no pending match (e.g. another client sent\n // it), fall back to the existing content-dedupe.\n if (msg.role === 'user') {\n const confirmedPending = this.confirmDeliveredByContent(msg.content);\n if (confirmedPending) {\n // Re-read: confirmDeliveredByContent already updated the store.\n return get(this.stateStore);\n }\n }\n const lastUserMessage = [...newMessages]\n .reverse()\n .find((m) => m.role === 'user');\n const isDuplicateUserMsg = msg.role === 'user' &&\n lastUserMessage &&\n lastUserMessage.content === msg.content;\n if (!isDuplicateUserMsg) {\n newMessages = [\n ...newMessages,\n {\n id: this.generateId(),\n role: msg.role || 'assistant',\n content: msg.content,\n timestamp: Date.now(),\n isStreaming: false,\n },\n ];\n }\n }\n return { ...s, messages: newMessages };\n });\n break;\n case 'agent_end':\n if (this.agentEndTimeout) {\n clearTimeout(this.agentEndTimeout);\n this.agentEndTimeout = null;\n }\n this.agentEndTimeout = setTimeout(() => {\n const now = Date.now();\n this.stateStore.update((s) => ({\n ...s,\n isStreaming: false,\n messages: s.messages.map((m) => m.isStreaming\n ? {\n ...m,\n isStreaming: false,\n // A tool still streaming when the turn ends never got a\n // tool_end (e.g. the turn was aborted, or its result frame\n // was lost): its outcome is unknown. Mark it interrupted\n // (neutral), never let it fall through to a green success\n // tick, which would falsely claim it succeeded. Assistant/\n // thinking messages just stop streaming.\n ...(m.role === 'tool' ? { interrupted: true } : {}),\n // Freeze a still-running tool's duration if it never got a\n // tool_end (turn ended between steps), so \"Elapsed\" stops\n // ticking and shows the final \"Took\".\n endedAt: m.role === 'tool' && m.endedAt === undefined\n ? now\n : m.endedAt,\n }\n : m),\n }));\n this.agentEndTimeout = null;\n }, 300);\n break;\n case 'tool_start':\n if (this.agentEndTimeout) {\n clearTimeout(this.agentEndTimeout);\n this.agentEndTimeout = null;\n }\n const toolArgs = msg.args\n ? Object.entries(msg.args)\n .filter(([k, v]) => v !== undefined && v !== '')\n .map(([k, v]) => `${k}=${JSON.stringify(v)}`)\n .join(' ')\n : '';\n this.stateStore.update((s) => {\n const finalizedMessages = s.messages.map((m) => m.isStreaming && (m.role === 'assistant' || m.role === 'thinking')\n ? { ...m, isStreaming: false }\n : m);\n const startedAt = Date.now();\n const newMsg = {\n id: this.generateId(),\n role: 'tool',\n content: toolArgs\n ? `$ ${msg.toolName} ${toolArgs}`\n : `$ ${msg.toolName}`,\n timestamp: startedAt,\n isStreaming: true,\n toolName: msg.toolName,\n toolArgs: toolArgs,\n toolOutput: '',\n startedAt,\n ...(msg.forceCommand ? { forceCommand: true } : {}),\n };\n return {\n ...s,\n messages: [...finalizedMessages, newMsg],\n };\n });\n break;\n case 'tool_update': {\n this.stateStore.update((s) => {\n const toolMsg = [...s.messages]\n .reverse()\n .find((m) => m.role === 'tool' &&\n m.toolName === msg.toolName &&\n m.isStreaming);\n if (toolMsg) {\n return {\n ...s,\n messages: s.messages.map((m) => m.id === toolMsg.id\n ? {\n ...m,\n content: m.content.includes('\\n')\n ? m.content + msg.delta\n : `${m.content}\\n${msg.delta}`,\n toolOutput: `${m.toolOutput}${msg.delta}`,\n }\n : m),\n };\n }\n return s;\n });\n break;\n }\n case 'tool_end': {\n const result = msg.result ? `${msg.result}` : '';\n // An abort (e.g. the web \"abort\" button killed the tool mid-run) surfaces\n // as isError with a trailing \"...aborted\" status. That is not a tool\n // FAILURE, so render it as the neutral interrupted state, not a red\n // error.\n const aborted = !!msg.isError && this.isAbortedToolResult(result);\n const effectiveIsError = !!msg.isError && !aborted;\n const toolImages = Array.isArray(msg.images) && msg.images.length > 0\n ? msg.images\n : undefined;\n this.stateStore.update((s) => {\n // Claim the OLDEST still-streaming tool of this name (FIFO). Parallel\n // tool calls share a name, so matching the LAST one (or any already\n // finalized one) would let two tool_end frames land on the SAME\n // message and leave the other tool stuck streaming: it would then be\n // finalized by the 'aborted'/agent_end sweep with no result and render\n // as a bogus green success. Preferring a streaming message means each\n // tool_end settles a distinct in-flight call. Fall back to the newest\n // non-error tool of this name only if none are still streaming.\n const toolMsg = s.messages.find((m) => m.role === 'tool' &&\n m.toolName === msg.toolName &&\n m.isStreaming) ??\n [...s.messages]\n .reverse()\n .find((m) => m.role === 'tool' &&\n m.toolName === msg.toolName &&\n !m.content.startsWith('Tool error:'));\n const endedAt = Date.now();\n if (toolMsg) {\n const errorPrefix = effectiveIsError ? 'Error: ' : '';\n return {\n ...s,\n messages: s.messages.map((m) => m.id === toolMsg.id\n ? {\n ...m,\n content: `${errorPrefix}${m.content}\\n${result}`,\n isStreaming: false,\n isError: effectiveIsError,\n interrupted: aborted,\n toolOutput: result,\n ...(toolImages ? { images: toolImages } : {}),\n endedAt,\n }\n : m),\n };\n }\n else {\n const content = effectiveIsError\n ? `Tool error: ${msg.toolName}\\n${result}`\n : `${msg.toolName}\\n${result}`;\n const message = {\n id: this.generateId(),\n role: 'tool',\n content,\n timestamp: endedAt,\n isStreaming: false,\n toolName: msg.toolName,\n toolArgs: '',\n toolOutput: result,\n ...(toolImages ? { images: toolImages } : {}),\n isError: effectiveIsError,\n interrupted: aborted,\n endedAt,\n };\n return {\n ...s,\n messages: [...s.messages, message],\n };\n }\n });\n break;\n }\n case 'aborted': {\n const abortedAt = Date.now();\n this.stateStore.update((s) => ({\n ...s,\n isStreaming: false,\n messages: s.messages.map((m) => m.isStreaming\n ? {\n ...m,\n isStreaming: false,\n // A tool still streaming when the turn is aborted was killed\n // with no result: mark it interrupted (neutral), never leave\n // it to fall through to a green success tick. Assistant/\n // thinking messages just stop streaming.\n ...(m.role === 'tool' ? { interrupted: true } : {}),\n endedAt: m.role === 'tool' && m.endedAt === undefined\n ? abortedAt\n : m.endedAt,\n }\n : m),\n }));\n break;\n }\n case 'session_created':\n this.stateStore.update((s) => ({\n ...s,\n session: msg.sessionFile,\n sessionId: msg.sessionId,\n activeSessionFile: msg.sessionFile,\n activeCwd: msg.cwd,\n activeModel: msg.model,\n isStreaming: msg.isStreaming ?? false,\n creatingSession: false,\n // The server forces read-only for sessions in a configured\n // sessions.readOnly folder (observe-only fleet view).\n readOnly: msg.readOnly ?? false,\n // pending -> the history is painted now but the live agent is still\n // building; keep the composer disabled (agentPending) until\n // session_ready. A non-pending create (new session, warm reload) is\n // immediately sendable.\n agentPending: msg.pending === true,\n // Initial context-usage snapshot for the new session (null if unknown;\n // live updates arrive via 'context_usage').\n contextUsage: msg.contextUsage ?? null,\n }));\n break;\n case 'session_ready':\n // The live agent finished building for a previously-pending load. Enable\n // the composer and refresh the now-authoritative model/streaming/usage.\n this.stateStore.update((s) => {\n // Ignore a stale ready for a session we already switched away from.\n if (msg.sessionFile && s.activeSessionFile && msg.sessionFile !== s.activeSessionFile) {\n return s;\n }\n return {\n ...s,\n agentPending: false,\n activeModel: msg.model ?? s.activeModel,\n isStreaming: msg.isStreaming ?? s.isStreaming,\n contextUsage: msg.contextUsage ?? s.contextUsage,\n };\n });\n break;\n case 'context_usage':\n this.stateStore.update((s) => ({\n ...s,\n contextUsage: msg.contextUsage ?? null,\n }));\n break;\n case 'session_notice':\n // A non-fatal notice for the active session (e.g. a CLI took over while\n // this session was mid-turn here, discarding the in-flight tool call or\n // streaming reply). Keep the session attached; surface it as a\n // dismissible banner. Ignore a notice for a session we switched away from.\n this.stateStore.update((s) => {\n if (s.sessionId && msg.sessionId && s.sessionId !== msg.sessionId)\n return s;\n return { ...s, notice: { level: msg.level, message: msg.message } };\n });\n break;\n case 'bash_sudo_prompt':\n // A `!sudo ...` command on the server needs a password before it can\n // run. Surface a masked prompt for the active session only; ignore a\n // prompt for a session we already switched away from.\n this.stateStore.update((s) => {\n if (s.sessionId && msg.sessionId && s.sessionId !== msg.sessionId)\n return s;\n return {\n ...s,\n sudoPrompt: {\n promptId: msg.promptId,\n command: msg.command,\n sessionId: msg.sessionId,\n },\n };\n });\n break;\n case 'session_destroyed':\n this.stateStore.update((s) => {\n if (s.sessionId === msg.sessionId) {\n return {\n ...s,\n messages: [],\n session: null,\n sessionId: null,\n activeSessionFile: null,\n activeCwd: null,\n activeModel: null,\n loadingSession: false,\n agentPending: false,\n notice: null,\n sudoPrompt: null,\n };\n }\n return s;\n });\n break;\n case 'session_error':\n this.stateStore.update((s) => ({\n ...s,\n sessionError: msg.error,\n isStreaming: false,\n creatingSession: false,\n loadingSession: false,\n resyncing: false,\n // A failed (cold) agent build clears pending: the session stays\n // readable, but sending remains blocked (no live agent) and the error\n // is surfaced. This is the degrade-to-read-only path.\n agentPending: false,\n }));\n break;\n case 'session_conflict':\n this.stateStore.update((s) => ({\n ...s,\n conflict: {\n targetSessionId: msg.sessionId,\n conflictingSessionId: msg.conflictingSession,\n conflictingCwd: msg.conflictingCwd,\n },\n creatingSession: false,\n loadingSession: false,\n resyncing: false,\n agentPending: false,\n }));\n break;\n case 'session_interrupted':\n this.stateStore.update((s) => ({\n ...s,\n isInterrupted: true,\n readOnly: true,\n messages: [],\n session: null,\n sessionId: null,\n activeSessionFile: null,\n activeCwd: null,\n activeModel: null,\n creatingSession: false,\n loadingSession: false,\n agentPending: false,\n notice: null,\n sudoPrompt: null,\n }));\n break;\n case 'message_history': {\n // The server transcript is authoritative for what was actually persisted.\n // Reconcile it against any unconfirmed outbound messages: keep the ones\n // that ARE in history (delivered), and re-surface the ones that are NOT\n // as recoverable 'failed' items so a message a half-open socket swallowed\n // is never silently lost across a reload/resync.\n const sessionIdForPending = msg.sessionId;\n // Carry-over from the CURRENT store (this-tab sends still in flight) plus\n // anything a PREVIOUS tab persisted before a reload.\n const inFlight = get(this.stateStore).messages.filter((m) => m.role === 'user' && m.delivery !== undefined);\n const persisted = this.loadPersistedPending(sessionIdForPending);\n const candidates = [...persisted, ...inFlight];\n this.stateStore.update((s) => {\n const mapped = this.mapHistory(msg.messages, msg.sessionId, s.isStreaming);\n const totalCount = typeof msg.totalCount === 'number' ? msg.totalCount : mapped.length;\n const offset = typeof msg.offset === 'number' ? msg.offset : 0;\n const historyContents = new Set(mapped.filter((m) => m.role === 'user').map((m) => m.content));\n // Unconfirmed candidates whose content is NOT in the loaded history are\n // undelivered. De-dupe by content so two identical undelivered sends do\n // not multiply. Everything else the server persisted is already in\n // `mapped` (confirmed).\n const seen = new Set();\n const undelivered = [];\n for (const c of candidates) {\n if (historyContents.has(c.content))\n continue;\n if (seen.has(c.content))\n continue;\n seen.add(c.content);\n undelivered.push({ ...c, sessionId: sessionIdForPending, delivery: 'failed' });\n }\n return {\n ...s,\n messages: [...mapped, ...undelivered],\n historyTotalCount: totalCount,\n historyOffset: offset,\n loadingMoreHistory: false,\n loadingSession: false,\n resyncing: false,\n };\n });\n // Clear watchdogs for anything now confirmed, and rewrite the persisted\n // store to exactly the still-undelivered set.\n for (const c of candidates)\n this.clearConfirm(c.id);\n this.persistPending(sessionIdForPending);\n break;\n }\n case 'message_history_prepend':\n this.stateStore.update((s) => {\n // Older window prepended ahead of currently-loaded messages. No\n // streaming-tail handling here (those messages are historical).\n const older = this.mapHistory(msg.messages, msg.sessionId, false);\n const offset = typeof msg.offset === 'number' ? msg.offset : 0;\n if (older.length === 0) {\n return { ...s, loadingMoreHistory: false, historyOffset: offset };\n }\n return {\n ...s,\n messages: [...older, ...s.messages],\n historyOffset: offset,\n loadingMoreHistory: false,\n };\n });\n break;\n case 'model_changed':\n this.stateStore.update((s) => ({\n ...s,\n activeModel: msg.model,\n }));\n break;\n }\n }\n /**\n * True when an errored tool result is the product of a USER ABORT (e.g. the\n * web \"abort\" button killed a running tool), rather than a genuine tool\n * failure. The pi tools append a trailing status line on abort (\"Command\n * aborted\" for bash, \"Operation aborted\" for edit/write, bare \"aborted\" for a\n * pre-execution abort). We match that trailing status so the UI can render a\n * neutral \"interrupted\" state instead of a red error: you cancelling a tool is\n * not the tool failing. Only meaningful when isError is already true; matched\n * as the LAST non-empty line to avoid false positives from command output that\n * merely contains the word \"aborted\".\n */\n isAbortedToolResult(result) {\n if (!result)\n return false;\n const lines = result.trimEnd().split('\\n');\n const last = (lines[lines.length - 1] || '').trim();\n return /^(command|operation)?\\s*aborted$/i.test(last);\n }\n /**\n * Map a server `HistoryMessage[]` window into UI `ChatMessage[]`. When\n * `applyStreamingTail` is true, the last assistant/thinking message and any\n * unmatched tool-call placeholders are marked streaming (used only for the\n * live tail window, not for prepended older history).\n */\n mapHistory(rawMessages, sessionId, applyStreamingTail) {\n const mapped = [];\n // A tool_call is rendered IN PLACE, at its position in the stream, as a tool\n // message that is initially result-less. Its matching tool_result fills it\n // in later. We track the still-open calls per tool name as indices into\n // `mapped`, so a call that never receives a result simply stays where it was\n // issued (correctly marked interrupted below) instead of being hoisted to\n // the very end of the transcript. The end-hoisting was the bug: dangling\n // tool calls from EARLIER in the conversation (e.g. an interrupted long-\n // running bash, later superseded by a new user turn) would all pile up as a\n // \"series of aborted tool calls\" AFTER the latest reply, even though the CLI\n // shows them inline where they happened.\n //\n // Matching is by tool-call id when present (the server forwards it on both\n // tool_call and tool_result), which pairs a result to its EXACT call even\n // when same-named calls interleave with some left dangling. When the id is\n // absent (older sessions, or the synthesized bashExecution pair) we fall\n // back to oldest-open-first per tool name.\n const openCalls = {};\n const openById = {};\n // Drop a resolved call's index from the name-FIFO list so an id match and a\n // later name-fallback can never both consume the same call.\n const removeFromNameQueue = (tName, idx) => {\n const q = openCalls[tName];\n if (!q)\n return;\n const at = q.indexOf(idx);\n if (at !== -1)\n q.splice(at, 1);\n };\n for (const m of rawMessages) {\n if (m.role === 'tool_call') {\n const tName = m.toolName || 'unknown';\n const args = m.content || '';\n const idx = mapped.length;\n mapped.push({\n id: this.generateId(),\n role: 'tool',\n content: args ? `$ ${tName} ${args}` : `$ ${tName}`,\n timestamp: m.timestamp,\n // No result yet. Marked as interrupted below if it stays unmatched;\n // the streaming tail promotes the last one back to streaming.\n isStreaming: false,\n toolName: tName,\n toolArgs: args,\n toolOutput: '',\n sessionId,\n // Keep the start so a matched result (or a still-running streaming\n // tail) can show a coherent duration / \"Elapsed\".\n ...(Number.isFinite(m.timestamp) ? { startedAt: m.timestamp } : {}),\n // Carry the force-command marker from history so a `!command` bash\n // tool call auto-expands on reload just like it does live.\n ...(m.forceCommand ? { forceCommand: true } : {}),\n });\n if (!openCalls[tName])\n openCalls[tName] = [];\n openCalls[tName].push(idx);\n if (typeof m.toolCallId === 'string' && m.toolCallId) {\n openById[m.toolCallId] = idx;\n }\n }\n else if (m.role === 'tool_result') {\n const tName = m.toolName || 'unknown';\n // Prefer an exact id match; else fill the OLDEST still-open call of this\n // name (FIFO), mirroring how parallel same-named calls resolve in order.\n let callIdx;\n if (typeof m.toolCallId === 'string' &&\n m.toolCallId &&\n openById[m.toolCallId] !== undefined) {\n callIdx = openById[m.toolCallId];\n delete openById[m.toolCallId];\n removeFromNameQueue(tName, callIdx);\n }\n else if (openCalls[tName] && openCalls[tName].length > 0) {\n callIdx = openCalls[tName].shift();\n // Keep openById consistent if this call had also registered an id.\n for (const [id, i] of Object.entries(openById)) {\n if (i === callIdx)\n delete openById[id];\n }\n }\n const isError = m.isError && !this.isAbortedToolResult(m.content);\n const interrupted = !!m.isError && this.isAbortedToolResult(m.content);\n if (callIdx !== undefined) {\n const call = mapped[callIdx];\n const tArgs = call.toolArgs || '';\n const startedAt = call.startedAt;\n mapped[callIdx] = {\n ...call,\n content: tArgs\n ? `$ ${tName} ${tArgs}\\n${m.content}`\n : `$ ${tName}\\n${m.content}`,\n isStreaming: false,\n toolOutput: m.content,\n ...(Array.isArray(m.images) && m.images.length > 0\n ? { images: m.images }\n : {}),\n // A user abort surfaces as an errored result with a trailing\n // \"...aborted\" status. Render it as interrupted (neutral), not a red\n // error: aborting a tool is not the tool failing.\n isError,\n interrupted,\n timestamp: m.timestamp,\n // Duration only when both timestamps are finite and coherent\n // (end >= start); otherwise leave unset rather than show a bogus one.\n ...(startedAt !== undefined &&\n Number.isFinite(startedAt) &&\n Number.isFinite(m.timestamp) &&\n m.timestamp >= startedAt\n ? { endedAt: m.timestamp }\n : {}),\n };\n }\n else {\n // A result with no preceding open call (shouldn't normally happen).\n // Render it in place as a standalone tool message so nothing is lost.\n mapped.push({\n id: this.generateId(),\n role: 'tool',\n content: `$ ${tName}\\n${m.content}`,\n timestamp: m.timestamp,\n isStreaming: false,\n toolName: tName,\n toolArgs: '',\n toolOutput: m.content,\n ...(Array.isArray(m.images) && m.images.length > 0\n ? { images: m.images }\n : {}),\n isError,\n interrupted,\n sessionId,\n });\n }\n }\n else {\n mapped.push({\n id: this.generateId(),\n role: m.role,\n content: m.content,\n timestamp: m.timestamp,\n isStreaming: false,\n toolName: m.toolName,\n sessionId,\n });\n }\n }\n // Any call still open (issued a toolCall, never got a tool_result) is FROZEN\n // in place with no result. Meaning depends on context:\n // - streaming tail (applyStreamingTail): only the MOST RECENT open call is\n // plausibly still running; keep it streaming so the UI ticks \"Elapsed\".\n // Earlier open calls in the same window are already superseded and are\n // interrupted.\n // - otherwise: its outcome is unknown (e.g. a CLI takeover / interruption\n // killed it mid-run), so mark it `interrupted` for a neutral \"no result\"\n // state instead of a bogus green success tick.\n const allOpen = [];\n for (const idxs of Object.values(openCalls))\n allOpen.push(...idxs);\n allOpen.sort((a, b) => a - b);\n const lastOpenIdx = applyStreamingTail && allOpen.length > 0\n ? allOpen[allOpen.length - 1]\n : -1;\n for (const idx of allOpen) {\n if (idx === lastOpenIdx) {\n mapped[idx] = { ...mapped[idx], isStreaming: true };\n }\n else {\n mapped[idx] = { ...mapped[idx], interrupted: true };\n }\n }\n if (applyStreamingTail && mapped.length > 0) {\n const lastIndex = mapped.length - 1;\n const lastMsg = mapped[lastIndex];\n if (lastMsg.role === 'assistant' || lastMsg.role === 'thinking') {\n mapped[lastIndex] = {\n ...lastMsg,\n isStreaming: true,\n };\n }\n }\n return mapped;\n }\n /**\n * Request the previous window of older history for the active session.\n * No-op when there is nothing older to load or a request is already in\n * flight.\n */\n loadMoreHistory() {\n const s = get(this.stateStore);\n if (!s.sessionId)\n return;\n if (s.loadingMoreHistory)\n return;\n if (s.historyOffset <= 0)\n return;\n this.stateStore.update((st) => ({\n ...st,\n loadingMoreHistory: true,\n }));\n this.send({\n type: 'history_load_more',\n sessionId: s.sessionId,\n beforeOffset: s.historyOffset,\n });\n }\n // Returns true only when the frame was actually handed to an OPEN socket.\n // A non-OPEN (null / CONNECTING / CLOSING / half-open) socket silently\n // dropping the frame is what made messages vanish: they rendered locally but\n // never reached the server, so they were gone after a reload. Callers that\n // carry user intent (sendMessage) must check this and surface the failure.\n send(msg) {\n if (this.ws && this.ws.readyState === 1 /* OPEN */) {\n try {\n this.ws.send(JSON.stringify(msg));\n return true;\n }\n catch {\n return false;\n }\n }\n return false;\n }\n // Returns true only if the message actually went out over an OPEN socket.\n // Callers MUST use the return value to decide whether to clear the input:\n // clearing on a false return is what loses the user's text on a dropped send.\n sendMessage(text) {\n const s = get(this.stateStore);\n if (!s.sessionId)\n return false;\n // The session's transcript is loaded but its live agent is still building\n // (cold, fast-first load). Reading is fine; sending is not possible yet, and\n // a message sent now would have no agent to receive it. Surface a clear,\n // recoverable hint and keep the text (the composer is disabled anyway, but a\n // programmatic caller could still reach here).\n if (s.agentPending) {\n this.stateStore.update((st) => ({\n ...st,\n sessionError: st.sessionError ?? 'Preparing the session agent; please wait a moment, then resend.',\n }));\n return false;\n }\n // Guard against sending on a dead / half-open socket. getIsConnected()\n // checks the real readyState (not the store's connected flag, which can lag\n // a half-open socket the liveness watchdog has not reaped yet). Sending here\n // would be silently dropped, the message would appear locally, then vanish\n // on reload. Surface a recoverable error and make sure we are reconnecting\n // instead of optimistically rendering a message that never left.\n if (!this.getIsConnected()) {\n this.stateStore.update((st) => ({\n ...st,\n sessionError: 'Not connected to the relay; your message was not sent. Reconnecting, then please resend.',\n }));\n if (!this.ws && !this.reconnectTimer) {\n this.scheduleReconnect();\n }\n return false;\n }\n // Send first; only commit the optimistic local echo + clear the error once\n // the frame is confirmed handed to an OPEN socket. This way a send that\n // fails (a narrow race between the readyState check and send) leaves no\n // phantom local message and keeps the input intact for the caller to retry.\n const ok = this.send({ type: 'message', message: text, sessionId: s.sessionId });\n if (!ok) {\n this.stateStore.update((st) => ({\n ...st,\n sessionError: 'Message failed to send (connection dropped). Please resend once reconnected.',\n }));\n return false;\n }\n // A `!command` / `!!command` is intercepted by the server and run as a bash\n // tool call, NOT delivered to the agent. The server never echoes it back as a\n // user message, and the bash tool_start/tool_end events are the real, durable\n // feedback (and are recorded in history). So do NOT add any local user echo\n // for it: a bubble here would be a transient duplicate that vanishes on\n // reload (bash runs are not part of the user-message transcript) and, if\n // delivery-tracked, would wrongly time out into a retry/discard banner. Just\n // clear any prior error and let the tool-call render carry the feedback.\n if (text.trimStart().startsWith('!')) {\n this.stateStore.update((st) => ({ ...st, sessionError: null }));\n return true;\n }\n // The frame was handed to an OPEN socket, but that is NOT proof of delivery:\n // a half-open TCP connection accepts send() (buffers locally, no throw) yet\n // the bytes never reach the server. So commit the echo as delivery:'sending'\n // (unconfirmed) and arm a watchdog + persist it, so it is recoverable on\n // reload and flips to 'failed' if the server never echoes it back.\n const message = {\n id: this.generateId(),\n role: 'user',\n content: text,\n timestamp: Date.now(),\n isStreaming: false,\n sessionId: s.sessionId,\n delivery: 'sending',\n };\n this.stateStore.update((st) => ({\n ...st,\n sessionError: null,\n messages: [...st.messages, message],\n }));\n this.armConfirm(message.id);\n this.persistPending(s.sessionId);\n return true;\n }\n // ==========================================================================\n // Outbound-message delivery confirmation + recovery.\n //\n // An optimistic user echo is unconfirmed until the server echoes it back. This\n // machinery makes an unconfirmed message survive a reload and surface a retry\n // affordance instead of being silently lost when a half-open socket swallowed\n // the frame.\n // ==========================================================================\n pendingKey(sessionId) {\n return WhereverClient.PENDING_PREFIX + sessionId;\n }\n // Persist the current session's still-unconfirmed (delivery-tagged) user\n // messages so a reload can recover them. Cleared to empty when none remain.\n persistPending(sessionId) {\n if (!sessionId || typeof localStorage === 'undefined')\n return;\n const pending = get(this.stateStore).messages.filter((m) => m.role === 'user' && m.delivery !== undefined);\n try {\n if (pending.length === 0) {\n localStorage.removeItem(this.pendingKey(sessionId));\n }\n else {\n localStorage.setItem(this.pendingKey(sessionId), JSON.stringify(pending.map((m) => ({\n id: m.id,\n content: m.content,\n timestamp: m.timestamp,\n // Persist as 'failed': a reload cannot know if it ever landed, so\n // it must be presented as needs-attention, never as delivered.\n delivery: 'failed',\n }))));\n }\n }\n catch { }\n }\n // Load persisted unconfirmed messages for a session (used on load/resync to\n // re-surface anything a previous tab left in limbo).\n loadPersistedPending(sessionId) {\n if (typeof localStorage === 'undefined')\n return [];\n try {\n const raw = localStorage.getItem(this.pendingKey(sessionId));\n if (!raw)\n return [];\n const arr = JSON.parse(raw);\n if (!Array.isArray(arr))\n return [];\n return arr\n .filter((m) => m && typeof m.content === 'string')\n .map((m) => ({\n id: typeof m.id === 'string' ? m.id : this.generateId(),\n role: 'user',\n content: m.content,\n timestamp: typeof m.timestamp === 'number' ? m.timestamp : Date.now(),\n isStreaming: false,\n sessionId,\n delivery: 'failed',\n }));\n }\n catch {\n return [];\n }\n }\n armConfirm(messageId) {\n this.clearConfirm(messageId);\n if (typeof setTimeout !== 'function')\n return;\n const timer = setTimeout(() => {\n this.confirmTimers.delete(messageId);\n // Still unconfirmed after the window: mark it failed so the UI offers a\n // retry. Delivery is genuinely uncertain (a half-open socket may have\n // eaten it), so we do NOT auto-resend: that risks a duplicate. The user\n // decides.\n let sessionId = null;\n this.stateStore.update((st) => {\n const m = st.messages.find((x) => x.id === messageId);\n if (!m || m.delivery !== 'sending')\n return st;\n sessionId = st.sessionId;\n return {\n ...st,\n messages: st.messages.map((x) => x.id === messageId ? { ...x, delivery: 'failed' } : x),\n };\n });\n if (sessionId)\n this.persistPending(sessionId);\n }, WhereverClient.CONFIRM_MS);\n if (timer && typeof timer.unref === 'function') {\n timer.unref();\n }\n this.confirmTimers.set(messageId, timer);\n }\n clearConfirm(messageId) {\n const t = this.confirmTimers.get(messageId);\n if (t) {\n clearTimeout(t);\n this.confirmTimers.delete(messageId);\n }\n }\n // Mark the oldest still-unconfirmed user message with this content as\n // delivered (the server echoed it back). Content-matched because the server\n // echo carries no client message id. Returns true if one was confirmed.\n confirmDeliveredByContent(content) {\n let confirmedId = null;\n let sessionId = null;\n this.stateStore.update((st) => {\n const target = st.messages.find((m) => m.role === 'user' && m.delivery !== undefined && m.content === content);\n if (!target)\n return st;\n confirmedId = target.id;\n sessionId = st.sessionId;\n return {\n ...st,\n messages: st.messages.map((m) => m.id === target.id ? { ...m, delivery: undefined } : m),\n };\n });\n if (confirmedId) {\n this.clearConfirm(confirmedId);\n this.persistPending(sessionId);\n return true;\n }\n return false;\n }\n // Retry a failed (or sending) outbound message: re-send its frame and re-arm\n // confirmation. Returns false if it could not be handed to an OPEN socket (the\n // message stays failed/recoverable).\n resendMessage(messageId) {\n const s = get(this.stateStore);\n const m = s.messages.find((x) => x.id === messageId && x.role === 'user');\n if (!m || !s.sessionId)\n return false;\n if (!this.getIsConnected()) {\n if (!this.ws && !this.reconnectTimer)\n this.scheduleReconnect();\n return false;\n }\n const ok = this.send({ type: 'message', message: m.content, sessionId: s.sessionId });\n if (!ok)\n return false;\n this.stateStore.update((st) => ({\n ...st,\n sessionError: null,\n messages: st.messages.map((x) => x.id === messageId ? { ...x, delivery: 'sending', timestamp: Date.now() } : x),\n }));\n this.armConfirm(messageId);\n this.persistPending(s.sessionId);\n return true;\n }\n // Drop a failed outbound message the user chooses not to resend. Removes it\n // from the transcript and from the persisted-pending store.\n discardMessage(messageId) {\n let sessionId = null;\n this.clearConfirm(messageId);\n this.stateStore.update((st) => {\n sessionId = st.sessionId;\n return {\n ...st,\n messages: st.messages.filter((m) => m.id !== messageId),\n };\n });\n if (sessionId)\n this.persistPending(sessionId);\n }\n abort() {\n const s = get(this.stateStore);\n if (!s.sessionId)\n return;\n this.send({ type: 'abort', sessionId: s.sessionId });\n }\n joinSession(sessionFile, cwd, model) {\n this.stateStore.update((s) => ({\n ...s,\n conflict: null,\n sessionError: null,\n loadingSession: true,\n agentPending: false,\n }));\n this.send({ type: 'session_load', sessionFile, cwd, model });\n this.armLoadWatchdog();\n }\n // Switch from the currently-active session (if any) straight to another one in\n // a single, atomic step. Leaving + loading used to be done by the UI as two\n // calls separated by a 100ms setTimeout; that gap could strand the loading\n // state (a tap landing mid-switch, a leave whose load never fired) and leave\n // the \"Loading session...\" spinner hanging with an open sidebar. Doing both\n // here, synchronously, means there is never an in-between state and the\n // watchdog is always (re)armed for the new load, so a superseded or lost load\n // can never strand the UI: the latest tap always wins.\n switchSession(sessionFile, cwd, model) {\n const s = get(this.stateStore);\n // Tapping the already-active session is a no-op (don't tear it down just to\n // reload the same history).\n if (s.activeSessionFile === sessionFile && !s.loadingSession && !s.resyncing) {\n return;\n }\n if (s.sessionId) {\n this.send({ type: 'session_leave', sessionId: s.sessionId });\n }\n // Reset to a clean loading state for the target session in one update so the\n // old conversation clears immediately and the spinner reflects the new load.\n this.stateStore.update((st) => ({\n ...st,\n messages: [],\n session: null,\n sessionId: null,\n activeSessionFile: null,\n activeCwd: null,\n activeModel: null,\n readOnly: false,\n conflict: null,\n sessionError: null,\n notice: null,\n sudoPrompt: null,\n creatingSession: false,\n resyncing: false,\n agentPending: false,\n contextUsage: null,\n loadingSession: true,\n }));\n this.resumeSessionFile = null;\n this.resumeCwd = undefined;\n this.resumeModel = undefined;\n // Switching supersedes any in-flight create; disarm its watchdog so it can't\n // later fire against the newly loaded session.\n this.clearCreateWatchdog();\n this.send({ type: 'session_load', sessionFile, cwd, model });\n this.armLoadWatchdog();\n }\n createSession(cwd, model, gitInit, createRemote, repoVisibility, cloneRemote) {\n this.stateStore.update((s) => ({\n ...s,\n conflict: null,\n sessionError: null,\n creatingSession: true,\n loadingSession: false,\n }));\n this.send({\n type: 'session_new',\n cwd,\n model,\n gitInit,\n createRemote,\n repoVisibility,\n cloneRemote,\n });\n // Never let the blocking \"Creating session...\" overlay hang if the reply is\n // lost. Symmetrical with armLoadWatchdog for session_load.\n this.armCreateWatchdog();\n }\n leaveSession() {\n const s = get(this.stateStore);\n // Leaving abandons any in-flight create too, so disarm its watchdog even when\n // there is no sessionId yet (a create that has not resolved).\n this.clearCreateWatchdog();\n if (!s.sessionId) {\n if (s.creatingSession) {\n this.stateStore.update((st) => ({\n ...st,\n creatingSession: false,\n }));\n }\n return;\n }\n this.send({ type: 'session_leave', sessionId: s.sessionId });\n this.stateStore.update((s) => ({\n ...s,\n messages: [],\n session: null,\n sessionId: null,\n activeSessionFile: null,\n activeCwd: null,\n activeModel: null,\n readOnly: false,\n notice: null,\n sudoPrompt: null,\n creatingSession: false,\n loadingSession: false,\n resyncing: false,\n agentPending: false,\n contextUsage: null,\n }));\n this.clearLoadWatchdog();\n this.resumeSessionFile = null;\n this.resumeCwd = undefined;\n this.resumeModel = undefined;\n }\n resolveConflict(action, cwd) {\n const s = get(this.stateStore);\n if (!s.conflict)\n return;\n this.send({\n type: 'session_resolve_conflict',\n action,\n sessionId: s.conflict.targetSessionId,\n cwd: cwd || s.conflict.conflictingCwd,\n });\n this.stateStore.update((s) => ({\n ...s,\n conflict: null,\n readOnly: action === 'read_only',\n }));\n }\n ping() {\n this.send({ type: 'ping' });\n }\n clearMessages() {\n this.stateStore.update((s) => ({ ...s, messages: [] }));\n }\n dismissSessionError() {\n this.stateStore.update((s) => ({ ...s, sessionError: null }));\n }\n dismissNotice() {\n this.stateStore.update((s) => ({ ...s, notice: null }));\n }\n // Answer a pending `!sudo ...` prompt with the password the user typed. The\n // password is sent straight to the server (never stored in client state) and\n // the prompt is cleared. No-op if there is no matching pending prompt.\n sendSudoPassword(password) {\n const s = get(this.stateStore);\n const prompt = s.sudoPrompt;\n if (!prompt)\n return;\n this.send({\n type: 'bash_sudo_password',\n sessionId: prompt.sessionId,\n promptId: prompt.promptId,\n password,\n });\n this.stateStore.update((st) => ({ ...st, sudoPrompt: null }));\n }\n // Dismiss a pending `!sudo ...` prompt without running the command. Tells the\n // server to drop the deferred command and clears the local prompt.\n cancelSudoPrompt() {\n const s = get(this.stateStore);\n const prompt = s.sudoPrompt;\n this.stateStore.update((st) => ({ ...st, sudoPrompt: null }));\n if (!prompt)\n return;\n this.send({\n type: 'bash_sudo_cancel',\n sessionId: prompt.sessionId,\n promptId: prompt.promptId,\n });\n }\n changeModel(model) {\n this.send({ type: 'model_change', model });\n }\n setConfig(updates) {\n this.config = {\n ...this.config,\n ...updates,\n };\n this.stateStore.update((s) => {\n const next = { ...s };\n if (updates.hideThinking !== undefined)\n next.hideThinking = !!updates.hideThinking;\n if (updates.hideTools !== undefined)\n next.hideTools = !!updates.hideTools;\n return next;\n });\n }\n onMessage(cb) {\n this.listeners.add(cb);\n return () => {\n this.listeners.delete(cb);\n };\n }\n uploadFileViaWebSocket(sessionId, filename, base64Data) {\n return new Promise((resolve, reject) => {\n const uploadId = this.generateId();\n this.pendingUploads.set(uploadId, { resolve, reject });\n this.send({\n type: 'file_upload',\n uploadId,\n sessionId,\n filename,\n data: base64Data\n });\n });\n }\n generateId() {\n return Math.random().toString(36).substring(2) + Date.now().toString(36);\n }\n getIsConnected() {\n return this.ws && this.ws.readyState === 1;\n }\n}\n//# sourceMappingURL=client.js.map","import {writable, get} from 'svelte/store';\n\nexport interface SessionInfo {\n\tpath: string;\n\tid: string;\n\tname?: string;\n\tcreated: string;\n\tmodified: string;\n\tmessageCount: number;\n\t// Short, capped preview of the first user message (not the full text).\n\tfirstMessage: string;\n\tisActive: boolean;\n\tclientCount: number;\n}\n\nexport interface FolderWithSessions {\n\tpath: string;\n\tname: string;\n\tsessions: SessionInfo[];\n\treadOnly?: boolean;\n}\n\nexport interface ConflictInfo {\n\ttargetSessionId: string;\n\tconflictingSessionId: string;\n\tconflictingCwd: string;\n}\n\nexport interface ModelInfo {\n\tprovider: string;\n\tmodelId: string;\n\tlabel: string;\n\tisDefault?: boolean;\n}\n\nexport interface SessionStoreData {\n\tfolders: FolderWithSessions[];\n\tactiveSessions: string[];\n\tcurrentSession: string | null;\n\tloading: boolean;\n}\n\nexport interface ModelsStoreData {\n\tmodels: ModelInfo[];\n\tloading: boolean;\n}\n\nexport const sessionFolders = writable<SessionStoreData>({\n\tfolders: [],\n\tactiveSessions: [],\n\tcurrentSession: null,\n\tloading: false,\n});\n\nexport const availableModels = writable<ModelsStoreData>({\n\tmodels: [],\n\tloading: false,\n});\n\n// Separate store for the read-only sessions page (sessions.readOnly folders),\n// fetched on demand via /sessions?view=readonly. Kept distinct from the main\n// list so the default dashboard payload stays small.\nexport const readOnlySessionFolders = writable<SessionStoreData>({\n\tfolders: [],\n\tactiveSessions: [],\n\tcurrentSession: null,\n\tloading: false,\n});\n\n// Default port when none is explicitly configured: prefer the page's own\n// origin port so reverse-proxy deployments (e.g. https://host behind Caddy on\n// 443, no port in the URL) work without the user configuring a port. Falls\n// back to the dev default 31415 only when no usable location port exists.\nfunction defaultPort(): number {\n\tif (typeof window !== 'undefined' && window.location) {\n\t\tconst loc = window.location;\n\t\tif (loc.port) return Number(loc.port);\n\t\tif (loc.protocol === 'https:') return 443;\n\t\tif (loc.protocol === 'http:') return 80;\n\t}\n\treturn 31415;\n}\n\nexport function getBaseUrl(): string {\n\tconst config = localStorage.getItem('wherever-config');\n\tconst defaultHost =\n\t\ttypeof window !== 'undefined' && window.location && window.location.hostname\n\t\t\t? window.location.hostname\n\t\t\t: 'localhost';\n\n\tif (config) {\n\t\tconst parsed = JSON.parse(config);\n\t\tconst protocol = window.location.protocol === 'https:' ? 'https:' : 'http:';\n\t\tlet host = parsed.host || defaultHost;\n\t\tif (host === 'localhost' || host === '127.0.0.1') {\n\t\t\tif (\n\t\t\t\tdefaultHost &&\n\t\t\t\tdefaultHost !== 'localhost' &&\n\t\t\t\tdefaultHost !== '127.0.0.1'\n\t\t\t) {\n\t\t\t\thost = defaultHost;\n\t\t\t}\n\t\t}\n\t\thost = host.startsWith('http') ? host.replace(/^wss?:\\/\\//, '') : host;\n\t\t// Heal a legacy stored 31415 when actually served from another origin\n\t\t// port (matches getConfig() in wherever.ts), so proxied setups don't\n\t\t// dial a closed 31415.\n\t\tlet port = parsed.port;\n\t\tif ((port === 31415 || port === undefined) && defaultPort() !== 31415) {\n\t\t\tport = defaultPort();\n\t\t}\n\t\treturn `${protocol}//${host}:${port || defaultPort()}`;\n\t}\n\treturn `${window.location.protocol}//${window.location.host}`;\n}\n\nlet fetchTimeout: ReturnType<typeof setTimeout> | null = null;\nlet resolveQueue: (() => void)[] = [];\n// In-flight + coalescing guards: a stream of `sessions_updated` events (one per\n// agent turn) used to pull the whole list repeatedly. We now (a) never run two\n// fetches at once, (b) collapse any requests that arrive during a fetch into a\n// single trailing re-fetch, and (c) cap the debounce reset so a continuous\n// stream still resolves promptly instead of being pushed back forever.\nlet fetchInFlight = false;\nlet refetchRequested = false;\nlet firstQueuedAt = 0;\nconst FETCH_DEBOUNCE_MS = 150;\nconst FETCH_MAX_WAIT_MS = 1000;\n\nasync function doFetchSessions(): Promise<void> {\n\tfetchInFlight = true;\n\ttry {\n\t\tconst baseUrl = getBaseUrl();\n\t\tconst token = getToken();\n\t\tconst url = `${baseUrl}/sessions${token ? `?token=${encodeURIComponent(token)}` : ''}`;\n\t\tconst res = await fetch(url);\n\t\tif (!res.ok) throw new Error(`HTTP ${res.status}`);\n\t\tconst data = await res.json();\n\t\tsessionFolders.set({\n\t\t\tfolders: data.folders || [],\n\t\t\tactiveSessions: (data.activeSessions || []).map(\n\t\t\t\t(s: any) => s.sessionFile,\n\t\t\t),\n\t\t\tcurrentSession: get(sessionFolders).currentSession,\n\t\t\tloading: false,\n\t\t});\n\t} catch (err) {\n\t\tsessionFolders.update((s) => ({...s, loading: false}));\n\t\tconsole.error('Failed to fetch sessions:', err);\n\t} finally {\n\t\tfetchInFlight = false;\n\t}\n}\n\nexport function fetchSessions(): Promise<void> {\n\tsessionFolders.update((s) => ({...s, loading: true}));\n\n\tconst promise = new Promise<void>((resolve) => {\n\t\tresolveQueue.push(resolve);\n\t});\n\n\t// If a fetch is already running, just mark that we need one more pass when it\n\t// finishes (collapsing any number of mid-flight requests into a single one).\n\tif (fetchInFlight) {\n\t\trefetchRequested = true;\n\t\treturn promise;\n\t}\n\n\tconst now = Date.now();\n\tif (!fetchTimeout) {\n\t\tfirstQueuedAt = now;\n\t} else {\n\t\tclearTimeout(fetchTimeout);\n\t\t// Cap the debounce: if we have already been waiting MAX_WAIT, fire now\n\t\t// rather than letting a continuous event stream postpone the fetch forever.\n\t\tif (now - firstQueuedAt >= FETCH_MAX_WAIT_MS) {\n\t\t\tfetchTimeout = null;\n\t\t\tvoid runQueuedFetch();\n\t\t\treturn promise;\n\t\t}\n\t}\n\n\tfetchTimeout = setTimeout(() => {\n\t\tfetchTimeout = null;\n\t\tvoid runQueuedFetch();\n\t}, FETCH_DEBOUNCE_MS);\n\n\treturn promise;\n}\n\nasync function runQueuedFetch(): Promise<void> {\n\tconst resolves = [...resolveQueue];\n\tresolveQueue = [];\n\ttry {\n\t\tawait doFetchSessions();\n\t\t// A request that arrived mid-flight collapses into exactly one re-fetch.\n\t\twhile (refetchRequested) {\n\t\t\trefetchRequested = false;\n\t\t\tawait doFetchSessions();\n\t\t}\n\t} finally {\n\t\tfor (const r of resolves) r();\n\t}\n}\n\n// Fetch the read-only session folders (sessions.readOnly) for the separate\n// read-only page. Deliberately simple (no debounce/coalesce): it is only\n// triggered while that page is open, not on the hot dashboard path.\nexport async function fetchReadOnlySessions(): Promise<void> {\n\treadOnlySessionFolders.update((s) => ({...s, loading: true}));\n\ttry {\n\t\tconst baseUrl = getBaseUrl();\n\t\tconst token = getToken();\n\t\tconst url = `${baseUrl}/sessions?view=readonly${token ? `&token=${encodeURIComponent(token)}` : ''}`;\n\t\tconst res = await fetch(url);\n\t\tif (!res.ok) throw new Error(`HTTP ${res.status}`);\n\t\tconst data = await res.json();\n\t\treadOnlySessionFolders.set({\n\t\t\tfolders: data.folders || [],\n\t\t\tactiveSessions: (data.activeSessions || []).map(\n\t\t\t\t(s: any) => s.sessionFile,\n\t\t\t),\n\t\t\tcurrentSession: get(readOnlySessionFolders).currentSession,\n\t\t\tloading: false,\n\t\t});\n\t} catch (err) {\n\t\treadOnlySessionFolders.update((s) => ({...s, loading: false}));\n\t\tconsole.error('Failed to fetch read-only sessions:', err);\n\t}\n}\n\nexport async function fetchModels(): Promise<void> {\n\tavailableModels.update((s) => ({...s, loading: true}));\n\ttry {\n\t\tconst baseUrl = getBaseUrl();\n\t\tconst token = getToken();\n\t\tconst url = `${baseUrl}/models${token ? `?token=${encodeURIComponent(token)}` : ''}`;\n\t\tconst res = await fetch(url);\n\t\tif (!res.ok) throw new Error(`HTTP ${res.status}`);\n\t\tconst data = await res.json();\n\t\tavailableModels.set({\n\t\t\tmodels: data.models || [],\n\t\t\tloading: false,\n\t\t});\n\t} catch (err) {\n\t\tavailableModels.update((s) => ({...s, loading: false}));\n\t\tconsole.error('Failed to fetch models:', err);\n\t}\n}\n\nexport function getToken(): string {\n\ttry {\n\t\tconst config = localStorage.getItem('wherever-config');\n\t\tif (config) {\n\t\t\tconst parsed = JSON.parse(config);\n\t\t\treturn parsed.token || '';\n\t\t}\n\t} catch {}\n\treturn '';\n}\n\nexport const gitInitDefaultStore = writable<boolean>(false);\nexport const uploadMethodStore = writable<'websocket' | 'post'>('websocket');\nexport const searchFolderStore = writable<string | null>(null);\nexport const searchCreateRemoteStore = writable<boolean>(false);\n// Default model (as \"provider:modelId\") for the configured search folder,\n// resolved server-side against that folder's settings. null when unset.\nexport const searchDefaultModelStore = writable<string | null>(null);\n\nexport interface PathCheckResult {\n\texists: boolean;\n\tisGit: boolean;\n\tresolvedPath: string;\n}\n\nexport async function checkPath(\n\tpathStr: string,\n): Promise<PathCheckResult | null> {\n\tif (!pathStr.trim()) return null;\n\ttry {\n\t\tconst baseUrl = getBaseUrl();\n\t\tconst token = getToken();\n\t\tconst url = `${baseUrl}/check-path?path=${encodeURIComponent(pathStr)}${token ? `&token=${encodeURIComponent(token)}` : ''}`;\n\t\tconst res = await fetch(url);\n\t\tif (!res.ok) throw new Error(`HTTP ${res.status}`);\n\t\treturn (await res.json()) as PathCheckResult;\n\t} catch (err) {\n\t\tconsole.error('Failed to check path:', err);\n\t\treturn null;\n\t}\n}\n\nexport interface RemoteRepoCheckResult {\n\tmatched: boolean;\n\tprovider?: string;\n\texists: boolean;\n\tsshUrl?: string;\n}\n\n/**\n * Submit-time probe: ask the server whether the remote repo that would be\n * created for `pathStr` already exists. Runs a provider CLI on the server, so\n * this is called ON DEMAND at create time, never on every keystroke.\n */\nexport async function checkRemoteRepo(\n\tpathStr: string,\n): Promise<RemoteRepoCheckResult | null> {\n\tif (!pathStr.trim()) return null;\n\ttry {\n\t\tconst baseUrl = getBaseUrl();\n\t\tconst token = getToken();\n\t\tconst url = `${baseUrl}/check-remote-repo?path=${encodeURIComponent(pathStr)}${token ? `&token=${encodeURIComponent(token)}` : ''}`;\n\t\tconst res = await fetch(url);\n\t\tif (!res.ok) throw new Error(`HTTP ${res.status}`);\n\t\treturn (await res.json()) as RemoteRepoCheckResult;\n\t} catch (err) {\n\t\tconsole.error('Failed to check remote repo:', err);\n\t\treturn null;\n\t}\n}\n\nexport interface PathAutocompleteResult {\n\tcompletions: string[];\n}\n\nexport async function autocompletePath(pathStr: string): Promise<string[]> {\n\ttry {\n\t\tconst baseUrl = getBaseUrl();\n\t\tconst token = getToken();\n\t\tconst url = `${baseUrl}/autocomplete-path?path=${encodeURIComponent(pathStr)}${token ? `&token=${encodeURIComponent(token)}` : ''}`;\n\t\tconst res = await fetch(url);\n\t\tif (!res.ok) throw new Error(`HTTP ${res.status}`);\n\t\tconst data = (await res.json()) as PathAutocompleteResult;\n\t\treturn data.completions || [];\n\t} catch (err) {\n\t\tconsole.error('Failed to autocomplete path:', err);\n\t\treturn [];\n\t}\n}\n\nexport async function fetchConfig(): Promise<void> {\n\ttry {\n\t\tconst baseUrl = getBaseUrl();\n\t\tconst token = getToken();\n\t\tconst url = `${baseUrl}/config${token ? `?token=${encodeURIComponent(token)}` : ''}`;\n\t\tconst res = await fetch(url);\n\t\tif (!res.ok) throw new Error(`HTTP ${res.status}`);\n\t\tconst data = await res.json();\n\t\tgitInitDefaultStore.set(!!data.gitInitDefault);\n\t\tuploadMethodStore.set(data.uploadMethod || 'websocket');\n\t\tsearchFolderStore.set(data.searchFolder || null);\n\t\tsearchCreateRemoteStore.set(!!data.searchCreateRemote);\n\t\tsearchDefaultModelStore.set(data.searchDefaultModel || null);\n\t} catch (err) {\n\t\tconsole.error('Failed to fetch config:', err);\n\t}\n}\n\nexport function setCurrentSession(sessionId: string | null): void {\n\tsessionFolders.update((s) => ({...s, currentSession: sessionId}));\n}\n","import {derived, get, writable} from 'svelte/store';\nimport {playInvitingBeep} from './core/beep';\nimport {\n\tWhereverClient,\n\ttype ChatMessage,\n\ttype WhereverState,\n\ttype ConflictInfo,\n} from '@wherever-dev/client';\nimport {\n\tsetCurrentSession,\n\tgetBaseUrl,\n\tgetToken,\n\tuploadMethodStore,\n\tfetchSessions,\n\tsearchFolderStore,\n\tsearchCreateRemoteStore,\n} from './session-store';\n\nexport type {ChatMessage, WhereverState};\n\nfunction getStoredConfig() {\n\ttry {\n\t\tconst stored = localStorage.getItem('wherever-config');\n\t\tif (stored) return JSON.parse(stored);\n\t} catch {}\n\treturn null;\n}\n\nfunction saveConfig(config: {\n\thost: string;\n\tport: number;\n\ttoken: string;\n\thideThinking?: boolean;\n\thideTools?: boolean;\n\tbeepDefault?: boolean;\n\tbeepSoundUrl?: string;\n}) {\n\tlocalStorage.setItem('wherever-config', JSON.stringify(config));\n}\n\n// The port to use when the user has NOT explicitly configured one. When the\n// dashboard is served from a real origin (e.g. behind a reverse proxy like\n// Caddy on 443, or any host:port), connect back to THAT origin's port instead\n// of assuming the dev default 31415. This makes reverse-proxy deployments\n// (https://host with no port in the URL) work without the user having to know\n// to type \"443\" into the port field. A direct LAN setup on http://ip:31415\n// still resolves to 31415 because that is the page's own port. Falls back to\n// 31415 only when there is no window (SSR) or no usable location port.\nfunction defaultPort(): number {\n\tif (typeof window !== 'undefined' && window.location) {\n\t\tconst loc = window.location;\n\t\tif (loc.port) return Number(loc.port);\n\t\t// No explicit port in the URL => standard port for the scheme.\n\t\tif (loc.protocol === 'https:') return 443;\n\t\tif (loc.protocol === 'http:') return 80;\n\t}\n\treturn 31415;\n}\n\nexport function getConfig() {\n\tconst defaultHost =\n\t\ttypeof window !== 'undefined' && window.location && window.location.hostname\n\t\t\t? window.location.hostname\n\t\t\t: 'localhost';\n\n\tconst stored = getStoredConfig();\n\tif (stored) {\n\t\t// Legacy port healing: a config stored before reverse-proxy support has\n\t\t// port 31415 baked in. If the dashboard is actually served from a\n\t\t// different origin port (e.g. 443 behind Caddy), that stale 31415 makes\n\t\t// the client dial a closed port and hang on \"Connecting...\". When the\n\t\t// stored port is the legacy default AND the page's own port differs,\n\t\t// adopt the page's port so proxied deployments just work.\n\t\tif (\n\t\t\t(stored.port === 31415 || stored.port === undefined) &&\n\t\t\tdefaultPort() !== 31415\n\t\t) {\n\t\t\tstored.port = defaultPort();\n\t\t}\n\t\tif (\n\t\t\t!stored.host ||\n\t\t\tstored.host === 'localhost' ||\n\t\t\tstored.host === '127.0.0.1'\n\t\t) {\n\t\t\tif (\n\t\t\t\tdefaultHost &&\n\t\t\t\tdefaultHost !== 'localhost' &&\n\t\t\t\tdefaultHost !== '127.0.0.1'\n\t\t\t) {\n\t\t\t\treturn {\n\t\t\t\t\thideThinking: false,\n\t\t\t\t\thideTools: false,\n\t\t\t\t\t...stored,\n\t\t\t\t\thost: defaultHost,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t\tif (!stored.host) {\n\t\t\tstored.host = defaultHost;\n\t\t}\n\t\treturn {\n\t\t\thideThinking: false,\n\t\t\thideTools: false,\n\t\t\tbeepDefault: false,\n\t\t\tbeepSoundUrl: '',\n\t\t\t...stored,\n\t\t};\n\t}\n\treturn {\n\t\thost: defaultHost,\n\t\tport: defaultPort(),\n\t\ttoken: '',\n\t\thideThinking: false,\n\t\thideTools: false,\n\t\tbeepDefault: false,\n\t\tbeepSoundUrl: '',\n\t};\n}\n\n// --- Waiting-for-human beep ------------------------------------------------\n// The beep is DISABLED by default. A persisted config flag (beepDefault) sets\n// the default for EVERY session. Each session can additionally hold its OWN\n// explicit choice (a per-session override) that wins over the default.\n//\n// Key semantics (\"unset\" is a real, distinct state):\n// - A session with NO override \"follows the default\": change the default and\n// this session's effective beep state changes with it, live.\n// - Once the user explicitly sets the per-session control (on/off), that\n// choice STICKS to that session and is unaffected by later default changes,\n// until the user clears it back to \"follow default\".\n//\n// Overrides are therefore stored PER SESSION (keyed by the session id/file) and\n// persisted, so a choice made in session A survives visiting session B and\n// coming back, and survives a reload. Absence of a key = \"follow default\".\nconst beepDefaultStore = writable<boolean>(!!getConfig().beepDefault);\n\n// Map<sessionKey, boolean> of explicit per-session choices, persisted to\n// localStorage. A missing key means the session follows the default.\nconst BEEP_OVERRIDES_KEY = 'wherever-beep-overrides';\n\nfunction loadBeepOverrides(): Record<string, boolean> {\n\ttry {\n\t\tconst raw = localStorage.getItem(BEEP_OVERRIDES_KEY);\n\t\tif (raw) {\n\t\t\tconst parsed = JSON.parse(raw);\n\t\t\tif (parsed && typeof parsed === 'object') return parsed;\n\t\t}\n\t} catch {}\n\treturn {};\n}\n\nfunction saveBeepOverrides(map: Record<string, boolean>) {\n\ttry {\n\t\tlocalStorage.setItem(BEEP_OVERRIDES_KEY, JSON.stringify(map));\n\t} catch {}\n}\n\nconst beepOverridesStore = writable<Record<string, boolean>>(\n\ttypeof localStorage !== 'undefined' ? loadBeepOverrides() : {},\n);\n// The active session's key ('' when no session). Drives which override applies.\nconst beepSessionKeyStore = writable<string>('');\n\nexport function getBeepDefault(): boolean {\n\treturn get(beepDefaultStore);\n}\n\n// Optional custom sound file/URL to play instead of the synthesized chime.\n// Empty string means \"use the built-in chime\".\nexport function getBeepSoundUrl(): string {\n\tconst url = getConfig().beepSoundUrl;\n\treturn typeof url === 'string' ? url : '';\n}\n\n// Persist the custom beep sound URL (empty string clears it, reverting to the\n// built-in chime).\nexport function setBeepSoundUrl(value: string) {\n\tconst config = getConfig();\n\tsaveConfig({...config, beepSoundUrl: value});\n}\n\n// The current session's explicit choice, or undefined when it follows the\n// default. Tri-state: true | false | undefined. Lets the UI signal \"not set\".\nexport const beepSessionOverride = derived(\n\t[beepSessionKeyStore, beepOverridesStore],\n\t([$key, $overrides]) =>\n\t\t$key && $key in $overrides ? $overrides[$key] : undefined,\n);\n\n// True when the beep should sound for the current session: the per-session\n// override if the session set one, otherwise the persisted default. Recomputes\n// when the session, its override, or the default changes.\nexport const beepEnabled = derived(\n\t[beepSessionOverride, beepDefaultStore],\n\t([$override, $default]) => ($override === undefined ? $default : $override),\n);\n\n// Set (or clear) the beep default that applies to all sessions. Persists to\n// config AND updates the reactive default store so beepEnabled recomputes.\nexport function setBeepDefault(value: boolean) {\n\tconst config = getConfig();\n\tsaveConfig({...config, beepDefault: value});\n\tbeepDefaultStore.set(value);\n}\n\n// Set this session's explicit choice (true/false), or pass undefined to CLEAR\n// it back to \"follow the default\". Persisted per session.\nexport function setBeepSessionOverride(value: boolean | undefined) {\n\tconst key = get(beepSessionKeyStore);\n\tif (!key) return; // no active session to attach the choice to\n\tbeepOverridesStore.update((map) => {\n\t\tconst next = {...map};\n\t\tif (value === undefined) {\n\t\t\tdelete next[key];\n\t\t} else {\n\t\t\tnext[key] = value;\n\t\t}\n\t\tsaveBeepOverrides(next);\n\t\treturn next;\n\t});\n}\n\n// Point the beep state at a session (its id/file). Called when the active\n// session changes. Does NOT clear any stored per-session choice: an unset\n// session follows the default; a session with a stored choice keeps it.\nexport function setBeepSessionKey(key: string | null) {\n\tbeepSessionKeyStore.set(key ?? '');\n}\n\n// Instantiate the isomorphic WhereverClient\nconst initialConfig = getConfig();\nexport const client = new WhereverClient({\n\thost: initialConfig.host,\n\tport: initialConfig.port,\n\ttoken: initialConfig.token,\n\tsecure:\n\t\ttypeof window !== 'undefined' &&\n\t\twindow.location &&\n\t\twindow.location.protocol === 'https:',\n\thideThinking: !!initialConfig.hideThinking,\n\thideTools: !!initialConfig.hideTools,\n});\n\nexport const state = client.stateStore;\n\n// --- Waiting-for-human beep trigger ----------------------------------------\n// Watch the streaming flag and sound the inviting chime on the true -> false\n// edge, i.e. the moment the agent stops working and is waiting for a human\n// message. Gated by beepEnabled (per-session override or the persisted\n// default). Also point the beep state at the active session when it changes, so\n// beepEnabled reflects THAT session's stored choice (or the default if unset).\nlet prevIsStreaming = false;\nlet prevSessionKey: string | null = null;\nstate.subscribe((s) => {\n\tconst sessionKey = s.sessionId ?? s.activeSessionFile ?? null;\n\tif (sessionKey !== prevSessionKey) {\n\t\tprevSessionKey = sessionKey;\n\t\t// New/changed session: retarget the beep state at it (its stored choice, if\n\t\t// any, else the default) and do not treat the session's initial streaming\n\t\t// state as a finished-turn edge.\n\t\tsetBeepSessionKey(sessionKey);\n\t\tprevIsStreaming = s.isStreaming;\n\t\treturn;\n\t}\n\tif (prevIsStreaming && !s.isStreaming) {\n\t\t// Only chime for a real session with a transcript, not for a bare\n\t\t// disconnect/leave that also drops isStreaming to false.\n\t\tif (sessionKey && get(beepEnabled)) {\n\t\t\tplayInvitingBeep(getBeepSoundUrl());\n\t\t}\n\t}\n\tprevIsStreaming = s.isStreaming;\n});\n\n// When runSearch() creates a session, hold the query here until the matching\n// session_created arrives, then send it as the first message of that session.\nlet pendingSearchQuery: string | null = null;\n\n// Sync WebSocket messages with Svelte session-store state side-effects\nclient.onMessage((msg) => {\n\tswitch (msg.type) {\n\t\tcase 'session_created':\n\t\t\tsetCurrentSession(msg.sessionFile);\n\t\t\tif (pendingSearchQuery !== null) {\n\t\t\t\tconst query = pendingSearchQuery;\n\t\t\t\tpendingSearchQuery = null;\n\t\t\t\t// App onMessage listeners run BEFORE the client's internal switch\n\t\t\t\t// sets sessionId on its state store, and sendMessage() drops the\n\t\t\t\t// message when sessionId is still null. Defer to the next microtask\n\t\t\t\t// so the store is populated before we send the query.\n\t\t\t\tqueueMicrotask(() => client.sendMessage(query));\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase 'session_error':\n\t\t\t// A search that failed to create a session must not leave a stale\n\t\t\t// pending query that would fire on the next unrelated session.\n\t\t\tpendingSearchQuery = null;\n\t\t\tbreak;\n\n\t\tcase 'session_destroyed':\n\t\t\tconst s = get(state);\n\t\t\tif (s.sessionId === msg.sessionId) {\n\t\t\t\tsetCurrentSession(null);\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase 'sessions_updated':\n\t\t\tfetchSessions();\n\t\t\tbreak;\n\n\t\tcase 'session_interrupted':\n\t\t\tsetCurrentSession(null);\n\t\t\tbreak;\n\t}\n});\n\nexport function connect() {\n\tconst config = getConfig();\n\tsaveConfig(config);\n\n\tconst isSecure =\n\t\ttypeof window !== 'undefined' &&\n\t\twindow.location &&\n\t\twindow.location.protocol === 'https:';\n\n\tclient.connect({\n\t\thost: config.host,\n\t\tport: config.port,\n\t\ttoken: config.token,\n\t\tsecure: isSecure,\n\t\thideThinking: !!config.hideThinking,\n\t\thideTools: !!config.hideTools,\n\t});\n}\n\nexport function disconnect() {\n\tclient.disconnect(true);\n\tsetCurrentSession(null);\n}\n\n// Suspend the connection on tab-background without dropping the cached session.\n// Keeps messages/sessionId in the store so returning resyncs in place instead of\n// reloading. Deliberately does NOT clear the current session.\nexport function suspend() {\n\tclient.suspend();\n}\n\n// Resume after suspend(): reconnect preserving the cache and rejoin the active\n// session. The store's resyncing flag drives the UI's reconnecting affordance.\nexport function resume() {\n\tclient.resume();\n}\n\n// True when a session was recorded for resume (i.e. the tab was suspended with an\n// active session). Lets callers choose the resume path only when there is\n// actually something to rejoin, and otherwise do a plain connect.\nexport function hasSuspendedSession(): boolean {\n\treturn client.hasSuspendedSession();\n}\n\n// True when the client still holds an active session to rejoin in place (from an\n// explicit suspend OR an unsolicited drop). Lets the page prefer the\n// preserve-cache resume() path over a session-wiping fresh connect() on return.\nexport function hasActiveSession(): boolean {\n\treturn client.hasActiveSession();\n}\n\n// --- Native file-picker guard ---------------------------------------------\n// Opening the OS file picker / camera backgrounds the page, which fires\n// `visibilitychange: hidden`. If the user lingers (taking a photo, browsing\n// files), the background suspend timer would otherwise fire and tear down the\n// session, so the subsequent upload fails with \"No active session\". Components\n// flag the picker as active so the visibility handler skips suspending while a\n// picker is open. A timestamp guards against the flag getting stuck if the\n// change event never arrives (e.g. the user cancels the picker on some\n// platforms).\nlet filePickerActiveUntil = 0;\nconst FILE_PICKER_GRACE_MS = 5 * 60 * 1000;\n\nexport function beginFilePicker() {\n\tfilePickerActiveUntil = Date.now() + FILE_PICKER_GRACE_MS;\n}\n\nexport function endFilePicker() {\n\tfilePickerActiveUntil = 0;\n}\n\nexport function isFilePickerActive(): boolean {\n\treturn Date.now() < filePickerActiveUntil;\n}\n\nexport function sendMessage(text: string): boolean {\n\treturn client.sendMessage(text);\n}\n\n// Retry a user message whose delivery could not be confirmed (delivery:\n// 'failed'). Returns false if it could not be handed to a live socket.\nexport function resendMessage(messageId: string): boolean {\n\treturn client.resendMessage(messageId);\n}\n\n// Drop an undelivered user message the user chooses not to resend.\nexport function discardMessage(messageId: string): void {\n\tclient.discardMessage(messageId);\n}\n\nexport function abort() {\n\tclient.abort();\n}\n\nexport function joinSession(sessionFile: string, cwd?: string, model?: string) {\n\tclient.joinSession(sessionFile, cwd, model);\n}\n\n// Atomically leave the current session (if any) and load another one. Preferred\n// over a manual leaveSession()+joinSession() dance: it has no in-between gap that\n// could strand the \"Loading session...\" spinner. Always rearms the load watchdog\n// for the new target, so the latest tap wins.\nexport function switchSession(\n\tsessionFile: string,\n\tcwd?: string,\n\tmodel?: string,\n) {\n\tclient.switchSession(sessionFile, cwd, model);\n}\n\nexport function createSession(\n\tcwd: string,\n\tmodel?: string,\n\tgitInit?: boolean,\n\tcreateRemote?: boolean,\n\trepoVisibility?: 'private' | 'public',\n\tcloneRemote?: boolean,\n) {\n\tclient.createSession(\n\t\tcwd,\n\t\tmodel,\n\t\tgitInit,\n\t\tcreateRemote,\n\t\trepoVisibility,\n\t\tcloneRemote,\n\t);\n}\n\n/**\n * Run a web search: create a fresh session in the configured search folder and,\n * once it is created, send the query as the first message. Each search is a new\n * session, grouped in the sidebar under the search folder. When `model` is\n * omitted the server default (folder-local config) is used. Returns false\n * (no-op) if no search folder is configured.\n */\nexport function runSearch(query: string, model?: string): boolean {\n\tconst trimmed = query.trim();\n\tif (!trimmed) return false;\n\tconst folder = get(searchFolderStore);\n\tif (!folder) return false;\n\tconst createRemote = get(searchCreateRemoteStore);\n\tpendingSearchQuery = trimmed;\n\t// model omitted -> server default. gitInit follows remote intent.\n\t// repoVisibility forced to 'private' when a remote is created.\n\tclient.createSession(\n\t\tfolder,\n\t\tmodel || undefined,\n\t\tcreateRemote,\n\t\tcreateRemote,\n\t\tcreateRemote ? 'private' : undefined,\n\t);\n\treturn true;\n}\n\nexport function leaveSession() {\n\tclient.leaveSession();\n\tsetCurrentSession(null);\n}\n\nexport function loadMoreHistory() {\n\tclient.loadMoreHistory();\n}\n\nexport function resolveConflict(\n\taction: 'take_over' | 'read_only',\n\tcwd?: string,\n) {\n\tclient.resolveConflict(action, cwd);\n}\n\nexport function ping() {\n\tclient.ping();\n}\n\nexport function clearMessages() {\n\tclient.clearMessages();\n}\n\nexport function setConfig(config: {\n\thost: string;\n\tport: number;\n\ttoken: string;\n\thideThinking?: boolean;\n\thideTools?: boolean;\n\tbeepDefault?: boolean;\n\tbeepSoundUrl?: string;\n}) {\n\tsaveConfig(config);\n\t// beepDefault/beepSoundUrl are frontend-only preferences; the client config\n\t// has no such fields, so forward only the fields it understands.\n\tconst {host, port, token, hideThinking, hideTools} = config;\n\tclient.setConfig({host, port, token, hideThinking, hideTools});\n\t// Keep the reactive beep-default store in sync so beepEnabled recomputes when\n\t// the Config menu changes the default (this is the path the settings UI uses,\n\t// not setBeepDefault). Only when the field is actually present in this update.\n\tif (config.beepDefault !== undefined) {\n\t\tbeepDefaultStore.set(!!config.beepDefault);\n\t}\n}\n\nexport function updateConfig(updates: {\n\thideThinking?: boolean;\n\thideTools?: boolean;\n}) {\n\tconst config = getConfig();\n\tconst newConfig = {...config, ...updates};\n\tsaveConfig(newConfig);\n\tclient.setConfig(newConfig);\n}\n\nexport function dismissSessionError() {\n\tclient.dismissSessionError();\n}\n\nexport function dismissNotice() {\n\tclient.dismissNotice();\n}\n\n// Submit the password for a pending `!sudo ...` command. The password is sent\n// straight to the server and never kept in client state.\nexport function sendSudoPassword(password: string) {\n\tclient.sendSudoPassword(password);\n}\n\n// Dismiss the pending sudo prompt without running the command.\nexport function cancelSudoPrompt() {\n\tclient.cancelSudoPrompt();\n}\n\nexport function changeModel(model: string) {\n\tclient.changeModel(model);\n}\n\nexport const piState = derived(state, ($s) => $s);\nexport const isConnected = derived(piState, ($s) => $s.connected);\nexport const isStreaming = derived(piState, ($s) => $s.isStreaming);\nexport const messages = derived(piState, ($s) => $s.messages);\nexport const connectionError = derived(piState, ($s) => $s.error);\nexport const currentSession = derived(piState, ($s) => $s.session);\nexport const conflict = derived(piState, ($s) => $s.conflict);\nexport const isInterrupted = derived(piState, ($s) => $s.isInterrupted);\nexport const sessionError = derived(piState, ($s) => $s.sessionError);\n// A dismissible, non-fatal session notice (e.g. a CLI took over this session\n// while it was mid-turn here, discarding the in-flight tool call or streaming\n// reply). Rendered as a banner.\nexport const sessionNotice = derived(piState, ($s) => $s.notice);\n// A pending `!sudo ...` password prompt for the active session (or null). Drives\n// the masked SudoPasswordDialog.\nexport const sudoPrompt = derived(piState, ($s) => $s.sudoPrompt);\nexport const isReadOnly = derived(piState, ($s) => $s.readOnly);\nexport const activeSessionInfo = derived(piState, ($s) => ({\n\tsessionFile: $s.activeSessionFile,\n\tcwd: $s.activeCwd,\n\tmodel: $s.activeModel,\n\tsessionId: $s.sessionId,\n}));\nexport const contextUsage = derived(piState, ($s) => $s.contextUsage);\nexport const isCreatingSession = derived(piState, ($s) => $s.creatingSession);\nexport const isLoadingSession = derived(piState, ($s) => $s.loadingSession);\nexport const isResyncing = derived(piState, ($s) => $s.resyncing);\n// True after a fast-first (cold) session load: the conversation is readable but\n// the live agent is still building, so sending must stay blocked until ready.\nexport const isAgentPending = derived(piState, ($s) => $s.agentPending);\nexport const hasMoreHistory = derived(piState, ($s) => $s.historyOffset > 0);\nexport const isLoadingMoreHistory = derived(\n\tpiState,\n\t($s) => $s.loadingMoreHistory,\n);\n\nasync function uploadFileViaPost(\n\tsessionId: string,\n\tfile: File,\n): Promise<{savedPath: string; filename: string}> {\n\tconst baseUrl = getBaseUrl();\n\tconst token = getToken();\n\tconst url = `${baseUrl}/session/upload?sessionId=${encodeURIComponent(sessionId)}&filename=${encodeURIComponent(file.name)}${token ? `&token=${encodeURIComponent(token)}` : ''}`;\n\n\tconst fileData = await file.arrayBuffer();\n\n\tconst res = await fetch(url, {\n\t\tmethod: 'POST',\n\t\theaders: {\n\t\t\t'Content-Type': 'text/plain',\n\t\t},\n\t\tbody: fileData,\n\t});\n\n\tif (!res.ok) {\n\t\tconst errData = await res.json().catch(() => ({}));\n\t\tthrow new Error(errData.error || `Upload failed with status ${res.status}`);\n\t}\n\n\treturn await res.json();\n}\n\nfunction uploadFileViaWebSocket(\n\tsessionId: string,\n\tfile: File,\n): Promise<{savedPath: string; filename: string}> {\n\treturn new Promise((resolve, reject) => {\n\t\ttry {\n\t\t\tconst reader = new FileReader();\n\t\t\treader.onload = () => {\n\t\t\t\ttry {\n\t\t\t\t\tconst result = reader.result as string;\n\t\t\t\t\tconst base64Data = result.split(',')[1] || '';\n\n\t\t\t\t\tclient\n\t\t\t\t\t\t.uploadFileViaWebSocket(sessionId, file.name, base64Data)\n\t\t\t\t\t\t.then(resolve)\n\t\t\t\t\t\t.catch(reject);\n\t\t\t\t} catch (err) {\n\t\t\t\t\treject(\n\t\t\t\t\t\tnew Error(`Failed to process file data: ${(err as Error).message}`),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t};\n\t\t\treader.onerror = () => {\n\t\t\t\treject(new Error('Failed to read file contents'));\n\t\t\t};\n\t\t\treader.readAsDataURL(file);\n\t\t} catch (err) {\n\t\t\treject(err);\n\t\t}\n\t});\n}\n\n/**\n * Build an authenticated URL for GET /session/download. The server streams the\n * file with Content-Disposition: attachment, validating `path` against the\n * session's allowed download roots. `path` is the server-provided (already\n * validated) path echoed back verbatim. Returns null when there is no active\n * session to attribute the download to.\n */\nexport function downloadFileUrl(path: string): string | null {\n\tconst state = get(piState);\n\tconst sessionId = state.sessionId;\n\tif (!sessionId) return null;\n\tconst baseUrl = getBaseUrl();\n\tconst token = getToken();\n\treturn (\n\t\t`${baseUrl}/session/download` +\n\t\t`?sessionId=${encodeURIComponent(sessionId)}` +\n\t\t`&path=${encodeURIComponent(path)}` +\n\t\t(token ? `&token=${encodeURIComponent(token)}` : '')\n\t);\n}\n\nexport async function uploadFile(\n\tsessionId: string,\n\tfile: File,\n): Promise<{savedPath: string; filename: string}> {\n\tconst method = get(uploadMethodStore);\n\tif (method === 'post') {\n\t\treturn uploadFileViaPost(sessionId, file);\n\t} else {\n\t\treturn uploadFileViaWebSocket(sessionId, file);\n\t}\n}\n\nexport async function deleteSession(sessionFile: string): Promise<void> {\n\ttry {\n\t\tconst baseUrl = getBaseUrl();\n\t\tconst token = getToken();\n\t\tconst url = `${baseUrl}/session/delete${token ? `?token=${encodeURIComponent(token)}` : ''}`;\n\n\t\tconst res = await fetch(url, {\n\t\t\tmethod: 'POST',\n\t\t\theaders: {\n\t\t\t\t'Content-Type': 'application/json',\n\t\t\t},\n\t\t\tbody: JSON.stringify({sessionFile}),\n\t\t});\n\n\t\tif (!res.ok) {\n\t\t\tconst errData = await res.json().catch(() => ({}));\n\t\t\tthrow new Error(\n\t\t\t\terrData.error || `Delete failed with status ${res.status}`,\n\t\t\t);\n\t\t}\n\t} catch (err) {\n\t\tconsole.error('Failed to delete session:', err);\n\t\tthrow err;\n\t}\n}\n","<script lang=\"ts\">\n\timport {\n\t\tconnect,\n\t\tdisconnect,\n\t\tgetConfig,\n\t\tsetConfig,\n\t\tisConnected,\n\t} from '$lib/wherever';\n\timport {playInvitingBeep} from '$lib/core/beep';\n\timport {onMount} from 'svelte';\n\n\tlet {\n\t\thost,\n\t\tport,\n\t\ttoken,\n\t\tonConnected,\n\t}: {\n\t\thost: string;\n\t\tport: number;\n\t\ttoken: string;\n\t\tonConnected: () => void;\n\t} = $props();\n\n\tlet localHost = $state('');\n\tlet localPort = $state(0);\n\tlet localToken = $state('');\n\tlet localHideThinking = $state(false);\n\tlet localBeepDefault = $state(false);\n\tlet localBeepSoundUrl = $state('');\n\tlet saving = $state(false);\n\tlet connected = $derived($isConnected);\n\n\tonMount(() => {\n\t\tconst config = getConfig();\n\t\tlocalHost = config.host;\n\t\tlocalPort = config.port;\n\t\tlocalToken = config.token || '';\n\t\tlocalHideThinking = !!config.hideThinking;\n\t\tlocalBeepDefault = !!config.beepDefault;\n\t\tlocalBeepSoundUrl = config.beepSoundUrl || '';\n\t});\n\n\tfunction handleTestBeep() {\n\t\tplayInvitingBeep(localBeepSoundUrl.trim() || undefined);\n\t}\n\n\tfunction handleConfigChange() {\n\t\tsetConfig({\n\t\t\thost: localHost,\n\t\t\tport: localPort,\n\t\t\ttoken: localToken,\n\t\t\thideThinking: localHideThinking,\n\t\t\t// Tool calls are always shown (the toggle was removed); force it off so a\n\t\t\t// previously-stored `true` is cleared.\n\t\t\thideTools: false,\n\t\t\tbeepDefault: localBeepDefault,\n\t\t\tbeepSoundUrl: localBeepSoundUrl.trim(),\n\t\t});\n\t}\n\n\tfunction handleConnect() {\n\t\tsetConfig({\n\t\t\thost: localHost,\n\t\t\tport: localPort,\n\t\t\ttoken: localToken,\n\t\t\thideThinking: localHideThinking,\n\t\t\thideTools: false,\n\t\t\tbeepDefault: localBeepDefault,\n\t\t\tbeepSoundUrl: localBeepSoundUrl.trim(),\n\t\t});\n\t\tdisconnect();\n\t\tsetTimeout(() => connect(), 100);\n\t}\n\n\tfunction handleDisconnect() {\n\t\tdisconnect();\n\t}\n\n\tfunction handleReload() {\n\t\twindow.location.reload();\n\t}\n</script>\n\n<div class=\"border-b border-brand-border p-4\">\n\t<div class=\"space-y-3\">\n\t\t<div>\n\t\t\t<label for=\"pi-host\" class=\"mb-1 block text-xs text-brand-text-muted\"\n\t\t\t\t>Host</label\n\t\t\t>\n\t\t\t<input\n\t\t\t\tid=\"pi-host\"\n\t\t\t\ttype=\"text\"\n\t\t\t\tbind:value={localHost}\n\t\t\t\tplaceholder=\"localhost\"\n\t\t\t\tclass=\"w-full rounded border border-brand-border bg-brand-surface-2 px-3 py-2 text-sm text-brand-text placeholder-brand-text-muted focus:border-brand-blue focus:outline-none\"\n\t\t\t/>\n\t\t</div>\n\n\t\t<div>\n\t\t\t<label for=\"pi-port\" class=\"mb-1 block text-xs text-brand-text-muted\"\n\t\t\t\t>Port</label\n\t\t\t>\n\t\t\t<input\n\t\t\t\tid=\"pi-port\"\n\t\t\t\ttype=\"number\"\n\t\t\t\tbind:value={localPort}\n\t\t\t\tclass=\"w-full rounded border border-brand-border bg-brand-surface-2 px-3 py-2 text-sm text-brand-text placeholder-brand-text-muted focus:border-brand-blue focus:outline-none\"\n\t\t\t/>\n\t\t</div>\n\n\t\t<div>\n\t\t\t<label for=\"pi-token\" class=\"mb-1 block text-xs text-brand-text-muted\"\n\t\t\t\t>Token (optional)</label\n\t\t\t>\n\t\t\t<input\n\t\t\t\tid=\"pi-token\"\n\t\t\t\ttype=\"password\"\n\t\t\t\tbind:value={localToken}\n\t\t\t\tplaceholder=\"Authentication token\"\n\t\t\t\tclass=\"w-full rounded border border-brand-border bg-brand-surface-2 px-3 py-2 text-sm text-brand-text placeholder-brand-text-muted focus:border-brand-blue focus:outline-none\"\n\t\t\t/>\n\t\t</div>\n\n\t\t<div class=\"flex items-center gap-2 py-1\">\n\t\t\t<input\n\t\t\t\tid=\"pi-hide-thinking\"\n\t\t\t\ttype=\"checkbox\"\n\t\t\t\tbind:checked={localHideThinking}\n\t\t\t\tonchange={handleConfigChange}\n\t\t\t\tclass=\"h-4 w-4 rounded border-brand-border bg-brand-surface-2 text-brand-blue focus:ring-brand-blue focus:ring-offset-0\"\n\t\t\t/>\n\t\t\t<label\n\t\t\t\tfor=\"pi-hide-thinking\"\n\t\t\t\tclass=\"cursor-pointer text-xs text-brand-text select-none\"\n\t\t\t>\n\t\t\t\tHide thinking steps\n\t\t\t</label>\n\t\t</div>\n\n\t\t<div class=\"flex items-center gap-2 py-1\">\n\t\t\t<input\n\t\t\t\tid=\"pi-beep-default\"\n\t\t\t\ttype=\"checkbox\"\n\t\t\t\tbind:checked={localBeepDefault}\n\t\t\t\tonchange={handleConfigChange}\n\t\t\t\tclass=\"h-4 w-4 rounded border-brand-border bg-brand-surface-2 text-brand-blue focus:ring-brand-blue focus:ring-offset-0\"\n\t\t\t/>\n\t\t\t<label\n\t\t\t\tfor=\"pi-beep-default\"\n\t\t\t\tclass=\"cursor-pointer text-xs text-brand-text select-none\"\n\t\t\t>\n\t\t\t\tBeep when the agent is waiting (default for new sessions)\n\t\t\t</label>\n\t\t</div>\n\n\t\t<div>\n\t\t\t<label\n\t\t\t\tfor=\"pi-beep-sound\"\n\t\t\t\tclass=\"mb-1 block text-xs text-brand-text-muted\"\n\t\t\t\t>Beep sound URL (optional, blank = built-in chime)</label\n\t\t\t>\n\t\t\t<div class=\"flex gap-2\">\n\t\t\t\t<input\n\t\t\t\t\tid=\"pi-beep-sound\"\n\t\t\t\t\ttype=\"text\"\n\t\t\t\t\tbind:value={localBeepSoundUrl}\n\t\t\t\t\tonchange={handleConfigChange}\n\t\t\t\t\tplaceholder=\"/sounds/complete.mp3 or https://...\"\n\t\t\t\t\tclass=\"w-full rounded border border-brand-border bg-brand-surface-2 px-3 py-2 text-sm text-brand-text placeholder-brand-text-muted focus:border-brand-blue focus:outline-none\"\n\t\t\t\t/>\n\t\t\t\t<button\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t\tonclick={handleTestBeep}\n\t\t\t\t\ttitle=\"Play the beep to test it\"\n\t\t\t\t\tclass=\"flex-shrink-0 rounded border border-brand-border bg-brand-surface-2 px-3 py-2 text-sm text-brand-text transition-colors hover:bg-brand-surface-3\"\n\t\t\t\t>\n\t\t\t\t\tTest\n\t\t\t\t</button>\n\t\t\t</div>\n\t\t</div>\n\n\t\t<div class=\"flex gap-2\">\n\t\t\t{#if connected}\n\t\t\t\t<button\n\t\t\t\t\tonclick={handleDisconnect}\n\t\t\t\t\tclass=\"flex-1 rounded bg-rose-500 px-4 py-2 text-sm text-white transition-colors hover:bg-rose-600\"\n\t\t\t\t>\n\t\t\t\t\tDisconnect\n\t\t\t\t</button>\n\t\t\t{:else}\n\t\t\t\t<button\n\t\t\t\t\tonclick={handleConnect}\n\t\t\t\t\tdisabled={saving}\n\t\t\t\t\tclass=\"flex-1 rounded bg-gradient-to-r from-brand-cyan to-brand-blue px-4 py-2 text-sm text-white transition-all hover:opacity-90 disabled:cursor-not-allowed disabled:from-brand-surface-3 disabled:to-brand-surface-3\"\n\t\t\t\t>\n\t\t\t\t\t{saving ? 'Connecting...' : 'Connect'}\n\t\t\t\t</button>\n\t\t\t{/if}\n\t\t</div>\n\n\t\t<button\n\t\t\tonclick={handleReload}\n\t\t\ttitle=\"Reload the page\"\n\t\t\tclass=\"flex w-full items-center justify-center gap-2 rounded border border-brand-border bg-brand-surface-2 px-4 py-2 text-sm text-brand-text transition-colors hover:bg-brand-surface-3\"\n\t\t>\n\t\t\t<svg\n\t\t\t\txmlns=\"http://www.w3.org/2000/svg\"\n\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\tfill=\"none\"\n\t\t\t\tstroke=\"currentColor\"\n\t\t\t\tstroke-width=\"2\"\n\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\tclass=\"h-4 w-4\"\n\t\t\t\taria-hidden=\"true\"\n\t\t\t>\n\t\t\t\t<path d=\"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8\" />\n\t\t\t\t<path d=\"M21 3v5h-5\" />\n\t\t\t\t<path d=\"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16\" />\n\t\t\t\t<path d=\"M8 16H3v5\" />\n\t\t\t</svg>\n\t\t\tReload\n\t\t</button>\n\t</div>\n</div>\n","/**\n * marked v15.0.12 - a markdown parser\n * Copyright (c) 2011-2025, Christopher Jeffrey. (MIT Licensed)\n * https://github.com/markedjs/marked\n */\n\n/**\n * DO NOT EDIT THIS FILE\n * The code in this file is generated from files in ./src/\n */\n\n\n// src/defaults.ts\nfunction _getDefaults() {\n return {\n async: false,\n breaks: false,\n extensions: null,\n gfm: true,\n hooks: null,\n pedantic: false,\n renderer: null,\n silent: false,\n tokenizer: null,\n walkTokens: null\n };\n}\nvar _defaults = _getDefaults();\nfunction changeDefaults(newDefaults) {\n _defaults = newDefaults;\n}\n\n// src/rules.ts\nvar noopTest = { exec: () => null };\nfunction edit(regex, opt = \"\") {\n let source = typeof regex === \"string\" ? regex : regex.source;\n const obj = {\n replace: (name, val) => {\n let valSource = typeof val === \"string\" ? val : val.source;\n valSource = valSource.replace(other.caret, \"$1\");\n source = source.replace(name, valSource);\n return obj;\n },\n getRegex: () => {\n return new RegExp(source, opt);\n }\n };\n return obj;\n}\nvar other = {\n codeRemoveIndent: /^(?: {1,4}| {0,3}\\t)/gm,\n outputLinkReplace: /\\\\([\\[\\]])/g,\n indentCodeCompensation: /^(\\s+)(?:```)/,\n beginningSpace: /^\\s+/,\n endingHash: /#$/,\n startingSpaceChar: /^ /,\n endingSpaceChar: / $/,\n nonSpaceChar: /[^ ]/,\n newLineCharGlobal: /\\n/g,\n tabCharGlobal: /\\t/g,\n multipleSpaceGlobal: /\\s+/g,\n blankLine: /^[ \\t]*$/,\n doubleBlankLine: /\\n[ \\t]*\\n[ \\t]*$/,\n blockquoteStart: /^ {0,3}>/,\n blockquoteSetextReplace: /\\n {0,3}((?:=+|-+) *)(?=\\n|$)/g,\n blockquoteSetextReplace2: /^ {0,3}>[ \\t]?/gm,\n listReplaceTabs: /^\\t+/,\n listReplaceNesting: /^ {1,4}(?=( {4})*[^ ])/g,\n listIsTask: /^\\[[ xX]\\] /,\n listReplaceTask: /^\\[[ xX]\\] +/,\n anyLine: /\\n.*\\n/,\n hrefBrackets: /^<(.*)>$/,\n tableDelimiter: /[:|]/,\n tableAlignChars: /^\\||\\| *$/g,\n tableRowBlankLine: /\\n[ \\t]*$/,\n tableAlignRight: /^ *-+: *$/,\n tableAlignCenter: /^ *:-+: *$/,\n tableAlignLeft: /^ *:-+ *$/,\n startATag: /^<a /i,\n endATag: /^<\\/a>/i,\n startPreScriptTag: /^<(pre|code|kbd|script)(\\s|>)/i,\n endPreScriptTag: /^<\\/(pre|code|kbd|script)(\\s|>)/i,\n startAngleBracket: /^</,\n endAngleBracket: />$/,\n pedanticHrefTitle: /^([^'\"]*[^\\s])\\s+(['\"])(.*)\\2/,\n unicodeAlphaNumeric: /[\\p{L}\\p{N}]/u,\n escapeTest: /[&<>\"']/,\n escapeReplace: /[&<>\"']/g,\n escapeTestNoEncode: /[<>\"']|&(?!(#\\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\\w+);)/,\n escapeReplaceNoEncode: /[<>\"']|&(?!(#\\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\\w+);)/g,\n unescapeTest: /&(#(?:\\d+)|(?:#x[0-9A-Fa-f]+)|(?:\\w+));?/ig,\n caret: /(^|[^\\[])\\^/g,\n percentDecode: /%25/g,\n findPipe: /\\|/g,\n splitPipe: / \\|/,\n slashPipe: /\\\\\\|/g,\n carriageReturn: /\\r\\n|\\r/g,\n spaceLine: /^ +$/gm,\n notSpaceStart: /^\\S*/,\n endingNewline: /\\n$/,\n listItemRegex: (bull) => new RegExp(`^( {0,3}${bull})((?:[\t ][^\\\\n]*)?(?:\\\\n|$))`),\n nextBulletRegex: (indent) => new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:[*+-]|\\\\d{1,9}[.)])((?:[ \t][^\\\\n]*)?(?:\\\\n|$))`),\n hrRegex: (indent) => new RegExp(`^ {0,${Math.min(3, indent - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\\\* *){3,})(?:\\\\n+|$)`),\n fencesBeginRegex: (indent) => new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:\\`\\`\\`|~~~)`),\n headingBeginRegex: (indent) => new RegExp(`^ {0,${Math.min(3, indent - 1)}}#`),\n htmlBeginRegex: (indent) => new RegExp(`^ {0,${Math.min(3, indent - 1)}}<(?:[a-z].*>|!--)`, \"i\")\n};\nvar newline = /^(?:[ \\t]*(?:\\n|$))+/;\nvar blockCode = /^((?: {4}| {0,3}\\t)[^\\n]+(?:\\n(?:[ \\t]*(?:\\n|$))*)?)+/;\nvar fences = /^ {0,3}(`{3,}(?=[^`\\n]*(?:\\n|$))|~{3,})([^\\n]*)(?:\\n|$)(?:|([\\s\\S]*?)(?:\\n|$))(?: {0,3}\\1[~`]* *(?=\\n|$)|$)/;\nvar hr = /^ {0,3}((?:-[\\t ]*){3,}|(?:_[ \\t]*){3,}|(?:\\*[ \\t]*){3,})(?:\\n+|$)/;\nvar heading = /^ {0,3}(#{1,6})(?=\\s|$)(.*)(?:\\n+|$)/;\nvar bullet = /(?:[*+-]|\\d{1,9}[.)])/;\nvar lheadingCore = /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\\n(?!\\s*?\\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\\n {0,3}(=+|-+) *(?:\\n+|$)/;\nvar lheading = edit(lheadingCore).replace(/bull/g, bullet).replace(/blockCode/g, /(?: {4}| {0,3}\\t)/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}/).replace(/html/g, / {0,3}<[^\\n>]+>\\n/).replace(/\\|table/g, \"\").getRegex();\nvar lheadingGfm = edit(lheadingCore).replace(/bull/g, bullet).replace(/blockCode/g, /(?: {4}| {0,3}\\t)/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}/).replace(/html/g, / {0,3}<[^\\n>]+>\\n/).replace(/table/g, / {0,3}\\|?(?:[:\\- ]*\\|)+[\\:\\- ]*\\n/).getRegex();\nvar _paragraph = /^([^\\n]+(?:\\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\\n)[^\\n]+)*)/;\nvar blockText = /^[^\\n]+/;\nvar _blockLabel = /(?!\\s*\\])(?:\\\\.|[^\\[\\]\\\\])+/;\nvar def = edit(/^ {0,3}\\[(label)\\]: *(?:\\n[ \\t]*)?([^<\\s][^\\s]*|<.*?>)(?:(?: +(?:\\n[ \\t]*)?| *\\n[ \\t]*)(title))? *(?:\\n+|$)/).replace(\"label\", _blockLabel).replace(\"title\", /(?:\"(?:\\\\\"?|[^\"\\\\])*\"|'[^'\\n]*(?:\\n[^'\\n]+)*\\n?'|\\([^()]*\\))/).getRegex();\nvar list = edit(/^( {0,3}bull)([ \\t][^\\n]+?)?(?:\\n|$)/).replace(/bull/g, bullet).getRegex();\nvar _tag = \"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|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul\";\nvar _comment = /<!--(?:-?>|[\\s\\S]*?(?:-->|$))/;\nvar html = edit(\n \"^ {0,3}(?:<(script|pre|style|textarea)[\\\\s>][\\\\s\\\\S]*?(?:</\\\\1>[^\\\\n]*\\\\n+|$)|comment[^\\\\n]*(\\\\n+|$)|<\\\\?[\\\\s\\\\S]*?(?:\\\\?>\\\\n*|$)|<![A-Z][\\\\s\\\\S]*?(?:>\\\\n*|$)|<!\\\\[CDATA\\\\[[\\\\s\\\\S]*?(?:\\\\]\\\\]>\\\\n*|$)|</?(tag)(?: +|\\\\n|/?>)[\\\\s\\\\S]*?(?:(?:\\\\n[ \t]*)+\\\\n|$)|<(?!script|pre|style|textarea)([a-z][\\\\w-]*)(?:attribute)*? */?>(?=[ \\\\t]*(?:\\\\n|$))[\\\\s\\\\S]*?(?:(?:\\\\n[ \t]*)+\\\\n|$)|</(?!script|pre|style|textarea)[a-z][\\\\w-]*\\\\s*>(?=[ \\\\t]*(?:\\\\n|$))[\\\\s\\\\S]*?(?:(?:\\\\n[ \t]*)+\\\\n|$))\",\n \"i\"\n).replace(\"comment\", _comment).replace(\"tag\", _tag).replace(\"attribute\", / +[a-zA-Z:_][\\w.:-]*(?: *= *\"[^\"\\n]*\"| *= *'[^'\\n]*'| *= *[^\\s\"'=<>`]+)?/).getRegex();\nvar paragraph = edit(_paragraph).replace(\"hr\", hr).replace(\"heading\", \" {0,3}#{1,6}(?:\\\\s|$)\").replace(\"|lheading\", \"\").replace(\"|table\", \"\").replace(\"blockquote\", \" {0,3}>\").replace(\"fences\", \" {0,3}(?:`{3,}(?=[^`\\\\n]*\\\\n)|~{3,})[^\\\\n]*\\\\n\").replace(\"list\", \" {0,3}(?:[*+-]|1[.)]) \").replace(\"html\", \"</?(?:tag)(?: +|\\\\n|/?>)|<(?:script|pre|style|textarea|!--)\").replace(\"tag\", _tag).getRegex();\nvar blockquote = edit(/^( {0,3}> ?(paragraph|[^\\n]*)(?:\\n|$))+/).replace(\"paragraph\", paragraph).getRegex();\nvar blockNormal = {\n blockquote,\n code: blockCode,\n def,\n fences,\n heading,\n hr,\n html,\n lheading,\n list,\n newline,\n paragraph,\n table: noopTest,\n text: blockText\n};\nvar gfmTable = edit(\n \"^ *([^\\\\n ].*)\\\\n {0,3}((?:\\\\| *)?:?-+:? *(?:\\\\| *:?-+:? *)*(?:\\\\| *)?)(?:\\\\n((?:(?! *\\\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\\\n|$))*)\\\\n*|$)\"\n).replace(\"hr\", hr).replace(\"heading\", \" {0,3}#{1,6}(?:\\\\s|$)\").replace(\"blockquote\", \" {0,3}>\").replace(\"code\", \"(?: {4}| {0,3}\t)[^\\\\n]\").replace(\"fences\", \" {0,3}(?:`{3,}(?=[^`\\\\n]*\\\\n)|~{3,})[^\\\\n]*\\\\n\").replace(\"list\", \" {0,3}(?:[*+-]|1[.)]) \").replace(\"html\", \"</?(?:tag)(?: +|\\\\n|/?>)|<(?:script|pre|style|textarea|!--)\").replace(\"tag\", _tag).getRegex();\nvar blockGfm = {\n ...blockNormal,\n lheading: lheadingGfm,\n table: gfmTable,\n paragraph: edit(_paragraph).replace(\"hr\", hr).replace(\"heading\", \" {0,3}#{1,6}(?:\\\\s|$)\").replace(\"|lheading\", \"\").replace(\"table\", gfmTable).replace(\"blockquote\", \" {0,3}>\").replace(\"fences\", \" {0,3}(?:`{3,}(?=[^`\\\\n]*\\\\n)|~{3,})[^\\\\n]*\\\\n\").replace(\"list\", \" {0,3}(?:[*+-]|1[.)]) \").replace(\"html\", \"</?(?:tag)(?: +|\\\\n|/?>)|<(?:script|pre|style|textarea|!--)\").replace(\"tag\", _tag).getRegex()\n};\nvar blockPedantic = {\n ...blockNormal,\n html: edit(\n `^ *(?:comment *(?:\\\\n|\\\\s*$)|<(tag)[\\\\s\\\\S]+?</\\\\1> *(?:\\\\n{2,}|\\\\s*$)|<tag(?:\"[^\"]*\"|'[^']*'|\\\\s[^'\"/>\\\\s]*)*?/?> *(?:\\\\n{2,}|\\\\s*$))`\n ).replace(\"comment\", _comment).replace(/tag/g, \"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\\\b)\\\\w+(?!:|[^\\\\w\\\\s@]*@)\\\\b\").getRegex(),\n def: /^ *\\[([^\\]]+)\\]: *<?([^\\s>]+)>?(?: +([\"(][^\\n]+[\")]))? *(?:\\n+|$)/,\n heading: /^(#{1,6})(.*)(?:\\n+|$)/,\n fences: noopTest,\n // fences not supported\n lheading: /^(.+?)\\n {0,3}(=+|-+) *(?:\\n+|$)/,\n paragraph: edit(_paragraph).replace(\"hr\", hr).replace(\"heading\", \" *#{1,6} *[^\\n]\").replace(\"lheading\", lheading).replace(\"|table\", \"\").replace(\"blockquote\", \" {0,3}>\").replace(\"|fences\", \"\").replace(\"|list\", \"\").replace(\"|html\", \"\").replace(\"|tag\", \"\").getRegex()\n};\nvar escape = /^\\\\([!\"#$%&'()*+,\\-./:;<=>?@\\[\\]\\\\^_`{|}~])/;\nvar inlineCode = /^(`+)([^`]|[^`][\\s\\S]*?[^`])\\1(?!`)/;\nvar br = /^( {2,}|\\\\)\\n(?!\\s*$)/;\nvar inlineText = /^(`+|[^`])(?:(?= {2,}\\n)|[\\s\\S]*?(?:(?=[\\\\<!\\[`*_]|\\b_|$)|[^ ](?= {2,}\\n)))/;\nvar _punctuation = /[\\p{P}\\p{S}]/u;\nvar _punctuationOrSpace = /[\\s\\p{P}\\p{S}]/u;\nvar _notPunctuationOrSpace = /[^\\s\\p{P}\\p{S}]/u;\nvar punctuation = edit(/^((?![*_])punctSpace)/, \"u\").replace(/punctSpace/g, _punctuationOrSpace).getRegex();\nvar _punctuationGfmStrongEm = /(?!~)[\\p{P}\\p{S}]/u;\nvar _punctuationOrSpaceGfmStrongEm = /(?!~)[\\s\\p{P}\\p{S}]/u;\nvar _notPunctuationOrSpaceGfmStrongEm = /(?:[^\\s\\p{P}\\p{S}]|~)/u;\nvar blockSkip = /\\[[^[\\]]*?\\]\\((?:\\\\.|[^\\\\\\(\\)]|\\((?:\\\\.|[^\\\\\\(\\)])*\\))*\\)|`[^`]*?`|<[^<>]*?>/g;\nvar emStrongLDelimCore = /^(?:\\*+(?:((?!\\*)punct)|[^\\s*]))|^_+(?:((?!_)punct)|([^\\s_]))/;\nvar emStrongLDelim = edit(emStrongLDelimCore, \"u\").replace(/punct/g, _punctuation).getRegex();\nvar emStrongLDelimGfm = edit(emStrongLDelimCore, \"u\").replace(/punct/g, _punctuationGfmStrongEm).getRegex();\nvar emStrongRDelimAstCore = \"^[^_*]*?__[^_*]*?\\\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\\\*)punct(\\\\*+)(?=[\\\\s]|$)|notPunctSpace(\\\\*+)(?!\\\\*)(?=punctSpace|$)|(?!\\\\*)punctSpace(\\\\*+)(?=notPunctSpace)|[\\\\s](\\\\*+)(?!\\\\*)(?=punct)|(?!\\\\*)punct(\\\\*+)(?!\\\\*)(?=punct)|notPunctSpace(\\\\*+)(?=notPunctSpace)\";\nvar emStrongRDelimAst = edit(emStrongRDelimAstCore, \"gu\").replace(/notPunctSpace/g, _notPunctuationOrSpace).replace(/punctSpace/g, _punctuationOrSpace).replace(/punct/g, _punctuation).getRegex();\nvar emStrongRDelimAstGfm = edit(emStrongRDelimAstCore, \"gu\").replace(/notPunctSpace/g, _notPunctuationOrSpaceGfmStrongEm).replace(/punctSpace/g, _punctuationOrSpaceGfmStrongEm).replace(/punct/g, _punctuationGfmStrongEm).getRegex();\nvar emStrongRDelimUnd = edit(\n \"^[^_*]*?\\\\*\\\\*[^_*]*?_[^_*]*?(?=\\\\*\\\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)\",\n \"gu\"\n).replace(/notPunctSpace/g, _notPunctuationOrSpace).replace(/punctSpace/g, _punctuationOrSpace).replace(/punct/g, _punctuation).getRegex();\nvar anyPunctuation = edit(/\\\\(punct)/, \"gu\").replace(/punct/g, _punctuation).getRegex();\nvar autolink = edit(/^<(scheme:[^\\s\\x00-\\x1f<>]*|email)>/).replace(\"scheme\", /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace(\"email\", /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex();\nvar _inlineComment = edit(_comment).replace(\"(?:-->|$)\", \"-->\").getRegex();\nvar tag = edit(\n \"^comment|^</[a-zA-Z][\\\\w:-]*\\\\s*>|^<[a-zA-Z][\\\\w-]*(?:attribute)*?\\\\s*/?>|^<\\\\?[\\\\s\\\\S]*?\\\\?>|^<![a-zA-Z]+\\\\s[\\\\s\\\\S]*?>|^<!\\\\[CDATA\\\\[[\\\\s\\\\S]*?\\\\]\\\\]>\"\n).replace(\"comment\", _inlineComment).replace(\"attribute\", /\\s+[a-zA-Z:_][\\w.:-]*(?:\\s*=\\s*\"[^\"]*\"|\\s*=\\s*'[^']*'|\\s*=\\s*[^\\s\"'=<>`]+)?/).getRegex();\nvar _inlineLabel = /(?:\\[(?:\\\\.|[^\\[\\]\\\\])*\\]|\\\\.|`[^`]*`|[^\\[\\]\\\\`])*?/;\nvar link = edit(/^!?\\[(label)\\]\\(\\s*(href)(?:(?:[ \\t]*(?:\\n[ \\t]*)?)(title))?\\s*\\)/).replace(\"label\", _inlineLabel).replace(\"href\", /<(?:\\\\.|[^\\n<>\\\\])+>|[^ \\t\\n\\x00-\\x1f]*/).replace(\"title\", /\"(?:\\\\\"?|[^\"\\\\])*\"|'(?:\\\\'?|[^'\\\\])*'|\\((?:\\\\\\)?|[^)\\\\])*\\)/).getRegex();\nvar reflink = edit(/^!?\\[(label)\\]\\[(ref)\\]/).replace(\"label\", _inlineLabel).replace(\"ref\", _blockLabel).getRegex();\nvar nolink = edit(/^!?\\[(ref)\\](?:\\[\\])?/).replace(\"ref\", _blockLabel).getRegex();\nvar reflinkSearch = edit(\"reflink|nolink(?!\\\\()\", \"g\").replace(\"reflink\", reflink).replace(\"nolink\", nolink).getRegex();\nvar inlineNormal = {\n _backpedal: noopTest,\n // only used for GFM url\n anyPunctuation,\n autolink,\n blockSkip,\n br,\n code: inlineCode,\n del: noopTest,\n emStrongLDelim,\n emStrongRDelimAst,\n emStrongRDelimUnd,\n escape,\n link,\n nolink,\n punctuation,\n reflink,\n reflinkSearch,\n tag,\n text: inlineText,\n url: noopTest\n};\nvar inlinePedantic = {\n ...inlineNormal,\n link: edit(/^!?\\[(label)\\]\\((.*?)\\)/).replace(\"label\", _inlineLabel).getRegex(),\n reflink: edit(/^!?\\[(label)\\]\\s*\\[([^\\]]*)\\]/).replace(\"label\", _inlineLabel).getRegex()\n};\nvar inlineGfm = {\n ...inlineNormal,\n emStrongRDelimAst: emStrongRDelimAstGfm,\n emStrongLDelim: emStrongLDelimGfm,\n url: edit(/^((?:ftp|https?):\\/\\/|www\\.)(?:[a-zA-Z0-9\\-]+\\.?)+[^\\s<]*|^email/, \"i\").replace(\"email\", /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),\n _backpedal: /(?:[^?!.,:;*_'\"~()&]+|\\([^)]*\\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'\"~)]+(?!$))+/,\n del: /^(~~?)(?=[^\\s~])((?:\\\\.|[^\\\\])*?(?:\\\\.|[^\\s~\\\\]))\\1(?=[^~]|$)/,\n text: /^([`~]+|[^`~])(?:(?= {2,}\\n)|(?=[a-zA-Z0-9.!#$%&'*+\\/=?_`{\\|}~-]+@)|[\\s\\S]*?(?:(?=[\\\\<!\\[`*~_]|\\b_|https?:\\/\\/|ftp:\\/\\/|www\\.|$)|[^ ](?= {2,}\\n)|[^a-zA-Z0-9.!#$%&'*+\\/=?_`{\\|}~-](?=[a-zA-Z0-9.!#$%&'*+\\/=?_`{\\|}~-]+@)))/\n};\nvar inlineBreaks = {\n ...inlineGfm,\n br: edit(br).replace(\"{2,}\", \"*\").getRegex(),\n text: edit(inlineGfm.text).replace(\"\\\\b_\", \"\\\\b_| {2,}\\\\n\").replace(/\\{2,\\}/g, \"*\").getRegex()\n};\nvar block = {\n normal: blockNormal,\n gfm: blockGfm,\n pedantic: blockPedantic\n};\nvar inline = {\n normal: inlineNormal,\n gfm: inlineGfm,\n breaks: inlineBreaks,\n pedantic: inlinePedantic\n};\n\n// src/helpers.ts\nvar escapeReplacements = {\n \"&\": \"&\",\n \"<\": \"<\",\n \">\": \">\",\n '\"': \""\",\n \"'\": \"'\"\n};\nvar getEscapeReplacement = (ch) => escapeReplacements[ch];\nfunction escape2(html2, encode) {\n if (encode) {\n if (other.escapeTest.test(html2)) {\n return html2.replace(other.escapeReplace, getEscapeReplacement);\n }\n } else {\n if (other.escapeTestNoEncode.test(html2)) {\n return html2.replace(other.escapeReplaceNoEncode, getEscapeReplacement);\n }\n }\n return html2;\n}\nfunction cleanUrl(href) {\n try {\n href = encodeURI(href).replace(other.percentDecode, \"%\");\n } catch {\n return null;\n }\n return href;\n}\nfunction splitCells(tableRow, count) {\n const row = tableRow.replace(other.findPipe, (match, offset, str) => {\n let escaped = false;\n let curr = offset;\n while (--curr >= 0 && str[curr] === \"\\\\\") escaped = !escaped;\n if (escaped) {\n return \"|\";\n } else {\n return \" |\";\n }\n }), cells = row.split(other.splitPipe);\n let i = 0;\n if (!cells[0].trim()) {\n cells.shift();\n }\n if (cells.length > 0 && !cells.at(-1)?.trim()) {\n cells.pop();\n }\n if (count) {\n if (cells.length > count) {\n cells.splice(count);\n } else {\n while (cells.length < count) cells.push(\"\");\n }\n }\n for (; i < cells.length; i++) {\n cells[i] = cells[i].trim().replace(other.slashPipe, \"|\");\n }\n return cells;\n}\nfunction rtrim(str, c, invert) {\n const l = str.length;\n if (l === 0) {\n return \"\";\n }\n let suffLen = 0;\n while (suffLen < l) {\n const currChar = str.charAt(l - suffLen - 1);\n if (currChar === c && !invert) {\n suffLen++;\n } else if (currChar !== c && invert) {\n suffLen++;\n } else {\n break;\n }\n }\n return str.slice(0, l - suffLen);\n}\nfunction findClosingBracket(str, b) {\n if (str.indexOf(b[1]) === -1) {\n return -1;\n }\n let level = 0;\n for (let i = 0; i < str.length; i++) {\n if (str[i] === \"\\\\\") {\n i++;\n } else if (str[i] === b[0]) {\n level++;\n } else if (str[i] === b[1]) {\n level--;\n if (level < 0) {\n return i;\n }\n }\n }\n if (level > 0) {\n return -2;\n }\n return -1;\n}\n\n// src/Tokenizer.ts\nfunction outputLink(cap, link2, raw, lexer2, rules) {\n const href = link2.href;\n const title = link2.title || null;\n const text = cap[1].replace(rules.other.outputLinkReplace, \"$1\");\n lexer2.state.inLink = true;\n const token = {\n type: cap[0].charAt(0) === \"!\" ? \"image\" : \"link\",\n raw,\n href,\n title,\n text,\n tokens: lexer2.inlineTokens(text)\n };\n lexer2.state.inLink = false;\n return token;\n}\nfunction indentCodeCompensation(raw, text, rules) {\n const matchIndentToCode = raw.match(rules.other.indentCodeCompensation);\n if (matchIndentToCode === null) {\n return text;\n }\n const indentToCode = matchIndentToCode[1];\n return text.split(\"\\n\").map((node) => {\n const matchIndentInNode = node.match(rules.other.beginningSpace);\n if (matchIndentInNode === null) {\n return node;\n }\n const [indentInNode] = matchIndentInNode;\n if (indentInNode.length >= indentToCode.length) {\n return node.slice(indentToCode.length);\n }\n return node;\n }).join(\"\\n\");\n}\nvar _Tokenizer = class {\n options;\n rules;\n // set by the lexer\n lexer;\n // set by the lexer\n constructor(options2) {\n this.options = options2 || _defaults;\n }\n space(src) {\n const cap = this.rules.block.newline.exec(src);\n if (cap && cap[0].length > 0) {\n return {\n type: \"space\",\n raw: cap[0]\n };\n }\n }\n code(src) {\n const cap = this.rules.block.code.exec(src);\n if (cap) {\n const text = cap[0].replace(this.rules.other.codeRemoveIndent, \"\");\n return {\n type: \"code\",\n raw: cap[0],\n codeBlockStyle: \"indented\",\n text: !this.options.pedantic ? rtrim(text, \"\\n\") : text\n };\n }\n }\n fences(src) {\n const cap = this.rules.block.fences.exec(src);\n if (cap) {\n const raw = cap[0];\n const text = indentCodeCompensation(raw, cap[3] || \"\", this.rules);\n return {\n type: \"code\",\n raw,\n lang: cap[2] ? cap[2].trim().replace(this.rules.inline.anyPunctuation, \"$1\") : cap[2],\n text\n };\n }\n }\n heading(src) {\n const cap = this.rules.block.heading.exec(src);\n if (cap) {\n let text = cap[2].trim();\n if (this.rules.other.endingHash.test(text)) {\n const trimmed = rtrim(text, \"#\");\n if (this.options.pedantic) {\n text = trimmed.trim();\n } else if (!trimmed || this.rules.other.endingSpaceChar.test(trimmed)) {\n text = trimmed.trim();\n }\n }\n return {\n type: \"heading\",\n raw: cap[0],\n depth: cap[1].length,\n text,\n tokens: this.lexer.inline(text)\n };\n }\n }\n hr(src) {\n const cap = this.rules.block.hr.exec(src);\n if (cap) {\n return {\n type: \"hr\",\n raw: rtrim(cap[0], \"\\n\")\n };\n }\n }\n blockquote(src) {\n const cap = this.rules.block.blockquote.exec(src);\n if (cap) {\n let lines = rtrim(cap[0], \"\\n\").split(\"\\n\");\n let raw = \"\";\n let text = \"\";\n const tokens = [];\n while (lines.length > 0) {\n let inBlockquote = false;\n const currentLines = [];\n let i;\n for (i = 0; i < lines.length; i++) {\n if (this.rules.other.blockquoteStart.test(lines[i])) {\n currentLines.push(lines[i]);\n inBlockquote = true;\n } else if (!inBlockquote) {\n currentLines.push(lines[i]);\n } else {\n break;\n }\n }\n lines = lines.slice(i);\n const currentRaw = currentLines.join(\"\\n\");\n const currentText = currentRaw.replace(this.rules.other.blockquoteSetextReplace, \"\\n $1\").replace(this.rules.other.blockquoteSetextReplace2, \"\");\n raw = raw ? `${raw}\n${currentRaw}` : currentRaw;\n text = text ? `${text}\n${currentText}` : currentText;\n const top = this.lexer.state.top;\n this.lexer.state.top = true;\n this.lexer.blockTokens(currentText, tokens, true);\n this.lexer.state.top = top;\n if (lines.length === 0) {\n break;\n }\n const lastToken = tokens.at(-1);\n if (lastToken?.type === \"code\") {\n break;\n } else if (lastToken?.type === \"blockquote\") {\n const oldToken = lastToken;\n const newText = oldToken.raw + \"\\n\" + lines.join(\"\\n\");\n const newToken = this.blockquote(newText);\n tokens[tokens.length - 1] = newToken;\n raw = raw.substring(0, raw.length - oldToken.raw.length) + newToken.raw;\n text = text.substring(0, text.length - oldToken.text.length) + newToken.text;\n break;\n } else if (lastToken?.type === \"list\") {\n const oldToken = lastToken;\n const newText = oldToken.raw + \"\\n\" + lines.join(\"\\n\");\n const newToken = this.list(newText);\n tokens[tokens.length - 1] = newToken;\n raw = raw.substring(0, raw.length - lastToken.raw.length) + newToken.raw;\n text = text.substring(0, text.length - oldToken.raw.length) + newToken.raw;\n lines = newText.substring(tokens.at(-1).raw.length).split(\"\\n\");\n continue;\n }\n }\n return {\n type: \"blockquote\",\n raw,\n tokens,\n text\n };\n }\n }\n list(src) {\n let cap = this.rules.block.list.exec(src);\n if (cap) {\n let bull = cap[1].trim();\n const isordered = bull.length > 1;\n const list2 = {\n type: \"list\",\n raw: \"\",\n ordered: isordered,\n start: isordered ? +bull.slice(0, -1) : \"\",\n loose: false,\n items: []\n };\n bull = isordered ? `\\\\d{1,9}\\\\${bull.slice(-1)}` : `\\\\${bull}`;\n if (this.options.pedantic) {\n bull = isordered ? bull : \"[*+-]\";\n }\n const itemRegex = this.rules.other.listItemRegex(bull);\n let endsWithBlankLine = false;\n while (src) {\n let endEarly = false;\n let raw = \"\";\n let itemContents = \"\";\n if (!(cap = itemRegex.exec(src))) {\n break;\n }\n if (this.rules.block.hr.test(src)) {\n break;\n }\n raw = cap[0];\n src = src.substring(raw.length);\n let line = cap[2].split(\"\\n\", 1)[0].replace(this.rules.other.listReplaceTabs, (t) => \" \".repeat(3 * t.length));\n let nextLine = src.split(\"\\n\", 1)[0];\n let blankLine = !line.trim();\n let indent = 0;\n if (this.options.pedantic) {\n indent = 2;\n itemContents = line.trimStart();\n } else if (blankLine) {\n indent = cap[1].length + 1;\n } else {\n indent = cap[2].search(this.rules.other.nonSpaceChar);\n indent = indent > 4 ? 1 : indent;\n itemContents = line.slice(indent);\n indent += cap[1].length;\n }\n if (blankLine && this.rules.other.blankLine.test(nextLine)) {\n raw += nextLine + \"\\n\";\n src = src.substring(nextLine.length + 1);\n endEarly = true;\n }\n if (!endEarly) {\n const nextBulletRegex = this.rules.other.nextBulletRegex(indent);\n const hrRegex = this.rules.other.hrRegex(indent);\n const fencesBeginRegex = this.rules.other.fencesBeginRegex(indent);\n const headingBeginRegex = this.rules.other.headingBeginRegex(indent);\n const htmlBeginRegex = this.rules.other.htmlBeginRegex(indent);\n while (src) {\n const rawLine = src.split(\"\\n\", 1)[0];\n let nextLineWithoutTabs;\n nextLine = rawLine;\n if (this.options.pedantic) {\n nextLine = nextLine.replace(this.rules.other.listReplaceNesting, \" \");\n nextLineWithoutTabs = nextLine;\n } else {\n nextLineWithoutTabs = nextLine.replace(this.rules.other.tabCharGlobal, \" \");\n }\n if (fencesBeginRegex.test(nextLine)) {\n break;\n }\n if (headingBeginRegex.test(nextLine)) {\n break;\n }\n if (htmlBeginRegex.test(nextLine)) {\n break;\n }\n if (nextBulletRegex.test(nextLine)) {\n break;\n }\n if (hrRegex.test(nextLine)) {\n break;\n }\n if (nextLineWithoutTabs.search(this.rules.other.nonSpaceChar) >= indent || !nextLine.trim()) {\n itemContents += \"\\n\" + nextLineWithoutTabs.slice(indent);\n } else {\n if (blankLine) {\n break;\n }\n if (line.replace(this.rules.other.tabCharGlobal, \" \").search(this.rules.other.nonSpaceChar) >= 4) {\n break;\n }\n if (fencesBeginRegex.test(line)) {\n break;\n }\n if (headingBeginRegex.test(line)) {\n break;\n }\n if (hrRegex.test(line)) {\n break;\n }\n itemContents += \"\\n\" + nextLine;\n }\n if (!blankLine && !nextLine.trim()) {\n blankLine = true;\n }\n raw += rawLine + \"\\n\";\n src = src.substring(rawLine.length + 1);\n line = nextLineWithoutTabs.slice(indent);\n }\n }\n if (!list2.loose) {\n if (endsWithBlankLine) {\n list2.loose = true;\n } else if (this.rules.other.doubleBlankLine.test(raw)) {\n endsWithBlankLine = true;\n }\n }\n let istask = null;\n let ischecked;\n if (this.options.gfm) {\n istask = this.rules.other.listIsTask.exec(itemContents);\n if (istask) {\n ischecked = istask[0] !== \"[ ] \";\n itemContents = itemContents.replace(this.rules.other.listReplaceTask, \"\");\n }\n }\n list2.items.push({\n type: \"list_item\",\n raw,\n task: !!istask,\n checked: ischecked,\n loose: false,\n text: itemContents,\n tokens: []\n });\n list2.raw += raw;\n }\n const lastItem = list2.items.at(-1);\n if (lastItem) {\n lastItem.raw = lastItem.raw.trimEnd();\n lastItem.text = lastItem.text.trimEnd();\n } else {\n return;\n }\n list2.raw = list2.raw.trimEnd();\n for (let i = 0; i < list2.items.length; i++) {\n this.lexer.state.top = false;\n list2.items[i].tokens = this.lexer.blockTokens(list2.items[i].text, []);\n if (!list2.loose) {\n const spacers = list2.items[i].tokens.filter((t) => t.type === \"space\");\n const hasMultipleLineBreaks = spacers.length > 0 && spacers.some((t) => this.rules.other.anyLine.test(t.raw));\n list2.loose = hasMultipleLineBreaks;\n }\n }\n if (list2.loose) {\n for (let i = 0; i < list2.items.length; i++) {\n list2.items[i].loose = true;\n }\n }\n return list2;\n }\n }\n html(src) {\n const cap = this.rules.block.html.exec(src);\n if (cap) {\n const token = {\n type: \"html\",\n block: true,\n raw: cap[0],\n pre: cap[1] === \"pre\" || cap[1] === \"script\" || cap[1] === \"style\",\n text: cap[0]\n };\n return token;\n }\n }\n def(src) {\n const cap = this.rules.block.def.exec(src);\n if (cap) {\n const tag2 = cap[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal, \" \");\n const href = cap[2] ? cap[2].replace(this.rules.other.hrefBrackets, \"$1\").replace(this.rules.inline.anyPunctuation, \"$1\") : \"\";\n const title = cap[3] ? cap[3].substring(1, cap[3].length - 1).replace(this.rules.inline.anyPunctuation, \"$1\") : cap[3];\n return {\n type: \"def\",\n tag: tag2,\n raw: cap[0],\n href,\n title\n };\n }\n }\n table(src) {\n const cap = this.rules.block.table.exec(src);\n if (!cap) {\n return;\n }\n if (!this.rules.other.tableDelimiter.test(cap[2])) {\n return;\n }\n const headers = splitCells(cap[1]);\n const aligns = cap[2].replace(this.rules.other.tableAlignChars, \"\").split(\"|\");\n const rows = cap[3]?.trim() ? cap[3].replace(this.rules.other.tableRowBlankLine, \"\").split(\"\\n\") : [];\n const item = {\n type: \"table\",\n raw: cap[0],\n header: [],\n align: [],\n rows: []\n };\n if (headers.length !== aligns.length) {\n return;\n }\n for (const align of aligns) {\n if (this.rules.other.tableAlignRight.test(align)) {\n item.align.push(\"right\");\n } else if (this.rules.other.tableAlignCenter.test(align)) {\n item.align.push(\"center\");\n } else if (this.rules.other.tableAlignLeft.test(align)) {\n item.align.push(\"left\");\n } else {\n item.align.push(null);\n }\n }\n for (let i = 0; i < headers.length; i++) {\n item.header.push({\n text: headers[i],\n tokens: this.lexer.inline(headers[i]),\n header: true,\n align: item.align[i]\n });\n }\n for (const row of rows) {\n item.rows.push(splitCells(row, item.header.length).map((cell, i) => {\n return {\n text: cell,\n tokens: this.lexer.inline(cell),\n header: false,\n align: item.align[i]\n };\n }));\n }\n return item;\n }\n lheading(src) {\n const cap = this.rules.block.lheading.exec(src);\n if (cap) {\n return {\n type: \"heading\",\n raw: cap[0],\n depth: cap[2].charAt(0) === \"=\" ? 1 : 2,\n text: cap[1],\n tokens: this.lexer.inline(cap[1])\n };\n }\n }\n paragraph(src) {\n const cap = this.rules.block.paragraph.exec(src);\n if (cap) {\n const text = cap[1].charAt(cap[1].length - 1) === \"\\n\" ? cap[1].slice(0, -1) : cap[1];\n return {\n type: \"paragraph\",\n raw: cap[0],\n text,\n tokens: this.lexer.inline(text)\n };\n }\n }\n text(src) {\n const cap = this.rules.block.text.exec(src);\n if (cap) {\n return {\n type: \"text\",\n raw: cap[0],\n text: cap[0],\n tokens: this.lexer.inline(cap[0])\n };\n }\n }\n escape(src) {\n const cap = this.rules.inline.escape.exec(src);\n if (cap) {\n return {\n type: \"escape\",\n raw: cap[0],\n text: cap[1]\n };\n }\n }\n tag(src) {\n const cap = this.rules.inline.tag.exec(src);\n if (cap) {\n if (!this.lexer.state.inLink && this.rules.other.startATag.test(cap[0])) {\n this.lexer.state.inLink = true;\n } else if (this.lexer.state.inLink && this.rules.other.endATag.test(cap[0])) {\n this.lexer.state.inLink = false;\n }\n if (!this.lexer.state.inRawBlock && this.rules.other.startPreScriptTag.test(cap[0])) {\n this.lexer.state.inRawBlock = true;\n } else if (this.lexer.state.inRawBlock && this.rules.other.endPreScriptTag.test(cap[0])) {\n this.lexer.state.inRawBlock = false;\n }\n return {\n type: \"html\",\n raw: cap[0],\n inLink: this.lexer.state.inLink,\n inRawBlock: this.lexer.state.inRawBlock,\n block: false,\n text: cap[0]\n };\n }\n }\n link(src) {\n const cap = this.rules.inline.link.exec(src);\n if (cap) {\n const trimmedUrl = cap[2].trim();\n if (!this.options.pedantic && this.rules.other.startAngleBracket.test(trimmedUrl)) {\n if (!this.rules.other.endAngleBracket.test(trimmedUrl)) {\n return;\n }\n const rtrimSlash = rtrim(trimmedUrl.slice(0, -1), \"\\\\\");\n if ((trimmedUrl.length - rtrimSlash.length) % 2 === 0) {\n return;\n }\n } else {\n const lastParenIndex = findClosingBracket(cap[2], \"()\");\n if (lastParenIndex === -2) {\n return;\n }\n if (lastParenIndex > -1) {\n const start = cap[0].indexOf(\"!\") === 0 ? 5 : 4;\n const linkLen = start + cap[1].length + lastParenIndex;\n cap[2] = cap[2].substring(0, lastParenIndex);\n cap[0] = cap[0].substring(0, linkLen).trim();\n cap[3] = \"\";\n }\n }\n let href = cap[2];\n let title = \"\";\n if (this.options.pedantic) {\n const link2 = this.rules.other.pedanticHrefTitle.exec(href);\n if (link2) {\n href = link2[1];\n title = link2[3];\n }\n } else {\n title = cap[3] ? cap[3].slice(1, -1) : \"\";\n }\n href = href.trim();\n if (this.rules.other.startAngleBracket.test(href)) {\n if (this.options.pedantic && !this.rules.other.endAngleBracket.test(trimmedUrl)) {\n href = href.slice(1);\n } else {\n href = href.slice(1, -1);\n }\n }\n return outputLink(cap, {\n href: href ? href.replace(this.rules.inline.anyPunctuation, \"$1\") : href,\n title: title ? title.replace(this.rules.inline.anyPunctuation, \"$1\") : title\n }, cap[0], this.lexer, this.rules);\n }\n }\n reflink(src, links) {\n let cap;\n if ((cap = this.rules.inline.reflink.exec(src)) || (cap = this.rules.inline.nolink.exec(src))) {\n const linkString = (cap[2] || cap[1]).replace(this.rules.other.multipleSpaceGlobal, \" \");\n const link2 = links[linkString.toLowerCase()];\n if (!link2) {\n const text = cap[0].charAt(0);\n return {\n type: \"text\",\n raw: text,\n text\n };\n }\n return outputLink(cap, link2, cap[0], this.lexer, this.rules);\n }\n }\n emStrong(src, maskedSrc, prevChar = \"\") {\n let match = this.rules.inline.emStrongLDelim.exec(src);\n if (!match) return;\n if (match[3] && prevChar.match(this.rules.other.unicodeAlphaNumeric)) return;\n const nextChar = match[1] || match[2] || \"\";\n if (!nextChar || !prevChar || this.rules.inline.punctuation.exec(prevChar)) {\n const lLength = [...match[0]].length - 1;\n let rDelim, rLength, delimTotal = lLength, midDelimTotal = 0;\n const endReg = match[0][0] === \"*\" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;\n endReg.lastIndex = 0;\n maskedSrc = maskedSrc.slice(-1 * src.length + lLength);\n while ((match = endReg.exec(maskedSrc)) != null) {\n rDelim = match[1] || match[2] || match[3] || match[4] || match[5] || match[6];\n if (!rDelim) continue;\n rLength = [...rDelim].length;\n if (match[3] || match[4]) {\n delimTotal += rLength;\n continue;\n } else if (match[5] || match[6]) {\n if (lLength % 3 && !((lLength + rLength) % 3)) {\n midDelimTotal += rLength;\n continue;\n }\n }\n delimTotal -= rLength;\n if (delimTotal > 0) continue;\n rLength = Math.min(rLength, rLength + delimTotal + midDelimTotal);\n const lastCharLength = [...match[0]][0].length;\n const raw = src.slice(0, lLength + match.index + lastCharLength + rLength);\n if (Math.min(lLength, rLength) % 2) {\n const text2 = raw.slice(1, -1);\n return {\n type: \"em\",\n raw,\n text: text2,\n tokens: this.lexer.inlineTokens(text2)\n };\n }\n const text = raw.slice(2, -2);\n return {\n type: \"strong\",\n raw,\n text,\n tokens: this.lexer.inlineTokens(text)\n };\n }\n }\n }\n codespan(src) {\n const cap = this.rules.inline.code.exec(src);\n if (cap) {\n let text = cap[2].replace(this.rules.other.newLineCharGlobal, \" \");\n const hasNonSpaceChars = this.rules.other.nonSpaceChar.test(text);\n const hasSpaceCharsOnBothEnds = this.rules.other.startingSpaceChar.test(text) && this.rules.other.endingSpaceChar.test(text);\n if (hasNonSpaceChars && hasSpaceCharsOnBothEnds) {\n text = text.substring(1, text.length - 1);\n }\n return {\n type: \"codespan\",\n raw: cap[0],\n text\n };\n }\n }\n br(src) {\n const cap = this.rules.inline.br.exec(src);\n if (cap) {\n return {\n type: \"br\",\n raw: cap[0]\n };\n }\n }\n del(src) {\n const cap = this.rules.inline.del.exec(src);\n if (cap) {\n return {\n type: \"del\",\n raw: cap[0],\n text: cap[2],\n tokens: this.lexer.inlineTokens(cap[2])\n };\n }\n }\n autolink(src) {\n const cap = this.rules.inline.autolink.exec(src);\n if (cap) {\n let text, href;\n if (cap[2] === \"@\") {\n text = cap[1];\n href = \"mailto:\" + text;\n } else {\n text = cap[1];\n href = text;\n }\n return {\n type: \"link\",\n raw: cap[0],\n text,\n href,\n tokens: [\n {\n type: \"text\",\n raw: text,\n text\n }\n ]\n };\n }\n }\n url(src) {\n let cap;\n if (cap = this.rules.inline.url.exec(src)) {\n let text, href;\n if (cap[2] === \"@\") {\n text = cap[0];\n href = \"mailto:\" + text;\n } else {\n let prevCapZero;\n do {\n prevCapZero = cap[0];\n cap[0] = this.rules.inline._backpedal.exec(cap[0])?.[0] ?? \"\";\n } while (prevCapZero !== cap[0]);\n text = cap[0];\n if (cap[1] === \"www.\") {\n href = \"http://\" + cap[0];\n } else {\n href = cap[0];\n }\n }\n return {\n type: \"link\",\n raw: cap[0],\n text,\n href,\n tokens: [\n {\n type: \"text\",\n raw: text,\n text\n }\n ]\n };\n }\n }\n inlineText(src) {\n const cap = this.rules.inline.text.exec(src);\n if (cap) {\n const escaped = this.lexer.state.inRawBlock;\n return {\n type: \"text\",\n raw: cap[0],\n text: cap[0],\n escaped\n };\n }\n }\n};\n\n// src/Lexer.ts\nvar _Lexer = class __Lexer {\n tokens;\n options;\n state;\n tokenizer;\n inlineQueue;\n constructor(options2) {\n this.tokens = [];\n this.tokens.links = /* @__PURE__ */ Object.create(null);\n this.options = options2 || _defaults;\n this.options.tokenizer = this.options.tokenizer || new _Tokenizer();\n this.tokenizer = this.options.tokenizer;\n this.tokenizer.options = this.options;\n this.tokenizer.lexer = this;\n this.inlineQueue = [];\n this.state = {\n inLink: false,\n inRawBlock: false,\n top: true\n };\n const rules = {\n other,\n block: block.normal,\n inline: inline.normal\n };\n if (this.options.pedantic) {\n rules.block = block.pedantic;\n rules.inline = inline.pedantic;\n } else if (this.options.gfm) {\n rules.block = block.gfm;\n if (this.options.breaks) {\n rules.inline = inline.breaks;\n } else {\n rules.inline = inline.gfm;\n }\n }\n this.tokenizer.rules = rules;\n }\n /**\n * Expose Rules\n */\n static get rules() {\n return {\n block,\n inline\n };\n }\n /**\n * Static Lex Method\n */\n static lex(src, options2) {\n const lexer2 = new __Lexer(options2);\n return lexer2.lex(src);\n }\n /**\n * Static Lex Inline Method\n */\n static lexInline(src, options2) {\n const lexer2 = new __Lexer(options2);\n return lexer2.inlineTokens(src);\n }\n /**\n * Preprocessing\n */\n lex(src) {\n src = src.replace(other.carriageReturn, \"\\n\");\n this.blockTokens(src, this.tokens);\n for (let i = 0; i < this.inlineQueue.length; i++) {\n const next = this.inlineQueue[i];\n this.inlineTokens(next.src, next.tokens);\n }\n this.inlineQueue = [];\n return this.tokens;\n }\n blockTokens(src, tokens = [], lastParagraphClipped = false) {\n if (this.options.pedantic) {\n src = src.replace(other.tabCharGlobal, \" \").replace(other.spaceLine, \"\");\n }\n while (src) {\n let token;\n if (this.options.extensions?.block?.some((extTokenizer) => {\n if (token = extTokenizer.call({ lexer: this }, src, tokens)) {\n src = src.substring(token.raw.length);\n tokens.push(token);\n return true;\n }\n return false;\n })) {\n continue;\n }\n if (token = this.tokenizer.space(src)) {\n src = src.substring(token.raw.length);\n const lastToken = tokens.at(-1);\n if (token.raw.length === 1 && lastToken !== void 0) {\n lastToken.raw += \"\\n\";\n } else {\n tokens.push(token);\n }\n continue;\n }\n if (token = this.tokenizer.code(src)) {\n src = src.substring(token.raw.length);\n const lastToken = tokens.at(-1);\n if (lastToken?.type === \"paragraph\" || lastToken?.type === \"text\") {\n lastToken.raw += \"\\n\" + token.raw;\n lastToken.text += \"\\n\" + token.text;\n this.inlineQueue.at(-1).src = lastToken.text;\n } else {\n tokens.push(token);\n }\n continue;\n }\n if (token = this.tokenizer.fences(src)) {\n src = src.substring(token.raw.length);\n tokens.push(token);\n continue;\n }\n if (token = this.tokenizer.heading(src)) {\n src = src.substring(token.raw.length);\n tokens.push(token);\n continue;\n }\n if (token = this.tokenizer.hr(src)) {\n src = src.substring(token.raw.length);\n tokens.push(token);\n continue;\n }\n if (token = this.tokenizer.blockquote(src)) {\n src = src.substring(token.raw.length);\n tokens.push(token);\n continue;\n }\n if (token = this.tokenizer.list(src)) {\n src = src.substring(token.raw.length);\n tokens.push(token);\n continue;\n }\n if (token = this.tokenizer.html(src)) {\n src = src.substring(token.raw.length);\n tokens.push(token);\n continue;\n }\n if (token = this.tokenizer.def(src)) {\n src = src.substring(token.raw.length);\n const lastToken = tokens.at(-1);\n if (lastToken?.type === \"paragraph\" || lastToken?.type === \"text\") {\n lastToken.raw += \"\\n\" + token.raw;\n lastToken.text += \"\\n\" + token.raw;\n this.inlineQueue.at(-1).src = lastToken.text;\n } else if (!this.tokens.links[token.tag]) {\n this.tokens.links[token.tag] = {\n href: token.href,\n title: token.title\n };\n }\n continue;\n }\n if (token = this.tokenizer.table(src)) {\n src = src.substring(token.raw.length);\n tokens.push(token);\n continue;\n }\n if (token = this.tokenizer.lheading(src)) {\n src = src.substring(token.raw.length);\n tokens.push(token);\n continue;\n }\n let cutSrc = src;\n if (this.options.extensions?.startBlock) {\n let startIndex = Infinity;\n const tempSrc = src.slice(1);\n let tempStart;\n this.options.extensions.startBlock.forEach((getStartIndex) => {\n tempStart = getStartIndex.call({ lexer: this }, tempSrc);\n if (typeof tempStart === \"number\" && tempStart >= 0) {\n startIndex = Math.min(startIndex, tempStart);\n }\n });\n if (startIndex < Infinity && startIndex >= 0) {\n cutSrc = src.substring(0, startIndex + 1);\n }\n }\n if (this.state.top && (token = this.tokenizer.paragraph(cutSrc))) {\n const lastToken = tokens.at(-1);\n if (lastParagraphClipped && lastToken?.type === \"paragraph\") {\n lastToken.raw += \"\\n\" + token.raw;\n lastToken.text += \"\\n\" + token.text;\n this.inlineQueue.pop();\n this.inlineQueue.at(-1).src = lastToken.text;\n } else {\n tokens.push(token);\n }\n lastParagraphClipped = cutSrc.length !== src.length;\n src = src.substring(token.raw.length);\n continue;\n }\n if (token = this.tokenizer.text(src)) {\n src = src.substring(token.raw.length);\n const lastToken = tokens.at(-1);\n if (lastToken?.type === \"text\") {\n lastToken.raw += \"\\n\" + token.raw;\n lastToken.text += \"\\n\" + token.text;\n this.inlineQueue.pop();\n this.inlineQueue.at(-1).src = lastToken.text;\n } else {\n tokens.push(token);\n }\n continue;\n }\n if (src) {\n const errMsg = \"Infinite loop on byte: \" + src.charCodeAt(0);\n if (this.options.silent) {\n console.error(errMsg);\n break;\n } else {\n throw new Error(errMsg);\n }\n }\n }\n this.state.top = true;\n return tokens;\n }\n inline(src, tokens = []) {\n this.inlineQueue.push({ src, tokens });\n return tokens;\n }\n /**\n * Lexing/Compiling\n */\n inlineTokens(src, tokens = []) {\n let maskedSrc = src;\n let match = null;\n if (this.tokens.links) {\n const links = Object.keys(this.tokens.links);\n if (links.length > 0) {\n while ((match = this.tokenizer.rules.inline.reflinkSearch.exec(maskedSrc)) != null) {\n if (links.includes(match[0].slice(match[0].lastIndexOf(\"[\") + 1, -1))) {\n maskedSrc = maskedSrc.slice(0, match.index) + \"[\" + \"a\".repeat(match[0].length - 2) + \"]\" + maskedSrc.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex);\n }\n }\n }\n }\n while ((match = this.tokenizer.rules.inline.anyPunctuation.exec(maskedSrc)) != null) {\n maskedSrc = maskedSrc.slice(0, match.index) + \"++\" + maskedSrc.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);\n }\n while ((match = this.tokenizer.rules.inline.blockSkip.exec(maskedSrc)) != null) {\n maskedSrc = maskedSrc.slice(0, match.index) + \"[\" + \"a\".repeat(match[0].length - 2) + \"]\" + maskedSrc.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);\n }\n let keepPrevChar = false;\n let prevChar = \"\";\n while (src) {\n if (!keepPrevChar) {\n prevChar = \"\";\n }\n keepPrevChar = false;\n let token;\n if (this.options.extensions?.inline?.some((extTokenizer) => {\n if (token = extTokenizer.call({ lexer: this }, src, tokens)) {\n src = src.substring(token.raw.length);\n tokens.push(token);\n return true;\n }\n return false;\n })) {\n continue;\n }\n if (token = this.tokenizer.escape(src)) {\n src = src.substring(token.raw.length);\n tokens.push(token);\n continue;\n }\n if (token = this.tokenizer.tag(src)) {\n src = src.substring(token.raw.length);\n tokens.push(token);\n continue;\n }\n if (token = this.tokenizer.link(src)) {\n src = src.substring(token.raw.length);\n tokens.push(token);\n continue;\n }\n if (token = this.tokenizer.reflink(src, this.tokens.links)) {\n src = src.substring(token.raw.length);\n const lastToken = tokens.at(-1);\n if (token.type === \"text\" && lastToken?.type === \"text\") {\n lastToken.raw += token.raw;\n lastToken.text += token.text;\n } else {\n tokens.push(token);\n }\n continue;\n }\n if (token = this.tokenizer.emStrong(src, maskedSrc, prevChar)) {\n src = src.substring(token.raw.length);\n tokens.push(token);\n continue;\n }\n if (token = this.tokenizer.codespan(src)) {\n src = src.substring(token.raw.length);\n tokens.push(token);\n continue;\n }\n if (token = this.tokenizer.br(src)) {\n src = src.substring(token.raw.length);\n tokens.push(token);\n continue;\n }\n if (token = this.tokenizer.del(src)) {\n src = src.substring(token.raw.length);\n tokens.push(token);\n continue;\n }\n if (token = this.tokenizer.autolink(src)) {\n src = src.substring(token.raw.length);\n tokens.push(token);\n continue;\n }\n if (!this.state.inLink && (token = this.tokenizer.url(src))) {\n src = src.substring(token.raw.length);\n tokens.push(token);\n continue;\n }\n let cutSrc = src;\n if (this.options.extensions?.startInline) {\n let startIndex = Infinity;\n const tempSrc = src.slice(1);\n let tempStart;\n this.options.extensions.startInline.forEach((getStartIndex) => {\n tempStart = getStartIndex.call({ lexer: this }, tempSrc);\n if (typeof tempStart === \"number\" && tempStart >= 0) {\n startIndex = Math.min(startIndex, tempStart);\n }\n });\n if (startIndex < Infinity && startIndex >= 0) {\n cutSrc = src.substring(0, startIndex + 1);\n }\n }\n if (token = this.tokenizer.inlineText(cutSrc)) {\n src = src.substring(token.raw.length);\n if (token.raw.slice(-1) !== \"_\") {\n prevChar = token.raw.slice(-1);\n }\n keepPrevChar = true;\n const lastToken = tokens.at(-1);\n if (lastToken?.type === \"text\") {\n lastToken.raw += token.raw;\n lastToken.text += token.text;\n } else {\n tokens.push(token);\n }\n continue;\n }\n if (src) {\n const errMsg = \"Infinite loop on byte: \" + src.charCodeAt(0);\n if (this.options.silent) {\n console.error(errMsg);\n break;\n } else {\n throw new Error(errMsg);\n }\n }\n }\n return tokens;\n }\n};\n\n// src/Renderer.ts\nvar _Renderer = class {\n options;\n parser;\n // set by the parser\n constructor(options2) {\n this.options = options2 || _defaults;\n }\n space(token) {\n return \"\";\n }\n code({ text, lang, escaped }) {\n const langString = (lang || \"\").match(other.notSpaceStart)?.[0];\n const code = text.replace(other.endingNewline, \"\") + \"\\n\";\n if (!langString) {\n return \"<pre><code>\" + (escaped ? code : escape2(code, true)) + \"</code></pre>\\n\";\n }\n return '<pre><code class=\"language-' + escape2(langString) + '\">' + (escaped ? code : escape2(code, true)) + \"</code></pre>\\n\";\n }\n blockquote({ tokens }) {\n const body = this.parser.parse(tokens);\n return `<blockquote>\n${body}</blockquote>\n`;\n }\n html({ text }) {\n return text;\n }\n heading({ tokens, depth }) {\n return `<h${depth}>${this.parser.parseInline(tokens)}</h${depth}>\n`;\n }\n hr(token) {\n return \"<hr>\\n\";\n }\n list(token) {\n const ordered = token.ordered;\n const start = token.start;\n let body = \"\";\n for (let j = 0; j < token.items.length; j++) {\n const item = token.items[j];\n body += this.listitem(item);\n }\n const type = ordered ? \"ol\" : \"ul\";\n const startAttr = ordered && start !== 1 ? ' start=\"' + start + '\"' : \"\";\n return \"<\" + type + startAttr + \">\\n\" + body + \"</\" + type + \">\\n\";\n }\n listitem(item) {\n let itemBody = \"\";\n if (item.task) {\n const checkbox = this.checkbox({ checked: !!item.checked });\n if (item.loose) {\n if (item.tokens[0]?.type === \"paragraph\") {\n item.tokens[0].text = checkbox + \" \" + item.tokens[0].text;\n if (item.tokens[0].tokens && item.tokens[0].tokens.length > 0 && item.tokens[0].tokens[0].type === \"text\") {\n item.tokens[0].tokens[0].text = checkbox + \" \" + escape2(item.tokens[0].tokens[0].text);\n item.tokens[0].tokens[0].escaped = true;\n }\n } else {\n item.tokens.unshift({\n type: \"text\",\n raw: checkbox + \" \",\n text: checkbox + \" \",\n escaped: true\n });\n }\n } else {\n itemBody += checkbox + \" \";\n }\n }\n itemBody += this.parser.parse(item.tokens, !!item.loose);\n return `<li>${itemBody}</li>\n`;\n }\n checkbox({ checked }) {\n return \"<input \" + (checked ? 'checked=\"\" ' : \"\") + 'disabled=\"\" type=\"checkbox\">';\n }\n paragraph({ tokens }) {\n return `<p>${this.parser.parseInline(tokens)}</p>\n`;\n }\n table(token) {\n let header = \"\";\n let cell = \"\";\n for (let j = 0; j < token.header.length; j++) {\n cell += this.tablecell(token.header[j]);\n }\n header += this.tablerow({ text: cell });\n let body = \"\";\n for (let j = 0; j < token.rows.length; j++) {\n const row = token.rows[j];\n cell = \"\";\n for (let k = 0; k < row.length; k++) {\n cell += this.tablecell(row[k]);\n }\n body += this.tablerow({ text: cell });\n }\n if (body) body = `<tbody>${body}</tbody>`;\n return \"<table>\\n<thead>\\n\" + header + \"</thead>\\n\" + body + \"</table>\\n\";\n }\n tablerow({ text }) {\n return `<tr>\n${text}</tr>\n`;\n }\n tablecell(token) {\n const content = this.parser.parseInline(token.tokens);\n const type = token.header ? \"th\" : \"td\";\n const tag2 = token.align ? `<${type} align=\"${token.align}\">` : `<${type}>`;\n return tag2 + content + `</${type}>\n`;\n }\n /**\n * span level renderer\n */\n strong({ tokens }) {\n return `<strong>${this.parser.parseInline(tokens)}</strong>`;\n }\n em({ tokens }) {\n return `<em>${this.parser.parseInline(tokens)}</em>`;\n }\n codespan({ text }) {\n return `<code>${escape2(text, true)}</code>`;\n }\n br(token) {\n return \"<br>\";\n }\n del({ tokens }) {\n return `<del>${this.parser.parseInline(tokens)}</del>`;\n }\n link({ href, title, tokens }) {\n const text = this.parser.parseInline(tokens);\n const cleanHref = cleanUrl(href);\n if (cleanHref === null) {\n return text;\n }\n href = cleanHref;\n let out = '<a href=\"' + href + '\"';\n if (title) {\n out += ' title=\"' + escape2(title) + '\"';\n }\n out += \">\" + text + \"</a>\";\n return out;\n }\n image({ href, title, text, tokens }) {\n if (tokens) {\n text = this.parser.parseInline(tokens, this.parser.textRenderer);\n }\n const cleanHref = cleanUrl(href);\n if (cleanHref === null) {\n return escape2(text);\n }\n href = cleanHref;\n let out = `<img src=\"${href}\" alt=\"${text}\"`;\n if (title) {\n out += ` title=\"${escape2(title)}\"`;\n }\n out += \">\";\n return out;\n }\n text(token) {\n return \"tokens\" in token && token.tokens ? this.parser.parseInline(token.tokens) : \"escaped\" in token && token.escaped ? token.text : escape2(token.text);\n }\n};\n\n// src/TextRenderer.ts\nvar _TextRenderer = class {\n // no need for block level renderers\n strong({ text }) {\n return text;\n }\n em({ text }) {\n return text;\n }\n codespan({ text }) {\n return text;\n }\n del({ text }) {\n return text;\n }\n html({ text }) {\n return text;\n }\n text({ text }) {\n return text;\n }\n link({ text }) {\n return \"\" + text;\n }\n image({ text }) {\n return \"\" + text;\n }\n br() {\n return \"\";\n }\n};\n\n// src/Parser.ts\nvar _Parser = class __Parser {\n options;\n renderer;\n textRenderer;\n constructor(options2) {\n this.options = options2 || _defaults;\n this.options.renderer = this.options.renderer || new _Renderer();\n this.renderer = this.options.renderer;\n this.renderer.options = this.options;\n this.renderer.parser = this;\n this.textRenderer = new _TextRenderer();\n }\n /**\n * Static Parse Method\n */\n static parse(tokens, options2) {\n const parser2 = new __Parser(options2);\n return parser2.parse(tokens);\n }\n /**\n * Static Parse Inline Method\n */\n static parseInline(tokens, options2) {\n const parser2 = new __Parser(options2);\n return parser2.parseInline(tokens);\n }\n /**\n * Parse Loop\n */\n parse(tokens, top = true) {\n let out = \"\";\n for (let i = 0; i < tokens.length; i++) {\n const anyToken = tokens[i];\n if (this.options.extensions?.renderers?.[anyToken.type]) {\n const genericToken = anyToken;\n const ret = this.options.extensions.renderers[genericToken.type].call({ parser: this }, genericToken);\n if (ret !== false || ![\"space\", \"hr\", \"heading\", \"code\", \"table\", \"blockquote\", \"list\", \"html\", \"paragraph\", \"text\"].includes(genericToken.type)) {\n out += ret || \"\";\n continue;\n }\n }\n const token = anyToken;\n switch (token.type) {\n case \"space\": {\n out += this.renderer.space(token);\n continue;\n }\n case \"hr\": {\n out += this.renderer.hr(token);\n continue;\n }\n case \"heading\": {\n out += this.renderer.heading(token);\n continue;\n }\n case \"code\": {\n out += this.renderer.code(token);\n continue;\n }\n case \"table\": {\n out += this.renderer.table(token);\n continue;\n }\n case \"blockquote\": {\n out += this.renderer.blockquote(token);\n continue;\n }\n case \"list\": {\n out += this.renderer.list(token);\n continue;\n }\n case \"html\": {\n out += this.renderer.html(token);\n continue;\n }\n case \"paragraph\": {\n out += this.renderer.paragraph(token);\n continue;\n }\n case \"text\": {\n let textToken = token;\n let body = this.renderer.text(textToken);\n while (i + 1 < tokens.length && tokens[i + 1].type === \"text\") {\n textToken = tokens[++i];\n body += \"\\n\" + this.renderer.text(textToken);\n }\n if (top) {\n out += this.renderer.paragraph({\n type: \"paragraph\",\n raw: body,\n text: body,\n tokens: [{ type: \"text\", raw: body, text: body, escaped: true }]\n });\n } else {\n out += body;\n }\n continue;\n }\n default: {\n const errMsg = 'Token with \"' + token.type + '\" type was not found.';\n if (this.options.silent) {\n console.error(errMsg);\n return \"\";\n } else {\n throw new Error(errMsg);\n }\n }\n }\n }\n return out;\n }\n /**\n * Parse Inline Tokens\n */\n parseInline(tokens, renderer = this.renderer) {\n let out = \"\";\n for (let i = 0; i < tokens.length; i++) {\n const anyToken = tokens[i];\n if (this.options.extensions?.renderers?.[anyToken.type]) {\n const ret = this.options.extensions.renderers[anyToken.type].call({ parser: this }, anyToken);\n if (ret !== false || ![\"escape\", \"html\", \"link\", \"image\", \"strong\", \"em\", \"codespan\", \"br\", \"del\", \"text\"].includes(anyToken.type)) {\n out += ret || \"\";\n continue;\n }\n }\n const token = anyToken;\n switch (token.type) {\n case \"escape\": {\n out += renderer.text(token);\n break;\n }\n case \"html\": {\n out += renderer.html(token);\n break;\n }\n case \"link\": {\n out += renderer.link(token);\n break;\n }\n case \"image\": {\n out += renderer.image(token);\n break;\n }\n case \"strong\": {\n out += renderer.strong(token);\n break;\n }\n case \"em\": {\n out += renderer.em(token);\n break;\n }\n case \"codespan\": {\n out += renderer.codespan(token);\n break;\n }\n case \"br\": {\n out += renderer.br(token);\n break;\n }\n case \"del\": {\n out += renderer.del(token);\n break;\n }\n case \"text\": {\n out += renderer.text(token);\n break;\n }\n default: {\n const errMsg = 'Token with \"' + token.type + '\" type was not found.';\n if (this.options.silent) {\n console.error(errMsg);\n return \"\";\n } else {\n throw new Error(errMsg);\n }\n }\n }\n }\n return out;\n }\n};\n\n// src/Hooks.ts\nvar _Hooks = class {\n options;\n block;\n constructor(options2) {\n this.options = options2 || _defaults;\n }\n static passThroughHooks = /* @__PURE__ */ new Set([\n \"preprocess\",\n \"postprocess\",\n \"processAllTokens\"\n ]);\n /**\n * Process markdown before marked\n */\n preprocess(markdown) {\n return markdown;\n }\n /**\n * Process HTML after marked is finished\n */\n postprocess(html2) {\n return html2;\n }\n /**\n * Process all tokens before walk tokens\n */\n processAllTokens(tokens) {\n return tokens;\n }\n /**\n * Provide function to tokenize markdown\n */\n provideLexer() {\n return this.block ? _Lexer.lex : _Lexer.lexInline;\n }\n /**\n * Provide function to parse tokens\n */\n provideParser() {\n return this.block ? _Parser.parse : _Parser.parseInline;\n }\n};\n\n// src/Instance.ts\nvar Marked = class {\n defaults = _getDefaults();\n options = this.setOptions;\n parse = this.parseMarkdown(true);\n parseInline = this.parseMarkdown(false);\n Parser = _Parser;\n Renderer = _Renderer;\n TextRenderer = _TextRenderer;\n Lexer = _Lexer;\n Tokenizer = _Tokenizer;\n Hooks = _Hooks;\n constructor(...args) {\n this.use(...args);\n }\n /**\n * Run callback for every token\n */\n walkTokens(tokens, callback) {\n let values = [];\n for (const token of tokens) {\n values = values.concat(callback.call(this, token));\n switch (token.type) {\n case \"table\": {\n const tableToken = token;\n for (const cell of tableToken.header) {\n values = values.concat(this.walkTokens(cell.tokens, callback));\n }\n for (const row of tableToken.rows) {\n for (const cell of row) {\n values = values.concat(this.walkTokens(cell.tokens, callback));\n }\n }\n break;\n }\n case \"list\": {\n const listToken = token;\n values = values.concat(this.walkTokens(listToken.items, callback));\n break;\n }\n default: {\n const genericToken = token;\n if (this.defaults.extensions?.childTokens?.[genericToken.type]) {\n this.defaults.extensions.childTokens[genericToken.type].forEach((childTokens) => {\n const tokens2 = genericToken[childTokens].flat(Infinity);\n values = values.concat(this.walkTokens(tokens2, callback));\n });\n } else if (genericToken.tokens) {\n values = values.concat(this.walkTokens(genericToken.tokens, callback));\n }\n }\n }\n }\n return values;\n }\n use(...args) {\n const extensions = this.defaults.extensions || { renderers: {}, childTokens: {} };\n args.forEach((pack) => {\n const opts = { ...pack };\n opts.async = this.defaults.async || opts.async || false;\n if (pack.extensions) {\n pack.extensions.forEach((ext) => {\n if (!ext.name) {\n throw new Error(\"extension name required\");\n }\n if (\"renderer\" in ext) {\n const prevRenderer = extensions.renderers[ext.name];\n if (prevRenderer) {\n extensions.renderers[ext.name] = function(...args2) {\n let ret = ext.renderer.apply(this, args2);\n if (ret === false) {\n ret = prevRenderer.apply(this, args2);\n }\n return ret;\n };\n } else {\n extensions.renderers[ext.name] = ext.renderer;\n }\n }\n if (\"tokenizer\" in ext) {\n if (!ext.level || ext.level !== \"block\" && ext.level !== \"inline\") {\n throw new Error(\"extension level must be 'block' or 'inline'\");\n }\n const extLevel = extensions[ext.level];\n if (extLevel) {\n extLevel.unshift(ext.tokenizer);\n } else {\n extensions[ext.level] = [ext.tokenizer];\n }\n if (ext.start) {\n if (ext.level === \"block\") {\n if (extensions.startBlock) {\n extensions.startBlock.push(ext.start);\n } else {\n extensions.startBlock = [ext.start];\n }\n } else if (ext.level === \"inline\") {\n if (extensions.startInline) {\n extensions.startInline.push(ext.start);\n } else {\n extensions.startInline = [ext.start];\n }\n }\n }\n }\n if (\"childTokens\" in ext && ext.childTokens) {\n extensions.childTokens[ext.name] = ext.childTokens;\n }\n });\n opts.extensions = extensions;\n }\n if (pack.renderer) {\n const renderer = this.defaults.renderer || new _Renderer(this.defaults);\n for (const prop in pack.renderer) {\n if (!(prop in renderer)) {\n throw new Error(`renderer '${prop}' does not exist`);\n }\n if ([\"options\", \"parser\"].includes(prop)) {\n continue;\n }\n const rendererProp = prop;\n const rendererFunc = pack.renderer[rendererProp];\n const prevRenderer = renderer[rendererProp];\n renderer[rendererProp] = (...args2) => {\n let ret = rendererFunc.apply(renderer, args2);\n if (ret === false) {\n ret = prevRenderer.apply(renderer, args2);\n }\n return ret || \"\";\n };\n }\n opts.renderer = renderer;\n }\n if (pack.tokenizer) {\n const tokenizer = this.defaults.tokenizer || new _Tokenizer(this.defaults);\n for (const prop in pack.tokenizer) {\n if (!(prop in tokenizer)) {\n throw new Error(`tokenizer '${prop}' does not exist`);\n }\n if ([\"options\", \"rules\", \"lexer\"].includes(prop)) {\n continue;\n }\n const tokenizerProp = prop;\n const tokenizerFunc = pack.tokenizer[tokenizerProp];\n const prevTokenizer = tokenizer[tokenizerProp];\n tokenizer[tokenizerProp] = (...args2) => {\n let ret = tokenizerFunc.apply(tokenizer, args2);\n if (ret === false) {\n ret = prevTokenizer.apply(tokenizer, args2);\n }\n return ret;\n };\n }\n opts.tokenizer = tokenizer;\n }\n if (pack.hooks) {\n const hooks = this.defaults.hooks || new _Hooks();\n for (const prop in pack.hooks) {\n if (!(prop in hooks)) {\n throw new Error(`hook '${prop}' does not exist`);\n }\n if ([\"options\", \"block\"].includes(prop)) {\n continue;\n }\n const hooksProp = prop;\n const hooksFunc = pack.hooks[hooksProp];\n const prevHook = hooks[hooksProp];\n if (_Hooks.passThroughHooks.has(prop)) {\n hooks[hooksProp] = (arg) => {\n if (this.defaults.async) {\n return Promise.resolve(hooksFunc.call(hooks, arg)).then((ret2) => {\n return prevHook.call(hooks, ret2);\n });\n }\n const ret = hooksFunc.call(hooks, arg);\n return prevHook.call(hooks, ret);\n };\n } else {\n hooks[hooksProp] = (...args2) => {\n let ret = hooksFunc.apply(hooks, args2);\n if (ret === false) {\n ret = prevHook.apply(hooks, args2);\n }\n return ret;\n };\n }\n }\n opts.hooks = hooks;\n }\n if (pack.walkTokens) {\n const walkTokens2 = this.defaults.walkTokens;\n const packWalktokens = pack.walkTokens;\n opts.walkTokens = function(token) {\n let values = [];\n values.push(packWalktokens.call(this, token));\n if (walkTokens2) {\n values = values.concat(walkTokens2.call(this, token));\n }\n return values;\n };\n }\n this.defaults = { ...this.defaults, ...opts };\n });\n return this;\n }\n setOptions(opt) {\n this.defaults = { ...this.defaults, ...opt };\n return this;\n }\n lexer(src, options2) {\n return _Lexer.lex(src, options2 ?? this.defaults);\n }\n parser(tokens, options2) {\n return _Parser.parse(tokens, options2 ?? this.defaults);\n }\n parseMarkdown(blockType) {\n const parse2 = (src, options2) => {\n const origOpt = { ...options2 };\n const opt = { ...this.defaults, ...origOpt };\n const throwError = this.onError(!!opt.silent, !!opt.async);\n if (this.defaults.async === true && origOpt.async === false) {\n return throwError(new Error(\"marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise.\"));\n }\n if (typeof src === \"undefined\" || src === null) {\n return throwError(new Error(\"marked(): input parameter is undefined or null\"));\n }\n if (typeof src !== \"string\") {\n return throwError(new Error(\"marked(): input parameter is of type \" + Object.prototype.toString.call(src) + \", string expected\"));\n }\n if (opt.hooks) {\n opt.hooks.options = opt;\n opt.hooks.block = blockType;\n }\n const lexer2 = opt.hooks ? opt.hooks.provideLexer() : blockType ? _Lexer.lex : _Lexer.lexInline;\n const parser2 = opt.hooks ? opt.hooks.provideParser() : blockType ? _Parser.parse : _Parser.parseInline;\n if (opt.async) {\n return Promise.resolve(opt.hooks ? opt.hooks.preprocess(src) : src).then((src2) => lexer2(src2, opt)).then((tokens) => opt.hooks ? opt.hooks.processAllTokens(tokens) : tokens).then((tokens) => opt.walkTokens ? Promise.all(this.walkTokens(tokens, opt.walkTokens)).then(() => tokens) : tokens).then((tokens) => parser2(tokens, opt)).then((html2) => opt.hooks ? opt.hooks.postprocess(html2) : html2).catch(throwError);\n }\n try {\n if (opt.hooks) {\n src = opt.hooks.preprocess(src);\n }\n let tokens = lexer2(src, opt);\n if (opt.hooks) {\n tokens = opt.hooks.processAllTokens(tokens);\n }\n if (opt.walkTokens) {\n this.walkTokens(tokens, opt.walkTokens);\n }\n let html2 = parser2(tokens, opt);\n if (opt.hooks) {\n html2 = opt.hooks.postprocess(html2);\n }\n return html2;\n } catch (e) {\n return throwError(e);\n }\n };\n return parse2;\n }\n onError(silent, async) {\n return (e) => {\n e.message += \"\\nPlease report this to https://github.com/markedjs/marked.\";\n if (silent) {\n const msg = \"<p>An error occurred:</p><pre>\" + escape2(e.message + \"\", true) + \"</pre>\";\n if (async) {\n return Promise.resolve(msg);\n }\n return msg;\n }\n if (async) {\n return Promise.reject(e);\n }\n throw e;\n };\n }\n};\n\n// src/marked.ts\nvar markedInstance = new Marked();\nfunction marked(src, opt) {\n return markedInstance.parse(src, opt);\n}\nmarked.options = marked.setOptions = function(options2) {\n markedInstance.setOptions(options2);\n marked.defaults = markedInstance.defaults;\n changeDefaults(marked.defaults);\n return marked;\n};\nmarked.getDefaults = _getDefaults;\nmarked.defaults = _defaults;\nmarked.use = function(...args) {\n markedInstance.use(...args);\n marked.defaults = markedInstance.defaults;\n changeDefaults(marked.defaults);\n return marked;\n};\nmarked.walkTokens = function(tokens, callback) {\n return markedInstance.walkTokens(tokens, callback);\n};\nmarked.parseInline = markedInstance.parseInline;\nmarked.Parser = _Parser;\nmarked.parser = _Parser.parse;\nmarked.Renderer = _Renderer;\nmarked.TextRenderer = _TextRenderer;\nmarked.Lexer = _Lexer;\nmarked.lexer = _Lexer.lex;\nmarked.Tokenizer = _Tokenizer;\nmarked.Hooks = _Hooks;\nmarked.parse = marked;\nvar options = marked.options;\nvar setOptions = marked.setOptions;\nvar use = marked.use;\nvar walkTokens = marked.walkTokens;\nvar parseInline = marked.parseInline;\nvar parse = marked;\nvar parser = _Parser.parse;\nvar lexer = _Lexer.lex;\nexport {\n _Hooks as Hooks,\n _Lexer as Lexer,\n Marked,\n _Parser as Parser,\n _Renderer as Renderer,\n _TextRenderer as TextRenderer,\n _Tokenizer as Tokenizer,\n _defaults as defaults,\n _getDefaults as getDefaults,\n lexer,\n marked,\n options,\n parse,\n parseInline,\n parser,\n setOptions,\n use,\n walkTokens\n};\n//# sourceMappingURL=marked.esm.js.map\n","/*! @license DOMPurify 3.4.11 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.11/LICENSE */\n\nfunction _arrayLikeToArray(r, a) {\n (null == a || a > r.length) && (a = r.length);\n for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];\n return n;\n}\nfunction _arrayWithHoles(r) {\n if (Array.isArray(r)) return r;\n}\nfunction _iterableToArrayLimit(r, l) {\n var t = null == r ? null : \"undefined\" != typeof Symbol && r[Symbol.iterator] || r[\"@@iterator\"];\n if (null != t) {\n var e,\n n,\n i,\n u,\n a = [],\n f = true,\n o = false;\n try {\n if (i = (t = t.call(r)).next, 0 === l) ; else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);\n } catch (r) {\n o = true, n = r;\n } finally {\n try {\n if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;\n } finally {\n if (o) throw n;\n }\n }\n return a;\n }\n}\nfunction _nonIterableRest() {\n throw new TypeError(\"Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\");\n}\nfunction _slicedToArray(r, e) {\n return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();\n}\nfunction _unsupportedIterableToArray(r, a) {\n if (r) {\n if (\"string\" == typeof r) return _arrayLikeToArray(r, a);\n var t = {}.toString.call(r).slice(8, -1);\n return \"Object\" === t && r.constructor && (t = r.constructor.name), \"Map\" === t || \"Set\" === t ? Array.from(r) : \"Arguments\" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;\n }\n}\n\nconst entries = Object.entries,\n setPrototypeOf = Object.setPrototypeOf,\n isFrozen = Object.isFrozen,\n getPrototypeOf = Object.getPrototypeOf,\n getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;\nlet freeze = Object.freeze,\n seal = Object.seal,\n create = Object.create; // eslint-disable-line import/no-mutable-exports\nlet _ref = typeof Reflect !== 'undefined' && Reflect,\n apply = _ref.apply,\n construct = _ref.construct;\nif (!freeze) {\n freeze = function freeze(x) {\n return x;\n };\n}\nif (!seal) {\n seal = function seal(x) {\n return x;\n };\n}\nif (!apply) {\n apply = function apply(func, thisArg) {\n for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {\n args[_key - 2] = arguments[_key];\n }\n return func.apply(thisArg, args);\n };\n}\nif (!construct) {\n construct = function construct(Func) {\n for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {\n args[_key2 - 1] = arguments[_key2];\n }\n return new Func(...args);\n };\n}\nconst arrayForEach = unapply(Array.prototype.forEach);\nconst arrayLastIndexOf = unapply(Array.prototype.lastIndexOf);\nconst arrayPop = unapply(Array.prototype.pop);\nconst arrayPush = unapply(Array.prototype.push);\nconst arraySplice = unapply(Array.prototype.splice);\nconst arrayIsArray = Array.isArray;\nconst stringToLowerCase = unapply(String.prototype.toLowerCase);\nconst stringToString = unapply(String.prototype.toString);\nconst stringMatch = unapply(String.prototype.match);\nconst stringReplace = unapply(String.prototype.replace);\nconst stringIndexOf = unapply(String.prototype.indexOf);\nconst stringTrim = unapply(String.prototype.trim);\nconst numberToString = unapply(Number.prototype.toString);\nconst booleanToString = unapply(Boolean.prototype.toString);\nconst bigintToString = typeof BigInt === 'undefined' ? null : unapply(BigInt.prototype.toString);\nconst symbolToString = typeof Symbol === 'undefined' ? null : unapply(Symbol.prototype.toString);\nconst objectHasOwnProperty = unapply(Object.prototype.hasOwnProperty);\nconst objectToString = unapply(Object.prototype.toString);\nconst regExpTest = unapply(RegExp.prototype.test);\nconst typeErrorCreate = unconstruct(TypeError);\n/**\n * Creates a new function that calls the given function with a specified thisArg and arguments.\n *\n * @param func - The function to be wrapped and called.\n * @returns A new function that calls the given function with a specified thisArg and arguments.\n */\nfunction unapply(func) {\n return function (thisArg) {\n if (thisArg instanceof RegExp) {\n thisArg.lastIndex = 0;\n }\n for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {\n args[_key3 - 1] = arguments[_key3];\n }\n return apply(func, thisArg, args);\n };\n}\n/**\n * Creates a new function that constructs an instance of the given constructor function with the provided arguments.\n *\n * @param func - The constructor function to be wrapped and called.\n * @returns A new function that constructs an instance of the given constructor function with the provided arguments.\n */\nfunction unconstruct(Func) {\n return function () {\n for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {\n args[_key4] = arguments[_key4];\n }\n return construct(Func, args);\n };\n}\n/**\n * Add properties to a lookup table\n *\n * @param set - The set to which elements will be added.\n * @param array - The array containing elements to be added to the set.\n * @param transformCaseFunc - An optional function to transform the case of each element before adding to the set.\n * @returns The modified set with added elements.\n */\nfunction addToSet(set, array) {\n let transformCaseFunc = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : stringToLowerCase;\n if (setPrototypeOf) {\n // Make 'in' and truthy checks like Boolean(set.constructor)\n // independent of any properties defined on Object.prototype.\n // Prevent prototype setters from intercepting set as a this value.\n setPrototypeOf(set, null);\n }\n if (!arrayIsArray(array)) {\n return set;\n }\n let l = array.length;\n while (l--) {\n let element = array[l];\n if (typeof element === 'string') {\n const lcElement = transformCaseFunc(element);\n if (lcElement !== element) {\n // Config presets (e.g. tags.js, attrs.js) are immutable.\n if (!isFrozen(array)) {\n array[l] = lcElement;\n }\n element = lcElement;\n }\n }\n set[element] = true;\n }\n return set;\n}\n/**\n * Clean up an array to harden against CSPP\n *\n * @param array - The array to be cleaned.\n * @returns The cleaned version of the array\n */\nfunction cleanArray(array) {\n for (let index = 0; index < array.length; index++) {\n const isPropertyExist = objectHasOwnProperty(array, index);\n if (!isPropertyExist) {\n array[index] = null;\n }\n }\n return array;\n}\n/**\n * Shallow clone an object\n *\n * @param object - The object to be cloned.\n * @returns A new object that copies the original.\n */\nfunction clone(object) {\n const newObject = create(null);\n for (const _ref2 of entries(object)) {\n var _ref3 = _slicedToArray(_ref2, 2);\n const property = _ref3[0];\n const value = _ref3[1];\n const isPropertyExist = objectHasOwnProperty(object, property);\n if (isPropertyExist) {\n if (arrayIsArray(value)) {\n newObject[property] = cleanArray(value);\n } else if (value && typeof value === 'object' && value.constructor === Object) {\n newObject[property] = clone(value);\n } else {\n newObject[property] = value;\n }\n }\n }\n return newObject;\n}\n/**\n * Convert non-node values into strings without depending on direct property access.\n *\n * @param value - The value to stringify.\n * @returns A string representation of the provided value.\n */\nfunction stringifyValue(value) {\n switch (typeof value) {\n case 'string':\n {\n return value;\n }\n case 'number':\n {\n return numberToString(value);\n }\n case 'boolean':\n {\n return booleanToString(value);\n }\n case 'bigint':\n {\n return bigintToString ? bigintToString(value) : '0';\n }\n case 'symbol':\n {\n return symbolToString ? symbolToString(value) : 'Symbol()';\n }\n case 'undefined':\n {\n return objectToString(value);\n }\n case 'function':\n case 'object':\n {\n if (value === null) {\n return objectToString(value);\n }\n const valueAsRecord = value;\n const valueToString = lookupGetter(valueAsRecord, 'toString');\n if (typeof valueToString === 'function') {\n const stringified = valueToString(valueAsRecord);\n return typeof stringified === 'string' ? stringified : objectToString(stringified);\n }\n return objectToString(value);\n }\n default:\n {\n return objectToString(value);\n }\n }\n}\n/**\n * This method automatically checks if the prop is function or getter and behaves accordingly.\n *\n * @param object - The object to look up the getter function in its prototype chain.\n * @param prop - The property name for which to find the getter function.\n * @returns The getter function found in the prototype chain or a fallback function.\n */\nfunction lookupGetter(object, prop) {\n while (object !== null) {\n const desc = getOwnPropertyDescriptor(object, prop);\n if (desc) {\n if (desc.get) {\n return unapply(desc.get);\n }\n if (typeof desc.value === 'function') {\n return unapply(desc.value);\n }\n }\n object = getPrototypeOf(object);\n }\n function fallbackValue() {\n return null;\n }\n return fallbackValue;\n}\nfunction isRegex(value) {\n try {\n regExpTest(value, '');\n return true;\n } catch (_unused) {\n return false;\n }\n}\n\nconst html$1 = freeze(['a', 'abbr', 'acronym', 'address', 'area', 'article', 'aside', 'audio', 'b', 'bdi', 'bdo', 'big', 'blink', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'center', 'cite', 'code', 'col', 'colgroup', 'content', 'data', 'datalist', 'dd', 'decorator', 'del', 'details', 'dfn', 'dialog', 'dir', 'div', 'dl', 'dt', 'element', 'em', 'fieldset', 'figcaption', 'figure', 'font', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'i', 'img', 'input', 'ins', 'kbd', 'label', 'legend', 'li', 'main', 'map', 'mark', 'marquee', 'menu', 'menuitem', 'meter', 'nav', 'nobr', 'ol', 'optgroup', 'option', 'output', 'p', 'picture', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'search', 'section', 'select', 'shadow', 'slot', 'small', 'source', 'spacer', 'span', 'strike', 'strong', 'style', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'template', 'textarea', 'tfoot', 'th', 'thead', 'time', 'tr', 'track', 'tt', 'u', 'ul', 'var', 'video', 'wbr']);\nconst svg$1 = freeze(['svg', 'a', 'altglyph', 'altglyphdef', 'altglyphitem', 'animatecolor', 'animatemotion', 'animatetransform', 'circle', 'clippath', 'defs', 'desc', 'ellipse', 'enterkeyhint', 'exportparts', 'filter', 'font', 'g', 'glyph', 'glyphref', 'hkern', 'image', 'inputmode', 'line', 'lineargradient', 'marker', 'mask', 'metadata', 'mpath', 'part', 'path', 'pattern', 'polygon', 'polyline', 'radialgradient', 'rect', 'stop', 'style', 'switch', 'symbol', 'text', 'textpath', 'title', 'tref', 'tspan', 'view', 'vkern']);\nconst svgFilters = freeze(['feBlend', 'feColorMatrix', 'feComponentTransfer', 'feComposite', 'feConvolveMatrix', 'feDiffuseLighting', 'feDisplacementMap', 'feDistantLight', 'feDropShadow', 'feFlood', 'feFuncA', 'feFuncB', 'feFuncG', 'feFuncR', 'feGaussianBlur', 'feImage', 'feMerge', 'feMergeNode', 'feMorphology', 'feOffset', 'fePointLight', 'feSpecularLighting', 'feSpotLight', 'feTile', 'feTurbulence']);\n// List of SVG elements that are disallowed by default.\n// We still need to know them so that we can do namespace\n// checks properly in case one wants to add them to\n// allow-list.\nconst svgDisallowed = freeze(['animate', 'color-profile', 'cursor', 'discard', 'font-face', 'font-face-format', 'font-face-name', 'font-face-src', 'font-face-uri', 'foreignobject', 'hatch', 'hatchpath', 'mesh', 'meshgradient', 'meshpatch', 'meshrow', 'missing-glyph', 'script', 'set', 'solidcolor', 'unknown', 'use']);\nconst mathMl$1 = freeze(['math', 'menclose', 'merror', 'mfenced', 'mfrac', 'mglyph', 'mi', 'mlabeledtr', 'mmultiscripts', 'mn', 'mo', 'mover', 'mpadded', 'mphantom', 'mroot', 'mrow', 'ms', 'mspace', 'msqrt', 'mstyle', 'msub', 'msup', 'msubsup', 'mtable', 'mtd', 'mtext', 'mtr', 'munder', 'munderover', 'mprescripts']);\n// Similarly to SVG, we want to know all MathML elements,\n// even those that we disallow by default.\nconst mathMlDisallowed = freeze(['maction', 'maligngroup', 'malignmark', 'mlongdiv', 'mscarries', 'mscarry', 'msgroup', 'mstack', 'msline', 'msrow', 'semantics', 'annotation', 'annotation-xml', 'mprescripts', 'none']);\nconst text = freeze(['#text']);\n\nconst html = freeze(['accept', 'action', 'align', 'alt', 'autocapitalize', 'autocomplete', 'autopictureinpicture', 'autoplay', 'background', 'bgcolor', 'border', 'capture', 'cellpadding', 'cellspacing', 'checked', 'cite', 'class', 'clear', 'color', 'cols', 'colspan', 'command', 'commandfor', 'controls', 'controlslist', 'coords', 'crossorigin', 'datetime', 'decoding', 'default', 'dir', 'disabled', 'disablepictureinpicture', 'disableremoteplayback', 'download', 'draggable', 'enctype', 'enterkeyhint', 'exportparts', 'face', 'for', 'headers', 'height', 'hidden', 'high', 'href', 'hreflang', 'id', 'inert', 'inputmode', 'integrity', 'ismap', 'kind', 'label', 'lang', 'list', 'loading', 'loop', 'low', 'max', 'maxlength', 'media', 'method', 'min', 'minlength', 'multiple', 'muted', 'name', 'nonce', 'noshade', 'novalidate', 'nowrap', 'open', 'optimum', 'part', 'pattern', 'placeholder', 'playsinline', 'popover', 'popovertarget', 'popovertargetaction', 'poster', 'preload', 'pubdate', 'radiogroup', 'readonly', 'rel', 'required', 'rev', 'reversed', 'role', 'rows', 'rowspan', 'spellcheck', 'scope', 'selected', 'shape', 'size', 'sizes', 'slot', 'span', 'srclang', 'start', 'src', 'srcset', 'step', 'style', 'summary', 'tabindex', 'title', 'translate', 'type', 'usemap', 'valign', 'value', 'width', 'wrap', 'xmlns']);\nconst svg = freeze(['accent-height', 'accumulate', 'additive', 'alignment-baseline', 'amplitude', 'ascent', 'attributename', 'attributetype', 'azimuth', 'basefrequency', 'baseline-shift', 'begin', 'bias', 'by', 'class', 'clip', 'clippathunits', 'clip-path', 'clip-rule', 'color', 'color-interpolation', 'color-interpolation-filters', 'color-profile', 'color-rendering', 'cx', 'cy', 'd', 'dx', 'dy', 'diffuseconstant', 'direction', 'display', 'divisor', 'dur', 'edgemode', 'elevation', 'end', 'exponent', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'filterunits', 'flood-color', 'flood-opacity', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', 'font-weight', 'fx', 'fy', 'g1', 'g2', 'glyph-name', 'glyphref', 'gradientunits', 'gradienttransform', 'height', 'href', 'id', 'image-rendering', 'in', 'in2', 'intercept', 'k', 'k1', 'k2', 'k3', 'k4', 'kerning', 'keypoints', 'keysplines', 'keytimes', 'lang', 'lengthadjust', 'letter-spacing', 'kernelmatrix', 'kernelunitlength', 'lighting-color', 'local', 'marker-end', 'marker-mid', 'marker-start', 'markerheight', 'markerunits', 'markerwidth', 'maskcontentunits', 'maskunits', 'max', 'mask', 'mask-type', 'media', 'method', 'mode', 'min', 'name', 'numoctaves', 'offset', 'operator', 'opacity', 'order', 'orient', 'orientation', 'origin', 'overflow', 'paint-order', 'path', 'pathlength', 'patterncontentunits', 'patterntransform', 'patternunits', 'points', 'preservealpha', 'preserveaspectratio', 'primitiveunits', 'r', 'rx', 'ry', 'radius', 'refx', 'refy', 'repeatcount', 'repeatdur', 'restart', 'result', 'rotate', 'scale', 'seed', 'shape-rendering', 'slope', 'specularconstant', 'specularexponent', 'spreadmethod', 'startoffset', 'stddeviation', 'stitchtiles', 'stop-color', 'stop-opacity', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke', 'stroke-width', 'style', 'surfacescale', 'systemlanguage', 'tabindex', 'tablevalues', 'targetx', 'targety', 'transform', 'transform-origin', 'text-anchor', 'text-decoration', 'text-rendering', 'textlength', 'type', 'u1', 'u2', 'unicode', 'values', 'viewbox', 'visibility', 'version', 'vert-adv-y', 'vert-origin-x', 'vert-origin-y', 'width', 'word-spacing', 'wrap', 'writing-mode', 'xchannelselector', 'ychannelselector', 'x', 'x1', 'x2', 'xmlns', 'y', 'y1', 'y2', 'z', 'zoomandpan']);\nconst mathMl = freeze(['accent', 'accentunder', 'align', 'bevelled', 'close', 'columnalign', 'columnlines', 'columnspacing', 'columnspan', 'denomalign', 'depth', 'dir', 'display', 'displaystyle', 'encoding', 'fence', 'frame', 'height', 'href', 'id', 'largeop', 'length', 'linethickness', 'lquote', 'lspace', 'mathbackground', 'mathcolor', 'mathsize', 'mathvariant', 'maxsize', 'minsize', 'movablelimits', 'notation', 'numalign', 'open', 'rowalign', 'rowlines', 'rowspacing', 'rowspan', 'rspace', 'rquote', 'scriptlevel', 'scriptminsize', 'scriptsizemultiplier', 'selection', 'separator', 'separators', 'stretchy', 'subscriptshift', 'supscriptshift', 'symmetric', 'voffset', 'width', 'xmlns']);\nconst xml = freeze(['xlink:href', 'xml:id', 'xlink:title', 'xml:space', 'xmlns:xlink']);\n\nconst MUSTACHE_EXPR = seal(/{{[\\w\\W]*|^[\\w\\W]*}}/g);\nconst ERB_EXPR = seal(/<%[\\w\\W]*|^[\\w\\W]*%>/g);\nconst TMPLIT_EXPR = seal(/\\${[\\w\\W]*/g);\nconst DATA_ATTR = seal(/^data-[\\-\\w.\\u00B7-\\uFFFF]+$/); // eslint-disable-line no-useless-escape\nconst ARIA_ATTR = seal(/^aria-[\\-\\w]+$/); // eslint-disable-line no-useless-escape\nconst IS_ALLOWED_URI = seal(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\\-]+(?:[^a-z+.\\-:]|$))/i // eslint-disable-line no-useless-escape\n);\nconst IS_SCRIPT_OR_DATA = seal(/^(?:\\w+script|data):/i);\nconst ATTR_WHITESPACE = seal(/[\\u0000-\\u0020\\u00A0\\u1680\\u180E\\u2000-\\u2029\\u205F\\u3000]/g // eslint-disable-line no-control-regex\n);\nconst DOCTYPE_NAME = seal(/^html$/i);\nconst CUSTOM_ELEMENT = seal(/^[a-z][.\\w]*(-[.\\w]+)+$/i);\n// Markup-significant character probes used by _sanitizeElements.\n// Shared module-level instances are safe despite the sticky /g flags:\n// unapply() resets lastIndex for RegExp receivers before every call.\nconst ELEMENT_MARKUP_PROBE = seal(/<[/\\w!]/g);\nconst COMMENT_MARKUP_PROBE = seal(/<[/\\w]/g);\nconst FALLBACK_TAG_CLOSE = seal(/<\\/no(script|embed|frames)/i);\nconst SELF_CLOSING_TAG = seal(/\\/>/i);\n\n// https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType\nconst NODE_TYPE = {\n element: 1,\n attribute: 2,\n text: 3,\n cdataSection: 4,\n entityReference: 5,\n // Deprecated\n entityNode: 6,\n // Deprecated\n processingInstruction: 7,\n comment: 8,\n document: 9,\n documentType: 10,\n documentFragment: 11,\n notation: 12 // Deprecated\n};\nconst getGlobal = function getGlobal() {\n return typeof window === 'undefined' ? null : window;\n};\n/**\n * Creates a no-op policy for internal use only.\n * Don't export this function outside this module!\n * @param trustedTypes The policy factory.\n * @param purifyHostElement The Script element used to load DOMPurify (to determine policy name suffix).\n * @return The policy created (or null, if Trusted Types\n * are not supported or creating the policy failed).\n */\nconst _createTrustedTypesPolicy = function _createTrustedTypesPolicy(trustedTypes, purifyHostElement) {\n if (typeof trustedTypes !== 'object' || typeof trustedTypes.createPolicy !== 'function') {\n return null;\n }\n // Allow the callers to control the unique policy name\n // by adding a data-tt-policy-suffix to the script element with the DOMPurify.\n // Policy creation with duplicate names throws in Trusted Types.\n let suffix = null;\n const ATTR_NAME = 'data-tt-policy-suffix';\n if (purifyHostElement && purifyHostElement.hasAttribute(ATTR_NAME)) {\n suffix = purifyHostElement.getAttribute(ATTR_NAME);\n }\n const policyName = 'dompurify' + (suffix ? '#' + suffix : '');\n try {\n return trustedTypes.createPolicy(policyName, {\n createHTML(html) {\n return html;\n },\n createScriptURL(scriptUrl) {\n return scriptUrl;\n }\n });\n } catch (_) {\n // Policy creation failed (most likely another DOMPurify script has\n // already run). Skip creating the policy, as this will only cause errors\n // if TT are enforced.\n console.warn('TrustedTypes policy ' + policyName + ' could not be created.');\n return null;\n }\n};\nconst _createHooksMap = function _createHooksMap() {\n return {\n afterSanitizeAttributes: [],\n afterSanitizeElements: [],\n afterSanitizeShadowDOM: [],\n beforeSanitizeAttributes: [],\n beforeSanitizeElements: [],\n beforeSanitizeShadowDOM: [],\n uponSanitizeAttribute: [],\n uponSanitizeElement: [],\n uponSanitizeShadowNode: []\n };\n};\n/**\n * Resolve a set-valued configuration option: a fresh set built from\n * cfg[key] when it is an own array property (seeded with a clone of\n * options.base when given, case-normalized via options.transform),\n * the fallback set otherwise.\n *\n * @param cfg the cloned, prototype-free configuration object\n * @param key the configuration property to read\n * @param fallback the set to use when the option is absent or not an array\n * @param options transform and optional base set to merge into\n * @returns the resolved set\n */\nconst _resolveSetOption = function _resolveSetOption(cfg, key, fallback, options) {\n return objectHasOwnProperty(cfg, key) && arrayIsArray(cfg[key]) ? addToSet(options.base ? clone(options.base) : {}, cfg[key], options.transform) : fallback;\n};\nfunction createDOMPurify() {\n let window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGlobal();\n const DOMPurify = root => createDOMPurify(root);\n DOMPurify.version = '3.4.11';\n DOMPurify.removed = [];\n if (!window || !window.document || window.document.nodeType !== NODE_TYPE.document || !window.Element) {\n // Not running in a browser, provide a factory function\n // so that you can pass your own Window\n DOMPurify.isSupported = false;\n return DOMPurify;\n }\n let document = window.document;\n const originalDocument = document;\n const currentScript = originalDocument.currentScript;\n window.DocumentFragment;\n const HTMLTemplateElement = window.HTMLTemplateElement,\n Node = window.Node,\n Element = window.Element,\n NodeFilter = window.NodeFilter,\n _window$NamedNodeMap = window.NamedNodeMap;\n _window$NamedNodeMap === void 0 ? window.NamedNodeMap || window.MozNamedAttrMap : _window$NamedNodeMap;\n window.HTMLFormElement;\n const DOMParser = window.DOMParser,\n trustedTypes = window.trustedTypes;\n const ElementPrototype = Element.prototype;\n const cloneNode = lookupGetter(ElementPrototype, 'cloneNode');\n const remove = lookupGetter(ElementPrototype, 'remove');\n const getNextSibling = lookupGetter(ElementPrototype, 'nextSibling');\n const getChildNodes = lookupGetter(ElementPrototype, 'childNodes');\n const getParentNode = lookupGetter(ElementPrototype, 'parentNode');\n const getShadowRoot = lookupGetter(ElementPrototype, 'shadowRoot');\n const getAttributes = lookupGetter(ElementPrototype, 'attributes');\n const getNodeType = Node && Node.prototype ? lookupGetter(Node.prototype, 'nodeType') : null;\n const getNodeName = Node && Node.prototype ? lookupGetter(Node.prototype, 'nodeName') : null;\n // As per issue #47, the web-components registry is inherited by a\n // new document created via createHTMLDocument. As per the spec\n // (http://w3c.github.io/webcomponents/spec/custom/#creating-and-passing-registries)\n // a new empty registry is used when creating a template contents owner\n // document, so we use that as our parent document to ensure nothing\n // is inherited.\n if (typeof HTMLTemplateElement === 'function') {\n const template = document.createElement('template');\n if (template.content && template.content.ownerDocument) {\n document = template.content.ownerDocument;\n }\n }\n let trustedTypesPolicy;\n let emptyHTML = '';\n // The instance's own internal Trusted Types policy. Unlike a caller-supplied\n // `TRUSTED_TYPES_POLICY`, this is created at most once — Trusted Types throws\n // on duplicate policy names — and is the only policy allowed to persist\n // across configurations and survive `clearConfig()`.\n let defaultTrustedTypesPolicy;\n let defaultTrustedTypesPolicyResolved = false;\n // Tracks whether we are already inside a call to the configured Trusted Types\n // policy (`createHTML` or `createScriptURL`). If a supplied policy callback\n // itself calls `DOMPurify.sanitize` (the cause of #1422), `sanitize` would\n // re-enter the policy and recurse until the stack overflows. We detect that\n // re-entry and throw a clear, actionable error instead. The guard is shared\n // across both callbacks, because either one re-entering `sanitize` triggers\n // the same unbounded recursion.\n let IN_TRUSTED_TYPES_POLICY = 0;\n const _assertNotInTrustedTypesPolicy = function _assertNotInTrustedTypesPolicy() {\n if (IN_TRUSTED_TYPES_POLICY > 0) {\n throw typeErrorCreate('A configured TRUSTED_TYPES_POLICY callback (createHTML or ' + 'createScriptURL) must not call DOMPurify.sanitize, as that causes ' + 'infinite recursion. Do not pass a policy whose callbacks wrap ' + 'DOMPurify as TRUSTED_TYPES_POLICY; see the \"DOMPurify and Trusted ' + 'Types\" section of the README.');\n }\n };\n const _createTrustedHTML = function _createTrustedHTML(html) {\n _assertNotInTrustedTypesPolicy();\n IN_TRUSTED_TYPES_POLICY++;\n try {\n return trustedTypesPolicy.createHTML(html);\n } finally {\n IN_TRUSTED_TYPES_POLICY--;\n }\n };\n const _createTrustedScriptURL = function _createTrustedScriptURL(scriptUrl) {\n _assertNotInTrustedTypesPolicy();\n IN_TRUSTED_TYPES_POLICY++;\n try {\n return trustedTypesPolicy.createScriptURL(scriptUrl);\n } finally {\n IN_TRUSTED_TYPES_POLICY--;\n }\n };\n // Lazily resolve (and cache) the instance's internal default policy.\n // Resolution is attempted at most once: a successful `createPolicy` cannot be\n // repeated (Trusted Types throws on duplicate names), and a failed or\n // unsupported attempt must not be retried on every parse.\n const _getDefaultTrustedTypesPolicy = function _getDefaultTrustedTypesPolicy() {\n if (!defaultTrustedTypesPolicyResolved) {\n defaultTrustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript);\n defaultTrustedTypesPolicyResolved = true;\n }\n return defaultTrustedTypesPolicy;\n };\n const _document = document,\n implementation = _document.implementation,\n createNodeIterator = _document.createNodeIterator,\n createDocumentFragment = _document.createDocumentFragment,\n getElementsByTagName = _document.getElementsByTagName;\n const importNode = originalDocument.importNode;\n let hooks = _createHooksMap();\n /**\n * Expose whether this browser supports running the full DOMPurify.\n */\n DOMPurify.isSupported = typeof entries === 'function' && typeof getParentNode === 'function' && implementation && implementation.createHTMLDocument !== undefined;\n const MUSTACHE_EXPR$1 = MUSTACHE_EXPR,\n ERB_EXPR$1 = ERB_EXPR,\n TMPLIT_EXPR$1 = TMPLIT_EXPR,\n DATA_ATTR$1 = DATA_ATTR,\n ARIA_ATTR$1 = ARIA_ATTR,\n IS_SCRIPT_OR_DATA$1 = IS_SCRIPT_OR_DATA,\n ATTR_WHITESPACE$1 = ATTR_WHITESPACE,\n CUSTOM_ELEMENT$1 = CUSTOM_ELEMENT;\n let IS_ALLOWED_URI$1 = IS_ALLOWED_URI;\n /**\n * We consider the elements and attributes below to be safe. Ideally\n * don't add any new ones but feel free to remove unwanted ones.\n */\n /* allowed element names */\n let ALLOWED_TAGS = null;\n const DEFAULT_ALLOWED_TAGS = addToSet({}, [...html$1, ...svg$1, ...svgFilters, ...mathMl$1, ...text]);\n /* Allowed attribute names */\n let ALLOWED_ATTR = null;\n const DEFAULT_ALLOWED_ATTR = addToSet({}, [...html, ...svg, ...mathMl, ...xml]);\n /*\n * Configure how DOMPurify should handle custom elements and their attributes as well as customized built-in elements.\n * @property {RegExp|Function|null} tagNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any custom elements)\n * @property {RegExp|Function|null} attributeNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any attributes not on the allow list)\n * @property {boolean} allowCustomizedBuiltInElements allow custom elements derived from built-ins if they pass CUSTOM_ELEMENT_HANDLING.tagNameCheck. Default: `false`.\n */\n let CUSTOM_ELEMENT_HANDLING = Object.seal(create(null, {\n tagNameCheck: {\n writable: true,\n configurable: false,\n enumerable: true,\n value: null\n },\n attributeNameCheck: {\n writable: true,\n configurable: false,\n enumerable: true,\n value: null\n },\n allowCustomizedBuiltInElements: {\n writable: true,\n configurable: false,\n enumerable: true,\n value: false\n }\n }));\n /* Explicitly forbidden tags (overrides ALLOWED_TAGS/ADD_TAGS) */\n let FORBID_TAGS = null;\n /* Explicitly forbidden attributes (overrides ALLOWED_ATTR/ADD_ATTR) */\n let FORBID_ATTR = null;\n /* Config object to store ADD_TAGS/ADD_ATTR functions (when used as functions) */\n const EXTRA_ELEMENT_HANDLING = Object.seal(create(null, {\n tagCheck: {\n writable: true,\n configurable: false,\n enumerable: true,\n value: null\n },\n attributeCheck: {\n writable: true,\n configurable: false,\n enumerable: true,\n value: null\n }\n }));\n /* Decide if ARIA attributes are okay */\n let ALLOW_ARIA_ATTR = true;\n /* Decide if custom data attributes are okay */\n let ALLOW_DATA_ATTR = true;\n /* Decide if unknown protocols are okay */\n let ALLOW_UNKNOWN_PROTOCOLS = false;\n /* Decide if self-closing tags in attributes are allowed.\n * Usually removed due to a mXSS issue in jQuery 3.0 */\n let ALLOW_SELF_CLOSE_IN_ATTR = true;\n /* Output should be safe for common template engines.\n * This means, DOMPurify removes data attributes, mustaches and ERB\n */\n let SAFE_FOR_TEMPLATES = false;\n /* Output should be safe even for XML used within HTML and alike.\n * This means, DOMPurify removes comments when containing risky content.\n */\n let SAFE_FOR_XML = true;\n /* Decide if document with <html>... should be returned */\n let WHOLE_DOCUMENT = false;\n /* Track whether config is already set on this instance of DOMPurify. */\n let SET_CONFIG = false;\n /* Pristine allowlist bindings captured at setConfig() time. On the\n * persistent-config path sanitize() restores the sets from these before\n * the per-walk hook clone-guard, so a hook's in-call widening cannot\n * carry across calls. Null until setConfig() is called; reset by\n * clearConfig(). */\n let SET_CONFIG_ALLOWED_TAGS = null;\n let SET_CONFIG_ALLOWED_ATTR = null;\n /* Decide if all elements (e.g. style, script) must be children of\n * document.body. By default, browsers might move them to document.head */\n let FORCE_BODY = false;\n /* Decide if a DOM `HTMLBodyElement` should be returned, instead of a html\n * string (or a TrustedHTML object if Trusted Types are supported).\n * If `WHOLE_DOCUMENT` is enabled a `HTMLHtmlElement` will be returned instead\n */\n let RETURN_DOM = false;\n /* Decide if a DOM `DocumentFragment` should be returned, instead of a html\n * string (or a TrustedHTML object if Trusted Types are supported) */\n let RETURN_DOM_FRAGMENT = false;\n /* Try to return a Trusted Type object instead of a string, return a string in\n * case Trusted Types are not supported */\n let RETURN_TRUSTED_TYPE = false;\n /* Output should be free from DOM clobbering attacks?\n * This sanitizes markups named with colliding, clobberable built-in DOM APIs.\n */\n let SANITIZE_DOM = true;\n /* Achieve full DOM Clobbering protection by isolating the namespace of named\n * properties and JS variables, mitigating attacks that abuse the HTML/DOM spec rules.\n *\n * HTML/DOM spec rules that enable DOM Clobbering:\n * - Named Access on Window (§7.3.3)\n * - DOM Tree Accessors (§3.1.5)\n * - Form Element Parent-Child Relations (§4.10.3)\n * - Iframe srcdoc / Nested WindowProxies (§4.8.5)\n * - HTMLCollection (§4.2.10.2)\n *\n * Namespace isolation is implemented by prefixing `id` and `name` attributes\n * with a constant string, i.e., `user-content-`\n */\n let SANITIZE_NAMED_PROPS = false;\n const SANITIZE_NAMED_PROPS_PREFIX = 'user-content-';\n /* Keep element content when removing element? */\n let KEEP_CONTENT = true;\n /* If a `Node` is passed to sanitize(), then performs sanitization in-place instead\n * of importing it into a new Document and returning a sanitized copy */\n let IN_PLACE = false;\n /* Allow usage of profiles like html, svg and mathMl */\n let USE_PROFILES = {};\n /* Tags to ignore content of when KEEP_CONTENT is true */\n let FORBID_CONTENTS = null;\n const DEFAULT_FORBID_CONTENTS = addToSet({}, ['annotation-xml', 'audio', 'colgroup', 'desc', 'foreignobject', 'head', 'iframe', 'math', 'mi', 'mn', 'mo', 'ms', 'mtext', 'noembed', 'noframes', 'noscript', 'plaintext', 'script',\n // <selectedcontent> mirrors the selected <option>'s subtree, cloned by\n // the UA (customizable <select>) — including any on* handlers — and the\n // engine re-mirrors synchronously whenever a removal changes which\n // option/selectedcontent is current, even inside DOMPurify's inert\n // DOMParser document. Hoisting its children on removal re-inserts a fresh\n // mirror target ahead of the walk, which the engine refills, looping\n // forever (DoS) and amplifying output. Dropping its content on removal\n // (rather than hoisting) breaks that cascade; the content is a duplicate\n // of the option, which is sanitized on its own. See campaign-3 F1/F6.\n 'selectedcontent', 'style', 'svg', 'template', 'thead', 'title', 'video', 'xmp']);\n /* Tags that are safe for data: URIs */\n let DATA_URI_TAGS = null;\n const DEFAULT_DATA_URI_TAGS = addToSet({}, ['audio', 'video', 'img', 'source', 'image', 'track']);\n /* Attributes safe for values like \"javascript:\" */\n let URI_SAFE_ATTRIBUTES = null;\n const DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ['alt', 'class', 'for', 'id', 'label', 'name', 'pattern', 'placeholder', 'role', 'summary', 'title', 'value', 'style', 'xmlns']);\n const MATHML_NAMESPACE = 'http://www.w3.org/1998/Math/MathML';\n const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';\n const HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml';\n /* Document namespace */\n let NAMESPACE = HTML_NAMESPACE;\n let IS_EMPTY_INPUT = false;\n /* Allowed XHTML+XML namespaces */\n let ALLOWED_NAMESPACES = null;\n const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [MATHML_NAMESPACE, SVG_NAMESPACE, HTML_NAMESPACE], stringToString);\n const DEFAULT_MATHML_TEXT_INTEGRATION_POINTS = freeze(['mi', 'mo', 'mn', 'ms', 'mtext']);\n let MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, DEFAULT_MATHML_TEXT_INTEGRATION_POINTS);\n const DEFAULT_HTML_INTEGRATION_POINTS = freeze(['annotation-xml']);\n let HTML_INTEGRATION_POINTS = addToSet({}, DEFAULT_HTML_INTEGRATION_POINTS);\n // Certain elements are allowed in both SVG and HTML\n // namespace. We need to specify them explicitly\n // so that they don't get erroneously deleted from\n // HTML namespace.\n const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, ['title', 'style', 'font', 'a', 'script']);\n /* Parsing of strict XHTML documents */\n let PARSER_MEDIA_TYPE = null;\n const SUPPORTED_PARSER_MEDIA_TYPES = ['application/xhtml+xml', 'text/html'];\n const DEFAULT_PARSER_MEDIA_TYPE = 'text/html';\n let transformCaseFunc = null;\n /* Keep a reference to config to pass to hooks */\n let CONFIG = null;\n /* Ideally, do not touch anything below this line */\n /* ______________________________________________ */\n const formElement = document.createElement('form');\n const isRegexOrFunction = function isRegexOrFunction(testValue) {\n return testValue instanceof RegExp || testValue instanceof Function;\n };\n /**\n * _parseConfig\n *\n * @param cfg optional config literal\n */\n // eslint-disable-next-line complexity\n const _parseConfig = function _parseConfig() {\n let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n if (CONFIG && CONFIG === cfg) {\n return;\n }\n /* Shield configuration object from tampering */\n if (!cfg || typeof cfg !== 'object') {\n cfg = {};\n }\n /* Shield configuration object from prototype pollution */\n cfg = clone(cfg);\n PARSER_MEDIA_TYPE =\n // eslint-disable-next-line unicorn/prefer-includes\n SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? DEFAULT_PARSER_MEDIA_TYPE : cfg.PARSER_MEDIA_TYPE;\n // HTML tags and attributes are not case-sensitive, converting to lowercase. Keeping XHTML as is.\n transformCaseFunc = PARSER_MEDIA_TYPE === 'application/xhtml+xml' ? stringToString : stringToLowerCase;\n /* Set configuration parameters */\n ALLOWED_TAGS = _resolveSetOption(cfg, 'ALLOWED_TAGS', DEFAULT_ALLOWED_TAGS, {\n transform: transformCaseFunc\n });\n ALLOWED_ATTR = _resolveSetOption(cfg, 'ALLOWED_ATTR', DEFAULT_ALLOWED_ATTR, {\n transform: transformCaseFunc\n });\n ALLOWED_NAMESPACES = _resolveSetOption(cfg, 'ALLOWED_NAMESPACES', DEFAULT_ALLOWED_NAMESPACES, {\n transform: stringToString\n });\n URI_SAFE_ATTRIBUTES = _resolveSetOption(cfg, 'ADD_URI_SAFE_ATTR', DEFAULT_URI_SAFE_ATTRIBUTES, {\n transform: transformCaseFunc,\n base: DEFAULT_URI_SAFE_ATTRIBUTES\n });\n DATA_URI_TAGS = _resolveSetOption(cfg, 'ADD_DATA_URI_TAGS', DEFAULT_DATA_URI_TAGS, {\n transform: transformCaseFunc,\n base: DEFAULT_DATA_URI_TAGS\n });\n FORBID_CONTENTS = _resolveSetOption(cfg, 'FORBID_CONTENTS', DEFAULT_FORBID_CONTENTS, {\n transform: transformCaseFunc\n });\n FORBID_TAGS = _resolveSetOption(cfg, 'FORBID_TAGS', clone({}), {\n transform: transformCaseFunc\n });\n FORBID_ATTR = _resolveSetOption(cfg, 'FORBID_ATTR', clone({}), {\n transform: transformCaseFunc\n });\n USE_PROFILES = objectHasOwnProperty(cfg, 'USE_PROFILES') ? cfg.USE_PROFILES && typeof cfg.USE_PROFILES === 'object' ? clone(cfg.USE_PROFILES) : cfg.USE_PROFILES : false;\n ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false; // Default true\n ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false; // Default true\n ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false; // Default false\n ALLOW_SELF_CLOSE_IN_ATTR = cfg.ALLOW_SELF_CLOSE_IN_ATTR !== false; // Default true\n SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false; // Default false\n SAFE_FOR_XML = cfg.SAFE_FOR_XML !== false; // Default true\n WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false; // Default false\n RETURN_DOM = cfg.RETURN_DOM || false; // Default false\n RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false; // Default false\n RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false; // Default false\n FORCE_BODY = cfg.FORCE_BODY || false; // Default false\n SANITIZE_DOM = cfg.SANITIZE_DOM !== false; // Default true\n SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false; // Default false\n KEEP_CONTENT = cfg.KEEP_CONTENT !== false; // Default true\n IN_PLACE = cfg.IN_PLACE || false; // Default false\n IS_ALLOWED_URI$1 = isRegex(cfg.ALLOWED_URI_REGEXP) ? cfg.ALLOWED_URI_REGEXP : IS_ALLOWED_URI; // Default regexp\n NAMESPACE = typeof cfg.NAMESPACE === 'string' ? cfg.NAMESPACE : HTML_NAMESPACE; // Default HTML namespace\n MATHML_TEXT_INTEGRATION_POINTS = objectHasOwnProperty(cfg, 'MATHML_TEXT_INTEGRATION_POINTS') && cfg.MATHML_TEXT_INTEGRATION_POINTS && typeof cfg.MATHML_TEXT_INTEGRATION_POINTS === 'object' ? clone(cfg.MATHML_TEXT_INTEGRATION_POINTS) : addToSet({}, DEFAULT_MATHML_TEXT_INTEGRATION_POINTS); // Default built-in map\n HTML_INTEGRATION_POINTS = objectHasOwnProperty(cfg, 'HTML_INTEGRATION_POINTS') && cfg.HTML_INTEGRATION_POINTS && typeof cfg.HTML_INTEGRATION_POINTS === 'object' ? clone(cfg.HTML_INTEGRATION_POINTS) : addToSet({}, DEFAULT_HTML_INTEGRATION_POINTS); // Default built-in map\n const customElementHandling = objectHasOwnProperty(cfg, 'CUSTOM_ELEMENT_HANDLING') && cfg.CUSTOM_ELEMENT_HANDLING && typeof cfg.CUSTOM_ELEMENT_HANDLING === 'object' ? clone(cfg.CUSTOM_ELEMENT_HANDLING) : create(null);\n CUSTOM_ELEMENT_HANDLING = create(null);\n if (objectHasOwnProperty(customElementHandling, 'tagNameCheck') && isRegexOrFunction(customElementHandling.tagNameCheck)) {\n CUSTOM_ELEMENT_HANDLING.tagNameCheck = customElementHandling.tagNameCheck; // Default undefined\n }\n if (objectHasOwnProperty(customElementHandling, 'attributeNameCheck') && isRegexOrFunction(customElementHandling.attributeNameCheck)) {\n CUSTOM_ELEMENT_HANDLING.attributeNameCheck = customElementHandling.attributeNameCheck; // Default undefined\n }\n if (objectHasOwnProperty(customElementHandling, 'allowCustomizedBuiltInElements') && typeof customElementHandling.allowCustomizedBuiltInElements === 'boolean') {\n CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = customElementHandling.allowCustomizedBuiltInElements; // Default undefined\n }\n seal(CUSTOM_ELEMENT_HANDLING);\n if (SAFE_FOR_TEMPLATES) {\n ALLOW_DATA_ATTR = false;\n }\n if (RETURN_DOM_FRAGMENT) {\n RETURN_DOM = true;\n }\n /* Parse profile info */\n if (USE_PROFILES) {\n ALLOWED_TAGS = addToSet({}, text);\n ALLOWED_ATTR = create(null);\n if (USE_PROFILES.html === true) {\n addToSet(ALLOWED_TAGS, html$1);\n addToSet(ALLOWED_ATTR, html);\n }\n if (USE_PROFILES.svg === true) {\n addToSet(ALLOWED_TAGS, svg$1);\n addToSet(ALLOWED_ATTR, svg);\n addToSet(ALLOWED_ATTR, xml);\n }\n if (USE_PROFILES.svgFilters === true) {\n addToSet(ALLOWED_TAGS, svgFilters);\n addToSet(ALLOWED_ATTR, svg);\n addToSet(ALLOWED_ATTR, xml);\n }\n if (USE_PROFILES.mathMl === true) {\n addToSet(ALLOWED_TAGS, mathMl$1);\n addToSet(ALLOWED_ATTR, mathMl);\n addToSet(ALLOWED_ATTR, xml);\n }\n }\n /* Always reset function-based ADD_TAGS / ADD_ATTR checks to prevent\n * leaking across calls when switching from function to array config */\n EXTRA_ELEMENT_HANDLING.tagCheck = null;\n EXTRA_ELEMENT_HANDLING.attributeCheck = null;\n /* Merge configuration parameters */\n if (objectHasOwnProperty(cfg, 'ADD_TAGS')) {\n if (typeof cfg.ADD_TAGS === 'function') {\n EXTRA_ELEMENT_HANDLING.tagCheck = cfg.ADD_TAGS;\n } else if (arrayIsArray(cfg.ADD_TAGS)) {\n if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {\n ALLOWED_TAGS = clone(ALLOWED_TAGS);\n }\n addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc);\n }\n }\n if (objectHasOwnProperty(cfg, 'ADD_ATTR')) {\n if (typeof cfg.ADD_ATTR === 'function') {\n EXTRA_ELEMENT_HANDLING.attributeCheck = cfg.ADD_ATTR;\n } else if (arrayIsArray(cfg.ADD_ATTR)) {\n if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) {\n ALLOWED_ATTR = clone(ALLOWED_ATTR);\n }\n addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc);\n }\n }\n if (objectHasOwnProperty(cfg, 'ADD_URI_SAFE_ATTR') && arrayIsArray(cfg.ADD_URI_SAFE_ATTR)) {\n addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR, transformCaseFunc);\n }\n if (objectHasOwnProperty(cfg, 'FORBID_CONTENTS') && arrayIsArray(cfg.FORBID_CONTENTS)) {\n if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {\n FORBID_CONTENTS = clone(FORBID_CONTENTS);\n }\n addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS, transformCaseFunc);\n }\n if (objectHasOwnProperty(cfg, 'ADD_FORBID_CONTENTS') && arrayIsArray(cfg.ADD_FORBID_CONTENTS)) {\n if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {\n FORBID_CONTENTS = clone(FORBID_CONTENTS);\n }\n addToSet(FORBID_CONTENTS, cfg.ADD_FORBID_CONTENTS, transformCaseFunc);\n }\n /* Add #text in case KEEP_CONTENT is set to true */\n if (KEEP_CONTENT) {\n ALLOWED_TAGS['#text'] = true;\n }\n /* Add html, head and body to ALLOWED_TAGS in case WHOLE_DOCUMENT is true */\n if (WHOLE_DOCUMENT) {\n addToSet(ALLOWED_TAGS, ['html', 'head', 'body']);\n }\n /* Add tbody to ALLOWED_TAGS in case tables are permitted, see #286, #365 */\n if (ALLOWED_TAGS.table) {\n addToSet(ALLOWED_TAGS, ['tbody']);\n delete FORBID_TAGS.tbody;\n }\n // Re-derive the active Trusted Types policy from this configuration on\n // every parse. The active policy must never be sticky closure state that\n // outlives the config that set it: a caller-supplied policy left in place\n // after `clearConfig()` — or after a later call that supplied none, or\n // `TRUSTED_TYPES_POLICY: null` — could sign a subsequent \"default\"\n // `RETURN_TRUSTED_TYPE` result with a foreign, possibly unsafe policy.\n // See GHSA-vxr8-fq34-vvx9.\n if (cfg.TRUSTED_TYPES_POLICY) {\n if (typeof cfg.TRUSTED_TYPES_POLICY.createHTML !== 'function') {\n throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a \"createHTML\" hook.');\n }\n if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== 'function') {\n throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a \"createScriptURL\" hook.');\n }\n // A caller-supplied policy applies to this configuration only.\n const previousTrustedTypesPolicy = trustedTypesPolicy;\n trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY;\n // Sign local variables required by `sanitize`. If the supplied policy's\n // `createHTML` is circular (i.e. it calls `DOMPurify.sanitize`), this\n // throws via the re-entrancy guard. Restore the previous policy first so\n // the instance is not left in a poisoned state. See #1422.\n try {\n emptyHTML = _createTrustedHTML('');\n } catch (error) {\n trustedTypesPolicy = previousTrustedTypesPolicy;\n throw error;\n }\n } else if (cfg.TRUSTED_TYPES_POLICY === null) {\n // Explicit opt-out for this call: perform no Trusted Types signing and\n // create nothing (so a strict `trusted-types` CSP that disallows a\n // `dompurify` policy can still call `sanitize` from inside its own\n // policy — see #1422). Resetting to `undefined` rather than a sticky\n // `null` also drops any previously retained caller policy, so it cannot\n // resurface on a later call, while still allowing the next config-less\n // call to restore the internal default policy. See GHSA-vxr8-fq34-vvx9.\n trustedTypesPolicy = undefined;\n emptyHTML = '';\n } else {\n // No policy supplied: keep the currently active policy if one is set — a\n // previously supplied policy is intentionally sticky across config-less\n // calls — otherwise fall back to the instance's own internal policy,\n // created at most once. (A policy supplied for a *single* call still\n // lingers by design; what must not linger is a policy whose configuration\n // has been torn down via `clearConfig()`, which restores the default.)\n if (trustedTypesPolicy === undefined) {\n trustedTypesPolicy = _getDefaultTrustedTypesPolicy();\n }\n // Sign internal variables only when a policy is active. A falsy policy\n // (Trusted Types unsupported, creation failed, or an explicit opt-out)\n // leaves `emptyHTML` as a plain string, so we never call `.createHTML` on\n // a non-policy and throw. See #1422.\n if (trustedTypesPolicy && typeof emptyHTML === 'string') {\n emptyHTML = _createTrustedHTML('');\n }\n }\n // Prevent further manipulation of configuration.\n // Not available in IE8, Safari 5, etc.\n if (freeze) {\n freeze(cfg);\n }\n CONFIG = cfg;\n };\n /* Keep track of all possible SVG and MathML tags\n * so that we can perform the namespace checks\n * correctly. */\n const ALL_SVG_TAGS = addToSet({}, [...svg$1, ...svgFilters, ...svgDisallowed]);\n const ALL_MATHML_TAGS = addToSet({}, [...mathMl$1, ...mathMlDisallowed]);\n /**\n * Namespace rules for an element in the SVG namespace.\n *\n * @param tagName the element's lowercase tag name\n * @param parent the (possibly simulated) parent node\n * @param parentTagName the parent's lowercase tag name\n * @returns true if a spec-compliant parser could produce this element\n */\n const _checkSvgNamespace = function _checkSvgNamespace(tagName, parent, parentTagName) {\n // The only way to switch from HTML namespace to SVG\n // is via <svg>. If it happens via any other tag, then\n // it should be killed.\n if (parent.namespaceURI === HTML_NAMESPACE) {\n return tagName === 'svg';\n }\n // The only way to switch from MathML to SVG is via <svg>\n // if the parent is either <annotation-xml> or a MathML\n // text integration point.\n if (parent.namespaceURI === MATHML_NAMESPACE) {\n return tagName === 'svg' && (parentTagName === 'annotation-xml' || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);\n }\n // We only allow elements that are defined in SVG\n // spec. All others are disallowed in SVG namespace.\n return Boolean(ALL_SVG_TAGS[tagName]);\n };\n /**\n * Namespace rules for an element in the MathML namespace.\n *\n * @param tagName the element's lowercase tag name\n * @param parent the (possibly simulated) parent node\n * @param parentTagName the parent's lowercase tag name\n * @returns true if a spec-compliant parser could produce this element\n */\n const _checkMathMlNamespace = function _checkMathMlNamespace(tagName, parent, parentTagName) {\n // The only way to switch from HTML namespace to MathML\n // is via <math>. If it happens via any other tag, then\n // it should be killed.\n if (parent.namespaceURI === HTML_NAMESPACE) {\n return tagName === 'math';\n }\n // The only way to switch from SVG to MathML is via\n // <math> and HTML integration points\n if (parent.namespaceURI === SVG_NAMESPACE) {\n return tagName === 'math' && HTML_INTEGRATION_POINTS[parentTagName];\n }\n // We only allow elements that are defined in MathML\n // spec. All others are disallowed in MathML namespace.\n return Boolean(ALL_MATHML_TAGS[tagName]);\n };\n /**\n * Namespace rules for an element in the HTML namespace.\n *\n * @param tagName the element's lowercase tag name\n * @param parent the (possibly simulated) parent node\n * @param parentTagName the parent's lowercase tag name\n * @returns true if a spec-compliant parser could produce this element\n */\n const _checkHtmlNamespace = function _checkHtmlNamespace(tagName, parent, parentTagName) {\n // The only way to switch from SVG to HTML is via\n // HTML integration points, and from MathML to HTML\n // is via MathML text integration points\n if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) {\n return false;\n }\n if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {\n return false;\n }\n // We disallow tags that are specific for MathML\n // or SVG and should never appear in HTML namespace\n return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);\n };\n /**\n * @param element a DOM element whose namespace is being checked\n * @returns Return false if the element has a\n * namespace that a spec-compliant parser would never\n * return. Return true otherwise.\n */\n const _checkValidNamespace = function _checkValidNamespace(element) {\n let parent = getParentNode(element);\n // In JSDOM, if we're inside shadow DOM, then parentNode\n // can be null. We just simulate parent in this case.\n if (!parent || !parent.tagName) {\n parent = {\n namespaceURI: NAMESPACE,\n tagName: 'template'\n };\n }\n const tagName = stringToLowerCase(element.tagName);\n const parentTagName = stringToLowerCase(parent.tagName);\n if (!ALLOWED_NAMESPACES[element.namespaceURI]) {\n return false;\n }\n if (element.namespaceURI === SVG_NAMESPACE) {\n return _checkSvgNamespace(tagName, parent, parentTagName);\n }\n if (element.namespaceURI === MATHML_NAMESPACE) {\n return _checkMathMlNamespace(tagName, parent, parentTagName);\n }\n if (element.namespaceURI === HTML_NAMESPACE) {\n return _checkHtmlNamespace(tagName, parent, parentTagName);\n }\n // For XHTML and XML documents that support custom namespaces\n if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && ALLOWED_NAMESPACES[element.namespaceURI]) {\n return true;\n }\n // The code should never reach this place (this means\n // that the element somehow got namespace that is not\n // HTML, SVG, MathML or allowed via ALLOWED_NAMESPACES).\n // Return false just in case.\n return false;\n };\n /**\n * _forceRemove\n *\n * @param node a DOM node\n */\n const _forceRemove = function _forceRemove(node) {\n arrayPush(DOMPurify.removed, {\n element: node\n });\n try {\n // eslint-disable-next-line unicorn/prefer-dom-node-remove\n getParentNode(node).removeChild(node);\n } catch (_) {\n /* The normal detach failed — this is reached for a parentless node\n (getParentNode() is null, so .removeChild throws). Element.prototype\n .remove() is itself a spec no-op on a parentless node, so a recorded\n \"removal\" would otherwise hand the caller back an intact,\n payload-bearing node (e.g. a detached IN_PLACE root the mXSS canary or\n the style-with-element-child rule decided to kill). Fail closed by\n throwing — exactly as a clobbered root does at the IN_PLACE entry —\n rather than trying to \"neutralize\" the node via its own methods.\n Neutralizing would mean calling getAttributeNames()/removeAttribute()\n on the node, both of which a <form> root can clobber via a named child\n (and _isClobbered does not even probe getAttributeNames), so the\n neutralize step could itself be silently defeated, leaving the payload\n intact. A throw touches only the cached, clobber-safe remove() and\n getParentNode(). Generalizes GHSA-r47g-fvhr-h676 (clobbered-form root)\n to every root-kill reason. REPORT-3.\n This lives inside the catch, so it never fires for a normally-removed\n in-tree node: those have a parent, removeChild() succeeds, and the\n catch is not entered. Only a kept (parentless) root reaches here. */\n remove(node);\n if (!getParentNode(node)) {\n throw typeErrorCreate('a node selected for removal could not be detached from its tree ' + 'and cannot be safely returned; refusing to sanitize in place');\n }\n }\n };\n /**\n * _neutralizeRoot\n *\n * Fail-closed teardown of an in-place root after the sanitize walk aborts\n * (campaign-3 F2). An internal throw mid-walk — e.g. a page-registered\n * custom element's reaction detaches a node so `_forceRemove`'s deliberate\n * parentless guard throws, or any other re-entrant engine mutation — would\n * otherwise leave the caller's *live* tree half-sanitized, with everything\n * after the abort point still carrying its handlers. There is no safe way\n * to resume the walk (the tree mutated under us), so we strip the root bare:\n * remove every child and every attribute, then let the caller's catch see\n * the original error. Clobber-safe (cached `remove`/`childNodes`/`attributes`\n * getters; the root was already clobber-pre-flighted at the IN_PLACE entry).\n *\n * @param root the in-place root to empty\n */\n const _neutralizeRoot = function _neutralizeRoot(root) {\n const childNodes = getChildNodes(root);\n if (childNodes) {\n const snapshot = [];\n arrayForEach(childNodes, child => {\n arrayPush(snapshot, child);\n });\n arrayForEach(snapshot, child => {\n try {\n remove(child);\n } catch (_) {\n /* Best-effort teardown; a still-attached child is handled below */\n }\n });\n }\n const attributes = getAttributes(root);\n if (attributes) {\n for (let i = attributes.length - 1; i >= 0; --i) {\n const attribute = attributes[i];\n const name = attribute && attribute.name;\n if (typeof name === 'string') {\n try {\n root.removeAttribute(name);\n } catch (_) {\n /* Clobbered removeAttribute — ignore (fail-closed best effort) */\n }\n }\n }\n }\n };\n /**\n * _removeAttribute\n *\n * @param name an Attribute name\n * @param element a DOM node\n */\n const _removeAttribute = function _removeAttribute(name, element) {\n try {\n arrayPush(DOMPurify.removed, {\n attribute: element.getAttributeNode(name),\n from: element\n });\n } catch (_) {\n arrayPush(DOMPurify.removed, {\n attribute: null,\n from: element\n });\n }\n element.removeAttribute(name);\n // We void attribute values for unremovable \"is\" attributes\n if (name === 'is') {\n if (RETURN_DOM || RETURN_DOM_FRAGMENT) {\n try {\n _forceRemove(element);\n } catch (_) {}\n } else {\n try {\n element.setAttribute(name, '');\n } catch (_) {}\n }\n }\n };\n /**\n * _stripDisallowedAttributes\n *\n * Removes every attribute the active configuration does not allow from a\n * single element, using the same allowlist as the main attribute pass (so\n * `on*` handlers go, but no `/^on/` blocklist is introduced). Used only to\n * neutralise nodes that are being discarded from an in-place tree.\n *\n * @param element the element to strip\n */\n const _stripDisallowedAttributes = function _stripDisallowedAttributes(element) {\n const attributes = getAttributes(element);\n if (!attributes) {\n return;\n }\n for (let i = attributes.length - 1; i >= 0; --i) {\n const attribute = attributes[i];\n const name = attribute && attribute.name;\n if (typeof name !== 'string' || ALLOWED_ATTR[transformCaseFunc(name)]) {\n continue;\n }\n try {\n element.removeAttribute(name);\n } catch (_) {\n /* Clobbered removeAttribute on a doomed node — ignore */\n }\n }\n };\n /**\n * _neutralizeSubtree\n *\n * Completes the audit-5 F1 fix across every removal path. The KEEP_CONTENT\n * move-hoist neutralises only disallowed-tag removals; clobber, mXSS-canary,\n * namespace, comment, processing-instruction and KEEP_CONTENT:false removals\n * all drop their subtree wholesale via `_forceRemove`. On the IN_PLACE path\n * those dropped nodes are detached from the caller's LIVE tree but a\n * handler-bearing original among them (an `<img onerror>`/`<video>` that was\n * loading) keeps its queued resource event, which fires in page scope after\n * sanitize returns. This walks a removed subtree and strips every attribute\n * the active configuration does not allow — so `on*` handlers are cancelled\n * through the SAME allowlist that governs kept nodes, not a separate `/^on/`\n * blocklist. Run synchronously before sanitize returns, i.e. before any\n * queued event can fire. Hook-free by design: these nodes leave the output,\n * so firing attribute hooks for them would be surprising. Clobber-safe reads;\n * a doomed clobbered node may shadow `removeAttribute` (its own attributes are\n * irrelevant — it is discarded — while its non-clobbered descendants, e.g.\n * the `<img>`, are reached and scrubbed).\n *\n * @param root the root of a removed subtree to neutralise\n */\n const _neutralizeSubtree = function _neutralizeSubtree(root) {\n const stack = [root];\n while (stack.length > 0) {\n const node = stack.pop();\n const nodeType = getNodeType ? getNodeType(node) : node.nodeType;\n if (nodeType === NODE_TYPE.element) {\n _stripDisallowedAttributes(node);\n }\n const childNodes = getChildNodes(node);\n if (childNodes) {\n for (let i = childNodes.length - 1; i >= 0; --i) {\n stack.push(childNodes[i]);\n }\n }\n }\n };\n /**\n * _initDocument\n *\n * @param dirty - a string of dirty markup\n * @return a DOM, filled with the dirty markup\n */\n const _initDocument = function _initDocument(dirty) {\n /* Create a HTML document */\n let doc = null;\n let leadingWhitespace = null;\n if (FORCE_BODY) {\n dirty = '<remove></remove>' + dirty;\n } else {\n /* If FORCE_BODY isn't used, leading whitespace needs to be preserved manually */\n const matches = stringMatch(dirty, /^[\\r\\n\\t ]+/);\n leadingWhitespace = matches && matches[0];\n }\n if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && NAMESPACE === HTML_NAMESPACE) {\n // Root of XHTML doc must contain xmlns declaration (see https://www.w3.org/TR/xhtml1/normative.html#strict)\n dirty = '<html xmlns=\"http://www.w3.org/1999/xhtml\"><head></head><body>' + dirty + '</body></html>';\n }\n const dirtyPayload = trustedTypesPolicy ? _createTrustedHTML(dirty) : dirty;\n /*\n * Use the DOMParser API by default, fallback later if needs be\n * DOMParser not work for svg when has multiple root element.\n */\n if (NAMESPACE === HTML_NAMESPACE) {\n try {\n doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE);\n } catch (_) {}\n }\n /* Use createHTMLDocument in case DOMParser is not available */\n if (!doc || !doc.documentElement) {\n doc = implementation.createDocument(NAMESPACE, 'template', null);\n try {\n doc.documentElement.innerHTML = IS_EMPTY_INPUT ? emptyHTML : dirtyPayload;\n } catch (_) {\n // Syntax error if dirtyPayload is invalid xml\n }\n }\n const body = doc.body || doc.documentElement;\n if (dirty && leadingWhitespace) {\n body.insertBefore(document.createTextNode(leadingWhitespace), body.childNodes[0] || null);\n }\n /* Work on whole document or just its body */\n if (NAMESPACE === HTML_NAMESPACE) {\n return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? 'html' : 'body')[0];\n }\n return WHOLE_DOCUMENT ? doc.documentElement : body;\n };\n /**\n * Creates a NodeIterator object that you can use to traverse filtered lists of nodes or elements in a document.\n *\n * @param root The root element or node to start traversing on.\n * @return The created NodeIterator\n */\n const _createNodeIterator = function _createNodeIterator(root) {\n return createNodeIterator.call(root.ownerDocument || root, root,\n // eslint-disable-next-line no-bitwise\n NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT | NodeFilter.SHOW_PROCESSING_INSTRUCTION | NodeFilter.SHOW_CDATA_SECTION, null);\n };\n /**\n * Replace template expression syntax (mustache, ERB, template\n * literal) with a space; shared by all SAFE_FOR_TEMPLATES scrub\n * sites. Order matters: mustache, then ERB, then template literal.\n *\n * @param value the string to scrub\n * @returns the scrubbed string\n */\n const _stripTemplateExpressions = function _stripTemplateExpressions(value) {\n value = stringReplace(value, MUSTACHE_EXPR$1, ' ');\n value = stringReplace(value, ERB_EXPR$1, ' ');\n value = stringReplace(value, TMPLIT_EXPR$1, ' ');\n return value;\n };\n /**\n * Strip template-engine expressions ({{...}}, ${...}, <%...%>) from the\n * character data of an element subtree. Used as the final safety net for\n * SAFE_FOR_TEMPLATES on every DOM-returning code path so that expressions\n * which only form after text-node normalization (e.g. fragments split across\n * stripped elements) cannot survive into a template-evaluating framework.\n *\n * Walks text/comment/CDATA/processing-instruction nodes and mutates `.data`\n * in place rather than round-tripping through innerHTML. This preserves\n * descendant node references (important for IN_PLACE callers), avoids a\n * serialize/reparse cycle, and reads literal character data — which means\n * `<%...%>` in text content matches the ERB regex against its real bytes\n * instead of the HTML-entity-escaped form innerHTML would produce.\n *\n * Attribute values are not visited here; SAFE_FOR_TEMPLATES handling for\n * attributes is performed during the per-node `_sanitizeAttributes` pass.\n *\n * @param node The root element whose character data should be scrubbed.\n */\n const _scrubTemplateExpressions2 = function _scrubTemplateExpressions(node) {\n var _node$querySelectorAl;\n node.normalize();\n const walker = createNodeIterator.call(node.ownerDocument || node, node,\n // eslint-disable-next-line no-bitwise\n NodeFilter.SHOW_TEXT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_CDATA_SECTION | NodeFilter.SHOW_PROCESSING_INSTRUCTION, null);\n let currentNode = walker.nextNode();\n while (currentNode) {\n currentNode.data = _stripTemplateExpressions(currentNode.data);\n currentNode = walker.nextNode();\n }\n // NodeIterator does not descend into <template>.content per the DOM spec,\n // so we must explicitly recurse into each template's content fragment,\n // mirroring the approach used by _sanitizeShadowDOM.\n const templates = (_node$querySelectorAl = node.querySelectorAll) === null || _node$querySelectorAl === void 0 ? void 0 : _node$querySelectorAl.call(node, 'template');\n if (templates) {\n arrayForEach(templates, tmpl => {\n if (_isDocumentFragment(tmpl.content)) {\n _scrubTemplateExpressions2(tmpl.content);\n }\n });\n }\n };\n /**\n * _isClobbered\n *\n * Detect DOM-clobbering on HTMLFormElement nodes. Form is the only HTML\n * interface with [LegacyOverrideBuiltIns]; a descendant element with a\n * `name` attribute matching a prototype property shadows that property\n * on direct reads. We use this check at the IN_PLACE entry-point and\n * during attribute sanitization to refuse clobbered forms.\n *\n * @param element element to check for clobbering attacks\n * @return true if clobbered, false if safe\n */\n const _isClobbered = function _isClobbered(element) {\n // Realm-independent tag-name probe. If we can't determine the tag\n // name at all, we can't reason about clobbering — return false\n // (the caller's other defences still apply).\n const realTagName = getNodeName ? getNodeName(element) : null;\n if (typeof realTagName !== 'string') {\n return false;\n }\n if (transformCaseFunc(realTagName) !== 'form') {\n return false;\n }\n return typeof element.nodeName !== 'string' || typeof element.textContent !== 'string' || typeof element.removeChild !== 'function' ||\n // Realm-safe NamedNodeMap detection: equality against the cached\n // prototype getter. Clobbered .attributes (e.g. <input name=\"attributes\">)\n // makes the direct read diverge from the cached read; a clean form\n // (same-realm OR foreign-realm) has both reads pointing at the same\n // canonical NamedNodeMap.\n element.attributes !== getAttributes(element) || typeof element.removeAttribute !== 'function' || typeof element.setAttribute !== 'function' || typeof element.namespaceURI !== 'string' || typeof element.insertBefore !== 'function' || typeof element.hasChildNodes !== 'function' ||\n // NodeType clobbering probe. Cached Node.prototype.nodeType getter\n // returns the integer 1 for any Element regardless of realm; direct\n // read on a clobbered form (e.g. <input name=\"nodeType\">) returns\n // the named child element. Cheap addition — nodeType is read from\n // an internal slot, no serialization cost — and removes a residual\n // clobbering surface used by several mXSS / PI / comment branches\n // in _sanitizeElements that compare currentNode.nodeType directly.\n element.nodeType !== getNodeType(element) ||\n // HTMLFormElement has [LegacyOverrideBuiltIns]: a descendant named\n // \"childNodes\" shadows the prototype getter. Direct reads of\n // form.childNodes from a clobbered form return the named child\n // instead of the real NodeList, so any walk that reads it directly\n // skips the form's real children. Compare the direct read to the\n // cached Node.prototype getter — when the form's named-property\n // getter intercepts the read, the two values differ and we flag\n // the form. This catches every clobbering child type (input,\n // select, etc.) regardless of whether the named child happens to\n // carry a numeric .length, which a typeof-based probe would miss\n // (e.g. HTMLSelectElement.length is a defined unsigned-long).\n element.childNodes !== getChildNodes(element);\n };\n /**\n * Checks whether the given value is a DocumentFragment from any realm.\n *\n * The realm-independent replacement reads `nodeType` through the cached\n * Node.prototype getter and compares to the DOCUMENT_FRAGMENT_NODE\n * constant (11). nodeType is a numeric value resolved from the node's\n * internal slot, identical across realms for the same kind of node.\n *\n * @param value object to check\n * @return true if value is a DocumentFragment-shaped node from any realm\n */\n const _isDocumentFragment = function _isDocumentFragment(value) {\n if (!getNodeType || typeof value !== 'object' || value === null) {\n return false;\n }\n try {\n return getNodeType(value) === NODE_TYPE.documentFragment;\n } catch (_) {\n return false;\n }\n };\n /**\n * Checks whether the given object is a DOM node, including nodes that\n * originate from a different window/realm (e.g. an iframe's\n * contentDocument). The previous `value instanceof Node` check was\n * realm-bound: nodes from a different window failed it, causing\n * sanitize() to silently stringify them and reset IN_PLACE to false,\n * returning the original node unsanitized. See GHSA-4w3q-35jp-p934.\n *\n * @param value object to check whether it's a DOM node\n * @return true if value is a DOM node from any realm\n */\n const _isNode = function _isNode(value) {\n if (!getNodeType || typeof value !== 'object' || value === null) {\n return false;\n }\n try {\n return typeof getNodeType(value) === 'number';\n } catch (_) {\n return false;\n }\n };\n function _executeHooks(hooks, currentNode, data) {\n if (hooks.length === 0) {\n return;\n }\n arrayForEach(hooks, hook => {\n hook.call(DOMPurify, currentNode, data, CONFIG);\n });\n }\n /**\n * Structural-threat checks that condemn a node regardless of the\n * allowlists: mXSS via namespace confusion, risky CSS construction,\n * processing instructions, markup-bearing comments. Pure predicate;\n * the caller removes. Check order is load-bearing.\n *\n * @param currentNode the node to inspect\n * @param tagName the node's transformCaseFunc'd tag name\n * @return true if the node must be removed\n */\n const _isUnsafeNode = function _isUnsafeNode(currentNode, tagName) {\n /* Detect mXSS attempts abusing namespace confusion */\n if (SAFE_FOR_XML && currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && regExpTest(ELEMENT_MARKUP_PROBE, currentNode.textContent) && regExpTest(ELEMENT_MARKUP_PROBE, currentNode.innerHTML)) {\n return true;\n }\n /* Remove risky CSS construction leading to mXSS */\n if (SAFE_FOR_XML && currentNode.namespaceURI === HTML_NAMESPACE && tagName === 'style' && _isNode(currentNode.firstElementChild)) {\n return true;\n }\n /* Remove any occurrence of processing instructions */\n if (currentNode.nodeType === NODE_TYPE.processingInstruction) {\n return true;\n }\n /* Remove any kind of possibly harmful comments */\n if (SAFE_FOR_XML && currentNode.nodeType === NODE_TYPE.comment && regExpTest(COMMENT_MARKUP_PROBE, currentNode.data)) {\n return true;\n }\n return false;\n };\n /**\n * Handle a node whose tag is forbidden or not allowlisted: keep\n * allowed custom elements (false return exits _sanitizeElements\n * early - namespace/fallback checks and the afterSanitizeElements\n * hook are intentionally skipped for kept custom elements), else\n * hoist content per KEEP_CONTENT and remove.\n *\n * @param currentNode the disallowed node\n * @param tagName the node's transformCaseFunc'd tag name\n * @return true if the node was removed, false if kept\n */\n const _sanitizeDisallowedNode = function _sanitizeDisallowedNode(currentNode, tagName) {\n /* Check if we have a custom element to handle */\n if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName)) {\n if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) {\n return false;\n }\n if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName)) {\n return false;\n }\n }\n /* Keep content except for bad-listed elements.\n Use the cached prototype getters exclusively — the previous code\n had `|| currentNode.parentNode` / `|| currentNode.childNodes`\n fallbacks, but the cached getters always return the canonical\n value (or null for a real parent-less node), so the fallback\n path was dead in safe cases and a clobbering surface in unsafe\n ones. Falsy cached results stay falsy; the `if (childNodes &&\n parentNode)` check already gates correctly. */\n if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {\n const parentNode = getParentNode(currentNode);\n const childNodes = getChildNodes(currentNode);\n if (childNodes && parentNode) {\n const childCount = childNodes.length;\n /* In-place: hoist the *original* children so the iterator visits\n and sanitises them through the same allowlist pass as every other\n node. The caller built the tree in the live document, so the\n originals carry already-queued resource events (`<img onerror>`,\n `<video>`/`<audio>` error, lazy/`onload`, …); cloning would leave\n those originals detached but still armed, firing in page scope\n while the returned tree looked clean. Moving is safe in-place: the\n root is pre-validated as an allowed tag and so is never the node\n being removed, which keeps `parentNode` inside the iterator root\n and the relocated child inside the serialised tree.\n Otherwise (string / DOM-copy paths): clone. The iterator is rooted\n at — and the result serialised from — `body`, so a restrictive\n ALLOWED_TAGS that removes `body` itself must leave its content in\n place, which only cloning does; and those paths parse into an\n inert document, so their discarded originals never had a queued\n event to neutralise.\n `childNodes` is live; a tail-to-head walk keeps `childNodes[i]`\n valid whether we move (drops the trailing entry) or clone (leaves\n the list intact). */\n for (let i = childCount - 1; i >= 0; --i) {\n const hoisted = IN_PLACE ? childNodes[i] : cloneNode(childNodes[i], true);\n parentNode.insertBefore(hoisted, getNextSibling(currentNode));\n }\n }\n }\n _forceRemove(currentNode);\n return true;\n };\n /**\n * _sanitizeElements\n *\n * @protect nodeName\n * @protect textContent\n * @protect removeChild\n * @param currentNode to check for permission to exist\n * @return true if node was killed, false if left alive\n */\n const _sanitizeElements = function _sanitizeElements(currentNode) {\n /* Execute a hook if present */\n _executeHooks(hooks.beforeSanitizeElements, currentNode, null);\n /* Check if element is clobbered or can clobber */\n if (_isClobbered(currentNode)) {\n _forceRemove(currentNode);\n return true;\n }\n /* Now let's check the element's type and name */\n const tagName = transformCaseFunc(getNodeName ? getNodeName(currentNode) : currentNode.nodeName);\n /* Execute a hook if present */\n _executeHooks(hooks.uponSanitizeElement, currentNode, {\n tagName,\n allowedTags: ALLOWED_TAGS\n });\n /* Remove mXSS vectors, processing instructions and risky comments */\n if (_isUnsafeNode(currentNode, tagName)) {\n _forceRemove(currentNode);\n return true;\n }\n /* Remove element if anything forbids its presence */\n if (FORBID_TAGS[tagName] || !(EXTRA_ELEMENT_HANDLING.tagCheck instanceof Function && EXTRA_ELEMENT_HANDLING.tagCheck(tagName)) && !ALLOWED_TAGS[tagName]) {\n return _sanitizeDisallowedNode(currentNode, tagName);\n }\n /* Check whether element has a valid namespace.\n Realm-safe check (GHSA-hpcv-96wg-7vj8): use the cached Node.prototype\n nodeType getter rather than `instanceof Element`, which is realm-\n bound and short-circuits to false for any node minted in a different\n realm — letting a foreign-realm element with a forbidden namespace\n slip past the namespace check entirely. */\n const nt = getNodeType ? getNodeType(currentNode) : currentNode.nodeType;\n if (nt === NODE_TYPE.element && !_checkValidNamespace(currentNode)) {\n _forceRemove(currentNode);\n return true;\n }\n /* Make sure that older browsers don't get fallback-tag mXSS */\n if ((tagName === 'noscript' || tagName === 'noembed' || tagName === 'noframes') && regExpTest(FALLBACK_TAG_CLOSE, currentNode.innerHTML)) {\n _forceRemove(currentNode);\n return true;\n }\n /* Sanitize element content to be template-safe */\n if (SAFE_FOR_TEMPLATES && currentNode.nodeType === NODE_TYPE.text) {\n /* Get the element's text content */\n const content = _stripTemplateExpressions(currentNode.textContent);\n if (currentNode.textContent !== content) {\n arrayPush(DOMPurify.removed, {\n element: currentNode.cloneNode()\n });\n currentNode.textContent = content;\n }\n }\n /* Execute a hook if present */\n _executeHooks(hooks.afterSanitizeElements, currentNode, null);\n return false;\n };\n /**\n * _isValidAttribute\n *\n * @param lcTag Lowercase tag name of containing element.\n * @param lcName Lowercase attribute name.\n * @param value Attribute value.\n * @return Returns true if `value` is valid, otherwise false.\n */\n // eslint-disable-next-line complexity\n const _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) {\n /* FORBID_ATTR must always win, even if ADD_ATTR predicate would allow it */\n if (FORBID_ATTR[lcName]) {\n return false;\n }\n /* Make sure attribute cannot clobber */\n if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement)) {\n return false;\n }\n const nameIsPermitted = ALLOWED_ATTR[lcName] || EXTRA_ELEMENT_HANDLING.attributeCheck instanceof Function && EXTRA_ELEMENT_HANDLING.attributeCheck(lcName, lcTag);\n /* Allow valid data-* attributes: At least one character after \"-\"\n (https://html.spec.whatwg.org/multipage/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes)\n XML-compatible (https://html.spec.whatwg.org/multipage/infrastructure.html#xml-compatible and http://www.w3.org/TR/xml/#d0e804)\n We don't need to check the value; it's always URI safe. */\n if (ALLOW_DATA_ATTR && regExpTest(DATA_ATTR$1, lcName)) ; else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR$1, lcName)) ; else if (!nameIsPermitted) {\n if (\n // First condition does a very basic check if a) it's basically a valid custom element tagname AND\n // b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck\n // and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck\n _isBasicCustomElement(lcTag) && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, lcTag) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(lcTag)) && (CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.attributeNameCheck, lcName) || CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.attributeNameCheck(lcName, lcTag)) ||\n // Alternative, second condition checks if it's an `is`-attribute, AND\n // the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck\n lcName === 'is' && CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, value) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(value))) ; else {\n return false;\n }\n /* Check value is safe. First, is attr inert? If so, is safe */\n } else if (URI_SAFE_ATTRIBUTES[lcName]) ; else if (regExpTest(IS_ALLOWED_URI$1, stringReplace(value, ATTR_WHITESPACE$1, ''))) ; else if ((lcName === 'src' || lcName === 'xlink:href' || lcName === 'href') && lcTag !== 'script' && stringIndexOf(value, 'data:') === 0 && DATA_URI_TAGS[lcTag]) ; else if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA$1, stringReplace(value, ATTR_WHITESPACE$1, ''))) ; else if (value) {\n return false;\n } else ;\n return true;\n };\n /* Names the HTML spec reserves from valid-custom-element-name; these must\n * never be treated as basic custom elements even when a permissive\n * CUSTOM_ELEMENT_HANDLING.tagNameCheck is configured. */\n const RESERVED_CUSTOM_ELEMENT_NAMES = addToSet({}, ['annotation-xml', 'color-profile', 'font-face', 'font-face-format', 'font-face-name', 'font-face-src', 'font-face-uri', 'missing-glyph']);\n /**\n * _isBasicCustomElement\n * checks if at least one dash is included in tagName, and it's not the first char\n * for more sophisticated checking see https://github.com/sindresorhus/validate-element-name\n *\n * @param tagName name of the tag of the node to sanitize\n * @returns Returns true if the tag name meets the basic criteria for a custom element, otherwise false.\n */\n const _isBasicCustomElement = function _isBasicCustomElement(tagName) {\n return !RESERVED_CUSTOM_ELEMENT_NAMES[stringToLowerCase(tagName)] && regExpTest(CUSTOM_ELEMENT$1, tagName);\n };\n /**\n * Wrap an attribute value in the matching Trusted Types object when\n * the active policy requires it. Namespaced attributes pass through\n * unchanged (no TT support yet, see\n * https://bugs.chromium.org/p/chromium/issues/detail?id=1305293).\n *\n * @param lcTag lowercase tag name of the containing element\n * @param lcName lowercase attribute name\n * @param namespaceURI the attribute's namespace, if any\n * @param value the attribute value to wrap\n * @return the value, wrapped when Trusted Types demand it\n */\n const _applyTrustedTypesToAttribute = function _applyTrustedTypesToAttribute(lcTag, lcName, namespaceURI, value) {\n if (trustedTypesPolicy && typeof trustedTypes === 'object' && typeof trustedTypes.getAttributeType === 'function' && !namespaceURI) {\n switch (trustedTypes.getAttributeType(lcTag, lcName)) {\n case 'TrustedHTML':\n {\n return _createTrustedHTML(value);\n }\n case 'TrustedScriptURL':\n {\n return _createTrustedScriptURL(value);\n }\n }\n }\n return value;\n };\n /**\n * Write a modified attribute value back onto the element. On\n * success, re-probe for clobbering introduced by the new value and\n * remove the element when found; otherwise pop the removal entry\n * recorded by the earlier _removeAttribute (long-standing pairing\n * with the SANITIZE_NAMED_PROPS path - do not \"fix\" casually). On\n * failure, remove the attribute instead.\n *\n * @param currentNode the element carrying the attribute\n * @param name the attribute name as present on the element\n * @param namespaceURI the attribute's namespace, if any\n * @param value the new attribute value\n */\n const _setAttributeValue = function _setAttributeValue(currentNode, name, namespaceURI, value) {\n try {\n if (namespaceURI) {\n currentNode.setAttributeNS(namespaceURI, name, value);\n } else {\n /* Fallback to setAttribute() for browser-unrecognized namespaces e.g. \"x-schema\". */\n currentNode.setAttribute(name, value);\n }\n if (_isClobbered(currentNode)) {\n _forceRemove(currentNode);\n } else {\n arrayPop(DOMPurify.removed);\n }\n } catch (_) {\n _removeAttribute(name, currentNode);\n }\n };\n /**\n * _sanitizeAttributes\n *\n * @protect attributes\n * @protect nodeName\n * @protect removeAttribute\n * @protect setAttribute\n *\n * @param currentNode to sanitize\n */\n const _sanitizeAttributes = function _sanitizeAttributes(currentNode) {\n /* Execute a hook if present */\n _executeHooks(hooks.beforeSanitizeAttributes, currentNode, null);\n const attributes = currentNode.attributes;\n /* Check if we have attributes; if not we might have a text node */\n if (!attributes || _isClobbered(currentNode)) {\n return;\n }\n const hookEvent = {\n attrName: '',\n attrValue: '',\n keepAttr: true,\n allowedAttributes: ALLOWED_ATTR,\n forceKeepAttr: undefined\n };\n let l = attributes.length;\n const lcTag = transformCaseFunc(currentNode.nodeName);\n /* Go backwards over all attributes; safely remove bad ones */\n while (l--) {\n const attr = attributes[l];\n const name = attr.name,\n namespaceURI = attr.namespaceURI,\n attrValue = attr.value;\n const lcName = transformCaseFunc(name);\n const initValue = attrValue;\n let value = name === 'value' ? initValue : stringTrim(initValue);\n /* Execute a hook if present */\n hookEvent.attrName = lcName;\n hookEvent.attrValue = value;\n hookEvent.keepAttr = true;\n hookEvent.forceKeepAttr = undefined; // Allows developers to see this is a property they can set\n _executeHooks(hooks.uponSanitizeAttribute, currentNode, hookEvent);\n value = hookEvent.attrValue;\n /* Full DOM Clobbering protection via namespace isolation,\n * Prefix id and name attributes with `user-content-`\n */\n if (SANITIZE_NAMED_PROPS && (lcName === 'id' || lcName === 'name') && stringIndexOf(value, SANITIZE_NAMED_PROPS_PREFIX) !== 0) {\n // Remove the attribute with this value\n _removeAttribute(name, currentNode);\n // Prefix the value and later re-create the attribute with the sanitized value\n value = SANITIZE_NAMED_PROPS_PREFIX + value;\n }\n // Else: already prefixed, leave the attribute alone — the prefix is\n // itself the clobbering protection, and re-applying it is incorrect.\n /* Work around a security issue with comments inside attributes */\n if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i, value)) {\n _removeAttribute(name, currentNode);\n continue;\n }\n /* Make sure we cannot easily use animated hrefs, even if animations are allowed */\n if (lcName === 'attributename' && stringMatch(value, 'href')) {\n _removeAttribute(name, currentNode);\n continue;\n }\n /* Did the hooks force-keep the attribute? */\n if (hookEvent.forceKeepAttr) {\n continue;\n }\n /* Did the hooks approve of the attribute? */\n if (!hookEvent.keepAttr) {\n _removeAttribute(name, currentNode);\n continue;\n }\n /* Work around a security issue in jQuery 3.0 */\n if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(SELF_CLOSING_TAG, value)) {\n _removeAttribute(name, currentNode);\n continue;\n }\n /* Sanitize attribute content to be template-safe */\n if (SAFE_FOR_TEMPLATES) {\n value = _stripTemplateExpressions(value);\n }\n /* Is `value` valid for this attribute? */\n if (!_isValidAttribute(lcTag, lcName, value)) {\n _removeAttribute(name, currentNode);\n continue;\n }\n /* Handle attributes that require Trusted Types */\n value = _applyTrustedTypesToAttribute(lcTag, lcName, namespaceURI, value);\n /* Handle invalid data-* attribute set by try-catching it */\n if (value !== initValue) {\n _setAttributeValue(currentNode, name, namespaceURI, value);\n }\n }\n /* Execute a hook if present */\n _executeHooks(hooks.afterSanitizeAttributes, currentNode, null);\n };\n /**\n * _sanitizeShadowDOM\n *\n * @param fragment to iterate over recursively\n */\n const _sanitizeShadowDOM2 = function _sanitizeShadowDOM(fragment) {\n let shadowNode = null;\n const shadowIterator = _createNodeIterator(fragment);\n /* Execute a hook if present */\n _executeHooks(hooks.beforeSanitizeShadowDOM, fragment, null);\n while (shadowNode = shadowIterator.nextNode()) {\n /* Execute a hook if present */\n _executeHooks(hooks.uponSanitizeShadowNode, shadowNode, null);\n /* Sanitize tags and elements */\n _sanitizeElements(shadowNode);\n /* Check attributes next */\n _sanitizeAttributes(shadowNode);\n /* Deep shadow DOM detected.\n Realm-safe check (GHSA-hpcv-96wg-7vj8): use nodeType against the\n DOCUMENT_FRAGMENT_NODE constant rather than instanceof, so we\n recurse into <template>.content from foreign realms too. */\n if (_isDocumentFragment(shadowNode.content)) {\n _sanitizeShadowDOM2(shadowNode.content);\n }\n /* An element iterated here may itself host an attached\n shadow root. The default NodeIterator does not enter shadow\n trees, so a shadow root nested inside template.content was\n previously reached by no walk at all (the pre-pass at\n _sanitizeAttachedShadowRoots descends via childNodes, which\n doesn't enter template.content; the template-content recursion\n above iterates the content but never inspected shadowRoot).\n Walk it explicitly. The nodeType guard avoids reading\n shadowRoot off text / comment / CDATA / PI nodes that the\n iterator also surfaces. */\n const shadowNodeType = getNodeType ? getNodeType(shadowNode) : shadowNode.nodeType;\n if (shadowNodeType === NODE_TYPE.element) {\n const innerSr = getShadowRoot(shadowNode);\n if (_isDocumentFragment(innerSr)) {\n _sanitizeAttachedShadowRoots(innerSr);\n _sanitizeShadowDOM2(innerSr);\n }\n }\n }\n /* Execute a hook if present */\n _executeHooks(hooks.afterSanitizeShadowDOM, fragment, null);\n };\n /**\n * _sanitizeAttachedShadowRoots\n *\n * Walks `root` and feeds every attached shadow root we encounter into\n * the existing _sanitizeShadowDOM pipeline. The default node iterator\n * does not descend into shadow trees, so nodes inside an attached\n * shadow root would otherwise be skipped entirely.\n *\n * Two real input paths put attached shadow roots in front of us:\n * 1. IN_PLACE on a DOM node that already has shadow roots attached.\n * 2. DOM-node input where importNode(dirty, true) deep-clones the\n * shadow root because it was created with `clonable: true`.\n *\n * This pass runs once, up front, so the main iteration loop (and the\n * existing _sanitizeShadowDOM template-content recursion) stay\n * untouched — string-input paths are not affected.\n *\n * @param root the subtree root to walk for attached shadow roots\n */\n const _sanitizeAttachedShadowRoots = function _sanitizeAttachedShadowRoots(root) {\n /* Iterative (explicit stack) rather than per-child recursion. DOM APIs\n impose no depth cap, so an attacker-shaped tree (JSON/CRDT/editor data\n built straight into the DOM — the IN_PLACE surface) deeper than the JS\n call-stack budget would otherwise overflow native recursion here and\n throw at the IN_PLACE entry pre-pass, before a single node is\n sanitized, leaving the caller's live tree untouched (fail-open). See\n campaign-3 F4. A heap stack keeps depth off the call stack.\n Each work item is either a node to descend into, or a deferred\n `_sanitizeShadowDOM` for an already-walked shadow root. The deferred\n form preserves the original post-order discipline: a shadow root's\n nested shadow roots are discovered before the outer shadow is\n sanitized (which may remove hosts). Pushes are in reverse of the\n desired processing order (LIFO): template content, then children, then\n the shadow-sanitize, then the shadow walk — so the order matches the\n previous recursion exactly. */\n const stack = [{\n node: root,\n shadow: null\n }];\n while (stack.length > 0) {\n const item = stack.pop();\n /* Deferred shadow-DOM sanitisation: runs after its subtree was walked. */\n if (item.shadow) {\n _sanitizeShadowDOM2(item.shadow);\n continue;\n }\n const node = item.node;\n const nodeType = getNodeType ? getNodeType(node) : node.nodeType;\n const isElement = nodeType === NODE_TYPE.element;\n /* (pushed last → processed first) Children, snapshotted in reverse so\n the first child is processed first. Snapshotting matters because a\n hook may detach siblings mid-walk. */\n const childNodes = getChildNodes(node);\n if (childNodes) {\n for (let i = childNodes.length - 1; i >= 0; --i) {\n stack.push({\n node: childNodes[i],\n shadow: null\n });\n }\n }\n /* (pushed before children → processed after them, matching the old\n \"template content last\" order) When the node is a <template>,\n descend into its content. */\n if (isElement) {\n const rootName = getNodeName ? getNodeName(node) : null;\n if (typeof rootName === 'string' && transformCaseFunc(rootName) === 'template') {\n const content = node.content;\n if (_isDocumentFragment(content)) {\n stack.push({\n node: content,\n shadow: null\n });\n }\n }\n }\n /* Shadow root (processed first): walk its subtree, then sanitise it.\n Realm-safe check (GHSA-hpcv-96wg-7vj8): nodeType-based detection\n rather than `instanceof DocumentFragment`, which is realm-bound and\n silently skipped foreign-realm shadow roots (e.g.\n iframe.contentDocument attachShadow). */\n if (isElement) {\n const sr = getShadowRoot(node);\n if (_isDocumentFragment(sr)) {\n /* Push the deferred sanitise first so it pops after the shadow\n walk we push next, i.e. nested shadow roots are discovered\n before this one is sanitised. */\n stack.push({\n node: null,\n shadow: sr\n }, {\n node: sr,\n shadow: null\n });\n }\n }\n }\n };\n // eslint-disable-next-line complexity\n DOMPurify.sanitize = function (dirty) {\n let cfg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n let body = null;\n let importedNode = null;\n let currentNode = null;\n let returnNode = null;\n /* Make sure we have a string to sanitize.\n DO NOT return early, as this will return the wrong type if\n the user has requested a DOM object rather than a string */\n IS_EMPTY_INPUT = !dirty;\n if (IS_EMPTY_INPUT) {\n dirty = '<!-->';\n }\n /* Stringify, in case dirty is an object */\n if (typeof dirty !== 'string' && !_isNode(dirty)) {\n dirty = stringifyValue(dirty);\n if (typeof dirty !== 'string') {\n throw typeErrorCreate('dirty is not a string, aborting');\n }\n }\n /* Return dirty HTML if DOMPurify cannot run */\n if (!DOMPurify.isSupported) {\n return dirty;\n }\n /* Assign config vars */\n if (SET_CONFIG) {\n /* Persistent setConfig() path: _parseConfig is skipped, so the sets are\n * not re-derived per call. Restore them from the pristine bindings\n * captured at setConfig() time so a previous call's hook clone (mutated\n * below) does not carry over. */\n ALLOWED_TAGS = SET_CONFIG_ALLOWED_TAGS;\n ALLOWED_ATTR = SET_CONFIG_ALLOWED_ATTR;\n } else {\n _parseConfig(cfg);\n }\n /* Clone the hook-mutable allowlists before the walk whenever an\n * uponSanitize* hook is registered. The hook event exposes ALLOWED_TAGS\n * and ALLOWED_ATTR by reference (as allowedTags / allowedAttributes), so\n * a hook that widens them would otherwise mutate the shared set\n * permanently: across later calls and across every element. Cloning per\n * walk keeps documented in-call widening working while scoping it to the\n * call. A single guard for both config paths - the per-call path rebinds\n * the sets in _parseConfig each call, the persistent path restores them\n * from the captured bindings just above - so the two cannot diverge. */\n if (hooks.uponSanitizeElement.length > 0 || hooks.uponSanitizeAttribute.length > 0) {\n ALLOWED_TAGS = clone(ALLOWED_TAGS);\n }\n if (hooks.uponSanitizeAttribute.length > 0) {\n ALLOWED_ATTR = clone(ALLOWED_ATTR);\n }\n /* Clean up removed elements */\n DOMPurify.removed = [];\n /* Resolve IN_PLACE for this call without mutating persistent config.\n Writing the IN_PLACE closure variable here leaks under setConfig(),\n where _parseConfig is skipped on later calls: a single string call would\n disable in-place mode for every subsequent node call, returning a\n sanitized copy while leaving the caller's node — which in-place callers\n keep using and whose return value they ignore — unsanitized. REPORT-2. */\n const inPlace = IN_PLACE && typeof dirty !== 'string' && _isNode(dirty);\n if (inPlace) {\n /* Do some early pre-sanitization to avoid unsafe root nodes.\n Read nodeName through the cached prototype getter — a clobbering\n child named \"nodeName\" on the form root would otherwise shadow\n the property and let this check skip the root-allowlist\n validation entirely. */\n const nn = getNodeName ? getNodeName(dirty) : dirty.nodeName;\n if (typeof nn === 'string') {\n const tagName = transformCaseFunc(nn);\n if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {\n throw typeErrorCreate('root node is forbidden and cannot be sanitized in-place');\n }\n }\n /* Pre-flight the root through _isClobbered. The iterator-driven\n removal path can not detach a parent-less root: _forceRemove\n falls through to Element.prototype.remove(), which per spec\n is a no-op on a node with no parent. A clobbered root would\n then survive the main loop with its attributes uninspected,\n because _sanitizeAttributes early-returns on _isClobbered. The\n result would be an attacker-controlled form, complete with any\n event-handler attributes the caller passed in, handed back to\n the application unsanitized. Refuse to sanitize such a root\n the same way we refuse a forbidden tag. GHSA-r47g-fvhr-h676. */\n if (_isClobbered(dirty)) {\n throw typeErrorCreate('root node is clobbered and cannot be sanitized in-place');\n }\n /* Sanitize attached shadow roots before the main iterator runs.\n The iterator does not descend into shadow trees. Same fail-closed\n barrier as the main walk (campaign-3 F2): a custom-element reaction\n inside a shadow root could abort this pre-pass before the walk runs,\n which would otherwise leave the entire live tree unsanitized. */\n try {\n _sanitizeAttachedShadowRoots(dirty);\n } catch (error) {\n _neutralizeRoot(dirty);\n throw error;\n }\n } else if (_isNode(dirty)) {\n /* If dirty is a DOM element, append to an empty document to avoid\n elements being stripped by the parser */\n body = _initDocument('<!---->');\n importedNode = body.ownerDocument.importNode(dirty, true);\n if (importedNode.nodeType === NODE_TYPE.element && importedNode.nodeName === 'BODY') {\n /* Node is already a body, use as is */\n body = importedNode;\n } else if (importedNode.nodeName === 'HTML') {\n body = importedNode;\n } else {\n // eslint-disable-next-line unicorn/prefer-dom-node-append\n body.appendChild(importedNode);\n }\n /* Clonable shadow roots are deep-cloned by importNode(); sanitize\n them before the main iterator runs, since the iterator does not\n descend into shadow trees. The walk routes every read through a\n cached prototype getter so clobbering descendants on a form root\n cannot hide a shadow host from this pass. */\n _sanitizeAttachedShadowRoots(importedNode);\n } else {\n /* Exit directly if we have nothing to do */\n if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT &&\n // eslint-disable-next-line unicorn/prefer-includes\n dirty.indexOf('<') === -1) {\n return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? _createTrustedHTML(dirty) : dirty;\n }\n /* Initialize the document to work on */\n body = _initDocument(dirty);\n /* Check we have a DOM node from the data */\n if (!body) {\n return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : '';\n }\n }\n /* Remove first element node (ours) if FORCE_BODY is set */\n if (body && FORCE_BODY) {\n _forceRemove(body.firstChild);\n }\n /* Get node iterator */\n const nodeIterator = _createNodeIterator(inPlace ? dirty : body);\n /* Now start iterating over the created document.\n The walk runs inside an exception barrier (campaign-3 F2): a re-entrant\n engine/custom-element mutation can detach a node mid-walk so\n `_forceRemove`'s parentless guard throws, aborting the loop. Without the\n barrier the caller's in-place tree would be left half-sanitized with the\n unvisited tail still armed. On any throw we fail closed — strip the\n in-place root bare — then rethrow so the existing throw contract is\n preserved. (String/DOM-copy paths never return the partial body, so the\n propagating throw is already fail-closed there.) */\n try {\n while (currentNode = nodeIterator.nextNode()) {\n /* Sanitize tags and elements */\n _sanitizeElements(currentNode);\n /* Check attributes next */\n _sanitizeAttributes(currentNode);\n /* Shadow DOM detected, sanitize it.\n Realm-safe check (GHSA-hpcv-96wg-7vj8): nodeType-based detection\n instead of instanceof, so foreign-realm <template>.content is\n walked correctly. */\n if (_isDocumentFragment(currentNode.content)) {\n _sanitizeShadowDOM2(currentNode.content);\n }\n }\n } catch (error) {\n if (inPlace) {\n _neutralizeRoot(dirty);\n }\n throw error;\n }\n /* If we sanitized `dirty` in-place, return it. */\n if (inPlace) {\n /* Fail-closed completion of the audit-5 F1 fix: every node removed from\n the caller's live tree is detached but may still hold a queued\n resource-event handler that fires in page scope after we return. The\n move-hoist covers only disallowed-tag KEEP_CONTENT removals; strip the\n non-allow-listed attributes off every other removed subtree (clobber,\n mXSS, namespace, comments, KEEP_CONTENT:false, …) so those handlers are\n cancelled before any event can fire. Runs synchronously, pre-return. */\n arrayForEach(DOMPurify.removed, entry => {\n if (entry.element) {\n _neutralizeSubtree(entry.element);\n }\n });\n if (SAFE_FOR_TEMPLATES) {\n _scrubTemplateExpressions2(dirty);\n }\n return dirty;\n }\n /* Return sanitized string or DOM */\n if (RETURN_DOM) {\n if (SAFE_FOR_TEMPLATES) {\n _scrubTemplateExpressions2(body);\n }\n if (RETURN_DOM_FRAGMENT) {\n returnNode = createDocumentFragment.call(body.ownerDocument);\n while (body.firstChild) {\n // eslint-disable-next-line unicorn/prefer-dom-node-append\n returnNode.appendChild(body.firstChild);\n }\n } else {\n returnNode = body;\n }\n if (ALLOWED_ATTR.shadowroot || ALLOWED_ATTR.shadowrootmode) {\n /*\n AdoptNode() is not used because internal state is not reset\n (e.g. the past names map of a HTMLFormElement), this is safe\n in theory but we would rather not risk another attack vector.\n The state that is cloned by importNode() is explicitly defined\n by the specs.\n */\n returnNode = importNode.call(originalDocument, returnNode, true);\n }\n return returnNode;\n }\n let serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;\n /* Serialize doctype if allowed */\n if (WHOLE_DOCUMENT && ALLOWED_TAGS['!doctype'] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) {\n serializedHTML = '<!DOCTYPE ' + body.ownerDocument.doctype.name + '>\\n' + serializedHTML;\n }\n /* Sanitize final string template-safe */\n if (SAFE_FOR_TEMPLATES) {\n serializedHTML = _stripTemplateExpressions(serializedHTML);\n }\n return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? _createTrustedHTML(serializedHTML) : serializedHTML;\n };\n DOMPurify.setConfig = function () {\n let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n _parseConfig(cfg);\n SET_CONFIG = true;\n SET_CONFIG_ALLOWED_TAGS = ALLOWED_TAGS;\n SET_CONFIG_ALLOWED_ATTR = ALLOWED_ATTR;\n };\n DOMPurify.clearConfig = function () {\n CONFIG = null;\n SET_CONFIG = false;\n SET_CONFIG_ALLOWED_TAGS = null;\n SET_CONFIG_ALLOWED_ATTR = null;\n // Drop any caller-supplied Trusted Types policy so it cannot poison later\n // `RETURN_TRUSTED_TYPE` output. The internal default policy (cached, and\n // never recreated — Trusted Types throws on duplicate names) is restored by\n // the next `_parseConfig`. See GHSA-vxr8-fq34-vvx9.\n trustedTypesPolicy = defaultTrustedTypesPolicy;\n emptyHTML = '';\n };\n DOMPurify.isValidAttribute = function (tag, attr, value) {\n /* Initialize shared config vars if necessary. */\n if (!CONFIG) {\n _parseConfig({});\n }\n const lcTag = transformCaseFunc(tag);\n const lcName = transformCaseFunc(attr);\n return _isValidAttribute(lcTag, lcName, value);\n };\n DOMPurify.addHook = function (entryPoint, hookFunction) {\n if (typeof hookFunction !== 'function') {\n return;\n }\n /* Reject unknown entry points. Without this, a non-hook key (e.g.\n * '__proto__') indexes off the prototype chain rather than a real\n * hook array, and arrayPush then writes to Object.prototype. Guard\n * with an own-property check against the known hook names. */\n if (!objectHasOwnProperty(hooks, entryPoint)) {\n return;\n }\n arrayPush(hooks[entryPoint], hookFunction);\n };\n DOMPurify.removeHook = function (entryPoint, hookFunction) {\n if (!objectHasOwnProperty(hooks, entryPoint)) {\n return undefined;\n }\n if (hookFunction !== undefined) {\n const index = arrayLastIndexOf(hooks[entryPoint], hookFunction);\n return index === -1 ? undefined : arraySplice(hooks[entryPoint], index, 1)[0];\n }\n return arrayPop(hooks[entryPoint]);\n };\n DOMPurify.removeHooks = function (entryPoint) {\n if (!objectHasOwnProperty(hooks, entryPoint)) {\n return;\n }\n hooks[entryPoint] = [];\n };\n DOMPurify.removeAllHooks = function () {\n hooks = _createHooksMap();\n };\n return DOMPurify;\n}\nvar purify = createDOMPurify();\n\nexport { purify as default };\n//# sourceMappingURL=purify.es.mjs.map\n","// Markdown rendering for assistant chat messages.\n//\n// Uses `marked` for GFM parsing and DOMPurify for sanitization. We deliberately\n// keep this dependency-light: no syntax-highlighting engine is bundled (code\n// blocks render as plain monospace, styled via the `prose` classes). The agent\n// output is broadly trusted, but DOMPurify still runs as defense-in-depth so a\n// stray `<script>`/`<img onerror>` in tool output or a pasted snippet cannot\n// execute.\n\nimport {marked} from 'marked';\nimport DOMPurify from 'dompurify';\n\nmarked.setOptions({\n\tgfm: true,\n\tbreaks: true,\n});\n\n// Max characters shown in the collapsed summary of a fenced code block before\n// we truncate with an ellipsis. Keeps long pasted blobs from cluttering the log.\nconst CODE_SUMMARY_MAX = 80;\n\nfunction escapeHtml(s: string): string {\n\treturn s\n\t\t.replace(/&/g, '&')\n\t\t.replace(/</g, '<')\n\t\t.replace(/>/g, '>')\n\t\t.replace(/\"/g, '"');\n}\n\n// Render fenced code blocks as collapsible <details>. The summary shows the\n// language (if any) plus the first non-empty line, truncated, so a long block\n// collapses to a single unobtrusive line. Single-line blocks stay open (nothing\n// gained by collapsing them). DOMPurify below is configured to allow the\n// details/summary tags this produces.\nconst codeRenderer = {\n\tcode(this: unknown, token: {text: string; lang?: string}): string {\n\t\tconst {text, lang} = token;\n\t\tconst langLabel = (lang ?? '').trim().split(/\\s+/)[0] ?? '';\n\t\tconst lines = text.split('\\n');\n\t\tconst nonEmpty = lines.filter((l) => l.trim() !== '');\n\t\tconst multiline = nonEmpty.length > 1;\n\t\tconst codeHtml = `<pre><code>${escapeHtml(text)}</code></pre>`;\n\t\tif (!multiline) {\n\t\t\treturn codeHtml;\n\t\t}\n\t\tconst firstLine = nonEmpty[0] ?? '';\n\t\tlet summaryText = firstLine;\n\t\tif (summaryText.length > CODE_SUMMARY_MAX) {\n\t\t\tsummaryText = summaryText.slice(0, CODE_SUMMARY_MAX) + '…';\n\t\t} else if (nonEmpty.length > 1) {\n\t\t\tsummaryText += ' …';\n\t\t}\n\t\tconst summaryLabel = langLabel\n\t\t\t? `<span class=\"code-lang\">${escapeHtml(langLabel)}</span> ${escapeHtml(summaryText)}`\n\t\t\t: escapeHtml(summaryText);\n\t\treturn `<details class=\"code-collapsible\"><summary>${summaryLabel}</summary>${codeHtml}</details>`;\n\t},\n};\nmarked.use({renderer: codeRenderer});\n\n// Open links in a new tab and harden them against reverse-tabnabbing. The hook\n// runs after sanitization so the attributes survive.\nlet hookRegistered = false;\nfunction ensureHook() {\n\tif (hookRegistered || typeof window === 'undefined') return;\n\thookRegistered = true;\n\tDOMPurify.addHook('afterSanitizeAttributes', (node) => {\n\t\tif (node.tagName === 'A') {\n\t\t\tnode.setAttribute('target', '_blank');\n\t\t\tnode.setAttribute('rel', 'noopener noreferrer');\n\t\t}\n\t});\n}\n\n/**\n * Render a markdown string to sanitized HTML.\n *\n * Server-side (no DOM available) it returns the raw text escaped as-is, since\n * DOMPurify needs a window; the client re-renders on hydration anyway.\n */\nexport function renderMarkdown(raw: string): string {\n\tif (!raw) return '';\n\tconst html = marked.parse(raw, {async: false}) as string;\n\tif (typeof window === 'undefined') {\n\t\t// No DOM to sanitize against during SSR. Return empty; the component shows\n\t\t// a plain-text fallback until the client hydrates and re-renders.\n\t\treturn '';\n\t}\n\tensureHook();\n\treturn DOMPurify.sanitize(html, {\n\t\tADD_ATTR: ['target', 'rel'],\n\t\tADD_TAGS: ['details', 'summary'],\n\t});\n}\n\n// GFM-ish autolink matcher for the link-only path. Matches http(s):// and www.\n// URLs. Trailing punctuation that is usually sentence punctuation (not part of\n// the URL) is trimmed off the match.\nconst URL_RE = /\\b(https?:\\/\\/[^\\s<]+|www\\.[^\\s<]+)/gi;\n\n/**\n * Linkify plain text WITHOUT running full markdown. Used for user messages,\n * where we want bare URLs to be clickable but must not reinterpret characters\n * the user typed literally (asterisks, backticks, hashes). Everything is\n * HTML-escaped first, then only URL matches are wrapped in anchors, then the\n * whole thing is sanitized as defense-in-depth.\n *\n * Returns escaped-but-unlinked text server-side (no DOM for DOMPurify); the\n * client re-renders on hydration.\n */\nexport function linkifyText(raw: string): string {\n\tif (!raw) return '';\n\tif (typeof window === 'undefined') {\n\t\treturn '';\n\t}\n\tlet out = '';\n\tlet lastIndex = 0;\n\tfor (const match of raw.matchAll(URL_RE)) {\n\t\tconst start = match.index ?? 0;\n\t\tout += escapeHtml(raw.slice(lastIndex, start));\n\t\tlet urlText = match[0];\n\t\t// Trim trailing sentence punctuation that is unlikely to be part of the URL.\n\t\tlet trailing = '';\n\t\tconst trailMatch = urlText.match(/[.,;:!?)\\]}'\"]+$/);\n\t\tif (trailMatch) {\n\t\t\ttrailing = trailMatch[0];\n\t\t\turlText = urlText.slice(0, urlText.length - trailing.length);\n\t\t}\n\t\tconst href = urlText.startsWith('www.') ? `https://${urlText}` : urlText;\n\t\tout += `<a href=\"${escapeHtml(href)}\">${escapeHtml(urlText)}</a>`;\n\t\tout += escapeHtml(trailing);\n\t\tlastIndex = start + match[0].length;\n\t}\n\tout += escapeHtml(raw.slice(lastIndex));\n\tensureHook();\n\treturn DOMPurify.sanitize(out, {\n\t\tADD_ATTR: ['target', 'rel'],\n\t});\n}\n","<script lang=\"ts\">\n\timport {\n\t\tmessages,\n\t\tisStreaming,\n\t\tabort,\n\t\tactiveSessionInfo,\n\t\tcreateSession,\n\t\tpiState,\n\t\tupdateConfig,\n\t\tloadMoreHistory,\n\t\thasMoreHistory,\n\t\tisLoadingMoreHistory,\n\t\tisLoadingSession,\n\t\tisResyncing,\n\t\tresendMessage,\n\t\tdiscardMessage,\n\t\tbeepEnabled,\n\t\tbeepSessionOverride,\n\t\tsetBeepSessionOverride,\n\t\tisReadOnly,\n\t\tdownloadFileUrl,\n\t} from '$lib/wherever';\n\timport {\n\t\tavailableModels,\n\t\tgitInitDefaultStore,\n\t\tcheckPath,\n\t\tautocompletePath,\n\t\tcheckRemoteRepo,\n\t} from '$lib/session-store';\n\timport type {ChatMessage} from '$lib/wherever';\n\timport {onMount} from 'svelte';\n\timport {url} from '$lib/core/utils/web/path';\n\timport {renderMarkdown, linkifyText} from '$lib/core/utils/markdown';\n\n\t// Memoize rendered markdown per (message id + content length) so a finalized\n\t// assistant message is parsed once and its DOM stays stable afterwards. A\n\t// stable node is what lets a text selection survive (re-parsing on every\n\t// keystroke would collapse the selection, the bug we are fixing). Streaming\n\t// messages are NOT rendered as markdown -- they show plain text until final.\n\tconst markdownCache = new Map<string, string>();\n\tfunction renderAssistant(id: string, content: string): string {\n\t\tconst key = `${id}:${content.length}`;\n\t\tlet cached = markdownCache.get(key);\n\t\tif (cached === undefined) {\n\t\t\tcached = renderMarkdown(content);\n\t\t\tmarkdownCache.set(key, cached);\n\t\t}\n\t\treturn cached;\n\t}\n\n\t// Link-only rendering for user messages: bare URLs become clickable, but the\n\t// user's literal characters (asterisks, backticks) are NOT reinterpreted as\n\t// markdown. Memoized on the cleaned content so the DOM stays stable.\n\tconst linkifyCache = new Map<string, string>();\n\tfunction renderUser(content: string): string {\n\t\tlet cached = linkifyCache.get(content);\n\t\tif (cached === undefined) {\n\t\t\tcached = linkifyText(content);\n\t\t\tlinkifyCache.set(content, cached);\n\t\t}\n\t\treturn cached;\n\t}\n\n\t// Context-window usage indicator, shown next to the Hide Thinking/Tools\n\t// toggles. Humanize like the pi CLI: 1_000_000 -> \"1.0M\", 128_000 -> \"128K\".\n\tfunction formatTokens(n: number): string {\n\t\tif (n >= 1_000_000) {\n\t\t\tconst m = n / 1_000_000;\n\t\t\treturn (m >= 10 ? Math.round(m).toString() : m.toFixed(1)) + 'M';\n\t\t}\n\t\tif (n >= 1_000) return Math.round(n / 1_000) + 'K';\n\t\treturn String(n);\n\t}\n\n\t// \"11.3% / 1.0M\". Percent omitted (\"–\") right after compaction when tokens are\n\t// momentarily unknown.\n\tlet contextLabel = $derived.by(() => {\n\t\tconst u = $piState.contextUsage;\n\t\tif (!u || !u.contextWindow) return null;\n\t\tconst window = formatTokens(u.contextWindow);\n\t\tif (u.percent == null) return `– / ${window}`;\n\t\treturn `${u.percent.toFixed(1)}% / ${window}`;\n\t});\n\n\tfunction parseUserMessage(content: string) {\n\t\tif (!content) return {cleanContent: '', attachments: []};\n\t\tconst lines = content.split('\\n');\n\t\tconst fileRegex = /^\\[Uploaded file: (.+)\\]$/;\n\t\tconst cleanLines: string[] = [];\n\t\tconst attachments: string[] = [];\n\n\t\tfor (const line of lines) {\n\t\t\tconst match = line.match(fileRegex);\n\t\t\tif (match) {\n\t\t\t\tattachments.push(match[1]);\n\t\t\t} else {\n\t\t\t\tcleanLines.push(line);\n\t\t\t}\n\t\t}\n\n\t\tlet cleanContent = cleanLines.join('\\n').trim();\n\t\tif (cleanContent === 'I have uploaded the following file(s) for you:') {\n\t\t\tcleanContent = '';\n\t\t}\n\t\treturn {cleanContent, attachments};\n\t}\n\n\tlet newFolderCwd = $state('');\n\tlet completions = $state<string[]>([]);\n\tlet inputFocused = $state(false);\n\tlet inputEl = $state<HTMLInputElement | null>(null);\n\tlet containerEl = $state<HTMLDivElement | null>(null);\n\tlet lastCheckedPath = '';\n\tlet newFolderModel = $state('');\n\tlet newFolderGitInit = $state(false);\n\tlet userManualGitInit = $state<boolean | null>(null);\n\tlet createRemoteRepo = $state(true);\n\tlet repoVisibility = $state<'private' | 'public'>('private');\n\tlet showGitInitConfirmModal = $state(false);\n\t// Clone-existing-remote flow. When creating a session in a non-existing folder\n\t// that matches a remote rule, we probe (at submit time) whether the remote\n\t// repo already exists. If it does, we ask the user whether to CLONE it (SSH)\n\t// instead of creating a fresh empty remote.\n\tlet showCloneConfirmModal = $state(false);\n\tlet checkingRemote = $state(false);\n\tlet cloneRemoteInfo = $state<{provider?: string; sshUrl?: string} | null>(\n\t\tnull,\n\t);\n\n\tfunction submitCreateSession(cloneRemote: boolean) {\n\t\tcreateSession(\n\t\t\tnewFolderCwd.trim(),\n\t\t\tnewFolderModel || undefined,\n\t\t\tcloneRemote ? false : newFolderGitInit,\n\t\t\tcloneRemote\n\t\t\t\t? false\n\t\t\t\t: pathStatus.matchingRule\n\t\t\t\t\t? createRemoteRepo\n\t\t\t\t\t: undefined,\n\t\t\tcloneRemote\n\t\t\t\t? undefined\n\t\t\t\t: pathStatus.matchingRule\n\t\t\t\t\t? repoVisibility\n\t\t\t\t\t: undefined,\n\t\t\tcloneRemote || undefined,\n\t\t);\n\t}\n\n\tlet appState = $derived($piState);\n\tlet modelsData = $derived($availableModels);\n\tlet defaultGitInit = $derived($gitInitDefaultStore);\n\n\t// Sync git init default\n\t$effect(() => {\n\t\tif (userManualGitInit === null) {\n\t\t\tnewFolderGitInit = defaultGitInit;\n\t\t}\n\t});\n\n\tlet pathStatus = $state<{\n\t\texists: boolean | null;\n\t\tisGit: boolean;\n\t\tresolvedPath: string;\n\t\tmatchingRule: {provider: string; visibility: string} | null;\n\t}>({\n\t\texists: null,\n\t\tisGit: false,\n\t\tresolvedPath: '',\n\t\tmatchingRule: null,\n\t});\n\n\tlet isRemoteRepoCreation = $derived(\n\t\tpathStatus.exists !== true && pathStatus.matchingRule && createRemoteRepo,\n\t);\n\n\tlet pathCheckTimeout: ReturnType<typeof setTimeout> | null = null;\n\n\tasync function triggerCheck(pathValue: string, immediate = false) {\n\t\tif (pathCheckTimeout) clearTimeout(pathCheckTimeout);\n\n\t\tif (pathValue === lastCheckedPath && !immediate) return;\n\t\tlastCheckedPath = pathValue;\n\n\t\tif (!pathValue.trim()) {\n\t\t\tpathStatus = {\n\t\t\t\texists: null,\n\t\t\t\tisGit: false,\n\t\t\t\tresolvedPath: '',\n\t\t\t\tmatchingRule: null,\n\t\t\t};\n\t\t\tconst fetchEmpty = async () => {\n\t\t\t\tconst list = await autocompletePath('');\n\t\t\t\tcompletions = list || [];\n\t\t\t};\n\t\t\tif (immediate) {\n\t\t\t\tawait fetchEmpty();\n\t\t\t} else {\n\t\t\t\tpathCheckTimeout = setTimeout(fetchEmpty, 300);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tconst fetchFn = async () => {\n\t\t\tconst [res, list] = await Promise.all([\n\t\t\t\tcheckPath(pathValue),\n\t\t\t\tautocompletePath(pathValue),\n\t\t\t]);\n\t\t\tcompletions = list || [];\n\t\t\tif (res) {\n\t\t\t\tpathStatus = {\n\t\t\t\t\texists: res.exists,\n\t\t\t\t\tisGit: res.isGit,\n\t\t\t\t\tresolvedPath: res.resolvedPath,\n\t\t\t\t\tmatchingRule: (res as any).matchingRule || null,\n\t\t\t\t};\n\t\t\t\tif (!res.exists) {\n\t\t\t\t\tnewFolderGitInit =\n\t\t\t\t\t\tuserManualGitInit !== null ? userManualGitInit : defaultGitInit;\n\t\t\t\t\tcreateRemoteRepo = true; // reset to true for non-existing folders\n\t\t\t\t\tif ((res as any).matchingRule) {\n\t\t\t\t\t\trepoVisibility = (res as any).matchingRule.visibility as\n\t\t\t\t\t\t\t| 'private'\n\t\t\t\t\t\t\t| 'public';\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tpathStatus = {\n\t\t\t\t\texists: null,\n\t\t\t\t\tisGit: false,\n\t\t\t\t\tresolvedPath: '',\n\t\t\t\t\tmatchingRule: null,\n\t\t\t\t};\n\t\t\t}\n\t\t};\n\n\t\tif (immediate) {\n\t\t\tawait fetchFn();\n\t\t} else {\n\t\t\tpathCheckTimeout = setTimeout(fetchFn, 300);\n\t\t}\n\t}\n\n\t$effect(() => {\n\t\tconst pathValue = newFolderCwd;\n\t\ttriggerCheck(pathValue, false);\n\t});\n\n\t// Select default model if any\n\t$effect(() => {\n\t\tif (modelsData.models.length > 0 && !newFolderModel) {\n\t\t\tconst defaultModel = modelsData.models.find((m) => m.isDefault);\n\t\t\tif (defaultModel) {\n\t\t\t\tnewFolderModel = `${defaultModel.provider}:${defaultModel.modelId}`;\n\t\t\t} else {\n\t\t\t\tnewFolderModel = `${modelsData.models[0].provider}:${modelsData.models[0].modelId}`;\n\t\t\t}\n\t\t}\n\t});\n\n\tasync function handleFormCreateSession() {\n\t\tif (!newFolderCwd.trim()) return;\n\t\tif (pathStatus.exists === true) {\n\t\t\tnewFolderGitInit = false; // toggled off by default in modal\n\t\t\tcreateRemoteRepo = false; // toggled off by default in modal\n\t\t\tif (pathStatus.matchingRule) {\n\t\t\t\trepoVisibility = pathStatus.matchingRule.visibility as\n\t\t\t\t\t| 'private'\n\t\t\t\t\t| 'public';\n\t\t\t}\n\t\t\tshowGitInitConfirmModal = true;\n\t\t\treturn;\n\t\t}\n\n\t\t// Non-existing folder. If it matches a remote rule AND the user still\n\t\t// wants a remote, probe (at submit time) whether that remote repo already\n\t\t// exists. If so, offer to CLONE it instead of failing on create.\n\t\tif (pathStatus.matchingRule && createRemoteRepo) {\n\t\t\tcheckingRemote = true;\n\t\t\ttry {\n\t\t\t\tconst probe = await checkRemoteRepo(newFolderCwd.trim());\n\t\t\t\tif (probe && probe.matched && probe.exists) {\n\t\t\t\t\tcloneRemoteInfo = {\n\t\t\t\t\t\tprovider: probe.provider,\n\t\t\t\t\t\tsshUrl: probe.sshUrl,\n\t\t\t\t\t};\n\t\t\t\t\tshowCloneConfirmModal = true;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t} finally {\n\t\t\t\tcheckingRemote = false;\n\t\t\t}\n\t\t}\n\n\t\tsubmitCreateSession(false);\n\t}\n\n\tlet messageList = $state<HTMLDivElement>();\n\tlet {onMessageSent}: {onMessageSent: () => void} = $props();\n\n\tlet sessionInfo = $derived($activeSessionInfo);\n\tlet loadingSession = $derived($isLoadingSession);\n\tlet resyncing = $derived($isResyncing);\n\n\t// Per-session beep control is tri-state: undefined = follow the global\n\t// default, true/false = an explicit choice that sticks to this session.\n\t// Cycling order: Default -> On -> Off -> Default. Showing \"Default\" (rather\n\t// than a plain on/off) is what signals the choice has NOT been set for this\n\t// session, so it tracks the default live.\n\tlet beepOverride = $derived($beepSessionOverride);\n\tlet beepOn = $derived($beepEnabled);\n\tfunction cycleBeep() {\n\t\tif (beepOverride === undefined) setBeepSessionOverride(true);\n\t\telse if (beepOverride === true) setBeepSessionOverride(false);\n\t\telse setBeepSessionOverride(undefined);\n\t}\n\n\t// True when we hold a cached session (its file + messages) that is merely\n\t// reconnecting/resyncing, not loading fresh. In this state the conversation\n\t// must stay on screen (with the parent's \"Reconnecting...\" banner over the\n\t// composer) instead of being replaced by the big \"Not connected\" panel or the\n\t// new-session / search empty-state. This is the core of \"block only where it\n\t// matters (this session)\": a dropped socket blocks sending, not reading.\n\tlet hasCachedSession = $derived(!!sessionInfo.sessionFile);\n\n\tlet shouldAutoScroll = $state(true);\n\tlet forceScroll = $state(false);\n\n\tlet expandedMessages = $state<Record<string, boolean>>({});\n\n\tfunction toggleMessage(id: string, currentVal: boolean) {\n\t\texpandedMessages[id] = !currentVal;\n\t}\n\n\tfunction parseArgsObject(\n\t\targsStr: string | undefined,\n\t): Record<string, any> | null {\n\t\tif (!argsStr) return null;\n\t\tconst trimmed = argsStr.trim();\n\t\tif (!trimmed) return null;\n\n\t\t// If it's JSON\n\t\tif (trimmed.startsWith('{')) {\n\t\t\ttry {\n\t\t\t\treturn JSON.parse(trimmed);\n\t\t\t} catch (e) {}\n\t\t}\n\n\t\t// If it's k1=\"v1\" k2=\"v2\" format, parse it\n\t\tconst obj: Record<string, any> = {};\n\t\tconst regex =\n\t\t\t/([a-zA-Z0-9_-]+)\\s*=\\s*(?:\"([^\"\\\\]*(?:\\\\.[^\"\\\\]*)*)\"|'([^'\\\\]*(?:\\\\.[^'\\\\]*)*)'|(\\S+))/g;\n\t\tlet match;\n\t\twhile ((match = regex.exec(trimmed)) !== null) {\n\t\t\tconst key = match[1];\n\t\t\tconst val =\n\t\t\t\tmatch[2] !== undefined\n\t\t\t\t\t? match[2]\n\t\t\t\t\t: match[3] !== undefined\n\t\t\t\t\t\t? match[3]\n\t\t\t\t\t\t: match[4];\n\t\t\tobj[key] = val;\n\t\t}\n\n\t\tif (Object.keys(obj).length > 0) {\n\t\t\treturn obj;\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tfunction getSmartTitleArgs(\n\t\ttoolName: string,\n\t\targsObj: Record<string, any> | null,\n\t\trawArgsStr: string,\n\t): string {\n\t\tif (!argsObj) {\n\t\t\treturn rawArgsStr ? rawArgsStr.trim() : '';\n\t\t}\n\n\t\tconst name = toolName.toLowerCase();\n\n\t\t// 1. read, write, edit, ls: show the path directly\n\t\tif (['read', 'write', 'edit', 'ls'].includes(name)) {\n\t\t\tconst pathVal = argsObj.path || argsObj.filepath || argsObj.file;\n\t\t\tif (pathVal) {\n\t\t\t\treturn String(pathVal);\n\t\t\t}\n\t\t}\n\n\t\t// 2. bash: show the first few characters of the command\n\t\tif (name === 'bash') {\n\t\t\tconst cmd = argsObj.command || argsObj.cmd;\n\t\t\tif (cmd) {\n\t\t\t\tconst cleanCmd = String(cmd).replace(/\\s+/g, ' ').trim();\n\t\t\t\treturn cleanCmd.length > 50 ? cleanCmd.slice(0, 47) + '...' : cleanCmd;\n\t\t\t}\n\t\t}\n\n\t\t// 3. grep: show pattern / pattern in path\n\t\tif (name === 'grep') {\n\t\t\tconst pattern = argsObj.pattern;\n\t\t\tconst pathVal = argsObj.path;\n\t\t\tif (pattern) {\n\t\t\t\treturn pathVal ? `\"${pattern}\" in ${pathVal}` : `\"${pattern}\"`;\n\t\t\t}\n\t\t}\n\n\t\t// 4. find: show pattern or path\n\t\tif (name === 'find') {\n\t\t\tconst pattern = argsObj.pattern || argsObj.path;\n\t\t\tif (pattern) {\n\t\t\t\treturn String(pattern);\n\t\t\t}\n\t\t}\n\n\t\t// Custom tools check for common key names\n\t\tconst commonPath =\n\t\t\targsObj.path ||\n\t\t\targsObj.filepath ||\n\t\t\targsObj.file ||\n\t\t\targsObj.name ||\n\t\t\targsObj.query;\n\t\tif (commonPath) {\n\t\t\treturn String(commonPath);\n\t\t}\n\n\t\t// Default fallback formatting for title\n\t\treturn Object.entries(argsObj)\n\t\t\t.filter(([k, v]) => v !== undefined && v !== '')\n\t\t\t.map(([k, v]) => `${k}=${typeof v === 'object' ? JSON.stringify(v) : v}`)\n\t\t\t.join(' ');\n\t}\n\n\tfunction getFullArgsFormatted(\n\t\targsObj: Record<string, any> | null,\n\t\trawArgsStr: string,\n\t): string {\n\t\tif (argsObj) {\n\t\t\treturn JSON.stringify(argsObj, null, 2);\n\t\t}\n\t\treturn rawArgsStr ? rawArgsStr.trim() : '';\n\t}\n\n\tfunction parseToolMessage(msg: ChatMessage) {\n\t\tlet toolName = msg.toolName || 'tool';\n\t\tlet toolArgs = msg.toolArgs !== undefined ? msg.toolArgs : '';\n\t\tlet toolOutput = msg.toolOutput !== undefined ? msg.toolOutput : '';\n\t\tlet isError = !!msg.isError;\n\n\t\t// If we don't have toolArgs or toolOutput, or if they are empty but msg.content is populated,\n\t\t// let's parse from content to be absolutely sure we get any args embedded in the raw text.\n\t\tif (!toolArgs && !toolOutput && msg.content) {\n\t\t\tlet content = msg.content || '';\n\n\t\t\tif (content.startsWith('Error: ')) {\n\t\t\t\tisError = true;\n\t\t\t\tcontent = content.slice(7);\n\t\t\t} else if (content.startsWith('Tool error: ')) {\n\t\t\t\tisError = true;\n\t\t\t\tcontent = content.slice(12);\n\t\t\t}\n\n\t\t\tconst firstLineBreak = content.indexOf('\\n');\n\t\t\tconst headerLine =\n\t\t\t\tfirstLineBreak !== -1 ? content.slice(0, firstLineBreak) : content;\n\t\t\ttoolOutput =\n\t\t\t\tfirstLineBreak !== -1 ? content.slice(firstLineBreak + 1) : '';\n\n\t\t\tlet header = headerLine.trim();\n\t\t\tif (header.startsWith('$ ')) {\n\t\t\t\theader = header.slice(2);\n\t\t\t}\n\n\t\t\tconst firstSpace = header.indexOf(' ');\n\t\t\ttoolName =\n\t\t\t\tmsg.toolName ||\n\t\t\t\t(firstSpace !== -1 ? header.slice(0, firstSpace) : header) ||\n\t\t\t\t'tool';\n\t\t\ttoolArgs = firstSpace !== -1 ? header.slice(firstSpace + 1) : '';\n\t\t}\n\n\t\tconst argsObj = parseArgsObject(toolArgs);\n\t\tconst smartTitleArgs = getSmartTitleArgs(toolName, argsObj, toolArgs);\n\t\tconst fullArgs = getFullArgsFormatted(argsObj, toolArgs);\n\n\t\treturn {\n\t\t\ttoolName,\n\t\t\tsmartTitleArgs,\n\t\t\tfullArgs,\n\t\t\ttoolOutput,\n\t\t\tisError,\n\t\t\t// A tool call that ended with no result (e.g. killed by a CLI takeover).\n\t\t\t// Outcome unknown: render a neutral \"interrupted\" state, not success.\n\t\t\tinterrupted: !!msg.interrupted,\n\t\t\t// The path of a single file this tool operated on, when it is a\n\t\t\t// file-oriented tool. Drives the per-tool download button. Two groups:\n\t\t\t// - `attach_file`: the agent EXPLICITLY offered this file for download\n\t\t\t// (the intended, agent-driven path, e.g. \"give me the gpx\").\n\t\t\t// - `read`/`write`/`edit`: the card already carries the exact path the\n\t\t\t// agent touched, so we offer it opportunistically too.\n\t\t\t// `ls`/`grep`/`find` are excluded (their path arg is a directory or\n\t\t\t// search scope, not a downloadable file). Suppressed on errors.\n\t\t\tdownloadPath: extractDownloadablePath(toolName, argsObj, isError),\n\t\t};\n\t}\n\n\t// Return the single file path a file-oriented tool operated on, or null. Kept\n\t// deliberately narrow so the button never appears on a directory (ls) or a\n\t// search scope (grep/find).\n\tfunction extractDownloadablePath(\n\t\ttoolName: string,\n\t\targsObj: Record<string, any> | null,\n\t\tisError: boolean,\n\t): string | null {\n\t\tif (isError || !argsObj) return null;\n\t\tconst name = (toolName || '').toLowerCase();\n\t\tif (!['attach_file', 'read', 'write', 'edit'].includes(name)) return null;\n\t\tconst pathVal = argsObj.path || argsObj.filepath || argsObj.file;\n\t\tif (!pathVal || typeof pathVal !== 'string') return null;\n\t\treturn pathVal.trim() || null;\n\t}\n\n\tfunction isScrolledToBottom(el: HTMLDivElement): boolean {\n\t\tconst threshold = 20;\n\t\treturn el.scrollHeight - el.scrollTop - el.clientHeight <= threshold;\n\t}\n\n\tfunction handleScroll() {\n\t\tif (messageList) {\n\t\t\tshouldAutoScroll = isScrolledToBottom(messageList);\n\t\t}\n\t}\n\n\tfunction scrollToBottom() {\n\t\tif (messageList) {\n\t\t\tmessageList.scrollTop = messageList.scrollHeight;\n\t\t}\n\t}\n\n\tfunction scrollToBottomIfShould() {\n\t\tif (shouldAutoScroll || forceScroll) {\n\t\t\tscrollToBottom();\n\t\t\tforceScroll = false;\n\t\t}\n\t}\n\n\tonMount(scrollToBottom);\n\n\t$effect(() => {\n\t\tif (messageList) {\n\t\t\tmessageList.addEventListener('scroll', handleScroll);\n\t\t\treturn () => {\n\t\t\t\tif (messageList) {\n\t\t\t\t\tmessageList.removeEventListener('scroll', handleScroll);\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\t});\n\n\tlet lastSessionFile = $state<string | null>(null);\n\tlet wasLoadingSession = $state(false);\n\n\t// Scroll the freshly-loaded session to the bottom. The session history\n\t// arrives as a separate WS message after the session itself, and the\n\t// rendered messages (markdown, code blocks) keep growing for a few frames\n\t// after they mount, so a single synchronous scroll lands too early. Retry\n\t// across a couple of frames to settle on the true bottom.\n\tfunction scrollToBottomSettled() {\n\t\tforceScroll = true;\n\t\tscrollToBottom();\n\t\trequestAnimationFrame(() => {\n\t\t\tscrollToBottom();\n\t\t\trequestAnimationFrame(scrollToBottom);\n\t\t});\n\t\tsetTimeout(scrollToBottom, 60);\n\t\tsetTimeout(scrollToBottom, 150);\n\t}\n\n\t$effect(() => {\n\t\t// Force scroll to bottom when the active session changes...\n\t\tconst sFile = sessionInfo.sessionFile;\n\t\tif (sFile !== lastSessionFile) {\n\t\t\tlastSessionFile = sFile;\n\t\t\tforceScroll = true;\n\t\t}\n\n\t\t// ...and again once its history finishes loading, since the messages only\n\t\t// render after loadingSession flips back to false.\n\t\tconst isLoading = loadingSession;\n\t\tif (wasLoadingSession && !isLoading) {\n\t\t\tscrollToBottomSettled();\n\t\t}\n\t\twasLoadingSession = isLoading;\n\t});\n\n\tlet msgList = $derived.by(() => {\n\t\tconst filtered = $messages.filter((msg) => {\n\t\t\tif (msg.role === 'thinking') {\n\t\t\t\tif ($piState.hideThinking) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (msg.role === 'tool') {\n\t\t\t\t// attach_file renders as an attachment, not tool noise, so it is\n\t\t\t\t// never suppressed by \"hide tools\".\n\t\t\t\tif ($piState.hideTools && msg.toolName !== 'attach_file') {\n\t\t\t\t\treturn isAssociatedWithForceCommand(msg) || !!msg.isStreaming;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn (\n\t\t\t\t(msg.role !== 'assistant' && msg.role !== 'thinking') ||\n\t\t\t\tmsg.isStreaming ||\n\t\t\t\tmsg.content.trim() !== ''\n\t\t\t);\n\t\t});\n\n\t\tconst activeStreamExists = filtered.some((msg) => msg.isStreaming);\n\t\tif (streaming && !activeStreamExists) {\n\t\t\tconst isThinking = $messages.some(\n\t\t\t\t(msg) => msg.role === 'thinking' && msg.isStreaming,\n\t\t\t);\n\t\t\tfiltered.push({\n\t\t\t\tid: 'fallback-loader-message-id',\n\t\t\t\trole: 'thinking',\n\t\t\t\tcontent: isThinking ? 'FALLBACK_THINKING_LOADER' : 'FALLBACK_LOADER',\n\t\t\t\ttimestamp: Date.now(),\n\t\t\t\tisStreaming: true,\n\t\t\t});\n\t\t}\n\n\t\treturn filtered;\n\t});\n\tlet streaming = $derived($isStreaming);\n\n\t// A live \"now\" that ticks ~every 100ms ONLY while a tool call is running, so\n\t// the \"Elapsed N.Ns\" duration counts up in real time (mirrors the pi CLI's\n\t// bash tool). The interval is torn down as soon as no tool is streaming, so an\n\t// idle session does no per-frame work. A finished tool freezes its duration\n\t// from startedAt..endedAt and does not depend on this ticker.\n\tlet now = $state(Date.now());\n\tlet anyToolRunning = $derived(\n\t\tmsgList.some((m) => m.role === 'tool' && m.isStreaming),\n\t);\n\t$effect(() => {\n\t\tif (!anyToolRunning) return;\n\t\tnow = Date.now();\n\t\tconst id = setInterval(() => (now = Date.now()), 100);\n\t\treturn () => clearInterval(id);\n\t});\n\n\t// Format a tool call's run duration the way the pi CLI does: \"N.Ns\" (one\n\t// decimal). While running, count from startedAt to the live `now`; once ended,\n\t// freeze at endedAt. Returns null when we have no start time (e.g. a tool\n\t// reconstructed from loaded history, which carries no timing).\n\tfunction toolDuration(msg: ChatMessage): string | null {\n\t\tif (msg.startedAt === undefined) return null;\n\t\tconst end = msg.endedAt ?? (msg.isStreaming ? now : undefined);\n\t\tif (end === undefined) return null;\n\t\tconst ms = Math.max(0, end - msg.startedAt);\n\t\treturn `${(ms / 1000).toFixed(1)}s`;\n\t}\n\n\t$effect.pre(() => {\n\t\t// React to msgList length and content changes of the last message in msgList\n\t\tconst lastMsg = msgList[msgList.length - 1];\n\t\tconst triggerValue = lastMsg\n\t\t\t? `${msgList.length}-${lastMsg.content.length}`\n\t\t\t: '0';\n\n\t\tif (messageList) {\n\t\t\tshouldAutoScroll = isScrolledToBottom(messageList);\n\t\t}\n\t});\n\n\t$effect(() => {\n\t\t// React to msgList length and content changes of the last message in msgList\n\t\tconst lastMsg = msgList[msgList.length - 1];\n\t\tconst triggerValue = lastMsg\n\t\t\t? `${msgList.length}-${lastMsg.content.length}`\n\t\t\t: '0';\n\n\t\tscrollToBottomIfShould();\n\t});\n\n\tfunction formatTime(timestamp: number) {\n\t\treturn new Date(timestamp).toLocaleTimeString([], {\n\t\t\thour: '2-digit',\n\t\t\tminute: '2-digit',\n\t\t});\n\t}\n\n\t// True when `msg` is a bash tool call produced by a user `!command` /\n\t// `!!command` (a \"force command\"), as opposed to one the agent issued. The\n\t// server marks these explicitly (`forceCommand`) both live (tool_start) and in\n\t// reloaded history (the bashExecution -> tool_call mapping), so this is an\n\t// unambiguous per-message flag: no structural inference, and it works\n\t// correctly for back-to-back `!command`s and after a reload.\n\tfunction isAssociatedWithForceCommand(msg: ChatMessage): boolean {\n\t\treturn msg.role === 'tool' && msg.forceCommand === true;\n\t}\n\n\tfunction shouldAutoExpand(msg: ChatMessage, list: ChatMessage[]): boolean {\n\t\treturn isAssociatedWithForceCommand(msg);\n\t}\n\n\texport function forceScrollToBottom() {\n\t\tforceScroll = true;\n\t\tsetTimeout(scrollToBottom, 0);\n\t}\n\n\tlet moreHistory = $derived($hasMoreHistory);\n\tlet loadingMore = $derived($isLoadingMoreHistory);\n\n\t// Scroll anchoring: when older messages are prepended, keep the viewport\n\t// anchored on the message that was previously first, and reveal the newly\n\t// loaded messages as a gap above it.\n\t//\n\t// We record the id of the first message before the load. After the older\n\t// window is prepended, we scroll so that anchor message sits just below the\n\t// top of the viewport, leaving REVEAL_GAP_PX of the newly loaded messages\n\t// visible above it as a hint that more history was inserted. If the anchor\n\t// element can't be found (e.g. it was filtered out), we fall back to\n\t// preserving the distance from the bottom so the content at least doesn't\n\t// jump.\n\tconst REVEAL_GAP_PX = 64;\n\tlet pendingAnchorId = $state<string | null>(null);\n\tlet pendingAnchorFromBottom = $state<number | null>(null);\n\n\tfunction handleLoadMore() {\n\t\tif (!messageList || loadingMore || !moreHistory) return;\n\t\t// Anchor on the first currently-rendered message so we can bring it back\n\t\t// to (near) the top after the older window is prepended.\n\t\tpendingAnchorId = msgList[0]?.id ?? null;\n\t\t// Fallback anchor: distance from the bottom, in case the id can't be found.\n\t\tpendingAnchorFromBottom = messageList.scrollHeight - messageList.scrollTop;\n\t\tloadMoreHistory();\n\t}\n\n\t$effect(() => {\n\t\t// When messages change and we have a pending anchor (older history was\n\t\t// just prepended), restore the scroll position.\n\t\tconst _len = $messages.length;\n\t\tif (\n\t\t\t(pendingAnchorId !== null || pendingAnchorFromBottom !== null) &&\n\t\t\tmessageList\n\t\t) {\n\t\t\tconst anchorId = pendingAnchorId;\n\t\t\tconst anchorFromBottom = pendingAnchorFromBottom;\n\t\t\tpendingAnchorId = null;\n\t\t\tpendingAnchorFromBottom = null;\n\t\t\t// Defer until after DOM paints the prepended nodes.\n\t\t\trequestAnimationFrame(() => {\n\t\t\t\tif (!messageList) return;\n\t\t\t\tconst anchorEl = anchorId\n\t\t\t\t\t? messageList.querySelector<HTMLElement>(\n\t\t\t\t\t\t\t`[data-msg-id=\"${CSS.escape(anchorId)}\"]`,\n\t\t\t\t\t\t)\n\t\t\t\t\t: null;\n\t\t\t\tif (anchorEl) {\n\t\t\t\t\t// Position the previously-first message just below the top, leaving\n\t\t\t\t\t// a gap that reveals the newly loaded messages above it. Using\n\t\t\t\t\t// rects (instead of offsetTop) keeps this correct regardless of the\n\t\t\t\t\t// element's offset parent.\n\t\t\t\t\tconst delta =\n\t\t\t\t\t\tanchorEl.getBoundingClientRect().top -\n\t\t\t\t\t\tmessageList.getBoundingClientRect().top;\n\t\t\t\t\tmessageList.scrollTop = Math.max(\n\t\t\t\t\t\t0,\n\t\t\t\t\t\tmessageList.scrollTop + delta - REVEAL_GAP_PX,\n\t\t\t\t\t);\n\t\t\t\t} else if (anchorFromBottom !== null) {\n\t\t\t\t\tmessageList.scrollTop = messageList.scrollHeight - anchorFromBottom;\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t});\n</script>\n\n<div class=\"flex flex-1 flex-col overflow-hidden bg-brand-dark\">\n\t{#if appState.connecting && !hasCachedSession}\n\t\t<div\n\t\t\tclass=\"flex flex-1 flex-col items-center justify-center bg-brand-dark p-6 text-brand-text-muted\"\n\t\t>\n\t\t\t<div class=\"text-center\">\n\t\t\t\t<div\n\t\t\t\t\tclass=\"mb-4 inline-block h-8 w-8 animate-spin rounded-full border-4 border-brand-blue border-t-transparent\"\n\t\t\t\t></div>\n\t\t\t\t<p class=\"text-base font-medium text-brand-text\">\n\t\t\t\t\tConnecting to Wherever Server...\n\t\t\t\t</p>\n\t\t\t\t<p class=\"mt-1 text-xs text-brand-text-muted\">\n\t\t\t\t\tEstablishing secure connection to your agent\n\t\t\t\t</p>\n\t\t\t</div>\n\t\t</div>\n\t{:else if !appState.connected && !hasCachedSession}\n\t\t<div\n\t\t\tclass=\"flex flex-1 flex-col items-center justify-center bg-brand-dark p-6 text-brand-text-muted\"\n\t\t>\n\t\t\t<div\n\t\t\t\tclass=\"w-full max-w-md rounded-lg border border-red-500/30 bg-red-500/10 p-6 text-center text-brand-text\"\n\t\t\t>\n\t\t\t\t<div class=\"mb-3 text-4xl\">⚠️</div>\n\t\t\t\t<h3 class=\"text-lg font-bold text-rose-400\">Not Connected to Server</h3>\n\t\t\t\t<p class=\"mt-2 text-sm text-brand-text-muted\">\n\t\t\t\t\tWe couldn't connect to the Wherever Server. Please verify the server\n\t\t\t\t\tis running and check your connection settings in the sidebar.\n\t\t\t\t</p>\n\t\t\t\t{#if appState.error}\n\t\t\t\t\t<p\n\t\t\t\t\t\tclass=\"mt-3 max-h-24 overflow-y-auto rounded bg-brand-surface-3 p-2 font-mono text-xs text-rose-300/80\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{appState.error}\n\t\t\t\t\t</p>\n\t\t\t\t{/if}\n\t\t\t\t<button\n\t\t\t\t\tonclick={() => {\n\t\t\t\t\t\timport('$lib/wherever').then((m) => m.connect());\n\t\t\t\t\t}}\n\t\t\t\t\tclass=\"mt-5 rounded bg-brand-surface-2 px-4 py-2 text-sm font-semibold text-brand-text transition-colors hover:bg-brand-surface-3\"\n\t\t\t\t>\n\t\t\t\t\tRetry Connection\n\t\t\t\t</button>\n\t\t\t</div>\n\t\t</div>\n\t{:else if !hasCachedSession && (loadingSession || (typeof window !== 'undefined' && window.location.hash))}\n\t\t<!-- Genuine fresh load of a session we do NOT yet hold. A resync of a\n\t\t cached session does NOT reach here (it keeps hasCachedSession true and\n\t\t falls through to the messages view with the parent's reconnect banner),\n\t\t so returning to the app never flashes this full-screen spinner over an\n\t\t already-loaded conversation. -->\n\t\t<div\n\t\t\tclass=\"flex flex-1 flex-col items-center justify-center bg-brand-dark p-6 text-brand-text-muted\"\n\t\t>\n\t\t\t<div class=\"text-center\">\n\t\t\t\t<div\n\t\t\t\t\tclass=\"mb-4 inline-block h-8 w-8 animate-spin rounded-full border-4 border-brand-blue border-t-transparent\"\n\t\t\t\t></div>\n\t\t\t\t<p class=\"text-base font-medium text-brand-text\">Loading session...</p>\n\t\t\t\t<p class=\"mt-1 text-xs text-brand-text-muted\">\n\t\t\t\t\tRetrieving workspace session history\n\t\t\t\t</p>\n\t\t\t</div>\n\t\t</div>\n\t{:else if !sessionInfo.sessionFile}\n\t\t<div class=\"flex flex-1 items-center justify-center p-6\">\n\t\t\t<div\n\t\t\t\tclass=\"w-full max-w-md rounded-lg border border-brand-border bg-brand-surface/40 p-6 text-brand-text\"\n\t\t\t>\n\t\t\t\t<div class=\"mb-5 text-center\">\n\t\t\t\t\t<div class=\"mb-3 flex justify-center\">\n\t\t\t\t\t\t<img src={url('/logo.svg')} alt=\"Wherever\" class=\"h-16 w-16\" />\n\t\t\t\t\t</div>\n\t\t\t\t\t<h2 class=\"mb-1 text-2xl font-bold\">\n\t\t\t\t\t\t<span class=\"gradient-text\">Wherever</span>\n\t\t\t\t\t</h2>\n\t\t\t\t\t<h3 class=\"text-sm font-semibold text-brand-text\">\n\t\t\t\t\t\tCreate a New Session\n\t\t\t\t\t</h3>\n\t\t\t\t\t<p class=\"mt-1 text-xs text-brand-text-muted\">\n\t\t\t\t\t\tStart a coding session in any folder on your machine, or use the\n\t\t\t\t\t\tsidebar to open an existing session.\n\t\t\t\t\t</p>\n\t\t\t\t</div>\n\n\t\t\t\t<form\n\t\t\t\t\tonsubmit={(e) => {\n\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t\thandleFormCreateSession();\n\t\t\t\t\t}}\n\t\t\t\t\tclass=\"space-y-4\"\n\t\t\t\t>\n\t\t\t\t\t<div>\n\t\t\t\t\t\t<label\n\t\t\t\t\t\t\tclass=\"mb-1 block text-xs font-bold tracking-wider text-brand-text-muted uppercase\"\n\t\t\t\t\t\t\tfor=\"main-folder-path\">Folder Path</label\n\t\t\t\t\t\t>\n\t\t\t\t\t\t<div class=\"relative\" bind:this={containerEl}>\n\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\tbind:this={inputEl}\n\t\t\t\t\t\t\t\tid=\"main-folder-path\"\n\t\t\t\t\t\t\t\ttype=\"text\"\n\t\t\t\t\t\t\t\tautocomplete=\"off\"\n\t\t\t\t\t\t\t\tspellcheck=\"false\"\n\t\t\t\t\t\t\t\tplaceholder=\"e.g. ~/projects/my-new-app\"\n\t\t\t\t\t\t\t\tbind:value={newFolderCwd}\n\t\t\t\t\t\t\t\tonfocus={() => {\n\t\t\t\t\t\t\t\t\tinputFocused = true;\n\t\t\t\t\t\t\t\t\ttriggerCheck(newFolderCwd, true);\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\tonblur={(e) => {\n\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\tcontainerEl &&\n\t\t\t\t\t\t\t\t\t\tcontainerEl.contains(e.relatedTarget as Node)\n\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tinputFocused = false;\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\tonkeydown={(e) => {\n\t\t\t\t\t\t\t\t\tif (e.key === 'Escape') {\n\t\t\t\t\t\t\t\t\t\tinputFocused = false;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\tclass=\"w-full rounded border px-3 py-2 text-sm text-brand-text placeholder-brand-text-muted transition-all duration-200 focus:outline-none {isRemoteRepoCreation\n\t\t\t\t\t\t\t\t\t? 'border-emerald-500/80 bg-emerald-500/10 focus:border-emerald-400 focus:ring-1 focus:ring-emerald-400/30'\n\t\t\t\t\t\t\t\t\t: 'border-brand-border bg-brand-surface-3 focus:border-brand-blue'}\"\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t{#if inputFocused && completions.length > 0}\n\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\tclass=\"absolute right-0 left-0 z-50 mt-1 max-h-48 overflow-y-auto rounded border border-brand-border bg-brand-surface-2 py-1 shadow-xl\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{#each completions as completion}\n\t\t\t\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\t\t\t\tonclick={() => {\n\t\t\t\t\t\t\t\t\t\t\t\tnewFolderCwd = completion;\n\t\t\t\t\t\t\t\t\t\t\t\ttriggerCheck(completion, true);\n\t\t\t\t\t\t\t\t\t\t\t\tinputEl?.focus();\n\t\t\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\t\t\tclass=\"block w-full px-3 py-1.5 text-left text-sm text-brand-text transition-colors hover:bg-brand-surface-3 hover:text-brand-text\"\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{completion}\n\t\t\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t\t\t{/each}\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t{#if pathStatus.exists === true}\n\t\t\t\t\t\t\t<span class=\"mt-1.5 block text-xs font-medium text-yellow-400\">\n\t\t\t\t\t\t\t\t📁 Folder already exists. Joining will create a session in it.\n\t\t\t\t\t\t\t\t{#if pathStatus.isGit}\n\t\t\t\t\t\t\t\t\t<span class=\"ml-1 font-medium text-emerald-400\"\n\t\t\t\t\t\t\t\t\t\t>(Git repo detected)</span\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t{:else}\n\t\t\t\t\t\t\t<span class=\"mt-1 block text-[10px] text-brand-text-muted\"\n\t\t\t\t\t\t\t\t>Relative paths are created inside your home folder.</span\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t{/if}\n\t\t\t\t\t</div>\n\n\t\t\t\t\t<div>\n\t\t\t\t\t\t<label\n\t\t\t\t\t\t\tclass=\"mb-1 block text-xs font-bold tracking-wider text-brand-text-muted uppercase\"\n\t\t\t\t\t\t\tfor=\"main-model-select\">Model</label\n\t\t\t\t\t\t>\n\t\t\t\t\t\t{#if modelsData.models.length > 0}\n\t\t\t\t\t\t\t<select\n\t\t\t\t\t\t\t\tid=\"main-model-select\"\n\t\t\t\t\t\t\t\tbind:value={newFolderModel}\n\t\t\t\t\t\t\t\tclass=\"w-full rounded border border-brand-border bg-brand-surface-3 px-3 py-2 text-sm text-brand-text focus:border-brand-blue focus:outline-none\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{#each modelsData.models as model}\n\t\t\t\t\t\t\t\t\t<option value={`${model.provider}:${model.modelId}`}>\n\t\t\t\t\t\t\t\t\t\t{model.label}{model.isDefault ? ' (default)' : ''}\n\t\t\t\t\t\t\t\t\t</option>\n\t\t\t\t\t\t\t\t{/each}\n\t\t\t\t\t\t\t</select>\n\t\t\t\t\t\t{:else}\n\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\tid=\"main-model-select\"\n\t\t\t\t\t\t\t\ttype=\"text\"\n\t\t\t\t\t\t\t\tbind:value={newFolderModel}\n\t\t\t\t\t\t\t\tplaceholder=\"provider:model\"\n\t\t\t\t\t\t\t\tclass=\"w-full rounded border border-brand-border bg-brand-surface-3 px-3 py-2 text-sm text-brand-text placeholder-brand-text-muted focus:border-brand-blue focus:outline-none\"\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t{/if}\n\t\t\t\t\t</div>\n\n\t\t\t\t\t{#if pathStatus.exists !== true && pathStatus.matchingRule}\n\t\t\t\t\t\t<div class=\"space-y-1.5 pt-1\">\n\t\t\t\t\t\t\t<div class=\"flex items-center gap-2\">\n\t\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\t\tid=\"main-create-remote\"\n\t\t\t\t\t\t\t\t\ttype=\"checkbox\"\n\t\t\t\t\t\t\t\t\tbind:checked={createRemoteRepo}\n\t\t\t\t\t\t\t\t\tclass=\"h-4 w-4 rounded border-brand-border bg-brand-surface-3 text-brand-blue focus:ring-brand-blue focus:ring-offset-brand-surface\"\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t<label\n\t\t\t\t\t\t\t\t\tfor=\"main-create-remote\"\n\t\t\t\t\t\t\t\t\tclass=\"cursor-pointer text-sm text-brand-text select-none\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\tCreate remote {pathStatus.matchingRule.provider} repository\n\t\t\t\t\t\t\t\t</label>\n\t\t\t\t\t\t\t</div>\n\n\t\t\t\t\t\t\t{#if createRemoteRepo}\n\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\tclass=\"flex items-center gap-4 pl-6 text-xs text-brand-text-muted\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<span>Visibility:</span>\n\t\t\t\t\t\t\t\t\t<label\n\t\t\t\t\t\t\t\t\t\tclass=\"flex cursor-pointer items-center gap-1.5 transition-colors select-none hover:text-brand-text\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\t\t\t\ttype=\"radio\"\n\t\t\t\t\t\t\t\t\t\t\tname=\"main-visibility\"\n\t\t\t\t\t\t\t\t\t\t\tvalue=\"private\"\n\t\t\t\t\t\t\t\t\t\t\tbind:group={repoVisibility}\n\t\t\t\t\t\t\t\t\t\t\tclass=\"border-brand-border bg-brand-surface-3 text-brand-blue focus:ring-brand-blue\"\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\tPrivate\n\t\t\t\t\t\t\t\t\t</label>\n\t\t\t\t\t\t\t\t\t<label\n\t\t\t\t\t\t\t\t\t\tclass=\"flex cursor-pointer items-center gap-1.5 transition-colors select-none hover:text-brand-text\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\t\t\t\ttype=\"radio\"\n\t\t\t\t\t\t\t\t\t\t\tname=\"main-visibility\"\n\t\t\t\t\t\t\t\t\t\t\tvalue=\"public\"\n\t\t\t\t\t\t\t\t\t\t\tbind:group={repoVisibility}\n\t\t\t\t\t\t\t\t\t\t\tclass=\"border-brand-border bg-brand-surface-3 text-brand-blue focus:ring-brand-blue\"\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\tPublic\n\t\t\t\t\t\t\t\t\t</label>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t{/if}\n\n\t\t\t\t\t{#if pathStatus.exists !== true && (!pathStatus.matchingRule || !createRemoteRepo)}\n\t\t\t\t\t\t<div class=\"flex items-center gap-2 pt-1\">\n\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\tid=\"main-git-init\"\n\t\t\t\t\t\t\t\ttype=\"checkbox\"\n\t\t\t\t\t\t\t\tbind:checked={newFolderGitInit}\n\t\t\t\t\t\t\t\tonchange={(e) => {\n\t\t\t\t\t\t\t\t\tuserManualGitInit = e.currentTarget.checked;\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\tclass=\"h-4 w-4 rounded border-brand-border bg-brand-surface-3 text-brand-blue focus:ring-brand-blue focus:ring-offset-brand-surface\"\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<label\n\t\t\t\t\t\t\t\tfor=\"main-git-init\"\n\t\t\t\t\t\t\t\tclass=\"cursor-pointer text-sm text-brand-text select-none\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\tInitialize Git repository\n\t\t\t\t\t\t\t</label>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t{/if}\n\n\t\t\t\t\t<button\n\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\tdisabled={!newFolderCwd.trim() || checkingRemote}\n\t\t\t\t\t\tclass=\"w-full rounded bg-gradient-to-r from-brand-cyan to-brand-blue py-2.5 text-sm font-semibold text-brand-text transition-all hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-50\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{checkingRemote ? 'Checking remote...' : 'Create & Start Session'}\n\t\t\t\t\t</button>\n\t\t\t\t</form>\n\t\t\t</div>\n\t\t</div>\n\t{:else if msgList.length === 0}\n\t\t<div class=\"flex flex-1 items-center justify-center text-brand-text-muted\">\n\t\t\t<div class=\"text-center\">\n\t\t\t\t<div class=\"mb-4 text-4xl\">💬</div>\n\t\t\t\t<p class=\"mb-2 text-lg font-medium text-brand-text\">\n\t\t\t\t\tNew Session Started\n\t\t\t\t</p>\n\t\t\t\t<p class=\"text-sm\">Type a message below to start building</p>\n\t\t\t</div>\n\t\t</div>\n\t{:else}\n\t\t<div\n\t\t\tbind:this={messageList}\n\t\t\tclass=\"flex-1 space-y-4 overflow-y-auto overscroll-y-contain p-4\"\n\t\t>\n\t\t\t{#if moreHistory}\n\t\t\t\t<div class=\"flex justify-center pb-2\">\n\t\t\t\t\t<button\n\t\t\t\t\t\tonclick={handleLoadMore}\n\t\t\t\t\t\tdisabled={loadingMore}\n\t\t\t\t\t\tclass=\"rounded border border-brand-border bg-brand-surface-2 px-3 py-1.5 text-xs text-brand-text-muted transition-colors hover:bg-brand-surface-3 hover:text-brand-text disabled:cursor-not-allowed disabled:opacity-50\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{#if loadingMore}\n\t\t\t\t\t\t\tLoading older messages...\n\t\t\t\t\t\t{:else}\n\t\t\t\t\t\t\tLoad older messages\n\t\t\t\t\t\t{/if}\n\t\t\t\t\t</button>\n\t\t\t\t</div>\n\t\t\t{/if}\n\t\t\t{#each msgList as msg (msg.id)}\n\t\t\t\t<div\n\t\t\t\t\tdata-msg-id={msg.id}\n\t\t\t\t\tclass=\"flex {msg.role === 'user' ? 'justify-end' : 'justify-start'}\"\n\t\t\t\t>\n\t\t\t\t\t<div\n\t\t\t\t\t\tclass=\"max-w-[85%] rounded-lg px-4 py-3 {msg.role === 'user'\n\t\t\t\t\t\t\t? 'bg-brand-blue/80 text-brand-text'\n\t\t\t\t\t\t\t: msg.role === 'thinking'\n\t\t\t\t\t\t\t\t? 'border-l-2 border-brand-border bg-brand-surface/30 text-sm text-brand-text-muted'\n\t\t\t\t\t\t\t\t: msg.role === 'tool' && msg.toolName === 'attach_file'\n\t\t\t\t\t\t\t\t\t? 'bg-transparent p-0 text-brand-text'\n\t\t\t\t\t\t\t\t\t: msg.role === 'tool'\n\t\t\t\t\t\t\t\t\t\t? $piState.hideTools && !isAssociatedWithForceCommand(msg)\n\t\t\t\t\t\t\t\t\t\t\t? 'border-l-2 border-brand-border bg-brand-surface/30 text-sm text-brand-text-muted'\n\t\t\t\t\t\t\t\t\t\t\t: `border-l-2 bg-brand-surface-2 font-mono text-sm text-brand-text ${\n\t\t\t\t\t\t\t\t\t\t\t\t\tmsg.isStreaming\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t? 'border-amber-400'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t: msg.isError\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t? 'border-rose-400'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t: msg.interrupted\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t? 'border-brand-border'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t: 'border-emerald-400'\n\t\t\t\t\t\t\t\t\t\t\t\t}`\n\t\t\t\t\t\t\t\t\t\t: msg.role === 'assistant'\n\t\t\t\t\t\t\t\t\t\t\t? 'border-l-2 border-brand-purple bg-brand-purple/10 text-brand-text'\n\t\t\t\t\t\t\t\t\t\t\t: msg.content === '' && msg.isStreaming\n\t\t\t\t\t\t\t\t\t\t\t\t? 'bg-brand-surface-3 text-brand-text-muted italic'\n\t\t\t\t\t\t\t\t\t\t\t\t: 'bg-brand-surface-2 text-brand-text'}\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{#if msg.role === 'thinking'}\n\t\t\t\t\t\t\t{#if msg.content === 'FALLBACK_THINKING_LOADER'}\n\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\tclass=\"flex items-center gap-2 font-sans text-sm text-brand-text-muted italic select-none\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<svg\n\t\t\t\t\t\t\t\t\t\tclass=\"h-4 w-4 animate-spin text-brand-cyan\"\n\t\t\t\t\t\t\t\t\t\txmlns=\"http://www.w3.org/2000/svg\"\n\t\t\t\t\t\t\t\t\t\tfill=\"none\"\n\t\t\t\t\t\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t<circle\n\t\t\t\t\t\t\t\t\t\t\tclass=\"opacity-25\"\n\t\t\t\t\t\t\t\t\t\t\tcx=\"12\"\n\t\t\t\t\t\t\t\t\t\t\tcy=\"12\"\n\t\t\t\t\t\t\t\t\t\t\tr=\"10\"\n\t\t\t\t\t\t\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\t\t\t\t\t\t\tstroke-width=\"4\"\n\t\t\t\t\t\t\t\t\t\t></circle>\n\t\t\t\t\t\t\t\t\t\t<path\n\t\t\t\t\t\t\t\t\t\t\tclass=\"opacity-75\"\n\t\t\t\t\t\t\t\t\t\t\tfill=\"currentColor\"\n\t\t\t\t\t\t\t\t\t\t\td=\"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z\"\n\t\t\t\t\t\t\t\t\t\t></path>\n\t\t\t\t\t\t\t\t\t</svg>\n\t\t\t\t\t\t\t\t\t<span>Agent is thinking...</span>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t{:else if msg.content === 'FALLBACK_LOADER'}\n\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\tclass=\"flex items-center gap-2 font-sans text-sm text-brand-text-muted italic select-none\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<svg\n\t\t\t\t\t\t\t\t\t\tclass=\"h-4 w-4 animate-spin text-brand-cyan\"\n\t\t\t\t\t\t\t\t\t\txmlns=\"http://www.w3.org/2000/svg\"\n\t\t\t\t\t\t\t\t\t\tfill=\"none\"\n\t\t\t\t\t\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t<circle\n\t\t\t\t\t\t\t\t\t\t\tclass=\"opacity-25\"\n\t\t\t\t\t\t\t\t\t\t\tcx=\"12\"\n\t\t\t\t\t\t\t\t\t\t\tcy=\"12\"\n\t\t\t\t\t\t\t\t\t\t\tr=\"10\"\n\t\t\t\t\t\t\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\t\t\t\t\t\t\tstroke-width=\"4\"\n\t\t\t\t\t\t\t\t\t\t></circle>\n\t\t\t\t\t\t\t\t\t\t<path\n\t\t\t\t\t\t\t\t\t\t\tclass=\"opacity-75\"\n\t\t\t\t\t\t\t\t\t\t\tfill=\"currentColor\"\n\t\t\t\t\t\t\t\t\t\t\td=\"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z\"\n\t\t\t\t\t\t\t\t\t\t></path>\n\t\t\t\t\t\t\t\t\t</svg>\n\t\t\t\t\t\t\t\t\t<span>Agent working...</span>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t{:else if $piState.hideThinking}\n\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\tclass=\"flex items-center gap-2 font-sans text-sm text-brand-text-muted italic select-none\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<svg\n\t\t\t\t\t\t\t\t\t\tclass=\"h-4 w-4 animate-spin text-brand-cyan\"\n\t\t\t\t\t\t\t\t\t\txmlns=\"http://www.w3.org/2000/svg\"\n\t\t\t\t\t\t\t\t\t\tfill=\"none\"\n\t\t\t\t\t\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t<circle\n\t\t\t\t\t\t\t\t\t\t\tclass=\"opacity-25\"\n\t\t\t\t\t\t\t\t\t\t\tcx=\"12\"\n\t\t\t\t\t\t\t\t\t\t\tcy=\"12\"\n\t\t\t\t\t\t\t\t\t\t\tr=\"10\"\n\t\t\t\t\t\t\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\t\t\t\t\t\t\tstroke-width=\"4\"\n\t\t\t\t\t\t\t\t\t\t></circle>\n\t\t\t\t\t\t\t\t\t\t<path\n\t\t\t\t\t\t\t\t\t\t\tclass=\"opacity-75\"\n\t\t\t\t\t\t\t\t\t\t\tfill=\"currentColor\"\n\t\t\t\t\t\t\t\t\t\t\td=\"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z\"\n\t\t\t\t\t\t\t\t\t\t></path>\n\t\t\t\t\t\t\t\t\t</svg>\n\t\t\t\t\t\t\t\t\t<span>Agent is thinking...</span>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t{:else}\n\t\t\t\t\t\t\t\t<div class=\"flex flex-col gap-1\">\n\t\t\t\t\t\t\t\t\t{#if msg.isStreaming}\n\t\t\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\t\t\tclass=\"mb-1 flex items-center gap-1.5 text-[10px] font-bold tracking-wider text-brand-cyan uppercase select-none\"\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\t\t\t\tclass=\"inline-block h-1.5 w-1.5 animate-pulse rounded-full bg-brand-cyan\"\n\t\t\t\t\t\t\t\t\t\t\t></span>\n\t\t\t\t\t\t\t\t\t\t\t<span>Thinking</span>\n\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t\t\t\t<div class=\"font-mono text-sm whitespace-pre-wrap\">\n\t\t\t\t\t\t\t\t\t\t{msg.content}\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t{:else if msg.role === 'tool'}\n\t\t\t\t\t\t\t{#if $piState.hideTools && msg.toolName !== 'attach_file' && !isAssociatedWithForceCommand(msg)}\n\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\tclass=\"flex items-center gap-2 font-sans text-sm text-brand-text-muted italic select-none\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<svg\n\t\t\t\t\t\t\t\t\t\tclass=\"h-4 w-4 animate-spin text-amber-500\"\n\t\t\t\t\t\t\t\t\t\txmlns=\"http://www.w3.org/2000/svg\"\n\t\t\t\t\t\t\t\t\t\tfill=\"none\"\n\t\t\t\t\t\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t<circle\n\t\t\t\t\t\t\t\t\t\t\tclass=\"opacity-25\"\n\t\t\t\t\t\t\t\t\t\t\tcx=\"12\"\n\t\t\t\t\t\t\t\t\t\t\tcy=\"12\"\n\t\t\t\t\t\t\t\t\t\t\tr=\"10\"\n\t\t\t\t\t\t\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\t\t\t\t\t\t\tstroke-width=\"4\"\n\t\t\t\t\t\t\t\t\t\t></circle>\n\t\t\t\t\t\t\t\t\t\t<path\n\t\t\t\t\t\t\t\t\t\t\tclass=\"opacity-75\"\n\t\t\t\t\t\t\t\t\t\t\tfill=\"currentColor\"\n\t\t\t\t\t\t\t\t\t\t\td=\"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z\"\n\t\t\t\t\t\t\t\t\t\t></path>\n\t\t\t\t\t\t\t\t\t</svg>\n\t\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\t\t>Running tool: <span\n\t\t\t\t\t\t\t\t\t\t\tclass=\"rounded bg-brand-surface-3 px-1 py-0.5 font-mono text-xs font-semibold\"\n\t\t\t\t\t\t\t\t\t\t\t>{msg.toolName || 'agent'}</span\n\t\t\t\t\t\t\t\t\t\t>...</span\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{#if toolDuration(msg)}\n\t\t\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\t\t\tclass=\"font-mono text-xs text-brand-text-muted tabular-nums\"\n\t\t\t\t\t\t\t\t\t\t\t>{toolDuration(msg)}</span\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t{:else}\n\t\t\t\t\t\t\t\t{@const parsed = parseToolMessage(msg)}\n\t\t\t\t\t\t\t\t{@const isExpanded =\n\t\t\t\t\t\t\t\t\texpandedMessages[msg.id] !== undefined\n\t\t\t\t\t\t\t\t\t\t? expandedMessages[msg.id]\n\t\t\t\t\t\t\t\t\t\t: shouldAutoExpand(msg, msgList)}\n\t\t\t\t\t\t\t\t{@const dlPath = parsed.downloadPath}\n\t\t\t\t\t\t\t\t{@const dlUrl = dlPath ? downloadFileUrl(dlPath) : null}\n\t\t\t\t\t\t\t\t{@const isAttachTool = parsed.toolName === 'attach_file'}\n\t\t\t\t\t\t\t\t{#if isAttachTool}\n\t\t\t\t\t\t\t\t\t<!-- attach_file rendered as a first-class ATTACHMENT, not a\n\t\t\t\t\t\t\t\t\t generic tool card: the agent explicitly offered this file\n\t\t\t\t\t\t\t\t\t for the (remote) user to download. Three states: streaming\n\t\t\t\t\t\t\t\t\t (attaching...), error (could not attach), success (download\n\t\t\t\t\t\t\t\t\t link). A failed attach shows the tool's error text so the\n\t\t\t\t\t\t\t\t\t agent/user can see WHY (e.g. file not found). -->\n\t\t\t\t\t\t\t\t\t{@const fileName = dlPath\n\t\t\t\t\t\t\t\t\t\t? dlPath.split('/').pop() || dlPath\n\t\t\t\t\t\t\t\t\t\t: ''}\n\t\t\t\t\t\t\t\t\t<div class=\"flex max-w-full min-w-[240px] flex-col\">\n\t\t\t\t\t\t\t\t\t\t{#if msg.isStreaming}\n\t\t\t\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\t\t\t\tclass=\"flex items-center gap-3 rounded-lg border border-brand-border bg-brand-surface-2 px-3 py-2.5 text-brand-text-muted\"\n\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t<span class=\"animate-pulse text-2xl leading-none\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t>📎</span\n\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t<span class=\"truncate text-sm\">Attaching file…</span>\n\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t{:else if parsed.isError}\n\t\t\t\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\t\t\t\tclass=\"flex items-start gap-3 rounded-lg border border-rose-400/40 bg-rose-400/10 px-3 py-2.5 text-brand-text\"\n\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t<span class=\"text-2xl leading-none\">📎</span>\n\t\t\t\t\t\t\t\t\t\t\t\t<span class=\"flex min-w-0 flex-1 flex-col gap-0.5\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t<span class=\"text-sm font-semibold text-rose-300\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t>Could not attach file</span\n\t\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t\t{#if parsed.toolOutput}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tclass=\"text-xs break-words text-brand-text-muted\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t>{parsed.toolOutput}</span\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t{:else if dlUrl}\n\t\t\t\t\t\t\t\t\t\t\t<a\n\t\t\t\t\t\t\t\t\t\t\t\thref={dlUrl}\n\t\t\t\t\t\t\t\t\t\t\t\tdownload={fileName}\n\t\t\t\t\t\t\t\t\t\t\t\tclass=\"flex items-center gap-3 rounded-lg border border-brand-cyan/40 bg-brand-cyan/10 px-3 py-2.5 text-brand-text no-underline transition-colors hover:bg-brand-cyan/20\"\n\t\t\t\t\t\t\t\t\t\t\t\ttitle={`Download ${dlPath}`}\n\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t<span class=\"text-2xl leading-none\">📎</span>\n\t\t\t\t\t\t\t\t\t\t\t\t<span class=\"flex min-w-0 flex-1 flex-col\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t<span class=\"truncate text-sm font-semibold\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t>{fileName}</span\n\t\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tclass=\"truncate text-xs text-brand-text-muted\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\ttitle={dlPath}>{dlPath}</span\n\t\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\t\t\t\t\tclass=\"flex shrink-0 items-center gap-1 rounded-md bg-brand-cyan/20 px-2.5 py-1 text-xs font-medium text-brand-cyan\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t>⬇️ Download</span\n\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t\t\t\t\t{:else}\n\t\t\t\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\t\t\t\tclass=\"flex items-center gap-3 rounded-lg border border-brand-border bg-brand-surface-2 px-3 py-2.5 text-brand-text-muted\"\n\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t<span class=\"text-2xl leading-none\">📎</span>\n\t\t\t\t\t\t\t\t\t\t\t\t<span class=\"flex min-w-0 flex-1 flex-col\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t<span class=\"truncate text-sm font-semibold\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t>{fileName}</span\n\t\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t\t<span class=\"truncate text-xs\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t>No active session to download from</span\n\t\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t{:else}\n\t\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\t\tclass=\"flex max-w-full min-w-[280px] flex-col sm:min-w-[400px] md:min-w-[550px]\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t<!-- Header of tool execution. The collapse toggle (button) and an\n\t\t\t\t\t\t\t\t\t optional download link (anchor) are SIBLINGS in a flex row so\n\t\t\t\t\t\t\t\t\t the anchor is never nested inside the button. -->\n\t\t\t\t\t\t\t\t\t\t<div class=\"flex w-full items-center gap-1\">\n\t\t\t\t\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\t\t\t\t\tonclick={() => toggleMessage(msg.id, isExpanded)}\n\t\t\t\t\t\t\t\t\t\t\t\tclass=\"flex min-w-0 flex-1 items-center justify-between gap-3 rounded p-1 text-left transition-colors hover:bg-brand-surface-3/30 focus:outline-none\"\n\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\t\t\t\t\tclass=\"flex flex-1 items-center gap-2 overflow-hidden\"\n\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t\t<!-- Status icon -->\n\t\t\t\t\t\t\t\t\t\t\t\t\t{#if msg.isStreaming}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<!-- Running -->\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tclass=\"inline-block animate-spin font-bold text-amber-400\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t>⚡</span\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t\t{:else if parsed.isError}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<!-- Error -->\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<span class=\"font-bold text-rose-400\" title=\"Failed\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t>❌</span\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t\t{:else if parsed.interrupted}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<!-- Interrupted: no result (e.g. a CLI took over and the\n\t\t\t\t\t\t\t\t\t\t\t\t running tool was killed). Outcome unknown: neither\n\t\t\t\t\t\t\t\t\t\t\t\t success nor failure. -->\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tclass=\"font-bold text-brand-text-muted\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\ttitle=\"Interrupted, no result (the running tool was stopped, e.g. by a CLI takeover)\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t>⊘</span\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t\t{:else}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<!-- Success -->\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tclass=\"font-bold text-emerald-400\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\ttitle=\"Succeeded\">✅</span\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t\t{/if}\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tclass=\"font-mono text-sm font-bold text-brand-text\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{parsed.toolName}\n\t\t\t\t\t\t\t\t\t\t\t\t\t</span>\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t{#if parsed.smartTitleArgs}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tclass=\"max-w-[180px] truncate font-mono text-xs text-brand-text-muted sm:max-w-[300px] md:max-w-[450px]\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\ttitle={parsed.smartTitleArgs}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t{parsed.smartTitleArgs}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t\t\t\t\t{/if}\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t{#if toolDuration(msg)}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tclass=\"shrink-0 font-mono text-xs tabular-nums {msg.isStreaming\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t? 'text-amber-400'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t: 'text-brand-text-muted'}\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\ttitle={msg.isStreaming\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t? 'Elapsed time'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t: 'Time taken'}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t{msg.isStreaming ? 'Elapsed' : 'Took'}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t{toolDuration(msg)}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t\t\t\t\t\t\t</div>\n\n\t\t\t\t\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\t\t\t\t\tclass=\"flex shrink-0 items-center gap-1 font-sans text-xs font-medium whitespace-nowrap text-brand-text-muted select-none hover:text-brand-text\"\n\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t\t{#if isExpanded}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tCollapse <span class=\"text-[10px]\">▲</span>\n\t\t\t\t\t\t\t\t\t\t\t\t\t{:else}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tExpand <span class=\"text-[10px]\">▼</span>\n\t\t\t\t\t\t\t\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t\t</button>\n\n\t\t\t\t\t\t\t\t\t\t\t{#if dlPath}\n\t\t\t\t\t\t\t\t\t\t\t\t{#if dlUrl}\n\t\t\t\t\t\t\t\t\t\t\t\t\t<a\n\t\t\t\t\t\t\t\t\t\t\t\t\t\thref={dlUrl}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tdownload={dlPath.split('/').pop() || ''}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tclass=\"flex shrink-0 items-center gap-1 rounded px-1.5 py-1 text-xs text-brand-cyan transition-colors hover:bg-brand-cyan/15\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\ttitle={`Download ${dlPath}`}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\taria-label={`Download ${dlPath}`}\n\t\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<span class=\"text-sm\">⬇️</span>\n\t\t\t\t\t\t\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t\t\t\t\t\t\t{:else}\n\t\t\t\t\t\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tclass=\"shrink-0 px-1.5 py-1 text-xs text-brand-text-muted opacity-40\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\ttitle=\"No active session to download from\">⬇️</span\n\t\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t\t\t\t\t</div>\n\n\t\t\t\t\t\t\t\t\t\t<!-- Tool image attachments (e.g. read on an image file).\n\t\t\t\t\t\t\t\t\t Rendered OUTSIDE the collapsible section so images stay\n\t\t\t\t\t\t\t\t\t visible even when the tool details are collapsed; the\n\t\t\t\t\t\t\t\t\t args/output below remain collapsible. -->\n\t\t\t\t\t\t\t\t\t\t{#if msg.images && msg.images.length > 0}\n\t\t\t\t\t\t\t\t\t\t\t<div class=\"mt-2 flex flex-col gap-1\">\n\t\t\t\t\t\t\t\t\t\t\t\t<div class=\"flex flex-wrap gap-2\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t{#each msg.images as img}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<a\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\thref={`data:${img.mimeType};base64,${img.data}`}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\ttarget=\"_blank\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\trel=\"noopener noreferrer\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tclass=\"block\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tsrc={`data:${img.mimeType};base64,${img.data}`}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\talt=\"Tool output\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tclass=\"max-h-96 max-w-full rounded border border-brand-border/40 bg-brand-dark/60 object-contain\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t\t\t\t\t\t\t\t{/each}\n\t\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t{/if}\n\n\t\t\t\t\t\t\t\t\t\t<!-- Tool Output (collapsible) -->\n\t\t\t\t\t\t\t\t\t\t{#if isExpanded}\n\t\t\t\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\t\t\t\tclass=\"mt-2 flex flex-col gap-3 overflow-hidden border-t border-brand-border/40 pt-2\"\n\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t<!-- Full Arguments section -->\n\t\t\t\t\t\t\t\t\t\t\t\t{#if parsed.fullArgs && parsed.fullArgs !== '{}'}\n\t\t\t\t\t\t\t\t\t\t\t\t\t<div class=\"flex flex-col gap-1\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tclass=\"font-sans text-[10px] font-bold tracking-wider text-brand-text-muted uppercase\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t>Arguments</span\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<pre\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tclass=\"max-h-40 overflow-x-auto rounded border border-brand-border/30 bg-brand-dark/60 p-1.5 font-mono text-[11px] whitespace-pre-wrap text-amber-400\">{parsed.fullArgs}</pre>\n\t\t\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t\t\t{/if}\n\n\t\t\t\t\t\t\t\t\t\t\t\t<!-- Tool Output section -->\n\t\t\t\t\t\t\t\t\t\t\t\t<div class=\"flex flex-col gap-1\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tclass=\"font-sans text-[10px] font-bold tracking-wider text-brand-text-muted uppercase\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t>Output</span\n\t\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t\t{#if parsed.toolOutput}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<pre\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tclass=\"max-h-96 overflow-x-auto rounded border border-brand-border/40 bg-brand-dark/60 p-2 font-mono text-xs whitespace-pre-wrap text-brand-text\">{parsed.toolOutput}</pre>\n\t\t\t\t\t\t\t\t\t\t\t\t\t{:else if msg.isStreaming}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tclass=\"animate-pulse p-1 text-xs text-brand-text-muted italic\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tRunning and waiting for output...\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t\t\t\t{:else if parsed.interrupted}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tclass=\"p-1 text-xs text-brand-text-muted italic\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tInterrupted before a result was returned (the\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\trunning tool was stopped, e.g. by a CLI takeover).\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tIts outcome is unknown.\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t\t\t\t{:else}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tclass=\"p-1 text-xs text-brand-text-muted italic\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tNo output returned\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t{:else if msg.role === 'assistant' && msg.content !== ''}\n\t\t\t\t\t\t\t{#if msg.isStreaming}\n\t\t\t\t\t\t\t\t<!-- While streaming, render plain text. Re-parsing markdown on\n\t\t\t\t\t\t\t\t every token would rebuild the DOM and collapse any active\n\t\t\t\t\t\t\t\t selection; the finalized branch renders once and stays stable. -->\n\t\t\t\t\t\t\t\t<pre\n\t\t\t\t\t\t\t\t\tclass=\"chat-selectable font-sans text-sm leading-relaxed whitespace-pre-wrap\">{msg.content}<span\n\t\t\t\t\t\t\t\t\t\tclass=\"ml-0.5 inline-block h-4 w-1.5 animate-pulse bg-brand-cyan align-text-bottom\"\n\t\t\t\t\t\t\t\t\t></span></pre>\n\t\t\t\t\t\t\t{:else}\n\t\t\t\t\t\t\t\t<!-- eslint-disable-next-line svelte/no-at-html-tags -- output sanitized via DOMPurify in renderMarkdown -->\n\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\tclass=\"chat-selectable markdown-body text-sm leading-relaxed\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{@html renderAssistant(msg.id, msg.content)}\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t{:else}\n\t\t\t\t\t\t\t{@const parsedUserMsg = parseUserMessage(msg.content)}\n\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\tclass=\"chat-selectable text-sm leading-relaxed whitespace-pre-wrap\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{#if parsedUserMsg.cleanContent}\n\t\t\t\t\t\t\t\t\t{@const userHtml = renderUser(parsedUserMsg.cleanContent)}\n\t\t\t\t\t\t\t\t\t{#if userHtml}\n\t\t\t\t\t\t\t\t\t\t<!-- eslint-disable-next-line svelte/no-at-html-tags -- sanitized via DOMPurify in linkifyText -->\n\t\t\t\t\t\t\t\t\t\t<span>{@html userHtml}</span>\n\t\t\t\t\t\t\t\t\t{:else}\n\t\t\t\t\t\t\t\t\t\t{parsedUserMsg.cleanContent}\n\t\t\t\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t\t\t{:else if parsedUserMsg.attachments.length > 0}\n\t\t\t\t\t\t\t\t\t<span class=\"text-brand-text-muted italic\"\n\t\t\t\t\t\t\t\t\t\t>Shared file{parsedUserMsg.attachments.length > 1\n\t\t\t\t\t\t\t\t\t\t\t? 's'\n\t\t\t\t\t\t\t\t\t\t\t: ''} with agent:</span\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{:else}\n\t\t\t\t\t\t\t\t\t{msg.content || (msg.isStreaming ? 'Thinking...' : '')}\n\t\t\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t\t\t{#if msg.isStreaming && streaming}\n\t\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\t\tclass=\"ml-1 inline-block h-4 w-1.5 animate-pulse bg-brand-cyan\"\n\t\t\t\t\t\t\t\t\t></span>\n\t\t\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t{#if parsedUserMsg.attachments.length > 0}\n\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\tclass=\"mt-2 flex flex-col gap-1 border-t border-brand-blue/20 pt-2\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{#each parsedUserMsg.attachments as filePath}\n\t\t\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\t\t\tclass=\"flex items-center gap-1.5 rounded bg-brand-blue/20 px-2 py-1 font-mono text-xs text-brand-text select-all\"\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t<span>📎</span>\n\t\t\t\t\t\t\t\t\t\t\t<span class=\"truncate\" title={filePath}>{filePath}</span>\n\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t{/each}\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t{#if msg.role !== 'thinking' && msg.role !== 'tool'}\n\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\tclass=\"mt-1 flex items-center gap-1.5 text-xs opacity-50 {msg.role ===\n\t\t\t\t\t\t\t\t'user'\n\t\t\t\t\t\t\t\t\t? 'justify-end text-brand-text-muted'\n\t\t\t\t\t\t\t\t\t: msg.role === 'assistant'\n\t\t\t\t\t\t\t\t\t\t? 'text-brand-purple'\n\t\t\t\t\t\t\t\t\t\t: 'text-brand-text-muted'}\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{#if msg.role === 'user' && msg.delivery === 'sending'}\n\t\t\t\t\t\t\t\t\t<span title=\"Sending, awaiting confirmation\">Sending...</span>\n\t\t\t\t\t\t\t\t\t<span>·</span>\n\t\t\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t\t\t{formatTime(msg.timestamp)}\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t{#if msg.role === 'user' && msg.delivery === 'failed'}\n\t\t\t\t\t\t\t\t<!-- Delivery could NOT be confirmed (a half-open socket may have\n\t\t\t\t\t\t\t\t swallowed the frame). Never silently drop it: offer retry /\n\t\t\t\t\t\t\t\t discard so the user's text is recoverable. -->\n\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\tclass=\"mt-1.5 flex flex-wrap items-center justify-end gap-2 text-xs\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<span class=\"font-medium text-amber-400\"\n\t\t\t\t\t\t\t\t\t\t>⚠️ Not delivered</span\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\t\t\tonclick={() => resendMessage(msg.id)}\n\t\t\t\t\t\t\t\t\t\tclass=\"rounded bg-brand-blue/80 px-2 py-0.5 font-medium text-brand-text transition-colors hover:bg-brand-blue\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\tRetry\n\t\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\t\t\tonclick={() => discardMessage(msg.id)}\n\t\t\t\t\t\t\t\t\t\tclass=\"rounded bg-brand-surface-3 px-2 py-0.5 font-medium text-brand-text-muted transition-colors hover:text-brand-text\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\tDiscard\n\t\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t{/if}\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t{/each}\n\t\t</div>\n\t{/if}\n\n\t<div\n\t\tclass=\"app-chrome flex flex-wrap items-center justify-between gap-x-4 gap-y-2 border-t border-brand-border p-2\"\n\t>\n\t\t<div class=\"flex flex-wrap items-center gap-x-4 gap-y-2\">\n\t\t\t<label\n\t\t\t\tclass=\"flex cursor-pointer items-center gap-1.5 text-xs text-brand-text-muted select-none hover:text-brand-text\"\n\t\t\t>\n\t\t\t\t<input\n\t\t\t\t\ttype=\"checkbox\"\n\t\t\t\t\tchecked={$piState.hideThinking}\n\t\t\t\t\tonchange={(e) =>\n\t\t\t\t\t\tupdateConfig({\n\t\t\t\t\t\t\thideThinking: (e.currentTarget as HTMLInputElement).checked,\n\t\t\t\t\t\t})}\n\t\t\t\t\tclass=\"h-3.5 w-3.5 rounded border-brand-border bg-brand-surface-3 text-brand-blue focus:ring-brand-blue\"\n\t\t\t\t/>\n\t\t\t\tHide Thinking\n\t\t\t</label>\n\n\t\t\t<!-- Per-session waiting-for-human beep, tri-state. Cycles\n\t\t\t Default -> On -> Off -> Default. \"Default\" means this session has no\n\t\t\t explicit choice and follows the global default live; On/Off stick to\n\t\t\t this session regardless of later default changes. Only for a live,\n\t\t\t drivable session. -->\n\t\t\t{#if sessionInfo.sessionFile && !$isReadOnly}\n\t\t\t\t<button\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t\tonclick={cycleBeep}\n\t\t\t\t\tclass=\"flex items-center gap-1.5 rounded px-1.5 py-0.5 text-xs select-none hover:text-brand-text {beepOverride ===\n\t\t\t\t\tundefined\n\t\t\t\t\t\t? 'text-brand-text-muted'\n\t\t\t\t\t\t: 'text-brand-blue'}\"\n\t\t\t\t\ttitle={beepOverride === undefined\n\t\t\t\t\t\t? `Beep when the agent is waiting: following the default (${beepOn ? 'on' : 'off'}). Click to set On for this session.`\n\t\t\t\t\t\t: beepOverride === true\n\t\t\t\t\t\t\t? 'Beep when the agent is waiting: ON for this session. Click to set Off.'\n\t\t\t\t\t\t\t: 'Beep when the agent is waiting: OFF for this session. Click to follow the default.'}\n\t\t\t\t\taria-label=\"Cycle waiting-for-human beep for this session\"\n\t\t\t\t>\n\t\t\t\t\t<span>{beepOn ? '🔔' : '🔕'}</span>\n\t\t\t\t\t<span>\n\t\t\t\t\t\t{beepOverride === undefined\n\t\t\t\t\t\t\t? `Beep: Default (${beepOn ? 'on' : 'off'})`\n\t\t\t\t\t\t\t: beepOverride\n\t\t\t\t\t\t\t\t? 'Beep: On'\n\t\t\t\t\t\t\t\t: 'Beep: Off'}\n\t\t\t\t\t</span>\n\t\t\t\t</button>\n\t\t\t{/if}\n\n\t\t\t<!-- Context-window usage, e.g. \"11.3% / 1.0M\" -->\n\t\t\t{#if contextLabel}\n\t\t\t\t<div\n\t\t\t\t\tclass=\"flex items-center gap-1 text-xs text-brand-text-muted\"\n\t\t\t\t\ttitle={$piState.contextUsage?.tokens != null\n\t\t\t\t\t\t? `${$piState.contextUsage.tokens.toLocaleString()} context tokens of ${$piState.contextUsage.contextWindow.toLocaleString()}`\n\t\t\t\t\t\t: 'Context window size'}\n\t\t\t\t>\n\t\t\t\t\t<span class=\"flex-shrink-0\">🧠</span>\n\t\t\t\t\t<span class=\"whitespace-nowrap tabular-nums\">{contextLabel}</span>\n\t\t\t\t</div>\n\t\t\t{/if}\n\t\t</div>\n\t\t<button\n\t\t\tonclick={abort}\n\t\t\tdisabled={!streaming}\n\t\t\tclass=\"rounded bg-rose-500 px-3 py-1.5 text-xs text-brand-text transition-colors hover:bg-rose-600 disabled:cursor-not-allowed disabled:opacity-50\"\n\t\t\ttitle=\"Abort\"\n\t\t>\n\t\t\tAbort\n\t\t</button>\n\t</div>\n\n\t<!-- Custom Confirm Modal for Existing Folders -->\n\t{#if showGitInitConfirmModal}\n\t\t<div\n\t\t\tclass=\"fixed inset-0 z-50 flex items-center justify-center bg-brand-dark/65 p-4\"\n\t\t\trole=\"dialog\"\n\t\t\taria-modal=\"true\"\n\t\t>\n\t\t\t<div\n\t\t\t\tclass=\"w-full max-w-sm rounded-lg border border-brand-border bg-brand-surface-2 p-6 text-brand-text\"\n\t\t\t>\n\t\t\t\t<h3 class=\"mb-2 text-base font-bold text-brand-text\">\n\t\t\t\t\tFolder Already Exists\n\t\t\t\t</h3>\n\t\t\t\t<p class=\"mb-4 text-sm text-brand-text-muted\">\n\t\t\t\t\tThe folder <span class=\"font-mono text-xs text-brand-text\"\n\t\t\t\t\t\t>{newFolderCwd}</span\n\t\t\t\t\t> already exists. Do you want to initialize a Git repository in it?\n\t\t\t\t</p>\n\n\t\t\t\t<div class=\"mb-6 flex flex-col gap-3.5\">\n\t\t\t\t\t<div class=\"flex items-center gap-2\">\n\t\t\t\t\t\t<input\n\t\t\t\t\t\t\tid=\"modal-git-init\"\n\t\t\t\t\t\t\ttype=\"checkbox\"\n\t\t\t\t\t\t\tbind:checked={newFolderGitInit}\n\t\t\t\t\t\t\tdisabled={pathStatus.isGit}\n\t\t\t\t\t\t\tclass=\"h-4 w-4 rounded border-brand-border bg-brand-surface-3 text-brand-blue focus:ring-brand-blue disabled:opacity-50\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<label\n\t\t\t\t\t\t\tfor=\"modal-git-init\"\n\t\t\t\t\t\t\tclass=\"cursor-pointer text-sm text-brand-text select-none disabled:opacity-50\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\tInitialize Git repository\n\t\t\t\t\t\t\t{#if pathStatus.isGit}\n\t\t\t\t\t\t\t\t<span class=\"ml-1 text-xs text-brand-text-muted\"\n\t\t\t\t\t\t\t\t\t>(already a Git repository)</span\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{:else}\n\t\t\t\t\t\t\t\t<span class=\"ml-1 text-xs font-medium text-yellow-500\"\n\t\t\t\t\t\t\t\t\t>(folder not empty)</span\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t</label>\n\t\t\t\t\t</div>\n\n\t\t\t\t\t{#if pathStatus.matchingRule}\n\t\t\t\t\t\t<div class=\"space-y-1.5\">\n\t\t\t\t\t\t\t<div class=\"flex items-center gap-2\">\n\t\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\t\tid=\"modal-create-remote\"\n\t\t\t\t\t\t\t\t\ttype=\"checkbox\"\n\t\t\t\t\t\t\t\t\tbind:checked={createRemoteRepo}\n\t\t\t\t\t\t\t\t\tclass=\"h-4 w-4 rounded border-brand-border bg-brand-surface-3 text-brand-blue focus:ring-brand-blue\"\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t<label\n\t\t\t\t\t\t\t\t\tfor=\"modal-create-remote\"\n\t\t\t\t\t\t\t\t\tclass=\"cursor-pointer text-sm text-brand-text select-none\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\tCreate remote {pathStatus.matchingRule.provider} repository\n\t\t\t\t\t\t\t\t</label>\n\t\t\t\t\t\t\t</div>\n\n\t\t\t\t\t\t\t{#if createRemoteRepo}\n\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\tclass=\"flex items-center gap-4 pl-6 text-xs text-brand-text-muted\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<span>Visibility:</span>\n\t\t\t\t\t\t\t\t\t<label\n\t\t\t\t\t\t\t\t\t\tclass=\"flex cursor-pointer items-center gap-1.5 transition-colors select-none hover:text-brand-text\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\t\t\t\ttype=\"radio\"\n\t\t\t\t\t\t\t\t\t\t\tname=\"modal-visibility\"\n\t\t\t\t\t\t\t\t\t\t\tvalue=\"private\"\n\t\t\t\t\t\t\t\t\t\t\tbind:group={repoVisibility}\n\t\t\t\t\t\t\t\t\t\t\tclass=\"border-brand-border bg-brand-surface-3 text-brand-blue focus:ring-brand-blue\"\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\tPrivate\n\t\t\t\t\t\t\t\t\t</label>\n\t\t\t\t\t\t\t\t\t<label\n\t\t\t\t\t\t\t\t\t\tclass=\"flex cursor-pointer items-center gap-1.5 transition-colors select-none hover:text-brand-text\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\t\t\t\ttype=\"radio\"\n\t\t\t\t\t\t\t\t\t\t\tname=\"modal-visibility\"\n\t\t\t\t\t\t\t\t\t\t\tvalue=\"public\"\n\t\t\t\t\t\t\t\t\t\t\tbind:group={repoVisibility}\n\t\t\t\t\t\t\t\t\t\t\tclass=\"border-brand-border bg-brand-surface-3 text-brand-blue focus:ring-brand-blue\"\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\tPublic\n\t\t\t\t\t\t\t\t\t</label>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t{/if}\n\t\t\t\t</div>\n\n\t\t\t\t<div class=\"flex justify-end gap-2.5\">\n\t\t\t\t\t<button\n\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\tonclick={() => (showGitInitConfirmModal = false)}\n\t\t\t\t\t\tclass=\"rounded bg-brand-surface-3 px-3.5 py-1.5 text-xs font-semibold text-brand-text transition-colors hover:bg-brand-surface-2\"\n\t\t\t\t\t>\n\t\t\t\t\t\tCancel\n\t\t\t\t\t</button>\n\t\t\t\t\t<button\n\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\tonclick={() => {\n\t\t\t\t\t\t\tshowGitInitConfirmModal = false;\n\t\t\t\t\t\t\tcreateSession(\n\t\t\t\t\t\t\t\tnewFolderCwd.trim(),\n\t\t\t\t\t\t\t\tnewFolderModel || undefined,\n\t\t\t\t\t\t\t\tnewFolderGitInit,\n\t\t\t\t\t\t\t\tpathStatus.matchingRule ? createRemoteRepo : undefined,\n\t\t\t\t\t\t\t\tpathStatus.matchingRule ? repoVisibility : undefined,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}}\n\t\t\t\t\t\tclass=\"rounded bg-gradient-to-r from-brand-cyan to-brand-blue px-3.5 py-1.5 text-xs font-semibold text-brand-text transition-all hover:opacity-90\"\n\t\t\t\t\t>\n\t\t\t\t\t\tConfirm & Create\n\t\t\t\t\t</button>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</div>\n\t{/if}\n\n\t<!-- Clone Existing Remote Repository -->\n\t{#if showCloneConfirmModal}\n\t\t<div\n\t\t\tclass=\"fixed inset-0 z-50 flex items-center justify-center bg-brand-dark/65 p-4\"\n\t\t\trole=\"dialog\"\n\t\t\taria-modal=\"true\"\n\t\t>\n\t\t\t<div\n\t\t\t\tclass=\"w-full max-w-sm rounded-lg border border-brand-border bg-brand-surface-2 p-6 text-brand-text\"\n\t\t\t>\n\t\t\t\t<h3 class=\"mb-2 text-base font-bold text-brand-text\">\n\t\t\t\t\tRemote Repository Already Exists\n\t\t\t\t</h3>\n\t\t\t\t<p class=\"mb-3 text-sm text-brand-text-muted\">\n\t\t\t\t\tA {cloneRemoteInfo?.provider ?? 'remote'} repository matching\n\t\t\t\t\t<span class=\"font-mono text-xs text-brand-text\">{newFolderCwd}</span>\n\t\t\t\t\talready exists. Do you want to clone it instead of creating a new one?\n\t\t\t\t</p>\n\t\t\t\t{#if cloneRemoteInfo?.sshUrl}\n\t\t\t\t\t<p\n\t\t\t\t\t\tclass=\"mb-4 rounded bg-brand-surface-3 px-2.5 py-1.5 font-mono text-xs break-all text-brand-text-muted\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{cloneRemoteInfo.sshUrl}\n\t\t\t\t\t</p>\n\t\t\t\t{/if}\n\n\t\t\t\t<div class=\"flex justify-end gap-2.5\">\n\t\t\t\t\t<button\n\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\tonclick={() => {\n\t\t\t\t\t\t\tshowCloneConfirmModal = false;\n\t\t\t\t\t\t\tcloneRemoteInfo = null;\n\t\t\t\t\t\t\tsubmitCreateSession(false);\n\t\t\t\t\t\t}}\n\t\t\t\t\t\tclass=\"rounded bg-brand-surface-3 px-3.5 py-1.5 text-xs font-semibold text-brand-text transition-colors hover:bg-brand-surface-2\"\n\t\t\t\t\t>\n\t\t\t\t\t\tCreate New Instead\n\t\t\t\t\t</button>\n\t\t\t\t\t<button\n\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\tonclick={() => {\n\t\t\t\t\t\t\tshowCloneConfirmModal = false;\n\t\t\t\t\t\t\tcloneRemoteInfo = null;\n\t\t\t\t\t\t\tsubmitCreateSession(true);\n\t\t\t\t\t\t}}\n\t\t\t\t\t\tclass=\"rounded bg-gradient-to-r from-brand-cyan to-brand-blue px-3.5 py-1.5 text-xs font-semibold text-brand-text transition-all hover:opacity-90\"\n\t\t\t\t\t>\n\t\t\t\t\t\tClone Repository\n\t\t\t\t\t</button>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</div>\n\t{/if}\n</div>\n","// Pure decision helper for what a composer submit should DO, extracted from\n// ChatInput.svelte so the behaviour is deterministically unit-testable (the\n// component itself is not exercised by the node-env vitest run).\n//\n// This encodes the pi-CLI default: a submit made WHILE the agent is streaming\n// STEERS immediately (the server turns a mid-stream `message` into a `steer`,\n// injected at the next tool/step boundary before the next LLM call). There is\n// NO local \"wait for the turn to finish\" queue and no isStreaming-driven\n// auto-drain: an explicit user submit is sent right away, exactly like pressing\n// Enter in the pi CLI (interactive-mode.ts calls\n// `session.prompt(text, { streamingBehavior: \"steer\" })`).\n//\n// `deliverAs` is carried on the `send` outcome so an explicit opt-in follow-up\n// (pi's Alt+Enter \"wait until the agent finishes\") can be added later WITHOUT\n// reworking this seam: the default submit is always `steer`.\n\nexport interface ComposeSendInput {\n\t/** The agent is mid-turn (a stream is active) on the server. */\n\tstreaming: boolean;\n\t/** There is a live relay connection (real socket, not a stale flag). */\n\tconnected: boolean;\n\t/** The session transcript is loaded but its live agent is still building. */\n\tagentPending: boolean;\n\t/** The session is observe-only; sending is not allowed. */\n\treadOnly: boolean;\n\t/** An active session is open to send into. */\n\thasSession: boolean;\n}\n\nexport type ComposeSendResult =\n\t| {\n\t\t\t/** Send now. `deliverAs` tells the intent for a mid-stream send. */\n\t\t\taction: 'send';\n\t\t\tdeliverAs: 'steer' | 'followUp';\n\t }\n\t| {\n\t\t\t/** Do not send; the composer should stay put and surface `reason`. */\n\t\t\taction: 'blocked';\n\t\t\treason: 'no-session' | 'read-only' | 'disconnected' | 'agent-pending';\n\t };\n\n/**\n * Decide the outcome of a composer submit.\n *\n * Key property (the whole point of this change): when the agent is streaming on\n * a live connection, the result is `{action:'send', deliverAs:'steer'}` -- an\n * IMMEDIATE send. It is never a \"queue and wait\" outcome. The only non-send\n * results are genuine block conditions (no session / read-only / disconnected /\n * agent still building), which keep the user's text intact instead of silently\n * swallowing it.\n *\n * @param opts.followUp opt-in to pi's \"wait until the agent finishes\"\n * (Alt+Enter) behaviour for THIS submit; defaults to steer.\n */\nexport function decideComposeSend(\n\tinput: ComposeSendInput,\n\topts?: {followUp?: boolean},\n): ComposeSendResult {\n\tif (!input.hasSession) return {action: 'blocked', reason: 'no-session'};\n\tif (input.readOnly) return {action: 'blocked', reason: 'read-only'};\n\tif (!input.connected) return {action: 'blocked', reason: 'disconnected'};\n\tif (input.agentPending) return {action: 'blocked', reason: 'agent-pending'};\n\n\t// Streaming or not, an explicit submit sends now. When streaming, the server\n\t// delivers it as steer (or followUp if the caller opted in); when idle, the\n\t// deliverAs field is irrelevant (the server sends it as a normal prompt).\n\treturn {\n\t\taction: 'send',\n\t\tdeliverAs: opts?.followUp ? 'followUp' : 'steer',\n\t};\n}\n","<script lang=\"ts\">\n\timport {onMount} from 'svelte';\n\n\tlet {\n\t\ttext = $bindable(),\n\t\tdisabled,\n\t\tonSend,\n\t}: {\n\t\ttext: string;\n\t\tdisabled: boolean;\n\t\tonSend?: () => void;\n\t} = $props();\n\n\t// Check for Web Speech API support\n\tconst SpeechRecognition =\n\t\ttypeof window !== 'undefined'\n\t\t\t? (window as any).SpeechRecognition ||\n\t\t\t\t(window as any).webkitSpeechRecognition\n\t\t\t: null;\n\tconst isBrowserSupported = !!SpeechRecognition;\n\n\t// State\n\tlet isRecording = $state(false);\n\tlet isProcessing = $state(false);\n\tlet isHolding = $state(false);\n\tlet showSettings = $state(false);\n\tlet directSend = $state(false);\n\tlet locale = $state('en-US');\n\tlet engine = $state<'browser' | 'cloud'>('browser');\n\tlet speechError = $state<string | null>(null);\n\n\t// Gesture & API Tracking\n\tlet pressTimer = $state<any>(null);\n\tlet recognitionInstance: any = null;\n\n\t// Direct WAV / Web Audio PCM Recording State\n\tlet audioContext: AudioContext | null = null;\n\tlet micSource: MediaStreamAudioSourceNode | null = null;\n\tlet scriptProcessor: any = null;\n\tlet audioStream: MediaStream | null = null;\n\tlet pcmChunks: Float32Array[] = [];\n\n\tlet baseText = '';\n\tlet textModified = false;\n\n\tconst locales = [\n\t\t{code: 'en-US', label: 'English (US)'},\n\t\t{code: 'en-GB', label: 'English (UK)'},\n\t\t{code: 'en-IN', label: 'English (India)'},\n\t\t{code: 'en-AU', label: 'English (Australia)'},\n\t\t{code: 'en-CA', label: 'English (Canada)'},\n\t\t{code: 'en-ZA', label: 'English (South Africa)'},\n\t];\n\n\tonMount(() => {\n\t\t// Load preferences\n\t\tconst storedDirectSend = localStorage.getItem(\n\t\t\t'wherever-speech-direct-send',\n\t\t);\n\t\tif (storedDirectSend !== null) {\n\t\t\tdirectSend = storedDirectSend === 'true';\n\t\t}\n\t\tconst storedLocale = localStorage.getItem('wherever-speech-locale');\n\t\tif (storedLocale !== null) {\n\t\t\tlocale = storedLocale;\n\t\t}\n\t\tconst storedEngine = localStorage.getItem('wherever-speech-engine');\n\t\tif (storedEngine !== null) {\n\t\t\tengine = storedEngine as 'browser' | 'cloud';\n\t\t} else if (!isBrowserSupported) {\n\t\t\tengine = 'cloud'; // Default to cloud if browser doesn't support Web Speech API\n\t\t}\n\n\t\t// Cleanup on destroy\n\t\treturn () => {\n\t\t\tif (recognitionInstance) {\n\t\t\t\ttry {\n\t\t\t\t\trecognitionInstance.abort();\n\t\t\t\t} catch (e) {}\n\t\t\t}\n\t\t\tif (scriptProcessor) {\n\t\t\t\ttry {\n\t\t\t\t\tscriptProcessor.disconnect();\n\t\t\t\t} catch {}\n\t\t\t}\n\t\t\tif (micSource) {\n\t\t\t\ttry {\n\t\t\t\t\tmicSource.disconnect();\n\t\t\t\t} catch {}\n\t\t\t}\n\t\t\tif (audioStream) {\n\t\t\t\ttry {\n\t\t\t\t\taudioStream.getTracks().forEach((track) => track.stop());\n\t\t\t\t} catch {}\n\t\t\t}\n\t\t\tif (audioContext) {\n\t\t\t\ttry {\n\t\t\t\t\taudioContext.close();\n\t\t\t\t} catch {}\n\t\t\t}\n\t\t\tif (pressTimer) clearTimeout(pressTimer);\n\t\t};\n\t});\n\n\tfunction savePreferences() {\n\t\tlocalStorage.setItem('wherever-speech-direct-send', String(directSend));\n\t\tlocalStorage.setItem('wherever-speech-locale', locale);\n\t\tlocalStorage.setItem('wherever-speech-engine', engine);\n\t}\n\n\tfunction getBaseUrl(): string {\n\t\tconst config = localStorage.getItem('wherever-config');\n\t\tif (config) {\n\t\t\tconst parsed = JSON.parse(config);\n\t\t\tconst protocol =\n\t\t\t\twindow.location.protocol === 'https:' ? 'https:' : 'http:';\n\t\t\tconst host = parsed.host.startsWith('http')\n\t\t\t\t? parsed.host.replace(/^wss?:\\/\\//, '')\n\t\t\t\t: parsed.host;\n\t\t\treturn `${protocol}//${host}:${parsed.port}`;\n\t\t}\n\t\treturn `${window.location.protocol}//${window.location.host}`;\n\t}\n\n\tfunction getToken(): string {\n\t\ttry {\n\t\t\tconst config = localStorage.getItem('wherever-config');\n\t\t\tif (config) {\n\t\t\t\tconst parsed = JSON.parse(config);\n\t\t\t\treturn parsed.token || '';\n\t\t\t}\n\t\t} catch {}\n\t\treturn '';\n\t}\n\n\t// Synthesize a brief audible beep to indicate recording start\n\tfunction playBeep() {\n\t\ttry {\n\t\t\tconst AudioContextClass =\n\t\t\t\twindow.AudioContext || (window as any).webkitAudioContext;\n\t\t\tif (!AudioContextClass) return;\n\t\t\tconst ctx = new AudioContextClass();\n\t\t\tconst osc = ctx.createOscillator();\n\t\t\tconst gain = ctx.createGain();\n\n\t\t\tosc.type = 'sine';\n\t\t\tosc.frequency.setValueAtTime(400, ctx.currentTime); // 400 Hz tone\n\n\t\t\tgain.gain.setValueAtTime(0.08, ctx.currentTime);\n\t\t\tgain.gain.exponentialRampToValueAtTime(0.001, ctx.currentTime + 0.12); // smooth fade out\n\n\t\t\tosc.connect(gain);\n\t\t\tgain.connect(ctx.destination);\n\n\t\t\tosc.start();\n\t\t\tosc.stop(ctx.currentTime + 0.12);\n\t\t} catch (e) {\n\t\t\tconsole.warn('Could not play audio beep feedback:', e);\n\t\t}\n\t}\n\n\t// Downsamples audio buffers to target sample rate (e.g. 16kHz)\n\tfunction downsampleBuffer(\n\t\tbuffer: Float32Array,\n\t\tinputSampleRate: number,\n\t\toutputSampleRate: number,\n\t): Float32Array {\n\t\tif (inputSampleRate === outputSampleRate) {\n\t\t\treturn buffer;\n\t\t}\n\t\tconst sampleRateRatio = inputSampleRate / outputSampleRate;\n\t\tconst newLength = Math.round(buffer.length / sampleRateRatio);\n\t\tconst result = new Float32Array(newLength);\n\t\tlet offsetResult = 0;\n\t\tlet offsetBuffer = 0;\n\t\twhile (offsetResult < result.length) {\n\t\t\tconst nextOffsetBuffer = Math.round((offsetResult + 1) * sampleRateRatio);\n\t\t\tlet accum = 0;\n\t\t\tlet count = 0;\n\t\t\tfor (\n\t\t\t\tlet i = offsetBuffer;\n\t\t\t\ti < nextOffsetBuffer && i < buffer.length;\n\t\t\t\ti++\n\t\t\t) {\n\t\t\t\taccum += buffer[i];\n\t\t\t\tcount++;\n\t\t\t}\n\t\t\tresult[offsetResult] = count > 0 ? accum / count : 0;\n\t\t\toffsetResult++;\n\t\t\toffsetBuffer = nextOffsetBuffer;\n\t\t}\n\t\treturn result;\n\t}\n\n\t// ==========================================\n\t// NATIVE BROWSER SPEECH RECOGNITION (STREAMING)\n\t// ==========================================\n\tfunction startBrowserRecording() {\n\t\tif (!isBrowserSupported) return;\n\t\ttry {\n\t\t\trecognitionInstance = new SpeechRecognition();\n\t\t\trecognitionInstance.continuous = true;\n\t\t\trecognitionInstance.interimResults = true;\n\t\t\trecognitionInstance.lang = locale;\n\n\t\t\trecognitionInstance.onstart = () => {\n\t\t\t\tisRecording = true;\n\t\t\t\tisProcessing = false;\n\t\t\t\tplayBeep();\n\t\t\t};\n\n\t\t\trecognitionInstance.onresult = (event: any) => {\n\t\t\t\tlet finalSessionText = '';\n\t\t\t\tlet interimSessionText = '';\n\n\t\t\t\tfor (let i = event.resultIndex; i < event.results.length; ++i) {\n\t\t\t\t\tconst result = event.results[i];\n\t\t\t\t\tif (result.isFinal) {\n\t\t\t\t\t\tfinalSessionText += result[0].transcript;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tinterimSessionText += result[0].transcript;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst sessionText = (finalSessionText + interimSessionText).trim();\n\t\t\t\tif (sessionText) {\n\t\t\t\t\ttextModified = true;\n\t\t\t\t\ttext = baseText + (baseText ? ' ' : '') + sessionText;\n\t\t\t\t}\n\t\t\t};\n\n\t\t\trecognitionInstance.onerror = (event: any) => {\n\t\t\t\tconsole.error('Browser speech recognition error:', event.error);\n\t\t\t\tif (event.error !== 'no-speech') {\n\t\t\t\t\tspeechError = `Error: ${event.error}`;\n\t\t\t\t}\n\t\t\t\tstopBrowserRecording();\n\t\t\t};\n\n\t\t\trecognitionInstance.onend = () => {\n\t\t\t\tisRecording = false;\n\t\t\t\tif (directSend && textModified && onSend) {\n\t\t\t\t\tsetTimeout(() => {\n\t\t\t\t\t\tif (text.trim()) {\n\t\t\t\t\t\t\tonSend();\n\t\t\t\t\t\t}\n\t\t\t\t\t}, 50);\n\t\t\t\t}\n\t\t\t};\n\n\t\t\trecognitionInstance.start();\n\t\t\tif (navigator.vibrate) {\n\t\t\t\tnavigator.vibrate(40);\n\t\t\t}\n\t\t} catch (e: any) {\n\t\t\tconsole.error('Failed to start browser speech recognition:', e);\n\t\t\tspeechError = 'Failed to start browser recording';\n\t\t\tisRecording = false;\n\t\t}\n\t}\n\n\tfunction stopBrowserRecording() {\n\t\tif (recognitionInstance) {\n\t\t\ttry {\n\t\t\t\trecognitionInstance.stop();\n\t\t\t} catch (e) {}\n\t\t}\n\t\tisRecording = false;\n\t}\n\n\t// ==========================================\n\t// CLOUD SERVER-ASSISTED SPEECH TRANSCRIPTION\n\t// ==========================================\n\tasync function startCloudRecording() {\n\t\ttry {\n\t\t\tconst stream = await navigator.mediaDevices.getUserMedia({audio: true});\n\t\t\taudioStream = stream;\n\t\t\tpcmChunks = [];\n\n\t\t\tconst AudioContextClass =\n\t\t\t\twindow.AudioContext || (window as any).webkitAudioContext;\n\t\t\taudioContext = new AudioContextClass();\n\n\t\t\tmicSource = audioContext.createMediaStreamSource(stream);\n\n\t\t\t// ScriptProcessor is widely supported and simpler than module-registered AudioWorklet\n\t\t\tscriptProcessor = audioContext.createScriptProcessor(4096, 1, 1);\n\t\t\tscriptProcessor.onaudioprocess = (event: any) => {\n\t\t\t\tconst inputBuffer = event.inputBuffer.getChannelData(0);\n\t\t\t\t// Push a snapshot/copy of Float32 audio samples\n\t\t\t\tpcmChunks.push(new Float32Array(inputBuffer));\n\t\t\t};\n\n\t\t\tmicSource.connect(scriptProcessor);\n\t\t\tscriptProcessor.connect(audioContext.destination);\n\n\t\t\tisRecording = true;\n\t\t\tisProcessing = false;\n\t\t\tplayBeep();\n\n\t\t\tif (navigator.vibrate) {\n\t\t\t\tnavigator.vibrate(40);\n\t\t\t}\n\t\t} catch (err: any) {\n\t\t\tconsole.error('Failed to start cloud audio recording:', err);\n\t\t\tspeechError = err.message || 'Microphone access denied';\n\t\t\tisRecording = false;\n\t\t\tisProcessing = false;\n\t\t}\n\t}\n\n\tfunction stopCloudRecording() {\n\t\tif (isRecording) {\n\t\t\tisRecording = false;\n\t\t\tisProcessing = true;\n\n\t\t\tif (scriptProcessor) {\n\t\t\t\ttry {\n\t\t\t\t\tscriptProcessor.disconnect();\n\t\t\t\t} catch {}\n\t\t\t\tscriptProcessor.onaudioprocess = null;\n\t\t\t}\n\t\t\tif (micSource) {\n\t\t\t\ttry {\n\t\t\t\t\tmicSource.disconnect();\n\t\t\t\t} catch {}\n\t\t\t}\n\t\t\tif (audioStream) {\n\t\t\t\ttry {\n\t\t\t\t\taudioStream.getTracks().forEach((track) => track.stop());\n\t\t\t\t} catch {}\n\t\t\t}\n\n\t\t\t// Decouple processing asynchronously to prevent UI freezing\n\t\t\tprocessCloudTranscription();\n\t\t}\n\t}\n\n\tasync function processCloudTranscription() {\n\t\ttry {\n\t\t\tif (pcmChunks.length === 0) {\n\t\t\t\tisProcessing = false;\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tspeechError = null;\n\n\t\t\t// Concatenate Float32 chunks\n\t\t\tlet totalLength = 0;\n\t\t\tfor (const chunk of pcmChunks) {\n\t\t\t\ttotalLength += chunk.length;\n\t\t\t}\n\n\t\t\tconst flatBuffer = new Float32Array(totalLength);\n\t\t\tlet offset = 0;\n\t\t\tfor (const chunk of pcmChunks) {\n\t\t\t\tflatBuffer.set(chunk, offset);\n\t\t\t\toffset += chunk.length;\n\t\t\t}\n\n\t\t\t// Downsample to 16kHz (Server transcriber standard)\n\t\t\tconst originalSampleRate = audioContext ? audioContext.sampleRate : 48000;\n\t\t\tconst targetSampleRate = 16000;\n\t\t\tconst downsampledBuffer = downsampleBuffer(\n\t\t\t\tflatBuffer,\n\t\t\t\toriginalSampleRate,\n\t\t\t\ttargetSampleRate,\n\t\t\t);\n\n\t\t\t// Encode directly to mono 16-bit PCM WAV buffer\n\t\t\tconst wavBuffer = createWav(\n\t\t\t\tdownsampledBuffer,\n\t\t\t\t1,\n\t\t\t\ttargetSampleRate,\n\t\t\t\t1,\n\t\t\t\t16,\n\t\t\t);\n\t\t\tconst wavBlob = new Blob([wavBuffer], {type: 'audio/wav'});\n\n\t\t\tconst baseUrl = getBaseUrl();\n\t\t\tconst token = getToken();\n\t\t\tconst url = `${baseUrl}/session/transcribe${token ? `?token=${encodeURIComponent(token)}` : ''}`;\n\n\t\t\tconst res = await fetch(url, {\n\t\t\t\tmethod: 'POST',\n\t\t\t\tbody: wavBlob,\n\t\t\t\theaders: {\n\t\t\t\t\t'Content-Type': 'application/octet-stream',\n\t\t\t\t},\n\t\t\t});\n\n\t\t\tconst data = await res.json();\n\t\t\tif (!res.ok) {\n\t\t\t\tthrow new Error(data.error || `HTTP ${res.status}`);\n\t\t\t}\n\n\t\t\tif (data.text && data.text.trim()) {\n\t\t\t\ttextModified = true;\n\t\t\t\ttext = baseText + (baseText ? ' ' : '') + data.text.trim();\n\n\t\t\t\t// Auto dispatch if enabled\n\t\t\t\tif (directSend && onSend) {\n\t\t\t\t\tsetTimeout(() => {\n\t\t\t\t\t\tif (text.trim()) {\n\t\t\t\t\t\t\tonSend();\n\t\t\t\t\t\t}\n\t\t\t\t\t}, 50);\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (err: any) {\n\t\t\tconsole.error('Cloud transcription request failed:', err);\n\t\t\tspeechError = err.message || 'Cloud API failed';\n\t\t} finally {\n\t\t\tisProcessing = false;\n\t\t\tif (audioContext) {\n\t\t\t\ttry {\n\t\t\t\t\taudioContext.close();\n\t\t\t\t} catch {}\n\t\t\t\taudioContext = null;\n\t\t\t}\n\t\t}\n\t}\n\n\t// ==========================================\n\t// GESTURE & INTERACTION DISPATCHERS\n\t// ==========================================\n\tfunction startRecording() {\n\t\tif (disabled || isRecording || isProcessing) return;\n\t\tspeechError = null;\n\t\ttextModified = false;\n\t\tbaseText = text;\n\n\t\tif (engine === 'cloud') {\n\t\t\tstartCloudRecording();\n\t\t} else {\n\t\t\tstartBrowserRecording();\n\t\t}\n\t}\n\n\tfunction stopRecording() {\n\t\tif (engine === 'cloud') {\n\t\t\tstopCloudRecording();\n\t\t} else {\n\t\t\tstopBrowserRecording();\n\t\t}\n\t}\n\n\tfunction handlePointerDown(e: PointerEvent) {\n\t\tif (e.button !== 0) return; // Only left click / main touch\n\t\tif (disabled) return;\n\n\t\te.preventDefault();\n\t\tif (isRecording) {\n\t\t\tstopRecording();\n\t\t\treturn;\n\t\t}\n\n\t\tisHolding = false;\n\t\tpressTimer = setTimeout(() => {\n\t\t\tisHolding = true;\n\t\t\tstartRecording();\n\t\t}, 350);\n\t}\n\n\tfunction handlePointerUp(e: PointerEvent) {\n\t\tif (pressTimer) {\n\t\t\tclearTimeout(pressTimer);\n\t\t\tpressTimer = null;\n\t\t}\n\n\t\tif (isHolding) {\n\t\t\tisHolding = false;\n\t\t\tstopRecording();\n\t\t} else if (!isRecording) {\n\t\t\tstartRecording();\n\t\t}\n\t}\n\n\tfunction handlePointerCancel() {\n\t\tif (pressTimer) {\n\t\t\tclearTimeout(pressTimer);\n\t\t\tpressTimer = null;\n\t\t}\n\t\tif (isHolding) {\n\t\t\tisHolding = false;\n\t\t\tstopRecording();\n\t\t}\n\t}\n\n\t// ==========================================\n\t// CLIENT-SIDE WAV ENCODER\n\t// ==========================================\n\tfunction audioBufferToWav(buffer: AudioBuffer): ArrayBuffer {\n\t\tconst numOfChan = buffer.numberOfChannels;\n\t\tconst sampleRate = buffer.sampleRate;\n\t\tconst format = 1; // Raw PCM\n\t\tconst bitDepth = 16;\n\n\t\tlet result;\n\t\tif (numOfChan === 2) {\n\t\t\tresult = interleave(buffer.getChannelData(0), buffer.getChannelData(1));\n\t\t} else {\n\t\t\tresult = buffer.getChannelData(0);\n\t\t}\n\n\t\treturn createWav(result, numOfChan, sampleRate, format, bitDepth);\n\t}\n\n\tfunction interleave(\n\t\tinputL: Float32Array,\n\t\tinputR: Float32Array,\n\t): Float32Array {\n\t\tconst length = inputL.length + inputR.length;\n\t\tconst result = new Float32Array(length);\n\t\tlet index = 0;\n\t\tlet inputIndex = 0;\n\n\t\twhile (index < length) {\n\t\t\tresult[index++] = inputL[inputIndex];\n\t\t\tresult[index++] = inputR[inputIndex];\n\t\t\tinputIndex++;\n\t\t}\n\t\treturn result;\n\t}\n\n\tfunction createWav(\n\t\tsamples: Float32Array,\n\t\tnumOfChan: number,\n\t\tsampleRate: number,\n\t\tformat: number,\n\t\tbitDepth: number,\n\t): ArrayBuffer {\n\t\tconst buffer = new ArrayBuffer(44 + samples.length * 2);\n\t\tconst view = new DataView(buffer);\n\n\t\t/* RIFF identifier */\n\t\twriteString(view, 0, 'RIFF');\n\t\t/* file length */\n\t\tview.setUint32(4, 36 + samples.length * 2, true);\n\t\t/* RIFF type */\n\t\twriteString(view, 8, 'WAVE');\n\t\t/* format chunk identifier */\n\t\twriteString(view, 12, 'fmt ');\n\t\t/* format chunk length */\n\t\tview.setUint32(16, 16, true);\n\t\t/* sample format (raw PCM) */\n\t\tview.setUint16(20, format, true);\n\t\t/* channel count */\n\t\tview.setUint16(22, numOfChan, true);\n\t\t/* sample rate */\n\t\tview.setUint32(24, sampleRate, true);\n\t\t/* byte rate (sample rate * block align) */\n\t\tview.setUint32(28, sampleRate * numOfChan * (bitDepth / 8), true);\n\t\t/* block align (channel count * bytes per sample) */\n\t\tview.setUint16(32, numOfChan * (bitDepth / 8), true);\n\t\t/* bits per sample */\n\t\tview.setUint16(34, bitDepth, true);\n\t\t/* data chunk identifier */\n\t\twriteString(view, 36, 'data');\n\t\t/* data chunk length */\n\t\tview.setUint32(40, samples.length * 2, true);\n\n\t\tfloatTo16BitPCM(view, 44, samples);\n\n\t\treturn buffer;\n\t}\n\n\tfunction floatTo16BitPCM(\n\t\toutput: DataView,\n\t\toffset: number,\n\t\tinput: Float32Array,\n\t) {\n\t\tfor (let i = 0; i < input.length; i++, offset += 2) {\n\t\t\tlet s = Math.max(-1, Math.min(1, input[i]));\n\t\t\toutput.setInt16(offset, s < 0 ? s * 0x8000 : s * 0x7fff, true);\n\t\t}\n\t}\n\n\tfunction writeString(view: DataView, offset: number, string: string) {\n\t\tfor (let i = 0; i < string.length; i++) {\n\t\t\tview.setUint8(offset + i, string.charCodeAt(i));\n\t\t}\n\t}\n</script>\n\n<div class=\"relative flex shrink-0 items-center gap-1 select-none\">\n\t<!-- Mic Button -->\n\t<button\n\t\ttype=\"button\"\n\t\tdisabled={(disabled && !isRecording && !isProcessing) || isProcessing}\n\t\tonpointerdown={handlePointerDown}\n\t\tonpointerup={handlePointerUp}\n\t\tonpointercancel={handlePointerCancel}\n\t\tclass=\"flex h-[48px] w-[48px] items-center justify-center rounded-lg border transition-all duration-150 disabled:cursor-not-allowed disabled:opacity-40\n\t\t\t{isRecording\n\t\t\t? 'animate-pulse border-red-500 bg-red-600 text-white'\n\t\t\t: isProcessing\n\t\t\t\t? 'cursor-wait border-amber-500 bg-amber-600 text-white'\n\t\t\t\t: 'border-gray-600 bg-gray-800 text-gray-400 hover:bg-gray-700 hover:text-white'}\"\n\t\ttitle={isRecording\n\t\t\t? 'Recording (release/tap to stop)...'\n\t\t\t: isProcessing\n\t\t\t\t? 'Processing speech...'\n\t\t\t\t: 'Hold to speak (walkie-talkie) or Tap to toggle recording'}\n\t>\n\t\t<svg\n\t\t\txmlns=\"http://www.w3.org/2000/svg\"\n\t\t\tviewBox=\"0 0 24 24\"\n\t\t\tfill=\"none\"\n\t\t\tstroke=\"currentColor\"\n\t\t\tstroke-width=\"2\"\n\t\t\tstroke-linecap=\"round\"\n\t\t\tstroke-linejoin=\"round\"\n\t\t\tclass=\"h-5 w-5\"\n\t\t>\n\t\t\t<path d=\"M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z\" />\n\t\t\t<path d=\"M19 10v2a7 7 0 0 1-14 0v-2\" />\n\t\t\t<line x1=\"12\" x2=\"12\" y1=\"19\" y2=\"22\" />\n\t\t</svg>\n\t</button>\n\n\t<!-- Settings Cog Button -->\n\t<button\n\t\ttype=\"button\"\n\t\tonclick={() => (showSettings = !showSettings)}\n\t\tdisabled={(disabled && !isRecording && !isProcessing) || isProcessing}\n\t\tclass=\"flex h-[48px] w-[28px] items-center justify-center rounded-lg border border-gray-600 bg-gray-800 text-gray-400 hover:bg-gray-700 hover:text-white disabled:cursor-not-allowed disabled:opacity-40\"\n\t\ttitle=\"Speech Settings\"\n\t>\n\t\t<svg\n\t\t\txmlns=\"http://www.w3.org/2000/svg\"\n\t\t\tviewBox=\"0 0 24 24\"\n\t\t\tfill=\"none\"\n\t\t\tstroke=\"currentColor\"\n\t\t\tstroke-width=\"2\"\n\t\t\tstroke-linecap=\"round\"\n\t\t\tstroke-linejoin=\"round\"\n\t\t\tclass=\"h-4 w-4 transition-transform duration-200 {showSettings\n\t\t\t\t? 'rotate-45 text-white'\n\t\t\t\t: ''}\"\n\t\t>\n\t\t\t<circle cx=\"12\" cy=\"12\" r=\"3\" />\n\t\t\t<path\n\t\t\t\td=\"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z\"\n\t\t\t/>\n\t\t</svg>\n\t</button>\n\n\t<!-- Settings Popover -->\n\t{#if showSettings}\n\t\t<!-- Click Outside Backdrop -->\n\t\t<!-- svelte-ignore a11y_click_events_have_key_events -->\n\t\t<!-- svelte-ignore a11y_no_static_element_interactions -->\n\t\t<div\n\t\t\tclass=\"fixed inset-0 z-40\"\n\t\t\tonclick={() => (showSettings = false)}\n\t\t></div>\n\n\t\t<div\n\t\t\tclass=\"absolute right-0 bottom-14 z-50 w-64 rounded-lg border border-gray-600 bg-gray-800 p-4 text-xs text-white shadow-xl\"\n\t\t>\n\t\t\t<h4\n\t\t\t\tclass=\"mb-3 border-b border-gray-700 pb-1.5 font-semibold text-gray-300\"\n\t\t\t>\n\t\t\t\tSpeech Settings\n\t\t\t</h4>\n\n\t\t\t<!-- Engine Selection -->\n\t\t\t<div class=\"mb-3.5\">\n\t\t\t\t<span class=\"mb-1 block font-medium text-gray-400\">\n\t\t\t\t\tSpeech-to-Text Engine\n\t\t\t\t</span>\n\t\t\t\t<div class=\"flex gap-2\">\n\t\t\t\t\t<button\n\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\tonclick={() => {\n\t\t\t\t\t\t\tengine = 'browser';\n\t\t\t\t\t\t\tsavePreferences();\n\t\t\t\t\t\t}}\n\t\t\t\t\t\tdisabled={!isBrowserSupported}\n\t\t\t\t\t\tclass=\"flex-1 rounded border px-2 py-1.5 text-center font-medium transition-colors disabled:opacity-40\n\t\t\t\t\t\t\t{engine === 'browser'\n\t\t\t\t\t\t\t? 'border-blue-500 bg-blue-600 text-white'\n\t\t\t\t\t\t\t: 'border-gray-600 bg-gray-950 text-gray-400 hover:text-white'}\"\n\t\t\t\t\t>\n\t\t\t\t\t\tOn-Device\n\t\t\t\t\t</button>\n\t\t\t\t\t<button\n\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\tonclick={() => {\n\t\t\t\t\t\t\tengine = 'cloud';\n\t\t\t\t\t\t\tsavePreferences();\n\t\t\t\t\t\t}}\n\t\t\t\t\t\tclass=\"flex-1 rounded border px-2 py-1.5 text-center font-medium transition-colors\n\t\t\t\t\t\t\t{engine === 'cloud'\n\t\t\t\t\t\t\t? 'border-blue-500 bg-blue-600 text-white'\n\t\t\t\t\t\t\t: 'border-gray-600 bg-gray-950 text-gray-400 hover:text-white'}\"\n\t\t\t\t\t>\n\t\t\t\t\t\tCloud AI\n\t\t\t\t\t</button>\n\t\t\t\t</div>\n\t\t\t\t<p class=\"mt-1 text-[10px] leading-relaxed text-gray-400\">\n\t\t\t\t\t{engine === 'browser'\n\t\t\t\t\t\t? 'Uses free built-in browser dictation. Streaming, zero-latency.'\n\t\t\t\t\t\t: 'Uses server-side Z.ai / Groq / OpenAI keys. High accent tolerance.'}\n\t\t\t\t</p>\n\t\t\t</div>\n\n\t\t\t<!-- Accent/Locale Selection (Only visible for Browser engine) -->\n\t\t\t{#if engine === 'browser'}\n\t\t\t\t<div class=\"mb-3.5\">\n\t\t\t\t\t<label\n\t\t\t\t\t\tfor=\"speech-locale\"\n\t\t\t\t\t\tclass=\"mb-1 block font-medium text-gray-400\"\n\t\t\t\t\t>\n\t\t\t\t\t\tAccent / Locale\n\t\t\t\t\t</label>\n\t\t\t\t\t<select\n\t\t\t\t\t\tid=\"speech-locale\"\n\t\t\t\t\t\tbind:value={locale}\n\t\t\t\t\t\tonchange={savePreferences}\n\t\t\t\t\t\tclass=\"w-full rounded border border-gray-600 bg-gray-950 px-2 py-1.5 text-white focus:border-blue-500 focus:outline-none\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{#each locales as loc}\n\t\t\t\t\t\t\t<option value={loc.code}>{loc.label}</option>\n\t\t\t\t\t\t{/each}\n\t\t\t\t\t</select>\n\t\t\t\t</div>\n\t\t\t{/if}\n\n\t\t\t<!-- Direct Send Toggle -->\n\t\t\t<div class=\"mb-2\">\n\t\t\t\t<label class=\"flex cursor-pointer items-center gap-2 py-1\">\n\t\t\t\t\t<input\n\t\t\t\t\t\ttype=\"checkbox\"\n\t\t\t\t\t\tbind:checked={directSend}\n\t\t\t\t\t\tonchange={savePreferences}\n\t\t\t\t\t\tclass=\"rounded border-gray-600 bg-gray-950 text-blue-600 focus:ring-0 focus:ring-offset-0\"\n\t\t\t\t\t/>\n\t\t\t\t\t<span class=\"font-medium text-gray-300\"\n\t\t\t\t\t\t>Direct Send (Auto-dispatch)</span\n\t\t\t\t\t>\n\t\t\t\t</label>\n\t\t\t\t<p class=\"pl-6 text-[10px] leading-relaxed text-gray-400\">\n\t\t\t\t\tWhen enabled, releasing or stopping the microphone immediately sends\n\t\t\t\t\tthe message.\n\t\t\t\t</p>\n\t\t\t</div>\n\n\t\t\t{#if speechError}\n\t\t\t\t<div\n\t\t\t\t\tclass=\"mt-2 rounded border border-red-900/40 bg-red-950/40 p-2 leading-normal text-red-400\"\n\t\t\t\t>\n\t\t\t\t\t{speechError}\n\t\t\t\t</div>\n\t\t\t{/if}\n\t\t</div>\n\t{/if}\n</div>\n","<script lang=\"ts\">\n\timport {onMount, untrack} from 'svelte';\n\timport {\n\t\tsendMessage,\n\t\tpiState,\n\t\tisConnected,\n\t\tcreateSession,\n\t\tclearMessages,\n\t\tleaveSession,\n\t\tuploadFile,\n\t\tbeginFilePicker,\n\t\tendFilePicker,\n\t} from '$lib/wherever';\n\timport {isStreaming, isReadOnly, activeSessionInfo} from '$lib/wherever';\n\timport {getBaseUrl, getToken} from '$lib/session-store';\n\timport {decideComposeSend} from '$lib/core/compose-send';\n\timport SpeechButton from './speech/SpeechButton.svelte';\n\n\tlet {\n\t\tdisabled,\n\t\tonSend,\n\t\tonSubmit,\n\t\tplaceholder,\n\t\tsubmitLabel,\n\t\tshowAttach = true,\n\t\tsearchMode = false,\n\t\tsearchConfigured = false,\n\t\tsearchModels = [],\n\t\tsearchModel = $bindable(''),\n\t}: {\n\t\tdisabled: boolean;\n\t\tonSend?: () => void;\n\t\t// When provided (search mode), submit routes here instead of sendMessage.\n\t\tonSubmit?: (text: string) => void;\n\t\tplaceholder?: string;\n\t\tsubmitLabel?: string;\n\t\tshowAttach?: boolean;\n\t\tsearchMode?: boolean;\n\t\t// Whether a search folder is configured (gates enablement in search mode).\n\t\tsearchConfigured?: boolean;\n\t\t// Model list + bound selection for the search-mode model picker. Values are\n\t\t// \"provider:modelId\"; empty label list hides the picker.\n\t\tsearchModels?: {value: string; label: string}[];\n\t\tsearchModel?: string;\n\t} = $props();\n\n\tlet text = $state('');\n\tlet enterToSend = $state(true);\n\tlet isCollapsed = $state(false);\n\n\tlet fileInput = $state<HTMLInputElement>();\n\tlet attachments = $state<\n\t\t{name: string; path?: string; error?: string; uploading: boolean}[]\n\t>([]);\n\n\tlet streaming = $derived($isStreaming);\n\tlet readOnly = $derived($isReadOnly);\n\tlet sessionInfo = $derived($activeSessionInfo);\n\tlet connected = $derived($isConnected);\n\tlet appState = $derived($piState);\n\n\t// In search mode the composer must work with no active session: it requires\n\t// only a live connection and a configured search folder. In chat mode it\n\t// stays gated on an active session as before.\n\t// Note: streaming does NOT disable the composer. A mid-stream submit steers\n\t// the agent immediately (pi's default), so the box stays live while the agent\n\t// works and the primary button reads \"Steer\".\n\tlet effectivelyDisabled = $derived(\n\t\tsearchMode\n\t\t\t? disabled || !connected || !searchConfigured\n\t\t\t: disabled || !connected || readOnly || !sessionInfo.sessionId,\n\t);\n\n\tlet isAnyUploading = $derived(attachments.some((a) => a.uploading));\n\tlet canSend = $derived(\n\t\t!effectivelyDisabled &&\n\t\t\t!isAnyUploading &&\n\t\t\t(text.trim().length > 0 || attachments.length > 0),\n\t);\n\n\tlet textarea = $state<HTMLTextAreaElement>();\n\n\t// Persist the in-progress draft so it is never lost when this composer is\n\t// unmounted out from under the user (e.g. the parent swaps it for the\n\t// \"Reconnecting and syncing session...\" status line during a resync, or on a\n\t// transient disconnect). The draft is keyed per session so switching sessions\n\t// does not bleed text between them; search mode (no session) uses a shared\n\t// 'search' key. Cleared on a successful send.\n\t// A draft belongs to the active session when one is open, otherwise to the\n\t// (no-session) search composer. Keying on sessionId-or-search this way means:\n\t// a session keeps its own draft, and the search query is preserved under one\n\t// shared key so switching into a session and back to search (by closing the\n\t// session or hitting the search button) restores what was typed. This holds\n\t// whether or not a search folder is configured (no session == search mode).\n\tconst DRAFT_PREFIX = 'wherever-draft:';\n\tlet draftKey = $derived(DRAFT_PREFIX + (sessionInfo.sessionId ?? 'search'));\n\t// Tracks which key we have already hydrated so the restore effect fires only\n\t// when the key actually changes (mount, session switch, search<->chat), not on\n\t// every keystroke. The persist effect below removes the key whenever the\n\t// textarea goes empty, so a successful send (which clears `text`) also clears\n\t// the saved draft.\n\tlet hydratedKey = $state<string | null>(null);\n\n\tonMount(() => {\n\t\tconst stored = localStorage.getItem('wherever-enter-to-send');\n\t\tif (stored !== null) {\n\t\t\tenterToSend = stored === 'true';\n\t\t}\n\t});\n\n\t// Swap the textarea to the active draft key's saved draft whenever the key\n\t// changes (initial mount, session switch, search<->chat). This is an\n\t// unconditional swap: the previous session's draft must NOT linger in the box\n\t// after switching, but going back to a session restores its own saved draft.\n\t// The hydratedKey guard makes this fire ONLY on a real key change (not on\n\t// every keystroke), so it never clobbers text the user is actively typing\n\t// within the current session. The text read is untracked accordingly.\n\t$effect(() => {\n\t\tconst key = draftKey;\n\t\tif (key === hydratedKey) return;\n\t\tuntrack(() => {\n\t\t\tlet saved: string | null = null;\n\t\t\tif (typeof localStorage !== 'undefined') {\n\t\t\t\ttry {\n\t\t\t\t\tsaved = localStorage.getItem(key);\n\t\t\t\t} catch {}\n\t\t\t}\n\t\t\ttext = saved ?? '';\n\t\t\thydratedKey = key;\n\t\t});\n\t});\n\n\t// Persist the draft on every text change. Removing the key when empty keeps\n\t// storage clean (and means a successful send, which clears text, clears it).\n\t// Only persists once the current key has been hydrated, so the restore above\n\t// is never overwritten by a stale empty value mid-switch.\n\t$effect(() => {\n\t\tconst value = text;\n\t\tconst key = draftKey;\n\t\tif (key !== hydratedKey || typeof localStorage === 'undefined') return;\n\t\ttry {\n\t\t\tif (value.trim().length > 0) {\n\t\t\t\tlocalStorage.setItem(key, value);\n\t\t\t} else {\n\t\t\t\tlocalStorage.removeItem(key);\n\t\t\t}\n\t\t} catch {}\n\t});\n\n\t// Exposed so a parent can focus the textarea SYNCHRONOUSLY inside a user\n\t// gesture (required to raise the mobile virtual keyboard, esp. iOS Safari).\n\texport function focusInput() {\n\t\tif (isCollapsed) isCollapsed = false;\n\t\ttextarea?.focus();\n\t}\n\n\tfunction toggleEnterToSend() {\n\t\tenterToSend = !enterToSend;\n\t\tlocalStorage.setItem('wherever-enter-to-send', String(enterToSend));\n\t}\n\n\t$effect(() => {\n\t\tif (textarea) {\n\t\t\t// Trigger reactive updates when text changes\n\t\t\ttext;\n\t\t\ttextarea.style.height = 'auto';\n\t\t\ttextarea.style.height = `${textarea.scrollHeight}px`;\n\t\t}\n\t});\n\n\t// Automatically focus/refocus the textarea whenever it becomes active/enabled\n\t$effect(() => {\n\t\tif (!effectivelyDisabled && textarea) {\n\t\t\ttextarea.focus();\n\t\t}\n\t});\n\n\tasync function handleFileChange(e: Event) {\n\t\t// The native picker is closed now that we have a change event; allow the\n\t\t// background suspend timer to resume its normal behaviour.\n\t\tendFilePicker();\n\t\tconst target = e.target as HTMLInputElement;\n\t\tif (!target.files) return;\n\t\tconst files = Array.from(target.files);\n\t\ttarget.value = '';\n\n\t\tconst startIdx = attachments.length;\n\t\tattachments = [\n\t\t\t...attachments,\n\t\t\t...files.map((f) => ({name: f.name, uploading: true})),\n\t\t];\n\n\t\tfor (let i = 0; i < files.length; i++) {\n\t\t\tconst file = files[i];\n\t\t\tconst idx = startIdx + i;\n\t\t\ttry {\n\t\t\t\tif (!sessionInfo.sessionId) {\n\t\t\t\t\tthrow new Error('No active session');\n\t\t\t\t}\n\t\t\t\tconst res = await uploadFile(sessionInfo.sessionId, file);\n\t\t\t\tattachments = attachments.map((a, currentIdx) =>\n\t\t\t\t\tcurrentIdx === idx\n\t\t\t\t\t\t? {name: file.name, path: res.savedPath, uploading: false}\n\t\t\t\t\t\t: a,\n\t\t\t\t);\n\t\t\t} catch (err) {\n\t\t\t\tconst errMsg = (err as Error).message || 'Failed to upload';\n\t\t\t\tconsole.error('File upload error details:', err);\n\n\t\t\t\t// Build a diagnostics target URL (/health)\n\t\t\t\tlet targetUrl = '';\n\t\t\t\ttry {\n\t\t\t\t\tconst baseUrl = getBaseUrl();\n\t\t\t\t\tconst token = getToken();\n\t\t\t\t\ttargetUrl = `${baseUrl}/health${token ? `?token=${encodeURIComponent(token)}` : ''}`;\n\t\t\t\t} catch (e) {}\n\n\t\t\t\tattachments = attachments.map((a, currentIdx) =>\n\t\t\t\t\tcurrentIdx === idx\n\t\t\t\t\t\t? ({\n\t\t\t\t\t\t\t\tname: file.name,\n\t\t\t\t\t\t\t\terror: errMsg,\n\t\t\t\t\t\t\t\turl: targetUrl,\n\t\t\t\t\t\t\t\tuploading: false,\n\t\t\t\t\t\t\t} as any)\n\t\t\t\t\t\t: a,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction removeAttachment(index: number) {\n\t\tattachments = attachments.filter((_, idx) => idx !== index);\n\t}\n\n\tfunction handleSend() {\n\t\tconst trimmed = text.trim();\n\n\t\t// Search mode: route to the injected handler, skip slash commands,\n\t\t// attachments and the streaming/queue machinery entirely.\n\t\tif (searchMode) {\n\t\t\tif (!trimmed || effectivelyDisabled) return;\n\t\t\tonSubmit?.(trimmed);\n\t\t\ttext = '';\n\t\t\tonSend?.();\n\t\t\treturn;\n\t\t}\n\n\t\tif (!trimmed && attachments.length === 0) return;\n\n\t\tlet messageToSend = trimmed;\n\t\tif (attachments.length > 0) {\n\t\t\tconst validAttachments = attachments.filter((a) => a.path);\n\t\t\tif (validAttachments.length > 0) {\n\t\t\t\tconst fileLines = validAttachments\n\t\t\t\t\t.map((a) => `[Uploaded file: ${a.path}]`)\n\t\t\t\t\t.join('\\n');\n\n\t\t\t\tif (messageToSend) {\n\t\t\t\t\tmessageToSend += '\\n\\n' + fileLines;\n\t\t\t\t} else {\n\t\t\t\t\tmessageToSend = `I have uploaded the following file(s) for you:\\n${fileLines}`;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Handle local slash commands to match terminal behavior\n\t\tif (trimmed.startsWith('/') && attachments.length === 0) {\n\t\t\tconst lower = trimmed.toLowerCase();\n\t\t\tif (lower === '/new' || lower === '/reset') {\n\t\t\t\tif (sessionInfo.cwd) {\n\t\t\t\t\tcreateSession(sessionInfo.cwd, sessionInfo.model || undefined);\n\t\t\t\t\ttext = '';\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t} else if (lower === '/clear') {\n\t\t\t\tclearMessages();\n\t\t\t\ttext = '';\n\t\t\t\treturn;\n\t\t\t} else if (lower === '/leave' || lower === '/exit') {\n\t\t\t\tleaveSession();\n\t\t\t\ttext = '';\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\t// pi's default: an explicit submit sends NOW. When the agent is streaming,\n\t\t// the server turns this mid-stream `message` into a STEER (injected at the\n\t\t// next tool/step boundary, before the next LLM call) rather than parking it\n\t\t// in a local queue that waits for the whole turn to resolve. The decision\n\t\t// helper is a pure, unit-tested function so this behaviour is gated in tests.\n\t\tconst decision = decideComposeSend({\n\t\t\tstreaming,\n\t\t\tconnected,\n\t\t\tagentPending: appState.agentPending,\n\t\t\treadOnly,\n\t\t\thasSession: !!sessionInfo.sessionId,\n\t\t});\n\t\tif (decision.action !== 'send') {\n\t\t\t// A genuine block (no session / read-only / disconnected / agent still\n\t\t\t// building). Keep the user's text intact; the composer's disabled/status\n\t\t\t// affordances already explain the state, and sendMessage() would surface a\n\t\t\t// recoverable error anyway. Never silently swallow the message.\n\t\t\tif (\n\t\t\t\tdecision.reason === 'disconnected' ||\n\t\t\t\tdecision.reason === 'agent-pending'\n\t\t\t) {\n\t\t\t\t// Route through sendMessage so it sets the clear, recoverable session\n\t\t\t\t// error (\"Not connected...\" / \"Preparing the session agent...\"). It\n\t\t\t\t// returns false and leaves the text so the user can retry.\n\t\t\t\tsendMessage(messageToSend);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\t// Only clear the composer if the message actually went out. On a dropped\n\t\t// send (socket died in the race) sendMessage() returns false and surfaces an\n\t\t// error; keep the text so the user can retry once reconnected instead of\n\t\t// silently losing what they typed.\n\t\tconst sent = sendMessage(messageToSend);\n\t\tif (sent) {\n\t\t\ttext = '';\n\t\t\tattachments = [];\n\t\t\tonSend?.();\n\t\t}\n\t}\n\n\tfunction handleKeydown(e: KeyboardEvent) {\n\t\tif (e.key === 'Enter') {\n\t\t\tif (enterToSend) {\n\t\t\t\t// Default mode: Enter to send, Shift+Enter for newline\n\t\t\t\tif (!e.shiftKey) {\n\t\t\t\t\te.preventDefault();\n\t\t\t\t\thandleSend();\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// Enter for newline, Shift+Enter to send\n\t\t\t\tif (e.shiftKey) {\n\t\t\t\t\te.preventDefault();\n\t\t\t\t\thandleSend();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n</script>\n\n<div class=\"border-t border-brand-border p-4\">\n\t{#if !connected || appState.connecting || appState.error}\n\t\t<div\n\t\t\tclass=\"mb-2.5 flex items-center gap-1.5 text-xs font-medium text-brand-text-muted select-none\"\n\t\t>\n\t\t\t{#if appState.connecting}\n\t\t\t\t<span\n\t\t\t\t\tclass=\"inline-block h-1.5 w-1.5 animate-ping rounded-full bg-amber-400\"\n\t\t\t\t></span>\n\t\t\t\t<span>Connecting to remote server...</span>\n\t\t\t{:else if appState.error}\n\t\t\t\t<span class=\"text-rose-400\">⚠️</span>\n\t\t\t\t<span class=\"text-rose-400/80\">{appState.error}</span>\n\t\t\t{:else if !connected}\n\t\t\t\t<span class=\"inline-block h-1.5 w-1.5 rounded-full bg-brand-surface-3\"\n\t\t\t\t></span>\n\t\t\t\t<span>Disconnected from remote server</span>\n\t\t\t{/if}\n\t\t</div>\n\t{/if}\n\t{#if isCollapsed}\n\t\t<div class=\"flex items-center\">\n\t\t\t<button\n\t\t\t\ttype=\"button\"\n\t\t\t\tonclick={() => {\n\t\t\t\t\tisCollapsed = false;\n\t\t\t\t\tsetTimeout(() => textarea?.focus(), 50);\n\t\t\t\t}}\n\t\t\t\tclass=\"flex w-full items-center justify-between rounded-lg border border-brand-border bg-brand-surface-2 px-4 py-2.5 text-sm text-brand-text-muted transition-all hover:bg-brand-surface-3 hover:text-brand-text\"\n\t\t\t>\n\t\t\t\t<span class=\"flex items-center gap-2\">\n\t\t\t\t\t<span>{searchMode ? '🔍' : '💬'}</span>\n\t\t\t\t\t<span>\n\t\t\t\t\t\t{#if searchMode}\n\t\t\t\t\t\t\t{placeholder ?? 'Search the web...'}\n\t\t\t\t\t\t{:else if streaming}\n\t\t\t\t\t\t\tAgent is working, tap to Steer...\n\t\t\t\t\t\t{:else if readOnly}\n\t\t\t\t\t\t\tRead-only mode\n\t\t\t\t\t\t{:else if !sessionInfo.sessionId}\n\t\t\t\t\t\t\tSelect a session first...\n\t\t\t\t\t\t{:else}\n\t\t\t\t\t\t\tTap to type a message...\n\t\t\t\t\t\t{/if}\n\t\t\t\t\t</span>\n\t\t\t\t</span>\n\t\t\t\t<span\n\t\t\t\t\tclass=\"rounded bg-brand-surface-3 px-2 py-1 text-xs font-medium text-brand-text transition-colors hover:bg-brand-surface-2\"\n\t\t\t\t\t>Expand ▲</span\n\t\t\t\t>\n\t\t\t</button>\n\t\t</div>\n\t{:else}\n\t\t{#if attachments.length > 0}\n\t\t\t<div class=\"mb-3 flex flex-wrap gap-2\">\n\t\t\t\t{#each attachments as attachment, index}\n\t\t\t\t\t<div\n\t\t\t\t\t\tclass=\"flex items-center gap-2 rounded border border-brand-border bg-brand-surface-2 px-2.5 py-1.5 text-xs\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<span\n\t\t\t\t\t\t\tclass=\"max-w-[150px] truncate font-medium text-brand-text\"\n\t\t\t\t\t\t\ttitle={attachment.name}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{attachment.name}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t\t{#if attachment.uploading}\n\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\tclass=\"inline-block h-3 w-3 animate-spin rounded-full border-2 border-brand-blue border-t-transparent\"\n\t\t\t\t\t\t\t></span>\n\t\t\t\t\t\t{:else if attachment.error}\n\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\tclass=\"flex items-center gap-1 text-[10px] font-medium text-rose-400\"\n\t\t\t\t\t\t\t\ttitle={attachment.error}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<span class=\"max-w-[120px] truncate\">⚠️ {attachment.error}</span\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{#if (attachment as any).url}\n\t\t\t\t\t\t\t\t\t<a\n\t\t\t\t\t\t\t\t\t\thref={(attachment as any).url}\n\t\t\t\t\t\t\t\t\t\ttarget=\"_blank\"\n\t\t\t\t\t\t\t\t\t\tclass=\"ml-1 shrink-0 font-semibold text-brand-blue underline hover:opacity-80\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t[Test Link]\n\t\t\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t{:else}\n\t\t\t\t\t\t\t<span class=\"text-emerald-400\">✓</span>\n\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t<button\n\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\tonclick={() => removeAttachment(index)}\n\t\t\t\t\t\t\tclass=\"ml-1 font-bold text-brand-text-muted hover:text-brand-text\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t×\n\t\t\t\t\t\t</button>\n\t\t\t\t\t</div>\n\t\t\t\t{/each}\n\t\t\t</div>\n\t\t{/if}\n\t\t{#if searchMode && searchModels.length > 0}\n\t\t\t<!-- Model picker for search mode. Lets the user override the search\n\t\t\t folder's default model before pressing Search. -->\n\t\t\t<div class=\"mb-2 flex items-center gap-2\">\n\t\t\t\t<label\n\t\t\t\t\tfor=\"search-model\"\n\t\t\t\t\tclass=\"text-xs font-medium text-brand-text-muted\">Model</label\n\t\t\t\t>\n\t\t\t\t<select\n\t\t\t\t\tid=\"search-model\"\n\t\t\t\t\tbind:value={searchModel}\n\t\t\t\t\tdisabled={effectivelyDisabled}\n\t\t\t\t\tclass=\"min-w-0 flex-1 rounded-lg border border-brand-border bg-brand-surface-2 px-2 py-1.5 text-xs text-brand-text focus:border-brand-blue focus:outline-none disabled:opacity-50\"\n\t\t\t\t>\n\t\t\t\t\t{#each searchModels as m}\n\t\t\t\t\t\t<option value={m.value}>{m.label}</option>\n\t\t\t\t\t{/each}\n\t\t\t\t</select>\n\t\t\t</div>\n\t\t{/if}\n\t\t<form\n\t\t\tonsubmit={(e) => {\n\t\t\t\te.preventDefault();\n\t\t\t\thandleSend();\n\t\t\t}}\n\t\t\tclass=\"flex items-stretch gap-3\"\n\t\t>\n\t\t\t<div class=\"min-w-0 flex-1\">\n\t\t\t\t<textarea\n\t\t\t\t\tbind:this={textarea}\n\t\t\t\t\tbind:value={text}\n\t\t\t\t\tonkeydown={handleKeydown}\n\t\t\t\t\tdisabled={effectivelyDisabled}\n\t\t\t\t\trows={1}\n\t\t\t\t\tplaceholder={searchMode\n\t\t\t\t\t\t? (placeholder ?? 'Search the web...')\n\t\t\t\t\t\t: !connected\n\t\t\t\t\t\t\t? appState.connecting\n\t\t\t\t\t\t\t\t? 'Reconnecting to remote server...'\n\t\t\t\t\t\t\t\t: 'Disconnected - cannot send'\n\t\t\t\t\t\t\t: streaming\n\t\t\t\t\t\t\t\t? 'Agent is working, Steer to interrupt...'\n\t\t\t\t\t\t\t\t: readOnly\n\t\t\t\t\t\t\t\t\t? 'Read-only mode'\n\t\t\t\t\t\t\t\t\t: !sessionInfo.sessionId\n\t\t\t\t\t\t\t\t\t\t? 'Select a session first...'\n\t\t\t\t\t\t\t\t\t\t: 'Type a message...'}\n\t\t\t\t\tclass=\"h-full max-h-48 min-h-[120px] w-full resize-none overflow-y-auto rounded-lg border border-brand-border bg-brand-surface-2 px-4 py-3 leading-relaxed text-brand-text placeholder-brand-text-muted focus:border-brand-blue focus:outline-none disabled:opacity-50\"\n\t\t\t\t></textarea>\n\t\t\t</div>\n\n\t\t\t<div class=\"flex w-[80px] shrink-0 flex-col justify-end gap-2\">\n\t\t\t\t{#if showAttach && !searchMode}\n\t\t\t\t\t<button\n\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\tonclick={() => {\n\t\t\t\t\t\t\t// Mark the picker active before it opens so the page-hidden\n\t\t\t\t\t\t\t// suspend timer doesn't tear down the session while the user\n\t\t\t\t\t\t\t// takes a photo / browses files.\n\t\t\t\t\t\t\tbeginFilePicker();\n\t\t\t\t\t\t\tfileInput?.click();\n\t\t\t\t\t\t}}\n\t\t\t\t\t\tdisabled={effectivelyDisabled}\n\t\t\t\t\t\tclass=\"flex h-[40px] w-full items-center justify-center rounded-lg border border-brand-border bg-brand-surface-2 text-brand-text-muted transition-colors hover:bg-brand-surface-3 hover:text-brand-text disabled:cursor-not-allowed disabled:opacity-50\"\n\t\t\t\t\t\ttitle=\"Attach file (image or document)\"\n\t\t\t\t\t>\n\t\t\t\t\t\t📎\n\t\t\t\t\t</button>\n\t\t\t\t\t<input\n\t\t\t\t\t\tbind:this={fileInput}\n\t\t\t\t\t\ttype=\"file\"\n\t\t\t\t\t\tmultiple\n\t\t\t\t\t\tonchange={handleFileChange}\n\t\t\t\t\t\tclass=\"hidden\"\n\t\t\t\t\t/>\n\t\t\t\t{/if}\n\t\t\t\t<div class=\"flex w-full justify-center\">\n\t\t\t\t\t<SpeechButton\n\t\t\t\t\t\tbind:text\n\t\t\t\t\t\tdisabled={effectivelyDisabled}\n\t\t\t\t\t\tonSend={handleSend}\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t\t<button\n\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\tdisabled={!canSend}\n\t\t\t\t\ttitle={!searchMode && streaming\n\t\t\t\t\t\t? 'Steer the agent now (injected at the next step, before the next model call)'\n\t\t\t\t\t\t: undefined}\n\t\t\t\t\tclass=\"flex h-[40px] w-full items-center justify-center rounded-lg bg-gradient-to-r from-brand-cyan to-brand-blue text-xs font-medium text-brand-text transition-all hover:opacity-90 disabled:cursor-not-allowed disabled:bg-brand-surface-3 disabled:from-brand-surface-3 disabled:to-brand-surface-3 disabled:opacity-50\"\n\t\t\t\t>\n\t\t\t\t\t{#if searchMode}\n\t\t\t\t\t\t{submitLabel ?? 'Search'}\n\t\t\t\t\t{:else if streaming}\n\t\t\t\t\t\tSteer\n\t\t\t\t\t{:else}\n\t\t\t\t\t\tSend\n\t\t\t\t\t{/if}\n\t\t\t\t</button>\n\t\t\t</div>\n\t\t</form>\n\n\t\t<div\n\t\t\tclass=\"mt-2 flex items-center justify-between px-1 text-[11px] text-brand-text-muted select-none\"\n\t\t>\n\t\t\t<label\n\t\t\t\tclass=\"flex cursor-pointer items-center gap-1.5 hover:text-brand-text\"\n\t\t\t>\n\t\t\t\t<input\n\t\t\t\t\ttype=\"checkbox\"\n\t\t\t\t\tchecked={enterToSend}\n\t\t\t\t\tonchange={toggleEnterToSend}\n\t\t\t\t\tclass=\"rounded border-brand-border bg-brand-surface-2 text-brand-blue focus:ring-0 focus:ring-offset-0\"\n\t\t\t\t/>\n\t\t\t\t<span>Press Enter to send</span>\n\t\t\t</label>\n\t\t\t<div class=\"flex items-center gap-3\">\n\t\t\t\t<button\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t\tonclick={() => (isCollapsed = true)}\n\t\t\t\t\tclass=\"rounded bg-brand-surface-3/50 px-2 py-0.5 text-xs text-brand-text-muted transition-colors hover:bg-brand-surface-3 hover:text-brand-text\"\n\t\t\t\t>\n\t\t\t\t\tCollapse ▽\n\t\t\t\t</button>\n\t\t\t\t{#if !enterToSend}\n\t\t\t\t\t<span class=\"hidden font-mono opacity-60 sm:inline\">\n\t\t\t\t\t\tShift+Enter to send\n\t\t\t\t\t</span>\n\t\t\t\t{/if}\n\t\t\t</div>\n\t\t</div>\n\t{/if}\n</div>\n","<script lang=\"ts\">\n\timport {\n\t\tsessionFolders,\n\t\treadOnlySessionFolders,\n\t\tavailableModels,\n\t\tfetchSessions,\n\t\tfetchReadOnlySessions,\n\t\tfetchModels,\n\t\tfetchConfig,\n\t\tgitInitDefaultStore,\n\t\tcheckPath,\n\t\tautocompletePath,\n\t\tsetCurrentSession,\n\t\ttype ModelInfo,\n\t\ttype FolderWithSessions,\n\t} from '$lib/session-store';\n\n\t// When true, this browser shows the read-only sessions page: it sources from\n\t// the read-only folder list, hides the create form, and hides all delete\n\t// controls. Opening a session here is forced read-only by the server.\n\tlet {readOnly = false}: {readOnly?: boolean} = $props();\n\timport {\n\t\tjoinSession,\n\t\tswitchSession,\n\t\tcreateSession,\n\t\tleaveSession,\n\t\tactiveSessionInfo,\n\t\tisConnected,\n\t\tisLoadingSession,\n\t\tisResyncing,\n\t\tsessionError,\n\t\tdismissSessionError,\n\t\tdeleteSession,\n\t} from '$lib/wherever';\n\n\tlet folders = $derived(\n\t\treadOnly ? $readOnlySessionFolders.folders : $sessionFolders.folders,\n\t);\n\tlet loading = $derived(\n\t\treadOnly ? $readOnlySessionFolders.loading : $sessionFolders.loading,\n\t);\n\n\tfunction refresh() {\n\t\tif (readOnly) {\n\t\t\tfetchReadOnlySessions();\n\t\t} else {\n\t\t\tfetchSessions();\n\t\t}\n\t}\n\tlet currentSession = $derived($activeSessionInfo.sessionFile);\n\tlet connected = $derived($isConnected);\n\tlet loadingSession = $derived($isLoadingSession);\n\tlet resyncing = $derived($isResyncing);\n\tlet models = $derived($availableModels.models);\n\n\tlet expanded = $state<Record<string, boolean>>({});\n\tlet searchExpanded = $state<Record<string, boolean>>({});\n\tlet confirmingDelete = $state<string | null>(null);\n\tlet confirmingDeleteFolder = $state<string | null>(null);\n\tlet searchQuery = $state('');\n\tlet filteredFolders = $state<FolderWithSessions[]>([]);\n\n\t// Auto-fetch sessions on connect and periodically\n\t$effect(() => {\n\t\tif (connected) {\n\t\t\trefresh();\n\t\t\tif (!readOnly) {\n\t\t\t\tfetchModels();\n\t\t\t\tfetchConfig();\n\t\t\t}\n\t\t}\n\t});\n\n\tfunction matchesFilter(\n\t\tsession: (typeof folders)[number]['sessions'][number],\n\t\tfolderName: string,\n\t\tquery: string,\n\t): boolean {\n\t\tif (!query) return true;\n\t\tconst q = query.toLowerCase();\n\t\treturn (\n\t\t\t(session.name || '').toLowerCase().includes(q) ||\n\t\t\tsession.firstMessage.toLowerCase().includes(q) ||\n\t\t\tfolderName.toLowerCase().includes(q)\n\t\t);\n\t}\n\n\t$effect(() => {\n\t\tconst q = searchQuery;\n\t\tconst foldersArr = folders;\n\t\tif (!q) {\n\t\t\tfilteredFolders = foldersArr;\n\t\t\tsearchExpanded = {};\n\t\t} else {\n\t\t\tfilteredFolders = foldersArr\n\t\t\t\t.map((folder) => ({\n\t\t\t\t\t...folder,\n\t\t\t\t\tsessions: folder.sessions.filter(\n\t\t\t\t\t\t(s: (typeof folder)['sessions'][number]) =>\n\t\t\t\t\t\t\tmatchesFilter(s, folder.name, q),\n\t\t\t\t\t),\n\t\t\t\t}))\n\t\t\t\t.filter((folder) => folder.sessions.length > 0);\n\t\t}\n\t});\n\n\tfunction isFolderExpanded(folderPath: string): boolean {\n\t\tif (searchQuery) {\n\t\t\tif (searchExpanded[folderPath] !== undefined) {\n\t\t\t\treturn searchExpanded[folderPath];\n\t\t\t}\n\t\t\treturn true;\n\t\t} else {\n\t\t\treturn !!expanded[folderPath];\n\t\t}\n\t}\n\n\tfunction toggleFolder(path: string) {\n\t\tif (searchQuery) {\n\t\t\tsearchExpanded[path] = !isFolderExpanded(path);\n\t\t} else {\n\t\t\texpanded[path] = !isFolderExpanded(path);\n\t\t}\n\t}\n\n\tasync function handleDeleteSession(sessionPath: string) {\n\t\ttry {\n\t\t\tif (currentSession === sessionPath) {\n\t\t\t\tif (typeof window !== 'undefined') {\n\t\t\t\t\twindow.location.hash = '';\n\t\t\t\t}\n\t\t\t\tleaveSession();\n\t\t\t}\n\t\t\tawait deleteSession(sessionPath);\n\t\t\tif (confirmingDelete === sessionPath) {\n\t\t\t\tconfirmingDelete = null;\n\t\t\t}\n\t\t\tfetchSessions();\n\t\t} catch (err) {\n\t\t\tconsole.error('Failed to delete session:', err);\n\t\t}\n\t}\n\n\tasync function handleDeleteAllFolderSessions(folder: FolderWithSessions) {\n\t\ttry {\n\t\t\tconst sessionPaths = folder.sessions.map((s) => s.path);\n\t\t\tif (currentSession && sessionPaths.includes(currentSession)) {\n\t\t\t\tif (typeof window !== 'undefined') {\n\t\t\t\t\twindow.location.hash = '';\n\t\t\t\t}\n\t\t\t\tleaveSession();\n\t\t\t}\n\t\t\tawait Promise.all(folder.sessions.map((s) => deleteSession(s.path)));\n\t\t\tif (confirmingDeleteFolder === folder.path) {\n\t\t\t\tconfirmingDeleteFolder = null;\n\t\t\t}\n\t\t\tfetchSessions();\n\t\t} catch (err) {\n\t\t\tconsole.error('Failed to delete all sessions of folder:', err);\n\t\t}\n\t}\n\n\tfunction handleSessionClick(sessionPath: string) {\n\t\t// Tapping the already-active session (and not currently loading) is a no-op.\n\t\tif (currentSession === sessionPath && !loadingSession && !resyncing) return;\n\t\tdismissSessionError();\n\t\t// One atomic switch: leave the current session (if any) and load the target.\n\t\t// switchSession supersedes any in-flight load and rearms the load watchdog, so\n\t\t// a stuck/hung load never blocks tapping a different session, and the latest\n\t\t// tap always wins (no fragile leave -> setTimeout -> join gap).\n\t\tswitchSession(sessionPath);\n\t}\n\n\t// Collapsible Sidebar form state\n\tlet createFormOpen = $state(false);\n\tlet sidebarCwd = $state('');\n\tlet sidebarCompletions = $state<string[]>([]);\n\tlet sidebarInputFocused = $state(false);\n\tlet sidebarInputEl = $state<HTMLInputElement | null>(null);\n\tlet sidebarContainerEl = $state<HTMLDivElement | null>(null);\n\tlet lastCheckedSidebarPath = '';\n\tlet sidebarModel = $state('');\n\tlet sidebarGitInit = $state(false);\n\tlet userManualSidebarGitInit = $state<boolean | null>(null);\n\tlet sidebarCreateRemote = $state(true);\n\tlet sidebarRepoVisibility = $state<'private' | 'public'>('private');\n\tlet showSidebarGitConfirmModal = $state(false);\n\n\tlet defaultGitInit = $derived($gitInitDefaultStore);\n\n\t// Sync git init default\n\t$effect(() => {\n\t\tif (userManualSidebarGitInit === null) {\n\t\t\tsidebarGitInit = defaultGitInit;\n\t\t}\n\t});\n\n\tlet sidebarPathStatus = $state<{\n\t\texists: boolean | null;\n\t\tisGit: boolean;\n\t\tresolvedPath: string;\n\t\tmatchingRule: {provider: string; visibility: string} | null;\n\t}>({\n\t\texists: null,\n\t\tisGit: false,\n\t\tresolvedPath: '',\n\t\tmatchingRule: null,\n\t});\n\n\tlet isSidebarRemoteRepoCreation = $derived(\n\t\tsidebarPathStatus.exists !== true &&\n\t\t\tsidebarPathStatus.matchingRule &&\n\t\t\tsidebarCreateRemote,\n\t);\n\n\tlet sidebarPathCheckTimeout: ReturnType<typeof setTimeout> | null = null;\n\n\tasync function triggerSidebarCheck(pathValue: string, immediate = false) {\n\t\tif (sidebarPathCheckTimeout) clearTimeout(sidebarPathCheckTimeout);\n\n\t\tif (pathValue === lastCheckedSidebarPath && !immediate) return;\n\t\tlastCheckedSidebarPath = pathValue;\n\n\t\tif (!pathValue.trim()) {\n\t\t\tsidebarPathStatus = {\n\t\t\t\texists: null,\n\t\t\t\tisGit: false,\n\t\t\t\tresolvedPath: '',\n\t\t\t\tmatchingRule: null,\n\t\t\t};\n\t\t\tconst fetchEmpty = async () => {\n\t\t\t\tconst list = await autocompletePath('');\n\t\t\t\tsidebarCompletions = list || [];\n\t\t\t};\n\t\t\tif (immediate) {\n\t\t\t\tawait fetchEmpty();\n\t\t\t} else {\n\t\t\t\tsidebarPathCheckTimeout = setTimeout(fetchEmpty, 300);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tconst fetchFn = async () => {\n\t\t\tconst [res, list] = await Promise.all([\n\t\t\t\tcheckPath(pathValue),\n\t\t\t\tautocompletePath(pathValue),\n\t\t\t]);\n\t\t\tsidebarCompletions = list || [];\n\t\t\tif (res) {\n\t\t\t\tsidebarPathStatus = {\n\t\t\t\t\texists: res.exists,\n\t\t\t\t\tisGit: res.isGit,\n\t\t\t\t\tresolvedPath: res.resolvedPath,\n\t\t\t\t\tmatchingRule: (res as any).matchingRule || null,\n\t\t\t\t};\n\t\t\t\tif (!res.exists) {\n\t\t\t\t\tsidebarGitInit =\n\t\t\t\t\t\tuserManualSidebarGitInit !== null\n\t\t\t\t\t\t\t? userManualSidebarGitInit\n\t\t\t\t\t\t\t: defaultGitInit;\n\t\t\t\t\tsidebarCreateRemote = true; // reset to true for non-existing folders\n\t\t\t\t\tif ((res as any).matchingRule) {\n\t\t\t\t\t\tsidebarRepoVisibility = (res as any).matchingRule.visibility as\n\t\t\t\t\t\t\t| 'private'\n\t\t\t\t\t\t\t| 'public';\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tsidebarPathStatus = {\n\t\t\t\t\texists: null,\n\t\t\t\t\tisGit: false,\n\t\t\t\t\tresolvedPath: '',\n\t\t\t\t\tmatchingRule: null,\n\t\t\t\t};\n\t\t\t}\n\t\t};\n\n\t\tif (immediate) {\n\t\t\tawait fetchFn();\n\t\t} else {\n\t\t\tsidebarPathCheckTimeout = setTimeout(fetchFn, 300);\n\t\t}\n\t}\n\n\t$effect(() => {\n\t\tconst pathValue = sidebarCwd;\n\t\ttriggerSidebarCheck(pathValue, false);\n\t});\n\n\t// Select default model if any\n\t$effect(() => {\n\t\tif (models.length > 0 && !sidebarModel) {\n\t\t\tconst defaultModel = models.find((m: ModelInfo) => m.isDefault);\n\t\t\tif (defaultModel) {\n\t\t\t\tsidebarModel = `${defaultModel.provider}:${defaultModel.modelId}`;\n\t\t\t} else {\n\t\t\t\tsidebarModel = `${models[0].provider}:${models[0].modelId}`;\n\t\t\t}\n\t\t}\n\t});\n\n\tfunction handleSidebarCreateSession() {\n\t\tif (!sidebarCwd.trim()) return;\n\t\tif (sidebarPathStatus.exists === true) {\n\t\t\tsidebarGitInit = false; // toggled off by default in modal\n\t\t\tsidebarCreateRemote = false; // toggled off by default in modal\n\t\t\tif (sidebarPathStatus.matchingRule) {\n\t\t\t\tsidebarRepoVisibility = sidebarPathStatus.matchingRule.visibility as\n\t\t\t\t\t| 'private'\n\t\t\t\t\t| 'public';\n\t\t\t}\n\t\t\tshowSidebarGitConfirmModal = true;\n\t\t} else {\n\t\t\tdismissSessionError();\n\t\t\tconst cwd = sidebarCwd.trim();\n\t\t\tconst model = sidebarModel || undefined;\n\t\t\tconst gitInit = sidebarGitInit;\n\t\t\tconst createRemote = sidebarPathStatus.matchingRule\n\t\t\t\t? sidebarCreateRemote\n\t\t\t\t: undefined;\n\t\t\tconst repoVisibility = sidebarPathStatus.matchingRule\n\t\t\t\t? sidebarRepoVisibility\n\t\t\t\t: undefined;\n\n\t\t\t// Reset state\n\t\t\tsidebarCwd = '';\n\t\t\tcreateFormOpen = false;\n\n\t\t\tif (currentSession) {\n\t\t\t\tleaveSession();\n\t\t\t\tsetTimeout(() => {\n\t\t\t\t\tcreateSession(cwd, model, gitInit, createRemote, repoVisibility);\n\t\t\t\t}, 100);\n\t\t\t} else {\n\t\t\t\tcreateSession(cwd, model, gitInit, createRemote, repoVisibility);\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction handleSidebarConfirmModalSubmit() {\n\t\tshowSidebarGitConfirmModal = false;\n\t\tdismissSessionError();\n\t\tconst cwd = sidebarCwd.trim();\n\t\tconst model = sidebarModel || undefined;\n\t\tconst gitInit = sidebarGitInit;\n\t\tconst createRemote = sidebarPathStatus.matchingRule\n\t\t\t? sidebarCreateRemote\n\t\t\t: undefined;\n\t\tconst repoVisibility = sidebarPathStatus.matchingRule\n\t\t\t? sidebarRepoVisibility\n\t\t\t: undefined;\n\n\t\t// Reset state\n\t\tsidebarCwd = '';\n\t\tcreateFormOpen = false;\n\n\t\tif (currentSession) {\n\t\t\tleaveSession();\n\t\t\tsetTimeout(() => {\n\t\t\t\tcreateSession(cwd, model, gitInit, createRemote, repoVisibility);\n\t\t\t}, 100);\n\t\t} else {\n\t\t\tcreateSession(cwd, model, gitInit, createRemote, repoVisibility);\n\t\t}\n\t}\n\n\t// New session picker state\n\tlet newSessionPicker = $state<{\n\t\topen: boolean;\n\t\tfolderPath: string;\n\t\tselected: string;\n\t}>({\n\t\topen: false,\n\t\tfolderPath: '',\n\t\tselected: '',\n\t});\n\n\tfunction openNewSessionPicker(folderPath: string) {\n\t\tconst defaultModel = models.find((m: ModelInfo) => m.isDefault);\n\t\tnewSessionPicker = {\n\t\t\topen: true,\n\t\t\tfolderPath,\n\t\t\tselected: defaultModel\n\t\t\t\t? `${defaultModel.provider}:${defaultModel.modelId}`\n\t\t\t\t: '',\n\t\t};\n\t}\n\n\tfunction closeNewSessionPicker() {\n\t\tnewSessionPicker.open = false;\n\t}\n\n\tfunction handleCreateSession() {\n\t\tif (!newSessionPicker.open) return;\n\t\tdismissSessionError();\n\t\tconst folderPath = newSessionPicker.folderPath;\n\t\tconst model = newSessionPicker.selected || undefined;\n\t\tcloseNewSessionPicker();\n\t\tif (currentSession) {\n\t\t\tleaveSession();\n\t\t\tsetTimeout(() => {\n\t\t\t\tcreateSession(folderPath, model);\n\t\t\t}, 100);\n\t\t} else {\n\t\t\tcreateSession(folderPath, model);\n\t\t}\n\t}\n\n\tfunction formatRelative(timeStr: string): string {\n\t\tconst diff = Date.now() - new Date(timeStr).getTime();\n\t\tconst mins = Math.floor(diff / 60000);\n\t\tif (mins < 1) return 'just now';\n\t\tif (mins < 60) return `${mins}m ago`;\n\t\tconst hours = Math.floor(mins / 60);\n\t\tif (hours < 24) return `${hours}h ago`;\n\t\tconst days = Math.floor(hours / 24);\n\t\treturn `${days}d ago`;\n\t}\n\n\tfunction truncate(text: string, max: number = 40): string {\n\t\treturn text.length > max ? text.slice(0, max) + '...' : text;\n\t}\n</script>\n\n<div class=\"flex h-full flex-col\">\n\t<div class=\"border-b border-brand-border/50 p-2\">\n\t\t<div class=\"flex gap-1.5\">\n\t\t\t<input\n\t\t\t\ttype=\"text\"\n\t\t\t\tplaceholder=\"Filter sessions...\"\n\t\t\t\tvalue={searchQuery}\n\t\t\t\toninput={(e) => (searchQuery = e.currentTarget.value)}\n\t\t\t\tclass=\"min-w-0 flex-1 rounded border border-brand-border bg-brand-surface-2 px-2 py-1.5 text-xs text-brand-text placeholder-brand-text-muted focus:border-brand-blue focus:outline-none\"\n\t\t\t/>\n\t\t\t<button\n\t\t\t\ttype=\"button\"\n\t\t\t\tonclick={() => refresh()}\n\t\t\t\tclass=\"flex shrink-0 items-center justify-center rounded border border-brand-border bg-brand-surface-2 px-1.5 py-1.5 text-brand-text-muted transition-colors hover:bg-brand-surface-3 hover:text-brand-text\"\n\t\t\t\ttitle=\"Refresh session list\"\n\t\t\t>\n\t\t\t\t<span class={loading ? 'animate-spin' : ''}>↻</span>\n\t\t\t</button>\n\t\t</div>\n\t</div>\n\n\t<div class=\"flex-1 overflow-y-auto\">\n\t\t<!-- Collapsible Create New Session Section (hidden in read-only mode) -->\n\t\t{#if !readOnly}\n\t\t\t<div class=\"border-b border-brand-border/50 bg-brand-surface/10\">\n\t\t\t\t<button\n\t\t\t\t\tonclick={() => (createFormOpen = !createFormOpen)}\n\t\t\t\t\tclass=\"flex w-full items-center justify-between px-3 py-2 text-left text-xs font-semibold text-brand-blue transition-colors hover:bg-brand-surface-3/30\"\n\t\t\t\t>\n\t\t\t\t\t<span\n\t\t\t\t\t\t>{createFormOpen\n\t\t\t\t\t\t\t? '▼ Close Create Session'\n\t\t\t\t\t\t\t: '✚ Create New Session'}</span\n\t\t\t\t\t>\n\t\t\t\t</button>\n\n\t\t\t\t{#if createFormOpen}\n\t\t\t\t\t<form\n\t\t\t\t\t\tonsubmit={(e) => {\n\t\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t\t\thandleSidebarCreateSession();\n\t\t\t\t\t\t}}\n\t\t\t\t\t\tclass=\"space-y-2.5 border-t border-brand-border/30 bg-brand-surface/30 p-3\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<div>\n\t\t\t\t\t\t\t<label\n\t\t\t\t\t\t\t\tclass=\"mb-1 block text-[10px] font-bold tracking-wider text-brand-text-muted uppercase\"\n\t\t\t\t\t\t\t\tfor=\"sidebar-folder\">Folder Path</label\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<div class=\"relative\" bind:this={sidebarContainerEl}>\n\t\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\t\tbind:this={sidebarInputEl}\n\t\t\t\t\t\t\t\t\tid=\"sidebar-folder\"\n\t\t\t\t\t\t\t\t\ttype=\"text\"\n\t\t\t\t\t\t\t\t\tautocomplete=\"off\"\n\t\t\t\t\t\t\t\t\tspellcheck=\"false\"\n\t\t\t\t\t\t\t\t\tplaceholder=\"e.g. ~/projects/my-new-app\"\n\t\t\t\t\t\t\t\t\tbind:value={sidebarCwd}\n\t\t\t\t\t\t\t\t\tonfocus={() => {\n\t\t\t\t\t\t\t\t\t\tsidebarInputFocused = true;\n\t\t\t\t\t\t\t\t\t\ttriggerSidebarCheck(sidebarCwd, true);\n\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\tonblur={(e) => {\n\t\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\t\tsidebarContainerEl &&\n\t\t\t\t\t\t\t\t\t\t\tsidebarContainerEl.contains(e.relatedTarget as Node)\n\t\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tsidebarInputFocused = false;\n\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\tonkeydown={(e) => {\n\t\t\t\t\t\t\t\t\t\tif (e.key === 'Escape') {\n\t\t\t\t\t\t\t\t\t\t\tsidebarInputFocused = false;\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\tclass=\"w-full rounded border px-2 py-1 text-xs text-brand-text placeholder-brand-text-muted transition-all duration-200 focus:outline-none {isSidebarRemoteRepoCreation\n\t\t\t\t\t\t\t\t\t\t? 'border-emerald-500/80 bg-emerald-500/10 focus:border-emerald-400 focus:ring-1 focus:ring-emerald-400/30'\n\t\t\t\t\t\t\t\t\t\t: 'border-brand-border bg-brand-dark/60 focus:border-brand-blue'}\"\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t{#if sidebarInputFocused && sidebarCompletions.length > 0}\n\t\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\t\tclass=\"absolute right-0 left-0 z-50 mt-1 max-h-40 overflow-y-auto rounded border border-brand-border bg-brand-surface-2 py-1 shadow-xl\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{#each sidebarCompletions as completion}\n\t\t\t\t\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\t\t\t\t\tonclick={() => {\n\t\t\t\t\t\t\t\t\t\t\t\t\tsidebarCwd = completion;\n\t\t\t\t\t\t\t\t\t\t\t\t\ttriggerSidebarCheck(completion, true);\n\t\t\t\t\t\t\t\t\t\t\t\t\tsidebarInputEl?.focus();\n\t\t\t\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\t\t\t\tclass=\"block w-full px-2.5 py-1 text-left text-xs text-brand-text transition-colors hover:bg-brand-surface-3 hover:text-brand-text\"\n\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t{completion}\n\t\t\t\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t\t\t\t{/each}\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t{#if sidebarPathStatus.exists === true}\n\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\tclass=\"mt-1 block text-[10px] font-medium text-yellow-400\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t📁 Folder already exists.\n\t\t\t\t\t\t\t\t\t{#if sidebarPathStatus.isGit}\n\t\t\t\t\t\t\t\t\t\t<span class=\"ml-1 font-semibold text-emerald-400\"\n\t\t\t\t\t\t\t\t\t\t\t>(Git repo)</span\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t</div>\n\n\t\t\t\t\t\t<div>\n\t\t\t\t\t\t\t<label\n\t\t\t\t\t\t\t\tclass=\"mb-1 block text-[10px] font-bold tracking-wider text-brand-text-muted uppercase\"\n\t\t\t\t\t\t\t\tfor=\"sidebar-model\">Model</label\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{#if models.length > 0}\n\t\t\t\t\t\t\t\t<select\n\t\t\t\t\t\t\t\t\tid=\"sidebar-model\"\n\t\t\t\t\t\t\t\t\tbind:value={sidebarModel}\n\t\t\t\t\t\t\t\t\tclass=\"w-full rounded border border-brand-border bg-brand-dark/60 px-2 py-1 text-xs text-brand-text focus:border-brand-blue focus:outline-none\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{#each models as model}\n\t\t\t\t\t\t\t\t\t\t<option value={`${model.provider}:${model.modelId}`}>\n\t\t\t\t\t\t\t\t\t\t\t{model.label}{model.isDefault ? ' (default)' : ''}\n\t\t\t\t\t\t\t\t\t\t</option>\n\t\t\t\t\t\t\t\t\t{/each}\n\t\t\t\t\t\t\t\t</select>\n\t\t\t\t\t\t\t{:else}\n\t\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\t\tid=\"sidebar-model\"\n\t\t\t\t\t\t\t\t\ttype=\"text\"\n\t\t\t\t\t\t\t\t\tbind:value={sidebarModel}\n\t\t\t\t\t\t\t\t\tplaceholder=\"provider:model\"\n\t\t\t\t\t\t\t\t\tclass=\"w-full rounded border border-brand-border bg-brand-dark/60 px-2 py-1 text-xs text-brand-text placeholder-brand-text-muted focus:border-brand-blue focus:outline-none\"\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t</div>\n\n\t\t\t\t\t\t{#if sidebarPathStatus.exists !== true && sidebarPathStatus.matchingRule}\n\t\t\t\t\t\t\t<div class=\"space-y-1 py-0.5\">\n\t\t\t\t\t\t\t\t<div class=\"flex items-center gap-1.5\">\n\t\t\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\t\t\tid=\"sidebar-create-remote\"\n\t\t\t\t\t\t\t\t\t\ttype=\"checkbox\"\n\t\t\t\t\t\t\t\t\t\tbind:checked={sidebarCreateRemote}\n\t\t\t\t\t\t\t\t\t\tclass=\"h-3.5 w-3.5 rounded border-brand-border bg-brand-surface-2 text-brand-blue focus:ring-brand-blue focus:ring-offset-brand-surface\"\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t<label\n\t\t\t\t\t\t\t\t\t\tfor=\"sidebar-create-remote\"\n\t\t\t\t\t\t\t\t\t\tclass=\"cursor-pointer text-xs text-brand-text select-none\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\tCreate remote {sidebarPathStatus.matchingRule.provider} repository\n\t\t\t\t\t\t\t\t\t</label>\n\t\t\t\t\t\t\t\t</div>\n\n\t\t\t\t\t\t\t\t{#if sidebarCreateRemote}\n\t\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\t\tclass=\"flex items-center gap-3 pl-5 text-[10px] text-brand-text-muted\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t<span>Visibility:</span>\n\t\t\t\t\t\t\t\t\t\t<label\n\t\t\t\t\t\t\t\t\t\t\tclass=\"flex cursor-pointer items-center gap-1 transition-colors select-none hover:text-brand-text\"\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\t\t\t\t\ttype=\"radio\"\n\t\t\t\t\t\t\t\t\t\t\t\tname=\"sidebar-visibility\"\n\t\t\t\t\t\t\t\t\t\t\t\tvalue=\"private\"\n\t\t\t\t\t\t\t\t\t\t\t\tbind:group={sidebarRepoVisibility}\n\t\t\t\t\t\t\t\t\t\t\t\tclass=\"border-brand-border bg-brand-surface-2 text-brand-blue focus:ring-brand-blue\"\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\tPrivate\n\t\t\t\t\t\t\t\t\t\t</label>\n\t\t\t\t\t\t\t\t\t\t<label\n\t\t\t\t\t\t\t\t\t\t\tclass=\"flex cursor-pointer items-center gap-1 transition-colors select-none hover:text-brand-text\"\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\t\t\t\t\ttype=\"radio\"\n\t\t\t\t\t\t\t\t\t\t\t\tname=\"sidebar-visibility\"\n\t\t\t\t\t\t\t\t\t\t\t\tvalue=\"public\"\n\t\t\t\t\t\t\t\t\t\t\t\tbind:group={sidebarRepoVisibility}\n\t\t\t\t\t\t\t\t\t\t\t\tclass=\"border-brand-border bg-brand-surface-2 text-brand-blue focus:ring-brand-blue\"\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\tPublic\n\t\t\t\t\t\t\t\t\t\t</label>\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t{/if}\n\n\t\t\t\t\t\t{#if sidebarPathStatus.exists !== true && (!sidebarPathStatus.matchingRule || !sidebarCreateRemote)}\n\t\t\t\t\t\t\t<div class=\"flex items-center gap-1.5 py-0.5\">\n\t\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\t\tid=\"sidebar-git-init\"\n\t\t\t\t\t\t\t\t\ttype=\"checkbox\"\n\t\t\t\t\t\t\t\t\tbind:checked={sidebarGitInit}\n\t\t\t\t\t\t\t\t\tonchange={(e) => {\n\t\t\t\t\t\t\t\t\t\tuserManualSidebarGitInit = e.currentTarget.checked;\n\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\tclass=\"h-3.5 w-3.5 rounded border-brand-border bg-brand-surface-2 text-brand-blue focus:ring-brand-blue focus:ring-offset-brand-surface\"\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t<label\n\t\t\t\t\t\t\t\t\tfor=\"sidebar-git-init\"\n\t\t\t\t\t\t\t\t\tclass=\"cursor-pointer text-xs text-brand-text select-none\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\tInitialize Git repository\n\t\t\t\t\t\t\t\t</label>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t{/if}\n\n\t\t\t\t\t\t<button\n\t\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\t\tdisabled={!sidebarCwd.trim()}\n\t\t\t\t\t\t\tclass=\"w-full rounded bg-gradient-to-r from-brand-cyan to-brand-blue py-1.5 text-xs font-semibold text-brand-text transition-all hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-50\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\tCreate Session\n\t\t\t\t\t\t</button>\n\t\t\t\t\t</form>\n\t\t\t\t{/if}\n\t\t\t</div>\n\t\t{/if}\n\n\t\t{#if loading && filteredFolders.length === 0}\n\t\t\t<div class=\"p-4 text-center text-brand-text-muted\">\n\t\t\t\t<div\n\t\t\t\t\tclass=\"inline-block h-4 w-4 animate-spin rounded-full border-2 border-brand-text-muted border-t-transparent\"\n\t\t\t\t></div>\n\t\t\t\t<span class=\"ml-2 text-sm\">Loading sessions...</span>\n\t\t\t</div>\n\t\t{:else if filteredFolders.length === 0}\n\t\t\t<div class=\"p-4 text-center text-sm text-brand-text-muted\">\n\t\t\t\t{searchQuery ? 'No sessions match your filter' : 'No sessions found'}\n\t\t\t</div>\n\t\t{:else}\n\t\t\t{#each filteredFolders as folder (folder.path)}\n\t\t\t\t<div class=\"border-b border-brand-border/50\">\n\t\t\t\t\t<button\n\t\t\t\t\t\tonclick={() => toggleFolder(folder.path)}\n\t\t\t\t\t\tclass=\"flex w-full items-center gap-2 px-3 py-2 text-left transition-colors hover:bg-brand-surface-3/50\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<span\n\t\t\t\t\t\t\tclass=\"text-xs text-brand-text-muted transition-transform {isFolderExpanded(\n\t\t\t\t\t\t\t\tfolder.path,\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t? 'rotate-90'\n\t\t\t\t\t\t\t\t: ''}\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t▶\n\t\t\t\t\t\t</span>\n\t\t\t\t\t\t<div class=\"min-w-0 flex-1\">\n\t\t\t\t\t\t\t<div class=\"truncate text-sm font-medium text-brand-text\">\n\t\t\t\t\t\t\t\t{folder.name}\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t<div class=\"truncate text-[10px] text-brand-text-muted\">\n\t\t\t\t\t\t\t\t{folder.path}\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<span class=\"text-xs text-brand-text-muted\"\n\t\t\t\t\t\t\t>{folder.sessions.length}</span\n\t\t\t\t\t\t>\n\t\t\t\t\t</button>\n\n\t\t\t\t\t{#if isFolderExpanded(folder.path)}\n\t\t\t\t\t\t<div class=\"px-3 pb-2\">\n\t\t\t\t\t\t\t{#if !readOnly}\n\t\t\t\t\t\t\t\t<div class=\"mb-1.5 flex items-center justify-between\">\n\t\t\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\t\t\tonclick={() => openNewSessionPicker(folder.path)}\n\t\t\t\t\t\t\t\t\t\tclass=\"rounded px-2 py-1 text-left text-xs text-brand-blue transition-colors hover:bg-brand-surface-3/50 hover:opacity-90\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t+ New Session Here\n\t\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t\t\t<div class=\"flex-shrink-0\">\n\t\t\t\t\t\t\t\t\t\t{#if confirmingDeleteFolder === folder.path}\n\t\t\t\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\t\t\t\tclass=\"flex items-center gap-1 rounded border border-red-500/30 bg-brand-surface-2/80 px-1 py-0.5\"\n\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\t\t\t\t\t\tonclick={(e) => {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\te.stopPropagation();\n\t\t\t\t\t\t\t\t\t\t\t\t\t\thandleDeleteAllFolderSessions(folder);\n\t\t\t\t\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\t\t\t\t\tclass=\"px-1.5 text-xs font-bold text-rose-400 hover:text-rose-300 focus:outline-none\"\n\t\t\t\t\t\t\t\t\t\t\t\t\ttitle=\"Confirm Delete All\"\n\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t\tDelete All?\n\t\t\t\t\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\t\t\t\t\t\tonclick={(e) => {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\te.stopPropagation();\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tconfirmingDeleteFolder = null;\n\t\t\t\t\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\t\t\t\t\tclass=\"px-1.5 text-[10px] text-brand-text-muted hover:text-brand-text focus:outline-none\"\n\t\t\t\t\t\t\t\t\t\t\t\t\ttitle=\"Cancel\"\n\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t\t✕\n\t\t\t\t\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t{:else}\n\t\t\t\t\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\t\t\t\t\tonclick={(e) => {\n\t\t\t\t\t\t\t\t\t\t\t\t\te.stopPropagation();\n\t\t\t\t\t\t\t\t\t\t\t\t\tconfirmingDeleteFolder = folder.path;\n\t\t\t\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\t\t\t\tclass=\"rounded px-2 py-1 text-xs text-brand-text-muted transition-colors hover:bg-brand-surface-3/50 hover:text-rose-400 focus:outline-none\"\n\t\t\t\t\t\t\t\t\t\t\t\ttitle=\"Delete all sessions in this folder\"\n\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\tDelete All\n\t\t\t\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t{/if}\n\n\t\t\t\t\t\t\t{#each folder.sessions as session (session.path)}\n\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\tclass=\"group flex w-full items-center gap-2 rounded px-2 py-1.5 text-left transition-colors hover:bg-brand-surface-3/30 {currentSession ===\n\t\t\t\t\t\t\t\t\tsession.path\n\t\t\t\t\t\t\t\t\t\t? 'bg-brand-surface-3'\n\t\t\t\t\t\t\t\t\t\t: ''}\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<a\n\t\t\t\t\t\t\t\t\t\thref=\"#{encodeURIComponent(session.id)}\"\n\t\t\t\t\t\t\t\t\t\tonclick={(e) => {\n\t\t\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\t\t\te.button === 0 &&\n\t\t\t\t\t\t\t\t\t\t\t\t!e.ctrlKey &&\n\t\t\t\t\t\t\t\t\t\t\t\t!e.metaKey &&\n\t\t\t\t\t\t\t\t\t\t\t\t!e.altKey &&\n\t\t\t\t\t\t\t\t\t\t\t\t!e.shiftKey\n\t\t\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t\t\t\t\t\t\t\thandleSessionClick(session.path);\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\t\tclass=\"flex min-w-0 flex-1 items-center gap-2 text-left no-underline\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{#if session.isActive}\n\t\t\t\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\t\t\t\tclass=\"h-2 w-2 flex-shrink-0 rounded-full bg-emerald-500\"\n\t\t\t\t\t\t\t\t\t\t\t></span>\n\t\t\t\t\t\t\t\t\t\t{:else}\n\t\t\t\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\t\t\t\tclass=\"h-2 w-2 flex-shrink-0 rounded-full bg-brand-surface-3\"\n\t\t\t\t\t\t\t\t\t\t\t></span>\n\t\t\t\t\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t\t\t\t\t<div class=\"min-w-0 flex-1\">\n\t\t\t\t\t\t\t\t\t\t\t<div class=\"truncate text-xs text-brand-text\">\n\t\t\t\t\t\t\t\t\t\t\t\t{session.name ||\n\t\t\t\t\t\t\t\t\t\t\t\t\ttruncate(session.firstMessage) ||\n\t\t\t\t\t\t\t\t\t\t\t\t\t'Empty session'}\n\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t\t<div class=\"text-xs text-brand-text-muted\">\n\t\t\t\t\t\t\t\t\t\t\t\t{formatRelative(session.modified)} · {session.messageCount}\n\t\t\t\t\t\t\t\t\t\t\t\tmsgs\n\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t{#if session.clientCount > 0}\n\t\t\t\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\t\t\t\tclass=\"rounded bg-brand-surface-3 px-1.5 py-0.5 text-xs text-brand-text\"\n\t\t\t\t\t\t\t\t\t\t\t\t>{session.clientCount}</span\n\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t\t\t\t</a>\n\n\t\t\t\t\t\t\t\t\t<!-- Delete button with confirm state (hidden in read-only mode) -->\n\t\t\t\t\t\t\t\t\t{#if !readOnly}\n\t\t\t\t\t\t\t\t\t\t<div class=\"flex-shrink-0\">\n\t\t\t\t\t\t\t\t\t\t\t{#if confirmingDelete === session.path}\n\t\t\t\t\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\t\t\t\t\tclass=\"flex items-center gap-1 rounded border border-red-500/30 bg-brand-surface-2/80 px-1 py-0.5\"\n\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tonclick={(e) => {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\te.stopPropagation();\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\thandleDeleteSession(session.path);\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tclass=\"px-1.5 text-xs font-bold text-rose-400 hover:text-rose-300 focus:outline-none\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\ttitle=\"Confirm Delete\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t❓\n\t\t\t\t\t\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tonclick={(e) => {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\te.stopPropagation();\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tconfirmingDelete = null;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tclass=\"px-1.5 text-[10px] text-brand-text-muted hover:text-brand-text focus:outline-none\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\ttitle=\"Cancel\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t✕\n\t\t\t\t\t\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t\t{:else}\n\t\t\t\t\t\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\t\t\t\t\t\tonclick={(e) => {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\te.stopPropagation();\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tconfirmingDelete = session.path;\n\t\t\t\t\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\t\t\t\t\tclass=\"p-1 text-xs text-brand-text-muted transition-opacity hover:text-rose-400 focus:outline-none md:opacity-0 md:group-hover:opacity-100\"\n\t\t\t\t\t\t\t\t\t\t\t\t\ttitle=\"Delete session\"\n\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t\t✕\n\t\t\t\t\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t{/each}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t{/if}\n\t\t\t\t</div>\n\t\t\t{/each}\n\t\t{/if}\n\t</div>\n</div>\n\n<!-- New Session Picker Dialog -->\n{#if newSessionPicker.open}\n\t<!-- svelte-ignore a11y_click_events_have_key_events -->\n\t<div\n\t\tclass=\"fixed inset-0 z-50 flex items-center justify-center bg-brand-dark/60\"\n\t\trole=\"presentation\"\n\t\tonclick={closeNewSessionPicker}\n\t>\n\t\t<div\n\t\t\tclass=\"w-80 rounded-lg border border-brand-border bg-brand-surface-2 p-6\"\n\t\t\trole=\"dialog\"\n\t\t\ttabindex=\"-1\"\n\t\t\tonclick={(e) => e.stopPropagation()}\n\t\t>\n\t\t\t<h3 class=\"mb-4 text-sm font-bold text-brand-text\">New Session</h3>\n\t\t\t<div class=\"mb-4\">\n\t\t\t\t<span class=\"mb-1 block text-xs text-brand-text-muted\">Folder</span>\n\t\t\t\t<div\n\t\t\t\t\tclass=\"truncate rounded bg-brand-surface-3 px-2 py-1.5 text-xs text-brand-text\"\n\t\t\t\t>\n\t\t\t\t\t{newSessionPicker.folderPath}\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t<div class=\"mb-4\">\n\t\t\t\t<label\n\t\t\t\t\tclass=\"mb-1 block text-xs text-brand-text-muted\"\n\t\t\t\t\tfor=\"model-select\">Model</label\n\t\t\t\t>\n\t\t\t\t{#if models.length > 0}\n\t\t\t\t\t<select\n\t\t\t\t\t\tid=\"model-select\"\n\t\t\t\t\t\tbind:value={newSessionPicker.selected}\n\t\t\t\t\t\tclass=\"w-full rounded border border-brand-border bg-brand-surface-3 px-2 py-1.5 text-xs text-brand-text\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{#each models as model}\n\t\t\t\t\t\t\t<option value={`${model.provider}:${model.modelId}`}>\n\t\t\t\t\t\t\t\t{model.label}{model.isDefault ? ' (default)' : ''}\n\t\t\t\t\t\t\t</option>\n\t\t\t\t\t\t{/each}\n\t\t\t\t\t</select>\n\t\t\t\t{:else}\n\t\t\t\t\t<input\n\t\t\t\t\t\tid=\"model-select\"\n\t\t\t\t\t\ttype=\"text\"\n\t\t\t\t\t\tbind:value={newSessionPicker.selected}\n\t\t\t\t\t\tplaceholder=\"provider:model\"\n\t\t\t\t\t\tclass=\"w-full rounded border border-brand-border bg-brand-surface-3 px-2 py-1.5 text-xs text-brand-text placeholder-brand-text-muted\"\n\t\t\t\t\t/>\n\t\t\t\t{/if}\n\t\t\t</div>\n\t\t\t<div class=\"flex justify-end gap-2\">\n\t\t\t\t<button\n\t\t\t\t\tonclick={closeNewSessionPicker}\n\t\t\t\t\tclass=\"rounded bg-brand-surface-3 px-3 py-1.5 text-xs text-brand-text transition-colors hover:bg-brand-surface-2\"\n\t\t\t\t>\n\t\t\t\t\tCancel\n\t\t\t\t</button>\n\t\t\t\t<button\n\t\t\t\t\tonclick={handleCreateSession}\n\t\t\t\t\tclass=\"rounded bg-gradient-to-r from-brand-cyan to-brand-blue px-3 py-1.5 text-xs font-semibold text-brand-text transition-all hover:opacity-90\"\n\t\t\t\t>\n\t\t\t\t\tCreate\n\t\t\t\t</button>\n\t\t\t</div>\n\t\t</div>\n\t</div>\n{/if}\n\n<!-- Session Error -->\n{#if $sessionError}\n\t<div\n\t\tclass=\"absolute right-0 bottom-0 left-0 flex items-center justify-between border-t border-red-500/30 bg-red-500/10 px-3 py-2 text-xs text-rose-400\"\n\t>\n\t\t<span class=\"truncate\">{$sessionError}</span>\n\t\t<button\n\t\t\tonclick={() => dismissSessionError()}\n\t\t\tclass=\"ml-2 flex-shrink-0 text-rose-300 hover:text-rose-200\">✕</button\n\t\t>\n\t</div>\n{/if}\n\n<!-- Sidebar Git Init Confirm Dialog -->\n{#if showSidebarGitConfirmModal}\n\t<div\n\t\tclass=\"fixed inset-0 z-50 flex items-center justify-center bg-brand-dark/65 p-4\"\n\t\trole=\"dialog\"\n\t\taria-modal=\"true\"\n\t>\n\t\t<div\n\t\t\tclass=\"w-80 rounded-lg border border-brand-border bg-brand-surface-2 p-5 text-brand-text\"\n\t\t>\n\t\t\t<h3 class=\"mb-2 text-sm font-bold text-brand-text\">\n\t\t\t\tFolder Already Exists\n\t\t\t</h3>\n\t\t\t<p class=\"mb-3 text-xs text-brand-text-muted\">\n\t\t\t\tThe folder <span class=\"font-mono text-[11px] break-all text-brand-text\"\n\t\t\t\t\t>{sidebarCwd}</span\n\t\t\t\t> already exists. Do you want to initialize a Git repository in it?\n\t\t\t</p>\n\n\t\t\t<div class=\"mb-4 flex flex-col gap-3\">\n\t\t\t\t<div class=\"flex items-center gap-1.5\">\n\t\t\t\t\t<input\n\t\t\t\t\t\tid=\"sidebar-modal-git-init\"\n\t\t\t\t\t\ttype=\"checkbox\"\n\t\t\t\t\t\tbind:checked={sidebarGitInit}\n\t\t\t\t\t\tdisabled={sidebarPathStatus.isGit}\n\t\t\t\t\t\tclass=\"h-3.5 w-3.5 rounded border-brand-border bg-brand-surface-3 text-brand-blue focus:ring-brand-blue disabled:opacity-50\"\n\t\t\t\t\t/>\n\t\t\t\t\t<label\n\t\t\t\t\t\tfor=\"sidebar-modal-git-init\"\n\t\t\t\t\t\tclass=\"cursor-pointer text-xs text-brand-text select-none disabled:opacity-50\"\n\t\t\t\t\t>\n\t\t\t\t\t\tInitialize Git repository\n\t\t\t\t\t\t{#if sidebarPathStatus.isGit}\n\t\t\t\t\t\t\t<span class=\"ml-1 text-[10px] text-brand-text-muted\"\n\t\t\t\t\t\t\t\t>(already a Git repo)</span\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t{:else}\n\t\t\t\t\t\t\t<span class=\"ml-1 text-[10px] font-medium text-yellow-500\"\n\t\t\t\t\t\t\t\t>(folder not empty)</span\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t{/if}\n\t\t\t\t\t</label>\n\t\t\t\t</div>\n\n\t\t\t\t{#if sidebarPathStatus.matchingRule}\n\t\t\t\t\t<div class=\"space-y-1\">\n\t\t\t\t\t\t<div class=\"flex items-center gap-1.5\">\n\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\tid=\"sidebar-modal-create-remote\"\n\t\t\t\t\t\t\t\ttype=\"checkbox\"\n\t\t\t\t\t\t\t\tbind:checked={sidebarCreateRemote}\n\t\t\t\t\t\t\t\tclass=\"h-3.5 w-3.5 rounded border-brand-border bg-brand-surface-3 text-brand-blue focus:ring-brand-blue\"\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<label\n\t\t\t\t\t\t\t\tfor=\"sidebar-modal-create-remote\"\n\t\t\t\t\t\t\t\tclass=\"cursor-pointer text-xs text-brand-text select-none\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\tCreate remote {sidebarPathStatus.matchingRule.provider} repository\n\t\t\t\t\t\t\t</label>\n\t\t\t\t\t\t</div>\n\n\t\t\t\t\t\t{#if sidebarCreateRemote}\n\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\tclass=\"flex items-center gap-3 pl-5 text-[10px] text-brand-text-muted\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<span>Visibility:</span>\n\t\t\t\t\t\t\t\t<label\n\t\t\t\t\t\t\t\t\tclass=\"flex cursor-pointer items-center gap-1 transition-colors select-none hover:text-brand-text\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\t\t\ttype=\"radio\"\n\t\t\t\t\t\t\t\t\t\tname=\"sidebar-modal-visibility\"\n\t\t\t\t\t\t\t\t\t\tvalue=\"private\"\n\t\t\t\t\t\t\t\t\t\tbind:group={sidebarRepoVisibility}\n\t\t\t\t\t\t\t\t\t\tclass=\"border-brand-border bg-brand-surface-3 text-brand-blue focus:ring-brand-blue\"\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\tPrivate\n\t\t\t\t\t\t\t\t</label>\n\t\t\t\t\t\t\t\t<label\n\t\t\t\t\t\t\t\t\tclass=\"flex cursor-pointer items-center gap-1 transition-colors select-none hover:text-brand-text\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\t\t\ttype=\"radio\"\n\t\t\t\t\t\t\t\t\t\tname=\"sidebar-modal-visibility\"\n\t\t\t\t\t\t\t\t\t\tvalue=\"public\"\n\t\t\t\t\t\t\t\t\t\tbind:group={sidebarRepoVisibility}\n\t\t\t\t\t\t\t\t\t\tclass=\"border-brand-border bg-brand-surface-3 text-brand-blue focus:ring-brand-blue\"\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\tPublic\n\t\t\t\t\t\t\t\t</label>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t{/if}\n\t\t\t\t\t</div>\n\t\t\t\t{/if}\n\t\t\t</div>\n\n\t\t\t<div class=\"flex justify-end gap-2\">\n\t\t\t\t<button\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t\tonclick={() => (showSidebarGitConfirmModal = false)}\n\t\t\t\t\tclass=\"rounded bg-brand-surface-3 px-3 py-1.5 text-xs text-brand-text transition-colors hover:bg-brand-surface-2\"\n\t\t\t\t>\n\t\t\t\t\tCancel\n\t\t\t\t</button>\n\t\t\t\t<button\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t\tonclick={handleSidebarConfirmModalSubmit}\n\t\t\t\t\tclass=\"rounded bg-gradient-to-r from-brand-cyan to-brand-blue px-3 py-1.5 text-xs font-semibold text-brand-text transition-all hover:opacity-90\"\n\t\t\t\t>\n\t\t\t\t\tConfirm & Create\n\t\t\t\t</button>\n\t\t\t</div>\n\t\t</div>\n\t</div>\n{/if}\n","<script lang=\"ts\">\n\timport {conflict, resolveConflict} from '$lib/wherever';\n\n\tlet c = $derived($conflict);\n</script>\n\n{#if c}\n\t<div\n\t\tclass=\"fixed inset-0 z-50 flex items-center justify-center bg-brand-dark/60\"\n\t>\n\t\t<div\n\t\t\tclass=\"mx-4 w-full max-w-md rounded-xl border border-brand-border bg-brand-surface-2 p-6 shadow-xl\"\n\t\t>\n\t\t\t<h2 class=\"mb-2 text-lg font-bold text-brand-text\">Session Conflict</h2>\n\t\t\t<p class=\"mb-6 text-sm text-brand-text-muted\">\n\t\t\t\tAnother client is active on a session in folder <span\n\t\t\t\t\tclass=\"font-mono text-xs text-brand-text\">{c.conflictingCwd}</span\n\t\t\t\t>. What would you like to do?\n\t\t\t</p>\n\n\t\t\t<div class=\"flex gap-3\">\n\t\t\t\t<button\n\t\t\t\t\tonclick={() => resolveConflict('read_only')}\n\t\t\t\t\tclass=\"flex-1 rounded-lg bg-brand-surface-3 px-4 py-2.5 text-sm text-brand-text transition-colors hover:bg-brand-surface-2\"\n\t\t\t\t>\n\t\t\t\t\tRead Only\n\t\t\t\t</button>\n\t\t\t\t<button\n\t\t\t\t\tonclick={() => resolveConflict('take_over')}\n\t\t\t\t\tclass=\"flex-1 rounded-lg bg-rose-500 px-4 py-2.5 text-sm text-brand-text transition-colors hover:bg-rose-600\"\n\t\t\t\t>\n\t\t\t\t\tTake Over\n\t\t\t\t</button>\n\t\t\t</div>\n\n\t\t\t<p class=\"mt-4 text-xs text-brand-text-muted\">\n\t\t\t\t<strong class=\"text-brand-text\">Read Only:</strong> Observe the session\n\t\t\t\tlive but cannot send messages.<br />\n\t\t\t\t<strong class=\"text-brand-text\">Take Over:</strong> Interrupt the other client\n\t\t\t\tand gain control.\n\t\t\t</p>\n\t\t</div>\n\t</div>\n{/if}\n","<script lang=\"ts\">\n\timport {sudoPrompt, sendSudoPassword, cancelSudoPrompt} from '$lib/wherever';\n\n\tlet prompt = $derived($sudoPrompt);\n\n\t// Local, transient password buffer. It lives only in this component for as\n\t// long as the dialog is open, is handed straight to the socket on submit, and\n\t// is wiped immediately after. It is never written to the store or persisted.\n\tlet password = $state('');\n\tlet inputEl = $state<HTMLInputElement | null>(null);\n\n\t// Autofocus the field and clear any stale buffer each time a new prompt\n\t// appears. Keyed on promptId so a fresh prompt (new command) always resets.\n\tlet lastPromptId = $state<string | null>(null);\n\t$effect(() => {\n\t\tconst id = prompt?.promptId ?? null;\n\t\tif (id !== lastPromptId) {\n\t\t\tlastPromptId = id;\n\t\t\tpassword = '';\n\t\t\tif (id) {\n\t\t\t\t// Defer so the input is mounted before focusing.\n\t\t\t\tqueueMicrotask(() => inputEl?.focus());\n\t\t\t}\n\t\t}\n\t});\n\n\tfunction submit() {\n\t\tif (!prompt) return;\n\t\tsendSudoPassword(password);\n\t\tpassword = '';\n\t}\n\n\tfunction cancel() {\n\t\tcancelSudoPrompt();\n\t\tpassword = '';\n\t}\n\n\tfunction onKeydown(e: KeyboardEvent) {\n\t\tif (e.key === 'Enter') {\n\t\t\te.preventDefault();\n\t\t\tsubmit();\n\t\t} else if (e.key === 'Escape') {\n\t\t\te.preventDefault();\n\t\t\tcancel();\n\t\t}\n\t}\n</script>\n\n{#if prompt}\n\t<div\n\t\tclass=\"fixed inset-0 z-50 flex items-center justify-center bg-brand-dark/60\"\n\t>\n\t\t<div\n\t\t\tclass=\"mx-4 w-full max-w-md rounded-xl border border-brand-border bg-brand-surface-2 p-6 shadow-xl\"\n\t\t>\n\t\t\t<h2 class=\"mb-2 text-lg font-bold text-brand-text\">Sudo password</h2>\n\t\t\t<p class=\"mb-3 text-sm text-brand-text-muted\">\n\t\t\t\tThis command needs your sudo password to run. It is used once and never\n\t\t\t\tstored.\n\t\t\t</p>\n\t\t\t<pre\n\t\t\t\tclass=\"mb-4 overflow-x-auto rounded-lg bg-brand-surface-3 px-3 py-2 font-mono text-xs text-brand-text\">{prompt.command}</pre>\n\n\t\t\t<!-- svelte-ignore a11y_autofocus -->\n\t\t\t<input\n\t\t\t\tbind:this={inputEl}\n\t\t\t\tbind:value={password}\n\t\t\t\tonkeydown={onKeydown}\n\t\t\t\ttype=\"password\"\n\t\t\t\tautocomplete=\"off\"\n\t\t\t\tautocapitalize=\"off\"\n\t\t\t\tautocorrect=\"off\"\n\t\t\t\tspellcheck=\"false\"\n\t\t\t\tplaceholder=\"Password\"\n\t\t\t\tclass=\"mb-4 w-full rounded-lg border border-brand-border bg-brand-surface-3 px-3 py-2.5 text-sm text-brand-text outline-none focus:border-brand-blue\"\n\t\t\t/>\n\n\t\t\t<div class=\"flex gap-3\">\n\t\t\t\t<button\n\t\t\t\t\tonclick={cancel}\n\t\t\t\t\tclass=\"flex-1 rounded-lg bg-brand-surface-3 px-4 py-2.5 text-sm text-brand-text transition-colors hover:bg-brand-surface-2\"\n\t\t\t\t>\n\t\t\t\t\tCancel\n\t\t\t\t</button>\n\t\t\t\t<button\n\t\t\t\t\tonclick={submit}\n\t\t\t\t\tclass=\"flex-1 rounded-lg bg-brand-blue px-4 py-2.5 text-sm text-brand-text transition-colors hover:opacity-90\"\n\t\t\t\t>\n\t\t\t\t\tRun\n\t\t\t\t</button>\n\t\t\t</div>\n\t\t</div>\n\t</div>\n{/if}\n","// Single source of truth for \"which top-level view are we in\", derived from the\n// session lifecycle flags. Both the message area (ChatMessageList) and the\n// bottom composer (+page.svelte) key off this so they can never disagree -- the\n// bug being fixed was the composer showing the search input while the message\n// area showed \"Loading session...\" because each computed the no-session state\n// independently.\n\nexport interface SessionViewInputs {\n\tconnected: boolean;\n\t/** A session's transcript is loaded (activeSessionFile is set). */\n\thasSession: boolean;\n\t/** A fresh session load is in flight (loadingSession). */\n\tloading: boolean;\n\t/** A reconnect is rejoining a cached session (resyncing). */\n\tresyncing: boolean;\n\t/** A URL hash points at a session we are about to open. */\n\thasSessionHash: boolean;\n}\n\n/**\n * True when a session is being opened (or reopened) but its transcript is not\n * yet on screen: a fresh load, a resync, or a hash that will drive a load. In\n * this window sessionFile is briefly null, but this is NOT the search / new-\n * session home state -- the message area shows a \"Loading session...\" spinner,\n * so the composer must NOT present the search input.\n */\nexport function isSessionPendingOpen(i: SessionViewInputs): boolean {\n\treturn i.loading || i.resyncing || i.hasSessionHash;\n}\n\n/**\n * True only at the genuine no-session home state where the composer acts as the\n * web-search input: connected, a search folder configured, no active session,\n * and no session mid-open. Mirrors the message area's empty-state condition so\n * the two views stay consistent.\n */\nexport function isSearchActive(\n\ti: SessionViewInputs & {searchConfigured: boolean},\n): boolean {\n\treturn (\n\t\ti.connected &&\n\t\ti.searchConfigured &&\n\t\t!i.hasSession &&\n\t\t!isSessionPendingOpen(i)\n\t);\n}\n","<script lang=\"ts\">\n\timport Head from '$lib/Head.svelte';\n\timport ConnectionSettings from '$lib/components/ConnectionSettings.svelte';\n\timport ChatMessageList from '$lib/components/ChatMessageList.svelte';\n\timport ChatInput from '$lib/components/ChatInput.svelte';\n\timport SessionBrowser from '$lib/components/SessionBrowser.svelte';\n\timport SessionConflictDialog from '$lib/components/SessionConflictDialog.svelte';\n\timport SudoPasswordDialog from '$lib/components/SudoPasswordDialog.svelte';\n\timport {\n\t\tpiState,\n\t\tisConnected,\n\t\tisInterrupted,\n\t\tsessionError,\n\t\tsessionNotice,\n\t\tisReadOnly,\n\t\tactiveSessionInfo,\n\t\tconnect,\n\t\tdisconnect,\n\t\tsuspend,\n\t\tresume,\n\t\tleaveSession,\n\t\tdismissSessionError,\n\t\tdismissNotice,\n\t\tchangeModel,\n\t\tjoinSession,\n\t\tswitchSession,\n\t\tisCreatingSession,\n\t\tisResyncing,\n\t\tisLoadingSession,\n\t\tisAgentPending,\n\t\thasSuspendedSession,\n\t\tisFilePickerActive,\n\t\tendFilePicker,\n\t\trunSearch,\n\t\thasActiveSession,\n\t} from '$lib/wherever';\n\timport {\n\t\tfetchSessions,\n\t\tfetchReadOnlySessions,\n\t\tavailableModels,\n\t\tsearchFolderStore,\n\t\tsearchDefaultModelStore,\n\t} from '$lib/session-store';\n\timport {onMount} from 'svelte';\n\timport {version} from '$app/environment';\n\timport {url} from '$lib/core/utils/web/path';\n\timport {isSearchActive} from '$lib/core/view-mode';\n\n\tlet sidebarOpen = $state(false);\n\t// Which session list the sidebar shows: the main dashboard, or the separate\n\t// read-only page (sessions.readOnly folders) reached via the sidebar link.\n\t// The read-only page hides the create form, delete controls, and the composer.\n\tlet sessionView = $state<'main' | 'readonly'>('main');\n\tlet showSettings = $state(false);\n\tlet autoConnect = $state(true);\n\tlet interruptedTimeout: ReturnType<typeof setTimeout> | null = null;\n\tlet chatList: {forceScrollToBottom: () => void};\n\n\tonMount(() => {\n\t\tif (autoConnect) {\n\t\t\tsetTimeout(() => connect(), 200);\n\t\t}\n\n\t\tconst handleHashChange = () => {\n\t\t\tif (connected) {\n\t\t\t\tconst hashId = window.location.hash\n\t\t\t\t\t? decodeURIComponent(window.location.hash.slice(1))\n\t\t\t\t\t: '';\n\t\t\t\tif (hashId && hashId !== currentSessionId) {\n\t\t\t\t\t// Atomic switch (no leave -> setTimeout -> join gap that could strand\n\t\t\t\t\t// the loading spinner). switchSession leaves the current session first\n\t\t\t\t\t// when there is one and loads the target either way.\n\t\t\t\t\tswitchSession(hashId);\n\t\t\t\t} else if (!hashId && currentSessionId) {\n\t\t\t\t\tleaveSession();\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\twindow.addEventListener('hashchange', handleHashChange);\n\n\t\t// --- Background/resume handling (esp. Firefox Android screen-lock) ---\n\t\t// While the page is backgrounded we close the WebSocket. An open WS makes\n\t\t// the page ineligible for the browser's back/forward cache, which on\n\t\t// mobile pushes the browser toward a full, slow reload on resume. Closing\n\t\t// it improves bfcache eligibility (instant restore) and, when a real\n\t\t// reload does happen, the active session is restored from the URL hash.\n\t\t// The disconnect is delayed so quick tab switches don't churn the\n\t\t// connection; reconnect is immediate on return.\n\t\tlet hiddenTimer: ReturnType<typeof setTimeout> | null = null;\n\t\tconst HIDE_DISCONNECT_DELAY = 8000;\n\n\t\tconst handleVisibility = () => {\n\t\t\tif (document.visibilityState === 'hidden') {\n\t\t\t\t// A native file picker / camera backgrounds the page. Don't schedule a\n\t\t\t\t// suspend in that window, or a slow file selection (e.g. taking a\n\t\t\t\t// photo) would tear down the session and make the upload fail with\n\t\t\t\t// \"No active session\" on return.\n\t\t\t\tif (isFilePickerActive()) return;\n\t\t\t\tif (hiddenTimer) clearTimeout(hiddenTimer);\n\t\t\t\thiddenTimer = setTimeout(() => {\n\t\t\t\t\thiddenTimer = null;\n\t\t\t\t\tif (document.visibilityState === 'hidden' && connected) {\n\t\t\t\t\t\t// Suspend (not disconnect): keep the cached session/messages so\n\t\t\t\t\t\t// returning resyncs in place instead of reloading from scratch.\n\t\t\t\t\t\tsuspend();\n\t\t\t\t\t}\n\t\t\t\t}, HIDE_DISCONNECT_DELAY);\n\t\t\t} else {\n\t\t\t\t// Back in the foreground: the picker (if any) is closed. Clear the\n\t\t\t\t// guard so a cancelled picker doesn't leave suspend disabled. The\n\t\t\t\t// upload's own session check already ran synchronously on the file\n\t\t\t\t// change, so the session is no longer needed to be pinned here.\n\t\t\t\tendFilePicker();\n\t\t\t\tif (hiddenTimer) {\n\t\t\t\t\tclearTimeout(hiddenTimer);\n\t\t\t\t\thiddenTimer = null;\n\t\t\t\t}\n\t\t\t\tif (!connected) {\n\t\t\t\t\t// Prefer the preserve-cache resume() path whenever we still hold an\n\t\t\t\t\t// active session -- from an explicit suspend OR an unsolicited drop that\n\t\t\t\t\t// happened while hidden (before the 8s suspend). resume() rejoins in\n\t\t\t\t\t// place and keeps the conversation visible; a plain connect() would wipe\n\t\t\t\t\t// the session and re-show the search / new-session empty-state. Only a\n\t\t\t\t\t// truly empty client (no session at all) falls back to connect(), where\n\t\t\t\t\t// the hash auto-join drives the load.\n\t\t\t\t\tif (hasActiveSession()) {\n\t\t\t\t\t\tresume();\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconnect();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\tconst handlePageShow = (e: PageTransitionEvent) => {\n\t\t\t// On bfcache restore (e.persisted) or any return to a visible page,\n\t\t\t// resume the suspended connection, rejoining the cached session in place.\n\t\t\tif (hiddenTimer) {\n\t\t\t\tclearTimeout(hiddenTimer);\n\t\t\t\thiddenTimer = null;\n\t\t\t}\n\t\t\tif (document.visibilityState !== 'hidden' && !connected) {\n\t\t\t\tif (hasActiveSession()) {\n\t\t\t\t\tresume();\n\t\t\t\t} else {\n\t\t\t\t\tconnect();\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\tdocument.addEventListener('visibilitychange', handleVisibility);\n\t\twindow.addEventListener('pageshow', handlePageShow);\n\n\t\treturn () => {\n\t\t\twindow.removeEventListener('hashchange', handleHashChange);\n\t\t\tdocument.removeEventListener('visibilitychange', handleVisibility);\n\t\t\twindow.removeEventListener('pageshow', handlePageShow);\n\t\t\tif (hiddenTimer) clearTimeout(hiddenTimer);\n\t\t};\n\t});\n\n\tfunction handleConnected() {\n\t\tconnect();\n\t}\n\n\tfunction handleDisconnect() {\n\t\tleaveSession();\n\t\tdisconnect();\n\t}\n\n\tfunction handleReconnect() {\n\t\tdisconnect();\n\t\tsetTimeout(() => connect(), 100);\n\t}\n\n\tfunction handleRefresh() {\n\t\tfetchSessions();\n\t}\n\n\tfunction handleShowMainScreen() {\n\t\tif (typeof window !== 'undefined') {\n\t\t\twindow.location.hash = '';\n\t\t}\n\t\tleaveSession();\n\t\tsidebarOpen = false;\n\t}\n\n\tlet connected = $derived($isConnected);\n\tlet resyncing = $derived($isResyncing);\n\tlet agentPending = $derived($isAgentPending);\n\tlet loadingSession = $derived($isLoadingSession);\n\tlet interrupted = $derived($isInterrupted);\n\tlet sError = $derived($sessionError);\n\tlet notice = $derived($sessionNotice);\n\tlet readOnly = $derived($isReadOnly);\n\tlet sessionInfo = $derived($activeSessionInfo);\n\tlet appState = $derived($piState);\n\tlet models = $derived($availableModels.models);\n\n\tlet wasSessionActive = $state(false);\n\tlet currentSessionId = $derived(sessionInfo.sessionId);\n\n\t// Update hash when sessionId changes, only if connected to prevent clearing on reload\n\t$effect(() => {\n\t\tif (typeof window !== 'undefined' && connected) {\n\t\t\tif (currentSessionId) {\n\t\t\t\twindow.location.hash = encodeURIComponent(currentSessionId);\n\t\t\t\twasSessionActive = true;\n\t\t\t} else if (wasSessionActive) {\n\t\t\t\twasSessionActive = false;\n\t\t\t\tif (window.location.hash) {\n\t\t\t\t\twindow.location.hash = '';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t});\n\n\t// Auto-join session from hash when connected.\n\t//\n\t// Self-healing by design: it re-evaluates whenever we are connected with a hash\n\t// but no session is active for it. An earlier guard latched per join and was\n\t// reset on disconnect, but rapid connect/disconnect churn (e.g. a reconnect\n\t// racing a resume) could flip `connected` within a single effect flush so the\n\t// reset was never observed, leaving the guard latched and the session never\n\t// loaded, which hung the \"Loading session...\" spinner forever. Gating purely on\n\t// the live state (active session id + loading/resync flags) instead avoids that.\n\tlet hashJoinTimer: ReturnType<typeof setTimeout> | null = null;\n\t$effect(() => {\n\t\tif (!connected || typeof window === 'undefined' || !window.location.hash) {\n\t\t\treturn;\n\t\t}\n\t\tconst hashId = decodeURIComponent(window.location.hash.slice(1));\n\t\tif (!hashId) return;\n\t\t// Already on (or already loading) the hash session: nothing to do. This also\n\t\t// covers the resume path, where the client rejoins the cached session in\n\t\t// place via session_load in onOpen, so re-joining here would double-load.\n\t\tif (currentSessionId === hashId || loadingSession || resyncing) return;\n\t\tif (hashJoinTimer) return; // a join is already pending\n\t\thashJoinTimer = setTimeout(() => {\n\t\t\thashJoinTimer = null;\n\t\t\tif (currentSessionId === hashId || loadingSession || resyncing) return;\n\t\t\tjoinSession(hashId);\n\t\t}, 300);\n\t});\n\n\t// Reset transient flags on disconnect.\n\t$effect(() => {\n\t\tif (!connected) {\n\t\t\twasSessionActive = false;\n\t\t}\n\t});\n\n\t// Close sidebar on mobile when a session is joined OR as soon as a load is in\n\t// flight. Previously it only closed once `currentSessionId` was set, so if the\n\t// load stalled (the \"Loading session...\" spinner hanging) the sidebar stayed\n\t// open over it. Closing on the loading/resync flag too means the tap always\n\t// dismisses the sidebar, and the user sees the spinner (or its eventual error)\n\t// rather than a stuck open sidebar.\n\t$effect(() => {\n\t\tif (currentSessionId || loadingSession || resyncing) {\n\t\t\tsidebarOpen = false;\n\t\t}\n\t});\n\n\tlet isCreating = $derived($isCreatingSession);\n\tlet searchFolder = $derived($searchFolderStore);\n\n\t// The bottom composer is always mounted but mode-switched: it acts as the\n\t// search composer when connected, a search folder is configured, and no\n\t// session is active. Keeping it mounted (not conditionally rendered) means it\n\t// exists at tap time so we can focus it synchronously inside a user gesture.\n\tlet chatInput: {focusInput: () => void} | undefined = $state();\n\t// The composer's search mode must mirror the message area's empty-state so the\n\t// two never disagree (the bug: a \"Loading session...\" spinner with an enabled\n\t// search box). isSearchActive treats a session that is loading/resyncing, or a\n\t// hash pointing at a session we are about to open, as NOT the search state even\n\t// though sessionFile is briefly still null.\n\tlet searchActive = $derived(\n\t\tisSearchActive({\n\t\t\tconnected,\n\t\t\tsearchConfigured: !!searchFolder,\n\t\t\thasSession: !!sessionInfo.sessionFile,\n\t\t\tloading: loadingSession,\n\t\t\tresyncing,\n\t\t\thasSessionHash: typeof window !== 'undefined' && !!window.location.hash,\n\t\t}),\n\t);\n\n\t// Search-mode model picker. Options mirror the sidebar new-session list; the\n\t// selection is seeded from the search folder's server-resolved default (which\n\t// honors folder-local harness/pi config), falling back to the models list's\n\t// isDefault entry, then the first model.\n\tlet searchModels = $derived(\n\t\tmodels.map((m) => ({\n\t\t\tvalue: `${m.provider}:${m.modelId}`,\n\t\t\tlabel: `${m.label}${m.isDefault ? ' (default)' : ''}`,\n\t\t})),\n\t);\n\tlet searchDefaultModel = $derived($searchDefaultModelStore);\n\tlet searchModel = $state('');\n\t// Seed (or re-seed) the selection once options are available and nothing valid\n\t// is chosen yet. Runs when the model list or folder default changes.\n\t$effect(() => {\n\t\tif (searchModels.length === 0) return;\n\t\tconst valid = searchModels.some((m) => m.value === searchModel);\n\t\tif (valid) return;\n\t\tconst folderDefault = searchModels.find(\n\t\t\t(m) => m.value === searchDefaultModel,\n\t\t);\n\t\tconst listDefault = models.find((m) => m.isDefault);\n\t\tsearchModel = folderDefault\n\t\t\t? folderDefault.value\n\t\t\t: listDefault\n\t\t\t\t? `${listDefault.provider}:${listDefault.modelId}`\n\t\t\t\t: searchModels[0].value;\n\t});\n\n\t// On page load with no session, focus the search composer so it is ready to\n\t// type. (One-shot; not inside the tap path, so no mobile-keyboard concern.)\n\tlet hasFocusedSearch = $state(false);\n\t$effect(() => {\n\t\tif (searchActive && !hasFocusedSearch && chatInput) {\n\t\t\thasFocusedSearch = true;\n\t\t\tchatInput.focusInput();\n\t\t}\n\t});\n\n\t// Top-bar magnifier (active-session case): leave the session and focus the\n\t// search composer SYNCHRONOUSLY inside this gesture so the mobile virtual\n\t// keyboard rises (focusing later from a reactive effect would not, esp. iOS).\n\tfunction startSearch() {\n\t\t// Clear the hash synchronously so the chat area drops straight to the\n\t\t// search empty-state instead of flashing the \"Loading session...\" spinner\n\t\t// (ChatMessageList reads window.location.hash, which is not reactive).\n\t\tif (typeof window !== 'undefined' && window.location.hash) {\n\t\t\twindow.location.hash = '';\n\t\t}\n\t\tleaveSession();\n\t\tchatInput?.focusInput();\n\t}\n</script>\n\n<Head title=\"Wherever\" description=\"Create & maintain apps from wherever\" />\n\n{#if isCreating}\n\t<div\n\t\tclass=\"fixed inset-0 z-[100] flex items-center justify-center bg-brand-dark/60 backdrop-blur-sm\"\n\t>\n\t\t<div class=\"flex flex-col items-center gap-4\">\n\t\t\t<div\n\t\t\t\tclass=\"h-12 w-12 animate-spin rounded-full border-4 border-brand-blue border-t-transparent\"\n\t\t\t></div>\n\t\t\t<span class=\"text-lg font-bold text-brand-text\">Creating session...</span>\n\t\t</div>\n\t</div>\n{/if}\n\n<div\n\tclass=\"fixed inset-0 flex overflow-hidden overscroll-none bg-brand-dark text-brand-text\"\n>\n\t<!-- Sidebar -->\n\t<div\n\t\tclass=\"app-chrome {sidebarOpen\n\t\t\t? 'translate-x-0'\n\t\t\t: '-translate-x-full'} fixed z-20 flex h-full w-72 flex-col border-r border-brand-border bg-brand-surface transition-transform duration-200 md:relative md:translate-x-0\"\n\t>\n\t\t<div class=\"border-b border-brand-border bg-brand-surface-2/20 p-4\">\n\t\t\t<div class=\"flex items-center justify-between\">\n\t\t\t\t{#if showSettings}\n\t\t\t\t\t<span class=\"text-lg font-bold text-brand-text\"\n\t\t\t\t\t\t>Connection Settings</span\n\t\t\t\t\t>\n\t\t\t\t\t<button\n\t\t\t\t\t\tonclick={() => (showSettings = false)}\n\t\t\t\t\t\tclass=\"rounded px-2 py-1 text-xs font-semibold text-brand-blue transition-colors hover:bg-brand-surface-2 hover:text-brand-blue\"\n\t\t\t\t\t>\n\t\t\t\t\t\t◀ Back\n\t\t\t\t\t</button>\n\t\t\t\t{:else}\n\t\t\t\t\t<button\n\t\t\t\t\t\tonclick={handleShowMainScreen}\n\t\t\t\t\t\tclass=\"flex items-center gap-2 text-left\"\n\t\t\t\t\t\ttitle=\"Show Main Screen / New Session\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<img src={url('/logo.svg')} alt=\"Wherever\" class=\"h-6 w-6\" />\n\t\t\t\t\t\t<span class=\"gradient-text text-lg font-bold\">Wherever</span>\n\t\t\t\t\t</button>\n\t\t\t\t\t<div class=\"flex items-center gap-2\">\n\t\t\t\t\t\t<button\n\t\t\t\t\t\t\tonclick={() => (showSettings = true)}\n\t\t\t\t\t\t\tclass=\"flex items-center gap-1 rounded border border-brand-border px-1.5 py-1 text-xs text-brand-text-muted transition-colors hover:bg-brand-surface-2 hover:text-brand-text\"\n\t\t\t\t\t\t\ttitle=\"Connection Settings\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t⚙️ Config\n\t\t\t\t\t\t</button>\n\t\t\t\t\t\t<button\n\t\t\t\t\t\t\tonclick={() => (sidebarOpen = false)}\n\t\t\t\t\t\t\tclass=\"text-brand-text-muted hover:text-brand-text md:hidden\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\tX\n\t\t\t\t\t\t</button>\n\t\t\t\t\t</div>\n\t\t\t\t{/if}\n\t\t\t</div>\n\t\t</div>\n\n\t\t{#if showSettings}\n\t\t\t<div class=\"flex-1 overflow-y-auto\">\n\t\t\t\t<ConnectionSettings\n\t\t\t\t\thost={appState.connected ? 'localhost' : 'localhost'}\n\t\t\t\t\tport={31415}\n\t\t\t\t\ttoken=\"\"\n\t\t\t\t\tonConnected={handleConnected}\n\t\t\t\t/>\n\n\t\t\t\t<div class=\"mt-2 border-t border-brand-border p-4\">\n\t\t\t\t\t<h3\n\t\t\t\t\t\tclass=\"mb-3 text-xs font-bold tracking-wider text-brand-text-muted uppercase\"\n\t\t\t\t\t>\n\t\t\t\t\t\tServer Control\n\t\t\t\t\t</h3>\n\t\t\t\t\t<div class=\"space-y-2\">\n\t\t\t\t\t\t<button\n\t\t\t\t\t\t\tonclick={handleRefresh}\n\t\t\t\t\t\t\tclass=\"flex w-full items-center justify-between rounded border border-brand-border bg-brand-surface-2 px-3 py-2 text-left text-sm text-brand-text transition-colors hover:bg-brand-surface-3 hover:text-brand-text\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<span>Refresh Session List</span>\n\t\t\t\t\t\t\t<span>🔄</span>\n\t\t\t\t\t\t</button>\n\t\t\t\t\t\t<button\n\t\t\t\t\t\t\tonclick={handleReconnect}\n\t\t\t\t\t\t\tclass=\"flex w-full items-center justify-between rounded border border-brand-border bg-brand-surface-2 px-3 py-2 text-left text-sm text-brand-text transition-colors hover:bg-brand-surface-3 hover:text-brand-text\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<span>Reconnect WebSocket</span>\n\t\t\t\t\t\t\t<span>🔌</span>\n\t\t\t\t\t\t</button>\n\t\t\t\t\t\t<button\n\t\t\t\t\t\t\tonclick={handleDisconnect}\n\t\t\t\t\t\t\tclass=\"flex w-full items-center justify-between rounded border border-red-500/30 bg-red-500/10 px-3 py-2 text-left text-sm text-rose-400 transition-colors hover:bg-red-500/20 hover:text-rose-300\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<span>Disconnect Server</span>\n\t\t\t\t\t\t\t<span>🛑</span>\n\t\t\t\t\t\t</button>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t{:else}\n\t\t\t<!-- Connection status -->\n\t\t\t<div class=\"border-b border-brand-border p-4\">\n\t\t\t\t<div class=\"flex items-center gap-2\">\n\t\t\t\t\t<div\n\t\t\t\t\t\tclass=\"h-2.5 w-2.5 rounded-full {connected\n\t\t\t\t\t\t\t? 'bg-emerald-500'\n\t\t\t\t\t\t\t: 'bg-rose-500'}\"\n\t\t\t\t\t></div>\n\t\t\t\t\t<span\n\t\t\t\t\t\tclass=\"text-sm {connected ? 'text-emerald-400' : 'text-rose-400'}\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{connected ? 'Connected' : 'Disconnected'}\n\t\t\t\t\t</span>\n\t\t\t\t\t<span\n\t\t\t\t\t\tclass=\"ml-auto font-mono text-xs text-brand-text-muted\"\n\t\t\t\t\t\ttitle=\"App build version\"\n\t\t\t\t\t>\n\t\t\t\t\t\tv{version}\n\t\t\t\t\t</span>\n\t\t\t\t</div>\n\t\t\t\t{#if sessionInfo.sessionFile}\n\t\t\t\t\t<div class=\"mt-2 space-y-1\">\n\t\t\t\t\t\t{#if sessionInfo.cwd}\n\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\tclass=\"truncate text-xs text-brand-text-muted\"\n\t\t\t\t\t\t\t\ttitle={sessionInfo.cwd}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t📁 {sessionInfo.cwd.split('/').pop() || sessionInfo.cwd}\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t{#if sessionInfo.model}\n\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\tclass=\"truncate text-xs text-brand-text-muted\"\n\t\t\t\t\t\t\t\ttitle={sessionInfo.model}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t🤖 {sessionInfo.model}\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t<div class=\"pt-1.5\">\n\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\tonclick={handleShowMainScreen}\n\t\t\t\t\t\t\t\tclass=\"w-full rounded border border-brand-border bg-brand-surface-2 px-2 py-1 text-center text-xs text-brand-text transition-colors hover:bg-brand-surface-3 hover:text-brand-text\"\n\t\t\t\t\t\t\t\ttitle=\"Show Main Screen (Clear URL Hash)\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\tClose Session\n\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t{/if}\n\t\t\t\t{#if appState.error && !connected}\n\t\t\t\t\t<div class=\"mt-2 text-xs text-rose-400\">\n\t\t\t\t\t\t{appState.error}\n\t\t\t\t\t</div>\n\t\t\t\t{/if}\n\t\t\t</div>\n\n\t\t\t<!-- Sidebar navigation: switch between the main list and the read-only page -->\n\t\t\t<div class=\"border-b border-brand-border/50 px-2 py-1.5\">\n\t\t\t\t{#if sessionView === 'main'}\n\t\t\t\t\t<button\n\t\t\t\t\t\tonclick={() => {\n\t\t\t\t\t\t\tsessionView = 'readonly';\n\t\t\t\t\t\t\tfetchReadOnlySessions();\n\t\t\t\t\t\t}}\n\t\t\t\t\t\tclass=\"flex w-full items-center gap-2 rounded px-2 py-1.5 text-left text-xs text-brand-text-muted transition-colors hover:bg-brand-surface-3/50 hover:text-brand-text\"\n\t\t\t\t\t\ttitle=\"View read-only sessions (e.g. autonomous agent fleets)\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<span>👁️</span>\n\t\t\t\t\t\t<span>Read-only sessions</span>\n\t\t\t\t\t\t<span class=\"ml-auto\">→</span>\n\t\t\t\t\t</button>\n\t\t\t\t{:else}\n\t\t\t\t\t<button\n\t\t\t\t\t\tonclick={() => (sessionView = 'main')}\n\t\t\t\t\t\tclass=\"flex w-full items-center gap-2 rounded px-2 py-1.5 text-left text-xs font-semibold text-brand-blue transition-colors hover:bg-brand-surface-3/50\"\n\t\t\t\t\t\ttitle=\"Back to your sessions\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<span>←</span>\n\t\t\t\t\t\t<span>Back to sessions</span>\n\t\t\t\t\t</button>\n\t\t\t\t{/if}\n\t\t\t</div>\n\n\t\t\t<!-- Session Browser -->\n\t\t\t<div class=\"flex-1 overflow-hidden\">\n\t\t\t\t{#if sessionView === 'readonly'}\n\t\t\t\t\t<SessionBrowser readOnly />\n\t\t\t\t{:else}\n\t\t\t\t\t<SessionBrowser />\n\t\t\t\t{/if}\n\t\t\t</div>\n\t\t{/if}\n\t</div>\n\n\t<!-- Main content -->\n\t<div class=\"flex min-w-0 flex-1 flex-col\">\n\t\t<!-- Top bar -->\n\t\t<div\n\t\t\tclass=\"app-chrome flex items-center gap-3 border-b border-brand-border bg-brand-surface p-3\"\n\t\t>\n\t\t\t<button\n\t\t\t\tonclick={() => (sidebarOpen = !sidebarOpen)}\n\t\t\t\tclass=\"p-1 text-brand-text-muted hover:text-brand-text md:hidden\"\n\t\t\t>\n\t\t\t\t=\n\t\t\t</button>\n\n\t\t\t<!-- Compact search affordance (active-session case): drop to the search\n\t\t\t empty-state. Hidden in the empty-state itself, where the bottom\n\t\t\t composer already IS the search input. -->\n\t\t\t{#if connected && searchFolder && sessionInfo.sessionFile}\n\t\t\t\t<button\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t\tonclick={startSearch}\n\t\t\t\t\tclass=\"flex flex-shrink-0 items-center justify-center rounded border border-brand-border bg-brand-surface-2 px-2.5 py-1.5 text-sm text-brand-text-muted transition-colors hover:bg-brand-surface-3 hover:text-brand-text\"\n\t\t\t\t\ttitle=\"Search the web\"\n\t\t\t\t\taria-label=\"Search the web\"\n\t\t\t\t>\n\t\t\t\t\t🔍\n\t\t\t\t</button>\n\t\t\t{/if}\n\n\t\t\t<!-- Status indicator -->\n\t\t\t{#if !connected || !sessionInfo.sessionFile}\n\t\t\t\t<div class=\"flex min-w-0 items-center gap-2\">\n\t\t\t\t\t{#if connected && searchActive}\n\t\t\t\t\t\t<span class=\"text-sm text-brand-text-muted\"\n\t\t\t\t\t\t\t>Search the web below, or pick a session from the sidebar</span\n\t\t\t\t\t\t>\n\t\t\t\t\t{:else if connected}\n\t\t\t\t\t\t<span class=\"text-sm text-brand-text-muted\"\n\t\t\t\t\t\t\t>Select a session from sidebar</span\n\t\t\t\t\t\t>\n\t\t\t\t\t{:else}\n\t\t\t\t\t\t<span class=\"text-sm text-brand-text-muted\">Not connected</span>\n\t\t\t\t\t{/if}\n\t\t\t\t</div>\n\t\t\t{/if}\n\n\t\t\t<!-- Folder and model info -->\n\t\t\t{#if sessionInfo.sessionFile}\n\t\t\t\t<div class=\"flex min-w-0 flex-1 items-center gap-3\">\n\t\t\t\t\t<!-- Folder -->\n\t\t\t\t\t{#if sessionInfo.cwd}\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tclass=\"flex min-w-0 items-center gap-1.5 text-xs text-brand-text-muted\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<span class=\"flex-shrink-0\">📁</span>\n\t\t\t\t\t\t\t<span class=\"truncate\" title={sessionInfo.cwd}\n\t\t\t\t\t\t\t\t>{sessionInfo.cwd.split('/').pop() || sessionInfo.cwd}</span\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t{/if}\n\n\t\t\t\t\t<!-- Model selector -->\n\t\t\t\t\t{#if sessionInfo.model}\n\t\t\t\t\t\t<div class=\"flex min-w-0 items-center gap-1.5 text-xs\">\n\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\tclass=\"relative flex flex-shrink-0 items-center justify-center text-sm\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<span>🤖</span>\n\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\tclass=\"absolute -right-0.5 -bottom-0.5 h-2 w-2 rounded-full border border-brand-surface {appState.isStreaming\n\t\t\t\t\t\t\t\t\t\t? 'animate-pulse bg-orange-500'\n\t\t\t\t\t\t\t\t\t\t: 'bg-emerald-500'}\"\n\t\t\t\t\t\t\t\t\ttitle={appState.isStreaming ? 'Agent working...' : 'Ready'}\n\t\t\t\t\t\t\t\t></span>\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t{#if models.length > 0 && !readOnly}\n\t\t\t\t\t\t\t\t<select\n\t\t\t\t\t\t\t\t\tvalue={sessionInfo.model}\n\t\t\t\t\t\t\t\t\toninput={(e) => changeModel(e.currentTarget.value)}\n\t\t\t\t\t\t\t\t\tclass=\"max-w-48 truncate rounded border border-brand-border bg-brand-surface-2 px-1.5 py-0.5 text-brand-text focus:border-brand-blue focus:outline-none\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{#each models as model}\n\t\t\t\t\t\t\t\t\t\t<option value={`${model.provider}:${model.modelId}`}>\n\t\t\t\t\t\t\t\t\t\t\t{model.label}\n\t\t\t\t\t\t\t\t\t\t</option>\n\t\t\t\t\t\t\t\t\t{/each}\n\t\t\t\t\t\t\t\t</select>\n\t\t\t\t\t\t\t{:else}\n\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\tclass=\"truncate text-brand-text-muted\"\n\t\t\t\t\t\t\t\t\ttitle={sessionInfo.model}>{sessionInfo.model}</span\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t{/if}\n\t\t\t\t</div>\n\t\t\t{/if}\n\n\t\t\t{#if readOnly}\n\t\t\t\t<span\n\t\t\t\t\tclass=\"flex-shrink-0 rounded bg-yellow-500/20 px-2 py-1 text-xs text-yellow-400\"\n\t\t\t\t\t>Read-only</span\n\t\t\t\t>\n\t\t\t{/if}\n\t\t</div>\n\n\t\t<!-- Interruption notification -->\n\t\t{#if interrupted}\n\t\t\t<div\n\t\t\t\tclass=\"border border-red-500/30 bg-red-500/10 px-4 py-2 text-center text-sm text-rose-400\"\n\t\t\t>\n\t\t\t\tYour session was interrupted — another client took over.\n\t\t\t</div>\n\t\t{/if}\n\n\t\t<!-- Session notice (non-fatal). e.g. a CLI took over this session while it\n\t\t was mid-turn here, discarding the in-flight tool call or streaming\n\t\t reply. The session stays attached; the user just needs to know why the\n\t\t running turn stopped. Dismissible. -->\n\t\t{#if notice}\n\t\t\t<div\n\t\t\t\tclass=\"flex items-start justify-between gap-2 border px-4 py-2 text-sm {notice.level ===\n\t\t\t\t'warning'\n\t\t\t\t\t? 'border-yellow-500/30 bg-yellow-500/10 text-yellow-400'\n\t\t\t\t\t: 'border-blue-500/30 bg-blue-500/10 text-blue-400'}\"\n\t\t\t>\n\t\t\t\t<span class=\"min-w-0 flex-1 break-words whitespace-pre-wrap\"\n\t\t\t\t\t>{notice.message}</span\n\t\t\t\t>\n\t\t\t\t<button\n\t\t\t\t\tonclick={() => dismissNotice()}\n\t\t\t\t\taria-label=\"Dismiss notice\"\n\t\t\t\t\tclass=\"flex-shrink-0 opacity-80 hover:opacity-100\">X</button\n\t\t\t\t>\n\t\t\t</div>\n\t\t{/if}\n\n\t\t<!-- Session error notification. The message can be long, so it scrolls\n\t\t within a bounded, wrapping area while the close button stays pinned and\n\t\t never gets pushed off-screen. -->\n\t\t{#if sError}\n\t\t\t<div\n\t\t\t\tclass=\"flex items-start justify-between gap-2 border border-red-500/30 bg-red-500/10 px-4 py-2 text-sm text-rose-400\"\n\t\t\t>\n\t\t\t\t<span\n\t\t\t\t\tclass=\"max-h-24 min-w-0 flex-1 overflow-y-auto break-words whitespace-pre-wrap\"\n\t\t\t\t\t>{sError}</span\n\t\t\t\t>\n\t\t\t\t<button\n\t\t\t\t\tonclick={() => dismissSessionError()}\n\t\t\t\t\taria-label=\"Dismiss error\"\n\t\t\t\t\tclass=\"flex-shrink-0 text-rose-300 hover:text-rose-200\">X</button\n\t\t\t\t>\n\t\t\t</div>\n\t\t{/if}\n\n\t\t<!-- Read-only banner -->\n\t\t{#if readOnly && !interrupted}\n\t\t\t<div\n\t\t\t\tclass=\"border border-yellow-500/30 bg-yellow-500/10 px-4 py-2 text-center text-sm text-yellow-400\"\n\t\t\t>\n\t\t\t\tRead-only: this session cannot be driven from here\n\t\t\t</div>\n\t\t{/if}\n\n\t\t<!-- Chat area -->\n\t\t<ChatMessageList bind:this={chatList} onMessageSent={() => {}} />\n\n\t\t<!-- Input: one composer, mode-switched. Search mode when connected, a\n\t\t search folder is configured, and no session is active; chat mode\n\t\t otherwise. Always mounted so it can be focused inside a tap gesture.\n\t\t EXCEPTION: a read-only session (e.g. a sessions.readOnly fleet folder)\n\t\t hides the composer entirely -- it is an observe-only view. -->\n\t\t{#if readOnly && sessionInfo.sessionFile}\n\t\t\t<div\n\t\t\t\tclass=\"border-t border-brand-border bg-brand-surface px-4 py-3 text-center text-xs text-brand-text-muted\"\n\t\t\t>\n\t\t\t\t👁️ Read-only session, observing only, no input.\n\t\t\t</div>\n\t\t{:else}\n\t\t\t<!-- Suspended/reconnecting: show a thin status banner ABOVE the composer\n\t\t\t instead of replacing it. Keeping ChatInput mounted preserves the\n\t\t\t textarea (and any in-progress draft) in the live DOM so a resync can\n\t\t\t never destroy what the user was typing; the composer is merely\n\t\t\t disabled until the socket is back and the session has resynced. -->\n\t\t\t{#if sessionInfo.sessionFile && (resyncing || !connected)}\n\t\t\t\t<div\n\t\t\t\t\tclass=\"flex items-center justify-center gap-2 border-t border-brand-border bg-brand-surface px-4 py-2 text-center text-sm text-brand-text-muted\"\n\t\t\t\t>\n\t\t\t\t\t<span\n\t\t\t\t\t\tclass=\"h-3.5 w-3.5 animate-spin rounded-full border-2 border-brand-blue border-t-transparent\"\n\t\t\t\t\t></span>\n\t\t\t\t\t<span>Reconnecting and syncing session...</span>\n\t\t\t\t</div>\n\t\t\t{:else if sessionInfo.sessionFile && agentPending}\n\t\t\t\t<!-- Fast-first load: the conversation is already readable above, but the\n\t\t\t\t live agent is still building (cold session). Block only the\n\t\t\t\t composer, with a distinct hint, so reading/scrolling stay instant. -->\n\t\t\t\t<div\n\t\t\t\t\tclass=\"flex items-center justify-center gap-2 border-t border-brand-border bg-brand-surface px-4 py-2 text-center text-sm text-brand-text-muted\"\n\t\t\t\t>\n\t\t\t\t\t<span\n\t\t\t\t\t\tclass=\"h-3.5 w-3.5 animate-spin rounded-full border-2 border-brand-blue border-t-transparent\"\n\t\t\t\t\t></span>\n\t\t\t\t\t<span>Preparing the session agent...</span>\n\t\t\t\t</div>\n\t\t\t{/if}\n\t\t\t<ChatInput\n\t\t\t\tbind:this={chatInput}\n\t\t\t\tsearchMode={searchActive}\n\t\t\t\tsearchConfigured={!!searchFolder}\n\t\t\t\t{searchModels}\n\t\t\t\tbind:searchModel\n\t\t\t\tonSubmit={(q) => runSearch(q, searchModel)}\n\t\t\t\tplaceholder=\"Search the web...\"\n\t\t\t\tsubmitLabel=\"Search\"\n\t\t\t\tdisabled={searchActive\n\t\t\t\t\t? !connected\n\t\t\t\t\t: !connected ||\n\t\t\t\t\t\treadOnly ||\n\t\t\t\t\t\t!sessionInfo.sessionFile ||\n\t\t\t\t\t\tresyncing ||\n\t\t\t\t\t\tagentPending}\n\t\t\t\tonSend={() => chatList?.forceScrollToBottom()}\n\t\t\t/>\n\t\t{/if}\n\t</div>\n\n\t<!-- Session Conflict Dialog -->\n\t<SessionConflictDialog />\n\n\t<!-- Sudo password prompt for `!sudo ...` commands -->\n\t<SudoPasswordDialog />\n\n\t<!-- Overlay for mobile sidebar -->\n\t{#if sidebarOpen}\n\t\t<button\n\t\t\ttype=\"button\"\n\t\t\tclass=\"fixed inset-0 z-10 bg-brand-dark/50 md:hidden\"\n\t\t\tonclick={() => (sidebarOpen = false)}\n\t\t\taria-label=\"Close sidebar\"\n\t\t></button>\n\t{/if}\n</div>\n"],"file":"2.D-h8cHh0.js"}
|