cc-viewer 1.6.254 → 1.6.256

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 (65) hide show
  1. package/dist/assets/App-BxUDsD3t.js +1 -0
  2. package/dist/assets/{MdxEditorPanel-BLBytlOn.js → MdxEditorPanel-DHU0Ardx.js} +1 -1
  3. package/dist/assets/Mobile-Cqm4xH5j.js +1 -0
  4. package/dist/assets/ProxyModal-83mKKqyB.js +2 -0
  5. package/dist/assets/{ProxyModal-CNPuwcCz.css → ProxyModal-DzTu4uGE.css} +1 -1
  6. package/dist/assets/{_baseUniq-Ck0avQQW.js → _baseUniq-DXjKWfhk.js} +1 -1
  7. package/dist/assets/{arc-DoPSafE-.js → arc-DsQxkW5T.js} +1 -1
  8. package/dist/assets/{architectureDiagram-Q4EWVU46-CXwNDWVJ.js → architectureDiagram-Q4EWVU46-D24v83bq.js} +1 -1
  9. package/dist/assets/{blockDiagram-DXYQGD6D-DqcTnX5B.js → blockDiagram-DXYQGD6D-D5ezdfnY.js} +1 -1
  10. package/dist/assets/{c4Diagram-AHTNJAMY-CzZqJcRw.js → c4Diagram-AHTNJAMY-g5VhpI4X.js} +1 -1
  11. package/dist/assets/{channel-BPHggAg1.js → channel-Bohj9Wcp.js} +1 -1
  12. package/dist/assets/{chunk-4BX2VUAB-_j7urp68.js → chunk-4BX2VUAB-5LFKrDPS.js} +1 -1
  13. package/dist/assets/{chunk-4TB4RGXK-DSm-83N3.js → chunk-4TB4RGXK-B7I8vecx.js} +1 -1
  14. package/dist/assets/{chunk-55IACEB6-vMas_Dfs.js → chunk-55IACEB6-BBIiUctL.js} +1 -1
  15. package/dist/assets/{chunk-EDXVE4YY-DJmHQIxZ.js → chunk-EDXVE4YY-BYpcDSKa.js} +1 -1
  16. package/dist/assets/{chunk-FMBD7UC4-C6U6noME.js → chunk-FMBD7UC4-Dpw6TUJP.js} +1 -1
  17. package/dist/assets/{chunk-OYMX7WX6-DV09n2XA.js → chunk-OYMX7WX6-1R1GcGjy.js} +1 -1
  18. package/dist/assets/{chunk-QZHKN3VN-Bwa__aOF.js → chunk-QZHKN3VN-B43hQ2vS.js} +1 -1
  19. package/dist/assets/{chunk-YZCP3GAM-CBRCt3K4.js → chunk-YZCP3GAM-1IZth8n2.js} +1 -1
  20. package/dist/assets/{classDiagram-6PBFFD2Q-DKCDn4jL.js → classDiagram-6PBFFD2Q-BBoAxatM.js} +1 -1
  21. package/dist/assets/{classDiagram-v2-HSJHXN6E-DKCDn4jL.js → classDiagram-v2-HSJHXN6E-BBoAxatM.js} +1 -1
  22. package/dist/assets/clone-Cc7ofJ6W.js +1 -0
  23. package/dist/assets/{cose-bilkent-S5V4N54A-BwOVr318.js → cose-bilkent-S5V4N54A-D05nug0R.js} +1 -1
  24. package/dist/assets/{dagre-KV5264BT-BrIcbm5i.js → dagre-KV5264BT-DZ9d_ZUE.js} +1 -1
  25. package/dist/assets/{diagram-5BDNPKRD-C5qxQhGg.js → diagram-5BDNPKRD-DdyX_gXl.js} +1 -1
  26. package/dist/assets/{diagram-G4DWMVQ6-DsH7kdR2.js → diagram-G4DWMVQ6-cjq8tNSZ.js} +1 -1
  27. package/dist/assets/{diagram-MMDJMWI5-RE-fR3Cz.js → diagram-MMDJMWI5-NiKFms6e.js} +1 -1
  28. package/dist/assets/{diagram-TYMM5635-voZ1zyYa.js → diagram-TYMM5635-Dpig5X9-.js} +1 -1
  29. package/dist/assets/{erDiagram-SMLLAGMA-PrA2wCsY.js → erDiagram-SMLLAGMA-D2sWo3Zv.js} +1 -1
  30. package/dist/assets/{flowDiagram-DWJPFMVM-Ce7hKuco.js → flowDiagram-DWJPFMVM-D85Dj_yq.js} +1 -1
  31. package/dist/assets/{ganttDiagram-T4ZO3ILL-CDVZdk1O.js → ganttDiagram-T4ZO3ILL-DxAjpfgn.js} +1 -1
  32. package/dist/assets/{gitGraphDiagram-UUTBAWPF-ud920O99.js → gitGraphDiagram-UUTBAWPF-BO9g8cL0.js} +1 -1
  33. package/dist/assets/{graph-S7ZyOMd5.js → graph-BfcDIvNk.js} +1 -1
  34. package/dist/assets/index-aBYCRImE.js +2 -0
  35. package/dist/assets/{infoDiagram-42DDH7IO-DqmBGCgd.js → infoDiagram-42DDH7IO-BnOW3PpN.js} +1 -1
  36. package/dist/assets/{ishikawaDiagram-UXIWVN3A-TF8Q_01t.js → ishikawaDiagram-UXIWVN3A-BdRWHTx5.js} +1 -1
  37. package/dist/assets/{journeyDiagram-VCZTEJTY-y5GmBD-h.js → journeyDiagram-VCZTEJTY-6-pOxb-c.js} +1 -1
  38. package/dist/assets/{kanban-definition-6JOO6SKY-B-VIbcAu.js → kanban-definition-6JOO6SKY-BBX4NlcN.js} +1 -1
  39. package/dist/assets/{layout-Ye8iwdjE.js → layout-DtQNOuH0.js} +1 -1
  40. package/dist/assets/{linear-B6rvw7LC.js → linear-6Y3OZ7u2.js} +1 -1
  41. package/dist/assets/{mermaid.core-BeZMQR0-.js → mermaid.core-CAsnLdlL.js} +2 -2
  42. package/dist/assets/{min-Ckbo1P6U.js → min-BRPZJLHh.js} +1 -1
  43. package/dist/assets/{mindmap-definition-QFDTVHPH-CnCiGofR.js → mindmap-definition-QFDTVHPH-BkmfcnFE.js} +1 -1
  44. package/dist/assets/{pieDiagram-DEJITSTG-BqIhPE7F.js → pieDiagram-DEJITSTG-D4a_1EvH.js} +1 -1
  45. package/dist/assets/{quadrantDiagram-34T5L4WZ-BUUOld6m.js → quadrantDiagram-34T5L4WZ-kKniISLU.js} +1 -1
  46. package/dist/assets/{requirementDiagram-MS252O5E-nXIfCEms.js → requirementDiagram-MS252O5E-DPikXO53.js} +1 -1
  47. package/dist/assets/{sankeyDiagram-XADWPNL6-DJThfilj.js → sankeyDiagram-XADWPNL6--rY8uDK7.js} +1 -1
  48. package/dist/assets/{sequenceDiagram-FGHM5R23-CQiVWsC6.js → sequenceDiagram-FGHM5R23-C57z6bd_.js} +1 -1
  49. package/dist/assets/{stateDiagram-FHFEXIEX-CxsMHyky.js → stateDiagram-FHFEXIEX-D7q_cBTL.js} +1 -1
  50. package/dist/assets/{stateDiagram-v2-QKLJ7IA2-Byzz6ymQ.js → stateDiagram-v2-QKLJ7IA2-Co3EU6Nf.js} +1 -1
  51. package/dist/assets/{timeline-definition-GMOUNBTQ-CkQgIeyQ.js → timeline-definition-GMOUNBTQ-DBV-lv69.js} +1 -1
  52. package/dist/assets/vendor-markdown-BFrYfpb0.js +1 -0
  53. package/dist/assets/{vennDiagram-DHZGUBPP-CPS3ODG3.js → vennDiagram-DHZGUBPP-ngWDn_ip.js} +1 -1
  54. package/dist/assets/{wardley-RL74JXVD-D6zaNgzM.js → wardley-RL74JXVD-BhMXVlU_.js} +1 -1
  55. package/dist/assets/{wardleyDiagram-NUSXRM2D-Bzaw757Q.js → wardleyDiagram-NUSXRM2D-lpdygHK-.js} +1 -1
  56. package/dist/assets/{xychartDiagram-5P7HB3ND-DCZ9r4uS.js → xychartDiagram-5P7HB3ND-DVafENtB.js} +1 -1
  57. package/dist/index.html +1 -1
  58. package/package.json +27 -4
  59. package/server.js +26 -4
  60. package/dist/assets/App-BE6CjL4z.js +0 -1
  61. package/dist/assets/Mobile-CCp4P4P4.js +0 -1
  62. package/dist/assets/ProxyModal-DFqdiF5j.js +0 -2
  63. package/dist/assets/clone-BbE0e7rU.js +0 -1
  64. package/dist/assets/index-WlCEIiNa.js +0 -2
  65. package/dist/assets/vendor-markdown-Bpu4AByL.js +0 -1
@@ -0,0 +1 @@
1
+ var __defProp=Object.defineProperty,__publicField=(obj,key,value)=>((obj,key,value)=>key in obj?__defProp(obj,key,{enumerable:!0,configurable:!0,writable:!0,value:value}):obj[key]=value)(obj,"symbol"!=typeof key?key+"":key,value);import{j as jsxRuntimeExports}from"./vendor-codemirror-2nbmPewy.js";import{a as reactExports,I as Icon,b as _extends,T as Tag,P as Popover,R as React__default,s as staticMethods,q as Collapse,S as Spin,d as reactDomExports,t as RefIcon$7,u as Space,D as Dropdown,v as Input,w as RefIcon$9,i as Button,x as RefIcon$a,M as Modal,o as RefIcon$b,y as Tabs,z as Drawer,l as Select,m as Switch,n as Radio,E as Empty,L as List,A as Tooltip,F as Typography,G as RefIcon$c,H as RefIcon$d,C as ConfigProvider,J as Layout,K as Alert,N as Checkbox,j as RefIcon$f,k as RefIcon$g}from"./vendor-antd-BeN8xqGk.js";import{k as styles$7,E as CachePopoverContent,o as isSystemText,p as classifyUserContent,q as isMainAgent,d as computeTokenStats,e as computeToolUsageStats,g as computeSkillUsageStats,m as formatTokenCount,C as ConceptHelp,h as computeCacheRebuildStats,L as resolveTeammateNames,j as classifyRequest,N as resolveCalibrationTokens,w as AUTO_COMPACT_USABLE_RATIO,O as OPTIMISTIC_CLEAR_PERCENT,Q as RefIcon$5,U as RefIcon$6,V as RefIcon$8,M as MemoryDetailModal,P as PluginModal,G as ProcessModal,H as ProxyModal,S as SkillsManagerModal,n as appConfig,W as getModelShort,X as formatRequestTag,Y as renderMarkdown,Z as restoreSlimmedEntry,_ as stripPrivateKeys,$ as isClaudeMdReminder,a0 as isSkillsReminder,a1 as hasClaudeMdReminder,a2 as hasSkillsReminder,a3 as extractCachedContent,A as AppBase,a4 as filterRelevantRequests,a5 as findPrevMainAgentTimestamp,t as uploadFileAndGetPath,T as TerminalWsProvider,y as ApprovalModal,r as styles$8,R as RefIcon$e,B as ChatView,J as OpenFolderIcon}from"./ProxyModal-83mKKqyB.js";import{t,S as SettingsContext,a as apiUrl,L as LANG_OPTIONS,c as setLang,g as getLang,s as setViewMode,d as isMobile}from"./index-aBYCRImE.js";import{Q as QRCodeCanvas}from"./vendor-qrcode-BFV_3WPO.js";import"./vendor-mdxeditor-C7DYEBoH.js";import"./vendor-xterm-DckPrCx1.js";import"./vendor-markdown-BFrYfpb0.js";import"./vendor-highlight-IFTJ9nxW.js";import"./vendor-virtuoso-COKXGpsa.js";var BarChartOutlined$1={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M888 792H200V168c0-4.4-3.6-8-8-8h-56c-4.4 0-8 3.6-8 8v688c0 4.4 3.6 8 8 8h752c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zm-600-80h56c4.4 0 8-3.6 8-8V560c0-4.4-3.6-8-8-8h-56c-4.4 0-8 3.6-8 8v144c0 4.4 3.6 8 8 8zm152 0h56c4.4 0 8-3.6 8-8V384c0-4.4-3.6-8-8-8h-56c-4.4 0-8 3.6-8 8v320c0 4.4 3.6 8 8 8zm152 0h56c4.4 0 8-3.6 8-8V462c0-4.4-3.6-8-8-8h-56c-4.4 0-8 3.6-8 8v242c0 4.4 3.6 8 8 8zm152 0h56c4.4 0 8-3.6 8-8V304c0-4.4-3.6-8-8-8h-56c-4.4 0-8 3.6-8 8v400c0 4.4 3.6 8 8 8z"}}]},name:"bar-chart",theme:"outlined"},BarChartOutlined=function(props,ref){return reactExports.createElement(Icon,_extends({},props,{ref:ref,icon:BarChartOutlined$1}))},RefIcon$4=reactExports.forwardRef(BarChartOutlined),CodeOutlined$1={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M516 673c0 4.4 3.4 8 7.5 8h185c4.1 0 7.5-3.6 7.5-8v-48c0-4.4-3.4-8-7.5-8h-185c-4.1 0-7.5 3.6-7.5 8v48zm-194.9 6.1l192-161c3.8-3.2 3.8-9.1 0-12.3l-192-160.9A7.95 7.95 0 00308 351v62.7c0 2.4 1 4.6 2.9 6.1L420.7 512l-109.8 92.2a8.1 8.1 0 00-2.9 6.1V673c0 6.8 7.9 10.5 13.1 6.1zM880 112H144c-17.7 0-32 14.3-32 32v736c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V144c0-17.7-14.3-32-32-32zm-40 728H184V184h656v656z"}}]},name:"code",theme:"outlined"},CodeOutlined=function(props,ref){return reactExports.createElement(Icon,_extends({},props,{ref:ref,icon:CodeOutlined$1}))},RefIcon$3=reactExports.forwardRef(CodeOutlined),ExportOutlined$1={icon:{tag:"svg",attrs:{"fill-rule":"evenodd",viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M880 912H144c-17.7 0-32-14.3-32-32V144c0-17.7 14.3-32 32-32h360c4.4 0 8 3.6 8 8v56c0 4.4-3.6 8-8 8H184v656h656V520c0-4.4 3.6-8 8-8h56c4.4 0 8 3.6 8 8v360c0 17.7-14.3 32-32 32zM770.87 199.13l-52.2-52.2a8.01 8.01 0 014.7-13.6l179.4-21c5.1-.6 9.5 3.7 8.9 8.9l-21 179.4c-.8 6.6-8.9 9.4-13.6 4.7l-52.4-52.4-256.2 256.2a8.03 8.03 0 01-11.3 0l-42.4-42.4a8.03 8.03 0 010-11.3l256.1-256.3z"}}]},name:"export",theme:"outlined"},ExportOutlined=function(props,ref){return reactExports.createElement(Icon,_extends({},props,{ref:ref,icon:ExportOutlined$1}))},RefIcon$2=reactExports.forwardRef(ExportOutlined),ImportOutlined$1={icon:{tag:"svg",attrs:{"fill-rule":"evenodd",viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M880 912H144c-17.7 0-32-14.3-32-32V144c0-17.7 14.3-32 32-32h360c4.4 0 8 3.6 8 8v56c0 4.4-3.6 8-8 8H184v656h656V520c0-4.4 3.6-8 8-8h56c4.4 0 8 3.6 8 8v360c0 17.7-14.3 32-32 32zM653.3 424.6l52.2 52.2a8.01 8.01 0 01-4.7 13.6l-179.4 21c-5.1.6-9.5-3.7-8.9-8.9l21-179.4c.8-6.6 8.9-9.4 13.6-4.7l52.4 52.4 256.2-256.2c3.1-3.1 8.2-3.1 11.3 0l42.4 42.4c3.1 3.1 3.1 8.2 0 11.3L653.3 424.6z"}}]},name:"import",theme:"outlined"},ImportOutlined=function(props,ref){return reactExports.createElement(Icon,_extends({},props,{ref:ref,icon:ImportOutlined$1}))},RefIcon$1=reactExports.forwardRef(ImportOutlined),MessageOutlined$1={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M464 512a48 48 0 1096 0 48 48 0 10-96 0zm200 0a48 48 0 1096 0 48 48 0 10-96 0zm-400 0a48 48 0 1096 0 48 48 0 10-96 0zm661.2-173.6c-22.6-53.7-55-101.9-96.3-143.3a444.35 444.35 0 00-143.3-96.3C630.6 75.7 572.2 64 512 64h-2c-60.6.3-119.3 12.3-174.5 35.9a445.35 445.35 0 00-142 96.5c-40.9 41.3-73 89.3-95.2 142.8-23 55.4-34.6 114.3-34.3 174.9A449.4 449.4 0 00112 714v152a46 46 0 0046 46h152.1A449.4 449.4 0 00510 960h2.1c59.9 0 118-11.6 172.7-34.3a444.48 444.48 0 00142.8-95.2c41.3-40.9 73.8-88.7 96.5-142 23.6-55.2 35.6-113.9 35.9-174.5.3-60.9-11.5-120-34.8-175.6zm-151.1 438C704 845.8 611 884 512 884h-1.7c-60.3-.3-120.2-15.3-173.1-43.5l-8.4-4.5H188V695.2l-4.5-8.4C155.3 633.9 140.3 574 140 513.7c-.4-99.7 37.7-193.3 107.6-263.8 69.8-70.5 163.1-109.5 262.8-109.9h1.7c50 0 98.5 9.7 144.2 28.9 44.6 18.7 84.6 45.6 119 80 34.3 34.3 61.3 74.4 80 119 19.4 46.2 29.1 95.2 28.9 145.8-.6 99.6-39.7 192.9-110.1 262.7z"}}]},name:"message",theme:"outlined"},MessageOutlined=function(props,ref){return reactExports.createElement(Icon,_extends({},props,{ref:ref,icon:MessageOutlined$1}))},RefIcon=reactExports.forwardRef(MessageOutlined);const POPOVER_OVERLAY_STYLE={background:"var(--bg-elevated)",border:"1px solid var(--border-hover)",borderRadius:8,padding:"8px 8px"};const LiveTagPopover$1=reactExports.memo(function({isLocalLog:isLocalLog,localLogFile:localLogFile,cachePopoverOpen:cachePopoverOpen,onOpenChange:onOpenChange,requests:requests,serverCachedContent:serverCachedContent,contextPercent:contextPercent,contextTokens:contextTokens,ctxColor:ctxColor,onSkillImported:onSkillImported,fsSkills:fsSkills,memory:memory,memoryRefreshing:memoryRefreshing,claudeMd:claudeMd,calibrationModel:calibrationModel,onCalibrationModelChange:onCalibrationModelChange,onOpenMemoryDetail:onOpenMemoryDetail,onOpenClaudeMd:onOpenClaudeMd,onOpenSkillsModal:onOpenSkillsModal,onRefreshMemory:onRefreshMemory,projectName:projectName}){const triggerStyle=reactExports.useMemo(()=>({"--ctx-color":ctxColor,"--ctx-percent":`${contextPercent}%`}),[ctxColor,contextPercent]);return isLocalLog?jsxRuntimeExports.jsx(Tag,{className:`${styles$7.liveTag} ${styles$7.liveTagHistory}`,children:jsxRuntimeExports.jsx("span",{className:styles$7.liveTagText,children:t("ui.historyLog",{file:localLogFile})})}):jsxRuntimeExports.jsx(Popover,{content:cachePopoverOpen?jsxRuntimeExports.jsx(CachePopoverContent,{requests:requests,serverCachedContent:serverCachedContent,contextPercent:contextPercent,contextTokens:contextTokens,fsSkills:fsSkills,memory:memory,memoryRefreshing:memoryRefreshing,claudeMd:claudeMd,calibrationModel:calibrationModel,onCalibrationModelChange:onCalibrationModelChange,onOpenMemoryDetail:onOpenMemoryDetail,onOpenClaudeMd:onOpenClaudeMd,onOpenSkillsModal:onOpenSkillsModal,onSkillImported:onSkillImported,onRefreshMemory:onRefreshMemory}):jsxRuntimeExports.jsx("div",{className:styles$7.cachePopoverPlaceholder}),trigger:"hover",placement:"topRight",overlayInnerStyle:POPOVER_OVERLAY_STYLE,onOpenChange:onOpenChange,children:jsxRuntimeExports.jsxs("span",{className:styles$7.liveTag,style:triggerStyle,children:[jsxRuntimeExports.jsx("span",{className:styles$7.liveTagFill}),jsxRuntimeExports.jsx("span",{className:styles$7.liveTagContent,children:jsxRuntimeExports.jsx("span",{className:styles$7.liveTagText,children:contextTokens>0?`${(contextTokens/1e3).toFixed(1)}K (${contextPercent}%)`:`${contextPercent}%`})})]})})}),CALIBRATION_MODELS=appConfig.calibrationModels,LEGACY_CALIBRATION_MIGRATION={"opus-4.7-1m":"1m","sonnet-4.6":"200k",glm5:"200k","kimi-k2.5":"200k","minimax-2.1":"200k","Qwen 3.5":"200k"};function readCalibrationModel(){const raw=localStorage.getItem("ccv_calibrationModel")||"auto",migrated=LEGACY_CALIBRATION_MIGRATION[raw]||raw;return CALIBRATION_MODELS.some(m=>m.value===migrated)?migrated:"auto"}const _AppHeader=class _AppHeader extends React__default.Component{constructor(props){super(props),__publicField(this,"reloadFsSkills",async()=>{if(this.props.isLocalLog)return{ok:!1,reason:"local_log"};const seq=++this._fsSkillsSeq;try{const r=await fetch(apiUrl("/api/skills")),data=await r.json();if(seq!==this._fsSkillsSeq)return{ok:!1,reason:"stale"};if(!r.ok||!data.ok||!Array.isArray(data.skills)){const reason=data&&data.error||`http:${r.status}`;return this.setState(prev=>({_fsSkills:!!Array.isArray(prev._fsSkills)&&prev._fsSkills})),{ok:!1,reason:reason}}return this.setState({_fsSkills:data.skills}),{ok:!0,skills:data.skills}}catch(e){return seq===this._fsSkillsSeq&&this.setState(prev=>({_fsSkills:!!Array.isArray(prev._fsSkills)&&prev._fsSkills})),{ok:!1,reason:e.message||"network"}}}),__publicField(this,"loadMemory",async()=>{const seq=++this._memorySeq;try{const r=await fetch(apiUrl("/api/project-memory")),data=await r.json();if(seq!==this._memorySeq)return;if(!r.ok)return void this.setState({_memory:!1});this.setState({_memory:data})}catch{seq===this._memorySeq&&this.setState({_memory:!1})}}),__publicField(this,"handleRefreshMemory",async()=>{if(this.state._memoryRefreshing)return;this.setState({_memoryRefreshing:!0});const seq=++this._memorySeq;let ok=!1,stale=!1;try{const r=await fetch(apiUrl("/api/project-memory")),data=await r.json();seq!==this._memorySeq?stale=!0:r.ok?(this.setState({_memory:data}),ok=!0):this.setState({_memory:!1})}catch{seq!==this._memorySeq?stale=!0:this.setState({_memory:!1})}finally{stale||this.setState({_memoryRefreshing:!1})}stale||(ok?staticMethods.success(t("ui.memoryRefreshSuccess")):staticMethods.error(t("ui.memoryRefreshFailed"),5))}),__publicField(this,"handleCachePopoverOpenChange",open=>{this.setState({_cachePopoverOpen:open}),open||(this._cacheScrollInited=!1),open&&null===this.state._fsSkills&&!this.props.isLocalLog&&this.reloadFsSkills(),open&&null===this.state._memory&&this.loadMemory(),open&&null===this.state._claudeMd&&this.loadClaudeMdList()}),__publicField(this,"loadClaudeMdList",async()=>{const seq=++this._claudeMdSeq;try{const r=await fetch(apiUrl("/api/claude-md")),data=await r.json();if(seq!==this._claudeMdSeq)return;if(!r.ok||!Array.isArray(data.entries))return void this.setState({_claudeMd:!1});this.setState({_claudeMd:data.entries})}catch{seq===this._claudeMdSeq&&this.setState({_claudeMd:!1})}}),__publicField(this,"loadClaudeMdDetail",async(id,tail,scope)=>{const seq=++this._claudeMdDetailSeq,title=`${t("global"===scope?"ui.claudeMdScopeGlobal":"ui.claudeMdScopeProject")} · ${tail}`;this.setState({_claudeMdDetail:{name:title,loading:!0}});try{const r=await fetch(apiUrl(`/api/claude-md?id=${encodeURIComponent(id)}`)),data=await r.json();if(seq!==this._claudeMdDetailSeq)return;if(!r.ok)return void this.setState({_claudeMdDetail:{name:title,error:data.error||`http:${r.status}`}});this.setState({_claudeMdDetail:{name:title,content:data.content||""}})}catch(e){seq===this._claudeMdDetailSeq&&this.setState({_claudeMdDetail:{name:title,error:e.message||"network"}})}}),__publicField(this,"loadMemoryDetail",async name=>{const seq=++this._memoryDetailSeq;this.setState({_memoryDetail:{name:name,loading:!0}});try{const r=await fetch(apiUrl(`/api/project-memory?file=${encodeURIComponent(name)}`)),data=await r.json();if(seq!==this._memoryDetailSeq)return;if(!r.ok)return void this.setState({_memoryDetail:{name:name,error:data.error||`http:${r.status}`}});this.setState({_memoryDetail:{name:name,content:data.content||""}})}catch(e){seq===this._memoryDetailSeq&&this.setState({_memoryDetail:{name:name,error:e.message||"network"}})}}),__publicField(this,"handleShowPrompts",()=>{this.setState({promptModalVisible:!0,promptData:this.extractUserPrompts()})}),__publicField(this,"handleExportPromptsTxt",()=>{const prompts=this.state.promptData;if(!prompts||0===prompts.length)return;const blocks=[];for(const p of prompts){const lines=[],ts=p.timestamp?new Date(p.timestamp).toLocaleString():"";ts&&lines.push(`${ts}:\n`);const textParts=(p.segments||[]).filter(seg=>"text"===seg.type).map(seg=>seg.content);textParts.length>0&&lines.push(textParts.join("\n")),blocks.push(lines.join("\n"))}if(0===blocks.length)return;const blob=new Blob([blocks.join("\n\n\n\n")],{type:"text/plain;charset=utf-8"}),url=URL.createObjectURL(blob),a=document.createElement("a");a.href=url,a.download=`user-prompts-${(new Date).toISOString().slice(0,10)}.txt`,a.click(),URL.revokeObjectURL(url)}),__publicField(this,"handleCalibrationModelChange",value=>{this.setState({calibrationModel:value}),localStorage.setItem("ccv_calibrationModel",value)}),__publicField(this,"handleShowProjectStats",()=>{this.setState({projectStatsVisible:!0,projectStatsLoading:!0}),fetch(apiUrl("/api/project-stats")).then(res=>{if(!res.ok)throw new Error("not found");return res.json()}).then(data=>this.setState({projectStats:data,projectStatsLoading:!1})).catch(()=>this.setState({projectStats:null,projectStatsLoading:!1}))}),__publicField(this,"handleShowPlugins",()=>this.setState({pluginModalVisible:!0})),__publicField(this,"handleShowProcesses",()=>this.setState({processModalVisible:!0})),__publicField(this,"handleOpenSkillsModal",async()=>{const cached=this.state._fsSkills,needFetch=!Array.isArray(cached);if(this.setState(prev=>{var _a;return{_skillsModal:{open:!0,loading:needFetch,skills:Array.isArray(cached)?cached:[],error:null,toggling:(null==(_a=prev._skillsModal)?void 0:_a.toggling)||new Set},_cachePopoverOpen:!1}}),needFetch){const result=await this.reloadFsSkills();this.setState(prev=>({_skillsModal:{...prev._skillsModal,loading:!1,skills:result.ok?result.skills:[],error:result.ok?null:result.reason}}))}}),__publicField(this,"handleToggleSkill",async skill=>{var _a,_b;const key=`${skill.source}-${skill.name}`;if(null==(_b=null==(_a=this.state._skillsModal)?void 0:_a.toggling)?void 0:_b.has(key))return;const enable=!skill.enabled,flipEnabled=target=>s=>s.source===skill.source&&s.name===skill.name?{...s,enabled:target}:s;this.setState(prev=>{const next=new Set(prev._skillsModal.toggling);return next.add(key),{_skillsModal:{...prev._skillsModal,toggling:next,skills:prev._skillsModal.skills.map(flipEnabled(enable))}}});try{const r=await fetch(apiUrl("/api/skills/toggle"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({source:skill.source,name:skill.name,enable:enable})}),data=await r.json();if(!r.ok)return this.setState(prev=>({_skillsModal:{...prev._skillsModal,skills:prev._skillsModal.skills.map(flipEnabled(!enable))}})),void("DEST_CONFLICT"===data.code?staticMethods.error(t("ui.skillToggleConflict",{name:skill.name})):staticMethods.error(t("ui.skillToggleFailed",{reason:data.error||"unknown"})));this.setState(prev=>({_fsSkills:Array.isArray(prev._fsSkills)?prev._fsSkills.map(s=>s.source===skill.source&&s.name===skill.name?{...s,enabled:enable}:s):prev._fsSkills}));const result=await this.reloadFsSkills();result.ok&&this.setState(prev=>{const orderMap=new Map(prev._skillsModal.skills.map((s,i)=>[`${s.source}-${s.name}`,i])),merged=[...result.skills].sort((a,b)=>{const ai=orderMap.get(`${a.source}-${a.name}`),bi=orderMap.get(`${b.source}-${b.name}`);return void 0===ai&&void 0===bi?0:void 0===ai?1:void 0===bi?-1:ai-bi});return{_skillsModal:{...prev._skillsModal,skills:merged}}})}catch(e){this.setState(prev=>({_skillsModal:{...prev._skillsModal,skills:prev._skillsModal.skills.map(flipEnabled(!enable))}})),staticMethods.error(t("ui.skillToggleFailed",{reason:e.message}))}finally{this.setState(prev=>{const next=new Set(prev._skillsModal.toggling);return next.delete(key),{_skillsModal:{...prev._skillsModal,toggling:next}}})}}),this.state={countdownText:"",promptModalVisible:!1,promptData:[],promptViewMode:"original",settingsDrawerVisible:!1,globalSettingsVisible:!1,projectStatsVisible:!1,projectStats:null,projectStatsLoading:!1,localUrl:"",pluginModalVisible:!1,processModalVisible:!1,logoDropdownOpen:!1,cacheHighlightIdx:null,cacheHighlightFading:!1,calibrationModel:readCalibrationModel(),proxyModalVisible:!1,logDirDraft:null,qrPopoverOpen:!1,_skillsModal:{open:!1,loading:!1,skills:[],error:null,toggling:new Set},_fsSkills:null,_memory:null,_memoryRefreshing:!1,_memoryDetail:null,_claudeMd:null,_claudeMdDetail:null},this._countdownTimer=null,this._expiredTimer=null,this._fsSkillsSeq=0,this._memorySeq=0,this._memoryDetailSeq=0,this._claudeMdSeq=0,this._claudeMdDetailSeq=0,this.updateCountdown=this.updateCountdown.bind(this)}componentDidMount(){this.startCountdown(),fetch(apiUrl("/api/local-url")).then(r=>r.json()).then(data=>{data.url&&this.setState({localUrl:data.url})}).catch(()=>{}),this.context._claudeSettingsReady.then(data=>{data&&data.model&&this.setState({settingsModel:data.model})}),this.props.isLocalLog||this.reloadFsSkills()}componentDidUpdate(prevProps){prevProps.cacheExpireAt!==this.props.cacheExpireAt&&this.startCountdown(),prevProps.projectName!==this.props.projectName&&(this._fsSkillsSeq++,this.setState({_fsSkills:null}),!this.props.isLocalLog&&this.props.projectName&&this.reloadFsSkills(),this._memorySeq++,this.setState({_memory:null,_memoryDetail:null,_memoryRefreshing:!1}),this._claudeMdSeq++,this._claudeMdDetailSeq++,this.setState({_claudeMd:null,_claudeMdDetail:null}))}shouldComponentUpdate(nextProps,nextState){return nextProps.requests!==this.props.requests||nextProps.requestCount!==this.props.requestCount||nextProps.viewMode!==this.props.viewMode||nextProps.cacheExpireAt!==this.props.cacheExpireAt||nextProps.cacheType!==this.props.cacheType||nextProps.isLocalLog!==this.props.isLocalLog||nextProps.localLogFile!==this.props.localLogFile||nextProps.projectName!==this.props.projectName||nextProps.collapseToolResults!==this.props.collapseToolResults||nextProps.expandThinking!==this.props.expandThinking||nextProps.showFullToolContent!==this.props.showFullToolContent||nextProps.expandDiff!==this.props.expandDiff||nextProps.filterIrrelevant!==this.props.filterIrrelevant||nextProps.logDir!==this.props.logDir||nextProps.cliMode!==this.props.cliMode||nextProps.sdkMode!==this.props.sdkMode||nextProps.terminalVisible!==this.props.terminalVisible||nextProps.contextWindow!==this.props.contextWindow||nextProps.contextBarOptimistic!==this.props.contextBarOptimistic||nextProps.contextBarSlot!==this.props.contextBarSlot||nextProps.serverCachedContent!==this.props.serverCachedContent||nextProps.resumeAutoChoice!==this.props.resumeAutoChoice||nextProps.themeColor!==this.props.themeColor||nextProps.autoApproveSeconds!==this.props.autoApproveSeconds||nextProps.proxyProfiles!==this.props.proxyProfiles||nextProps.activeProxyId!==this.props.activeProxyId||nextProps.defaultConfig!==this.props.defaultConfig||nextProps.approvalPrefs!==this.props.approvalPrefs||nextProps.approvalGlobal!==this.props.approvalGlobal||nextProps.approvalDismissedIds!==this.props.approvalDismissedIds||nextProps.approvalOwnPending!==this.props.approvalOwnPending||nextState!==this.state}componentWillUnmount(){this._countdownTimer&&clearTimeout(this._countdownTimer),this._expiredTimer&&clearTimeout(this._expiredTimer),this._cacheFadeClearTimer&&clearTimeout(this._cacheFadeClearTimer),this._cacheScrollSettleTimer&&clearTimeout(this._cacheScrollSettleTimer),this._cacheAutoFadeTimer&&clearTimeout(this._cacheAutoFadeTimer),this._cacheHighlightDelayTimer&&clearTimeout(this._cacheHighlightDelayTimer),this._cacheUnbindScrollFade(),this._fsSkillsSeq++,this._memorySeq++,this._memoryDetailSeq++,this._claudeMdSeq++,this._claudeMdDetailSeq++}startCountdown(){this._countdownTimer&&clearTimeout(this._countdownTimer),this._expiredTimer&&clearTimeout(this._expiredTimer),this.props.cacheExpireAt?this.updateCountdown():""!==this.state.countdownText&&this.setState({countdownText:""})}updateCountdown(){const{cacheExpireAt:cacheExpireAt}=this.props;if(!cacheExpireAt)return void(""!==this.state.countdownText&&this.setState({countdownText:""}));const now=Date.now(),remaining=Math.max(0,cacheExpireAt-now);if(remaining<=0){const expired=t("ui.cacheExpired");return this.state.countdownText!==expired&&this.setState({countdownText:expired}),void(this._expiredTimer=setTimeout(()=>{""!==this.state.countdownText&&this.setState({countdownText:""})},5e3))}const totalSec=Math.ceil(remaining/1e3);let text;if(totalSec>=60){const m=Math.floor(totalSec/60);text=t("ui.minuteSecond",{m:m,s:String(totalSec%60).padStart(2,"0")})}else text=t("ui.second",{s:totalSec});text!==this.state.countdownText&&this.setState({countdownText:text});const delay=1e3-now%1e3;this._countdownTimer=setTimeout(this.updateCountdown,delay)}static parseSegments(text){const segments=[],regex=/<([a-zA-Z_][\w-]*)(?:\s[^>]*)?>[\s\S]*?<\/\1>/g;let match,lastIndex=0;for(;null!==(match=regex.exec(text));){const before=text.slice(lastIndex,match.index).trim();before&&segments.push({type:"text",content:before});const tagName=match[1];if(lastIndex=match.index+match[0].length,_AppHeader.COMMAND_TAGS.has(tagName))continue;const innerRegex=new RegExp(`^<${tagName}(?:\\s[^>]*)?>([\\s\\S]*)<\\/${tagName}>$`),innerMatch=match[0].match(innerRegex),content2=innerMatch?innerMatch[1].trim():match[0].trim();segments.push({type:"system",content:content2,label:tagName})}const after=text.slice(lastIndex).trim();return after&&segments.push({type:"text",content:after}),segments}static extractUserTexts(messages){const userMsgs=[],fullTexts=[];let slashCmd=null;for(const msg of messages)if("user"===msg.role)if("string"==typeof msg.content){const text=msg.content.trim();if(!text)continue;if(!isSystemText(text)){if(/Implement the following plan:/i.test(text))continue;userMsgs.push(text),fullTexts.push(text)}}else if(Array.isArray(msg.content)){const{commands:commands,textBlocks:textBlocks}=classifyUserContent(msg.content);commands.length>0&&(slashCmd=commands[commands.length-1]);const userParts=[];for(const b of textBlocks)/Implement the following plan:/i.test((b.text||"").trim())||userParts.push(b.text.trim());const allParts=msg.content.filter(b=>{var _a;return"text"===b.type&&(null==(_a=b.text)?void 0:_a.trim())}).map(b=>b.text.trim());userParts.length>0&&(userMsgs.push(userParts.join("\n")),fullTexts.push(allParts.join("\n")))}return{userMsgs:userMsgs,fullTexts:fullTexts,slashCmd:slashCmd}}extractUserPrompts(){var _a;const{requests:requests=[]}=this.props,prompts=[],seen=new Set;let prevSlashCmd=null;const mainAgentRequests=requests.filter(r=>isMainAgent(r));for(let ri=0;ri<mainAgentRequests.length;ri++){const req=mainAgentRequests[ri],messages=(null==(_a=req.body)?void 0:_a.messages)||[],timestamp=req.timestamp||"",{userMsgs:userMsgs,fullTexts:fullTexts,slashCmd:slashCmd}=_AppHeader.extractUserTexts(messages);slashCmd&&"/compact"!==slashCmd&&slashCmd!==prevSlashCmd&&prompts.push({type:"prompt",segments:[{type:"text",content:slashCmd}],timestamp:timestamp}),prevSlashCmd=slashCmd;for(let i=0;i<userMsgs.length;i++){const key=userMsgs[i];if(seen.has(key))continue;seen.add(key);const raw=fullTexts[i]||key;prompts.push({type:"prompt",segments:_AppHeader.parseSegments(raw),timestamp:timestamp})}}return prompts}renderTokenStats(){const{requests:requests=[]}=this.props,{cacheHighlightIdx:cacheHighlightIdx,cacheHighlightFading:cacheHighlightFading}=this.state;if(this._tokenStatsCache&&this._tokenStatsCacheReq===requests&&this._tokenStatsCacheHl===cacheHighlightIdx&&this._tokenStatsCacheFade===cacheHighlightFading)return this._tokenStatsCache;const byModel=computeTokenStats(requests),models=Object.keys(byModel),toolStats=computeToolUsageStats(requests),skillStats=computeSkillUsageStats(requests);if(0===models.length&&0===toolStats.length)return jsxRuntimeExports.jsx("div",{className:styles$7.tokenStatsEmpty,children:"暂无 token 数据"});const tokenColumn=jsxRuntimeExports.jsx("div",{className:styles$7.tokenStatsColumn,children:models.map(model=>{const s=byModel[model],totalInput=s.input+s.cacheCreation+s.cacheRead,cacheHitRate=totalInput>0?(s.cacheRead/totalInput*100).toFixed(1):"0.0";return jsxRuntimeExports.jsxs("div",{className:models.length>1?styles$7.modelCardSpaced:styles$7.modelCard,children:[jsxRuntimeExports.jsx("div",{className:styles$7.modelName,children:model}),jsxRuntimeExports.jsx("table",{className:styles$7.statsTable,children:jsxRuntimeExports.jsxs("tbody",{children:[jsxRuntimeExports.jsxs("tr",{children:[jsxRuntimeExports.jsx("td",{className:styles$7.label,children:"Token"}),jsxRuntimeExports.jsx("td",{className:styles$7.th,children:"input"}),jsxRuntimeExports.jsx("td",{className:styles$7.th,children:"output"})]}),jsxRuntimeExports.jsxs("tr",{className:styles$7.rowBorder,children:[jsxRuntimeExports.jsx("td",{className:styles$7.label}),jsxRuntimeExports.jsx("td",{className:styles$7.td,children:formatTokenCount(totalInput)}),jsxRuntimeExports.jsx("td",{className:styles$7.td,children:formatTokenCount(s.output)})]}),jsxRuntimeExports.jsxs("tr",{children:[jsxRuntimeExports.jsx("td",{className:styles$7.label,children:"Cache"}),jsxRuntimeExports.jsx("td",{className:styles$7.th,children:"create"}),jsxRuntimeExports.jsx("td",{className:styles$7.th,children:"read"})]}),jsxRuntimeExports.jsxs("tr",{className:styles$7.rowBorder,children:[jsxRuntimeExports.jsx("td",{className:styles$7.label}),jsxRuntimeExports.jsx("td",{className:styles$7.td,children:formatTokenCount(s.cacheCreation)}),jsxRuntimeExports.jsx("td",{className:styles$7.td,children:formatTokenCount(s.cacheRead)})]}),jsxRuntimeExports.jsxs("tr",{children:[jsxRuntimeExports.jsx("td",{className:styles$7.label,children:t("ui.hitRate")}),jsxRuntimeExports.jsxs("td",{colSpan:2,className:styles$7.td,children:[cacheHitRate,"%"]})]})]})})]},model)})}),cacheRebuildColumn=this.renderCacheRebuildStats(),toolColumn=toolStats.length>0?jsxRuntimeExports.jsx("div",{className:styles$7.toolStatsColumn,children:jsxRuntimeExports.jsxs("div",{className:styles$7.modelCard,children:[jsxRuntimeExports.jsx("div",{className:styles$7.modelName,children:t("ui.toolUsageStats")}),jsxRuntimeExports.jsxs("table",{className:styles$7.statsTable,children:[jsxRuntimeExports.jsx("thead",{children:jsxRuntimeExports.jsxs("tr",{children:[jsxRuntimeExports.jsx("td",{className:`${styles$7.th} ${styles$7.thLeft}`,children:"Tool"}),jsxRuntimeExports.jsx("td",{className:styles$7.th,children:t("ui.cacheRebuild.count")})]})}),jsxRuntimeExports.jsxs("tbody",{children:[toolStats.map(([name,count])=>jsxRuntimeExports.jsxs("tr",{className:styles$7.rowBorder,children:[jsxRuntimeExports.jsxs("td",{className:styles$7.label,children:[name," ",jsxRuntimeExports.jsx(ConceptHelp,{doc:`Tool-${name}`})]}),jsxRuntimeExports.jsx("td",{className:styles$7.td,children:count})]},name)),toolStats.length>1&&jsxRuntimeExports.jsxs("tr",{className:styles$7.rebuildTotalRow,children:[jsxRuntimeExports.jsx("td",{className:styles$7.label,children:"Total"}),jsxRuntimeExports.jsx("td",{className:styles$7.td,children:toolStats.reduce((s,e)=>s+e[1],0)})]})]})]})]})}):null,skillColumn=skillStats.length>0?jsxRuntimeExports.jsx("div",{className:styles$7.toolStatsColumn,children:jsxRuntimeExports.jsxs("div",{className:styles$7.modelCard,children:[jsxRuntimeExports.jsx("div",{className:styles$7.modelName,children:t("ui.skillUsageStats")}),jsxRuntimeExports.jsxs("table",{className:styles$7.statsTable,children:[jsxRuntimeExports.jsx("thead",{children:jsxRuntimeExports.jsxs("tr",{children:[jsxRuntimeExports.jsx("td",{className:`${styles$7.th} ${styles$7.thLeft}`,children:"Skill"}),jsxRuntimeExports.jsx("td",{className:styles$7.th,children:t("ui.cacheRebuild.count")})]})}),jsxRuntimeExports.jsxs("tbody",{children:[skillStats.map(([name,count])=>jsxRuntimeExports.jsxs("tr",{className:styles$7.rowBorder,children:[jsxRuntimeExports.jsx("td",{className:styles$7.label,children:name}),jsxRuntimeExports.jsx("td",{className:styles$7.td,children:count})]},name)),skillStats.length>1&&jsxRuntimeExports.jsxs("tr",{className:styles$7.rebuildTotalRow,children:[jsxRuntimeExports.jsx("td",{className:styles$7.label,children:"Total"}),jsxRuntimeExports.jsx("td",{className:styles$7.td,children:skillStats.reduce((s,e)=>s+e[1],0)})]})]})]})]})}):null,result=jsxRuntimeExports.jsxs("div",{className:styles$7.tokenStatsContainer,children:[tokenColumn,cacheRebuildColumn,toolColumn,skillColumn]});return this._tokenStatsCache=result,this._tokenStatsCacheReq=requests,this._tokenStatsCacheHl=cacheHighlightIdx,this._tokenStatsCacheFade=cacheHighlightFading,result}_cacheUnbindScrollFade(){this._cacheOnScrollFade&&this._cacheScrollEl&&(this._cacheScrollEl.removeEventListener("scroll",this._cacheOnScrollFade),this._cacheOnScrollFade=null)}_cacheBindScrollFade(){this._cacheUnbindScrollFade();const el=this._cacheScrollEl;el&&(this._cacheOnScrollFade=()=>{clearTimeout(this._cacheAutoFadeTimer),this.setState({cacheHighlightFading:!0}),this._cacheFadeClearTimer=setTimeout(()=>{this.setState({cacheHighlightIdx:null,cacheHighlightFading:!1})},3e3),this._cacheUnbindScrollFade()},el.addEventListener("scroll",this._cacheOnScrollFade,{passive:!0}))}scrollToCacheMsg(idx){if("raw"===this.props.viewMode&&this.props.onNavigateCacheMsg&&this.props.onNavigateCacheMsg(idx),(this.state._cacheSectionCollapsed||{}).messages)return void this.setState(prev=>({_cacheSectionCollapsed:{...prev._cacheSectionCollapsed||{},messages:!1}}),()=>this.scrollToCacheMsg(idx));const el=this._cacheScrollEl;if(!el)return;const target=el.querySelector(`[data-msg-idx="${idx}"]`);if(!target)return;clearTimeout(this._cacheScrollSettleTimer),clearTimeout(this._cacheFadeClearTimer),clearTimeout(this._cacheAutoFadeTimer),clearTimeout(this._cacheHighlightDelayTimer),this._cacheUnbindScrollFade(),this._cacheScrollEndHandler&&el.removeEventListener("scrollend",this._cacheScrollEndHandler),this.setState({cacheHighlightIdx:null,cacheHighlightFading:!1});let scrollDone=!1,minPassed=!1;const showHighlight=()=>{scrollDone&&minPassed&&(this.setState({cacheHighlightIdx:idx,cacheHighlightFading:!1}),this._cacheScrollSettleTimer=setTimeout(()=>this._cacheBindScrollFade(),200),this._cacheAutoFadeTimer=setTimeout(()=>{this.state.cacheHighlightIdx!==idx||this.state.cacheHighlightFading||(this.setState({cacheHighlightFading:!0}),this._cacheFadeClearTimer=setTimeout(()=>{this.setState({cacheHighlightIdx:null,cacheHighlightFading:!1})},3e3),this._cacheUnbindScrollFade())},3e3))};this._cacheScrollEndHandler=()=>{el.removeEventListener("scrollend",this._cacheScrollEndHandler),scrollDone=!0,showHighlight()},el.addEventListener("scrollend",this._cacheScrollEndHandler,{once:!0}),this._cacheScrollSettleTimer=setTimeout(()=>{el.removeEventListener("scrollend",this._cacheScrollEndHandler),scrollDone=!0,showHighlight()},800),this._cacheHighlightDelayTimer=setTimeout(()=>{minPassed=!0,showHighlight()},500),target.scrollIntoView({behavior:"smooth",block:"center"})}renderCacheRebuildStats(){const{requests:requests=[]}=this.props,stats=computeCacheRebuildStats(requests),i18nMap={ttl:"cacheLoss.ttl",system_change:"cacheLoss.systemChange",tools_change:"cacheLoss.toolsChange",model_change:"cacheLoss.modelChange",msg_truncated:"cacheLoss.msgTruncated",msg_modified:"cacheLoss.msgModified",key_change:"cacheLoss.keyChange"},activeReasons=["ttl","system_change","tools_change","model_change","msg_truncated","msg_modified","key_change"].filter(k=>stats[k].count>0),totalCount=activeReasons.reduce((sum,k)=>sum+stats[k].count,0),totalCache=activeReasons.reduce((sum,k)=>sum+stats[k].cacheCreate,0);resolveTeammateNames(requests);const subAgentCounts={},teammateCounts={};for(let i=0;i<requests.length;i++){const cls=classifyRequest(requests[i],requests[i+1]);if("SubAgent"===cls.type){const label=cls.subType||"Other";subAgentCounts[label]=(subAgentCounts[label]||0)+1}else if("Teammate"===cls.type){const label=cls.subType||"Teammate";teammateCounts[label]=(teammateCounts[label]||0)+1}}const subAgentEntries=Object.entries(subAgentCounts).sort((a,b)=>b[1]-a[1]),teammateEntries=Object.entries(teammateCounts).sort((a,b)=>b[1]-a[1]),hasCacheStats=activeReasons.length>0,hasSubAgentStats=subAgentEntries.length>0,hasTeammateStats=teammateEntries.length>0;return hasCacheStats||hasSubAgentStats||hasTeammateStats?jsxRuntimeExports.jsxs("div",{className:styles$7.toolStatsColumn,children:[hasCacheStats&&jsxRuntimeExports.jsxs("div",{className:hasSubAgentStats||hasTeammateStats?styles$7.modelCardSpaced:styles$7.modelCard,children:[jsxRuntimeExports.jsxs("div",{className:styles$7.modelName,children:["MainAgent",jsxRuntimeExports.jsx(ConceptHelp,{doc:"MainAgent"})," ",t("ui.cacheRebuildStats"),jsxRuntimeExports.jsx(ConceptHelp,{doc:"CacheRebuild"})]}),jsxRuntimeExports.jsxs("table",{className:styles$7.statsTable,children:[jsxRuntimeExports.jsx("thead",{children:jsxRuntimeExports.jsxs("tr",{children:[jsxRuntimeExports.jsx("td",{className:`${styles$7.th} ${styles$7.thLeft}`,children:t("ui.cacheRebuild.reason")}),jsxRuntimeExports.jsx("td",{className:styles$7.th,children:t("ui.cacheRebuild.count")}),jsxRuntimeExports.jsx("td",{className:styles$7.th,children:t("ui.cacheRebuild.cacheCreate")})]})}),jsxRuntimeExports.jsxs("tbody",{children:[activeReasons.map(k=>jsxRuntimeExports.jsxs("tr",{className:styles$7.rowBorder,children:[jsxRuntimeExports.jsx("td",{className:styles$7.label,children:t(`ui.${i18nMap[k]}`)}),jsxRuntimeExports.jsx("td",{className:styles$7.td,children:stats[k].count}),jsxRuntimeExports.jsx("td",{className:styles$7.td,children:formatTokenCount(stats[k].cacheCreate)})]},k)),activeReasons.length>1&&jsxRuntimeExports.jsxs("tr",{className:styles$7.rebuildTotalRow,children:[jsxRuntimeExports.jsx("td",{className:styles$7.label,children:"Total"}),jsxRuntimeExports.jsx("td",{className:styles$7.td,children:totalCount}),jsxRuntimeExports.jsx("td",{className:styles$7.td,children:formatTokenCount(totalCache)})]})]})]})]}),hasSubAgentStats&&jsxRuntimeExports.jsxs("div",{className:hasTeammateStats?styles$7.modelCardSpaced:styles$7.modelCard,children:[jsxRuntimeExports.jsx("div",{className:styles$7.modelName,children:t("ui.subAgentStats")}),jsxRuntimeExports.jsxs("table",{className:styles$7.statsTable,children:[jsxRuntimeExports.jsx("thead",{children:jsxRuntimeExports.jsxs("tr",{children:[jsxRuntimeExports.jsx("td",{className:`${styles$7.th} ${styles$7.thLeft}`,children:"SubAgent"}),jsxRuntimeExports.jsx("td",{className:styles$7.th,children:t("ui.cacheRebuild.count")})]})}),jsxRuntimeExports.jsxs("tbody",{children:[subAgentEntries.map(([name,count])=>jsxRuntimeExports.jsxs("tr",{className:styles$7.rowBorder,children:[jsxRuntimeExports.jsxs("td",{className:styles$7.label,children:[name," ",jsxRuntimeExports.jsx(ConceptHelp,{doc:`SubAgent-${name}`})]}),jsxRuntimeExports.jsx("td",{className:styles$7.td,children:count})]},name)),subAgentEntries.length>1&&jsxRuntimeExports.jsxs("tr",{className:styles$7.rebuildTotalRow,children:[jsxRuntimeExports.jsx("td",{className:styles$7.label,children:"Total"}),jsxRuntimeExports.jsx("td",{className:styles$7.td,children:subAgentEntries.reduce((s,e)=>s+e[1],0)})]})]})]})]}),hasTeammateStats&&jsxRuntimeExports.jsxs("div",{className:styles$7.modelCard,children:[jsxRuntimeExports.jsxs("div",{className:styles$7.modelName,children:["Teammate",jsxRuntimeExports.jsx(ConceptHelp,{doc:"Teammate"})]}),jsxRuntimeExports.jsxs("table",{className:styles$7.statsTable,children:[jsxRuntimeExports.jsx("thead",{children:jsxRuntimeExports.jsxs("tr",{children:[jsxRuntimeExports.jsx("td",{className:`${styles$7.th} ${styles$7.thLeft}`,children:"Name"}),jsxRuntimeExports.jsx("td",{className:styles$7.th,children:t("ui.cacheRebuild.count")})]})}),jsxRuntimeExports.jsxs("tbody",{children:[teammateEntries.map(([name,count])=>jsxRuntimeExports.jsxs("tr",{className:styles$7.rowBorder,children:[jsxRuntimeExports.jsx("td",{className:styles$7.label,children:name}),jsxRuntimeExports.jsx("td",{className:styles$7.td,children:count})]},name)),teammateEntries.length>1&&jsxRuntimeExports.jsxs("tr",{className:styles$7.rebuildTotalRow,children:[jsxRuntimeExports.jsx("td",{className:styles$7.label,children:"Total"}),jsxRuntimeExports.jsx("td",{className:styles$7.td,children:teammateEntries.reduce((s,e)=>s+e[1],0)})]})]})]})]})]}):null}renderTextPrompt(p){return jsxRuntimeExports.jsx("div",{className:styles$7.textPromptCard,children:p.segments.map((seg,j)=>"text"===seg.type?jsxRuntimeExports.jsx("pre",{className:styles$7.preText,children:seg.content},j):jsxRuntimeExports.jsx(Collapse,{size:"small",className:styles$7.systemCollapse,items:[{key:`sys-${j}`,label:jsxRuntimeExports.jsx("span",{className:styles$7.systemLabel,children:seg.label}),children:jsxRuntimeExports.jsx("pre",{className:styles$7.preSys,children:seg.content})}]},j))})}renderOriginalPrompt(p){const textSegments=p.segments.filter(seg=>"text"===seg.type);return 0===textSegments.length?null:jsxRuntimeExports.jsx("div",{className:styles$7.textPromptCard,children:textSegments.map((seg,j)=>jsxRuntimeExports.jsx("pre",{className:styles$7.preText,children:seg.content},j))})}buildTextModeContent(){const{promptData:promptData}=this.state,blocks=[];for(const p of promptData){const textParts=(p.segments||[]).filter(seg=>"text"===seg.type).map(seg=>seg.content);textParts.length>0&&blocks.push(textParts.join("\n"))}return blocks.join("\n\n\n")}renderProjectStatsContent(){const{projectStats:projectStats,projectStatsLoading:projectStatsLoading}=this.state;if(projectStatsLoading)return jsxRuntimeExports.jsx("div",{className:styles$7.projectStatsCenter,children:jsxRuntimeExports.jsx(Spin,{})});if(!projectStats)return jsxRuntimeExports.jsx("div",{className:styles$7.projectStatsEmpty,children:t("ui.projectStats.noData")});const{summary:summary,models:models,updatedAt:updatedAt}=projectStats;!models||Object.entries(models).sort((a,b)=>b[1]-a[1]);const modelTokens={};if(projectStats.files)for(const fStats of Object.values(projectStats.files))if(fStats.models)for(const[model,data]of Object.entries(fStats.models))modelTokens[model]||(modelTokens[model]={input:0,output:0,cacheRead:0,cacheCreation:0,count:0}),modelTokens[model].input+=data.input_tokens||0,modelTokens[model].output+=data.output_tokens||0,modelTokens[model].cacheRead+=data.cache_read_input_tokens||0,modelTokens[model].cacheCreation+=data.cache_creation_input_tokens||0,modelTokens[model].count+=data.count||0;const modelTokenEntries=Object.entries(modelTokens).sort((a,b)=>b[1].count-a[1].count);return jsxRuntimeExports.jsxs("div",{className:styles$7.projectStatsContent,children:[updatedAt&&jsxRuntimeExports.jsx("div",{className:styles$7.projectStatsUpdated,children:t("ui.projectStats.updatedAt",{time:new Date(updatedAt).toLocaleString()})}),jsxRuntimeExports.jsxs("div",{className:styles$7.projectStatsSummary,children:[jsxRuntimeExports.jsxs("div",{className:styles$7.projectStatCard,children:[jsxRuntimeExports.jsx("div",{className:styles$7.projectStatValue,children:(null==summary?void 0:summary.requestCount)??0}),jsxRuntimeExports.jsx("div",{className:styles$7.projectStatLabel,children:t("ui.projectStats.totalRequests")})]}),jsxRuntimeExports.jsxs("div",{className:styles$7.projectStatCard,children:[jsxRuntimeExports.jsx("div",{className:styles$7.projectStatValue,children:(null==summary?void 0:summary.turnCount)??(null==summary?void 0:summary.sessionCount)??0}),jsxRuntimeExports.jsx("div",{className:styles$7.projectStatLabel,children:t("ui.projectStats.turnCount")})]}),jsxRuntimeExports.jsxs("div",{className:styles$7.projectStatCard,children:[jsxRuntimeExports.jsx("div",{className:styles$7.projectStatValue,children:(null==summary?void 0:summary.fileCount)??0}),jsxRuntimeExports.jsx("div",{className:styles$7.projectStatLabel,children:t("ui.projectStats.totalFiles")})]}),jsxRuntimeExports.jsxs("div",{className:styles$7.projectStatCard,children:[jsxRuntimeExports.jsx("div",{className:styles$7.projectStatValue,children:formatTokenCount(null==summary?void 0:summary.input_tokens)}),jsxRuntimeExports.jsx("div",{className:styles$7.projectStatLabel,children:"Input Tokens"})]}),jsxRuntimeExports.jsxs("div",{className:styles$7.projectStatCard,children:[jsxRuntimeExports.jsx("div",{className:styles$7.projectStatValue,children:formatTokenCount(null==summary?void 0:summary.output_tokens)}),jsxRuntimeExports.jsx("div",{className:styles$7.projectStatLabel,children:"Output Tokens"})]})]}),modelTokenEntries.length>0&&jsxRuntimeExports.jsxs("div",{className:styles$7.projectStatsSection,children:[jsxRuntimeExports.jsx("div",{className:styles$7.projectStatsSectionTitle,children:t("ui.projectStats.modelUsage")}),modelTokenEntries.map(([model,data])=>{const totalInput=data.input+data.cacheRead+data.cacheCreation,cacheHitRate=totalInput>0?(data.cacheRead/totalInput*100).toFixed(1):"0.0";return jsxRuntimeExports.jsxs("div",{className:styles$7.projectStatsModelCard,children:[jsxRuntimeExports.jsxs("div",{className:styles$7.projectStatsModelHeader,children:[jsxRuntimeExports.jsx("span",{className:styles$7.projectStatsModelName,children:model}),jsxRuntimeExports.jsxs("span",{className:styles$7.projectStatsModelCount,children:[data.count," reqs"]})]}),jsxRuntimeExports.jsx("table",{className:styles$7.statsTable,children:jsxRuntimeExports.jsxs("tbody",{children:[jsxRuntimeExports.jsxs("tr",{children:[jsxRuntimeExports.jsx("td",{className:styles$7.label,children:"Token"}),jsxRuntimeExports.jsx("td",{className:styles$7.th,children:"input"}),jsxRuntimeExports.jsx("td",{className:styles$7.th,children:"output"})]}),jsxRuntimeExports.jsxs("tr",{className:styles$7.rowBorder,children:[jsxRuntimeExports.jsx("td",{className:styles$7.label}),jsxRuntimeExports.jsx("td",{className:styles$7.td,children:formatTokenCount(totalInput)}),jsxRuntimeExports.jsx("td",{className:styles$7.td,children:formatTokenCount(data.output)})]}),jsxRuntimeExports.jsxs("tr",{children:[jsxRuntimeExports.jsx("td",{className:styles$7.label,children:"Cache"}),jsxRuntimeExports.jsx("td",{className:styles$7.th,children:"create"}),jsxRuntimeExports.jsx("td",{className:styles$7.th,children:"read"})]}),jsxRuntimeExports.jsxs("tr",{className:styles$7.rowBorder,children:[jsxRuntimeExports.jsx("td",{className:styles$7.label}),jsxRuntimeExports.jsx("td",{className:styles$7.td,children:formatTokenCount(data.cacheCreation)}),jsxRuntimeExports.jsx("td",{className:styles$7.td,children:formatTokenCount(data.cacheRead)})]}),jsxRuntimeExports.jsxs("tr",{children:[jsxRuntimeExports.jsx("td",{className:styles$7.label,children:t("ui.hitRate")}),jsxRuntimeExports.jsxs("td",{colSpan:2,className:styles$7.td,children:[cacheHitRate,"%"]})]})]})})]},model)})]})]})}renderContextBarPortal(){var _a,_b;const slot=this.props.contextBarSlot;if(!slot)return null;const{requests:requests=[],isLocalLog:isLocalLog,localLogFile:localLogFile,projectName:projectName,contextWindow:contextWindow,contextBarOptimistic:contextBarOptimistic,serverCachedContent:serverCachedContent}=this.props;let contextPercent=0,lastMainAgent=null,lastTotalTokens=0;if(!isLocalLog&&requests.length>0)for(let i=requests.length-1;i>=0;i--)if(isMainAgent(requests[i])&&(null==(_b=null==(_a=requests[i].response)?void 0:_a.body)?void 0:_b.usage)){lastMainAgent=requests[i];const u=lastMainAgent.response.body.usage;lastTotalTokens=(u.input_tokens||0)+(u.cache_creation_input_tokens||0)+(u.cache_read_input_tokens||0);break}const calibrationTokens=resolveCalibrationTokens(this.state.calibrationModel,lastMainAgent);if(!isLocalLog)if(null!=(null==contextWindow?void 0:contextWindow.used_percentage))if(lastTotalTokens>0){const usable=calibrationTokens*AUTO_COMPACT_USABLE_RATIO;contextPercent=Math.min(100,Math.max(0,Math.round(lastTotalTokens/usable*100)))}else{const origMax=contextWindow.context_window_size||2e5;contextPercent=Math.min(100,Math.max(0,Math.round(contextWindow.used_percentage*origMax/calibrationTokens/AUTO_COMPACT_USABLE_RATIO)))}else if(lastMainAgent&&lastTotalTokens>0){const usable=calibrationTokens*AUTO_COMPACT_USABLE_RATIO;contextPercent=Math.min(100,Math.max(0,Math.round(lastTotalTokens/usable*100)))}contextPercent>0&&(this._lastContextPercent=contextPercent),0===contextPercent&&this._lastContextPercent>0&&(contextPercent=this._lastContextPercent),contextBarOptimistic&&(contextPercent=OPTIMISTIC_CLEAR_PERCENT);const ctxColor=contextPercent>=80?"var(--color-error-light)":contextPercent>=60?"var(--color-warning-light)":"var(--color-success)",contextTokens=lastTotalTokens;return reactDomExports.createPortal(jsxRuntimeExports.jsx(LiveTagPopover$1,{isLocalLog:isLocalLog,localLogFile:localLogFile,cachePopoverOpen:this.state._cachePopoverOpen,onOpenChange:this.handleCachePopoverOpenChange,requests:requests,serverCachedContent:serverCachedContent,contextPercent:contextPercent,contextTokens:contextTokens,ctxColor:ctxColor,onSkillImported:this.reloadFsSkills,fsSkills:this.state._fsSkills,memory:this.state._memory,memoryRefreshing:this.state._memoryRefreshing,claudeMd:this.state._claudeMd,calibrationModel:this.state.calibrationModel,onCalibrationModelChange:this.handleCalibrationModelChange,onOpenMemoryDetail:this.loadMemoryDetail,onOpenClaudeMd:this.loadClaudeMdDetail,onOpenSkillsModal:this.handleOpenSkillsModal,onRefreshMemory:this.handleRefreshMemory,projectName:projectName}),slot)}render(){const{requestCount:requestCount,requests:requests=[],viewMode:viewMode,cacheType:cacheType,onToggleViewMode:onToggleViewMode,onImportLocalLogs:onImportLocalLogs,onLangChange:onLangChange,isLocalLog:isLocalLog,localLogFile:localLogFile,projectName:projectName,collapseToolResults:collapseToolResults,onCollapseToolResultsChange:onCollapseToolResultsChange,expandThinking:expandThinking,onExpandThinkingChange:onExpandThinkingChange,showFullToolContent:showFullToolContent,onShowFullToolContentChange:onShowFullToolContentChange,expandDiff:expandDiff,onExpandDiffChange:onExpandDiffChange,filterIrrelevant:filterIrrelevant,onFilterIrrelevantChange:onFilterIrrelevantChange,logDir:logDir,onLogDirChange:onLogDirChange,cliMode:cliMode,terminalVisible:terminalVisible,onToggleTerminal:onToggleTerminal,onReturnToWorkspaces:onReturnToWorkspaces,contextWindow:contextWindow,contextBarOptimistic:contextBarOptimistic,serverCachedContent:serverCachedContent,resumeAutoChoice:resumeAutoChoice,onResumeAutoChoiceToggle:onResumeAutoChoiceToggle,onResumeAutoChoiceChange:onResumeAutoChoiceChange,themeColor:themeColor,onThemeColorChange:onThemeColorChange,autoApproveSeconds:autoApproveSeconds,onAutoApproveChange:onAutoApproveChange}=this.props,{countdownText:countdownText}=this.state,menuItems=[{key:"import-local",icon:jsxRuntimeExports.jsx(RefIcon$1,{}),label:t("ui.importLocalLogs"),onClick:onImportLocalLogs},{key:"export-prompts",icon:jsxRuntimeExports.jsx(RefIcon$2,{}),label:t("ui.exportPrompts"),onClick:this.handleShowPrompts},{key:"plugin-management",icon:jsxRuntimeExports.jsx(RefIcon$5,{}),label:t("ui.pluginManagement"),onClick:this.handleShowPlugins},{key:"process-management",icon:jsxRuntimeExports.jsx(RefIcon$6,{}),label:t("ui.processManagement"),onClick:this.handleShowProcesses},{key:"proxy-switch",icon:jsxRuntimeExports.jsx(RefIcon$7,{}),label:t("ui.proxySwitch"),onClick:()=>this.setState({proxyModalVisible:!0})},{type:"divider"},{key:"project-stats",icon:jsxRuntimeExports.jsx(RefIcon$4,{}),label:t("ui.projectStats"),onClick:this.handleShowProjectStats},..."raw"===viewMode?[{key:"global-settings",icon:jsxRuntimeExports.jsx(RefIcon$8,{}),label:t("ui.globalSettings"),onClick:()=>this.setState({globalSettingsVisible:!0})}]:[],..."chat"===viewMode?[{key:"display-settings",icon:jsxRuntimeExports.jsx(RefIcon$8,{}),label:t("ui.settings"),onClick:()=>this.setState({settingsDrawerVisible:!0})}]:[]];return jsxRuntimeExports.jsxs("div",{className:styles$7.headerBar,children:[jsxRuntimeExports.jsxs(Space,{size:"middle",children:[jsxRuntimeExports.jsx(Dropdown,{menu:{items:menuItems,className:"logo-dropdown-menu"},trigger:["hover"],onOpenChange:open=>this.setState({logoDropdownOpen:open}),align:{offset:[-4,0]},children:jsxRuntimeExports.jsx("span",{className:`${styles$7.logoWrap}${this.state.logoDropdownOpen?` ${styles$7.logoWrapActive}`:""}`,children:jsxRuntimeExports.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:`${styles$7.logoImage}${this.state.logoDropdownOpen?` ${styles$7.logoImageActive}`:""}`,children:[jsxRuntimeExports.jsx("line",{x1:"3",y1:"6",x2:"21",y2:"6"}),jsxRuntimeExports.jsx("line",{x1:"3",y1:"12",x2:"21",y2:"12"}),jsxRuntimeExports.jsx("line",{x1:"3",y1:"18",x2:"21",y2:"18"})]})})}),this.props.activeProxyId&&"max"!==this.props.activeProxyId&&(()=>{const p=(this.props.proxyProfiles||[]).find(x=>x.id===this.props.activeProxyId);return p?jsxRuntimeExports.jsxs(Tag,{className:styles$7.proxyProfileTag,onClick:()=>this.setState({proxyModalVisible:!0}),children:[jsxRuntimeExports.jsx(RefIcon$7,{className:styles$7.proxySwapIcon}),p.name,p.activeModel?` · ${p.activeModel}`:""]}):null})(),jsxRuntimeExports.jsxs("span",{className:styles$7.headerProjectName,children:[t("ui.liveMonitoring"),projectName?`:${projectName}`:""]}),this.renderContextBarPortal()]}),jsxRuntimeExports.jsxs(Space,{size:12,align:"center",className:styles$7.headerRightRow,children:[(()=>{var _a,_b,_c,_d,_e,_f;const ag=this.props.approvalGlobal,adi=this.props.approvalDismissedIds,own=this.props.approvalOwnPending||{ask:0,ptyPlan:0};if(!ag||!this.props.onApprovalReopen)return null;let dismissedActive=0;null!=(null==(_b=null==(_a=ag.ask)?void 0:_a.ask)?void 0:_b.id)&&adi instanceof Set&&adi.has(`ask:${ag.ask.ask.id}`)&&dismissedActive++,null!=(null==(_d=null==(_c=ag.ptyPlan)?void 0:_c.ptyPlan)?void 0:_d.id)&&adi instanceof Set&&adi.has(`ptyPlan:${ag.ptyPlan.ptyPlan.id}`)&&dismissedActive++;const total=dismissedActive+(!(null==(_e=ag.ask)?void 0:_e.ask)&&!(null==(_f=ag.ptyPlan)?void 0:_f.ptyPlan)?(own.ask||0)+(own.ptyPlan||0):0);if(0===total)return null;const titleKey=dismissedActive>0?"ui.approval.bell.reopen":"ui.approval.bell.orphan",titleFallback=dismissedActive>0?"Reopen approval modal":"Server has pending approvals",_tr=(k,p,f)=>{try{const r=t(k,p);return r&&r!==k?r:f}catch{return f}};return jsxRuntimeExports.jsxs("button",{type:"button",className:styles$7.approvalBell,"aria-label":_tr(titleKey,null,titleFallback),title:_tr(titleKey,null,titleFallback),onClick:()=>this.props.onApprovalReopen&&this.props.onApprovalReopen(),children:[jsxRuntimeExports.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[jsxRuntimeExports.jsx("path",{d:"M12 2a6 6 0 0 0-6 6v3.5L4.5 14a1 1 0 0 0 .8 1.6h13.4a1 1 0 0 0 .8-1.6L18 11.5V8a6 6 0 0 0-6-6z",stroke:"currentColor",strokeWidth:"1.6",strokeLinejoin:"round",fill:"none"}),jsxRuntimeExports.jsx("path",{d:"M10 18a2 2 0 0 0 4 0",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",fill:"none"})]}),total>0&&jsxRuntimeExports.jsx("span",{className:styles$7.approvalBellBadge,children:total})]})})(),countdownText&&"raw"===viewMode&&jsxRuntimeExports.jsxs(Tag,{className:styles$7.headerCountdownTag,style:{color:countdownText===t("ui.cacheExpired")?"var(--color-error-light)":"var(--text-secondary)"},children:[t("ui.cacheCountdown",{type:cacheType?`(${cacheType})`:""}),jsxRuntimeExports.jsx("strong",{className:styles$7.countdownStrong,children:countdownText})]}),"chat"===viewMode&&cliMode&&!isLocalLog&&this.state.localUrl&&jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(Popover,{content:jsxRuntimeExports.jsxs("div",{className:styles$7.qrcodePopover,onClick:e=>e.stopPropagation(),children:[jsxRuntimeExports.jsxs("div",{className:styles$7.qrcodeTitle,children:[t("ui.scanToCoding")," ",jsxRuntimeExports.jsx(ConceptHelp,{doc:"QRCode"})]}),jsxRuntimeExports.jsx(QRCodeCanvas,{value:this.state.localUrl,size:200,bgColor:"light"===themeColor?"#ffffff":"#141414",fgColor:"light"===themeColor?"#1a1a1a":"#d9d9d9",level:"M"}),jsxRuntimeExports.jsx(Input,{readOnly:!0,value:this.state.localUrl,className:styles$7.qrcodeUrlInput,suffix:jsxRuntimeExports.jsx(RefIcon$9,{className:styles$7.qrcodeUrlCopy,onClick:()=>{navigator.clipboard.writeText(this.state.localUrl).then(()=>{staticMethods.success(t("ui.copied"))}).catch(()=>{})}})})]}),trigger:["click"],open:this.state.qrPopoverOpen,onOpenChange:o=>this.setState({qrPopoverOpen:o}),placement:"bottomRight",overlayInnerStyle:{background:"var(--bg-elevated)",border:"1px solid var(--border-hover)",borderRadius:8,padding:"8px 8px"},children:jsxRuntimeExports.jsx("button",{type:"button",className:styles$7.qrcodeIcon,"aria-label":t("ui.scanToCoding"),children:jsxRuntimeExports.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:jsxRuntimeExports.jsx("path",{fillRule:"evenodd",d:"M0 0h10v10H0zM2 2v6h6V2zM3 3h4v4H3zM14 0h10v10H14zM16 2v6h6V2zM17 3h4v4H17zM0 14h10v10H0zM2 16v6h6v-6zM3 17h4v4H3zM14 14h3v3h-3zM20 14h3v3h-3zM17 17h3v3h-3zM14 20h3v3h-3zM20 20h3v3h-3z"})})})}),jsxRuntimeExports.jsx("button",{type:"button",className:styles$7.themeToggle,"data-theme":"light"===themeColor?"light":"dark",role:"switch","aria-checked":"light"===themeColor,title:t("light"===themeColor?"ui.themeColor.light":"ui.themeColor.dark"),onClick:()=>onThemeColorChange&&onThemeColorChange("light"===themeColor?"dark":"light"),children:jsxRuntimeExports.jsx("span",{className:styles$7.themeToggleKnob,children:"light"===themeColor?jsxRuntimeExports.jsxs("svg",{className:styles$7.themeToggleIcon,width:"14",height:"14",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[jsxRuntimeExports.jsx("circle",{cx:"8",cy:"8",r:"2.8",fill:"currentColor"}),jsxRuntimeExports.jsxs("g",{stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",children:[jsxRuntimeExports.jsx("line",{x1:"8",y1:"1",x2:"8",y2:"2.6"}),jsxRuntimeExports.jsx("line",{x1:"8",y1:"13.4",x2:"8",y2:"15"}),jsxRuntimeExports.jsx("line",{x1:"1",y1:"8",x2:"2.6",y2:"8"}),jsxRuntimeExports.jsx("line",{x1:"13.4",y1:"8",x2:"15",y2:"8"}),jsxRuntimeExports.jsx("line",{x1:"2.95",y1:"2.95",x2:"4.1",y2:"4.1"}),jsxRuntimeExports.jsx("line",{x1:"11.9",y1:"11.9",x2:"13.05",y2:"13.05"}),jsxRuntimeExports.jsx("line",{x1:"2.95",y1:"13.05",x2:"4.1",y2:"11.9"}),jsxRuntimeExports.jsx("line",{x1:"11.9",y1:"4.1",x2:"13.05",y2:"2.95"})]})]}):jsxRuntimeExports.jsx("svg",{className:styles$7.themeToggleIcon,width:"14",height:"14",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:jsxRuntimeExports.jsx("path",{d:"M8.4 2.5a5.9 5.9 0 1 0 5.1 8.55A4.8 4.8 0 0 1 8.4 2.5Z",fill:"currentColor"})})})})]}),cliMode&&"chat"===viewMode&&!isLocalLog&&jsxRuntimeExports.jsx(Button,{className:styles$7.compactBtn,type:terminalVisible?"primary":"default",ghost:terminalVisible,icon:jsxRuntimeExports.jsx(RefIcon$3,{}),onClick:onToggleTerminal,children:t("ui.terminal")}),jsxRuntimeExports.jsx(Button,{className:styles$7.compactBtn,type:"raw"===viewMode?"primary":"default",icon:"raw"===viewMode?jsxRuntimeExports.jsx(RefIcon,{}):jsxRuntimeExports.jsx(RefIcon$a,{}),onClick:onToggleViewMode,children:t("raw"===viewMode?"ui.chatMode":"ui.rawMode")})]}),jsxRuntimeExports.jsx(MemoryDetailModal,{detail:this.state._memoryDetail,onClose:()=>this.setState({_memoryDetail:null}),onOpenMemoryDetail:this.loadMemoryDetail}),jsxRuntimeExports.jsx(MemoryDetailModal,{detail:this.state._claudeMdDetail,onClose:()=>this.setState({_claudeMdDetail:null}),linkMode:"passthrough"}),jsxRuntimeExports.jsxs(Modal,{title:`${t("ui.userPrompt")} (${this.state.promptData.length}${t("ui.promptCountUnit")})`,open:this.state.promptModalVisible,onCancel:()=>this.setState({promptModalVisible:!1}),footer:null,width:700,children:[jsxRuntimeExports.jsx("div",{className:styles$7.promptExportBar,children:jsxRuntimeExports.jsx(Button,{icon:jsxRuntimeExports.jsx(RefIcon$b,{}),onClick:this.handleExportPromptsTxt,children:t("ui.exportPromptsTxt")})}),jsxRuntimeExports.jsx(Tabs,{activeKey:this.state.promptViewMode,onChange:key=>this.setState({promptViewMode:key}),size:"small",items:[{key:"original",label:t("ui.promptModeOriginal")},{key:"context",label:t("ui.promptModeContext")},{key:"text",label:t("ui.promptModeText")}]}),"text"===this.state.promptViewMode?jsxRuntimeExports.jsx("textarea",{readOnly:!0,className:styles$7.promptTextarea,value:this.buildTextModeContent()}):jsxRuntimeExports.jsxs("div",{className:styles$7.promptScrollArea,children:[0===this.state.promptData.length&&jsxRuntimeExports.jsx("div",{className:styles$7.promptEmpty,children:t("ui.noPrompt")}),this.state.promptData.map((p,i)=>{const ts=p.timestamp?new Date(p.timestamp).toLocaleString():t("ui.unknownTime");return jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsxs("div",{className:styles$7.promptTimestamp,children:[ts,":"]}),"original"===this.state.promptViewMode?this.renderOriginalPrompt(p):this.renderTextPrompt(p)]},i)})]})]}),jsxRuntimeExports.jsxs(Drawer,{title:t("ui.settings"),placement:"left",width:360,open:this.state.settingsDrawerVisible,onClose:()=>this.setState({settingsDrawerVisible:!1}),children:[jsxRuntimeExports.jsxs("div",{className:styles$7.settingsGroupBox,children:[jsxRuntimeExports.jsx("div",{className:styles$7.settingsGroupTitle,children:t("ui.chatDisplay")}),jsxRuntimeExports.jsxs("div",{className:styles$7.settingsItem,children:[jsxRuntimeExports.jsx("span",{className:styles$7.settingsLabel,children:t("ui.permission.autoApprove.setting")}),jsxRuntimeExports.jsx(Select,{size:"small",value:autoApproveSeconds||0,onChange:value=>onAutoApproveChange&&onAutoApproveChange(value),options:[{label:t("ui.permission.autoApprove.off"),value:0},{label:"3s",value:3},{label:"5s",value:5},{label:"10s",value:10},{label:"15s",value:15},{label:"20s",value:20},{label:"30s",value:30},{label:"60s",value:60}],style:{width:100}})]}),this.props.approvalPrefs&&this.props.onApprovalPrefsChange&&jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("div",{className:styles$7.settingsItem,children:[jsxRuntimeExports.jsx("span",{className:styles$7.settingsLabel,children:t("ui.approval.settings.modalEnabled")}),jsxRuntimeExports.jsx(Switch,{checked:!1!==this.props.approvalPrefs.modalEnabled,onChange:checked=>this.props.onApprovalPrefsChange({modalEnabled:checked})})]}),jsxRuntimeExports.jsxs("div",{className:styles$7.settingsItem,children:[jsxRuntimeExports.jsx("span",{className:styles$7.settingsLabel,children:t("ui.approval.settings.soundEnabled")}),jsxRuntimeExports.jsx(Switch,{checked:!!this.props.approvalPrefs.soundEnabled,onChange:checked=>this.props.onApprovalPrefsChange({soundEnabled:checked})})]}),"undefined"!=typeof window&&window.tabBridge&&jsxRuntimeExports.jsxs("div",{className:styles$7.settingsItem,children:[jsxRuntimeExports.jsx("span",{className:styles$7.settingsLabel,children:t("ui.approval.settings.notifyOnlyWhenHidden")}),jsxRuntimeExports.jsx(Switch,{checked:!1!==this.props.approvalPrefs.notifyOnlyWhenHidden,onChange:checked=>this.props.onApprovalPrefsChange({notifyOnlyWhenHidden:checked})})]})]}),jsxRuntimeExports.jsxs("div",{className:styles$7.settingsItem,children:[jsxRuntimeExports.jsx("span",{className:styles$7.settingsLabel,children:t("ui.expandThinking")}),jsxRuntimeExports.jsx(Switch,{checked:!!expandThinking,onChange:checked=>onExpandThinkingChange&&onExpandThinkingChange(checked)})]}),jsxRuntimeExports.jsxs("div",{className:styles$7.settingsItem,children:[jsxRuntimeExports.jsx("span",{className:styles$7.settingsLabel,children:t("ui.showFullToolContent")}),jsxRuntimeExports.jsx(Switch,{checked:!!showFullToolContent,onChange:checked=>onShowFullToolContentChange&&onShowFullToolContentChange(checked)})]}),showFullToolContent&&jsxRuntimeExports.jsxs("div",{className:styles$7.settingsItem,children:[jsxRuntimeExports.jsx("span",{className:styles$7.settingsLabel,children:t("ui.collapseToolResults")}),jsxRuntimeExports.jsx(Switch,{checked:!!collapseToolResults,onChange:checked=>onCollapseToolResultsChange&&onCollapseToolResultsChange(checked)})]})]}),jsxRuntimeExports.jsxs("div",{className:styles$7.settingsGroupBox,children:[jsxRuntimeExports.jsx("div",{className:styles$7.settingsGroupTitle,children:t("ui.logSettings")}),jsxRuntimeExports.jsxs("div",{className:styles$7.settingsItem,children:[jsxRuntimeExports.jsx("span",{className:styles$7.settingsLabel,children:t("ui.resumeAutoChoice")}),jsxRuntimeExports.jsx(Switch,{checked:!!resumeAutoChoice,onChange:checked=>onResumeAutoChoiceToggle&&onResumeAutoChoiceToggle(checked)})]}),resumeAutoChoice&&jsxRuntimeExports.jsx("div",{className:styles$7.settingsItem,children:jsxRuntimeExports.jsxs(Radio.Group,{value:resumeAutoChoice,onChange:e=>onResumeAutoChoiceChange&&onResumeAutoChoiceChange(e.target.value),size:"small",children:[jsxRuntimeExports.jsx(Radio,{value:"continue",children:t("ui.resumeAutoChoice.continue")}),jsxRuntimeExports.jsx(Radio,{value:"new",children:t("ui.resumeAutoChoice.new")})]})})]}),jsxRuntimeExports.jsxs("div",{className:styles$7.settingsGroupBox,children:[jsxRuntimeExports.jsx("div",{className:styles$7.settingsGroupTitle,children:t("ui.themeStyle")}),jsxRuntimeExports.jsxs("div",{className:styles$7.settingsItem,children:[jsxRuntimeExports.jsx("span",{className:styles$7.settingsLabel,children:t("ui.themeColor")}),jsxRuntimeExports.jsx(Select,{size:"small",value:themeColor||"light",onChange:value=>onThemeColorChange&&onThemeColorChange(value),options:[{label:t("ui.themeColor.dark"),value:"dark"},{label:t("ui.themeColor.light"),value:"light"}],style:{width:140}})]}),jsxRuntimeExports.jsxs("div",{className:styles$7.settingsItem,children:[jsxRuntimeExports.jsx("span",{className:styles$7.settingsLabel,children:t("ui.languageSettings")}),jsxRuntimeExports.jsx(Select,{size:"small",value:getLang(),onChange:value=>{setLang(value),onLangChange&&onLangChange()},options:LANG_OPTIONS.map(o=>({label:o.label,value:o.value})),style:{width:140}})]})]})]}),jsxRuntimeExports.jsxs(Drawer,{title:jsxRuntimeExports.jsxs("span",{children:[t("ui.globalSettings")," ",jsxRuntimeExports.jsx(ConceptHelp,{doc:"GlobalSettings"})]}),placement:"left",width:400,open:this.state.globalSettingsVisible,onClose:()=>this.setState({globalSettingsVisible:!1}),children:[jsxRuntimeExports.jsxs("div",{className:styles$7.settingsItem,children:[jsxRuntimeExports.jsx("span",{className:styles$7.settingsLabel,children:t("ui.filterIrrelevant")}),jsxRuntimeExports.jsx(Switch,{checked:!!filterIrrelevant,onChange:checked=>onFilterIrrelevantChange&&onFilterIrrelevantChange(checked)})]}),jsxRuntimeExports.jsxs("div",{className:styles$7.settingsItem,children:[jsxRuntimeExports.jsx("span",{className:styles$7.settingsLabel,children:t("ui.expandDiff")}),jsxRuntimeExports.jsx(Switch,{checked:!!expandDiff,onChange:checked=>onExpandDiffChange&&onExpandDiffChange(checked)})]}),jsxRuntimeExports.jsx("div",{className:styles$7.settingsDivider}),jsxRuntimeExports.jsx("div",{className:styles$7.settingsLabel,children:t("ui.logDirTitle")}),jsxRuntimeExports.jsx(Input,{className:styles$7.logDirInput,value:this.state.logDirDraft??logDir,onChange:e=>this.setState({logDirDraft:e.target.value}),onBlur:()=>{const val=this.state.logDirDraft;null!=val&&val!==logDir&&(null==onLogDirChange||onLogDirChange(val)),this.setState({logDirDraft:null})},onPressEnter:()=>{const val=this.state.logDirDraft;null!=val&&val!==logDir&&(null==onLogDirChange||onLogDirChange(val)),this.setState({logDirDraft:null})},placeholder:"~/.claude/cc-viewer"})]}),jsxRuntimeExports.jsx(Drawer,{title:jsxRuntimeExports.jsxs("span",{children:[jsxRuntimeExports.jsx(RefIcon$4,{className:styles$7.titleIcon}),t("ui.projectStats")]}),placement:"left",width:400,open:this.state.projectStatsVisible,onClose:()=>this.setState({projectStatsVisible:!1}),children:this.renderProjectStatsContent()}),jsxRuntimeExports.jsx(PluginModal,{open:this.state.pluginModalVisible,onClose:()=>this.setState({pluginModalVisible:!1})}),jsxRuntimeExports.jsx(ProcessModal,{open:this.state.processModalVisible,onClose:()=>this.setState({processModalVisible:!1})}),jsxRuntimeExports.jsx(ProxyModal,{open:this.state.proxyModalVisible,onClose:()=>this.setState({proxyModalVisible:!1}),proxyProfiles:this.props.proxyProfiles,activeProxyId:this.props.activeProxyId,defaultConfig:this.props.defaultConfig,onProxyProfileChange:this.props.onProxyProfileChange}),this.renderSkillsManagerModal()]})}renderSkillsManagerModal(){const modal=this.state._skillsModal||{};return jsxRuntimeExports.jsx(SkillsManagerModal,{open:modal.open||!1,loading:modal.loading||!1,error:modal.error||null,skills:modal.skills||[],toggling:modal.toggling,onToggle:s=>this.handleToggleSkill(s),onClose:()=>this.setState(prev=>({_skillsModal:{...prev._skillsModal,open:!1}}))})}};__publicField(_AppHeader,"contextType",SettingsContext),__publicField(_AppHeader,"COMMAND_TAGS",new Set(["command-name","command-message","command-args","local-command-caveat","local-command-stdout"]));let AppHeader=_AppHeader;const styles$6_centerEmpty="_centerEmpty_midza_1",styles$6_scrollContainer="_scrollContainer_midza_8",styles$6_listItem="_listItem_midza_15",styles$6_listItemActive="_listItemActive_midza_29",styles$6_itemContent="_itemContent_midza_46",styles$6_itemHeader="_itemHeader_midza_51",styles$6_tagNoMargin="_tagNoMargin_midza_59",styles$6_modelName="_modelName_midza_64",styles$6_modelNameMain="_modelNameMain_midza_69",styles$6_time="_time_midza_73",styles$6_detailRow="_detailRow_midza_79",styles$6_urlText="_urlText_midza_86",styles$6_duration="_duration_midza_95",styles$6_statusOk="_statusOk_midza_100",styles$6_statusErr="_statusErr_midza_106",styles$6_statusDefault="_statusDefault_midza_111",styles$6_usageBox="_usageBox_midza_116",styles$6_cacheDot="_cacheDot_midza_126",styles$6_cacheDotLoss="_cacheDotLoss_midza_135",styles$6_cacheDotNormal="_cacheDotNormal_midza_140",styles$6_tagMainAgent="_tagMainAgent_midza_144",styles$6_tagPlan="_tagPlan_midza_150",styles$6_tagMuted="_tagMuted_midza_156",styles$6_tooltipPreLine="_tooltipPreLine_midza_162";class RequestList extends React__default.Component{constructor(props){super(props),__publicField(this,"handleKeyDown",e=>{if("ArrowUp"!==e.key&&"ArrowDown"!==e.key)return;const{requests:requests,selectedIndex:selectedIndex,onSelect:onSelect}=this.props;if(!requests.length)return;e.preventDefault();const current=selectedIndex??0,next="ArrowUp"===e.key?Math.max(0,current-1):Math.min(requests.length-1,current+1);next!==current&&onSelect(next)}),this.activeItemRef=React__default.createRef()}componentDidMount(){this.scrollToSelected(!0)}shouldComponentUpdate(nextProps){return nextProps.requests!==this.props.requests||nextProps.selectedIndex!==this.props.selectedIndex||nextProps.scrollCenter!==this.props.scrollCenter||nextProps.cacheLossMap!==this.props.cacheLossMap}componentDidUpdate(prevProps){this.props.scrollCenter&&prevProps.selectedIndex!==this.props.selectedIndex?this.scrollToSelected(!0):prevProps.selectedIndex!==this.props.selectedIndex&&(this.scrollToSelected(!1),this.activeItemRef.current&&this.activeItemRef.current.focus({preventScroll:!0}))}scrollToSelected(center){this.activeItemRef.current&&(this.activeItemRef.current.scrollIntoView({block:center?"center":"nearest",behavior:"instant"}),center&&this.props.onScrollDone&&this.props.onScrollDone())}render(){const{requests:requests,selectedIndex:selectedIndex,onSelect:onSelect}=this.props;return 0===requests.length?jsxRuntimeExports.jsx("div",{className:styles$6_centerEmpty,children:jsxRuntimeExports.jsx(Empty,{description:t("ui.waitingRequests")})}):jsxRuntimeExports.jsx("div",{className:styles$6_scrollContainer,onKeyDown:this.handleKeyDown,children:jsxRuntimeExports.jsx(List,{dataSource:requests,size:"small",split:!1,renderItem:(req,index)=>{var _a,_b,_c;const time2=new Date(req.timestamp).toLocaleTimeString("zh-CN"),isActive=index===selectedIndex,statusOk2=req.response&&req.response.status<400,statusErr2=req.response&&req.response.status>=400,model=getModelShort(null==(_a=req.body)?void 0:_a.model),nextReq=index+1<requests.length?requests[index+1]:null,{type:reqType,subType:subType}=classifyRequest(req,nextReq),usage=null==(_c=null==(_b=req.response)?void 0:_b.body)?void 0:_c.usage,inputTokens=usage?(usage.input_tokens||0)+(usage.cache_read_input_tokens||0)+(usage.cache_creation_input_tokens||0):null,outputTokens=(null==usage?void 0:usage.output_tokens)||null,cacheRead=(null==usage?void 0:usage.cache_read_input_tokens)||0,cacheCreate=(null==usage?void 0:usage.cache_creation_input_tokens)||0,displayUrl=req.proxyUrl||req.url;let urlShort=displayUrl;try{const u=new URL(displayUrl);urlShort=u.host+u.pathname}catch{}return jsxRuntimeExports.jsx(List.Item,{ref:isActive?this.activeItemRef:void 0,tabIndex:0,onClick:()=>onSelect(index),className:`${styles$6_listItem} ${isActive?styles$6_listItemActive:""}`,children:jsxRuntimeExports.jsxs("div",{className:styles$6_itemContent,children:[jsxRuntimeExports.jsxs("div",{className:styles$6_itemHeader,children:["MainAgent"===reqType?jsxRuntimeExports.jsx(Tag,{className:`${styles$6_tagNoMargin} ${styles$6_tagMainAgent}`,children:"MainAgent"}):"Plan"===reqType?jsxRuntimeExports.jsx(Tag,{className:`${styles$6_tagNoMargin} ${styles$6_tagPlan}`,children:formatRequestTag(reqType,subType)}):"Count"===reqType||"Preflight"===reqType?jsxRuntimeExports.jsx(Tag,{className:`${styles$6_tagNoMargin} ${styles$6_tagMuted}`,children:reqType}):"Synthetic"===reqType?jsxRuntimeExports.jsx(Tag,{className:`${styles$6_tagNoMargin} ${styles$6_tagMuted}`,children:formatRequestTag(reqType,subType)}):jsxRuntimeExports.jsx(Tag,{className:styles$6_tagNoMargin,children:formatRequestTag(reqType,subType)}),model&&jsxRuntimeExports.jsx("span",{className:`${styles$6_modelName} ${"MainAgent"===reqType?styles$6_modelNameMain:""}`,children:model}),jsxRuntimeExports.jsx("span",{className:styles$6_time,children:time2})]}),jsxRuntimeExports.jsxs("div",{className:styles$6_detailRow,children:[jsxRuntimeExports.jsx("span",{className:styles$6_urlText,title:displayUrl,children:urlShort}),req.duration&&jsxRuntimeExports.jsxs("span",{className:styles$6_duration,children:[req.duration,"ms"]}),req.response&&jsxRuntimeExports.jsx("span",{className:statusOk2?styles$6_statusOk:statusErr2?styles$6_statusErr:styles$6_statusDefault,children:req.response.status})]}),usage&&jsxRuntimeExports.jsxs("div",{className:styles$6_usageBox,children:[jsxRuntimeExports.jsxs("div",{children:["token: output:",formatTokenCount(outputTokens)||0,", input: ",formatTokenCount(inputTokens)||0]}),(cacheRead>0||cacheCreate>0)&&jsxRuntimeExports.jsx("div",{children:(()=>{var _a2;const loss=null==(_a2=this.props.cacheLossMap)?void 0:_a2.get(index),reasonI18nMap={ttl:"ui.cacheLoss.ttl",system_change:"ui.cacheLoss.systemChange",tools_change:"ui.cacheLoss.toolsChange",model_change:"ui.cacheLoss.modelChange",msg_truncated:"ui.cacheLoss.msgTruncated",msg_modified:"ui.cacheLoss.msgModified",key_change:"ui.cacheLoss.keyChange"};let dot;if(loss){const tooltipText=(loss.reasons||[loss.reason]).map(r=>t(reasonI18nMap[r]||reasonI18nMap.key_change)).join("\n");dot=jsxRuntimeExports.jsx(Tooltip,{title:jsxRuntimeExports.jsx("span",{className:styles$6_tooltipPreLine,children:tooltipText}),children:jsxRuntimeExports.jsx("span",{className:`${styles$6_cacheDot} ${styles$6_cacheDotLoss}`})})}else dot=jsxRuntimeExports.jsx("span",{className:`${styles$6_cacheDot} ${styles$6_cacheDotNormal}`});return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:["cache",dot,": ",cacheRead>0?`read:${formatTokenCount(cacheRead)}`:"",cacheRead>0&&cacheCreate>0?", ":"",cacheCreate>0?`create:${formatTokenCount(cacheCreate)}`:""]})})()})]})]})})}})})}}const isDate=data=>!!data&&data instanceof Date,isObject=data=>"object"==typeof data&&null!==data,isFunction=data=>!!data&&data instanceof Object&&"function"==typeof data;function quoteString(value,quoted){return void 0===quoted&&(quoted=!1),!value||quoted?`"${value}"`:value}function ExpandableObject(_ref){let{field:field,value:value,data:data,lastElement:lastElement,openBracket:openBracket,closeBracket:closeBracket,level:level,style:style,shouldExpandNode:shouldExpandNode,clickToExpandNode:clickToExpandNode,outerRef:outerRef,beforeExpandChange:beforeExpandChange}=_ref;const shouldExpandNodeCalledRef=reactExports.useRef(!1),[expanded,setExpanded]=reactExports.useState(()=>shouldExpandNode(level,value,field)),expanderButtonRef=reactExports.useRef(null);reactExports.useEffect(()=>{shouldExpandNodeCalledRef.current?setExpanded(shouldExpandNode(level,value,field)):shouldExpandNodeCalledRef.current=!0},[shouldExpandNode]);const contentsId=reactExports.useId();if(0===data.length)return function(_ref2){let{field:field,openBracket:openBracket,closeBracket:closeBracket,lastElement:lastElement,style:style}=_ref2;return reactExports.createElement("div",{className:style.basicChildStyle,role:"treeitem","aria-selected":void 0},(field||""===field)&&reactExports.createElement("span",{className:style.label},quoteString(field,style.quotesForFieldNames),":"),reactExports.createElement("span",{className:style.punctuation},openBracket),reactExports.createElement("span",{className:style.punctuation},closeBracket),!lastElement&&reactExports.createElement("span",{className:style.punctuation},","))}({field:field,openBracket:openBracket,closeBracket:closeBracket,lastElement:lastElement,style:style});const expanderIconStyle=expanded?style.collapseIcon:style.expandIcon,ariaLabel=expanded?style.ariaLables.collapseJson:style.ariaLables.expandJson,childLevel=level+1,lastIndex=data.length-1,setExpandWithCallback=newExpandValue=>{expanded===newExpandValue||beforeExpandChange&&!beforeExpandChange({level:level,value:value,field:field,newExpandValue:newExpandValue})||setExpanded(newExpandValue)},onKeyDown=e=>{if("ArrowRight"===e.key||"ArrowLeft"===e.key)e.preventDefault(),setExpandWithCallback("ArrowRight"===e.key);else if("ArrowUp"===e.key||"ArrowDown"===e.key){e.preventDefault();const direction="ArrowUp"===e.key?-1:1;if(!outerRef.current)return;const buttonElements=outerRef.current.querySelectorAll("[role=button]");let currentIndex=-1;for(let i=0;i<buttonElements.length;i++)if(0===buttonElements[i].tabIndex){currentIndex=i;break}if(currentIndex<0)return;const nextIndex=(currentIndex+direction+buttonElements.length)%buttonElements.length;buttonElements[currentIndex].tabIndex=-1,buttonElements[nextIndex].tabIndex=0,buttonElements[nextIndex].focus()}},onClick=()=>{var _outerRef$current;setExpandWithCallback(!expanded);const buttonElement=expanderButtonRef.current;if(!buttonElement)return;const prevButtonElement=null===(_outerRef$current=outerRef.current)||void 0===_outerRef$current?void 0:_outerRef$current.querySelector('[role=button][tabindex="0"]');prevButtonElement&&(prevButtonElement.tabIndex=-1),buttonElement.tabIndex=0,buttonElement.focus()};return reactExports.createElement("div",{className:style.basicChildStyle,role:"treeitem","aria-expanded":expanded,"aria-selected":void 0},reactExports.createElement("span",{className:expanderIconStyle,onClick:onClick,onKeyDown:onKeyDown,role:"button","aria-label":ariaLabel,"aria-expanded":expanded,"aria-controls":expanded?contentsId:void 0,ref:expanderButtonRef,tabIndex:0===level?0:-1}),(field||""===field)&&(clickToExpandNode?reactExports.createElement("span",{className:style.clickableLabel,onClick:onClick,onKeyDown:onKeyDown},quoteString(field,style.quotesForFieldNames),":"):reactExports.createElement("span",{className:style.label},quoteString(field,style.quotesForFieldNames),":")),reactExports.createElement("span",{className:style.punctuation},openBracket),expanded?reactExports.createElement("ul",{id:contentsId,role:"group",className:style.childFieldsContainer},data.map((dataElement,index)=>reactExports.createElement(DataRender,{key:dataElement[0]||index,field:dataElement[0],value:dataElement[1],style:style,lastElement:index===lastIndex,level:childLevel,shouldExpandNode:shouldExpandNode,clickToExpandNode:clickToExpandNode,beforeExpandChange:beforeExpandChange,outerRef:outerRef}))):reactExports.createElement("span",{className:style.collapsedContent,onClick:onClick,onKeyDown:onKeyDown}),reactExports.createElement("span",{className:style.punctuation},closeBracket),!lastElement&&reactExports.createElement("span",{className:style.punctuation},","))}function JsonObject(_ref3){let{field:field,value:value,style:style,lastElement:lastElement,shouldExpandNode:shouldExpandNode,clickToExpandNode:clickToExpandNode,level:level,outerRef:outerRef,beforeExpandChange:beforeExpandChange}=_ref3;return ExpandableObject({field:field,value:value,lastElement:lastElement||!1,level:level,openBracket:"{",closeBracket:"}",style:style,shouldExpandNode:shouldExpandNode,clickToExpandNode:clickToExpandNode,data:Object.keys(value).map(key=>[key,value[key]]),outerRef:outerRef,beforeExpandChange:beforeExpandChange})}function JsonArray(_ref4){let{field:field,value:value,style:style,lastElement:lastElement,level:level,shouldExpandNode:shouldExpandNode,clickToExpandNode:clickToExpandNode,outerRef:outerRef,beforeExpandChange:beforeExpandChange}=_ref4;return ExpandableObject({field:field,value:value,lastElement:lastElement||!1,level:level,openBracket:"[",closeBracket:"]",style:style,shouldExpandNode:shouldExpandNode,clickToExpandNode:clickToExpandNode,data:value.map(element=>[void 0,element]),outerRef:outerRef,beforeExpandChange:beforeExpandChange})}function JsonPrimitiveValue(_ref5){let stringValue,{field:field,value:value,style:style,lastElement:lastElement}=_ref5,valueStyle=style.otherValue;var data;return null===value?(stringValue="null",valueStyle=style.nullValue):void 0===value?(stringValue="undefined",valueStyle=style.undefinedValue):"string"==typeof(data=value)||data instanceof String?(stringValue=function(value,quoted,stringify){return stringify?JSON.stringify(value):quoted?`"${value}"`:value}(value,!style.noQuotesForStringValues,style.stringifyStringValues),valueStyle=style.stringValue):(data=>"boolean"==typeof data||data instanceof Boolean)(value)?(stringValue=value?"true":"false",valueStyle=style.booleanValue):(data=>"number"==typeof data||data instanceof Number)(value)?(stringValue=value.toString(),valueStyle=style.numberValue):(data=>"bigint"==typeof data||data instanceof BigInt)(value)?(stringValue=`${value.toString()}n`,valueStyle=style.numberValue):stringValue=isDate(value)?value.toISOString():isFunction(value)?"function() { }":value.toString(),reactExports.createElement("div",{className:style.basicChildStyle,role:"treeitem","aria-selected":void 0},(field||""===field)&&reactExports.createElement("span",{className:style.label},quoteString(field,style.quotesForFieldNames),":"),reactExports.createElement("span",{className:valueStyle},stringValue),!lastElement&&reactExports.createElement("span",{className:style.punctuation},","))}function DataRender(props){const value=props.value;return data=value,Array.isArray(data)?reactExports.createElement(JsonArray,Object.assign({},props)):!isObject(value)||isDate(value)||isFunction(value)?reactExports.createElement(JsonPrimitiveValue,Object.assign({},props)):reactExports.createElement(JsonObject,Object.assign({},props));var data}var styles$5_basic_element_style="_2bkNM",styles$5_child_fields_container="_1BXBN";const defaultAriaLables={collapseJson:"collapse JSON",expandJson:"expand JSON"},defaultStyles={container:"_2IvMF _GzYRV",basicChildStyle:styles$5_basic_element_style,childFieldsContainer:styles$5_child_fields_container,label:"_1MGIk",clickableLabel:"_2YKJg _1MGIk _1MFti",nullValue:"_2T6PJ",undefinedValue:"_1Gho6",stringValue:"_vGjyY",booleanValue:"_3zQKs",numberValue:"_1bQdo",otherValue:"_1xvuR",punctuation:"_3uHL6 _3eOF8",collapseIcon:"_oLqym _f10Tu _1MFti _1LId0",expandIcon:"_2AXVT _f10Tu _1MFti _1UmXx",collapsedContent:"_2KJWg _1pNG9 _1MFti",noQuotesForStringValues:!1,quotesForFieldNames:!1,ariaLables:defaultAriaLables,stringifyStringValues:!1},darkStyles={container:"_11RoI _GzYRV",basicChildStyle:styles$5_basic_element_style,childFieldsContainer:styles$5_child_fields_container,label:"_2bSDX",clickableLabel:"_1RQEj _2bSDX _1MFti",nullValue:"_LaAZe",undefinedValue:"_GTKgm",stringValue:"_Chy1W",booleanValue:"_2vRm-",numberValue:"_2bveF",otherValue:"_1prJR",punctuation:"_gsbQL _3eOF8",collapseIcon:"_3QHg2 _f10Tu _1MFti _1LId0",expandIcon:"_17H2C _f10Tu _1MFti _1UmXx",collapsedContent:"_3fDAz _1pNG9 _1MFti",noQuotesForStringValues:!1,quotesForFieldNames:!1,ariaLables:defaultAriaLables,stringifyStringValues:!1},allExpanded=()=>!0,JsonView=_ref=>{let{data:data,style:style=defaultStyles,shouldExpandNode:shouldExpandNode=allExpanded,clickToExpandNode:clickToExpandNode=!1,beforeExpandChange:beforeExpandChange,compactTopLevel:compactTopLevel,...ariaAttrs}=_ref;const outerRef=reactExports.useRef(null);return reactExports.createElement("div",Object.assign({"aria-label":"JSON view"},ariaAttrs,{className:style.container,ref:outerRef,role:"tree"}),compactTopLevel&&isObject(data)?Object.entries(data).map(_ref2=>{let[key,value]=_ref2;return reactExports.createElement(DataRender,{key:key,field:key,value:value,style:{...defaultStyles,...style},lastElement:!0,level:1,shouldExpandNode:shouldExpandNode,clickToExpandNode:clickToExpandNode,beforeExpandChange:beforeExpandChange,outerRef:outerRef})}):reactExports.createElement(DataRender,{value:data,style:{...defaultStyles,...style},lastElement:!0,level:0,shouldExpandNode:shouldExpandNode,clickToExpandNode:clickToExpandNode,outerRef:outerRef,beforeExpandChange:beforeExpandChange}))},styles$4_container="_container_qeuid_1";class JsonViewer extends React__default.Component{shouldComponentUpdate(nextProps){return nextProps.data!==this.props.data||nextProps.defaultExpand!==this.props.defaultExpand||nextProps.expandNode!==this.props.expandNode}render(){const{data:data,defaultExpand:defaultExpand,expandNode:expandNode}=this.props,customStyles={..."undefined"!=typeof document&&"light"!==document.documentElement.getAttribute("data-theme")?darkStyles:defaultStyles,container:"rjv-container"};if(null==data)return null;const shouldExpandNode="function"==typeof expandNode?expandNode:"all"===defaultExpand?()=>!0:"root"===defaultExpand?level=>level<2:level=>level<1;return jsxRuntimeExports.jsx("div",{className:styles$4_container,children:jsxRuntimeExports.jsx(JsonView,{data:data,shouldExpandNode:shouldExpandNode,style:customStyles})})}}const styles$3={root:"_root_17dqd_1",sidebar:"_sidebar_17dqd_9",section:"_section_17dqd_18",sectionHeader:"_sectionHeader_17dqd_22",arrow:"_arrow_17dqd_48",sectionTitle:"_sectionTitle_17dqd_54",sectionCount:"_sectionCount_17dqd_62",sectionBody:"_sectionBody_17dqd_71",historyToggle:"_historyToggle_17dqd_76",historyToggleLabel:"_historyToggleLabel_17dqd_102",item:"_item_17dqd_107",itemActive:"_itemActive_17dqd_135",itemContent:"_itemContent_17dqd_142",itemLabel:"_itemLabel_17dqd_148",itemSublabel:"_itemSublabel_17dqd_156",itemTime:"_itemTime_17dqd_165",content:"_content_17dqd_174",contentEmpty:"_contentEmpty_17dqd_182",contentInner:"_contentInner_17dqd_189",emptyWrap:"_emptyWrap_17dqd_193",roleHeader:"_roleHeader_17dqd_201",roleBadge:"_roleBadge_17dqd_209",role_user:"_role_user_17dqd_218",role_assistant:"_role_assistant_17dqd_224",roleLabel:"_roleLabel_17dqd_230",contentTime:"_contentTime_17dqd_237",turnDivider:"_turnDivider_17dqd_245",textBlock:"_textBlock_17dqd_252",textBlockBar:"_textBlockBar_17dqd_259",textBlockBody:"_textBlockBody_17dqd_268",textBlockCompact:"_textBlockCompact_17dqd_276",textBlockCompactFloat:"_textBlockCompactFloat_17dqd_283",thinkingBlock:"_thinkingBlock_17dqd_290",thinkingHeader:"_thinkingHeader_17dqd_298",thinkingPreview:"_thinkingPreview_17dqd_313",thinkingBody:"_thinkingBody_17dqd_323",toolBlock:"_toolBlock_17dqd_329",toolBlockResult:"_toolBlockResult_17dqd_336",toolBlockError:"_toolBlockError_17dqd_340",toolBlockHeader:"_toolBlockHeader_17dqd_344",toolBlockBody:"_toolBlockBody_17dqd_355",toolName:"_toolName_17dqd_360",toolId:"_toolId_17dqd_366",errorLabel:"_errorLabel_17dqd_373",blockTag:"_blockTag_17dqd_383",blockTagText:"_blockTagText_17dqd_396",blockTagThinking:"_blockTagThinking_17dqd_402",blockTagResult:"_blockTagResult_17dqd_408",blockTagError:"_blockTagError_17dqd_414",jsonBlock:"_jsonBlock_17dqd_421",jsonBlockLabel:"_jsonBlockLabel_17dqd_428",blockSeparator:"_blockSeparator_17dqd_438",markdownBody:"_markdownBody_17dqd_445"},{Text:Text$1}=Typography;function parseContentBlocks(content2){if(null==content2)return[];if("string"==typeof content2){const trimmed=content2.trim();return trimmed?[{type:"markdown",text:trimmed}]:[]}if(Array.isArray(content2)){const blocks=[];for(const block of content2)if(block)if("text"===block.type){const trimmed=(block.text||"").trim();trimmed&&blocks.push({type:"markdown",text:trimmed})}else if("tool_use"===block.type)blocks.push({type:"tool_use",name:block.name||"unknown",id:block.id||"",input:block.input??{}});else if("tool_result"===block.type){const inner=parseResultContent(block.content);blocks.push({type:"tool_result",tool_use_id:block.tool_use_id||"",is_error:block.is_error,content:inner})}else if("thinking"===block.type){const text=block.thinking||"";text.trim()&&blocks.push({type:"thinking",text:text})}else"image"===block.type?blocks.push({type:"json",label:"image",data:block}):blocks.push({type:"json",label:block.type||"block",data:block});return blocks}return[{type:"json",label:"content",data:content2}]}function parseResultContent(content2){if(null==content2)return[];if("string"==typeof content2){const trimmed=content2.trim();return trimmed?[{type:"markdown",text:trimmed}]:[]}return Array.isArray(content2)?content2.flatMap(c=>{if(!c)return[];if("text"===c.type){const trimmed=(c.text||"").trim();return trimmed?[{type:"markdown",text:trimmed}]:[]}return[{type:"json",label:c.type||"block",data:c}]}):[{type:"json",label:"content",data:content2}]}function parseToolBlocks(tool){const blocks=[],name=(null==tool?void 0:tool.name)||"unknown",desc=(null==tool?void 0:tool.description)||"";let md=`### ${name}\n\n`;desc&&(md+=`${desc}\n\n`),blocks.push({type:"markdown",text:md});const schema=(null==tool?void 0:tool.input_schema)||(null==tool?void 0:tool.parameters)||null;return schema&&blocks.push({type:"json",label:"Parameters",data:schema}),blocks}function extractPreviewText(content2){var _a;if("string"==typeof content2)return content2.slice(0,60).replace(/\n/g," ");if(Array.isArray(content2))for(const block of content2)if("text"===(null==block?void 0:block.type)&&(null==(_a=block.text)?void 0:_a.trim()))return block.text.trim().slice(0,60).replace(/\n/g," ");return""}function formatTurnTime(isoStr){try{return new Date(isoStr).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})}catch{return null}}function TranslatableMarkdown({text:text,compact:compact}){const displayHtml=renderMarkdown(text);return compact?jsxRuntimeExports.jsx("div",{className:styles$3.textBlockCompact,children:jsxRuntimeExports.jsx("div",{className:`chat-md ${styles$3.markdownBody}`,dangerouslySetInnerHTML:{__html:displayHtml}})}):jsxRuntimeExports.jsxs("div",{className:styles$3.textBlock,children:[jsxRuntimeExports.jsx("div",{className:styles$3.textBlockBar,children:jsxRuntimeExports.jsx("span",{className:`${styles$3.blockTag} ${styles$3.blockTagText}`,children:"text"})}),jsxRuntimeExports.jsx("div",{className:`chat-md ${styles$3.textBlockBody}`,dangerouslySetInnerHTML:{__html:displayHtml}})]})}function ThinkingBlock({block:block}){const[expanded,setExpanded]=reactExports.useState(!0),preview=block.text.length>60?block.text.slice(0,60).replace(/\n/g," ")+"…":block.text.replace(/\n/g," ");return jsxRuntimeExports.jsxs("div",{className:styles$3.thinkingBlock,children:[jsxRuntimeExports.jsxs("div",{className:styles$3.thinkingHeader,onClick:()=>setExpanded(v=>!v),children:[expanded?jsxRuntimeExports.jsx(RefIcon$c,{className:styles$3.arrow}):jsxRuntimeExports.jsx(RefIcon$d,{className:styles$3.arrow}),jsxRuntimeExports.jsx("span",{className:`${styles$3.blockTag} ${styles$3.blockTagThinking}`,children:"thinking"}),!expanded&&jsxRuntimeExports.jsx("span",{className:styles$3.thinkingPreview,children:preview})]}),expanded&&jsxRuntimeExports.jsx("div",{className:styles$3.thinkingBody,children:jsxRuntimeExports.jsx("div",{className:`chat-md ${styles$3.markdownBody}`,dangerouslySetInnerHTML:{__html:renderMarkdown(block.text)}})})]})}function RenderBlocks({blocks:blocks,compact:compact}){return blocks&&0!==blocks.length?jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:blocks.map((block,i)=>jsxRuntimeExports.jsx(RenderBlock,{block:block,compact:compact},i))}):null}function RenderBlock({block:block,compact:compact}){var _a;return"separator"===block.type?jsxRuntimeExports.jsx("hr",{className:styles$3.blockSeparator}):"markdown"===block.type?(null==(_a=block.text)?void 0:_a.trim())?jsxRuntimeExports.jsx(TranslatableMarkdown,{text:block.text,compact:compact}):null:"thinking"===block.type?jsxRuntimeExports.jsx(ThinkingBlock,{block:block}):"tool_use"===block.type?jsxRuntimeExports.jsxs("div",{className:styles$3.toolBlock,children:[jsxRuntimeExports.jsxs("div",{className:styles$3.toolBlockHeader,children:[jsxRuntimeExports.jsx("span",{className:styles$3.blockTag,children:"tool_use"}),jsxRuntimeExports.jsx("span",{className:styles$3.toolName,children:block.name}),block.id&&jsxRuntimeExports.jsx("span",{className:styles$3.toolId,children:block.id})]}),jsxRuntimeExports.jsx("div",{className:styles$3.toolBlockBody,children:jsxRuntimeExports.jsx(JsonViewer,{data:block.input,defaultExpand:"root"})})]}):"tool_result"===block.type?jsxRuntimeExports.jsxs("div",{className:`${styles$3.toolBlock} ${block.is_error?styles$3.toolBlockError:styles$3.toolBlockResult}`,children:[jsxRuntimeExports.jsxs("div",{className:styles$3.toolBlockHeader,children:[jsxRuntimeExports.jsx("span",{className:`${styles$3.blockTag} ${block.is_error?styles$3.blockTagError:styles$3.blockTagResult}`,children:"tool_result"}),block.tool_use_id&&jsxRuntimeExports.jsx("span",{className:styles$3.toolId,children:block.tool_use_id}),block.is_error&&jsxRuntimeExports.jsx("span",{className:styles$3.errorLabel,children:"error"})]}),jsxRuntimeExports.jsx("div",{className:styles$3.toolBlockBody,children:jsxRuntimeExports.jsx(RenderBlocks,{blocks:block.content,compact:!0})})]}):"json"===block.type?jsxRuntimeExports.jsxs("div",{className:styles$3.jsonBlock,children:[block.label&&jsxRuntimeExports.jsx("div",{className:styles$3.jsonBlockLabel,children:block.label}),jsxRuntimeExports.jsx(JsonViewer,{data:block.data,defaultExpand:"root"})]}):null}function TurnContent({turn:turn}){const timeStr=turn.timestamp?formatTurnTime(turn.timestamp):null,assistantTimeStr=turn.assistantTimestamp?formatTurnTime(turn.assistantTimestamp):null;return jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsxs("div",{className:styles$3.roleHeader,children:[jsxRuntimeExports.jsx("span",{className:`${styles$3.roleBadge} ${styles$3.role_user}`,children:"user"}),jsxRuntimeExports.jsx("span",{className:styles$3.roleLabel,children:`Turn ${turn.turnIndex+1}`}),timeStr&&jsxRuntimeExports.jsx("span",{className:styles$3.contentTime,children:timeStr})]}),jsxRuntimeExports.jsx(RenderBlocks,{blocks:turn.userBlocks}),turn.assistantBlocks&&jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:styles$3.turnDivider}),jsxRuntimeExports.jsxs("div",{className:styles$3.roleHeader,children:[jsxRuntimeExports.jsx("span",{className:`${styles$3.roleBadge} ${styles$3.role_assistant}`,children:"assistant"}),assistantTimeStr&&jsxRuntimeExports.jsx("span",{className:styles$3.contentTime,children:assistantTimeStr})]}),jsxRuntimeExports.jsx(RenderBlocks,{blocks:turn.assistantBlocks})]})]})}function AccordionSection({sectionKey:sectionKey,title:title,items:items,historyItems:historyItems=[],onSelect:onSelect,onSelectById:onSelectById,selectedId:selectedId,sidebarRef:sidebarRef}){const[open,setOpen]=reactExports.useState("tools"!==sectionKey),[historyOpen,setHistoryOpen]=reactExports.useState(!1),totalCount=items.length+historyItems.length,historyToggleId=`${sectionKey}__history_toggle`;function handleControlKeyDown(event,controlId){var _a;const nextId=function({currentId:currentId,visibleIds:visibleIds=[],key:key}){if("ArrowUp"!==key&&"ArrowDown"!==key)return null;const currentIndex=visibleIds.findIndex(id=>id===currentId);return currentIndex>=0?visibleIds[currentIndex+("ArrowUp"===key?-1:1)]??null:null}({currentId:controlId,visibleIds:Array.from((null==(_a=sidebarRef.current)?void 0:_a.querySelectorAll("[data-context-sidebar-control]"))||[]).map(el=>el.dataset.contextSidebarControl).filter(Boolean),key:event.key});nextId&&(event.preventDefault(),"undefined"!=typeof window&&window.requestAnimationFrame(()=>{var _a2;!function(controlId){var _a;const el=null==(_a=sidebarRef.current)?void 0:_a.querySelector(`[data-context-sidebar-control="${controlId}"]`);el&&(el.focus(),el.scrollIntoView({block:"nearest"}))}(nextId);const nextEl=null==(_a2=sidebarRef.current)?void 0:_a2.querySelector(`[data-context-sidebar-control="${nextId}"]`);"item"===(null==nextEl?void 0:nextEl.dataset.controlType)&&onSelectById(nextId)}))}function renderItem(item2){const active=selectedId===item2.id;return jsxRuntimeExports.jsxs("button",{type:"button",className:`${styles$3.item} ${active?styles$3.itemActive:""}`,onClick:()=>onSelect(item2),onKeyDown:event=>handleControlKeyDown(event,item2.id),"aria-current":active?"true":void 0,"data-context-sidebar-control":item2.id,"data-control-type":"item",children:[jsxRuntimeExports.jsxs("div",{className:styles$3.itemContent,children:[jsxRuntimeExports.jsx("span",{className:styles$3.itemLabel,children:item2.label}),item2.sublabel&&!active&&jsxRuntimeExports.jsx("div",{className:styles$3.itemSublabel,children:item2.sublabel})]}),item2.time&&jsxRuntimeExports.jsx("span",{className:styles$3.itemTime,children:item2.time})]},item2.id)}return jsxRuntimeExports.jsxs("div",{className:styles$3.section,children:[jsxRuntimeExports.jsxs("button",{type:"button",className:styles$3.sectionHeader,onClick:()=>setOpen(v=>!v),"aria-expanded":open,children:[open?jsxRuntimeExports.jsx(RefIcon$c,{className:styles$3.arrow}):jsxRuntimeExports.jsx(RefIcon$d,{className:styles$3.arrow}),jsxRuntimeExports.jsx("span",{className:styles$3.sectionTitle,children:title}),jsxRuntimeExports.jsx("span",{className:styles$3.sectionCount,children:totalCount})]}),open&&jsxRuntimeExports.jsxs("div",{className:styles$3.sectionBody,children:[historyItems.length>0&&jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("button",{type:"button",className:styles$3.historyToggle,onClick:()=>setHistoryOpen(v=>!v),onKeyDown:event=>handleControlKeyDown(event,historyToggleId),"aria-expanded":historyOpen,"data-context-sidebar-control":historyToggleId,"data-control-type":"toggle",children:[historyOpen?jsxRuntimeExports.jsx(RefIcon$c,{className:styles$3.arrow}):jsxRuntimeExports.jsx(RefIcon$d,{className:styles$3.arrow}),jsxRuntimeExports.jsxs("span",{className:styles$3.historyToggleLabel,children:[t("ui.context.history")," (",historyItems.length,")"]})]}),historyOpen&&historyItems.map(renderItem)]}),items.map(renderItem)]})]})}function ContextTab({body:body,response:response}){const[selectedItem,setSelectedItem]=reactExports.useState(null),sidebarRef=reactExports.useRef(null),turns=reactExports.useMemo(()=>{if(!Array.isArray(null==body?void 0:body.messages))return[];const allTurns=function(messages){var _a;const turns=[];let i=0;for(;i<messages.length;){const userMsg=messages[i];if("user"!==(null==userMsg?void 0:userMsg.role)){i++;continue}const assistantMsg="assistant"===(null==(_a=messages[i+1])?void 0:_a.role)?messages[i+1]:null;turns.push({id:`turn__${i}`,isTurn:!0,turnIndex:turns.length,timestamp:userMsg._timestamp||null,assistantTimestamp:(null==assistantMsg?void 0:assistantMsg._timestamp)||null,userBlocks:parseContentBlocks(null==userMsg?void 0:userMsg.content),assistantBlocks:assistantMsg?parseContentBlocks(assistantMsg.content):null,preview:extractPreviewText(null==userMsg?void 0:userMsg.content)}),i+=assistantMsg?2:1}return turns}(body.messages);if(0===allTurns.length)return allTurns;const last=allTurns[allTurns.length-1],responseBlocks=(null==response?void 0:response.content)?parseContentBlocks(response.content):null;return[...allTurns.slice(0,-1),{...last,assistantBlocks:responseBlocks??last.assistantBlocks}]},[body,response]);if(reactExports.useEffect(()=>{turns.length>0?setSelectedItem(turns[turns.length-1]):setSelectedItem(null)},[body,response]),!body||"object"!=typeof body)return jsxRuntimeExports.jsx("div",{className:styles$3.emptyWrap,children:jsxRuntimeExports.jsx(Empty,{description:t("ui.context.noData")})});const accordionSections=[];Array.isArray(body.tools)&&body.tools.length>0&&accordionSections.push({key:"tools",title:jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[t("ui.context.tools")," ",jsxRuntimeExports.jsx(ConceptHelp,{doc:"ToolsFirst"})]}),items:body.tools.map((tool,i)=>({id:`tool__${i}`,label:(null==tool?void 0:tool.name)||`Tool ${i}`,blocks:parseToolBlocks(tool)}))});const systemBlocks=function(system){if(!system)return null;if("string"==typeof system)return[{type:"markdown",text:system}];if(Array.isArray(system)){const blocks=[];return system.forEach((item2,i)=>{i>0&&blocks.push({type:"separator"}),item2&&("string"==typeof item2?blocks.push({type:"markdown",text:item2}):"text"===item2.type?blocks.push({type:"markdown",text:item2.text||""}):blocks.push({type:"json",label:item2.type||"item",data:item2}))}),blocks}return[{type:"json",label:"system",data:system}]}(body.system);if(null!=systemBlocks&&accordionSections.push({key:"system",title:t("ui.context.systemPrompt"),items:[{id:"system__0",label:t("ui.context.systemPrompt"),blocks:systemBlocks}]}),turns.length>0){const toHistoryItem=turn=>({...turn,label:t("ui.context.historyTurnNoTime",{n:turn.turnIndex+1}),time:turn.timestamp?formatTurnTime(turn.timestamp):null,sublabel:turn.preview||void 0}),toCurrentItem=turn=>({...turn,label:t("ui.context.currentTurn"),sublabel:turn.preview||void 0}),historyTurns=turns.slice(0,-1).map(toHistoryItem),currentTurn=toCurrentItem(turns[turns.length-1]);accordionSections.push({key:"messages",title:t("ui.context.messages"),historyItems:historyTurns.length>0?historyTurns:void 0,items:[currentTurn]})}if(0===accordionSections.length)return jsxRuntimeExports.jsx("div",{className:styles$3.emptyWrap,children:jsxRuntimeExports.jsx(Empty,{description:t("ui.context.noFields")})});const currentSelectedItem=(null==selectedItem?void 0:selectedItem.isTurn)?turns.find(turn=>turn.id===selectedItem.id)??null:selectedItem,itemMap=new Map;return accordionSections.forEach(section2=>{(section2.historyItems||[]).forEach(item2=>itemMap.set(item2.id,item2)),section2.items.forEach(item2=>itemMap.set(item2.id,item2))}),jsxRuntimeExports.jsxs("div",{className:styles$3.root,children:[jsxRuntimeExports.jsx("div",{ref:sidebarRef,className:styles$3.sidebar,children:accordionSections.map(sec=>jsxRuntimeExports.jsx(AccordionSection,{sectionKey:sec.key,title:sec.title,items:sec.items,historyItems:sec.historyItems,selectedId:null==currentSelectedItem?void 0:currentSelectedItem.id,onSelect:item2=>setSelectedItem(item2),onSelectById:itemId=>{const nextItem=itemMap.get(itemId);nextItem&&setSelectedItem(nextItem)},sidebarRef:sidebarRef},sec.key))}),jsxRuntimeExports.jsx("div",{className:styles$3.content,children:null==currentSelectedItem?jsxRuntimeExports.jsx("div",{className:styles$3.contentEmpty,children:jsxRuntimeExports.jsx(Text$1,{type:"secondary",children:t("ui.context.selectPrompt")})}):jsxRuntimeExports.jsx("div",{className:styles$3.contentInner,children:currentSelectedItem.isTurn?jsxRuntimeExports.jsx(TurnContent,{turn:currentSelectedItem}):jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[currentSelectedItem.role&&jsxRuntimeExports.jsxs("div",{className:styles$3.roleHeader,children:[jsxRuntimeExports.jsx("span",{className:`${styles$3.roleBadge} ${styles$3[`role_${currentSelectedItem.role}`]||""}`,children:currentSelectedItem.role}),jsxRuntimeExports.jsx("span",{className:styles$3.roleLabel,children:currentSelectedItem.label})]}),jsxRuntimeExports.jsx(RenderBlocks,{blocks:currentSelectedItem.blocks})]})},currentSelectedItem.id)})]})}const styles$2_container="_container_rg6mx_1",styles$2_emptyState="_emptyState_rg6mx_10",styles$2_urlSection="_urlSection_rg6mx_17",styles$2_urlLeft="_urlLeft_rg6mx_25",styles$2_tokenStatsBox="_tokenStatsBox_rg6mx_30",styles$2_tokenGrid="_tokenGrid_rg6mx_37",styles$2_tokenRows="_tokenRows_rg6mx_47",styles$2_tokenRow="_tokenRow_rg6mx_47",styles$2_tokenRowBorder="_tokenRowBorder_rg6mx_55",styles$2_tokenLabel="_tokenLabel_rg6mx_59",styles$2_tokenTd="_tokenTd_rg6mx_66",styles$2_tokenHitRate="_tokenHitRate_rg6mx_75",styles$2_tokenHitRateLabel="_tokenHitRateLabel_rg6mx_88",styles$2_urlText="_urlText_rg6mx_98",styles$2_metaText="_metaText_rg6mx_105",styles$2_headersContainer="_headersContainer_rg6mx_109",styles$2_headerRow="_headerRow_rg6mx_113",styles$2_headerKey="_headerKey_rg6mx_119",styles$2_headerValue="_headerValue_rg6mx_124",styles$2_streamingBox="_streamingBox_rg6mx_129",styles$2_rawTextPre="_rawTextPre_rg6mx_142",styles$2_tabContent="_tabContent_rg6mx_155",styles$2_bodyLabel="_bodyLabel_rg6mx_167",styles$2_bodyHeader="_bodyHeader_rg6mx_171",styles$2_diffSection="_diffSection_rg6mx_178",styles$2_diffToggle="_diffToggle_rg6mx_182",styles$2_diffIcon="_diffIcon_rg6mx_188",styles$2_reminderSelect="_reminderSelect_rg6mx_214",styles$2_diffHeaderRow="_diffHeaderRow_rg6mx_233",styles$2_diffSpaceRight="_diffSpaceRight_rg6mx_239",styles$2_reminderFilterWrapper="_reminderFilterWrapper_rg6mx_243",styles$2_reminderLabel="_reminderLabel_rg6mx_249",styles$2_cacheTabContent="_cacheTabContent_rg6mx_255",styles$2_userPromptList="_userPromptList_rg6mx_260",styles$2_userPromptItem="_userPromptItem_rg6mx_266",styles$2_userPromptNavBtn="_userPromptNavBtn_rg6mx_277",styles$2_cacheContent="_cacheContent_rg6mx_288",styles$2_cacheTokenBar="_cacheTokenBar_rg6mx_295",styles$2_cacheTokenWrite="_cacheTokenWrite_rg6mx_305",styles$2_cacheTokenRead="_cacheTokenRead_rg6mx_309",styles$2_cacheCopyIcon="_cacheCopyIcon_rg6mx_313",styles$2_cacheScrollArea="_cacheScrollArea_rg6mx_320",styles$2_cacheSectionBlock="_cacheSectionBlock_rg6mx_326",styles$2_cacheSectionHeader="_cacheSectionHeader_rg6mx_330",styles$2_cacheCollapseArrow="_cacheCollapseArrow_rg6mx_342",styles$2_cachePre="_cachePre_rg6mx_348",styles$2_cacheHighlightSvg="_cacheHighlightSvg_rg6mx_362",styles$2_cachePreSystem="_cachePreSystem_rg6mx_371",{Text:Text,Paragraph:Paragraph}=Typography;class DetailPanel extends React__default.Component{constructor(props){super(props),this.state={bodyViewMode:{request:"json",response:"json",diff:"json"},diffExpanded:!1,requestHeadersExpanded:!1,responseHeadersExpanded:!1,reminderFilters:null,cacheHighlightIdx:null,cacheHighlightFading:!1,cacheCollapsed:{tools:!1,system:!1,messages:!1}}}_cacheUnbindScrollFade(){this._cacheOnScrollFade&&this._cacheScrollEl&&(this._cacheScrollEl.removeEventListener("scroll",this._cacheOnScrollFade),this._cacheOnScrollFade=null)}_cacheClearAllTimers(){clearTimeout(this._cacheScrollSettleTimer),clearTimeout(this._cacheFadeClearTimer),clearTimeout(this._cacheAutoFadeTimer),clearTimeout(this._cacheHighlightDelayTimer),this._cacheUnbindScrollFade(),this._cacheScrollEndHandler&&this._cacheScrollEl&&(this._cacheScrollEl.removeEventListener("scrollend",this._cacheScrollEndHandler),this._cacheScrollEndHandler=null)}componentWillUnmount(){this._cacheClearAllTimers()}_cacheBindScrollFade(){this._cacheUnbindScrollFade();const el=this._cacheScrollEl;el&&(this._cacheOnScrollFade=()=>{clearTimeout(this._cacheAutoFadeTimer),this.setState({cacheHighlightFading:!0}),this._cacheFadeClearTimer=setTimeout(()=>{this.setState({cacheHighlightIdx:null,cacheHighlightFading:!1})},3e3),this._cacheUnbindScrollFade()},el.addEventListener("scroll",this._cacheOnScrollFade,{passive:!0}))}scrollToCacheMsg(idx){if(this.state.cacheCollapsed.messages)return void this.setState(prev=>({cacheCollapsed:{...prev.cacheCollapsed,messages:!1}}),()=>this.scrollToCacheMsg(idx));const el=this._cacheScrollEl;if(!el)return;const target=el.querySelector(`[data-msg-idx="${idx}"]`);if(!target)return;clearTimeout(this._cacheScrollSettleTimer),clearTimeout(this._cacheFadeClearTimer),clearTimeout(this._cacheAutoFadeTimer),clearTimeout(this._cacheHighlightDelayTimer),this._cacheUnbindScrollFade(),this._cacheScrollEndHandler&&el.removeEventListener("scrollend",this._cacheScrollEndHandler),this.setState({cacheHighlightIdx:null,cacheHighlightFading:!1});let scrollDone=!1,minPassed=!1;const showHighlight=()=>{scrollDone&&minPassed&&(this.setState({cacheHighlightIdx:idx,cacheHighlightFading:!1}),this._cacheScrollSettleTimer=setTimeout(()=>this._cacheBindScrollFade(),200),this._cacheAutoFadeTimer=setTimeout(()=>{this.state.cacheHighlightIdx!==idx||this.state.cacheHighlightFading||(this.setState({cacheHighlightFading:!0}),this._cacheFadeClearTimer=setTimeout(()=>{this.setState({cacheHighlightIdx:null,cacheHighlightFading:!1})},3e3),this._cacheUnbindScrollFade())},3e3))};this._cacheScrollEndHandler=()=>{el.removeEventListener("scrollend",this._cacheScrollEndHandler),scrollDone=!0,showHighlight()},el.addEventListener("scrollend",this._cacheScrollEndHandler,{once:!0}),this._cacheScrollSettleTimer=setTimeout(()=>{el.removeEventListener("scrollend",this._cacheScrollEndHandler),scrollDone=!0,showHighlight()},800),this._cacheHighlightDelayTimer=setTimeout(()=>{minPassed=!0,showHighlight()},500),target.scrollIntoView({behavior:"smooth",block:"center"})}shouldComponentUpdate(nextProps,nextState){if(nextProps.request!==this.props.request){const isMA=isMainAgent(nextProps.request);this.setState({diffExpanded:isMA&&!!nextProps.expandDiff,requestHeadersExpanded:!1,responseHeadersExpanded:!1,reminderFilters:null}),this._cacheClearAllTimers()}const onCacheTab="kv-cache-text"===nextProps.currentTab;return nextProps.request!==this.props.request||nextProps.currentTab!==this.props.currentTab||nextProps.onTabChange!==this.props.onTabChange||nextProps.selectedIndex!==this.props.selectedIndex||nextProps.expandDiff!==this.props.expandDiff||nextProps.pendingCacheHighlight!==this.props.pendingCacheHighlight||nextState.bodyViewMode!==this.state.bodyViewMode||onCacheTab&&nextState.cacheHighlightIdx!==this.state.cacheHighlightIdx||onCacheTab&&nextState.cacheHighlightFading!==this.state.cacheHighlightFading||nextState.diffExpanded!==this.state.diffExpanded||nextState.requestHeadersExpanded!==this.state.requestHeadersExpanded||nextState.responseHeadersExpanded!==this.state.responseHeadersExpanded||nextState.reminderFilters!==this.state.reminderFilters||onCacheTab&&nextState.cacheCollapsed!==this.state.cacheCollapsed}componentDidUpdate(prevProps){const pch=this.props.pendingCacheHighlight;pch&&pch!==prevProps.pendingCacheHighlight&&setTimeout(()=>{var _a,_b;this.scrollToCacheMsg(pch.msgIdx),null==(_b=(_a=this.props).onCacheHighlightDone)||_b.call(_a)},150)}getCurrentRequest(){const{request:request,allRequests:allRequests,requests:requests}=this.props;return request?request._slimmed?restoreSlimmedEntry(request,allRequests||requests||[]):request:null}toggleBodyViewMode(type){this.setState(prev=>({bodyViewMode:{...prev.bodyViewMode,[type]:"json"===prev.bodyViewMode[type]?"text":"json"}}))}copyBody(type){var _a;const request=this.getCurrentRequest();if(!request)return;let data;if(data="diff"===type?this._lastDiffResult:"request"===type?request.body:null==(_a=request.response)?void 0:_a.body,null==data)return;const clean="object"==typeof data?stripPrivateKeys(data):data,text="string"==typeof clean?clean:JSON.stringify(clean,null,2);navigator.clipboard.writeText(text).then(()=>staticMethods.success(t("ui.copySuccess")))}renderHeaders(headers){return headers&&0!==Object.keys(headers).length?jsxRuntimeExports.jsx("div",{className:styles$2_headersContainer,children:Object.entries(headers).map(([key,value])=>jsxRuntimeExports.jsxs("div",{className:styles$2_headerRow,children:[jsxRuntimeExports.jsx(Text,{code:!0,className:styles$2_headerKey,children:key}),"authorization"===key&&jsxRuntimeExports.jsx(ConceptHelp,{doc:"TranslateContextPollution"}),jsxRuntimeExports.jsx(Text,{type:"secondary",className:styles$2_headerValue,children:String(value)})]},key))}):jsxRuntimeExports.jsx(Text,{type:"secondary",children:t("ui.noHeaders")})}getRequestExpandNode(data,type){if("request"!==type||!data||"object"!=typeof data)return;const{request:request,requests:requests,selectedIndex:selectedIndex}=this.props;if(!request)return;const nextReq=requests&&null!=selectedIndex?requests[selectedIndex+1]:null,{type:reqType}=classifyRequest(request,nextReq);let claudeMdExpandSet=null;if("claudeMd"===this.state.reminderFilters&&Array.isArray(data.messages)){claudeMdExpandSet=new Set,claudeMdExpandSet.add(data.messages);for(const msg of data.messages){if(!msg||"object"!=typeof msg)continue;const content2=msg.content;if("string"==typeof content2)isClaudeMdReminder(content2)&&claudeMdExpandSet.add(msg);else if(Array.isArray(content2)){let hasMatch=!1;for(const block of content2)block&&"text"===block.type&&isClaudeMdReminder(block.text)&&(claudeMdExpandSet.add(block),hasMatch=!0);hasMatch&&(claudeMdExpandSet.add(msg),claudeMdExpandSet.add(content2))}}}let skillsExpandSet=null;if("skills"===this.state.reminderFilters&&Array.isArray(data.messages)){skillsExpandSet=new Set,skillsExpandSet.add(data.messages);for(const msg of data.messages){if(!msg||"object"!=typeof msg)continue;const content2=msg.content;if("string"==typeof content2)isSkillsReminder(content2)&&skillsExpandSet.add(msg);else if(Array.isArray(content2)){let hasMatch=!1;for(const block of content2)block&&"text"===block.type&&isSkillsReminder(block.text)&&(skillsExpandSet.add(block),hasMatch=!0);hasMatch&&(skillsExpandSet.add(msg),skillsExpandSet.add(content2))}}}const filterExpandSet=claudeMdExpandSet||skillsExpandSet;if("Preflight"===reqType){const expandRefs=new Set,collectAll=obj=>{obj&&"object"==typeof obj&&(expandRefs.add(obj),Array.isArray(obj)?obj.forEach(collectAll):Object.values(obj).forEach(collectAll))};return Array.isArray(data.messages)&&collectAll(data.messages),Array.isArray(data.system)&&data.system.length>=3&&collectAll(data.system[2]),(level,value,field)=>level<2||(!!expandRefs.has(value)||(!(!filterExpandSet||!filterExpandSet.has(value))||1===level&&"system"===field))}if("MainAgent"===reqType&&Array.isArray(data.messages)&&1===data.messages.length){const msg=data.messages[0],contentArr=msg&&Array.isArray(msg.content)?msg.content:null,lastContent=contentArr&&contentArr.length>0?contentArr[contentArr.length-1]:null,expandRefs=new Set,collectAll=obj=>{obj&&"object"==typeof obj&&(expandRefs.add(obj),Array.isArray(obj)?obj.forEach(collectAll):Object.values(obj).forEach(collectAll))};return lastContent&&collectAll(lastContent),expandRefs.add(data.messages),msg&&"object"==typeof msg&&expandRefs.add(msg),contentArr&&expandRefs.add(contentArr),(level,value,field)=>level<2||(!!expandRefs.has(value)||!(!filterExpandSet||!filterExpandSet.has(value)))}return filterExpandSet?(level,value,field)=>level<2||!!filterExpandSet.has(value):void 0}renderBody(data,type){const{bodyViewMode:bodyViewMode}=this.state;if(null==data)return jsxRuntimeExports.jsx(Text,{type:"secondary",children:t("ui.noBody")});if("string"==typeof data&&data.includes("Streaming Response"))return jsxRuntimeExports.jsx("div",{className:styles$2_streamingBox,children:jsxRuntimeExports.jsx(Text,{type:"secondary",children:t("ui.streamingResponse")})});const clean="object"==typeof data?stripPrivateKeys(data):data,isJsonMode="json"===bodyViewMode[type],expandNode=this.getRequestExpandNode(clean,type);return jsxRuntimeExports.jsx("div",{children:isJsonMode?jsxRuntimeExports.jsx(JsonViewer,{data:clean,defaultExpand:"response"===type?"all":"root",expandNode:expandNode}):jsxRuntimeExports.jsx("pre",{className:styles$2_rawTextPre,children:"string"==typeof clean?clean:JSON.stringify(clean,null,2)})})}getPrevMainAgentRequest(){const{requests:requests,selectedIndex:selectedIndex}=this.props;if(!requests||null==selectedIndex)return null;for(let i=selectedIndex-1;i>=0;i--)if(isMainAgent(requests[i])){const r=requests[i];return r._slimmed?restoreSlimmedEntry(r,this.props.allRequests||requests):r}return null}computeDiff(prev,curr){if(null==prev||null==curr)return null;if("object"!=typeof prev||"object"!=typeof curr)return null;const result={},allKeys=new Set([...Object.keys(prev),...Object.keys(curr)]);for(const key of allKeys)if(!key.startsWith("_"))if(key in prev){if(!(key in curr))continue;JSON.stringify(prev[key])!==JSON.stringify(curr[key])&&("messages"===key&&Array.isArray(prev[key])&&Array.isArray(curr[key])&&curr[key].length>prev[key].length?result[key]=curr[key].slice(prev[key].length):result[key]=curr[key])}else result[key]=curr[key];return Object.keys(result).length?result:null}render(){var _a,_b,_c;let request=this.getCurrentRequest();const{currentTab:currentTab,onTabChange:onTabChange}=this.props;if(!request)return jsxRuntimeExports.jsx("div",{className:styles$2_emptyState,children:jsxRuntimeExports.jsx(Empty,{description:"选择一个请求查看详情"})});const time2=new Date(request.timestamp).toLocaleString("zh-CN"),statusOk2=request.response&&request.response.status<400;let diffBlock=null;if(isMainAgent(request)){const prevRequest=this.getPrevMainAgentRequest();if(prevRequest){if(JSON.stringify(request.body).length<JSON.stringify(prevRequest.body).length)diffBlock=jsxRuntimeExports.jsxs("div",{className:styles$2_diffSection,children:[jsxRuntimeExports.jsxs(Text,{strong:!0,className:styles$2_diffToggle,onClick:()=>this.setState(prev=>({diffExpanded:!prev.diffExpanded})),children:["Body Diff JSON ",jsxRuntimeExports.jsx(ConceptHelp,{doc:"BodyDiffJSON"})," ",this.state.diffExpanded?jsxRuntimeExports.jsx(RefIcon$c,{className:styles$2_diffIcon}):jsxRuntimeExports.jsx(RefIcon$d,{className:styles$2_diffIcon})]}),this.state.diffExpanded&&jsxRuntimeExports.jsx(Text,{type:"secondary",children:t("ui.diffSessionChanged")})]});else{const diffResult=stripPrivateKeys(this.computeDiff(prevRequest.body,request.body));diffResult&&(this._lastDiffResult=diffResult,diffBlock=jsxRuntimeExports.jsxs("div",{className:styles$2_diffSection,children:[jsxRuntimeExports.jsxs("div",{className:styles$2_diffHeaderRow,children:[jsxRuntimeExports.jsxs(Text,{strong:!0,className:styles$2_diffToggle,onClick:()=>this.setState(prev=>({diffExpanded:!prev.diffExpanded})),children:["Body Diff JSON ",jsxRuntimeExports.jsx(ConceptHelp,{doc:"BodyDiffJSON"})," ",this.state.diffExpanded?jsxRuntimeExports.jsx(RefIcon$c,{className:styles$2_diffIcon}):jsxRuntimeExports.jsx(RefIcon$d,{className:styles$2_diffIcon})]}),this.state.diffExpanded&&jsxRuntimeExports.jsxs(Space,{size:"small",className:styles$2_diffSpaceRight,children:[jsxRuntimeExports.jsx(Button,{size:"small",icon:"json"===this.state.bodyViewMode.diff?jsxRuntimeExports.jsx(RefIcon$a,{}):jsxRuntimeExports.jsx(RefIcon$3,{}),onClick:()=>this.toggleBodyViewMode("diff"),children:"json"===this.state.bodyViewMode.diff?"Text":"JSON"}),jsxRuntimeExports.jsx(Button,{size:"small",icon:jsxRuntimeExports.jsx(RefIcon$9,{}),onClick:()=>this.copyBody("diff"),children:t("ui.copy")})]})]}),this.state.diffExpanded&&jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:"json"===this.state.bodyViewMode.diff?jsxRuntimeExports.jsx(JsonViewer,{data:diffResult,defaultExpand:"all"}):jsxRuntimeExports.jsx("pre",{className:styles$2_rawTextPre,children:JSON.stringify(diffResult,null,2)})})]}))}}}const hasClaudeMd=hasClaudeMdReminder(request.body),hasSkills=hasSkillsReminder(request.body),tabItems=[{key:"request",label:"Request",children:jsxRuntimeExports.jsxs("div",{className:styles$2_tabContent,children:[jsxRuntimeExports.jsxs("div",{className:styles$2_diffSection,children:[jsxRuntimeExports.jsxs(Text,{strong:!0,className:styles$2_diffToggle,onClick:()=>this.setState(prev=>({requestHeadersExpanded:!prev.requestHeadersExpanded})),children:["Headers ",this.state.requestHeadersExpanded?jsxRuntimeExports.jsx(RefIcon$c,{className:styles$2_diffIcon}):jsxRuntimeExports.jsx(RefIcon$d,{className:styles$2_diffIcon})]}),this.state.requestHeadersExpanded&&this.renderHeaders(request.headers)]}),diffBlock,jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsxs("div",{className:styles$2_bodyHeader,children:[jsxRuntimeExports.jsxs(Text,{strong:!0,className:styles$2_bodyLabel,children:["Body",jsxRuntimeExports.jsx(ConceptHelp,{doc:"BodyFields"})]}),jsxRuntimeExports.jsxs(Space,{size:"small",children:[(hasClaudeMd||hasSkills)&&jsxRuntimeExports.jsxs("span",{className:styles$2_reminderFilterWrapper,children:[jsxRuntimeExports.jsx("span",{className:styles$2_reminderLabel,children:"system-reminder:"}),jsxRuntimeExports.jsx(Select,{size:"small",className:styles$2_reminderSelect,placeholder:"filter",value:this.state.reminderFilters||void 0,onChange:val=>this.setState({reminderFilters:val||null}),options:[{label:"CLAUDE.md",value:"claudeMd",disabled:!hasClaudeMd},{label:"Skills",value:"skills",disabled:!hasSkills}],popupMatchSelectWidth:!1,allowClear:!0})]}),jsxRuntimeExports.jsx(Button,{size:"small",icon:"json"===this.state.bodyViewMode.request?jsxRuntimeExports.jsx(RefIcon$a,{}):jsxRuntimeExports.jsx(RefIcon$3,{}),onClick:()=>this.toggleBodyViewMode("request"),children:"json"===this.state.bodyViewMode.request?"Text":"JSON"}),jsxRuntimeExports.jsx(Button,{size:"small",icon:jsxRuntimeExports.jsx(RefIcon$9,{}),onClick:()=>this.copyBody("request"),children:t("ui.copy")})]})]}),this.renderBody(request.body,"request")]})]})},{key:"response",label:"Response",children:jsxRuntimeExports.jsx("div",{className:styles$2_tabContent,children:request.response?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("div",{className:styles$2_diffSection,children:[jsxRuntimeExports.jsxs(Text,{strong:!0,className:styles$2_diffToggle,onClick:()=>this.setState(prev=>({responseHeadersExpanded:!prev.responseHeadersExpanded})),children:["Headers ",this.state.responseHeadersExpanded?jsxRuntimeExports.jsx(RefIcon$c,{className:styles$2_diffIcon}):jsxRuntimeExports.jsx(RefIcon$d,{className:styles$2_diffIcon})]}),this.state.responseHeadersExpanded&&this.renderHeaders(request.response.headers)]}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsxs("div",{className:styles$2_bodyHeader,children:[jsxRuntimeExports.jsxs(Text,{strong:!0,className:styles$2_bodyLabel,children:["Body",jsxRuntimeExports.jsx(ConceptHelp,{doc:"ResponseFields"})]}),jsxRuntimeExports.jsxs(Space,{size:"small",children:[jsxRuntimeExports.jsx(Button,{size:"small",icon:"json"===this.state.bodyViewMode.response?jsxRuntimeExports.jsx(RefIcon$a,{}):jsxRuntimeExports.jsx(RefIcon$3,{}),onClick:()=>this.toggleBodyViewMode("response"),children:"json"===this.state.bodyViewMode.response?"Text":"JSON"}),jsxRuntimeExports.jsx(Button,{size:"small",icon:jsxRuntimeExports.jsx(RefIcon$9,{}),onClick:()=>this.copyBody("response"),children:t("ui.copy")})]})]}),this.renderBody(request.response.body,"response")]})]}):jsxRuntimeExports.jsx(Empty,{description:t("ui.responseNotCaptured")})})},{key:"kv-cache-text",label:jsxRuntimeExports.jsxs("span",{children:["KV-Cache-Text ",jsxRuntimeExports.jsx(ConceptHelp,{doc:"KVCacheContent"})]}),children:jsxRuntimeExports.jsx("div",{className:`${styles$2_tabContent} ${styles$2_cacheTabContent}`,children:(()=>{const cached=extractCachedContent([request]),reqKey=request.timestamp+"|"+request.url;if(cached&&(cached.cacheCreateTokens>0||cached.cacheReadTokens>0)&&(this._lastCachedTokensKey=reqKey,this._lastCachedTokens={cacheCreateTokens:cached.cacheCreateTokens,cacheReadTokens:cached.cacheReadTokens}),!cached||0===cached.system.length&&0===cached.messages.length&&0===cached.tools.length)return jsxRuntimeExports.jsx(Empty,{description:t("ui.noCachedContent"),image:Empty.PRESENTED_IMAGE_SIMPLE});const userPrompts=cached.messages.map((text,i)=>({text:text,msgIdx:i})).filter(({text:text})=>text.startsWith("[user]")).map(({text:text,msgIdx:msgIdx})=>{const raw=text.replace(/^\[user\]\s*/,"").trim();if(!raw||isSystemText(raw))return{cleaned:"",msgIdx:msgIdx};return{cleaned:AppHeader.parseSegments(raw).filter(s=>"text"===s.type).map(s=>s.content.trim()).filter(s=>s&&!isSystemText(s)).join(" ").trim(),msgIdx:msgIdx}}).filter(({cleaned:cleaned})=>!!cleaned&&!/Implement the following plan:/i.test(cleaned)),userPromptNavList=userPrompts.length>0?jsxRuntimeExports.jsx("div",{className:styles$2_userPromptList,children:userPrompts.map(({cleaned:cleaned,msgIdx:msgIdx})=>jsxRuntimeExports.jsx("div",{className:styles$2_userPromptItem,onMouseEnter:e=>{e.currentTarget.style.background="var(--color-primary-bg-lighter)",e.currentTarget.style.color="var(--text-white)"},onMouseLeave:e=>{e.currentTarget.style.background="",e.currentTarget.style.color="var(--text-secondary)"},onClick:()=>this.scrollToCacheMsg(msgIdx),children:cleaned},msgIdx))}):null;return jsxRuntimeExports.jsxs("div",{className:styles$2_cacheContent,children:[(()=>{const displayTokens=cached.cacheCreateTokens>0||cached.cacheReadTokens>0?cached:this._lastCachedTokensKey===reqKey?this._lastCachedTokens:null;return displayTokens||userPromptNavList?jsxRuntimeExports.jsxs("div",{className:styles$2_cacheTokenBar,children:[displayTokens&&jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[t("ui.tokens"),": ",jsxRuntimeExports.jsxs("span",{className:styles$2_cacheTokenWrite,children:["write ",formatTokenCount(displayTokens.cacheCreateTokens)]})," / ",jsxRuntimeExports.jsxs("span",{className:styles$2_cacheTokenRead,children:["read ",formatTokenCount(displayTokens.cacheReadTokens)]}),jsxRuntimeExports.jsx(Tooltip,{title:t("ui.copyAllCacheText"),children:jsxRuntimeExports.jsx(RefIcon$9,{className:styles$2_cacheCopyIcon,onClick:()=>{navigator.clipboard.writeText((()=>{const parts=[];if(cached.tools.length>0){const indented=cached.tools.map(xml=>xml.split("\n").map(l=>l?" "+l:l).join("\n")).join("\n");parts.push(`<tools>\n${indented}\n</tools>`)}return cached.system.length>0&&parts.push(`<system-reminder>\n${cached.system.join("\n\n")}\n</system-reminder>`),cached.messages.length>0&&cached.messages.forEach(t2=>parts.push(t2)),parts.join("\n\n")})()).then(()=>{staticMethods.success(t("ui.copied"))}).catch(()=>{})}})})]}),userPromptNavList&&jsxRuntimeExports.jsx(Popover,{content:userPromptNavList,trigger:"hover",placement:"left",children:jsxRuntimeExports.jsx("span",{className:styles$2_userPromptNavBtn,children:t("ui.userPromptNav")})})]}):null})(),jsxRuntimeExports.jsxs("div",{className:styles$2_cacheScrollArea,ref:el=>{this._cacheScrollEl=el},children:[cached.tools.length>0&&jsxRuntimeExports.jsxs("div",{className:styles$2_cacheSectionBlock,children:[jsxRuntimeExports.jsxs("div",{className:styles$2_cacheSectionHeader,onClick:()=>this.setState(prev=>({cacheCollapsed:{...prev.cacheCollapsed,tools:!prev.cacheCollapsed.tools}})),children:[jsxRuntimeExports.jsx("span",{className:styles$2_cacheCollapseArrow,style:{transform:this.state.cacheCollapsed.tools?"rotate(-90deg)":"rotate(0deg)"},children:"▼"}),t("ui.tools")," (",cached.tools.length,")"]}),!this.state.cacheCollapsed.tools&&cached.tools.map((text,i)=>jsxRuntimeExports.jsx("pre",{className:styles$2_cachePre,children:text},i))]}),cached.system.length>0&&jsxRuntimeExports.jsxs("div",{className:styles$2_cacheSectionBlock,children:[jsxRuntimeExports.jsxs("div",{className:styles$2_cacheSectionHeader,onClick:()=>this.setState(prev=>({cacheCollapsed:{...prev.cacheCollapsed,system:!prev.cacheCollapsed.system}})),children:[jsxRuntimeExports.jsx("span",{className:styles$2_cacheCollapseArrow,style:{transform:this.state.cacheCollapsed.system?"rotate(-90deg)":"rotate(0deg)"},children:"▼"}),t("ui.systemPrompt")," (",cached.system.length,")"]}),!this.state.cacheCollapsed.system&&cached.system.map((text,i)=>jsxRuntimeExports.jsx("pre",{className:styles$2_cachePreSystem,children:text},i))]}),cached.messages.length>0&&jsxRuntimeExports.jsxs("div",{className:styles$2_cacheSectionBlock,children:[jsxRuntimeExports.jsxs("div",{className:styles$2_cacheSectionHeader,onClick:()=>this.setState(prev=>({cacheCollapsed:{...prev.cacheCollapsed,messages:!prev.cacheCollapsed.messages}})),children:[jsxRuntimeExports.jsx("span",{className:styles$2_cacheCollapseArrow,style:{transform:this.state.cacheCollapsed.messages?"rotate(-90deg)":"rotate(0deg)"},children:"▼"}),t("ui.messages")," (",cached.messages.length,")"]}),!this.state.cacheCollapsed.messages&&cached.messages.map((text,i)=>{const isHl=i===this.state.cacheHighlightIdx,hlStyle=isHl?this.state.cacheHighlightFading?{boxShadow:"0 0 10px rgba(22,104,220,0)",transition:"box-shadow 3s ease-out",position:"relative"}:{boxShadow:"0 0 10px rgba(22,104,220,0.6)",transition:"box-shadow 0.2s ease-in",position:"relative"}:{};return jsxRuntimeExports.jsxs("pre",{"data-msg-idx":i,className:styles$2_cachePre,style:hlStyle,children:[isHl&&jsxRuntimeExports.jsx("svg",{className:styles$2_cacheHighlightSvg,style:{opacity:this.state.cacheHighlightFading?0:1,transition:this.state.cacheHighlightFading?"opacity 3s ease-out":void 0},preserveAspectRatio:"none",children:jsxRuntimeExports.jsx("rect",{x:"0.5",y:"0.5",width:"calc(100% - 1px)",height:"calc(100% - 1px)",rx:"4",ry:"4",fill:"none",stroke:"#1668dc",strokeWidth:"1",strokeDasharray:"6 4",children:jsxRuntimeExports.jsx("animate",{attributeName:"stroke-dashoffset",from:"0",to:"-100",dur:"4s",repeatCount:"indefinite"})})}),text]},i)})]})]})]})})()})},{key:"context",label:"Context",children:jsxRuntimeExports.jsx("div",{className:`${styles$2_tabContent} ${styles$2_cacheTabContent}`,children:jsxRuntimeExports.jsx(ContextTab,{body:request.body,response:null==(_a=request.response)?void 0:_a.body})})}],usage=null==(_c=null==(_b=request.response)?void 0:_b.body)?void 0:_c.usage,tokenStats=usage?(()=>{const input=usage.input_tokens||0,output=usage.output_tokens||0,cacheCreate=usage.cache_creation_input_tokens||0,cacheRead=usage.cache_read_input_tokens||0,totalInput=input+cacheCreate+cacheRead;return{input:input,output:output,cacheCreate:cacheCreate,cacheRead:cacheRead,hitRate:totalInput>0?(cacheRead/totalInput*100).toFixed(1):"0.0"}})():null;return jsxRuntimeExports.jsxs("div",{className:styles$2_container,children:[jsxRuntimeExports.jsxs("div",{className:styles$2_urlSection,children:[jsxRuntimeExports.jsxs("div",{className:styles$2_urlLeft,children:[jsxRuntimeExports.jsx(Paragraph,{className:styles$2_urlText,ellipsis:{rows:2,expandable:!0},children:request.proxyUrl||request.url}),jsxRuntimeExports.jsxs(Space,{size:"small",wrap:!0,children:[jsxRuntimeExports.jsx(Tag,{color:"POST"===request.method?"blue":"green",children:request.method}),jsxRuntimeExports.jsxs(Text,{type:"secondary",className:styles$2_metaText,children:["🕐 ",time2]}),request.duration&&jsxRuntimeExports.jsxs(Text,{type:"secondary",className:styles$2_metaText,children:["⏱️ ",request.duration,"ms"]}),request.response&&jsxRuntimeExports.jsxs(Tag,{color:statusOk2?"success":"error",children:["HTTP ",request.response.status]})]})]}),tokenStats&&jsxRuntimeExports.jsx("div",{className:styles$2_tokenStatsBox,children:jsxRuntimeExports.jsxs("div",{className:styles$2_tokenGrid,children:[jsxRuntimeExports.jsxs("div",{className:styles$2_tokenRows,children:[jsxRuntimeExports.jsxs("div",{className:styles$2_tokenRow,children:[jsxRuntimeExports.jsx("span",{className:styles$2_tokenLabel,children:"Token"}),jsxRuntimeExports.jsxs("span",{className:styles$2_tokenTd,children:["input: ",formatTokenCount(tokenStats.input)]}),jsxRuntimeExports.jsxs("span",{className:styles$2_tokenTd,children:["output: ",formatTokenCount(tokenStats.output)]})]}),jsxRuntimeExports.jsxs("div",{className:`${styles$2_tokenRow} ${styles$2_tokenRowBorder}`,children:[jsxRuntimeExports.jsx("span",{className:styles$2_tokenLabel,children:"Cache"}),jsxRuntimeExports.jsxs("span",{className:styles$2_tokenTd,children:["create: ",formatTokenCount(tokenStats.cacheCreate)]}),jsxRuntimeExports.jsxs("span",{className:styles$2_tokenTd,children:["read: ",formatTokenCount(tokenStats.cacheRead)]})]})]}),jsxRuntimeExports.jsxs("div",{className:styles$2_tokenHitRate,children:[jsxRuntimeExports.jsxs("div",{children:[tokenStats.hitRate,"%"]}),jsxRuntimeExports.jsx("div",{className:styles$2_tokenHitRateLabel,children:t("ui.hitRate")})]})]})})]}),jsxRuntimeExports.jsx(Tabs,{activeKey:currentTab,onChange:onTabChange,items:tabItems,size:"small"})]})}}const styles$1_resizer="_resizer_pzn4b_1";class PanelResizer extends React__default.Component{constructor(props){super(props),this.handleMouseDown=this.handleMouseDown.bind(this),this.handleMouseMove=this.handleMouseMove.bind(this),this.handleMouseUp=this.handleMouseUp.bind(this)}handleMouseDown(e){e.preventDefault(),document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("mouseup",this.handleMouseUp)}handleMouseMove(e){this.props.onResize&&this.props.onResize(e.clientX)}handleMouseUp(){document.body.style.cursor="",document.body.style.userSelect="",document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp)}componentWillUnmount(){document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp)}render(){return jsxRuntimeExports.jsx("div",{onMouseDown:this.handleMouseDown,className:styles$1_resizer})}}const styles_flag="_flag_1q4ri_3",styles_popover="_popover_1q4ri_27",styles_meta="_meta_1q4ri_33";class CountryFlag extends React__default.Component{constructor(props){super(props),this.state={flag:null,info:null,popoverOpen:!1},this._aborted=!1}componentDidMount(){fetch("https://ipinfo.io/json",{signal:AbortSignal.timeout(5e3)}).then(r=>r.json()).then(data=>{var code;this._aborted||data&&data.country&&this.setState({flag:(code=data.country,code&&2===code.length?code.toUpperCase().split("").map(c=>String.fromCodePoint(127462+c.charCodeAt(0)-65)).join(""):"🇨🇳"),info:data})}).catch(()=>{})}componentWillUnmount(){this._aborted=!0}render(){const{flag:flag2,info:info}=this.state;if(!flag2||"CN"===(null==info?void 0:info.country))return null;const content2=jsxRuntimeExports.jsxs("div",{className:styles_popover,onClick:e=>e.stopPropagation(),children:[jsxRuntimeExports.jsxs("div",{children:[flag2," ",info.country]}),info.region&&jsxRuntimeExports.jsx("div",{children:info.region}),info.city&&jsxRuntimeExports.jsx("div",{children:info.city}),info.org&&jsxRuntimeExports.jsx("div",{className:styles_meta,children:info.org}),info.ip&&jsxRuntimeExports.jsx("div",{className:styles_meta,children:info.ip})]});return jsxRuntimeExports.jsx(Popover,{content:content2,trigger:["click"],open:this.state.popoverOpen,onOpenChange:o=>this.setState({popoverOpen:o}),placement:"topLeft",overlayInnerStyle:{background:"var(--bg-elevated)",border:"1px solid var(--border-hover)",borderRadius:8,padding:"8px 12px"},children:jsxRuntimeExports.jsx("button",{type:"button",className:styles_flag,"aria-label":`${info.country}${info.region?" · "+info.region:""}`,children:flag2})})}}class App extends AppBase{constructor(props){super(props),__publicField(this,"setContextBarSlot",el=>{el&&!el.isConnected||el!==this.state.contextBarSlot&&this.setState({contextBarSlot:el})}),__publicField(this,"handleViewRequest",index=>{this.setState({viewMode:"raw",selectedIndex:index,scrollCenter:!0})}),__publicField(this,"handleViewInChat",()=>{this.setState(prev=>{const selectedReq=(prev.showAll?prev.requests:filterRelevantRequests(prev.requests))[prev.selectedIndex];if(!selectedReq)return null;let targetTs=null;if(isMainAgent(selectedReq)&&selectedReq.timestamp)targetTs=selectedReq.timestamp;else{const cls=classifyRequest(selectedReq);if("SubAgent"!==cls.type&&"Teammate"!==cls.type||!selectedReq.timestamp){const idx=prev.requests.indexOf(selectedReq);idx>=0&&(targetTs=findPrevMainAgentTimestamp(prev.requests,idx))}else targetTs=selectedReq.timestamp;targetTs||staticMethods.info(t("ui.cannotMap"))}return{viewMode:"chat",chatScrollToTs:targetTs}})}),__publicField(this,"handleToggleViewMode",()=>{this.setState(prev=>{const newMode="raw"===prev.viewMode?"chat":"raw";if("raw"===newMode){if(null===prev.selectedIndex){const filtered2=prev.showAll?prev.requests:filterRelevantRequests(prev.requests);return{viewMode:newMode,selectedIndex:filtered2.length>0?filtered2.length-1:null,scrollCenter:!0}}return{viewMode:newMode,scrollCenter:!0}}const filtered=prev.showAll?prev.requests:filterRelevantRequests(prev.requests),selectedReq=null!=prev.selectedIndex?filtered[prev.selectedIndex]:null;if(selectedReq){let targetTs=null;if(isMainAgent(selectedReq)&&selectedReq.timestamp)targetTs=selectedReq.timestamp;else{const cls=classifyRequest(selectedReq);if("SubAgent"!==cls.type&&"Teammate"!==cls.type||!selectedReq.timestamp){const idx=prev.requests.indexOf(selectedReq);idx>=0&&(targetTs=findPrevMainAgentTimestamp(prev.requests,idx)),targetTs||staticMethods.info(t("ui.cannotMap"))}else targetTs=selectedReq.timestamp}return{viewMode:newMode,chatScrollToTs:targetTs}}return{viewMode:newMode,chatScrollToTs:null}},()=>{"chat"===this.state.viewMode&&this.state.terminalVisible&&this.state.cliMode&&!isMobile&&requestAnimationFrame(()=>{const ta=document.querySelector(".xterm-helper-textarea");ta&&ta.focus()})})}),__publicField(this,"handleTabChange",key=>{this.setState({currentTab:key})}),__publicField(this,"handleCacheHighlightDone",()=>{this.setState({pendingCacheHighlight:null})}),__publicField(this,"handleNavigateCacheMsg",msgIdx=>{const filteredRequests=this.state.showAll?this.state.requests:filterRelevantRequests(this.state.requests);let targetIdx=-1;for(let i=filteredRequests.length-1;i>=0;i--)if(isMainAgent(filteredRequests[i])){targetIdx=i;break}targetIdx<0||this.setState({selectedIndex:targetIdx,scrollCenter:!0,currentTab:"kv-cache-text",pendingCacheHighlight:{msgIdx:msgIdx,key:Date.now()}})}),__publicField(this,"handleResize",clientX=>{const container2=this.mainContainerRef.current;if(!container2)return;const newWidth=clientX-container2.getBoundingClientRect().left;newWidth>=250&&newWidth<=800&&this.setState({leftPanelWidth:newWidth})}),__publicField(this,"handleLoadLocalJsonlFile",()=>{const input=document.createElement("input");input.type="file",input.accept=".jsonl",input.multiple=!0,input.onchange=e=>{const files=Array.from(e.target.files);if(0===files.length)return;if(files.reduce((s,f)=>s+f.size,0)>524288e3)return void staticMethods.error(t("ui.fileTooLarge"));this.setState({fileLoading:!0,fileLoadingCount:0});let readCount=0;const allEntries=[],fileNames=[];files.forEach(file=>{const reader=new FileReader;reader.onload=ev=>{try{const entries=ev.target.result.split("\n---\n").filter(line=>line.trim()).map(entry=>{try{return JSON.parse(entry)}catch{return null}}).filter(Boolean);allEntries.push(...entries),fileNames.push(file.name)}catch{}readCount++,readCount===files.length&&this._finishLocalLoad(allEntries,fileNames)},reader.readAsText(file)})},input.click()}),__publicField(this,"_processJsonlFiles",files=>{if(!files||0===files.length)return;if(files.reduce((s,f)=>s+f.size,0)>524288e3)return void staticMethods.error(t("ui.fileTooLarge"));this.setState({fileLoading:!0,fileLoadingCount:0});let readCount=0;const allEntries=[],fileNames=[];files.forEach(file=>{const reader=new FileReader;reader.onload=ev=>{try{const entries=ev.target.result.split("\n---\n").filter(line=>line.trim()).map(entry=>{try{return JSON.parse(entry)}catch{return null}}).filter(Boolean);allEntries.push(...entries),fileNames.push(file.name)}catch{}readCount++,readCount===files.length&&this._finishLocalLoad(allEntries,fileNames)},reader.readAsText(file)})}),__publicField(this,"_isInternalDrag",e=>e.dataTransfer.types.includes("text/x-preset-reorder")),__publicField(this,"_onDragOver",e=>{if(e.preventDefault(),this._isInternalDrag(e))return;e.target.closest&&e.target.closest("[data-file-explorer]")?this.state.isDragging&&this.setState({isDragging:!1}):this.state.isDragging||this.setState({isDragging:!0})}),__publicField(this,"_onDragLeave",e=>{const layout=this._layoutRef.current;layout&&!layout.contains(e.relatedTarget)&&this.setState({isDragging:!1})}),__publicField(this,"_onDrop",e=>{if(e.preventDefault(),this._isInternalDrag(e))return;this.setState({isDragging:!1});const files=Array.from(e.dataTransfer.files);files.length&&Promise.all(files.map(file=>uploadFileAndGetPath(file).then(path=>({name:file.name,path:path})).catch(err=>(staticMethods.error(`${file.name}: ${err.message}`),null)))).then(results=>{const paths=results.filter(Boolean).map(r=>`"${r.path}"`);paths.length>0&&this.setState(prev=>({pendingUploadPaths:[...prev.pendingUploadPaths||[],...paths]}))})}),__publicField(this,"handleUploadPathsConsumed",()=>{this.setState({pendingUploadPaths:[]})}),Object.assign(this.state,{leftPanelWidth:380,terminalVisible:!0,currentTab:"context",pendingCacheHighlight:null,contextBarSlot:null}),this.appHeaderRef=React__default.createRef(),this._getTokenStatsContent=()=>{var _a,_b;return(null==(_b=null==(_a=this.appHeaderRef.current)?void 0:_a.renderTokenStats)?void 0:_b.call(_a))??null}}componentDidMount(){super.componentDidMount(),this._mqlNarrow=window.matchMedia("(max-width: 600px)"),this._modeSwitchDialog=null,this._onNarrowChange=e=>{e.matches?this._modeSwitchDialog=Modal.confirm({title:t("ui.modeSwitchTitle"),content:t("ui.modeSwitchToSidebar"),okText:t("ui.ok"),onOk:()=>{this._modeSwitchDialog=null,setViewMode("pad")},onCancel:()=>{this._modeSwitchDialog=null}}):this._modeSwitchDialog&&(this._modeSwitchDialog.destroy(),this._modeSwitchDialog=null)},this._mqlNarrow.addEventListener("change",this._onNarrowChange)}componentWillUnmount(){this._mqlNarrow&&this._mqlNarrow.removeEventListener("change",this._onNarrowChange),this._modeSwitchDialog&&(this._modeSwitchDialog.destroy(),this._modeSwitchDialog=null),super.componentWillUnmount()}render(){const{filteredRequests:filteredRequests,selectedRequest:selectedRequest,fileLoading:fileLoading,fileLoadingCount:fileLoadingCount,mainAgentSessions:mainAgentSessions,viewMode:viewMode}=this.renderPrepare(),{selectedIndex:selectedIndex,leftPanelWidth:leftPanelWidth,currentTab:currentTab}=this.state;if(this.state.workspaceMode)return this.renderWorkspaceMode();const wsOpen=!this._isLocalLog&&!this.state.sdkMode;return jsxRuntimeExports.jsx(ConfigProvider,{theme:this.themeConfig,children:jsxRuntimeExports.jsx(TerminalWsProvider,{open:wsOpen,children:jsxRuntimeExports.jsxs(ApprovalModal,{enabled:this.state.approvalPrefs.modalEnabled,soundEnabled:this.state.approvalPrefs.soundEnabled,approvalGlobal:this.state.approvalGlobal,dismissedIds:this.state.approvalDismissedIds,onDismiss:this.handleApprovalDismiss,onJumpTab:this.handleApprovalJumpTab,otherTabs:this.state.approvalOtherTabs,children:[fileLoading&&jsxRuntimeExports.jsx("div",{className:styles$8.loadingOverlay,children:jsxRuntimeExports.jsxs("div",{className:styles$8.loadingText,children:["Loading...(",fileLoadingCount,")"]})}),this.state.isDragging&&jsxRuntimeExports.jsx("div",{className:styles$8.dragOverlay,children:jsxRuntimeExports.jsxs("div",{className:styles$8.dragOverlayContent,children:[jsxRuntimeExports.jsx(RefIcon$e,{className:styles$8.dragIcon}),jsxRuntimeExports.jsx("p",{children:t("ui.dragDropHint")})]})}),jsxRuntimeExports.jsxs(Layout,{className:styles$8.layout,ref:this._layoutRef,onDragOver:this._onDragOver,onDragLeave:this._onDragLeave,onDrop:this._onDrop,children:[jsxRuntimeExports.jsx(Layout.Header,{className:styles$8.header,children:jsxRuntimeExports.jsx(AppHeader,{ref:this.appHeaderRef,requestCount:filteredRequests.length,requests:filteredRequests,viewMode:viewMode,cacheExpireAt:this.state.cacheExpireAt,cacheType:this.state.cacheType,onToggleViewMode:this.handleToggleViewMode,onLangChange:this.handleLangChange,onImportLocalLogs:this.handleImportLocalLogs,isLocalLog:!!this._isLocalLog,localLogFile:this._localLogFile,projectName:this.state.projectName,collapseToolResults:this.state.collapseToolResults,onCollapseToolResultsChange:this.handleCollapseToolResultsChange,expandThinking:this.state.expandThinking,onExpandThinkingChange:this.handleExpandThinkingChange,showFullToolContent:this.state.showFullToolContent,onShowFullToolContentChange:this.handleShowFullToolContentChange,expandDiff:this.state.expandDiff,onExpandDiffChange:this.handleExpandDiffChange,filterIrrelevant:!this.state.showAll,onFilterIrrelevantChange:this.handleFilterIrrelevantChange,logDir:this.state.logDir,onLogDirChange:this.handleLogDirChange,cliMode:this.state.cliMode,sdkMode:this.state.sdkMode,terminalVisible:!this.state.sdkMode&&this.state.terminalVisible,onToggleTerminal:()=>this.setState(prev=>({terminalVisible:!prev.terminalVisible})),onReturnToWorkspaces:this.state.cliMode?this.handleReturnToWorkspaces:null,contextWindow:this.state.contextWindow,contextBarOptimistic:this.state.contextBarOptimistic,onNavigateCacheMsg:this.handleNavigateCacheMsg,serverCachedContent:this.state.serverCachedContent||this._lastKvCacheContent,resumeAutoChoice:this.state.resumeAutoChoice,onResumeAutoChoiceToggle:this.handleResumeAutoChoiceToggle,onResumeAutoChoiceChange:this.handleResumeAutoChoiceChange,themeColor:this.state.themeColor,onThemeColorChange:this.handleThemeColorChange,autoApproveSeconds:this.state.autoApproveSeconds,onAutoApproveChange:this.handleAutoApproveChange,approvalPrefs:this.state.approvalPrefs,onApprovalPrefsChange:this.handleApprovalPrefsChange,approvalGlobal:this.state.approvalGlobal,approvalDismissedIds:this.state.approvalDismissedIds,approvalOwnPending:this.state.approvalOwnPending,onApprovalReopen:this.handleApprovalReopen,proxyProfiles:this.state.proxyProfiles,activeProxyId:this.state.activeProxyId,defaultConfig:this.state.defaultConfig,onProxyProfileChange:this.handleProxyProfileChange,contextBarSlot:this.state.contextBarSlot})}),this.state.claudeMissing&&jsxRuntimeExports.jsx(Alert,{type:"warning",showIcon:!0,banner:!0,message:t("ui.claudeMissing.title"),description:jsxRuntimeExports.jsxs("span",{children:[t("ui.claudeMissing.desc"),jsxRuntimeExports.jsx("br",{}),jsxRuntimeExports.jsx("code",{style:{background:"var(--bg-code)",padding:"2px 6px",borderRadius:3},children:"npm install -g @anthropic-ai/claude-code"})," ",jsxRuntimeExports.jsx("span",{style:{color:"var(--text-muted)",margin:"0 4px"},children:t("ui.claudeMissing.or")})," ",jsxRuntimeExports.jsx("a",{href:"https://claude.ai/download",target:"_blank",rel:"noopener noreferrer",style:{color:"var(--color-primary-light)"},children:t("ui.claudeMissing.native")})]})}),jsxRuntimeExports.jsxs(Layout.Content,{className:styles$8.content,children:["raw"===viewMode&&(0===filteredRequests.length?jsxRuntimeExports.jsx("div",{className:styles$8.guideContainer,children:jsxRuntimeExports.jsxs("div",{className:styles$8.guideContent,children:[jsxRuntimeExports.jsx("h2",{className:styles$8.guideTitle,children:t("ui.guide.title")}),jsxRuntimeExports.jsxs("div",{className:styles$8.guideStep,children:[jsxRuntimeExports.jsx("div",{className:styles$8.guideStepNum,children:"1"}),jsxRuntimeExports.jsxs("div",{className:styles$8.guideStepBody,children:[jsxRuntimeExports.jsx("p",{className:styles$8.guideText,children:t("ui.guide.step1")}),jsxRuntimeExports.jsx("code",{className:styles$8.guideCode,children:t("ui.guide.exampleQuestion")})]})]}),jsxRuntimeExports.jsxs("div",{className:styles$8.guideStep,children:[jsxRuntimeExports.jsx("div",{className:styles$8.guideStepNum,children:"2"}),jsxRuntimeExports.jsxs("div",{className:styles$8.guideStepBody,children:[jsxRuntimeExports.jsx("p",{className:styles$8.guideText,children:t("ui.guide.step2")}),jsxRuntimeExports.jsx("code",{className:styles$8.guideCode,children:t("ui.guide.troubleshootCmd")})]})]}),jsxRuntimeExports.jsxs("div",{className:styles$8.guideStep,children:[jsxRuntimeExports.jsx("div",{className:styles$8.guideStepNum,children:"3"}),jsxRuntimeExports.jsxs("div",{className:styles$8.guideStepBody,children:[jsxRuntimeExports.jsx("p",{className:styles$8.guideText,children:t("ui.guide.step3")}),jsxRuntimeExports.jsx("code",{className:styles$8.guideCode,children:"npm install -g @anthropic-ai/claude-code"})]})]})]})}):jsxRuntimeExports.jsxs("div",{ref:this.mainContainerRef,className:styles$8.mainContainer,children:[jsxRuntimeExports.jsxs("div",{className:styles$8.leftPanel,style:{width:leftPanelWidth},children:[jsxRuntimeExports.jsxs("div",{className:styles$8.leftPanelHeader,children:[jsxRuntimeExports.jsx("span",{children:t("ui.requestList")}),jsxRuntimeExports.jsx("span",{className:styles$8.leftPanelCount,children:t("ui.totalRequests",{count:filteredRequests.length})})]}),jsxRuntimeExports.jsx("div",{className:styles$8.leftPanelBody,children:jsxRuntimeExports.jsx(RequestList,{requests:filteredRequests,selectedIndex:selectedIndex,scrollCenter:this.state.scrollCenter,onSelect:this.handleSelectRequest,onScrollDone:this.handleScrollDone,cacheLossMap:this._cacheLossMap})})]}),jsxRuntimeExports.jsx(PanelResizer,{onResize:this.handleResize}),jsxRuntimeExports.jsx("div",{className:styles$8.rightPanel,children:jsxRuntimeExports.jsx(DetailPanel,{request:selectedRequest,requests:filteredRequests,allRequests:this.state.requests,selectedIndex:selectedIndex,currentTab:currentTab,onTabChange:this.handleTabChange,onViewInChat:this.handleViewInChat,expandDiff:this.state.expandDiff,pendingCacheHighlight:this.state.pendingCacheHighlight,onCacheHighlightDone:this.handleCacheHighlightDone})})]})),jsxRuntimeExports.jsx("div",{className:styles$8.chatViewWrapper,style:{display:"chat"===viewMode?"flex":"none"},children:jsxRuntimeExports.jsx(ChatView,{...this._settingsProps(),getTokenStatsContent:this._getTokenStatsContent,requests:filteredRequests,mainAgentSessions:mainAgentSessions,streamingLatest:this.state.streamingLatest,userProfile:this.state.userProfile,collapseToolResults:this.state.collapseToolResults,expandThinking:this.state.expandThinking,showFullToolContent:this.state.showFullToolContent,showThinkingSummaries:this.state.showThinkingSummaries,onViewRequest:this.handleViewRequest,scrollToTimestamp:this.state.chatScrollToTs,onScrollTsDone:this.handleScrollTsDone,cliMode:!this._isLocalLog&&this.state.cliMode,sdkMode:!this._isLocalLog&&this.state.sdkMode,terminalVisible:!this._isLocalLog&&(!this.state.sdkMode&&this.state.terminalVisible),onToggleTerminal:()=>this.setState(prev=>({terminalVisible:!prev.terminalVisible})),pendingUploadPaths:this.state.pendingUploadPaths,onUploadPathsConsumed:this.handleUploadPathsConsumed,fileLoading:this.state.fileLoading,isStreaming:this.state.isStreaming,hasMoreHistory:this.state.hasMoreHistory,loadingMore:this.state.loadingMore,onLoadMoreHistory:()=>this.loadMoreHistory(),loadingSessionId:this.state.loadingSessionId,onLoadSession:sid=>this.loadSession(sid),lang:this.state.lang,autoApproveSeconds:this.state.autoApproveSeconds,onAutoApproveChange:this.handleAutoApproveChange,onClearContextOptimistic:this.handleClearContextOptimistic,onPendingAsk:this.handleApprovalAsk,onPendingPtyPlan:this.handleApprovalPtyPlan,ownTabId:this.state.ownTabId,projectName:this.state.projectName,setContextBarSlot:this.setContextBarSlot})})]}),jsxRuntimeExports.jsxs("div",{className:styles$8.footer,children:[jsxRuntimeExports.jsx(CountryFlag,{}),jsxRuntimeExports.jsxs("div",{className:styles$8.footerRight,children:[jsxRuntimeExports.jsxs("a",{href:"https://github.com/weiesky/cc-viewer",target:"_blank",rel:"noopener noreferrer",className:styles$8.footerLink,children:[jsxRuntimeExports.jsx("svg",{className:styles$8.footerIcon,viewBox:"0 0 16 16",fill:"currentColor",children:jsxRuntimeExports.jsx("path",{d:"M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"})}),"GitHub",null!=this.state.githubStars?` ★ ${this.state.githubStars}`:""]}),jsxRuntimeExports.jsx("span",{className:styles$8.footerSep,children:"|"}),jsxRuntimeExports.jsxs("span",{className:styles$8.footerVersion,onClick:()=>this.setState({updateModalVisible:!0}),style:{cursor:"pointer"},children:["v","1.6.256"]}),this.state.updateInfo&&jsxRuntimeExports.jsx(Tooltip,{title:t("ui.update.majorAvailable",{version:this.state.updateInfo.version}),placement:"top",children:jsxRuntimeExports.jsx("span",{className:styles$8.newBadgeText,onClick:()=>this.setState({updateModalVisible:!0}),children:t("ui.update.newBadge")})})]})]})]}),jsxRuntimeExports.jsx(Modal,{title:t("ui.update.title"),open:this.state.updateModalVisible,onCancel:()=>this.setState({updateModalVisible:!1}),footer:null,width:480,children:jsxRuntimeExports.jsxs("div",{style:{lineHeight:1.8},children:[jsxRuntimeExports.jsxs("p",{children:[jsxRuntimeExports.jsxs("strong",{children:[t("ui.update.current"),":"]})," v","1.6.256"]}),this.state.updateInfo&&jsxRuntimeExports.jsxs("p",{children:[jsxRuntimeExports.jsxs("strong",{children:[t("ui.update.latest"),":"]})," v",this.state.updateInfo.version]}),jsxRuntimeExports.jsx("p",{style:{marginTop:12},children:jsxRuntimeExports.jsx("strong",{children:t("ui.update.npm")})}),jsxRuntimeExports.jsx("code",{style:{display:"block",background:"var(--bg-code)",padding:"8px 12px",borderRadius:6,fontSize:13},children:"npm update -g cc-viewer"}),"undefined"!=typeof window&&window.electronAPI&&jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("p",{style:{marginTop:16},children:jsxRuntimeExports.jsx("strong",{children:t("ui.update.electron")})}),jsxRuntimeExports.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:13},children:t("ui.update.electronDesc")}),jsxRuntimeExports.jsxs("ol",{style:{color:"var(--text-tertiary)",fontSize:13,paddingLeft:20,margin:"6px 0"},children:[jsxRuntimeExports.jsx("li",{children:t("ui.update.step1")}),jsxRuntimeExports.jsx("li",{children:t("ui.update.step2")}),jsxRuntimeExports.jsx("li",{children:t("ui.update.step3")})]})]}),jsxRuntimeExports.jsx("div",{style:{marginTop:16,textAlign:"right"},children:jsxRuntimeExports.jsx(Button,{type:"primary",href:"https://github.com/weiesky/cc-viewer/releases",target:"_blank",rel:"noopener noreferrer",children:t("ui.update.goReleases")})})]})}),jsxRuntimeExports.jsx(Modal,{title:t("ui.resume.title"),open:this.state.resumeModalVisible,closable:!1,maskClosable:!1,keyboard:!1,footer:jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsxs("div",{className:styles$8.resumeFooterRight,children:[jsxRuntimeExports.jsx(Button,{type:"primary",onClick:()=>this.handleResumeChoice("continue"),className:styles$8.btnMarginRight,children:t("ui.resume.continue")},"continue"),jsxRuntimeExports.jsx(Button,{onClick:()=>this.handleResumeChoice("new"),children:t("ui.resume.new")},"new")]}),jsxRuntimeExports.jsx("div",{className:styles$8.resumeFooterLeft,children:jsxRuntimeExports.jsx(Checkbox,{checked:this.state.resumeRememberChoice,onChange:e=>this.setState({resumeRememberChoice:e.target.checked}),className:styles$8.resumeCheckboxOpacity,children:jsxRuntimeExports.jsx("span",{className:styles$8.resumeCheckboxOpacity,children:t("ui.resume.remember")})})})]}),children:jsxRuntimeExports.jsx("p",{children:t("ui.resume.message",{file:this.state.resumeFileName})})}),jsxRuntimeExports.jsxs(Modal,{title:jsxRuntimeExports.jsxs("span",{className:styles$8.modalTitleInline,children:[jsxRuntimeExports.jsx(OpenFolderIcon,{apiEndpoint:apiUrl("/api/open-log-dir"),title:t("ui.openLogDir"),size:16}),t("ui.importLocalLogs")]}),open:this.state.importModalVisible,onCancel:this.handleCloseImportModal,footer:null,width:1e3,styles:{body:{overflow:"hidden"}},children:[jsxRuntimeExports.jsxs("div",{className:styles$8.modalActions,children:[jsxRuntimeExports.jsx(Button,{icon:jsxRuntimeExports.jsx(RefIcon$e,{}),onClick:this.handleLoadLocalJsonlFile,children:t("ui.loadLocalJsonl")}),jsxRuntimeExports.jsx(Button,{size:"small",type:this.state.selectedLogs.size>1?"primary":"default",disabled:this.state.selectedLogs.size<2,onClick:this.handleMergeLogs,className:styles$8.btnMarginLeft,children:t("ui.mergeLogs")}),jsxRuntimeExports.jsx(Button,{size:"small",danger:!0,icon:jsxRuntimeExports.jsx(RefIcon$f,{}),disabled:0===this.state.selectedLogs.size,onClick:this.handleDeleteLogs,className:styles$8.btnMarginLeft,children:t("ui.deleteLogs")}),jsxRuntimeExports.jsx(Button,{size:"small",icon:jsxRuntimeExports.jsx(RefIcon$g,{spin:this.state.refreshingStats}),loading:this.state.refreshingStats,onClick:this.handleRefreshStats,className:styles$8.btnMarginLeft,children:t("ui.refreshStats")})]}),this.state.localLogsLoading?jsxRuntimeExports.jsx("div",{className:styles$8.spinCenter,children:jsxRuntimeExports.jsx(Spin,{})}):(()=>{const currentLogs=this.state.localLogs[this.state.currentProject];return currentLogs&&0!==currentLogs.length?jsxRuntimeExports.jsx("div",{className:styles$8.logListContainer,children:this.renderLogTable(currentLogs,!1)}):jsxRuntimeExports.jsx("div",{className:styles$8.emptyCenter,children:t("ui.noLogs")})})()]})]})})})}}export{App as default};
@@ -1 +1 @@
1
- import{j as jsxRuntimeExports}from"./vendor-codemirror-2nbmPewy.js";import{a as reactExports,s as staticMethods}from"./vendor-antd-BeN8xqGk.js";import{M as MDXEditor,h as headingsPlugin,l as listsPlugin,q as quotePlugin,a as linkPlugin,b as linkDialogPlugin,i as imagePlugin,t as tablePlugin,c as codeBlockPlugin,d as codeMirrorPlugin,e as thematicBreakPlugin,m as markdownShortcutPlugin,f as diffSourcePlugin,g as toolbarPlugin,D as DiffSourceToggleWrapper,U as UndoRedo,S as Separator,B as BoldItalicUnderlineToggles,C as CodeToggle,j as BlockTypeSelect,L as ListsToggle,k as CreateLink,I as InsertImage,n as InsertTable,o as InsertCodeBlock,p as InsertThematicBreak}from"./vendor-mdxeditor-C7DYEBoH.js";import{g as getLang,t}from"./index-WlCEIiNa.js";const styles={container:"_container_3d9hl_25",light:"_light_3d9hl_3",contentEditable:"_contentEditable_3d9hl_16"},PASSTHROUGH_TYPES=new Set(["image/png","image/gif","image/webp","image/svg+xml"]);function readAsDataURL(file){return new Promise((resolve,reject)=>{const reader=new FileReader;reader.onload=()=>resolve(reader.result),reader.onerror=()=>reject(new Error("FileReader failed")),reader.readAsDataURL(file)})}async function compressImageToDataURL(file,opts={}){if(!(file instanceof Blob))throw new Error("compressImageToDataURL: input must be a File or Blob");if(!file.type||!file.type.startsWith("image/"))throw new Error(`Unsupported file type: ${file.type||"unknown"}`);if(file.size>10485760)throw new Error(`Image too large: ${(file.size/1024/1024).toFixed(1)}MB > 10MB limit`);const maxEdge=opts.maxEdge??2e3,quality=opts.quality??.85;if(PASSTHROUGH_TYPES.has(file.type))return await readAsDataURL(file);const originalDataURL=await readAsDataURL(file),img=await(src=originalDataURL,new Promise((resolve,reject)=>{const img=new Image;img.onload=()=>resolve(img),img.onerror=()=>reject(new Error("Image decode failed")),img.src=src}));var src;const longestEdge=Math.max(img.naturalWidth,img.naturalHeight),scale=longestEdge>maxEdge?maxEdge/longestEdge:1,targetW=Math.max(1,Math.round(img.naturalWidth*scale)),targetH=Math.max(1,Math.round(img.naturalHeight*scale)),canvas=document.createElement("canvas");canvas.width=targetW,canvas.height=targetH;const ctx=canvas.getContext("2d");if(!ctx)return originalDataURL;let compressed;ctx.drawImage(img,0,0,targetW,targetH);try{compressed=canvas.toDataURL("image/jpeg",quality)}catch{return originalDataURL}return!compressed||"data:,"===compressed||compressed.length>=originalDataURL.length?originalDataURL:compressed}const TRANSLATIONS={zh:{contentArea:{editableMarkdown:"可编辑 Markdown"},dialog:{close:"关闭"},dialogControls:{cancel:"取消",save:"保存"},createLink:{text:"链接文字",textTooltip:"链接显示的文字",title:"标题",titleTooltip:"链接的 title 属性(鼠标悬停时显示)",url:"链接地址",urlPlaceholder:"请输入链接地址",saveTooltip:"保存链接",cancelTooltip:"取消编辑"},linkPreview:{open:"在新窗口打开 {{url}}",edit:"编辑链接",copyToClipboard:"复制链接到剪贴板",copied:"已复制",remove:"移除链接"},uploadImage:{dialogTitle:"插入图片",uploadInstructions:"从本地选择图片上传",addViaUrlInstructions:"或输入图片地址",addViaUrlInstructionsNoUpload:"请输入图片地址",autoCompletePlaceholder:"搜索已有图片",alt:"替代文字",title:"标题",width:"宽度",height:"高度"},imageEditor:{editImage:"编辑图片",deleteImage:"删除图片"},table:{columnMenu:"列菜单",rowMenu:"行菜单",textAlignment:"文字对齐",alignLeft:"左对齐",alignCenter:"居中",alignRight:"右对齐",insertColumnLeft:"在左侧插入列",insertColumnRight:"在右侧插入列",insertRowAbove:"在上方插入行",insertRowBelow:"在下方插入行",deleteColumn:"删除列",deleteRow:"删除行",deleteTable:"删除表格"},codeBlock:{language:"语言",inlineLanguage:"行内语言",selectLanguage:"选择语言"},codeblock:{delete:"删除代码块"},toolbar:{undo:"撤销 {{shortcut}}",redo:"重做 {{shortcut}}",bold:"加粗",italic:"斜体",underline:"下划线",removeBold:"取消加粗",removeItalic:"取消斜体",removeUnderline:"取消下划线",inlineCode:"行内代码",removeInlineCode:"取消行内代码",bulletedList:"无序列表",numberedList:"有序列表",checkList:"任务列表",toggleGroup:"列表样式",link:"插入链接",image:"插入图片",table:"插入表格",codeBlock:"插入代码块",thematicBreak:"插入分隔线",richText:"富文本",diffMode:"对比视图",source:"源代码",blockTypeSelect:{placeholder:"块类型",selectBlockTypeTooltip:"选择块类型"},blockTypes:{paragraph:"段落",heading:"标题 {{level}}",quote:"引用"}}},"zh-TW":{contentArea:{editableMarkdown:"可編輯 Markdown"},dialog:{close:"關閉"},dialogControls:{cancel:"取消",save:"儲存"},createLink:{text:"連結文字",textTooltip:"連結顯示的文字",title:"標題",titleTooltip:"連結的 title 屬性(滑鼠懸停時顯示)",url:"連結網址",urlPlaceholder:"請輸入連結網址",saveTooltip:"儲存連結",cancelTooltip:"取消編輯"},linkPreview:{open:"在新視窗開啟 {{url}}",edit:"編輯連結",copyToClipboard:"複製連結至剪貼簿",copied:"已複製",remove:"移除連結"},uploadImage:{dialogTitle:"插入圖片",uploadInstructions:"從本地選擇圖片上傳",addViaUrlInstructions:"或輸入圖片網址",addViaUrlInstructionsNoUpload:"請輸入圖片網址",autoCompletePlaceholder:"搜尋現有圖片",alt:"替代文字",title:"標題",width:"寬度",height:"高度"},imageEditor:{editImage:"編輯圖片",deleteImage:"刪除圖片"},table:{columnMenu:"欄選單",rowMenu:"列選單",textAlignment:"文字對齊",alignLeft:"靠左",alignCenter:"置中",alignRight:"靠右",insertColumnLeft:"在左側插入欄",insertColumnRight:"在右側插入欄",insertRowAbove:"在上方插入列",insertRowBelow:"在下方插入列",deleteColumn:"刪除欄",deleteRow:"刪除列",deleteTable:"刪除表格"},codeBlock:{language:"語言",inlineLanguage:"行內語言",selectLanguage:"選擇語言"},codeblock:{delete:"刪除程式碼區塊"},toolbar:{undo:"復原 {{shortcut}}",redo:"重做 {{shortcut}}",bold:"粗體",italic:"斜體",underline:"底線",removeBold:"取消粗體",removeItalic:"取消斜體",removeUnderline:"取消底線",inlineCode:"行內程式碼",removeInlineCode:"取消行內程式碼",bulletedList:"項目符號清單",numberedList:"編號清單",checkList:"工作清單",toggleGroup:"清單樣式",link:"插入連結",image:"插入圖片",table:"插入表格",codeBlock:"插入程式碼區塊",thematicBreak:"插入分隔線",richText:"所見即所得",diffMode:"比對檢視",source:"原始碼",blockTypeSelect:{placeholder:"區塊類型",selectBlockTypeTooltip:"選擇區塊類型"},blockTypes:{paragraph:"段落",heading:"標題 {{level}}",quote:"引用"}}},ja:{toolbar:{undo:"元に戻す {{shortcut}}",redo:"やり直し {{shortcut}}",bold:"太字",italic:"イタリック",underline:"下線",removeBold:"太字を解除",removeItalic:"イタリックを解除",removeUnderline:"下線を解除",inlineCode:"インラインコード",removeInlineCode:"インラインコードを解除",bulletedList:"箇条書き",numberedList:"番号付きリスト",checkList:"チェックリスト",toggleGroup:"リストスタイル",link:"リンクを挿入",image:"画像を挿入",table:"表を挿入",codeBlock:"コードブロックを挿入",thematicBreak:"区切り線を挿入",richText:"リッチテキスト",diffMode:"差分表示",source:"ソース",blockTypeSelect:{placeholder:"ブロック種別",selectBlockTypeTooltip:"ブロック種別を選択"},blockTypes:{paragraph:"段落",heading:"見出し {{level}}",quote:"引用"}}},ko:{toolbar:{undo:"실행 취소 {{shortcut}}",redo:"다시 실행 {{shortcut}}",bold:"굵게",italic:"기울임",underline:"밑줄",removeBold:"굵게 해제",removeItalic:"기울임 해제",removeUnderline:"밑줄 해제",inlineCode:"인라인 코드",removeInlineCode:"인라인 코드 해제",bulletedList:"글머리 기호 목록",numberedList:"번호 매기기 목록",checkList:"체크리스트",toggleGroup:"목록 스타일",link:"링크 삽입",image:"이미지 삽입",table:"표 삽입",codeBlock:"코드 블록 삽입",thematicBreak:"구분선 삽입",richText:"서식있는 텍스트",diffMode:"비교 보기",source:"소스",blockTypeSelect:{placeholder:"블록 유형",selectBlockTypeTooltip:"블록 유형 선택"},blockTypes:{paragraph:"단락",heading:"제목 {{level}}",quote:"인용"}}},de:{toolbar:{undo:"Rückgängig {{shortcut}}",redo:"Wiederherstellen {{shortcut}}",bold:"Fett",italic:"Kursiv",underline:"Unterstrichen",removeBold:"Fett entfernen",removeItalic:"Kursiv entfernen",removeUnderline:"Unterstrichen entfernen",inlineCode:"Inline-Code",removeInlineCode:"Inline-Code entfernen",bulletedList:"Aufzählungsliste",numberedList:"Nummerierte Liste",checkList:"Aufgabenliste",toggleGroup:"Listenstil",link:"Link einfügen",image:"Bild einfügen",table:"Tabelle einfügen",codeBlock:"Codeblock einfügen",thematicBreak:"Trennlinie einfügen",richText:"Rich-Text",diffMode:"Diff-Ansicht",source:"Quelltext",blockTypeSelect:{placeholder:"Blocktyp",selectBlockTypeTooltip:"Blocktyp auswählen"},blockTypes:{paragraph:"Absatz",heading:"Überschrift {{level}}",quote:"Zitat"}}},es:{toolbar:{undo:"Deshacer {{shortcut}}",redo:"Rehacer {{shortcut}}",bold:"Negrita",italic:"Cursiva",underline:"Subrayado",removeBold:"Quitar negrita",removeItalic:"Quitar cursiva",removeUnderline:"Quitar subrayado",inlineCode:"Código en línea",removeInlineCode:"Quitar código en línea",bulletedList:"Lista con viñetas",numberedList:"Lista numerada",checkList:"Lista de tareas",toggleGroup:"Estilo de lista",link:"Insertar enlace",image:"Insertar imagen",table:"Insertar tabla",codeBlock:"Insertar bloque de código",thematicBreak:"Insertar separador",richText:"Texto enriquecido",diffMode:"Vista comparativa",source:"Código fuente",blockTypeSelect:{placeholder:"Tipo de bloque",selectBlockTypeTooltip:"Seleccionar tipo de bloque"},blockTypes:{paragraph:"Párrafo",heading:"Encabezado {{level}}",quote:"Cita"}}},fr:{toolbar:{undo:"Annuler {{shortcut}}",redo:"Rétablir {{shortcut}}",bold:"Gras",italic:"Italique",underline:"Souligné",removeBold:"Retirer le gras",removeItalic:"Retirer l’italique",removeUnderline:"Retirer le soulignement",inlineCode:"Code en ligne",removeInlineCode:"Retirer le code en ligne",bulletedList:"Liste à puces",numberedList:"Liste numérotée",checkList:"Liste de tâches",toggleGroup:"Style de liste",link:"Insérer un lien",image:"Insérer une image",table:"Insérer un tableau",codeBlock:"Insérer un bloc de code",thematicBreak:"Insérer un séparateur",richText:"Texte enrichi",diffMode:"Vue comparative",source:"Source",blockTypeSelect:{placeholder:"Type de bloc",selectBlockTypeTooltip:"Choisir le type de bloc"},blockTypes:{paragraph:"Paragraphe",heading:"Titre {{level}}",quote:"Citation"}}},it:{toolbar:{undo:"Annulla {{shortcut}}",redo:"Ripristina {{shortcut}}",bold:"Grassetto",italic:"Corsivo",underline:"Sottolineato",removeBold:"Rimuovi grassetto",removeItalic:"Rimuovi corsivo",removeUnderline:"Rimuovi sottolineato",inlineCode:"Codice in linea",removeInlineCode:"Rimuovi codice in linea",bulletedList:"Elenco puntato",numberedList:"Elenco numerato",checkList:"Elenco di attività",toggleGroup:"Stile elenco",link:"Inserisci link",image:"Inserisci immagine",table:"Inserisci tabella",codeBlock:"Inserisci blocco di codice",thematicBreak:"Inserisci separatore",richText:"Testo formattato",diffMode:"Vista differenze",source:"Sorgente",blockTypeSelect:{placeholder:"Tipo di blocco",selectBlockTypeTooltip:"Seleziona tipo di blocco"},blockTypes:{paragraph:"Paragrafo",heading:"Titolo {{level}}",quote:"Citazione"}}},da:{toolbar:{undo:"Fortryd {{shortcut}}",redo:"Gentag {{shortcut}}",bold:"Fed",italic:"Kursiv",underline:"Understreget",removeBold:"Fjern fed",removeItalic:"Fjern kursiv",removeUnderline:"Fjern understregning",inlineCode:"Indlejret kode",removeInlineCode:"Fjern indlejret kode",bulletedList:"Punktopstilling",numberedList:"Nummereret liste",checkList:"Tjekliste",toggleGroup:"Listestil",link:"Indsæt link",image:"Indsæt billede",table:"Indsæt tabel",codeBlock:"Indsæt kodeblok",thematicBreak:"Indsæt skillelinje",richText:"Formateret tekst",diffMode:"Diff-visning",source:"Kilde",blockTypeSelect:{placeholder:"Bloktype",selectBlockTypeTooltip:"Vælg bloktype"},blockTypes:{paragraph:"Afsnit",heading:"Overskrift {{level}}",quote:"Citat"}}},pl:{toolbar:{undo:"Cofnij {{shortcut}}",redo:"Ponów {{shortcut}}",bold:"Pogrubienie",italic:"Kursywa",underline:"Podkreślenie",removeBold:"Usuń pogrubienie",removeItalic:"Usuń kursywę",removeUnderline:"Usuń podkreślenie",inlineCode:"Kod w linii",removeInlineCode:"Usuń kod w linii",bulletedList:"Lista punktowana",numberedList:"Lista numerowana",checkList:"Lista zadań",toggleGroup:"Styl listy",link:"Wstaw link",image:"Wstaw obraz",table:"Wstaw tabelę",codeBlock:"Wstaw blok kodu",thematicBreak:"Wstaw separator",richText:"Tekst sformatowany",diffMode:"Widok porównania",source:"Źródło",blockTypeSelect:{placeholder:"Typ bloku",selectBlockTypeTooltip:"Wybierz typ bloku"},blockTypes:{paragraph:"Akapit",heading:"Nagłówek {{level}}",quote:"Cytat"}}},ru:{toolbar:{undo:"Отменить {{shortcut}}",redo:"Повторить {{shortcut}}",bold:"Полужирный",italic:"Курсив",underline:"Подчёркнутый",removeBold:"Убрать полужирный",removeItalic:"Убрать курсив",removeUnderline:"Убрать подчёркивание",inlineCode:"Встроенный код",removeInlineCode:"Убрать встроенный код",bulletedList:"Маркированный список",numberedList:"Нумерованный список",checkList:"Список задач",toggleGroup:"Стиль списка",link:"Вставить ссылку",image:"Вставить изображение",table:"Вставить таблицу",codeBlock:"Вставить блок кода",thematicBreak:"Вставить разделитель",richText:"Форматированный текст",diffMode:"Вид сравнения",source:"Исходный код",blockTypeSelect:{placeholder:"Тип блока",selectBlockTypeTooltip:"Выбрать тип блока"},blockTypes:{paragraph:"Абзац",heading:"Заголовок {{level}}",quote:"Цитата"}}},ar:{toolbar:{undo:"تراجع {{shortcut}}",redo:"إعادة {{shortcut}}",bold:"عريض",italic:"مائل",underline:"تسطير",removeBold:"إزالة العريض",removeItalic:"إزالة المائل",removeUnderline:"إزالة التسطير",inlineCode:"كود مضمن",removeInlineCode:"إزالة الكود المضمن",bulletedList:"قائمة نقطية",numberedList:"قائمة مرقمة",checkList:"قائمة مهام",toggleGroup:"نمط القائمة",link:"إدراج رابط",image:"إدراج صورة",table:"إدراج جدول",codeBlock:"إدراج كتلة كود",thematicBreak:"إدراج فاصل",richText:"نص منسق",diffMode:"عرض المقارنة",source:"المصدر",blockTypeSelect:{placeholder:"نوع الكتلة",selectBlockTypeTooltip:"اختر نوع الكتلة"},blockTypes:{paragraph:"فقرة",heading:"عنوان {{level}}",quote:"اقتباس"}}},no:{toolbar:{undo:"Angre {{shortcut}}",redo:"Gjør om {{shortcut}}",bold:"Fet",italic:"Kursiv",underline:"Understreket",removeBold:"Fjern fet",removeItalic:"Fjern kursiv",removeUnderline:"Fjern understreking",inlineCode:"Inline-kode",removeInlineCode:"Fjern inline-kode",bulletedList:"Punktliste",numberedList:"Nummerert liste",checkList:"Sjekkliste",toggleGroup:"Listestil",link:"Sett inn lenke",image:"Sett inn bilde",table:"Sett inn tabell",codeBlock:"Sett inn kodeblokk",thematicBreak:"Sett inn skillelinje",richText:"Formatert tekst",diffMode:"Diff-visning",source:"Kilde",blockTypeSelect:{placeholder:"Blokktype",selectBlockTypeTooltip:"Velg blokktype"},blockTypes:{paragraph:"Avsnitt",heading:"Overskrift {{level}}",quote:"Sitat"}}},"pt-BR":{toolbar:{undo:"Desfazer {{shortcut}}",redo:"Refazer {{shortcut}}",bold:"Negrito",italic:"Itálico",underline:"Sublinhado",removeBold:"Remover negrito",removeItalic:"Remover itálico",removeUnderline:"Remover sublinhado",inlineCode:"Código em linha",removeInlineCode:"Remover código em linha",bulletedList:"Lista com marcadores",numberedList:"Lista numerada",checkList:"Lista de tarefas",toggleGroup:"Estilo da lista",link:"Inserir link",image:"Inserir imagem",table:"Inserir tabela",codeBlock:"Inserir bloco de código",thematicBreak:"Inserir separador",richText:"Texto formatado",diffMode:"Visualização de diferenças",source:"Código-fonte",blockTypeSelect:{placeholder:"Tipo de bloco",selectBlockTypeTooltip:"Selecionar tipo de bloco"},blockTypes:{paragraph:"Parágrafo",heading:"Título {{level}}",quote:"Citação"}}},th:{toolbar:{undo:"เลิกทำ {{shortcut}}",redo:"ทำซ้ำ {{shortcut}}",bold:"ตัวหนา",italic:"ตัวเอียง",underline:"ขีดเส้นใต้",removeBold:"ยกเลิกตัวหนา",removeItalic:"ยกเลิกตัวเอียง",removeUnderline:"ยกเลิกขีดเส้นใต้",inlineCode:"โค้ดในบรรทัด",removeInlineCode:"ยกเลิกโค้ดในบรรทัด",bulletedList:"รายการแบบจุด",numberedList:"รายการตัวเลข",checkList:"รายการตรวจสอบ",toggleGroup:"รูปแบบรายการ",link:"แทรกลิงก์",image:"แทรกรูปภาพ",table:"แทรกตาราง",codeBlock:"แทรกบล็อกโค้ด",thematicBreak:"แทรกเส้นคั่น",richText:"ข้อความรูปแบบ",diffMode:"มุมมองเปรียบเทียบ",source:"ซอร์ส",blockTypeSelect:{placeholder:"ประเภทบล็อก",selectBlockTypeTooltip:"เลือกประเภทบล็อก"},blockTypes:{paragraph:"ย่อหน้า",heading:"หัวข้อ {{level}}",quote:"คำพูดอ้างอิง"}}},tr:{toolbar:{undo:"Geri al {{shortcut}}",redo:"Yinele {{shortcut}}",bold:"Kalın",italic:"İtalik",underline:"Altı çizili",removeBold:"Kalını kaldır",removeItalic:"İtaliği kaldır",removeUnderline:"Altı çiziliyi kaldır",inlineCode:"Satır içi kod",removeInlineCode:"Satır içi kodu kaldır",bulletedList:"Madde işaretli liste",numberedList:"Numaralı liste",checkList:"Kontrol listesi",toggleGroup:"Liste stili",link:"Bağlantı ekle",image:"Resim ekle",table:"Tablo ekle",codeBlock:"Kod bloğu ekle",thematicBreak:"Ayraç ekle",richText:"Zengin metin",diffMode:"Karşılaştırma görünümü",source:"Kaynak",blockTypeSelect:{placeholder:"Blok türü",selectBlockTypeTooltip:"Blok türü seç"},blockTypes:{paragraph:"Paragraf",heading:"Başlık {{level}}",quote:"Alıntı"}}},uk:{toolbar:{undo:"Скасувати {{shortcut}}",redo:"Повторити {{shortcut}}",bold:"Жирний",italic:"Курсив",underline:"Підкреслений",removeBold:"Прибрати жирний",removeItalic:"Прибрати курсив",removeUnderline:"Прибрати підкреслення",inlineCode:"Вбудований код",removeInlineCode:"Прибрати вбудований код",bulletedList:"Маркований список",numberedList:"Нумерований список",checkList:"Список завдань",toggleGroup:"Стиль списку",link:"Вставити посилання",image:"Вставити зображення",table:"Вставити таблицю",codeBlock:"Вставити блок коду",thematicBreak:"Вставити роздільник",richText:"Форматований текст",diffMode:"Перегляд порівняння",source:"Джерело",blockTypeSelect:{placeholder:"Тип блоку",selectBlockTypeTooltip:"Виберіть тип блоку"},blockTypes:{paragraph:"Абзац",heading:"Заголовок {{level}}",quote:"Цитата"}}}};function mdxTranslation(key,defaultValue,interpolations){const lang=("function"==typeof getLang?getLang():"en")||"en",langTable=TRANSLATIONS[lang]||TRANSLATIONS[lang.split("-")[0]];return function(template,values){if(!values)return template;let out=template.replace(/\{\{\s*(\w+)\s*\}\}/g,(_,k)=>k in values?String(values[k]):`{{${k}}}`);return out=out.replace(/\{(\w+)\}/g,(_,k)=>k in values?String(values[k]):`{${k}}`),out}((langTable&&function(obj,path){const parts=path.split(".");let cur=obj;for(const p of parts){if(!cur||"object"!=typeof cur||!(p in cur))return;cur=cur[p]}return"string"==typeof cur?cur:void 0}(langTable,key))??defaultValue??key,interpolations)}function getDocTheme(){return"undefined"==typeof document?"dark":"light"===document.documentElement.getAttribute("data-theme")?"light":"dark"}const CODE_BLOCK_LANGUAGES={"":"Plain text",js:"JavaScript",ts:"TypeScript",jsx:"JSX",tsx:"TSX",py:"Python",sh:"Shell",bash:"Bash",json:"JSON",yaml:"YAML",md:"Markdown",html:"HTML",css:"CSS",sql:"SQL",go:"Go",rust:"Rust",java:"Java",cpp:"C++"},MdxEditorPanel=reactExports.forwardRef(function({initialMarkdown:initialMarkdown,onChange:onChange,onError:onError,onParseError:onParseError},ref){const editorRef=reactExports.useRef(null),[theme,setTheme]=reactExports.useState(getDocTheme),lang="function"==typeof getLang?getLang():"en";reactExports.useEffect(()=>{const target=document.documentElement,obs=new MutationObserver(()=>setTheme(getDocTheme()));return obs.observe(target,{attributes:!0,attributeFilter:["data-theme"]}),()=>obs.disconnect()},[]);const imageUploadHandler=reactExports.useCallback(async file=>{try{return await compressImageToDataURL(file,{maxEdge:2e3,quality:.85})}catch(err){const msg=`${t("ui.mdEditor.uploadFailed")}: ${err.message??err}`;try{staticMethods.error(msg)}catch{}throw"function"==typeof onError&&onError(err),err}},[onError]);return reactExports.useImperativeHandle(ref,()=>({getMarkdown:()=>{var _a,_b;return(null==(_b=null==(_a=editorRef.current)?void 0:_a.getMarkdown)?void 0:_b.call(_a))??""},setMarkdown:md=>{var _a,_b;return null==(_b=null==(_a=editorRef.current)?void 0:_a.setMarkdown)?void 0:_b.call(_a,md??"")},focus:()=>{var _a,_b;return null==(_b=null==(_a=editorRef.current)?void 0:_a.focus)?void 0:_b.call(_a)}}),[]),jsxRuntimeExports.jsx("div",{className:`${styles.container} ${"dark"===theme?`dark-theme ${styles.dark}`:styles.light}`,children:jsxRuntimeExports.jsx(MDXEditor,{ref:editorRef,markdown:initialMarkdown??"",onChange:onChange,onError:payload=>{if("function"==typeof onParseError)try{onParseError(payload)}catch{}},translation:mdxTranslation,contentEditableClassName:styles.contentEditable,plugins:[headingsPlugin(),listsPlugin(),quotePlugin(),linkPlugin(),linkDialogPlugin(),imagePlugin({imageUploadHandler:imageUploadHandler}),tablePlugin(),codeBlockPlugin({defaultCodeBlockLanguage:""}),codeMirrorPlugin({codeBlockLanguages:CODE_BLOCK_LANGUAGES}),thematicBreakPlugin(),markdownShortcutPlugin(),diffSourcePlugin({viewMode:"rich-text",diffMarkdown:initialMarkdown??""}),toolbarPlugin({toolbarContents:()=>jsxRuntimeExports.jsxs(DiffSourceToggleWrapper,{children:[jsxRuntimeExports.jsx(UndoRedo,{}),jsxRuntimeExports.jsx(Separator,{}),jsxRuntimeExports.jsx(BoldItalicUnderlineToggles,{}),jsxRuntimeExports.jsx(CodeToggle,{}),jsxRuntimeExports.jsx(Separator,{}),jsxRuntimeExports.jsx(BlockTypeSelect,{}),jsxRuntimeExports.jsx(ListsToggle,{}),jsxRuntimeExports.jsx(Separator,{}),jsxRuntimeExports.jsx(CreateLink,{}),jsxRuntimeExports.jsx(InsertImage,{}),jsxRuntimeExports.jsx(InsertTable,{}),jsxRuntimeExports.jsx(InsertCodeBlock,{}),jsxRuntimeExports.jsx(InsertThematicBreak,{})]})})]},lang)})});export{MdxEditorPanel as default};
1
+ import{j as jsxRuntimeExports}from"./vendor-codemirror-2nbmPewy.js";import{a as reactExports,s as staticMethods}from"./vendor-antd-BeN8xqGk.js";import{M as MDXEditor,h as headingsPlugin,l as listsPlugin,q as quotePlugin,a as linkPlugin,b as linkDialogPlugin,i as imagePlugin,t as tablePlugin,c as codeBlockPlugin,d as codeMirrorPlugin,e as thematicBreakPlugin,m as markdownShortcutPlugin,f as diffSourcePlugin,g as toolbarPlugin,D as DiffSourceToggleWrapper,U as UndoRedo,S as Separator,B as BoldItalicUnderlineToggles,C as CodeToggle,j as BlockTypeSelect,L as ListsToggle,k as CreateLink,I as InsertImage,n as InsertTable,o as InsertCodeBlock,p as InsertThematicBreak}from"./vendor-mdxeditor-C7DYEBoH.js";import{g as getLang,t}from"./index-aBYCRImE.js";const styles={container:"_container_3d9hl_25",light:"_light_3d9hl_3",contentEditable:"_contentEditable_3d9hl_16"},PASSTHROUGH_TYPES=new Set(["image/png","image/gif","image/webp","image/svg+xml"]);function readAsDataURL(file){return new Promise((resolve,reject)=>{const reader=new FileReader;reader.onload=()=>resolve(reader.result),reader.onerror=()=>reject(new Error("FileReader failed")),reader.readAsDataURL(file)})}async function compressImageToDataURL(file,opts={}){if(!(file instanceof Blob))throw new Error("compressImageToDataURL: input must be a File or Blob");if(!file.type||!file.type.startsWith("image/"))throw new Error(`Unsupported file type: ${file.type||"unknown"}`);if(file.size>10485760)throw new Error(`Image too large: ${(file.size/1024/1024).toFixed(1)}MB > 10MB limit`);const maxEdge=opts.maxEdge??2e3,quality=opts.quality??.85;if(PASSTHROUGH_TYPES.has(file.type))return await readAsDataURL(file);const originalDataURL=await readAsDataURL(file),img=await(src=originalDataURL,new Promise((resolve,reject)=>{const img=new Image;img.onload=()=>resolve(img),img.onerror=()=>reject(new Error("Image decode failed")),img.src=src}));var src;const longestEdge=Math.max(img.naturalWidth,img.naturalHeight),scale=longestEdge>maxEdge?maxEdge/longestEdge:1,targetW=Math.max(1,Math.round(img.naturalWidth*scale)),targetH=Math.max(1,Math.round(img.naturalHeight*scale)),canvas=document.createElement("canvas");canvas.width=targetW,canvas.height=targetH;const ctx=canvas.getContext("2d");if(!ctx)return originalDataURL;let compressed;ctx.drawImage(img,0,0,targetW,targetH);try{compressed=canvas.toDataURL("image/jpeg",quality)}catch{return originalDataURL}return!compressed||"data:,"===compressed||compressed.length>=originalDataURL.length?originalDataURL:compressed}const TRANSLATIONS={zh:{contentArea:{editableMarkdown:"可编辑 Markdown"},dialog:{close:"关闭"},dialogControls:{cancel:"取消",save:"保存"},createLink:{text:"链接文字",textTooltip:"链接显示的文字",title:"标题",titleTooltip:"链接的 title 属性(鼠标悬停时显示)",url:"链接地址",urlPlaceholder:"请输入链接地址",saveTooltip:"保存链接",cancelTooltip:"取消编辑"},linkPreview:{open:"在新窗口打开 {{url}}",edit:"编辑链接",copyToClipboard:"复制链接到剪贴板",copied:"已复制",remove:"移除链接"},uploadImage:{dialogTitle:"插入图片",uploadInstructions:"从本地选择图片上传",addViaUrlInstructions:"或输入图片地址",addViaUrlInstructionsNoUpload:"请输入图片地址",autoCompletePlaceholder:"搜索已有图片",alt:"替代文字",title:"标题",width:"宽度",height:"高度"},imageEditor:{editImage:"编辑图片",deleteImage:"删除图片"},table:{columnMenu:"列菜单",rowMenu:"行菜单",textAlignment:"文字对齐",alignLeft:"左对齐",alignCenter:"居中",alignRight:"右对齐",insertColumnLeft:"在左侧插入列",insertColumnRight:"在右侧插入列",insertRowAbove:"在上方插入行",insertRowBelow:"在下方插入行",deleteColumn:"删除列",deleteRow:"删除行",deleteTable:"删除表格"},codeBlock:{language:"语言",inlineLanguage:"行内语言",selectLanguage:"选择语言"},codeblock:{delete:"删除代码块"},toolbar:{undo:"撤销 {{shortcut}}",redo:"重做 {{shortcut}}",bold:"加粗",italic:"斜体",underline:"下划线",removeBold:"取消加粗",removeItalic:"取消斜体",removeUnderline:"取消下划线",inlineCode:"行内代码",removeInlineCode:"取消行内代码",bulletedList:"无序列表",numberedList:"有序列表",checkList:"任务列表",toggleGroup:"列表样式",link:"插入链接",image:"插入图片",table:"插入表格",codeBlock:"插入代码块",thematicBreak:"插入分隔线",richText:"富文本",diffMode:"对比视图",source:"源代码",blockTypeSelect:{placeholder:"块类型",selectBlockTypeTooltip:"选择块类型"},blockTypes:{paragraph:"段落",heading:"标题 {{level}}",quote:"引用"}}},"zh-TW":{contentArea:{editableMarkdown:"可編輯 Markdown"},dialog:{close:"關閉"},dialogControls:{cancel:"取消",save:"儲存"},createLink:{text:"連結文字",textTooltip:"連結顯示的文字",title:"標題",titleTooltip:"連結的 title 屬性(滑鼠懸停時顯示)",url:"連結網址",urlPlaceholder:"請輸入連結網址",saveTooltip:"儲存連結",cancelTooltip:"取消編輯"},linkPreview:{open:"在新視窗開啟 {{url}}",edit:"編輯連結",copyToClipboard:"複製連結至剪貼簿",copied:"已複製",remove:"移除連結"},uploadImage:{dialogTitle:"插入圖片",uploadInstructions:"從本地選擇圖片上傳",addViaUrlInstructions:"或輸入圖片網址",addViaUrlInstructionsNoUpload:"請輸入圖片網址",autoCompletePlaceholder:"搜尋現有圖片",alt:"替代文字",title:"標題",width:"寬度",height:"高度"},imageEditor:{editImage:"編輯圖片",deleteImage:"刪除圖片"},table:{columnMenu:"欄選單",rowMenu:"列選單",textAlignment:"文字對齊",alignLeft:"靠左",alignCenter:"置中",alignRight:"靠右",insertColumnLeft:"在左側插入欄",insertColumnRight:"在右側插入欄",insertRowAbove:"在上方插入列",insertRowBelow:"在下方插入列",deleteColumn:"刪除欄",deleteRow:"刪除列",deleteTable:"刪除表格"},codeBlock:{language:"語言",inlineLanguage:"行內語言",selectLanguage:"選擇語言"},codeblock:{delete:"刪除程式碼區塊"},toolbar:{undo:"復原 {{shortcut}}",redo:"重做 {{shortcut}}",bold:"粗體",italic:"斜體",underline:"底線",removeBold:"取消粗體",removeItalic:"取消斜體",removeUnderline:"取消底線",inlineCode:"行內程式碼",removeInlineCode:"取消行內程式碼",bulletedList:"項目符號清單",numberedList:"編號清單",checkList:"工作清單",toggleGroup:"清單樣式",link:"插入連結",image:"插入圖片",table:"插入表格",codeBlock:"插入程式碼區塊",thematicBreak:"插入分隔線",richText:"所見即所得",diffMode:"比對檢視",source:"原始碼",blockTypeSelect:{placeholder:"區塊類型",selectBlockTypeTooltip:"選擇區塊類型"},blockTypes:{paragraph:"段落",heading:"標題 {{level}}",quote:"引用"}}},ja:{toolbar:{undo:"元に戻す {{shortcut}}",redo:"やり直し {{shortcut}}",bold:"太字",italic:"イタリック",underline:"下線",removeBold:"太字を解除",removeItalic:"イタリックを解除",removeUnderline:"下線を解除",inlineCode:"インラインコード",removeInlineCode:"インラインコードを解除",bulletedList:"箇条書き",numberedList:"番号付きリスト",checkList:"チェックリスト",toggleGroup:"リストスタイル",link:"リンクを挿入",image:"画像を挿入",table:"表を挿入",codeBlock:"コードブロックを挿入",thematicBreak:"区切り線を挿入",richText:"リッチテキスト",diffMode:"差分表示",source:"ソース",blockTypeSelect:{placeholder:"ブロック種別",selectBlockTypeTooltip:"ブロック種別を選択"},blockTypes:{paragraph:"段落",heading:"見出し {{level}}",quote:"引用"}}},ko:{toolbar:{undo:"실행 취소 {{shortcut}}",redo:"다시 실행 {{shortcut}}",bold:"굵게",italic:"기울임",underline:"밑줄",removeBold:"굵게 해제",removeItalic:"기울임 해제",removeUnderline:"밑줄 해제",inlineCode:"인라인 코드",removeInlineCode:"인라인 코드 해제",bulletedList:"글머리 기호 목록",numberedList:"번호 매기기 목록",checkList:"체크리스트",toggleGroup:"목록 스타일",link:"링크 삽입",image:"이미지 삽입",table:"표 삽입",codeBlock:"코드 블록 삽입",thematicBreak:"구분선 삽입",richText:"서식있는 텍스트",diffMode:"비교 보기",source:"소스",blockTypeSelect:{placeholder:"블록 유형",selectBlockTypeTooltip:"블록 유형 선택"},blockTypes:{paragraph:"단락",heading:"제목 {{level}}",quote:"인용"}}},de:{toolbar:{undo:"Rückgängig {{shortcut}}",redo:"Wiederherstellen {{shortcut}}",bold:"Fett",italic:"Kursiv",underline:"Unterstrichen",removeBold:"Fett entfernen",removeItalic:"Kursiv entfernen",removeUnderline:"Unterstrichen entfernen",inlineCode:"Inline-Code",removeInlineCode:"Inline-Code entfernen",bulletedList:"Aufzählungsliste",numberedList:"Nummerierte Liste",checkList:"Aufgabenliste",toggleGroup:"Listenstil",link:"Link einfügen",image:"Bild einfügen",table:"Tabelle einfügen",codeBlock:"Codeblock einfügen",thematicBreak:"Trennlinie einfügen",richText:"Rich-Text",diffMode:"Diff-Ansicht",source:"Quelltext",blockTypeSelect:{placeholder:"Blocktyp",selectBlockTypeTooltip:"Blocktyp auswählen"},blockTypes:{paragraph:"Absatz",heading:"Überschrift {{level}}",quote:"Zitat"}}},es:{toolbar:{undo:"Deshacer {{shortcut}}",redo:"Rehacer {{shortcut}}",bold:"Negrita",italic:"Cursiva",underline:"Subrayado",removeBold:"Quitar negrita",removeItalic:"Quitar cursiva",removeUnderline:"Quitar subrayado",inlineCode:"Código en línea",removeInlineCode:"Quitar código en línea",bulletedList:"Lista con viñetas",numberedList:"Lista numerada",checkList:"Lista de tareas",toggleGroup:"Estilo de lista",link:"Insertar enlace",image:"Insertar imagen",table:"Insertar tabla",codeBlock:"Insertar bloque de código",thematicBreak:"Insertar separador",richText:"Texto enriquecido",diffMode:"Vista comparativa",source:"Código fuente",blockTypeSelect:{placeholder:"Tipo de bloque",selectBlockTypeTooltip:"Seleccionar tipo de bloque"},blockTypes:{paragraph:"Párrafo",heading:"Encabezado {{level}}",quote:"Cita"}}},fr:{toolbar:{undo:"Annuler {{shortcut}}",redo:"Rétablir {{shortcut}}",bold:"Gras",italic:"Italique",underline:"Souligné",removeBold:"Retirer le gras",removeItalic:"Retirer l’italique",removeUnderline:"Retirer le soulignement",inlineCode:"Code en ligne",removeInlineCode:"Retirer le code en ligne",bulletedList:"Liste à puces",numberedList:"Liste numérotée",checkList:"Liste de tâches",toggleGroup:"Style de liste",link:"Insérer un lien",image:"Insérer une image",table:"Insérer un tableau",codeBlock:"Insérer un bloc de code",thematicBreak:"Insérer un séparateur",richText:"Texte enrichi",diffMode:"Vue comparative",source:"Source",blockTypeSelect:{placeholder:"Type de bloc",selectBlockTypeTooltip:"Choisir le type de bloc"},blockTypes:{paragraph:"Paragraphe",heading:"Titre {{level}}",quote:"Citation"}}},it:{toolbar:{undo:"Annulla {{shortcut}}",redo:"Ripristina {{shortcut}}",bold:"Grassetto",italic:"Corsivo",underline:"Sottolineato",removeBold:"Rimuovi grassetto",removeItalic:"Rimuovi corsivo",removeUnderline:"Rimuovi sottolineato",inlineCode:"Codice in linea",removeInlineCode:"Rimuovi codice in linea",bulletedList:"Elenco puntato",numberedList:"Elenco numerato",checkList:"Elenco di attività",toggleGroup:"Stile elenco",link:"Inserisci link",image:"Inserisci immagine",table:"Inserisci tabella",codeBlock:"Inserisci blocco di codice",thematicBreak:"Inserisci separatore",richText:"Testo formattato",diffMode:"Vista differenze",source:"Sorgente",blockTypeSelect:{placeholder:"Tipo di blocco",selectBlockTypeTooltip:"Seleziona tipo di blocco"},blockTypes:{paragraph:"Paragrafo",heading:"Titolo {{level}}",quote:"Citazione"}}},da:{toolbar:{undo:"Fortryd {{shortcut}}",redo:"Gentag {{shortcut}}",bold:"Fed",italic:"Kursiv",underline:"Understreget",removeBold:"Fjern fed",removeItalic:"Fjern kursiv",removeUnderline:"Fjern understregning",inlineCode:"Indlejret kode",removeInlineCode:"Fjern indlejret kode",bulletedList:"Punktopstilling",numberedList:"Nummereret liste",checkList:"Tjekliste",toggleGroup:"Listestil",link:"Indsæt link",image:"Indsæt billede",table:"Indsæt tabel",codeBlock:"Indsæt kodeblok",thematicBreak:"Indsæt skillelinje",richText:"Formateret tekst",diffMode:"Diff-visning",source:"Kilde",blockTypeSelect:{placeholder:"Bloktype",selectBlockTypeTooltip:"Vælg bloktype"},blockTypes:{paragraph:"Afsnit",heading:"Overskrift {{level}}",quote:"Citat"}}},pl:{toolbar:{undo:"Cofnij {{shortcut}}",redo:"Ponów {{shortcut}}",bold:"Pogrubienie",italic:"Kursywa",underline:"Podkreślenie",removeBold:"Usuń pogrubienie",removeItalic:"Usuń kursywę",removeUnderline:"Usuń podkreślenie",inlineCode:"Kod w linii",removeInlineCode:"Usuń kod w linii",bulletedList:"Lista punktowana",numberedList:"Lista numerowana",checkList:"Lista zadań",toggleGroup:"Styl listy",link:"Wstaw link",image:"Wstaw obraz",table:"Wstaw tabelę",codeBlock:"Wstaw blok kodu",thematicBreak:"Wstaw separator",richText:"Tekst sformatowany",diffMode:"Widok porównania",source:"Źródło",blockTypeSelect:{placeholder:"Typ bloku",selectBlockTypeTooltip:"Wybierz typ bloku"},blockTypes:{paragraph:"Akapit",heading:"Nagłówek {{level}}",quote:"Cytat"}}},ru:{toolbar:{undo:"Отменить {{shortcut}}",redo:"Повторить {{shortcut}}",bold:"Полужирный",italic:"Курсив",underline:"Подчёркнутый",removeBold:"Убрать полужирный",removeItalic:"Убрать курсив",removeUnderline:"Убрать подчёркивание",inlineCode:"Встроенный код",removeInlineCode:"Убрать встроенный код",bulletedList:"Маркированный список",numberedList:"Нумерованный список",checkList:"Список задач",toggleGroup:"Стиль списка",link:"Вставить ссылку",image:"Вставить изображение",table:"Вставить таблицу",codeBlock:"Вставить блок кода",thematicBreak:"Вставить разделитель",richText:"Форматированный текст",diffMode:"Вид сравнения",source:"Исходный код",blockTypeSelect:{placeholder:"Тип блока",selectBlockTypeTooltip:"Выбрать тип блока"},blockTypes:{paragraph:"Абзац",heading:"Заголовок {{level}}",quote:"Цитата"}}},ar:{toolbar:{undo:"تراجع {{shortcut}}",redo:"إعادة {{shortcut}}",bold:"عريض",italic:"مائل",underline:"تسطير",removeBold:"إزالة العريض",removeItalic:"إزالة المائل",removeUnderline:"إزالة التسطير",inlineCode:"كود مضمن",removeInlineCode:"إزالة الكود المضمن",bulletedList:"قائمة نقطية",numberedList:"قائمة مرقمة",checkList:"قائمة مهام",toggleGroup:"نمط القائمة",link:"إدراج رابط",image:"إدراج صورة",table:"إدراج جدول",codeBlock:"إدراج كتلة كود",thematicBreak:"إدراج فاصل",richText:"نص منسق",diffMode:"عرض المقارنة",source:"المصدر",blockTypeSelect:{placeholder:"نوع الكتلة",selectBlockTypeTooltip:"اختر نوع الكتلة"},blockTypes:{paragraph:"فقرة",heading:"عنوان {{level}}",quote:"اقتباس"}}},no:{toolbar:{undo:"Angre {{shortcut}}",redo:"Gjør om {{shortcut}}",bold:"Fet",italic:"Kursiv",underline:"Understreket",removeBold:"Fjern fet",removeItalic:"Fjern kursiv",removeUnderline:"Fjern understreking",inlineCode:"Inline-kode",removeInlineCode:"Fjern inline-kode",bulletedList:"Punktliste",numberedList:"Nummerert liste",checkList:"Sjekkliste",toggleGroup:"Listestil",link:"Sett inn lenke",image:"Sett inn bilde",table:"Sett inn tabell",codeBlock:"Sett inn kodeblokk",thematicBreak:"Sett inn skillelinje",richText:"Formatert tekst",diffMode:"Diff-visning",source:"Kilde",blockTypeSelect:{placeholder:"Blokktype",selectBlockTypeTooltip:"Velg blokktype"},blockTypes:{paragraph:"Avsnitt",heading:"Overskrift {{level}}",quote:"Sitat"}}},"pt-BR":{toolbar:{undo:"Desfazer {{shortcut}}",redo:"Refazer {{shortcut}}",bold:"Negrito",italic:"Itálico",underline:"Sublinhado",removeBold:"Remover negrito",removeItalic:"Remover itálico",removeUnderline:"Remover sublinhado",inlineCode:"Código em linha",removeInlineCode:"Remover código em linha",bulletedList:"Lista com marcadores",numberedList:"Lista numerada",checkList:"Lista de tarefas",toggleGroup:"Estilo da lista",link:"Inserir link",image:"Inserir imagem",table:"Inserir tabela",codeBlock:"Inserir bloco de código",thematicBreak:"Inserir separador",richText:"Texto formatado",diffMode:"Visualização de diferenças",source:"Código-fonte",blockTypeSelect:{placeholder:"Tipo de bloco",selectBlockTypeTooltip:"Selecionar tipo de bloco"},blockTypes:{paragraph:"Parágrafo",heading:"Título {{level}}",quote:"Citação"}}},th:{toolbar:{undo:"เลิกทำ {{shortcut}}",redo:"ทำซ้ำ {{shortcut}}",bold:"ตัวหนา",italic:"ตัวเอียง",underline:"ขีดเส้นใต้",removeBold:"ยกเลิกตัวหนา",removeItalic:"ยกเลิกตัวเอียง",removeUnderline:"ยกเลิกขีดเส้นใต้",inlineCode:"โค้ดในบรรทัด",removeInlineCode:"ยกเลิกโค้ดในบรรทัด",bulletedList:"รายการแบบจุด",numberedList:"รายการตัวเลข",checkList:"รายการตรวจสอบ",toggleGroup:"รูปแบบรายการ",link:"แทรกลิงก์",image:"แทรกรูปภาพ",table:"แทรกตาราง",codeBlock:"แทรกบล็อกโค้ด",thematicBreak:"แทรกเส้นคั่น",richText:"ข้อความรูปแบบ",diffMode:"มุมมองเปรียบเทียบ",source:"ซอร์ส",blockTypeSelect:{placeholder:"ประเภทบล็อก",selectBlockTypeTooltip:"เลือกประเภทบล็อก"},blockTypes:{paragraph:"ย่อหน้า",heading:"หัวข้อ {{level}}",quote:"คำพูดอ้างอิง"}}},tr:{toolbar:{undo:"Geri al {{shortcut}}",redo:"Yinele {{shortcut}}",bold:"Kalın",italic:"İtalik",underline:"Altı çizili",removeBold:"Kalını kaldır",removeItalic:"İtaliği kaldır",removeUnderline:"Altı çiziliyi kaldır",inlineCode:"Satır içi kod",removeInlineCode:"Satır içi kodu kaldır",bulletedList:"Madde işaretli liste",numberedList:"Numaralı liste",checkList:"Kontrol listesi",toggleGroup:"Liste stili",link:"Bağlantı ekle",image:"Resim ekle",table:"Tablo ekle",codeBlock:"Kod bloğu ekle",thematicBreak:"Ayraç ekle",richText:"Zengin metin",diffMode:"Karşılaştırma görünümü",source:"Kaynak",blockTypeSelect:{placeholder:"Blok türü",selectBlockTypeTooltip:"Blok türü seç"},blockTypes:{paragraph:"Paragraf",heading:"Başlık {{level}}",quote:"Alıntı"}}},uk:{toolbar:{undo:"Скасувати {{shortcut}}",redo:"Повторити {{shortcut}}",bold:"Жирний",italic:"Курсив",underline:"Підкреслений",removeBold:"Прибрати жирний",removeItalic:"Прибрати курсив",removeUnderline:"Прибрати підкреслення",inlineCode:"Вбудований код",removeInlineCode:"Прибрати вбудований код",bulletedList:"Маркований список",numberedList:"Нумерований список",checkList:"Список завдань",toggleGroup:"Стиль списку",link:"Вставити посилання",image:"Вставити зображення",table:"Вставити таблицю",codeBlock:"Вставити блок коду",thematicBreak:"Вставити роздільник",richText:"Форматований текст",diffMode:"Перегляд порівняння",source:"Джерело",blockTypeSelect:{placeholder:"Тип блоку",selectBlockTypeTooltip:"Виберіть тип блоку"},blockTypes:{paragraph:"Абзац",heading:"Заголовок {{level}}",quote:"Цитата"}}}};function mdxTranslation(key,defaultValue,interpolations){const lang=("function"==typeof getLang?getLang():"en")||"en",langTable=TRANSLATIONS[lang]||TRANSLATIONS[lang.split("-")[0]];return function(template,values){if(!values)return template;let out=template.replace(/\{\{\s*(\w+)\s*\}\}/g,(_,k)=>k in values?String(values[k]):`{{${k}}}`);return out=out.replace(/\{(\w+)\}/g,(_,k)=>k in values?String(values[k]):`{${k}}`),out}((langTable&&function(obj,path){const parts=path.split(".");let cur=obj;for(const p of parts){if(!cur||"object"!=typeof cur||!(p in cur))return;cur=cur[p]}return"string"==typeof cur?cur:void 0}(langTable,key))??defaultValue??key,interpolations)}function getDocTheme(){return"undefined"==typeof document?"dark":"light"===document.documentElement.getAttribute("data-theme")?"light":"dark"}const CODE_BLOCK_LANGUAGES={"":"Plain text",js:"JavaScript",ts:"TypeScript",jsx:"JSX",tsx:"TSX",py:"Python",sh:"Shell",bash:"Bash",json:"JSON",yaml:"YAML",md:"Markdown",html:"HTML",css:"CSS",sql:"SQL",go:"Go",rust:"Rust",java:"Java",cpp:"C++"},MdxEditorPanel=reactExports.forwardRef(function({initialMarkdown:initialMarkdown,onChange:onChange,onError:onError,onParseError:onParseError},ref){const editorRef=reactExports.useRef(null),[theme,setTheme]=reactExports.useState(getDocTheme),lang="function"==typeof getLang?getLang():"en";reactExports.useEffect(()=>{const target=document.documentElement,obs=new MutationObserver(()=>setTheme(getDocTheme()));return obs.observe(target,{attributes:!0,attributeFilter:["data-theme"]}),()=>obs.disconnect()},[]);const imageUploadHandler=reactExports.useCallback(async file=>{try{return await compressImageToDataURL(file,{maxEdge:2e3,quality:.85})}catch(err){const msg=`${t("ui.mdEditor.uploadFailed")}: ${err.message??err}`;try{staticMethods.error(msg)}catch{}throw"function"==typeof onError&&onError(err),err}},[onError]),wrapperRef=reactExports.useRef(null);return reactExports.useImperativeHandle(ref,()=>({getMarkdown:()=>{var _a,_b;return(null==(_b=null==(_a=editorRef.current)?void 0:_a.getMarkdown)?void 0:_b.call(_a))??""},setMarkdown:md=>{var _a,_b;return null==(_b=null==(_a=editorRef.current)?void 0:_a.setMarkdown)?void 0:_b.call(_a,md??"")},focus:()=>{var _a,_b;return null==(_b=null==(_a=editorRef.current)?void 0:_a.focus)?void 0:_b.call(_a)},getScrollEl:()=>{var _a;return(null==(_a=wrapperRef.current)?void 0:_a.querySelector(".mdxeditor-root-contenteditable"))||wrapperRef.current||null}}),[]),jsxRuntimeExports.jsx("div",{ref:wrapperRef,className:`${styles.container} ${"dark"===theme?`dark-theme ${styles.dark}`:styles.light}`,children:jsxRuntimeExports.jsx(MDXEditor,{ref:editorRef,markdown:initialMarkdown??"",onChange:onChange,onError:payload=>{if("function"==typeof onParseError)try{onParseError(payload)}catch{}},translation:mdxTranslation,contentEditableClassName:styles.contentEditable,plugins:[headingsPlugin(),listsPlugin(),quotePlugin(),linkPlugin(),linkDialogPlugin(),imagePlugin({imageUploadHandler:imageUploadHandler}),tablePlugin(),codeBlockPlugin({defaultCodeBlockLanguage:""}),codeMirrorPlugin({codeBlockLanguages:CODE_BLOCK_LANGUAGES}),thematicBreakPlugin(),markdownShortcutPlugin(),diffSourcePlugin({viewMode:"rich-text",diffMarkdown:initialMarkdown??""}),toolbarPlugin({toolbarContents:()=>jsxRuntimeExports.jsxs(DiffSourceToggleWrapper,{children:[jsxRuntimeExports.jsx(UndoRedo,{}),jsxRuntimeExports.jsx(Separator,{}),jsxRuntimeExports.jsx(BoldItalicUnderlineToggles,{}),jsxRuntimeExports.jsx(CodeToggle,{}),jsxRuntimeExports.jsx(Separator,{}),jsxRuntimeExports.jsx(BlockTypeSelect,{}),jsxRuntimeExports.jsx(ListsToggle,{}),jsxRuntimeExports.jsx(Separator,{}),jsxRuntimeExports.jsx(CreateLink,{}),jsxRuntimeExports.jsx(InsertImage,{}),jsxRuntimeExports.jsx(InsertTable,{}),jsxRuntimeExports.jsx(InsertCodeBlock,{}),jsxRuntimeExports.jsx(InsertThematicBreak,{})]})})]},lang)})});export{MdxEditorPanel as default};