filecat 7.13.0 → 7.14.4

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 (39) hide show
  1. package/build/dist/1142.97da60368424992aa345.js +1 -0
  2. package/build/dist/{2572.8fdddfebb4da2f29dbd8.js → 2572.7e7a9c31be5b678fae9f.js} +1 -1
  3. package/build/dist/{2674.2713dbaf7b4dbb6baa4c.js → 2674.57dca88c03c75c01a508.js} +1 -1
  4. package/build/dist/{3299.b85fad5623f990484bd9.js → 3299.937b009da6be833febd9.js} +1 -1
  5. package/build/dist/394.c8dd8740abe9c8e966be.js +1 -0
  6. package/build/dist/5308.7b9f32f5b110b7b30f98.js +1 -0
  7. package/build/dist/5516.30abe1f0cae2352028c1.js +1 -0
  8. package/build/dist/5744.236bce5b3b9188b4927f.js +1 -0
  9. package/build/dist/621.9b9a5312624393359a06.js +1 -0
  10. package/build/dist/6404.a2bcc23b592dbd6d719b.js +1 -0
  11. package/build/dist/7181.91fe39c64601170928c9.js +1 -0
  12. package/build/dist/735.80eacc3ca29a27059b14.js +1 -0
  13. package/build/dist/{7873.e3098bc6f510e5bea55f.js → 7873.f206780aa5e1d97ee481.js} +1 -1
  14. package/build/dist/8302.dacd7272ac7837764b5f.js +1 -0
  15. package/build/dist/8365.e876e79b3f2031b20183.js +1 -0
  16. package/build/dist/892.7c2341cc1d38845fceb9.js +1 -0
  17. package/build/dist/{9299.4c39ae6b03d41c516b1f.js → 9299.d5615865bd9ebd376923.js} +1 -1
  18. package/build/dist/dark.css +21 -28
  19. package/build/dist/google-dark.css +21 -28
  20. package/build/dist/google.css +4 -13
  21. package/build/dist/index.html +1 -1
  22. package/build/dist/main.393fb0005ec80a2b4828.js +2 -0
  23. package/build/main.js +1 -1
  24. package/package.json +1 -1
  25. package/build/dist/1142.bc43fae2e5e38d9359df.js +0 -1
  26. package/build/dist/394.a8337677ef993b923783.js +0 -1
  27. package/build/dist/4004.ca7e777145c700c5b186.js +0 -1
  28. package/build/dist/5308.d1e5ccb49396fc1b026d.js +0 -1
  29. package/build/dist/5516.88521f3a3c7101c46df3.js +0 -1
  30. package/build/dist/5744.0f8a0432b73b2eb0a7ff.js +0 -1
  31. package/build/dist/621.28f07b5c059e80331746.js +0 -1
  32. package/build/dist/6404.bcf224539211a7979990.js +0 -1
  33. package/build/dist/7181.640be82b27656082091e.js +0 -1
  34. package/build/dist/735.38718e61fe313f131a3e.js +0 -1
  35. package/build/dist/8302.c72a3767319d87419737.js +0 -1
  36. package/build/dist/892.a62727e6df6e80655ca7.js +0 -1
  37. package/build/dist/main.e03c0b1342da0ac83715.js +0 -2
  38. package/build/ripgrep/rg.exe +0 -0
  39. /package/build/dist/{main.e03c0b1342da0ac83715.js.LICENSE.txt → main.393fb0005ec80a2b4828.js.LICENSE.txt} +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "filecat",
3
- "version": "7.13.0",
3
+ "version": "7.14.4",
4
4
  "description": "A self-hosted Web File browser and lightweight server management tool.",
5
5
  "author": "xiaobaidadada",
6
6
  "repository": {
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[1142],{71142(e,t,r){r.r(t),r.d(t,{default:()=>ue});var n=r(96540),s=r(7523),o=r(34843),c=r(82893),i=r(78247),u=r(23430),a=r(85997),l=r(57952),d=r(62042),m=r(53459),f=r(14284),v=r(57889),_=r(23496),h=r(22022),p=r(76118),g=r(67951),w=r(74848);function x(e){const{t}=(0,h.Bd)(),r=(0,n.useRef)(null),[s,o]=(0,n.useState)({marks:[],block:{name:"paragraph"}}),[c,i]=(0,n.useState)(null),u=(0,n.useCallback)(()=>{const t=e.get_view();if(!t)return;const r=t.state.selection,n=t.state.storedMarks??r.$from.marks();if(o({marks:n.map(e=>e.type.name),block:y(r.$from)}),r.empty)return void i(null);const s=t.coordsAtPos(r.from),c=t.coordsAtPos(r.to),u=(Math.min(s.left,c.left)+Math.max(s.right,c.right))/2,a=Math.min(s.top,c.top),l=Math.max(s.bottom,c.bottom);i({top:a,bottom:l,left:u})},[e.get_view]);(0,n.useEffect)(()=>{u();const t=e.get_view();if(!t)return;const r=()=>u();t.dom.addEventListener("keyup",r),t.dom.addEventListener("mouseup",r),document.addEventListener("selectionchange",r);const n=t.dom.closest(".md-editor-context");return n?.addEventListener("scroll",r,{passive:!0}),window.addEventListener("resize",r),()=>{t.dom.removeEventListener("keyup",r),t.dom.removeEventListener("mouseup",r),document.removeEventListener("selectionchange",r),n?.removeEventListener("scroll",r),window.removeEventListener("resize",r)}},[u,e.get_view,e.refresh_key]);const a=t=>{const r=e.get_view();r&&(t(r.state,r.dispatch),r.focus(),u())},l=e=>s.marks.includes(e),d=e=>"heading"===s.block.name&&s.block.level===e,[m,f]=(0,n.useState)({w:0,h:36});if((0,n.useLayoutEffect)(()=>{if(!c||!r.current)return;const e=r.current.offsetWidth,t=r.current.offsetHeight;f(r=>r.w===e&&r.h===t?r:{w:e,h:t})},[c,e.refresh_key]),!c)return null;const v=(e,r,n,s,o=!1)=>(0,w.jsx)("button",{className:"mdtb__btn"+(o?" mdtb__btn--on":""),title:t(n),onMouseDown:e=>e.preventDefault(),onClick:s,children:r},e),_=m.w/2,p=_+4,x=Math.max(p,window.innerWidth-_-4),k=document.querySelector(".header")?.getBoundingClientRect().bottom??0,b=c.top-m.h-8,E=b<k+4,j={top:E?Math.min(c.bottom+8,window.innerHeight-m.h-4):b,left:Math.min(x,Math.max(p,c.left))};return(0,w.jsxs)("div",{className:"mdtb mdtb--floating"+(E?" mdtb--below":""),ref:r,style:j,children:[v("h1","H1","一级标题",()=>a((0,g.uf)("heading",{level:1})),d(1)),v("h2","H2","二级标题",()=>a((0,g.uf)("heading",{level:2})),d(2)),v("h3","H3","三级标题",()=>a((0,g.uf)("heading",{level:3})),d(3)),(0,w.jsx)("span",{className:"mdtb__sep"}),v("b","B","加粗",()=>a((0,g.NH)("strong")),l("strong")),v("i","I","斜体",()=>a((0,g.NH)("em")),l("em")),v("s","S","删除线",()=>a((0,g.NH)("strike")),l("strike")),v("code","</>","行内代码",()=>a((0,g.NH)("code")),l("code")),(0,w.jsx)("span",{className:"mdtb__sep"}),v("ul","≔","无序列表",()=>a(g.fK)),v("ol","1.","有序列表",()=>a(g.oB)),v("quote","❝","引用",()=>a(g.Vu))]})}function y(e){for(let t=e.depth;t>0;t--){const r=e.node(t).type.name;if("heading"===r)return{name:"heading",level:e.node(t).attrs.level};if("paragraph"===r)return{name:"paragraph"}}return{name:"paragraph"}}var k=r(75725),b=r(86059);const E="cut",j="copy",S="paste",C="strong",N="em",L="strike",A="code",R="h1",H="h2",M="h3",G="paragraph",z="bullet",B="ordered",P="quote",$="code_block",F="clean",D="row_before",K="row_after",I="row_delete",T="col_before",U="col_after",W="col_delete",Y="header_toggle",X="cell_merge",q="cell_split",V="table_delete",J="table_insert",O="select_all";function Z(e){const{t}=(0,h.Bd)(),[r,s]=(0,n.useState)(null),o=(0,n.useRef)(e.get_view);o.current=e.get_view,(0,n.useEffect)(()=>{const e=e=>{const t=o.current();if(!t)return;const r=e.target;if(!r||!r.closest(".md-filecat-content"))return;e.preventDefault();const n=t.posAtCoords({left:e.clientX,top:e.clientY});if(n){const e=t.state.selection;if(n.pos<e.from||n.pos>e.to){const{TextSelection:e}=t.state.selection.constructor;try{t.dispatch(t.state.tr.setSelection(e.near(t.state.doc.resolve(n.pos))))}catch{}}}const c=!!r.closest("td, th");s({x:e.clientX,y:e.clientY,in_table:c||(0,b.aH)(t.state)})};return document.addEventListener("contextmenu",e,!0),()=>document.removeEventListener("contextmenu",e,!0)},[]);const c=()=>s(null),i=(0,n.useCallback)(e=>{const t=o.current();t&&(e(t.state,t.dispatch),t.focus(),c())},[]),u=e=>{const t=o.current();t?.focus(),document.execCommand(e),c()};if(!r)return null;const a=r.in_table?[{r:t("上方插入行"),v:D},{r:t("下方插入行"),v:K},{r:t("左侧插入列"),v:T},{r:t("右侧插入列"),v:U},{r:t("删除行"),v:I},{r:t("删除列"),v:W},{r:t("切换表头行"),v:Y},{r:t("合并单元格"),v:X},{r:t("拆分单元格"),v:q},{r:t("删除表格"),v:V}]:[],l=[{r:t("剪切"),v:E},{r:t("复制"),v:j},{r:t("粘贴"),v:S},{r:t("格式"),v:"format",items:[{r:t("加粗"),v:C},{r:t("斜体"),v:N},{r:t("删除线"),v:L},{r:t("行内代码"),v:A}]},{r:t("段落"),v:"block",items:[{r:t("一级标题"),v:R},{r:t("二级标题"),v:H},{r:t("三级标题"),v:M},{r:t("正文"),v:G}]},{r:t("插入"),v:"insert",items:[{r:t("无序列表"),v:z},{r:t("有序列表"),v:B},{r:t("引用"),v:P},{r:t("代码块"),v:$},{r:t("插入表格"),v:J}]},...a.length?[{r:t("表格"),v:"table",items:a}]:[],{r:t("清除格式"),v:F},{r:t("全选"),v:O}];return(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(k.rY,{click:c}),(0,w.jsx)(k.Pu,{x:r.x,y:r.y,items:l,click:t=>{switch(t){case E:return u("cut");case j:return u("copy");case S:return u("paste");case C:return i((0,g.NH)("strong"));case N:return i((0,g.NH)("em"));case L:return i((0,g.NH)("strike"));case A:return i((0,g.NH)("code"));case R:return i((0,g.uf)("heading",{level:1}));case H:return i((0,g.uf)("heading",{level:2}));case M:return i((0,g.uf)("heading",{level:3}));case G:return i((0,g.uf)("paragraph"));case z:return i(g.fK);case B:return i(g.oB);case P:return i(g.Vu);case $:return i((0,g.uf)("code_block"));case J:return c(),void e.on_insert_table?.();case D:return i(b.JD);case K:return i(b.gC);case T:return i(b.RC);case U:return i(b.GU);case I:return i(b.aR);case W:return i(b.gR);case Y:return i(b.uC);case X:return i(b.w7);case q:return i(b.L0);case V:return i(b.kG);case F:return i((e,t)=>{const{from:r,to:n}=e.selection;let s=e.tr;return e.doc.nodesBetween(r,n,(e,t)=>{if(e.isText)for(const r of e.marks)s=s.removeMark(t,t+e.nodeSize,r.type)}),t?.(s),!0});case O:return i((e,t)=>{const{TextSelection:r}=e.selection.constructor;return t?.(e.tr.setSelection(r.create(e.doc,0,e.doc.content.size))),!0})}}})]})}var Q=r(64877);function ee(e){const t=[];if(!e)return t;const r=e.split(/(\n)/);let n=null,s=0;for(let e=0;e<r.length;e+=2){const o=r[e],c=s;s+=o.length+(r[e+1]?.length??0);const i=o.endsWith("\r")?o.slice(0,-1):o,u=i.trimStart(),a=/^(`{3,}|~{3,})/.exec(u);if(a){const e=a[1][0];null===n?n=e:n===e&&(n=null);continue}if(null!==n)continue;const l=/^ {0,3}(#{1,6})\s+(.*)$/.exec(i);if(!l)continue;const d=l[1].length,m=l[2].replace(/\s+#+\s*$/,"").trim();t.push({level:d,text:m,pos:c})}return t}var te=r(69918),re=r(96763),ne=r(40505);function se(e){const{t}=(0,h.Bd)(),[r,s]=(0,n.useState)(!1),[i,u]=(0,n.useState)({x:0,y:0}),[l,d]=(0,n.useState)([]),[m]=(0,o.fp)(c.AG.user_base_info);(0,n.useEffect)(()=>{if(!r)return;let e=!1;return(0,re.Kz)().then(t=>{e||d(t)}),()=>{e=!0}},[r]);const f=(e,t)=>(0,w.jsx)("div",{style:{...(0,ne.ok)(t===m?.user_data?.md_editor_theme)},children:e});return(0,w.jsxs)(n.Fragment,{children:[(0,w.jsx)(a.rA,{icon:"palette",title:t("主题"),onClick:e=>{u({x:e.clientX,y:e.clientY}),s(!0)}}),r&&(0,w.jsx)(k.rY,{click:()=>s(!1),children:(0,w.jsx)(k.Pu,{x:i.x,y:i.y,items:[{r:f(t("follow_sys"),""),v:""},...l.map(e=>({r:f(e.id,e.id),v:e.id}))],click:t=>{s(!1),e.on_change(t)}})})]})}var oe=r(2543),ce=r(61973),ie=r(87361);function ue(e){const t=e.pane,{t:r}=(0,h.Bd)(),g=(0,ce.Zp)(),{check_user_auth:y}=(0,i.MH)(),k=y(u.oV.md_editor_setting),[b,E]=(0,o.fp)(c.AG.md_editor),j=t??b,S=(0,o.fp)(c.AG.md_editor_last_context)[1],C=(0,n.useRef)(null),[N,L]=(0,n.useState)(null),[A,R]=(0,n.useState)(!1),[H,M]=(0,n.useState)(!1),[G,z]=(0,n.useState)(0),B=(0,n.useRef)(null),[P,$]=(0,n.useState)([]),[F,D]=(0,n.useState)(-1),[K,I]=(0,n.useState)(15),[T,U]=(0,n.useState)(!1),W=(0,n.useRef)(null),Y=(0,n.useRef)(null),[X,q]=(0,o.fp)(c.AG.md_editor_show_outline),[V,J]=(0,o.fp)(c.AG.md_editor_mode),O=(0,n.useCallback)(()=>{const e="wysiwyg"===V?"source":"wysiwyg",t=B.current;t&&("source"===e?t.enter_source_mode():t.exit_source_mode(),J(e))},[V]),[ne]=(0,o.fp)(c.AG.md_editor_setting),[ue,ae]=(0,o.fp)(c.AG.md_theme_css),[le]=(0,o.fp)(c.AG.user_base_info),{initUserInfo:de}=(0,n.useContext)(s.F),me=(0,n.useRef)(null),fe=(0,n.useRef)(null);(0,n.useEffect)(()=>{fe.current},[le]),(0,n.useEffect)(()=>{(0,te.Ce)(W.current,ne)},[ne]);(0,n.useEffect)(()=>{(0,re.bN)("editor",ue)},[ue]),(0,n.useEffect)(()=>{const e=()=>{(0,re.sO)().then(ae)};return window.addEventListener(re.o3,e),()=>window.removeEventListener(re.o3,e)},[]);const ve=(0,n.useRef)([]),_e=(0,n.useCallback)(()=>{const e=B.current;if(!e)return;const t=e.is_source_mode()?ee(e.get_markdown()):e.get_headings();ve.current=t,$(t)},[]);(0,n.useEffect)(()=>{t?.on_outline?.(P,F)},[P,F]);const he=(0,n.useCallback)(()=>{const e=B.current,t=e?.get_view();if(!e||!t)return;const r=e.is_source_mode()?t.state.selection.from-1:t.state.selection.from;let n=-1;for(const e of ve.current){if(!(e.pos<=r))break;n=e.pos}D(n)},[]);(0,n.useEffect)(()=>{let e=!1;if(j?.url)return M(!1),R(!0),v.l.get(j.url).then(t=>{if(e)return;L(t??"")}).catch(()=>{e||((0,d.zN)(r("打开失败")),L(""))}).finally(()=>{e||R(!1)}),()=>{e=!0};L(null)},[j?.url]),(0,n.useEffect)(()=>{const e=()=>z(e=>e+1);return document.addEventListener("selectionchange",e),()=>document.removeEventListener("selectionchange",e)},[]);const pe=(0,n.useRef)(O);pe.current=O,(0,n.useEffect)(()=>{const e=e=>{(e.ctrlKey||e.metaKey)&&"/"===e.key&&(e.preventDefault(),e.stopPropagation(),pe.current())};return document.addEventListener("keydown",e,!0),()=>document.removeEventListener("keydown",e,!0)},[]),(0,n.useEffect)(()=>{_e(),he()},[G,V,_e,he]);const ge=(0,n.useCallback)(oe.throttle(e=>{if(!W.current||!Y.current)return;const t=parseFloat(getComputedStyle(W.current).fontSize),r=e.clientX/t,n=window.innerWidth/t-4,s=2.25+Y.current.offsetWidth/t;r<=n&&r>=s&&I(parseFloat(r.toFixed(2)))},32),[]),we=()=>{U(!1),W.current?.removeEventListener("pointermove",ge)},xe=e=>{const t=B.current;t&&(t.scroll_to_pos(t.is_source_mode()?e.pos+1:e.pos),D(e.pos))},ye=async(e=!1)=>{if(!j?.name||!j?.path)return;const t=B.current?.get_markdown();if(void 0===t)return;const n=j.path.slice(0,j.path.length-j.name.length),s=`${encodeURIComponent(n)}${j.name}`;(await f.$M.post(`save/${s}`,{context:t})).code===m.m.Success?(M(!1),e||(0,d.SK)(r("保存成功"))):(0,d.zN)(r("保存失败"))},ke=(0,n.useRef)(ye);ke.current=ye;const be=(0,n.useRef)(H);be.current=H;const Ee=ne?.auto_save_interval??0;(0,n.useEffect)(()=>{if(j.readonly||Ee<=0)return;const e=setInterval(()=>{be.current&&ke.current(!0)},1e3*Ee);return()=>clearInterval(e)},[Ee,j.readonly]);const je=()=>{window.print()},Se=(0,n.useRef)(V);Se.current=V;const Ce=(0,n.useRef)(xe);Ce.current=xe;const Ne=(0,n.useRef)(je);Ne.current=je,(0,n.useEffect)(()=>{t?.on_dirty?.(H)},[H]),(0,n.useEffect)(()=>{t?.register?.({save:e=>ke.current(e),export_pdf:()=>Ne.current(),toggle_mode:()=>pe.current(),mode:()=>Se.current,goto_heading:e=>Ce.current(e),dirty:()=>be.current})},[]);const Le=()=>{E({}),M(!1),L(null),B.current=null,b?.close?.()},Ae=(0,n.useMemo)(()=>j?.url??"md_editor",[j?.url]);if(!j?.name)return null;const Re=!!t,He=(0,w.jsxs)("div",{className:"md-editor-context",ref:W,children:[A&&(0,w.jsxs)("div",{className:"common-box common-box-center",children:[r("加载中"),"..."]}),!A&&null!==N&&(0,w.jsxs)(n.Fragment,{children:[!Re&&X&&(0,w.jsx)("div",{className:"md-outline-panel",style:{width:`${K}em`},children:(0,w.jsx)(Q.default,{items:P,active_pos:F,on_click:xe})}),!Re&&X&&(0,w.jsx)("div",{className:"md-editor-divider",ref:Y,onPointerDown:()=>{U(!0),W.current?.addEventListener("pointermove",ge)},onPointerUp:we}),!Re&&T&&(0,w.jsx)("div",{className:"md-editor-drag-overlay",onPointerUp:we}),(0,w.jsx)("div",{className:"md-editor-scroll",children:(0,w.jsxs)("div",{className:"md-editor-sheet",children:["wysiwyg"===V&&(0,w.jsx)(x,{get_view:()=>B.current?.get_view()??null,refresh_key:G}),(0,w.jsx)(p.A,{value:N,ref:B,initial_source_mode:"source"===V,doc_path:j?.path,on_ready:e=>{const t=e.is_source_mode()?ee(e.get_markdown()):e.get_headings();ve.current=t,$(t),D(-1)},on_change:()=>{H||M(!0),C.current&&clearTimeout(C.current),C.current=setTimeout(()=>{const e=B.current?.get_markdown()??"";e&&S(e)},800)},on_save:()=>ke.current(),on_selection_change:()=>z(e=>e+1),on_source_mode_change:e=>{J(e?"source":"wysiwyg"),z(e=>e+1)}},Ae),"wysiwyg"===V&&(0,w.jsx)(Z,{get_view:()=>B.current?.get_view()??null,on_insert_table:()=>{B.current?.insert_table(3,3),M(!0)}})]})})]})]});return Re?He:(0,w.jsxs)("div",{id:"md-editor-container",ref:me,children:[(0,w.jsx)(l.A,{ignore_tags:!0,left_children:[(0,w.jsx)(a.rA,{title:r("关闭"),icon:"close",onClick:Le},1),(0,w.jsx)("div",{className:"md-editor-title",children:j.name},3),...H&&!j.readonly?[(0,w.jsx)(a.rA,{title:r("保存"),icon:"save",onClick:ye},2)]:[],(0,w.jsx)(a.rA,{title:r("大纲"),icon:"list",onClick:()=>q(e=>!e),selected:X},4),...j.readonly?[]:[(0,w.jsx)(a.rA,{title:r("wysiwyg"===V?"源码模式":"实时编辑模式"),icon:"wysiwyg"===V?"code":"edit",onClick:O},5)],...j.readonly?[]:[(0,w.jsx)(se,{on_change:async e=>{const t=await f.wm.post(_.s.user_save_private_attr,{is_md_theme:!0,md_editor_theme:e});t?.code===m.m.Success?(fe.current=e,await de(),(0,d.SK)(r("保存成功"))):(0,d.zN)(r("保存失败"))}},8)],(0,w.jsx)(a.rA,{title:r("导出PDF"),icon:"print",onClick:je},7),...k&&!j.readonly?[(0,w.jsx)(a.rA,{title:r("编辑器设置"),icon:"settings",onClick:()=>{Le(),g(ie.o.md_editor_setting_page)}},6)]:[]]}),He]})}}}]);
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[394],{30394(e,n,t){t.r(n),t.d(n,{default:()=>p});var s=t(96540),i=t(34843),a=t(82893),l=t(14284),c=t(62042),r=t(53459),o=t(34289),d=t(22022),m=t(20892),u=t(74848);function p(){const[e,n]=(0,i.fp)(a.AG.timeline_editor),[t,p]=(0,s.useState)(!1),{t:_}=(0,d.Bd)(),f=(0,s.useRef)(null),h=()=>{t&&!window.confirm(_("有未保存的修改,确定要关闭吗?"))||(n({}),e?.close?.())};if((0,s.useEffect)(()=>{if(void 0===e.url)return;const n=e=>{"Escape"===e.key&&(e.stopPropagation(),h())};return document.addEventListener("keydown",n),()=>document.removeEventListener("keydown",n)},[e.url,t]),void 0===e.url)return null;const[v,x]=(0,s.useState)(!1);return(0,u.jsx)("div",{id:"timeline-container",children:(0,u.jsx)("div",{className:"timeline-context",children:(0,u.jsx)(m.default,{fullscreen:!0,reset_key:e.url??e.name,url:e.url,on_dirty:p,on_edit_mode_change:x,register:e=>{f.current=e,x(e.is_edit_mode())},header:(0,u.jsxs)("div",{className:"timeline-topbar",children:[(0,u.jsx)("span",{className:"material-icons timeline-topbar__icon",children:"timeline"}),(0,u.jsx)("span",{className:"timeline-topbar__name",children:e.name}),t&&(0,u.jsx)("span",{className:"timeline-topbar__dirty",children:"*"}),(0,u.jsx)("span",{className:"timeline-topbar__gap"}),v&&(0,u.jsx)("button",{type:"button",className:"timeline-btn",title:_("保存")+" (Ctrl+S)",onClick:async()=>{await(f.current?.save())},children:(0,u.jsx)("span",{className:"material-icons",children:"save"})}),(0,u.jsx)("button",{type:"button",className:"timeline-btn",title:_("关闭"),onClick:h,children:(0,u.jsx)("span",{className:"material-icons",children:"close"})})]}),on_save:async n=>(await l.$M.post(`save/${encodeURIComponent((0,o.GG)("file",(0,o.vX)()))}${e.name}`,{context:n})).code===r.m.Success&&((0,c.SK)(_("保存成功")),!0)})})})}}}]);
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[4004,6010],{83277(e,s,t){t.d(s,{$j:()=>i,Lv:()=>n});class n{token;open=!1;note;index;url;model;request_type;json_params;sys_prompt;dotenv="";tool_mode=!1;show_options;static get_label_by_v(e,s){if(!e||!s?.length)return e;for(const t of s)if(t.value===e)return t.label;return e}static have_label_by_v(e,s){if(!e||!s?.length)return!1;for(const t of s)if(t.value===e)return!0;return!1}}const a=JSON.stringify({stream:!0,thinking:{type:"disabled"}});function i(e){return"string"==typeof e?e:Array.isArray(e)?e.map(e=>"text"===e.type?e.text:"[图片]").join("\n"):""}t.d(s,["CP",0,'\n\n\n\n# 聊天循环最大次数\ntool_call_max=500\n# 是否允许AI直接执行命令而不需要用户确认,默认为false,需要用户手动确认,如果使用 workflow 这里等价于为 true\nallow_exec_cmd_directly=false\n\n# 可选的代理 url,如果指定了所有访问大模型的请求将会走代理\n#proxy_url=\n\n# 可选的多个url 以数组分割\n# options_agent_url_list=[{"value":"http://..","label":"openai"}]\n\n# 可选的多个 key\n# options_agent_key_list=[{"value":"sh-aaa","label":"option1"}]\n\n# 可选的多个 model\n# options_agent_model_list=[{"value":"gpt-5.5","label":"gpt"}]\n\n# 存放本地的 prompt 文件 用于每次聊天的时候自动读取并加载\n# options_local_file_path_prompt_list=["/prompt/a.txt"]\n\n# 开启切换模型 ,开启以后,你可以自己写 prompt 提供多个模型让 ai 自己根据每次聊天切换下一步调用其他模型的次数\n# open_pick_model=false\n\n# 压缩后仍然完整保留的最近消息数\nmax_recent_messages=12\n# 当单个会话累计消息条数超过该值时,触发历史消息裁剪\ncompress_message_count=16\n# 历史消息中 tool 输出的最大字符数,只保留调用形式让 AI 知道调用了就行\nmax_tool_content_chars=200\n\n# ===== 模型类型(request_type)=====\n# 必填项,不同类型的 model 接口格式不同,默认 completions。\n# 可选值:\n# completions 标准对话/聊天补全 (chat/completions)\n# images 图片生成 (images/generations)\n# audio_speech 文本转语音 (audio/speech)\n# audio_transcription 语音转文字 (audio/transcriptions)\n# audio_translation 语音翻译 (audio/translations)\n# embeddings 向量嵌入 (embeddings)\n#request_type=completions\n\n# ===== 成为 tool(tool_mode)=====\n# 开启后该模型会作为一个工具被加载,可实现不同模型担任不同角色/能力,供 AI agent 在对话中动态调用。\n# 注意:不能与「是否开启」(open) 同时为 true。\n#tool_mode=false\n\n# ===== 是否支持图片(support_image)=====\n# 开启后:1) 注册 read_image 工具,让 AI 能读取本地图片;\n# 2) 工具读到的图片会以 OpenAI 多模态格式 image_url 随消息发给模型,模型就能真正"看图"。\n# 关闭后:AI 看不到图片,read_image 只会返回一句文字说明。\n# 主流模型(gpt-4o、豆包、qwen-vl、deepseek-vl 等)都支持,默认开启。\nsupport_image=true\n',"cL",0,a])},95733(e,s,t){t.r(s),t.d(s,{default:()=>ae});var n=t(96540),a=t(34843),i=t(22022),o=t(61973),c=t(92275),r=t(14284),l=t(7463),d=t(21499),u=t(64694),m=t(78247),h=t(40505),g=t(62042),p=t(45907),_=t(53459),f=t(72693),x=t(82893),j=t(61443),v=t(83277);function b(e){return null==e||e<0?"0":e.toLocaleString()}function w(e){const s=[];if(e.attachments?.length&&s.push(e.attachments.map(e=>`[附件] ${e.name}`).join("\n")),e.content_list?.length)for(const t of e.content_list){const e=(0,v.$j)(t.content);if(e&&s.push(e),t.tool_call_ends?.length){const e=t.tool_call_ends.map(e=>{const s=e.tool_display_name||e.tool_name;return e.success?`[工具] ${s} 成功`:`[工具] ${s} 失败`});s.push(e.join("\n"))}}return e.text&&!s.length&&s.push(e.text),e.images?.length&&s.push(`[生成图片 ${e.images.length} 张]`),e.audio&&s.push("[音频]"),s.join("\n\n")}function y(e){const s=(0,v.$j)(e.content);if(s)return s;const t=e.content_list??[];return t.length?t.map(e=>(0,v.$j)(e.content)).filter(Boolean).join("\n\n"):""}function S(e=[]){return e.filter(e=>"user"===e.role||"assistant"===e.role).map((e,s)=>({id:Date.now()+s,sender:"assistant"===e.role?"bot":"user",text:y(e),attachments:e.attachments??[],content_list:e.content_list,images:e.images,audio:e.audio,embeddings:e.embeddings,elapsed_ms:e.elapsed_ms}))}const N=/\.(md|txt|json|js|jsx|ts|tsx|css|html?|xml|ya?ml|py|java|go|rs|c|cpp|h|hpp|sh|bat|cmd|ini|toml|csv|log|sql|env|gitignore|dockerfile)$/i;function k(e){return e.type?.startsWith("image/")?"image":e.type?.startsWith("text/")||N.test(e.name)?"text":"binary"}function C(e){return e.text()}function A(e){return new Promise((s,t)=>{const n=new FileReader;n.onload=()=>s(n.result),n.onerror=t,n.readAsDataURL(e)})}async function $(e){const s=[];for(const t of e){const e=k(t);let n="";if("text"===e)try{const e=await C(t),s=12e4;n=e.length>s?`${e.slice(0,s)}\n\n[内容已截断,原始长度 ${e.length} 字符]`:e}catch{n="[文本读取失败]"}else if("image"===e)try{n=await A(t)}catch{n=`[图片文件: ${t.name}]`}else n=`[二进制文件: ${t.name}]`;s.push({name:t.name,mime_type:t.type,size:t.size,kind:e,content:n})}return s}var I=t(14944);function M(e){return"bot"!==e.sender||!!(e.text||e.content_list?.length||e.attachments?.length)}var R=t(85997),D=t(34299),H=t(74848);function V(e){const s=e.attachments&&e.attachments.length>0?(0,H.jsx)("div",{className:"chat-message-attachments",children:e.attachments.map((e,s)=>(0,H.jsxs)("div",{className:"chat-message-attachment",children:[(0,H.jsx)(R.In,{icon:"attach_file"}),(0,H.jsx)("span",{children:e.name}),(0,H.jsxs)("small",{children:[e.size," B"]})]},`${e.name}_${s}`))}):null,t=[];e.images&&"bot"===e.sender&&t.push((0,H.jsx)(n.Fragment,{children:(0,H.jsx)(E,{images:e.images,text:e.text})},"images")),e.audio&&"bot"===e.sender&&t.push((0,H.jsx)(n.Fragment,{children:(0,H.jsx)(K,{audio:e.audio,text:e.text})},"audio")),e.embeddings&&"bot"===e.sender&&t.push((0,H.jsx)(n.Fragment,{children:(0,H.jsx)(z,{embeddings:e.embeddings,text:e.text})},"embeddings"));const a=function(e){if("bot"!==e.sender||!e.content_list?.length)return e.text?(0,H.jsx)(D.default,{context:e.text}):null;return(0,H.jsxs)(H.Fragment,{children:[e.content_list.map((e,s)=>{const t=[],a=(0,v.$j)(e.content);return a&&t.push((0,H.jsx)(n.Fragment,{children:(0,H.jsx)(D.default,{context:a})},`content-${s}`)),e.tool_call_ends?.length&&t.push((0,H.jsx)(n.Fragment,{children:(0,H.jsx)(T,{callList:e.tool_call_ends})},`tool-${s}`)),(0,H.jsx)(n.Fragment,{children:t},`part-${s}`)}),!e.content_list.some(e=>e.content)&&e.text?(0,H.jsx)(D.default,{context:e.text}):null]})}(e);return 0===t.length?(0,H.jsxs)(H.Fragment,{children:[s,a]}):(0,H.jsxs)(H.Fragment,{children:[t,s,a]})}function T({callList:e}){const[s,t]=n.useState(!1);if(!e?.length)return null;e.filter(e=>e.success).length;const a=e.filter(e=>!e.success).length;return(0,H.jsxs)("div",{className:"chat-message-call-list",children:[(0,H.jsxs)("div",{className:"call-list-header",onClick:()=>t(!s),children:[(0,H.jsx)(R.In,{icon:s?"expand_less":"expand_more"}),(0,H.jsxs)("span",{className:"call-list-summary",children:["工具调用 (",e.length,")",a>0&&(0,H.jsx)("span",{className:"call-list-fail",children:" 失败 "})]})]}),s&&(0,H.jsx)("div",{className:"call-list-body",children:e.map((e,s)=>(0,H.jsxs)("div",{className:"call-list-item "+(e.success?"call-success":"call-fail"),children:[(0,H.jsxs)("div",{className:"call-list-item-header",children:[(0,H.jsx)(R.In,{icon:e.success?"check_circle":"error"}),(0,H.jsx)("span",{className:"call-list-tool-name",children:e.tool_display_name||e.tool_name}),(0,H.jsxs)("span",{className:"call-list-duration",children:[e.duration_ms,"ms"]})]}),e.tool_args&&(0,H.jsxs)("details",{className:"call-list-details",children:[(0,H.jsx)("summary",{children:"参数"}),(0,H.jsx)("pre",{className:"call-list-pre",children:JSON.stringify(e.tool_args,null,2)})]}),!e.success&&e.error&&(0,H.jsxs)("details",{className:"call-list-details",children:[(0,H.jsx)("summary",{children:"错误"}),(0,H.jsx)("pre",{className:"call-list-pre call-list-error-text",children:e.error})]}),e.success&&e.tool_result&&(0,H.jsxs)("details",{className:"call-list-details",children:[(0,H.jsx)("summary",{children:"结果"}),(0,H.jsx)("pre",{className:"call-list-pre",children:e.tool_result.length>500?e.tool_result.slice(0,500)+"...":e.tool_result})]})]},s))})]})}function E({images:e,text:s}){let t=e||[];if(!t.length&&s)try{t=JSON.parse(s).data||[]}catch{}return t.length?(0,H.jsxs)("div",{className:"image-generation-result",children:[t.map((e,s)=>(0,H.jsxs)("div",{className:"image-generation-item",children:[e.url&&(0,H.jsx)("div",{className:"image-generation-image-wrapper",children:(0,H.jsx)("img",{src:e.url,alt:e.revised_prompt||`生成的图片 ${s+1}`,loading:"lazy"})}),e.b64_json&&(0,H.jsx)("div",{className:"image-generation-image-wrapper",children:(0,H.jsx)("img",{src:`data:image/png;base64,${e.b64_json}`,alt:`生成的图片 ${s+1}`})}),e.revised_prompt&&(0,H.jsx)("p",{className:"image-generation-prompt",children:(0,H.jsx)("small",{children:e.revised_prompt})})]},s)),s&&!e&&(0,H.jsx)(D.default,{context:s})]}):(0,H.jsx)(D.default,{context:s||""})}function K({audio:e,text:s}){if(e){if(e.url)return(0,H.jsx)("div",{className:"audio-result",children:(0,H.jsx)("audio",{controls:!0,src:e.url,children:"您的浏览器不支持音频播放"})});if(e.data){const s=e.mime_type||"audio/mpeg";return(0,H.jsx)("div",{className:"audio-result",children:(0,H.jsx)("audio",{controls:!0,src:`data:${s};base64,${e.data}`,children:"您的浏览器不支持音频播放"})})}}const t=s||"";if(t.startsWith("http://")||t.startsWith("https://"))return(0,H.jsx)("div",{className:"audio-result",children:(0,H.jsx)("audio",{controls:!0,src:t,children:"您的浏览器不支持音频播放"})});try{const e=JSON.parse(t);if(e?.data||e?.audio_data){const s=e.data||e.audio_data;return(0,H.jsx)("div",{className:"audio-result",children:(0,H.jsx)("audio",{controls:!0,src:`data:audio/mpeg;base64,${s}`,children:"您的浏览器不支持音频播放"})})}}catch{}return(0,H.jsx)(D.default,{context:t})}function B({content:e,label:s}){const[t,a]=n.useState(!1);return(0,H.jsxs)("button",{className:"embeddings-copy-btn",onClick:()=>{(0,h.lW)(e),a(!0),setTimeout(()=>a(!1),1500)},children:[(0,H.jsx)(R.In,{icon:t?"check":"content_copy"}),t?"已复制":s||"复制"]})}function z({embeddings:e,text:s}){let t=e||null;if(!t&&s)try{t=JSON.parse(s)}catch{return(0,H.jsx)(D.default,{context:s})}if(!t)return(0,H.jsx)(D.default,{context:s||""});const n=t?.data||[],a=t?.usage,i=JSON.stringify(t,null,2);return(0,H.jsxs)("div",{className:"embeddings-result",children:[(0,H.jsxs)("div",{className:"embeddings-summary",children:[(0,H.jsx)("strong",{children:"向量嵌入结果"}),(0,H.jsxs)("span",{children:["维度: ",n[0]?.embedding?.length??"N/A"]}),(0,H.jsxs)("span",{children:["数量: ",n.length]}),a&&(0,H.jsxs)("span",{children:["使用 tokens: ",a.total_tokens??"N/A"]})]}),(0,H.jsxs)("div",{className:"embeddings-toolbar",children:[(0,H.jsx)(B,{content:i,label:"复制全部结果"}),n.length>0&&n[0]?.embedding&&(0,H.jsx)(B,{content:JSON.stringify(n[0].embedding,null,2),label:"复制第一条向量"}),n.length>0&&(0,H.jsx)(B,{content:JSON.stringify(n.map(e=>e.embedding),null,2),label:"复制所有向量数据"})]}),n.length>0&&n[0]?.embedding&&(0,H.jsx)("div",{className:"embeddings-preview",children:(0,H.jsxs)("span",{children:["向量预览: [",n[0].embedding.slice(0,5).join(", "),n[0].embedding.length>5?", ...":"","]"]})}),n.length>0&&(0,H.jsxs)("details",{children:[(0,H.jsx)("summary",{children:"查看详细数据"}),(0,H.jsx)("pre",{className:"embeddings-raw",children:i})]})]})}async function L(e,s,t,n){try{switch(e){case"images":{const e=await async function(e,s){const t={prompt:e,session_id:s},n=await r.jV.post("images/generations",t);if(0!==n.code)throw new Error(n.message||"图片生成失败");const a=n.data||{},i=(a.data||[]).map(e=>({url:e.url,b64_json:e.b64_json,revised_prompt:e.revised_prompt})),o=i.map((e,s)=>`![生成图片${s+1}](${e.url||`data:image/png;base64,${e.b64_json}`})${e.revised_prompt?`\n> ${e.revised_prompt}`:""}`).join("\n\n");return{session_id:a.session_id||s,images:i,text:o||`生成了 ${i.length} 张图片`}}(s,t);return e&&n(e.text,{images:e.images}),!0}case"audio_speech":{const e=await async function(e,s){const t={input:e,session_id:s};try{const e=localStorage.getItem("ai_audio_extra_params");if(e){const s=JSON.parse(e);s.voice&&(t.voice=s.voice),s.speed&&(t.speed=parseFloat(s.speed))}}catch{}const n=localStorage.getItem("token")||"",a=await fetch("/api/ai_agent/audio/speech",{method:"POST",headers:{"Content-Type":"application/json",Authorization:n},body:JSON.stringify(t)});if(!a.ok)throw new Error(`语音合成失败: ${a.statusText}`);const i=a.headers.get("X-Session-Id")||s,o=await a.arrayBuffer();return{session_id:i,audio:{data:btoa(String.fromCharCode(...Array.from(new Uint8Array(o)))),mime_type:a.headers.get("content-type")||"audio/mpeg"},text:`[音频文件: ${e.slice(0,50)}...]`}}(s,t);return e&&n(e.text,{audio:e.audio}),!0}case"embeddings":{const e=await async function(e,s){const t=await r.jV.post("embeddings",{input:e,session_id:s});if(0!==t.code)throw new Error(t.message||"Embeddings 请求失败");const n=t.data||{},a=n?.data??[],i=`向量维度: ${a[0]?.embedding?.length??0}, 数量: ${a.length}`;return{session_id:n.session_id||s,embeddings:n,text:`✅ Embeddings 结果 - ${i}\n\`\`\`json\n${JSON.stringify(n,null,2).slice(0,2e3)}\n\`\`\``}}(s,t);return e&&n(e.text,{embeddings:e.embeddings}),!0}default:return!1}}catch(e){return n(`请求失败: ${e?.message||JSON.stringify(e)}`),!0}}var P=t(4412),F=t(23430),O=t(87361),q=t(80389),G=t(7523),U=t(23496);const J=({currentModelName:e,setCurrentModelName:s,modelGroups:t,onModelChanged:c,sysPromptList:l,batchMode:d,selectedMsgCount:u,sessionVisible:h,onToggleSessionPanel:p,onCreateSession:f,onToggleBatchMode:v,onBatchDeleteMessages:b,bgProcessVisible:w,bgProcessCount:y,onToggleBgProcess:S,selectedSysPromptId:N,setSelectedSysPromptId:k,inline:C})=>{const{t:A}=(0,i.Bd)(),$=(0,o.Zp)(),{check_user_auth:I}=(0,m.MH)(),[,M]=(0,a.fp)(x.AG.ai_session_collapsed),{open:D}=function(){const{t:e}=(0,i.Bd)(),[,s]=(0,a.fp)(x.AG.prompt_card),[t,o]=(0,a.fp)(x.AG.ai_chat_zoom),{initUserInfo:c}=(0,n.useContext)(G.F);return{open:()=>{const n=t,a=()=>s({open:!1});s({open:!0,title:e("缩放调整"),context_div:(0,H.jsx)(q.p,{defaultValue:t,onChange:o,min:30,max:200}),cancel:()=>{o(n),a()},confirm:async()=>{let s=100;o(e=>(s=e<30||e>200?100:e,s)),await r.wm.post(U.s.user_save_private_attr,{is_ai_chat_zoom:!0,ai_chat_zoom:s}),(0,g.SK)(e("缩放调整成功")),c(),a()}})}}}(),V=I(F.oV.ai_model_switch)||I(F.oV.ai_agent_setting),T=[];for(const e of t)for(const s of e.models)T.push({title:s.label||s.value,value:`${e.index}::${s.value}`,group:e.note});const E=t.find(e=>e.active),K=E?`${E.index}::${e}`:"",B=(0,H.jsxs)(n.Fragment,{children:[(0,H.jsx)(R.rA,{icon:"menu",title:A("会话"),onClick:p,selected:h}),(0,H.jsx)(R.rA,{icon:"add",title:A("新会话"),onClick:()=>f()}),l.length>0&&(0,H.jsx)(j.l6,{value:N,options:[{title:A("选择系统提示词"),value:""},...l.map(e=>({title:e.note||e.prompt.slice(0,30),value:String(e.index)}))],onChange:e=>{k(e)},no_border:!0,width:"auto"}),V&&T.length>0&&(0,H.jsx)(j.l6,{value:K,options:[{title:A("选择模型"),value:""},...T],margin:"0 0 0 1em",onChange:e=>{const t=String(e??"");if(!t.includes("::"))return;const[n,...a]=t.split("::"),i=a.join("::");i&&(s(i),r.jV.post("set_active_model",{index:Number(n),model_name:i}).then(e=>{e?.code===_.m.Success?((0,g.SK)("success"),c()):(0,g.zN)(e?.message||"fail")}).catch(console.error))},no_border:!0,width:"auto"}),d&&u>0&&(0,H.jsx)(R.rA,{icon:"delete",title:A("删除选中消息"),onClick:b}),(0,H.jsx)(R.rA,{icon:"zoom_in",title:A("缩放调整"),onClick:D}),(0,H.jsx)(R.rA,{icon:"terminal",title:A("后台进程"),onClick:S,selected:w,tip:y||null}),I(F.oV.ai_agent_setting)&&(0,H.jsx)(R.rA,{icon:"smart_toy",title:"机器人配置",onClick:()=>{$(O.o.ai_rebot_setting_page)}}),I(F.oV.ai_agent_setting)&&(0,H.jsx)(R.rA,{icon:"settings",title:"ai setting",onClick:()=>{$(O.o.ai_agent_setting_page)}})]});return C?(0,H.jsx)("div",{className:"chat-inline-header",children:B}):(0,H.jsx)(P.aZ,{position:"right",children:B})};var W=t(89824);function Q({sessions:e,activeSessionId:s,onSelectSession:t,onReorderSessions:a,onRenameSession:o,onDeleteSession:c,onToggleCmdAuto:r,onShowUsageStats:l,onShowSessionSetting:d,batchMode:u,selectedSessionIds:m,onToggleSessionSelect:h,onToggleBatchMode:g,onBatchDeleteSessions:p,onClearAllSessions:_,allUsersMode:f,onToggleAllUsersMode:x,showAllUsersEntry:j}){const{t:v}=(0,i.Bd)(),[b,w]=(0,n.useState)(""),[y,S]=(0,n.useState)(null),[N,k]=(0,n.useState)(null),C=!!a&&!f,A=b.trim()?e.filter(e=>(e.title||"").toLowerCase().includes(b.toLowerCase())||(e.summary||"").toLowerCase().includes(b.toLowerCase())||(e.long_term_memory||"").toLowerCase().includes(b.toLowerCase())||f&&(e.owner_name||"").toLowerCase().includes(b.toLowerCase())):e;return(0,H.jsxs)("aside",{className:"chat-session-list",children:[(0,H.jsx)("div",{className:"chat-session-search",children:(0,H.jsx)("input",{type:"text",className:"chat-session-search-input",placeholder:v("搜索会话"),value:b,onChange:e=>w(e.target.value)})}),(0,H.jsx)("div",{className:"chat-session-items-wrap",children:A.map((e,n)=>{return(0,H.jsx)("div",{children:(0,H.jsxs)("button",{className:`chat-session-item ${s===e.id?"active":""} ${u?"batch-mode":""} ${e.running?"is-running":""} ${y===n?"row-dragging":""} ${N===n&&null!==y&&y!==n?"row-drop-target":""}`,draggable:C,onDragStart:()=>S(n),onDragOver:e=>{null!==y&&(e.preventDefault(),N!==n&&k(n))},onDragEnd:()=>{S(null),k(null)},onDrop:e=>{e.preventDefault(),(e=>{const s=y;if(S(null),k(null),null===s||s===e||!a)return;const t=A[s]?.id,n=A[e]?.id;t&&n&&a(t,n)})(n)},onClick:()=>{u&&h?h(e.id):t(e.id)},title:e.summary||e.long_term_memory||e.title,children:[u&&(0,H.jsx)("input",{type:"checkbox",className:"chat-session-checkbox",checked:m?.has(e.id)??!1,onChange:()=>h?.(e.id),onClick:e=>e.stopPropagation()}),(0,H.jsx)("span",{children:(i=e.title,i||"新会话")}),f&&e.owner_name&&(0,H.jsx)("em",{className:"chat-session-owner",title:e.owner_name,children:e.owner_name}),e.running&&(0,H.jsx)("span",{className:"chat-session-running",title:v("正在执行中")}),(0,H.jsx)("small",{children:e.message_count}),"web"!==e.source&&(0,H.jsx)("em",{className:"chat-session-source",children:e.source}),!u&&(0,H.jsx)(W.MenuSelect,{list:[{name:v("重命名"),click:()=>o(e.id,e.title)},...f?[]:[{name:v("移动到最上"),click:()=>{const s=A[0];s&&s.id!==e.id&&a?.(e.id,s.id)}},{name:v("移动到最下"),click:()=>{const s=A[A.length-1];s&&s.id!==e.id&&a?.(e.id,s.id)}}],{name:e.cmd_auto_allow?v("命令检测关闭"):v("命令检测开启"),click:()=>r?.(e.id,!e.cmd_auto_allow)},{name:v("字符消耗统计"),click:()=>l(e.id)},{name:v("设置"),click:()=>d?.(e.id)},{name:v("删除"),click:()=>c(e.id)}],children:(0,H.jsx)(R.In,{icon:"more_horiz"})})]})},e.id);var i})}),(0,H.jsxs)("div",{className:"chat-session-actions",children:[(0,H.jsx)(R.rA,{icon:u?"check_circle":"checklist",title:v(u?"取消批量选择":"批量选择"),onClick:g}),j&&!u&&(0,H.jsx)(R.rA,{icon:f?"person":"groups",title:v(f?"仅看我的会话":"查看所有用户会话"),onClick:x}),u&&(m?.size??0)>0&&(0,H.jsx)(R.rA,{icon:"delete",title:v("删除选中会话"),onClick:p}),!u&&_&&(0,H.jsx)(R.rA,{icon:"delete_sweep",title:v("删除全部会话"),onClick:_})]})]})}function X(e){const s=(e.text||"").split("\n").map(e=>e.trim()).find(Boolean)||"";return s.length>80?s.slice(0,80)+"…":s}const Z=({messages:e,batchMode:s,selectedMsgIds:t,sending:a,chatContainerRef:i,messagesEndRef:o,onToggleMsgSelect:c,onDelete:r,onCopy:l,onCopyAll:u,onToggleBatchMode:m,onBatchCopy:h,onBatchDelete:g,showBatchBar:p,t:_})=>{const[f,x]=(0,n.useState)(new Set),j=(0,n.useMemo)(()=>e.filter(e=>!e.is_loading).map(e=>e.id),[e]),v=e=>{x(s=>{const t=new Set(s);return t.has(e)?t.delete(e):t.add(e),t})},b=()=>{x(e=>e.size>0&&j.every(s=>e.has(s))?new Set:new Set(j))};return(0,H.jsxs)("div",{className:"chat-messages",ref:i,"data-sending":a?"true":"false",children:[p&&(0,H.jsxs)("div",{className:"chat-message-batch-bar",children:[(0,H.jsxs)("span",{className:"batch-bar-count",children:[_("已选")," ",t.size]}),(0,H.jsx)("button",{onClick:h,children:_("复制所选")}),(0,H.jsx)("button",{onClick:g,className:"danger",children:_("删除所选")}),(0,H.jsx)("button",{onClick:m,children:_("取消")})]}),e.map(e=>{const n=f.has(e.id);return(0,H.jsxs)("div",{className:`chat-message ${e.sender} ${s?"batch-mode":""} ${e.is_loading?"is-loading":""} ${n?"collapsed":""}`,children:[s&&(0,H.jsx)("input",{type:"checkbox",className:"chat-message-checkbox",checked:t.has(e.id),onChange:()=>c(e.id)}),e.is_loading?(0,H.jsxs)("div",{className:"ai-loading-bubble",children:[(0,H.jsxs)("div",{className:"ai-loading-dots",children:[(0,H.jsx)("span",{className:"ai-loading-dot"}),(0,H.jsx)("span",{className:"ai-loading-dot"}),(0,H.jsx)("span",{className:"ai-loading-dot"})]}),(0,H.jsx)("span",{className:"ai-loading-text",children:e.text})]}):(0,H.jsxs)(H.Fragment,{children:[n?(0,H.jsxs)("div",{className:"chat-message-summary",title:e.text,onClick:()=>v(e.id),children:[(0,H.jsx)("span",{className:"chat-message-summary-icon",children:"▸"}),(0,H.jsx)("span",{className:"chat-message-summary-text",children:X(e)||_("(无内容)")})]}):(0,H.jsx)("div",{className:"chat-message-body",children:V(e)}),(0,H.jsxs)("div",{className:"message-collapse-bar",children:[(0,H.jsx)("button",{onClick:()=>v(e.id),children:_(n?"展开":"折叠")}),(0,H.jsx)("button",{onClick:b,children:_("全部折叠")}),"bot"===e.sender&&null!=e.elapsed_ms&&(0,H.jsx)("span",{className:"message-elapsed",children:(0,d.kf)(e.elapsed_ms)})]}),(0,H.jsx)("div",{className:"message-actions",children:s?(0,H.jsx)("button",{onClick:()=>c(e.id),children:t.has(e.id)?_("取消选择"):_("选择")}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)("button",{onClick:()=>r(e.id),children:_("删除")}),(0,H.jsx)("button",{onClick:()=>l(e),children:_("复制")}),(0,H.jsx)("button",{onClick:u,children:_("全部复制")}),(0,H.jsx)("button",{onClick:m,children:_("多选")})]})})]})]},e.id)}),(0,H.jsx)("div",{ref:o})]})},Y=(0,n.forwardRef)(function({placeholder:e="",disabled:s=!1,className:t,style:a,onEnter:i,onPaste:o,onChange:c},r){const l=(0,n.useRef)(null),[d,u]=(0,n.useState)(!0),[m,h]=(0,n.useState)(!1),g=(0,n.useCallback)(()=>{const e=l.current;return e?(e.textContent??"").replace(/\u00A0/g," ").trimEnd():""},[]);(0,n.useImperativeHandle)(r,()=>({getValue:()=>g(),setValue:e=>{const s=l.current;if(!s)return;s.textContent=e,u(!e);const t=document.createRange();t.selectNodeContents(s),t.collapse(!1);const n=window.getSelection();n?.removeAllRanges(),n?.addRange(t)},clear:()=>{const e=l.current;e&&(e.textContent="",u(!0))},focus:()=>l.current?.focus()})),(0,n.useEffect)(()=>{const e=l.current;if(!e)return;const s=()=>u(!e.textContent);return e.addEventListener("input",s),()=>e.removeEventListener("input",s)},[]);return(0,H.jsx)("div",{ref:l,contentEditable:!s,suppressContentEditableWarning:!0,className:"rich-textarea"+(t?" "+t:""),style:a,onKeyDown:e=>{m||"Enter"!==e.key||e.shiftKey||e.ctrlKey||e.metaKey||e.altKey||(e.preventDefault(),i?.())},onPaste:o,onInput:()=>c?.(g()),onCompositionStart:()=>h(!0),onCompositionEnd:()=>h(!1),"data-placeholder":d?e:void 0})});var ee=t(84369);function se({pendingAttachments:e,onRemove:s}){return 0===e.length?null:(0,H.jsx)("div",{className:"chat-attachment-strip",children:e.map((e,t)=>(0,H.jsxs)("div",{className:"chat-attachment-chip",children:[(0,H.jsx)(R.In,{icon:"attach_file"}),(0,H.jsx)("span",{title:e.name,children:e.name}),(0,H.jsx)("button",{type:"button",onClick:()=>s(t),children:(0,H.jsx)(R.In,{icon:"close"})})]},`${e.name}_${t}`))})}const te=(0,n.forwardRef)(({onSend:e,sending:s,onAbort:t,pendingAttachments:o,onRemoveAttachment:c,onOpenFilePicker:r,onAddFiles:l,onDrop:d,onDragOver:u,fileInputRef:m,readonly:h=!1},g)=>{const{t:p}=(0,i.Bd)(),_=(0,n.useRef)(null),f=(0,n.useRef)(null),[j,v]=(0,a.fp)(x.AG.ai_chat_input_height);(0,n.useImperativeHandle)(g,()=>({getValue:()=>_.current?.getValue()??"",setValue:e=>_.current?.setValue(e),clear:()=>_.current?.clear()}));const{dragging:b,on_pointer_down:w,on_pointer_up:y}=(0,ee.y)({direction:"vertical",get_start_size:()=>j,px_to_unit:e=>e/(()=>{const e=f.current;return e&&parseFloat(getComputedStyle(e).fontSize)||16})(),min:2,on_change:e=>v(e)}),S={minHeight:`${j}em`,maxHeight:`${j}em`};return(0,H.jsxs)("div",{ref:f,className:"chat-input-area"+(h?" readonly":""),onDrop:h?void 0:d,onDragOver:h?void 0:u,children:[!h&&(0,H.jsx)("div",{className:"chat-input-resize-handle"+(b?" dragging":""),onPointerDown:w}),(0,H.jsx)("input",{ref:m,type:"file",multiple:!0,style:{display:"none"},onChange:e=>{e.target.files?.length&&(l(e.target.files),e.currentTarget.value="")}}),(0,H.jsxs)("div",{className:"chat-input-shell",children:[(0,H.jsx)(se,{pendingAttachments:o,onRemove:c}),(0,H.jsx)(Y,{ref:_,placeholder:p(h?"查看全部会话时不可发送消息":"输入消息"),disabled:h,onEnter:()=>e(),onPaste:e=>{const s=e.clipboardData?.files;s&&s.length>0&&(e.preventDefault(),l(s))},className:"chat-input",style:S})]}),!h&&(0,H.jsx)(R.rA,{title:p("添加文件"),icon:"attach_file",onClick:r}),h?(0,H.jsx)("button",{className:"little-button button",disabled:!0,children:p("发送")}):s?(0,H.jsx)(R.Vi,{color:"var( --icon-red)",text:p("暂停"),clickFun:t}):(0,H.jsx)(R.Vi,{text:p("发送"),clickFun:e}),b&&(0,H.jsx)("div",{className:"chat-input-overlay",onPointerUp:y})]})}),ne=function(e){const{t:s}=(0,i.Bd)(),[t,o]=(0,n.useState)([]),[r,l]=(0,n.useState)(!1),[d,u]=(0,n.useState)(null),[m,h]=(0,n.useState)(null),[p,_]=(0,n.useState)(!1),[f,j]=(0,a.fp)(x.AG.ai_bg_expanded),[,v]=(0,a.fp)(x.AG.ai_session_collapsed),b=()=>{j(!1)},w=(0,n.useCallback)(async()=>{l(!0);try{const s=new c.hf(c.HK.ai_bg_process_list_req);s.context={};const t=await I.ws.send(s);t?.context?.processes&&(o(t.context.processes),e.panelRef?.current?.onCountChange?.(t.context.processes.length))}catch(e){console.error("获取后台进程列表失败",e)}finally{l(!1)}},[]);e.panelRef&&(e.panelRef.current.refresh=w);const y=(0,n.useCallback)(async e=>{_(!0),u(e);try{const s=new c.hf(c.HK.ai_bg_process_output_req);s.context={pid:e};const t=await I.ws.send(s);h(t.context)}catch(e){console.error("获取进程输出失败",e),(0,g.zN)("获取进程输出失败")}finally{_(!1)}},[]),S=(0,n.useCallback)(async e=>{try{const s=new c.hf(c.HK.ai_bg_process_kill_req);s.context={pid:e};const t=await I.ws.send(s);t?.context?.success?((0,g.SK)("进程已终止"),w(),d===e&&(u(null),h(null))):(0,g.zN)(t?.context?.message||"终止失败")}catch(e){console.error("终止进程失败",e),(0,g.zN)("终止进程失败")}},[w,d]);(0,n.useEffect)(()=>{w();const e=setInterval(w,5e3);return()=>clearInterval(e)},[w]);const N=t.filter(e=>e.running),k=t.filter(e=>!e.running);return(0,H.jsxs)(H.Fragment,{children:[f&&(0,H.jsx)("div",{className:"chat-session-overlay",onClick:b}),(0,H.jsxs)("aside",{className:"chat-bg-process-panel "+(f?"expanded":""),children:[(0,H.jsxs)("div",{className:"chat-bg-process-header",children:[(0,H.jsx)("span",{className:"chat-bg-process-title",children:s("后台进程")}),(0,H.jsx)(R.rA,{icon:"close",title:s("关闭"),onClick:b})]}),(0,H.jsxs)("div",{className:"chat-bg-process-toolbar",children:[(0,H.jsx)(R.rA,{icon:"refresh",title:s("刷新"),onClick:w}),(0,H.jsxs)("span",{className:"chat-bg-process-count",children:[N.length," ",s("个运行中"),k.length>0&&` / ${k.length} ${s("个已退出")}`]})]}),(0,H.jsxs)("div",{className:"chat-bg-process-list",children:[r&&0===t.length&&(0,H.jsx)("div",{className:"chat-bg-process-empty",children:s("加载中...")}),!r&&0===t.length&&(0,H.jsx)("div",{className:"chat-bg-process-empty",children:s("暂无后台进程")}),N.map(e=>(0,H.jsxs)("div",{className:`chat-bg-process-item ${d===e.pid?"active":""} running`,children:[(0,H.jsxs)("div",{className:"chat-bg-process-item-main",onClick:()=>y(e.pid),children:[(0,H.jsxs)("span",{className:"chat-bg-process-pid",children:["PID: ",e.pid]}),(0,H.jsx)("span",{className:"chat-bg-process-cmd",title:e.cmd,children:e.cmd.length>40?e.cmd.slice(0,40)+"...":e.cmd}),(0,H.jsx)("span",{className:"chat-bg-process-time",children:new Date(e.start_time).toLocaleTimeString()}),(0,H.jsx)("span",{className:"chat-bg-process-status running-dot",title:s("运行中"),children:"●"})]}),(0,H.jsxs)("div",{className:"chat-bg-process-item-actions",children:[(0,H.jsx)(R.rA,{icon:"terminal",title:s("查看输出"),onClick:()=>y(e.pid)}),(0,H.jsx)(R.rA,{icon:"stop",title:s("终止进程"),onClick:()=>S(e.pid)})]})]},e.pid)),k.map(e=>(0,H.jsx)("div",{className:`chat-bg-process-item ${d===e.pid?"active":""} finished`,children:(0,H.jsxs)("div",{className:"chat-bg-process-item-main",onClick:()=>y(e.pid),children:[(0,H.jsxs)("span",{className:"chat-bg-process-pid",children:["PID: ",e.pid]}),(0,H.jsx)("span",{className:"chat-bg-process-cmd",title:e.cmd,children:e.cmd.length>30?e.cmd.slice(0,30)+"...":e.cmd}),(0,H.jsx)("span",{className:"chat-bg-process-time",children:new Date(e.start_time).toLocaleTimeString()}),(0,H.jsxs)("span",{className:"chat-bg-process-exit-code",children:["exit: ",e.exit_code]})]})},e.pid))]}),null!==d&&(0,H.jsxs)("div",{className:"chat-bg-process-output",children:[(0,H.jsxs)("div",{className:"chat-bg-process-output-header",children:[(0,H.jsxs)("span",{children:["PID: ",d," ",s("输出")]}),(0,H.jsx)(R.rA,{icon:"close",title:s("关闭"),onClick:()=>{u(null),h(null)}})]}),(0,H.jsx)("div",{className:"chat-bg-process-output-content",children:p?(0,H.jsx)("div",{className:"chat-bg-process-empty",children:s("加载中...")}):m?(0,H.jsx)("pre",{className:"chat-bg-process-output-pre",children:m.output||s("(无输出)")}):null})]})]})]})};t(99214);function ae(e={}){const{inline_header:s=!1,session_id:t,file_cwd_path:v,sync_url:y=!0,on_session_change:N}=e,{t:k}=(0,i.Bd)(),[C,A]=(0,o.ok)(),R=y&&C.get("session")||"",D=e=>{y&&A(s=>{const t=new URLSearchParams(s);return e?t.set("session",e):t.delete("session"),t},{replace:!0})},V=(0,p.y)(),{check_user_auth:T}=(0,m.MH)();(0,f.w)();const[E,K]=(0,n.useState)([]),[B,z]=(0,n.useState)([]),[P,F]=(0,n.useState)(!1),[O,q]=(0,n.useState)(""),[G,U]=(0,n.useState)(null),[W,X]=(0,n.useState)(!1),Y=(0,n.useRef)(null),[ee,se]=(0,n.useState)([]),[ae]=(0,a.fp)(x.AG.user_base_info),ie=!!ae?.user_data?.is_root,[oe,ce]=(0,a.fp)(x.AG.ai_session_collapsed),[re,le]=(0,a.fp)(x.AG.ai_bg_expanded),[de,ue]=(0,a.fp)(x.AG.prompt_card),[me]=(0,a.fp)(x.AG.ai_chat_zoom),[he,ge]=(0,n.useState)(!1),[pe,_e]=(0,n.useState)(new Set),[fe,xe]=(0,n.useState)(new Set),[je,ve]=(0,n.useState)(""),be=(0,n.useRef)(null),we=(0,n.useRef)(null),ye=(0,n.useRef)(null),Se=(0,n.useRef)(!0),Ne=(0,n.useRef)(null),ke=(0,n.useRef)(null),Ce=(0,n.useRef)({}),Ae=(0,n.useRef)(O),$e=(0,n.useRef)(G);(0,n.useEffect)(()=>{Ae.current=O},[O]),(0,n.useEffect)(()=>{$e.current=G},[G]);const Ie=(0,n.useRef)({}),[Me,Re]=(0,n.useState)([]),[De,He]=(0,n.useState)(""),[Ve,Te]=(0,n.useState)([]),Ee=async()=>{try{const e=await r.jV.get("public_models");e.code===_.m.Success&&Te(e.data?.groups??[])}catch{Te([])}},Ke=e=>{He(e?.ai_config?.model??"")},[Be,ze]=(0,n.useState)(0),Le=(0,n.useRef)((0,l.sg)(e=>{K(e),Se.current&&Pe(!1)},50)).current,Pe=(e=!1)=>{const s=ye.current;s&&(s.scrollTo({top:s.scrollHeight,behavior:e?"smooth":"auto"}),requestAnimationFrame(()=>{const s=ye.current;s&&s.scrollTo({top:s.scrollHeight,behavior:e?"smooth":"auto"})}))},Fe=(0,n.useRef)(!1),Oe=(0,n.useRef)(!1);(0,n.useEffect)(()=>{Oe.current=P},[P]);const qe=(e,s={})=>r.jV.post("admin/session",{action:e,...s}),Ge=async()=>{const e=Oe.current?await qe("list_all_sessions"):await r.jV.get("sessions");e.code===_.m.Success&&z(e.data??[])},Ue=(e,s)=>{z(t=>{const n=t.find(s=>s.id===e);return n&&!!n.running!==s?t.map(t=>t.id===e?{...t,running:s}:t):t})},Je=function(e){const{getMessages:s,setMessages:t,setMessagesDebounced:a,setSending:i,getActiveSessionId:o,setActiveSessionId:r,refreshSessions:l,scrollToBottom:d,buildRequestMessages:u,getSelectedSysPromptId:m}=e,h=(0,n.useRef)([]),g=(0,n.useRef)(null),p=(e,n,r)=>{const h=[...s(),n];t(h),i(e),g.current={abort:()=>{}};const p={id:n.id+1,sender:"bot",text:"AI thinking ...",is_loading:!0};h.push(p),t([...h]);const _=new Map,f=()=>{o()===e&&a([...h])},x=()=>{const e=h.indexOf(p);-1!==e&&h.splice(e,1)},j=s=>{const t=s.context||{};if(t.session_id!==e)return;const n=t.text||"",a=t.tool_call_ends,i=t.chunk_index??0;if(t.notice)return p.text=n,p.is_loading=!0,h.includes(p)||h.push(p),void f();if("[DONE]"===n)return;if(!n&&!a)return;x();let o=_.get(i);o||(o={id:Date.now()+Math.random(),sender:"bot",text:"",is_loading:!0},h.push(o),_.set(i,o)),n&&(o.text=o.text+n,o.is_loading=!1),a&&(o.content_list=[{tool_call_ends:a,content:o.text,role:"assistant"}],o.is_loading=!1),f()},v=s=>{const n=s.context||{};if(n.session_id===e){if(w(),g.current=null,i(s=>s===e?null:s),o()===e)if(n.once_messages_list?.length){const e=S(n.once_messages_list);t(s=>{const t=s.filter(M),n=t[t.length-1];return"bot"===n?.sender?[...t.slice(0,-1),...e]:[...t,...e]})}else t(h.filter(M));l(),d(!0),r()}},b=s=>{const n=s.context||{};if(n.session_id!==e)return;w(),g.current=null,i(s=>s===e?null:s);const a="AI request error: "+(n.message||"未知错误");x();const c=[...h].reverse().find(e=>"bot"===e.sender);c?(c.text=c.text?`${c.text}\n\n${a}`:a,c.is_loading=!1):h.push({id:Date.now()+Math.random(),sender:"bot",text:a}),o()===e&&t([...h]),r()},w=()=>{I.ws.off_message(`message_${c.HK.ai_chat_msg}`,j),I.ws.off_message(`message_${c.HK.ai_chat_end}`,v),I.ws.off_message(`message_${c.HK.ai_chat_error}`,b)};I.ws.addMsg(c.HK.ai_chat_msg,j),I.ws.addMsg(c.HK.ai_chat_end,v),I.ws.addMsg(c.HK.ai_chat_error,b),I.ws.sendData(c.HK.ai_chat_req,{messages:u(n),session_id:e,sys_prompt_id:m()})},_=()=>{const e=h.current;if(0===e.length)return;const s=e.shift();if(!s)return;t(e=>e.map(e=>"user"===e.sender&&e.text.includes("⏳(排队中...)")?{...e,text:e.text.replace(" ⏳(排队中...)","")}:e));const n={id:Date.now(),sender:"user",text:s.text,attachments:s.attachments};p(o(),n,_)};return{startChatStream:p,processPendingQueue:_,enqueueMessage:(e,s)=>{h.current.push({text:e,attachments:s})},getQueueLength:()=>h.current.length,abort:()=>{const e=o();e&&(I.ws.sendData(c.HK.ai_chat_abort,{session_id:e}),g.current&&(g.current=null,i(s=>s===e?null:s)))}}}({getMessages:()=>E,setMessages:K,setMessagesDebounced:Le,setSending:U,getActiveSessionId:()=>Ae.current,setActiveSessionId:q,refreshSessions:Ge,scrollToBottom:Pe,buildRequestMessages:e=>{const s=(e.attachments??[]).filter(e=>"image"===e.kind);if(s.length>0){const t=[];e.text&&t.push({type:"text",text:e.text});for(const e of s)t.push({type:"image_url",image_url:{url:e.content}});return[{content:t,role:"user",attachments:e.attachments??[]}]}return[{content:e.text,role:"bot"===e.sender?"assistant":"user",attachments:e.attachments??[]}]},getSelectedSysPromptId:()=>je}),We=async e=>{const s=Oe.current?await qe("list_all_sessions"):await r.jV.get("sessions");if(s.code!==_.m.Success)return!1;const t=s.data??[];z(t);const n=null===e?t[0]?.id??"":e||O||t[0]?.id||"";if(n){const e=t.find(e=>e.id===n)?.user_id;return await Qe(n,!1,e)}return K([]),q(""),D(null),!1},Qe=async(e,s=!1,t)=>{const n=t??B.find(s=>s.id===e)?.user_id,a=Oe.current&&n?await qe("get",{session_id:e,user_id:n}):await r.jV.post("session/get",{session_id:e});if(a.code!==_.m.Success||!a.data)return!1;const i=a.data;q(i.id),y&&R!==i.id&&D(i.id),N?.(i.id),X(!!i.running),ke.current&&ke.current!==i.id&&I.ws.sendData(c.HK.ai_chat_subscribe,{session_id:ke.current,subscribe:!1}),ke.current=i.running?i.id:null,ke.current&&I.ws.sendData(c.HK.ai_chat_subscribe,{session_id:ke.current,subscribe:!0});const o=S(i.messages);return i.running&&i.live_messages?.length?K([...o,...S(i.live_messages)]):K(o),ve(i.sys_prompt_id??""),s&&ce(!1),Ce.current.refresh?.(),Fe.current=!0,!0},Xe=e=>{if(Oe.current)return B.find(s=>s.id===e)?.user_id},Ze=e=>{const s=Array.from(e??[]).filter(Boolean);s.length&&se(e=>[...e,...s])},Ye=()=>{he&&(_e(new Set),xe(new Set)),ge(e=>!e)},es=()=>{0!==pe.size&&V({sub_title:k("cf_msgs"),confirm_fun:async()=>{const e=[];if(E.forEach((s,t)=>{pe.has(s.id)&&e.push(t)}),K(E.filter(e=>!pe.has(e.id))),_e(new Set),ge(!1),O&&e.length>0){const s=Xe(O);s?qe("message_delete",{session_id:O,user_id:s,indices:e}).catch(console.error):r.jV.post("session/message/delete",{session_id:O,indices:e}).catch(console.error)}}})},ss=async()=>{const e=await r.XO.get("ai_agent_setting/env");if(e.code===_.m.Success&&(Ie.current=e.data,Ke(e.data)),await Ee(),v){const e=await(async e=>{if(!e)return null;const s=await r.jV.get("sessions");if(s.code!==_.m.Success)return null;const t=s.data??[];e=(0,d.ed)(e);const n=t.find(s=>(0,d.ed)(s.file_cwd_path)===e);if(n)return n.id;const a=await r.jV.post("session",{file_cwd_path:e});return a.code!==_.m.Success?null:a.data.id})(v);!!e&&await We(e)||await We()}else if(t){await We(t)||await We()}else if(R){await We(R)||await We()}else await We();const s=await r.jV.get("system_prompts");s.code===_.m.Success&&Re(s.data??[])};(0,n.useEffect)(()=>{ss(),requestAnimationFrame(()=>Pe(!1)),Ce.current.onCountChange=ze,Ce.current.refresh?.();const e=e=>{const s=e?.context?.count;"number"==typeof s&&ze(s)};return I.ws.addMsg(c.HK.ai_bg_process_count_notify,e),()=>{I.ws.off_message(`message_${c.HK.ai_bg_process_count_notify}`,e)}},[]),(0,n.useEffect)(()=>{const e=ye.current;if(!e)return;const s=()=>{Se.current=((e,s=120)=>{const{scrollTop:t,scrollHeight:n,clientHeight:a}=e;return n-(t+a)<s})(e)};e.addEventListener("scroll",s);const t=()=>{Se.current&&(e.scrollTop=e.scrollHeight)},n=new ResizeObserver(t),a=()=>[...e.children].forEach(e=>n.observe(e));a();const i=new MutationObserver(()=>{a(),t()});return i.observe(e,{childList:!0}),()=>{e.removeEventListener("scroll",s),n.disconnect(),i.disconnect()}},[]),(0,n.useEffect)(()=>{const e=()=>Ae.current,s=()=>$e.current,t=(t,n)=>{if(Ue(t,!1),e()&&e()===t){if(Ne.current=null,X(!1),ke.current===t&&(I.ws.sendData(c.HK.ai_chat_subscribe,{session_id:t,subscribe:!1}),ke.current=null),s()===t)return;n?.length?K(e=>{const s=S(n),t=e.filter(e=>"bot"!==e.sender||e.text||e.content_list?.length||e.attachments?.length),a=t[t.length-1];return"bot"===a?.sender?[...t.slice(0,-1),...s]:[...t,...s]}):Qe(t).catch(()=>{})}Ge()},n=t=>{const n=t?.context||{};var a,i,o,c;n.session_id&&(a=n.session_id,i=n.text||"",o=n.tool_call_ends,c=n.notice,e()&&e()===a&&s()!==a&&K(e=>{const s=e[e.length-1],t=s&&"bot"===s.sender?{...s}:{id:Date.now()+Math.random(),sender:"bot",text:""};return c?(t.text=i,t.is_loading=!0):i&&(t.text=t.text+i,t.is_loading=!1),o&&(t.content_list=[{tool_call_ends:o,content:t.text,role:"assistant"}]),Ne.current=t.id,Se.current&&requestAnimationFrame(()=>Pe(!1)),s&&"bot"===s.sender?[...e.slice(0,-1),t]:[...e,t]}),Ue(n.session_id,!0))},a=e=>{const s=e?.context||{};s.session_id&&t(s.session_id,s.once_messages_list)},i=e=>{const s=e?.context||{};s.session_id&&t(s.session_id)};return I.ws.addMsg(c.HK.ai_chat_msg,n),I.ws.addMsg(c.HK.ai_chat_end,a),I.ws.addMsg(c.HK.ai_chat_error,i),()=>{I.ws.off_message(`message_${c.HK.ai_chat_msg}`,n),I.ws.off_message(`message_${c.HK.ai_chat_end}`,a),I.ws.off_message(`message_${c.HK.ai_chat_error}`,i),ke.current&&(I.ws.sendData(c.HK.ai_chat_subscribe,{session_id:ke.current,subscribe:!1}),ke.current=null)}},[]),(0,n.useLayoutEffect)(()=>{Fe.current&&(Fe.current=!1,Se.current=!0),Se.current&&Pe(!1)},[E]);return(0,H.jsxs)(n.Fragment,{children:[(0,H.jsx)(J,{inline:s,currentModelName:De,setCurrentModelName:He,modelGroups:Ve,onModelChanged:async()=>{await Ee();const e=await r.XO.get("ai_agent_setting/env");e.code===_.m.Success&&(Ie.current=e.data,Ke(e.data))},sysPromptList:Me,batchMode:he,selectedMsgCount:pe.size,sessionVisible:!oe,onToggleSessionPanel:()=>{ce(e=>!e)},onCreateSession:async e=>{const s=e??"",t=await r.jV.post("session",{sys_prompt_id:s||void 0,file_cwd_path:v||void 0});if(t.code!==_.m.Success)return;const n=t.data;q(n.id),K([]),ve(n.sys_prompt_id??""),ce(!1),await We(n.id),requestAnimationFrame(()=>{const e=document.querySelector(".chat-input");e&&(e.style.height="auto",e.style.height=Math.min(e.scrollHeight,200)+"px")})},onBatchDeleteMessages:es,bgProcessVisible:re,bgProcessCount:Be,onToggleBgProcess:()=>le(e=>!e),selectedSysPromptId:je,setSelectedSysPromptId:e=>{if(ve(e),O){const s=Xe(O);s?qe("sys_prompt",{session_id:O,user_id:s,sys_prompt_id:e||void 0}).catch(console.error):r.jV.post("session/sys_prompt",{session_id:O,sys_prompt_id:e||void 0}).catch(console.error)}}}),(0,H.jsxs)("div",{className:"chat-page"+(s?" chat-page--embedded":" chat-page-with-sessions"),style:{"--ai-chat-zoom":me},children:[!oe&&(0,H.jsx)("div",{className:"chat-session-overlay",onClick:()=>ce(!0)}),!oe&&(0,H.jsx)(Q,{sessions:B,activeSessionId:O,onSelectSession:e=>Qe(e,!1),onReorderSessions:(e,s)=>{if(Oe.current)return;const t=B.findIndex(s=>s.id===e),n=B.findIndex(e=>e.id===s);if(t<0||n<0||t===n)return;const a=(0,u.TI)(B,t,n);z(a),r.jV.post("sessions/update/sort",{session_ids:a.map(e=>e.id)}).catch(()=>{})},onRenameSession:(e,s)=>{let t=s;V({confirm_fun:async()=>{const s=Xe(e);s?await qe("rename",{session_id:e,user_id:s,title:t}):await r.jV.post("sessions/update/meta",{id:e,title:t}),await We(O)},context_div:(0,H.jsx)("div",{className:"card-content",children:(0,H.jsx)(j.Sm,{value:t,handleInputChange:e=>{t=e}})})})},onDeleteSession:e=>{V({sub_title:"确认删除这个会话吗?",confirm_fun:async()=>{const s=Xe(e);s?await qe("delete",{session_id:e,user_id:s}):await r.jV.post("session/delete",{session_id:e}),O===e?(q(""),await We(null)):await We(O)}})},onToggleCmdAuto:async(e,s)=>{const t=Xe(e);t?await qe("cmd_auto",{session_id:e,user_id:t,allow:s}):await r.jV.post("session/cmd_auto_allow",{session_id:e,allow:s}),(0,g.SK)(k(s?"命令检测已开启":"命令检测已关闭")),await We(O)},onShowUsageStats:async e=>{ue({open:!0,title:k("Token消耗统计"),context_div:(0,H.jsx)("div",{className:"usage-stats-loading",children:k("加载中...")}),cancel:()=>ue({open:!1})});try{const s=Xe(e),t=s?await qe("usage_stats",{session_id:e,user_id:s}):await r.jV.post("session/usage_stats",{session_id:e});if(t.code===_.m.Success&&t.data){const e=t.data;ue({open:!0,title:k("Token消耗统计"),context_div:(0,H.jsxs)("div",{className:"usage-stats-panel",children:[[{l:k("对话轮次"),v:(e.turns??0).toString()},{l:k("AI输入Token"),v:b(e.input_tokens)},{l:k("AI输出Token"),v:b(e.output_tokens)},{l:k("AI输入Token(最近一轮)"),v:b(e.recent_input_tokens)},{l:k("AI输出Token(最近一轮)"),v:b(e.recent_output_tokens)}].map((e,s)=>(0,H.jsxs)("div",{className:"usage-stats-row",children:[(0,H.jsx)("span",{className:"usage-stats-label",children:e.l}),(0,H.jsx)("span",{className:"usage-stats-value",children:e.v})]},s)),(0,H.jsxs)("div",{className:"usage-stats-row usage-stats-total",children:[(0,H.jsx)("span",{className:"usage-stats-label",children:k("AI Token总计消耗")}),(0,H.jsx)("span",{className:"usage-stats-value",children:b((e.input_tokens||0)+(e.output_tokens||0))})]})]}),cancel:()=>ue({open:!1})})}else ue({open:!0,title:k("Token消耗统计"),context_div:(0,H.jsx)("div",{className:"usage-stats-empty",children:k("暂无统计数据")}),cancel:()=>ue({open:!1})})}catch{ue({open:!0,title:k("Token消耗统计"),context_div:(0,H.jsx)("div",{className:"usage-stats-empty",children:k("暂无统计数据")}),cancel:()=>ue({open:!1})})}},onShowSessionSetting:e=>{let s=B.find(s=>s.id===e)?.file_cwd_path??"";ue({open:!0,title:k("会话设置"),context_div:(0,H.jsxs)("div",{className:"session-setting",children:[(0,H.jsx)("div",{className:"session-setting__label",children:k("服务器工作目录")}),(0,H.jsx)(j.Sm,{value:s,placeholder:k("服务器工作目录提示"),handleInputChange:e=>{s=e}})]}),confirm:async()=>{try{const t=Xe(e);(t?await qe("setting",{session_id:e,user_id:t,file_cwd_path:s.trim()}):await r.jV.post("session/setting",{session_id:e,file_cwd_path:s.trim()})).code===_.m.Success&&(0,g.SK)(k("保存成功"))}catch{}ue({open:!1}),await We(O)},cancel:()=>ue({open:!1})})},batchMode:he,selectedSessionIds:fe,onToggleSessionSelect:e=>{xe(s=>{const t=new Set(s);return t.has(e)?t.delete(e):t.add(e),t})},onToggleBatchMode:Ye,onBatchDeleteSessions:()=>{0!==fe.size&&V({sub_title:k("cf_ses"),confirm_fun:async()=>{if(Oe.current)await qe("batch_delete",{session_ids:Array.from(fe)});else for(const e of fe)await r.jV.post("session/delete",{session_id:e});xe(new Set),ge(!1),fe.has(O)?(q(""),await We(null)):await We(O)}})},onClearAllSessions:P?void 0:()=>{V({sub_title:k("cf_all"),confirm_fun:async()=>{await r.jV.post("sessions/clear",{}),q(""),K([]),await We(null)}})},allUsersMode:P,onToggleAllUsersMode:async()=>{const e=!P;F(e),Oe.current=e,q(""),K([]);const s=e?await qe("list_all_sessions"):await r.jV.get("sessions"),t=s.code===_.m.Success?s.data??[]:[];z(t),t[0]?.id&&await Qe(t[0].id,!1,t[0].user_id)},showAllUsersEntry:ie}),(0,H.jsx)(ne,{panelRef:Ce}),(0,H.jsxs)("section",{className:"chat-main",children:[0===E?.length&&(0,H.jsx)("div",{className:"chat-header",children:(0,H.jsx)("div",{children:k("ai_ask")})}),(0,H.jsx)(Z,{messages:E,batchMode:he,selectedMsgIds:pe,sending:G===O||W,chatContainerRef:ye,messagesEndRef:we,onToggleMsgSelect:e=>{_e(s=>{const t=new Set(s);return t.has(e)?t.delete(e):t.add(e),t})},onDelete:e=>{V({sub_title:k("cf_one"),confirm_fun:async()=>{const s=E.findIndex(s=>s.id===e);if(s<0)return;const t=E.filter(s=>s.id!==e);if(K(t),O){const e=Xe(O);e?qe("message_delete",{session_id:O,user_id:e,indices:[s]}).catch(console.error):r.jV.post("session/message/delete",{session_id:O,indices:[s]}).catch(console.error)}}})},onCopy:async e=>{(0,h.lW)(w(e)),(0,g.SK)("复制成功")},onCopyAll:async()=>{if(!B.length)return void(0,g.SK)("暂无聊天记录");const e=[];for(const s of B){const t=s.user_id?await qe("get",{session_id:s.id,user_id:s.user_id}):await r.jV.post("session/get",{session_id:s.id});if(t.code!==_.m.Success||!t.data)continue;const n=t.data,a=S([...n.messages??[],...n.live_messages??[]]).map(w).filter(Boolean).join("\n\n\n");a&&e.push(a)}e.length?((0,h.lW)(e.join("\n\n\n")),(0,g.SK)("复制成功")):(0,g.SK)("暂无聊天记录")},onToggleBatchMode:Ye,onBatchCopy:()=>{const e=E.filter(e=>pe.has(e.id)).map(w).filter(Boolean).join("\n\n\n");e?((0,h.lW)(e),(0,g.SK)("复制成功")):(0,g.SK)("暂无内容")},onBatchDelete:es,showBatchBar:he&&pe.size>0&&0===fe.size,t:k}),(0,H.jsx)(te,{ref:Y,onSend:async()=>{if(Oe.current)return;const e=(Y.current?.getValue()??"").trim();if(!e&&0===ee.length)return;if(G===O){const s=await $(ee);Je.enqueueMessage(e,s),Y.current?.clear(),se([]);const t={id:Date.now(),sender:"user",text:e+(Je.getQueueLength()>1?" ⏳(排队中...)":""),attachments:s};return void K(e=>[...e,t])}let s=O;if(!s){const t=await r.jV.post("session",{title:(e||ee[0]?.name).slice(0,28),sys_prompt_id:void 0,file_cwd_path:v||void 0});if(t.code!==_.m.Success)return;s=t.data.id,q(s),N?.(s),await We(s)}const t=await $(ee),n={id:Date.now(),sender:"user",text:e,attachments:t};Y.current?.clear(),se([]);const a=Ie?.current?.ai_config?.request_type||"completions";if("completions"!==a){const t={id:n.id+1,sender:"bot",text:"处理中...",is_loading:!0},i=[...E,n,t];K(i),U(s);return void(await L(a,e,s,async(e,s)=>{t.text=e,t.is_loading=!1,s?.images&&(t.images=s.images),s?.audio&&(t.audio=s.audio),s?.embeddings&&(t.embeddings=s.embeddings),K([...i]),U(null),Ge(),Pe(!0),Je.processPendingQueue()})||(t.text=`请求类型 "${a}" 的专用处理器尚未实现,请使用 completions 类型。`,t.is_loading=!1,K([...i]),U(null),Je.processPendingQueue()))}Je.startChatStream(s,n,()=>Je.processPendingQueue())},readonly:P,sending:G===O||W,onAbort:Je.abort,pendingAttachments:ee,onRemoveAttachment:e=>{se(s=>s.filter((s,t)=>t!==e))},onOpenFilePicker:()=>{be.current?.click()},onAddFiles:Ze,onDrop:e=>{const s=e.dataTransfer?.files;s&&s.length>0&&(e.preventDefault(),Ze(s))},onDragOver:e=>{e.dataTransfer?.types?.includes("Files")&&e.preventDefault()},fileInputRef:be})]})]})]})}},72693(e,s,t){t.d(s,{w:()=>h});var n=t(96540),a=t(22022),i=t(14944),o=t(92275),c=t(34843),r=t(82893),l=t(85997),d=t(14284),u=t(74848);function m(e){const{t:s}=(0,a.Bd)(),[t,i]=(0,n.useState)(!1),o=!!e.sessionId;return(0,u.jsxs)("div",{children:[(0,u.jsx)("div",{style:{maxHeight:"60vh",overflow:"auto",whiteSpace:"pre-wrap",wordBreak:"break-all",background:"var(--surfaceSecondary)",padding:"0.75em",borderRadius:"0.5em",marginBottom:"0.75em",fontFamily:"monospace",fontSize:"0.9em",lineHeight:"1.5"},children:e.cmd}),o&&(0,u.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"0.5em",marginBottom:"0.75em",color:t?"var(--icon-blue)":"var(--textSecondary)"},children:[(0,u.jsx)(l.Ay,{checked:t,onChange:s=>{i(s),s&&e.onAutoAllow()},title:s("此会话不再询问")}),(0,u.jsx)("span",{children:s("此会话不再询问")})]}),(0,u.jsxs)("div",{style:{display:"flex",gap:"0.5em",justifyContent:"flex-end"},children:[(0,u.jsx)(l.$n,{text:s("拒绝"),color:"var(--red)",clickFun:e.onDeny}),(0,u.jsx)(l.$n,{text:s("允许"),clickFun:e.onAllow})]})]})}function h(){const[e,s]=(0,c.fp)(r.AG.prompt_card),{t}=(0,a.Bd)(),l=(0,n.useRef)([]),h=(0,n.useRef)(!1),g=(0,n.useRef)(null),p=(0,n.useRef)(void 0),_=(0,n.useRef)(()=>{}),f=(0,n.useCallback)(e=>{s({open:!1}),h.current=!1,g.current&&(i.ws.sendData(o.HK.ai_confirm_cmd,{askId:g.current,approved:e}),g.current=null),_.current()},[s]),x=(0,n.useCallback)(()=>{if(h.current)return;if(0===l.current.length)return h.current=!1,void s({open:!1});h.current=!0;const e=l.current.shift();e?(g.current=e.askId,p.current=e.session_id,s({open:!0,title:t("命令确认"),cancel:()=>f(!1),context_div:(0,u.jsx)(m,{cmd:e.cmd,sessionId:e.session_id,onDeny:()=>f(!1),onAllow:()=>f(!0),onAutoAllow:async()=>{if(p.current)try{await d.jV.post("session/cmd_auto_allow",{session_id:p.current,allow:!0})}catch(e){console.error("设置会话命令免确认失败",e)}f(!0)}})})):h.current=!1},[t,f,s]);_.current=x;const j=(0,n.useCallback)(e=>{l.current.push(e),x()},[x]);(0,n.useEffect)(()=>{const e=e=>{const t=e.context||{};if(t.dismiss&&t.askId)return l.current=l.current.filter(e=>e.askId!==t.askId),void(h.current&&g.current===t.askId&&(g.current=null,h.current=!1,s({open:!1}),x()));t.askId&&t.cmd&&j({askId:t.askId,cmd:t.cmd,session_id:t.session_id})};return i.ws.addMsg(o.HK.ai_confirm_cmd,e),()=>{i.ws.off_message(`message_${o.HK.ai_confirm_cmd}`,e)}},[j]),(0,n.useEffect)(()=>()=>{l.current=[],h.current=!1,g.current=null},[])}},34299(e,s,t){t.r(s),t.d(s,{default:()=>y});var n=t(96540),a=t(23802),i=t(53995),o=t(18569),c=t(77979),r=t(8263),l=t(69428),d=t.n(l),u=(t(3775),t(21499)),m=t(99214),h=t(89117),g=t(86063),p=t(89334),_=t(41105),f=t(52388),x=t(19878),j=(t(72411),t(74848));const v=new a.A({html:!0,highlight:function(e,s){if(s&&x.A.getLanguage(s))try{return`<pre class="hljs code-block-with-copy"><code class="hljs language-${s}">${x.A.highlight(e,{language:s}).value}</code></pre>`}catch(e){}try{return`<pre class="hljs code-block-with-copy"><code class="hljs">${x.A.highlightAuto(e).value}</code></pre>`}catch(e){}return`<pre class="hljs code-block-with-copy"><code>${v.utils.escapeHtml(e)}</code></pre>`}});async function b(e,s){e.className="md-graph md-graph--mind md-graph--loading",e.textContent=f.A.t("rendering");const t=await(0,g.Hn)(s);e.isConnected&&(e.className="md-graph md-graph--mind",e.textContent="",await t.mount(e))}function w(e){const s=e.className.match(/language-([\w-]+)/);return s?s[1]:""}function y(e){const s=(0,n.useRef)(null);return(0,m.VD)(),(0,n.useEffect)(()=>{s.current&&(s.current.innerHTML=v.render(e.context??""),async function(e){const s=e.querySelectorAll("pre > code[class*='language-']");for(const e of Array.from(s)){const s=w(e),t=(0,h.Hm)(s),n=(0,g.hj)(s);if(!t&&!n)continue;const a=e.closest(".code-block-with-copy")??e.parentElement;if(!a)continue;const i=e.textContent??"",o=document.createElement("div");if(a.replaceWith(o),n){try{await b(o,i)}catch(e){console.error("[mind] render failed",e),o.className="md-graph md-graph--mind",o.textContent=String(e)}continue}o.className="md-graph md-graph--loading",o.textContent=f.A.t("rendering");const c=await(0,h.U6)(s,i);o.isConnected&&(c.error?(o.className="md-graph md-graph--error",o.textContent=c.error):(o.className="md-graph",o.innerHTML=c.svg))}}(s.current),(0,p.rg)(s.current))},[e.context]),(0,j.jsx)("div",{ref:s})}v.use(i.A).use(o.A).use(c.A).use(r.A).use(d()).use(e=>{e.renderer.rules.fence;e.renderer.rules.fence=(s,t,n,a,i)=>{const o=s[t],c=o.content.trim(),r=o.info.trim();let l="";if(r&&x.A.getLanguage(r))try{l=x.A.highlight(c,{language:r}).value}catch(s){l=e.utils.escapeHtml(c)}else try{l=x.A.highlightAuto(c).value}catch(s){l=e.utils.escapeHtml(c)}return`\n <div class="code-block-with-copy">\n <div class="code-header">\n <span class="code-language">${r||"code"}</span>\n <button class="copy-btn" data-code="${e.utils.escapeHtml(c)}">复制</button>\n </div>\n <pre><code class="hljs ${r?`language-${r}`:""}">${l}</code></pre>\n </div>`}}).use(e=>{const s=e.renderer.rules.link_open||function(e,s,t,n,a){return a.renderToken(e,s,t)};e.renderer.rules.link_open=(e,t,n,a,i)=>{const o=e[t],c=o.attrIndex("href");if(c>=0){const e=o.attrs[c][1];o.attrs[c][1]=(0,u.bi)(window.location.href,e)}return s(e,t,n,a,i)}}),(0,p.Rh)(v,_.pC)},84369(e,s,t){t.d(s,{y:()=>o});var n=t(96540),a=t(2543);function i(e){if(void 0!==e)return"function"==typeof e?e():e}function o(e){const{direction:s="vertical",target_ref:t,get_start_size:o,px_to_unit:c,min:r,max:l,throttle:d,on_change:u,on_drag_end:m}=e,[h,g]=(0,n.useState)(!1),p=(0,n.useRef)(null),_=(0,n.useRef)(u);_.current=u;const f=e=>"vertical"===s?e.clientY:e.clientX,x=(0,n.useRef)({direction:s,get_start_size:o,px_to_unit:c,min:r,max:l,get_pos:f});x.current={direction:s,get_start_size:o,px_to_unit:c,min:r,max:l,get_pos:f};const j=(0,n.useCallback)(e=>{const s=p.current;if(!s)return;const{px_to_unit:t,min:n,max:a,get_pos:o}=x.current,c=s.pos-o(e);let r=s.size+t(c);const l=i(n),d=i(a);void 0!==l&&(r=Math.max(l,r)),void 0!==d&&(r=Math.min(d,r)),_.current(r)},[]),v=n.useMemo(()=>void 0===d?j:a.throttle(e=>j(e),d),[d,j]),b=(0,n.useCallback)(()=>{p.current=null,g(!1);const e=v;"function"==typeof e.cancel&&e.cancel(),m?.()},[v,m]),w=(0,n.useCallback)(e=>{const{get_start_size:s,get_pos:t}=x.current;p.current={pos:t(e),size:s()},g(!0)},[]);return(0,n.useEffect)(()=>{if(!h)return;const e=t?.current??window;return e.addEventListener("pointermove",v),e.addEventListener("pointerup",b),()=>{e.removeEventListener("pointermove",v),e.removeEventListener("pointerup",b)}},[h,v,b,t]),(0,n.useEffect)(()=>{const e=v;return()=>{"function"==typeof e.cancel&&e.cancel()}},[v]),{dragging:h,on_pointer_down:w,on_pointer_up:b}}},60840(e){e.exports="data:image/svg+xml,<svg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 16 16%27 version=%271.1%27 aria-hidden=%27true%27><path fill-rule=%27evenodd%27 d=%27M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z%27></path></svg>"}}]);
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[5308],{65308(e,t,o){o.r(t),o.d(t,{default:()=>p});var a=o(96540),n=o(34843),i=o(82893),r=o(34289),d=o(14284),s=o(38240),c=o(62042),l=o(61973),m=o(74848);let f,u=!1;function p(){const[e,t]=(0,n.fp)(i.AG.image_editor),o=(0,l.Zp)();(0,l.zy)();return(0,a.useEffect)(()=>((async()=>{if(!u)try{await(0,s.J)("filerobot-image-editor.min.js"),u=!0}catch(e){return void(0,c.zN)("加载资源失败")}const a=(0,r.GG)("file",e.path),n=window.FilerobotImageEditor,{TABS:i,TOOLS:l}=n,m={defaultSavedImageName:e.name,source:d.$M.getDownloadUrl(a),onSave:async(t,o)=>{const n=t.extension,i=t.name??e.name,s=await new Promise(e=>t.imageCanvas.toBlob(e,t.mimeType));await d.$M.put(`${encodeURIComponent(`${(0,r.Yp)(a)}${i}.${n}`)}`,s,void 0),(0,c.SK)("保存成功")},annotationsCommon:{fill:"#151717",stroke:"#ec0f42",shadowColor:"#151717"},Text:{text:""},Rotate:{angle:90,componentType:"slider"},tabsIds:[Object.values(i)],defaultTabId:i.ANNOTATE,defaultToolId:l.ANNOTATE};f=new n(document.querySelector("#editor_container"),m),f.render({onClose:a=>{f.terminate();const n=e.close;t({}),n?.(),o((0,r.vX)())}})})(),()=>{f&&f.terminate()}),[]),(0,m.jsx)("div",{id:"image-editor-container",children:(0,m.jsx)("div",{className:"image-editor-context",children:(0,m.jsx)("div",{id:"editor_container",className:"image-editor-context"})})})}}}]);
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[5516],{52811(e,t,a){a.r(t),a.d(t,{default:()=>f,parseScene:()=>A});var n=a(96540),s=a(60882),r=a(34843),l=a(82893),o=a(14284),i=a(34289),c=a(62042),d=a(61973),u=a(57889),g=a(22022),m=a(53459),w=(a(3561),a(74848));function A(e){if(!e)return null;const t="string"==typeof e?e:e.context??e.data??e;if(!t)return null;try{return"string"==typeof t?JSON.parse(t):t}catch{return null}}function f(){const[e,t]=(0,r.fp)(l.AG.excalidraw_editor),[a,f]=(0,n.useState)(null),[x,p]=(0,n.useState)(null),[v,h]=(0,n.useState)(!1),y=(0,d.Zp)(),{t:S}=(0,g.Bd)(),k=(0,n.useRef)(()=>{});(0,n.useEffect)(()=>{k.current=z}),(0,n.useEffect)(()=>{let t=!1;return(async()=>{if(e?.url){h(!0);try{const a=await u.l.get(e.url);if(t)return;const n=A(a);if(!n)throw new Error("invalid excalidraw scene");p(n)}catch{t||(p(null),(0,c.zN)("Load Excalidraw file failed"))}finally{t||h(!1)}}else p(null)})(),()=>{t=!0}},[e?.url]);const z=async()=>{if(!a)return void(0,c.zN)("Editor is not ready");const t=a.getSceneElements(),n=a.getAppState(),r=a.getFiles(),l=(0,s.nu)(t,n,r,"local"),d=JSON.parse(l);d.appState={...d.appState??{},zoom:n.zoom,scrollX:n.scrollX,scrollY:n.scrollY,viewBackgroundColor:n.viewBackgroundColor,gridSize:n.gridSize};(await o.$M.post(`save/${encodeURIComponent((0,i.GG)("file",(0,i.vX)()))}${e.name}`,{context:JSON.stringify(d)})).code===m.m.Success&&(0,c.SK)("保存成功")};return(0,n.useEffect)(()=>{const e=e=>{(e.ctrlKey||e.metaKey)&&("s"===e.key||"S"===e.key||83===e.keyCode)&&(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),k.current())};return window.addEventListener("keydown",e,!0),document.addEventListener("keydown",e,!0),()=>{window.removeEventListener("keydown",e,!0),document.removeEventListener("keydown",e,!0)}},[]),(0,w.jsx)("div",{id:"excalidraw-container",children:(0,w.jsxs)("div",{className:"excalidraw-context",children:[v&&(0,w.jsx)("div",{className:"common-box common-box-center",children:"Loading..."}),!v&&x&&(0,w.jsx)(s.Td,{langCode:"zh-CN",initialData:x,excalidrawAPI:e=>f(e),onKeyDown:e=>!(!e.ctrlKey&&!e.metaKey||"s"!==e.key&&"S"!==e.key&&83!==e.keyCode)&&(e.preventDefault(),k.current(),!0),UIOptions:{dockedSidebarBreakpoint:0},children:(0,w.jsxs)(s.zU,{children:[(0,w.jsx)(s.zU.Item,{onSelect:()=>{t({}),y((0,i.vX)()),e?.close?.()},children:S("关闭")}),(0,w.jsx)(s.zU.Item,{onSelect:z,children:S("保存到服务器")}),(0,w.jsxs)(s.zU.Group,{title:"Excalidraw items",children:[(0,w.jsx)(s.zU.DefaultItems.LoadScene,{}),(0,w.jsx)(s.zU.DefaultItems.Export,{}),(0,w.jsx)(s.zU.DefaultItems.SaveToActiveFile,{}),(0,w.jsx)(s.zU.DefaultItems.SaveAsImage,{}),(0,w.jsx)(s.zU.DefaultItems.ClearCanvas,{}),(0,w.jsx)(s.zU.DefaultItems.ToggleTheme,{}),(0,w.jsx)(s.zU.DefaultItems.ChangeCanvasBackground,{})]})]})},e.url??"excalidraw")]})})}},51953(e){e.exports="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAMUlEQVQ4T2NkYGAQYcAP3uCTZhw1gGGYhAGBZIA/nYDCgBDAm9BGDWAAJyRCgLaBCAAgXwixzAS0pgAAAABJRU5ErkJggg=="},17834(e){e.exports='data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="292.4" height="292.4" viewBox="0 0 292 292"><path d="M287 197L159 69c-4-3-8-5-13-5s-9 2-13 5L5 197c-3 4-5 8-5 13s2 9 5 13c4 4 8 5 13 5h256c5 0 9-1 13-5s5-8 5-13-1-9-5-13z"/></svg>'},56933(e){e.exports='data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="292.4" height="292.4" viewBox="0 0 292 292"><path fill="%23ced4da" d="M287 197L159 69c-4-3-8-5-13-5s-9 2-13 5L5 197c-3 4-5 8-5 13s2 9 5 13c4 4 8 5 13 5h256c5 0 9-1 13-5s5-8 5-13-1-9-5-13z"/></svg>'}}]);
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[5516,5744],{52811(e,t,n){n.r(t),n.d(t,{default:()=>w,parseScene:()=>f});var r=n(96540),a=n(60882),s=n(34843),o=n(82893),l=n(14284),c=n(34289),i=n(62042),d=n(61973),u=n(57889),p=n(22022),m=n(53459),g=(n(3561),n(74848));function f(e){if(!e)return null;const t="string"==typeof e?e:e.context??e.data??e;if(!t)return null;try{return"string"==typeof t?JSON.parse(t):t}catch{return null}}function w(){const[e,t]=(0,s.fp)(o.AG.excalidraw_editor),[n,w]=(0,r.useState)(null),[x,v]=(0,r.useState)(null),[y,h]=(0,r.useState)(!1),S=(0,d.Zp)(),{t:A}=(0,p.Bd)(),k=(0,r.useRef)(()=>{});(0,r.useEffect)(()=>{k.current=z}),(0,r.useEffect)(()=>{let t=!1;return(async()=>{if(e?.url){h(!0);try{const n=await u.l.get(e.url);if(t)return;const r=f(n);if(!r)throw new Error("invalid excalidraw scene");v(r)}catch{t||(v(null),(0,i.zN)("Load Excalidraw file failed"))}finally{t||h(!1)}}else v(null)})(),()=>{t=!0}},[e?.url]);const z=async()=>{if(!n)return void(0,i.zN)("Editor is not ready");const t=n.getSceneElements(),r=n.getAppState(),s=n.getFiles(),o=(0,a.nu)(t,r,s,"local"),d=JSON.parse(o);d.appState={...d.appState??{},zoom:r.zoom,scrollX:r.scrollX,scrollY:r.scrollY,viewBackgroundColor:r.viewBackgroundColor,gridSize:r.gridSize};(await l.$M.post(`save/${encodeURIComponent((0,c.GG)("file",(0,c.vX)()))}${e.name}`,{context:JSON.stringify(d)})).code===m.m.Success&&(0,i.SK)("保存成功")};return(0,r.useEffect)(()=>{const e=e=>{(e.ctrlKey||e.metaKey)&&("s"===e.key||"S"===e.key||83===e.keyCode)&&(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),k.current())};return window.addEventListener("keydown",e,!0),document.addEventListener("keydown",e,!0),()=>{window.removeEventListener("keydown",e,!0),document.removeEventListener("keydown",e,!0)}},[]),(0,g.jsx)("div",{id:"excalidraw-container",children:(0,g.jsxs)("div",{className:"excalidraw-context",children:[y&&(0,g.jsx)("div",{className:"common-box common-box-center",children:"Loading..."}),!y&&x&&(0,g.jsx)(a.Td,{langCode:"zh-CN",initialData:x,excalidrawAPI:e=>w(e),onKeyDown:e=>!(!e.ctrlKey&&!e.metaKey||"s"!==e.key&&"S"!==e.key&&83!==e.keyCode)&&(e.preventDefault(),k.current(),!0),UIOptions:{dockedSidebarBreakpoint:0},children:(0,g.jsxs)(a.zU,{children:[(0,g.jsx)(a.zU.Item,{onSelect:()=>{t({}),S((0,c.vX)()),e?.close?.()},children:A("关闭")}),(0,g.jsx)(a.zU.Item,{onSelect:z,children:A("保存到服务器")}),(0,g.jsxs)(a.zU.Group,{title:"Excalidraw items",children:[(0,g.jsx)(a.zU.DefaultItems.LoadScene,{}),(0,g.jsx)(a.zU.DefaultItems.Export,{}),(0,g.jsx)(a.zU.DefaultItems.SaveToActiveFile,{}),(0,g.jsx)(a.zU.DefaultItems.SaveAsImage,{}),(0,g.jsx)(a.zU.DefaultItems.ClearCanvas,{}),(0,g.jsx)(a.zU.DefaultItems.ToggleTheme,{}),(0,g.jsx)(a.zU.DefaultItems.ChangeCanvasBackground,{})]})]})},e.url??"excalidraw")]})})}},16575(e,t,n){n.r(t),n.d(t,{default:()=>p});var r=n(96540),a=n(60882),s=n(57889),o=n(14284),l=n(62042),c=n(53459),i=n(22022),d=n(52811),u=(n(3561),n(74848));function p(e){const{t}=(0,i.Bd)(),[n,p]=(0,r.useState)(null),[m,g]=(0,r.useState)(null),[f,w]=(0,r.useState)(!1),x=(0,r.useRef)(!1),v=(0,r.useRef)(!1),y=(0,r.useRef)({api:n,props:e});y.current={api:n,props:e};const h=async()=>{const e=(()=>{const e=y.current.api;if(!e)return null;const t=e.getSceneElements(),n=e.getAppState(),r=e.getFiles(),s=(0,a.nu)(t,n,r,"local"),o=JSON.parse(s);return o.appState={...o.appState??{},zoom:n.zoom,scrollX:n.scrollX,scrollY:n.scrollY,viewBackgroundColor:n.viewBackgroundColor,gridSize:n.gridSize},JSON.stringify(o)})();if(null===e)return(0,l.zN)(t("编辑器尚未就绪")),!1;return(await o.$M.post(`save/${encodeURIComponent(y.current.props.save_path)}`,{context:e})).code===c.m.Success&&(x.current=!1,y.current.props.on_dirty?.(!1),y.current.props.on_saved?.(),(0,l.SK)(t("保存成功")),!0)};return(0,r.useEffect)(()=>{e.register?.({save:h,is_dirty:()=>x.current})},[e.register]),(0,r.useEffect)(()=>{let n=!1;return(async()=>{if(e.url){w(!0);try{const t=await s.l.get(e.url);if(n)return;const r=(0,d.parseScene)(t);if(!r)throw new Error("invalid excalidraw scene");g(r)}catch{n||(g(null),(0,l.zN)(t("加载画板失败")))}finally{n||w(!1)}}else g(null)})(),()=>{n=!0}},[e.url]),(0,r.useEffect)(()=>{const e=e=>{(e.ctrlKey||e.metaKey)&&("s"===e.key||"S"===e.key||83===e.keyCode)&&(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),h())};return window.addEventListener("keydown",e,!0),document.addEventListener("keydown",e,!0),()=>{window.removeEventListener("keydown",e,!0),document.removeEventListener("keydown",e,!0)}},[]),(0,u.jsxs)("div",{className:"excalidraw-inline",children:[f&&(0,u.jsx)("div",{className:"common-box common-box-center",children:"Loading..."}),!f&&m&&(0,u.jsx)(a.Td,{langCode:"zh-CN",initialData:m,excalidrawAPI:e=>p(e),onChange:()=>{v.current?x.current||(x.current=!0,y.current.props.on_dirty?.(!0)):v.current=!0},onKeyDown:e=>!(!e.ctrlKey&&!e.metaKey||"s"!==e.key&&"S"!==e.key&&83!==e.keyCode)&&(e.preventDefault(),h(),!0),UIOptions:{dockedSidebarBreakpoint:0},children:(0,u.jsxs)(a.zU,{children:[(0,u.jsx)(a.zU.Item,{onSelect:()=>h(),children:t("保存到服务器")}),(0,u.jsxs)(a.zU.Group,{title:"Excalidraw items",children:[(0,u.jsx)(a.zU.DefaultItems.Export,{}),(0,u.jsx)(a.zU.DefaultItems.SaveAsImage,{}),(0,u.jsx)(a.zU.DefaultItems.ClearCanvas,{}),(0,u.jsx)(a.zU.DefaultItems.ToggleTheme,{}),(0,u.jsx)(a.zU.DefaultItems.ChangeCanvasBackground,{})]})]})},e.reset_key??e.url??"excalidraw")]})}},51953(e){e.exports="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAMUlEQVQ4T2NkYGAQYcAP3uCTZhw1gGGYhAGBZIA/nYDCgBDAm9BGDWAAJyRCgLaBCAAgXwixzAS0pgAAAABJRU5ErkJggg=="},17834(e){e.exports='data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="292.4" height="292.4" viewBox="0 0 292 292"><path d="M287 197L159 69c-4-3-8-5-13-5s-9 2-13 5L5 197c-3 4-5 8-5 13s2 9 5 13c4 4 8 5 13 5h256c5 0 9-1 13-5s5-8 5-13-1-9-5-13z"/></svg>'},56933(e){e.exports='data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="292.4" height="292.4" viewBox="0 0 292 292"><path fill="%23ced4da" d="M287 197L159 69c-4-3-8-5-13-5s-9 2-13 5L5 197c-3 4-5 8-5 13s2 9 5 13c4 4 8 5 13 5h256c5 0 9-1 13-5s5-8 5-13-1-9-5-13z"/></svg>'}}]);
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[621,4935],{53002(e,t,n){n.r(t),n.d(t,{default:()=>d});var r=n(96540),s=n(34843),o=n(82893),c=n(85997),l=n(45907),a=n(74848);function i(e){const{name:t,dirty:n,loading:s,error:o,saving:i,on_save:u,on_close:f,children:d,extra:h}=e,m=(0,l.y)(),g=(0,r.useRef)(f),x=(0,r.useRef)(u),y=(0,r.useRef)(n);g.current=f,x.current=u,y.current=n;const p=()=>{y.current?m({title:"关闭",sub_title:"有未保存的修改,确定关闭吗?",confirm_fun:()=>g.current?.()}):g.current?.()};return(0,r.useEffect)(()=>{const e=e=>{(e.ctrlKey||e.metaKey)&&"s"===e.key.toLowerCase()?(e.preventDefault(),e.stopPropagation(),x.current?.()):"Escape"===e.key&&p()};return document.addEventListener("keydown",e,!0),()=>document.removeEventListener("keydown",e,!0)},[]),(0,a.jsxs)("div",{className:"office-editor",children:[(0,a.jsxs)("div",{className:"office-editor__topbar",children:[(0,a.jsxs)("div",{className:"office-editor__name",children:[t,n&&(0,a.jsx)("span",{className:"office-editor__dirty",title:"有未保存的修改"})]}),(0,a.jsxs)("div",{className:"office-editor__ops",children:[h,i&&(0,a.jsx)("span",{className:"office-editor__saving",children:"保存中…"}),u&&(0,a.jsx)(c.rA,{icon:"save",title:"保存 (Ctrl+S)",onClick:()=>u()}),(0,a.jsx)(c.rA,{icon:"close",title:"关闭 (Esc)",onClick:p})]})]}),(0,a.jsxs)("div",{className:"office-editor__body",children:[s&&(0,a.jsx)("div",{className:"office-editor__tip",children:"加载中…"}),!s&&o&&(0,a.jsx)("div",{className:"office-editor__tip office-editor__tip--error",children:o}),!s&&!o&&d]})]})}var u=n(24935),f=n(99018);function d(){const[e,t]=(0,s.fp)(o.AG.excel_editor),[n,c]=(0,r.useState)(!1),[l,d]=(0,r.useState)(!1),h=(0,r.useRef)();return(0,a.jsx)(i,{name:e.name,dirty:n,loading:!1,error:"",saving:l,on_save:async()=>{if(!h.current)return!1;d(!0);try{return await h.current()}finally{d(!1)}},on_close:()=>{const n=e.close;t({}),n?.()},children:e.url&&(0,a.jsx)(u.default,{url:e.url,save_path:(0,f.Vi)(e.name??""),on_dirty:c,bind_save:e=>h.current=e})})}},24935(e,t,n){n.r(t),n.d(t,{default:()=>S});var r=n(96540),s=n(47049),o=n(8890);const c=e=>Math.round(7*e+5),l=e=>Math.round(4*e/3);function a(e){return{toBytes:async()=>e}}function i(e,t){if(e){if(e.rgb){const t=String(e.rgb);return"#"+(8===t.length?t.slice(2):t)}return void 0!==e.theme&&t[e.theme]?"#"+function(e,t){if(!t)return e;const n=parseInt(e,16);return[n>>16&255,n>>8&255,255&n].map(e=>{const n=t<0?e*(1+t):e*(1-t)+255*t;return Math.round(n).toString(16).padStart(2,"0")}).join("").toUpperCase()}(t[e.theme],e.tint??0):void 0}}function u(e){const t=Math.round(864e5*(e-25569));return new Date(t)}function f(e,t){const n=e=>String(e).padStart(2,"0"),r=e.getUTCFullYear(),s=r%100,o=e.getUTCMonth()+1,c=e.getUTCDate(),l="日一二三四五六"[e.getUTCDay()];return t.replace(/;.*$/,"").replace(/\[[^\]]*\]/g,"").replace(/"[^"]*"/g,e=>e.slice(1,-1)).replace(/\\/g,"").replace(/yyyy/g,String(r)).replace(/yy/g,n(s)).replace(/(?<!m)m(?!m)/g,String(o)).replace(/mm/g,n(o)).replace(/d(?!d)/g,String(c)).replace(/dd/g,n(c)).replace(/aaaa/g,`星期${l}`)}const d=e=>!!e&&/[ymd]/i.test(e.replace(/"[^"]*"/g,""))&&!/[#0]/.test(e.replace(/"[^"]*"/g,""));function h(e,t,n){const r=e?.value;if(null==r)return{text:null};if("object"==typeof r){if(Array.isArray(r.runs)){const e=r.runs.map(e=>({text:e.text??"",color:i(e.font?.color,t)}));return{text:e.map(e=>e.text).join("")||null,runs:e.some(e=>e.color)?e:void 0}}if("string"==typeof r.text)return{text:r.text};const e=r.cachedValue??r.result;return void 0!==e?"number"==typeof e&&d(n)?{text:f(u(e),n)}:{text:String(e)}:{text:null}}return"number"==typeof r&&d(n)?{text:f(u(r),n)}:{text:String(r)}}function m(e,t,n){const r=e?.styleId;if(void 0===r)return;const s=t.cellXfs?.[r];if(!s)return;const o=t.fills?.[s.fillId],c=t.fonts?.[s.fontId],l={};"solid"===o?.patternType&&(l.bg=i(o.fgColor,n)),l.color=i(c?.color,n),c?.bold&&(l.bold=!0),c?.italic&&(l.italic=!0),c?.size&&(l.fontSize=c.size),c?.name&&(l.fontFamily=c.name),c?.underline&&(l.underline=!0),c?.strike&&(l.strike=!0);const a=s.alignment;return a?.horizontal&&["left","center","right"].includes(a.horizontal)&&(l.align=a.horizontal),a?.vertical&&(l.valign="center"===a.vertical?"middle":a.vertical),a?.wrapText&&(l.wrap=!0),a?.indent&&(l.indent=a.indent),Object.keys(l).length?l:void 0}function g(e,t){const n=e?.styleId;if(void 0===n)return;const r=t.cellXfs?.[n];if(!r)return;const s=r.numFmtId;if(void 0===s||0===s)return;const o={14:"m/d/yy",15:"d-mmm-yy",16:"d-mmm",17:"mmm-yy",18:"h:mm AM/PM",19:"h:mm:ss AM/PM",20:"h:mm",21:"h:mm:ss",22:"m/d/yy h:mm",27:'yyyy"年"m"月"',28:'m"月"d"日"',29:'m"月"d"日"',30:"m-d-yy",31:'yyyy"年"m"月"d"日"',32:'h"时"mm"分"',33:'h"时"mm"分"ss"秒"',34:'上午/下午h"时"mm"分"',35:'上午/下午h"时"mm"分"ss"秒"',36:'yyyy"年"m"月"'};if(o[s])return o[s];const c=t.numFmts;return c instanceof Map?c.get(s):void 0}async function x(e){const t=await(0,s.a)(a(e)),n=function(e){const t=["FFFFFF","000000","EEECE1","1F497D","4F81BD","C0504D","9BBB59","8064A2","4BACC6","F79646"];if(!e)return t;const n="string"==typeof e?e:(new TextDecoder).decode(e),r=/<a:clrScheme[\s\S]*?<\/a:clrScheme>/.exec(n)?.[0];if(!r)return t;const s=[],o=/<a:(dk1|lt1|dk2|lt2|accent[1-6]|hlink|folHlink)>([\s\S]*?)<\/a:\1>/g,c=new Map;let l;for(;l=o.exec(r);){const e=/(?:lastClr|val)="([0-9A-Fa-f]{6})"/.exec(l[2])?.[1];e&&c.set(l[1],e.toUpperCase())}return["lt1","dk1","lt2","dk2","accent1","accent2","accent3","accent4","accent5","accent6"].forEach((e,n)=>s[n]=c.get(e)??t[n]),s}(t.themeXml);return t.sheets.map(e=>{const r=e.sheet,s=t.styles;let o=0,a=0;r.rows.forEach((e,t)=>{e.size&&(o=Math.max(o,t),e.forEach((e,t)=>{a=Math.max(a,t)}))});const i=[],u=new Map;for(let e=1;e<=o;e++){const t=[],o=r.rows.get(e);for(let r=1;r<=a;r++){const c=o?.get(r),l=h(c,n,g(c,s));t.push(l.text);const a=m(c,s,n);l.runs&&(a?a.runs=l.runs:u.set(`${e-1}_${r-1}`,{runs:l.runs})),a&&u.set(`${e-1}_${r-1}`,a)}i.push(t)}const f=c(r.defaultColumnWidth??8.43),d=new Array(a).fill(f);r.columnDimensions?.forEach(e=>{const t=c(e.width??8.43);for(let n=e.min;n<=e.max;n++)n-1<d.length&&(d[n-1]=t)});const x=l(r.defaultRowHeight??15),y=new Array(o).fill(x),p=new Set;r.rowDimensions?.forEach((e,t)=>{t-1<y.length&&e.height&&(y[t-1]=l(e.height)),e.hidden&&t-1<o&&p.add(t-1)});const v=(r.mergedCells??[]).map(e=>[(e.minRow??e.start?.row??1)-1,(e.minCol??e.start?.col??1)-1,(e.maxRow??e.end?.row??1)-1,(e.maxCol??e.end?.col??1)-1]);return{title:r.title,values:i,styles:u,col_widths:d,row_heights:y,hidden_rows:p,merges:v}})}var y=n(74848);function p(e){const{bytes:t,on_change:n,bind_save:c}=e,[l,i]=(0,r.useState)([]),[u,f]=(0,r.useState)(0),[,d]=(0,r.useState)(0),[h,m]=(0,r.useState)(""),g=(0,r.useRef)(!1),p=(0,r.useRef)(null),[w,S]=(0,r.useState)({r0:0,r1:40,c0:0,c1:20});(0,r.useEffect)(()=>{let e=!0;return m(""),x(t).then(t=>e&&i(t)).catch(t=>e&&m(String(t?.message??t))),()=>{e=!1}},[t]);const b=(0,r.useCallback)(()=>{g.current||(g.current=!0,n(!0))},[n]);(0,r.useEffect)(()=>{c(async()=>{const e=await async function(e,t){const n=await(0,s.a)(a(e));return t.forEach((e,t)=>{const r=n.sheets[t];if(!r)return;const s=r.sheet;e.values.forEach((e,t)=>{e.forEach((e,n)=>{const r=t+1,o=n+1;let c=s.rows.get(r);c||(c=new Map,s.rows.set(r,c));const l=c.get(o);null!==e&&""!==e?l?l.value=e:c.set(o,{row:r,col:o,value:e}):l&&(l.value=null)})})}),await(0,o.n)(n)}(t,l);return g.current=!1,n(!1),e})},[l,t,c,n]);const C=l[u],{col_x:j,row_y:E,total_w:k,total_h:M}=r.useMemo(()=>{const e=C?.col_widths??[],t=C?.row_heights??[],n=[0];e.forEach((e,t)=>n.push(n[t]+(C?.hidden_rows.has(t)?0:e)));const r=[0];return t.forEach((e,t)=>r.push(r[t]+e)),{col_x:n,row_y:r,total_w:n[n.length-1]??0,total_h:r[r.length-1]??0}},[C]),N=(e,t)=>{let n=0,r=e.length-1;for(;n<r;){const s=n+r>>1;e[s]<t?n=s+1:r=s}return n},$=(0,r.useCallback)(()=>{const e=p.current;if(!e||!j.length)return;const t=Math.max(0,N(j,e.scrollLeft)-1),n=Math.max(0,N(E,e.scrollTop)-1);S({c0:t,c1:Math.min(j.length-1,N(j,e.scrollLeft+e.clientWidth)+2),r0:n,r1:Math.min(E.length-1,N(E,e.scrollTop+e.clientHeight)+2)})},[j,E]);(0,r.useEffect)(()=>{$()},[C,$]);if(h)return(0,y.jsx)("div",{className:"office-editor__tip office-editor__tip--error",children:h});if(!l.length)return(0,y.jsx)("div",{className:"office-editor__tip",children:"解析中…"});const F=C?.values??[],A=(E.length,j.length,new Set);C.merges.forEach(([e,t,n,r])=>{for(let s=e;s<=n;s++)for(let n=t;n<=r;n++)s===e&&n===t||A.add(`${s}_${n}`)});const D=(e,t)=>{const n=F[e]?.[t];return(null==n||""===n)&&!C.styles.get(`${e}_${t}`)?.bg};return(0,y.jsxs)("div",{className:"xlsx-body",children:[(0,y.jsx)("div",{className:"xlsx-tabs",children:l.map((e,t)=>(0,y.jsx)("div",{className:"xlsx-tab "+(t===u?"xlsx-tab--active":""),onClick:()=>{f(t),p.current&&(p.current.scrollTop=0,p.current.scrollLeft=0)},children:e.title},e.title+t))}),(0,y.jsx)("div",{className:"xlsx-scroll",ref:p,onScroll:$,children:(0,y.jsxs)("div",{className:"xlsx-grid",style:{width:46+k,height:24+M},children:[Array.from({length:Math.max(0,w.c1-w.c0)}).map((e,t)=>{const n=w.c0+t;return(0,y.jsx)("div",{className:"xlsx-head",style:{left:46+j[n],top:0,width:j[n+1]-j[n],height:24},children:_(n)},"ch"+n)}),Array.from({length:Math.max(0,w.r1-w.r0)}).map((e,t)=>{const n=w.r0+t;return(0,y.jsxs)(r.Fragment,{children:[(0,y.jsx)("div",{className:"xlsx-head xlsx-head--row",style:{left:0,top:24+E[n],width:46,height:E[n+1]-E[n]},children:n+1}),Array.from({length:Math.max(0,w.c1-w.c0)}).map((e,t)=>{const r=w.c0+t;if(A.has(`${n}_${r}`))return null;const s=C.merges.find(e=>e[0]===n&&e[1]===r),o=s?j[s[3]+1]-j[s[1]]:j[r+1]-j[r],c=s?E[s[2]+1]-E[s[0]]:E[n+1]-E[n];return(0,y.jsx)(v,{value:F[n]?.[r]??"",cell_style:C.styles.get(`${n}_${r}`),spillable:D(n,r+1),style:{left:46+j[r],top:24+E[n],width:o,height:c,zIndex:s?2:1},on_change:e=>((e,t,n)=>{const r=l[u];r&&(r.values[e][t]=""===n?null:n,b(),d(e=>e+1))})(n,r,e)},r)})]},n)})]})})]})}function v(e){const{value:t,cell_style:n,style:s,spillable:o,on_change:c}=e,[l,a]=(0,r.useState)(!1),[i,u]=(0,r.useState)(""),f=(0,r.useRef)(null);(0,r.useEffect)(()=>{l&&f.current&&(f.current.focus(),f.current.select())},[l]);const d=()=>{a(!1),i!==(t??"")&&c(i)},h={};return n?.bg&&(h.backgroundColor=n.bg),n?.color&&(h.color=n.color),n?.bold&&(h.fontWeight=600),n?.italic&&(h.fontStyle="italic"),n?.fontSize&&(h.fontSize=Math.round(4*n.fontSize/3*10)/10+"px"),n?.fontFamily&&(h.fontFamily=`"${n.fontFamily}", "PingFang SC", sans-serif`),n?.underline&&(h.textDecoration="underline"),n?.strike&&(h.textDecoration=h.textDecoration?`${h.textDecoration} line-through`:"line-through"),n?.align&&(h.textAlign=n.align,h.justifyContent="center"===n.align?"center":"right"===n.align?"flex-end":"flex-start"),n?.valign&&(h.alignItems="middle"===n.valign?"center":"bottom"===n.valign?"flex-end":"flex-start"),n?.wrap&&(h.whiteSpace="pre-wrap"),n?.indent&&(h.paddingLeft=.35+1.4*n.indent+"em"),(0,y.jsx)("div",{className:`xlsx-cell ${n?.wrap?"xlsx-cell--wrap":""} ${o?"xlsx-cell--spill":""}`,style:{...s,...h,"--cell-h":n?.wrap?"1.4":s.height-1+"px"},onDoubleClick:()=>{u(t??""),a(!0)},children:l?(0,y.jsx)("textarea",{ref:f,className:"xlsx-cell__input",value:i,onChange:e=>u(e.target.value),onBlur:d,onKeyDown:e=>{"Enter"!==e.key||e.shiftKey?"Escape"===e.key&&a(!1):(e.preventDefault(),d())}}):n?.runs?(0,y.jsx)("span",{children:n.runs.map((e,t)=>(0,y.jsx)("span",{style:e.color?{color:e.color}:void 0,children:e.text},t))}):t})}function _(e){let t="",n=e+1;for(;n>0;){const e=(n-1)%26;t=String.fromCharCode(65+e)+t,n=Math.floor((n-1)/26)}return t}var w=n(99018);function S(e){const{url:t,save_path:n,on_dirty:s,bind_save:o}=e,[c,l]=(0,r.useState)(),[a,i]=(0,r.useState)(""),[u,f]=(0,r.useState)(!0),[d,h]=(0,r.useState)(!1),m=(0,r.useRef)();return(0,r.useEffect)(()=>{if(!t)return;let e=!0;return f(!0),i(""),h(!1),l(void 0),(0,w.PQ)(t).then(t=>e&&l(t)).catch(t=>e&&i(String(t?.message??t))).finally(()=>e&&f(!1)),()=>{e=!1}},[t]),(0,r.useEffect)(()=>{s?.(d)},[d,s]),(0,r.useEffect)(()=>{o?.(async()=>{if(!m.current)return!1;const e=await m.current(),t=await(0,w.GB)(n,e);return t&&(l(e),h(!1)),t})},[n,o]),a?(0,y.jsx)("div",{className:"office-editor__tip office-editor__tip--error",children:a}):u||!c?(0,y.jsx)("div",{className:"office-editor__tip",children:"读取中…"}):(0,y.jsx)(p,{bytes:c,on_change:h,bind_save:e=>m.current=e})}},99018(e,t,n){n.d(t,{GB:()=>a,PQ:()=>l,Vi:()=>c});var r=n(14284),s=n(34289),o=n(62042);function c(e){return`${encodeURIComponent((0,s.GG)("file",(0,s.vX)()))}${e}`}async function l(e){const t=await fetch(e,{headers:{Authorization:localStorage.getItem("token")}});if(!t.ok)throw new Error(`读取文件失败: ${t.status}`);return new Uint8Array(await t.arrayBuffer())}function a(e,t){return async function(e,t){const n=await r.$M.post(`save_bin/${e}`,{base64:i(t)});return 0===n.code||((0,o.zN)(n.message??"保存失败"),!1)}(function(e){const t=e.lastIndexOf("/");return t<0?encodeURIComponent(e):encodeURIComponent(e.slice(0,t))+e.slice(t)}(e),t)}function i(e){let t="";for(let n=0;n<e.length;n+=32768)t+=String.fromCharCode(...e.subarray(n,n+32768));return btoa(t)}}}]);
@@ -1 +0,0 @@
1
- (self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[6404,8277],{35304(e,t,n){"use strict";n.r(t),n.d(t,{default:()=>C});var a=n(96540),r=n(57889),l=(n(14284),n(62042)),o=n(22022),i=n(45602),c=(n(88781),n(86063));const d={classic:{backgroundColor:"#fafafa",lineColor:"#4d8f7f",lineWidth:2,root:{fillColor:"#4d8f7f",color:"#fff",borderRadius:6,paddingX:18,paddingY:8},second:{fillColor:"#fff",color:"#2f4f47",borderRadius:5,borderColor:"#4d8f7f",borderWidth:1,paddingX:14,paddingY:6},node:{fillColor:"#fff",color:"#3c3c3c",borderRadius:5,borderColor:"#a8d5c8",borderWidth:1,paddingX:12,paddingY:5}},dark:{backgroundColor:"#1f2226",lineColor:"#6b7c8c",lineWidth:1,root:{fillColor:"#3a4654",color:"#f2f4f6",borderRadius:6,paddingX:18,paddingY:8},second:{fillColor:"#2b323a",color:"#e6eaef",borderRadius:5,borderColor:"#4c5866",borderWidth:1,paddingX:14,paddingY:6},node:{fillColor:"#242a31",color:"#ccd3da",borderRadius:5,borderColor:"#3c454f",borderWidth:1,paddingX:12,paddingY:5}},simple:{backgroundColor:"#fff",lineColor:"#c8ccd0",lineWidth:1,root:{fillColor:"transparent",color:"#202124",borderRadius:0,borderWidth:0,paddingX:10,paddingY:4},second:{fillColor:"transparent",color:"#202124",borderRadius:0,borderWidth:0,paddingX:8,paddingY:3},node:{fillColor:"transparent",color:"#5f6368",borderRadius:0,borderWidth:0,paddingX:8,paddingY:3}},colorful:{backgroundColor:"#fffdf6",lineColor:"#f2a65a",lineWidth:2,root:{fillColor:"#f2854a",color:"#fff",borderRadius:24,paddingX:20,paddingY:9},second:{fillColor:"#ffd66b",color:"#6b4a12",borderRadius:16,borderWidth:0,paddingX:14,paddingY:6},node:{fillColor:"#a8d8ea",color:"#1e3f4d",borderRadius:12,borderWidth:0,paddingX:12,paddingY:5}}};var s=n(34843),u=n(82893),m=n(61443),p=n(74848);function f(e){const[t,n]=(0,a.useState)(e.initValue||""),r=t=>{n(t),e.onChange(t)};return e.multiline?(0,p.jsx)("div",{className:"prompt-input",children:(0,p.jsx)(m.Z2,{placeholder:e.placeholder||"",rows:e.rows??5,value:t,handleInputChange:r})}):(0,p.jsx)("div",{className:"prompt-input",children:(0,p.jsx)(m.Sm,{placeholder:e.placeholder||"",value:t,handleInputChange:r})})}var E,b=n(75725),_=n(85997);n(30576);E=i.default,Object.entries(d).forEach(([e,t])=>{E.defineTheme?.(e,t)});const h=[{cmd:"INSERT_CHILD_NODE",icon:"account_tree",label:"添加子节点"},{cmd:"INSERT_NODE",icon:"subdirectory_arrow_right",label:"添加同级节点"},{cmd:"INSERT_PARENT_NODE",icon:"arrow_upward",label:"插入父节点"},{cmd:"CUT_NODE",icon:"content_cut",label:"剪切"},{cmd:"PASTE_NODE",icon:"content_paste",label:"粘贴"},{cmd:"REMOVE_NODE",icon:"delete",label:"删除节点"},{cmd:"INSERT_GROUP",icon:"add_circle_outline",label:"插入",children:[{cmd:"SET_NODE_ICON",icon:"emoji_emotions",label:"插入图标"},{cmd:"REMOVE_NODE_ICON",icon:"format_clear",label:"删除图标"},{cmd:"SET_NODE_NOTE",icon:"sticky_note_2",label:"节点备注"},{cmd:"REMOVE_NODE_NOTE",icon:"speaker_notes_off",label:"删除备注"},{cmd:"SET_NODE_TAG",icon:"sell",label:"节点标签"},{cmd:"REMOVE_NODE_TAG",icon:"label_off",label:"删除标签"},{cmd:"SET_NODE_HYPERLINK",icon:"link",label:"插入超链接"},{cmd:"REMOVE_NODE_HYPERLINK",icon:"link_off",label:"删除超链接"}]},{cmd:"ADD_GENERALIZATION",icon:"call_merge",label:"添加概要"},{cmd:"REMOVE_GENERALIZATION",icon:"call_split",label:"删除概要"}],N=[{value:"logicalStructure",label:"逻辑结构图"},{value:"mindMap",label:"思维导图"},{value:"organizationStructure",label:"组织结构图"},{value:"catalogOrganization",label:"目录组织图"},{value:"timeline",label:"时间轴(左)"},{value:"timeline2",label:"时间轴(下)"},{value:"timeline3",label:"时间轴(上)"},{value:"verticalTimeline",label:"时间轴(竖)"},{value:"fishbone",label:"鱼骨图"},{value:"rightFishbone",label:"鱼骨图(右)"}],v=[{value:"curve",label:"曲线"},{value:"straight",label:"直线"},{value:"direct",label:"直连"}],g=[{value:"default",label:"默认主题"},{value:"classic",label:"经典"},{value:"dark",label:"暗色"},{value:"simple",label:"极简"},{value:"colorful",label:"缤纷"}],x=i.default.iconList||[];function C(e){const{t}=(0,o.Bd)(),[n,d]=(0,a.useState)(!0),[m,E]=(0,a.useState)(""),[C,y]=(0,a.useState)(100),[D,T]=(0,a.useState)("default"),[,w]=(0,s.fp)(u.AG.prompt_card),[j,R]=(0,a.useState)("mindMap"),[S,k]=(0,a.useState)(null),I=(0,a.useRef)(null),L=(0,a.useRef)(null),A=(0,a.useRef)(null),M=(0,a.useRef)(!1),Y=(0,a.useRef)({props:e});Y.current={props:e};const W=()=>{M.current||(M.current=!0,Y.current.props.on_dirty?.(!0))},P=async()=>{if(!A.current)return(0,l.zN)(t("编辑器尚未就绪")),!1;const e=await Y.current.props.on_save((()=>{const e=A.current;return e?JSON.stringify(e.getData(!0)):""})());return e&&(M.current=!1,Y.current.props.on_dirty?.(!1),Y.current.props.on_saved?.()),e};(0,a.useEffect)(()=>{e.register?.({save:P,is_dirty:()=>M.current})},[e.register]),(0,a.useEffect)(()=>{if(!I.current)return;if(!e.url&&void 0===e.data)return;let n=!1;const a=[];A.current?.destroy?.(),A.current=null,M.current=!1,d(!0),E("");const o=async e=>{if(n||!I.current)return;const r=e&&e.root?e:null,l=r?r.root:e??{data:{text:t("中心主题")}},o=new i.default({el:I.current,data:l,fit:!0,enableDblclickBackToRootNode:!0,enableShortcutOnlyWhenMouseInSvg:!0,autoMoveWhenMouseInEdgeOnDrag:!0,...c.k$});A.current=o,r&&o.setFullData(r),d(!1),T(o.getTheme?.()||"default"),R(o.getLayout?.()||"mindMap");window.requestAnimationFrame(()=>{n||(()=>{let e=!1;const t=window.setTimeout(()=>{n||(e=!0)},400);a.push(t),o.on("data_change",()=>{e&&(W(),y(O(o)))}),o.on("view_data_change",()=>{y(O(o))}),o.on("error",(e,t)=>{console.error("[mind]",e,t)}),y(O(o))})()})};return(async()=>{try{let t=null;if(void 0!==e.data)t=e.data;else{const a=await r.l.get(e.url);if(n)return;t=a}let a=null;if("string"==typeof t&&t.trim())try{a=JSON.parse(t)}catch{a=null}else t&&"object"==typeof t&&(a=t);a=(0,c.tW)(a),await o(a)}catch(e){n||(d(!1),E(t("加载思维导图失败")),(0,l.zN)(t("加载思维导图失败")))}})(),()=>{n=!0,a.forEach(e=>window.clearTimeout(e)),A.current?.destroy?.(),A.current=null}},[e.url,e.data]),(0,a.useEffect)(()=>{const e=e=>{(e.ctrlKey||e.metaKey)&&("s"===e.key||"S"===e.key||83===e.keyCode)&&(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),P())};return window.addEventListener("keydown",e,!0),document.addEventListener("keydown",e,!0),()=>{window.removeEventListener("keydown",e,!0),document.removeEventListener("keydown",e,!0)}},[]);const V=e=>{const t=A.current;if(!t)return;const n=Math.min(4,Math.max(.25,e));t.view.setScale(n),y(Math.round(100*n))},G={SET_NODE_NOTE:{title:"节点备注",placeholder:"请输入节点备注",get:e=>e.getData("note")||""},SET_NODE_TAG:{title:"节点标签",placeholder:"请输入节点标签,多个用逗号分隔",get:e=>(e.getData("tag")||[]).join(",")},SET_NODE_HYPERLINK:{title:"插入超链接",placeholder:"请输入链接地址",get:e=>e.getData("hyperlink")||""}};(0,a.useEffect)(()=>{if(!S)return;const e=()=>k(null),t=window.setTimeout(()=>{window.addEventListener("click",e),window.addEventListener("blur",e)},0);return()=>{window.clearTimeout(t),window.removeEventListener("click",e),window.removeEventListener("blur",e)}},[S]),(0,a.useEffect)(()=>{const e=L.current;if(!e)return;const t=e=>{const t=A.current?.renderer?.activeNodeList?.[0];t&&(e.preventDefault(),e.stopPropagation(),k({x:e.clientX,y:e.clientY,node:t}))};return e.addEventListener("contextmenu",t,!0),()=>e.removeEventListener("contextmenu",t,!0)},[]);const X=e=>e.map(e=>({v:e.cmd,r:(0,p.jsxs)("div",{className:"common-tag-center mind-menu-row",children:[(0,p.jsx)(_.In,{icon:e.icon,not_use_icon_style:!0}),(0,p.jsx)("span",{children:t(e.label)})]}),items:e.children?X(e.children):void 0})),H=e=>{const n=A.current,a=S;if(n&&a){if(k(null),"ADD_GENERALIZATION"===e||"REMOVE_GENERALIZATION"===e)return n.execCommand(e),void W();"SET_NODE_NOTE"!==e&&"SET_NODE_TAG"!==e&&"SET_NODE_HYPERLINK"!==e?"SET_NODE_ICON"!==e?e.startsWith("REMOVE_NODE_")?((e,t)=>{e&&("REMOVE_NODE_ICON"===t?A.current.execCommand("SET_NODE_ICON",e,[]):"REMOVE_NODE_NOTE"===t?A.current.execCommand("SET_NODE_NOTE",e,""):"REMOVE_NODE_TAG"===t?A.current.execCommand("SET_NODE_TAG",e,[]):"REMOVE_NODE_HYPERLINK"===t&&A.current.execCommand("SET_NODE_HYPERLINK",e,"",""),W())})(a.node,e):(n.execCommand(e,a.node),W()):(e=>{if(!e)return;const n=Array.isArray(e.getData("icon"))?e.getData("icon"):[];w({open:!0,title:t("插入图标"),context_div:(0,p.jsx)("div",{className:"prompt-icon-list",children:x.flatMap(t=>(t.list||[]).map((a,r)=>(0,p.jsx)("button",{type:"button",className:"prompt-icon-list__item",title:a.name,dangerouslySetInnerHTML:{__html:a.icon},onClick:()=>{A.current.execCommand("SET_NODE_ICON",e,[...n,`${t.type}_${a.name}`]),w({open:!1}),W()}},t.type+r)))}),cancel:()=>w({open:!1})})})(a.node):((e,n)=>{if(!e)return;const a=G[n],r=a.get(e);let l=r;w({open:!0,title:t(a.title),context_div:(0,p.jsx)(f,{initValue:r,placeholder:t(a.placeholder),multiline:!0,onChange:e=>l=e}),confirm:()=>{const t=l.trim();"SET_NODE_TAG"===n?A.current.execCommand(n,e,t.split(/[,,]/).map(e=>e.trim()).filter(Boolean)):"SET_NODE_HYPERLINK"===n?A.current.execCommand(n,e,t,t):A.current.execCommand(n,e,t),w({open:!1}),W()},cancel:()=>w({open:!1})})})(a.node,e)}};return(0,p.jsxs)("div",{className:"mind-wrap"+(e.fullscreen?" mind-wrap--full":""),children:[e.header,(0,p.jsxs)("div",{className:"mind-toolbar",children:[(0,p.jsx)("button",{type:"button",className:"mind-btn",title:t("添加子节点")+" (Tab)",onClick:()=>A.current?.execCommand?.("INSERT_CHILD_NODE"),children:(0,p.jsx)("span",{className:"material-icons",children:"account_tree"})}),(0,p.jsx)("button",{type:"button",className:"mind-btn",title:t("添加同级节点")+" (Enter)",onClick:()=>A.current?.execCommand?.("INSERT_NODE"),children:(0,p.jsx)("span",{className:"material-icons",children:"subdirectory_arrow_right"})}),(0,p.jsx)("button",{type:"button",className:"mind-btn",title:t("删除节点")+" (Delete)",onClick:()=>A.current?.execCommand?.("REMOVE_NODE"),children:(0,p.jsx)("span",{className:"material-icons",children:"delete"})}),(0,p.jsx)("span",{className:"mind-toolbar__sep"}),(0,p.jsx)("button",{type:"button",className:"mind-btn",title:t("撤销")+" (Ctrl+Z)",onClick:()=>A.current?.execCommand?.("BACK"),children:(0,p.jsx)("span",{className:"material-icons",children:"undo"})}),(0,p.jsx)("button",{type:"button",className:"mind-btn",title:t("重做")+" (Ctrl+Y)",onClick:()=>A.current?.execCommand?.("FORWARD"),children:(0,p.jsx)("span",{className:"material-icons",children:"redo"})}),(0,p.jsx)("span",{className:"mind-toolbar__sep"}),(0,p.jsxs)("span",{className:"mind-toolbar__zoom",children:[C,"%"]}),(0,p.jsx)("button",{type:"button",className:"mind-btn",title:t("缩小"),onClick:()=>V(O(A.current)/100-.2),children:(0,p.jsx)("span",{className:"material-icons",children:"remove"})}),(0,p.jsx)("button",{type:"button",className:"mind-btn",title:t("放大"),onClick:()=>V(O(A.current)/100+.2),children:(0,p.jsx)("span",{className:"material-icons",children:"add"})}),(0,p.jsx)("button",{type:"button",className:"mind-btn",title:t("适应窗口"),onClick:()=>{A.current?.view?.fit?.(),y(O(A.current))},children:(0,p.jsx)("span",{className:"material-icons",children:"fit_screen"})})]}),(0,p.jsxs)("div",{className:"mind-toolbar mind-toolbar--sub",children:[(0,p.jsx)("select",{className:"mind-select",title:t("结构"),value:j,onChange:e=>{const t=e.target.value;A.current?.setLayout?.(t),R(t),W()},children:N.map(e=>(0,p.jsx)("option",{value:e.value,children:t(e.label)},e.value))}),(0,p.jsxs)("select",{className:"mind-select",title:t("连线风格"),defaultValue:"",onChange:e=>{const t=e.target.value;if(t){const e=A.current?.getCustomThemeConfig?.()||{};A.current?.setThemeConfig?.({...e,lineStyle:t}),W()}e.target.value=""},children:[(0,p.jsx)("option",{value:"",children:t("连线风格")}),v.map(e=>(0,p.jsx)("option",{value:e.value,children:t(e.label)},e.value))]}),(0,p.jsx)("select",{className:"mind-select",title:t("主题"),value:D,onChange:e=>{const t=e.target.value;T(t),A.current?.setTheme?.(t),W()},children:g.map(e=>(0,p.jsx)("option",{value:e.value,children:t(e.label)},e.value))}),(0,p.jsx)("span",{className:"mind-toolbar__gap"})]}),(0,p.jsxs)("div",{className:"mind-canvas",ref:L,children:[(0,p.jsx)("div",{className:"mind-mount",ref:I}),n&&(0,p.jsx)("div",{className:"mind-mask",children:"Loading..."}),m&&(0,p.jsx)("div",{className:"mind-mask",children:m}),S&&(0,p.jsx)(b.rY,{click:()=>k(null),children:(0,p.jsx)(b.Pu,{x:S.x,y:S.y,items:X(h),click:e=>H(e)})})]})]})}function O(e){const t=e?.view?.getTransformData?.()?.state?.scale;return"number"==typeof t&&t>0?Math.round(100*t):100}},86063(e,t,n){"use strict";function a(e){return"smm-mind"===e}n.d(t,{Hn:()=>s,hj:()=>a,tW:()=>o});const r={mousewheelMoveStep:35,scaleRatio:.08};let l=null;function o(e){return e&&"object"==typeof e?e.data?.nodeData?i(e.data.nodeData):e.root&&"object"==typeof e.root?e.root.data?e:{...e,root:c(e.root)}:e.data&&"object"==typeof e.data?e:c(e):null}function i(e){return{data:{text:"string"==typeof e?.topic?e.topic:"string"==typeof e?.data?.text?e.data.text:""},children:Array.isArray(e?.children)?e.children.map(i):[]}}function c(e){return{data:{text:"string"==typeof e?.text?e.text:"",...e?.note?{note:e.note}:{}},children:Array.isArray(e?.children)?e.children.map(c):[]}}function d(e){e.stopPropagation()}async function s(e){const t=function(e){const t=e.trim();if(!t)return null;let n=null;try{n=JSON.parse(t)}catch{return null}return o(n)}(e),a=await(l||(l=Promise.all([Promise.all([n.e(8725),n.e(2728),n.e(2130),n.e(5602),n.e(8277)]).then(n.bind(n,45602)),n.e(8781).then(n.bind(n,88781))]).then(([e])=>e.default)),l);return{data:t,async mount(e,n){let l=!1;const o=await function(e,t){return new Promise(n=>{const a=()=>{t()?n(!1):e.isConnected&&e.clientWidth&&e.clientHeight?n(!0):window.setTimeout(a,16)};a()})}(e,()=>l);if(!o)return{destroy:()=>{},get_data:()=>null};const i=document.createElement("div");i.className="md-graph__mind-host",!1!==n?.release_wheel&&e.addEventListener("wheel",d,{capture:!0,passive:!0}),e.append(i);const c=new a({el:i,data:t?.root??t??{data:{text:""}},readonly:!n?.editable,fit:!0,...r});return t?.root&&c.setFullData(t),{destroy:()=>{l=!0,e.removeEventListener("wheel",d,{capture:!0}),c?.destroy?.()},get_data:()=>c?.getData?.(!1)}}}}n.d(t,["k$",0,r])},28277(){}}]);
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[4091,7181],{48890(e,t,n){n.d(t,{Kw:()=>i,Tt:()=>o});var i=n(80952),o=(n(82327),n(1766),n(24854),n(90008),n(90846),n(40975),n(44286),n(30766),n(14973),n(69687),n(1234),n(47507),n(87268),n(34678),n(24522));const s=`https://gcore.jsdelivr.net/npm/ace-builds@${i.version}/src-min-noconflict/`;i.config.set("basePath",s),i.config.set("modePath",s),i.config.set("themePath",s),i.config.set("workerPath",s)},84091(e,t,n){n.r(t),n.d(t,{default:()=>l});var i=n(96540),o=(n(80952),n(48890)),s=n(34843),a=n(82893),r=n(78247),c=n(74848);function l(e){const t=(0,i.useRef)(null),[n,l]=(0,s.fp)(a.AG.user_base_info),d=n.user_data.theme?.includes("dark")?"cloud_editor_dark":"cloud9_day";return(0,i.useEffect)(()=>{const n=o.Kw.edit(t.current,{value:r.xK.get_value_temp(e.editor_id),showPrintMargin:!1,theme:`ace/theme/${d}`,mode:e.model??o.Tt.getModeForPath(e.name??"").mode,wrap:!1,highlightActiveLine:!1,fontSize:14,...e.options});return n.setOptions({}),n.container.addEventListener("wheel",function(e){e.preventDefault()}),n.focus(),n.on("change",function(t){e.on_change&&e.on_change()}),t.current=n,n.formatCode=()=>{const e=o.Kw.require("ace/ext/beautify"),n=t.current;n&&e.beautify(n.session)},r.xK.set_editor_temp(n,e.editor_id),()=>{r.xK.delete_editor_temp(e.editor_id),n.destroy()}},[]),(0,c.jsx)("div",{ref:t,style:{height:"100%",width:"100%"}})}},57181(e,t,n){n.r(t),n.d(t,{default:()=>h});var i=n(96540),o=n(85997),s=n(57952),a=n(34843),r=n(82893),c=n(78247),l=(n(62042),n(84091)),d=n(34289),f=n(34251),u=n(74848);function h(){const[e,t]=(0,a.fp)(r.AG.editorSetting),[n,h]=(0,i.useState)(!1),[m,_]=(0,a.fp)(r.AG.fileShellShow),[v,p]=(0,a.fp)(r.AG.file_shell_hidden);async function g(){e.save&&n&&(await e.save(c.xK.get_editor_value()),c.xK.set_value_temp(""),h(!1))}const x=t=>{(t.ctrlKey||t.metaKey)&&"s"===t.key&&(t.preventDefault(),e.save&&n&&g())};return(0,i.useEffect)(()=>()=>{h(!1)},[e]),(0,i.useEffect)(()=>(document.addEventListener("keydown",x),()=>{document.removeEventListener("keydown",x)}),[n,e]),e.open&&(0,u.jsxs)("div",{id:"editor-container",children:[(0,u.jsxs)(s.A,{ignore_tags:!0,left_children:[(0,u.jsx)(o.rA,{title:"取消",icon:"close",onClick:function(){c.xK.set_value_temp(""),t({open:!1,model:"",fileName:"",save:null}),e?.close?.()}},1),(0,u.jsx)("div",{children:e.fileName},2)],children:[e.menu_list&&e.menu_list,(e.can_format||(0,f.zr)(e.fileName))&&(0,u.jsx)(o.rA,{title:"格式化",icon:"data_object",onClick:function(){c.xK.get_editor()?.formatCode()}}),e.opt_shell&&(0,u.jsx)(o.rA,{icon:"terminal",title:"shell",onClick:function(){m.show?p(!v):_({show:!0,path:(0,d.GG)("file",(0,d.vX)())})}}),n&&(0,u.jsx)(o.rA,{title:"保存",icon:"save",onClick:g}),(0,u.jsx)("title",{children:e.fileName})]}),(0,u.jsx)(l.default,{name:e.fileName,model:e.model,on_change:function(){n||h(!0)}})]})}}}]);
@@ -1 +0,0 @@
1
- (self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[735,6404,8277],{87943(e,t,n){"use strict";n.r(t),n.d(t,{default:()=>p});var a=n(96540),r=n(34843),l=n(82893),o=n(14284),i=n(62042),c=n(53459),d=n(34289),s=n(22022),u=n(35304),m=n(74848);function p(){const[e,t]=(0,r.fp)(l.AG.mind_editor),[n,p]=(0,a.useState)(!1),{t:f}=(0,s.Bd)(),_=(0,a.useRef)(null),b=void 0!==e.code_source,E=()=>{n&&!window.confirm(f("有未保存的修改,确定要关闭吗?"))||(t({}),e?.close?.())};return(0,a.useEffect)(()=>{if(void 0===e.url&&void 0===e.code_source)return;const t=e=>{"Escape"===e.key&&(e.stopPropagation(),E())};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[e.url,e.code_source,n]),void 0!==e.url||b?(0,m.jsx)("div",{id:"mind-container",className:b?"mind-container--over":void 0,children:(0,m.jsx)("div",{className:"mind-context",children:(0,m.jsx)(u.default,{fullscreen:!0,reset_key:e.url??e.name,url:b?void 0:e.url,data:b?e.code_source:void 0,on_dirty:p,register:e=>{_.current=e},header:(0,m.jsxs)("div",{className:"mind-topbar",children:[(0,m.jsx)("span",{className:"material-icons mind-topbar__icon",children:"account_tree"}),(0,m.jsx)("span",{className:"mind-topbar__name",children:e.name}),(0,m.jsx)("span",{style:{flex:1}}),(0,m.jsx)("button",{type:"button",className:"mind-btn",title:f("保存")+" (Ctrl+S)",onClick:async()=>{await(_.current?.save())},children:(0,m.jsx)("span",{className:"material-icons",children:"save"})}),(0,m.jsx)("button",{type:"button",className:"mind-btn",title:f("关闭"),onClick:E,children:(0,m.jsx)("span",{className:"material-icons",children:"close"})})]}),on_save:async n=>{if(b)return e.on_save_code?.(n),(0,i.SK)(f("保存成功")),t({}),!0;return(await o.$M.post(`save/${encodeURIComponent((0,d.GG)("file",(0,d.vX)()))}${e.name}`,{context:n})).code===c.m.Success&&((0,i.SK)(f("保存成功")),!0)}})})}):null}},35304(e,t,n){"use strict";n.r(t),n.d(t,{default:()=>C});var a=n(96540),r=n(57889),l=(n(14284),n(62042)),o=n(22022),i=n(45602),c=(n(88781),n(86063));const d={classic:{backgroundColor:"#fafafa",lineColor:"#4d8f7f",lineWidth:2,root:{fillColor:"#4d8f7f",color:"#fff",borderRadius:6,paddingX:18,paddingY:8},second:{fillColor:"#fff",color:"#2f4f47",borderRadius:5,borderColor:"#4d8f7f",borderWidth:1,paddingX:14,paddingY:6},node:{fillColor:"#fff",color:"#3c3c3c",borderRadius:5,borderColor:"#a8d5c8",borderWidth:1,paddingX:12,paddingY:5}},dark:{backgroundColor:"#1f2226",lineColor:"#6b7c8c",lineWidth:1,root:{fillColor:"#3a4654",color:"#f2f4f6",borderRadius:6,paddingX:18,paddingY:8},second:{fillColor:"#2b323a",color:"#e6eaef",borderRadius:5,borderColor:"#4c5866",borderWidth:1,paddingX:14,paddingY:6},node:{fillColor:"#242a31",color:"#ccd3da",borderRadius:5,borderColor:"#3c454f",borderWidth:1,paddingX:12,paddingY:5}},simple:{backgroundColor:"#fff",lineColor:"#c8ccd0",lineWidth:1,root:{fillColor:"transparent",color:"#202124",borderRadius:0,borderWidth:0,paddingX:10,paddingY:4},second:{fillColor:"transparent",color:"#202124",borderRadius:0,borderWidth:0,paddingX:8,paddingY:3},node:{fillColor:"transparent",color:"#5f6368",borderRadius:0,borderWidth:0,paddingX:8,paddingY:3}},colorful:{backgroundColor:"#fffdf6",lineColor:"#f2a65a",lineWidth:2,root:{fillColor:"#f2854a",color:"#fff",borderRadius:24,paddingX:20,paddingY:9},second:{fillColor:"#ffd66b",color:"#6b4a12",borderRadius:16,borderWidth:0,paddingX:14,paddingY:6},node:{fillColor:"#a8d8ea",color:"#1e3f4d",borderRadius:12,borderWidth:0,paddingX:12,paddingY:5}}};var s=n(34843),u=n(82893),m=n(61443),p=n(74848);function f(e){const[t,n]=(0,a.useState)(e.initValue||""),r=t=>{n(t),e.onChange(t)};return e.multiline?(0,p.jsx)("div",{className:"prompt-input",children:(0,p.jsx)(m.Z2,{placeholder:e.placeholder||"",rows:e.rows??5,value:t,handleInputChange:r})}):(0,p.jsx)("div",{className:"prompt-input",children:(0,p.jsx)(m.Sm,{placeholder:e.placeholder||"",value:t,handleInputChange:r})})}var _,b=n(75725),E=n(85997);n(30576);_=i.default,Object.entries(d).forEach(([e,t])=>{_.defineTheme?.(e,t)});const h=[{cmd:"INSERT_CHILD_NODE",icon:"account_tree",label:"添加子节点"},{cmd:"INSERT_NODE",icon:"subdirectory_arrow_right",label:"添加同级节点"},{cmd:"INSERT_PARENT_NODE",icon:"arrow_upward",label:"插入父节点"},{cmd:"CUT_NODE",icon:"content_cut",label:"剪切"},{cmd:"PASTE_NODE",icon:"content_paste",label:"粘贴"},{cmd:"REMOVE_NODE",icon:"delete",label:"删除节点"},{cmd:"INSERT_GROUP",icon:"add_circle_outline",label:"插入",children:[{cmd:"SET_NODE_ICON",icon:"emoji_emotions",label:"插入图标"},{cmd:"REMOVE_NODE_ICON",icon:"format_clear",label:"删除图标"},{cmd:"SET_NODE_NOTE",icon:"sticky_note_2",label:"节点备注"},{cmd:"REMOVE_NODE_NOTE",icon:"speaker_notes_off",label:"删除备注"},{cmd:"SET_NODE_TAG",icon:"sell",label:"节点标签"},{cmd:"REMOVE_NODE_TAG",icon:"label_off",label:"删除标签"},{cmd:"SET_NODE_HYPERLINK",icon:"link",label:"插入超链接"},{cmd:"REMOVE_NODE_HYPERLINK",icon:"link_off",label:"删除超链接"}]},{cmd:"ADD_GENERALIZATION",icon:"call_merge",label:"添加概要"},{cmd:"REMOVE_GENERALIZATION",icon:"call_split",label:"删除概要"}],N=[{value:"logicalStructure",label:"逻辑结构图"},{value:"mindMap",label:"思维导图"},{value:"organizationStructure",label:"组织结构图"},{value:"catalogOrganization",label:"目录组织图"},{value:"timeline",label:"时间轴(左)"},{value:"timeline2",label:"时间轴(下)"},{value:"timeline3",label:"时间轴(上)"},{value:"verticalTimeline",label:"时间轴(竖)"},{value:"fishbone",label:"鱼骨图"},{value:"rightFishbone",label:"鱼骨图(右)"}],v=[{value:"curve",label:"曲线"},{value:"straight",label:"直线"},{value:"direct",label:"直连"}],g=[{value:"default",label:"默认主题"},{value:"classic",label:"经典"},{value:"dark",label:"暗色"},{value:"simple",label:"极简"},{value:"colorful",label:"缤纷"}],x=i.default.iconList||[];function C(e){const{t}=(0,o.Bd)(),[n,d]=(0,a.useState)(!0),[m,_]=(0,a.useState)(""),[C,O]=(0,a.useState)(100),[j,w]=(0,a.useState)("default"),[,D]=(0,s.fp)(u.AG.prompt_card),[T,R]=(0,a.useState)("mindMap"),[S,k]=(0,a.useState)(null),I=(0,a.useRef)(null),L=(0,a.useRef)(null),A=(0,a.useRef)(null),M=(0,a.useRef)(!1),Y=(0,a.useRef)({props:e});Y.current={props:e};const W=()=>{M.current||(M.current=!0,Y.current.props.on_dirty?.(!0))},P=async()=>{if(!A.current)return(0,l.zN)(t("编辑器尚未就绪")),!1;const e=await Y.current.props.on_save((()=>{const e=A.current;return e?JSON.stringify(e.getData(!0)):""})());return e&&(M.current=!1,Y.current.props.on_dirty?.(!1),Y.current.props.on_saved?.()),e};(0,a.useEffect)(()=>{e.register?.({save:P,is_dirty:()=>M.current})},[e.register]),(0,a.useEffect)(()=>{if(!I.current)return;if(!e.url&&void 0===e.data)return;let n=!1;const a=[];A.current?.destroy?.(),A.current=null,M.current=!1,d(!0),_("");const o=async e=>{if(n||!I.current)return;const r=e&&e.root?e:null,l=r?r.root:e??{data:{text:t("中心主题")}},o=new i.default({el:I.current,data:l,fit:!0,enableDblclickBackToRootNode:!0,enableShortcutOnlyWhenMouseInSvg:!0,autoMoveWhenMouseInEdgeOnDrag:!0,...c.k$});A.current=o,r&&o.setFullData(r),d(!1),w(o.getTheme?.()||"default"),R(o.getLayout?.()||"mindMap");window.requestAnimationFrame(()=>{n||(()=>{let e=!1;const t=window.setTimeout(()=>{n||(e=!0)},400);a.push(t),o.on("data_change",()=>{e&&(W(),O(y(o)))}),o.on("view_data_change",()=>{O(y(o))}),o.on("error",(e,t)=>{console.error("[mind]",e,t)}),O(y(o))})()})};return(async()=>{try{let t=null;if(void 0!==e.data)t=e.data;else{const a=await r.l.get(e.url);if(n)return;t=a}let a=null;if("string"==typeof t&&t.trim())try{a=JSON.parse(t)}catch{a=null}else t&&"object"==typeof t&&(a=t);a=(0,c.tW)(a),await o(a)}catch(e){n||(d(!1),_(t("加载思维导图失败")),(0,l.zN)(t("加载思维导图失败")))}})(),()=>{n=!0,a.forEach(e=>window.clearTimeout(e)),A.current?.destroy?.(),A.current=null}},[e.url,e.data]),(0,a.useEffect)(()=>{const e=e=>{(e.ctrlKey||e.metaKey)&&("s"===e.key||"S"===e.key||83===e.keyCode)&&(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),P())};return window.addEventListener("keydown",e,!0),document.addEventListener("keydown",e,!0),()=>{window.removeEventListener("keydown",e,!0),document.removeEventListener("keydown",e,!0)}},[]);const G=e=>{const t=A.current;if(!t)return;const n=Math.min(4,Math.max(.25,e));t.view.setScale(n),O(Math.round(100*n))},V={SET_NODE_NOTE:{title:"节点备注",placeholder:"请输入节点备注",get:e=>e.getData("note")||""},SET_NODE_TAG:{title:"节点标签",placeholder:"请输入节点标签,多个用逗号分隔",get:e=>(e.getData("tag")||[]).join(",")},SET_NODE_HYPERLINK:{title:"插入超链接",placeholder:"请输入链接地址",get:e=>e.getData("hyperlink")||""}};(0,a.useEffect)(()=>{if(!S)return;const e=()=>k(null),t=window.setTimeout(()=>{window.addEventListener("click",e),window.addEventListener("blur",e)},0);return()=>{window.clearTimeout(t),window.removeEventListener("click",e),window.removeEventListener("blur",e)}},[S]),(0,a.useEffect)(()=>{const e=L.current;if(!e)return;const t=e=>{const t=A.current?.renderer?.activeNodeList?.[0];t&&(e.preventDefault(),e.stopPropagation(),k({x:e.clientX,y:e.clientY,node:t}))};return e.addEventListener("contextmenu",t,!0),()=>e.removeEventListener("contextmenu",t,!0)},[]);const X=e=>e.map(e=>({v:e.cmd,r:(0,p.jsxs)("div",{className:"common-tag-center mind-menu-row",children:[(0,p.jsx)(E.In,{icon:e.icon,not_use_icon_style:!0}),(0,p.jsx)("span",{children:t(e.label)})]}),items:e.children?X(e.children):void 0})),H=e=>{const n=A.current,a=S;if(n&&a){if(k(null),"ADD_GENERALIZATION"===e||"REMOVE_GENERALIZATION"===e)return n.execCommand(e),void W();"SET_NODE_NOTE"!==e&&"SET_NODE_TAG"!==e&&"SET_NODE_HYPERLINK"!==e?"SET_NODE_ICON"!==e?e.startsWith("REMOVE_NODE_")?((e,t)=>{e&&("REMOVE_NODE_ICON"===t?A.current.execCommand("SET_NODE_ICON",e,[]):"REMOVE_NODE_NOTE"===t?A.current.execCommand("SET_NODE_NOTE",e,""):"REMOVE_NODE_TAG"===t?A.current.execCommand("SET_NODE_TAG",e,[]):"REMOVE_NODE_HYPERLINK"===t&&A.current.execCommand("SET_NODE_HYPERLINK",e,"",""),W())})(a.node,e):(n.execCommand(e,a.node),W()):(e=>{if(!e)return;const n=Array.isArray(e.getData("icon"))?e.getData("icon"):[];D({open:!0,title:t("插入图标"),context_div:(0,p.jsx)("div",{className:"prompt-icon-list",children:x.flatMap(t=>(t.list||[]).map((a,r)=>(0,p.jsx)("button",{type:"button",className:"prompt-icon-list__item",title:a.name,dangerouslySetInnerHTML:{__html:a.icon},onClick:()=>{A.current.execCommand("SET_NODE_ICON",e,[...n,`${t.type}_${a.name}`]),D({open:!1}),W()}},t.type+r)))}),cancel:()=>D({open:!1})})})(a.node):((e,n)=>{if(!e)return;const a=V[n],r=a.get(e);let l=r;D({open:!0,title:t(a.title),context_div:(0,p.jsx)(f,{initValue:r,placeholder:t(a.placeholder),multiline:!0,onChange:e=>l=e}),confirm:()=>{const t=l.trim();"SET_NODE_TAG"===n?A.current.execCommand(n,e,t.split(/[,,]/).map(e=>e.trim()).filter(Boolean)):"SET_NODE_HYPERLINK"===n?A.current.execCommand(n,e,t,t):A.current.execCommand(n,e,t),D({open:!1}),W()},cancel:()=>D({open:!1})})})(a.node,e)}};return(0,p.jsxs)("div",{className:"mind-wrap"+(e.fullscreen?" mind-wrap--full":""),children:[e.header,(0,p.jsxs)("div",{className:"mind-toolbar",children:[(0,p.jsx)("button",{type:"button",className:"mind-btn",title:t("添加子节点")+" (Tab)",onClick:()=>A.current?.execCommand?.("INSERT_CHILD_NODE"),children:(0,p.jsx)("span",{className:"material-icons",children:"account_tree"})}),(0,p.jsx)("button",{type:"button",className:"mind-btn",title:t("添加同级节点")+" (Enter)",onClick:()=>A.current?.execCommand?.("INSERT_NODE"),children:(0,p.jsx)("span",{className:"material-icons",children:"subdirectory_arrow_right"})}),(0,p.jsx)("button",{type:"button",className:"mind-btn",title:t("删除节点")+" (Delete)",onClick:()=>A.current?.execCommand?.("REMOVE_NODE"),children:(0,p.jsx)("span",{className:"material-icons",children:"delete"})}),(0,p.jsx)("span",{className:"mind-toolbar__sep"}),(0,p.jsx)("button",{type:"button",className:"mind-btn",title:t("撤销")+" (Ctrl+Z)",onClick:()=>A.current?.execCommand?.("BACK"),children:(0,p.jsx)("span",{className:"material-icons",children:"undo"})}),(0,p.jsx)("button",{type:"button",className:"mind-btn",title:t("重做")+" (Ctrl+Y)",onClick:()=>A.current?.execCommand?.("FORWARD"),children:(0,p.jsx)("span",{className:"material-icons",children:"redo"})}),(0,p.jsx)("span",{className:"mind-toolbar__sep"}),(0,p.jsxs)("span",{className:"mind-toolbar__zoom",children:[C,"%"]}),(0,p.jsx)("button",{type:"button",className:"mind-btn",title:t("缩小"),onClick:()=>G(y(A.current)/100-.2),children:(0,p.jsx)("span",{className:"material-icons",children:"remove"})}),(0,p.jsx)("button",{type:"button",className:"mind-btn",title:t("放大"),onClick:()=>G(y(A.current)/100+.2),children:(0,p.jsx)("span",{className:"material-icons",children:"add"})}),(0,p.jsx)("button",{type:"button",className:"mind-btn",title:t("适应窗口"),onClick:()=>{A.current?.view?.fit?.(),O(y(A.current))},children:(0,p.jsx)("span",{className:"material-icons",children:"fit_screen"})})]}),(0,p.jsxs)("div",{className:"mind-toolbar mind-toolbar--sub",children:[(0,p.jsx)("select",{className:"mind-select",title:t("结构"),value:T,onChange:e=>{const t=e.target.value;A.current?.setLayout?.(t),R(t),W()},children:N.map(e=>(0,p.jsx)("option",{value:e.value,children:t(e.label)},e.value))}),(0,p.jsxs)("select",{className:"mind-select",title:t("连线风格"),defaultValue:"",onChange:e=>{const t=e.target.value;if(t){const e=A.current?.getCustomThemeConfig?.()||{};A.current?.setThemeConfig?.({...e,lineStyle:t}),W()}e.target.value=""},children:[(0,p.jsx)("option",{value:"",children:t("连线风格")}),v.map(e=>(0,p.jsx)("option",{value:e.value,children:t(e.label)},e.value))]}),(0,p.jsx)("select",{className:"mind-select",title:t("主题"),value:j,onChange:e=>{const t=e.target.value;w(t),A.current?.setTheme?.(t),W()},children:g.map(e=>(0,p.jsx)("option",{value:e.value,children:t(e.label)},e.value))}),(0,p.jsx)("span",{className:"mind-toolbar__gap"})]}),(0,p.jsxs)("div",{className:"mind-canvas",ref:L,children:[(0,p.jsx)("div",{className:"mind-mount",ref:I}),n&&(0,p.jsx)("div",{className:"mind-mask",children:"Loading..."}),m&&(0,p.jsx)("div",{className:"mind-mask",children:m}),S&&(0,p.jsx)(b.rY,{click:()=>k(null),children:(0,p.jsx)(b.Pu,{x:S.x,y:S.y,items:X(h),click:e=>H(e)})})]})]})}function y(e){const t=e?.view?.getTransformData?.()?.state?.scale;return"number"==typeof t&&t>0?Math.round(100*t):100}},86063(e,t,n){"use strict";function a(e){return"smm-mind"===e}n.d(t,{Hn:()=>s,hj:()=>a,tW:()=>o});const r={mousewheelMoveStep:35,scaleRatio:.08};let l=null;function o(e){return e&&"object"==typeof e?e.data?.nodeData?i(e.data.nodeData):e.root&&"object"==typeof e.root?e.root.data?e:{...e,root:c(e.root)}:e.data&&"object"==typeof e.data?e:c(e):null}function i(e){return{data:{text:"string"==typeof e?.topic?e.topic:"string"==typeof e?.data?.text?e.data.text:""},children:Array.isArray(e?.children)?e.children.map(i):[]}}function c(e){return{data:{text:"string"==typeof e?.text?e.text:"",...e?.note?{note:e.note}:{}},children:Array.isArray(e?.children)?e.children.map(c):[]}}function d(e){e.stopPropagation()}async function s(e){const t=function(e){const t=e.trim();if(!t)return null;let n=null;try{n=JSON.parse(t)}catch{return null}return o(n)}(e),a=await(l||(l=Promise.all([Promise.all([n.e(8725),n.e(2728),n.e(2130),n.e(5602),n.e(8277)]).then(n.bind(n,45602)),n.e(8781).then(n.bind(n,88781))]).then(([e])=>e.default)),l);return{data:t,async mount(e,n){let l=!1;const o=await function(e,t){return new Promise(n=>{const a=()=>{t()?n(!1):e.isConnected&&e.clientWidth&&e.clientHeight?n(!0):window.setTimeout(a,16)};a()})}(e,()=>l);if(!o)return{destroy:()=>{},get_data:()=>null};const i=document.createElement("div");i.className="md-graph__mind-host",!1!==n?.release_wheel&&e.addEventListener("wheel",d,{capture:!0,passive:!0}),e.append(i);const c=new a({el:i,data:t?.root??t??{data:{text:""}},readonly:!n?.editable,fit:!0,...r});return t?.root&&c.setFullData(t),{destroy:()=>{l=!0,e.removeEventListener("wheel",d,{capture:!0}),c?.destroy?.()},get_data:()=>c?.getData?.(!1)}}}}n.d(t,["k$",0,r])},28277(){}}]);
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[6010,8302],{83277(e,t,n){n.d(t,{$j:()=>a,Lv:()=>s});class s{token;open=!1;note;index;url;model;request_type;json_params;sys_prompt;dotenv="";tool_mode=!1;show_options;static get_label_by_v(e,t){if(!e||!t?.length)return e;for(const n of t)if(n.value===e)return n.label;return e}static have_label_by_v(e,t){if(!e||!t?.length)return!1;for(const n of t)if(n.value===e)return!0;return!1}}const o=JSON.stringify({stream:!0,thinking:{type:"disabled"}});function a(e){return"string"==typeof e?e:Array.isArray(e)?e.map(e=>"text"===e.type?e.text:"[图片]").join("\n"):""}n.d(t,["CP",0,'\n\n\n\n# 聊天循环最大次数\ntool_call_max=500\n# 是否允许AI直接执行命令而不需要用户确认,默认为false,需要用户手动确认,如果使用 workflow 这里等价于为 true\nallow_exec_cmd_directly=false\n\n# 可选的代理 url,如果指定了所有访问大模型的请求将会走代理\n#proxy_url=\n\n# 可选的多个url 以数组分割\n# options_agent_url_list=[{"value":"http://..","label":"openai"}]\n\n# 可选的多个 key\n# options_agent_key_list=[{"value":"sh-aaa","label":"option1"}]\n\n# 可选的多个 model\n# options_agent_model_list=[{"value":"gpt-5.5","label":"gpt"}]\n\n# 存放本地的 prompt 文件 用于每次聊天的时候自动读取并加载\n# options_local_file_path_prompt_list=["/prompt/a.txt"]\n\n# 开启切换模型 ,开启以后,你可以自己写 prompt 提供多个模型让 ai 自己根据每次聊天切换下一步调用其他模型的次数\n# open_pick_model=false\n\n# 压缩后仍然完整保留的最近消息数\nmax_recent_messages=12\n# 当单个会话累计消息条数超过该值时,触发历史消息裁剪\ncompress_message_count=16\n# 历史消息中 tool 输出的最大字符数,只保留调用形式让 AI 知道调用了就行\nmax_tool_content_chars=200\n\n# ===== 模型类型(request_type)=====\n# 必填项,不同类型的 model 接口格式不同,默认 completions。\n# 可选值:\n# completions 标准对话/聊天补全 (chat/completions)\n# images 图片生成 (images/generations)\n# audio_speech 文本转语音 (audio/speech)\n# audio_transcription 语音转文字 (audio/transcriptions)\n# audio_translation 语音翻译 (audio/translations)\n# embeddings 向量嵌入 (embeddings)\n#request_type=completions\n\n# ===== 成为 tool(tool_mode)=====\n# 开启后该模型会作为一个工具被加载,可实现不同模型担任不同角色/能力,供 AI agent 在对话中动态调用。\n# 注意:不能与「是否开启」(open) 同时为 true。\n#tool_mode=false\n\n# ===== 是否支持图片(support_image)=====\n# 开启后:1) 注册 read_image 工具,让 AI 能读取本地图片;\n# 2) 工具读到的图片会以 OpenAI 多模态格式 image_url 随消息发给模型,模型就能真正"看图"。\n# 关闭后:AI 看不到图片,read_image 只会返回一句文字说明。\n# 主流模型(gpt-4o、豆包、qwen-vl、deepseek-vl 等)都支持,默认开启。\nsupport_image=true\n',"cL",0,o])},77481(e,t,n){n.d(t,{S:()=>r,X:()=>i});var s=n(96540),o=n(61443),a=n(74848);function i(e){const[t,n]=s.useState([]),i=(0,s.useRef)(-1),[r,l]=(0,s.useState)(-1),[c,d]=(0,s.useState)(-1);(0,s.useEffect)(()=>{e.children?n(Array.isArray(e.children)?e.children:[e.children]):n(e.rows)},[e.rows,e.children]);const p=()=>{i.current=-1,l(-1),d(-1)};return(0,a.jsxs)("table",{children:[(0,a.jsx)("thead",{children:(0,a.jsx)("tr",{children:e.headers?.map((t,n)=>{const s=!!e.filter&&(e.filter.column??0)===n;let i=t;if(s){const n=e.filter,s=n.options.find(e=>e.value===n.value);null!=n.value&&s&&(i=`${t} (${s.label})`)}return(0,a.jsx)("th",{className:s?"table-filter-col":"",children:s?(0,a.jsx)(o.l6,{value:e.filter.value,options:e.filter.options,onChange:e.filter.onChange,bare:!0,trigger_label:i}):t},n)})})}),(0,a.jsx)("tbody",{children:t.map((t,n)=>{const s=!!e.onRowDrag;return(0,a.jsx)("tr",{className:s?(r===n?"row-dragging":"")+(c===n?" row-drop-target":""):"",draggable:s,onContextMenu:()=>{e.handleContextMenu&&e.handleContextMenu(t)},onDragStart:e=>{s&&(i.current=n,l(n),e.dataTransfer.effectAllowed="move")},onDragOver:e=>{!s||i.current<0||(e.preventDefault(),e.dataTransfer.dropEffect="move",d(n))},onDrop:t=>{s&&(t.preventDefault(),(()=>{const t=i.current,n=c;p(),t<0||n<0||t===n||e.onRowDrag?.(t,n)})())},onDragEnd:p,children:t.map((n,s)=>{const o=s===t.length-1?"small":"";return(0,a.jsx)("td",{className:o,style:{width:e.width??"auto"},children:n},s)})},n)})})]})}function r(e){return(0,a.jsx)("div",{style:{display:e.isFlex?"flex":"block"},children:e.columns.map((e,t)=>(0,a.jsx)("div",{children:e},t))})}},29591(e,t,n){n.r(t),n.d(t,{default:()=>N});var s=n(22022),o=n(96540),a=n(85997),i=n(4412),r=n(34843),l=n(82893),c=n(75725),d=n(77481),p=n(61443),m=n(70447),u=n(34299),_=n(74848);var h=n(14284),x=n(53459),g=n(62042),v=n(7523),j=n(78247),f=n(23430),y=n(61973),w=n(14944),C=n(92275),b=n(88815),A=n(64694),k=n(45907),S=n(12721),I=n(24659),K=n(83277);function N(){const{t:e}=(0,s.Bd)(),{initUserInfo:t}=(0,o.useContext)(v.F),n=[e("编号"),e("url"),e("是否开启"),e("key"),e("默认model"),e("更多属性"),e("备注")],N=[e("编号"),e("本地目录"),e("自动加载"),e("备注")],[$,O]=(0,o.useState)([]),[L,M]=(0,o.useState)({}),[P,X]=(0,o.useState)([]),[D,T]=(0,o.useState)([]),[H,R]=(0,o.useState)(null),q=(0,o.useRef)(),F=(0,o.useRef)(!1),V=(0,o.useRef)(!1),[E,Y]=(0,o.useState)([]),[B,G]=(0,o.useState)(!1),[J,W]=(0,o.useState)({}),[z,U]=(0,r.fp)(l.AG.prompt_card),[Z,Q]=(0,r.fp)(l.AG.user_base_info),[ee,te]=(0,o.useState)(!1),ne=D.filter(e=>"http"!==(e.transport??"stdio")),se=D.filter(e=>"http"===e.transport),oe=[e("编号"),e("名称"),e("是否开启"),e("状态"),"command","args","cwd",e("tools|env"),e("备注")],ae=[e("编号"),e("名称"),e("是否开启"),e("状态"),e("endpoint"),e("tools|headers"),e("备注")],ie=[e("编号"),e("提示词"),e("LLM编辑开关"),e("llm_pmt"),e("编辑规则"),e("备注")],[re,le]=(0,o.useState)([]),[ce,de]=(0,o.useState)(!1),pe=function(){const[e,t]=(0,r.fp)(l.AG.prompt_card);return e=>{t({open:!0,title:"信息",context_div:(0,_.jsx)("div",{children:(0,_.jsx)(u.default,{context:e})})})}}(),{check_user_auth:me}=(0,j.MH)(),[ue,_e]=(0,r.fp)(l.AG.editorSetting),he=(0,y.Zp)(),xe=(0,k.y)(),ge=(0,I.K)(),ve=async()=>{const e=await h.jV.get("docs_on_get");e.code===x.m.Success&&te(e.data)};(0,o.useEffect)(()=>{(async()=>{const e=await h.XO.get("ai_agent_setting");e.code===x.m.Success&&O(e.data.models);const t=await h.XO.get("ai_agent_global_setting");t.code===x.m.Success&&M(t.data??{}),await w.ws.addMsg(C.HK.ai_load_info,e=>{R(e.context)});const n=await w.ws.sendData(C.HK.ai_load_info,{});n?.context&&R(n.context);const s=await h.XO.get("ai_docs_setting");s.code===x.m.Success&&(q.current=s.data.param,s.data.list?.length&&X(s.data.list));const o=await h.XO.get("ai_mcp_setting");o.code===x.m.Success&&T(o.data.list??[]),await Ae(),ve();const a=await h.XO.get("ai_system_prompts");a.code===x.m.Success&&le(a.data??[]);const i=await h.XO.get("ai_long_term_memory_setting");i.code===x.m.Success&&de(i.data?.open??!1)})()},[]),(0,o.useEffect)(()=>{w.ws.addMsg(C.HK.mcp_status,e=>{const t=e.context??{},n={};for(const e of t.status??[])n[e.index]={state:e.state,error:e.error,tool_count:e.tool_count};W(n),t.done&&Ae()})},[]);const je=(e="stdio")=>{const t="http"===e?{name:"",open:!1,note:"",transport:"http",endpoint:"",headers:"",stream:!1,timeout_ms:1e4}:{name:"",open:!1,command:"",args:"",cwd:"",env:"",note:"",transport:"stdio",timeout_ms:1e4};T([...D,t]),F.current=!0},fe=e=>{const t=D.indexOf(e);t<0||(D.splice(t,1),T([...D]),F.current=!0)},ye=e=>{T([...D,{...e,open:!1}]),F.current=!0},we=async e=>{for(let e=0;e<$.length;e++)$[e].index=e;(await h.XO.post("ai_agent_setting/save",{models:e??$})).code===x.m.Success&&(0,g.SK)("保存成功")},Ce=async e=>{(await h.XO.post("ai_agent_global_setting/save",e??L)).code===x.m.Success&&(0,g.SK)("保存成功")},be=async e=>{for(let e=0;e<D.length;e++)D[e].index=e;(await h.XO.post("ai_mcp_setting/save",{list:e??D})).code===x.m.Success&&((0,g.SK)("保存成功"),F.current=!1,w.ws.sendData(C.HK.mcp_reload,{}))},Ae=async()=>{const e=await h.XO.get("ai_mcp_tools");return e.code===x.m.Success?(Y(e.data??[]),e.data??[]):[]},ke=async e=>{G(!0);try{const t=await h.XO.post("ai_mcp_tools/reload",{index:e});if(t.code===x.m.Success)return await Ae(),(0,g.SK)("MCP工具加载成功"),t.data??null}finally{G(!1)}return null},Se=async(t,n,s,o)=>{const a=o??E.find(e=>e.index===n)??{index:n,key:`${n}`,name:t.name??"",note:t.note,transport:t.transport??"stdio",open:!!t.open,loaded:!1,tool_count:0,tools:[]},i=(a.tools??[]).map(t=>({id:t.runtime_name,title:t.tool_name,subtitle:t.description||e("无描述"),detail:t.display_name,meta:t.runtime_name}));U({open:!0,title:`${t.name||t.note||n} MCP工具`,context_div:(0,_.jsx)(S.O,{title:`${t.name||t.note||n} MCP工具`,subtitle:`${a.transport??"stdio"} | ${a.open?e("是"):e("否")} | ${a.loaded?"loaded":"idle"} | ${a.tool_count} tools`,pages:i,initialPageId:s,onRefresh:async()=>{const e=await ke(n);e&&await Se(t,n,s,e)},renderPage:t=>{if(!t)return(0,_.jsx)("div",{className:"prompt-switch-page__empty",children:e("暂无工具")});const n=a.tools?.find(e=>e.runtime_name===t.id);return n?(0,_.jsxs)("div",{className:"prompt-switch-page__detail",children:[(0,_.jsx)("div",{className:"prompt-switch-page__detail-title",children:n.display_name}),(0,_.jsx)("div",{className:"prompt-switch-page__detail-desc",children:n.description||e("无描述")}),(0,_.jsxs)("div",{className:"prompt-switch-page__detail-row",children:[(0,_.jsx)("strong",{children:"runtime:"})," ",n.runtime_name]}),(0,_.jsxs)("div",{children:[(0,_.jsx)("strong",{children:"schema:"}),(0,_.jsx)("pre",{className:"prompt-switch-page__schema",children:JSON.stringify(n.input_schema??{},null,2)})]})]}):(0,_.jsx)("div",{className:"prompt-switch-page__empty",children:e("暂无工具")})}}),cancel:()=>U({open:!1})})},Ie=t=>{const n=J[t];let s=n?.state,o=n?.error,a=n?.tool_count;if(!s){const e=E.find(e=>e.index===t);s=e?.state,o=e?.error,a=e?.tool_count}switch(s){case"loading":return(0,_.jsx)(m.fq,{loading:!0,text:e("加载中")});case"success":return(0,_.jsx)(m.fq,{success:!0,text:`${a??0} ${e("个工具")}`});case"failed":return(0,_.jsx)("span",{title:o??e("加载失败"),children:(0,_.jsx)(m.fq,{success:!1,text:e("加载失败")})});default:return(0,_.jsx)(m.fq,{text:e("未加载")})}},Ke=async e=>{for(let e=0;e<$.length;e++)$[e].index=e;let t={list:P,docs_update_tag:V.current};null!=e&&(t={param:e}),V.current=!1;(await h.XO.post("ai_docs_setting_save",t)).code===x.m.Success&&(0,g.SK)("保存成功")},Ne=async()=>{for(let e=0;e<re.length;e++)re[e].index=e;(await h.XO.post("ai_system_prompts/save",{list:re})).code===x.m.Success&&(0,g.SK)("保存成功")};return(0,_.jsxs)("div",{children:[(0,_.jsx)(i.aZ,{position:"right",children:me(f.oV.ai_agent_setting)&&(0,_.jsx)(a.rA,{icon:"arrow_back",title:e("上一页"),onClick:()=>{he(-1)}})}),(0,_.jsx)(c.jW,{isFull:!0,more:!0,children:(0,_.jsx)(c.NN,{children:(0,_.jsxs)(c.xh,{children:[(0,_.jsx)(c.fI,{children:(0,_.jsx)(c.VP,{widthPer:100,children:(0,_.jsx)(m.uF,{self_title:(0,_.jsxs)("span",{className:" div-row ",children:[(0,_.jsx)("h2",{children:e("供应商设置")})," ",(0,_.jsx)(a.rA,{icon:"info",onClick:()=>{pe('\n1. Only OpenAI-style AI APIs are supported. Fill in the FULL endpoint path (not just the domain), e.g. https://ark.cn-beijing.volces.com/api/v3/chat/completions\n2. The longer the conversation history, the more expensive the LLM token cost. Currently, there is no long-term memory simplification capability. You can set the system prompt to make the AI answer more concisely to save tokens\n3. When writing the model request parameter JSON, you can only write JSON in it, to configure the attributes supported by OpenAI-style AI, such as temperature, thinking (Doubao\'s deep thinking toggle), etc.\n4. You can enable "stream": true in the model request parameters to improve response speed.\n5. Deep thinking currently affects output speed. It is recommended to set { "thinking" : { "type":"disabled" } } to disable it (Doubao example).\n6. To use the AI feature to query server information, the AI needs to be able to know some commands. You need to first set command permissions for the user in user settings. It is recommended to set * to allow all commands, and then set the dangerous commands that are not allowed to be executed in the settings\n7. The model type and Become Tool are now both configured in "More Attributes → Extra Parameter Settings" using request_type / tool_mode (comments are already provided in the editor).\n8. After becoming a tool, the model will be loaded as a tool, enabling different models to serve as different roles; please do not set both it and "Enabled" to true at the same time.\n')},title:"信息"})]}),titleCom:(0,_.jsxs)("div",{children:[(0,_.jsx)(a.rA,{icon:"short_text",title:e("全局prompt"),onClick:()=>{_e({model:"ace/mode/text",open:!0,fileName:"",save:async e=>{L.sys_prompt=e,M({...L}),j.xK.set_value_temp(""),await Ce({...L,sys_prompt:e})}}),j.xK.set_value_temp(L.sys_prompt??"")}}),(0,_.jsx)(a.rA,{icon:"edit_attributes",title:e("全局")+" "+e("model请求参数json编写"),onClick:()=>{_e({model:"ace/mode/json",open:!0,fileName:"",save:async e=>{L.json_params=e,M({...L}),j.xK.set_value_temp(""),await Ce({...L,json_params:e})},can_format:!0}),j.xK.set_value_temp(L.json_params??"")}}),(0,_.jsx)(a.rA,{icon:"settings",title:e("全局")+" "+e("额外参数设置"),onClick:()=>{_e({model:"ace/mode/ini",open:!0,fileName:"",save:async e=>{L.dotenv=e,M({...L}),j.xK.set_value_temp(""),await Ce({...L,dotenv:e})}}),j.xK.set_value_temp(L.dotenv??"")}}),(0,_.jsx)(a.rA,{icon:"add",title:e("添加"),onClick:()=>{O([...$,{note:"",open:!1,path:"",dotenv:K.CP,json_params:K.cL}])}}),(0,_.jsx)(a.rA,{icon:"save",title:e("保存"),onClick:async()=>{await we()}})]}),children:(0,_.jsx)(d.X,{headers:n,onRowDrag:(e,t)=>{O((0,A.TI)($,e,t))},rows:$.map((t,n)=>{const s=[(0,_.jsx)("div",{children:n}),(0,_.jsx)(p.Sm,{value:K.Lv.get_label_by_v(t.url,t.show_options?.options_agent_url_list),options:t.show_options?.options_agent_url_list,handleInputChange:e=>{t.url=e},no_border:!0}),(0,_.jsx)(p.l6,{value:t.open,onChange:e=>{((e,t,n)=>{const s=[];for(let e=0;e<$.length;e++)$[e].open=e===n&&t,s.push($[e]);O(s)})(0,e,n)},options:ge,no_border:!0}),(0,_.jsx)(p.Sm,{type:K.Lv.have_label_by_v(t.token,t.show_options?.options_agent_key_list)?null:"password",value:K.Lv.get_label_by_v(t.token,t.show_options?.options_agent_key_list),options:t.show_options?.options_agent_key_list,handleInputChange:e=>{t.token=e},no_border:!0}),(0,_.jsx)(p.Sm,{value:K.Lv.get_label_by_v(t.model,t.show_options?.options_agent_model_list),options:t.show_options?.options_agent_model_list,handleInputChange:e=>{t.model=e},no_border:!0}),(0,_.jsxs)("div",{children:[(0,_.jsx)(a.rA,{icon:"short_text",title:"prompt",onClick:()=>{j.xK.set_value_temp($[n].sys_prompt??""),_e({model:"ace/mode/text",open:!0,fileName:"",save:async e=>{$[n].sys_prompt=e,O($),j.xK.set_value_temp(""),we($)}})}}),(0,_.jsx)(a.rA,{icon:"edit_attributes",title:"model请求参数json编写",onClick:()=>{j.xK.set_value_temp($[n].json_params),_e({model:"ace/mode/json",open:!0,fileName:"",save:async e=>{$[n].json_params=e,O($),j.xK.set_value_temp(""),we($)},can_format:!0})}}),(0,_.jsx)(a.rA,{icon:"settings",title:"额外参数设置",onClick:()=>{j.xK.set_value_temp($[n].dotenv),_e({model:"ace/mode/ini",open:!0,fileName:"",save:async e=>{$[n].dotenv=e,O($),j.xK.set_value_temp(""),we($)}})}})]}),(0,_.jsx)(p.Sm,{value:t.note,handleInputChange:e=>{t.note=e},no_border:!0}),(0,_.jsxs)("div",{children:[(0,_.jsx)(a.rA,{icon:"delete",title:e("删除"),onClick:()=>(e=>{$.splice(e,1),O([...$])})(n)}),(0,_.jsx)(a.rA,{icon:"copy_all",title:e("复制"),onClick:()=>(e=>{O([...$,{...$[e],open:!1}])})(n)})]})];return s}),width:"10rem"})})})}),(0,_.jsx)(c.fI,{children:(0,_.jsx)(c.VP,{widthPer:70,children:(0,_.jsx)(m.uF,{self_title:(0,_.jsxs)("span",{className:" div-row ",children:[(0,_.jsxs)("h2",{children:[e("MCP")+" "+e("设置")," - stdio"]})," ",(0,_.jsx)(a.rA,{icon:"info",onClick:()=>{pe("\n1. 这里配置的是 MCP Client 启动参数,当前实现的是 stdio 模式,也就是通过 command + args 启动本地 MCP Server\n2. 例如可以填 npx / uvx / python 等命令,再配合对应的 MCP server 包参数\n3. 保存后会自动重新加载 MCP 工具,agent 聊天时会把这些工具一起带给模型\n4. 建议把 cwd 配到具体项目目录,避免 server 在错误目录里运行\n")},title:"信息"})]}),titleCom:(0,_.jsxs)("div",{children:[(0,_.jsx)(a.rA,{icon:"add",title:e("添加"),onClick:()=>je("stdio")}),(0,_.jsx)(a.rA,{icon:"save",title:e("保存"),onClick:()=>{be()}})]}),children:(0,_.jsx)(d.X,{headers:oe,onRowDrag:(e,t)=>{T((0,A.TI)(D,D.indexOf(ne[e]),D.indexOf(ne[t]))),F.current=!0},rows:ne.map((t,n)=>{const s=D.indexOf(t);return[(0,_.jsx)("div",{children:n}),(0,_.jsx)(p.Sm,{value:t.name,handleInputChange:e=>{t.name=e,F.current=!0},no_border:!0}),(0,_.jsx)(p.l6,{value:t.open,onChange:e=>{t.open=e,T([...D]),F.current=!0},options:ge,no_border:!0}),Ie(D.indexOf(t)),(0,_.jsx)(p.Sm,{value:t.command,handleInputChange:e=>{t.command=e,F.current=!0},no_border:!0}),(0,_.jsx)(p.Sm,{value:t.args,handleInputChange:e=>{t.args=e,F.current=!0},no_border:!0}),(0,_.jsx)(p.Sm,{value:t.cwd,handleInputChange:e=>{t.cwd=e,F.current=!0},no_border:!0}),(0,_.jsxs)("div",{children:[(0,_.jsx)(a.rA,{icon:"visibility",title:"查看工具",onClick:()=>{Se(t,s)}}),(0,_.jsx)(a.rA,{icon:"settings",title:"env",onClick:()=>{j.xK.set_value_temp(t.env??""),_e({model:"ace/mode/ini",open:!0,fileName:"",save:async e=>{t.env=e,T([...D]),j.xK.set_value_temp(""),F.current=!0,be()}})}})]}),(0,_.jsx)(p.Sm,{value:t.note,handleInputChange:e=>{t.note=e,F.current=!0},no_border:!0}),(0,_.jsxs)("div",{children:[(0,_.jsx)(a.rA,{icon:"delete",title:e("删除"),onClick:()=>fe(t)}),(0,_.jsx)(a.rA,{icon:"copy_all",title:e("复制"),onClick:()=>ye(t)})]})]}),width:"10rem"})})})}),(0,_.jsx)(c.fI,{children:(0,_.jsxs)(c.VP,{widthPer:70,children:[(0,_.jsx)(m.uF,{self_title:(0,_.jsxs)("span",{className:" div-row ",children:[(0,_.jsxs)("h2",{children:[e("MCP")+" "+e("设置")," - HTTP"]})," "]}),titleCom:(0,_.jsxs)("div",{children:[(0,_.jsx)(a.rA,{icon:"add",title:e("添加"),onClick:()=>je("http")}),(0,_.jsx)(a.rA,{icon:"save",title:e("保存"),onClick:()=>{be()}})]}),children:(0,_.jsx)(d.X,{headers:ae,onRowDrag:(e,t)=>{T((0,A.TI)(D,D.indexOf(se[e]),D.indexOf(se[t]))),F.current=!0},rows:se.map((t,n)=>{const s=D.indexOf(t);return[(0,_.jsx)("div",{children:n}),(0,_.jsx)(p.Sm,{value:t.name,handleInputChange:e=>{t.name=e,F.current=!0},no_border:!0}),(0,_.jsx)(p.l6,{value:t.open,onChange:e=>{t.open=e,T([...D]),F.current=!0},options:ge,no_border:!0}),Ie(D.indexOf(t)),(0,_.jsx)(p.Sm,{value:t.endpoint,handleInputChange:e=>{t.endpoint=e,F.current=!0},no_border:!0}),(0,_.jsxs)("div",{children:[(0,_.jsx)(a.rA,{icon:"visibility",title:"查看工具",onClick:()=>{Se(t,s)}}),(0,_.jsx)(a.rA,{icon:"settings",title:"headers",onClick:()=>{j.xK.set_value_temp(t.headers??""),_e({model:"ace/mode/ini",open:!0,fileName:"",save:async e=>{t.headers=e,T([...D]),j.xK.set_value_temp(""),F.current=!0,be()}})}})]}),(0,_.jsx)(p.Sm,{value:t.note,handleInputChange:e=>{t.note=e,F.current=!0},no_border:!0}),(0,_.jsxs)("div",{children:[(0,_.jsx)(a.rA,{icon:"delete",title:e("删除"),onClick:()=>fe(t)}),(0,_.jsx)(a.rA,{icon:"copy_all",title:e("复制"),onClick:()=>ye(t)})]})]}),width:"10rem"})}),(0,_.jsx)(m.uF,{self_title:(0,_.jsxs)("span",{className:" div-row ",children:[(0,_.jsx)("h2",{children:e("系统会话提示词")})," ",(0,_.jsx)(a.rA,{icon:"info",onClick:()=>{pe('\n1. 系统会话提示词,在 AI 聊天页创建会话时可以选择,选中的提示词会自动填入聊天框作为第一条系统消息\n2. 适用于预先设定常用的会话场景模板,如"代码审查"、"翻译助手"、"运维诊断"等\n3. "LLM编辑开关":开启后,当用户选择了该系统提示词发起对话时,AI 将会获得一个"更新会话提示词"工具,允许 AI 在对话中对当前会话进行总结,并写入到本提示词的"LLM编辑提示词"字段(全局保存,供之后的新会话沿用),使 AI 能自我维护长期上下文。\n4. "LLM编辑提示词":可选。AI 编辑后写回的内容(可预填初始方向)。仅在"LLM编辑开关"开启时生效。\n5. "编辑规则":可选。给 LLM 的编辑要求,例如"总结时不要超过 300 token"、"用简洁的项目要点记录"等。仅在"LLM编辑开关"开启时生效。\n')},title:"信息"})]}),titleCom:(0,_.jsxs)("div",{children:[(0,_.jsx)(a.rA,{icon:"add",title:e("添加"),onClick:()=>{le([...re,{prompt:"",note:"",llm_prompt_enable:!1}])}}),(0,_.jsx)(a.rA,{icon:"save",title:e("保存"),onClick:()=>{Ne()}})]}),children:(0,_.jsx)(d.X,{headers:ie,onRowDrag:(e,t)=>{le((0,A.TI)(re,e,t))},rows:re.map((t,n)=>{const s=[(0,_.jsx)("div",{children:n}),(0,_.jsx)("div",{children:(0,_.jsx)(a.rA,{icon:"short_text",title:e("提示词"),onClick:()=>{j.xK.set_value_temp(t.prompt??""),_e({model:"ace/mode/text",open:!0,fileName:"",save:async e=>{t.prompt=e,le([...re]),j.xK.set_value_temp(""),Ne()}})}})}),(0,_.jsx)(a.Ay,{checked:!!t.llm_prompt_enable,onChange:e=>{t.llm_prompt_enable=e,le([...re])},title:e("LLM编辑开关")}),(0,_.jsx)("div",{children:(0,_.jsx)(a.rA,{icon:"edit_note",title:e("llm_pmt"),onClick:()=>{j.xK.set_value_temp(t.llm_prompt??""),_e({model:"ace/mode/text",open:!0,fileName:"",save:async e=>{t.llm_prompt=e,le([...re]),j.xK.set_value_temp(""),Ne()}})}})}),(0,_.jsx)("div",{children:(0,_.jsx)(a.rA,{icon:"rule",title:e("编辑规则"),onClick:()=>{j.xK.set_value_temp(t.llm_prompt_tip??""),_e({model:"ace/mode/text",open:!0,fileName:"",save:async e=>{t.llm_prompt_tip=e,le([...re]),j.xK.set_value_temp(""),Ne()}})}})}),(0,_.jsx)(p.Sm,{value:t.note,handleInputChange:e=>{t.note=e},no_border:!0}),(0,_.jsx)("div",{children:(0,_.jsx)(a.rA,{icon:"delete",title:e("删除"),onClick:()=>(e=>{re.splice(e,1),le([...re])})(n)})})];return s}),width:"10rem"})}),(0,_.jsx)(m.uF,{self_title:(0,_.jsxs)("span",{className:" div-row ",children:[(0,_.jsx)("h2",{children:e("长期记忆")})," ",(0,_.jsx)(a.rA,{icon:"info",onClick:()=>{pe(e("开启后跨会话保存记忆。四个固定文件:周/月/年/永久。每周结束自动压缩周→月,每月结束自动压缩月→年,每年结束自动压缩年→永久。编辑按钮可手动查看和修改。"))},title:"信息"})]}),titleCom:(0,_.jsx)("div",{children:(0,_.jsx)(a.Ay,{checked:ce,onChange:async t=>{de(t),await h.XO.post("ai_long_term_memory_setting/save",{open:t}),(0,g.SK)(e("长期记忆设置已保存"))},title:e("开关")})}),children:(0,_.jsx)("div",{style:{display:"flex",gap:"0.5rem",padding:"0.5rem 0",flexWrap:"wrap"},children:[{type:"week",label:e("周记忆"),tip:e("上限3000字")},{type:"month",label:e("月记忆"),tip:e("上限6000字")},{type:"year",label:e("年记忆"),tip:e("上限9000字")},{type:"forever",label:e("永久记忆"),tip:e("上限12000字")}].map(({type:t,label:n,tip:s})=>(0,_.jsx)(a.rA,{icon:"edit",title:`${e("编辑")} ${n} (${s})`,onClick:async()=>{const s=await h.XO.get(`ai_long_term_memory_bucket/${t}`),o=s.code===x.m.Success?s.data??"":"";j.xK.set_value_temp(o),_e({model:"ace/mode/text",open:!0,fileName:`long_term_memory_${t}.txt`,save:async s=>{await h.XO.post(`ai_long_term_memory_bucket/${t}/save`,{data:s}),j.xK.set_value_temp(""),(0,g.SK)(`${n} ${e("已保存")}`)}})}},t))})})]})}),(0,_.jsxs)(c.fI,{children:[(0,_.jsx)(c.VP,{widthPer:50,children:(0,_.jsx)(m.uF,{self_title:(0,_.jsxs)("span",{className:" div-row ",children:[(0,_.jsx)("h2",{children:e("本地知识库")})," ",(0,_.jsx)(a.rA,{icon:"info",onClick:()=>{pe("\n1. 本地知识库用于为AI增强理解能力,或者分析本地文件,原理读取本地的文件,对文件在内存中建立全文索引,为AI提供额外数据(需要有模型开启才能使用)\n2. 该功能只能用于小型知识库,作为本地小型或者公司内部资料使用还是没有问题的\n3. 每次保存都会重新加载知识库中的文件,不会全部重新加载,而是检测哪些文件有变更\n")},title:"信息"})]}),titleCom:(0,_.jsxs)("div",{children:[(0,_.jsx)(a.Ay,{checked:ee,onChange:async e=>{await h.jV.post("docs_on_set",{status:e}),ve(),t()},title:e("知识库开关")}),(0,_.jsx)(a.rA,{icon:"settings",title:"额外参数设置",onClick:()=>{j.xK.set_value_temp(q.current),_e({model:"ace/mode/ini",open:!0,fileName:"",save:async e=>{q.current=e,j.xK.set_value_temp(""),Ke(q.current)}})}}),(0,_.jsx)(a.rA,{icon:"add",title:e("添加"),onClick:()=>{X([...P,{note:"",auto_load:!1,dir:""}]),V.current=!0}}),(0,_.jsx)(a.rA,{icon:"save",title:e("保存"),onClick:()=>{Ke()}})]}),children:(0,_.jsx)(d.X,{headers:N,onRowDrag:(e,t)=>{X((0,A.TI)(P,e,t)),V.current=!0},rows:P.map((t,n)=>{const s=[(0,_.jsx)("div",{children:n}),(0,_.jsx)(p.Sm,{value:t.dir,handleInputChange:e=>{t.dir=e,V.current=!0},no_border:!0}),(0,_.jsx)(p.l6,{value:t.auto_load,onChange:e=>{t.auto_load=e,X([...P]),V.current=!0},options:ge,no_border:!0}),(0,_.jsx)(p.Sm,{value:t.note,handleInputChange:e=>{t.note=e},no_border:!0}),(0,_.jsxs)("div",{children:[(0,_.jsx)(a.rA,{icon:"delete",title:e("删除记录"),onClick:()=>(e=>{P.splice(e,1),X([...P]),V.current=!0})(n)}),(0,_.jsx)(a.rA,{icon:"restore",title:e("手动加载"),onClick:()=>{xe({sub_title:"手动加载",confirm_fun:()=>{h.jV.post("docs_load_file",{param_path:t.dir}),(0,g.SK)("ok")}})}}),(0,_.jsx)(a.rA,{icon:"delete_forever",title:e("从索引删除"),onClick:()=>{xe({sub_title:"从索引删除",confirm_fun:()=>{h.jV.post("docs_del",{param_path:t.dir}),(0,g.SK)("ok")}})}})]})];return s}),width:"10rem"})})}),H&&(0,_.jsx)(c.VP,{widthPer:50,children:(0,_.jsxs)(m.Zp,{title:e("知识库加载信息"),children:[(0,_.jsx)(c.Yh,{left:e("最近一次加载")+","+e("加载进度"),right:H?.progress}),(0,_.jsx)(c.Yh,{left:`${e("最近一次加载")},${e("总文件数量")}`,right:H?.num}),(0,_.jsx)(c.Yh,{left:`${e("最近一次加载")},${e("总文件字符数量")}`,right:H?.char_num}),(0,_.jsx)(c.Yh,{left:`${e("最近一次加载")},${e("总文件大小")}`,right:(0,b.v7)(H?.size)}),(0,_.jsx)(c.Yh,{left:`${e("最近一次加载")},${e("总耗时")}`,right:(0,b.a3)(H?.consume_time_ms_len)}),(0,_.jsx)(c.Yh,{left:`${e("总文件数量")}`,right:H?.total_num})]})})]})]})})})]})}},34299(e,t,n){n.r(t),n.d(t,{default:()=>C});var s=n(96540),o=n(23802),a=n(53995),i=n(18569),r=n(77979),l=n(8263),c=n(69428),d=n.n(c),p=(n(3775),n(21499)),m=n(99214),u=n(89117),_=n(86063),h=n(89334),x=n(41105),g=n(52388),v=n(19878),j=(n(72411),n(74848));const f=new o.A({html:!0,highlight:function(e,t){if(t&&v.A.getLanguage(t))try{return`<pre class="hljs code-block-with-copy"><code class="hljs language-${t}">${v.A.highlight(e,{language:t}).value}</code></pre>`}catch(e){}try{return`<pre class="hljs code-block-with-copy"><code class="hljs">${v.A.highlightAuto(e).value}</code></pre>`}catch(e){}return`<pre class="hljs code-block-with-copy"><code>${f.utils.escapeHtml(e)}</code></pre>`}});async function y(e,t){e.className="md-graph md-graph--mind md-graph--loading",e.textContent=g.A.t("rendering");const n=await(0,_.Hn)(t);e.isConnected&&(e.className="md-graph md-graph--mind",e.textContent="",await n.mount(e))}function w(e){const t=e.className.match(/language-([\w-]+)/);return t?t[1]:""}function C(e){const t=(0,s.useRef)(null);return(0,m.VD)(),(0,s.useEffect)(()=>{t.current&&(t.current.innerHTML=f.render(e.context??""),async function(e){const t=e.querySelectorAll("pre > code[class*='language-']");for(const e of Array.from(t)){const t=w(e),n=(0,u.Hm)(t),s=(0,_.hj)(t);if(!n&&!s)continue;const o=e.closest(".code-block-with-copy")??e.parentElement;if(!o)continue;const a=e.textContent??"",i=document.createElement("div");if(o.replaceWith(i),s){try{await y(i,a)}catch(e){console.error("[mind] render failed",e),i.className="md-graph md-graph--mind",i.textContent=String(e)}continue}i.className="md-graph md-graph--loading",i.textContent=g.A.t("rendering");const r=await(0,u.U6)(t,a);i.isConnected&&(r.error?(i.className="md-graph md-graph--error",i.textContent=r.error):(i.className="md-graph",i.innerHTML=r.svg))}}(t.current),(0,h.rg)(t.current))},[e.context]),(0,j.jsx)("div",{ref:t})}f.use(a.A).use(i.A).use(r.A).use(l.A).use(d()).use(e=>{e.renderer.rules.fence;e.renderer.rules.fence=(t,n,s,o,a)=>{const i=t[n],r=i.content.trim(),l=i.info.trim();let c="";if(l&&v.A.getLanguage(l))try{c=v.A.highlight(r,{language:l}).value}catch(t){c=e.utils.escapeHtml(r)}else try{c=v.A.highlightAuto(r).value}catch(t){c=e.utils.escapeHtml(r)}return`\n <div class="code-block-with-copy">\n <div class="code-header">\n <span class="code-language">${l||"code"}</span>\n <button class="copy-btn" data-code="${e.utils.escapeHtml(r)}">复制</button>\n </div>\n <pre><code class="hljs ${l?`language-${l}`:""}">${c}</code></pre>\n </div>`}}).use(e=>{const t=e.renderer.rules.link_open||function(e,t,n,s,o){return o.renderToken(e,t,n)};e.renderer.rules.link_open=(e,n,s,o,a)=>{const i=e[n],r=i.attrIndex("href");if(r>=0){const e=i.attrs[r][1];i.attrs[r][1]=(0,p.bi)(window.location.href,e)}return t(e,n,s,o,a)}}),(0,h.Rh)(f,x.pC)},24659(e,t,n){var s=n(22022);n.d(t,["K",0,()=>{const{t:e}=(0,s.Bd)();return[{title:e("是"),value:!0,color:"#28a745"},{title:e("否"),value:!1,color:"#666666"}]}])},60840(e){e.exports="data:image/svg+xml,<svg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 16 16%27 version=%271.1%27 aria-hidden=%27true%27><path fill-rule=%27evenodd%27 d=%27M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z%27></path></svg>"}}]);
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[892],{20892(e,t,n){n.r(t),n.d(t,{default:()=>m});var s=n(96540),i=n(57889),l=n(62042),a=n(22022),r=n(93392),c=n(74848);const o=36,d=4.8;function u(e){return`timeline-node--${e}`}function m(e){const{t}=(0,a.Bd)(),[n,d]=(0,s.useState)(()=>(0,r.bw)()),[u,m]=(0,s.useState)(!0),[p,_]=(0,s.useState)(""),[v,x]=(0,s.useState)(1),[b,g]=(0,s.useState)({}),f=(0,s.useCallback)((e,t)=>{g(n=>n[e]===t?n:{...n,[e]:t})},[]),[j,y]=(0,s.useState)({}),N=(0,s.useCallback)((e,t)=>{y(n=>n[e]===t?n:{...n,[e]:t})},[]),[w,k]=(0,s.useState)(!1),[C,E]=(0,s.useState)(null),[L,R]=(0,s.useState)("event"),$=(0,s.useRef)(null),T=(0,s.useRef)(null),S=(0,s.useRef)(!1),z=(0,s.useRef)({props:e});z.current={props:e};const P=(0,s.useRef)([]),U=(0,s.useRef)([]),[D,O]=(0,s.useState)(0),M=(0,s.useRef)(null),[B,Y]=(0,s.useState)(null),[I,X]=(0,s.useState)(null),F=(0,s.useRef)(n);F.current=n;const A=(0,s.useRef)(v);A.current=v;const K="vertical"===n.layout.direction,q=(0,s.useRef)(w);q.current=w;const G=e=>{e&&!q.current||S.current!==e&&(S.current=e,z.current.props.on_dirty?.(e))},J=(0,s.useCallback)(e=>{P.current[P.current.length-1]!==e&&(P.current.push(e),P.current.length>100&&P.current.shift()),U.current=[],O(e=>e+1)},[]),W=(0,s.useCallback)(e=>{q.current&&(J((0,r.vE)(F.current)),F.current=e,d(e),G(!0))},[J,G]),Z=e=>{q.current?W(e):(F.current=e,d(e))},H=(0,s.useCallback)(()=>{if(!q.current)return;const e=P.current.pop();null!=e&&(U.current.push((0,r.vE)(F.current)),d((0,r.Tz)(JSON.parse(e))),E(null),G(!0),O(e=>e+1))},[]),V=(0,s.useCallback)(()=>{if(!q.current)return;const e=U.current.pop();null!=e&&(P.current.push((0,r.vE)(F.current)),d((0,r.Tz)(JSON.parse(e))),E(null),G(!0),O(e=>e+1))},[]),Q=async()=>{if(!q.current)return!1;const e=await z.current.props.on_save((0,r.vE)(F.current));return e&&G(!1),e};(0,s.useEffect)(()=>{e.register?.({save:Q,is_dirty:()=>S.current,is_edit_mode:()=>w})},[e.register,w]),(0,s.useEffect)(()=>{z.current.props.on_edit_mode_change?.(w)},[w]),(0,s.useEffect)(()=>{if(e.doc)return d(e.doc),x(1),m(!1),void _("");if(!e.url)return;let n=!1;return m(!0),_(""),P.current=[],U.current=[],O(e=>e+1),E(null),G(!1),(async()=>{try{const t=await i.l.get(e.url);if(n)return;const s=(0,r.dO)(t)??(0,r.bw)();d(s),x((0,r.$4)(s.layout.zoom??1,.3,3,1)),window.setTimeout(()=>{const e=T.current;e&&(e.scrollLeft=(s.layout.scroll_x??0)*(s.layout.zoom??1),e.scrollTop=(s.layout.scroll_y??0)*(s.layout.zoom??1))},60)}catch{if(n)return;_(t("加载时间线失败")),(0,l.zN)(t("加载时间线失败"))}finally{n||m(!1)}})(),()=>{n=!0}},[e.url,e.doc]);const ee=e=>{return Math.max(o,(t=e.id,b[t]??o))+10;var t},te=e=>e.collapsed?ee(e):o+(e=>{const t="vertical"===n.layout.direction?96:240,s={left:0,right:0};return e.events.forEach((e,i)=>{const l=n.layout.alternate?i%2==0?"left":"right":e.side;s[l]+=(j[e.id]??t)+12}),Math.max(s.left,s.right)})(e),ne=(0,s.useMemo)(()=>{const e=[];let t=0;for(const s of n.phases)e.push(t),t+=s.collapsed?Math.max(o,b[s.id]??o)+10:te(s);return e},[n.phases,b,j]);(0,s.useEffect)(()=>{const e=e=>{const t=M.current,n=$.current;if(!t||!n)return;const s=n.getBoundingClientRect(),i=A.current,l=("vertical"===F.current.layout.direction?e.clientY-s.top:e.clientX-s.left)/i,a=F.current.phases;let r=a.length-1;for(let e=0;e<a.length;e++){if(l<=ne[e]+te(a[e])){r=e;break}}const c=r<=t.from?ne[r]:ne[r]+te(a[r]);X(c),r!==t.from&&(((e,t)=>{const n=[...F.current.phases];if(e<0||e>=n.length||t<0||t>=n.length||e===t)return;const[s]=n.splice(e,1);n.splice(t,0,s);const i={...F.current,phases:n};F.current=i,d(i)})(t.from,r),t.from=r)},t=()=>{const e=M.current;e&&(M.current=null,document.body.classList.remove("timeline-phase-dragging"),Y(null),X(null),null!=e.snapshot&&e.snapshot!==(0,r.vE)(F.current)&&(J(e.snapshot),G(!0)))};return document.addEventListener("pointermove",e),document.addEventListener("pointerup",t),document.addEventListener("pointercancel",t),()=>{document.removeEventListener("pointermove",e),document.removeEventListener("pointerup",t),document.removeEventListener("pointercancel",t)}},[ne,J]);const se=(e,t,s)=>{if(!q.current)return;if(0!==e.button)return;e.target.closest("input, textarea, button, select, [data-event-width], [data-event-link]")||(e.stopPropagation(),R("event"),E(n.phases[t].events[s].id))},ie=(e,t)=>{if(!q.current)return;const n=F.current.phases[t];if(!n)return;const s="vertical"===F.current.layout.direction,i=A.current;let l=n.head_width??0;if(!l){const t=e.currentTarget.closest(".timeline-phase__head");t&&(l=t.getBoundingClientRect().width/i)}const a=s?e.clientX:e.clientY,c=n.id,o=(0,r.vE)(F.current),u=e=>{let t=((s?e.clientX:e.clientY)-a)/i;s&&(t=-t);const n=Math.round((0,r.$4)(l+t,80,1200,l)),o={...F.current,phases:F.current.phases.map(e=>e.id===c?{...e,head_width:n}:e)};F.current=o,d(o)},m=()=>{document.removeEventListener("pointermove",u),document.removeEventListener("pointerup",m),o!==(0,r.vE)(F.current)&&(J(o),G(!0))};document.addEventListener("pointermove",u),document.addEventListener("pointerup",m)},le=(e,t,n,s)=>{if(!q.current)return;const i=F.current.phases[t]?.events[n];if(!i)return;const l="vertical"===F.current.layout.direction,a=A.current;let c=i.width??0;if(!c){const t=e.currentTarget.closest(".timeline-event");t&&(c=t.getBoundingClientRect().width/a)}const o=l?e.clientX:e.clientY,u=i.id,m=(0,r.vE)(F.current),h=e=>{let t=((l?e.clientX:e.clientY)-o)/a;"left"===s&&(t=-t);const n=Math.round((0,r.$4)(c+t,80,1200,c)),i={...F.current,phases:F.current.phases.map(e=>({...e,events:e.events.map(e=>e.id===u?{...e,width:n}:e)}))};F.current=i,d(i)},p=()=>{document.removeEventListener("pointermove",h),document.removeEventListener("pointerup",p),m!==(0,r.vE)(F.current)&&(J(m),G(!0))};document.addEventListener("pointermove",h),document.addEventListener("pointerup",p)},ae=(e,t,n,s)=>{if(!q.current)return;const i=F.current.phases[t]?.events[n];if(!i)return;const l="vertical"===F.current.layout.direction,a=A.current,c=i.link_length??42,o=l?e.clientX:e.clientY,u=i.id,m=(0,r.vE)(F.current),h=e=>{let t=((l?e.clientX:e.clientY)-o)/a;"left"===s&&(t=-t);const n=(0,r.$4)(c+t,8,800,c),i={...F.current,phases:F.current.phases.map(e=>({...e,events:e.events.map(e=>e.id===u?{...e,link_length:n}:e)}))};F.current=i,d(i)},p=()=>{document.removeEventListener("pointermove",h),document.removeEventListener("pointerup",p),m!==(0,r.vE)(F.current)&&(J(m),G(!0))};document.addEventListener("pointermove",h),document.addEventListener("pointerup",p)};(0,s.useEffect)(()=>{const e=T.current;if(!e)return;const t=e=>{if(!e.ctrlKey&&!e.metaKey)return;e.preventDefault();const t=e.deltaY>0?-.1:.1;x(e=>(0,r.$4)(Number((e+t).toFixed(2)),.3,3,1))};return e.addEventListener("wheel",t,{passive:!1}),()=>e.removeEventListener("wheel",t)},[]);const re=e=>{W({...F.current,layout:{...F.current.layout,...e}})},ce=e=>{const t=(0,r.$4)(Number(e.toFixed(2)),.3,3,1);x(t),q.current&&re({zoom:t})},oe=(e,t)=>{W({...F.current,phases:F.current.phases.map(n=>({...n,events:n.events.map(n=>n.id===e?{...n,...t}:n)}))})},de=(e,t)=>{Z({...F.current,phases:F.current.phases.map(n=>n.id===e?{...n,...t}:n)})},ue=(e,t)=>{const n=F.current.phases,s=n.findIndex(t=>t.id===e);if(s<0)return;const i="before"===t?s:s+1,l=[...n];l.splice(i,0,(0,r.vT)(i)),Z({...F.current,phases:l})},me=(e,t)=>{const n=[...F.current.phases],s=n.findIndex(t=>t.id===e),i=s+t;s<0||i<0||i>=n.length||([n[s],n[i]]=[n[i],n[s]],W({...F.current,phases:n}))},he=(e,t)=>{W({...F.current,phases:F.current.phases.map(n=>{const s=n.events.findIndex(t=>t.id===e),i=s+t;if(s<0||i<0||i>=n.events.length)return n;const l=[...n.events];return[l[s],l[i]]=[l[i],l[s]],{...n,events:l}})})},pe=e=>{q.current&&(M.current={from:e,snapshot:(0,r.vE)(F.current)},Y(F.current.phases[e]?.id??null),document.body.classList.add("timeline-phase-dragging"))},_e=e=>{const t=F.current.phases.find(t=>t.id===e);if(!t)return;const n=t.events.filter(e=>"left"===e.side).length,s=n<=t.events.length-n?"left":"right",i=(0,r.IG)(s,.5),l=F.current.phases.map(t=>t.id===e?{...t,events:[...t.events,i]}:t);W({...F.current,phases:l}),R("event"),E(i.id)},ve=e=>{W({...F.current,phases:F.current.phases.map(t=>({...t,events:t.events.filter(t=>t.id!==e)}))}),E(t=>t===e?null:t)},xe=e=>{R("phase"),E(e)},be=e=>{W({...F.current,phases:F.current.phases.filter(t=>t.id!==e)}),E(t=>t===e?null:t)},ge=()=>{const e=z.current.props.url??"";let t=e;const n=e.indexOf("?");if(n>=0){t=new URLSearchParams(e.slice(n+1)).get("file")||""}t||(t=e.split("?")[0]);let s=t.split("/").filter(Boolean).pop()??"";for(let e=0;e<2;e++)try{const e=decodeURIComponent(s);if(e===s)break;s=e}catch{break}return s.replace(/\.timeline$/,"")||"timeline"};(0,s.useEffect)(()=>{const e=$.current,t=T.current;if(!e||!t||"vertical"!==n.layout.direction)return;e.style.setProperty("--side-scroll","0px");const s=t.clientWidth/2,i=t.getBoundingClientRect().left+s;let l=0;e.querySelectorAll(".timeline-event").forEach(e=>{const t=e.getBoundingClientRect();l=Math.max(l,i-t.left,t.right-i)}),e.style.setProperty("--side-scroll",`${Math.max(120,Math.ceil(l)+40)}px`)},[n.phases,n.layout.direction,n.layout.card_style,n.layout.node_style,v]);const fe=(0,s.useRef)(0);(0,s.useEffect)(()=>{const e=e=>{const t=e.target;if(t&&("INPUT"===t.tagName||"TEXTAREA"===t.tagName||t.isContentEditable))return;const n=e.ctrlKey||e.metaKey;return!n||"s"!==e.key&&"S"!==e.key?!n||"z"!==e.key&&"Z"!==e.key?!n||"y"!==e.key&&"Y"!==e.key?void(("Delete"===e.key||"Backspace"===e.key)&&C&&"event"===L&&q.current&&(e.preventDefault(),ve(C))):(e.preventDefault(),e.stopPropagation(),void V()):(e.preventDefault(),e.stopPropagation(),void(e.shiftKey?V():H())):(e.preventDefault(),e.stopPropagation(),void Q())};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[C,L]);const je="event"===L&&C?(e=>{for(const t of n.phases){const n=t.events.find(t=>t.id===e);if(n)return{event:n,phase:t}}return null})(C):null,ye="phase"===L&&C?n.phases.find(e=>e.id===C)??null:null,Ne=n.layout,we=n.phases.length>0&&n.phases.every(e=>e.collapsed);return(0,c.jsxs)("div",{className:`timeline-wrap${e.fullscreen?" timeline-wrap--full":""}${e.readonly?" timeline-wrap--readonly":""}`,children:[e.header,!e.readonly&&(0,c.jsxs)("div",{className:"timeline-toolbar",children:[(0,c.jsx)("button",{type:"button",className:"timeline-btn"+(w?" timeline-btn--on":""),title:t(w?"退出编辑模式":"进入编辑模式"),onClick:()=>k(e=>!e),children:(0,c.jsx)("span",{className:"material-icons",children:w?"edit":"visibility"})}),(0,c.jsx)("button",{type:"button",className:"timeline-btn",title:t(we?"展开全部阶段":"折叠全部阶段"),onClick:()=>{const e=F.current.phases.some(e=>!e.collapsed);Z({...F.current,phases:F.current.phases.map(t=>({...t,collapsed:e}))})},children:(0,c.jsx)("span",{className:"material-icons",children:we?"unfold_more":"unfold_less"})}),(0,c.jsx)("button",{type:"button",className:"timeline-btn",title:t("阶段倒置"),onClick:()=>{const e=[...F.current.phases].reverse();Z({...F.current,phases:e})},children:(0,c.jsx)("span",{className:"material-icons",children:"swap_vert"})}),w&&(0,c.jsx)(c.Fragment,{children:(0,c.jsx)("button",{type:"button",className:"timeline-btn",title:t("添加阶段"),onClick:()=>{const e=F.current.phases.length;W({...F.current,phases:[...F.current.phases,(0,r.vT)(e)]})},children:(0,c.jsx)("span",{className:"material-icons",children:"add_box"})})}),(0,c.jsx)("button",{type:"button",className:"timeline-btn",title:t("导出 SVG"),onClick:()=>{const e=(0,r.Ao)(F.current),t=new Blob([e],{type:"image/svg+xml;charset=utf-8"}),n=URL.createObjectURL(t),s=document.createElement("a");s.href=n,s.download=ge()+".svg",document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(n)},children:(0,c.jsx)("span",{className:"material-icons",children:"download"})}),(0,c.jsx)("button",{type:"button",className:"timeline-btn",title:t("导出图片"),onClick:()=>{const e=(0,r.Ao)(F.current),n=new Blob([e],{type:"image/svg+xml;charset=utf-8"}),s=URL.createObjectURL(n),i=new Image;i.onload=()=>{const e=document.createElement("canvas");e.width=2*i.width||1200,e.height=2*i.height||800;const t=e.getContext("2d");t&&(t.fillStyle="#ffffff",t.fillRect(0,0,e.width,e.height),t.drawImage(i,0,0,e.width,e.height),e.toBlob(e=>{if(!e)return;const t=URL.createObjectURL(e),n=document.createElement("a");n.href=t,n.download=ge()+".png",document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(t)},"image/png")),URL.revokeObjectURL(s)},i.onerror=()=>{(0,l.zN)(t("导出图片失败")),URL.revokeObjectURL(s)},i.src=s},children:(0,c.jsx)("span",{className:"material-icons",children:"image"})}),w&&(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)("span",{className:"timeline-toolbar__divider"}),(0,c.jsxs)("div",{className:"timeline-seg",children:[(0,c.jsx)("button",{type:"button",className:"timeline-seg__btn"+(K?" timeline-seg__btn--on":""),title:t("纵向"),onClick:()=>{K||re({direction:"vertical"})},children:(0,c.jsx)("span",{className:"material-icons",children:"swap_vert"})}),(0,c.jsx)("button",{type:"button",className:"timeline-seg__btn"+(K?"":" timeline-seg__btn--on"),title:t("横向"),onClick:()=>{K&&re({direction:"horizontal"})},children:(0,c.jsx)("span",{className:"material-icons",children:"swap_horiz"})})]}),(0,c.jsxs)("label",{className:"timeline-toolbar__select",title:t("节点样式"),children:[(0,c.jsx)("span",{className:"material-icons",children:"radio_button_checked"}),(0,c.jsxs)("select",{value:Ne.node_style,onChange:e=>re({node_style:e.target.value}),children:[(0,c.jsx)("option",{value:"dot",children:t("圆点")}),(0,c.jsx)("option",{value:"circle",children:t("圆形")}),(0,c.jsx)("option",{value:"square",children:t("方形")}),(0,c.jsx)("option",{value:"image",children:t("图片")})]})]}),(0,c.jsxs)("label",{className:"timeline-toolbar__select",title:t("卡片样式"),children:[(0,c.jsx)("span",{className:"material-icons",children:"crop_square"}),(0,c.jsxs)("select",{value:Ne.card_style,onChange:e=>re({card_style:e.target.value}),children:[(0,c.jsx)("option",{value:"card",children:t("卡片")}),(0,c.jsx)("option",{value:"plain",children:t("朴素")}),(0,c.jsx)("option",{value:"bubble",children:t("气泡")})]})]}),(0,c.jsxs)("label",{className:"timeline-toolbar__select",title:t("连线风格"),children:[(0,c.jsx)("span",{className:"material-icons",children:"linear_scale"}),(0,c.jsxs)("select",{value:Ne.line_style,onChange:e=>re({line_style:e.target.value}),children:[(0,c.jsx)("option",{value:"solid",children:t("实线")}),(0,c.jsx)("option",{value:"dashed",children:t("虚线")}),(0,c.jsx)("option",{value:"dotted",children:t("点线")})]})]}),(0,c.jsx)("button",{type:"button",className:"timeline-btn"+(Ne.show_connector?" timeline-btn--on":""),title:t("显示连线"),onClick:()=>re({show_connector:!Ne.show_connector}),children:(0,c.jsx)("span",{className:"material-icons",children:"timeline"})})]}),(0,c.jsx)("span",{className:"timeline-toolbar__gap"}),(0,c.jsx)("button",{type:"button",className:"timeline-btn",title:t("撤销")+" (Ctrl+Z)","data-tick":D,disabled:0===P.current.length,onClick:H,children:(0,c.jsx)("span",{className:"material-icons",children:"undo"})}),(0,c.jsx)("button",{type:"button",className:"timeline-btn",title:t("重做")+" (Ctrl+Y)",disabled:0===U.current.length,onClick:V,children:(0,c.jsx)("span",{className:"material-icons",children:"redo"})}),(0,c.jsxs)("span",{className:"timeline-toolbar__zoom",children:[Math.round(100*v),"%"]}),(0,c.jsx)("button",{type:"button",className:"timeline-btn",title:t("缩小"),onClick:()=>ce(v-.1),children:(0,c.jsx)("span",{className:"material-icons",children:"remove"})}),(0,c.jsx)("button",{type:"button",className:"timeline-btn",title:t("放大"),onClick:()=>ce(v+.1),children:(0,c.jsx)("span",{className:"material-icons",children:"add"})}),(0,c.jsx)("button",{type:"button",className:"timeline-btn",title:t("重置缩放"),onClick:()=>ce(1),children:(0,c.jsx)("span",{className:"material-icons",children:"restart_alt"})})]}),(0,c.jsxs)("div",{className:"timeline-body",children:[(0,c.jsx)("div",{className:`timeline-canvas timeline-canvas--${Ne.direction}`,ref:T,onScroll:()=>{q.current&&(window.clearTimeout(fe.current),fe.current=window.setTimeout(()=>{const e=T.current;if(!e)return;const t=Math.round(e.scrollLeft/A.current),n=Math.round(e.scrollTop/A.current),s=F.current.layout;if(s.scroll_x===t&&s.scroll_y===n)return;const i={...F.current,layout:{...s,scroll_x:t,scroll_y:n}};F.current=i,d(i),G(!0)},250))},children:(0,c.jsxs)("div",{className:"timeline-inner",ref:$,style:{"--zoom":v},children:[null!==I&&(0,c.jsx)("div",{className:"timeline-drop",style:K?{top:`${I}px`}:{left:`${I}px`}}),n.phases.map((e,n)=>(0,c.jsx)(h,{phase:e,phase_index:n,layout:Ne,zoom:v,vertical:K,selected_id:C,on_event_down:se,on_width_down:le,on_link_down:ae,on_add_event:_e,on_delete_event:ve,on_update_phase:de,on_delete_phase:be,on_select_phase:xe,head_height:b[e.id],on_head_height:f,on_phase_width_down:ie,event_heights:j,on_event_height:N,edit_mode:w,on_phase_drag_start:pe,drag_phase_id:B,t},e.id))]})}),w&&!e.readonly&&ye&&(0,c.jsxs)("div",{className:"timeline-panel",children:[(0,c.jsxs)("div",{className:"timeline-panel__title",children:[(0,c.jsx)("span",{className:"material-icons",children:"layers"}),(0,c.jsx)("span",{children:t("阶段")}),(0,c.jsx)("span",{className:"material-icons timeline-panel__close",title:t("关闭"),onClick:()=>E(null),children:"close"})]}),(0,c.jsx)("label",{className:"timeline-panel__label",children:t("名称")}),(0,c.jsx)("textarea",{className:"timeline-panel__textarea",readOnly:!w,value:ye.name,onChange:e=>de(ye.id,{name:e.target.value})}),(0,c.jsx)("label",{className:"timeline-panel__label",children:t("描述")}),(0,c.jsx)("textarea",{className:"timeline-panel__textarea",readOnly:!w,value:ye.desc??"",onChange:e=>de(ye.id,{desc:e.target.value})}),(0,c.jsx)("label",{className:"timeline-panel__label",children:t("颜色")}),(0,c.jsxs)("div",{className:"timeline-panel__colors",children:[r.Tw.map(e=>(0,c.jsx)("span",{className:"timeline-swatch",style:{background:e},onClick:()=>de(ye.id,{color:e})},e)),(0,c.jsx)("label",{className:"timeline-swatch timeline-swatch--pick",title:t("自定义颜色"),children:(0,c.jsx)("input",{type:"color",value:ye.color||Ne.axis_color,onChange:e=>de(ye.id,{color:e.target.value})})})]}),(0,c.jsx)("label",{className:"timeline-panel__label",children:t("阶段头")}),(0,c.jsxs)("div",{className:"timeline-panel__seg",children:[(0,c.jsx)("button",{type:"button",className:"timeline-seg__btn"+(!1!==ye.head_visible?" timeline-seg__btn--on":""),onClick:()=>de(ye.id,{head_visible:!0}),children:t("显示")}),(0,c.jsx)("button",{type:"button",className:"timeline-seg__btn"+(!1===ye.head_visible?" timeline-seg__btn--on":""),onClick:()=>de(ye.id,{head_visible:!1}),children:t("隐藏")})]}),(0,c.jsx)("div",{className:"timeline-panel__hint",children:t("拖动阶段头可调整顺序")}),(0,c.jsxs)("div",{className:"timeline-panel__insert",children:[(0,c.jsxs)("button",{type:"button",className:"timeline-panel__add",onClick:()=>ue(ye.id,"before"),children:[(0,c.jsx)("span",{className:"material-icons",children:"vertical_align_top"}),t("在阶段前插入")]}),(0,c.jsxs)("button",{type:"button",className:"timeline-panel__add",onClick:()=>ue(ye.id,"after"),children:[(0,c.jsx)("span",{className:"material-icons",children:"vertical_align_bottom"}),t("在阶段后插入")]})]}),(0,c.jsxs)("button",{type:"button",className:"timeline-panel__add",onClick:()=>_e(ye.id),children:[(0,c.jsx)("span",{className:"material-icons",children:"add_circle"}),t("添加事件")]}),(0,c.jsxs)("div",{className:"timeline-panel__insert",children:[(0,c.jsxs)("button",{type:"button",className:"timeline-panel__add",onClick:()=>me(ye.id,-1),children:[(0,c.jsx)("span",{className:"material-icons",children:"arrow_upward"}),t("上移")]}),(0,c.jsxs)("button",{type:"button",className:"timeline-panel__add",onClick:()=>me(ye.id,1),children:[(0,c.jsx)("span",{className:"material-icons",children:"arrow_downward"}),t("下移")]})]}),(0,c.jsxs)("button",{type:"button",className:"timeline-panel__del",onClick:()=>be(ye.id),children:[(0,c.jsx)("span",{className:"material-icons",children:"delete"}),t("删除阶段")]})]}),w&&!e.readonly&&je&&(0,c.jsxs)("div",{className:"timeline-panel",children:[(0,c.jsxs)("div",{className:"timeline-panel__title",children:[(0,c.jsx)("span",{className:"material-icons",children:"edit"}),(0,c.jsx)("span",{children:t("事件")}),(0,c.jsx)("span",{className:"material-icons timeline-panel__close",title:t("关闭"),onClick:()=>E(null),children:"close"})]}),(0,c.jsx)("label",{className:"timeline-panel__label",children:t("标题")}),(0,c.jsx)("input",{className:"timeline-panel__input",value:je.event.title,onChange:e=>oe(je.event.id,{title:e.target.value})}),(0,c.jsx)("label",{className:"timeline-panel__label",children:t("描述")}),(0,c.jsx)("textarea",{className:"timeline-panel__textarea",readOnly:!w,value:je.event.desc??"",onChange:e=>oe(je.event.id,{desc:e.target.value})}),(0,c.jsx)("label",{className:"timeline-panel__label",children:t("时间")}),(0,c.jsxs)("div",{className:"timeline-panel__times",children:[(0,c.jsx)("input",{className:"timeline-panel__input",value:je.event.startTime??"",placeholder:t("起始时间"),onChange:e=>oe(je.event.id,{startTime:e.target.value})}),(0,c.jsx)("input",{className:"timeline-panel__input",value:je.event.endTime??"",placeholder:t("结束时间"),onChange:e=>oe(je.event.id,{endTime:e.target.value})})]}),(0,c.jsx)("label",{className:"timeline-panel__label",children:t("图片地址")}),(0,c.jsx)("input",{className:"timeline-panel__input",value:je.event.image??"",placeholder:"https://...",onChange:e=>oe(je.event.id,{image:e.target.value})}),(0,c.jsx)("label",{className:"timeline-panel__label",children:t("方向")}),(0,c.jsxs)("div",{className:"timeline-panel__seg",children:[(0,c.jsx)("button",{type:"button",className:"timeline-seg__btn"+("left"===je.event.side?" timeline-seg__btn--on":""),onClick:()=>oe(je.event.id,{side:"left"}),children:t(K?"左侧":"上侧")}),(0,c.jsx)("button",{type:"button",className:"timeline-seg__btn"+("right"===je.event.side?" timeline-seg__btn--on":""),onClick:()=>oe(je.event.id,{side:"right"}),children:t(K?"右侧":"下侧")})]}),(0,c.jsx)("label",{className:"timeline-panel__label",children:t("颜色")}),(0,c.jsxs)("div",{className:"timeline-panel__colors",children:[(0,c.jsx)("span",{className:"timeline-swatch timeline-swatch--auto",title:t("跟随阶段"),onClick:()=>oe(je.event.id,{color:""})}),r.Tw.map(e=>(0,c.jsx)("span",{className:"timeline-swatch",style:{background:e},onClick:()=>oe(je.event.id,{color:e})},e)),(0,c.jsx)("label",{className:"timeline-swatch timeline-swatch--pick",title:t("自定义颜色"),children:(0,c.jsx)("input",{type:"color",value:je.event.color||ye?.color||Ne.axis_color,onChange:e=>oe(je.event.id,{color:e.target.value})})})]}),(0,c.jsx)("div",{className:"timeline-panel__hint",children:t("用上移下移调整事件顺序,用左右切换事件所在侧")}),(0,c.jsxs)("div",{className:"timeline-panel__insert",children:[(0,c.jsxs)("button",{type:"button",className:"timeline-panel__add",onClick:()=>he(je.event.id,-1),children:[(0,c.jsx)("span",{className:"material-icons",children:"arrow_upward"}),t("上移")]}),(0,c.jsxs)("button",{type:"button",className:"timeline-panel__add",onClick:()=>he(je.event.id,1),children:[(0,c.jsx)("span",{className:"material-icons",children:"arrow_downward"}),t("下移")]})]}),(0,c.jsxs)("button",{type:"button",className:"timeline-panel__del",onClick:()=>ve(je.event.id),children:[(0,c.jsx)("span",{className:"material-icons",children:"delete"}),t("删除事件")]})]})]}),u&&(0,c.jsx)("div",{className:"timeline-mask",children:"Loading..."}),p&&(0,c.jsx)("div",{className:"timeline-mask",children:p})]})}function h(e){const{phase:t,layout:n,zoom:i,vertical:l,selected_id:a,t:r}=e,u=t.color||n.axis_color,m=!!t.collapsed,h=(0,s.useRef)(null);(0,s.useLayoutEffect)(()=>{const n=h.current;if(!n||!1===t.head_visible)return;const s=()=>e.on_head_height(t.id,n.offsetHeight);s();const i=new ResizeObserver(s);return i.observe(n),()=>i.disconnect()},[t.id,t.name,t.desc,t.head_visible]);const _=e.head_height??o,v=(()=>{const s=l?96:240,i={left:0,right:0};return t.events.forEach((t,l)=>{const a=n.alternate?l%2==0?"left":"right":t.side;i[a]+=(e.event_heights[t.id]??s)+12}),d+_+6+Math.max(i.left,i.right)})(),x=m?Math.max(o,d+_+6)+10:v,b="solid"===n.line_style?{background:u}:{borderColor:u,borderStyle:(g=n.line_style,"dashed"===g?"dashed":"dotted"===g?"dotted":"solid")};var g;return(0,c.jsxs)("div",{className:`timeline-phase${m?" timeline-phase--collapsed":""}${e.drag_phase_id===t.id?" timeline-phase--dragging":""}`,style:l?{height:`${x}px`}:{width:`${x}px`},children:[(0,c.jsx)("div",{className:"timeline-phase__band",style:b}),!1!==t.head_visible&&(0,c.jsxs)("div",{className:"timeline-phase__head",ref:h,style:{borderColor:u,...t.head_width?{width:t.head_width,maxWidth:"none"}:{}},onPointerDown:n=>{const s=n.target;s.closest(".timeline-phase__op")||s.closest(".timeline-phase__drag")||s.closest(".timeline-phase__toggle")||e.on_select_phase(t.id)},children:[(0,c.jsx)("span",{className:"material-icons timeline-phase__drag",title:r("拖动排序"),onPointerDown:t=>{t.stopPropagation(),t.preventDefault(),e.on_phase_drag_start(e.phase_index)},children:"drag_indicator"}),(0,c.jsx)("span",{className:"material-icons timeline-phase__toggle",title:r(m?"展开":"折叠"),onClick:()=>e.on_update_phase(t.id,{collapsed:!m}),children:m?"expand_more":"expand_less"}),(0,c.jsx)("div",{className:"timeline-phase__name",style:{color:u},title:t.name,children:t.name}),t.desc&&(0,c.jsx)("div",{className:"timeline-phase__desc",title:t.desc,children:t.desc}),(0,c.jsx)("div",{className:"timeline-phase__width","data-phase-width":t.id,title:r("拖动调整宽度"),onPointerDown:t=>{t.stopPropagation(),t.preventDefault(),e.on_phase_width_down(t,e.phase_index)}})]}),!m&&(0,c.jsxs)(c.Fragment,{children:[!1===t.head_visible&&(0,c.jsx)("span",{className:"material-icons timeline-phase__show-head",title:r("显示阶段头"),onClick:()=>e.on_update_phase(t.id,{head_visible:!0}),children:"visibility"}),(()=>{const o=e=>n.alternate?e%2==0?"left":"right":t.events[e].side,u=l?96:240,m=t=>e.event_heights[t]??u,h={left:0,right:0},v=t.events.map((e,t)=>{const n=o(t),s=h[n];return h[n]=s+m(e.id)+12,s});return t.events.map((u,h)=>{const x=o(h),b=d+_+6+v[h]+m(u.id)/2,g=n.node_style;return(0,c.jsxs)(s.Fragment,{children:[u.startTime&&(0,c.jsx)("div",{className:`timeline-event__time timeline-event__time--start timeline-event--node-${g}`,style:l?{top:b}:{left:b},children:u.startTime}),u.endTime&&(0,c.jsx)("div",{className:`timeline-event__time timeline-event__time--end timeline-event--node-${g}`,style:l?{top:b}:{left:b},children:u.endTime}),(0,c.jsx)(p,{event:u,phase:t,layout:n,vertical:l,zoom:i,side:x,along:v[h],head_size:_,on_height:t=>e.on_event_height(u.id,t),event_index:h,phase_index:e.phase_index,selected:a===u.id,on_down:e.on_event_down,on_width_down:e.on_width_down,on_link_down:e.on_link_down,on_delete:e.on_delete_event,t:r})]},u.id)})})()]})]})}function p(e){const{event:t,phase:n,layout:i,vertical:l,zoom:a,side:r,selected:m,t:h}=e,p=t.color||n.color||i.axis_color,_=(0,s.useRef)(null);(0,s.useLayoutEffect)(()=>{const t=_.current;if(!t||!e.on_height)return;const n="vertical"===i.direction,s=()=>{const s=t.getBoundingClientRect(),i=Math.round((n?s.height:s.width)/a);i>0&&e.on_height(i)};s();const l=new ResizeObserver(s);l.observe(t);const r=window.setTimeout(s,300);return()=>{l.disconnect(),window.clearTimeout(r)}},[t.title,t.desc,t.image,t.width,a,i.direction,e.on_height]);const v=`${d+(e.head_size??o)+6+e.along}px`,x={"--ev-color":p};null!=t.link_length&&(x["--side-gap"]=`${t.link_length}px`);const b=l?{top:v}:{left:v};return t.width&&(b.width=`${t.width}px`),(0,c.jsxs)("div",{className:`timeline-event timeline-event--${i.card_style} timeline-event--side-${r} timeline-event--node-${i.node_style}`+(m?" timeline-event--on":"")+(i.show_connector?" timeline-event--linked":""),ref:_,style:{...b,...x,borderColor:p},onPointerDown:t=>e.on_down(t,e.phase_index,e.event_index),children:[i.show_connector&&(0,c.jsx)("div",{className:"timeline-event__link",style:{borderColor:p,borderStyle:i.line_style}}),(0,c.jsx)("div",{className:`timeline-node ${u(i.node_style)}`,style:{background:"image"===i.node_style&&t.image?"transparent":p},children:"image"===i.node_style&&t.image?(0,c.jsx)("img",{src:t.image,alt:""}):null}),(0,c.jsxs)("div",{className:"timeline-event__body",children:[(0,c.jsx)("div",{className:"timeline-event__title",style:{color:p},children:t.title||h("未命名")}),t.desc&&(0,c.jsx)("div",{className:"timeline-event__desc",children:t.desc})]}),(0,c.jsx)("div",{className:"timeline-event__width","data-event-width":t.id,title:h("拖动调整卡片宽度"),onPointerDown:t=>{t.stopPropagation(),t.preventDefault(),e.on_width_down(t,e.phase_index,e.event_index,r)}}),i.show_connector&&(0,c.jsx)("div",{className:"timeline-event__link-handle","data-event-link":t.id,title:h("拖动调整连线长度"),onPointerDown:t=>{t.stopPropagation(),t.preventDefault(),e.on_link_down(t,e.phase_index,e.event_index,r)}}),(0,c.jsx)("span",{className:"material-icons timeline-event__del",title:h("删除事件"),onClick:n=>{n.stopPropagation(),e.on_delete(t.id)},children:"close"})]})}}}]);