@wangjian2254/pi-web 1.0.30 → 1.0.32

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.
Files changed (36) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/app-path-routes-manifest.json +9 -9
  3. package/.next/build-manifest.json +2 -2
  4. package/.next/required-server-files.js +7 -2
  5. package/.next/required-server-files.json +7 -2
  6. package/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  7. package/.next/server/app/_global-error.html +1 -1
  8. package/.next/server/app/_global-error.rsc +1 -1
  9. package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  10. package/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  11. package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  12. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  13. package/.next/server/app/_not-found.html +1 -1
  14. package/.next/server/app/_not-found.rsc +3 -3
  15. package/.next/server/app/_not-found.segments/_full.segment.rsc +3 -3
  16. package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +3 -3
  17. package/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  18. package/.next/server/app/index.html +1 -1
  19. package/.next/server/app/index.rsc +5 -5
  20. package/.next/server/app/index.segments/__PAGE__.segment.rsc +5 -5
  21. package/.next/server/app/index.segments/_full.segment.rsc +5 -5
  22. package/.next/server/app/index.segments/_tree.segment.rsc +1 -1
  23. package/.next/server/app/page.js +1 -1
  24. package/.next/server/app/page_client-reference-manifest.js +1 -1
  25. package/.next/server/app-paths-manifest.json +9 -9
  26. package/.next/server/middleware-build-manifest.js +1 -1
  27. package/.next/server/pages/404.html +1 -1
  28. package/.next/server/pages/500.html +1 -1
  29. package/.next/static/chunks/app/{layout-866f8051b953d4a9.js → layout-fcfadca2b0c54869.js} +1 -1
  30. package/.next/static/chunks/app/{page-5279bb8fda2b87a8.js → page-8f29ba37bd8f99ca.js} +1 -1
  31. package/.next/trace +6 -6
  32. package/.next/trace-build +1 -1
  33. package/next.config.ts +13 -0
  34. package/package.json +1 -1
  35. /package/.next/static/{BfCGHPX4rfBnMLatAZV0Q → tzIdZNyWPpbaeJuTTF_pG}/_buildManifest.js +0 -0
  36. /package/.next/static/{BfCGHPX4rfBnMLatAZV0Q → tzIdZNyWPpbaeJuTTF_pG}/_ssgManifest.js +0 -0
@@ -1,4 +1,4 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8974],{14755:(e,t,n)=>{"use strict";n.d(t,{getPresetFromTools:()=>c,sn:()=>d,xG:()=>u});let r=["none","read-only","default","full"],i=[],o=["read","grep","find","ls"],l=["read","bash","edit","write"],s=["bash","read","edit","write","grep","find","ls"],a=new Set(s);function d(e){return"string"==typeof e&&r.includes(e)}function c(e){let t=e.filter(e=>e.active);if(0===t.length)return"none";let n=t.map(e=>e.name).filter(e=>a.has(e)).sort().join(",");return n===[...o].sort().join(",")?"read-only":n===[...l].sort().join(",")?"default":n===[...s].sort().join(",")?"full":"default"}function u(e){return"none"===e?[...i]:"read-only"===e?[...o]:"full"===e?[...s]:[...l]}},26619:(e,t,n)=>{"use strict";n.d(t,{DP:()=>d,eH:()=>c,hd:()=>i,o2:()=>r});let r="/pi-web";function i(e){return!r||!e.startsWith("/")||e.startsWith(r)||e.startsWith("/_next/")||"/sw.js"===e||e.startsWith("/sw.js?")?e:`${r}${e}`}function o(e){return e.startsWith("/")&&!e.startsWith("/_next/")&&!e.startsWith(r)}let l=!1,s=new URLSearchParams(window.location.search).get("cookie_sessionid");function a(e){if(!s||!e.startsWith("/api/"))return e;let t=e.indexOf("?"),n=-1===t?e:e.slice(0,t),r=new URLSearchParams(-1===t?"":e.slice(t+1));return r.set("cookie_sessionid",s),`${n}?${r.toString()}`}function d(e){return i(a(e))}function c(){if(l||!r)return;l=!0;let e=window.fetch.bind(window);window.fetch=(t,n)=>("string"==typeof t?t=d(t):t instanceof URL&&t.origin===window.location.origin&&o(t.pathname)&&(t=new URL(`${r}${t.pathname}${t.search}`,t.origin)),e(t,n));let t=window.EventSource;if(t){class e extends t{constructor(e,t){if("string"==typeof e){const n=a(e);super(o(n)?`${r}${n}`:n,t)}else super(e,t)}}window.EventSource=e}}},36149:(e,t,n)=>{Promise.resolve().then(n.bind(n,73964)),Promise.resolve().then(n.bind(n,39247))},39247:(e,t,n)=>{"use strict";n.d(t,{I18nProvider:()=>c,s:()=>u});var r=n(95155),i=n(12115);let o=new Map;function l(e){if(!e.id.trim())throw Error("Locale id must not be empty");if(o.has(e.id))throw Error(`Locale already registered: ${e.id}`);o.set(e.id,e)}function s(){return[...o.keys()]}l({id:"en",label:"English",messages:{"common.ok":"OK","common.language":"Language","common.models":"Models","common.skills":"Skills","common.plugins":"Plugins","sidebar.hide":"Hide sidebar","sidebar.show":"Show sidebar","theme.light":"Light mode (click for dark)","theme.dark":"Dark mode (click for system)","theme.auto":"System theme (click for light)","history.full":"Full history","history.unsaved":"Full history is available after the session is saved","history.label":"Full history","title.generating":"Generating...","title.updated":"Title updated","title.failed":"Generation failed","title.generate":"Generate title","title.unsaved":"Title generation is available after the session is saved","title.noMessages":"Send a message before naming this session","title.generateSession":"Generate a session title","system.prompt":"System prompt","system.empty":"System prompt is empty (tools are disabled)","system.load":"System prompt has not loaded yet","system.loading":"Loading system prompt…","system.label":"System","session.info":"Session info","session.name":"Name","session.file":"File","session.inMemory":"In-memory","session.id":"ID","session.user":"User","session.assistant":"Assistant","session.toolCalls":"Tool Calls","session.toolResults":"Tool Results","session.total":"Total","session.input":"Input","session.output":"Output","session.cacheRead":"Cache Read","session.cacheWrite":"Cache Write","session.cost":"Cost","session.context":"Context","session.cacheHitRate":"Avg cache hit rate","session.copy":"Copy {value}","session.copied":"Copied","session.title":"Session info","session.load":"Send a message or run /session to load session info","session.infoSection":"Session Info","session.messages":"Messages","session.tokens":"Tokens","session.totalActive":"Active Time","session.copyFile":"Copy file path","session.copyId":"Copy session ID","workspace.opening":"Opening workspace...","workspace.unable":"Unable to open workspace","auth.deniedTitle":"Access denied","auth.deniedBody":"The login session is invalid or expired and the current user could not be verified. Please log in to LiYuBase3 first, then refresh this page.","auth.retry":"Retry","workspace.selectSession":"Select a session from the sidebar","workspace.getStarted":"Get Started","workspace.selectProject":"Select a project directory from the sidebar","workspace.addModels":"Add models via the Models button at the bottom","workspace.stepProject":"Select a project directory from the sidebar","workspace.stepModels":"Add models via the Models button at the bottom","files.hidePanel":"Hide file panel","files.showPanel":"Show file panel","files.noneOpen":"No file open","layout.resizeSidebar":"Resize sidebar","layout.resizeFilePanel":"Resize file panel","layout.resizeHint":"Drag to resize. Double-click or press Enter to reset.","sidebar.new":"New","sidebar.newSessionTitle":"New session in {path}","sidebar.refresh":"Refresh","sidebar.selectProject":"Select project…","sidebar.filterProjects":"Filter projects…","sidebar.noMatchingProjects":"No matching projects","sidebar.useDefaultDirectory":"Use default directory","sidebar.customPath":"Custom path…","directoryPicker.selectDirectory":"Select directory","directoryPicker.goToParent":"Go to parent directory","directoryPicker.directoryPath":"Directory path","directoryPicker.goToDirectory":"Go to directory","directoryPicker.go":"Go","directoryPicker.loadingDirectories":"Loading directories…","directoryPicker.noSubdirectories":"No subdirectories","directoryPicker.openBeforeSelecting":"Open this path before selecting it","directoryPicker.selectCurrentDirectory":"Select current directory","directoryPicker.selectThisFolder":"Select this folder","directoryPicker.noDrives":"No drives found","sidebar.checking":"Checking…","sidebar.open":"Open","sidebar.cancel":"Cancel","sidebar.openRepoRoot":"Open repo root","sidebar.openRepoRootTitle":"Open the repository root to manage worktrees.","sidebar.gitRepoRootOnly":"Git repo root only","sidebar.gitRepoRootOnlyTitle":"Worktrees are available in Git repository roots.","sidebar.worktrees":"Worktrees...","sidebar.checkingWorktrees":"Checking worktrees for this directory.","sidebar.filterWorktrees":"Filter worktrees…","sidebar.noMatchingWorktrees":"No matching worktrees","sidebar.switchWorktree":"Switch worktree","sidebar.switchWorktreeTitle":"Switch worktree: {path}","sidebar.main":"main","sidebar.forceRemoveCheckout":"Uncommitted changes. Force remove checkout?","sidebar.force":"Force","sidebar.createWorktreeTitle":"Create a worktree checkout for a branch","sidebar.newWorktree":"New worktree…","sidebar.branchName":"branch name","sidebar.creating":"Creating…","sidebar.create":"Create","sidebar.uploadFilesTitle":"Upload files to project root","sidebar.uploadFiles":"Upload files","sidebar.refreshExplorer":"Refresh explorer","sidebar.changedFiles":"{count} changed files","sidebar.loading":"Loading...","sidebar.noSessions":"No sessions found","sidebar.agentRunning":"Agent running…","sidebar.newActivity":"New activity","sidebar.newSessionActivity":"New session activity","sidebar.deleteSession":"Delete {title}?","sidebar.rename":"Rename","sidebar.delete":"Delete","sidebar.deleteWithShiftClick":"Delete (Shift+click to delete without confirmation)","sidebar.expandForks":"Expand forks","sidebar.collapseForks":"Collapse forks","sidebar.messagesCount":"{count} msgs","sidebar.worktreePath":"Worktree: {path}","sidebar.removeWorktreeTitle":"Remove worktree checkout {path}; the branch is kept","files.modified":"Modified","files.added":"Added","files.deleted":"Deleted","files.renamed":"Renamed","files.untracked":"Untracked","files.conflict":"Conflict","files.newlyUploaded":"Newly uploaded","files.containsChangedFiles":"Contains changed files","files.insertPath":"Insert path into chat","files.mention":"mention","files.download":"Download file","files.delete":"Delete file","files.deleteAction":"Delete","files.deleteConfirm":"Delete {name}? This cannot be undone.","files.deleteDirConfirm":"Delete directory {name} and all of its contents? This cannot be undone.","files.deleteFailed":"Failed to delete","files.dismissError":"Dismiss error","files.addUploadedFile":"Add uploaded file to chat","files.addAllUploadedFiles":"Add all uploaded files to chat","files.dismissUploadResults":"Dismiss upload results","files.loading":"Loading files...","files.noFiles":"No files found","files.explorer":"Explorer","files.changedCount":"{count} files","files.changeStats":"{count} changed files, {additions} lines added, {deletions} lines deleted","files.conflictSummary":"{count} file{countSuffix} already exist: {files}","files.cannotReplace":"Cannot replace: {files}","files.replace":"Replace","files.skipExisting":"Skip existing","files.cancel":"Cancel","files.checking":"Checking files","files.uploading":"Uploading, {progress}%","chat.loadingSession":"Loading session...","chat.runningTool":"Running tool...","chat.generatingToolInput":"Generating parameters...","chat.runningNamedTool":"Running {name}...","chat.runningTools":"Running {names}...","chat.runningToolsMore":"Running {names} (+{count})...","chat.waitingModel":"Waiting for model...","chat.runningCommand":"Running command...","chat.thinking":"Thinking...","chat.processDetails":"Process details","chat.message":"message","chat.messages":"messages","chat.toolCall":"tool call","chat.toolCalls":"tool calls","chat.collapseProcess":"Collapse process details","chat.expandProcess":"Expand process details","chat.filesWritten":"Files changed","chat.openWrittenFile":"Open {name}","chat.loadEarlier":"Scroll up to load earlier messages ({count} hidden)","chat.extensionRequest":"extension request","chat.cancel":"Cancel","chat.confirm":"Confirm","chat.submit":"Submit","chat.extensionInput":"Extension terminal input","chat.extensionPanel":"Extension panel","chat.extensionWidgets":"Extension widgets","chat.extensionWidgetAbove":"Above editor widget","chat.extensionWidgetBelow":"Below editor widget","chat.extensionWidgetLine":"{count} line","chat.extensionWidgetLines":"{count} lines","chat.close":"Close","chat.queued":"Queued \xb7 {count}","chat.recall":"Recall to input","chat.recallTitle":"Remove all queued messages and put them back into the input box for editing","chat.retrying":"Retrying ({attempt}/{max})…","chat.loadingCommands":"Loading commands...","chat.slashCommands":"Slash commands \xb7 {label}","chat.tabEnter":"Tab / Enter","chat.noCommands":"No extension, prompt, or skill commands found","chat.match":"1 match","chat.matches":"{count} matches","chat.command":"1 command","chat.commands":"{count} commands","chat.loadingFiles":"Loading files...","chat.files":"Files \xb7 {label}{hint}","chat.searching":"Searching…","chat.noMatchingFiles":"No matching files","chat.searchingAll":" \xb7 searching all files…","chat.indexTruncated":" \xb7 index truncated","chat.steerPlaceholder":"Steer now / queue follow-up...","chat.agentPlaceholder":"Agent is running…","chat.messagePlaceholder":"Message… Type / for commands, @ for files","chat.steer":"Steer","chat.followUp":"Follow-up","chat.send":"Send","chat.removePrefix":"Remove prefix","chat.attachFile":"Attach files (images use the image flow, other files are added as attachment context)","chat.attachmentUploading":"Uploading…","chat.attachmentFailed":"Upload failed","chat.previewImage":"Preview image","chat.filterModels":"Filter models…","chat.noMatchingModels":"No matching models","chat.moreControls":"More controls","chat.collapseControls":"Collapse controls","chat.shell":"Shell","chat.outputLocal":"output stays local","chat.outputModel":"output sent to model","chat.noTools":"No tools","chat.readOnlyTools":"{count} read-only built-in tools","chat.builtInTools":"{count} built-in tools","chat.allBuiltInTools":"All built-in tools","chat.changeReasoning":"Change reasoning level: {level}","chat.changeReasoningLabel":"Change reasoning level","chat.changeToolPreset":"Change tool preset","chat.stopCompaction":"Stop compaction","chat.compactContext":"Compact context","chat.compacting":"Compacting…","chat.compact":"Compact","chat.stopAgent":"Stop agent","chat.stop":"Stop","chat.disableSound":"Disable completion sound","chat.enableSound":"Enable completion sound","chat.thinkingUseDefault":"Use pi default","chat.thinkingOff":"Reasoning off","chat.thinkingMinimal":"Minimal reasoning","chat.thinkingLow":"Low reasoning","chat.thinkingMedium":"Medium reasoning","chat.thinkingHigh":"High reasoning","chat.thinkingXhigh":"Extra-high reasoning","chat.thinkingMax":"Max reasoning","chat.builtIn":"Built-in","chat.extensions":"Extensions","chat.prompts":"Prompts","chat.skills":"Skills","chat.dormant":"dormant","chat.commandCompact":"Compress context, optionally with instructions","chat.commandReload":"Reload extensions, skills, prompts, and tools","chat.commandName":"Set the session display name","chat.commandSession":"Show session message, token, and cost stats","chat.commandCopy":"Copy the last assistant message","chat.compacted":"Compacted","chat.tokensSaved":"{saved} saved","i18n.close":"Close","i18n.copy":"Copy","i18n.copied":"Copied","i18n.cancel":"Cancel","i18n.save":"Save","i18n.saving":"Saving…","i18n.saved":"Saved","i18n.remove":"Remove","i18n.removing":"Removing…","i18n.delete":"Delete","i18n.loading":"Loading...","i18n.search":"Search","i18n.refresh":"Refresh","i18n.update":"Update","i18n.updating":"Updating...","i18n.check":"Check","i18n.checking":"Checking...","i18n.install":"Install","i18n.installing":"Installing...","i18n.noResults":"No results","i18n.searchProviders":"Search providers…","i18n.noProviders":"No providers match","i18n.newModel":"new model","i18n.addProvider":"Add provider","i18n.selectProviderModel":"Select a provider or model","i18n.visibleInPrompt":"Visible in model prompt — click to disable","i18n.hiddenFromPrompt":"Hidden from model prompt — click to enable","i18n.dormant":"Dormant","i18n.hiddenButInvocable":"Hidden from model, still manually invocable","i18n.skillSearchPlaceholder":"e.g. react, testing, deploy","i18n.searching":"Searching…","i18n.noSkills":"No skills found","i18n.checkUpdates":"Check updates","i18n.updates":"updates","i18n.noResolvedResources":"No resolved resources","i18n.enablePackage":"Enable package","i18n.disablePackage":"Disable package","i18n.filtered":"filtered","i18n.openSessionToReload":"Open a session to reload","i18n.notFound":"Not found","i18n.noPlugins":"No plugins configured","trust.resourcesNotLoaded":"Restricted mode","trust.trustProject":"Trust project","trust.trusting":"Trusting...","trust.cancel":"Cancel","trust.dialogTitle":"Trust this project?","trust.dialogBody":"Project resources can run local code. Trust only projects whose contents you know.","trust.skillsNotLoaded":"Project skills are not loaded because this project is not trusted.","trust.pluginsNotLoaded":"Project plugins are not loaded because this project is not trusted.","trust.projectScopeUnavailable":"Project installs are unavailable while project resources are not loaded.","i18n.creatingSession":"Creating new session…","i18n.creating":"Creating…","i18n.subscription":"Subscription","i18n.subscriptions":"Subscriptions","i18n.customEndpoint":"Custom endpoint format","i18n.noChanges":"No changes","i18n.branches":"Branches","i18n.noActiveSession":"No active session","i18n.noBranches":"This session has no branches","i18n.source":"Source","i18n.preview":"Preview","i18n.diff":"Diff","i18n.downloadFile":"Download file","i18n.liveSync":"Live sync active","i18n.notWatching":"Not watching","i18n.fileViewMode":"File view mode","i18n.compareHead":"Compare working tree with HEAD","i18n.mentionSelectedLines":"Mention selected lines","i18n.disableWrap":"Disable word wrap","i18n.enableWrap":"Enable word wrap","i18n.htmlPreview":"HTML preview","i18n.previewFile":"Preview {file}","i18n.convertingDocument":"Converting…","i18n.invalidMermaid":"Invalid Mermaid diagram","i18n.renderingMermaid":"Rendering Mermaid diagram","i18n.previewAfterStreaming":"Preview available after streaming","i18n.showMermaidSource":"Show Mermaid source","i18n.previewMermaid":"Preview Mermaid diagram","i18n.openMermaidViewer":"Open diagram viewer","i18n.mermaidViewer":"Mermaid diagram viewer","i18n.mermaidDiagram":"Mermaid diagram","i18n.zoomOut":"Zoom out","i18n.zoomIn":"Zoom in","i18n.fitToWidth":"Fit to width","models.discoveryFetching":"Importing models…","models.discoveryFetch":"Import models…","models.discoveryFilterPlaceholder":"Filter {count} models…","models.discoveryFilter":"Filter upstream models","models.discoverySelectShown":"Select shown","models.discoveryNoMatches":"No matching models.","models.discoveryAdded":"added","models.discoveryShowing":"Showing first {shown} of {total}","models.discoveryFetched":"{count} models fetched","models.discoveryAddSelected":"Add selected","models.discoveryAddSelectedCount":"Add selected ({count})","models.catalogSource":"source: models.dev ↗","models.catalogFilling":"Filling details…","models.catalogFill":"Fill model details","models.catalogFilled":"{count} fields filled","models.catalogNoEmptyFields":"No empty fields to fill","models.catalogNoExactMatch":"No exact models.dev match","models.catalogPriceProvider":"Price matched Provider {provider}","models.catalogPriceBaseUrl":"Price matched Base URL to {provider}","models.catalogPriceConsensus":"Price agreed by {support}/{total} records","models.catalogPriceUnreliable":"No reliable price found","models.catalogUndo":"Undo","models.capabilities":"Capabilities","models.reasoning":"Reasoning / thinking","models.imageInput":"Image input","models.modelSpecs":"Model specifications","models.contextWindow":"Context window (tokens)","models.maxOutputTokens":"Max output tokens","models.costPerMillion":"Cost per million tokens","models.costInput":"Input","models.costOutput":"Output","models.costCacheRead":"Cache read","models.costCacheWrite":"Cache write","models.notProvided":"Not provided","models.editCosts":"Edit prices","models.finishEditingCosts":"Done","models.costAllRequired":"Enter a valid non-negative price; blank fields are saved as 0.","models.advancedSettings":"Advanced settings","models.providerDefaults":"Using provider defaults","models.headersSummary":"Headers: {count}","models.compatSummary":"Compatibility: {count}","models.thinkingSummary":"Thinking levels: {count}","models.apiOverride":"API override","models.headers":"Headers","models.headersHelp":"Added to this model's requests and overrides provider headers.","models.compatibility":"Compatibility","models.deepSeekThinkingCompat":"DeepSeek thinking compatibility","models.developerRole":"Use the developer role for the system prompt","models.thinkingLevelMap":"Thinking level map","models.clearAll":"Clear all","i18n.testingModel":"Testing model connection...","i18n.connected":"Connected","i18n.failed":"Failed","i18n.test":"Test","i18n.testConnection":"Test model connection","i18n.provider":"Provider","i18n.model":"Model","i18n.providerName":"Provider name","i18n.rename":"Rename","i18n.default":"Default","i18n.disabled":"Disabled","i18n.noResources":"No resources","i18n.unknown":"Unknown","i18n.installedVersion":"installed {version}","i18n.configuredVersion":"configured {version}","i18n.extensions":"Extensions","i18n.prompts":"Prompts","i18n.themes":"Themes","i18n.resourceCount":"{count} {label}","i18n.extensionShort":"ext","i18n.skillShort":"skills","i18n.promptShort":"prompts","i18n.themeShort":"themes","i18n.custom":"Custom","i18n.clearAll":"clear all","i18n.connectedSuccessfully":"Connected successfully.","i18n.notConnected":"not connected","i18n.configured":"configured","i18n.notConfigured":"not configured","i18n.openingBrowser":"Opening browser…","i18n.submit":"Submit","i18n.login":"Login","i18n.relogin":"Re-login","i18n.disconnect":"Disconnect","i18n.networkError":"Network error","i18n.continuing":"Continuing…","i18n.skills":"Skills","i18n.plugins":"Plugins","i18n.addSkill":"Add skill","i18n.addPlugin":"Add plugin","i18n.selectSkill":"Select a skill","i18n.selectPackage":"Select a package","i18n.updateAvailable":"Update available","i18n.upToDate":"Up to date","i18n.automaticChecksUnavailable":"Automatic checks unavailable","i18n.checkFailed":"Check failed","i18n.installed":"Installed","i18n.status":"Status","i18n.version":"Version","i18n.package":"Package","i18n.resources":"Resources","i18n.installedPath":"Installed path","i18n.cwd":"CWD","i18n.resolvedResources":"Resolved Resources","i18n.reloadSession":"Reload session","i18n.reloading":"Reloading...","i18n.packageRemoved":"Package removed.","i18n.packageInstalled":"Package installed.","i18n.packageUpdated":"Package updated.","i18n.packageDisabled":"Package disabled.","i18n.packageEnabled":"Package enabled.","i18n.sessionReloaded":"Session reloaded.","i18n.thinking":"Thinking","i18n.largeMessageReveal":"Message content is very large ({size}). Click to view as plain text — markdown rendering is disabled to keep the page responsive.","i18n.loadingThinking":"Loading thinking...","i18n.copyMessage":"Copy message","i18n.editFromHere":"Edit from here","i18n.editFromHereTitle":"Edit from here — branches within this session","i18n.newSession":"New session","i18n.newSessionTitle":"New session — creates an independent copy from here","i18n.estimatedTokens":"Estimated token count while streaming","i18n.noOutput":"(no output)","i18n.noSummary":"(no summary)","i18n.conversationCompacted":"Conversation compacted","i18n.compactionDescription":"The conversation history before this point was compacted into the following summary:","i18n.fileContext":"File context: {details}","i18n.readFiles":"Read files","i18n.modifiedFiles":"Modified files","i18n.hiddenExtensionMessage":"hidden extension message","i18n.noMessage":"(no message)","i18n.showExtensionMessage":"Show extension message","i18n.collapse":"Collapse","i18n.expand":"Expand","i18n.hideDetails":"Hide details","i18n.showDetails":"Show details","i18n.thinkingUnavailable":"Thinking content unavailable","i18n.before":"Before","i18n.after":"After","i18n.sessionComplete":"Session complete","i18n.taskFinished":"Task finished.","i18n.attentionNeeded":"Pi needs your attention","i18n.extensionInputNeeded":"An extension is waiting for your input."}}),l({id:"zh-CN",label:"简体中文",messages:{"common.ok":"确定","common.language":"语言","common.models":"模型","common.skills":"技能","common.plugins":"插件","sidebar.hide":"隐藏侧边栏","sidebar.show":"显示侧边栏","theme.light":"浅色模式(点击切换到深色)","theme.dark":"深色模式(点击切换到跟随系统)","theme.auto":"跟随系统(点击切换到浅色)","history.full":"完整历史","history.unsaved":"会话保存后才能查看完整历史","history.label":"完整历史","title.generating":"正在生成...","title.updated":"标题已更新","title.failed":"生成失败","title.generate":"生成标题","title.unsaved":"会话保存后才能生成标题","title.noMessages":"请先发送消息,再为会话命名","title.generateSession":"生成会话标题","system.prompt":"系统提示词","system.empty":"系统提示词为空(工具已禁用)","system.load":"系统提示词尚未加载","system.loading":"正在加载系统提示词…","system.label":"系统","session.info":"会话信息","session.name":"名称","session.file":"文件","session.inMemory":"内存中","session.id":"ID","session.user":"用户","session.assistant":"助手","session.toolCalls":"工具调用","session.toolResults":"工具结果","session.total":"总计","session.input":"输入","session.output":"输出","session.cacheRead":"缓存读取","session.cacheWrite":"缓存写入","session.cost":"费用","session.context":"上下文","session.cacheHitRate":"平均缓存命中率","session.copy":"复制{value}","session.copied":"已复制","session.title":"会话信息","session.load":"发送消息或运行 /session 以加载会话信息","session.infoSection":"会话信息","session.messages":"消息","session.tokens":"Token","session.totalActive":"活跃时长","session.copyFile":"复制文件路径","session.copyId":"复制会话 ID","workspace.opening":"正在打开工作区...","workspace.unable":"无法打开工作区","auth.deniedTitle":"无法访问","auth.deniedBody":"登录状态无效或已过期,无法确认当前用户。请先登录,然后刷新本页面。","auth.retry":"重试","workspace.selectSession":"从侧边栏选择一个会话","workspace.getStarted":"开始使用","workspace.selectProject":"从侧边栏选择项目目录","workspace.addModels":"点击底部的“模型”按钮添加模型","workspace.stepProject":"从侧边栏选择项目目录","workspace.stepModels":"点击底部的“模型”按钮添加模型","files.hidePanel":"隐藏文件面板","files.showPanel":"显示文件面板","files.noneOpen":"没有打开的文件","layout.resizeSidebar":"调整侧边栏宽度","layout.resizeFilePanel":"调整文件面板宽度","layout.resizeHint":"拖动调整宽度。双击或按 Enter 恢复默认值。","sidebar.new":"新建","sidebar.newSessionTitle":"在 {path} 中新建会话","sidebar.refresh":"刷新","sidebar.selectProject":"选择项目…","sidebar.filterProjects":"筛选项目…","sidebar.noMatchingProjects":"没有匹配的项目","sidebar.useDefaultDirectory":"使用默认目录","sidebar.customPath":"自定义路径…","directoryPicker.selectDirectory":"选择目录","directoryPicker.goToParent":"转到上级目录","directoryPicker.directoryPath":"目录路径","directoryPicker.goToDirectory":"转到目录","directoryPicker.go":"转到","directoryPicker.loadingDirectories":"正在加载目录…","directoryPicker.noSubdirectories":"没有子目录","directoryPicker.openBeforeSelecting":"选择前请先打开此路径","directoryPicker.selectCurrentDirectory":"选择当前目录","directoryPicker.selectThisFolder":"选择此文件夹","directoryPicker.noDrives":"未找到盘符","sidebar.checking":"检查中…","sidebar.open":"打开","sidebar.cancel":"取消","sidebar.openRepoRoot":"打开仓库根目录","sidebar.openRepoRootTitle":"打开仓库根目录以管理 worktree。","sidebar.gitRepoRootOnly":"仅 Git 仓库根目录","sidebar.gitRepoRootOnlyTitle":"只能在 Git 仓库根目录使用 worktree。","sidebar.worktrees":"Worktrees...","sidebar.checkingWorktrees":"正在检查此目录的 worktree。","sidebar.filterWorktrees":"筛选 worktree…","sidebar.noMatchingWorktrees":"没有匹配的 worktree","sidebar.switchWorktree":"切换 worktree","sidebar.switchWorktreeTitle":"切换 worktree:{path}","sidebar.main":"主分支","sidebar.forceRemoveCheckout":"存在未提交的更改。强制移除 checkout?","sidebar.force":"强制移除","sidebar.createWorktreeTitle":"为分支创建 worktree checkout","sidebar.newWorktree":"新建 worktree…","sidebar.branchName":"分支名称","sidebar.creating":"创建中…","sidebar.create":"创建","sidebar.uploadFilesTitle":"将文件上传到项目根目录","sidebar.uploadFiles":"上传文件","sidebar.refreshExplorer":"刷新文件浏览器","sidebar.changedFiles":"{count} 个变更文件","sidebar.loading":"加载中...","sidebar.noSessions":"未找到会话","sidebar.agentRunning":"Agent 运行中…","sidebar.newActivity":"有新活动","sidebar.newSessionActivity":"会话有新活动","sidebar.deleteSession":"删除 {title}?","sidebar.rename":"重命名","sidebar.delete":"删除","sidebar.deleteWithShiftClick":"删除(按住 Shift 点击可跳过确认)","sidebar.expandForks":"展开分叉","sidebar.collapseForks":"折叠分叉","sidebar.messagesCount":"{count} 条消息","sidebar.worktreePath":"Worktree:{path}","sidebar.removeWorktreeTitle":"移除 worktree checkout {path};保留分支","files.modified":"已修改","files.added":"已添加","files.deleted":"已删除","files.renamed":"已重命名","files.untracked":"未跟踪","files.conflict":"冲突","files.newlyUploaded":"刚上传","files.containsChangedFiles":"包含已更改文件","files.insertPath":"将路径插入聊天","files.mention":"提及","files.download":"下载文件","files.delete":"删除文件","files.deleteAction":"删除","files.deleteConfirm":"删除 {name}?此操作不可恢复。","files.deleteDirConfirm":"删除目录 {name} 及其全部内容?此操作不可恢复。","files.deleteFailed":"删除失败","files.dismissError":"关闭错误","files.addUploadedFile":"将上传的文件添加到聊天","files.addAllUploadedFiles":"将所有上传的文件添加到聊天","files.dismissUploadResults":"关闭上传结果","files.loading":"正在加载文件...","files.noFiles":"未找到文件","files.explorer":"文件浏览器","files.changedCount":"{count} 个文件","files.changeStats":"{count} 个变更文件,新增 {additions} 行,删除 {deletions} 行","files.conflictSummary":"已有 {count} 个文件:{files}","files.cannotReplace":"无法替换:{files}","files.replace":"替换","files.skipExisting":"跳过已有文件","files.cancel":"取消","files.checking":"正在检查文件","files.uploading":"正在上传,{progress}%","chat.loadingSession":"正在加载会话...","chat.runningTool":"正在运行工具...","chat.generatingToolInput":"正在生成参数...","chat.runningNamedTool":"正在运行 {name}...","chat.runningTools":"正在运行 {names}...","chat.runningToolsMore":"正在运行 {names}(另有 {count} 个)...","chat.waitingModel":"正在等待模型...","chat.runningCommand":"正在运行命令...","chat.thinking":"正在思考...","chat.processDetails":"处理详情","chat.message":"条消息","chat.messages":"条消息","chat.toolCall":"次工具调用","chat.toolCalls":"次工具调用","chat.collapseProcess":"收起处理详情","chat.expandProcess":"展开处理详情","chat.filesWritten":"改动的文件","chat.openWrittenFile":"打开 {name}","chat.loadEarlier":"向上滚动以加载更早的消息(隐藏 {count} 条)","chat.extensionRequest":"扩展请求","chat.cancel":"取消","chat.confirm":"确认","chat.submit":"提交","chat.extensionInput":"扩展终端输入","chat.extensionPanel":"扩展面板","chat.extensionWidgets":"扩展组件","chat.extensionWidgetAbove":"输入框上方组件","chat.extensionWidgetBelow":"输入框下方组件","chat.extensionWidgetLine":"{count} 行","chat.extensionWidgetLines":"{count} 行","chat.close":"关闭","chat.queued":"已排队 \xb7 {count}","chat.recall":"移回输入框","chat.recallTitle":"移除所有排队消息并将其放回输入框编辑","chat.retrying":"正在重试({attempt}/{max})…","chat.loadingCommands":"正在加载命令...","chat.slashCommands":"斜杠命令 \xb7 {label}","chat.tabEnter":"Tab / Enter","chat.noCommands":"未找到扩展、提示词或技能命令","chat.match":"1 个匹配项","chat.matches":"{count} 个匹配项","chat.command":"1 个命令","chat.commands":"{count} 个命令","chat.loadingFiles":"正在加载文件...","chat.files":"文件 \xb7 {label}{hint}","chat.searching":"搜索中…","chat.noMatchingFiles":"未找到匹配的文件","chat.searchingAll":" \xb7 正在搜索所有文件…","chat.indexTruncated":" \xb7 索引不完整","chat.steerPlaceholder":"立即引导 / 排队后续消息...","chat.agentPlaceholder":"Agent 运行中…","chat.messagePlaceholder":"消息…输入 / 使用命令,输入 @ 查找文件","chat.steer":"引导","chat.followUp":"后续消息","chat.send":"发送","chat.removePrefix":"移除前缀","chat.attachFile":"附加文件(图片按图片处理,其他文件作为附件上下文)","chat.attachmentUploading":"上传中…","chat.attachmentFailed":"上传失败","chat.previewImage":"预览图片","chat.filterModels":"筛选模型…","chat.noMatchingModels":"没有匹配的模型","chat.moreControls":"更多控件","chat.collapseControls":"收起控件","chat.shell":"Shell","chat.outputLocal":"输出保留在本地","chat.outputModel":"输出发送给模型","chat.noTools":"不使用工具","chat.readOnlyTools":"{count} 个只读内置工具","chat.builtInTools":"{count} 个内置工具","chat.allBuiltInTools":"全部内置工具","chat.changeReasoning":"更改推理级别:{level}","chat.changeReasoningLabel":"更改推理级别","chat.changeToolPreset":"更改工具预设","chat.stopCompaction":"停止压缩","chat.compactContext":"压缩上下文","chat.compacting":"正在压缩…","chat.compact":"压缩","chat.stopAgent":"停止 Agent","chat.stop":"停止","chat.disableSound":"关闭完成提示音","chat.enableSound":"开启完成提示音","chat.thinkingUseDefault":"使用 pi 默认设置","chat.thinkingOff":"关闭推理","chat.thinkingMinimal":"最低限度推理","chat.thinkingLow":"低强度推理","chat.thinkingMedium":"中等强度推理","chat.thinkingHigh":"高强度推理","chat.thinkingXhigh":"超高强度推理","chat.thinkingMax":"最高强度推理","chat.builtIn":"内置","chat.extensions":"扩展","chat.prompts":"提示词","chat.skills":"技能","chat.dormant":"休眠","chat.commandCompact":"压缩上下文,可选附加说明","chat.commandReload":"重新加载扩展、技能、提示词和工具","chat.commandName":"设置会话显示名称","chat.commandSession":"显示会话消息、Token 和费用统计","chat.commandCopy":"复制最后一条助手消息","chat.compacted":"已压缩","chat.tokensSaved":"节省 {saved}","i18n.close":"关闭","i18n.copy":"复制","i18n.copied":"已复制","i18n.cancel":"取消","i18n.save":"保存","i18n.saving":"保存中…","i18n.saved":"已保存","i18n.remove":"移除","i18n.removing":"移除中…","i18n.delete":"删除","i18n.loading":"加载中...","i18n.search":"搜索","i18n.refresh":"刷新","i18n.update":"更新","i18n.updating":"更新中...","i18n.check":"检查","i18n.checking":"检查中...","i18n.install":"安装","i18n.installing":"安装中...","i18n.noResults":"没有结果","i18n.searchProviders":"搜索 Provider…","i18n.noProviders":"没有匹配的 Provider","i18n.newModel":"新模型","i18n.addProvider":"添加 Provider","i18n.selectProviderModel":"选择 Provider 或模型","i18n.visibleInPrompt":"在模型提示词中可见,点击以禁用","i18n.hiddenFromPrompt":"在模型提示词中隐藏,点击以启用","i18n.dormant":"休眠","i18n.hiddenButInvocable":"对模型隐藏,仍可手动调用","i18n.skillSearchPlaceholder":"例如 react、testing、deploy","i18n.searching":"搜索中…","i18n.noSkills":"未找到技能","i18n.checkUpdates":"检查更新","i18n.updates":"项更新","i18n.noResolvedResources":"没有已解析资源","i18n.enablePackage":"启用包","i18n.disablePackage":"禁用包","i18n.filtered":"已筛选","i18n.openSessionToReload":"打开会话后才能重新加载","i18n.notFound":"未找到","i18n.noPlugins":"未配置插件","trust.resourcesNotLoaded":"受限模式","trust.trustProject":"信任项目","trust.trusting":"正在信任...","trust.cancel":"取消","trust.dialogTitle":"信任此项目?","trust.dialogBody":"项目资源可以运行本地代码。请仅信任你了解其内容的项目。","trust.skillsNotLoaded":"此项目尚未受信任,项目技能未加载。","trust.pluginsNotLoaded":"此项目尚未受信任,项目插件未加载。","trust.projectScopeUnavailable":"项目资源未加载时,无法安装到项目范围。","i18n.creatingSession":"正在创建新会话…","i18n.creating":"创建中…","i18n.subscription":"订阅","i18n.subscriptions":"订阅服务","i18n.customEndpoint":"自定义端点格式","i18n.noChanges":"没有更改","i18n.branches":"分支","i18n.noActiveSession":"没有活动会话","i18n.noBranches":"此会话没有分支","i18n.source":"源代码","i18n.preview":"预览","i18n.diff":"Diff","i18n.downloadFile":"下载文件","i18n.liveSync":"实时同步已启用","i18n.notWatching":"未监视","i18n.fileViewMode":"文件视图模式","i18n.compareHead":"比较工作区与 HEAD","i18n.mentionSelectedLines":"提及所选行","i18n.disableWrap":"禁用自动换行","i18n.enableWrap":"启用自动换行","i18n.htmlPreview":"HTML 预览","i18n.previewFile":"预览 {file}","i18n.convertingDocument":"解析中…","i18n.invalidMermaid":"Mermaid 图表无效","i18n.renderingMermaid":"正在渲染 Mermaid 图表","i18n.previewAfterStreaming":"流式输出完成后可预览","i18n.showMermaidSource":"显示 Mermaid 源码","i18n.previewMermaid":"预览 Mermaid 图表","i18n.openMermaidViewer":"打开图表查看器","i18n.mermaidViewer":"Mermaid 图表查看器","i18n.mermaidDiagram":"Mermaid 图表","i18n.zoomOut":"缩小","i18n.zoomIn":"放大","i18n.fitToWidth":"适应宽度","models.discoveryFetching":"正在导入模型…","models.discoveryFetch":"导入模型…","models.discoveryFilterPlaceholder":"筛选 {count} 个模型…","models.discoveryFilter":"筛选上游模型","models.discoverySelectShown":"选择当前结果","models.discoveryNoMatches":"没有匹配的模型。","models.discoveryAdded":"已添加","models.discoveryShowing":"显示前 {shown} 个,共 {total} 个","models.discoveryFetched":"已获取 {count} 个模型","models.discoveryAddSelected":"添加所选模型","models.discoveryAddSelectedCount":"添加所选模型({count})","models.catalogSource":"来源:models.dev ↗","models.catalogFilling":"正在填入模型信息…","models.catalogFill":"填入模型信息","models.catalogFilled":"已填入 {count} 个字段","models.catalogNoEmptyFields":"没有需要填入的空字段","models.catalogNoExactMatch":"models.dev 中没有精确匹配","models.catalogPriceProvider":"价格已匹配 Provider {provider}","models.catalogPriceBaseUrl":"价格已按 Base URL 匹配 {provider}","models.catalogPriceConsensus":"价格得到 {support}/{total} 条记录支持","models.catalogPriceUnreliable":"未找到可靠价格","models.catalogUndo":"撤销","models.capabilities":"能力","models.reasoning":"推理 / 思考","models.imageInput":"图片输入","models.modelSpecs":"模型规格","models.contextWindow":"上下文窗口(tokens)","models.maxOutputTokens":"最大输出 tokens","models.costPerMillion":"每百万 tokens 价格","models.costInput":"输入","models.costOutput":"输出","models.costCacheRead":"缓存读取","models.costCacheWrite":"缓存写入","models.notProvided":"未提供","models.editCosts":"编辑价格","models.finishEditingCosts":"完成","models.costAllRequired":"请输入有效的非负价格;留空项将按 0 保存。","models.advancedSettings":"高级设置","models.providerDefaults":"沿用 Provider 默认设置","models.headersSummary":"Headers:{count}","models.compatSummary":"兼容性:{count}","models.thinkingSummary":"思考等级:{count}","models.apiOverride":"API 覆盖","models.headers":"Headers","models.headersHelp":"仅添加到该模型的请求中,并覆盖 Provider 的同名 Header。","models.compatibility":"兼容性","models.deepSeekThinkingCompat":"DeepSeek 思考兼容","models.developerRole":"使用 developer role 传递系统提示词","models.thinkingLevelMap":"思考等级映射","models.clearAll":"全部清除","i18n.testingModel":"正在测试模型连接...","i18n.connected":"已连接","i18n.failed":"失败","i18n.test":"测试","i18n.testConnection":"测试模型连接","i18n.provider":"Provider","i18n.model":"模型","i18n.providerName":"Provider 名称","i18n.rename":"重命名","i18n.default":"默认","i18n.disabled":"已禁用","i18n.noResources":"没有资源","i18n.unknown":"未知","i18n.installedVersion":"已安装 {version}","i18n.configuredVersion":"已配置 {version}","i18n.extensions":"扩展","i18n.prompts":"提示词","i18n.themes":"主题","i18n.resourceCount":"{count}{label}","i18n.extensionShort":"扩展","i18n.skillShort":"技能","i18n.promptShort":"提示词","i18n.themeShort":"主题","i18n.custom":"自定义","i18n.clearAll":"清除全部","i18n.connectedSuccessfully":"连接成功。","i18n.notConnected":"未连接","i18n.configured":"已配置","i18n.notConfigured":"未配置","i18n.openingBrowser":"正在打开浏览器…","i18n.submit":"提交","i18n.login":"登录","i18n.relogin":"重新登录","i18n.disconnect":"断开连接","i18n.networkError":"网络错误","i18n.continuing":"继续中…","i18n.skills":"技能","i18n.plugins":"插件","i18n.addSkill":"添加技能","i18n.addPlugin":"添加插件","i18n.selectSkill":"选择技能","i18n.selectPackage":"选择包","i18n.updateAvailable":"有可用更新","i18n.upToDate":"已是最新","i18n.automaticChecksUnavailable":"自动检查不可用","i18n.checkFailed":"检查失败","i18n.installed":"已安装","i18n.status":"状态","i18n.version":"版本","i18n.package":"包","i18n.resources":"资源","i18n.installedPath":"安装路径","i18n.cwd":"CWD","i18n.resolvedResources":"已解析资源","i18n.reloadSession":"重新加载会话","i18n.reloading":"重新加载中...","i18n.packageRemoved":"包已移除。","i18n.packageInstalled":"包已安装。","i18n.packageUpdated":"包已更新。","i18n.packageDisabled":"包已禁用。","i18n.packageEnabled":"包已启用。","i18n.sessionReloaded":"会话已重新加载。","i18n.thinking":"思考","i18n.largeMessageReveal":"消息内容过大({size})。点击以纯文本查看 — 已禁用 markdown 渲染以避免页面卡顿。","i18n.loadingThinking":"正在加载思考内容...","i18n.copyMessage":"复制消息","i18n.editFromHere":"从此处编辑","i18n.editFromHereTitle":"从此处编辑,此会话内创建分支","i18n.newSession":"新会话","i18n.newSessionTitle":"新会话,从此处创建独立副本","i18n.estimatedTokens":"流式输出期间的估算 Token 数","i18n.noOutput":"(无输出)","i18n.noSummary":"(无摘要)","i18n.conversationCompacted":"会话已压缩","i18n.compactionDescription":"此处之前的会话历史已压缩为以下摘要:","i18n.fileContext":"文件上下文:{details}","i18n.readFiles":"读取的文件","i18n.modifiedFiles":"修改的文件","i18n.hiddenExtensionMessage":"隐藏的扩展消息","i18n.noMessage":"(无消息)","i18n.showExtensionMessage":"显示扩展消息","i18n.collapse":"收起","i18n.expand":"展开","i18n.hideDetails":"隐藏详情","i18n.showDetails":"显示详情","i18n.thinkingUnavailable":"思考内容不可用","i18n.before":"之前","i18n.after":"之后","i18n.sessionComplete":"任务完成","i18n.taskFinished":"任务已完成。","i18n.attentionNeeded":"Pi 需要你的操作","i18n.extensionInputNeeded":"扩展正在等待你的输入。"}});let a="pi-locale",d=(0,i.createContext)(null);function c({children:e}){let[t,n]=(0,i.useState)("en"),[l,u]=(0,i.useState)(!1),p=(0,i.useMemo)(()=>s().map(e=>o.get(e)).filter(e=>!!e),[]),h=(0,i.useMemo)(()=>Object.fromEntries(s().flatMap(e=>{let t=o.get(e);return t?[[e,t.messages]]:[]})),[]);(0,i.useEffect)(()=>{let e=function(){try{let e=window.localStorage.getItem(a);if("en"===e||"zh-CN"===e)return e}catch{}for(let e of window.navigator.languages.length?window.navigator.languages:[window.navigator.language]){let t=e.toLowerCase();if("en"===t||t.startsWith("en-"))break;if("zh"===t||t.startsWith("zh-"))return"zh-CN"}return"en"}();n(e),document.documentElement.lang=e,u(!0)},[]);let g=(0,i.useCallback)(e=>{if(o.get(e)){n(e),document.documentElement.lang=e;try{window.localStorage.setItem(a,e)}catch{}}},[]),f=(0,i.useCallback)((e,n)=>(function(e,t,n,r={}){let i=n[e]?.[t]??n.en?.[t];return void 0===i?t:function(e,t={}){return e.replace(/\{([\w.-]+)\}/g,(e,n)=>{let r=t[n];return void 0===r?e:String(r)})}(i,r)})(t,e,h,n),[t,h]),x=(0,i.useMemo)(()=>({locale:l?t:"en",setLocale:g,t:f,supportedLocales:p}),[l,t,g,f,p]);return(0,r.jsx)(d.Provider,{value:x,children:e})}function u(){let e=(0,i.useContext)(d);if(!e)throw Error("useI18n must be used inside I18nProvider");return e}},73964:(e,t,n)=>{"use strict";n.d(t,{AppShell:()=>or});var r=n(95155),i=n(12115),o=n(73321);let l=null;var s=n(26619);let a="pi-web:file-explorer:open";function d(){try{return window.localStorage}catch{return null}}let c=/^<skill name="([^"\n]+)" location="([^"\n]+)">\nReferences are relative to [^\n]+\.\n\n([\s\S]*)\n<\/skill>(?:\n\n([\s\S]+))?$/;function u(e){let t=e.match(c);if(!t)return null;let[,n,,,r]=t;return r?`/skill:${n} ${r}`:`/skill:${n}`}let p="pi-web:last-open-by-workspace";function h(){try{return window.localStorage}catch{return null}}function g(e){let t=e.getItem(p);if(!t)return{};try{let e=JSON.parse(t);return null===e||"object"!=typeof e||Array.isArray(e)?{}:e}catch{return{}}}function f(e,t=h()){if(t)try{let n=g(t);if(!(e in n))return;delete n[e],0===Object.keys(n).length?t.removeItem(p):t.setItem(p,JSON.stringify(n))}catch{}}function x(e){return e.projectKey??e.projectRoot??e.cwd}function m(e,t){return e.filter(e=>x(e)===t)}var v=n(39247);let y="/icons/catppuccin";function b({name:e,size:t=14}){let n={width:t,height:t,"--catppuccin-icon-light":`url(${(0,s.hd)(`${y}/latte/${e}.svg`)})`,"--catppuccin-icon-dark":`url(${(0,s.hd)(`${y}/mocha/${e}.svg`)})`};return(0,r.jsx)("span",{"aria-hidden":"true",className:"catppuccin-file-icon",style:n})}function k({size:e=14,open:t=!1}){return(0,r.jsx)(b,{name:t?"_folder_open":"_folder",size:e})}function w({size:e=14}){return(0,r.jsx)(b,{name:"_file",size:e})}let j={ts:"typescript",tsx:"typescript-react",js:"javascript",mjs:"javascript",cjs:"javascript",jsx:"javascript-react",py:"python",json:"json",jsonl:"json",css:"css",less:"css",scss:"sass",html:"html",htm:"html",md:"markdown",mdx:"markdown",yaml:"yaml",yml:"yaml",toml:"toml",sh:"bash",bash:"bash",zsh:"bash",fish:"bash",rs:"rust",go:"go",sql:"database",graphql:"graphql",gql:"graphql",tf:"terraform",hcl:"terraform",docx:"ms-word",pdf:"pdf",lock:"lock"};function S(e,t=14){let n=e.toLowerCase(),i="dockerfile"===n||n.startsWith("dockerfile.")?"docker":".env"===n||n.startsWith(".env.")?"env":[".gitignore",".gitattributes",".gitmodules"].includes(n)?"git":"package-lock.json"===n?"npm-lock":"bun.lock"===n?"bun-lock":["next.config.js","next.config.mjs","next.config.cjs","next.config.ts"].includes(n)?"next":[".eslintrc",".eslintrc.js",".eslintrc.json",".eslintrc.yml","eslint.config.mjs","eslint.config.js"].includes(n)?"eslint":["yarn.lock","pnpm-lock.yaml","cargo.lock"].includes(n)?"lock":n.endsWith(".config.ts")||n.endsWith(".config.js")||n.endsWith(".config.mjs")||n.endsWith(".config.cjs")?"config":void 0;if(i)return(0,r.jsx)(b,{name:i,size:t});let o=j[n.split(".").pop()??""];return o?(0,r.jsx)(b,{name:o,size:t}):(0,r.jsx)(w,{size:t})}function C(e){return/^[a-zA-Z]:[\\/]/.test(e)||e.startsWith("\\\\")?e.replace(/\\/g,"/"):e}function T(e){return C(e).split("/").filter(Boolean).map(encodeURIComponent).join("/")}function R(e){let t=C(e).replace(/\/+$/,"");return t.split("/").pop()??t}function M(e){let t=C(e).replace(/\/+$/,""),n=t.lastIndexOf("/");return n<0?"":0===n?"/":2===n&&/^[a-zA-Z]:\//.test(t)?t.slice(0,3):t.slice(0,n)}function I(e,t){if(!t)return e;let n=C(e),r=C(t).replace(/\/$/,"");return n.startsWith(r+"/")?n.slice(r.length+1):e}function L(e,t){return`${C(e).replace(/\/$/,"")}/${t}`}let E="ly-ai-assistant";function W(e,t){let n=document.createElement("a");n.href=e,n.download=t,n.rel="noopener noreferrer",n.style.display="none",document.body.appendChild(n),n.click(),n.remove()}async function $(e,t){let n=(0,s.hd)(e);if(!function(){try{return window.parent!==window}catch{return!0}}())return void W(n,t);let r=await fetch(n);if(!r.ok)throw Error(`下载文件失败(HTTP ${r.status})`);let i=function(e){if(!e)return null;let t=/filename\*=UTF-8''([^;]+)/i.exec(e);if(t?.[1])try{return decodeURIComponent(t[1])}catch{return t[1]}let n=/filename="?([^"]+)"?/i.exec(e);return n?.[1]||null}(r.headers.get("content-disposition"))||t,o=r.headers.get("content-type")?.split(";",1)[0]?.trim()||"application/octet-stream",l=await r.arrayBuffer();if(!(await function(e,t=15e3){return new Promise(n=>{let r=!1,i=null,o=`${Date.now()}-${Math.random().toString(36).slice(2,8)}-download`,l=e=>{r||(r=!0,i&&clearTimeout(i),window.removeEventListener("message",s),n(e))},s=e=>{let t=e.data;t&&"object"==typeof t&&t.source===E&&"download_file_response"===t.type&&t.requestId===o&&l(t.ok?{ok:!0}:{ok:!1,error:"string"==typeof t.error?t.error:"未知错误"})};i=setTimeout(()=>l({ok:!1,error:"父页面未响应下载请求(超时)"}),t),window.addEventListener("message",s);try{window.parent.postMessage({source:E,type:"download_file_request",requestId:o,fileName:e.fileName,mimeType:e.mimeType,bytes:e.bytes},"*",[e.bytes])}catch(e){l({ok:!1,error:`向父页面发送下载内容失败: ${e instanceof Error?e.message:String(e)}`})}})}({fileName:i,mimeType:o,bytes:l})).ok){let e=new Blob([l],{type:o||"application/octet-stream"}),t=URL.createObjectURL(e);try{W(t,i)}finally{window.setTimeout(()=>URL.revokeObjectURL(t),1e3)}}}function z({title:e,message:t,confirmLabel:n,cancelLabel:o,destructive:l=!1,busy:s=!1,error:a=null,onConfirm:d,onCancel:c}){return(0,i.useEffect)(()=>{let e=e=>{"Escape"!==e.key||s||c()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[s,c]),(0,r.jsx)("div",{role:"presentation",style:{position:"fixed",inset:0,zIndex:1100,display:"flex",alignItems:"center",justifyContent:"center",padding:16,background:"rgba(0,0,0,0.4)"},onClick:e=>{s||e.target!==e.currentTarget||c()},children:(0,r.jsxs)("div",{role:"dialog","aria-modal":"true","aria-label":e,style:{width:400,maxWidth:"100%",border:"1px solid var(--border)",borderRadius:8,background:"var(--bg-panel)",boxShadow:"0 12px 36px rgba(0,0,0,0.24)",overflow:"hidden"},children:[(0,r.jsxs)("div",{style:{display:"flex",gap:12,padding:"18px 18px 14px"},children:[(0,r.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:l?"#ef4444":"#f59e0b",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{flexShrink:0,marginTop:1},children:[(0,r.jsx)("path",{d:"M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0Z"}),(0,r.jsx)("path",{d:"M12 9v4"}),(0,r.jsx)("path",{d:"M12 17h.01"})]}),(0,r.jsxs)("div",{style:{minWidth:0},children:[(0,r.jsx)("div",{style:{fontSize:15,fontWeight:700,color:"var(--text)"},children:e}),(0,r.jsx)("div",{style:{marginTop:7,fontSize:12,lineHeight:1.6,color:"var(--text-muted)",overflowWrap:"anywhere"},children:t}),a&&(0,r.jsx)("div",{role:"alert",style:{marginTop:10,color:"#ef4444",fontSize:12,lineHeight:1.5,overflowWrap:"anywhere"},children:a})]})]}),(0,r.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,padding:"10px 18px",borderTop:"1px solid var(--border)"},children:[(0,r.jsx)("button",{type:"button",onClick:c,disabled:s,style:{height:32,padding:"0 12px",border:"1px solid var(--border)",borderRadius:5,background:"transparent",color:"var(--text-muted)",cursor:s?"not-allowed":"pointer",fontSize:12},children:o}),(0,r.jsx)("button",{type:"button",onClick:d,disabled:s,style:{height:32,padding:"0 12px",border:l?"1px solid #ef4444":"1px solid var(--accent)",borderRadius:5,background:l?"#ef4444":"var(--accent)",color:"white",cursor:s?"wait":"pointer",opacity:s?.7:1,fontSize:12,fontWeight:600},children:n})]})]})})}async function P(e){let t=T(e),n=await fetch(`/api/files/${t}?type=list`);if(!n.ok){let e=`Failed to load files (HTTP ${n.status})`;try{let t=await n.json();t.error&&(e=t.error)}catch{}throw Error(e)}return((await n.json()).entries??[]).map(t=>({name:t.name,fullPath:L(e,t.name),isDir:t.isDir,size:t.size,children:t.isDir?[]:void 0,loaded:!t.isDir}))}async function N(e){let t=new URLSearchParams({cwd:e}),n=await fetch(`/api/git/status?${t.toString()}`);if(!n.ok)throw Error(`Failed to load Git status (HTTP ${n.status})`);return n.json()}let A={modified:"files.modified",added:"files.added",deleted:"files.deleted",renamed:"files.renamed",untracked:"files.untracked",conflict:"files.conflict"},F={modified:"#d6a84b",added:"#4ade80",deleted:"#f87171",renamed:"#60a5fa",untracked:"#4ade80",conflict:"#f87171"};function D({status:e,t}){return(0,r.jsx)("span",{title:t(A[e.status]),"aria-label":t(A[e.status]),style:{width:14,height:14,flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",color:F[e.status],fontFamily:"var(--font-mono)",fontSize:11,fontWeight:600},children:e.code})}function B({size:e=11}){return(0,r.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"4"}),(0,r.jsx)("path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8"})]})}function H({onClick:e,title:t}){return(0,r.jsx)("button",{type:"button",onClick:e,title:t,"aria-label":t,style:{width:24,height:24,padding:0,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,border:"none",borderRadius:4,background:"none",color:"var(--text-dim)",cursor:"pointer"},onMouseEnter:e=>{e.currentTarget.style.color="var(--text-muted)",e.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-dim)",e.currentTarget.style.background="none"},children:(0,r.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round","aria-hidden":"true",children:[(0,r.jsx)("path",{d:"m6 6 12 12"}),(0,r.jsx)("path",{d:"m18 6-12 12"})]})})}function O({node:e,depth:t,cwd:n,onOpenFile:o,onAtMention:l,expandedPaths:s,onToggleExpanded:a,refreshToken:d,highlightedPaths:c,gitStatusByPath:u,changedDirectoryPaths:p,deletingPaths:h,onDeleteNode:g,t:f}){let x=s.has(e.fullPath),m=c.has(e.fullPath),v=h.has(e.fullPath),y=C(e.fullPath),b=u.get(y),w=e.isDir&&(void 0!==b||p.has(y)),[j,M]=(0,i.useState)(e.children??[]),[L,E]=(0,i.useState)(e.loaded??!1),[W,z]=(0,i.useState)(!1),[N,A]=(0,i.useState)(!1),F=(0,i.useCallback)(async(t=!1)=>{if(!L||t){z(!0);try{let t=await P(e.fullPath);M(t),E(!0)}catch{}finally{z(!1)}}},[L,e.fullPath]);(0,i.useEffect)(()=>{x&&L&&F(!0)},[d]);let H=(0,i.useCallback)(()=>{if(e.isDir){let t=!x;a(e.fullPath,t),t&&!L&&F()}else o(e.fullPath,e.name)},[e.isDir,e.fullPath,e.name,L,x,F,o,a]);return(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{onClick:H,onMouseEnter:()=>A(!0),onMouseLeave:()=>A(!1),style:{position:"relative",display:"flex",alignItems:"center",gap:4,paddingLeft:8+14*t,paddingRight:8,height:24,cursor:"pointer",background:N?"var(--bg-hover)":"transparent",borderRadius:4,userSelect:"none"},children:[e.isDir&&(0,r.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"var(--text-dim)",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,transform:x?"rotate(90deg)":"none",transition:"transform 0.1s"},children:(0,r.jsx)("polyline",{points:"3 2 7 5 3 8"})}),!e.isDir&&(0,r.jsx)("span",{style:{width:10,flexShrink:0}}),(0,r.jsx)("span",{style:{flexShrink:0,display:"flex",alignItems:"center"},children:e.isDir?(0,r.jsx)(k,{size:14,open:x}):S(e.name,14)}),(0,r.jsx)("span",{style:{fontSize:12,color:"var(--text)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1},title:e.fullPath,children:e.name}),m&&(0,r.jsx)("span",{title:f("files.newlyUploaded"),"aria-label":f("files.newlyUploaded"),style:{width:14,height:14,flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center"},children:(0,r.jsx)("span",{style:{width:6,height:6,borderRadius:"50%",background:"#3b82f6"}})}),!N&&!e.isDir&&b&&(0,r.jsx)(D,{status:b,t:f}),!N&&w&&(0,r.jsx)("span",{title:f("files.containsChangedFiles"),"aria-label":f("files.containsChangedFiles"),style:{width:14,height:14,flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center"},children:(0,r.jsx)("span",{style:{width:6,height:6,borderRadius:"50%",background:"#d6a84b"}})}),W&&(0,r.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-dim)",strokeWidth:"2",strokeLinecap:"round",children:(0,r.jsx)("path",{d:"M12 2v4M12 18v4M4.93 4.93l2.83 2.83M16.24 16.24l2.83 2.83M2 12h4M18 12h4"})}),N&&(0,r.jsxs)("div",{style:{position:"absolute",right:4,top:"50%",transform:"translateY(-50%)",display:"flex",alignItems:"center",gap:4,flexShrink:0},children:[l&&(0,r.jsxs)("button",{type:"button",onClick:t=>{t.stopPropagation(),l(I(e.fullPath,n),e.isDir)},title:f("files.insertPath"),style:{display:"flex",alignItems:"center",justifyContent:"center",gap:4,padding:"0 8px",height:20,background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:4,color:"var(--accent)",cursor:"pointer",fontSize:11,fontWeight:600,whiteSpace:"nowrap"},children:[(0,r.jsx)(B,{}),f("files.mention")]}),!e.isDir&&(0,r.jsx)("button",{type:"button",onClick:async t=>{t.stopPropagation();try{await $(`/api/files/${T(e.fullPath)}?type=download`,R(e.fullPath))}catch(t){let e=t instanceof Error?t.message:String(t);window.alert(`下载文件失败: ${e}`)}},title:f("files.download"),style:{display:"flex",alignItems:"center",justifyContent:"center",gap:4,padding:"0 5px",height:20,background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:4,color:"var(--text-muted)",cursor:"pointer",fontSize:11,fontWeight:600,whiteSpace:"nowrap",textDecoration:"none",appearance:"none"},children:(0,r.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),(0,r.jsx)("polyline",{points:"7 10 12 15 17 10"}),(0,r.jsx)("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]})}),(0,r.jsx)("button",{type:"button",onClick:t=>{t.stopPropagation(),g(e)},disabled:v,title:f("files.delete"),"aria-label":f("files.delete"),style:{width:20,height:20,padding:0,display:"flex",alignItems:"center",justifyContent:"center",background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:4,color:"var(--text-muted)",cursor:v?"default":"pointer",flexShrink:0},onMouseEnter:e=>{v||(e.currentTarget.style.color="#f87171")},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-muted)"},children:v?(0,r.jsx)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.4",strokeLinecap:"round",style:{animation:"spin 0.8s linear infinite"},"aria-hidden":"true",children:(0,r.jsx)("path",{d:"M21 12a9 9 0 1 1-5.7-8.4"})}):(0,r.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,r.jsx)("polyline",{points:"3 6 5 6 21 6"}),(0,r.jsx)("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"}),(0,r.jsx)("path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]})})]})]}),e.isDir&&x&&(0,r.jsxs)("div",{children:[j.map(e=>(0,r.jsx)(O,{node:e,depth:t+1,cwd:n,onOpenFile:o,onAtMention:l,expandedPaths:s,onToggleExpanded:a,refreshToken:d,highlightedPaths:c,gitStatusByPath:u,changedDirectoryPaths:p,deletingPaths:h,onDeleteNode:g,t:f},e.fullPath)),0===j.length&&L&&(0,r.jsx)("div",{style:{paddingLeft:8+(t+1)*14,fontSize:11,color:"var(--text-dim)",height:22,display:"flex",alignItems:"center"},children:"empty"})]})]})}function U({status:e,cwd:t,onOpenFile:n,t:o}){let[l,s]=(0,i.useState)(!1),a=R(e.filePath),d=I(e.filePath,t);return(0,r.jsxs)("div",{onClick:()=>n(e.filePath,a,{modeHint:"diff"}),onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),title:e.filePath,style:{display:"flex",alignItems:"center",gap:6,paddingLeft:10,paddingRight:8,height:24,cursor:"pointer",background:l?"var(--bg-hover)":"transparent",borderRadius:4,userSelect:"none"},children:[(0,r.jsx)(D,{status:e,t:o}),(0,r.jsx)("span",{style:{flexShrink:0,display:"flex",alignItems:"center",opacity:.85},children:S(a,13)}),(0,r.jsx)("span",{style:{fontSize:12,color:"var(--text)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1},children:d})]})}let _=(0,i.forwardRef)(function({cwd:e,onOpenFile:t,refreshKey:n,onAtMention:o,onAtMentions:l,onUploadBusyChange:a,changesCollapsed:d,onChangesCountChange:c},u){let{t:p}=(0,v.s)(),[h,g]=(0,i.useState)([]),[f,x]=(0,i.useState)(!0),[m,y]=(0,i.useState)(null),[b,k]=(0,i.useState)(new Set),[w,j]=(0,i.useState)(0),[S,R]=(0,i.useState)(new Set),[E,W]=(0,i.useState)([]),[$,A]=(0,i.useState)({additions:0,deletions:0}),[D,_]=(0,i.useState)("idle"),[q,K]=(0,i.useState)(0),[V,J]=(0,i.useState)(null),[Y,G]=(0,i.useState)(null),[Z,X]=(0,i.useState)(null),[Q,ee]=(0,i.useState)(new Set),[et,en]=(0,i.useState)(null),[er,ei]=(0,i.useState)(!1),[eo,el]=(0,i.useState)(null),es=(0,i.useRef)(null),ea=(0,i.useRef)(null),ed=`${n??0}:${w}`,ec="idle"!==D,eu=(0,i.useMemo)(()=>new Map(E.map(e=>[C(e.filePath),e])),[E]),ep=(0,i.useMemo)(()=>{let t=new Set,n=C(e).replace(/\/$/,"");for(let e of E){let r=M(C(e.filePath));for(;(r===n||r.startsWith(`${n}/`))&&(t.add(r),r!==n);){let e=M(r);if(e===r)break;r=e}}return t},[e,E]),eh=(0,i.useCallback)((e,t)=>{k(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r})},[]),eg=(0,i.useCallback)(e=>{en(e),el(null)},[]),ef=(0,i.useCallback)(async e=>{ei(!0),el(null),ee(t=>new Set(t).add(e.fullPath));try{let t=await fetch(`/api/files/${T(e.fullPath)}`,{method:"DELETE"}),n=await t.json().catch(()=>({}));if(!t.ok)throw Error(n.error??`Delete failed (HTTP ${t.status})`);R(t=>{let n=new Set(t);return n.delete(e.fullPath),n}),en(null),j(e=>e+1)}catch(e){el(e instanceof Error?e.message:String(e))}finally{ei(!1),ee(t=>{let n=new Set(t);return n.delete(e.fullPath),n})}},[]),ex=(0,i.useCallback)(t=>{let n=t.uploaded??[];G({uploaded:n,skipped:t.skipped??[],errors:t.errors??[]}),n.length>0&&(R(new Set(n.map(t=>L(e,t)))),j(e=>e+1))},[e]),em=(0,i.useCallback)(async(t,n)=>{X(null),J(null),K(0),_("uploading");try{let{status:r,data:i}=await new Promise((r,i)=>{let o=new FormData;t.forEach(e=>o.append("files",e,e.name));let l=new XMLHttpRequest;l.open("POST",(0,s.DP)(`/api/files/${T(e)}?type=upload&conflict=${n}`)),l.upload.onprogress=e=>{e.lengthComputable&&e.total>0&&K(Math.round(e.loaded/e.total*100))},l.onerror=()=>i(Error("Network error while uploading files")),l.onabort=()=>i(Error("Upload cancelled")),l.onload=()=>{let e={};try{e=JSON.parse(l.responseText)}catch{l.responseText&&(e.error=l.responseText)}r({status:l.status,data:e})},l.send(o)});if(409===r&&i.conflicts?.length)return void X({files:t,conflicts:i.conflicts,nonReplaceable:i.nonReplaceable??[]});if(r<200||r>=300)throw Error(i.error??`Upload failed (HTTP ${r})`);K(100),ex(i)}catch(e){J(e instanceof Error?e.message:String(e))}finally{_("idle")}},[ex,e]),ev=(0,i.useCallback)(async t=>{if(0!==t.length&&!ec){G(null),R(new Set),X(null),J(null),K(0),_("checking");try{let n=await fetch(`/api/files/${T(e)}?type=upload-check`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({fileNames:t.map(e=>e.name)})}),r=await n.json().catch(()=>({}));if(!n.ok)throw Error(r.error??`Upload check failed (HTTP ${n.status})`);if(r.conflicts?.length)return void X({files:t,conflicts:r.conflicts,nonReplaceable:r.nonReplaceable??[]});await em(t,"error")}catch(e){J(e instanceof Error?e.message:String(e))}finally{_("idle")}}},[e,em,ec]),ey=(0,i.useCallback)(e=>{let t=Array.from(e.target.files??[]);e.target.value="",ev(t)},[ev]);(0,i.useImperativeHandle)(u,()=>({openUploadPicker(){ec||ea.current?.click()}}),[ec]),(0,i.useEffect)(()=>{a?.(ec)},[a,ec]),(0,i.useEffect)(()=>()=>a?.(!1),[a]),(0,i.useEffect)(()=>{let t=es.current!==e;es.current=e,t&&(k(new Set),R(new Set),G(null),X(null),J(null)),x(t),y(null);let n=!1;return P(e).then(e=>{n||g(e)}).catch(e=>{n||y(e instanceof Error?e.message:String(e))}).finally(()=>{n||x(!1)}),()=>{n=!0}},[e,n,w]),(0,i.useEffect)(()=>{let t=!1;return N(e).then(e=>{t||(W(e.isGitRepository?e.files:[]),A(e.isGitRepository?{additions:e.additions,deletions:e.deletions}:{additions:0,deletions:0}))}).catch(()=>{t||(W([]),A({additions:0,deletions:0}))}),()=>{t=!0}},[e,n,w]),(0,i.useEffect)(()=>{c?.(E.length)},[E,c]);let eb=ec||null!==Z||null!==V||null!==Y,ek=(0,i.useCallback)(()=>{Y&&0!==Y.uploaded.length&&l?.(Y.uploaded.map(t=>I(L(e,t),e)))},[e,l,Y]);return(0,r.jsxs)("div",{style:{minHeight:"100%"},children:[(0,r.jsx)("input",{ref:ea,type:"file",multiple:!0,hidden:!0,onChange:ey}),eb&&(0,r.jsxs)("div",{style:{padding:"6px 8px",borderBottom:"1px solid var(--border)"},children:[ec&&(0,r.jsxs)("div",{role:"status","aria-live":"polite","aria-label":"checking"===D?p("files.checking"):p("files.uploading",{progress:q}),children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,minHeight:14,color:"var(--text-muted)"},children:["checking"===D?(0,r.jsx)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",style:{animation:"spin 0.8s linear infinite"},"aria-hidden":"true",children:(0,r.jsx)("path",{d:"M21 12a9 9 0 1 1-5.7-8.4"})}):(0,r.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,r.jsx)("path",{d:"M12 16V4"}),(0,r.jsx)("path",{d:"m7 9 5-5 5 5"}),(0,r.jsx)("path",{d:"M5 20h14"})]}),"uploading"===D&&(0,r.jsxs)("span",{style:{fontSize:10},children:[q,"%"]})]}),"uploading"===D&&(0,r.jsx)("div",{style:{height:3,marginTop:4,overflow:"hidden",borderRadius:2,background:"var(--border)"},children:(0,r.jsx)("div",{style:{width:`${q}%`,height:"100%",background:"var(--text-muted)",transition:"width 120ms ease"}})})]}),Z&&(0,r.jsxs)("div",{role:"alert",style:{padding:7,border:"1px solid color-mix(in srgb, #f59e0b 55%, var(--border))",borderRadius:4,background:"color-mix(in srgb, #f59e0b 9%, var(--bg-panel))"},children:[(0,r.jsx)("div",{style:{fontSize:11,color:"var(--text)",lineHeight:1.35,overflowWrap:"anywhere"},children:p("files.conflictSummary",{count:Z.conflicts.length,countSuffix:1===Z.conflicts.length?"":"s",files:Z.conflicts.join(", ")})}),Z.nonReplaceable.length>0&&(0,r.jsx)("div",{style:{marginTop:3,fontSize:10,color:"#f59e0b",lineHeight:1.35,overflowWrap:"anywhere"},children:p("files.cannotReplace",{files:Z.nonReplaceable.join(", ")})}),(0,r.jsxs)("div",{style:{display:"flex",gap:5,marginTop:7},children:[(0,r.jsx)("button",{type:"button",onClick:()=>void em(Z.files,"overwrite"),style:{height:22,padding:"0 7px",border:"1px solid #ef4444",borderRadius:4,background:"transparent",color:"#ef4444",cursor:"pointer",fontSize:10},children:p("files.replace")}),(0,r.jsx)("button",{type:"button",onClick:()=>void em(Z.files,"skip"),style:{height:22,padding:"0 7px",border:"1px solid var(--border)",borderRadius:4,background:"var(--bg-panel)",color:"var(--text)",cursor:"pointer",fontSize:10},children:p("files.skipExisting")}),(0,r.jsx)("button",{type:"button",onClick:()=>X(null),style:{height:22,padding:"0 7px",border:"none",borderRadius:4,background:"transparent",color:"var(--text-muted)",cursor:"pointer",fontSize:10},children:p("files.cancel")})]})]}),V&&(0,r.jsxs)("div",{role:"alert",style:{display:"flex",alignItems:"flex-start",gap:6,fontSize:11,lineHeight:1.35,color:"#f87171"},children:[(0,r.jsx)("span",{style:{minWidth:0,flex:1,overflowWrap:"anywhere"},children:V}),(0,r.jsx)(H,{onClick:()=>J(null),title:p("files.dismissError")})]}),Y&&(0,r.jsxs)("div",{"aria-live":"polite",children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,minHeight:22,fontSize:11},children:[(0,r.jsxs)("div",{style:{minWidth:0,flex:1,display:"flex",alignItems:"center",gap:8},children:[Y.uploaded.length>0&&(0,r.jsxs)("span",{title:`${Y.uploaded.length} uploaded`,"aria-label":`${Y.uploaded.length} uploaded`,style:{display:"flex",alignItems:"center",gap:3,color:"#22c55e"},children:[(0,r.jsx)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:(0,r.jsx)("path",{d:"m5 12 4 4L19 6"})}),(0,r.jsx)("span",{children:Y.uploaded.length})]}),Y.skipped.length>0&&(0,r.jsxs)("span",{title:`${Y.skipped.length} skipped`,"aria-label":`${Y.skipped.length} skipped`,style:{display:"flex",alignItems:"center",gap:3,color:"var(--text-dim)"},children:[(0,r.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round","aria-hidden":"true",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,r.jsx)("path",{d:"M8 12h8"})]}),(0,r.jsx)("span",{children:Y.skipped.length})]}),Y.errors.length>0&&(0,r.jsxs)("span",{title:`${Y.errors.length} failed`,"aria-label":`${Y.errors.length} failed`,style:{display:"flex",alignItems:"center",gap:3,color:"#f87171"},children:[(0,r.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,r.jsx)("path",{d:"M12 3 2.5 20h19L12 3Z"}),(0,r.jsx)("path",{d:"M12 9v4"}),(0,r.jsx)("path",{d:"M12 17h.01"})]}),(0,r.jsx)("span",{children:Y.errors.length})]})]}),Y.uploaded.length>0&&l&&(0,r.jsxs)("button",{type:"button",onClick:ek,title:1===Y.uploaded.length?p("files.addUploadedFile"):p("files.addAllUploadedFiles"),"aria-label":1===Y.uploaded.length?p("files.addUploadedFile"):p("files.addAllUploadedFiles"),style:{height:22,padding:"0 7px",display:"flex",alignItems:"center",justifyContent:"center",gap:4,flexShrink:0,border:"1px solid var(--border)",borderRadius:4,background:"var(--bg-panel)",color:"var(--accent)",cursor:"pointer",fontSize:11,fontWeight:600,whiteSpace:"nowrap"},children:[(0,r.jsx)(B,{}),p("files.mention")]}),(0,r.jsx)(H,{onClick:()=>G(null),title:p("files.dismissUploadResults")})]}),Y.errors.map(e=>(0,r.jsxs)("div",{title:e.error,style:{display:"flex",alignItems:"center",gap:4,marginTop:3,minWidth:0,fontSize:10,color:"#f87171"},children:[(0,r.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},"aria-hidden":"true",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,r.jsx)("path",{d:"M12 8v5"}),(0,r.jsx)("path",{d:"M12 17h.01"})]}),(0,r.jsx)("span",{style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name})]},e.name))]})]}),!d&&E.length>0&&(0,r.jsxs)("div",{style:{padding:"0 4px 2px"},children:[(0,r.jsxs)("div",{"aria-label":p("files.changeStats",{count:E.length,additions:$.additions,deletions:$.deletions}),style:{display:"flex",alignItems:"center",gap:6,height:24,padding:"0 10px",fontSize:12},children:[(0,r.jsx)("span",{style:{color:"var(--text-dim)"},children:p("files.changedCount",{count:E.length})}),(0,r.jsxs)("span",{style:{color:F.added,fontFamily:"var(--font-mono)"},children:["+",$.additions]}),(0,r.jsxs)("span",{style:{color:F.deleted,fontFamily:"var(--font-mono)"},children:["-",$.deletions]})]}),E.map(n=>(0,r.jsx)(U,{status:n,cwd:e,onOpenFile:t,t:p},n.filePath))]}),(d||0===E.length)&&(0,r.jsxs)("div",{style:{padding:"2px 4px"},children:[f?(0,r.jsx)("div",{style:{padding:"8px 12px",fontSize:11,color:"var(--text-dim)"},children:"Loading files..."}):m?(0,r.jsx)("div",{style:{padding:"8px 12px",fontSize:11,color:"#f87171"},children:m}):h.map(n=>(0,r.jsx)(O,{node:n,depth:0,cwd:e,onOpenFile:t,onAtMention:o,expandedPaths:b,onToggleExpanded:eh,refreshToken:ed,highlightedPaths:S,gitStatusByPath:eu,changedDirectoryPaths:ep,deletingPaths:Q,onDeleteNode:eg,t:p},n.fullPath)),!f&&!m&&0===h.length&&(0,r.jsx)("div",{style:{padding:"8px 12px",fontSize:11,color:"var(--text-dim)"},children:p("files.noFiles")})]}),et&&(0,r.jsx)(z,{title:p("files.delete"),message:et.isDir?p("files.deleteDirConfirm",{name:I(et.fullPath,e)}):p("files.deleteConfirm",{name:I(et.fullPath,e)}),confirmLabel:p("files.deleteAction"),cancelLabel:p("files.cancel"),destructive:!0,busy:er,error:eo,onConfirm:()=>void ef(et),onCancel:()=>{er||(en(null),el(null))}})]})});function q({onClick:e,title:t,disabled:n,skipHover:i,color:o,background:l="none",marginRight:s,ariaPressed:a,children:d}){return(0,r.jsx)("button",{onClick:e,disabled:n,title:t,"aria-label":t,"aria-pressed":a,style:{position:"relative",display:"flex",alignItems:"center",justifyContent:"center",width:26,height:26,padding:0,marginRight:s,background:l,border:"none",color:o,cursor:n?"default":"pointer",borderRadius:5,flexShrink:0,opacity:n?.6:1,transition:"color 0.3s, background 0.3s"},onMouseEnter:e=>{n||i||(e.currentTarget.style.color="var(--text-muted)",e.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:e=>{n||i||(e.currentTarget.style.color=o,e.currentTarget.style.background=l)},children:d})}let K="pi-web:unread-session-ids";function V(e,t){return t&&e.startsWith(t)?"~"+e.slice(t.length):e}function J({text:e,style:t}){return(0,r.jsx)("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",display:"block",minWidth:0,lineHeight:1.35,direction:"rtl",textAlign:"left",...t},children:(0,r.jsx)("span",{style:{unicodeBidi:"plaintext"},children:e})})}function Y({open:e,children:t,style:n}){let[o,l]=(0,i.useState)(e),[s,a]=(0,i.useState)(e);return((0,i.useEffect)(()=>{let t,n;return e?(l(!0),a(!1),t=window.requestAnimationFrame(()=>{t=window.requestAnimationFrame(()=>a(!0))})):(a(!1),n=setTimeout(()=>l(!1),140)),()=>{void 0!==t&&window.cancelAnimationFrame(t),n&&clearTimeout(n)}},[e]),o)?(0,r.jsx)("div",{style:{...n,opacity:+!!s,transform:s?"translateY(0) scale(1)":"translateY(-8px) scale(0.96)",transformOrigin:"top center",transition:"opacity 140ms ease, transform 140ms ease",pointerEvents:e?"auto":"none"},children:t}):null}function G({selectedSessionId:e,onSelectSession:t,onNewSession:n,initialSessionId:o,skipInitialProjectSelection:l,fixedWorkspace:s=!1,fixedWorkspaceRoot:c,onInitialRestoreDone:u,refreshKey:p,onSessionDeleted:h,selectedCwd:g,onCwdChange:f,onOpenFile:y,explorerRefreshKey:b,onExplorerRefresh:k,onAtMention:w,onAtMentions:j,onBackgroundTaskDone:S,onRunningSessionIdsChange:C}){let{t:T}=(0,v.s)(),[R,M]=(0,i.useState)([]),[I,L]=(0,i.useState)(!0),[E,W]=(0,i.useState)(null),[$,z]=(0,i.useState)(null),[P,N]=(0,i.useState)(""),[A,F]=(0,i.useState)(""),[D,B]=(0,i.useState)(null),[H,O]=(0,i.useState)(!1),[U,X]=(0,i.useState)(!1),[Q,ee]=(0,i.useState)(""),[et,en]=(0,i.useState)(null),[er,ei]=(0,i.useState)(!1),[eo,el]=(0,i.useState)(null),[es,ea]=(0,i.useState)(null),ed=(0,i.useRef)(null),ec=(0,i.useRef)(null),[eu,ep]=(0,i.useState)(!0),[eh,eg]=(0,i.useState)(0),[ef,ex]=(0,i.useState)(!1),[em,ev]=(0,i.useState)(0),[ey,eb]=(0,i.useState)(!0),[ek,ew]=(0,i.useState)(!1),[ej,eS]=(0,i.useState)(!1),[eC,eT]=(0,i.useState)(()=>new Set),[eR,eM]=(0,i.useState)(()=>(function(){try{let e=window.localStorage.getItem(K);if(!e)return new Set;let t=JSON.parse(e);if(Array.isArray(t))return new Set(t.filter(e=>"string"==typeof e));return new Set}catch{return new Set}})()),eI=(0,i.useRef)(new Set),eL=(0,i.useRef)(!1),eE=(0,i.useRef)(null),eW=(0,i.useRef)(null),e$=(0,i.useRef)(null),ez=(0,i.useCallback)(async(e=!1,t=!1)=>{try{e&&L(!0);let n=await fetch(t?"/api/sessions?force=1":"/api/sessions",{cache:"no-store"});if(!n.ok)throw Error(`HTTP ${n.status}`);let r=await n.json();M(r.sessions),eL.current||eT(new Set(r.runningSessionIds??[]));let i=new Set(r.sessions.map(e=>e.id));eM(e=>{if(0===e.size)return e;let t=new Set([...e].filter(e=>i.has(e)));return t.size===e.size?e:t}),W(null),e||(ew(!0),eE.current&&clearTimeout(eE.current),eE.current=setTimeout(()=>ew(!1),2e3))}catch(e){W(String(e))}finally{e&&L(!1)}},[]),eP=(0,i.useRef)(!1);(0,i.useEffect)(()=>{let e=!eP.current;eP.current=!0,ez(e,!e)},[ez,p]),(0,i.useEffect)(()=>{ep(function(e=d()){if(!e)return!0;try{return"false"!==e.getItem(a)}catch{return!0}}())},[]),(0,i.useEffect)(()=>{try{0===eR.size?window.localStorage.removeItem(K):window.localStorage.setItem(K,JSON.stringify([...eR]))}catch{}},[eR]),(0,i.useEffect)(()=>{let e=!1,t=null,n=null,r=()=>{t&&clearTimeout(t),t=null},i=async()=>{if(e||"visible"!==document.visibilityState)return;let o=new AbortController;n?.abort(),n=o;try{let t=await fetch("/api/agent/running",{cache:"no-store",signal:o.signal});if(!t.ok)return;let r=await t.json();if(e||n!==o)return;eL.current=!0,eT(new Set(r.runningSessionIds??[]))}catch{}finally{n===o&&(n=null),r(),e||"visible"!==document.visibilityState||(t=setTimeout(()=>void i(),2500))}},o=()=>{"visible"===document.visibilityState?i():(r(),n?.abort(),n=null)};return i(),document.addEventListener("visibilitychange",o),()=>{e=!0,r(),n?.abort(),document.removeEventListener("visibilitychange",o)}},[]),(0,i.useEffect)(()=>{C?.(eC)},[C,eC]),(0,i.useEffect)(()=>{let t=eI.current,n=[...t].filter(t=>!eC.has(t)&&t!==e),r=[...eC].filter(e=>!t.has(e));(n.length>0||r.length>0)&&eM(e=>{let t=new Set(e);return eC.forEach(e=>t.delete(e)),n.forEach(e=>t.add(e)),t});let i=r.some(e=>!R.some(t=>t.id===e));(n.length>0||i)&&ez(!1,!0),n.length>0&&S?.(),eI.current=eC},[eC,e,R,ez,S]),(0,i.useEffect)(()=>{e&&eM(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n})},[e]),(0,i.useEffect)(()=>{void 0!==b&&eg(e=>e+1)},[b]),(0,i.useEffect)(()=>{fetch("/api/home").then(e=>e.json()).then(e=>{e.home&&N(e.home)}).catch(()=>{})},[]);let eN=(0,i.useRef)(!1),eA=(0,i.useCallback)((e,t)=>({root:e,key:t}),[]),eF=(0,i.useCallback)(e=>{if(!e)return null;if(D&&D.forCwd===e||D?.worktrees.some(t=>t.path===e))return eA(D.projectRoot,D.projectKey);let t=R.find(t=>t.cwd===e||(t.projectRoot??t.cwd)===e);return t?eA(t.projectRoot??t.cwd,x(t)):eA(e,e)},[D,R,eA]),eD=(0,i.useRef)(null);(0,i.useEffect)(()=>{let e=eF($),t=eD.current;(t?.cwd!==$||t.key!==(e?.key??null))&&(eD.current={cwd:$,key:e?.key??null},f?.($,e?.root??null,e?.key??null))},[$,f,eF]);let eB=(0,i.useRef)(null);(0,i.useEffect)(()=>{g&&g!==eB.current&&(eB.current=g,z(g))},[g]);let[eH,eO]=(0,i.useState)(0);(0,i.useLayoutEffect)(()=>{if(!$){B(null),ea(null);return}let e=!1;return ea($),fetch(`/api/worktrees?cwd=${encodeURIComponent($)}`).then(e=>e.json()).then(t=>{if(!e){if(ea(null),t.error||!t.projectRoot)return void B(null);B({forCwd:$,projectRoot:t.projectRoot,projectKey:t.projectKey??t.projectRoot,isGit:t.isGit??!1,isTopLevel:t.isTopLevel??!1,currentWorktreePath:t.currentWorktreePath??null,worktrees:t.worktrees??[]})}}).catch(()=>{e||(ea(null),B(null))}),()=>{e=!0}},[$,eH,p]),(0,i.useEffect)(()=>{if(0!==R.length&&!l){if(s){if(!c)return;if(o&&!eN.current){eN.current=!0;let e=eF(c);if(!e)return;let n=m(R,e.key).find(e=>e.id===o);if(n){z(n.cwd),t(n,!0);return}u?.()}return}if(null===$){if(o&&!eN.current){eN.current=!0;let e=R.find(e=>e.id===o);if(e){z(e.cwd),t(e,!0);return}u?.()}let e=function(e){let t=new Map;for(let n of e){let e=n.projectRoot??n.cwd;if(!e)continue;let r=x(n),i=t.get(r);(!i||n.modified>i.modified)&&t.set(r,{root:e,modified:n.modified})}return[...t.entries()].sort((e,t)=>t[1].modified.localeCompare(e[1].modified)).map(([e,{root:t}])=>({key:e,root:t}))}(R);e.length>0&&z(e[0].root)}}},[R,$,o,l,s,c,t,u,eF]);let eU=D?D.worktrees.find(e=>e.path===$)??(D.forCwd===$&&D.currentWorktreePath?D.worktrees.find(e=>e.path===D.currentWorktreePath):void 0)??D.worktrees.find(e=>e.isMain):void 0,e_=eU?.path??null,eq=(0,i.useCallback)(async()=>{let e=Q.trim();if(e&&!er&&D){ei(!0),en(null);try{let t=await fetch("/api/worktrees",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:D.projectRoot,branch:e})}),n=await t.json().catch(()=>({}));if(!t.ok||n.error||!n.path)return void en(n.error??`HTTP ${t.status}`);X(!1),ee(""),O(!1),B(t=>t?{...t,forCwd:n.path,currentWorktreePath:n.path,worktrees:[...t.worktrees,{path:n.path,branch:e,isMain:!1}]}:t),z(n.path),eO(e=>e+1)}catch(e){en(e instanceof Error?e.message:String(e))}finally{ei(!1)}}},[Q,er,D]),eK=(0,i.useCallback)(async(e,t)=>{if(D&&!er){ei(!0),en(null);try{let n=await fetch("/api/worktrees",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:D.projectRoot,path:e,force:t})}),r=await n.json().catch(()=>({}));if(!n.ok){if(r.dirty&&!t)return void el(e);en(r.error??`HTTP ${n.status}`);return}el(null),e_===e&&z(D.projectRoot),eO(e=>e+1)}catch(e){en(e instanceof Error?e.message:String(e))}finally{ei(!1)}}},[D,er,e_]);(0,i.useEffect)(()=>{let e=e=>{ed.current&&!ed.current.contains(e.target)&&(O(!1),X(!1),ee(""),en(null),el(null),F(""))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);let eV=(0,i.useCallback)(e=>{e.cwd&&z(e.cwd),t(e)},[t]),eJ=(0,i.useCallback)(()=>{if(!$)return;let e="function"==typeof crypto.randomUUID?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}-${Math.random().toString(36).slice(2)}`;n?.(e,$)},[$,n]),eY=eF($),eG=eY?m(R,eY.key):R,eZ=!!(D?.isGit&&D.isTopLevel&&$&&eY?.key===D.projectKey),eX=!s&&$&&D&&eY?.key===D.projectKey&&!eZ?D.isGit?{label:T("sidebar.openRepoRoot"),title:T("sidebar.openRepoRootTitle")}:{label:T("sidebar.gitRepoRootOnly"),title:T("sidebar.gitRepoRootOnlyTitle")}:null,eQ=!!($&&es===$),e0=s?null:eX??(eQ&&!eZ?{label:T("sidebar.worktrees"),title:T("sidebar.checkingWorktrees")}:null),e1=function(e){let t=new Map;for(let n of e)t.set(n.id,{session:n,children:[]});let n=new Map;for(let t of e)t.parentSessionId&&n.set(t.id,t.parentSessionId);let r=[];for(let e of t.values()){let i=function(e){let r=n.get(e),i=new Set;for(;r&&!i.has(r);){if(i.add(r),t.has(r))return r;r=n.get(r)}return null}(e.session.id);i?t.get(i).children.push(e):r.push(e)}let i=e=>{e.sort((e,t)=>t.session.modified.localeCompare(e.session.modified)),e.forEach(e=>i(e.children))};return i(r),r}(eG);return(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"},children:[(0,r.jsxs)("div",{style:{padding:"12px 10px 10px",borderBottom:"1px solid var(--border)",flexShrink:0},children:[(0,r.jsx)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:10},children:(0,r.jsxs)("div",{style:{display:"flex",gap:6},children:[(0,r.jsxs)("button",{onClick:eJ,disabled:!$,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:5,background:"var(--bg-hover)",border:"1px solid var(--border)",color:$?"var(--text-muted)":"var(--text-dim)",cursor:$?"pointer":"not-allowed",height:32,paddingLeft:10,paddingRight:12,borderRadius:7,fontSize:12,fontWeight:500,letterSpacing:"-0.01em",flexShrink:0,transition:"background 0.12s, color 0.12s, border-color 0.12s"},title:$?T("sidebar.newSessionTitle",{path:$}):T("sidebar.selectProject"),onMouseEnter:e=>{$&&(e.currentTarget.style.background="var(--bg-selected)",e.currentTarget.style.color="var(--accent)",e.currentTarget.style.borderColor="rgba(37,99,235,0.35)")},onMouseLeave:e=>{e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color=$?"var(--text-muted)":"var(--text-dim)",e.currentTarget.style.borderColor="var(--border)"},children:[(0,r.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",children:[(0,r.jsx)("line",{x1:"6",y1:"1",x2:"6",y2:"11"}),(0,r.jsx)("line",{x1:"1",y1:"6",x2:"11",y2:"6"})]}),T("sidebar.new")]}),(0,r.jsx)("button",{onClick:()=>ez(!1,!0),style:{display:"flex",alignItems:"center",justifyContent:"center",background:ek?"rgba(74,222,128,0.18)":"var(--bg-hover)",border:`1px solid ${ek?"rgba(74,222,128,0.4)":"var(--border)"}`,color:ek?"#4ade80":"var(--text-muted)",cursor:"pointer",width:32,height:32,borderRadius:7,padding:0,flexShrink:0,transition:"background 0.3s, color 0.3s, border-color 0.3s"},onMouseEnter:e=>{ek||(e.currentTarget.style.background="var(--bg-selected)",e.currentTarget.style.color="var(--accent)",e.currentTarget.style.borderColor="rgba(37,99,235,0.35)")},onMouseLeave:e=>{ek||(e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color="var(--text-muted)",e.currentTarget.style.borderColor="var(--border)")},title:T("sidebar.refresh"),children:ek?(0,r.jsx)("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"#4ade80",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:(0,r.jsx)("polyline",{points:"20 6 9 17 4 12"})}):(0,r.jsxs)("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}),(0,r.jsx)("path",{d:"M3 3v5h5"})]})})]})}),!s&&eZ&&(()=>{if(!D)return null;let e=D.worktrees.length>=8,t=e&&A.trim()?D.worktrees.filter(e=>(e.branch??V(e.path,P)).toLowerCase().includes(A.trim().toLowerCase())):D.worktrees;return(0,r.jsxs)("div",{ref:ed,style:{position:"relative",marginTop:6},children:[(0,r.jsxs)("button",{onClick:()=>O(e=>!e),title:eU?T("sidebar.switchWorktreeTitle",{path:eU.path}):T("sidebar.switchWorktree"),style:{width:"100%",height:29,boxSizing:"border-box",display:"flex",alignItems:"center",gap:6,padding:"0 10px",background:"var(--bg-hover)",border:"1px solid var(--border)",borderRadius:7,cursor:"pointer",fontSize:11,lineHeight:1.35,color:"var(--text-muted)",textAlign:"left"},children:[(0,r.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,color:eU&&!eU.isMain?"var(--accent)":"var(--text-dim)"},children:[(0,r.jsx)("line",{x1:"6",y1:"3",x2:"6",y2:"15"}),(0,r.jsx)("circle",{cx:"18",cy:"6",r:"3"}),(0,r.jsx)("circle",{cx:"6",cy:"18",r:"3"}),(0,r.jsx)("path",{d:"M18 9a9 9 0 0 1-9 9"})]}),(0,r.jsx)(J,{text:eU?eU.branch??V(eU.path,P):"…",style:{flex:1,fontFamily:"var(--font-mono)",color:"var(--text)"}}),eU?.isMain&&(0,r.jsx)("span",{style:{flexShrink:0,color:"var(--text-dim)",fontSize:10},children:T("sidebar.main")}),D.worktrees.length>1&&(0,r.jsx)("span",{style:{flexShrink:0,color:"var(--text-dim)",fontSize:10},children:D.worktrees.length}),(0,r.jsx)("svg",{width:"9",height:"9",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:(0,r.jsx)("polyline",{points:"2 3.5 5 6.5 8 3.5"})})]}),(0,r.jsxs)(Y,{open:H,style:{position:"absolute",top:"calc(100% + 4px)",left:0,right:0,zIndex:100,background:"var(--bg)",border:"1px solid var(--border)",borderRadius:8,boxShadow:"0 6px 20px rgba(0,0,0,0.10)",overflow:"hidden"},children:[e&&(0,r.jsx)("div",{style:{padding:"6px 8px",borderBottom:"1px solid var(--border)"},children:(0,r.jsx)("input",{value:A,onChange:e=>F(e.target.value),onKeyDown:e=>{"Escape"===e.key&&(F(""),O(!1))},placeholder:T("sidebar.filterWorktrees"),autoFocus:!0,style:{width:"100%",fontSize:11,fontFamily:"var(--font-mono)",padding:"5px 8px",border:"1px solid var(--border)",borderRadius:5,outline:"none",background:"var(--bg)",color:"var(--text)",boxSizing:"border-box"}})}),(0,r.jsxs)("div",{style:{maxHeight:"min(40vh, 300px)",overflowY:"auto"},children:[t.map(e=>{let t=e.path===e_;return eo===e.path?(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"7px 10px",borderBottom:"1px solid var(--border)",background:"rgba(239,68,68,0.06)"},children:[(0,r.jsx)("span",{style:{flex:1,fontSize:11,color:"var(--text)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:T("sidebar.forceRemoveCheckout")}),(0,r.jsx)("button",{onClick:()=>void eK(e.path,!0),disabled:er,style:{padding:"3px 9px",background:"#ef4444",border:"none",borderRadius:5,color:"#fff",fontSize:11,fontWeight:600,cursor:"pointer",flexShrink:0},children:T("sidebar.force")}),(0,r.jsx)("button",{onClick:()=>el(null),style:{padding:"3px 9px",background:"var(--bg-hover)",border:"1px solid var(--border)",borderRadius:5,color:"var(--text-muted)",fontSize:11,cursor:"pointer",flexShrink:0},children:T("sidebar.cancel")})]},e.path):(0,r.jsxs)("div",{className:"wt-row",style:{display:"flex",alignItems:"center",borderBottom:"1px solid var(--border)"},children:[(0,r.jsxs)("button",{onClick:()=>{z(e.path),O(!1),en(null),F("")},title:e.path,style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:7,padding:"8px 10px",background:"var(--bg)",border:"none",color:t?"var(--text)":"var(--text-muted)",cursor:"pointer",textAlign:"left",fontSize:11,fontFamily:"var(--font-mono)"},children:[t?(0,r.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"var(--accent)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:(0,r.jsx)("polyline",{points:"1.5 5 4 7.5 8.5 2.5"})}):(0,r.jsx)("span",{style:{width:10,flexShrink:0}}),(0,r.jsx)(J,{text:e.branch??V(e.path,P),style:{flex:1}}),e.isMain&&(0,r.jsx)("span",{style:{flexShrink:0,color:"var(--text-dim)",fontSize:10},children:T("sidebar.main")})]}),!e.isMain&&(0,r.jsx)("button",{onClick:()=>void eK(e.path,!1),disabled:er,title:T("sidebar.removeWorktreeTitle",{path:e.path}),style:{display:"flex",alignItems:"center",justifyContent:"center",width:34,height:28,padding:0,marginRight:4,background:"none",border:"none",color:"var(--text-dim)",cursor:"pointer",borderRadius:5,flexShrink:0,transition:"color 0.12s, background 0.12s"},onMouseEnter:e=>{e.currentTarget.style.color="#ef4444",e.currentTarget.style.background="rgba(239,68,68,0.08)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-dim)",e.currentTarget.style.background="none"},children:(0,r.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("polyline",{points:"3 6 5 6 21 6"}),(0,r.jsx)("path",{d:"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"}),(0,r.jsx)("path",{d:"M10 11v6M14 11v6"}),(0,r.jsx)("path",{d:"M9 6V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2"})]})})]},e.path)}),e&&0===t.length&&A.trim()&&(0,r.jsx)("div",{style:{padding:"8px 10px",fontSize:11,color:"var(--text-dim)"},children:T("sidebar.noMatchingWorktrees")})]}),U?(0,r.jsxs)("div",{style:{padding:"6px 8px"},children:[(0,r.jsx)("input",{ref:ec,value:Q,onChange:e=>{ee(e.target.value),en(null)},onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),eq()),"Escape"===e.key&&(X(!1),ee(""),en(null))},placeholder:T("sidebar.branchName"),style:{width:"100%",fontSize:11,fontFamily:"var(--font-mono)",padding:"5px 8px",border:"1px solid var(--accent)",borderRadius:5,outline:"none",background:"var(--bg)",color:"var(--text)",boxSizing:"border-box"}}),(0,r.jsxs)("div",{style:{display:"flex",gap:5,marginTop:5},children:[(0,r.jsx)("button",{onClick:()=>void eq(),disabled:er||!Q.trim(),style:{flex:1,padding:"4px 0",background:"var(--accent)",border:"none",borderRadius:5,color:"#fff",fontSize:11,fontWeight:600,cursor:er||!Q.trim()?"not-allowed":"pointer",opacity:er||!Q.trim()?.65:1},children:er?T("sidebar.creating"):T("sidebar.create")}),(0,r.jsx)("button",{onClick:()=>{X(!1),ee(""),en(null)},style:{flex:1,padding:"4px 0",background:"var(--bg-hover)",border:"1px solid var(--border)",borderRadius:5,color:"var(--text-muted)",fontSize:11,cursor:"pointer"},children:T("sidebar.cancel")})]})]}):(0,r.jsxs)("button",{onClick:e=>{e.stopPropagation(),X(!0),en(null),setTimeout(()=>ec.current?.focus(),0)},title:T("sidebar.createWorktreeTitle"),style:{display:"flex",alignItems:"center",gap:7,width:"100%",padding:"8px 10px",background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",textAlign:"left",fontSize:11},children:[(0,r.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.1",strokeLinecap:"round",style:{flexShrink:0},children:[(0,r.jsx)("line",{x1:"5",y1:"1",x2:"5",y2:"9"}),(0,r.jsx)("line",{x1:"1",y1:"5",x2:"9",y2:"5"})]}),(0,r.jsx)("span",{children:T("sidebar.newWorktree")})]}),et&&(0,r.jsx)("div",{style:{padding:"5px 10px 8px",color:"#dc2626",fontSize:11,lineHeight:1.35,overflowWrap:"anywhere"},children:et})]})]})})(),e0&&(0,r.jsxs)("button",{type:"button","aria-disabled":"true",tabIndex:-1,title:e0.title,style:{width:"100%",height:29,boxSizing:"border-box",marginTop:6,display:"flex",alignItems:"center",gap:6,padding:"0 10px",border:"1px solid var(--border)",borderRadius:7,background:"var(--bg-hover)",color:"var(--text-dim)",fontSize:11,lineHeight:1.35,whiteSpace:"nowrap",textAlign:"left",cursor:"default",opacity:.82},children:[(0,r.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[(0,r.jsx)("line",{x1:"6",y1:"3",x2:"6",y2:"15"}),(0,r.jsx)("circle",{cx:"18",cy:"6",r:"3"}),(0,r.jsx)("circle",{cx:"6",cy:"18",r:"3"}),(0,r.jsx)("path",{d:"M18 9a9 9 0 0 1-9 9"})]}),(0,r.jsx)("span",{style:{overflow:"hidden",textOverflow:"ellipsis"},children:e0.label})]})]}),(0,r.jsxs)("div",{style:{flex:eu&&(g||$)?"1 1 0":"1 1 auto",overflowY:"auto",padding:"0",minHeight:80},children:[I&&(0,r.jsx)("div",{style:{padding:"16px 14px",color:"var(--text-muted)",fontSize:12},children:T("sidebar.loading")}),E&&(0,r.jsx)("div",{style:{padding:"12px 14px",color:"#f87171",fontSize:12},children:E}),!I&&!E&&0===eG.length&&(0,r.jsx)("div",{style:{padding:"16px 14px",color:"var(--text-muted)",fontSize:12},children:T("sidebar.noSessions")}),e1.map(t=>(0,r.jsx)(Z,{node:t,selectedSessionId:e,runningSessionIds:eC,unreadSessionIds:eR,onSelectSession:eV,onRenamed:ez,onSessionDeleted:e=>{h?.(e),ez()},depth:0},t.session.id))]}),(g||$)&&(0,r.jsxs)("div",{style:{borderTop:"1px solid var(--border)",display:"flex",flexDirection:"column",flex:eu?"1 1 0":"0 0 auto",minHeight:0,overflow:"hidden"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",flexShrink:0},children:[(0,r.jsxs)("button",{onClick:()=>ep(e=>{let t=!e;return!function(e,t=d()){if(t)try{t.setItem(a,String(e))}catch{}}(t),t}),style:{display:"flex",alignItems:"center",gap:6,flex:1,padding:"6px 10px",background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",fontSize:11,fontWeight:600,letterSpacing:"0.05em",textTransform:"uppercase",textAlign:"left"},children:[(0,r.jsx)("svg",{width:"9",height:"9",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",style:{transform:eu?"rotate(90deg)":"none",transition:"transform 0.15s",flexShrink:0},children:(0,r.jsx)("polyline",{points:"3 2 7 5 3 8"})}),T("files.explorer")]}),eu&&em>0&&(0,r.jsx)(q,{onClick:()=>eb(e=>!e),title:T("sidebar.changedFiles",{count:em}),ariaPressed:!ey,color:ey?"var(--text-dim)":"var(--accent)",background:ey?"none":"var(--bg-selected)",children:(0,r.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"3"}),(0,r.jsx)("path",{d:"M3 12h6"}),(0,r.jsx)("path",{d:"M15 12h6"})]})}),eu&&(0,r.jsx)(q,{onClick:()=>e$.current?.openUploadPicker(),disabled:ef,title:T("sidebar.uploadFilesTitle"),color:"var(--text-dim)",children:(0,r.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,r.jsx)("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),(0,r.jsx)("path",{d:"m17 8-5-5-5 5"}),(0,r.jsx)("path",{d:"M12 3v12"})]})}),(0,r.jsx)(q,{onClick:()=>{k?k():eg(e=>e+1),eS(!0),eW.current&&clearTimeout(eW.current),eW.current=setTimeout(()=>eS(!1),2e3)},title:T("sidebar.refreshExplorer"),skipHover:ej,color:ej?"#4ade80":"var(--text-dim)",background:ej?"rgba(74,222,128,0.18)":"none",marginRight:6,children:ej?(0,r.jsx)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"#4ade80",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:(0,r.jsx)("polyline",{points:"20 6 9 17 4 12"})}):(0,r.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}),(0,r.jsx)("path",{d:"M3 3v5h5"})]})})]}),eu&&(0,r.jsx)("div",{style:{flex:1,overflowY:"auto",overflowX:"hidden"},children:(0,r.jsx)(_,{ref:e$,cwd:$??g,onOpenFile:y??(()=>{}),refreshKey:eh,onAtMention:w,onAtMentions:j,onUploadBusyChange:ex,changesCollapsed:ey,onChangesCountChange:ev})})]})]})}function Z({node:e,selectedSessionId:t,runningSessionIds:n,unreadSessionIds:o,onSelectSession:l,onRenamed:s,onSessionDeleted:a,depth:d}){let[c,u]=(0,i.useState)(!1),p=e.children.length>0;return(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{style:{position:"relative"},children:[d>0&&(0,r.jsx)("div",{style:{position:"absolute",left:12*d+6,top:0,bottom:0,width:1,background:"var(--border)",pointerEvents:"none"}}),(0,r.jsx)(ee,{session:e.session,isSelected:e.session.id===t,isRunning:n.has(e.session.id),isUnread:o.has(e.session.id),onClick:()=>l(e.session),onRenamed:s,onDeleted:e=>a?.(e),depth:d,hasChildren:p,collapsed:c,onToggleCollapse:()=>u(e=>!e)})]}),p&&!c&&(0,r.jsx)("div",{children:e.children.map(e=>(0,r.jsx)(Z,{node:e,selectedSessionId:t,runningSessionIds:n,unreadSessionIds:o,onSelectSession:l,onRenamed:s,onSessionDeleted:a,depth:d+1},e.session.id))})]})}function X(){let{t:e}=(0,v.s)();return(0,r.jsx)("span",{title:e("sidebar.agentRunning"),"aria-label":e("sidebar.agentRunning"),style:{width:14,height:14,display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,color:"var(--accent)"},children:(0,r.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",style:{display:"block"},children:(0,r.jsxs)("g",{children:[(0,r.jsx)("path",{d:"M21 12a9 9 0 1 1-3.8-7.4",stroke:"currentColor",strokeWidth:"2.8",strokeLinecap:"round"}),(0,r.jsx)("animateTransform",{attributeName:"transform",type:"rotate",from:"0 12 12",to:"360 12 12",dur:"0.9s",repeatCount:"indefinite"})]})})})}function Q(){let{t:e}=(0,v.s)();return(0,r.jsx)("span",{title:e("sidebar.newActivity"),"aria-label":e("sidebar.newSessionActivity"),style:{width:14,height:14,display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,color:"#0891b2"},children:(0,r.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",style:{display:"block"},children:[(0,r.jsx)("circle",{cx:"7",cy:"7",r:"2.5",fill:"currentColor"}),(0,r.jsxs)("circle",{cx:"7",cy:"7",r:"3",stroke:"currentColor",strokeWidth:"1.4",opacity:"0.32",children:[(0,r.jsx)("animate",{attributeName:"r",values:"3;6;3",dur:"1.6s",repeatCount:"indefinite"}),(0,r.jsx)("animate",{attributeName:"opacity",values:"0.32;0;0.32",dur:"1.6s",repeatCount:"indefinite"})]})]})})}function ee({session:e,isSelected:t,isRunning:n,isUnread:o,onClick:l,onRenamed:s,onDeleted:a,depth:d=0,hasChildren:c=!1,collapsed:p=!1,onToggleCollapse:h}){let g,f,x,m,y,{t:b}=(0,v.s)(),[k,w]=(0,i.useState)(!1),[j,S]=(0,i.useState)(!1),[C,T]=(0,i.useState)(""),[R,M]=(0,i.useState)(!1),[I,L]=(0,i.useState)(!1),E=(0,i.useRef)(null);(0,i.useEffect)(()=>{if(j){let e=requestAnimationFrame(()=>E.current?.select());return()=>cancelAnimationFrame(e)}},[j]);let W=u(e.firstMessage)??e.firstMessage,$=e.name||W.slice(0,50)||e.id.slice(0,12),z=(0,i.useCallback)(t=>{t.stopPropagation(),e.transient||(T(e.name||W.slice(0,50)||e.id.slice(0,12)),S(!0))},[e.name,e.transient,W,e.id]),P=(0,i.useCallback)(async()=>{let t=C.trim();if(S(!1),C!==$&&t!==(e.name??""))try{await fetch(`/api/sessions/${encodeURIComponent(e.id)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:t})}),s?.()}catch{}},[C,e.id,e.name,s,$]),N=(0,i.useCallback)(async()=>{if(!e.transient){M(!1),L(!0);try{await fetch(`/api/sessions/${encodeURIComponent(e.id)}`,{method:"DELETE"}),a?.(e.id)}catch{L(!1)}}},[e.id,e.transient,a]),A=(0,i.useCallback)(e=>{e.stopPropagation(),e.shiftKey?N():M(!0)},[N]),F=(0,i.useCallback)(e=>{e.stopPropagation(),N()},[N]),D=(0,i.useCallback)(e=>{e.stopPropagation(),M(!1)},[]),B=(0,i.useCallback)(t=>{(function(e,t=window){let n=new CustomEvent("pi-web:session-row-contextmenu",{cancelable:!0,detail:e});return!t.dispatchEvent(n)})({id:e.id,path:e.path,cwd:e.cwd,name:e.name,clientX:t.clientX,clientY:t.clientY,refresh:()=>{s?.()}})&&(t.preventDefault(),t.stopPropagation())},[s,e.cwd,e.id,e.name,e.path]);return(0,r.jsx)("div",{onClick:R||j?void 0:l,onContextMenu:R||j?void 0:B,onMouseEnter:()=>w(!0),onMouseLeave:()=>{w(!1)},style:{height:54,display:"flex",alignItems:"center",paddingLeft:d>0?12*d+14:14,paddingRight:8,cursor:R||j?"default":"pointer",background:R?"rgba(239,68,68,0.06)":t?"var(--bg-selected)":k?"var(--bg-hover)":"transparent",borderLeft:R?"2px solid #ef4444":t?"2px solid var(--accent)":"2px solid transparent",transition:"background 0.1s",opacity:I?.5:1,gap:6,overflow:"hidden"},children:R?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{style:{flex:1,minWidth:0,fontSize:12,color:"var(--text)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:b("sidebar.deleteSession",{title:$.slice(0,22)+($.length>22?"…":"")})}),(0,r.jsxs)("div",{style:{display:"flex",gap:5,flexShrink:0},children:[(0,r.jsxs)("button",{onClick:F,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:4,height:30,padding:"0 11px",background:"#ef4444",border:"none",borderRadius:6,color:"#fff",cursor:"pointer",fontSize:12,fontWeight:600,whiteSpace:"nowrap"},children:[(0,r.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("polyline",{points:"3 6 5 6 21 6"}),(0,r.jsx)("path",{d:"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"}),(0,r.jsx)("path",{d:"M10 11v6M14 11v6"}),(0,r.jsx)("path",{d:"M9 6V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2"})]}),b("sidebar.delete")]}),(0,r.jsx)("button",{onClick:D,style:{display:"flex",alignItems:"center",justifyContent:"center",height:30,padding:"0 11px",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:6,color:"var(--text-muted)",cursor:"pointer",fontSize:12,fontWeight:500,whiteSpace:"nowrap"},children:b("sidebar.cancel")})]})]}):j?(0,r.jsx)("input",{ref:E,value:C,onChange:e=>T(e.target.value),onBlur:P,onKeyDown:e=>{"Enter"===e.key&&P(),"Escape"===e.key&&S(!1)},autoFocus:!0,style:{flex:1,fontSize:12,padding:"5px 8px",border:"1px solid var(--accent)",borderRadius:5,outline:"none",background:"var(--bg)",color:"var(--text)",height:30}}):(0,r.jsxs)(r.Fragment,{children:[d>0&&(0,r.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-dim)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[(0,r.jsx)("line",{x1:"6",y1:"3",x2:"6",y2:"15"}),(0,r.jsx)("circle",{cx:"18",cy:"6",r:"3"}),(0,r.jsx)("circle",{cx:"6",cy:"18",r:"3"}),(0,r.jsx)("path",{d:"M18 9a9 9 0 0 1-9 9"})]}),(0,r.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,r.jsx)("div",{style:{display:"flex",alignItems:"center",gap:5,minWidth:0,fontSize:12,fontWeight:t?500:400,lineHeight:1.4,color:"var(--text)"},title:$,children:(0,r.jsx)("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0},children:$})}),(0,r.jsxs)("div",{style:{marginTop:2,display:"flex",alignItems:"center",gap:8,color:"var(--text-dim)",fontSize:11,minWidth:0},children:[n?(0,r.jsx)(X,{}):o?(0,r.jsx)(Q,{}):(0,r.jsx)("span",{title:e.modified,children:(g=new Date(e.modified),x=Math.floor((f=new Date().getTime()-g.getTime())/6e4),m=Math.floor(f/36e5),y=Math.floor(f/864e5),x<1?"just now":x<60?`${x}m ago`:m<24?`${m}h ago`:y<7?`${y}d ago`:g.toLocaleDateString())}),(0,r.jsx)("span",{children:b("sidebar.messagesCount",{count:e.messageCount})}),e.worktreeBranch&&(0,r.jsxs)("span",{title:`Worktree: ${e.cwd}`,style:{display:"flex",alignItems:"center",gap:3,color:"var(--accent)",minWidth:0,overflow:"hidden"},children:[(0,r.jsxs)("svg",{width:"9",height:"9",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.4",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[(0,r.jsx)("line",{x1:"6",y1:"3",x2:"6",y2:"15"}),(0,r.jsx)("circle",{cx:"18",cy:"6",r:"3"}),(0,r.jsx)("circle",{cx:"6",cy:"18",r:"3"}),(0,r.jsx)("path",{d:"M18 9a9 9 0 0 1-9 9"})]}),(0,r.jsx)("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.worktreeBranch})]})]})]}),c&&(0,r.jsx)("button",{onClick:e=>{e.stopPropagation(),h?.()},title:p?"Expand forks":"Collapse forks",style:{display:"flex",alignItems:"center",justifyContent:"center",width:20,height:20,padding:0,flexShrink:0,background:"none",border:"none",color:"var(--text-dim)",cursor:"pointer",transform:p?"rotate(-90deg)":"none",transition:"transform 0.15s"},children:(0,r.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:(0,r.jsx)("polyline",{points:"2 3.5 5 6.5 8 3.5"})})}),k&&!e.transient&&(0,r.jsxs)("div",{style:{display:"flex",gap:4,flexShrink:0},children:[(0,r.jsx)("button",{onClick:z,title:b("sidebar.rename"),style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,padding:0,background:"var(--bg-hover)",border:"1px solid var(--border)",borderRadius:7,color:"var(--text-muted)",cursor:"pointer",flexShrink:0,transition:"background 0.12s, color 0.12s, border-color 0.12s"},onMouseEnter:e=>{e.currentTarget.style.background="var(--bg-selected)",e.currentTarget.style.color="var(--accent)",e.currentTarget.style.borderColor="rgba(37,99,235,0.35)"},onMouseLeave:e=>{e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color="var(--text-muted)",e.currentTarget.style.borderColor="var(--border)"},children:(0,r.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,r.jsx)("path",{d:"M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"})})}),(0,r.jsx)("button",{onClick:A,title:b("sidebar.deleteWithShiftClick"),style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,padding:0,background:"var(--bg-hover)",border:"1px solid var(--border)",borderRadius:7,color:"var(--text-muted)",cursor:"pointer",flexShrink:0,transition:"background 0.12s, color 0.12s, border-color 0.12s"},onMouseEnter:e=>{e.currentTarget.style.background="rgba(239,68,68,0.08)",e.currentTarget.style.color="#ef4444",e.currentTarget.style.borderColor="rgba(239,68,68,0.35)"},onMouseLeave:e=>{e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color="var(--text-muted)",e.currentTarget.style.borderColor="var(--border)"},children:(0,r.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("polyline",{points:"3 6 5 6 21 6"}),(0,r.jsx)("path",{d:"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"}),(0,r.jsx)("path",{d:"M10 11v6M14 11v6"}),(0,r.jsx)("path",{d:"M9 6V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2"})]})})]})]})})}let et=/\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~]|\][^\x07]*(?:\x07|\x1B\\))/g,en=/^\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~]|\][^\x07]*(?:\x07|\x1B\\))/,er=/\x1B\[([0-9;]*)m/g,ei=/\x1B_pi:c\x07/g,eo=["#1f2937","#dc2626","#16a34a","#d97706","#2563eb","#9333ea","#0891b2","#6b7280"],el=["#9ca3af","#ef4444","#22c55e","#f59e0b","#3b82f6","#a855f7","#06b6d4","#e5e7eb"];function es(e){return e.replace(ei,"").replace(et,"")}function ea(e){let t=[],n=0;for(;n<e.length;){if(27===e.charCodeAt(n)){let t=e.slice(n).match(en);if(t){n+=t[0].length;continue}}let r=e.codePointAt(n);if(void 0===r)break;let i=String.fromCodePoint(r);t.push({start:n,end:n+i.length,char:i}),n+=i.length}return t}function ed(e,t){let n=ea(e)[t];return n?e.slice(0,n.start)+e.slice(n.end):e}function ec(e){return ea(e)[0]?.char}function eu(e){let t,n=[],r={},i=0;for(er.lastIndex=0;null!==(t=er.exec(e));)t.index>i&&n.push({text:e.slice(i,t.index),style:r}),r=function(e,t){let n={...e};for(let e=0;e<t.length;e++){let r=t[e];if(0===r)for(let e of Object.keys(n))delete n[e];else if(1===r)n.fontWeight=700;else if(2===r)n.opacity=.65;else if(3===r)n.fontStyle="italic";else if(4===r)n.textDecoration="underline";else if(22===r)delete n.fontWeight,delete n.opacity;else if(23===r)delete n.fontStyle;else if(24===r)delete n.textDecoration;else if(39===r)delete n.color;else if(49===r)delete n.backgroundColor;else if(r>=30&&r<=37)n.color=eo[r-30];else if(r>=90&&r<=97)n.color=el[r-90];else if(r>=40&&r<=47)n.backgroundColor=eo[r-40];else if(r>=100&&r<=107)n.backgroundColor=el[r-100];else if((38===r||48===r)&&2===t[e+1]){let[i,o,l]=[t[e+2],t[e+3],t[e+4]];[i,o,l].every(e=>"number"==typeof e&&Number.isFinite(e))&&(38===r?n.color=`rgb(${i}, ${o}, ${l})`:n.backgroundColor=`rgb(${i}, ${o}, ${l})`),e+=4}else if((38===r||48===r)&&5===t[e+1]){let i=function(e){if(e>=0&&e<8)return eo[e];if(e>=8&&e<16)return el[e-8];if(e>=16&&e<=231){let t=e-16,n=Math.floor(t/36),r=Math.floor(t%36/6),i=e=>0===e?0:55+40*e;return`rgb(${i(n)}, ${i(r)}, ${i(t%6)})`}if(e>=232&&e<=255){let t=8+(e-232)*10;return`rgb(${t}, ${t}, ${t})`}}(t[e+2]);i&&(38===r?n.color=i:n.backgroundColor=i),e+=2}}return n}(r,t[1]?t[1].split(";").map(e=>Number(e||"0")):[0]),i=t.index+t[0].length;return i<e.length&&n.push({text:e.slice(i),style:r}),n}let ep={ArrowUp:"\x1b[A",ArrowDown:"\x1b[B",ArrowRight:"\x1b[C",ArrowLeft:"\x1b[D",Home:"\x1b[H",End:"\x1b[F",Insert:"\x1b[2~",Delete:"\x1b[3~",PageUp:"\x1b[5~",PageDown:"\x1b[6~",Escape:"\x1b",Backspace:""},eh={ArrowLeft:"\x1bb",ArrowRight:"\x1bf",ArrowUp:"\x1bp",ArrowDown:"\x1bn"};function eg(e,t={}){return"thinking"===e.type&&!e.deferred&&!t.isStreaming&&""===e.thinking.trim()}function ef(e,t={}){return(e.content??[]).filter(e=>!eg(e,t))}function ex(e,t={}){return t.isStreaming||"error"!==e.stopReason?null:e.errorMessage?.trim()||"Unknown provider error"}function em(e,t={}){let n=ef(e,t),r=n.findLastIndex(e=>"text"!==e.type&&"image"!==e.type);return -1===r?{answerBlocks:n,processBlocks:[]}:{answerBlocks:n.slice(r+1),processBlocks:n.slice(0,r+1)}}function ev(e){return e.filter(e=>"toolCall"===e.type).length}function ey(e){try{return decodeURIComponent(e)}catch{return e}}function eb(e){return/^[a-zA-Z]:[\\/]/.test(e)||e.startsWith("\\\\")?e.replace(/\\/g,"/"):e}function ek(e){let t=eb(e),n=/^[a-zA-Z]:\//.test(t),r=t.startsWith("//"),i=t.startsWith("/")&&!n&&!r,o=[];for(let e of t.split("/"))if(e&&"."!==e){if(".."===e){o.length>0&&".."!==o[o.length-1]?o.pop():i||n||r||o.push(e);continue}o.push(e)}let l=o.join("/");return n?l:r?`//${l}`:i?`/${l}`:l}function ew(e,t,n=t){let r,i,o,l,s;if(!e)return null;let a=e.split("#",1)[0].split("?",1)[0].trim();if(!a)return null;let d=null,c=null,u=ey(a),p=u.startsWith("\\\\"),h=eb(u),g=h.toLowerCase();if(g.startsWith("/api/")||g.startsWith("/_next/")||!p&&h.startsWith("//")||/^[a-zA-Z][a-zA-Z0-9+.-]*:/i.test(h)&&!g.startsWith("file:")&&!/^[a-zA-Z]:\//.test(h))return null;if(g.startsWith("file:")?c=(d=function(e){try{let t=new URL(e);if("file:"!==t.protocol)return null;let n=ey(t.pathname);if(t.hostname)return`//${t.hostname}${n.startsWith("/")?n:`/${n}`}`;if(/^\/[a-zA-Z]:\//.test(n))return n.slice(1);return n}catch{return null}}(h))?"absolute":null:/^[a-zA-Z]:\//.test(h)||h.startsWith("/")?(d=h,c="absolute"):t&&!(h.startsWith("#")||h.startsWith("?"))&&(h.startsWith("./")||h.startsWith("../")||h.includes("/")||/(^|\/)\.?[^/]+\.[^/.]+$/.test(h))&&(d=`${eb(t).replace(/\/+$/,"")}/${h}`,c="relative"),!d)return null;let f=ek(d).replace(/:\d+(?::\d+)?$/,"");return"relative"===c&&n&&(r=ek(f).replace(/\/+$/,""),i=ek(n).replace(/\/+$/,""),l=(o=/^[a-zA-Z]:\//.test(r)||/^[a-zA-Z]:\//.test(i))?r.toLowerCase():r,!(l===(s=o?i.toLowerCase():i)||l.startsWith(`${s}/`)))?null:f}function ej(e){let t=e.toLowerCase();return"edit"===t||t.startsWith("edit_")||t.endsWith(".edit")||t.endsWith("_edit")||t.includes("str_replace")||t.includes("replace_editor")}var eS=n(32316),eC=n(88374),eT=n(5924),eR=n(94764),eM=n(63835),eI=n(54152),eL=n(84678),eE=n(98164);let eW={...eR.j,attributes:{...eR.j.attributes,code:[["className",/^language-./,"math-inline","math-display"]]},strip:[...eR.j.strip||[],"iframe","object","style","form"]};function e$(e){let t=e.includes("\r\n")?"\r\n":"\n",n=e.split(/\r?\n/),r=[],i=null,o=0,l=null,s=new Map;for(let e=0;e<n.length;e++){var a;let t=n[e];if(l){r.push(t),RegExp(`</${l}\\s*>`,"i").test(t)&&(l=null);continue}let d=t.match(/^ {0,3}(`{3,}|~{3,})/);if(d){let e=d[1][0],n=d[1].length;i?e===i.marker&&n>=i.size&&(i=null):i={marker:e,size:n},o=0,r.push(t);continue}if(i){r.push(t);continue}let c=t.match(/<(code|pre|script|style)\b/i);if(c){let e=c[1].toLowerCase(),n=t.slice((c.index??0)+c[0].length);RegExp(`</${e}\\s*>`,"i").test(n)||(l=e),o=0,r.push(t);continue}if(/^(?: {4}|\t)/.test(t)||""===t.trim()){o=0,r.push(t);continue}if(o||t.includes("`")){o=function(e,t){let n=t;for(let t=0;t<e.length;){if("`"!==e[t]){t++;continue}let r=t+1;for(;"`"===e[r];)r++;let i=r-t;0===n?n=i:i===n&&(n=0),t=r}return n}(t,o),r.push(t);continue}let u=t.match(/^([ ]{0,3})\\\[[ \t]*(.+?)[ \t]*\\\][ \t]*$/);if(u){let e=u[2].trim();if(e){r.push(`${u[1]}$$`,`${u[1]}${e}`,`${u[1]}$$`);continue}}let p=t.match(/^([ ]{0,3})\\\[[ \t]*$/);if(p){let t=function(e,t){for(let n=t;n<e.length;n++){let t=e[n];if(/^ {0,3}\\\][ \t]*$/.test(t))return n;if(/^ {0,3}(`{3,}|~{3,})/.test(t)||/^ {0,3}\\\[[ \t]*$/.test(t)||/<(code|pre|script|style)\b/i.test(t))break}return -1}(n,e+1);if(-1!==t){r.push(`${p[1]}$$`,...n.slice(e+1,t).map(e=>eP(e,p[1])),`${p[1]}$$`),e=t;continue}}let h=t.match(/^([ \t]{0,3})\$\$(.+)\$\$[ \t]*$/);if(h){let e=h[2].trim();if(e){r.push(`${h[1]}$$`,`${h[1]}${e}`,`${h[1]}$$`);continue}}let g=t.match(/^([ \t]{0,3})\$\$(.+)$/);if(g){let t=g[1],i=g[2].trimEnd();if(i&&!i.includes("$$")){let o=ez(n,e+1,t,s);if(o){r.push(`${t}$$`,`${t}${i}`);for(let i=e+1;i<o.index;i++)r.push(eP(n[i],t));o.content&&r.push(`${t}${o.content}`),r.push(`${t}$$`),e=o.index;continue}}}let f=t.match(/^([ \t]{0,3})\$\$\s*$/);if(f){let t=f[1],i=ez(n,e+1,t,s);if(i&&(i.glued||""!==t)){r.push(`${t}$$`);for(let o=e+1;o<i.index;o++)r.push(eP(n[o],t));i.content&&r.push(`${t}${i.content}`),r.push(`${t}$$`),e=i.index;continue}}r.push((a=t,/^\s{0,3}\[[^\]]+\]:/.test(a)||/]\s*\(/.test(a)||/<(?:!--|\/?[A-Za-z][^>]*>)/.test(a)||/\b(?:https?|file|mailto):/i.test(a)||/\b[A-Za-z]:\\/.test(a)?a:a.replace(/(?<!\\)\\\(([^`\r\n$]+?)(?<!\\)\\\)/g,(e,t)=>t.trim()?`$${t}$`:e)))}return r.join(t)}function ez(e,t,n,r){let i=r.get(n);if(void 0!==i&&t<i)return null;for(let i=t;i<e.length;i++){var o,l,s,a;let t=e[i];if(o=t,""===(l=n)?/^ {0,3}\$\$\s*$/.test(o):o.startsWith(l)&&/^\$\$\s*$/.test(o.slice(l.length)))return{index:i,content:"",glued:!1};if(s=t,/^ {0,3}(`{3,}|~{3,})/.test(s)||/^[ \t]*(?:[-+*]|\d{1,9}[.)])(?:[ \t]+|$)/.test(s)||/^ {0,3}#{1,6}(?:[ \t]+|$)/.test(s)||/^ {0,3}>/.test(s)||/<(code|pre|script|style)\b/i.test(s)||(a=t,/^ {0,3}\$\$(?:\S|[ \t]+\S)/.test(a)))return r.set(n,i),null;let d=function(e,t){if(!e.startsWith(t))return null;let n=e.slice(t.length).match(/^(.+?)\$\$\s*$/);if(!n)return null;let r=n[1].trimEnd();return r&&!r.includes("$$")?r:null}(t,n);if(null!==d)return{index:i,content:d,glued:!0}}return r.set(n,e.length),null}function eP(e,t){if(!t||!e||e.startsWith(" "))return e;let n=e.match(/^ */)?.[0].length??0;return n>=t.length?e:`${t.slice(n)}${e}`}let eN={singleTilde:!1},eA=[[eI.A,["yaml"]],[eL.A,eN],eE.A],eF=[[eI.A,["yaml"]],[eL.A,eN],eE.A],eD=[eT.A,[eM.A,eW],[eC.A,{throwOnError:!1,strict:!1}]],eB=[eT.A,[eM.A,eW],[eC.A,{throwOnError:!1,strict:!1}]];var eH=n(65063),eO=n(7644);let eU="pi-theme",e_=["light","dark","auto"],eq={preference:"auto",theme:"light"},eK=new Set,eV=null,eJ=!1;function eY(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function eG(e){return"auto"===e?eY():e}function eZ(e){"u">typeof document&&document.documentElement.classList.toggle("dark","dark"===e)}function eX(){if(eV)return eV;let e=function(){try{let e=localStorage.getItem(eU);if("light"===e||"dark"===e||"auto"===e)return e}catch{}return"auto"}(),t=eG(e);return eZ(t),eV={preference:e,theme:t}}function eQ(e,t,n){if(eZ(t),n)try{localStorage.setItem(eU,e)}catch{}eV={preference:e,theme:t},eK.forEach(e=>e())}function e0(){let e=eX();if("auto"!==e.preference)return;let t=eY();t!==e.theme&&eQ("auto",t,!1)}function e1(e){return eK.add(e),eX(),eJ||!window.matchMedia||(window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",e0),window.addEventListener("focus",e0),document.addEventListener("visibilitychange",()=>{"visible"===document.visibilityState&&e0()}),eJ=!0),e0(),()=>{eK.delete(e)}}function e2(){return eX()}function e8(){return eq}function e4(){let e=(0,i.useSyncExternalStore)(e1,e2,e8),t=(0,i.useCallback)(e=>{var t;let n,r=(t=eX().preference,n=e_.indexOf(t),e_[(n+1)%e_.length]),i=eG(r),o=()=>{eQ(r,i,!0)},l=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;if("function"!=typeof document.startViewTransition||l)return void o();let s=e?.x??window.innerWidth/2,a=e?.y??window.innerHeight/2,d=Math.hypot(Math.max(s,window.innerWidth-s),Math.max(a,window.innerHeight-a));document.startViewTransition(o).ready.then(()=>{document.documentElement.animate({clipPath:[`circle(0px at ${s}px ${a}px)`,`circle(${d}px at ${s}px ${a}px)`]},{duration:450,easing:"cubic-bezier(0.22, 0.61, 0.36, 1)",pseudoElement:"::view-transition-new(root)"})}).catch(()=>{})},[]);return{theme:e.theme,preference:e.preference,toggleTheme:t,isDark:"dark"===e.theme}}function e6(e){if(navigator.clipboard?.writeText)return navigator.clipboard.writeText(e);try{let t=document.createElement("textarea");return t.value=e,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t),Promise.resolve()}catch{return Promise.reject()}}function e5({code:e,isStreaming:t,defaultPreview:o=!1}){let{isDark:l}=e4(),{t:s}=(0,v.s)(),[a,d]=(0,i.useState)(o),[c,u]=(0,i.useState)(null),[p,h]=(0,i.useState)(!1),g=`${l?"dark":"light"}
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8974],{14755:(e,t,n)=>{"use strict";n.d(t,{getPresetFromTools:()=>c,sn:()=>d,xG:()=>u});let r=["none","read-only","default","full"],i=[],o=["read","grep","find","ls"],l=["read","bash","edit","write"],s=["bash","read","edit","write","grep","find","ls"],a=new Set(s);function d(e){return"string"==typeof e&&r.includes(e)}function c(e){let t=e.filter(e=>e.active);if(0===t.length)return"none";let n=t.map(e=>e.name).filter(e=>a.has(e)).sort().join(",");return n===[...o].sort().join(",")?"read-only":n===[...l].sort().join(",")?"default":n===[...s].sort().join(",")?"full":"default"}function u(e){return"none"===e?[...i]:"read-only"===e?[...o]:"full"===e?[...s]:[...l]}},26619:(e,t,n)=>{"use strict";n.d(t,{DP:()=>d,eH:()=>c,hd:()=>i,o2:()=>r});let r="/pi-web";function i(e){return!r||!e.startsWith("/")||e.startsWith(r)||e.startsWith("/_next/")||"/sw.js"===e||e.startsWith("/sw.js?")?e:`${r}${e}`}function o(e){return e.startsWith("/")&&!e.startsWith("/_next/")&&!e.startsWith(r)}let l=!1,s=new URLSearchParams(window.location.search).get("cookie_sessionid");function a(e){if(!s||!e.startsWith("/api/"))return e;let t=e.indexOf("?"),n=-1===t?e:e.slice(0,t),r=new URLSearchParams(-1===t?"":e.slice(t+1));return r.set("cookie_sessionid",s),`${n}?${r.toString()}`}function d(e){return i(a(e))}function c(){if(l||!r)return;l=!0;let e=window.fetch.bind(window);window.fetch=(t,n)=>("string"==typeof t?t=d(t):t instanceof URL&&t.origin===window.location.origin&&o(t.pathname)&&(t=new URL(`${r}${t.pathname}${t.search}`,t.origin)),e(t,n));let t=window.EventSource;if(t){class e extends t{constructor(e,t){if("string"==typeof e){const n=a(e);super(o(n)?`${r}${n}`:n,t)}else super(e,t)}}window.EventSource=e}}},36149:(e,t,n)=>{Promise.resolve().then(n.bind(n,73964)),Promise.resolve().then(n.bind(n,39247))},39247:(e,t,n)=>{"use strict";n.d(t,{I18nProvider:()=>c,s:()=>u});var r=n(95155),i=n(12115);let o=new Map;function l(e){if(!e.id.trim())throw Error("Locale id must not be empty");if(o.has(e.id))throw Error(`Locale already registered: ${e.id}`);o.set(e.id,e)}function s(){return[...o.keys()]}l({id:"en",label:"English",messages:{"common.ok":"OK","common.language":"Language","common.models":"Models","common.skills":"Skills","common.plugins":"Plugins","sidebar.hide":"Hide sidebar","sidebar.show":"Show sidebar","theme.light":"Light mode (click for dark)","theme.dark":"Dark mode (click for system)","theme.auto":"System theme (click for light)","history.full":"Full history","history.unsaved":"Full history is available after the session is saved","history.label":"Full history","title.generating":"Generating...","title.updated":"Title updated","title.failed":"Generation failed","title.generate":"Generate title","title.unsaved":"Title generation is available after the session is saved","title.noMessages":"Send a message before naming this session","title.generateSession":"Generate a session title","system.prompt":"System prompt","system.empty":"System prompt is empty (tools are disabled)","system.load":"System prompt has not loaded yet","system.loading":"Loading system prompt…","system.label":"System","session.info":"Session info","session.name":"Name","session.file":"File","session.inMemory":"In-memory","session.id":"ID","session.user":"User","session.assistant":"Assistant","session.toolCalls":"Tool Calls","session.toolResults":"Tool Results","session.total":"Total","session.input":"Input","session.output":"Output","session.cacheRead":"Cache Read","session.cacheWrite":"Cache Write","session.cost":"Cost","session.context":"Context","session.cacheHitRate":"Avg cache hit rate","session.copy":"Copy {value}","session.copied":"Copied","session.title":"Session info","session.load":"Send a message or run /session to load session info","session.infoSection":"Session Info","session.messages":"Messages","session.tokens":"Tokens","session.totalActive":"Active Time","session.copyFile":"Copy file path","session.copyId":"Copy session ID","workspace.opening":"Opening workspace...","workspace.unable":"Unable to open workspace","auth.deniedTitle":"Access denied","auth.deniedBody":"The login session is invalid or expired and the current user could not be verified. Please log in to LiYuBase3 first, then refresh this page.","auth.retry":"Retry","workspace.selectSession":"Select a session from the sidebar","workspace.getStarted":"Get Started","workspace.selectProject":"Select a project directory from the sidebar","workspace.addModels":"Add models via the Models button at the bottom","workspace.stepProject":"Select a project directory from the sidebar","workspace.stepModels":"Add models via the Models button at the bottom","files.hidePanel":"Hide file panel","files.showPanel":"Show file panel","files.noneOpen":"No file open","layout.resizeSidebar":"Resize sidebar","layout.resizeFilePanel":"Resize file panel","layout.resizeHint":"Drag to resize. Double-click or press Enter to reset.","sidebar.new":"New","sidebar.newSessionTitle":"New session in {path}","sidebar.refresh":"Refresh","sidebar.selectProject":"Select project…","sidebar.filterProjects":"Filter projects…","sidebar.noMatchingProjects":"No matching projects","sidebar.useDefaultDirectory":"Use default directory","sidebar.customPath":"Custom path…","directoryPicker.selectDirectory":"Select directory","directoryPicker.goToParent":"Go to parent directory","directoryPicker.directoryPath":"Directory path","directoryPicker.goToDirectory":"Go to directory","directoryPicker.go":"Go","directoryPicker.loadingDirectories":"Loading directories…","directoryPicker.noSubdirectories":"No subdirectories","directoryPicker.openBeforeSelecting":"Open this path before selecting it","directoryPicker.selectCurrentDirectory":"Select current directory","directoryPicker.selectThisFolder":"Select this folder","directoryPicker.noDrives":"No drives found","sidebar.checking":"Checking…","sidebar.open":"Open","sidebar.cancel":"Cancel","sidebar.openRepoRoot":"Open repo root","sidebar.openRepoRootTitle":"Open the repository root to manage worktrees.","sidebar.gitRepoRootOnly":"Git repo root only","sidebar.gitRepoRootOnlyTitle":"Worktrees are available in Git repository roots.","sidebar.worktrees":"Worktrees...","sidebar.checkingWorktrees":"Checking worktrees for this directory.","sidebar.filterWorktrees":"Filter worktrees…","sidebar.noMatchingWorktrees":"No matching worktrees","sidebar.switchWorktree":"Switch worktree","sidebar.switchWorktreeTitle":"Switch worktree: {path}","sidebar.main":"main","sidebar.forceRemoveCheckout":"Uncommitted changes. Force remove checkout?","sidebar.force":"Force","sidebar.createWorktreeTitle":"Create a worktree checkout for a branch","sidebar.newWorktree":"New worktree…","sidebar.branchName":"branch name","sidebar.creating":"Creating…","sidebar.create":"Create","sidebar.uploadFilesTitle":"Upload files to project root","sidebar.uploadFiles":"Upload files","sidebar.refreshExplorer":"Refresh explorer","sidebar.changedFiles":"{count} changed files","sidebar.loading":"Loading...","sidebar.noSessions":"No sessions found","sidebar.agentRunning":"Agent running…","sidebar.newActivity":"New activity","sidebar.newSessionActivity":"New session activity","sidebar.deleteSession":"Delete {title}?","sidebar.rename":"Rename","sidebar.delete":"Delete","sidebar.deleteWithShiftClick":"Delete (Shift+click to delete without confirmation)","sidebar.expandForks":"Expand forks","sidebar.collapseForks":"Collapse forks","sidebar.messagesCount":"{count} msgs","sidebar.worktreePath":"Worktree: {path}","sidebar.removeWorktreeTitle":"Remove worktree checkout {path}; the branch is kept","files.modified":"Modified","files.added":"Added","files.deleted":"Deleted","files.renamed":"Renamed","files.untracked":"Untracked","files.conflict":"Conflict","files.newlyUploaded":"Newly uploaded","files.containsChangedFiles":"Contains changed files","files.insertPath":"Insert path into chat","files.mention":"mention","files.download":"Download file","files.delete":"Delete file","files.deleteAction":"Delete","files.deleteConfirm":"Delete {name}? This cannot be undone.","files.deleteDirConfirm":"Delete directory {name} and all of its contents? This cannot be undone.","files.deleteFailed":"Failed to delete","files.dismissError":"Dismiss error","files.addUploadedFile":"Add uploaded file to chat","files.addAllUploadedFiles":"Add all uploaded files to chat","files.dismissUploadResults":"Dismiss upload results","files.loading":"Loading files...","files.noFiles":"No files found","files.explorer":"Explorer","files.changedCount":"{count} files","files.changeStats":"{count} changed files, {additions} lines added, {deletions} lines deleted","files.conflictSummary":"{count} file{countSuffix} already exist: {files}","files.cannotReplace":"Cannot replace: {files}","files.replace":"Replace","files.skipExisting":"Skip existing","files.cancel":"Cancel","files.checking":"Checking files","files.uploading":"Uploading, {progress}%","chat.loadingSession":"Loading session...","chat.runningTool":"Running tool...","chat.generatingToolInput":"Generating parameters...","chat.runningNamedTool":"Running {name}...","chat.runningTools":"Running {names}...","chat.runningToolsMore":"Running {names} (+{count})...","chat.waitingModel":"Waiting for model...","chat.runningCommand":"Running command...","chat.thinking":"Thinking...","chat.processDetails":"Process details","chat.message":"message","chat.messages":"messages","chat.toolCall":"tool call","chat.toolCalls":"tool calls","chat.collapseProcess":"Collapse process details","chat.expandProcess":"Expand process details","chat.filesWritten":"Files changed","chat.openWrittenFile":"Open {name}","chat.loadEarlier":"Scroll up to load earlier messages ({count} hidden)","chat.extensionRequest":"extension request","chat.cancel":"Cancel","chat.confirm":"Confirm","chat.submit":"Submit","chat.extensionInput":"Extension terminal input","chat.extensionPanel":"Extension panel","chat.extensionWidgets":"Extension widgets","chat.extensionWidgetAbove":"Above editor widget","chat.extensionWidgetBelow":"Below editor widget","chat.extensionWidgetLine":"{count} line","chat.extensionWidgetLines":"{count} lines","chat.close":"Close","chat.queued":"Queued \xb7 {count}","chat.recall":"Recall to input","chat.recallTitle":"Remove all queued messages and put them back into the input box for editing","chat.retrying":"Retrying ({attempt}/{max})…","chat.loadingCommands":"Loading commands...","chat.slashCommands":"Slash commands \xb7 {label}","chat.tabEnter":"Tab / Enter","chat.noCommands":"No extension, prompt, or skill commands found","chat.match":"1 match","chat.matches":"{count} matches","chat.command":"1 command","chat.commands":"{count} commands","chat.loadingFiles":"Loading files...","chat.files":"Files \xb7 {label}{hint}","chat.searching":"Searching…","chat.noMatchingFiles":"No matching files","chat.searchingAll":" \xb7 searching all files…","chat.indexTruncated":" \xb7 index truncated","chat.steerPlaceholder":"Steer now / queue follow-up...","chat.agentPlaceholder":"Agent is running…","chat.messagePlaceholder":"Message… Type / for commands, @ for files","chat.steer":"Steer","chat.followUp":"Follow-up","chat.send":"Send","chat.removePrefix":"Remove prefix","chat.attachFile":"Attach files (images use the image flow, other files are added as attachment context)","chat.attachmentUploading":"Uploading…","chat.attachmentFailed":"Upload failed","chat.previewImage":"Preview image","chat.filterModels":"Filter models…","chat.noMatchingModels":"No matching models","chat.moreControls":"More controls","chat.collapseControls":"Collapse controls","chat.shell":"Shell","chat.outputLocal":"output stays local","chat.outputModel":"output sent to model","chat.noTools":"No tools","chat.readOnlyTools":"{count} read-only built-in tools","chat.builtInTools":"{count} built-in tools","chat.allBuiltInTools":"All built-in tools","chat.changeReasoning":"Change reasoning level: {level}","chat.changeReasoningLabel":"Change reasoning level","chat.changeToolPreset":"Change tool preset","chat.stopCompaction":"Stop compaction","chat.compactContext":"Compact context","chat.compacting":"Compacting…","chat.compact":"Compact","chat.stopAgent":"Stop agent","chat.stop":"Stop","chat.disableSound":"Disable completion sound","chat.enableSound":"Enable completion sound","chat.thinkingUseDefault":"Use pi default","chat.thinkingOff":"Reasoning off","chat.thinkingMinimal":"Minimal reasoning","chat.thinkingLow":"Low reasoning","chat.thinkingMedium":"Medium reasoning","chat.thinkingHigh":"High reasoning","chat.thinkingXhigh":"Extra-high reasoning","chat.thinkingMax":"Max reasoning","chat.builtIn":"Built-in","chat.extensions":"Extensions","chat.prompts":"Prompts","chat.skills":"Skills","chat.dormant":"dormant","chat.commandCompact":"Compress context, optionally with instructions","chat.commandReload":"Reload extensions, skills, prompts, and tools","chat.commandName":"Set the session display name","chat.commandSession":"Show session message, token, and cost stats","chat.commandCopy":"Copy the last assistant message","chat.compacted":"Compacted","chat.tokensSaved":"{saved} saved","i18n.close":"Close","i18n.copy":"Copy","i18n.copied":"Copied","i18n.cancel":"Cancel","i18n.save":"Save","i18n.saving":"Saving…","i18n.saved":"Saved","i18n.remove":"Remove","i18n.removing":"Removing…","i18n.delete":"Delete","i18n.loading":"Loading...","i18n.search":"Search","i18n.refresh":"Refresh","i18n.update":"Update","i18n.updating":"Updating...","i18n.check":"Check","i18n.checking":"Checking...","i18n.install":"Install","i18n.installing":"Installing...","i18n.noResults":"No results","i18n.searchProviders":"Search providers…","i18n.noProviders":"No providers match","i18n.newModel":"new model","i18n.addProvider":"Add provider","i18n.selectProviderModel":"Select a provider or model","i18n.visibleInPrompt":"Visible in model prompt — click to disable","i18n.hiddenFromPrompt":"Hidden from model prompt — click to enable","i18n.dormant":"Dormant","i18n.hiddenButInvocable":"Hidden from model, still manually invocable","i18n.skillSearchPlaceholder":"e.g. react, testing, deploy","i18n.searching":"Searching…","i18n.noSkills":"No skills found","i18n.checkUpdates":"Check updates","i18n.updates":"updates","i18n.noResolvedResources":"No resolved resources","i18n.enablePackage":"Enable package","i18n.disablePackage":"Disable package","i18n.filtered":"filtered","i18n.openSessionToReload":"Open a session to reload","i18n.notFound":"Not found","i18n.noPlugins":"No plugins configured","trust.resourcesNotLoaded":"Restricted mode","trust.trustProject":"Trust project","trust.trusting":"Trusting...","trust.cancel":"Cancel","trust.dialogTitle":"Trust this project?","trust.dialogBody":"Project resources can run local code. Trust only projects whose contents you know.","trust.skillsNotLoaded":"Project skills are not loaded because this project is not trusted.","trust.pluginsNotLoaded":"Project plugins are not loaded because this project is not trusted.","trust.projectScopeUnavailable":"Project installs are unavailable while project resources are not loaded.","i18n.creatingSession":"Creating new session…","i18n.creating":"Creating…","i18n.subscription":"Subscription","i18n.subscriptions":"Subscriptions","i18n.customEndpoint":"Custom endpoint format","i18n.noChanges":"No changes","i18n.branches":"Branches","i18n.noActiveSession":"No active session","i18n.noBranches":"This session has no branches","i18n.source":"Source","i18n.preview":"Preview","i18n.diff":"Diff","i18n.downloadFile":"Download file","i18n.liveSync":"Live sync active","i18n.notWatching":"Not watching","i18n.fileViewMode":"File view mode","i18n.compareHead":"Compare working tree with HEAD","i18n.mentionSelectedLines":"Mention selected lines","i18n.disableWrap":"Disable word wrap","i18n.enableWrap":"Enable word wrap","i18n.htmlPreview":"HTML preview","i18n.previewFile":"Preview {file}","i18n.convertingDocument":"Converting…","i18n.invalidMermaid":"Invalid Mermaid diagram","i18n.renderingMermaid":"Rendering Mermaid diagram","i18n.previewAfterStreaming":"Preview available after streaming","i18n.showMermaidSource":"Show Mermaid source","i18n.previewMermaid":"Preview Mermaid diagram","i18n.openMermaidViewer":"Open diagram viewer","i18n.mermaidViewer":"Mermaid diagram viewer","i18n.mermaidDiagram":"Mermaid diagram","i18n.zoomOut":"Zoom out","i18n.zoomIn":"Zoom in","i18n.fitToWidth":"Fit to width","models.discoveryFetching":"Importing models…","models.discoveryFetch":"Import models…","models.discoveryFilterPlaceholder":"Filter {count} models…","models.discoveryFilter":"Filter upstream models","models.discoverySelectShown":"Select shown","models.discoveryNoMatches":"No matching models.","models.discoveryAdded":"added","models.discoveryShowing":"Showing first {shown} of {total}","models.discoveryFetched":"{count} models fetched","models.discoveryAddSelected":"Add selected","models.discoveryAddSelectedCount":"Add selected ({count})","models.catalogSource":"source: models.dev ↗","models.catalogFilling":"Filling details…","models.catalogFill":"Fill model details","models.catalogFilled":"{count} fields filled","models.catalogNoEmptyFields":"No empty fields to fill","models.catalogNoExactMatch":"No exact models.dev match","models.catalogPriceProvider":"Price matched Provider {provider}","models.catalogPriceBaseUrl":"Price matched Base URL to {provider}","models.catalogPriceConsensus":"Price agreed by {support}/{total} records","models.catalogPriceUnreliable":"No reliable price found","models.catalogUndo":"Undo","models.capabilities":"Capabilities","models.reasoning":"Reasoning / thinking","models.imageInput":"Image input","models.modelSpecs":"Model specifications","models.contextWindow":"Context window (tokens)","models.maxOutputTokens":"Max output tokens","models.costPerMillion":"Cost per million tokens","models.costInput":"Input","models.costOutput":"Output","models.costCacheRead":"Cache read","models.costCacheWrite":"Cache write","models.notProvided":"Not provided","models.editCosts":"Edit prices","models.finishEditingCosts":"Done","models.costAllRequired":"Enter a valid non-negative price; blank fields are saved as 0.","models.advancedSettings":"Advanced settings","models.providerDefaults":"Using provider defaults","models.headersSummary":"Headers: {count}","models.compatSummary":"Compatibility: {count}","models.thinkingSummary":"Thinking levels: {count}","models.apiOverride":"API override","models.headers":"Headers","models.headersHelp":"Added to this model's requests and overrides provider headers.","models.compatibility":"Compatibility","models.deepSeekThinkingCompat":"DeepSeek thinking compatibility","models.developerRole":"Use the developer role for the system prompt","models.thinkingLevelMap":"Thinking level map","models.clearAll":"Clear all","i18n.testingModel":"Testing model connection...","i18n.connected":"Connected","i18n.failed":"Failed","i18n.test":"Test","i18n.testConnection":"Test model connection","i18n.provider":"Provider","i18n.model":"Model","i18n.providerName":"Provider name","i18n.rename":"Rename","i18n.default":"Default","i18n.disabled":"Disabled","i18n.noResources":"No resources","i18n.unknown":"Unknown","i18n.installedVersion":"installed {version}","i18n.configuredVersion":"configured {version}","i18n.extensions":"Extensions","i18n.prompts":"Prompts","i18n.themes":"Themes","i18n.resourceCount":"{count} {label}","i18n.extensionShort":"ext","i18n.skillShort":"skills","i18n.promptShort":"prompts","i18n.themeShort":"themes","i18n.custom":"Custom","i18n.clearAll":"clear all","i18n.connectedSuccessfully":"Connected successfully.","i18n.notConnected":"not connected","i18n.configured":"configured","i18n.notConfigured":"not configured","i18n.openingBrowser":"Opening browser…","i18n.submit":"Submit","i18n.login":"Login","i18n.relogin":"Re-login","i18n.disconnect":"Disconnect","i18n.networkError":"Network error","i18n.continuing":"Continuing…","i18n.skills":"Skills","i18n.plugins":"Plugins","i18n.addSkill":"Add skill","i18n.addPlugin":"Add plugin","i18n.selectSkill":"Select a skill","i18n.selectPackage":"Select a package","i18n.updateAvailable":"Update available","i18n.upToDate":"Up to date","i18n.automaticChecksUnavailable":"Automatic checks unavailable","i18n.checkFailed":"Check failed","i18n.installed":"Installed","i18n.status":"Status","i18n.version":"Version","i18n.package":"Package","i18n.resources":"Resources","i18n.installedPath":"Installed path","i18n.cwd":"CWD","i18n.resolvedResources":"Resolved Resources","i18n.reloadSession":"Reload session","i18n.reloading":"Reloading...","i18n.packageRemoved":"Package removed.","i18n.packageInstalled":"Package installed.","i18n.packageUpdated":"Package updated.","i18n.packageDisabled":"Package disabled.","i18n.packageEnabled":"Package enabled.","i18n.sessionReloaded":"Session reloaded.","i18n.thinking":"Thinking","i18n.largeMessageReveal":"Message content is very large ({size}). Click to view as plain text — markdown rendering is disabled to keep the page responsive.","i18n.loadingThinking":"Loading thinking...","i18n.copyMessage":"Copy message","i18n.editFromHere":"Edit from here","i18n.editFromHereTitle":"Edit from here — branches within this session","i18n.newSession":"New session","i18n.newSessionTitle":"New session — creates an independent copy from here","i18n.estimatedTokens":"Estimated token count while streaming","i18n.noOutput":"(no output)","i18n.noSummary":"(no summary)","i18n.conversationCompacted":"Conversation compacted","i18n.compactionDescription":"The conversation history before this point was compacted into the following summary:","i18n.fileContext":"File context: {details}","i18n.readFiles":"Read files","i18n.modifiedFiles":"Modified files","i18n.hiddenExtensionMessage":"hidden extension message","i18n.noMessage":"(no message)","i18n.showExtensionMessage":"Show extension message","i18n.collapse":"Collapse","i18n.expand":"Expand","i18n.hideDetails":"Hide details","i18n.showDetails":"Show details","i18n.thinkingUnavailable":"Thinking content unavailable","i18n.before":"Before","i18n.after":"After","i18n.sessionComplete":"Session complete","i18n.taskFinished":"Task finished.","i18n.attentionNeeded":"Pi needs your attention","i18n.extensionInputNeeded":"An extension is waiting for your input."}}),l({id:"zh-CN",label:"简体中文",messages:{"common.ok":"确定","common.language":"语言","common.models":"模型","common.skills":"技能","common.plugins":"插件","sidebar.hide":"隐藏侧边栏","sidebar.show":"显示侧边栏","theme.light":"浅色模式(点击切换到深色)","theme.dark":"深色模式(点击切换到跟随系统)","theme.auto":"跟随系统(点击切换到浅色)","history.full":"完整历史","history.unsaved":"会话保存后才能查看完整历史","history.label":"完整历史","title.generating":"正在生成...","title.updated":"标题已更新","title.failed":"生成失败","title.generate":"生成标题","title.unsaved":"会话保存后才能生成标题","title.noMessages":"请先发送消息,再为会话命名","title.generateSession":"生成会话标题","system.prompt":"系统提示词","system.empty":"系统提示词为空(工具已禁用)","system.load":"系统提示词尚未加载","system.loading":"正在加载系统提示词…","system.label":"系统","session.info":"会话信息","session.name":"名称","session.file":"文件","session.inMemory":"内存中","session.id":"ID","session.user":"用户","session.assistant":"助手","session.toolCalls":"工具调用","session.toolResults":"工具结果","session.total":"总计","session.input":"输入","session.output":"输出","session.cacheRead":"缓存读取","session.cacheWrite":"缓存写入","session.cost":"费用","session.context":"上下文","session.cacheHitRate":"平均缓存命中率","session.copy":"复制{value}","session.copied":"已复制","session.title":"会话信息","session.load":"发送消息或运行 /session 以加载会话信息","session.infoSection":"会话信息","session.messages":"消息","session.tokens":"Token","session.totalActive":"活跃时长","session.copyFile":"复制文件路径","session.copyId":"复制会话 ID","workspace.opening":"正在打开工作区...","workspace.unable":"无法打开工作区","auth.deniedTitle":"无法访问","auth.deniedBody":"登录状态无效或已过期,无法确认当前用户。请先登录,然后刷新本页面。","auth.retry":"重试","workspace.selectSession":"从侧边栏选择一个会话","workspace.getStarted":"开始使用","workspace.selectProject":"从侧边栏选择项目目录","workspace.addModels":"点击底部的“模型”按钮添加模型","workspace.stepProject":"从侧边栏选择项目目录","workspace.stepModels":"点击底部的“模型”按钮添加模型","files.hidePanel":"隐藏文件面板","files.showPanel":"显示文件面板","files.noneOpen":"没有打开的文件","layout.resizeSidebar":"调整侧边栏宽度","layout.resizeFilePanel":"调整文件面板宽度","layout.resizeHint":"拖动调整宽度。双击或按 Enter 恢复默认值。","sidebar.new":"新建","sidebar.newSessionTitle":"在 {path} 中新建会话","sidebar.refresh":"刷新","sidebar.selectProject":"选择项目…","sidebar.filterProjects":"筛选项目…","sidebar.noMatchingProjects":"没有匹配的项目","sidebar.useDefaultDirectory":"使用默认目录","sidebar.customPath":"自定义路径…","directoryPicker.selectDirectory":"选择目录","directoryPicker.goToParent":"转到上级目录","directoryPicker.directoryPath":"目录路径","directoryPicker.goToDirectory":"转到目录","directoryPicker.go":"转到","directoryPicker.loadingDirectories":"正在加载目录…","directoryPicker.noSubdirectories":"没有子目录","directoryPicker.openBeforeSelecting":"选择前请先打开此路径","directoryPicker.selectCurrentDirectory":"选择当前目录","directoryPicker.selectThisFolder":"选择此文件夹","directoryPicker.noDrives":"未找到盘符","sidebar.checking":"检查中…","sidebar.open":"打开","sidebar.cancel":"取消","sidebar.openRepoRoot":"打开仓库根目录","sidebar.openRepoRootTitle":"打开仓库根目录以管理 worktree。","sidebar.gitRepoRootOnly":"仅 Git 仓库根目录","sidebar.gitRepoRootOnlyTitle":"只能在 Git 仓库根目录使用 worktree。","sidebar.worktrees":"Worktrees...","sidebar.checkingWorktrees":"正在检查此目录的 worktree。","sidebar.filterWorktrees":"筛选 worktree…","sidebar.noMatchingWorktrees":"没有匹配的 worktree","sidebar.switchWorktree":"切换 worktree","sidebar.switchWorktreeTitle":"切换 worktree:{path}","sidebar.main":"主分支","sidebar.forceRemoveCheckout":"存在未提交的更改。强制移除 checkout?","sidebar.force":"强制移除","sidebar.createWorktreeTitle":"为分支创建 worktree checkout","sidebar.newWorktree":"新建 worktree…","sidebar.branchName":"分支名称","sidebar.creating":"创建中…","sidebar.create":"创建","sidebar.uploadFilesTitle":"将文件上传到项目根目录","sidebar.uploadFiles":"上传文件","sidebar.refreshExplorer":"刷新文件浏览器","sidebar.changedFiles":"{count} 个变更文件","sidebar.loading":"加载中...","sidebar.noSessions":"未找到会话","sidebar.agentRunning":"Agent 运行中…","sidebar.newActivity":"有新活动","sidebar.newSessionActivity":"会话有新活动","sidebar.deleteSession":"删除 {title}?","sidebar.rename":"重命名","sidebar.delete":"删除","sidebar.deleteWithShiftClick":"删除(按住 Shift 点击可跳过确认)","sidebar.expandForks":"展开分叉","sidebar.collapseForks":"折叠分叉","sidebar.messagesCount":"{count} 条消息","sidebar.worktreePath":"Worktree:{path}","sidebar.removeWorktreeTitle":"移除 worktree checkout {path};保留分支","files.modified":"已修改","files.added":"已添加","files.deleted":"已删除","files.renamed":"已重命名","files.untracked":"未跟踪","files.conflict":"冲突","files.newlyUploaded":"刚上传","files.containsChangedFiles":"包含已更改文件","files.insertPath":"将路径插入聊天","files.mention":"提及","files.download":"下载文件","files.delete":"删除文件","files.deleteAction":"删除","files.deleteConfirm":"删除 {name}?此操作不可恢复。","files.deleteDirConfirm":"删除目录 {name} 及其全部内容?此操作不可恢复。","files.deleteFailed":"删除失败","files.dismissError":"关闭错误","files.addUploadedFile":"将上传的文件添加到聊天","files.addAllUploadedFiles":"将所有上传的文件添加到聊天","files.dismissUploadResults":"关闭上传结果","files.loading":"正在加载文件...","files.noFiles":"未找到文件","files.explorer":"文件浏览器","files.changedCount":"{count} 个文件","files.changeStats":"{count} 个变更文件,新增 {additions} 行,删除 {deletions} 行","files.conflictSummary":"已有 {count} 个文件:{files}","files.cannotReplace":"无法替换:{files}","files.replace":"替换","files.skipExisting":"跳过已有文件","files.cancel":"取消","files.checking":"正在检查文件","files.uploading":"正在上传,{progress}%","chat.loadingSession":"正在加载会话...","chat.runningTool":"正在运行工具...","chat.generatingToolInput":"正在生成参数...","chat.runningNamedTool":"正在运行 {name}...","chat.runningTools":"正在运行 {names}...","chat.runningToolsMore":"正在运行 {names}(另有 {count} 个)...","chat.waitingModel":"正在等待模型...","chat.runningCommand":"正在运行命令...","chat.thinking":"正在思考...","chat.processDetails":"处理详情","chat.message":"条消息","chat.messages":"条消息","chat.toolCall":"次工具调用","chat.toolCalls":"次工具调用","chat.collapseProcess":"收起处理详情","chat.expandProcess":"展开处理详情","chat.filesWritten":"改动的文件","chat.openWrittenFile":"打开 {name}","chat.loadEarlier":"向上滚动以加载更早的消息(隐藏 {count} 条)","chat.extensionRequest":"扩展请求","chat.cancel":"取消","chat.confirm":"确认","chat.submit":"提交","chat.extensionInput":"扩展终端输入","chat.extensionPanel":"扩展面板","chat.extensionWidgets":"扩展组件","chat.extensionWidgetAbove":"输入框上方组件","chat.extensionWidgetBelow":"输入框下方组件","chat.extensionWidgetLine":"{count} 行","chat.extensionWidgetLines":"{count} 行","chat.close":"关闭","chat.queued":"已排队 \xb7 {count}","chat.recall":"移回输入框","chat.recallTitle":"移除所有排队消息并将其放回输入框编辑","chat.retrying":"正在重试({attempt}/{max})…","chat.loadingCommands":"正在加载命令...","chat.slashCommands":"斜杠命令 \xb7 {label}","chat.tabEnter":"Tab / Enter","chat.noCommands":"未找到扩展、提示词或技能命令","chat.match":"1 个匹配项","chat.matches":"{count} 个匹配项","chat.command":"1 个命令","chat.commands":"{count} 个命令","chat.loadingFiles":"正在加载文件...","chat.files":"文件 \xb7 {label}{hint}","chat.searching":"搜索中…","chat.noMatchingFiles":"未找到匹配的文件","chat.searchingAll":" \xb7 正在搜索所有文件…","chat.indexTruncated":" \xb7 索引不完整","chat.steerPlaceholder":"立即引导 / 排队后续消息...","chat.agentPlaceholder":"Agent 运行中…","chat.messagePlaceholder":"消息…输入 / 使用命令,输入 @ 查找文件","chat.steer":"引导","chat.followUp":"后续消息","chat.send":"发送","chat.removePrefix":"移除前缀","chat.attachFile":"附加文件(图片按图片处理,其他文件作为附件上下文)","chat.attachmentUploading":"上传中…","chat.attachmentFailed":"上传失败","chat.previewImage":"预览图片","chat.filterModels":"筛选模型…","chat.noMatchingModels":"没有匹配的模型","chat.moreControls":"更多控件","chat.collapseControls":"收起控件","chat.shell":"Shell","chat.outputLocal":"输出保留在本地","chat.outputModel":"输出发送给模型","chat.noTools":"不使用工具","chat.readOnlyTools":"{count} 个只读内置工具","chat.builtInTools":"{count} 个内置工具","chat.allBuiltInTools":"全部内置工具","chat.changeReasoning":"更改推理级别:{level}","chat.changeReasoningLabel":"更改推理级别","chat.changeToolPreset":"更改工具预设","chat.stopCompaction":"停止压缩","chat.compactContext":"压缩上下文","chat.compacting":"正在压缩…","chat.compact":"压缩","chat.stopAgent":"停止 Agent","chat.stop":"停止","chat.disableSound":"关闭完成提示音","chat.enableSound":"开启完成提示音","chat.thinkingUseDefault":"使用 pi 默认设置","chat.thinkingOff":"关闭推理","chat.thinkingMinimal":"最低限度推理","chat.thinkingLow":"低强度推理","chat.thinkingMedium":"中等强度推理","chat.thinkingHigh":"高强度推理","chat.thinkingXhigh":"超高强度推理","chat.thinkingMax":"最高强度推理","chat.builtIn":"内置","chat.extensions":"扩展","chat.prompts":"提示词","chat.skills":"技能","chat.dormant":"休眠","chat.commandCompact":"压缩上下文,可选附加说明","chat.commandReload":"重新加载扩展、技能、提示词和工具","chat.commandName":"设置会话显示名称","chat.commandSession":"显示会话消息、Token 和费用统计","chat.commandCopy":"复制最后一条助手消息","chat.compacted":"已压缩","chat.tokensSaved":"节省 {saved}","i18n.close":"关闭","i18n.copy":"复制","i18n.copied":"已复制","i18n.cancel":"取消","i18n.save":"保存","i18n.saving":"保存中…","i18n.saved":"已保存","i18n.remove":"移除","i18n.removing":"移除中…","i18n.delete":"删除","i18n.loading":"加载中...","i18n.search":"搜索","i18n.refresh":"刷新","i18n.update":"更新","i18n.updating":"更新中...","i18n.check":"检查","i18n.checking":"检查中...","i18n.install":"安装","i18n.installing":"安装中...","i18n.noResults":"没有结果","i18n.searchProviders":"搜索 Provider…","i18n.noProviders":"没有匹配的 Provider","i18n.newModel":"新模型","i18n.addProvider":"添加 Provider","i18n.selectProviderModel":"选择 Provider 或模型","i18n.visibleInPrompt":"在模型提示词中可见,点击以禁用","i18n.hiddenFromPrompt":"在模型提示词中隐藏,点击以启用","i18n.dormant":"休眠","i18n.hiddenButInvocable":"对模型隐藏,仍可手动调用","i18n.skillSearchPlaceholder":"例如 react、testing、deploy","i18n.searching":"搜索中…","i18n.noSkills":"未找到技能","i18n.checkUpdates":"检查更新","i18n.updates":"项更新","i18n.noResolvedResources":"没有已解析资源","i18n.enablePackage":"启用包","i18n.disablePackage":"禁用包","i18n.filtered":"已筛选","i18n.openSessionToReload":"打开会话后才能重新加载","i18n.notFound":"未找到","i18n.noPlugins":"未配置插件","trust.resourcesNotLoaded":"受限模式","trust.trustProject":"信任项目","trust.trusting":"正在信任...","trust.cancel":"取消","trust.dialogTitle":"信任此项目?","trust.dialogBody":"项目资源可以运行本地代码。请仅信任你了解其内容的项目。","trust.skillsNotLoaded":"此项目尚未受信任,项目技能未加载。","trust.pluginsNotLoaded":"此项目尚未受信任,项目插件未加载。","trust.projectScopeUnavailable":"项目资源未加载时,无法安装到项目范围。","i18n.creatingSession":"正在创建新会话…","i18n.creating":"创建中…","i18n.subscription":"订阅","i18n.subscriptions":"订阅服务","i18n.customEndpoint":"自定义端点格式","i18n.noChanges":"没有更改","i18n.branches":"分支","i18n.noActiveSession":"没有活动会话","i18n.noBranches":"此会话没有分支","i18n.source":"源代码","i18n.preview":"预览","i18n.diff":"Diff","i18n.downloadFile":"下载文件","i18n.liveSync":"实时同步已启用","i18n.notWatching":"未监视","i18n.fileViewMode":"文件视图模式","i18n.compareHead":"比较工作区与 HEAD","i18n.mentionSelectedLines":"提及所选行","i18n.disableWrap":"禁用自动换行","i18n.enableWrap":"启用自动换行","i18n.htmlPreview":"HTML 预览","i18n.previewFile":"预览 {file}","i18n.convertingDocument":"解析中…","i18n.invalidMermaid":"Mermaid 图表无效","i18n.renderingMermaid":"正在渲染 Mermaid 图表","i18n.previewAfterStreaming":"流式输出完成后可预览","i18n.showMermaidSource":"显示 Mermaid 源码","i18n.previewMermaid":"预览 Mermaid 图表","i18n.openMermaidViewer":"打开图表查看器","i18n.mermaidViewer":"Mermaid 图表查看器","i18n.mermaidDiagram":"Mermaid 图表","i18n.zoomOut":"缩小","i18n.zoomIn":"放大","i18n.fitToWidth":"适应宽度","models.discoveryFetching":"正在导入模型…","models.discoveryFetch":"导入模型…","models.discoveryFilterPlaceholder":"筛选 {count} 个模型…","models.discoveryFilter":"筛选上游模型","models.discoverySelectShown":"选择当前结果","models.discoveryNoMatches":"没有匹配的模型。","models.discoveryAdded":"已添加","models.discoveryShowing":"显示前 {shown} 个,共 {total} 个","models.discoveryFetched":"已获取 {count} 个模型","models.discoveryAddSelected":"添加所选模型","models.discoveryAddSelectedCount":"添加所选模型({count})","models.catalogSource":"来源:models.dev ↗","models.catalogFilling":"正在填入模型信息…","models.catalogFill":"填入模型信息","models.catalogFilled":"已填入 {count} 个字段","models.catalogNoEmptyFields":"没有需要填入的空字段","models.catalogNoExactMatch":"models.dev 中没有精确匹配","models.catalogPriceProvider":"价格已匹配 Provider {provider}","models.catalogPriceBaseUrl":"价格已按 Base URL 匹配 {provider}","models.catalogPriceConsensus":"价格得到 {support}/{total} 条记录支持","models.catalogPriceUnreliable":"未找到可靠价格","models.catalogUndo":"撤销","models.capabilities":"能力","models.reasoning":"推理 / 思考","models.imageInput":"图片输入","models.modelSpecs":"模型规格","models.contextWindow":"上下文窗口(tokens)","models.maxOutputTokens":"最大输出 tokens","models.costPerMillion":"每百万 tokens 价格","models.costInput":"输入","models.costOutput":"输出","models.costCacheRead":"缓存读取","models.costCacheWrite":"缓存写入","models.notProvided":"未提供","models.editCosts":"编辑价格","models.finishEditingCosts":"完成","models.costAllRequired":"请输入有效的非负价格;留空项将按 0 保存。","models.advancedSettings":"高级设置","models.providerDefaults":"沿用 Provider 默认设置","models.headersSummary":"Headers:{count}","models.compatSummary":"兼容性:{count}","models.thinkingSummary":"思考等级:{count}","models.apiOverride":"API 覆盖","models.headers":"Headers","models.headersHelp":"仅添加到该模型的请求中,并覆盖 Provider 的同名 Header。","models.compatibility":"兼容性","models.deepSeekThinkingCompat":"DeepSeek 思考兼容","models.developerRole":"使用 developer role 传递系统提示词","models.thinkingLevelMap":"思考等级映射","models.clearAll":"全部清除","i18n.testingModel":"正在测试模型连接...","i18n.connected":"已连接","i18n.failed":"失败","i18n.test":"测试","i18n.testConnection":"测试模型连接","i18n.provider":"Provider","i18n.model":"模型","i18n.providerName":"Provider 名称","i18n.rename":"重命名","i18n.default":"默认","i18n.disabled":"已禁用","i18n.noResources":"没有资源","i18n.unknown":"未知","i18n.installedVersion":"已安装 {version}","i18n.configuredVersion":"已配置 {version}","i18n.extensions":"扩展","i18n.prompts":"提示词","i18n.themes":"主题","i18n.resourceCount":"{count}{label}","i18n.extensionShort":"扩展","i18n.skillShort":"技能","i18n.promptShort":"提示词","i18n.themeShort":"主题","i18n.custom":"自定义","i18n.clearAll":"清除全部","i18n.connectedSuccessfully":"连接成功。","i18n.notConnected":"未连接","i18n.configured":"已配置","i18n.notConfigured":"未配置","i18n.openingBrowser":"正在打开浏览器…","i18n.submit":"提交","i18n.login":"登录","i18n.relogin":"重新登录","i18n.disconnect":"断开连接","i18n.networkError":"网络错误","i18n.continuing":"继续中…","i18n.skills":"技能","i18n.plugins":"插件","i18n.addSkill":"添加技能","i18n.addPlugin":"添加插件","i18n.selectSkill":"选择技能","i18n.selectPackage":"选择包","i18n.updateAvailable":"有可用更新","i18n.upToDate":"已是最新","i18n.automaticChecksUnavailable":"自动检查不可用","i18n.checkFailed":"检查失败","i18n.installed":"已安装","i18n.status":"状态","i18n.version":"版本","i18n.package":"包","i18n.resources":"资源","i18n.installedPath":"安装路径","i18n.cwd":"CWD","i18n.resolvedResources":"已解析资源","i18n.reloadSession":"重新加载会话","i18n.reloading":"重新加载中...","i18n.packageRemoved":"包已移除。","i18n.packageInstalled":"包已安装。","i18n.packageUpdated":"包已更新。","i18n.packageDisabled":"包已禁用。","i18n.packageEnabled":"包已启用。","i18n.sessionReloaded":"会话已重新加载。","i18n.thinking":"思考","i18n.largeMessageReveal":"消息内容过大({size})。点击以纯文本查看 — 已禁用 markdown 渲染以避免页面卡顿。","i18n.loadingThinking":"正在加载思考内容...","i18n.copyMessage":"复制消息","i18n.editFromHere":"从此处编辑","i18n.editFromHereTitle":"从此处编辑,此会话内创建分支","i18n.newSession":"新会话","i18n.newSessionTitle":"新会话,从此处创建独立副本","i18n.estimatedTokens":"流式输出期间的估算 Token 数","i18n.noOutput":"(无输出)","i18n.noSummary":"(无摘要)","i18n.conversationCompacted":"会话已压缩","i18n.compactionDescription":"此处之前的会话历史已压缩为以下摘要:","i18n.fileContext":"文件上下文:{details}","i18n.readFiles":"读取的文件","i18n.modifiedFiles":"修改的文件","i18n.hiddenExtensionMessage":"隐藏的扩展消息","i18n.noMessage":"(无消息)","i18n.showExtensionMessage":"显示扩展消息","i18n.collapse":"收起","i18n.expand":"展开","i18n.hideDetails":"隐藏详情","i18n.showDetails":"显示详情","i18n.thinkingUnavailable":"思考内容不可用","i18n.before":"之前","i18n.after":"之后","i18n.sessionComplete":"任务完成","i18n.taskFinished":"任务已完成。","i18n.attentionNeeded":"Pi 需要你的操作","i18n.extensionInputNeeded":"扩展正在等待你的输入。"}});let a="pi-locale",d=(0,i.createContext)(null);function c({children:e}){let[t,n]=(0,i.useState)("en"),[l,u]=(0,i.useState)(!1),p=(0,i.useMemo)(()=>s().map(e=>o.get(e)).filter(e=>!!e),[]),h=(0,i.useMemo)(()=>Object.fromEntries(s().flatMap(e=>{let t=o.get(e);return t?[[e,t.messages]]:[]})),[]);(0,i.useEffect)(()=>{let e=function(){try{let e=window.localStorage.getItem(a);if("en"===e||"zh-CN"===e)return e}catch{}for(let e of window.navigator.languages.length?window.navigator.languages:[window.navigator.language]){let t=e.toLowerCase();if("en"===t||t.startsWith("en-"))break;if("zh"===t||t.startsWith("zh-"))return"zh-CN"}return"en"}();n(e),document.documentElement.lang=e,u(!0)},[]);let g=(0,i.useCallback)(e=>{if(o.get(e)){n(e),document.documentElement.lang=e;try{window.localStorage.setItem(a,e)}catch{}}},[]),f=(0,i.useCallback)((e,n)=>(function(e,t,n,r={}){let i=n[e]?.[t]??n.en?.[t];return void 0===i?t:function(e,t={}){return e.replace(/\{([\w.-]+)\}/g,(e,n)=>{let r=t[n];return void 0===r?e:String(r)})}(i,r)})(t,e,h,n),[t,h]),x=(0,i.useMemo)(()=>({locale:l?t:"en",setLocale:g,t:f,supportedLocales:p}),[l,t,g,f,p]);return(0,r.jsx)(d.Provider,{value:x,children:e})}function u(){let e=(0,i.useContext)(d);if(!e)throw Error("useI18n must be used inside I18nProvider");return e}},73964:(e,t,n)=>{"use strict";n.d(t,{AppShell:()=>or});var r=n(95155),i=n(12115),o=n(73321);let l=null;var s=n(26619);let a="pi-web:file-explorer:open";function d(){try{return window.localStorage}catch{return null}}let c=/^<skill name="([^"\n]+)" location="([^"\n]+)">\nReferences are relative to [^\n]+\.\n\n([\s\S]*)\n<\/skill>(?:\n\n([\s\S]+))?$/;function u(e){let t=e.match(c);if(!t)return null;let[,n,,,r]=t;return r?`/skill:${n} ${r}`:`/skill:${n}`}let p="pi-web:last-open-by-workspace";function h(){try{return window.localStorage}catch{return null}}function g(e){let t=e.getItem(p);if(!t)return{};try{let e=JSON.parse(t);return null===e||"object"!=typeof e||Array.isArray(e)?{}:e}catch{return{}}}function f(e,t=h()){if(t)try{let n=g(t);if(!(e in n))return;delete n[e],0===Object.keys(n).length?t.removeItem(p):t.setItem(p,JSON.stringify(n))}catch{}}function x(e){return e.projectKey??e.projectRoot??e.cwd}function m(e,t){return e.filter(e=>x(e)===t)}var v=n(39247);let y="/icons/catppuccin";function b({name:e,size:t=14}){let n={width:t,height:t,"--catppuccin-icon-light":`url(${(0,s.hd)(`${y}/latte/${e}.svg`)})`,"--catppuccin-icon-dark":`url(${(0,s.hd)(`${y}/mocha/${e}.svg`)})`};return(0,r.jsx)("span",{"aria-hidden":"true",className:"catppuccin-file-icon",style:n})}function k({size:e=14,open:t=!1}){return(0,r.jsx)(b,{name:t?"_folder_open":"_folder",size:e})}function w({size:e=14}){return(0,r.jsx)(b,{name:"_file",size:e})}let j={ts:"typescript",tsx:"typescript-react",js:"javascript",mjs:"javascript",cjs:"javascript",jsx:"javascript-react",py:"python",json:"json",jsonl:"json",css:"css",less:"css",scss:"sass",html:"html",htm:"html",md:"markdown",mdx:"markdown",yaml:"yaml",yml:"yaml",toml:"toml",sh:"bash",bash:"bash",zsh:"bash",fish:"bash",rs:"rust",go:"go",sql:"database",graphql:"graphql",gql:"graphql",tf:"terraform",hcl:"terraform",docx:"ms-word",pdf:"pdf",lock:"lock"};function S(e,t=14){let n=e.toLowerCase(),i="dockerfile"===n||n.startsWith("dockerfile.")?"docker":".env"===n||n.startsWith(".env.")?"env":[".gitignore",".gitattributes",".gitmodules"].includes(n)?"git":"package-lock.json"===n?"npm-lock":"bun.lock"===n?"bun-lock":["next.config.js","next.config.mjs","next.config.cjs","next.config.ts"].includes(n)?"next":[".eslintrc",".eslintrc.js",".eslintrc.json",".eslintrc.yml","eslint.config.mjs","eslint.config.js"].includes(n)?"eslint":["yarn.lock","pnpm-lock.yaml","cargo.lock"].includes(n)?"lock":n.endsWith(".config.ts")||n.endsWith(".config.js")||n.endsWith(".config.mjs")||n.endsWith(".config.cjs")?"config":void 0;if(i)return(0,r.jsx)(b,{name:i,size:t});let o=j[n.split(".").pop()??""];return o?(0,r.jsx)(b,{name:o,size:t}):(0,r.jsx)(w,{size:t})}function C(e){return/^[a-zA-Z]:[\\/]/.test(e)||e.startsWith("\\\\")?e.replace(/\\/g,"/"):e}function T(e){return C(e).split("/").filter(Boolean).map(encodeURIComponent).join("/")}function R(e){let t=C(e).replace(/\/+$/,"");return t.split("/").pop()??t}function M(e){let t=C(e).replace(/\/+$/,""),n=t.lastIndexOf("/");return n<0?"":0===n?"/":2===n&&/^[a-zA-Z]:\//.test(t)?t.slice(0,3):t.slice(0,n)}function I(e,t){if(!t)return e;let n=C(e),r=C(t).replace(/\/$/,"");return n.startsWith(r+"/")?n.slice(r.length+1):e}function L(e,t){return`${C(e).replace(/\/$/,"")}/${t}`}let E="ly-ai-assistant";function W(e,t){let n=document.createElement("a");n.href=e,n.download=t,n.rel="noopener noreferrer",n.style.display="none",document.body.appendChild(n),n.click(),n.remove()}async function $(e,t){let n=(0,s.hd)(e);if(!function(){try{return window.parent!==window}catch{return!0}}())return void W(n,t);let r=await fetch(n);if(!r.ok)throw Error(`下载文件失败(HTTP ${r.status})`);let i=function(e){if(!e)return null;let t=/filename\*=UTF-8''([^;]+)/i.exec(e);if(t?.[1])try{return decodeURIComponent(t[1])}catch{return t[1]}let n=/filename="?([^"]+)"?/i.exec(e);return n?.[1]||null}(r.headers.get("content-disposition"))||t,o=r.headers.get("content-type")?.split(";",1)[0]?.trim()||"application/octet-stream",l=await r.arrayBuffer();if(!(await function(e,t=15e3){return new Promise(n=>{let r=!1,i=null,o=`${Date.now()}-${Math.random().toString(36).slice(2,8)}-download`,l=e=>{r||(r=!0,i&&clearTimeout(i),window.removeEventListener("message",s),n(e))},s=e=>{let t=e.data;t&&"object"==typeof t&&t.source===E&&"download_file_response"===t.type&&t.requestId===o&&l(t.ok?{ok:!0}:{ok:!1,error:"string"==typeof t.error?t.error:"未知错误"})};i=setTimeout(()=>l({ok:!1,error:"父页面未响应下载请求(超时)"}),t),window.addEventListener("message",s);try{window.parent.postMessage({source:E,type:"download_file_request",requestId:o,fileName:e.fileName,mimeType:e.mimeType,bytes:e.bytes},"*",[e.bytes])}catch(e){l({ok:!1,error:`向父页面发送下载内容失败: ${e instanceof Error?e.message:String(e)}`})}})}({fileName:i,mimeType:o,bytes:l})).ok){let e=new Blob([l],{type:o||"application/octet-stream"}),t=URL.createObjectURL(e);try{W(t,i)}finally{window.setTimeout(()=>URL.revokeObjectURL(t),1e3)}}}function z({title:e,message:t,confirmLabel:n,cancelLabel:o,destructive:l=!1,busy:s=!1,error:a=null,onConfirm:d,onCancel:c}){return(0,i.useEffect)(()=>{let e=e=>{"Escape"!==e.key||s||c()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[s,c]),(0,r.jsx)("div",{role:"presentation",style:{position:"fixed",inset:0,zIndex:1100,display:"flex",alignItems:"center",justifyContent:"center",padding:16,background:"rgba(0,0,0,0.4)"},onClick:e=>{s||e.target!==e.currentTarget||c()},children:(0,r.jsxs)("div",{role:"dialog","aria-modal":"true","aria-label":e,style:{width:400,maxWidth:"100%",border:"1px solid var(--border)",borderRadius:8,background:"var(--bg-panel)",boxShadow:"0 12px 36px rgba(0,0,0,0.24)",overflow:"hidden"},children:[(0,r.jsxs)("div",{style:{display:"flex",gap:12,padding:"18px 18px 14px"},children:[(0,r.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:l?"#ef4444":"#f59e0b",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{flexShrink:0,marginTop:1},children:[(0,r.jsx)("path",{d:"M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0Z"}),(0,r.jsx)("path",{d:"M12 9v4"}),(0,r.jsx)("path",{d:"M12 17h.01"})]}),(0,r.jsxs)("div",{style:{minWidth:0},children:[(0,r.jsx)("div",{style:{fontSize:15,fontWeight:700,color:"var(--text)"},children:e}),(0,r.jsx)("div",{style:{marginTop:7,fontSize:12,lineHeight:1.6,color:"var(--text-muted)",overflowWrap:"anywhere"},children:t}),a&&(0,r.jsx)("div",{role:"alert",style:{marginTop:10,color:"#ef4444",fontSize:12,lineHeight:1.5,overflowWrap:"anywhere"},children:a})]})]}),(0,r.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,padding:"10px 18px",borderTop:"1px solid var(--border)"},children:[(0,r.jsx)("button",{type:"button",onClick:c,disabled:s,style:{height:32,padding:"0 12px",border:"1px solid var(--border)",borderRadius:5,background:"transparent",color:"var(--text-muted)",cursor:s?"not-allowed":"pointer",fontSize:12},children:o}),(0,r.jsx)("button",{type:"button",onClick:d,disabled:s,style:{height:32,padding:"0 12px",border:l?"1px solid #ef4444":"1px solid var(--accent)",borderRadius:5,background:l?"#ef4444":"var(--accent)",color:"white",cursor:s?"wait":"pointer",opacity:s?.7:1,fontSize:12,fontWeight:600},children:n})]})]})})}async function P(e){let t=T(e),n=await fetch(`/api/files/${t}?type=list`);if(!n.ok){let e=`Failed to load files (HTTP ${n.status})`;try{let t=await n.json();t.error&&(e=t.error)}catch{}throw Error(e)}return((await n.json()).entries??[]).map(t=>({name:t.name,fullPath:L(e,t.name),isDir:t.isDir,size:t.size,children:t.isDir?[]:void 0,loaded:!t.isDir}))}async function N(e){let t=new URLSearchParams({cwd:e}),n=await fetch(`/api/git/status?${t.toString()}`);if(!n.ok)throw Error(`Failed to load Git status (HTTP ${n.status})`);return n.json()}let A={modified:"files.modified",added:"files.added",deleted:"files.deleted",renamed:"files.renamed",untracked:"files.untracked",conflict:"files.conflict"},F={modified:"#d6a84b",added:"#4ade80",deleted:"#f87171",renamed:"#60a5fa",untracked:"#4ade80",conflict:"#f87171"};function D({status:e,t}){return(0,r.jsx)("span",{title:t(A[e.status]),"aria-label":t(A[e.status]),style:{width:14,height:14,flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",color:F[e.status],fontFamily:"var(--font-mono)",fontSize:11,fontWeight:600},children:e.code})}function B({size:e=11}){return(0,r.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"4"}),(0,r.jsx)("path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8"})]})}function H({onClick:e,title:t}){return(0,r.jsx)("button",{type:"button",onClick:e,title:t,"aria-label":t,style:{width:24,height:24,padding:0,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,border:"none",borderRadius:4,background:"none",color:"var(--text-dim)",cursor:"pointer"},onMouseEnter:e=>{e.currentTarget.style.color="var(--text-muted)",e.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-dim)",e.currentTarget.style.background="none"},children:(0,r.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round","aria-hidden":"true",children:[(0,r.jsx)("path",{d:"m6 6 12 12"}),(0,r.jsx)("path",{d:"m18 6-12 12"})]})})}function O({node:e,depth:t,cwd:n,onOpenFile:o,onAtMention:l,expandedPaths:s,onToggleExpanded:a,refreshToken:d,highlightedPaths:c,gitStatusByPath:u,changedDirectoryPaths:p,deletingPaths:h,onDeleteNode:g,t:f}){let x=s.has(e.fullPath),m=c.has(e.fullPath),v=h.has(e.fullPath),y=C(e.fullPath),b=u.get(y),w=e.isDir&&(void 0!==b||p.has(y)),[j,M]=(0,i.useState)(e.children??[]),[L,E]=(0,i.useState)(e.loaded??!1),[W,z]=(0,i.useState)(!1),[N,A]=(0,i.useState)(!1),F=(0,i.useCallback)(async(t=!1)=>{if(!L||t){z(!0);try{let t=await P(e.fullPath);M(t),E(!0)}catch{}finally{z(!1)}}},[L,e.fullPath]);(0,i.useEffect)(()=>{x&&L&&F(!0)},[d]);let H=(0,i.useCallback)(()=>{if(e.isDir){let t=!x;a(e.fullPath,t),t&&!L&&F()}else o(e.fullPath,e.name)},[e.isDir,e.fullPath,e.name,L,x,F,o,a]);return(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{onClick:H,onMouseEnter:()=>A(!0),onMouseLeave:()=>A(!1),style:{position:"relative",display:"flex",alignItems:"center",gap:4,paddingLeft:8+14*t,paddingRight:8,height:24,cursor:"pointer",background:N?"var(--bg-hover)":"transparent",borderRadius:4,userSelect:"none"},children:[e.isDir&&(0,r.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"var(--text-dim)",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,transform:x?"rotate(90deg)":"none",transition:"transform 0.1s"},children:(0,r.jsx)("polyline",{points:"3 2 7 5 3 8"})}),!e.isDir&&(0,r.jsx)("span",{style:{width:10,flexShrink:0}}),(0,r.jsx)("span",{style:{flexShrink:0,display:"flex",alignItems:"center"},children:e.isDir?(0,r.jsx)(k,{size:14,open:x}):S(e.name,14)}),(0,r.jsx)("span",{style:{fontSize:12,color:"var(--text)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1},title:e.fullPath,children:e.name}),m&&(0,r.jsx)("span",{title:f("files.newlyUploaded"),"aria-label":f("files.newlyUploaded"),style:{width:14,height:14,flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center"},children:(0,r.jsx)("span",{style:{width:6,height:6,borderRadius:"50%",background:"#3b82f6"}})}),!N&&!e.isDir&&b&&(0,r.jsx)(D,{status:b,t:f}),!N&&w&&(0,r.jsx)("span",{title:f("files.containsChangedFiles"),"aria-label":f("files.containsChangedFiles"),style:{width:14,height:14,flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center"},children:(0,r.jsx)("span",{style:{width:6,height:6,borderRadius:"50%",background:"#d6a84b"}})}),W&&(0,r.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-dim)",strokeWidth:"2",strokeLinecap:"round",children:(0,r.jsx)("path",{d:"M12 2v4M12 18v4M4.93 4.93l2.83 2.83M16.24 16.24l2.83 2.83M2 12h4M18 12h4"})}),N&&(0,r.jsxs)("div",{style:{position:"absolute",right:4,top:"50%",transform:"translateY(-50%)",display:"flex",alignItems:"center",gap:4,flexShrink:0},children:[l&&(0,r.jsxs)("button",{type:"button",onClick:t=>{t.stopPropagation(),l(I(e.fullPath,n),e.isDir)},title:f("files.insertPath"),style:{display:"flex",alignItems:"center",justifyContent:"center",gap:4,padding:"0 8px",height:20,background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:4,color:"var(--accent)",cursor:"pointer",fontSize:11,fontWeight:600,whiteSpace:"nowrap"},children:[(0,r.jsx)(B,{}),f("files.mention")]}),!e.isDir&&(0,r.jsx)("button",{type:"button",onClick:async t=>{t.stopPropagation();try{await $(`/api/files/${T(e.fullPath)}?type=download`,R(e.fullPath))}catch(t){let e=t instanceof Error?t.message:String(t);window.alert(`下载文件失败: ${e}`)}},title:f("files.download"),style:{display:"flex",alignItems:"center",justifyContent:"center",gap:4,padding:"0 5px",height:20,background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:4,color:"var(--text-muted)",cursor:"pointer",fontSize:11,fontWeight:600,whiteSpace:"nowrap",textDecoration:"none",appearance:"none"},children:(0,r.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),(0,r.jsx)("polyline",{points:"7 10 12 15 17 10"}),(0,r.jsx)("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]})}),(0,r.jsx)("button",{type:"button",onClick:t=>{t.stopPropagation(),g(e)},disabled:v,title:f("files.delete"),"aria-label":f("files.delete"),style:{width:20,height:20,padding:0,display:"flex",alignItems:"center",justifyContent:"center",background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:4,color:"var(--text-muted)",cursor:v?"default":"pointer",flexShrink:0},onMouseEnter:e=>{v||(e.currentTarget.style.color="#f87171")},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-muted)"},children:v?(0,r.jsx)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.4",strokeLinecap:"round",style:{animation:"spin 0.8s linear infinite"},"aria-hidden":"true",children:(0,r.jsx)("path",{d:"M21 12a9 9 0 1 1-5.7-8.4"})}):(0,r.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,r.jsx)("polyline",{points:"3 6 5 6 21 6"}),(0,r.jsx)("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"}),(0,r.jsx)("path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]})})]})]}),e.isDir&&x&&(0,r.jsxs)("div",{children:[j.map(e=>(0,r.jsx)(O,{node:e,depth:t+1,cwd:n,onOpenFile:o,onAtMention:l,expandedPaths:s,onToggleExpanded:a,refreshToken:d,highlightedPaths:c,gitStatusByPath:u,changedDirectoryPaths:p,deletingPaths:h,onDeleteNode:g,t:f},e.fullPath)),0===j.length&&L&&(0,r.jsx)("div",{style:{paddingLeft:8+(t+1)*14,fontSize:11,color:"var(--text-dim)",height:22,display:"flex",alignItems:"center"},children:"empty"})]})]})}function U({status:e,cwd:t,onOpenFile:n,t:o}){let[l,s]=(0,i.useState)(!1),a=R(e.filePath),d=I(e.filePath,t);return(0,r.jsxs)("div",{onClick:()=>n(e.filePath,a,{modeHint:"diff"}),onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),title:e.filePath,style:{display:"flex",alignItems:"center",gap:6,paddingLeft:10,paddingRight:8,height:24,cursor:"pointer",background:l?"var(--bg-hover)":"transparent",borderRadius:4,userSelect:"none"},children:[(0,r.jsx)(D,{status:e,t:o}),(0,r.jsx)("span",{style:{flexShrink:0,display:"flex",alignItems:"center",opacity:.85},children:S(a,13)}),(0,r.jsx)("span",{style:{fontSize:12,color:"var(--text)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1},children:d})]})}let _=(0,i.forwardRef)(function({cwd:e,onOpenFile:t,refreshKey:n,onAtMention:o,onAtMentions:l,onUploadBusyChange:a,changesCollapsed:d,onChangesCountChange:c},u){let{t:p}=(0,v.s)(),[h,g]=(0,i.useState)([]),[f,x]=(0,i.useState)(!0),[m,y]=(0,i.useState)(null),[b,k]=(0,i.useState)(new Set),[w,j]=(0,i.useState)(0),[S,R]=(0,i.useState)(new Set),[E,W]=(0,i.useState)([]),[$,A]=(0,i.useState)({additions:0,deletions:0}),[D,_]=(0,i.useState)("idle"),[q,K]=(0,i.useState)(0),[V,J]=(0,i.useState)(null),[Y,G]=(0,i.useState)(null),[Z,X]=(0,i.useState)(null),[Q,ee]=(0,i.useState)(new Set),[et,en]=(0,i.useState)(null),[er,ei]=(0,i.useState)(!1),[eo,el]=(0,i.useState)(null),es=(0,i.useRef)(null),ea=(0,i.useRef)(null),ed=`${n??0}:${w}`,ec="idle"!==D,eu=(0,i.useMemo)(()=>new Map(E.map(e=>[C(e.filePath),e])),[E]),ep=(0,i.useMemo)(()=>{let t=new Set,n=C(e).replace(/\/$/,"");for(let e of E){let r=M(C(e.filePath));for(;(r===n||r.startsWith(`${n}/`))&&(t.add(r),r!==n);){let e=M(r);if(e===r)break;r=e}}return t},[e,E]),eh=(0,i.useCallback)((e,t)=>{k(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r})},[]),eg=(0,i.useCallback)(e=>{en(e),el(null)},[]),ef=(0,i.useCallback)(async e=>{ei(!0),el(null),ee(t=>new Set(t).add(e.fullPath));try{let t=await fetch(`/api/files/${T(e.fullPath)}`,{method:"DELETE"}),n=await t.json().catch(()=>({}));if(!t.ok)throw Error(n.error??`Delete failed (HTTP ${t.status})`);R(t=>{let n=new Set(t);return n.delete(e.fullPath),n}),en(null),j(e=>e+1)}catch(e){el(e instanceof Error?e.message:String(e))}finally{ei(!1),ee(t=>{let n=new Set(t);return n.delete(e.fullPath),n})}},[]),ex=(0,i.useCallback)(t=>{let n=t.uploaded??[];G({uploaded:n,skipped:t.skipped??[],errors:t.errors??[]}),n.length>0&&(R(new Set(n.map(t=>L(e,t)))),j(e=>e+1))},[e]),em=(0,i.useCallback)(async(t,n)=>{X(null),J(null),K(0),_("uploading");try{let{status:r,data:i}=await new Promise((r,i)=>{let o=new FormData;t.forEach(e=>o.append("files",e,e.name));let l=new XMLHttpRequest;l.open("POST",(0,s.DP)(`/api/files/${T(e)}?type=upload&conflict=${n}`)),l.upload.onprogress=e=>{e.lengthComputable&&e.total>0&&K(Math.round(e.loaded/e.total*100))},l.onerror=()=>i(Error("Network error while uploading files")),l.onabort=()=>i(Error("Upload cancelled")),l.onload=()=>{let e={};try{e=JSON.parse(l.responseText)}catch{l.responseText&&(e.error=l.responseText)}r({status:l.status,data:e})},l.send(o)});if(409===r&&i.conflicts?.length)return void X({files:t,conflicts:i.conflicts,nonReplaceable:i.nonReplaceable??[]});if(r<200||r>=300)throw Error(i.error??`Upload failed (HTTP ${r})`);K(100),ex(i)}catch(e){J(e instanceof Error?e.message:String(e))}finally{_("idle")}},[ex,e]),ev=(0,i.useCallback)(async t=>{if(0!==t.length&&!ec){G(null),R(new Set),X(null),J(null),K(0),_("checking");try{let n=await fetch(`/api/files/${T(e)}?type=upload-check`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({fileNames:t.map(e=>e.name)})}),r=await n.json().catch(()=>({}));if(!n.ok)throw Error(r.error??`Upload check failed (HTTP ${n.status})`);if(r.conflicts?.length)return void X({files:t,conflicts:r.conflicts,nonReplaceable:r.nonReplaceable??[]});await em(t,"error")}catch(e){J(e instanceof Error?e.message:String(e))}finally{_("idle")}}},[e,em,ec]),ey=(0,i.useCallback)(e=>{let t=Array.from(e.target.files??[]);e.target.value="",ev(t)},[ev]);(0,i.useImperativeHandle)(u,()=>({openUploadPicker(){ec||ea.current?.click()}}),[ec]),(0,i.useEffect)(()=>{a?.(ec)},[a,ec]),(0,i.useEffect)(()=>()=>a?.(!1),[a]),(0,i.useEffect)(()=>{let t=es.current!==e;es.current=e,t&&(k(new Set),R(new Set),G(null),X(null),J(null)),x(t),y(null);let n=!1;return P(e).then(e=>{n||g(e)}).catch(e=>{n||y(e instanceof Error?e.message:String(e))}).finally(()=>{n||x(!1)}),()=>{n=!0}},[e,n,w]),(0,i.useEffect)(()=>{let t=!1;return N(e).then(e=>{t||(W(e.isGitRepository?e.files:[]),A(e.isGitRepository?{additions:e.additions,deletions:e.deletions}:{additions:0,deletions:0}))}).catch(()=>{t||(W([]),A({additions:0,deletions:0}))}),()=>{t=!0}},[e,n,w]),(0,i.useEffect)(()=>{c?.(E.length)},[E,c]);let eb=ec||null!==Z||null!==V||null!==Y,ek=(0,i.useCallback)(()=>{Y&&0!==Y.uploaded.length&&l?.(Y.uploaded.map(t=>I(L(e,t),e)))},[e,l,Y]);return(0,r.jsxs)("div",{style:{minHeight:"100%"},children:[(0,r.jsx)("input",{ref:ea,type:"file",multiple:!0,hidden:!0,onChange:ey}),eb&&(0,r.jsxs)("div",{style:{padding:"6px 8px",borderBottom:"1px solid var(--border)"},children:[ec&&(0,r.jsxs)("div",{role:"status","aria-live":"polite","aria-label":"checking"===D?p("files.checking"):p("files.uploading",{progress:q}),children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,minHeight:14,color:"var(--text-muted)"},children:["checking"===D?(0,r.jsx)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",style:{animation:"spin 0.8s linear infinite"},"aria-hidden":"true",children:(0,r.jsx)("path",{d:"M21 12a9 9 0 1 1-5.7-8.4"})}):(0,r.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,r.jsx)("path",{d:"M12 16V4"}),(0,r.jsx)("path",{d:"m7 9 5-5 5 5"}),(0,r.jsx)("path",{d:"M5 20h14"})]}),"uploading"===D&&(0,r.jsxs)("span",{style:{fontSize:10},children:[q,"%"]})]}),"uploading"===D&&(0,r.jsx)("div",{style:{height:3,marginTop:4,overflow:"hidden",borderRadius:2,background:"var(--border)"},children:(0,r.jsx)("div",{style:{width:`${q}%`,height:"100%",background:"var(--text-muted)",transition:"width 120ms ease"}})})]}),Z&&(0,r.jsxs)("div",{role:"alert",style:{padding:7,border:"1px solid color-mix(in srgb, #f59e0b 55%, var(--border))",borderRadius:4,background:"color-mix(in srgb, #f59e0b 9%, var(--bg-panel))"},children:[(0,r.jsx)("div",{style:{fontSize:11,color:"var(--text)",lineHeight:1.35,overflowWrap:"anywhere"},children:p("files.conflictSummary",{count:Z.conflicts.length,countSuffix:1===Z.conflicts.length?"":"s",files:Z.conflicts.join(", ")})}),Z.nonReplaceable.length>0&&(0,r.jsx)("div",{style:{marginTop:3,fontSize:10,color:"#f59e0b",lineHeight:1.35,overflowWrap:"anywhere"},children:p("files.cannotReplace",{files:Z.nonReplaceable.join(", ")})}),(0,r.jsxs)("div",{style:{display:"flex",gap:5,marginTop:7},children:[(0,r.jsx)("button",{type:"button",onClick:()=>void em(Z.files,"overwrite"),style:{height:22,padding:"0 7px",border:"1px solid #ef4444",borderRadius:4,background:"transparent",color:"#ef4444",cursor:"pointer",fontSize:10},children:p("files.replace")}),(0,r.jsx)("button",{type:"button",onClick:()=>void em(Z.files,"skip"),style:{height:22,padding:"0 7px",border:"1px solid var(--border)",borderRadius:4,background:"var(--bg-panel)",color:"var(--text)",cursor:"pointer",fontSize:10},children:p("files.skipExisting")}),(0,r.jsx)("button",{type:"button",onClick:()=>X(null),style:{height:22,padding:"0 7px",border:"none",borderRadius:4,background:"transparent",color:"var(--text-muted)",cursor:"pointer",fontSize:10},children:p("files.cancel")})]})]}),V&&(0,r.jsxs)("div",{role:"alert",style:{display:"flex",alignItems:"flex-start",gap:6,fontSize:11,lineHeight:1.35,color:"#f87171"},children:[(0,r.jsx)("span",{style:{minWidth:0,flex:1,overflowWrap:"anywhere"},children:V}),(0,r.jsx)(H,{onClick:()=>J(null),title:p("files.dismissError")})]}),Y&&(0,r.jsxs)("div",{"aria-live":"polite",children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,minHeight:22,fontSize:11},children:[(0,r.jsxs)("div",{style:{minWidth:0,flex:1,display:"flex",alignItems:"center",gap:8},children:[Y.uploaded.length>0&&(0,r.jsxs)("span",{title:`${Y.uploaded.length} uploaded`,"aria-label":`${Y.uploaded.length} uploaded`,style:{display:"flex",alignItems:"center",gap:3,color:"#22c55e"},children:[(0,r.jsx)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:(0,r.jsx)("path",{d:"m5 12 4 4L19 6"})}),(0,r.jsx)("span",{children:Y.uploaded.length})]}),Y.skipped.length>0&&(0,r.jsxs)("span",{title:`${Y.skipped.length} skipped`,"aria-label":`${Y.skipped.length} skipped`,style:{display:"flex",alignItems:"center",gap:3,color:"var(--text-dim)"},children:[(0,r.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round","aria-hidden":"true",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,r.jsx)("path",{d:"M8 12h8"})]}),(0,r.jsx)("span",{children:Y.skipped.length})]}),Y.errors.length>0&&(0,r.jsxs)("span",{title:`${Y.errors.length} failed`,"aria-label":`${Y.errors.length} failed`,style:{display:"flex",alignItems:"center",gap:3,color:"#f87171"},children:[(0,r.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,r.jsx)("path",{d:"M12 3 2.5 20h19L12 3Z"}),(0,r.jsx)("path",{d:"M12 9v4"}),(0,r.jsx)("path",{d:"M12 17h.01"})]}),(0,r.jsx)("span",{children:Y.errors.length})]})]}),Y.uploaded.length>0&&l&&(0,r.jsxs)("button",{type:"button",onClick:ek,title:1===Y.uploaded.length?p("files.addUploadedFile"):p("files.addAllUploadedFiles"),"aria-label":1===Y.uploaded.length?p("files.addUploadedFile"):p("files.addAllUploadedFiles"),style:{height:22,padding:"0 7px",display:"flex",alignItems:"center",justifyContent:"center",gap:4,flexShrink:0,border:"1px solid var(--border)",borderRadius:4,background:"var(--bg-panel)",color:"var(--accent)",cursor:"pointer",fontSize:11,fontWeight:600,whiteSpace:"nowrap"},children:[(0,r.jsx)(B,{}),p("files.mention")]}),(0,r.jsx)(H,{onClick:()=>G(null),title:p("files.dismissUploadResults")})]}),Y.errors.map(e=>(0,r.jsxs)("div",{title:e.error,style:{display:"flex",alignItems:"center",gap:4,marginTop:3,minWidth:0,fontSize:10,color:"#f87171"},children:[(0,r.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},"aria-hidden":"true",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,r.jsx)("path",{d:"M12 8v5"}),(0,r.jsx)("path",{d:"M12 17h.01"})]}),(0,r.jsx)("span",{style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name})]},e.name))]})]}),!d&&E.length>0&&(0,r.jsxs)("div",{style:{padding:"0 4px 2px"},children:[(0,r.jsxs)("div",{"aria-label":p("files.changeStats",{count:E.length,additions:$.additions,deletions:$.deletions}),style:{display:"flex",alignItems:"center",gap:6,height:24,padding:"0 10px",fontSize:12},children:[(0,r.jsx)("span",{style:{color:"var(--text-dim)"},children:p("files.changedCount",{count:E.length})}),(0,r.jsxs)("span",{style:{color:F.added,fontFamily:"var(--font-mono)"},children:["+",$.additions]}),(0,r.jsxs)("span",{style:{color:F.deleted,fontFamily:"var(--font-mono)"},children:["-",$.deletions]})]}),E.map(n=>(0,r.jsx)(U,{status:n,cwd:e,onOpenFile:t,t:p},n.filePath))]}),(d||0===E.length)&&(0,r.jsxs)("div",{style:{padding:"2px 4px"},children:[f?(0,r.jsx)("div",{style:{padding:"8px 12px",fontSize:11,color:"var(--text-dim)"},children:"Loading files..."}):m?(0,r.jsx)("div",{style:{padding:"8px 12px",fontSize:11,color:"#f87171"},children:m}):h.map(n=>(0,r.jsx)(O,{node:n,depth:0,cwd:e,onOpenFile:t,onAtMention:o,expandedPaths:b,onToggleExpanded:eh,refreshToken:ed,highlightedPaths:S,gitStatusByPath:eu,changedDirectoryPaths:ep,deletingPaths:Q,onDeleteNode:eg,t:p},n.fullPath)),!f&&!m&&0===h.length&&(0,r.jsx)("div",{style:{padding:"8px 12px",fontSize:11,color:"var(--text-dim)"},children:p("files.noFiles")})]}),et&&(0,r.jsx)(z,{title:p("files.delete"),message:et.isDir?p("files.deleteDirConfirm",{name:I(et.fullPath,e)}):p("files.deleteConfirm",{name:I(et.fullPath,e)}),confirmLabel:p("files.deleteAction"),cancelLabel:p("files.cancel"),destructive:!0,busy:er,error:eo,onConfirm:()=>void ef(et),onCancel:()=>{er||(en(null),el(null))}})]})});function q({onClick:e,title:t,disabled:n,skipHover:i,color:o,background:l="none",marginRight:s,ariaPressed:a,children:d}){return(0,r.jsx)("button",{onClick:e,disabled:n,title:t,"aria-label":t,"aria-pressed":a,style:{position:"relative",display:"flex",alignItems:"center",justifyContent:"center",width:26,height:26,padding:0,marginRight:s,background:l,border:"none",color:o,cursor:n?"default":"pointer",borderRadius:5,flexShrink:0,opacity:n?.6:1,transition:"color 0.3s, background 0.3s"},onMouseEnter:e=>{n||i||(e.currentTarget.style.color="var(--text-muted)",e.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:e=>{n||i||(e.currentTarget.style.color=o,e.currentTarget.style.background=l)},children:d})}let K="pi-web:unread-session-ids";function V(e,t){return t&&e.startsWith(t)?"~"+e.slice(t.length):e}function J({text:e,style:t}){return(0,r.jsx)("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",display:"block",minWidth:0,lineHeight:1.35,direction:"rtl",textAlign:"left",...t},children:(0,r.jsx)("span",{style:{unicodeBidi:"plaintext"},children:e})})}function Y({open:e,children:t,style:n}){let[o,l]=(0,i.useState)(e),[s,a]=(0,i.useState)(e);return((0,i.useEffect)(()=>{let t,n;return e?(l(!0),a(!1),t=window.requestAnimationFrame(()=>{t=window.requestAnimationFrame(()=>a(!0))})):(a(!1),n=setTimeout(()=>l(!1),140)),()=>{void 0!==t&&window.cancelAnimationFrame(t),n&&clearTimeout(n)}},[e]),o)?(0,r.jsx)("div",{style:{...n,opacity:+!!s,transform:s?"translateY(0) scale(1)":"translateY(-8px) scale(0.96)",transformOrigin:"top center",transition:"opacity 140ms ease, transform 140ms ease",pointerEvents:e?"auto":"none"},children:t}):null}function G({selectedSessionId:e,onSelectSession:t,onNewSession:n,initialSessionId:o,skipInitialProjectSelection:l,fixedWorkspace:s=!1,fixedWorkspaceRoot:c,onInitialRestoreDone:u,refreshKey:p,onSessionDeleted:h,selectedCwd:g,onCwdChange:f,onOpenFile:y,explorerRefreshKey:b,onExplorerRefresh:k,onAtMention:w,onAtMentions:j,onBackgroundTaskDone:S,onRunningSessionIdsChange:C}){let{t:T}=(0,v.s)(),[R,M]=(0,i.useState)([]),[I,L]=(0,i.useState)(!0),[E,W]=(0,i.useState)(null),[$,z]=(0,i.useState)(null),[P,N]=(0,i.useState)(""),[A,F]=(0,i.useState)(""),[D,B]=(0,i.useState)(null),[H,O]=(0,i.useState)(!1),[U,X]=(0,i.useState)(!1),[Q,ee]=(0,i.useState)(""),[et,en]=(0,i.useState)(null),[er,ei]=(0,i.useState)(!1),[eo,el]=(0,i.useState)(null),[es,ea]=(0,i.useState)(null),ed=(0,i.useRef)(null),ec=(0,i.useRef)(null),[eu,ep]=(0,i.useState)(!0),[eh,eg]=(0,i.useState)(0),[ef,ex]=(0,i.useState)(!1),[em,ev]=(0,i.useState)(0),[ey,eb]=(0,i.useState)(!0),[ek,ew]=(0,i.useState)(!1),[ej,eS]=(0,i.useState)(!1),[eC,eT]=(0,i.useState)(()=>new Set),[eR,eM]=(0,i.useState)(()=>(function(){try{let e=window.localStorage.getItem(K);if(!e)return new Set;let t=JSON.parse(e);if(Array.isArray(t))return new Set(t.filter(e=>"string"==typeof e));return new Set}catch{return new Set}})()),eI=(0,i.useRef)(new Set),eL=(0,i.useRef)(!1),eE=(0,i.useRef)(null),eW=(0,i.useRef)(null),e$=(0,i.useRef)(null),ez=(0,i.useCallback)(async(e=!1,t=!1)=>{try{e&&L(!0);let n=await fetch(t?"/api/sessions?force=1":"/api/sessions",{cache:"no-store"});if(!n.ok)throw Error(`HTTP ${n.status}`);let r=await n.json();M(r.sessions),eL.current||eT(new Set(r.runningSessionIds??[]));let i=new Set(r.sessions.map(e=>e.id));eM(e=>{if(0===e.size)return e;let t=new Set([...e].filter(e=>i.has(e)));return t.size===e.size?e:t}),W(null),e||(ew(!0),eE.current&&clearTimeout(eE.current),eE.current=setTimeout(()=>ew(!1),2e3))}catch(e){W(String(e))}finally{e&&L(!1)}},[]),eP=(0,i.useRef)(!1);(0,i.useEffect)(()=>{let e=!eP.current;eP.current=!0,ez(e,!e)},[ez,p]),(0,i.useEffect)(()=>{ep(function(e=d()){if(!e)return!0;try{return"false"!==e.getItem(a)}catch{return!0}}())},[]),(0,i.useEffect)(()=>{try{0===eR.size?window.localStorage.removeItem(K):window.localStorage.setItem(K,JSON.stringify([...eR]))}catch{}},[eR]),(0,i.useEffect)(()=>{let e=!1,t=null,n=null,r=()=>{t&&clearTimeout(t),t=null},i=async()=>{if(e||"visible"!==document.visibilityState)return;let o=new AbortController;n?.abort(),n=o;try{let t=await fetch("/api/agent/running",{cache:"no-store",signal:o.signal});if(!t.ok)return;let r=await t.json();if(e||n!==o)return;eL.current=!0,eT(new Set(r.runningSessionIds??[]))}catch{}finally{n===o&&(n=null),r(),e||"visible"!==document.visibilityState||(t=setTimeout(()=>void i(),2500))}},o=()=>{"visible"===document.visibilityState?i():(r(),n?.abort(),n=null)};return i(),document.addEventListener("visibilitychange",o),()=>{e=!0,r(),n?.abort(),document.removeEventListener("visibilitychange",o)}},[]),(0,i.useEffect)(()=>{C?.(eC)},[C,eC]),(0,i.useEffect)(()=>{let t=eI.current,n=[...t].filter(t=>!eC.has(t)&&t!==e),r=[...eC].filter(e=>!t.has(e));(n.length>0||r.length>0)&&eM(e=>{let t=new Set(e);return eC.forEach(e=>t.delete(e)),n.forEach(e=>t.add(e)),t});let i=r.some(e=>!R.some(t=>t.id===e));(n.length>0||i)&&ez(!1,!0),n.length>0&&S?.(),eI.current=eC},[eC,e,R,ez,S]),(0,i.useEffect)(()=>{e&&eM(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n})},[e]),(0,i.useEffect)(()=>{void 0!==b&&eg(e=>e+1)},[b]),(0,i.useEffect)(()=>{fetch("/api/home").then(e=>e.json()).then(e=>{e.home&&N(e.home)}).catch(()=>{})},[]);let eN=(0,i.useRef)(!1),eA=(0,i.useCallback)((e,t)=>({root:e,key:t}),[]),eF=(0,i.useCallback)(e=>{if(!e)return null;if(D&&D.forCwd===e||D?.worktrees.some(t=>t.path===e))return eA(D.projectRoot,D.projectKey);let t=R.find(t=>t.cwd===e||(t.projectRoot??t.cwd)===e);return t?eA(t.projectRoot??t.cwd,x(t)):eA(e,e)},[D,R,eA]),eD=(0,i.useRef)(null);(0,i.useEffect)(()=>{let e=eF($),t=eD.current;(t?.cwd!==$||t.key!==(e?.key??null))&&(eD.current={cwd:$,key:e?.key??null},f?.($,e?.root??null,e?.key??null))},[$,f,eF]);let eB=(0,i.useRef)(null);(0,i.useEffect)(()=>{g&&g!==eB.current&&(eB.current=g,z(g))},[g]);let[eH,eO]=(0,i.useState)(0);(0,i.useLayoutEffect)(()=>{if(!$){B(null),ea(null);return}let e=!1;return ea($),fetch(`/api/worktrees?cwd=${encodeURIComponent($)}`).then(e=>e.json()).then(t=>{if(!e){if(ea(null),t.error||!t.projectRoot)return void B(null);B({forCwd:$,projectRoot:t.projectRoot,projectKey:t.projectKey??t.projectRoot,isGit:t.isGit??!1,isTopLevel:t.isTopLevel??!1,currentWorktreePath:t.currentWorktreePath??null,worktrees:t.worktrees??[]})}}).catch(()=>{e||(ea(null),B(null))}),()=>{e=!0}},[$,eH,p]),(0,i.useEffect)(()=>{if(0!==R.length&&!l){if(s){if(!c)return;if(o&&!eN.current){eN.current=!0;let e=eF(c);if(!e)return;let n=m(R,e.key).find(e=>e.id===o);if(n){z(n.cwd),t(n,!0);return}u?.()}return}if(null===$){if(o&&!eN.current){eN.current=!0;let e=R.find(e=>e.id===o);if(e){z(e.cwd),t(e,!0);return}u?.()}let e=function(e){let t=new Map;for(let n of e){let e=n.projectRoot??n.cwd;if(!e)continue;let r=x(n),i=t.get(r);(!i||n.modified>i.modified)&&t.set(r,{root:e,modified:n.modified})}return[...t.entries()].sort((e,t)=>t[1].modified.localeCompare(e[1].modified)).map(([e,{root:t}])=>({key:e,root:t}))}(R);e.length>0&&z(e[0].root)}}},[R,$,o,l,s,c,t,u,eF]);let eU=D?D.worktrees.find(e=>e.path===$)??(D.forCwd===$&&D.currentWorktreePath?D.worktrees.find(e=>e.path===D.currentWorktreePath):void 0)??D.worktrees.find(e=>e.isMain):void 0,e_=eU?.path??null,eq=(0,i.useCallback)(async()=>{let e=Q.trim();if(e&&!er&&D){ei(!0),en(null);try{let t=await fetch("/api/worktrees",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:D.projectRoot,branch:e})}),n=await t.json().catch(()=>({}));if(!t.ok||n.error||!n.path)return void en(n.error??`HTTP ${t.status}`);X(!1),ee(""),O(!1),B(t=>t?{...t,forCwd:n.path,currentWorktreePath:n.path,worktrees:[...t.worktrees,{path:n.path,branch:e,isMain:!1}]}:t),z(n.path),eO(e=>e+1)}catch(e){en(e instanceof Error?e.message:String(e))}finally{ei(!1)}}},[Q,er,D]),eK=(0,i.useCallback)(async(e,t)=>{if(D&&!er){ei(!0),en(null);try{let n=await fetch("/api/worktrees",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:D.projectRoot,path:e,force:t})}),r=await n.json().catch(()=>({}));if(!n.ok){if(r.dirty&&!t)return void el(e);en(r.error??`HTTP ${n.status}`);return}el(null),e_===e&&z(D.projectRoot),eO(e=>e+1)}catch(e){en(e instanceof Error?e.message:String(e))}finally{ei(!1)}}},[D,er,e_]);(0,i.useEffect)(()=>{let e=e=>{ed.current&&!ed.current.contains(e.target)&&(O(!1),X(!1),ee(""),en(null),el(null),F(""))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);let eV=(0,i.useCallback)(e=>{e.cwd&&z(e.cwd),t(e)},[t]),eJ=(0,i.useCallback)(()=>{if(!$)return;let e="function"==typeof crypto.randomUUID?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}-${Math.random().toString(36).slice(2)}`;n?.(e,$)},[$,n]),eY=eF($),eG=eY?m(R,eY.key):R,eZ=!!(D?.isGit&&D.isTopLevel&&$&&eY?.key===D.projectKey),eX=!s&&$&&D&&eY?.key===D.projectKey&&!eZ?D.isGit?{label:T("sidebar.openRepoRoot"),title:T("sidebar.openRepoRootTitle")}:{label:T("sidebar.gitRepoRootOnly"),title:T("sidebar.gitRepoRootOnlyTitle")}:null,eQ=!!($&&es===$),e0=s?null:eX??(eQ&&!eZ?{label:T("sidebar.worktrees"),title:T("sidebar.checkingWorktrees")}:null),e1=function(e){let t=new Map;for(let n of e)t.set(n.id,{session:n,children:[]});let n=new Map;for(let t of e)t.parentSessionId&&n.set(t.id,t.parentSessionId);let r=[];for(let e of t.values()){let i=function(e){let r=n.get(e),i=new Set;for(;r&&!i.has(r);){if(i.add(r),t.has(r))return r;r=n.get(r)}return null}(e.session.id);i?t.get(i).children.push(e):r.push(e)}let i=e=>{e.sort((e,t)=>t.session.modified.localeCompare(e.session.modified)),e.forEach(e=>i(e.children))};return i(r),r}(eG);return(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"},children:[(0,r.jsxs)("div",{style:{padding:"12px 10px 10px",borderBottom:"1px solid var(--border)",flexShrink:0},children:[(0,r.jsx)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:10},children:(0,r.jsxs)("div",{style:{display:"flex",gap:6},children:[(0,r.jsxs)("button",{onClick:eJ,disabled:!$,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:5,background:"var(--bg-hover)",border:"1px solid var(--border)",color:$?"var(--text-muted)":"var(--text-dim)",cursor:$?"pointer":"not-allowed",height:32,paddingLeft:10,paddingRight:12,borderRadius:7,fontSize:12,fontWeight:500,letterSpacing:"-0.01em",flexShrink:0,transition:"background 0.12s, color 0.12s, border-color 0.12s"},title:$?T("sidebar.newSessionTitle",{path:$}):T("sidebar.selectProject"),onMouseEnter:e=>{$&&(e.currentTarget.style.background="var(--bg-selected)",e.currentTarget.style.color="var(--accent)",e.currentTarget.style.borderColor="rgba(37,99,235,0.35)")},onMouseLeave:e=>{e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color=$?"var(--text-muted)":"var(--text-dim)",e.currentTarget.style.borderColor="var(--border)"},children:[(0,r.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",children:[(0,r.jsx)("line",{x1:"6",y1:"1",x2:"6",y2:"11"}),(0,r.jsx)("line",{x1:"1",y1:"6",x2:"11",y2:"6"})]}),T("sidebar.new")]}),(0,r.jsx)("button",{onClick:()=>ez(!1,!0),style:{display:"flex",alignItems:"center",justifyContent:"center",background:ek?"rgba(74,222,128,0.18)":"var(--bg-hover)",border:`1px solid ${ek?"rgba(74,222,128,0.4)":"var(--border)"}`,color:ek?"#4ade80":"var(--text-muted)",cursor:"pointer",width:32,height:32,borderRadius:7,padding:0,flexShrink:0,transition:"background 0.3s, color 0.3s, border-color 0.3s"},onMouseEnter:e=>{ek||(e.currentTarget.style.background="var(--bg-selected)",e.currentTarget.style.color="var(--accent)",e.currentTarget.style.borderColor="rgba(37,99,235,0.35)")},onMouseLeave:e=>{ek||(e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color="var(--text-muted)",e.currentTarget.style.borderColor="var(--border)")},title:T("sidebar.refresh"),children:ek?(0,r.jsx)("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"#4ade80",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:(0,r.jsx)("polyline",{points:"20 6 9 17 4 12"})}):(0,r.jsxs)("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}),(0,r.jsx)("path",{d:"M3 3v5h5"})]})})]})}),!s&&eZ&&(()=>{if(!D)return null;let e=D.worktrees.length>=8,t=e&&A.trim()?D.worktrees.filter(e=>(e.branch??V(e.path,P)).toLowerCase().includes(A.trim().toLowerCase())):D.worktrees;return(0,r.jsxs)("div",{ref:ed,style:{position:"relative",marginTop:6},children:[(0,r.jsxs)("button",{onClick:()=>O(e=>!e),title:eU?T("sidebar.switchWorktreeTitle",{path:eU.path}):T("sidebar.switchWorktree"),style:{width:"100%",height:29,boxSizing:"border-box",display:"flex",alignItems:"center",gap:6,padding:"0 10px",background:"var(--bg-hover)",border:"1px solid var(--border)",borderRadius:7,cursor:"pointer",fontSize:11,lineHeight:1.35,color:"var(--text-muted)",textAlign:"left"},children:[(0,r.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,color:eU&&!eU.isMain?"var(--accent)":"var(--text-dim)"},children:[(0,r.jsx)("line",{x1:"6",y1:"3",x2:"6",y2:"15"}),(0,r.jsx)("circle",{cx:"18",cy:"6",r:"3"}),(0,r.jsx)("circle",{cx:"6",cy:"18",r:"3"}),(0,r.jsx)("path",{d:"M18 9a9 9 0 0 1-9 9"})]}),(0,r.jsx)(J,{text:eU?eU.branch??V(eU.path,P):"…",style:{flex:1,fontFamily:"var(--font-mono)",color:"var(--text)"}}),eU?.isMain&&(0,r.jsx)("span",{style:{flexShrink:0,color:"var(--text-dim)",fontSize:10},children:T("sidebar.main")}),D.worktrees.length>1&&(0,r.jsx)("span",{style:{flexShrink:0,color:"var(--text-dim)",fontSize:10},children:D.worktrees.length}),(0,r.jsx)("svg",{width:"9",height:"9",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:(0,r.jsx)("polyline",{points:"2 3.5 5 6.5 8 3.5"})})]}),(0,r.jsxs)(Y,{open:H,style:{position:"absolute",top:"calc(100% + 4px)",left:0,right:0,zIndex:100,background:"var(--bg)",border:"1px solid var(--border)",borderRadius:8,boxShadow:"0 6px 20px rgba(0,0,0,0.10)",overflow:"hidden"},children:[e&&(0,r.jsx)("div",{style:{padding:"6px 8px",borderBottom:"1px solid var(--border)"},children:(0,r.jsx)("input",{value:A,onChange:e=>F(e.target.value),onKeyDown:e=>{"Escape"===e.key&&(F(""),O(!1))},placeholder:T("sidebar.filterWorktrees"),autoFocus:!0,style:{width:"100%",fontSize:11,fontFamily:"var(--font-mono)",padding:"5px 8px",border:"1px solid var(--border)",borderRadius:5,outline:"none",background:"var(--bg)",color:"var(--text)",boxSizing:"border-box"}})}),(0,r.jsxs)("div",{style:{maxHeight:"min(40vh, 300px)",overflowY:"auto"},children:[t.map(e=>{let t=e.path===e_;return eo===e.path?(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"7px 10px",borderBottom:"1px solid var(--border)",background:"rgba(239,68,68,0.06)"},children:[(0,r.jsx)("span",{style:{flex:1,fontSize:11,color:"var(--text)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:T("sidebar.forceRemoveCheckout")}),(0,r.jsx)("button",{onClick:()=>void eK(e.path,!0),disabled:er,style:{padding:"3px 9px",background:"#ef4444",border:"none",borderRadius:5,color:"#fff",fontSize:11,fontWeight:600,cursor:"pointer",flexShrink:0},children:T("sidebar.force")}),(0,r.jsx)("button",{onClick:()=>el(null),style:{padding:"3px 9px",background:"var(--bg-hover)",border:"1px solid var(--border)",borderRadius:5,color:"var(--text-muted)",fontSize:11,cursor:"pointer",flexShrink:0},children:T("sidebar.cancel")})]},e.path):(0,r.jsxs)("div",{className:"wt-row",style:{display:"flex",alignItems:"center",borderBottom:"1px solid var(--border)"},children:[(0,r.jsxs)("button",{onClick:()=>{z(e.path),O(!1),en(null),F("")},title:e.path,style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:7,padding:"8px 10px",background:"var(--bg)",border:"none",color:t?"var(--text)":"var(--text-muted)",cursor:"pointer",textAlign:"left",fontSize:11,fontFamily:"var(--font-mono)"},children:[t?(0,r.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"var(--accent)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:(0,r.jsx)("polyline",{points:"1.5 5 4 7.5 8.5 2.5"})}):(0,r.jsx)("span",{style:{width:10,flexShrink:0}}),(0,r.jsx)(J,{text:e.branch??V(e.path,P),style:{flex:1}}),e.isMain&&(0,r.jsx)("span",{style:{flexShrink:0,color:"var(--text-dim)",fontSize:10},children:T("sidebar.main")})]}),!e.isMain&&(0,r.jsx)("button",{onClick:()=>void eK(e.path,!1),disabled:er,title:T("sidebar.removeWorktreeTitle",{path:e.path}),style:{display:"flex",alignItems:"center",justifyContent:"center",width:34,height:28,padding:0,marginRight:4,background:"none",border:"none",color:"var(--text-dim)",cursor:"pointer",borderRadius:5,flexShrink:0,transition:"color 0.12s, background 0.12s"},onMouseEnter:e=>{e.currentTarget.style.color="#ef4444",e.currentTarget.style.background="rgba(239,68,68,0.08)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-dim)",e.currentTarget.style.background="none"},children:(0,r.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("polyline",{points:"3 6 5 6 21 6"}),(0,r.jsx)("path",{d:"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"}),(0,r.jsx)("path",{d:"M10 11v6M14 11v6"}),(0,r.jsx)("path",{d:"M9 6V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2"})]})})]},e.path)}),e&&0===t.length&&A.trim()&&(0,r.jsx)("div",{style:{padding:"8px 10px",fontSize:11,color:"var(--text-dim)"},children:T("sidebar.noMatchingWorktrees")})]}),U?(0,r.jsxs)("div",{style:{padding:"6px 8px"},children:[(0,r.jsx)("input",{ref:ec,value:Q,onChange:e=>{ee(e.target.value),en(null)},onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),eq()),"Escape"===e.key&&(X(!1),ee(""),en(null))},placeholder:T("sidebar.branchName"),style:{width:"100%",fontSize:11,fontFamily:"var(--font-mono)",padding:"5px 8px",border:"1px solid var(--accent)",borderRadius:5,outline:"none",background:"var(--bg)",color:"var(--text)",boxSizing:"border-box"}}),(0,r.jsxs)("div",{style:{display:"flex",gap:5,marginTop:5},children:[(0,r.jsx)("button",{onClick:()=>void eq(),disabled:er||!Q.trim(),style:{flex:1,padding:"4px 0",background:"var(--accent)",border:"none",borderRadius:5,color:"#fff",fontSize:11,fontWeight:600,cursor:er||!Q.trim()?"not-allowed":"pointer",opacity:er||!Q.trim()?.65:1},children:er?T("sidebar.creating"):T("sidebar.create")}),(0,r.jsx)("button",{onClick:()=>{X(!1),ee(""),en(null)},style:{flex:1,padding:"4px 0",background:"var(--bg-hover)",border:"1px solid var(--border)",borderRadius:5,color:"var(--text-muted)",fontSize:11,cursor:"pointer"},children:T("sidebar.cancel")})]})]}):(0,r.jsxs)("button",{onClick:e=>{e.stopPropagation(),X(!0),en(null),setTimeout(()=>ec.current?.focus(),0)},title:T("sidebar.createWorktreeTitle"),style:{display:"flex",alignItems:"center",gap:7,width:"100%",padding:"8px 10px",background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",textAlign:"left",fontSize:11},children:[(0,r.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.1",strokeLinecap:"round",style:{flexShrink:0},children:[(0,r.jsx)("line",{x1:"5",y1:"1",x2:"5",y2:"9"}),(0,r.jsx)("line",{x1:"1",y1:"5",x2:"9",y2:"5"})]}),(0,r.jsx)("span",{children:T("sidebar.newWorktree")})]}),et&&(0,r.jsx)("div",{style:{padding:"5px 10px 8px",color:"#dc2626",fontSize:11,lineHeight:1.35,overflowWrap:"anywhere"},children:et})]})]})})(),e0&&(0,r.jsxs)("button",{type:"button","aria-disabled":"true",tabIndex:-1,title:e0.title,style:{width:"100%",height:29,boxSizing:"border-box",marginTop:6,display:"flex",alignItems:"center",gap:6,padding:"0 10px",border:"1px solid var(--border)",borderRadius:7,background:"var(--bg-hover)",color:"var(--text-dim)",fontSize:11,lineHeight:1.35,whiteSpace:"nowrap",textAlign:"left",cursor:"default",opacity:.82},children:[(0,r.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[(0,r.jsx)("line",{x1:"6",y1:"3",x2:"6",y2:"15"}),(0,r.jsx)("circle",{cx:"18",cy:"6",r:"3"}),(0,r.jsx)("circle",{cx:"6",cy:"18",r:"3"}),(0,r.jsx)("path",{d:"M18 9a9 9 0 0 1-9 9"})]}),(0,r.jsx)("span",{style:{overflow:"hidden",textOverflow:"ellipsis"},children:e0.label})]})]}),(0,r.jsxs)("div",{style:{flex:eu&&(g||$)?"1 1 0":"1 1 auto",overflowY:"auto",padding:"0",minHeight:80},children:[I&&(0,r.jsx)("div",{style:{padding:"16px 14px",color:"var(--text-muted)",fontSize:12},children:T("sidebar.loading")}),E&&(0,r.jsx)("div",{style:{padding:"12px 14px",color:"#f87171",fontSize:12},children:E}),!I&&!E&&0===eG.length&&(0,r.jsx)("div",{style:{padding:"16px 14px",color:"var(--text-muted)",fontSize:12},children:T("sidebar.noSessions")}),e1.map(t=>(0,r.jsx)(Z,{node:t,selectedSessionId:e,runningSessionIds:eC,unreadSessionIds:eR,onSelectSession:eV,onRenamed:ez,onSessionDeleted:e=>{h?.(e),ez()},depth:0},t.session.id))]}),(g||$)&&(0,r.jsxs)("div",{style:{borderTop:"1px solid var(--border)",display:"flex",flexDirection:"column",flex:eu?"1 1 0":"0 0 auto",minHeight:0,overflow:"hidden"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",flexShrink:0},children:[(0,r.jsxs)("button",{onClick:()=>ep(e=>{let t=!e;return!function(e,t=d()){if(t)try{t.setItem(a,String(e))}catch{}}(t),t}),style:{display:"flex",alignItems:"center",gap:6,flex:1,padding:"6px 10px",background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",fontSize:11,fontWeight:600,letterSpacing:"0.05em",textTransform:"uppercase",textAlign:"left"},children:[(0,r.jsx)("svg",{width:"9",height:"9",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",style:{transform:eu?"rotate(90deg)":"none",transition:"transform 0.15s",flexShrink:0},children:(0,r.jsx)("polyline",{points:"3 2 7 5 3 8"})}),T("files.explorer")]}),eu&&em>0&&(0,r.jsx)(q,{onClick:()=>eb(e=>!e),title:T("sidebar.changedFiles",{count:em}),ariaPressed:!ey,color:ey?"var(--text-dim)":"var(--accent)",background:ey?"none":"var(--bg-selected)",children:(0,r.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"3"}),(0,r.jsx)("path",{d:"M3 12h6"}),(0,r.jsx)("path",{d:"M15 12h6"})]})}),eu&&(0,r.jsx)(q,{onClick:()=>e$.current?.openUploadPicker(),disabled:ef,title:T("sidebar.uploadFilesTitle"),color:"var(--text-dim)",children:(0,r.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,r.jsx)("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),(0,r.jsx)("path",{d:"m17 8-5-5-5 5"}),(0,r.jsx)("path",{d:"M12 3v12"})]})}),(0,r.jsx)(q,{onClick:()=>{k?k():eg(e=>e+1),eS(!0),eW.current&&clearTimeout(eW.current),eW.current=setTimeout(()=>eS(!1),2e3)},title:T("sidebar.refreshExplorer"),skipHover:ej,color:ej?"#4ade80":"var(--text-dim)",background:ej?"rgba(74,222,128,0.18)":"none",marginRight:6,children:ej?(0,r.jsx)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"#4ade80",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:(0,r.jsx)("polyline",{points:"20 6 9 17 4 12"})}):(0,r.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}),(0,r.jsx)("path",{d:"M3 3v5h5"})]})})]}),eu&&(0,r.jsx)("div",{style:{flex:1,overflowY:"auto",overflowX:"hidden"},children:(0,r.jsx)(_,{ref:e$,cwd:$??g,onOpenFile:y??(()=>{}),refreshKey:eh,onAtMention:w,onAtMentions:j,onUploadBusyChange:ex,changesCollapsed:ey,onChangesCountChange:ev})})]})]})}function Z({node:e,selectedSessionId:t,runningSessionIds:n,unreadSessionIds:o,onSelectSession:l,onRenamed:s,onSessionDeleted:a,depth:d}){let[c,u]=(0,i.useState)(!1),p=e.children.length>0;return(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{style:{position:"relative"},children:[d>0&&(0,r.jsx)("div",{style:{position:"absolute",left:12*d+6,top:0,bottom:0,width:1,background:"var(--border)",pointerEvents:"none"}}),(0,r.jsx)(ee,{session:e.session,isSelected:e.session.id===t,isRunning:n.has(e.session.id),isUnread:o.has(e.session.id),onClick:()=>l(e.session),onRenamed:s,onDeleted:e=>a?.(e),depth:d,hasChildren:p,collapsed:c,onToggleCollapse:()=>u(e=>!e)})]}),p&&!c&&(0,r.jsx)("div",{children:e.children.map(e=>(0,r.jsx)(Z,{node:e,selectedSessionId:t,runningSessionIds:n,unreadSessionIds:o,onSelectSession:l,onRenamed:s,onSessionDeleted:a,depth:d+1},e.session.id))})]})}function X(){let{t:e}=(0,v.s)();return(0,r.jsx)("span",{title:e("sidebar.agentRunning"),"aria-label":e("sidebar.agentRunning"),style:{width:14,height:14,display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,color:"var(--accent)"},children:(0,r.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",style:{display:"block"},children:(0,r.jsxs)("g",{children:[(0,r.jsx)("path",{d:"M21 12a9 9 0 1 1-3.8-7.4",stroke:"currentColor",strokeWidth:"2.8",strokeLinecap:"round"}),(0,r.jsx)("animateTransform",{attributeName:"transform",type:"rotate",from:"0 12 12",to:"360 12 12",dur:"0.9s",repeatCount:"indefinite"})]})})})}function Q(){let{t:e}=(0,v.s)();return(0,r.jsx)("span",{title:e("sidebar.newActivity"),"aria-label":e("sidebar.newSessionActivity"),style:{width:14,height:14,display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,color:"#0891b2"},children:(0,r.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",style:{display:"block"},children:[(0,r.jsx)("circle",{cx:"7",cy:"7",r:"2.5",fill:"currentColor"}),(0,r.jsxs)("circle",{cx:"7",cy:"7",r:"3",stroke:"currentColor",strokeWidth:"1.4",opacity:"0.32",children:[(0,r.jsx)("animate",{attributeName:"r",values:"3;6;3",dur:"1.6s",repeatCount:"indefinite"}),(0,r.jsx)("animate",{attributeName:"opacity",values:"0.32;0;0.32",dur:"1.6s",repeatCount:"indefinite"})]})]})})}function ee({session:e,isSelected:t,isRunning:n,isUnread:o,onClick:l,onRenamed:s,onDeleted:a,depth:d=0,hasChildren:c=!1,collapsed:p=!1,onToggleCollapse:h}){let g,f,x,m,y,{t:b}=(0,v.s)(),[k,w]=(0,i.useState)(!1),[j,S]=(0,i.useState)(!1),[C,T]=(0,i.useState)(""),[R,M]=(0,i.useState)(!1),[I,L]=(0,i.useState)(!1),E=(0,i.useRef)(null);(0,i.useEffect)(()=>{if(j){let e=requestAnimationFrame(()=>E.current?.select());return()=>cancelAnimationFrame(e)}},[j]);let W=u(e.firstMessage)??e.firstMessage,$=e.name||W.slice(0,50)||e.id.slice(0,12),z=(0,i.useCallback)(t=>{t.stopPropagation(),e.transient||(T(e.name||W.slice(0,50)||e.id.slice(0,12)),S(!0))},[e.name,e.transient,W,e.id]),P=(0,i.useCallback)(async()=>{let t=C.trim();if(S(!1),C!==$&&t!==(e.name??""))try{await fetch(`/api/sessions/${encodeURIComponent(e.id)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:t})}),s?.()}catch{}},[C,e.id,e.name,s,$]),N=(0,i.useCallback)(async()=>{if(!e.transient){M(!1),L(!0);try{await fetch(`/api/sessions/${encodeURIComponent(e.id)}`,{method:"DELETE"}),a?.(e.id)}catch{L(!1)}}},[e.id,e.transient,a]),A=(0,i.useCallback)(e=>{e.stopPropagation(),e.shiftKey?N():M(!0)},[N]),F=(0,i.useCallback)(e=>{e.stopPropagation(),N()},[N]),D=(0,i.useCallback)(e=>{e.stopPropagation(),M(!1)},[]),B=(0,i.useCallback)(t=>{(function(e,t=window){let n=new CustomEvent("pi-web:session-row-contextmenu",{cancelable:!0,detail:e});return!t.dispatchEvent(n)})({id:e.id,path:e.path,cwd:e.cwd,name:e.name,clientX:t.clientX,clientY:t.clientY,refresh:()=>{s?.()}})&&(t.preventDefault(),t.stopPropagation())},[s,e.cwd,e.id,e.name,e.path]);return(0,r.jsx)("div",{onClick:R||j?void 0:l,onContextMenu:R||j?void 0:B,onMouseEnter:()=>w(!0),onMouseLeave:()=>{w(!1)},style:{height:54,display:"flex",alignItems:"center",paddingLeft:d>0?12*d+14:14,paddingRight:8,cursor:R||j?"default":"pointer",background:R?"rgba(239,68,68,0.06)":t?"var(--bg-selected)":k?"var(--bg-hover)":"transparent",borderLeft:R?"2px solid #ef4444":t?"2px solid var(--accent)":"2px solid transparent",transition:"background 0.1s",opacity:I?.5:1,gap:6,overflow:"hidden"},children:R?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{style:{flex:1,minWidth:0,fontSize:12,color:"var(--text)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:b("sidebar.deleteSession",{title:$.slice(0,22)+($.length>22?"…":"")})}),(0,r.jsxs)("div",{style:{display:"flex",gap:5,flexShrink:0},children:[(0,r.jsxs)("button",{onClick:F,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:4,height:30,padding:"0 11px",background:"#ef4444",border:"none",borderRadius:6,color:"#fff",cursor:"pointer",fontSize:12,fontWeight:600,whiteSpace:"nowrap"},children:[(0,r.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("polyline",{points:"3 6 5 6 21 6"}),(0,r.jsx)("path",{d:"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"}),(0,r.jsx)("path",{d:"M10 11v6M14 11v6"}),(0,r.jsx)("path",{d:"M9 6V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2"})]}),b("sidebar.delete")]}),(0,r.jsx)("button",{onClick:D,style:{display:"flex",alignItems:"center",justifyContent:"center",height:30,padding:"0 11px",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:6,color:"var(--text-muted)",cursor:"pointer",fontSize:12,fontWeight:500,whiteSpace:"nowrap"},children:b("sidebar.cancel")})]})]}):j?(0,r.jsx)("input",{ref:E,value:C,onChange:e=>T(e.target.value),onBlur:P,onKeyDown:e=>{"Enter"===e.key&&P(),"Escape"===e.key&&S(!1)},autoFocus:!0,style:{flex:1,fontSize:12,padding:"5px 8px",border:"1px solid var(--accent)",borderRadius:5,outline:"none",background:"var(--bg)",color:"var(--text)",height:30}}):(0,r.jsxs)(r.Fragment,{children:[d>0&&(0,r.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-dim)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[(0,r.jsx)("line",{x1:"6",y1:"3",x2:"6",y2:"15"}),(0,r.jsx)("circle",{cx:"18",cy:"6",r:"3"}),(0,r.jsx)("circle",{cx:"6",cy:"18",r:"3"}),(0,r.jsx)("path",{d:"M18 9a9 9 0 0 1-9 9"})]}),(0,r.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,r.jsx)("div",{style:{display:"flex",alignItems:"center",gap:5,minWidth:0,fontSize:12,fontWeight:t?500:400,lineHeight:1.4,color:"var(--text)"},title:$,children:(0,r.jsx)("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0},children:$})}),(0,r.jsxs)("div",{style:{marginTop:2,display:"flex",alignItems:"center",gap:8,color:"var(--text-dim)",fontSize:11,minWidth:0},children:[n?(0,r.jsx)(X,{}):o?(0,r.jsx)(Q,{}):(0,r.jsx)("span",{title:e.modified,children:(g=new Date(e.modified),x=Math.floor((f=new Date().getTime()-g.getTime())/6e4),m=Math.floor(f/36e5),y=Math.floor(f/864e5),x<1?"just now":x<60?`${x}m ago`:m<24?`${m}h ago`:y<7?`${y}d ago`:g.toLocaleDateString())}),(0,r.jsx)("span",{children:b("sidebar.messagesCount",{count:e.messageCount})}),e.worktreeBranch&&(0,r.jsxs)("span",{title:`Worktree: ${e.cwd}`,style:{display:"flex",alignItems:"center",gap:3,color:"var(--accent)",minWidth:0,overflow:"hidden"},children:[(0,r.jsxs)("svg",{width:"9",height:"9",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.4",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[(0,r.jsx)("line",{x1:"6",y1:"3",x2:"6",y2:"15"}),(0,r.jsx)("circle",{cx:"18",cy:"6",r:"3"}),(0,r.jsx)("circle",{cx:"6",cy:"18",r:"3"}),(0,r.jsx)("path",{d:"M18 9a9 9 0 0 1-9 9"})]}),(0,r.jsx)("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.worktreeBranch})]})]})]}),c&&(0,r.jsx)("button",{onClick:e=>{e.stopPropagation(),h?.()},title:p?"Expand forks":"Collapse forks",style:{display:"flex",alignItems:"center",justifyContent:"center",width:20,height:20,padding:0,flexShrink:0,background:"none",border:"none",color:"var(--text-dim)",cursor:"pointer",transform:p?"rotate(-90deg)":"none",transition:"transform 0.15s"},children:(0,r.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:(0,r.jsx)("polyline",{points:"2 3.5 5 6.5 8 3.5"})})}),k&&!e.transient&&(0,r.jsxs)("div",{style:{display:"flex",gap:4,flexShrink:0},children:[(0,r.jsx)("button",{onClick:z,title:b("sidebar.rename"),style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,padding:0,background:"var(--bg-hover)",border:"1px solid var(--border)",borderRadius:7,color:"var(--text-muted)",cursor:"pointer",flexShrink:0,transition:"background 0.12s, color 0.12s, border-color 0.12s"},onMouseEnter:e=>{e.currentTarget.style.background="var(--bg-selected)",e.currentTarget.style.color="var(--accent)",e.currentTarget.style.borderColor="rgba(37,99,235,0.35)"},onMouseLeave:e=>{e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color="var(--text-muted)",e.currentTarget.style.borderColor="var(--border)"},children:(0,r.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,r.jsx)("path",{d:"M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"})})}),(0,r.jsx)("button",{onClick:A,title:b("sidebar.deleteWithShiftClick"),style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,padding:0,background:"var(--bg-hover)",border:"1px solid var(--border)",borderRadius:7,color:"var(--text-muted)",cursor:"pointer",flexShrink:0,transition:"background 0.12s, color 0.12s, border-color 0.12s"},onMouseEnter:e=>{e.currentTarget.style.background="rgba(239,68,68,0.08)",e.currentTarget.style.color="#ef4444",e.currentTarget.style.borderColor="rgba(239,68,68,0.35)"},onMouseLeave:e=>{e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color="var(--text-muted)",e.currentTarget.style.borderColor="var(--border)"},children:(0,r.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("polyline",{points:"3 6 5 6 21 6"}),(0,r.jsx)("path",{d:"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"}),(0,r.jsx)("path",{d:"M10 11v6M14 11v6"}),(0,r.jsx)("path",{d:"M9 6V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2"})]})})]})]})})}let et=/\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~]|\][^\x07]*(?:\x07|\x1B\\))/g,en=/^\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~]|\][^\x07]*(?:\x07|\x1B\\))/,er=/\x1B\[([0-9;]*)m/g,ei=/\x1B_pi:c\x07/g,eo=["#1f2937","#dc2626","#16a34a","#d97706","#2563eb","#9333ea","#0891b2","#6b7280"],el=["#9ca3af","#ef4444","#22c55e","#f59e0b","#3b82f6","#a855f7","#06b6d4","#e5e7eb"];function es(e){return e.replace(ei,"").replace(et,"")}function ea(e){let t=[],n=0;for(;n<e.length;){if(27===e.charCodeAt(n)){let t=e.slice(n).match(en);if(t){n+=t[0].length;continue}}let r=e.codePointAt(n);if(void 0===r)break;let i=String.fromCodePoint(r);t.push({start:n,end:n+i.length,char:i}),n+=i.length}return t}function ed(e,t){let n=ea(e)[t];return n?e.slice(0,n.start)+e.slice(n.end):e}function ec(e){return ea(e)[0]?.char}function eu(e){let t,n=[],r={},i=0;for(er.lastIndex=0;null!==(t=er.exec(e));)t.index>i&&n.push({text:e.slice(i,t.index),style:r}),r=function(e,t){let n={...e};for(let e=0;e<t.length;e++){let r=t[e];if(0===r)for(let e of Object.keys(n))delete n[e];else if(1===r)n.fontWeight=700;else if(2===r)n.opacity=.65;else if(3===r)n.fontStyle="italic";else if(4===r)n.textDecoration="underline";else if(22===r)delete n.fontWeight,delete n.opacity;else if(23===r)delete n.fontStyle;else if(24===r)delete n.textDecoration;else if(39===r)delete n.color;else if(49===r)delete n.backgroundColor;else if(r>=30&&r<=37)n.color=eo[r-30];else if(r>=90&&r<=97)n.color=el[r-90];else if(r>=40&&r<=47)n.backgroundColor=eo[r-40];else if(r>=100&&r<=107)n.backgroundColor=el[r-100];else if((38===r||48===r)&&2===t[e+1]){let[i,o,l]=[t[e+2],t[e+3],t[e+4]];[i,o,l].every(e=>"number"==typeof e&&Number.isFinite(e))&&(38===r?n.color=`rgb(${i}, ${o}, ${l})`:n.backgroundColor=`rgb(${i}, ${o}, ${l})`),e+=4}else if((38===r||48===r)&&5===t[e+1]){let i=function(e){if(e>=0&&e<8)return eo[e];if(e>=8&&e<16)return el[e-8];if(e>=16&&e<=231){let t=e-16,n=Math.floor(t/36),r=Math.floor(t%36/6),i=e=>0===e?0:55+40*e;return`rgb(${i(n)}, ${i(r)}, ${i(t%6)})`}if(e>=232&&e<=255){let t=8+(e-232)*10;return`rgb(${t}, ${t}, ${t})`}}(t[e+2]);i&&(38===r?n.color=i:n.backgroundColor=i),e+=2}}return n}(r,t[1]?t[1].split(";").map(e=>Number(e||"0")):[0]),i=t.index+t[0].length;return i<e.length&&n.push({text:e.slice(i),style:r}),n}let ep={ArrowUp:"\x1b[A",ArrowDown:"\x1b[B",ArrowRight:"\x1b[C",ArrowLeft:"\x1b[D",Home:"\x1b[H",End:"\x1b[F",Insert:"\x1b[2~",Delete:"\x1b[3~",PageUp:"\x1b[5~",PageDown:"\x1b[6~",Escape:"\x1b",Backspace:""},eh={ArrowLeft:"\x1bb",ArrowRight:"\x1bf",ArrowUp:"\x1bp",ArrowDown:"\x1bn"};function eg(e,t={}){return"thinking"===e.type&&!e.deferred&&!t.isStreaming&&""===e.thinking.trim()}function ef(e,t={}){return(e.content??[]).filter(e=>!eg(e,t))}function ex(e,t={}){return t.isStreaming||"error"!==e.stopReason?null:e.errorMessage?.trim()||"Unknown provider error"}function em(e,t={}){let n=ef(e,t),r=n.findLastIndex(e=>"text"!==e.type&&"image"!==e.type);return -1===r?{answerBlocks:n,processBlocks:[]}:{answerBlocks:n.slice(r+1),processBlocks:n.slice(0,r+1)}}function ev(e){return e.filter(e=>"toolCall"===e.type).length}function ey(e){try{return decodeURIComponent(e)}catch{return e}}function eb(e){return/^[a-zA-Z]:[\\/]/.test(e)||e.startsWith("\\\\")?e.replace(/\\/g,"/"):e}function ek(e){let t=eb(e),n=/^[a-zA-Z]:\//.test(t),r=t.startsWith("//"),i=t.startsWith("/")&&!n&&!r,o=[];for(let e of t.split("/"))if(e&&"."!==e){if(".."===e){o.length>0&&".."!==o[o.length-1]?o.pop():i||n||r||o.push(e);continue}o.push(e)}let l=o.join("/");return n?l:r?`//${l}`:i?`/${l}`:l}function ew(e,t,n=t){let r,i,o,l,s;if(!e)return null;let a=e.split("#",1)[0].split("?",1)[0].trim();if(!a)return null;let d=null,c=null,u=ey(a),p=u.startsWith("\\\\"),h=eb(u),g=h.toLowerCase();if(g.startsWith("/api/")||g.startsWith("/ai_agent_web/")||g.startsWith("/_next/")||!p&&h.startsWith("//")||/^[a-zA-Z][a-zA-Z0-9+.-]*:/i.test(h)&&!g.startsWith("file:")&&!/^[a-zA-Z]:\//.test(h))return null;if(g.startsWith("file:")?c=(d=function(e){try{let t=new URL(e);if("file:"!==t.protocol)return null;let n=ey(t.pathname);if(t.hostname)return`//${t.hostname}${n.startsWith("/")?n:`/${n}`}`;if(/^\/[a-zA-Z]:\//.test(n))return n.slice(1);return n}catch{return null}}(h))?"absolute":null:/^[a-zA-Z]:\//.test(h)||h.startsWith("/")?(d=h,c="absolute"):t&&!(h.startsWith("#")||h.startsWith("?"))&&(h.startsWith("./")||h.startsWith("../")||h.includes("/")||/(^|\/)\.?[^/]+\.[^/.]+$/.test(h))&&(d=`${eb(t).replace(/\/+$/,"")}/${h}`,c="relative"),!d)return null;let f=ek(d).replace(/:\d+(?::\d+)?$/,"");return"relative"===c&&n&&(r=ek(f).replace(/\/+$/,""),i=ek(n).replace(/\/+$/,""),l=(o=/^[a-zA-Z]:\//.test(r)||/^[a-zA-Z]:\//.test(i))?r.toLowerCase():r,!(l===(s=o?i.toLowerCase():i)||l.startsWith(`${s}/`)))?null:f}function ej(e){let t=e.toLowerCase();return"edit"===t||t.startsWith("edit_")||t.endsWith(".edit")||t.endsWith("_edit")||t.includes("str_replace")||t.includes("replace_editor")}var eS=n(32316),eC=n(88374),eT=n(5924),eR=n(94764),eM=n(63835),eI=n(54152),eL=n(84678),eE=n(98164);let eW={...eR.j,attributes:{...eR.j.attributes,code:[["className",/^language-./,"math-inline","math-display"]]},strip:[...eR.j.strip||[],"iframe","object","style","form"]};function e$(e){let t=e.includes("\r\n")?"\r\n":"\n",n=e.split(/\r?\n/),r=[],i=null,o=0,l=null,s=new Map;for(let e=0;e<n.length;e++){var a;let t=n[e];if(l){r.push(t),RegExp(`</${l}\\s*>`,"i").test(t)&&(l=null);continue}let d=t.match(/^ {0,3}(`{3,}|~{3,})/);if(d){let e=d[1][0],n=d[1].length;i?e===i.marker&&n>=i.size&&(i=null):i={marker:e,size:n},o=0,r.push(t);continue}if(i){r.push(t);continue}let c=t.match(/<(code|pre|script|style)\b/i);if(c){let e=c[1].toLowerCase(),n=t.slice((c.index??0)+c[0].length);RegExp(`</${e}\\s*>`,"i").test(n)||(l=e),o=0,r.push(t);continue}if(/^(?: {4}|\t)/.test(t)||""===t.trim()){o=0,r.push(t);continue}if(o||t.includes("`")){o=function(e,t){let n=t;for(let t=0;t<e.length;){if("`"!==e[t]){t++;continue}let r=t+1;for(;"`"===e[r];)r++;let i=r-t;0===n?n=i:i===n&&(n=0),t=r}return n}(t,o),r.push(t);continue}let u=t.match(/^([ ]{0,3})\\\[[ \t]*(.+?)[ \t]*\\\][ \t]*$/);if(u){let e=u[2].trim();if(e){r.push(`${u[1]}$$`,`${u[1]}${e}`,`${u[1]}$$`);continue}}let p=t.match(/^([ ]{0,3})\\\[[ \t]*$/);if(p){let t=function(e,t){for(let n=t;n<e.length;n++){let t=e[n];if(/^ {0,3}\\\][ \t]*$/.test(t))return n;if(/^ {0,3}(`{3,}|~{3,})/.test(t)||/^ {0,3}\\\[[ \t]*$/.test(t)||/<(code|pre|script|style)\b/i.test(t))break}return -1}(n,e+1);if(-1!==t){r.push(`${p[1]}$$`,...n.slice(e+1,t).map(e=>eP(e,p[1])),`${p[1]}$$`),e=t;continue}}let h=t.match(/^([ \t]{0,3})\$\$(.+)\$\$[ \t]*$/);if(h){let e=h[2].trim();if(e){r.push(`${h[1]}$$`,`${h[1]}${e}`,`${h[1]}$$`);continue}}let g=t.match(/^([ \t]{0,3})\$\$(.+)$/);if(g){let t=g[1],i=g[2].trimEnd();if(i&&!i.includes("$$")){let o=ez(n,e+1,t,s);if(o){r.push(`${t}$$`,`${t}${i}`);for(let i=e+1;i<o.index;i++)r.push(eP(n[i],t));o.content&&r.push(`${t}${o.content}`),r.push(`${t}$$`),e=o.index;continue}}}let f=t.match(/^([ \t]{0,3})\$\$\s*$/);if(f){let t=f[1],i=ez(n,e+1,t,s);if(i&&(i.glued||""!==t)){r.push(`${t}$$`);for(let o=e+1;o<i.index;o++)r.push(eP(n[o],t));i.content&&r.push(`${t}${i.content}`),r.push(`${t}$$`),e=i.index;continue}}r.push((a=t,/^\s{0,3}\[[^\]]+\]:/.test(a)||/]\s*\(/.test(a)||/<(?:!--|\/?[A-Za-z][^>]*>)/.test(a)||/\b(?:https?|file|mailto):/i.test(a)||/\b[A-Za-z]:\\/.test(a)?a:a.replace(/(?<!\\)\\\(([^`\r\n$]+?)(?<!\\)\\\)/g,(e,t)=>t.trim()?`$${t}$`:e)))}return r.join(t)}function ez(e,t,n,r){let i=r.get(n);if(void 0!==i&&t<i)return null;for(let i=t;i<e.length;i++){var o,l,s,a;let t=e[i];if(o=t,""===(l=n)?/^ {0,3}\$\$\s*$/.test(o):o.startsWith(l)&&/^\$\$\s*$/.test(o.slice(l.length)))return{index:i,content:"",glued:!1};if(s=t,/^ {0,3}(`{3,}|~{3,})/.test(s)||/^[ \t]*(?:[-+*]|\d{1,9}[.)])(?:[ \t]+|$)/.test(s)||/^ {0,3}#{1,6}(?:[ \t]+|$)/.test(s)||/^ {0,3}>/.test(s)||/<(code|pre|script|style)\b/i.test(s)||(a=t,/^ {0,3}\$\$(?:\S|[ \t]+\S)/.test(a)))return r.set(n,i),null;let d=function(e,t){if(!e.startsWith(t))return null;let n=e.slice(t.length).match(/^(.+?)\$\$\s*$/);if(!n)return null;let r=n[1].trimEnd();return r&&!r.includes("$$")?r:null}(t,n);if(null!==d)return{index:i,content:d,glued:!0}}return r.set(n,e.length),null}function eP(e,t){if(!t||!e||e.startsWith(" "))return e;let n=e.match(/^ */)?.[0].length??0;return n>=t.length?e:`${t.slice(n)}${e}`}let eN={singleTilde:!1},eA=[[eI.A,["yaml"]],[eL.A,eN],eE.A],eF=[[eI.A,["yaml"]],[eL.A,eN],eE.A],eD=[eT.A,[eM.A,eW],[eC.A,{throwOnError:!1,strict:!1}]],eB=[eT.A,[eM.A,eW],[eC.A,{throwOnError:!1,strict:!1}]];var eH=n(65063),eO=n(7644);let eU="pi-theme",e_=["light","dark","auto"],eq={preference:"auto",theme:"light"},eK=new Set,eV=null,eJ=!1;function eY(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function eG(e){return"auto"===e?eY():e}function eZ(e){"u">typeof document&&document.documentElement.classList.toggle("dark","dark"===e)}function eX(){if(eV)return eV;let e=function(){try{let e=localStorage.getItem(eU);if("light"===e||"dark"===e||"auto"===e)return e}catch{}return"auto"}(),t=eG(e);return eZ(t),eV={preference:e,theme:t}}function eQ(e,t,n){if(eZ(t),n)try{localStorage.setItem(eU,e)}catch{}eV={preference:e,theme:t},eK.forEach(e=>e())}function e0(){let e=eX();if("auto"!==e.preference)return;let t=eY();t!==e.theme&&eQ("auto",t,!1)}function e1(e){return eK.add(e),eX(),eJ||!window.matchMedia||(window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",e0),window.addEventListener("focus",e0),document.addEventListener("visibilitychange",()=>{"visible"===document.visibilityState&&e0()}),eJ=!0),e0(),()=>{eK.delete(e)}}function e2(){return eX()}function e8(){return eq}function e4(){let e=(0,i.useSyncExternalStore)(e1,e2,e8),t=(0,i.useCallback)(e=>{var t;let n,r=(t=eX().preference,n=e_.indexOf(t),e_[(n+1)%e_.length]),i=eG(r),o=()=>{eQ(r,i,!0)},l=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;if("function"!=typeof document.startViewTransition||l)return void o();let s=e?.x??window.innerWidth/2,a=e?.y??window.innerHeight/2,d=Math.hypot(Math.max(s,window.innerWidth-s),Math.max(a,window.innerHeight-a));document.startViewTransition(o).ready.then(()=>{document.documentElement.animate({clipPath:[`circle(0px at ${s}px ${a}px)`,`circle(${d}px at ${s}px ${a}px)`]},{duration:450,easing:"cubic-bezier(0.22, 0.61, 0.36, 1)",pseudoElement:"::view-transition-new(root)"})}).catch(()=>{})},[]);return{theme:e.theme,preference:e.preference,toggleTheme:t,isDark:"dark"===e.theme}}function e6(e){if(navigator.clipboard?.writeText)return navigator.clipboard.writeText(e);try{let t=document.createElement("textarea");return t.value=e,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t),Promise.resolve()}catch{return Promise.reject()}}function e5({code:e,isStreaming:t,defaultPreview:o=!1}){let{isDark:l}=e4(),{t:s}=(0,v.s)(),[a,d]=(0,i.useState)(o),[c,u]=(0,i.useState)(null),[p,h]=(0,i.useState)(!1),g=`${l?"dark":"light"}
2
2
  ${e}`,f=a&&!t;(0,i.useEffect)(()=>{if(!f)return;let t=!1;return u({key:g,status:"loading"}),(async()=>{let{default:r}=await Promise.all([n.e(6349),n.e(866),n.e(3308)]).then(n.bind(n,43328));if(r.initialize({startOnLoad:!1,securityLevel:"strict",suppressErrorRendering:!0,theme:l?"dark":"default"}),!await r.parse(e,{suppressErrors:!0}))throw Error("Invalid Mermaid diagram");let i="u">typeof crypto&&"randomUUID"in crypto?`mermaid-${crypto.randomUUID()}`:`mermaid-${Date.now()}-${Math.random().toString(36).slice(2)}`,o=await r.render(i,e);t||u({key:g,status:"ready",svg:o.svg})})().catch(()=>{t||u({key:g,status:"error"})}),()=>{t=!0}},[e,g,l,f]);let x=(0,i.useMemo)(()=>(0,r.jsx)("button",{type:"button",onClick:()=>d(e=>!e),disabled:t,title:t?s("i18n.previewAfterStreaming"):f?s("i18n.showMermaidSource"):s("i18n.previewMermaid"),className:["markdown-code-action",f?"is-active":""].filter(Boolean).join(" "),children:f?s("i18n.source"):s("i18n.preview")}),[t,f,s]);if(!f)return(0,r.jsx)(e9,{code:e,lang:"mermaid",headerAction:x,isStreaming:t});let m=c?.key===g&&"error"===c.status?(0,r.jsx)("div",{className:"mermaid-block mermaid-block-error",children:s("i18n.invalidMermaid")}):c?.key!==g||"ready"!==c.status?(0,r.jsx)("div",{className:"mermaid-block mermaid-block-loading","aria-label":s("i18n.renderingMermaid")}):(0,r.jsxs)(r.Fragment,{children:[!p&&(0,r.jsx)("button",{type:"button",className:"mermaid-block mermaid-preview-button",title:s("i18n.openMermaidViewer"),"aria-label":s("i18n.openMermaidViewer"),onClick:()=>h(!0),dangerouslySetInnerHTML:{__html:c.svg}}),p&&(0,r.jsx)(e3,{svg:c.svg,onClose:()=>h(!1)})]});return(0,r.jsxs)("div",{className:"markdown-code-block",children:[(0,r.jsxs)("div",{className:"markdown-code-header",children:[(0,r.jsx)("span",{className:"markdown-code-lang",children:"mermaid"}),x]}),m]})}function e3({svg:e,onClose:t}){let{t:n}=(0,v.s)(),o=(0,i.useRef)(null),[l,s]=(0,i.useState)(1);return(0,i.useEffect)(()=>{let e=o.current;if(!e)return;let t=document.body.style.overflow;return document.body.style.overflow="hidden",e.showModal(),()=>{document.body.style.overflow=t,e.open&&e.close()}},[]),(0,r.jsx)("dialog",{ref:o,className:"mermaid-zoom-dialog","aria-label":n("i18n.mermaidViewer"),onCancel:e=>{e.preventDefault(),t()},onKeyDown:e=>{"Escape"===e.key&&(e.preventDefault(),t())},children:(0,r.jsxs)("div",{className:"mermaid-zoom-layout",children:[(0,r.jsxs)("div",{className:"mermaid-zoom-toolbar",children:[(0,r.jsx)("span",{className:"mermaid-zoom-title",children:n("i18n.mermaidDiagram")}),(0,r.jsxs)("div",{className:"mermaid-zoom-actions",children:[(0,r.jsxs)("div",{className:"mermaid-zoom-stepper",children:[(0,r.jsx)("button",{type:"button",onClick:()=>s(e=>Math.max(.5,e-.25)),disabled:l<=.5,title:n("i18n.zoomOut"),"aria-label":n("i18n.zoomOut"),children:(0,r.jsx)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round","aria-hidden":"true",children:(0,r.jsx)("path",{d:"M5 12h14"})})}),(0,r.jsxs)("span",{className:"mermaid-zoom-value",children:[Math.round(100*l),"%"]}),(0,r.jsx)("button",{type:"button",onClick:()=>s(e=>Math.min(3,e+.25)),disabled:l>=3,title:n("i18n.zoomIn"),"aria-label":n("i18n.zoomIn"),children:(0,r.jsx)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round","aria-hidden":"true",children:(0,r.jsx)("path",{d:"M12 5v14M5 12h14"})})})]}),(0,r.jsx)("button",{type:"button",className:"mermaid-zoom-icon-button",onClick:()=>s(1),title:n("i18n.fitToWidth"),"aria-label":n("i18n.fitToWidth"),children:(0,r.jsx)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:(0,r.jsx)("path",{d:"M8 3H3v5M16 3h5v5M8 21H3v-5M16 21h5v-5"})})}),(0,r.jsx)("button",{type:"button",className:"mermaid-zoom-icon-button",onClick:t,title:n("i18n.close"),"aria-label":n("i18n.close"),children:(0,r.jsx)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round","aria-hidden":"true",children:(0,r.jsx)("path",{d:"M6 6l12 12M18 6 6 18"})})})]})]}),(0,r.jsx)("div",{className:"mermaid-zoom-viewport",onClick:e=>{e.target===e.currentTarget&&t()},children:(0,r.jsx)("div",{className:"mermaid-zoom-canvas",style:{width:`${100*l}%`},dangerouslySetInnerHTML:{__html:e}})})]})})}let e9=(0,i.memo)(function({code:e,lang:t,headerAction:n,isStreaming:o}){let{isDark:l}=e4(),{t:s}=(0,v.s)(),[a,d]=(0,i.useState)(!1);return(0,r.jsxs)("div",{className:"markdown-code-block",children:[(0,r.jsxs)("div",{className:"markdown-code-header",children:[(0,r.jsx)("span",{className:"markdown-code-lang",children:t||"text"}),(0,r.jsxs)("div",{className:"markdown-code-actions",children:[n,(0,r.jsx)("button",{onClick:()=>{e6(e).then(()=>{d(!0),setTimeout(()=>d(!1),1500)})},className:"markdown-code-action",children:s(a?"i18n.copied":"i18n.copy")})]})]}),o?(0,r.jsx)("pre",{style:{margin:0,padding:"11px 13px",fontSize:12.5,lineHeight:1.62,overflowX:"auto",background:"color-mix(in srgb, var(--bg) 92%, var(--bg-panel))"},children:(0,r.jsx)("code",{style:{fontFamily:"var(--font-mono)"},children:e})}):(0,r.jsx)(eH.A,{language:t||"text",style:l?eO.xJ:eO.vs,showLineNumbers:!0,lineNumberStyle:{color:"var(--text-dim)",fontStyle:"normal"},customStyle:{margin:0,padding:"11px 13px",fontSize:12.5,lineHeight:1.62,borderRadius:0,background:"color-mix(in srgb, var(--bg) 92%, var(--bg-panel))"},codeTagProps:{style:{fontFamily:"var(--font-mono)"}},children:e})]})}),e7="ly-ai-assistant";function te(e,t=1e4){return new Promise(n=>{let r=!1,i=null,o=e=>{r||(r=!0,i&&clearTimeout(i),window.removeEventListener("message",l),n(e))},l=e=>{let t=e.data;t&&"object"==typeof t&&t.source===e7&&"page_ability_response"===t.type&&t.requestId===s&&o(t.ok?{ok:!0,data:t.data}:{ok:!1,error:"string"==typeof t.error?t.error:"未知错误"})},s=`${Date.now()}-${Math.random().toString(36).slice(2,8)}`;i=setTimeout(()=>o({ok:!1,error:"父页面未响应(能力调用超时)"}),t),window.addEventListener("message",l);try{let t=window.parent;if(!t||t===window)return void o({ok:!1,error:"当前不在宿主页面 iframe 内,无法调用页面能力"});let n=tr(e)||{};t.postMessage({source:e7,type:"page_ability_request",requestId:s,...n},"*")}catch(e){o({ok:!1,error:`调用父页面失败: ${e instanceof Error?e.message:String(e)}`})}})}async function tt(e=1e4){let t=await te({action:"list"},e);return t.ok&&t.data&&"object"==typeof t.data&&"abilities"in t.data&&Array.isArray(t.data.abilities)?{ok:!0,data:{abilities:t.data.abilities}}:t.ok?{ok:!1,error:"父页面未返回有效页面能力清单"}:t}function tn(e,t,n=1e4){return te({action:"execute",ability:e,params:tr(t)},n)}function tr(e){try{return JSON.parse(JSON.stringify(e))}catch{return}}let ti={goto_view:"view_goto"},to={display:"inline-flex",alignItems:"center",gap:8,flexWrap:"wrap",margin:"6px 0"},tl={display:"inline-flex",alignItems:"center",gap:6,padding:"4px 14px",borderRadius:6,border:"1px solid #1677ff",background:"#fff",color:"#1677ff",cursor:"pointer",fontSize:13,lineHeight:"20px",transition:"background 0.15s, color 0.15s"},ts={...tl,opacity:.6,cursor:"default"},ta={fontSize:12,color:"#888"},td={fontSize:12,color:"#cf1322"},tc={fontSize:12,color:"#cf1322",fontStyle:"italic"};function tu({action:e}){let[t,n]=(0,i.useState)("idle"),[o,l]=(0,i.useState)(""),s=ti[e.action];if(!s)return(0,r.jsxs)("span",{style:tc,children:["未知动作: ",e.action]});let a="string"==typeof e.label&&e.label?e.label:`执行: ${e.action}`,d=async()=>{if("loading"===t)return;n("loading"),l("");let{action:r,label:i,...o}=e,a=await tn(s,o,15e3);a.ok?n("done"):(n("error"),l(a.error||"执行失败"))};return(0,r.jsxs)("span",{style:to,children:[(0,r.jsx)("button",{type:"button",style:"loading"===t?ts:tl,disabled:"loading"===t,onClick:d,children:a}),"loading"===t&&(0,r.jsx)("span",{style:ta,children:"执行中…"}),"done"===t&&(0,r.jsx)("span",{style:ta,children:"✓ 已执行"}),"error"===t&&(0,r.jsx)("span",{style:td,children:o})]})}function tp({raw:e}){let t;try{t=JSON.parse(e.trim())}catch{return(0,r.jsx)("span",{style:tc,children:"动作数据解析失败(非法 JSON)"})}let n=(Array.isArray(t)?t:[t]).filter(e=>!!e&&"object"==typeof e);return 0===n.length?(0,r.jsx)("span",{style:tc,children:"动作数据为空"}):(0,r.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:2},children:n.map((e,t)=>(0,r.jsx)(tu,{action:e},t))})}function th({children:e,className:t,isStreaming:n,cwd:o,onOpenFile:l}){let a=(0,i.useMemo)(()=>e$(e),[e]),d=(0,i.useMemo)(()=>({code({className:e,children:t,...i}){let o=e?.replace("language-","").toLowerCase()??"",l=String(t);return e?.includes("language-")||l.includes("\n")?"mermaid"===o?(0,r.jsx)(e5,{code:l.replace(/\n$/,""),isStreaming:n}):"ly_action"===o?(0,r.jsx)(tp,{raw:l}):(0,r.jsx)(e9,{code:l.replace(/\n$/,""),lang:o,isStreaming:n}):(0,r.jsx)("code",{className:"markdown-inline-code",...i,children:t})},pre:({children:e})=>(0,r.jsx)(r.Fragment,{children:e}),a({href:e,children:t,...n}){delete n.node;let i=l?ew(e,o):null;return i&&l?(0,r.jsx)("a",{href:e,...n,onClick:e=>{if(e.defaultPrevented||0!==e.button||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return;let t=e.currentTarget.getAttribute("target");t&&"_self"!==t||(e.preventDefault(),l(i))},children:t}):(0,r.jsx)("a",{href:e,...n,target:"_blank",rel:"noopener noreferrer",children:t})},img({src:e,alt:t,...n}){delete n.node;let i="string"==typeof e?ew(e,o):null,l=i?(0,s.hd)(`/api/files/${T(i)}?type=read`):e;return(0,r.jsx)("img",{src:l,alt:t??"",loading:"lazy",...n})},table:({children:e})=>(0,r.jsx)("div",{className:"markdown-table-wrap",children:(0,r.jsx)("table",{children:e})})}),[o,n,l]);return(0,r.jsx)("div",{className:["markdown-body",t].filter(Boolean).join(" "),children:(0,r.jsx)(eS.oz,{remarkPlugins:eA,rehypePlugins:eD,components:d,children:a})})}function tg({src:e,alt:t="",children:n,className:o,style:l}){let{t:s}=(0,v.s)(),[a,d]=(0,i.useState)(!1),c=(0,i.useRef)(null),u=(0,i.useRef)(null),p=(0,i.useRef)(null);(0,i.useEffect)(()=>{if(!a)return;let e=u.current;if(!e)return;let t=c.current,n=document.body.style.overflow;return document.body.style.overflow="hidden",e.showModal(),p.current?.focus({preventScroll:!0}),()=>{document.body.style.overflow=n,e.open&&e.close(),t?.isConnected&&t.focus({preventScroll:!0})}},[a]);let h=()=>{u.current?.open&&u.current.close(),d(!1)};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("button",{ref:c,type:"button",className:o,style:{display:"block",padding:0,border:"none",background:"none",color:"inherit",cursor:"zoom-in",...l},onClick:()=>d(!0),"aria-label":s("chat.previewImage"),"aria-haspopup":"dialog","aria-expanded":a,title:s("chat.previewImage"),children:n}),a&&(0,r.jsxs)("dialog",{ref:u,className:"image-preview-dialog","aria-label":s("chat.previewImage"),onCancel:e=>{e.preventDefault(),e.stopPropagation(),h()},onKeyDown:e=>{"Escape"===e.key&&(e.preventDefault(),e.stopPropagation(),h())},onClick:e=>{e.target===e.currentTarget&&h()},children:[(0,r.jsx)("img",{className:"image-preview-image",src:e,alt:t}),(0,r.jsx)("button",{ref:p,type:"button",className:"image-preview-close",onClick:h,"aria-label":s("chat.close"),title:s("chat.close"),children:(0,r.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round","aria-hidden":"true",children:(0,r.jsx)("path",{d:"M6 6l12 12M18 6 6 18"})})})]})]})}let tf=/<(read-files|modified-files)>\s*([\s\S]*?)\s*<\/\1>/g,tx=/(?:\r?\n){2,}((?:[ \t]*<(?:read-files|modified-files)>[ \t]*\r?\n[\s\S]*?\r?\n[ \t]*<\/(?:read-files|modified-files)>[ \t]*(?:\r?\n)?)+)\s*$/;function tm(e){let t,n=[],r=null,i=0,o=0,l=0,s=0,a=[],d=[],c=()=>({lineNo:null,text:"",type:"empty"}),u=()=>{if(!r){a=[],d=[];return}let e=Math.max(a.length,d.length);for(let t=0;t<e;t++){let e=a[t]?{lineNo:a[t].lineNo,text:a[t].text,type:"removed"}:c(),n=d[t]?{lineNo:d[t].lineNo,text:d[t].text,type:"added"}:c();r.rows.push({type:"line",left:e,right:n})}a=[],d=[]};for(let c of e.split(/\r?\n/)){if(!(l>0||s>0)){if(c.startsWith("--- ")){u(),t=tv(c.slice(4));continue}if(c.startsWith("+++ ")){u(),r={oldPath:t,newPath:tv(c.slice(4)),rows:[]},n.push(r);continue}}let e=c.match(/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/);if(e){r||(r={rows:[]},n.push(r)),u(),i=Number(e[1]),o=Number(e[3]),l=void 0===e[2]?1:Number(e[2]),s=void 0===e[4]?1:Number(e[4]),r.rows.push({type:"hunk",text:c});continue}if(!r)continue;if(c.startsWith("\\ ")){u(),r.rows.push({type:"hunk",text:c});continue}let p=c[0],h=c.slice(1);" "===p?(u(),r.rows.push({type:"line",left:{lineNo:i++,text:h,type:"context"},right:{lineNo:o++,text:h,type:"context"}}),l>0&&l--,s>0&&s--):"-"===p?(a.push({lineNo:i++,text:h}),l>0&&l--):"+"===p?(d.push({lineNo:o++,text:h}),s>0&&s--):""!==c&&(u(),r.rows.push({type:"hunk",text:c}))}u();let p=n.filter(e=>e.rows.some(e=>"line"===e.type));return p.length>0?p:null}function tv(e){return e.split(" ")[0].trim()}function ty({files:e,onOpenFile:t}){let{t:n}=(0,v.s)();return 0===e.length?null:(0,r.jsx)("div",{"aria-label":n("chat.filesWritten"),style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:6,marginTop:6},children:e.map(({filePath:e})=>{let i=R(e);return(0,r.jsxs)("button",{type:"button",title:e,"aria-label":n("chat.openWrittenFile",{name:i}),onClick:()=>t?.(e),style:{display:"inline-flex",alignItems:"center",gap:4,padding:"2px 8px",fontSize:12,fontFamily:"var(--font-mono)",color:"var(--text)",background:"var(--bg-subtle)",border:"1px solid var(--border)",borderRadius:6,cursor:"pointer"},children:[S(i,12),(0,r.jsx)("span",{children:i})]},e)})})}let tb=/[\u3000-\u30ff\u3400-\u9fff\uf900-\ufaff\u{20000}-\u{2fa1f}\uac00-\ud7af]/u;function tk(e){let t=0,n=0;for(let r of e)tb.test(r)?t++:n++;return t+n/4}let tw=new Map;function tj({children:e,className:t,...n}){let{t:o}=(0,v.s)(),[l,s]=(0,i.useState)(!1);if(e.length<=1e5)return(0,r.jsx)(th,{className:t,...n,children:e});if(!l){var a;return(0,r.jsxs)("button",{onClick:()=>s(!0),style:{display:"block",width:"100%",margin:"4px 0",padding:"7px 10px",border:"1px solid var(--border)",borderRadius:6,background:"var(--bg-panel)",color:"var(--text-muted)",cursor:"pointer",fontSize:12,textAlign:"left"},children:["⚠ ",o("i18n.largeMessageReveal",{size:(a=e.length)>=1e6?`${(a/1e6).toFixed(1)} MB`:a>=1e3?`${Math.round(a/1e3)} KB`:`${a} B`})]})}return(0,r.jsx)("div",{className:t,style:{maxHeight:420,overflow:"auto",fontSize:12,lineHeight:1.5},children:(0,r.jsx)("pre",{style:{margin:0,padding:"8px 10px",whiteSpace:"pre-wrap",wordBreak:"break-word",fontFamily:"var(--font-mono)",color:"var(--text-muted)"},children:e})})}function tS(e){if(!e)return null;let t=new Date(e),n=new Date,r=t.getFullYear()===n.getFullYear()&&t.getMonth()===n.getMonth()&&t.getDate()===n.getDate(),i=t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});if(r)return i;let o=t.toLocaleDateString([],{month:"short",day:"numeric",year:t.getFullYear()!==n.getFullYear()?"numeric":void 0});return`${o} ${i}`}let tC=(0,i.memo)(function({message:e,isStreaming:t,toolResults:n,modelNames:i,cwd:o,onOpenFile:l,entryId:s,onFork:a,forking:d,onNavigate:c,prevAssistantEntryId:u,onEditContent:p,showTimestamp:h,prevTimestamp:g,sessionId:f,writtenFiles:x}){return"user"===e.role?(0,r.jsx)(tT,{message:e,cwd:o,onOpenFile:l,entryId:s,onFork:a,forking:d,onNavigate:c,prevAssistantEntryId:u,onEditContent:p}):"assistant"===e.role?(0,r.jsx)(tR,{message:e,isStreaming:t,toolResults:n,modelNames:i,cwd:o,onOpenFile:l,showTimestamp:h,prevTimestamp:g,sessionId:f,entryId:s,writtenFiles:x}):"toolResult"===e.role?null:"custom"===e.role?"compaction"===e.customType?(0,r.jsx)(tF,{message:e}):(0,r.jsx)(tH,{message:e,cwd:o,onOpenFile:l}):"bashExecution"===e.role?(0,r.jsx)(tU,{message:e,sessionId:f}):null},(e,t)=>e.message===t.message&&e.isStreaming===t.isStreaming&&function(e,t,n){if(t===n||"assistant"!==e.role)return!0;for(let r of e.content??[])if("toolCall"===r.type&&t?.get(r.toolCallId)!==n?.get(r.toolCallId))return!1;return!0}(e.message,e.toolResults,t.toolResults)&&e.modelNames===t.modelNames&&e.cwd===t.cwd&&e.onOpenFile===t.onOpenFile&&e.entryId===t.entryId&&e.onFork===t.onFork&&e.forking===t.forking&&e.onNavigate===t.onNavigate&&e.prevAssistantEntryId===t.prevAssistantEntryId&&e.onEditContent===t.onEditContent&&e.showTimestamp===t.showTimestamp&&e.prevTimestamp===t.prevTimestamp&&e.sessionId===t.sessionId);function tT({message:e,cwd:t,onOpenFile:n,entryId:o,onFork:l,forking:s,onNavigate:a,prevAssistantEntryId:d,onEditContent:c}){let{t:p}=(0,v.s)(),[h,g]=(0,i.useState)(!1),[f,x]=(0,i.useState)(!1),[m,y]=(0,i.useState)(!1),b="string"==typeof e.content?e.content:e.content.filter(e=>"text"===e.type).map(e=>e.text).join("\n"),k="string"==typeof e.content?[]:e.content.filter(e=>"image"===e.type),w=u(b),j=w?.search(/\s/)??-1,S=w?-1===j?w:w.slice(0,j):"",C=w&&-1!==j?w.slice(j+1):"",T=tS(e.timestamp),R=!!o&&!!l,M=w??b,I=w?function(e,t){if("string"==typeof e.content)return{...e,content:t};let n=[],r=!1;for(let i of e.content){if("text"!==i.type){n.push(i);continue}r||(n.push({...i,text:t}),r=!0)}return r||n.unshift({type:"text",text:t}),{...e,content:n}}(e,w):e,L=k.length>0&&(0,r.jsx)("div",{style:{display:"flex",gap:6,flexWrap:"wrap",marginBottom:8*!!b},children:k.map((e,t)=>{let n=e.source?"base64"===e.source.type?`data:${e.source.media_type};base64,${e.source.data}`:e.source.url??"":e.data?`data:${e.mimeType};base64,${e.data}`:"";return(0,r.jsx)(tg,{src:n,children:(0,r.jsx)("img",{src:n,alt:"",style:{maxWidth:240,maxHeight:240,borderRadius:6,objectFit:"contain",display:"block",border:"1px solid rgba(59,130,246,0.15)"}})},t)})}),E=!!d&&!!a;return(0,r.jsxs)("div",{style:{marginBottom:16,display:"flex",flexDirection:"column",alignItems:"flex-end"},onMouseEnter:()=>g(!0),onMouseLeave:()=>g(!1),children:[(0,r.jsx)("div",{style:{display:"flex",alignItems:"flex-end",gap:6,maxWidth:"85%"},children:(0,r.jsx)("div",{style:{flex:1,minWidth:0,background:"var(--user-bg)",border:"1px solid rgba(59,130,246,0.2)",borderRadius:12,padding:"8px 12px",fontSize:14,lineHeight:1.6,color:"var(--text)",wordBreak:"break-word",maxHeight:300,overflowY:"auto"},children:w?(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6,minWidth:0},children:[L,(0,r.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:8,flexWrap:"wrap"},children:[(0,r.jsxs)("button",{onClick:()=>y(e=>!e),title:p(m?"i18n.collapse":"i18n.expand"),"aria-expanded":m,style:{display:"flex",alignItems:"center",gap:6,flexShrink:0,padding:0,background:"none",border:"none",cursor:"pointer",color:"var(--accent)",fontFamily:"var(--font-mono)",fontSize:13,textAlign:"left"},children:[(0,r.jsx)("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:S}),(0,r.jsx)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,opacity:.75,transform:m?"rotate(180deg)":"none",transition:"transform 0.15s"},"aria-hidden":"true",children:(0,r.jsx)("polyline",{points:"6 9 12 15 18 9"})})]}),C&&(0,r.jsx)("span",{style:{color:"var(--text)",fontSize:14,lineHeight:1.6,whiteSpace:"pre-wrap",wordBreak:"break-word",minWidth:0,flex:1},children:C})]}),m&&(0,r.jsx)(th,{className:"markdown-user-message",cwd:t,onOpenFile:n,children:b})]}):(0,r.jsxs)(r.Fragment,{children:[L,b&&(0,r.jsx)(tj,{className:"markdown-user-message",cwd:t,onOpenFile:n,children:b})]})})}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:6,marginTop:3},children:[(0,r.jsx)("div",{style:{display:"flex",gap:3,opacity:+!!h,pointerEvents:h?"auto":"none",transition:"opacity 0.12s"},children:(0,r.jsxs)("button",{onClick:()=>{e6(M).then(()=>{x(!0),setTimeout(()=>x(!1),1500)})},title:p("i18n.copyMessage"),style:{display:"flex",alignItems:"center",gap:4,padding:"3px 8px",height:22,background:"none",border:"none",borderRadius:5,color:f?"var(--accent)":"var(--text-dim)",cursor:"pointer",fontSize:11,fontWeight:400,whiteSpace:"nowrap",transition:"color 0.12s"},onMouseEnter:e=>{f||(e.currentTarget.style.color="var(--accent)")},onMouseLeave:e=>{f||(e.currentTarget.style.color="var(--text-dim)")},children:[f?(0,r.jsx)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:(0,r.jsx)("polyline",{points:"20 6 9 17 4 12"})}):(0,r.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),(0,r.jsx)("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]}),p(f?"i18n.copied":"i18n.copy")]})}),(R||E)&&(0,r.jsxs)("div",{style:{display:"flex",gap:3,opacity:h||s?1:0,pointerEvents:h||s?"auto":"none",transition:"opacity 0.12s"},children:[E&&(0,r.jsxs)("button",{onClick:()=>{a(d),c?.(I)},title:p("i18n.editFromHereTitle"),style:{display:"flex",alignItems:"center",gap:4,padding:"3px 8px",height:22,background:"none",border:"none",borderRadius:5,color:"var(--text-dim)",cursor:"pointer",fontSize:11,fontWeight:400,whiteSpace:"nowrap",transition:"color 0.12s"},onMouseEnter:e=>{e.currentTarget.style.color="var(--accent)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-dim)"},children:[(0,r.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("polyline",{points:"15 10 20 15 15 20"}),(0,r.jsx)("path",{d:"M4 4v7a4 4 0 0 0 4 4h12"})]}),p("i18n.editFromHere")]}),R&&(0,r.jsxs)("button",{onClick:()=>{l(o)},disabled:s,title:p(s?"i18n.creatingSession":"i18n.newSessionTitle"),style:{display:"flex",alignItems:"center",gap:4,padding:"3px 8px",height:22,background:"none",border:"none",borderRadius:5,color:s?"var(--accent)":"var(--text-dim)",cursor:s?"not-allowed":"pointer",fontSize:11,fontWeight:400,whiteSpace:"nowrap",transition:"color 0.12s"},onMouseEnter:e=>{s||(e.currentTarget.style.color="var(--accent)")},onMouseLeave:e=>{s||(e.currentTarget.style.color="var(--text-dim)")},children:[(0,r.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("line",{x1:"6",y1:"3",x2:"6",y2:"15"}),(0,r.jsx)("circle",{cx:"18",cy:"6",r:"3"}),(0,r.jsx)("circle",{cx:"6",cy:"18",r:"3"}),(0,r.jsx)("path",{d:"M18 9a9 9 0 0 1-9 9"})]}),p(s?"i18n.creating":"i18n.newSession")]})]}),T&&(0,r.jsx)("span",{style:{fontSize:10,color:"var(--text-dim)"},children:T})]})]})}function tR({message:e,isStreaming:t,toolResults:n,modelNames:o,cwd:l,onOpenFile:s,showTimestamp:a,prevTimestamp:d,sessionId:c,entryId:u,writtenFiles:p}){var h;let g,f,x,{t:m}=(0,v.s)(),y=a?tS(e.timestamp):null,b=(0,i.useMemo)(()=>(e.content??[]).map((e,t)=>({block:e,originalIndex:t})).filter(({block:e})=>!eg(e,{isStreaming:t})),[e.content,t]),k=(0,i.useMemo)(()=>b.map(({block:e})=>e),[b]),w=ex(e,{isStreaming:t}),[j,S]=(0,i.useState)(!1),[C,T]=(0,i.useState)(!1),R=(0,i.useRef)(null),[M,I]=(0,i.useState)(null),L=(0,i.useRef)(b);L.current=b;let E=(0,i.useRef)(new Map),W=(0,i.useMemo)(()=>{if(!t)return E.current=new Map,0;let e=new Map,n=0;for(let{block:t,originalIndex:r}of b){let i="text"===t.type?t.text:"thinking"===t.type?t.thinking:"toolCall"===t.type?t.rawInput??JSON.stringify(t.input??{})??"":null;if(null===i)continue;let o=function(e,t){var n,r;if(!e||!t.startsWith(e.text))return tk(t);let i=e.tokens,o=e.text.length;return o>0&&o<t.length&&(n=e.text.charCodeAt(o-1))>=55296&&n<=56319&&(r=t.charCodeAt(o))>=56320&&r<=57343&&(i-=1/4,o--),i+tk(t.slice(o))}(E.current.get(r),i);e.set(r,{text:i,tokens:o}),n+=o}return E.current=e,n},[b,t]),$=(0,i.useRef)(W);$.current=W;let z=(0,i.useRef)(new Map),[P,N]=(0,i.useState)(new Map),A=(0,i.useMemo)(()=>{if(!e.timestamp||!d)return;let t=Math.round((e.timestamp-d)/1e3);return t>0?t:void 0},[e.timestamp,d]),F=(0,i.useMemo)(()=>{let t=new Map;if(!n||!e.timestamp)return t;for(let[r,i]of n)if(i.timestamp&&e.timestamp){let n=Math.round((i.timestamp-e.timestamp)/1e3);n>0&&t.set(r,n)}return t},[n,e.timestamp]),D=k.filter(e=>"text"===e.type).map(e=>e.text).join("\n");if((0,i.useEffect)(()=>{if(!t){let e=new Date().getTime();N(t=>{let n=new Map(t);for(let[t,r]of z.current)n.has(t)||n.set(t,Math.round((e-r)/1e3));return n}),R.current=null,I(null);return}let e=setInterval(()=>{let e=L.current,t=Date.now();e.forEach(({originalIndex:e})=>{z.current.has(e)||z.current.set(e,t)}),N(n=>{let r=!1,i=new Map(n);for(let n=0;n<e.length-1;n++){let o=e[n].originalIndex,l=e[n+1].originalIndex;if(!i.has(o)&&z.current.has(o)){let e=z.current.get(o),n=z.current.get(l)??t;i.set(o,Math.round((n-e)/1e3)),r=!0}}return r?i:n});let n=$.current;if(0===n)return;null===R.current&&(R.current=t);let r=(t-R.current)/1e3;r>.5&&I(n/r)},300);return()=>clearInterval(e)},[t]),0===k.length&&!t&&!w)return null;return(0,r.jsxs)("div",{style:{marginBottom:16},onMouseEnter:()=>S(!0),onMouseLeave:()=>S(!1),children:[(0,r.jsxs)("div",{style:{fontSize:11,color:"var(--text-dim)",marginBottom:4,display:"flex",alignItems:"center",gap:6},children:[e.provider&&(0,r.jsx)("span",{children:o?.[`${e.provider}:${e.model}`]??o?.[e.model]??e.model}),t&&(f=Math.round(W),(0,r.jsx)(r.Fragment,{children:f>0&&(0,r.jsxs)("span",{style:{display:"flex",alignItems:"center",gap:4,color:"var(--text)"},title:m("i18n.estimatedTokens"),children:[(0,r.jsxs)("span",{style:{display:"flex",alignItems:"center",gap:2,fontSize:11,fontWeight:400},children:[(0,r.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("line",{x1:"5",y1:"1.5",x2:"5",y2:"8.5"}),(0,r.jsx)("polyline",{points:"2 6 5 8.5 8 6"})]}),f]}),null!==M&&(x=M>=50?"#53b3cb":M>=30?"#9bc53d":M>=15?"#f9c22e":"#e01a4f",(0,r.jsxs)("span",{style:{marginLeft:6,padding:"1px 6px",borderRadius:4,background:x,color:"#fff",fontSize:11,fontWeight:400},children:[M.toFixed(1)," t/s"]}))]})}))]}),(0,r.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:8},children:b.map(({block:e,originalIndex:i})=>(0,r.jsx)(tM,{block:e,toolResults:n,isStreaming:t,streamingDuration:P.get(i)??("thinking"===e.type?A:void 0),toolCallDurations:F,cwd:l,onOpenFile:s,sessionId:c,entryId:u,blockIndex:i},`${u??"stream"}-${i}`))}),w&&(0,r.jsxs)("div",{role:"alert",style:{marginTop:8*(k.length>0),padding:"7px 10px",border:"1px solid rgba(239,68,68,0.3)",borderRadius:6,background:"rgba(239,68,68,0.07)",color:"#ef4444",fontFamily:"var(--font-mono)",fontSize:12,lineHeight:1.5,whiteSpace:"pre-wrap",overflowWrap:"anywhere"},children:["Error: ",w]}),p&&p.length>0&&(0,r.jsx)(ty,{files:p,onOpenFile:s}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:4},children:[e.usage&&!t&&(0,r.jsx)("div",{style:{fontSize:11,color:"var(--text-dim)"},children:(h=e.usage,g=[],h.input&&g.push(`${h.input.toLocaleString()} in`),h.output&&g.push(`${h.output.toLocaleString()} out`),h.cacheRead&&g.push(`${h.cacheRead.toLocaleString()} cache R`),h.cacheWrite&&g.push(`${h.cacheWrite.toLocaleString()} cache W`),h.cost?.total&&g.push(`$${h.cost.total.toFixed(4)}`),g.join(" \xb7 "))}),D&&!t&&(0,r.jsxs)("button",{onClick:()=>{e6(D).then(()=>{T(!0),setTimeout(()=>T(!1),1500)})},title:m("i18n.copyMessage"),style:{display:"flex",alignItems:"center",gap:4,padding:"3px 8px",height:22,background:"none",border:"none",borderRadius:5,color:C?"var(--accent)":"var(--text-dim)",cursor:"pointer",fontSize:11,fontWeight:400,whiteSpace:"nowrap",opacity:+!!j,pointerEvents:j?"auto":"none",transition:"opacity 0.12s, color 0.12s"},onMouseEnter:e=>{C||(e.currentTarget.style.color="var(--accent)")},onMouseLeave:e=>{C||(e.currentTarget.style.color="var(--text-dim)")},children:[C?(0,r.jsx)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:(0,r.jsx)("polyline",{points:"20 6 9 17 4 12"})}):(0,r.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),(0,r.jsx)("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]}),m(C?"i18n.copied":"i18n.copy")]}),y&&!t&&(0,r.jsx)("span",{style:{fontSize:10,color:"var(--text-dim)",marginLeft:"auto"},children:y})]})]})}function tM({block:e,toolResults:t,isStreaming:n,streamingDuration:i,toolCallDurations:o,cwd:l,onOpenFile:s,sessionId:a,entryId:d,blockIndex:c}){if("text"===e.type)return(0,r.jsx)(tI,{block:e,isStreaming:n,cwd:l,onOpenFile:s});if("thinking"===e.type)return(0,r.jsx)(tL,{block:e,duration:i,sessionId:a,entryId:d,blockIndex:c});if("toolCall"===e.type){let n=t?.get(e.toolCallId),i=o?.get(e.toolCallId);return(0,r.jsx)(tE,{block:e,result:n,duration:i})}return null}function tI({block:e,isStreaming:t,cwd:n,onOpenFile:i}){return(0,r.jsx)(tj,{isStreaming:t,cwd:n,onOpenFile:i,children:e.text})}function tL({block:e,duration:t,sessionId:n,entryId:o,blockIndex:l}){let{t:s}=(0,v.s)(),[a,d]=(0,i.useState)(!1),[c,u]=(0,i.useState)(null),[p,h]=(0,i.useState)(!1),[g,f]=(0,i.useState)(null),x=async()=>{let t=!a;if(d(t),t&&e.deferred&&null===c){if(!n||!o)return void f(s("i18n.thinkingUnavailable"));h(!0),f(null);try{u(await function(e,t,n){let r=`${e}:${t}:${n}`,i=tw.get(r);if(i)return tw.delete(r),tw.set(r,i),i;let o=fetch(`/api/sessions/${encodeURIComponent(e)}/entries/${encodeURIComponent(t)}/thinking?blockIndex=${n}`).then(async e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);let t=await e.json();if("string"!=typeof t.thinking)throw Error("Invalid thinking response");return t.thinking}).catch(e=>{throw tw.delete(r),e});if(tw.set(r,o),tw.size>100){let e=tw.keys().next().value;e&&tw.delete(e)}return o}(n,o,l))}catch(e){f(e instanceof Error?e.message:String(e))}finally{h(!1)}}};return(0,r.jsxs)("div",{style:{border:"1px solid var(--border)",borderRadius:6,overflow:"hidden",fontSize:13},children:[(0,r.jsxs)("button",{onClick:()=>void x(),style:{display:"flex",alignItems:"center",gap:6,width:"100%",padding:"6px 10px",background:"var(--bg-panel)",border:"none",color:"var(--text-muted)",cursor:"pointer",fontSize:12,textAlign:"left"},children:[(0,r.jsx)("span",{children:s("i18n.thinking")}),void 0!==t&&(0,r.jsxs)("span",{style:{marginLeft:"auto",fontSize:11,color:"var(--text-dim)",fontVariantNumeric:"tabular-nums"},children:[t,"s"]})]}),a&&(0,r.jsx)("div",{style:{padding:"8px 10px",color:g?"#f87171":"var(--text-muted)",fontSize:12,lineHeight:1.6,whiteSpace:"pre-wrap",background:"var(--bg-panel)",borderTop:"1px solid var(--border)"},children:p?s("i18n.loadingThinking"):g??(e.deferred?c:e.thinking)})]})}function tE({block:e,result:t,duration:n}){var o;let{t:l}=(0,v.s)(),[s,a]=(0,i.useState)(!1),d=(o=e).rawInput??JSON.stringify(o.input,null,2),c=void 0!==e.rawInput,u=ej(e.toolName),p=t&&!t.isError?function(e){var t;let n=e.details;if(!("object"==typeof(t=n)&&null!==t&&!Array.isArray(t)))return null;let r="string"==typeof n.patch?n.patch:null;if(r)return{text:r};let i="string"==typeof n.diff?n.diff:null;return i?{text:i}:null}(t):null,h=t?t.content.filter(e=>"text"===e.type).map(e=>e.text).join("\n"):null,g=null!==h&&("(no output)"===h.trim()||""===h.trim()),f=t?.isError??!1;return(0,r.jsxs)("div",{style:{borderRadius:7,overflow:"hidden",fontSize:12,border:f?"1px solid rgba(248,113,113,0.45)":"1px solid rgba(34,197,94,0.25)",background:f?"rgba(248,113,113,0.05)":"rgba(34,197,94,0.04)"},children:[(0,r.jsxs)("button",{onClick:()=>a(e=>!e),style:{display:"flex",alignItems:"center",gap:7,width:"100%",padding:"6px 10px",background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",fontSize:12,textAlign:"left",minWidth:0},children:[(0,r.jsx)("span",{style:{color:f?"#f87171":"#16a34a",fontFamily:"var(--font-mono)",fontWeight:600,fontSize:11,flexShrink:0},children:e.toolName}),(0,r.jsx)("span",{style:{color:"var(--text-dim)",fontFamily:"var(--font-mono)",fontSize:11,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1,minWidth:0},children:c?l("chat.generatingToolInput"):function(e){let t=e.input;if(!t||"object"!=typeof t)return"";let n=Object.keys(t);return 0===n.length?"":"command"in t?String(t.command).slice(0,120):"path"in t?String(t.path).slice(0,120):"file_path"in t?String(t.file_path).slice(0,120):"pattern"in t?String(t.pattern).slice(0,120):"query"in t?String(t.query).slice(0,120):String(t[n[0]]).slice(0,120)}(e)}),void 0!==n&&(0,r.jsxs)("span",{style:{fontSize:11,color:"var(--text-dim)",flexShrink:0,fontVariantNumeric:"tabular-nums"},children:[n,"s"]}),(0,r.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"var(--text-dim)",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,transform:s?"rotate(180deg)":"none",transition:"transform 0.15s"},children:(0,r.jsx)("polyline",{points:"2 3.5 5 6.5 8 3.5"})})]}),s&&(c||!u)&&(0,r.jsx)("pre",{style:{margin:0,padding:"8px 10px",color:"var(--text-muted)",fontSize:12,lineHeight:1.5,overflow:"auto",background:"var(--bg-subtle)",borderTop:f?"1px solid rgba(248,113,113,0.25)":"1px solid rgba(34,197,94,0.2)",whiteSpace:"pre-wrap",wordBreak:"break-all"},children:d}),s&&t&&(p?(0,r.jsx)(tW,{diff:p}):(0,r.jsx)(tA,{text:h??"",isEmpty:g,isError:f}))]})}function tW({diff:e}){return(0,r.jsx)("div",{style:{borderTop:"1px solid rgba(34,197,94,0.15)",background:"var(--bg)"},children:(0,r.jsx)(t$,{text:e.text})})}function t$({text:e}){let{t}=(0,v.s)(),n=(0,i.useMemo)(()=>tm(e),[e]);if(!n)return(0,r.jsx)(tN,{text:e});let o=n.length>1;return(0,r.jsx)("div",{style:{maxHeight:560,overflowY:"auto",overflowX:"hidden",background:"var(--bg)"},children:n.map((e,n)=>(0,r.jsxs)("div",{style:{minWidth:0,borderTop:0===n?"none":"1px solid var(--border)",fontFamily:"var(--font-mono)",fontSize:12,lineHeight:1.55},children:[o&&(0,r.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"minmax(0, 1fr) minmax(0, 1fr)",position:"sticky",top:0,zIndex:1,background:"var(--bg-panel)",borderBottom:"1px solid var(--border)"},children:[(0,r.jsx)(tz,{title:e.oldPath||t("i18n.before"),side:"left"}),(0,r.jsx)(tz,{title:e.newPath||t("i18n.after"),side:"right"})]}),(0,r.jsx)("div",{style:{display:"grid",gridTemplateColumns:"minmax(0, 1fr) minmax(0, 1fr)"},children:e.rows.map((e,t)=>"hunk"===e.type?null:(0,r.jsxs)("div",{style:{display:"contents"},children:[(0,r.jsx)(tP,{cell:e.left,side:"left"}),(0,r.jsx)(tP,{cell:e.right,side:"right"})]},t))})]},n))})}function tz({title:e,side:t}){return(0,r.jsx)("div",{title:e,style:{padding:"5px 10px",color:"var(--text-dim)",borderRight:"left"===t?"1px solid var(--border)":"none",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e})}function tP({cell:e,side:t}){let n="added"===e.type?"rgba(34,197,94,0.12)":"removed"===e.type?"rgba(248,113,113,0.13)":"empty"===e.type?"var(--bg-subtle)":"transparent",i="added"===e.type?"+":"removed"===e.type?"-":" ",o="added"===e.type?"#22c55e":"removed"===e.type?"#f87171":"var(--text-dim)";return(0,r.jsxs)("div",{style:{display:"flex",minWidth:0,background:n,borderRight:"left"===t?"1px solid var(--border)":"none"},children:[(0,r.jsx)("span",{style:{width:42,padding:"0 6px",textAlign:"right",color:"var(--text-dim)",userSelect:"none",background:"var(--bg-panel)",borderRight:"1px solid var(--border)",flexShrink:0},children:e.lineNo??""}),(0,r.jsx)("span",{style:{width:18,padding:"0 5px",color:o,userSelect:"none",fontWeight:"context"===e.type||"empty"===e.type?400:700,flexShrink:0},children:i}),(0,r.jsx)("span",{style:{flex:1,minWidth:0,padding:"0 10px 0 0",color:"empty"===e.type?"var(--text-dim)":"var(--text)",whiteSpace:"pre-wrap",overflowWrap:"anywhere"},children:e.text||"\xa0"})]})}function tN({text:e}){let t=e.split(/\r?\n/);return(0,r.jsx)("div",{style:{maxHeight:520,overflowY:"auto",overflowX:"hidden",fontFamily:"var(--font-mono)",fontSize:12,lineHeight:1.55,minWidth:0},children:t.map((e,t)=>{let n=e.startsWith("@@")?"hunk":e.startsWith("+")&&!e.startsWith("+++")?"added":e.startsWith("-")&&!e.startsWith("---")?"removed":"context";return(0,r.jsxs)("div",{style:{display:"flex",background:"added"===n?"rgba(34,197,94,0.12)":"removed"===n?"rgba(248,113,113,0.13)":"hunk"===n?"rgba(96,165,250,0.12)":"transparent",borderLeft:"added"===n?"3px solid #22c55e":"removed"===n?"3px solid #f87171":"hunk"===n?"3px solid var(--accent)":"3px solid transparent"},children:[(0,r.jsx)("span",{style:{width:48,padding:"0 8px",color:"var(--text-dim)",background:"var(--bg-panel)",borderRight:"1px solid var(--border)",textAlign:"right",userSelect:"none",flexShrink:0},children:t+1}),(0,r.jsx)("span",{style:{padding:"0 10px",whiteSpace:"pre-wrap",overflowWrap:"anywhere",color:"added"===n?"#22c55e":"removed"===n?"#f87171":"hunk"===n?"var(--accent)":"var(--text)"},children:e||"\xa0"})]},t)})})}function tA({text:e,isEmpty:t,isError:n}){let{t:i}=(0,v.s)();return(0,r.jsx)("div",{style:{borderTop:`1px solid ${n?"rgba(248,113,113,0.3)":"rgba(34,197,94,0.15)"}`,background:n?"rgba(248,113,113,0.04)":"var(--bg-subtle)"},children:(0,r.jsx)("pre",{style:{margin:0,padding:"8px 10px",color:n?"#f87171":t?"var(--text-dim)":"var(--text-muted)",fontSize:12,lineHeight:1.5,overflow:"auto",maxHeight:400,background:"var(--bg)",whiteSpace:"pre-wrap",wordBreak:"break-all",fontStyle:t?"italic":"normal",opacity:t?.6:1},children:t?i("i18n.noOutput"):e})})}function tF({message:e}){let{t}=(0,v.s)(),n=tO(e.content),o=(0,i.useMemo)(()=>{let e,t,r,i,o;return e=[],t=[],r=n.match(tx),i=r?.[1]??"",o=r?.index===void 0?n:n.slice(0,r.index),i.replace(tf,(n,r,i)=>{let o=i.split(/\r?\n/).map(e=>e.trim()).filter(Boolean);return"read-files"===r?e.push(...o):t.push(...o),""}),{body:o.trim(),readFiles:e,modifiedFiles:t}},[n]),l=tS(e.timestamp);return(0,r.jsx)("div",{style:{marginBottom:16},children:(0,r.jsxs)("div",{style:{border:"1px solid var(--border)",borderRadius:8,overflow:"hidden",background:"var(--bg)"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"7px 10px",borderBottom:"1px solid var(--border)",background:"var(--bg-panel)",color:"var(--text-muted)"},children:[(0,r.jsx)("span",{style:{fontFamily:"var(--font-mono)",fontSize:11,fontWeight:650},children:"compaction"}),l&&(0,r.jsx)("span",{style:{marginLeft:"auto",color:"var(--text-dim)",fontSize:10},children:l})]}),(0,r.jsxs)("div",{style:{padding:"11px 13px 12px"},children:[(0,r.jsx)("div",{style:{color:"var(--text)",fontSize:15,fontWeight:700,lineHeight:1.35},children:t("i18n.conversationCompacted")}),(0,r.jsx)("div",{style:{marginTop:3,marginBottom:10,color:"var(--text)",fontSize:14,lineHeight:1.5},children:t("i18n.compactionDescription")}),o.body?(0,r.jsx)(th,{className:"markdown-compaction-message",children:o.body}):(0,r.jsx)("span",{style:{color:"var(--text-dim)",fontSize:12},children:t("i18n.noSummary")}),(0,r.jsx)(tD,{readFiles:o.readFiles,modifiedFiles:o.modifiedFiles})]})]})})}function tD({readFiles:e,modifiedFiles:t}){let{t:n}=(0,v.s)();if(0===e.length+t.length)return null;let i=[];return e.length>0&&i.push(`${e.length} read`),t.length>0&&i.push(`${t.length} modified`),(0,r.jsxs)("details",{className:"compaction-file-details",children:[(0,r.jsx)("summary",{children:n("i18n.fileContext",{details:i.join(", ")})}),t.length>0&&(0,r.jsx)(tB,{title:n("i18n.modifiedFiles"),files:t}),e.length>0&&(0,r.jsx)(tB,{title:n("i18n.readFiles"),files:e})]})}function tB({title:e,files:t}){return(0,r.jsxs)("div",{className:"compaction-file-section",children:[(0,r.jsx)("div",{className:"compaction-file-title",children:e}),(0,r.jsx)("ul",{className:"compaction-file-list",children:t.map(e=>(0,r.jsx)("li",{children:e},e))})]})}function tH({message:e,cwd:t,onOpenFile:n}){var o;let l,{t:s}=(0,v.s)(),a=!1===e.display,[d,c]=(0,i.useState)(!a),[u,p]=(0,i.useState)(!1),[h,g]=(0,i.useState)(!1),f=tO(e.content),x="string"==typeof(o=e.content)?[]:o.filter(e=>"image"===e.type),m=void 0!==e.details,y=m?function(e){try{return JSON.stringify(e,null,2)}catch{return String(e)}}(e.details):"",b=e.customType||"extension",k=tS(e.timestamp);return(0,r.jsx)("div",{style:{marginBottom:16},children:(0,r.jsxs)("div",{style:{border:"1px solid var(--border)",borderRadius:8,overflow:"hidden",background:a?"var(--bg-subtle)":"var(--bg)",opacity:a&&!d?.82:1},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"7px 10px",borderBottom:"1px solid var(--border)",background:"var(--bg-panel)",color:"var(--text-muted)",fontSize:12},children:[(0,r.jsx)("span",{style:{color:"var(--text-muted)",fontFamily:"var(--font-mono)",fontSize:11,fontWeight:650},children:b}),a&&(0,r.jsx)("span",{style:{color:"var(--text-dim)",fontSize:11},children:s("i18n.hiddenExtensionMessage")}),k&&(0,r.jsx)("span",{style:{marginLeft:"auto",color:"var(--text-dim)",fontSize:10},children:k})]}),d?(0,r.jsxs)("div",{style:{padding:"6px 9px"},children:[x.length>0&&(0,r.jsx)("div",{style:{display:"flex",gap:6,flexWrap:"wrap",marginBottom:8*!!f},children:x.map((e,t)=>{var n;let i=(n=e).source?"base64"===n.source.type?`data:${n.source.media_type};base64,${n.source.data}`:n.source.url??"":n.data?`data:${n.mimeType};base64,${n.data}`:"";return i?(0,r.jsx)(tg,{src:i,children:(0,r.jsx)("img",{src:i,alt:"",style:{maxWidth:240,maxHeight:240,borderRadius:6,objectFit:"contain",display:"block",border:"1px solid var(--border)"}})},t):null})}),f?(0,r.jsx)(th,{className:"markdown-custom-message",cwd:t,onOpenFile:n,children:f}):(0,r.jsx)("span",{style:{color:"var(--text-dim)",fontSize:12},children:s("i18n.noMessage")})]}):(0,r.jsx)("button",{onClick:()=>c(!0),style:{display:"block",width:"100%",padding:"8px 10px",border:"none",background:"transparent",color:"var(--text-dim)",cursor:"pointer",fontSize:12,textAlign:"left"},children:f?(l=f.replace(/\s+/g," ").trim())?l.length>140?`${l.slice(0,140)}...`:l:"Show extension message":s("i18n.showExtensionMessage")}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"4px 9px",borderTop:"1px solid var(--border)",background:"var(--bg-subtle)"},children:[f||y?(0,r.jsx)("button",{onClick:()=>{e6(f||y).then(()=>{g(!0),setTimeout(()=>g(!1),1500)})},style:{padding:"3px 7px",border:"none",background:"none",color:h?"var(--accent)":"var(--text-dim)",cursor:"pointer",fontSize:11},children:s(h?"i18n.copied":"i18n.copy")}):null,(m||a)&&(0,r.jsx)("button",{onClick:()=>{a?c(e=>!e):p(e=>!e)},style:{marginLeft:"auto",padding:"3px 7px",border:"none",background:"none",color:"var(--text-dim)",cursor:"pointer",fontSize:11},children:s(a?d?"i18n.collapse":"i18n.expand":u?"i18n.hideDetails":"i18n.showDetails")})]}),m&&(a&&d||!a&&u)&&(0,r.jsx)("pre",{style:{margin:0,padding:"9px 10px",borderTop:"1px solid var(--border)",background:"var(--bg)",color:"var(--text-muted)",fontSize:12,lineHeight:1.5,whiteSpace:"pre-wrap",wordBreak:"break-word",maxHeight:360,overflow:"auto",fontFamily:"var(--font-mono)"},children:y})]})})}function tO(e){return"string"==typeof e?e:e.filter(e=>"text"===e.type).map(e=>e.text).join("\n")}function tU({message:e,sessionId:t}){let[n,o]=(0,i.useState)(null),[l,s]=(0,i.useState)(!1),[a,d]=(0,i.useState)(null),c=!e.output&&void 0===e.exitCode&&!e.cancelled,u=e.cancelled||void 0!==e.exitCode&&0!==e.exitCode,p=t&&e.fullOutputPath?`/api/agent/${encodeURIComponent(t)}/bash-output?path=${encodeURIComponent(e.fullOutputPath)}`:null,h=e.truncated&&p&&null===n,g=n??e.output;async function f(){if(p){s(!0),d(null);try{let e=await fetch(p),t=await e.json();t.success?o(t.data?.output??""):d(t.error??"failed")}catch(e){d(String(e))}finally{s(!1)}}}let x=e.excludeFromContext?"bash (local)":"bash",m={type:"toolCall",toolCallId:`bash-${e.timestamp??""}`,toolName:x,input:{command:e.command}},v=c?void 0:{role:"toolResult",toolCallId:m.toolCallId,toolName:x,content:g?[{type:"text",text:g}]:[],isError:u,timestamp:e.timestamp};return(0,r.jsxs)("div",{style:{margin:"6px 0"},children:[(0,r.jsx)(tE,{block:m,result:v}),e.truncated&&p&&(0,r.jsxs)("div",{style:{padding:"4px 10px",fontSize:11,marginTop:-1},children:[h&&(0,r.jsx)("button",{onClick:f,disabled:l,style:{background:"none",border:"none",color:"var(--accent)",cursor:l?"default":"pointer",fontSize:11,padding:0,textDecoration:"underline"},children:l?"loading…":"view full output"}),(0,r.jsx)("a",{href:`${p}&download=1`,style:{marginLeft:10*!!h,color:"var(--accent)",fontSize:11,textDecoration:"underline"},children:"download full output"}),a&&(0,r.jsxs)("span",{style:{marginLeft:6,color:"var(--text-dim)",fontSize:11},children:["(",a,")"]})]})]})}function t_(e){if(!e||"object"!=typeof e||"string"!=typeof e.data||"string"!=typeof e.mimeType||!e.mimeType.startsWith("image/"))return!1;let t=function(e){if(!e||e.length%4!=0)return null;let t=e.endsWith("==")?2:+!!e.endsWith("="),n=e.length-t;for(let t=0;t<n;t+=1){var r;if(!((r=e.charCodeAt(t))>=65&&r<=90||r>=97&&r<=122||r>=48&&r<=57||43===r||47===r))return null}for(let t=n;t<e.length;t+=1)if("="!==e[t])return null;return e.length/4*3-t}(e.data);return null!==t&&t<=0xa00000}let tq=new Map;function tK(e){return{value:e.value,images:e.images.map(e=>({...e})),...e.docs?{docs:e.docs.map(e=>({...e}))}:{}}}function tV(e){return!e.value&&0===e.images.length&&(e.docs?.length??0)===0}function tJ(e){let t=tq.get(e);return t?tK(t):null}function tY(e,t){tV(t)?tq.delete(e):tq.set(e,tK(t))}function tG(e){tq.delete(e)}function tZ(e,t){return e.trim()?t.trim()?`${e}
3
3
 
4
4
  ${t}`:e:t}function tX(e,t,n,r){let i=[...t??[],...r].filter(t_).slice(0,10).map(({data:e,mimeType:t})=>({data:e,mimeType:t}));return{value:tZ(e,n),images:i}}function tQ(e,t,n){if(e===t)return n?tK(n):tJ(t);let r=tJ(e),i=n&&!tV(n)?tK(n):r??(n?tK(n):null),o=tJ(t);if(tG(e),!i)return o;let l=o?tX(o.value,o.images,i.value,i.images):i;return o&&!l.docs&&i.docs&&(l.docs=i.docs),tY(t,l),tK(l)}let t0=/^(text\/|application\/(json|xml|javascript|x-yaml|yaml|toml|sql|graphql|x-sh|svg))/,t1=new Set(["ts","tsx","js","jsx","mjs","cjs","vue","svelte","php","lua","r","dart","py","rb","go","rs","java","kt","swift","c","cpp","h","hpp","cs","html","htm","css","scss","less","styl","json","jsonl","yaml","yml","toml","xml","md","mdx","csv","tsv","sh","bash","zsh","sql","graphql","gql","txt","log","ini","cfg","conf","env","properties","dockerfile","makefile","gitignore","svg","bat","ps1","diff","patch","rst","tex"]);function t2(e){return e>=1048576?`${(e/1048576).toFixed(1)}MB`:e>=1024?`${Math.round(e/1024)}KB`:`${e}B`}async function t8(e,t){if(t.size>0x1900000)throw Error("文件超过 25MB 上限");let n=async n=>{let r=new FormData;return r.append("files",t,n),fetch((0,s.DP)(`/api/files/${T(e)}?type=upload&conflict=error`),{method:"POST",body:r})},r=await n(t.name),i=t.name;if(409===r.status){let e=t.name.lastIndexOf(".");i=e>0?`${t.name.slice(0,e)}-${Date.now()}${t.name.slice(e)}`:`${t.name}-${Date.now()}`,r=await n(i)}let o=await r.json().catch(()=>null);if(!r.ok||!o?.uploaded?.includes(i))throw Error(o?.errors?.[0]?.error??o?.error??`上传失败(HTTP ${r.status})`);return`${e.replace(/\/+$/,"")}/${i}`}function t4(e){let t=/(?:^|\s)@"([^"\n]*)$/.exec(e);if(t)return{start:e.length-(t[1].length+2),query:t[1],quoted:!0};let n=/(?:^|\s)@([^\s"]*)$/.exec(e);return n?{start:e.length-(n[1].length+1),query:n[1],quoted:!1}:null}function t6(e){let t=0;for(let n=0;n<e.length;n++)"/"===e[n]&&t++;return t}function t5(e,t){if(!e)return!0;let n=0;for(let r=0;r<t.length&&n<e.length;r++)t[r]===e[n]&&n++;return n===e.length}function t3(e,t){let n=t?`${e}/`:e;return n.includes(" ")?`@"${n}" `:`@${n} `}let t9="(max-width: 640px)";function t7(e){if(!window.matchMedia)return()=>{};let t=window.matchMedia(t9);return t.addEventListener("change",e),()=>t.removeEventListener("change",e)}function ne(){return!!window.matchMedia&&window.matchMedia(t9).matches}function nt(){return!1}function nn(){return(0,i.useSyncExternalStore)(t7,ne,nt)}let nr="ly-ai-assistant",ni=[];function no(e){if(!e||"object"!=typeof e)return null;let t="string"==typeof e.label?e.label.trim():"";return t?{label:t,sendDirect:!0===e.sendDirect,prompt:"string"==typeof e.prompt?e.prompt:""}:null}function nl(){return`doc-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function ns(e){return{fileName:e.fileName,size:e.size,inlineContent:e.inlineContent,serverPath:e.serverPath}}function na(e){return(e??[]).map(e=>({id:nl(),fileName:e.fileName,size:e.size,inlineContent:e.inlineContent,serverPath:e.serverPath,status:"ready"}))}let nd=["off","read-only","default","full"],nc={off:"none","read-only":"read-only",default:"default",full:"full"},nu=new Intl.Collator(void 0,{numeric:!0,sensitivity:"base"});function np(e,t){return nu.compare(e.name||e.modelId,t.name||t.modelId)||nu.compare(e.provider,t.provider)||nu.compare(e.modelId,t.modelId)}let nh=["auto","off","minimal","low","medium","high","xhigh","max"],ng={auto:"chat.thinkingUseDefault",off:"chat.thinkingOff",minimal:"chat.thinkingMinimal",low:"chat.thinkingLow",medium:"chat.thinkingMedium",high:"chat.thinkingHigh",xhigh:"chat.thinkingXhigh",max:"chat.thinkingMax"};function nf(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${Math.round(e/1e3)}k`:e.toLocaleString()}let nx=[{name:"compact",description:"chat.commandCompact",source:"builtin"},{name:"reload",description:"chat.commandReload",source:"builtin"},{name:"name",description:"chat.commandName",source:"builtin"},{name:"session",description:"chat.commandSession",source:"builtin"},{name:"copy",description:"chat.commandCopy",source:"builtin"}],nm=["builtin","extension","prompt","skill"],nv={builtin:"chat.builtIn",extension:"chat.extensions",prompt:"chat.prompts",skill:"chat.skills"},ny={builtin:0,extension:1,prompt:2,skill:3};function nb(e,t,n){let r=e.name.toLowerCase(),i=nk(e,n).toLowerCase();return r===t?0:r.startsWith(t)?1:r.includes(t)?2:i.includes(t)?3:4}function nk(e,t){return"builtin"===e.source?t(e.description):e.description??""}function nw(e,t){return"skill"===e.source&&!!e.name.startsWith("skill:")&&!0===t[e.name.slice(6)]}function nj(e){return{data:e.data,mimeType:e.mimeType}}function nS(e,t){let n=t.trim();return n?e?`${e}