@zwbigi/ink-xy 0.1.11 → 0.1.13

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 (41) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/app-path-routes-manifest.json +1 -1
  3. package/.next/build-manifest.json +2 -2
  4. package/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  5. package/.next/server/app/_global-error.html +1 -1
  6. package/.next/server/app/_global-error.rsc +1 -1
  7. package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  8. package/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  9. package/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  10. package/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  11. package/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  12. package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  13. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  14. package/.next/server/app/_not-found.html +1 -1
  15. package/.next/server/app/_not-found.rsc +1 -1
  16. package/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
  17. package/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  18. package/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
  19. package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  20. package/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  21. package/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  22. package/.next/server/app/api/inkos/route.js +1 -1
  23. package/.next/server/app/index.html +1 -1
  24. package/.next/server/app/index.rsc +2 -2
  25. package/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
  26. package/.next/server/app/index.segments/_full.segment.rsc +2 -2
  27. package/.next/server/app/index.segments/_head.segment.rsc +1 -1
  28. package/.next/server/app/index.segments/_index.segment.rsc +1 -1
  29. package/.next/server/app/index.segments/_tree.segment.rsc +1 -1
  30. package/.next/server/app/page.js +15 -9
  31. package/.next/server/app/page_client-reference-manifest.js +1 -1
  32. package/.next/server/app-paths-manifest.json +1 -1
  33. package/.next/server/middleware-build-manifest.js +1 -1
  34. package/.next/server/pages/404.html +1 -1
  35. package/.next/server/pages/500.html +1 -1
  36. package/.next/static/chunks/app/{page-bb9d173e9b5c0ccd.js → page-fbf66e00e4553a09.js} +32 -26
  37. package/.next/trace +4 -4
  38. package/.next/trace-build +1 -1
  39. package/package.json +1 -1
  40. /package/.next/static/{MjlqwYgBpEuM_6Hbvv1k1 → _dVc8qn-Ll1d6faCafbmD}/_buildManifest.js +0 -0
  41. /package/.next/static/{MjlqwYgBpEuM_6Hbvv1k1 → _dVc8qn-Ll1d6faCafbmD}/_ssgManifest.js +0 -0
@@ -1,10 +1,10 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8974],{1789:(e,t,r)=>{"use strict";r.d(t,{AppShell:()=>tq});var n=r(5155),o=r(2115),i=r(3321);let l="var(--text-dim)";function s({size:e=14,open:t=!1}){return t?(0,n.jsxs)("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"none",children:[(0,n.jsx)("path",{d:"M1 4.5A1 1 0 0 1 2 3.5H5.5L7 5h7.5v1H1V4.5Z",fill:l}),(0,n.jsx)("path",{d:"M1 6h14.5L14 13H2L1 6Z",stroke:l,strokeWidth:"1",fill:l,fillOpacity:"0.12"})]}):(0,n.jsx)("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"none",children:(0,n.jsx)("path",{d:"M1 4.5A1 1 0 0 1 2 3.5H5.5L7 5H14a1 1 0 0 1 1 1v6a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V4.5Z",stroke:l,strokeWidth:"1",fill:l,fillOpacity:"0.1"})})}function a({size:e=14}){return(0,n.jsxs)("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"none",children:[(0,n.jsx)("path",{d:"M3 2h7l3 3v9H3V2Z",stroke:l,strokeWidth:"1",fill:l,fillOpacity:"0.08"}),(0,n.jsx)("path",{d:"M10 2v3h3",stroke:l,strokeWidth:"1",fill:"none",strokeLinejoin:"round"})]})}function d({label:e,size:t=14}){let r=t/14;return(0,n.jsxs)("svg",{width:t,height:t,viewBox:"0 0 14 14",fill:"none",children:[(0,n.jsx)("path",{d:"M2.5 1h6l3 3v9h-9V1Z",stroke:l,strokeWidth:"0.9",fill:l,fillOpacity:"0.07",strokeLinejoin:"round"}),(0,n.jsx)("path",{d:"M8.5 1v3h3",stroke:l,strokeWidth:"0.9",fill:"none",strokeLinejoin:"round"}),(0,n.jsx)("text",{x:"7",y:"9.5",textAnchor:"middle",fontSize:3.4*r,fontFamily:"var(--font-mono), monospace",fontWeight:"600",fill:l,letterSpacing:"0",children:e})]})}function c({size:e=14}){return(0,n.jsx)(d,{label:"TS",size:e})}function p({size:e=14}){return(0,n.jsx)(d,{label:"TSX",size:e})}function x({size:e=14}){return(0,n.jsx)(d,{label:"JS",size:e})}function u({size:e=14}){return(0,n.jsx)(d,{label:"JSX",size:e})}function g({size:e=14}){return(0,n.jsx)(d,{label:"PY",size:e})}function h({size:e=14}){return(0,n.jsx)(d,{label:"{}",size:e})}function f({size:e=14}){return(0,n.jsx)(d,{label:"CSS",size:e})}function y({size:e=14}){return(0,n.jsx)(d,{label:"SC",size:e})}function b({size:e=14}){return(0,n.jsx)(d,{label:"HTM",size:e})}function v({size:e=14}){return(0,n.jsxs)("svg",{width:e,height:e,viewBox:"0 0 14 14",fill:"none",children:[(0,n.jsx)("path",{d:"M2.5 1h6l3 3v9h-9V1Z",stroke:l,strokeWidth:"0.9",fill:l,fillOpacity:"0.07",strokeLinejoin:"round"}),(0,n.jsx)("path",{d:"M8.5 1v3h3",stroke:l,strokeWidth:"0.9",fill:"none",strokeLinejoin:"round"}),(0,n.jsx)("path",{d:"M3.5 9.5V7l1.5 1.5L6.5 7v2.5",stroke:l,strokeWidth:"0.9",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),(0,n.jsx)("path",{d:"M8 7v2.5M7 9l1 1.5 1-1.5",stroke:l,strokeWidth:"0.9",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]})}function m({size:e=14}){return(0,n.jsx)(d,{label:"YML",size:e})}function j({size:e=14}){return(0,n.jsx)(d,{label:"TOM",size:e})}function k({size:e=14}){return(0,n.jsxs)("svg",{width:e,height:e,viewBox:"0 0 14 14",fill:"none",children:[(0,n.jsx)("path",{d:"M2.5 1h6l3 3v9h-9V1Z",stroke:l,strokeWidth:"0.9",fill:l,fillOpacity:"0.07",strokeLinejoin:"round"}),(0,n.jsx)("path",{d:"M8.5 1v3h3",stroke:l,strokeWidth:"0.9",fill:"none",strokeLinejoin:"round"}),(0,n.jsx)("path",{d:"M4 7.5l2 1.5-2 1.5",stroke:l,strokeWidth:"0.95",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),(0,n.jsx)("path",{d:"M7.5 10.5h2.5",stroke:l,strokeWidth:"0.95",strokeLinecap:"round"})]})}function w({size:e=14}){return(0,n.jsx)(d,{label:"RS",size:e})}function S({size:e=14}){return(0,n.jsx)(d,{label:"GO",size:e})}function C({size:e=14}){return(0,n.jsx)(d,{label:"SQL",size:e})}function T({size:e=14}){return(0,n.jsx)(d,{label:"GQL",size:e})}function I({size:e=14}){return(0,n.jsx)(d,{label:"TF",size:e})}function z({size:e=14}){return(0,n.jsxs)("svg",{width:e,height:e,viewBox:"0 0 14 14",fill:"none",children:[(0,n.jsx)("path",{d:"M2.5 1h6l3 3v9h-9V1Z",stroke:l,strokeWidth:"0.9",fill:l,fillOpacity:"0.07",strokeLinejoin:"round"}),(0,n.jsx)("path",{d:"M8.5 1v3h3",stroke:l,strokeWidth:"0.9",fill:"none",strokeLinejoin:"round"}),(0,n.jsx)("rect",{x:"3.5",y:"6.5",width:"2",height:"1.5",rx:"0.3",stroke:l,strokeWidth:"0.8"}),(0,n.jsx)("rect",{x:"6",y:"6.5",width:"2",height:"1.5",rx:"0.3",stroke:l,strokeWidth:"0.8"}),(0,n.jsx)("rect",{x:"3.5",y:"8.5",width:"2",height:"1.5",rx:"0.3",stroke:l,strokeWidth:"0.8"})]})}function R({size:e=14}){return(0,n.jsxs)("svg",{width:e,height:e,viewBox:"0 0 14 14",fill:"none",children:[(0,n.jsx)("path",{d:"M2.5 1h6l3 3v9h-9V1Z",stroke:l,strokeWidth:"0.9",fill:l,fillOpacity:"0.07",strokeLinejoin:"round"}),(0,n.jsx)("path",{d:"M8.5 1v3h3",stroke:l,strokeWidth:"0.9",fill:"none",strokeLinejoin:"round"}),(0,n.jsx)("circle",{cx:"5.5",cy:"8.5",r:"1.5",stroke:l,strokeWidth:"0.9"}),(0,n.jsx)("path",{d:"M7 8.5h2.5M8.5 8.5v1.5",stroke:l,strokeWidth:"0.9",strokeLinecap:"round"})]})}function L({size:e=14}){return(0,n.jsxs)("svg",{width:e,height:e,viewBox:"0 0 14 14",fill:"none",children:[(0,n.jsx)("path",{d:"M2.5 1h6l3 3v9h-9V1Z",stroke:l,strokeWidth:"0.9",fill:l,fillOpacity:"0.07",strokeLinejoin:"round"}),(0,n.jsx)("path",{d:"M8.5 1v3h3",stroke:l,strokeWidth:"0.9",fill:"none",strokeLinejoin:"round"}),(0,n.jsx)("circle",{cx:"5",cy:"6.5",r:"1",stroke:l,strokeWidth:"0.85"}),(0,n.jsx)("circle",{cx:"9",cy:"6.5",r:"1",stroke:l,strokeWidth:"0.85"}),(0,n.jsx)("circle",{cx:"5",cy:"10",r:"1",stroke:l,strokeWidth:"0.85"}),(0,n.jsx)("path",{d:"M5 7.5V9",stroke:l,strokeWidth:"0.85",strokeLinecap:"round"}),(0,n.jsx)("path",{d:"M9 7.5v.5a2 2 0 0 1-2 2H6",stroke:l,strokeWidth:"0.85",strokeLinecap:"round",fill:"none"})]})}function W({size:e=14}){return(0,n.jsxs)("svg",{width:e,height:e,viewBox:"0 0 14 14",fill:"none",children:[(0,n.jsx)("path",{d:"M2.5 1h6l3 3v9h-9V1Z",stroke:l,strokeWidth:"0.9",fill:l,fillOpacity:"0.07",strokeLinejoin:"round"}),(0,n.jsx)("path",{d:"M8.5 1v3h3",stroke:l,strokeWidth:"0.9",fill:"none",strokeLinejoin:"round"}),(0,n.jsx)("rect",{x:"4.5",y:"8.5",width:"5",height:"3",rx:"0.6",stroke:l,strokeWidth:"0.9"}),(0,n.jsx)("path",{d:"M5.5 8.5V7.5a1.5 1.5 0 0 1 3 0v1",stroke:l,strokeWidth:"0.9",strokeLinecap:"round",fill:"none"})]})}function E({size:e=14}){return(0,n.jsxs)("svg",{width:e,height:e,viewBox:"0 0 14 14",fill:"none",children:[(0,n.jsx)("path",{d:"M2.5 1h6l3 3v9h-9V1Z",stroke:l,strokeWidth:"0.9",fill:l,fillOpacity:"0.07",strokeLinejoin:"round"}),(0,n.jsx)("path",{d:"M8.5 1v3h3",stroke:l,strokeWidth:"0.9",fill:"none",strokeLinejoin:"round"}),(0,n.jsx)("circle",{cx:"7",cy:"8.5",r:"1.3",stroke:l,strokeWidth:"0.9"}),(0,n.jsx)("path",{d:"M7 6.5v.7M7 10.3v.7M5 8.5h.7M8.3 8.5H9M5.5 6.9l.5.5M8.5 9.6l-.5-.5M5.5 10.1l.5-.5M8.5 7.4l-.5.5",stroke:l,strokeWidth:"0.8",strokeLinecap:"round"})]})}function M(e,t=14){let r=e.toLowerCase(),o=r.split(".").pop()??"";if("dockerfile"===r||r.startsWith("dockerfile."))return(0,n.jsx)(z,{size:t});if(".env"===r||r.startsWith(".env."))return(0,n.jsx)(R,{size:t});if(".gitignore"===r||".gitattributes"===r||".gitmodules"===r)return(0,n.jsx)(L,{size:t});if("package-lock.json"===r||"yarn.lock"===r||"bun.lock"===r||"pnpm-lock.yaml"===r||"cargo.lock"===r)return(0,n.jsx)(W,{size:t});if(r.endsWith(".config.ts")||r.endsWith(".config.js")||r.endsWith(".config.mjs")||r.endsWith(".config.cjs")||[".eslintrc",".eslintrc.js",".eslintrc.json",".eslintrc.yml","eslint.config.mjs","eslint.config.js"].includes(r))return(0,n.jsx)(E,{size:t});switch(o){case"ts":return(0,n.jsx)(c,{size:t});case"tsx":return(0,n.jsx)(p,{size:t});case"js":case"mjs":case"cjs":return(0,n.jsx)(x,{size:t});case"jsx":return(0,n.jsx)(u,{size:t});case"py":return(0,n.jsx)(g,{size:t});case"json":case"jsonl":return(0,n.jsx)(h,{size:t});case"css":case"less":return(0,n.jsx)(f,{size:t});case"scss":return(0,n.jsx)(y,{size:t});case"html":case"htm":return(0,n.jsx)(b,{size:t});case"md":case"mdx":return(0,n.jsx)(v,{size:t});case"yaml":case"yml":return(0,n.jsx)(m,{size:t});case"toml":return(0,n.jsx)(j,{size:t});case"sh":case"bash":case"zsh":case"fish":return(0,n.jsx)(k,{size:t});case"rs":return(0,n.jsx)(w,{size:t});case"go":return(0,n.jsx)(S,{size:t});case"sql":return(0,n.jsx)(C,{size:t});case"graphql":case"gql":return(0,n.jsx)(T,{size:t});case"tf":case"hcl":return(0,n.jsx)(I,{size:t});case"lock":return(0,n.jsx)(W,{size:t});default:return(0,n.jsx)(a,{size:t})}}function D(e){return/^[a-zA-Z]:[\\/]/.test(e)||e.startsWith("\\\\")?e.replace(/\\/g,"/"):e}function $(e){return D(e).split("/").filter(Boolean).map(encodeURIComponent).join("/")}function B(e){let t=D(e).replace(/\/+$/,"");return t.split("/").pop()??t}function A(e,t){if(!t)return e;let r=D(e),n=D(t).replace(/\/$/,"");return r.startsWith(n+"/")?r.slice(n.length+1):e}function F(e,t){return`${D(e).replace(/\/$/,"")}/${t}`}async function O(e){let t=$(e),r=await fetch(`/api/files/${t}?type=list`);return r.ok?((await r.json()).entries??[]).map(t=>({name:t.name,fullPath:F(e,t.name),isDir:t.isDir,size:t.size,children:t.isDir?[]:void 0,loaded:!t.isDir})):[]}function N({node:e,depth:t,cwd:r,onOpenFile:i,onAtMention:l,expandedPaths:a,onToggleExpanded:d,refreshKey:c,chapterStatusMap:p}){let x=a.has(e.fullPath),[u,g]=(0,o.useState)(e.children??[]),[h,f]=(0,o.useState)(e.loaded??!1),[y,b]=(0,o.useState)(!1),[v,m]=(0,o.useState)(!1),j=null;if(!e.isDir&&p){let t=e.name.match(/^(\d{4})_/);if(t){let e=p[parseInt(t[1],10)];if(e){let t="",r="",o="";switch(e){case"approved":t="已过审",r="#10b981",o="rgba(16,185,129,0.08)";break;case"ready-for-review":t="待审核",r="#eab308",o="rgba(234,179,8,0.08)";break;case"audit-failed":t="审计未过",r="#ef4444",o="rgba(239,68,68,0.08)";break;case"rejected":t="已驳回",r="#9ca3af",o="rgba(156,163,175,0.08)";break;default:t=e,r="var(--text-muted)",o="var(--bg-hover)"}j=(0,n.jsx)("span",{style:{fontSize:"9px",padding:"1px 5px",borderRadius:"4px",color:r,background:o,fontWeight:600,border:`1px solid ${r}25`,marginLeft:6,flexShrink:0,whiteSpace:"nowrap"},children:t})}}}let k=(0,o.useCallback)(async(t=!1)=>{if(!h||t){b(!0);try{let t=await O(e.fullPath);g(t),f(!0)}catch{}finally{b(!1)}}},[h,e.fullPath]),w=(0,o.useRef)(h);(0,o.useEffect)(()=>{w.current=h}),(0,o.useEffect)(()=>{x&&h&&k(!0)},[c]);let S=(0,o.useCallback)(()=>{if(e.isDir){let t=!x;d(e.fullPath,t),t&&!h&&k()}else i(e.fullPath,e.name)},[e.isDir,e.fullPath,e.name,h,x,k,i,d]);return(0,n.jsxs)("div",{children:[(0,n.jsxs)("div",{onClick:S,onMouseEnter:()=>m(!0),onMouseLeave:()=>m(!1),style:{position:"relative",display:"flex",alignItems:"center",gap:4,paddingLeft:8+14*t,paddingRight:8,height:24,cursor:"pointer",background:v?"var(--bg-hover)":"transparent",borderRadius:4,userSelect:"none"},children:[e.isDir&&(0,n.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"var(--text-dim)",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,transform:x?"rotate(90deg)":"none",transition:"transform 0.1s"},children:(0,n.jsx)("polyline",{points:"3 2 7 5 3 8"})}),!e.isDir&&(0,n.jsx)("span",{style:{width:10,flexShrink:0}}),(0,n.jsx)("span",{style:{flexShrink:0,display:"flex",alignItems:"center"},children:e.isDir?(0,n.jsx)(s,{size:14,open:x}):M(e.name,14)}),(0,n.jsx)("span",{style:{fontSize:12,color:"var(--text)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1},title:e.fullPath,children:e.name}),j,y&&(0,n.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-dim)",strokeWidth:"2",strokeLinecap:"round",children:(0,n.jsx)("path",{d:"M12 2v4M12 18v4M4.93 4.93l2.83 2.83M16.24 16.24l2.83 2.83M2 12h4M18 12h4"})}),l&&v&&(0,n.jsxs)("button",{onClick:t=>{t.stopPropagation(),l(A(e.fullPath,r))},title:"Insert path into chat",style:{position:"absolute",right:4,top:"50%",transform:"translateY(-50%)",display:"flex",alignItems:"center",justifyContent:"center",gap:4,padding:"0 8px",height:20,background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:4,color:"var(--accent)",cursor:"pointer",fontSize:11,fontWeight:600,whiteSpace:"nowrap"},children:[(0,n.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"4"}),(0,n.jsx)("path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8"})]}),"mention"]})]}),e.isDir&&x&&(0,n.jsxs)("div",{children:[u.map(e=>(0,n.jsx)(N,{node:e,depth:t+1,cwd:r,onOpenFile:i,onAtMention:l,expandedPaths:a,onToggleExpanded:d,refreshKey:c,chapterStatusMap:p},e.fullPath)),0===u.length&&h&&(0,n.jsx)("div",{style:{paddingLeft:8+(t+1)*14,fontSize:11,color:"var(--text-dim)",height:22,display:"flex",alignItems:"center"},children:"empty"})]})]})}function P({cwd:e,onOpenFile:t,refreshKey:r,onAtMention:i,chapterStatusMap:l}){let[s,a]=(0,o.useState)([]),[d,c]=(0,o.useState)(!0),[p,x]=(0,o.useState)(null),[u,g]=(0,o.useState)(new Set),h=(0,o.useRef)(null),f=(0,o.useCallback)((e,t)=>{g(r=>{let n=new Set(r);return t?n.add(e):n.delete(e),n})},[]);return((0,o.useEffect)(()=>{let t=h.current!==e;h.current=e,t&&g(new Set),c(t),x(null),O(e).then(e=>a(e)).catch(e=>x(String(e))).finally(()=>c(!1))},[e,r]),d)?(0,n.jsx)("div",{style:{padding:"8px 12px",fontSize:11,color:"var(--text-dim)"},children:"Loading files..."}):p?(0,n.jsx)("div",{style:{padding:"8px 12px",fontSize:11,color:"#f87171"},children:p}):(0,n.jsxs)("div",{style:{padding:"2px 4px"},children:[s.map(o=>(0,n.jsx)(N,{node:o,depth:0,cwd:e,onOpenFile:t,onAtMention:i,expandedPaths:u,onToggleExpanded:f,refreshKey:r,chapterStatusMap:l},o.fullPath)),0===s.length&&(0,n.jsx)("div",{style:{padding:"8px 12px",fontSize:11,color:"var(--text-dim)"},children:"No files found"})]})}var H=r(3143),_=r(2957);let J=[{name:"read",desc:"读取文件内容 (read_file)"},{name:"grep",desc:"搜索正则模式 (grep_search)"},{name:"find",desc:"查找文件 (find_files)"},{name:"ls",desc:"列出目录内容 (list_dir)"},{name:"edit",desc:"编辑/替换文件 (replace_file_content)"},{name:"write",desc:"新建文件 (write_to_file)"},{name:"bash",desc:"运行终端命令 (run_command)"}],U=["\uD83E\uDD16","\uD83D\uDCBB","\uD83D\uDD0D","\uD83E\uDDE0","✍️","\uD83C\uDFA8","\uD83C\uDF10","⚡","\uD83D\uDD27","\uD83D\uDCC1","\uD83D\uDCCA","\uD83D\uDE80"];function V({isOpen:e,onClose:t,gemId:r,onSave:i,modelList:l,defaultModel:s}){let[a,d]=(0,o.useState)(""),[c,p]=(0,o.useState)(""),[x,u]=(0,o.useState)("\uD83E\uDD16"),[g,h]=(0,o.useState)(""),[f,y]=(0,o.useState)(""),[b,v]=(0,o.useState)([]),[m,j]=(0,o.useState)([]),[k,w]=(0,o.useState)(""),[S,C]=(0,o.useState)(!1),[T,I]=(0,o.useState)(null);if((0,o.useEffect)(()=>{e&&(r?(C(!0),I(null),fetch("/api/gem-xy").then(e=>{if(!e.ok)throw Error("Failed to load Gem-xY list");return e.json()}).then(e=>{let t=e.find(e=>e.id===r);t&&(d(t.name),p(t.description||""),u(t.avatar||"\uD83E\uDD16"),h(t.systemPrompt),v(t.allowedTools||[]),j(t.knowledgeFiles||[]),t.provider&&t.modelId?y(`${t.provider}/${t.modelId}`):y("")),C(!1)}).catch(e=>{console.error(e),I("无法加载智能体配置"),C(!1)})):(d(""),p(""),u("\uD83E\uDD16"),h(""),v(J.map(e=>e.name)),j([]),s?y(`${s.provider}/${s.modelId}`):y(l.length>0?`${l[0].provider}/${l[0].id}`:""),I(null)))},[e,r,l]),!e)return null;let z=async e=>{if(e.preventDefault(),!a.trim())return void I("名称不能为空");if(!g.trim())return void I("核心指令不能为空");let n="",o="";if(f){let e=f.split("/");n=e[0],o=e[1]}let l={...r?{id:r}:{},name:a.trim(),description:c.trim(),avatar:x,systemPrompt:g.trim(),provider:n,modelId:o,allowedTools:b,knowledgeFiles:m};C(!0),I(null);try{let e=await fetch("/api/gem-xy",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error||"保存失败")}let r=await e.json();i(r),t()}catch(e){I(e instanceof Error?e.message:String(e))}finally{C(!1)}};return(0,n.jsx)("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:1e3,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0, 0, 0, 0.4)",backdropFilter:"blur(8px)",padding:20},children:(0,n.jsxs)("div",{style:{width:"100%",maxWidth:620,maxHeight:"85vh",background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:12,boxShadow:"0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 10px 10px -5px rgba(0, 0, 0, 0.2)",display:"flex",flexDirection:"column",overflow:"hidden"},children:[(0,n.jsxs)("div",{style:{padding:"16px 20px",borderBottom:"1px solid var(--border)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[(0,n.jsx)("h2",{style:{margin:0,fontSize:16,color:"var(--text)",fontWeight:600},children:r?"编辑 Gem-xY 智能体":"创建全新 Gem-xY 智能体"}),(0,n.jsx)("button",{onClick:t,style:{background:"none",border:"none",color:"var(--text-dim)",cursor:"pointer",padding:4,display:"flex",alignItems:"center",justifyContent:"center"},children:(0,n.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,n.jsx)("path",{d:"M18 6L6 18M6 6l12 12"})})})]}),(0,n.jsxs)("form",{onSubmit:z,style:{padding:20,overflowY:"auto",display:"flex",flexDirection:"column",gap:16,flex:1},children:[T&&(0,n.jsx)("div",{style:{padding:"8px 12px",background:"rgba(239, 68, 68, 0.15)",border:"1px solid rgba(239, 68, 68, 0.3)",color:"#f87171",borderRadius:6,fontSize:12},children:T}),S&&!r?(0,n.jsx)("div",{style:{padding:20,textAlign:"center",color:"var(--text-muted)",fontSize:12},children:"保存中..."}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[(0,n.jsx)("label",{style:{fontSize:11,color:"var(--text-muted)",fontWeight:500},children:"选择头像 (Emoji)"}),(0,n.jsxs)("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[(0,n.jsx)("div",{style:{width:44,height:44,borderRadius:8,background:"var(--bg)",border:"1px solid var(--border)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:24,flexShrink:0},children:x}),(0,n.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:U.map(e=>(0,n.jsx)("button",{type:"button",onClick:()=>u(e),style:{width:28,height:28,borderRadius:4,border:x===e?"1px solid var(--accent)":"1px solid transparent",background:x===e?"var(--bg-selected)":"transparent",cursor:"pointer",fontSize:14,display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.1s"},children:e},e))})]})]}),(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[(0,n.jsx)("label",{style:{fontSize:11,color:"var(--text-muted)",fontWeight:500},children:"智能体名称 *"}),(0,n.jsx)("input",{type:"text",required:!0,placeholder:"例如: Code Analyzer, 英语翻译官",value:a,onChange:e=>d(e.target.value),style:{padding:"8px 12px",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:6,color:"var(--text)",fontSize:12,outline:"none"}})]}),(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[(0,n.jsx)("label",{style:{fontSize:11,color:"var(--text-muted)",fontWeight:500},children:"功能描述"}),(0,n.jsx)("input",{type:"text",placeholder:"用一句话描述它的专业领域",value:c,onChange:e=>p(e.target.value),style:{padding:"8px 12px",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:6,color:"var(--text)",fontSize:12,outline:"none"}})]}),(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[(0,n.jsx)("label",{style:{fontSize:11,color:"var(--text-muted)",fontWeight:500},children:"核心指令 (System Prompt) *"}),(0,n.jsx)("textarea",{required:!0,rows:6,placeholder:"详细定义智能体的角色、口吻、回复格式以及所需遵循的准则。比如: '你是一个专业的 React 专家,使用简洁的代码逻辑进行回答。'",value:g,onChange:e=>h(e.target.value),style:{padding:"8px 12px",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:6,color:"var(--text)",fontSize:12,outline:"none",fontFamily:"inherit",resize:"vertical"}})]}),(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[(0,n.jsx)("label",{style:{fontSize:11,color:"var(--text-muted)",fontWeight:500},children:"底层模型 (可选)"}),(0,n.jsxs)("select",{value:f,onChange:e=>y(e.target.value),style:{padding:"8px 12px",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:6,color:"var(--text)",fontSize:12,outline:"none"},children:[(0,n.jsx)("option",{value:"",children:"— 沿用全局默认模型 —"}),l.map(e=>(0,n.jsxs)("option",{value:`${e.provider}/${e.id}`,children:[e.name||e.id," (",e.provider,")"]},`${e.provider}/${e.id}`))]})]}),(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[(0,n.jsx)("label",{style:{fontSize:11,color:"var(--text-muted)",fontWeight:500},children:"开启工具能力 (禁用可创建纯分析沙箱)"}),(0,n.jsx)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:8,background:"var(--bg)",padding:10,borderRadius:6,border:"1px solid var(--border)"},children:J.map(e=>(0,n.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:8,fontSize:11,color:"var(--text-muted)",cursor:"pointer"},children:[(0,n.jsx)("input",{type:"checkbox",checked:b.includes(e.name),onChange:()=>{var t;return t=e.name,void v(e=>e.includes(t)?e.filter(e=>e!==t):[...e,t])},style:{width:14,height:14,accentColor:"var(--accent)",cursor:"pointer"}}),(0,n.jsxs)("div",{children:[(0,n.jsx)("strong",{style:{color:"var(--text)"},children:e.name}),(0,n.jsx)("span",{style:{display:"block",fontSize:9,color:"var(--text-dim)"},children:e.desc})]})]},e.name))})]}),(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[(0,n.jsx)("label",{style:{fontSize:11,color:"var(--text-muted)",fontWeight:500},children:"关联知识库文件 (读取内容注入上下文)"}),m.length>0&&(0,n.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:4,maxHeight:120,overflowY:"auto",background:"var(--bg)",padding:"8px 10px",borderRadius:6,border:"1px solid var(--border)"},children:m.map((e,t)=>(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",fontSize:11,color:"var(--text-muted)",padding:"3px 0"},children:[(0,n.jsx)("span",{style:{fontFamily:"var(--font-mono)",wordBreak:"break-all",paddingRight:8},children:e}),(0,n.jsx)("button",{type:"button",onClick:()=>{j(e=>e.filter((e,r)=>r!==t))},style:{background:"none",border:"none",color:"#ef4444",cursor:"pointer",padding:"0 4px"},children:"删除"})]},t))}),(0,n.jsxs)("div",{style:{display:"flex",gap:8},children:[(0,n.jsx)("input",{type:"text",placeholder:"输入宿主机上文件的绝对路径 (如 D:/rules.md)",value:k,onChange:e=>w(e.target.value),style:{flex:1,padding:"8px 12px",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:6,color:"var(--text)",fontSize:12,outline:"none"}}),(0,n.jsx)("button",{type:"button",onClick:()=>{if(k.trim()){if(m.includes(k.trim()))return void w("");j(e=>[...e,k.trim()]),w("")}},style:{padding:"0 14px",background:"var(--bg-hover)",border:"1px solid var(--border)",borderRadius:6,color:"var(--text)",fontSize:12,cursor:"pointer"},children:"添加"})]}),(0,n.jsx)("span",{style:{fontSize:10,color:"var(--text-dim)"},children:"* 会话启动时将自动读取该路径下的文件内容并与核心指令一并注入上下文。"})]})]})]}),(0,n.jsxs)("div",{style:{padding:"12px 20px",borderTop:"1px solid var(--border)",background:"var(--bg-hover)",display:"flex",justifyContent:"flex-end",gap:10},children:[(0,n.jsx)("button",{type:"button",onClick:t,style:{padding:"6px 14px",background:"none",border:"1px solid var(--border)",borderRadius:6,color:"var(--text-muted)",fontSize:12,cursor:"pointer"},children:"取消"}),(0,n.jsx)("button",{type:"button",disabled:S,onClick:z,style:{padding:"6px 18px",background:"var(--accent)",border:"none",borderRadius:6,color:"#fff",fontSize:12,fontWeight:600,cursor:S?"not-allowed":"pointer",opacity:S?.7:1},children:S?"保存中...":"保存智能体"})]})]})})}var Y=r(1463);function K(e,t){return t&&e.startsWith(t)?"~"+e.slice(t.length):e}let q="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*";function G(){let[e,t]=(0,o.useState)(!1),[r,i]=(0,o.useState)(!1),l=(0,o.useRef)(null),s=function(e,t){let[r,n]=(0,o.useState)(e),i=(0,o.useRef)(null),l=(0,o.useRef)(0);return(0,o.useEffect)(()=>{if(!t)return void n(e);l.current=0;let r=4*e.length,o=()=>{l.current+=1;let t=Math.floor(l.current/r*e.length);n(e.split("").map((e,r)=>" "===e?" ":r<t?e:q[Math.floor(Math.random()*q.length)]).join("")),l.current<r?i.current=requestAnimationFrame(o):n(e)};return i.current=requestAnimationFrame(o),()=>{i.current&&cancelAnimationFrame(i.current)}},[e,t]),r}(e?`v${Y.env.NEXT_PUBLIC_APP_VERSION??"0.1.0"}`:"ink-xY Studio",r),a=(0,o.useCallback)(e=>{t(e),i(!0),setTimeout(()=>i(!1),(e?6:8)*4*(1e3/60)+100)},[]),d=(0,o.useCallback)(()=>{l.current&&clearTimeout(l.current);let t=!e;a(t),t&&(l.current=setTimeout(()=>a(!1),3e3))},[e,a]);return(0,o.useEffect)(()=>()=>{l.current&&clearTimeout(l.current)},[]),(0,n.jsx)("button",{onClick:d,style:{background:"none",border:"none",padding:0,cursor:"default",fontWeight:700,fontSize:15,letterSpacing:"-0.01em",color:e?"var(--accent)":"var(--text)",fontFamily:"var(--font-mono)",minWidth:"6ch"},children:s})}function Z({selectedSessionId:e,onSelectSession:t,onNewSession:r,initialSessionId:i,onInitialRestoreDone:l,refreshKey:s,onSessionDeleted:a,selectedCwd:d,onCwdChange:c,onOpenFile:p,explorerRefreshKey:x,onAtMention:u,activeGemId:g,availableStyles:h=[],activeStyleName:f=null,onStylesChange:y,onWorkspaceStatusChange:b}){let[v,m]=(0,o.useState)([]),[j,k]=(0,o.useState)(!0),[w,S]=(0,o.useState)(null),[C,T]=(0,o.useState)(null),[I,z]=(0,o.useState)(""),[R,L]=(0,o.useState)(!1),[W,E]=(0,o.useState)(!1),[M,D]=(0,o.useState)(""),B=(0,o.useRef)(null),A=(0,o.useRef)(null),[O,N]=(0,o.useState)(!0),[J,U]=(0,o.useState)(0),[Y,q]=(0,o.useState)([]),[Q,ee]=(0,o.useState)([]),[et,er]=(0,o.useState)(null),[en,eo]=(0,o.useState)(!1),[ei,el]=(0,o.useState)(null),[es,ea]=(0,o.useState)(!0),[ed,ec]=(0,o.useState)(!1),[ep,ex]=(0,o.useState)(!0),[eu,eg]=(0,o.useState)(!0),[eh,ef]=(0,o.useState)(!1),[ey,eb]=(0,o.useState)(!0),[ev,em]=(0,o.useState)(!0),[ej,ek]=(0,o.useState)(!1),[ew,eS]=(0,o.useState)(!1),[eC,eT]=(0,o.useState)(null),[eI,ez]=(0,o.useState)(!1),[eR,eL]=(0,o.useState)(!1),[eW,eE]=(0,o.useState)(null),[eM,eD]=(0,o.useState)(!1),[e$,eB]=(0,o.useState)(!1),[eA,eF]=(0,o.useState)(null),eO=(0,o.useRef)(null);(0,o.useEffect)(()=>{eO.current=eA},[eA]);let[eN,eP]=(0,o.useState)(!1),[eH,e_]=(0,o.useState)(""),[eJ,eU]=(0,o.useState)(""),[eV,eY]=(0,o.useState)(""),[eK,eq]=(0,o.useState)(!1),[eG,eZ]=(0,o.useState)([]),[eX,eQ]=(0,o.useState)(null),[e0,e1]=(0,o.useState)(null),[e2,e4]=(0,o.useState)([]),[e6,e5]=(0,o.useState)(!1),[e8,e3]=(0,o.useState)({}),[e9,e7]=(0,o.useState)(!1),[te,tt]=(0,o.useState)("epub"),[tr,tn]=(0,o.useState)(!0),[to,ti]=(0,o.useState)(!1),[tl,ts]=(0,o.useState)(null),[ta,td]=(0,o.useState)(null),[tc,tp]=(0,o.useState)([]),tx=(0,o.useRef)(null),[tu,tg]=(0,o.useState)(!1),[th,tf]=(0,o.useState)("chapters"),[ty,tb]=(0,o.useState)(""),[tv,tm]=(0,o.useState)(""),[tj,tk]=(0,o.useState)(""),[tw,tS]=(0,o.useState)(!1),[tC,tT]=(0,o.useState)(""),[tI,tz]=(0,o.useState)(!1),[tR,tL]=(0,o.useState)([]),[tW,tE]=(0,o.useState)(null),[tM,tD]=(0,o.useState)(null),[t$,tB]=(0,o.useState)([]),[tA,tF]=(0,o.useState)("active"),[tO,tN]=(0,o.useState)(""),[tP,tH]=(0,o.useState)(""),[t_,tJ]=(0,o.useState)(!1),[tU,tV]=(0,o.useState)("paste"),[tY,tK]=(0,o.useState)(""),[tq,tG]=(0,o.useState)(""),[tZ,tX]=(0,o.useState)(""),[tQ,t0]=(0,o.useState)(!1),[t1,t2]=(0,o.useState)(!1),[t4,t6]=(0,o.useState)([]),[t5,t8]=(0,o.useState)(null),[t3,t9]=(0,o.useState)(null),[t7,re]=(0,o.useState)(null),[rt,rr]=(0,o.useState)("canon"),[rn,ro]=(0,o.useState)(""),[ri,rl]=(0,o.useState)(!1),[rs,ra]=(0,o.useState)(null),[rd,rc]=(0,o.useState)(!1),[rp,rx]=(0,o.useState)(""),[ru,rg]=(0,o.useState)(!1),[rh,rf]=(0,o.useState)([]),[ry,rb]=(0,o.useState)(null),[rv,rm]=(0,o.useState)(null),rj=(0,o.useRef)(null),[rk,rw]=(0,o.useState)(!1),[rS,rC]=(0,o.useState)(!1),[rT,rI]=(0,o.useState)([]),[rz,rR]=(0,o.useState)(null),[rL,rW]=(0,o.useState)(null),rE=(0,o.useRef)(null),[rM,rD]=(0,o.useState)(!1),[r$,rB]=(0,o.useState)(!1),[rA,rF]=(0,o.useState)([]),[rO,rN]=(0,o.useState)(null),[rP,rH]=(0,o.useState)(null),[r_,rJ]=(0,o.useState)(""),[rU,rV]=(0,o.useState)(12),[rY,rK]=(0,o.useState)(1e3),[rq,rG]=(0,o.useState)(!0),[rZ,rX]=(0,o.useState)(null),[rQ,r0]=(0,o.useState)("idle"),r1=(0,o.useRef)(null);(0,o.useEffect)(()=>{rj.current&&(rj.current.scrollTop=rj.current.scrollHeight)},[rh]),(0,o.useEffect)(()=>{rE.current&&(rE.current.scrollTop=rE.current.scrollHeight)},[rT]),(0,o.useEffect)(()=>{r1.current&&(r1.current.scrollTop=r1.current.scrollHeight)},[rA]),(0,o.useEffect)(()=>{let e=localStorage.getItem("ink-show-import-draft");null!==e&&eb("true"===e);let t=localStorage.getItem("ink-show-auto-generate-short");null!==t&&em("true"===t);let r=e=>{e.detail&&("boolean"==typeof e.detail.showImportDraft&&eb(e.detail.showImportDraft),"boolean"==typeof e.detail.showAutoGenerateShort&&em(e.detail.showAutoGenerateShort))};return window.addEventListener("ink-settings-changed",r),()=>{window.removeEventListener("ink-settings-changed",r)}},[]);let[r2,r4]=(0,o.useState)(!1),[r6,r5]=(0,o.useState)(""),[r8,r3]=(0,o.useState)(!1),[r9,r7]=(0,o.useState)(!1),[ne,nt]=(0,o.useState)([]),[nr,nn]=(0,o.useState)(null),[no,ni]=(0,o.useState)(null),nl=(0,o.useRef)(null),ns=(0,o.useRef)(null),na=(0,o.useRef)(null);(0,o.useEffect)(()=>{tx.current&&(tx.current.scrollTop=tx.current.scrollHeight)},[eG]),(0,o.useEffect)(()=>{nl.current&&(nl.current.scrollTop=nl.current.scrollHeight)},[tR]),(0,o.useEffect)(()=>{ns.current&&(ns.current.scrollTop=ns.current.scrollHeight)},[t4]),(0,o.useEffect)(()=>{na.current&&(na.current.scrollTop=na.current.scrollHeight)},[ne]);let[nd,nc]=(0,o.useState)(""),[np,nx]=(0,o.useState)("xuanhuan"),[nu,ng]=(0,o.useState)("tomato"),[nh,nf]=(0,o.useState)(""),[ny,nb]=(0,o.useState)(null),[nv,nm]=(0,o.useState)(null),[nj,nk]=(0,o.useState)(!0),[nw,nS]=(0,o.useState)(!0);(0,o.useEffect)(()=>{if(!ej){nb(null),nm(null),nk(!0),nS(!0);return}let e=d||C;e&&(async()=>{try{let t=null,r=null,n=[{name:"根目录",path:e},{name:"Temp",path:`${e}/Temp`},{name:"temp",path:`${e}/temp`}].filter((e,t,r)=>r.findIndex(t=>t.path.toLowerCase().replace(/\\/g,"/")===e.path.toLowerCase().replace(/\\/g,"/"))===t),o=["novel_framework_v2.md","novel_framework.md","novel-framework.md","架构.md","构架.md"],i=["character_profiles.md","character-profiles.md","character.md","人设.md"];for(let e of n)try{let n=await fetch(`/api/files/${$(e.path)}?type=list`);if(!n.ok)continue;let l=await n.json();if(l.entries){if(!t){let r=l.entries.find(e=>!e.isDir&&o.includes(e.name.toLowerCase()));r&&(t={name:r.name,fullPath:`${e.path}/${r.name}`})}if(!r){let t=l.entries.find(e=>!e.isDir&&i.includes(e.name.toLowerCase()));t&&(r={name:t.name,fullPath:`${e.path}/${t.name}`})}}}catch(e){}nb(t),nm(r)}catch(e){console.error("Failed to scan local framework/character files:",e)}})()},[ej,d,C]);let[nC,nT]=(0,o.useState)(!1),[nI,nz]=(0,o.useState)(null),nR=(0,o.useCallback)(async(e,t)=>{if(e)try{let r=$(e),n=await fetch(`/api/files/${r}?type=list`);if(!n.ok){ex(!1),eg(!1),ef(!1),eF(null),eD(!1),e3({}),tB([]),r4(!1),r5(""),rl(!1),ra(null);return}let o=((await n.json()).entries||[]).some(e=>".inkos"===e.name||"story"===e.name||"books"===e.name);if(ex(o),o){let r=!1;try{let t=F(e,"shorts"),n=$(t),o=await fetch(`/api/files/${n}?type=list`);o.ok&&(r=((await o.json()).entries||[]).filter(e=>".gitkeep"!==e.name&&!e.name.startsWith(".")).length>0)}catch(e){console.error("Failed to check shorts folder status:",e)}ef(r);let n=F(e,"books"),o=$(n),i=await fetch(`/api/files/${o}?type=list`);if(i.ok){let r=((await i.json()).entries||[]).filter(e=>".gitkeep"!==e.name&&!e.name.startsWith(".")),n=r.length>0;eg(n);let o=r.map(e=>e.name);if(tB(o),n){let n=t||null;if(!n||!o.includes(n)){let e=eO.current;n=e&&o.includes(e)?e:r[0].name}eF(n);try{let t=F(e,`books/${n}/book.json`),r=$(t),o=await fetch(`/api/files/${r}?type=read`);if(o.ok){let e=await o.json(),t=JSON.parse(e.content);t&&t.fanficMode?(rl(!0),ra(t.fanficMode)):(rl(!1),ra(null))}else rl(!1),ra(null)}catch(e){console.error("Failed to parse book.json for fanfic mode:",e),rl(!1),ra(null)}let i=F(e,`books/${n}/chapters`),l=$(i),s=await fetch(`/api/files/${l}?type=list`),a=0;if(s.ok){let e=((await s.json()).entries||[]).filter(e=>!e.isDir&&e.name.endsWith(".md")&&/^\d{4}/.test(e.name));eD(e.length>0);let t=e.map(e=>{let t=e.name.match(/^(\d+)/);return t?parseInt(t[1],10):0}).filter(e=>e>0);a=t.length>0?Math.max(...t):0}else eD(!1);let d=!1;try{let t=F(e,`books/${n}/story/runtime/chapter-0001.plan.md`),r=$(t);(await fetch(`/api/files/${r}?type=read`)).ok&&(d=!0)}catch(e){console.error("Failed to check chapter-0001.plan.md:",e)}eB(d);try{let t="",r=F(e,`books/${n}/story/outline/volume_map.md`),o=$(r),i=await fetch(`/api/files/${o}?type=read`);if(i.ok){let e=await i.json();e&&e.content&&(t=e.content)}if(!t.trim()){let r=F(e,`books/${n}/story/volume_outline.md`),o=$(r),i=await fetch(`/api/files/${o}?type=read`);if(i.ok){let e=await i.json();e&&e.content&&(t=e.content)}}if(t.trim()){let r=(e=>{let t=[],r=e.split("\n"),n=/^(第[一二三四五六七八九十百千万零〇\d]+卷|Volume\s+\d+)/i,o=/[((]\s*(?:第|[Cc]hapters?\s+)?(\d+)\s*[-–~~—]\s*(\d+)\s*(?:章)?\s*[))]|(?:第|[Cc]hapters?\s+)(\d+)\s*[-–~~—]\s*(\d+)\s*(?:章)?/i;for(let e of r){let r=e.replace(/^#+\s*/,"").trim();if(!n.test(r))continue;let i=r.match(o);if(!i)continue;let l=parseInt(i[1]??i[3]??"0",10),s=parseInt(i[2]??i[4]??"0",10);if(l<=0||s<=0)continue;let a=r.match(/^([^\((]+)/),d=a?a[1].trim():r;t.push({name:d,startCh:l,endCh:s})}return t})(t),o="",i=F(e,`books/${n}/story/volume_summaries.md`),l=$(i),s=await fetch(`/api/files/${l}?type=read`);if(s.ok){let e=await s.json();e&&e.content&&(o=e.content)}let d=!1,c="";for(let e of r)if(a>=e.endCh&&!(o.includes(e.name)||o.includes(`Ch.${e.startCh}-${e.endCh}`)||o.includes(`vol_${e.startCh}-${e.endCh}`))){d=!0,c=`${e.name} (${e.startCh}-${e.endCh}章)`;break}r4(d),r5(c)}else r4(!1),r5("")}catch(e){console.error("Failed to check consolidation status:",e),r4(!1),r5("")}try{let t=await fetch("/api/inkos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"style-list",cwd:e,args:{bookId:n}})});if(t.ok){let e=await t.json();y&&y(e.styles||[],e.activeStyle||null)}}catch(e){console.error("Failed to load style list:",e)}let c=F(e,`books/${n}/chapters/index.json`),p=$(c),x=await fetch(`/api/files/${p}?type=read`);if(x.ok)try{let e=await x.json(),t=JSON.parse(e.content),r={};if(Array.isArray(t))for(let e of t)e&&"number"==typeof e.number&&e.status&&(r[e.number]=e.status);e3(r)}catch(e){console.error("Failed to parse chapter index.json:",e),e3({})}else e3({})}else eF(null),eD(!1),e3({}),r4(!1),r5(""),rl(!1),ra(null)}else eg(!1),eF(null),eD(!1),e3({}),tB([]),r4(!1),r5(""),rl(!1),ra(null)}else eg(!1),ef(!1),eF(null),eD(!1),e3({}),tB([]),r4(!1),r5(""),rl(!1),ra(null)}catch(e){console.error("Failed to verify workspace status:",e)}},[y]),nL=async e=>{e.preventDefault();let t=d||C;if(!t||!eA)return;ti(!0),ts(null),td(null),tp([]);let r=`${eA}_export_${Date.now()}.${te}`,n=`${t}/Temp/${r}`;try{let e=await fetch("/api/inkos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"export",cwd:t,args:{bookId:eA,format:te,approvedOnly:tr,output:n,json:!0}})});if(!e.ok)throw Error(`HTTP 异常 ${e.status}`);if(!e.body)throw Error("响应正文流为空");let r=e.body.getReader(),o=new TextDecoder,i="",l=null;for(;;){let{done:e,value:t}=await r.read();if(e)break;let n=(i+=o.decode(t,{stream:!0})).split("\n");for(let e of(i=n.pop()||"",n))if(e.trim())try{let t=JSON.parse(e);"stdout"===t.type||"stderr"===t.type?tp(e=>[...e,t.data||""]):"result"===t.type&&(l=t)}catch(e){}}if(i.trim())try{let e=JSON.parse(i);"result"===e.type&&(l=e)}catch(e){}if(!l||!l.success)throw Error(l?.error||"书稿导出执行失败,请检查配置或存量章节。");let s=null;try{s=JSON.parse(l.stdout)}catch(e){console.error("Failed to parse export stdout:",e)}if(s&&s.error)throw Error(s.error);let a=$(n),d=`/api/files/${a}?type=read`,c=document.createElement("a");c.href=d,c.download=`${eA}_export.${te}`,document.body.appendChild(c),c.click(),document.body.removeChild(c),td(`🎉 导出成功!已导出 ${s?.chaptersExported??"全部"} 章节,共 ${s?.totalWords??0} 字。`),U(e=>e+1)}catch(e){console.error(e),ts(e.message||"书稿导出失败,请重试。")}finally{ti(!1)}},nW=async()=>{let e=d||C;if(e&&eA){r3(!0),nn(null),ni(null),nt([]),r7(!0);try{let t=await fetch("/api/inkos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"consolidate",cwd:e,args:{bookId:eA,json:!0}})});if(!t.ok)throw Error(`HTTP 异常 ${t.status}`);if(!t.body)throw Error("响应正文流为空");let r=t.body.getReader(),n=new TextDecoder,o="",i=null;for(;;){let{done:e,value:t}=await r.read();if(e)break;let l=(o+=n.decode(t,{stream:!0})).split("\n");for(let e of(o=l.pop()||"",l))if(e.trim())try{let t=JSON.parse(e);"stdout"===t.type||"stderr"===t.type?nt(e=>[...e,t.data||""]):"result"===t.type&&(i=t)}catch(e){console.error("Failed to parse stream chunk:",e)}}if(o.trim())try{let e=JSON.parse(o);"result"===e.type&&(i=e)}catch(e){}if(!i||!i.success){let e="";if(i){if(i.error)e=i.error;else if(i.stdout)try{let t=JSON.parse(i.stdout);t&&t.error?e=t.error:Array.isArray(t)&&t.length>0&&t[t.length-1]?.error&&(e=t[t.length-1].error)}catch(e){}!e&&i.stderr&&(e=i.stderr.trim())}throw Error(e||"大纲摘要压缩执行失败")}let l=null;try{l=JSON.parse(i.stdout)}catch(e){console.error("Failed to parse consolidate JSON output:",e)}l?ni({archivedVolumes:l.archivedVolumes??0,retainedChapters:l.retainedChapters??0}):ni({archivedVolumes:1,retainedChapters:0}),await nR(e),U(e=>e+1)}catch(e){console.error(e),nn(e.message||String(e))}finally{r3(!1)}}},nE=async e=>{e.preventDefault();let t=d||C;if(t){tz(!0),tE(null),tD(null),tL([]);try{let e="new"===tA||0===t$.length?tO.trim():eA||void 0;if(("new"===tA||0===t$.length)&&"chapters"===th){if(!e)throw Error("新书籍 ID 不能为空");let r=tP.trim()||e;tL(t=>[...t,`[System] 正在自动创建新书籍 "${e}" (${r})...
2
- `]);let n=await fetch("/api/inkos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"book-create",cwd:t,args:{title:r,genre:"xuanhuan",platform:"tomato"}})});if(!n.ok)throw Error(`创建新书籍失败,HTTP 异常 ${n.status}`);if(!n.body)throw Error("创建新书籍响应流为空");let o=n.body.getReader(),i=new TextDecoder,l="",s=null;for(;;){let{done:e,value:t}=await o.read();if(e)break;let r=(l+=i.decode(t,{stream:!0})).split("\n");for(let e of(l=r.pop()||"",r))if(e.trim())try{let t=JSON.parse(e);"stdout"===t.type||"stderr"===t.type?tL(e=>[...e,t.data||""]):"result"===t.type&&(s=t)}catch(e){}}if(l.trim())try{let e=JSON.parse(l);"result"===e.type&&(s=e)}catch(e){}if(!s||!s.success)throw Error(s?.error||"创建新书籍失败");tL(e=>[...e,`[System] 新书籍创建完成,正在导入章节数据...
3
- `])}let r={};if("chapters"===th){if(!ty.trim())throw Error("导入源路径不能为空");r={action:"import-chapters",cwd:t,args:{bookId:e,from:ty.trim(),split:tv.trim()||void 0,resumeFrom:tj?parseInt(tj,10):void 0,series:tw,json:!0}}}else{if(!tC.trim())throw Error("请选择或输入原著/前作 Book ID");r={action:"import-canon",cwd:t,args:{bookId:eA||void 0,from:tC.trim(),json:!0}}}let n=await fetch("/api/inkos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!n.ok)throw Error(`HTTP 异常 ${n.status}`);if(!n.body)throw Error("响应正文流为空");let o=n.body.getReader(),i=new TextDecoder,l="",s=null;for(;;){let{done:e,value:t}=await o.read();if(e)break;let r=(l+=i.decode(t,{stream:!0})).split("\n");for(let e of(l=r.pop()||"",r))if(e.trim())try{let t=JSON.parse(e);"stdout"===t.type||"stderr"===t.type?tL(e=>[...e,t.data||""]):"result"===t.type&&(s=t)}catch(e){}}if(l.trim())try{let e=JSON.parse(l);"result"===e.type&&(s=e)}catch(e){}if(!s||!s.success)throw Error(s?.error||"导入执行失败,请检查路径或日志。");if("chapters"===th){let e=null;try{s.stdout&&(e=JSON.parse(s.stdout))}catch(e){}let t=e?.importedCount??"部分",r=e?.totalWords??0;tD(`🎉 成功导入章节!共处理了 ${t} 章节,约 ${r} 字。逆向工程设定提取成功!`)}else tD(`🎉 成功导入前作设定!世界观与人物正典已同步成功。`);await nR(t),U(e=>e+1),window.dispatchEvent(new CustomEvent("refresh-explorer"))}catch(e){console.error(e),tE(e.message||"导入执行失败,请重试。")}finally{tz(!1)}}},nM=async e=>{e.preventDefault();let t=d||C;if(t&&eA){t0(!0),t8(null),t9(null),t6([]),re(null);try{let e=tY.trim();if(!e)throw Error("文风名称不能为空");let r={};if("paste"===tU){if(!tq.trim())throw Error("克隆样文本内容不能为空");r={action:"style-import",cwd:t,args:{bookId:eA,content:tq.trim(),name:e,json:!0}}}else{if(!tZ.trim())throw Error("克隆样文绝对路径不能为空");r={action:"style-import",cwd:t,args:{bookId:eA,from:tZ.trim(),name:e,json:!0}}}let n=await fetch("/api/inkos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!n.ok)throw Error(`HTTP 异常 ${n.status}`);if(!n.body)throw Error("响应正文流为空");let o=n.body.getReader(),i=new TextDecoder,l="",s=null;for(;;){let{done:e,value:t}=await o.read();if(e)break;let r=(l+=i.decode(t,{stream:!0})).split("\n");for(let e of(l=r.pop()||"",r))if(e.trim())try{let t=JSON.parse(e);"stdout"===t.type||"stderr"===t.type?t6(e=>[...e,t.data||""]):"result"===t.type&&(s=t)}catch(e){}}if(l.trim())try{let e=JSON.parse(l);"result"===e.type&&(s=e)}catch(e){}if(!s||!s.success)throw Error(s?.error||"文风导入执行失败,请检查路径或日志。");t9(`🎉 成功完成文风克隆分析!统计学特征已存入 style_profile.json,大模型文风提示词已写入 style_guide.md。后续写作 AI 将会自动参照该文风书写。`);let a=F(t,`books/${eA}/story/style_guide.md`);re(a),await nR(t),U(e=>e+1),window.dispatchEvent(new CustomEvent("refresh-explorer"))}catch(e){console.error(e),t8(e.message||"文风导入执行失败,请重试。")}finally{t0(!1)}}},nD=async e=>{let t=d||C;if(t&&eA){t2(!0);try{let r=await fetch("/api/inkos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"style-switch",cwd:t,args:{bookId:eA,styleName:e}})});if(!r.ok){let e=await r.json();throw Error(e.error||`HTTP error ${r.status}`)}y&&y(h,e),U(e=>e+1)}catch(e){alert(`切换文风失败: ${e.message||e}`)}finally{t2(!1)}}};(0,o.useEffect)(()=>{b?.(ep,eu)},[ep,eu,b]),(0,o.useEffect)(()=>{let e=()=>{tJ(!0),t9(null),t8(null),t6([]),tK(""),tG(""),tX(""),re(null)},t=()=>{rw(!0),rR(null),rW(null),rI([])},r=e=>{e.detail&&e.detail.styleName&&nD(e.detail.styleName)};return window.addEventListener("trigger-style-clone",e),window.addEventListener("trigger-radar",t),window.addEventListener("trigger-style-switch",r),()=>{window.removeEventListener("trigger-style-clone",e),window.removeEventListener("trigger-radar",t),window.removeEventListener("trigger-style-switch",r)}},[nD]);let n$=async e=>{e.preventDefault();let t=d||C;if(t&&eA){if(!rp.trim())return void rb("请输入原作素材的绝对路径");rg(!0),rb(null),rm(null),rf([]);try{let e=await fetch("/api/inkos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"fanfic-refresh",cwd:t,args:{bookId:eA,from:rp.trim(),json:!0}})});if(!e.ok)throw Error(`HTTP 异常 ${e.status}`);if(!e.body)throw Error("响应正文流为空");let r=e.body.getReader(),n=new TextDecoder,o="",i=null;for(;;){let{done:e,value:t}=await r.read();if(e)break;let l=(o+=n.decode(t,{stream:!0})).split("\n");for(let e of(o=l.pop()||"",l))if(e.trim())try{let t=JSON.parse(e);"stdout"===t.type||"stderr"===t.type?rf(e=>[...e,t.data||""]):"result"===t.type&&(i=t)}catch(e){}}if(o.trim())try{let e=JSON.parse(o);"result"===e.type&&(i=e)}catch(e){}if(!i||!i.success)throw Error(i?.error||"刷新原作设定执行失败");rm("同人原作正典设定已刷新!"),U(e=>e+1),window.dispatchEvent(new CustomEvent("refresh-explorer"))}catch(e){console.error(e),rb(e.message||String(e))}finally{rg(!1)}}},nB=async()=>{let e=d||C;if(e&&eA){eP(!0),e_("正在为您规划首章蓝图,请稍候..."),eU(""),eY(""),eZ([]),eQ(null);try{let t=await fetch("/api/inkos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"plan",cwd:e,args:{bookId:eA,json:!0}})});if(!t.ok)throw Error(`HTTP 异常 ${t.status}`);if(!t.body)throw Error("响应正文流为空");let r=t.body.getReader(),n=new TextDecoder,o="",i=null;for(;;){let{done:e,value:t}=await r.read();if(e)break;let l=(o+=n.decode(t,{stream:!0})).split("\n");for(let e of(o=l.pop()||"",l))if(e.trim())try{let t=JSON.parse(e);if("stdout"===t.type||"stderr"===t.type){let e=t.data||"";eZ(t=>[...t,e])}else"result"===t.type&&(i=t)}catch(e){console.error("Failed to parse stream chunk:",e)}}if(o.trim())try{let e=JSON.parse(o);"result"===e.type&&(i=e)}catch{}if(!i||!i.success)throw Error(i?.error||"首章蓝图规划失败");eU("首章蓝图规划完成"),eY("已成功规划首章大纲与大纲意图栈!\n已在 books/"+eA+"/story/runtime/ 目录下生成了 chapter-0001.plan.md。接下来,您可以点击“智能写作”按钮以起草正文。"),eq(!0),window.dispatchEvent(new CustomEvent("refresh-explorer")),await nR(e)}catch(e){console.error(e),eQ(e instanceof Error?e.message:String(e))}finally{eP(!1)}}},nA=async()=>{let e=d||C;if(e&&eA){eP(!0),e_("正在为您规划大纲并起草首章正文,请稍候..."),eU(""),eY(""),eZ([]);try{let t=await fetch("/api/inkos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"write-next",cwd:e,args:{bookId:eA,json:!0}})});if(!t.ok)throw Error(`HTTP 异常 ${t.status}`);if(!t.body)throw Error("响应正文流为空");let r=t.body.getReader(),n=new TextDecoder,o="",i=null;for(;;){let{done:e,value:t}=await r.read();if(e)break;let l=(o+=n.decode(t,{stream:!0})).split("\n");for(let e of(o=l.pop()||"",l))if(e.trim())try{let t=JSON.parse(e);if("stdout"===t.type||"stderr"===t.type){let e=t.data||"";eZ(t=>[...t,e]),e.includes("planning chapter")||e.includes("规划本章")?e_("正在规划本章意图与章节规划栈..."):e.includes("起草")||e.includes("drafting")?e_("正在协同起草首章正文,请稍候..."):(e.includes("audit")||e.includes("审计"))&&e_("正在执行离线审稿与一致性审计...")}else"result"===t.type&&(i=t)}catch(e){console.error("Failed to parse stream chunk:",e)}}if(o.trim())try{let e=JSON.parse(o);"result"===e.type&&(i=e)}catch(e){}if(!i||!i.success){let e="";if(i){if(i.error)e=i.error;else if(i.stdout)try{let t=JSON.parse(i.stdout);t&&t.error?e=t.error:Array.isArray(t)&&t.length>0&&t[t.length-1]?.error&&(e=t[t.length-1].error)}catch(e){}!e&&i.stderr&&(e=i.stderr.trim())}throw Error(e||"首章创作执行失败")}let l=[];try{l=JSON.parse(i.stdout)}catch(t){console.error("Failed to parse write-next JSON output:",t),eY(i.stdout||"首章起草成功!"),eU("首章起草完成"),eq(!0),window.dispatchEvent(new CustomEvent("refresh-explorer")),await nR(e);return}let s=l[0];if(!s)throw Error("未返回有效的创作章节结果。");let a=String(s.chapterNumber).padStart(4,"0"),d=`${e}/books/${eA}/chapters`,c=await fetch(`/api/files/${$(d)}?type=list`),p=await c.json(),x=p.entries?.find(e=>!e.isDir&&e.name.startsWith(a));if(x){let e=d+"/"+x.name;window.dispatchEvent(new CustomEvent("open-file",{detail:{filePath:e,fileName:x.name}}))}let u=s.auditResult?.passed??!1,g=s.auditResult?.issues??[],h=[`### 🎉 智能写作首章完成!`,"",`- **章节**: 第 ${s.chapterNumber} 章 《${s.title}》`,`- **字数**: ${s.wordCount} 字`,`- **自动修正**: ${s.revised?"已执行(已修复关键问题)":"无(无需修正)"}`,`- **状态结算**: \`${s.status}\``,"",`#### 🔍 离线审稿审计结果`,u?"✅ **审计通过**:无逻辑矛盾或角色人设崩塌问题。":"⚠️ **审计未完全通过**:检测到一些逻辑或人设风险,建议审阅:","",g.length>0?g.map(e=>{let t=String(e.severity||"info").toLowerCase(),r="critical"===t||"error"===t?"\uD83D\uDD34 [critical]":"warning"===t?"\uD83D\uDFE1 [warning]":"info"===t?"\uD83D\uDD35 [info]":`⚪ [${e.severity}]`;return`- ${r} **${e.category}**: ${e.description}
4
- *建议: ${e.suggestion}*`}).join("\n"):"*(无关键警告或错误)*"].join("\n");eU("首章创作与审计报告"),eY(h),eq(!0),window.dispatchEvent(new CustomEvent("refresh-explorer")),await nR(e),eP(!1)}catch(e){console.error(e),e.message.includes("超时")||e.message.includes("timed out")||eG.some(e=>e.includes("超时"))?eQ("任务运行超时(已超过 1800 秒)。建议在右上角「模型配置」中,更换速度较快且稳定的标准模型(例如将 reasoning/思索模型切换为标准对话模型),并检查您的 API Key 与接口代理连接状态。"):eQ(e.message||String(e))}}},nF=async e=>{if(e.preventDefault(),!nd.trim())return void eT("书籍名称不能为空");let t=d||C;if(t){eS(!0),eT(null);try{let e="fanfic"===np;if(e&&!rn.trim())throw Error("同人小说原作素材磁盘路径不能为空");let r=await fetch("/api/inkos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:e?"fanfic-init":"book-create",cwd:t,args:e?{title:nd.trim(),from:rn.trim(),mode:rt,genre:"fanfic",platform:nu,json:!0}:{title:nd.trim(),genre:np,platform:nu,brief:nh.trim()||void 0,selectedFrameworkPath:ny&&nj?ny.fullPath:void 0,selectedCharacterPath:nv&&nw?nv.fullPath:void 0}})});if(!r.ok)throw Error(`HTTP 异常 ${r.status}`);if(!r.body)throw Error("响应正文流为空");let n=r.body.getReader(),o=new TextDecoder,i="",l=null;for(;;){let{done:e,value:t}=await n.read();if(e)break;let r=(i+=o.decode(t,{stream:!0})).split("\n");for(let e of(i=r.pop()||"",r))if(e.trim())try{let t=JSON.parse(e);"result"===t.type&&(l=t)}catch(e){}}if(i.trim())try{let e=JSON.parse(i);"result"===e.type&&(l=e)}catch(e){}if(!l||!l.success)throw Error(l?.error||"创建书籍失败,大模型生成异常,请检查配置和 Key");await nR(t),U(e=>e+1),nc(""),nf(""),ro(""),ek(!1)}catch(e){console.error(e),eT(e.message||"创建书籍失败,请确认侧边栏左下角 Models 中 API Key 填写正确且模型支持当前题材生成。")}finally{eS(!1)}}},nO=async()=>{let e=d||C;if(e&&eA){eL(!0),eE(null);try{let t=await fetch("/api/inkos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"book-delete",cwd:e,args:{bookId:eA,json:!0}})});if(!t.ok)throw Error(`HTTP 异常 ${t.status}`);if(!t.body)throw Error("响应正文流为空");let r=t.body.getReader(),n=new TextDecoder,o="",i=null;for(;;){let{done:e,value:t}=await r.read();if(e)break;let l=(o+=n.decode(t,{stream:!0})).split("\n");for(let e of(o=l.pop()||"",l))if(e.trim())try{let t=JSON.parse(e);"result"===t.type&&(i=t)}catch(e){}}if(o.trim())try{let e=JSON.parse(o);"result"===e.type&&(i=e)}catch(e){}if(!i||!i.success)throw Error(i?.error||"删除书籍失败");window.dispatchEvent(new CustomEvent("close-directory",{detail:{dirPath:`${e}/books/${eA}`}})),await nR(e),U(e=>e+1),ez(!1)}catch(e){console.error(e),eE(e.message||"删除书籍失败")}finally{eL(!1)}}},nN=async e=>{e.preventDefault();let t=d||C;if(t){rC(!0),rR(null),rW(null),rI([]);try{let e=await fetch("/api/inkos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"radar-scan",cwd:t,args:{json:!0}})});if(!e.ok)throw Error(`HTTP 异常 ${e.status}`);if(!e.body)throw Error("响应流为空");let r=e.body.getReader(),n=new TextDecoder,o="",i=null;for(;;){let{done:e,value:t}=await r.read();if(e)break;let l=(o+=n.decode(t,{stream:!0})).split("\n");for(let e of(o=l.pop()||"",l))if(e.trim())try{let t=JSON.parse(e);"stdout"===t.type||"stderr"===t.type?rI(e=>[...e,t.data||""]):"result"===t.type&&(i=t)}catch(e){console.error("Failed to parse stream chunk:",e)}}if(o.trim())try{let e=JSON.parse(o);"result"===e.type&&(i=e)}catch{}if(!i||!i.success)throw Error(i?.error||"扫描市场情报失败");let l=null;try{l=JSON.parse(i.stdout||"")}catch(e){console.error("Failed to parse radar scan result JSON:",e)}if(l)rW(l);else throw Error("检测引擎未返回有效的 JSON 结构")}catch(e){console.error(e),rR(e instanceof Error?e.message:String(e))}finally{rC(!1)}}},nP=async e=>{if(!r_.trim())return void rN("创作方向不能为空");let t=d||C;if(t){rB(!0),rN(null),rH(null),rF([]);try{let r=await fetch("/api/inkos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"short-run",cwd:t,args:{direction:r_.trim(),chapters:rU,chars:rY,noCover:!rq,json:!0,stage:e,storyId:rZ||void 0}})});if(!r.ok)throw Error(`HTTP 异常 ${r.status}`);if(!r.body)throw Error("响应流为空");let n=r.body.getReader(),o=new TextDecoder,i="",l=null;for(;;){let{done:e,value:t}=await n.read();if(e)break;let r=(i+=o.decode(t,{stream:!0})).split("\n");for(let e of(i=r.pop()||"",r))if(e.trim())try{let t=JSON.parse(e);"stdout"===t.type||"stderr"===t.type?rF(e=>[...e,t.data||""]):"result"===t.type&&(l=t)}catch(e){console.error("Failed to parse stream chunk:",e)}}if(i.trim())try{let e=JSON.parse(i);"result"===e.type&&(l=e)}catch{}if(!l||!l.success)throw Error(l?.error||`${"outline"===e?"大纲规划":"draft"===e?"正文写作":"封面与包装"} 阶段任务执行失败`);let s=null;try{s=JSON.parse(l.stdout||"")}catch(e){console.error("Failed to parse short fiction result JSON:",e)}s&&s.storyId?(rX(s.storyId),"outline"===e?(rH(`【第一步:生成大纲】执行完成!故事 ID 为: ${s.storyId}
5
- 大纲与大纲评审文件已输出至 shorts/${s.storyId}/outline/v002.md,请查阅无误后点击下方【第二步】开始起草章节。`),r0("draft")):"draft"===e?(rH(`【第二步:批量起草】执行完成!故事 ID 为: ${s.storyId}
6
- 所有章节的初稿已经全部起草完毕,文件输出在 shorts/${s.storyId}/final/full.md。点击下方【第三步】即可一键打包与制作封面。`),r0("package")):"package"===e&&(rH(`【第三步:生成书封包装】执行完成!
7
- 故事销售包装和封面图文件已成功生成。至此,该短篇小说已全部创作完毕!`),r0("completed"))):rH("全自动短篇生成运行完成!已将成果输出至 shorts/ 目录下,请检查文件浏览器。"),window.dispatchEvent(new CustomEvent("refresh-explorer")),await nR(t)}catch(e){console.error(e),rN(e instanceof Error?e.message:String(e))}finally{rB(!1)}}},nH=async()=>{let e=d||C;if(e){nT(!0),nz(null);try{let t=await fetch("/api/inkos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"init",cwd:e})});if(!t.ok)throw Error(`HTTP 异常 ${t.status}`);if(!t.body)throw Error("响应正文流为空");let r=t.body.getReader(),n=new TextDecoder,o="",i=null;for(;;){let{done:e,value:t}=await r.read();if(e)break;let l=(o+=n.decode(t,{stream:!0})).split("\n");for(let e of(o=l.pop()||"",l))if(e.trim())try{let t=JSON.parse(e);"result"===t.type&&(i=t)}catch(e){}}if(o.trim())try{let e=JSON.parse(o);"result"===e.type&&(i=e)}catch(e){}if(!i||!i.success)throw Error(i?.error||"Failed to initialize workspace");await nR(e),U(e=>e+1)}catch(e){console.error(e),nz(e.message||"初始化失败")}finally{nT(!1)}}};(0,o.useEffect)(()=>{let e=d||C;e?fetch("/api/register-cwd",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e})}).then(e=>{if(!e.ok)throw Error("Failed to register CWD");return e.json()}).then(()=>{e1(e),nR(e)}).catch(t=>{console.error("CWD registration failed:",t),e1(e),nR(e)}):(e1(null),ex(!0))},[d,C,nR,J]);let n_=(0,o.useCallback)(async()=>{try{let e=await fetch("/api/gem-xy");if(!e.ok)throw Error("Failed to load Gem-xY profiles");let t=await e.json();q(t)}catch(e){console.error(e)}},[]);(0,o.useEffect)(()=>{n_()},[n_]),(0,o.useEffect)(()=>{fetch("/api/models").then(e=>e.json()).then(e=>{e.modelList&&ee(e.modelList),e.defaultModel&&er(e.defaultModel)}).catch(()=>{})},[]);let nJ=(0,o.useCallback)(e=>{if(!C)return;let t="function"==typeof crypto.randomUUID?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}-${Math.random().toString(36).slice(2)}`;r?.(t,C,e)},[C,r]),nU=async(e,t)=>{if(e.stopPropagation(),confirm("确定要删除这个智能体吗?"))try{if(!(await fetch(`/api/gem-xy/${t}`,{method:"DELETE"})).ok)throw Error("Delete failed");n_()}catch(e){console.error(e),alert("删除失败")}},[nV,nY]=(0,o.useState)(!1),[nK,nq]=(0,o.useState)(!1),nG=(0,o.useRef)(null),nZ=(0,o.useRef)(null),nX=(0,o.useCallback)(async(e=!1)=>{try{e&&k(!0);let t=await fetch("/api/sessions");if(!t.ok)throw Error(`HTTP ${t.status}`);let r=await t.json();m(r.sessions),S(null),e||(nY(!0),nG.current&&clearTimeout(nG.current),nG.current=setTimeout(()=>nY(!1),2e3))}catch(e){S(String(e))}finally{e&&k(!1)}},[]),nQ=(0,o.useRef)(!1);(0,o.useEffect)(()=>{let e=!nQ.current;nQ.current=!0,nX(e)},[nX,s]),(0,o.useEffect)(()=>{void 0!==x&&U(e=>e+1)},[x]),(0,o.useEffect)(()=>{fetch("/api/home").then(e=>e.json()).then(e=>{e.home&&z(e.home)}).catch(()=>{})},[]);let n0=(0,o.useRef)(!1);(0,o.useEffect)(()=>{c?.(C)},[C,c]),(0,o.useEffect)(()=>{if(C)try{let e=localStorage.getItem("ink-xy-recent-cwds"),t=[];e&&(t=JSON.parse(e)),Array.isArray(t)||(t=[]);let r=[C,...t.filter(e=>e!==C)].slice(0,10);localStorage.setItem("ink-xy-recent-cwds",JSON.stringify(r))}catch(e){console.error("Failed to save recent CWD to localStorage:",e)}},[C]),(0,o.useEffect)(()=>{let e=function(e){let t=new Map;for(let r of e){if(!r.cwd)continue;let e=t.get(r.cwd);(!e||r.modified>e)&&t.set(r.cwd,r.modified)}return[...t.entries()].sort((e,t)=>t[1].localeCompare(e[1])).slice(0,5).map(([e])=>e)}(v),t=[];try{let e=localStorage.getItem("ink-xy-recent-cwds");e&&(t=JSON.parse(e))}catch(e){}Array.isArray(t)||(t=[]);let r=[];try{let e=localStorage.getItem("ink-xy-deleted-cwds");e&&(r=JSON.parse(e))}catch(e){}Array.isArray(r)||(r=[]);let n=[...new Set([...e,...t])].filter(e=>!r.includes(e));if(0===n.length){e4([]),e5(!0);return}(async()=>{try{await fetch("/api/register-cwd",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwds:n})})}catch(e){console.error("Failed to register combined CWDs:",e)}e4((await Promise.all(n.map(async e=>{try{let t=await fetch(`/api/files/${$(e)}?type=list&check=true`);if(t.ok){let r=await t.json();return{cwd:e,exists:!1!==r.exists}}}catch(e){}return{cwd:e,exists:!1}}))).filter(e=>e.exists).map(e=>e.cwd)),e5(!0)})()},[v,C,J]),(0,o.useEffect)(()=>{if(0!==v.length&&null===C){if(i&&!n0.current){n0.current=!0;let e=v.find(e=>e.id===i);if(e){T(e.cwd),t(e,!0);return}l?.()}e6&&(e2.length>0?T(e2[0]):fetch("/api/default-cwd",{method:"POST"}).then(e=>e.json()).then(e=>{e.cwd&&T(e.cwd)}).catch(()=>{}))}},[v,C,i,t,l,e2,e6]);let n1=(0,o.useCallback)(()=>{let e=M.trim();if(e){T(e);try{let t=localStorage.getItem("ink-xy-deleted-cwds");if(t){let r=JSON.parse(t);Array.isArray(r)&&r.includes(e)&&(r=r.filter(t=>t!==e),localStorage.setItem("ink-xy-deleted-cwds",JSON.stringify(r)))}}catch(e){console.error("Failed to remove re-added path from deleted list:",e)}}E(!1),D(""),L(!1)},[M]),n2=(0,o.useCallback)(async()=>{try{let e=await fetch("/api/default-cwd",{method:"POST"}),t=await e.json();t.cwd&&(T(t.cwd),L(!1))}catch{}},[]),n4=(0,o.useCallback)(e=>{try{let t=localStorage.getItem("ink-xy-deleted-cwds"),r=[];t&&(r=JSON.parse(t)),Array.isArray(r)||(r=[]),r.includes(e)||(r.push(e),localStorage.setItem("ink-xy-deleted-cwds",JSON.stringify(r)))}catch(e){console.error("Failed to update deleted CWDs list:",e)}try{let t=localStorage.getItem("ink-xy-recent-cwds");if(t){let r=JSON.parse(t);if(Array.isArray(r)){let t=r.filter(t=>t!==e);localStorage.setItem("ink-xy-recent-cwds",JSON.stringify(t))}}}catch(e){console.error("Failed to remove CWD from localStorage:",e)}if(e4(t=>t.filter(t=>t!==e)),(d||C)===e){let t=e2.filter(t=>t!==e);t.length>0?T(t[0]):n2()}},[e2,d,C,n2]);(0,o.useEffect)(()=>{let e=e=>{A.current&&!A.current.contains(e.target)&&(L(!1),E(!1),D(""))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);let n6=(0,o.useCallback)(()=>{if(!C)return;let e="function"==typeof crypto.randomUUID?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}-${Math.random().toString(36).slice(2)}`;r?.(e,C)},[C,r]),n5=C?v.filter(e=>e.cwd===C):v,n8=function(e){let t=new Map;for(let r of e)t.set(r.id,{session:r,children:[]});let r=new Map;for(let t of e)t.parentSessionId&&r.set(t.id,t.parentSessionId);let n=[];for(let e of t.values()){let o=function(e){let n=r.get(e),o=new Set;for(;n&&!o.has(n);){if(o.add(n),t.has(n))return n;n=r.get(n)}return null}(e.session.id);o?t.get(o).children.push(e):n.push(e)}let o=e=>{e.sort((e,t)=>{let r=+!!e.session.locked,n=+!!t.session.locked;return r!==n?n-r:t.session.modified.localeCompare(e.session.modified)}),e.forEach(e=>o(e.children))};return o(n),n}(n5);return(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"},children:[(0,n.jsxs)("div",{style:{padding:"12px 10px 10px",borderBottom:"1px solid var(--border)",flexShrink:0},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:10},children:[(0,n.jsx)(G,{}),(0,n.jsxs)("div",{style:{display:"flex",gap:6},children:[(0,n.jsxs)("button",{onClick:n6,disabled:!C,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:5,background:"var(--bg-hover)",border:"1px solid var(--border)",color:C?"var(--text-muted)":"var(--text-dim)",cursor:C?"pointer":"not-allowed",height:32,paddingLeft:10,paddingRight:12,borderRadius:7,fontSize:12,fontWeight:500,letterSpacing:"-0.01em",flexShrink:0,transition:"background 0.12s, color 0.12s, border-color 0.12s"},title:C?"在新协同会话中写作":"请先选择创作工作区",onMouseEnter:e=>{C&&(e.currentTarget.style.background="var(--bg-selected)",e.currentTarget.style.color="var(--accent)",e.currentTarget.style.borderColor="rgba(37,99,235,0.35)")},onMouseLeave:e=>{e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color=C?"var(--text-muted)":"var(--text-dim)",e.currentTarget.style.borderColor="var(--border)"},children:[(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",children:[(0,n.jsx)("line",{x1:"6",y1:"1",x2:"6",y2:"11"}),(0,n.jsx)("line",{x1:"1",y1:"6",x2:"11",y2:"6"})]}),"新会话"]}),(0,n.jsx)("button",{onClick:()=>nX(!1),style:{display:"flex",alignItems:"center",justifyContent:"center",background:nV?"rgba(74,222,128,0.18)":"var(--bg-hover)",border:`1px solid ${nV?"rgba(74,222,128,0.4)":"var(--border)"}`,color:nV?"#4ade80":"var(--text-muted)",cursor:"pointer",width:32,height:32,borderRadius:7,padding:0,flexShrink:0,transition:"background 0.3s, color 0.3s, border-color 0.3s"},onMouseEnter:e=>{nV||(e.currentTarget.style.background="var(--bg-selected)",e.currentTarget.style.color="var(--accent)",e.currentTarget.style.borderColor="rgba(37,99,235,0.35)")},onMouseLeave:e=>{nV||(e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color="var(--text-muted)",e.currentTarget.style.borderColor="var(--border)")},title:"刷新会话",children:nV?(0,n.jsx)("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"#4ade80",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("polyline",{points:"20 6 9 17 4 12"})}):(0,n.jsxs)("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}),(0,n.jsx)("path",{d:"M3 3v5h5"})]})})]})]}),(0,n.jsxs)("div",{ref:A,style:{position:"relative"},children:[(0,n.jsx)("button",{onClick:()=>L(e=>!e),style:{width:"100%",display:"flex",alignItems:"center",padding:"6px 10px",background:C?"var(--bg-hover)":"rgba(37,99,235,0.06)",border:C?"1px solid var(--border)":"1px solid rgba(37,99,235,0.4)",borderRadius:7,cursor:"pointer",fontSize:12,color:"var(--text)",textAlign:"left",transition:"border-color 0.15s, background 0.15s"},children:(0,n.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontFamily:"var(--font-mono)",fontSize:11,color:C?"var(--text)":"var(--text-dim)"},title:C??"",children:C?K(C,I):i&&!n0.current?"":"选择创作目录…"})}),R&&(0,n.jsxs)("div",{style:{position:"absolute",top:"calc(100% + 4px)",left:0,right:0,zIndex:100,background:"var(--bg)",border:"1px solid var(--border)",borderRadius:8,boxShadow:"0 6px 20px rgba(0,0,0,0.10)",overflow:"hidden"},children:[e2.map(e=>(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%",background:e===C?"var(--bg-selected)":"none",borderBottom:"1px solid var(--border)",transition:"background 0.2s"},onMouseEnter:t=>{e!==C&&(t.currentTarget.style.background="var(--bg-panel)")},onMouseLeave:t=>{e!==C&&(t.currentTarget.style.background="none")},children:[(0,n.jsxs)("button",{onClick:()=>{T(e),E(!1),D(""),L(!1)},style:{display:"flex",alignItems:"center",gap:7,flex:1,padding:"8px 10px",background:"none",border:"none",color:e===C?"var(--text)":"var(--text-muted)",cursor:"pointer",textAlign:"left",fontSize:11,fontFamily:"var(--font-mono)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:e,children:[e===C&&(0,n.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"var(--accent)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:(0,n.jsx)("polyline",{points:"1.5 5 4 7.5 8.5 2.5"})}),e!==C&&(0,n.jsx)("span",{style:{width:10,flexShrink:0}}),(0,n.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:K(e,I)})]}),(0,n.jsx)("button",{onClick:t=>{t.stopPropagation(),n4(e)},title:"从列表中移除该路径",style:{display:"flex",alignItems:"center",justifyContent:"center",width:20,height:20,marginRight:6,background:"none",border:"none",color:"var(--text-dim)",cursor:"pointer",borderRadius:4,transition:"color 0.2s, background 0.2s"},onMouseEnter:e=>{e.currentTarget.style.color="#ef4444",e.currentTarget.style.background="rgba(239, 68, 68, 0.08)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-dim)",e.currentTarget.style.background="none"},children:(0,n.jsxs)("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,n.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},e)),!W&&(0,n.jsxs)("button",{onClick:e=>{e.stopPropagation(),n2()},style:{display:"flex",alignItems:"center",gap:7,width:"100%",padding:"8px 10px",background:"none",border:"none",borderTop:e2.length>0?"1px solid var(--border)":"none",color:"var(--text-muted)",cursor:"pointer",textAlign:"left",fontSize:11},children:[(0,n.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.1",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:(0,n.jsx)("path",{d:"M1 3A1 1 0 0 1 2 2H4L5 3.5H8.5a.5.5 0 0 1 .5.5v4a.5.5 0 0 1-.5.5h-7A.5.5 0 0 1 1 8V3Z"})}),(0,n.jsx)("span",{children:"使用默认创作目录"})]}),W?(0,n.jsxs)("div",{style:{padding:"6px 8px",borderTop:e2.length>0?"none":void 0},children:[(0,n.jsx)("input",{ref:B,value:M,onChange:e=>D(e.target.value),onKeyDown:e=>{"Enter"===e.key&&n1(),"Escape"===e.key&&(E(!1),D(""))},placeholder:"/path/to/project",style:{width:"100%",fontSize:11,fontFamily:"var(--font-mono)",padding:"5px 8px",border:"1px solid var(--accent)",borderRadius:5,outline:"none",background:"var(--bg)",color:"var(--text)",boxSizing:"border-box"}}),(0,n.jsxs)("div",{style:{display:"flex",gap:5,marginTop:5},children:[(0,n.jsx)("button",{onClick:n1,style:{flex:1,padding:"4px 0",background:"var(--accent)",border:"none",borderRadius:5,color:"#fff",fontSize:11,fontWeight:600,cursor:"pointer"},children:"打开"}),(0,n.jsx)("button",{onClick:()=>{E(!1),D("")},style:{flex:1,padding:"4px 0",background:"var(--bg-hover)",border:"1px solid var(--border)",borderRadius:5,color:"var(--text-muted)",fontSize:11,cursor:"pointer"},children:"取消"})]})]}):(0,n.jsxs)("button",{onClick:e=>{e.stopPropagation(),E(!0),setTimeout(()=>B.current?.focus(),0)},style:{display:"flex",alignItems:"center",gap:7,width:"100%",padding:"8px 10px",background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",textAlign:"left",fontSize:11},children:[(0,n.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.1",strokeLinecap:"round",style:{flexShrink:0},children:[(0,n.jsx)("line",{x1:"5",y1:"1",x2:"5",y2:"9"}),(0,n.jsx)("line",{x1:"1",y1:"5",x2:"9",y2:"5"})]}),(0,n.jsx)("span",{children:"自定义路径…"})]})]})]})]}),(d||C)&&(0,n.jsxs)("div",{style:{borderBottom:"1px solid var(--border)",display:"flex",flexDirection:"column",flex:O?"1 1 0":"0 0 auto",minHeight:0,overflow:"hidden"},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",flexShrink:0},children:[(0,n.jsxs)("button",{onClick:()=>N(e=>!e),style:{display:"flex",alignItems:"center",gap:6,flex:1,padding:"8px 10px",background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",fontSize:11,fontWeight:600,letterSpacing:"0.05em",textTransform:"uppercase",textAlign:"left"},children:[(0,n.jsx)("svg",{width:"9",height:"9",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",style:{transform:O?"rotate(90deg)":"none",transition:"transform 0.15s",flexShrink:0},children:(0,n.jsx)("polyline",{points:"3 2 7 5 3 8"})}),"创作目录 (Workspace)"]}),ep&&(0,n.jsxs)("div",{style:{display:"flex",gap:2},children:[eu&&(0,n.jsx)("button",{onClick:()=>{e7(!0),td(null),ts(null),tp([])},title:"导出小说书稿 (Export Book)",style:{display:"flex",alignItems:"center",justifyContent:"center",width:26,height:26,padding:0,background:"none",border:"none",color:"var(--text-dim)",cursor:"pointer",borderRadius:5,flexShrink:0,transition:"color 0.3s, background 0.3s"},onMouseEnter:e=>{e.currentTarget.style.color="var(--text-muted)",e.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-dim)",e.currentTarget.style.background="none"},children:(0,n.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),(0,n.jsx)("polyline",{points:"17 8 12 3 7 8"}),(0,n.jsx)("line",{x1:"12",y1:"3",x2:"12",y2:"15"})]})}),ri&&(0,n.jsx)("button",{onClick:()=>{rc(!0),rm(null),rb(null),rf([]),rx("")},title:"刷新同人原作背景设定 (Refresh Fanfic Canon)",style:{display:"flex",alignItems:"center",justifyContent:"center",width:26,height:26,padding:0,background:"none",border:"none",color:"var(--text-dim)",cursor:"pointer",borderRadius:5,flexShrink:0,transition:"color 0.3s, background 0.3s"},onMouseEnter:e=>{e.currentTarget.style.color="var(--text-muted)",e.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-dim)",e.currentTarget.style.background="none"},children:(0,n.jsx)("span",{style:{fontSize:13},children:"\uD83C\uDFAC"})}),(0,n.jsx)("button",{onClick:()=>{tg(!0),tD(null),tE(null),tL([]),tb(""),tm(""),tk(""),tS(!1),tF(t$.length>0?"active":"new"),tN(""),tH(""),tT(t$.find(e=>e!==eA)||"")},title:"导入设定或旧章原稿 (Import Canon/Chapters)",style:{display:"flex",alignItems:"center",justifyContent:"center",width:26,height:26,padding:0,marginRight:6,background:"none",border:"none",color:"var(--text-dim)",cursor:"pointer",borderRadius:5,flexShrink:0,transition:"color 0.3s, background 0.3s"},onMouseEnter:e=>{e.currentTarget.style.color="var(--text-muted)",e.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-dim)",e.currentTarget.style.background="none"},children:(0,n.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),(0,n.jsx)("polyline",{points:"7 10 12 15 17 10"}),(0,n.jsx)("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]})})]}),(0,n.jsx)("button",{onClick:()=>{U(e=>e+1),nq(!0),nZ.current&&clearTimeout(nZ.current),nZ.current=setTimeout(()=>nq(!1),2e3)},title:"刷新创作目录",style:{display:"flex",alignItems:"center",justifyContent:"center",width:26,height:26,padding:0,marginRight:6,background:nK?"rgba(74,222,128,0.18)":"none",border:"none",color:nK?"#4ade80":"var(--text-dim)",cursor:"pointer",borderRadius:5,flexShrink:0,transition:"color 0.3s, background 0.3s"},onMouseEnter:e=>{nK||(e.currentTarget.style.color="var(--text-muted)",e.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:e=>{nK||(e.currentTarget.style.color="var(--text-dim)",e.currentTarget.style.background="none")},children:nK?(0,n.jsx)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"#4ade80",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("polyline",{points:"20 6 9 17 4 12"})}):(0,n.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}),(0,n.jsx)("path",{d:"M3 3v5h5"})]})})]}),O&&(0,n.jsxs)("div",{style:{flex:1,overflowY:"auto",overflowX:"hidden",display:"flex",flexDirection:"column"},children:[!ep&&(0,n.jsxs)("div",{style:{margin:"8px 10px",padding:"12px",background:"var(--bg-panel)",border:"1px dashed var(--accent)",borderRadius:"8px",fontSize:"11px",fontFamily:"var(--font-serif)"},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,fontWeight:600,color:"var(--text)",marginBottom:6},children:[(0,n.jsx)("span",{style:{fontSize:13},children:"✒️"}),(0,n.jsx)("span",{children:"未初始化的创作空间"})]}),(0,n.jsx)("div",{style:{color:"var(--text-muted)",lineHeight:1.5,marginBottom:8},children:"该目录尚未创建 InkOS 小说项目结构。一键初始化以启用自动章节规划、人设审计与快照防崩系统。"}),nI&&(0,n.jsxs)("div",{style:{color:"#ef4444",marginBottom:8,fontSize:10},children:["⚠️ ",nI]}),(0,n.jsx)("button",{onClick:nH,disabled:nC,style:{width:"100%",padding:"6px 0",background:"var(--accent)",border:"none",borderRadius:"6px",color:"white",fontWeight:600,cursor:nC?"not-allowed":"pointer",opacity:nC?.7:1,textAlign:"center",transition:"opacity 0.15s"},children:nC?"正在开启小说宇宙...":"一键开启创作宇宙"})]}),ep&&!eu&&!eh&&(0,n.jsxs)("div",{style:{margin:"8px 10px",padding:"12px",background:"var(--bg-panel)",border:"1px dashed var(--accent)",borderRadius:"8px",fontSize:"11px",fontFamily:"var(--font-serif)"},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,fontWeight:600,color:"var(--text)",marginBottom:6},children:[(0,n.jsx)("span",{style:{fontSize:13},children:"\uD83D\uDCDA"}),(0,n.jsx)("span",{children:"小说宇宙内尚无书籍"})]}),(0,n.jsx)("div",{style:{color:"var(--text-muted)",lineHeight:1.5,marginBottom:8},children:"在 InkOS 中,设定与大纲是以“书籍”为单位存储的。立即创建您的第一本书,AI 架构师将为您搭建创作地基。"}),(0,n.jsxs)("div",{style:{display:"flex",gap:8,marginTop:4},children:[(0,n.jsx)("button",{onClick:()=>ek(!0),style:{flex:1,padding:"6px 0",background:"var(--accent)",border:"none",borderRadius:"6px",color:"white",fontWeight:600,cursor:"pointer",textAlign:"center",fontSize:"11px",transition:"opacity 0.15s"},children:"✍️ 创建小说书籍"}),ey&&(0,n.jsx)("button",{onClick:()=>{tg(!0),tD(null),tE(null),tL([]),tb(""),tm(""),tk(""),tS(!1),tF("new"),tN(""),tH(""),tT(t$.find(e=>e!==eA)||"")},style:{flex:1,padding:"6px 0",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:"6px",color:"var(--text)",fontWeight:600,cursor:"pointer",textAlign:"center",fontSize:"11px",transition:"opacity 0.15s"},children:"\uD83D\uDCE5 导入已有旧稿"})]}),ev&&(0,n.jsx)("button",{onClick:()=>{rD(!0),rN(null),rH(null),rF([]),rJ(""),rV(12),rK(1e3),rG(!0)},style:{width:"100%",marginTop:8,padding:"6px 0",background:"rgba(139, 92, 246, 0.08)",border:"1px solid rgba(139, 92, 246, 0.3)",borderRadius:"6px",color:"#a78bfa",fontWeight:600,cursor:"pointer",textAlign:"center",fontSize:"11px",transition:"all 0.15s"},onMouseEnter:e=>{e.currentTarget.style.background="rgba(139, 92, 246, 0.16)",e.currentTarget.style.borderColor="rgba(139, 92, 246, 0.5)",e.currentTarget.style.color="#c084fc"},onMouseLeave:e=>{e.currentTarget.style.background="rgba(139, 92, 246, 0.08)",e.currentTarget.style.borderColor="rgba(139, 92, 246, 0.3)",e.currentTarget.style.color="#a78bfa"},children:"\uD83D\uDE80 一键全自动生成短篇"})]}),ep&&eu&&!eM&&(0,n.jsxs)("div",{style:{margin:"8px 10px",padding:"12px",background:"var(--bg-panel)",border:"1px dashed var(--accent)",borderRadius:"8px",fontSize:"11px",fontFamily:"var(--font-serif)"},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,fontWeight:600,color:"var(--text)",marginBottom:6},children:[(0,n.jsx)("span",{style:{fontSize:13},children:"✍️"}),(0,n.jsx)("span",{children:"书籍已创建,准备开始首章创作"})]}),(0,n.jsx)("div",{style:{color:"var(--text-muted)",lineHeight:1.5,marginBottom:8},children:e$?"第一章蓝图已规划完成!点击下方按钮,由 AI 协同起草第一章正文,拉开故事序幕。":"您的创作宇宙和人设基础已准备就绪!开始写作前,请先点击下方按钮规划首章蓝图,确立开篇方向。"}),(0,n.jsxs)("div",{style:{display:"flex",gap:8,marginTop:4},children:[e$?(0,n.jsx)("button",{onClick:nA,disabled:eN,style:{flex:1,padding:"6px 0",background:"var(--accent)",border:"none",borderRadius:"6px",color:"white",fontWeight:600,cursor:eN?"not-allowed":"pointer",textAlign:"center",fontSize:"11px",transition:"opacity 0.15s"},children:"✍️ 智能写作"}):(0,n.jsx)("button",{onClick:nB,disabled:eN,style:{flex:1,padding:"6px 0",background:"var(--accent)",border:"none",borderRadius:"6px",color:"white",fontWeight:600,cursor:eN?"not-allowed":"pointer",textAlign:"center",fontSize:"11px",transition:"opacity 0.15s"},children:"\uD83D\uDDFA️ 规划首章蓝图"}),ey&&(0,n.jsx)("button",{onClick:()=>{tg(!0),tD(null),tE(null),tL([]),tb(""),tm(""),tk(""),tS(!1),tT(t$.find(e=>e!==eA)||"")},disabled:eN,style:{flex:1,padding:"6px 0",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:"6px",color:"var(--text)",fontWeight:600,cursor:eN?"not-allowed":"pointer",textAlign:"center",fontSize:"11px",transition:"opacity 0.15s"},children:"\uD83D\uDCE5 导入已有旧稿"})]}),ev&&(0,n.jsx)("button",{onClick:()=>{rD(!0),rN(null),rH(null),rF([]),rJ(""),rV(12),rK(1e3),rG(!0)},style:{width:"calc(100% - 20px)",margin:"8px 10px 0 10px",padding:"6px 0",background:"rgba(139, 92, 246, 0.08)",border:"1px solid rgba(139, 92, 246, 0.3)",borderRadius:"6px",color:"#a78bfa",fontWeight:600,cursor:"pointer",textAlign:"center",fontSize:"11px",transition:"all 0.15s"},onMouseEnter:e=>{e.currentTarget.style.background="rgba(139, 92, 246, 0.16)",e.currentTarget.style.borderColor="rgba(139, 92, 246, 0.5)",e.currentTarget.style.color="#c084fc"},onMouseLeave:e=>{e.currentTarget.style.background="rgba(139, 92, 246, 0.08)",e.currentTarget.style.borderColor="rgba(139, 92, 246, 0.3)",e.currentTarget.style.color="#a78bfa"},children:"\uD83D\uDE80 一键全自动生成短篇"})]}),e0===(d??C)&&(0,n.jsxs)("div",{style:{flex:1,display:"flex",flexDirection:"column",minHeight:0,overflow:"hidden"},children:[(0,n.jsxs)("div",{style:{margin:"8px 10px",padding:"8px 10px",background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:"8px",display:"flex",alignItems:"center",gap:"8px",fontSize:"12px",fontFamily:"var(--font-serif)",flexShrink:0},children:[(0,n.jsx)("span",{style:{fontSize:13,flexShrink:0},children:"\uD83D\uDCD6"}),(0,n.jsx)("span",{style:{color:"var(--text-muted)",flexShrink:0},children:"当前书籍:"}),(0,n.jsx)("select",{value:eA||"",onChange:e=>{let t=e.target.value;eF(t);let r=d||C;r&&nR(r,t)},style:{flex:1,background:"var(--bg)",border:"1px solid var(--border)",borderRadius:"5px",padding:"3px 6px",fontSize:"12px",fontFamily:"var(--font-serif)",color:"var(--text)",outline:"none",cursor:"pointer",minWidth:0},children:t$.map(e=>(0,n.jsx)("option",{value:e,children:e},e))}),(0,n.jsx)("button",{onClick:()=>{eE(null),ez(!0)},title:"删除当前书籍 (Delete Book)",style:{display:"flex",alignItems:"center",justifyContent:"center",width:24,height:24,padding:0,background:"none",border:"none",color:"var(--text-dim)",cursor:"pointer",borderRadius:4,transition:"color 0.2s, background-color 0.2s"},onMouseEnter:e=>{e.currentTarget.style.color="#ef4444",e.currentTarget.style.background="rgba(239, 68, 68, 0.08)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-dim)",e.currentTarget.style.background="none"},children:(0,n.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("polyline",{points:"3 6 5 6 21 6"}),(0,n.jsx)("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}),(0,n.jsx)("line",{x1:"10",y1:"11",x2:"10",y2:"17"}),(0,n.jsx)("line",{x1:"14",y1:"11",x2:"14",y2:"17"})]})})]}),r2&&(0,n.jsxs)("div",{style:{margin:"8px 10px",padding:"10px 12px",background:"rgba(249, 115, 22, 0.04)",border:"1px solid rgba(249, 115, 22, 0.25)",borderRadius:"8px",fontSize:"11px",fontFamily:"var(--font-serif)",boxShadow:"0 2px 8px rgba(249, 115, 22, 0.05)",flexShrink:0},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,fontWeight:600,color:"#e07a34",marginBottom:4},children:[(0,n.jsx)("span",{style:{fontSize:13},children:"\uD83D\uDDDC️"}),(0,n.jsx)("span",{children:"建议进行大纲摘要压缩"})]}),(0,n.jsxs)("div",{style:{color:"var(--text-muted)",lineHeight:1.5,marginBottom:8},children:["检测到完结卷 ",(0,n.jsx)("strong",{children:r6}),",建议运行压缩归档以优化大语言模型上下文,防止远期伏笔记忆衰退。"]}),(0,n.jsx)("button",{onClick:nW,disabled:r8,style:{width:"100%",padding:"5px 0",background:"rgba(249, 115, 22, 0.08)",border:"1px solid rgba(249, 115, 22, 0.35)",borderRadius:"6px",color:"#ff903f",fontWeight:600,cursor:r8?"not-allowed":"pointer",textAlign:"center",fontSize:"11px",transition:"all 0.2s"},onMouseEnter:e=>{r8||(e.currentTarget.style.background="rgba(249, 115, 22, 0.16)",e.currentTarget.style.borderColor="#f97316",e.currentTarget.style.color="#ffaa64")},onMouseLeave:e=>{r8||(e.currentTarget.style.background="rgba(249, 115, 22, 0.08)",e.currentTarget.style.borderColor="rgba(249, 115, 22, 0.35)",e.currentTarget.style.color="#ff903f")},children:r8?"正在压缩...":"\uD83D\uDDDC️ 一键压缩归档"})]}),ri&&(0,n.jsxs)("div",{style:{margin:"0 10px 8px 10px",padding:"8px 12px",background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:"8px",fontSize:"11px",display:"flex",alignItems:"center",justifyContent:"space-between",flexShrink:0,boxShadow:"0 1px 3px rgba(0,0,0,0.02)"},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,color:"var(--text-muted)"},children:[(0,n.jsx)("span",{style:{fontSize:13},children:"\uD83C\uDFAC"}),(0,n.jsx)("span",{children:"同人创作模式:"}),(0,n.jsx)("strong",{style:{color:"var(--accent)",fontWeight:600},children:"canon"===rs?"正典延续":"au"===rs?"平行宇宙":"ooc"===rs?"角色偏离":"cp"===rs?"角色配对":rs||"未知"})]}),(0,n.jsx)("button",{onClick:()=>{rc(!0),rm(null),rb(null),rf([]),rx("")},style:{padding:"2px 6px",background:"var(--bg)",color:"var(--text)",border:"1px solid var(--border)",borderRadius:"4px",fontSize:"10px",outline:"none",cursor:"pointer",fontWeight:500,transition:"all 0.15s"},onMouseEnter:e=>{e.currentTarget.style.borderColor="var(--accent)"},onMouseLeave:e=>{e.currentTarget.style.borderColor="var(--border)"},children:"\uD83D\uDD04 刷新设定"})]}),(0,n.jsx)("div",{style:{flex:1,overflowY:"auto"},children:(0,n.jsx)(P,{cwd:d??C,onOpenFile:p??(()=>{}),refreshKey:J,onAtMention:u,chapterStatusMap:e8})})]})]})]}),(d||C)&&(0,n.jsxs)("div",{style:{flexShrink:0,paddingBottom:6},children:[(0,n.jsxs)("div",{onClick:()=>ea(!es),style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 10px 4px",color:"var(--text-muted)",cursor:"pointer",fontSize:11,fontWeight:600,letterSpacing:"0.05em",textTransform:"uppercase"},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[(0,n.jsx)("svg",{width:"9",height:"9",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",style:{transform:es?"rotate(90deg)":"none",transition:"transform 0.15s",flexShrink:0},children:(0,n.jsx)("polyline",{points:"3 2 7 5 3 8"})}),(0,n.jsx)("span",{children:"AI 写作伴侣 (Co-writers)"})]}),(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),el(null),eo(!0)},title:"配置专属写作姬",style:{background:"none",border:"none",color:"var(--text-dim)",cursor:"pointer",padding:"2px 6px",borderRadius:4,fontSize:10,display:"flex",alignItems:"center",gap:2},onMouseEnter:e=>{e.currentTarget.style.color="var(--accent)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-dim)"},children:"+ Create"})]}),es&&(0,n.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:2,padding:"0 6px",maxHeight:240,overflowY:"auto"},children:0===Y.length?(0,n.jsx)("div",{style:{padding:"6px 10px",color:"var(--text-dim)",fontSize:11,fontStyle:"italic"},children:"暂无写作姬,点击 Create 配置"}):Y.map(t=>{let r=g===t.id&&!e,o=t.id.startsWith("default-");return(0,n.jsxs)("div",{onClick:()=>nJ(t.id),title:t.description||void 0,style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"6px 8px",borderRadius:6,background:r?"var(--bg-selected)":"transparent",cursor:"pointer",fontSize:12,transition:"all 0.12s"},className:"gem-sidebar-item",onMouseEnter:e=>{r||(e.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:e=>{r||(e.currentTarget.style.background="transparent")},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,minWidth:0},children:[(0,n.jsx)("span",{style:{fontSize:14,flexShrink:0},children:t.avatar||"\uD83D\uDD2E"}),(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",minWidth:0},children:[(0,n.jsx)("span",{style:{color:r?"var(--accent)":"var(--text)",fontWeight:r?600:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.name}),t.description&&(0,n.jsx)("span",{style:{fontSize:10,color:"var(--text-dim)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.description})]})]}),!o&&(0,n.jsxs)("div",{className:"gem-actions",style:{display:"flex",gap:4,flexShrink:0,opacity:0,transition:"opacity 0.15s"},children:[(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),el(t.id),eo(!0)},title:"编辑",style:{background:"none",border:"none",color:"var(--text-dim)",cursor:"pointer",padding:2},onMouseEnter:e=>{e.currentTarget.style.color="var(--text)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-dim)"},children:"✎"}),(0,n.jsx)("button",{onClick:e=>nU(e,t.id),title:"删除",style:{background:"none",border:"none",color:"var(--text-dim)",cursor:"pointer",padding:2},onMouseEnter:e=>{e.currentTarget.style.color="#ef4444"},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-dim)"},children:"\uD83D\uDDD1"})]})]},t.id)})})]}),(d||C)&&(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",flexShrink:0,borderTop:"1px solid var(--border)",height:ed?"auto":"35px",boxSizing:"border-box",justifyContent:ed?"flex-start":"center"},children:[(0,n.jsx)("div",{onClick:()=>ec(!ed),style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:ed?"8px 10px 4px":"0 10px",color:"var(--text-muted)",cursor:"pointer",fontSize:11,fontWeight:600,letterSpacing:"0.05em",textTransform:"uppercase"},children:(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[(0,n.jsx)("svg",{width:"9",height:"9",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",style:{transform:ed?"rotate(90deg)":"none",transition:"transform 0.15s",flexShrink:0},children:(0,n.jsx)("polyline",{points:"3 2 7 5 3 8"})}),(0,n.jsx)("span",{children:"AI 协同历史 (AI Chats)"})]})}),ed&&(0,n.jsxs)("div",{style:{maxHeight:160,overflowY:"auto",padding:"0"},children:[j&&(0,n.jsx)("div",{style:{padding:"12px 14px",color:"var(--text-muted)",fontSize:11},children:"Loading..."}),w&&(0,n.jsx)("div",{style:{padding:"12px 14px",color:"#f87171",fontSize:11},children:w}),!j&&!w&&0===n5.length&&(0,n.jsx)("div",{style:{padding:"12px 14px",color:"var(--text-muted)",fontSize:11},children:"无历史协同会话"}),n8.map(r=>(0,n.jsx)(X,{node:r,selectedSessionId:e,onSelectSession:t,onRenamed:nX,onSessionDeleted:e=>{a?.(e),nX()},depth:0},r.session.id))]})]}),(0,n.jsx)("style",{children:`
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8974],{3705:(e,t,r)=>{Promise.resolve().then(r.bind(r,9659))},9659:(e,t,r)=>{"use strict";r.d(t,{AppShell:()=>tq});var n=r(5155),o=r(2115),i=r(3321);let l="var(--text-dim)";function s({size:e=14,open:t=!1}){return t?(0,n.jsxs)("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"none",children:[(0,n.jsx)("path",{d:"M1 4.5A1 1 0 0 1 2 3.5H5.5L7 5h7.5v1H1V4.5Z",fill:l}),(0,n.jsx)("path",{d:"M1 6h14.5L14 13H2L1 6Z",stroke:l,strokeWidth:"1",fill:l,fillOpacity:"0.12"})]}):(0,n.jsx)("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"none",children:(0,n.jsx)("path",{d:"M1 4.5A1 1 0 0 1 2 3.5H5.5L7 5H14a1 1 0 0 1 1 1v6a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V4.5Z",stroke:l,strokeWidth:"1",fill:l,fillOpacity:"0.1"})})}function a({size:e=14}){return(0,n.jsxs)("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"none",children:[(0,n.jsx)("path",{d:"M3 2h7l3 3v9H3V2Z",stroke:l,strokeWidth:"1",fill:l,fillOpacity:"0.08"}),(0,n.jsx)("path",{d:"M10 2v3h3",stroke:l,strokeWidth:"1",fill:"none",strokeLinejoin:"round"})]})}function d({label:e,size:t=14}){let r=t/14;return(0,n.jsxs)("svg",{width:t,height:t,viewBox:"0 0 14 14",fill:"none",children:[(0,n.jsx)("path",{d:"M2.5 1h6l3 3v9h-9V1Z",stroke:l,strokeWidth:"0.9",fill:l,fillOpacity:"0.07",strokeLinejoin:"round"}),(0,n.jsx)("path",{d:"M8.5 1v3h3",stroke:l,strokeWidth:"0.9",fill:"none",strokeLinejoin:"round"}),(0,n.jsx)("text",{x:"7",y:"9.5",textAnchor:"middle",fontSize:3.4*r,fontFamily:"var(--font-mono), monospace",fontWeight:"600",fill:l,letterSpacing:"0",children:e})]})}function c({size:e=14}){return(0,n.jsx)(d,{label:"TS",size:e})}function p({size:e=14}){return(0,n.jsx)(d,{label:"TSX",size:e})}function x({size:e=14}){return(0,n.jsx)(d,{label:"JS",size:e})}function u({size:e=14}){return(0,n.jsx)(d,{label:"JSX",size:e})}function g({size:e=14}){return(0,n.jsx)(d,{label:"PY",size:e})}function h({size:e=14}){return(0,n.jsx)(d,{label:"{}",size:e})}function f({size:e=14}){return(0,n.jsx)(d,{label:"CSS",size:e})}function b({size:e=14}){return(0,n.jsx)(d,{label:"SC",size:e})}function y({size:e=14}){return(0,n.jsx)(d,{label:"HTM",size:e})}function v({size:e=14}){return(0,n.jsxs)("svg",{width:e,height:e,viewBox:"0 0 14 14",fill:"none",children:[(0,n.jsx)("path",{d:"M2.5 1h6l3 3v9h-9V1Z",stroke:l,strokeWidth:"0.9",fill:l,fillOpacity:"0.07",strokeLinejoin:"round"}),(0,n.jsx)("path",{d:"M8.5 1v3h3",stroke:l,strokeWidth:"0.9",fill:"none",strokeLinejoin:"round"}),(0,n.jsx)("path",{d:"M3.5 9.5V7l1.5 1.5L6.5 7v2.5",stroke:l,strokeWidth:"0.9",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),(0,n.jsx)("path",{d:"M8 7v2.5M7 9l1 1.5 1-1.5",stroke:l,strokeWidth:"0.9",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]})}function m({size:e=14}){return(0,n.jsx)(d,{label:"YML",size:e})}function j({size:e=14}){return(0,n.jsx)(d,{label:"TOM",size:e})}function k({size:e=14}){return(0,n.jsxs)("svg",{width:e,height:e,viewBox:"0 0 14 14",fill:"none",children:[(0,n.jsx)("path",{d:"M2.5 1h6l3 3v9h-9V1Z",stroke:l,strokeWidth:"0.9",fill:l,fillOpacity:"0.07",strokeLinejoin:"round"}),(0,n.jsx)("path",{d:"M8.5 1v3h3",stroke:l,strokeWidth:"0.9",fill:"none",strokeLinejoin:"round"}),(0,n.jsx)("path",{d:"M4 7.5l2 1.5-2 1.5",stroke:l,strokeWidth:"0.95",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),(0,n.jsx)("path",{d:"M7.5 10.5h2.5",stroke:l,strokeWidth:"0.95",strokeLinecap:"round"})]})}function w({size:e=14}){return(0,n.jsx)(d,{label:"RS",size:e})}function S({size:e=14}){return(0,n.jsx)(d,{label:"GO",size:e})}function C({size:e=14}){return(0,n.jsx)(d,{label:"SQL",size:e})}function T({size:e=14}){return(0,n.jsx)(d,{label:"GQL",size:e})}function z({size:e=14}){return(0,n.jsx)(d,{label:"TF",size:e})}function I({size:e=14}){return(0,n.jsxs)("svg",{width:e,height:e,viewBox:"0 0 14 14",fill:"none",children:[(0,n.jsx)("path",{d:"M2.5 1h6l3 3v9h-9V1Z",stroke:l,strokeWidth:"0.9",fill:l,fillOpacity:"0.07",strokeLinejoin:"round"}),(0,n.jsx)("path",{d:"M8.5 1v3h3",stroke:l,strokeWidth:"0.9",fill:"none",strokeLinejoin:"round"}),(0,n.jsx)("rect",{x:"3.5",y:"6.5",width:"2",height:"1.5",rx:"0.3",stroke:l,strokeWidth:"0.8"}),(0,n.jsx)("rect",{x:"6",y:"6.5",width:"2",height:"1.5",rx:"0.3",stroke:l,strokeWidth:"0.8"}),(0,n.jsx)("rect",{x:"3.5",y:"8.5",width:"2",height:"1.5",rx:"0.3",stroke:l,strokeWidth:"0.8"})]})}function R({size:e=14}){return(0,n.jsxs)("svg",{width:e,height:e,viewBox:"0 0 14 14",fill:"none",children:[(0,n.jsx)("path",{d:"M2.5 1h6l3 3v9h-9V1Z",stroke:l,strokeWidth:"0.9",fill:l,fillOpacity:"0.07",strokeLinejoin:"round"}),(0,n.jsx)("path",{d:"M8.5 1v3h3",stroke:l,strokeWidth:"0.9",fill:"none",strokeLinejoin:"round"}),(0,n.jsx)("circle",{cx:"5.5",cy:"8.5",r:"1.5",stroke:l,strokeWidth:"0.9"}),(0,n.jsx)("path",{d:"M7 8.5h2.5M8.5 8.5v1.5",stroke:l,strokeWidth:"0.9",strokeLinecap:"round"})]})}function L({size:e=14}){return(0,n.jsxs)("svg",{width:e,height:e,viewBox:"0 0 14 14",fill:"none",children:[(0,n.jsx)("path",{d:"M2.5 1h6l3 3v9h-9V1Z",stroke:l,strokeWidth:"0.9",fill:l,fillOpacity:"0.07",strokeLinejoin:"round"}),(0,n.jsx)("path",{d:"M8.5 1v3h3",stroke:l,strokeWidth:"0.9",fill:"none",strokeLinejoin:"round"}),(0,n.jsx)("circle",{cx:"5",cy:"6.5",r:"1",stroke:l,strokeWidth:"0.85"}),(0,n.jsx)("circle",{cx:"9",cy:"6.5",r:"1",stroke:l,strokeWidth:"0.85"}),(0,n.jsx)("circle",{cx:"5",cy:"10",r:"1",stroke:l,strokeWidth:"0.85"}),(0,n.jsx)("path",{d:"M5 7.5V9",stroke:l,strokeWidth:"0.85",strokeLinecap:"round"}),(0,n.jsx)("path",{d:"M9 7.5v.5a2 2 0 0 1-2 2H6",stroke:l,strokeWidth:"0.85",strokeLinecap:"round",fill:"none"})]})}function W({size:e=14}){return(0,n.jsxs)("svg",{width:e,height:e,viewBox:"0 0 14 14",fill:"none",children:[(0,n.jsx)("path",{d:"M2.5 1h6l3 3v9h-9V1Z",stroke:l,strokeWidth:"0.9",fill:l,fillOpacity:"0.07",strokeLinejoin:"round"}),(0,n.jsx)("path",{d:"M8.5 1v3h3",stroke:l,strokeWidth:"0.9",fill:"none",strokeLinejoin:"round"}),(0,n.jsx)("rect",{x:"4.5",y:"8.5",width:"5",height:"3",rx:"0.6",stroke:l,strokeWidth:"0.9"}),(0,n.jsx)("path",{d:"M5.5 8.5V7.5a1.5 1.5 0 0 1 3 0v1",stroke:l,strokeWidth:"0.9",strokeLinecap:"round",fill:"none"})]})}function E({size:e=14}){return(0,n.jsxs)("svg",{width:e,height:e,viewBox:"0 0 14 14",fill:"none",children:[(0,n.jsx)("path",{d:"M2.5 1h6l3 3v9h-9V1Z",stroke:l,strokeWidth:"0.9",fill:l,fillOpacity:"0.07",strokeLinejoin:"round"}),(0,n.jsx)("path",{d:"M8.5 1v3h3",stroke:l,strokeWidth:"0.9",fill:"none",strokeLinejoin:"round"}),(0,n.jsx)("circle",{cx:"7",cy:"8.5",r:"1.3",stroke:l,strokeWidth:"0.9"}),(0,n.jsx)("path",{d:"M7 6.5v.7M7 10.3v.7M5 8.5h.7M8.3 8.5H9M5.5 6.9l.5.5M8.5 9.6l-.5-.5M5.5 10.1l.5-.5M8.5 7.4l-.5.5",stroke:l,strokeWidth:"0.8",strokeLinecap:"round"})]})}function M(e,t=14){let r=e.toLowerCase(),o=r.split(".").pop()??"";if("dockerfile"===r||r.startsWith("dockerfile."))return(0,n.jsx)(I,{size:t});if(".env"===r||r.startsWith(".env."))return(0,n.jsx)(R,{size:t});if(".gitignore"===r||".gitattributes"===r||".gitmodules"===r)return(0,n.jsx)(L,{size:t});if("package-lock.json"===r||"yarn.lock"===r||"bun.lock"===r||"pnpm-lock.yaml"===r||"cargo.lock"===r)return(0,n.jsx)(W,{size:t});if(r.endsWith(".config.ts")||r.endsWith(".config.js")||r.endsWith(".config.mjs")||r.endsWith(".config.cjs")||[".eslintrc",".eslintrc.js",".eslintrc.json",".eslintrc.yml","eslint.config.mjs","eslint.config.js"].includes(r))return(0,n.jsx)(E,{size:t});switch(o){case"ts":return(0,n.jsx)(c,{size:t});case"tsx":return(0,n.jsx)(p,{size:t});case"js":case"mjs":case"cjs":return(0,n.jsx)(x,{size:t});case"jsx":return(0,n.jsx)(u,{size:t});case"py":return(0,n.jsx)(g,{size:t});case"json":case"jsonl":return(0,n.jsx)(h,{size:t});case"css":case"less":return(0,n.jsx)(f,{size:t});case"scss":return(0,n.jsx)(b,{size:t});case"html":case"htm":return(0,n.jsx)(y,{size:t});case"md":case"mdx":return(0,n.jsx)(v,{size:t});case"yaml":case"yml":return(0,n.jsx)(m,{size:t});case"toml":return(0,n.jsx)(j,{size:t});case"sh":case"bash":case"zsh":case"fish":return(0,n.jsx)(k,{size:t});case"rs":return(0,n.jsx)(w,{size:t});case"go":return(0,n.jsx)(S,{size:t});case"sql":return(0,n.jsx)(C,{size:t});case"graphql":case"gql":return(0,n.jsx)(T,{size:t});case"tf":case"hcl":return(0,n.jsx)(z,{size:t});case"lock":return(0,n.jsx)(W,{size:t});default:return(0,n.jsx)(a,{size:t})}}function D(e){return/^[a-zA-Z]:[\\/]/.test(e)||e.startsWith("\\\\")?e.replace(/\\/g,"/"):e}function $(e){return D(e).split("/").filter(Boolean).map(encodeURIComponent).join("/")}function B(e){let t=D(e).replace(/\/+$/,"");return t.split("/").pop()??t}function A(e,t){if(!t)return e;let r=D(e),n=D(t).replace(/\/$/,"");return r.startsWith(n+"/")?r.slice(n.length+1):e}function O(e,t){return`${D(e).replace(/\/$/,"")}/${t}`}async function F(e){let t=$(e),r=await fetch(`/api/files/${t}?type=list`);return r.ok?((await r.json()).entries??[]).map(t=>({name:t.name,fullPath:O(e,t.name),isDir:t.isDir,size:t.size,children:t.isDir?[]:void 0,loaded:!t.isDir})):[]}function N({node:e,depth:t,cwd:r,onOpenFile:i,onAtMention:l,expandedPaths:a,onToggleExpanded:d,refreshKey:c,chapterStatusMap:p}){let x=a.has(e.fullPath),[u,g]=(0,o.useState)(e.children??[]),[h,f]=(0,o.useState)(e.loaded??!1),[b,y]=(0,o.useState)(!1),[v,m]=(0,o.useState)(!1),j=null;if(!e.isDir&&p){let t=e.name.match(/^(\d{4})_/);if(t){let e=p[parseInt(t[1],10)];if(e){let t="",r="",o="";switch(e){case"approved":t="已过审",r="#10b981",o="rgba(16,185,129,0.08)";break;case"ready-for-review":t="待审核",r="#eab308",o="rgba(234,179,8,0.08)";break;case"audit-failed":t="审计未过",r="#ef4444",o="rgba(239,68,68,0.08)";break;case"rejected":t="已驳回",r="#9ca3af",o="rgba(156,163,175,0.08)";break;default:t=e,r="var(--text-muted)",o="var(--bg-hover)"}j=(0,n.jsx)("span",{style:{fontSize:"9px",padding:"1px 5px",borderRadius:"4px",color:r,background:o,fontWeight:600,border:`1px solid ${r}25`,marginLeft:6,flexShrink:0,whiteSpace:"nowrap"},children:t})}}}let k=(0,o.useCallback)(async(t=!1)=>{if(!h||t){y(!0);try{let t=await F(e.fullPath);g(t),f(!0)}catch{}finally{y(!1)}}},[h,e.fullPath]),w=(0,o.useRef)(h);(0,o.useEffect)(()=>{w.current=h}),(0,o.useEffect)(()=>{x&&h&&k(!0)},[c]);let S=(0,o.useCallback)(()=>{if(e.isDir){let t=!x;d(e.fullPath,t),t&&!h&&k()}else i(e.fullPath,e.name)},[e.isDir,e.fullPath,e.name,h,x,k,i,d]);return(0,n.jsxs)("div",{children:[(0,n.jsxs)("div",{onClick:S,onMouseEnter:()=>m(!0),onMouseLeave:()=>m(!1),style:{position:"relative",display:"flex",alignItems:"center",gap:4,paddingLeft:8+14*t,paddingRight:8,height:24,cursor:"pointer",background:v?"var(--bg-hover)":"transparent",borderRadius:4,userSelect:"none"},children:[e.isDir&&(0,n.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"var(--text-dim)",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,transform:x?"rotate(90deg)":"none",transition:"transform 0.1s"},children:(0,n.jsx)("polyline",{points:"3 2 7 5 3 8"})}),!e.isDir&&(0,n.jsx)("span",{style:{width:10,flexShrink:0}}),(0,n.jsx)("span",{style:{flexShrink:0,display:"flex",alignItems:"center"},children:e.isDir?(0,n.jsx)(s,{size:14,open:x}):M(e.name,14)}),(0,n.jsx)("span",{style:{fontSize:12,color:"var(--text)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1},title:e.fullPath,children:e.name}),j,b&&(0,n.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-dim)",strokeWidth:"2",strokeLinecap:"round",children:(0,n.jsx)("path",{d:"M12 2v4M12 18v4M4.93 4.93l2.83 2.83M16.24 16.24l2.83 2.83M2 12h4M18 12h4"})}),l&&v&&(0,n.jsxs)("button",{onClick:t=>{t.stopPropagation(),l(A(e.fullPath,r))},title:"Insert path into chat",style:{position:"absolute",right:4,top:"50%",transform:"translateY(-50%)",display:"flex",alignItems:"center",justifyContent:"center",gap:4,padding:"0 8px",height:20,background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:4,color:"var(--accent)",cursor:"pointer",fontSize:11,fontWeight:600,whiteSpace:"nowrap"},children:[(0,n.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"4"}),(0,n.jsx)("path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8"})]}),"mention"]})]}),e.isDir&&x&&(0,n.jsxs)("div",{children:[u.map(e=>(0,n.jsx)(N,{node:e,depth:t+1,cwd:r,onOpenFile:i,onAtMention:l,expandedPaths:a,onToggleExpanded:d,refreshKey:c,chapterStatusMap:p},e.fullPath)),0===u.length&&h&&(0,n.jsx)("div",{style:{paddingLeft:8+(t+1)*14,fontSize:11,color:"var(--text-dim)",height:22,display:"flex",alignItems:"center"},children:"empty"})]})]})}function P({cwd:e,onOpenFile:t,refreshKey:r,onAtMention:i,chapterStatusMap:l}){let[s,a]=(0,o.useState)([]),[d,c]=(0,o.useState)(!0),[p,x]=(0,o.useState)(null),[u,g]=(0,o.useState)(new Set),h=(0,o.useRef)(null),f=(0,o.useCallback)((e,t)=>{g(r=>{let n=new Set(r);return t?n.add(e):n.delete(e),n})},[]);return((0,o.useEffect)(()=>{let t=h.current!==e;h.current=e,t&&g(new Set),c(t),x(null),F(e).then(e=>a(e)).catch(e=>x(String(e))).finally(()=>c(!1))},[e,r]),d)?(0,n.jsx)("div",{style:{padding:"8px 12px",fontSize:11,color:"var(--text-dim)"},children:"Loading files..."}):p?(0,n.jsx)("div",{style:{padding:"8px 12px",fontSize:11,color:"#f87171"},children:p}):(0,n.jsxs)("div",{style:{padding:"2px 4px"},children:[s.map(o=>(0,n.jsx)(N,{node:o,depth:0,cwd:e,onOpenFile:t,onAtMention:i,expandedPaths:u,onToggleExpanded:f,refreshKey:r,chapterStatusMap:l},o.fullPath)),0===s.length&&(0,n.jsx)("div",{style:{padding:"8px 12px",fontSize:11,color:"var(--text-dim)"},children:"No files found"})]})}var H=r(3143),_=r(2957);let J=[{name:"read",desc:"读取文件内容 (read_file)"},{name:"grep",desc:"搜索正则模式 (grep_search)"},{name:"find",desc:"查找文件 (find_files)"},{name:"ls",desc:"列出目录内容 (list_dir)"},{name:"edit",desc:"编辑/替换文件 (replace_file_content)"},{name:"write",desc:"新建文件 (write_to_file)"},{name:"bash",desc:"运行终端命令 (run_command)"}],U=["\uD83E\uDD16","\uD83D\uDCBB","\uD83D\uDD0D","\uD83E\uDDE0","✍️","\uD83C\uDFA8","\uD83C\uDF10","⚡","\uD83D\uDD27","\uD83D\uDCC1","\uD83D\uDCCA","\uD83D\uDE80"];function V({isOpen:e,onClose:t,gemId:r,onSave:i,modelList:l,defaultModel:s}){let[a,d]=(0,o.useState)(""),[c,p]=(0,o.useState)(""),[x,u]=(0,o.useState)("\uD83E\uDD16"),[g,h]=(0,o.useState)(""),[f,b]=(0,o.useState)(""),[y,v]=(0,o.useState)([]),[m,j]=(0,o.useState)([]),[k,w]=(0,o.useState)(""),[S,C]=(0,o.useState)(!1),[T,z]=(0,o.useState)(null);if((0,o.useEffect)(()=>{e&&(r?(C(!0),z(null),fetch("/api/gem-xy").then(e=>{if(!e.ok)throw Error("Failed to load Gem-xY list");return e.json()}).then(e=>{let t=e.find(e=>e.id===r);t&&(d(t.name),p(t.description||""),u(t.avatar||"\uD83E\uDD16"),h(t.systemPrompt),v(t.allowedTools||[]),j(t.knowledgeFiles||[]),t.provider&&t.modelId?b(`${t.provider}/${t.modelId}`):b("")),C(!1)}).catch(e=>{console.error(e),z("无法加载智能体配置"),C(!1)})):(d(""),p(""),u("\uD83E\uDD16"),h(""),v(J.map(e=>e.name)),j([]),s?b(`${s.provider}/${s.modelId}`):b(l.length>0?`${l[0].provider}/${l[0].id}`:""),z(null)))},[e,r,l]),!e)return null;let I=async e=>{if(e.preventDefault(),!a.trim())return void z("名称不能为空");if(!g.trim())return void z("核心指令不能为空");let n="",o="";if(f){let e=f.split("/");n=e[0],o=e[1]}let l={...r?{id:r}:{},name:a.trim(),description:c.trim(),avatar:x,systemPrompt:g.trim(),provider:n,modelId:o,allowedTools:y,knowledgeFiles:m};C(!0),z(null);try{let e=await fetch("/api/gem-xy",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error||"保存失败")}let r=await e.json();i(r),t()}catch(e){z(e instanceof Error?e.message:String(e))}finally{C(!1)}};return(0,n.jsx)("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:1e3,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0, 0, 0, 0.4)",backdropFilter:"blur(8px)",padding:20},children:(0,n.jsxs)("div",{style:{width:"100%",maxWidth:620,maxHeight:"85vh",background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:12,boxShadow:"0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 10px 10px -5px rgba(0, 0, 0, 0.2)",display:"flex",flexDirection:"column",overflow:"hidden"},children:[(0,n.jsxs)("div",{style:{padding:"16px 20px",borderBottom:"1px solid var(--border)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[(0,n.jsx)("h2",{style:{margin:0,fontSize:16,color:"var(--text)",fontWeight:600},children:r?"编辑 Gem-xY 智能体":"创建全新 Gem-xY 智能体"}),(0,n.jsx)("button",{onClick:t,style:{background:"none",border:"none",color:"var(--text-dim)",cursor:"pointer",padding:4,display:"flex",alignItems:"center",justifyContent:"center"},children:(0,n.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,n.jsx)("path",{d:"M18 6L6 18M6 6l12 12"})})})]}),(0,n.jsxs)("form",{onSubmit:I,style:{padding:20,overflowY:"auto",display:"flex",flexDirection:"column",gap:16,flex:1},children:[T&&(0,n.jsx)("div",{style:{padding:"8px 12px",background:"rgba(239, 68, 68, 0.15)",border:"1px solid rgba(239, 68, 68, 0.3)",color:"#f87171",borderRadius:6,fontSize:12},children:T}),S&&!r?(0,n.jsx)("div",{style:{padding:20,textAlign:"center",color:"var(--text-muted)",fontSize:12},children:"保存中..."}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[(0,n.jsx)("label",{style:{fontSize:11,color:"var(--text-muted)",fontWeight:500},children:"选择头像 (Emoji)"}),(0,n.jsxs)("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[(0,n.jsx)("div",{style:{width:44,height:44,borderRadius:8,background:"var(--bg)",border:"1px solid var(--border)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:24,flexShrink:0},children:x}),(0,n.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:U.map(e=>(0,n.jsx)("button",{type:"button",onClick:()=>u(e),style:{width:28,height:28,borderRadius:4,border:x===e?"1px solid var(--accent)":"1px solid transparent",background:x===e?"var(--bg-selected)":"transparent",cursor:"pointer",fontSize:14,display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.1s"},children:e},e))})]})]}),(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[(0,n.jsx)("label",{style:{fontSize:11,color:"var(--text-muted)",fontWeight:500},children:"智能体名称 *"}),(0,n.jsx)("input",{type:"text",required:!0,placeholder:"例如: Code Analyzer, 英语翻译官",value:a,onChange:e=>d(e.target.value),style:{padding:"8px 12px",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:6,color:"var(--text)",fontSize:12,outline:"none"}})]}),(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[(0,n.jsx)("label",{style:{fontSize:11,color:"var(--text-muted)",fontWeight:500},children:"功能描述"}),(0,n.jsx)("input",{type:"text",placeholder:"用一句话描述它的专业领域",value:c,onChange:e=>p(e.target.value),style:{padding:"8px 12px",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:6,color:"var(--text)",fontSize:12,outline:"none"}})]}),(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[(0,n.jsx)("label",{style:{fontSize:11,color:"var(--text-muted)",fontWeight:500},children:"核心指令 (System Prompt) *"}),(0,n.jsx)("textarea",{required:!0,rows:6,placeholder:"详细定义智能体的角色、口吻、回复格式以及所需遵循的准则。比如: '你是一个专业的 React 专家,使用简洁的代码逻辑进行回答。'",value:g,onChange:e=>h(e.target.value),style:{padding:"8px 12px",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:6,color:"var(--text)",fontSize:12,outline:"none",fontFamily:"inherit",resize:"vertical"}})]}),(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[(0,n.jsx)("label",{style:{fontSize:11,color:"var(--text-muted)",fontWeight:500},children:"底层模型 (可选)"}),(0,n.jsxs)("select",{value:f,onChange:e=>b(e.target.value),style:{padding:"8px 12px",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:6,color:"var(--text)",fontSize:12,outline:"none"},children:[(0,n.jsx)("option",{value:"",children:"— 沿用全局默认模型 —"}),l.map(e=>(0,n.jsxs)("option",{value:`${e.provider}/${e.id}`,children:[e.name||e.id," (",e.provider,")"]},`${e.provider}/${e.id}`))]})]}),(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[(0,n.jsx)("label",{style:{fontSize:11,color:"var(--text-muted)",fontWeight:500},children:"开启工具能力 (禁用可创建纯分析沙箱)"}),(0,n.jsx)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:8,background:"var(--bg)",padding:10,borderRadius:6,border:"1px solid var(--border)"},children:J.map(e=>(0,n.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:8,fontSize:11,color:"var(--text-muted)",cursor:"pointer"},children:[(0,n.jsx)("input",{type:"checkbox",checked:y.includes(e.name),onChange:()=>{var t;return t=e.name,void v(e=>e.includes(t)?e.filter(e=>e!==t):[...e,t])},style:{width:14,height:14,accentColor:"var(--accent)",cursor:"pointer"}}),(0,n.jsxs)("div",{children:[(0,n.jsx)("strong",{style:{color:"var(--text)"},children:e.name}),(0,n.jsx)("span",{style:{display:"block",fontSize:9,color:"var(--text-dim)"},children:e.desc})]})]},e.name))})]}),(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[(0,n.jsx)("label",{style:{fontSize:11,color:"var(--text-muted)",fontWeight:500},children:"关联知识库文件 (读取内容注入上下文)"}),m.length>0&&(0,n.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:4,maxHeight:120,overflowY:"auto",background:"var(--bg)",padding:"8px 10px",borderRadius:6,border:"1px solid var(--border)"},children:m.map((e,t)=>(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",fontSize:11,color:"var(--text-muted)",padding:"3px 0"},children:[(0,n.jsx)("span",{style:{fontFamily:"var(--font-mono)",wordBreak:"break-all",paddingRight:8},children:e}),(0,n.jsx)("button",{type:"button",onClick:()=>{j(e=>e.filter((e,r)=>r!==t))},style:{background:"none",border:"none",color:"#ef4444",cursor:"pointer",padding:"0 4px"},children:"删除"})]},t))}),(0,n.jsxs)("div",{style:{display:"flex",gap:8},children:[(0,n.jsx)("input",{type:"text",placeholder:"输入宿主机上文件的绝对路径 (如 D:/rules.md)",value:k,onChange:e=>w(e.target.value),style:{flex:1,padding:"8px 12px",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:6,color:"var(--text)",fontSize:12,outline:"none"}}),(0,n.jsx)("button",{type:"button",onClick:()=>{if(k.trim()){if(m.includes(k.trim()))return void w("");j(e=>[...e,k.trim()]),w("")}},style:{padding:"0 14px",background:"var(--bg-hover)",border:"1px solid var(--border)",borderRadius:6,color:"var(--text)",fontSize:12,cursor:"pointer"},children:"添加"})]}),(0,n.jsx)("span",{style:{fontSize:10,color:"var(--text-dim)"},children:"* 会话启动时将自动读取该路径下的文件内容并与核心指令一并注入上下文。"})]})]})]}),(0,n.jsxs)("div",{style:{padding:"12px 20px",borderTop:"1px solid var(--border)",background:"var(--bg-hover)",display:"flex",justifyContent:"flex-end",gap:10},children:[(0,n.jsx)("button",{type:"button",onClick:t,style:{padding:"6px 14px",background:"none",border:"1px solid var(--border)",borderRadius:6,color:"var(--text-muted)",fontSize:12,cursor:"pointer"},children:"取消"}),(0,n.jsx)("button",{type:"button",disabled:S,onClick:I,style:{padding:"6px 18px",background:"var(--accent)",border:"none",borderRadius:6,color:"#fff",fontSize:12,fontWeight:600,cursor:S?"not-allowed":"pointer",opacity:S?.7:1},children:S?"保存中...":"保存智能体"})]})]})})}var Y=r(1463);function K(e,t){return t&&e.startsWith(t)?"~"+e.slice(t.length):e}let G="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*";function q(){let[e,t]=(0,o.useState)(!1),[r,i]=(0,o.useState)(!1),l=(0,o.useRef)(null),s=function(e,t){let[r,n]=(0,o.useState)(e),i=(0,o.useRef)(null),l=(0,o.useRef)(0);return(0,o.useEffect)(()=>{if(!t)return void n(e);l.current=0;let r=4*e.length,o=()=>{l.current+=1;let t=Math.floor(l.current/r*e.length);n(e.split("").map((e,r)=>" "===e?" ":r<t?e:G[Math.floor(Math.random()*G.length)]).join("")),l.current<r?i.current=requestAnimationFrame(o):n(e)};return i.current=requestAnimationFrame(o),()=>{i.current&&cancelAnimationFrame(i.current)}},[e,t]),r}(e?`v${Y.env.NEXT_PUBLIC_APP_VERSION??"0.1.0"}`:"ink-xY Studio",r),a=(0,o.useCallback)(e=>{t(e),i(!0),setTimeout(()=>i(!1),(e?6:8)*4*(1e3/60)+100)},[]),d=(0,o.useCallback)(()=>{l.current&&clearTimeout(l.current);let t=!e;a(t),t&&(l.current=setTimeout(()=>a(!1),3e3))},[e,a]);return(0,o.useEffect)(()=>()=>{l.current&&clearTimeout(l.current)},[]),(0,n.jsx)("button",{onClick:d,style:{background:"none",border:"none",padding:0,cursor:"default",fontWeight:700,fontSize:15,letterSpacing:"-0.01em",color:e?"var(--accent)":"var(--text)",fontFamily:"var(--font-mono)",minWidth:"6ch"},children:s})}function Z({selectedSessionId:e,onSelectSession:t,onNewSession:r,initialSessionId:i,onInitialRestoreDone:l,refreshKey:s,onSessionDeleted:a,selectedCwd:d,onCwdChange:c,onOpenFile:p,explorerRefreshKey:x,onAtMention:u,activeGemId:g,availableStyles:h=[],activeStyleName:f=null,onStylesChange:b,onWorkspaceStatusChange:y,onActiveBookChange:v}){let[m,j]=(0,o.useState)([]),[k,w]=(0,o.useState)(!0),[S,C]=(0,o.useState)(null),[T,z]=(0,o.useState)(null),[I,R]=(0,o.useState)(""),[L,W]=(0,o.useState)(!1),[E,M]=(0,o.useState)(!1),[D,B]=(0,o.useState)(""),A=(0,o.useRef)(null),F=(0,o.useRef)(null),[N,J]=(0,o.useState)(!0),[U,Y]=(0,o.useState)(0),[G,Q]=(0,o.useState)([]),[ee,et]=(0,o.useState)([]),[er,en]=(0,o.useState)(null),[eo,ei]=(0,o.useState)(!1),[el,es]=(0,o.useState)(null),[ea,ed]=(0,o.useState)(!0),[ec,ep]=(0,o.useState)(!1),[ex,eu]=(0,o.useState)(!0),[eg,eh]=(0,o.useState)(!0),[ef,eb]=(0,o.useState)(!1),[ey,ev]=(0,o.useState)(!0),[em,ej]=(0,o.useState)(!0),[ek,ew]=(0,o.useState)(!1),[eS,eC]=(0,o.useState)(!1),[eT,ez]=(0,o.useState)(null),[eI,eR]=(0,o.useState)(!1),[eL,eW]=(0,o.useState)(!1),[eE,eM]=(0,o.useState)(null),[eD,e$]=(0,o.useState)(!1),[eB,eA]=(0,o.useState)(!1),[eO,eF]=(0,o.useState)(null),eN=(0,o.useRef)(null);(0,o.useEffect)(()=>{eN.current=eO,v?.(eO)},[eO,v]);let[eP,eH]=(0,o.useState)(!1),[e_,eJ]=(0,o.useState)(""),[eU,eV]=(0,o.useState)(""),[eY,eK]=(0,o.useState)(""),[eG,eq]=(0,o.useState)(!1),[eZ,eX]=(0,o.useState)([]),[eQ,e0]=(0,o.useState)(null),[e1,e2]=(0,o.useState)(null),[e4,e6]=(0,o.useState)([]),[e5,e8]=(0,o.useState)(!1),[e3,e9]=(0,o.useState)({}),[e7,te]=(0,o.useState)(!1),[tt,tr]=(0,o.useState)("epub"),[tn,to]=(0,o.useState)(!0),[ti,tl]=(0,o.useState)(!1),[ts,ta]=(0,o.useState)(null),[td,tc]=(0,o.useState)(null),[tp,tx]=(0,o.useState)([]),tu=(0,o.useRef)(null),[tg,th]=(0,o.useState)(!1),[tf,tb]=(0,o.useState)("chapters"),[ty,tv]=(0,o.useState)(""),[tm,tj]=(0,o.useState)(""),[tk,tw]=(0,o.useState)(""),[tS,tC]=(0,o.useState)(!1),[tT,tz]=(0,o.useState)(""),[tI,tR]=(0,o.useState)(!1),[tL,tW]=(0,o.useState)([]),[tE,tM]=(0,o.useState)(null),[tD,t$]=(0,o.useState)(null),[tB,tA]=(0,o.useState)([]),[tO,tF]=(0,o.useState)("active"),[tN,tP]=(0,o.useState)(""),[tH,t_]=(0,o.useState)(""),[tJ,tU]=(0,o.useState)(!1),[tV,tY]=(0,o.useState)("paste"),[tK,tG]=(0,o.useState)(""),[tq,tZ]=(0,o.useState)(""),[tX,tQ]=(0,o.useState)(""),[t0,t1]=(0,o.useState)(!1),[t2,t4]=(0,o.useState)(!1),[t6,t5]=(0,o.useState)([]),[t8,t3]=(0,o.useState)(null),[t9,t7]=(0,o.useState)(null),[re,rt]=(0,o.useState)(null),[rr,rn]=(0,o.useState)("canon"),[ro,ri]=(0,o.useState)(""),[rl,rs]=(0,o.useState)(!1),[ra,rd]=(0,o.useState)(null),[rc,rp]=(0,o.useState)(!1),[rx,ru]=(0,o.useState)(""),[rg,rh]=(0,o.useState)(!1),[rf,rb]=(0,o.useState)([]),[ry,rv]=(0,o.useState)(null),[rm,rj]=(0,o.useState)(null),rk=(0,o.useRef)(null),[rw,rS]=(0,o.useState)(!1),[rC,rT]=(0,o.useState)(!1),[rz,rI]=(0,o.useState)([]),[rR,rL]=(0,o.useState)(null),[rW,rE]=(0,o.useState)(null),rM=(0,o.useRef)(null),[rD,r$]=(0,o.useState)(!1),[rB,rA]=(0,o.useState)(!1),[rO,rF]=(0,o.useState)([]),[rN,rP]=(0,o.useState)(null),[rH,r_]=(0,o.useState)(null),[rJ,rU]=(0,o.useState)(""),[rV,rY]=(0,o.useState)(12),[rK,rG]=(0,o.useState)(1e3),[rq,rZ]=(0,o.useState)(!0),[rX,rQ]=(0,o.useState)(null),[r0,r1]=(0,o.useState)("idle"),r2=(0,o.useRef)(null);(0,o.useEffect)(()=>{rk.current&&(rk.current.scrollTop=rk.current.scrollHeight)},[rf]),(0,o.useEffect)(()=>{rM.current&&(rM.current.scrollTop=rM.current.scrollHeight)},[rz]),(0,o.useEffect)(()=>{r2.current&&(r2.current.scrollTop=r2.current.scrollHeight)},[rO]),(0,o.useEffect)(()=>{let e=localStorage.getItem("ink-show-import-draft");null!==e&&ev("true"===e);let t=localStorage.getItem("ink-show-auto-generate-short");null!==t&&ej("true"===t);let r=e=>{e.detail&&("boolean"==typeof e.detail.showImportDraft&&ev(e.detail.showImportDraft),"boolean"==typeof e.detail.showAutoGenerateShort&&ej(e.detail.showAutoGenerateShort))};return window.addEventListener("ink-settings-changed",r),()=>{window.removeEventListener("ink-settings-changed",r)}},[]);let[r4,r6]=(0,o.useState)(!1),[r5,r8]=(0,o.useState)(""),[r3,r9]=(0,o.useState)(!1),[r7,ne]=(0,o.useState)(!1),[nt,nr]=(0,o.useState)([]),[nn,no]=(0,o.useState)(null),[ni,nl]=(0,o.useState)(null),ns=(0,o.useRef)(null),na=(0,o.useRef)(null),nd=(0,o.useRef)(null);(0,o.useEffect)(()=>{tu.current&&(tu.current.scrollTop=tu.current.scrollHeight)},[eZ]),(0,o.useEffect)(()=>{ns.current&&(ns.current.scrollTop=ns.current.scrollHeight)},[tL]),(0,o.useEffect)(()=>{na.current&&(na.current.scrollTop=na.current.scrollHeight)},[t6]),(0,o.useEffect)(()=>{nd.current&&(nd.current.scrollTop=nd.current.scrollHeight)},[nt]);let[nc,np]=(0,o.useState)(""),[nx,nu]=(0,o.useState)("xuanhuan"),[ng,nh]=(0,o.useState)("tomato"),[nf,nb]=(0,o.useState)(""),[ny,nv]=(0,o.useState)(null),[nm,nj]=(0,o.useState)(null),[nk,nw]=(0,o.useState)(!0),[nS,nC]=(0,o.useState)(!0);(0,o.useEffect)(()=>{if(!ek){nv(null),nj(null),nw(!0),nC(!0);return}let e=d||T;e&&(async()=>{try{let t=null,r=null,n=[{name:"根目录",path:e},{name:"Temp",path:`${e}/Temp`},{name:"temp",path:`${e}/temp`}].filter((e,t,r)=>r.findIndex(t=>t.path.toLowerCase().replace(/\\/g,"/")===e.path.toLowerCase().replace(/\\/g,"/"))===t),o=["novel_framework_v2.md","novel_framework.md","novel-framework.md","架构.md","构架.md"],i=["character_profiles.md","character-profiles.md","character.md","人设.md"];for(let e of n)try{let n=await fetch(`/api/files/${$(e.path)}?type=list`);if(!n.ok)continue;let l=await n.json();if(l.entries){if(!t){let r=l.entries.find(e=>!e.isDir&&o.includes(e.name.toLowerCase()));r&&(t={name:r.name,fullPath:`${e.path}/${r.name}`})}if(!r){let t=l.entries.find(e=>!e.isDir&&i.includes(e.name.toLowerCase()));t&&(r={name:t.name,fullPath:`${e.path}/${t.name}`})}}}catch(e){}nv(t),nj(r)}catch(e){console.error("Failed to scan local framework/character files:",e)}})()},[ek,d,T]);let[nT,nz]=(0,o.useState)(!1),[nI,nR]=(0,o.useState)(null),nL=(0,o.useCallback)(async(e,t)=>{if(e)try{let r=$(e),n=await fetch(`/api/files/${r}?type=list`);if(!n.ok){eu(!1),eh(!1),eb(!1),eF(null),e$(!1),e9({}),tA([]),r6(!1),r8(""),rs(!1),rd(null);return}let o=((await n.json()).entries||[]).some(e=>".inkos"===e.name||"story"===e.name||"books"===e.name);if(eu(o),o){let r=!1;try{let t=O(e,"shorts"),n=$(t),o=await fetch(`/api/files/${n}?type=list`);o.ok&&(r=((await o.json()).entries||[]).filter(e=>".gitkeep"!==e.name&&!e.name.startsWith(".")).length>0)}catch(e){console.error("Failed to check shorts folder status:",e)}eb(r);let n=O(e,"books"),o=$(n),i=await fetch(`/api/files/${o}?type=list`);if(i.ok){let r=((await i.json()).entries||[]).filter(e=>".gitkeep"!==e.name&&!e.name.startsWith(".")),n=r.length>0;eh(n);let o=r.map(e=>e.name);if(tA(o),n){let n=t||null;if(!n||!o.includes(n)){let e=eN.current;n=e&&o.includes(e)?e:r[0].name}eF(n);try{let t=O(e,`books/${n}/book.json`),r=$(t),o=await fetch(`/api/files/${r}?type=read`);if(o.ok){let e=await o.json(),t=JSON.parse(e.content);t&&t.fanficMode?(rs(!0),rd(t.fanficMode)):(rs(!1),rd(null))}else rs(!1),rd(null)}catch(e){console.error("Failed to parse book.json for fanfic mode:",e),rs(!1),rd(null)}let i=O(e,`books/${n}/chapters`),l=$(i),s=await fetch(`/api/files/${l}?type=list`),a=0;if(s.ok){let e=((await s.json()).entries||[]).filter(e=>!e.isDir&&e.name.endsWith(".md")&&/^\d{4}/.test(e.name));e$(e.length>0);let t=e.map(e=>{let t=e.name.match(/^(\d+)/);return t?parseInt(t[1],10):0}).filter(e=>e>0);a=t.length>0?Math.max(...t):0}else e$(!1);let d=!1;try{let t=O(e,`books/${n}/story/runtime/chapter-0001.plan.md`),r=$(t);(await fetch(`/api/files/${r}?type=read`)).ok&&(d=!0)}catch(e){console.error("Failed to check chapter-0001.plan.md:",e)}eA(d);try{let t="",r=O(e,`books/${n}/story/outline/volume_map.md`),o=$(r),i=await fetch(`/api/files/${o}?type=read`);if(i.ok){let e=await i.json();e&&e.content&&(t=e.content)}if(!t.trim()){let r=O(e,`books/${n}/story/volume_outline.md`),o=$(r),i=await fetch(`/api/files/${o}?type=read`);if(i.ok){let e=await i.json();e&&e.content&&(t=e.content)}}if(t.trim()){let r=(e=>{let t=[],r=e.split("\n"),n=/^(第[一二三四五六七八九十百千万零〇\d]+卷|Volume\s+\d+)/i,o=/[((]\s*(?:第|[Cc]hapters?\s+)?(\d+)\s*[-–~~—]\s*(\d+)\s*(?:章)?\s*[))]|(?:第|[Cc]hapters?\s+)(\d+)\s*[-–~~—]\s*(\d+)\s*(?:章)?/i;for(let e of r){let r=e.replace(/^#+\s*/,"").trim();if(!n.test(r))continue;let i=r.match(o);if(!i)continue;let l=parseInt(i[1]??i[3]??"0",10),s=parseInt(i[2]??i[4]??"0",10);if(l<=0||s<=0)continue;let a=r.match(/^([^\((]+)/),d=a?a[1].trim():r;t.push({name:d,startCh:l,endCh:s})}return t})(t),o="",i=O(e,`books/${n}/story/volume_summaries.md`),l=$(i),s=await fetch(`/api/files/${l}?type=read`);if(s.ok){let e=await s.json();e&&e.content&&(o=e.content)}let d=!1,c="";for(let e of r)if(a>=e.endCh&&!(o.includes(e.name)||o.includes(`Ch.${e.startCh}-${e.endCh}`)||o.includes(`vol_${e.startCh}-${e.endCh}`))){d=!0,c=`${e.name} (${e.startCh}-${e.endCh}章)`;break}r6(d),r8(c)}else r6(!1),r8("")}catch(e){console.error("Failed to check consolidation status:",e),r6(!1),r8("")}try{let t=await fetch("/api/inkos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"style-list",cwd:e,args:{bookId:n}})});if(t.ok){let e=await t.json();b&&b(e.styles||[],e.activeStyle||null)}}catch(e){console.error("Failed to load style list:",e)}let c=O(e,`books/${n}/chapters/index.json`),p=$(c),x=await fetch(`/api/files/${p}?type=read`);if(x.ok)try{let e=await x.json(),t=JSON.parse(e.content),r={};if(Array.isArray(t))for(let e of t)e&&"number"==typeof e.number&&e.status&&(r[e.number]=e.status);e9(r)}catch(e){console.error("Failed to parse chapter index.json:",e),e9({})}else e9({})}else eF(null),e$(!1),e9({}),r6(!1),r8(""),rs(!1),rd(null)}else eh(!1),eF(null),e$(!1),e9({}),tA([]),r6(!1),r8(""),rs(!1),rd(null)}else eh(!1),eb(!1),eF(null),e$(!1),e9({}),tA([]),r6(!1),r8(""),rs(!1),rd(null)}catch(e){console.error("Failed to verify workspace status:",e)}},[b]),nW=async e=>{e.preventDefault();let t=d||T;if(!t||!eO)return;tl(!0),ta(null),tc(null),tx([]);let r=`${eO}_export_${Date.now()}.${tt}`,n=`${t}/Temp/${r}`;try{let e=await fetch("/api/inkos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"export",cwd:t,args:{bookId:eO,format:tt,approvedOnly:tn,output:n,json:!0}})});if(!e.ok)throw Error(`HTTP 异常 ${e.status}`);if(!e.body)throw Error("响应正文流为空");let r=e.body.getReader(),o=new TextDecoder,i="",l=null;for(;;){let{done:e,value:t}=await r.read();if(e)break;let n=(i+=o.decode(t,{stream:!0})).split("\n");for(let e of(i=n.pop()||"",n))if(e.trim())try{let t=JSON.parse(e);"stdout"===t.type||"stderr"===t.type?tx(e=>[...e,t.data||""]):"result"===t.type&&(l=t)}catch(e){}}if(i.trim())try{let e=JSON.parse(i);"result"===e.type&&(l=e)}catch(e){}if(!l||!l.success)throw Error(l?.error||"书稿导出执行失败,请检查配置或存量章节。");let s=null;try{s=JSON.parse(l.stdout)}catch(e){console.error("Failed to parse export stdout:",e)}if(s&&s.error)throw Error(s.error);let a=$(n),d=`/api/files/${a}?type=read`,c=document.createElement("a");c.href=d,c.download=`${eO}_export.${tt}`,document.body.appendChild(c),c.click(),document.body.removeChild(c),tc(`🎉 导出成功!已导出 ${s?.chaptersExported??"全部"} 章节,共 ${s?.totalWords??0} 字。`),Y(e=>e+1)}catch(e){console.error(e),ta(e.message||"书稿导出失败,请重试。")}finally{tl(!1)}},nE=async()=>{let e=d||T;if(e&&eO){r9(!0),no(null),nl(null),nr([]),ne(!0);try{let t=await fetch("/api/inkos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"consolidate",cwd:e,args:{bookId:eO,json:!0}})});if(!t.ok)throw Error(`HTTP 异常 ${t.status}`);if(!t.body)throw Error("响应正文流为空");let r=t.body.getReader(),n=new TextDecoder,o="",i=null;for(;;){let{done:e,value:t}=await r.read();if(e)break;let l=(o+=n.decode(t,{stream:!0})).split("\n");for(let e of(o=l.pop()||"",l))if(e.trim())try{let t=JSON.parse(e);"stdout"===t.type||"stderr"===t.type?nr(e=>[...e,t.data||""]):"result"===t.type&&(i=t)}catch(e){console.error("Failed to parse stream chunk:",e)}}if(o.trim())try{let e=JSON.parse(o);"result"===e.type&&(i=e)}catch(e){}if(!i||!i.success){let e="";if(i){if(i.error)e=i.error;else if(i.stdout)try{let t=JSON.parse(i.stdout);t&&t.error?e=t.error:Array.isArray(t)&&t.length>0&&t[t.length-1]?.error&&(e=t[t.length-1].error)}catch(e){}!e&&i.stderr&&(e=i.stderr.trim())}throw Error(e||"大纲摘要压缩执行失败")}let l=null;try{l=JSON.parse(i.stdout)}catch(e){console.error("Failed to parse consolidate JSON output:",e)}l?nl({archivedVolumes:l.archivedVolumes??0,retainedChapters:l.retainedChapters??0}):nl({archivedVolumes:1,retainedChapters:0}),await nL(e),Y(e=>e+1)}catch(e){console.error(e),no(e.message||String(e))}finally{r9(!1)}}},nM=async e=>{e.preventDefault();let t=d||T;if(t){tR(!0),tM(null),t$(null),tW([]);try{let e="new"===tO||0===tB.length?tN.trim():eO||void 0;if(("new"===tO||0===tB.length)&&"chapters"===tf){if(!e)throw Error("新书籍 ID 不能为空");let r=tH.trim()||e;tW(t=>[...t,`[System] 正在自动创建新书籍 "${e}" (${r})...
2
+ `]);let n=await fetch("/api/inkos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"book-create",cwd:t,args:{title:r,genre:"xuanhuan",platform:"tomato"}})});if(!n.ok)throw Error(`创建新书籍失败,HTTP 异常 ${n.status}`);if(!n.body)throw Error("创建新书籍响应流为空");let o=n.body.getReader(),i=new TextDecoder,l="",s=null;for(;;){let{done:e,value:t}=await o.read();if(e)break;let r=(l+=i.decode(t,{stream:!0})).split("\n");for(let e of(l=r.pop()||"",r))if(e.trim())try{let t=JSON.parse(e);"stdout"===t.type||"stderr"===t.type?tW(e=>[...e,t.data||""]):"result"===t.type&&(s=t)}catch(e){}}if(l.trim())try{let e=JSON.parse(l);"result"===e.type&&(s=e)}catch(e){}if(!s||!s.success)throw Error(s?.error||"创建新书籍失败");tW(e=>[...e,`[System] 新书籍创建完成,正在导入章节数据...
3
+ `])}let r={};if("chapters"===tf){if(!ty.trim())throw Error("导入源路径不能为空");r={action:"import-chapters",cwd:t,args:{bookId:e,from:ty.trim(),split:tm.trim()||void 0,resumeFrom:tk?parseInt(tk,10):void 0,series:tS,json:!0}}}else{if(!tT.trim())throw Error("请选择或输入原著/前作 Book ID");r={action:"import-canon",cwd:t,args:{bookId:eO||void 0,from:tT.trim(),json:!0}}}let n=await fetch("/api/inkos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!n.ok)throw Error(`HTTP 异常 ${n.status}`);if(!n.body)throw Error("响应正文流为空");let o=n.body.getReader(),i=new TextDecoder,l="",s=null;for(;;){let{done:e,value:t}=await o.read();if(e)break;let r=(l+=i.decode(t,{stream:!0})).split("\n");for(let e of(l=r.pop()||"",r))if(e.trim())try{let t=JSON.parse(e);"stdout"===t.type||"stderr"===t.type?tW(e=>[...e,t.data||""]):"result"===t.type&&(s=t)}catch(e){}}if(l.trim())try{let e=JSON.parse(l);"result"===e.type&&(s=e)}catch(e){}if(!s||!s.success)throw Error(s?.error||"导入执行失败,请检查路径或日志。");if("chapters"===tf){let e=null;try{s.stdout&&(e=JSON.parse(s.stdout))}catch(e){}let t=e?.importedCount??"部分",r=e?.totalWords??0;t$(`🎉 成功导入章节!共处理了 ${t} 章节,约 ${r} 字。逆向工程设定提取成功!`)}else t$(`🎉 成功导入前作设定!世界观与人物正典已同步成功。`);await nL(t),Y(e=>e+1),window.dispatchEvent(new CustomEvent("refresh-explorer"))}catch(e){console.error(e),tM(e.message||"导入执行失败,请重试。")}finally{tR(!1)}}},nD=async e=>{e.preventDefault();let t=d||T;if(t&&eO){t1(!0),t3(null),t7(null),t5([]),rt(null);try{let e=tK.trim();if(!e)throw Error("文风名称不能为空");let r={};if("paste"===tV){if(!tq.trim())throw Error("克隆样文本内容不能为空");r={action:"style-import",cwd:t,args:{bookId:eO,content:tq.trim(),name:e,json:!0}}}else{if(!tX.trim())throw Error("克隆样文绝对路径不能为空");r={action:"style-import",cwd:t,args:{bookId:eO,from:tX.trim(),name:e,json:!0}}}let n=await fetch("/api/inkos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!n.ok)throw Error(`HTTP 异常 ${n.status}`);if(!n.body)throw Error("响应正文流为空");let o=n.body.getReader(),i=new TextDecoder,l="",s=null;for(;;){let{done:e,value:t}=await o.read();if(e)break;let r=(l+=i.decode(t,{stream:!0})).split("\n");for(let e of(l=r.pop()||"",r))if(e.trim())try{let t=JSON.parse(e);"stdout"===t.type||"stderr"===t.type?t5(e=>[...e,t.data||""]):"result"===t.type&&(s=t)}catch(e){}}if(l.trim())try{let e=JSON.parse(l);"result"===e.type&&(s=e)}catch(e){}if(!s||!s.success)throw Error(s?.error||"文风导入执行失败,请检查路径或日志。");t7(`🎉 成功完成文风克隆分析!统计学特征已存入 style_profile.json,大模型文风提示词已写入 style_guide.md。后续写作 AI 将会自动参照该文风书写。`);let a=O(t,`books/${eO}/story/style_guide.md`);rt(a),await nL(t),Y(e=>e+1),window.dispatchEvent(new CustomEvent("refresh-explorer"))}catch(e){console.error(e),t3(e.message||"文风导入执行失败,请重试。")}finally{t1(!1)}}},n$=async e=>{let t=d||T;if(t&&eO){t4(!0);try{let r=await fetch("/api/inkos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"style-switch",cwd:t,args:{bookId:eO,styleName:e}})});if(!r.ok){let e=await r.json();throw Error(e.error||`HTTP error ${r.status}`)}b&&b(h,e),Y(e=>e+1)}catch(e){alert(`切换文风失败: ${e.message||e}`)}finally{t4(!1)}}};(0,o.useEffect)(()=>{y?.(ex,eg)},[ex,eg,y]),(0,o.useEffect)(()=>{let e=()=>{tU(!0),t7(null),t3(null),t5([]),tG(""),tZ(""),tQ(""),rt(null)},t=()=>{rS(!0),rL(null),rE(null),rI([])},r=e=>{e.detail&&e.detail.styleName&&n$(e.detail.styleName)};return window.addEventListener("trigger-style-clone",e),window.addEventListener("trigger-radar",t),window.addEventListener("trigger-style-switch",r),()=>{window.removeEventListener("trigger-style-clone",e),window.removeEventListener("trigger-radar",t),window.removeEventListener("trigger-style-switch",r)}},[n$]);let nB=async e=>{e.preventDefault();let t=d||T;if(t&&eO){if(!rx.trim())return void rv("请输入原作素材的绝对路径");rh(!0),rv(null),rj(null),rb([]);try{let e=await fetch("/api/inkos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"fanfic-refresh",cwd:t,args:{bookId:eO,from:rx.trim(),json:!0}})});if(!e.ok)throw Error(`HTTP 异常 ${e.status}`);if(!e.body)throw Error("响应正文流为空");let r=e.body.getReader(),n=new TextDecoder,o="",i=null;for(;;){let{done:e,value:t}=await r.read();if(e)break;let l=(o+=n.decode(t,{stream:!0})).split("\n");for(let e of(o=l.pop()||"",l))if(e.trim())try{let t=JSON.parse(e);"stdout"===t.type||"stderr"===t.type?rb(e=>[...e,t.data||""]):"result"===t.type&&(i=t)}catch(e){}}if(o.trim())try{let e=JSON.parse(o);"result"===e.type&&(i=e)}catch(e){}if(!i||!i.success)throw Error(i?.error||"刷新原作设定执行失败");rj("同人原作正典设定已刷新!"),Y(e=>e+1),window.dispatchEvent(new CustomEvent("refresh-explorer"))}catch(e){console.error(e),rv(e.message||String(e))}finally{rh(!1)}}},nA=async()=>{let e=d||T;if(e&&eO){eH(!0),eJ("正在为您规划首章蓝图,请稍候..."),eV(""),eK(""),eX([]),e0(null);try{let t=await fetch("/api/inkos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"plan",cwd:e,args:{bookId:eO,json:!0}})});if(!t.ok)throw Error(`HTTP 异常 ${t.status}`);if(!t.body)throw Error("响应正文流为空");let r=t.body.getReader(),n=new TextDecoder,o="",i=null;for(;;){let{done:e,value:t}=await r.read();if(e)break;let l=(o+=n.decode(t,{stream:!0})).split("\n");for(let e of(o=l.pop()||"",l))if(e.trim())try{let t=JSON.parse(e);if("stdout"===t.type||"stderr"===t.type){let e=t.data||"";eX(t=>[...t,e])}else"result"===t.type&&(i=t)}catch(e){console.error("Failed to parse stream chunk:",e)}}if(o.trim())try{let e=JSON.parse(o);"result"===e.type&&(i=e)}catch{}if(!i||!i.success)throw Error(i?.error||"首章蓝图规划失败");eV("首章蓝图规划完成"),eK("已成功规划首章大纲与大纲意图栈!\n已在 books/"+eO+"/story/runtime/ 目录下生成了 chapter-0001.plan.md。接下来,您可以点击“智能写作”按钮以起草正文。"),eq(!0),window.dispatchEvent(new CustomEvent("refresh-explorer")),await nL(e)}catch(e){console.error(e),e0(e instanceof Error?e.message:String(e))}finally{eH(!1)}}},nO=async()=>{let e=d||T;if(e&&eO){eH(!0),eJ("正在为您规划大纲并起草首章正文,请稍候..."),eV(""),eK(""),eX([]);try{let t=await fetch("/api/inkos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"write-next",cwd:e,args:{bookId:eO,json:!0}})});if(!t.ok)throw Error(`HTTP 异常 ${t.status}`);if(!t.body)throw Error("响应正文流为空");let r=t.body.getReader(),n=new TextDecoder,o="",i=null;for(;;){let{done:e,value:t}=await r.read();if(e)break;let l=(o+=n.decode(t,{stream:!0})).split("\n");for(let e of(o=l.pop()||"",l))if(e.trim())try{let t=JSON.parse(e);if("stdout"===t.type||"stderr"===t.type){let e=t.data||"";eX(t=>[...t,e]),e.includes("planning chapter")||e.includes("规划本章")?eJ("正在规划本章意图与章节规划栈..."):e.includes("起草")||e.includes("drafting")?eJ("正在协同起草首章正文,请稍候..."):(e.includes("audit")||e.includes("审计"))&&eJ("正在执行离线审稿与一致性审计...")}else"result"===t.type&&(i=t)}catch(e){console.error("Failed to parse stream chunk:",e)}}if(o.trim())try{let e=JSON.parse(o);"result"===e.type&&(i=e)}catch(e){}if(!i||!i.success){let e="";if(i){if(i.error)e=i.error;else if(i.stdout)try{let t=JSON.parse(i.stdout);t&&t.error?e=t.error:Array.isArray(t)&&t.length>0&&t[t.length-1]?.error&&(e=t[t.length-1].error)}catch(e){}!e&&i.stderr&&(e=i.stderr.trim())}throw Error(e||"首章创作执行失败")}let l=[];try{l=JSON.parse(i.stdout)}catch(t){console.error("Failed to parse write-next JSON output:",t),eK(i.stdout||"首章起草成功!"),eV("首章起草完成"),eq(!0),window.dispatchEvent(new CustomEvent("refresh-explorer")),await nL(e);return}let s=l[0];if(!s)throw Error("未返回有效的创作章节结果。");let a=String(s.chapterNumber).padStart(4,"0"),d=`${e}/books/${eO}/chapters`,c=await fetch(`/api/files/${$(d)}?type=list`),p=await c.json(),x=p.entries?.find(e=>!e.isDir&&e.name.startsWith(a));if(x){let e=d+"/"+x.name;window.dispatchEvent(new CustomEvent("open-file",{detail:{filePath:e,fileName:x.name}}))}let u=s.auditResult?.passed??!1,g=s.auditResult?.issues??[],h=[`### 🎉 智能写作首章完成!`,"",`- **章节**: 第 ${s.chapterNumber} 章 《${s.title}》`,`- **字数**: ${s.wordCount} 字`,`- **自动修正**: ${s.revised?"已执行(已修复关键问题)":"无(无需修正)"}`,`- **状态结算**: \`${s.status}\``,"",`#### 🔍 离线审稿审计结果`,u?"✅ **审计通过**:无逻辑矛盾或角色人设崩塌问题。":"⚠️ **审计未完全通过**:检测到一些逻辑或人设风险,建议审阅:","",g.length>0?g.map(e=>{let t=String(e.severity||"info").toLowerCase(),r="critical"===t||"error"===t?"\uD83D\uDD34 [critical]":"warning"===t?"\uD83D\uDFE1 [warning]":"info"===t?"\uD83D\uDD35 [info]":`⚪ [${e.severity}]`;return`- ${r} **${e.category}**: ${e.description}
4
+ *建议: ${e.suggestion}*`}).join("\n"):"*(无关键警告或错误)*"].join("\n");eV("首章创作与审计报告"),eK(h),eq(!0),window.dispatchEvent(new CustomEvent("refresh-explorer")),await nL(e),eH(!1)}catch(e){console.error(e),e.message.includes("超时")||e.message.includes("timed out")||eZ.some(e=>e.includes("超时"))?e0("任务运行超时(已超过 1800 秒)。建议在右上角「模型配置」中,更换速度较快且稳定的标准模型(例如将 reasoning/思索模型切换为标准对话模型),并检查您的 API Key 与接口代理连接状态。"):e0(e.message||String(e))}}},nF=async e=>{if(e.preventDefault(),!nc.trim())return void ez("书籍名称不能为空");let t=d||T;if(t){eC(!0),ez(null);try{let e="fanfic"===nx;if(e&&!ro.trim())throw Error("同人小说原作素材磁盘路径不能为空");let r=await fetch("/api/inkos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:e?"fanfic-init":"book-create",cwd:t,args:e?{title:nc.trim(),from:ro.trim(),mode:rr,genre:"fanfic",platform:ng,json:!0}:{title:nc.trim(),genre:nx,platform:ng,brief:nf.trim()||void 0,selectedFrameworkPath:ny&&nk?ny.fullPath:void 0,selectedCharacterPath:nm&&nS?nm.fullPath:void 0}})});if(!r.ok)throw Error(`HTTP 异常 ${r.status}`);if(!r.body)throw Error("响应正文流为空");let n=r.body.getReader(),o=new TextDecoder,i="",l=null;for(;;){let{done:e,value:t}=await n.read();if(e)break;let r=(i+=o.decode(t,{stream:!0})).split("\n");for(let e of(i=r.pop()||"",r))if(e.trim())try{let t=JSON.parse(e);"result"===t.type&&(l=t)}catch(e){}}if(i.trim())try{let e=JSON.parse(i);"result"===e.type&&(l=e)}catch(e){}if(!l||!l.success)throw Error(l?.error||"创建书籍失败,大模型生成异常,请检查配置和 Key");await nL(t),Y(e=>e+1),np(""),nb(""),ri(""),ew(!1)}catch(e){console.error(e),ez(e.message||"创建书籍失败,请确认侧边栏左下角 Models 中 API Key 填写正确且模型支持当前题材生成。")}finally{eC(!1)}}},nN=async()=>{let e=d||T;if(e&&eO){eW(!0),eM(null);try{let t=await fetch("/api/inkos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"book-delete",cwd:e,args:{bookId:eO,json:!0}})});if(!t.ok)throw Error(`HTTP 异常 ${t.status}`);if(!t.body)throw Error("响应正文流为空");let r=t.body.getReader(),n=new TextDecoder,o="",i=null;for(;;){let{done:e,value:t}=await r.read();if(e)break;let l=(o+=n.decode(t,{stream:!0})).split("\n");for(let e of(o=l.pop()||"",l))if(e.trim())try{let t=JSON.parse(e);"result"===t.type&&(i=t)}catch(e){}}if(o.trim())try{let e=JSON.parse(o);"result"===e.type&&(i=e)}catch(e){}if(!i||!i.success)throw Error(i?.error||"删除书籍失败");window.dispatchEvent(new CustomEvent("close-directory",{detail:{dirPath:`${e}/books/${eO}`}})),await nL(e),Y(e=>e+1),eR(!1)}catch(e){console.error(e),eM(e.message||"删除书籍失败")}finally{eW(!1)}}},nP=async e=>{e.preventDefault();let t=d||T;if(t){rT(!0),rL(null),rE(null),rI([]);try{let e=await fetch("/api/inkos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"radar-scan",cwd:t,args:{json:!0}})});if(!e.ok)throw Error(`HTTP 异常 ${e.status}`);if(!e.body)throw Error("响应流为空");let r=e.body.getReader(),n=new TextDecoder,o="",i=null;for(;;){let{done:e,value:t}=await r.read();if(e)break;let l=(o+=n.decode(t,{stream:!0})).split("\n");for(let e of(o=l.pop()||"",l))if(e.trim())try{let t=JSON.parse(e);"stdout"===t.type||"stderr"===t.type?rI(e=>[...e,t.data||""]):"result"===t.type&&(i=t)}catch(e){console.error("Failed to parse stream chunk:",e)}}if(o.trim())try{let e=JSON.parse(o);"result"===e.type&&(i=e)}catch{}if(!i||!i.success)throw Error(i?.error||"扫描市场情报失败");let l=null;try{l=JSON.parse(i.stdout||"")}catch(e){console.error("Failed to parse radar scan result JSON:",e)}if(l)rE(l);else throw Error("检测引擎未返回有效的 JSON 结构")}catch(e){console.error(e),rL(e instanceof Error?e.message:String(e))}finally{rT(!1)}}},nH=async e=>{if(!rJ.trim())return void rP("创作方向不能为空");let t=d||T;if(t){rA(!0),rP(null),r_(null),rF([]);try{let r=await fetch("/api/inkos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"short-run",cwd:t,args:{direction:rJ.trim(),chapters:rV,chars:rK,noCover:!rq,json:!0,stage:e,storyId:rX||void 0}})});if(!r.ok)throw Error(`HTTP 异常 ${r.status}`);if(!r.body)throw Error("响应流为空");let n=r.body.getReader(),o=new TextDecoder,i="",l=null;for(;;){let{done:e,value:t}=await n.read();if(e)break;let r=(i+=o.decode(t,{stream:!0})).split("\n");for(let e of(i=r.pop()||"",r))if(e.trim())try{let t=JSON.parse(e);"stdout"===t.type||"stderr"===t.type?rF(e=>[...e,t.data||""]):"result"===t.type&&(l=t)}catch(e){console.error("Failed to parse stream chunk:",e)}}if(i.trim())try{let e=JSON.parse(i);"result"===e.type&&(l=e)}catch{}if(!l||!l.success)throw Error(l?.error||`${"outline"===e?"大纲规划":"draft"===e?"正文写作":"封面与包装"} 阶段任务执行失败`);let s=null;try{s=JSON.parse(l.stdout||"")}catch(e){console.error("Failed to parse short fiction result JSON:",e)}s&&s.storyId?(rQ(s.storyId),"outline"===e?(r_(`【第一步:生成大纲】执行完成!故事 ID 为: ${s.storyId}
5
+ 大纲与大纲评审文件已输出至 shorts/${s.storyId}/outline/v002.md,请查阅无误后点击下方【第二步】开始起草章节。`),r1("draft")):"draft"===e?(r_(`【第二步:批量起草】执行完成!故事 ID 为: ${s.storyId}
6
+ 所有章节的初稿已经全部起草完毕,文件输出在 shorts/${s.storyId}/final/full.md。点击下方【第三步】即可一键打包与制作封面。`),r1("package")):"package"===e&&(r_(`【第三步:生成书封包装】执行完成!
7
+ 故事销售包装和封面图文件已成功生成。至此,该短篇小说已全部创作完毕!`),r1("completed"))):r_("全自动短篇生成运行完成!已将成果输出至 shorts/ 目录下,请检查文件浏览器。"),window.dispatchEvent(new CustomEvent("refresh-explorer")),await nL(t)}catch(e){console.error(e),rP(e instanceof Error?e.message:String(e))}finally{rA(!1)}}},n_=async()=>{let e=d||T;if(e){nz(!0),nR(null);try{let t=await fetch("/api/inkos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"init",cwd:e})});if(!t.ok)throw Error(`HTTP 异常 ${t.status}`);if(!t.body)throw Error("响应正文流为空");let r=t.body.getReader(),n=new TextDecoder,o="",i=null;for(;;){let{done:e,value:t}=await r.read();if(e)break;let l=(o+=n.decode(t,{stream:!0})).split("\n");for(let e of(o=l.pop()||"",l))if(e.trim())try{let t=JSON.parse(e);"result"===t.type&&(i=t)}catch(e){}}if(o.trim())try{let e=JSON.parse(o);"result"===e.type&&(i=e)}catch(e){}if(!i||!i.success)throw Error(i?.error||"Failed to initialize workspace");await nL(e),Y(e=>e+1)}catch(e){console.error(e),nR(e.message||"初始化失败")}finally{nz(!1)}}};(0,o.useEffect)(()=>{let e=d||T;e?fetch("/api/register-cwd",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e})}).then(e=>{if(!e.ok)throw Error("Failed to register CWD");return e.json()}).then(()=>{e2(e),nL(e)}).catch(t=>{console.error("CWD registration failed:",t),e2(e),nL(e)}):(e2(null),eu(!0))},[d,T,nL,U]);let nJ=(0,o.useCallback)(async()=>{try{let e=await fetch("/api/gem-xy");if(!e.ok)throw Error("Failed to load Gem-xY profiles");let t=await e.json();Q(t)}catch(e){console.error(e)}},[]);(0,o.useEffect)(()=>{nJ()},[nJ]),(0,o.useEffect)(()=>{fetch("/api/models").then(e=>e.json()).then(e=>{e.modelList&&et(e.modelList),e.defaultModel&&en(e.defaultModel)}).catch(()=>{})},[]);let nU=(0,o.useCallback)(e=>{if(!T)return;let t="function"==typeof crypto.randomUUID?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}-${Math.random().toString(36).slice(2)}`;r?.(t,T,e)},[T,r]),nV=async(e,t)=>{if(e.stopPropagation(),confirm("确定要删除这个智能体吗?"))try{if(!(await fetch(`/api/gem-xy/${t}`,{method:"DELETE"})).ok)throw Error("Delete failed");nJ()}catch(e){console.error(e),alert("删除失败")}},[nY,nK]=(0,o.useState)(!1),[nG,nq]=(0,o.useState)(!1),nZ=(0,o.useRef)(null),nX=(0,o.useRef)(null),nQ=(0,o.useCallback)(async(e=!1)=>{try{e&&w(!0);let t=await fetch("/api/sessions");if(!t.ok)throw Error(`HTTP ${t.status}`);let r=await t.json();j(r.sessions),C(null),e||(nK(!0),nZ.current&&clearTimeout(nZ.current),nZ.current=setTimeout(()=>nK(!1),2e3))}catch(e){C(String(e))}finally{e&&w(!1)}},[]),n0=(0,o.useRef)(!1);(0,o.useEffect)(()=>{let e=!n0.current;n0.current=!0,nQ(e)},[nQ,s]),(0,o.useEffect)(()=>{void 0!==x&&Y(e=>e+1)},[x]),(0,o.useEffect)(()=>{fetch("/api/home").then(e=>e.json()).then(e=>{e.home&&R(e.home)}).catch(()=>{})},[]);let n1=(0,o.useRef)(!1);(0,o.useEffect)(()=>{c?.(T)},[T,c]),(0,o.useEffect)(()=>{if(T)try{let e=localStorage.getItem("ink-xy-recent-cwds"),t=[];e&&(t=JSON.parse(e)),Array.isArray(t)||(t=[]);let r=[T,...t.filter(e=>e!==T)].slice(0,10);localStorage.setItem("ink-xy-recent-cwds",JSON.stringify(r))}catch(e){console.error("Failed to save recent CWD to localStorage:",e)}},[T]),(0,o.useEffect)(()=>{let e=function(e){let t=new Map;for(let r of e){if(!r.cwd)continue;let e=t.get(r.cwd);(!e||r.modified>e)&&t.set(r.cwd,r.modified)}return[...t.entries()].sort((e,t)=>t[1].localeCompare(e[1])).slice(0,5).map(([e])=>e)}(m),t=[];try{let e=localStorage.getItem("ink-xy-recent-cwds");e&&(t=JSON.parse(e))}catch(e){}Array.isArray(t)||(t=[]);let r=[];try{let e=localStorage.getItem("ink-xy-deleted-cwds");e&&(r=JSON.parse(e))}catch(e){}Array.isArray(r)||(r=[]);let n=[...new Set([...e,...t])].filter(e=>!r.includes(e));if(0===n.length){e6([]),e8(!0);return}(async()=>{try{await fetch("/api/register-cwd",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwds:n})})}catch(e){console.error("Failed to register combined CWDs:",e)}e6((await Promise.all(n.map(async e=>{try{let t=await fetch(`/api/files/${$(e)}?type=list&check=true`);if(t.ok){let r=await t.json();return{cwd:e,exists:!1!==r.exists}}}catch(e){}return{cwd:e,exists:!1}}))).filter(e=>e.exists).map(e=>e.cwd)),e8(!0)})()},[m,T,U]),(0,o.useEffect)(()=>{if(0!==m.length&&null===T){if(i&&!n1.current){n1.current=!0;let e=m.find(e=>e.id===i);if(e){z(e.cwd),t(e,!0);return}l?.()}e5&&(e4.length>0?z(e4[0]):fetch("/api/default-cwd",{method:"POST"}).then(e=>e.json()).then(e=>{e.cwd&&z(e.cwd)}).catch(()=>{}))}},[m,T,i,t,l,e4,e5]);let n2=(0,o.useCallback)(()=>{let e=D.trim();if(e){z(e);try{let t=localStorage.getItem("ink-xy-deleted-cwds");if(t){let r=JSON.parse(t);Array.isArray(r)&&r.includes(e)&&(r=r.filter(t=>t!==e),localStorage.setItem("ink-xy-deleted-cwds",JSON.stringify(r)))}}catch(e){console.error("Failed to remove re-added path from deleted list:",e)}}M(!1),B(""),W(!1)},[D]),n4=(0,o.useCallback)(async()=>{try{let e=await fetch("/api/default-cwd",{method:"POST"}),t=await e.json();t.cwd&&(z(t.cwd),W(!1))}catch{}},[]),n6=(0,o.useCallback)(e=>{try{let t=localStorage.getItem("ink-xy-deleted-cwds"),r=[];t&&(r=JSON.parse(t)),Array.isArray(r)||(r=[]),r.includes(e)||(r.push(e),localStorage.setItem("ink-xy-deleted-cwds",JSON.stringify(r)))}catch(e){console.error("Failed to update deleted CWDs list:",e)}try{let t=localStorage.getItem("ink-xy-recent-cwds");if(t){let r=JSON.parse(t);if(Array.isArray(r)){let t=r.filter(t=>t!==e);localStorage.setItem("ink-xy-recent-cwds",JSON.stringify(t))}}}catch(e){console.error("Failed to remove CWD from localStorage:",e)}if(e6(t=>t.filter(t=>t!==e)),(d||T)===e){let t=e4.filter(t=>t!==e);t.length>0?z(t[0]):n4()}},[e4,d,T,n4]);(0,o.useEffect)(()=>{let e=e=>{F.current&&!F.current.contains(e.target)&&(W(!1),M(!1),B(""))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);let n5=(0,o.useCallback)(()=>{if(!T)return;let e="function"==typeof crypto.randomUUID?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}-${Math.random().toString(36).slice(2)}`;r?.(e,T)},[T,r]),n8=T?m.filter(e=>e.cwd===T):m,n3=function(e){let t=new Map;for(let r of e)t.set(r.id,{session:r,children:[]});let r=new Map;for(let t of e)t.parentSessionId&&r.set(t.id,t.parentSessionId);let n=[];for(let e of t.values()){let o=function(e){let n=r.get(e),o=new Set;for(;n&&!o.has(n);){if(o.add(n),t.has(n))return n;n=r.get(n)}return null}(e.session.id);o?t.get(o).children.push(e):n.push(e)}let o=e=>{e.sort((e,t)=>{let r=+!!e.session.locked,n=+!!t.session.locked;return r!==n?n-r:t.session.modified.localeCompare(e.session.modified)}),e.forEach(e=>o(e.children))};return o(n),n}(n8);return(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"},children:[(0,n.jsxs)("div",{style:{padding:"12px 10px 10px",borderBottom:"1px solid var(--border)",flexShrink:0},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:10},children:[(0,n.jsx)(q,{}),(0,n.jsxs)("div",{style:{display:"flex",gap:6},children:[(0,n.jsxs)("button",{onClick:n5,disabled:!T,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:5,background:"var(--bg-hover)",border:"1px solid var(--border)",color:T?"var(--text-muted)":"var(--text-dim)",cursor:T?"pointer":"not-allowed",height:32,paddingLeft:10,paddingRight:12,borderRadius:7,fontSize:12,fontWeight:500,letterSpacing:"-0.01em",flexShrink:0,transition:"background 0.12s, color 0.12s, border-color 0.12s"},title:T?"在新协同会话中写作":"请先选择创作工作区",onMouseEnter:e=>{T&&(e.currentTarget.style.background="var(--bg-selected)",e.currentTarget.style.color="var(--accent)",e.currentTarget.style.borderColor="rgba(37,99,235,0.35)")},onMouseLeave:e=>{e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color=T?"var(--text-muted)":"var(--text-dim)",e.currentTarget.style.borderColor="var(--border)"},children:[(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",children:[(0,n.jsx)("line",{x1:"6",y1:"1",x2:"6",y2:"11"}),(0,n.jsx)("line",{x1:"1",y1:"6",x2:"11",y2:"6"})]}),"新会话"]}),(0,n.jsx)("button",{onClick:()=>nQ(!1),style:{display:"flex",alignItems:"center",justifyContent:"center",background:nY?"rgba(74,222,128,0.18)":"var(--bg-hover)",border:`1px solid ${nY?"rgba(74,222,128,0.4)":"var(--border)"}`,color:nY?"#4ade80":"var(--text-muted)",cursor:"pointer",width:32,height:32,borderRadius:7,padding:0,flexShrink:0,transition:"background 0.3s, color 0.3s, border-color 0.3s"},onMouseEnter:e=>{nY||(e.currentTarget.style.background="var(--bg-selected)",e.currentTarget.style.color="var(--accent)",e.currentTarget.style.borderColor="rgba(37,99,235,0.35)")},onMouseLeave:e=>{nY||(e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color="var(--text-muted)",e.currentTarget.style.borderColor="var(--border)")},title:"刷新会话",children:nY?(0,n.jsx)("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"#4ade80",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("polyline",{points:"20 6 9 17 4 12"})}):(0,n.jsxs)("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}),(0,n.jsx)("path",{d:"M3 3v5h5"})]})})]})]}),(0,n.jsxs)("div",{ref:F,style:{position:"relative"},children:[(0,n.jsx)("button",{onClick:()=>W(e=>!e),style:{width:"100%",display:"flex",alignItems:"center",padding:"6px 10px",background:T?"var(--bg-hover)":"rgba(37,99,235,0.06)",border:T?"1px solid var(--border)":"1px solid rgba(37,99,235,0.4)",borderRadius:7,cursor:"pointer",fontSize:12,color:"var(--text)",textAlign:"left",transition:"border-color 0.15s, background 0.15s"},children:(0,n.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontFamily:"var(--font-mono)",fontSize:11,color:T?"var(--text)":"var(--text-dim)"},title:T??"",children:T?K(T,I):i&&!n1.current?"":"选择创作目录…"})}),L&&(0,n.jsxs)("div",{style:{position:"absolute",top:"calc(100% + 4px)",left:0,right:0,zIndex:100,background:"var(--bg)",border:"1px solid var(--border)",borderRadius:8,boxShadow:"0 6px 20px rgba(0,0,0,0.10)",overflow:"hidden"},children:[e4.map(e=>(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%",background:e===T?"var(--bg-selected)":"none",borderBottom:"1px solid var(--border)",transition:"background 0.2s"},onMouseEnter:t=>{e!==T&&(t.currentTarget.style.background="var(--bg-panel)")},onMouseLeave:t=>{e!==T&&(t.currentTarget.style.background="none")},children:[(0,n.jsxs)("button",{onClick:()=>{z(e),M(!1),B(""),W(!1)},style:{display:"flex",alignItems:"center",gap:7,flex:1,padding:"8px 10px",background:"none",border:"none",color:e===T?"var(--text)":"var(--text-muted)",cursor:"pointer",textAlign:"left",fontSize:11,fontFamily:"var(--font-mono)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:e,children:[e===T&&(0,n.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"var(--accent)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:(0,n.jsx)("polyline",{points:"1.5 5 4 7.5 8.5 2.5"})}),e!==T&&(0,n.jsx)("span",{style:{width:10,flexShrink:0}}),(0,n.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:K(e,I)})]}),(0,n.jsx)("button",{onClick:t=>{t.stopPropagation(),n6(e)},title:"从列表中移除该路径",style:{display:"flex",alignItems:"center",justifyContent:"center",width:20,height:20,marginRight:6,background:"none",border:"none",color:"var(--text-dim)",cursor:"pointer",borderRadius:4,transition:"color 0.2s, background 0.2s"},onMouseEnter:e=>{e.currentTarget.style.color="#ef4444",e.currentTarget.style.background="rgba(239, 68, 68, 0.08)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-dim)",e.currentTarget.style.background="none"},children:(0,n.jsxs)("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,n.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},e)),!E&&(0,n.jsxs)("button",{onClick:e=>{e.stopPropagation(),n4()},style:{display:"flex",alignItems:"center",gap:7,width:"100%",padding:"8px 10px",background:"none",border:"none",borderTop:e4.length>0?"1px solid var(--border)":"none",color:"var(--text-muted)",cursor:"pointer",textAlign:"left",fontSize:11},children:[(0,n.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.1",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:(0,n.jsx)("path",{d:"M1 3A1 1 0 0 1 2 2H4L5 3.5H8.5a.5.5 0 0 1 .5.5v4a.5.5 0 0 1-.5.5h-7A.5.5 0 0 1 1 8V3Z"})}),(0,n.jsx)("span",{children:"使用默认创作目录"})]}),E?(0,n.jsxs)("div",{style:{padding:"6px 8px",borderTop:e4.length>0?"none":void 0},children:[(0,n.jsx)("input",{ref:A,value:D,onChange:e=>B(e.target.value),onKeyDown:e=>{"Enter"===e.key&&n2(),"Escape"===e.key&&(M(!1),B(""))},placeholder:"/path/to/project",style:{width:"100%",fontSize:11,fontFamily:"var(--font-mono)",padding:"5px 8px",border:"1px solid var(--accent)",borderRadius:5,outline:"none",background:"var(--bg)",color:"var(--text)",boxSizing:"border-box"}}),(0,n.jsxs)("div",{style:{display:"flex",gap:5,marginTop:5},children:[(0,n.jsx)("button",{onClick:n2,style:{flex:1,padding:"4px 0",background:"var(--accent)",border:"none",borderRadius:5,color:"#fff",fontSize:11,fontWeight:600,cursor:"pointer"},children:"打开"}),(0,n.jsx)("button",{onClick:()=>{M(!1),B("")},style:{flex:1,padding:"4px 0",background:"var(--bg-hover)",border:"1px solid var(--border)",borderRadius:5,color:"var(--text-muted)",fontSize:11,cursor:"pointer"},children:"取消"})]})]}):(0,n.jsxs)("button",{onClick:e=>{e.stopPropagation(),M(!0),setTimeout(()=>A.current?.focus(),0)},style:{display:"flex",alignItems:"center",gap:7,width:"100%",padding:"8px 10px",background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",textAlign:"left",fontSize:11},children:[(0,n.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.1",strokeLinecap:"round",style:{flexShrink:0},children:[(0,n.jsx)("line",{x1:"5",y1:"1",x2:"5",y2:"9"}),(0,n.jsx)("line",{x1:"1",y1:"5",x2:"9",y2:"5"})]}),(0,n.jsx)("span",{children:"自定义路径…"})]})]})]})]}),(d||T)&&(0,n.jsxs)("div",{style:{borderBottom:"1px solid var(--border)",display:"flex",flexDirection:"column",flex:N?"1 1 0":"0 0 auto",minHeight:0,overflow:"hidden"},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",flexShrink:0},children:[(0,n.jsxs)("button",{onClick:()=>J(e=>!e),style:{display:"flex",alignItems:"center",gap:6,flex:1,padding:"8px 10px",background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",fontSize:11,fontWeight:600,letterSpacing:"0.05em",textTransform:"uppercase",textAlign:"left"},children:[(0,n.jsx)("svg",{width:"9",height:"9",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",style:{transform:N?"rotate(90deg)":"none",transition:"transform 0.15s",flexShrink:0},children:(0,n.jsx)("polyline",{points:"3 2 7 5 3 8"})}),"创作目录 (Workspace)"]}),ex&&(0,n.jsxs)("div",{style:{display:"flex",gap:2},children:[eg&&(0,n.jsx)("button",{onClick:()=>{te(!0),tc(null),ta(null),tx([])},title:"导出小说书稿 (Export Book)",style:{display:"flex",alignItems:"center",justifyContent:"center",width:26,height:26,padding:0,background:"none",border:"none",color:"var(--text-dim)",cursor:"pointer",borderRadius:5,flexShrink:0,transition:"color 0.3s, background 0.3s"},onMouseEnter:e=>{e.currentTarget.style.color="var(--text-muted)",e.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-dim)",e.currentTarget.style.background="none"},children:(0,n.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),(0,n.jsx)("polyline",{points:"17 8 12 3 7 8"}),(0,n.jsx)("line",{x1:"12",y1:"3",x2:"12",y2:"15"})]})}),rl&&(0,n.jsx)("button",{onClick:()=>{rp(!0),rj(null),rv(null),rb([]),ru("")},title:"刷新同人原作背景设定 (Refresh Fanfic Canon)",style:{display:"flex",alignItems:"center",justifyContent:"center",width:26,height:26,padding:0,background:"none",border:"none",color:"var(--text-dim)",cursor:"pointer",borderRadius:5,flexShrink:0,transition:"color 0.3s, background 0.3s"},onMouseEnter:e=>{e.currentTarget.style.color="var(--text-muted)",e.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-dim)",e.currentTarget.style.background="none"},children:(0,n.jsx)("span",{style:{fontSize:13},children:"\uD83C\uDFAC"})}),(0,n.jsx)("button",{onClick:()=>{th(!0),t$(null),tM(null),tW([]),tv(""),tj(""),tw(""),tC(!1),tF(tB.length>0?"active":"new"),tP(""),t_(""),tz(tB.find(e=>e!==eO)||"")},title:"导入设定或旧章原稿 (Import Canon/Chapters)",style:{display:"flex",alignItems:"center",justifyContent:"center",width:26,height:26,padding:0,marginRight:6,background:"none",border:"none",color:"var(--text-dim)",cursor:"pointer",borderRadius:5,flexShrink:0,transition:"color 0.3s, background 0.3s"},onMouseEnter:e=>{e.currentTarget.style.color="var(--text-muted)",e.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-dim)",e.currentTarget.style.background="none"},children:(0,n.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),(0,n.jsx)("polyline",{points:"7 10 12 15 17 10"}),(0,n.jsx)("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]})})]}),(0,n.jsx)("button",{onClick:()=>{Y(e=>e+1),nq(!0),nX.current&&clearTimeout(nX.current),nX.current=setTimeout(()=>nq(!1),2e3)},title:"刷新创作目录",style:{display:"flex",alignItems:"center",justifyContent:"center",width:26,height:26,padding:0,marginRight:6,background:nG?"rgba(74,222,128,0.18)":"none",border:"none",color:nG?"#4ade80":"var(--text-dim)",cursor:"pointer",borderRadius:5,flexShrink:0,transition:"color 0.3s, background 0.3s"},onMouseEnter:e=>{nG||(e.currentTarget.style.color="var(--text-muted)",e.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:e=>{nG||(e.currentTarget.style.color="var(--text-dim)",e.currentTarget.style.background="none")},children:nG?(0,n.jsx)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"#4ade80",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("polyline",{points:"20 6 9 17 4 12"})}):(0,n.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}),(0,n.jsx)("path",{d:"M3 3v5h5"})]})})]}),N&&(0,n.jsxs)("div",{style:{flex:1,overflowY:"auto",overflowX:"hidden",display:"flex",flexDirection:"column"},children:[!ex&&(0,n.jsxs)("div",{style:{margin:"8px 10px",padding:"12px",background:"var(--bg-panel)",border:"1px dashed var(--accent)",borderRadius:"8px",fontSize:"11px",fontFamily:"var(--font-serif)"},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,fontWeight:600,color:"var(--text)",marginBottom:6},children:[(0,n.jsx)("span",{style:{fontSize:13},children:"✒️"}),(0,n.jsx)("span",{children:"未初始化的创作空间"})]}),(0,n.jsx)("div",{style:{color:"var(--text-muted)",lineHeight:1.5,marginBottom:8},children:"该目录尚未创建 InkOS 小说项目结构。一键初始化以启用自动章节规划、人设审计与快照防崩系统。"}),nI&&(0,n.jsxs)("div",{style:{color:"#ef4444",marginBottom:8,fontSize:10},children:["⚠️ ",nI]}),(0,n.jsx)("button",{onClick:n_,disabled:nT,style:{width:"100%",padding:"6px 0",background:"var(--accent)",border:"none",borderRadius:"6px",color:"white",fontWeight:600,cursor:nT?"not-allowed":"pointer",opacity:nT?.7:1,textAlign:"center",transition:"opacity 0.15s"},children:nT?"正在开启小说宇宙...":"一键开启创作宇宙"})]}),ex&&(0,n.jsxs)("div",{style:{margin:"8px 10px",padding:"12px",background:"var(--bg-panel)",border:"1px dashed var(--accent)",borderRadius:"8px",fontSize:"11px",fontFamily:"var(--font-serif)"},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,fontWeight:600,color:"var(--text)",marginBottom:6},children:[(0,n.jsx)("span",{style:{fontSize:13},children:"\uD83D\uDCDA"}),(0,n.jsx)("span",{children:eg?"创建新小说书籍":"小说宇宙内尚无书籍"})]}),(0,n.jsx)("div",{style:{color:"var(--text-muted)",lineHeight:1.5,marginBottom:8},children:eg?"在当前创作宇宙中创建另一本新书。新书将拥有独立的设定大纲、章节规划和人设体系。":"在 InkOS 中,设定与大纲是以“书籍”为单位存储的。立即创建您的第一本书,AI 架构师将为您搭建创作地基。"}),(0,n.jsxs)("div",{style:{display:"flex",gap:8,marginTop:4},children:[(0,n.jsx)("button",{onClick:()=>ew(!0),style:{flex:1,padding:"6px 0",background:"var(--accent)",border:"none",borderRadius:"6px",color:"white",fontWeight:600,cursor:"pointer",textAlign:"center",fontSize:"11px",transition:"opacity 0.15s"},children:eg?"➕ 创建新书籍":"✍️ 创建小说书籍"}),!eg&&ey&&(0,n.jsx)("button",{onClick:()=>{th(!0),t$(null),tM(null),tW([]),tv(""),tj(""),tw(""),tC(!1),tF("new"),tP(""),t_(""),tz(tB.find(e=>e!==eO)||"")},style:{flex:1,padding:"6px 0",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:"6px",color:"var(--text)",fontWeight:600,cursor:"pointer",textAlign:"center",fontSize:"11px",transition:"opacity 0.15s"},children:"\uD83D\uDCE5 导入已有旧稿"})]}),!eg&&em&&(0,n.jsx)("button",{onClick:()=>{r$(!0),rP(null),r_(null),rF([]),rU(""),rY(12),rG(1e3),rZ(!0)},style:{width:"100%",marginTop:8,padding:"6px 0",background:"rgba(139, 92, 246, 0.08)",border:"1px solid rgba(139, 92, 246, 0.3)",borderRadius:"6px",color:"#a78bfa",fontWeight:600,cursor:"pointer",textAlign:"center",fontSize:"11px",transition:"all 0.15s"},onMouseEnter:e=>{e.currentTarget.style.background="rgba(139, 92, 246, 0.16)",e.currentTarget.style.borderColor="rgba(139, 92, 246, 0.5)",e.currentTarget.style.color="#c084fc"},onMouseLeave:e=>{e.currentTarget.style.background="rgba(139, 92, 246, 0.08)",e.currentTarget.style.borderColor="rgba(139, 92, 246, 0.3)",e.currentTarget.style.color="#a78bfa"},children:"\uD83D\uDE80 一键全自动生成短篇"})]}),ex&&eg&&!eD&&(0,n.jsxs)("div",{style:{margin:"8px 10px",padding:"12px",background:"var(--bg-panel)",border:"1px dashed var(--accent)",borderRadius:"8px",fontSize:"11px",fontFamily:"var(--font-serif)"},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,fontWeight:600,color:"var(--text)",marginBottom:6},children:[(0,n.jsx)("span",{style:{fontSize:13},children:"✍️"}),(0,n.jsx)("span",{children:"书籍已创建,准备开始首章创作"})]}),(0,n.jsx)("div",{style:{color:"var(--text-muted)",lineHeight:1.5,marginBottom:8},children:eB?"第一章蓝图已规划完成!点击下方按钮,由 AI 协同起草第一章正文,拉开故事序幕。":"您的创作宇宙和人设基础已准备就绪!开始写作前,请先点击下方按钮规划首章蓝图,确立开篇方向。"}),(0,n.jsxs)("div",{style:{display:"flex",gap:8,marginTop:4},children:[eB?(0,n.jsx)("button",{onClick:nO,disabled:eP,style:{flex:1,padding:"6px 0",background:"var(--accent)",border:"none",borderRadius:"6px",color:"white",fontWeight:600,cursor:eP?"not-allowed":"pointer",textAlign:"center",fontSize:"11px",transition:"opacity 0.15s"},children:"✍️ 智能写作"}):(0,n.jsx)("button",{onClick:nA,disabled:eP,style:{flex:1,padding:"6px 0",background:"var(--accent)",border:"none",borderRadius:"6px",color:"white",fontWeight:600,cursor:eP?"not-allowed":"pointer",textAlign:"center",fontSize:"11px",transition:"opacity 0.15s"},children:"\uD83D\uDDFA️ 规划首章蓝图"}),ey&&(0,n.jsx)("button",{onClick:()=>{th(!0),t$(null),tM(null),tW([]),tv(""),tj(""),tw(""),tC(!1),tz(tB.find(e=>e!==eO)||"")},disabled:eP,style:{flex:1,padding:"6px 0",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:"6px",color:"var(--text)",fontWeight:600,cursor:eP?"not-allowed":"pointer",textAlign:"center",fontSize:"11px",transition:"opacity 0.15s"},children:"\uD83D\uDCE5 导入已有旧稿"})]}),em&&(0,n.jsx)("button",{onClick:()=>{r$(!0),rP(null),r_(null),rF([]),rU(""),rY(12),rG(1e3),rZ(!0)},style:{width:"calc(100% - 20px)",margin:"8px 10px 0 10px",padding:"6px 0",background:"rgba(139, 92, 246, 0.08)",border:"1px solid rgba(139, 92, 246, 0.3)",borderRadius:"6px",color:"#a78bfa",fontWeight:600,cursor:"pointer",textAlign:"center",fontSize:"11px",transition:"all 0.15s"},onMouseEnter:e=>{e.currentTarget.style.background="rgba(139, 92, 246, 0.16)",e.currentTarget.style.borderColor="rgba(139, 92, 246, 0.5)",e.currentTarget.style.color="#c084fc"},onMouseLeave:e=>{e.currentTarget.style.background="rgba(139, 92, 246, 0.08)",e.currentTarget.style.borderColor="rgba(139, 92, 246, 0.3)",e.currentTarget.style.color="#a78bfa"},children:"\uD83D\uDE80 一键全自动生成短篇"})]}),e1===(d??T)&&(0,n.jsxs)("div",{style:{flex:1,display:"flex",flexDirection:"column",minHeight:0,overflow:"hidden"},children:[(0,n.jsxs)("div",{style:{margin:"8px 10px",padding:"8px 10px",background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:"8px",display:"flex",alignItems:"center",gap:"8px",fontSize:"12px",fontFamily:"var(--font-serif)",flexShrink:0},children:[(0,n.jsx)("span",{style:{color:"var(--text-muted)",flexShrink:0},children:"当前书籍:"}),(0,n.jsx)("select",{value:eO||"",onChange:e=>{let t=e.target.value;eF(t);let r=d||T;r&&nL(r,t)},style:{flex:1,background:"var(--bg)",border:"1px solid var(--border)",borderRadius:"5px",padding:"3px 6px",fontSize:"12px",fontFamily:"var(--font-serif)",color:"var(--text)",outline:"none",cursor:"pointer",minWidth:0},children:tB.map(e=>(0,n.jsx)("option",{value:e,children:e},e))}),(0,n.jsx)("button",{onClick:()=>{eM(null),eR(!0)},title:"删除当前书籍 (Delete Book)",style:{display:"flex",alignItems:"center",justifyContent:"center",width:24,height:24,padding:0,background:"none",border:"none",color:"var(--text-dim)",cursor:"pointer",borderRadius:4,transition:"color 0.2s, background-color 0.2s"},onMouseEnter:e=>{e.currentTarget.style.color="#ef4444",e.currentTarget.style.background="rgba(239, 68, 68, 0.08)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-dim)",e.currentTarget.style.background="none"},children:(0,n.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("polyline",{points:"3 6 5 6 21 6"}),(0,n.jsx)("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}),(0,n.jsx)("line",{x1:"10",y1:"11",x2:"10",y2:"17"}),(0,n.jsx)("line",{x1:"14",y1:"11",x2:"14",y2:"17"})]})})]}),r4&&(0,n.jsxs)("div",{style:{margin:"8px 10px",padding:"10px 12px",background:"rgba(249, 115, 22, 0.04)",border:"1px solid rgba(249, 115, 22, 0.25)",borderRadius:"8px",fontSize:"11px",fontFamily:"var(--font-serif)",boxShadow:"0 2px 8px rgba(249, 115, 22, 0.05)",flexShrink:0},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,fontWeight:600,color:"#e07a34",marginBottom:4},children:[(0,n.jsx)("span",{style:{fontSize:13},children:"\uD83D\uDDDC️"}),(0,n.jsx)("span",{children:"建议进行大纲摘要压缩"})]}),(0,n.jsxs)("div",{style:{color:"var(--text-muted)",lineHeight:1.5,marginBottom:8},children:["检测到完结卷 ",(0,n.jsx)("strong",{children:r5}),",建议运行压缩归档以优化大语言模型上下文,防止远期伏笔记忆衰退。"]}),(0,n.jsx)("button",{onClick:nE,disabled:r3,style:{width:"100%",padding:"5px 0",background:"rgba(249, 115, 22, 0.08)",border:"1px solid rgba(249, 115, 22, 0.35)",borderRadius:"6px",color:"#ff903f",fontWeight:600,cursor:r3?"not-allowed":"pointer",textAlign:"center",fontSize:"11px",transition:"all 0.2s"},onMouseEnter:e=>{r3||(e.currentTarget.style.background="rgba(249, 115, 22, 0.16)",e.currentTarget.style.borderColor="#f97316",e.currentTarget.style.color="#ffaa64")},onMouseLeave:e=>{r3||(e.currentTarget.style.background="rgba(249, 115, 22, 0.08)",e.currentTarget.style.borderColor="rgba(249, 115, 22, 0.35)",e.currentTarget.style.color="#ff903f")},children:r3?"正在压缩...":"\uD83D\uDDDC️ 一键压缩归档"})]}),rl&&(0,n.jsxs)("div",{style:{margin:"0 10px 8px 10px",padding:"8px 12px",background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:"8px",fontSize:"11px",display:"flex",alignItems:"center",justifyContent:"space-between",flexShrink:0,boxShadow:"0 1px 3px rgba(0,0,0,0.02)"},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,color:"var(--text-muted)"},children:[(0,n.jsx)("span",{style:{fontSize:13},children:"\uD83C\uDFAC"}),(0,n.jsx)("span",{children:"同人创作模式:"}),(0,n.jsx)("strong",{style:{color:"var(--accent)",fontWeight:600},children:"canon"===ra?"正典延续":"au"===ra?"平行宇宙":"ooc"===ra?"角色偏离":"cp"===ra?"角色配对":ra||"未知"})]}),(0,n.jsx)("button",{onClick:()=>{rp(!0),rj(null),rv(null),rb([]),ru("")},style:{padding:"2px 6px",background:"var(--bg)",color:"var(--text)",border:"1px solid var(--border)",borderRadius:"4px",fontSize:"10px",outline:"none",cursor:"pointer",fontWeight:500,transition:"all 0.15s"},onMouseEnter:e=>{e.currentTarget.style.borderColor="var(--accent)"},onMouseLeave:e=>{e.currentTarget.style.borderColor="var(--border)"},children:"\uD83D\uDD04 刷新设定"})]}),(0,n.jsx)("div",{style:{flex:1,overflowY:"auto"},children:(0,n.jsx)(P,{cwd:d??T,onOpenFile:p??(()=>{}),refreshKey:U,onAtMention:u,chapterStatusMap:e3})})]})]})]}),(d||T)&&(0,n.jsxs)("div",{style:{flexShrink:0,paddingBottom:6},children:[(0,n.jsxs)("div",{onClick:()=>ed(!ea),style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 10px 4px",color:"var(--text-muted)",cursor:"pointer",fontSize:11,fontWeight:600,letterSpacing:"0.05em",textTransform:"uppercase"},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[(0,n.jsx)("svg",{width:"9",height:"9",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",style:{transform:ea?"rotate(90deg)":"none",transition:"transform 0.15s",flexShrink:0},children:(0,n.jsx)("polyline",{points:"3 2 7 5 3 8"})}),(0,n.jsx)("span",{children:"AI 写作伴侣 (Co-writers)"})]}),(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),es(null),ei(!0)},title:"配置专属写作姬",style:{background:"none",border:"none",color:"var(--text-dim)",cursor:"pointer",padding:"2px 6px",borderRadius:4,fontSize:10,display:"flex",alignItems:"center",gap:2},onMouseEnter:e=>{e.currentTarget.style.color="var(--accent)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-dim)"},children:"+ Create"})]}),ea&&(0,n.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:2,padding:"0 6px",maxHeight:240,overflowY:"auto"},children:0===G.length?(0,n.jsx)("div",{style:{padding:"6px 10px",color:"var(--text-dim)",fontSize:11,fontStyle:"italic"},children:"暂无写作姬,点击 Create 配置"}):G.map(t=>{let r=g===t.id&&!e,o=t.id.startsWith("default-");return(0,n.jsxs)("div",{onClick:()=>nU(t.id),title:t.description||void 0,style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"6px 8px",borderRadius:6,background:r?"var(--bg-selected)":"transparent",cursor:"pointer",fontSize:12,transition:"all 0.12s"},className:"gem-sidebar-item",onMouseEnter:e=>{r||(e.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:e=>{r||(e.currentTarget.style.background="transparent")},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,minWidth:0},children:[(0,n.jsx)("span",{style:{fontSize:14,flexShrink:0},children:t.avatar||"\uD83D\uDD2E"}),(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",minWidth:0},children:[(0,n.jsx)("span",{style:{color:r?"var(--accent)":"var(--text)",fontWeight:r?600:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.name}),t.description&&(0,n.jsx)("span",{style:{fontSize:10,color:"var(--text-dim)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.description})]})]}),!o&&(0,n.jsxs)("div",{className:"gem-actions",style:{display:"flex",gap:4,flexShrink:0,opacity:0,transition:"opacity 0.15s"},children:[(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),es(t.id),ei(!0)},title:"编辑",style:{background:"none",border:"none",color:"var(--text-dim)",cursor:"pointer",padding:2},onMouseEnter:e=>{e.currentTarget.style.color="var(--text)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-dim)"},children:"✎"}),(0,n.jsx)("button",{onClick:e=>nV(e,t.id),title:"删除",style:{background:"none",border:"none",color:"var(--text-dim)",cursor:"pointer",padding:2},onMouseEnter:e=>{e.currentTarget.style.color="#ef4444"},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-dim)"},children:"\uD83D\uDDD1"})]})]},t.id)})})]}),(d||T)&&(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",flexShrink:0,borderTop:"1px solid var(--border)",height:ec?"auto":"35px",boxSizing:"border-box",justifyContent:ec?"flex-start":"center"},children:[(0,n.jsx)("div",{onClick:()=>ep(!ec),style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:ec?"8px 10px 4px":"0 10px",color:"var(--text-muted)",cursor:"pointer",fontSize:11,fontWeight:600,letterSpacing:"0.05em",textTransform:"uppercase"},children:(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[(0,n.jsx)("svg",{width:"9",height:"9",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",style:{transform:ec?"rotate(90deg)":"none",transition:"transform 0.15s",flexShrink:0},children:(0,n.jsx)("polyline",{points:"3 2 7 5 3 8"})}),(0,n.jsx)("span",{children:"AI 协同历史 (AI Chats)"})]})}),ec&&(0,n.jsxs)("div",{style:{maxHeight:160,overflowY:"auto",padding:"0"},children:[k&&(0,n.jsx)("div",{style:{padding:"12px 14px",color:"var(--text-muted)",fontSize:11},children:"Loading..."}),S&&(0,n.jsx)("div",{style:{padding:"12px 14px",color:"#f87171",fontSize:11},children:S}),!k&&!S&&0===n8.length&&(0,n.jsx)("div",{style:{padding:"12px 14px",color:"var(--text-muted)",fontSize:11},children:"无历史协同会话"}),n3.map(r=>(0,n.jsx)(X,{node:r,selectedSessionId:e,onSelectSession:t,onRenamed:nQ,onSessionDeleted:e=>{a?.(e),nQ()},depth:0},r.session.id))]})]}),(0,n.jsx)("style",{children:`
8
8
  .gem-sidebar-item:hover .gem-actions {
9
9
  opacity: 1 !important;
10
10
  }
@@ -12,7 +12,7 @@
12
12
  0% { transform: rotate(0deg); }
13
13
  100% { transform: rotate(360deg); }
14
14
  }
15
- `}),(0,n.jsx)(V,{isOpen:en,onClose:()=>eo(!1),gemId:ei,onSave:()=>n_(),modelList:Q,defaultModel:et}),eI&&(0,n.jsx)("div",{style:{position:"fixed",inset:0,zIndex:999,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.5)",backdropFilter:"blur(4px)"},children:(0,n.jsxs)("div",{style:{background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:"12px",width:"min(420px, 90vw)",padding:"20px",boxShadow:"0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1)",fontFamily:"var(--font-serif)"},children:[(0,n.jsxs)("h3",{style:{margin:"0 0 12px",fontSize:"15px",fontWeight:600,color:"#ef4444",display:"flex",alignItems:"center",gap:8,borderBottom:"1px solid var(--border)",paddingBottom:"10px"},children:[(0,n.jsx)("span",{children:"⚠️"}),(0,n.jsx)("span",{children:"删除书籍确认 (Delete Book)"})]}),eR?(0,n.jsxs)("div",{style:{padding:"20px 10px",textAlign:"center"},children:[(0,n.jsx)("div",{style:{width:"30px",height:"30px",border:"3px solid var(--border)",borderTopColor:"#ef4444",borderRadius:"50%",animation:"spin 1s linear infinite",margin:"0 auto 16px"}}),(0,n.jsx)("div",{style:{fontWeight:600,color:"var(--text)",fontSize:"12px"},children:"正在彻底删除书籍及相关数据..."})]}):(0,n.jsxs)("div",{children:[eW&&(0,n.jsxs)("div",{style:{background:"rgba(239, 68, 68, 0.08)",border:"1px solid rgba(239, 68, 68, 0.2)",borderRadius:"6px",padding:"10px",color:"#ef4444",fontSize:"11px",marginBottom:"16px",lineHeight:1.5},children:["⚠️ ",eW]}),(0,n.jsxs)("p",{style:{fontSize:"12px",color:"var(--text)",lineHeight:1.6,margin:"0 0 16px"},children:["您确定要永久删除书籍 ",(0,n.jsx)("strong",{style:{color:"#ef4444"},children:eA})," 吗?"]}),(0,n.jsxs)("div",{style:{background:"rgba(239, 68, 68, 0.04)",border:"1px dashed rgba(239, 68, 68, 0.25)",borderRadius:"8px",padding:"10px 12px",fontSize:"11px",color:"var(--text-muted)",lineHeight:1.5,marginBottom:"20px"},children:[(0,n.jsx)("strong",{children:"此操作不可逆!"})," 它将永久清除:",(0,n.jsxs)("ul",{style:{margin:"4px 0 0",paddingLeft:"16px"},children:[(0,n.jsx)("li",{children:"该书的所有章节草稿正文"}),(0,n.jsx)("li",{children:"人物卡片设定与世界观设定"}),(0,n.jsx)("li",{children:"所有的历史修订版本快照与大纲"})]})]}),(0,n.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",gap:"10px"},children:[(0,n.jsx)("button",{type:"button",onClick:()=>ez(!1),style:{padding:"6px 14px",border:"1px solid var(--border)",borderRadius:"6px",background:"transparent",color:"var(--text-muted)",fontSize:"12px",cursor:"pointer"},children:"取消"}),(0,n.jsx)("button",{type:"button",onClick:nO,style:{padding:"6px 16px",background:"#ef4444",border:"none",borderRadius:"6px",color:"white",fontSize:"12px",fontWeight:600,cursor:"pointer"},children:"确认删除"})]})]})]})}),ej&&(0,n.jsx)("div",{style:{position:"fixed",inset:0,zIndex:999,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.5)",backdropFilter:"blur(4px)"},children:(0,n.jsxs)("div",{style:{background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:"12px",width:"min(480px, 90vw)",padding:"20px",boxShadow:"0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1)",fontFamily:"var(--font-serif)"},children:[(0,n.jsxs)("h3",{style:{margin:"0 0 16px",fontSize:"15px",fontWeight:600,color:"var(--text)",display:"flex",alignItems:"center",gap:8,borderBottom:"1px solid var(--border)",paddingBottom:"10px"},children:[(0,n.jsx)("span",{children:"\uD83D\uDCDA"}),(0,n.jsx)("span",{children:"创建新小说书籍 (Create Book)"})]}),ew?(0,n.jsxs)("div",{style:{padding:"30px 10px",textAlign:"center"},children:[(0,n.jsx)("div",{style:{width:"36px",height:"36px",border:"3px solid var(--border)",borderTopColor:"var(--accent)",borderRadius:"50%",animation:"spin 1s linear infinite",margin:"0 auto 16px"}}),(0,n.jsx)("div",{style:{fontWeight:600,color:"var(--text)",marginBottom:8,fontSize:"13px"},children:"正在生成创作宇宙基础设定..."}),(0,n.jsx)("div",{style:{color:"var(--text-muted)",fontSize:"11px",lineHeight:1.6,maxWidth:"300px",margin:"0 auto"},children:"AI 架构师正在分析题材大纲,并自动构建卷大纲、角色设定卡片与世界观法则,请稍候约 30 秒。"})]}):(0,n.jsxs)("form",{onSubmit:nF,children:[eC&&(0,n.jsxs)("div",{style:{background:"rgba(239, 68, 68, 0.08)",border:"1px solid rgba(239, 68, 68, 0.2)",borderRadius:"6px",padding:"10px",color:"#ef4444",fontSize:"11px",marginBottom:"16px",lineHeight:1.5},children:["⚠️ ",eC]}),ny||nv?(0,n.jsxs)("div",{style:{background:"var(--bg)",border:"1px solid var(--border)",borderRadius:"8px",padding:"12px",marginBottom:"16px",fontSize:"12px"},children:[(0,n.jsx)("div",{style:{fontWeight:600,color:"var(--text)",marginBottom:"8px",display:"flex",alignItems:"center",gap:6},children:(0,n.jsx)("span",{children:"\uD83D\uDD0D 检测到本地创作设定,请选择是否作为新书创建基础:"})}),(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[ny&&(0,n.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",color:"var(--text)"},children:[(0,n.jsx)("input",{type:"checkbox",checked:nj,onChange:e=>nk(e.target.checked),style:{cursor:"pointer"}}),(0,n.jsxs)("span",{children:["小说框架:",(0,n.jsx)("code",{style:{fontFamily:"var(--font-mono)",fontSize:"11px",color:"var(--accent)"},children:ny.name})]})]}),nv&&(0,n.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",color:"var(--text)"},children:[(0,n.jsx)("input",{type:"checkbox",checked:nw,onChange:e=>nS(e.target.checked),style:{cursor:"pointer"}}),(0,n.jsxs)("span",{children:["角色人设:",(0,n.jsx)("code",{style:{fontFamily:"var(--font-mono)",fontSize:"11px",color:"var(--accent)"},children:nv.name})]})]})]})]}):(0,n.jsxs)("div",{style:{background:"var(--bg-panel)",border:"1px dashed var(--border)",borderRadius:"8px",padding:"12px",marginBottom:"16px",fontSize:"11px",lineHeight:1.6,color:"var(--text-muted)"},children:[(0,n.jsx)("div",{style:{fontWeight:600,color:"var(--text)",marginBottom:"6px",display:"flex",alignItems:"center",gap:6},children:(0,n.jsx)("span",{children:"\uD83D\uDCA1 创作建议与提示"})}),"当前未检测到本地的「小说框架」或「角色人设」设定文件。您可以:",(0,n.jsxs)("ul",{style:{margin:"4px 0 0",paddingLeft:"16px",display:"flex",flexDirection:"column",gap:"2px"},children:[(0,n.jsxs)("li",{children:[(0,n.jsx)("strong",{children:"直接创建书卷"}),":忽略此提示,系统将自动为您构思并生成初始的世界观与角色人设。"]}),(0,n.jsxs)("li",{children:[(0,n.jsx)("strong",{children:"AI 协同起草"}),":先关闭此窗口,用左侧的",(0,n.jsx)("strong",{children:"「AI写作伴侣」"}),"来共同探讨并起草您的框架与人设设定,保存后再行创建。"]})]})]}),(0,n.jsxs)("div",{style:{marginBottom:"14px"},children:[(0,n.jsx)("label",{style:{display:"block",fontSize:"11px",fontWeight:600,color:"var(--text-muted)",marginBottom:"6px"},children:"小说书名 (Title)"}),(0,n.jsx)("input",{type:"text",required:!0,value:nd,onChange:e=>nc(e.target.value),placeholder:"例如:万古大帝",style:{width:"100%",padding:"8px 12px",border:"1px solid var(--border)",borderRadius:"6px",background:"var(--bg)",color:"var(--text)",fontSize:"12px",fontFamily:"var(--font-serif)",outline:"none"}})]}),(0,n.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px",marginBottom:"14px"},children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{style:{display:"block",fontSize:"11px",fontWeight:600,color:"var(--text-muted)",marginBottom:"6px"},children:"小说题材 (Genre)"}),(0,n.jsxs)("select",{value:np,onChange:e=>nx(e.target.value),style:{width:"100%",padding:"8px 12px",border:"1px solid var(--border)",borderRadius:"6px",background:"var(--bg)",color:"var(--text)",fontSize:"12px",outline:"none"},children:[(0,n.jsxs)("optgroup",{label:"中文网文题材 (Chinese Genres)",style:{background:"var(--bg-panel)",color:"var(--text)"},children:[(0,n.jsx)("option",{value:"xuanhuan",children:"玄幻奇幻 (Xuanhuan)"}),(0,n.jsx)("option",{value:"xianxia",children:"仙侠修真 (Xianxia)"}),(0,n.jsx)("option",{value:"urban",children:"都市异能 (Urban)"}),(0,n.jsx)("option",{value:"horror",children:"悬疑恐怖 (Horror)"}),(0,n.jsx)("option",{value:"other",children:"其它通用 (Other)"})]}),(0,n.jsxs)("optgroup",{label:"英文原生题材 (English Genres)",style:{background:"var(--bg-panel)",color:"var(--text)"},children:[(0,n.jsx)("option",{value:"litrpg",children:"数据无限流/系统流 (LitRPG)"}),(0,n.jsx)("option",{value:"progression",children:"升级流奇幻 (Progression Fantasy)"}),(0,n.jsx)("option",{value:"cozy",children:"温馨奇幻 (Cozy Fantasy)"}),(0,n.jsx)("option",{value:"cultivation",children:"英文修真 (English Cultivation)"}),(0,n.jsx)("option",{value:"dungeon-core",children:"地下城核心流 (Dungeon Core)"}),(0,n.jsx)("option",{value:"isekai",children:"异世界穿梭 (Isekai / Portal Fantasy)"}),(0,n.jsx)("option",{value:"romantasy",children:"浪漫奇幻 (Romantasy)"}),(0,n.jsx)("option",{value:"sci-fi",children:"科学幻想 (Science Fiction)"}),(0,n.jsx)("option",{value:"system-apocalypse",children:"系统废土流 (System Apocalypse)"}),(0,n.jsx)("option",{value:"tower-climber",children:"爬塔闯关流 (Tower Climbing)"})]}),(0,n.jsx)("optgroup",{label:"特殊创作模式 (Special Modes)",style:{background:"var(--bg-panel)",color:"var(--text)"},children:(0,n.jsx)("option",{value:"fanfic",children:"同人创作 (Fanfic)"})})]})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{style:{display:"block",fontSize:"11px",fontWeight:600,color:"var(--text-muted)",marginBottom:"6px"},children:"目标平台 (Platform)"}),(0,n.jsxs)("select",{value:nu,onChange:e=>ng(e.target.value),style:{width:"100%",padding:"8px 12px",border:"1px solid var(--border)",borderRadius:"6px",background:"var(--bg)",color:"var(--text)",fontSize:"12px",outline:"none"},children:[(0,n.jsx)("option",{value:"tomato",children:"番茄小说 (Tomato)"}),(0,n.jsx)("option",{value:"qidian",children:"起点中文 (Qidian)"}),(0,n.jsx)("option",{value:"other",children:"其他独立平台 (Other)"})]})]})]}),"fanfic"===np?(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:"12px",marginBottom:"20px"},children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{style:{display:"block",fontSize:"11px",fontWeight:600,color:"var(--text-muted)",marginBottom:"6px"},children:"同人创作模式 (Fanfic Mode)"}),(0,n.jsxs)("select",{value:rt,onChange:e=>rr(e.target.value),style:{width:"100%",padding:"8px 12px",border:"1px solid var(--border)",borderRadius:"6px",background:"var(--bg)",color:"var(--text)",fontSize:"12px",outline:"none"},children:[(0,n.jsx)("option",{value:"canon",children:"正典延续 (Canon - 忠实原著剧情补完)"}),(0,n.jsx)("option",{value:"au",children:"平行宇宙 (AU - 相同设定不同时空/世界)"}),(0,n.jsx)("option",{value:"ooc",children:"角色偏离 (OOC - 性格反转与脑洞脑侧)"}),(0,n.jsx)("option",{value:"cp",children:"角色配对 (CP - 深入刻画人物关系与情感)"})]})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{style:{display:"block",fontSize:"11px",fontWeight:600,color:"var(--text-muted)",marginBottom:"6px"},children:"原作素材文件/目录绝对路径 (Source Path - 必填)"}),(0,n.jsx)("input",{type:"text",value:rn,onChange:e=>ro(e.target.value),placeholder:"请输入原作素材的绝对路径,例如: D:/novel/source.txt",required:!0,style:{width:"100%",padding:"8px 12px",border:"1px solid var(--border)",borderRadius:"6px",background:"var(--bg)",color:"var(--text)",fontSize:"12px",fontFamily:"var(--font-serif)",outline:"none"}}),(0,n.jsx)("div",{style:{color:"var(--text-dim)",fontSize:"10px",marginTop:"4px",lineHeight:1.4},children:"支持指向一个 `.txt` / `.md` 文本文件,或包含若干原作设定/故事文本的文件夹绝对路径。AI 将会自动提取并解析作为同人设定依据。"})]})]}):(0,n.jsxs)("div",{style:{marginBottom:"20px"},children:[(0,n.jsx)("label",{style:{display:"block",fontSize:"11px",fontWeight:600,color:"var(--text-muted)",marginBottom:"6px"},children:"大纲梗概/创意简报 (Brief - 可选)"}),(0,n.jsx)("textarea",{value:nh,onChange:e=>nf(e.target.value),placeholder:"在此输入您的创意构想(例如:主角是退役兵王、金手指是万界交易面板、核心冲突为世家倾轧)。AI 架构师将优先融合您的创意进行大纲设定设计。",rows:4,style:{width:"100%",padding:"8px 12px",border:"1px solid var(--border)",borderRadius:"6px",background:"var(--bg)",color:"var(--text)",fontSize:"12px",fontFamily:"var(--font-serif)",lineHeight:"1.6",outline:"none",resize:"vertical"}})]}),(0,n.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",gap:"10px",borderTop:"1px solid var(--border)",paddingTop:"14px"},children:[(0,n.jsx)("button",{type:"button",onClick:()=>ek(!1),style:{padding:"6px 14px",border:"1px solid var(--border)",borderRadius:"6px",background:"transparent",color:"var(--text-muted)",fontSize:"12px",cursor:"pointer"},children:"取消"}),(0,n.jsx)("button",{type:"submit",style:{padding:"6px 16px",background:"var(--accent)",border:"none",borderRadius:"6px",color:"white",fontSize:"12px",fontWeight:600,cursor:"pointer"},children:"确认创建"})]})]})]})}),eN&&(0,n.jsx)("div",{style:{position:"fixed",inset:0,zIndex:999,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.5)",backdropFilter:"blur(4px)"},children:(0,n.jsxs)("div",{style:{background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:"12px",width:"min(600px, 90vw)",padding:"24px 20px",boxShadow:"0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1)",fontFamily:"var(--font-serif)",textAlign:"center"},children:[eX?(0,n.jsx)("div",{style:{fontSize:"28px",margin:"0 auto 12px",color:"#ef4444"},children:"⚠️"}):(0,n.jsx)("div",{style:{width:"36px",height:"36px",border:"3px solid var(--border)",borderTopColor:"var(--accent)",borderRadius:"50%",animation:"spin 1s linear infinite",margin:"0 auto 16px"}}),(0,n.jsx)("div",{style:{fontWeight:600,color:eX?"#ef4444":"var(--text)",marginBottom:8,fontSize:"14px"},children:eX?"智能写作首章失败":"正在进行智能首章写作..."}),(0,n.jsx)("div",{style:{color:"var(--text-muted)",fontSize:"11px",lineHeight:1.6},children:eX?`错误详情: ${eX}`:eH}),(0,n.jsx)("div",{ref:tx,style:{background:"#121214",border:"1px solid var(--border)",borderRadius:"6px",padding:"12px",height:"240px",overflowY:"auto",textAlign:"left",fontFamily:"var(--font-mono), monospace",fontSize:"11px",lineHeight:"1.5",color:"#e4e4e7",whiteSpace:"pre-wrap",wordBreak:"break-all",marginTop:"16px"},children:0===eG.length?(0,n.jsx)("span",{style:{color:"var(--text-dim)"},children:"正在启动写作引擎..."}):eG.map((e,t)=>(0,n.jsx)("div",{style:{marginBottom:2},children:e},t))}),eX&&(0,n.jsx)("div",{style:{display:"flex",justifyContent:"center",marginTop:16},children:(0,n.jsx)("button",{onClick:()=>{eP(!1),eQ(null)},style:{padding:"6px 20px",background:"var(--accent)",border:"none",borderRadius:"6px",color:"white",fontSize:"12px",fontWeight:600,cursor:"pointer"},children:"关闭"})})]})}),eK&&(0,n.jsx)("div",{style:{position:"fixed",inset:0,zIndex:999,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.5)",backdropFilter:"blur(4px)"},children:(0,n.jsxs)("div",{style:{background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:"12px",width:"min(500px, 90vw)",maxHeight:"80vh",display:"flex",flexDirection:"column",boxShadow:"0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1)",fontFamily:"var(--font-serif)",overflow:"hidden"},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"14px 18px",borderBottom:"1px solid var(--border)",background:"var(--bg-panel)",flexShrink:0},children:[(0,n.jsx)("span",{style:{fontSize:13,fontWeight:600,color:"var(--text)"},children:eJ}),(0,n.jsx)("button",{onClick:()=>eq(!1),style:{padding:"4px 12px",fontSize:11,borderRadius:4,border:"1px solid var(--border)",background:"var(--bg-hover)",color:"var(--text-muted)",cursor:"pointer",fontWeight:600},children:"✕ 关闭"})]}),(0,n.jsx)("div",{style:{flex:1,padding:"18px",overflowY:"auto",lineHeight:"1.8",fontSize:"12px",color:"var(--text)"},className:"markdown-body",children:(0,n.jsx)(H.oz,{remarkPlugins:[_.A],children:eV})})]})}),e9&&(0,n.jsx)("div",{style:{position:"fixed",inset:0,zIndex:1e3,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.55)",backdropFilter:"blur(4px)"},children:(0,n.jsxs)("div",{style:{background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:12,width:"480px",maxWidth:"90%",boxShadow:"0 10px 30px rgba(0,0,0,0.25)",display:"flex",flexDirection:"column",overflow:"hidden",fontFamily:"var(--font-serif)"},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 20px",borderBottom:"1px solid var(--border)",background:"var(--bg)"},children:[(0,n.jsxs)("span",{style:{fontSize:14,fontWeight:700,color:"var(--text)"},children:["\uD83D\uDCE4 导出小说书稿 (",eA,")"]}),(0,n.jsx)("button",{onClick:()=>{to||e7(!1)},disabled:to,style:{background:"none",border:"none",color:"var(--text-dim)",fontSize:14,cursor:to?"not-allowed":"pointer"},children:"✕"})]}),(0,n.jsxs)("form",{onSubmit:nL,style:{padding:"20px",display:"flex",flexDirection:"column",gap:16},children:[(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[(0,n.jsx)("label",{style:{fontSize:12,fontWeight:600,color:"var(--text-muted)"},children:"选择导出格式"}),(0,n.jsx)("div",{style:{display:"flex",gap:8},children:["epub","txt","md"].map(e=>(0,n.jsxs)("label",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",gap:6,height:38,background:te===e?"var(--bg-selected)":"var(--bg)",border:te===e?"1px solid var(--accent)":"1px solid var(--border)",borderRadius:8,fontSize:12,fontWeight:600,color:te===e?"var(--accent)":"var(--text-muted)",cursor:to?"not-allowed":"pointer",transition:"all 0.15s"},children:[(0,n.jsx)("input",{type:"radio",name:"exportFormat",value:e,checked:te===e,disabled:to,onChange:()=>tt(e),style:{display:"none"}}),(0,n.jsx)("span",{children:e.toUpperCase()})]},e))})]}),(0,n.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:8,fontSize:12,color:"var(--text)",cursor:to?"not-allowed":"pointer",userSelect:"none"},children:[(0,n.jsx)("input",{type:"checkbox",checked:tr,disabled:to,onChange:e=>tn(e.target.checked),style:{width:14,height:14,accentColor:"var(--accent)",cursor:"pointer"}}),(0,n.jsx)("span",{children:"仅导出已过审章节 (Approved Only)"})]}),(to||tc.length>0||tl||ta)&&(0,n.jsxs)("div",{style:{background:"var(--bg)",border:"1px solid var(--border)",borderRadius:8,padding:"12px",fontSize:11,display:"flex",flexDirection:"column",gap:8},children:[tl&&(0,n.jsxs)("div",{style:{color:"#ef4444",fontWeight:600},children:["⚠️ 导出失败: ",tl]}),ta&&(0,n.jsx)("div",{style:{color:"#10b981",fontWeight:600},children:ta}),to&&(0,n.jsxs)("div",{style:{color:"var(--accent)",display:"flex",alignItems:"center",gap:6},children:[(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",className:"animate-spin",style:{animation:"spin 1s linear infinite"},children:[(0,n.jsx)("line",{x1:"12",y1:"2",x2:"12",y2:"6"}),(0,n.jsx)("line",{x1:"12",y1:"18",x2:"12",y2:"22"}),(0,n.jsx)("line",{x1:"4.93",y1:"4.93",x2:"7.76",y2:"7.76"}),(0,n.jsx)("line",{x1:"16.24",y1:"16.24",x2:"19.07",y2:"19.07"}),(0,n.jsx)("line",{x1:"2",y1:"12",x2:"6",y2:"12"}),(0,n.jsx)("line",{x1:"18",y1:"12",x2:"22",y2:"12"}),(0,n.jsx)("line",{x1:"4.93",y1:"19.07",x2:"7.76",y2:"16.24"}),(0,n.jsx)("line",{x1:"16.24",y1:"7.76",x2:"19.07",y2:"4.93"})]}),(0,n.jsx)("span",{children:"正在整理并排版书稿中,请稍候..."})]}),tc.length>0&&(0,n.jsx)("div",{style:{maxHeight:"80px",overflowY:"auto",fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-dim)",background:"rgba(0,0,0,0.15)",padding:"6px",borderRadius:4,whiteSpace:"pre-wrap"},children:tc.join("")})]}),(0,n.jsxs)("div",{style:{display:"flex",gap:8,marginTop:8},children:[(0,n.jsx)("button",{type:"submit",disabled:to,style:{flex:1,height:38,background:"var(--accent)",border:"none",borderRadius:8,color:"white",fontSize:12,fontWeight:600,cursor:to?"not-allowed":"pointer",opacity:to?.7:1},children:to?"正在导出...":"确认开始导出"}),!to&&(0,n.jsx)("button",{type:"button",onClick:()=>e7(!1),style:{padding:"0 16px",height:38,background:"var(--bg-hover)",border:"1px solid var(--border)",borderRadius:8,color:"var(--text-muted)",fontSize:12,fontWeight:500,cursor:"pointer"},children:"取消"})]})]})]})}),tu&&(0,n.jsx)("div",{style:{position:"fixed",inset:0,zIndex:1e3,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.55)",backdropFilter:"blur(4px)"},children:(0,n.jsxs)("div",{style:{background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:12,width:"500px",maxWidth:"95%",boxShadow:"0 10px 30px rgba(0,0,0,0.25)",display:"flex",flexDirection:"column",overflow:"hidden",fontFamily:"var(--font-serif)"},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 20px",borderBottom:"1px solid var(--border)",background:"var(--bg)"},children:[(0,n.jsxs)("span",{style:{fontSize:14,fontWeight:700,color:"var(--text)"},children:["\uD83D\uDCE5 InkOS 导入向导 (",eA,")"]}),(0,n.jsx)("button",{onClick:()=>{tI||tg(!1)},disabled:tI,style:{background:"none",border:"none",color:"var(--text-dim)",fontSize:14,cursor:tI?"not-allowed":"pointer"},children:"✕"})]}),(0,n.jsxs)("div",{style:{display:"flex",borderBottom:"1px solid var(--border)",background:"var(--bg-panel)"},children:[(0,n.jsx)("button",{type:"button",onClick:()=>{tI||tf("chapters")},disabled:tI,style:{flex:1,padding:"10px 0",fontSize:12,fontWeight:600,border:"none",background:"chapters"===th?"var(--bg)":"transparent",color:"chapters"===th?"var(--accent)":"var(--text-muted)",borderBottom:"chapters"===th?"2px solid var(--accent)":"none",cursor:tI?"not-allowed":"pointer",transition:"all 0.15s"},children:"\uD83D\uDCE5 导入旧章原稿"}),(0,n.jsx)("button",{type:"button",onClick:()=>{tI||tf("canon")},disabled:tI,style:{flex:1,padding:"10px 0",fontSize:12,fontWeight:600,border:"none",background:"canon"===th?"var(--bg)":"transparent",color:"canon"===th?"var(--accent)":"var(--text-muted)",borderBottom:"canon"===th?"2px solid var(--accent)":"none",cursor:tI?"not-allowed":"pointer",transition:"all 0.15s"},children:"\uD83D\uDCD6 导入前作设定 (Canon)"})]}),(0,n.jsxs)("form",{onSubmit:nE,style:{padding:"20px",display:"flex",flexDirection:"column",gap:14},children:["chapters"===th?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[(0,n.jsx)("label",{style:{fontSize:11,fontWeight:600,color:"var(--text-muted)"},children:"选择导入的目标书籍*"}),t$.length>0?(0,n.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:8},children:(0,n.jsxs)("div",{style:{display:"flex",gap:10},children:[(0,n.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:6,fontSize:11,color:"var(--text)",cursor:"pointer"},children:[(0,n.jsx)("input",{type:"radio",name:"importBookSelect",checked:"active"===tA,onChange:()=>tF("active"),disabled:tI,style:{accentColor:"var(--accent)"}}),(0,n.jsxs)("span",{children:["当前书籍 (",eA,")"]})]}),(0,n.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:6,fontSize:11,color:"var(--text)",cursor:"pointer"},children:[(0,n.jsx)("input",{type:"radio",name:"importBookSelect",checked:"new"===tA,onChange:()=>tF("new"),disabled:tI,style:{accentColor:"var(--accent)"}}),(0,n.jsx)("span",{children:"➕ 导入并创建新书籍"})]})]})}):(0,n.jsx)("span",{style:{fontSize:10,color:"var(--text-dim)"},children:"⚠️ 当前小说宇宙内尚无书籍,将自动创建新书籍进行导入。"})]}),("new"===tA||0===t$.length)&&(0,n.jsx)("div",{style:{background:"rgba(var(--accent-rgb), 0.03)",border:"1px dashed var(--border)",borderRadius:8,padding:"10px 12px",display:"flex",flexDirection:"column",gap:8},children:(0,n.jsxs)("div",{style:{display:"flex",gap:10},children:[(0,n.jsxs)("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:4},children:[(0,n.jsx)("label",{style:{fontSize:10,fontWeight:600,color:"var(--text-muted)"},children:"新书籍 ID (拼音/英文)*"}),(0,n.jsx)("input",{type:"text",value:tO,onChange:e=>tN(e.target.value.replace(/[^a-zA-Z0-9_\-]/g,"")),placeholder:"如: my_new_novel",disabled:tI,style:{width:"100%",padding:"6px 8px",borderRadius:4,background:"var(--bg)",border:"1px solid var(--border)",color:"var(--text)",fontSize:11,fontFamily:"var(--font-mono)",outline:"none"},required:!0})]}),(0,n.jsxs)("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:4},children:[(0,n.jsx)("label",{style:{fontSize:10,fontWeight:600,color:"var(--text-muted)"},children:"新书籍名称*"}),(0,n.jsx)("input",{type:"text",value:tP,onChange:e=>tH(e.target.value),placeholder:"如: 我的新科幻小说",disabled:tI,style:{width:"100%",padding:"6px 8px",borderRadius:4,background:"var(--bg)",border:"1px solid var(--border)",color:"var(--text)",fontSize:11,fontFamily:"var(--font-serif)",outline:"none"},required:!0})]})]})}),(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[(0,n.jsx)("label",{style:{fontSize:11,fontWeight:600,color:"var(--text-muted)"},children:"输入源文件或文件夹路径 (from)*"}),(0,n.jsx)("input",{type:"text",value:ty,onChange:e=>tb(e.target.value),placeholder:"如: D:/novel/drafts (目录) 或 D:/draft.txt (单文件)",disabled:tI,style:{width:"100%",padding:"8px 10px",borderRadius:6,background:"var(--bg)",border:"1px solid var(--border)",color:"var(--text)",fontSize:12,fontFamily:"var(--font-mono)",outline:"none"},required:!0}),(0,n.jsx)("span",{style:{fontSize:10,color:"var(--text-dim)",lineHeight:1.4},children:"提示:系统会扫描目录下的所有 .md/.txt 并按文件名排序,或读取大文件进行自动分章,同时**提取人设与设定数据库**以备续写。"})]}),(0,n.jsxs)("div",{style:{display:"flex",gap:10},children:[(0,n.jsxs)("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:6},children:[(0,n.jsx)("label",{style:{fontSize:11,fontWeight:600,color:"var(--text-muted)"},children:"分章正则式 (可选)"}),(0,n.jsx)("input",{type:"text",value:tv,onChange:e=>tm(e.target.value),placeholder:"如: ^第[一二三四五]章",disabled:tI,style:{width:"100%",padding:"8px 10px",borderRadius:6,background:"var(--bg)",border:"1px solid var(--border)",color:"var(--text)",fontSize:12,fontFamily:"var(--font-mono)",outline:"none"}})]}),(0,n.jsxs)("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:6},children:[(0,n.jsx)("label",{style:{fontSize:11,fontWeight:600,color:"var(--text-muted)"},children:"续传章节号 (可选)"}),(0,n.jsx)("input",{type:"number",value:tj,onChange:e=>tk(e.target.value),placeholder:"如: 12",disabled:tI,style:{width:"100%",padding:"8px 10px",borderRadius:6,background:"var(--bg)",border:"1px solid var(--border)",color:"var(--text)",fontSize:12,fontFamily:"var(--font-mono)",outline:"none"}})]})]}),(0,n.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:8,fontSize:11,color:"var(--text)",cursor:tI?"not-allowed":"pointer",userSelect:"none",marginTop:4},children:[(0,n.jsx)("input",{type:"checkbox",checked:tw,disabled:tI,onChange:e=>tS(e.target.checked),style:{width:14,height:14,accentColor:"var(--accent)",cursor:"pointer"}}),(0,n.jsx)("span",{children:"作为独立同宇宙系列作品导入 (shared universe spinoff)"})]})]}):(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[(0,n.jsx)("label",{style:{fontSize:11,fontWeight:600,color:"var(--text-muted)"},children:"选择或输入前作书籍 ID (parentBookId)*"}),t$.filter(e=>e!==eA).length>0?(0,n.jsxs)("select",{value:tC,onChange:e=>tT(e.target.value),disabled:tI,style:{width:"100%",padding:"8px 10px",borderRadius:6,background:"var(--bg)",border:"1px solid var(--border)",color:"var(--text)",fontSize:12,fontFamily:"var(--font-serif)",outline:"none",cursor:"pointer"},required:!0,children:[(0,n.jsx)("option",{value:"",children:"-- 请选择书籍 --"}),t$.filter(e=>e!==eA).map(e=>(0,n.jsx)("option",{value:e,children:e},e))]}):(0,n.jsx)("input",{type:"text",value:tC,onChange:e=>tT(e.target.value),placeholder:"请输入前作 Book ID (例如: my_first_novel)",disabled:tI,style:{width:"100%",padding:"8px 10px",borderRadius:6,background:"var(--bg)",border:"1px solid var(--border)",color:"var(--text)",fontSize:12,fontFamily:"var(--font-mono)",outline:"none"},required:!0}),(0,n.jsx)("span",{style:{fontSize:10,color:"var(--text-dim)",lineHeight:1.4},children:"提示:将从所选的书籍目录中复制并合并人物卡片、纪元史和设定,帮助在全新书籍中开展同宇宙故事线(Spinoff)的创作。"})]}),(tI||tR.length>0||tW||tM)&&(0,n.jsxs)("div",{style:{background:"var(--bg)",border:"1px solid var(--border)",borderRadius:8,padding:"12px",fontSize:11,display:"flex",flexDirection:"column",gap:8},children:[tW&&(0,n.jsxs)("div",{style:{color:"#ef4444",fontWeight:600},children:["⚠️ 导入失败: ",tW]}),tM&&(0,n.jsx)("div",{style:{color:"#10b981",fontWeight:600},children:tM}),tI&&(0,n.jsxs)("div",{style:{color:"var(--accent)",display:"flex",alignItems:"center",gap:6},children:[(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",className:"animate-spin",style:{animation:"spin 1s linear infinite"},children:[(0,n.jsx)("line",{x1:"12",y1:"2",x2:"12",y2:"6"}),(0,n.jsx)("line",{x1:"12",y1:"18",x2:"12",y2:"22"}),(0,n.jsx)("line",{x1:"4.93",y1:"4.93",x2:"7.76",y2:"7.76"}),(0,n.jsx)("line",{x1:"16.24",y1:"16.24",x2:"19.07",y2:"19.07"}),(0,n.jsx)("line",{x1:"2",y1:"12",x2:"6",y2:"12"}),(0,n.jsx)("line",{x1:"18",y1:"12",x2:"22",y2:"12"}),(0,n.jsx)("line",{x1:"4.93",y1:"19.07",x2:"7.76",y2:"16.24"}),(0,n.jsx)("line",{x1:"16.24",y1:"7.76",x2:"19.07",y2:"4.93"})]}),(0,n.jsx)("span",{children:"正在运行 InkOS 智能导入引擎,请稍候..."})]}),tR.length>0&&(0,n.jsx)("div",{ref:nl,style:{maxHeight:"80px",overflowY:"auto",fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-dim)",background:"#121214",padding:"6px",borderRadius:4,whiteSpace:"pre-wrap",textAlign:"left"},children:tR.map((e,t)=>(0,n.jsx)("div",{style:{marginBottom:2},children:e},t))})]}),(0,n.jsxs)("div",{style:{display:"flex",gap:8,marginTop:8},children:[(0,n.jsx)("button",{type:"submit",disabled:tI,style:{flex:1,height:38,background:"var(--accent)",border:"none",borderRadius:8,color:"white",fontSize:12,fontWeight:600,cursor:tI?"not-allowed":"pointer",opacity:tI?.7:1},children:tI?"正在导入...":"确认开始导入"}),!tI&&(0,n.jsx)("button",{type:"button",onClick:()=>tg(!1),style:{padding:"0 16px",height:38,background:"var(--bg-hover)",border:"1px solid var(--border)",borderRadius:8,color:"var(--text-muted)",fontSize:12,fontWeight:500,cursor:"pointer"},children:"取消"})]})]})]})}),t_&&(0,n.jsx)("div",{style:{position:"fixed",inset:0,zIndex:1e3,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.55)",backdropFilter:"blur(4px)"},children:(0,n.jsxs)("div",{style:{background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:12,width:"500px",maxWidth:"95%",boxShadow:"0 10px 30px rgba(0,0,0,0.25)",display:"flex",flexDirection:"column",overflow:"hidden",fontFamily:"var(--font-serif)"},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 20px",borderBottom:"1px solid var(--border)",background:"var(--bg)"},children:[(0,n.jsxs)("span",{style:{fontSize:14,fontWeight:700,color:"var(--text)"},children:["\uD83C\uDFAD ink-xY 文风克隆工坊 (",eA,")"]}),(0,n.jsx)("button",{onClick:()=>{tQ||tJ(!1)},disabled:tQ,style:{background:"none",border:"none",color:"var(--text-dim)",fontSize:14,cursor:tQ?"not-allowed":"pointer"},children:"✕"})]}),(0,n.jsxs)("div",{style:{display:"flex",borderBottom:"1px solid var(--border)",background:"var(--bg-panel)"},children:[(0,n.jsx)("button",{type:"button",onClick:()=>{tQ||tV("paste")},disabled:tQ,style:{flex:1,padding:"10px 0",fontSize:12,fontWeight:600,border:"none",background:"paste"===tU?"var(--bg)":"transparent",color:"paste"===tU?"var(--accent)":"var(--text-muted)",borderBottom:"paste"===tU?"2px solid var(--accent)":"none",cursor:tQ?"not-allowed":"pointer",transition:"all 0.15s"},children:"\uD83D\uDCDD 直接粘贴样文"}),(0,n.jsx)("button",{type:"button",onClick:()=>{tQ||tV("path")},disabled:tQ,style:{flex:1,padding:"10px 0",fontSize:12,fontWeight:600,border:"none",background:"path"===tU?"var(--bg)":"transparent",color:"path"===tU?"var(--accent)":"var(--text-muted)",borderBottom:"path"===tU?"2px solid var(--accent)":"none",cursor:tQ?"not-allowed":"pointer",transition:"all 0.15s"},children:"\uD83D\uDCC2 指定本地文件"})]}),(0,n.jsxs)("form",{onSubmit:nM,style:{padding:"20px",display:"flex",flexDirection:"column",gap:14},children:[(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[(0,n.jsx)("label",{style:{fontSize:11,fontWeight:600,color:"var(--text-muted)"},children:"文风名称 (如:金庸、江南、科幻冷峻、言情华丽)*"}),(0,n.jsx)("input",{type:"text",value:tY,onChange:e=>tK(e.target.value),placeholder:"如: 金庸",disabled:tQ,style:{width:"100%",padding:"8px 10px",borderRadius:6,background:"var(--bg)",border:"1px solid var(--border)",color:"var(--text)",fontSize:12,fontFamily:"var(--font-serif)",outline:"none"},required:!0})]}),"paste"===tU?(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[(0,n.jsx)("label",{style:{fontSize:11,fontWeight:600,color:"var(--text-muted)"},children:"粘贴样文本内容 (建议 1000 - 5000 字)*"}),(0,n.jsx)("textarea",{value:tq,onChange:e=>tG(e.target.value),placeholder:"在此处粘贴您想让 AI 模仿写作的样文本内容(例如从金庸、江南等作家的作品中复制一两页经典段落)...",disabled:tQ,style:{width:"100%",height:"120px",padding:"8px 10px",borderRadius:6,background:"var(--bg)",border:"1px solid var(--border)",color:"var(--text)",fontSize:11,fontFamily:"var(--font-serif)",outline:"none",resize:"none",lineHeight:1.5},required:!0})]}):(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[(0,n.jsx)("label",{style:{fontSize:11,fontWeight:600,color:"var(--text-muted)"},children:"输入源文本文件绝对路径 (from)*"}),(0,n.jsx)("input",{type:"text",value:tZ,onChange:e=>tX(e.target.value),placeholder:"如: D:/novel/samples/jinyong_sample.txt",disabled:tQ,style:{width:"100%",padding:"8px 10px",borderRadius:6,background:"var(--bg)",border:"1px solid var(--border)",color:"var(--text)",fontSize:12,fontFamily:"var(--font-mono)",outline:"none"},required:!0})]}),(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[(0,n.jsx)("label",{style:{fontSize:11,fontWeight:600,color:"var(--text-muted)"},children:"应用的目标书籍 (克隆成果将写入该书)*"}),(0,n.jsx)("select",{value:eA||"",onChange:e=>eF(e.target.value),disabled:tQ,style:{width:"100%",padding:"8px 10px",borderRadius:6,background:"var(--bg)",border:"1px solid var(--border)",color:"var(--text)",fontSize:12,fontFamily:"var(--font-serif)",outline:"none",cursor:"pointer"},required:!0,children:t$.map(e=>(0,n.jsx)("option",{value:e,children:e},e))})]}),(tQ||t4.length>0||t5||t3)&&(0,n.jsxs)("div",{style:{background:"var(--bg)",border:"1px solid var(--border)",borderRadius:8,padding:"12px",fontSize:11,display:"flex",flexDirection:"column",gap:8},children:[t5&&(0,n.jsxs)("div",{style:{color:"#ef4444",fontWeight:600},children:["⚠️ 克隆失败: ",t5]}),t3&&(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[(0,n.jsx)("div",{style:{color:"#10b981",fontWeight:600},children:t3}),t7&&p&&(0,n.jsx)("button",{type:"button",onClick:()=>{p(t7,"style_guide.md"),tJ(!1)},style:{alignSelf:"flex-start",padding:"4px 10px",background:"rgba(16,185,129,0.08)",border:"1px solid #10b981",borderRadius:4,color:"#10b981",fontSize:10,fontWeight:600,cursor:"pointer",transition:"all 0.15s"},children:"\uD83D\uDCD6 查看生成的文风指南 (style_guide.md)"})]}),tQ&&(0,n.jsxs)("div",{style:{color:"var(--accent)",display:"flex",alignItems:"center",gap:6},children:[(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",className:"animate-spin",style:{animation:"spin 1s linear infinite"},children:[(0,n.jsx)("line",{x1:"12",y1:"2",x2:"12",y2:"6"}),(0,n.jsx)("line",{x1:"12",y1:"18",x2:"12",y2:"22"}),(0,n.jsx)("line",{x1:"4.93",y1:"4.93",x2:"7.76",y2:"7.76"}),(0,n.jsx)("line",{x1:"16.24",y1:"16.24",x2:"19.07",y2:"19.07"}),(0,n.jsx)("line",{x1:"2",y1:"12",x2:"6",y2:"12"}),(0,n.jsx)("line",{x1:"18",y1:"12",x2:"22",y2:"12"}),(0,n.jsx)("line",{x1:"4.93",y1:"19.07",x2:"7.76",y2:"16.24"}),(0,n.jsx)("line",{x1:"16.24",y1:"7.76",x2:"19.07",y2:"4.93"})]}),(0,n.jsx)("span",{children:"正在提取分析统计特征并由 LLM 克隆生成文风指南,请稍候..."})]}),t4.length>0&&(0,n.jsx)("div",{ref:ns,style:{maxHeight:"80px",overflowY:"auto",fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-dim)",background:"#121214",padding:"6px",borderRadius:4,whiteSpace:"pre-wrap",textAlign:"left"},children:t4.map((e,t)=>(0,n.jsx)("div",{style:{marginBottom:2},children:e},t))})]}),(0,n.jsxs)("div",{style:{display:"flex",gap:8,marginTop:8},children:[(0,n.jsx)("button",{type:"submit",disabled:tQ,style:{flex:1,height:38,background:"var(--accent)",border:"none",borderRadius:8,color:"white",fontSize:12,fontWeight:600,cursor:tQ?"not-allowed":"pointer",opacity:tQ?.7:1},children:tQ?"正在克隆分析...":"确认克隆文风"}),!tQ&&(0,n.jsx)("button",{type:"button",onClick:()=>tJ(!1),style:{padding:"0 16px",height:38,background:"var(--bg-hover)",border:"1px solid var(--border)",borderRadius:8,color:"var(--text-muted)",fontSize:12,fontWeight:500,cursor:"pointer"},children:"取消"})]})]})]})}),rd&&(0,n.jsx)("div",{style:{position:"fixed",inset:0,zIndex:1e3,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.55)",backdropFilter:"blur(4px)"},children:(0,n.jsxs)("div",{style:{background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:12,width:"500px",maxWidth:"95%",boxShadow:"0 10px 30px rgba(0,0,0,0.25)",display:"flex",flexDirection:"column",overflow:"hidden",fontFamily:"var(--font-serif)"},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 20px",borderBottom:"1px solid var(--border)",background:"rgba(139, 92, 246, 0.08)",color:"#a78bfa"},children:[(0,n.jsxs)("h3",{style:{margin:0,fontSize:"14px",fontWeight:600,display:"flex",alignItems:"center",gap:8},children:[(0,n.jsx)("span",{children:"\uD83D\uDD04"}),(0,n.jsxs)("span",{children:["刷新同人原作设定 (",eA,")"]})]}),!ru&&(0,n.jsx)("button",{onClick:()=>rc(!1),style:{background:"none",border:"none",color:"var(--text-dim)",cursor:"pointer",fontSize:16},children:"✕"})]}),(0,n.jsxs)("form",{onSubmit:n$,style:{padding:"20px",display:"flex",flexDirection:"column",gap:14},children:[ry&&(0,n.jsxs)("div",{style:{padding:10,background:"rgba(239,68,68,0.08)",border:"1px solid rgba(239,68,68,0.2)",borderRadius:8,color:"#ef4444",fontSize:11},children:["⚠️ ",ry]}),rv&&(0,n.jsxs)("div",{style:{padding:10,background:"rgba(16,185,129,0.08)",border:"1px solid rgba(16,185,129,0.2)",borderRadius:8,color:"#10b981",fontSize:11},children:["✨ ",rv]}),(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[(0,n.jsx)("label",{style:{fontSize:11,fontWeight:600,color:"var(--text-muted)"},children:"同人原作素材绝对路径 (Source Path - 必填)"}),(0,n.jsx)("input",{type:"text",value:rp,onChange:e=>rx(e.target.value),placeholder:"请输入最新的原著素材路径,例如: D:/novel/source_v2.txt",required:!0,disabled:ru,style:{padding:"8px 12px",border:"1px solid var(--border)",borderRadius:"6px",background:"var(--bg)",color:"var(--text)",fontSize:"12px",fontFamily:"var(--font-serif)",outline:"none"}})]}),rh.length>0&&(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[(0,n.jsx)("label",{style:{fontSize:11,fontWeight:600,color:"var(--text-muted)"},children:"刷新运行日志"}),(0,n.jsx)("div",{ref:rj,style:{height:"150px",background:"#1e1e1e",color:"#d4d4d4",fontFamily:"var(--font-mono)",fontSize:"10px",padding:"8px 12px",borderRadius:"6px",overflowY:"auto",whiteSpace:"pre-wrap",lineHeight:"1.5",border:"1px solid var(--border)"},children:rh.map((e,t)=>(0,n.jsx)("div",{children:e},t))})]}),(0,n.jsxs)("div",{style:{display:"flex",gap:10,borderTop:"1px solid var(--border)",paddingTop:"14px",justifyContent:"flex-end"},children:[(0,n.jsx)("button",{type:"submit",disabled:ru,style:{padding:"0 16px",height:38,background:"#a78bfa",border:"none",borderRadius:8,color:"white",fontSize:12,fontWeight:600,cursor:ru?"not-allowed":"pointer",opacity:ru?.7:1},children:ru?"正在分析刷新...":"开始刷新"}),!ru&&(0,n.jsx)("button",{type:"button",onClick:()=>rc(!1),style:{padding:"0 16px",height:38,background:"var(--bg-hover)",border:"1px solid var(--border)",borderRadius:8,color:"var(--text-muted)",fontSize:12,fontWeight:500,cursor:"pointer"},children:"取消"})]})]})]})}),r9&&(0,n.jsx)("div",{style:{position:"fixed",inset:0,zIndex:1e3,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.55)",backdropFilter:"blur(4px)"},children:(0,n.jsxs)("div",{style:{background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:12,width:"500px",maxWidth:"90%",boxShadow:"0 10px 30px rgba(0,0,0,0.25)",display:"flex",flexDirection:"column",overflow:"hidden",fontFamily:"var(--font-serif)"},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 20px",borderBottom:"1px solid var(--border)",background:"var(--bg)"},children:[(0,n.jsxs)("span",{style:{fontSize:14,fontWeight:700,color:"var(--text)",display:"flex",alignItems:"center",gap:6},children:[(0,n.jsx)("span",{children:"\uD83D\uDDDC️"})," 大纲摘要压缩归档"]}),(0,n.jsx)("button",{onClick:()=>{r8||r7(!1)},disabled:r8,style:{background:"none",border:"none",color:"var(--text-dim)",fontSize:14,cursor:r8?"not-allowed":"pointer"},children:"✕"})]}),(0,n.jsxs)("div",{style:{padding:"20px",display:"flex",flexDirection:"column",gap:16},children:[(0,n.jsx)("div",{style:{fontSize:12,color:"var(--text-muted)",lineHeight:1.6},children:"运行大纲摘要压缩会将已完结分卷的逐章梗概合并提炼,输出到分卷摘要中,并对已完结章节的明细梗概进行历史归档,以大幅缩减大语言模型上下文 Token 占用,提升续写连贯性,防止远期情节记忆退化。"}),(r8||ne.length>0)&&(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[(0,n.jsxs)("div",{style:{fontSize:11,fontWeight:600,color:"var(--text-muted)",display:"flex",alignItems:"center",gap:4},children:[r8&&(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",className:"animate-spin",style:{animation:"spin 1s linear infinite"},children:[(0,n.jsx)("line",{x1:"12",y1:"2",x2:"12",y2:"6"}),(0,n.jsx)("line",{x1:"12",y1:"18",x2:"12",y2:"22"}),(0,n.jsx)("line",{x1:"4.93",y1:"4.93",x2:"7.76",y2:"7.76"}),(0,n.jsx)("line",{x1:"16.24",y1:"16.24",x2:"19.07",y2:"19.07"}),(0,n.jsx)("line",{x1:"2",y1:"12",x2:"6",y2:"12"}),(0,n.jsx)("line",{x1:"18",y1:"12",x2:"22",y2:"12"}),(0,n.jsx)("line",{x1:"4.93",y1:"19.07",x2:"7.76",y2:"16.24"}),(0,n.jsx)("line",{x1:"16.24",y1:"7.76",x2:"19.07",y2:"4.93"})]}),(0,n.jsx)("span",{children:"执行控制台日志:"})]}),(0,n.jsx)("div",{ref:na,style:{height:"150px",overflowY:"auto",fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-dim)",background:"#121214",padding:"8px 12px",borderRadius:6,whiteSpace:"pre-wrap",textAlign:"left",border:"1px solid var(--border)",lineHeight:1.4},children:0===ne.length?(0,n.jsx)("div",{style:{color:"#6b7280"},children:"正在初始化并启动命令行脚本..."}):ne.map((e,t)=>(0,n.jsx)("div",{style:{marginBottom:2},children:e},t))})]}),no&&(0,n.jsxs)("div",{style:{background:"rgba(16, 185, 129, 0.04)",border:"1px solid rgba(16, 185, 129, 0.25)",borderRadius:8,padding:"12px",display:"flex",flexDirection:"column",gap:6},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,fontWeight:600,color:"#10b981",fontSize:"12px"},children:[(0,n.jsx)("span",{children:"✨"})," 压缩归档完成"]}),(0,n.jsxs)("div",{style:{fontSize:"11px",color:"var(--text-muted)",lineHeight:1.6},children:[(0,n.jsxs)("div",{style:{marginBottom:4},children:["• 成功压缩归档卷数:",(0,n.jsxs)("strong",{children:[no.archivedVolumes," 卷"]})]}),(0,n.jsxs)("div",{children:["• 当前内存保留近期章节:",(0,n.jsxs)("strong",{children:[no.retainedChapters," 章"]})]})]}),(0,n.jsx)("div",{style:{fontSize:"10px",color:"var(--text-dim)",marginTop:4,borderTop:"1px dashed rgba(16, 185, 129, 0.15)",paddingTop:4},children:"已将对应卷的章节梗概安全移动至归档目录,活动大纲摘要已刷新。"})]}),nr&&(0,n.jsxs)("div",{style:{background:"rgba(239, 68, 68, 0.04)",border:"1px solid rgba(239, 68, 68, 0.25)",borderRadius:8,padding:"12px",display:"flex",flexDirection:"column",gap:4},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,fontWeight:600,color:"#ef4444",fontSize:"12px"},children:[(0,n.jsx)("span",{children:"⚠️"})," 执行出错"]}),(0,n.jsx)("div",{style:{fontSize:"11px",color:"var(--text-muted)",fontFamily:"var(--font-mono)",wordBreak:"break-all"},children:nr})]}),(0,n.jsx)("div",{style:{display:"flex",gap:8,marginTop:8},children:r8?(0,n.jsx)("button",{disabled:!0,style:{flex:1,height:38,background:"var(--accent)",opacity:.7,border:"none",borderRadius:8,color:"white",fontSize:12,fontWeight:600,cursor:"not-allowed"},children:"正在压缩..."}):(0,n.jsx)("button",{onClick:()=>r7(!1),style:{flex:1,height:38,background:"var(--accent)",border:"none",borderRadius:8,color:"white",fontSize:12,fontWeight:600,cursor:"pointer"},children:nr?"关闭":"确认并关闭"})})]})]})}),rk&&(0,n.jsx)("div",{style:{position:"fixed",inset:0,zIndex:1e3,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.55)",backdropFilter:"blur(4px)"},children:(0,n.jsxs)("div",{style:{background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:12,width:"650px",maxWidth:"95%",maxHeight:"85vh",boxShadow:"0 10px 30px rgba(0,0,0,0.25)",display:"flex",flexDirection:"column",overflow:"hidden",fontFamily:"var(--font-serif)"},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",padding:"16px 20px",borderBottom:"1px solid var(--border)",background:"rgba(16, 185, 129, 0.08)",color:"#10b981",justifyContent:"space-between"},children:[(0,n.jsxs)("h3",{style:{margin:0,fontSize:"14px",fontWeight:600,display:"flex",alignItems:"center",gap:8},children:[(0,n.jsx)("span",{children:"\uD83D\uDCE1"}),(0,n.jsx)("span",{children:"智能市场分析雷达 (Radar Market Scanner)"})]}),!rS&&(0,n.jsx)("button",{onClick:()=>rw(!1),style:{background:"none",border:"none",color:"var(--text-dim)",cursor:"pointer",fontSize:16},children:"✕"})]}),(0,n.jsxs)("div",{style:{padding:"20px",overflowY:"auto",display:"flex",flexDirection:"column",gap:14,flex:1},children:[rz&&(0,n.jsxs)("div",{style:{padding:10,background:"rgba(239,68,68,0.08)",border:"1px solid rgba(239,68,68,0.2)",borderRadius:8,color:"#ef4444",fontSize:11},children:["⚠️ 扫描失败: ",rz]}),rS&&(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:12,color:"var(--text-muted)"},children:[(0,n.jsx)("div",{style:{width:"12px",height:"12px",border:"2px solid var(--border)",borderTopColor:"#10b981",borderRadius:"50%",animation:"spin 1s linear infinite"}}),(0,n.jsx)("span",{children:"雷达天线展开,正在扫描各大网文平台潜力题材与受众风向..."})]}),(0,n.jsx)("div",{ref:rE,style:{height:"220px",background:"#121214",color:"#d4d4d4",fontFamily:"var(--font-mono)",fontSize:"10px",padding:"10px 12px",borderRadius:"6px",overflowY:"auto",whiteSpace:"pre-wrap",lineHeight:"1.5",border:"1px solid var(--border)",textAlign:"left"},children:rT.map((e,t)=>(0,n.jsx)("div",{children:e},t))})]}),!rS&&rL&&(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[(0,n.jsxs)("div",{style:{background:"var(--bg)",border:"1px solid var(--border)",borderRadius:"8px",padding:"14px 16px",fontSize:"12px",lineHeight:"1.6"},children:[(0,n.jsxs)("div",{style:{fontWeight:600,color:"#10b981",marginBottom:8,display:"flex",alignItems:"center",gap:6},children:[(0,n.jsx)("span",{children:"\uD83D\uDCCA"})," 市场概况总结 (Global Trend Summary)"]}),(0,n.jsx)("div",{style:{color:"var(--text-muted)",fontSize:"11px"},children:(0,n.jsx)(H.oz,{remarkPlugins:[_.A],children:rL.marketSummary})})]}),(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[(0,n.jsxs)("div",{style:{fontWeight:600,fontSize:"12px",color:"var(--text)",display:"flex",alignItems:"center",gap:6},children:[(0,n.jsx)("span",{children:"\uD83C\uDFAF"})," AI 潜力选题方向推荐 (AIGC Concept Prompts)"]}),(0,n.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:rL.recommendations?.map((e,t)=>{let r=Math.round(100*e.confidence),o=r>=75,i=o?"#10b981":"#f59e0b";return(0,n.jsxs)("div",{style:{background:"var(--bg)",border:"1px solid var(--border)",borderRadius:"8px",padding:"14px",transition:"all 0.2s",display:"flex",flexDirection:"column",gap:8},onMouseEnter:e=>{e.currentTarget.style.borderColor="#10b981",e.currentTarget.style.boxShadow="0 4px 12px rgba(16, 185, 129, 0.05)"},onMouseLeave:e=>{e.currentTarget.style.borderColor="var(--border)",e.currentTarget.style.boxShadow="none"},children:[(0,n.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[(0,n.jsxs)("span",{style:{fontSize:"12px",fontWeight:700,color:"var(--text)"},children:[e.platform," / ",e.genre]}),(0,n.jsxs)("span",{style:{fontSize:"10px",fontWeight:600,padding:"2px 8px",borderRadius:"10px",color:i,background:o?"rgba(16, 185, 129, 0.08)":"rgba(245, 158, 11, 0.08)",border:`1px solid ${i}33`},children:["潜力指数: ",r,"%"]})]}),(0,n.jsxs)("div",{style:{fontSize:"11px",color:"var(--text-muted)"},children:[(0,n.jsx)("strong",{style:{color:"var(--text)"},children:"核心概念:"})," ",e.concept]}),(0,n.jsxs)("div",{style:{fontSize:"11px",color:"var(--text-muted)"},children:[(0,n.jsx)("strong",{style:{color:"var(--text)"},children:"推荐逻辑:"})," ",e.reasoning]}),e.benchmarkTitles?.length>0&&(0,n.jsxs)("div",{style:{fontSize:"10px",color:"var(--text-dim)",marginTop:4,display:"flex",flexWrap:"wrap",gap:4},children:[(0,n.jsx)("span",{children:"\uD83C\uDFF7️ 对标书目:"}),e.benchmarkTitles.map((e,t)=>(0,n.jsxs)("span",{style:{background:"var(--bg-hover)",padding:"1px 6px",borderRadius:4},children:["《",e,"》"]},t))]})]},t)})})]})]}),!rS&&!rL&&(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",padding:"30px 10px",gap:14,textAlign:"center"},children:[(0,n.jsx)("span",{style:{fontSize:"40px"},children:"\uD83D\uDCE1"}),(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[(0,n.jsx)("div",{style:{fontSize:"13px",fontWeight:600,color:"var(--text)"},children:"扫描当前网文市场热点"}),(0,n.jsx)("div",{style:{fontSize:"11px",color:"var(--text-muted)",maxWidth:360,lineHeight:1.6},children:"AI 市场雷达将深度挖掘当前各大发布平台的热门标签、高互动率流派以及对标爆款,为您提供高置信度的写作题材概念指南。"})]}),(0,n.jsxs)("button",{onClick:nN,style:{padding:"8px 24px",background:"#10b981",border:"none",borderRadius:"8px",color:"white",fontSize:12,fontWeight:600,cursor:"pointer",display:"flex",alignItems:"center",gap:6,transition:"opacity 0.15s"},children:[(0,n.jsx)("span",{children:"\uD83D\uDCE1"})," 启动雷达行情扫描"]})]})]}),(0,n.jsx)("div",{style:{display:"flex",gap:8,padding:"12px 20px",background:"var(--bg-panel)",borderTop:"1px solid var(--border)",justifyContent:"flex-end"},children:!rS&&(0,n.jsx)("button",{onClick:()=>rw(!1),style:{padding:"6px 16px",background:"var(--bg-hover)",border:"1px solid var(--border)",borderRadius:8,color:"var(--text-muted)",fontSize:12,fontWeight:500,cursor:"pointer"},children:"关闭"})})]})}),rM&&(0,n.jsx)("div",{style:{position:"fixed",inset:0,zIndex:1e3,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.55)",backdropFilter:"blur(4px)"},children:(0,n.jsxs)("div",{style:{background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:12,width:"520px",maxWidth:"95%",maxHeight:"85vh",boxShadow:"0 10px 30px rgba(0,0,0,0.25)",display:"flex",flexDirection:"column",overflow:"hidden",fontFamily:"var(--font-serif)"},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 20px",borderBottom:"1px solid var(--border)",background:"rgba(139, 92, 246, 0.08)",color:"#a78bfa"},children:[(0,n.jsxs)("h3",{style:{margin:0,fontSize:"14px",fontWeight:600,display:"flex",alignItems:"center",gap:8},children:[(0,n.jsx)("span",{children:"\uD83D\uDE80"}),(0,n.jsx)("span",{children:"全自动短篇小说工坊 (Auto Short Fiction Pipeline)"})]}),!r$&&(0,n.jsx)("button",{onClick:()=>rD(!1),style:{background:"none",border:"none",color:"var(--text-dim)",cursor:"pointer",fontSize:16},children:"✕"})]}),(0,n.jsxs)("div",{style:{padding:"20px",display:"flex",flexDirection:"column",gap:14,overflowY:"auto",flex:1},children:[rO&&(0,n.jsxs)("div",{style:{padding:10,background:"rgba(239,68,68,0.08)",border:"1px solid rgba(239,68,68,0.2)",borderRadius:8,color:"#ef4444",fontSize:11},children:["⚠️ 运行错误: ",rO]}),rP&&(0,n.jsxs)("div",{style:{background:"rgba(16, 185, 129, 0.04)",border:"1px solid rgba(16, 185, 129, 0.25)",borderRadius:8,padding:"14px",display:"flex",flexDirection:"column",gap:8},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,fontWeight:600,color:"#10b981",fontSize:"13px"},children:[(0,n.jsx)("span",{children:"✨"})," 阶段任务完成!"]}),(0,n.jsx)("div",{style:{fontSize:"11px",color:"var(--text-muted)",lineHeight:1.6,whiteSpace:"pre-wrap"},children:rP})]}),(0,n.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"10px 0",borderBottom:"1px solid var(--border)",marginBottom:10},children:[(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",flex:1},children:[(0,n.jsx)("div",{style:{width:24,height:24,borderRadius:"50%",background:rZ?"#10b981":r$&&"idle"===rQ?"var(--accent)":"var(--bg-hover)",color:rZ?"white":"var(--text-muted)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:11,fontWeight:"bold"},children:rZ?"✓":"1"}),(0,n.jsx)("span",{style:{fontSize:10,marginTop:4,color:r$&&"idle"===rQ?"var(--accent)":"var(--text-muted)"},children:"大纲规划"})]}),(0,n.jsx)("div",{style:{flex:1,height:2,background:rZ?"#10b981":"var(--border)",margin:"0 -10px"}}),(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",flex:1},children:[(0,n.jsx)("div",{style:{width:24,height:24,borderRadius:"50%",background:"package"===rQ||"completed"===rQ?"#10b981":r$&&"draft"===rQ?"var(--accent)":"var(--bg-hover)",color:"package"===rQ||"completed"===rQ?"white":"var(--text-muted)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:11,fontWeight:"bold"},children:"package"===rQ||"completed"===rQ?"✓":"2"}),(0,n.jsx)("span",{style:{fontSize:10,marginTop:4,color:r$&&"draft"===rQ?"var(--accent)":"var(--text-muted)"},children:"正文写作"})]}),(0,n.jsx)("div",{style:{flex:1,height:2,background:"package"===rQ||"completed"===rQ?"#10b981":"var(--border)",margin:"0 -10px"}}),(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",flex:1},children:[(0,n.jsx)("div",{style:{width:24,height:24,borderRadius:"50%",background:"completed"===rQ?"#10b981":r$&&"package"===rQ?"var(--accent)":"var(--bg-hover)",color:"completed"===rQ?"white":"var(--text-muted)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:11,fontWeight:"bold"},children:"completed"===rQ?"✓":"3"}),(0,n.jsx)("span",{style:{fontSize:10,marginTop:4,color:r$&&"package"===rQ?"var(--accent)":"var(--text-muted)"},children:"书封包装"})]})]}),!r$&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[(0,n.jsx)("label",{style:{fontSize:11,fontWeight:600,color:"var(--text-muted)"},children:"故事创意与走向方向 (Story Direction - 必填)*"}),(0,n.jsx)("input",{type:"text",value:r_,onChange:e=>rJ(e.target.value),placeholder:"例如: 女频短篇 婚姻背叛 商业争夺 证据反杀 爽文",disabled:!!rZ,required:!0,style:{padding:"8px 12px",border:"1px solid var(--border)",borderRadius:"6px",background:"var(--bg)",color:"var(--text)",fontSize:"12px",fontFamily:"var(--font-serif)",outline:"none",opacity:rZ?.7:1}})]}),(0,n.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},children:[(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[(0,n.jsx)("label",{style:{fontSize:11,fontWeight:600,color:"var(--text-muted)"},children:"章节数量 (Chapter Count)*"}),(0,n.jsx)("select",{value:rU,onChange:e=>rV(parseInt(e.target.value,10)),disabled:!!rZ,style:{padding:"8px 10px",borderRadius:6,background:"var(--bg)",border:"1px solid var(--border)",color:"var(--text)",fontSize:12,fontFamily:"var(--font-serif)",outline:"none",cursor:rZ?"not-allowed":"pointer",opacity:rZ?.7:1},children:[12,13,14,15,16,17,18].map(e=>(0,n.jsxs)("option",{value:e,children:[e," 章"]},e))})]}),(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[(0,n.jsx)("label",{style:{fontSize:11,fontWeight:600,color:"var(--text-muted)"},children:"单章目标字数 (Words Target)*"}),(0,n.jsx)("select",{value:rY,onChange:e=>rK(parseInt(e.target.value,10)),disabled:!!rZ,style:{padding:"8px 10px",borderRadius:6,background:"var(--bg)",border:"1px solid var(--border)",color:"var(--text)",fontSize:12,fontFamily:"var(--font-serif)",outline:"none",cursor:rZ?"not-allowed":"pointer",opacity:rZ?.7:1},children:[900,1e3,1100,1200].map(e=>(0,n.jsxs)("option",{value:e,children:[e," 字/章"]},e))})]})]}),(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"4px 0"},children:[(0,n.jsx)("input",{type:"checkbox",id:"shortCoverCheckbox",checked:rq,onChange:e=>rG(e.target.checked),disabled:!!rZ,style:{cursor:rZ?"not-allowed":"pointer",accentColor:"#a78bfa"}}),(0,n.jsx)("label",{htmlFor:"shortCoverCheckbox",style:{fontSize:11,color:"var(--text-muted)",cursor:rZ?"not-allowed":"pointer",userSelect:"none",opacity:rZ?.7:1},children:"\uD83C\uDF0C 全自动生成配图故事封面 (AI Cover Generation)"})]})]}),r$&&(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:12,color:"var(--text-muted)"},children:[(0,n.jsx)("div",{style:{width:"12px",height:"12px",border:"2px solid var(--border)",borderTopColor:"#a78bfa",borderRadius:"50%",animation:"spin 1s linear infinite"}}),(0,n.jsx)("span",{children:"idle"===rQ||"outline"===rQ?"正在运行 步骤一:AI 规划大纲与大纲精修评审...":"draft"===rQ?"正在运行 步骤二:AI 协同批量起草各章节正文...":"正在运行 步骤三:AI 生成故事简介、卖点与封面提示词,并调用模型生成书封..."})]}),(0,n.jsx)("div",{ref:r1,style:{height:"220px",background:"#121214",color:"#d4d4d4",fontFamily:"var(--font-mono)",fontSize:"10px",padding:"10px 12px",borderRadius:"6px",overflowY:"auto",whiteSpace:"pre-wrap",lineHeight:"1.5",border:"1px solid var(--border)",textAlign:"left"},children:rA.map((e,t)=>(0,n.jsx)("div",{children:e},t))})]}),(0,n.jsxs)("div",{style:{display:"flex",gap:10,borderTop:"1px solid var(--border)",paddingTop:"14px",justifyContent:"flex-end",alignItems:"center"},children:[rZ&&!r$&&(0,n.jsx)("button",{type:"button",onClick:()=>{rX(null),r0("idle"),rH(null),rN(null),rF([])},style:{padding:"0 12px",height:38,background:"rgba(239, 68, 68, 0.08)",border:"1px solid rgba(239, 68, 68, 0.2)",borderRadius:8,color:"#ef4444",fontSize:11,fontWeight:500,cursor:"pointer",marginRight:"auto"},children:"\uD83D\uDD04 重置新故事"}),r$?(0,n.jsx)("button",{type:"button",disabled:!0,style:{padding:"0 20px",height:38,background:"var(--border)",border:"none",borderRadius:8,color:"var(--text-muted)",fontSize:12,fontWeight:600,cursor:"not-allowed"},children:"正在生成中..."}):(0,n.jsxs)(n.Fragment,{children:[!rZ&&(0,n.jsx)("button",{type:"button",onClick:()=>nP("outline"),disabled:!r_.trim(),style:{padding:"0 20px",height:38,background:"#a78bfa",border:"none",borderRadius:8,color:"white",fontSize:12,fontWeight:600,cursor:r_.trim()?"pointer":"not-allowed",opacity:r_.trim()?1:.6},children:"\uD83D\uDE80 步骤一:生成大纲"}),rZ&&"draft"===rQ&&(0,n.jsx)("button",{type:"button",onClick:()=>nP("draft"),style:{padding:"0 20px",height:38,background:"#8b5cf6",border:"none",borderRadius:8,color:"white",fontSize:12,fontWeight:600,cursor:"pointer"},children:"✍️ 步骤二:批量起草正文"}),rZ&&"package"===rQ&&(0,n.jsx)("button",{type:"button",onClick:()=>nP("package"),style:{padding:"0 20px",height:38,background:"#ec4899",border:"none",borderRadius:8,color:"white",fontSize:12,fontWeight:600,cursor:"pointer"},children:"\uD83C\uDFA8 步骤三:生成封面与包装"})]}),!r$&&(0,n.jsx)("button",{type:"button",onClick:()=>{rD(!1),rH(null),rN(null)},style:{padding:"0 16px",height:38,background:"var(--bg-hover)",border:"1px solid var(--border)",borderRadius:8,color:"var(--text-muted)",fontSize:12,fontWeight:500,cursor:"pointer"},children:"completed"===rQ?"完成":"关闭"})]})]})]})})]})}function X({node:e,selectedSessionId:t,onSelectSession:r,onRenamed:i,onSessionDeleted:l,depth:s}){let[a,d]=(0,o.useState)(!1),c=e.children.length>0;return(0,n.jsxs)("div",{children:[(0,n.jsxs)("div",{style:{position:"relative"},children:[s>0&&(0,n.jsx)("div",{style:{position:"absolute",left:12*s+6,top:0,bottom:0,width:1,background:"var(--border)",pointerEvents:"none"}}),(0,n.jsx)(Q,{session:e.session,isSelected:e.session.id===t,onClick:()=>r(e.session),onRenamed:i,onDeleted:e=>l?.(e),depth:s,hasChildren:c,collapsed:a,onToggleCollapse:()=>d(e=>!e)})]}),c&&!a&&(0,n.jsx)("div",{children:e.children.map(e=>(0,n.jsx)(X,{node:e,selectedSessionId:t,onSelectSession:r,onRenamed:i,onSessionDeleted:l,depth:s+1},e.session.id))})]})}function Q({session:e,isSelected:t,onClick:r,onRenamed:i,onDeleted:l,depth:s=0,hasChildren:a=!1,collapsed:d=!1,onToggleCollapse:c}){let p,x,u,g,h,[f,y]=(0,o.useState)(!1),[b,v]=(0,o.useState)(!1),[m,j]=(0,o.useState)(""),[k,w]=(0,o.useState)(!1),[S,C]=(0,o.useState)(!1),[T,I]=(0,o.useState)(e.locked),z=(0,o.useRef)(null);(0,o.useEffect)(()=>{I(e.locked)},[e.locked]);let R=(0,o.useCallback)(async t=>{t.stopPropagation();let r=!T;I(r),e.locked=r;try{await fetch(`/api/sessions/${encodeURIComponent(e.id)}/lock`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({locked:r})}),i?.()}catch{I(!r),e.locked=!r}},[T,e,i]),L=e.name||e.firstMessage.slice(0,50)||e.id.slice(0,12),W=(0,o.useCallback)(t=>{t.stopPropagation(),j(e.name??""),v(!0),setTimeout(()=>z.current?.select(),0)},[e.name]),E=(0,o.useCallback)(async()=>{let t=m.trim();if(v(!1),t!==(e.name??""))try{await fetch(`/api/sessions/${encodeURIComponent(e.id)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:t})}),i?.()}catch{}},[m,e.id,e.name,i]),M=(0,o.useCallback)(e=>{e.stopPropagation(),w(!0)},[]),D=(0,o.useCallback)(async t=>{t.stopPropagation(),w(!1),C(!0);try{await fetch(`/api/sessions/${encodeURIComponent(e.id)}`,{method:"DELETE"}),l?.(e.id)}catch{C(!1)}},[e.id,l]),$=(0,o.useCallback)(e=>{e.stopPropagation(),w(!1)},[]);return(0,n.jsx)("div",{onClick:k||b?void 0:r,onMouseEnter:()=>y(!0),onMouseLeave:()=>{y(!1)},style:{height:54,display:"flex",alignItems:"center",paddingLeft:s>0?12*s+14:14,paddingRight:8,cursor:k||b?"default":"pointer",background:k?"rgba(239,68,68,0.06)":t?"var(--bg-selected)":f?"var(--bg-hover)":"transparent",borderLeft:k?"2px solid #ef4444":t?"2px solid var(--accent)":"2px solid transparent",transition:"background 0.1s",opacity:S?.5:1,gap:6,overflow:"hidden"},children:k?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{style:{flex:1,minWidth:0,fontSize:12,color:"var(--text)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:["Delete ",(0,n.jsxs)("span",{style:{fontWeight:600},children:["“",L.slice(0,22),L.length>22?"…":"","”"]}),"?"]}),(0,n.jsxs)("div",{style:{display:"flex",gap:5,flexShrink:0},children:[(0,n.jsxs)("button",{onClick:D,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:4,height:30,padding:"0 11px",background:"#ef4444",border:"none",borderRadius:6,color:"#fff",cursor:"pointer",fontSize:12,fontWeight:600,whiteSpace:"nowrap"},children:[(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("polyline",{points:"3 6 5 6 21 6"}),(0,n.jsx)("path",{d:"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"}),(0,n.jsx)("path",{d:"M10 11v6M14 11v6"}),(0,n.jsx)("path",{d:"M9 6V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2"})]}),"Delete"]}),(0,n.jsx)("button",{onClick:$,style:{display:"flex",alignItems:"center",justifyContent:"center",height:30,padding:"0 11px",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:6,color:"var(--text-muted)",cursor:"pointer",fontSize:12,fontWeight:500,whiteSpace:"nowrap"},children:"Cancel"})]})]}):b?(0,n.jsx)("input",{ref:z,value:m,onChange:e=>j(e.target.value),onBlur:E,onKeyDown:e=>{"Enter"===e.key&&E(),"Escape"===e.key&&v(!1)},autoFocus:!0,style:{flex:1,fontSize:12,padding:"5px 8px",border:"1px solid var(--accent)",borderRadius:5,outline:"none",background:"var(--bg)",color:"var(--text)",height:30}}):(0,n.jsxs)(n.Fragment,{children:[s>0&&(0,n.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-dim)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[(0,n.jsx)("line",{x1:"6",y1:"3",x2:"6",y2:"15"}),(0,n.jsx)("circle",{cx:"18",cy:"6",r:"3"}),(0,n.jsx)("circle",{cx:"6",cy:"18",r:"3"}),(0,n.jsx)("path",{d:"M18 9a9 9 0 0 1-9 9"})]}),(0,n.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,n.jsxs)("div",{style:{fontSize:12,fontWeight:t?500:400,lineHeight:1.4,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:"var(--text)",display:"flex",alignItems:"center",gap:4},title:L,children:[T&&(0,n.jsx)("span",{title:"本会话已被锁定,无法删除。请先解锁!",style:{display:"inline-flex",fontSize:10,flexShrink:0},children:"\uD83D\uDD12"}),(0,n.jsx)("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:L})]}),(0,n.jsxs)("div",{style:{marginTop:2,display:"flex",gap:8,color:"var(--text-dim)",fontSize:11},children:[(0,n.jsx)("span",{title:e.modified,children:(p=new Date(e.modified),u=Math.floor((x=new Date().getTime()-p.getTime())/6e4),g=Math.floor(x/36e5),h=Math.floor(x/864e5),u<1?"just now":u<60?`${u}m ago`:g<24?`${g}h ago`:h<7?`${h}d ago`:p.toLocaleDateString())}),(0,n.jsxs)("span",{children:[e.messageCount," msgs"]})]})]}),a&&(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),c?.()},title:d?"Expand forks":"Collapse forks",style:{display:"flex",alignItems:"center",justifyContent:"center",width:20,height:20,padding:0,flexShrink:0,background:"none",border:"none",color:"var(--text-dim)",cursor:"pointer",transform:d?"rotate(-90deg)":"none",transition:"transform 0.15s"},children:(0,n.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("polyline",{points:"2 3.5 5 6.5 8 3.5"})})}),f&&(0,n.jsxs)("div",{style:{display:"flex",gap:4,flexShrink:0},children:[(0,n.jsx)("button",{onClick:R,title:T?"解锁会话 (Unlock session)":"锁定会话 (Lock session)",style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,padding:0,background:"var(--bg-hover)",border:"1px solid var(--border)",borderRadius:7,color:T?"var(--accent)":"var(--text-muted)",cursor:"pointer",flexShrink:0,transition:"background 0.12s, color 0.12s, border-color 0.12s",borderColor:T?"rgba(37,99,235,0.25)":"var(--border)"},onMouseEnter:e=>{e.currentTarget.style.background="var(--bg-selected)",e.currentTarget.style.color="var(--accent)",e.currentTarget.style.borderColor="rgba(37,99,235,0.35)"},onMouseLeave:e=>{e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color=T?"var(--accent)":"var(--text-muted)",e.currentTarget.style.borderColor=T?"rgba(37,99,235,0.25)":"var(--border)"},children:T?(0,n.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),(0,n.jsx)("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}):(0,n.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),(0,n.jsx)("path",{d:"M7 11V7a5 5 0 0 1 9.9-1"})]})}),(0,n.jsx)("button",{onClick:W,title:"Rename",style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,padding:0,background:"var(--bg-hover)",border:"1px solid var(--border)",borderRadius:7,color:"var(--text-muted)",cursor:"pointer",flexShrink:0,transition:"background 0.12s, color 0.12s, border-color 0.12s"},onMouseEnter:e=>{e.currentTarget.style.background="var(--bg-selected)",e.currentTarget.style.color="var(--accent)",e.currentTarget.style.borderColor="rgba(37,99,235,0.35)"},onMouseLeave:e=>{e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color="var(--text-muted)",e.currentTarget.style.borderColor="var(--border)"},children:(0,n.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("path",{d:"M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"})})}),(0,n.jsx)("button",{onClick:T?void 0:M,disabled:T,title:T?"本会话已被锁定,无法删除。请先解锁!":"Delete",style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,padding:0,background:"var(--bg-hover)",border:"1px solid var(--border)",borderRadius:7,color:T?"var(--text-dim)":"var(--text-muted)",cursor:T?"not-allowed":"pointer",flexShrink:0,opacity:T?.35:1,transition:"background 0.12s, color 0.12s, border-color 0.12s"},onMouseEnter:e=>{T||(e.currentTarget.style.background="rgba(239,68,68,0.08)",e.currentTarget.style.color="#ef4444",e.currentTarget.style.borderColor="rgba(239,68,68,0.35)")},onMouseLeave:e=>{T||(e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color="var(--text-muted)",e.currentTarget.style.borderColor="var(--border)")},children:(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("polyline",{points:"3 6 5 6 21 6"}),(0,n.jsx)("path",{d:"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"}),(0,n.jsx)("path",{d:"M10 11v6M14 11v6"}),(0,n.jsx)("path",{d:"M9 6V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2"})]})})]})]})})}let ee=null,et=null;function er(e,t,r){let n,o,i=t;try{let e=null;if(r){let t=localStorage.getItem("mimo_history_voice_settings");t&&(e=JSON.parse(t)[r])}if(!e){let t=localStorage.getItem("mimo_voice_settings");t&&(e=JSON.parse(t))}if(e){let r=(e.modelId||t||"").toLowerCase();i=e.modelId||t,r.includes("voicedesign")||r.includes("design")?(n=void 0,o=e.voiceDesignPrompt||""):r.includes("voiceclone")||r.includes("clone")?n=e.voiceCloneAudioData?e.voiceCloneAudioData:void 0:r.includes("tts")&&(n=e.presetVoice||"mimo_default")}}catch(e){console.error("Failed to read voice settings in getVoiceParams:",e)}return{text:e,voice:n,modelId:i,voiceDesignPrompt:o}}async function en(e){if(!window.caches)return null;try{let t=JSON.stringify(e),r=`https://mimo.local/audio?key=${encodeURIComponent(t)}`,n=await caches.open("mimo-tts-cache"),o=await n.match(r);if(o)return await o.text()}catch(e){console.error("Error reading from Cache Storage:",e)}return null}async function eo(e,t){if(window.caches)try{let r=JSON.stringify(e),n=`https://mimo.local/audio?key=${encodeURIComponent(r)}`,o=await caches.open("mimo-tts-cache");await o.put(n,new Response(t))}catch(e){console.error("Error writing to Cache Storage:",e)}}function ei(e,t){if(!t)return!1;let r=t.toLowerCase(),n=e?.toLowerCase()||"";return r.includes("tts")||r.includes("voiceclone")||r.includes("voicedesign")||r.includes("audio-gen")||n.includes("mimo-tts")}function el(e,t){if(!t)return!1;let r=t.toLowerCase();return r.includes("voiceclone")||r.includes("clone")}function es(e,t){if(!t)return!1;let r=t.toLowerCase();return r.includes("voicedesign")||r.includes("design")}function ea(e){if(!e)return null;let t=new Date(e),r=new Date,n=t.getFullYear()===r.getFullYear()&&t.getMonth()===r.getMonth()&&t.getDate()===r.getDate(),o=t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});if(n)return o;let i=t.toLocaleDateString([],{month:"short",day:"numeric",year:t.getFullYear()!==r.getFullYear()?"numeric":void 0});return`${i} ${o}`}function ed(e){if(navigator.clipboard?.writeText)return navigator.clipboard.writeText(e);try{let t=document.createElement("textarea");return t.value=e,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t),Promise.resolve()}catch{return Promise.reject()}}function ec(e){if(!e)return{cleanText:"",attachments:[]};let t="\x3c!-- PI_FILE_ATTACHMENTS_START --\x3e",r="\x3c!-- PI_FILE_ATTACHMENTS_END --\x3e",n=e.indexOf(t),o=e.indexOf(r);if(-1===n||-1===o||n>=o)return{cleanText:e,attachments:[]};let i=e.substring(0,n),l=e.substring(o+r.length),s=e.substring(n+t.length,o).trim(),a=(i.trim()+"\n"+l.trim()).trim(),d=[];for(let e of s.split("\n")){let t=e.trim();if(!t||t.startsWith("\uD83D\uDCC4")||t.includes("已上传文件"))continue;let r=t.match(/^[-*]\s+(.+?)(?:\s+\((.+?)\))?$/)||t.match(/^(.+?)(?:\s+\((.+?)\))?$/);if(r){let e=r[1].trim(),t=r[2]?.trim(),n=e.split(/[/\\]/),o=n[n.length-1]||e;d.push({name:o,path:e,size:t})}}return{cleanText:a,attachments:d}}function ep({file:e,cwd:t}){let r=/\.(wav|mp3|ogg|m4a|webm|aac)$/i.test(e.name),i=/\.(png|jpe?g|gif|webp|svg|bmp)$/i.test(e.name),l=/\.(js|jsx|ts|tsx|json|html|css|py|go|rs|cpp|c|h|sh|bat|md)$/i.test(e.name),[s,a]=(0,o.useState)(!1),d=(0,o.useRef)(null);(0,o.useEffect)(()=>()=>{d.current&&(d.current.pause(),d.current=null)},[]);let c="var(--text-dim)",p="rgba(255, 255, 255, 0.03)",x="1px solid var(--border)",u="rgba(255, 255, 255, 0.06)";return r?(c="var(--accent)",p="rgba(59, 130, 246, 0.05)",x="1px solid rgba(59, 130, 246, 0.15)",u="rgba(59, 130, 246, 0.09)"):i?(c="#e11d48",p="rgba(225, 29, 72, 0.05)",x="1px solid rgba(225, 29, 72, 0.15)",u="rgba(225, 29, 72, 0.09)"):l&&(c="#10b981",p="rgba(16, 185, 129, 0.05)",x="1px solid rgba(16, 185, 129, 0.15)",u="rgba(16, 185, 129, 0.09)"),(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 12px",background:p,border:x,borderRadius:8,fontSize:12.5,color:"var(--text)",maxWidth:320,boxShadow:"0 1px 2px rgba(0, 0, 0, 0.05)",transition:"transform 0.15s ease, background 0.15s ease, border-color 0.15s ease",cursor:r?"pointer":"default",userSelect:"none"},onClick:r?n=>{if(r)if(n.stopPropagation(),s)d.current?.pause(),a(!1);else{if(!d.current){let r=e.path;if(t&&!/^[a-zA-Z]:/i.test(r)&&!r.startsWith("/")){let n=t.replace(/[\\/]+$/,"");r=`${n}/${e.path}`}let n=r.replace(/\\/g,"/").split("/").filter(Boolean).map(encodeURIComponent).join("/"),o=new Audio(`/api/files/${n}?type=read`);o.onended=()=>a(!1),o.onerror=()=>a(!1),d.current=o}d.current.play().catch(()=>a(!1)),a(!0)}}:void 0,onMouseEnter:e=>{e.currentTarget.style.transform="translateY(-1px)",e.currentTarget.style.background=u,r&&(e.currentTarget.style.borderColor="var(--accent)")},onMouseLeave:e=>{e.currentTarget.style.transform="translateY(0)",e.currentTarget.style.background=p,e.currentTarget.style.borderColor=r?"rgba(59, 130, 246, 0.15)":i?"rgba(225, 29, 72, 0.15)":l?"rgba(16, 185, 129, 0.15)":"var(--border)"},children:[(0,n.jsx)("span",{style:{display:"flex",alignItems:"center",color:c,flexShrink:0},children:r?s?(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{animation:"pulse 1s infinite"},children:[(0,n.jsx)("rect",{x:"6",y:"4",width:"4",height:"16"}),(0,n.jsx)("rect",{x:"14",y:"4",width:"4",height:"16"})]}):(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),(0,n.jsx)("path",{d:"M15.54 8.46a5 5 0 0 1 0 7.07"})]}):i?(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),(0,n.jsx)("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),(0,n.jsx)("polyline",{points:"21 15 16 10 5 21"})]}):l?(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("polyline",{points:"16 18 22 12 16 6"}),(0,n.jsx)("polyline",{points:"8 6 2 12 8 18"})]}):(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),(0,n.jsx)("polyline",{points:"14 2 14 8 20 8"})]})}),(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,minWidth:0,overflow:"hidden"},children:[(0,n.jsx)("span",{style:{fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:180},title:e.path,children:e.name}),e.size&&(0,n.jsxs)("span",{style:{fontSize:10,color:"var(--text-dim)",flexShrink:0},children:["(",e.size,")"]})]}),r&&s&&(0,n.jsxs)("div",{style:{display:"flex",gap:1.5,alignItems:"flex-end",height:11,marginLeft:4,flexShrink:0},children:[(0,n.jsx)("style",{children:`
15
+ `}),(0,n.jsx)(V,{isOpen:eo,onClose:()=>ei(!1),gemId:el,onSave:()=>nJ(),modelList:ee,defaultModel:er}),eI&&(0,n.jsx)("div",{style:{position:"fixed",inset:0,zIndex:999,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.5)",backdropFilter:"blur(4px)"},children:(0,n.jsxs)("div",{style:{background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:"12px",width:"min(420px, 90vw)",padding:"20px",boxShadow:"0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1)",fontFamily:"var(--font-serif)"},children:[(0,n.jsxs)("h3",{style:{margin:"0 0 12px",fontSize:"15px",fontWeight:600,color:"#ef4444",display:"flex",alignItems:"center",gap:8,borderBottom:"1px solid var(--border)",paddingBottom:"10px"},children:[(0,n.jsx)("span",{children:"⚠️"}),(0,n.jsx)("span",{children:"删除书籍确认 (Delete Book)"})]}),eL?(0,n.jsxs)("div",{style:{padding:"20px 10px",textAlign:"center"},children:[(0,n.jsx)("div",{style:{width:"30px",height:"30px",border:"3px solid var(--border)",borderTopColor:"#ef4444",borderRadius:"50%",animation:"spin 1s linear infinite",margin:"0 auto 16px"}}),(0,n.jsx)("div",{style:{fontWeight:600,color:"var(--text)",fontSize:"12px"},children:"正在彻底删除书籍及相关数据..."})]}):(0,n.jsxs)("div",{children:[eE&&(0,n.jsxs)("div",{style:{background:"rgba(239, 68, 68, 0.08)",border:"1px solid rgba(239, 68, 68, 0.2)",borderRadius:"6px",padding:"10px",color:"#ef4444",fontSize:"11px",marginBottom:"16px",lineHeight:1.5},children:["⚠️ ",eE]}),(0,n.jsxs)("p",{style:{fontSize:"12px",color:"var(--text)",lineHeight:1.6,margin:"0 0 16px"},children:["您确定要永久删除书籍 ",(0,n.jsx)("strong",{style:{color:"#ef4444"},children:eO})," 吗?"]}),(0,n.jsxs)("div",{style:{background:"rgba(239, 68, 68, 0.04)",border:"1px dashed rgba(239, 68, 68, 0.25)",borderRadius:"8px",padding:"10px 12px",fontSize:"11px",color:"var(--text-muted)",lineHeight:1.5,marginBottom:"20px"},children:[(0,n.jsx)("strong",{children:"此操作不可逆!"})," 它将永久清除:",(0,n.jsxs)("ul",{style:{margin:"4px 0 0",paddingLeft:"16px"},children:[(0,n.jsx)("li",{children:"该书的所有章节草稿正文"}),(0,n.jsx)("li",{children:"人物卡片设定与世界观设定"}),(0,n.jsx)("li",{children:"所有的历史修订版本快照与大纲"})]})]}),(0,n.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",gap:"10px"},children:[(0,n.jsx)("button",{type:"button",onClick:()=>eR(!1),style:{padding:"6px 14px",border:"1px solid var(--border)",borderRadius:"6px",background:"transparent",color:"var(--text-muted)",fontSize:"12px",cursor:"pointer"},children:"取消"}),(0,n.jsx)("button",{type:"button",onClick:nN,style:{padding:"6px 16px",background:"#ef4444",border:"none",borderRadius:"6px",color:"white",fontSize:"12px",fontWeight:600,cursor:"pointer"},children:"确认删除"})]})]})]})}),ek&&(0,n.jsx)("div",{style:{position:"fixed",inset:0,zIndex:999,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.5)",backdropFilter:"blur(4px)"},children:(0,n.jsxs)("div",{style:{background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:"12px",width:"min(480px, 90vw)",padding:"20px",boxShadow:"0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1)",fontFamily:"var(--font-serif)"},children:[(0,n.jsxs)("h3",{style:{margin:"0 0 16px",fontSize:"15px",fontWeight:600,color:"var(--text)",display:"flex",alignItems:"center",gap:8,borderBottom:"1px solid var(--border)",paddingBottom:"10px"},children:[(0,n.jsx)("span",{children:"\uD83D\uDCDA"}),(0,n.jsx)("span",{children:"创建新小说书籍 (Create Book)"})]}),eS?(0,n.jsxs)("div",{style:{padding:"30px 10px",textAlign:"center"},children:[(0,n.jsx)("div",{style:{width:"36px",height:"36px",border:"3px solid var(--border)",borderTopColor:"var(--accent)",borderRadius:"50%",animation:"spin 1s linear infinite",margin:"0 auto 16px"}}),(0,n.jsx)("div",{style:{fontWeight:600,color:"var(--text)",marginBottom:8,fontSize:"13px"},children:"正在生成创作宇宙基础设定..."}),(0,n.jsx)("div",{style:{color:"var(--text-muted)",fontSize:"11px",lineHeight:1.6,maxWidth:"300px",margin:"0 auto"},children:"AI 架构师正在分析题材大纲,并自动构建卷大纲、角色设定卡片与世界观法则,请稍候约 30 秒。"})]}):(0,n.jsxs)("form",{onSubmit:nF,children:[eT&&(0,n.jsxs)("div",{style:{background:"rgba(239, 68, 68, 0.08)",border:"1px solid rgba(239, 68, 68, 0.2)",borderRadius:"6px",padding:"10px",color:"#ef4444",fontSize:"11px",marginBottom:"16px",lineHeight:1.5},children:["⚠️ ",eT]}),ny||nm?(0,n.jsxs)("div",{style:{background:"var(--bg)",border:"1px solid var(--border)",borderRadius:"8px",padding:"12px",marginBottom:"16px",fontSize:"12px"},children:[(0,n.jsx)("div",{style:{fontWeight:600,color:"var(--text)",marginBottom:"8px",display:"flex",alignItems:"center",gap:6},children:(0,n.jsx)("span",{children:"\uD83D\uDD0D 检测到本地创作设定,请选择是否作为新书创建基础:"})}),(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[ny&&(0,n.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",color:"var(--text)"},children:[(0,n.jsx)("input",{type:"checkbox",checked:nk,onChange:e=>nw(e.target.checked),style:{cursor:"pointer"}}),(0,n.jsxs)("span",{children:["小说框架:",(0,n.jsx)("code",{style:{fontFamily:"var(--font-mono)",fontSize:"11px",color:"var(--accent)"},children:ny.name})]})]}),nm&&(0,n.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",color:"var(--text)"},children:[(0,n.jsx)("input",{type:"checkbox",checked:nS,onChange:e=>nC(e.target.checked),style:{cursor:"pointer"}}),(0,n.jsxs)("span",{children:["角色人设:",(0,n.jsx)("code",{style:{fontFamily:"var(--font-mono)",fontSize:"11px",color:"var(--accent)"},children:nm.name})]})]})]})]}):(0,n.jsxs)("div",{style:{background:"var(--bg-panel)",border:"1px dashed var(--border)",borderRadius:"8px",padding:"12px",marginBottom:"16px",fontSize:"11px",lineHeight:1.6,color:"var(--text-muted)"},children:[(0,n.jsx)("div",{style:{fontWeight:600,color:"var(--text)",marginBottom:"6px",display:"flex",alignItems:"center",gap:6},children:(0,n.jsx)("span",{children:"\uD83D\uDCA1 创作建议与提示"})}),"当前未检测到本地的「小说框架」或「角色人设」设定文件。您可以:",(0,n.jsxs)("ul",{style:{margin:"4px 0 0",paddingLeft:"16px",display:"flex",flexDirection:"column",gap:"2px"},children:[(0,n.jsxs)("li",{children:[(0,n.jsx)("strong",{children:"直接创建书卷"}),":忽略此提示,系统将自动为您构思并生成初始的世界观与角色人设。"]}),(0,n.jsxs)("li",{children:[(0,n.jsx)("strong",{children:"AI 协同起草"}),":先关闭此窗口,用左侧的",(0,n.jsx)("strong",{children:"「AI写作伴侣」"}),"来共同探讨并起草您的框架与人设设定,保存后再行创建。"]})]})]}),(0,n.jsxs)("div",{style:{marginBottom:"14px"},children:[(0,n.jsx)("label",{style:{display:"block",fontSize:"11px",fontWeight:600,color:"var(--text-muted)",marginBottom:"6px"},children:"小说书名 (Title)"}),(0,n.jsx)("input",{type:"text",required:!0,value:nc,onChange:e=>np(e.target.value),placeholder:"例如:万古大帝",style:{width:"100%",padding:"8px 12px",border:"1px solid var(--border)",borderRadius:"6px",background:"var(--bg)",color:"var(--text)",fontSize:"12px",fontFamily:"var(--font-serif)",outline:"none"}})]}),(0,n.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px",marginBottom:"14px"},children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{style:{display:"block",fontSize:"11px",fontWeight:600,color:"var(--text-muted)",marginBottom:"6px"},children:"小说题材 (Genre)"}),(0,n.jsxs)("select",{value:nx,onChange:e=>nu(e.target.value),style:{width:"100%",padding:"8px 12px",border:"1px solid var(--border)",borderRadius:"6px",background:"var(--bg)",color:"var(--text)",fontSize:"12px",outline:"none"},children:[(0,n.jsxs)("optgroup",{label:"中文网文题材 (Chinese Genres)",style:{background:"var(--bg-panel)",color:"var(--text)"},children:[(0,n.jsx)("option",{value:"xuanhuan",children:"玄幻奇幻 (Xuanhuan)"}),(0,n.jsx)("option",{value:"xianxia",children:"仙侠修真 (Xianxia)"}),(0,n.jsx)("option",{value:"urban",children:"都市异能 (Urban)"}),(0,n.jsx)("option",{value:"horror",children:"悬疑恐怖 (Horror)"}),(0,n.jsx)("option",{value:"other",children:"其它通用 (Other)"})]}),(0,n.jsxs)("optgroup",{label:"英文原生题材 (English Genres)",style:{background:"var(--bg-panel)",color:"var(--text)"},children:[(0,n.jsx)("option",{value:"litrpg",children:"数据无限流/系统流 (LitRPG)"}),(0,n.jsx)("option",{value:"progression",children:"升级流奇幻 (Progression Fantasy)"}),(0,n.jsx)("option",{value:"cozy",children:"温馨奇幻 (Cozy Fantasy)"}),(0,n.jsx)("option",{value:"cultivation",children:"英文修真 (English Cultivation)"}),(0,n.jsx)("option",{value:"dungeon-core",children:"地下城核心流 (Dungeon Core)"}),(0,n.jsx)("option",{value:"isekai",children:"异世界穿梭 (Isekai / Portal Fantasy)"}),(0,n.jsx)("option",{value:"romantasy",children:"浪漫奇幻 (Romantasy)"}),(0,n.jsx)("option",{value:"sci-fi",children:"科学幻想 (Science Fiction)"}),(0,n.jsx)("option",{value:"system-apocalypse",children:"系统废土流 (System Apocalypse)"}),(0,n.jsx)("option",{value:"tower-climber",children:"爬塔闯关流 (Tower Climbing)"})]}),(0,n.jsx)("optgroup",{label:"特殊创作模式 (Special Modes)",style:{background:"var(--bg-panel)",color:"var(--text)"},children:(0,n.jsx)("option",{value:"fanfic",children:"同人创作 (Fanfic)"})})]})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{style:{display:"block",fontSize:"11px",fontWeight:600,color:"var(--text-muted)",marginBottom:"6px"},children:"目标平台 (Platform)"}),(0,n.jsxs)("select",{value:ng,onChange:e=>nh(e.target.value),style:{width:"100%",padding:"8px 12px",border:"1px solid var(--border)",borderRadius:"6px",background:"var(--bg)",color:"var(--text)",fontSize:"12px",outline:"none"},children:[(0,n.jsx)("option",{value:"tomato",children:"番茄小说 (Tomato)"}),(0,n.jsx)("option",{value:"qidian",children:"起点中文 (Qidian)"}),(0,n.jsx)("option",{value:"other",children:"其他独立平台 (Other)"})]})]})]}),"fanfic"===nx?(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:"12px",marginBottom:"20px"},children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{style:{display:"block",fontSize:"11px",fontWeight:600,color:"var(--text-muted)",marginBottom:"6px"},children:"同人创作模式 (Fanfic Mode)"}),(0,n.jsxs)("select",{value:rr,onChange:e=>rn(e.target.value),style:{width:"100%",padding:"8px 12px",border:"1px solid var(--border)",borderRadius:"6px",background:"var(--bg)",color:"var(--text)",fontSize:"12px",outline:"none"},children:[(0,n.jsx)("option",{value:"canon",children:"正典延续 (Canon - 忠实原著剧情补完)"}),(0,n.jsx)("option",{value:"au",children:"平行宇宙 (AU - 相同设定不同时空/世界)"}),(0,n.jsx)("option",{value:"ooc",children:"角色偏离 (OOC - 性格反转与脑洞脑侧)"}),(0,n.jsx)("option",{value:"cp",children:"角色配对 (CP - 深入刻画人物关系与情感)"})]})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{style:{display:"block",fontSize:"11px",fontWeight:600,color:"var(--text-muted)",marginBottom:"6px"},children:"原作素材文件/目录绝对路径 (Source Path - 必填)"}),(0,n.jsx)("input",{type:"text",value:ro,onChange:e=>ri(e.target.value),placeholder:"请输入原作素材的绝对路径,例如: D:/novel/source.txt",required:!0,style:{width:"100%",padding:"8px 12px",border:"1px solid var(--border)",borderRadius:"6px",background:"var(--bg)",color:"var(--text)",fontSize:"12px",fontFamily:"var(--font-serif)",outline:"none"}}),(0,n.jsx)("div",{style:{color:"var(--text-dim)",fontSize:"10px",marginTop:"4px",lineHeight:1.4},children:"支持指向一个 `.txt` / `.md` 文本文件,或包含若干原作设定/故事文本的文件夹绝对路径。AI 将会自动提取并解析作为同人设定依据。"})]})]}):(0,n.jsxs)("div",{style:{marginBottom:"20px"},children:[(0,n.jsx)("label",{style:{display:"block",fontSize:"11px",fontWeight:600,color:"var(--text-muted)",marginBottom:"6px"},children:"大纲梗概/创意简报 (Brief - 可选)"}),(0,n.jsx)("textarea",{value:nf,onChange:e=>nb(e.target.value),placeholder:"在此输入您的创意构想(例如:主角是退役兵王、金手指是万界交易面板、核心冲突为世家倾轧)。AI 架构师将优先融合您的创意进行大纲设定设计。",rows:4,style:{width:"100%",padding:"8px 12px",border:"1px solid var(--border)",borderRadius:"6px",background:"var(--bg)",color:"var(--text)",fontSize:"12px",fontFamily:"var(--font-serif)",lineHeight:"1.6",outline:"none",resize:"vertical"}})]}),(0,n.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",gap:"10px",borderTop:"1px solid var(--border)",paddingTop:"14px"},children:[(0,n.jsx)("button",{type:"button",onClick:()=>ew(!1),style:{padding:"6px 14px",border:"1px solid var(--border)",borderRadius:"6px",background:"transparent",color:"var(--text-muted)",fontSize:"12px",cursor:"pointer"},children:"取消"}),(0,n.jsx)("button",{type:"submit",style:{padding:"6px 16px",background:"var(--accent)",border:"none",borderRadius:"6px",color:"white",fontSize:"12px",fontWeight:600,cursor:"pointer"},children:"确认创建"})]})]})]})}),eP&&(0,n.jsx)("div",{style:{position:"fixed",inset:0,zIndex:999,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.5)",backdropFilter:"blur(4px)"},children:(0,n.jsxs)("div",{style:{background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:"12px",width:"min(600px, 90vw)",padding:"24px 20px",boxShadow:"0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1)",fontFamily:"var(--font-serif)",textAlign:"center"},children:[eQ?(0,n.jsx)("div",{style:{fontSize:"28px",margin:"0 auto 12px",color:"#ef4444"},children:"⚠️"}):(0,n.jsx)("div",{style:{width:"36px",height:"36px",border:"3px solid var(--border)",borderTopColor:"var(--accent)",borderRadius:"50%",animation:"spin 1s linear infinite",margin:"0 auto 16px"}}),(0,n.jsx)("div",{style:{fontWeight:600,color:eQ?"#ef4444":"var(--text)",marginBottom:8,fontSize:"14px"},children:eQ?"智能写作首章失败":"正在进行智能首章写作..."}),(0,n.jsx)("div",{style:{color:"var(--text-muted)",fontSize:"11px",lineHeight:1.6},children:eQ?`错误详情: ${eQ}`:e_}),(0,n.jsx)("div",{ref:tu,style:{background:"#121214",border:"1px solid var(--border)",borderRadius:"6px",padding:"12px",height:"240px",overflowY:"auto",textAlign:"left",fontFamily:"var(--font-mono), monospace",fontSize:"11px",lineHeight:"1.5",color:"#e4e4e7",whiteSpace:"pre-wrap",wordBreak:"break-all",marginTop:"16px"},children:0===eZ.length?(0,n.jsx)("span",{style:{color:"var(--text-dim)"},children:"正在启动写作引擎..."}):eZ.map((e,t)=>(0,n.jsx)("div",{style:{marginBottom:2},children:e},t))}),eQ&&(0,n.jsx)("div",{style:{display:"flex",justifyContent:"center",marginTop:16},children:(0,n.jsx)("button",{onClick:()=>{eH(!1),e0(null)},style:{padding:"6px 20px",background:"var(--accent)",border:"none",borderRadius:"6px",color:"white",fontSize:"12px",fontWeight:600,cursor:"pointer"},children:"关闭"})})]})}),eG&&(0,n.jsx)("div",{style:{position:"fixed",inset:0,zIndex:999,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.5)",backdropFilter:"blur(4px)"},children:(0,n.jsxs)("div",{style:{background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:"12px",width:"min(500px, 90vw)",maxHeight:"80vh",display:"flex",flexDirection:"column",boxShadow:"0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1)",fontFamily:"var(--font-serif)",overflow:"hidden"},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"14px 18px",borderBottom:"1px solid var(--border)",background:"var(--bg-panel)",flexShrink:0},children:[(0,n.jsx)("span",{style:{fontSize:13,fontWeight:600,color:"var(--text)"},children:eU}),(0,n.jsx)("button",{onClick:()=>eq(!1),style:{padding:"4px 12px",fontSize:11,borderRadius:4,border:"1px solid var(--border)",background:"var(--bg-hover)",color:"var(--text-muted)",cursor:"pointer",fontWeight:600},children:"✕ 关闭"})]}),(0,n.jsx)("div",{style:{flex:1,padding:"18px",overflowY:"auto",lineHeight:"1.8",fontSize:"12px",color:"var(--text)"},className:"markdown-body",children:(0,n.jsx)(H.oz,{remarkPlugins:[_.A],children:eY})})]})}),e7&&(0,n.jsx)("div",{style:{position:"fixed",inset:0,zIndex:1e3,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.55)",backdropFilter:"blur(4px)"},children:(0,n.jsxs)("div",{style:{background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:12,width:"480px",maxWidth:"90%",boxShadow:"0 10px 30px rgba(0,0,0,0.25)",display:"flex",flexDirection:"column",overflow:"hidden",fontFamily:"var(--font-serif)"},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 20px",borderBottom:"1px solid var(--border)",background:"var(--bg)"},children:[(0,n.jsxs)("span",{style:{fontSize:14,fontWeight:700,color:"var(--text)"},children:["\uD83D\uDCE4 导出小说书稿 (",eO,")"]}),(0,n.jsx)("button",{onClick:()=>{ti||te(!1)},disabled:ti,style:{background:"none",border:"none",color:"var(--text-dim)",fontSize:14,cursor:ti?"not-allowed":"pointer"},children:"✕"})]}),(0,n.jsxs)("form",{onSubmit:nW,style:{padding:"20px",display:"flex",flexDirection:"column",gap:16},children:[(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[(0,n.jsx)("label",{style:{fontSize:12,fontWeight:600,color:"var(--text-muted)"},children:"选择导出格式"}),(0,n.jsx)("div",{style:{display:"flex",gap:8},children:["epub","txt","md"].map(e=>(0,n.jsxs)("label",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",gap:6,height:38,background:tt===e?"var(--bg-selected)":"var(--bg)",border:tt===e?"1px solid var(--accent)":"1px solid var(--border)",borderRadius:8,fontSize:12,fontWeight:600,color:tt===e?"var(--accent)":"var(--text-muted)",cursor:ti?"not-allowed":"pointer",transition:"all 0.15s"},children:[(0,n.jsx)("input",{type:"radio",name:"exportFormat",value:e,checked:tt===e,disabled:ti,onChange:()=>tr(e),style:{display:"none"}}),(0,n.jsx)("span",{children:e.toUpperCase()})]},e))})]}),(0,n.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:8,fontSize:12,color:"var(--text)",cursor:ti?"not-allowed":"pointer",userSelect:"none"},children:[(0,n.jsx)("input",{type:"checkbox",checked:tn,disabled:ti,onChange:e=>to(e.target.checked),style:{width:14,height:14,accentColor:"var(--accent)",cursor:"pointer"}}),(0,n.jsx)("span",{children:"仅导出已过审章节 (Approved Only)"})]}),(ti||tp.length>0||ts||td)&&(0,n.jsxs)("div",{style:{background:"var(--bg)",border:"1px solid var(--border)",borderRadius:8,padding:"12px",fontSize:11,display:"flex",flexDirection:"column",gap:8},children:[ts&&(0,n.jsxs)("div",{style:{color:"#ef4444",fontWeight:600},children:["⚠️ 导出失败: ",ts]}),td&&(0,n.jsx)("div",{style:{color:"#10b981",fontWeight:600},children:td}),ti&&(0,n.jsxs)("div",{style:{color:"var(--accent)",display:"flex",alignItems:"center",gap:6},children:[(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",className:"animate-spin",style:{animation:"spin 1s linear infinite"},children:[(0,n.jsx)("line",{x1:"12",y1:"2",x2:"12",y2:"6"}),(0,n.jsx)("line",{x1:"12",y1:"18",x2:"12",y2:"22"}),(0,n.jsx)("line",{x1:"4.93",y1:"4.93",x2:"7.76",y2:"7.76"}),(0,n.jsx)("line",{x1:"16.24",y1:"16.24",x2:"19.07",y2:"19.07"}),(0,n.jsx)("line",{x1:"2",y1:"12",x2:"6",y2:"12"}),(0,n.jsx)("line",{x1:"18",y1:"12",x2:"22",y2:"12"}),(0,n.jsx)("line",{x1:"4.93",y1:"19.07",x2:"7.76",y2:"16.24"}),(0,n.jsx)("line",{x1:"16.24",y1:"7.76",x2:"19.07",y2:"4.93"})]}),(0,n.jsx)("span",{children:"正在整理并排版书稿中,请稍候..."})]}),tp.length>0&&(0,n.jsx)("div",{style:{maxHeight:"80px",overflowY:"auto",fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-dim)",background:"rgba(0,0,0,0.15)",padding:"6px",borderRadius:4,whiteSpace:"pre-wrap"},children:tp.join("")})]}),(0,n.jsxs)("div",{style:{display:"flex",gap:8,marginTop:8},children:[(0,n.jsx)("button",{type:"submit",disabled:ti,style:{flex:1,height:38,background:"var(--accent)",border:"none",borderRadius:8,color:"white",fontSize:12,fontWeight:600,cursor:ti?"not-allowed":"pointer",opacity:ti?.7:1},children:ti?"正在导出...":"确认开始导出"}),!ti&&(0,n.jsx)("button",{type:"button",onClick:()=>te(!1),style:{padding:"0 16px",height:38,background:"var(--bg-hover)",border:"1px solid var(--border)",borderRadius:8,color:"var(--text-muted)",fontSize:12,fontWeight:500,cursor:"pointer"},children:"取消"})]})]})]})}),tg&&(0,n.jsx)("div",{style:{position:"fixed",inset:0,zIndex:1e3,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.55)",backdropFilter:"blur(4px)"},children:(0,n.jsxs)("div",{style:{background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:12,width:"500px",maxWidth:"95%",boxShadow:"0 10px 30px rgba(0,0,0,0.25)",display:"flex",flexDirection:"column",overflow:"hidden",fontFamily:"var(--font-serif)"},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 20px",borderBottom:"1px solid var(--border)",background:"var(--bg)"},children:[(0,n.jsxs)("span",{style:{fontSize:14,fontWeight:700,color:"var(--text)"},children:["\uD83D\uDCE5 InkOS 导入向导 (",eO,")"]}),(0,n.jsx)("button",{onClick:()=>{tI||th(!1)},disabled:tI,style:{background:"none",border:"none",color:"var(--text-dim)",fontSize:14,cursor:tI?"not-allowed":"pointer"},children:"✕"})]}),(0,n.jsxs)("div",{style:{display:"flex",borderBottom:"1px solid var(--border)",background:"var(--bg-panel)"},children:[(0,n.jsx)("button",{type:"button",onClick:()=>{tI||tb("chapters")},disabled:tI,style:{flex:1,padding:"10px 0",fontSize:12,fontWeight:600,border:"none",background:"chapters"===tf?"var(--bg)":"transparent",color:"chapters"===tf?"var(--accent)":"var(--text-muted)",borderBottom:"chapters"===tf?"2px solid var(--accent)":"none",cursor:tI?"not-allowed":"pointer",transition:"all 0.15s"},children:"\uD83D\uDCE5 导入旧章原稿"}),(0,n.jsx)("button",{type:"button",onClick:()=>{tI||tb("canon")},disabled:tI,style:{flex:1,padding:"10px 0",fontSize:12,fontWeight:600,border:"none",background:"canon"===tf?"var(--bg)":"transparent",color:"canon"===tf?"var(--accent)":"var(--text-muted)",borderBottom:"canon"===tf?"2px solid var(--accent)":"none",cursor:tI?"not-allowed":"pointer",transition:"all 0.15s"},children:"\uD83D\uDCD6 导入前作设定 (Canon)"})]}),(0,n.jsxs)("form",{onSubmit:nM,style:{padding:"20px",display:"flex",flexDirection:"column",gap:14},children:["chapters"===tf?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[(0,n.jsx)("label",{style:{fontSize:11,fontWeight:600,color:"var(--text-muted)"},children:"选择导入的目标书籍*"}),tB.length>0?(0,n.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:8},children:(0,n.jsxs)("div",{style:{display:"flex",gap:10},children:[(0,n.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:6,fontSize:11,color:"var(--text)",cursor:"pointer"},children:[(0,n.jsx)("input",{type:"radio",name:"importBookSelect",checked:"active"===tO,onChange:()=>tF("active"),disabled:tI,style:{accentColor:"var(--accent)"}}),(0,n.jsxs)("span",{children:["当前书籍 (",eO,")"]})]}),(0,n.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:6,fontSize:11,color:"var(--text)",cursor:"pointer"},children:[(0,n.jsx)("input",{type:"radio",name:"importBookSelect",checked:"new"===tO,onChange:()=>tF("new"),disabled:tI,style:{accentColor:"var(--accent)"}}),(0,n.jsx)("span",{children:"➕ 导入并创建新书籍"})]})]})}):(0,n.jsx)("span",{style:{fontSize:10,color:"var(--text-dim)"},children:"⚠️ 当前小说宇宙内尚无书籍,将自动创建新书籍进行导入。"})]}),("new"===tO||0===tB.length)&&(0,n.jsx)("div",{style:{background:"rgba(var(--accent-rgb), 0.03)",border:"1px dashed var(--border)",borderRadius:8,padding:"10px 12px",display:"flex",flexDirection:"column",gap:8},children:(0,n.jsxs)("div",{style:{display:"flex",gap:10},children:[(0,n.jsxs)("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:4},children:[(0,n.jsx)("label",{style:{fontSize:10,fontWeight:600,color:"var(--text-muted)"},children:"新书籍 ID (拼音/英文)*"}),(0,n.jsx)("input",{type:"text",value:tN,onChange:e=>tP(e.target.value.replace(/[^a-zA-Z0-9_\-]/g,"")),placeholder:"如: my_new_novel",disabled:tI,style:{width:"100%",padding:"6px 8px",borderRadius:4,background:"var(--bg)",border:"1px solid var(--border)",color:"var(--text)",fontSize:11,fontFamily:"var(--font-mono)",outline:"none"},required:!0})]}),(0,n.jsxs)("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:4},children:[(0,n.jsx)("label",{style:{fontSize:10,fontWeight:600,color:"var(--text-muted)"},children:"新书籍名称*"}),(0,n.jsx)("input",{type:"text",value:tH,onChange:e=>t_(e.target.value),placeholder:"如: 我的新科幻小说",disabled:tI,style:{width:"100%",padding:"6px 8px",borderRadius:4,background:"var(--bg)",border:"1px solid var(--border)",color:"var(--text)",fontSize:11,fontFamily:"var(--font-serif)",outline:"none"},required:!0})]})]})}),(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[(0,n.jsx)("label",{style:{fontSize:11,fontWeight:600,color:"var(--text-muted)"},children:"输入源文件或文件夹路径 (from)*"}),(0,n.jsx)("input",{type:"text",value:ty,onChange:e=>tv(e.target.value),placeholder:"如: D:/novel/drafts (目录) 或 D:/draft.txt (单文件)",disabled:tI,style:{width:"100%",padding:"8px 10px",borderRadius:6,background:"var(--bg)",border:"1px solid var(--border)",color:"var(--text)",fontSize:12,fontFamily:"var(--font-mono)",outline:"none"},required:!0}),(0,n.jsx)("span",{style:{fontSize:10,color:"var(--text-dim)",lineHeight:1.4},children:"提示:系统会扫描目录下的所有 .md/.txt 并按文件名排序,或读取大文件进行自动分章,同时**提取人设与设定数据库**以备续写。"})]}),(0,n.jsxs)("div",{style:{display:"flex",gap:10},children:[(0,n.jsxs)("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:6},children:[(0,n.jsx)("label",{style:{fontSize:11,fontWeight:600,color:"var(--text-muted)"},children:"分章正则式 (可选)"}),(0,n.jsx)("input",{type:"text",value:tm,onChange:e=>tj(e.target.value),placeholder:"如: ^第[一二三四五]章",disabled:tI,style:{width:"100%",padding:"8px 10px",borderRadius:6,background:"var(--bg)",border:"1px solid var(--border)",color:"var(--text)",fontSize:12,fontFamily:"var(--font-mono)",outline:"none"}})]}),(0,n.jsxs)("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:6},children:[(0,n.jsx)("label",{style:{fontSize:11,fontWeight:600,color:"var(--text-muted)"},children:"续传章节号 (可选)"}),(0,n.jsx)("input",{type:"number",value:tk,onChange:e=>tw(e.target.value),placeholder:"如: 12",disabled:tI,style:{width:"100%",padding:"8px 10px",borderRadius:6,background:"var(--bg)",border:"1px solid var(--border)",color:"var(--text)",fontSize:12,fontFamily:"var(--font-mono)",outline:"none"}})]})]}),(0,n.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:8,fontSize:11,color:"var(--text)",cursor:tI?"not-allowed":"pointer",userSelect:"none",marginTop:4},children:[(0,n.jsx)("input",{type:"checkbox",checked:tS,disabled:tI,onChange:e=>tC(e.target.checked),style:{width:14,height:14,accentColor:"var(--accent)",cursor:"pointer"}}),(0,n.jsx)("span",{children:"作为独立同宇宙系列作品导入 (shared universe spinoff)"})]})]}):(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[(0,n.jsx)("label",{style:{fontSize:11,fontWeight:600,color:"var(--text-muted)"},children:"选择或输入前作书籍 ID (parentBookId)*"}),tB.filter(e=>e!==eO).length>0?(0,n.jsxs)("select",{value:tT,onChange:e=>tz(e.target.value),disabled:tI,style:{width:"100%",padding:"8px 10px",borderRadius:6,background:"var(--bg)",border:"1px solid var(--border)",color:"var(--text)",fontSize:12,fontFamily:"var(--font-serif)",outline:"none",cursor:"pointer"},required:!0,children:[(0,n.jsx)("option",{value:"",children:"-- 请选择书籍 --"}),tB.filter(e=>e!==eO).map(e=>(0,n.jsx)("option",{value:e,children:e},e))]}):(0,n.jsx)("input",{type:"text",value:tT,onChange:e=>tz(e.target.value),placeholder:"请输入前作 Book ID (例如: my_first_novel)",disabled:tI,style:{width:"100%",padding:"8px 10px",borderRadius:6,background:"var(--bg)",border:"1px solid var(--border)",color:"var(--text)",fontSize:12,fontFamily:"var(--font-mono)",outline:"none"},required:!0}),(0,n.jsx)("span",{style:{fontSize:10,color:"var(--text-dim)",lineHeight:1.4},children:"提示:将从所选的书籍目录中复制并合并人物卡片、纪元史和设定,帮助在全新书籍中开展同宇宙故事线(Spinoff)的创作。"})]}),(tI||tL.length>0||tE||tD)&&(0,n.jsxs)("div",{style:{background:"var(--bg)",border:"1px solid var(--border)",borderRadius:8,padding:"12px",fontSize:11,display:"flex",flexDirection:"column",gap:8},children:[tE&&(0,n.jsxs)("div",{style:{color:"#ef4444",fontWeight:600},children:["⚠️ 导入失败: ",tE]}),tD&&(0,n.jsx)("div",{style:{color:"#10b981",fontWeight:600},children:tD}),tI&&(0,n.jsxs)("div",{style:{color:"var(--accent)",display:"flex",alignItems:"center",gap:6},children:[(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",className:"animate-spin",style:{animation:"spin 1s linear infinite"},children:[(0,n.jsx)("line",{x1:"12",y1:"2",x2:"12",y2:"6"}),(0,n.jsx)("line",{x1:"12",y1:"18",x2:"12",y2:"22"}),(0,n.jsx)("line",{x1:"4.93",y1:"4.93",x2:"7.76",y2:"7.76"}),(0,n.jsx)("line",{x1:"16.24",y1:"16.24",x2:"19.07",y2:"19.07"}),(0,n.jsx)("line",{x1:"2",y1:"12",x2:"6",y2:"12"}),(0,n.jsx)("line",{x1:"18",y1:"12",x2:"22",y2:"12"}),(0,n.jsx)("line",{x1:"4.93",y1:"19.07",x2:"7.76",y2:"16.24"}),(0,n.jsx)("line",{x1:"16.24",y1:"7.76",x2:"19.07",y2:"4.93"})]}),(0,n.jsx)("span",{children:"正在运行 InkOS 智能导入引擎,请稍候..."})]}),tL.length>0&&(0,n.jsx)("div",{ref:ns,style:{maxHeight:"80px",overflowY:"auto",fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-dim)",background:"#121214",padding:"6px",borderRadius:4,whiteSpace:"pre-wrap",textAlign:"left"},children:tL.map((e,t)=>(0,n.jsx)("div",{style:{marginBottom:2},children:e},t))})]}),(0,n.jsxs)("div",{style:{display:"flex",gap:8,marginTop:8},children:[(0,n.jsx)("button",{type:"submit",disabled:tI,style:{flex:1,height:38,background:"var(--accent)",border:"none",borderRadius:8,color:"white",fontSize:12,fontWeight:600,cursor:tI?"not-allowed":"pointer",opacity:tI?.7:1},children:tI?"正在导入...":"确认开始导入"}),!tI&&(0,n.jsx)("button",{type:"button",onClick:()=>th(!1),style:{padding:"0 16px",height:38,background:"var(--bg-hover)",border:"1px solid var(--border)",borderRadius:8,color:"var(--text-muted)",fontSize:12,fontWeight:500,cursor:"pointer"},children:"取消"})]})]})]})}),tJ&&(0,n.jsx)("div",{style:{position:"fixed",inset:0,zIndex:1e3,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.55)",backdropFilter:"blur(4px)"},children:(0,n.jsxs)("div",{style:{background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:12,width:"500px",maxWidth:"95%",boxShadow:"0 10px 30px rgba(0,0,0,0.25)",display:"flex",flexDirection:"column",overflow:"hidden",fontFamily:"var(--font-serif)"},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 20px",borderBottom:"1px solid var(--border)",background:"var(--bg)"},children:[(0,n.jsxs)("span",{style:{fontSize:14,fontWeight:700,color:"var(--text)"},children:["\uD83C\uDFAD ink-xY 文风克隆工坊 (",eO,")"]}),(0,n.jsx)("button",{onClick:()=>{t0||tU(!1)},disabled:t0,style:{background:"none",border:"none",color:"var(--text-dim)",fontSize:14,cursor:t0?"not-allowed":"pointer"},children:"✕"})]}),(0,n.jsxs)("div",{style:{display:"flex",borderBottom:"1px solid var(--border)",background:"var(--bg-panel)"},children:[(0,n.jsx)("button",{type:"button",onClick:()=>{t0||tY("paste")},disabled:t0,style:{flex:1,padding:"10px 0",fontSize:12,fontWeight:600,border:"none",background:"paste"===tV?"var(--bg)":"transparent",color:"paste"===tV?"var(--accent)":"var(--text-muted)",borderBottom:"paste"===tV?"2px solid var(--accent)":"none",cursor:t0?"not-allowed":"pointer",transition:"all 0.15s"},children:"\uD83D\uDCDD 直接粘贴样文"}),(0,n.jsx)("button",{type:"button",onClick:()=>{t0||tY("path")},disabled:t0,style:{flex:1,padding:"10px 0",fontSize:12,fontWeight:600,border:"none",background:"path"===tV?"var(--bg)":"transparent",color:"path"===tV?"var(--accent)":"var(--text-muted)",borderBottom:"path"===tV?"2px solid var(--accent)":"none",cursor:t0?"not-allowed":"pointer",transition:"all 0.15s"},children:"\uD83D\uDCC2 指定本地文件"})]}),(0,n.jsxs)("form",{onSubmit:nD,style:{padding:"20px",display:"flex",flexDirection:"column",gap:14},children:[(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[(0,n.jsx)("label",{style:{fontSize:11,fontWeight:600,color:"var(--text-muted)"},children:"文风名称 (如:金庸、江南、科幻冷峻、言情华丽)*"}),(0,n.jsx)("input",{type:"text",value:tK,onChange:e=>tG(e.target.value),placeholder:"如: 金庸",disabled:t0,style:{width:"100%",padding:"8px 10px",borderRadius:6,background:"var(--bg)",border:"1px solid var(--border)",color:"var(--text)",fontSize:12,fontFamily:"var(--font-serif)",outline:"none"},required:!0})]}),"paste"===tV?(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[(0,n.jsx)("label",{style:{fontSize:11,fontWeight:600,color:"var(--text-muted)"},children:"粘贴样文本内容 (建议 1000 - 5000 字)*"}),(0,n.jsx)("textarea",{value:tq,onChange:e=>tZ(e.target.value),placeholder:"在此处粘贴您想让 AI 模仿写作的样文本内容(例如从金庸、江南等作家的作品中复制一两页经典段落)...",disabled:t0,style:{width:"100%",height:"120px",padding:"8px 10px",borderRadius:6,background:"var(--bg)",border:"1px solid var(--border)",color:"var(--text)",fontSize:11,fontFamily:"var(--font-serif)",outline:"none",resize:"none",lineHeight:1.5},required:!0})]}):(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[(0,n.jsx)("label",{style:{fontSize:11,fontWeight:600,color:"var(--text-muted)"},children:"输入源文本文件绝对路径 (from)*"}),(0,n.jsx)("input",{type:"text",value:tX,onChange:e=>tQ(e.target.value),placeholder:"如: D:/novel/samples/jinyong_sample.txt",disabled:t0,style:{width:"100%",padding:"8px 10px",borderRadius:6,background:"var(--bg)",border:"1px solid var(--border)",color:"var(--text)",fontSize:12,fontFamily:"var(--font-mono)",outline:"none"},required:!0})]}),(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[(0,n.jsx)("label",{style:{fontSize:11,fontWeight:600,color:"var(--text-muted)"},children:"应用的目标书籍 (克隆成果将写入该书)*"}),(0,n.jsx)("select",{value:eO||"",onChange:e=>eF(e.target.value),disabled:t0,style:{width:"100%",padding:"8px 10px",borderRadius:6,background:"var(--bg)",border:"1px solid var(--border)",color:"var(--text)",fontSize:12,fontFamily:"var(--font-serif)",outline:"none",cursor:"pointer"},required:!0,children:tB.map(e=>(0,n.jsx)("option",{value:e,children:e},e))})]}),(t0||t6.length>0||t8||t9)&&(0,n.jsxs)("div",{style:{background:"var(--bg)",border:"1px solid var(--border)",borderRadius:8,padding:"12px",fontSize:11,display:"flex",flexDirection:"column",gap:8},children:[t8&&(0,n.jsxs)("div",{style:{color:"#ef4444",fontWeight:600},children:["⚠️ 克隆失败: ",t8]}),t9&&(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[(0,n.jsx)("div",{style:{color:"#10b981",fontWeight:600},children:t9}),re&&p&&(0,n.jsx)("button",{type:"button",onClick:()=>{p(re,"style_guide.md"),tU(!1)},style:{alignSelf:"flex-start",padding:"4px 10px",background:"rgba(16,185,129,0.08)",border:"1px solid #10b981",borderRadius:4,color:"#10b981",fontSize:10,fontWeight:600,cursor:"pointer",transition:"all 0.15s"},children:"\uD83D\uDCD6 查看生成的文风指南 (style_guide.md)"})]}),t0&&(0,n.jsxs)("div",{style:{color:"var(--accent)",display:"flex",alignItems:"center",gap:6},children:[(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",className:"animate-spin",style:{animation:"spin 1s linear infinite"},children:[(0,n.jsx)("line",{x1:"12",y1:"2",x2:"12",y2:"6"}),(0,n.jsx)("line",{x1:"12",y1:"18",x2:"12",y2:"22"}),(0,n.jsx)("line",{x1:"4.93",y1:"4.93",x2:"7.76",y2:"7.76"}),(0,n.jsx)("line",{x1:"16.24",y1:"16.24",x2:"19.07",y2:"19.07"}),(0,n.jsx)("line",{x1:"2",y1:"12",x2:"6",y2:"12"}),(0,n.jsx)("line",{x1:"18",y1:"12",x2:"22",y2:"12"}),(0,n.jsx)("line",{x1:"4.93",y1:"19.07",x2:"7.76",y2:"16.24"}),(0,n.jsx)("line",{x1:"16.24",y1:"7.76",x2:"19.07",y2:"4.93"})]}),(0,n.jsx)("span",{children:"正在提取分析统计特征并由 LLM 克隆生成文风指南,请稍候..."})]}),t6.length>0&&(0,n.jsx)("div",{ref:na,style:{maxHeight:"80px",overflowY:"auto",fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-dim)",background:"#121214",padding:"6px",borderRadius:4,whiteSpace:"pre-wrap",textAlign:"left"},children:t6.map((e,t)=>(0,n.jsx)("div",{style:{marginBottom:2},children:e},t))})]}),(0,n.jsxs)("div",{style:{display:"flex",gap:8,marginTop:8},children:[(0,n.jsx)("button",{type:"submit",disabled:t0,style:{flex:1,height:38,background:"var(--accent)",border:"none",borderRadius:8,color:"white",fontSize:12,fontWeight:600,cursor:t0?"not-allowed":"pointer",opacity:t0?.7:1},children:t0?"正在克隆分析...":"确认克隆文风"}),!t0&&(0,n.jsx)("button",{type:"button",onClick:()=>tU(!1),style:{padding:"0 16px",height:38,background:"var(--bg-hover)",border:"1px solid var(--border)",borderRadius:8,color:"var(--text-muted)",fontSize:12,fontWeight:500,cursor:"pointer"},children:"取消"})]})]})]})}),rc&&(0,n.jsx)("div",{style:{position:"fixed",inset:0,zIndex:1e3,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.55)",backdropFilter:"blur(4px)"},children:(0,n.jsxs)("div",{style:{background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:12,width:"500px",maxWidth:"95%",boxShadow:"0 10px 30px rgba(0,0,0,0.25)",display:"flex",flexDirection:"column",overflow:"hidden",fontFamily:"var(--font-serif)"},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 20px",borderBottom:"1px solid var(--border)",background:"rgba(139, 92, 246, 0.08)",color:"#a78bfa"},children:[(0,n.jsxs)("h3",{style:{margin:0,fontSize:"14px",fontWeight:600,display:"flex",alignItems:"center",gap:8},children:[(0,n.jsx)("span",{children:"\uD83D\uDD04"}),(0,n.jsxs)("span",{children:["刷新同人原作设定 (",eO,")"]})]}),!rg&&(0,n.jsx)("button",{onClick:()=>rp(!1),style:{background:"none",border:"none",color:"var(--text-dim)",cursor:"pointer",fontSize:16},children:"✕"})]}),(0,n.jsxs)("form",{onSubmit:nB,style:{padding:"20px",display:"flex",flexDirection:"column",gap:14},children:[ry&&(0,n.jsxs)("div",{style:{padding:10,background:"rgba(239,68,68,0.08)",border:"1px solid rgba(239,68,68,0.2)",borderRadius:8,color:"#ef4444",fontSize:11},children:["⚠️ ",ry]}),rm&&(0,n.jsxs)("div",{style:{padding:10,background:"rgba(16,185,129,0.08)",border:"1px solid rgba(16,185,129,0.2)",borderRadius:8,color:"#10b981",fontSize:11},children:["✨ ",rm]}),(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[(0,n.jsx)("label",{style:{fontSize:11,fontWeight:600,color:"var(--text-muted)"},children:"同人原作素材绝对路径 (Source Path - 必填)"}),(0,n.jsx)("input",{type:"text",value:rx,onChange:e=>ru(e.target.value),placeholder:"请输入最新的原著素材路径,例如: D:/novel/source_v2.txt",required:!0,disabled:rg,style:{padding:"8px 12px",border:"1px solid var(--border)",borderRadius:"6px",background:"var(--bg)",color:"var(--text)",fontSize:"12px",fontFamily:"var(--font-serif)",outline:"none"}})]}),rf.length>0&&(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[(0,n.jsx)("label",{style:{fontSize:11,fontWeight:600,color:"var(--text-muted)"},children:"刷新运行日志"}),(0,n.jsx)("div",{ref:rk,style:{height:"150px",background:"#1e1e1e",color:"#d4d4d4",fontFamily:"var(--font-mono)",fontSize:"10px",padding:"8px 12px",borderRadius:"6px",overflowY:"auto",whiteSpace:"pre-wrap",lineHeight:"1.5",border:"1px solid var(--border)"},children:rf.map((e,t)=>(0,n.jsx)("div",{children:e},t))})]}),(0,n.jsxs)("div",{style:{display:"flex",gap:10,borderTop:"1px solid var(--border)",paddingTop:"14px",justifyContent:"flex-end"},children:[(0,n.jsx)("button",{type:"submit",disabled:rg,style:{padding:"0 16px",height:38,background:"#a78bfa",border:"none",borderRadius:8,color:"white",fontSize:12,fontWeight:600,cursor:rg?"not-allowed":"pointer",opacity:rg?.7:1},children:rg?"正在分析刷新...":"开始刷新"}),!rg&&(0,n.jsx)("button",{type:"button",onClick:()=>rp(!1),style:{padding:"0 16px",height:38,background:"var(--bg-hover)",border:"1px solid var(--border)",borderRadius:8,color:"var(--text-muted)",fontSize:12,fontWeight:500,cursor:"pointer"},children:"取消"})]})]})]})}),r7&&(0,n.jsx)("div",{style:{position:"fixed",inset:0,zIndex:1e3,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.55)",backdropFilter:"blur(4px)"},children:(0,n.jsxs)("div",{style:{background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:12,width:"500px",maxWidth:"90%",boxShadow:"0 10px 30px rgba(0,0,0,0.25)",display:"flex",flexDirection:"column",overflow:"hidden",fontFamily:"var(--font-serif)"},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 20px",borderBottom:"1px solid var(--border)",background:"var(--bg)"},children:[(0,n.jsxs)("span",{style:{fontSize:14,fontWeight:700,color:"var(--text)",display:"flex",alignItems:"center",gap:6},children:[(0,n.jsx)("span",{children:"\uD83D\uDDDC️"})," 大纲摘要压缩归档"]}),(0,n.jsx)("button",{onClick:()=>{r3||ne(!1)},disabled:r3,style:{background:"none",border:"none",color:"var(--text-dim)",fontSize:14,cursor:r3?"not-allowed":"pointer"},children:"✕"})]}),(0,n.jsxs)("div",{style:{padding:"20px",display:"flex",flexDirection:"column",gap:16},children:[(0,n.jsx)("div",{style:{fontSize:12,color:"var(--text-muted)",lineHeight:1.6},children:"运行大纲摘要压缩会将已完结分卷的逐章梗概合并提炼,输出到分卷摘要中,并对已完结章节的明细梗概进行历史归档,以大幅缩减大语言模型上下文 Token 占用,提升续写连贯性,防止远期情节记忆退化。"}),(r3||nt.length>0)&&(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[(0,n.jsxs)("div",{style:{fontSize:11,fontWeight:600,color:"var(--text-muted)",display:"flex",alignItems:"center",gap:4},children:[r3&&(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",className:"animate-spin",style:{animation:"spin 1s linear infinite"},children:[(0,n.jsx)("line",{x1:"12",y1:"2",x2:"12",y2:"6"}),(0,n.jsx)("line",{x1:"12",y1:"18",x2:"12",y2:"22"}),(0,n.jsx)("line",{x1:"4.93",y1:"4.93",x2:"7.76",y2:"7.76"}),(0,n.jsx)("line",{x1:"16.24",y1:"16.24",x2:"19.07",y2:"19.07"}),(0,n.jsx)("line",{x1:"2",y1:"12",x2:"6",y2:"12"}),(0,n.jsx)("line",{x1:"18",y1:"12",x2:"22",y2:"12"}),(0,n.jsx)("line",{x1:"4.93",y1:"19.07",x2:"7.76",y2:"16.24"}),(0,n.jsx)("line",{x1:"16.24",y1:"7.76",x2:"19.07",y2:"4.93"})]}),(0,n.jsx)("span",{children:"执行控制台日志:"})]}),(0,n.jsx)("div",{ref:nd,style:{height:"150px",overflowY:"auto",fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-dim)",background:"#121214",padding:"8px 12px",borderRadius:6,whiteSpace:"pre-wrap",textAlign:"left",border:"1px solid var(--border)",lineHeight:1.4},children:0===nt.length?(0,n.jsx)("div",{style:{color:"#6b7280"},children:"正在初始化并启动命令行脚本..."}):nt.map((e,t)=>(0,n.jsx)("div",{style:{marginBottom:2},children:e},t))})]}),ni&&(0,n.jsxs)("div",{style:{background:"rgba(16, 185, 129, 0.04)",border:"1px solid rgba(16, 185, 129, 0.25)",borderRadius:8,padding:"12px",display:"flex",flexDirection:"column",gap:6},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,fontWeight:600,color:"#10b981",fontSize:"12px"},children:[(0,n.jsx)("span",{children:"✨"})," 压缩归档完成"]}),(0,n.jsxs)("div",{style:{fontSize:"11px",color:"var(--text-muted)",lineHeight:1.6},children:[(0,n.jsxs)("div",{style:{marginBottom:4},children:["• 成功压缩归档卷数:",(0,n.jsxs)("strong",{children:[ni.archivedVolumes," 卷"]})]}),(0,n.jsxs)("div",{children:["• 当前内存保留近期章节:",(0,n.jsxs)("strong",{children:[ni.retainedChapters," 章"]})]})]}),(0,n.jsx)("div",{style:{fontSize:"10px",color:"var(--text-dim)",marginTop:4,borderTop:"1px dashed rgba(16, 185, 129, 0.15)",paddingTop:4},children:"已将对应卷的章节梗概安全移动至归档目录,活动大纲摘要已刷新。"})]}),nn&&(0,n.jsxs)("div",{style:{background:"rgba(239, 68, 68, 0.04)",border:"1px solid rgba(239, 68, 68, 0.25)",borderRadius:8,padding:"12px",display:"flex",flexDirection:"column",gap:4},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,fontWeight:600,color:"#ef4444",fontSize:"12px"},children:[(0,n.jsx)("span",{children:"⚠️"})," 执行出错"]}),(0,n.jsx)("div",{style:{fontSize:"11px",color:"var(--text-muted)",fontFamily:"var(--font-mono)",wordBreak:"break-all"},children:nn})]}),(0,n.jsx)("div",{style:{display:"flex",gap:8,marginTop:8},children:r3?(0,n.jsx)("button",{disabled:!0,style:{flex:1,height:38,background:"var(--accent)",opacity:.7,border:"none",borderRadius:8,color:"white",fontSize:12,fontWeight:600,cursor:"not-allowed"},children:"正在压缩..."}):(0,n.jsx)("button",{onClick:()=>ne(!1),style:{flex:1,height:38,background:"var(--accent)",border:"none",borderRadius:8,color:"white",fontSize:12,fontWeight:600,cursor:"pointer"},children:nn?"关闭":"确认并关闭"})})]})]})}),rw&&(0,n.jsx)("div",{style:{position:"fixed",inset:0,zIndex:1e3,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.55)",backdropFilter:"blur(4px)"},children:(0,n.jsxs)("div",{style:{background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:12,width:"650px",maxWidth:"95%",maxHeight:"85vh",boxShadow:"0 10px 30px rgba(0,0,0,0.25)",display:"flex",flexDirection:"column",overflow:"hidden",fontFamily:"var(--font-serif)"},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",padding:"16px 20px",borderBottom:"1px solid var(--border)",background:"rgba(16, 185, 129, 0.08)",color:"#10b981",justifyContent:"space-between"},children:[(0,n.jsxs)("h3",{style:{margin:0,fontSize:"14px",fontWeight:600,display:"flex",alignItems:"center",gap:8},children:[(0,n.jsx)("span",{children:"\uD83D\uDCE1"}),(0,n.jsx)("span",{children:"智能市场分析雷达 (Radar Market Scanner)"})]}),!rC&&(0,n.jsx)("button",{onClick:()=>rS(!1),style:{background:"none",border:"none",color:"var(--text-dim)",cursor:"pointer",fontSize:16},children:"✕"})]}),(0,n.jsxs)("div",{style:{padding:"20px",overflowY:"auto",display:"flex",flexDirection:"column",gap:14,flex:1},children:[rR&&(0,n.jsxs)("div",{style:{padding:10,background:"rgba(239,68,68,0.08)",border:"1px solid rgba(239,68,68,0.2)",borderRadius:8,color:"#ef4444",fontSize:11},children:["⚠️ 扫描失败: ",rR]}),rC&&(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:12,color:"var(--text-muted)"},children:[(0,n.jsx)("div",{style:{width:"12px",height:"12px",border:"2px solid var(--border)",borderTopColor:"#10b981",borderRadius:"50%",animation:"spin 1s linear infinite"}}),(0,n.jsx)("span",{children:"雷达天线展开,正在扫描各大网文平台潜力题材与受众风向..."})]}),(0,n.jsx)("div",{ref:rM,style:{height:"220px",background:"#121214",color:"#d4d4d4",fontFamily:"var(--font-mono)",fontSize:"10px",padding:"10px 12px",borderRadius:"6px",overflowY:"auto",whiteSpace:"pre-wrap",lineHeight:"1.5",border:"1px solid var(--border)",textAlign:"left"},children:rz.map((e,t)=>(0,n.jsx)("div",{children:e},t))})]}),!rC&&rW&&(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[(0,n.jsxs)("div",{style:{background:"var(--bg)",border:"1px solid var(--border)",borderRadius:"8px",padding:"14px 16px",fontSize:"12px",lineHeight:"1.6"},children:[(0,n.jsxs)("div",{style:{fontWeight:600,color:"#10b981",marginBottom:8,display:"flex",alignItems:"center",gap:6},children:[(0,n.jsx)("span",{children:"\uD83D\uDCCA"})," 市场概况总结 (Global Trend Summary)"]}),(0,n.jsx)("div",{style:{color:"var(--text-muted)",fontSize:"11px"},children:(0,n.jsx)(H.oz,{remarkPlugins:[_.A],children:rW.marketSummary})})]}),(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[(0,n.jsxs)("div",{style:{fontWeight:600,fontSize:"12px",color:"var(--text)",display:"flex",alignItems:"center",gap:6},children:[(0,n.jsx)("span",{children:"\uD83C\uDFAF"})," AI 潜力选题方向推荐 (AIGC Concept Prompts)"]}),(0,n.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:rW.recommendations?.map((e,t)=>{let r=Math.round(100*e.confidence),o=r>=75,i=o?"#10b981":"#f59e0b";return(0,n.jsxs)("div",{style:{background:"var(--bg)",border:"1px solid var(--border)",borderRadius:"8px",padding:"14px",transition:"all 0.2s",display:"flex",flexDirection:"column",gap:8},onMouseEnter:e=>{e.currentTarget.style.borderColor="#10b981",e.currentTarget.style.boxShadow="0 4px 12px rgba(16, 185, 129, 0.05)"},onMouseLeave:e=>{e.currentTarget.style.borderColor="var(--border)",e.currentTarget.style.boxShadow="none"},children:[(0,n.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[(0,n.jsxs)("span",{style:{fontSize:"12px",fontWeight:700,color:"var(--text)"},children:[e.platform," / ",e.genre]}),(0,n.jsxs)("span",{style:{fontSize:"10px",fontWeight:600,padding:"2px 8px",borderRadius:"10px",color:i,background:o?"rgba(16, 185, 129, 0.08)":"rgba(245, 158, 11, 0.08)",border:`1px solid ${i}33`},children:["潜力指数: ",r,"%"]})]}),(0,n.jsxs)("div",{style:{fontSize:"11px",color:"var(--text-muted)"},children:[(0,n.jsx)("strong",{style:{color:"var(--text)"},children:"核心概念:"})," ",e.concept]}),(0,n.jsxs)("div",{style:{fontSize:"11px",color:"var(--text-muted)"},children:[(0,n.jsx)("strong",{style:{color:"var(--text)"},children:"推荐逻辑:"})," ",e.reasoning]}),e.benchmarkTitles?.length>0&&(0,n.jsxs)("div",{style:{fontSize:"10px",color:"var(--text-dim)",marginTop:4,display:"flex",flexWrap:"wrap",gap:4},children:[(0,n.jsx)("span",{children:"\uD83C\uDFF7️ 对标书目:"}),e.benchmarkTitles.map((e,t)=>(0,n.jsxs)("span",{style:{background:"var(--bg-hover)",padding:"1px 6px",borderRadius:4},children:["《",e,"》"]},t))]})]},t)})})]})]}),!rC&&!rW&&(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",padding:"30px 10px",gap:14,textAlign:"center"},children:[(0,n.jsx)("span",{style:{fontSize:"40px"},children:"\uD83D\uDCE1"}),(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[(0,n.jsx)("div",{style:{fontSize:"13px",fontWeight:600,color:"var(--text)"},children:"扫描当前网文市场热点"}),(0,n.jsx)("div",{style:{fontSize:"11px",color:"var(--text-muted)",maxWidth:360,lineHeight:1.6},children:"AI 市场雷达将深度挖掘当前各大发布平台的热门标签、高互动率流派以及对标爆款,为您提供高置信度的写作题材概念指南。"})]}),(0,n.jsxs)("button",{onClick:nP,style:{padding:"8px 24px",background:"#10b981",border:"none",borderRadius:"8px",color:"white",fontSize:12,fontWeight:600,cursor:"pointer",display:"flex",alignItems:"center",gap:6,transition:"opacity 0.15s"},children:[(0,n.jsx)("span",{children:"\uD83D\uDCE1"})," 启动雷达行情扫描"]})]})]}),(0,n.jsx)("div",{style:{display:"flex",gap:8,padding:"12px 20px",background:"var(--bg-panel)",borderTop:"1px solid var(--border)",justifyContent:"flex-end"},children:!rC&&(0,n.jsx)("button",{onClick:()=>rS(!1),style:{padding:"6px 16px",background:"var(--bg-hover)",border:"1px solid var(--border)",borderRadius:8,color:"var(--text-muted)",fontSize:12,fontWeight:500,cursor:"pointer"},children:"关闭"})})]})}),rD&&(0,n.jsx)("div",{style:{position:"fixed",inset:0,zIndex:1e3,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.55)",backdropFilter:"blur(4px)"},children:(0,n.jsxs)("div",{style:{background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:12,width:"520px",maxWidth:"95%",maxHeight:"85vh",boxShadow:"0 10px 30px rgba(0,0,0,0.25)",display:"flex",flexDirection:"column",overflow:"hidden",fontFamily:"var(--font-serif)"},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 20px",borderBottom:"1px solid var(--border)",background:"rgba(139, 92, 246, 0.08)",color:"#a78bfa"},children:[(0,n.jsxs)("h3",{style:{margin:0,fontSize:"14px",fontWeight:600,display:"flex",alignItems:"center",gap:8},children:[(0,n.jsx)("span",{children:"\uD83D\uDE80"}),(0,n.jsx)("span",{children:"全自动短篇小说工坊 (Auto Short Fiction Pipeline)"})]}),!rB&&(0,n.jsx)("button",{onClick:()=>r$(!1),style:{background:"none",border:"none",color:"var(--text-dim)",cursor:"pointer",fontSize:16},children:"✕"})]}),(0,n.jsxs)("div",{style:{padding:"20px",display:"flex",flexDirection:"column",gap:14,overflowY:"auto",flex:1},children:[rN&&(0,n.jsxs)("div",{style:{padding:10,background:"rgba(239,68,68,0.08)",border:"1px solid rgba(239,68,68,0.2)",borderRadius:8,color:"#ef4444",fontSize:11},children:["⚠️ 运行错误: ",rN]}),rH&&(0,n.jsxs)("div",{style:{background:"rgba(16, 185, 129, 0.04)",border:"1px solid rgba(16, 185, 129, 0.25)",borderRadius:8,padding:"14px",display:"flex",flexDirection:"column",gap:8},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,fontWeight:600,color:"#10b981",fontSize:"13px"},children:[(0,n.jsx)("span",{children:"✨"})," 阶段任务完成!"]}),(0,n.jsx)("div",{style:{fontSize:"11px",color:"var(--text-muted)",lineHeight:1.6,whiteSpace:"pre-wrap"},children:rH})]}),(0,n.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"10px 0",borderBottom:"1px solid var(--border)",marginBottom:10},children:[(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",flex:1},children:[(0,n.jsx)("div",{style:{width:24,height:24,borderRadius:"50%",background:rX?"#10b981":rB&&"idle"===r0?"var(--accent)":"var(--bg-hover)",color:rX?"white":"var(--text-muted)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:11,fontWeight:"bold"},children:rX?"✓":"1"}),(0,n.jsx)("span",{style:{fontSize:10,marginTop:4,color:rB&&"idle"===r0?"var(--accent)":"var(--text-muted)"},children:"大纲规划"})]}),(0,n.jsx)("div",{style:{flex:1,height:2,background:rX?"#10b981":"var(--border)",margin:"0 -10px"}}),(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",flex:1},children:[(0,n.jsx)("div",{style:{width:24,height:24,borderRadius:"50%",background:"package"===r0||"completed"===r0?"#10b981":rB&&"draft"===r0?"var(--accent)":"var(--bg-hover)",color:"package"===r0||"completed"===r0?"white":"var(--text-muted)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:11,fontWeight:"bold"},children:"package"===r0||"completed"===r0?"✓":"2"}),(0,n.jsx)("span",{style:{fontSize:10,marginTop:4,color:rB&&"draft"===r0?"var(--accent)":"var(--text-muted)"},children:"正文写作"})]}),(0,n.jsx)("div",{style:{flex:1,height:2,background:"package"===r0||"completed"===r0?"#10b981":"var(--border)",margin:"0 -10px"}}),(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",flex:1},children:[(0,n.jsx)("div",{style:{width:24,height:24,borderRadius:"50%",background:"completed"===r0?"#10b981":rB&&"package"===r0?"var(--accent)":"var(--bg-hover)",color:"completed"===r0?"white":"var(--text-muted)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:11,fontWeight:"bold"},children:"completed"===r0?"✓":"3"}),(0,n.jsx)("span",{style:{fontSize:10,marginTop:4,color:rB&&"package"===r0?"var(--accent)":"var(--text-muted)"},children:"书封包装"})]})]}),!rB&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[(0,n.jsx)("label",{style:{fontSize:11,fontWeight:600,color:"var(--text-muted)"},children:"故事创意与走向方向 (Story Direction - 必填)*"}),(0,n.jsx)("input",{type:"text",value:rJ,onChange:e=>rU(e.target.value),placeholder:"例如: 女频短篇 婚姻背叛 商业争夺 证据反杀 爽文",disabled:!!rX,required:!0,style:{padding:"8px 12px",border:"1px solid var(--border)",borderRadius:"6px",background:"var(--bg)",color:"var(--text)",fontSize:"12px",fontFamily:"var(--font-serif)",outline:"none",opacity:rX?.7:1}})]}),(0,n.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},children:[(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[(0,n.jsx)("label",{style:{fontSize:11,fontWeight:600,color:"var(--text-muted)"},children:"章节数量 (Chapter Count)*"}),(0,n.jsx)("select",{value:rV,onChange:e=>rY(parseInt(e.target.value,10)),disabled:!!rX,style:{padding:"8px 10px",borderRadius:6,background:"var(--bg)",border:"1px solid var(--border)",color:"var(--text)",fontSize:12,fontFamily:"var(--font-serif)",outline:"none",cursor:rX?"not-allowed":"pointer",opacity:rX?.7:1},children:[12,13,14,15,16,17,18].map(e=>(0,n.jsxs)("option",{value:e,children:[e," 章"]},e))})]}),(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[(0,n.jsx)("label",{style:{fontSize:11,fontWeight:600,color:"var(--text-muted)"},children:"单章目标字数 (Words Target)*"}),(0,n.jsx)("select",{value:rK,onChange:e=>rG(parseInt(e.target.value,10)),disabled:!!rX,style:{padding:"8px 10px",borderRadius:6,background:"var(--bg)",border:"1px solid var(--border)",color:"var(--text)",fontSize:12,fontFamily:"var(--font-serif)",outline:"none",cursor:rX?"not-allowed":"pointer",opacity:rX?.7:1},children:[900,1e3,1100,1200].map(e=>(0,n.jsxs)("option",{value:e,children:[e," 字/章"]},e))})]})]}),(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"4px 0"},children:[(0,n.jsx)("input",{type:"checkbox",id:"shortCoverCheckbox",checked:rq,onChange:e=>rZ(e.target.checked),disabled:!!rX,style:{cursor:rX?"not-allowed":"pointer",accentColor:"#a78bfa"}}),(0,n.jsx)("label",{htmlFor:"shortCoverCheckbox",style:{fontSize:11,color:"var(--text-muted)",cursor:rX?"not-allowed":"pointer",userSelect:"none",opacity:rX?.7:1},children:"\uD83C\uDF0C 全自动生成配图故事封面 (AI Cover Generation)"})]})]}),rB&&(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:12,color:"var(--text-muted)"},children:[(0,n.jsx)("div",{style:{width:"12px",height:"12px",border:"2px solid var(--border)",borderTopColor:"#a78bfa",borderRadius:"50%",animation:"spin 1s linear infinite"}}),(0,n.jsx)("span",{children:"idle"===r0||"outline"===r0?"正在运行 步骤一:AI 规划大纲与大纲精修评审...":"draft"===r0?"正在运行 步骤二:AI 协同批量起草各章节正文...":"正在运行 步骤三:AI 生成故事简介、卖点与封面提示词,并调用模型生成书封..."})]}),(0,n.jsx)("div",{ref:r2,style:{height:"220px",background:"#121214",color:"#d4d4d4",fontFamily:"var(--font-mono)",fontSize:"10px",padding:"10px 12px",borderRadius:"6px",overflowY:"auto",whiteSpace:"pre-wrap",lineHeight:"1.5",border:"1px solid var(--border)",textAlign:"left"},children:rO.map((e,t)=>(0,n.jsx)("div",{children:e},t))})]}),(0,n.jsxs)("div",{style:{display:"flex",gap:10,borderTop:"1px solid var(--border)",paddingTop:"14px",justifyContent:"flex-end",alignItems:"center"},children:[rX&&!rB&&(0,n.jsx)("button",{type:"button",onClick:()=>{rQ(null),r1("idle"),r_(null),rP(null),rF([])},style:{padding:"0 12px",height:38,background:"rgba(239, 68, 68, 0.08)",border:"1px solid rgba(239, 68, 68, 0.2)",borderRadius:8,color:"#ef4444",fontSize:11,fontWeight:500,cursor:"pointer",marginRight:"auto"},children:"\uD83D\uDD04 重置新故事"}),rB?(0,n.jsx)("button",{type:"button",disabled:!0,style:{padding:"0 20px",height:38,background:"var(--border)",border:"none",borderRadius:8,color:"var(--text-muted)",fontSize:12,fontWeight:600,cursor:"not-allowed"},children:"正在生成中..."}):(0,n.jsxs)(n.Fragment,{children:[!rX&&(0,n.jsx)("button",{type:"button",onClick:()=>nH("outline"),disabled:!rJ.trim(),style:{padding:"0 20px",height:38,background:"#a78bfa",border:"none",borderRadius:8,color:"white",fontSize:12,fontWeight:600,cursor:rJ.trim()?"pointer":"not-allowed",opacity:rJ.trim()?1:.6},children:"\uD83D\uDE80 步骤一:生成大纲"}),rX&&"draft"===r0&&(0,n.jsx)("button",{type:"button",onClick:()=>nH("draft"),style:{padding:"0 20px",height:38,background:"#8b5cf6",border:"none",borderRadius:8,color:"white",fontSize:12,fontWeight:600,cursor:"pointer"},children:"✍️ 步骤二:批量起草正文"}),rX&&"package"===r0&&(0,n.jsx)("button",{type:"button",onClick:()=>nH("package"),style:{padding:"0 20px",height:38,background:"#ec4899",border:"none",borderRadius:8,color:"white",fontSize:12,fontWeight:600,cursor:"pointer"},children:"\uD83C\uDFA8 步骤三:生成封面与包装"})]}),!rB&&(0,n.jsx)("button",{type:"button",onClick:()=>{r$(!1),r_(null),rP(null)},style:{padding:"0 16px",height:38,background:"var(--bg-hover)",border:"1px solid var(--border)",borderRadius:8,color:"var(--text-muted)",fontSize:12,fontWeight:500,cursor:"pointer"},children:"completed"===r0?"完成":"关闭"})]})]})]})})]})}function X({node:e,selectedSessionId:t,onSelectSession:r,onRenamed:i,onSessionDeleted:l,depth:s}){let[a,d]=(0,o.useState)(!1),c=e.children.length>0;return(0,n.jsxs)("div",{children:[(0,n.jsxs)("div",{style:{position:"relative"},children:[s>0&&(0,n.jsx)("div",{style:{position:"absolute",left:12*s+6,top:0,bottom:0,width:1,background:"var(--border)",pointerEvents:"none"}}),(0,n.jsx)(Q,{session:e.session,isSelected:e.session.id===t,onClick:()=>r(e.session),onRenamed:i,onDeleted:e=>l?.(e),depth:s,hasChildren:c,collapsed:a,onToggleCollapse:()=>d(e=>!e)})]}),c&&!a&&(0,n.jsx)("div",{children:e.children.map(e=>(0,n.jsx)(X,{node:e,selectedSessionId:t,onSelectSession:r,onRenamed:i,onSessionDeleted:l,depth:s+1},e.session.id))})]})}function Q({session:e,isSelected:t,onClick:r,onRenamed:i,onDeleted:l,depth:s=0,hasChildren:a=!1,collapsed:d=!1,onToggleCollapse:c}){let p,x,u,g,h,[f,b]=(0,o.useState)(!1),[y,v]=(0,o.useState)(!1),[m,j]=(0,o.useState)(""),[k,w]=(0,o.useState)(!1),[S,C]=(0,o.useState)(!1),[T,z]=(0,o.useState)(e.locked),I=(0,o.useRef)(null);(0,o.useEffect)(()=>{z(e.locked)},[e.locked]);let R=(0,o.useCallback)(async t=>{t.stopPropagation();let r=!T;z(r),e.locked=r;try{await fetch(`/api/sessions/${encodeURIComponent(e.id)}/lock`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({locked:r})}),i?.()}catch{z(!r),e.locked=!r}},[T,e,i]),L=e.name||e.firstMessage.slice(0,50)||e.id.slice(0,12),W=(0,o.useCallback)(t=>{t.stopPropagation(),j(e.name??""),v(!0),setTimeout(()=>I.current?.select(),0)},[e.name]),E=(0,o.useCallback)(async()=>{let t=m.trim();if(v(!1),t!==(e.name??""))try{await fetch(`/api/sessions/${encodeURIComponent(e.id)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:t})}),i?.()}catch{}},[m,e.id,e.name,i]),M=(0,o.useCallback)(e=>{e.stopPropagation(),w(!0)},[]),D=(0,o.useCallback)(async t=>{t.stopPropagation(),w(!1),C(!0);try{await fetch(`/api/sessions/${encodeURIComponent(e.id)}`,{method:"DELETE"}),l?.(e.id)}catch{C(!1)}},[e.id,l]),$=(0,o.useCallback)(e=>{e.stopPropagation(),w(!1)},[]);return(0,n.jsx)("div",{onClick:k||y?void 0:r,onMouseEnter:()=>b(!0),onMouseLeave:()=>{b(!1)},style:{height:54,display:"flex",alignItems:"center",paddingLeft:s>0?12*s+14:14,paddingRight:8,cursor:k||y?"default":"pointer",background:k?"rgba(239,68,68,0.06)":t?"var(--bg-selected)":f?"var(--bg-hover)":"transparent",borderLeft:k?"2px solid #ef4444":t?"2px solid var(--accent)":"2px solid transparent",transition:"background 0.1s",opacity:S?.5:1,gap:6,overflow:"hidden"},children:k?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{style:{flex:1,minWidth:0,fontSize:12,color:"var(--text)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:["Delete ",(0,n.jsxs)("span",{style:{fontWeight:600},children:["“",L.slice(0,22),L.length>22?"…":"","”"]}),"?"]}),(0,n.jsxs)("div",{style:{display:"flex",gap:5,flexShrink:0},children:[(0,n.jsxs)("button",{onClick:D,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:4,height:30,padding:"0 11px",background:"#ef4444",border:"none",borderRadius:6,color:"#fff",cursor:"pointer",fontSize:12,fontWeight:600,whiteSpace:"nowrap"},children:[(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("polyline",{points:"3 6 5 6 21 6"}),(0,n.jsx)("path",{d:"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"}),(0,n.jsx)("path",{d:"M10 11v6M14 11v6"}),(0,n.jsx)("path",{d:"M9 6V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2"})]}),"Delete"]}),(0,n.jsx)("button",{onClick:$,style:{display:"flex",alignItems:"center",justifyContent:"center",height:30,padding:"0 11px",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:6,color:"var(--text-muted)",cursor:"pointer",fontSize:12,fontWeight:500,whiteSpace:"nowrap"},children:"Cancel"})]})]}):y?(0,n.jsx)("input",{ref:I,value:m,onChange:e=>j(e.target.value),onBlur:E,onKeyDown:e=>{"Enter"===e.key&&E(),"Escape"===e.key&&v(!1)},autoFocus:!0,style:{flex:1,fontSize:12,padding:"5px 8px",border:"1px solid var(--accent)",borderRadius:5,outline:"none",background:"var(--bg)",color:"var(--text)",height:30}}):(0,n.jsxs)(n.Fragment,{children:[s>0&&(0,n.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-dim)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[(0,n.jsx)("line",{x1:"6",y1:"3",x2:"6",y2:"15"}),(0,n.jsx)("circle",{cx:"18",cy:"6",r:"3"}),(0,n.jsx)("circle",{cx:"6",cy:"18",r:"3"}),(0,n.jsx)("path",{d:"M18 9a9 9 0 0 1-9 9"})]}),(0,n.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,n.jsxs)("div",{style:{fontSize:12,fontWeight:t?500:400,lineHeight:1.4,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:"var(--text)",display:"flex",alignItems:"center",gap:4},title:L,children:[T&&(0,n.jsx)("span",{title:"本会话已被锁定,无法删除。请先解锁!",style:{display:"inline-flex",fontSize:10,flexShrink:0},children:"\uD83D\uDD12"}),(0,n.jsx)("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:L})]}),(0,n.jsxs)("div",{style:{marginTop:2,display:"flex",gap:8,color:"var(--text-dim)",fontSize:11},children:[(0,n.jsx)("span",{title:e.modified,children:(p=new Date(e.modified),u=Math.floor((x=new Date().getTime()-p.getTime())/6e4),g=Math.floor(x/36e5),h=Math.floor(x/864e5),u<1?"just now":u<60?`${u}m ago`:g<24?`${g}h ago`:h<7?`${h}d ago`:p.toLocaleDateString())}),(0,n.jsxs)("span",{children:[e.messageCount," msgs"]})]})]}),a&&(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),c?.()},title:d?"Expand forks":"Collapse forks",style:{display:"flex",alignItems:"center",justifyContent:"center",width:20,height:20,padding:0,flexShrink:0,background:"none",border:"none",color:"var(--text-dim)",cursor:"pointer",transform:d?"rotate(-90deg)":"none",transition:"transform 0.15s"},children:(0,n.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("polyline",{points:"2 3.5 5 6.5 8 3.5"})})}),f&&(0,n.jsxs)("div",{style:{display:"flex",gap:4,flexShrink:0},children:[(0,n.jsx)("button",{onClick:R,title:T?"解锁会话 (Unlock session)":"锁定会话 (Lock session)",style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,padding:0,background:"var(--bg-hover)",border:"1px solid var(--border)",borderRadius:7,color:T?"var(--accent)":"var(--text-muted)",cursor:"pointer",flexShrink:0,transition:"background 0.12s, color 0.12s, border-color 0.12s",borderColor:T?"rgba(37,99,235,0.25)":"var(--border)"},onMouseEnter:e=>{e.currentTarget.style.background="var(--bg-selected)",e.currentTarget.style.color="var(--accent)",e.currentTarget.style.borderColor="rgba(37,99,235,0.35)"},onMouseLeave:e=>{e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color=T?"var(--accent)":"var(--text-muted)",e.currentTarget.style.borderColor=T?"rgba(37,99,235,0.25)":"var(--border)"},children:T?(0,n.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),(0,n.jsx)("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}):(0,n.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),(0,n.jsx)("path",{d:"M7 11V7a5 5 0 0 1 9.9-1"})]})}),(0,n.jsx)("button",{onClick:W,title:"Rename",style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,padding:0,background:"var(--bg-hover)",border:"1px solid var(--border)",borderRadius:7,color:"var(--text-muted)",cursor:"pointer",flexShrink:0,transition:"background 0.12s, color 0.12s, border-color 0.12s"},onMouseEnter:e=>{e.currentTarget.style.background="var(--bg-selected)",e.currentTarget.style.color="var(--accent)",e.currentTarget.style.borderColor="rgba(37,99,235,0.35)"},onMouseLeave:e=>{e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color="var(--text-muted)",e.currentTarget.style.borderColor="var(--border)"},children:(0,n.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("path",{d:"M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"})})}),(0,n.jsx)("button",{onClick:T?void 0:M,disabled:T,title:T?"本会话已被锁定,无法删除。请先解锁!":"Delete",style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,padding:0,background:"var(--bg-hover)",border:"1px solid var(--border)",borderRadius:7,color:T?"var(--text-dim)":"var(--text-muted)",cursor:T?"not-allowed":"pointer",flexShrink:0,opacity:T?.35:1,transition:"background 0.12s, color 0.12s, border-color 0.12s"},onMouseEnter:e=>{T||(e.currentTarget.style.background="rgba(239,68,68,0.08)",e.currentTarget.style.color="#ef4444",e.currentTarget.style.borderColor="rgba(239,68,68,0.35)")},onMouseLeave:e=>{T||(e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color="var(--text-muted)",e.currentTarget.style.borderColor="var(--border)")},children:(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("polyline",{points:"3 6 5 6 21 6"}),(0,n.jsx)("path",{d:"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"}),(0,n.jsx)("path",{d:"M10 11v6M14 11v6"}),(0,n.jsx)("path",{d:"M9 6V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2"})]})})]})]})})}let ee=null,et=null;function er(e,t,r){let n,o,i=t;try{let e=null;if(r){let t=localStorage.getItem("mimo_history_voice_settings");t&&(e=JSON.parse(t)[r])}if(!e){let t=localStorage.getItem("mimo_voice_settings");t&&(e=JSON.parse(t))}if(e){let r=(e.modelId||t||"").toLowerCase();i=e.modelId||t,r.includes("voicedesign")||r.includes("design")?(n=void 0,o=e.voiceDesignPrompt||""):r.includes("voiceclone")||r.includes("clone")?n=e.voiceCloneAudioData?e.voiceCloneAudioData:void 0:r.includes("tts")&&(n=e.presetVoice||"mimo_default")}}catch(e){console.error("Failed to read voice settings in getVoiceParams:",e)}return{text:e,voice:n,modelId:i,voiceDesignPrompt:o}}async function en(e){if(!window.caches)return null;try{let t=JSON.stringify(e),r=`https://mimo.local/audio?key=${encodeURIComponent(t)}`,n=await caches.open("mimo-tts-cache"),o=await n.match(r);if(o)return await o.text()}catch(e){console.error("Error reading from Cache Storage:",e)}return null}async function eo(e,t){if(window.caches)try{let r=JSON.stringify(e),n=`https://mimo.local/audio?key=${encodeURIComponent(r)}`,o=await caches.open("mimo-tts-cache");await o.put(n,new Response(t))}catch(e){console.error("Error writing to Cache Storage:",e)}}function ei(e,t){if(!t)return!1;let r=t.toLowerCase(),n=e?.toLowerCase()||"";return r.includes("tts")||r.includes("voiceclone")||r.includes("voicedesign")||r.includes("audio-gen")||n.includes("mimo-tts")}function el(e,t){if(!t)return!1;let r=t.toLowerCase();return r.includes("voiceclone")||r.includes("clone")}function es(e,t){if(!t)return!1;let r=t.toLowerCase();return r.includes("voicedesign")||r.includes("design")}function ea(e){if(!e)return null;let t=new Date(e),r=new Date,n=t.getFullYear()===r.getFullYear()&&t.getMonth()===r.getMonth()&&t.getDate()===r.getDate(),o=t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});if(n)return o;let i=t.toLocaleDateString([],{month:"short",day:"numeric",year:t.getFullYear()!==r.getFullYear()?"numeric":void 0});return`${i} ${o}`}function ed(e){if(navigator.clipboard?.writeText)return navigator.clipboard.writeText(e);try{let t=document.createElement("textarea");return t.value=e,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t),Promise.resolve()}catch{return Promise.reject()}}function ec(e){if(!e)return{cleanText:"",attachments:[]};let t="\x3c!-- PI_FILE_ATTACHMENTS_START --\x3e",r="\x3c!-- PI_FILE_ATTACHMENTS_END --\x3e",n=e.indexOf(t),o=e.indexOf(r);if(-1===n||-1===o||n>=o)return{cleanText:e,attachments:[]};let i=e.substring(0,n),l=e.substring(o+r.length),s=e.substring(n+t.length,o).trim(),a=(i.trim()+"\n"+l.trim()).trim(),d=[];for(let e of s.split("\n")){let t=e.trim();if(!t||t.startsWith("\uD83D\uDCC4")||t.includes("已上传文件"))continue;let r=t.match(/^[-*]\s+(.+?)(?:\s+\((.+?)\))?$/)||t.match(/^(.+?)(?:\s+\((.+?)\))?$/);if(r){let e=r[1].trim(),t=r[2]?.trim(),n=e.split(/[/\\]/),o=n[n.length-1]||e;d.push({name:o,path:e,size:t})}}return{cleanText:a,attachments:d}}function ep({file:e,cwd:t}){let r=/\.(wav|mp3|ogg|m4a|webm|aac)$/i.test(e.name),i=/\.(png|jpe?g|gif|webp|svg|bmp)$/i.test(e.name),l=/\.(js|jsx|ts|tsx|json|html|css|py|go|rs|cpp|c|h|sh|bat|md)$/i.test(e.name),[s,a]=(0,o.useState)(!1),d=(0,o.useRef)(null);(0,o.useEffect)(()=>()=>{d.current&&(d.current.pause(),d.current=null)},[]);let c="var(--text-dim)",p="rgba(255, 255, 255, 0.03)",x="1px solid var(--border)",u="rgba(255, 255, 255, 0.06)";return r?(c="var(--accent)",p="rgba(59, 130, 246, 0.05)",x="1px solid rgba(59, 130, 246, 0.15)",u="rgba(59, 130, 246, 0.09)"):i?(c="#e11d48",p="rgba(225, 29, 72, 0.05)",x="1px solid rgba(225, 29, 72, 0.15)",u="rgba(225, 29, 72, 0.09)"):l&&(c="#10b981",p="rgba(16, 185, 129, 0.05)",x="1px solid rgba(16, 185, 129, 0.15)",u="rgba(16, 185, 129, 0.09)"),(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 12px",background:p,border:x,borderRadius:8,fontSize:12.5,color:"var(--text)",maxWidth:320,boxShadow:"0 1px 2px rgba(0, 0, 0, 0.05)",transition:"transform 0.15s ease, background 0.15s ease, border-color 0.15s ease",cursor:r?"pointer":"default",userSelect:"none"},onClick:r?n=>{if(r)if(n.stopPropagation(),s)d.current?.pause(),a(!1);else{if(!d.current){let r=e.path;if(t&&!/^[a-zA-Z]:/i.test(r)&&!r.startsWith("/")){let n=t.replace(/[\\/]+$/,"");r=`${n}/${e.path}`}let n=r.replace(/\\/g,"/").split("/").filter(Boolean).map(encodeURIComponent).join("/"),o=new Audio(`/api/files/${n}?type=read`);o.onended=()=>a(!1),o.onerror=()=>a(!1),d.current=o}d.current.play().catch(()=>a(!1)),a(!0)}}:void 0,onMouseEnter:e=>{e.currentTarget.style.transform="translateY(-1px)",e.currentTarget.style.background=u,r&&(e.currentTarget.style.borderColor="var(--accent)")},onMouseLeave:e=>{e.currentTarget.style.transform="translateY(0)",e.currentTarget.style.background=p,e.currentTarget.style.borderColor=r?"rgba(59, 130, 246, 0.15)":i?"rgba(225, 29, 72, 0.15)":l?"rgba(16, 185, 129, 0.15)":"var(--border)"},children:[(0,n.jsx)("span",{style:{display:"flex",alignItems:"center",color:c,flexShrink:0},children:r?s?(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{animation:"pulse 1s infinite"},children:[(0,n.jsx)("rect",{x:"6",y:"4",width:"4",height:"16"}),(0,n.jsx)("rect",{x:"14",y:"4",width:"4",height:"16"})]}):(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),(0,n.jsx)("path",{d:"M15.54 8.46a5 5 0 0 1 0 7.07"})]}):i?(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),(0,n.jsx)("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),(0,n.jsx)("polyline",{points:"21 15 16 10 5 21"})]}):l?(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("polyline",{points:"16 18 22 12 16 6"}),(0,n.jsx)("polyline",{points:"8 6 2 12 8 18"})]}):(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),(0,n.jsx)("polyline",{points:"14 2 14 8 20 8"})]})}),(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,minWidth:0,overflow:"hidden"},children:[(0,n.jsx)("span",{style:{fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:180},title:e.path,children:e.name}),e.size&&(0,n.jsxs)("span",{style:{fontSize:10,color:"var(--text-dim)",flexShrink:0},children:["(",e.size,")"]})]}),r&&s&&(0,n.jsxs)("div",{style:{display:"flex",gap:1.5,alignItems:"flex-end",height:11,marginLeft:4,flexShrink:0},children:[(0,n.jsx)("style",{children:`
16
16
  @keyframes chipTtsJump {
17
17
  0%, 100% { height: 3px; }
18
18
  50% { height: 11px; }
@@ -22,10 +22,10 @@
22
22
  background: var(--accent);
23
23
  border-radius: 0.8px;
24
24
  }
25
- `}),(0,n.jsx)("span",{className:"chip-tts-wave-bar",style:{height:6,animation:"chipTtsJump 0.8s ease-in-out infinite"}}),(0,n.jsx)("span",{className:"chip-tts-wave-bar",style:{height:11,animation:"chipTtsJump 0.8s ease-in-out infinite 0.15s"}}),(0,n.jsx)("span",{className:"chip-tts-wave-bar",style:{height:4,animation:"chipTtsJump 0.8s ease-in-out infinite 0.3s"}})]})]})}function ex({attachments:e,cwd:t}){return e&&0!==e.length?(0,n.jsx)("div",{style:{display:"flex",gap:8,flexWrap:"wrap",marginTop:8},children:e.map((e,r)=>(0,n.jsx)(ep,{file:e,cwd:t},r))}):null}let eu=(0,o.memo)(function({message:e,isStreaming:t,toolResults:r,modelNames:i,entryId:l,onFork:s,forking:a,onNavigate:d,prevAssistantEntryId:c,onEditContent:p,showTimestamp:x,prevTimestamp:u,activeModel:g,prevUserContent:h,cwd:f}){let[y,b]=(0,o.useState)(null),v=y&&(0,n.jsxs)("div",{onClick:()=>b(null),style:{position:"fixed",top:0,left:0,right:0,bottom:0,background:"rgba(15, 23, 42, 0.85)",backdropFilter:"blur(12px) saturate(180%)",WebkitBackdropFilter:"blur(12px) saturate(180%)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:99999,cursor:"zoom-out",animation:"fadeIn 0.2s ease-out"},children:[(0,n.jsx)("style",{children:`
25
+ `}),(0,n.jsx)("span",{className:"chip-tts-wave-bar",style:{height:6,animation:"chipTtsJump 0.8s ease-in-out infinite"}}),(0,n.jsx)("span",{className:"chip-tts-wave-bar",style:{height:11,animation:"chipTtsJump 0.8s ease-in-out infinite 0.15s"}}),(0,n.jsx)("span",{className:"chip-tts-wave-bar",style:{height:4,animation:"chipTtsJump 0.8s ease-in-out infinite 0.3s"}})]})]})}function ex({attachments:e,cwd:t}){return e&&0!==e.length?(0,n.jsx)("div",{style:{display:"flex",gap:8,flexWrap:"wrap",marginTop:8},children:e.map((e,r)=>(0,n.jsx)(ep,{file:e,cwd:t},r))}):null}let eu=(0,o.memo)(function({message:e,isStreaming:t,toolResults:r,modelNames:i,entryId:l,onFork:s,forking:a,onNavigate:d,prevAssistantEntryId:c,onEditContent:p,showTimestamp:x,prevTimestamp:u,activeModel:g,prevUserContent:h,cwd:f}){let[b,y]=(0,o.useState)(null),v=b&&(0,n.jsxs)("div",{onClick:()=>y(null),style:{position:"fixed",top:0,left:0,right:0,bottom:0,background:"rgba(15, 23, 42, 0.85)",backdropFilter:"blur(12px) saturate(180%)",WebkitBackdropFilter:"blur(12px) saturate(180%)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:99999,cursor:"zoom-out",animation:"fadeIn 0.2s ease-out"},children:[(0,n.jsx)("style",{children:`
26
26
  @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
27
27
  @keyframes scaleUp { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
28
- `}),(0,n.jsxs)("div",{style:{position:"relative",maxWidth:"90vw",maxHeight:"90vh",display:"flex",alignItems:"center",justifyContent:"center"},children:[(0,n.jsx)("img",{src:y,alt:"Zoomed",style:{maxWidth:"90vw",maxHeight:"90vh",objectFit:"contain",borderRadius:8,boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.5)",animation:"scaleUp 0.2s cubic-bezier(0.34, 1.56, 0.64, 1)"}}),(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),b(null)},style:{position:"fixed",top:20,right:20,width:40,height:40,borderRadius:"50%",background:"rgba(255, 255, 255, 0.1)",border:"none",color:"#fff",fontSize:24,display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",transition:"background 0.15s, transform 0.15s"},onMouseEnter:e=>{e.currentTarget.style.background="rgba(255, 255, 255, 0.2)",e.currentTarget.style.transform="scale(1.08)"},onMouseLeave:e=>{e.currentTarget.style.background="rgba(255, 255, 255, 0.1)",e.currentTarget.style.transform="scale(1)"},children:"\xd7"})]})]});return"user"===e.role?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(eg,{message:e,entryId:l,onFork:s,forking:a,onNavigate:d,prevAssistantEntryId:c,onEditContent:p,onZoomImage:b,cwd:f}),v]}):"assistant"===e.role?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(eh,{message:e,isStreaming:t,toolResults:r,modelNames:i,showTimestamp:x,prevTimestamp:u,onZoomImage:b,activeModel:g,entryId:l,prevUserContent:h,cwd:f}),v]}):(e.role,null)});function eg({message:e,entryId:t,onFork:r,forking:i,onNavigate:l,prevAssistantEntryId:s,onEditContent:a,onZoomImage:d,cwd:c}){let[p,x]=(0,o.useState)(!1),[u,g]=(0,o.useState)(!1),h="string"==typeof e.content?e.content:e.content.filter(e=>"text"===e.type).map(e=>e.text).join("\n"),{cleanText:f,attachments:y}=(0,o.useMemo)(()=>ec(h),[h]),b="string"==typeof e.content?[]:e.content.filter(e=>"image"===e.type),v=ea(e.timestamp),m=!!t&&!!r,j=!!s&&!!l;return(0,n.jsxs)("div",{style:{marginBottom:16,display:"flex",flexDirection:"column",alignItems:"flex-end"},onMouseEnter:()=>x(!0),onMouseLeave:()=>x(!1),children:[(0,n.jsx)("div",{style:{display:"flex",alignItems:"flex-end",gap:6,maxWidth:"85%"},children:(0,n.jsxs)("div",{style:{flex:1,minWidth:0,background:"var(--user-bg)",border:"1px solid rgba(59,130,246,0.2)",borderRadius:12,padding:"8px 12px",fontSize:14,lineHeight:1.6,color:"var(--text)",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:[b.length>0&&(0,n.jsx)("div",{style:{display:"flex",gap:6,flexWrap:"wrap",marginBottom:8*!!f},children:b.map((e,t)=>{let r=e.source?"base64"===e.source.type?`data:${e.source.media_type};base64,${e.source.data}`:e.source.url??"":e.data?`data:${e.mimeType};base64,${e.data}`:"";return(0,n.jsx)("img",{src:r,alt:"",onClick:()=>d?.(r),style:{maxWidth:240,maxHeight:240,borderRadius:6,objectFit:"contain",display:"block",border:"1px solid rgba(59,130,246,0.15)",cursor:"zoom-in"}},t)})}),f,(0,n.jsx)(ex,{attachments:y,cwd:c})]})}),(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:6,marginTop:3},children:[(0,n.jsx)("div",{style:{display:"flex",gap:3,opacity:+!!p,pointerEvents:p?"auto":"none",transition:"opacity 0.12s"},children:(0,n.jsxs)("button",{onClick:()=>{ed(f).then(()=>{g(!0),setTimeout(()=>g(!1),1500)})},title:"Copy message",style:{display:"flex",alignItems:"center",gap:4,padding:"3px 8px",height:22,background:"none",border:"none",borderRadius:5,color:u?"var(--accent)":"var(--text-dim)",cursor:"pointer",fontSize:11,fontWeight:400,whiteSpace:"nowrap",transition:"color 0.12s"},onMouseEnter:e=>{u||(e.currentTarget.style.color="var(--accent)")},onMouseLeave:e=>{u||(e.currentTarget.style.color="var(--text-dim)")},children:[u?(0,n.jsx)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("polyline",{points:"20 6 9 17 4 12"})}):(0,n.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),(0,n.jsx)("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]}),u?"Copied":"Copy"]})}),(m||j)&&(0,n.jsxs)("div",{style:{display:"flex",gap:3,opacity:p||i?1:0,pointerEvents:p||i?"auto":"none",transition:"opacity 0.12s"},children:[j&&(0,n.jsxs)("button",{onClick:()=>{l(s),a?.(f)},title:"Edit from here — branches within this session",style:{display:"flex",alignItems:"center",gap:4,padding:"3px 8px",height:22,background:"none",border:"none",borderRadius:5,color:"var(--text-dim)",cursor:"pointer",fontSize:11,fontWeight:400,whiteSpace:"nowrap",transition:"color 0.12s"},onMouseEnter:e=>{e.currentTarget.style.color="var(--accent)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-dim)"},children:[(0,n.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("polyline",{points:"15 10 20 15 15 20"}),(0,n.jsx)("path",{d:"M4 4v7a4 4 0 0 0 4 4h12"})]}),"Edit from here"]}),m&&(0,n.jsxs)("button",{onClick:()=>{r(t)},disabled:i,title:i?"Creating new session…":"New session — creates an independent copy from here",style:{display:"flex",alignItems:"center",gap:4,padding:"3px 8px",height:22,background:"none",border:"none",borderRadius:5,color:i?"var(--accent)":"var(--text-dim)",cursor:i?"not-allowed":"pointer",fontSize:11,fontWeight:400,whiteSpace:"nowrap",transition:"color 0.12s"},onMouseEnter:e=>{i||(e.currentTarget.style.color="var(--accent)")},onMouseLeave:e=>{i||(e.currentTarget.style.color="var(--text-dim)")},children:[(0,n.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("line",{x1:"6",y1:"3",x2:"6",y2:"15"}),(0,n.jsx)("circle",{cx:"18",cy:"6",r:"3"}),(0,n.jsx)("circle",{cx:"6",cy:"18",r:"3"}),(0,n.jsx)("path",{d:"M18 9a9 9 0 0 1-9 9"})]}),i?"Creating…":"New session"]})]}),v&&(0,n.jsx)("span",{style:{fontSize:10,color:"var(--text-dim)"},children:v})]})]})}function eh({message:e,isStreaming:t,toolResults:r,modelNames:i,showTimestamp:l,prevTimestamp:s,onZoomImage:a,activeModel:d,entryId:c,prevUserContent:p,cwd:x}){var u;let g,h=l?ea(e.timestamp):null,[f,y]=(0,o.useState)(null),b=(ei(e.provider,e.model)?e.model:d?.modelId||"").toLowerCase(),v=(f?.modelId||b).toLowerCase();(0,o.useEffect)(()=>{if("assistant"===e.role)try{let t=localStorage.getItem("mimo_history_voice_settings"),r=t?JSON.parse(t):{},n=String(e.timestamp),o=!1;if(!r[n]){let e=localStorage.getItem("mimo_voice_settings");if(e){let t=JSON.parse(e);t.modelId=b,r[n]=t,o=!0}}if(c&&!r[c])if(r[n])r[c]=r[n],o=!0;else{let e=localStorage.getItem("mimo_voice_settings");if(e){let t=JSON.parse(e);t.modelId=b,r[c]=t,o=!0}}o&&(localStorage.setItem("mimo_history_voice_settings",JSON.stringify(r)),window.dispatchEvent(new Event("mimo_history_voice_settings_changed")))}catch(e){console.error("Failed to snapshot voice settings:",e)}},[c,e.timestamp,b,e.role]),(0,o.useEffect)(()=>{let t=()=>{try{let t=localStorage.getItem("mimo_history_voice_settings");if(t){let r=JSON.parse(t),n=(c?r[c]:void 0)||r[String(e.timestamp)];if(n)return void y(n)}let r=localStorage.getItem("mimo_voice_settings");r&&y(JSON.parse(r))}catch(e){console.error("Failed to load settings in MessageView:",e)}};return t(),window.addEventListener("mimo_voice_settings_changed",t),window.addEventListener("mimo_history_voice_settings_changed",t),()=>{window.removeEventListener("mimo_voice_settings_changed",t),window.removeEventListener("mimo_history_voice_settings_changed",t)}},[c,e.timestamp]);let m=es(void 0,v),j=el(void 0,v),k=e.content??[],[w,S]=(0,o.useState)(!1),[C,T]=(0,o.useState)(!1),I=(0,o.useRef)(null),[z,R]=(0,o.useState)(null),L=(0,o.useRef)(k);L.current=k;let W=(0,o.useRef)(new Map),[E,M]=(0,o.useState)(new Map),D=(0,o.useMemo)(()=>{if(!e.timestamp||!s)return;let t=Math.round((e.timestamp-s)/1e3);return t>0?t:void 0},[e.timestamp,s]),$=(0,o.useMemo)(()=>{let t=new Map;if(!r||!e.timestamp)return t;for(let[n,o]of r)if(o.timestamp&&e.timestamp){let r=Math.round((o.timestamp-e.timestamp)/1e3);r>0&&t.set(n,r)}return t},[r,e.timestamp]),B=k.filter(e=>"text"===e.type).map(e=>e.text).join("\n"),A=ei(d?.provider,d?.modelId)||ei(e.provider,e.model),F=function(e){if(!e)return"";let t=e,r="\x3c!-- PI_FILE_ATTACHMENTS_START --\x3e",n="\x3c!-- PI_FILE_ATTACHMENTS_END --\x3e";if(t.includes(r)){let e=t.indexOf(r),o=t.indexOf(n);t=-1!==o&&o>e?t.substring(0,e)+t.substring(o+n.length):t.substring(0,e)}return(t=(t=(t=t.replace(/📄\s*\[已上传文件到工作区\][\s\S]*/g,"")).replace(/^[-\*\s•]*temp\/[^\r\n]*/gim,"")).replace(/^📄\s*\[已上传文件到工作区\][^\r\n]*/gim,"")).trim()}(B||p||""),{isPlaying:O,isLoading:N,error:P,play:H,pause:_,audioUrl:J}=function(e,t,r,n=!1){let[i,l]=(0,o.useState)({isPlaying:!1,isLoading:!1,error:null}),[s,a]=(0,o.useState)(null);(0,o.useEffect)(()=>()=>{et===l&&(et=null)},[]),(0,o.useEffect)(()=>{if(!n)return;let o=async()=>{let n=er(t,r,e);a(await en(n))};return o(),window.addEventListener("mimo_voice_settings_changed",o),window.addEventListener("mimo_history_voice_settings_changed",o),()=>{window.removeEventListener("mimo_voice_settings_changed",o),window.removeEventListener("mimo_history_voice_settings_changed",o)}},[t,r,e,n]);let d=async(n,o,i)=>{if(ee){try{ee.pause(),ee.currentTime=0}catch(e){console.error("Failed to pause active audio:",e)}ee=null}et&&(et({isPlaying:!1,isLoading:!1,error:null}),et=null),l({isPlaying:!1,isLoading:!0,error:null}),et=l;try{let s=er(t,i||r,e);n&&(s.style=n),o&&(s.voice=o);let d=await en(s);if(!d){let e=await fetch("/api/tts/synthesize",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!e.ok){let t=await e.json().catch(()=>({}));throw console.error("[useTts] Synthesis endpoint returned error details:",t),Error(t.error||`Synthesis failed (HTTP ${e.status})`)}let t=await e.json();if(!t.audioUrl)throw Error("No speech audio returned from synthesis endpoint");d=t.audioUrl,await eo(s,d)}let c=new Audio(d);ee=c,a(d),c.onplay=()=>{l({isPlaying:!0,isLoading:!1,error:null})},c.onended=()=>{l({isPlaying:!1,isLoading:!1,error:null}),ee===c&&(ee=null),et===l&&(et=null)},c.onerror=()=>{l({isPlaying:!1,isLoading:!1,error:"音频播放失败"}),ee===c&&(ee=null),et===l&&(et=null)},await c.play()}catch(e){console.error("[useTts] Speech synthesis error:",e),l({isPlaying:!1,isLoading:!1,error:e.message||"语音合成出错"}),et===l&&(et=null)}};return{isPlaying:i.isPlaying,isLoading:i.isLoading,error:i.error,play:d,pause:()=>{if(ee&&et===l){try{ee.pause()}catch(e){console.error("Pause error:",e)}l({isPlaying:!1,isLoading:!1,error:null}),ee=null,et=null}},audioUrl:s}}(c||String(e.timestamp),F,b,w),U=!B&&A&&p;return(0,o.useEffect)(()=>{if(!t){let e=Date.now();M(t=>{let r=new Map(t);for(let[t,n]of W.current)r.has(t)||r.set(t,Math.round((e-n)/1e3));return r}),I.current=null,R(null);return}let e=setInterval(()=>{let e=L.current,t=Date.now();e.forEach((e,r)=>{W.current.has(r)||W.current.set(r,t)}),M(r=>{let n=!1,o=new Map(r);for(let r=0;r<e.length-1;r++)if(!o.has(r)&&W.current.has(r)){let e=W.current.get(r),i=W.current.get(r+1)??t;o.set(r,Math.round((i-e)/1e3)),n=!0}return n?o:r});let r=0;for(let t of e)"text"===t.type?r+=t.text?.length??0:"thinking"===t.type?r+=t.thinking?.length??0:"toolCall"===t.type&&(r+=JSON.stringify(t.input??{}).length);if(0===r)return;null===I.current&&(I.current=t);let n=(t-I.current)/1e3;n>.5&&R(r/4/n)},300);return()=>clearInterval(e)},[t]),(0,n.jsxs)("div",{style:{marginBottom:16},onMouseEnter:()=>S(!0),onMouseLeave:()=>S(!1),children:[(0,n.jsxs)("div",{style:{fontSize:11,color:"var(--text-dim)",marginBottom:4,display:"flex",alignItems:"center",gap:6},children:[e.provider&&(0,n.jsx)("span",{children:i?.[`${e.provider}:${e.model}`]??i?.[e.model]??e.model}),t&&(()=>{let e,t=0;for(let e of k)"text"===e.type?t+=e.text?.length??0:"thinking"===e.type?t+=e.thinking?.length??0:"toolCall"===e.type&&(t+=JSON.stringify(e.input??{}).length);let r=Math.round(t/4);return(0,n.jsx)(n.Fragment,{children:r>0&&(0,n.jsxs)("span",{style:{display:"flex",alignItems:"center",gap:4,color:"var(--text)"},title:"预估 token 数(流式接收中)",children:[(0,n.jsxs)("span",{style:{display:"flex",alignItems:"center",gap:2,fontSize:11,fontWeight:400},children:[(0,n.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("line",{x1:"5",y1:"1.5",x2:"5",y2:"8.5"}),(0,n.jsx)("polyline",{points:"2 6 5 8.5 8 6"})]}),r]}),null!==z&&(e=z>=50?"#53b3cb":z>=30?"#9bc53d":z>=15?"#f9c22e":"#e01a4f",(0,n.jsxs)("span",{style:{marginLeft:6,padding:"1px 6px",borderRadius:4,background:e,color:"#fff",fontSize:11,fontWeight:400},children:[z.toFixed(1)," t/s"]}))]})})})()]}),(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[k.map((e,o)=>(0,n.jsx)(ef,{block:e,toolResults:r,isStreaming:t,streamingDuration:E.get(o)??("thinking"===e.type?D:void 0),toolCallDurations:$,onZoomImage:a},o)),"assistant"===e.role&&e.errorMessage&&(0,n.jsxs)("div",{style:{border:"1px dashed #ef4444",background:"rgba(239, 68, 68, 0.04)",borderRadius:8,padding:"10px 14px",fontSize:13,color:"#ef4444",lineHeight:1.6,fontFamily:"var(--font-serif)",marginTop:4,maxWidth:"100%",boxSizing:"border-box"},children:[(0,n.jsxs)("div",{style:{fontWeight:600,display:"flex",alignItems:"center",gap:6,marginBottom:4},children:[(0,n.jsx)("span",{style:{fontSize:13},children:"⚠️"}),(0,n.jsx)("span",{children:"协同写作服务发生错误 (API Error)"})]}),(0,n.jsx)("div",{style:{opacity:.85,fontSize:12},children:e.errorMessage})]}),U&&(()=>{let{cleanText:e,attachments:t}=ec(p||"");return(0,n.jsxs)("div",{style:{border:"1px dashed rgba(59,130,246,0.35)",background:"rgba(59,130,246,0.015)",borderRadius:8,padding:"10px 14px",fontSize:13,color:"var(--text)",lineHeight:1.6},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,fontSize:11,color:"var(--accent)",fontWeight:600,marginBottom:6},children:[(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),(0,n.jsx)("path",{d:"M15.54 8.46a5 5 0 0 1 0 7.07"})]}),"待播报文本 (Speech prompt text):"]}),(0,n.jsx)("div",{style:{whiteSpace:"pre-wrap",color:"var(--text-muted)",fontSize:12.5},children:e}),(0,n.jsx)(ex,{attachments:t,cwd:x})]})})(),t&&0===k.length&&(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,color:"var(--text-dim)",fontSize:13,padding:"4px 0"},children:[(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{animation:"spin 1s linear infinite"},children:[(0,n.jsx)("line",{x1:"12",y1:"2",x2:"12",y2:"6"}),(0,n.jsx)("line",{x1:"12",y1:"18",x2:"12",y2:"22"}),(0,n.jsx)("line",{x1:"4.93",y1:"4.93",x2:"7.76",y2:"7.76"}),(0,n.jsx)("line",{x1:"16.24",y1:"16.24",x2:"19.07",y2:"19.07"}),(0,n.jsx)("line",{x1:"2",y1:"12",x2:"6",y2:"12"}),(0,n.jsx)("line",{x1:"18",y1:"12",x2:"22",y2:"12"}),(0,n.jsx)("line",{x1:"4.93",y1:"19.07",x2:"7.76",y2:"16.24"}),(0,n.jsx)("line",{x1:"16.24",y1:"7.76",x2:"19.07",y2:"4.93"})]}),(0,n.jsx)("span",{style:{animation:"pulse 1.5s infinite"},children:"Thinking..."})]})]}),(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:4},children:[e.usage&&!t&&(0,n.jsx)("div",{style:{fontSize:11,color:"var(--text-dim)"},children:(u=e.usage,g=[],u.input&&g.push(`${u.input.toLocaleString()} in`),u.output&&g.push(`${u.output.toLocaleString()} out`),u.cacheRead&&g.push(`${u.cacheRead.toLocaleString()} cache`),u.cost?.total&&g.push(`$${u.cost.total.toFixed(4)}`),g.join(" \xb7 "))}),B&&!t&&(0,n.jsxs)("button",{onClick:()=>{ed(B).then(()=>{T(!0),setTimeout(()=>T(!1),1500)})},title:"Copy message",style:{display:"flex",alignItems:"center",gap:4,padding:"3px 8px",height:22,background:"none",border:"none",borderRadius:5,color:C?"var(--accent)":"var(--text-dim)",cursor:"pointer",fontSize:11,fontWeight:400,whiteSpace:"nowrap",opacity:+!!w,pointerEvents:w?"auto":"none",transition:"opacity 0.12s, color 0.12s"},onMouseEnter:e=>{C||(e.currentTarget.style.color="var(--accent)")},onMouseLeave:e=>{C||(e.currentTarget.style.color="var(--text-dim)")},children:[C?(0,n.jsx)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("polyline",{points:"20 6 9 17 4 12"})}):(0,n.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),(0,n.jsx)("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]}),C?"Copied":"Copy"]}),A&&F&&!t&&(0,n.jsxs)("div",{style:{position:"relative",display:"inline-flex",alignItems:"center",gap:2},children:[(0,n.jsxs)("button",{onClick:()=>O?_():H(void 0,void 0,ei(e.provider,e.model)?e.model:d?.modelId||e.model),title:O?"暂停播放":J?"播放已生成的语音":"生成并播放语音",style:{display:"flex",alignItems:"center",gap:4,padding:"3px 8px",height:22,background:"none",border:"none",borderRadius:5,color:O?"var(--accent)":"var(--text-dim)",cursor:N?"not-allowed":"pointer",fontSize:11,fontWeight:400,whiteSpace:"nowrap",opacity:1,pointerEvents:"auto",transition:"color 0.12s"},disabled:N,onMouseEnter:e=>{O||(e.currentTarget.style.color="var(--accent)")},onMouseLeave:e=>{O||(e.currentTarget.style.color="var(--text-dim)")},children:[N?(0,n.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",style:{animation:"spin 1s linear infinite"},children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"10",stroke:"rgba(255,255,255,0.2)"}),(0,n.jsx)("path",{d:"M12 2a10 10 0 0 1 10 10"})]}):O?(0,n.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("rect",{x:"6",y:"4",width:"4",height:"16"}),(0,n.jsx)("rect",{x:"14",y:"4",width:"4",height:"16"})]}):(0,n.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),(0,n.jsx)("path",{d:"M15.54 8.46a5 5 0 0 1 0 7.07"}),(0,n.jsx)("path",{d:"M19.07 4.93a10 10 0 0 1 0 14.14"})]}),N?"生成中...":O?"播放中":J?"播放":"生成并播放"]}),J&&(0,n.jsx)("button",{onClick:()=>{let e=document.createElement("a");e.href=J;let t=Math.floor(1e5+9e5*Math.random()),r="tts";j?r="voiceclone":m&&(r="voicedesign"),e.download=`mimo-${r}-${t}.mp3`,document.body.appendChild(e),e.click(),document.body.removeChild(e)},title:"下载语音文件 (Download MP3)",style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"3px",width:22,height:22,background:"none",border:"none",borderRadius:5,color:"var(--text-dim)",cursor:"pointer",transition:"color 0.12s"},onMouseEnter:e=>{e.currentTarget.style.color="var(--accent)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-dim)"},children:(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),(0,n.jsx)("polyline",{points:"7 10 12 15 17 10"}),(0,n.jsx)("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]})}),f&&(()=>{let e="",t=f.voiceDesignActiveChips||[];if(m)try{let r=localStorage.getItem("mimo_voice_design_library"),n=(r?JSON.parse(r):[]).find(e=>e.prompt===f.voiceDesignPrompt||!!(Array.isArray(e.chips)&&Array.isArray(t))&&e.chips.length===t.length&&e.chips.every((e,r)=>e===t[r]));n&&(e=n.name)}catch(e){console.error("Failed to lookup matched timbre name:",e)}let r="\uD83C\uDF99️",o="",i="var(--text-dim)",l="var(--bg-panel)",s="1px solid var(--border)";if(m)r="\uD83E\uDDE9",o=t.length>0?t.join(" / "):"自定义声线",i="var(--accent)",l="rgba(59,130,246,0.06)",s="1px solid rgba(59,130,246,0.15)";else if(j)r="\uD83C\uDF99️",o=f.voiceCloneActiveFile?`声线克隆: ${f.voiceCloneActiveFile}`:"未选择克隆声源",i="#10b981",l="rgba(16,185,129,0.06)",s="1px solid rgba(16,185,129,0.15)";else{r="\uD83C\uDF38";let e={mimo_default:"冰糖 (默认)",茉莉:"茉莉 (温柔女)",苏打:"苏打 (活力男)",白桦:"白桦 (稳重男)",Chloe:"Chloe (英音女)",Mia:"Mia (美音女)",Milo:"Milo (美音男)",Dean:"Dean (澳音男)"}[f.presetVoice||"mimo_default"]||f.presetVoice||"冰糖 (默认)";o=`官方声线: ${e}`,i="var(--text-muted)",l="rgba(255,255,255,0.02)",s="1px solid var(--border)"}return(0,n.jsxs)("div",{style:{display:"inline-flex",alignItems:"center",gap:6,marginLeft:6},children:[e&&(0,n.jsx)("span",{style:{display:"inline-flex",alignItems:"center",gap:4,padding:"2px 8px",borderRadius:6,fontSize:10.5,color:"#f59e0b",background:"rgba(245, 158, 11, 0.08)",border:"1px solid rgba(245, 158, 11, 0.2)",height:22,pointerEvents:"none",whiteSpace:"nowrap",opacity:1},title:e,children:(0,n.jsx)("span",{style:{fontWeight:600},children:e})}),(0,n.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:4,padding:"2px 8px",borderRadius:6,fontSize:10.5,color:i,background:l,border:s,height:22,pointerEvents:"none",whiteSpace:"nowrap",opacity:1},title:o,children:[(0,n.jsx)("span",{children:r}),(0,n.jsx)("span",{style:{fontWeight:500},children:o})]})]})})(),O&&(0,n.jsxs)("div",{style:{display:"flex",gap:1.5,alignItems:"flex-end",height:11,marginLeft:2,marginRight:2},children:[(0,n.jsx)("style",{children:`
28
+ `}),(0,n.jsxs)("div",{style:{position:"relative",maxWidth:"90vw",maxHeight:"90vh",display:"flex",alignItems:"center",justifyContent:"center"},children:[(0,n.jsx)("img",{src:b,alt:"Zoomed",style:{maxWidth:"90vw",maxHeight:"90vh",objectFit:"contain",borderRadius:8,boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.5)",animation:"scaleUp 0.2s cubic-bezier(0.34, 1.56, 0.64, 1)"}}),(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),y(null)},style:{position:"fixed",top:20,right:20,width:40,height:40,borderRadius:"50%",background:"rgba(255, 255, 255, 0.1)",border:"none",color:"#fff",fontSize:24,display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",transition:"background 0.15s, transform 0.15s"},onMouseEnter:e=>{e.currentTarget.style.background="rgba(255, 255, 255, 0.2)",e.currentTarget.style.transform="scale(1.08)"},onMouseLeave:e=>{e.currentTarget.style.background="rgba(255, 255, 255, 0.1)",e.currentTarget.style.transform="scale(1)"},children:"\xd7"})]})]});return"user"===e.role?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(eg,{message:e,entryId:l,onFork:s,forking:a,onNavigate:d,prevAssistantEntryId:c,onEditContent:p,onZoomImage:y,cwd:f}),v]}):"assistant"===e.role?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(eh,{message:e,isStreaming:t,toolResults:r,modelNames:i,showTimestamp:x,prevTimestamp:u,onZoomImage:y,activeModel:g,entryId:l,prevUserContent:h,cwd:f}),v]}):(e.role,null)});function eg({message:e,entryId:t,onFork:r,forking:i,onNavigate:l,prevAssistantEntryId:s,onEditContent:a,onZoomImage:d,cwd:c}){let[p,x]=(0,o.useState)(!1),[u,g]=(0,o.useState)(!1),h="string"==typeof e.content?e.content:e.content.filter(e=>"text"===e.type).map(e=>e.text).join("\n"),{cleanText:f,attachments:b}=(0,o.useMemo)(()=>ec(h),[h]),y="string"==typeof e.content?[]:e.content.filter(e=>"image"===e.type),v=ea(e.timestamp),m=!!t&&!!r,j=!!s&&!!l;return(0,n.jsxs)("div",{style:{marginBottom:16,display:"flex",flexDirection:"column",alignItems:"flex-end"},onMouseEnter:()=>x(!0),onMouseLeave:()=>x(!1),children:[(0,n.jsx)("div",{style:{display:"flex",alignItems:"flex-end",gap:6,maxWidth:"85%"},children:(0,n.jsxs)("div",{style:{flex:1,minWidth:0,background:"var(--user-bg)",border:"1px solid rgba(59,130,246,0.2)",borderRadius:12,padding:"8px 12px",fontSize:14,lineHeight:1.6,color:"var(--text)",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:[y.length>0&&(0,n.jsx)("div",{style:{display:"flex",gap:6,flexWrap:"wrap",marginBottom:8*!!f},children:y.map((e,t)=>{let r=e.source?"base64"===e.source.type?`data:${e.source.media_type};base64,${e.source.data}`:e.source.url??"":e.data?`data:${e.mimeType};base64,${e.data}`:"";return(0,n.jsx)("img",{src:r,alt:"",onClick:()=>d?.(r),style:{maxWidth:240,maxHeight:240,borderRadius:6,objectFit:"contain",display:"block",border:"1px solid rgba(59,130,246,0.15)",cursor:"zoom-in"}},t)})}),f,(0,n.jsx)(ex,{attachments:b,cwd:c})]})}),(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:6,marginTop:3},children:[(0,n.jsx)("div",{style:{display:"flex",gap:3,opacity:+!!p,pointerEvents:p?"auto":"none",transition:"opacity 0.12s"},children:(0,n.jsxs)("button",{onClick:()=>{ed(f).then(()=>{g(!0),setTimeout(()=>g(!1),1500)})},title:"Copy message",style:{display:"flex",alignItems:"center",gap:4,padding:"3px 8px",height:22,background:"none",border:"none",borderRadius:5,color:u?"var(--accent)":"var(--text-dim)",cursor:"pointer",fontSize:11,fontWeight:400,whiteSpace:"nowrap",transition:"color 0.12s"},onMouseEnter:e=>{u||(e.currentTarget.style.color="var(--accent)")},onMouseLeave:e=>{u||(e.currentTarget.style.color="var(--text-dim)")},children:[u?(0,n.jsx)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("polyline",{points:"20 6 9 17 4 12"})}):(0,n.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),(0,n.jsx)("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]}),u?"Copied":"Copy"]})}),(m||j)&&(0,n.jsxs)("div",{style:{display:"flex",gap:3,opacity:p||i?1:0,pointerEvents:p||i?"auto":"none",transition:"opacity 0.12s"},children:[j&&(0,n.jsxs)("button",{onClick:()=>{l(s),a?.(f)},title:"Edit from here — branches within this session",style:{display:"flex",alignItems:"center",gap:4,padding:"3px 8px",height:22,background:"none",border:"none",borderRadius:5,color:"var(--text-dim)",cursor:"pointer",fontSize:11,fontWeight:400,whiteSpace:"nowrap",transition:"color 0.12s"},onMouseEnter:e=>{e.currentTarget.style.color="var(--accent)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-dim)"},children:[(0,n.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("polyline",{points:"15 10 20 15 15 20"}),(0,n.jsx)("path",{d:"M4 4v7a4 4 0 0 0 4 4h12"})]}),"Edit from here"]}),m&&(0,n.jsxs)("button",{onClick:()=>{r(t)},disabled:i,title:i?"Creating new session…":"New session — creates an independent copy from here",style:{display:"flex",alignItems:"center",gap:4,padding:"3px 8px",height:22,background:"none",border:"none",borderRadius:5,color:i?"var(--accent)":"var(--text-dim)",cursor:i?"not-allowed":"pointer",fontSize:11,fontWeight:400,whiteSpace:"nowrap",transition:"color 0.12s"},onMouseEnter:e=>{i||(e.currentTarget.style.color="var(--accent)")},onMouseLeave:e=>{i||(e.currentTarget.style.color="var(--text-dim)")},children:[(0,n.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("line",{x1:"6",y1:"3",x2:"6",y2:"15"}),(0,n.jsx)("circle",{cx:"18",cy:"6",r:"3"}),(0,n.jsx)("circle",{cx:"6",cy:"18",r:"3"}),(0,n.jsx)("path",{d:"M18 9a9 9 0 0 1-9 9"})]}),i?"Creating…":"New session"]})]}),v&&(0,n.jsx)("span",{style:{fontSize:10,color:"var(--text-dim)"},children:v})]})]})}function eh({message:e,isStreaming:t,toolResults:r,modelNames:i,showTimestamp:l,prevTimestamp:s,onZoomImage:a,activeModel:d,entryId:c,prevUserContent:p,cwd:x}){var u;let g,h=l?ea(e.timestamp):null,[f,b]=(0,o.useState)(null),y=(ei(e.provider,e.model)?e.model:d?.modelId||"").toLowerCase(),v=(f?.modelId||y).toLowerCase();(0,o.useEffect)(()=>{if("assistant"===e.role)try{let t=localStorage.getItem("mimo_history_voice_settings"),r=t?JSON.parse(t):{},n=String(e.timestamp),o=!1;if(!r[n]){let e=localStorage.getItem("mimo_voice_settings");if(e){let t=JSON.parse(e);t.modelId=y,r[n]=t,o=!0}}if(c&&!r[c])if(r[n])r[c]=r[n],o=!0;else{let e=localStorage.getItem("mimo_voice_settings");if(e){let t=JSON.parse(e);t.modelId=y,r[c]=t,o=!0}}o&&(localStorage.setItem("mimo_history_voice_settings",JSON.stringify(r)),window.dispatchEvent(new Event("mimo_history_voice_settings_changed")))}catch(e){console.error("Failed to snapshot voice settings:",e)}},[c,e.timestamp,y,e.role]),(0,o.useEffect)(()=>{let t=()=>{try{let t=localStorage.getItem("mimo_history_voice_settings");if(t){let r=JSON.parse(t),n=(c?r[c]:void 0)||r[String(e.timestamp)];if(n)return void b(n)}let r=localStorage.getItem("mimo_voice_settings");r&&b(JSON.parse(r))}catch(e){console.error("Failed to load settings in MessageView:",e)}};return t(),window.addEventListener("mimo_voice_settings_changed",t),window.addEventListener("mimo_history_voice_settings_changed",t),()=>{window.removeEventListener("mimo_voice_settings_changed",t),window.removeEventListener("mimo_history_voice_settings_changed",t)}},[c,e.timestamp]);let m=es(void 0,v),j=el(void 0,v),k=e.content??[],[w,S]=(0,o.useState)(!1),[C,T]=(0,o.useState)(!1),z=(0,o.useRef)(null),[I,R]=(0,o.useState)(null),L=(0,o.useRef)(k);L.current=k;let W=(0,o.useRef)(new Map),[E,M]=(0,o.useState)(new Map),D=(0,o.useMemo)(()=>{if(!e.timestamp||!s)return;let t=Math.round((e.timestamp-s)/1e3);return t>0?t:void 0},[e.timestamp,s]),$=(0,o.useMemo)(()=>{let t=new Map;if(!r||!e.timestamp)return t;for(let[n,o]of r)if(o.timestamp&&e.timestamp){let r=Math.round((o.timestamp-e.timestamp)/1e3);r>0&&t.set(n,r)}return t},[r,e.timestamp]),B=k.filter(e=>"text"===e.type).map(e=>e.text).join("\n"),A=ei(d?.provider,d?.modelId)||ei(e.provider,e.model),O=function(e){if(!e)return"";let t=e,r="\x3c!-- PI_FILE_ATTACHMENTS_START --\x3e",n="\x3c!-- PI_FILE_ATTACHMENTS_END --\x3e";if(t.includes(r)){let e=t.indexOf(r),o=t.indexOf(n);t=-1!==o&&o>e?t.substring(0,e)+t.substring(o+n.length):t.substring(0,e)}return(t=(t=(t=t.replace(/📄\s*\[已上传文件到工作区\][\s\S]*/g,"")).replace(/^[-\*\s•]*temp\/[^\r\n]*/gim,"")).replace(/^📄\s*\[已上传文件到工作区\][^\r\n]*/gim,"")).trim()}(B||p||""),{isPlaying:F,isLoading:N,error:P,play:H,pause:_,audioUrl:J}=function(e,t,r,n=!1){let[i,l]=(0,o.useState)({isPlaying:!1,isLoading:!1,error:null}),[s,a]=(0,o.useState)(null);(0,o.useEffect)(()=>()=>{et===l&&(et=null)},[]),(0,o.useEffect)(()=>{if(!n)return;let o=async()=>{let n=er(t,r,e);a(await en(n))};return o(),window.addEventListener("mimo_voice_settings_changed",o),window.addEventListener("mimo_history_voice_settings_changed",o),()=>{window.removeEventListener("mimo_voice_settings_changed",o),window.removeEventListener("mimo_history_voice_settings_changed",o)}},[t,r,e,n]);let d=async(n,o,i)=>{if(ee){try{ee.pause(),ee.currentTime=0}catch(e){console.error("Failed to pause active audio:",e)}ee=null}et&&(et({isPlaying:!1,isLoading:!1,error:null}),et=null),l({isPlaying:!1,isLoading:!0,error:null}),et=l;try{let s=er(t,i||r,e);n&&(s.style=n),o&&(s.voice=o);let d=await en(s);if(!d){let e=await fetch("/api/tts/synthesize",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!e.ok){let t=await e.json().catch(()=>({}));throw console.error("[useTts] Synthesis endpoint returned error details:",t),Error(t.error||`Synthesis failed (HTTP ${e.status})`)}let t=await e.json();if(!t.audioUrl)throw Error("No speech audio returned from synthesis endpoint");d=t.audioUrl,await eo(s,d)}let c=new Audio(d);ee=c,a(d),c.onplay=()=>{l({isPlaying:!0,isLoading:!1,error:null})},c.onended=()=>{l({isPlaying:!1,isLoading:!1,error:null}),ee===c&&(ee=null),et===l&&(et=null)},c.onerror=()=>{l({isPlaying:!1,isLoading:!1,error:"音频播放失败"}),ee===c&&(ee=null),et===l&&(et=null)},await c.play()}catch(e){console.error("[useTts] Speech synthesis error:",e),l({isPlaying:!1,isLoading:!1,error:e.message||"语音合成出错"}),et===l&&(et=null)}};return{isPlaying:i.isPlaying,isLoading:i.isLoading,error:i.error,play:d,pause:()=>{if(ee&&et===l){try{ee.pause()}catch(e){console.error("Pause error:",e)}l({isPlaying:!1,isLoading:!1,error:null}),ee=null,et=null}},audioUrl:s}}(c||String(e.timestamp),O,y,w),U=!B&&A&&p;return(0,o.useEffect)(()=>{if(!t){let e=Date.now();M(t=>{let r=new Map(t);for(let[t,n]of W.current)r.has(t)||r.set(t,Math.round((e-n)/1e3));return r}),z.current=null,R(null);return}let e=setInterval(()=>{let e=L.current,t=Date.now();e.forEach((e,r)=>{W.current.has(r)||W.current.set(r,t)}),M(r=>{let n=!1,o=new Map(r);for(let r=0;r<e.length-1;r++)if(!o.has(r)&&W.current.has(r)){let e=W.current.get(r),i=W.current.get(r+1)??t;o.set(r,Math.round((i-e)/1e3)),n=!0}return n?o:r});let r=0;for(let t of e)"text"===t.type?r+=t.text?.length??0:"thinking"===t.type?r+=t.thinking?.length??0:"toolCall"===t.type&&(r+=JSON.stringify(t.input??{}).length);if(0===r)return;null===z.current&&(z.current=t);let n=(t-z.current)/1e3;n>.5&&R(r/4/n)},300);return()=>clearInterval(e)},[t]),(0,n.jsxs)("div",{style:{marginBottom:16},onMouseEnter:()=>S(!0),onMouseLeave:()=>S(!1),children:[(0,n.jsxs)("div",{style:{fontSize:11,color:"var(--text-dim)",marginBottom:4,display:"flex",alignItems:"center",gap:6},children:[e.provider&&(0,n.jsx)("span",{children:i?.[`${e.provider}:${e.model}`]??i?.[e.model]??e.model}),t&&(()=>{let e,t=0;for(let e of k)"text"===e.type?t+=e.text?.length??0:"thinking"===e.type?t+=e.thinking?.length??0:"toolCall"===e.type&&(t+=JSON.stringify(e.input??{}).length);let r=Math.round(t/4);return(0,n.jsx)(n.Fragment,{children:r>0&&(0,n.jsxs)("span",{style:{display:"flex",alignItems:"center",gap:4,color:"var(--text)"},title:"预估 token 数(流式接收中)",children:[(0,n.jsxs)("span",{style:{display:"flex",alignItems:"center",gap:2,fontSize:11,fontWeight:400},children:[(0,n.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("line",{x1:"5",y1:"1.5",x2:"5",y2:"8.5"}),(0,n.jsx)("polyline",{points:"2 6 5 8.5 8 6"})]}),r]}),null!==I&&(e=I>=50?"#53b3cb":I>=30?"#9bc53d":I>=15?"#f9c22e":"#e01a4f",(0,n.jsxs)("span",{style:{marginLeft:6,padding:"1px 6px",borderRadius:4,background:e,color:"#fff",fontSize:11,fontWeight:400},children:[I.toFixed(1)," t/s"]}))]})})})()]}),(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[k.map((e,o)=>(0,n.jsx)(ef,{block:e,toolResults:r,isStreaming:t,streamingDuration:E.get(o)??("thinking"===e.type?D:void 0),toolCallDurations:$,onZoomImage:a},o)),"assistant"===e.role&&e.errorMessage&&(0,n.jsxs)("div",{style:{border:"1px dashed #ef4444",background:"rgba(239, 68, 68, 0.04)",borderRadius:8,padding:"10px 14px",fontSize:13,color:"#ef4444",lineHeight:1.6,fontFamily:"var(--font-serif)",marginTop:4,maxWidth:"100%",boxSizing:"border-box"},children:[(0,n.jsxs)("div",{style:{fontWeight:600,display:"flex",alignItems:"center",gap:6,marginBottom:4},children:[(0,n.jsx)("span",{style:{fontSize:13},children:"⚠️"}),(0,n.jsx)("span",{children:"协同写作服务发生错误 (API Error)"})]}),(0,n.jsx)("div",{style:{opacity:.85,fontSize:12},children:e.errorMessage})]}),U&&(()=>{let{cleanText:e,attachments:t}=ec(p||"");return(0,n.jsxs)("div",{style:{border:"1px dashed rgba(59,130,246,0.35)",background:"rgba(59,130,246,0.015)",borderRadius:8,padding:"10px 14px",fontSize:13,color:"var(--text)",lineHeight:1.6},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,fontSize:11,color:"var(--accent)",fontWeight:600,marginBottom:6},children:[(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),(0,n.jsx)("path",{d:"M15.54 8.46a5 5 0 0 1 0 7.07"})]}),"待播报文本 (Speech prompt text):"]}),(0,n.jsx)("div",{style:{whiteSpace:"pre-wrap",color:"var(--text-muted)",fontSize:12.5},children:e}),(0,n.jsx)(ex,{attachments:t,cwd:x})]})})(),t&&0===k.length&&(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,color:"var(--text-dim)",fontSize:13,padding:"4px 0"},children:[(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{animation:"spin 1s linear infinite"},children:[(0,n.jsx)("line",{x1:"12",y1:"2",x2:"12",y2:"6"}),(0,n.jsx)("line",{x1:"12",y1:"18",x2:"12",y2:"22"}),(0,n.jsx)("line",{x1:"4.93",y1:"4.93",x2:"7.76",y2:"7.76"}),(0,n.jsx)("line",{x1:"16.24",y1:"16.24",x2:"19.07",y2:"19.07"}),(0,n.jsx)("line",{x1:"2",y1:"12",x2:"6",y2:"12"}),(0,n.jsx)("line",{x1:"18",y1:"12",x2:"22",y2:"12"}),(0,n.jsx)("line",{x1:"4.93",y1:"19.07",x2:"7.76",y2:"16.24"}),(0,n.jsx)("line",{x1:"16.24",y1:"7.76",x2:"19.07",y2:"4.93"})]}),(0,n.jsx)("span",{style:{animation:"pulse 1.5s infinite"},children:"Thinking..."})]})]}),(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:4},children:[e.usage&&!t&&(0,n.jsx)("div",{style:{fontSize:11,color:"var(--text-dim)"},children:(u=e.usage,g=[],u.input&&g.push(`${u.input.toLocaleString()} in`),u.output&&g.push(`${u.output.toLocaleString()} out`),u.cacheRead&&g.push(`${u.cacheRead.toLocaleString()} cache`),u.cost?.total&&g.push(`$${u.cost.total.toFixed(4)}`),g.join(" \xb7 "))}),B&&!t&&(0,n.jsxs)("button",{onClick:()=>{ed(B).then(()=>{T(!0),setTimeout(()=>T(!1),1500)})},title:"Copy message",style:{display:"flex",alignItems:"center",gap:4,padding:"3px 8px",height:22,background:"none",border:"none",borderRadius:5,color:C?"var(--accent)":"var(--text-dim)",cursor:"pointer",fontSize:11,fontWeight:400,whiteSpace:"nowrap",opacity:+!!w,pointerEvents:w?"auto":"none",transition:"opacity 0.12s, color 0.12s"},onMouseEnter:e=>{C||(e.currentTarget.style.color="var(--accent)")},onMouseLeave:e=>{C||(e.currentTarget.style.color="var(--text-dim)")},children:[C?(0,n.jsx)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("polyline",{points:"20 6 9 17 4 12"})}):(0,n.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),(0,n.jsx)("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]}),C?"Copied":"Copy"]}),A&&O&&!t&&(0,n.jsxs)("div",{style:{position:"relative",display:"inline-flex",alignItems:"center",gap:2},children:[(0,n.jsxs)("button",{onClick:()=>F?_():H(void 0,void 0,ei(e.provider,e.model)?e.model:d?.modelId||e.model),title:F?"暂停播放":J?"播放已生成的语音":"生成并播放语音",style:{display:"flex",alignItems:"center",gap:4,padding:"3px 8px",height:22,background:"none",border:"none",borderRadius:5,color:F?"var(--accent)":"var(--text-dim)",cursor:N?"not-allowed":"pointer",fontSize:11,fontWeight:400,whiteSpace:"nowrap",opacity:1,pointerEvents:"auto",transition:"color 0.12s"},disabled:N,onMouseEnter:e=>{F||(e.currentTarget.style.color="var(--accent)")},onMouseLeave:e=>{F||(e.currentTarget.style.color="var(--text-dim)")},children:[N?(0,n.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",style:{animation:"spin 1s linear infinite"},children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"10",stroke:"rgba(255,255,255,0.2)"}),(0,n.jsx)("path",{d:"M12 2a10 10 0 0 1 10 10"})]}):F?(0,n.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("rect",{x:"6",y:"4",width:"4",height:"16"}),(0,n.jsx)("rect",{x:"14",y:"4",width:"4",height:"16"})]}):(0,n.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),(0,n.jsx)("path",{d:"M15.54 8.46a5 5 0 0 1 0 7.07"}),(0,n.jsx)("path",{d:"M19.07 4.93a10 10 0 0 1 0 14.14"})]}),N?"生成中...":F?"播放中":J?"播放":"生成并播放"]}),J&&(0,n.jsx)("button",{onClick:()=>{let e=document.createElement("a");e.href=J;let t=Math.floor(1e5+9e5*Math.random()),r="tts";j?r="voiceclone":m&&(r="voicedesign"),e.download=`mimo-${r}-${t}.mp3`,document.body.appendChild(e),e.click(),document.body.removeChild(e)},title:"下载语音文件 (Download MP3)",style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"3px",width:22,height:22,background:"none",border:"none",borderRadius:5,color:"var(--text-dim)",cursor:"pointer",transition:"color 0.12s"},onMouseEnter:e=>{e.currentTarget.style.color="var(--accent)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-dim)"},children:(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),(0,n.jsx)("polyline",{points:"7 10 12 15 17 10"}),(0,n.jsx)("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]})}),f&&(()=>{let e="",t=f.voiceDesignActiveChips||[];if(m)try{let r=localStorage.getItem("mimo_voice_design_library"),n=(r?JSON.parse(r):[]).find(e=>e.prompt===f.voiceDesignPrompt||!!(Array.isArray(e.chips)&&Array.isArray(t))&&e.chips.length===t.length&&e.chips.every((e,r)=>e===t[r]));n&&(e=n.name)}catch(e){console.error("Failed to lookup matched timbre name:",e)}let r="\uD83C\uDF99️",o="",i="var(--text-dim)",l="var(--bg-panel)",s="1px solid var(--border)";if(m)r="\uD83E\uDDE9",o=t.length>0?t.join(" / "):"自定义声线",i="var(--accent)",l="rgba(59,130,246,0.06)",s="1px solid rgba(59,130,246,0.15)";else if(j)r="\uD83C\uDF99️",o=f.voiceCloneActiveFile?`声线克隆: ${f.voiceCloneActiveFile}`:"未选择克隆声源",i="#10b981",l="rgba(16,185,129,0.06)",s="1px solid rgba(16,185,129,0.15)";else{r="\uD83C\uDF38";let e={mimo_default:"冰糖 (默认)",茉莉:"茉莉 (温柔女)",苏打:"苏打 (活力男)",白桦:"白桦 (稳重男)",Chloe:"Chloe (英音女)",Mia:"Mia (美音女)",Milo:"Milo (美音男)",Dean:"Dean (澳音男)"}[f.presetVoice||"mimo_default"]||f.presetVoice||"冰糖 (默认)";o=`官方声线: ${e}`,i="var(--text-muted)",l="rgba(255,255,255,0.02)",s="1px solid var(--border)"}return(0,n.jsxs)("div",{style:{display:"inline-flex",alignItems:"center",gap:6,marginLeft:6},children:[e&&(0,n.jsx)("span",{style:{display:"inline-flex",alignItems:"center",gap:4,padding:"2px 8px",borderRadius:6,fontSize:10.5,color:"#f59e0b",background:"rgba(245, 158, 11, 0.08)",border:"1px solid rgba(245, 158, 11, 0.2)",height:22,pointerEvents:"none",whiteSpace:"nowrap",opacity:1},title:e,children:(0,n.jsx)("span",{style:{fontWeight:600},children:e})}),(0,n.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:4,padding:"2px 8px",borderRadius:6,fontSize:10.5,color:i,background:l,border:s,height:22,pointerEvents:"none",whiteSpace:"nowrap",opacity:1},title:o,children:[(0,n.jsx)("span",{children:r}),(0,n.jsx)("span",{style:{fontWeight:500},children:o})]})]})})(),F&&(0,n.jsxs)("div",{style:{display:"flex",gap:1.5,alignItems:"flex-end",height:11,marginLeft:2,marginRight:2},children:[(0,n.jsx)("style",{children:`
29
29
  @keyframes ttsJump {
30
30
  0%, 100% { height: 3px; }
31
31
  50% { height: 11px; }
@@ -35,24 +35,24 @@
35
35
  background: var(--accent);
36
36
  border-radius: 1px;
37
37
  }
38
- `}),(0,n.jsx)("span",{className:"tts-wave-bar",style:{height:6,animation:"ttsJump 0.8s ease-in-out infinite"}}),(0,n.jsx)("span",{className:"tts-wave-bar",style:{height:11,animation:"ttsJump 0.8s ease-in-out infinite 0.15s"}}),(0,n.jsx)("span",{className:"tts-wave-bar",style:{height:4,animation:"ttsJump 0.8s ease-in-out infinite 0.3s"}}),(0,n.jsx)("span",{className:"tts-wave-bar",style:{height:8,animation:"ttsJump 0.8s ease-in-out infinite 0.45s"}})]}),P&&(0,n.jsx)("span",{style:{fontSize:10,color:"#ef4444",marginLeft:4},title:P,children:"⚠️ Play error"})]}),h&&!t&&(0,n.jsx)("span",{style:{fontSize:10,color:"var(--text-dim)",marginLeft:"auto"},children:h})]})]})}function ef({block:e,toolResults:t,isStreaming:r,streamingDuration:o,toolCallDurations:i,onZoomImage:l}){return"text"===e.type?(0,n.jsx)(ey,{block:e,onZoomImage:l,isStreaming:r}):("thinking"===e.type||e.type,null)}function ey({block:e,onZoomImage:t,isStreaming:r}){return(0,n.jsx)("div",{className:"markdown-body",children:(0,n.jsx)(H.oz,{remarkPlugins:[_.A],components:{img:({src:e,alt:r})=>(0,n.jsx)("img",{src:e,alt:r,style:{cursor:"zoom-in",maxWidth:"100%",borderRadius:6,border:"1px solid var(--border)"},onClick:()=>{"string"==typeof e&&t?.(e)}}),code({className:e,children:t,...o}){let i=e?.replace("language-","")??"",l=String(t);return e?.includes("language-")||l.includes("\n")?(0,n.jsx)(eb,{code:l.replace(/\n$/,""),lang:i,isStreaming:r}):(0,n.jsx)("code",{style:{background:"var(--bg-selected)",padding:"1px 4px",borderRadius:3,fontFamily:"var(--font-mono)",fontSize:"0.9em"},...o,children:t})},pre:({children:e})=>(0,n.jsx)(n.Fragment,{children:e})},children:e.text})})}function eb({code:e,lang:t,isStreaming:r}){return(0,n.jsx)("pre",{style:{margin:"8px 0",padding:"12px 16px",fontSize:"13px",lineHeight:"1.6",borderRadius:"6px",background:"var(--bg-panel)",border:"1px solid var(--border)",fontFamily:"var(--font-mono)",color:"var(--text)",whiteSpace:"pre-wrap",wordBreak:"break-all"},children:e})}function ev(e,t){let r=e.toLowerCase(),n=t.toLowerCase();return!(n.includes("tts")||n.includes("voiceclone")||n.includes("voicedesign")||n.includes("audio-gen")||n.includes("mimo")&&n.includes("flash"))&&(r.includes("deepseek")||n.includes("deepseek")?!!(n.includes("vl")||n.includes("v4")||n.includes("janus")||n.includes("ocr")):r.includes("openai")?!n.includes("o1-mini")&&!!(n.includes("gpt-4o")||n.includes("gpt-5")||n.includes("gpt-4.5")||n.includes("gpt-4-turbo")||n.includes("vision")||n.includes("multimodal")||"o1"===n||n.startsWith("o1-202")):r.includes("anthropic")?!!(n.includes("claude-3")||n.includes("claude-4")||n.includes("claude-5")||n.includes("claude-sonnet")||n.includes("claude-opus")||n.includes("claude-")&&(n.includes("vision")||n.includes("multimodal"))):r.includes("google")||r.includes("gemini")?!!(n.includes("gemini-")||n.includes("omni")||n.includes("vision")||n.includes("multimodal")):!!(n.includes("vision")||n.includes("multimodal")||n.includes("vlm")||n.includes("vla")||n.includes("gpt-4o")||n.includes("gpt-5")||n.includes("gpt-4.5")||n.includes("claude-3")||n.includes("claude-4")||n.includes("gemini-")||n.includes("pixtral")||n.includes("mimo")||n.includes("-vl")||n.includes("molmo")||n.includes("paligemma")||n.includes("gemma-3")||n.includes("gemma-4")||n.includes("gemma-5")||n.includes("llama")&&(n.includes("11b")||n.includes("90b")||n.includes("vision")||n.includes("multimodal"))||n.includes("qwen")&&n.includes("vl")||n.includes("glm")&&(n.includes("vision")||n.includes("vl")||n.includes("thinking")||/glm-(?:\d+(?:\.\d+)?v|edge-v|omni)/i.test(n))||n.includes("cogvlm")||n.includes("internvl")||n.includes("yi")&&n.includes("vl")||n.includes("step-")&&(n.includes("v")||n.includes("vision"))||n.includes("hunyuan")&&(n.includes("vision")||n.includes("vl"))||n.includes("doubao")&&(n.includes("vision")||n.includes("vl"))||(n.includes("kimi")||n.includes("moonshot"))&&(n.includes("vision")||n.includes("vl")||n.includes("2.6")||n.includes("k2"))||n.includes("abab")&&(n.includes("vision")||n.includes("vl"))||n.includes("minimax")&&(n.includes("vision")||n.includes("vl"))||n.includes("hailuo")))}function em({model:e,attachedFiles:t,voiceConsoleOpen:r,setVoiceConsoleOpen:i,insertAudioTag:l}){var s;let a,d=!!e&&ei(e.provider,e.modelId),[c,p]=(0,o.useState)("mimo_default"),[x,u]=(0,o.useState)(""),[g,h]=(0,o.useState)([]),[f,y]=(0,o.useState)(null),[b,v]=(0,o.useState)(null),[m,j]=(0,o.useState)([]),[k,w]=(0,o.useState)(!1),[S,C]=(0,o.useState)("");if((0,o.useEffect)(()=>{try{let e=localStorage.getItem("mimo_voice_settings");if(e){let t=JSON.parse(e);t.presetVoice&&p(t.presetVoice),t.voiceDesignPrompt&&u(t.voiceDesignPrompt),t.voiceDesignActiveChips&&h(t.voiceDesignActiveChips),t.voiceCloneActiveFile&&y(t.voiceCloneActiveFile),t.voiceCloneAudioData&&v(t.voiceCloneAudioData)}let t=localStorage.getItem("mimo_voice_design_library");if(t)j(JSON.parse(t));else{let e=[{name:"\uD83D\uDC51 金牌客服",prompt:"A sweet young female voice with clear, sweet texture, gentle and patient temperament, speaking standard Mandarin.",chips:["青年女 \uD83D\uDC69","清脆甜美 \uD83C\uDF6C","温柔耐心 \uD83C\uDF38","标准国语"]},{name:"\uD83C\uDF99️ 知性主播",prompt:"A thirty-year-old mature female voice with intellectual, calm, and composed presenter temperament, speaking standard Mandarin.",chips:["青年女 \uD83D\uDC69","富有磁性 \uD83E\uDDF2","知性稳重 \uD83D\uDCDA","标准国语"]},{name:"\uD83D\uDCD6 故事说书人",prompt:"A middle-aged male voice with husky, deep, and magnetic texture, nostalgic and storytelling vibe, speaking standard Mandarin.",chips:["大叔男 \uD83E\uDDD4","深沉低沉 \uD83C\uDF99️","慵懒随性 ☕","标准国语"]}];localStorage.setItem("mimo_voice_design_library",JSON.stringify(e)),j(e)}}catch(e){console.error("Failed to load mimo voice settings:",e)}},[]),(0,o.useEffect)(()=>{try{localStorage.setItem("mimo_voice_settings",JSON.stringify({presetVoice:c,voiceDesignPrompt:x,voiceDesignActiveChips:g,voiceCloneActiveFile:f,voiceCloneAudioData:b})),window.dispatchEvent(new Event("mimo_voice_settings_changed"))}catch(e){console.error("Failed to save mimo voice settings:",e)}},[c,x,g,f,b]),!d)return null;let T=e?.modelId||"",I=(s=e?.provider,!!T&&ei(s,T)&&!el(s,T)&&!es(s,T)),z=es(e?.provider,T),R=el(e?.provider,T);return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{style:{display:"flex",gap:6,marginBottom:6,alignItems:"center",flexWrap:"wrap",background:"rgba(var(--accent-rgb), 0.03)",padding:"6px 10px",borderRadius:8,border:"1px solid var(--border)"},children:[(0,n.jsx)("span",{style:{fontSize:10,color:"var(--text-dim)",fontWeight:600},children:"\uD83D\uDCA8 音频标签助手:"}),[{label:"吸气",tag:"inhale",icon:"\uD83D\uDCA8"},{label:"大笑",tag:"laughter",icon:"\uD83D\uDE02"},{label:"叹气",tag:"sigh",icon:"\uD83D\uDE2E‍\uD83D\uDCA8"},{label:"啜泣",tag:"sob",icon:"\uD83D\uDE22"},{label:"咳嗽",tag:"cough",icon:"\uD83D\uDE37"}].map(e=>(0,n.jsxs)("button",{type:"button",onClick:()=>l(e.tag),style:{padding:"2px 8px",borderRadius:4,fontSize:10,border:"1px solid var(--border)",background:"var(--bg-panel)",color:"var(--text-muted)",cursor:"pointer",display:"inline-flex",alignItems:"center",gap:2,transition:"all 0.12s"},onMouseEnter:e=>{e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color="var(--text)"},onMouseLeave:e=>{e.currentTarget.style.background="var(--bg-panel)",e.currentTarget.style.color="var(--text-muted)"},children:[(0,n.jsx)("span",{children:e.icon}),(0,n.jsx)("span",{children:e.label})]},e.tag)),(0,n.jsx)("span",{style:{fontSize:9,color:"var(--text-dim)",marginLeft:"auto"},children:"点击在光标处插入标签"})]}),r&&(0,n.jsxs)("div",{style:{marginBottom:10,padding:16,background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:12,boxShadow:"0 4px 20px rgba(0,0,0,0.08)",display:"flex",flexDirection:"column",gap:12,transition:"all 0.2s ease-in-out"},children:[(0,n.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",borderBottom:"1px solid var(--border)",paddingBottom:8},children:[(0,n.jsxs)("span",{style:{fontSize:13,fontWeight:600,color:"var(--text)",display:"flex",alignItems:"center",gap:6},children:["\uD83C\uDF99️ AI 声音工坊",(0,n.jsxs)("span",{style:{fontSize:11,fontWeight:400,color:"var(--accent)",background:"rgba(var(--accent-rgb), 0.1)",padding:"1px 6px",borderRadius:4},children:[I&&"标准朗读模式",z&&"自定义声线塑造",R&&"高真声音克隆"]})]}),(0,n.jsx)("button",{type:"button",onClick:()=>i(!1),style:{background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",fontSize:11},children:"收起 ✕"})]}),I&&(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[(0,n.jsx)("span",{style:{fontSize:11,fontWeight:600,color:"var(--text-muted)"},children:"请选择内置高质感官方声线:"}),(0,n.jsx)("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[{name:"冰糖 \uD83C\uDF6C (国语女)",id:"mimo_default"},{name:"茉莉 \uD83C\uDF38 (温柔女)",id:"茉莉"},{name:"苏打 \uD83E\uDD5B (活力男)",id:"苏打"},{name:"白桦 \uD83C\uDF32 (稳重男)",id:"白桦"},{name:"Chloe \uD83C\uDDEC\uD83C\uDDE7 (英音女)",id:"Chloe"},{name:"Mia \uD83C\uDDFA\uD83C\uDDF8 (美音女)",id:"Mia"},{name:"Milo \uD83C\uDDE8\uD83C\uDDE6 (美音男)",id:"Milo"},{name:"Dean \uD83E\uDD98 (澳音男)",id:"Dean"}].map(e=>{let t=c===e.id;return(0,n.jsx)("button",{type:"button",onClick:()=>p(e.id),style:{padding:"4px 10px",borderRadius:6,fontSize:11,border:t?"1px solid var(--accent)":"1px solid var(--border)",background:t?"var(--bg-selected)":"none",color:t?"var(--text)":"var(--text-muted)",cursor:"pointer",fontWeight:t?600:400,transition:"all 0.12s"},onMouseEnter:e=>{t||(e.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:e=>{t||(e.currentTarget.style.background="none")},children:e.name},e.id)})})]}),z&&(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[(0,n.jsxs)("span",{style:{fontSize:11,fontWeight:600,color:"var(--text-muted)",display:"flex",justifyContent:"space-between",alignItems:"center",width:"100%"},children:[(0,n.jsx)("span",{children:"\uD83D\uDC51 我的声线库:"}),k?(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:4},children:[(0,n.jsx)("input",{type:"text",value:S,onChange:e=>C(e.target.value),placeholder:"输入音色名称...",autoFocus:!0,style:{padding:"2px 6px",fontSize:10.5,borderRadius:4,border:"1px solid var(--accent)",background:"var(--bg)",color:"var(--text)",outline:"none",width:120}}),(0,n.jsx)("button",{type:"button",onClick:()=>{if(S.trim()){let e=[...m,{name:S.trim(),prompt:x,chips:g}];j(e),localStorage.setItem("mimo_voice_design_library",JSON.stringify(e)),C(""),w(!1)}},style:{background:"var(--accent)",border:"none",color:"#fff",fontSize:10,padding:"2px 6px",borderRadius:4,cursor:"pointer"},children:"确认"}),(0,n.jsx)("button",{type:"button",onClick:()=>{C(""),w(!1)},style:{background:"none",border:"1px solid var(--border)",color:"var(--text-dim)",fontSize:10,padding:"2px 6px",borderRadius:4,cursor:"pointer"},children:"取消"})]}):(0,n.jsx)("button",{type:"button",onClick:()=>w(!0),disabled:!x,style:{background:"none",border:"none",color:x?"var(--accent)":"var(--text-dim)",fontSize:11,cursor:x?"pointer":"not-allowed",fontWeight:600},children:"+ 保存当前声线组合"})]}),(0,n.jsx)("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:m.map((e,t)=>{let r=x===e.prompt;return(0,n.jsxs)("div",{onClick:()=>{u(e.prompt),h(e.chips)},style:{display:"inline-flex",alignItems:"center",gap:4,padding:"3px 8px",borderRadius:6,fontSize:11,border:r?"1px solid var(--accent)":"1px solid var(--border)",background:r?"var(--bg-selected)":"none",color:r?"var(--text)":"var(--text-muted)",cursor:"pointer",transition:"all 0.12s"},children:[(0,n.jsx)("span",{children:e.name}),t>=3&&(0,n.jsx)("span",{onClick:t=>((e,t)=>{if(t.stopPropagation(),confirm(`确定要删除自定义音色 "${e}" 吗?`)){let t=m.filter(t=>t.name!==e);j(t),localStorage.setItem("mimo_voice_design_library",JSON.stringify(t))}})(e.name,t),style:{color:"var(--text-dim)",marginLeft:4,fontSize:10,cursor:"pointer"},title:"删除此声线",children:"✕"})]},t)})})]}),(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:8,borderTop:"1px dashed var(--border)",paddingTop:10},children:[(0,n.jsx)("span",{style:{fontSize:11,fontWeight:600,color:"var(--text-muted)"},children:"\uD83E\uDDE9 声线塑造魔方(自由勾选实时拼装):"}),[{title:"性别年龄",chips:["青年女 \uD83D\uDC69","青年男 \uD83D\uDC68","大叔男 \uD83E\uDDD4","幼态少女 \uD83D\uDC67","白发老者 \uD83D\uDC74"]},{title:"嗓音特质",chips:["沙哑 \uD83C\uDF42","清脆甜美 \uD83C\uDF6C","富有磁性 \uD83E\uDDF2","深沉低沉 \uD83C\uDF99️","浑厚中气 \uD83D\uDD0A"]},{title:"性格气质",chips:["知性稳重 \uD83D\uDCDA","温柔耐心 \uD83C\uDF38","阳光活泼 ☀️","严肃冷酷 ❄️","慵懒随性 ☕"]},{title:"语言口音",chips:["标准国语","川普口音","粤普口音","东北口音","英普口音"]}].map(e=>(0,n.jsxs)("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[(0,n.jsxs)("span",{style:{fontSize:10,color:"var(--text-dim)",width:55,flexShrink:0},children:[e.title,":"]}),(0,n.jsx)("div",{style:{display:"flex",gap:4,flexWrap:"wrap"},children:e.chips.map(t=>{let r=g.includes(t);return(0,n.jsx)("button",{type:"button",onClick:()=>{let n;if(r)n=g.filter(e=>e!==t);else{let r=e.chips.filter(e=>e!==t);(n=g.filter(e=>!r.includes(e))).push(t)}h(n),u((e=>{if(0===e.length)return"";let t={"青年女 \uD83D\uDC69":"young female voice","青年男 \uD83D\uDC68":"young male voice","大叔男 \uD83E\uDDD4":"mature middle-aged male voice","幼态少女 \uD83D\uDC67":"lively young girl voice","白发老者 \uD83D\uDC74":"elderly grandfather male voice","沙哑 \uD83C\uDF42":"husky and raspy vocal texture","清脆甜美 \uD83C\uDF6C":"crisp and sweet vocal texture","富有磁性 \uD83E\uDDF2":"magnetic and charming voice","深沉低沉 \uD83C\uDF99️":"deep and low-pitched vocal texture","浑厚中气 \uD83D\uDD0A":"full-bodied and resonant voice","知性稳重 \uD83D\uDCDA":"intellectual, calm, and composed presenter temperament","温柔耐心 \uD83C\uDF38":"gentle, soft, and extremely patient temperament","阳光活泼 ☀️":"bright, energetic, and highly enthusiastic temperament","严肃冷酷 ❄️":"stern, cold, and serious tone","慵懒随性 ☕":"lazy, relaxed, and casual conversational tone",标准国语:"speaking standard Mandarin",川普口音:"speaking standard Mandarin with a charming Sichuan dialect accent",粤普口音:"speaking standard Mandarin with a subtle Cantonese dialect accent",东北口音:"speaking standard Mandarin with a noticeable Northeast dialect accent",英普口音:"speaking standard Mandarin with a slight English accent"},r=e.map(e=>t[e]||e);return`A beautiful ${r.join(", ")}.`})(n))},style:{padding:"2px 8px",borderRadius:4,fontSize:10,border:r?"1px solid var(--accent)":"1px solid var(--border)",background:r?"var(--bg-selected)":"none",color:r?"var(--text)":"var(--text-muted)",cursor:"pointer",transition:"all 0.12s"},children:t},t)})})]},e.title))]}),(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6,borderTop:"1px dashed var(--border)",paddingTop:10},children:[(0,n.jsx)("span",{style:{fontSize:11,fontWeight:600,color:"var(--text-muted)"},children:"\uD83D\uDCDD 生成的声线描述 (Timbre Prompt):"}),(0,n.jsx)("textarea",{value:x,onChange:e=>u(e.target.value),rows:2,placeholder:"点击上方魔方自动组装声线,或在此手动撰写...",style:{width:"100%",padding:8,fontSize:11,borderRadius:6,border:"1px solid var(--border)",background:"var(--bg)",color:"var(--text)",fontFamily:"var(--font-mono)",resize:"none"}})]})]}),R&&(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[(0,n.jsx)("span",{style:{fontSize:11,fontWeight:600,color:"var(--text-muted)"},children:"\uD83D\uDD0A 声线克隆提取器 (Voice Clone Source):"}),0===(a=t.filter(e=>e.name.endsWith(".wav")||e.name.endsWith(".webm")||e.name.endsWith(".mp3")||e.name.endsWith(".m4a"))).length?(0,n.jsx)("div",{style:{padding:"16px 12px",border:"1px dashed var(--border)",borderRadius:8,fontSize:11,color:"var(--text-muted)",textAlign:"center",lineHeight:"1.6"},children:"\uD83D\uDCA1 请先在左下角点击麦克风 \uD83C\uDFA4 录制您的声音,或点击别针 \uD83D\uDCCE 上传一段录音(WAV/MP3),然后在此选中它以提取克隆声线!"}):(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[(0,n.jsx)("span",{style:{fontSize:10,color:"var(--text-dim)"},children:"检测到已上传的音频附件,点击指定为当前克隆声源:"}),(0,n.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:a.map((e,t)=>{let r=f===e.name;return(0,n.jsxs)("div",{onClick:()=>{var t,r;let n;return t=e.file,r=e.name,void((n=new FileReader).onload=e=>{if(e.target?.result&&"string"==typeof e.target.result){let t=e.target.result;t.startsWith("data:audio/webm;")&&(t=t.replace("data:audio/webm;","data:audio/wav;")),v(t),y(r)}},n.readAsDataURL(t))},style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"6px 12px",borderRadius:6,border:r?"1px solid #10b981":"1px solid var(--border)",background:r?"rgba(16,185,129,0.06)":"none",cursor:"pointer",transition:"all 0.15s"},children:[(0,n.jsx)("span",{style:{fontSize:11,color:"var(--text)",fontWeight:r?600:400},children:e.name}),(0,n.jsx)("span",{style:{fontSize:10,color:r?"#10b981":"var(--text-muted)"},children:r?"✓ 已选定为克隆声源":"点击提取"})]},t)})})]})]})]})]})}let ej=["off","default","full"],ek={off:"none",default:"default",full:"full"},ew=["auto","off","minimal","low","medium","high","xhigh"],eS={auto:"沿用 pi 默认设置",off:"关闭推理",minimal:"最少推理",low:"低强度推理",medium:"中等推理",high:"高强度推理",xhigh:"最高强度推理"},eC=(0,o.forwardRef)(function({onSend:e,onAbort:t,onSteer:r,onFollowUp:i,isStreaming:l,model:s,modelNames:a,modelList:d,onModelChange:c,onCompact:p,onAbortCompaction:x,isCompacting:u,compactError:g,toolPreset:h,onToolPresetChange:f,thinkingLevel:y,onThinkingLevelChange:b,availableThinkingLevels:v,thinkingLevelMap:m,retryInfo:j,soundEnabled:k,onSoundToggle:w,cwd:S},C){let T,I,z,R,L,W,E,M,D,[B,A]=(0,o.useState)(""),[O,N]=(0,o.useState)(!1),[P,H]=(0,o.useState)(null),[_,J]=(0,o.useState)(!1),[U,V]=(0,o.useState)(!1),[Y,K]=(0,o.useState)([]),[q,G]=(0,o.useState)([]),[Z,X]=(0,o.useState)(!1),[Q,ee]=(0,o.useState)({}),[et,er]=(0,o.useState)(null),[en,eo]=(0,o.useState)(!1),[es,ea]=(0,o.useState)(""),[ed,ec]=(0,o.useState)(!1),[ep,ex]=(0,o.useState)("text"),eu=!!s&&ei(s.provider,s.modelId),[eg,eh]=(0,o.useState)(!1),[ef,ey]=(0,o.useState)(!1),[eb,eC]=(0,o.useState)(0),eT=(0,o.useRef)(null),eI=(0,o.useRef)([]),ez=(0,o.useRef)(null);(0,o.useEffect)(()=>()=>{ez.current&&clearInterval(ez.current)},[]);let eR=async()=>{if(!navigator.mediaDevices)return void er("您的浏览器不支持麦克风录音设备。");try{let e,t=await navigator.mediaDevices.getUserMedia({audio:!0});eI.current=[];try{e=new MediaRecorder(t,{mimeType:"audio/webm"})}catch(r){e=new MediaRecorder(t)}eT.current=e,e.ondataavailable=e=>{e.data.size>0&&eI.current.push(e.data)},e.onstop=()=>{let r=new Blob(eI.current,{type:e.mimeType||"audio/webm"}),n=e.mimeType?.includes("webm")?"webm":"wav",o=new File([r],`voice_record_${Date.now()}.${n}`,{type:r.type});eP([o]),t.getTracks().forEach(e=>e.stop())},e.start(),ey(!0),eC(0),ez.current=setInterval(()=>{eC(e=>e+1)},1e3)}catch(e){console.error("Failed to start recording:",e),er("麦克风启动失败,请检查浏览器是否已授权麦克风权限!")}},eL=()=>{eT.current&&"inactive"!==eT.current.state&&eT.current.stop(),ey(!1),ez.current&&(clearInterval(ez.current),ez.current=null)},eW=(0,o.useRef)(null),eE=(0,o.useRef)(null),eM=(0,o.useRef)(null),eD=(0,o.useRef)(null),e$=(0,o.useRef)(null),eB=(0,o.useRef)(null),eA=(0,o.useRef)(null);(0,o.useImperativeHandle)(C,()=>({insertIfEmpty(e){let t=eW.current;(t?t.value:B).trim()||(A(e),requestAnimationFrame(()=>{t&&(t.focus(),t.style.height="auto",t.style.height=`${Math.min(t.scrollHeight,200)}px`)}))},insertText(e){let t=eW.current;if(!t)return void A(t=>t+(t?" ":"")+e);let r=t.selectionStart??t.value.length,n=t.selectionEnd??t.value.length,o=t.value.slice(0,r),i=t.value.slice(n),l=o.length>0&&!o.endsWith(" ")?" ":"";A(o+l+e+i),requestAnimationFrame(()=>{if(!t)return;let n=r+l.length+e.length;t.setSelectionRange(n,n),t.focus(),t.style.height="auto",t.style.height=`${Math.min(t.scrollHeight,200)}px`})},addImages(e){eF(e)},addFiles(e){eP(e)}}));let eF=(0,o.useCallback)(async e=>{let t=e.filter(e=>e.type.startsWith("image/"));if(t.length)try{let e=await Promise.all(t.map(async e=>{let t=await function(e,t=1024,r=1024,n=.8){return new Promise((o,i)=>{let l=new FileReader;l.onload=e=>{let l=new Image;l.onload=()=>{let e=l.width,s=l.height;e>s?e>t&&(s=Math.round(s*t/e),e=t):s>r&&(e=Math.round(e*r/s),s=r);let a=document.createElement("canvas");a.width=e,a.height=s;let d=a.getContext("2d");if(!d)return void i(Error("Failed to get canvas 2D context"));d.fillStyle="#ffffff",d.fillRect(0,0,e,s),d.drawImage(l,0,0,e,s);let c=a.toDataURL("image/jpeg",n),p=c.indexOf(",");o({data:-1!==p?c.substring(p+1):c,mimeType:"image/jpeg"})},l.onerror=e=>i(e),l.src=e.target?.result},l.onerror=e=>i(e),l.readAsDataURL(e)})}(e);return{data:t.data,mimeType:t.mimeType,previewUrl:URL.createObjectURL(e)}}));K(t=>[...t,...e])}catch(e){console.error("Failed to process and compress image files:",e)}},[]),eO=(0,o.useCallback)(e=>{K(t=>{let r=[...t];return URL.revokeObjectURL(r[e].previewUrl),r.splice(e,1),r})},[]),eN=(0,o.useCallback)(()=>{K(e=>(e.forEach(e=>URL.revokeObjectURL(e.previewUrl)),[]))},[]),eP=(0,o.useCallback)(e=>{let t=e.map(e=>({file:e,name:e.name,size:e.size}));G(e=>[...e,...t])},[]),eH=(0,o.useCallback)(e=>{G(t=>{let r=[...t];return r.splice(e,1),r})},[]),e_=(0,o.useCallback)(e=>{if(0===e)return"0 Bytes";let t=Math.floor(Math.log(e)/Math.log(1024));return parseFloat((e/Math.pow(1024,t)).toFixed(2))+" "+["Bytes","KB","MB","GB"][t]},[]),eJ=(0,o.useCallback)(async e=>{let t=Y[e];if(!t)return;let r=d?.find(e=>e.id===s?.modelId&&e.provider===s?.provider);if(!(r&&r.supportsVision||s&&ev(s.provider,s.modelId)))return void er("该模型不是视觉模型,不支持识图功能。");ee(t=>({...t,[e]:!0})),er(null);try{let e=await fetch("/api/agent/describe-image",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({image:t.data,mimeType:t.mimeType,provider:s.provider,modelId:s.modelId})}),r=await e.json();if(!e.ok)throw Error(r.error||"Failed to describe image");ea(r.description),eo(!0),ec(!1),ex("text")}catch(t){console.error(t);let e=t.message||String(t);(e.includes("No endpoints found that support image input")||e.includes("support image input")||e.includes("not support image")||e.includes("404")&&(e.toLowerCase().includes("image")||e.toLowerCase().includes("endpoint")))&&(e="该模型不是视觉模型,不支持识图功能。"),er(e)}finally{ee(t=>({...t,[e]:!1}))}},[Y,s,d]),eU=(0,o.useCallback)(async()=>{let t=B.trim();if(!t&&!Y.length&&!q.length||l||Z)return;if(Y.length>0){let e=d?.find(e=>e.id===s?.modelId&&e.provider===s?.provider);if(!(e&&e.supportsVision||s&&ev(s.provider,s.modelId)))return void er("该模型不是视觉模型,不支持识图功能。")}let r=t;if(q.length>0){if(!S)return void er("无法获取当前工作区路径,文件上传失败。");X(!0),er(null);try{let e=await Promise.all(q.map(async e=>{let t=F(F(S,"Temp"),e.name),r=$(t),n=await fetch(`/api/files/${r}`,{method:"POST",body:e.file});if(!n.ok){let t=await n.json().catch(()=>({}));throw Error(t.error||`上传文件 ${e.name} 失败`)}return e})),t="\n\n\x3c!-- PI_FILE_ATTACHMENTS_START --\x3e\n\uD83D\uDCC4 [已上传文件到工作区]\n"+e.map(e=>`- Temp/${e.name} (${e_(e.size)})`).join("\n")+"\n\x3c!-- PI_FILE_ATTACHMENTS_END --\x3e";r=r?`${r}${t}`:t.trim(),G([])}catch(e){console.error("Upload error:",e),er(e.message||"上传文件过程中出现未知错误"),X(!1);return}X(!1)}e(r,Y.length?Y:void 0),A(""),eN(),eW.current&&(eW.current.style.height="auto")},[B,Y,q,l,Z,e,eN,s,d,S,e_]),eV=(0,o.useCallback)(async e=>{let t=B.trim();if(!t&&!Y.length&&!q.length||Z)return;if(Y.length>0){let e=d?.find(e=>e.id===s?.modelId&&e.provider===s?.provider);if(!(e&&e.supportsVision||s&&ev(s.provider,s.modelId)))return void er("该模型不是视觉模型,不支持识图功能。")}let n=t;if(q.length>0){if(!S)return void er("无法获取当前工作区路径,文件上传失败。");X(!0),er(null);try{let e=await Promise.all(q.map(async e=>{let t=F(F(S,"Temp"),e.name),r=$(t),n=await fetch(`/api/files/${r}`,{method:"POST",body:e.file});if(!n.ok){let t=await n.json().catch(()=>({}));throw Error(t.error||`上传文件 ${e.name} 失败`)}return e})),t="\n\n\x3c!-- PI_FILE_ATTACHMENTS_START --\x3e\n\uD83D\uDCC4 [已上传文件到工作区]\n"+e.map(e=>`- Temp/${e.name} (${e_(e.size)})`).join("\n")+"\n\x3c!-- PI_FILE_ATTACHMENTS_END --\x3e";n=n?`${n}${t}`:t.trim(),G([])}catch(e){console.error("Upload error:",e),er(e.message||"上传文件过程中出现未知错误"),X(!1);return}X(!1)}"steer"===e&&r?r(n,Y.length?Y:void 0):"followup"===e&&i&&i(n,Y.length?Y:void 0),A(""),eN(),eW.current&&(eW.current.style.height="auto")},[B,Y,q,r,i,eN,s,d,S,Z,e_]),eY=(0,o.useCallback)(e=>{"Enter"!==e.key||e.shiftKey||e.nativeEvent.isComposing||(e.preventDefault(),l&&(r||i)?eV(r?"steer":"followup"):eU())},[l,r,i,eV,eU]),eK=(0,o.useCallback)(()=>{let e=eW.current;e&&(e.style.height="auto",e.style.height=`${Math.min(e.scrollHeight,200)}px`)},[]),eq=(0,o.useCallback)(e=>{let t=Array.from(e.clipboardData?.items??[]).filter(e=>e.type.startsWith("image/"));t.length&&(e.preventDefault(),eF(t.map(e=>e.getAsFile()).filter(e=>null!==e)))},[eF]),eG=d&&d.length>0?d.map(e=>({provider:e.provider,modelId:e.id,name:e.name})):Object.entries(a??{}).map(([e,t])=>({provider:s?.provider??"unknown",modelId:e,name:t})),eZ=[];for(let e of eG){let t=eZ.find(t=>t.provider===e.provider);t?t.options.push(e):eZ.push({provider:e.provider,options:[e]})}let eX=s?eG.find(e=>e.modelId===s.modelId&&e.provider===s.provider)?.name??s.modelId:eG.length>0?eG[0].name:null;return(0,o.useEffect)(()=>{let e=e=>{eE.current&&!eE.current.contains(e.target)&&eM.current&&!eM.current.contains(e.target)&&N(!1),eD.current&&!eD.current.contains(e.target)&&J(!1),e$.current&&!e$.current.contains(e.target)&&V(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]),(0,n.jsxs)("div",{style:{flexShrink:0,background:"transparent",padding:"0 16px 8px",paddingRight:34},children:[(0,n.jsx)("input",{ref:eB,type:"file",accept:"image/*",multiple:!0,style:{display:"none"},onChange:e=>{eF(Array.from(e.target.files??[])),e.target.value=""}}),(0,n.jsx)("input",{ref:eA,type:"file",multiple:!0,style:{display:"none"},onChange:e=>{eP(Array.from(e.target.files??[])),e.target.value=""}}),(0,n.jsxs)("div",{style:{maxWidth:820,margin:"0 auto"},children:[j&&(0,n.jsxs)("div",{style:{marginBottom:8,padding:"5px 10px",background:"rgba(234,179,8,0.08)",border:"1px solid rgba(234,179,8,0.25)",borderRadius:6,fontSize:12,color:"rgba(180,130,0,0.9)",display:"flex",alignItems:"center",gap:6},children:[(0,n.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[(0,n.jsx)("path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}),(0,n.jsx)("path",{d:"M3 3v5h5"})]}),"Retrying (",j.attempt,"/",j.maxAttempts,")…",j.errorMessage&&(0,n.jsxs)("span",{style:{opacity:.7,marginLeft:4},children:["— ",j.errorMessage]})]}),et&&(0,n.jsxs)("div",{style:{marginBottom:8,padding:"8px 12px",background:"rgba(239,68,68,0.08)",border:"1px solid rgba(239,68,68,0.25)",borderRadius:8,fontSize:12,color:"rgba(220,38,38,0.9)",display:"flex",alignItems:"center",gap:6,position:"relative"},children:[(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,n.jsx)("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),(0,n.jsx)("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),(0,n.jsx)("span",{style:{flex:1},children:et}),(0,n.jsx)("button",{onClick:()=>er(null),style:{background:"none",border:"none",color:"rgba(220,38,38,0.6)",cursor:"pointer",display:"flex",alignItems:"center",padding:2},children:(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,n.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),Y.length>0&&(0,n.jsxs)("div",{style:{display:"flex",gap:6,marginBottom:6,flexWrap:"wrap"},children:[(0,n.jsx)("style",{children:`
38
+ `}),(0,n.jsx)("span",{className:"tts-wave-bar",style:{height:6,animation:"ttsJump 0.8s ease-in-out infinite"}}),(0,n.jsx)("span",{className:"tts-wave-bar",style:{height:11,animation:"ttsJump 0.8s ease-in-out infinite 0.15s"}}),(0,n.jsx)("span",{className:"tts-wave-bar",style:{height:4,animation:"ttsJump 0.8s ease-in-out infinite 0.3s"}}),(0,n.jsx)("span",{className:"tts-wave-bar",style:{height:8,animation:"ttsJump 0.8s ease-in-out infinite 0.45s"}})]}),P&&(0,n.jsx)("span",{style:{fontSize:10,color:"#ef4444",marginLeft:4},title:P,children:"⚠️ Play error"})]}),h&&!t&&(0,n.jsx)("span",{style:{fontSize:10,color:"var(--text-dim)",marginLeft:"auto"},children:h})]})]})}function ef({block:e,toolResults:t,isStreaming:r,streamingDuration:o,toolCallDurations:i,onZoomImage:l}){return"text"===e.type?(0,n.jsx)(eb,{block:e,onZoomImage:l,isStreaming:r}):("thinking"===e.type||e.type,null)}function eb({block:e,onZoomImage:t,isStreaming:r}){return(0,n.jsx)("div",{className:"markdown-body",children:(0,n.jsx)(H.oz,{remarkPlugins:[_.A],components:{img:({src:e,alt:r})=>(0,n.jsx)("img",{src:e,alt:r,style:{cursor:"zoom-in",maxWidth:"100%",borderRadius:6,border:"1px solid var(--border)"},onClick:()=>{"string"==typeof e&&t?.(e)}}),code({className:e,children:t,...o}){let i=e?.replace("language-","")??"",l=String(t);return e?.includes("language-")||l.includes("\n")?(0,n.jsx)(ey,{code:l.replace(/\n$/,""),lang:i,isStreaming:r}):(0,n.jsx)("code",{style:{background:"var(--bg-selected)",padding:"1px 4px",borderRadius:3,fontFamily:"var(--font-mono)",fontSize:"0.9em"},...o,children:t})},pre:({children:e})=>(0,n.jsx)(n.Fragment,{children:e})},children:e.text})})}function ey({code:e,lang:t,isStreaming:r}){return(0,n.jsx)("pre",{style:{margin:"8px 0",padding:"12px 16px",fontSize:"13px",lineHeight:"1.6",borderRadius:"6px",background:"var(--bg-panel)",border:"1px solid var(--border)",fontFamily:"var(--font-mono)",color:"var(--text)",whiteSpace:"pre-wrap",wordBreak:"break-all"},children:e})}function ev(e,t){let r=e.toLowerCase(),n=t.toLowerCase();return!(n.includes("tts")||n.includes("voiceclone")||n.includes("voicedesign")||n.includes("audio-gen")||n.includes("mimo")&&n.includes("flash"))&&(r.includes("deepseek")||n.includes("deepseek")?!!(n.includes("vl")||n.includes("v4")||n.includes("janus")||n.includes("ocr")):r.includes("openai")?!n.includes("o1-mini")&&!!(n.includes("gpt-4o")||n.includes("gpt-5")||n.includes("gpt-4.5")||n.includes("gpt-4-turbo")||n.includes("vision")||n.includes("multimodal")||"o1"===n||n.startsWith("o1-202")):r.includes("anthropic")?!!(n.includes("claude-3")||n.includes("claude-4")||n.includes("claude-5")||n.includes("claude-sonnet")||n.includes("claude-opus")||n.includes("claude-")&&(n.includes("vision")||n.includes("multimodal"))):r.includes("google")||r.includes("gemini")?!!(n.includes("gemini-")||n.includes("omni")||n.includes("vision")||n.includes("multimodal")):!!(n.includes("vision")||n.includes("multimodal")||n.includes("vlm")||n.includes("vla")||n.includes("gpt-4o")||n.includes("gpt-5")||n.includes("gpt-4.5")||n.includes("claude-3")||n.includes("claude-4")||n.includes("gemini-")||n.includes("pixtral")||n.includes("mimo")||n.includes("-vl")||n.includes("molmo")||n.includes("paligemma")||n.includes("gemma-3")||n.includes("gemma-4")||n.includes("gemma-5")||n.includes("llama")&&(n.includes("11b")||n.includes("90b")||n.includes("vision")||n.includes("multimodal"))||n.includes("qwen")&&n.includes("vl")||n.includes("glm")&&(n.includes("vision")||n.includes("vl")||n.includes("thinking")||/glm-(?:\d+(?:\.\d+)?v|edge-v|omni)/i.test(n))||n.includes("cogvlm")||n.includes("internvl")||n.includes("yi")&&n.includes("vl")||n.includes("step-")&&(n.includes("v")||n.includes("vision"))||n.includes("hunyuan")&&(n.includes("vision")||n.includes("vl"))||n.includes("doubao")&&(n.includes("vision")||n.includes("vl"))||(n.includes("kimi")||n.includes("moonshot"))&&(n.includes("vision")||n.includes("vl")||n.includes("2.6")||n.includes("k2"))||n.includes("abab")&&(n.includes("vision")||n.includes("vl"))||n.includes("minimax")&&(n.includes("vision")||n.includes("vl"))||n.includes("hailuo")))}function em({model:e,attachedFiles:t,voiceConsoleOpen:r,setVoiceConsoleOpen:i,insertAudioTag:l}){var s;let a,d=!!e&&ei(e.provider,e.modelId),[c,p]=(0,o.useState)("mimo_default"),[x,u]=(0,o.useState)(""),[g,h]=(0,o.useState)([]),[f,b]=(0,o.useState)(null),[y,v]=(0,o.useState)(null),[m,j]=(0,o.useState)([]),[k,w]=(0,o.useState)(!1),[S,C]=(0,o.useState)("");if((0,o.useEffect)(()=>{try{let e=localStorage.getItem("mimo_voice_settings");if(e){let t=JSON.parse(e);t.presetVoice&&p(t.presetVoice),t.voiceDesignPrompt&&u(t.voiceDesignPrompt),t.voiceDesignActiveChips&&h(t.voiceDesignActiveChips),t.voiceCloneActiveFile&&b(t.voiceCloneActiveFile),t.voiceCloneAudioData&&v(t.voiceCloneAudioData)}let t=localStorage.getItem("mimo_voice_design_library");if(t)j(JSON.parse(t));else{let e=[{name:"\uD83D\uDC51 金牌客服",prompt:"A sweet young female voice with clear, sweet texture, gentle and patient temperament, speaking standard Mandarin.",chips:["青年女 \uD83D\uDC69","清脆甜美 \uD83C\uDF6C","温柔耐心 \uD83C\uDF38","标准国语"]},{name:"\uD83C\uDF99️ 知性主播",prompt:"A thirty-year-old mature female voice with intellectual, calm, and composed presenter temperament, speaking standard Mandarin.",chips:["青年女 \uD83D\uDC69","富有磁性 \uD83E\uDDF2","知性稳重 \uD83D\uDCDA","标准国语"]},{name:"\uD83D\uDCD6 故事说书人",prompt:"A middle-aged male voice with husky, deep, and magnetic texture, nostalgic and storytelling vibe, speaking standard Mandarin.",chips:["大叔男 \uD83E\uDDD4","深沉低沉 \uD83C\uDF99️","慵懒随性 ☕","标准国语"]}];localStorage.setItem("mimo_voice_design_library",JSON.stringify(e)),j(e)}}catch(e){console.error("Failed to load mimo voice settings:",e)}},[]),(0,o.useEffect)(()=>{try{localStorage.setItem("mimo_voice_settings",JSON.stringify({presetVoice:c,voiceDesignPrompt:x,voiceDesignActiveChips:g,voiceCloneActiveFile:f,voiceCloneAudioData:y})),window.dispatchEvent(new Event("mimo_voice_settings_changed"))}catch(e){console.error("Failed to save mimo voice settings:",e)}},[c,x,g,f,y]),!d)return null;let T=e?.modelId||"",z=(s=e?.provider,!!T&&ei(s,T)&&!el(s,T)&&!es(s,T)),I=es(e?.provider,T),R=el(e?.provider,T);return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{style:{display:"flex",gap:6,marginBottom:6,alignItems:"center",flexWrap:"wrap",background:"rgba(var(--accent-rgb), 0.03)",padding:"6px 10px",borderRadius:8,border:"1px solid var(--border)"},children:[(0,n.jsx)("span",{style:{fontSize:10,color:"var(--text-dim)",fontWeight:600},children:"\uD83D\uDCA8 音频标签助手:"}),[{label:"吸气",tag:"inhale",icon:"\uD83D\uDCA8"},{label:"大笑",tag:"laughter",icon:"\uD83D\uDE02"},{label:"叹气",tag:"sigh",icon:"\uD83D\uDE2E‍\uD83D\uDCA8"},{label:"啜泣",tag:"sob",icon:"\uD83D\uDE22"},{label:"咳嗽",tag:"cough",icon:"\uD83D\uDE37"}].map(e=>(0,n.jsxs)("button",{type:"button",onClick:()=>l(e.tag),style:{padding:"2px 8px",borderRadius:4,fontSize:10,border:"1px solid var(--border)",background:"var(--bg-panel)",color:"var(--text-muted)",cursor:"pointer",display:"inline-flex",alignItems:"center",gap:2,transition:"all 0.12s"},onMouseEnter:e=>{e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color="var(--text)"},onMouseLeave:e=>{e.currentTarget.style.background="var(--bg-panel)",e.currentTarget.style.color="var(--text-muted)"},children:[(0,n.jsx)("span",{children:e.icon}),(0,n.jsx)("span",{children:e.label})]},e.tag)),(0,n.jsx)("span",{style:{fontSize:9,color:"var(--text-dim)",marginLeft:"auto"},children:"点击在光标处插入标签"})]}),r&&(0,n.jsxs)("div",{style:{marginBottom:10,padding:16,background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:12,boxShadow:"0 4px 20px rgba(0,0,0,0.08)",display:"flex",flexDirection:"column",gap:12,transition:"all 0.2s ease-in-out"},children:[(0,n.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",borderBottom:"1px solid var(--border)",paddingBottom:8},children:[(0,n.jsxs)("span",{style:{fontSize:13,fontWeight:600,color:"var(--text)",display:"flex",alignItems:"center",gap:6},children:["\uD83C\uDF99️ AI 声音工坊",(0,n.jsxs)("span",{style:{fontSize:11,fontWeight:400,color:"var(--accent)",background:"rgba(var(--accent-rgb), 0.1)",padding:"1px 6px",borderRadius:4},children:[z&&"标准朗读模式",I&&"自定义声线塑造",R&&"高真声音克隆"]})]}),(0,n.jsx)("button",{type:"button",onClick:()=>i(!1),style:{background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",fontSize:11},children:"收起 ✕"})]}),z&&(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[(0,n.jsx)("span",{style:{fontSize:11,fontWeight:600,color:"var(--text-muted)"},children:"请选择内置高质感官方声线:"}),(0,n.jsx)("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[{name:"冰糖 \uD83C\uDF6C (国语女)",id:"mimo_default"},{name:"茉莉 \uD83C\uDF38 (温柔女)",id:"茉莉"},{name:"苏打 \uD83E\uDD5B (活力男)",id:"苏打"},{name:"白桦 \uD83C\uDF32 (稳重男)",id:"白桦"},{name:"Chloe \uD83C\uDDEC\uD83C\uDDE7 (英音女)",id:"Chloe"},{name:"Mia \uD83C\uDDFA\uD83C\uDDF8 (美音女)",id:"Mia"},{name:"Milo \uD83C\uDDE8\uD83C\uDDE6 (美音男)",id:"Milo"},{name:"Dean \uD83E\uDD98 (澳音男)",id:"Dean"}].map(e=>{let t=c===e.id;return(0,n.jsx)("button",{type:"button",onClick:()=>p(e.id),style:{padding:"4px 10px",borderRadius:6,fontSize:11,border:t?"1px solid var(--accent)":"1px solid var(--border)",background:t?"var(--bg-selected)":"none",color:t?"var(--text)":"var(--text-muted)",cursor:"pointer",fontWeight:t?600:400,transition:"all 0.12s"},onMouseEnter:e=>{t||(e.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:e=>{t||(e.currentTarget.style.background="none")},children:e.name},e.id)})})]}),I&&(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[(0,n.jsxs)("span",{style:{fontSize:11,fontWeight:600,color:"var(--text-muted)",display:"flex",justifyContent:"space-between",alignItems:"center",width:"100%"},children:[(0,n.jsx)("span",{children:"\uD83D\uDC51 我的声线库:"}),k?(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:4},children:[(0,n.jsx)("input",{type:"text",value:S,onChange:e=>C(e.target.value),placeholder:"输入音色名称...",autoFocus:!0,style:{padding:"2px 6px",fontSize:10.5,borderRadius:4,border:"1px solid var(--accent)",background:"var(--bg)",color:"var(--text)",outline:"none",width:120}}),(0,n.jsx)("button",{type:"button",onClick:()=>{if(S.trim()){let e=[...m,{name:S.trim(),prompt:x,chips:g}];j(e),localStorage.setItem("mimo_voice_design_library",JSON.stringify(e)),C(""),w(!1)}},style:{background:"var(--accent)",border:"none",color:"#fff",fontSize:10,padding:"2px 6px",borderRadius:4,cursor:"pointer"},children:"确认"}),(0,n.jsx)("button",{type:"button",onClick:()=>{C(""),w(!1)},style:{background:"none",border:"1px solid var(--border)",color:"var(--text-dim)",fontSize:10,padding:"2px 6px",borderRadius:4,cursor:"pointer"},children:"取消"})]}):(0,n.jsx)("button",{type:"button",onClick:()=>w(!0),disabled:!x,style:{background:"none",border:"none",color:x?"var(--accent)":"var(--text-dim)",fontSize:11,cursor:x?"pointer":"not-allowed",fontWeight:600},children:"+ 保存当前声线组合"})]}),(0,n.jsx)("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:m.map((e,t)=>{let r=x===e.prompt;return(0,n.jsxs)("div",{onClick:()=>{u(e.prompt),h(e.chips)},style:{display:"inline-flex",alignItems:"center",gap:4,padding:"3px 8px",borderRadius:6,fontSize:11,border:r?"1px solid var(--accent)":"1px solid var(--border)",background:r?"var(--bg-selected)":"none",color:r?"var(--text)":"var(--text-muted)",cursor:"pointer",transition:"all 0.12s"},children:[(0,n.jsx)("span",{children:e.name}),t>=3&&(0,n.jsx)("span",{onClick:t=>((e,t)=>{if(t.stopPropagation(),confirm(`确定要删除自定义音色 "${e}" 吗?`)){let t=m.filter(t=>t.name!==e);j(t),localStorage.setItem("mimo_voice_design_library",JSON.stringify(t))}})(e.name,t),style:{color:"var(--text-dim)",marginLeft:4,fontSize:10,cursor:"pointer"},title:"删除此声线",children:"✕"})]},t)})})]}),(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:8,borderTop:"1px dashed var(--border)",paddingTop:10},children:[(0,n.jsx)("span",{style:{fontSize:11,fontWeight:600,color:"var(--text-muted)"},children:"\uD83E\uDDE9 声线塑造魔方(自由勾选实时拼装):"}),[{title:"性别年龄",chips:["青年女 \uD83D\uDC69","青年男 \uD83D\uDC68","大叔男 \uD83E\uDDD4","幼态少女 \uD83D\uDC67","白发老者 \uD83D\uDC74"]},{title:"嗓音特质",chips:["沙哑 \uD83C\uDF42","清脆甜美 \uD83C\uDF6C","富有磁性 \uD83E\uDDF2","深沉低沉 \uD83C\uDF99️","浑厚中气 \uD83D\uDD0A"]},{title:"性格气质",chips:["知性稳重 \uD83D\uDCDA","温柔耐心 \uD83C\uDF38","阳光活泼 ☀️","严肃冷酷 ❄️","慵懒随性 ☕"]},{title:"语言口音",chips:["标准国语","川普口音","粤普口音","东北口音","英普口音"]}].map(e=>(0,n.jsxs)("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[(0,n.jsxs)("span",{style:{fontSize:10,color:"var(--text-dim)",width:55,flexShrink:0},children:[e.title,":"]}),(0,n.jsx)("div",{style:{display:"flex",gap:4,flexWrap:"wrap"},children:e.chips.map(t=>{let r=g.includes(t);return(0,n.jsx)("button",{type:"button",onClick:()=>{let n;if(r)n=g.filter(e=>e!==t);else{let r=e.chips.filter(e=>e!==t);(n=g.filter(e=>!r.includes(e))).push(t)}h(n),u((e=>{if(0===e.length)return"";let t={"青年女 \uD83D\uDC69":"young female voice","青年男 \uD83D\uDC68":"young male voice","大叔男 \uD83E\uDDD4":"mature middle-aged male voice","幼态少女 \uD83D\uDC67":"lively young girl voice","白发老者 \uD83D\uDC74":"elderly grandfather male voice","沙哑 \uD83C\uDF42":"husky and raspy vocal texture","清脆甜美 \uD83C\uDF6C":"crisp and sweet vocal texture","富有磁性 \uD83E\uDDF2":"magnetic and charming voice","深沉低沉 \uD83C\uDF99️":"deep and low-pitched vocal texture","浑厚中气 \uD83D\uDD0A":"full-bodied and resonant voice","知性稳重 \uD83D\uDCDA":"intellectual, calm, and composed presenter temperament","温柔耐心 \uD83C\uDF38":"gentle, soft, and extremely patient temperament","阳光活泼 ☀️":"bright, energetic, and highly enthusiastic temperament","严肃冷酷 ❄️":"stern, cold, and serious tone","慵懒随性 ☕":"lazy, relaxed, and casual conversational tone",标准国语:"speaking standard Mandarin",川普口音:"speaking standard Mandarin with a charming Sichuan dialect accent",粤普口音:"speaking standard Mandarin with a subtle Cantonese dialect accent",东北口音:"speaking standard Mandarin with a noticeable Northeast dialect accent",英普口音:"speaking standard Mandarin with a slight English accent"},r=e.map(e=>t[e]||e);return`A beautiful ${r.join(", ")}.`})(n))},style:{padding:"2px 8px",borderRadius:4,fontSize:10,border:r?"1px solid var(--accent)":"1px solid var(--border)",background:r?"var(--bg-selected)":"none",color:r?"var(--text)":"var(--text-muted)",cursor:"pointer",transition:"all 0.12s"},children:t},t)})})]},e.title))]}),(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6,borderTop:"1px dashed var(--border)",paddingTop:10},children:[(0,n.jsx)("span",{style:{fontSize:11,fontWeight:600,color:"var(--text-muted)"},children:"\uD83D\uDCDD 生成的声线描述 (Timbre Prompt):"}),(0,n.jsx)("textarea",{value:x,onChange:e=>u(e.target.value),rows:2,placeholder:"点击上方魔方自动组装声线,或在此手动撰写...",style:{width:"100%",padding:8,fontSize:11,borderRadius:6,border:"1px solid var(--border)",background:"var(--bg)",color:"var(--text)",fontFamily:"var(--font-mono)",resize:"none"}})]})]}),R&&(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[(0,n.jsx)("span",{style:{fontSize:11,fontWeight:600,color:"var(--text-muted)"},children:"\uD83D\uDD0A 声线克隆提取器 (Voice Clone Source):"}),0===(a=t.filter(e=>e.name.endsWith(".wav")||e.name.endsWith(".webm")||e.name.endsWith(".mp3")||e.name.endsWith(".m4a"))).length?(0,n.jsx)("div",{style:{padding:"16px 12px",border:"1px dashed var(--border)",borderRadius:8,fontSize:11,color:"var(--text-muted)",textAlign:"center",lineHeight:"1.6"},children:"\uD83D\uDCA1 请先在左下角点击麦克风 \uD83C\uDFA4 录制您的声音,或点击别针 \uD83D\uDCCE 上传一段录音(WAV/MP3),然后在此选中它以提取克隆声线!"}):(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[(0,n.jsx)("span",{style:{fontSize:10,color:"var(--text-dim)"},children:"检测到已上传的音频附件,点击指定为当前克隆声源:"}),(0,n.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:a.map((e,t)=>{let r=f===e.name;return(0,n.jsxs)("div",{onClick:()=>{var t,r;let n;return t=e.file,r=e.name,void((n=new FileReader).onload=e=>{if(e.target?.result&&"string"==typeof e.target.result){let t=e.target.result;t.startsWith("data:audio/webm;")&&(t=t.replace("data:audio/webm;","data:audio/wav;")),v(t),b(r)}},n.readAsDataURL(t))},style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"6px 12px",borderRadius:6,border:r?"1px solid #10b981":"1px solid var(--border)",background:r?"rgba(16,185,129,0.06)":"none",cursor:"pointer",transition:"all 0.15s"},children:[(0,n.jsx)("span",{style:{fontSize:11,color:"var(--text)",fontWeight:r?600:400},children:e.name}),(0,n.jsx)("span",{style:{fontSize:10,color:r?"#10b981":"var(--text-muted)"},children:r?"✓ 已选定为克隆声源":"点击提取"})]},t)})})]})]})]})]})}let ej=["off","default","full"],ek={off:"none",default:"default",full:"full"},ew=["auto","off","minimal","low","medium","high","xhigh"],eS={auto:"沿用 pi 默认设置",off:"关闭推理",minimal:"最少推理",low:"低强度推理",medium:"中等推理",high:"高强度推理",xhigh:"最高强度推理"},eC=(0,o.forwardRef)(function({onSend:e,onAbort:t,onSteer:r,onFollowUp:i,isStreaming:l,model:s,modelNames:a,modelList:d,onModelChange:c,onCompact:p,onAbortCompaction:x,isCompacting:u,compactError:g,toolPreset:h,onToolPresetChange:f,thinkingLevel:b,onThinkingLevelChange:y,availableThinkingLevels:v,thinkingLevelMap:m,retryInfo:j,soundEnabled:k,onSoundToggle:w,cwd:S},C){let T,z,I,R,L,W,E,M,D,[B,A]=(0,o.useState)(""),[F,N]=(0,o.useState)(!1),[P,H]=(0,o.useState)(null),[_,J]=(0,o.useState)(!1),[U,V]=(0,o.useState)(!1),[Y,K]=(0,o.useState)([]),[G,q]=(0,o.useState)([]),[Z,X]=(0,o.useState)(!1),[Q,ee]=(0,o.useState)({}),[et,er]=(0,o.useState)(null),[en,eo]=(0,o.useState)(!1),[es,ea]=(0,o.useState)(""),[ed,ec]=(0,o.useState)(!1),[ep,ex]=(0,o.useState)("text"),eu=!!s&&ei(s.provider,s.modelId),[eg,eh]=(0,o.useState)(!1),[ef,eb]=(0,o.useState)(!1),[ey,eC]=(0,o.useState)(0),eT=(0,o.useRef)(null),ez=(0,o.useRef)([]),eI=(0,o.useRef)(null);(0,o.useEffect)(()=>()=>{eI.current&&clearInterval(eI.current)},[]);let eR=async()=>{if(!navigator.mediaDevices)return void er("您的浏览器不支持麦克风录音设备。");try{let e,t=await navigator.mediaDevices.getUserMedia({audio:!0});ez.current=[];try{e=new MediaRecorder(t,{mimeType:"audio/webm"})}catch(r){e=new MediaRecorder(t)}eT.current=e,e.ondataavailable=e=>{e.data.size>0&&ez.current.push(e.data)},e.onstop=()=>{let r=new Blob(ez.current,{type:e.mimeType||"audio/webm"}),n=e.mimeType?.includes("webm")?"webm":"wav",o=new File([r],`voice_record_${Date.now()}.${n}`,{type:r.type});eP([o]),t.getTracks().forEach(e=>e.stop())},e.start(),eb(!0),eC(0),eI.current=setInterval(()=>{eC(e=>e+1)},1e3)}catch(e){console.error("Failed to start recording:",e),er("麦克风启动失败,请检查浏览器是否已授权麦克风权限!")}},eL=()=>{eT.current&&"inactive"!==eT.current.state&&eT.current.stop(),eb(!1),eI.current&&(clearInterval(eI.current),eI.current=null)},eW=(0,o.useRef)(null),eE=(0,o.useRef)(null),eM=(0,o.useRef)(null),eD=(0,o.useRef)(null),e$=(0,o.useRef)(null),eB=(0,o.useRef)(null),eA=(0,o.useRef)(null);(0,o.useImperativeHandle)(C,()=>({insertIfEmpty(e){let t=eW.current;(t?t.value:B).trim()||(A(e),requestAnimationFrame(()=>{t&&(t.focus(),t.style.height="auto",t.style.height=`${Math.min(t.scrollHeight,200)}px`)}))},insertText(e){let t=eW.current;if(!t)return void A(t=>t+(t?" ":"")+e);let r=t.selectionStart??t.value.length,n=t.selectionEnd??t.value.length,o=t.value.slice(0,r),i=t.value.slice(n),l=o.length>0&&!o.endsWith(" ")?" ":"";A(o+l+e+i),requestAnimationFrame(()=>{if(!t)return;let n=r+l.length+e.length;t.setSelectionRange(n,n),t.focus(),t.style.height="auto",t.style.height=`${Math.min(t.scrollHeight,200)}px`})},addImages(e){eO(e)},addFiles(e){eP(e)}}));let eO=(0,o.useCallback)(async e=>{let t=e.filter(e=>e.type.startsWith("image/"));if(t.length)try{let e=await Promise.all(t.map(async e=>{let t=await function(e,t=1024,r=1024,n=.8){return new Promise((o,i)=>{let l=new FileReader;l.onload=e=>{let l=new Image;l.onload=()=>{let e=l.width,s=l.height;e>s?e>t&&(s=Math.round(s*t/e),e=t):s>r&&(e=Math.round(e*r/s),s=r);let a=document.createElement("canvas");a.width=e,a.height=s;let d=a.getContext("2d");if(!d)return void i(Error("Failed to get canvas 2D context"));d.fillStyle="#ffffff",d.fillRect(0,0,e,s),d.drawImage(l,0,0,e,s);let c=a.toDataURL("image/jpeg",n),p=c.indexOf(",");o({data:-1!==p?c.substring(p+1):c,mimeType:"image/jpeg"})},l.onerror=e=>i(e),l.src=e.target?.result},l.onerror=e=>i(e),l.readAsDataURL(e)})}(e);return{data:t.data,mimeType:t.mimeType,previewUrl:URL.createObjectURL(e)}}));K(t=>[...t,...e])}catch(e){console.error("Failed to process and compress image files:",e)}},[]),eF=(0,o.useCallback)(e=>{K(t=>{let r=[...t];return URL.revokeObjectURL(r[e].previewUrl),r.splice(e,1),r})},[]),eN=(0,o.useCallback)(()=>{K(e=>(e.forEach(e=>URL.revokeObjectURL(e.previewUrl)),[]))},[]),eP=(0,o.useCallback)(e=>{let t=e.map(e=>({file:e,name:e.name,size:e.size}));q(e=>[...e,...t])},[]),eH=(0,o.useCallback)(e=>{q(t=>{let r=[...t];return r.splice(e,1),r})},[]),e_=(0,o.useCallback)(e=>{if(0===e)return"0 Bytes";let t=Math.floor(Math.log(e)/Math.log(1024));return parseFloat((e/Math.pow(1024,t)).toFixed(2))+" "+["Bytes","KB","MB","GB"][t]},[]),eJ=(0,o.useCallback)(async e=>{let t=Y[e];if(!t)return;let r=d?.find(e=>e.id===s?.modelId&&e.provider===s?.provider);if(!(r&&r.supportsVision||s&&ev(s.provider,s.modelId)))return void er("该模型不是视觉模型,不支持识图功能。");ee(t=>({...t,[e]:!0})),er(null);try{let e=await fetch("/api/agent/describe-image",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({image:t.data,mimeType:t.mimeType,provider:s.provider,modelId:s.modelId})}),r=await e.json();if(!e.ok)throw Error(r.error||"Failed to describe image");ea(r.description),eo(!0),ec(!1),ex("text")}catch(t){console.error(t);let e=t.message||String(t);(e.includes("No endpoints found that support image input")||e.includes("support image input")||e.includes("not support image")||e.includes("404")&&(e.toLowerCase().includes("image")||e.toLowerCase().includes("endpoint")))&&(e="该模型不是视觉模型,不支持识图功能。"),er(e)}finally{ee(t=>({...t,[e]:!1}))}},[Y,s,d]),eU=(0,o.useCallback)(async()=>{let t=B.trim();if(!t&&!Y.length&&!G.length||l||Z)return;if(Y.length>0){let e=d?.find(e=>e.id===s?.modelId&&e.provider===s?.provider);if(!(e&&e.supportsVision||s&&ev(s.provider,s.modelId)))return void er("该模型不是视觉模型,不支持识图功能。")}let r=t;if(G.length>0){if(!S)return void er("无法获取当前工作区路径,文件上传失败。");X(!0),er(null);try{let e=await Promise.all(G.map(async e=>{let t=O(O(S,"Temp"),e.name),r=$(t),n=await fetch(`/api/files/${r}`,{method:"POST",body:e.file});if(!n.ok){let t=await n.json().catch(()=>({}));throw Error(t.error||`上传文件 ${e.name} 失败`)}return e})),t="\n\n\x3c!-- PI_FILE_ATTACHMENTS_START --\x3e\n\uD83D\uDCC4 [已上传文件到工作区]\n"+e.map(e=>`- Temp/${e.name} (${e_(e.size)})`).join("\n")+"\n\x3c!-- PI_FILE_ATTACHMENTS_END --\x3e";r=r?`${r}${t}`:t.trim(),q([])}catch(e){console.error("Upload error:",e),er(e.message||"上传文件过程中出现未知错误"),X(!1);return}X(!1)}e(r,Y.length?Y:void 0),A(""),eN(),eW.current&&(eW.current.style.height="auto")},[B,Y,G,l,Z,e,eN,s,d,S,e_]),eV=(0,o.useCallback)(async e=>{let t=B.trim();if(!t&&!Y.length&&!G.length||Z)return;if(Y.length>0){let e=d?.find(e=>e.id===s?.modelId&&e.provider===s?.provider);if(!(e&&e.supportsVision||s&&ev(s.provider,s.modelId)))return void er("该模型不是视觉模型,不支持识图功能。")}let n=t;if(G.length>0){if(!S)return void er("无法获取当前工作区路径,文件上传失败。");X(!0),er(null);try{let e=await Promise.all(G.map(async e=>{let t=O(O(S,"Temp"),e.name),r=$(t),n=await fetch(`/api/files/${r}`,{method:"POST",body:e.file});if(!n.ok){let t=await n.json().catch(()=>({}));throw Error(t.error||`上传文件 ${e.name} 失败`)}return e})),t="\n\n\x3c!-- PI_FILE_ATTACHMENTS_START --\x3e\n\uD83D\uDCC4 [已上传文件到工作区]\n"+e.map(e=>`- Temp/${e.name} (${e_(e.size)})`).join("\n")+"\n\x3c!-- PI_FILE_ATTACHMENTS_END --\x3e";n=n?`${n}${t}`:t.trim(),q([])}catch(e){console.error("Upload error:",e),er(e.message||"上传文件过程中出现未知错误"),X(!1);return}X(!1)}"steer"===e&&r?r(n,Y.length?Y:void 0):"followup"===e&&i&&i(n,Y.length?Y:void 0),A(""),eN(),eW.current&&(eW.current.style.height="auto")},[B,Y,G,r,i,eN,s,d,S,Z,e_]),eY=(0,o.useCallback)(e=>{"Enter"!==e.key||e.shiftKey||e.nativeEvent.isComposing||(e.preventDefault(),l&&(r||i)?eV(r?"steer":"followup"):eU())},[l,r,i,eV,eU]),eK=(0,o.useCallback)(()=>{let e=eW.current;e&&(e.style.height="auto",e.style.height=`${Math.min(e.scrollHeight,200)}px`)},[]),eG=(0,o.useCallback)(e=>{let t=Array.from(e.clipboardData?.items??[]).filter(e=>e.type.startsWith("image/"));t.length&&(e.preventDefault(),eO(t.map(e=>e.getAsFile()).filter(e=>null!==e)))},[eO]),eq=d&&d.length>0?d.map(e=>({provider:e.provider,modelId:e.id,name:e.name})):Object.entries(a??{}).map(([e,t])=>({provider:s?.provider??"unknown",modelId:e,name:t})),eZ=[];for(let e of eq){let t=eZ.find(t=>t.provider===e.provider);t?t.options.push(e):eZ.push({provider:e.provider,options:[e]})}let eX=s?eq.find(e=>e.modelId===s.modelId&&e.provider===s.provider)?.name??s.modelId:eq.length>0?eq[0].name:null;return(0,o.useEffect)(()=>{let e=e=>{eE.current&&!eE.current.contains(e.target)&&eM.current&&!eM.current.contains(e.target)&&N(!1),eD.current&&!eD.current.contains(e.target)&&J(!1),e$.current&&!e$.current.contains(e.target)&&V(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]),(0,n.jsxs)("div",{style:{flexShrink:0,background:"transparent",padding:"0 16px 8px",paddingRight:34},children:[(0,n.jsx)("input",{ref:eB,type:"file",accept:"image/*",multiple:!0,style:{display:"none"},onChange:e=>{eO(Array.from(e.target.files??[])),e.target.value=""}}),(0,n.jsx)("input",{ref:eA,type:"file",multiple:!0,style:{display:"none"},onChange:e=>{eP(Array.from(e.target.files??[])),e.target.value=""}}),(0,n.jsxs)("div",{style:{maxWidth:820,margin:"0 auto"},children:[j&&(0,n.jsxs)("div",{style:{marginBottom:8,padding:"5px 10px",background:"rgba(234,179,8,0.08)",border:"1px solid rgba(234,179,8,0.25)",borderRadius:6,fontSize:12,color:"rgba(180,130,0,0.9)",display:"flex",alignItems:"center",gap:6},children:[(0,n.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[(0,n.jsx)("path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}),(0,n.jsx)("path",{d:"M3 3v5h5"})]}),"Retrying (",j.attempt,"/",j.maxAttempts,")…",j.errorMessage&&(0,n.jsxs)("span",{style:{opacity:.7,marginLeft:4},children:["— ",j.errorMessage]})]}),et&&(0,n.jsxs)("div",{style:{marginBottom:8,padding:"8px 12px",background:"rgba(239,68,68,0.08)",border:"1px solid rgba(239,68,68,0.25)",borderRadius:8,fontSize:12,color:"rgba(220,38,38,0.9)",display:"flex",alignItems:"center",gap:6,position:"relative"},children:[(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,n.jsx)("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),(0,n.jsx)("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),(0,n.jsx)("span",{style:{flex:1},children:et}),(0,n.jsx)("button",{onClick:()=>er(null),style:{background:"none",border:"none",color:"rgba(220,38,38,0.6)",cursor:"pointer",display:"flex",alignItems:"center",padding:2},children:(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,n.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),Y.length>0&&(0,n.jsxs)("div",{style:{display:"flex",gap:6,marginBottom:6,flexWrap:"wrap"},children:[(0,n.jsx)("style",{children:`
39
39
  @keyframes spin {
40
40
  0% { transform: rotate(0deg); }
41
41
  100% { transform: rotate(360deg); }
42
42
  }
43
- `}),Y.map((e,t)=>{let r=!!Q[t];return(0,n.jsxs)("div",{style:{position:"relative",flexShrink:0},children:[(0,n.jsx)("img",{src:e.previewUrl,alt:"",style:{width:56,height:56,objectFit:"cover",borderRadius:6,border:"1px solid var(--border)",display:"block",filter:r?"brightness(0.4)":"none",transition:"filter 0.2s"}}),r?(0,n.jsx)("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0, 0, 0, 0.4)",borderRadius:6},children:(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"#fff",strokeWidth:"3",strokeLinecap:"round",style:{animation:"spin 1s linear infinite"},children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"10",stroke:"rgba(255,255,255,0.2)"}),(0,n.jsx)("path",{d:"M12 2a10 10 0 0 1 10 10"})]})}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("button",{onClick:()=>eJ(t),title:"\uD83E\uDE84 反推提示词",style:{position:"absolute",bottom:-4,left:-4,width:20,height:20,borderRadius:"50%",background:"var(--bg-panel)",border:"1px solid var(--border)",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",padding:0,color:"var(--accent)",boxShadow:"0 2px 4px rgba(0,0,0,0.1)",fontSize:11,transition:"transform 0.15s, background-color 0.15s"},onMouseEnter:e=>{e.currentTarget.style.transform="scale(1.15)",e.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:e=>{e.currentTarget.style.transform="scale(1)",e.currentTarget.style.background="var(--bg-panel)"},children:"\uD83E\uDE84"}),(0,n.jsx)("button",{onClick:()=>eO(t),style:{position:"absolute",top:-4,right:-4,width:16,height:16,borderRadius:"50%",background:"var(--bg-panel)",border:"1px solid var(--border)",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",padding:0,color:"var(--text-muted)"},children:(0,n.jsxs)("svg",{width:"8",height:"8",viewBox:"0 0 8 8",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",children:[(0,n.jsx)("line",{x1:"1",y1:"1",x2:"7",y2:"7"}),(0,n.jsx)("line",{x1:"7",y1:"1",x2:"1",y2:"7"})]})})]})]},t)})]}),ef&&(0,n.jsxs)("div",{style:{marginBottom:8,padding:"8px 12px",background:"rgba(239,68,68,0.08)",border:"1px solid rgba(239,68,68,0.25)",borderRadius:8,fontSize:12,color:"#ef4444",display:"flex",alignItems:"center",gap:8},children:[(0,n.jsx)("style",{children:`
43
+ `}),Y.map((e,t)=>{let r=!!Q[t];return(0,n.jsxs)("div",{style:{position:"relative",flexShrink:0},children:[(0,n.jsx)("img",{src:e.previewUrl,alt:"",style:{width:56,height:56,objectFit:"cover",borderRadius:6,border:"1px solid var(--border)",display:"block",filter:r?"brightness(0.4)":"none",transition:"filter 0.2s"}}),r?(0,n.jsx)("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0, 0, 0, 0.4)",borderRadius:6},children:(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"#fff",strokeWidth:"3",strokeLinecap:"round",style:{animation:"spin 1s linear infinite"},children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"10",stroke:"rgba(255,255,255,0.2)"}),(0,n.jsx)("path",{d:"M12 2a10 10 0 0 1 10 10"})]})}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("button",{onClick:()=>eJ(t),title:"\uD83E\uDE84 反推提示词",style:{position:"absolute",bottom:-4,left:-4,width:20,height:20,borderRadius:"50%",background:"var(--bg-panel)",border:"1px solid var(--border)",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",padding:0,color:"var(--accent)",boxShadow:"0 2px 4px rgba(0,0,0,0.1)",fontSize:11,transition:"transform 0.15s, background-color 0.15s"},onMouseEnter:e=>{e.currentTarget.style.transform="scale(1.15)",e.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:e=>{e.currentTarget.style.transform="scale(1)",e.currentTarget.style.background="var(--bg-panel)"},children:"\uD83E\uDE84"}),(0,n.jsx)("button",{onClick:()=>eF(t),style:{position:"absolute",top:-4,right:-4,width:16,height:16,borderRadius:"50%",background:"var(--bg-panel)",border:"1px solid var(--border)",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",padding:0,color:"var(--text-muted)"},children:(0,n.jsxs)("svg",{width:"8",height:"8",viewBox:"0 0 8 8",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",children:[(0,n.jsx)("line",{x1:"1",y1:"1",x2:"7",y2:"7"}),(0,n.jsx)("line",{x1:"7",y1:"1",x2:"1",y2:"7"})]})})]})]},t)})]}),ef&&(0,n.jsxs)("div",{style:{marginBottom:8,padding:"8px 12px",background:"rgba(239,68,68,0.08)",border:"1px solid rgba(239,68,68,0.25)",borderRadius:8,fontSize:12,color:"#ef4444",display:"flex",alignItems:"center",gap:8},children:[(0,n.jsx)("style",{children:`
44
44
  @keyframes recordPulse {
45
45
  0% { opacity: 0.4; }
46
46
  50% { opacity: 1; }
47
47
  100% { opacity: 0.4; }
48
48
  }
49
- `}),(0,n.jsx)("span",{style:{width:8,height:8,borderRadius:"50%",background:"#ef4444",display:"inline-block",animation:"recordPulse 1s infinite"}}),(0,n.jsx)("span",{style:{fontWeight:600},children:"麦克风录制中:"}),(0,n.jsx)("span",{style:{fontFamily:"var(--font-mono)",fontVariantNumeric:"tabular-nums"},children:(T=Math.floor(eb/60).toString().padStart(2,"0"),I=(eb%60).toString().padStart(2,"0"),`${T}:${I}`)}),(0,n.jsx)("button",{onClick:eL,style:{marginLeft:"auto",padding:"2px 8px",background:"#ef4444",border:"none",borderRadius:4,color:"#fff",fontSize:11,fontWeight:600,cursor:"pointer",boxShadow:"0 1px 3px rgba(239,68,68,0.3)"},children:"停止录音并添加至附件"})]}),Z&&(0,n.jsxs)("div",{style:{marginBottom:8,padding:"5px 10px",background:"rgba(59,130,246,0.08)",border:"1px solid rgba(59,130,246,0.25)",borderRadius:6,fontSize:12,color:"var(--accent)",display:"flex",alignItems:"center",gap:6},children:[(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",style:{animation:"spin 1s linear infinite"},children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"10",stroke:"rgba(59,130,246,0.2)"}),(0,n.jsx)("path",{d:"M12 2a10 10 0 0 1 10 10"})]}),"Uploading ",q.length," file(s) to workspace…"]}),q.length>0&&(0,n.jsx)("div",{style:{display:"flex",gap:6,marginBottom:8,flexWrap:"wrap"},children:q.map((e,t)=>(0,n.jsxs)("div",{style:{display:"inline-flex",alignItems:"center",gap:6,padding:"5px 10px",background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:8,fontSize:12,color:"var(--text)",boxShadow:"0 1px 3px rgba(0,0,0,0.05)",position:"relative",transition:"background 0.15s"},children:[(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-muted)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[(0,n.jsx)("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),(0,n.jsx)("polyline",{points:"14 2 14 8 20 8"})]}),(0,n.jsx)("span",{style:{maxWidth:150,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:e.name,children:e.name}),(0,n.jsx)("span",{style:{fontSize:10,color:"var(--text-dim)",flexShrink:0},children:e_(e.size)}),(0,n.jsx)("button",{onClick:()=>eH(t),disabled:Z,style:{display:"flex",alignItems:"center",justifyContent:"center",width:14,height:14,borderRadius:"50%",background:"rgba(255,255,255,0.05)",border:"none",color:"var(--text-muted)",cursor:Z?"not-allowed":"pointer",padding:0,marginLeft:2,fontSize:10},onMouseEnter:e=>{Z||(e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color="#ef4444")},onMouseLeave:e=>{e.currentTarget.style.background="rgba(255,255,255,0.05)",e.currentTarget.style.color="var(--text-muted)"},children:(0,n.jsxs)("svg",{width:"6",height:"6",viewBox:"0 0 8 8",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:[(0,n.jsx)("line",{x1:"1",y1:"1",x2:"7",y2:"7"}),(0,n.jsx)("line",{x1:"7",y1:"1",x2:"1",y2:"7"})]})})]},t))}),(0,n.jsx)(em,{model:s,attachedFiles:q,voiceConsoleOpen:eg,setVoiceConsoleOpen:eh,insertAudioTag:e=>{let t=eW.current;if(!t)return;let r=t.selectionStart,n=t.selectionEnd;A(B.substring(0,r)+` [${e}] `+B.substring(n)),setTimeout(()=>{t.focus();let n=r+e.length+4;t.setSelectionRange(n,n)},10)}}),(0,n.jsxs)("div",{style:{display:"flex",gap:8,alignItems:"center",background:"var(--bg)",border:`1px solid ${l&&(r||i)?"rgba(234,179,8,0.4)":"color-mix(in srgb, var(--border) 70%, transparent)"}`,borderRadius:14,padding:"10px 10px 10px 14px",boxShadow:"0 1px 2px rgba(15,23,42,0.04), 0 8px 24px -12px rgba(15,23,42,0.10)",transition:"border-color 0.15s, background 0.15s, box-shadow 0.15s"},children:[(0,n.jsx)("textarea",{ref:eW,value:B,onChange:e=>A(e.target.value),onKeyDown:eY,onInput:eK,onPaste:eq,placeholder:l&&(r||i)?"Steer 立即注入 / Follow-up 排队…":l?"Agent is running…":"Message…",rows:1,style:{flex:1,background:"none",border:"none",outline:"none",resize:"none",color:"var(--text)",fontSize:14,lineHeight:1.6,fontFamily:"inherit",minHeight:24,maxHeight:200,overflow:"auto"}}),l?(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,flexShrink:0,alignSelf:"flex-end"},children:[r&&(0,n.jsxs)("button",{onClick:()=>eV("steer"),disabled:!B.trim()&&!Y.length&&!q.length,title:"打断 Agent 当前运行,立即注入消息",style:{display:"flex",alignItems:"center",gap:5,padding:"7px 12px",background:B.trim()||Y.length||q.length?"rgba(234,179,8,0.12)":"none",border:"1px solid rgba(234,179,8,0.35)",borderRadius:8,color:B.trim()||Y.length||q.length?"rgba(180,130,0,1)":"var(--text-dim)",cursor:B.trim()||Y.length||q.length?"pointer":"not-allowed",fontSize:13,fontWeight:600,letterSpacing:"-0.01em",transition:"background 0.12s"},children:[(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M5 1 L9 5 L5 9"}),(0,n.jsx)("line",{x1:"1",y1:"5",x2:"9",y2:"5"})]}),"Steer"]}),i&&(0,n.jsxs)("button",{onClick:()=>eV("followup"),disabled:!B.trim()&&!Y.length&&!q.length,title:"在 Agent 完成后排队发送",style:{display:"flex",alignItems:"center",gap:5,padding:"7px 12px",background:B.trim()||Y.length||q.length?"rgba(129,140,248,0.12)":"none",border:"1px solid rgba(129,140,248,0.35)",borderRadius:8,color:B.trim()||Y.length||q.length?"rgba(99,102,241,1)":"var(--text-dim)",cursor:B.trim()||Y.length||q.length?"pointer":"not-allowed",fontSize:13,fontWeight:600,letterSpacing:"-0.01em",transition:"background 0.12s"},children:[(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("line",{x1:"5",y1:"1",x2:"5",y2:"6"}),(0,n.jsx)("polyline",{points:"2.5 3.5 5 1 7.5 3.5"}),(0,n.jsx)("line",{x1:"2",y1:"9",x2:"8",y2:"9"})]}),"Follow-up"]})]}):(0,n.jsxs)("button",{onClick:eU,disabled:!B.trim()&&!Y.length&&!q.length,style:{flexShrink:0,alignSelf:"flex-end",display:"flex",alignItems:"center",gap:6,padding:"7px 14px",background:B.trim()||Y.length||q.length?"var(--accent)":"var(--bg-panel)",border:"none",borderRadius:8,color:B.trim()||Y.length||q.length?"#fff":"var(--text-dim)",cursor:B.trim()||Y.length||q.length?"pointer":"not-allowed",fontSize:13,fontWeight:600,letterSpacing:"-0.01em",boxShadow:B.trim()||Y.length||q.length?"0 1px 3px rgba(37,99,235,0.25)":"none",transition:"background 0.15s, box-shadow 0.15s"},children:[(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("line",{x1:"2",y1:"7",x2:"11",y2:"7"}),(0,n.jsx)("polyline",{points:"7.5 3 12 7 7.5 11"})]}),"Send"]})]}),(0,n.jsxs)("div",{style:{marginTop:8,display:"flex",alignItems:"center",gap:6},children:[(0,n.jsxs)("div",{style:{flex:"0 0 auto",display:"flex",alignItems:"center",gap:2},children:[(0,n.jsx)("button",{onClick:()=>eB.current?.click(),disabled:l,title:"Attach image",style:{flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,padding:0,background:"none",border:"none",borderRadius:9,color:Y.length?"var(--accent)":"var(--text-muted)",cursor:l?"not-allowed":"pointer",opacity:l?.5:1,transition:"background 0.12s, color 0.12s"},onMouseEnter:e=>{l||(e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color=Y.length?"var(--accent)":"var(--text)")},onMouseLeave:e=>{e.currentTarget.style.background="none",e.currentTarget.style.color=Y.length?"var(--accent)":"var(--text-muted)"},children:(0,n.jsxs)("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),(0,n.jsx)("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),(0,n.jsx)("polyline",{points:"21 15 16 10 5 21"})]})}),(0,n.jsx)("button",{onClick:()=>eA.current?.click(),disabled:l||Z,title:"Upload files to workspace",style:{flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,padding:0,background:"none",border:"none",borderRadius:9,color:q.length?"var(--accent)":"var(--text-muted)",cursor:l||Z?"not-allowed":"pointer",opacity:l||Z?.5:1,transition:"background 0.12s, color 0.12s"},onMouseEnter:e=>{l||Z||(e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color=q.length?"var(--accent)":"var(--text)")},onMouseLeave:e=>{e.currentTarget.style.background="none",e.currentTarget.style.color=q.length?"var(--accent)":"var(--text-muted)"},children:(0,n.jsx)("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("path",{d:"M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"})})}),eu&&(z=s?.modelId||"",R=el(s?.provider,z),(0,n.jsxs)("div",{style:{display:"inline-flex",alignItems:"center",gap:4},children:[R&&(0,n.jsx)("button",{onClick:ef?eL:eR,disabled:l,title:ef?"停止录音":"麦克风录音 (可作为声音克隆音源)",style:{flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,padding:0,background:ef?"rgba(239,68,68,0.15)":"none",border:"none",borderRadius:9,color:ef?"#ef4444":"var(--text-muted)",cursor:l?"not-allowed":"pointer",opacity:l?.5:1,transition:"background 0.12s, color 0.12s"},onMouseEnter:e=>{l||(e.currentTarget.style.background=ef?"rgba(239,68,68,0.2)":"var(--bg-hover)",e.currentTarget.style.color=ef?"#ef4444":"var(--text)")},onMouseLeave:e=>{e.currentTarget.style.background=ef?"rgba(239,68,68,0.15)":"none",e.currentTarget.style.color=ef?"#ef4444":"var(--text-muted)"},children:ef?(0,n.jsxs)("div",{style:{position:"relative",display:"flex",alignItems:"center",justifyContent:"center",width:14,height:14},children:[(0,n.jsx)("style",{children:`
49
+ `}),(0,n.jsx)("span",{style:{width:8,height:8,borderRadius:"50%",background:"#ef4444",display:"inline-block",animation:"recordPulse 1s infinite"}}),(0,n.jsx)("span",{style:{fontWeight:600},children:"麦克风录制中:"}),(0,n.jsx)("span",{style:{fontFamily:"var(--font-mono)",fontVariantNumeric:"tabular-nums"},children:(T=Math.floor(ey/60).toString().padStart(2,"0"),z=(ey%60).toString().padStart(2,"0"),`${T}:${z}`)}),(0,n.jsx)("button",{onClick:eL,style:{marginLeft:"auto",padding:"2px 8px",background:"#ef4444",border:"none",borderRadius:4,color:"#fff",fontSize:11,fontWeight:600,cursor:"pointer",boxShadow:"0 1px 3px rgba(239,68,68,0.3)"},children:"停止录音并添加至附件"})]}),Z&&(0,n.jsxs)("div",{style:{marginBottom:8,padding:"5px 10px",background:"rgba(59,130,246,0.08)",border:"1px solid rgba(59,130,246,0.25)",borderRadius:6,fontSize:12,color:"var(--accent)",display:"flex",alignItems:"center",gap:6},children:[(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",style:{animation:"spin 1s linear infinite"},children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"10",stroke:"rgba(59,130,246,0.2)"}),(0,n.jsx)("path",{d:"M12 2a10 10 0 0 1 10 10"})]}),"Uploading ",G.length," file(s) to workspace…"]}),G.length>0&&(0,n.jsx)("div",{style:{display:"flex",gap:6,marginBottom:8,flexWrap:"wrap"},children:G.map((e,t)=>(0,n.jsxs)("div",{style:{display:"inline-flex",alignItems:"center",gap:6,padding:"5px 10px",background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:8,fontSize:12,color:"var(--text)",boxShadow:"0 1px 3px rgba(0,0,0,0.05)",position:"relative",transition:"background 0.15s"},children:[(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-muted)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[(0,n.jsx)("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),(0,n.jsx)("polyline",{points:"14 2 14 8 20 8"})]}),(0,n.jsx)("span",{style:{maxWidth:150,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:e.name,children:e.name}),(0,n.jsx)("span",{style:{fontSize:10,color:"var(--text-dim)",flexShrink:0},children:e_(e.size)}),(0,n.jsx)("button",{onClick:()=>eH(t),disabled:Z,style:{display:"flex",alignItems:"center",justifyContent:"center",width:14,height:14,borderRadius:"50%",background:"rgba(255,255,255,0.05)",border:"none",color:"var(--text-muted)",cursor:Z?"not-allowed":"pointer",padding:0,marginLeft:2,fontSize:10},onMouseEnter:e=>{Z||(e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color="#ef4444")},onMouseLeave:e=>{e.currentTarget.style.background="rgba(255,255,255,0.05)",e.currentTarget.style.color="var(--text-muted)"},children:(0,n.jsxs)("svg",{width:"6",height:"6",viewBox:"0 0 8 8",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:[(0,n.jsx)("line",{x1:"1",y1:"1",x2:"7",y2:"7"}),(0,n.jsx)("line",{x1:"7",y1:"1",x2:"1",y2:"7"})]})})]},t))}),(0,n.jsx)(em,{model:s,attachedFiles:G,voiceConsoleOpen:eg,setVoiceConsoleOpen:eh,insertAudioTag:e=>{let t=eW.current;if(!t)return;let r=t.selectionStart,n=t.selectionEnd;A(B.substring(0,r)+` [${e}] `+B.substring(n)),setTimeout(()=>{t.focus();let n=r+e.length+4;t.setSelectionRange(n,n)},10)}}),(0,n.jsxs)("div",{style:{display:"flex",gap:8,alignItems:"center",background:"var(--bg)",border:`1px solid ${l&&(r||i)?"rgba(234,179,8,0.4)":"color-mix(in srgb, var(--border) 70%, transparent)"}`,borderRadius:14,padding:"10px 10px 10px 14px",boxShadow:"0 1px 2px rgba(15,23,42,0.04), 0 8px 24px -12px rgba(15,23,42,0.10)",transition:"border-color 0.15s, background 0.15s, box-shadow 0.15s"},children:[(0,n.jsx)("textarea",{ref:eW,value:B,onChange:e=>A(e.target.value),onKeyDown:eY,onInput:eK,onPaste:eG,placeholder:l&&(r||i)?"Steer 立即注入 / Follow-up 排队…":l?"Agent is running…":"Message…",rows:1,style:{flex:1,background:"none",border:"none",outline:"none",resize:"none",color:"var(--text)",fontSize:14,lineHeight:1.6,fontFamily:"inherit",minHeight:24,maxHeight:200,overflow:"auto"}}),l?(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,flexShrink:0,alignSelf:"flex-end"},children:[r&&(0,n.jsxs)("button",{onClick:()=>eV("steer"),disabled:!B.trim()&&!Y.length&&!G.length,title:"打断 Agent 当前运行,立即注入消息",style:{display:"flex",alignItems:"center",gap:5,padding:"7px 12px",background:B.trim()||Y.length||G.length?"rgba(234,179,8,0.12)":"none",border:"1px solid rgba(234,179,8,0.35)",borderRadius:8,color:B.trim()||Y.length||G.length?"rgba(180,130,0,1)":"var(--text-dim)",cursor:B.trim()||Y.length||G.length?"pointer":"not-allowed",fontSize:13,fontWeight:600,letterSpacing:"-0.01em",transition:"background 0.12s"},children:[(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M5 1 L9 5 L5 9"}),(0,n.jsx)("line",{x1:"1",y1:"5",x2:"9",y2:"5"})]}),"Steer"]}),i&&(0,n.jsxs)("button",{onClick:()=>eV("followup"),disabled:!B.trim()&&!Y.length&&!G.length,title:"在 Agent 完成后排队发送",style:{display:"flex",alignItems:"center",gap:5,padding:"7px 12px",background:B.trim()||Y.length||G.length?"rgba(129,140,248,0.12)":"none",border:"1px solid rgba(129,140,248,0.35)",borderRadius:8,color:B.trim()||Y.length||G.length?"rgba(99,102,241,1)":"var(--text-dim)",cursor:B.trim()||Y.length||G.length?"pointer":"not-allowed",fontSize:13,fontWeight:600,letterSpacing:"-0.01em",transition:"background 0.12s"},children:[(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("line",{x1:"5",y1:"1",x2:"5",y2:"6"}),(0,n.jsx)("polyline",{points:"2.5 3.5 5 1 7.5 3.5"}),(0,n.jsx)("line",{x1:"2",y1:"9",x2:"8",y2:"9"})]}),"Follow-up"]})]}):(0,n.jsxs)("button",{onClick:eU,disabled:!B.trim()&&!Y.length&&!G.length,style:{flexShrink:0,alignSelf:"flex-end",display:"flex",alignItems:"center",gap:6,padding:"7px 14px",background:B.trim()||Y.length||G.length?"var(--accent)":"var(--bg-panel)",border:"none",borderRadius:8,color:B.trim()||Y.length||G.length?"#fff":"var(--text-dim)",cursor:B.trim()||Y.length||G.length?"pointer":"not-allowed",fontSize:13,fontWeight:600,letterSpacing:"-0.01em",boxShadow:B.trim()||Y.length||G.length?"0 1px 3px rgba(37,99,235,0.25)":"none",transition:"background 0.15s, box-shadow 0.15s"},children:[(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("line",{x1:"2",y1:"7",x2:"11",y2:"7"}),(0,n.jsx)("polyline",{points:"7.5 3 12 7 7.5 11"})]}),"Send"]})]}),(0,n.jsxs)("div",{style:{marginTop:8,display:"flex",alignItems:"center",gap:6},children:[(0,n.jsxs)("div",{style:{flex:"0 0 auto",display:"flex",alignItems:"center",gap:2},children:[(0,n.jsx)("button",{onClick:()=>eB.current?.click(),disabled:l,title:"Attach image",style:{flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,padding:0,background:"none",border:"none",borderRadius:9,color:Y.length?"var(--accent)":"var(--text-muted)",cursor:l?"not-allowed":"pointer",opacity:l?.5:1,transition:"background 0.12s, color 0.12s"},onMouseEnter:e=>{l||(e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color=Y.length?"var(--accent)":"var(--text)")},onMouseLeave:e=>{e.currentTarget.style.background="none",e.currentTarget.style.color=Y.length?"var(--accent)":"var(--text-muted)"},children:(0,n.jsxs)("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),(0,n.jsx)("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),(0,n.jsx)("polyline",{points:"21 15 16 10 5 21"})]})}),(0,n.jsx)("button",{onClick:()=>eA.current?.click(),disabled:l||Z,title:"Upload files to workspace",style:{flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,padding:0,background:"none",border:"none",borderRadius:9,color:G.length?"var(--accent)":"var(--text-muted)",cursor:l||Z?"not-allowed":"pointer",opacity:l||Z?.5:1,transition:"background 0.12s, color 0.12s"},onMouseEnter:e=>{l||Z||(e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color=G.length?"var(--accent)":"var(--text)")},onMouseLeave:e=>{e.currentTarget.style.background="none",e.currentTarget.style.color=G.length?"var(--accent)":"var(--text-muted)"},children:(0,n.jsx)("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("path",{d:"M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"})})}),eu&&(I=s?.modelId||"",R=el(s?.provider,I),(0,n.jsxs)("div",{style:{display:"inline-flex",alignItems:"center",gap:4},children:[R&&(0,n.jsx)("button",{onClick:ef?eL:eR,disabled:l,title:ef?"停止录音":"麦克风录音 (可作为声音克隆音源)",style:{flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,padding:0,background:ef?"rgba(239,68,68,0.15)":"none",border:"none",borderRadius:9,color:ef?"#ef4444":"var(--text-muted)",cursor:l?"not-allowed":"pointer",opacity:l?.5:1,transition:"background 0.12s, color 0.12s"},onMouseEnter:e=>{l||(e.currentTarget.style.background=ef?"rgba(239,68,68,0.2)":"var(--bg-hover)",e.currentTarget.style.color=ef?"#ef4444":"var(--text)")},onMouseLeave:e=>{e.currentTarget.style.background=ef?"rgba(239,68,68,0.15)":"none",e.currentTarget.style.color=ef?"#ef4444":"var(--text-muted)"},children:ef?(0,n.jsxs)("div",{style:{position:"relative",display:"flex",alignItems:"center",justifyContent:"center",width:14,height:14},children:[(0,n.jsx)("style",{children:`
50
50
  @keyframes micPulse {
51
51
  0% { transform: scale(0.9); opacity: 0.5; }
52
52
  50% { transform: scale(1.3); opacity: 1; }
53
53
  100% { transform: scale(0.9); opacity: 0.5; }
54
54
  }
55
- `}),(0,n.jsx)("span",{style:{position:"absolute",width:14,height:14,borderRadius:"50%",background:"#ef4444",animation:"micPulse 1.2s infinite"}}),(0,n.jsx)("span",{style:{position:"absolute",width:6,height:6,borderRadius:"50%",background:"#fff"}})]}):(0,n.jsxs)("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z"}),(0,n.jsx)("path",{d:"M19 10v2a7 7 0 0 1-14 0v-2"}),(0,n.jsx)("line",{x1:"12",y1:"19",x2:"12",y2:"22"})]})}),(0,n.jsx)("button",{onClick:()=>eh(e=>!e),title:"语音工坊设定",style:{flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,padding:0,background:eg?"rgba(var(--accent-rgb), 0.12)":"none",border:"none",borderRadius:9,color:eg?"var(--accent)":"var(--text-muted)",cursor:"pointer",transition:"background 0.12s, color 0.12s"},onMouseEnter:e=>{e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color="var(--text)"},onMouseLeave:e=>{e.currentTarget.style.background=eg?"rgba(var(--accent-rgb), 0.12)":"none",e.currentTarget.style.color=eg?"var(--accent)":"var(--text-muted)"},children:(0,n.jsxs)("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"3"}),(0,n.jsx)("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"})]})})]})),eG.length>0&&eX&&c&&(0,n.jsxs)("div",{ref:eE,style:{position:"relative"},children:[(0,n.jsxs)("button",{onClick:e=>{let t=e.currentTarget.getBoundingClientRect();H({top:t.top,left:t.left,width:t.width}),N(e=>!e)},disabled:l,style:{display:"flex",alignItems:"center",gap:6,padding:"8px 12px",height:32,maxWidth:220,overflow:"hidden",background:O?"var(--bg-hover)":"none",border:"none",borderRadius:9,color:"var(--text-muted)",cursor:l?"not-allowed":"pointer",fontSize:12,opacity:l?.5:1,transition:"background 0.12s, color 0.12s"},onMouseEnter:e=>{l||(e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color="var(--text)")},onMouseLeave:e=>{e.currentTarget.style.background=O?"var(--bg-hover)":"none",e.currentTarget.style.color="var(--text-muted)"},children:[(0,n.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"}),(0,n.jsx)("rect",{x:"9",y:"9",width:"6",height:"6"}),(0,n.jsx)("line",{x1:"9",y1:"1",x2:"9",y2:"4"}),(0,n.jsx)("line",{x1:"15",y1:"1",x2:"15",y2:"4"}),(0,n.jsx)("line",{x1:"9",y1:"20",x2:"9",y2:"23"}),(0,n.jsx)("line",{x1:"15",y1:"20",x2:"15",y2:"23"}),(0,n.jsx)("line",{x1:"20",y1:"9",x2:"23",y2:"9"}),(0,n.jsx)("line",{x1:"20",y1:"14",x2:"23",y2:"14"}),(0,n.jsx)("line",{x1:"1",y1:"9",x2:"4",y2:"9"}),(0,n.jsx)("line",{x1:"1",y1:"14",x2:"4",y2:"14"})]}),(0,n.jsx)("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0},children:eX})]}),O&&P&&(W=(L=window.visualViewport?.height??window.innerHeight)-P.top+6,E=Math.max(120,Math.min(P.top-8,.6*L)),(0,n.jsx)("div",{ref:eM,style:{position:"fixed",bottom:W,left:P.left,zIndex:500,background:"var(--bg)",border:"1px solid var(--border)",borderRadius:8,boxShadow:"0 -4px 16px rgba(0,0,0,0.10)",overflow:"hidden",width:"max-content",minWidth:P.width,maxHeight:E,overflowY:"auto"},children:eZ.map((e,t)=>(0,n.jsxs)("div",{children:[eZ.length>1&&(0,n.jsx)("div",{style:{padding:"6px 12px 4px",fontSize:10,fontWeight:600,color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:"0.07em",borderTop:t>0?"1px solid var(--border)":"none"},children:e.provider}),e.options.map(e=>{let t=e.modelId===s?.modelId&&e.provider===s?.provider;return(0,n.jsxs)("button",{onClick:()=>{N(!1),t||c(e.provider,e.modelId)},style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"7px 12px",background:t?"var(--bg-selected)":"none",border:"none",color:t?"var(--text)":"var(--text-muted)",cursor:"pointer",fontSize:12,textAlign:"left",fontWeight:t?600:400,whiteSpace:"nowrap"},onMouseEnter:e=>{t||(e.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:e=>{t||(e.currentTarget.style.background="none")},children:[t?(0,n.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"var(--accent)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:(0,n.jsx)("polyline",{points:"1.5 5 4 7.5 8.5 2.5"})}):(0,n.jsx)("span",{style:{width:10,flexShrink:0}}),e.name]},`${e.provider}:${e.modelId}`)})]},e.provider))}))]})]}),(0,n.jsx)("div",{style:{flex:1}}),(0,n.jsxs)("div",{style:{flex:"0 0 auto",display:"flex",alignItems:"center",gap:2,marginLeft:"auto"},children:[!l&&b&&(0,n.jsxs)("div",{ref:e$,style:{position:"relative"},children:[(0,n.jsxs)("button",{onClick:()=>!l&&V(e=>!e),disabled:l,title:"切换推理强度",style:{display:"flex",alignItems:"center",gap:5,padding:"8px 12px",height:32,background:U?"var(--bg-hover)":"none",border:"none",borderRadius:9,color:"var(--text-muted)",cursor:l?"not-allowed":"pointer",fontSize:12,opacity:l?.5:1,transition:"background 0.12s, color 0.12s"},onMouseEnter:e=>{l||(e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color="var(--text)")},onMouseLeave:e=>{e.currentTarget.style.background=U?"var(--bg-hover)":"none",e.currentTarget.style.color="var(--text-muted)"},children:[(0,n.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M9.5 2A5.5 5.5 0 0 0 4 7.5c0 1.7.78 3.21 2 4.21V14a1 1 0 0 0 1 1h5a1 1 0 0 0 1-1v-2.29c1.22-1 2-2.51 2-4.21A5.5 5.5 0 0 0 9.5 2z"}),(0,n.jsx)("line",{x1:"7",y1:"18",x2:"12",y2:"18"}),(0,n.jsx)("line",{x1:"8",y1:"21",x2:"11",y2:"21"})]}),(0,n.jsx)("span",{children:(()=>{let e=y??"auto";if("auto"===e||!m)return e;let t=m[e];return null!=t?t:e})()})]}),U&&(0,n.jsx)("div",{style:{position:"absolute",bottom:"calc(100% + 6px)",right:0,zIndex:100,background:"var(--bg)",border:"1px solid var(--border)",borderRadius:8,boxShadow:"0 -4px 16px rgba(0,0,0,0.10)",overflow:"hidden",minWidth:180},children:ew.filter(e=>!v||"auto"===e||v.includes(e)).map(e=>{let t=(y??"auto")===e,r=eS[e],o="auto"!==e&&m?m[e]:void 0,i=null!=o&&o!==e?o:e,l=null!=o&&o!==e;return(0,n.jsxs)("button",{onClick:()=>{V(!1),t||b(e)},style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"7px 12px",background:t?"var(--bg-selected)":"none",border:"none",color:t?"var(--text)":"var(--text-muted)",cursor:"pointer",fontSize:12,textAlign:"left",fontWeight:t?600:400,whiteSpace:"nowrap"},onMouseEnter:e=>{t||(e.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:e=>{t||(e.currentTarget.style.background="none")},children:[t?(0,n.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"var(--accent)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:(0,n.jsx)("polyline",{points:"1.5 5 4 7.5 8.5 2.5"})}):(0,n.jsx)("span",{style:{width:10,flexShrink:0}}),(0,n.jsxs)("span",{style:{flex:1},children:[i,l&&(0,n.jsxs)("span",{style:{fontSize:10,color:"var(--text-dim)",fontFamily:"var(--font-mono)",marginLeft:5},children:["(",e,")"]})]}),(0,n.jsx)("span",{style:{fontSize:11,color:"var(--text-dim)",marginLeft:8},children:r})]},e)})})]}),!l&&f&&(0,n.jsxs)("div",{ref:eD,style:{position:"relative"},children:[(0,n.jsxs)("button",{onClick:()=>!l&&J(e=>!e),disabled:l,title:"切换工具预设",style:{display:"flex",alignItems:"center",gap:5,padding:"8px 12px",height:32,background:_?"var(--bg-hover)":"none",border:"none",borderRadius:9,color:"var(--text-muted)",cursor:l?"not-allowed":"pointer",fontSize:12,opacity:l?.5:1,transition:"background 0.12s, color 0.12s"},onMouseEnter:e=>{l||(e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color="var(--text)")},onMouseLeave:e=>{e.currentTarget.style.background=_?"var(--bg-hover)":"none",e.currentTarget.style.color="var(--text-muted)"},children:[(0,n.jsx)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"})}),(0,n.jsx)("span",{children:Object.entries(ek).find(([,e])=>e===(h??"default"))?.[0]??"default"})]}),_&&(0,n.jsx)("div",{style:{position:"absolute",bottom:"calc(100% + 6px)",right:0,zIndex:100,background:"var(--bg)",border:"1px solid var(--border)",borderRadius:8,boxShadow:"0 -4px 16px rgba(0,0,0,0.10)",overflow:"hidden",minWidth:120},children:ej.map(e=>{let t=ek[e],r=(h??"default")===t,o="off"===e?"无工具,纯聊天":"default"===e?"4 项内置工具":"全部内置工具";return(0,n.jsxs)("button",{onClick:()=>{J(!1),r||f(t)},style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"7px 12px",background:r?"var(--bg-selected)":"none",border:"none",color:r?"var(--text)":"var(--text-muted)",cursor:"pointer",fontSize:12,textAlign:"left",fontWeight:r?600:400,whiteSpace:"nowrap"},onMouseEnter:e=>{r||(e.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:e=>{r||(e.currentTarget.style.background="none")},children:[r?(0,n.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"var(--accent)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:(0,n.jsx)("polyline",{points:"1.5 5 4 7.5 8.5 2.5"})}):(0,n.jsx)("span",{style:{width:10,flexShrink:0}}),(0,n.jsx)("span",{style:{flex:1},children:e}),(0,n.jsx)("span",{style:{fontSize:11,color:"var(--text-dim)",marginLeft:8},children:o})]},e)})})]}),!l&&p&&(0,n.jsxs)("div",{style:{position:"relative"},children:[g&&(0,n.jsx)("div",{style:{position:"absolute",bottom:"calc(100% + 6px)",right:0,background:"#1f2937",color:"#f87171",fontSize:11,padding:"4px 8px",borderRadius:5,whiteSpace:"nowrap",pointerEvents:"none",boxShadow:"0 2px 8px rgba(0,0,0,0.2)",zIndex:50},children:g}),(0,n.jsx)("button",{onClick:u?x:p,disabled:l&&!u,style:{display:"flex",alignItems:"center",gap:5,padding:"8px 12px",height:32,background:u?"rgba(239,68,68,0.08)":"none",border:"none",borderRadius:9,color:u?"#ef4444":"var(--text-muted)",cursor:l&&!u?"not-allowed":"pointer",fontSize:12,opacity:l&&!u?.5:1,transition:"background 0.12s, color 0.12s"},onMouseEnter:e=>{(!l||u)&&(e.currentTarget.style.background=u?"rgba(239,68,68,0.16)":"var(--bg-hover)",e.currentTarget.style.color=u?"#ef4444":"var(--text)")},onMouseLeave:e=>{e.currentTarget.style.background=u?"rgba(239,68,68,0.08)":"none",e.currentTarget.style.color=u?"#ef4444":"var(--text-muted)"},title:u?"停止压缩":"压缩上下文",children:u?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:(0,n.jsx)("rect",{x:"2",y:"2",width:"6",height:"6",rx:"1",fill:"currentColor"})}),"Compacting…"]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("polyline",{points:"4 14 10 14 10 20"}),(0,n.jsx)("polyline",{points:"20 10 14 10 14 4"}),(0,n.jsx)("line",{x1:"10",y1:"14",x2:"3",y2:"21"}),(0,n.jsx)("line",{x1:"21",y1:"3",x2:"14",y2:"10"})]}),"Compact"]})})]}),l&&(0,n.jsxs)("button",{onClick:t,title:"停止 Agent",style:{display:"flex",alignItems:"center",gap:6,padding:"8px 14px",height:32,background:"rgba(239,68,68,0.08)",border:"1px solid rgba(239,68,68,0.3)",borderRadius:9,color:"#ef4444",cursor:"pointer",fontSize:12,fontWeight:600,whiteSpace:"nowrap",letterSpacing:"-0.01em",transition:"background 0.12s"},onMouseEnter:e=>{e.currentTarget.style.background="rgba(239,68,68,0.16)"},onMouseLeave:e=>{e.currentTarget.style.background="rgba(239,68,68,0.08)"},children:[(0,n.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:(0,n.jsx)("rect",{x:"1.5",y:"1.5",width:"7",height:"7",rx:"1.5",fill:"currentColor"})}),"Stop"]}),void 0!==w&&(0,n.jsx)("button",{onClick:w,title:k?"关闭完成提示音":"开启完成提示音",style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,padding:0,background:"none",border:"none",borderRadius:9,color:k?"var(--text-muted)":"var(--text-dim)",cursor:"pointer",opacity:k?1:.55,transition:"background 0.12s, color 0.12s, opacity 0.12s"},onMouseEnter:e=>{e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color="var(--text)",e.currentTarget.style.opacity="1"},onMouseLeave:e=>{e.currentTarget.style.background="none",e.currentTarget.style.color=k?"var(--text-muted)":"var(--text-dim)",e.currentTarget.style.opacity=k?"1":"0.55"},children:k?(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),(0,n.jsx)("path",{d:"M15.54 8.46a5 5 0 0 1 0 7.07"}),(0,n.jsx)("path",{d:"M19.07 4.93a10 10 0 0 1 0 14.14"})]}):(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),(0,n.jsx)("line",{x1:"23",y1:"9",x2:"17",y2:"15"}),(0,n.jsx)("line",{x1:"17",y1:"9",x2:"23",y2:"15"})]})})]})]})]}),en&&(M=function(e){let t="",r="",n="",o="",i="",l="",s=e.split(/\r?\n/),a=!1,d=[];for(let e of s){let s=e.trim();if(!s)continue;if(s.includes("最终直调用")||s.includes("【最终直调用 Prompt】")){a=!0;continue}if(a){if("---"===s||s.startsWith("---")||s.startsWith("***"))continue;d.push(s);continue}let c=s.toLowerCase();if(c.includes("core_subject")||s.includes("核心主体")){let e=s.split(/[::]/);e.length>1&&(t=e.slice(1).join(":").trim())}else if(c.includes("clothing")||s.includes("服装/材质")||s.includes("服装")||s.includes("材质")){if(!c.includes("lighting")&&!s.includes("光照")){let e=s.split(/[::]/);e.length>1&&(r=e.slice(1).join(":").trim())}}else if(c.includes("location")||s.includes("具体地点")){let e=s.split(/[::]/);e.length>1&&(n=e.slice(1).join(":").trim())}else if(c.includes("background")||s.includes("画面背景")){let e=s.split(/[::::]/);e.length>1&&(o=e.slice(1).join(":").trim())}else if(c.includes("lighting")||s.includes("光照与色彩")||s.includes("光照")||s.includes("色彩")){let e=s.split(/[::]/);e.length>1&&(i=e.slice(1).join(":").trim())}else if(c.includes("style")||s.includes("艺术风格")){let e=s.split(/[::]/);e.length>1&&(l=e.slice(1).join(":").trim())}}let c=e=>e.replace(/[\*\#\>\`]/g,"").trim();t=c(t),r=c(r),n=c(n),o=c(o),i=c(i),l=c(l);let p=d.join("\n").trim();for(let e of[/请根据上述分析,直接组合出可直接复制的流利中文\s*Prompt。/ig,/请使用纯英文自然语言或短语(用逗号隔开),以便我直接复制粘贴:/ig,/请使用纯英文自然语言或短语\s*\(用逗号隔开\)\s*,以便我直接复制粘贴:/ig,/请使用纯英文自然语言或短语\s*(用逗号隔开)\s*,以便我直接复制粘贴:/ig,/请根据上述分析,直接组合出可直接复制的流利中文\s*Prompt/ig,/请使用纯英文自然语言或短语/ig,/以便我直接复制粘贴/ig])p=p.replace(e,"");if(p=c(p=p.replace(/^[::\s]+/,"").trim()),!t||!l){let s=e.replace(/[\*\#\>\-\`]/g," ").replace(/\s+/g," ").trim();if(!t){let e=s.match(/(?:主角是|主体是|画面中是|一个|一位|一幅|主角为|主体为|核心焦点为|核心为)([^,。;]+)/i);t=e?e[1].trim():""}if(!r){let e=s.match(/(?:身穿|身着|穿着|身披|着装为|服装为|衣服为|衣服是|身穿一袭)([^,。;]+)/i);r=e?e[1].trim():""}if(!n){let e=s.match(/(?:在|位于|置身于|场景是|地点是|背景是|场景为|位置为|居中放置)([^,。;]{2,20})(?:中|里|上|下|旁|前|后|,|。|;)/i);n=e?e[1].trim():""}if(!o){let e=s.match(/(?:背景是|背景为|背景中包含|背景有|配景为|背景采用)([^。;,]+)/i);o=e?e[1].trim():""}if(!i){let e=s.match(/(?:光线|光影|阳光|照射|照明|光效|光环|散发出)([^,。;]+)/i);i=e?e[1].trim():""}if(!l){let e=s.match(/(?:风格|画风|设计风格|视觉风格|呈现出|表现为|采用)([^,。;]+)/i);l=e?e[1].trim():""}let a=s.split(/[,。;]/).map(e=>e.trim()).filter(Boolean);!t&&a.length>0&&(t=a[0]),!n&&a.length>1&&(n=a[1]),l||(l=s.includes("摄影")?"写实摄影肖像":s.includes("插画")?"动漫手绘插画":s.includes("界面")||s.includes("设计")?"UI界面设计":"现代艺术风格")}return!p&&((p=[l||"",t||"",n||"",r||"",o||"",i||""].filter(Boolean).join(","))||(p=e.replace(/[\*\#\>\-\`]/g," ").replace(/\s+/g," ").trim())),JSON.stringify({image_prompt:{core_subject:t,clothing:r,location:n,background:o,lighting:i,style:l,prompt:p}},null,2)}(es),D="text"===ep?es:M,(0,n.jsxs)("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,background:"rgba(0, 0, 0, 0.45)",backdropFilter:"blur(4px)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:9999,padding:16,animation:"fadeIn 0.2s ease-out"},children:[(0,n.jsx)("style",{children:`
55
+ `}),(0,n.jsx)("span",{style:{position:"absolute",width:14,height:14,borderRadius:"50%",background:"#ef4444",animation:"micPulse 1.2s infinite"}}),(0,n.jsx)("span",{style:{position:"absolute",width:6,height:6,borderRadius:"50%",background:"#fff"}})]}):(0,n.jsxs)("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z"}),(0,n.jsx)("path",{d:"M19 10v2a7 7 0 0 1-14 0v-2"}),(0,n.jsx)("line",{x1:"12",y1:"19",x2:"12",y2:"22"})]})}),(0,n.jsx)("button",{onClick:()=>eh(e=>!e),title:"语音工坊设定",style:{flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,padding:0,background:eg?"rgba(var(--accent-rgb), 0.12)":"none",border:"none",borderRadius:9,color:eg?"var(--accent)":"var(--text-muted)",cursor:"pointer",transition:"background 0.12s, color 0.12s"},onMouseEnter:e=>{e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color="var(--text)"},onMouseLeave:e=>{e.currentTarget.style.background=eg?"rgba(var(--accent-rgb), 0.12)":"none",e.currentTarget.style.color=eg?"var(--accent)":"var(--text-muted)"},children:(0,n.jsxs)("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"3"}),(0,n.jsx)("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"})]})})]})),eq.length>0&&eX&&c&&(0,n.jsxs)("div",{ref:eE,style:{position:"relative"},children:[(0,n.jsxs)("button",{onClick:e=>{let t=e.currentTarget.getBoundingClientRect();H({top:t.top,left:t.left,width:t.width}),N(e=>!e)},disabled:l,style:{display:"flex",alignItems:"center",gap:6,padding:"8px 12px",height:32,maxWidth:220,overflow:"hidden",background:F?"var(--bg-hover)":"none",border:"none",borderRadius:9,color:"var(--text-muted)",cursor:l?"not-allowed":"pointer",fontSize:12,opacity:l?.5:1,transition:"background 0.12s, color 0.12s"},onMouseEnter:e=>{l||(e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color="var(--text)")},onMouseLeave:e=>{e.currentTarget.style.background=F?"var(--bg-hover)":"none",e.currentTarget.style.color="var(--text-muted)"},children:[(0,n.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"}),(0,n.jsx)("rect",{x:"9",y:"9",width:"6",height:"6"}),(0,n.jsx)("line",{x1:"9",y1:"1",x2:"9",y2:"4"}),(0,n.jsx)("line",{x1:"15",y1:"1",x2:"15",y2:"4"}),(0,n.jsx)("line",{x1:"9",y1:"20",x2:"9",y2:"23"}),(0,n.jsx)("line",{x1:"15",y1:"20",x2:"15",y2:"23"}),(0,n.jsx)("line",{x1:"20",y1:"9",x2:"23",y2:"9"}),(0,n.jsx)("line",{x1:"20",y1:"14",x2:"23",y2:"14"}),(0,n.jsx)("line",{x1:"1",y1:"9",x2:"4",y2:"9"}),(0,n.jsx)("line",{x1:"1",y1:"14",x2:"4",y2:"14"})]}),(0,n.jsx)("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0},children:eX})]}),F&&P&&(W=(L=window.visualViewport?.height??window.innerHeight)-P.top+6,E=Math.max(120,Math.min(P.top-8,.6*L)),(0,n.jsx)("div",{ref:eM,style:{position:"fixed",bottom:W,left:P.left,zIndex:500,background:"var(--bg)",border:"1px solid var(--border)",borderRadius:8,boxShadow:"0 -4px 16px rgba(0,0,0,0.10)",overflow:"hidden",width:"max-content",minWidth:P.width,maxHeight:E,overflowY:"auto"},children:eZ.map((e,t)=>(0,n.jsxs)("div",{children:[eZ.length>1&&(0,n.jsx)("div",{style:{padding:"6px 12px 4px",fontSize:10,fontWeight:600,color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:"0.07em",borderTop:t>0?"1px solid var(--border)":"none"},children:e.provider}),e.options.map(e=>{let t=e.modelId===s?.modelId&&e.provider===s?.provider;return(0,n.jsxs)("button",{onClick:()=>{N(!1),t||c(e.provider,e.modelId)},style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"7px 12px",background:t?"var(--bg-selected)":"none",border:"none",color:t?"var(--text)":"var(--text-muted)",cursor:"pointer",fontSize:12,textAlign:"left",fontWeight:t?600:400,whiteSpace:"nowrap"},onMouseEnter:e=>{t||(e.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:e=>{t||(e.currentTarget.style.background="none")},children:[t?(0,n.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"var(--accent)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:(0,n.jsx)("polyline",{points:"1.5 5 4 7.5 8.5 2.5"})}):(0,n.jsx)("span",{style:{width:10,flexShrink:0}}),e.name]},`${e.provider}:${e.modelId}`)})]},e.provider))}))]})]}),(0,n.jsx)("div",{style:{flex:1}}),(0,n.jsxs)("div",{style:{flex:"0 0 auto",display:"flex",alignItems:"center",gap:2,marginLeft:"auto"},children:[!l&&y&&(0,n.jsxs)("div",{ref:e$,style:{position:"relative"},children:[(0,n.jsxs)("button",{onClick:()=>!l&&V(e=>!e),disabled:l,title:"切换推理强度",style:{display:"flex",alignItems:"center",gap:5,padding:"8px 12px",height:32,background:U?"var(--bg-hover)":"none",border:"none",borderRadius:9,color:"var(--text-muted)",cursor:l?"not-allowed":"pointer",fontSize:12,opacity:l?.5:1,transition:"background 0.12s, color 0.12s"},onMouseEnter:e=>{l||(e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color="var(--text)")},onMouseLeave:e=>{e.currentTarget.style.background=U?"var(--bg-hover)":"none",e.currentTarget.style.color="var(--text-muted)"},children:[(0,n.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M9.5 2A5.5 5.5 0 0 0 4 7.5c0 1.7.78 3.21 2 4.21V14a1 1 0 0 0 1 1h5a1 1 0 0 0 1-1v-2.29c1.22-1 2-2.51 2-4.21A5.5 5.5 0 0 0 9.5 2z"}),(0,n.jsx)("line",{x1:"7",y1:"18",x2:"12",y2:"18"}),(0,n.jsx)("line",{x1:"8",y1:"21",x2:"11",y2:"21"})]}),(0,n.jsx)("span",{children:(()=>{let e=b??"auto";if("auto"===e||!m)return e;let t=m[e];return null!=t?t:e})()})]}),U&&(0,n.jsx)("div",{style:{position:"absolute",bottom:"calc(100% + 6px)",right:0,zIndex:100,background:"var(--bg)",border:"1px solid var(--border)",borderRadius:8,boxShadow:"0 -4px 16px rgba(0,0,0,0.10)",overflow:"hidden",minWidth:180},children:ew.filter(e=>!v||"auto"===e||v.includes(e)).map(e=>{let t=(b??"auto")===e,r=eS[e],o="auto"!==e&&m?m[e]:void 0,i=null!=o&&o!==e?o:e,l=null!=o&&o!==e;return(0,n.jsxs)("button",{onClick:()=>{V(!1),t||y(e)},style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"7px 12px",background:t?"var(--bg-selected)":"none",border:"none",color:t?"var(--text)":"var(--text-muted)",cursor:"pointer",fontSize:12,textAlign:"left",fontWeight:t?600:400,whiteSpace:"nowrap"},onMouseEnter:e=>{t||(e.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:e=>{t||(e.currentTarget.style.background="none")},children:[t?(0,n.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"var(--accent)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:(0,n.jsx)("polyline",{points:"1.5 5 4 7.5 8.5 2.5"})}):(0,n.jsx)("span",{style:{width:10,flexShrink:0}}),(0,n.jsxs)("span",{style:{flex:1},children:[i,l&&(0,n.jsxs)("span",{style:{fontSize:10,color:"var(--text-dim)",fontFamily:"var(--font-mono)",marginLeft:5},children:["(",e,")"]})]}),(0,n.jsx)("span",{style:{fontSize:11,color:"var(--text-dim)",marginLeft:8},children:r})]},e)})})]}),!l&&f&&(0,n.jsxs)("div",{ref:eD,style:{position:"relative"},children:[(0,n.jsxs)("button",{onClick:()=>!l&&J(e=>!e),disabled:l,title:"切换工具预设",style:{display:"flex",alignItems:"center",gap:5,padding:"8px 12px",height:32,background:_?"var(--bg-hover)":"none",border:"none",borderRadius:9,color:"var(--text-muted)",cursor:l?"not-allowed":"pointer",fontSize:12,opacity:l?.5:1,transition:"background 0.12s, color 0.12s"},onMouseEnter:e=>{l||(e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color="var(--text)")},onMouseLeave:e=>{e.currentTarget.style.background=_?"var(--bg-hover)":"none",e.currentTarget.style.color="var(--text-muted)"},children:[(0,n.jsx)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"})}),(0,n.jsx)("span",{children:Object.entries(ek).find(([,e])=>e===(h??"default"))?.[0]??"default"})]}),_&&(0,n.jsx)("div",{style:{position:"absolute",bottom:"calc(100% + 6px)",right:0,zIndex:100,background:"var(--bg)",border:"1px solid var(--border)",borderRadius:8,boxShadow:"0 -4px 16px rgba(0,0,0,0.10)",overflow:"hidden",minWidth:120},children:ej.map(e=>{let t=ek[e],r=(h??"default")===t,o="off"===e?"无工具,纯聊天":"default"===e?"4 项内置工具":"全部内置工具";return(0,n.jsxs)("button",{onClick:()=>{J(!1),r||f(t)},style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"7px 12px",background:r?"var(--bg-selected)":"none",border:"none",color:r?"var(--text)":"var(--text-muted)",cursor:"pointer",fontSize:12,textAlign:"left",fontWeight:r?600:400,whiteSpace:"nowrap"},onMouseEnter:e=>{r||(e.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:e=>{r||(e.currentTarget.style.background="none")},children:[r?(0,n.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"var(--accent)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:(0,n.jsx)("polyline",{points:"1.5 5 4 7.5 8.5 2.5"})}):(0,n.jsx)("span",{style:{width:10,flexShrink:0}}),(0,n.jsx)("span",{style:{flex:1},children:e}),(0,n.jsx)("span",{style:{fontSize:11,color:"var(--text-dim)",marginLeft:8},children:o})]},e)})})]}),!l&&p&&(0,n.jsxs)("div",{style:{position:"relative"},children:[g&&(0,n.jsx)("div",{style:{position:"absolute",bottom:"calc(100% + 6px)",right:0,background:"#1f2937",color:"#f87171",fontSize:11,padding:"4px 8px",borderRadius:5,whiteSpace:"nowrap",pointerEvents:"none",boxShadow:"0 2px 8px rgba(0,0,0,0.2)",zIndex:50},children:g}),(0,n.jsx)("button",{onClick:u?x:p,disabled:l&&!u,style:{display:"flex",alignItems:"center",gap:5,padding:"8px 12px",height:32,background:u?"rgba(239,68,68,0.08)":"none",border:"none",borderRadius:9,color:u?"#ef4444":"var(--text-muted)",cursor:l&&!u?"not-allowed":"pointer",fontSize:12,opacity:l&&!u?.5:1,transition:"background 0.12s, color 0.12s"},onMouseEnter:e=>{(!l||u)&&(e.currentTarget.style.background=u?"rgba(239,68,68,0.16)":"var(--bg-hover)",e.currentTarget.style.color=u?"#ef4444":"var(--text)")},onMouseLeave:e=>{e.currentTarget.style.background=u?"rgba(239,68,68,0.08)":"none",e.currentTarget.style.color=u?"#ef4444":"var(--text-muted)"},title:u?"停止压缩":"压缩上下文",children:u?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:(0,n.jsx)("rect",{x:"2",y:"2",width:"6",height:"6",rx:"1",fill:"currentColor"})}),"Compacting…"]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("polyline",{points:"4 14 10 14 10 20"}),(0,n.jsx)("polyline",{points:"20 10 14 10 14 4"}),(0,n.jsx)("line",{x1:"10",y1:"14",x2:"3",y2:"21"}),(0,n.jsx)("line",{x1:"21",y1:"3",x2:"14",y2:"10"})]}),"Compact"]})})]}),l&&(0,n.jsxs)("button",{onClick:t,title:"停止 Agent",style:{display:"flex",alignItems:"center",gap:6,padding:"8px 14px",height:32,background:"rgba(239,68,68,0.08)",border:"1px solid rgba(239,68,68,0.3)",borderRadius:9,color:"#ef4444",cursor:"pointer",fontSize:12,fontWeight:600,whiteSpace:"nowrap",letterSpacing:"-0.01em",transition:"background 0.12s"},onMouseEnter:e=>{e.currentTarget.style.background="rgba(239,68,68,0.16)"},onMouseLeave:e=>{e.currentTarget.style.background="rgba(239,68,68,0.08)"},children:[(0,n.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:(0,n.jsx)("rect",{x:"1.5",y:"1.5",width:"7",height:"7",rx:"1.5",fill:"currentColor"})}),"Stop"]}),void 0!==w&&(0,n.jsx)("button",{onClick:w,title:k?"关闭完成提示音":"开启完成提示音",style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,padding:0,background:"none",border:"none",borderRadius:9,color:k?"var(--text-muted)":"var(--text-dim)",cursor:"pointer",opacity:k?1:.55,transition:"background 0.12s, color 0.12s, opacity 0.12s"},onMouseEnter:e=>{e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color="var(--text)",e.currentTarget.style.opacity="1"},onMouseLeave:e=>{e.currentTarget.style.background="none",e.currentTarget.style.color=k?"var(--text-muted)":"var(--text-dim)",e.currentTarget.style.opacity=k?"1":"0.55"},children:k?(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),(0,n.jsx)("path",{d:"M15.54 8.46a5 5 0 0 1 0 7.07"}),(0,n.jsx)("path",{d:"M19.07 4.93a10 10 0 0 1 0 14.14"})]}):(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),(0,n.jsx)("line",{x1:"23",y1:"9",x2:"17",y2:"15"}),(0,n.jsx)("line",{x1:"17",y1:"9",x2:"23",y2:"15"})]})})]})]})]}),en&&(M=function(e){let t="",r="",n="",o="",i="",l="",s=e.split(/\r?\n/),a=!1,d=[];for(let e of s){let s=e.trim();if(!s)continue;if(s.includes("最终直调用")||s.includes("【最终直调用 Prompt】")){a=!0;continue}if(a){if("---"===s||s.startsWith("---")||s.startsWith("***"))continue;d.push(s);continue}let c=s.toLowerCase();if(c.includes("core_subject")||s.includes("核心主体")){let e=s.split(/[::]/);e.length>1&&(t=e.slice(1).join(":").trim())}else if(c.includes("clothing")||s.includes("服装/材质")||s.includes("服装")||s.includes("材质")){if(!c.includes("lighting")&&!s.includes("光照")){let e=s.split(/[::]/);e.length>1&&(r=e.slice(1).join(":").trim())}}else if(c.includes("location")||s.includes("具体地点")){let e=s.split(/[::]/);e.length>1&&(n=e.slice(1).join(":").trim())}else if(c.includes("background")||s.includes("画面背景")){let e=s.split(/[::::]/);e.length>1&&(o=e.slice(1).join(":").trim())}else if(c.includes("lighting")||s.includes("光照与色彩")||s.includes("光照")||s.includes("色彩")){let e=s.split(/[::]/);e.length>1&&(i=e.slice(1).join(":").trim())}else if(c.includes("style")||s.includes("艺术风格")){let e=s.split(/[::]/);e.length>1&&(l=e.slice(1).join(":").trim())}}let c=e=>e.replace(/[\*\#\>\`]/g,"").trim();t=c(t),r=c(r),n=c(n),o=c(o),i=c(i),l=c(l);let p=d.join("\n").trim();for(let e of[/请根据上述分析,直接组合出可直接复制的流利中文\s*Prompt。/ig,/请使用纯英文自然语言或短语(用逗号隔开),以便我直接复制粘贴:/ig,/请使用纯英文自然语言或短语\s*\(用逗号隔开\)\s*,以便我直接复制粘贴:/ig,/请使用纯英文自然语言或短语\s*(用逗号隔开)\s*,以便我直接复制粘贴:/ig,/请根据上述分析,直接组合出可直接复制的流利中文\s*Prompt/ig,/请使用纯英文自然语言或短语/ig,/以便我直接复制粘贴/ig])p=p.replace(e,"");if(p=c(p=p.replace(/^[::\s]+/,"").trim()),!t||!l){let s=e.replace(/[\*\#\>\-\`]/g," ").replace(/\s+/g," ").trim();if(!t){let e=s.match(/(?:主角是|主体是|画面中是|一个|一位|一幅|主角为|主体为|核心焦点为|核心为)([^,。;]+)/i);t=e?e[1].trim():""}if(!r){let e=s.match(/(?:身穿|身着|穿着|身披|着装为|服装为|衣服为|衣服是|身穿一袭)([^,。;]+)/i);r=e?e[1].trim():""}if(!n){let e=s.match(/(?:在|位于|置身于|场景是|地点是|背景是|场景为|位置为|居中放置)([^,。;]{2,20})(?:中|里|上|下|旁|前|后|,|。|;)/i);n=e?e[1].trim():""}if(!o){let e=s.match(/(?:背景是|背景为|背景中包含|背景有|配景为|背景采用)([^。;,]+)/i);o=e?e[1].trim():""}if(!i){let e=s.match(/(?:光线|光影|阳光|照射|照明|光效|光环|散发出)([^,。;]+)/i);i=e?e[1].trim():""}if(!l){let e=s.match(/(?:风格|画风|设计风格|视觉风格|呈现出|表现为|采用)([^,。;]+)/i);l=e?e[1].trim():""}let a=s.split(/[,。;]/).map(e=>e.trim()).filter(Boolean);!t&&a.length>0&&(t=a[0]),!n&&a.length>1&&(n=a[1]),l||(l=s.includes("摄影")?"写实摄影肖像":s.includes("插画")?"动漫手绘插画":s.includes("界面")||s.includes("设计")?"UI界面设计":"现代艺术风格")}return!p&&((p=[l||"",t||"",n||"",r||"",o||"",i||""].filter(Boolean).join(","))||(p=e.replace(/[\*\#\>\-\`]/g," ").replace(/\s+/g," ").trim())),JSON.stringify({image_prompt:{core_subject:t,clothing:r,location:n,background:o,lighting:i,style:l,prompt:p}},null,2)}(es),D="text"===ep?es:M,(0,n.jsxs)("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,background:"rgba(0, 0, 0, 0.45)",backdropFilter:"blur(4px)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:9999,padding:16,animation:"fadeIn 0.2s ease-out"},children:[(0,n.jsx)("style",{children:`
56
56
  @keyframes fadeIn {
57
57
  from { opacity: 0; }
58
58
  to { opacity: 1; }
@@ -61,10 +61,10 @@
61
61
  from { transform: scale(0.96); opacity: 0; }
62
62
  to { transform: scale(1); opacity: 1; }
63
63
  }
64
- `}),(0,n.jsxs)("div",{style:{background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:16,width:"100%",maxWidth:560,boxShadow:"0 20px 25px -5px rgba(0, 0, 0, 0.15), 0 10px 10px -5px rgba(0, 0, 0, 0.04)",display:"flex",flexDirection:"column",animation:"scaleIn 0.2s cubic-bezier(0.34, 1.56, 0.64, 1)",overflow:"hidden"},children:[(0,n.jsxs)("div",{style:{display:"flex",borderBottom:"1px solid var(--border)",background:"rgba(255,255,255,0.02)",padding:"0 20px",alignItems:"center",justifyContent:"space-between"},children:[(0,n.jsxs)("div",{style:{display:"flex",gap:16},children:[(0,n.jsx)("button",{onClick:()=>ex("text"),style:{padding:"16px 4px",border:"none",borderBottom:`2px solid ${"text"===ep?"var(--accent)":"transparent"}`,background:"none",color:"text"===ep?"var(--text)":"var(--text-muted)",fontSize:14,fontWeight:600,cursor:"pointer",transition:"color 0.15s, border-color 0.15s"},children:"文本格式"}),(0,n.jsx)("button",{onClick:()=>ex("json"),style:{padding:"16px 4px",border:"none",borderBottom:`2px solid ${"json"===ep?"var(--accent)":"transparent"}`,background:"none",color:"json"===ep?"var(--text)":"var(--text-muted)",fontSize:14,fontWeight:600,cursor:"pointer",transition:"color 0.15s, border-color 0.15s"},children:"JSON 格式"})]}),(0,n.jsx)("button",{onClick:()=>eo(!1),style:{background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",display:"flex",alignItems:"center",padding:4,borderRadius:"50%",transition:"background 0.15s"},onMouseEnter:e=>e.currentTarget.style.background="var(--bg-hover)",onMouseLeave:e=>e.currentTarget.style.background="none",children:(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,n.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),(0,n.jsxs)("div",{style:{padding:20,display:"flex",flexDirection:"column",gap:12},children:[(0,n.jsx)("div",{style:{fontSize:13,color:"var(--text-muted)"},children:"text"===ep?"视觉大模型已为您反推解析出以下结构化文本提示词:":"已将提示词自动分词并重构为以下 image_prompt JSON 结构:"}),(0,n.jsx)("textarea",{readOnly:!0,value:D,style:{width:"100%",height:220,padding:12,background:"var(--bg)",border:"1px solid var(--border)",borderRadius:10,fontSize:13,lineHeight:"1.6",color:"var(--text)",resize:"none",outline:"none",fontFamily:"json"===ep?"var(--font-mono), monospace":"inherit"}})]}),(0,n.jsxs)("div",{style:{padding:"16px 20px",borderTop:"1px solid var(--border)",background:"rgba(255,255,255,0.01)",display:"flex",justifyContent:"flex-end",gap:10},children:[(0,n.jsx)("button",{onClick:()=>{A(e=>e+(e?"\n\n":"")+D),eo(!1),requestAnimationFrame(()=>{eW.current&&(eW.current.focus(),eW.current.style.height="auto",eW.current.style.height=`${Math.min(eW.current.scrollHeight,200)}px`)})},style:{padding:"8px 16px",background:"rgba(129,140,248,0.1)",border:"1px solid rgba(129,140,248,0.25)",borderRadius:8,color:"rgb(99,102,241)",cursor:"pointer",fontSize:13,fontWeight:600,transition:"background 0.12s"},onMouseEnter:e=>e.currentTarget.style.background="rgba(129,140,248,0.18)",onMouseLeave:e=>e.currentTarget.style.background="rgba(129,140,248,0.1)",children:"插入到输入框"}),(0,n.jsx)("button",{onClick:async()=>{try{await navigator.clipboard.writeText(D),ec(!0),setTimeout(()=>ec(!1),2e3)}catch(e){console.error("Failed to copy text:",e)}},style:{padding:"8px 18px",background:ed?"#10B981":"var(--accent)",border:"none",borderRadius:8,color:"#fff",cursor:"pointer",fontSize:13,fontWeight:600,display:"flex",alignItems:"center",gap:6,transition:"background 0.15s"},onMouseEnter:e=>{ed||(e.currentTarget.style.filter="brightness(1.15)")},onMouseLeave:e=>{e.currentTarget.style.filter="none"},children:ed?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("polyline",{points:"20 6 9 17 4 12"})}),"已复制!"]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),(0,n.jsx)("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]}),"复制提示词"]})})]})]})]}))]})});function eT(e){return"user"===e.role?{bg:"rgba(37,99,235,0.18)",border:"rgba(37,99,235,0.7)"}:{bg:"rgba(107,114,128,0.12)",border:"rgba(107,114,128,0.5)"}}function eI({messages:e,streamingMessage:t,scrollContainer:r,messageRefs:i}){let[l,s]=(0,o.useState)(0),[a,d]=(0,o.useState)(1),[c,p]=(0,o.useState)(!1),[x,u]=(0,o.useState)([]),[g,h]=(0,o.useState)(!1),[f,y]=(0,o.useState)(null),b=(0,o.useRef)(!1),v=(0,o.useRef)(null),m=(0,o.useMemo)(()=>t?[...e,t]:e,[e,t]),j=(0,o.useRef)(m);j.current=m;let k=(0,o.useRef)(null);k.current=()=>{let e=r.current;if(!e)return;let t=e.scrollHeight,n=e.clientHeight,o=t-n;p(o>20),o<=0?(s(0),d(1)):(s(e.scrollTop/o),d(n/t));let l=i.current,a=[],c=0,x=j.current;for(let r=0;r<x.length;r++){let n=x[r];if("user"!==n.role&&"assistant"!==n.role)continue;let o=l?.[c];if(c++,("user"===n.role||"assistant"===n.role&&(n.content??[]).some(e=>"text"===e.type))&&o&&t>0){let r=o.getBoundingClientRect(),i=e.getBoundingClientRect(),l=r.top-i.top+e.scrollTop,s=r.height;a.push({topRatio:l/t,heightRatio:s/t,msg:n,index:a.length})}}u(a)};let w=(0,o.useCallback)(()=>k.current(),[]);(0,o.useEffect)(()=>{let e=r.current;if(!e)return;e.addEventListener("scroll",w,{passive:!0});let t=new ResizeObserver(w);return t.observe(e),e.firstElementChild&&t.observe(e.firstElementChild),w(),()=>{e.removeEventListener("scroll",w),t.disconnect()}},[r,w]),(0,o.useEffect)(()=>{let e=setTimeout(w,50);return()=>clearTimeout(e)},[e.length,w]);let S=(0,o.useCallback)(e=>{let t=r.current;if(!t)return;let n=t.scrollHeight-t.clientHeight;n<=0||(t.scrollTop=Math.max(0,Math.min(1-a,e))/(1-a)*n)},[r,a,r.current]),C=(0,o.useCallback)(e=>{if(!c)return;b.current=!0;let t=e.currentTarget.getBoundingClientRect(),r=(e.clientY-t.top)/t.height,n=r-l*(1-a),o=n>=0&&n<=a?n:a/2;S(r-o);let i=e=>{b.current&&S((e.clientY-t.top)/t.height-o)},s=()=>{b.current=!1,window.removeEventListener("mousemove",i),window.removeEventListener("mouseup",s)};window.addEventListener("mousemove",i),window.addEventListener("mouseup",s)},[c,a,l,S]),T=v.current?.clientHeight??600,I=(0,o.useMemo)(()=>{if(!g||0===x.length)return[];let e=x.map(e=>Math.round(e.topRatio*T-11));for(let t=0;t<10;t++){for(let t=1;t<e.length;t++){let r=e[t-1]+22+2;e[t]<r&&(e[t]=r)}for(let t=e.length-2;t>=0;t--){let r=e[t+1]-22-2;e[t]>r&&(e[t]=r)}}for(let t=0;t<e.length;t++)e[t]=Math.max(0,Math.min(T-22,e[t]));return e},[g,x,T]);if(!c)return null;let z=l*(1-a)*100,R=100*a,L=null!==f&&x.length>0?x.reduce((e,t)=>Math.abs(t.topRatio-f)<Math.abs(x[e].topRatio-f)?t.index:e,0):null;return(0,n.jsxs)("div",{ref:v,onMouseDown:C,onMouseEnter:()=>h(!0),onMouseLeave:()=>{h(!1),y(null)},onMouseMove:e=>{let t=e.currentTarget.getBoundingClientRect();y((e.clientY-t.top)/t.height)},style:{width:18,flexShrink:0,position:"relative",cursor:"default",userSelect:"none",borderLeft:"1px solid var(--border)",background:"var(--bg-panel)",overflow:"visible"},children:[(0,n.jsx)("div",{style:{position:"absolute",left:0,right:0,top:`${z}%`,height:`${R}%`,background:"rgba(100,100,100,0.1)",borderTop:"1px solid rgba(100,100,100,0.2)",borderBottom:"1px solid rgba(100,100,100,0.2)",pointerEvents:"none",zIndex:1}}),x.map(e=>{let t=eT(e.msg),r=g&&L===e.index,o="user"===e.msg.role,i=100*e.topRatio;return(0,n.jsx)("div",{style:{position:"absolute",top:`${i}%`,transform:"translateY(-50%)",left:0,right:0,height:"12px",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",zIndex:2},children:(0,n.jsx)("div",{style:{width:o?8:6,height:o?8:6,borderRadius:o?2:"50%",background:t.bg,border:`1.5px solid ${t.border}`,flexShrink:0,transition:"transform 0.1s",transform:r?"scale(1.6)":"scale(1)"}})},e.index)}),(0,n.jsx)("div",{style:{position:"absolute",left:"50%",top:0,bottom:0,width:1,background:"var(--border)",transform:"translateX(-50%)",zIndex:0}}),g&&x.map((e,t)=>{let r=function(e){if("user"===e.role){let t=e.content;return"string"==typeof t?t.slice(0,200):Array.isArray(t)?t.filter(e=>"text"===e.type&&e.text).map(e=>e.text).join("\n").slice(0,200):""}if("assistant"===e.role){let t=e.content??[],r=t.filter(e=>"text"===e.type).map(e=>e.text).join(" ");if(r)return r.slice(0,200);let n=t.filter(e=>"toolCall"===e.type).map(e=>e.toolName);if(n.length)return n.join(", ")}return""}(e.msg),o=eT(e.msg),i=L===e.index;return r&&0!==I.length?(0,n.jsx)("div",{style:{position:"absolute",top:I[t],right:"100%",marginRight:6,background:"var(--bg)",borderTop:`1px solid ${i?o.border:"var(--border)"}`,borderRight:`1px solid ${i?o.border:"var(--border)"}`,borderBottom:`1px solid ${i?o.border:"var(--border)"}`,borderLeft:`2px solid ${o.border}`,borderRadius:4,padding:"2px 7px",width:200,zIndex:100,pointerEvents:"none",opacity:i?1:.45,transition:"top 0.1s, opacity 0.1s"},children:(0,n.jsx)("div",{style:{fontSize:11,color:i?"var(--text)":"var(--text-muted)",lineHeight:1.4,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:r})},e.index):null})]})}function ez(e){if("assistant"!==e.role)return e;let t=e.content;if(!Array.isArray(t))return e;let r=function e(t){if(!Array.isArray(t))return t;let r=[];for(let n of t)if(n&&"text"===n.type&&"string"==typeof n.text){let t=n.text,o=t.indexOf("<think>");if(-1!==o){let n=o+7,i=t.indexOf("</think>",n);if(-1!==i){let l=t.substring(n,i),s=t.substring(i+8);if(o>0){let e=t.substring(0,o);r.push({type:"text",text:e})}if(r.push({type:"thinking",thinking:l}),s){let t=e([{type:"text",text:s}]);r.push(...t)}}else{let e=t.substring(n);if(o>0){let e=t.substring(0,o);r.push({type:"text",text:e})}r.push({type:"thinking",thinking:e})}}else r.push(n)}else r.push(n);return r}(t.map(e=>("object"!=typeof e||null===e||Array.isArray(e)||"toolCall"!==e.type?null:{type:"toolCall",toolCallId:"string"==typeof e.toolCallId?e.toolCallId:"string"==typeof e.id?e.id:"",toolName:"string"==typeof e.toolName?e.toolName:"string"==typeof e.name?e.name:"",input:"object"!=typeof e.input||null===e.input||Array.isArray(e.input)?"object"!=typeof e.arguments||null===e.arguments||Array.isArray(e.arguments)?{}:e.arguments:e.input})??e));return{...e,content:r}}async function eR(e,t){let r=await fetch(`/api/agent/${encodeURIComponent(e)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),n=await r.json().catch(()=>({}));if(!r.ok||n.error)throw Error(n.error??`HTTP ${r.status}`);return n.data}function eL(e,t){switch(t.type){case"start":return{isStreaming:!0,streamingMessage:null};case"update":return{isStreaming:!0,streamingMessage:t.message};case"end":case"reset":return{isStreaming:!1,streamingMessage:null};default:return e}}var eW=r(1463);function eE({session:e,newSessionCwd:t,onAgentEnd:i,onSessionCreated:l,onSessionForked:s,modelsRefreshKey:a,chatInputRef:d,onBranchDataChange:c,onSystemPromptChange:p,onSessionStatsChange:x,onContextUsageChange:u,activeGemId:g}){var h;let f,y,b,[v,m]=(0,o.useState)(null);(0,o.useEffect)(()=>{g?fetch("/api/gem-xy").then(e=>e.json()).then(e=>{let t=e.find(e=>e.id===g);t&&m(`${t.avatar||"\uD83E\uDD16"} ${t.name}`)}).catch(()=>{}):m(null)},[g]);let{loading:j,error:k,messages:w,entryIds:S,streamState:C,agentRunning:T,modelNames:I,modelList:z,modelThinkingLevels:R,modelThinkingLevelMaps:L,toolPreset:W,thinkingLevel:E,retryInfo:M,contextUsage:D,forkingEntryId:$,isCompacting:B,compactError:A,displayModel:F,sessionStats:O,agentPhase:N,isNew:P,messagesEndRef:H,scrollContainerRef:_,lastUserMsgRef:J,handleSend:U,handleAbort:V,handleFork:Y,handleNavigate:K,handleModelChange:q,handleCompact:G,handleSteer:Z,handleFollowUp:X,handleAbortCompaction:Q,handleToolPresetChange:ee,handleThinkingLevelChange:et,handleAgentEventRef:er}=function(e){let{session:t,newSessionCwd:n,onAgentEnd:i,onSessionCreated:l,onSessionForked:s,modelsRefreshKey:a,onBranchDataChange:d,onSystemPromptChange:c}=e,p=null===t&&null!==n,[x,u]=(0,o.useState)(null),[g,h]=(0,o.useState)(!p),[f,y]=(0,o.useState)(null),[b,v]=(0,o.useState)(null),[m,j]=(0,o.useState)([]),[k,w]=(0,o.useState)([]),[S,C]=(0,o.useReducer)(eL,{isStreaming:!1,streamingMessage:null}),[T,I]=(0,o.useState)(!1),[z,R]=(0,o.useState)({}),[L,W]=(0,o.useState)([]),[E,M]=(0,o.useState)({}),[D,$]=(0,o.useState)({}),[B,A]=(0,o.useState)(null),[F,O]=(0,o.useState)("none"),[N,P]=(0,o.useState)("auto"),[H,_]=(0,o.useState)(null),[J,U]=(0,o.useState)(null),[V,Y]=(0,o.useState)(null),[K,q]=(0,o.useState)(null),[G,Z]=(0,o.useState)(null),[X,Q]=(0,o.useState)(null),[ee,et]=(0,o.useState)(!1),[er,en]=(0,o.useState)(null),[eo,ei]=(0,o.useState)(null),[el,es]=(0,o.useState)(null),ea=(0,o.useRef)(null),ed=(0,o.useRef)(t?.id??null),ec=(0,o.useRef)(!1),ep=(0,o.useRef)(!1),ex=(0,o.useRef)(null),eu=(0,o.useRef)(!1),eg=(0,o.useRef)(null),eh=(0,o.useRef)(!1),ef=(0,o.useRef)(null),ey=(0,o.useRef)(null),eb=(0,o.useRef)(null),em=(0,o.useRef)(null),ej=t?.id??null;ej!==el&&(es(ej),ed.current=ej,u(null),j([]),w([]),U(null),Y(null),I(!1),ei(null),et(!1),q(null),eu.current=!1,eh.current=!1,h(null!==ej));let ek=e.setNewSessionModel??A,ew=e.setToolPreset??O,eS=G??x?.context.model??X??null,eC=p?B:eS,eT=(()=>{let e={input:0,output:0,cacheRead:0,cacheWrite:0},t=0;for(let r of m){if("assistant"!==r.role)continue;let n=r.usage;n&&(e.input+=n.input??0,e.output+=n.output??0,e.cacheRead+=n.cacheRead??0,e.cacheWrite+=n.cacheWrite??0,t+=n.cost?.total??0)}return e.input+e.output+e.cacheRead+e.cacheWrite>0?{tokens:e,cost:t}:null})(),eI=(0,o.useCallback)(async(e,t=!1,r=!1)=>{try{t&&h(!0);let n=r?`/api/sessions/${encodeURIComponent(e)}?includeState`:`/api/sessions/${encodeURIComponent(e)}`,o=await fetch(n);if(404===o.status)return t&&(u(null),v(null),j([]),y(null)),null;if(!o.ok)throw Error(`HTTP ${o.status}`);let i=await o.json();return u(i),v(i.leafId),j(i.context.messages),w(i.context.entryIds??[]),Z(null),y(null),!i.agentState?.state?.thinkingLevel&&i.context.thinkingLevel&&"off"!==i.context.thinkingLevel&&P(i.context.thinkingLevel),i.agentState??null}catch(e){return y(String(e)),null}finally{t&&h(!1)}},[]),eW=(0,o.useCallback)(async(e,t)=>{try{let r=t?`/api/sessions/${encodeURIComponent(e)}/context?leafId=${encodeURIComponent(t)}`:`/api/sessions/${encodeURIComponent(e)}/context`,n=await fetch(r);if(!n.ok)throw Error(`HTTP ${n.status}`);let o=await n.json();j(o.context.messages),w(o.context.entryIds??[])}catch(e){console.error("Failed to load context:",e)}},[]),eE=(0,o.useCallback)(async e=>{try{let t=await eR(e,{type:"get_tools"});if(t){let{getPresetFromTools:e}=await r.e(8451).then(r.bind(r,8451));ew(e(t))}}catch(e){console.error("Failed to load tools:",e)}},[ew]),eM=(0,o.useCallback)(e=>(ea.current&&(ea.current.close(),ea.current=null),new Promise(t=>{let r=new EventSource(`/api/agent/${encodeURIComponent(e)}/events`);ea.current=r;let n=!1,o=()=>{n||(n=!0,t())};r.onopen=()=>o(),setTimeout(o,200),r.onmessage=e=>{o();try{let t=JSON.parse(e.data);ex.current?.(t)}catch{}},r.onerror=()=>{ea.current===r&&ec.current&&(r.close(),ea.current=null,setTimeout(()=>{ec.current&&eM(e)},1e3))}})),[]);(0,o.useEffect)(()=>{ec.current=T},[T]),ex.current=(0,o.useCallback)(e=>{switch(e.type){case"agent_start":I(!0),ei({kind:"waiting_model"}),C({type:"start"});break;case"agent_end":em.current&&(clearTimeout(em.current),em.current=null),eb.current=null,I(!1),ep.current=!1,ei(null),_(null),C({type:"end"}),ed.current&&(eI(ed.current),fetch(`/api/agent/${encodeURIComponent(ed.current)}`).then(e=>e.json()).then(e=>{e.state?.contextUsage!==void 0&&U(e.state.contextUsage??null),e.state?.systemPrompt!==void 0&&Y(e.state.systemPrompt??null)}).catch(()=>{})),i?.();break;case"message_start":case"message_update":{let t=e.message;t&&(eb.current=ez(t),em.current||(em.current=setTimeout(()=>{eb.current&&C({type:"update",message:eb.current}),em.current=null},80))),ei(null);break}case"message_end":{em.current&&(clearTimeout(em.current),em.current=null),eb.current=null;let t=e.message;t&&"user"!==t.role&&j(e=>[...e,ez(t)]),C({type:"reset"}),ei({kind:"waiting_model"});break}case"tool_execution_start":{let t=e.toolCallId,r=e.toolName;ei(e=>{let n=e?.kind==="running_tools"?[...e.tools]:[];return n.some(e=>e.id===t)||n.push({id:t,name:r}),{kind:"running_tools",tools:n}});break}case"tool_execution_end":{let t=e.toolCallId;ei(e=>{if(e?.kind!=="running_tools")return e;let r=e.tools.filter(e=>e.id!==t);return 0===r.length?{kind:"waiting_model"}:{kind:"running_tools",tools:r}});break}case"auto_retry_start":_({attempt:e.attempt,maxAttempts:e.maxAttempts,errorMessage:e.errorMessage});break;case"auto_retry_end":_(null);break;case"auto_compaction_start":case"compaction_start":et(!0),en(null);break;case"auto_compaction_end":case"compaction_end":et(!1),e.errorMessage?en(e.errorMessage):!e.aborted&&ed.current&&eI(ed.current)}},[eI,i]);let eD=(0,o.useCallback)(async(e,t)=>{if(!t||0===t.length)return e;let r=L?.find(e=>e.id===eC?.modelId&&e.provider===eC?.provider);if(r&&r.supportsVision||eC&&ev(eC.provider,eC.modelId))return e.trim()||"请分析这张图片。";try{let r=(await Promise.all(t.map(async e=>{let t=await fetch("/api/agent/describe-image",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({image:e.data,mimeType:e.mimeType})});if(!t.ok)throw Error("Failed to describe image");return(await t.json()).description}))).filter(Boolean).join("\n\n");if(r){let t=`[图片描述]:
64
+ `}),(0,n.jsxs)("div",{style:{background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:16,width:"100%",maxWidth:560,boxShadow:"0 20px 25px -5px rgba(0, 0, 0, 0.15), 0 10px 10px -5px rgba(0, 0, 0, 0.04)",display:"flex",flexDirection:"column",animation:"scaleIn 0.2s cubic-bezier(0.34, 1.56, 0.64, 1)",overflow:"hidden"},children:[(0,n.jsxs)("div",{style:{display:"flex",borderBottom:"1px solid var(--border)",background:"rgba(255,255,255,0.02)",padding:"0 20px",alignItems:"center",justifyContent:"space-between"},children:[(0,n.jsxs)("div",{style:{display:"flex",gap:16},children:[(0,n.jsx)("button",{onClick:()=>ex("text"),style:{padding:"16px 4px",border:"none",borderBottom:`2px solid ${"text"===ep?"var(--accent)":"transparent"}`,background:"none",color:"text"===ep?"var(--text)":"var(--text-muted)",fontSize:14,fontWeight:600,cursor:"pointer",transition:"color 0.15s, border-color 0.15s"},children:"文本格式"}),(0,n.jsx)("button",{onClick:()=>ex("json"),style:{padding:"16px 4px",border:"none",borderBottom:`2px solid ${"json"===ep?"var(--accent)":"transparent"}`,background:"none",color:"json"===ep?"var(--text)":"var(--text-muted)",fontSize:14,fontWeight:600,cursor:"pointer",transition:"color 0.15s, border-color 0.15s"},children:"JSON 格式"})]}),(0,n.jsx)("button",{onClick:()=>eo(!1),style:{background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",display:"flex",alignItems:"center",padding:4,borderRadius:"50%",transition:"background 0.15s"},onMouseEnter:e=>e.currentTarget.style.background="var(--bg-hover)",onMouseLeave:e=>e.currentTarget.style.background="none",children:(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,n.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),(0,n.jsxs)("div",{style:{padding:20,display:"flex",flexDirection:"column",gap:12},children:[(0,n.jsx)("div",{style:{fontSize:13,color:"var(--text-muted)"},children:"text"===ep?"视觉大模型已为您反推解析出以下结构化文本提示词:":"已将提示词自动分词并重构为以下 image_prompt JSON 结构:"}),(0,n.jsx)("textarea",{readOnly:!0,value:D,style:{width:"100%",height:220,padding:12,background:"var(--bg)",border:"1px solid var(--border)",borderRadius:10,fontSize:13,lineHeight:"1.6",color:"var(--text)",resize:"none",outline:"none",fontFamily:"json"===ep?"var(--font-mono), monospace":"inherit"}})]}),(0,n.jsxs)("div",{style:{padding:"16px 20px",borderTop:"1px solid var(--border)",background:"rgba(255,255,255,0.01)",display:"flex",justifyContent:"flex-end",gap:10},children:[(0,n.jsx)("button",{onClick:()=>{A(e=>e+(e?"\n\n":"")+D),eo(!1),requestAnimationFrame(()=>{eW.current&&(eW.current.focus(),eW.current.style.height="auto",eW.current.style.height=`${Math.min(eW.current.scrollHeight,200)}px`)})},style:{padding:"8px 16px",background:"rgba(129,140,248,0.1)",border:"1px solid rgba(129,140,248,0.25)",borderRadius:8,color:"rgb(99,102,241)",cursor:"pointer",fontSize:13,fontWeight:600,transition:"background 0.12s"},onMouseEnter:e=>e.currentTarget.style.background="rgba(129,140,248,0.18)",onMouseLeave:e=>e.currentTarget.style.background="rgba(129,140,248,0.1)",children:"插入到输入框"}),(0,n.jsx)("button",{onClick:async()=>{try{await navigator.clipboard.writeText(D),ec(!0),setTimeout(()=>ec(!1),2e3)}catch(e){console.error("Failed to copy text:",e)}},style:{padding:"8px 18px",background:ed?"#10B981":"var(--accent)",border:"none",borderRadius:8,color:"#fff",cursor:"pointer",fontSize:13,fontWeight:600,display:"flex",alignItems:"center",gap:6,transition:"background 0.15s"},onMouseEnter:e=>{ed||(e.currentTarget.style.filter="brightness(1.15)")},onMouseLeave:e=>{e.currentTarget.style.filter="none"},children:ed?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("polyline",{points:"20 6 9 17 4 12"})}),"已复制!"]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),(0,n.jsx)("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]}),"复制提示词"]})})]})]})]}))]})});function eT(e){return"user"===e.role?{bg:"rgba(37,99,235,0.18)",border:"rgba(37,99,235,0.7)"}:{bg:"rgba(107,114,128,0.12)",border:"rgba(107,114,128,0.5)"}}function ez({messages:e,streamingMessage:t,scrollContainer:r,messageRefs:i}){let[l,s]=(0,o.useState)(0),[a,d]=(0,o.useState)(1),[c,p]=(0,o.useState)(!1),[x,u]=(0,o.useState)([]),[g,h]=(0,o.useState)(!1),[f,b]=(0,o.useState)(null),y=(0,o.useRef)(!1),v=(0,o.useRef)(null),m=(0,o.useMemo)(()=>t?[...e,t]:e,[e,t]),j=(0,o.useRef)(m);j.current=m;let k=(0,o.useRef)(null);k.current=()=>{let e=r.current;if(!e)return;let t=e.scrollHeight,n=e.clientHeight,o=t-n;p(o>20),o<=0?(s(0),d(1)):(s(e.scrollTop/o),d(n/t));let l=i.current,a=[],c=0,x=j.current;for(let r=0;r<x.length;r++){let n=x[r];if("user"!==n.role&&"assistant"!==n.role)continue;let o=l?.[c];if(c++,("user"===n.role||"assistant"===n.role&&(n.content??[]).some(e=>"text"===e.type))&&o&&t>0){let r=o.getBoundingClientRect(),i=e.getBoundingClientRect(),l=r.top-i.top+e.scrollTop,s=r.height;a.push({topRatio:l/t,heightRatio:s/t,msg:n,index:a.length})}}u(a)};let w=(0,o.useCallback)(()=>k.current(),[]);(0,o.useEffect)(()=>{let e=r.current;if(!e)return;e.addEventListener("scroll",w,{passive:!0});let t=new ResizeObserver(w);return t.observe(e),e.firstElementChild&&t.observe(e.firstElementChild),w(),()=>{e.removeEventListener("scroll",w),t.disconnect()}},[r,w]),(0,o.useEffect)(()=>{let e=setTimeout(w,50);return()=>clearTimeout(e)},[e.length,w]);let S=(0,o.useCallback)(e=>{let t=r.current;if(!t)return;let n=t.scrollHeight-t.clientHeight;n<=0||(t.scrollTop=Math.max(0,Math.min(1-a,e))/(1-a)*n)},[r,a,r.current]),C=(0,o.useCallback)(e=>{if(!c)return;y.current=!0;let t=e.currentTarget.getBoundingClientRect(),r=(e.clientY-t.top)/t.height,n=r-l*(1-a),o=n>=0&&n<=a?n:a/2;S(r-o);let i=e=>{y.current&&S((e.clientY-t.top)/t.height-o)},s=()=>{y.current=!1,window.removeEventListener("mousemove",i),window.removeEventListener("mouseup",s)};window.addEventListener("mousemove",i),window.addEventListener("mouseup",s)},[c,a,l,S]),T=v.current?.clientHeight??600,z=(0,o.useMemo)(()=>{if(!g||0===x.length)return[];let e=x.map(e=>Math.round(e.topRatio*T-11));for(let t=0;t<10;t++){for(let t=1;t<e.length;t++){let r=e[t-1]+22+2;e[t]<r&&(e[t]=r)}for(let t=e.length-2;t>=0;t--){let r=e[t+1]-22-2;e[t]>r&&(e[t]=r)}}for(let t=0;t<e.length;t++)e[t]=Math.max(0,Math.min(T-22,e[t]));return e},[g,x,T]);if(!c)return null;let I=l*(1-a)*100,R=100*a,L=null!==f&&x.length>0?x.reduce((e,t)=>Math.abs(t.topRatio-f)<Math.abs(x[e].topRatio-f)?t.index:e,0):null;return(0,n.jsxs)("div",{ref:v,onMouseDown:C,onMouseEnter:()=>h(!0),onMouseLeave:()=>{h(!1),b(null)},onMouseMove:e=>{let t=e.currentTarget.getBoundingClientRect();b((e.clientY-t.top)/t.height)},style:{width:18,flexShrink:0,position:"relative",cursor:"default",userSelect:"none",borderLeft:"1px solid var(--border)",background:"var(--bg-panel)",overflow:"visible"},children:[(0,n.jsx)("div",{style:{position:"absolute",left:0,right:0,top:`${I}%`,height:`${R}%`,background:"rgba(100,100,100,0.1)",borderTop:"1px solid rgba(100,100,100,0.2)",borderBottom:"1px solid rgba(100,100,100,0.2)",pointerEvents:"none",zIndex:1}}),x.map(e=>{let t=eT(e.msg),r=g&&L===e.index,o="user"===e.msg.role,i=100*e.topRatio;return(0,n.jsx)("div",{style:{position:"absolute",top:`${i}%`,transform:"translateY(-50%)",left:0,right:0,height:"12px",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",zIndex:2},children:(0,n.jsx)("div",{style:{width:o?8:6,height:o?8:6,borderRadius:o?2:"50%",background:t.bg,border:`1.5px solid ${t.border}`,flexShrink:0,transition:"transform 0.1s",transform:r?"scale(1.6)":"scale(1)"}})},e.index)}),(0,n.jsx)("div",{style:{position:"absolute",left:"50%",top:0,bottom:0,width:1,background:"var(--border)",transform:"translateX(-50%)",zIndex:0}}),g&&x.map((e,t)=>{let r=function(e){if("user"===e.role){let t=e.content;return"string"==typeof t?t.slice(0,200):Array.isArray(t)?t.filter(e=>"text"===e.type&&e.text).map(e=>e.text).join("\n").slice(0,200):""}if("assistant"===e.role){let t=e.content??[],r=t.filter(e=>"text"===e.type).map(e=>e.text).join(" ");if(r)return r.slice(0,200);let n=t.filter(e=>"toolCall"===e.type).map(e=>e.toolName);if(n.length)return n.join(", ")}return""}(e.msg),o=eT(e.msg),i=L===e.index;return r&&0!==z.length?(0,n.jsx)("div",{style:{position:"absolute",top:z[t],right:"100%",marginRight:6,background:"var(--bg)",borderTop:`1px solid ${i?o.border:"var(--border)"}`,borderRight:`1px solid ${i?o.border:"var(--border)"}`,borderBottom:`1px solid ${i?o.border:"var(--border)"}`,borderLeft:`2px solid ${o.border}`,borderRadius:4,padding:"2px 7px",width:200,zIndex:100,pointerEvents:"none",opacity:i?1:.45,transition:"top 0.1s, opacity 0.1s"},children:(0,n.jsx)("div",{style:{fontSize:11,color:i?"var(--text)":"var(--text-muted)",lineHeight:1.4,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:r})},e.index):null})]})}function eI(e){if("assistant"!==e.role)return e;let t=e.content;if(!Array.isArray(t))return e;let r=function e(t){if(!Array.isArray(t))return t;let r=[];for(let n of t)if(n&&"text"===n.type&&"string"==typeof n.text){let t=n.text,o=t.indexOf("<think>");if(-1!==o){let n=o+7,i=t.indexOf("</think>",n);if(-1!==i){let l=t.substring(n,i),s=t.substring(i+8);if(o>0){let e=t.substring(0,o);r.push({type:"text",text:e})}if(r.push({type:"thinking",thinking:l}),s){let t=e([{type:"text",text:s}]);r.push(...t)}}else{let e=t.substring(n);if(o>0){let e=t.substring(0,o);r.push({type:"text",text:e})}r.push({type:"thinking",thinking:e})}}else r.push(n)}else r.push(n);return r}(t.map(e=>("object"!=typeof e||null===e||Array.isArray(e)||"toolCall"!==e.type?null:{type:"toolCall",toolCallId:"string"==typeof e.toolCallId?e.toolCallId:"string"==typeof e.id?e.id:"",toolName:"string"==typeof e.toolName?e.toolName:"string"==typeof e.name?e.name:"",input:"object"!=typeof e.input||null===e.input||Array.isArray(e.input)?"object"!=typeof e.arguments||null===e.arguments||Array.isArray(e.arguments)?{}:e.arguments:e.input})??e));return{...e,content:r}}async function eR(e,t){let r=await fetch(`/api/agent/${encodeURIComponent(e)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),n=await r.json().catch(()=>({}));if(!r.ok||n.error)throw Error(n.error??`HTTP ${r.status}`);return n.data}function eL(e,t){switch(t.type){case"start":return{isStreaming:!0,streamingMessage:null};case"update":return{isStreaming:!0,streamingMessage:t.message};case"end":case"reset":return{isStreaming:!1,streamingMessage:null};default:return e}}var eW=r(1463);function eE({session:e,newSessionCwd:t,onAgentEnd:i,onSessionCreated:l,onSessionForked:s,modelsRefreshKey:a,chatInputRef:d,onBranchDataChange:c,onSystemPromptChange:p,onSessionStatsChange:x,onContextUsageChange:u,activeGemId:g}){var h;let f,b,y,[v,m]=(0,o.useState)(null);(0,o.useEffect)(()=>{g?fetch("/api/gem-xy").then(e=>e.json()).then(e=>{let t=e.find(e=>e.id===g);t&&m(`${t.avatar||"\uD83E\uDD16"} ${t.name}`)}).catch(()=>{}):m(null)},[g]);let{loading:j,error:k,messages:w,entryIds:S,streamState:C,agentRunning:T,modelNames:z,modelList:I,modelThinkingLevels:R,modelThinkingLevelMaps:L,toolPreset:W,thinkingLevel:E,retryInfo:M,contextUsage:D,forkingEntryId:$,isCompacting:B,compactError:A,displayModel:O,sessionStats:F,agentPhase:N,isNew:P,messagesEndRef:H,scrollContainerRef:_,lastUserMsgRef:J,handleSend:U,handleAbort:V,handleFork:Y,handleNavigate:K,handleModelChange:G,handleCompact:q,handleSteer:Z,handleFollowUp:X,handleAbortCompaction:Q,handleToolPresetChange:ee,handleThinkingLevelChange:et,handleAgentEventRef:er}=function(e){let{session:t,newSessionCwd:n,onAgentEnd:i,onSessionCreated:l,onSessionForked:s,modelsRefreshKey:a,onBranchDataChange:d,onSystemPromptChange:c}=e,p=null===t&&null!==n,[x,u]=(0,o.useState)(null),[g,h]=(0,o.useState)(!p),[f,b]=(0,o.useState)(null),[y,v]=(0,o.useState)(null),[m,j]=(0,o.useState)([]),[k,w]=(0,o.useState)([]),[S,C]=(0,o.useReducer)(eL,{isStreaming:!1,streamingMessage:null}),[T,z]=(0,o.useState)(!1),[I,R]=(0,o.useState)({}),[L,W]=(0,o.useState)([]),[E,M]=(0,o.useState)({}),[D,$]=(0,o.useState)({}),[B,A]=(0,o.useState)(null),[O,F]=(0,o.useState)("none"),[N,P]=(0,o.useState)("auto"),[H,_]=(0,o.useState)(null),[J,U]=(0,o.useState)(null),[V,Y]=(0,o.useState)(null),[K,G]=(0,o.useState)(null),[q,Z]=(0,o.useState)(null),[X,Q]=(0,o.useState)(null),[ee,et]=(0,o.useState)(!1),[er,en]=(0,o.useState)(null),[eo,ei]=(0,o.useState)(null),[el,es]=(0,o.useState)(null),ea=(0,o.useRef)(null),ed=(0,o.useRef)(t?.id??null),ec=(0,o.useRef)(!1),ep=(0,o.useRef)(!1),ex=(0,o.useRef)(null),eu=(0,o.useRef)(!1),eg=(0,o.useRef)(null),eh=(0,o.useRef)(!1),ef=(0,o.useRef)(null),eb=(0,o.useRef)(null),ey=(0,o.useRef)(null),em=(0,o.useRef)(null),ej=t?.id??null;ej!==el&&(es(ej),ed.current=ej,u(null),j([]),w([]),U(null),Y(null),z(!1),ei(null),et(!1),G(null),eu.current=!1,eh.current=!1,h(null!==ej));let ek=e.setNewSessionModel??A,ew=e.setToolPreset??F,eS=q??x?.context.model??X??null,eC=p?B:eS,eT=(()=>{let e={input:0,output:0,cacheRead:0,cacheWrite:0},t=0;for(let r of m){if("assistant"!==r.role)continue;let n=r.usage;n&&(e.input+=n.input??0,e.output+=n.output??0,e.cacheRead+=n.cacheRead??0,e.cacheWrite+=n.cacheWrite??0,t+=n.cost?.total??0)}return e.input+e.output+e.cacheRead+e.cacheWrite>0?{tokens:e,cost:t}:null})(),ez=(0,o.useCallback)(async(e,t=!1,r=!1)=>{try{t&&h(!0);let n=r?`/api/sessions/${encodeURIComponent(e)}?includeState`:`/api/sessions/${encodeURIComponent(e)}`,o=await fetch(n);if(404===o.status)return t&&(u(null),v(null),j([]),b(null)),null;if(!o.ok)throw Error(`HTTP ${o.status}`);let i=await o.json();return u(i),v(i.leafId),j(i.context.messages),w(i.context.entryIds??[]),Z(null),b(null),!i.agentState?.state?.thinkingLevel&&i.context.thinkingLevel&&"off"!==i.context.thinkingLevel&&P(i.context.thinkingLevel),i.agentState??null}catch(e){return b(String(e)),null}finally{t&&h(!1)}},[]),eW=(0,o.useCallback)(async(e,t)=>{try{let r=t?`/api/sessions/${encodeURIComponent(e)}/context?leafId=${encodeURIComponent(t)}`:`/api/sessions/${encodeURIComponent(e)}/context`,n=await fetch(r);if(!n.ok)throw Error(`HTTP ${n.status}`);let o=await n.json();j(o.context.messages),w(o.context.entryIds??[])}catch(e){console.error("Failed to load context:",e)}},[]),eE=(0,o.useCallback)(async e=>{try{let t=await eR(e,{type:"get_tools"});if(t){let{getPresetFromTools:e}=await r.e(8451).then(r.bind(r,8451));ew(e(t))}}catch(e){console.error("Failed to load tools:",e)}},[ew]),eM=(0,o.useCallback)(e=>(ea.current&&(ea.current.close(),ea.current=null),new Promise(t=>{let r=new EventSource(`/api/agent/${encodeURIComponent(e)}/events`);ea.current=r;let n=!1,o=()=>{n||(n=!0,t())};r.onopen=()=>o(),setTimeout(o,200),r.onmessage=e=>{o();try{let t=JSON.parse(e.data);ex.current?.(t)}catch{}},r.onerror=()=>{ea.current===r&&ec.current&&(r.close(),ea.current=null,setTimeout(()=>{ec.current&&eM(e)},1e3))}})),[]);(0,o.useEffect)(()=>{ec.current=T},[T]),ex.current=(0,o.useCallback)(e=>{switch(e.type){case"agent_start":z(!0),ei({kind:"waiting_model"}),C({type:"start"});break;case"agent_end":em.current&&(clearTimeout(em.current),em.current=null),ey.current=null,z(!1),ep.current=!1,ei(null),_(null),C({type:"end"}),ed.current&&(ez(ed.current),fetch(`/api/agent/${encodeURIComponent(ed.current)}`).then(e=>e.json()).then(e=>{e.state?.contextUsage!==void 0&&U(e.state.contextUsage??null),e.state?.systemPrompt!==void 0&&Y(e.state.systemPrompt??null)}).catch(()=>{})),i?.();break;case"message_start":case"message_update":{let t=e.message;t&&(ey.current=eI(t),em.current||(em.current=setTimeout(()=>{ey.current&&C({type:"update",message:ey.current}),em.current=null},80))),ei(null);break}case"message_end":{em.current&&(clearTimeout(em.current),em.current=null),ey.current=null;let t=e.message;t&&"user"!==t.role&&j(e=>[...e,eI(t)]),C({type:"reset"}),ei({kind:"waiting_model"});break}case"tool_execution_start":{let t=e.toolCallId,r=e.toolName;ei(e=>{let n=e?.kind==="running_tools"?[...e.tools]:[];return n.some(e=>e.id===t)||n.push({id:t,name:r}),{kind:"running_tools",tools:n}});break}case"tool_execution_end":{let t=e.toolCallId;ei(e=>{if(e?.kind!=="running_tools")return e;let r=e.tools.filter(e=>e.id!==t);return 0===r.length?{kind:"waiting_model"}:{kind:"running_tools",tools:r}});break}case"auto_retry_start":_({attempt:e.attempt,maxAttempts:e.maxAttempts,errorMessage:e.errorMessage});break;case"auto_retry_end":_(null);break;case"auto_compaction_start":case"compaction_start":et(!0),en(null);break;case"auto_compaction_end":case"compaction_end":et(!1),e.errorMessage?en(e.errorMessage):!e.aborted&&ed.current&&ez(ed.current)}},[ez,i]);let eD=(0,o.useCallback)(async(e,t)=>{if(!t||0===t.length)return e;let r=L?.find(e=>e.id===eC?.modelId&&e.provider===eC?.provider);if(r&&r.supportsVision||eC&&ev(eC.provider,eC.modelId))return e.trim()||"请分析这张图片。";try{let r=(await Promise.all(t.map(async e=>{let t=await fetch("/api/agent/describe-image",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({image:e.data,mimeType:e.mimeType})});if(!t.ok)throw Error("Failed to describe image");return(await t.json()).description}))).filter(Boolean).join("\n\n");if(r){let t=`[图片描述]:
65
65
  ${r}`;return e.trim()?`${t}
66
66
 
67
- ${e.trim()}`:t}}catch(e){console.error("Failed to describe images for non-vision model:",e)}return e.trim()||"请分析这张图片。"},[L,eC]),e$=(0,o.useCallback)(async(o,i)=>{if(!o.trim()&&!i?.length||T||ep.current)return;ep.current=!0;let s=i?.map(e=>({type:"image",source:{type:"base64",media_type:e.mimeType,data:e.data}})),a={role:"user",content:s?.length?[...o.trim()?[{type:"text",text:o}]:[],...s]:o,timestamp:Date.now()};j(e=>[...e,a]),I(!0),ei({kind:"waiting_model"}),C({type:"start"}),eh.current=!0;let d=i?.map(e=>({type:"image",data:e.data,mimeType:e.mimeType}));try{let s=await eD(o,i);if(p&&n){B&&Q(B);let{PRESET_NONE:t,PRESET_DEFAULT:i,PRESET_FULL:a}=await r.e(8451).then(r.bind(r,8451)),c="none"===F?t:"default"===F?i:a,p=await fetch("/api/agent/new",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:n,type:"prompt",message:s,toolNames:c,...d?.length?{images:d}:{},...B?{provider:B.provider,modelId:B.modelId}:{},..."auto"!==N?{thinkingLevel:N}:{},...e.activeGemId?{gemId:e.activeGemId}:{}})});if(!p.ok)throw Error(`HTTP ${p.status}`);let x=(await p.json()).sessionId;ed.current=x,await eM(x),l?.({id:x,path:"",cwd:n,name:void 0,created:new Date().toISOString(),modified:new Date().toISOString(),messageCount:1,firstMessage:o})}else t&&(await eM(t.id),eR(t.id,{type:"prompt",message:s,...d?.length?{images:d}:{}}).catch(e=>{console.error("Prompt command error:",e),ep.current=!1}))}catch(e){console.error("Failed to send message:",e),I(!1),ei(null),C({type:"end"}),ep.current=!1}},[p,n,B,F,N,t,T,eM,l,e.activeGemId,eD]),eB=(0,o.useCallback)(async()=>{let e=ed.current;if(e)try{await eR(e,{type:"abort"})}catch(e){console.error("Failed to abort:",e)}},[]),eA=(0,o.useCallback)(async e=>{let t=ed.current;if(t){q(e);try{let{cancelled:r,newSessionId:n}=await eR(t,{type:"fork",entryId:e})??{};!r&&n&&s?.(n)}catch(e){console.error("Fork failed:",e)}finally{q(null)}}},[s]),eF=(0,o.useCallback)(async e=>{let t=ed.current;t&&(eR(t,{type:"navigate_tree",targetId:e}).catch(()=>{}),v(e),await eW(t,e))},[eW]),eO=(0,o.useCallback)(async e=>{v(e);let t=ed.current;t&&(await eW(t,e),e&&eR(t,{type:"navigate_tree",targetId:e}).catch(()=>{}))},[eW]),eN=(0,o.useCallback)(async(e,t)=>{if(p)return void ek({provider:e,modelId:t});let r=ed.current;if(r)try{await eR(r,{type:"set_model",provider:e,modelId:t}),Z({provider:e,modelId:t})}catch(e){console.error("Failed to set model:",e)}},[p,ek]),eP=(0,o.useCallback)(async()=>{let e=ed.current;if(e&&!ee){et(!0),en(null);try{await eR(e,{type:"compact"}),await eI(e,!0)}catch(e){en(e instanceof Error?e.message:String(e))}finally{et(!1)}}},[ee,eI]),eH=(0,o.useCallback)(async(e,t)=>{let r=ed.current;if(!r)return;j(t=>[...t,{role:"user",content:`[steer] ${e}`,timestamp:Date.now()}]);let n=t?.map(e=>({type:"image",data:e.data,mimeType:e.mimeType}));try{let o=await eD(e,t);await eR(r,{type:"steer",message:o,...n?.length?{images:n}:{}})}catch(e){console.error("Failed to steer:",e)}},[eD]),e_=(0,o.useCallback)(async(e,t)=>{let r=ed.current;if(!r)return;j(t=>[...t,{role:"user",content:e,timestamp:Date.now()}]);let n=t?.map(e=>({type:"image",data:e.data,mimeType:e.mimeType}));try{let o=await eD(e,t);await eR(r,{type:"follow_up",message:o,...n?.length?{images:n}:{}})}catch(e){console.error("Failed to follow up:",e)}},[eD]),eJ=(0,o.useCallback)(async()=>{let e=ed.current;if(e)try{await eR(e,{type:"abort_compaction"})}catch(e){console.error("Failed to abort compaction:",e)}},[]),eU=(0,o.useCallback)(async e=>{if(P(e),"auto"===e)return;let t=ed.current;if(t)try{await eR(t,{type:"set_thinking_level",level:e})}catch(e){console.error("Failed to set thinking level:",e)}},[]),eV=(0,o.useCallback)(async e=>{let{PRESET_NONE:t,PRESET_DEFAULT:n,PRESET_FULL:o}=await r.e(8451).then(r.bind(r,8451));ew(e);let i=ed.current;if(i)try{await eR(i,{type:"set_tools",toolNames:"none"===e?t:"default"===e?n:o})}catch(e){console.error("Failed to set tools:",e)}},[ew]),eY=(0,o.useCallback)((e="smooth")=>{ef.current?.scrollIntoView({behavior:e})},[]),eK=(0,o.useCallback)(()=>{let e=ey.current,t=eg.current;if(!e||!t)return;let r=t.getBoundingClientRect().top-e.getBoundingClientRect().top+e.scrollTop;e.scrollTo({top:r-16,behavior:"smooth"})},[]);return(0,o.useEffect)(()=>(t&&(ed.current=t.id,eI(t.id,!0,!0).then(e=>{e?.running?(eE(t.id),e.state?.isStreaming&&(I(!0),ei({kind:"waiting_model"}),eM(t.id))):ea.current&&(ea.current.close(),ea.current=null),e?.state&&(void 0!==e.state.isCompacting&&et(e.state.isCompacting),void 0!==e.state.contextUsage&&U(e.state.contextUsage??null),void 0!==e.state.systemPrompt&&Y(e.state.systemPrompt??null),void 0!==e.state.thinkingLevel&&P(e.state.thinkingLevel??"auto"))})),()=>{ea.current?.close(),ea.current=null,em.current&&(clearTimeout(em.current),em.current=null),eb.current=null}),[t?.id,eI,eE,eM]),(0,o.useEffect)(()=>{c?.(V)},[V,c]),(0,o.useEffect)(()=>{d&&d(x?.tree??[],b,eO)},[x?.tree,b,eO,d]),(0,o.useEffect)(()=>{m.length>0&&(eh.current?(eh.current=!1,eu.current=!0,eK()):eu.current?ec.current||eY("smooth"):(eu.current=!0,eY("instant")))},[m.length,T,eY,eK]),(0,o.useEffect)(()=>{fetch("/api/models").then(e=>e.json()).then(e=>{if(R(e.models),e.thinkingLevels&&M(e.thinkingLevels),e.thinkingLevelMaps&&$(e.thinkingLevelMaps),e.modelList&&(W(e.modelList),p&&e.modelList.length>0)){let t=e.defaultModel,r=t&&e.modelList.find(e=>e.id===t.modelId&&e.provider===t.provider);ek(r?{provider:r.provider,modelId:r.id}:{provider:e.modelList[0].provider,modelId:e.modelList[0].id})}}).catch(()=>{})},[p,a,ek]),(0,o.useEffect)(()=>{if(!er)return;let e=setTimeout(()=>en(null),3e3);return()=>clearTimeout(e)},[er]),{data:x,loading:g,error:f,activeLeafId:b,messages:m,entryIds:k,streamState:S,agentRunning:T,modelNames:z,modelList:L,modelThinkingLevels:E,modelThinkingLevelMaps:D,newSessionModel:B,toolPreset:F,thinkingLevel:N,retryInfo:H,contextUsage:J,systemPrompt:V,forkingEntryId:K,isCompacting:ee,compactError:er,currentModel:eS,displayModel:eC,sessionStats:eT,agentPhase:eo,isNew:p,sessionIdRef:ed,eventSourceRef:ea,messagesEndRef:ef,scrollContainerRef:ey,lastUserMsgRef:eg,pendingScrollToUserRef:eh,initialScrollDoneRef:eu,handleSend:e$,handleAbort:eB,handleFork:eA,handleNavigate:eF,handleModelChange:eN,handleCompact:eP,handleSteer:eH,handleFollowUp:e_,handleAbortCompaction:eJ,handleToolPresetChange:eV,handleThinkingLevelChange:eU,loadTools:eE,setActiveLeafId:v,setData:u,setMessages:j,dispatch:C,setAgentRunning:I,setForkingEntryId:q,handleAgentEventRef:ex}}({session:e,newSessionCwd:t,onAgentEnd:i,onSessionCreated:l,onSessionForked:s,modelsRefreshKey:a,onBranchDataChange:c,onSystemPromptChange:p,activeGemId:g}),{soundEnabled:en,onSoundToggle:eo,playDoneSound:ei}=function(){let[e,t]=(0,o.useState)(()=>{let e=localStorage.getItem("pi-sound-enabled");return null===e||"true"===e}),r=(0,o.useRef)(e);return(0,o.useEffect)(()=>{r.current=e},[e]),{soundEnabled:e,onSoundToggle:(0,o.useCallback)(()=>{t(e=>{let t=!e;return localStorage.setItem("pi-sound-enabled",String(t)),t})},[]),playDoneSound:(0,o.useCallback)(()=>{if(r.current)try{let e=new AudioContext,t=e.currentTime;[523.25,659.25].forEach((r,n)=>{let o=e.createOscillator(),i=e.createGain();o.connect(i),i.connect(e.destination),o.type="sine",o.frequency.value=r;let l=t+.18*n;i.gain.setValueAtTime(0,l),i.gain.linearRampToValueAtTime(.18,l+.02),i.gain.exponentialRampToValueAtTime(.001,l+.45),o.start(l),o.stop(l+.45)}),setTimeout(()=>e.close(),1200)}catch{}},[]),soundEnabledRef:r}}(),el=(0,o.useRef)(ei);el.current=ei;let es=(0,o.useRef)(en);es.current=en;let ea=er.current;(0,o.useEffect)(()=>{er.current=e=>{"agent_end"===e.type&&es.current&&el.current(),ea?.(e)}},[ea,er]);let ed=O?`${O.tokens.input}|${O.tokens.output}|${O.tokens.cacheRead}|${O.tokens.cacheWrite}|${O.cost??0}`:null,ec=(0,o.useRef)(O);ec.current=O,(0,o.useEffect)(()=>{x?.(ec.current)},[ed,x]),(0,o.useEffect)(()=>()=>{x?.(null)},[x]);let ep=D?`${D.percent??"null"}|${D.contextWindow}|${D.tokens??"null"}`:null,ex=(0,o.useRef)(D);ex.current=D,(0,o.useEffect)(()=>{u?.(ex.current)},[ep,u]),(0,o.useEffect)(()=>()=>{u?.(null)},[u]);let{isDragOver:eg,handleDragEnter:eh,handleDragOver:ef,handleDragLeave:ey,handleDrop:eb}=function(e){let[t,r]=(0,o.useState)(!1),n=(0,o.useRef)(0),i=(0,o.useCallback)(e=>{Array.from(e.dataTransfer.items).some(e=>e.type.startsWith("image/"))&&(e.preventDefault(),n.current+=1,r(!0))},[]),l=(0,o.useCallback)(e=>{Array.from(e.dataTransfer.items).some(e=>e.type.startsWith("image/"))&&e.preventDefault()},[]);return{isDragOver:t,handleDragEnter:i,handleDragOver:l,handleDragLeave:(0,o.useCallback)(()=>{n.current-=1,n.current<=0&&(n.current=0,r(!1))},[]),handleDrop:(0,o.useCallback)(t=>{t.preventDefault(),n.current=0,r(!1),e(Array.from(t.dataTransfer.files))},[e])}}((0,o.useCallback)(e=>{let t=e.filter(e=>e.type.startsWith("image/")),r=e.filter(e=>!e.type.startsWith("image/"));t.length>0&&d?.current?.addImages(t),r.length>0&&d?.current?.addFiles?.(r)},[d])),em=(h=w.filter(e=>"user"===e.role||"assistant"===e.role).length,(f=(0,o.useRef)([])).current=Array(h).fill(null).map((e,t)=>f.current[t]??null),f),ej=(0,o.useMemo)(()=>{let e=new Map;for(let t of w)"toolResult"===t.role&&e.set(t.toolCallId,t);return e},[w]),ek=P&&0===w.length&&!C.isStreaming&&!T,ew=F?R[`${F.provider}:${F.modelId}`]??null:null,eS=F?L[`${F.provider}:${F.modelId}`]??null:null,eT=(0,n.jsx)(eC,{ref:d,onSend:U,onAbort:V,onSteer:T?Z:void 0,onFollowUp:T?X:void 0,isStreaming:T,model:F,modelNames:I,modelList:z,onModelChange:q,onCompact:e||P?G:void 0,onAbortCompaction:Q,isCompacting:B,compactError:A,toolPreset:W,onToolPresetChange:e||P?ee:void 0,thinkingLevel:E,onThinkingLevelChange:e||P?et:void 0,availableThinkingLevels:ew,thinkingLevelMap:eS,retryInfo:M,soundEnabled:en,onSoundToggle:eo,cwd:e?.cwd??t??null});return j?(0,n.jsx)("div",{className:"flex h-full items-center justify-center text-text-muted",children:"Loading session..."}):k?(0,n.jsx)("div",{className:"flex h-full items-center justify-center text-red-400",children:k}):(0,n.jsxs)("div",{className:"relative flex h-full flex-col overflow-hidden",onDragEnter:eh,onDragOver:ef,onDragLeave:ey,onDrop:eb,children:[eg&&(0,n.jsxs)("div",{className:"pointer-events-none absolute inset-0 z-50 flex animate-[drop-zone-in_0.15s_ease_both] items-center justify-center bg-[rgba(37,99,235,0.06)] backdrop-blur-[1px]",children:[(0,n.jsx)("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:[0,.8,1.6].map(e=>(0,n.jsx)("div",{className:"absolute h-[720px] w-[720px] rounded-full border-[1.5px] border-solid border-[rgba(37,99,235,0.5)] animate-[drop-ripple_2.4s_ease-out_infinite_backwards]",style:{transformOrigin:"center",animationDelay:`${e}s`}},e))}),(0,n.jsxs)("svg",{width:"280",height:"280",viewBox:"0 0 140 140",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"drop-shadow-[0_6px_18px_rgba(37,99,235,0.18)]",children:[(0,n.jsx)("rect",{x:"28",y:"44",width:"84",height:"60",rx:"8",fill:"rgba(37,99,235,0.08)",stroke:"rgba(37,99,235,0.50)",strokeWidth:"1.8"}),(0,n.jsx)("path",{d:"M36 100 L54 72 L68 88 L80 74 L104 100Z",fill:"rgba(37,99,235,0.16)",stroke:"rgba(37,99,235,0.40)",strokeWidth:"1.4",strokeLinejoin:"round"}),(0,n.jsx)("circle",{cx:"96",cy:"58",r:"8",fill:"rgba(37,99,235,0.22)",stroke:"rgba(37,99,235,0.55)",strokeWidth:"1.6"}),(0,n.jsxs)("g",{stroke:"rgba(37,99,235,0.45)",strokeWidth:"1.4",strokeLinecap:"round",children:[(0,n.jsx)("line",{x1:"96",y1:"46",x2:"96",y2:"43"}),(0,n.jsx)("line",{x1:"96",y1:"70",x2:"96",y2:"73"}),(0,n.jsx)("line",{x1:"84",y1:"58",x2:"81",y2:"58"}),(0,n.jsx)("line",{x1:"108",y1:"58",x2:"111",y2:"58"}),(0,n.jsx)("line",{x1:"87.5",y1:"49.5",x2:"85.4",y2:"47.4"}),(0,n.jsx)("line",{x1:"104.5",y1:"66.5",x2:"106.6",y2:"68.6"}),(0,n.jsx)("line",{x1:"104.5",y1:"49.5",x2:"106.6",y2:"47.4"}),(0,n.jsx)("line",{x1:"87.5",y1:"66.5",x2:"85.4",y2:"68.6"})]})]})]}),ek?(0,n.jsx)("div",{className:"flex flex-1 flex-col items-center justify-center overflow-y-auto px-4 py-8",children:(0,n.jsxs)("div",{className:"w-full max-w-[820px]",children:[(0,n.jsxs)("div",{className:"mb-3",style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,marginLeft:16,marginRight:52,fontFamily:"var(--font-mono)"},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:10,minWidth:0,flex:1,lineHeight:1.4},children:[(0,n.jsx)("span",{style:{fontSize:28,fontWeight:700,letterSpacing:"-0.02em",color:"var(--text)"},children:"✒️"}),(0,n.jsxs)("span",{style:{fontSize:22,color:"var(--text)",fontWeight:700,letterSpacing:"-0.01em"},children:["ink-xY Novel Studio",v?` [${v}]`:""]})]}),(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-end",gap:2,flexShrink:0},children:[(0,n.jsxs)("span",{style:{fontSize:11,color:"var(--text-muted)"},children:["web ",(0,n.jsxs)("span",{style:{color:"var(--text)"},children:["v",eW.env.NEXT_PUBLIC_APP_VERSION??"0.0.0"]})]}),(0,n.jsxs)("span",{style:{fontSize:11,color:"var(--text-muted)"},children:["pi ",(0,n.jsxs)("span",{style:{color:"var(--text)"},children:["v",eW.env.NEXT_PUBLIC_PI_VERSION??"0.0.0"]})]})]})]}),eT]})}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"relative flex flex-1 overflow-hidden",children:[(0,n.jsx)("div",{ref:_,className:"flex-1 overflow-y-auto pt-4 [scrollbar-width:none]",style:{overflowAnchor:"auto"},children:(0,n.jsxs)("div",{className:"mx-auto max-w-[820px] px-4",children:[(()=>{let r=-1;for(let e=w.length-1;e>=0;e--)if("user"===w[e].role){r=e;break}let o=0;return w.map((i,l)=>{let s="user"===i.role&&l>0&&"assistant"===w[l-1].role?S[l-1]:void 0,a="assistant"===i.role&&l>0&&"user"===w[l-1].role?"string"==typeof w[l-1].content?w[l-1].content:w[l-1].content.filter(e=>"text"===e.type).map(e=>e.text).join("\n"):void 0,c="user"===i.role||"assistant"===i.role,p=c?o++:-1,x=!1;if("assistant"===i.role){x=!0;for(let e=l+1;e<w.length;e++){let t=w[e].role;if("user"===t)break;if("assistant"===t){x=!1;break}}x&&C.isStreaming&&l===w.length-1&&(x=!1)}let u=(0,n.jsx)(eu,{message:i,toolResults:ej,modelNames:I,entryId:S[l],onFork:T||P||0===l&&"user"===i.role?void 0:Y,forking:$===S[l],onNavigate:T?void 0:K,prevAssistantEntryId:T?void 0:s,onEditContent:e=>d?.current?.insertIfEmpty(e),showTimestamp:x,prevTimestamp:l>0?w[l-1].timestamp:void 0,activeModel:F,prevUserContent:a,cwd:e?.cwd||t},l);return c?(0,n.jsx)("div",{ref:e=>{em.current[p]=e,l===r&&(J.current=e)},children:u},l):u})})(),C.isStreaming&&C.streamingMessage&&(b=(y=w.length>0&&"user"===w[w.length-1].role?w[w.length-1]:null)?"string"==typeof y.content?y.content:y.content.filter(e=>"text"===e.type).map(e=>e.text).join("\n"):void 0,(0,n.jsx)(eu,{message:C.streamingMessage,isStreaming:!0,modelNames:I,activeModel:F,prevUserContent:b,cwd:e?.cwd||t})),T&&!C.streamingMessage&&(0,n.jsx)("div",{className:"py-2 text-[13px] text-text-muted",children:(0,n.jsx)("span",{className:"animate-[pulse_1.5s_infinite]",children:function(e){if(e?.kind==="running_tools"){let t=e.tools.map(e=>e.name);return 0===t.length?"Running tool...":1===t.length?`Running ${t[0]}...`:t.length<=3?`Running ${t.join(", ")}...`:`Running ${t.slice(0,2).join(", ")} (+${t.length-2})...`}return e?.kind==="waiting_model"?"Waiting for model...":"Thinking..."}(N)})}),T&&(0,n.jsx)("div",{style:{height:_.current?_.current.clientHeight:"80vh"}}),(0,n.jsx)("div",{ref:H})]})}),(0,n.jsx)(eI,{messages:w,streamingMessage:C.streamingMessage,scrollContainer:_,messageRefs:em})]}),(0,n.jsx)("div",{className:"relative",children:eT})]})]})}var eM=r(9893),eD=r(7644);let e$=new Set;function eB(e){return e$.add(e),()=>{e$.delete(e)}}function eA(){return"u"<typeof document?"light":document.documentElement.classList.contains("dark")?"dark":"light"}function eF(){return"light"}function eO(){let e=(0,o.useSyncExternalStore)(eB,eA,eF);return{theme:e,toggleTheme:(0,o.useCallback)(e=>{let t="dark"===eA()?"light":"dark",r=()=>{"dark"===t?document.documentElement.classList.add("dark"):document.documentElement.classList.remove("dark");try{localStorage.setItem("pi-theme",t)}catch{}e$.forEach(e=>e())},n=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;if("function"!=typeof document.startViewTransition||n)return void r();let o=e?.x??window.innerWidth/2,i=e?.y??window.innerHeight/2,l=Math.hypot(Math.max(o,window.innerWidth-o),Math.max(i,window.innerHeight-i));document.startViewTransition(r).ready.then(()=>{document.documentElement.animate({clipPath:[`circle(0px at ${o}px ${i}px)`,`circle(${l}px at ${o}px ${i}px)`]},{duration:450,easing:"cubic-bezier(0.22, 0.61, 0.36, 1)",pseudoElement:"::view-transition-new(root)"})}).catch(()=>{})},[]),isDark:"dark"===e}}let eN=new Set(["png","jpg","jpeg","gif","webp","svg","bmp","ico","avif"]),eP=new Set(["mp3","wav","ogg","oga","opus","m4a","aac","flac","weba","webm"]),eH=new Set(["pptx","ppt"]);function e_(e,t){if(!t)return null;let r=A(e,t).replace(/\\/g,"/").split("/");return"books"===r[0]&&r[1]?r[1]:null}function eJ(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function eU({oldContent:e,newContent:t}){let r=function(e,t){let r=e.length,n=t.length,o=r+n,i=Array(2*o+1).fill(0),l=[];for(let s=0;s<=o;s++){l.push([...i]);for(let a=-s;a<=s;a+=2){let d,c=(d=a===-s||a!==s&&i[a-1+o]<i[a+1+o]?i[a+1+o]:i[a-1+o]+1)-a;for(;d<r&&c<n&&e[d]===t[c];)d++,c++;if(i[a+o]=d,d>=r&&c>=n){let i=[],a=r,d=n;for(let r=s;r>0;r--){let n,s=l[r-1],c=a-d;n=c===-r||c!==r&&s[c-1+o]<s[c+1+o]?c+1:c-1;let p=s[n+o],x=p-n;for(;a>p&&d>x;)a--,d--,i.unshift({type:"unchanged",text:e[a],lineNo:a+1});r>0&&(a>p?(a--,i.unshift({type:"removed",text:e[a],lineNo:a+1})):(d--,i.unshift({type:"added",text:t[d],lineNo:d+1})))}for(;a>0&&d>0;)a--,d--,i.unshift({type:"unchanged",text:e[a],lineNo:a+1});return i}}}return[...e.map((e,t)=>({type:"removed",text:e,lineNo:t+1})),...t.map((e,t)=>({type:"added",text:e,lineNo:t+1}))]}(e.split("\n"),t.split("\n"));if(!r.some(e=>"unchanged"!==e.type))return(0,n.jsx)("div",{style:{padding:"12px 16px",fontSize:12,color:"var(--text-dim)",fontFamily:"var(--font-mono)"},children:"No changes"});let o=new Set(r.flatMap((e,t)=>"unchanged"!==e.type?[t]:[])),i=new Set;for(let e of o)for(let t=Math.max(0,e-3);t<=Math.min(r.length-1,e+3);t++)i.add(t);let l=[],s=0;for(;s<r.length;)if(i.has(s)){let e=[];for(;s<r.length&&i.has(s);)e.push(r[s]),s++;l.push({hidden:!1,lines:e})}else{let e=0;for(;s<r.length&&!i.has(s);)e++,s++;l.push({hidden:!0,count:e})}let a=[],d=1;for(let e of r)"removed"===e.type?a.push(0):a.push(d++);let c=0;return(0,n.jsx)("div",{style:{fontFamily:"var(--font-mono)",fontSize:13,lineHeight:1.6},children:l.map((e,t)=>{if(e.hidden){let r=(0,n.jsxs)("div",{style:{padding:"2px 16px",color:"var(--text-dim)",background:"var(--bg-panel)",fontSize:11,borderTop:"1px solid var(--border)",borderBottom:"1px solid var(--border)"},children:["... ",e.count," unchanged lines ..."]},t);return c+=e.count,r}let r=e.lines.map((e,t)=>{let r=a[c+t],o="added"===e.type?"rgba(0,200,80,0.12)":"removed"===e.type?"rgba(240,60,60,0.14)":"transparent",i="added"===e.type?"+":"removed"===e.type?"-":" ",l="added"===e.type?"#4ade80":"removed"===e.type?"#f87171":"var(--text-dim)";return(0,n.jsxs)("div",{style:{display:"flex",background:o,borderLeft:"added"===e.type?"3px solid #4ade80":"removed"===e.type?"3px solid #f87171":"3px solid transparent"},children:[(0,n.jsx)("span",{style:{minWidth:44,padding:"0 8px 0 16px",textAlign:"right",color:"var(--text-dim)",userSelect:"none",fontSize:11,lineHeight:1.6,borderRight:"1px solid var(--border)",background:"var(--bg-panel)",flexShrink:0},children:"removed"===e.type?e.lineNo:r||""}),(0,n.jsx)("span",{style:{minWidth:16,padding:"0 6px",color:l,userSelect:"none",flexShrink:0,fontWeight:600},children:i}),(0,n.jsx)("span",{style:{flex:1,padding:"0 8px 0 0",whiteSpace:"pre",color:"var(--text)",overflowX:"auto"},children:e.text||"\xa0"})]},t)});return c+=e.lines.length,(0,n.jsx)("div",{children:r},t)})})}function eV({filePath:e,cwd:t}){let[r,i]=(0,o.useState)(!1),[l,s]=(0,o.useState)(0),[a,d]=(0,o.useState)(null),[c,p]=(0,o.useState)(null),[x,u]=(0,o.useState)(null),g=(0,o.useRef)(null),h=B(e).toLowerCase().split(".").pop()??"";(0,o.useEffect)(()=>{s(0),d(null),p(null),u(null),i(!1),g.current&&(g.current.close(),g.current=null);let t=$(e),r=new EventSource(`/api/files/${t}?type=watch`);g.current=r;let n=null;return r.addEventListener("change",e=>{try{let t=JSON.parse(e.data);"number"==typeof t.size&&d(t.size)}catch{}n&&clearTimeout(n),n=setTimeout(()=>{s(e=>e+1)},1e3)}),r.addEventListener("error",()=>i(!1)),r.onerror=()=>i(!1),()=>{n&&clearTimeout(n),r.close(),g.current=null}},[e]);let f=$(e),y=`/api/files/${f}?type=read${l?`&v=${l}`:""}`,b=null!=a?eJ(a):null;return(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"4px 16px",borderBottom:"1px solid var(--border)",fontSize:11,color:"var(--text-dim)",background:"var(--bg)",flexShrink:0},children:[(0,n.jsx)("span",{style:{fontFamily:"var(--font-mono)"},title:e,children:A(e,t)}),(0,n.jsx)("span",{style:{marginLeft:"auto"},children:h||"image"}),c&&(0,n.jsxs)("span",{children:[c.w," \xd7 ",c.h]}),b&&(0,n.jsx)("span",{children:b}),(0,n.jsxs)("span",{title:r?"Live sync active":"Not watching",style:{display:"flex",alignItems:"center",gap:4,color:r?"#4ade80":"var(--text-dim)"},children:[(0,n.jsx)("span",{style:{width:7,height:7,borderRadius:"50%",background:r?"#4ade80":"var(--border)",display:"inline-block",boxShadow:r?"0 0 4px #4ade80":"none"}}),r?"live":"static"]})]}),(0,n.jsx)("div",{style:{flex:1,overflow:"auto",background:"var(--bg-panel)",display:"flex",alignItems:"center",justifyContent:"center",padding:16,backgroundImage:"linear-gradient(45deg, var(--bg) 25%, transparent 25%), linear-gradient(-45deg, var(--bg) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, var(--bg) 75%), linear-gradient(-45deg, transparent 75%, var(--bg) 75%)",backgroundSize:"16px 16px",backgroundPosition:"0 0, 0 8px, 8px -8px, -8px 0px"},children:x?(0,n.jsx)("div",{style:{color:"#f87171",fontSize:13},children:x}):(0,n.jsx)("img",{src:y,alt:e,onLoad:e=>{let t=e.currentTarget;p({w:t.naturalWidth,h:t.naturalHeight})},onError:()=>u("Failed to load image"),style:{maxWidth:"100%",maxHeight:"100%",objectFit:"contain",boxShadow:"0 2px 8px rgba(0,0,0,0.15)"}})})]})}function eY({filePath:e,cwd:t}){let[r,i]=(0,o.useState)(!1),[l,s]=(0,o.useState)(0),[a,d]=(0,o.useState)(null),[c,p]=(0,o.useState)(null),[x,u]=(0,o.useState)(null),g=(0,o.useRef)(null),h=B(e).toLowerCase().split(".").pop()??"";(0,o.useEffect)(()=>{s(0),d(null),p(null),u(null),i(!1),g.current&&(g.current.close(),g.current=null);let t=$(e),r=new EventSource(`/api/files/${t}?type=watch`);g.current=r;let n=null;return r.addEventListener("change",e=>{try{let t=JSON.parse(e.data);"number"==typeof t.size&&d(t.size)}catch{}p(null),u(null),n&&clearTimeout(n),n=setTimeout(()=>{s(e=>e+1)},1e3)}),r.addEventListener("error",()=>i(!1)),r.onerror=()=>i(!1),()=>{n&&clearTimeout(n),r.close(),g.current=null}},[e]);let f=$(e),y=`/api/files/${f}?type=read${l?`&v=${l}`:""}`;return(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"4px 16px",borderBottom:"1px solid var(--border)",fontSize:11,color:"var(--text-dim)",background:"var(--bg)",flexShrink:0},children:[(0,n.jsx)("span",{style:{fontFamily:"var(--font-mono)"},title:e,children:A(e,t)}),(0,n.jsx)("span",{style:{marginLeft:"auto"},children:h||"audio"}),null!=c&&(0,n.jsx)("span",{children:function(e){if(!Number.isFinite(e))return"";let t=Math.round(e),r=Math.floor(t/60);return`${r}:${String(t%60).padStart(2,"0")}`}(c)}),null!=a&&(0,n.jsx)("span",{children:eJ(a)}),(0,n.jsxs)("span",{title:r?"Live sync active":"Not watching",style:{display:"flex",alignItems:"center",gap:4,color:r?"#4ade80":"var(--text-dim)"},children:[(0,n.jsx)("span",{style:{width:7,height:7,borderRadius:"50%",background:r?"#4ade80":"var(--border)",display:"inline-block",boxShadow:r?"0 0 4px #4ade80":"none"}}),r?"live":"static"]})]}),(0,n.jsx)("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",padding:24,background:"var(--bg-panel)"},children:(0,n.jsxs)("div",{style:{width:"min(680px, 100%)"},children:[x&&(0,n.jsx)("div",{style:{color:"#f87171",fontSize:13,marginBottom:12,textAlign:"center"},children:x}),(0,n.jsx)("audio",{controls:!0,preload:"metadata",src:y,onLoadedMetadata:e=>p(e.currentTarget.duration),onError:()=>u("Failed to load audio"),style:{width:"100%"}},y)]})})]})}function eK({src:e}){let t=(0,o.useRef)(null),i=(0,o.useRef)(null),l=(0,o.useRef)(null),s=(0,o.useRef)(null),[a,d]=(0,o.useState)(null),[c,p]=(0,o.useState)(0),[x,u]=(0,o.useState)(0),[g,h]=(0,o.useState)(!0),[f,y]=(0,o.useState)(null),[b,v]=(0,o.useState)(null),[m,j]=(0,o.useState)(null),[k,w]=(0,o.useState)(!1),[S,C]=(0,o.useState)(null);(0,o.useEffect)(()=>{if(!i.current)return;let e=i.current.getBoundingClientRect();e.width>0&&e.height>0&&v({width:e.width,height:e.height});let t=new ResizeObserver(e=>{if(!e||0===e.length)return;let{width:t,height:r}=e[0].contentRect;t>0&&r>0&&v({width:t,height:r})});return t.observe(i.current),()=>{t.disconnect()}},[]),(0,o.useEffect)(()=>{if(!k||!s.current)return;let e=s.current.getBoundingClientRect();e.width>0&&e.height>0&&C({width:e.width,height:e.height});let t=new ResizeObserver(e=>{if(!e||0===e.length)return;let{width:t,height:r}=e[0].contentRect;t>0&&r>0&&C({width:t,height:r})});return t.observe(s.current),()=>{t.disconnect()}},[k]),(0,o.useEffect)(()=>{let n=!0,o=null;return async function(){try{h(!0),y(null);let i=await fetch(e);if(!i.ok)throw Error(`Failed to load file: ${i.statusText}`);let l=await i.arrayBuffer();if(!n)return;let{PPTXViewer:s}=await Promise.all([r.e(5647),r.e(2767),r.e(9900),r.e(2479)]).then(r.bind(r,9603));if(!n)return;let a=new s({canvas:t.current,slideSizeMode:"fit",autoChartRerenderDelayMs:200});if(o=a,await a.loadFile(new Uint8Array(l)),!n)return;u(o.getSlideCount()),p(o.getCurrentSlideIndex());let c=16/9,x=o.processor;if(x){if("function"==typeof x.getSlideDimensions){let e=x.getSlideDimensions();e&&e.cx&&e.cy&&(c=e.cx/e.cy)}else if(x.presentation?.slideSize){let e=x.presentation.slideSize;e&&e.cx&&e.cy&&(c=e.cx/e.cy)}}j(c),d(o),h(!1)}catch(t){let e=t instanceof Error?t.message:String(t);console.error("PPTX render error:",t),n&&(y(e||"Failed to render PowerPoint presentation"),h(!1))}}(),()=>{if(n=!1,o)try{o.destroy()}catch{}}},[e]);let T=m||16/9,I=0,z=0;if(b){let e=Math.max(10,b.width-32),t=Math.max(10,b.height-32);e/t>T?(z=t,I=t*T):(I=e,z=e/T)}let R=0,L=0;if(k&&S){let e=Math.max(10,S.width-48),t=Math.max(10,S.height-80);e/t>T?(L=t,R=t*T):(R=e,L=e/T)}(0,o.useEffect)(()=>{if(!a||!t.current||0===I||0===z||k)return;let e=!0;return async function(){if(a)try{await a.renderSlide(c,t.current,{quality:"high"})}catch(t){e&&console.error("Render slide error:",t)}}(),()=>{e=!1}},[a,c,I,z,k]),(0,o.useEffect)(()=>{if(!k||!a||!l.current||0===R||0===L)return;let e=!0;return async function(){if(a)try{await a.renderSlide(c,l.current,{quality:"high"})}catch(t){e&&console.error("Render modal slide error:",t)}}(),()=>{e=!1}},[k,a,c,R,L]);let W=()=>{a&&c<x-1&&p(c+1)},E=()=>{a&&c>0&&p(c-1)};return(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%",width:"100%",overflow:"hidden"},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"6px 16px",background:"var(--bg)",borderBottom:"1px solid var(--border)",flexShrink:0},children:[(0,n.jsx)("div",{style:{display:"flex",alignItems:"center",gap:12},children:(0,n.jsx)("span",{style:{fontSize:11,color:"var(--text-muted)",fontWeight:500},children:x>0?`Slide ${c+1} of ${x}`:"Loading slides..."})}),(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[(0,n.jsx)("button",{onClick:E,disabled:g||0===c,style:{padding:"4px 10px",fontSize:11,borderRadius:4,border:"1px solid var(--border)",background:"var(--bg-hover)",color:"var(--text)",cursor:g||0===c?"default":"pointer",opacity:g||0===c?.5:1},children:"◀ Prev"}),(0,n.jsx)("button",{onClick:W,disabled:g||c===x-1,style:{padding:"4px 10px",fontSize:11,borderRadius:4,border:"1px solid var(--border)",background:"var(--bg-hover)",color:"var(--text)",cursor:g||c===x-1?"default":"pointer",opacity:g||c===x-1?.5:1},children:"Next ▶"}),(0,n.jsx)("button",{onClick:()=>w(!0),disabled:g||0===x,title:"Open in fullscreen zoom",style:{padding:"4px 10px",fontSize:11,borderRadius:4,border:"1px solid var(--border)",background:"var(--bg-hover)",color:"var(--text)",cursor:g||0===x?"default":"pointer",opacity:g||0===x?.5:1},children:"\uD83D\uDD0D Zoom"}),(0,n.jsx)("a",{href:e,download:!0,title:"Download original file",style:{padding:"4px 10px",fontSize:11,borderRadius:4,border:"1px solid var(--border)",background:"var(--accent)",color:"white",textDecoration:"none",fontWeight:500,marginLeft:6},children:"⬇️ Download"})]})]}),(0,n.jsxs)("div",{ref:i,style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",background:"var(--bg-panel)",position:"relative",overflow:"hidden"},children:[g&&(0,n.jsx)("div",{style:{position:"absolute",zIndex:10,background:"rgba(0,0,0,0.05)",inset:0,display:"flex",alignItems:"center",justifyContent:"center",color:"var(--text-muted)",fontSize:13},children:"Rendering slide..."}),f?(0,n.jsx)("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",padding:16},children:(0,n.jsxs)("div",{style:{padding:24,background:"var(--bg-panel)",borderRadius:8,border:"1px solid var(--border)",textAlign:"center",maxWidth:400},children:[(0,n.jsx)("div",{style:{fontSize:36,marginBottom:12},children:"⚠️"}),(0,n.jsx)("div",{style:{fontSize:14,fontWeight:600,color:"#f87171",marginBottom:8},children:"Local Preview Failed"}),(0,n.jsx)("div",{style:{fontSize:12,color:"var(--text-muted)",marginBottom:16},children:f}),(0,n.jsx)("a",{href:e,download:!0,style:{padding:"6px 16px",background:"var(--accent)",color:"white",borderRadius:4,textDecoration:"none",fontSize:12,fontWeight:500,display:"inline-block"},children:"⬇️ Download File"})]})}):(0,n.jsx)("canvas",{ref:t,style:{width:`${Math.round(I)}px`,height:`${Math.round(z)}px`,boxShadow:"0 4px 12px rgba(0,0,0,0.15)",background:"white",display:"block",visibility:g&&0===x?"hidden":"visible"}})]}),k&&(0,n.jsxs)("div",{style:{position:"fixed",inset:0,zIndex:1e3,background:"rgba(10, 10, 10, 0.95)",backdropFilter:"blur(8px)",display:"flex",flexDirection:"column",padding:"20px 24px",color:"white"},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:16,flexShrink:0},children:[(0,n.jsx)("span",{style:{fontSize:13,color:"#ccc",fontWeight:500},children:x>0?`Slide ${c+1} of ${x}`:""}),(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[(0,n.jsx)("button",{onClick:E,disabled:0===c,style:{padding:"6px 14px",fontSize:12,borderRadius:4,border:"1px solid #444",background:"#222",color:"white",cursor:0===c?"default":"pointer",opacity:0===c?.5:1},children:"◀ Prev"}),(0,n.jsx)("button",{onClick:W,disabled:c===x-1,style:{padding:"6px 14px",fontSize:12,borderRadius:4,border:"1px solid #444",background:"#222",color:"white",cursor:c===x-1?"default":"pointer",opacity:c===x-1?.5:1},children:"Next ▶"}),(0,n.jsx)("button",{onClick:()=>w(!1),style:{padding:"6px 16px",fontSize:12,borderRadius:4,border:"none",background:"#ef4444",color:"white",cursor:"pointer",fontWeight:600,marginLeft:12},children:"✕ Close"})]})]}),(0,n.jsx)("div",{ref:s,style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",position:"relative"},children:R>0&&L>0&&(0,n.jsx)("canvas",{ref:l,style:{width:`${Math.round(R)}px`,height:`${Math.round(L)}px`,boxShadow:"0 10px 30px rgba(0,0,0,0.5)",background:"white",display:"block"}})})]})]})}function eq({filePath:e,cwd:t}){let[r,i]=(0,o.useState)(!1),[l,s]=(0,o.useState)(0),[a,d]=(0,o.useState)(null),[c,p]=(0,o.useState)(null),x=(0,o.useRef)(null),u=B(e).toLowerCase().split(".").pop()??"";(0,o.useEffect)(()=>{s(0),d(null),p(null),i(!1),x.current&&(x.current.close(),x.current=null);let t=$(e),r=new EventSource(`/api/files/${t}?type=watch`);x.current=r;let n=null;return r.addEventListener("change",e=>{try{let t=JSON.parse(e.data);"number"==typeof t.size&&d(t.size)}catch{}n&&clearTimeout(n),n=setTimeout(()=>{s(e=>e+1)},1500)}),r.addEventListener("error",()=>i(!1)),r.onerror=()=>i(!1),()=>{n&&clearTimeout(n),r.close(),x.current=null}},[e]);let g=$(e),h=`/api/files/${g}?type=read${l?`&v=${l}`:""}`,f=null!=a?eJ(a):null,y=function(e){if(!e||"localhost"===e||"127.0.0.1"===e||"::1"===e||"[::1]"===e)return!0;let t=e.match(/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/);if(t){let[,e,r]=t.map(Number);if(10===e||172===e&&r>=16&&r<=31||192===e&&168===r||169===e&&254===r||127===e)return!0}return!!(e.startsWith("[fe8")||e.startsWith("[fc")||e.startsWith("[fd")||e.startsWith("fe8")||e.startsWith("fc")||e.startsWith("fd"))}(window.location.hostname);return(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"4px 16px",borderBottom:"1px solid var(--border)",fontSize:11,color:"var(--text-dim)",background:"var(--bg)",flexShrink:0},children:[(0,n.jsx)("span",{style:{fontFamily:"var(--font-mono)"},title:e,children:A(e,t)}),(0,n.jsx)("span",{style:{marginLeft:"auto"},children:u.toUpperCase()}),f&&(0,n.jsx)("span",{children:f}),(0,n.jsxs)("span",{title:r?"Live sync active":"Not watching",style:{display:"flex",alignItems:"center",gap:4,color:r?"#4ade80":"var(--text-dim)"},children:[(0,n.jsx)("span",{style:{width:7,height:7,borderRadius:"50%",background:r?"#4ade80":"var(--border)",display:"inline-block",boxShadow:r?"0 0 4px #4ade80":"none"}}),r?"live":"static"]})]}),(0,n.jsx)("div",{style:{flex:1,overflow:"auto",background:"var(--bg-panel)",display:"flex",flexDirection:"column"},children:c?(0,n.jsx)("div",{style:{color:"#f87171",fontSize:13,padding:16},children:c}):y?(0,n.jsx)(eK,{filePath:e,src:h,formatSizeStr:f,ext:u}):(0,n.jsx)("iframe",{src:`https://view.officeapps.live.com/op/embed.aspx?src=${encodeURIComponent(window.location.origin+h)}`,style:{width:"100%",height:"100%",border:"none"},title:"PPT Preview"})})]})}function eG({data:e}){let t=e.chapterNumber,r=e.detection?.score??0,o=100*r,i=e.detection?.provider||"未知引擎",l=e.passed??!0,s=l?{text:"#10b981",border:"rgba(16, 185, 129, 0.4)",bg:"rgba(16, 185, 129, 0.08)",label:"符合自然创作特征 (通过)",emoji:"\uD83D\uDFE2"}:{text:"#ef4444",border:"rgba(239, 68, 68, 0.4)",bg:"rgba(239, 68, 68, 0.08)",label:"可能包含高比例 AI 生成 (超标)",emoji:"\uD83D\uDD34"};return(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:20,paddingBottom:24},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"14px 16px",background:s.bg,border:`1px solid ${s.border}`,borderRadius:"8px"},children:[(0,n.jsx)("span",{style:{fontSize:20},children:s.emoji}),(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{style:{fontSize:"11px",color:"var(--text-muted)",fontWeight:500},children:"AIGC 风格合规评定"}),(0,n.jsx)("div",{style:{fontSize:"14px",fontWeight:700,color:s.text,marginTop:"2px"},children:s.label})]})]}),(0,n.jsxs)("div",{style:{background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:"10px",padding:"20px",display:"flex",flexDirection:"column",gap:16},children:[(0,n.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline"},children:[(0,n.jsx)("span",{style:{fontSize:"12px",fontWeight:600,color:"var(--text-muted)"},children:"AI 生成度占比 (AI味浓度)"}),(0,n.jsxs)("span",{style:{fontSize:"28px",fontWeight:800,fontFamily:"var(--font-mono)",color:s.text},children:[o.toFixed(1),"%"]})]}),(0,n.jsx)("div",{style:{width:"100%",height:"12px",background:"var(--bg)",borderRadius:"6px",overflow:"hidden",border:"1px solid var(--border)",position:"relative"},children:(0,n.jsx)("div",{style:{width:`${Math.min(100,Math.max(0,o))}%`,height:"100%",background:r<.3?"linear-gradient(90deg, #10b981, #34d399)":r<.6?"linear-gradient(90deg, #f59e0b, #fbbf24)":"linear-gradient(90deg, #ef4444, #f87171)",borderRadius:"6px",transition:"width 0.8s cubic-bezier(0.4, 0, 0.2, 1)"}})}),(0,n.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12,paddingTop:12,borderTop:"1px solid var(--border)"},children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{style:{fontSize:"10px",color:"var(--text-muted)"},children:"评估章节"}),(0,n.jsxs)("div",{style:{fontSize:"12px",fontWeight:600,color:"var(--text)"},children:["第 ",t," 章"]})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{style:{fontSize:"10px",color:"var(--text-muted)"},children:"检测引擎"}),(0,n.jsx)("div",{style:{fontSize:"12px",fontWeight:600,color:"var(--text)"},children:i})]})]})]}),(0,n.jsxs)("div",{style:{background:"rgba(16, 185, 129, 0.03)",border:"1px dashed var(--border)",borderRadius:"8px",padding:"14px 16px",fontSize:"12px",lineHeight:"1.6"},children:[(0,n.jsx)("div",{style:{fontWeight:600,color:"var(--text)",marginBottom:6},children:"\uD83D\uDCA1 创作者润色建议:"}),(0,n.jsx)("div",{style:{color:"var(--text-muted)"},children:l?"本章文风特征自然,符合人类作家的遣词造句习惯。如果希望精益求精,可以继续保持目前的创作风格,或者使用「防崩审计」排查角色一致性。":(0,n.jsxs)("span",{children:["检测到当前章节的 AI 痕迹较为明显。建议点击编辑器底部工具栏的"," ",(0,n.jsx)("strong",{style:{color:"var(--accent)"},children:"「\uD83E\uDE84 局部定点修复」"})," 按钮,并将修正模式切换为"," ",(0,n.jsx)("strong",{style:{color:"var(--accent)"},children:"「防检测润色 (Anti-detect)」"}),",AI 协同润色器会自动打乱常见的 AI 写作特征,重组句子结构,使其更加自然流畅。"]})})]})]})}function eZ({data:e}){let t=e.passed??!1,r=e.issues??[];return(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:20,paddingBottom:24},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:12,paddingBottom:16,borderBottom:"1px solid var(--border)"},children:[(0,n.jsx)("div",{style:{fontSize:28},children:"\uD83D\uDD0D"}),(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{style:{fontSize:16,fontWeight:700,color:"var(--text)"},children:"人设防崩与一致性审计报告"}),null!=e.chapterNumber&&(0,n.jsxs)("div",{style:{fontSize:12,color:"var(--text-muted)",marginTop:2},children:["第 ",e.chapterNumber," 章"]})]}),(0,n.jsx)("div",{style:{marginLeft:"auto"},children:(0,n.jsx)("span",{style:{display:"inline-flex",alignItems:"center",gap:6,padding:"5px 14px",borderRadius:20,fontSize:12,fontWeight:600,background:t?"rgba(74,222,128,0.12)":"rgba(251,191,36,0.12)",color:t?"#4ade80":"#fbbf24",border:`1px solid ${t?"rgba(74,222,128,0.3)":"rgba(251,191,36,0.3)"}`},children:t?"✅ 审计通过":"⚠️ 发现风险"})})]}),e.summary&&(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{style:{fontSize:12,fontWeight:600,color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.08em",marginBottom:10},children:"\uD83D\uDCDD 本章内容总结"}),(0,n.jsx)("div",{style:{padding:"14px 18px",background:"rgba(96,165,250,0.06)",border:"1px solid rgba(96,165,250,0.2)",borderLeft:"3px solid #60a5fa",borderRadius:8,fontSize:13,lineHeight:1.8,color:"var(--text)"},children:e.summary})]}),(0,n.jsxs)("div",{children:[(0,n.jsxs)("div",{style:{fontSize:12,fontWeight:600,color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.08em",marginBottom:10},children:["\uD83D\uDEE0️ 审计诊断条目 (",r.length,")"]}),0===r.length?(0,n.jsx)("div",{style:{padding:"14px 18px",background:"rgba(74,222,128,0.06)",border:"1px solid rgba(74,222,128,0.2)",borderLeft:"3px solid #4ade80",borderRadius:8,fontSize:13,color:"#4ade80"},children:"✅ 未检测到任何明显的角色设定矛盾或世界观冲突风险。"}):(0,n.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:12},children:r.map((e,t)=>{let r,o="error"===(r=(e.severity||"info").toLowerCase())||"critical"===r?{color:"#f87171",bg:"rgba(248,113,113,0.08)",border:"#f87171",label:"严重",emoji:"❌"}:"warning"===r?{color:"#fbbf24",bg:"rgba(251,191,36,0.08)",border:"#fbbf24",label:"警告",emoji:"⚠️"}:{color:"#60a5fa",bg:"rgba(96,165,250,0.08)",border:"#60a5fa",label:"提示",emoji:"ℹ️"};return(0,n.jsxs)("div",{style:{padding:"14px 18px",background:o.bg,border:`1px solid ${o.border}33`,borderLeft:`3px solid ${o.border}`,borderRadius:8,display:"flex",flexDirection:"column",gap:8},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[(0,n.jsx)("span",{style:{fontSize:14},children:o.emoji}),(0,n.jsx)("span",{style:{fontSize:12,fontWeight:700,color:o.color,textTransform:"uppercase",letterSpacing:"0.05em"},children:o.label}),(0,n.jsx)("span",{style:{fontSize:12,fontWeight:600,color:"var(--text)",background:"var(--bg-hover)",padding:"1px 8px",borderRadius:4},children:e.category||"未分类"})]}),(0,n.jsxs)("div",{style:{fontSize:13,lineHeight:1.75,color:"var(--text)"},children:[(0,n.jsx)("span",{style:{color:"var(--text-muted)",fontWeight:600},children:"问题描述:"}),e.description]}),e.suggestion&&(0,n.jsxs)("div",{style:{fontSize:13,lineHeight:1.75,color:"var(--text)"},children:[(0,n.jsx)("span",{style:{color:"var(--text-muted)",fontWeight:600},children:"修改建议:"}),e.suggestion]})]},t)})})]})]})}function eX({data:e}){let t=e.auditResult,r=t?.passed??!0,o=t?.issues??[],i="drafted"===e.status;return(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:20,paddingBottom:24},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:12,paddingBottom:16,borderBottom:"1px solid var(--border)"},children:[(0,n.jsx)("div",{style:{fontSize:28},children:i?"\uD83D\uDE80":"✍️"}),(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{style:{fontSize:16,fontWeight:700,color:"var(--text)"},children:i?"极速草稿起草完成":"智能续写完成"}),(0,n.jsxs)("div",{style:{fontSize:12,color:"var(--text-muted)",marginTop:2},children:["第 ",e.chapterNumber," 章 《",e.title,"》"]})]}),(0,n.jsx)("div",{style:{marginLeft:"auto"},children:(0,n.jsx)("span",{style:{display:"inline-flex",alignItems:"center",gap:6,padding:"5px 14px",borderRadius:20,fontSize:12,fontWeight:600,background:i?"rgba(249,115,22,0.12)":"rgba(139,92,246,0.12)",color:i?"#ff903f":"#a78bfa",border:i?"1px solid rgba(249,115,22,0.3)":"1px solid rgba(139,92,246,0.3)"},children:i?"\uD83D\uDE80 极速草稿":"✨ 已生成"})})]}),(0,n.jsx)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:12},children:[{label:"生成字数",value:`${e.wordCount} 字`,color:i?"#ff903f":"#a78bfa",bg:i?"rgba(249,115,22,0.08)":"rgba(139,92,246,0.08)",border:i?"rgba(249,115,22,0.2)":"rgba(139,92,246,0.2)"},{label:"章节状态",value:i?"已起草 (未审计)":e.status||"complete",color:"#34d399",bg:"rgba(52,211,153,0.08)",border:"rgba(52,211,153,0.2)"},{label:"即时修正",value:i?"已绕过":e.revised?"已执行":"无需",color:i?"var(--text-dim)":e.revised?"#60a5fa":"var(--text-muted)",bg:i?"var(--bg-subtle)":e.revised?"rgba(96,165,250,0.08)":"var(--bg-hover)",border:i?"var(--border)":e.revised?"rgba(96,165,250,0.2)":"var(--border)"}].map((e,t)=>(0,n.jsxs)("div",{style:{padding:"12px 16px",background:e.bg,border:`1px solid ${e.border}`,borderRadius:8,display:"flex",flexDirection:"column",gap:4},children:[(0,n.jsx)("div",{style:{fontSize:11,color:"var(--text-muted)",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em"},children:e.label}),(0,n.jsx)("div",{style:{fontSize:13,fontWeight:700,color:e.color},children:e.value})]},t))}),t&&(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{style:{fontSize:12,fontWeight:600,color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.08em",marginBottom:10},children:"\uD83D\uDD0D 离线审稿审计"}),(0,n.jsx)("div",{style:{padding:"10px 16px",borderRadius:8,background:r?"rgba(74,222,128,0.06)":"rgba(251,191,36,0.06)",border:`1px solid ${r?"rgba(74,222,128,0.2)":"rgba(251,191,36,0.2)"}`,borderLeft:`3px solid ${r?"#4ade80":"#fbbf24"}`,fontSize:13,fontWeight:600,color:r?"#4ade80":"#fbbf24",marginBottom:10*(o.length>0)},children:r?"✅ 审计通过 — 无明显逻辑矛盾或人设崩塌风险":"⚠️ 审计未完全通过 — 检测到以下风险条目:"}),o.length>0&&(0,n.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:8},children:o.map((e,t)=>{let r=(e.severity||"info").toLowerCase(),o="error"===r||"critical"===r?{color:"#f87171",bg:"rgba(248,113,113,0.08)",border:"#f87171",emoji:"❌",label:"严重"}:"warning"===r?{color:"#fbbf24",bg:"rgba(251,191,36,0.08)",border:"#fbbf24",emoji:"⚠️",label:"警告"}:{color:"#60a5fa",bg:"rgba(96,165,250,0.08)",border:"#60a5fa",emoji:"ℹ️",label:"提示"};return(0,n.jsxs)("div",{style:{padding:"12px 16px",background:o.bg,border:`1px solid ${o.border}33`,borderLeft:`3px solid ${o.border}`,borderRadius:8,display:"flex",flexDirection:"column",gap:6},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[(0,n.jsx)("span",{style:{fontSize:13},children:o.emoji}),(0,n.jsx)("span",{style:{fontSize:11,fontWeight:700,color:o.color,textTransform:"uppercase",letterSpacing:"0.05em"},children:o.label}),(0,n.jsx)("span",{style:{fontSize:12,fontWeight:600,color:"var(--text)",background:"var(--bg-hover)",padding:"1px 8px",borderRadius:4},children:e.category||"未分类"})]}),(0,n.jsxs)("div",{style:{fontSize:13,lineHeight:1.7,color:"var(--text)"},children:[(0,n.jsx)("span",{style:{color:"var(--text-muted)",fontWeight:600},children:"问题描述:"}),e.description]}),e.suggestion&&(0,n.jsxs)("div",{style:{fontSize:12,lineHeight:1.7,color:"var(--text-muted)"},children:[(0,n.jsx)("span",{style:{fontWeight:600},children:"修改建议:"}),e.suggestion]})]},t)})})]}),e.autoReviseResult&&(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{style:{fontSize:12,fontWeight:600,color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.08em",marginBottom:10},children:"\uD83E\uDE84 自动修正结果"}),(0,n.jsx)(eQ,{data:e.autoReviseResult,compact:!0})]}),!e.autoReviseResult&&!r&&(0,n.jsxs)("div",{style:{padding:"12px 16px",background:"rgba(96,165,250,0.06)",border:"1px solid rgba(96,165,250,0.2)",borderRadius:8,fontSize:13,color:"var(--text-muted)",lineHeight:1.7},children:["\uD83D\uDCA1 ",(0,n.jsx)("strong",{style:{color:"var(--text)"},children:"建议"}),":点击工具栏的 ",(0,n.jsx)("strong",{children:"「\uD83E\uDE84 局部定点修复」"})," 对以上风险条目进行自动局部修缮,或手动微调相关情节后点击 ",(0,n.jsx)("strong",{children:"「\uD83D\uDD04 同步设定」"})," 重新对齐故事数据库。"]})]})}function eQ({data:e,compact:t=!1}){return e.applied?(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:t?10:16},children:[!t&&(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:12,paddingBottom:16,borderBottom:"1px solid var(--border)"},children:[(0,n.jsx)("div",{style:{fontSize:28},children:"\uD83E\uDE84"}),(0,n.jsx)("div",{children:(0,n.jsx)("div",{style:{fontSize:16,fontWeight:700,color:"var(--text)"},children:"局部定点修复成功应用"})}),(0,n.jsx)("div",{style:{marginLeft:"auto"},children:(0,n.jsx)("span",{style:{display:"inline-flex",alignItems:"center",gap:6,padding:"5px 14px",borderRadius:20,fontSize:12,fontWeight:600,background:"rgba(74,222,128,0.12)",color:"#4ade80",border:"1px solid rgba(74,222,128,0.3)"},children:"✅ 已修正"})})]}),e.fixedIssues&&e.fixedIssues.length>0&&(0,n.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:e.fixedIssues.map((e,t)=>(0,n.jsxs)("div",{style:{padding:"10px 14px",background:"rgba(74,222,128,0.06)",border:"1px solid rgba(74,222,128,0.2)",borderLeft:"3px solid #4ade80",borderRadius:8,fontSize:13,color:"var(--text)",lineHeight:1.6},children:["✅ ",e]},t))}),!t&&(e.status||e.wordCount)&&(0,n.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:10},children:[e.status&&(0,n.jsxs)("div",{style:{padding:"10px 14px",background:"rgba(52,211,153,0.08)",border:"1px solid rgba(52,211,153,0.2)",borderRadius:8},children:[(0,n.jsx)("div",{style:{fontSize:11,color:"var(--text-muted)",fontWeight:600,marginBottom:4},children:"当前状态"}),(0,n.jsx)("div",{style:{fontSize:13,fontWeight:700,color:"#34d399"},children:e.status})]}),e.wordCount&&(0,n.jsxs)("div",{style:{padding:"10px 14px",background:"rgba(96,165,250,0.08)",border:"1px solid rgba(96,165,250,0.2)",borderRadius:8},children:[(0,n.jsx)("div",{style:{fontSize:11,color:"var(--text-muted)",fontWeight:600,marginBottom:4},children:"当前字数"}),(0,n.jsxs)("div",{style:{fontSize:13,fontWeight:700,color:"#60a5fa"},children:[e.wordCount," 字"]})]})]}),!t&&(0,n.jsxs)("div",{style:{padding:"12px 16px",background:"rgba(96,165,250,0.06)",border:"1px solid rgba(96,165,250,0.2)",borderRadius:8,fontSize:13,color:"var(--text-muted)",lineHeight:1.7},children:["\uD83D\uDCA1 正文已自动更新。建议点击 ",(0,n.jsx)("strong",{style:{color:"var(--text)"},children:"「\uD83D\uDD0D 防崩审计」"})," 重新运行审查,确认修改后是否完全绿灯。"]})]}):(0,n.jsxs)("div",{style:{padding:"14px 18px",background:"rgba(96,165,250,0.06)",border:"1px solid rgba(96,165,250,0.2)",borderLeft:"3px solid #60a5fa",borderRadius:8,fontSize:13,lineHeight:1.75,color:"var(--text)"},children:[(0,n.jsx)("div",{style:{fontWeight:600,color:"#60a5fa",marginBottom:4},children:"\uD83D\uDCA1 未应用修改"}),(0,n.jsx)("div",{style:{color:"var(--text-muted)"},children:e.skippedReason||"未发现明显的改善机会,当前文本已达到较好的一致性水平。"}),!t&&(0,n.jsxs)("div",{style:{marginTop:8,fontSize:12,color:"var(--text-dim)"},children:["建议手动微调相关段落后,点击 ",(0,n.jsx)("strong",{children:"「\uD83D\uDD04 同步设定」"})," 重新对齐故事数据库。"]})]})}function e0({data:e}){let t=e.auditResult,r=t?.passed??!0,o=t?.issues??[];return(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:20,paddingBottom:24},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:12,paddingBottom:16,borderBottom:"1px solid var(--border)"},children:[(0,n.jsx)("div",{style:{fontSize:28},children:"\uD83D\uDD04"}),(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{style:{fontSize:16,fontWeight:700,color:"var(--text)"},children:"同步设定成功"}),(0,n.jsx)("div",{style:{fontSize:12,color:"var(--text-muted)",marginTop:2},children:"人物卡、伏笔池与大纲事件线已与最新正文完全对齐"})]}),(0,n.jsx)("div",{style:{marginLeft:"auto"},children:(0,n.jsx)("span",{style:{display:"inline-flex",alignItems:"center",gap:6,padding:"5px 14px",borderRadius:20,fontSize:12,fontWeight:600,background:"rgba(52,211,153,0.12)",color:"#34d399",border:"1px solid rgba(52,211,153,0.3)"},children:"\uD83D\uDD04 已同步"})})]}),t&&(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{style:{fontSize:12,fontWeight:600,color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.08em",marginBottom:10},children:"\uD83D\uDD0D 同步后审计结果"}),(0,n.jsx)("div",{style:{padding:"10px 16px",borderRadius:8,background:r?"rgba(74,222,128,0.06)":"rgba(251,191,36,0.06)",border:`1px solid ${r?"rgba(74,222,128,0.2)":"rgba(251,191,36,0.2)"}`,borderLeft:`3px solid ${r?"#4ade80":"#fbbf24"}`,fontSize:13,fontWeight:600,color:r?"#4ade80":"#fbbf24",marginBottom:10*(o.length>0)},children:r?"✅ 审计通过 — 无逻辑矛盾或角色人设崩塌问题":"⚠️ 检测到部分人设或逻辑风险 — 建议处理以下条目:"}),o.length>0&&(0,n.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:8},children:o.map((e,t)=>{let r=(e.severity||"info").toLowerCase(),o="error"===r||"critical"===r?{color:"#f87171",bg:"rgba(248,113,113,0.08)",border:"#f87171",emoji:"❌",label:"严重"}:"warning"===r?{color:"#fbbf24",bg:"rgba(251,191,36,0.08)",border:"#fbbf24",emoji:"⚠️",label:"警告"}:{color:"#60a5fa",bg:"rgba(96,165,250,0.08)",border:"#60a5fa",emoji:"ℹ️",label:"提示"};return(0,n.jsxs)("div",{style:{padding:"12px 16px",background:o.bg,border:`1px solid ${o.border}33`,borderLeft:`3px solid ${o.border}`,borderRadius:8,display:"flex",flexDirection:"column",gap:6},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[(0,n.jsx)("span",{style:{fontSize:13},children:o.emoji}),(0,n.jsx)("span",{style:{fontSize:11,fontWeight:700,color:o.color,textTransform:"uppercase",letterSpacing:"0.05em"},children:o.label}),(0,n.jsx)("span",{style:{fontSize:12,fontWeight:600,color:"var(--text)",background:"var(--bg-hover)",padding:"1px 8px",borderRadius:4},children:e.category||"未分类"})]}),(0,n.jsxs)("div",{style:{fontSize:13,lineHeight:1.7,color:"var(--text)"},children:[(0,n.jsx)("span",{style:{color:"var(--text-muted)",fontWeight:600},children:"问题描述:"}),e.description]}),e.suggestion&&(0,n.jsxs)("div",{style:{fontSize:12,lineHeight:1.7,color:"var(--text-muted)"},children:[(0,n.jsx)("span",{style:{fontWeight:600},children:"修改建议:"}),e.suggestion]})]},t)})})]}),(0,n.jsxs)("div",{style:{padding:"12px 16px",background:"rgba(96,165,250,0.06)",border:"1px solid rgba(96,165,250,0.2)",borderRadius:8,fontSize:13,color:"var(--text-muted)",lineHeight:1.7},children:["\uD83D\uDCA1 如发现残留的人设警告,可点击 ",(0,n.jsx)("strong",{style:{color:"var(--text)"},children:"「\uD83E\uDE84 局部定点修复」"})," 运行自动局部修缮,或根据审计描述手动微调相关情节。"]})]})}function e1({data:e}){return e.raw&&!e.goal?(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:16,paddingBottom:24},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:12,paddingBottom:16,borderBottom:"1px solid var(--border)"},children:[(0,n.jsx)("div",{style:{fontSize:28},children:"\uD83D\uDCDD"}),(0,n.jsx)("div",{style:{fontSize:16,fontWeight:700,color:"var(--text)"},children:"本章意图规划完成"})]}),(0,n.jsx)("div",{style:{padding:"14px 18px",background:"rgba(96,165,250,0.06)",border:"1px solid rgba(96,165,250,0.2)",borderLeft:"3px solid #60a5fa",borderRadius:8,fontSize:13,lineHeight:1.8,color:"var(--text)",whiteSpace:"pre-wrap"},children:e.raw}),(0,n.jsxs)("div",{style:{padding:"12px 16px",background:"rgba(139,92,246,0.06)",border:"1px solid rgba(139,92,246,0.2)",borderRadius:8,fontSize:13,color:"var(--text-muted)",lineHeight:1.7},children:["\uD83D\uDCA1 剧情意图与备忘账本已成功保存。点击 ",(0,n.jsx)("strong",{style:{color:"var(--text)"},children:"「✍️ 智能续写」"})," 时,AI 会以此为核心基准进行剧情铺陈与细节扩写。"]})]}):(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:20,paddingBottom:24},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:12,paddingBottom:16,borderBottom:"1px solid var(--border)"},children:[(0,n.jsx)("div",{style:{fontSize:28},children:"\uD83D\uDCDD"}),(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{style:{fontSize:16,fontWeight:700,color:"var(--text)"},children:"本章意图与剧情大纲规划"}),e.bookTitle&&(0,n.jsxs)("div",{style:{fontSize:12,color:"var(--text-muted)",marginTop:2},children:["《",e.bookTitle,"》 第 ",e.chapterNumber," 章"]})]}),(0,n.jsx)("div",{style:{marginLeft:"auto"},children:(0,n.jsx)("span",{style:{display:"inline-flex",alignItems:"center",gap:6,padding:"5px 14px",borderRadius:20,fontSize:12,fontWeight:600,background:"rgba(139,92,246,0.12)",color:"#a78bfa",border:"1px solid rgba(139,92,246,0.3)"},children:"\uD83D\uDCDD 已规划"})})]}),e.goal&&(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{style:{fontSize:12,fontWeight:600,color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.08em",marginBottom:10},children:"\uD83C\uDFAF 核心写作目标 (Goal)"}),(0,n.jsx)("div",{style:{padding:"14px 18px",background:"rgba(139,92,246,0.06)",border:"1px solid rgba(139,92,246,0.2)",borderLeft:"3px solid #a78bfa",borderRadius:8,fontSize:14,lineHeight:1.8,color:"var(--text)",fontStyle:"italic"},children:e.goal})]}),e.intentFile&&(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{style:{fontSize:12,fontWeight:600,color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.08em",marginBottom:10},children:"\uD83D\uDCC2 关联意图文件 (Intent)"}),(0,n.jsx)("div",{style:{padding:"10px 16px",background:"var(--bg-hover)",border:"1px solid var(--border)",borderRadius:8,fontSize:13,color:"var(--text-muted)",fontFamily:"var(--font-mono)"},children:e.intentFile})]}),(0,n.jsxs)("div",{style:{padding:"12px 16px",background:"rgba(139,92,246,0.06)",border:"1px solid rgba(139,92,246,0.2)",borderRadius:8,fontSize:13,color:"var(--text-muted)",lineHeight:1.7},children:["\uD83D\uDCA1 剧情意图与备忘账本已保存。点击 ",(0,n.jsx)("strong",{style:{color:"var(--text)"},children:"「✍️ 智能续写」"})," 时,AI 会以此目标为核心进行剧情铺陈与细节扩写,确保故事节奏与伏笔完美对齐。"]})]})}function e2({filePath:e,cwd:t,availableStyles:r=[],activeStyleName:o=null,showExecutionConfirm:i=!0}){let l,s,a;return(l=B(e).toLowerCase().split(".").pop()??"",eN.has(l))?(0,n.jsx)(eV,{filePath:e,cwd:t}):(s=B(e).toLowerCase().split(".").pop()??"",eP.has(s))?(0,n.jsx)(eY,{filePath:e,cwd:t}):(a=B(e).toLowerCase().split(".").pop()??"",eH.has(a))?(0,n.jsx)(eq,{filePath:e,cwd:t}):(0,n.jsx)(e4,{filePath:e,cwd:t,availableStyles:r,activeStyleName:o,showExecutionConfirm:i})}function e4({filePath:e,cwd:t,availableStyles:r=[],activeStyleName:i=null,showExecutionConfirm:l=!0}){let s,a,d,{isDark:c}=eO(),[p,x]=(0,o.useState)(null),[u,g]=(0,o.useState)(null),[h,f]=(0,o.useState)(!0),[y,b]=(0,o.useState)(null),[v,m]=(0,o.useState)(!1),[j,k]=(0,o.useState)("source"),[w,S]=(0,o.useState)(!1),[C,T]=(0,o.useState)(!1),[I,z]=(0,o.useState)(0),[R,L]=(0,o.useState)(!1),[W,E]=(0,o.useState)(!1),M=(0,o.useRef)(null),[D,F]=(0,o.useState)(""),[O,N]=(0,o.useState)("saved"),P=(0,o.useRef)(null),J=(0,o.useRef)(O),[U,V]=(0,o.useState)(!1),[Y,K]=(0,o.useState)(!1),[q,G]=(0,o.useState)(!1),[Z,X]=(0,o.useState)(!1),[Q,ee]=(0,o.useState)(!1),[et,er]=(0,o.useState)(!1),[en,eo]=(0,o.useState)(!1),[ei,el]=(0,o.useState)(""),[es,ea]=(0,o.useState)(""),[ed,ec]=(0,o.useState)(null),[ep,ex]=(0,o.useState)(null),[eu,eg]=(0,o.useState)(null),[eh,ef]=(0,o.useState)(null),[ey,eb]=(0,o.useState)(null),[ev,em]=(0,o.useState)(null),[ej,ek]=(0,o.useState)(!1),ew=q||Z||U||Q||Y||et,[eS,eC]=(0,o.useState)([]),eT=(0,o.useRef)(null),[eI,ez]=(0,o.useState)(null),[eR,eL]=(0,o.useState)([]),[eW,eE]=(0,o.useState)(!1),[e$,eB]=(0,o.useState)([]),[eA,eF]=(0,o.useState)(!1),[eN,eP]=(0,o.useState)(null),[eH,eJ]=(0,o.useState)(!1),[eV,eY]=(0,o.useState)(""),[eK,eq]=(0,o.useState)(null),[e2,e6]=(0,o.useState)("normal"),[e5,e8]=(0,o.useState)(!1),[e3,e9]=(0,o.useState)(!1),[e7,te]=(0,o.useState)(2e3),[tt,tr]=(0,o.useState)(""),[tn,to]=(0,o.useState)(null),[ti,tl]=(0,o.useState)("spot-fix"),[ts,ta]=(0,o.useState)(!1),[td,tc]=(0,o.useState)(l),[tp,tx]=(0,o.useState)(null);(0,o.useEffect)(()=>{let e=localStorage.getItem("ink-show-execution-confirm");null!==e?tc("true"===e):tc(l);let t=e=>{e.detail&&"boolean"==typeof e.detail.showExecutionConfirm&&tc(e.detail.showExecutionConfirm)};return window.addEventListener("ink-settings-changed",t),()=>{window.removeEventListener("ink-settings-changed",t)}},[l]),(0,o.useEffect)(()=>{tc(l)},[l]),(0,o.useEffect)(()=>{to(i)},[i]);let tu=e_(e,t),tg=B(e).match(/^(\d{4})_/),th=tg?parseInt(tg[1],10):null,tf=tg?tg[1]:"XXXX",ty=e=>({"write-next":{title:"智能续写 (标准模式)",desc:"大模型将根据当前正文、大纲 and 人设设定,自动为您生成并续写下一段正文内容。\n\n\uD83D\uDCA1 说明:续写前会自动将正文同步至设定库并运行防崩审计,以保证人设不崩。生成质量高但速度相对较慢(约1分钟左右)。",icon:"✍️",themeColor:"#f97316",bgTheme:"rgba(249, 115, 22, 0.08)"},draft:{title:"极速草稿 (快跑模式)",desc:"AI 将绕过复杂的设定同步、审计和 spot-fix 局部修正,直接根据大纲和创意引导快速生成下一章首稿。\n\n⚠️ 注意:极速草稿追求速度,可能会出现设定矛盾或人设偏移,适合灵感爆发时快速铺垫字数,后续建议配合「防崩审计」和「局部定点修复」进行优化。",icon:"\uD83D\uDE80",themeColor:"#ff903f",bgTheme:"rgba(255, 144, 63, 0.08)"},"detect-llm":{title:"检测 AI 味",desc:"利用大模型智能评估当前章节的文本风格特征,仅分析 AI 特征并生成诊断报告,不会对章节正文内容做任何修改。",icon:"\uD83D\uDD0D",themeColor:"#8b5cf6",bgTheme:"rgba(139, 92, 246, 0.08)"},"spot-fix":{title:"局部定点修复",desc:"通过 AI 微调修复当前正文中存在的叙事冲突、前后矛盾与逻辑不一致的问题。\n\n\uD83D\uDCA1 运作机制:此功能会自动读取上一阶段「防崩审计」检出的冲突列表,针对性生成局部替换补丁进行“唯一精准定位修复”。未受影响的其余正文和段落结构将被强行保留,不影响小说整体框架。",icon:"\uD83E\uDE84",themeColor:"#2dd4bf",bgTheme:"rgba(45, 212, 191, 0.08)"},"anti-detect":{title:"防检测润色 (消除 AI 腔调)",desc:"专门优化当前正文中机器味过浓的语句,进行口语化、自然化重构,在不改变原有故事结构的前提下降低 AIGC 痕迹。\n\n\uD83D\uDCA1 运作机制:\n1. 替换高频 AI 标记词/疲劳词(如“仿佛、不禁、宛如、竟然、冷笑、瞳孔骤缩”等)。\n2. 优化死板套板的排比句、连续相同开头的“列表式句式”以及生硬转折。\n3. 重组为口语化、文学色彩更自然的句子,提升人类作家的阅读节奏感。\n\n\uD83D\uDEE1️ 提示:此润色仅在“遣词造句”和“句法文风”层运作,100% 保持您的剧情走向、人物关系与故事设定不发生任何变动。",icon:"\uD83E\uDE84",themeColor:"#2dd4bf",bgTheme:"rgba(45, 212, 191, 0.08)"},polish:{title:"文本润色",desc:"对章节词句进行精细化雕琢以提升文学色彩和可读性,在此过程中将保留全部原有的剧情和段落结构。",icon:"\uD83E\uDE84",themeColor:"#2dd4bf",bgTheme:"rgba(45, 212, 191, 0.08)"},rewrite:{title:"智能改写",desc:"对特定段落进行重新编写以提升细节、张力与动作情绪。\n\n\uD83D\uDCA1 说明:无需您手动在编辑器中拉框选择段落。系统将自动根据「防崩审计」检出的叙事或文风欠佳段落,针对该段落及直接上下文进行重组改写,同时保留核心因果与人物动机。",icon:"\uD83E\uDE84",themeColor:"#2dd4bf",bgTheme:"rgba(45, 212, 191, 0.08)"},rework:{title:"剧情重写",desc:`根据大纲与意图完全重新编写本章内容(现有正文将被覆盖,建议提前备份)。
67
+ ${e.trim()}`:t}}catch(e){console.error("Failed to describe images for non-vision model:",e)}return e.trim()||"请分析这张图片。"},[L,eC]),e$=(0,o.useCallback)(async(o,i)=>{if(!o.trim()&&!i?.length||T||ep.current)return;ep.current=!0;let s=i?.map(e=>({type:"image",source:{type:"base64",media_type:e.mimeType,data:e.data}})),a={role:"user",content:s?.length?[...o.trim()?[{type:"text",text:o}]:[],...s]:o,timestamp:Date.now()};j(e=>[...e,a]),z(!0),ei({kind:"waiting_model"}),C({type:"start"}),eh.current=!0;let d=i?.map(e=>({type:"image",data:e.data,mimeType:e.mimeType}));try{let s=await eD(o,i);if(p&&n){B&&Q(B);let{PRESET_NONE:t,PRESET_DEFAULT:i,PRESET_FULL:a}=await r.e(8451).then(r.bind(r,8451)),c="none"===O?t:"default"===O?i:a,p=await fetch("/api/agent/new",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:n,type:"prompt",message:s,toolNames:c,...d?.length?{images:d}:{},...B?{provider:B.provider,modelId:B.modelId}:{},..."auto"!==N?{thinkingLevel:N}:{},...e.activeGemId?{gemId:e.activeGemId}:{}})});if(!p.ok)throw Error(`HTTP ${p.status}`);let x=(await p.json()).sessionId;ed.current=x,await eM(x),l?.({id:x,path:"",cwd:n,name:void 0,created:new Date().toISOString(),modified:new Date().toISOString(),messageCount:1,firstMessage:o})}else t&&(await eM(t.id),eR(t.id,{type:"prompt",message:s,...d?.length?{images:d}:{}}).catch(e=>{console.error("Prompt command error:",e),ep.current=!1}))}catch(e){console.error("Failed to send message:",e),z(!1),ei(null),C({type:"end"}),ep.current=!1}},[p,n,B,O,N,t,T,eM,l,e.activeGemId,eD]),eB=(0,o.useCallback)(async()=>{let e=ed.current;if(e)try{await eR(e,{type:"abort"})}catch(e){console.error("Failed to abort:",e)}},[]),eA=(0,o.useCallback)(async e=>{let t=ed.current;if(t){G(e);try{let{cancelled:r,newSessionId:n}=await eR(t,{type:"fork",entryId:e})??{};!r&&n&&s?.(n)}catch(e){console.error("Fork failed:",e)}finally{G(null)}}},[s]),eO=(0,o.useCallback)(async e=>{let t=ed.current;t&&(eR(t,{type:"navigate_tree",targetId:e}).catch(()=>{}),v(e),await eW(t,e))},[eW]),eF=(0,o.useCallback)(async e=>{v(e);let t=ed.current;t&&(await eW(t,e),e&&eR(t,{type:"navigate_tree",targetId:e}).catch(()=>{}))},[eW]),eN=(0,o.useCallback)(async(e,t)=>{if(p)return void ek({provider:e,modelId:t});let r=ed.current;if(r)try{await eR(r,{type:"set_model",provider:e,modelId:t}),Z({provider:e,modelId:t})}catch(e){console.error("Failed to set model:",e)}},[p,ek]),eP=(0,o.useCallback)(async()=>{let e=ed.current;if(e&&!ee){et(!0),en(null);try{await eR(e,{type:"compact"}),await ez(e,!0)}catch(e){en(e instanceof Error?e.message:String(e))}finally{et(!1)}}},[ee,ez]),eH=(0,o.useCallback)(async(e,t)=>{let r=ed.current;if(!r)return;j(t=>[...t,{role:"user",content:`[steer] ${e}`,timestamp:Date.now()}]);let n=t?.map(e=>({type:"image",data:e.data,mimeType:e.mimeType}));try{let o=await eD(e,t);await eR(r,{type:"steer",message:o,...n?.length?{images:n}:{}})}catch(e){console.error("Failed to steer:",e)}},[eD]),e_=(0,o.useCallback)(async(e,t)=>{let r=ed.current;if(!r)return;j(t=>[...t,{role:"user",content:e,timestamp:Date.now()}]);let n=t?.map(e=>({type:"image",data:e.data,mimeType:e.mimeType}));try{let o=await eD(e,t);await eR(r,{type:"follow_up",message:o,...n?.length?{images:n}:{}})}catch(e){console.error("Failed to follow up:",e)}},[eD]),eJ=(0,o.useCallback)(async()=>{let e=ed.current;if(e)try{await eR(e,{type:"abort_compaction"})}catch(e){console.error("Failed to abort compaction:",e)}},[]),eU=(0,o.useCallback)(async e=>{if(P(e),"auto"===e)return;let t=ed.current;if(t)try{await eR(t,{type:"set_thinking_level",level:e})}catch(e){console.error("Failed to set thinking level:",e)}},[]),eV=(0,o.useCallback)(async e=>{let{PRESET_NONE:t,PRESET_DEFAULT:n,PRESET_FULL:o}=await r.e(8451).then(r.bind(r,8451));ew(e);let i=ed.current;if(i)try{await eR(i,{type:"set_tools",toolNames:"none"===e?t:"default"===e?n:o})}catch(e){console.error("Failed to set tools:",e)}},[ew]),eY=(0,o.useCallback)((e="smooth")=>{ef.current?.scrollIntoView({behavior:e})},[]),eK=(0,o.useCallback)(()=>{let e=eb.current,t=eg.current;if(!e||!t)return;let r=t.getBoundingClientRect().top-e.getBoundingClientRect().top+e.scrollTop;e.scrollTo({top:r-16,behavior:"smooth"})},[]);return(0,o.useEffect)(()=>(t&&(ed.current=t.id,ez(t.id,!0,!0).then(e=>{e?.running?(eE(t.id),e.state?.isStreaming&&(z(!0),ei({kind:"waiting_model"}),eM(t.id))):ea.current&&(ea.current.close(),ea.current=null),e?.state&&(void 0!==e.state.isCompacting&&et(e.state.isCompacting),void 0!==e.state.contextUsage&&U(e.state.contextUsage??null),void 0!==e.state.systemPrompt&&Y(e.state.systemPrompt??null),void 0!==e.state.thinkingLevel&&P(e.state.thinkingLevel??"auto"))})),()=>{ea.current?.close(),ea.current=null,em.current&&(clearTimeout(em.current),em.current=null),ey.current=null}),[t?.id,ez,eE,eM]),(0,o.useEffect)(()=>{c?.(V)},[V,c]),(0,o.useEffect)(()=>{d&&d(x?.tree??[],y,eF)},[x?.tree,y,eF,d]),(0,o.useEffect)(()=>{m.length>0&&(eh.current?(eh.current=!1,eu.current=!0,eK()):eu.current?ec.current||eY("smooth"):(eu.current=!0,eY("instant")))},[m.length,T,eY,eK]),(0,o.useEffect)(()=>{fetch("/api/models").then(e=>e.json()).then(e=>{if(R(e.models),e.thinkingLevels&&M(e.thinkingLevels),e.thinkingLevelMaps&&$(e.thinkingLevelMaps),e.modelList&&(W(e.modelList),p&&e.modelList.length>0)){let t=e.defaultModel,r=t&&e.modelList.find(e=>e.id===t.modelId&&e.provider===t.provider);ek(r?{provider:r.provider,modelId:r.id}:{provider:e.modelList[0].provider,modelId:e.modelList[0].id})}}).catch(()=>{})},[p,a,ek]),(0,o.useEffect)(()=>{if(!er)return;let e=setTimeout(()=>en(null),3e3);return()=>clearTimeout(e)},[er]),{data:x,loading:g,error:f,activeLeafId:y,messages:m,entryIds:k,streamState:S,agentRunning:T,modelNames:I,modelList:L,modelThinkingLevels:E,modelThinkingLevelMaps:D,newSessionModel:B,toolPreset:O,thinkingLevel:N,retryInfo:H,contextUsage:J,systemPrompt:V,forkingEntryId:K,isCompacting:ee,compactError:er,currentModel:eS,displayModel:eC,sessionStats:eT,agentPhase:eo,isNew:p,sessionIdRef:ed,eventSourceRef:ea,messagesEndRef:ef,scrollContainerRef:eb,lastUserMsgRef:eg,pendingScrollToUserRef:eh,initialScrollDoneRef:eu,handleSend:e$,handleAbort:eB,handleFork:eA,handleNavigate:eO,handleModelChange:eN,handleCompact:eP,handleSteer:eH,handleFollowUp:e_,handleAbortCompaction:eJ,handleToolPresetChange:eV,handleThinkingLevelChange:eU,loadTools:eE,setActiveLeafId:v,setData:u,setMessages:j,dispatch:C,setAgentRunning:z,setForkingEntryId:G,handleAgentEventRef:ex}}({session:e,newSessionCwd:t,onAgentEnd:i,onSessionCreated:l,onSessionForked:s,modelsRefreshKey:a,onBranchDataChange:c,onSystemPromptChange:p,activeGemId:g}),{soundEnabled:en,onSoundToggle:eo,playDoneSound:ei}=function(){let[e,t]=(0,o.useState)(()=>{let e=localStorage.getItem("pi-sound-enabled");return null===e||"true"===e}),r=(0,o.useRef)(e);return(0,o.useEffect)(()=>{r.current=e},[e]),{soundEnabled:e,onSoundToggle:(0,o.useCallback)(()=>{t(e=>{let t=!e;return localStorage.setItem("pi-sound-enabled",String(t)),t})},[]),playDoneSound:(0,o.useCallback)(()=>{if(r.current)try{let e=new AudioContext,t=e.currentTime;[523.25,659.25].forEach((r,n)=>{let o=e.createOscillator(),i=e.createGain();o.connect(i),i.connect(e.destination),o.type="sine",o.frequency.value=r;let l=t+.18*n;i.gain.setValueAtTime(0,l),i.gain.linearRampToValueAtTime(.18,l+.02),i.gain.exponentialRampToValueAtTime(.001,l+.45),o.start(l),o.stop(l+.45)}),setTimeout(()=>e.close(),1200)}catch{}},[]),soundEnabledRef:r}}(),el=(0,o.useRef)(ei);el.current=ei;let es=(0,o.useRef)(en);es.current=en;let ea=er.current;(0,o.useEffect)(()=>{er.current=e=>{"agent_end"===e.type&&es.current&&el.current(),ea?.(e)}},[ea,er]);let ed=F?`${F.tokens.input}|${F.tokens.output}|${F.tokens.cacheRead}|${F.tokens.cacheWrite}|${F.cost??0}`:null,ec=(0,o.useRef)(F);ec.current=F,(0,o.useEffect)(()=>{x?.(ec.current)},[ed,x]),(0,o.useEffect)(()=>()=>{x?.(null)},[x]);let ep=D?`${D.percent??"null"}|${D.contextWindow}|${D.tokens??"null"}`:null,ex=(0,o.useRef)(D);ex.current=D,(0,o.useEffect)(()=>{u?.(ex.current)},[ep,u]),(0,o.useEffect)(()=>()=>{u?.(null)},[u]);let{isDragOver:eg,handleDragEnter:eh,handleDragOver:ef,handleDragLeave:eb,handleDrop:ey}=function(e){let[t,r]=(0,o.useState)(!1),n=(0,o.useRef)(0),i=(0,o.useCallback)(e=>{Array.from(e.dataTransfer.items).some(e=>e.type.startsWith("image/"))&&(e.preventDefault(),n.current+=1,r(!0))},[]),l=(0,o.useCallback)(e=>{Array.from(e.dataTransfer.items).some(e=>e.type.startsWith("image/"))&&e.preventDefault()},[]);return{isDragOver:t,handleDragEnter:i,handleDragOver:l,handleDragLeave:(0,o.useCallback)(()=>{n.current-=1,n.current<=0&&(n.current=0,r(!1))},[]),handleDrop:(0,o.useCallback)(t=>{t.preventDefault(),n.current=0,r(!1),e(Array.from(t.dataTransfer.files))},[e])}}((0,o.useCallback)(e=>{let t=e.filter(e=>e.type.startsWith("image/")),r=e.filter(e=>!e.type.startsWith("image/"));t.length>0&&d?.current?.addImages(t),r.length>0&&d?.current?.addFiles?.(r)},[d])),em=(h=w.filter(e=>"user"===e.role||"assistant"===e.role).length,(f=(0,o.useRef)([])).current=Array(h).fill(null).map((e,t)=>f.current[t]??null),f),ej=(0,o.useMemo)(()=>{let e=new Map;for(let t of w)"toolResult"===t.role&&e.set(t.toolCallId,t);return e},[w]),ek=P&&0===w.length&&!C.isStreaming&&!T,ew=O?R[`${O.provider}:${O.modelId}`]??null:null,eS=O?L[`${O.provider}:${O.modelId}`]??null:null,eT=(0,n.jsx)(eC,{ref:d,onSend:U,onAbort:V,onSteer:T?Z:void 0,onFollowUp:T?X:void 0,isStreaming:T,model:O,modelNames:z,modelList:I,onModelChange:G,onCompact:e||P?q:void 0,onAbortCompaction:Q,isCompacting:B,compactError:A,toolPreset:W,onToolPresetChange:e||P?ee:void 0,thinkingLevel:E,onThinkingLevelChange:e||P?et:void 0,availableThinkingLevels:ew,thinkingLevelMap:eS,retryInfo:M,soundEnabled:en,onSoundToggle:eo,cwd:e?.cwd??t??null});return j?(0,n.jsx)("div",{className:"flex h-full items-center justify-center text-text-muted",children:"Loading session..."}):k?(0,n.jsx)("div",{className:"flex h-full items-center justify-center text-red-400",children:k}):(0,n.jsxs)("div",{className:"relative flex h-full flex-col overflow-hidden",onDragEnter:eh,onDragOver:ef,onDragLeave:eb,onDrop:ey,children:[eg&&(0,n.jsxs)("div",{className:"pointer-events-none absolute inset-0 z-50 flex animate-[drop-zone-in_0.15s_ease_both] items-center justify-center bg-[rgba(37,99,235,0.06)] backdrop-blur-[1px]",children:[(0,n.jsx)("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:[0,.8,1.6].map(e=>(0,n.jsx)("div",{className:"absolute h-[720px] w-[720px] rounded-full border-[1.5px] border-solid border-[rgba(37,99,235,0.5)] animate-[drop-ripple_2.4s_ease-out_infinite_backwards]",style:{transformOrigin:"center",animationDelay:`${e}s`}},e))}),(0,n.jsxs)("svg",{width:"280",height:"280",viewBox:"0 0 140 140",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"drop-shadow-[0_6px_18px_rgba(37,99,235,0.18)]",children:[(0,n.jsx)("rect",{x:"28",y:"44",width:"84",height:"60",rx:"8",fill:"rgba(37,99,235,0.08)",stroke:"rgba(37,99,235,0.50)",strokeWidth:"1.8"}),(0,n.jsx)("path",{d:"M36 100 L54 72 L68 88 L80 74 L104 100Z",fill:"rgba(37,99,235,0.16)",stroke:"rgba(37,99,235,0.40)",strokeWidth:"1.4",strokeLinejoin:"round"}),(0,n.jsx)("circle",{cx:"96",cy:"58",r:"8",fill:"rgba(37,99,235,0.22)",stroke:"rgba(37,99,235,0.55)",strokeWidth:"1.6"}),(0,n.jsxs)("g",{stroke:"rgba(37,99,235,0.45)",strokeWidth:"1.4",strokeLinecap:"round",children:[(0,n.jsx)("line",{x1:"96",y1:"46",x2:"96",y2:"43"}),(0,n.jsx)("line",{x1:"96",y1:"70",x2:"96",y2:"73"}),(0,n.jsx)("line",{x1:"84",y1:"58",x2:"81",y2:"58"}),(0,n.jsx)("line",{x1:"108",y1:"58",x2:"111",y2:"58"}),(0,n.jsx)("line",{x1:"87.5",y1:"49.5",x2:"85.4",y2:"47.4"}),(0,n.jsx)("line",{x1:"104.5",y1:"66.5",x2:"106.6",y2:"68.6"}),(0,n.jsx)("line",{x1:"104.5",y1:"49.5",x2:"106.6",y2:"47.4"}),(0,n.jsx)("line",{x1:"87.5",y1:"66.5",x2:"85.4",y2:"68.6"})]})]})]}),ek?(0,n.jsx)("div",{className:"flex flex-1 flex-col items-center justify-center overflow-y-auto px-4 py-8",children:(0,n.jsxs)("div",{className:"w-full max-w-[820px]",children:[(0,n.jsxs)("div",{className:"mb-3",style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,marginLeft:16,marginRight:52,fontFamily:"var(--font-mono)"},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:10,minWidth:0,flex:1,lineHeight:1.4},children:[(0,n.jsx)("span",{style:{fontSize:28,fontWeight:700,letterSpacing:"-0.02em",color:"var(--text)"},children:"✒️"}),(0,n.jsxs)("span",{style:{fontSize:22,color:"var(--text)",fontWeight:700,letterSpacing:"-0.01em"},children:["ink-xY Novel Studio",v?` [${v}]`:""]})]}),(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-end",gap:2,flexShrink:0},children:[(0,n.jsxs)("span",{style:{fontSize:11,color:"var(--text-muted)"},children:["web ",(0,n.jsxs)("span",{style:{color:"var(--text)"},children:["v",eW.env.NEXT_PUBLIC_APP_VERSION??"0.0.0"]})]}),(0,n.jsxs)("span",{style:{fontSize:11,color:"var(--text-muted)"},children:["pi ",(0,n.jsxs)("span",{style:{color:"var(--text)"},children:["v",eW.env.NEXT_PUBLIC_PI_VERSION??"0.0.0"]})]})]})]}),eT]})}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"relative flex flex-1 overflow-hidden",children:[(0,n.jsx)("div",{ref:_,className:"flex-1 overflow-y-auto pt-4 [scrollbar-width:none]",style:{overflowAnchor:"auto"},children:(0,n.jsxs)("div",{className:"mx-auto max-w-[820px] px-4",children:[(()=>{let r=-1;for(let e=w.length-1;e>=0;e--)if("user"===w[e].role){r=e;break}let o=0;return w.map((i,l)=>{let s="user"===i.role&&l>0&&"assistant"===w[l-1].role?S[l-1]:void 0,a="assistant"===i.role&&l>0&&"user"===w[l-1].role?"string"==typeof w[l-1].content?w[l-1].content:w[l-1].content.filter(e=>"text"===e.type).map(e=>e.text).join("\n"):void 0,c="user"===i.role||"assistant"===i.role,p=c?o++:-1,x=!1;if("assistant"===i.role){x=!0;for(let e=l+1;e<w.length;e++){let t=w[e].role;if("user"===t)break;if("assistant"===t){x=!1;break}}x&&C.isStreaming&&l===w.length-1&&(x=!1)}let u=(0,n.jsx)(eu,{message:i,toolResults:ej,modelNames:z,entryId:S[l],onFork:T||P||0===l&&"user"===i.role?void 0:Y,forking:$===S[l],onNavigate:T?void 0:K,prevAssistantEntryId:T?void 0:s,onEditContent:e=>d?.current?.insertIfEmpty(e),showTimestamp:x,prevTimestamp:l>0?w[l-1].timestamp:void 0,activeModel:O,prevUserContent:a,cwd:e?.cwd||t},l);return c?(0,n.jsx)("div",{ref:e=>{em.current[p]=e,l===r&&(J.current=e)},children:u},l):u})})(),C.isStreaming&&C.streamingMessage&&(y=(b=w.length>0&&"user"===w[w.length-1].role?w[w.length-1]:null)?"string"==typeof b.content?b.content:b.content.filter(e=>"text"===e.type).map(e=>e.text).join("\n"):void 0,(0,n.jsx)(eu,{message:C.streamingMessage,isStreaming:!0,modelNames:z,activeModel:O,prevUserContent:y,cwd:e?.cwd||t})),T&&!C.streamingMessage&&(0,n.jsx)("div",{className:"py-2 text-[13px] text-text-muted",children:(0,n.jsx)("span",{className:"animate-[pulse_1.5s_infinite]",children:function(e){if(e?.kind==="running_tools"){let t=e.tools.map(e=>e.name);return 0===t.length?"Running tool...":1===t.length?`Running ${t[0]}...`:t.length<=3?`Running ${t.join(", ")}...`:`Running ${t.slice(0,2).join(", ")} (+${t.length-2})...`}return e?.kind==="waiting_model"?"Waiting for model...":"Thinking..."}(N)})}),T&&(0,n.jsx)("div",{style:{height:_.current?_.current.clientHeight:"80vh"}}),(0,n.jsx)("div",{ref:H})]})}),(0,n.jsx)(ez,{messages:w,streamingMessage:C.streamingMessage,scrollContainer:_,messageRefs:em})]}),(0,n.jsx)("div",{className:"relative",children:eT})]})]})}var eM=r(9893),eD=r(7644);let e$=new Set;function eB(e){return e$.add(e),()=>{e$.delete(e)}}function eA(){return"u"<typeof document?"light":document.documentElement.classList.contains("dark")?"dark":"light"}function eO(){return"light"}function eF(){let e=(0,o.useSyncExternalStore)(eB,eA,eO);return{theme:e,toggleTheme:(0,o.useCallback)(e=>{let t="dark"===eA()?"light":"dark",r=()=>{"dark"===t?document.documentElement.classList.add("dark"):document.documentElement.classList.remove("dark");try{localStorage.setItem("pi-theme",t)}catch{}e$.forEach(e=>e())},n=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;if("function"!=typeof document.startViewTransition||n)return void r();let o=e?.x??window.innerWidth/2,i=e?.y??window.innerHeight/2,l=Math.hypot(Math.max(o,window.innerWidth-o),Math.max(i,window.innerHeight-i));document.startViewTransition(r).ready.then(()=>{document.documentElement.animate({clipPath:[`circle(0px at ${o}px ${i}px)`,`circle(${l}px at ${o}px ${i}px)`]},{duration:450,easing:"cubic-bezier(0.22, 0.61, 0.36, 1)",pseudoElement:"::view-transition-new(root)"})}).catch(()=>{})},[]),isDark:"dark"===e}}let eN=new Set(["png","jpg","jpeg","gif","webp","svg","bmp","ico","avif"]),eP=new Set(["mp3","wav","ogg","oga","opus","m4a","aac","flac","weba","webm"]),eH=new Set(["pptx","ppt"]);function e_(e,t){if(!t)return null;let r=A(e,t).replace(/\\/g,"/").split("/");return"books"===r[0]&&r[1]?r[1]:null}function eJ(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function eU({oldContent:e,newContent:t}){let r=function(e,t){let r=e.length,n=t.length,o=r+n,i=Array(2*o+1).fill(0),l=[];for(let s=0;s<=o;s++){l.push([...i]);for(let a=-s;a<=s;a+=2){let d,c=(d=a===-s||a!==s&&i[a-1+o]<i[a+1+o]?i[a+1+o]:i[a-1+o]+1)-a;for(;d<r&&c<n&&e[d]===t[c];)d++,c++;if(i[a+o]=d,d>=r&&c>=n){let i=[],a=r,d=n;for(let r=s;r>0;r--){let n,s=l[r-1],c=a-d;n=c===-r||c!==r&&s[c-1+o]<s[c+1+o]?c+1:c-1;let p=s[n+o],x=p-n;for(;a>p&&d>x;)a--,d--,i.unshift({type:"unchanged",text:e[a],lineNo:a+1});r>0&&(a>p?(a--,i.unshift({type:"removed",text:e[a],lineNo:a+1})):(d--,i.unshift({type:"added",text:t[d],lineNo:d+1})))}for(;a>0&&d>0;)a--,d--,i.unshift({type:"unchanged",text:e[a],lineNo:a+1});return i}}}return[...e.map((e,t)=>({type:"removed",text:e,lineNo:t+1})),...t.map((e,t)=>({type:"added",text:e,lineNo:t+1}))]}(e.split("\n"),t.split("\n"));if(!r.some(e=>"unchanged"!==e.type))return(0,n.jsx)("div",{style:{padding:"12px 16px",fontSize:12,color:"var(--text-dim)",fontFamily:"var(--font-mono)"},children:"No changes"});let o=new Set(r.flatMap((e,t)=>"unchanged"!==e.type?[t]:[])),i=new Set;for(let e of o)for(let t=Math.max(0,e-3);t<=Math.min(r.length-1,e+3);t++)i.add(t);let l=[],s=0;for(;s<r.length;)if(i.has(s)){let e=[];for(;s<r.length&&i.has(s);)e.push(r[s]),s++;l.push({hidden:!1,lines:e})}else{let e=0;for(;s<r.length&&!i.has(s);)e++,s++;l.push({hidden:!0,count:e})}let a=[],d=1;for(let e of r)"removed"===e.type?a.push(0):a.push(d++);let c=0;return(0,n.jsx)("div",{style:{fontFamily:"var(--font-mono)",fontSize:13,lineHeight:1.6},children:l.map((e,t)=>{if(e.hidden){let r=(0,n.jsxs)("div",{style:{padding:"2px 16px",color:"var(--text-dim)",background:"var(--bg-panel)",fontSize:11,borderTop:"1px solid var(--border)",borderBottom:"1px solid var(--border)"},children:["... ",e.count," unchanged lines ..."]},t);return c+=e.count,r}let r=e.lines.map((e,t)=>{let r=a[c+t],o="added"===e.type?"rgba(0,200,80,0.12)":"removed"===e.type?"rgba(240,60,60,0.14)":"transparent",i="added"===e.type?"+":"removed"===e.type?"-":" ",l="added"===e.type?"#4ade80":"removed"===e.type?"#f87171":"var(--text-dim)";return(0,n.jsxs)("div",{style:{display:"flex",background:o,borderLeft:"added"===e.type?"3px solid #4ade80":"removed"===e.type?"3px solid #f87171":"3px solid transparent"},children:[(0,n.jsx)("span",{style:{minWidth:44,padding:"0 8px 0 16px",textAlign:"right",color:"var(--text-dim)",userSelect:"none",fontSize:11,lineHeight:1.6,borderRight:"1px solid var(--border)",background:"var(--bg-panel)",flexShrink:0},children:"removed"===e.type?e.lineNo:r||""}),(0,n.jsx)("span",{style:{minWidth:16,padding:"0 6px",color:l,userSelect:"none",flexShrink:0,fontWeight:600},children:i}),(0,n.jsx)("span",{style:{flex:1,padding:"0 8px 0 0",whiteSpace:"pre",color:"var(--text)",overflowX:"auto"},children:e.text||"\xa0"})]},t)});return c+=e.lines.length,(0,n.jsx)("div",{children:r},t)})})}function eV({filePath:e,cwd:t}){let[r,i]=(0,o.useState)(!1),[l,s]=(0,o.useState)(0),[a,d]=(0,o.useState)(null),[c,p]=(0,o.useState)(null),[x,u]=(0,o.useState)(null),g=(0,o.useRef)(null),h=B(e).toLowerCase().split(".").pop()??"";(0,o.useEffect)(()=>{s(0),d(null),p(null),u(null),i(!1),g.current&&(g.current.close(),g.current=null);let t=$(e),r=new EventSource(`/api/files/${t}?type=watch`);g.current=r;let n=null;return r.addEventListener("change",e=>{try{let t=JSON.parse(e.data);"number"==typeof t.size&&d(t.size)}catch{}n&&clearTimeout(n),n=setTimeout(()=>{s(e=>e+1)},1e3)}),r.addEventListener("error",()=>i(!1)),r.onerror=()=>i(!1),()=>{n&&clearTimeout(n),r.close(),g.current=null}},[e]);let f=$(e),b=`/api/files/${f}?type=read${l?`&v=${l}`:""}`,y=null!=a?eJ(a):null;return(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"4px 16px",borderBottom:"1px solid var(--border)",fontSize:11,color:"var(--text-dim)",background:"var(--bg)",flexShrink:0},children:[(0,n.jsx)("span",{style:{fontFamily:"var(--font-mono)"},title:e,children:A(e,t)}),(0,n.jsx)("span",{style:{marginLeft:"auto"},children:h||"image"}),c&&(0,n.jsxs)("span",{children:[c.w," \xd7 ",c.h]}),y&&(0,n.jsx)("span",{children:y}),(0,n.jsxs)("span",{title:r?"Live sync active":"Not watching",style:{display:"flex",alignItems:"center",gap:4,color:r?"#4ade80":"var(--text-dim)"},children:[(0,n.jsx)("span",{style:{width:7,height:7,borderRadius:"50%",background:r?"#4ade80":"var(--border)",display:"inline-block",boxShadow:r?"0 0 4px #4ade80":"none"}}),r?"live":"static"]})]}),(0,n.jsx)("div",{style:{flex:1,overflow:"auto",background:"var(--bg-panel)",display:"flex",alignItems:"center",justifyContent:"center",padding:16,backgroundImage:"linear-gradient(45deg, var(--bg) 25%, transparent 25%), linear-gradient(-45deg, var(--bg) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, var(--bg) 75%), linear-gradient(-45deg, transparent 75%, var(--bg) 75%)",backgroundSize:"16px 16px",backgroundPosition:"0 0, 0 8px, 8px -8px, -8px 0px"},children:x?(0,n.jsx)("div",{style:{color:"#f87171",fontSize:13},children:x}):(0,n.jsx)("img",{src:b,alt:e,onLoad:e=>{let t=e.currentTarget;p({w:t.naturalWidth,h:t.naturalHeight})},onError:()=>u("Failed to load image"),style:{maxWidth:"100%",maxHeight:"100%",objectFit:"contain",boxShadow:"0 2px 8px rgba(0,0,0,0.15)"}})})]})}function eY({filePath:e,cwd:t}){let[r,i]=(0,o.useState)(!1),[l,s]=(0,o.useState)(0),[a,d]=(0,o.useState)(null),[c,p]=(0,o.useState)(null),[x,u]=(0,o.useState)(null),g=(0,o.useRef)(null),h=B(e).toLowerCase().split(".").pop()??"";(0,o.useEffect)(()=>{s(0),d(null),p(null),u(null),i(!1),g.current&&(g.current.close(),g.current=null);let t=$(e),r=new EventSource(`/api/files/${t}?type=watch`);g.current=r;let n=null;return r.addEventListener("change",e=>{try{let t=JSON.parse(e.data);"number"==typeof t.size&&d(t.size)}catch{}p(null),u(null),n&&clearTimeout(n),n=setTimeout(()=>{s(e=>e+1)},1e3)}),r.addEventListener("error",()=>i(!1)),r.onerror=()=>i(!1),()=>{n&&clearTimeout(n),r.close(),g.current=null}},[e]);let f=$(e),b=`/api/files/${f}?type=read${l?`&v=${l}`:""}`;return(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"4px 16px",borderBottom:"1px solid var(--border)",fontSize:11,color:"var(--text-dim)",background:"var(--bg)",flexShrink:0},children:[(0,n.jsx)("span",{style:{fontFamily:"var(--font-mono)"},title:e,children:A(e,t)}),(0,n.jsx)("span",{style:{marginLeft:"auto"},children:h||"audio"}),null!=c&&(0,n.jsx)("span",{children:function(e){if(!Number.isFinite(e))return"";let t=Math.round(e),r=Math.floor(t/60);return`${r}:${String(t%60).padStart(2,"0")}`}(c)}),null!=a&&(0,n.jsx)("span",{children:eJ(a)}),(0,n.jsxs)("span",{title:r?"Live sync active":"Not watching",style:{display:"flex",alignItems:"center",gap:4,color:r?"#4ade80":"var(--text-dim)"},children:[(0,n.jsx)("span",{style:{width:7,height:7,borderRadius:"50%",background:r?"#4ade80":"var(--border)",display:"inline-block",boxShadow:r?"0 0 4px #4ade80":"none"}}),r?"live":"static"]})]}),(0,n.jsx)("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",padding:24,background:"var(--bg-panel)"},children:(0,n.jsxs)("div",{style:{width:"min(680px, 100%)"},children:[x&&(0,n.jsx)("div",{style:{color:"#f87171",fontSize:13,marginBottom:12,textAlign:"center"},children:x}),(0,n.jsx)("audio",{controls:!0,preload:"metadata",src:b,onLoadedMetadata:e=>p(e.currentTarget.duration),onError:()=>u("Failed to load audio"),style:{width:"100%"}},b)]})})]})}function eK({src:e}){let t=(0,o.useRef)(null),i=(0,o.useRef)(null),l=(0,o.useRef)(null),s=(0,o.useRef)(null),[a,d]=(0,o.useState)(null),[c,p]=(0,o.useState)(0),[x,u]=(0,o.useState)(0),[g,h]=(0,o.useState)(!0),[f,b]=(0,o.useState)(null),[y,v]=(0,o.useState)(null),[m,j]=(0,o.useState)(null),[k,w]=(0,o.useState)(!1),[S,C]=(0,o.useState)(null);(0,o.useEffect)(()=>{if(!i.current)return;let e=i.current.getBoundingClientRect();e.width>0&&e.height>0&&v({width:e.width,height:e.height});let t=new ResizeObserver(e=>{if(!e||0===e.length)return;let{width:t,height:r}=e[0].contentRect;t>0&&r>0&&v({width:t,height:r})});return t.observe(i.current),()=>{t.disconnect()}},[]),(0,o.useEffect)(()=>{if(!k||!s.current)return;let e=s.current.getBoundingClientRect();e.width>0&&e.height>0&&C({width:e.width,height:e.height});let t=new ResizeObserver(e=>{if(!e||0===e.length)return;let{width:t,height:r}=e[0].contentRect;t>0&&r>0&&C({width:t,height:r})});return t.observe(s.current),()=>{t.disconnect()}},[k]),(0,o.useEffect)(()=>{let n=!0,o=null;return async function(){try{h(!0),b(null);let i=await fetch(e);if(!i.ok)throw Error(`Failed to load file: ${i.statusText}`);let l=await i.arrayBuffer();if(!n)return;let{PPTXViewer:s}=await Promise.all([r.e(5647),r.e(2767),r.e(9900),r.e(2479)]).then(r.bind(r,9603));if(!n)return;let a=new s({canvas:t.current,slideSizeMode:"fit",autoChartRerenderDelayMs:200});if(o=a,await a.loadFile(new Uint8Array(l)),!n)return;u(o.getSlideCount()),p(o.getCurrentSlideIndex());let c=16/9,x=o.processor;if(x){if("function"==typeof x.getSlideDimensions){let e=x.getSlideDimensions();e&&e.cx&&e.cy&&(c=e.cx/e.cy)}else if(x.presentation?.slideSize){let e=x.presentation.slideSize;e&&e.cx&&e.cy&&(c=e.cx/e.cy)}}j(c),d(o),h(!1)}catch(t){let e=t instanceof Error?t.message:String(t);console.error("PPTX render error:",t),n&&(b(e||"Failed to render PowerPoint presentation"),h(!1))}}(),()=>{if(n=!1,o)try{o.destroy()}catch{}}},[e]);let T=m||16/9,z=0,I=0;if(y){let e=Math.max(10,y.width-32),t=Math.max(10,y.height-32);e/t>T?(I=t,z=t*T):(z=e,I=e/T)}let R=0,L=0;if(k&&S){let e=Math.max(10,S.width-48),t=Math.max(10,S.height-80);e/t>T?(L=t,R=t*T):(R=e,L=e/T)}(0,o.useEffect)(()=>{if(!a||!t.current||0===z||0===I||k)return;let e=!0;return async function(){if(a)try{await a.renderSlide(c,t.current,{quality:"high"})}catch(t){e&&console.error("Render slide error:",t)}}(),()=>{e=!1}},[a,c,z,I,k]),(0,o.useEffect)(()=>{if(!k||!a||!l.current||0===R||0===L)return;let e=!0;return async function(){if(a)try{await a.renderSlide(c,l.current,{quality:"high"})}catch(t){e&&console.error("Render modal slide error:",t)}}(),()=>{e=!1}},[k,a,c,R,L]);let W=()=>{a&&c<x-1&&p(c+1)},E=()=>{a&&c>0&&p(c-1)};return(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%",width:"100%",overflow:"hidden"},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"6px 16px",background:"var(--bg)",borderBottom:"1px solid var(--border)",flexShrink:0},children:[(0,n.jsx)("div",{style:{display:"flex",alignItems:"center",gap:12},children:(0,n.jsx)("span",{style:{fontSize:11,color:"var(--text-muted)",fontWeight:500},children:x>0?`Slide ${c+1} of ${x}`:"Loading slides..."})}),(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[(0,n.jsx)("button",{onClick:E,disabled:g||0===c,style:{padding:"4px 10px",fontSize:11,borderRadius:4,border:"1px solid var(--border)",background:"var(--bg-hover)",color:"var(--text)",cursor:g||0===c?"default":"pointer",opacity:g||0===c?.5:1},children:"◀ Prev"}),(0,n.jsx)("button",{onClick:W,disabled:g||c===x-1,style:{padding:"4px 10px",fontSize:11,borderRadius:4,border:"1px solid var(--border)",background:"var(--bg-hover)",color:"var(--text)",cursor:g||c===x-1?"default":"pointer",opacity:g||c===x-1?.5:1},children:"Next ▶"}),(0,n.jsx)("button",{onClick:()=>w(!0),disabled:g||0===x,title:"Open in fullscreen zoom",style:{padding:"4px 10px",fontSize:11,borderRadius:4,border:"1px solid var(--border)",background:"var(--bg-hover)",color:"var(--text)",cursor:g||0===x?"default":"pointer",opacity:g||0===x?.5:1},children:"\uD83D\uDD0D Zoom"}),(0,n.jsx)("a",{href:e,download:!0,title:"Download original file",style:{padding:"4px 10px",fontSize:11,borderRadius:4,border:"1px solid var(--border)",background:"var(--accent)",color:"white",textDecoration:"none",fontWeight:500,marginLeft:6},children:"⬇️ Download"})]})]}),(0,n.jsxs)("div",{ref:i,style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",background:"var(--bg-panel)",position:"relative",overflow:"hidden"},children:[g&&(0,n.jsx)("div",{style:{position:"absolute",zIndex:10,background:"rgba(0,0,0,0.05)",inset:0,display:"flex",alignItems:"center",justifyContent:"center",color:"var(--text-muted)",fontSize:13},children:"Rendering slide..."}),f?(0,n.jsx)("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",padding:16},children:(0,n.jsxs)("div",{style:{padding:24,background:"var(--bg-panel)",borderRadius:8,border:"1px solid var(--border)",textAlign:"center",maxWidth:400},children:[(0,n.jsx)("div",{style:{fontSize:36,marginBottom:12},children:"⚠️"}),(0,n.jsx)("div",{style:{fontSize:14,fontWeight:600,color:"#f87171",marginBottom:8},children:"Local Preview Failed"}),(0,n.jsx)("div",{style:{fontSize:12,color:"var(--text-muted)",marginBottom:16},children:f}),(0,n.jsx)("a",{href:e,download:!0,style:{padding:"6px 16px",background:"var(--accent)",color:"white",borderRadius:4,textDecoration:"none",fontSize:12,fontWeight:500,display:"inline-block"},children:"⬇️ Download File"})]})}):(0,n.jsx)("canvas",{ref:t,style:{width:`${Math.round(z)}px`,height:`${Math.round(I)}px`,boxShadow:"0 4px 12px rgba(0,0,0,0.15)",background:"white",display:"block",visibility:g&&0===x?"hidden":"visible"}})]}),k&&(0,n.jsxs)("div",{style:{position:"fixed",inset:0,zIndex:1e3,background:"rgba(10, 10, 10, 0.95)",backdropFilter:"blur(8px)",display:"flex",flexDirection:"column",padding:"20px 24px",color:"white"},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:16,flexShrink:0},children:[(0,n.jsx)("span",{style:{fontSize:13,color:"#ccc",fontWeight:500},children:x>0?`Slide ${c+1} of ${x}`:""}),(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[(0,n.jsx)("button",{onClick:E,disabled:0===c,style:{padding:"6px 14px",fontSize:12,borderRadius:4,border:"1px solid #444",background:"#222",color:"white",cursor:0===c?"default":"pointer",opacity:0===c?.5:1},children:"◀ Prev"}),(0,n.jsx)("button",{onClick:W,disabled:c===x-1,style:{padding:"6px 14px",fontSize:12,borderRadius:4,border:"1px solid #444",background:"#222",color:"white",cursor:c===x-1?"default":"pointer",opacity:c===x-1?.5:1},children:"Next ▶"}),(0,n.jsx)("button",{onClick:()=>w(!1),style:{padding:"6px 16px",fontSize:12,borderRadius:4,border:"none",background:"#ef4444",color:"white",cursor:"pointer",fontWeight:600,marginLeft:12},children:"✕ Close"})]})]}),(0,n.jsx)("div",{ref:s,style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",position:"relative"},children:R>0&&L>0&&(0,n.jsx)("canvas",{ref:l,style:{width:`${Math.round(R)}px`,height:`${Math.round(L)}px`,boxShadow:"0 10px 30px rgba(0,0,0,0.5)",background:"white",display:"block"}})})]})]})}function eG({filePath:e,cwd:t}){let[r,i]=(0,o.useState)(!1),[l,s]=(0,o.useState)(0),[a,d]=(0,o.useState)(null),[c,p]=(0,o.useState)(null),x=(0,o.useRef)(null),u=B(e).toLowerCase().split(".").pop()??"";(0,o.useEffect)(()=>{s(0),d(null),p(null),i(!1),x.current&&(x.current.close(),x.current=null);let t=$(e),r=new EventSource(`/api/files/${t}?type=watch`);x.current=r;let n=null;return r.addEventListener("change",e=>{try{let t=JSON.parse(e.data);"number"==typeof t.size&&d(t.size)}catch{}n&&clearTimeout(n),n=setTimeout(()=>{s(e=>e+1)},1500)}),r.addEventListener("error",()=>i(!1)),r.onerror=()=>i(!1),()=>{n&&clearTimeout(n),r.close(),x.current=null}},[e]);let g=$(e),h=`/api/files/${g}?type=read${l?`&v=${l}`:""}`,f=null!=a?eJ(a):null,b=function(e){if(!e||"localhost"===e||"127.0.0.1"===e||"::1"===e||"[::1]"===e)return!0;let t=e.match(/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/);if(t){let[,e,r]=t.map(Number);if(10===e||172===e&&r>=16&&r<=31||192===e&&168===r||169===e&&254===r||127===e)return!0}return!!(e.startsWith("[fe8")||e.startsWith("[fc")||e.startsWith("[fd")||e.startsWith("fe8")||e.startsWith("fc")||e.startsWith("fd"))}(window.location.hostname);return(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"4px 16px",borderBottom:"1px solid var(--border)",fontSize:11,color:"var(--text-dim)",background:"var(--bg)",flexShrink:0},children:[(0,n.jsx)("span",{style:{fontFamily:"var(--font-mono)"},title:e,children:A(e,t)}),(0,n.jsx)("span",{style:{marginLeft:"auto"},children:u.toUpperCase()}),f&&(0,n.jsx)("span",{children:f}),(0,n.jsxs)("span",{title:r?"Live sync active":"Not watching",style:{display:"flex",alignItems:"center",gap:4,color:r?"#4ade80":"var(--text-dim)"},children:[(0,n.jsx)("span",{style:{width:7,height:7,borderRadius:"50%",background:r?"#4ade80":"var(--border)",display:"inline-block",boxShadow:r?"0 0 4px #4ade80":"none"}}),r?"live":"static"]})]}),(0,n.jsx)("div",{style:{flex:1,overflow:"auto",background:"var(--bg-panel)",display:"flex",flexDirection:"column"},children:c?(0,n.jsx)("div",{style:{color:"#f87171",fontSize:13,padding:16},children:c}):b?(0,n.jsx)(eK,{filePath:e,src:h,formatSizeStr:f,ext:u}):(0,n.jsx)("iframe",{src:`https://view.officeapps.live.com/op/embed.aspx?src=${encodeURIComponent(window.location.origin+h)}`,style:{width:"100%",height:"100%",border:"none"},title:"PPT Preview"})})]})}function eq({data:e}){let t=e.chapterNumber,r=e.detection?.score??0,o=100*r,i=e.detection?.provider||"未知引擎",l=e.passed??!0,s=l?{text:"#10b981",border:"rgba(16, 185, 129, 0.4)",bg:"rgba(16, 185, 129, 0.08)",label:"符合自然创作特征 (通过)",emoji:"\uD83D\uDFE2"}:{text:"#ef4444",border:"rgba(239, 68, 68, 0.4)",bg:"rgba(239, 68, 68, 0.08)",label:"可能包含高比例 AI 生成 (超标)",emoji:"\uD83D\uDD34"};return(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:20,paddingBottom:24},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"14px 16px",background:s.bg,border:`1px solid ${s.border}`,borderRadius:"8px"},children:[(0,n.jsx)("span",{style:{fontSize:20},children:s.emoji}),(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{style:{fontSize:"11px",color:"var(--text-muted)",fontWeight:500},children:"AIGC 风格合规评定"}),(0,n.jsx)("div",{style:{fontSize:"14px",fontWeight:700,color:s.text,marginTop:"2px"},children:s.label})]})]}),(0,n.jsxs)("div",{style:{background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:"10px",padding:"20px",display:"flex",flexDirection:"column",gap:16},children:[(0,n.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline"},children:[(0,n.jsx)("span",{style:{fontSize:"12px",fontWeight:600,color:"var(--text-muted)"},children:"AI 生成度占比 (AI味浓度)"}),(0,n.jsxs)("span",{style:{fontSize:"28px",fontWeight:800,fontFamily:"var(--font-mono)",color:s.text},children:[o.toFixed(1),"%"]})]}),(0,n.jsx)("div",{style:{width:"100%",height:"12px",background:"var(--bg)",borderRadius:"6px",overflow:"hidden",border:"1px solid var(--border)",position:"relative"},children:(0,n.jsx)("div",{style:{width:`${Math.min(100,Math.max(0,o))}%`,height:"100%",background:r<.3?"linear-gradient(90deg, #10b981, #34d399)":r<.6?"linear-gradient(90deg, #f59e0b, #fbbf24)":"linear-gradient(90deg, #ef4444, #f87171)",borderRadius:"6px",transition:"width 0.8s cubic-bezier(0.4, 0, 0.2, 1)"}})}),(0,n.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12,paddingTop:12,borderTop:"1px solid var(--border)"},children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{style:{fontSize:"10px",color:"var(--text-muted)"},children:"评估章节"}),(0,n.jsxs)("div",{style:{fontSize:"12px",fontWeight:600,color:"var(--text)"},children:["第 ",t," 章"]})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{style:{fontSize:"10px",color:"var(--text-muted)"},children:"检测引擎"}),(0,n.jsx)("div",{style:{fontSize:"12px",fontWeight:600,color:"var(--text)"},children:i})]})]})]}),(0,n.jsxs)("div",{style:{background:"rgba(16, 185, 129, 0.03)",border:"1px dashed var(--border)",borderRadius:"8px",padding:"14px 16px",fontSize:"12px",lineHeight:"1.6"},children:[(0,n.jsx)("div",{style:{fontWeight:600,color:"var(--text)",marginBottom:6},children:"\uD83D\uDCA1 创作者润色建议:"}),(0,n.jsx)("div",{style:{color:"var(--text-muted)"},children:l?"本章文风特征自然,符合人类作家的遣词造句习惯。如果希望精益求精,可以继续保持目前的创作风格,或者使用「防崩审计」排查角色一致性。":(0,n.jsxs)("span",{children:["检测到当前章节的 AI 痕迹较为明显。建议点击编辑器底部工具栏的"," ",(0,n.jsx)("strong",{style:{color:"var(--accent)"},children:"「\uD83E\uDE84 局部定点修复」"})," 按钮,并将修正模式切换为"," ",(0,n.jsx)("strong",{style:{color:"var(--accent)"},children:"「防检测润色 (Anti-detect)」"}),",AI 协同润色器会自动打乱常见的 AI 写作特征,重组句子结构,使其更加自然流畅。"]})})]})]})}function eZ({data:e}){let t=e.passed??!1,r=e.issues??[];return(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:20,paddingBottom:24},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:12,paddingBottom:16,borderBottom:"1px solid var(--border)"},children:[(0,n.jsx)("div",{style:{fontSize:28},children:"\uD83D\uDD0D"}),(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{style:{fontSize:16,fontWeight:700,color:"var(--text)"},children:"人设防崩与一致性审计报告"}),null!=e.chapterNumber&&(0,n.jsxs)("div",{style:{fontSize:12,color:"var(--text-muted)",marginTop:2},children:["第 ",e.chapterNumber," 章"]})]}),(0,n.jsx)("div",{style:{marginLeft:"auto"},children:(0,n.jsx)("span",{style:{display:"inline-flex",alignItems:"center",gap:6,padding:"5px 14px",borderRadius:20,fontSize:12,fontWeight:600,background:t?"rgba(74,222,128,0.12)":"rgba(251,191,36,0.12)",color:t?"#4ade80":"#fbbf24",border:`1px solid ${t?"rgba(74,222,128,0.3)":"rgba(251,191,36,0.3)"}`},children:t?"✅ 审计通过":"⚠️ 发现风险"})})]}),e.summary&&(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{style:{fontSize:12,fontWeight:600,color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.08em",marginBottom:10},children:"\uD83D\uDCDD 本章内容总结"}),(0,n.jsx)("div",{style:{padding:"14px 18px",background:"rgba(96,165,250,0.06)",border:"1px solid rgba(96,165,250,0.2)",borderLeft:"3px solid #60a5fa",borderRadius:8,fontSize:13,lineHeight:1.8,color:"var(--text)"},children:e.summary})]}),(0,n.jsxs)("div",{children:[(0,n.jsxs)("div",{style:{fontSize:12,fontWeight:600,color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.08em",marginBottom:10},children:["\uD83D\uDEE0️ 审计诊断条目 (",r.length,")"]}),0===r.length?(0,n.jsx)("div",{style:{padding:"14px 18px",background:"rgba(74,222,128,0.06)",border:"1px solid rgba(74,222,128,0.2)",borderLeft:"3px solid #4ade80",borderRadius:8,fontSize:13,color:"#4ade80"},children:"✅ 未检测到任何明显的角色设定矛盾或世界观冲突风险。"}):(0,n.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:12},children:r.map((e,t)=>{let r,o="error"===(r=(e.severity||"info").toLowerCase())||"critical"===r?{color:"#f87171",bg:"rgba(248,113,113,0.08)",border:"#f87171",label:"严重",emoji:"❌"}:"warning"===r?{color:"#fbbf24",bg:"rgba(251,191,36,0.08)",border:"#fbbf24",label:"警告",emoji:"⚠️"}:{color:"#60a5fa",bg:"rgba(96,165,250,0.08)",border:"#60a5fa",label:"提示",emoji:"ℹ️"};return(0,n.jsxs)("div",{style:{padding:"14px 18px",background:o.bg,border:`1px solid ${o.border}33`,borderLeft:`3px solid ${o.border}`,borderRadius:8,display:"flex",flexDirection:"column",gap:8},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[(0,n.jsx)("span",{style:{fontSize:14},children:o.emoji}),(0,n.jsx)("span",{style:{fontSize:12,fontWeight:700,color:o.color,textTransform:"uppercase",letterSpacing:"0.05em"},children:o.label}),(0,n.jsx)("span",{style:{fontSize:12,fontWeight:600,color:"var(--text)",background:"var(--bg-hover)",padding:"1px 8px",borderRadius:4},children:e.category||"未分类"})]}),(0,n.jsxs)("div",{style:{fontSize:13,lineHeight:1.75,color:"var(--text)"},children:[(0,n.jsx)("span",{style:{color:"var(--text-muted)",fontWeight:600},children:"问题描述:"}),e.description]}),e.suggestion&&(0,n.jsxs)("div",{style:{fontSize:13,lineHeight:1.75,color:"var(--text)"},children:[(0,n.jsx)("span",{style:{color:"var(--text-muted)",fontWeight:600},children:"修改建议:"}),e.suggestion]})]},t)})})]})]})}function eX({data:e}){let t=e.auditResult,r=t?.passed??!0,o=t?.issues??[],i="drafted"===e.status;return(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:20,paddingBottom:24},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:12,paddingBottom:16,borderBottom:"1px solid var(--border)"},children:[(0,n.jsx)("div",{style:{fontSize:28},children:i?"\uD83D\uDE80":"✍️"}),(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{style:{fontSize:16,fontWeight:700,color:"var(--text)"},children:i?"极速草稿起草完成":"智能续写完成"}),(0,n.jsxs)("div",{style:{fontSize:12,color:"var(--text-muted)",marginTop:2},children:["第 ",e.chapterNumber," 章 《",e.title,"》"]})]}),(0,n.jsx)("div",{style:{marginLeft:"auto"},children:(0,n.jsx)("span",{style:{display:"inline-flex",alignItems:"center",gap:6,padding:"5px 14px",borderRadius:20,fontSize:12,fontWeight:600,background:i?"rgba(249,115,22,0.12)":"rgba(139,92,246,0.12)",color:i?"#ff903f":"#a78bfa",border:i?"1px solid rgba(249,115,22,0.3)":"1px solid rgba(139,92,246,0.3)"},children:i?"\uD83D\uDE80 极速草稿":"✨ 已生成"})})]}),(0,n.jsx)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:12},children:[{label:"生成字数",value:`${e.wordCount} 字`,color:i?"#ff903f":"#a78bfa",bg:i?"rgba(249,115,22,0.08)":"rgba(139,92,246,0.08)",border:i?"rgba(249,115,22,0.2)":"rgba(139,92,246,0.2)"},{label:"章节状态",value:i?"已起草 (未审计)":e.status||"complete",color:"#34d399",bg:"rgba(52,211,153,0.08)",border:"rgba(52,211,153,0.2)"},{label:"即时修正",value:i?"已绕过":e.revised?"已执行":"无需",color:i?"var(--text-dim)":e.revised?"#60a5fa":"var(--text-muted)",bg:i?"var(--bg-subtle)":e.revised?"rgba(96,165,250,0.08)":"var(--bg-hover)",border:i?"var(--border)":e.revised?"rgba(96,165,250,0.2)":"var(--border)"}].map((e,t)=>(0,n.jsxs)("div",{style:{padding:"12px 16px",background:e.bg,border:`1px solid ${e.border}`,borderRadius:8,display:"flex",flexDirection:"column",gap:4},children:[(0,n.jsx)("div",{style:{fontSize:11,color:"var(--text-muted)",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em"},children:e.label}),(0,n.jsx)("div",{style:{fontSize:13,fontWeight:700,color:e.color},children:e.value})]},t))}),t&&(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{style:{fontSize:12,fontWeight:600,color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.08em",marginBottom:10},children:"\uD83D\uDD0D 离线审稿审计"}),(0,n.jsx)("div",{style:{padding:"10px 16px",borderRadius:8,background:r?"rgba(74,222,128,0.06)":"rgba(251,191,36,0.06)",border:`1px solid ${r?"rgba(74,222,128,0.2)":"rgba(251,191,36,0.2)"}`,borderLeft:`3px solid ${r?"#4ade80":"#fbbf24"}`,fontSize:13,fontWeight:600,color:r?"#4ade80":"#fbbf24",marginBottom:10*(o.length>0)},children:r?"✅ 审计通过 — 无明显逻辑矛盾或人设崩塌风险":"⚠️ 审计未完全通过 — 检测到以下风险条目:"}),o.length>0&&(0,n.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:8},children:o.map((e,t)=>{let r=(e.severity||"info").toLowerCase(),o="error"===r||"critical"===r?{color:"#f87171",bg:"rgba(248,113,113,0.08)",border:"#f87171",emoji:"❌",label:"严重"}:"warning"===r?{color:"#fbbf24",bg:"rgba(251,191,36,0.08)",border:"#fbbf24",emoji:"⚠️",label:"警告"}:{color:"#60a5fa",bg:"rgba(96,165,250,0.08)",border:"#60a5fa",emoji:"ℹ️",label:"提示"};return(0,n.jsxs)("div",{style:{padding:"12px 16px",background:o.bg,border:`1px solid ${o.border}33`,borderLeft:`3px solid ${o.border}`,borderRadius:8,display:"flex",flexDirection:"column",gap:6},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[(0,n.jsx)("span",{style:{fontSize:13},children:o.emoji}),(0,n.jsx)("span",{style:{fontSize:11,fontWeight:700,color:o.color,textTransform:"uppercase",letterSpacing:"0.05em"},children:o.label}),(0,n.jsx)("span",{style:{fontSize:12,fontWeight:600,color:"var(--text)",background:"var(--bg-hover)",padding:"1px 8px",borderRadius:4},children:e.category||"未分类"})]}),(0,n.jsxs)("div",{style:{fontSize:13,lineHeight:1.7,color:"var(--text)"},children:[(0,n.jsx)("span",{style:{color:"var(--text-muted)",fontWeight:600},children:"问题描述:"}),e.description]}),e.suggestion&&(0,n.jsxs)("div",{style:{fontSize:12,lineHeight:1.7,color:"var(--text-muted)"},children:[(0,n.jsx)("span",{style:{fontWeight:600},children:"修改建议:"}),e.suggestion]})]},t)})})]}),e.autoReviseResult&&(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{style:{fontSize:12,fontWeight:600,color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.08em",marginBottom:10},children:"\uD83E\uDE84 自动修正结果"}),(0,n.jsx)(eQ,{data:e.autoReviseResult,compact:!0})]}),!e.autoReviseResult&&!r&&(0,n.jsxs)("div",{style:{padding:"12px 16px",background:"rgba(96,165,250,0.06)",border:"1px solid rgba(96,165,250,0.2)",borderRadius:8,fontSize:13,color:"var(--text-muted)",lineHeight:1.7},children:["\uD83D\uDCA1 ",(0,n.jsx)("strong",{style:{color:"var(--text)"},children:"建议"}),":点击工具栏的 ",(0,n.jsx)("strong",{children:"「\uD83E\uDE84 局部定点修复」"})," 对以上风险条目进行自动局部修缮,或手动微调相关情节后点击 ",(0,n.jsx)("strong",{children:"「\uD83D\uDD04 同步设定」"})," 重新对齐故事数据库。"]})]})}function eQ({data:e,compact:t=!1}){return e.applied?(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:t?10:16},children:[!t&&(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:12,paddingBottom:16,borderBottom:"1px solid var(--border)"},children:[(0,n.jsx)("div",{style:{fontSize:28},children:"\uD83E\uDE84"}),(0,n.jsx)("div",{children:(0,n.jsx)("div",{style:{fontSize:16,fontWeight:700,color:"var(--text)"},children:"局部定点修复成功应用"})}),(0,n.jsx)("div",{style:{marginLeft:"auto"},children:(0,n.jsx)("span",{style:{display:"inline-flex",alignItems:"center",gap:6,padding:"5px 14px",borderRadius:20,fontSize:12,fontWeight:600,background:"rgba(74,222,128,0.12)",color:"#4ade80",border:"1px solid rgba(74,222,128,0.3)"},children:"✅ 已修正"})})]}),e.fixedIssues&&e.fixedIssues.length>0&&(0,n.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:e.fixedIssues.map((e,t)=>(0,n.jsxs)("div",{style:{padding:"10px 14px",background:"rgba(74,222,128,0.06)",border:"1px solid rgba(74,222,128,0.2)",borderLeft:"3px solid #4ade80",borderRadius:8,fontSize:13,color:"var(--text)",lineHeight:1.6},children:["✅ ",e]},t))}),!t&&(e.status||e.wordCount)&&(0,n.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:10},children:[e.status&&(0,n.jsxs)("div",{style:{padding:"10px 14px",background:"rgba(52,211,153,0.08)",border:"1px solid rgba(52,211,153,0.2)",borderRadius:8},children:[(0,n.jsx)("div",{style:{fontSize:11,color:"var(--text-muted)",fontWeight:600,marginBottom:4},children:"当前状态"}),(0,n.jsx)("div",{style:{fontSize:13,fontWeight:700,color:"#34d399"},children:e.status})]}),e.wordCount&&(0,n.jsxs)("div",{style:{padding:"10px 14px",background:"rgba(96,165,250,0.08)",border:"1px solid rgba(96,165,250,0.2)",borderRadius:8},children:[(0,n.jsx)("div",{style:{fontSize:11,color:"var(--text-muted)",fontWeight:600,marginBottom:4},children:"当前字数"}),(0,n.jsxs)("div",{style:{fontSize:13,fontWeight:700,color:"#60a5fa"},children:[e.wordCount," 字"]})]})]}),!t&&(0,n.jsxs)("div",{style:{padding:"12px 16px",background:"rgba(96,165,250,0.06)",border:"1px solid rgba(96,165,250,0.2)",borderRadius:8,fontSize:13,color:"var(--text-muted)",lineHeight:1.7},children:["\uD83D\uDCA1 正文已自动更新。建议点击 ",(0,n.jsx)("strong",{style:{color:"var(--text)"},children:"「\uD83D\uDD0D 防崩审计」"})," 重新运行审查,确认修改后是否完全绿灯。"]})]}):(0,n.jsxs)("div",{style:{padding:"14px 18px",background:"rgba(96,165,250,0.06)",border:"1px solid rgba(96,165,250,0.2)",borderLeft:"3px solid #60a5fa",borderRadius:8,fontSize:13,lineHeight:1.75,color:"var(--text)"},children:[(0,n.jsx)("div",{style:{fontWeight:600,color:"#60a5fa",marginBottom:4},children:"\uD83D\uDCA1 未应用修改"}),(0,n.jsx)("div",{style:{color:"var(--text-muted)"},children:e.skippedReason||"未发现明显的改善机会,当前文本已达到较好的一致性水平。"}),!t&&(0,n.jsxs)("div",{style:{marginTop:8,fontSize:12,color:"var(--text-dim)"},children:["建议手动微调相关段落后,点击 ",(0,n.jsx)("strong",{children:"「\uD83D\uDD04 同步设定」"})," 重新对齐故事数据库。"]})]})}function e0({data:e}){let t=e.auditResult,r=t?.passed??!0,o=t?.issues??[];return(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:20,paddingBottom:24},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:12,paddingBottom:16,borderBottom:"1px solid var(--border)"},children:[(0,n.jsx)("div",{style:{fontSize:28},children:"\uD83D\uDD04"}),(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{style:{fontSize:16,fontWeight:700,color:"var(--text)"},children:"同步设定成功"}),(0,n.jsx)("div",{style:{fontSize:12,color:"var(--text-muted)",marginTop:2},children:"人物卡、伏笔池与大纲事件线已与最新正文完全对齐"})]}),(0,n.jsx)("div",{style:{marginLeft:"auto"},children:(0,n.jsx)("span",{style:{display:"inline-flex",alignItems:"center",gap:6,padding:"5px 14px",borderRadius:20,fontSize:12,fontWeight:600,background:"rgba(52,211,153,0.12)",color:"#34d399",border:"1px solid rgba(52,211,153,0.3)"},children:"\uD83D\uDD04 已同步"})})]}),t&&(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{style:{fontSize:12,fontWeight:600,color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.08em",marginBottom:10},children:"\uD83D\uDD0D 同步后审计结果"}),(0,n.jsx)("div",{style:{padding:"10px 16px",borderRadius:8,background:r?"rgba(74,222,128,0.06)":"rgba(251,191,36,0.06)",border:`1px solid ${r?"rgba(74,222,128,0.2)":"rgba(251,191,36,0.2)"}`,borderLeft:`3px solid ${r?"#4ade80":"#fbbf24"}`,fontSize:13,fontWeight:600,color:r?"#4ade80":"#fbbf24",marginBottom:10*(o.length>0)},children:r?"✅ 审计通过 — 无逻辑矛盾或角色人设崩塌问题":"⚠️ 检测到部分人设或逻辑风险 — 建议处理以下条目:"}),o.length>0&&(0,n.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:8},children:o.map((e,t)=>{let r=(e.severity||"info").toLowerCase(),o="error"===r||"critical"===r?{color:"#f87171",bg:"rgba(248,113,113,0.08)",border:"#f87171",emoji:"❌",label:"严重"}:"warning"===r?{color:"#fbbf24",bg:"rgba(251,191,36,0.08)",border:"#fbbf24",emoji:"⚠️",label:"警告"}:{color:"#60a5fa",bg:"rgba(96,165,250,0.08)",border:"#60a5fa",emoji:"ℹ️",label:"提示"};return(0,n.jsxs)("div",{style:{padding:"12px 16px",background:o.bg,border:`1px solid ${o.border}33`,borderLeft:`3px solid ${o.border}`,borderRadius:8,display:"flex",flexDirection:"column",gap:6},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[(0,n.jsx)("span",{style:{fontSize:13},children:o.emoji}),(0,n.jsx)("span",{style:{fontSize:11,fontWeight:700,color:o.color,textTransform:"uppercase",letterSpacing:"0.05em"},children:o.label}),(0,n.jsx)("span",{style:{fontSize:12,fontWeight:600,color:"var(--text)",background:"var(--bg-hover)",padding:"1px 8px",borderRadius:4},children:e.category||"未分类"})]}),(0,n.jsxs)("div",{style:{fontSize:13,lineHeight:1.7,color:"var(--text)"},children:[(0,n.jsx)("span",{style:{color:"var(--text-muted)",fontWeight:600},children:"问题描述:"}),e.description]}),e.suggestion&&(0,n.jsxs)("div",{style:{fontSize:12,lineHeight:1.7,color:"var(--text-muted)"},children:[(0,n.jsx)("span",{style:{fontWeight:600},children:"修改建议:"}),e.suggestion]})]},t)})})]}),(0,n.jsxs)("div",{style:{padding:"12px 16px",background:"rgba(96,165,250,0.06)",border:"1px solid rgba(96,165,250,0.2)",borderRadius:8,fontSize:13,color:"var(--text-muted)",lineHeight:1.7},children:["\uD83D\uDCA1 如发现残留的人设警告,可点击 ",(0,n.jsx)("strong",{style:{color:"var(--text)"},children:"「\uD83E\uDE84 局部定点修复」"})," 运行自动局部修缮,或根据审计描述手动微调相关情节。"]})]})}function e1({data:e}){return e.raw&&!e.goal?(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:16,paddingBottom:24},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:12,paddingBottom:16,borderBottom:"1px solid var(--border)"},children:[(0,n.jsx)("div",{style:{fontSize:28},children:"\uD83D\uDCDD"}),(0,n.jsx)("div",{style:{fontSize:16,fontWeight:700,color:"var(--text)"},children:"本章意图规划完成"})]}),(0,n.jsx)("div",{style:{padding:"14px 18px",background:"rgba(96,165,250,0.06)",border:"1px solid rgba(96,165,250,0.2)",borderLeft:"3px solid #60a5fa",borderRadius:8,fontSize:13,lineHeight:1.8,color:"var(--text)",whiteSpace:"pre-wrap"},children:e.raw}),(0,n.jsxs)("div",{style:{padding:"12px 16px",background:"rgba(139,92,246,0.06)",border:"1px solid rgba(139,92,246,0.2)",borderRadius:8,fontSize:13,color:"var(--text-muted)",lineHeight:1.7},children:["\uD83D\uDCA1 剧情意图与备忘账本已成功保存。点击 ",(0,n.jsx)("strong",{style:{color:"var(--text)"},children:"「✍️ 智能续写」"})," 时,AI 会以此为核心基准进行剧情铺陈与细节扩写。"]})]}):(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:20,paddingBottom:24},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:12,paddingBottom:16,borderBottom:"1px solid var(--border)"},children:[(0,n.jsx)("div",{style:{fontSize:28},children:"\uD83D\uDCDD"}),(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{style:{fontSize:16,fontWeight:700,color:"var(--text)"},children:"本章意图与剧情大纲规划"}),e.bookTitle&&(0,n.jsxs)("div",{style:{fontSize:12,color:"var(--text-muted)",marginTop:2},children:["《",e.bookTitle,"》 第 ",e.chapterNumber," 章"]})]}),(0,n.jsx)("div",{style:{marginLeft:"auto"},children:(0,n.jsx)("span",{style:{display:"inline-flex",alignItems:"center",gap:6,padding:"5px 14px",borderRadius:20,fontSize:12,fontWeight:600,background:"rgba(139,92,246,0.12)",color:"#a78bfa",border:"1px solid rgba(139,92,246,0.3)"},children:"\uD83D\uDCDD 已规划"})})]}),e.goal&&(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{style:{fontSize:12,fontWeight:600,color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.08em",marginBottom:10},children:"\uD83C\uDFAF 核心写作目标 (Goal)"}),(0,n.jsx)("div",{style:{padding:"14px 18px",background:"rgba(139,92,246,0.06)",border:"1px solid rgba(139,92,246,0.2)",borderLeft:"3px solid #a78bfa",borderRadius:8,fontSize:14,lineHeight:1.8,color:"var(--text)",fontStyle:"italic"},children:e.goal})]}),e.intentFile&&(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{style:{fontSize:12,fontWeight:600,color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.08em",marginBottom:10},children:"\uD83D\uDCC2 关联意图文件 (Intent)"}),(0,n.jsx)("div",{style:{padding:"10px 16px",background:"var(--bg-hover)",border:"1px solid var(--border)",borderRadius:8,fontSize:13,color:"var(--text-muted)",fontFamily:"var(--font-mono)"},children:e.intentFile})]}),(0,n.jsxs)("div",{style:{padding:"12px 16px",background:"rgba(139,92,246,0.06)",border:"1px solid rgba(139,92,246,0.2)",borderRadius:8,fontSize:13,color:"var(--text-muted)",lineHeight:1.7},children:["\uD83D\uDCA1 剧情意图与备忘账本已保存。点击 ",(0,n.jsx)("strong",{style:{color:"var(--text)"},children:"「✍️ 智能续写」"})," 时,AI 会以此目标为核心进行剧情铺陈与细节扩写,确保故事节奏与伏笔完美对齐。"]})]})}function e2({filePath:e,cwd:t,availableStyles:r=[],activeStyleName:o=null,showExecutionConfirm:i=!0}){let l,s,a;return(l=B(e).toLowerCase().split(".").pop()??"",eN.has(l))?(0,n.jsx)(eV,{filePath:e,cwd:t}):(s=B(e).toLowerCase().split(".").pop()??"",eP.has(s))?(0,n.jsx)(eY,{filePath:e,cwd:t}):(a=B(e).toLowerCase().split(".").pop()??"",eH.has(a))?(0,n.jsx)(eG,{filePath:e,cwd:t}):(0,n.jsx)(e4,{filePath:e,cwd:t,availableStyles:r,activeStyleName:o,showExecutionConfirm:i})}function e4({filePath:e,cwd:t,availableStyles:r=[],activeStyleName:i=null,showExecutionConfirm:l=!0}){let s,a,d,{isDark:c}=eF(),[p,x]=(0,o.useState)(null),[u,g]=(0,o.useState)(null),[h,f]=(0,o.useState)(!0),[b,y]=(0,o.useState)(null),[v,m]=(0,o.useState)(!1),[j,k]=(0,o.useState)("source"),[w,S]=(0,o.useState)(!1),[C,T]=(0,o.useState)(!1),[z,I]=(0,o.useState)(0),[R,L]=(0,o.useState)(!1),[W,E]=(0,o.useState)(!1),M=(0,o.useRef)(null),[D,O]=(0,o.useState)(""),[F,N]=(0,o.useState)("saved"),P=(0,o.useRef)(null),J=(0,o.useRef)(F),[U,V]=(0,o.useState)(!1),[Y,K]=(0,o.useState)(!1),[G,q]=(0,o.useState)(!1),[Z,X]=(0,o.useState)(!1),[Q,ee]=(0,o.useState)(!1),[et,er]=(0,o.useState)(!1),[en,eo]=(0,o.useState)(!1),[ei,el]=(0,o.useState)(""),[es,ea]=(0,o.useState)(""),[ed,ec]=(0,o.useState)(null),[ep,ex]=(0,o.useState)(null),[eu,eg]=(0,o.useState)(null),[eh,ef]=(0,o.useState)(null),[eb,ey]=(0,o.useState)(null),[ev,em]=(0,o.useState)(null),[ej,ek]=(0,o.useState)(!1),ew=G||Z||U||Q||Y||et,[eS,eC]=(0,o.useState)([]),eT=(0,o.useRef)(null),[ez,eI]=(0,o.useState)(null),[eR,eL]=(0,o.useState)([]),[eW,eE]=(0,o.useState)(!1),[e$,eB]=(0,o.useState)([]),[eA,eO]=(0,o.useState)(!1),[eN,eP]=(0,o.useState)(null),[eH,eJ]=(0,o.useState)(!1),[eV,eY]=(0,o.useState)(""),[eK,eG]=(0,o.useState)(null),[e2,e6]=(0,o.useState)("normal"),[e5,e8]=(0,o.useState)(!1),[e3,e9]=(0,o.useState)(!1),[e7,te]=(0,o.useState)(2e3),[tt,tr]=(0,o.useState)(""),[tn,to]=(0,o.useState)(null),[ti,tl]=(0,o.useState)("spot-fix"),[ts,ta]=(0,o.useState)(!1),[td,tc]=(0,o.useState)(l),[tp,tx]=(0,o.useState)(null);(0,o.useEffect)(()=>{let e=localStorage.getItem("ink-show-execution-confirm");null!==e?tc("true"===e):tc(l);let t=e=>{e.detail&&"boolean"==typeof e.detail.showExecutionConfirm&&tc(e.detail.showExecutionConfirm)};return window.addEventListener("ink-settings-changed",t),()=>{window.removeEventListener("ink-settings-changed",t)}},[l]),(0,o.useEffect)(()=>{tc(l)},[l]),(0,o.useEffect)(()=>{to(i)},[i]);let tu=e_(e,t),tg=B(e).match(/^(\d{4})_/),th=tg?parseInt(tg[1],10):null,tf=tg?tg[1]:"XXXX",tb=e=>({"write-next":{title:"智能续写 (标准模式)",desc:"大模型将根据当前正文、大纲 and 人设设定,自动为您生成并续写下一段正文内容。\n\n\uD83D\uDCA1 说明:续写前会自动将正文同步至设定库并运行防崩审计,以保证人设不崩。生成质量高但速度相对较慢(约1分钟左右)。",icon:"✍️",themeColor:"#f97316",bgTheme:"rgba(249, 115, 22, 0.08)"},draft:{title:"极速草稿 (快跑模式)",desc:"AI 将绕过复杂的设定同步、审计和 spot-fix 局部修正,直接根据大纲和创意引导快速生成下一章首稿。\n\n⚠️ 注意:极速草稿追求速度,可能会出现设定矛盾或人设偏移,适合灵感爆发时快速铺垫字数,后续建议配合「防崩审计」和「局部定点修复」进行优化。",icon:"\uD83D\uDE80",themeColor:"#ff903f",bgTheme:"rgba(255, 144, 63, 0.08)"},"detect-llm":{title:"检测 AI 味",desc:"利用大模型智能评估当前章节的文本风格特征,仅分析 AI 特征并生成诊断报告,不会对章节正文内容做任何修改。",icon:"\uD83D\uDD0D",themeColor:"#8b5cf6",bgTheme:"rgba(139, 92, 246, 0.08)"},"spot-fix":{title:"局部定点修复",desc:"通过 AI 微调修复当前正文中存在的叙事冲突、前后矛盾与逻辑不一致的问题。\n\n\uD83D\uDCA1 运作机制:此功能会自动读取上一阶段「防崩审计」检出的冲突列表,针对性生成局部替换补丁进行“唯一精准定位修复”。未受影响的其余正文和段落结构将被强行保留,不影响小说整体框架。",icon:"\uD83E\uDE84",themeColor:"#2dd4bf",bgTheme:"rgba(45, 212, 191, 0.08)"},"anti-detect":{title:"防检测润色 (消除 AI 腔调)",desc:"专门优化当前正文中机器味过浓的语句,进行口语化、自然化重构,在不改变原有故事结构的前提下降低 AIGC 痕迹。\n\n\uD83D\uDCA1 运作机制:\n1. 替换高频 AI 标记词/疲劳词(如“仿佛、不禁、宛如、竟然、冷笑、瞳孔骤缩”等)。\n2. 优化死板套板的排比句、连续相同开头的“列表式句式”以及生硬转折。\n3. 重组为口语化、文学色彩更自然的句子,提升人类作家的阅读节奏感。\n\n\uD83D\uDEE1️ 提示:此润色仅在“遣词造句”和“句法文风”层运作,100% 保持您的剧情走向、人物关系与故事设定不发生任何变动。",icon:"\uD83E\uDE84",themeColor:"#2dd4bf",bgTheme:"rgba(45, 212, 191, 0.08)"},polish:{title:"文本润色",desc:"对章节词句进行精细化雕琢以提升文学色彩和可读性,在此过程中将保留全部原有的剧情和段落结构。",icon:"\uD83E\uDE84",themeColor:"#2dd4bf",bgTheme:"rgba(45, 212, 191, 0.08)"},rewrite:{title:"智能改写",desc:"对特定段落进行重新编写以提升细节、张力与动作情绪。\n\n\uD83D\uDCA1 说明:无需您手动在编辑器中拉框选择段落。系统将自动根据「防崩审计」检出的叙事或文风欠佳段落,针对该段落及直接上下文进行重组改写,同时保留核心因果与人物动机。",icon:"\uD83E\uDE84",themeColor:"#2dd4bf",bgTheme:"rgba(45, 212, 191, 0.08)"},rework:{title:"剧情重写",desc:`根据大纲与意图完全重新编写本章内容(现有正文将被覆盖,建议提前备份)。
68
68
 
69
69
  ⚠️ 必须先手动修改:如果您需要改变本章的剧情走向,请先双击左侧文件浏览器中的以下文件进行编辑:
70
70
  - 大纲文件:story/volume_map.md(修改大纲事件走向)
@@ -72,7 +72,7 @@ ${e.trim()}`:t}}catch(e){console.error("Failed to describe images for non-vision
72
72
 
73
73
  确认修改并保存上述设定后,再点击确定,AI 才会基于新走向进行重写。`,icon:"\uD83E\uDE84",themeColor:"#2dd4bf",bgTheme:"rgba(45, 212, 191, 0.08)"},audit:{title:"防崩审计",desc:"运行 InkOS 离线审计引擎,全面扫描本章内容与大纲、人设卡、设定真相库的一致性,排查潜在的人设崩塌与逻辑漏洞。",icon:"\uD83D\uDEE1️",themeColor:"#3b82f6",bgTheme:"rgba(59, 130, 246, 0.08)"},sync:{title:"同步设定",desc:"将正文中的最新改变同步至故事设定库,重构 AI 记忆体系。\n\n\uD83D\uDCA1 使用场景:当您手动修改了正文核心剧情(例如新增了角色、发放了新道具、解开了某处伏笔)后,请务必执行此同步。它会更新 story/current_state.md(状态卡) and story/pending_hooks.md(伏笔池),以防后续续写出现冲突。",icon:"\uD83D\uDD04",themeColor:"#10b981",bgTheme:"rgba(16, 185, 129, 0.08)"},plan:{title:"规划蓝图",desc:`规划本章写作焦点与规则栈,为起草做准备。
74
74
 
75
- 💡 后续编辑说明:运行成功后,会在左侧 story/runtime/ 目录下生成本章的 chapter-${tf}.intent.md 意图文件,您可以在此文件生成后双击打开,手动修改您想要的“必须保留/必须避免”要求,然后再启动续写或重写。`,icon:"\uD83D\uDDFA️",themeColor:"#a855f7",bgTheme:"rgba(168, 85, 247, 0.08)"}})[e]||{title:"操作确认",desc:"",icon:"⚡",themeColor:"var(--accent)",bgTheme:"var(--bg-hover)"},tb=(e,t)=>{if(!td)return void t();let r=ty(e);tx({title:r.title,description:r.desc,actionType:e,onConfirm:t})},tv=(0,o.useCallback)(async()=>{if(!t||!e)return;let r=e_(e,t);if(!r||!th){ez(null),eL([]);return}let n=$(`${t}/books/${r}/chapters/index.json`);try{let e=await fetch(`/api/files/${n}?type=read`);if(e.ok){let t=await e.json(),r=JSON.parse(t.content);if(Array.isArray(r)){let e=r.find(e=>e.number===th);if(e){ez(e.status||null),eL(e.auditIssues||[]);return}}}}catch(e){console.error("Failed to load active chapter status:",e)}ez(null),eL([])},[t,e,th]);(0,o.useEffect)(()=>{tv()},[tv]);let tm=async()=>{if(t&&tu&&th){eF(!0),eP(null),eB([]);try{let e=await fetch("/api/inkos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"review-approve",cwd:t,args:{bookId:tu,chapter:th,json:!0}})});if(!e.ok)throw Error(`HTTP 异常 ${e.status}`);if(!e.body)throw Error("响应正文流为空");let r=e.body.getReader(),n=new TextDecoder,o="",i=null;for(;;){let{done:e,value:t}=await r.read();if(e)break;let l=(o+=n.decode(t,{stream:!0})).split("\n");for(let e of(o=l.pop()||"",l))if(e.trim())try{let t=JSON.parse(e);"stdout"===t.type||"stderr"===t.type?eB(e=>[...e,t.data||""]):"result"===t.type&&(i=t)}catch(e){}}if(o.trim())try{let e=JSON.parse(o);"result"===e.type&&(i=e)}catch(e){}if(!i||!i.success)throw Error(i?.error||"批准章节执行失败");await tv(),window.dispatchEvent(new CustomEvent("refresh-explorer"))}catch(e){console.error(e),eP(e.message||"批准章节失败,请重试。")}finally{eF(!1)}}},tj=async()=>{if(t&&tu&&th){eF(!0),eP(null),eB([]);try{let r=await fetch("/api/inkos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"review-reject",cwd:t,args:{bookId:tu,chapter:th,reason:eV.trim()||void 0,json:!0}})});if(!r.ok)throw Error(`HTTP 异常 ${r.status}`);if(!r.body)throw Error("响应流为空");let n=r.body.getReader(),o=new TextDecoder,i="",l=null;for(;;){let{done:e,value:t}=await n.read();if(e)break;let r=(i+=o.decode(t,{stream:!0})).split("\n");for(let e of(i=r.pop()||"",r))if(e.trim())try{let t=JSON.parse(e);"stdout"===t.type||"stderr"===t.type?eB(e=>[...e,t.data||""]):"result"===t.type&&(l=t)}catch(e){}}if(i.trim())try{let e=JSON.parse(i);"result"===e.type&&(l=e)}catch(e){}if(!l||!l.success)throw Error(l?.error||"驳回并重构章节执行失败");eJ(!1),eY(""),window.dispatchEvent(new CustomEvent("close-file",{detail:{filePath:e}})),window.dispatchEvent(new CustomEvent("refresh-explorer"))}catch(e){console.error(e),eP(e.message||"驳回章节失败,请重试。")}finally{eF(!1)}}};(0,o.useEffect)(()=>{eT.current&&(eT.current.scrollTop=eT.current.scrollHeight)},[eS]),(0,o.useEffect)(()=>{if(!t||!e)return;let r=e_(e,t);if(!r)return void eo(!1);let n=$(`${t}/books/${r}/chapters`);fetch(`/api/files/${n}?type=list`).then(e=>e.json()).then(e=>{e.entries?eo(e.entries.filter(e=>!e.isDir&&e.name.endsWith(".md")&&/^\d{4}/.test(e.name)).length>0):eo(!1)}).catch(e=>{console.error("Failed to check chapters list:",e),eo(!1)})},[e,t]);let tk=async()=>{if(t){ec(null),ex(null),V(!0),eC([]),el("人设防崩与一致性审计报告"),ea("正在运行 InkOS 离线审计引擎,请稍候..."),ek(!0);try{let r=A(e,t),n=await fetch("/api/inkos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"audit",cwd:t,args:{chapter:r,json:!0}})});if(!n.ok)throw Error(`HTTP 异常 ${n.status}`);if(!n.body)throw Error("响应正文流为空");let o=n.body.getReader(),i=new TextDecoder,l="",s=null;for(;;){let{done:e,value:t}=await o.read();if(e)break;let r=(l+=i.decode(t,{stream:!0})).split("\n");for(let e of(l=r.pop()||"",r))if(e.trim())try{let t=JSON.parse(e);"stdout"===t.type||"stderr"===t.type?eC(e=>[...e,t.data||""]):"result"===t.type&&(s=t)}catch(e){console.error("Failed to parse stream chunk:",e)}}if(l.trim())try{let e=JSON.parse(l);"result"===e.type&&(s=e)}catch(e){}if(!s||!s.success)throw Error(s?.error||"审计执行失败");let a=null;try{a=JSON.parse(s.stdout)}catch(e){console.error("Failed to parse audit result JSON:",e)}a?(eg(null),ef(null),eb(null),em(null),ec(a),ea("")):(ec(null),eg(null),ef(null),eb(null),em(null),ea(`### 🔍 防崩审计完成
75
+ 💡 后续编辑说明:运行成功后,会在左侧 story/runtime/ 目录下生成本章的 chapter-${tf}.intent.md 意图文件,您可以在此文件生成后双击打开,手动修改您想要的“必须保留/必须避免”要求,然后再启动续写或重写。`,icon:"\uD83D\uDDFA️",themeColor:"#a855f7",bgTheme:"rgba(168, 85, 247, 0.08)"}})[e]||{title:"操作确认",desc:"",icon:"⚡",themeColor:"var(--accent)",bgTheme:"var(--bg-hover)"},ty=(e,t)=>{if(!td)return void t();let r=tb(e);tx({title:r.title,description:r.desc,actionType:e,onConfirm:t})},tv=(0,o.useCallback)(async()=>{if(!t||!e)return;let r=e_(e,t);if(!r||!th){eI(null),eL([]);return}let n=$(`${t}/books/${r}/chapters/index.json`);try{let e=await fetch(`/api/files/${n}?type=read`);if(e.ok){let t=await e.json(),r=JSON.parse(t.content);if(Array.isArray(r)){let e=r.find(e=>e.number===th);if(e){eI(e.status||null),eL(e.auditIssues||[]);return}}}}catch(e){console.error("Failed to load active chapter status:",e)}eI(null),eL([])},[t,e,th]);(0,o.useEffect)(()=>{tv()},[tv]);let tm=async()=>{if(t&&tu&&th){eO(!0),eP(null),eB([]);try{let e=await fetch("/api/inkos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"review-approve",cwd:t,args:{bookId:tu,chapter:th,json:!0}})});if(!e.ok)throw Error(`HTTP 异常 ${e.status}`);if(!e.body)throw Error("响应正文流为空");let r=e.body.getReader(),n=new TextDecoder,o="",i=null;for(;;){let{done:e,value:t}=await r.read();if(e)break;let l=(o+=n.decode(t,{stream:!0})).split("\n");for(let e of(o=l.pop()||"",l))if(e.trim())try{let t=JSON.parse(e);"stdout"===t.type||"stderr"===t.type?eB(e=>[...e,t.data||""]):"result"===t.type&&(i=t)}catch(e){}}if(o.trim())try{let e=JSON.parse(o);"result"===e.type&&(i=e)}catch(e){}if(!i||!i.success)throw Error(i?.error||"批准章节执行失败");await tv(),window.dispatchEvent(new CustomEvent("refresh-explorer"))}catch(e){console.error(e),eP(e.message||"批准章节失败,请重试。")}finally{eO(!1)}}},tj=async()=>{if(t&&tu&&th){eO(!0),eP(null),eB([]);try{let r=await fetch("/api/inkos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"review-reject",cwd:t,args:{bookId:tu,chapter:th,reason:eV.trim()||void 0,json:!0}})});if(!r.ok)throw Error(`HTTP 异常 ${r.status}`);if(!r.body)throw Error("响应流为空");let n=r.body.getReader(),o=new TextDecoder,i="",l=null;for(;;){let{done:e,value:t}=await n.read();if(e)break;let r=(i+=o.decode(t,{stream:!0})).split("\n");for(let e of(i=r.pop()||"",r))if(e.trim())try{let t=JSON.parse(e);"stdout"===t.type||"stderr"===t.type?eB(e=>[...e,t.data||""]):"result"===t.type&&(l=t)}catch(e){}}if(i.trim())try{let e=JSON.parse(i);"result"===e.type&&(l=e)}catch(e){}if(!l||!l.success)throw Error(l?.error||"驳回并重构章节执行失败");eJ(!1),eY(""),window.dispatchEvent(new CustomEvent("close-file",{detail:{filePath:e}})),window.dispatchEvent(new CustomEvent("refresh-explorer"))}catch(e){console.error(e),eP(e.message||"驳回章节失败,请重试。")}finally{eO(!1)}}};(0,o.useEffect)(()=>{eT.current&&(eT.current.scrollTop=eT.current.scrollHeight)},[eS]),(0,o.useEffect)(()=>{if(!t||!e)return;let r=e_(e,t);if(!r)return void eo(!1);let n=$(`${t}/books/${r}/chapters`);fetch(`/api/files/${n}?type=list`).then(e=>e.json()).then(e=>{e.entries?eo(e.entries.filter(e=>!e.isDir&&e.name.endsWith(".md")&&/^\d{4}/.test(e.name)).length>0):eo(!1)}).catch(e=>{console.error("Failed to check chapters list:",e),eo(!1)})},[e,t]);let tk=async()=>{if(t){ec(null),ex(null),V(!0),eC([]),el("人设防崩与一致性审计报告"),ea("正在运行 InkOS 离线审计引擎,请稍候..."),ek(!0);try{let r=A(e,t),n=await fetch("/api/inkos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"audit",cwd:t,args:{chapter:r,json:!0}})});if(!n.ok)throw Error(`HTTP 异常 ${n.status}`);if(!n.body)throw Error("响应正文流为空");let o=n.body.getReader(),i=new TextDecoder,l="",s=null;for(;;){let{done:e,value:t}=await o.read();if(e)break;let r=(l+=i.decode(t,{stream:!0})).split("\n");for(let e of(l=r.pop()||"",r))if(e.trim())try{let t=JSON.parse(e);"stdout"===t.type||"stderr"===t.type?eC(e=>[...e,t.data||""]):"result"===t.type&&(s=t)}catch(e){console.error("Failed to parse stream chunk:",e)}}if(l.trim())try{let e=JSON.parse(l);"result"===e.type&&(s=e)}catch(e){}if(!s||!s.success)throw Error(s?.error||"审计执行失败");let a=null;try{a=JSON.parse(s.stdout)}catch(e){console.error("Failed to parse audit result JSON:",e)}a?(eg(null),ef(null),ey(null),em(null),ec(a),ea("")):(ec(null),eg(null),ef(null),ey(null),em(null),ea(`### 🔍 防崩审计完成
76
76
 
77
77
  🎉 **审计结论**:未检测到明显的一致性问题或人设偏离风险。
78
78
 
@@ -80,7 +80,7 @@ ${e.trim()}`:t}}catch(e){console.error("Failed to describe images for non-vision
80
80
  - **诊断详情**:${s.stdout||"审计完成,没有检测到任何一致性警告。"}
81
81
  - **提示**:如果您新写了正文,建议点击工具栏底部的 **「🔄 同步设定」**,将最新正文内容同步至故事数据库中。`)),await tv(),window.dispatchEvent(new CustomEvent("refresh-explorer"))}catch(e){console.error(e),ec(null),ea(`审计运行失败:${e.message||String(e)}
82
82
 
83
- 请确保已在侧边栏点击【一键开启创作宇宙】初始化该工作区,并在「模型配置」中配置了大模型 API Key。`)}finally{V(!1)}}},tw=async(e="llm")=>{if(t){ex(null),ec(null),eg(null),ef(null),eb(null),em(null),er(!0),eC([]),el("local"===e?"本地离线 AIGC 风格特征检测报告":"AIGC 写作风格与 AI 味检测报告"),ea("local"===e?"正在运行 InkOS 本地规则检测引擎扫描套话转折...":"正在运行 InkOS AI 检测引擎评估文本风格特征,请稍候..."),ek(!0);try{let r=await fetch("/api/inkos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"aigc-detect",cwd:t,args:{bookId:tu,chapter:th||void 0,provider:e,json:!0}})});if(!r.ok)throw Error(`HTTP 异常 ${r.status}`);if(!r.body)throw Error("响应正文流为空");let n=r.body.getReader(),o=new TextDecoder,i="",l=null;for(;;){let{done:e,value:t}=await n.read();if(e)break;let r=(i+=o.decode(t,{stream:!0})).split("\n");for(let e of(i=r.pop()||"",r))if(e.trim())try{let t=JSON.parse(e);"stdout"===t.type||"stderr"===t.type?eC(e=>[...e,t.data||""]):"result"===t.type&&(l=t)}catch(e){console.error("Failed to parse stream chunk:",e)}}if(i.trim())try{let e=JSON.parse(i);"result"===e.type&&(l=e)}catch(e){}if(!l)throw Error("未能获取检测模块的运行结果");if(l.stderr?.includes("detection is not enabled")||l.stdout?.includes("detection is not enabled"))return void ea(`### ⚠️ AIGC 检测服务未启用
83
+ 请确保已在侧边栏点击【一键开启创作宇宙】初始化该工作区,并在「模型配置」中配置了大模型 API Key。`)}finally{V(!1)}}},tw=async(e="llm")=>{if(t){ex(null),ec(null),eg(null),ef(null),ey(null),em(null),er(!0),eC([]),el("local"===e?"本地离线 AIGC 风格特征检测报告":"AIGC 写作风格与 AI 味检测报告"),ea("local"===e?"正在运行 InkOS 本地规则检测引擎扫描套话转折...":"正在运行 InkOS AI 检测引擎评估文本风格特征,请稍候..."),ek(!0);try{let r=await fetch("/api/inkos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"aigc-detect",cwd:t,args:{bookId:tu,chapter:th||void 0,provider:e,json:!0}})});if(!r.ok)throw Error(`HTTP 异常 ${r.status}`);if(!r.body)throw Error("响应正文流为空");let n=r.body.getReader(),o=new TextDecoder,i="",l=null;for(;;){let{done:e,value:t}=await n.read();if(e)break;let r=(i+=o.decode(t,{stream:!0})).split("\n");for(let e of(i=r.pop()||"",r))if(e.trim())try{let t=JSON.parse(e);"stdout"===t.type||"stderr"===t.type?eC(e=>[...e,t.data||""]):"result"===t.type&&(l=t)}catch(e){console.error("Failed to parse stream chunk:",e)}}if(i.trim())try{let e=JSON.parse(i);"result"===e.type&&(l=e)}catch(e){}if(!l)throw Error("未能获取检测模块的运行结果");if(l.stderr?.includes("detection is not enabled")||l.stdout?.includes("detection is not enabled"))return void ea(`### ⚠️ AIGC 检测服务未启用
84
84
 
85
85
  当前项目尚未开启 AIGC 检测支持。
86
86
 
@@ -117,13 +117,13 @@ ${e.trim()}`:t}}catch(e){console.error("Failed to describe images for non-vision
117
117
  > \`\`\`
118
118
  > *提示:配置外部服务时,请在环境或项目根目录 .env 中设置对应的环境变量(如 \`DETECTION_API_KEY\`)。*`);if(!l.success)throw Error(l?.error||"检测运行失败");let s=null;try{s=JSON.parse(l.stdout)}catch(e){console.error("Failed to parse detect result JSON:",e)}s?(ex(s),ea("")):ea([`### 🔍 AI 味检测完成`,"\n评测输出:\n```",l.stdout||"无详细检测结果。","```"].join("\n"))}catch(e){console.error(e),ea(`AIGC 检测失败:${e.message||String(e)}
119
119
 
120
- 请确保已在侧边栏点击【一键开启创作宇宙】初始化工作区,并验证检测环境接口无故障。`)}finally{er(!1)}}},tS=async()=>{if(t){ec(null),ex(null),K(!0),eC([]),el("本章意图与剧情大纲规划"),ea("正在运行 InkOS 多智能体规划管线,请稍候..."),ek(!0);try{let r=e_(e,t),n=await fetch("/api/inkos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"plan",cwd:t,args:{bookId:r}})});if(!n.ok)throw Error(`HTTP 异常 ${n.status}`);if(!n.body)throw Error("响应正文流为空");let o=n.body.getReader(),i=new TextDecoder,l="",s=null;for(;;){let{done:e,value:t}=await o.read();if(e)break;let r=(l+=i.decode(t,{stream:!0})).split("\n");for(let e of(l=r.pop()||"",r))if(e.trim())try{let t=JSON.parse(e);"stdout"===t.type||"stderr"===t.type?eC(e=>[...e,t.data||""]):"result"===t.type&&(s=t)}catch(e){console.error("Failed to parse stream chunk:",e)}}if(l.trim())try{let e=JSON.parse(l);"result"===e.type&&(s=e)}catch(e){}if(!s||!s.success)throw Error(s?.error||"规划执行失败");let a=s.stdout||"",d=a.match(/Planned chapter (\d+) for "([^"]+)" Goal: ([\s\S]+?)(?:\s+Intent:\s+(.+))?$/i);if(d){let[e,t,r,n,o]=d;ec(null),eg(null),ef(null),eb(null),em({chapterNumber:parseInt(t,10),bookTitle:r,goal:n.trim(),intentFile:o?o.trim():void 0}),ea("")}else ec(null),eg(null),ef(null),eb(null),em({raw:a||"规划完成。已为您生成本章写作焦点和规则栈。"}),ea("")}catch(e){console.error(e),em(null),ea(`### ⚠️ 规划运行失败
120
+ 请确保已在侧边栏点击【一键开启创作宇宙】初始化工作区,并验证检测环境接口无故障。`)}finally{er(!1)}}},tS=async()=>{if(t){ec(null),ex(null),K(!0),eC([]),el("本章意图与剧情大纲规划"),ea("正在运行 InkOS 多智能体规划管线,请稍候..."),ek(!0);try{let r=e_(e,t),n=await fetch("/api/inkos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"plan",cwd:t,args:{bookId:r}})});if(!n.ok)throw Error(`HTTP 异常 ${n.status}`);if(!n.body)throw Error("响应正文流为空");let o=n.body.getReader(),i=new TextDecoder,l="",s=null;for(;;){let{done:e,value:t}=await o.read();if(e)break;let r=(l+=i.decode(t,{stream:!0})).split("\n");for(let e of(l=r.pop()||"",r))if(e.trim())try{let t=JSON.parse(e);"stdout"===t.type||"stderr"===t.type?eC(e=>[...e,t.data||""]):"result"===t.type&&(s=t)}catch(e){console.error("Failed to parse stream chunk:",e)}}if(l.trim())try{let e=JSON.parse(l);"result"===e.type&&(s=e)}catch(e){}if(!s||!s.success)throw Error(s?.error||"规划执行失败");let a=s.stdout||"",d=a.match(/Planned chapter (\d+) for "([^"]+)" Goal: ([\s\S]+?)(?:\s+Intent:\s+(.+))?$/i);if(d){let[e,t,r,n,o]=d;ec(null),eg(null),ef(null),ey(null),em({chapterNumber:parseInt(t,10),bookTitle:r,goal:n.trim(),intentFile:o?o.trim():void 0}),ea("")}else ec(null),eg(null),ef(null),ey(null),em({raw:a||"规划完成。已为您生成本章写作焦点和规则栈。"}),ea("")}catch(e){console.error(e),em(null),ea(`### ⚠️ 规划运行失败
121
121
 
122
122
  ${e.message||String(e)}
123
123
 
124
- 请确保已在侧边栏点击【一键开启创作宇宙】初始化该工作区,并在「模型配置」中配置了大模型 API Key。`)}finally{K(!1)}}},tC=async(r=!1)=>{if(!t)return;ec(null),ex(null);let n=e_(e,t);if(n){G(!0),eC([]),el("智能续写"),ea(en?"正在进行智能续写中,请稍候...":"正在为您规划大纲并起草首章正文,请稍候..."),ek(!0);try{"dirty"===O&&(P.current&&clearTimeout(P.current),await tR(D));let o=B(e).match(/^(\d+)/),i=o?parseInt(o[1],10):void 0,l=await fetch("/api/inkos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"write-next",cwd:t,args:{bookId:n,json:!0,activeChapter:i,forceRewrite:!0===r}})});if(409===l.status){let e=await l.json();G(!1),ek(!1),e.conflict&&eq({title:"确认覆盖并重构章节",warning:"注意:此操作不可逆!",message:`${e.message}
124
+ 请确保已在侧边栏点击【一键开启创作宇宙】初始化该工作区,并在「模型配置」中配置了大模型 API Key。`)}finally{K(!1)}}},tC=async(r=!1)=>{if(!t)return;ec(null),ex(null);let n=e_(e,t);if(n){q(!0),eC([]),el("智能续写"),ea(en?"正在进行智能续写中,请稍候...":"正在为您规划大纲并起草首章正文,请稍候..."),ek(!0);try{"dirty"===F&&(P.current&&clearTimeout(P.current),await tR(D));let o=B(e).match(/^(\d+)/),i=o?parseInt(o[1],10):void 0,l=await fetch("/api/inkos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"write-next",cwd:t,args:{bookId:n,json:!0,activeChapter:i,forceRewrite:!0===r}})});if(409===l.status){let e=await l.json();q(!1),ek(!1),e.conflict&&eG({title:"确认覆盖并重构章节",warning:"注意:此操作不可逆!",message:`${e.message}
125
125
 
126
- 确认要重写该章节并永久删除后续所有章节吗?`,onConfirm:()=>{tC(!0)}});return}if(!l.ok)throw Error(`HTTP 异常 ${l.status}`);if(!l.body)throw Error("响应正文流为空");let s=l.body.getReader(),a=new TextDecoder,d="",c=null;for(;;){let{done:e,value:t}=await s.read();if(e)break;let r=(d+=a.decode(t,{stream:!0})).split("\n");for(let e of(d=r.pop()||"",r))if(e.trim())try{let t=JSON.parse(e);"stdout"===t.type||"stderr"===t.type?eC(e=>[...e,t.data||""]):"result"===t.type&&(c=t)}catch(e){console.error("Failed to parse stream chunk:",e)}}if(d.trim())try{let e=JSON.parse(d);"result"===e.type&&(c=e)}catch(e){}if(!c||!c.success){let e="";if(c){if(c.error)e=c.error;else if(c.stdout)try{let t=JSON.parse(c.stdout);t&&t.error?e=t.error:Array.isArray(t)&&t.length>0&&t[t.length-1]?.error&&(e=t[t.length-1].error)}catch(e){}!e&&c.stderr&&(e=c.stderr.trim())}throw Error(e||"智能创作执行失败")}let p=[];try{p=JSON.parse(c.stdout)}catch(e){console.error("Failed to parse write-next JSON output:",e),ea(c.stdout||"写作/续写任务完成。"),window.dispatchEvent(new CustomEvent("refresh-explorer"));return}let x=p[0];if(!x)throw Error("未返回有效的创作章节结果。");let u=String(x.chapterNumber).padStart(4,"0"),g=`${t}/books/${n}/chapters`,h=await fetch(`/api/files/${$(g)}?type=list`),f=await h.json(),y=f.entries?.find(e=>!e.isDir&&e.name.startsWith(u));if(y){let t=g+"/"+y.name;t!==e&&window.dispatchEvent(new CustomEvent("close-file",{detail:{filePath:e}})),window.dispatchEvent(new CustomEvent("open-file",{detail:{filePath:t,fileName:y.name}}))}window.dispatchEvent(new CustomEvent("refresh-explorer"));let b=x.auditResult,v=b?.passed??!0;if(ec(null),ef(null),eb(null),em(null),eg({chapterNumber:x.chapterNumber,title:x.title||"",wordCount:x.wordCount??0,revised:!!x.revised,status:x.status||"complete",auditResult:b}),ea(""),eo(!0),!v&&!x.revised&&n){el("✍️ 智能续写 + \uD83E\uDE84 自动修正");try{let r=B(y?g+"/"+y.name:e).match(/^(\d+)/),o=r?parseInt(r[1],10):x.chapterNumber,i=await fetch("/api/inkos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"revise",cwd:t,args:{bookId:n,chapter:o,mode:"spot-fix",json:!0}})});if(i.ok&&i.body){let t=i.body.getReader(),r=new TextDecoder,n="",o=null;for(;;){let{done:e,value:i}=await t.read();if(e)break;let l=(n+=r.decode(i,{stream:!0})).split("\n");for(let e of(n=l.pop()||"",l))if(e.trim())try{let t=JSON.parse(e);"stdout"===t.type||"stderr"===t.type?eC(e=>[...e,t.data||""]):"result"===t.type&&(o=t)}catch(e){}}if(n.trim())try{let e=JSON.parse(n);"result"===e.type&&(o=e)}catch(e){}if(o?.success){let t=null;try{t=JSON.parse(o.stdout)}catch(e){}t&&(await tL(y?g+"/"+y.name:e),eg(e=>e?{...e,autoReviseResult:{applied:t.applied??!0,skippedReason:t.skippedReason,fixedIssues:t.fixedIssues,status:t.status,wordCount:t.wordCount}}:null))}}}catch(e){console.error("Auto-revise after write-next failed:",e)}}}catch(e){console.error(e),eg(null),e.message.includes("超时")||e.message.includes("timed out")||eS.some(e=>e.includes("超时"))?ea(`### ⚠️ 智能创作超时
126
+ 确认要重写该章节并永久删除后续所有章节吗?`,onConfirm:()=>{tC(!0)}});return}if(!l.ok)throw Error(`HTTP 异常 ${l.status}`);if(!l.body)throw Error("响应正文流为空");let s=l.body.getReader(),a=new TextDecoder,d="",c=null;for(;;){let{done:e,value:t}=await s.read();if(e)break;let r=(d+=a.decode(t,{stream:!0})).split("\n");for(let e of(d=r.pop()||"",r))if(e.trim())try{let t=JSON.parse(e);"stdout"===t.type||"stderr"===t.type?eC(e=>[...e,t.data||""]):"result"===t.type&&(c=t)}catch(e){console.error("Failed to parse stream chunk:",e)}}if(d.trim())try{let e=JSON.parse(d);"result"===e.type&&(c=e)}catch(e){}if(!c||!c.success){let e="";if(c){if(c.error)e=c.error;else if(c.stdout)try{let t=JSON.parse(c.stdout);t&&t.error?e=t.error:Array.isArray(t)&&t.length>0&&t[t.length-1]?.error&&(e=t[t.length-1].error)}catch(e){}!e&&c.stderr&&(e=c.stderr.trim())}throw Error(e||"智能创作执行失败")}let p=[];try{p=JSON.parse(c.stdout)}catch(e){console.error("Failed to parse write-next JSON output:",e),ea(c.stdout||"写作/续写任务完成。"),window.dispatchEvent(new CustomEvent("refresh-explorer"));return}let x=p[0];if(!x)throw Error("未返回有效的创作章节结果。");let u=String(x.chapterNumber).padStart(4,"0"),g=`${t}/books/${n}/chapters`,h=await fetch(`/api/files/${$(g)}?type=list`),f=await h.json(),b=f.entries?.find(e=>!e.isDir&&e.name.startsWith(u));if(b){let t=g+"/"+b.name;t!==e&&window.dispatchEvent(new CustomEvent("close-file",{detail:{filePath:e}})),window.dispatchEvent(new CustomEvent("open-file",{detail:{filePath:t,fileName:b.name}}))}window.dispatchEvent(new CustomEvent("refresh-explorer"));let y=x.auditResult,v=y?.passed??!0;if(ec(null),ef(null),ey(null),em(null),eg({chapterNumber:x.chapterNumber,title:x.title||"",wordCount:x.wordCount??0,revised:!!x.revised,status:x.status||"complete",auditResult:y}),ea(""),eo(!0),!v&&!x.revised&&n){el("✍️ 智能续写 + \uD83E\uDE84 自动修正");try{let r=B(b?g+"/"+b.name:e).match(/^(\d+)/),o=r?parseInt(r[1],10):x.chapterNumber,i=await fetch("/api/inkos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"revise",cwd:t,args:{bookId:n,chapter:o,mode:"spot-fix",json:!0}})});if(i.ok&&i.body){let t=i.body.getReader(),r=new TextDecoder,n="",o=null;for(;;){let{done:e,value:i}=await t.read();if(e)break;let l=(n+=r.decode(i,{stream:!0})).split("\n");for(let e of(n=l.pop()||"",l))if(e.trim())try{let t=JSON.parse(e);"stdout"===t.type||"stderr"===t.type?eC(e=>[...e,t.data||""]):"result"===t.type&&(o=t)}catch(e){}}if(n.trim())try{let e=JSON.parse(n);"result"===e.type&&(o=e)}catch(e){}if(o?.success){let t=null;try{t=JSON.parse(o.stdout)}catch(e){}t&&(await tL(b?g+"/"+b.name:e),eg(e=>e?{...e,autoReviseResult:{applied:t.applied??!0,skippedReason:t.skippedReason,fixedIssues:t.fixedIssues,status:t.status,wordCount:t.wordCount}}:null))}}}catch(e){console.error("Auto-revise after write-next failed:",e)}}}catch(e){console.error(e),eg(null),e.message.includes("超时")||e.message.includes("timed out")||eS.some(e=>e.includes("超时"))?ea(`### ⚠️ 智能创作超时
127
127
 
128
128
  系统运行已超过 1800 秒,已自动终止。
129
129
 
@@ -134,9 +134,9 @@ ${e.message||String(e)}
134
134
  **错误详情**:
135
135
  ${e.message||String(e)}
136
136
 
137
- 请确保已在侧边栏点击【一键开启创作宇宙】初始化该工作区,并在右上角【配置模型】中配置了大模型 API Key 和接口代理。`)}finally{G(!1)}}},tT=async(r=!1)=>{if(!t)return;ec(null),ex(null);let n=e_(e,t);if(n){G(!0),eC([]),el("极速起草"),ea("正在为您极速起草下一章草稿(绕过审计/修正管道),请稍候..."),ek(!0),e9(!1);try{if(tn&&tn!==i)try{(await fetch("/api/inkos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"style-switch",cwd:t,args:{bookId:n,styleName:tn}})})).ok&&window.dispatchEvent(new CustomEvent("refresh-explorer"))}catch(e){console.error("Failed to switch style guide before draft:",e)}"dirty"===O&&(P.current&&clearTimeout(P.current),await tR(D));let o=B(e).match(/^(\d+)/),l=o?parseInt(o[1],10):void 0,s=await fetch("/api/inkos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"draft",cwd:t,args:{bookId:n,json:!0,activeChapter:l,forceRewrite:!0===r,words:e7,context:tt}})});if(409===s.status){let e=await s.json();G(!1),ek(!1),e.conflict&&eq({title:"确认覆盖并起草章节",warning:"注意:此操作不可逆!",message:`${e.message}
137
+ 请确保已在侧边栏点击【一键开启创作宇宙】初始化该工作区,并在右上角【配置模型】中配置了大模型 API Key 和接口代理。`)}finally{q(!1)}}},tT=async(r=!1)=>{if(!t)return;ec(null),ex(null);let n=e_(e,t);if(n){q(!0),eC([]),el("极速起草"),ea("正在为您极速起草下一章草稿(绕过审计/修正管道),请稍候..."),ek(!0),e9(!1);try{if(tn&&tn!==i)try{(await fetch("/api/inkos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"style-switch",cwd:t,args:{bookId:n,styleName:tn}})})).ok&&window.dispatchEvent(new CustomEvent("refresh-explorer"))}catch(e){console.error("Failed to switch style guide before draft:",e)}"dirty"===F&&(P.current&&clearTimeout(P.current),await tR(D));let o=B(e).match(/^(\d+)/),l=o?parseInt(o[1],10):void 0,s=await fetch("/api/inkos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"draft",cwd:t,args:{bookId:n,json:!0,activeChapter:l,forceRewrite:!0===r,words:e7,context:tt}})});if(409===s.status){let e=await s.json();q(!1),ek(!1),e.conflict&&eG({title:"确认覆盖并起草章节",warning:"注意:此操作不可逆!",message:`${e.message}
138
138
 
139
- 确认要起草该章节并永久删除后续所有章节吗?`,onConfirm:()=>{tT(!0)}});return}if(!s.ok)throw Error(`HTTP 异常 ${s.status}`);if(!s.body)throw Error("响应正文流为空");let a=s.body.getReader(),d=new TextDecoder,c="",p=null;for(;;){let{done:e,value:t}=await a.read();if(e)break;let r=(c+=d.decode(t,{stream:!0})).split("\n");for(let e of(c=r.pop()||"",r))if(e.trim())try{let t=JSON.parse(e);"stdout"===t.type||"stderr"===t.type?eC(e=>[...e,t.data||""]):"result"===t.type&&(p=t)}catch(e){console.error("Failed to parse stream chunk:",e)}}if(c.trim())try{let e=JSON.parse(c);"result"===e.type&&(p=e)}catch(e){}if(!p||!p.success){let e="";if(p){if(p.error)e=p.error;else if(p.stdout)try{let t=JSON.parse(p.stdout);t&&t.error?e=t.error:Array.isArray(t)&&t.length>0&&t[t.length-1]?.error&&(e=t[t.length-1].error)}catch(e){}!e&&p.stderr&&(e=p.stderr.trim())}throw Error(e||"极速草稿起草失败")}let x=null;try{x=JSON.parse(p.stdout)}catch(e){console.error("Failed to parse draft JSON output:",e),ea(p.stdout||"草稿起草任务完成。"),window.dispatchEvent(new CustomEvent("refresh-explorer"));return}if(!x)throw Error("未返回有效的草稿章节结果。");let u=String(x.chapterNumber).padStart(4,"0"),g=`${t}/books/${n}/chapters`,h=await fetch(`/api/files/${$(g)}?type=list`),f=await h.json(),y=f.entries?.find(e=>!e.isDir&&e.name.startsWith(u));if(y){let t=g+"/"+y.name;t!==e&&window.dispatchEvent(new CustomEvent("close-file",{detail:{filePath:e}})),window.dispatchEvent(new CustomEvent("open-file",{detail:{filePath:t,fileName:y.name}}))}window.dispatchEvent(new CustomEvent("refresh-explorer")),ec(null),ef(null),eb(null),em(null),eg({chapterNumber:x.chapterNumber,title:x.title||"",wordCount:x.wordCount??0,revised:!1,status:"drafted",auditResult:void 0}),ea(""),eo(!0)}catch(e){console.error(e),eg(null),e.message.includes("超时")||e.message.includes("timed out")||eS.some(e=>e.includes("超时"))?ea(`### ⚠️ 极速起草超时
139
+ 确认要起草该章节并永久删除后续所有章节吗?`,onConfirm:()=>{tT(!0)}});return}if(!s.ok)throw Error(`HTTP 异常 ${s.status}`);if(!s.body)throw Error("响应正文流为空");let a=s.body.getReader(),d=new TextDecoder,c="",p=null;for(;;){let{done:e,value:t}=await a.read();if(e)break;let r=(c+=d.decode(t,{stream:!0})).split("\n");for(let e of(c=r.pop()||"",r))if(e.trim())try{let t=JSON.parse(e);"stdout"===t.type||"stderr"===t.type?eC(e=>[...e,t.data||""]):"result"===t.type&&(p=t)}catch(e){console.error("Failed to parse stream chunk:",e)}}if(c.trim())try{let e=JSON.parse(c);"result"===e.type&&(p=e)}catch(e){}if(!p||!p.success){let e="";if(p){if(p.error)e=p.error;else if(p.stdout)try{let t=JSON.parse(p.stdout);t&&t.error?e=t.error:Array.isArray(t)&&t.length>0&&t[t.length-1]?.error&&(e=t[t.length-1].error)}catch(e){}!e&&p.stderr&&(e=p.stderr.trim())}throw Error(e||"极速草稿起草失败")}let x=null;try{x=JSON.parse(p.stdout)}catch(e){console.error("Failed to parse draft JSON output:",e),ea(p.stdout||"草稿起草任务完成。"),window.dispatchEvent(new CustomEvent("refresh-explorer"));return}if(!x)throw Error("未返回有效的草稿章节结果。");let u=String(x.chapterNumber).padStart(4,"0"),g=`${t}/books/${n}/chapters`,h=await fetch(`/api/files/${$(g)}?type=list`),f=await h.json(),b=f.entries?.find(e=>!e.isDir&&e.name.startsWith(u));if(b){let t=g+"/"+b.name;t!==e&&window.dispatchEvent(new CustomEvent("close-file",{detail:{filePath:e}})),window.dispatchEvent(new CustomEvent("open-file",{detail:{filePath:t,fileName:b.name}}))}window.dispatchEvent(new CustomEvent("refresh-explorer")),ec(null),ef(null),ey(null),em(null),eg({chapterNumber:x.chapterNumber,title:x.title||"",wordCount:x.wordCount??0,revised:!1,status:"drafted",auditResult:void 0}),ea(""),eo(!0)}catch(e){console.error(e),eg(null),e.message.includes("超时")||e.message.includes("timed out")||eS.some(e=>e.includes("超时"))?ea(`### ⚠️ 极速起草超时
140
140
 
141
141
  系统运行已超过 1800 秒,已自动终止。
142
142
 
@@ -147,7 +147,7 @@ ${e.message||String(e)}
147
147
  **错误详情**:
148
148
  ${e.message||String(e)}
149
149
 
150
- 请确保已在侧边栏点击【一键开启创作宇宙】初始化该工作区,并在右上角【配置模型】中配置了大模型 API Key 和接口代理。`)}finally{G(!1)}}},tI=async(r="spot-fix")=>{if(!t)return;ec(null),ex(null);let n=e_(e,t);if(!n)return;X(!0),eC([]);let o=e=>{switch(e){case"anti-detect":return"防检测润色";case"polish":return"文本润色";case"rewrite":return"智能改写";case"rework":return"剧情重写";default:return"AI 局部定点修复"}};el(`🪄 局部定点修复 - ${o(r)}`),ea(`正在运行 InkOS AI ${o(r)},请稍候...`),ek(!0);try{"dirty"===O&&(P.current&&clearTimeout(P.current),await tR(D));let o=B(e).match(/^(\d+)/),i=o?parseInt(o[1],10):void 0,l=await fetch("/api/inkos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"revise",cwd:t,args:{bookId:n,chapter:i,mode:r,json:!0}})});if(!l.ok)throw Error(`HTTP 异常 ${l.status}`);if(!l.body)throw Error("响应正文流为空");let s=l.body.getReader(),a=new TextDecoder,d="",c=null;for(;;){let{done:e,value:t}=await s.read();if(e)break;let r=(d+=a.decode(t,{stream:!0})).split("\n");for(let e of(d=r.pop()||"",r))if(e.trim())try{let t=JSON.parse(e);"stdout"===t.type||"stderr"===t.type?eC(e=>[...e,t.data||""]):"result"===t.type&&(c=t)}catch(e){console.error("Failed to parse stream chunk:",e)}}if(d.trim())try{let e=JSON.parse(d);"result"===e.type&&(c=e)}catch(e){}if(!c||!c.success){let e="";if(c){if(c.error)e=c.error;else if(c.stdout)try{let t=JSON.parse(c.stdout);t&&t.error?e=t.error:Array.isArray(t)&&t.length>0&&t[t.length-1]?.error&&(e=t[t.length-1].error)}catch(e){}!e&&c.stderr&&(e=c.stderr.trim())}throw Error(e||"智能修正执行失败")}let p=null;try{p=JSON.parse(c.stdout)}catch(e){console.error("Failed to parse revise JSON output:",e)}p&&!p.applied?(ec(null),eg(null),eb(null),em(null),ef({applied:!1,skippedReason:p.skippedReason})):p?(ec(null),eg(null),eb(null),em(null),ef({applied:!0,fixedIssues:p.fixedIssues&&p.fixedIssues.length>0?p.fixedIssues:["优化并修正了人设与设定偏离"],status:p.status,wordCount:p.wordCount})):(ec(null),eg(null),eb(null),em(null),ef({applied:!0})),ea(""),await tL(e),await tv(),window.dispatchEvent(new CustomEvent("refresh-explorer"))}catch(e){console.error(e),ef(null),e.message.includes("超时")||e.message.includes("timed out")||eS.some(e=>e.includes("超时"))?ea(`### ⚠️ 智能修正超时
150
+ 请确保已在侧边栏点击【一键开启创作宇宙】初始化该工作区,并在右上角【配置模型】中配置了大模型 API Key 和接口代理。`)}finally{q(!1)}}},tz=async(r="spot-fix")=>{if(!t)return;ec(null),ex(null);let n=e_(e,t);if(!n)return;X(!0),eC([]);let o=e=>{switch(e){case"anti-detect":return"防检测润色";case"polish":return"文本润色";case"rewrite":return"智能改写";case"rework":return"剧情重写";default:return"AI 局部定点修复"}};el(`🪄 局部定点修复 - ${o(r)}`),ea(`正在运行 InkOS AI ${o(r)},请稍候...`),ek(!0);try{"dirty"===F&&(P.current&&clearTimeout(P.current),await tR(D));let o=B(e).match(/^(\d+)/),i=o?parseInt(o[1],10):void 0,l=await fetch("/api/inkos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"revise",cwd:t,args:{bookId:n,chapter:i,mode:r,json:!0}})});if(!l.ok)throw Error(`HTTP 异常 ${l.status}`);if(!l.body)throw Error("响应正文流为空");let s=l.body.getReader(),a=new TextDecoder,d="",c=null;for(;;){let{done:e,value:t}=await s.read();if(e)break;let r=(d+=a.decode(t,{stream:!0})).split("\n");for(let e of(d=r.pop()||"",r))if(e.trim())try{let t=JSON.parse(e);"stdout"===t.type||"stderr"===t.type?eC(e=>[...e,t.data||""]):"result"===t.type&&(c=t)}catch(e){console.error("Failed to parse stream chunk:",e)}}if(d.trim())try{let e=JSON.parse(d);"result"===e.type&&(c=e)}catch(e){}if(!c||!c.success){let e="";if(c){if(c.error)e=c.error;else if(c.stdout)try{let t=JSON.parse(c.stdout);t&&t.error?e=t.error:Array.isArray(t)&&t.length>0&&t[t.length-1]?.error&&(e=t[t.length-1].error)}catch(e){}!e&&c.stderr&&(e=c.stderr.trim())}throw Error(e||"智能修正执行失败")}let p=null;try{p=JSON.parse(c.stdout)}catch(e){console.error("Failed to parse revise JSON output:",e)}p&&!p.applied?(ec(null),eg(null),ey(null),em(null),ef({applied:!1,skippedReason:p.skippedReason})):p?(ec(null),eg(null),ey(null),em(null),ef({applied:!0,fixedIssues:p.fixedIssues&&p.fixedIssues.length>0?p.fixedIssues:["优化并修正了人设与设定偏离"],status:p.status,wordCount:p.wordCount})):(ec(null),eg(null),ey(null),em(null),ef({applied:!0})),ea(""),await tL(e),await tv(),window.dispatchEvent(new CustomEvent("refresh-explorer"))}catch(e){console.error(e),ef(null),e.message.includes("超时")||e.message.includes("timed out")||eS.some(e=>e.includes("超时"))?ea(`### ⚠️ 智能修正超时
151
151
 
152
152
  系统运行已超过 1800 秒,已自动终止。
153
153
 
@@ -155,7 +155,13 @@ ${e.message||String(e)}
155
155
  - 在右上角【配置模型】中更换速度较快的对话模型后再试。`):ea(`### ⚠️ 智能修正失败
156
156
 
157
157
  **错误详情**:
158
- ${e.message||String(e)}`)}finally{X(!1)}},tz=async()=>{if(!t)return;ec(null),ex(null);let r=e_(e,t);if(r){ee(!0),eC([]),el("\uD83D\uDD04 同步设定"),ea("正在同步您修改的正文内容至故事真相账本中,并重新构建索引..."),ek(!0);try{"dirty"===O&&(P.current&&clearTimeout(P.current),await tR(D));let n=B(e).match(/^(\d+)/),o=n?parseInt(n[1],10):void 0,i=await fetch("/api/inkos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"write-sync",cwd:t,args:{bookId:r,chapter:o,json:!0}})});if(!i.ok)throw Error(`HTTP 异常 ${i.status}`);if(!i.body)throw Error("响应正文流为空");let l=i.body.getReader(),s=new TextDecoder,a="",d=null;for(;;){let{done:e,value:t}=await l.read();if(e)break;let r=(a+=s.decode(t,{stream:!0})).split("\n");for(let e of(a=r.pop()||"",r))if(e.trim())try{let t=JSON.parse(e);"stdout"===t.type||"stderr"===t.type?eC(e=>[...e,t.data||""]):"result"===t.type&&(d=t)}catch(e){console.error("Failed to parse stream chunk:",e)}}if(a.trim())try{let e=JSON.parse(a);"result"===e.type&&(d=e)}catch(e){}if(!d||!d.success){let e="";if(d){if(d.error)e=d.error;else if(d.stdout)try{let t=JSON.parse(d.stdout);t&&t.error?e=t.error:Array.isArray(t)&&t.length>0&&t[t.length-1]?.error&&(e=t[t.length-1].error)}catch(e){}!e&&d.stderr&&(e=d.stderr.trim())}throw Error(e||"同步设定失败")}let c=null;try{let e=JSON.parse(d.stdout);c=e[0]||e}catch(e){console.error("Failed to parse sync JSON output:",e)}let p=c?.auditResult;ec(null),eg(null),ef(null),em(null),eb({auditResult:p}),ea(""),window.dispatchEvent(new CustomEvent("refresh-explorer"))}catch(e){console.error(e),eb(null),ea(`### ⚠️ 同步设定失败
158
+ ${e.message||String(e)}`)}finally{X(!1)}},tI=async()=>{if(!t)return;ec(null),ex(null);let r=e_(e,t);if(r){ee(!0),eC([]),el("\uD83D\uDD04 同步设定"),ea("正在同步您修改的正文内容至故事真相账本中,并重新构建索引..."),ek(!0);try{"dirty"===F&&(P.current&&clearTimeout(P.current),await tR(D));let n=B(e).match(/^(\d+)/),o=n?parseInt(n[1],10):void 0,i=await fetch("/api/inkos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"write-sync",cwd:t,args:{bookId:r,chapter:o,json:!0}})});if(!i.ok)throw Error(`HTTP 异常 ${i.status}`);if(!i.body)throw Error("响应正文流为空");let l=i.body.getReader(),s=new TextDecoder,a="",d=null;for(;;){let{done:e,value:t}=await l.read();if(e)break;let r=(a+=s.decode(t,{stream:!0})).split("\n");for(let e of(a=r.pop()||"",r))if(e.trim())try{let t=JSON.parse(e);"stdout"===t.type||"stderr"===t.type?eC(e=>[...e,t.data||""]):"result"===t.type&&(d=t)}catch(e){console.error("Failed to parse stream chunk:",e)}}if(a.trim())try{let e=JSON.parse(a);"result"===e.type&&(d=e)}catch(e){}if(!d||!d.success){let e="";if(d){if(d.error)e=d.error;else if(d.stdout)try{let t=JSON.parse(d.stdout);t&&t.error?e=t.error:Array.isArray(t)&&t.length>0&&t[t.length-1]?.error&&(e=t[t.length-1].error)}catch(e){}!e&&d.stderr&&(e=d.stderr.trim())}throw Error(e||"同步设定失败")}let c=null;try{let e=JSON.parse(d.stdout);c=e[0]||e}catch(e){console.error("Failed to parse sync JSON output:",e)}let p=c?.auditResult;ec(null),eg(null),ef(null),em(null),ey({auditResult:p}),ea(""),window.dispatchEvent(new CustomEvent("refresh-explorer"))}catch(e){console.error(e),ey(null),ea(`### ⚠️ 同步设定失败
159
159
 
160
160
  **错误详情**:
161
- ${e.message||String(e)}`)}finally{ee(!1)}}};(0,o.useEffect)(()=>{J.current=O},[O]);let tR=(0,o.useCallback)(async t=>{N("saving");try{let r=$(e),n=await fetch(`/api/files/${r}`,{method:"POST",body:t});if(!n.ok)throw Error(`Failed to save file: ${n.statusText}`);N("saved")}catch(e){console.error(e),N("error")}},[e]),tL=(0,o.useCallback)((e,t=!1)=>{let r=$(e);return fetch(`/api/files/${r}?type=read`).then(e=>e.json()).then(e=>e.error?(b(e.error),null):(t?(x(t=>(t&&g(t.content),e)),z(e=>e+1)):x(e),e)).catch(e=>(b(String(e)),null))},[]);if((0,o.useEffect)(()=>{f(!0),b(null),x(null),g(null),m(!1),k("source"),S(!1),z(0),T(!1),P.current&&clearTimeout(P.current),N("saved"),M.current&&(M.current.close(),M.current=null),tL(e).then(e=>{e&&F(e.content)}).finally(()=>f(!1));let t=$(e),r=new EventSource(`/api/files/${t}?type=watch`);M.current=r,r.addEventListener("connected",()=>{T(!0)});let n=null;return r.addEventListener("change",()=>{n&&clearTimeout(n),n=setTimeout(()=>{"saved"===J.current&&tL(e,!0).then(e=>{e&&F(e.content)})},800)}),r.addEventListener("error",()=>{T(!1)}),r.onerror=()=>{T(!1)},()=>{n&&clearTimeout(n),P.current&&clearTimeout(P.current),r.close(),M.current=null}},[e,tL]),h)return(0,n.jsx)("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--text-muted)",fontSize:13},children:"Loading..."});if(y)return(0,n.jsx)("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"#f87171",fontSize:13},children:y});if(!p)return null;let tW="html"===p.language,tE="markdown"===p.language,tM=null!==u&&u!==p.content;return(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"4px 16px",borderBottom:"1px solid var(--border)",fontSize:11,color:"var(--text-dim)",background:"var(--bg)",flexShrink:0},children:[(0,n.jsx)("span",{style:{fontFamily:"var(--font-mono)"},title:e,children:A(e,t)}),null!==th&&eI&&(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,borderLeft:"1px solid var(--border)",paddingLeft:12},children:[(0,n.jsxs)("span",{onClick:eR.length>0?()=>eE(!0):void 0,title:eR.length>0?"点击查看审计详情":void 0,onMouseEnter:e=>{eR.length>0&&(e.currentTarget.style.filter="brightness(1.15)",e.currentTarget.style.transform="scale(1.02)")},onMouseLeave:e=>{eR.length>0&&(e.currentTarget.style.filter="none",e.currentTarget.style.transform="none")},style:{fontSize:"10px",padding:"2px 6px",borderRadius:"4px",fontWeight:600,cursor:eR.length>0?"pointer":"default",transition:"all 0.15s ease",color:"approved"===eI?"#10b981":"ready-for-review"===eI?"#eab308":"audit-failed"===eI?"#ef4444":"rejected"===eI?"#9ca3af":"var(--text-muted)",background:"approved"===eI?"rgba(16,185,129,0.08)":"ready-for-review"===eI?"rgba(234,179,8,0.08)":"audit-failed"===eI?"rgba(239,68,68,0.08)":"rejected"===eI?"rgba(156,163,175,0.08)":"var(--bg-hover)",border:`1px solid ${"approved"===eI?"#10b98125":"ready-for-review"===eI?"#eab30825":"audit-failed"===eI?"#ef444425":"rejected"===eI?"#9ca3af25":"transparent"}`},children:["approved"===eI?"已过审":"ready-for-review"===eI?"待审核":"audit-failed"===eI?"审计失败":"rejected"===eI?"已驳回":eI,eR.length>0&&(0,n.jsx)("span",{style:{marginLeft:4,fontSize:8},children:"\uD83D\uDD0D"})]}),"approved"!==eI&&(0,n.jsxs)("div",{style:{display:"flex",gap:6},children:[(0,n.jsx)("button",{onClick:tm,disabled:eA,style:{padding:"2px 8px",fontSize:10,cursor:eA?"not-allowed":"pointer",background:"rgba(16,185,129,0.08)",color:"#10b981",border:"1px solid rgba(16,185,129,0.25)",borderRadius:5,fontWeight:600,whiteSpace:"nowrap"},title:"批准并提交该章节状态为已过审",children:eA?"处理中...":"✅ 批准章节"}),(0,n.jsx)("button",{onClick:()=>eJ(!0),disabled:eA,style:{padding:"2px 8px",fontSize:10,cursor:eA?"not-allowed":"pointer",background:"rgba(239,68,68,0.08)",color:"#ef4444",border:"1px solid rgba(239,68,68,0.25)",borderRadius:5,fontWeight:600,whiteSpace:"nowrap"},title:"驳回并回滚故事状态到该章之前",children:eA?"处理中...":"❌ 驳回重构"})]})]}),(0,n.jsxs)("span",{title:C?"Live sync active":"Not watching",style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:4,color:C?"#4ade80":"var(--text-dim)"},children:[(0,n.jsx)("span",{style:{width:7,height:7,borderRadius:"50%",background:C?"#4ade80":"var(--border)",display:"inline-block",boxShadow:C?"0 0 4px #4ade80":"none"}}),C?"live":"static"]}),tM&&(0,n.jsxs)("div",{style:{display:"flex",borderRadius:5,overflow:"hidden",border:"1px solid var(--border)"},children:[(0,n.jsx)("button",{onClick:()=>k("source"),style:{padding:"2px 8px",fontSize:11,border:"none",cursor:"pointer",background:"source"===j?"var(--bg-selected)":"var(--bg-hover)",color:"source"===j?"var(--text)":"var(--text-muted)",fontWeight:"source"===j?600:400},children:"Source"}),(0,n.jsxs)("button",{onClick:()=>k("diff"),style:{padding:"2px 8px",fontSize:11,border:"none",borderLeft:"1px solid var(--border)",cursor:"pointer",background:"diff"===j?"var(--bg-selected)":"var(--bg-hover)",color:"diff"===j?"var(--text)":"var(--text-muted)",fontWeight:"diff"===j?600:400},children:["Diff ",I>0&&(0,n.jsxs)("span",{style:{color:"#4ade80",marginLeft:2},children:["+",I]})]})]}),"source"===j&&!v&&(0,n.jsx)("button",{onClick:()=>S(e=>!e),title:w?"Disable word wrap":"Enable word wrap",style:{padding:"2px 8px",fontSize:11,cursor:"pointer",background:w?"var(--bg-selected)":"var(--bg-hover)",color:w?"var(--text)":"var(--text-muted)",border:"1px solid var(--border)",borderRadius:5,fontWeight:w?600:400},children:"wrap"}),tW&&"source"===j&&(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[(0,n.jsxs)("div",{style:{display:"flex",borderRadius:5,overflow:"hidden",border:"1px solid var(--border)"},children:[(0,n.jsx)("button",{onClick:()=>m(!1),style:{padding:"2px 8px",fontSize:11,border:"none",cursor:"pointer",background:v?"var(--bg-hover)":"var(--bg-selected)",color:v?"var(--text-muted)":"var(--text)",fontWeight:v?400:600},children:"Code"}),(0,n.jsx)("button",{onClick:()=>m(!0),style:{padding:"2px 8px",fontSize:11,border:"none",borderLeft:"1px solid var(--border)",cursor:"pointer",background:v?"var(--bg-selected)":"var(--bg-hover)",color:v?"var(--text)":"var(--text-muted)",fontWeight:v?600:400},children:"Preview"})]}),v&&(0,n.jsx)("button",{onClick:()=>E(!0),title:"Open preview in fullscreen modal",style:{padding:"2px 8px",fontSize:11,cursor:"pointer",background:"var(--bg-hover)",color:"var(--text-muted)",border:"1px solid var(--border)",borderRadius:5,fontWeight:400},children:"\uD83D\uDD0D Zoom"})]}),tE&&"source"===j&&(0,n.jsxs)("div",{style:{display:"flex",borderRadius:5,overflow:"hidden",border:"1px solid var(--border)"},children:[(0,n.jsx)("button",{onClick:()=>m(!0),style:{padding:"2px 8px",fontSize:11,border:"none",cursor:"pointer",background:v?"var(--bg-selected)":"var(--bg-hover)",color:v?"var(--text)":"var(--text-muted)",fontWeight:v?600:400},children:"排版预览"}),(0,n.jsx)("button",{onClick:()=>m(!1),style:{padding:"2px 8px",fontSize:11,border:"none",borderLeft:"1px solid var(--border)",cursor:"pointer",background:v?"var(--bg-hover)":"var(--bg-selected)",color:v?"var(--text-muted)":"var(--text)",fontWeight:v?400:600},children:"沉浸创作"})]}),"source"===j&&!v&&(0,n.jsxs)("button",{onClick:()=>{navigator.clipboard.writeText(D).then(()=>{L(!0),setTimeout(()=>L(!1),2e3)})},title:"Copy to clipboard",style:{padding:"2px 8px",fontSize:11,cursor:"pointer",background:R?"rgba(74,222,128,0.15)":"var(--bg-hover)",color:R?"#4ade80":"var(--text-muted)",border:"1px solid var(--border)",borderRadius:5,display:"flex",alignItems:"center",gap:4,transition:"background 0.15s, color 0.15s"},children:[R?(0,n.jsx)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("polyline",{points:"20 6 9 17 4 12"})}):(0,n.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),(0,n.jsx)("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]}),R?"Copied":"Copy"]})]}),(0,n.jsx)("div",{style:{flex:1,overflow:"auto",background:"var(--bg)",display:"flex",flexDirection:"column"},children:"diff"===j&&tM?(0,n.jsx)("div",{style:{flex:1,overflow:"auto"},children:(0,n.jsx)(eU,{oldContent:u,newContent:D,language:p.language})}):tW&&v?(0,n.jsx)("div",{style:{flex:1,overflow:"hidden"},children:(0,n.jsx)("iframe",{srcDoc:D,sandbox:"allow-scripts",style:{width:"100%",height:"100%",border:"none",background:"var(--bg)"},title:"HTML preview"})}):tE&&v?(0,n.jsx)("div",{style:{flex:1,overflow:"auto"},children:(0,n.jsx)("div",{className:"markdown-body markdown-file-preview",style:{padding:"32px 48px",maxWidth:800,margin:"0 auto",fontFamily:"var(--font-serif)"},children:(0,n.jsx)(H.oz,{remarkPlugins:[_.A],children:D})})}):"markdown"===p.language||"text"===p.language?(0,n.jsxs)("div",{style:{flex:1,display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"},children:[(0,n.jsx)("textarea",{value:D,onChange:e=>{var t;F(t=e.target.value),N("dirty"),P.current&&clearTimeout(P.current),P.current=setTimeout(()=>{tR(t)},1500)},placeholder:"在这里开始您的文学创作...",spellCheck:!1,style:{flex:1,width:"100%",padding:"32px 48px",background:"var(--bg)",color:"var(--text)",fontFamily:"var(--font-serif)",fontSize:"16px",lineHeight:"1.8",border:"none",outline:"none",resize:"none",boxSizing:"border-box",overflowY:"auto",caretColor:"var(--accent)"}}),(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"0 16px",height:"35px",boxSizing:"border-box",background:"var(--bg-panel)",borderTop:"1px solid var(--border)",fontSize:"11px",color:"var(--text-muted)",fontFamily:"var(--font-serif)",flexShrink:0},children:[(0,n.jsxs)("div",{children:["字数: ",(0,n.jsxs)("span",{style:{fontWeight:600,color:"var(--text)",marginRight:16},children:[D.length," 字"]}),"行数: ",(0,n.jsxs)("span",{style:{fontWeight:600,color:"var(--text)"},children:[D.split("\n").length," 行"]})]}),t&&(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[i&&(0,n.jsxs)("span",{title:`当前已启用 ${i} 写作风格指南`,style:{padding:"3px 8px",background:"rgba(139, 92, 246, 0.08)",border:"1px solid rgba(139, 92, 246, 0.2)",borderRadius:"12px",fontSize:"10px",color:"#a78bfa",fontFamily:"var(--font-mono)",display:"inline-flex",alignItems:"center",gap:"4px",marginRight:4},children:[(0,n.jsx)("span",{children:"\uD83C\uDFAD"}),(0,n.jsx)("span",{style:{fontWeight:600},children:i})]}),(0,n.jsxs)("div",{style:{position:"relative",display:"inline-flex",alignItems:"stretch"},onMouseLeave:()=>e8(!1),children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",background:"rgba(249, 115, 22, 0.08)",border:"1px solid rgba(249, 115, 22, 0.4)",borderRadius:"6px",transition:"all 0.2s ease",boxShadow:"0 1px 2px rgba(0, 0, 0, 0.05)"},children:[(0,n.jsx)("button",{onClick:"normal"===e2?()=>tb("write-next",()=>tC(!1)):()=>e9(!0),disabled:q||Z||Q||U||Y||"saving"===O,style:{padding:"5px 10px 5px 12px",background:"none",border:"none",borderRadius:"5px 0 0 5px",color:"#ff903f",cursor:"pointer",fontSize:"11px",fontWeight:600,fontFamily:"var(--font-serif)",whiteSpace:"nowrap",outline:"none",display:"flex",alignItems:"center"},onMouseEnter:e=>{e.currentTarget.parentElement.style.background="rgba(249, 115, 22, 0.16)",e.currentTarget.parentElement.style.borderColor="#f97316",e.currentTarget.style.color="#ffaa64"},onMouseLeave:e=>{e.currentTarget.parentElement.style.background="rgba(249, 115, 22, 0.08)",e.currentTarget.parentElement.style.borderColor="rgba(249, 115, 22, 0.4)",e.currentTarget.style.color="#ff903f"},children:q?"normal"===e2?"正在续写...":"正在起草...":"normal"===e2?(0,n.jsxs)("span",{style:{display:"flex",alignItems:"center"},children:[(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{marginRight:5},children:[(0,n.jsx)("path",{d:"M12 20h9"}),(0,n.jsx)("path",{d:"M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z"})]}),"智能续写"]}):(0,n.jsxs)("span",{style:{display:"flex",alignItems:"center"},children:[(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{marginRight:5},children:[(0,n.jsx)("path",{d:"M4.5 16.5c-1.5 1.25-2.5 3.5-2.5 3.5h13.5"}),(0,n.jsx)("path",{d:"M12 2h9v9"}),(0,n.jsx)("path",{d:"M21 2 9 14"})]}),"极速草稿"]})}),(0,n.jsx)("div",{style:{width:"1px",alignSelf:"stretch",background:"rgba(249, 115, 22, 0.3)",margin:"4px 0"}}),(0,n.jsx)("button",{onClick:()=>e8(!e5),disabled:q||Z||Q||U||Y||"saving"===O,style:{padding:"5px 8px",background:"none",border:"none",borderRadius:"0 5px 5px 0",color:"#ff903f",cursor:"pointer",fontSize:"10px",outline:"none",display:"flex",alignItems:"center",justifyContent:"center"},onMouseEnter:e=>{e.currentTarget.parentElement.style.background="rgba(249, 115, 22, 0.16)",e.currentTarget.parentElement.style.borderColor="#f97316",e.currentTarget.style.color="#ffaa64"},onMouseLeave:e=>{e.currentTarget.parentElement.style.background="rgba(249, 115, 22, 0.08)",e.currentTarget.parentElement.style.borderColor="rgba(249, 115, 22, 0.4)",e.currentTarget.style.color="#ff903f"},children:"▾"})]}),e5&&(0,n.jsx)("div",{style:{position:"absolute",bottom:"100%",right:0,paddingBottom:"6px",minWidth:"220px",zIndex:105},children:(0,n.jsxs)("div",{style:{background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:"8px",boxShadow:"0 10px 25px rgba(0, 0, 0, 0.15)",padding:"6px",display:"flex",flexDirection:"column",gap:"2px",animation:"fadeIn 0.15s ease-out"},children:[(0,n.jsx)("div",{style:{fontSize:"9px",color:"var(--text-dim)",padding:"4px 8px 2px",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em"},children:"选择创作模式"}),(0,n.jsxs)("button",{onClick:()=>{e6("normal"),e8(!1)},style:{display:"flex",flexDirection:"column",alignItems:"flex-start",padding:"8px 10px",borderRadius:"6px",border:"none",background:"normal"===e2?"var(--bg-selected)":"transparent",cursor:"pointer",width:"100%",textAlign:"left",fontFamily:"var(--font-serif)",transition:"background 0.2s"},onMouseEnter:e=>{"normal"!==e2&&(e.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:e=>{"normal"!==e2&&(e.currentTarget.style.background="transparent")},children:[(0,n.jsxs)("div",{style:{fontSize:"11px",fontWeight:600,color:"var(--text)",display:"flex",alignItems:"center"},children:[(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{marginRight:5},children:[(0,n.jsx)("path",{d:"M12 20h9"}),(0,n.jsx)("path",{d:"M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z"})]}),"智能续写 (标准模式)"]}),(0,n.jsx)("div",{style:{fontSize:"9px",color:"var(--text-muted)",marginTop:"2px"},children:"包含设定同步、防崩逻辑审计与AI智能局部修正"})]}),(0,n.jsxs)("button",{onClick:()=>{e6("draft"),e8(!1)},style:{display:"flex",flexDirection:"column",alignItems:"flex-start",padding:"8px 10px",borderRadius:"6px",border:"none",background:"draft"===e2?"var(--bg-selected)":"transparent",cursor:"pointer",width:"100%",textAlign:"left",fontFamily:"var(--font-serif)",transition:"background 0.2s"},onMouseEnter:e=>{"draft"!==e2&&(e.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:e=>{"draft"!==e2&&(e.currentTarget.style.background="transparent")},children:[(0,n.jsxs)("div",{style:{fontSize:"11px",fontWeight:600,color:"var(--text)",display:"flex",alignItems:"center"},children:[(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{marginRight:5},children:[(0,n.jsx)("path",{d:"M4.5 16.5c-1.5 1.25-2.5 3.5-2.5 3.5h13.5"}),(0,n.jsx)("path",{d:"M12 2h9v9"}),(0,n.jsx)("path",{d:"M21 2 9 14"})]}),"极速草稿 (快跑模式)"]}),(0,n.jsx)("div",{style:{fontSize:"9px",color:"var(--text-muted)",marginTop:"2px"},children:"直接生成初稿以追求连贯灵感,支持字数控制与创意引导"})]})]})})]}),(0,n.jsx)("button",{onClick:()=>tb("audit",tk),disabled:U||q||Z||Q||Y||"saving"===O,style:{padding:"5px 12px",background:"rgba(59, 130, 246, 0.08)",border:"1px solid rgba(59, 130, 246, 0.4)",borderRadius:"6px",color:"#60a5fa",cursor:"pointer",fontSize:"11px",fontWeight:600,fontFamily:"var(--font-serif)",transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)",boxShadow:"0 1px 2px rgba(0, 0, 0, 0.05)",whiteSpace:"nowrap"},onMouseEnter:e=>{e.currentTarget.style.background="rgba(59, 130, 246, 0.16)",e.currentTarget.style.borderColor="#3b82f6",e.currentTarget.style.color="#93c5fd",e.currentTarget.style.transform="translateY(-1px)",e.currentTarget.style.boxShadow="0 4px 12px rgba(59, 130, 246, 0.2)"},onMouseLeave:e=>{e.currentTarget.style.background="rgba(59, 130, 246, 0.08)",e.currentTarget.style.borderColor="rgba(59, 130, 246, 0.4)",e.currentTarget.style.color="#60a5fa",e.currentTarget.style.transform="none",e.currentTarget.style.boxShadow="0 1px 2px rgba(0, 0, 0, 0.05)"},children:U?"正在审计中...":(0,n.jsxs)("span",{style:{display:"flex",alignItems:"center"},children:[(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{marginRight:5},children:[(0,n.jsx)("circle",{cx:"11",cy:"11",r:"7"}),(0,n.jsx)("path",{d:"m21 21-4.3-4.3"}),(0,n.jsx)("path",{d:"m8 11 2 2 4-4"})]}),"防崩审计"]})}),(0,n.jsx)("button",{onClick:()=>tb("sync",tz),disabled:Q||q||Z||U||Y||"saving"===O,style:{padding:"5px 12px",background:"rgba(16, 185, 129, 0.08)",border:"1px solid rgba(16, 185, 129, 0.4)",borderRadius:"6px",color:"#34d399",cursor:"pointer",fontSize:"11px",fontWeight:600,fontFamily:"var(--font-serif)",transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)",boxShadow:"0 1px 2px rgba(0, 0, 0, 0.05)",whiteSpace:"nowrap"},onMouseEnter:e=>{e.currentTarget.style.background="rgba(16, 185, 129, 0.16)",e.currentTarget.style.borderColor="#10b981",e.currentTarget.style.color="#6ee7b7",e.currentTarget.style.transform="translateY(-1px)",e.currentTarget.style.boxShadow="0 4px 12px rgba(16, 185, 129, 0.2)"},onMouseLeave:e=>{e.currentTarget.style.background="rgba(16, 185, 129, 0.08)",e.currentTarget.style.borderColor="rgba(16, 185, 129, 0.4)",e.currentTarget.style.color="#34d399",e.currentTarget.style.transform="none",e.currentTarget.style.boxShadow="0 1px 2px rgba(0, 0, 0, 0.05)"},children:Q?"正在同步中...":(0,n.jsxs)("span",{style:{display:"flex",alignItems:"center"},children:[(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{marginRight:5},children:[(0,n.jsx)("path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"}),(0,n.jsx)("path",{d:"M16 3h5v5"}),(0,n.jsx)("path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"}),(0,n.jsx)("path",{d:"M8 21H3v-5"})]}),"同步设定"]})}),(0,n.jsx)("button",{onClick:()=>tb("plan",tS),disabled:Y||q||Z||Q||U||"saving"===O,style:{padding:"5px 12px",background:"rgba(168, 85, 247, 0.08)",border:"1px solid rgba(168, 85, 247, 0.4)",borderRadius:"6px",color:"#c084fc",cursor:"pointer",fontSize:"11px",fontWeight:600,fontFamily:"var(--font-serif)",transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)",boxShadow:"0 1px 2px rgba(0, 0, 0, 0.05)",whiteSpace:"nowrap"},onMouseEnter:e=>{e.currentTarget.style.background="rgba(168, 85, 247, 0.16)",e.currentTarget.style.borderColor="#a855f7",e.currentTarget.style.color="#d8b4fe",e.currentTarget.style.transform="translateY(-1px)",e.currentTarget.style.boxShadow="0 4px 12px rgba(168, 85, 247, 0.2)"},onMouseLeave:e=>{e.currentTarget.style.background="rgba(168, 85, 247, 0.08)",e.currentTarget.style.borderColor="rgba(168, 85, 247, 0.4)",e.currentTarget.style.color="#c084fc",e.currentTarget.style.transform="none",e.currentTarget.style.boxShadow="0 1px 2px rgba(0, 0, 0, 0.05)"},children:Y?"正在规划中...":(0,n.jsxs)("span",{style:{display:"flex",alignItems:"center"},children:[(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{marginRight:5},children:[(0,n.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),(0,n.jsx)("path",{d:"M21 9H3M21 15H3M12 3v18"})]}),"规划蓝图"]})}),(a=(s=ti.startsWith("detect-"))?{text:"#a78bfa",textHover:"#c084fc",bg:"rgba(139, 92, 246, 0.08)",bgHover:"rgba(139, 92, 246, 0.16)",border:"rgba(139, 92, 246, 0.4)",borderHover:"#8b5cf6",separator:"rgba(139, 92, 246, 0.3)"}:{text:"#2dd4bf",textHover:"#5eead4",bg:"rgba(20, 184, 166, 0.08)",bgHover:"rgba(20, 184, 166, 0.16)",border:"rgba(20, 184, 166, 0.4)",borderHover:"#14b8a6",separator:"rgba(20, 184, 166, 0.3)"},(0,n.jsxs)("div",{style:{position:"relative",display:"inline-flex",alignItems:"stretch"},onMouseLeave:()=>ta(!1),children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",background:a.bg,border:`1px solid ${a.border}`,borderRadius:"6px",transition:"all 0.2s ease",boxShadow:"0 1px 2px rgba(0, 0, 0, 0.05)"},children:[(0,n.jsx)("button",{onClick:()=>{"detect-llm"===ti?tb("detect-llm",()=>tw("llm")):tb(ti,()=>tI(ti))},disabled:Z||et||q||Q||U||Y||"saving"===O,style:{padding:"5px 10px 5px 12px",background:"none",border:"none",borderRadius:"5px 0 0 5px",color:a.text,cursor:"pointer",fontSize:"11px",fontWeight:600,fontFamily:"var(--font-serif)",whiteSpace:"nowrap",outline:"none",display:"flex",alignItems:"center"},onMouseEnter:e=>{e.currentTarget.parentElement.style.background=a.bgHover,e.currentTarget.parentElement.style.borderColor=a.borderHover,e.currentTarget.style.color=a.textHover},onMouseLeave:e=>{e.currentTarget.parentElement.style.background=a.bg,e.currentTarget.parentElement.style.borderColor=a.border,e.currentTarget.style.color=a.text},children:Z||et?Z?"正在修正...":"正在检测...":(0,n.jsxs)("span",{style:{display:"flex",alignItems:"center"},children:[s?(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{marginRight:5},children:[(0,n.jsx)("circle",{cx:"11",cy:"11",r:"7"}),(0,n.jsx)("path",{d:"m21 21-4.3-4.3"}),(0,n.jsx)("rect",{x:"9",y:"9",width:"4",height:"4",rx:"1"})]}):(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{marginRight:5},children:[(0,n.jsx)("path",{d:"m12 3-1.912 5.813a2 2 0 0 1-1.275 1.275L3 12l5.813 1.912a2 2 0 0 1 1.275 1.275L12 21l1.912-5.813a2 2 0 0 1 1.275-1.275L21 12l-5.813-1.912a2 2 0 0 1-1.275-1.275Z"}),(0,n.jsx)("path",{d:"m5 3 1 2.5L8.5 6 6 7 5 9.5 4 7 1.5 6 4 5Z",opacity:"0.6"})]}),"detect-llm"===ti&&"检测 AI 味","spot-fix"===ti&&"局部定点修复","anti-detect"===ti&&"防检测润色","polish"===ti&&"文本润色","rewrite"===ti&&"智能改写","rework"===ti&&"剧情重写"]})}),(0,n.jsx)("div",{style:{width:"1px",alignSelf:"stretch",background:a.separator,margin:"4px 0"}}),(0,n.jsx)("button",{onClick:()=>ta(!ts),disabled:Z||et||q||Q||U||Y||"saving"===O,style:{padding:"5px 8px",background:"none",border:"none",borderRadius:"0 5px 5px 0",color:a.text,cursor:"pointer",fontSize:"10px",outline:"none",display:"flex",alignItems:"center",justifyContent:"center"},onMouseEnter:e=>{e.currentTarget.parentElement.style.background=a.bgHover,e.currentTarget.parentElement.style.borderColor=a.borderHover,e.currentTarget.style.color=a.textHover},onMouseLeave:e=>{e.currentTarget.parentElement.style.background=a.bg,e.currentTarget.parentElement.style.borderColor=a.border,e.currentTarget.style.color=a.text},children:"▾"})]}),ts&&(0,n.jsx)("div",{style:{position:"absolute",bottom:"100%",right:0,paddingBottom:"6px",minWidth:"220px",zIndex:105},children:(0,n.jsxs)("div",{style:{background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:"8px",boxShadow:"0 10px 25px rgba(0, 0, 0, 0.15)",padding:"6px",display:"flex",flexDirection:"column",gap:"2px",animation:"fadeIn 0.15s ease-out"},children:[(0,n.jsx)("div",{style:{fontSize:"9px",color:"var(--text-dim)",padding:"4px 8px 2px",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em"},children:"选择修正模式"}),[{mode:"detect-llm",label:"检测 AI 味",desc:"大模型智能评估,只分析特征提供诊断报告,不动正文",isDetect:!0},{mode:"spot-fix",label:"局部定点修复",desc:"微调修复叙事前后矛盾与逻辑不一致",isDetect:!1},{mode:"anti-detect",label:"防检测润色",desc:"消除 AI 腔调与高频标记词,使文字表达自然流畅",isDetect:!1},{mode:"polish",label:"文本润色",desc:"雕琢词句提升文学性,保留全部原有情节",isDetect:!1},{mode:"rewrite",label:"智能改写",desc:"重写特定段落,丰富对话、情绪和动作描写",isDetect:!1},{mode:"rework",label:"剧情重写",desc:"根据最新意图和大纲完全重写本章",isDetect:!1}].map(e=>(0,n.jsxs)("button",{onClick:()=>{tl(e.mode),ta(!1)},style:{display:"flex",flexDirection:"column",alignItems:"flex-start",padding:"8px 10px",borderRadius:"6px",border:"none",background:ti===e.mode?"var(--bg-selected)":"transparent",cursor:"pointer",width:"100%",textAlign:"left",fontFamily:"var(--font-serif)",transition:"background 0.2s"},onMouseEnter:t=>{ti!==e.mode&&(t.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:t=>{ti!==e.mode&&(t.currentTarget.style.background="transparent")},children:[(0,n.jsxs)("div",{style:{fontSize:"11px",fontWeight:600,color:"var(--text)",display:"flex",alignItems:"center"},children:[e.isDetect?(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{marginRight:5},children:[(0,n.jsx)("circle",{cx:"11",cy:"11",r:"7"}),(0,n.jsx)("path",{d:"m21 21-4.3-4.3"}),(0,n.jsx)("rect",{x:"9",y:"9",width:"4",height:"4",rx:"1"})]}):(0,n.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{marginRight:5},children:(0,n.jsx)("path",{d:"m12 3-1.912 5.813a2 2 0 0 1-1.275 1.275L3 12l5.813 1.912a2 2 0 0 1 1.275 1.275L12 21l1.912-5.813a2 2 0 0 1 1.275-1.275L21 12l-5.813-1.912a2 2 0 0 1-1.275-1.275Z"})}),e.label]}),(0,n.jsx)("div",{style:{fontSize:"9px",color:"var(--text-muted)",marginTop:"2px"},children:e.desc})]},e.mode))]})})]}))]}),(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[!ej&&(ew||ed||ep||eu||eh||ey||ev||es)&&(0,n.jsxs)("button",{onClick:()=>ek(!0),style:{display:"flex",alignItems:"center",gap:4,padding:"3px 8px",background:"rgba(255, 255, 255, 0.04)",border:"1px solid var(--border)",borderRadius:4,color:"var(--text-muted)",fontSize:10,cursor:"pointer",fontFamily:"var(--font-serif)",transition:"all 0.15s",marginRight:6},onMouseEnter:e=>{e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color="var(--text)"},onMouseLeave:e=>{e.currentTarget.style.background="rgba(255, 255, 255, 0.04)",e.currentTarget.style.color="var(--text-muted)"},children:[(0,n.jsx)("span",{children:ew?"⏳":"\uD83D\uDCCB"}),(0,n.jsx)("span",{children:ew?"查看运行进度":"查看报告"})]}),"saving"===O&&(0,n.jsxs)("span",{style:{display:"flex",alignItems:"center",gap:4,color:"var(--accent)"},children:[(0,n.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",style:{animation:"spin 1s linear infinite"},children:[(0,n.jsx)("line",{x1:"12",y1:"2",x2:"12",y2:"6"}),(0,n.jsx)("line",{x1:"12",y1:"18",x2:"12",y2:"22"}),(0,n.jsx)("line",{x1:"4.93",y1:"4.93",x2:"7.76",y2:"7.76"}),(0,n.jsx)("line",{x1:"16.24",y1:"16.24",x2:"19.07",y2:"19.07"})]}),"自动保存中..."]}),"saved"===O&&(0,n.jsxs)("span",{style:{color:"#22c55e",display:"flex",alignItems:"center",gap:4},children:[(0,n.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3.5",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("polyline",{points:"20 6 9 17 4 12"})}),"已自动保存"]}),"dirty"===O&&(0,n.jsx)("span",{style:{color:"var(--text-dim)"},children:"编辑中..."}),"error"===O&&(0,n.jsx)("span",{style:{color:"#ef4444"},children:"⚠️ 自动保存失败"})]})]})]}):(0,n.jsx)("div",{style:{flex:1,overflow:"auto"},children:(0,n.jsx)(eM.A,{language:"text"===p.language?"plaintext":p.language,style:c?eD.xJ:eD.vs,showLineNumbers:!0,lineNumberStyle:{color:"var(--text-dim)",fontStyle:"normal",minWidth:"3em",paddingRight:"1em"},customStyle:{margin:0,padding:"12px 0",background:"var(--bg)",fontSize:13,lineHeight:1.6,fontFamily:"var(--font-mono)",minHeight:"100%"},codeTagProps:{style:{fontFamily:"var(--font-mono)"}},wrapLongLines:w,children:D})})}),W&&(0,n.jsxs)("div",{style:{position:"fixed",inset:0,zIndex:1e3,background:"rgba(10, 10, 10, 0.95)",backdropFilter:"blur(8px)",display:"flex",flexDirection:"column",padding:"20px 24px",color:"white"},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:16,flexShrink:0},children:[(0,n.jsx)("span",{style:{fontSize:13,color:"#ccc",fontWeight:500},children:"HTML Fullscreen Preview"}),(0,n.jsx)("button",{onClick:()=>E(!1),style:{padding:"6px 16px",fontSize:12,borderRadius:4,border:"none",background:"#ef4444",color:"white",cursor:"pointer",fontWeight:600},children:"✕ Close"})]}),(0,n.jsx)("div",{style:{flex:1,background:"white",borderRadius:8,overflow:"hidden",boxShadow:"0 10px 30px rgba(0,0,0,0.5)"},children:(0,n.jsx)("iframe",{srcDoc:p.content,sandbox:"allow-scripts",style:{width:"100%",height:"100%",border:"none"},title:"HTML fullscreen preview"})})]}),ej&&(0,n.jsx)("div",{style:{position:"fixed",inset:0,zIndex:1e3,background:"rgba(10, 10, 10, 0.4)",backdropFilter:"blur(4px)",display:"flex",justifyContent:"flex-end",color:"var(--text)"},children:(0,n.jsxs)("div",{style:{width:"min(600px, 90%)",height:"100%",background:"var(--bg)",boxShadow:"-10px 0 30px rgba(0,0,0,0.15)",display:"flex",flexDirection:"column",borderLeft:"1px solid var(--border)",fontFamily:"var(--font-serif)"},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 24px",borderBottom:"1px solid var(--border)",background:"var(--bg-panel)",flexShrink:0},children:[(0,n.jsx)("span",{style:{fontSize:13,fontWeight:600},children:ei}),(0,n.jsx)("button",{onClick:()=>{ew||ek(!1)},disabled:ew,style:{padding:"4px 12px",fontSize:11,borderRadius:4,border:"1px solid var(--border)",background:ew?"var(--bg)":"var(--bg-hover)",color:ew?"var(--text-dim)":"var(--text-muted)",cursor:ew?"not-allowed":"pointer",opacity:ew?.6:1,fontWeight:600,fontFamily:"var(--font-serif)"},children:ew?"执行中...":"✕ 关闭"})]}),(0,n.jsx)("div",{style:{flex:1,padding:"24px 32px",overflowY:"auto",lineHeight:"1.8",fontSize:"14px",display:"flex",flexDirection:"column"},className:"markdown-body markdown-file-preview",children:q||U||Y||Z||Q||et?(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",flex:1,minHeight:0},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:16,flexShrink:0},children:[(0,n.jsx)("div",{style:{width:"16px",height:"16px",border:"2px solid var(--border)",borderTopColor:"var(--accent)",borderRadius:"50%",animation:"spin 1s linear infinite",flexShrink:0}}),(0,n.jsx)("span",{style:{fontSize:13,fontWeight:500,color:"var(--text-muted)"},children:"正在执行指令,实时进度如下:"})]}),(0,n.jsx)("div",{ref:eT,style:{flex:1,background:"#121214",border:"1px solid var(--border)",borderRadius:"6px",padding:"12px",overflowY:"auto",fontFamily:"var(--font-mono), monospace",fontSize:"11px",lineHeight:"1.5",color:"#e4e4e7",whiteSpace:"pre-wrap",wordBreak:"break-all"},children:0===eS.length?(0,n.jsx)("span",{style:{color:"var(--text-dim)"},children:"正在准备执行环境..."}):eS.map((e,t)=>(0,n.jsx)("div",{style:{marginBottom:2},children:e},t))})]}):(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",flex:1,minHeight:0},children:[(0,n.jsx)("div",{style:{flex:1,overflowY:"auto"},children:ep?(0,n.jsx)(eG,{data:ep}):ed?(0,n.jsx)(eZ,{data:ed}):eu?(0,n.jsx)(eX,{data:eu}):eh?(0,n.jsx)(eQ,{data:eh}):ey?(0,n.jsx)(e0,{data:ey}):ev?(0,n.jsx)(e1,{data:ev}):(0,n.jsx)(H.oz,{remarkPlugins:[_.A],children:es})}),eS.length>0&&(0,n.jsx)("div",{style:{marginTop:20,borderTop:"1px solid var(--border)",paddingTop:12,flexShrink:0},children:(0,n.jsxs)("details",{style:{cursor:"pointer",fontSize:12,color:"var(--text-muted)"},children:[(0,n.jsx)("summary",{style:{fontWeight:600,marginBottom:8,userSelect:"none"},children:"查看控制台运行日志"}),(0,n.jsx)("div",{style:{background:"#121214",border:"1px solid var(--border)",borderRadius:"6px",padding:"12px",maxHeight:"180px",overflowY:"auto",fontFamily:"var(--font-mono), monospace",fontSize:"11px",lineHeight:"1.5",color:"#e4e4e7",whiteSpace:"pre-wrap",wordBreak:"break-all",textAlign:"left"},children:eS.map((e,t)=>(0,n.jsx)("div",{style:{marginBottom:2},children:e},t))})]})})]})})]})}),eH&&(0,n.jsx)("div",{style:{position:"fixed",inset:0,zIndex:1100,background:"rgba(15, 10, 10, 0.4)",backdropFilter:"blur(6px)",display:"flex",alignItems:"center",justifyContent:"center",animation:"fadeIn 0.2s ease-out"},children:(0,n.jsxs)("div",{style:{width:"min(480px, 90%)",background:"var(--bg-panel)",border:"1px solid rgba(239, 68, 68, 0.2)",borderRadius:"12px",boxShadow:"0 20px 40px rgba(0, 0, 0, 0.3)",display:"flex",flexDirection:"column",overflow:"hidden",fontFamily:"var(--font-serif)"},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"16px 20px",background:"rgba(239, 68, 68, 0.08)",borderBottom:"1px solid rgba(239, 68, 68, 0.15)",color:"#ef4444",fontWeight:600,fontSize:14},children:[(0,n.jsx)("span",{style:{fontSize:16},children:"⚠️"}),(0,n.jsx)("span",{children:"确认驳回并重构章节"})]}),(0,n.jsxs)("div",{style:{padding:"20px",display:"flex",flexDirection:"column",gap:16},children:[(0,n.jsxs)("div",{style:{background:"rgba(239, 68, 68, 0.04)",border:"1px solid rgba(239, 68, 68, 0.1)",borderRadius:"8px",padding:"12px 14px",fontSize:12,color:"var(--text)",lineHeight:"1.6"},children:[(0,n.jsx)("span",{style:{color:"#ef4444",fontWeight:600,display:"block",marginBottom:4},children:"⚠️ 毁灭性操作警告:"}),"驳回该章节将",(0,n.jsx)("strong",{children:"删除此章节及所有后续章节"}),",并将书籍与AI系统的状态数据库回滚到前一章节(第 ",th?th-1:0," 章)。此操作会丢弃当前章节的所有生成数据与文件,",(0,n.jsx)("strong",{children:"且无法撤销!"})]}),(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[(0,n.jsx)("span",{style:{fontSize:12,color:"var(--text-muted)",fontWeight:500},children:"请输入驳回重构的具体原因(可选,将作为重构的指导上下文):"}),(0,n.jsx)("textarea",{value:eV,onChange:e=>eY(e.target.value),placeholder:"例如:剧情节奏太慢,角色性格偏离设定,或者需要重新规划意图...",disabled:eA,style:{width:"100%",height:"90px",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:"6px",padding:"8px 12px",fontSize:12,color:"var(--text)",fontFamily:"var(--font-serif)",resize:"none",outline:"none"}})]}),eN&&(0,n.jsx)("div",{style:{color:"#ef4444",fontSize:12,background:"rgba(239, 68, 68, 0.05)",border:"1px solid rgba(239, 68, 68, 0.15)",borderRadius:"6px",padding:"8px 12px"},children:eN}),eA&&e$.length>0&&(0,n.jsx)("div",{style:{background:"#121214",border:"1px solid var(--border)",borderRadius:"6px",padding:"8px",maxHeight:"100px",overflowY:"auto",fontFamily:"var(--font-mono), monospace",fontSize:"10px",color:"#e4e4e7",whiteSpace:"pre-wrap",wordBreak:"break-all"},children:e$.map((e,t)=>(0,n.jsx)("div",{style:{marginBottom:2},children:e},t))})]}),(0,n.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",gap:10,padding:"12px 20px",background:"var(--bg-panel)",borderTop:"1px solid var(--border)"},children:[(0,n.jsx)("button",{onClick:()=>{eJ(!1),eY("")},disabled:eA,style:{padding:"6px 14px",fontSize:12,borderRadius:6,border:"1px solid var(--border)",background:"var(--bg)",color:"var(--text-muted)",cursor:eA?"not-allowed":"pointer",fontWeight:500},children:"取消"}),(0,n.jsx)("button",{onClick:tj,disabled:eA,style:{padding:"6px 14px",fontSize:12,borderRadius:6,border:"none",background:eA?"rgba(239, 68, 68, 0.5)":"#ef4444",color:"white",cursor:eA?"not-allowed":"pointer",fontWeight:600,display:"flex",alignItems:"center",gap:6},children:eA?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{style:{width:"12px",height:"12px",border:"2px solid rgba(255, 255, 255, 0.3)",borderTopColor:"white",borderRadius:"50%",animation:"spin 1s linear infinite"}}),"正在回滚..."]}):"确认驳回并重构"})]})]})}),e3&&(0,n.jsx)("div",{style:{position:"fixed",inset:0,zIndex:1100,background:"rgba(15, 10, 10, 0.4)",backdropFilter:"blur(6px)",display:"flex",alignItems:"center",justifyContent:"center",animation:"fadeIn 0.2s ease-out"},children:(0,n.jsxs)("div",{style:{width:"min(500px, 92%)",background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:"12px",boxShadow:"0 20px 40px rgba(0, 0, 0, 0.3)",display:"flex",flexDirection:"column",overflow:"hidden",fontFamily:"var(--font-serif)"},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"16px 20px",background:"rgba(249, 115, 22, 0.08)",borderBottom:"1px solid rgba(249, 115, 22, 0.15)",color:"#ff903f",fontWeight:600,fontSize:14},children:[(0,n.jsx)("span",{style:{fontSize:16},children:"\uD83D\uDE80"}),(0,n.jsx)("span",{children:"极速起草模式配置"})]}),(0,n.jsxs)("div",{style:{padding:"20px",display:"flex",flexDirection:"column",gap:16},children:[(0,n.jsxs)("div",{style:{background:"rgba(249, 115, 22, 0.03)",border:"1px solid rgba(249, 115, 22, 0.1)",borderRadius:"8px",padding:"10px 12px",fontSize:11,color:"var(--text-muted)",lineHeight:"1.5"},children:[(0,n.jsx)("span",{style:{color:"#ff903f",fontWeight:600},children:"\uD83D\uDCA1 极速起草说明:"}),"此模式下,AI 将绕过复杂的设定同步、审计和 spot-fix 局部修正,直接根据大纲和以下创意引导快速生成首稿。这对于维持高涨的灵感和连贯的写作逻辑非常合适。"]}),(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[(0,n.jsx)("span",{style:{fontSize:12,color:"var(--text-muted)",fontWeight:500},children:"本章创意引导 (可选,指导本章具体剧情走向):"}),(0,n.jsx)("textarea",{value:tt,onChange:e=>tr(e.target.value),placeholder:"例如:主角在林中遭遇黑衣人伏击,一番激战后身负轻伤跳崖。在崖底醒来,发现一个神秘石洞...",style:{width:"100%",height:"110px",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:"6px",padding:"8px 12px",fontSize:12,color:"var(--text)",fontFamily:"var(--font-serif)",resize:"none",outline:"none"}})]}),r.length>0&&(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[(0,n.jsx)("span",{style:{fontSize:12,color:"var(--text-muted)",fontWeight:500},children:"\uD83C\uDFAD 选择写作文风偏好:"}),(0,n.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:r.map(e=>{let t=(tn||"default")===e;return(0,n.jsxs)("button",{type:"button",onClick:()=>to(e),style:{padding:"4px 10px",fontSize:"11px",borderRadius:"16px",border:`1px solid ${t?"#ff903f":"var(--border)"}`,background:t?"rgba(249, 115, 22, 0.08)":"var(--bg)",color:t?"#ff903f":"var(--text)",cursor:"pointer",fontWeight:t?600:500,transition:"all 0.15s",display:"flex",alignItems:"center",gap:3},children:[(0,n.jsx)("span",{children:"\uD83C\uDFAD"}),(0,n.jsx)("span",{children:e})]},e)})})]}),(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[(0,n.jsx)("span",{style:{fontSize:12,color:"var(--text-muted)",fontWeight:500},children:"期望本章字数:"}),(0,n.jsx)("div",{style:{display:"flex",gap:8},children:[1e3,2e3,3e3,5e3].map(e=>(0,n.jsxs)("button",{type:"button",onClick:()=>te(e),style:{flex:1,padding:"5px 0",fontSize:"11px",borderRadius:"4px",border:`1px solid ${e7===e?"#ff903f":"var(--border)"}`,background:e7===e?"rgba(249, 115, 22, 0.08)":"var(--bg)",color:e7===e?"#ff903f":"var(--text)",cursor:"pointer",fontWeight:e7===e?600:500,transition:"all 0.2s"},children:[e,"字"]},e))}),(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:12,marginTop:4},children:[(0,n.jsx)("input",{type:"range",min:"500",max:"10000",step:"100",value:e7,onChange:e=>te(parseInt(e.target.value,10)),style:{flex:1,accentColor:"#ff903f",cursor:"pointer"}}),(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:4},children:[(0,n.jsx)("input",{type:"number",min:"500",max:"20000",value:e7,onChange:e=>{let t=parseInt(e.target.value,10);isNaN(t)||te(t)},style:{width:"70px",textAlign:"center",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:"6px",padding:"4px 6px",fontSize:"11px",color:"var(--text)",fontFamily:"var(--font-serif)",outline:"none"}}),(0,n.jsx)("span",{style:{fontSize:"11px",color:"var(--text-muted)"},children:"字"})]})]})]})]}),(0,n.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",gap:10,padding:"12px 20px",background:"var(--bg-panel)",borderTop:"1px solid var(--border)"},children:[(0,n.jsx)("button",{onClick:()=>{e9(!1)},style:{padding:"6px 14px",fontSize:12,borderRadius:6,border:"1px solid var(--border)",background:"var(--bg)",color:"var(--text-muted)",cursor:"pointer",fontWeight:500},children:"取消"}),(0,n.jsx)("button",{onClick:()=>tb("draft",()=>tT(!1)),style:{padding:"6px 14px",fontSize:12,borderRadius:6,border:"none",background:"#ff903f",color:"white",cursor:"pointer",fontWeight:600,display:"flex",alignItems:"center",gap:6},children:"开始起草"})]})]})}),eW&&(0,n.jsx)("div",{style:{position:"fixed",inset:0,zIndex:1100,background:"rgba(15, 10, 10, 0.4)",backdropFilter:"blur(6px)",display:"flex",alignItems:"center",justifyContent:"center",animation:"fadeIn 0.2s ease-out"},children:(0,n.jsxs)("div",{style:{width:"min(600px, 92%)",background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:"12px",boxShadow:"0 20px 40px rgba(0, 0, 0, 0.3)",display:"flex",flexDirection:"column",overflow:"hidden",fontFamily:"var(--font-serif)"},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 20px",background:"rgba(59, 130, 246, 0.08)",borderBottom:"1px solid rgba(59, 130, 246, 0.15)",color:"var(--text)",fontWeight:600,fontSize:14},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[(0,n.jsx)("span",{style:{fontSize:16},children:"\uD83D\uDEE1️"}),(0,n.jsxs)("span",{children:["离线审计报告 - 第 ",th," 章"]})]}),(0,n.jsx)("button",{onClick:()=>eE(!1),style:{background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",fontSize:18,padding:4,display:"flex",alignItems:"center",justifyContent:"center",transition:"color 0.2s"},onMouseEnter:e=>e.currentTarget.style.color="var(--text)",onMouseLeave:e=>e.currentTarget.style.color="var(--text-muted)",children:"✕"})]}),(0,n.jsx)("div",{style:{padding:"20px",display:"flex",flexDirection:"column",gap:12,maxHeight:"60vh",overflowY:"auto"},children:0===eR.length?(0,n.jsx)("div",{style:{padding:"20px 0",textAlign:"center",color:"var(--text-dim)",fontSize:12},children:"没有检测到任何审计问题。"}):eR.map((e,t)=>{let r=e.match(/^\[(critical|warning|info)\]\s*(.*)$/i),o=r?r[1].toLowerCase():"info",i=r?r[2]:e,l={critical:{label:"严重错误",color:"#ef4444",bg:"rgba(239, 68, 68, 0.04)",border:"rgba(239, 68, 68, 0.15)",badgeBg:"rgba(239, 68, 68, 0.12)"},warning:{label:"潜在风险",color:"#eab308",bg:"rgba(234, 179, 8, 0.04)",border:"rgba(234, 179, 8, 0.15)",badgeBg:"rgba(234, 179, 8, 0.12)"},info:{label:"风格建议",color:"#3b82f6",bg:"rgba(59, 130, 246, 0.04)",border:"rgba(59, 130, 246, 0.15)",badgeBg:"rgba(59, 130, 246, 0.12)"}}[o];return(0,n.jsxs)("div",{style:{background:l.bg,border:`1px solid ${l.border}`,borderLeft:`4px solid ${l.color}`,borderRadius:"8px",padding:"12px 14px",display:"flex",flexDirection:"column",gap:6},children:[(0,n.jsx)("div",{style:{display:"flex",alignItems:"center",gap:8},children:(0,n.jsx)("span",{style:{fontSize:"10px",fontWeight:600,color:l.color,background:l.badgeBg,padding:"2px 6px",borderRadius:"4px",textTransform:"uppercase"},children:l.label})}),(0,n.jsx)("div",{style:{fontSize:12,color:"var(--text)",lineHeight:1.6,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:i}),(0,n.jsxs)("div",{style:{marginTop:4,paddingTop:6,borderTop:"1px dashed var(--border)",display:"flex",alignItems:"center",gap:6,fontSize:11,color:"var(--text-muted)"},children:[(0,n.jsx)("span",{style:{color:"var(--text-dim)"},children:"建议使用修复功能:"}),(0,n.jsx)("span",{style:{color:"critical"===o||"warning"===o?"#2dd4bf":"#3b82f6",fontWeight:500},children:"critical"===o||"warning"===o?"\uD83E\uDE84 局部定点修复":i.toLowerCase().includes("ai")||i.includes("检测到")||i.includes("句式")?"\uD83E\uDE84 防检测润色 / 文本润色":"\uD83E\uDE84 文本润色"})]})]},t)})}),(0,n.jsx)("div",{style:{display:"flex",justifyContent:"flex-end",padding:"12px 20px",background:"var(--bg-panel)",borderTop:"1px solid var(--border)"},children:(0,n.jsx)("button",{onClick:()=>eE(!1),style:{padding:"6px 20px",fontSize:12,borderRadius:6,border:"1px solid var(--border)",background:"var(--bg)",color:"var(--text-muted)",cursor:"pointer",fontWeight:500,transition:"all 0.2s"},onMouseEnter:e=>{e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color="var(--text)"},onMouseLeave:e=>{e.currentTarget.style.background="var(--bg)",e.currentTarget.style.color="var(--text-muted)"},children:"关闭"})})]})}),eK&&(0,n.jsx)("div",{style:{position:"fixed",inset:0,zIndex:1100,background:"rgba(15, 10, 10, 0.4)",backdropFilter:"blur(6px)",display:"flex",alignItems:"center",justifyContent:"center",animation:"fadeIn 0.2s ease-out"},children:(0,n.jsxs)("div",{style:{width:"min(480px, 90%)",background:"var(--bg-panel)",border:"1px solid rgba(239, 68, 68, 0.2)",borderRadius:"12px",boxShadow:"0 20px 40px rgba(0, 0, 0, 0.3)",display:"flex",flexDirection:"column",overflow:"hidden",fontFamily:"var(--font-serif)"},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"16px 20px",background:"rgba(239, 68, 68, 0.08)",borderBottom:"1px solid rgba(239, 68, 68, 0.15)",color:"#ef4444",fontWeight:600,fontSize:14},children:[(0,n.jsx)("span",{style:{fontSize:16},children:"⚠️"}),(0,n.jsx)("span",{children:eK.title})]}),(0,n.jsx)("div",{style:{padding:"20px",display:"flex",flexDirection:"column",gap:16},children:(0,n.jsxs)("div",{style:{background:"rgba(239, 68, 68, 0.04)",border:"1px solid rgba(239, 68, 68, 0.1)",borderRadius:"8px",padding:"12px 14px",fontSize:12,color:"var(--text)",lineHeight:"1.6",whiteSpace:"pre-wrap"},children:[(0,n.jsxs)("span",{style:{color:"#ef4444",fontWeight:600,display:"block",marginBottom:4},children:["⚠️ ",eK.warning||"操作警告:"]}),eK.message]})}),(0,n.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",gap:10,padding:"12px 20px",background:"var(--bg-panel)",borderTop:"1px solid var(--border)"},children:[(0,n.jsx)("button",{onClick:()=>eq(null),style:{padding:"6px 14px",fontSize:12,borderRadius:6,border:"1px solid var(--border)",background:"var(--bg)",color:"var(--text-muted)",cursor:"pointer",fontWeight:500},children:"取消"}),(0,n.jsx)("button",{onClick:()=>{let e=eK.onConfirm;eq(null),e()},style:{padding:"6px 16px",fontSize:12,borderRadius:6,border:"none",background:"#ef4444",color:"white",cursor:"pointer",fontWeight:600,transition:"background-color 0.2s"},onMouseEnter:e=>{e.currentTarget.style.background="#dc2626"},onMouseLeave:e=>{e.currentTarget.style.background="#ef4444"},children:"确认操作"})]})]})}),tp&&(d=ty(tp.actionType),(0,n.jsx)("div",{style:{position:"fixed",inset:0,zIndex:1200,background:"rgba(10, 10, 10, 0.4)",backdropFilter:"blur(8px)",display:"flex",alignItems:"center",justifyContent:"center",animation:"fadeIn 0.2s ease-out"},onClick:()=>tx(null),children:(0,n.jsxs)("div",{style:{width:"min(500px, 92%)",background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:"16px",boxShadow:"0 24px 60px rgba(0, 0, 0, 0.3)",display:"flex",flexDirection:"column",overflow:"hidden",fontFamily:"var(--font-serif)"},onClick:e=>e.stopPropagation(),children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"18px 24px",background:d.bgTheme,borderBottom:"1px solid var(--border)"},children:[(0,n.jsx)("div",{style:{width:32,height:32,borderRadius:"50%",background:"var(--bg)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:16,border:`1px solid ${d.themeColor}33`,boxShadow:`0 2px 8px ${d.themeColor}15`},children:d.icon}),(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column"},children:[(0,n.jsx)("span",{style:{fontSize:13,fontWeight:700,color:"var(--text)"},children:"确认执行此操作"}),(0,n.jsx)("span",{style:{fontSize:11,color:"var(--text-dim)",marginTop:2},children:d.title})]})]}),(0,n.jsxs)("div",{style:{padding:"24px",display:"flex",flexDirection:"column",gap:16},children:[(0,n.jsxs)("div",{style:{fontSize:13,color:"var(--text)",lineHeight:"1.6"},children:["您已点击运行 ",(0,n.jsxs)("strong",{style:{color:d.themeColor},children:["「",d.title,"」"]}),"。"]}),(0,n.jsxs)("div",{style:{background:"var(--bg)",border:"1px solid var(--border)",borderLeft:`4px solid ${d.themeColor}`,borderRadius:"8px",padding:"14px 18px",fontSize:12,color:"var(--text-muted)",lineHeight:"1.7"},children:[(0,n.jsx)("span",{style:{fontWeight:600,color:"var(--text)",display:"block",marginBottom:6},children:"功能说明:"}),d.desc]}),(0,n.jsx)("div",{style:{fontSize:11,color:"var(--text-dim)"},children:"\uD83D\uDCA1 提示:您可以在顶部的“系统全局设置” ⚙️ 中关闭此确认弹窗。"})]}),(0,n.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",gap:12,padding:"16px 24px",background:"var(--bg-panel)",borderTop:"1px solid var(--border)"},children:[(0,n.jsx)("button",{onClick:()=>tx(null),style:{padding:"7px 16px",fontSize:12,borderRadius:8,border:"1px solid var(--border)",background:"var(--bg)",color:"var(--text-muted)",cursor:"pointer",fontWeight:500,transition:"all 0.2s"},onMouseEnter:e=>{e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color="var(--text)"},onMouseLeave:e=>{e.currentTarget.style.background="var(--bg)",e.currentTarget.style.color="var(--text-muted)"},children:"取消"}),(0,n.jsx)("button",{onClick:()=>{let e=tp.onConfirm;tx(null),e()},style:{padding:"7px 20px",fontSize:12,borderRadius:8,border:"none",background:d.themeColor,color:"white",cursor:"pointer",fontWeight:600,boxShadow:`0 4px 12px ${d.themeColor}33`,transition:"all 0.2s"},onMouseEnter:e=>{e.currentTarget.style.opacity="0.9",e.currentTarget.style.transform="translateY(-1px)",e.currentTarget.style.boxShadow=`0 6px 16px ${d.themeColor}44`},onMouseLeave:e=>{e.currentTarget.style.opacity="1",e.currentTarget.style.transform="none",e.currentTarget.style.boxShadow=`0 4px 12px ${d.themeColor}33`},children:"确定执行"})]})]})}))]})}function e6({tabs:e,activeTabId:t,onSelectTab:r,onCloseTab:i}){let[l,s]=(0,o.useState)(null);return(0,n.jsx)("div",{style:{display:"flex",alignItems:"flex-end",background:"var(--bg-panel)",overflowX:"auto",flexShrink:0,height:36},children:e.map(e=>{let o=e.id===t;return(0,n.jsxs)("div",{onClick:()=>r(e.id),style:{display:"flex",alignItems:"center",gap:6,height:36,paddingLeft:12,paddingRight:6,borderRight:"1px solid var(--border)",background:o?"var(--bg)":"var(--bg-panel)",cursor:"pointer",fontSize:12,color:o?"var(--text)":"var(--text-muted)",whiteSpace:"nowrap",maxWidth:180,minWidth:80,flexShrink:0,userSelect:"none",transition:"background 0.1s, color 0.1s"},children:[(0,n.jsx)("span",{style:{flexShrink:0,opacity:o?1:.7,display:"flex",alignItems:"center"},children:M(e.label,13)}),(0,n.jsx)("span",{style:{overflow:"hidden",textOverflow:"ellipsis",flex:1,fontWeight:o?500:400},title:e.filePath,children:e.label}),(0,n.jsx)("button",{onClick:t=>{t.stopPropagation(),i(e.id)},onMouseEnter:()=>s(e.id),onMouseLeave:()=>s(null),style:{display:"flex",alignItems:"center",justifyContent:"center",width:16,height:16,background:l===e.id?"var(--bg-hover)":"transparent",border:"none",borderRadius:3,color:l===e.id?"var(--text)":"var(--text-dim)",cursor:"pointer",padding:0,flexShrink:0,transition:"background 0.1s, color 0.1s"},title:"Close",children:(0,n.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:[(0,n.jsx)("line",{x1:"2",y1:"2",x2:"8",y2:"8"}),(0,n.jsx)("line",{x1:"8",y1:"2",x2:"2",y2:"8"})]})})]},e.id)})})}var e5=r(7381),e8=r(4433),e3=r(350),e9=r(8195),e7=r(9312),te=r(7275),tt=r(2008),tr=r(5476),tn=r(7410),to=r(4489),ti=r(8728),tl=r(9872),ts=r(7751),ta=r(2526),td=r(8238),tc=r(7794),tp=r(1098),tx=r(4604),tu=r(5315),tg=r(4278),th=r(5457),tf=r(1437),ty=r(9167),tb=r(7283),tv=r(4166);let tm={anthropic:{Icon:e5.A,hasColor:!1},openai:{Icon:e8.A,hasColor:!1},"openai-codex":{Icon:e8.A,hasColor:!1},google:{Icon:e3.A,hasColor:!0},"google-vertex":{Icon:e3.A,hasColor:!0},deepseek:{Icon:e9.A,hasColor:!0},groq:{Icon:e7.A,hasColor:!1},mistral:{Icon:te.A,hasColor:!0},moonshotai:{Icon:tt.A,hasColor:!1},"moonshotai-cn":{Icon:tt.A,hasColor:!1},moonshot:{Icon:tt.A,hasColor:!1},minimax:{Icon:tr.A,hasColor:!0},"minimax-cn":{Icon:tr.A,hasColor:!0},fireworks:{Icon:tn.A,hasColor:!0},huggingface:{Icon:to.A,hasColor:!0},cerebras:{Icon:ti.A,hasColor:!0},openrouter:{Icon:tl.A,hasColor:!1},xai:{Icon:ts.A,hasColor:!1},"cloudflare-ai-gateway":{Icon:ta.A,hasColor:!0},"cloudflare-workers-ai":{Icon:ta.A,hasColor:!0},"vercel-ai-gateway":{Icon:td.A,hasColor:!1},"github-copilot":{Icon:tc.A,hasColor:!1},"amazon-bedrock":{Icon:tp.A,hasColor:!0},"azure-openai-responses":{Icon:tx.A,hasColor:!0},"kimi-coding":{Icon:tu.A,hasColor:!0},qwen:{Icon:tg.A,hasColor:!0},zai:{Icon:th.A,hasColor:!0},cohere:{Icon:tf.A,hasColor:!0},perplexity:{Icon:ty.A,hasColor:!0},together:{Icon:tb.A,hasColor:!0},grok:{Icon:tv.A,hasColor:!1}},tj=["openai-completions","openai-responses","anthropic-messages","google-generative-ai"];function tk({label:e,children:t}){return(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[(0,n.jsx)("label",{style:{fontSize:11,color:"var(--text-muted)",fontWeight:500},children:e}),t]})}let tw={padding:"6px 9px",background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:5,color:"var(--text)",fontSize:12,outline:"none",width:"100%",boxSizing:"border-box"};function tS({value:e,onChange:t,placeholder:r,mono:o}){return(0,n.jsx)("input",{value:e,onChange:e=>t(e.target.value),placeholder:r,style:{...tw,fontFamily:o?"var(--font-mono)":"inherit"}})}function tC({value:e,onChange:t,placeholder:r,mono:i,onKeyDown:l,autoComplete:s="off",spellCheck:a=!1,style:d}){let[c,p]=(0,o.useState)(!1);return(0,o.useEffect)(()=>{e||p(!1)},[e]),(0,n.jsxs)("div",{style:{position:"relative",width:"100%",...d},children:[(0,n.jsx)("input",{type:c?"text":"password",value:e,onChange:e=>t(e.target.value),onKeyDown:l,placeholder:r,style:{...tw,paddingRight:34,fontFamily:i?"var(--font-mono)":"inherit"},autoComplete:s,spellCheck:a}),(0,n.jsx)("button",{type:"button",onClick:()=>p(e=>!e),"aria-label":c?"Hide API key":"Show API key",title:c?"Hide API key":"Show API key",style:{position:"absolute",right:5,top:"50%",transform:"translateY(-50%)",width:24,height:24,padding:0,border:"none",background:"transparent",color:"var(--text-dim)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},children:c?(0,n.jsxs)("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M17.94 17.94A10.94 10.94 0 0 1 12 20C7 20 2.73 16.89 1 12a18.45 18.45 0 0 1 5.06-6.94"}),(0,n.jsx)("path",{d:"M9.9 4.24A10.94 10.94 0 0 1 12 4c5 0 9.27 3.11 11 8a18.5 18.5 0 0 1-2.16 3.19"}),(0,n.jsx)("path",{d:"M14.12 14.12A3 3 0 0 1 9.88 9.88"}),(0,n.jsx)("path",{d:"M1 1l22 22"})]}):(0,n.jsxs)("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8S1 12 1 12Z"}),(0,n.jsx)("circle",{cx:"12",cy:"12",r:"3"})]})})]})}function tT({value:e,onChange:t,placeholder:r}){return(0,n.jsx)("input",{type:"number",value:e,onChange:e=>t(e.target.value),placeholder:r,style:tw})}function tI({value:e,onChange:t,options:r,required:o}){return(0,n.jsxs)("select",{value:e,onChange:e=>t(e.target.value),style:{...tw,color:e?"var(--text)":"var(--text-dim)"},children:[!o&&(0,n.jsx)("option",{value:"",children:"— inherit / none —"}),r.map(e=>(0,n.jsx)("option",{value:e,children:e},e))]})}function tz({label:e,checked:t,onChange:r}){return(0,n.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:6,cursor:"pointer",fontSize:12,color:"var(--text-muted)"},children:[(0,n.jsx)("input",{type:"checkbox",checked:t,onChange:e=>r(e.target.checked),style:{width:13,height:13,accentColor:"var(--accent)",cursor:"pointer"}}),e]})}function tR({children:e}){return(0,n.jsx)("div",{style:{fontSize:11,fontWeight:600,color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:"0.06em",marginBottom:2},children:e})}function tL({name:e,provider:t,onChange:r,onRename:i,onDelete:l}){let[s,a]=(0,o.useState)(e);(0,o.useEffect)(()=>a(e),[e]);let d=(e,n)=>r({...t,[e]:n});return(0,o.useEffect)(()=>{t.api||r({...t,api:"openai-completions"})},[t.api]),(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[(0,n.jsx)(tR,{children:"Provider"}),(0,n.jsx)("button",{onClick:l,style:{padding:"3px 8px",background:"none",border:"1px solid rgba(239,68,68,0.3)",borderRadius:4,color:"#ef4444",cursor:"pointer",fontSize:11},children:"Delete"})]}),(0,n.jsxs)(tk,{label:"Provider name",children:[(0,n.jsx)(tS,{value:s,onChange:a,placeholder:"provider-name",mono:!0}),s!==e&&s.trim()&&(0,n.jsx)("button",{onClick:()=>i(s.trim()),style:{marginTop:4,padding:"3px 10px",background:"var(--accent)",border:"none",borderRadius:4,color:"#fff",cursor:"pointer",fontSize:11,alignSelf:"flex-start"},children:"Rename"})]}),(0,n.jsx)(tk,{label:"Base URL",children:(0,n.jsx)(tS,{value:t.baseUrl??"",onChange:e=>d("baseUrl",e||void 0),placeholder:"https://api.example.com/v1",mono:!0})}),(0,n.jsxs)(tk,{label:"API Key",children:[(0,n.jsx)(tC,{value:t.apiKey??"",onChange:e=>d("apiKey",e||void 0),placeholder:"ENV_VAR_NAME, !shell-command, or literal key",mono:!0}),(0,n.jsxs)("span",{style:{fontSize:10,color:"var(--text-dim)",marginTop:2},children:["Prefix with ",(0,n.jsx)("code",{style:{fontFamily:"var(--font-mono)"},children:"!"})," to run a shell command, or use an env var name"]})]}),(0,n.jsx)(tk,{label:"API",children:(0,n.jsx)(tI,{value:t.api??"openai-completions",onChange:e=>d("api",e),options:tj,required:!0})})]})}let tW=["off","minimal","low","medium","high","xhigh"],tE={off:"var(--text-dim)",minimal:"#6b7280",low:"#60a5fa",medium:"#a78bfa",high:"#f472b6",xhigh:"#fb923c"};function tM({value:e,onChange:t}){let r=e??{},o=(e,n)=>{let o={...r};"omit"===n?delete o[e]:o[e]=n,t(Object.keys(o).length?o:void 0)};return(0,n.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:2},children:tW.map(e=>{let t=r[e],i=e in r?null===t?"null":"string":"omit",l="string"==typeof t?t:"",s=tE[e],a={padding:"4px 10px",fontSize:10,border:"none",cursor:"pointer",fontWeight:400,transition:"background 0.1s, color 0.1s",whiteSpace:"nowrap",background:"var(--bg-panel)",color:"var(--text-dim)"},d={background:"var(--accent)",color:"#fff",fontWeight:600};return(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"5px 4px",borderRadius:6,background:"transparent",border:"1px solid transparent"},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:5,width:68,flexShrink:0},children:[(0,n.jsx)("span",{style:{width:6,height:6,borderRadius:"50%",background:s,flexShrink:0,opacity:"null"===i?.3:1}}),(0,n.jsx)("span",{style:{fontSize:11,fontFamily:"var(--font-mono)",color:"null"===i?"var(--text-dim)":"var(--text-muted)",textDecoration:"null"===i?"line-through":"none"},children:e})]}),(0,n.jsxs)("div",{style:{display:"flex",borderRadius:5,border:"1px solid var(--border)",overflow:"hidden",flexShrink:0},children:[(0,n.jsx)("button",{onClick:()=>o(e,"omit"),style:{...a,..."omit"===i?d:{}},children:"Default"}),(0,n.jsx)("button",{onClick:()=>o(e,null),style:{...a,borderLeft:"1px solid var(--border)",..."null"===i?{background:"#ef4444",color:"#fff",fontWeight:600}:{}},children:"Disabled"})]}),(0,n.jsxs)("div",{style:{display:"flex",borderRadius:5,border:`1px solid ${"string"===i?"var(--accent)":"var(--border)"}`,overflow:"hidden",transition:"border-color 0.1s"},children:[(0,n.jsx)("button",{onClick:()=>o(e,l||e),style:{...a,..."string"===i?d:{},borderRight:"1px solid var(--border)",flexShrink:0},children:"Custom"}),(0,n.jsx)("input",{value:l,onChange:t=>o(e,t.target.value),onFocus:()=>{"string"!==i&&o(e,l||e)},placeholder:e,maxLength:10,style:{width:"12ch",background:"string"===i?"var(--bg)":"var(--bg-panel)",border:"none",outline:"none",color:"string"===i?"var(--text)":"var(--text-dim)",fontFamily:"var(--font-mono)",fontSize:11,padding:"4px 7px",transition:"background 0.1s, color 0.1s"}})]})]},e)})})}let tD={thinkingFormat:"deepseek",requiresReasoningContentOnAssistantMessages:!0};function t$({model:e,isDefault:t,onSetDefault:r,onChange:o,onDelete:i}){let l=(t,r)=>o({...e,[t]:r});return(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10},children:[(0,n.jsx)(tR,{children:"Model"}),e.id&&(t?(0,n.jsx)("span",{style:{fontSize:10,color:"var(--accent)",fontWeight:600,background:"rgba(249,115,22,0.1)",padding:"2px 6px",borderRadius:4},children:"✨ 全局默认 / Global Default"}):(0,n.jsx)("button",{onClick:r,style:{fontSize:10,padding:"2px 7px",background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:4,color:"var(--text-muted)",cursor:"pointer",fontWeight:500,transition:"border-color 0.12s, color 0.12s"},onMouseEnter:e=>{e.currentTarget.style.borderColor="var(--accent)",e.currentTarget.style.color="var(--accent)"},onMouseLeave:e=>{e.currentTarget.style.borderColor="var(--border)",e.currentTarget.style.color="var(--text-muted)"},children:"设为全局默认 / Set as Global Default"}))]}),(0,n.jsx)("button",{onClick:i,style:{padding:"3px 8px",background:"none",border:"1px solid rgba(239,68,68,0.3)",borderRadius:4,color:"#ef4444",cursor:"pointer",fontSize:11},children:"Remove"})]}),(0,n.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:10},children:[(0,n.jsx)(tk,{label:"ID *",children:(0,n.jsx)(tS,{value:e.id,onChange:e=>l("id",e),placeholder:"model-id",mono:!0})}),(0,n.jsx)(tk,{label:"Name",children:(0,n.jsx)(tS,{value:e.name??"",onChange:e=>l("name",e||void 0),placeholder:"Display name"})})]}),(0,n.jsx)(tk,{label:"API override",children:(0,n.jsx)(tI,{value:e.api??"",onChange:e=>l("api",e||void 0),options:tj})}),(0,n.jsxs)("div",{style:{display:"flex",gap:20,flexWrap:"wrap"},children:[(0,n.jsx)(tz,{label:"Reasoning / thinking",checked:e.reasoning??!1,onChange:e=>l("reasoning",e||void 0)}),(0,n.jsx)(tz,{label:"Image input",checked:e.input?.includes("image")??!1,onChange:e=>l("input",e?["text","image"]:void 0)})]}),e.reasoning&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(tz,{label:"DeepSeek thinking compat",checked:e.compat?.thinkingFormat==="deepseek",onChange:t=>o(function(e,t){if(t)return{...e,compat:{...e.compat??{},...tD}};if(!e.compat)return e;let r={...e.compat};return delete r.thinkingFormat,delete r.requiresReasoningContentOnAssistantMessages,{...e,compat:Object.keys(r).length?r:void 0}}(e,t))}),(0,n.jsxs)("div",{children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:8},children:[(0,n.jsx)(tR,{children:"Thinking level map"}),e.thinkingLevelMap&&(0,n.jsx)("button",{onClick:()=>l("thinkingLevelMap",void 0),style:{fontSize:10,padding:"2px 7px",background:"none",border:"1px solid var(--border)",borderRadius:4,color:"var(--text-dim)",cursor:"pointer"},children:"clear all"})]}),(0,n.jsx)(tM,{value:e.thinkingLevelMap,onChange:e=>l("thinkingLevelMap",e)})]})]}),(0,n.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:10},children:[(0,n.jsx)(tk,{label:"Context window (tokens)",children:(0,n.jsx)(tT,{value:void 0!==e.contextWindow?String(e.contextWindow):"",onChange:e=>l("contextWindow",e?parseInt(e):void 0),placeholder:"128000"})}),(0,n.jsx)(tk,{label:"Max output tokens",children:(0,n.jsx)(tT,{value:void 0!==e.maxTokens?String(e.maxTokens):"",onChange:e=>l("maxTokens",e?parseInt(e):void 0),placeholder:"16384"})})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)(tR,{children:"Cost (per million tokens)"}),(0,n.jsx)("div",{style:{marginTop:8,display:"grid",gridTemplateColumns:"1fr 1fr 1fr 1fr",gap:8},children:["input","output","cacheRead","cacheWrite"].map(t=>(0,n.jsx)(tk,{label:t,children:(0,n.jsx)(tT,{value:e.cost?.[t]!==void 0?String(e.cost[t]):"",onChange:r=>{let n;return n=parseFloat(r),void o({...e,cost:{...e.cost??{},[t]:isNaN(n)?void 0:n}})},placeholder:"0"})},t))})]})]})}function tB({provider:e,onRefresh:t,models:r=[],defaultModel:i,onSetDefault:l}){let[s,a]=(0,o.useState)({phase:"idle"}),[d,c]=(0,o.useState)(""),p=(0,o.useRef)(null),x=(0,o.useRef)(null);(0,o.useEffect)(()=>{("auth"===s.phase||"prompt"===s.phase)&&setTimeout(()=>x.current?.focus(),50)},[s.phase]),(0,o.useEffect)(()=>{a({phase:"idle"}),c(""),p.current?.close(),p.current=null},[e.id]),(0,o.useEffect)(()=>()=>{p.current?.close()},[]);let u=(0,o.useCallback)(()=>{p.current?.close(),a({phase:"connecting"}),c("");let r=new EventSource(`/api/auth/login/${encodeURIComponent(e.id)}`);p.current=r,r.onmessage=e=>{let n=JSON.parse(e.data);"auth"===n.type?(a({phase:"auth",url:n.url,instructions:n.instructions??null,token:n.token}),window.open(n.url,"_blank","noopener,noreferrer")):"device_code"===n.type?(a({phase:"device_code",userCode:n.userCode,verificationUri:n.verificationUri,intervalSeconds:n.intervalSeconds??null,expiresInSeconds:n.expiresInSeconds??null}),window.open(n.verificationUri,"_blank","noopener,noreferrer")):"prompt_request"===n.type?a({phase:"prompt",message:n.message,placeholder:n.placeholder??null,token:n.token}):"select_request"===n.type?a({phase:"select",message:n.message,options:n.options??[],token:n.token}):"progress"===n.type?a({phase:"progress",message:n.message}):"success"===n.type?(r.close(),a({phase:"success"}),t()):"error"===n.type?(r.close(),a({phase:"error",message:n.message})):"cancelled"===n.type&&(r.close(),a({phase:"idle"}))},r.onerror=()=>{r.close(),a(e=>"success"===e.phase?e:{phase:"error",message:"Connection lost"})}},[e.id,t]),g=(0,o.useCallback)(async()=>{await fetch(`/api/auth/logout/${encodeURIComponent(e.id)}`,{method:"POST"}),a({phase:"idle"}),t()},[e.id,t]),h=(0,o.useCallback)(async(t,r)=>{if(r.trim()){a({phase:"progress",message:"Verifying…"});try{let n=await fetch(`/api/auth/login/${encodeURIComponent(e.id)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:t,code:r.trim()})});if(!n.ok){let e=await n.json().catch(()=>({}));a({phase:"error",message:e.error??`Server error ${n.status}`});return}c("")}catch(e){a({phase:"error",message:e instanceof Error?e.message:"Network error"})}}},[e.id]),f=(0,o.useCallback)(async(t,r)=>{a({phase:"progress",message:"Continuing…"});try{let n=await fetch(`/api/auth/login/${encodeURIComponent(e.id)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:t,code:r})});if(!n.ok){let e=await n.json().catch(()=>({}));a({phase:"error",message:e.error??`Server error ${n.status}`})}}catch(e){a({phase:"error",message:e instanceof Error?e.message:"Network error"})}},[e.id]),y="connecting"===s.phase||"progress"===s.phase||"auth"===s.phase||"device_code"===s.phase||"prompt"===s.phase||"select"===s.phase;return(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[(0,n.jsx)(tR,{children:"Subscription"}),(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[(0,n.jsx)("span",{style:{width:7,height:7,borderRadius:"50%",background:e.loggedIn?"#4ade80":"var(--border)",display:"inline-block"}}),(0,n.jsx)("span",{style:{fontSize:11,color:e.loggedIn?"#4ade80":"var(--text-dim)"},children:e.loggedIn?"connected":"not connected"})]})]}),(0,n.jsxs)("div",{style:{minHeight:48},children:["idle"===s.phase&&(0,n.jsx)("p",{style:{margin:0,fontSize:12,color:"var(--text-muted)",lineHeight:1.5},children:e.loggedIn?"Already connected. You can re-login or disconnect.":`Connect your ${e.name} account.`}),"connecting"===s.phase&&(0,n.jsx)("p",{style:{margin:0,fontSize:12,color:"var(--text-muted)"},children:"Opening browser…"}),"select"===s.phase&&(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[(0,n.jsx)("p",{style:{margin:0,fontSize:12,color:"var(--text-muted)",lineHeight:1.5},children:s.message}),(0,n.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:s.options.map(e=>(0,n.jsx)("button",{onClick:()=>f(s.token,e.id),style:{padding:"6px 9px",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:5,color:"var(--text)",cursor:"pointer",fontSize:12,textAlign:"left"},children:e.label},e.id))})]}),("auth"===s.phase||"prompt"===s.phase)&&(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[(0,n.jsx)("p",{style:{margin:0,fontSize:12,color:"var(--text-muted)",lineHeight:1.5},children:"auth"===s.phase?"Complete sign-in in the browser, then copy the redirect URL from the address bar and paste it below.":s.message}),"auth"===s.phase&&(0,n.jsxs)("p",{style:{margin:0,fontSize:11,color:"var(--text-dim)",lineHeight:1.5},children:["If the browser window did not open,"," ",(0,n.jsx)("a",{href:s.url,target:"_blank",rel:"noopener noreferrer",style:{color:"var(--accent)",wordBreak:"break-all"},children:"click here to open the login page"}),"."]}),(0,n.jsxs)("div",{style:{display:"flex",gap:6},children:[(0,n.jsx)("input",{ref:x,value:d,onChange:e=>c(e.target.value),onKeyDown:e=>{"Enter"===e.key&&h(s.token,d)},placeholder:"auth"===s.phase?"http://localhost:1455/auth/callback?code=…":s.placeholder??"Enter value…",style:{flex:1,padding:"6px 9px",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:5,color:"var(--text)",fontSize:12,outline:"none",fontFamily:"var(--font-mono)",boxSizing:"border-box"}}),(0,n.jsx)("button",{onClick:()=>h(s.token,d),disabled:!d.trim(),style:{padding:"6px 12px",background:d.trim()?"var(--accent)":"var(--bg-panel)",border:"none",borderRadius:5,color:d.trim()?"#fff":"var(--text-dim)",cursor:d.trim()?"pointer":"not-allowed",fontSize:12,fontWeight:600,flexShrink:0},children:"Submit"})]})]}),"device_code"===s.phase&&(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[(0,n.jsx)("p",{style:{margin:0,fontSize:12,color:"var(--text-muted)",lineHeight:1.5},children:"Open the verification page and enter this code:"}),(0,n.jsx)("div",{style:{padding:"8px 10px",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:5,color:"var(--text)",fontSize:16,fontWeight:700,fontFamily:"var(--font-mono)",letterSpacing:0},children:s.userCode}),(0,n.jsxs)("p",{style:{margin:0,fontSize:11,color:"var(--text-dim)",lineHeight:1.5},children:[(0,n.jsx)("a",{href:s.verificationUri,target:"_blank",rel:"noopener noreferrer",style:{color:"var(--accent)",wordBreak:"break-all"},children:s.verificationUri}),s.expiresInSeconds?` Expires in ${Math.ceil(s.expiresInSeconds/60)} minutes.`:""]})]}),"progress"===s.phase&&(0,n.jsx)("p",{style:{margin:0,fontSize:12,color:"var(--text-muted)"},children:s.message}),"success"===s.phase&&(0,n.jsx)("p",{style:{margin:0,fontSize:12,color:"#4ade80"},children:"Connected successfully."}),"error"===s.phase&&(0,n.jsx)("p",{style:{margin:0,fontSize:12,color:"#f87171"},children:s.message})]}),(0,n.jsx)("div",{style:{display:"flex",gap:8},children:y?(0,n.jsx)("button",{onClick:()=>{p.current?.close(),a({phase:"idle"})},style:{padding:"5px 12px",background:"none",border:"1px solid var(--border)",borderRadius:5,color:"var(--text-muted)",cursor:"pointer",fontSize:12},children:"Cancel"}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("button",{onClick:u,style:{padding:"5px 14px",background:"var(--accent)",border:"none",borderRadius:5,color:"#fff",cursor:"pointer",fontSize:12,fontWeight:600},children:e.loggedIn?"Re-login":"Login"}),e.loggedIn&&(0,n.jsx)("button",{onClick:g,style:{padding:"5px 12px",background:"none",border:"1px solid rgba(239,68,68,0.3)",borderRadius:5,color:"#ef4444",cursor:"pointer",fontSize:12},children:"Disconnect"})]})}),r.length>0&&(0,n.jsxs)("div",{style:{marginTop:24,borderTop:"1px solid var(--border)",paddingTop:16},children:[(0,n.jsxs)(tR,{children:["包含模型 / Models (",r.length,")"]}),(0,n.jsx)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(180px, 1fr))",gap:8,marginTop:10},children:r.map(t=>{let r=i?.provider===e.id&&i?.modelId===t.id;return(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:3,padding:"8px 10px",background:"var(--bg-panel)",border:r?"1.5px solid var(--accent)":"1px solid var(--border)",borderRadius:6,position:"relative"},children:[(0,n.jsx)("span",{style:{fontSize:11,fontWeight:600,color:"var(--text)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",paddingRight:r?40:58},children:t.name||t.id}),(0,n.jsx)("code",{style:{fontSize:9,color:"var(--text-dim)",fontFamily:"var(--font-mono)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",paddingRight:r?40:58},children:t.id}),r?(0,n.jsx)("span",{style:{position:"absolute",right:8,top:"50%",transform:"translateY(-50%)",fontSize:9,color:"var(--accent)",fontWeight:600,background:"rgba(249,115,22,0.1)",padding:"2px 5px",borderRadius:4},children:"✨ 全局默认"}):l&&(0,n.jsx)("button",{onClick:()=>l(e.id,t.id),style:{position:"absolute",right:8,top:"50%",transform:"translateY(-50%)",fontSize:9,padding:"2px 5px",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:4,color:"var(--text-muted)",cursor:"pointer",fontWeight:500},onMouseEnter:e=>{e.currentTarget.style.borderColor="var(--accent)",e.currentTarget.style.color="var(--accent)"},onMouseLeave:e=>{e.currentTarget.style.borderColor="var(--border)",e.currentTarget.style.color="var(--text-muted)"},children:"设为全局默认"})]},t.id)})})]})]})}function tA({provider:e,onRefresh:t,models:r=[],defaultModel:i,onSetDefault:l}){let[s,a]=(0,o.useState)(""),[d,c]=(0,o.useState)(!1),[p,x]=(0,o.useState)(!1),[u,g]=(0,o.useState)(null),[h,f]=(0,o.useState)(!1);(0,o.useEffect)(()=>{a(""),g(null),f(!1)},[e.id]);let y=(0,o.useCallback)(async()=>{if(s.trim()){c(!0),g(null),f(!1);try{let r=await fetch(`/api/auth/api-key/${encodeURIComponent(e.id)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:s.trim()})}),n=await r.json();!r.ok||n.error?g(n.error??`HTTP ${r.status}`):(a(""),f(!0),setTimeout(()=>f(!1),2e3),t())}catch(e){g(String(e))}finally{c(!1)}}},[s,e.id,t]),b=(0,o.useCallback)(async()=>{x(!0),g(null);try{let r=await fetch(`/api/auth/api-key/${encodeURIComponent(e.id)}`,{method:"DELETE"}),n=await r.json();!r.ok||n.error?g(n.error??`HTTP ${r.status}`):t()}catch(e){g(String(e))}finally{x(!1)}},[e.id,t]);return(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[(0,n.jsx)(tR,{children:"API Key"}),(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[(0,n.jsx)("span",{style:{width:7,height:7,borderRadius:"50%",background:e.configured?"#4ade80":"var(--border)",display:"inline-block"}}),(0,n.jsx)("span",{style:{fontSize:11,color:e.configured?"#4ade80":"var(--text-dim)"},children:e.configured?"configured":"not configured"})]})]}),(0,n.jsx)("p",{style:{margin:0,fontSize:12,color:"var(--text-muted)",lineHeight:1.5},children:e.configured?"API key is stored. Enter a new key below to replace it, or disconnect to remove it.":`Enter your ${e.displayName} API key to enable ${e.modelCount} model${1!==e.modelCount?"s":""}.`}),(0,n.jsx)(tk,{label:"API Key",children:(0,n.jsxs)("div",{style:{display:"flex",gap:6},children:[(0,n.jsx)(tC,{value:s,onChange:a,onKeyDown:e=>{"Enter"===e.key&&s.trim()&&y()},placeholder:e.configured?"Enter new key to replace…":"sk-…",style:{flex:1},autoComplete:"off",spellCheck:!1,mono:!0}),(0,n.jsxs)("button",{onClick:y,disabled:d||!s.trim()||h,style:{padding:"6px 12px",background:h?"#16a34a":s.trim()?"var(--accent)":"var(--bg-panel)",border:"none",borderRadius:5,color:s.trim()||h?"#fff":"var(--text-dim)",cursor:d||!s.trim()||h?"not-allowed":"pointer",fontSize:12,fontWeight:600,flexShrink:0,display:"flex",alignItems:"center",gap:5},children:[h&&(0,n.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("polyline",{points:"20 6 9 17 4 12"})}),h?"Saved":d?"Saving…":"Save"]})]})}),u&&(0,n.jsx)("p",{style:{margin:0,fontSize:12,color:"#f87171"},children:u}),e.configured&&(0,n.jsx)("button",{onClick:b,disabled:p,style:{alignSelf:"flex-start",padding:"5px 12px",background:"none",border:"1px solid rgba(239,68,68,0.3)",borderRadius:5,color:"#ef4444",cursor:p?"not-allowed":"pointer",fontSize:12},children:p?"Removing…":"Disconnect"}),r.length>0&&(0,n.jsxs)("div",{style:{marginTop:24,borderTop:"1px solid var(--border)",paddingTop:16},children:[(0,n.jsxs)(tR,{children:["包含模型 / Models (",r.length,")"]}),(0,n.jsx)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(180px, 1fr))",gap:8,marginTop:10},children:r.map(t=>{let r=i?.provider===e.id&&i?.modelId===t.id;return(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:3,padding:"8px 10px",background:"var(--bg-panel)",border:r?"1.5px solid var(--accent)":"1px solid var(--border)",borderRadius:6,position:"relative"},children:[(0,n.jsx)("span",{style:{fontSize:11,fontWeight:600,color:"var(--text)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",paddingRight:r?40:58},children:t.name||t.id}),(0,n.jsx)("code",{style:{fontSize:9,color:"var(--text-dim)",fontFamily:"var(--font-mono)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",paddingRight:r?40:58},children:t.id}),r?(0,n.jsx)("span",{style:{position:"absolute",right:8,top:"50%",transform:"translateY(-50%)",fontSize:9,color:"var(--accent)",fontWeight:600,background:"rgba(249,115,22,0.1)",padding:"2px 5px",borderRadius:4},children:"✨ 全局默认"}):l&&(0,n.jsx)("button",{onClick:()=>l(e.id,t.id),style:{position:"absolute",right:8,top:"50%",transform:"translateY(-50%)",fontSize:9,padding:"2px 5px",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:4,color:"var(--text-muted)",cursor:"pointer",fontWeight:500},onMouseEnter:e=>{e.currentTarget.style.borderColor="var(--accent)",e.currentTarget.style.color="var(--accent)"},onMouseLeave:e=>{e.currentTarget.style.borderColor="var(--border)",e.currentTarget.style.color="var(--text-muted)"},children:"设为全局默认"})]},t.id)})})]})]})}function tF({id:e,size:t}){let r=tm[e];return r?r.hasColor?(0,n.jsx)(r.Icon,{size:t}):(0,n.jsx)(r.Icon,{size:t,style:{color:"var(--text-muted)"}}):null}function tO({oauthProviders:e,apiKeyProviders:t,onSelectOAuth:r,onSelectApiKey:i,onAddCustom:l,onClose:s}){let[a,d]=(0,o.useState)(""),c=(0,o.useRef)(null);(0,o.useEffect)(()=>{setTimeout(()=>c.current?.focus(),30)},[]);let p=a.trim().toLowerCase(),x=e.filter(e=>!e.loggedIn&&(!p||e.name.toLowerCase().includes(p))),u=t.filter(e=>!e.configured&&(!p||e.displayName.toLowerCase().includes(p)||e.id.toLowerCase().includes(p))),g=!p||"custom".includes(p)||"openai-compatible".includes(p)||"anthropic-compatible".includes(p),h=x.length+u.length+ +!!g,f={display:"flex",flexDirection:"row",alignItems:"center",gap:8,padding:"10px 12px",background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:7,boxSizing:"border-box",cursor:"pointer",minWidth:0,textAlign:"left",transition:"border-color 0.12s, background 0.12s",width:"100%"};return(0,n.jsx)("div",{style:{position:"fixed",inset:0,zIndex:1100,background:"rgba(0,0,0,0.4)",display:"flex",alignItems:"center",justifyContent:"center"},onClick:e=>{e.target===e.currentTarget&&s()},children:(0,n.jsxs)("div",{style:{width:820,maxWidth:"calc(100vw - 32px)",maxHeight:"min(72vh, calc(100vh - 32px))",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:10,display:"flex",flexDirection:"column",boxShadow:"0 8px 32px rgba(0,0,0,0.22)",overflow:"hidden"},children:[(0,n.jsxs)("div",{style:{padding:"10px 14px",borderBottom:"1px solid var(--border)",flexShrink:0,display:"flex",alignItems:"center",gap:8},children:[(0,n.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{color:"var(--text-dim)",flexShrink:0},children:[(0,n.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,n.jsx)("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),(0,n.jsx)("input",{ref:c,value:a,onChange:e=>d(e.target.value),onKeyDown:e=>{"Escape"===e.key&&s()},placeholder:"Search providers…",style:{flex:1,background:"none",border:"none",outline:"none",color:"var(--text)",fontSize:13,boxSizing:"border-box"}})]}),(0,n.jsx)("div",{style:{flex:1,overflowY:"auto",padding:14},children:0===h?(0,n.jsx)("div",{style:{padding:"20px 0",fontSize:12,color:"var(--text-dim)",textAlign:"center"},children:"No providers match"}):(0,n.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(min(240px, 100%), 1fr))",gap:8},children:[g&&(0,n.jsx)("div",{style:{gridColumn:"1 / -1",fontSize:10,fontWeight:600,color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:"0.07em"},children:"Custom"}),g&&(0,n.jsxs)("button",{onClick:()=>{l(),s()},style:f,onMouseEnter:e=>{e.currentTarget.style.borderColor="var(--accent)",e.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:e=>{e.currentTarget.style.borderColor="var(--border)",e.currentTarget.style.background="var(--bg-panel)"},children:[(0,n.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,n.jsx)("div",{style:{fontSize:12,fontWeight:600,color:"var(--text)",lineHeight:1.3,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:"OpenAI / Anthropic compatible"}),(0,n.jsx)("div",{style:{fontSize:10,color:"var(--text-dim)",marginTop:2},children:"Custom endpoint format"})]}),(0,n.jsx)("span",{style:{width:26,height:26,borderRadius:5,background:"var(--bg-hover)",border:"1px dashed var(--border)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:(0,n.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{color:"var(--text-dim)"},children:[(0,n.jsx)("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),(0,n.jsx)("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})})]}),x.length>0&&(0,n.jsx)("div",{style:{gridColumn:"1 / -1",paddingTop:6*!!g,fontSize:10,fontWeight:600,color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:"0.07em"},children:"Subscriptions"}),x.map(e=>(0,n.jsxs)("button",{onClick:()=>{r(e.id),s()},style:f,onMouseEnter:e=>{e.currentTarget.style.borderColor="var(--accent)",e.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:e=>{e.currentTarget.style.borderColor="var(--border)",e.currentTarget.style.background="var(--bg-panel)"},children:[(0,n.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,n.jsx)("div",{style:{fontSize:12,fontWeight:600,color:"var(--text)",lineHeight:1.3,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name}),(0,n.jsx)("div",{style:{fontSize:10,color:"var(--text-dim)",marginTop:2},children:"OAuth"})]}),(0,n.jsx)(tF,{id:e.id,size:28})]},e.id)),u.length>0&&(0,n.jsx)("div",{style:{gridColumn:"1 / -1",paddingTop:6*(x.length>0),fontSize:10,fontWeight:600,color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:"0.07em"},children:"API Key"}),u.map(e=>(0,n.jsxs)("button",{onClick:()=>{i(e.id),s()},style:f,onMouseEnter:e=>{e.currentTarget.style.borderColor="var(--accent)",e.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:e=>{e.currentTarget.style.borderColor="var(--border)",e.currentTarget.style.background="var(--bg-panel)"},children:[(0,n.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,n.jsx)("div",{style:{fontSize:12,fontWeight:600,color:"var(--text)",lineHeight:1.3,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.displayName}),(0,n.jsxs)("div",{style:{fontSize:10,color:"var(--text-dim)",marginTop:2},children:[e.modelCount," models"]})]}),(0,n.jsx)(tF,{id:e.id,size:28})]},e.id))]})})]})})}function tN({onClose:e}){let[t,r]=(0,o.useState)({providers:{}}),[i,l]=(0,o.useState)(!0),[s,a]=(0,o.useState)(!1),[d,c]=(0,o.useState)(null),[p,x]=(0,o.useState)(!1),[u,g]=(0,o.useState)(null),[h,f]=(0,o.useState)([]),[y,b]=(0,o.useState)([]),[v,m]=(0,o.useState)([]),[j,k]=(0,o.useState)(null),[w,S]=(0,o.useState)(!1),C=(0,o.useCallback)(()=>{fetch("/api/auth/providers").then(e=>e.json()).then(e=>f(e.providers)).catch(()=>{})},[]),T=(0,o.useCallback)(()=>{fetch("/api/auth/all-providers").then(e=>e.json()).then(e=>b(e.providers)).catch(()=>{})},[]);(0,o.useEffect)(()=>{fetch("/api/models-config").then(e=>e.json()).then(e=>{let t=e.providers?e:{...e,providers:{}};r(t);let n=Object.keys(t.providers??{});n.length>0&&g({type:"provider",name:n[0]})}).catch(()=>r({providers:{}})).finally(()=>l(!1)),C(),T(),fetch("/api/models").then(e=>e.json()).then(e=>{e.modelList&&m(e.modelList),e.defaultModel&&k(e.defaultModel)}).catch(()=>{})},[C,T]);let I=(0,o.useCallback)(async(e,t)=>{try{(await fetch("/api/models",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:e,modelId:t})})).ok&&k({provider:e,modelId:t})}catch(e){console.error("Failed to set default model:",e)}},[]),z=(0,o.useCallback)(()=>{let e="new-provider",n=1;for(;t.providers?.[e];)e=`new-provider-${n++}`;r(t=>({...t,providers:{...t.providers??{},[e]:{api:"openai-completions"}}})),g({type:"provider",name:e})},[t.providers]),R=(0,o.useCallback)((e,t)=>{r(r=>({...r,providers:{...r.providers??{},[e]:t}}))},[]),L=(0,o.useCallback)((e,t)=>{r(r=>{let n=Object.entries(r.providers??{}),o=n.findIndex(([t])=>t===e);return -1===o?r:(n[o]=[t,n[o][1]],{...r,providers:Object.fromEntries(n)})}),g(r=>r?"provider"===r.type&&r.name===e?{type:"provider",name:t}:"model"===r.type&&r.providerName===e?{...r,providerName:t}:r:r)},[]),W=(0,o.useCallback)(e=>{r(t=>{let r={...t.providers??{}};return delete r[e],{...t,providers:r}}),r(e=>{let t=Object.keys(e.providers??{});return g(t.length>0?{type:"provider",name:t[0]}:null),e})},[]),E=(0,o.useCallback)(e=>{r(t=>{let r=t.providers?.[e]??{},n=[...r.models??[],{id:""}];return{...t,providers:{...t.providers??{},[e]:{...r,models:n}}}}),r(t=>{let r=(t.providers?.[e]?.models?.length??1)-1;return g({type:"model",providerName:e,index:r}),t})},[]),M=(0,o.useCallback)((e,t,n)=>{r(r=>{let o=r.providers?.[e]??{},i=[...o.models??[]];return i[t]=n,{...r,providers:{...r.providers??{},[e]:{...o,models:i}}}})},[]),D=(0,o.useCallback)((e,t)=>{r(r=>{let n=r.providers?.[e]??{},o=[...n.models??[]];return o.splice(t,1),{...r,providers:{...r.providers??{},[e]:{...n,models:o.length?o:void 0}}}}),g({type:"provider",name:e})},[]),$=(0,o.useCallback)(async()=>{a(!0),c(null),x(!1);try{let e=await fetch("/api/models-config",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),r=await e.json();!e.ok||r.error?c(r.error??`HTTP ${e.status}`):(x(!0),setTimeout(()=>x(!1),2e3))}catch(e){c(String(e))}finally{a(!1)}},[t]),B=Object.entries(t.providers??{}),A=h.filter(e=>e.loggedIn),F=y.filter(e=>e.configured),O=(()=>{if(!u)return null;if("oauth"===u.type){let e=h.find(e=>e.id===u.providerId);if(!e)return null;let t=v.filter(t=>t.provider===e.id);return(0,n.jsx)(tB,{provider:e,onRefresh:C,models:t,defaultModel:j,onSetDefault:I},e.id)}if("apikey"===u.type){let e=y.find(e=>e.id===u.providerId);if(!e)return null;let t=v.filter(t=>t.provider===e.id);return(0,n.jsx)(tA,{provider:e,onRefresh:T,models:t,defaultModel:j,onSetDefault:I},e.id)}if("provider"===u.type){let e=t.providers?.[u.name];return e?(0,n.jsx)(tL,{name:u.name,provider:e,onChange:e=>R(u.name,e),onRename:e=>L(u.name,e),onDelete:()=>W(u.name)},u.name):null}let e=t.providers?.[u.providerName],r=e?.models?.[u.index];if(!r)return null;let o=j?.provider===u.providerName&&j?.modelId===r.id;return(0,n.jsx)(t$,{model:r,isDefault:o,onSetDefault:()=>I(u.providerName,r.id),onChange:e=>M(u.providerName,u.index,e),onDelete:()=>D(u.providerName,u.index)},`${u.providerName}-${u.index}`)})();return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{style:{position:"fixed",inset:0,zIndex:1e3,background:"rgba(0,0,0,0.35)",display:"flex",alignItems:"center",justifyContent:"center"},onClick:t=>{t.target===t.currentTarget&&e()},children:(0,n.jsxs)("div",{style:{width:860,height:"78vh",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:10,display:"flex",flexDirection:"column",boxShadow:"0 8px 32px rgba(0,0,0,0.18)",overflow:"hidden"},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 18px",borderBottom:"1px solid var(--border)",flexShrink:0},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:10},children:[(0,n.jsx)("span",{style:{fontSize:15,fontWeight:700,color:"var(--text)"},children:"Models"}),(0,n.jsx)("code",{style:{fontSize:11,color:"var(--text-muted)",fontFamily:"var(--font-mono)"},children:"~/.ink/agent/models.json"})]}),(0,n.jsx)("button",{onClick:e,style:{background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",fontSize:20,lineHeight:1,padding:"2px 6px"},children:"\xd7"})]}),(0,n.jsxs)("div",{style:{flex:1,display:"flex",overflow:"hidden"},children:[(0,n.jsxs)("div",{style:{width:210,borderRight:"1px solid var(--border)",display:"flex",flexDirection:"column",flexShrink:0,background:"var(--bg-panel)"},children:[(0,n.jsxs)("div",{style:{flex:1,overflowY:"auto",padding:"8px 6px"},children:[A.map(e=>{let t=u?.type==="oauth"&&u.providerId===e.id;return(0,n.jsxs)("div",{onClick:()=>g({type:"oauth",providerId:e.id}),style:{display:"flex",alignItems:"center",gap:7,padding:"5px 8px",borderRadius:5,cursor:"pointer",background:t?"var(--bg-selected)":"none"},onMouseEnter:e=>{t||(e.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:e=>{t||(e.currentTarget.style.background="none")},children:[(0,n.jsx)(tF,{id:e.id,size:16}),(0,n.jsx)("span",{style:{fontSize:12,color:"var(--text)",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name})]},e.id)}),F.map(e=>{let t=u?.type==="apikey"&&u.providerId===e.id;return(0,n.jsxs)("div",{onClick:()=>g({type:"apikey",providerId:e.id}),style:{display:"flex",alignItems:"center",gap:7,padding:"5px 8px",borderRadius:5,cursor:"pointer",background:t?"var(--bg-selected)":"none"},onMouseEnter:e=>{t||(e.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:e=>{t||(e.currentTarget.style.background="none")},children:[(0,n.jsx)(tF,{id:e.id,size:16}),(0,n.jsx)("span",{style:{fontSize:12,color:"var(--text)",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.displayName})]},e.id)}),(A.length>0||F.length>0)&&B.length>0&&(0,n.jsx)("div",{style:{margin:"4px 8px",borderTop:"1px solid var(--border)"}}),i?(0,n.jsx)("div",{style:{padding:"10px 8px",fontSize:12,color:"var(--text-muted)"},children:"Loading…"}):B.map(([e,t])=>{let r=u?.type==="provider"&&u.name===e,o=t.models??[];return(0,n.jsxs)("div",{style:{marginBottom:2},children:[(0,n.jsxs)("div",{onClick:()=>g({type:"provider",name:e}),style:{display:"flex",alignItems:"center",gap:6,padding:"7px 8px",borderRadius:5,cursor:"pointer",background:r?"var(--bg-selected)":"none"},onMouseEnter:e=>{r||(e.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:e=>{r||(e.currentTarget.style.background="none")},children:[(0,n.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{color:"var(--text-dim)",flexShrink:0},children:[(0,n.jsx)("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"}),(0,n.jsx)("rect",{x:"9",y:"9",width:"6",height:"6"}),(0,n.jsx)("line",{x1:"9",y1:"1",x2:"9",y2:"4"}),(0,n.jsx)("line",{x1:"15",y1:"1",x2:"15",y2:"4"}),(0,n.jsx)("line",{x1:"9",y1:"20",x2:"9",y2:"23"}),(0,n.jsx)("line",{x1:"15",y1:"20",x2:"15",y2:"23"}),(0,n.jsx)("line",{x1:"20",y1:"9",x2:"23",y2:"9"}),(0,n.jsx)("line",{x1:"20",y1:"14",x2:"23",y2:"14"}),(0,n.jsx)("line",{x1:"1",y1:"9",x2:"4",y2:"9"}),(0,n.jsx)("line",{x1:"1",y1:"14",x2:"4",y2:"14"})]}),(0,n.jsx)("span",{style:{fontSize:12,fontWeight:r?600:400,color:"var(--text)",fontFamily:"var(--font-mono)",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e})]}),o.map((t,r)=>{let o=u?.type==="model"&&u.providerName===e&&u.index===r;return(0,n.jsxs)("div",{onClick:()=>g({type:"model",providerName:e,index:r}),style:{display:"flex",alignItems:"center",gap:6,padding:"5px 8px 5px 26px",borderRadius:5,cursor:"pointer",background:o?"var(--bg-selected)":"none"},onMouseEnter:e=>{o||(e.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:e=>{o||(e.currentTarget.style.background="none")},children:[(0,n.jsx)("span",{style:{fontSize:11,fontFamily:"var(--font-mono)",color:t.id?"var(--text-muted)":"var(--text-dim)",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.id||"new model"}),t.reasoning&&(0,n.jsx)("span",{style:{fontSize:9,padding:"1px 4px",background:"rgba(99,102,241,0.12)",color:"rgba(99,102,241,0.8)",borderRadius:3,flexShrink:0},children:"T"})]},r)}),(0,n.jsx)("div",{onClick:t=>{t.stopPropagation(),E(e)},style:{display:"flex",alignItems:"center",gap:4,padding:"4px 8px 4px 26px",borderRadius:5,cursor:"pointer",color:"var(--text-dim)"},onMouseEnter:e=>{e.currentTarget.style.color="var(--accent)",e.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-dim)",e.currentTarget.style.background="none"},children:(0,n.jsx)("span",{style:{fontSize:11},children:"+ model"})})]},e)})]}),(0,n.jsx)("div",{style:{borderTop:"1px solid var(--border)",padding:"8px 6px"},children:(0,n.jsx)("button",{onClick:()=>S(!0),style:{display:"flex",alignItems:"center",justifyContent:"center",gap:5,width:"100%",padding:"6px 0",background:"none",border:"1px dashed var(--border)",borderRadius:5,color:"var(--text-muted)",cursor:"pointer",fontSize:12},onMouseEnter:e=>{e.currentTarget.style.borderColor="var(--accent)",e.currentTarget.style.color="var(--accent)"},onMouseLeave:e=>{e.currentTarget.style.borderColor="var(--border)",e.currentTarget.style.color="var(--text-muted)"},children:"+ Add provider"})})]}),(0,n.jsx)("div",{style:{flex:1,overflowY:"auto",padding:20},children:i?null:O??(0,n.jsx)("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--text-dim)",fontSize:13},children:"Select a provider or model"})})]}),(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:10,padding:"10px 18px",borderTop:"1px solid var(--border)",flexShrink:0},children:[d&&(0,n.jsx)("span",{style:{fontSize:12,color:"#f87171",flex:1},children:d}),(0,n.jsx)("button",{onClick:e,style:{padding:"6px 14px",background:"none",border:"1px solid var(--border)",borderRadius:6,color:"var(--text-muted)",cursor:"pointer",fontSize:13},children:"Cancel"}),(0,n.jsxs)("button",{onClick:$,disabled:s||p,style:{position:"relative",padding:"6px 16px",minWidth:92,background:p?"#16a34a":s?"var(--bg-panel)":"var(--accent)",border:"none",borderRadius:6,color:p?"#fff":s?"var(--text-muted)":"#fff",cursor:s||p?"default":"pointer",fontSize:13,fontWeight:600,display:"inline-flex",alignItems:"center",justifyContent:"center",gap:6,transition:"background-color 0.2s ease, color 0.2s ease",animation:p?"saved-pop 0.45s ease":void 0},children:[p&&(0,n.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",style:{strokeDasharray:18,animation:"saved-check-draw 0.35s ease forwards",flexShrink:0},children:(0,n.jsx)("polyline",{points:"20 6 9 17 4 12"})}),(0,n.jsx)("span",{children:p?"Saved":s?"Saving…":"Save"})]})]})]})}),w&&(0,n.jsx)(tO,{oauthProviders:h,apiKeyProviders:y,onSelectOAuth:e=>g({type:"oauth",providerId:e}),onSelectApiKey:e=>g({type:"apikey",providerId:e}),onAddCustom:z,onClose:()=>S(!1)})]})}function tP(e){return e.replace(/^\/(?:Users|home)\/[^/]+/,"~")}function tH(e){let t=e.sourceInfo?.source,r=e.sourceInfo?.scope;return"user"===r||"user"===t?"global":"project"===r||"project"===t?"project":"path"}function t_({enabled:e,loading:t,onToggle:r}){return(0,n.jsx)("button",{onClick:r,disabled:t,title:e?"Visible in model prompt — click to disable":"Hidden from model prompt — click to enable",style:{flexShrink:0,width:40,height:22,borderRadius:11,border:"none",padding:0,cursor:t?"wait":"pointer",background:e?"var(--accent)":"var(--border)",position:"relative",transition:"background 0.18s",outline:"none"},children:(0,n.jsx)("span",{style:{position:"absolute",top:3,left:e?21:3,width:16,height:16,borderRadius:"50%",background:"var(--bg)",boxShadow:"0 1px 4px rgba(0,0,0,0.22)",transition:"left 0.18s cubic-bezier(.4,0,.2,1)"}})})}function tJ({skill:e,cwd:t,onToggle:r,toggling:o,saveError:i}){let l=tH(e),s=!e.disableModelInvocation;return(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:20},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:7},children:[(0,n.jsx)("span",{style:{fontSize:10,padding:"1px 5px",borderRadius:3,flexShrink:0,background:"project"===l?"rgba(99,102,241,0.12)":"rgba(120,120,120,0.12)",color:"project"===l?"rgba(99,102,241,0.8)":"var(--text-dim)"},children:l}),(0,n.jsx)("span",{style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-dim)",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:function(e){if("project"===l&&e.startsWith(t)){let r=e.slice(t.length).replace(/^[/\\]/,"");return`./${r}`}return tP(e)}(e.filePath)}),(0,n.jsx)(t_,{enabled:s,loading:o,onToggle:()=>r(e)}),i&&(0,n.jsx)("span",{style:{fontSize:12,color:"#f87171",flexShrink:0},children:i})]}),(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:5},children:[(0,n.jsx)("span",{style:{fontSize:12,color:"var(--text-muted)",fontWeight:500},children:"Name"}),(0,n.jsx)("span",{style:{fontFamily:"var(--font-mono)",fontSize:14,color:"var(--text)"},children:e.name})]}),(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:5},children:[(0,n.jsx)("span",{style:{fontSize:12,color:"var(--text-muted)",fontWeight:500},children:"Description"}),(0,n.jsx)("span",{style:{fontSize:14,color:"var(--text-muted)",lineHeight:1.6},children:e.description})]})]})}function tU({cwd:e,onInstalled:t}){let[r,i]=(0,o.useState)(""),[l,s]=(0,o.useState)([]),[a,d]=(0,o.useState)(!1),[c,p]=(0,o.useState)(null),[x,u]=(0,o.useState)(null),[g,h]=(0,o.useState)(null),[f,y]=(0,o.useState)(new Set),[b,v]=(0,o.useState)("global"),m=(0,o.useRef)(null);(0,o.useEffect)(()=>{m.current?.focus()},[]);let j=(0,o.useCallback)(async e=>{if(e.trim()){d(!0),p(null),s([]);try{let t=await fetch("/api/skills/search",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:e.trim()})}),r=await t.json();if(r.error)return void p(r.error);s(r.results??[]),0===(r.results??[]).length&&p("No skills found")}catch(e){p(String(e))}finally{d(!1)}}},[]),k=(0,o.useCallback)(async r=>{u(r),h(null);try{let n=await fetch("/api/skills/install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({package:r,scope:b,cwd:e})}),o=await n.json();if(!n.ok||o.error)return void h(o.error??`HTTP ${n.status}`);y(e=>new Set(e).add(r)),t()}catch(e){h(String(e))}finally{u(null)}},[t,b,e]),w="global"===b?"~/.ink/agent/skills/":`${tP(e)}/.ink/agent/skills/`;return(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%"},children:[(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:12,marginBottom:20},children:[(0,n.jsx)("div",{style:{fontSize:14,fontWeight:600,color:"var(--text)"},children:"Add Skill"}),(0,n.jsxs)("div",{style:{display:"flex",gap:8},children:[(0,n.jsx)("input",{ref:m,value:r,onChange:e=>i(e.target.value),onKeyDown:e=>{"Enter"===e.key&&j(r)},placeholder:"e.g. react, testing, deploy",style:{flex:1,padding:"7px 10px",fontSize:13,background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:6,color:"var(--text)",outline:"none"}}),(0,n.jsx)("button",{onClick:()=>j(r),disabled:a||!r.trim(),style:{padding:"7px 16px",fontSize:13,borderRadius:6,border:"none",background:"var(--accent)",color:"#fff",cursor:a||!r.trim()?"not-allowed":"pointer",opacity:a||!r.trim()?.5:1,flexShrink:0},children:a?"Searching…":"Search"})]}),(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10},children:[(0,n.jsx)("div",{style:{display:"flex",borderRadius:5,border:"1px solid var(--border)",overflow:"hidden",fontSize:12,flexShrink:0},children:["global","project"].map(e=>(0,n.jsx)("button",{onClick:()=>v(e),style:{padding:"3px 10px",border:"none",cursor:"pointer",background:b===e?"var(--bg-selected)":"none",color:b===e?"var(--text)":"var(--text-dim)",fontWeight:b===e?600:400,borderRight:"global"===e?"1px solid var(--border)":"none"},children:e},e))}),(0,n.jsxs)("span",{style:{fontSize:12,color:"var(--text-dim)",fontFamily:"var(--font-mono)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:["→ ",w]})]}),c&&(0,n.jsx)("div",{style:{fontSize:12,color:"#f87171"},children:c}),g&&(0,n.jsx)("div",{style:{fontSize:12,color:"#f87171",wordBreak:"break-word"},children:g})]}),l.length>0?(0,n.jsx)("div",{style:{flex:1,overflowY:"auto"},children:l.map(e=>{let t=f.has(e.package),r=x===e.package,o=e.package.indexOf("@"),i=o>-1?e.package.slice(0,o):e.package,l=o>-1?e.package.slice(o+1):null;return(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:14,padding:"12px 0",borderBottom:"1px solid var(--border)"},children:[(0,n.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,n.jsx)("div",{style:{fontSize:13,fontWeight:600,color:"var(--text)",marginBottom:3},children:l??i}),(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,flexWrap:"wrap"},children:[(0,n.jsx)("span",{style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-dim)"},children:i}),(0,n.jsx)("span",{style:{fontSize:12,color:"var(--text-muted)",fontWeight:500},children:e.installs}),e.url&&(0,n.jsx)("a",{href:e.url,target:"_blank",rel:"noreferrer",style:{fontSize:12,color:"var(--accent)",textDecoration:"none"},children:"skills.sh ↗"})]})]}),(0,n.jsx)("button",{onClick:()=>!t&&!r&&k(e.package),disabled:t||r||null!==x,style:{flexShrink:0,padding:"5px 14px",fontSize:12,fontWeight:500,borderRadius:5,border:"1px solid var(--border)",cursor:t||r||null!==x?"not-allowed":"pointer",background:t?"rgba(34,197,94,0.1)":"none",color:t?"#16a34a":r?"var(--accent)":"var(--text-muted)",transition:"color 0.12s"},children:t?"✓ Installed":r?"Installing…":"Install"})]},e.package)})}):!c&&!a&&(0,n.jsxs)("div",{style:{fontSize:13,color:"var(--text-dim)",lineHeight:1.8},children:["Search"," ",(0,n.jsx)("a",{href:"https://skills.sh",target:"_blank",rel:"noreferrer",style:{color:"var(--accent)",textDecoration:"none"},children:"skills.sh"})," ","to discover and install skills for your agent."]})]})}function tV({cwd:e,onClose:t}){let[r,i]=(0,o.useState)([]),[l,s]=(0,o.useState)(!0),[a,d]=(0,o.useState)(null),[c,p]=(0,o.useState)(null),[x,u]=(0,o.useState)(new Set),[g,h]=(0,o.useState)(null),[f,y]=(0,o.useState)(!1),b=(0,o.useCallback)(()=>{s(!0),d(null),fetch(`/api/skills?cwd=${encodeURIComponent(e)}`).then(e=>e.json()).then(e=>{if(e.error)return void d(e.error);let t=e.skills??[];i(t),t.length>0&&!c&&p(t[0].filePath)}).catch(e=>d(String(e))).finally(()=>s(!1))},[e,c]);(0,o.useEffect)(()=>{b()},[e]);let v=(0,o.useCallback)(async e=>{let t=!e.disableModelInvocation;u(t=>new Set(t).add(e.filePath)),h(null);try{let r=await fetch("/api/skills",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({filePath:e.filePath,disableModelInvocation:t})}),n=await r.json();if(!r.ok||n.error)return void h(n.error??`HTTP ${r.status}`);i(r=>r.map(r=>r.filePath===e.filePath?{...r,disableModelInvocation:t}:r))}catch(e){h(String(e))}finally{u(t=>{let r=new Set(t);return r.delete(e.filePath),r})}},[]),m=r.find(e=>e.filePath===c)??null;return(0,n.jsx)("div",{style:{position:"fixed",inset:0,zIndex:1e3,background:"rgba(0,0,0,0.35)",display:"flex",alignItems:"center",justifyContent:"center"},onClick:e=>{e.target===e.currentTarget&&t()},children:(0,n.jsxs)("div",{style:{width:860,height:"78vh",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:10,display:"flex",flexDirection:"column",boxShadow:"0 8px 32px rgba(0,0,0,0.18)",overflow:"hidden"},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 18px",borderBottom:"1px solid var(--border)",flexShrink:0},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:10},children:[(0,n.jsx)("span",{style:{fontSize:15,fontWeight:700,color:"var(--text)"},children:"Skills"}),(0,n.jsx)("code",{style:{fontSize:11,color:"var(--text-muted)",fontFamily:"var(--font-mono)",maxWidth:320,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:tP(e)})]}),(0,n.jsx)("button",{onClick:t,style:{background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",fontSize:20,lineHeight:1,padding:"2px 6px"},children:"\xd7"})]}),(0,n.jsxs)("div",{style:{flex:1,display:"flex",overflow:"hidden"},children:[(0,n.jsxs)("div",{style:{width:210,borderRight:"1px solid var(--border)",display:"flex",flexDirection:"column",flexShrink:0,background:"var(--bg-panel)"},children:[(0,n.jsx)("div",{style:{flex:1,overflowY:"auto",padding:"8px 6px"},children:l?(0,n.jsx)("div",{style:{padding:"10px 8px",fontSize:12,color:"var(--text-muted)"},children:"Loading…"}):a?(0,n.jsx)("div",{style:{padding:"10px 8px",fontSize:11,color:"#f87171"},children:a}):0===r.length?(0,n.jsx)("div",{style:{padding:"10px 8px",fontSize:11,color:"var(--text-dim)"},children:"No skills found"}):(()=>{let e=[];for(let t of["project","global","path"]){let n=r.filter(e=>tH(e)===t);n.length>0&&e.push({label:t,skills:n})}return e.map(({label:e,skills:t})=>(0,n.jsxs)("div",{style:{marginBottom:6},children:[(0,n.jsx)("div",{style:{padding:"4px 8px 3px",fontSize:10,fontWeight:600,color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:"0.06em"},children:e}),t.map(e=>{let t=!f&&c===e.filePath,r=e.disableModelInvocation;return(0,n.jsxs)("div",{onClick:()=>{p(e.filePath),y(!1)},style:{display:"flex",alignItems:"center",gap:7,padding:"8px 8px",borderRadius:5,cursor:"pointer",background:t?"var(--bg-selected)":"none"},onMouseEnter:e=>{t||(e.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:e=>{t||(e.currentTarget.style.background="none")},children:[(0,n.jsx)("span",{style:{flexShrink:0,width:7,height:7,borderRadius:"50%",background:r?"var(--border)":"var(--accent)",boxShadow:r?"none":"0 0 4px var(--accent)",transition:"background 0.15s, box-shadow 0.15s"}}),(0,n.jsx)("span",{style:{fontSize:12,fontWeight:t?600:400,color:r?"var(--text-dim)":"var(--text)",fontFamily:"var(--font-mono)",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name})]},e.filePath)})]},e))})()}),(0,n.jsx)("div",{style:{padding:"8px 6px",borderTop:"1px solid var(--border)",flexShrink:0},children:(0,n.jsxs)("div",{onClick:()=>y(!0),style:{display:"flex",alignItems:"center",gap:6,padding:"7px 8px",borderRadius:5,cursor:"pointer",background:f?"var(--bg-selected)":"none",color:f?"var(--accent)":"var(--text-dim)",fontSize:12},onMouseEnter:e=>{f||(e.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:e=>{f||(e.currentTarget.style.background="none")},children:[(0,n.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),(0,n.jsx)("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),"Add skill"]})})]}),(0,n.jsx)("div",{style:{flex:1,overflowY:"auto",padding:20},children:f?(0,n.jsx)(tU,{cwd:e,onInstalled:()=>{b()}}):l?null:m?(0,n.jsx)(tJ,{skill:m,cwd:e,onToggle:v,toggling:x.has(m.filePath),saveError:g},m.filePath):(0,n.jsx)("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--text-dim)",fontSize:13},children:"Select a skill"})})]}),(0,n.jsx)("div",{style:{display:"flex",alignItems:"center",justifyContent:"flex-end",padding:"10px 18px",borderTop:"1px solid var(--border)",flexShrink:0},children:(0,n.jsx)("button",{onClick:t,style:{padding:"6px 14px",background:"none",border:"1px solid var(--border)",borderRadius:6,color:"var(--text-muted)",cursor:"pointer",fontSize:13},children:"Close"})})]})})}function tY({onClose:e,onSave:t}){let[r,i]=(0,o.useState)(!0),[l,s]=(0,o.useState)(!0),[a,d]=(0,o.useState)(!0),[c,p]=(0,o.useState)(!1),[x,u]=(0,o.useState)(!1);return(0,o.useEffect)(()=>{let e=localStorage.getItem("ink-show-execution-confirm");null!==e&&i("true"===e);let t=localStorage.getItem("ink-show-import-draft");null!==t&&s("true"===t);let r=localStorage.getItem("ink-show-auto-generate-short");null!==r&&d("true"===r)},[]),(0,n.jsx)("div",{style:{position:"fixed",inset:0,zIndex:1e3,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(10, 10, 10, 0.4)",backdropFilter:"blur(4px)"},onClick:e,children:(0,n.jsxs)("div",{onClick:e=>e.stopPropagation(),style:{width:"min(400px, 90%)",background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:12,boxShadow:"0 20px 40px rgba(0,0,0,0.15)",display:"flex",flexDirection:"column",overflow:"hidden"},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"14px 18px",borderBottom:"1px solid var(--border)"},children:[(0,n.jsxs)("span",{style:{fontSize:13,fontWeight:600,color:"var(--text)",display:"flex",alignItems:"center",gap:6},children:[(0,n.jsx)("span",{style:{fontSize:14},children:"⚙️"})," 系统全局设置"]}),(0,n.jsx)("button",{onClick:e,style:{background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",fontSize:16,padding:4,lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center"},children:"✕"})]}),(0,n.jsxs)("div",{style:{padding:"20px 18px",display:"flex",flexDirection:"column",gap:16},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:16},children:[(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[(0,n.jsx)("span",{style:{fontSize:13,fontWeight:500,color:"var(--text)"},children:"操作执行前确认提示"}),(0,n.jsx)("span",{style:{fontSize:11,color:"var(--text-dim)",lineHeight:1.4},children:"点击底部工具栏按钮(智能续写、局部定点修复、防崩审计等)时,弹出确认窗口并显示功能说明。"})]}),(0,n.jsxs)("label",{style:{position:"relative",display:"inline-block",width:40,height:22,flexShrink:0,cursor:"pointer"},children:[(0,n.jsx)("input",{type:"checkbox",checked:r,onChange:e=>i(e.target.checked),style:{opacity:0,width:0,height:0}}),(0,n.jsx)("span",{style:{position:"absolute",cursor:"pointer",inset:0,backgroundColor:r?"var(--accent)":"var(--bg-hover)",border:"1px solid var(--border)",borderRadius:22,transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)",boxShadow:"inset 0 1px 2px rgba(0,0,0,0.05)"},children:(0,n.jsx)("span",{style:{position:"absolute",height:16,width:16,left:r?20:2,bottom:2,backgroundColor:"#fff",borderRadius:"50%",transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)",boxShadow:"0 1px 3px rgba(0,0,0,0.15)"}})})]})]}),(0,n.jsx)("div",{style:{height:"1px",background:"var(--border)",opacity:.6}}),(0,n.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:16},children:[(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[(0,n.jsx)("span",{style:{fontSize:13,fontWeight:500,color:"var(--text)"},children:"显示“导入已有旧稿”按钮"}),(0,n.jsx)("span",{style:{fontSize:11,color:"var(--text-dim)",lineHeight:1.4},children:"在侧边栏显示“导入已有旧稿”按钮,支持从外部 TXT 章节或已有文件批量导入故事宇宙。"})]}),(0,n.jsxs)("label",{style:{position:"relative",display:"inline-block",width:40,height:22,flexShrink:0,cursor:"pointer"},children:[(0,n.jsx)("input",{type:"checkbox",checked:l,onChange:e=>s(e.target.checked),style:{opacity:0,width:0,height:0}}),(0,n.jsx)("span",{style:{position:"absolute",cursor:"pointer",inset:0,backgroundColor:l?"var(--accent)":"var(--bg-hover)",border:"1px solid var(--border)",borderRadius:22,transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)",boxShadow:"inset 0 1px 2px rgba(0,0,0,0.05)"},children:(0,n.jsx)("span",{style:{position:"absolute",height:16,width:16,left:l?20:2,bottom:2,backgroundColor:"#fff",borderRadius:"50%",transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)",boxShadow:"0 1px 3px rgba(0,0,0,0.15)"}})})]})]}),(0,n.jsx)("div",{style:{height:"1px",background:"var(--border)",opacity:.6}}),(0,n.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:16},children:[(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[(0,n.jsx)("span",{style:{fontSize:13,fontWeight:500,color:"var(--text)"},children:"显示“一键全自动生成短篇”按钮"}),(0,n.jsx)("span",{style:{fontSize:11,color:"var(--text-dim)",lineHeight:1.4},children:"在侧边栏显示“一键全自动生成短篇”快捷键,支持配置并启动全自动短篇小说大纲与章节生成流水线。"})]}),(0,n.jsxs)("label",{style:{position:"relative",display:"inline-block",width:40,height:22,flexShrink:0,cursor:"pointer"},children:[(0,n.jsx)("input",{type:"checkbox",checked:a,onChange:e=>d(e.target.checked),style:{opacity:0,width:0,height:0}}),(0,n.jsx)("span",{style:{position:"absolute",cursor:"pointer",inset:0,backgroundColor:a?"var(--accent)":"var(--bg-hover)",border:"1px solid var(--border)",borderRadius:22,transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)",boxShadow:"inset 0 1px 2px rgba(0,0,0,0.05)"},children:(0,n.jsx)("span",{style:{position:"absolute",height:16,width:16,left:a?20:2,bottom:2,backgroundColor:"#fff",borderRadius:"50%",transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)",boxShadow:"0 1px 3px rgba(0,0,0,0.15)"}})})]})]})]}),(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:10,padding:"10px 18px",borderTop:"1px solid var(--border)",background:"var(--bg-panel)"},children:[(0,n.jsx)("button",{onClick:e,style:{padding:"5px 12px",background:"none",border:"1px solid var(--border)",borderRadius:6,color:"var(--text-muted)",cursor:"pointer",fontSize:12},children:"取消"}),(0,n.jsxs)("button",{onClick:()=>{p(!0),localStorage.setItem("ink-show-execution-confirm",String(r)),localStorage.setItem("ink-show-import-draft",String(l)),localStorage.setItem("ink-show-auto-generate-short",String(a)),window.dispatchEvent(new CustomEvent("ink-settings-changed",{detail:{showExecutionConfirm:r,showImportDraft:l,showAutoGenerateShort:a}})),setTimeout(()=>{p(!1),u(!0),setTimeout(()=>{u(!1),t&&t(),e()},500)},300)},disabled:c||x,style:{padding:"5px 14px",minWidth:80,background:x?"#16a34a":"var(--accent)",border:"none",borderRadius:6,color:"#fff",cursor:c||x?"default":"pointer",fontSize:12,fontWeight:600,display:"inline-flex",alignItems:"center",justifyContent:"center",gap:4,transition:"background-color 0.2s ease"},children:[x&&(0,n.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("polyline",{points:"20 6 9 17 4 12"})}),(0,n.jsx)("span",{children:x?"已保存":c?"保存中…":"保存设定"})]})]})]})})}function tK({onClose:e}){let t,[r,i]=(0,o.useState)("setup"),[l,s]=(0,o.useState)(0),a=[{id:"setup",icon:"\uD83D\uDEE0️",title:"第一步:工作区初始化",subtitle:"一键开启小说创作宇宙与模型配置",steps:[{title:"1. 一键开启创作宇宙 (Workspace Init)",content:(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[(0,n.jsxs)("div",{children:["当你选定一个未初始化的空文件夹或已有稿件的目录后,侧边栏顶部会亮起 ",(0,n.jsx)("strong",{children:"“未初始化的创作空间”"})," 警告卡。 点击 ",(0,n.jsx)("strong",{style:{color:"var(--accent)"},children:"【一键开启创作宇宙】"})," 按钮,系统将在后台执行 ",(0,n.jsx)("code",{children:"inkos init"}),":"]}),(0,n.jsx)("div",{style:{background:"rgba(255, 255, 255, 0.03)",padding:"10px 14px",borderRadius:8,border:"1px solid var(--border)"},children:(0,n.jsxs)("ul",{style:{paddingLeft:18,margin:0,lineHeight:"1.7"},children:[(0,n.jsxs)("li",{children:["在项目根目录下生成 ",(0,n.jsx)("code",{children:"story/"}),"(真相数据库)和 ",(0,n.jsx)("code",{children:"books/"}),"(书籍目录)。"]}),(0,n.jsxs)("li",{children:["建立并注册 ",(0,n.jsx)("code",{children:"inkos.json"})," 工作区参数配置文件。"]}),(0,n.jsx)("li",{children:"检测完毕后,警告卡会自动消失,开启正式的小说管理界面。"})]})}),(0,n.jsx)("div",{children:(0,n.jsx)("em",{children:"提示:初始化成功后,警告框会自动关闭并刷新文件树,此时即可创建第一本书籍。"})})]})},{title:"2. 大模型能力配置 (Models Config)",content:(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[(0,n.jsxs)("div",{children:["点击右上角的 ",(0,n.jsx)("strong",{children:"【配置模型】"})," 按钮(芯片网格图标)。对于网文及严肃长篇创作,大模型的“分工协作”对产出质量有着决定性影响:"]}),(0,n.jsx)("div",{style:{background:"rgba(255, 255, 255, 0.03)",padding:"10px 14px",borderRadius:8,border:"1px solid var(--border)"},children:(0,n.jsxs)("ul",{style:{paddingLeft:18,margin:0,lineHeight:"1.7"},children:[(0,n.jsxs)("li",{children:[(0,n.jsx)("strong",{children:"起草与润色模型 (Drafting & Polishing)"}),":",(0,n.jsx)("br",{}),"推荐使用生成速度较快、词汇库相对活泼、情节张力强且具备强大长上下文对齐能力的选择。例如:",(0,n.jsx)("code",{children:"Claude 3.5 Sonnet"}),"、",(0,n.jsx)("code",{children:"DeepSeek-Chat (V3)"}),"。"]}),(0,n.jsxs)("li",{style:{marginTop:8},children:[(0,n.jsx)("strong",{children:"防崩审计模型 (Auditing)"}),":",(0,n.jsx)("br",{}),"防崩溃审计需要极强的心智模型和严谨的指令遵循度,用于检测境界贬值、逻辑冲突等。强烈推荐配置高规格的推理大模型,如 ",(0,n.jsx)("code",{children:"GPT-4o"}),"、",(0,n.jsx)("code",{children:"Claude 3.5 Sonnet"}),"。"]})]})}),(0,n.jsxs)("div",{children:["配置好 API Key 和 Proxy Base URL(如无代理则留空)后,点击 ",(0,n.jsx)("strong",{children:"【保存设定】"})," 即可即时生效。"]})]})}]},{id:"create",icon:"\uD83D\uDCE5",title:"第二步:书籍管理、起草与导入",subtitle:"协同起草大纲人设、新建书籍与旧稿导入",steps:[{title:"1. AI 协同起草大纲人设 (AI Co-writers)",content:(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("strong",{children:"适用场景"}),":当手头只有一些灵感碎片,还没有成型的小说大纲与角色人设时。"]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("strong",{children:"操作流程"}),":先不急于创建新书。在左侧侧边栏展开 ",(0,n.jsx)("strong",{style:{color:"var(--accent)"},children:"【AI 写作伴侣 (Co-writers)】"})," 面板,点击 ",(0,n.jsx)("strong",{children:"+ Create"})," 或选用内置写作姬:"]}),(0,n.jsx)("div",{style:{background:"rgba(255, 255, 255, 0.03)",padding:"10px 14px",borderRadius:8,border:"1px solid var(--border)"},children:(0,n.jsxs)("ul",{style:{paddingLeft:18,margin:0,lineHeight:"1.7"},children:[(0,n.jsxs)("li",{children:[(0,n.jsx)("strong",{children:"大纲策划师 (\uD83D\uDDFA️)"}),":共同脑暴、梳理剧情冲突与主线节奏,策划结果将在本地工作区生成 ",(0,n.jsx)("code",{children:"架构.md"}),"。"]}),(0,n.jsxs)("li",{children:[(0,n.jsx)("strong",{children:"人设雕琢师 (\uD83D\uDD2E)"}),":设定角色姓名、背景性格、专属对话口吻等,结果生成为 ",(0,n.jsx)("code",{children:"人设.md"}),"。"]})]})}),(0,n.jsx)("div",{children:(0,n.jsx)("em",{children:"提示:Gems 写作伴侣支持指定不同的底层大模型,并允许“关联知识库文件”注入绝对路径的设定参考,实现精准对齐。"})})]})},{title:"2. 新建书籍与框架继承 (Create Book)",content:(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[(0,n.jsxs)("div",{children:["在左侧栏选择 ",(0,n.jsx)("strong",{children:"【创建新书】"}),",你需要配置书籍标题、风格题材、以及创意简报。"]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("strong",{children:"\uD83D\uDCA1 极速架构合入与继承机制"}),": 如果在新建书籍前,你已在项目工作区目录下存有由 AI 写作伴侣起草保存的 ",(0,n.jsx)("code",{children:"架构.md"}),"(或 ",(0,n.jsx)("code",{children:"novel_framework.md"}),")和 ",(0,n.jsx)("code",{children:"人设.md"}),"(或 ",(0,n.jsx)("code",{children:"character_profiles.md"}),"),系统会在建书时",(0,n.jsx)("strong",{children:"自动识别并读取"}),"它们,将人设与境界体系合入底层 Truth 数据库(",(0,n.jsx)("code",{children:"story/"})," 目录)。"]})]})},{title:"3. 批量导入已有旧章原稿",content:(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[(0,n.jsxs)("div",{children:["如果你想将以往在其他软件写好的小说(包含数十万字的历史章节)迁移到本站继续写,可以使用侧边栏工具栏的 ",(0,n.jsx)("strong",{children:"【导入设定或旧章原稿】"})," 按钮(向下的箭头):"]}),(0,n.jsxs)("div",{style:{background:"rgba(255, 255, 255, 0.03)",padding:"10px 14px",borderRadius:8,border:"1px solid var(--border)"},children:[(0,n.jsx)("strong",{children:"操作配置项"}),":",(0,n.jsxs)("ul",{style:{paddingLeft:18,margin:"6px 0",lineHeight:"1.7"},children:[(0,n.jsxs)("li",{children:[(0,n.jsx)("code",{children:"导入源路径 (From Path)"}),":选择包含旧稿 Markdown 或 TXT 文件的本地文件夹,或者单个合集大文本文件。"]}),(0,n.jsxs)("li",{children:[(0,n.jsx)("code",{children:"章节拆分正则 (Split Regex)"}),":系统默认以 ",(0,n.jsx)("code",{children:"第[一二三四五六七八九十百千万\\d]+章"})," 进行智能切割分章,你可以根据自己的分章规范修改正则。"]}),(0,n.jsxs)("li",{children:[(0,n.jsx)("code",{children:"断点续传 (Resume From)"}),":可设定从某章开始导入。"]})]})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("strong",{children:"逆向提取引擎的工作流程"}),": 导入旧稿不仅仅是把文字搬运过来。导入后,AI 会自动按章节运行逆向同步流水线。它会读取你的历史章节正文,梳理世界观、人物性格特征、当前境界、并搜寻所有尚未解决的历史伏笔。最终在 ",(0,n.jsx)("code",{children:"story/"})," 目录下自动搭建出人设矩阵、伏笔池和状态卡,完成逆向“补完”。"]})]})},{title:"4. 继承前作/正典设定",content:(0,n.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:(0,n.jsxs)("div",{children:["如果是撰写同宇宙的系列第二部,在导入面板中选择 ",(0,n.jsx)("strong",{children:"“导入正典设定”"}),",指定前作的 Book ID,即可将前作的世界观、人物人设直接克隆到新书中作为参考正典,避免吃设定。"]})})}]},{id:"plan",icon:"\uD83D\uDDFA️",title:"第三步:蓝图细化",subtitle:"智能大纲细纲编译与意图强制控制",steps:[{title:"1. 一键规划蓝图",content:(0,n.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:8},children:(0,n.jsxs)("div",{children:["在写每章之前,点击章节底部的 ",(0,n.jsx)("strong",{children:"【规划蓝图】"}),"。 系统后台的多智能体大纲规划管线会启动。AI 会结合:",(0,n.jsxs)("ol",{style:{paddingLeft:18,margin:"6px 0",lineHeight:"1.6"},children:[(0,n.jsx)("li",{children:"当前书的大纲设定和卷纲。"}),(0,n.jsx)("li",{children:"前一章节的末尾内容(保持剧情绝对平滑过渡)。"}),(0,n.jsxs)("li",{children:[(0,n.jsx)("code",{children:"pending_hooks.md"})," 中标记为“本章该兑现”或“急需解决”的悬念和伏笔。"]}),(0,n.jsxs)("li",{children:[(0,n.jsx)("code",{children:"current_state.md"})," 中存活的、且在当前场景的角色列表。"]})]}),"从而编译生成本章的 ",(0,n.jsx)("strong",{children:"本章大纲细纲 (Outline)"})," 以及 ",(0,n.jsx)("strong",{children:"本章写作意图 (Intent)"}),"。"]})})},{title:"2. 意图调整与主线校验",content:(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[(0,n.jsxs)("div",{children:["规划出的细纲会在右侧报告面板展示。",(0,n.jsx)("strong",{children:"作为作者,您握有最高控制权:"})]}),(0,n.jsx)("div",{style:{borderLeft:"3px solid var(--accent)",paddingLeft:12,fontStyle:"italic",fontSize:11},children:"例如:系统规划本章是日常过渡,而你决定强行加快节奏。你可以直接在报告的意图编辑框中添加: “本章插入刺客夜袭情节,主角被迫反击并暴露法宝,击退敌人后负伤撤退”。"}),(0,n.jsxs)("div",{children:["修改保存后,接下来的“智能续写”和“极速草稿”都将把此修改作为",(0,n.jsx)("strong",{children:"刚性控制参数"}),"输入,绝对不会偏离你的微调方向。"]})]})}]},{id:"write",icon:"✍️",title:"第四步:正文创作",subtitle:"高文采续写、草稿快跑与冲突回滚机制",steps:[{title:"1. 智能续写 (标准模式)",content:(0,n.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:(0,n.jsxs)("div",{children:["点击底部的橙色按钮 ",(0,n.jsx)("strong",{style:{color:"#ff903f"},children:"【智能续写】"}),"。 AI 将根据本章蓝图和设定账本展开高水平文学写作。生成过程中会连续在后台执行防崩溃逻辑检验和修正,最终生成最符合要求的上下文章节。"]})})},{title:"2. 极速草稿 (快跑模式)",content:(0,n.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:(0,n.jsxs)("div",{children:["点击续写旁的下拉箭头,切换至 ",(0,n.jsx)("strong",{children:"【极速草稿】"}),",在右侧输入“创意引导描述”(例如:“主角打碎花瓶,被师父责罚”)。 此模式将跳过复杂的后台审计直接以最高生成速度输出大纲片段,方便快速扩充灵感,稍后再行修正。"]})})},{title:"3. 空缺章节填补与逻辑冲突回滚",content:(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[(0,n.jsx)("div",{children:"系统内置了智能的文件断层检测和回滚保护:"}),(0,n.jsxs)("ul",{style:{paddingLeft:18,margin:0,lineHeight:"1.7"},children:[(0,n.jsxs)("li",{children:[(0,n.jsx)("strong",{children:"空缺章节自动填补 (Auto-Healing)"}),":若你在文件树中意外删除了某章(如第 4 章),在写第 5 章时,系统检测到章节空缺,会自动创建第 4 章占位草稿并向你报警,维持故事的时序连贯。"]}),(0,n.jsxs)("li",{children:[(0,n.jsx)("strong",{children:"分支重写冲突阻断 (Conflict Warning)"}),":若你回到前面(例如第 3 章)重新续写,而你的书库中已经存在后续的第 4、5、6 章。系统会弹出红色警告:",(0,n.jsx)("br",{}),(0,n.jsx)("span",{style:{color:"#ef4444",fontWeight:600},children:"“检测到书库中已存在后续章节。在第 3 章后重新起草,将自动废弃并物理覆盖后续所有章节。”"}),(0,n.jsx)("br",{}),"一旦你确认强制重写,系统会在后台执行 `write rewrite --force`,自动将整个宇宙的状态快照完美回滚到第 3 章末尾,确保后续章节不会产生大面积逻辑污染。"]})]})]})}]},{id:"sync",icon:"\uD83D\uDD04",title:"第五步:对账同步",subtitle:"更新真相账本以对抗AI长期遗忘",steps:[{title:"1. 设定同步的作用原理",content:(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[(0,n.jsx)("div",{children:"网络小说创作极度依赖前后的呼应和设定的严密性。当你手动修改了章节正文后,大模型如果未能读取到你的修改,会在后续生成中产生吃设定现象。"}),(0,n.jsxs)("div",{children:[(0,n.jsx)("strong",{children:"解决方案"}),":完成手动编辑后,点击底部工具栏绿色的 ",(0,n.jsx)("strong",{children:"【同步设定】"}),"。 系统会在后台提取本章所有关键事件、状态演变,更新到 ",(0,n.jsx)("code",{children:"story/"})," 账本中。"]})]})},{title:"2. 三大核心对账单详解",content:(0,n.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:(0,n.jsx)("div",{style:{background:"rgba(255, 255, 255, 0.03)",padding:12,borderRadius:8,border:"1px solid var(--border)"},children:(0,n.jsxs)("ul",{style:{paddingLeft:18,margin:0,lineHeight:"1.7"},children:[(0,n.jsxs)("li",{children:[(0,n.jsxs)("strong",{children:["状态卡 (",(0,n.jsx)("code",{children:"current_state.md"}),")"]}),": 更新当前章发生事件的简短摘要、所处宏观场景与时序,以及当前在场角色的存活状态。"]}),(0,n.jsxs)("li",{style:{marginTop:6},children:[(0,n.jsxs)("strong",{children:["资源数值账本 (",(0,n.jsx)("code",{children:"particle_ledger.md"}),")"]}),": 对于升级流或具有严密数值系统的网络小说(如修仙的灵力、网游的经验值、财富等),同步设定会自动对账并更新数值。若正文中主角购买法宝消耗了 100 灵石,账本中灵石会自动扣除,避免“主角的灵石花不完”等贬值硬伤。"]}),(0,n.jsxs)("li",{style:{marginTop:6},children:[(0,n.jsxs)("strong",{children:["未兑现伏笔池 (",(0,n.jsx)("code",{children:"pending_hooks.md"}),")"]}),": 自动检索本章正文。如果主角在正文中埋下了伏笔(如“在角落种下了隐形种子”),伏笔池会自动记录该 Hook;若主角击杀了埋伏已久的强敌,伏笔池会自动将该伏笔标记为“已兑现并闭环”,防止烂尾。"]})]})})})}]},{id:"audit",icon:"\uD83D\uDD0D",title:"第六步:质量审计",subtitle:"连续性与人设冲突多智能体校验",steps:[{title:"1. 运行防崩审计",content:(0,n.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:(0,n.jsxs)("div",{children:["点击底部的蓝色按钮 ",(0,n.jsx)("strong",{style:{color:"#60a5fa"},children:"【防崩审计】"}),"。 系统将调用独立审计智能体扫描本章正文,与你的真相设定数据库进行精细核对。"]})})},{title:"2. 十二大核心防崩维度",content:(0,n.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:(0,n.jsx)("div",{style:{background:"rgba(255, 255, 255, 0.02)",padding:"12px 16px",borderRadius:8,border:"1px solid var(--border)",fontSize:11},children:(0,n.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px 16px",lineHeight:"1.6"},children:[(0,n.jsxs)("div",{children:["• ",(0,n.jsx)("strong",{children:"OOC 人设坍塌"}),":性格突变或违反人设设定"]}),(0,n.jsxs)("div",{children:["• ",(0,n.jsx)("strong",{children:"Mainline 大纲跑偏"}),":偏离主线意图"]}),(0,n.jsxs)("div",{children:["• ",(0,n.jsx)("strong",{children:"Timeline 时序冲突"}),":剧情发生顺序错误"]}),(0,n.jsxs)("div",{children:["• ",(0,n.jsx)("strong",{children:"Conflict 爽点虚化"}),":承诺的情节点未爆开"]}),(0,n.jsxs)("div",{children:["• ",(0,n.jsx)("strong",{children:"Hook 伏笔漏洞"}),":挖坑未埋或未同步登记"]}),(0,n.jsxs)("div",{children:["• ",(0,n.jsx)("strong",{children:"Power 战力崩坏"}),":境界、装备数值异常膨胀"]}),(0,n.jsxs)("div",{children:["• ",(0,n.jsx)("strong",{children:"Pacing 节奏失控"}),":推进过慢或过渡过硬"]}),(0,n.jsxs)("div",{children:["• ",(0,n.jsx)("strong",{children:"POV 视角混乱"}),":第三人称与第一人称意外混淆"]}),(0,n.jsxs)("div",{children:["• ",(0,n.jsx)("strong",{children:"Subplot 支线停滞"}),":支线大面积闲置无推进"]}),(0,n.jsxs)("div",{children:["• ",(0,n.jsx)("strong",{children:"Relationship 关系冲突"}),":配角对主角态度转变不合理"]}),(0,n.jsxs)("div",{children:["• ",(0,n.jsx)("strong",{children:"Incentive 利益链冲突"}),":人物动机缺乏底层逻辑"]}),(0,n.jsxs)("div",{children:["• ",(0,n.jsx)("strong",{children:"Canon 违反正典"}),":同人创作中违背原著世界法则"]})]})})})},{title:"3. 问题级别定义",content:(0,n.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:(0,n.jsxs)("ul",{style:{paddingLeft:18,margin:0,lineHeight:"1.7"},children:[(0,n.jsxs)("li",{children:[(0,n.jsx)("strong",{style:{color:"#ef4444"},children:"Critical (严重致命)"}),":人设大面积坍塌、核心设定冲突、大纲彻底跑偏。系统会拦截接下来的新章自动续写,必须修正此级别错误后方可继续。"]}),(0,n.jsxs)("li",{children:[(0,n.jsx)("strong",{style:{color:"#f97316"},children:"Warning (警告)"}),":局部战斗力描写略高、伏笔登记漏掉、小数值算错。建议微调以保持长篇故事线整洁。"]}),(0,n.jsxs)("li",{children:[(0,n.jsx)("strong",{style:{color:"var(--accent)"},children:"Info (参考建议)"}),":局部的行文措辞冗余、段落等长导致阅读疲劳、词汇丰富度建议。"]})]})})}]},{id:"revise",icon:"\uD83E\uDE84",title:"第七步:智能精修与检测",subtitle:"智能特征检测与精细修补,掌控修改幅度",steps:[{title:"1. 检测 AI 味 (Detect AI-ness)",content:(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("strong",{children:"定义与核心原则"}),": 只评估,**绝对不修改任何正文**。系统通过大模型或本地规则,深度解剖当前正文中的 AI 特征,并生成诊断报告。"]}),(0,n.jsx)("div",{style:{background:"rgba(255, 255, 255, 0.03)",padding:12,borderRadius:8,border:"1px solid var(--border)"},children:(0,n.jsxs)("ul",{style:{paddingLeft:18,margin:0,lineHeight:"1.7"},children:[(0,n.jsxs)("li",{children:[(0,n.jsx)("strong",{children:"LLM 大模型检测"}),":从语义层面审查文字是否空洞、叙述腔调是否模板化,指明需要去 AI 味的具体句子和冗长句段。"]}),(0,n.jsxs)("li",{children:[(0,n.jsx)("strong",{children:"本地规则检测 (Offline)"}),":完全基于本地算法,计算段落句长分布是否过于均等、排比结构是否冗余、以及套话转折词的出现频次(零耗费 Token)。"]})]})})]})},{title:"2. 局部定点修复 (Spot-Fix)",content:(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("strong",{children:"定义与核心原则"}),": 定点修复是为解决“改一个错字导致AI把全章重写一遍”而设计的。它",(0,n.jsx)("strong",{children:"绝对禁止改动无关段落"}),"。"]}),(0,n.jsx)("div",{style:{background:"rgba(255, 255, 255, 0.03)",padding:12,borderRadius:8,border:"1px solid var(--border)"},children:(0,n.jsxs)("ul",{style:{paddingLeft:18,margin:0,lineHeight:"1.7"},children:[(0,n.jsxs)("li",{children:[(0,n.jsx)("strong",{children:"允许范围"}),":严格锁定在审计指出问题的那个句子或段落,以及其前后紧邻的各一句话(前后 1 行行内颗粒度)。"]}),(0,n.jsxs)("li",{children:[(0,n.jsx)("strong",{children:"运作逻辑"}),":AI 识别定位 ",(0,n.jsx)("code",{children:"TARGET_TEXT"})," 并生成 ",(0,n.jsx)("code",{children:"REPLACEMENT_TEXT"})," 补丁,其余 99% 的文本原封不动地返回,安全度最高。"]})]})})]})},{title:"3. 防检测润色 (Anti-Detect) — 去 AI 味黄金指南",content:(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("strong",{children:"定义与核心原则"}),": 网络小说中如果充斥着死板的“AI味”,会极大地削弱读者的代入感。防检测润色是通过重置词汇指纹与语法句式,抹除生成痕迹。"]}),(0,n.jsxs)("div",{style:{background:"rgba(255, 255, 255, 0.03)",padding:12,borderRadius:8,border:"1px solid var(--border)"},children:[(0,n.jsx)("strong",{children:"引擎底层的九大改写规则"}),":",(0,n.jsxs)("ol",{style:{paddingLeft:18,margin:"6px 0",lineHeight:"1.7",fontSize:11},children:[(0,n.jsxs)("li",{children:[(0,n.jsx)("strong",{children:"打破等长段落"}),":交替长短句,避免大模型惯有的均等对称句子,使句式结构不可预测。"]}),(0,n.jsxs)("li",{children:[(0,n.jsx)("strong",{children:"口语化与自然表达"}),":消灭书面套话。",(0,n.jsx)("br",{}),(0,n.jsx)("em",{children:"正例:✗“然而事情并没有那么简单” ➜ ✓“哪有那么便宜的事”"})]}),(0,n.jsxs)("li",{children:[(0,n.jsx)("strong",{children:"降低“了”字密度"}),":避免冗余的时态助词。",(0,n.jsx)("br",{}),(0,n.jsx)("em",{children:"正例:✗“他走了过去,拿了杯子” ➜ ✓“他走过去,端起杯子”"})]}),(0,n.jsxs)("li",{children:[(0,n.jsx)("strong",{children:"转折词降频"}),":删除过于死板的“虽然…但是…”、“不得不说”,换用角色内心吐槽或直接动作切换。"]}),(0,n.jsxs)("li",{children:[(0,n.jsx)("strong",{children:"情绪动作外化 (Show, Don't Tell)"}),":不写抽象结论。",(0,n.jsx)("br",{}),(0,n.jsx)("em",{children:"正例:✗“他感到非常愤怒” ➜ ✓“他捏减了茶杯,指节发白,滚烫的茶水顺着指缝流下来”"})]}),(0,n.jsxs)("li",{children:[(0,n.jsx)("strong",{children:"删去叙述者强行盖棺定论"}),":剔除“这一刻他终于懂得了力量”等大道理,只保留具体行动,让读者自行感受。"]}),(0,n.jsxs)("li",{children:[(0,n.jsx)("strong",{children:"群像反应具体化"}),":避免脸谱化。",(0,n.jsx)("br",{}),(0,n.jsx)("em",{children:"正例:✗“全场震惊” ➜ ✓“老陈手里的烟头掉在了裤子上,烫得他龇牙咧嘴跳起来”"})]}),(0,n.jsxs)("li",{children:[(0,n.jsx)("strong",{children:"消除AI标志性疲劳词"}),":强力清洗“不禁”、“仿佛”、“宛如”、“嘴角微微上扬”等大模型高频出现的敷衍性过渡词,换为独具文学色彩的具体感官描写。"]}),(0,n.jsxs)("li",{children:[(0,n.jsx)("strong",{children:"段落长短悬殊化"}),":让有的段落只有几个字,有的段落七八行,营造真实的叙事节奏感。"]})]})]})]})},{title:"4. 文本润色 (Polish)",content:(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("strong",{children:"定义与核心原则"}),": 只改行文措辞和语调,**绝对不改变任何剧情事实与结论**。"]}),(0,n.jsx)("div",{style:{background:"rgba(255, 255, 255, 0.03)",padding:12,borderRadius:8,border:"1px solid var(--border)"},children:(0,n.jsxs)("ul",{style:{paddingLeft:18,margin:0,lineHeight:"1.7"},children:[(0,n.jsxs)("li",{children:[(0,n.jsx)("strong",{children:"严禁操作"}),":禁止增删段落、禁止更改人名/地名/法宝名称、禁止添加任何新的剧情对话。"]}),(0,n.jsxs)("li",{children:[(0,n.jsx)("strong",{children:"允许操作"}),":替换高雅词汇、优化语言节奏、调整语序、改善句段之间的衔接呼吸感。适合成稿后的最后一轮精细抛光。"]})]})})]})},{title:"5. 智能改写 (Rewrite)",content:(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("strong",{children:"定义与核心原则"}),": 围绕有缺陷或干瘪的段落及其直接上下文进行局部细节扩写和场景重组。"]}),(0,n.jsx)("div",{style:{background:"rgba(255, 255, 255, 0.03)",padding:12,borderRadius:8,border:"1px solid var(--border)"},children:(0,n.jsxs)("ul",{style:{paddingLeft:18,margin:0,lineHeight:"1.7"},children:[(0,n.jsxs)("li",{children:[(0,n.jsx)("strong",{children:"适用场景"}),":某场戏打斗软弱无力、表白情节毫无波澜、对话干瘪无趣。"]}),(0,n.jsxs)("li",{children:[(0,n.jsx)("strong",{children:"修改方式"}),":AI会专注于这一段场景,添加大量的神态细节、心理活动、微表情、环境动作互动,把抽象的情节点“撑开”变得立体饱满,但保留人物的核心动机和结果。"]})]})})]})},{title:"6. 剧情重写 (Rework)",content:(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("strong",{children:"定义与核心原则"}),": 允许推倒整章的场景顺序和矛盾冲突,重新结构化正文。"]}),(0,n.jsx)("div",{style:{background:"rgba(255, 255, 255, 0.03)",padding:12,borderRadius:8,border:"1px solid var(--border)"},children:(0,n.jsxs)("ul",{style:{paddingLeft:18,margin:0,lineHeight:"1.7"},children:[(0,n.jsxs)("li",{children:[(0,n.jsx)("strong",{children:"适用场景"}),":当前章节的叙事结构、推进节奏严重拉崩,或者因为大纲重大调整需要推倒重来。"]}),(0,n.jsxs)("li",{children:[(0,n.jsx)("strong",{children:"刚性约束"}),":虽然允许重构全部场景与对话,但依然受到 ",(0,n.jsx)("code",{children:"story/"})," Truth 账本的高层约束,不能违反已经发生的正典事实或强行改变大设定。"]})]})})]})}]},{id:"advanced",icon:"\uD83D\uDE80",title:"第八步:高级辅助功能",subtitle:"文风克隆、长篇归档、同人创作与合规导出",steps:[{title:"1. 文风克隆工坊 (Style Clone Workshop)",content:(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[(0,n.jsx)("div",{children:"通过提取和分析统计你的文风特征,让 AI 续写和改写时的文笔高度贴合你本人的写作语气。"}),(0,n.jsxs)("div",{style:{background:"rgba(255, 255, 255, 0.03)",padding:12,borderRadius:8,border:"1px solid var(--border)"},children:[(0,n.jsx)("strong",{children:"实战技巧"}),":",(0,n.jsxs)("ol",{style:{paddingLeft:18,margin:0,lineHeight:"1.7"},children:[(0,n.jsxs)("li",{children:["点击顶部的 ",(0,n.jsx)("strong",{children:"【文风克隆工坊】"})," 按钮。"]}),(0,n.jsx)("li",{children:"粘贴你本人以往纯手写、且最满意的小说段落(强烈建议在 2000-5000 字之间,最好是包含对话、场景描写和日常叙述的综合片段)。"}),(0,n.jsxs)("li",{children:["AI会进行文风特征提取并生成 ",(0,n.jsx)("code",{children:"style_guide.md"})," 文风指南存入 ",(0,n.jsx)("code",{children:"story/"}),"。"]}),(0,n.jsx)("li",{children:"在顶部左侧的文风下拉选择框中,切换为刚刚克隆出的文风名称。此后所有的智能续写和改写都将自动沿袭你的这一专属特色。"})]})]})]})},{title:"2. 大纲摘要压缩归档 (Consolidate)",content:(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("strong",{children:"上下文窗口危机"}),": 当你的书写到 50 章或上百章之后,几近百万字的历史章节由于大模型上下文窗口限制,会导致 AI 忘记前期的伏笔和人设。"]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("strong",{children:"操作方法"}),": 当系统检测到完结卷或历史章节过多时,左侧栏顶部会弹出 ",(0,n.jsx)("strong",{children:"“建议进行大纲摘要压缩”"})," 的小字卡片。点击 ",(0,n.jsx)("strong",{children:"【一键压缩归档】"}),"。"]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("strong",{children:"底层逻辑"}),": 系统会将已完结的所有章节摘要压缩归并为宏观的“卷级概要”存入 ",(0,n.jsx)("code",{children:"volume_summaries.md"}),",并将明细摘要封存到 ",(0,n.jsx)("code",{children:"summaries_archive/"}),"。这样可以极大地精简大模型所需阅读的上下文,腾空 Token,同时保障大模型对几百章前埋下的暗线伏笔依然具备长效记忆。"]})]})},{title:"3. 同人创作模式深度规则 (Fanfiction CP/AU/OOC)",content:(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[(0,n.jsx)("div",{children:"在新建书籍时开启“同人写作”模式,系统支持以下 4 种微调态度:"}),(0,n.jsx)("div",{style:{background:"rgba(255, 255, 255, 0.03)",padding:12,borderRadius:8,border:"1px solid var(--border)"},children:(0,n.jsxs)("ul",{style:{paddingLeft:18,margin:0,lineHeight:"1.7",fontSize:11},children:[(0,n.jsxs)("li",{children:[(0,n.jsx)("strong",{children:"正典延续 (canon)"}),":AI 强力对齐原著背景设定和人物结局,作为官方续写。"]}),(0,n.jsxs)("li",{children:[(0,n.jsx)("strong",{children:"平行宇宙 (au)"}),":允许将人物放置在全新世界背景下,但保留核心性格和说话语癖。"]}),(0,n.jsxs)("li",{children:[(0,n.jsx)("strong",{children:"角色偏离 (ooc)"}),":放开人设性格束缚,允许发生反差性发展。"]}),(0,n.jsxs)("li",{children:[(0,n.jsx)("strong",{children:"角色配对 (cp)"}),":强力驱动两人互动,自动聚焦和放大情感线、羁绊线。"]})]})}),(0,n.jsxs)("div",{children:[(0,n.jsx)("strong",{children:"\uD83C\uDFAC 刷新同人设定"}),": 在左侧栏点击“刷新设定”,填入原著的小说文本或人物百科绝对路径。AI会重新提炼原作的语癖(如标志性口头禅、句尾助词)以及人物特征,重新计算以供写作时随时使用。"]})]})},{title:"4. 全自动短篇小说生成管线 (Short Novel Pipeline)",content:(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[(0,n.jsxs)("div",{children:["侧边栏支持 ",(0,n.jsx)("strong",{children:"【一键全自动生成短篇】"}),":"]}),(0,n.jsx)("div",{style:{background:"rgba(255, 255, 255, 0.03)",padding:12,borderRadius:8,border:"1px solid var(--border)"},children:"输入一段故事题材意图,并设定目标章节数(默认为 12 章)和单章字数。 系统将连续启动多智能体管线:自动生成故事大纲 ➜ 生成每章意图细化细纲 ➜ 连续全自动起草 12-18 章完整正文 ➜ 在后台自动生成对应的书籍精美封面。适合快速生成成套短篇小说。"})]})},{title:"5. 导出小说书稿 (Exporting Options)",content:(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[(0,n.jsxs)("div",{children:["点击侧边栏顶部的 ",(0,n.jsx)("strong",{children:"【导出小说书稿】"})," 按钮(向上箭头图标):"]}),(0,n.jsx)("div",{style:{background:"rgba(255, 255, 255, 0.03)",padding:12,borderRadius:8,border:"1px solid var(--border)"},children:(0,n.jsxs)("ul",{style:{paddingLeft:18,margin:0,lineHeight:"1.7"},children:[(0,n.jsxs)("li",{children:[(0,n.jsx)("strong",{children:"输出格式"}),":支持合并为单一的 ",(0,n.jsx)("code",{children:".txt"}),"、",(0,n.jsx)("code",{children:".md"}),",或导出为格式精美的 ",(0,n.jsx)("code",{children:".epub"})," 电子书格式。"]}),(0,n.jsxs)("li",{children:[(0,n.jsx)("strong",{children:"审核态过滤"}),":勾选 ",(0,n.jsx)("strong",{children:"“仅导出已审核通过章节”"}),",系统会自动过滤掉尚未完成或被标记为审计失败的草稿,保障发布版本绝对合规安全。"]})]})})]})}]}];return(0,n.jsx)("div",{style:{position:"fixed",inset:0,zIndex:1100,background:"rgba(10, 10, 10, 0.4)",backdropFilter:"blur(6px)",display:"flex",justifyContent:"flex-end",animation:"fadeIn 0.2s ease-out"},onClick:e,children:(0,n.jsxs)("div",{onClick:e=>e.stopPropagation(),style:{width:"min(640px, 92%)",height:"100%",background:"var(--bg)",boxShadow:"-10px 0 30px rgba(0,0,0,0.2)",display:"flex",flexDirection:"column",borderLeft:"1px solid var(--border)",fontFamily:"var(--font-serif)",animation:"slideIn 0.25s cubic-bezier(0.16, 1, 0.3, 1)"},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"18px 24px",borderBottom:"1px solid var(--border)",background:"var(--bg-panel)",flexShrink:0},children:[(0,n.jsxs)("span",{style:{fontSize:14,fontWeight:700,color:"var(--text)",display:"flex",alignItems:"center",gap:8},children:[(0,n.jsx)("span",{style:{fontSize:18},children:"\uD83D\uDCDA"})," InkOS 小说实战创作手册"]}),(0,n.jsx)("button",{onClick:e,style:{background:"none",border:"1px solid var(--border)",borderRadius:"50%",width:26,height:26,color:"var(--text-muted)",cursor:"pointer",fontSize:12,display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.15s"},onMouseEnter:e=>{e.currentTarget.style.color="var(--text)",e.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-muted)",e.currentTarget.style.background="none"},children:"✕"})]}),(0,n.jsx)("div",{style:{display:"flex",flexWrap:"nowrap",overflowX:"auto",background:"var(--bg-panel)",borderBottom:"1px solid var(--border)",padding:"6px 8px",gap:3,flexShrink:0,WebkitOverflowScrolling:"touch"},children:a.map(e=>{let t=r===e.id;return(0,n.jsxs)("button",{onClick:()=>{i(e.id),s(0)},style:{display:"flex",alignItems:"center",gap:4,padding:"5px 8px",borderRadius:6,border:"none",background:t?"var(--bg-selected)":"transparent",color:t?"var(--accent)":"var(--text-muted)",cursor:"pointer",fontSize:10.5,fontWeight:600,whiteSpace:"nowrap",transition:"all 0.15s",flexShrink:0},onMouseEnter:e=>{t||(e.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:e=>{t||(e.currentTarget.style.background="transparent")},children:[(0,n.jsx)("span",{children:e.icon}),(0,n.jsx)("span",{children:e.title.split(":")[0]})]},e.id)})}),(t=a.find(e=>e.id===r)||a[0],(0,n.jsxs)("div",{style:{flex:1,overflowY:"auto",padding:"24px 28px"},children:[(0,n.jsxs)("div",{style:{marginBottom:20},children:[(0,n.jsx)("span",{style:{fontSize:11,color:"var(--accent)",fontWeight:700,textTransform:"uppercase",letterSpacing:"0.05em"},children:t.title}),(0,n.jsx)("h2",{style:{fontSize:18,fontWeight:700,margin:"4px 0 8px 0",color:"var(--text)"},children:t.subtitle}),(0,n.jsx)("div",{style:{height:2,width:40,background:"var(--accent)",borderRadius:1}})]}),(0,n.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:12},children:t.steps.map((e,t)=>{let r=l===t;return(0,n.jsxs)("div",{style:{border:"1px solid var(--border)",borderRadius:10,background:r?"var(--bg-panel)":"transparent",overflow:"hidden",transition:"all 0.2s ease"},children:[(0,n.jsxs)("button",{onClick:()=>s(r?null:t),style:{width:"100%",padding:"14px 18px",display:"flex",alignItems:"center",justifyContent:"space-between",border:"none",background:"none",cursor:"pointer",textAlign:"left",fontFamily:"var(--font-serif)"},children:[(0,n.jsx)("span",{style:{fontSize:13,fontWeight:600,color:r?"var(--accent)":"var(--text)"},children:e.title}),(0,n.jsx)("span",{style:{fontSize:10,color:"var(--text-dim)"},children:r?"▲":"▼"})]}),r&&(0,n.jsx)("div",{style:{padding:"0 18px 18px 18px",fontSize:12,color:"var(--text-muted)",lineHeight:"1.7",borderTop:"1px solid rgba(255, 255, 255, 0.03)"},children:e.content})]},t)})})]})),(0,n.jsxs)("div",{style:{padding:"16px 24px",borderTop:"1px solid var(--border)",background:"var(--bg-panel)",display:"flex",justifyContent:"space-between",alignItems:"center",flexShrink:0},children:[(0,n.jsx)("span",{style:{fontSize:10,color:"var(--text-dim)"},children:"\uD83D\uDCA1 提示:侧边栏支持导入旧稿、导出书稿、一键全自动生成短篇和设定归档。"}),(0,n.jsx)("button",{onClick:e,style:{padding:"6px 16px",fontSize:11,borderRadius:6,border:"1px solid var(--border)",background:"var(--bg)",color:"var(--text)",cursor:"pointer",fontWeight:600,transition:"all 0.15s"},onMouseEnter:e=>{e.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:e=>{e.currentTarget.style.background="var(--bg)"},children:"我懂了,开始创作"})]})]})})}function tq(){let e=(0,i.useSearchParams)(),{isDark:t,toggleTheme:r}=eO(),[l,s]=(0,o.useState)(null),[a,d]=(0,o.useState)(null),[c,p]=(0,o.useState)(null),[x,u]=(0,o.useState)(0),[g,h]=(0,o.useState)(0),[f,y]=(0,o.useState)(0),[b,v]=(0,o.useState)(!1),[m,j]=(0,o.useState)(0),[k,w]=(0,o.useState)(!1),[S,C]=(0,o.useState)(!1),[T,I]=(0,o.useState)(!1),[z,R]=(0,o.useState)(!0),[L,W]=(0,o.useState)(null),[E,M]=(0,o.useState)(!0),D=(0,o.useRef)(null),$=(0,o.useRef)(null),[B,A]=(0,o.useState)([]),[F,O]=(0,o.useState)(null),N=(0,o.useRef)(null),P=(0,o.useCallback)((e,t,r)=>{A(e),O(t),N.current=r},[]);(0,o.useCallback)(e=>{N.current?.(e)},[]);let[H,_]=(0,o.useState)(null);(0,o.useRef)(null);let J=(0,o.useCallback)(e=>{_(e)},[]),[U,V]=(0,o.useState)(null),Y=(0,o.useCallback)(e=>{V(e)},[]),[K,q]=(0,o.useState)(null),G=(0,o.useCallback)(e=>{q(e)},[]),[X,Q]=(0,o.useState)(null),[ee,et]=(0,o.useState)(null);(0,o.useCallback)(e=>{Q(t=>t===e?null:e)},[]),(0,o.useEffect)(()=>{if(!X||!$.current)return;let e=()=>{let e=$.current.getBoundingClientRect();et({top:e.bottom,left:e.left,width:e.width})};e();let t=new ResizeObserver(e);return t.observe($.current),()=>t.disconnect()},[X]),(0,o.useEffect)(()=>{let e=localStorage.getItem("ink-show-execution-confirm");null!==e?R("true"===e):R(!0);let t=e=>{e.detail&&R(e.detail.showExecutionConfirm)};return window.addEventListener("ink-settings-changed",t),()=>{window.removeEventListener("ink-settings-changed",t)}},[]);let[er,en]=(0,o.useState)([]),[eo,ei]=(0,o.useState)(null),[el,es]=(0,o.useState)(()=>!!new URLSearchParams(window.location.search).get("session")),ea=(0,o.useCallback)(e=>{D.current?.insertText("`"+e+"`")},[]),[ed]=(0,o.useState)(()=>e.get("session")),[ec,ep]=(0,o.useState)(null),[ex,eu]=(0,o.useState)(()=>!e.get("session")),eg=(0,o.useRef)(!1),eh=(0,o.useCallback)(e=>{ep(e),e&&!eg.current&&(s(t=>t&&t.cwd!==e?null:t),d(t=>t&&t!==e?null:t),h(e=>e+1),A([]),O(null),_(null),Q(null),window.history.replaceState(null,"","/"))},[]),ef=(0,o.useCallback)((e,t=!1)=>{d(null),s(e),p(null),h(e=>e+1),_(null),eu(!0),t&&(eg.current=!0,setTimeout(()=>{eg.current=!1},0)),t||window.history.replaceState(null,"",`?session=${encodeURIComponent(e.id)}`),es(!0)},[]),ey=(0,o.useCallback)((e,t,r)=>{s(null),d(t),p(r??null),h(e=>e+1),A([]),O(null),_(null),Q(null),window.history.replaceState(null,"","/"),es(!0)},[]),eb=(0,o.useCallback)(e=>{d(null),s(e),p(null),u(e=>e+1),window.history.replaceState(null,"",`?session=${encodeURIComponent(e.id)}`),es(!0)},[]),ev=(0,o.useCallback)(()=>{u(e=>e+1),y(e=>e+1)},[]),em=(0,o.useCallback)(e=>{u(e=>e+1),h(e=>e+1),d(null),s(t=>({...t??{path:"",cwd:"",created:"",modified:"",messageCount:0,firstMessage:""},id:e})),window.history.replaceState(null,"",`?session=${encodeURIComponent(e)}`),es(!0)},[]),ej=(0,o.useCallback)(()=>{eu(!0)},[]),ek=(0,o.useCallback)(e=>{if(u(e=>e+1),l?.id===e){let e=l.cwd;s(null),d(e??null),h(e=>e+1),A([]),O(null),_(null),Q(null),window.history.replaceState(null,"","/")}},[l]),ew=(0,o.useCallback)(e=>{en(t=>{let r=t.filter(t=>t.id!==e);return 0===r.length&&es(!1),r}),ei(t=>{if(t!==e)return t;let r=er.filter(t=>t.id!==e);return r.length>0?r[r.length-1].id:null})},[er]),eS=(0,o.useCallback)((e,t)=>{let r=`file:${e}`;en(n=>n.find(e=>e.id===r)?n:[...n,{id:r,label:t,filePath:e}]),ei(r),es(!0)},[]);(0,o.useEffect)(()=>{let e=()=>{y(e=>e+1)},t=e=>{e.detail&&eS(e.detail.filePath,e.detail.fileName)},r=e=>{e.detail&&e.detail.filePath&&ew(`file:${e.detail.filePath}`)},n=e=>{if(e.detail&&e.detail.dirPath){let t=e.detail.dirPath.replace(/\\/g,"/").toLowerCase();en(e=>{let r=e.filter(e=>!e.filePath.replace(/\\/g,"/").toLowerCase().startsWith(t));return 0===r.length&&es(!1),ei(e=>e?e.replace(/^file:/,"").replace(/\\/g,"/").toLowerCase().startsWith(t)?r.length>0?r[r.length-1].id:null:e:null),r})}};return window.addEventListener("refresh-explorer",e),window.addEventListener("open-file",t),window.addEventListener("close-file",r),window.addEventListener("close-directory",n),()=>{window.removeEventListener("refresh-explorer",e),window.removeEventListener("open-file",t),window.removeEventListener("close-file",r),window.removeEventListener("close-directory",n)}},[eS,ew]);let eC=a??(null===l&&ec?ec:null),eT=null!==l||null!==eC,eI=ex&&!eT,ez=er.find(e=>e.id===eo)??null,[eR,eL]=(0,o.useState)([]),[eW,eM]=(0,o.useState)(null),[eD,e$]=(0,o.useState)(!1),[eB,eA]=(0,o.useState)(!1),[eF,eN]=(0,o.useState)(!1),eP=(0,o.useCallback)((e,t)=>{eL(e),eM(t),eN(!1)},[]),eH=(0,o.useCallback)(e=>{eN(!0),window.dispatchEvent(new CustomEvent("trigger-style-switch",{detail:{styleName:e}}))},[]),e_=(0,o.useCallback)(e=>{if(e!==(eW||"default")){if(!z)return void eH(e);W({targetStyle:e,onConfirm:()=>{eH(e),W(null)},onCancel:()=>{W(null)}})}},[eW,z,eH]),eJ=(0,o.useCallback)((e,t)=>{e$(e),eA(t)},[]),eU=(0,n.jsx)(n.Fragment,{children:(0,n.jsx)(Z,{selectedSessionId:l?.id??null,onSelectSession:ef,onNewSession:ey,initialSessionId:ed,onInitialRestoreDone:ej,refreshKey:x,onSessionDeleted:ek,selectedCwd:l?.cwd??a??null,onCwdChange:eh,onOpenFile:eS,explorerRefreshKey:f,onAtMention:ea,activeGemId:c,availableStyles:eR,activeStyleName:eW,onStylesChange:eP,onWorkspaceStatusChange:eJ})});return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{style:{display:"flex",height:"100dvh",overflow:"hidden",background:"var(--bg)"},children:[(0,n.jsx)("div",{className:"sidebar-overlay-backdrop",onClick:()=>M(!1),style:{position:"fixed",inset:0,zIndex:199,background:"rgba(0,0,0,0.4)",opacity:+!!E,pointerEvents:E?"auto":"none",transition:"opacity 0.25s ease"}}),(0,n.jsx)("div",{className:`sidebar-container${E?" sidebar-open":" sidebar-closed"}`,style:{background:"var(--bg-panel)",borderRight:"1px solid var(--border)",display:"flex",flexDirection:"column",flexShrink:0,zIndex:200},children:eU}),(0,n.jsxs)("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden",minWidth:0},children:[(0,n.jsxs)("div",{ref:$,style:{display:"flex",alignItems:"center",flexShrink:0,borderBottom:"1px solid var(--border)",height:36,background:"var(--bg-panel)"},children:[(0,n.jsx)("button",{onClick:()=>M(e=>!e),title:E?"Hide sidebar":"Show sidebar",style:{display:"flex",alignItems:"center",justifyContent:"center",width:36,height:36,padding:0,background:"none",border:"none",borderRight:"1px solid var(--border)",color:"var(--text-muted)",cursor:"pointer",flexShrink:0,transition:"color 0.12s"},onMouseEnter:e=>{e.currentTarget.style.color="var(--text)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-muted)"},children:E?(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),(0,n.jsx)("line",{x1:"9",y1:"3",x2:"9",y2:"21"})]}):(0,n.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[(0,n.jsx)("line",{x1:"3",y1:"6",x2:"21",y2:"6"}),(0,n.jsx)("line",{x1:"3",y1:"12",x2:"21",y2:"12"}),(0,n.jsx)("line",{x1:"3",y1:"18",x2:"21",y2:"18"})]})}),eD&&(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",flexShrink:0,height:"100%"},children:[(0,n.jsx)("div",{style:{display:"flex",alignItems:"center",padding:"0 10px",borderRight:"1px solid var(--border)",height:"100%"},children:(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",background:"rgba(99, 102, 241, 0.08)",border:"1px solid rgba(99, 102, 241, 0.4)",borderRadius:"6px",padding:"4px 8px",height:24,transition:"all 0.2s ease"},children:[(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"#818cf8",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{marginRight:4},children:[(0,n.jsx)("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),(0,n.jsx)("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]}),(0,n.jsx)("select",{value:L?L.targetStyle:eW||"default",disabled:eF,onChange:e=>e_(e.target.value),style:{background:"none",color:"#818cf8",border:"none",fontSize:"11px",outline:"none",cursor:eR&&eR.length>1?"pointer":"default",padding:"0 4px",fontWeight:600,fontFamily:"var(--font-serif)"},children:eR&&eR.length>0?eR.map(e=>(0,n.jsx)("option",{value:e,style:{background:"var(--bg-panel)",color:"var(--text)"},children:e},e)):(0,n.jsx)("option",{value:"default",style:{background:"var(--bg-panel)",color:"var(--text)"},children:"default"})})]})}),eB&&(0,n.jsxs)("button",{onClick:()=>{window.dispatchEvent(new Event("trigger-style-clone"))},title:"文风克隆工坊 (Style Clone)",style:{display:"flex",alignItems:"center",gap:6,height:"100%",padding:"0 12px",background:"none",border:"none",borderRight:"1px solid var(--border)",color:"var(--text-muted)",cursor:"pointer",fontSize:12,fontWeight:500,transition:"color 0.12s, background 0.12s"},onMouseEnter:e=>{e.currentTarget.style.color="var(--text)",e.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-muted)",e.currentTarget.style.background="none"},children:[(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{marginRight:2},children:[(0,n.jsx)("path",{d:"M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18z"}),(0,n.jsx)("path",{d:"M8 10h.01M16 10h.01",strokeWidth:"3"}),(0,n.jsx)("path",{d:"M12 14a3 3 0 0 0-3 3h6a3 3 0 0 0-3-3z"})]}),(0,n.jsx)("span",{children:"文风克隆工坊"})]}),(0,n.jsxs)("button",{onClick:()=>{window.dispatchEvent(new Event("trigger-radar"))},title:"市场雷达 (Market Intelligence Scan)",style:{display:"flex",alignItems:"center",gap:6,height:"100%",padding:"0 12px",background:"none",border:"none",borderRight:"1px solid var(--border)",color:"var(--text-muted)",cursor:"pointer",fontSize:12,fontWeight:500,transition:"color 0.12s, background 0.12s"},onMouseEnter:e=>{e.currentTarget.style.color="var(--text)",e.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-muted)",e.currentTarget.style.background="none"},children:[(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{marginRight:2},children:[(0,n.jsx)("path",{d:"M12 22c5.523 0 10-4.477 10-10S17.523 2 12 2 2 6.477 2 12s4.477 10 10 10z"}),(0,n.jsx)("path",{d:"M12 17c2.761 0 5-2.239 5-5s-2.239-5-5-5-5 2.239-5 5 2.239 5 5 5z"}),(0,n.jsx)("circle",{cx:"12",cy:"12",r:"1",fill:"currentColor"})]}),(0,n.jsx)("span",{children:"市场雷达"})]})]}),eT&&(U||K)&&(()=>{let e=U?.tokens,t=U?.cost??0,r=e=>e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(0)}k`:String(e),o=t>0?t>=.01?`$${t.toFixed(2)}`:"<$0.01":null,i="var(--text-muted)",l=null;if(K?.contextWindow){let e=K.percent;null!==e&&e>90?i="#ef4444":null!==e&&e>70&&(i="rgba(234,179,8,0.95)"),l=null!==e?`${e.toFixed(0)}% / ${r(K.contextWindow)}`:`? / ${r(K.contextWindow)}`}let s=[];if(e&&(s.push(`in: ${e.input.toLocaleString()}`),s.push(`out: ${e.output.toLocaleString()}`),s.push(`cache read: ${e.cacheRead.toLocaleString()}`),s.push(`cache write: ${e.cacheWrite.toLocaleString()}`),t>0&&s.push(`cost: $${t.toFixed(4)}`)),K?.contextWindow){let e=K.percent;s.push(`context: ${null!==e?e.toFixed(1)+"%":"unknown"} of ${K.contextWindow.toLocaleString()} tokens`)}let a=s.join(" | ");return(0,n.jsxs)("div",{title:a,style:{marginLeft:"auto",flex:"0 1 auto",minWidth:0,overflow:"hidden",display:"flex",alignItems:"center",gap:10,paddingLeft:12,paddingRight:el?12:156,height:"100%",fontSize:11,color:"var(--text-muted)",whiteSpace:"nowrap",cursor:"default",fontVariantNumeric:"tabular-nums"},children:[e&&e.input>0&&(0,n.jsxs)("span",{style:{display:"flex",alignItems:"center",gap:4},children:[(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("line",{x1:"5",y1:"8.5",x2:"5",y2:"1.5"}),(0,n.jsx)("polyline",{points:"2 4 5 1.5 8 4"})]}),r(e.input)]}),e&&e.output>0&&(0,n.jsxs)("span",{style:{display:"flex",alignItems:"center",gap:4},children:[(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("line",{x1:"5",y1:"1.5",x2:"5",y2:"8.5"}),(0,n.jsx)("polyline",{points:"2 6 5 8.5 8 6"})]}),r(e.output)]}),e&&e.cacheRead>0&&(0,n.jsxs)("span",{style:{display:"flex",alignItems:"center",gap:4},children:[(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M8.5 5a3.5 3.5 0 1 1-1-2.45"}),(0,n.jsx)("polyline",{points:"6.5 1.5 8.5 2.5 7.5 4.5"})]}),r(e.cacheRead)]}),o&&(0,n.jsx)("span",{style:{display:"flex",alignItems:"center",color:"var(--text)",fontWeight:500},children:o}),l&&(0,n.jsxs)("span",{style:{display:"flex",alignItems:"center",gap:4,color:i},children:[(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M1 9 L1 5 Q1 1 5 1 Q9 1 9 5 L9 9"}),(0,n.jsx)("line",{x1:"1",y1:"9",x2:"9",y2:"9"})]}),l]})]})})(),X&&ee&&(0,n.jsx)("div",{style:{position:"fixed",top:ee.top,left:ee.left,width:ee.width,zIndex:500},children:"system"===X&&(0,n.jsx)("div",{style:{background:"var(--bg-panel)",borderBottom:"1px solid var(--border)"},children:H?(0,n.jsx)("div",{style:{maxHeight:"min(600px, 75vh)",overflowY:"auto",padding:"12px 16px",color:"var(--text-muted)",fontSize:12,lineHeight:1.6,whiteSpace:"pre-wrap",fontFamily:"var(--font-mono)"},children:H}):""===H?(0,n.jsx)("div",{style:{padding:"10px 16px",fontSize:12,color:"var(--text-muted)",fontStyle:"italic"},children:"System prompt is empty (tools are disabled)"}):(0,n.jsx)("div",{style:{padding:"10px 16px",fontSize:12,color:"var(--text-muted)",fontStyle:"italic"},children:"Send a message to load the system prompt"})})})]}),(0,n.jsx)("div",{style:{display:"flex",alignItems:"center",flexShrink:0,background:"var(--bg-panel)",borderBottom:"1px solid var(--border)",height:36},children:(0,n.jsx)("div",{style:{flex:1,overflow:"hidden"},children:(0,n.jsx)(e6,{tabs:er,activeTabId:eo??"",onSelectTab:ei,onCloseTab:ew})})}),(0,n.jsx)("div",{style:{flex:1,overflow:"hidden",position:"relative",background:"var(--bg)"},children:ez?.filePath?(0,n.jsx)(e2,{filePath:ez.filePath,cwd:ec??void 0,availableStyles:eR,activeStyleName:eW,showExecutionConfirm:z}):(0,n.jsxs)("div",{style:{height:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",color:"var(--text-muted)",padding:32,textAlign:"center"},children:[(0,n.jsx)("div",{style:{fontSize:48,marginBottom:16},children:"✍️"}),(0,n.jsx)("div",{style:{fontSize:16,fontWeight:600,color:"var(--text)",marginBottom:8},children:"开始您的文学创作之旅"}),(0,n.jsx)("div",{style:{fontSize:13,color:"var(--text-dim)",maxWidth:360,lineHeight:1.6},children:"在左侧“项目目录”中选择故事大纲、章节草稿或人设卡片,即可在此开启沉浸式 Zen 模式协同写作。"})]})})]}),(0,n.jsxs)("div",{className:`right-panel-container${el?" right-panel-open":" right-panel-closed"}`,style:{display:"flex",flexDirection:"column",borderLeft:"1px solid var(--border)",background:"var(--bg)"},children:[(0,n.jsx)("div",{style:{display:"flex",alignItems:"center",flexShrink:0,background:"var(--bg-panel)",borderBottom:"1px solid var(--border)",height:36,padding:"0 12px"},children:(0,n.jsxs)("span",{style:{fontSize:12,fontWeight:600,color:"var(--text)",display:"flex",alignItems:"center",gap:6},children:[(0,n.jsx)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent)",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})}),"写作协同姬 (AI Copilot)"]})}),(0,n.jsx)("div",{style:{flex:1,overflow:"hidden",position:"relative"},children:eT?(0,n.jsx)(eE,{session:l,newSessionCwd:eC,onAgentEnd:ev,onSessionCreated:eb,onSessionForked:em,modelsRefreshKey:m,chatInputRef:D,onBranchDataChange:P,onSystemPromptChange:J,onSessionStatsChange:Y,onContextUsageChange:G,activeGemId:c}):eI?ec?(0,n.jsx)("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--text-muted)",fontSize:13,padding:16,textAlign:"center"},children:"请在左侧侧边栏中选择或新建写作会话以激活 AI 写作姬。"}):(0,n.jsxs)("div",{style:{position:"absolute",top:12,left:12,display:"flex",alignItems:"flex-start",gap:8,userSelect:"none",pointerEvents:"none"},children:[(0,n.jsxs)("svg",{width:"32",height:"32",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",style:{opacity:.7,flexShrink:0},children:[(0,n.jsx)("line",{x1:"20",y1:"12",x2:"4",y2:"12"}),(0,n.jsx)("polyline",{points:"10 6 4 12 10 18"})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{style:{fontSize:14,fontWeight:600,color:"var(--text)",marginBottom:4},children:"创作起航"}),(0,n.jsxs)("div",{style:{fontSize:11,color:"var(--text-muted)",lineHeight:1.6},children:["1. 在左侧选择项目工作区",(0,n.jsx)("br",{}),"2. 点击底部 Models 键配置模型"]})]})]}):null})]})]}),(0,n.jsx)("button",{onClick:()=>v(!0),title:"配置模型",style:{position:"fixed",top:0,right:144,zIndex:300,display:"flex",alignItems:"center",justifyContent:"center",width:36,height:36,padding:0,background:"var(--bg-panel)",border:"none",borderLeft:"1px solid var(--border)",borderBottom:"1px solid var(--border)",color:"var(--text-muted)",cursor:"pointer",transition:"color 0.12s"},onMouseEnter:e=>{e.currentTarget.style.color="var(--text)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-muted)"},children:(0,n.jsxs)("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"}),(0,n.jsx)("rect",{x:"9",y:"9",width:"6",height:"6"}),(0,n.jsx)("line",{x1:"9",y1:"1",x2:"9",y2:"4"}),(0,n.jsx)("line",{x1:"15",y1:"1",x2:"15",y2:"4"}),(0,n.jsx)("line",{x1:"9",y1:"20",x2:"9",y2:"23"}),(0,n.jsx)("line",{x1:"15",y1:"20",x2:"15",y2:"23"}),(0,n.jsx)("line",{x1:"20",y1:"9",x2:"23",y2:"9"}),(0,n.jsx)("line",{x1:"20",y1:"14",x2:"23",y2:"14"}),(0,n.jsx)("line",{x1:"1",y1:"9",x2:"4",y2:"9"}),(0,n.jsx)("line",{x1:"1",y1:"14",x2:"4",y2:"14"})]})}),(0,n.jsx)("button",{onClick:()=>C(!0),title:"全局设置",style:{position:"fixed",top:0,right:108,zIndex:300,display:"flex",alignItems:"center",justifyContent:"center",width:36,height:36,padding:0,background:"var(--bg-panel)",border:"none",borderLeft:"1px solid var(--border)",borderBottom:"1px solid var(--border)",color:"var(--text-muted)",cursor:"pointer",transition:"color 0.12s"},onMouseEnter:e=>{e.currentTarget.style.color="var(--text)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-muted)"},children:(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"3"}),(0,n.jsx)("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"})]})}),(0,n.jsx)("button",{onClick:()=>I(!0),title:"小说创作实战手册",style:{position:"fixed",top:0,right:72,zIndex:300,display:"flex",alignItems:"center",justifyContent:"center",width:36,height:36,padding:0,background:"var(--bg-panel)",border:"none",borderLeft:"1px solid var(--border)",borderBottom:"1px solid var(--border)",color:"var(--text-muted)",cursor:"pointer",transition:"color 0.12s"},onMouseEnter:e=>{e.currentTarget.style.color="var(--text)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-muted)"},children:(0,n.jsxs)("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,n.jsx)("path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"}),(0,n.jsx)("line",{x1:"12",y1:"17",x2:"12.01",y2:"17",strokeWidth:"3"})]})}),(0,n.jsx)("button",{onClick:e=>{let t=e.currentTarget.getBoundingClientRect();r({x:t.left+t.width/2,y:t.top+t.height/2})},title:t?"Switch to light mode":"Switch to dark mode","aria-label":t?"Switch to light mode":"Switch to dark mode","aria-pressed":t,style:{position:"fixed",top:0,right:36,zIndex:300,display:"flex",alignItems:"center",justifyContent:"center",width:36,height:36,padding:0,background:"var(--bg-panel)",border:"none",borderLeft:"1px solid var(--border)",borderBottom:"1px solid var(--border)",color:"var(--text-muted)",cursor:"pointer",transition:"color 0.12s"},onMouseEnter:e=>{e.currentTarget.style.color="var(--text)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-muted)"},children:t?(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"5"}),(0,n.jsx)("line",{x1:"12",y1:"1",x2:"12",y2:"3"}),(0,n.jsx)("line",{x1:"12",y1:"21",x2:"12",y2:"23"}),(0,n.jsx)("line",{x1:"4.22",y1:"4.22",x2:"5.64",y2:"5.64"}),(0,n.jsx)("line",{x1:"18.36",y1:"18.36",x2:"19.78",y2:"19.78"}),(0,n.jsx)("line",{x1:"1",y1:"12",x2:"3",y2:"12"}),(0,n.jsx)("line",{x1:"21",y1:"12",x2:"23",y2:"12"}),(0,n.jsx)("line",{x1:"4.22",y1:"19.78",x2:"5.64",y2:"18.36"}),(0,n.jsx)("line",{x1:"18.36",y1:"5.64",x2:"19.78",y2:"4.22"})]}):(0,n.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("path",{d:"M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"})})}),(0,n.jsx)("button",{onClick:()=>es(e=>!e),title:el?"隐藏写作辅助":"显示写作辅助",style:{position:"fixed",top:0,right:0,zIndex:300,display:"flex",alignItems:"center",justifyContent:"center",width:36,height:36,padding:0,background:"var(--bg-panel)",border:"none",borderLeft:"1px solid var(--border)",borderBottom:"1px solid var(--border)",color:el?"var(--text)":"var(--text-muted)",cursor:"pointer",transition:"color 0.12s"},onMouseEnter:e=>{e.currentTarget.style.color="var(--text)"},onMouseLeave:e=>{e.currentTarget.style.color=el?"var(--text)":"var(--text-muted)"},children:(0,n.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}),b&&(0,n.jsx)(tN,{onClose:()=>{v(!1),j(e=>e+1)}}),k&&(ec??l?.cwd??a)&&(0,n.jsx)(tV,{cwd:ec??l?.cwd??a,onClose:()=>w(!1)}),S&&(0,n.jsx)(tY,{onClose:()=>C(!1)}),T&&(0,n.jsx)(tK,{onClose:()=>I(!1)}),L&&(0,n.jsx)("div",{style:{position:"fixed",inset:0,zIndex:1200,background:"rgba(10, 10, 10, 0.4)",backdropFilter:"blur(8px)",display:"flex",alignItems:"center",justifyContent:"center",animation:"fadeIn 0.2s ease-out"},onClick:L.onCancel,children:(0,n.jsxs)("div",{style:{width:"min(500px, 92%)",background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:"16px",boxShadow:"0 24px 60px rgba(0, 0, 0, 0.3)",display:"flex",flexDirection:"column",overflow:"hidden",fontFamily:"var(--font-serif)"},onClick:e=>e.stopPropagation(),children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"18px 24px",background:"rgba(99, 102, 241, 0.08)",borderBottom:"1px solid var(--border)"},children:[(0,n.jsx)("div",{style:{width:32,height:32,borderRadius:"50%",background:"var(--bg)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:16,border:"1px solid #818cf833",boxShadow:"0 2px 8px rgba(99, 102, 241, 0.15)"},children:"\uD83C\uDFAD"}),(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column"},children:[(0,n.jsx)("span",{style:{fontSize:13,fontWeight:700,color:"var(--text)"},children:"确认更换写作文风"}),(0,n.jsxs)("span",{style:{fontSize:11,color:"var(--text-dim)",marginTop:2},children:["将风格切换至:",L.targetStyle]})]})]}),(0,n.jsxs)("div",{style:{padding:"24px",display:"flex",flexDirection:"column",gap:16},children:[(0,n.jsxs)("div",{style:{fontSize:13,color:"var(--text)",lineHeight:"1.6"},children:["您正在准备将当前书籍的写作风格切换为 ",(0,n.jsxs)("strong",{style:{color:"#818cf8"},children:["「",L.targetStyle,"」"]}),"。"]}),(0,n.jsxs)("div",{style:{background:"var(--bg)",border:"1px solid var(--border)",borderLeft:"4px solid #818cf8",borderRadius:"8px",padding:"14px 18px",fontSize:12,color:"var(--text-muted)",lineHeight:"1.7"},children:[(0,n.jsx)("span",{style:{fontWeight:600,color:"var(--text)",display:"block",marginBottom:6},children:"⚠️ 注意事项:"}),"此操作将使用该文风模板自动覆盖当前书籍的活动文风指南(`story/style_guide.md`)与统计特征库(`style_profile.json`)。历史章节正文不会被修改。"]}),(0,n.jsxs)("div",{style:{background:"var(--bg-hover)",borderRadius:"8px",padding:"12px 16px",fontSize:11,color:"var(--text-muted)",lineHeight:"1.6"},children:[(0,n.jsx)("span",{style:{fontWeight:600,color:"var(--text)",display:"block",marginBottom:4},children:"\uD83D\uDCA1 后续操作指引:"}),"切换成功后,接下来的「智能续写」、「极速草稿」、「文本润色」和「剧情重写」等 AI 生成动作,都将自动采用该风格进行写作。"]})]}),(0,n.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",gap:12,padding:"16px 24px",background:"var(--bg-panel)",borderTop:"1px solid var(--border)"},children:[(0,n.jsx)("button",{onClick:L.onCancel,style:{padding:"7px 16px",fontSize:12,borderRadius:8,border:"1px solid var(--border)",background:"var(--bg)",color:"var(--text-muted)",cursor:"pointer",fontWeight:500,transition:"all 0.2s"},onMouseEnter:e=>{e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color="var(--text)"},onMouseLeave:e=>{e.currentTarget.style.background="var(--bg)",e.currentTarget.style.color="var(--text-muted)"},children:"取消"}),(0,n.jsx)("button",{onClick:L.onConfirm,style:{padding:"7px 20px",fontSize:12,borderRadius:8,border:"none",background:"#818cf8",color:"white",cursor:"pointer",fontWeight:600,boxShadow:"0 4px 12px rgba(99, 102, 241, 0.33)",transition:"all 0.2s"},onMouseEnter:e=>{e.currentTarget.style.opacity="0.9",e.currentTarget.style.transform="translateY(-1px)",e.currentTarget.style.boxShadow="0 6px 16px rgba(99, 102, 241, 0.44)"},onMouseLeave:e=>{e.currentTarget.style.opacity="1",e.currentTarget.style.transform="none",e.currentTarget.style.boxShadow="0 4px 12px rgba(99, 102, 241, 0.33)"},children:"确定更换"})]})]})})]})}},3705:(e,t,r)=>{Promise.resolve().then(r.bind(r,1789))}},e=>{e.O(0,[7547,8441,3794,7358],()=>e(e.s=3705)),_N_E=e.O()}]);
161
+ ${e.message||String(e)}`)}finally{ee(!1)}}};(0,o.useEffect)(()=>{J.current=F},[F]);let tR=(0,o.useCallback)(async t=>{N("saving");try{let r=$(e),n=await fetch(`/api/files/${r}`,{method:"POST",body:t});if(!n.ok)throw Error(`Failed to save file: ${n.statusText}`);N("saved")}catch(e){console.error(e),N("error")}},[e]),tL=(0,o.useCallback)((e,t=!1)=>{let r=$(e);return fetch(`/api/files/${r}?type=read`).then(e=>e.json()).then(e=>e.error?(y(e.error),null):(t?(x(t=>(t&&g(t.content),e)),I(e=>e+1)):x(e),e)).catch(e=>(y(String(e)),null))},[]);if((0,o.useEffect)(()=>{f(!0),y(null),x(null),g(null),m(!1),k("source"),S(!1),I(0),T(!1),P.current&&clearTimeout(P.current),N("saved"),M.current&&(M.current.close(),M.current=null),tL(e).then(e=>{e&&O(e.content)}).finally(()=>f(!1));let t=$(e),r=new EventSource(`/api/files/${t}?type=watch`);M.current=r,r.addEventListener("connected",()=>{T(!0)});let n=null;return r.addEventListener("change",()=>{n&&clearTimeout(n),n=setTimeout(()=>{"saved"===J.current&&tL(e,!0).then(e=>{e&&O(e.content)})},800)}),r.addEventListener("error",()=>{T(!1)}),r.onerror=()=>{T(!1)},()=>{n&&clearTimeout(n),P.current&&clearTimeout(P.current),r.close(),M.current=null}},[e,tL]),h)return(0,n.jsx)("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--text-muted)",fontSize:13},children:"Loading..."});if(b)return(0,n.jsx)("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"#f87171",fontSize:13},children:b});if(!p)return null;let tW="html"===p.language,tE="markdown"===p.language,tM=null!==u&&u!==p.content;return(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"4px 16px",borderBottom:"1px solid var(--border)",fontSize:11,color:"var(--text-dim)",background:"var(--bg)",flexShrink:0},children:[(0,n.jsx)("span",{style:{fontFamily:"var(--font-mono)"},title:e,children:A(e,t)}),null!==th&&ez&&(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,borderLeft:"1px solid var(--border)",paddingLeft:12},children:[(0,n.jsxs)("span",{onClick:eR.length>0?()=>eE(!0):void 0,title:eR.length>0?"点击查看审计详情":void 0,onMouseEnter:e=>{eR.length>0&&(e.currentTarget.style.filter="brightness(1.15)",e.currentTarget.style.transform="scale(1.02)")},onMouseLeave:e=>{eR.length>0&&(e.currentTarget.style.filter="none",e.currentTarget.style.transform="none")},style:{fontSize:"10px",padding:"2px 6px",borderRadius:"4px",fontWeight:600,cursor:eR.length>0?"pointer":"default",transition:"all 0.15s ease",color:"approved"===ez?"#10b981":"ready-for-review"===ez?"#eab308":"audit-failed"===ez?"#ef4444":"rejected"===ez?"#9ca3af":"var(--text-muted)",background:"approved"===ez?"rgba(16,185,129,0.08)":"ready-for-review"===ez?"rgba(234,179,8,0.08)":"audit-failed"===ez?"rgba(239,68,68,0.08)":"rejected"===ez?"rgba(156,163,175,0.08)":"var(--bg-hover)",border:`1px solid ${"approved"===ez?"#10b98125":"ready-for-review"===ez?"#eab30825":"audit-failed"===ez?"#ef444425":"rejected"===ez?"#9ca3af25":"transparent"}`},children:["approved"===ez?"已过审":"ready-for-review"===ez?"待审核":"audit-failed"===ez?"审计失败":"rejected"===ez?"已驳回":ez,eR.length>0&&(0,n.jsx)("span",{style:{marginLeft:4,fontSize:8},children:"\uD83D\uDD0D"})]}),"approved"!==ez&&(0,n.jsxs)("div",{style:{display:"flex",gap:6},children:[(0,n.jsx)("button",{onClick:tm,disabled:eA,style:{padding:"2px 8px",fontSize:10,cursor:eA?"not-allowed":"pointer",background:"rgba(16,185,129,0.08)",color:"#10b981",border:"1px solid rgba(16,185,129,0.25)",borderRadius:5,fontWeight:600,whiteSpace:"nowrap"},title:"批准并提交该章节状态为已过审",children:eA?"处理中...":"✅ 批准章节"}),(0,n.jsx)("button",{onClick:()=>eJ(!0),disabled:eA,style:{padding:"2px 8px",fontSize:10,cursor:eA?"not-allowed":"pointer",background:"rgba(239,68,68,0.08)",color:"#ef4444",border:"1px solid rgba(239,68,68,0.25)",borderRadius:5,fontWeight:600,whiteSpace:"nowrap"},title:"驳回并回滚故事状态到该章之前",children:eA?"处理中...":"❌ 驳回重构"})]})]}),(0,n.jsxs)("span",{title:C?"Live sync active":"Not watching",style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:4,color:C?"#4ade80":"var(--text-dim)"},children:[(0,n.jsx)("span",{style:{width:7,height:7,borderRadius:"50%",background:C?"#4ade80":"var(--border)",display:"inline-block",boxShadow:C?"0 0 4px #4ade80":"none"}}),C?"live":"static"]}),tM&&(0,n.jsxs)("div",{style:{display:"flex",borderRadius:5,overflow:"hidden",border:"1px solid var(--border)"},children:[(0,n.jsx)("button",{onClick:()=>k("source"),style:{padding:"2px 8px",fontSize:11,border:"none",cursor:"pointer",background:"source"===j?"var(--bg-selected)":"var(--bg-hover)",color:"source"===j?"var(--text)":"var(--text-muted)",fontWeight:"source"===j?600:400},children:"Source"}),(0,n.jsxs)("button",{onClick:()=>k("diff"),style:{padding:"2px 8px",fontSize:11,border:"none",borderLeft:"1px solid var(--border)",cursor:"pointer",background:"diff"===j?"var(--bg-selected)":"var(--bg-hover)",color:"diff"===j?"var(--text)":"var(--text-muted)",fontWeight:"diff"===j?600:400},children:["Diff ",z>0&&(0,n.jsxs)("span",{style:{color:"#4ade80",marginLeft:2},children:["+",z]})]})]}),"source"===j&&!v&&(0,n.jsx)("button",{onClick:()=>S(e=>!e),title:w?"Disable word wrap":"Enable word wrap",style:{padding:"2px 8px",fontSize:11,cursor:"pointer",background:w?"var(--bg-selected)":"var(--bg-hover)",color:w?"var(--text)":"var(--text-muted)",border:"1px solid var(--border)",borderRadius:5,fontWeight:w?600:400},children:"wrap"}),tW&&"source"===j&&(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[(0,n.jsxs)("div",{style:{display:"flex",borderRadius:5,overflow:"hidden",border:"1px solid var(--border)"},children:[(0,n.jsx)("button",{onClick:()=>m(!1),style:{padding:"2px 8px",fontSize:11,border:"none",cursor:"pointer",background:v?"var(--bg-hover)":"var(--bg-selected)",color:v?"var(--text-muted)":"var(--text)",fontWeight:v?400:600},children:"Code"}),(0,n.jsx)("button",{onClick:()=>m(!0),style:{padding:"2px 8px",fontSize:11,border:"none",borderLeft:"1px solid var(--border)",cursor:"pointer",background:v?"var(--bg-selected)":"var(--bg-hover)",color:v?"var(--text)":"var(--text-muted)",fontWeight:v?600:400},children:"Preview"})]}),v&&(0,n.jsx)("button",{onClick:()=>E(!0),title:"Open preview in fullscreen modal",style:{padding:"2px 8px",fontSize:11,cursor:"pointer",background:"var(--bg-hover)",color:"var(--text-muted)",border:"1px solid var(--border)",borderRadius:5,fontWeight:400},children:"\uD83D\uDD0D Zoom"})]}),tE&&"source"===j&&(0,n.jsxs)("div",{style:{display:"flex",borderRadius:5,overflow:"hidden",border:"1px solid var(--border)"},children:[(0,n.jsx)("button",{onClick:()=>m(!0),style:{padding:"2px 8px",fontSize:11,border:"none",cursor:"pointer",background:v?"var(--bg-selected)":"var(--bg-hover)",color:v?"var(--text)":"var(--text-muted)",fontWeight:v?600:400},children:"排版预览"}),(0,n.jsx)("button",{onClick:()=>m(!1),style:{padding:"2px 8px",fontSize:11,border:"none",borderLeft:"1px solid var(--border)",cursor:"pointer",background:v?"var(--bg-hover)":"var(--bg-selected)",color:v?"var(--text-muted)":"var(--text)",fontWeight:v?400:600},children:"沉浸创作"})]}),"source"===j&&!v&&(0,n.jsxs)("button",{onClick:()=>{navigator.clipboard.writeText(D).then(()=>{L(!0),setTimeout(()=>L(!1),2e3)})},title:"Copy to clipboard",style:{padding:"2px 8px",fontSize:11,cursor:"pointer",background:R?"rgba(74,222,128,0.15)":"var(--bg-hover)",color:R?"#4ade80":"var(--text-muted)",border:"1px solid var(--border)",borderRadius:5,display:"flex",alignItems:"center",gap:4,transition:"background 0.15s, color 0.15s"},children:[R?(0,n.jsx)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("polyline",{points:"20 6 9 17 4 12"})}):(0,n.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),(0,n.jsx)("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]}),R?"Copied":"Copy"]})]}),(0,n.jsx)("div",{style:{flex:1,overflow:"auto",background:"var(--bg)",display:"flex",flexDirection:"column"},children:"diff"===j&&tM?(0,n.jsx)("div",{style:{flex:1,overflow:"auto"},children:(0,n.jsx)(eU,{oldContent:u,newContent:D,language:p.language})}):tW&&v?(0,n.jsx)("div",{style:{flex:1,overflow:"hidden"},children:(0,n.jsx)("iframe",{srcDoc:D,sandbox:"allow-scripts",style:{width:"100%",height:"100%",border:"none",background:"var(--bg)"},title:"HTML preview"})}):tE&&v?(0,n.jsx)("div",{style:{flex:1,overflow:"auto"},children:(0,n.jsx)("div",{className:"markdown-body markdown-file-preview",style:{padding:"32px 48px",maxWidth:800,margin:"0 auto",fontFamily:"var(--font-serif)"},children:(0,n.jsx)(H.oz,{remarkPlugins:[_.A],children:D})})}):"markdown"===p.language||"text"===p.language?(0,n.jsxs)("div",{style:{flex:1,display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"},children:[(0,n.jsx)("textarea",{value:D,onChange:e=>{var t;O(t=e.target.value),N("dirty"),P.current&&clearTimeout(P.current),P.current=setTimeout(()=>{tR(t)},1500)},placeholder:"在这里开始您的文学创作...",spellCheck:!1,style:{flex:1,width:"100%",padding:"32px 48px",background:"var(--bg)",color:"var(--text)",fontFamily:"var(--font-serif)",fontSize:"16px",lineHeight:"1.8",border:"none",outline:"none",resize:"none",boxSizing:"border-box",overflowY:"auto",caretColor:"var(--accent)"}}),(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"0 16px",height:"35px",boxSizing:"border-box",background:"var(--bg-panel)",borderTop:"1px solid var(--border)",fontSize:"11px",color:"var(--text-muted)",fontFamily:"var(--font-serif)",flexShrink:0},children:[(0,n.jsxs)("div",{children:["字数: ",(0,n.jsxs)("span",{style:{fontWeight:600,color:"var(--text)",marginRight:16},children:[D.length," 字"]}),"行数: ",(0,n.jsxs)("span",{style:{fontWeight:600,color:"var(--text)"},children:[D.split("\n").length," 行"]})]}),t&&(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[i&&(0,n.jsxs)("span",{title:`当前已启用 ${i} 写作风格指南`,style:{padding:"3px 8px",background:"rgba(139, 92, 246, 0.08)",border:"1px solid rgba(139, 92, 246, 0.2)",borderRadius:"12px",fontSize:"10px",color:"#a78bfa",fontFamily:"var(--font-mono)",display:"inline-flex",alignItems:"center",gap:"4px",marginRight:4},children:[(0,n.jsx)("span",{children:"\uD83C\uDFAD"}),(0,n.jsx)("span",{style:{fontWeight:600},children:i})]}),(0,n.jsxs)("div",{style:{position:"relative",display:"inline-flex",alignItems:"stretch"},onMouseLeave:()=>e8(!1),children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",background:"rgba(249, 115, 22, 0.08)",border:"1px solid rgba(249, 115, 22, 0.4)",borderRadius:"6px",transition:"all 0.2s ease",boxShadow:"0 1px 2px rgba(0, 0, 0, 0.05)"},children:[(0,n.jsx)("button",{onClick:"normal"===e2?()=>ty("write-next",()=>tC(!1)):()=>e9(!0),disabled:G||Z||Q||U||Y||"saving"===F,style:{padding:"5px 10px 5px 12px",background:"none",border:"none",borderRadius:"5px 0 0 5px",color:"#ff903f",cursor:"pointer",fontSize:"11px",fontWeight:600,fontFamily:"var(--font-serif)",whiteSpace:"nowrap",outline:"none",display:"flex",alignItems:"center"},onMouseEnter:e=>{e.currentTarget.parentElement.style.background="rgba(249, 115, 22, 0.16)",e.currentTarget.parentElement.style.borderColor="#f97316",e.currentTarget.style.color="#ffaa64"},onMouseLeave:e=>{e.currentTarget.parentElement.style.background="rgba(249, 115, 22, 0.08)",e.currentTarget.parentElement.style.borderColor="rgba(249, 115, 22, 0.4)",e.currentTarget.style.color="#ff903f"},children:G?"normal"===e2?"正在续写...":"正在起草...":"normal"===e2?(0,n.jsxs)("span",{style:{display:"flex",alignItems:"center"},children:[(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{marginRight:5},children:[(0,n.jsx)("path",{d:"M12 20h9"}),(0,n.jsx)("path",{d:"M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z"})]}),"智能续写"]}):(0,n.jsxs)("span",{style:{display:"flex",alignItems:"center"},children:[(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{marginRight:5},children:[(0,n.jsx)("path",{d:"M4.5 16.5c-1.5 1.25-2.5 3.5-2.5 3.5h13.5"}),(0,n.jsx)("path",{d:"M12 2h9v9"}),(0,n.jsx)("path",{d:"M21 2 9 14"})]}),"极速草稿"]})}),(0,n.jsx)("div",{style:{width:"1px",alignSelf:"stretch",background:"rgba(249, 115, 22, 0.3)",margin:"4px 0"}}),(0,n.jsx)("button",{onClick:()=>e8(!e5),disabled:G||Z||Q||U||Y||"saving"===F,style:{padding:"5px 8px",background:"none",border:"none",borderRadius:"0 5px 5px 0",color:"#ff903f",cursor:"pointer",fontSize:"10px",outline:"none",display:"flex",alignItems:"center",justifyContent:"center"},onMouseEnter:e=>{e.currentTarget.parentElement.style.background="rgba(249, 115, 22, 0.16)",e.currentTarget.parentElement.style.borderColor="#f97316",e.currentTarget.style.color="#ffaa64"},onMouseLeave:e=>{e.currentTarget.parentElement.style.background="rgba(249, 115, 22, 0.08)",e.currentTarget.parentElement.style.borderColor="rgba(249, 115, 22, 0.4)",e.currentTarget.style.color="#ff903f"},children:"▾"})]}),e5&&(0,n.jsx)("div",{style:{position:"absolute",bottom:"100%",right:0,paddingBottom:"6px",minWidth:"220px",zIndex:105},children:(0,n.jsxs)("div",{style:{background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:"8px",boxShadow:"0 10px 25px rgba(0, 0, 0, 0.15)",padding:"6px",display:"flex",flexDirection:"column",gap:"2px",animation:"fadeIn 0.15s ease-out"},children:[(0,n.jsx)("div",{style:{fontSize:"9px",color:"var(--text-dim)",padding:"4px 8px 2px",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em"},children:"选择创作模式"}),(0,n.jsxs)("button",{onClick:()=>{e6("normal"),e8(!1)},style:{display:"flex",flexDirection:"column",alignItems:"flex-start",padding:"8px 10px",borderRadius:"6px",border:"none",background:"normal"===e2?"var(--bg-selected)":"transparent",cursor:"pointer",width:"100%",textAlign:"left",fontFamily:"var(--font-serif)",transition:"background 0.2s"},onMouseEnter:e=>{"normal"!==e2&&(e.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:e=>{"normal"!==e2&&(e.currentTarget.style.background="transparent")},children:[(0,n.jsxs)("div",{style:{fontSize:"11px",fontWeight:600,color:"var(--text)",display:"flex",alignItems:"center"},children:[(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{marginRight:5},children:[(0,n.jsx)("path",{d:"M12 20h9"}),(0,n.jsx)("path",{d:"M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z"})]}),"智能续写 (标准模式)"]}),(0,n.jsx)("div",{style:{fontSize:"9px",color:"var(--text-muted)",marginTop:"2px"},children:"包含设定同步、防崩逻辑审计与AI智能局部修正"})]}),(0,n.jsxs)("button",{onClick:()=>{e6("draft"),e8(!1)},style:{display:"flex",flexDirection:"column",alignItems:"flex-start",padding:"8px 10px",borderRadius:"6px",border:"none",background:"draft"===e2?"var(--bg-selected)":"transparent",cursor:"pointer",width:"100%",textAlign:"left",fontFamily:"var(--font-serif)",transition:"background 0.2s"},onMouseEnter:e=>{"draft"!==e2&&(e.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:e=>{"draft"!==e2&&(e.currentTarget.style.background="transparent")},children:[(0,n.jsxs)("div",{style:{fontSize:"11px",fontWeight:600,color:"var(--text)",display:"flex",alignItems:"center"},children:[(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{marginRight:5},children:[(0,n.jsx)("path",{d:"M4.5 16.5c-1.5 1.25-2.5 3.5-2.5 3.5h13.5"}),(0,n.jsx)("path",{d:"M12 2h9v9"}),(0,n.jsx)("path",{d:"M21 2 9 14"})]}),"极速草稿 (快跑模式)"]}),(0,n.jsx)("div",{style:{fontSize:"9px",color:"var(--text-muted)",marginTop:"2px"},children:"直接生成初稿以追求连贯灵感,支持字数控制与创意引导"})]})]})})]}),(0,n.jsx)("button",{onClick:()=>ty("audit",tk),disabled:U||G||Z||Q||Y||"saving"===F,style:{padding:"5px 12px",background:"rgba(59, 130, 246, 0.08)",border:"1px solid rgba(59, 130, 246, 0.4)",borderRadius:"6px",color:"#60a5fa",cursor:"pointer",fontSize:"11px",fontWeight:600,fontFamily:"var(--font-serif)",transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)",boxShadow:"0 1px 2px rgba(0, 0, 0, 0.05)",whiteSpace:"nowrap"},onMouseEnter:e=>{e.currentTarget.style.background="rgba(59, 130, 246, 0.16)",e.currentTarget.style.borderColor="#3b82f6",e.currentTarget.style.color="#93c5fd",e.currentTarget.style.transform="translateY(-1px)",e.currentTarget.style.boxShadow="0 4px 12px rgba(59, 130, 246, 0.2)"},onMouseLeave:e=>{e.currentTarget.style.background="rgba(59, 130, 246, 0.08)",e.currentTarget.style.borderColor="rgba(59, 130, 246, 0.4)",e.currentTarget.style.color="#60a5fa",e.currentTarget.style.transform="none",e.currentTarget.style.boxShadow="0 1px 2px rgba(0, 0, 0, 0.05)"},children:U?"正在审计中...":(0,n.jsxs)("span",{style:{display:"flex",alignItems:"center"},children:[(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{marginRight:5},children:[(0,n.jsx)("circle",{cx:"11",cy:"11",r:"7"}),(0,n.jsx)("path",{d:"m21 21-4.3-4.3"}),(0,n.jsx)("path",{d:"m8 11 2 2 4-4"})]}),"防崩审计"]})}),(0,n.jsx)("button",{onClick:()=>ty("sync",tI),disabled:Q||G||Z||U||Y||"saving"===F,style:{padding:"5px 12px",background:"rgba(16, 185, 129, 0.08)",border:"1px solid rgba(16, 185, 129, 0.4)",borderRadius:"6px",color:"#34d399",cursor:"pointer",fontSize:"11px",fontWeight:600,fontFamily:"var(--font-serif)",transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)",boxShadow:"0 1px 2px rgba(0, 0, 0, 0.05)",whiteSpace:"nowrap"},onMouseEnter:e=>{e.currentTarget.style.background="rgba(16, 185, 129, 0.16)",e.currentTarget.style.borderColor="#10b981",e.currentTarget.style.color="#6ee7b7",e.currentTarget.style.transform="translateY(-1px)",e.currentTarget.style.boxShadow="0 4px 12px rgba(16, 185, 129, 0.2)"},onMouseLeave:e=>{e.currentTarget.style.background="rgba(16, 185, 129, 0.08)",e.currentTarget.style.borderColor="rgba(16, 185, 129, 0.4)",e.currentTarget.style.color="#34d399",e.currentTarget.style.transform="none",e.currentTarget.style.boxShadow="0 1px 2px rgba(0, 0, 0, 0.05)"},children:Q?"正在同步中...":(0,n.jsxs)("span",{style:{display:"flex",alignItems:"center"},children:[(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{marginRight:5},children:[(0,n.jsx)("path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"}),(0,n.jsx)("path",{d:"M16 3h5v5"}),(0,n.jsx)("path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"}),(0,n.jsx)("path",{d:"M8 21H3v-5"})]}),"同步设定"]})}),(0,n.jsx)("button",{onClick:()=>ty("plan",tS),disabled:Y||G||Z||Q||U||"saving"===F,style:{padding:"5px 12px",background:"rgba(168, 85, 247, 0.08)",border:"1px solid rgba(168, 85, 247, 0.4)",borderRadius:"6px",color:"#c084fc",cursor:"pointer",fontSize:"11px",fontWeight:600,fontFamily:"var(--font-serif)",transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)",boxShadow:"0 1px 2px rgba(0, 0, 0, 0.05)",whiteSpace:"nowrap"},onMouseEnter:e=>{e.currentTarget.style.background="rgba(168, 85, 247, 0.16)",e.currentTarget.style.borderColor="#a855f7",e.currentTarget.style.color="#d8b4fe",e.currentTarget.style.transform="translateY(-1px)",e.currentTarget.style.boxShadow="0 4px 12px rgba(168, 85, 247, 0.2)"},onMouseLeave:e=>{e.currentTarget.style.background="rgba(168, 85, 247, 0.08)",e.currentTarget.style.borderColor="rgba(168, 85, 247, 0.4)",e.currentTarget.style.color="#c084fc",e.currentTarget.style.transform="none",e.currentTarget.style.boxShadow="0 1px 2px rgba(0, 0, 0, 0.05)"},children:Y?"正在规划中...":(0,n.jsxs)("span",{style:{display:"flex",alignItems:"center"},children:[(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{marginRight:5},children:[(0,n.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),(0,n.jsx)("path",{d:"M21 9H3M21 15H3M12 3v18"})]}),"规划蓝图"]})}),(a=(s=ti.startsWith("detect-"))?{text:"#a78bfa",textHover:"#c084fc",bg:"rgba(139, 92, 246, 0.08)",bgHover:"rgba(139, 92, 246, 0.16)",border:"rgba(139, 92, 246, 0.4)",borderHover:"#8b5cf6",separator:"rgba(139, 92, 246, 0.3)"}:{text:"#2dd4bf",textHover:"#5eead4",bg:"rgba(20, 184, 166, 0.08)",bgHover:"rgba(20, 184, 166, 0.16)",border:"rgba(20, 184, 166, 0.4)",borderHover:"#14b8a6",separator:"rgba(20, 184, 166, 0.3)"},(0,n.jsxs)("div",{style:{position:"relative",display:"inline-flex",alignItems:"stretch"},onMouseLeave:()=>ta(!1),children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",background:a.bg,border:`1px solid ${a.border}`,borderRadius:"6px",transition:"all 0.2s ease",boxShadow:"0 1px 2px rgba(0, 0, 0, 0.05)"},children:[(0,n.jsx)("button",{onClick:()=>{"detect-llm"===ti?ty("detect-llm",()=>tw("llm")):ty(ti,()=>tz(ti))},disabled:Z||et||G||Q||U||Y||"saving"===F,style:{padding:"5px 10px 5px 12px",background:"none",border:"none",borderRadius:"5px 0 0 5px",color:a.text,cursor:"pointer",fontSize:"11px",fontWeight:600,fontFamily:"var(--font-serif)",whiteSpace:"nowrap",outline:"none",display:"flex",alignItems:"center"},onMouseEnter:e=>{e.currentTarget.parentElement.style.background=a.bgHover,e.currentTarget.parentElement.style.borderColor=a.borderHover,e.currentTarget.style.color=a.textHover},onMouseLeave:e=>{e.currentTarget.parentElement.style.background=a.bg,e.currentTarget.parentElement.style.borderColor=a.border,e.currentTarget.style.color=a.text},children:Z||et?Z?"正在修正...":"正在检测...":(0,n.jsxs)("span",{style:{display:"flex",alignItems:"center"},children:[s?(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{marginRight:5},children:[(0,n.jsx)("circle",{cx:"11",cy:"11",r:"7"}),(0,n.jsx)("path",{d:"m21 21-4.3-4.3"}),(0,n.jsx)("rect",{x:"9",y:"9",width:"4",height:"4",rx:"1"})]}):(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{marginRight:5},children:[(0,n.jsx)("path",{d:"m12 3-1.912 5.813a2 2 0 0 1-1.275 1.275L3 12l5.813 1.912a2 2 0 0 1 1.275 1.275L12 21l1.912-5.813a2 2 0 0 1 1.275-1.275L21 12l-5.813-1.912a2 2 0 0 1-1.275-1.275Z"}),(0,n.jsx)("path",{d:"m5 3 1 2.5L8.5 6 6 7 5 9.5 4 7 1.5 6 4 5Z",opacity:"0.6"})]}),"detect-llm"===ti&&"检测 AI 味","spot-fix"===ti&&"局部定点修复","anti-detect"===ti&&"防检测润色","polish"===ti&&"文本润色","rewrite"===ti&&"智能改写","rework"===ti&&"剧情重写"]})}),(0,n.jsx)("div",{style:{width:"1px",alignSelf:"stretch",background:a.separator,margin:"4px 0"}}),(0,n.jsx)("button",{onClick:()=>ta(!ts),disabled:Z||et||G||Q||U||Y||"saving"===F,style:{padding:"5px 8px",background:"none",border:"none",borderRadius:"0 5px 5px 0",color:a.text,cursor:"pointer",fontSize:"10px",outline:"none",display:"flex",alignItems:"center",justifyContent:"center"},onMouseEnter:e=>{e.currentTarget.parentElement.style.background=a.bgHover,e.currentTarget.parentElement.style.borderColor=a.borderHover,e.currentTarget.style.color=a.textHover},onMouseLeave:e=>{e.currentTarget.parentElement.style.background=a.bg,e.currentTarget.parentElement.style.borderColor=a.border,e.currentTarget.style.color=a.text},children:"▾"})]}),ts&&(0,n.jsx)("div",{style:{position:"absolute",bottom:"100%",right:0,paddingBottom:"6px",minWidth:"220px",zIndex:105},children:(0,n.jsxs)("div",{style:{background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:"8px",boxShadow:"0 10px 25px rgba(0, 0, 0, 0.15)",padding:"6px",display:"flex",flexDirection:"column",gap:"2px",animation:"fadeIn 0.15s ease-out"},children:[(0,n.jsx)("div",{style:{fontSize:"9px",color:"var(--text-dim)",padding:"4px 8px 2px",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em"},children:"选择修正模式"}),[{mode:"detect-llm",label:"检测 AI 味",desc:"大模型智能评估,只分析特征提供诊断报告,不动正文",isDetect:!0},{mode:"spot-fix",label:"局部定点修复",desc:"微调修复叙事前后矛盾与逻辑不一致",isDetect:!1},{mode:"anti-detect",label:"防检测润色",desc:"消除 AI 腔调与高频标记词,使文字表达自然流畅",isDetect:!1},{mode:"polish",label:"文本润色",desc:"雕琢词句提升文学性,保留全部原有情节",isDetect:!1},{mode:"rewrite",label:"智能改写",desc:"重写特定段落,丰富对话、情绪和动作描写",isDetect:!1},{mode:"rework",label:"剧情重写",desc:"根据最新意图和大纲完全重写本章",isDetect:!1}].map(e=>(0,n.jsxs)("button",{onClick:()=>{tl(e.mode),ta(!1)},style:{display:"flex",flexDirection:"column",alignItems:"flex-start",padding:"8px 10px",borderRadius:"6px",border:"none",background:ti===e.mode?"var(--bg-selected)":"transparent",cursor:"pointer",width:"100%",textAlign:"left",fontFamily:"var(--font-serif)",transition:"background 0.2s"},onMouseEnter:t=>{ti!==e.mode&&(t.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:t=>{ti!==e.mode&&(t.currentTarget.style.background="transparent")},children:[(0,n.jsxs)("div",{style:{fontSize:"11px",fontWeight:600,color:"var(--text)",display:"flex",alignItems:"center"},children:[e.isDetect?(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{marginRight:5},children:[(0,n.jsx)("circle",{cx:"11",cy:"11",r:"7"}),(0,n.jsx)("path",{d:"m21 21-4.3-4.3"}),(0,n.jsx)("rect",{x:"9",y:"9",width:"4",height:"4",rx:"1"})]}):(0,n.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{marginRight:5},children:(0,n.jsx)("path",{d:"m12 3-1.912 5.813a2 2 0 0 1-1.275 1.275L3 12l5.813 1.912a2 2 0 0 1 1.275 1.275L12 21l1.912-5.813a2 2 0 0 1 1.275-1.275L21 12l-5.813-1.912a2 2 0 0 1-1.275-1.275Z"})}),e.label]}),(0,n.jsx)("div",{style:{fontSize:"9px",color:"var(--text-muted)",marginTop:"2px"},children:e.desc})]},e.mode))]})})]}))]}),(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[!ej&&(ew||ed||ep||eu||eh||eb||ev||es)&&(0,n.jsxs)("button",{onClick:()=>ek(!0),style:{display:"flex",alignItems:"center",gap:4,padding:"3px 8px",background:"rgba(255, 255, 255, 0.04)",border:"1px solid var(--border)",borderRadius:4,color:"var(--text-muted)",fontSize:10,cursor:"pointer",fontFamily:"var(--font-serif)",transition:"all 0.15s",marginRight:6},onMouseEnter:e=>{e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color="var(--text)"},onMouseLeave:e=>{e.currentTarget.style.background="rgba(255, 255, 255, 0.04)",e.currentTarget.style.color="var(--text-muted)"},children:[(0,n.jsx)("span",{children:ew?"⏳":"\uD83D\uDCCB"}),(0,n.jsx)("span",{children:ew?"查看运行进度":"查看报告"})]}),"saving"===F&&(0,n.jsxs)("span",{style:{display:"flex",alignItems:"center",gap:4,color:"var(--accent)"},children:[(0,n.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",style:{animation:"spin 1s linear infinite"},children:[(0,n.jsx)("line",{x1:"12",y1:"2",x2:"12",y2:"6"}),(0,n.jsx)("line",{x1:"12",y1:"18",x2:"12",y2:"22"}),(0,n.jsx)("line",{x1:"4.93",y1:"4.93",x2:"7.76",y2:"7.76"}),(0,n.jsx)("line",{x1:"16.24",y1:"16.24",x2:"19.07",y2:"19.07"})]}),"自动保存中..."]}),"saved"===F&&(0,n.jsxs)("span",{style:{color:"#22c55e",display:"flex",alignItems:"center",gap:4},children:[(0,n.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3.5",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("polyline",{points:"20 6 9 17 4 12"})}),"已自动保存"]}),"dirty"===F&&(0,n.jsx)("span",{style:{color:"var(--text-dim)"},children:"编辑中..."}),"error"===F&&(0,n.jsx)("span",{style:{color:"#ef4444"},children:"⚠️ 自动保存失败"})]})]})]}):(0,n.jsx)("div",{style:{flex:1,overflow:"auto"},children:(0,n.jsx)(eM.A,{language:"text"===p.language?"plaintext":p.language,style:c?eD.xJ:eD.vs,showLineNumbers:!0,lineNumberStyle:{color:"var(--text-dim)",fontStyle:"normal",minWidth:"3em",paddingRight:"1em"},customStyle:{margin:0,padding:"12px 0",background:"var(--bg)",fontSize:13,lineHeight:1.6,fontFamily:"var(--font-mono)",minHeight:"100%"},codeTagProps:{style:{fontFamily:"var(--font-mono)"}},wrapLongLines:w,children:D})})}),W&&(0,n.jsxs)("div",{style:{position:"fixed",inset:0,zIndex:1e3,background:"rgba(10, 10, 10, 0.95)",backdropFilter:"blur(8px)",display:"flex",flexDirection:"column",padding:"20px 24px",color:"white"},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:16,flexShrink:0},children:[(0,n.jsx)("span",{style:{fontSize:13,color:"#ccc",fontWeight:500},children:"HTML Fullscreen Preview"}),(0,n.jsx)("button",{onClick:()=>E(!1),style:{padding:"6px 16px",fontSize:12,borderRadius:4,border:"none",background:"#ef4444",color:"white",cursor:"pointer",fontWeight:600},children:"✕ Close"})]}),(0,n.jsx)("div",{style:{flex:1,background:"white",borderRadius:8,overflow:"hidden",boxShadow:"0 10px 30px rgba(0,0,0,0.5)"},children:(0,n.jsx)("iframe",{srcDoc:p.content,sandbox:"allow-scripts",style:{width:"100%",height:"100%",border:"none"},title:"HTML fullscreen preview"})})]}),ej&&(0,n.jsx)("div",{style:{position:"fixed",inset:0,zIndex:1e3,background:"rgba(10, 10, 10, 0.4)",backdropFilter:"blur(4px)",display:"flex",justifyContent:"flex-end",color:"var(--text)"},children:(0,n.jsxs)("div",{style:{width:"min(600px, 90%)",height:"100%",background:"var(--bg)",boxShadow:"-10px 0 30px rgba(0,0,0,0.15)",display:"flex",flexDirection:"column",borderLeft:"1px solid var(--border)",fontFamily:"var(--font-serif)"},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 24px",borderBottom:"1px solid var(--border)",background:"var(--bg-panel)",flexShrink:0},children:[(0,n.jsx)("span",{style:{fontSize:13,fontWeight:600},children:ei}),(0,n.jsx)("button",{onClick:()=>{ew||ek(!1)},disabled:ew,style:{padding:"4px 12px",fontSize:11,borderRadius:4,border:"1px solid var(--border)",background:ew?"var(--bg)":"var(--bg-hover)",color:ew?"var(--text-dim)":"var(--text-muted)",cursor:ew?"not-allowed":"pointer",opacity:ew?.6:1,fontWeight:600,fontFamily:"var(--font-serif)"},children:ew?"执行中...":"✕ 关闭"})]}),(0,n.jsx)("div",{style:{flex:1,padding:"24px 32px",overflowY:"auto",lineHeight:"1.8",fontSize:"14px",display:"flex",flexDirection:"column"},className:"markdown-body markdown-file-preview",children:G||U||Y||Z||Q||et?(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",flex:1,minHeight:0},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:16,flexShrink:0},children:[(0,n.jsx)("div",{style:{width:"16px",height:"16px",border:"2px solid var(--border)",borderTopColor:"var(--accent)",borderRadius:"50%",animation:"spin 1s linear infinite",flexShrink:0}}),(0,n.jsx)("span",{style:{fontSize:13,fontWeight:500,color:"var(--text-muted)"},children:"正在执行指令,实时进度如下:"})]}),(0,n.jsx)("div",{ref:eT,style:{flex:1,background:"#121214",border:"1px solid var(--border)",borderRadius:"6px",padding:"12px",overflowY:"auto",fontFamily:"var(--font-mono), monospace",fontSize:"11px",lineHeight:"1.5",color:"#e4e4e7",whiteSpace:"pre-wrap",wordBreak:"break-all"},children:0===eS.length?(0,n.jsx)("span",{style:{color:"var(--text-dim)"},children:"正在准备执行环境..."}):eS.map((e,t)=>(0,n.jsx)("div",{style:{marginBottom:2},children:e},t))})]}):(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",flex:1,minHeight:0},children:[(0,n.jsx)("div",{style:{flex:1,overflowY:"auto"},children:ep?(0,n.jsx)(eq,{data:ep}):ed?(0,n.jsx)(eZ,{data:ed}):eu?(0,n.jsx)(eX,{data:eu}):eh?(0,n.jsx)(eQ,{data:eh}):eb?(0,n.jsx)(e0,{data:eb}):ev?(0,n.jsx)(e1,{data:ev}):(0,n.jsx)(H.oz,{remarkPlugins:[_.A],children:es})}),eS.length>0&&(0,n.jsx)("div",{style:{marginTop:20,borderTop:"1px solid var(--border)",paddingTop:12,flexShrink:0},children:(0,n.jsxs)("details",{style:{cursor:"pointer",fontSize:12,color:"var(--text-muted)"},children:[(0,n.jsx)("summary",{style:{fontWeight:600,marginBottom:8,userSelect:"none"},children:"查看控制台运行日志"}),(0,n.jsx)("div",{style:{background:"#121214",border:"1px solid var(--border)",borderRadius:"6px",padding:"12px",maxHeight:"180px",overflowY:"auto",fontFamily:"var(--font-mono), monospace",fontSize:"11px",lineHeight:"1.5",color:"#e4e4e7",whiteSpace:"pre-wrap",wordBreak:"break-all",textAlign:"left"},children:eS.map((e,t)=>(0,n.jsx)("div",{style:{marginBottom:2},children:e},t))})]})})]})})]})}),eH&&(0,n.jsx)("div",{style:{position:"fixed",inset:0,zIndex:1100,background:"rgba(15, 10, 10, 0.4)",backdropFilter:"blur(6px)",display:"flex",alignItems:"center",justifyContent:"center",animation:"fadeIn 0.2s ease-out"},children:(0,n.jsxs)("div",{style:{width:"min(480px, 90%)",background:"var(--bg-panel)",border:"1px solid rgba(239, 68, 68, 0.2)",borderRadius:"12px",boxShadow:"0 20px 40px rgba(0, 0, 0, 0.3)",display:"flex",flexDirection:"column",overflow:"hidden",fontFamily:"var(--font-serif)"},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"16px 20px",background:"rgba(239, 68, 68, 0.08)",borderBottom:"1px solid rgba(239, 68, 68, 0.15)",color:"#ef4444",fontWeight:600,fontSize:14},children:[(0,n.jsx)("span",{style:{fontSize:16},children:"⚠️"}),(0,n.jsx)("span",{children:"确认驳回并重构章节"})]}),(0,n.jsxs)("div",{style:{padding:"20px",display:"flex",flexDirection:"column",gap:16},children:[(0,n.jsxs)("div",{style:{background:"rgba(239, 68, 68, 0.04)",border:"1px solid rgba(239, 68, 68, 0.1)",borderRadius:"8px",padding:"12px 14px",fontSize:12,color:"var(--text)",lineHeight:"1.6"},children:[(0,n.jsx)("span",{style:{color:"#ef4444",fontWeight:600,display:"block",marginBottom:4},children:"⚠️ 毁灭性操作警告:"}),"驳回该章节将",(0,n.jsx)("strong",{children:"删除此章节及所有后续章节"}),",并将书籍与AI系统的状态数据库回滚到前一章节(第 ",th?th-1:0," 章)。此操作会丢弃当前章节的所有生成数据与文件,",(0,n.jsx)("strong",{children:"且无法撤销!"})]}),(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[(0,n.jsx)("span",{style:{fontSize:12,color:"var(--text-muted)",fontWeight:500},children:"请输入驳回重构的具体原因(可选,将作为重构的指导上下文):"}),(0,n.jsx)("textarea",{value:eV,onChange:e=>eY(e.target.value),placeholder:"例如:剧情节奏太慢,角色性格偏离设定,或者需要重新规划意图...",disabled:eA,style:{width:"100%",height:"90px",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:"6px",padding:"8px 12px",fontSize:12,color:"var(--text)",fontFamily:"var(--font-serif)",resize:"none",outline:"none"}})]}),eN&&(0,n.jsx)("div",{style:{color:"#ef4444",fontSize:12,background:"rgba(239, 68, 68, 0.05)",border:"1px solid rgba(239, 68, 68, 0.15)",borderRadius:"6px",padding:"8px 12px"},children:eN}),eA&&e$.length>0&&(0,n.jsx)("div",{style:{background:"#121214",border:"1px solid var(--border)",borderRadius:"6px",padding:"8px",maxHeight:"100px",overflowY:"auto",fontFamily:"var(--font-mono), monospace",fontSize:"10px",color:"#e4e4e7",whiteSpace:"pre-wrap",wordBreak:"break-all"},children:e$.map((e,t)=>(0,n.jsx)("div",{style:{marginBottom:2},children:e},t))})]}),(0,n.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",gap:10,padding:"12px 20px",background:"var(--bg-panel)",borderTop:"1px solid var(--border)"},children:[(0,n.jsx)("button",{onClick:()=>{eJ(!1),eY("")},disabled:eA,style:{padding:"6px 14px",fontSize:12,borderRadius:6,border:"1px solid var(--border)",background:"var(--bg)",color:"var(--text-muted)",cursor:eA?"not-allowed":"pointer",fontWeight:500},children:"取消"}),(0,n.jsx)("button",{onClick:tj,disabled:eA,style:{padding:"6px 14px",fontSize:12,borderRadius:6,border:"none",background:eA?"rgba(239, 68, 68, 0.5)":"#ef4444",color:"white",cursor:eA?"not-allowed":"pointer",fontWeight:600,display:"flex",alignItems:"center",gap:6},children:eA?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{style:{width:"12px",height:"12px",border:"2px solid rgba(255, 255, 255, 0.3)",borderTopColor:"white",borderRadius:"50%",animation:"spin 1s linear infinite"}}),"正在回滚..."]}):"确认驳回并重构"})]})]})}),e3&&(0,n.jsx)("div",{style:{position:"fixed",inset:0,zIndex:1100,background:"rgba(15, 10, 10, 0.4)",backdropFilter:"blur(6px)",display:"flex",alignItems:"center",justifyContent:"center",animation:"fadeIn 0.2s ease-out"},children:(0,n.jsxs)("div",{style:{width:"min(500px, 92%)",background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:"12px",boxShadow:"0 20px 40px rgba(0, 0, 0, 0.3)",display:"flex",flexDirection:"column",overflow:"hidden",fontFamily:"var(--font-serif)"},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"16px 20px",background:"rgba(249, 115, 22, 0.08)",borderBottom:"1px solid rgba(249, 115, 22, 0.15)",color:"#ff903f",fontWeight:600,fontSize:14},children:[(0,n.jsx)("span",{style:{fontSize:16},children:"\uD83D\uDE80"}),(0,n.jsx)("span",{children:"极速起草模式配置"})]}),(0,n.jsxs)("div",{style:{padding:"20px",display:"flex",flexDirection:"column",gap:16},children:[(0,n.jsxs)("div",{style:{background:"rgba(249, 115, 22, 0.03)",border:"1px solid rgba(249, 115, 22, 0.1)",borderRadius:"8px",padding:"10px 12px",fontSize:11,color:"var(--text-muted)",lineHeight:"1.5"},children:[(0,n.jsx)("span",{style:{color:"#ff903f",fontWeight:600},children:"\uD83D\uDCA1 极速起草说明:"}),"此模式下,AI 将绕过复杂的设定同步、审计和 spot-fix 局部修正,直接根据大纲和以下创意引导快速生成首稿。这对于维持高涨的灵感和连贯的写作逻辑非常合适。"]}),(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[(0,n.jsx)("span",{style:{fontSize:12,color:"var(--text-muted)",fontWeight:500},children:"本章创意引导 (可选,指导本章具体剧情走向):"}),(0,n.jsx)("textarea",{value:tt,onChange:e=>tr(e.target.value),placeholder:"例如:主角在林中遭遇黑衣人伏击,一番激战后身负轻伤跳崖。在崖底醒来,发现一个神秘石洞...",style:{width:"100%",height:"110px",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:"6px",padding:"8px 12px",fontSize:12,color:"var(--text)",fontFamily:"var(--font-serif)",resize:"none",outline:"none"}})]}),r.length>0&&(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[(0,n.jsx)("span",{style:{fontSize:12,color:"var(--text-muted)",fontWeight:500},children:"\uD83C\uDFAD 选择写作文风偏好:"}),(0,n.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:r.map(e=>{let t=(tn||"default")===e;return(0,n.jsxs)("button",{type:"button",onClick:()=>to(e),style:{padding:"4px 10px",fontSize:"11px",borderRadius:"16px",border:`1px solid ${t?"#ff903f":"var(--border)"}`,background:t?"rgba(249, 115, 22, 0.08)":"var(--bg)",color:t?"#ff903f":"var(--text)",cursor:"pointer",fontWeight:t?600:500,transition:"all 0.15s",display:"flex",alignItems:"center",gap:3},children:[(0,n.jsx)("span",{children:"\uD83C\uDFAD"}),(0,n.jsx)("span",{children:e})]},e)})})]}),(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[(0,n.jsx)("span",{style:{fontSize:12,color:"var(--text-muted)",fontWeight:500},children:"期望本章字数:"}),(0,n.jsx)("div",{style:{display:"flex",gap:8},children:[1e3,2e3,3e3,5e3].map(e=>(0,n.jsxs)("button",{type:"button",onClick:()=>te(e),style:{flex:1,padding:"5px 0",fontSize:"11px",borderRadius:"4px",border:`1px solid ${e7===e?"#ff903f":"var(--border)"}`,background:e7===e?"rgba(249, 115, 22, 0.08)":"var(--bg)",color:e7===e?"#ff903f":"var(--text)",cursor:"pointer",fontWeight:e7===e?600:500,transition:"all 0.2s"},children:[e,"字"]},e))}),(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:12,marginTop:4},children:[(0,n.jsx)("input",{type:"range",min:"500",max:"10000",step:"100",value:e7,onChange:e=>te(parseInt(e.target.value,10)),style:{flex:1,accentColor:"#ff903f",cursor:"pointer"}}),(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:4},children:[(0,n.jsx)("input",{type:"number",min:"500",max:"20000",value:e7,onChange:e=>{let t=parseInt(e.target.value,10);isNaN(t)||te(t)},style:{width:"70px",textAlign:"center",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:"6px",padding:"4px 6px",fontSize:"11px",color:"var(--text)",fontFamily:"var(--font-serif)",outline:"none"}}),(0,n.jsx)("span",{style:{fontSize:"11px",color:"var(--text-muted)"},children:"字"})]})]})]})]}),(0,n.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",gap:10,padding:"12px 20px",background:"var(--bg-panel)",borderTop:"1px solid var(--border)"},children:[(0,n.jsx)("button",{onClick:()=>{e9(!1)},style:{padding:"6px 14px",fontSize:12,borderRadius:6,border:"1px solid var(--border)",background:"var(--bg)",color:"var(--text-muted)",cursor:"pointer",fontWeight:500},children:"取消"}),(0,n.jsx)("button",{onClick:()=>ty("draft",()=>tT(!1)),style:{padding:"6px 14px",fontSize:12,borderRadius:6,border:"none",background:"#ff903f",color:"white",cursor:"pointer",fontWeight:600,display:"flex",alignItems:"center",gap:6},children:"开始起草"})]})]})}),eW&&(0,n.jsx)("div",{style:{position:"fixed",inset:0,zIndex:1100,background:"rgba(15, 10, 10, 0.4)",backdropFilter:"blur(6px)",display:"flex",alignItems:"center",justifyContent:"center",animation:"fadeIn 0.2s ease-out"},children:(0,n.jsxs)("div",{style:{width:"min(600px, 92%)",background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:"12px",boxShadow:"0 20px 40px rgba(0, 0, 0, 0.3)",display:"flex",flexDirection:"column",overflow:"hidden",fontFamily:"var(--font-serif)"},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 20px",background:"rgba(59, 130, 246, 0.08)",borderBottom:"1px solid rgba(59, 130, 246, 0.15)",color:"var(--text)",fontWeight:600,fontSize:14},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[(0,n.jsx)("span",{style:{fontSize:16},children:"\uD83D\uDEE1️"}),(0,n.jsxs)("span",{children:["离线审计报告 - 第 ",th," 章"]})]}),(0,n.jsx)("button",{onClick:()=>eE(!1),style:{background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",fontSize:18,padding:4,display:"flex",alignItems:"center",justifyContent:"center",transition:"color 0.2s"},onMouseEnter:e=>e.currentTarget.style.color="var(--text)",onMouseLeave:e=>e.currentTarget.style.color="var(--text-muted)",children:"✕"})]}),(0,n.jsx)("div",{style:{padding:"20px",display:"flex",flexDirection:"column",gap:12,maxHeight:"60vh",overflowY:"auto"},children:0===eR.length?(0,n.jsx)("div",{style:{padding:"20px 0",textAlign:"center",color:"var(--text-dim)",fontSize:12},children:"没有检测到任何审计问题。"}):eR.map((e,t)=>{let r=e.match(/^\[(critical|warning|info)\]\s*(.*)$/i),o=r?r[1].toLowerCase():"info",i=r?r[2]:e,l={critical:{label:"严重错误",color:"#ef4444",bg:"rgba(239, 68, 68, 0.04)",border:"rgba(239, 68, 68, 0.15)",badgeBg:"rgba(239, 68, 68, 0.12)"},warning:{label:"潜在风险",color:"#eab308",bg:"rgba(234, 179, 8, 0.04)",border:"rgba(234, 179, 8, 0.15)",badgeBg:"rgba(234, 179, 8, 0.12)"},info:{label:"风格建议",color:"#3b82f6",bg:"rgba(59, 130, 246, 0.04)",border:"rgba(59, 130, 246, 0.15)",badgeBg:"rgba(59, 130, 246, 0.12)"}}[o];return(0,n.jsxs)("div",{style:{background:l.bg,border:`1px solid ${l.border}`,borderLeft:`4px solid ${l.color}`,borderRadius:"8px",padding:"12px 14px",display:"flex",flexDirection:"column",gap:6},children:[(0,n.jsx)("div",{style:{display:"flex",alignItems:"center",gap:8},children:(0,n.jsx)("span",{style:{fontSize:"10px",fontWeight:600,color:l.color,background:l.badgeBg,padding:"2px 6px",borderRadius:"4px",textTransform:"uppercase"},children:l.label})}),(0,n.jsx)("div",{style:{fontSize:12,color:"var(--text)",lineHeight:1.6,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:i}),(0,n.jsxs)("div",{style:{marginTop:4,paddingTop:6,borderTop:"1px dashed var(--border)",display:"flex",alignItems:"center",gap:6,fontSize:11,color:"var(--text-muted)"},children:[(0,n.jsx)("span",{style:{color:"var(--text-dim)"},children:"建议使用修复功能:"}),(0,n.jsx)("span",{style:{color:"critical"===o||"warning"===o?"#2dd4bf":"#3b82f6",fontWeight:500},children:"critical"===o||"warning"===o?"\uD83E\uDE84 局部定点修复":i.toLowerCase().includes("ai")||i.includes("检测到")||i.includes("句式")?"\uD83E\uDE84 防检测润色 / 文本润色":"\uD83E\uDE84 文本润色"})]})]},t)})}),(0,n.jsx)("div",{style:{display:"flex",justifyContent:"flex-end",padding:"12px 20px",background:"var(--bg-panel)",borderTop:"1px solid var(--border)"},children:(0,n.jsx)("button",{onClick:()=>eE(!1),style:{padding:"6px 20px",fontSize:12,borderRadius:6,border:"1px solid var(--border)",background:"var(--bg)",color:"var(--text-muted)",cursor:"pointer",fontWeight:500,transition:"all 0.2s"},onMouseEnter:e=>{e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color="var(--text)"},onMouseLeave:e=>{e.currentTarget.style.background="var(--bg)",e.currentTarget.style.color="var(--text-muted)"},children:"关闭"})})]})}),eK&&(0,n.jsx)("div",{style:{position:"fixed",inset:0,zIndex:1100,background:"rgba(15, 10, 10, 0.4)",backdropFilter:"blur(6px)",display:"flex",alignItems:"center",justifyContent:"center",animation:"fadeIn 0.2s ease-out"},children:(0,n.jsxs)("div",{style:{width:"min(480px, 90%)",background:"var(--bg-panel)",border:"1px solid rgba(239, 68, 68, 0.2)",borderRadius:"12px",boxShadow:"0 20px 40px rgba(0, 0, 0, 0.3)",display:"flex",flexDirection:"column",overflow:"hidden",fontFamily:"var(--font-serif)"},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"16px 20px",background:"rgba(239, 68, 68, 0.08)",borderBottom:"1px solid rgba(239, 68, 68, 0.15)",color:"#ef4444",fontWeight:600,fontSize:14},children:[(0,n.jsx)("span",{style:{fontSize:16},children:"⚠️"}),(0,n.jsx)("span",{children:eK.title})]}),(0,n.jsx)("div",{style:{padding:"20px",display:"flex",flexDirection:"column",gap:16},children:(0,n.jsxs)("div",{style:{background:"rgba(239, 68, 68, 0.04)",border:"1px solid rgba(239, 68, 68, 0.1)",borderRadius:"8px",padding:"12px 14px",fontSize:12,color:"var(--text)",lineHeight:"1.6",whiteSpace:"pre-wrap"},children:[(0,n.jsxs)("span",{style:{color:"#ef4444",fontWeight:600,display:"block",marginBottom:4},children:["⚠️ ",eK.warning||"操作警告:"]}),eK.message]})}),(0,n.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",gap:10,padding:"12px 20px",background:"var(--bg-panel)",borderTop:"1px solid var(--border)"},children:[(0,n.jsx)("button",{onClick:()=>eG(null),style:{padding:"6px 14px",fontSize:12,borderRadius:6,border:"1px solid var(--border)",background:"var(--bg)",color:"var(--text-muted)",cursor:"pointer",fontWeight:500},children:"取消"}),(0,n.jsx)("button",{onClick:()=>{let e=eK.onConfirm;eG(null),e()},style:{padding:"6px 16px",fontSize:12,borderRadius:6,border:"none",background:"#ef4444",color:"white",cursor:"pointer",fontWeight:600,transition:"background-color 0.2s"},onMouseEnter:e=>{e.currentTarget.style.background="#dc2626"},onMouseLeave:e=>{e.currentTarget.style.background="#ef4444"},children:"确认操作"})]})]})}),tp&&(d=tb(tp.actionType),(0,n.jsx)("div",{style:{position:"fixed",inset:0,zIndex:1200,background:"rgba(10, 10, 10, 0.4)",backdropFilter:"blur(8px)",display:"flex",alignItems:"center",justifyContent:"center",animation:"fadeIn 0.2s ease-out"},onClick:()=>tx(null),children:(0,n.jsxs)("div",{style:{width:"min(500px, 92%)",background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:"16px",boxShadow:"0 24px 60px rgba(0, 0, 0, 0.3)",display:"flex",flexDirection:"column",overflow:"hidden",fontFamily:"var(--font-serif)"},onClick:e=>e.stopPropagation(),children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"18px 24px",background:d.bgTheme,borderBottom:"1px solid var(--border)"},children:[(0,n.jsx)("div",{style:{width:32,height:32,borderRadius:"50%",background:"var(--bg)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:16,border:`1px solid ${d.themeColor}33`,boxShadow:`0 2px 8px ${d.themeColor}15`},children:d.icon}),(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column"},children:[(0,n.jsx)("span",{style:{fontSize:13,fontWeight:700,color:"var(--text)"},children:"确认执行此操作"}),(0,n.jsx)("span",{style:{fontSize:11,color:"var(--text-dim)",marginTop:2},children:d.title})]})]}),(0,n.jsxs)("div",{style:{padding:"24px",display:"flex",flexDirection:"column",gap:16},children:[(0,n.jsxs)("div",{style:{fontSize:13,color:"var(--text)",lineHeight:"1.6"},children:["您已点击运行 ",(0,n.jsxs)("strong",{style:{color:d.themeColor},children:["「",d.title,"」"]}),"。"]}),(0,n.jsxs)("div",{style:{background:"var(--bg)",border:"1px solid var(--border)",borderLeft:`4px solid ${d.themeColor}`,borderRadius:"8px",padding:"14px 18px",fontSize:12,color:"var(--text-muted)",lineHeight:"1.7"},children:[(0,n.jsx)("span",{style:{fontWeight:600,color:"var(--text)",display:"block",marginBottom:6},children:"功能说明:"}),d.desc]}),(0,n.jsx)("div",{style:{fontSize:11,color:"var(--text-dim)"},children:"\uD83D\uDCA1 提示:您可以在顶部的“系统全局设置” ⚙️ 中关闭此确认弹窗。"})]}),(0,n.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",gap:12,padding:"16px 24px",background:"var(--bg-panel)",borderTop:"1px solid var(--border)"},children:[(0,n.jsx)("button",{onClick:()=>tx(null),style:{padding:"7px 16px",fontSize:12,borderRadius:8,border:"1px solid var(--border)",background:"var(--bg)",color:"var(--text-muted)",cursor:"pointer",fontWeight:500,transition:"all 0.2s"},onMouseEnter:e=>{e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color="var(--text)"},onMouseLeave:e=>{e.currentTarget.style.background="var(--bg)",e.currentTarget.style.color="var(--text-muted)"},children:"取消"}),(0,n.jsx)("button",{onClick:()=>{let e=tp.onConfirm;tx(null),e()},style:{padding:"7px 20px",fontSize:12,borderRadius:8,border:"none",background:d.themeColor,color:"white",cursor:"pointer",fontWeight:600,boxShadow:`0 4px 12px ${d.themeColor}33`,transition:"all 0.2s"},onMouseEnter:e=>{e.currentTarget.style.opacity="0.9",e.currentTarget.style.transform="translateY(-1px)",e.currentTarget.style.boxShadow=`0 6px 16px ${d.themeColor}44`},onMouseLeave:e=>{e.currentTarget.style.opacity="1",e.currentTarget.style.transform="none",e.currentTarget.style.boxShadow=`0 4px 12px ${d.themeColor}33`},children:"确定执行"})]})]})}))]})}function e6({tabs:e,activeTabId:t,onSelectTab:r,onCloseTab:i}){let[l,s]=(0,o.useState)(null);return(0,n.jsx)("div",{style:{display:"flex",alignItems:"flex-end",background:"var(--bg-panel)",overflowX:"auto",flexShrink:0,height:36},children:e.map(e=>{let o=e.id===t;return(0,n.jsxs)("div",{onClick:()=>r(e.id),style:{display:"flex",alignItems:"center",gap:6,height:36,paddingLeft:12,paddingRight:6,borderRight:"1px solid var(--border)",background:o?"var(--bg)":"var(--bg-panel)",cursor:"pointer",fontSize:12,color:o?"var(--text)":"var(--text-muted)",whiteSpace:"nowrap",maxWidth:180,minWidth:80,flexShrink:0,userSelect:"none",transition:"background 0.1s, color 0.1s"},children:[(0,n.jsx)("span",{style:{flexShrink:0,opacity:o?1:.7,display:"flex",alignItems:"center"},children:M(e.label,13)}),(0,n.jsx)("span",{style:{overflow:"hidden",textOverflow:"ellipsis",flex:1,fontWeight:o?500:400},title:e.filePath,children:e.label}),(0,n.jsx)("button",{onClick:t=>{t.stopPropagation(),i(e.id)},onMouseEnter:()=>s(e.id),onMouseLeave:()=>s(null),style:{display:"flex",alignItems:"center",justifyContent:"center",width:16,height:16,background:l===e.id?"var(--bg-hover)":"transparent",border:"none",borderRadius:3,color:l===e.id?"var(--text)":"var(--text-dim)",cursor:"pointer",padding:0,flexShrink:0,transition:"background 0.1s, color 0.1s"},title:"Close",children:(0,n.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:[(0,n.jsx)("line",{x1:"2",y1:"2",x2:"8",y2:"8"}),(0,n.jsx)("line",{x1:"8",y1:"2",x2:"2",y2:"8"})]})})]},e.id)})})}var e5=r(7381),e8=r(4433),e3=r(350),e9=r(8195),e7=r(9312),te=r(7275),tt=r(2008),tr=r(5476),tn=r(7410),to=r(4489),ti=r(8728),tl=r(9872),ts=r(7751),ta=r(2526),td=r(8238),tc=r(7794),tp=r(1098),tx=r(4604),tu=r(5315),tg=r(4278),th=r(5457),tf=r(1437),tb=r(9167),ty=r(7283),tv=r(4166);let tm={anthropic:{Icon:e5.A,hasColor:!1},openai:{Icon:e8.A,hasColor:!1},"openai-codex":{Icon:e8.A,hasColor:!1},google:{Icon:e3.A,hasColor:!0},"google-vertex":{Icon:e3.A,hasColor:!0},deepseek:{Icon:e9.A,hasColor:!0},groq:{Icon:e7.A,hasColor:!1},mistral:{Icon:te.A,hasColor:!0},moonshotai:{Icon:tt.A,hasColor:!1},"moonshotai-cn":{Icon:tt.A,hasColor:!1},moonshot:{Icon:tt.A,hasColor:!1},minimax:{Icon:tr.A,hasColor:!0},"minimax-cn":{Icon:tr.A,hasColor:!0},fireworks:{Icon:tn.A,hasColor:!0},huggingface:{Icon:to.A,hasColor:!0},cerebras:{Icon:ti.A,hasColor:!0},openrouter:{Icon:tl.A,hasColor:!1},xai:{Icon:ts.A,hasColor:!1},"cloudflare-ai-gateway":{Icon:ta.A,hasColor:!0},"cloudflare-workers-ai":{Icon:ta.A,hasColor:!0},"vercel-ai-gateway":{Icon:td.A,hasColor:!1},"github-copilot":{Icon:tc.A,hasColor:!1},"amazon-bedrock":{Icon:tp.A,hasColor:!0},"azure-openai-responses":{Icon:tx.A,hasColor:!0},"kimi-coding":{Icon:tu.A,hasColor:!0},qwen:{Icon:tg.A,hasColor:!0},zai:{Icon:th.A,hasColor:!0},cohere:{Icon:tf.A,hasColor:!0},perplexity:{Icon:tb.A,hasColor:!0},together:{Icon:ty.A,hasColor:!0},grok:{Icon:tv.A,hasColor:!1}},tj=["openai-completions","openai-responses","anthropic-messages","google-generative-ai"];function tk({label:e,children:t}){return(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[(0,n.jsx)("label",{style:{fontSize:11,color:"var(--text-muted)",fontWeight:500},children:e}),t]})}let tw={padding:"6px 9px",background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:5,color:"var(--text)",fontSize:12,outline:"none",width:"100%",boxSizing:"border-box"};function tS({value:e,onChange:t,placeholder:r,mono:o}){return(0,n.jsx)("input",{value:e,onChange:e=>t(e.target.value),placeholder:r,style:{...tw,fontFamily:o?"var(--font-mono)":"inherit"}})}function tC({value:e,onChange:t,placeholder:r,mono:i,onKeyDown:l,autoComplete:s="off",spellCheck:a=!1,style:d}){let[c,p]=(0,o.useState)(!1);return(0,o.useEffect)(()=>{e||p(!1)},[e]),(0,n.jsxs)("div",{style:{position:"relative",width:"100%",...d},children:[(0,n.jsx)("input",{type:c?"text":"password",value:e,onChange:e=>t(e.target.value),onKeyDown:l,placeholder:r,style:{...tw,paddingRight:34,fontFamily:i?"var(--font-mono)":"inherit"},autoComplete:s,spellCheck:a}),(0,n.jsx)("button",{type:"button",onClick:()=>p(e=>!e),"aria-label":c?"Hide API key":"Show API key",title:c?"Hide API key":"Show API key",style:{position:"absolute",right:5,top:"50%",transform:"translateY(-50%)",width:24,height:24,padding:0,border:"none",background:"transparent",color:"var(--text-dim)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},children:c?(0,n.jsxs)("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M17.94 17.94A10.94 10.94 0 0 1 12 20C7 20 2.73 16.89 1 12a18.45 18.45 0 0 1 5.06-6.94"}),(0,n.jsx)("path",{d:"M9.9 4.24A10.94 10.94 0 0 1 12 4c5 0 9.27 3.11 11 8a18.5 18.5 0 0 1-2.16 3.19"}),(0,n.jsx)("path",{d:"M14.12 14.12A3 3 0 0 1 9.88 9.88"}),(0,n.jsx)("path",{d:"M1 1l22 22"})]}):(0,n.jsxs)("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8S1 12 1 12Z"}),(0,n.jsx)("circle",{cx:"12",cy:"12",r:"3"})]})})]})}function tT({value:e,onChange:t,placeholder:r}){return(0,n.jsx)("input",{type:"number",value:e,onChange:e=>t(e.target.value),placeholder:r,style:tw})}function tz({value:e,onChange:t,options:r,required:o}){return(0,n.jsxs)("select",{value:e,onChange:e=>t(e.target.value),style:{...tw,color:e?"var(--text)":"var(--text-dim)"},children:[!o&&(0,n.jsx)("option",{value:"",children:"— inherit / none —"}),r.map(e=>(0,n.jsx)("option",{value:e,children:e},e))]})}function tI({label:e,checked:t,onChange:r}){return(0,n.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:6,cursor:"pointer",fontSize:12,color:"var(--text-muted)"},children:[(0,n.jsx)("input",{type:"checkbox",checked:t,onChange:e=>r(e.target.checked),style:{width:13,height:13,accentColor:"var(--accent)",cursor:"pointer"}}),e]})}function tR({children:e}){return(0,n.jsx)("div",{style:{fontSize:11,fontWeight:600,color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:"0.06em",marginBottom:2},children:e})}function tL({name:e,provider:t,onChange:r,onRename:i,onDelete:l}){let[s,a]=(0,o.useState)(e);(0,o.useEffect)(()=>a(e),[e]);let d=(e,n)=>r({...t,[e]:n});return(0,o.useEffect)(()=>{t.api||r({...t,api:"openai-completions"})},[t.api]),(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[(0,n.jsx)(tR,{children:"Provider"}),(0,n.jsx)("button",{onClick:l,style:{padding:"3px 8px",background:"none",border:"1px solid rgba(239,68,68,0.3)",borderRadius:4,color:"#ef4444",cursor:"pointer",fontSize:11},children:"Delete"})]}),(0,n.jsxs)(tk,{label:"Provider name",children:[(0,n.jsx)(tS,{value:s,onChange:a,placeholder:"provider-name",mono:!0}),s!==e&&s.trim()&&(0,n.jsx)("button",{onClick:()=>i(s.trim()),style:{marginTop:4,padding:"3px 10px",background:"var(--accent)",border:"none",borderRadius:4,color:"#fff",cursor:"pointer",fontSize:11,alignSelf:"flex-start"},children:"Rename"})]}),(0,n.jsx)(tk,{label:"Base URL",children:(0,n.jsx)(tS,{value:t.baseUrl??"",onChange:e=>d("baseUrl",e||void 0),placeholder:"https://api.example.com/v1",mono:!0})}),(0,n.jsxs)(tk,{label:"API Key",children:[(0,n.jsx)(tC,{value:t.apiKey??"",onChange:e=>d("apiKey",e||void 0),placeholder:"ENV_VAR_NAME, !shell-command, or literal key",mono:!0}),(0,n.jsxs)("span",{style:{fontSize:10,color:"var(--text-dim)",marginTop:2},children:["Prefix with ",(0,n.jsx)("code",{style:{fontFamily:"var(--font-mono)"},children:"!"})," to run a shell command, or use an env var name"]})]}),(0,n.jsx)(tk,{label:"API",children:(0,n.jsx)(tz,{value:t.api??"openai-completions",onChange:e=>d("api",e),options:tj,required:!0})})]})}let tW=["off","minimal","low","medium","high","xhigh"],tE={off:"var(--text-dim)",minimal:"#6b7280",low:"#60a5fa",medium:"#a78bfa",high:"#f472b6",xhigh:"#fb923c"};function tM({value:e,onChange:t}){let r=e??{},o=(e,n)=>{let o={...r};"omit"===n?delete o[e]:o[e]=n,t(Object.keys(o).length?o:void 0)};return(0,n.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:2},children:tW.map(e=>{let t=r[e],i=e in r?null===t?"null":"string":"omit",l="string"==typeof t?t:"",s=tE[e],a={padding:"4px 10px",fontSize:10,border:"none",cursor:"pointer",fontWeight:400,transition:"background 0.1s, color 0.1s",whiteSpace:"nowrap",background:"var(--bg-panel)",color:"var(--text-dim)"},d={background:"var(--accent)",color:"#fff",fontWeight:600};return(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"5px 4px",borderRadius:6,background:"transparent",border:"1px solid transparent"},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:5,width:68,flexShrink:0},children:[(0,n.jsx)("span",{style:{width:6,height:6,borderRadius:"50%",background:s,flexShrink:0,opacity:"null"===i?.3:1}}),(0,n.jsx)("span",{style:{fontSize:11,fontFamily:"var(--font-mono)",color:"null"===i?"var(--text-dim)":"var(--text-muted)",textDecoration:"null"===i?"line-through":"none"},children:e})]}),(0,n.jsxs)("div",{style:{display:"flex",borderRadius:5,border:"1px solid var(--border)",overflow:"hidden",flexShrink:0},children:[(0,n.jsx)("button",{onClick:()=>o(e,"omit"),style:{...a,..."omit"===i?d:{}},children:"Default"}),(0,n.jsx)("button",{onClick:()=>o(e,null),style:{...a,borderLeft:"1px solid var(--border)",..."null"===i?{background:"#ef4444",color:"#fff",fontWeight:600}:{}},children:"Disabled"})]}),(0,n.jsxs)("div",{style:{display:"flex",borderRadius:5,border:`1px solid ${"string"===i?"var(--accent)":"var(--border)"}`,overflow:"hidden",transition:"border-color 0.1s"},children:[(0,n.jsx)("button",{onClick:()=>o(e,l||e),style:{...a,..."string"===i?d:{},borderRight:"1px solid var(--border)",flexShrink:0},children:"Custom"}),(0,n.jsx)("input",{value:l,onChange:t=>o(e,t.target.value),onFocus:()=>{"string"!==i&&o(e,l||e)},placeholder:e,maxLength:10,style:{width:"12ch",background:"string"===i?"var(--bg)":"var(--bg-panel)",border:"none",outline:"none",color:"string"===i?"var(--text)":"var(--text-dim)",fontFamily:"var(--font-mono)",fontSize:11,padding:"4px 7px",transition:"background 0.1s, color 0.1s"}})]})]},e)})})}let tD={thinkingFormat:"deepseek",requiresReasoningContentOnAssistantMessages:!0};function t$({model:e,isDefault:t,onSetDefault:r,onChange:o,onDelete:i}){let l=(t,r)=>o({...e,[t]:r});return(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10},children:[(0,n.jsx)(tR,{children:"Model"}),e.id&&(t?(0,n.jsx)("span",{style:{fontSize:10,color:"var(--accent)",fontWeight:600,background:"rgba(249,115,22,0.1)",padding:"2px 6px",borderRadius:4},children:"✨ 全局默认 / Global Default"}):(0,n.jsx)("button",{onClick:r,style:{fontSize:10,padding:"2px 7px",background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:4,color:"var(--text-muted)",cursor:"pointer",fontWeight:500,transition:"border-color 0.12s, color 0.12s"},onMouseEnter:e=>{e.currentTarget.style.borderColor="var(--accent)",e.currentTarget.style.color="var(--accent)"},onMouseLeave:e=>{e.currentTarget.style.borderColor="var(--border)",e.currentTarget.style.color="var(--text-muted)"},children:"设为全局默认 / Set as Global Default"}))]}),(0,n.jsx)("button",{onClick:i,style:{padding:"3px 8px",background:"none",border:"1px solid rgba(239,68,68,0.3)",borderRadius:4,color:"#ef4444",cursor:"pointer",fontSize:11},children:"Remove"})]}),(0,n.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:10},children:[(0,n.jsx)(tk,{label:"ID *",children:(0,n.jsx)(tS,{value:e.id,onChange:e=>l("id",e),placeholder:"model-id",mono:!0})}),(0,n.jsx)(tk,{label:"Name",children:(0,n.jsx)(tS,{value:e.name??"",onChange:e=>l("name",e||void 0),placeholder:"Display name"})})]}),(0,n.jsx)(tk,{label:"API override",children:(0,n.jsx)(tz,{value:e.api??"",onChange:e=>l("api",e||void 0),options:tj})}),(0,n.jsxs)("div",{style:{display:"flex",gap:20,flexWrap:"wrap"},children:[(0,n.jsx)(tI,{label:"Reasoning / thinking",checked:e.reasoning??!1,onChange:e=>l("reasoning",e||void 0)}),(0,n.jsx)(tI,{label:"Image input",checked:e.input?.includes("image")??!1,onChange:e=>l("input",e?["text","image"]:void 0)})]}),e.reasoning&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(tI,{label:"DeepSeek thinking compat",checked:e.compat?.thinkingFormat==="deepseek",onChange:t=>o(function(e,t){if(t)return{...e,compat:{...e.compat??{},...tD}};if(!e.compat)return e;let r={...e.compat};return delete r.thinkingFormat,delete r.requiresReasoningContentOnAssistantMessages,{...e,compat:Object.keys(r).length?r:void 0}}(e,t))}),(0,n.jsxs)("div",{children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:8},children:[(0,n.jsx)(tR,{children:"Thinking level map"}),e.thinkingLevelMap&&(0,n.jsx)("button",{onClick:()=>l("thinkingLevelMap",void 0),style:{fontSize:10,padding:"2px 7px",background:"none",border:"1px solid var(--border)",borderRadius:4,color:"var(--text-dim)",cursor:"pointer"},children:"clear all"})]}),(0,n.jsx)(tM,{value:e.thinkingLevelMap,onChange:e=>l("thinkingLevelMap",e)})]})]}),(0,n.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:10},children:[(0,n.jsx)(tk,{label:"Context window (tokens)",children:(0,n.jsx)(tT,{value:void 0!==e.contextWindow?String(e.contextWindow):"",onChange:e=>l("contextWindow",e?parseInt(e):void 0),placeholder:"128000"})}),(0,n.jsx)(tk,{label:"Max output tokens",children:(0,n.jsx)(tT,{value:void 0!==e.maxTokens?String(e.maxTokens):"",onChange:e=>l("maxTokens",e?parseInt(e):void 0),placeholder:"16384"})})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)(tR,{children:"Cost (per million tokens)"}),(0,n.jsx)("div",{style:{marginTop:8,display:"grid",gridTemplateColumns:"1fr 1fr 1fr 1fr",gap:8},children:["input","output","cacheRead","cacheWrite"].map(t=>(0,n.jsx)(tk,{label:t,children:(0,n.jsx)(tT,{value:e.cost?.[t]!==void 0?String(e.cost[t]):"",onChange:r=>{let n;return n=parseFloat(r),void o({...e,cost:{...e.cost??{},[t]:isNaN(n)?void 0:n}})},placeholder:"0"})},t))})]})]})}function tB({provider:e,onRefresh:t,models:r=[],defaultModel:i,onSetDefault:l}){let[s,a]=(0,o.useState)({phase:"idle"}),[d,c]=(0,o.useState)(""),p=(0,o.useRef)(null),x=(0,o.useRef)(null);(0,o.useEffect)(()=>{("auth"===s.phase||"prompt"===s.phase)&&setTimeout(()=>x.current?.focus(),50)},[s.phase]),(0,o.useEffect)(()=>{a({phase:"idle"}),c(""),p.current?.close(),p.current=null},[e.id]),(0,o.useEffect)(()=>()=>{p.current?.close()},[]);let u=(0,o.useCallback)(()=>{p.current?.close(),a({phase:"connecting"}),c("");let r=new EventSource(`/api/auth/login/${encodeURIComponent(e.id)}`);p.current=r,r.onmessage=e=>{let n=JSON.parse(e.data);"auth"===n.type?(a({phase:"auth",url:n.url,instructions:n.instructions??null,token:n.token}),window.open(n.url,"_blank","noopener,noreferrer")):"device_code"===n.type?(a({phase:"device_code",userCode:n.userCode,verificationUri:n.verificationUri,intervalSeconds:n.intervalSeconds??null,expiresInSeconds:n.expiresInSeconds??null}),window.open(n.verificationUri,"_blank","noopener,noreferrer")):"prompt_request"===n.type?a({phase:"prompt",message:n.message,placeholder:n.placeholder??null,token:n.token}):"select_request"===n.type?a({phase:"select",message:n.message,options:n.options??[],token:n.token}):"progress"===n.type?a({phase:"progress",message:n.message}):"success"===n.type?(r.close(),a({phase:"success"}),t()):"error"===n.type?(r.close(),a({phase:"error",message:n.message})):"cancelled"===n.type&&(r.close(),a({phase:"idle"}))},r.onerror=()=>{r.close(),a(e=>"success"===e.phase?e:{phase:"error",message:"Connection lost"})}},[e.id,t]),g=(0,o.useCallback)(async()=>{await fetch(`/api/auth/logout/${encodeURIComponent(e.id)}`,{method:"POST"}),a({phase:"idle"}),t()},[e.id,t]),h=(0,o.useCallback)(async(t,r)=>{if(r.trim()){a({phase:"progress",message:"Verifying…"});try{let n=await fetch(`/api/auth/login/${encodeURIComponent(e.id)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:t,code:r.trim()})});if(!n.ok){let e=await n.json().catch(()=>({}));a({phase:"error",message:e.error??`Server error ${n.status}`});return}c("")}catch(e){a({phase:"error",message:e instanceof Error?e.message:"Network error"})}}},[e.id]),f=(0,o.useCallback)(async(t,r)=>{a({phase:"progress",message:"Continuing…"});try{let n=await fetch(`/api/auth/login/${encodeURIComponent(e.id)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:t,code:r})});if(!n.ok){let e=await n.json().catch(()=>({}));a({phase:"error",message:e.error??`Server error ${n.status}`})}}catch(e){a({phase:"error",message:e instanceof Error?e.message:"Network error"})}},[e.id]),b="connecting"===s.phase||"progress"===s.phase||"auth"===s.phase||"device_code"===s.phase||"prompt"===s.phase||"select"===s.phase;return(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[(0,n.jsx)(tR,{children:"Subscription"}),(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[(0,n.jsx)("span",{style:{width:7,height:7,borderRadius:"50%",background:e.loggedIn?"#4ade80":"var(--border)",display:"inline-block"}}),(0,n.jsx)("span",{style:{fontSize:11,color:e.loggedIn?"#4ade80":"var(--text-dim)"},children:e.loggedIn?"connected":"not connected"})]})]}),(0,n.jsxs)("div",{style:{minHeight:48},children:["idle"===s.phase&&(0,n.jsx)("p",{style:{margin:0,fontSize:12,color:"var(--text-muted)",lineHeight:1.5},children:e.loggedIn?"Already connected. You can re-login or disconnect.":`Connect your ${e.name} account.`}),"connecting"===s.phase&&(0,n.jsx)("p",{style:{margin:0,fontSize:12,color:"var(--text-muted)"},children:"Opening browser…"}),"select"===s.phase&&(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[(0,n.jsx)("p",{style:{margin:0,fontSize:12,color:"var(--text-muted)",lineHeight:1.5},children:s.message}),(0,n.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:s.options.map(e=>(0,n.jsx)("button",{onClick:()=>f(s.token,e.id),style:{padding:"6px 9px",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:5,color:"var(--text)",cursor:"pointer",fontSize:12,textAlign:"left"},children:e.label},e.id))})]}),("auth"===s.phase||"prompt"===s.phase)&&(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[(0,n.jsx)("p",{style:{margin:0,fontSize:12,color:"var(--text-muted)",lineHeight:1.5},children:"auth"===s.phase?"Complete sign-in in the browser, then copy the redirect URL from the address bar and paste it below.":s.message}),"auth"===s.phase&&(0,n.jsxs)("p",{style:{margin:0,fontSize:11,color:"var(--text-dim)",lineHeight:1.5},children:["If the browser window did not open,"," ",(0,n.jsx)("a",{href:s.url,target:"_blank",rel:"noopener noreferrer",style:{color:"var(--accent)",wordBreak:"break-all"},children:"click here to open the login page"}),"."]}),(0,n.jsxs)("div",{style:{display:"flex",gap:6},children:[(0,n.jsx)("input",{ref:x,value:d,onChange:e=>c(e.target.value),onKeyDown:e=>{"Enter"===e.key&&h(s.token,d)},placeholder:"auth"===s.phase?"http://localhost:1455/auth/callback?code=…":s.placeholder??"Enter value…",style:{flex:1,padding:"6px 9px",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:5,color:"var(--text)",fontSize:12,outline:"none",fontFamily:"var(--font-mono)",boxSizing:"border-box"}}),(0,n.jsx)("button",{onClick:()=>h(s.token,d),disabled:!d.trim(),style:{padding:"6px 12px",background:d.trim()?"var(--accent)":"var(--bg-panel)",border:"none",borderRadius:5,color:d.trim()?"#fff":"var(--text-dim)",cursor:d.trim()?"pointer":"not-allowed",fontSize:12,fontWeight:600,flexShrink:0},children:"Submit"})]})]}),"device_code"===s.phase&&(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[(0,n.jsx)("p",{style:{margin:0,fontSize:12,color:"var(--text-muted)",lineHeight:1.5},children:"Open the verification page and enter this code:"}),(0,n.jsx)("div",{style:{padding:"8px 10px",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:5,color:"var(--text)",fontSize:16,fontWeight:700,fontFamily:"var(--font-mono)",letterSpacing:0},children:s.userCode}),(0,n.jsxs)("p",{style:{margin:0,fontSize:11,color:"var(--text-dim)",lineHeight:1.5},children:[(0,n.jsx)("a",{href:s.verificationUri,target:"_blank",rel:"noopener noreferrer",style:{color:"var(--accent)",wordBreak:"break-all"},children:s.verificationUri}),s.expiresInSeconds?` Expires in ${Math.ceil(s.expiresInSeconds/60)} minutes.`:""]})]}),"progress"===s.phase&&(0,n.jsx)("p",{style:{margin:0,fontSize:12,color:"var(--text-muted)"},children:s.message}),"success"===s.phase&&(0,n.jsx)("p",{style:{margin:0,fontSize:12,color:"#4ade80"},children:"Connected successfully."}),"error"===s.phase&&(0,n.jsx)("p",{style:{margin:0,fontSize:12,color:"#f87171"},children:s.message})]}),(0,n.jsx)("div",{style:{display:"flex",gap:8},children:b?(0,n.jsx)("button",{onClick:()=>{p.current?.close(),a({phase:"idle"})},style:{padding:"5px 12px",background:"none",border:"1px solid var(--border)",borderRadius:5,color:"var(--text-muted)",cursor:"pointer",fontSize:12},children:"Cancel"}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("button",{onClick:u,style:{padding:"5px 14px",background:"var(--accent)",border:"none",borderRadius:5,color:"#fff",cursor:"pointer",fontSize:12,fontWeight:600},children:e.loggedIn?"Re-login":"Login"}),e.loggedIn&&(0,n.jsx)("button",{onClick:g,style:{padding:"5px 12px",background:"none",border:"1px solid rgba(239,68,68,0.3)",borderRadius:5,color:"#ef4444",cursor:"pointer",fontSize:12},children:"Disconnect"})]})}),r.length>0&&(0,n.jsxs)("div",{style:{marginTop:24,borderTop:"1px solid var(--border)",paddingTop:16},children:[(0,n.jsxs)(tR,{children:["包含模型 / Models (",r.length,")"]}),(0,n.jsx)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(180px, 1fr))",gap:8,marginTop:10},children:r.map(t=>{let r=i?.provider===e.id&&i?.modelId===t.id;return(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:3,padding:"8px 10px",background:"var(--bg-panel)",border:r?"1.5px solid var(--accent)":"1px solid var(--border)",borderRadius:6,position:"relative"},children:[(0,n.jsx)("span",{style:{fontSize:11,fontWeight:600,color:"var(--text)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",paddingRight:r?40:58},children:t.name||t.id}),(0,n.jsx)("code",{style:{fontSize:9,color:"var(--text-dim)",fontFamily:"var(--font-mono)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",paddingRight:r?40:58},children:t.id}),r?(0,n.jsx)("span",{style:{position:"absolute",right:8,top:"50%",transform:"translateY(-50%)",fontSize:9,color:"var(--accent)",fontWeight:600,background:"rgba(249,115,22,0.1)",padding:"2px 5px",borderRadius:4},children:"✨ 全局默认"}):l&&(0,n.jsx)("button",{onClick:()=>l(e.id,t.id),style:{position:"absolute",right:8,top:"50%",transform:"translateY(-50%)",fontSize:9,padding:"2px 5px",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:4,color:"var(--text-muted)",cursor:"pointer",fontWeight:500},onMouseEnter:e=>{e.currentTarget.style.borderColor="var(--accent)",e.currentTarget.style.color="var(--accent)"},onMouseLeave:e=>{e.currentTarget.style.borderColor="var(--border)",e.currentTarget.style.color="var(--text-muted)"},children:"设为全局默认"})]},t.id)})})]})]})}function tA({provider:e,onRefresh:t,models:r=[],defaultModel:i,onSetDefault:l}){let[s,a]=(0,o.useState)(""),[d,c]=(0,o.useState)(!1),[p,x]=(0,o.useState)(!1),[u,g]=(0,o.useState)(null),[h,f]=(0,o.useState)(!1);(0,o.useEffect)(()=>{a(""),g(null),f(!1)},[e.id]);let b=(0,o.useCallback)(async()=>{if(s.trim()){c(!0),g(null),f(!1);try{let r=await fetch(`/api/auth/api-key/${encodeURIComponent(e.id)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:s.trim()})}),n=await r.json();!r.ok||n.error?g(n.error??`HTTP ${r.status}`):(a(""),f(!0),setTimeout(()=>f(!1),2e3),t())}catch(e){g(String(e))}finally{c(!1)}}},[s,e.id,t]),y=(0,o.useCallback)(async()=>{x(!0),g(null);try{let r=await fetch(`/api/auth/api-key/${encodeURIComponent(e.id)}`,{method:"DELETE"}),n=await r.json();!r.ok||n.error?g(n.error??`HTTP ${r.status}`):t()}catch(e){g(String(e))}finally{x(!1)}},[e.id,t]);return(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[(0,n.jsx)(tR,{children:"API Key"}),(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[(0,n.jsx)("span",{style:{width:7,height:7,borderRadius:"50%",background:e.configured?"#4ade80":"var(--border)",display:"inline-block"}}),(0,n.jsx)("span",{style:{fontSize:11,color:e.configured?"#4ade80":"var(--text-dim)"},children:e.configured?"configured":"not configured"})]})]}),(0,n.jsx)("p",{style:{margin:0,fontSize:12,color:"var(--text-muted)",lineHeight:1.5},children:e.configured?"API key is stored. Enter a new key below to replace it, or disconnect to remove it.":`Enter your ${e.displayName} API key to enable ${e.modelCount} model${1!==e.modelCount?"s":""}.`}),(0,n.jsx)(tk,{label:"API Key",children:(0,n.jsxs)("div",{style:{display:"flex",gap:6},children:[(0,n.jsx)(tC,{value:s,onChange:a,onKeyDown:e=>{"Enter"===e.key&&s.trim()&&b()},placeholder:e.configured?"Enter new key to replace…":"sk-…",style:{flex:1},autoComplete:"off",spellCheck:!1,mono:!0}),(0,n.jsxs)("button",{onClick:b,disabled:d||!s.trim()||h,style:{padding:"6px 12px",background:h?"#16a34a":s.trim()?"var(--accent)":"var(--bg-panel)",border:"none",borderRadius:5,color:s.trim()||h?"#fff":"var(--text-dim)",cursor:d||!s.trim()||h?"not-allowed":"pointer",fontSize:12,fontWeight:600,flexShrink:0,display:"flex",alignItems:"center",gap:5},children:[h&&(0,n.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("polyline",{points:"20 6 9 17 4 12"})}),h?"Saved":d?"Saving…":"Save"]})]})}),u&&(0,n.jsx)("p",{style:{margin:0,fontSize:12,color:"#f87171"},children:u}),e.configured&&(0,n.jsx)("button",{onClick:y,disabled:p,style:{alignSelf:"flex-start",padding:"5px 12px",background:"none",border:"1px solid rgba(239,68,68,0.3)",borderRadius:5,color:"#ef4444",cursor:p?"not-allowed":"pointer",fontSize:12},children:p?"Removing…":"Disconnect"}),r.length>0&&(0,n.jsxs)("div",{style:{marginTop:24,borderTop:"1px solid var(--border)",paddingTop:16},children:[(0,n.jsxs)(tR,{children:["包含模型 / Models (",r.length,")"]}),(0,n.jsx)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(180px, 1fr))",gap:8,marginTop:10},children:r.map(t=>{let r=i?.provider===e.id&&i?.modelId===t.id;return(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:3,padding:"8px 10px",background:"var(--bg-panel)",border:r?"1.5px solid var(--accent)":"1px solid var(--border)",borderRadius:6,position:"relative"},children:[(0,n.jsx)("span",{style:{fontSize:11,fontWeight:600,color:"var(--text)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",paddingRight:r?40:58},children:t.name||t.id}),(0,n.jsx)("code",{style:{fontSize:9,color:"var(--text-dim)",fontFamily:"var(--font-mono)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",paddingRight:r?40:58},children:t.id}),r?(0,n.jsx)("span",{style:{position:"absolute",right:8,top:"50%",transform:"translateY(-50%)",fontSize:9,color:"var(--accent)",fontWeight:600,background:"rgba(249,115,22,0.1)",padding:"2px 5px",borderRadius:4},children:"✨ 全局默认"}):l&&(0,n.jsx)("button",{onClick:()=>l(e.id,t.id),style:{position:"absolute",right:8,top:"50%",transform:"translateY(-50%)",fontSize:9,padding:"2px 5px",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:4,color:"var(--text-muted)",cursor:"pointer",fontWeight:500},onMouseEnter:e=>{e.currentTarget.style.borderColor="var(--accent)",e.currentTarget.style.color="var(--accent)"},onMouseLeave:e=>{e.currentTarget.style.borderColor="var(--border)",e.currentTarget.style.color="var(--text-muted)"},children:"设为全局默认"})]},t.id)})})]})]})}function tO({id:e,size:t}){let r=tm[e];return r?r.hasColor?(0,n.jsx)(r.Icon,{size:t}):(0,n.jsx)(r.Icon,{size:t,style:{color:"var(--text-muted)"}}):null}function tF({oauthProviders:e,apiKeyProviders:t,onSelectOAuth:r,onSelectApiKey:i,onAddCustom:l,onClose:s}){let[a,d]=(0,o.useState)(""),c=(0,o.useRef)(null);(0,o.useEffect)(()=>{setTimeout(()=>c.current?.focus(),30)},[]);let p=a.trim().toLowerCase(),x=e.filter(e=>!e.loggedIn&&(!p||e.name.toLowerCase().includes(p))),u=t.filter(e=>!e.configured&&(!p||e.displayName.toLowerCase().includes(p)||e.id.toLowerCase().includes(p))),g=!p||"custom".includes(p)||"openai-compatible".includes(p)||"anthropic-compatible".includes(p),h=x.length+u.length+ +!!g,f={display:"flex",flexDirection:"row",alignItems:"center",gap:8,padding:"10px 12px",background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:7,boxSizing:"border-box",cursor:"pointer",minWidth:0,textAlign:"left",transition:"border-color 0.12s, background 0.12s",width:"100%"};return(0,n.jsx)("div",{style:{position:"fixed",inset:0,zIndex:1100,background:"rgba(0,0,0,0.4)",display:"flex",alignItems:"center",justifyContent:"center"},onClick:e=>{e.target===e.currentTarget&&s()},children:(0,n.jsxs)("div",{style:{width:820,maxWidth:"calc(100vw - 32px)",maxHeight:"min(72vh, calc(100vh - 32px))",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:10,display:"flex",flexDirection:"column",boxShadow:"0 8px 32px rgba(0,0,0,0.22)",overflow:"hidden"},children:[(0,n.jsxs)("div",{style:{padding:"10px 14px",borderBottom:"1px solid var(--border)",flexShrink:0,display:"flex",alignItems:"center",gap:8},children:[(0,n.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{color:"var(--text-dim)",flexShrink:0},children:[(0,n.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,n.jsx)("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),(0,n.jsx)("input",{ref:c,value:a,onChange:e=>d(e.target.value),onKeyDown:e=>{"Escape"===e.key&&s()},placeholder:"Search providers…",style:{flex:1,background:"none",border:"none",outline:"none",color:"var(--text)",fontSize:13,boxSizing:"border-box"}})]}),(0,n.jsx)("div",{style:{flex:1,overflowY:"auto",padding:14},children:0===h?(0,n.jsx)("div",{style:{padding:"20px 0",fontSize:12,color:"var(--text-dim)",textAlign:"center"},children:"No providers match"}):(0,n.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(min(240px, 100%), 1fr))",gap:8},children:[g&&(0,n.jsx)("div",{style:{gridColumn:"1 / -1",fontSize:10,fontWeight:600,color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:"0.07em"},children:"Custom"}),g&&(0,n.jsxs)("button",{onClick:()=>{l(),s()},style:f,onMouseEnter:e=>{e.currentTarget.style.borderColor="var(--accent)",e.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:e=>{e.currentTarget.style.borderColor="var(--border)",e.currentTarget.style.background="var(--bg-panel)"},children:[(0,n.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,n.jsx)("div",{style:{fontSize:12,fontWeight:600,color:"var(--text)",lineHeight:1.3,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:"OpenAI / Anthropic compatible"}),(0,n.jsx)("div",{style:{fontSize:10,color:"var(--text-dim)",marginTop:2},children:"Custom endpoint format"})]}),(0,n.jsx)("span",{style:{width:26,height:26,borderRadius:5,background:"var(--bg-hover)",border:"1px dashed var(--border)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:(0,n.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{color:"var(--text-dim)"},children:[(0,n.jsx)("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),(0,n.jsx)("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})})]}),x.length>0&&(0,n.jsx)("div",{style:{gridColumn:"1 / -1",paddingTop:6*!!g,fontSize:10,fontWeight:600,color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:"0.07em"},children:"Subscriptions"}),x.map(e=>(0,n.jsxs)("button",{onClick:()=>{r(e.id),s()},style:f,onMouseEnter:e=>{e.currentTarget.style.borderColor="var(--accent)",e.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:e=>{e.currentTarget.style.borderColor="var(--border)",e.currentTarget.style.background="var(--bg-panel)"},children:[(0,n.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,n.jsx)("div",{style:{fontSize:12,fontWeight:600,color:"var(--text)",lineHeight:1.3,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name}),(0,n.jsx)("div",{style:{fontSize:10,color:"var(--text-dim)",marginTop:2},children:"OAuth"})]}),(0,n.jsx)(tO,{id:e.id,size:28})]},e.id)),u.length>0&&(0,n.jsx)("div",{style:{gridColumn:"1 / -1",paddingTop:6*(x.length>0),fontSize:10,fontWeight:600,color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:"0.07em"},children:"API Key"}),u.map(e=>(0,n.jsxs)("button",{onClick:()=>{i(e.id),s()},style:f,onMouseEnter:e=>{e.currentTarget.style.borderColor="var(--accent)",e.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:e=>{e.currentTarget.style.borderColor="var(--border)",e.currentTarget.style.background="var(--bg-panel)"},children:[(0,n.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,n.jsx)("div",{style:{fontSize:12,fontWeight:600,color:"var(--text)",lineHeight:1.3,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.displayName}),(0,n.jsxs)("div",{style:{fontSize:10,color:"var(--text-dim)",marginTop:2},children:[e.modelCount," models"]})]}),(0,n.jsx)(tO,{id:e.id,size:28})]},e.id))]})})]})})}function tN({onClose:e}){let[t,r]=(0,o.useState)({providers:{}}),[i,l]=(0,o.useState)(!0),[s,a]=(0,o.useState)(!1),[d,c]=(0,o.useState)(null),[p,x]=(0,o.useState)(!1),[u,g]=(0,o.useState)(null),[h,f]=(0,o.useState)([]),[b,y]=(0,o.useState)([]),[v,m]=(0,o.useState)([]),[j,k]=(0,o.useState)(null),[w,S]=(0,o.useState)(!1),C=(0,o.useCallback)(()=>{fetch("/api/auth/providers").then(e=>e.json()).then(e=>f(e.providers)).catch(()=>{})},[]),T=(0,o.useCallback)(()=>{fetch("/api/auth/all-providers").then(e=>e.json()).then(e=>y(e.providers)).catch(()=>{})},[]);(0,o.useEffect)(()=>{fetch("/api/models-config").then(e=>e.json()).then(e=>{let t=e.providers?e:{...e,providers:{}};r(t);let n=Object.keys(t.providers??{});n.length>0&&g({type:"provider",name:n[0]})}).catch(()=>r({providers:{}})).finally(()=>l(!1)),C(),T(),fetch("/api/models").then(e=>e.json()).then(e=>{e.modelList&&m(e.modelList),e.defaultModel&&k(e.defaultModel)}).catch(()=>{})},[C,T]);let z=(0,o.useCallback)(async(e,t)=>{try{(await fetch("/api/models",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:e,modelId:t})})).ok&&k({provider:e,modelId:t})}catch(e){console.error("Failed to set default model:",e)}},[]),I=(0,o.useCallback)(()=>{let e="new-provider",n=1;for(;t.providers?.[e];)e=`new-provider-${n++}`;r(t=>({...t,providers:{...t.providers??{},[e]:{api:"openai-completions"}}})),g({type:"provider",name:e})},[t.providers]),R=(0,o.useCallback)((e,t)=>{r(r=>({...r,providers:{...r.providers??{},[e]:t}}))},[]),L=(0,o.useCallback)((e,t)=>{r(r=>{let n=Object.entries(r.providers??{}),o=n.findIndex(([t])=>t===e);return -1===o?r:(n[o]=[t,n[o][1]],{...r,providers:Object.fromEntries(n)})}),g(r=>r?"provider"===r.type&&r.name===e?{type:"provider",name:t}:"model"===r.type&&r.providerName===e?{...r,providerName:t}:r:r)},[]),W=(0,o.useCallback)(e=>{r(t=>{let r={...t.providers??{}};return delete r[e],{...t,providers:r}}),r(e=>{let t=Object.keys(e.providers??{});return g(t.length>0?{type:"provider",name:t[0]}:null),e})},[]),E=(0,o.useCallback)(e=>{r(t=>{let r=t.providers?.[e]??{},n=[...r.models??[],{id:""}];return{...t,providers:{...t.providers??{},[e]:{...r,models:n}}}}),r(t=>{let r=(t.providers?.[e]?.models?.length??1)-1;return g({type:"model",providerName:e,index:r}),t})},[]),M=(0,o.useCallback)((e,t,n)=>{r(r=>{let o=r.providers?.[e]??{},i=[...o.models??[]];return i[t]=n,{...r,providers:{...r.providers??{},[e]:{...o,models:i}}}})},[]),D=(0,o.useCallback)((e,t)=>{r(r=>{let n=r.providers?.[e]??{},o=[...n.models??[]];return o.splice(t,1),{...r,providers:{...r.providers??{},[e]:{...n,models:o.length?o:void 0}}}}),g({type:"provider",name:e})},[]),$=(0,o.useCallback)(async()=>{a(!0),c(null),x(!1);try{let e=await fetch("/api/models-config",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),r=await e.json();!e.ok||r.error?c(r.error??`HTTP ${e.status}`):(x(!0),setTimeout(()=>x(!1),2e3))}catch(e){c(String(e))}finally{a(!1)}},[t]),B=Object.entries(t.providers??{}),A=h.filter(e=>e.loggedIn),O=b.filter(e=>e.configured),F=(()=>{if(!u)return null;if("oauth"===u.type){let e=h.find(e=>e.id===u.providerId);if(!e)return null;let t=v.filter(t=>t.provider===e.id);return(0,n.jsx)(tB,{provider:e,onRefresh:C,models:t,defaultModel:j,onSetDefault:z},e.id)}if("apikey"===u.type){let e=b.find(e=>e.id===u.providerId);if(!e)return null;let t=v.filter(t=>t.provider===e.id);return(0,n.jsx)(tA,{provider:e,onRefresh:T,models:t,defaultModel:j,onSetDefault:z},e.id)}if("provider"===u.type){let e=t.providers?.[u.name];return e?(0,n.jsx)(tL,{name:u.name,provider:e,onChange:e=>R(u.name,e),onRename:e=>L(u.name,e),onDelete:()=>W(u.name)},u.name):null}let e=t.providers?.[u.providerName],r=e?.models?.[u.index];if(!r)return null;let o=j?.provider===u.providerName&&j?.modelId===r.id;return(0,n.jsx)(t$,{model:r,isDefault:o,onSetDefault:()=>z(u.providerName,r.id),onChange:e=>M(u.providerName,u.index,e),onDelete:()=>D(u.providerName,u.index)},`${u.providerName}-${u.index}`)})();return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{style:{position:"fixed",inset:0,zIndex:1e3,background:"rgba(0,0,0,0.35)",display:"flex",alignItems:"center",justifyContent:"center"},onClick:t=>{t.target===t.currentTarget&&e()},children:(0,n.jsxs)("div",{style:{width:860,height:"78vh",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:10,display:"flex",flexDirection:"column",boxShadow:"0 8px 32px rgba(0,0,0,0.18)",overflow:"hidden"},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 18px",borderBottom:"1px solid var(--border)",flexShrink:0},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:10},children:[(0,n.jsx)("span",{style:{fontSize:15,fontWeight:700,color:"var(--text)"},children:"Models"}),(0,n.jsx)("code",{style:{fontSize:11,color:"var(--text-muted)",fontFamily:"var(--font-mono)"},children:"~/.ink/agent/models.json"})]}),(0,n.jsx)("button",{onClick:e,style:{background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",fontSize:20,lineHeight:1,padding:"2px 6px"},children:"\xd7"})]}),(0,n.jsxs)("div",{style:{flex:1,display:"flex",overflow:"hidden"},children:[(0,n.jsxs)("div",{style:{width:210,borderRight:"1px solid var(--border)",display:"flex",flexDirection:"column",flexShrink:0,background:"var(--bg-panel)"},children:[(0,n.jsxs)("div",{style:{flex:1,overflowY:"auto",padding:"8px 6px"},children:[A.map(e=>{let t=u?.type==="oauth"&&u.providerId===e.id;return(0,n.jsxs)("div",{onClick:()=>g({type:"oauth",providerId:e.id}),style:{display:"flex",alignItems:"center",gap:7,padding:"5px 8px",borderRadius:5,cursor:"pointer",background:t?"var(--bg-selected)":"none"},onMouseEnter:e=>{t||(e.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:e=>{t||(e.currentTarget.style.background="none")},children:[(0,n.jsx)(tO,{id:e.id,size:16}),(0,n.jsx)("span",{style:{fontSize:12,color:"var(--text)",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name})]},e.id)}),O.map(e=>{let t=u?.type==="apikey"&&u.providerId===e.id;return(0,n.jsxs)("div",{onClick:()=>g({type:"apikey",providerId:e.id}),style:{display:"flex",alignItems:"center",gap:7,padding:"5px 8px",borderRadius:5,cursor:"pointer",background:t?"var(--bg-selected)":"none"},onMouseEnter:e=>{t||(e.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:e=>{t||(e.currentTarget.style.background="none")},children:[(0,n.jsx)(tO,{id:e.id,size:16}),(0,n.jsx)("span",{style:{fontSize:12,color:"var(--text)",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.displayName})]},e.id)}),(A.length>0||O.length>0)&&B.length>0&&(0,n.jsx)("div",{style:{margin:"4px 8px",borderTop:"1px solid var(--border)"}}),i?(0,n.jsx)("div",{style:{padding:"10px 8px",fontSize:12,color:"var(--text-muted)"},children:"Loading…"}):B.map(([e,t])=>{let r=u?.type==="provider"&&u.name===e,o=t.models??[];return(0,n.jsxs)("div",{style:{marginBottom:2},children:[(0,n.jsxs)("div",{onClick:()=>g({type:"provider",name:e}),style:{display:"flex",alignItems:"center",gap:6,padding:"7px 8px",borderRadius:5,cursor:"pointer",background:r?"var(--bg-selected)":"none"},onMouseEnter:e=>{r||(e.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:e=>{r||(e.currentTarget.style.background="none")},children:[(0,n.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{color:"var(--text-dim)",flexShrink:0},children:[(0,n.jsx)("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"}),(0,n.jsx)("rect",{x:"9",y:"9",width:"6",height:"6"}),(0,n.jsx)("line",{x1:"9",y1:"1",x2:"9",y2:"4"}),(0,n.jsx)("line",{x1:"15",y1:"1",x2:"15",y2:"4"}),(0,n.jsx)("line",{x1:"9",y1:"20",x2:"9",y2:"23"}),(0,n.jsx)("line",{x1:"15",y1:"20",x2:"15",y2:"23"}),(0,n.jsx)("line",{x1:"20",y1:"9",x2:"23",y2:"9"}),(0,n.jsx)("line",{x1:"20",y1:"14",x2:"23",y2:"14"}),(0,n.jsx)("line",{x1:"1",y1:"9",x2:"4",y2:"9"}),(0,n.jsx)("line",{x1:"1",y1:"14",x2:"4",y2:"14"})]}),(0,n.jsx)("span",{style:{fontSize:12,fontWeight:r?600:400,color:"var(--text)",fontFamily:"var(--font-mono)",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e})]}),o.map((t,r)=>{let o=u?.type==="model"&&u.providerName===e&&u.index===r;return(0,n.jsxs)("div",{onClick:()=>g({type:"model",providerName:e,index:r}),style:{display:"flex",alignItems:"center",gap:6,padding:"5px 8px 5px 26px",borderRadius:5,cursor:"pointer",background:o?"var(--bg-selected)":"none"},onMouseEnter:e=>{o||(e.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:e=>{o||(e.currentTarget.style.background="none")},children:[(0,n.jsx)("span",{style:{fontSize:11,fontFamily:"var(--font-mono)",color:t.id?"var(--text-muted)":"var(--text-dim)",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.id||"new model"}),t.reasoning&&(0,n.jsx)("span",{style:{fontSize:9,padding:"1px 4px",background:"rgba(99,102,241,0.12)",color:"rgba(99,102,241,0.8)",borderRadius:3,flexShrink:0},children:"T"})]},r)}),(0,n.jsx)("div",{onClick:t=>{t.stopPropagation(),E(e)},style:{display:"flex",alignItems:"center",gap:4,padding:"4px 8px 4px 26px",borderRadius:5,cursor:"pointer",color:"var(--text-dim)"},onMouseEnter:e=>{e.currentTarget.style.color="var(--accent)",e.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-dim)",e.currentTarget.style.background="none"},children:(0,n.jsx)("span",{style:{fontSize:11},children:"+ model"})})]},e)})]}),(0,n.jsx)("div",{style:{borderTop:"1px solid var(--border)",padding:"8px 6px"},children:(0,n.jsx)("button",{onClick:()=>S(!0),style:{display:"flex",alignItems:"center",justifyContent:"center",gap:5,width:"100%",padding:"6px 0",background:"none",border:"1px dashed var(--border)",borderRadius:5,color:"var(--text-muted)",cursor:"pointer",fontSize:12},onMouseEnter:e=>{e.currentTarget.style.borderColor="var(--accent)",e.currentTarget.style.color="var(--accent)"},onMouseLeave:e=>{e.currentTarget.style.borderColor="var(--border)",e.currentTarget.style.color="var(--text-muted)"},children:"+ Add provider"})})]}),(0,n.jsx)("div",{style:{flex:1,overflowY:"auto",padding:20},children:i?null:F??(0,n.jsx)("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--text-dim)",fontSize:13},children:"Select a provider or model"})})]}),(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:10,padding:"10px 18px",borderTop:"1px solid var(--border)",flexShrink:0},children:[d&&(0,n.jsx)("span",{style:{fontSize:12,color:"#f87171",flex:1},children:d}),(0,n.jsx)("button",{onClick:e,style:{padding:"6px 14px",background:"none",border:"1px solid var(--border)",borderRadius:6,color:"var(--text-muted)",cursor:"pointer",fontSize:13},children:"Cancel"}),(0,n.jsxs)("button",{onClick:$,disabled:s||p,style:{position:"relative",padding:"6px 16px",minWidth:92,background:p?"#16a34a":s?"var(--bg-panel)":"var(--accent)",border:"none",borderRadius:6,color:p?"#fff":s?"var(--text-muted)":"#fff",cursor:s||p?"default":"pointer",fontSize:13,fontWeight:600,display:"inline-flex",alignItems:"center",justifyContent:"center",gap:6,transition:"background-color 0.2s ease, color 0.2s ease",animation:p?"saved-pop 0.45s ease":void 0},children:[p&&(0,n.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",style:{strokeDasharray:18,animation:"saved-check-draw 0.35s ease forwards",flexShrink:0},children:(0,n.jsx)("polyline",{points:"20 6 9 17 4 12"})}),(0,n.jsx)("span",{children:p?"Saved":s?"Saving…":"Save"})]})]})]})}),w&&(0,n.jsx)(tF,{oauthProviders:h,apiKeyProviders:b,onSelectOAuth:e=>g({type:"oauth",providerId:e}),onSelectApiKey:e=>g({type:"apikey",providerId:e}),onAddCustom:I,onClose:()=>S(!1)})]})}function tP(e){return e.replace(/^\/(?:Users|home)\/[^/]+/,"~")}function tH(e){let t=e.sourceInfo?.source,r=e.sourceInfo?.scope;return"user"===r||"user"===t?"global":"project"===r||"project"===t?"project":"path"}function t_({enabled:e,loading:t,onToggle:r}){return(0,n.jsx)("button",{onClick:r,disabled:t,title:e?"Visible in model prompt — click to disable":"Hidden from model prompt — click to enable",style:{flexShrink:0,width:40,height:22,borderRadius:11,border:"none",padding:0,cursor:t?"wait":"pointer",background:e?"var(--accent)":"var(--border)",position:"relative",transition:"background 0.18s",outline:"none"},children:(0,n.jsx)("span",{style:{position:"absolute",top:3,left:e?21:3,width:16,height:16,borderRadius:"50%",background:"var(--bg)",boxShadow:"0 1px 4px rgba(0,0,0,0.22)",transition:"left 0.18s cubic-bezier(.4,0,.2,1)"}})})}function tJ({skill:e,cwd:t,onToggle:r,toggling:o,saveError:i}){let l=tH(e),s=!e.disableModelInvocation;return(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:20},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:7},children:[(0,n.jsx)("span",{style:{fontSize:10,padding:"1px 5px",borderRadius:3,flexShrink:0,background:"project"===l?"rgba(99,102,241,0.12)":"rgba(120,120,120,0.12)",color:"project"===l?"rgba(99,102,241,0.8)":"var(--text-dim)"},children:l}),(0,n.jsx)("span",{style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-dim)",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:function(e){if("project"===l&&e.startsWith(t)){let r=e.slice(t.length).replace(/^[/\\]/,"");return`./${r}`}return tP(e)}(e.filePath)}),(0,n.jsx)(t_,{enabled:s,loading:o,onToggle:()=>r(e)}),i&&(0,n.jsx)("span",{style:{fontSize:12,color:"#f87171",flexShrink:0},children:i})]}),(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:5},children:[(0,n.jsx)("span",{style:{fontSize:12,color:"var(--text-muted)",fontWeight:500},children:"Name"}),(0,n.jsx)("span",{style:{fontFamily:"var(--font-mono)",fontSize:14,color:"var(--text)"},children:e.name})]}),(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:5},children:[(0,n.jsx)("span",{style:{fontSize:12,color:"var(--text-muted)",fontWeight:500},children:"Description"}),(0,n.jsx)("span",{style:{fontSize:14,color:"var(--text-muted)",lineHeight:1.6},children:e.description})]})]})}function tU({cwd:e,onInstalled:t}){let[r,i]=(0,o.useState)(""),[l,s]=(0,o.useState)([]),[a,d]=(0,o.useState)(!1),[c,p]=(0,o.useState)(null),[x,u]=(0,o.useState)(null),[g,h]=(0,o.useState)(null),[f,b]=(0,o.useState)(new Set),[y,v]=(0,o.useState)("global"),m=(0,o.useRef)(null);(0,o.useEffect)(()=>{m.current?.focus()},[]);let j=(0,o.useCallback)(async e=>{if(e.trim()){d(!0),p(null),s([]);try{let t=await fetch("/api/skills/search",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:e.trim()})}),r=await t.json();if(r.error)return void p(r.error);s(r.results??[]),0===(r.results??[]).length&&p("No skills found")}catch(e){p(String(e))}finally{d(!1)}}},[]),k=(0,o.useCallback)(async r=>{u(r),h(null);try{let n=await fetch("/api/skills/install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({package:r,scope:y,cwd:e})}),o=await n.json();if(!n.ok||o.error)return void h(o.error??`HTTP ${n.status}`);b(e=>new Set(e).add(r)),t()}catch(e){h(String(e))}finally{u(null)}},[t,y,e]),w="global"===y?"~/.ink/agent/skills/":`${tP(e)}/.ink/agent/skills/`;return(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%"},children:[(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:12,marginBottom:20},children:[(0,n.jsx)("div",{style:{fontSize:14,fontWeight:600,color:"var(--text)"},children:"Add Skill"}),(0,n.jsxs)("div",{style:{display:"flex",gap:8},children:[(0,n.jsx)("input",{ref:m,value:r,onChange:e=>i(e.target.value),onKeyDown:e=>{"Enter"===e.key&&j(r)},placeholder:"e.g. react, testing, deploy",style:{flex:1,padding:"7px 10px",fontSize:13,background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:6,color:"var(--text)",outline:"none"}}),(0,n.jsx)("button",{onClick:()=>j(r),disabled:a||!r.trim(),style:{padding:"7px 16px",fontSize:13,borderRadius:6,border:"none",background:"var(--accent)",color:"#fff",cursor:a||!r.trim()?"not-allowed":"pointer",opacity:a||!r.trim()?.5:1,flexShrink:0},children:a?"Searching…":"Search"})]}),(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10},children:[(0,n.jsx)("div",{style:{display:"flex",borderRadius:5,border:"1px solid var(--border)",overflow:"hidden",fontSize:12,flexShrink:0},children:["global","project"].map(e=>(0,n.jsx)("button",{onClick:()=>v(e),style:{padding:"3px 10px",border:"none",cursor:"pointer",background:y===e?"var(--bg-selected)":"none",color:y===e?"var(--text)":"var(--text-dim)",fontWeight:y===e?600:400,borderRight:"global"===e?"1px solid var(--border)":"none"},children:e},e))}),(0,n.jsxs)("span",{style:{fontSize:12,color:"var(--text-dim)",fontFamily:"var(--font-mono)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:["→ ",w]})]}),c&&(0,n.jsx)("div",{style:{fontSize:12,color:"#f87171"},children:c}),g&&(0,n.jsx)("div",{style:{fontSize:12,color:"#f87171",wordBreak:"break-word"},children:g})]}),l.length>0?(0,n.jsx)("div",{style:{flex:1,overflowY:"auto"},children:l.map(e=>{let t=f.has(e.package),r=x===e.package,o=e.package.indexOf("@"),i=o>-1?e.package.slice(0,o):e.package,l=o>-1?e.package.slice(o+1):null;return(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:14,padding:"12px 0",borderBottom:"1px solid var(--border)"},children:[(0,n.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,n.jsx)("div",{style:{fontSize:13,fontWeight:600,color:"var(--text)",marginBottom:3},children:l??i}),(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,flexWrap:"wrap"},children:[(0,n.jsx)("span",{style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-dim)"},children:i}),(0,n.jsx)("span",{style:{fontSize:12,color:"var(--text-muted)",fontWeight:500},children:e.installs}),e.url&&(0,n.jsx)("a",{href:e.url,target:"_blank",rel:"noreferrer",style:{fontSize:12,color:"var(--accent)",textDecoration:"none"},children:"skills.sh ↗"})]})]}),(0,n.jsx)("button",{onClick:()=>!t&&!r&&k(e.package),disabled:t||r||null!==x,style:{flexShrink:0,padding:"5px 14px",fontSize:12,fontWeight:500,borderRadius:5,border:"1px solid var(--border)",cursor:t||r||null!==x?"not-allowed":"pointer",background:t?"rgba(34,197,94,0.1)":"none",color:t?"#16a34a":r?"var(--accent)":"var(--text-muted)",transition:"color 0.12s"},children:t?"✓ Installed":r?"Installing…":"Install"})]},e.package)})}):!c&&!a&&(0,n.jsxs)("div",{style:{fontSize:13,color:"var(--text-dim)",lineHeight:1.8},children:["Search"," ",(0,n.jsx)("a",{href:"https://skills.sh",target:"_blank",rel:"noreferrer",style:{color:"var(--accent)",textDecoration:"none"},children:"skills.sh"})," ","to discover and install skills for your agent."]})]})}function tV({cwd:e,onClose:t}){let[r,i]=(0,o.useState)([]),[l,s]=(0,o.useState)(!0),[a,d]=(0,o.useState)(null),[c,p]=(0,o.useState)(null),[x,u]=(0,o.useState)(new Set),[g,h]=(0,o.useState)(null),[f,b]=(0,o.useState)(!1),y=(0,o.useCallback)(()=>{s(!0),d(null),fetch(`/api/skills?cwd=${encodeURIComponent(e)}`).then(e=>e.json()).then(e=>{if(e.error)return void d(e.error);let t=e.skills??[];i(t),t.length>0&&!c&&p(t[0].filePath)}).catch(e=>d(String(e))).finally(()=>s(!1))},[e,c]);(0,o.useEffect)(()=>{y()},[e]);let v=(0,o.useCallback)(async e=>{let t=!e.disableModelInvocation;u(t=>new Set(t).add(e.filePath)),h(null);try{let r=await fetch("/api/skills",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({filePath:e.filePath,disableModelInvocation:t})}),n=await r.json();if(!r.ok||n.error)return void h(n.error??`HTTP ${r.status}`);i(r=>r.map(r=>r.filePath===e.filePath?{...r,disableModelInvocation:t}:r))}catch(e){h(String(e))}finally{u(t=>{let r=new Set(t);return r.delete(e.filePath),r})}},[]),m=r.find(e=>e.filePath===c)??null;return(0,n.jsx)("div",{style:{position:"fixed",inset:0,zIndex:1e3,background:"rgba(0,0,0,0.35)",display:"flex",alignItems:"center",justifyContent:"center"},onClick:e=>{e.target===e.currentTarget&&t()},children:(0,n.jsxs)("div",{style:{width:860,height:"78vh",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:10,display:"flex",flexDirection:"column",boxShadow:"0 8px 32px rgba(0,0,0,0.18)",overflow:"hidden"},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 18px",borderBottom:"1px solid var(--border)",flexShrink:0},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:10},children:[(0,n.jsx)("span",{style:{fontSize:15,fontWeight:700,color:"var(--text)"},children:"Skills"}),(0,n.jsx)("code",{style:{fontSize:11,color:"var(--text-muted)",fontFamily:"var(--font-mono)",maxWidth:320,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:tP(e)})]}),(0,n.jsx)("button",{onClick:t,style:{background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",fontSize:20,lineHeight:1,padding:"2px 6px"},children:"\xd7"})]}),(0,n.jsxs)("div",{style:{flex:1,display:"flex",overflow:"hidden"},children:[(0,n.jsxs)("div",{style:{width:210,borderRight:"1px solid var(--border)",display:"flex",flexDirection:"column",flexShrink:0,background:"var(--bg-panel)"},children:[(0,n.jsx)("div",{style:{flex:1,overflowY:"auto",padding:"8px 6px"},children:l?(0,n.jsx)("div",{style:{padding:"10px 8px",fontSize:12,color:"var(--text-muted)"},children:"Loading…"}):a?(0,n.jsx)("div",{style:{padding:"10px 8px",fontSize:11,color:"#f87171"},children:a}):0===r.length?(0,n.jsx)("div",{style:{padding:"10px 8px",fontSize:11,color:"var(--text-dim)"},children:"No skills found"}):(()=>{let e=[];for(let t of["project","global","path"]){let n=r.filter(e=>tH(e)===t);n.length>0&&e.push({label:t,skills:n})}return e.map(({label:e,skills:t})=>(0,n.jsxs)("div",{style:{marginBottom:6},children:[(0,n.jsx)("div",{style:{padding:"4px 8px 3px",fontSize:10,fontWeight:600,color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:"0.06em"},children:e}),t.map(e=>{let t=!f&&c===e.filePath,r=e.disableModelInvocation;return(0,n.jsxs)("div",{onClick:()=>{p(e.filePath),b(!1)},style:{display:"flex",alignItems:"center",gap:7,padding:"8px 8px",borderRadius:5,cursor:"pointer",background:t?"var(--bg-selected)":"none"},onMouseEnter:e=>{t||(e.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:e=>{t||(e.currentTarget.style.background="none")},children:[(0,n.jsx)("span",{style:{flexShrink:0,width:7,height:7,borderRadius:"50%",background:r?"var(--border)":"var(--accent)",boxShadow:r?"none":"0 0 4px var(--accent)",transition:"background 0.15s, box-shadow 0.15s"}}),(0,n.jsx)("span",{style:{fontSize:12,fontWeight:t?600:400,color:r?"var(--text-dim)":"var(--text)",fontFamily:"var(--font-mono)",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name})]},e.filePath)})]},e))})()}),(0,n.jsx)("div",{style:{padding:"8px 6px",borderTop:"1px solid var(--border)",flexShrink:0},children:(0,n.jsxs)("div",{onClick:()=>b(!0),style:{display:"flex",alignItems:"center",gap:6,padding:"7px 8px",borderRadius:5,cursor:"pointer",background:f?"var(--bg-selected)":"none",color:f?"var(--accent)":"var(--text-dim)",fontSize:12},onMouseEnter:e=>{f||(e.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:e=>{f||(e.currentTarget.style.background="none")},children:[(0,n.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),(0,n.jsx)("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),"Add skill"]})})]}),(0,n.jsx)("div",{style:{flex:1,overflowY:"auto",padding:20},children:f?(0,n.jsx)(tU,{cwd:e,onInstalled:()=>{y()}}):l?null:m?(0,n.jsx)(tJ,{skill:m,cwd:e,onToggle:v,toggling:x.has(m.filePath),saveError:g},m.filePath):(0,n.jsx)("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--text-dim)",fontSize:13},children:"Select a skill"})})]}),(0,n.jsx)("div",{style:{display:"flex",alignItems:"center",justifyContent:"flex-end",padding:"10px 18px",borderTop:"1px solid var(--border)",flexShrink:0},children:(0,n.jsx)("button",{onClick:t,style:{padding:"6px 14px",background:"none",border:"1px solid var(--border)",borderRadius:6,color:"var(--text-muted)",cursor:"pointer",fontSize:13},children:"Close"})})]})})}function tY({onClose:e,onSave:t}){let[r,i]=(0,o.useState)(!0),[l,s]=(0,o.useState)(!0),[a,d]=(0,o.useState)(!0),[c,p]=(0,o.useState)(!1),[x,u]=(0,o.useState)(!1);return(0,o.useEffect)(()=>{let e=localStorage.getItem("ink-show-execution-confirm");null!==e&&i("true"===e);let t=localStorage.getItem("ink-show-import-draft");null!==t&&s("true"===t);let r=localStorage.getItem("ink-show-auto-generate-short");null!==r&&d("true"===r)},[]),(0,n.jsx)("div",{style:{position:"fixed",inset:0,zIndex:1e3,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(10, 10, 10, 0.4)",backdropFilter:"blur(4px)"},onClick:e,children:(0,n.jsxs)("div",{onClick:e=>e.stopPropagation(),style:{width:"min(400px, 90%)",background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:12,boxShadow:"0 20px 40px rgba(0,0,0,0.15)",display:"flex",flexDirection:"column",overflow:"hidden"},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"14px 18px",borderBottom:"1px solid var(--border)"},children:[(0,n.jsxs)("span",{style:{fontSize:13,fontWeight:600,color:"var(--text)",display:"flex",alignItems:"center",gap:6},children:[(0,n.jsx)("span",{style:{fontSize:14},children:"⚙️"})," 系统全局设置"]}),(0,n.jsx)("button",{onClick:e,style:{background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",fontSize:16,padding:4,lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center"},children:"✕"})]}),(0,n.jsxs)("div",{style:{padding:"20px 18px",display:"flex",flexDirection:"column",gap:16},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:16},children:[(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[(0,n.jsx)("span",{style:{fontSize:13,fontWeight:500,color:"var(--text)"},children:"操作执行前确认提示"}),(0,n.jsx)("span",{style:{fontSize:11,color:"var(--text-dim)",lineHeight:1.4},children:"点击底部工具栏按钮(智能续写、局部定点修复、防崩审计等)时,弹出确认窗口并显示功能说明。"})]}),(0,n.jsxs)("label",{style:{position:"relative",display:"inline-block",width:40,height:22,flexShrink:0,cursor:"pointer"},children:[(0,n.jsx)("input",{type:"checkbox",checked:r,onChange:e=>i(e.target.checked),style:{opacity:0,width:0,height:0}}),(0,n.jsx)("span",{style:{position:"absolute",cursor:"pointer",inset:0,backgroundColor:r?"var(--accent)":"var(--bg-hover)",border:"1px solid var(--border)",borderRadius:22,transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)",boxShadow:"inset 0 1px 2px rgba(0,0,0,0.05)"},children:(0,n.jsx)("span",{style:{position:"absolute",height:16,width:16,left:r?20:2,bottom:2,backgroundColor:"#fff",borderRadius:"50%",transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)",boxShadow:"0 1px 3px rgba(0,0,0,0.15)"}})})]})]}),(0,n.jsx)("div",{style:{height:"1px",background:"var(--border)",opacity:.6}}),(0,n.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:16},children:[(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[(0,n.jsx)("span",{style:{fontSize:13,fontWeight:500,color:"var(--text)"},children:"显示“导入已有旧稿”按钮"}),(0,n.jsx)("span",{style:{fontSize:11,color:"var(--text-dim)",lineHeight:1.4},children:"在侧边栏显示“导入已有旧稿”按钮,支持从外部 TXT 章节或已有文件批量导入故事宇宙。"})]}),(0,n.jsxs)("label",{style:{position:"relative",display:"inline-block",width:40,height:22,flexShrink:0,cursor:"pointer"},children:[(0,n.jsx)("input",{type:"checkbox",checked:l,onChange:e=>s(e.target.checked),style:{opacity:0,width:0,height:0}}),(0,n.jsx)("span",{style:{position:"absolute",cursor:"pointer",inset:0,backgroundColor:l?"var(--accent)":"var(--bg-hover)",border:"1px solid var(--border)",borderRadius:22,transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)",boxShadow:"inset 0 1px 2px rgba(0,0,0,0.05)"},children:(0,n.jsx)("span",{style:{position:"absolute",height:16,width:16,left:l?20:2,bottom:2,backgroundColor:"#fff",borderRadius:"50%",transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)",boxShadow:"0 1px 3px rgba(0,0,0,0.15)"}})})]})]}),(0,n.jsx)("div",{style:{height:"1px",background:"var(--border)",opacity:.6}}),(0,n.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:16},children:[(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[(0,n.jsx)("span",{style:{fontSize:13,fontWeight:500,color:"var(--text)"},children:"显示“一键全自动生成短篇”按钮"}),(0,n.jsx)("span",{style:{fontSize:11,color:"var(--text-dim)",lineHeight:1.4},children:"在侧边栏显示“一键全自动生成短篇”快捷键,支持配置并启动全自动短篇小说大纲与章节生成流水线。"})]}),(0,n.jsxs)("label",{style:{position:"relative",display:"inline-block",width:40,height:22,flexShrink:0,cursor:"pointer"},children:[(0,n.jsx)("input",{type:"checkbox",checked:a,onChange:e=>d(e.target.checked),style:{opacity:0,width:0,height:0}}),(0,n.jsx)("span",{style:{position:"absolute",cursor:"pointer",inset:0,backgroundColor:a?"var(--accent)":"var(--bg-hover)",border:"1px solid var(--border)",borderRadius:22,transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)",boxShadow:"inset 0 1px 2px rgba(0,0,0,0.05)"},children:(0,n.jsx)("span",{style:{position:"absolute",height:16,width:16,left:a?20:2,bottom:2,backgroundColor:"#fff",borderRadius:"50%",transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)",boxShadow:"0 1px 3px rgba(0,0,0,0.15)"}})})]})]})]}),(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:10,padding:"10px 18px",borderTop:"1px solid var(--border)",background:"var(--bg-panel)"},children:[(0,n.jsx)("button",{onClick:e,style:{padding:"5px 12px",background:"none",border:"1px solid var(--border)",borderRadius:6,color:"var(--text-muted)",cursor:"pointer",fontSize:12},children:"取消"}),(0,n.jsxs)("button",{onClick:()=>{p(!0),localStorage.setItem("ink-show-execution-confirm",String(r)),localStorage.setItem("ink-show-import-draft",String(l)),localStorage.setItem("ink-show-auto-generate-short",String(a)),window.dispatchEvent(new CustomEvent("ink-settings-changed",{detail:{showExecutionConfirm:r,showImportDraft:l,showAutoGenerateShort:a}})),setTimeout(()=>{p(!1),u(!0),setTimeout(()=>{u(!1),t&&t(),e()},500)},300)},disabled:c||x,style:{padding:"5px 14px",minWidth:80,background:x?"#16a34a":"var(--accent)",border:"none",borderRadius:6,color:"#fff",cursor:c||x?"default":"pointer",fontSize:12,fontWeight:600,display:"inline-flex",alignItems:"center",justifyContent:"center",gap:4,transition:"background-color 0.2s ease"},children:[x&&(0,n.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("polyline",{points:"20 6 9 17 4 12"})}),(0,n.jsx)("span",{children:x?"已保存":c?"保存中…":"保存设定"})]})]})]})})}function tK({onClose:e}){let t,[r,i]=(0,o.useState)("setup"),[l,s]=(0,o.useState)(0),a=[{id:"setup",icon:"\uD83D\uDEE0️",title:"第一步:工作区初始化",subtitle:"一键开启小说创作宇宙与模型配置",steps:[{title:"1. 一键开启创作宇宙 (Workspace Init)",content:(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[(0,n.jsxs)("div",{children:["当你选定一个未初始化的空文件夹或已有稿件的目录后,侧边栏顶部会亮起 ",(0,n.jsx)("strong",{children:"“未初始化的创作空间”"})," 警告卡。 点击 ",(0,n.jsx)("strong",{style:{color:"var(--accent)"},children:"【一键开启创作宇宙】"})," 按钮,系统将在后台执行 ",(0,n.jsx)("code",{children:"inkos init"}),":"]}),(0,n.jsx)("div",{style:{background:"rgba(255, 255, 255, 0.03)",padding:"10px 14px",borderRadius:8,border:"1px solid var(--border)"},children:(0,n.jsxs)("ul",{style:{paddingLeft:18,margin:0,lineHeight:"1.7"},children:[(0,n.jsxs)("li",{children:["在项目根目录下生成 ",(0,n.jsx)("code",{children:"story/"}),"(真相数据库)和 ",(0,n.jsx)("code",{children:"books/"}),"(书籍目录)。"]}),(0,n.jsxs)("li",{children:["建立并注册 ",(0,n.jsx)("code",{children:"inkos.json"})," 工作区参数配置文件。"]}),(0,n.jsx)("li",{children:"检测完毕后,警告卡会自动消失,开启正式的小说管理界面。"})]})}),(0,n.jsx)("div",{children:(0,n.jsx)("em",{children:"提示:初始化成功后,警告框会自动关闭并刷新文件树,此时即可创建第一本书籍。"})})]})},{title:"2. 大模型能力配置 (Models Config)",content:(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[(0,n.jsxs)("div",{children:["点击右上角的 ",(0,n.jsx)("strong",{children:"【配置模型】"})," 按钮(芯片网格图标)。对于网文及严肃长篇创作,大模型的“分工协作”对产出质量有着决定性影响:"]}),(0,n.jsx)("div",{style:{background:"rgba(255, 255, 255, 0.03)",padding:"10px 14px",borderRadius:8,border:"1px solid var(--border)"},children:(0,n.jsxs)("ul",{style:{paddingLeft:18,margin:0,lineHeight:"1.7"},children:[(0,n.jsxs)("li",{children:[(0,n.jsx)("strong",{children:"起草与润色模型 (Drafting & Polishing)"}),":",(0,n.jsx)("br",{}),"推荐使用生成速度较快、词汇库相对活泼、情节张力强且具备强大长上下文对齐能力的选择。例如:",(0,n.jsx)("code",{children:"Claude 3.5 Sonnet"}),"、",(0,n.jsx)("code",{children:"DeepSeek-Chat (V3)"}),"。"]}),(0,n.jsxs)("li",{style:{marginTop:8},children:[(0,n.jsx)("strong",{children:"防崩审计模型 (Auditing)"}),":",(0,n.jsx)("br",{}),"防崩溃审计需要极强的心智模型和严谨的指令遵循度,用于检测境界贬值、逻辑冲突等。强烈推荐配置高规格的推理大模型,如 ",(0,n.jsx)("code",{children:"GPT-4o"}),"、",(0,n.jsx)("code",{children:"Claude 3.5 Sonnet"}),"。"]})]})}),(0,n.jsxs)("div",{children:["配置好 API Key 和 Proxy Base URL(如无代理则留空)后,点击 ",(0,n.jsx)("strong",{children:"【保存设定】"})," 即可即时生效。"]})]})}]},{id:"create",icon:"\uD83D\uDCE5",title:"第二步:书籍管理、起草与导入",subtitle:"协同起草大纲人设、新建书籍与旧稿导入",steps:[{title:"1. AI 协同起草大纲人设 (AI Co-writers)",content:(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("strong",{children:"适用场景"}),":当手头只有一些灵感碎片,还没有成型的小说大纲与角色人设时。"]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("strong",{children:"操作流程"}),":先不急于创建新书。在左侧侧边栏展开 ",(0,n.jsx)("strong",{style:{color:"var(--accent)"},children:"【AI 写作伴侣 (Co-writers)】"})," 面板,点击 ",(0,n.jsx)("strong",{children:"+ Create"})," 或选用内置写作姬:"]}),(0,n.jsx)("div",{style:{background:"rgba(255, 255, 255, 0.03)",padding:"10px 14px",borderRadius:8,border:"1px solid var(--border)"},children:(0,n.jsxs)("ul",{style:{paddingLeft:18,margin:0,lineHeight:"1.7"},children:[(0,n.jsxs)("li",{children:[(0,n.jsx)("strong",{children:"大纲策划师 (\uD83D\uDDFA️)"}),":共同脑暴、梳理剧情冲突与主线节奏,策划结果将在本地工作区生成 ",(0,n.jsx)("code",{children:"架构.md"}),"。"]}),(0,n.jsxs)("li",{children:[(0,n.jsx)("strong",{children:"人设雕琢师 (\uD83D\uDD2E)"}),":设定角色姓名、背景性格、专属对话口吻等,结果生成为 ",(0,n.jsx)("code",{children:"人设.md"}),"。"]})]})}),(0,n.jsx)("div",{children:(0,n.jsx)("em",{children:"提示:Gems 写作伴侣支持指定不同的底层大模型,并允许“关联知识库文件”注入绝对路径的设定参考,实现精准对齐。"})})]})},{title:"2. 新建书籍与框架继承 (Create Book)",content:(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[(0,n.jsxs)("div",{children:["在左侧栏选择 ",(0,n.jsx)("strong",{children:"【创建新书】"}),",你需要配置书籍标题、风格题材、以及创意简报。"]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("strong",{children:"\uD83D\uDCA1 极速架构合入与继承机制"}),": 如果在新建书籍前,你已在项目工作区目录下存有由 AI 写作伴侣起草保存的 ",(0,n.jsx)("code",{children:"架构.md"}),"(或 ",(0,n.jsx)("code",{children:"novel_framework.md"}),")和 ",(0,n.jsx)("code",{children:"人设.md"}),"(或 ",(0,n.jsx)("code",{children:"character_profiles.md"}),"),系统会在建书时",(0,n.jsx)("strong",{children:"自动识别并读取"}),"它们,将人设与境界体系合入底层 Truth 数据库(",(0,n.jsx)("code",{children:"story/"})," 目录)。"]})]})},{title:"3. 批量导入已有旧章原稿",content:(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[(0,n.jsxs)("div",{children:["如果你想将以往在其他软件写好的小说(包含数十万字的历史章节)迁移到本站继续写,可以使用侧边栏工具栏的 ",(0,n.jsx)("strong",{children:"【导入设定或旧章原稿】"})," 按钮(向下的箭头):"]}),(0,n.jsxs)("div",{style:{background:"rgba(255, 255, 255, 0.03)",padding:"10px 14px",borderRadius:8,border:"1px solid var(--border)"},children:[(0,n.jsx)("strong",{children:"操作配置项"}),":",(0,n.jsxs)("ul",{style:{paddingLeft:18,margin:"6px 0",lineHeight:"1.7"},children:[(0,n.jsxs)("li",{children:[(0,n.jsx)("code",{children:"导入源路径 (From Path)"}),":选择包含旧稿 Markdown 或 TXT 文件的本地文件夹,或者单个合集大文本文件。"]}),(0,n.jsxs)("li",{children:[(0,n.jsx)("code",{children:"章节拆分正则 (Split Regex)"}),":系统默认以 ",(0,n.jsx)("code",{children:"第[一二三四五六七八九十百千万\\d]+章"})," 进行智能切割分章,你可以根据自己的分章规范修改正则。"]}),(0,n.jsxs)("li",{children:[(0,n.jsx)("code",{children:"断点续传 (Resume From)"}),":可设定从某章开始导入。"]})]})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("strong",{children:"逆向提取引擎的工作流程"}),": 导入旧稿不仅仅是把文字搬运过来。导入后,AI 会自动按章节运行逆向同步流水线。它会读取你的历史章节正文,梳理世界观、人物性格特征、当前境界、并搜寻所有尚未解决的历史伏笔。最终在 ",(0,n.jsx)("code",{children:"story/"})," 目录下自动搭建出人设矩阵、伏笔池和状态卡,完成逆向“补完”。"]})]})},{title:"4. 继承前作/正典设定",content:(0,n.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:(0,n.jsxs)("div",{children:["如果是撰写同宇宙的系列第二部,在导入面板中选择 ",(0,n.jsx)("strong",{children:"“导入正典设定”"}),",指定前作的 Book ID,即可将前作的世界观、人物人设直接克隆到新书中作为参考正典,避免吃设定。"]})})}]},{id:"plan",icon:"\uD83D\uDDFA️",title:"第三步:蓝图细化",subtitle:"智能大纲细纲编译与意图强制控制",steps:[{title:"1. 一键规划蓝图",content:(0,n.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:8},children:(0,n.jsxs)("div",{children:["在写每章之前,点击章节底部的 ",(0,n.jsx)("strong",{children:"【规划蓝图】"}),"。 系统后台的多智能体大纲规划管线会启动。AI 会结合:",(0,n.jsxs)("ol",{style:{paddingLeft:18,margin:"6px 0",lineHeight:"1.6"},children:[(0,n.jsx)("li",{children:"当前书的大纲设定和卷纲。"}),(0,n.jsx)("li",{children:"前一章节的末尾内容(保持剧情绝对平滑过渡)。"}),(0,n.jsxs)("li",{children:[(0,n.jsx)("code",{children:"pending_hooks.md"})," 中标记为“本章该兑现”或“急需解决”的悬念和伏笔。"]}),(0,n.jsxs)("li",{children:[(0,n.jsx)("code",{children:"current_state.md"})," 中存活的、且在当前场景的角色列表。"]})]}),"从而编译生成本章的 ",(0,n.jsx)("strong",{children:"本章大纲细纲 (Outline)"})," 以及 ",(0,n.jsx)("strong",{children:"本章写作意图 (Intent)"}),"。"]})})},{title:"2. 意图调整与主线校验",content:(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[(0,n.jsxs)("div",{children:["规划出的细纲会在右侧报告面板展示。",(0,n.jsx)("strong",{children:"作为作者,您握有最高控制权:"})]}),(0,n.jsx)("div",{style:{borderLeft:"3px solid var(--accent)",paddingLeft:12,fontStyle:"italic",fontSize:11},children:"例如:系统规划本章是日常过渡,而你决定强行加快节奏。你可以直接在报告的意图编辑框中添加: “本章插入刺客夜袭情节,主角被迫反击并暴露法宝,击退敌人后负伤撤退”。"}),(0,n.jsxs)("div",{children:["修改保存后,接下来的“智能续写”和“极速草稿”都将把此修改作为",(0,n.jsx)("strong",{children:"刚性控制参数"}),"输入,绝对不会偏离你的微调方向。"]})]})}]},{id:"write",icon:"✍️",title:"第四步:正文创作",subtitle:"高文采续写、草稿快跑与冲突回滚机制",steps:[{title:"1. 智能续写 (标准模式)",content:(0,n.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:(0,n.jsxs)("div",{children:["点击底部的橙色按钮 ",(0,n.jsx)("strong",{style:{color:"#ff903f"},children:"【智能续写】"}),"。 AI 将根据本章蓝图和设定账本展开高水平文学写作。生成过程中会连续在后台执行防崩溃逻辑检验和修正,最终生成最符合要求的上下文章节。"]})})},{title:"2. 极速草稿 (快跑模式)",content:(0,n.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:(0,n.jsxs)("div",{children:["点击续写旁的下拉箭头,切换至 ",(0,n.jsx)("strong",{children:"【极速草稿】"}),",在右侧输入“创意引导描述”(例如:“主角打碎花瓶,被师父责罚”)。 此模式将跳过复杂的后台审计直接以最高生成速度输出大纲片段,方便快速扩充灵感,稍后再行修正。"]})})},{title:"3. 空缺章节填补与逻辑冲突回滚",content:(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[(0,n.jsx)("div",{children:"系统内置了智能的文件断层检测和回滚保护:"}),(0,n.jsxs)("ul",{style:{paddingLeft:18,margin:0,lineHeight:"1.7"},children:[(0,n.jsxs)("li",{children:[(0,n.jsx)("strong",{children:"空缺章节自动填补 (Auto-Healing)"}),":若你在文件树中意外删除了某章(如第 4 章),在写第 5 章时,系统检测到章节空缺,会自动创建第 4 章占位草稿并向你报警,维持故事的时序连贯。"]}),(0,n.jsxs)("li",{children:[(0,n.jsx)("strong",{children:"分支重写冲突阻断 (Conflict Warning)"}),":若你回到前面(例如第 3 章)重新续写,而你的书库中已经存在后续的第 4、5、6 章。系统会弹出红色警告:",(0,n.jsx)("br",{}),(0,n.jsx)("span",{style:{color:"#ef4444",fontWeight:600},children:"“检测到书库中已存在后续章节。在第 3 章后重新起草,将自动废弃并物理覆盖后续所有章节。”"}),(0,n.jsx)("br",{}),"一旦你确认强制重写,系统会在后台执行 `write rewrite --force`,自动将整个宇宙的状态快照完美回滚到第 3 章末尾,确保后续章节不会产生大面积逻辑污染。"]})]})]})}]},{id:"sync",icon:"\uD83D\uDD04",title:"第五步:对账同步",subtitle:"更新真相账本以对抗AI长期遗忘",steps:[{title:"1. 设定同步的作用原理",content:(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[(0,n.jsx)("div",{children:"网络小说创作极度依赖前后的呼应和设定的严密性。当你手动修改了章节正文后,大模型如果未能读取到你的修改,会在后续生成中产生吃设定现象。"}),(0,n.jsxs)("div",{children:[(0,n.jsx)("strong",{children:"解决方案"}),":完成手动编辑后,点击底部工具栏绿色的 ",(0,n.jsx)("strong",{children:"【同步设定】"}),"。 系统会在后台提取本章所有关键事件、状态演变,更新到 ",(0,n.jsx)("code",{children:"story/"})," 账本中。"]})]})},{title:"2. 三大核心对账单详解",content:(0,n.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:(0,n.jsx)("div",{style:{background:"rgba(255, 255, 255, 0.03)",padding:12,borderRadius:8,border:"1px solid var(--border)"},children:(0,n.jsxs)("ul",{style:{paddingLeft:18,margin:0,lineHeight:"1.7"},children:[(0,n.jsxs)("li",{children:[(0,n.jsxs)("strong",{children:["状态卡 (",(0,n.jsx)("code",{children:"current_state.md"}),")"]}),": 更新当前章发生事件的简短摘要、所处宏观场景与时序,以及当前在场角色的存活状态。"]}),(0,n.jsxs)("li",{style:{marginTop:6},children:[(0,n.jsxs)("strong",{children:["资源数值账本 (",(0,n.jsx)("code",{children:"particle_ledger.md"}),")"]}),": 对于升级流或具有严密数值系统的网络小说(如修仙的灵力、网游的经验值、财富等),同步设定会自动对账并更新数值。若正文中主角购买法宝消耗了 100 灵石,账本中灵石会自动扣除,避免“主角的灵石花不完”等贬值硬伤。"]}),(0,n.jsxs)("li",{style:{marginTop:6},children:[(0,n.jsxs)("strong",{children:["未兑现伏笔池 (",(0,n.jsx)("code",{children:"pending_hooks.md"}),")"]}),": 自动检索本章正文。如果主角在正文中埋下了伏笔(如“在角落种下了隐形种子”),伏笔池会自动记录该 Hook;若主角击杀了埋伏已久的强敌,伏笔池会自动将该伏笔标记为“已兑现并闭环”,防止烂尾。"]})]})})})}]},{id:"audit",icon:"\uD83D\uDD0D",title:"第六步:质量审计",subtitle:"连续性与人设冲突多智能体校验",steps:[{title:"1. 运行防崩审计",content:(0,n.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:(0,n.jsxs)("div",{children:["点击底部的蓝色按钮 ",(0,n.jsx)("strong",{style:{color:"#60a5fa"},children:"【防崩审计】"}),"。 系统将调用独立审计智能体扫描本章正文,与你的真相设定数据库进行精细核对。"]})})},{title:"2. 十二大核心防崩维度",content:(0,n.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:(0,n.jsx)("div",{style:{background:"rgba(255, 255, 255, 0.02)",padding:"12px 16px",borderRadius:8,border:"1px solid var(--border)",fontSize:11},children:(0,n.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px 16px",lineHeight:"1.6"},children:[(0,n.jsxs)("div",{children:["• ",(0,n.jsx)("strong",{children:"OOC 人设坍塌"}),":性格突变或违反人设设定"]}),(0,n.jsxs)("div",{children:["• ",(0,n.jsx)("strong",{children:"Mainline 大纲跑偏"}),":偏离主线意图"]}),(0,n.jsxs)("div",{children:["• ",(0,n.jsx)("strong",{children:"Timeline 时序冲突"}),":剧情发生顺序错误"]}),(0,n.jsxs)("div",{children:["• ",(0,n.jsx)("strong",{children:"Conflict 爽点虚化"}),":承诺的情节点未爆开"]}),(0,n.jsxs)("div",{children:["• ",(0,n.jsx)("strong",{children:"Hook 伏笔漏洞"}),":挖坑未埋或未同步登记"]}),(0,n.jsxs)("div",{children:["• ",(0,n.jsx)("strong",{children:"Power 战力崩坏"}),":境界、装备数值异常膨胀"]}),(0,n.jsxs)("div",{children:["• ",(0,n.jsx)("strong",{children:"Pacing 节奏失控"}),":推进过慢或过渡过硬"]}),(0,n.jsxs)("div",{children:["• ",(0,n.jsx)("strong",{children:"POV 视角混乱"}),":第三人称与第一人称意外混淆"]}),(0,n.jsxs)("div",{children:["• ",(0,n.jsx)("strong",{children:"Subplot 支线停滞"}),":支线大面积闲置无推进"]}),(0,n.jsxs)("div",{children:["• ",(0,n.jsx)("strong",{children:"Relationship 关系冲突"}),":配角对主角态度转变不合理"]}),(0,n.jsxs)("div",{children:["• ",(0,n.jsx)("strong",{children:"Incentive 利益链冲突"}),":人物动机缺乏底层逻辑"]}),(0,n.jsxs)("div",{children:["• ",(0,n.jsx)("strong",{children:"Canon 违反正典"}),":同人创作中违背原著世界法则"]})]})})})},{title:"3. 问题级别定义",content:(0,n.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:(0,n.jsxs)("ul",{style:{paddingLeft:18,margin:0,lineHeight:"1.7"},children:[(0,n.jsxs)("li",{children:[(0,n.jsx)("strong",{style:{color:"#ef4444"},children:"Critical (严重致命)"}),":人设大面积坍塌、核心设定冲突、大纲彻底跑偏。系统会拦截接下来的新章自动续写,必须修正此级别错误后方可继续。"]}),(0,n.jsxs)("li",{children:[(0,n.jsx)("strong",{style:{color:"#f97316"},children:"Warning (警告)"}),":局部战斗力描写略高、伏笔登记漏掉、小数值算错。建议微调以保持长篇故事线整洁。"]}),(0,n.jsxs)("li",{children:[(0,n.jsx)("strong",{style:{color:"var(--accent)"},children:"Info (参考建议)"}),":局部的行文措辞冗余、段落等长导致阅读疲劳、词汇丰富度建议。"]})]})})}]},{id:"revise",icon:"\uD83E\uDE84",title:"第七步:智能精修与检测",subtitle:"智能特征检测与精细修补,掌控修改幅度",steps:[{title:"1. 检测 AI 味 (Detect AI-ness)",content:(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("strong",{children:"定义与核心原则"}),": 只评估,**绝对不修改任何正文**。系统通过大模型或本地规则,深度解剖当前正文中的 AI 特征,并生成诊断报告。"]}),(0,n.jsx)("div",{style:{background:"rgba(255, 255, 255, 0.03)",padding:12,borderRadius:8,border:"1px solid var(--border)"},children:(0,n.jsxs)("ul",{style:{paddingLeft:18,margin:0,lineHeight:"1.7"},children:[(0,n.jsxs)("li",{children:[(0,n.jsx)("strong",{children:"LLM 大模型检测"}),":从语义层面审查文字是否空洞、叙述腔调是否模板化,指明需要去 AI 味的具体句子和冗长句段。"]}),(0,n.jsxs)("li",{children:[(0,n.jsx)("strong",{children:"本地规则检测 (Offline)"}),":完全基于本地算法,计算段落句长分布是否过于均等、排比结构是否冗余、以及套话转折词的出现频次(零耗费 Token)。"]})]})})]})},{title:"2. 局部定点修复 (Spot-Fix)",content:(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("strong",{children:"定义与核心原则"}),": 定点修复是为解决“改一个错字导致AI把全章重写一遍”而设计的。它",(0,n.jsx)("strong",{children:"绝对禁止改动无关段落"}),"。"]}),(0,n.jsx)("div",{style:{background:"rgba(255, 255, 255, 0.03)",padding:12,borderRadius:8,border:"1px solid var(--border)"},children:(0,n.jsxs)("ul",{style:{paddingLeft:18,margin:0,lineHeight:"1.7"},children:[(0,n.jsxs)("li",{children:[(0,n.jsx)("strong",{children:"允许范围"}),":严格锁定在审计指出问题的那个句子或段落,以及其前后紧邻的各一句话(前后 1 行行内颗粒度)。"]}),(0,n.jsxs)("li",{children:[(0,n.jsx)("strong",{children:"运作逻辑"}),":AI 识别定位 ",(0,n.jsx)("code",{children:"TARGET_TEXT"})," 并生成 ",(0,n.jsx)("code",{children:"REPLACEMENT_TEXT"})," 补丁,其余 99% 的文本原封不动地返回,安全度最高。"]})]})})]})},{title:"3. 防检测润色 (Anti-Detect) — 去 AI 味黄金指南",content:(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("strong",{children:"定义与核心原则"}),": 网络小说中如果充斥着死板的“AI味”,会极大地削弱读者的代入感。防检测润色是通过重置词汇指纹与语法句式,抹除生成痕迹。"]}),(0,n.jsxs)("div",{style:{background:"rgba(255, 255, 255, 0.03)",padding:12,borderRadius:8,border:"1px solid var(--border)"},children:[(0,n.jsx)("strong",{children:"引擎底层的九大改写规则"}),":",(0,n.jsxs)("ol",{style:{paddingLeft:18,margin:"6px 0",lineHeight:"1.7",fontSize:11},children:[(0,n.jsxs)("li",{children:[(0,n.jsx)("strong",{children:"打破等长段落"}),":交替长短句,避免大模型惯有的均等对称句子,使句式结构不可预测。"]}),(0,n.jsxs)("li",{children:[(0,n.jsx)("strong",{children:"口语化与自然表达"}),":消灭书面套话。",(0,n.jsx)("br",{}),(0,n.jsx)("em",{children:"正例:✗“然而事情并没有那么简单” ➜ ✓“哪有那么便宜的事”"})]}),(0,n.jsxs)("li",{children:[(0,n.jsx)("strong",{children:"降低“了”字密度"}),":避免冗余的时态助词。",(0,n.jsx)("br",{}),(0,n.jsx)("em",{children:"正例:✗“他走了过去,拿了杯子” ➜ ✓“他走过去,端起杯子”"})]}),(0,n.jsxs)("li",{children:[(0,n.jsx)("strong",{children:"转折词降频"}),":删除过于死板的“虽然…但是…”、“不得不说”,换用角色内心吐槽或直接动作切换。"]}),(0,n.jsxs)("li",{children:[(0,n.jsx)("strong",{children:"情绪动作外化 (Show, Don't Tell)"}),":不写抽象结论。",(0,n.jsx)("br",{}),(0,n.jsx)("em",{children:"正例:✗“他感到非常愤怒” ➜ ✓“他捏减了茶杯,指节发白,滚烫的茶水顺着指缝流下来”"})]}),(0,n.jsxs)("li",{children:[(0,n.jsx)("strong",{children:"删去叙述者强行盖棺定论"}),":剔除“这一刻他终于懂得了力量”等大道理,只保留具体行动,让读者自行感受。"]}),(0,n.jsxs)("li",{children:[(0,n.jsx)("strong",{children:"群像反应具体化"}),":避免脸谱化。",(0,n.jsx)("br",{}),(0,n.jsx)("em",{children:"正例:✗“全场震惊” ➜ ✓“老陈手里的烟头掉在了裤子上,烫得他龇牙咧嘴跳起来”"})]}),(0,n.jsxs)("li",{children:[(0,n.jsx)("strong",{children:"消除AI标志性疲劳词"}),":强力清洗“不禁”、“仿佛”、“宛如”、“嘴角微微上扬”等大模型高频出现的敷衍性过渡词,换为独具文学色彩的具体感官描写。"]}),(0,n.jsxs)("li",{children:[(0,n.jsx)("strong",{children:"段落长短悬殊化"}),":让有的段落只有几个字,有的段落七八行,营造真实的叙事节奏感。"]})]})]})]})},{title:"4. 文本润色 (Polish)",content:(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("strong",{children:"定义与核心原则"}),": 只改行文措辞和语调,**绝对不改变任何剧情事实与结论**。"]}),(0,n.jsx)("div",{style:{background:"rgba(255, 255, 255, 0.03)",padding:12,borderRadius:8,border:"1px solid var(--border)"},children:(0,n.jsxs)("ul",{style:{paddingLeft:18,margin:0,lineHeight:"1.7"},children:[(0,n.jsxs)("li",{children:[(0,n.jsx)("strong",{children:"严禁操作"}),":禁止增删段落、禁止更改人名/地名/法宝名称、禁止添加任何新的剧情对话。"]}),(0,n.jsxs)("li",{children:[(0,n.jsx)("strong",{children:"允许操作"}),":替换高雅词汇、优化语言节奏、调整语序、改善句段之间的衔接呼吸感。适合成稿后的最后一轮精细抛光。"]})]})})]})},{title:"5. 智能改写 (Rewrite)",content:(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("strong",{children:"定义与核心原则"}),": 围绕有缺陷或干瘪的段落及其直接上下文进行局部细节扩写和场景重组。"]}),(0,n.jsx)("div",{style:{background:"rgba(255, 255, 255, 0.03)",padding:12,borderRadius:8,border:"1px solid var(--border)"},children:(0,n.jsxs)("ul",{style:{paddingLeft:18,margin:0,lineHeight:"1.7"},children:[(0,n.jsxs)("li",{children:[(0,n.jsx)("strong",{children:"适用场景"}),":某场戏打斗软弱无力、表白情节毫无波澜、对话干瘪无趣。"]}),(0,n.jsxs)("li",{children:[(0,n.jsx)("strong",{children:"修改方式"}),":AI会专注于这一段场景,添加大量的神态细节、心理活动、微表情、环境动作互动,把抽象的情节点“撑开”变得立体饱满,但保留人物的核心动机和结果。"]})]})})]})},{title:"6. 剧情重写 (Rework)",content:(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("strong",{children:"定义与核心原则"}),": 允许推倒整章的场景顺序和矛盾冲突,重新结构化正文。"]}),(0,n.jsx)("div",{style:{background:"rgba(255, 255, 255, 0.03)",padding:12,borderRadius:8,border:"1px solid var(--border)"},children:(0,n.jsxs)("ul",{style:{paddingLeft:18,margin:0,lineHeight:"1.7"},children:[(0,n.jsxs)("li",{children:[(0,n.jsx)("strong",{children:"适用场景"}),":当前章节的叙事结构、推进节奏严重拉崩,或者因为大纲重大调整需要推倒重来。"]}),(0,n.jsxs)("li",{children:[(0,n.jsx)("strong",{children:"刚性约束"}),":虽然允许重构全部场景与对话,但依然受到 ",(0,n.jsx)("code",{children:"story/"})," Truth 账本的高层约束,不能违反已经发生的正典事实或强行改变大设定。"]})]})})]})}]},{id:"advanced",icon:"\uD83D\uDE80",title:"第八步:高级辅助功能",subtitle:"文风克隆、长篇归档、同人创作与合规导出",steps:[{title:"1. 文风克隆工坊 (Style Clone Workshop)",content:(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[(0,n.jsx)("div",{children:"通过提取和分析统计你的文风特征,让 AI 续写和改写时的文笔高度贴合你本人的写作语气。"}),(0,n.jsxs)("div",{style:{background:"rgba(255, 255, 255, 0.03)",padding:12,borderRadius:8,border:"1px solid var(--border)"},children:[(0,n.jsx)("strong",{children:"实战技巧"}),":",(0,n.jsxs)("ol",{style:{paddingLeft:18,margin:0,lineHeight:"1.7"},children:[(0,n.jsxs)("li",{children:["点击顶部的 ",(0,n.jsx)("strong",{children:"【文风克隆工坊】"})," 按钮。"]}),(0,n.jsx)("li",{children:"粘贴你本人以往纯手写、且最满意的小说段落(强烈建议在 2000-5000 字之间,最好是包含对话、场景描写和日常叙述的综合片段)。"}),(0,n.jsxs)("li",{children:["AI会进行文风特征提取并生成 ",(0,n.jsx)("code",{children:"style_guide.md"})," 文风指南存入 ",(0,n.jsx)("code",{children:"story/"}),"。"]}),(0,n.jsx)("li",{children:"在顶部左侧的文风下拉选择框中,切换为刚刚克隆出的文风名称。此后所有的智能续写和改写都将自动沿袭你的这一专属特色。"})]})]})]})},{title:"2. 大纲摘要压缩归档 (Consolidate)",content:(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("strong",{children:"上下文窗口危机"}),": 当你的书写到 50 章或上百章之后,几近百万字的历史章节由于大模型上下文窗口限制,会导致 AI 忘记前期的伏笔和人设。"]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("strong",{children:"操作方法"}),": 当系统检测到完结卷或历史章节过多时,左侧栏顶部会弹出 ",(0,n.jsx)("strong",{children:"“建议进行大纲摘要压缩”"})," 的小字卡片。点击 ",(0,n.jsx)("strong",{children:"【一键压缩归档】"}),"。"]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("strong",{children:"底层逻辑"}),": 系统会将已完结的所有章节摘要压缩归并为宏观的“卷级概要”存入 ",(0,n.jsx)("code",{children:"volume_summaries.md"}),",并将明细摘要封存到 ",(0,n.jsx)("code",{children:"summaries_archive/"}),"。这样可以极大地精简大模型所需阅读的上下文,腾空 Token,同时保障大模型对几百章前埋下的暗线伏笔依然具备长效记忆。"]})]})},{title:"3. 同人创作模式深度规则 (Fanfiction CP/AU/OOC)",content:(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[(0,n.jsx)("div",{children:"在新建书籍时开启“同人写作”模式,系统支持以下 4 种微调态度:"}),(0,n.jsx)("div",{style:{background:"rgba(255, 255, 255, 0.03)",padding:12,borderRadius:8,border:"1px solid var(--border)"},children:(0,n.jsxs)("ul",{style:{paddingLeft:18,margin:0,lineHeight:"1.7",fontSize:11},children:[(0,n.jsxs)("li",{children:[(0,n.jsx)("strong",{children:"正典延续 (canon)"}),":AI 强力对齐原著背景设定和人物结局,作为官方续写。"]}),(0,n.jsxs)("li",{children:[(0,n.jsx)("strong",{children:"平行宇宙 (au)"}),":允许将人物放置在全新世界背景下,但保留核心性格和说话语癖。"]}),(0,n.jsxs)("li",{children:[(0,n.jsx)("strong",{children:"角色偏离 (ooc)"}),":放开人设性格束缚,允许发生反差性发展。"]}),(0,n.jsxs)("li",{children:[(0,n.jsx)("strong",{children:"角色配对 (cp)"}),":强力驱动两人互动,自动聚焦和放大情感线、羁绊线。"]})]})}),(0,n.jsxs)("div",{children:[(0,n.jsx)("strong",{children:"\uD83C\uDFAC 刷新同人设定"}),": 在左侧栏点击“刷新设定”,填入原著的小说文本或人物百科绝对路径。AI会重新提炼原作的语癖(如标志性口头禅、句尾助词)以及人物特征,重新计算以供写作时随时使用。"]})]})},{title:"4. 全自动短篇小说生成管线 (Short Novel Pipeline)",content:(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[(0,n.jsxs)("div",{children:["侧边栏支持 ",(0,n.jsx)("strong",{children:"【一键全自动生成短篇】"}),":"]}),(0,n.jsx)("div",{style:{background:"rgba(255, 255, 255, 0.03)",padding:12,borderRadius:8,border:"1px solid var(--border)"},children:"输入一段故事题材意图,并设定目标章节数(默认为 12 章)和单章字数。 系统将连续启动多智能体管线:自动生成故事大纲 ➜ 生成每章意图细化细纲 ➜ 连续全自动起草 12-18 章完整正文 ➜ 在后台自动生成对应的书籍精美封面。适合快速生成成套短篇小说。"})]})},{title:"5. 导出小说书稿 (Exporting Options)",content:(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[(0,n.jsxs)("div",{children:["点击侧边栏顶部的 ",(0,n.jsx)("strong",{children:"【导出小说书稿】"})," 按钮(向上箭头图标):"]}),(0,n.jsx)("div",{style:{background:"rgba(255, 255, 255, 0.03)",padding:12,borderRadius:8,border:"1px solid var(--border)"},children:(0,n.jsxs)("ul",{style:{paddingLeft:18,margin:0,lineHeight:"1.7"},children:[(0,n.jsxs)("li",{children:[(0,n.jsx)("strong",{children:"输出格式"}),":支持合并为单一的 ",(0,n.jsx)("code",{children:".txt"}),"、",(0,n.jsx)("code",{children:".md"}),",或导出为格式精美的 ",(0,n.jsx)("code",{children:".epub"})," 电子书格式。"]}),(0,n.jsxs)("li",{children:[(0,n.jsx)("strong",{children:"审核态过滤"}),":勾选 ",(0,n.jsx)("strong",{children:"“仅导出已审核通过章节”"}),",系统会自动过滤掉尚未完成或被标记为审计失败的草稿,保障发布版本绝对合规安全。"]})]})})]})}]}];return(0,n.jsx)("div",{style:{position:"fixed",inset:0,zIndex:1100,background:"rgba(10, 10, 10, 0.4)",backdropFilter:"blur(6px)",display:"flex",justifyContent:"flex-end",animation:"fadeIn 0.2s ease-out"},onClick:e,children:(0,n.jsxs)("div",{onClick:e=>e.stopPropagation(),style:{width:"min(640px, 92%)",height:"100%",background:"var(--bg)",boxShadow:"-10px 0 30px rgba(0,0,0,0.2)",display:"flex",flexDirection:"column",borderLeft:"1px solid var(--border)",fontFamily:"var(--font-serif)",animation:"slideIn 0.25s cubic-bezier(0.16, 1, 0.3, 1)"},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"18px 24px",borderBottom:"1px solid var(--border)",background:"var(--bg-panel)",flexShrink:0},children:[(0,n.jsxs)("span",{style:{fontSize:14,fontWeight:700,color:"var(--text)",display:"flex",alignItems:"center",gap:8},children:[(0,n.jsx)("span",{style:{fontSize:18},children:"\uD83D\uDCDA"})," InkOS 小说实战创作手册"]}),(0,n.jsx)("button",{onClick:e,style:{background:"none",border:"1px solid var(--border)",borderRadius:"50%",width:26,height:26,color:"var(--text-muted)",cursor:"pointer",fontSize:12,display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.15s"},onMouseEnter:e=>{e.currentTarget.style.color="var(--text)",e.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-muted)",e.currentTarget.style.background="none"},children:"✕"})]}),(0,n.jsx)("div",{style:{display:"flex",flexWrap:"nowrap",overflowX:"auto",background:"var(--bg-panel)",borderBottom:"1px solid var(--border)",padding:"6px 8px",gap:3,flexShrink:0,WebkitOverflowScrolling:"touch"},children:a.map(e=>{let t=r===e.id;return(0,n.jsxs)("button",{onClick:()=>{i(e.id),s(0)},style:{display:"flex",alignItems:"center",gap:4,padding:"5px 8px",borderRadius:6,border:"none",background:t?"var(--bg-selected)":"transparent",color:t?"var(--accent)":"var(--text-muted)",cursor:"pointer",fontSize:10.5,fontWeight:600,whiteSpace:"nowrap",transition:"all 0.15s",flexShrink:0},onMouseEnter:e=>{t||(e.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:e=>{t||(e.currentTarget.style.background="transparent")},children:[(0,n.jsx)("span",{children:e.icon}),(0,n.jsx)("span",{children:e.title.split(":")[0]})]},e.id)})}),(t=a.find(e=>e.id===r)||a[0],(0,n.jsxs)("div",{style:{flex:1,overflowY:"auto",padding:"24px 28px"},children:[(0,n.jsxs)("div",{style:{marginBottom:20},children:[(0,n.jsx)("span",{style:{fontSize:11,color:"var(--accent)",fontWeight:700,textTransform:"uppercase",letterSpacing:"0.05em"},children:t.title}),(0,n.jsx)("h2",{style:{fontSize:18,fontWeight:700,margin:"4px 0 8px 0",color:"var(--text)"},children:t.subtitle}),(0,n.jsx)("div",{style:{height:2,width:40,background:"var(--accent)",borderRadius:1}})]}),(0,n.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:12},children:t.steps.map((e,t)=>{let r=l===t;return(0,n.jsxs)("div",{style:{border:"1px solid var(--border)",borderRadius:10,background:r?"var(--bg-panel)":"transparent",overflow:"hidden",transition:"all 0.2s ease"},children:[(0,n.jsxs)("button",{onClick:()=>s(r?null:t),style:{width:"100%",padding:"14px 18px",display:"flex",alignItems:"center",justifyContent:"space-between",border:"none",background:"none",cursor:"pointer",textAlign:"left",fontFamily:"var(--font-serif)"},children:[(0,n.jsx)("span",{style:{fontSize:13,fontWeight:600,color:r?"var(--accent)":"var(--text)"},children:e.title}),(0,n.jsx)("span",{style:{fontSize:10,color:"var(--text-dim)"},children:r?"▲":"▼"})]}),r&&(0,n.jsx)("div",{style:{padding:"0 18px 18px 18px",fontSize:12,color:"var(--text-muted)",lineHeight:"1.7",borderTop:"1px solid rgba(255, 255, 255, 0.03)"},children:e.content})]},t)})})]})),(0,n.jsxs)("div",{style:{padding:"16px 24px",borderTop:"1px solid var(--border)",background:"var(--bg-panel)",display:"flex",justifyContent:"space-between",alignItems:"center",flexShrink:0},children:[(0,n.jsx)("span",{style:{fontSize:10,color:"var(--text-dim)"},children:"\uD83D\uDCA1 提示:侧边栏支持导入旧稿、导出书稿、一键全自动生成短篇和设定归档。"}),(0,n.jsx)("button",{onClick:e,style:{padding:"6px 16px",fontSize:11,borderRadius:6,border:"1px solid var(--border)",background:"var(--bg)",color:"var(--text)",cursor:"pointer",fontWeight:600,transition:"all 0.15s"},onMouseEnter:e=>{e.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:e=>{e.currentTarget.style.background="var(--bg)"},children:"我懂了,开始创作"})]})]})})}function tG({bookId:e,cwd:t,onOpenFile:r}){let[i,l]=(0,o.useState)([]),[s,a]=(0,o.useState)(null),[d,c]=(0,o.useState)(!0),[p,x]=(0,o.useState)(null),[u,g]=(0,o.useState)(""),[h,f]=(0,o.useState)({}),[b,y]=(0,o.useState)({}),[v,m]=(0,o.useState)(new Set),[j,k]=(0,o.useState)(null),[w,S]=(0,o.useState)(!1),[C,T]=(0,o.useState)(null),[z,I]=(0,o.useState)(""),[R,L]=(0,o.useState)(!1),W=(0,o.useRef)({}),E=(0,o.useCallback)(async(r=!1)=>{r||c(!0),x(null);try{let r=await fetch("/api/inkos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"dashboard",cwd:t,args:{bookId:e}})});if(!r.ok)throw Error(`HTTP 异常 ${r.status}`);let n=await r.json();if(n.success)l(n.chapters||[]),a(n.nextChapter||null);else throw Error(n.error||"获取看板数据失败")}catch(e){console.error("Dashboard fetch error:",e),x(e instanceof Error?e.message:String(e))}finally{r||c(!1)}},[e,t]);(0,o.useEffect)(()=>{E()},[E]),(0,o.useEffect)(()=>{let e=()=>{E(!0)};return window.addEventListener("refresh-explorer",e),()=>{window.removeEventListener("refresh-explorer",e)}},[E]);let M=(0,o.useCallback)((e,t)=>{y(r=>{let n=r[e]||[];return{...r,[e]:[...n,t]}}),setTimeout(()=>{let t=W.current[e];t&&(t.scrollTop=t.scrollHeight)},50)},[]),D=(0,o.useCallback)(e=>{y(t=>({...t,[e]:[]}))},[]),$=(0,o.useCallback)(e=>{m(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r})},[]),B=async(r,n,o)=>{if(!h[r]){f(e=>({...e,[r]:n})),D(r),m(e=>{let t=new Set(e);return t.add(r),t});try{let n="";if("audit"===o){let t=String(r).padStart(4,"0");n=`books/${e}/chapters/${t}_`}let i=await fetch("/api/inkos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:o,cwd:t,args:{bookId:e,chapter:"audit"===o?n:String(r),json:!0}})});if(!i.ok)throw Error(`HTTP 异常 ${i.status}`);if(!i.body)throw Error("响应正文流为空");let l=i.body.getReader(),s=new TextDecoder,a="";for(;;){let{done:e,value:t}=await l.read();if(e)break;let n=(a+=s.decode(t,{stream:!0})).split("\n");for(let e of(a=n.pop()||"",n))if(e.trim())try{let t=JSON.parse(e);("stdout"===t.type||"stderr"===t.type)&&M(r,t.data||"")}catch{}}if(a.trim())try{let e=JSON.parse(a);("stdout"===e.type||"stderr"===e.type)&&M(r,e.data||"")}catch{}M(r,`
162
+ 🎉 执行完成。已成功刷新章节 ${r} 的数据结构。`),setTimeout(()=>{m(e=>{let t=new Set(e);return t.delete(r),t})},3e3)}catch(t){console.error(t);let e=t instanceof Error?t.message:String(t);M(r,`
163
+ ❌ 执行失败: ${e}`)}finally{f(e=>{let t={...e};return delete t[r],t}),await E(!0),window.dispatchEvent(new CustomEvent("refresh-explorer"))}}},A=async r=>{if(!h[r]){f(e=>({...e,[r]:"review-approve"})),D(r),$(r),M(r,`正在向系统提交批准请求,标记章节 ${r} 为已过审(将持久化提交快照状态)...`);try{let n=await fetch("/api/inkos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"review-approve",cwd:t,args:{bookId:e,chapter:r,json:!0}})});if(!n.ok)throw Error(`HTTP 异常 ${n.status}`);if(!n.body)throw Error("响应正文流为空");let o=n.body.getReader(),i=new TextDecoder,l="";for(;;){let{done:e,value:t}=await o.read();if(e)break;let n=(l+=i.decode(t,{stream:!0})).split("\n");for(let e of(l=n.pop()||"",n))if(e.trim())try{let t=JSON.parse(e);("stdout"===t.type||"stderr"===t.type)&&M(r,t.data||"")}catch{}}M(r,`
164
+ ✅ 审核成功!章节 ${r} 状态已变更为 [已过审]。`),setTimeout(()=>{m(e=>{let t=new Set(e);return t.delete(r),t})},2e3)}catch(t){console.error(t);let e=t instanceof Error?t.message:String(t);M(r,`
165
+ ❌ 审核提交失败: ${e}`)}finally{f(e=>{let t={...e};return delete t[r],t}),await E(!0),window.dispatchEvent(new CustomEvent("refresh-explorer"))}}},O=async()=>{if(null!==C){L(!0),f(e=>({...e,[C]:"review-reject"})),D(C),$(C),M(C,`正在向系统提交驳回并版本回滚请求... (驳回第 ${C} 章,将自动删除后续所有章节并回滚设定真相库至第 ${C-1} 章时)`);try{let r=await fetch("/api/inkos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"review-reject",cwd:t,args:{bookId:e,chapter:C,reason:z.trim()||void 0,json:!0}})});if(!r.ok)throw Error(`HTTP 异常 ${r.status}`);if(!r.body)throw Error("响应正文流为空");let n=r.body.getReader(),o=new TextDecoder,i="";for(;;){let{done:e,value:t}=await n.read();if(e)break;let r=(i+=o.decode(t,{stream:!0})).split("\n");for(let e of(i=r.pop()||"",r))if(e.trim())try{let t=JSON.parse(e);("stdout"===t.type||"stderr"===t.type)&&M(C,t.data||"")}catch{}}M(C,`
166
+ ✅ 驳回且状态回滚完成!`),window.dispatchEvent(new CustomEvent("refresh-explorer")),setTimeout(()=>{m(e=>{let t=new Set(e);return t.delete(C),t})},2e3)}catch(t){console.error(t);let e=t instanceof Error?t.message:String(t);M(C,`
167
+ ❌ 驳回执行失败: ${e}`)}finally{L(!1),T(null),f(e=>{let t={...e};return delete t[C],t}),await E(!0)}}},F=(n,o)=>{let i=String(n).padStart(4,"0"),l=o.replace(/[/\\?%*:|"<>]/g,"").replace(/\s+/g,"_").slice(0,50),s=`${i}_${l}.md`;r(`${t}/books/${e}/chapters/${s}`,s)},N=i.filter(e=>{let t=u.toLowerCase();return e.title.toLowerCase().includes(t)||String(e.number).includes(t)}),P=i.length,H=i.filter(e=>"approved"===e.status).length,_=i.filter(e=>"audit-failed"===e.status).length,J=i.filter(e=>"state-degraded"===e.status).length,U=i.filter(e=>e.hasPlan).length,V=P>0?Math.round(H/P*100):100,Y=P>0?Math.round(U/P*100):100;return(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%",background:"var(--bg)",color:"var(--text)",fontFamily:"var(--font-serif)",overflow:"hidden"},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 24px",borderBottom:"1px solid var(--border)",background:"var(--bg-panel)"},children:[(0,n.jsxs)("div",{children:[(0,n.jsxs)("h1",{style:{fontSize:18,fontWeight:700,margin:0,display:"flex",alignItems:"center",gap:8},children:[(0,n.jsx)("span",{children:"\uD83D\uDCCA"})," 《",e,"》 章节管控中心"]}),(0,n.jsx)("p",{style:{fontSize:11,color:"var(--text-dim)",margin:"4px 0 0 0"},children:"一站式监控防崩审计、设定同步及写作蓝图,防范故事逻辑与人设漂移。"})]}),(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:12},children:[(0,n.jsx)("input",{type:"text",placeholder:"搜索章节或标题...",value:u,onChange:e=>g(e.target.value),style:{padding:"6px 12px",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:6,fontSize:12,color:"var(--text)",width:180,outline:"none"}}),(0,n.jsxs)("button",{onClick:()=>E(),disabled:d,style:{padding:"6px 14px",background:"rgba(96, 165, 250, 0.08)",border:"1px solid rgba(96, 165, 250, 0.3)",borderRadius:6,color:"#60a5fa",fontSize:12,fontWeight:600,cursor:"pointer",display:"flex",alignItems:"center",gap:6},children:[(0,n.jsx)("span",{children:"\uD83D\uDD04"})," 重新扫描"]})]})]}),d&&(0,n.jsxs)("div",{style:{display:"flex",flex:1,alignItems:"center",justifyContent:"center",flexDirection:"column",gap:12},children:[(0,n.jsx)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent)",strokeWidth:"3",strokeLinecap:"round",style:{animation:"spin 1s linear infinite"},children:(0,n.jsx)("path",{d:"M12 2v4M12 18v4M4.93 4.93l2.83 2.83M16.24 16.24l2.83 2.83M2 12h4M18 12h4"})}),(0,n.jsx)("span",{style:{fontSize:13,color:"var(--text-muted)"},children:"正在加载工作区大纲与章节快照,请稍候..."})]}),p&&!d&&(0,n.jsx)("div",{style:{padding:24,overflowY:"auto",flex:1},children:(0,n.jsxs)("div",{style:{padding:"16px 20px",background:"rgba(239, 68, 68, 0.06)",border:"1px solid rgba(239, 68, 68, 0.2)",borderRadius:8,color:"#ef4444"},children:[(0,n.jsx)("h3",{style:{margin:"0 0 8px 0",fontSize:14},children:"⚠️ 加载失败"}),(0,n.jsx)("p",{style:{fontSize:13,margin:0},children:p}),(0,n.jsx)("p",{style:{fontSize:12,margin:"12px 0 0 0",color:"var(--text-muted)"},children:"请确保您当前的工作区已初始化。可以在侧边栏点击「一键开启创作宇宙」进行初始化检测。"})]})}),!d&&!p&&(0,n.jsxs)("div",{style:{flex:1,overflowY:"auto",display:"flex",flexDirection:"column"},children:[(0,n.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:16,padding:"20px 24px"},children:[(0,n.jsxs)("div",{style:{padding:16,background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:10},children:[(0,n.jsx)("div",{style:{fontSize:11,color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.05em"},children:"总章节数"}),(0,n.jsxs)("div",{style:{fontSize:24,fontWeight:700,marginTop:8,color:"var(--text)"},children:[P," ",(0,n.jsx)("span",{style:{fontSize:14,fontWeight:400,color:"var(--text-dim)"},children:"章"})]})]}),(0,n.jsxs)("div",{style:{padding:16,background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:10},children:[(0,n.jsx)("div",{style:{fontSize:11,color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.05em"},children:"离线审计过审率"}),(0,n.jsxs)("div",{style:{fontSize:24,fontWeight:700,marginTop:8,color:V>=80?"#10b981":"#eab308"},children:[V,"%"]}),(0,n.jsxs)("div",{style:{fontSize:10,color:"var(--text-dim)",marginTop:6},children:["已审核过审 ",H," 章"]})]}),(0,n.jsxs)("div",{style:{padding:16,background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:10},children:[(0,n.jsx)("div",{style:{fontSize:11,color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.05em"},children:"异常章节 (审计失败 / 状态漂移)"}),(0,n.jsxs)("div",{style:{fontSize:24,fontWeight:700,marginTop:8,color:_+J>0?"#ef4444":"#10b981"},children:[_+J," ",(0,n.jsx)("span",{style:{fontSize:14,fontWeight:400,color:"var(--text-dim)"},children:"处"})]}),(0,n.jsxs)("div",{style:{fontSize:10,color:"var(--text-dim)",marginTop:6},children:["审计不合规 ",_," | 设定失步 ",J]})]}),(0,n.jsxs)("div",{style:{padding:16,background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:10},children:[(0,n.jsx)("div",{style:{fontSize:11,color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.05em"},children:"大纲蓝图覆盖度"}),(0,n.jsxs)("div",{style:{fontSize:24,fontWeight:700,marginTop:8,color:"#a855f7"},children:[Y,"%"]}),(0,n.jsxs)("div",{style:{fontSize:10,color:"var(--text-dim)",marginTop:6},children:["已规划意图 ",U," / ",P," 章"]})]})]}),(0,n.jsx)("div",{style:{padding:"0 24px 24px 24px",flex:1,display:"flex",flexDirection:"column"},children:(0,n.jsxs)("div",{style:{flex:1,border:"1px solid var(--border)",borderRadius:10,background:"var(--bg-panel)",overflow:"hidden",display:"flex",flexDirection:"column"},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",padding:"10px 16px",background:"var(--bg-hover)",borderBottom:"1px solid var(--border)",fontSize:11,fontWeight:600,color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.03em"},children:[(0,n.jsx)("div",{style:{width:"60px",flexShrink:0},children:"章节"}),(0,n.jsx)("div",{style:{flex:1,minWidth:150},children:"章节名称"}),(0,n.jsx)("div",{style:{width:"100px",flexShrink:0},children:"防崩审计"}),(0,n.jsx)("div",{style:{width:"100px",flexShrink:0},children:"设定同步"}),(0,n.jsx)("div",{style:{width:"100px",flexShrink:0},children:"意图蓝图"}),(0,n.jsx)("div",{style:{width:"110px",flexShrink:0},children:"审核决策"}),(0,n.jsx)("div",{style:{width:"230px",flexShrink:0,textAlign:"right"},children:"系统动作"})]}),(0,n.jsx)("div",{style:{flex:1,overflowY:"auto"},children:0===N.length?(0,n.jsx)("div",{style:{padding:48,textAlign:"center",color:"var(--text-dim)",fontSize:12},children:"没有找到符合条件的章节。"}):N.map(e=>{let t="audit"===h[e.number],r="sync"===h[e.number],o=!!h[e.number],i=v.has(e.number),l=b[e.number]||[];return(0,n.jsxs)("div",{style:{borderBottom:"1px solid var(--border)",background:i?"rgba(255,255,255,0.01)":"transparent"},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",padding:"12px 16px",fontSize:12,transition:"background 0.15s"},onMouseEnter:e=>{i||(e.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:e=>{i||(e.currentTarget.style.background="transparent")},children:[(0,n.jsxs)("div",{style:{width:"60px",flexShrink:0,fontFamily:"var(--font-mono)",color:"var(--text-dim)"},children:["Ch.",e.number]}),(0,n.jsxs)("div",{style:{flex:1,minWidth:150,paddingRight:10},children:[(0,n.jsx)("span",{onClick:()=>F(e.number,e.title),style:{fontWeight:600,cursor:"pointer",borderBottom:"1px dashed transparent",transition:"all 0.15s"},onMouseEnter:e=>{e.currentTarget.style.color="var(--accent)",e.currentTarget.style.borderBottomColor="var(--accent)"},onMouseLeave:e=>{e.currentTarget.style.color="inherit",e.currentTarget.style.borderBottomColor="transparent"},title:"点击打开文件编辑器",children:e.title}),(0,n.jsxs)("div",{style:{fontSize:10,color:"var(--text-dim)",marginTop:3},children:[e.wordCount," 字 | ",new Date(e.updatedAt).toLocaleString("zh-CN")]})]}),(0,n.jsx)("div",{style:{width:"100px",flexShrink:0},children:(0,n.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:4,padding:"2px 6px",borderRadius:4,fontSize:10,fontWeight:600,background:"approved"===e.status?"rgba(16, 185, 129, 0.08)":"ready-for-review"===e.status?"rgba(234, 179, 8, 0.08)":"audit-failed"===e.status?"rgba(239, 68, 68, 0.08)":"var(--bg)",color:"approved"===e.status?"#10b981":"ready-for-review"===e.status?"#eab308":"audit-failed"===e.status?"#ef4444":"var(--text-muted)",border:`1px solid ${"approved"===e.status?"#10b98133":"ready-for-review"===e.status?"#eab30833":"audit-failed"===e.status?"#ef444433":"var(--border)"}`},children:[(0,n.jsx)("span",{style:{width:5,height:5,borderRadius:"50%",background:"approved"===e.status?"#10b981":"ready-for-review"===e.status?"#eab308":"audit-failed"===e.status?"#ef4444":"#9ca3af"}}),"approved"===e.status?"审计通过":"ready-for-review"===e.status?"待审核":"audit-failed"===e.status?"审计未过":"未审计"]})}),(0,n.jsx)("div",{style:{width:"100px",flexShrink:0},children:(0,n.jsx)("span",{style:{display:"inline-flex",alignItems:"center",gap:4,padding:"2px 6px",borderRadius:4,fontSize:10,fontWeight:600,background:"state-degraded"===e.status?"rgba(239, 68, 68, 0.08)":e.hasSnapshot?"rgba(16, 185, 129, 0.08)":"var(--bg)",color:"state-degraded"===e.status?"#ef4444":e.hasSnapshot?"#10b981":"var(--text-muted)",border:`1px solid ${"state-degraded"===e.status?"#ef444433":e.hasSnapshot?"#10b98133":"var(--border)"}`},children:"state-degraded"===e.status?"⚠️ 设定失步":e.hasSnapshot?"\uD83D\uDD04 已同步":"⚪ 未同步"})}),(0,n.jsx)("div",{style:{width:"100px",flexShrink:0},children:(0,n.jsx)("span",{style:{display:"inline-flex",alignItems:"center",gap:4,padding:"2px 6px",borderRadius:4,fontSize:10,fontWeight:600,background:e.hasPlan?"rgba(168, 85, 247, 0.08)":"var(--bg)",color:e.hasPlan?"#a855f7":"var(--text-muted)",border:`1px solid ${e.hasPlan?"#a855f733":"var(--border)"}`},children:e.hasPlan?"\uD83D\uDDFA️ 已规划":"⚪ 未规划"})}),(0,n.jsx)("div",{style:{width:"110px",flexShrink:0},children:"approved"!==e.status?(0,n.jsxs)("div",{style:{display:"flex",gap:4},children:[(0,n.jsx)("button",{onClick:()=>A(e.number),disabled:o,style:{padding:"2px 6px",fontSize:10,background:"rgba(16, 185, 129, 0.08)",border:"1px solid rgba(16, 185, 129, 0.3)",borderRadius:4,color:"#10b981",fontWeight:600,cursor:o?"not-allowed":"pointer"},title:"批准章节",children:"批准"}),(0,n.jsx)("button",{onClick:()=>{T(e.number),I(""),L(!1)},disabled:o,style:{padding:"2px 6px",fontSize:10,background:"rgba(239, 68, 68, 0.08)",border:"1px solid rgba(239, 68, 68, 0.3)",borderRadius:4,color:"#ef4444",fontWeight:600,cursor:o?"not-allowed":"pointer"},title:"驳回回滚章节",children:"驳回"})]}):(0,n.jsx)("span",{style:{fontSize:10,color:"var(--text-dim)",fontStyle:"italic"},children:"状态已锁定过审"})}),(0,n.jsxs)("div",{style:{width:"230px",flexShrink:0,display:"flex",justifyContent:"flex-end",gap:6},children:[(0,n.jsx)("button",{onClick:()=>{k(e),S(!0)},style:{padding:"4px 8px",fontSize:10,background:"none",border:"1px solid var(--border)",borderRadius:5,color:"var(--text-muted)",cursor:"pointer"},children:"\uD83D\uDCCB 详情"}),(0,n.jsx)("button",{onClick:()=>B(e.number,"audit","audit"),disabled:o,style:{padding:"4px 8px",fontSize:10,background:"rgba(59, 130, 246, 0.08)",border:"1px solid rgba(59, 130, 246, 0.3)",borderRadius:5,color:"#60a5fa",fontWeight:600,cursor:o?"not-allowed":"pointer"},title:"运行防崩审计",children:t?"⏳ 审计":"\uD83D\uDEE1️ 审计"}),(0,n.jsx)("button",{onClick:()=>B(e.number,"sync","write-sync"),disabled:o,style:{padding:"4px 8px",fontSize:10,background:"rgba(16, 185, 129, 0.08)",border:"1px solid rgba(16, 185, 129, 0.3)",borderRadius:5,color:"#10b981",fontWeight:600,cursor:o?"not-allowed":"pointer"},title:"同步故事设定",children:r?"⏳ 同步":"\uD83D\uDD04 同步"}),l.length>0&&(0,n.jsx)("button",{onClick:()=>$(e.number),style:{padding:"4px",fontSize:10,background:i?"var(--bg-hover)":"none",border:"1px solid var(--border)",borderRadius:5,color:"var(--text-dim)",cursor:"pointer",display:"flex",alignItems:"center"},title:"切换日志显示",children:"\uD83D\uDDA5️"})]})]}),i&&(0,n.jsxs)("div",{style:{background:"rgba(10, 10, 15, 0.95)",borderTop:"1px solid var(--border)",borderBottom:"1px solid var(--border)",padding:"10px 16px"},children:[(0,n.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:6},children:[(0,n.jsxs)("span",{style:{fontSize:9,fontFamily:"var(--font-mono)",color:"rgba(16, 185, 129, 0.8)",fontWeight:700},children:["TERMINAL LOGS :: CHAPTER ",e.number," :: CLI OUTPUT"]}),(0,n.jsx)("button",{onClick:()=>$(e.number),style:{background:"none",border:"none",color:"#ef4444",fontSize:10,cursor:"pointer",fontWeight:600},children:"收起日志 [✕]"})]}),(0,n.jsx)("div",{ref:t=>{W.current[e.number]=t},style:{maxHeight:"160px",overflowY:"auto",fontFamily:"var(--font-mono)",fontSize:"11px",color:"#f3f4f6",whiteSpace:"pre-wrap",padding:"8px",background:"#09090b",border:"1px solid rgba(255,255,255,0.05)",borderRadius:5,lineHeight:1.5},children:0===l.length?(0,n.jsx)("span",{style:{color:"var(--text-dim)"},children:"正在启动 InkOS 引擎子进程..."}):l.join("")})]})]},e.number)})}),s&&(0,n.jsxs)("div",{style:{padding:"16px 20px",background:"var(--bg-hover)",borderTop:"1px solid var(--border)",display:"flex",alignItems:"center",justifyContent:"space-between",fontSize:12},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:12},children:[(0,n.jsx)("span",{style:{fontSize:16},children:"\uD83D\uDDFA️"}),(0,n.jsxs)("div",{children:[(0,n.jsxs)("strong",{style:{color:"var(--text)"},children:["下一章节写作规划:第 ",s.number," 章"]}),(0,n.jsx)("span",{style:{fontSize:11,color:"var(--text-muted)",marginLeft:10},children:s.hasPlan?"\uD83D\uDFE2 意图蓝图已就绪。续写时将自动装载。":"⚪ 当前无规划蓝图,系统将自动使用通用大纲生成。建议前置规划以微调目标。"})]})]}),(0,n.jsxs)("div",{style:{display:"flex",gap:8},children:[s.hasPlan&&(0,n.jsx)("button",{onClick:()=>{r(`${t}/books/${e}/story/runtime/chapter-${String(s.number).padStart(4,"0")}.intent.md`,`chapter-${String(s.number).padStart(4,"0")}.intent.md`)},style:{padding:"6px 12px",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:6,color:"var(--text)",cursor:"pointer",fontWeight:600},children:"\uD83D\uDC41️ 查看意图蓝图"}),(0,n.jsx)("button",{onClick:()=>B(s.number,"plan","plan"),disabled:!!h[s.number],style:{padding:"6px 14px",background:"rgba(168, 85, 247, 0.08)",border:"1px solid rgba(168, 85, 247, 0.3)",borderRadius:6,color:"#c084fc",cursor:"pointer",fontWeight:600,display:"flex",alignItems:"center",gap:6},children:"plan"===h[s.number]?"⏳ 规划中...":"\uD83D\uDDFA️ 规划下一章意图"})]})]})]})})]}),null!==C&&(0,n.jsx)("div",{style:{position:"fixed",inset:0,zIndex:1100,background:"rgba(10, 8, 8, 0.4)",backdropFilter:"blur(6px)",display:"flex",alignItems:"center",justifyContent:"center"},children:(0,n.jsxs)("div",{style:{width:"480px",background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:"12px",boxShadow:"0 20px 40px rgba(0, 0, 0, 0.35)",padding:"20px 24px"},children:[(0,n.jsxs)("h3",{style:{margin:"0 0 12px 0",fontSize:15,fontWeight:700,color:"#ef4444",display:"flex",alignItems:"center",gap:8},children:[(0,n.jsx)("span",{children:"⚠️"})," 确定驳回并执行回滚吗?"]}),(0,n.jsxs)("div",{style:{fontSize:13,color:"var(--text)",lineHeight:1.6,marginBottom:16},children:["您确定要驳回 ",(0,n.jsxs)("strong",{style:{color:"var(--accent)"},children:["第 ",C," 章"]})," 吗?",(0,n.jsxs)("div",{style:{marginTop:8,padding:"8px 12px",background:"rgba(239, 68, 68, 0.04)",border:"1px solid rgba(239, 68, 68, 0.15)",borderRadius:6,color:"#f87171",fontSize:12},children:["**重要警告**:此驳回操作将自动**回滚系统设定到第 ",C-1," 章**的快照点。 在磁盘上,**第 ",C," 章及之后的所有后续章节草稿、运行时蓝图和修改快照均会被永久物理删除**以维持故事连贯性!"]})]}),(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6,marginBottom:20},children:[(0,n.jsx)("label",{style:{fontSize:11,color:"var(--text-muted)",fontWeight:600},children:"驳回原因 (可选):"}),(0,n.jsx)("textarea",{value:z,onChange:e=>I(e.target.value),placeholder:"在此输入驳回该章节的原因/修改意见...",style:{height:"70px",padding:"8px",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:6,color:"var(--text)",fontSize:12,fontFamily:"var(--font-serif)",resize:"none",outline:"none"}})]}),(0,n.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[(0,n.jsx)("button",{onClick:()=>T(null),disabled:R,style:{padding:"6px 14px",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:6,color:"var(--text-muted)",cursor:"pointer",fontSize:12},children:"取消"}),(0,n.jsx)("button",{onClick:O,disabled:R,style:{padding:"6px 14px",background:"#ef4444",border:"none",borderRadius:6,color:"#fff",fontWeight:600,cursor:"pointer",fontSize:12},children:R?"正在回滚...":"\uD83D\uDEA8 确定驳回并删除后续"})]})]})}),w&&j&&(0,n.jsxs)("div",{style:{position:"fixed",inset:0,zIndex:1050,display:"flex",justifyContent:"flex-end",background:"rgba(0,0,0,0.2)",backdropFilter:"blur(2px)"},children:[(0,n.jsx)("div",{style:{flex:1},onClick:()=>S(!1)}),(0,n.jsxs)("div",{style:{width:"480px",height:"100%",background:"var(--bg-panel)",borderLeft:"1px solid var(--border)",boxShadow:"-10px 0 30px rgba(0,0,0,0.2)",display:"flex",flexDirection:"column",animation:"slideIn 0.25s ease-out"},children:[(0,n.jsxs)("div",{style:{padding:"16px 20px",borderBottom:"1px solid var(--border)",display:"flex",alignItems:"center",justifyContent:"space-between",background:"var(--bg-hover)"},children:[(0,n.jsxs)("div",{children:[(0,n.jsxs)("h3",{style:{margin:0,fontSize:14,fontWeight:700},children:["章节详情报告 - Ch.",j.number]}),(0,n.jsx)("span",{style:{fontSize:10,color:"var(--text-muted)"},children:j.title})]}),(0,n.jsx)("button",{onClick:()=>S(!1),style:{background:"none",border:"none",color:"var(--text-muted)",fontSize:16,cursor:"pointer"},children:"✕"})]}),(0,n.jsxs)("div",{style:{flex:1,overflowY:"auto",padding:"20px",display:"flex",flexDirection:"column",gap:20},children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("h4",{style:{margin:"0 0 10px 0",fontSize:12,color:"var(--text-muted)",textTransform:"uppercase"},children:"基本元数据"}),(0,n.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12,background:"var(--bg)",padding:12,borderRadius:8,border:"1px solid var(--border)",fontSize:12},children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("span",{style:{color:"var(--text-dim)"},children:"章节字数:"}),(0,n.jsxs)("strong",{style:{color:"var(--text)"},children:[j.wordCount," 字"]})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("span",{style:{color:"var(--text-dim)"},children:"流程状态:"}),(0,n.jsx)("strong",{style:{color:"var(--text)"},children:j.status})]}),(0,n.jsxs)("div",{style:{gridColumn:"span 2"},children:[(0,n.jsx)("span",{style:{color:"var(--text-dim)"},children:"创建时间:"}),(0,n.jsx)("span",{style:{color:"var(--text)"},children:new Date(j.createdAt).toLocaleString("zh-CN")})]}),(0,n.jsxs)("div",{style:{gridColumn:"span 2"},children:[(0,n.jsx)("span",{style:{color:"var(--text-dim)"},children:"最后修改:"}),(0,n.jsx)("span",{style:{color:"var(--text)"},children:new Date(j.updatedAt).toLocaleString("zh-CN")})]})]})]}),j.reviewNote&&(0,n.jsxs)("div",{style:{padding:"12px 14px",background:"rgba(239,68,68,0.03)",border:"1px dashed rgba(239,68,68,0.25)",borderRadius:8},children:[(0,n.jsx)("h4",{style:{margin:"0 0 6px 0",fontSize:12,color:"#ef4444"},children:"\uD83D\uDEA9 历史驳回备注"}),(0,n.jsx)("p",{style:{fontSize:12,margin:0,lineHeight:1.5,color:"var(--text)"},children:j.reviewNote})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("h4",{style:{margin:"0 0 10px 0",fontSize:12,color:"var(--text-muted)",textTransform:"uppercase"},children:"\uD83D\uDCCF 字数管控指标"}),j.lengthWarnings&&j.lengthWarnings.length>0?(0,n.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:8},children:j.lengthWarnings.map((e,t)=>(0,n.jsxs)("div",{style:{padding:"10px 14px",background:"rgba(234,179,8,0.03)",borderLeft:"3px solid #eab308",border:"1px solid rgba(234,179,8,0.15)",borderRadius:6,fontSize:11,color:"var(--text)",lineHeight:1.5},children:["⚠️ ",e]},t))}):(0,n.jsx)("div",{style:{fontSize:11,color:"#10b981",background:"rgba(16,185,129,0.04)",border:"1px solid rgba(16,185,129,0.15)",padding:"10px 12px",borderRadius:6},children:"✓ 字数控制处于健康范围内,未触发偏多/偏少警告。"})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("h4",{style:{margin:"0 0 10px 0",fontSize:12,color:"var(--text-muted)",textTransform:"uppercase"},children:"\uD83D\uDEE1️ 防崩一致性审计"}),j.auditIssues&&j.auditIssues.length>0?(0,n.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:j.auditIssues.map((e,t)=>{let r=e.match(/^\[(critical|warning|info)\]\s*(.*)$/i),o=r?r[1].toLowerCase():"info",i=r?r[2]:e,l="critical"===o?"#ef4444":"warning"===o?"#eab308":"#3b82f6";return(0,n.jsxs)("div",{style:{padding:"12px 14px",background:"var(--bg)",border:"1px solid var(--border)",borderLeft:`3px solid ${l}`,borderRadius:6,display:"flex",flexDirection:"column",gap:4},children:[(0,n.jsx)("div",{style:{display:"flex",alignItems:"center",gap:8},children:(0,n.jsx)("span",{style:{fontSize:10,fontWeight:700,color:l,textTransform:"uppercase"},children:"critical"===o?"严重错误":"warning"===o?"潜在风险":"风格建议"})}),(0,n.jsx)("p",{style:{fontSize:12,margin:0,color:"var(--text)",lineHeight:1.6},children:i})]},t)})}):(0,n.jsx)("div",{style:{fontSize:11,color:"#10b981",background:"rgba(16,185,129,0.04)",border:"1px solid rgba(16,185,129,0.15)",padding:"10px 12px",borderRadius:6},children:"✓ 本章未发现任何设定连续性矛盾或逻辑硬伤。"})]})]}),(0,n.jsx)("div",{style:{padding:"16px 20px",borderTop:"1px solid var(--border)",background:"var(--bg-hover)",display:"flex",justifyContent:"flex-end"},children:(0,n.jsx)("button",{onClick:()=>{S(!1),F(j.number,j.title)},style:{padding:"8px 16px",background:"var(--accent)",border:"none",borderRadius:6,color:"#fff",fontWeight:600,fontSize:12,cursor:"pointer"},children:"✍️ 进入正文编辑器"})})]})]})]})}function tq(){let e=(0,i.useSearchParams)(),{isDark:t,toggleTheme:r}=eF(),[l,s]=(0,o.useState)(null),[a,d]=(0,o.useState)(null),[c,p]=(0,o.useState)(null),[x,u]=(0,o.useState)(0),[g,h]=(0,o.useState)(0),[f,b]=(0,o.useState)(0),[y,v]=(0,o.useState)(!1),[m,j]=(0,o.useState)(0),[k,w]=(0,o.useState)(!1),[S,C]=(0,o.useState)(!1),[T,z]=(0,o.useState)(!1),[I,R]=(0,o.useState)(!0),[L,W]=(0,o.useState)(null),[E,M]=(0,o.useState)(!0),D=(0,o.useRef)(null),$=(0,o.useRef)(null),[B,A]=(0,o.useState)([]),[O,F]=(0,o.useState)(null),N=(0,o.useRef)(null),P=(0,o.useCallback)((e,t,r)=>{A(e),F(t),N.current=r},[]);(0,o.useCallback)(e=>{N.current?.(e)},[]);let[H,_]=(0,o.useState)(null);(0,o.useRef)(null);let J=(0,o.useCallback)(e=>{_(e)},[]),[U,V]=(0,o.useState)(null),Y=(0,o.useCallback)(e=>{V(e)},[]),[K,G]=(0,o.useState)(null),q=(0,o.useCallback)(e=>{G(e)},[]),[X,Q]=(0,o.useState)(null),[ee,et]=(0,o.useState)(null);(0,o.useCallback)(e=>{Q(t=>t===e?null:e)},[]),(0,o.useEffect)(()=>{if(!X||!$.current)return;let e=()=>{let e=$.current.getBoundingClientRect();et({top:e.bottom,left:e.left,width:e.width})};e();let t=new ResizeObserver(e);return t.observe($.current),()=>t.disconnect()},[X]),(0,o.useEffect)(()=>{let e=localStorage.getItem("ink-show-execution-confirm");null!==e?R("true"===e):R(!0);let t=e=>{e.detail&&R(e.detail.showExecutionConfirm)};return window.addEventListener("ink-settings-changed",t),()=>{window.removeEventListener("ink-settings-changed",t)}},[]);let[er,en]=(0,o.useState)([]),[eo,ei]=(0,o.useState)(null),[el,es]=(0,o.useState)(()=>!!new URLSearchParams(window.location.search).get("session")),ea=(0,o.useCallback)(e=>{D.current?.insertText("`"+e+"`")},[]),[ed]=(0,o.useState)(()=>e.get("session")),[ec,ep]=(0,o.useState)(null),[ex,eu]=(0,o.useState)(()=>!e.get("session")),eg=(0,o.useRef)(!1),eh=(0,o.useCallback)(e=>{ep(e),e&&!eg.current&&(s(t=>t&&t.cwd!==e?null:t),d(t=>t&&t!==e?null:t),h(e=>e+1),A([]),F(null),_(null),Q(null),window.history.replaceState(null,"","/"))},[]),ef=(0,o.useCallback)((e,t=!1)=>{d(null),s(e),p(null),h(e=>e+1),_(null),eu(!0),t&&(eg.current=!0,setTimeout(()=>{eg.current=!1},0)),t||window.history.replaceState(null,"",`?session=${encodeURIComponent(e.id)}`),es(!0)},[]),eb=(0,o.useCallback)((e,t,r)=>{s(null),d(t),p(r??null),h(e=>e+1),A([]),F(null),_(null),Q(null),window.history.replaceState(null,"","/"),es(!0)},[]),ey=(0,o.useCallback)(e=>{d(null),s(e),p(null),u(e=>e+1),window.history.replaceState(null,"",`?session=${encodeURIComponent(e.id)}`),es(!0)},[]),ev=(0,o.useCallback)(()=>{u(e=>e+1),b(e=>e+1)},[]),em=(0,o.useCallback)(e=>{u(e=>e+1),h(e=>e+1),d(null),s(t=>({...t??{path:"",cwd:"",created:"",modified:"",messageCount:0,firstMessage:""},id:e})),window.history.replaceState(null,"",`?session=${encodeURIComponent(e)}`),es(!0)},[]),ej=(0,o.useCallback)(()=>{eu(!0)},[]),ek=(0,o.useCallback)(e=>{if(u(e=>e+1),l?.id===e){let e=l.cwd;s(null),d(e??null),h(e=>e+1),A([]),F(null),_(null),Q(null),window.history.replaceState(null,"","/")}},[l]),ew=(0,o.useCallback)(e=>{en(t=>{let r=t.filter(t=>t.id!==e);return 0===r.length&&es(!1),r}),ei(t=>{if(t!==e)return t;let r=er.filter(t=>t.id!==e);return r.length>0?r[r.length-1].id:null})},[er]),eS=(0,o.useCallback)((e,t)=>{let r=`file:${e}`;en(n=>n.find(e=>e.id===r)?n:[...n,{id:r,label:t,filePath:e}]),ei(r),es(!0)},[]),eC=(0,o.useCallback)(e=>{let t=`dashboard:${e}`;en(r=>r.find(e=>e.id===t)?r:[...r,{id:t,label:`📊 ${e} 看板`,filePath:`dashboard:${e}`}]),ei(t),es(!0)},[]);(0,o.useEffect)(()=>{let e=()=>{b(e=>e+1)},t=e=>{e.detail&&eS(e.detail.filePath,e.detail.fileName)},r=e=>{e.detail&&e.detail.filePath&&ew(`file:${e.detail.filePath}`)},n=e=>{if(e.detail&&e.detail.dirPath){let t=e.detail.dirPath.replace(/\\/g,"/").toLowerCase();en(e=>{let r=e.filter(e=>!e.filePath.replace(/\\/g,"/").toLowerCase().startsWith(t));return 0===r.length&&es(!1),ei(e=>e?e.replace(/^file:/,"").replace(/\\/g,"/").toLowerCase().startsWith(t)?r.length>0?r[r.length-1].id:null:e:null),r})}},o=e=>{e.detail&&e.detail.bookId&&eC(e.detail.bookId)};return window.addEventListener("refresh-explorer",e),window.addEventListener("open-file",t),window.addEventListener("close-file",r),window.addEventListener("close-directory",n),window.addEventListener("open-dashboard",o),()=>{window.removeEventListener("refresh-explorer",e),window.removeEventListener("open-file",t),window.removeEventListener("close-file",r),window.removeEventListener("close-directory",n),window.removeEventListener("open-dashboard",o)}},[eS,ew,eC]);let eT=a??(null===l&&ec?ec:null),ez=null!==l||null!==eT,eI=ex&&!ez,eR=er.find(e=>e.id===eo)??null,[eL,eW]=(0,o.useState)([]),[eM,eD]=(0,o.useState)(null),[e$,eB]=(0,o.useState)(!1),[eA,eO]=(0,o.useState)(!1),[eN,eP]=(0,o.useState)(null),[eH,e_]=(0,o.useState)(!1),eJ=(0,o.useCallback)((e,t)=>{eW(e),eD(t),e_(!1)},[]),eU=(0,o.useCallback)(e=>{e_(!0),window.dispatchEvent(new CustomEvent("trigger-style-switch",{detail:{styleName:e}}))},[]),eV=(0,o.useCallback)(e=>{if(e!==(eM||"default")){if(!I)return void eU(e);W({targetStyle:e,onConfirm:()=>{eU(e),W(null)},onCancel:()=>{W(null)}})}},[eM,I,eU]),eY=(0,o.useCallback)((e,t)=>{eB(e),eO(t)},[]),eK=(0,n.jsx)(n.Fragment,{children:(0,n.jsx)(Z,{selectedSessionId:l?.id??null,onSelectSession:ef,onNewSession:eb,initialSessionId:ed,onInitialRestoreDone:ej,refreshKey:x,onSessionDeleted:ek,selectedCwd:l?.cwd??a??null,onCwdChange:eh,onOpenFile:eS,explorerRefreshKey:f,onAtMention:ea,activeGemId:c,availableStyles:eL,activeStyleName:eM,onStylesChange:eJ,onWorkspaceStatusChange:eY,onActiveBookChange:eP})});return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{style:{display:"flex",height:"100dvh",overflow:"hidden",background:"var(--bg)"},children:[(0,n.jsx)("div",{className:"sidebar-overlay-backdrop",onClick:()=>M(!1),style:{position:"fixed",inset:0,zIndex:199,background:"rgba(0,0,0,0.4)",opacity:+!!E,pointerEvents:E?"auto":"none",transition:"opacity 0.25s ease"}}),(0,n.jsx)("div",{className:`sidebar-container${E?" sidebar-open":" sidebar-closed"}`,style:{background:"var(--bg-panel)",borderRight:"1px solid var(--border)",display:"flex",flexDirection:"column",flexShrink:0,zIndex:200},children:eK}),(0,n.jsxs)("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden",minWidth:0},children:[(0,n.jsxs)("div",{ref:$,style:{display:"flex",alignItems:"center",flexShrink:0,borderBottom:"1px solid var(--border)",height:36,background:"var(--bg-panel)"},children:[(0,n.jsx)("button",{onClick:()=>M(e=>!e),title:E?"Hide sidebar":"Show sidebar",style:{display:"flex",alignItems:"center",justifyContent:"center",width:36,height:36,padding:0,background:"none",border:"none",borderRight:"1px solid var(--border)",color:"var(--text-muted)",cursor:"pointer",flexShrink:0,transition:"color 0.12s"},onMouseEnter:e=>{e.currentTarget.style.color="var(--text)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-muted)"},children:E?(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),(0,n.jsx)("line",{x1:"9",y1:"3",x2:"9",y2:"21"})]}):(0,n.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[(0,n.jsx)("line",{x1:"3",y1:"6",x2:"21",y2:"6"}),(0,n.jsx)("line",{x1:"3",y1:"12",x2:"21",y2:"12"}),(0,n.jsx)("line",{x1:"3",y1:"18",x2:"21",y2:"18"})]})}),e$&&(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",flexShrink:0,height:"100%"},children:[(0,n.jsx)("div",{style:{display:"flex",alignItems:"center",padding:"0 10px",borderRight:"1px solid var(--border)",height:"100%"},children:(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",background:"rgba(99, 102, 241, 0.08)",border:"1px solid rgba(99, 102, 241, 0.4)",borderRadius:"6px",padding:"4px 8px",height:24,transition:"all 0.2s ease"},children:[(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"#818cf8",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{marginRight:4},children:[(0,n.jsx)("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),(0,n.jsx)("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]}),(0,n.jsx)("select",{value:L?L.targetStyle:eM||"default",disabled:eH,onChange:e=>eV(e.target.value),style:{background:"none",color:"#818cf8",border:"none",fontSize:"11px",outline:"none",cursor:eL&&eL.length>1?"pointer":"default",padding:"0 4px",fontWeight:600,fontFamily:"var(--font-serif)"},children:eL&&eL.length>0?eL.map(e=>(0,n.jsx)("option",{value:e,style:{background:"var(--bg-panel)",color:"var(--text)"},children:e},e)):(0,n.jsx)("option",{value:"default",style:{background:"var(--bg-panel)",color:"var(--text)"},children:"default"})})]})}),eA&&eN&&(0,n.jsxs)("button",{onClick:()=>{eC(eN)},title:"章节管控看板 (Chapter Control Center)",style:{display:"flex",alignItems:"center",gap:6,height:"100%",padding:"0 12px",background:"none",border:"none",borderRight:"1px solid var(--border)",color:"var(--text-muted)",cursor:"pointer",fontSize:12,fontWeight:500,transition:"color 0.12s, background 0.12s"},onMouseEnter:e=>{e.currentTarget.style.color="var(--text)",e.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-muted)",e.currentTarget.style.background="none"},children:[(0,n.jsx)("span",{style:{fontSize:12},children:"\uD83D\uDCCA"}),(0,n.jsx)("span",{children:"章节管控看板"})]}),eA&&(0,n.jsxs)("button",{onClick:()=>{window.dispatchEvent(new Event("trigger-style-clone"))},title:"文风克隆工坊 (Style Clone)",style:{display:"flex",alignItems:"center",gap:6,height:"100%",padding:"0 12px",background:"none",border:"none",borderRight:"1px solid var(--border)",color:"var(--text-muted)",cursor:"pointer",fontSize:12,fontWeight:500,transition:"color 0.12s, background 0.12s"},onMouseEnter:e=>{e.currentTarget.style.color="var(--text)",e.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-muted)",e.currentTarget.style.background="none"},children:[(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{marginRight:2},children:[(0,n.jsx)("path",{d:"M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18z"}),(0,n.jsx)("path",{d:"M8 10h.01M16 10h.01",strokeWidth:"3"}),(0,n.jsx)("path",{d:"M12 14a3 3 0 0 0-3 3h6a3 3 0 0 0-3-3z"})]}),(0,n.jsx)("span",{children:"文风克隆工坊"})]}),(0,n.jsxs)("button",{onClick:()=>{window.dispatchEvent(new Event("trigger-radar"))},title:"市场雷达 (Market Intelligence Scan)",style:{display:"flex",alignItems:"center",gap:6,height:"100%",padding:"0 12px",background:"none",border:"none",borderRight:"1px solid var(--border)",color:"var(--text-muted)",cursor:"pointer",fontSize:12,fontWeight:500,transition:"color 0.12s, background 0.12s"},onMouseEnter:e=>{e.currentTarget.style.color="var(--text)",e.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-muted)",e.currentTarget.style.background="none"},children:[(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{marginRight:2},children:[(0,n.jsx)("path",{d:"M12 22c5.523 0 10-4.477 10-10S17.523 2 12 2 2 6.477 2 12s4.477 10 10 10z"}),(0,n.jsx)("path",{d:"M12 17c2.761 0 5-2.239 5-5s-2.239-5-5-5-5 2.239-5 5 2.239 5 5 5z"}),(0,n.jsx)("circle",{cx:"12",cy:"12",r:"1",fill:"currentColor"})]}),(0,n.jsx)("span",{children:"市场雷达"})]})]}),ez&&(U||K)&&(()=>{let e=U?.tokens,t=U?.cost??0,r=e=>e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(0)}k`:String(e),o=t>0?t>=.01?`$${t.toFixed(2)}`:"<$0.01":null,i="var(--text-muted)",l=null;if(K?.contextWindow){let e=K.percent;null!==e&&e>90?i="#ef4444":null!==e&&e>70&&(i="rgba(234,179,8,0.95)"),l=null!==e?`${e.toFixed(0)}% / ${r(K.contextWindow)}`:`? / ${r(K.contextWindow)}`}let s=[];if(e&&(s.push(`in: ${e.input.toLocaleString()}`),s.push(`out: ${e.output.toLocaleString()}`),s.push(`cache read: ${e.cacheRead.toLocaleString()}`),s.push(`cache write: ${e.cacheWrite.toLocaleString()}`),t>0&&s.push(`cost: $${t.toFixed(4)}`)),K?.contextWindow){let e=K.percent;s.push(`context: ${null!==e?e.toFixed(1)+"%":"unknown"} of ${K.contextWindow.toLocaleString()} tokens`)}let a=s.join(" | ");return(0,n.jsxs)("div",{title:a,style:{marginLeft:"auto",flex:"0 1 auto",minWidth:0,overflow:"hidden",display:"flex",alignItems:"center",gap:10,paddingLeft:12,paddingRight:el?12:156,height:"100%",fontSize:11,color:"var(--text-muted)",whiteSpace:"nowrap",cursor:"default",fontVariantNumeric:"tabular-nums"},children:[e&&e.input>0&&(0,n.jsxs)("span",{style:{display:"flex",alignItems:"center",gap:4},children:[(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("line",{x1:"5",y1:"8.5",x2:"5",y2:"1.5"}),(0,n.jsx)("polyline",{points:"2 4 5 1.5 8 4"})]}),r(e.input)]}),e&&e.output>0&&(0,n.jsxs)("span",{style:{display:"flex",alignItems:"center",gap:4},children:[(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("line",{x1:"5",y1:"1.5",x2:"5",y2:"8.5"}),(0,n.jsx)("polyline",{points:"2 6 5 8.5 8 6"})]}),r(e.output)]}),e&&e.cacheRead>0&&(0,n.jsxs)("span",{style:{display:"flex",alignItems:"center",gap:4},children:[(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M8.5 5a3.5 3.5 0 1 1-1-2.45"}),(0,n.jsx)("polyline",{points:"6.5 1.5 8.5 2.5 7.5 4.5"})]}),r(e.cacheRead)]}),o&&(0,n.jsx)("span",{style:{display:"flex",alignItems:"center",color:"var(--text)",fontWeight:500},children:o}),l&&(0,n.jsxs)("span",{style:{display:"flex",alignItems:"center",gap:4,color:i},children:[(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M1 9 L1 5 Q1 1 5 1 Q9 1 9 5 L9 9"}),(0,n.jsx)("line",{x1:"1",y1:"9",x2:"9",y2:"9"})]}),l]})]})})(),X&&ee&&(0,n.jsx)("div",{style:{position:"fixed",top:ee.top,left:ee.left,width:ee.width,zIndex:500},children:"system"===X&&(0,n.jsx)("div",{style:{background:"var(--bg-panel)",borderBottom:"1px solid var(--border)"},children:H?(0,n.jsx)("div",{style:{maxHeight:"min(600px, 75vh)",overflowY:"auto",padding:"12px 16px",color:"var(--text-muted)",fontSize:12,lineHeight:1.6,whiteSpace:"pre-wrap",fontFamily:"var(--font-mono)"},children:H}):""===H?(0,n.jsx)("div",{style:{padding:"10px 16px",fontSize:12,color:"var(--text-muted)",fontStyle:"italic"},children:"System prompt is empty (tools are disabled)"}):(0,n.jsx)("div",{style:{padding:"10px 16px",fontSize:12,color:"var(--text-muted)",fontStyle:"italic"},children:"Send a message to load the system prompt"})})})]}),(0,n.jsx)("div",{style:{display:"flex",alignItems:"center",flexShrink:0,background:"var(--bg-panel)",borderBottom:"1px solid var(--border)",height:36},children:(0,n.jsx)("div",{style:{flex:1,overflow:"hidden"},children:(0,n.jsx)(e6,{tabs:er,activeTabId:eo??"",onSelectTab:ei,onCloseTab:ew})})}),(0,n.jsx)("div",{style:{flex:1,overflow:"hidden",position:"relative",background:"var(--bg)"},children:eR?.filePath?eR.filePath.startsWith("dashboard:")?(0,n.jsx)(tG,{bookId:eR.filePath.substring(10),cwd:ec,onOpenFile:eS}):(0,n.jsx)(e2,{filePath:eR.filePath,cwd:ec??void 0,availableStyles:eL,activeStyleName:eM,showExecutionConfirm:I}):(0,n.jsxs)("div",{style:{height:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",color:"var(--text-muted)",padding:32,textAlign:"center"},children:[(0,n.jsx)("div",{style:{fontSize:48,marginBottom:16},children:"✍️"}),(0,n.jsx)("div",{style:{fontSize:16,fontWeight:600,color:"var(--text)",marginBottom:8},children:"开始您的文学创作之旅"}),(0,n.jsx)("div",{style:{fontSize:13,color:"var(--text-dim)",maxWidth:360,lineHeight:1.6},children:"在左侧“项目目录”中选择故事大纲、章节草稿或人设卡片,即可在此开启沉浸式 Zen 模式协同写作。"})]})})]}),(0,n.jsxs)("div",{className:`right-panel-container${el?" right-panel-open":" right-panel-closed"}`,style:{display:"flex",flexDirection:"column",borderLeft:"1px solid var(--border)",background:"var(--bg)"},children:[(0,n.jsx)("div",{style:{display:"flex",alignItems:"center",flexShrink:0,background:"var(--bg-panel)",borderBottom:"1px solid var(--border)",height:36,padding:"0 12px"},children:(0,n.jsxs)("span",{style:{fontSize:12,fontWeight:600,color:"var(--text)",display:"flex",alignItems:"center",gap:6},children:[(0,n.jsx)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent)",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})}),"写作协同姬 (AI Copilot)"]})}),(0,n.jsx)("div",{style:{flex:1,overflow:"hidden",position:"relative"},children:ez?(0,n.jsx)(eE,{session:l,newSessionCwd:eT,onAgentEnd:ev,onSessionCreated:ey,onSessionForked:em,modelsRefreshKey:m,chatInputRef:D,onBranchDataChange:P,onSystemPromptChange:J,onSessionStatsChange:Y,onContextUsageChange:q,activeGemId:c}):eI?ec?(0,n.jsx)("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--text-muted)",fontSize:13,padding:16,textAlign:"center"},children:"请在左侧侧边栏中选择或新建写作会话以激活 AI 写作姬。"}):(0,n.jsxs)("div",{style:{position:"absolute",top:12,left:12,display:"flex",alignItems:"flex-start",gap:8,userSelect:"none",pointerEvents:"none"},children:[(0,n.jsxs)("svg",{width:"32",height:"32",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",style:{opacity:.7,flexShrink:0},children:[(0,n.jsx)("line",{x1:"20",y1:"12",x2:"4",y2:"12"}),(0,n.jsx)("polyline",{points:"10 6 4 12 10 18"})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{style:{fontSize:14,fontWeight:600,color:"var(--text)",marginBottom:4},children:"创作起航"}),(0,n.jsxs)("div",{style:{fontSize:11,color:"var(--text-muted)",lineHeight:1.6},children:["1. 在左侧选择项目工作区",(0,n.jsx)("br",{}),"2. 点击底部 Models 键配置模型"]})]})]}):null})]})]}),(0,n.jsx)("button",{onClick:()=>v(!0),title:"配置模型",style:{position:"fixed",top:0,right:144,zIndex:300,display:"flex",alignItems:"center",justifyContent:"center",width:36,height:36,padding:0,background:"var(--bg-panel)",border:"none",borderLeft:"1px solid var(--border)",borderBottom:"1px solid var(--border)",color:"var(--text-muted)",cursor:"pointer",transition:"color 0.12s"},onMouseEnter:e=>{e.currentTarget.style.color="var(--text)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-muted)"},children:(0,n.jsxs)("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"}),(0,n.jsx)("rect",{x:"9",y:"9",width:"6",height:"6"}),(0,n.jsx)("line",{x1:"9",y1:"1",x2:"9",y2:"4"}),(0,n.jsx)("line",{x1:"15",y1:"1",x2:"15",y2:"4"}),(0,n.jsx)("line",{x1:"9",y1:"20",x2:"9",y2:"23"}),(0,n.jsx)("line",{x1:"15",y1:"20",x2:"15",y2:"23"}),(0,n.jsx)("line",{x1:"20",y1:"9",x2:"23",y2:"9"}),(0,n.jsx)("line",{x1:"20",y1:"14",x2:"23",y2:"14"}),(0,n.jsx)("line",{x1:"1",y1:"9",x2:"4",y2:"9"}),(0,n.jsx)("line",{x1:"1",y1:"14",x2:"4",y2:"14"})]})}),(0,n.jsx)("button",{onClick:()=>C(!0),title:"全局设置",style:{position:"fixed",top:0,right:108,zIndex:300,display:"flex",alignItems:"center",justifyContent:"center",width:36,height:36,padding:0,background:"var(--bg-panel)",border:"none",borderLeft:"1px solid var(--border)",borderBottom:"1px solid var(--border)",color:"var(--text-muted)",cursor:"pointer",transition:"color 0.12s"},onMouseEnter:e=>{e.currentTarget.style.color="var(--text)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-muted)"},children:(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"3"}),(0,n.jsx)("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"})]})}),(0,n.jsx)("button",{onClick:()=>z(!0),title:"小说创作实战手册",style:{position:"fixed",top:0,right:72,zIndex:300,display:"flex",alignItems:"center",justifyContent:"center",width:36,height:36,padding:0,background:"var(--bg-panel)",border:"none",borderLeft:"1px solid var(--border)",borderBottom:"1px solid var(--border)",color:"var(--text-muted)",cursor:"pointer",transition:"color 0.12s"},onMouseEnter:e=>{e.currentTarget.style.color="var(--text)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-muted)"},children:(0,n.jsxs)("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,n.jsx)("path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"}),(0,n.jsx)("line",{x1:"12",y1:"17",x2:"12.01",y2:"17",strokeWidth:"3"})]})}),(0,n.jsx)("button",{onClick:e=>{let t=e.currentTarget.getBoundingClientRect();r({x:t.left+t.width/2,y:t.top+t.height/2})},title:t?"Switch to light mode":"Switch to dark mode","aria-label":t?"Switch to light mode":"Switch to dark mode","aria-pressed":t,style:{position:"fixed",top:0,right:36,zIndex:300,display:"flex",alignItems:"center",justifyContent:"center",width:36,height:36,padding:0,background:"var(--bg-panel)",border:"none",borderLeft:"1px solid var(--border)",borderBottom:"1px solid var(--border)",color:"var(--text-muted)",cursor:"pointer",transition:"color 0.12s"},onMouseEnter:e=>{e.currentTarget.style.color="var(--text)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-muted)"},children:t?(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"5"}),(0,n.jsx)("line",{x1:"12",y1:"1",x2:"12",y2:"3"}),(0,n.jsx)("line",{x1:"12",y1:"21",x2:"12",y2:"23"}),(0,n.jsx)("line",{x1:"4.22",y1:"4.22",x2:"5.64",y2:"5.64"}),(0,n.jsx)("line",{x1:"18.36",y1:"18.36",x2:"19.78",y2:"19.78"}),(0,n.jsx)("line",{x1:"1",y1:"12",x2:"3",y2:"12"}),(0,n.jsx)("line",{x1:"21",y1:"12",x2:"23",y2:"12"}),(0,n.jsx)("line",{x1:"4.22",y1:"19.78",x2:"5.64",y2:"18.36"}),(0,n.jsx)("line",{x1:"18.36",y1:"5.64",x2:"19.78",y2:"4.22"})]}):(0,n.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("path",{d:"M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"})})}),(0,n.jsx)("button",{onClick:()=>es(e=>!e),title:el?"隐藏写作辅助":"显示写作辅助",style:{position:"fixed",top:0,right:0,zIndex:300,display:"flex",alignItems:"center",justifyContent:"center",width:36,height:36,padding:0,background:"var(--bg-panel)",border:"none",borderLeft:"1px solid var(--border)",borderBottom:"1px solid var(--border)",color:el?"var(--text)":"var(--text-muted)",cursor:"pointer",transition:"color 0.12s"},onMouseEnter:e=>{e.currentTarget.style.color="var(--text)"},onMouseLeave:e=>{e.currentTarget.style.color=el?"var(--text)":"var(--text-muted)"},children:(0,n.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}),y&&(0,n.jsx)(tN,{onClose:()=>{v(!1),j(e=>e+1)}}),k&&(ec??l?.cwd??a)&&(0,n.jsx)(tV,{cwd:ec??l?.cwd??a,onClose:()=>w(!1)}),S&&(0,n.jsx)(tY,{onClose:()=>C(!1)}),T&&(0,n.jsx)(tK,{onClose:()=>z(!1)}),L&&(0,n.jsx)("div",{style:{position:"fixed",inset:0,zIndex:1200,background:"rgba(10, 10, 10, 0.4)",backdropFilter:"blur(8px)",display:"flex",alignItems:"center",justifyContent:"center",animation:"fadeIn 0.2s ease-out"},onClick:L.onCancel,children:(0,n.jsxs)("div",{style:{width:"min(500px, 92%)",background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:"16px",boxShadow:"0 24px 60px rgba(0, 0, 0, 0.3)",display:"flex",flexDirection:"column",overflow:"hidden",fontFamily:"var(--font-serif)"},onClick:e=>e.stopPropagation(),children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"18px 24px",background:"rgba(99, 102, 241, 0.08)",borderBottom:"1px solid var(--border)"},children:[(0,n.jsx)("div",{style:{width:32,height:32,borderRadius:"50%",background:"var(--bg)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:16,border:"1px solid #818cf833",boxShadow:"0 2px 8px rgba(99, 102, 241, 0.15)"},children:"\uD83C\uDFAD"}),(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column"},children:[(0,n.jsx)("span",{style:{fontSize:13,fontWeight:700,color:"var(--text)"},children:"确认更换写作文风"}),(0,n.jsxs)("span",{style:{fontSize:11,color:"var(--text-dim)",marginTop:2},children:["将风格切换至:",L.targetStyle]})]})]}),(0,n.jsxs)("div",{style:{padding:"24px",display:"flex",flexDirection:"column",gap:16},children:[(0,n.jsxs)("div",{style:{fontSize:13,color:"var(--text)",lineHeight:"1.6"},children:["您正在准备将当前书籍的写作风格切换为 ",(0,n.jsxs)("strong",{style:{color:"#818cf8"},children:["「",L.targetStyle,"」"]}),"。"]}),(0,n.jsxs)("div",{style:{background:"var(--bg)",border:"1px solid var(--border)",borderLeft:"4px solid #818cf8",borderRadius:"8px",padding:"14px 18px",fontSize:12,color:"var(--text-muted)",lineHeight:"1.7"},children:[(0,n.jsx)("span",{style:{fontWeight:600,color:"var(--text)",display:"block",marginBottom:6},children:"⚠️ 注意事项:"}),"此操作将使用该文风模板自动覆盖当前书籍的活动文风指南(`story/style_guide.md`)与统计特征库(`style_profile.json`)。历史章节正文不会被修改。"]}),(0,n.jsxs)("div",{style:{background:"var(--bg-hover)",borderRadius:"8px",padding:"12px 16px",fontSize:11,color:"var(--text-muted)",lineHeight:"1.6"},children:[(0,n.jsx)("span",{style:{fontWeight:600,color:"var(--text)",display:"block",marginBottom:4},children:"\uD83D\uDCA1 后续操作指引:"}),"切换成功后,接下来的「智能续写」、「极速草稿」、「文本润色」和「剧情重写」等 AI 生成动作,都将自动采用该风格进行写作。"]})]}),(0,n.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",gap:12,padding:"16px 24px",background:"var(--bg-panel)",borderTop:"1px solid var(--border)"},children:[(0,n.jsx)("button",{onClick:L.onCancel,style:{padding:"7px 16px",fontSize:12,borderRadius:8,border:"1px solid var(--border)",background:"var(--bg)",color:"var(--text-muted)",cursor:"pointer",fontWeight:500,transition:"all 0.2s"},onMouseEnter:e=>{e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color="var(--text)"},onMouseLeave:e=>{e.currentTarget.style.background="var(--bg)",e.currentTarget.style.color="var(--text-muted)"},children:"取消"}),(0,n.jsx)("button",{onClick:L.onConfirm,style:{padding:"7px 20px",fontSize:12,borderRadius:8,border:"none",background:"#818cf8",color:"white",cursor:"pointer",fontWeight:600,boxShadow:"0 4px 12px rgba(99, 102, 241, 0.33)",transition:"all 0.2s"},onMouseEnter:e=>{e.currentTarget.style.opacity="0.9",e.currentTarget.style.transform="translateY(-1px)",e.currentTarget.style.boxShadow="0 6px 16px rgba(99, 102, 241, 0.44)"},onMouseLeave:e=>{e.currentTarget.style.opacity="1",e.currentTarget.style.transform="none",e.currentTarget.style.boxShadow="0 4px 12px rgba(99, 102, 241, 0.33)"},children:"确定更换"})]})]})})]})}}},e=>{e.O(0,[7547,8441,3794,7358],()=>e(e.s=3705)),_N_E=e.O()}]);